@saasquatch/squatch-js 2.8.3-5 → 2.8.3-6
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 +43 -14
- package/dist/squatch.cjs.js.map +1 -1
- package/dist/squatch.esm.js +118 -74
- package/dist/squatch.esm.js.map +1 -1
- package/dist/squatch.js +41 -12
- 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 U(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,
|
|
@@ -112,7 +112,7 @@ function W(o) {
|
|
|
112
112
|
function I(o) {
|
|
113
113
|
return typeof o == "object" && !Array.isArray(o) && o !== null;
|
|
114
114
|
}
|
|
115
|
-
function
|
|
115
|
+
function Te(o) {
|
|
116
116
|
if (o && /^[a-z]{2}_(?:[A-Z]{2}|[0-9]{3})$/.test(o))
|
|
117
117
|
return o;
|
|
118
118
|
}
|
|
@@ -125,7 +125,7 @@ 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() {
|
|
@@ -142,8 +142,8 @@ function J(o) {
|
|
|
142
142
|
}
|
|
143
143
|
return { message: o };
|
|
144
144
|
}
|
|
145
|
-
async function
|
|
146
|
-
const i = n ||
|
|
145
|
+
async function Ue(o, t, e, n) {
|
|
146
|
+
const i = n || W(), s = {
|
|
147
147
|
Accept: "application/json",
|
|
148
148
|
"Content-Type": "application/json",
|
|
149
149
|
...i ? { Authorization: `Bearer ${i}` } : {},
|
|
@@ -161,11 +161,11 @@ async function We(o, t, e, n) {
|
|
|
161
161
|
throw r;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
async function
|
|
164
|
+
async function We(o, t = "") {
|
|
165
165
|
const e = {
|
|
166
166
|
Accept: "application/json",
|
|
167
167
|
"Content-Type": "application/json"
|
|
168
|
-
}, n = t ||
|
|
168
|
+
}, n = t || W();
|
|
169
169
|
n && (e["X-SaaSquatch-User-Token"] = n);
|
|
170
170
|
try {
|
|
171
171
|
const i = await fetch(o, {
|
|
@@ -183,7 +183,7 @@ async function Q(o, t, e) {
|
|
|
183
183
|
const n = {
|
|
184
184
|
Accept: "application/json",
|
|
185
185
|
"Content-Type": "application/json"
|
|
186
|
-
}, i = e ||
|
|
186
|
+
}, i = e || W();
|
|
187
187
|
i && (n["X-SaaSquatch-User-Token"] = i);
|
|
188
188
|
try {
|
|
189
189
|
const s = await fetch(o, {
|
|
@@ -197,12 +197,12 @@ async function Q(o, t, e) {
|
|
|
197
197
|
throw s;
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
|
-
async function
|
|
200
|
+
async function Se(o, t, e) {
|
|
201
201
|
const n = {
|
|
202
202
|
Accept: "application/json",
|
|
203
203
|
"Content-Type": "application/json",
|
|
204
204
|
"X-SaaSquatch-Referrer": window ? window.location.href : ""
|
|
205
|
-
}, i = e ||
|
|
205
|
+
}, i = e || W();
|
|
206
206
|
i && (n["X-SaaSquatch-User-Token"] = i);
|
|
207
207
|
try {
|
|
208
208
|
const s = await fetch(o, {
|
|
@@ -217,7 +217,7 @@ async function qe(o, t, e) {
|
|
|
217
217
|
throw s;
|
|
218
218
|
}
|
|
219
219
|
}
|
|
220
|
-
const
|
|
220
|
+
const qe = `
|
|
221
221
|
query renderWidget ($user: UserIdInput, $engagementMedium: UserEngagementMedium, $widgetType: WidgetType, $locale: RSLocale) {
|
|
222
222
|
renderWidget(user: $user, engagementMedium: $engagementMedium, widgetType: $widgetType, locale: $locale) {
|
|
223
223
|
template
|
|
@@ -254,7 +254,7 @@ class Z {
|
|
|
254
254
|
l(this, "domain");
|
|
255
255
|
l(this, "npmCdn");
|
|
256
256
|
l(this, "referralCookie", this.squatchReferralCookie);
|
|
257
|
-
const n =
|
|
257
|
+
const n = U(t);
|
|
258
258
|
this.tenantAlias = n.tenantAlias, this.domain = n.domain, this.npmCdn = n.npmCdn;
|
|
259
259
|
}
|
|
260
260
|
/**
|
|
@@ -282,8 +282,8 @@ class Z {
|
|
|
282
282
|
widgetType: i,
|
|
283
283
|
engagementMedium: s,
|
|
284
284
|
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),
|
|
285
|
+
}), m = `/api/v1/${c}/widget/account/${h}/user/${u}/upsert${p}`, g = this.domain + m, w = (P || window.Cookies).get("_saasquatch");
|
|
286
|
+
return w && (d.cookies = w), Se(g, JSON.stringify(d), r);
|
|
287
287
|
}
|
|
288
288
|
/**
|
|
289
289
|
* Requests widget template
|
|
@@ -299,13 +299,13 @@ class Z {
|
|
|
299
299
|
* @return {Promise} template html if true.
|
|
300
300
|
*/
|
|
301
301
|
render(t) {
|
|
302
|
-
const n = he(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, d = encodeURIComponent(this.tenantAlias), c = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ??
|
|
302
|
+
const n = he(t), { widgetType: i, engagementMedium: s = "POPUP", jwt: r, user: a } = n, d = encodeURIComponent(this.tenantAlias), c = a != null && a.accountId ? encodeURIComponent(a.accountId) : null, h = a != null && a.id ? encodeURIComponent(a.id) : null, u = n.locale ?? Te(navigator.language.replace(/\-/g, "_")), p = `/api/v1/${d}/graphql`, m = this.domain + p;
|
|
303
303
|
return new Promise(async (g, w) => {
|
|
304
304
|
var b;
|
|
305
305
|
try {
|
|
306
|
-
const f = await
|
|
306
|
+
const f = await Ue(
|
|
307
307
|
m,
|
|
308
|
-
|
|
308
|
+
qe,
|
|
309
309
|
{
|
|
310
310
|
user: h && c ? { id: h, accountId: c } : null,
|
|
311
311
|
engagementMedium: s,
|
|
@@ -326,7 +326,7 @@ class Z {
|
|
|
326
326
|
* @return {Promise<ReferralCookie>} code referral code if true.
|
|
327
327
|
*/
|
|
328
328
|
async squatchReferralCookie() {
|
|
329
|
-
const t = encodeURIComponent(this.tenantAlias), e = (
|
|
329
|
+
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
330
|
return Promise.resolve({
|
|
331
331
|
...s,
|
|
332
332
|
encodedCookie: e
|
|
@@ -378,7 +378,7 @@ class ue {
|
|
|
378
378
|
constructor(t) {
|
|
379
379
|
l(this, "domain");
|
|
380
380
|
var i;
|
|
381
|
-
const n =
|
|
381
|
+
const n = Me(t);
|
|
382
382
|
this.domain = (n == null ? void 0 : n.domain) || ((i = K()) == null ? void 0 : i.domain) || A;
|
|
383
383
|
}
|
|
384
384
|
pushAnalyticsLoadEvent(t) {
|
|
@@ -391,7 +391,7 @@ class ue {
|
|
|
391
391
|
return Q(d, JSON.stringify({}));
|
|
392
392
|
}
|
|
393
393
|
}
|
|
394
|
-
function
|
|
394
|
+
function Me(o) {
|
|
395
395
|
if (!I(o)) throw new Error("'options' should be an object");
|
|
396
396
|
return o;
|
|
397
397
|
}
|
|
@@ -649,7 +649,7 @@ const pe = ({
|
|
|
649
649
|
`}
|
|
650
650
|
</div>
|
|
651
651
|
`;
|
|
652
|
-
},
|
|
652
|
+
}, Pe = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
|
|
653
653
|
__proto__: null,
|
|
654
654
|
getSkeleton: pe
|
|
655
655
|
}, Symbol.toStringTag, { value: "Module" })), y = k("squatch-js:widget");
|
|
@@ -664,7 +664,12 @@ class ge {
|
|
|
664
664
|
l(this, "container");
|
|
665
665
|
l(this, "loadEventListener", null);
|
|
666
666
|
var e;
|
|
667
|
-
y("widget initializing ..."), this.content = t.content === "error" ? this._error(
|
|
667
|
+
y("widget initializing ..."), this.content = t.content === "error" ? this._error({
|
|
668
|
+
rsCode: t.rsCode,
|
|
669
|
+
apiErrorCode: t.apiErrorCode,
|
|
670
|
+
statusCode: t.statusCode,
|
|
671
|
+
message: t.errorMessage
|
|
672
|
+
}) : 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
673
|
}
|
|
669
674
|
_findElement() {
|
|
670
675
|
let t;
|
|
@@ -749,6 +754,7 @@ class ge {
|
|
|
749
754
|
});
|
|
750
755
|
}
|
|
751
756
|
_error(t, e = "modal", n = "") {
|
|
757
|
+
const { rsCode: i, apiErrorCode: s, statusCode: r, message: a } = t || {};
|
|
752
758
|
return `<!DOCTYPE html>
|
|
753
759
|
<!--[if IE 7]><html class="ie7 oldie" lang="en"><![endif]-->
|
|
754
760
|
<!--[if IE 8]><html class="ie8 oldie" lang="en"><![endif]-->
|
|
@@ -757,6 +763,31 @@ class ge {
|
|
|
757
763
|
<link rel="stylesheet" media="all" href="https://fast.ssqt.io/assets/css/widget/errorpage.css">
|
|
758
764
|
<style>
|
|
759
765
|
${n}
|
|
766
|
+
.error-details {
|
|
767
|
+
margin-top: 16px;
|
|
768
|
+
padding: 12px;
|
|
769
|
+
background: #f8f8f8;
|
|
770
|
+
border-radius: 4px;
|
|
771
|
+
text-align: left;
|
|
772
|
+
font-size: 13px;
|
|
773
|
+
color: #666;
|
|
774
|
+
}
|
|
775
|
+
.error-details dt {
|
|
776
|
+
font-weight: 600;
|
|
777
|
+
color: #333;
|
|
778
|
+
margin-top: 8px;
|
|
779
|
+
}
|
|
780
|
+
.error-details dt:first-child {
|
|
781
|
+
margin-top: 0;
|
|
782
|
+
}
|
|
783
|
+
.error-details dd {
|
|
784
|
+
margin: 4px 0 0 0;
|
|
785
|
+
word-break: break-word;
|
|
786
|
+
font-family: monospace;
|
|
787
|
+
}
|
|
788
|
+
.error-details dd.message {
|
|
789
|
+
font-family: inherit;
|
|
790
|
+
}
|
|
760
791
|
</style>
|
|
761
792
|
</head>
|
|
762
793
|
<body>
|
|
@@ -768,14 +799,18 @@ class ge {
|
|
|
768
799
|
</div>
|
|
769
800
|
<div class="errorbody">
|
|
770
801
|
<div class="sadface"><img src="https://fast.ssqt.io/assets/images/face.png"></div>
|
|
771
|
-
<h4>Our referral program is temporarily unavailable.</h4
|
|
802
|
+
<h4>Our referral program is temporarily unavailable.</h4>
|
|
772
803
|
<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
|
-
|
|
804
|
+
<p>If the problem persists please contact our support team.</p>
|
|
805
|
+
|
|
806
|
+
${r || s || i || a ? `
|
|
807
|
+
<dl class="error-details">
|
|
808
|
+
${r ? `<dt>Status Code</dt><dd>${r}</dd>` : ""}
|
|
809
|
+
${s ? `<dt>API Error Code</dt><dd>${s}</dd>` : ""}
|
|
810
|
+
${i ? `<dt>RS Code</dt><dd>${i}</dd>` : ""}
|
|
811
|
+
${a ? `<dt>Message</dt><dd class="message">${a}</dd>` : ""}
|
|
812
|
+
</dl>
|
|
813
|
+
` : ""}
|
|
779
814
|
</div>
|
|
780
815
|
</div>
|
|
781
816
|
</body>
|
|
@@ -987,7 +1022,7 @@ class O extends ge {
|
|
|
987
1022
|
return !!this.context.user && (e || n);
|
|
988
1023
|
}
|
|
989
1024
|
}
|
|
990
|
-
const
|
|
1025
|
+
const $ = k("squatch-js:POPUPwidget");
|
|
991
1026
|
let R = 0;
|
|
992
1027
|
class D extends ge {
|
|
993
1028
|
constructor(e, n = ".squatchpop") {
|
|
@@ -1005,9 +1040,9 @@ class D extends ge {
|
|
|
1005
1040
|
if (!this.trigger) return;
|
|
1006
1041
|
let e;
|
|
1007
1042
|
try {
|
|
1008
|
-
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e &&
|
|
1043
|
+
e = document.querySelector(this.trigger) || document.querySelector(".impactpop"), this.trigger && !e && $("No element found with trigger selector", this.trigger);
|
|
1009
1044
|
} catch {
|
|
1010
|
-
|
|
1045
|
+
$("Not a valid selector", this.trigger);
|
|
1011
1046
|
}
|
|
1012
1047
|
e && (e.onclick = () => {
|
|
1013
1048
|
this.open();
|
|
@@ -1054,7 +1089,7 @@ class D extends ge {
|
|
|
1054
1089
|
${this._getSkeletonPreloadHTML(i, (_ = e == null ? void 0 : e.color) == null ? void 0 : _.backgroundColor)}
|
|
1055
1090
|
${this.content}
|
|
1056
1091
|
<script src="${this.npmCdn}/resize-observer-polyfill@1.5.x"><\/script>
|
|
1057
|
-
`), h.close(),
|
|
1092
|
+
`), h.close(), $("Popup template loaded into iframe"), await this._setupResizeHandler(s);
|
|
1058
1093
|
}
|
|
1059
1094
|
async _setupResizeHandler(e) {
|
|
1060
1095
|
const { contentWindow: n } = e;
|
|
@@ -1084,7 +1119,7 @@ class D extends ge {
|
|
|
1084
1119
|
Y(a, () => {
|
|
1085
1120
|
var c;
|
|
1086
1121
|
const d = r.squatch || r.widgetIdent;
|
|
1087
|
-
(c = s.contentDocument) == null || c.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(d),
|
|
1122
|
+
(c = s.contentDocument) == null || c.dispatchEvent(new CustomEvent("sq:refresh")), this.context.user ? (this._loadEvent(d), $("Popup opened")) : this._attachLoadEventListener(a, d);
|
|
1088
1123
|
});
|
|
1089
1124
|
}
|
|
1090
1125
|
close() {
|
|
@@ -1092,7 +1127,7 @@ class D extends ge {
|
|
|
1092
1127
|
e != null && e.contentDocument && this._detachLoadEventListener(e.contentDocument);
|
|
1093
1128
|
const n = this.container ? this._findElement() : document.body, s = (n.shadowRoot || n).querySelector(`#${this.id}`);
|
|
1094
1129
|
if (!s) throw new Error("Could not determine container div");
|
|
1095
|
-
s.close(),
|
|
1130
|
+
s.close(), $("Popup closed");
|
|
1096
1131
|
}
|
|
1097
1132
|
_clickedOutside({ target: e }) {
|
|
1098
1133
|
}
|
|
@@ -1137,7 +1172,7 @@ class j {
|
|
|
1137
1172
|
* @default "https://fast.ssqt.io/npm"
|
|
1138
1173
|
*/
|
|
1139
1174
|
l(this, "npmCdn");
|
|
1140
|
-
const e =
|
|
1175
|
+
const e = U(t);
|
|
1141
1176
|
this.tenantAlias = e.tenantAlias, this.domain = e.domain, this.npmCdn = e.npmCdn, this.api = new Z(e);
|
|
1142
1177
|
}
|
|
1143
1178
|
/**
|
|
@@ -1302,19 +1337,22 @@ class j {
|
|
|
1302
1337
|
* @returns {void}
|
|
1303
1338
|
*/
|
|
1304
1339
|
_renderErrorWidget(t, e = "POPUP") {
|
|
1305
|
-
const { apiErrorCode: n, rsCode: i,
|
|
1306
|
-
v(new Error(`${n} (${i}) ${
|
|
1307
|
-
const
|
|
1340
|
+
const { apiErrorCode: n, rsCode: i, statusCode: s, message: r } = t;
|
|
1341
|
+
v(new Error(`${n} (${i}) ${r}`));
|
|
1342
|
+
const a = {
|
|
1308
1343
|
content: "error",
|
|
1309
1344
|
rsCode: i,
|
|
1345
|
+
apiErrorCode: n,
|
|
1346
|
+
statusCode: s,
|
|
1347
|
+
errorMessage: r,
|
|
1310
1348
|
api: this.api,
|
|
1311
1349
|
domain: this.domain,
|
|
1312
1350
|
npmCdn: this.npmCdn,
|
|
1313
1351
|
type: "ERROR_WIDGET",
|
|
1314
1352
|
context: { type: "error" }
|
|
1315
1353
|
};
|
|
1316
|
-
let
|
|
1317
|
-
e === "EMBED" ? (
|
|
1354
|
+
let d;
|
|
1355
|
+
e === "EMBED" ? (d = new O(a), d.load()) : e === "POPUP" && (d = new D(a), d.load());
|
|
1318
1356
|
}
|
|
1319
1357
|
/**
|
|
1320
1358
|
* @hidden
|
|
@@ -1345,7 +1383,7 @@ class De {
|
|
|
1345
1383
|
constructor(t) {
|
|
1346
1384
|
l(this, "tenantAlias");
|
|
1347
1385
|
l(this, "domain");
|
|
1348
|
-
const n =
|
|
1386
|
+
const n = U(t);
|
|
1349
1387
|
this.tenantAlias = n.tenantAlias, this.domain = n.domain;
|
|
1350
1388
|
}
|
|
1351
1389
|
/**
|
|
@@ -1377,9 +1415,9 @@ function Ne(o) {
|
|
|
1377
1415
|
}
|
|
1378
1416
|
function Fe() {
|
|
1379
1417
|
var i;
|
|
1380
|
-
const o = window[z] ? z :
|
|
1418
|
+
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
1419
|
setTimeout(() => {
|
|
1382
|
-
window[
|
|
1420
|
+
window[q] && (window[z] = window[q], n.forEach((s) => s()), window[q]._auto(), window["_" + o] = void 0, delete window["_" + o]);
|
|
1383
1421
|
}, 0);
|
|
1384
1422
|
}
|
|
1385
1423
|
const E = k("squatch-js"), re = (o) => typeof o == "object" && !Array.isArray(o), me = (o, t) => {
|
|
@@ -1421,7 +1459,7 @@ function Be() {
|
|
|
1421
1459
|
return;
|
|
1422
1460
|
}
|
|
1423
1461
|
try {
|
|
1424
|
-
i = JSON.parse(N(
|
|
1462
|
+
i = JSON.parse(N(P.get("_saasquatch"))), E("existing cookie", i);
|
|
1425
1463
|
} catch (r) {
|
|
1426
1464
|
E("Unable to retrieve cookie", r);
|
|
1427
1465
|
}
|
|
@@ -1432,7 +1470,7 @@ function Be() {
|
|
|
1432
1470
|
s = ae(JSON.stringify(a)), E("cookie to store:", a);
|
|
1433
1471
|
} else
|
|
1434
1472
|
s = ae(JSON.stringify(n)), E("cookie to store:", n);
|
|
1435
|
-
|
|
1473
|
+
P.set("_saasquatch", s, {
|
|
1436
1474
|
expires: 365,
|
|
1437
1475
|
secure: !1,
|
|
1438
1476
|
sameSite: "Lax",
|
|
@@ -1444,26 +1482,26 @@ function Be() {
|
|
|
1444
1482
|
}
|
|
1445
1483
|
}
|
|
1446
1484
|
}
|
|
1447
|
-
const
|
|
1485
|
+
const M = k("squatch-js");
|
|
1448
1486
|
function Je() {
|
|
1449
1487
|
var u;
|
|
1450
1488
|
const o = window.location.search, e = new URLSearchParams(o).get("_saasquatchExtra") || "";
|
|
1451
1489
|
if (!e) {
|
|
1452
|
-
|
|
1490
|
+
M("No _saasquatchExtra param");
|
|
1453
1491
|
return;
|
|
1454
1492
|
}
|
|
1455
|
-
const n =
|
|
1493
|
+
const n = U({
|
|
1456
1494
|
tenantAlias: "UNKNOWN"
|
|
1457
1495
|
});
|
|
1458
1496
|
if (!n.domain) {
|
|
1459
|
-
|
|
1497
|
+
M("domain must be provided in config to use _saasquatchExtra");
|
|
1460
1498
|
return;
|
|
1461
1499
|
}
|
|
1462
1500
|
let i;
|
|
1463
1501
|
try {
|
|
1464
1502
|
i = JSON.parse(N(e));
|
|
1465
1503
|
} catch {
|
|
1466
|
-
|
|
1504
|
+
M("Unable to decode _saasquatchExtra config");
|
|
1467
1505
|
return;
|
|
1468
1506
|
}
|
|
1469
1507
|
function s(p) {
|
|
@@ -1471,7 +1509,7 @@ function Je() {
|
|
|
1471
1509
|
}
|
|
1472
1510
|
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
1511
|
if (!d) {
|
|
1474
|
-
|
|
1512
|
+
M("_saasquatchExtra did not have an expected structure");
|
|
1475
1513
|
return;
|
|
1476
1514
|
}
|
|
1477
1515
|
const { autoPopupWidgetType: c, ...h } = d;
|
|
@@ -1582,8 +1620,8 @@ class fe extends HTMLElement {
|
|
|
1582
1620
|
* @returns Instance of either {@link EmbedWidget} or {@link PopupWidget} depending on `this.type`
|
|
1583
1621
|
*/
|
|
1584
1622
|
l(this, "setErrorWidget", (e) => {
|
|
1585
|
-
var
|
|
1586
|
-
const n = {
|
|
1623
|
+
var d;
|
|
1624
|
+
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
1625
|
api: this.widgetApi,
|
|
1588
1626
|
content: "error",
|
|
1589
1627
|
context: {
|
|
@@ -1591,15 +1629,19 @@ class fe extends HTMLElement {
|
|
|
1591
1629
|
container: this.container || void 0
|
|
1592
1630
|
},
|
|
1593
1631
|
type: "ERROR_WIDGET",
|
|
1594
|
-
domain: ((
|
|
1632
|
+
domain: ((d = this.config) == null ? void 0 : d.domain) || A,
|
|
1595
1633
|
npmCdn: X,
|
|
1596
|
-
container: this
|
|
1634
|
+
container: this,
|
|
1635
|
+
apiErrorCode: i,
|
|
1636
|
+
rsCode: s,
|
|
1637
|
+
statusCode: r,
|
|
1638
|
+
errorMessage: n
|
|
1597
1639
|
};
|
|
1598
1640
|
if (this.type === "EMBED")
|
|
1599
|
-
return new O(
|
|
1641
|
+
return new O(a);
|
|
1600
1642
|
{
|
|
1601
|
-
const
|
|
1602
|
-
return new D(
|
|
1643
|
+
const c = this.firstChild ? null : void 0;
|
|
1644
|
+
return new D(a, c);
|
|
1603
1645
|
}
|
|
1604
1646
|
});
|
|
1605
1647
|
l(this, "reload", this.renderWidget);
|
|
@@ -1607,7 +1649,7 @@ class fe extends HTMLElement {
|
|
|
1607
1649
|
l(this, "hide", this.close);
|
|
1608
1650
|
this.attachShadow({
|
|
1609
1651
|
mode: "open"
|
|
1610
|
-
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = K(), this.token =
|
|
1652
|
+
}).innerHTML = "<style>:host { display: block; }</style><slot></slot>", this.config = K(), this.token = W(), this.tenant = window.squatchTenant, this.container = this;
|
|
1611
1653
|
}
|
|
1612
1654
|
_setupApis(e) {
|
|
1613
1655
|
var n, i;
|
|
@@ -1644,7 +1686,9 @@ class fe extends HTMLElement {
|
|
|
1644
1686
|
jwt: this.token
|
|
1645
1687
|
});
|
|
1646
1688
|
} catch (i) {
|
|
1647
|
-
return this.setErrorWidget(
|
|
1689
|
+
return this.setErrorWidget(
|
|
1690
|
+
i
|
|
1691
|
+
);
|
|
1648
1692
|
}
|
|
1649
1693
|
return await this.widgetApi.render({
|
|
1650
1694
|
locale: this.locale,
|
|
@@ -1698,7 +1742,7 @@ class fe extends HTMLElement {
|
|
|
1698
1742
|
}
|
|
1699
1743
|
async connectedCallback() {
|
|
1700
1744
|
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(() =>
|
|
1745
|
+
const e = this.getWidgetType(this.widgetType), { getSkeleton: n } = await Promise.resolve().then(() => Pe), i = n({
|
|
1702
1746
|
height: "100%",
|
|
1703
1747
|
type: e
|
|
1704
1748
|
}), s = document.createElement("div");
|
|
@@ -1743,7 +1787,7 @@ function et() {
|
|
|
1743
1787
|
"Having trouble using Squatch.js? Go to https://docs.referralsaasquatch.com/developer/ for tutorials, references and error codes."
|
|
1744
1788
|
);
|
|
1745
1789
|
}
|
|
1746
|
-
const
|
|
1790
|
+
const T = k("squatch-js");
|
|
1747
1791
|
let F = null, H = null, B = null;
|
|
1748
1792
|
function tt() {
|
|
1749
1793
|
return F || G({}), F;
|
|
@@ -1767,8 +1811,8 @@ function ot() {
|
|
|
1767
1811
|
}
|
|
1768
1812
|
}
|
|
1769
1813
|
function G(o) {
|
|
1770
|
-
const e =
|
|
1771
|
-
e.tenantAlias.match("^test") || e.debug ? Ie("squatch-js*") : _e(),
|
|
1814
|
+
const e = U(o);
|
|
1815
|
+
e.tenantAlias.match("^test") || e.debug ? Ie("squatch-js*") : _e(), T("initializing ..."), F = new Z(e), H = new j(e), B = new De(e), T("Widget API instance", F), T("Widgets instance", H), T("Events API instance", B);
|
|
1772
1816
|
}
|
|
1773
1817
|
function st(o) {
|
|
1774
1818
|
o();
|
|
@@ -1781,7 +1825,7 @@ function Ke() {
|
|
|
1781
1825
|
}
|
|
1782
1826
|
typeof document < "u" && !window.SaaSquatchDoNotAutoDrop && Ke();
|
|
1783
1827
|
var ce;
|
|
1784
|
-
(ce = window.squatch) != null && ce.init &&
|
|
1828
|
+
(ce = window.squatch) != null && ce.init && T(
|
|
1785
1829
|
"Squatchjs is being loaded more than once. This may lead to multiple load events being sent, duplicated widgets, and inaccurate analytics."
|
|
1786
1830
|
);
|
|
1787
1831
|
typeof document < "u" && Fe();
|