@saasquatch/squatch-js 2.8.3-5 → 2.8.3-7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/squatch.cjs.js +42 -13
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +144 -93
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +42 -13
- package/dist/squatch.js.map +1 -1
- package/dist/squatch.min.js +2 -2
- package/dist/widgets/Widget.d.ts +9 -1
- package/dist/widgets/declarative/DeclarativeWidget.d.ts +6 -1
- package/package.json +1 -1
package/dist/squatch.esm.js
CHANGED
|
@@ -20,7 +20,7 @@ function k(o) {
|
|
|
20
20
|
}), t;
|
|
21
21
|
}
|
|
22
22
|
/*! js-cookie v3.0.5 | MIT */
|
|
23
|
-
function
|
|
23
|
+
function S(o) {
|
|
24
24
|
for (var t = 1; t < arguments.length; t++) {
|
|
25
25
|
var e = arguments[t];
|
|
26
26
|
for (var n in e)
|
|
@@ -28,7 +28,7 @@ function q(o) {
|
|
|
28
28
|
}
|
|
29
29
|
return o;
|
|
30
30
|
}
|
|
31
|
-
var
|
|
31
|
+
var $e = {
|
|
32
32
|
read: function(o) {
|
|
33
33
|
return o[0] === '"' && (o = o.slice(1, -1)), o.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
|
|
34
34
|
},
|
|
@@ -42,7 +42,7 @@ var Te = {
|
|
|
42
42
|
function V(o, t) {
|
|
43
43
|
function e(i, s, r) {
|
|
44
44
|
if (!(typeof document > "u")) {
|
|
45
|
-
r =
|
|
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);
|
|
46
46
|
var a = "";
|
|
47
47
|
for (var d in r)
|
|
48
48
|
r[d] && (a += "; " + d, r[d] !== !0 && (a += "=" + r[d].split(";")[0]));
|
|
@@ -71,16 +71,16 @@ function V(o, t) {
|
|
|
71
71
|
e(
|
|
72
72
|
i,
|
|
73
73
|
"",
|
|
74
|
-
|
|
74
|
+
S({}, s, {
|
|
75
75
|
expires: -1
|
|
76
76
|
})
|
|
77
77
|
);
|
|
78
78
|
},
|
|
79
79
|
withAttributes: function(i) {
|
|
80
|
-
return V(this.converter,
|
|
80
|
+
return V(this.converter, S({}, this.attributes, i));
|
|
81
81
|
},
|
|
82
82
|
withConverter: function(i) {
|
|
83
|
-
return V(
|
|
83
|
+
return V(S({}, this.converter, i), this.attributes);
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
86
|
{
|
|
@@ -89,9 +89,9 @@ function V(o, t) {
|
|
|
89
89
|
}
|
|
90
90
|
);
|
|
91
91
|
}
|
|
92
|
-
var
|
|
93
|
-
const A = "https://app.referralsaasquatch.com", X = "https://fast.ssqt.io/npm",
|
|
94
|
-
function
|
|
92
|
+
var P = V($e, { path: "/" });
|
|
93
|
+
const A = "https://app.referralsaasquatch.com", X = "https://fast.ssqt.io/npm", q = "squatch", z = "impact";
|
|
94
|
+
function T(o) {
|
|
95
95
|
if (typeof o != "object") throw new Error("config must be an object");
|
|
96
96
|
const t = window.squatchTenant, e = K(), n = {
|
|
97
97
|
tenantAlias: (o == null ? void 0 : o.tenantAlias) || t,
|
|
@@ -125,25 +125,28 @@ function he(o) {
|
|
|
125
125
|
if (!I(o)) throw new Error("Widget properties must be an object");
|
|
126
126
|
return o;
|
|
127
127
|
}
|
|
128
|
-
function
|
|
128
|
+
function W() {
|
|
129
129
|
return window.impactToken || window.squatchToken;
|
|
130
130
|
}
|
|
131
131
|
function K() {
|
|
132
132
|
return window.impactConfig || window.squatchConfig;
|
|
133
133
|
}
|
|
134
|
-
function
|
|
134
|
+
function G(o) {
|
|
135
135
|
console.log("[DEBUG] parseErrorResponse - raw responseText:", o);
|
|
136
136
|
try {
|
|
137
137
|
const t = JSON.parse(o);
|
|
138
138
|
if (console.log("[DEBUG] parseErrorResponse - parsed JSON:", t), t && typeof t == "object")
|
|
139
|
-
return console.log(
|
|
139
|
+
return console.log(
|
|
140
|
+
"[DEBUG] parseErrorResponse - returning parsed object with apiErrorCode:",
|
|
141
|
+
t.apiErrorCode
|
|
142
|
+
), t;
|
|
140
143
|
} catch (t) {
|
|
141
144
|
console.log("[DEBUG] parseErrorResponse - JSON parse failed:", t);
|
|
142
145
|
}
|
|
143
146
|
return { message: o };
|
|
144
147
|
}
|
|
145
|
-
async function
|
|
146
|
-
const i = n ||
|
|
148
|
+
async function Te(o, t, e, n) {
|
|
149
|
+
const i = n || W(), s = {
|
|
147
150
|
Accept: "application/json",
|
|
148
151
|
"Content-Type": "application/json",
|
|
149
152
|
...i ? { Authorization: `Bearer ${i}` } : {},
|
|
@@ -155,25 +158,27 @@ async function We(o, t, e, n) {
|
|
|
155
158
|
body: JSON.stringify({ query: t, variables: e }),
|
|
156
159
|
headers: s
|
|
157
160
|
});
|
|
158
|
-
if (!r.ok) throw
|
|
161
|
+
if (!r.ok) throw G(await r.text());
|
|
159
162
|
return await r.json();
|
|
160
163
|
} catch (r) {
|
|
161
164
|
throw r;
|
|
162
165
|
}
|
|
163
166
|
}
|
|
164
|
-
async function
|
|
167
|
+
async function We(o, t = "") {
|
|
165
168
|
const e = {
|
|
166
169
|
Accept: "application/json",
|
|
167
170
|
"Content-Type": "application/json"
|
|
168
|
-
}, n = t ||
|
|
169
|
-
n
|
|
171
|
+
}, n = t || W();
|
|
172
|
+
n ? (e["X-SaaSquatch-User-Token"] = n, console.log("[DEBUG] doGet - Adding token to headers:", n)) : console.log(
|
|
173
|
+
"[DEBUG] doGet - No token found, proceeding without authentication header."
|
|
174
|
+
);
|
|
170
175
|
try {
|
|
171
176
|
const i = await fetch(o, {
|
|
172
177
|
method: "GET",
|
|
173
178
|
credentials: "include",
|
|
174
179
|
headers: e
|
|
175
180
|
}), s = await i.text();
|
|
176
|
-
if (!i.ok) throw
|
|
181
|
+
if (!i.ok) throw G(s);
|
|
177
182
|
return s && JSON.parse(s);
|
|
178
183
|
} catch (i) {
|
|
179
184
|
throw i;
|
|
@@ -183,26 +188,28 @@ async function Q(o, t, e) {
|
|
|
183
188
|
const n = {
|
|
184
189
|
Accept: "application/json",
|
|
185
190
|
"Content-Type": "application/json"
|
|
186
|
-
}, i = e ||
|
|
187
|
-
i
|
|
191
|
+
}, i = e || W();
|
|
192
|
+
i ? (console.log("[DEBUG] doPost - Adding token to headers:", i), n["X-SaaSquatch-User-Token"] = i) : console.log(
|
|
193
|
+
"[DEBUG] doPost - No token found, proceeding without authentication header."
|
|
194
|
+
);
|
|
188
195
|
try {
|
|
189
196
|
const s = await fetch(o, {
|
|
190
197
|
method: "POST",
|
|
191
198
|
body: t,
|
|
192
199
|
headers: n
|
|
193
200
|
}), r = await s.text();
|
|
194
|
-
if (!s.ok) throw
|
|
201
|
+
if (!s.ok) throw G(r);
|
|
195
202
|
return r && JSON.parse(r);
|
|
196
203
|
} catch (s) {
|
|
197
204
|
throw s;
|
|
198
205
|
}
|
|
199
206
|
}
|
|
200
|
-
async function
|
|
207
|
+
async function Se(o, t, e) {
|
|
201
208
|
const n = {
|
|
202
209
|
Accept: "application/json",
|
|
203
210
|
"Content-Type": "application/json",
|
|
204
211
|
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
205
|
-
}, i = e ||
|
|
212
|
+
}, i = e || W();
|
|
206
213
|
i && (n["X-SaaSquatch-User-Token"] = i);
|
|
207
214
|
try {
|
|
208
215
|
const s = await fetch(o, {
|
|
@@ -211,13 +218,13 @@ async function qe(o, t, e) {
|
|
|
211
218
|
credentials: "include",
|
|
212
219
|
body: t
|
|
213
220
|
}), r = await s.text();
|
|
214
|
-
if (!s.ok) throw
|
|
221
|
+
if (!s.ok) throw G(r);
|
|
215
222
|
return r && JSON.parse(r);
|
|
216
223
|
} catch (s) {
|
|
217
224
|
throw s;
|
|
218
225
|
}
|
|
219
226
|
}
|
|
220
|
-
const
|
|
227
|
+
const qe = `
|
|
221
228
|
query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {
|
|
222
229
|
renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {
|
|
223
230
|
template
|
|
@@ -254,7 +261,7 @@ class Z {
|
|
|
254
261
|
l(this, "domain");
|
|
255
262
|
l(this, "npmCdn");
|
|
256
263
|
l(this, "referralCookie", this.squatchReferralCookie);
|
|
257
|
-
const n =
|
|
264
|
+
const n = T(t);
|
|
258
265
|
this.tenantAlias = n.tenantAlias, this.domain = n.domain, this.npmCdn = n.npmCdn;
|
|
259
266
|
}
|
|
260
267
|
/**
|
|
@@ -282,8 +289,8 @@ class Z {
|
|
|
282
289
|
widgetType: i,
|
|
283
290
|
engagementMedium: s,
|
|
284
291
|
locale: a
|
|
285
|
-
}), m = `/api/v1/${c}/widget/account/${h}/user/${u}/upsert${p}`, g = this.domain + m, w = (
|
|
286
|
-
return w && (d.cookies = w),
|
|
292
|
+
}), m = `/api/v1/${c}/widget/account/${h}/user/${u}/upsert${p}`, g = this.domain + m, w = (P || window.Cookies).get("_saasquatch");
|
|
293
|
+
return w && (d.cookies = w), Se(g, JSON.stringify(d), r);
|
|
287
294
|
}
|
|
288
295
|
/**
|
|
289
296
|
* Requests widget template
|
|
@@ -303,9 +310,9 @@ class Z {
|
|
|
303
310
|
return new Promise(async (g, w) => {
|
|
304
311
|
var b;
|
|
305
312
|
try {
|
|
306
|
-
const f = await
|
|
313
|
+
const f = await Te(
|
|
307
314
|
m,
|
|
308
|
-
|
|
315
|
+
qe,
|
|
309
316
|
{
|
|
310
317
|
user: h && c ? { id: h, accountId: c } : null,
|
|
311
318
|
engagementMedium: s,
|
|
@@ -326,7 +333,7 @@ class Z {
|
|
|
326
333
|
* @return {Promise<ReferralCookie>} code referral code if true.
|
|
327
334
|
*/
|
|
328
335
|
async squatchReferralCookie() {
|
|
329
|
-
const t = encodeURIComponent(this.tenantAlias), e = (
|
|
336
|
+
const t = encodeURIComponent(this.tenantAlias), e = (P || window.Cookies).get("_saasquatch") || "", n = e ? `?cookies=${encodeURIComponent(e)}` : "", i = `${this.domain}/a/${t}/widgets/squatchcookiejson${n}`, s = await We(i);
|
|
330
337
|
return Promise.resolve({
|
|
331
338
|
...s,
|
|
332
339
|
encodedCookie: e
|
|
@@ -378,7 +385,7 @@ class ue {
|
|
|
378
385
|
constructor(t) {
|
|
379
386
|
l(this, "domain");
|
|
380
387
|
var i;
|
|
381
|
-
const n =
|
|
388
|
+
const n = Me(t);
|
|
382
389
|
this.domain = (n == null ? void 0 : n.domain) || ((i = K()) == null ? void 0 : i.domain) || A;
|
|
383
390
|
}
|
|
384
391
|
pushAnalyticsLoadEvent(t) {
|
|
@@ -391,7 +398,7 @@ class ue {
|
|
|
391
398
|
return Q(d, JSON.stringify({}));
|
|
392
399
|
}
|
|
393
400
|
}
|
|
394
|
-
function
|
|
401
|
+
function Me(o) {
|
|
395
402
|
if (!I(o)) throw new Error("'options' should be an object");
|
|
396
403
|
return o;
|
|
397
404
|
}
|
|
@@ -649,7 +656,7 @@ const pe = ({
|
|
|
649
656
|
`}
|
|
650
657
|
</div>
|
|
651
658
|
`;
|
|
652
|
-
},
|
|
659
|
+
}, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
653
660
|
__proto__: null,
|
|
654
661
|
getSkeleton: pe
|
|
655
662
|
}, Symbol.toStringTag, { value: "Module" })), y = k("squatch-js:widget");
|
|
@@ -664,7 +671,12 @@ class ge {
|
|
|
664
671
|
l(this, "container");
|
|
665
672
|
l(this, "loadEventListener", null);
|
|
666
673
|
var e;
|
|
667
|
-
y("widget initializing ..."), this.content = t.content === "error" ? this._error(
|
|
674
|
+
y("widget initializing ..."), this.content = t.content === "error" ? this._error({
|
|
675
|
+
rsCode: t.rsCode,
|
|
676
|
+
apiErrorCode: t.apiErrorCode,
|
|
677
|
+
statusCode: t.statusCode,
|
|
678
|
+
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;
|
|
668
680
|
}
|
|
669
681
|
_findElement() {
|
|
670
682
|
let t;
|
|
@@ -749,6 +761,7 @@ class ge {
|
|
|
749
761
|
});
|
|
750
762
|
}
|
|
751
763
|
_error(t, e = "modal", n = "") {
|
|
764
|
+
const { rsCode: i, apiErrorCode: s, statusCode: r, message: a } = t || {};
|
|
752
765
|
return `<!DOCTYPE html>
|
|
753
766
|
<!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]-->
|
|
754
767
|
<!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]-->
|
|
@@ -757,6 +770,31 @@ class ge {
|
|
|
757
770
|
<link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">
|
|
758
771
|
<style>
|
|
759
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
|
+
}
|
|
760
798
|
</style>
|
|
761
799
|
</head>
|
|
762
800
|
<body>
|
|
@@ -768,14 +806,18 @@ class ge {
|
|
|
768
806
|
</div>
|
|
769
807
|
<div class="errorbody">
|
|
770
808
|
<div class="sadface"><img src="https://fast.ssqt.io/assets/images/face.png"></div>
|
|
771
|
-
<h4>Our referral program is temporarily unavailable.</h4
|
|
809
|
+
<h4>Our referral program is temporarily unavailable.</h4>
|
|
772
810
|
<p>Please reload the page or check back later.</p>
|
|
773
|
-
<p>If the persists please contact our support team.</p>
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
<
|
|
777
|
-
|
|
778
|
-
|
|
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
|
+
` : ""}
|
|
779
821
|
</div>
|
|
780
822
|
</div>
|
|
781
823
|
</body>
|
|
@@ -987,7 +1029,7 @@ class O extends ge {
|
|
|
987
1029
|
return !!this.context.user && (e || n);
|
|
988
1030
|
}
|
|
989
1031
|
}
|
|
990
|
-
const
|
|
1032
|
+
const $ = k("squatch-js:POPUPwidget");
|
|
991
1033
|
let R = 0;
|
|
992
1034
|
class D extends ge {
|
|
993
1035
|
constructor(e, n = ".squatchpop") {
|
|
@@ -1005,9 +1047,9 @@ class D extends ge {
|
|
|
1005
1047
|
if (!this.trigger) return;
|
|
1006
1048
|
let e;
|
|
1007
1049
|
try {
|
|
1008
|
-
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e &&
|
|
1050
|
+
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e && $("No element found with trigger selector", this.trigger);
|
|
1009
1051
|
} catch {
|
|
1010
|
-
|
|
1052
|
+
$("Not a valid selector", this.trigger);
|
|
1011
1053
|
}
|
|
1012
1054
|
e && (e.onclick = () => {
|
|
1013
1055
|
this.open();
|
|
@@ -1054,7 +1096,7 @@ class D extends ge {
|
|
|
1054
1096
|
${this._getSkeletonPreloadHTML(i, (_ = e == null ? void 0 : e.color) == null ? void 0 : _.backgroundColor)}
|
|
1055
1097
|
${this.content}
|
|
1056
1098
|
<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
1057
|
-
`), h.close(),
|
|
1099
|
+
`), h.close(), $("Popup template loaded into iframe"), await this._setupResizeHandler(s);
|
|
1058
1100
|
}
|
|
1059
1101
|
async _setupResizeHandler(e) {
|
|
1060
1102
|
const { contentWindow: n } = e;
|
|
@@ -1084,7 +1126,7 @@ class D extends ge {
|
|
|
1084
1126
|
Y(a, () => {
|
|
1085
1127
|
var c;
|
|
1086
1128
|
const d = r.squatch || r.widgetIdent;
|
|
1087
|
-
(c = s.contentDocument) == null || c.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(d),
|
|
1129
|
+
(c = s.contentDocument) == null || c.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(d), $("Popup opened")) : this._attachLoadEventListener(a, d);
|
|
1088
1130
|
});
|
|
1089
1131
|
}
|
|
1090
1132
|
close() {
|
|
@@ -1092,7 +1134,7 @@ class D extends ge {
|
|
|
1092
1134
|
e != null && e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
1093
1135
|
const n = this.container ? this._findElement() : document.body, s = (n.shadowRoot || n).querySelector(`#${this.id}`);
|
|
1094
1136
|
if (!s) throw new Error("Could not determine container div");
|
|
1095
|
-
s.close(),
|
|
1137
|
+
s.close(), $("Popup closed");
|
|
1096
1138
|
}
|
|
1097
1139
|
_clickedOutside({ target: e }) {
|
|
1098
1140
|
}
|
|
@@ -1137,7 +1179,7 @@ class j {
|
|
|
1137
1179
|
* @default "https://fast.ssqt.io/npm"
|
|
1138
1180
|
*/
|
|
1139
1181
|
l(this, "npmCdn");
|
|
1140
|
-
const e =
|
|
1182
|
+
const e = T(t);
|
|
1141
1183
|
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new Z(e);
|
|
1142
1184
|
}
|
|
1143
1185
|
/**
|
|
@@ -1302,19 +1344,22 @@ class j {
|
|
|
1302
1344
|
* @returns {void}
|
|
1303
1345
|
*/
|
|
1304
1346
|
_renderErrorWidget(t, e = "POPUP") {
|
|
1305
|
-
const { apiErrorCode: n, rsCode: i,
|
|
1306
|
-
v(new Error(`${n} (${i}) ${
|
|
1307
|
-
const
|
|
1347
|
+
const { apiErrorCode: n, rsCode: i, statusCode: s, message: r } = t;
|
|
1348
|
+
v(new Error(`${n} (${i}) ${r}`));
|
|
1349
|
+
const a = {
|
|
1308
1350
|
content: "error",
|
|
1309
1351
|
rsCode: i,
|
|
1352
|
+
apiErrorCode: n,
|
|
1353
|
+
statusCode: s,
|
|
1354
|
+
errorMessage: r,
|
|
1310
1355
|
api: this.api,
|
|
1311
1356
|
domain: this.domain,
|
|
1312
1357
|
npmCdn: this.npmCdn,
|
|
1313
1358
|
type: "ERROR_WIDGET",
|
|
1314
1359
|
context: { type: "error" }
|
|
1315
1360
|
};
|
|
1316
|
-
let
|
|
1317
|
-
e === "EMBED" ? (
|
|
1361
|
+
let d;
|
|
1362
|
+
e === "EMBED" ? (d = new O(a), d.load()) : e === "POPUP" && (d = new D(a), d.load());
|
|
1318
1363
|
}
|
|
1319
1364
|
/**
|
|
1320
1365
|
* @hidden
|
|
@@ -1345,7 +1390,7 @@ class De {
|
|
|
1345
1390
|
constructor(t) {
|
|
1346
1391
|
l(this, "tenantAlias");
|
|
1347
1392
|
l(this, "domain");
|
|
1348
|
-
const n =
|
|
1393
|
+
const n = T(t);
|
|
1349
1394
|
this.tenantAlias = n.tenantAlias, this.domain = n.domain;
|
|
1350
1395
|
}
|
|
1351
1396
|
/**
|
|
@@ -1377,9 +1422,9 @@ function Ne(o) {
|
|
|
1377
1422
|
}
|
|
1378
1423
|
function Fe() {
|
|
1379
1424
|
var i;
|
|
1380
|
-
const o = window[z] ? z :
|
|
1425
|
+
const o = window[z] ? z : q, t = ((i = window["_" + o]) == null ? void 0 : i.ready) || [], e = window.impactOnReady || window.squatchOnReady, n = [...t, e].filter((s) => !!s);
|
|
1381
1426
|
setTimeout(() => {
|
|
1382
|
-
window[
|
|
1427
|
+
window[q] && (window[z] = window[q], n.forEach((s) => s()), window[q]._auto(), window["_" + o] = void 0, delete window["_" + o]);
|
|
1383
1428
|
}, 0);
|
|
1384
1429
|
}
|
|
1385
1430
|
const E = k("squatch-js"), re = (o) => typeof o == "object" && !Array.isArray(o), me = (o, t) => {
|
|
@@ -1404,13 +1449,13 @@ function ae(o) {
|
|
|
1404
1449
|
).join("");
|
|
1405
1450
|
return btoa(e).replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
1406
1451
|
}
|
|
1407
|
-
function
|
|
1452
|
+
function Be() {
|
|
1408
1453
|
var o, t, e = "weird_get_top_level_domain=cookie", n = document.location.hostname.split(".");
|
|
1409
1454
|
for (o = n.length - 1; o >= 0; o--)
|
|
1410
1455
|
if (t = n.slice(o).join("."), document.cookie = e + ";domain=." + t + ";", document.cookie.indexOf(e) > -1)
|
|
1411
1456
|
return document.cookie = e.split("=")[0] + "=;domain=." + t + ";expires=Thu, 01 Jan 1970 00:00:01 GMT;", t;
|
|
1412
1457
|
}
|
|
1413
|
-
function
|
|
1458
|
+
function He() {
|
|
1414
1459
|
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatch") || "";
|
|
1415
1460
|
if (e) {
|
|
1416
1461
|
let n = "", i = "", s = "";
|
|
@@ -1421,18 +1466,18 @@ function Be() {
|
|
|
1421
1466
|
return;
|
|
1422
1467
|
}
|
|
1423
1468
|
try {
|
|
1424
|
-
i = JSON.parse(N(
|
|
1469
|
+
i = JSON.parse(N(P.get("_saasquatch"))), E("existing cookie", i);
|
|
1425
1470
|
} catch (r) {
|
|
1426
1471
|
E("Unable to retrieve cookie", r);
|
|
1427
1472
|
}
|
|
1428
1473
|
try {
|
|
1429
|
-
const r =
|
|
1474
|
+
const r = Be();
|
|
1430
1475
|
if (E("domain retrieved:", r), i) {
|
|
1431
1476
|
const a = me(i, n);
|
|
1432
1477
|
s = ae(JSON.stringify(a)), E("cookie to store:", a);
|
|
1433
1478
|
} else
|
|
1434
1479
|
s = ae(JSON.stringify(n)), E("cookie to store:", n);
|
|
1435
|
-
|
|
1480
|
+
P.set("_saasquatch", s, {
|
|
1436
1481
|
expires: 365,
|
|
1437
1482
|
secure: !1,
|
|
1438
1483
|
sameSite: "Lax",
|
|
@@ -1444,26 +1489,26 @@ function Be() {
|
|
|
1444
1489
|
}
|
|
1445
1490
|
}
|
|
1446
1491
|
}
|
|
1447
|
-
const
|
|
1448
|
-
function
|
|
1492
|
+
const M = k("squatch-js");
|
|
1493
|
+
function Ge() {
|
|
1449
1494
|
var u;
|
|
1450
1495
|
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatchExtra") || "";
|
|
1451
1496
|
if (!e) {
|
|
1452
|
-
|
|
1497
|
+
M("No _saasquatchExtra param");
|
|
1453
1498
|
return;
|
|
1454
1499
|
}
|
|
1455
|
-
const n =
|
|
1500
|
+
const n = T({
|
|
1456
1501
|
tenantAlias: "UNKNOWN"
|
|
1457
1502
|
});
|
|
1458
1503
|
if (!n.domain) {
|
|
1459
|
-
|
|
1504
|
+
M("domain must be provided in config to use _saasquatchExtra");
|
|
1460
1505
|
return;
|
|
1461
1506
|
}
|
|
1462
1507
|
let i;
|
|
1463
1508
|
try {
|
|
1464
1509
|
i = JSON.parse(N(e));
|
|
1465
1510
|
} catch {
|
|
1466
|
-
|
|
1511
|
+
M("Unable to decode _saasquatchExtra config");
|
|
1467
1512
|
return;
|
|
1468
1513
|
}
|
|
1469
1514
|
function s(p) {
|
|
@@ -1471,7 +1516,7 @@ function Je() {
|
|
|
1471
1516
|
}
|
|
1472
1517
|
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];
|
|
1473
1518
|
if (!d) {
|
|
1474
|
-
|
|
1519
|
+
M("_saasquatchExtra did not have an expected structure");
|
|
1475
1520
|
return;
|
|
1476
1521
|
}
|
|
1477
1522
|
const { autoPopupWidgetType: c, ...h } = d;
|
|
@@ -1487,7 +1532,7 @@ function Je() {
|
|
|
1487
1532
|
}
|
|
1488
1533
|
};
|
|
1489
1534
|
}
|
|
1490
|
-
const
|
|
1535
|
+
const Je = k("squatch-js:decodeUserJwt");
|
|
1491
1536
|
function ze(o) {
|
|
1492
1537
|
var t;
|
|
1493
1538
|
try {
|
|
@@ -1496,7 +1541,7 @@ function ze(o) {
|
|
|
1496
1541
|
const n = N(e);
|
|
1497
1542
|
return (t = JSON.parse(n)) == null ? void 0 : t.user;
|
|
1498
1543
|
} catch (e) {
|
|
1499
|
-
return
|
|
1544
|
+
return Je(e), null;
|
|
1500
1545
|
}
|
|
1501
1546
|
}
|
|
1502
1547
|
const de = k("squatch-js:DeclarativeWidget");
|
|
@@ -1582,8 +1627,8 @@ class fe extends HTMLElement {
|
|
|
1582
1627
|
* @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
|
|
1583
1628
|
*/
|
|
1584
1629
|
l(this, "setErrorWidget", (e) => {
|
|
1585
|
-
var
|
|
1586
|
-
const n = {
|
|
1630
|
+
var d;
|
|
1631
|
+
const n = e instanceof Error ? e.message : e == null ? void 0 : e.message, i = e instanceof Error || e == null ? void 0 : e.apiErrorCode, s = e instanceof Error || e == null ? void 0 : e.rsCode, r = e instanceof Error || e == null ? void 0 : e.statusCode, a = {
|
|
1587
1632
|
api: this.widgetApi,
|
|
1588
1633
|
content: "error",
|
|
1589
1634
|
context: {
|
|
@@ -1591,15 +1636,19 @@ class fe extends HTMLElement {
|
|
|
1591
1636
|
container: this.container || void 0
|
|
1592
1637
|
},
|
|
1593
1638
|
type: "ERROR_WIDGET",
|
|
1594
|
-
domain: ((
|
|
1639
|
+
domain: ((d = this.config) == null ? void 0 : d.domain) || A,
|
|
1595
1640
|
npmCdn: X,
|
|
1596
|
-
container: this
|
|
1641
|
+
container: this,
|
|
1642
|
+
apiErrorCode: i,
|
|
1643
|
+
rsCode: s,
|
|
1644
|
+
statusCode: r,
|
|
1645
|
+
errorMessage: n
|
|
1597
1646
|
};
|
|
1598
1647
|
if (this.type === "EMBED")
|
|
1599
|
-
return new O(
|
|
1648
|
+
return new O(a);
|
|
1600
1649
|
{
|
|
1601
|
-
const
|
|
1602
|
-
return new D(
|
|
1650
|
+
const c = this.firstChild ? null : void 0;
|
|
1651
|
+
return new D(a, c);
|
|
1603
1652
|
}
|
|
1604
1653
|
});
|
|
1605
1654
|
l(this, "reload", this.renderWidget);
|
|
@@ -1607,7 +1656,7 @@ class fe extends HTMLElement {
|
|
|
1607
1656
|
l(this, "hide", this.close);
|
|
1608
1657
|
this.attachShadow({
|
|
1609
1658
|
mode: "open"
|
|
1610
|
-
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = K(), this.token =
|
|
1659
|
+
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = K(), this.token = W(), this.tenant = window.squatchTenant, this.container = this;
|
|
1611
1660
|
}
|
|
1612
1661
|
_setupApis(e) {
|
|
1613
1662
|
var n, i;
|
|
@@ -1644,7 +1693,9 @@ class fe extends HTMLElement {
|
|
|
1644
1693
|
jwt: this.token
|
|
1645
1694
|
});
|
|
1646
1695
|
} catch (i) {
|
|
1647
|
-
return this.setErrorWidget(
|
|
1696
|
+
return this.setErrorWidget(
|
|
1697
|
+
i
|
|
1698
|
+
);
|
|
1648
1699
|
}
|
|
1649
1700
|
return await this.widgetApi.render({
|
|
1650
1701
|
locale: this.locale,
|
|
@@ -1698,7 +1749,7 @@ class fe extends HTMLElement {
|
|
|
1698
1749
|
}
|
|
1699
1750
|
async connectedCallback() {
|
|
1700
1751
|
this.loaded = !0, this.container = this.getAttribute("container"), this.widgetType = this.getAttribute("widget") || void 0;
|
|
1701
|
-
const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await Promise.resolve().then(() =>
|
|
1752
|
+
const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await Promise.resolve().then(() => Pe), i = n({
|
|
1702
1753
|
height: "100%",
|
|
1703
1754
|
type: e
|
|
1704
1755
|
}), s = document.createElement("div");
|
|
@@ -1744,15 +1795,15 @@ function et() {
|
|
|
1744
1795
|
);
|
|
1745
1796
|
}
|
|
1746
1797
|
const U = k("squatch-js");
|
|
1747
|
-
let F = null,
|
|
1798
|
+
let F = null, B = null, H = null;
|
|
1748
1799
|
function tt() {
|
|
1749
|
-
return F ||
|
|
1800
|
+
return F || J({}), F;
|
|
1750
1801
|
}
|
|
1751
1802
|
function ee() {
|
|
1752
|
-
return
|
|
1803
|
+
return B || J({}), B;
|
|
1753
1804
|
}
|
|
1754
1805
|
function nt() {
|
|
1755
|
-
return
|
|
1806
|
+
return H || J({}), H;
|
|
1756
1807
|
}
|
|
1757
1808
|
function it(o) {
|
|
1758
1809
|
var t;
|
|
@@ -1760,15 +1811,15 @@ function it(o) {
|
|
|
1760
1811
|
}
|
|
1761
1812
|
function ot() {
|
|
1762
1813
|
var t;
|
|
1763
|
-
const o =
|
|
1814
|
+
const o = Ge();
|
|
1764
1815
|
if (o) {
|
|
1765
1816
|
const { squatchConfig: e, widgetConfig: n } = o;
|
|
1766
|
-
return
|
|
1817
|
+
return J(e), (t = ee()) == null ? void 0 : t.render(n);
|
|
1767
1818
|
}
|
|
1768
1819
|
}
|
|
1769
|
-
function
|
|
1770
|
-
const e =
|
|
1771
|
-
e.tenantAlias.match("^test") || e.debug ? Ie("squatch-js*") : _e(), U("initializing ..."), F = new Z(e),
|
|
1820
|
+
function J(o) {
|
|
1821
|
+
const e = T(o);
|
|
1822
|
+
e.tenantAlias.match("^test") || e.debug ? Ie("squatch-js*") : _e(), U("initializing ..."), F = new Z(e), B = new j(e), H = new De(e), U("Widget API instance", F), U("Widgets instance", B), U("Events API instance", H);
|
|
1772
1823
|
}
|
|
1773
1824
|
function st(o) {
|
|
1774
1825
|
o();
|
|
@@ -1777,7 +1828,7 @@ function rt(o) {
|
|
|
1777
1828
|
ee().autofill(o);
|
|
1778
1829
|
}
|
|
1779
1830
|
function Ke() {
|
|
1780
|
-
|
|
1831
|
+
He();
|
|
1781
1832
|
}
|
|
1782
1833
|
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Ke();
|
|
1783
1834
|
var ce;
|
|
@@ -1797,7 +1848,7 @@ export {
|
|
|
1797
1848
|
rt as autofill,
|
|
1798
1849
|
nt as events,
|
|
1799
1850
|
et as help,
|
|
1800
|
-
|
|
1851
|
+
J as init,
|
|
1801
1852
|
Ke as pushCookie,
|
|
1802
1853
|
st as ready,
|
|
1803
1854
|
it as widget,
|