@saasquatch/squatch-js 2.8.3-0 → 2.8.3-1

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.
@@ -1,29 +1,34 @@
1
- var ye = Object.defineProperty;
2
- var Ee = (o, t, e) => t in o ? ye(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
- var l = (o, t, e) => Ee(o, typeof t != "symbol" ? t + "" : t, e);
4
- let P = null;
5
- function Ce(o) {
1
+ var Ee = Object.defineProperty;
2
+ var Ce = (o, t, e) => t in o ? Ee(o, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : o[t] = e;
3
+ var l = (o, t, e) => Ce(o, typeof t != "symbol" ? t + "" : t, e);
4
+ let C = null;
5
+ function Ae(o) {
6
6
  const e = o.replace(/[.+?^${}()|[\]\\]/g, "\\$&").replace(/\*/g, ".*");
7
- P = new RegExp(`^${e}$`);
7
+ C = new RegExp(`^${e}$`);
8
8
  }
9
- function ve() {
10
- P = null;
9
+ function Ie() {
10
+ C = null;
11
11
  }
12
- function E(o) {
13
- return (...t) => {
14
- P && P.test(o) && console.log(`[${o}]`, ...t);
12
+ function k(o) {
13
+ const t = (...e) => {
14
+ C && C.test(o) && console.log(`[${o}]`, ...e);
15
15
  };
16
+ return Object.defineProperty(t, "enabled", {
17
+ get() {
18
+ return !!(C && C.test(o));
19
+ }
20
+ }), t;
16
21
  }
17
22
  /*! js-cookie v3.0.5 | MIT */
18
- function T(o) {
23
+ function S(o) {
19
24
  for (var t = 1; t < arguments.length; t++) {
20
25
  var e = arguments[t];
21
- for (var i in e)
22
- o[i] = e[i];
26
+ for (var n in e)
27
+ o[n] = e[n];
23
28
  }
24
29
  return o;
25
30
  }
26
- var be = {
31
+ var _e = {
27
32
  read: function(o) {
28
33
  return o[0] === '"' && (o = o.slice(1, -1)), o.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
29
34
  },
@@ -35,47 +40,47 @@ var be = {
35
40
  }
36
41
  };
37
42
  function G(o, t) {
38
- function e(n, s, r) {
43
+ function e(i, s, r) {
39
44
  if (!(typeof document > "u")) {
40
- r = T({}, t, r), typeof r.expires == "number" && (r.expires = new Date(Date.now() + r.expires * 864e5)), r.expires && (r.expires = r.expires.toUTCString()), n = encodeURIComponent(n).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
45
+ r = S({}, t, r), typeof r.expires == "number" && (r.expires = new Date(Date.now() + r.expires * 864e5)), r.expires && (r.expires = r.expires.toUTCString()), i = encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
41
46
  var a = "";
42
- for (var c in r)
43
- r[c] && (a += "; " + c, r[c] !== !0 && (a += "=" + r[c].split(";")[0]));
44
- return document.cookie = n + "=" + o.write(s, n) + a;
47
+ for (var d in r)
48
+ r[d] && (a += "; " + d, r[d] !== !0 && (a += "=" + r[d].split(";")[0]));
49
+ return document.cookie = i + "=" + o.write(s, i) + a;
45
50
  }
46
51
  }
47
- function i(n) {
48
- if (!(typeof document > "u" || arguments.length && !n)) {
52
+ function n(i) {
53
+ if (!(typeof document > "u" || arguments.length && !i)) {
49
54
  for (var s = document.cookie ? document.cookie.split("; ") : [], r = {}, a = 0; a < s.length; a++) {
50
- var c = s[a].split("="), d = c.slice(1).join("=");
55
+ var d = s[a].split("="), c = d.slice(1).join("=");
51
56
  try {
52
- var h = decodeURIComponent(c[0]);
53
- if (r[h] = o.read(d, h), n === h)
57
+ var h = decodeURIComponent(d[0]);
58
+ if (r[h] = o.read(c, h), i === h)
54
59
  break;
55
60
  } catch {
56
61
  }
57
62
  }
58
- return n ? r[n] : r;
63
+ return i ? r[i] : r;
59
64
  }
60
65
  }
61
66
  return Object.create(
62
67
  {
63
68
  set: e,
64
- get: i,
65
- remove: function(n, s) {
69
+ get: n,
70
+ remove: function(i, s) {
66
71
  e(
67
- n,
72
+ i,
68
73
  "",
69
- T({}, s, {
74
+ S({}, s, {
70
75
  expires: -1
71
76
  })
72
77
  );
73
78
  },
74
- withAttributes: function(n) {
75
- return G(this.converter, T({}, this.attributes, n));
79
+ withAttributes: function(i) {
80
+ return G(this.converter, S({}, this.attributes, i));
76
81
  },
77
- withConverter: function(n) {
78
- return G(T({}, this.converter, n), this.attributes);
82
+ withConverter: function(i) {
83
+ return G(S({}, this.converter, i), this.attributes);
79
84
  }
80
85
  },
81
86
  {
@@ -84,21 +89,21 @@ function G(o, t) {
84
89
  }
85
90
  );
86
91
  }
87
- var S = G(be, { path: "/" });
88
- const A = "https://app.referralsaasquatch.com", z = "https://fast.ssqt.io/npm", U = "squatch", J = "impact";
89
- function W(o) {
92
+ var M = G(_e, { path: "/" });
93
+ const A = "https://app.referralsaasquatch.com", V = "https://fast.ssqt.io/npm", R = "squatch", z = "impact";
94
+ function q(o) {
90
95
  if (typeof o != "object") throw new Error("config must be an object");
91
- const t = window.squatchTenant, e = Q(), i = {
96
+ const t = window.squatchTenant, e = Y(), n = {
92
97
  tenantAlias: (o == null ? void 0 : o.tenantAlias) || t,
93
98
  domain: (o == null ? void 0 : o.domain) || (e == null ? void 0 : e.domain),
94
99
  npmCdn: (o == null ? void 0 : o.npmCdn) || (e == null ? void 0 : e.npmCdn),
95
100
  debug: (o == null ? void 0 : o.debug) || (e == null ? void 0 : e.debug)
96
101
  };
97
- if (typeof i.tenantAlias != "string")
102
+ if (typeof n.tenantAlias != "string")
98
103
  throw new Error("tenantAlias not provided");
99
- const n = i.tenantAlias, s = typeof i.domain == "string" && i.domain || A, r = typeof i.debug == "boolean" && i.debug || !1, a = typeof i.npmCdn == "string" && i.npmCdn || z;
104
+ const i = n.tenantAlias, s = typeof n.domain == "string" && n.domain || A, r = typeof n.debug == "boolean" && n.debug || !1, a = typeof n.npmCdn == "string" && n.npmCdn || V;
100
105
  return {
101
- tenantAlias: n,
106
+ tenantAlias: i,
102
107
  domain: s,
103
108
  debug: r,
104
109
  npmCdn: a
@@ -107,30 +112,30 @@ function W(o) {
107
112
  function I(o) {
108
113
  return typeof o == "object" && !Array.isArray(o) && o !== null;
109
114
  }
110
- function Ae(o) {
115
+ function Te(o) {
111
116
  if (o && /^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(o))
112
117
  return o;
113
118
  }
114
- function se(o) {
119
+ function ce(o) {
115
120
  if (!I(o)) throw new Error("Widget properties must be an object");
116
121
  if (!(o != null && o.user)) throw new Error("Required properties missing.");
117
122
  return o;
118
123
  }
119
- function re(o) {
124
+ function le(o) {
120
125
  if (!I(o)) throw new Error("Widget properties must be an object");
121
126
  return o;
122
127
  }
123
- function q() {
128
+ function W() {
124
129
  return window.impactToken || window.squatchToken;
125
130
  }
126
- function Q() {
131
+ function Y() {
127
132
  return window.impactConfig || window.squatchConfig;
128
133
  }
129
- async function Ie(o, t, e, i) {
130
- const n = i || q(), s = {
134
+ async function $e(o, t, e, n) {
135
+ const i = n || W(), s = {
131
136
  Accept: "application/json",
132
137
  "Content-Type": "application/json",
133
- ...n ? { Authorization: `Bearer ${n}` } : {},
138
+ ...i ? { Authorization: `Bearer ${i}` } : {},
134
139
  "X-SaaSquatch-Referrer": window ? window.location.href : ""
135
140
  };
136
141
  try {
@@ -145,35 +150,35 @@ async function Ie(o, t, e, i) {
145
150
  throw r;
146
151
  }
147
152
  }
148
- async function _e(o, t = "") {
153
+ async function qe(o, t = "") {
149
154
  const e = {
150
155
  Accept: "application/json",
151
156
  "Content-Type": "application/json"
152
- }, i = t || q();
153
- i && (e["X-SaaSquatch-User-Token"] = i);
157
+ }, n = t || W();
158
+ n && (e["X-SaaSquatch-User-Token"] = n);
154
159
  try {
155
- const n = await fetch(o, {
160
+ const i = await fetch(o, {
156
161
  method: "GET",
157
162
  credentials: "include",
158
163
  headers: e
159
- }), s = await n.text();
160
- if (!n.ok) throw new Error(s);
164
+ }), s = await i.text();
165
+ if (!i.ok) throw new Error(s);
161
166
  return s && JSON.parse(s);
162
- } catch (n) {
163
- throw n;
167
+ } catch (i) {
168
+ throw i;
164
169
  }
165
170
  }
166
- async function V(o, t, e) {
167
- const i = {
171
+ async function X(o, t, e) {
172
+ const n = {
168
173
  Accept: "application/json",
169
174
  "Content-Type": "application/json"
170
- }, n = e || q();
171
- n && (i["X-SaaSquatch-User-Token"] = n);
175
+ }, i = e || W();
176
+ i && (n["X-SaaSquatch-User-Token"] = i);
172
177
  try {
173
178
  const s = await fetch(o, {
174
179
  method: "POST",
175
180
  body: t,
176
- headers: i
181
+ headers: n
177
182
  }), r = await s.text();
178
183
  if (!s.ok) throw new Error(r);
179
184
  return r && JSON.parse(r);
@@ -181,16 +186,16 @@ async function V(o, t, e) {
181
186
  throw s;
182
187
  }
183
188
  }
184
- async function ke(o, t, e) {
185
- const i = {
189
+ async function We(o, t, e) {
190
+ const n = {
186
191
  Accept: "application/json",
187
192
  "Content-Type": "application/json",
188
193
  "X-SaaSquatch-Referrer": window ? window.location.href : ""
189
- }, n = e || q();
190
- n && (i["X-SaaSquatch-User-Token"] = n);
194
+ }, i = e || W();
195
+ i && (n["X-SaaSquatch-User-Token"] = i);
191
196
  try {
192
197
  const s = await fetch(o, {
193
- headers: i,
198
+ headers: n,
194
199
  method: "PUT",
195
200
  credentials: "include",
196
201
  body: t
@@ -201,7 +206,7 @@ async function ke(o, t, e) {
201
206
  throw s;
202
207
  }
203
208
  }
204
- const xe = `
209
+ const Se = `
205
210
  query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {
206
211
  renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {
207
212
  template
@@ -216,7 +221,7 @@ const xe = `
216
221
  }
217
222
  }
218
223
  `;
219
- class Y {
224
+ class K {
220
225
  /**
221
226
  * Initialize a new {@link WidgetApi} instance.
222
227
  *
@@ -238,8 +243,8 @@ class Y {
238
243
  l(this, "domain");
239
244
  l(this, "npmCdn");
240
245
  l(this, "referralCookie", this.squatchReferralCookie);
241
- const i = W(t);
242
- this.tenantAlias = i.tenantAlias, this.domain = i.domain, this.npmCdn = i.npmCdn;
246
+ const n = q(t);
247
+ this.tenantAlias = n.tenantAlias, this.domain = n.domain, this.npmCdn = n.npmCdn;
243
248
  }
244
249
  /**
245
250
  * Creates/upserts user, requests widget template.
@@ -256,18 +261,18 @@ class Y {
256
261
  * @return {Promise} string if true, with the widget template, jsOptions and user details.
257
262
  */
258
263
  upsertUser(t) {
259
- const i = se(t), {
260
- widgetType: n,
264
+ const n = ce(t), {
265
+ widgetType: i,
261
266
  engagementMedium: s = "POPUP",
262
267
  jwt: r,
263
268
  locale: a,
264
- user: c
265
- } = i, d = encodeURIComponent(this.tenantAlias), h = c.accountId ? encodeURIComponent(c.accountId) : null, u = c.id ? encodeURIComponent(c.id) : null, m = We({
266
- widgetType: n,
269
+ user: d
270
+ } = n, c = encodeURIComponent(this.tenantAlias), h = d.accountId ? encodeURIComponent(d.accountId) : null, u = d.id ? encodeURIComponent(d.id) : null, p = Re({
271
+ widgetType: i,
267
272
  engagementMedium: s,
268
273
  locale: a
269
- }), p = `/api/v1/${d}/widget/account/${h}/user/${u}/upsert${m}`, g = this.domain + p, f = (S || window.Cookies).get("_saasquatch");
270
- return f && (c.cookies = f), ke(g, JSON.stringify(c), r);
274
+ }), g = `/api/v1/${c}/widget/account/${h}/user/${u}/upsert${p}`, m = this.domain + g, w = (M || window.Cookies).get("_saasquatch");
275
+ return w && (d.cookies = w), We(m, JSON.stringify(d), r);
271
276
  }
272
277
  /**
273
278
  * Requests widget template
@@ -283,24 +288,24 @@ class Y {
283
288
  * @return {Promise} template html if true.
284
289
  */
285
290
  render(t) {
286
- const i = re(t), { widgetType: n, engagementMedium: s = "POPUP", jwt: r, user: a } = i, c = encodeURIComponent(this.tenantAlias), d = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = i.locale ?? Ae(navigator.language.replace(/\-/g, "_")), m = `/api/v1/${c}/graphql`, p = this.domain + m;
287
- return new Promise(async (g, f) => {
288
- var _;
291
+ const n = le(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, d = encodeURIComponent(this.tenantAlias), c = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ?? Te(navigator.language.replace(/\-/g, "_")), p = `/api/v1/${d}/graphql`, g = this.domain + p;
292
+ return new Promise(async (m, w) => {
293
+ var b;
289
294
  try {
290
- const C = await Ie(
291
- p,
292
- xe,
295
+ const f = await $e(
296
+ g,
297
+ Se,
293
298
  {
294
- user: h && d ? { id: h, accountId: d } : null,
299
+ user: h && c ? { id: h, accountId: c } : null,
295
300
  engagementMedium: s,
296
- widgetType: n,
301
+ widgetType: i,
297
302
  locale: u
298
303
  },
299
304
  r
300
305
  );
301
- g((_ = C == null ? void 0 : C.data) == null ? void 0 : _.renderWidget);
302
- } catch (C) {
303
- f(C);
306
+ m((b = f == null ? void 0 : f.data) == null ? void 0 : b.renderWidget);
307
+ } catch (f) {
308
+ w(f);
304
309
  }
305
310
  });
306
311
  }
@@ -310,35 +315,35 @@ class Y {
310
315
  * @return {Promise<ReferralCookie>} code referral code if true.
311
316
  */
312
317
  async squatchReferralCookie() {
313
- const t = encodeURIComponent(this.tenantAlias), e = (S || window.Cookies).get("_saasquatch") || "", i = e ? `?cookies=${encodeURIComponent(e)}` : "", n = `${this.domain}/a/${t}/widgets/squatchcookiejson${i}`, s = await _e(n);
318
+ const t = encodeURIComponent(this.tenantAlias), e = (M || window.Cookies).get("_saasquatch") || "", n = e ? `?cookies=${encodeURIComponent(e)}` : "", i = `${this.domain}/a/${t}/widgets/squatchcookiejson${n}`, s = await qe(i);
314
319
  return Promise.resolve({
315
320
  ...s,
316
321
  encodedCookie: e
317
322
  });
318
323
  }
319
324
  }
320
- function We({
325
+ function Re({
321
326
  widgetType: o,
322
327
  engagementMedium: t,
323
328
  locale: e
324
329
  }) {
325
- const i = new URLSearchParams();
326
- return i.append("engagementMedium", t), o && i.append("widgetType", o), e && i.append("locale", e), `?${i.toString()}`;
330
+ const n = new URLSearchParams();
331
+ return n.append("engagementMedium", t), o && n.append("widgetType", o), e && n.append("locale", e), `?${n.toString()}`;
327
332
  }
328
333
  /*!
329
334
  * domready (c) Dustin Diaz 2014 - License MIT
330
335
  *
331
336
  */
332
- function X(o, t) {
333
- let e = [], i, n = o, s = n.documentElement.doScroll, r = "DOMContentLoaded", a = (s ? /^loaded|^c/ : /^loaded|^i|^c/).test(n.readyState);
334
- return a || n.addEventListener(
337
+ function Q(o, t) {
338
+ let e = [], n, i = o, s = i.documentElement.doScroll, r = "DOMContentLoaded", a = (s ? /^loaded|^c/ : /^loaded|^i|^c/).test(i.readyState);
339
+ return a || i.addEventListener(
335
340
  r,
336
- i = () => {
337
- for (n.removeEventListener(r, i), a = !0; i = e.shift(); ) i();
341
+ n = () => {
342
+ for (i.removeEventListener(r, n), a = !0; n = e.shift(); ) n();
338
343
  }
339
344
  ), a ? setTimeout(t, 0) : e.push(t);
340
345
  }
341
- function M({
346
+ function L({
342
347
  value: o,
343
348
  unit: t
344
349
  }) {
@@ -351,7 +356,7 @@ function M({
351
356
  return `${o}px`;
352
357
  }
353
358
  }
354
- class ae {
359
+ class he {
355
360
  /**
356
361
  * Initialize a new {@link AnalyticsApi} instance.
357
362
  *
@@ -361,26 +366,283 @@ class ae {
361
366
  */
362
367
  constructor(t) {
363
368
  l(this, "domain");
364
- var n;
365
- const i = qe(t);
366
- this.domain = (i == null ? void 0 : i.domain) || ((n = Q()) == null ? void 0 : n.domain) || A;
369
+ var i;
370
+ const n = Ue(t);
371
+ this.domain = (n == null ? void 0 : n.domain) || ((i = Y()) == null ? void 0 : i.domain) || A;
367
372
  }
368
373
  pushAnalyticsLoadEvent(t) {
369
374
  if (!t.externalUserId || !t.externalAccountId) return;
370
- const e = encodeURIComponent(t.tenantAlias), i = encodeURIComponent(t.externalAccountId), n = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = t.programId ? `&programId=${encodeURIComponent(t.programId)}` : "", a = `/a/${e}/widgets/analytics/loaded?externalAccountId=${i}&externalUserId=${n}&engagementMedium=${s}${r}`, c = this.domain + a;
371
- return V(c, JSON.stringify({}));
375
+ const e = encodeURIComponent(t.tenantAlias), n = encodeURIComponent(t.externalAccountId), i = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = t.programId ? `&programId=${encodeURIComponent(t.programId)}` : "", a = `/a/${e}/widgets/analytics/loaded?externalAccountId=${n}&externalUserId=${i}&engagementMedium=${s}${r}`, d = this.domain + a;
376
+ return X(d, JSON.stringify({}));
372
377
  }
373
378
  pushAnalyticsShareClickedEvent(t) {
374
- const e = encodeURIComponent(t.tenantAlias), i = encodeURIComponent(t.externalAccountId), n = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = encodeURIComponent(t.shareMedium), a = `/a/${e}/widgets/analytics/shared?externalAccountId=${i}&externalUserId=${n}&engagementMedium=${s}&shareMedium=${r}`, c = this.domain + a;
375
- return V(c, JSON.stringify({}));
379
+ const e = encodeURIComponent(t.tenantAlias), n = encodeURIComponent(t.externalAccountId), i = encodeURIComponent(t.externalUserId), s = encodeURIComponent(t.engagementMedium), r = encodeURIComponent(t.shareMedium), a = `/a/${e}/widgets/analytics/shared?externalAccountId=${n}&externalUserId=${i}&engagementMedium=${s}&shareMedium=${r}`, d = this.domain + a;
380
+ return X(d, JSON.stringify({}));
376
381
  }
377
382
  }
378
- function qe(o) {
383
+ function Ue(o) {
379
384
  if (!I(o)) throw new Error("'options' should be an object");
380
385
  return o;
381
386
  }
382
- const w = E("squatch-js:widget");
383
- class ce {
387
+ const ue = ({
388
+ type: o = "verified-access",
389
+ height: t = "500px"
390
+ }) => {
391
+ const e = "#e0e0e0";
392
+ return `
393
+ <style>
394
+ * {
395
+ box-sizing: border-box;
396
+ padding: 0;
397
+ margin: 0;
398
+ }
399
+
400
+ .widget-container {
401
+ background: white;
402
+ width: 100%;
403
+ padding: 40px;
404
+ box-sizing: border-box;
405
+ overflow: hidden;
406
+ }
407
+
408
+ @keyframes shimmer {
409
+ 0% { background-position: -100% 0; }
410
+ 100% { background-position: 100% 0; }
411
+ }
412
+
413
+ .skeleton {
414
+ background: ${e};
415
+ background: linear-gradient(
416
+ 90deg,
417
+ ${e} 25%,
418
+ #f5f5f5 50%,
419
+ ${e} 75%
420
+ );
421
+ background-size: 200% 100%;
422
+ animation: shimmer 1.5s infinite linear;
423
+ border-radius: 6px;
424
+ margin-bottom: 12px;
425
+ }
426
+
427
+ /* Typography Skeletons */
428
+ .sk-title-lg { height: 36px; width: 80%; margin-bottom: 16px; }
429
+ .sk-title-md { height: 28px; width: 30%; margin-bottom: 20px; margin-top: 40px; }
430
+ .sk-text { height: 16px; width: 90%; margin-bottom: 8px; }
431
+ .sk-text-short { width: 40%; }
432
+ .sk-label { height: 14px; width: 25%; margin-bottom: 10px; }
433
+
434
+ /* Layouts */
435
+ .hero-section {
436
+ display: flex;
437
+ gap: 40px;
438
+ margin-bottom: 40px;
439
+ padding-bottom: 40px;
440
+ flex-direction: row;
441
+ height: 100%;
442
+ /* Removed border-bottom */
443
+ }
444
+
445
+ .hero-content {
446
+ flex: 1;
447
+ display: flex;
448
+ flex-direction: column;
449
+ justify-content: center;
450
+ }
451
+
452
+ .hero-image {
453
+ flex: 1;
454
+ height: 300px;
455
+ border-radius: 12px;
456
+ }
457
+
458
+ /* -- Specific Instant Access Overrides -- */
459
+ .instant-access-layout {
460
+ margin-bottom: 0;
461
+ padding-bottom: 0;
462
+ align-items: center;
463
+ }
464
+ .ia-image {
465
+ height: 400px;
466
+ }
467
+ .ia-center {
468
+ margin-left: auto;
469
+ margin-right: auto;
470
+ }
471
+ .ia-content {
472
+ align-items: center;
473
+ text-align: center;
474
+ }
475
+ .sk-btn-action {
476
+ height: 45px;
477
+ width: 140px;
478
+ border-radius: 6px;
479
+ margin: 24px auto;
480
+ }
481
+ .input-group {
482
+ display: flex;
483
+ gap: 10px;
484
+ width: 100%;
485
+ max-width: 400px;
486
+ }
487
+ .sk-btn-copy {
488
+ height: 50px;
489
+ width: 120px;
490
+ border-radius: 8px;
491
+ }
492
+ /* ------------------------------------- */
493
+
494
+ .share-section { margin-bottom: 40px; }
495
+ .sk-input { height: 50px; width: 100%; border-radius: 8px; margin-bottom: 16px; }
496
+
497
+ .social-buttons { display: flex; gap: 12px; }
498
+ .sk-btn-social { flex: 1; height: 50px; border-radius: 8px; }
499
+
500
+ .stats-section {
501
+ display: flex;
502
+ gap: 24px;
503
+ margin-bottom: 40px;
504
+ padding: 30px 0;
505
+ /* Removed border-top and border-bottom */
506
+ }
507
+ .stat-card { flex: 1; display: flex; flex-direction: column; align-items: center; }
508
+ .stat-divider { padding-left: 24px; }
509
+ .sk-stat-num { height: 48px; width: 120px; margin-bottom: 8px; }
510
+ .sk-stat-label { height: 18px; width: 80px; }
511
+
512
+ /* Table Styles */
513
+ .table-header { display: flex; gap: 16px; margin-bottom: 16px; }
514
+ .sk-th { height: 16px; }
515
+ .table-row {
516
+ display: flex;
517
+ align-items: center;
518
+ gap: 16px;
519
+ padding: 16px 0;
520
+ /* Removed border-bottom */
521
+ }
522
+
523
+ .col-user { flex: 2; }
524
+ .col-status { flex: 1; }
525
+ .col-reward { flex: 2; }
526
+ .col-date { flex: 1; }
527
+
528
+ .sk-badge { height: 28px; width: 90px; border-radius: 14px; }
529
+ .sk-reward-block { height: 36px; width: 100%; border-radius: 6px; }
530
+
531
+ .pagination { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
532
+ .sk-btn-page { height: 36px; width: 64px; border-radius: 6px; margin-bottom: 0; }
533
+
534
+ @media (max-width: 768px) {
535
+ body { padding: 20px; }
536
+ .widget-container { padding: 24px; }
537
+
538
+ .hero-section { flex-direction: column-reverse; gap: 24px; }
539
+ .instant-access-layout { flex-direction: column; }
540
+
541
+ .hero-image { height: 220px; width: 100%; }
542
+ .sk-title-lg { width: 100%; }
543
+
544
+ .col-date { display: none; }
545
+ }
546
+ </style>
547
+
548
+ <div class="widget-container">
549
+ ${o === "verified-access" ? `
550
+ <div class="hero-section">
551
+ <div class="hero-content">
552
+ <div class="skeleton sk-title-lg"></div>
553
+ <div class="skeleton sk-text"></div>
554
+ <div class="skeleton sk-text sk-text-short"></div>
555
+ </div>
556
+ <div class="skeleton hero-image"></div>
557
+ </div>
558
+
559
+ <div class="share-section">
560
+ <div class="skeleton sk-label"></div>
561
+ <div class="skeleton sk-input"></div>
562
+ <div class="social-buttons">
563
+ <div class="skeleton sk-btn-social"></div>
564
+ <div class="skeleton sk-btn-social"></div>
565
+ <div class="skeleton sk-btn-social"></div>
566
+ <div class="skeleton sk-btn-social"></div>
567
+ </div>
568
+ </div>
569
+
570
+ <div class="skeleton sk-title-md" style="margin-top: 0; width: 30%; margin-left: auto; margin-right: auto"></div>
571
+ <div class="skeleton sk-text" style="width: 60%; margin-left: auto; margin-right: auto"></div>
572
+
573
+ <div class="stats-section">
574
+ <div class="stat-card">
575
+ <div class="skeleton sk-stat-num"></div>
576
+ <div class="skeleton sk-stat-label"></div>
577
+ </div>
578
+ <div class="stat-card stat-divider">
579
+ <div class="skeleton sk-stat-num"></div>
580
+ <div class="skeleton sk-stat-label"></div>
581
+ </div>
582
+ </div>
583
+
584
+ <div class="skeleton sk-title-md"></div>
585
+
586
+ <div class="table-header">
587
+ <div class="skeleton sk-th col-user"></div>
588
+ <div class="skeleton sk-th col-status"></div>
589
+ <div class="skeleton sk-th col-reward"></div>
590
+ <div class="skeleton sk-th col-date"></div>
591
+ </div>
592
+
593
+ <div class="table-row">
594
+ <div class="col-user"><div class="skeleton sk-text" style="width: 70%; margin: 0"></div></div>
595
+ <div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
596
+ <div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
597
+ <div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
598
+ </div>
599
+
600
+ <div class="table-row">
601
+ <div class="col-user"><div class="skeleton sk-text" style="width: 60%; margin: 0"></div></div>
602
+ <div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
603
+ <div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
604
+ <div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
605
+ </div>
606
+
607
+ <div class="table-row">
608
+ <div class="col-user"><div class="skeleton sk-text" style="width: 75%; margin: 0"></div></div>
609
+ <div class="col-status"><div class="skeleton sk-badge" style="margin: 0"></div></div>
610
+ <div class="col-reward"><div class="skeleton sk-reward-block" style="margin: 0"></div></div>
611
+ <div class="col-date"><div class="skeleton sk-text" style="width: 80%; margin: 0"></div></div>
612
+ </div>
613
+
614
+ <div class="pagination">
615
+ <div class="skeleton sk-btn-page"></div>
616
+ <div class="skeleton sk-btn-page"></div>
617
+ </div>
618
+ ` : `
619
+ <div class="hero-section instant-access-layout">
620
+ <div class="skeleton hero-image ia-image"></div>
621
+
622
+ <div class="hero-content ia-content">
623
+ <div class="skeleton sk-title-lg ia-center"></div>
624
+ <div class="skeleton sk-text ia-center"></div>
625
+
626
+ <div class="skeleton sk-btn-action"></div>
627
+
628
+ <div class="skeleton sk-label"></div>
629
+ <div class="input-group">
630
+ <div class="skeleton sk-input"></div>
631
+ <div class="skeleton sk-btn-copy"></div>
632
+ </div>
633
+
634
+ <div class="skeleton sk-text-short ia-center" style="margin-top: 20px; width: 30%"></div>
635
+ <div class="skeleton sk-text-short ia-center" style="width: 20%"></div>
636
+ </div>
637
+ </div>
638
+ `}
639
+ </div>
640
+ `;
641
+ }, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
642
+ __proto__: null,
643
+ getSkeleton: ue
644
+ }, Symbol.toStringTag, { value: "Module" })), y = k("squatch-js:widget");
645
+ class pe {
384
646
  constructor(t) {
385
647
  l(this, "type");
386
648
  l(this, "content");
@@ -391,11 +653,11 @@ class ce {
391
653
  l(this, "container");
392
654
  l(this, "loadEventListener", null);
393
655
  var e;
394
- w("widget initializing ..."), this.content = t.content === "error" ? this._error(t.rsCode) : t.content, this.type = t.type, this.widgetApi = t.api, this.npmCdn = t.npmCdn, this.analyticsApi = new ae({ domain: t.domain }), this.context = t.context, this.container = ((e = t.context) == null ? void 0 : e.container) || t.container;
656
+ y("widget initializing ..."), this.content = t.content === "error" ? this._error(t.rsCode) : t.content, this.type = t.type, this.widgetApi = t.api, this.npmCdn = t.npmCdn, this.analyticsApi = new he({ domain: t.domain }), this.context = t.context, this.container = ((e = t.context) == null ? void 0 : e.container) || t.container;
395
657
  }
396
658
  _findElement() {
397
659
  let t;
398
- if (typeof this.container == "string" ? (t = document.querySelector(this.container), w("loading widget with selector", t)) : this.container instanceof HTMLElement ? (t = this.container, w("loading widget with container", t)) : this.container ? (t = null, w("container must be an HTMLElement or string", this.container)) : (t = document.querySelector("#squatchembed") || document.querySelector(".squatchembed") || document.querySelector("#impactembed") || document.querySelector(".impactembed"), w("loading widget with default selector", t)), !(t instanceof HTMLElement))
660
+ if (typeof this.container == "string" ? (t = document.querySelector(this.container), y("loading widget with selector", t)) : this.container instanceof HTMLElement ? (t = this.container, y("loading widget with container", t)) : this.container ? (t = null, y("container must be an HTMLElement or string", this.container)) : (t = document.querySelector("#squatchembed") || document.querySelector(".squatchembed") || document.querySelector("#impactembed") || document.querySelector(".impactembed"), y("loading widget with default selector", t)), !(t instanceof HTMLElement))
399
661
  throw new Error(
400
662
  `element with selector '${this.container || "#squatchembed, .squatchembed, #impactembed, or .impactembed"}' not found.'`
401
663
  );
@@ -406,7 +668,7 @@ class ce {
406
668
  return e.squatchJsApi = this, e.id = "squatchFrame", e.width = "100%", e.src = "about:blank", e.scrolling = "no", e.setAttribute(
407
669
  "style",
408
670
  "border: 0; background-color: none; width: 1px; min-width: 100%;"
409
- ), t != null && t.minWidth && (e.style.minWidth = t.minWidth), t != null && t.maxWidth && (e.style.maxWidth = t.maxWidth), (t != null && t.maxWidth || t != null && t.minWidth) && (e.style.width = "100%"), t != null && t.initialHeight && (e.height = t.initialHeight), e;
671
+ ), t != null && t.minWidth && (e.style.minWidth = t.minWidth), t != null && t.maxWidth && (e.style.maxWidth = t.maxWidth), (t != null && t.maxWidth || t != null && t.minWidth) && (e.style.width = "100%"), t != null && t.initialHeight && (e.height = String(t.initialHeight)), e;
410
672
  }
411
673
  _findFrame() {
412
674
  const t = this.container ? this._findElement() : document.body;
@@ -421,16 +683,16 @@ class ce {
421
683
  ), this.loadEventListener = null);
422
684
  }
423
685
  _attachLoadEventListener(t, e) {
424
- this.loadEventListener === null && (this.loadEventListener = (i) => {
686
+ this.loadEventListener === null && (this.loadEventListener = (n) => {
425
687
  this._loadEvent({
426
688
  ...e,
427
- userId: i.detail.userId,
428
- accountId: i.detail.accountId
689
+ userId: n.detail.userId,
690
+ accountId: n.detail.accountId
429
691
  });
430
692
  }, t.addEventListener("sq:user-registration", this.loadEventListener));
431
693
  }
432
694
  _loadEvent(t) {
433
- var i;
695
+ var n;
434
696
  if (!t) return;
435
697
  if (!I(t))
436
698
  throw new Error("Widget Load event identity property is not an object");
@@ -446,18 +708,18 @@ class ce {
446
708
  programId: t.programId
447
709
  };
448
710
  } else {
449
- const { analytics: n, mode: s } = t;
711
+ const { analytics: i, mode: s } = t;
450
712
  e = {
451
- tenantAlias: n.attributes.tenant,
452
- externalAccountId: n.attributes.accountId,
453
- externalUserId: n.attributes.userId,
713
+ tenantAlias: i.attributes.tenant,
714
+ externalAccountId: i.attributes.accountId,
715
+ externalUserId: i.attributes.userId,
454
716
  engagementMedium: s.widgetMode
455
717
  };
456
718
  }
457
- (i = this.analyticsApi.pushAnalyticsLoadEvent(e)) == null || i.then((n) => {
458
- w(`${e.engagementMedium} loaded event recorded.`);
459
- }).catch((n) => {
460
- w(`ERROR: pushAnalyticsLoadEvent() ${n}`);
719
+ (n = this.analyticsApi.pushAnalyticsLoadEvent(e)) == null || n.then((i) => {
720
+ y(`${e.engagementMedium} loaded event recorded.`);
721
+ }).catch((i) => {
722
+ y(`ERROR: pushAnalyticsLoadEvent() ${i}`);
461
723
  });
462
724
  }
463
725
  _shareEvent(t, e) {
@@ -467,15 +729,15 @@ class ce {
467
729
  externalUserId: t.analytics.attributes.userId,
468
730
  engagementMedium: t.mode.widgetMode,
469
731
  shareMedium: e
470
- }).then((i) => {
471
- w(
472
- `${t.mode.widgetMode} share ${e} event recorded. ${i}`
732
+ }).then((n) => {
733
+ y(
734
+ `${t.mode.widgetMode} share ${e} event recorded. ${n}`
473
735
  );
474
- }).catch((i) => {
475
- w(`ERROR: pushAnalyticsShareClickedEvent() ${i}`);
736
+ }).catch((n) => {
737
+ y(`ERROR: pushAnalyticsShareClickedEvent() ${n}`);
476
738
  });
477
739
  }
478
- _error(t, e = "modal", i = "") {
740
+ _error(t, e = "modal", n = "") {
479
741
  return `<!DOCTYPE html>
480
742
  <!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]-->
481
743
  <!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]-->
@@ -483,7 +745,7 @@ class ce {
483
745
  <head>
484
746
  <link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">
485
747
  <style>
486
- ${i}
748
+ ${n}
487
749
  </style>
488
750
  </head>
489
751
  <body>
@@ -512,15 +774,38 @@ class ce {
512
774
  const { contentWindow: e } = t;
513
775
  if (!e)
514
776
  throw new Error("Squatch.js frame inner frame is empty");
515
- const i = e.document;
516
- function n() {
517
- const r = i.getElementsByTagName("sqh-global-container"), a = i.getElementsByClassName("squatch-container");
777
+ const n = e.document;
778
+ function i() {
779
+ const r = n.getElementsByTagName("sqh-global-container"), a = n.getElementsByClassName("squatch-container");
518
780
  return r.length > 0 ? r[0] : a.length > 0 ? a[0] : null;
519
781
  }
520
782
  let s = null;
521
- for (let r = 0; r < 5 && (s = n(), !s); r++)
522
- await Te(100);
523
- return s || i.body;
783
+ for (let r = 0; r < 5 && (s = i(), !s); r++)
784
+ await Me(100);
785
+ return s || n.body;
786
+ }
787
+ /**
788
+ * Returns HTML for an in-iframe skeleton preload overlay that is removed
789
+ * once all Stencil component chunks have loaded and been hydrated.
790
+ *
791
+ * Uses a MutationObserver to detect when components receive the `hydrated`
792
+ * class, debouncing removal so the skeleton stays visible until all chunks
793
+ * have finished loading. Includes a timeout fallback.
794
+ *
795
+ * Only generates content for mint-components widgets; returns empty string otherwise.
796
+ */
797
+ _getSkeletonPreloadHTML(t, e) {
798
+ if (!t) return "";
799
+ const n = this.context.type === "passwordless" ? "instant-access" : "verified-access", i = ue({
800
+ type: n,
801
+ height: "100%"
802
+ });
803
+ return `
804
+ <div id="sq-preload" style="visibility: visible; position: absolute; top: 0; left: 0; width: 100%; z-index: 9999; background: ${e || "white"};">
805
+ ${i}
806
+ </div>
807
+ <script>(${Le.toString()})()<\/script>
808
+ `;
524
809
  }
525
810
  /**
526
811
  * Reloads the current widget, makes updated request to API and renders result.
@@ -528,30 +813,30 @@ class ce {
528
813
  * @param param0 Form field values
529
814
  * @param jwt JWT for API authentication
530
815
  */
531
- reload({ email: t, firstName: e, lastName: i }, n) {
816
+ reload({ email: t, firstName: e, lastName: n }, i) {
532
817
  const s = this._findFrame();
533
818
  if (!s) throw new Error("Could not find widget iframe");
534
819
  const r = s.contentWindow, a = this.context.engagementMedium || "POPUP";
535
820
  if (!r)
536
821
  throw new Error("Frame needs a content window");
537
- let c;
822
+ let d;
538
823
  if (this.context.type === "upsert") {
539
824
  if (!this.context.user) throw new Error("Can't reload without user ids");
540
- let d = {
825
+ let c = {
541
826
  email: t || null,
542
827
  firstName: e || null,
543
- lastName: i || null,
828
+ lastName: n || null,
544
829
  id: this.context.user.id,
545
830
  accountId: this.context.user.accountId
546
831
  };
547
- c = this.widgetApi.upsertUser({
548
- user: d,
832
+ d = this.widgetApi.upsertUser({
833
+ user: c,
549
834
  engagementMedium: a,
550
835
  widgetType: this.type,
551
- jwt: n
836
+ jwt: i
552
837
  });
553
838
  } else if (this.context.type === "passwordless")
554
- c = this.widgetApi.render({
839
+ d = this.widgetApi.render({
555
840
  user: void 0,
556
841
  engagementMedium: a,
557
842
  widgetType: this.type,
@@ -559,79 +844,104 @@ class ce {
559
844
  });
560
845
  else
561
846
  throw new Error("can't reload an error widget");
562
- c.then(({ template: d }) => {
563
- d && (this.content = d, this.__deprecated__register(
847
+ d.then(({ template: c }) => {
848
+ c && (this.content = c, this.__deprecated__register(
564
849
  s,
565
850
  { email: t, engagementMedium: a },
566
851
  () => {
567
852
  this.load(), a === "POPUP" && this.open();
568
853
  }
569
854
  ));
570
- }).catch(({ message: d }) => {
571
- w(`${d}`);
855
+ }).catch(({ message: c }) => {
856
+ y(`${c}`);
572
857
  });
573
858
  }
574
- __deprecated__register(t, e, i) {
859
+ __deprecated__register(t, e, n) {
575
860
  const s = t.contentWindow.document, r = s.createElement("button"), a = s.getElementsByClassName("squatch-register")[0];
576
861
  if (a) {
577
862
  r.className = "btn btn-primary", r.id = "show-stats-btn", r.textContent = this.type === "REFERRER_WIDGET" ? "Show Stats" : "Show Reward";
578
- const c = e.engagementMedium === "POPUP" ? "margin-top: 10px; max-width: 130px; width: 100%;" : "margin-top: 10px;";
579
- r.setAttribute("style", c), r.onclick = i, a.style.paddingTop = "30px", a.innerHTML = `<p><strong>${e.email}</strong><br>Has been successfully registered</p>`, a.appendChild(r);
863
+ const d = e.engagementMedium === "POPUP" ? "margin-top: 10px; max-width: 130px; width: 100%;" : "margin-top: 10px;";
864
+ r.setAttribute("style", d), r.onclick = n, a.style.paddingTop = "30px", a.innerHTML = `<p><strong>${e.email}</strong><br>Has been successfully registered</p>`, a.appendChild(r);
580
865
  }
581
866
  }
582
867
  }
583
- function Te(o) {
868
+ function Me(o) {
584
869
  return new Promise((t) => {
585
870
  setTimeout(t, o);
586
871
  });
587
872
  }
588
- const b = E("squatch-js:EMBEDwidget");
589
- class L extends ce {
590
- constructor(e, i) {
873
+ function Le() {
874
+ var o = setTimeout(t, 1e4);
875
+ function t() {
876
+ var n = document.getElementById("sq-preload");
877
+ n && n.remove(), clearTimeout(o);
878
+ }
879
+ function e() {
880
+ var n = /* @__PURE__ */ new Set();
881
+ if (document.querySelectorAll("*").forEach(function(i) {
882
+ i.tagName.includes("-") && n.add(i.tagName.toLowerCase());
883
+ }), !n.size) return t();
884
+ Promise.all(
885
+ Array.from(n).map(function(i) {
886
+ return customElements.whenDefined(i);
887
+ })
888
+ ).then(function() {
889
+ requestAnimationFrame(function() {
890
+ requestAnimationFrame(t);
891
+ });
892
+ });
893
+ }
894
+ document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", e) : e();
895
+ }
896
+ const E = k("squatch-js:EMBEDwidget");
897
+ class O extends pe {
898
+ constructor(e, n) {
591
899
  super(e);
592
900
  l(this, "show", this.open);
593
901
  l(this, "hide", this.close);
594
- i && (this.container = i);
902
+ n && (this.container = n);
595
903
  }
596
904
  async load() {
597
- var m, p, g, f, _, C, Z;
598
- const e = (p = (m = this.context.widgetConfig) == null ? void 0 : m.values) == null ? void 0 : p.brandingConfig, i = e == null ? void 0 : e.loadingHeight, n = (g = e == null ? void 0 : e.widgetSize) == null ? void 0 : g.embeddedWidgets, s = n != null && n.maxWidth ? M(n.maxWidth) : "", r = n != null && n.minWidth ? M(n.minWidth) : "", a = this._createFrame({
599
- minWidth: r,
600
- maxWidth: s,
905
+ var m, w, b, f, _, ee, te, ne, ie;
906
+ const e = (w = (m = this.context.widgetConfig) == null ? void 0 : m.values) == null ? void 0 : w.brandingConfig, n = (b = this.content) == null ? void 0 : b.includes("mint-components"), i = (e == null ? void 0 : e.loadingHeight) || 500, s = (f = e == null ? void 0 : e.widgetSize) == null ? void 0 : f.embeddedWidgets, r = s != null && s.maxWidth ? L(s.maxWidth) : "", a = s != null && s.minWidth ? L(s.minWidth) : "", d = this._createFrame({
907
+ minWidth: a,
908
+ maxWidth: r,
601
909
  initialHeight: i
602
910
  }), c = this._findElement();
603
- (f = this.context) != null && f.container && (c.style.visibility = "hidden", c.style.height = "0", c.style["overflow-y"] = "hidden"), this.container ? c.shadowRoot ? ((_ = c.shadowRoot.lastChild) == null ? void 0 : _.nodeName) === "IFRAME" ? c.shadowRoot.replaceChild(a, c.shadowRoot.lastChild) : c.shadowRoot.appendChild(a) : c.firstChild ? c.replaceChild(a, c.firstChild) : c.appendChild(a) : (!c.firstChild || c.firstChild.nodeName === "#text") && c.appendChild(a);
604
- const { contentWindow: d } = a;
605
- if (!d)
911
+ (_ = this.context) != null && _.container && (c.style.visibility = "hidden", c.style.height = "0", c.style["overflow-y"] = "hidden"), this.container ? c.shadowRoot ? ((ee = c.shadowRoot.lastChild) == null ? void 0 : ee.nodeName) === "IFRAME" ? c.shadowRoot.replaceChild(d, c.shadowRoot.lastChild) : c.shadowRoot.appendChild(d) : c.firstChild ? c.replaceChild(d, c.firstChild) : c.appendChild(d) : (!c.firstChild || c.firstChild.nodeName === "#text") && c.appendChild(d);
912
+ const { contentWindow: h } = d;
913
+ if (!h)
606
914
  throw new Error("Frame needs a content window");
607
- const h = d.document;
608
- h.open();
609
- const u = this.widgetApi.domain;
610
- h.write(`
611
- ${(C = e == null ? void 0 : e.main) != null && C.brandFont ? `
612
- <link rel="preconnect" href="https://fast${u === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
915
+ const u = h.document;
916
+ u.open();
917
+ const g = this.widgetApi.domain === "https://staging.referralsaasquatch.com" ? "-staging" : "";
918
+ u.write(`
919
+ ${(te = e == null ? void 0 : e.main) != null && te.brandFont ? `
920
+ <link rel="preconnect" href="https://fast${g}.ssqt.io">
613
921
  <link rel="preconnect" href="https://fonts.gstatic.com">
614
922
  <link rel="preconnect" href="https://fonts.googleapis.com">
615
923
  <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
616
- (Z = e == null ? void 0 : e.main) == null ? void 0 : Z.brandFont
924
+ (ne = e == null ? void 0 : e.main) == null ? void 0 : ne.brandFont
617
925
  )}" as="style">` : ""}
618
926
  <link rel="dns-prefetch" href="https://res.cloudinary.com">
619
927
  <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
928
+ ${n ? `
620
929
  <style data-styles>
621
- html { visibility:hidden;}
622
- </style>
930
+ html { visibility: hidden; }
931
+ </style>` : ""}
932
+ ${this._getSkeletonPreloadHTML(n, (ie = e == null ? void 0 : e.color) == null ? void 0 : ie.backgroundColor)}
623
933
  ${this.content}
624
934
 
625
- `), h.close(), X(h, async () => {
626
- const ee = d.squatch || d.widgetIdent;
627
- a.height = i || h.body.scrollHeight;
628
- const me = new ResizeObserver((ge) => {
629
- for (const fe of ge) {
630
- const { height: we } = fe.contentRect;
631
- a.height = we;
935
+ `), u.close(), Q(u, async () => {
936
+ const oe = h.squatch || h.widgetIdent;
937
+ d.height = i;
938
+ const ye = new ResizeObserver((ke) => {
939
+ for (const be of ke) {
940
+ const { height: xe } = be.contentRect;
941
+ d.height = xe;
632
942
  }
633
- }), pe = await this._findInnerContainer(a);
634
- me.observe(pe), this._shouldFireLoadEvent() ? (this._loadEvent(ee), b("loaded")) : h && this._attachLoadEventListener(h, ee);
943
+ }), ve = await this._findInnerContainer(d);
944
+ ye.observe(ve), this._shouldFireLoadEvent() ? (this._loadEvent(oe), E("loaded")) : u && this._attachLoadEventListener(u, oe);
635
945
  });
636
946
  }
637
947
  /**
@@ -639,43 +949,43 @@ class L extends ce {
639
949
  */
640
950
  open() {
641
951
  const e = this._findFrame();
642
- if (!e) return b("no target element to open");
643
- if (!e.contentWindow) return b("Frame needs a content window");
644
- const i = this._findElement();
645
- i.style.visibility = "unset", i.style.height = "auto", i.style["overflow-y"] = "auto", e.contentWindow.document.dispatchEvent(new CustomEvent("sq:refresh"));
646
- const n = e.contentWindow.squatch || e.contentWindow.widgetIdent;
952
+ if (!e) return E("no target element to open");
953
+ if (!e.contentWindow) return E("Frame needs a content window");
954
+ const n = this._findElement();
955
+ n.style.visibility = "unset", n.style.height = "auto", n.style["overflow-y"] = "auto", e.contentWindow.document.dispatchEvent(new CustomEvent("sq:refresh"));
956
+ const i = e.contentWindow.squatch || e.contentWindow.widgetIdent;
647
957
  if (this.context.user)
648
- this._loadEvent(n), b("loaded");
958
+ this._loadEvent(i), E("loaded");
649
959
  else {
650
960
  if (!e.contentDocument) return;
651
- this._attachLoadEventListener(e.contentDocument, n);
961
+ this._attachLoadEventListener(e.contentDocument, i);
652
962
  }
653
963
  }
654
964
  close() {
655
965
  const e = this._findFrame();
656
- if (!e) return b("no target element to close");
966
+ if (!e) return E("no target element to close");
657
967
  e.contentDocument && this._detachLoadEventListener(e.contentDocument);
658
- const i = this._findElement();
659
- i.style.visibility = "hidden", i.style.height = "0", i.style["overflow-y"] = "hidden", b("Embed widget closed");
968
+ const n = this._findElement();
969
+ n.style.visibility = "hidden", n.style.height = "0", n.style["overflow-y"] = "hidden", E("Embed widget closed");
660
970
  }
661
- _error(e, i = "embed", n = "") {
662
- return super._error(e, i, n);
971
+ _error(e, n = "embed", i = "") {
972
+ return super._error(e, n, i);
663
973
  }
664
974
  _shouldFireLoadEvent() {
665
- const e = !this.container, i = this.container instanceof HTMLElement && (this.container.tagName.startsWith("SQUATCH-") || this.container.tagName.startsWith("IMPACT-"));
666
- return !!this.context.user && (e || i);
975
+ const e = !this.container, n = this.container instanceof HTMLElement && (this.container.tagName.startsWith("SQUATCH-") || this.container.tagName.startsWith("IMPACT-"));
976
+ return !!this.context.user && (e || n);
667
977
  }
668
978
  }
669
- const k = E("squatch-js:POPUPwidget");
670
- let R = 0;
671
- class O extends ce {
672
- constructor(e, i = ".squatchpop") {
979
+ const T = k("squatch-js:POPUPwidget");
980
+ let U = 0;
981
+ class j extends pe {
982
+ constructor(e, n = ".squatchpop") {
673
983
  super(e);
674
984
  l(this, "trigger");
675
985
  l(this, "id");
676
986
  l(this, "show", this.open);
677
987
  l(this, "hide", this.close);
678
- this.trigger = i, this.container ? this.id = "squatchModal" : (this.id = R === 0 ? "squatchModal" : `squatchModal__${R}`, R = R + 1), document.head.insertAdjacentHTML(
988
+ this.trigger = n, this.container ? this.id = "squatchModal" : (this.id = U === 0 ? "squatchModal" : `squatchModal__${U}`, U = U + 1), document.head.insertAdjacentHTML(
679
989
  "beforeend",
680
990
  `<style>#${this.id}::-webkit-scrollbar { display: none; }</style>`
681
991
  );
@@ -684,41 +994,41 @@ class O extends ce {
684
994
  if (!this.trigger) return;
685
995
  let e;
686
996
  try {
687
- e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e && k("No element found with trigger selector", this.trigger);
997
+ e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e && T("No element found with trigger selector", this.trigger);
688
998
  } catch {
689
- k("Not a valid selector", this.trigger);
999
+ T("Not a valid selector", this.trigger);
690
1000
  }
691
1001
  e && (e.onclick = () => {
692
1002
  this.open();
693
1003
  });
694
1004
  }
695
1005
  _createPopupDialog(e) {
696
- var c;
697
- const i = document.createElement("dialog"), n = (c = e == null ? void 0 : e.widgetSize) == null ? void 0 : c.popupWidgets, s = n != null && n.minWidth ? M(n.minWidth) : "auto", r = n != null && n.maxWidth ? M(n.maxWidth) : "500px";
698
- i.id = this.id, i.setAttribute(
1006
+ var d;
1007
+ const n = document.createElement("dialog"), i = (d = e == null ? void 0 : e.widgetSize) == null ? void 0 : d.popupWidgets, s = i != null && i.minWidth ? L(i.minWidth) : "auto", r = i != null && i.maxWidth ? L(i.maxWidth) : "500px";
1008
+ n.id = this.id, n.setAttribute(
699
1009
  "style",
700
1010
  `width: 100%; min-width: ${s}; max-width: ${r}; border: none; padding: 0;`
701
1011
  );
702
- const a = (d) => {
703
- d.stopPropagation(), d.target === i && i.close();
1012
+ const a = (c) => {
1013
+ c.stopPropagation(), c.target === n && n.close();
704
1014
  };
705
- return i.addEventListener("click", a), i;
1015
+ return n.addEventListener("click", a), n;
706
1016
  }
707
1017
  async load() {
708
- var u, m, p, g, f;
709
- const e = (m = (u = this.context.widgetConfig) == null ? void 0 : u.values) == null ? void 0 : m.brandingConfig, i = e == null ? void 0 : e.loadingHeight, n = this._createFrame({ initialHeight: i });
1018
+ var p, g, m, w, b, f, _;
1019
+ const e = (g = (p = this.context.widgetConfig) == null ? void 0 : p.values) == null ? void 0 : g.brandingConfig, n = (e == null ? void 0 : e.loadingHeight) || 500, i = (m = this.content) == null ? void 0 : m.includes("mint-components"), s = this._createFrame({ initialHeight: n });
710
1020
  this._initialiseCTA();
711
- const s = this.container ? this._findElement() : document.body, r = s.shadowRoot || s, a = this._createPopupDialog(e);
712
- a.appendChild(n), ((p = r.lastChild) == null ? void 0 : p.nodeName) === "DIALOG" ? r.replaceChild(a, r.lastChild) : r.appendChild(a);
713
- const { contentWindow: c } = n;
1021
+ const r = this.container ? this._findElement() : document.body, a = (r == null ? void 0 : r.shadowRoot) || r, d = this._createPopupDialog(e);
1022
+ d.appendChild(s), ((w = a.lastChild) == null ? void 0 : w.nodeName) === "DIALOG" ? a.replaceChild(d, a.lastChild) : a.appendChild(d);
1023
+ const { contentWindow: c } = s;
714
1024
  if (!c)
715
1025
  throw new Error("Frame needs a content window");
716
- const d = c.document;
717
- d.open();
718
- const h = this.widgetApi.domain;
719
- d.write(`
720
- ${(g = e == null ? void 0 : e.main) != null && g.brandFont ? `
721
- <link rel="preconnect" href="https://fast${h === "https://staging.referralsaasquatch.com" && "-staging"}.ssqt.io">
1026
+ const h = c.document;
1027
+ h.open();
1028
+ const u = this.widgetApi.domain;
1029
+ h.write(`
1030
+ ${(b = e == null ? void 0 : e.main) != null && b.brandFont ? `
1031
+ <link rel="preconnect" href="https://fast${u === "https://staging.referralsaasquatch.com" ? "-staging" : ""}.ssqt.io">
722
1032
  <link rel="preconnect" href="https://fonts.gstatic.com">
723
1033
  <link rel="preconnect" href="https://fonts.googleapis.com">
724
1034
  <link rel="preload" href="https://fonts.googleapis.com/css2?family=${encodeURIComponent(
@@ -726,57 +1036,59 @@ class O extends ce {
726
1036
  )}" as="style">` : ""}
727
1037
  <link rel="dns-prefetch" href="https://res.cloudinary.com">
728
1038
  <link rel="preconnect" href="https://res.cloudinary.com" crossorigin>
1039
+ ${i ? `
729
1040
  <style data-styles>
730
- html { visibility:hidden;}
731
- </style>
1041
+ html { visibility: hidden; }
1042
+ </style>` : ""}
1043
+ ${this._getSkeletonPreloadHTML(i, (_ = e == null ? void 0 : e.color) == null ? void 0 : _.backgroundColor)}
732
1044
  ${this.content}
733
1045
 
734
- `), d.close(), k("Popup template loaded into iframe"), await this._setupResizeHandler(n, i);
1046
+ `), h.close(), T("Popup template loaded into iframe"), await this._setupResizeHandler(s, n);
735
1047
  }
736
- async _setupResizeHandler(e, i) {
737
- const { contentWindow: n } = e;
738
- if (!n)
1048
+ async _setupResizeHandler(e, n) {
1049
+ const { contentWindow: i } = e;
1050
+ if (!i)
739
1051
  throw new Error("Frame needs a content window");
740
- const s = n.document;
741
- X(s, async () => {
742
- s.body.style.overflowY = "hidden", e.height = i || s.body.offsetHeight, new ResizeObserver((a) => {
743
- for (const c of a) {
744
- const { top: d, bottom: h } = c.contentRect, u = h + d;
745
- e.height = u + "", c.target.style = "";
1052
+ const s = i.document;
1053
+ Q(s, async () => {
1054
+ s.body.style.overflowY = "hidden", e.height = n || s.body.offsetHeight, new ResizeObserver((a) => {
1055
+ for (const d of a) {
1056
+ const { top: c, bottom: h } = d.contentRect, u = h + c;
1057
+ e.height = u + "", d.target.style = "";
746
1058
  }
747
1059
  }).observe(await this._findInnerContainer(e));
748
1060
  });
749
1061
  }
750
1062
  open() {
751
- const e = this.container ? this._findElement() : document.body, n = (e.shadowRoot || e).querySelector(`#${this.id}`);
752
- if (!n) throw new Error("Could not determine container div");
753
- n.showModal();
1063
+ const e = this.container ? this._findElement() : document.body, i = (e.shadowRoot || e).querySelector(`#${this.id}`);
1064
+ if (!i) throw new Error("Could not determine container div");
1065
+ i.showModal();
754
1066
  const s = this._findFrame();
755
1067
  if (!s) throw new Error("Could not find iframe");
756
1068
  const { contentWindow: r } = s;
757
1069
  if (!r) throw new Error("Squatch.js has an empty iframe");
758
1070
  const a = r.document;
759
- X(a, () => {
760
- var d;
761
- const c = r.squatch || r.widgetIdent;
762
- (d = s.contentDocument) == null || d.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(c), k("Popup opened")) : this._attachLoadEventListener(a, c);
1071
+ Q(a, () => {
1072
+ var c;
1073
+ const d = r.squatch || r.widgetIdent;
1074
+ (c = s.contentDocument) == null || c.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(d), T("Popup opened")) : this._attachLoadEventListener(a, d);
763
1075
  });
764
1076
  }
765
1077
  close() {
766
1078
  const e = this._findFrame();
767
1079
  e != null && e.contentDocument && this._detachLoadEventListener(e.contentDocument);
768
- const i = this.container ? this._findElement() : document.body, s = (i.shadowRoot || i).querySelector(`#${this.id}`);
1080
+ const n = this.container ? this._findElement() : document.body, s = (n.shadowRoot || n).querySelector(`#${this.id}`);
769
1081
  if (!s) throw new Error("Could not determine container div");
770
- s.close(), k("Popup closed");
1082
+ s.close(), T("Popup closed");
771
1083
  }
772
1084
  _clickedOutside({ target: e }) {
773
1085
  }
774
- _error(e, i = "modal", n = "") {
775
- return super._error(e, i, n || "body { margin: 0; } .modal { box-shadow: none; border: 0; }");
1086
+ _error(e, n = "modal", i = "") {
1087
+ return super._error(e, n, i || "body { margin: 0; } .modal { box-shadow: none; border: 0; }");
776
1088
  }
777
1089
  }
778
- const y = E("squatch-js:widgets");
779
- class j {
1090
+ const v = k("squatch-js:widgets");
1091
+ class D {
780
1092
  /**
781
1093
  * Initialize a new {@link Widgets} instance.
782
1094
  *
@@ -812,8 +1124,8 @@ class j {
812
1124
  * @default "https://fast.ssqt.io/npm"
813
1125
  */
814
1126
  l(this, "npmCdn");
815
- const e = W(t);
816
- this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new Y(e);
1127
+ const e = q(t);
1128
+ this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new K(e);
817
1129
  }
818
1130
  /**
819
1131
  * This function calls the {@link WidgetApi.upsertUser} method, and it renders
@@ -832,26 +1144,26 @@ class j {
832
1144
  * @return {Promise<WidgetResult>} json object if true, with a Widget and user details
833
1145
  */
834
1146
  async upsertUser(t) {
835
- const i = se(t);
1147
+ const n = ce(t);
836
1148
  try {
837
- const n = await this.api.upsertUser(i);
1149
+ const i = await this.api.upsertUser(n);
838
1150
  return {
839
- widget: this._renderWidget(n, i, {
1151
+ widget: this._renderWidget(i, n, {
840
1152
  type: "upsert",
841
- user: i.user,
1153
+ user: n.user,
842
1154
  engagementMedium: t.engagementMedium,
843
1155
  container: t.container,
844
1156
  trigger: t.trigger,
845
1157
  widgetConfig: {
846
1158
  values: {
847
- brandingConfig: n == null ? void 0 : n.brandingConfig
1159
+ brandingConfig: i == null ? void 0 : i.brandingConfig
848
1160
  }
849
1161
  }
850
1162
  }),
851
- user: n.user
1163
+ user: i.user
852
1164
  };
853
- } catch (n) {
854
- throw y(n), n.apiErrorCode && this._renderErrorWidget(n, t.engagementMedium), new Error(n);
1165
+ } catch (i) {
1166
+ throw v(i), i.apiErrorCode && this._renderErrorWidget(i, t.engagementMedium), new Error(i);
855
1167
  }
856
1168
  }
857
1169
  /**
@@ -870,21 +1182,21 @@ class j {
870
1182
  * @return {Promise<WidgetResult>} json object if true, with a Widget and user details
871
1183
  */
872
1184
  async render(t) {
873
- const i = re(t);
1185
+ const n = le(t);
874
1186
  try {
875
- const n = await this.api.render(i);
1187
+ const i = await this.api.render(n);
876
1188
  return {
877
- widget: this._renderWidget(n, i, {
1189
+ widget: this._renderWidget(i, n, {
878
1190
  type: "passwordless",
879
- engagementMedium: i.engagementMedium,
880
- container: i.container,
881
- trigger: i.trigger,
882
- widgetConfig: n == null ? void 0 : n.widgetConfig
1191
+ engagementMedium: n.engagementMedium,
1192
+ container: n.container,
1193
+ trigger: n.trigger,
1194
+ widgetConfig: i == null ? void 0 : i.widgetConfig
883
1195
  }),
884
- user: n.user
1196
+ user: i.user
885
1197
  };
886
- } catch (n) {
887
- throw n.apiErrorCode && this._renderErrorWidget(n, i.engagementMedium), new Error(n);
1198
+ } catch (i) {
1199
+ throw i.apiErrorCode && this._renderErrorWidget(i, n.engagementMedium), new Error(i);
888
1200
  }
889
1201
  }
890
1202
  /**
@@ -901,20 +1213,20 @@ class j {
901
1213
  const s = await this.api.squatchReferralCookie();
902
1214
  e(s);
903
1215
  } catch (s) {
904
- throw y("Autofill error", s), new Error(s);
1216
+ throw v("Autofill error", s), new Error(s);
905
1217
  }
906
1218
  return;
907
1219
  }
908
1220
  if (typeof e != "string")
909
1221
  throw new Error("Autofill accepts a string or function");
910
- let i = document.querySelectorAll(e), n;
911
- if (i.length > 0)
912
- n = i[0];
1222
+ let n = document.querySelectorAll(e), i;
1223
+ if (n.length > 0)
1224
+ i = n[0];
913
1225
  else
914
- throw y("Element id/class or function missing"), new Error("Element id/class or function missing");
1226
+ throw v("Element id/class or function missing"), new Error("Element id/class or function missing");
915
1227
  try {
916
1228
  const s = await this.api.squatchReferralCookie();
917
- n.value = s.codes[0];
1229
+ i.value = s.codes[0];
918
1230
  } catch (s) {
919
1231
  throw new Error(s);
920
1232
  }
@@ -927,41 +1239,41 @@ class j {
927
1239
  * @param {string} config.engagementMedium (POPUP, EMBED)
928
1240
  * @returns {Widget} widget (PopupWidget or EmbedWidget)
929
1241
  */
930
- _renderWidget(t, e, i) {
931
- var c;
932
- if (y("Rendering Widget..."), !t) throw new Error("Unable to get a response");
933
- let n, s = !!e.displayOnLoad;
1242
+ _renderWidget(t, e, n) {
1243
+ var d;
1244
+ if (v("Rendering Widget..."), !t) throw new Error("Unable to get a response");
1245
+ let i, s = !!e.displayOnLoad;
934
1246
  const r = t.jsOptions || {}, a = {
935
1247
  content: t.template,
936
- type: e.widgetType || ((c = r.widget) == null ? void 0 : c.defaultWidgetType),
1248
+ type: e.widgetType || ((d = r.widget) == null ? void 0 : d.defaultWidgetType),
937
1249
  api: this.api,
938
1250
  domain: this.domain,
939
1251
  npmCdn: this.npmCdn,
940
- context: i
1252
+ context: n
941
1253
  };
942
- return r.widgetUrlMappings && r.widgetUrlMappings.forEach((d) => {
1254
+ return r.widgetUrlMappings && r.widgetUrlMappings.forEach((c) => {
943
1255
  var h, u;
944
- j._matchesUrl(d.url) && (d.widgetType !== "CONVERSION_WIDGET" || (u = (h = t.user) == null ? void 0 : h.referredBy) != null && u.code ? (s = d.displayOnLoad, y(`Display ${d.widgetType} on ${d.url}`)) : y(
945
- `Don't display ${d.widgetType} when no referral on widget rule match ${d.url}`
1256
+ D._matchesUrl(c.url) && (c.widgetType !== "CONVERSION_WIDGET" || (u = (h = t.user) == null ? void 0 : h.referredBy) != null && u.code ? (s = c.displayOnLoad, v(`Display ${c.widgetType} on ${c.url}`)) : v(
1257
+ `Don't display ${c.widgetType} when no referral on widget rule match ${c.url}`
946
1258
  ));
947
- }), r.fuelTankAutofillUrls && (y("We found a fuel tank autofill!"), r.fuelTankAutofillUrls.forEach(({ url: d, formSelector: h }) => {
948
- var u, m, p;
949
- if (j._matchesUrl(d) && (y("Fuel Tank URL matches"), (m = (u = t.user) == null ? void 0 : u.referredBy) != null && m.code)) {
950
- const g = document.querySelector(h);
951
- g ? g.value = ((p = t.user.referredBy.referredReward) == null ? void 0 : p.fuelTankCode) || "" : y(
1259
+ }), r.fuelTankAutofillUrls && (v("We found a fuel tank autofill!"), r.fuelTankAutofillUrls.forEach(({ url: c, formSelector: h }) => {
1260
+ var u, p, g;
1261
+ if (D._matchesUrl(c) && (v("Fuel Tank URL matches"), (p = (u = t.user) == null ? void 0 : u.referredBy) != null && p.code)) {
1262
+ const m = document.querySelector(h);
1263
+ m ? m.value = ((g = t.user.referredBy.referredReward) == null ? void 0 : g.fuelTankCode) || "" : v(
952
1264
  new Error(
953
1265
  `Element with id/class ${h} was not found.`
954
1266
  )
955
1267
  );
956
1268
  }
957
- })), e.engagementMedium === "EMBED" ? n = this._renderEmbedWidget(a) : (n = this._renderPopupWidget(a), s && n.open()), n;
1269
+ })), e.engagementMedium === "EMBED" ? i = this._renderEmbedWidget(a) : (i = this._renderPopupWidget(a), s && i.open()), i;
958
1270
  }
959
1271
  _renderPopupWidget(t) {
960
- const e = new O(t, t.context.trigger);
1272
+ const e = new j(t, t.context.trigger);
961
1273
  return e.load(), e;
962
1274
  }
963
1275
  _renderEmbedWidget(t) {
964
- const e = new L(t, t.context.container);
1276
+ const e = new O(t, t.context.container);
965
1277
  return e.load(), e;
966
1278
  }
967
1279
  /**
@@ -971,11 +1283,11 @@ class j {
971
1283
  * @returns {void}
972
1284
  */
973
1285
  _renderErrorWidget(t, e = "POPUP") {
974
- const { apiErrorCode: i, rsCode: n, message: s } = t;
975
- y(new Error(`${i} (${n}) ${s}`));
1286
+ const { apiErrorCode: n, rsCode: i, message: s } = t;
1287
+ v(new Error(`${n} (${i}) ${s}`));
976
1288
  const r = {
977
1289
  content: "error",
978
- rsCode: n,
1290
+ rsCode: i,
979
1291
  api: this.api,
980
1292
  domain: this.domain,
981
1293
  npmCdn: this.npmCdn,
@@ -983,7 +1295,7 @@ class j {
983
1295
  context: { type: "error" }
984
1296
  };
985
1297
  let a;
986
- e === "EMBED" ? (a = new L(r), a.load()) : e === "POPUP" && (a = new O(r), a.load());
1298
+ e === "EMBED" ? (a = new O(r), a.load()) : e === "POPUP" && (a = new j(r), a.load());
987
1299
  }
988
1300
  /**
989
1301
  * @hidden
@@ -994,7 +1306,7 @@ class j {
994
1306
  return !!window.location.href.match(new RegExp(t));
995
1307
  }
996
1308
  }
997
- class Ue {
1309
+ class Oe {
998
1310
  /**
999
1311
  * Initialize a new {@link EventsApi} instance.
1000
1312
  *
@@ -1014,8 +1326,8 @@ class Ue {
1014
1326
  constructor(t) {
1015
1327
  l(this, "tenantAlias");
1016
1328
  l(this, "domain");
1017
- const i = W(t);
1018
- this.tenantAlias = i.tenantAlias, this.domain = i.domain;
1329
+ const n = q(t);
1330
+ this.tenantAlias = n.tenantAlias, this.domain = n.domain;
1019
1331
  }
1020
1332
  /**
1021
1333
  * Track an event for a user
@@ -1026,11 +1338,11 @@ class Ue {
1026
1338
  * @return An ID to confirm the event has been accepted for asynchronous processing
1027
1339
  */
1028
1340
  track(t, e) {
1029
- const i = t, n = e, s = Re(i), { jwt: r } = $e(n), 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;
1030
- return V(u, JSON.stringify(s), r);
1341
+ const n = t, i = e, s = je(n), { jwt: r } = De(i), a = encodeURIComponent(this.tenantAlias), d = encodeURIComponent(s.userId), c = encodeURIComponent(s.accountId), h = `/api/v1/${a}/open/account/${c}/user/${d}/events`, u = this.domain + h;
1342
+ return X(u, JSON.stringify(s), r);
1031
1343
  }
1032
1344
  }
1033
- function Re(o) {
1345
+ function je(o) {
1034
1346
  if (!I(o)) throw new Error("tracking parameter must be an object");
1035
1347
  if (!(o != null && o.accountId)) throw new Error("accountId field is required");
1036
1348
  if (!(o != null && o.events)) throw new Error("events field is required");
@@ -1040,68 +1352,68 @@ function Re(o) {
1040
1352
  throw new Error("'events' should be an array");
1041
1353
  return t;
1042
1354
  }
1043
- function $e(o) {
1355
+ function De(o) {
1044
1356
  if (!I(o)) throw new Error("'options' should be an object");
1045
1357
  return o;
1046
1358
  }
1047
- function Pe() {
1048
- var n;
1049
- const o = window[J] ? J : U, t = ((n = window["_" + o]) == null ? void 0 : n.ready) || [], e = window.impactOnReady || window.squatchOnReady, i = [...t, e].filter((s) => !!s);
1359
+ function Ne() {
1360
+ var i;
1361
+ const o = window[z] ? z : R, t = ((i = window["_" + o]) == null ? void 0 : i.ready) || [], e = window.impactOnReady || window.squatchOnReady, n = [...t, e].filter((s) => !!s);
1050
1362
  setTimeout(() => {
1051
- window[U] && (window[J] = window[U], i.forEach((s) => s()), window[U]._auto(), window["_" + o] = void 0, delete window["_" + o]);
1363
+ window[R] && (window[z] = window[R], n.forEach((s) => s()), window[R]._auto(), window["_" + o] = void 0, delete window["_" + o]);
1052
1364
  }, 0);
1053
1365
  }
1054
- const v = E("squatch-js"), te = (o) => typeof o == "object" && !Array.isArray(o), de = (o, t) => {
1055
- const e = (n) => te(t[n]) && o.hasOwnProperty(n) && te(o[n]), i = Object.getOwnPropertyNames(t).map((n) => ({
1056
- [n]: e(n) ? de(o[n], t[n]) : t[n]
1057
- })).reduce((n, s) => ({ ...n, ...s }), {});
1366
+ const x = k("squatch-js"), se = (o) => typeof o == "object" && !Array.isArray(o), me = (o, t) => {
1367
+ const e = (i) => se(t[i]) && o.hasOwnProperty(i) && se(o[i]), n = Object.getOwnPropertyNames(t).map((i) => ({
1368
+ [i]: e(i) ? me(o[i], t[i]) : t[i]
1369
+ })).reduce((i, s) => ({ ...i, ...s }), {});
1058
1370
  return {
1059
1371
  ...o,
1060
- ...i
1372
+ ...n
1061
1373
  };
1062
1374
  };
1063
- function D(o) {
1375
+ function N(o) {
1064
1376
  const t = atob(o.replace(/_/g, "/").replace(/-/g, "+")), e = new Uint8Array(t.length);
1065
- for (let i = 0; i < t.length; i++)
1066
- e[i] = t.charCodeAt(i);
1377
+ for (let n = 0; n < t.length; n++)
1378
+ e[n] = t.charCodeAt(n);
1067
1379
  return new TextDecoder("utf8").decode(e);
1068
1380
  }
1069
- function ne(o) {
1381
+ function re(o) {
1070
1382
  const t = new TextEncoder().encode(o), e = Array.from(
1071
1383
  t,
1072
- (i) => String.fromCodePoint(i)
1384
+ (n) => String.fromCodePoint(n)
1073
1385
  ).join("");
1074
1386
  return btoa(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
1075
1387
  }
1076
- function Se() {
1077
- var o, t, e = "weird_get_top_level_domain=cookie", i = document.location.hostname.split(".");
1078
- for (o = i.length - 1; o >= 0; o--)
1079
- if (t = i.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
1388
+ function Fe() {
1389
+ var o, t, e = "weird_get_top_level_domain=cookie", n = document.location.hostname.split(".");
1390
+ for (o = n.length - 1; o >= 0; o--)
1391
+ if (t = n.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
1080
1392
  return document.cookie = e.split("=")[0] + "=;domain=." + t + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", t;
1081
1393
  }
1082
- function Me() {
1394
+ function He() {
1083
1395
  const o = window.location.search, e = new URLSearchParams(o).get("_saasquatch") || "";
1084
1396
  if (e) {
1085
- let i = "", n = "", s = "";
1397
+ let n = "", i = "", s = "";
1086
1398
  try {
1087
- i = JSON.parse(D(e));
1399
+ n = JSON.parse(N(e));
1088
1400
  } catch (r) {
1089
- v("Unable to decode params", r);
1401
+ x("Unable to decode params", r);
1090
1402
  return;
1091
1403
  }
1092
1404
  try {
1093
- n = JSON.parse(D(S.get("_saasquatch"))), v("existing cookie", n);
1405
+ i = JSON.parse(N(M.get("_saasquatch"))), x("existing cookie", i);
1094
1406
  } catch (r) {
1095
- v("Unable to retrieve cookie", r);
1407
+ x("Unable to retrieve cookie", r);
1096
1408
  }
1097
1409
  try {
1098
- const r = Se();
1099
- if (v("domain retrieved:", r), n) {
1100
- const a = de(n, i);
1101
- s = ne(JSON.stringify(a)), v("cookie to store:", a);
1410
+ const r = Fe();
1411
+ if (x("domain retrieved:", r), i) {
1412
+ const a = me(i, n);
1413
+ s = re(JSON.stringify(a)), x("cookie to store:", a);
1102
1414
  } else
1103
- s = ne(JSON.stringify(i)), v("cookie to store:", i);
1104
- S.set("_saasquatch", s, {
1415
+ s = re(JSON.stringify(n)), x("cookie to store:", n);
1416
+ M.set("_saasquatch", s, {
1105
1417
  expires: 365,
1106
1418
  secure: !1,
1107
1419
  sameSite: "Lax",
@@ -1109,67 +1421,67 @@ function Me() {
1109
1421
  path: "/"
1110
1422
  });
1111
1423
  } catch (r) {
1112
- v("Unable to set cookie", r);
1424
+ x("Unable to set cookie", r);
1113
1425
  }
1114
1426
  }
1115
1427
  }
1116
- const $ = E("squatch-js");
1117
- function Le() {
1428
+ const P = k("squatch-js");
1429
+ function Be() {
1118
1430
  var u;
1119
1431
  const o = window.location.search, e = new URLSearchParams(o).get("_saasquatchExtra") || "";
1120
1432
  if (!e) {
1121
- $("No _saasquatchExtra param");
1433
+ P("No _saasquatchExtra param");
1122
1434
  return;
1123
1435
  }
1124
- const i = W({
1436
+ const n = q({
1125
1437
  tenantAlias: "UNKNOWN"
1126
1438
  });
1127
- if (!i.domain) {
1128
- $("domain must be provided in config to use _saasquatchExtra");
1439
+ if (!n.domain) {
1440
+ P("domain must be provided in config to use _saasquatchExtra");
1129
1441
  return;
1130
1442
  }
1131
- let n;
1443
+ let i;
1132
1444
  try {
1133
- n = JSON.parse(D(e));
1445
+ i = JSON.parse(N(e));
1134
1446
  } catch {
1135
- $("Unable to decode _saasquatchExtra config");
1447
+ P("Unable to decode _saasquatchExtra config");
1136
1448
  return;
1137
1449
  }
1138
- function s(m) {
1139
- return m.replace(/^https?:\/\//, "");
1450
+ function s(p) {
1451
+ return p.replace(/^https?:\/\//, "");
1140
1452
  }
1141
- const r = s(i.domain), a = Object.keys((n == null ? void 0 : n[r]) || {})[0], c = (u = n == null ? void 0 : n[r]) == null ? void 0 : u[a];
1142
- if (!c) {
1143
- $("_saasquatchExtra did not have an expected structure");
1453
+ const r = s(n.domain), a = Object.keys((i == null ? void 0 : i[r]) || {})[0], d = (u = i == null ? void 0 : i[r]) == null ? void 0 : u[a];
1454
+ if (!d) {
1455
+ P("_saasquatchExtra did not have an expected structure");
1144
1456
  return;
1145
1457
  }
1146
- const { autoPopupWidgetType: d, ...h } = c;
1458
+ const { autoPopupWidgetType: c, ...h } = d;
1147
1459
  return {
1148
1460
  widgetConfig: {
1149
- widgetType: d,
1461
+ widgetType: c,
1150
1462
  displayOnLoad: !0,
1151
1463
  ...h
1152
1464
  },
1153
1465
  squatchConfig: {
1154
- ...i,
1466
+ ...n,
1155
1467
  tenantAlias: a
1156
1468
  }
1157
1469
  };
1158
1470
  }
1159
- const Oe = E("squatch-js:decodeUserJwt");
1160
- function je(o) {
1471
+ const Je = k("squatch-js:decodeUserJwt");
1472
+ function ze(o) {
1161
1473
  var t;
1162
1474
  try {
1163
1475
  const e = o.split(".")[1];
1164
1476
  if (e === void 0) return null;
1165
- const i = D(e);
1166
- return (t = JSON.parse(i)) == null ? void 0 : t.user;
1477
+ const n = N(e);
1478
+ return (t = JSON.parse(n)) == null ? void 0 : t.user;
1167
1479
  } catch (e) {
1168
- return Oe(e), null;
1480
+ return Je(e), null;
1169
1481
  }
1170
1482
  }
1171
- const ie = E("squatch-js:DeclarativeWidget");
1172
- class le extends HTMLElement {
1483
+ const ae = k("squatch-js:DeclarativeWidget");
1484
+ class ge extends HTMLElement {
1173
1485
  constructor() {
1174
1486
  super();
1175
1487
  /**
@@ -1222,28 +1534,28 @@ class le extends HTMLElement {
1222
1534
  * @hidden
1223
1535
  */
1224
1536
  l(this, "loaded");
1225
- l(this, "_setWidget", (e, i) => {
1537
+ l(this, "_setWidget", (e, n) => {
1226
1538
  var s;
1227
- const n = {
1539
+ const i = {
1228
1540
  api: this.widgetApi,
1229
1541
  content: e.template,
1230
1542
  context: {
1231
- type: i.type,
1232
- user: i.user,
1543
+ type: n.type,
1544
+ user: n.user,
1233
1545
  container: this.container || void 0,
1234
1546
  engagementMedium: this.type,
1235
1547
  widgetConfig: e.widgetConfig
1236
1548
  },
1237
1549
  type: this.widgetType,
1238
1550
  domain: ((s = this.config) == null ? void 0 : s.domain) || A,
1239
- npmCdn: z,
1551
+ npmCdn: V,
1240
1552
  container: this
1241
1553
  };
1242
1554
  if (this.type === "EMBED")
1243
- return new L(n);
1555
+ return new O(i);
1244
1556
  {
1245
1557
  const r = this.firstChild ? null : void 0;
1246
- return new O(n, r);
1558
+ return new j(i, r);
1247
1559
  }
1248
1560
  });
1249
1561
  /**
@@ -1251,8 +1563,8 @@ class le extends HTMLElement {
1251
1563
  * @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
1252
1564
  */
1253
1565
  l(this, "setErrorWidget", (e) => {
1254
- var n;
1255
- const i = {
1566
+ var i;
1567
+ const n = {
1256
1568
  api: this.widgetApi,
1257
1569
  content: "error",
1258
1570
  context: {
@@ -1260,15 +1572,15 @@ class le extends HTMLElement {
1260
1572
  container: this.container || void 0
1261
1573
  },
1262
1574
  type: "ERROR_WIDGET",
1263
- domain: ((n = this.config) == null ? void 0 : n.domain) || A,
1264
- npmCdn: z,
1575
+ domain: ((i = this.config) == null ? void 0 : i.domain) || A,
1576
+ npmCdn: V,
1265
1577
  container: this
1266
1578
  };
1267
1579
  if (this.type === "EMBED")
1268
- return new L(i);
1580
+ return new O(n);
1269
1581
  {
1270
1582
  const s = this.firstChild ? null : void 0;
1271
- return new O(i, s);
1583
+ return new j(n, s);
1272
1584
  }
1273
1585
  });
1274
1586
  l(this, "reload", this.renderWidget);
@@ -1276,23 +1588,23 @@ class le extends HTMLElement {
1276
1588
  l(this, "hide", this.close);
1277
1589
  this.attachShadow({
1278
1590
  mode: "open"
1279
- }).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = Q(), this.token = q(), this.tenant = window.squatchTenant, this.container = this;
1591
+ }).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = Y(), this.token = W(), this.tenant = window.squatchTenant, this.container = this;
1280
1592
  }
1281
1593
  _setupApis(e) {
1282
- var i, n;
1594
+ var n, i;
1283
1595
  if (!this.tenant) throw new Error("tenantAlias not provided");
1284
- this.widgetApi = new Y({
1596
+ this.widgetApi = new K({
1285
1597
  tenantAlias: (e == null ? void 0 : e.tenantAlias) || this.tenant,
1286
- domain: (e == null ? void 0 : e.domain) || ((i = this.config) == null ? void 0 : i.domain) || A
1287
- }), this.analyticsApi = new ae({
1288
1598
  domain: (e == null ? void 0 : e.domain) || ((n = this.config) == null ? void 0 : n.domain) || A
1599
+ }), this.analyticsApi = new he({
1600
+ domain: (e == null ? void 0 : e.domain) || ((i = this.config) == null ? void 0 : i.domain) || A
1289
1601
  });
1290
1602
  }
1291
1603
  getWidgetType(e) {
1292
1604
  return e && (e.includes("websiteReferralWidget") || e.includes("friendWidget")) ? "instant-access" : "verified-access";
1293
1605
  }
1294
1606
  async renderPasswordlessVariant() {
1295
- return this._setupApis(), ie("Rendering as an Instant Access widget"), await this.widgetApi.render({
1607
+ return this._setupApis(), ae("Rendering as an Instant Access widget"), await this.widgetApi.render({
1296
1608
  engagementMedium: this.type,
1297
1609
  widgetType: this.widgetType,
1298
1610
  locale: this.locale
@@ -1300,8 +1612,8 @@ class le extends HTMLElement {
1300
1612
  }
1301
1613
  async renderUserUpsertVariant() {
1302
1614
  this._setupApis();
1303
- const e = je(this.token);
1304
- return e ? (ie("Rendering as a Verified widget"), await this.widgetApi.upsertUser({
1615
+ const e = ze(this.token);
1616
+ return e ? (ae("Rendering as a Verified widget"), await this.widgetApi.upsertUser({
1305
1617
  user: e,
1306
1618
  locale: this.locale,
1307
1619
  engagementMedium: this.type,
@@ -1311,7 +1623,7 @@ class le extends HTMLElement {
1311
1623
  locale: this.locale,
1312
1624
  engagementMedium: this.type,
1313
1625
  widgetType: this.widgetType
1314
- }).then((n) => this._setWidget(n, { type: "upsert", user: e })).catch(this.setErrorWidget)) : this.setErrorWidget(Error("No user object in token."));
1626
+ }).then((i) => this._setWidget(i, { type: "upsert", user: e })).catch(this.setErrorWidget)) : this.setErrorWidget(Error("No user object in token."));
1315
1627
  }
1316
1628
  /**
1317
1629
  * Fetches widget content from SaaSquatch and builds a Widget instance to support rendering the widget in the DOM
@@ -1348,8 +1660,8 @@ class le extends HTMLElement {
1348
1660
  static get observedAttributes() {
1349
1661
  return ["widget", "locale"];
1350
1662
  }
1351
- attributeChangedCallback(e, i, n) {
1352
- if (!(i === n || !this.loaded))
1663
+ attributeChangedCallback(e, n, i) {
1664
+ if (!(n === i || !this.loaded))
1353
1665
  switch (e) {
1354
1666
  case "locale":
1355
1667
  case "widget":
@@ -1359,15 +1671,15 @@ class le extends HTMLElement {
1359
1671
  }
1360
1672
  async connectedCallback() {
1361
1673
  this.loaded = !0, this.container = this.getAttribute("container"), this.widgetType = this.getAttribute("widget") || void 0;
1362
- const e = this.getWidgetType(this.widgetType), { getSkeleton: i } = await import("./SkeletonTemplate-CIRGs_GB.js"), n = i({
1674
+ const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await Promise.resolve().then(() => Pe), i = n({
1363
1675
  height: "100%",
1364
1676
  type: e
1365
1677
  }), s = document.createElement("div");
1366
- s.id = "loading-skeleton", s.innerHTML = n;
1678
+ s.id = "loading-skeleton", s.innerHTML = i;
1367
1679
  const r = this.shadowRoot || this.attachShadow({ mode: "open" });
1368
1680
  if (this.type === "POPUP") {
1369
- const c = r.getElementById("#squatchModal");
1370
- c && (c.innerHTML = "", c.appendChild(s));
1681
+ const d = r.getElementById("#squatchModal");
1682
+ d && (d.innerHTML = "", d.appendChild(s));
1371
1683
  } else
1372
1684
  r.innerHTML = "", r.appendChild(s);
1373
1685
  await this.renderWidget();
@@ -1375,93 +1687,93 @@ class le extends HTMLElement {
1375
1687
  a && a.remove(), this.getAttribute("open") !== null && this.open();
1376
1688
  }
1377
1689
  }
1378
- class he extends le {
1690
+ class fe extends ge {
1379
1691
  constructor() {
1380
1692
  super(), this.type = "EMBED", this.loaded = !1;
1381
1693
  }
1382
1694
  }
1383
- class ue extends le {
1695
+ class we extends ge {
1384
1696
  constructor() {
1385
1697
  super(), this.type = "POPUP", this.loaded = !1, this.addEventListener("click", (t) => {
1386
1698
  t.stopPropagation(), this.open();
1387
1699
  });
1388
1700
  }
1389
1701
  }
1390
- class De extends he {
1702
+ class Ge extends fe {
1391
1703
  }
1392
- class Ne extends ue {
1704
+ class Ve extends we {
1393
1705
  }
1394
- class Fe extends he {
1706
+ class Xe extends fe {
1395
1707
  }
1396
- class He extends ue {
1708
+ class Qe extends we {
1397
1709
  }
1398
- window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed", De);
1399
- window.customElements.get("impact-embed") || window.customElements.define("impact-embed", Fe);
1400
- window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup", Ne);
1401
- window.customElements.get("impact-popup") || window.customElements.define("impact-popup", He);
1402
- function Ge() {
1710
+ window.customElements.get("squatch-embed") || window.customElements.define("squatch-embed", Ge);
1711
+ window.customElements.get("impact-embed") || window.customElements.define("impact-embed", Xe);
1712
+ window.customElements.get("squatch-popup") || window.customElements.define("squatch-popup", Ve);
1713
+ window.customElements.get("impact-popup") || window.customElements.define("impact-popup", Qe);
1714
+ function Ze() {
1403
1715
  console.log(
1404
1716
  "Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes."
1405
1717
  );
1406
1718
  }
1407
- const x = E("squatch-js");
1408
- let N = null, F = null, H = null;
1409
- function ze() {
1410
- return N || B({}), N;
1719
+ const $ = k("squatch-js");
1720
+ let F = null, H = null, B = null;
1721
+ function et() {
1722
+ return F || J({}), F;
1411
1723
  }
1412
- function K() {
1413
- return F || B({}), F;
1724
+ function Z() {
1725
+ return H || J({}), H;
1414
1726
  }
1415
- function Ve() {
1416
- return H || B({}), H;
1727
+ function tt() {
1728
+ return B || J({}), B;
1417
1729
  }
1418
- function Xe(o) {
1730
+ function nt(o) {
1419
1731
  var t;
1420
- return (t = K()) == null ? void 0 : t.render(o);
1732
+ return (t = Z()) == null ? void 0 : t.render(o);
1421
1733
  }
1422
- function Qe() {
1734
+ function it() {
1423
1735
  var t;
1424
- const o = Le();
1736
+ const o = Be();
1425
1737
  if (o) {
1426
- const { squatchConfig: e, widgetConfig: i } = o;
1427
- return B(e), (t = K()) == null ? void 0 : t.render(i);
1738
+ const { squatchConfig: e, widgetConfig: n } = o;
1739
+ return J(e), (t = Z()) == null ? void 0 : t.render(n);
1428
1740
  }
1429
1741
  }
1430
- function B(o) {
1431
- const e = W(o);
1432
- e.tenantAlias.match("^test") || e.debug ? Ce("squatch-js*") : ve(), x("initializing ..."), N = new Y(e), F = new j(e), H = new Ue(e), x("Widget API instance", N), x("Widgets instance", F), x("Events API instance", H);
1742
+ function J(o) {
1743
+ const e = q(o);
1744
+ e.tenantAlias.match("^test") || e.debug ? Ae("squatch-js*") : Ie(), $("initializing ..."), F = new K(e), H = new D(e), B = new Oe(e), $("Widget API instance", F), $("Widgets instance", H), $("Events API instance", B);
1433
1745
  }
1434
- function Ye(o) {
1746
+ function ot(o) {
1435
1747
  o();
1436
1748
  }
1437
- function Ke(o) {
1438
- K().autofill(o);
1749
+ function st(o) {
1750
+ Z().autofill(o);
1439
1751
  }
1440
- function Be() {
1441
- Me();
1752
+ function Ye() {
1753
+ He();
1442
1754
  }
1443
- typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Be();
1444
- var oe;
1445
- (oe = window.squatch) != null && oe.init && x(
1755
+ typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Ye();
1756
+ var de;
1757
+ (de = window.squatch) != null && de.init && $(
1446
1758
  "Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics."
1447
1759
  );
1448
- typeof document < "u" && Pe();
1760
+ typeof document < "u" && Ne();
1449
1761
  export {
1450
- he as DeclarativeEmbedWidget,
1451
- ue as DeclarativePopupWidget,
1452
- L as EmbedWidget,
1453
- O as PopupWidget,
1454
- Y as WidgetApi,
1455
- j as Widgets,
1456
- Qe as _auto,
1457
- ze as api,
1458
- Ke as autofill,
1459
- Ve as events,
1460
- Ge as help,
1461
- B as init,
1462
- Be as pushCookie,
1463
- Ye as ready,
1464
- Xe as widget,
1465
- K as widgets
1762
+ fe as DeclarativeEmbedWidget,
1763
+ we as DeclarativePopupWidget,
1764
+ O as EmbedWidget,
1765
+ j as PopupWidget,
1766
+ K as WidgetApi,
1767
+ D as Widgets,
1768
+ it as _auto,
1769
+ et as api,
1770
+ st as autofill,
1771
+ tt as events,
1772
+ Ze as help,
1773
+ J as init,
1774
+ Ye as pushCookie,
1775
+ ot as ready,
1776
+ nt as widget,
1777
+ Z as widgets
1466
1778
  };
1467
1779
  //# sourceMappingURL=squatch.esm.js.map