@fuul/sdk 3.1.0 → 3.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.d.ts +2 -0
- package/dist/core.d.ts.map +1 -1
- package/dist/index.mjs +86 -82
- package/dist/index.umd.js +3 -3
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
|
@@ -62,6 +62,7 @@ export declare function createAffiliateCode(address: string, code: string, signa
|
|
|
62
62
|
* @see https://docs.fuul.xyz/technical-guide-for-projects/creating-partners-tracking-links-using-the-fuul-sdk
|
|
63
63
|
**/
|
|
64
64
|
export declare function generateTrackingLink(baseUrl: string, affiliateAddress: string, params?: AffiliateLinkParams): Promise<string>;
|
|
65
|
+
export declare function getAffiliateCode(affiliateAddress: string): Promise<string | null>;
|
|
65
66
|
export declare function getConversions(): Promise<Conversion[]>;
|
|
66
67
|
declare const _default: {
|
|
67
68
|
init: typeof init;
|
|
@@ -71,6 +72,7 @@ declare const _default: {
|
|
|
71
72
|
generateTrackingLink: typeof generateTrackingLink;
|
|
72
73
|
getConversions: typeof getConversions;
|
|
73
74
|
createAffiliateCode: typeof createAffiliateCode;
|
|
75
|
+
getAffiliateCode: typeof getAffiliateCode;
|
|
74
76
|
};
|
|
75
77
|
export default _default;
|
|
76
78
|
//# sourceMappingURL=core.d.ts.map
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYzF,wBAAgB,IAAI,CAAC,QAAQ,EAAE,YAAY,QAqB1C;AAQD;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD1G;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjF;AAED;;;;;;;;;IASI;AACJ,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzG;AAED;;;;;;;;;;;;IAYI;AACJ,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EACxB,MAAM,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAG5D
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAYzF,wBAAgB,IAAI,CAAC,QAAQ,EAAE,YAAY,QAqB1C;AAQD;;;;;;;;;GASG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,SAAS,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuD1G;AAED;;;;;;;;;GASG;AACH,wBAAsB,YAAY,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKnE;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,iBAAiB,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAEjF;AAED;;;;;;;;;IASI;AACJ,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAGzG;AAED;;;;;;;;;;;;IAYI;AACJ,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,MAAM,EACf,gBAAgB,EAAE,MAAM,EACxB,MAAM,CAAC,EAAE,mBAAmB,GAC3B,OAAO,CAAC,MAAM,CAAC,CAiBjB;AAED,wBAAsB,gBAAgB,CAAC,gBAAgB,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAEvF;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAG5D;;;;;;;;;;;AAuBD,wBASE"}
|
package/dist/index.mjs
CHANGED
|
@@ -6,10 +6,10 @@ function Ae(e, t) {
|
|
|
6
6
|
return e.apply(t, arguments);
|
|
7
7
|
};
|
|
8
8
|
}
|
|
9
|
-
const { toString: Re } = Object.prototype, { getPrototypeOf:
|
|
9
|
+
const { toString: Re } = Object.prototype, { getPrototypeOf: re } = Object, se = ((e) => (t) => {
|
|
10
10
|
const n = Re.call(t);
|
|
11
11
|
return e[n] || (e[n] = n.slice(8, -1).toLowerCase());
|
|
12
|
-
})(/* @__PURE__ */ Object.create(null)), O = (e) => (e = e.toLowerCase(), (t) =>
|
|
12
|
+
})(/* @__PURE__ */ Object.create(null)), O = (e) => (e = e.toLowerCase(), (t) => se(t) === e), V = (e) => (t) => typeof t === e, { isArray: x } = Array, U = V("undefined");
|
|
13
13
|
function Xe(e) {
|
|
14
14
|
return e !== null && !U(e) && e.constructor !== null && !U(e.constructor) && P(e.constructor.isBuffer) && e.constructor.isBuffer(e);
|
|
15
15
|
}
|
|
@@ -18,12 +18,12 @@ function Ye(e) {
|
|
|
18
18
|
let t;
|
|
19
19
|
return typeof ArrayBuffer < "u" && ArrayBuffer.isView ? t = ArrayBuffer.isView(e) : t = e && e.buffer && Oe(e.buffer), t;
|
|
20
20
|
}
|
|
21
|
-
const Qe = V("string"), P = V("function"), Te = V("number"),
|
|
22
|
-
if (
|
|
21
|
+
const Qe = V("string"), P = V("function"), Te = V("number"), oe = (e) => e !== null && typeof e == "object", Ze = (e) => e === !0 || e === !1, j = (e) => {
|
|
22
|
+
if (se(e) !== "object")
|
|
23
23
|
return !1;
|
|
24
|
-
const t =
|
|
24
|
+
const t = re(e);
|
|
25
25
|
return (t === null || t === Object.prototype || Object.getPrototypeOf(t) === null) && !(Symbol.toStringTag in e) && !(Symbol.iterator in e);
|
|
26
|
-
}, et = O("Date"), tt = O("File"), nt = O("Blob"), rt = O("FileList"), st = (e) =>
|
|
26
|
+
}, et = O("Date"), tt = O("File"), nt = O("Blob"), rt = O("FileList"), st = (e) => oe(e) && P(e.pipe), ot = (e) => {
|
|
27
27
|
const t = "[object FormData]";
|
|
28
28
|
return e && (typeof FormData == "function" && e instanceof FormData || Re.call(e) === t || P(e.toString) && e.toString() === t);
|
|
29
29
|
}, it = O("URLSearchParams"), at = (e) => e.trim ? e.trim() : e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
|
|
@@ -51,10 +51,10 @@ function Ce(e, t) {
|
|
|
51
51
|
return null;
|
|
52
52
|
}
|
|
53
53
|
const Pe = (() => typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global)(), _e = (e) => !U(e) && e !== Pe;
|
|
54
|
-
function
|
|
54
|
+
function Q() {
|
|
55
55
|
const { caseless: e } = _e(this) && this || {}, t = {}, n = (r, s) => {
|
|
56
56
|
const o = e && Ce(t, s) || s;
|
|
57
|
-
j(t[o]) && j(r) ? t[o] =
|
|
57
|
+
j(t[o]) && j(r) ? t[o] = Q(t[o], r) : j(r) ? t[o] = Q({}, r) : x(r) ? t[o] = r.slice() : t[o] = r;
|
|
58
58
|
};
|
|
59
59
|
for (let r = 0, s = arguments.length; r < s; r++)
|
|
60
60
|
arguments[r] && L(arguments[r], n);
|
|
@@ -74,7 +74,7 @@ const ct = (e, t, n, { allOwnKeys: r } = {}) => (L(t, (s, o) => {
|
|
|
74
74
|
do {
|
|
75
75
|
for (s = Object.getOwnPropertyNames(e), o = s.length; o-- > 0; )
|
|
76
76
|
i = s[o], (!r || r(i, e, t)) && !c[i] && (t[i] = e[i], c[i] = !0);
|
|
77
|
-
e = n !== !1 &&
|
|
77
|
+
e = n !== !1 && re(e);
|
|
78
78
|
} while (e && (!n || n(e, t)) && e !== Object.prototype);
|
|
79
79
|
return t;
|
|
80
80
|
}, dt = (e, t, n) => {
|
|
@@ -93,7 +93,7 @@ const ct = (e, t, n, { allOwnKeys: r } = {}) => (L(t, (s, o) => {
|
|
|
93
93
|
for (; t-- > 0; )
|
|
94
94
|
n[t] = e[t];
|
|
95
95
|
return n;
|
|
96
|
-
}, ht = ((e) => (t) => e && t instanceof e)(typeof Uint8Array < "u" &&
|
|
96
|
+
}, ht = ((e) => (t) => e && t instanceof e)(typeof Uint8Array < "u" && re(Uint8Array)), mt = (e, t) => {
|
|
97
97
|
const r = (e && e[Symbol.iterator]).call(e);
|
|
98
98
|
let s;
|
|
99
99
|
for (; (s = r.next()) && !s.done; ) {
|
|
@@ -139,10 +139,10 @@ const ct = (e, t, n, { allOwnKeys: r } = {}) => (L(t, (s, o) => {
|
|
|
139
139
|
};
|
|
140
140
|
return x(e) ? r(e) : r(String(e).split(t)), n;
|
|
141
141
|
}, At = () => {
|
|
142
|
-
}, Rt = (e, t) => (e = +e, Number.isFinite(e) ? e : t),
|
|
142
|
+
}, Rt = (e, t) => (e = +e, Number.isFinite(e) ? e : t), W = "abcdefghijklmnopqrstuvwxyz", de = "0123456789", xe = {
|
|
143
143
|
DIGIT: de,
|
|
144
|
-
ALPHA:
|
|
145
|
-
ALPHA_DIGIT:
|
|
144
|
+
ALPHA: W,
|
|
145
|
+
ALPHA_DIGIT: W + W.toUpperCase() + de
|
|
146
146
|
}, Ot = (e = 16, t = xe.ALPHA_DIGIT) => {
|
|
147
147
|
let n = "";
|
|
148
148
|
const { length: r } = t;
|
|
@@ -155,7 +155,7 @@ function Tt(e) {
|
|
|
155
155
|
}
|
|
156
156
|
const Ct = (e) => {
|
|
157
157
|
const t = new Array(10), n = (r, s) => {
|
|
158
|
-
if (
|
|
158
|
+
if (oe(r)) {
|
|
159
159
|
if (t.indexOf(r) >= 0)
|
|
160
160
|
return;
|
|
161
161
|
if (!("toJSON" in r)) {
|
|
@@ -179,7 +179,7 @@ const Ct = (e) => {
|
|
|
179
179
|
isString: Qe,
|
|
180
180
|
isNumber: Te,
|
|
181
181
|
isBoolean: Ze,
|
|
182
|
-
isObject:
|
|
182
|
+
isObject: oe,
|
|
183
183
|
isPlainObject: j,
|
|
184
184
|
isUndefined: U,
|
|
185
185
|
isDate: et,
|
|
@@ -192,13 +192,13 @@ const Ct = (e) => {
|
|
|
192
192
|
isTypedArray: ht,
|
|
193
193
|
isFileList: rt,
|
|
194
194
|
forEach: L,
|
|
195
|
-
merge:
|
|
195
|
+
merge: Q,
|
|
196
196
|
extend: ct,
|
|
197
197
|
trim: at,
|
|
198
198
|
stripBOM: ut,
|
|
199
199
|
inherits: lt,
|
|
200
200
|
toFlatObject: ft,
|
|
201
|
-
kindOf:
|
|
201
|
+
kindOf: se,
|
|
202
202
|
kindOfTest: O,
|
|
203
203
|
endsWith: dt,
|
|
204
204
|
toArray: pt,
|
|
@@ -273,7 +273,7 @@ m.from = (e, t, n, r, s, o) => {
|
|
|
273
273
|
}, (c) => c !== "isAxiosError"), m.call(i, e.message, t, n, r, s), i.cause = e, i.name = e.name, o && Object.assign(i, o), i;
|
|
274
274
|
};
|
|
275
275
|
const Pt = null;
|
|
276
|
-
function
|
|
276
|
+
function Z(e) {
|
|
277
277
|
return a.isPlainObject(e) || a.isArray(e);
|
|
278
278
|
}
|
|
279
279
|
function Ue(e) {
|
|
@@ -285,7 +285,7 @@ function pe(e, t, n) {
|
|
|
285
285
|
}).join(n ? "." : "") : t;
|
|
286
286
|
}
|
|
287
287
|
function _t(e) {
|
|
288
|
-
return a.isArray(e) && !e.some(
|
|
288
|
+
return a.isArray(e) && !e.some(Z);
|
|
289
289
|
}
|
|
290
290
|
const Nt = a.toFlatObject(a, {}, null, function(t) {
|
|
291
291
|
return /^is[A-Z]/.test(t);
|
|
@@ -326,12 +326,12 @@ function K(e, t, n) {
|
|
|
326
326
|
);
|
|
327
327
|
}), !1;
|
|
328
328
|
}
|
|
329
|
-
return
|
|
329
|
+
return Z(d) ? !0 : (t.append(pe(A, h, o), u(d)), !1);
|
|
330
330
|
}
|
|
331
331
|
const p = [], w = Object.assign(Nt, {
|
|
332
332
|
defaultVisitor: l,
|
|
333
333
|
convertValue: u,
|
|
334
|
-
isVisitable:
|
|
334
|
+
isVisitable: Z
|
|
335
335
|
});
|
|
336
336
|
function y(d, h) {
|
|
337
337
|
if (!a.isUndefined(d)) {
|
|
@@ -366,10 +366,10 @@ function he(e) {
|
|
|
366
366
|
return t[r];
|
|
367
367
|
});
|
|
368
368
|
}
|
|
369
|
-
function
|
|
369
|
+
function ie(e, t) {
|
|
370
370
|
this._pairs = [], e && K(e, this, t);
|
|
371
371
|
}
|
|
372
|
-
const Le =
|
|
372
|
+
const Le = ie.prototype;
|
|
373
373
|
Le.append = function(t, n) {
|
|
374
374
|
this._pairs.push([t, n]);
|
|
375
375
|
};
|
|
@@ -389,7 +389,7 @@ function Be(e, t, n) {
|
|
|
389
389
|
return e;
|
|
390
390
|
const r = n && n.encode || xt, s = n && n.serialize;
|
|
391
391
|
let o;
|
|
392
|
-
if (s ? o = s(t, n) : o = a.isURLSearchParams(t) ? t.toString() : new
|
|
392
|
+
if (s ? o = s(t, n) : o = a.isURLSearchParams(t) ? t.toString() : new ie(t, n).toString(r), o) {
|
|
393
393
|
const i = e.indexOf("#");
|
|
394
394
|
i !== -1 && (e = e.slice(0, i)), e += (e.indexOf("?") === -1 ? "?" : "&") + o;
|
|
395
395
|
}
|
|
@@ -453,7 +453,7 @@ const me = Dt, Ie = {
|
|
|
453
453
|
silentJSONParsing: !0,
|
|
454
454
|
forcedJSONParsing: !0,
|
|
455
455
|
clarifyTimeoutError: !1
|
|
456
|
-
}, Ft = typeof URLSearchParams < "u" ? URLSearchParams :
|
|
456
|
+
}, Ft = typeof URLSearchParams < "u" ? URLSearchParams : ie, Ut = typeof FormData < "u" ? FormData : null, Lt = typeof Blob < "u" ? Blob : null, Bt = (() => {
|
|
457
457
|
let e;
|
|
458
458
|
return typeof navigator < "u" && ((e = navigator.product) === "ReactNative" || e === "NativeScript" || e === "NS") ? !1 : typeof window < "u" && typeof document < "u";
|
|
459
459
|
})(), It = (() => typeof WorkerGlobalScope < "u" && // eslint-disable-next-line no-undef
|
|
@@ -583,7 +583,7 @@ a.forEach(["delete", "get", "head"], function(t) {
|
|
|
583
583
|
a.forEach(["post", "put", "patch"], function(t) {
|
|
584
584
|
J.headers[t] = a.merge($t);
|
|
585
585
|
});
|
|
586
|
-
const
|
|
586
|
+
const ae = J, zt = a.toObjectSet([
|
|
587
587
|
"age",
|
|
588
588
|
"authorization",
|
|
589
589
|
"content-length",
|
|
@@ -625,7 +625,7 @@ function Kt(e) {
|
|
|
625
625
|
function Jt(e) {
|
|
626
626
|
return /^[-_a-zA-Z]+$/.test(e.trim());
|
|
627
627
|
}
|
|
628
|
-
function
|
|
628
|
+
function G(e, t, n, r, s) {
|
|
629
629
|
if (a.isFunction(r))
|
|
630
630
|
return r.call(this, t, n);
|
|
631
631
|
if (s && (t = n), !!a.isString(t)) {
|
|
@@ -685,7 +685,7 @@ let v = class {
|
|
|
685
685
|
has(t, n) {
|
|
686
686
|
if (t = D(t), t) {
|
|
687
687
|
const r = a.findKey(this, t);
|
|
688
|
-
return !!(r && this[r] !== void 0 && (!n ||
|
|
688
|
+
return !!(r && this[r] !== void 0 && (!n || G(this, this[r], r, n)));
|
|
689
689
|
}
|
|
690
690
|
return !1;
|
|
691
691
|
}
|
|
@@ -695,7 +695,7 @@ let v = class {
|
|
|
695
695
|
function o(i) {
|
|
696
696
|
if (i = D(i), i) {
|
|
697
697
|
const c = a.findKey(r, i);
|
|
698
|
-
c && (!n ||
|
|
698
|
+
c && (!n || G(r, r[c], c, n)) && (delete r[c], s = !0);
|
|
699
699
|
}
|
|
700
700
|
}
|
|
701
701
|
return a.isArray(t) ? t.forEach(o) : o(t), s;
|
|
@@ -705,7 +705,7 @@ let v = class {
|
|
|
705
705
|
let r = n.length, s = !1;
|
|
706
706
|
for (; r--; ) {
|
|
707
707
|
const o = n[r];
|
|
708
|
-
(!t ||
|
|
708
|
+
(!t || G(this, this[o], o, t, !0)) && (delete this[o], s = !0);
|
|
709
709
|
}
|
|
710
710
|
return s;
|
|
711
711
|
}
|
|
@@ -762,8 +762,8 @@ v.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User
|
|
|
762
762
|
a.freezeMethods(v.prototype);
|
|
763
763
|
a.freezeMethods(v);
|
|
764
764
|
const R = v;
|
|
765
|
-
function
|
|
766
|
-
const n = this ||
|
|
765
|
+
function X(e, t) {
|
|
766
|
+
const n = this || ae, r = t || n, s = R.from(r.headers);
|
|
767
767
|
let o = r.data;
|
|
768
768
|
return a.forEach(e, function(c) {
|
|
769
769
|
o = c.call(n, o, s.normalize(), t ? t.status : void 0);
|
|
@@ -997,22 +997,22 @@ const rn = {
|
|
|
997
997
|
},
|
|
998
998
|
adapters: $
|
|
999
999
|
};
|
|
1000
|
-
function
|
|
1000
|
+
function Y(e) {
|
|
1001
1001
|
if (e.cancelToken && e.cancelToken.throwIfRequested(), e.signal && e.signal.aborted)
|
|
1002
1002
|
throw new B(null, e);
|
|
1003
1003
|
}
|
|
1004
1004
|
function we(e) {
|
|
1005
|
-
return
|
|
1005
|
+
return Y(e), e.headers = R.from(e.headers), e.data = X.call(
|
|
1006
1006
|
e,
|
|
1007
1007
|
e.transformRequest
|
|
1008
|
-
), ["post", "put", "patch"].indexOf(e.method) !== -1 && e.headers.setContentType("application/x-www-form-urlencoded", !1), rn.getAdapter(e.adapter ||
|
|
1009
|
-
return
|
|
1008
|
+
), ["post", "put", "patch"].indexOf(e.method) !== -1 && e.headers.setContentType("application/x-www-form-urlencoded", !1), rn.getAdapter(e.adapter || ae.adapter)(e).then(function(r) {
|
|
1009
|
+
return Y(e), r.data = X.call(
|
|
1010
1010
|
e,
|
|
1011
1011
|
e.transformResponse,
|
|
1012
1012
|
r
|
|
1013
1013
|
), r.headers = R.from(r.headers), r;
|
|
1014
1014
|
}, function(r) {
|
|
1015
|
-
return je(r) || (
|
|
1015
|
+
return je(r) || (Y(e), r && r.response && (r.response.data = X.call(
|
|
1016
1016
|
e,
|
|
1017
1017
|
e.transformResponse,
|
|
1018
1018
|
r.response
|
|
@@ -1085,14 +1085,14 @@ function N(e, t) {
|
|
|
1085
1085
|
a.isUndefined(w) && p !== c || (n[l] = w);
|
|
1086
1086
|
}), n;
|
|
1087
1087
|
}
|
|
1088
|
-
const $e = "1.3.4",
|
|
1088
|
+
const $e = "1.3.4", ce = {};
|
|
1089
1089
|
["object", "boolean", "number", "function", "string", "symbol"].forEach((e, t) => {
|
|
1090
|
-
|
|
1090
|
+
ce[e] = function(r) {
|
|
1091
1091
|
return typeof r === e || "a" + (t < 1 ? "n " : " ") + e;
|
|
1092
1092
|
};
|
|
1093
1093
|
});
|
|
1094
1094
|
const Se = {};
|
|
1095
|
-
|
|
1095
|
+
ce.transitional = function(t, n, r) {
|
|
1096
1096
|
function s(o, i) {
|
|
1097
1097
|
return "[Axios v" + $e + "] Transitional option '" + o + "'" + i + (r ? ". " + r : "");
|
|
1098
1098
|
}
|
|
@@ -1127,10 +1127,10 @@ function sn(e, t, n) {
|
|
|
1127
1127
|
throw new m("Unknown option " + o, m.ERR_BAD_OPTION);
|
|
1128
1128
|
}
|
|
1129
1129
|
}
|
|
1130
|
-
const
|
|
1130
|
+
const ee = {
|
|
1131
1131
|
assertOptions: sn,
|
|
1132
|
-
validators:
|
|
1133
|
-
}, T =
|
|
1132
|
+
validators: ce
|
|
1133
|
+
}, T = ee.validators;
|
|
1134
1134
|
let z = class {
|
|
1135
1135
|
constructor(t) {
|
|
1136
1136
|
this.defaults = t, this.interceptors = {
|
|
@@ -1149,11 +1149,11 @@ let z = class {
|
|
|
1149
1149
|
request(t, n) {
|
|
1150
1150
|
typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n = N(this.defaults, n);
|
|
1151
1151
|
const { transitional: r, paramsSerializer: s, headers: o } = n;
|
|
1152
|
-
r !== void 0 &&
|
|
1152
|
+
r !== void 0 && ee.assertOptions(r, {
|
|
1153
1153
|
silentJSONParsing: T.transitional(T.boolean),
|
|
1154
1154
|
forcedJSONParsing: T.transitional(T.boolean),
|
|
1155
1155
|
clarifyTimeoutError: T.transitional(T.boolean)
|
|
1156
|
-
}, !1), s !== void 0 &&
|
|
1156
|
+
}, !1), s !== void 0 && ee.assertOptions(s, {
|
|
1157
1157
|
encode: T.function,
|
|
1158
1158
|
serialize: T.function
|
|
1159
1159
|
}, !0), n.method = (n.method || this.defaults.method || "get").toLowerCase();
|
|
@@ -1311,7 +1311,7 @@ function cn(e) {
|
|
|
1311
1311
|
function un(e) {
|
|
1312
1312
|
return a.isObject(e) && e.isAxiosError === !0;
|
|
1313
1313
|
}
|
|
1314
|
-
const
|
|
1314
|
+
const te = {
|
|
1315
1315
|
Continue: 100,
|
|
1316
1316
|
SwitchingProtocols: 101,
|
|
1317
1317
|
Processing: 102,
|
|
@@ -1376,17 +1376,17 @@ const ee = {
|
|
|
1376
1376
|
NotExtended: 510,
|
|
1377
1377
|
NetworkAuthenticationRequired: 511
|
|
1378
1378
|
};
|
|
1379
|
-
Object.entries(
|
|
1380
|
-
|
|
1379
|
+
Object.entries(te).forEach(([e, t]) => {
|
|
1380
|
+
te[t] = e;
|
|
1381
1381
|
});
|
|
1382
|
-
const ln =
|
|
1382
|
+
const ln = te;
|
|
1383
1383
|
function ze(e) {
|
|
1384
1384
|
const t = new H(e), n = Ae(H.prototype.request, t);
|
|
1385
1385
|
return a.extend(n, H.prototype, t, { allOwnKeys: !0 }), a.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(s) {
|
|
1386
1386
|
return ze(N(e, s));
|
|
1387
1387
|
}, n;
|
|
1388
1388
|
}
|
|
1389
|
-
const E = ze(
|
|
1389
|
+
const E = ze(ae);
|
|
1390
1390
|
E.Axios = H;
|
|
1391
1391
|
E.CanceledError = B;
|
|
1392
1392
|
E.CancelToken = an;
|
|
@@ -1406,21 +1406,21 @@ E.formToJSON = (e) => ke(a.isHTMLForm(e) ? new FormData(e) : e);
|
|
|
1406
1406
|
E.HttpStatusCode = ln;
|
|
1407
1407
|
E.default = E;
|
|
1408
1408
|
const Ve = E, {
|
|
1409
|
-
Axios:
|
|
1409
|
+
Axios: Wn,
|
|
1410
1410
|
AxiosError: fn,
|
|
1411
|
-
CanceledError:
|
|
1412
|
-
isCancel:
|
|
1413
|
-
CancelToken:
|
|
1414
|
-
VERSION:
|
|
1415
|
-
all:
|
|
1416
|
-
Cancel:
|
|
1417
|
-
isAxiosError:
|
|
1418
|
-
spread:
|
|
1419
|
-
toFormData:
|
|
1420
|
-
AxiosHeaders:
|
|
1421
|
-
HttpStatusCode:
|
|
1422
|
-
formToJSON:
|
|
1423
|
-
mergeConfig:
|
|
1411
|
+
CanceledError: Gn,
|
|
1412
|
+
isCancel: Xn,
|
|
1413
|
+
CancelToken: Yn,
|
|
1414
|
+
VERSION: Qn,
|
|
1415
|
+
all: Zn,
|
|
1416
|
+
Cancel: er,
|
|
1417
|
+
isAxiosError: tr,
|
|
1418
|
+
spread: nr,
|
|
1419
|
+
toFormData: rr,
|
|
1420
|
+
AxiosHeaders: sr,
|
|
1421
|
+
HttpStatusCode: or,
|
|
1422
|
+
formToJSON: ir,
|
|
1423
|
+
mergeConfig: ar
|
|
1424
1424
|
} = Ve;
|
|
1425
1425
|
class dn extends Error {
|
|
1426
1426
|
constructor(n) {
|
|
@@ -1537,7 +1537,7 @@ class Sn {
|
|
|
1537
1537
|
...t,
|
|
1538
1538
|
headers: {
|
|
1539
1539
|
Authorization: `Bearer ${t.apiKey}`,
|
|
1540
|
-
"X-Fuul-Sdk-Version": "3.
|
|
1540
|
+
"X-Fuul-Sdk-Version": "3.1.1"
|
|
1541
1541
|
}
|
|
1542
1542
|
}), this.queryParams = t.queryParams ? this.buildQueryParams(t.queryParams) : "";
|
|
1543
1543
|
}
|
|
@@ -1581,19 +1581,19 @@ const An = "fuul.tracking_id", Rn = ["google.com", "bing.com", "yahoo.com"], On
|
|
|
1581
1581
|
var r;
|
|
1582
1582
|
return (r = new URL(e).hostname) == null ? void 0 : r.split(".").slice(-2).join(".");
|
|
1583
1583
|
}, Ln = "https://api.fuul.xyz/api/v1/";
|
|
1584
|
-
let F = !1,
|
|
1584
|
+
let F = !1, ne = !1, ue, k, Ke, M, Je;
|
|
1585
1585
|
function Bn(e) {
|
|
1586
|
-
F = !!e.debug, !
|
|
1586
|
+
F = !!e.debug, !ne && (ue = e.apiKey, Vn(), k = Kn(
|
|
1587
1587
|
e.baseApiUrl ?? Ln,
|
|
1588
1588
|
e.defaultQueryParams ?? {}
|
|
1589
|
-
), Ke = new En({ httpClient: k, debug: F }), Je = new gn({ httpClient: k, debug: F }),
|
|
1589
|
+
), Ke = new En({ httpClient: k, debug: F }), Je = new gn({ httpClient: k, debug: F }), M = new yn({ httpClient: k, debug: F }), ne = !0, F && console.debug("Fuul SDK: init() complete"));
|
|
1590
1590
|
}
|
|
1591
1591
|
function ve() {
|
|
1592
|
-
if (!
|
|
1592
|
+
if (!ne)
|
|
1593
1593
|
throw new Error("Fuul SDK: You need to call init() to initialize the library before using any methods");
|
|
1594
1594
|
}
|
|
1595
1595
|
async function le(e, t, n) {
|
|
1596
|
-
ve(),
|
|
1596
|
+
ve(), zn();
|
|
1597
1597
|
const r = On(), s = Tn(), o = Pn(), i = _n(), c = Nn(), f = xn(), u = Cn(), l = {
|
|
1598
1598
|
name: e,
|
|
1599
1599
|
args: t || {},
|
|
@@ -1614,42 +1614,46 @@ async function kn(e) {
|
|
|
1614
1614
|
}
|
|
1615
1615
|
async function jn(e, t, n) {
|
|
1616
1616
|
const r = `I confirm that I am creating the ${t} code on Fuul`;
|
|
1617
|
-
await
|
|
1617
|
+
await M.create(e, t, n, r);
|
|
1618
1618
|
}
|
|
1619
1619
|
async function qn(e, t, n) {
|
|
1620
|
-
const r = await
|
|
1620
|
+
const r = await M.getCode(t), s = new URLSearchParams({
|
|
1621
1621
|
af: r ?? t
|
|
1622
1622
|
});
|
|
1623
1623
|
return n != null && n.title && s.append("af_title", n.title), n != null && n.format && s.append("af_format", n.format), n != null && n.place && s.append("af_place", n.place), `${e}?${s.toString()}`;
|
|
1624
1624
|
}
|
|
1625
|
-
async function $n() {
|
|
1625
|
+
async function $n(e) {
|
|
1626
|
+
return await M.getCode(e);
|
|
1627
|
+
}
|
|
1628
|
+
async function Hn() {
|
|
1626
1629
|
return ve(), Ke.getAll();
|
|
1627
1630
|
}
|
|
1628
|
-
function
|
|
1631
|
+
function zn() {
|
|
1629
1632
|
if (typeof window > "u" || typeof document > "u")
|
|
1630
1633
|
throw new Error("Fuul SDK: Browser context required");
|
|
1631
1634
|
}
|
|
1632
|
-
function
|
|
1633
|
-
if (!
|
|
1635
|
+
function Vn() {
|
|
1636
|
+
if (!ue)
|
|
1634
1637
|
throw new Error("Fuul SDK: Invalid API key");
|
|
1635
1638
|
}
|
|
1636
|
-
function
|
|
1639
|
+
function Kn(e, t) {
|
|
1637
1640
|
return new Sn({
|
|
1638
1641
|
baseURL: e,
|
|
1639
1642
|
timeout: 1e4,
|
|
1640
|
-
apiKey:
|
|
1643
|
+
apiKey: ue,
|
|
1641
1644
|
queryParams: t
|
|
1642
1645
|
});
|
|
1643
1646
|
}
|
|
1644
|
-
const
|
|
1647
|
+
const cr = {
|
|
1645
1648
|
init: Bn,
|
|
1646
1649
|
sendEvent: le,
|
|
1647
1650
|
sendPageview: In,
|
|
1648
1651
|
sendConnectWallet: kn,
|
|
1649
1652
|
generateTrackingLink: qn,
|
|
1650
|
-
getConversions:
|
|
1651
|
-
createAffiliateCode: jn
|
|
1653
|
+
getConversions: Hn,
|
|
1654
|
+
createAffiliateCode: jn,
|
|
1655
|
+
getAffiliateCode: $n
|
|
1652
1656
|
};
|
|
1653
1657
|
export {
|
|
1654
|
-
|
|
1658
|
+
cr as Fuul
|
|
1655
1659
|
};
|
package/dist/index.umd.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(S,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(S=typeof globalThis<"u"?globalThis:S||self,g(S.Fuul={}))})(this,function(S){"use strict";var $n=Object.defineProperty;var Hn=(S,g,P)=>g in S?$n(S,g,{enumerable:!0,configurable:!0,writable:!0,value:P}):S[g]=P;var A=(S,g,P)=>(Hn(S,typeof g!="symbol"?g+"":g,P),P);function g(e,t){return function(){return e.apply(t,arguments)}}const{toString:P}=Object.prototype,{getPrototypeOf:X}=Object,Y=(e=>t=>{const n=P.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),O=e=>(e=e.toLowerCase(),t=>Y(t)===e),q=e=>t=>typeof t===e,{isArray:D}=Array,L=q("undefined");function We(e){return e!==null&&!L(e)&&e.constructor!==null&&!L(e.constructor)&&N(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const he=O("ArrayBuffer");function Ge(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&he(e.buffer),t}const Xe=q("string"),N=q("function"),me=q("number"),Q=e=>e!==null&&typeof e=="object",Ye=e=>e===!0||e===!1,$=e=>{if(Y(e)!=="object")return!1;const t=X(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Qe=O("Date"),Ze=O("File"),et=O("Blob"),tt=O("FileList"),nt=e=>Q(e)&&N(e.pipe),rt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||P.call(e)===t||N(e.toString)&&e.toString()===t)},st=O("URLSearchParams"),ot=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function B(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),D(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(r=0;r<i;r++)c=o[r],t.call(null,e[c],c,e)}}function ye(e,t){t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Ee=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),we=e=>!L(e)&&e!==Ee;function Z(){const{caseless:e}=we(this)&&this||{},t={},n=(r,s)=>{const o=e&&ye(t,s)||s;$(t[o])&&$(r)?t[o]=Z(t[o],r):$(r)?t[o]=Z({},r):D(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&B(arguments[r],n);return t}const it=(e,t,n,{allOwnKeys:r}={})=>(B(t,(s,o)=>{n&&N(s)?e[o]=g(s,n):e[o]=s},{allOwnKeys:r}),e),at=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ct=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},ut=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&X(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},lt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},ft=e=>{if(!e)return null;if(D(e))return e;let t=e.length;if(!me(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},dt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&X(Uint8Array)),pt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},ht=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},mt=O("HTMLFormElement"),yt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),ge=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Et=O("RegExp"),Se=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};B(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},wt=e=>{Se(e,(t,n)=>{if(N(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(N(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},gt=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return D(e)?r(e):r(String(e).split(t)),n},St=()=>{},bt=(e,t)=>(e=+e,Number.isFinite(e)?e:t),ee="abcdefghijklmnopqrstuvwxyz",be="0123456789",Ae={DIGIT:be,ALPHA:ee,ALPHA_DIGIT:ee+ee.toUpperCase()+be},At=(e=16,t=Ae.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n};function Rt(e){return!!(e&&N(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const a={isArray:D,isArrayBuffer:he,isBuffer:We,isFormData:rt,isArrayBufferView:Ge,isString:Xe,isNumber:me,isBoolean:Ye,isObject:Q,isPlainObject:$,isUndefined:L,isDate:Qe,isFile:Ze,isBlob:et,isRegExp:Et,isFunction:N,isStream:nt,isURLSearchParams:st,isTypedArray:dt,isFileList:tt,forEach:B,merge:Z,extend:it,trim:ot,stripBOM:at,inherits:ct,toFlatObject:ut,kindOf:Y,kindOfTest:O,endsWith:lt,toArray:ft,forEachEntry:pt,matchAll:ht,isHTMLForm:mt,hasOwnProperty:ge,hasOwnProp:ge,reduceDescriptors:Se,freezeMethods:wt,toObjectSet:gt,toCamelCase:yt,noop:St,toFiniteNumber:bt,findKey:ye,global:Ee,isContextDefined:we,ALPHABET:Ae,generateString:At,isSpecCompliantForm:Rt,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(Q(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=D(r)?[]:{};return B(r,(i,c)=>{const f=n(i,s+1);!L(f)&&(o[c]=f)}),t[s]=void 0,o}}return r};return n(e,0)}};function m(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}a.inherits(m,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Re=m.prototype,Oe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Oe[e]={value:e}}),Object.defineProperties(m,Oe),Object.defineProperty(Re,"isAxiosError",{value:!0}),m.from=(e,t,n,r,s,o)=>{const i=Object.create(Re);return a.toFlatObject(e,i,function(f){return f!==Error.prototype},c=>c!=="isAxiosError"),m.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};const Ot=null;function te(e){return a.isPlainObject(e)||a.isArray(e)}function Te(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ce(e,t,n){return e?e.concat(t).map(function(s,o){return s=Te(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Tt(e){return a.isArray(e)&&!e.some(te)}const Ct=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function H(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,C){return!a.isUndefined(C[h])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,f=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(d){if(d===null)return"";if(a.isDate(d))return d.toISOString();if(!f&&a.isBlob(d))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(d)||a.isTypedArray(d)?f&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,h,C){let b=d;if(d&&!C&&typeof d=="object"){if(a.endsWith(h,"{}"))h=r?h:h.slice(0,-2),d=JSON.stringify(d);else if(a.isArray(d)&&Tt(d)||(a.isFileList(d)||a.endsWith(h,"[]"))&&(b=a.toArray(d)))return h=Te(h),b.forEach(function(G,qn){!(a.isUndefined(G)||G===null)&&t.append(i===!0?Ce([h],qn,o):i===null?h:h+"[]",u(G))}),!1}return te(d)?!0:(t.append(Ce(C,h,o),u(d)),!1)}const p=[],w=Object.assign(Ct,{defaultVisitor:l,convertValue:u,isVisitable:te});function y(d,h){if(!a.isUndefined(d)){if(p.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(d),a.forEach(d,function(b,U){(!(a.isUndefined(b)||b===null)&&s.call(t,b,a.isString(U)?U.trim():U,h,w))===!0&&y(b,h?h.concat(U):[U])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Pe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ne(e,t){this._pairs=[],e&&H(e,this,t)}const Ne=ne.prototype;Ne.append=function(t,n){this._pairs.push([t,n])},Ne.toString=function(t){const n=t?function(r){return t.call(this,r,Pe)}:Pe;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Pt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function _e(e,t,n){if(!t)return e;const r=n&&n.encode||Pt,s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new ne(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Nt{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const xe=Nt,De={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},_t=typeof URLSearchParams<"u"?URLSearchParams:ne,xt=typeof FormData<"u"?FormData:null,Dt=typeof Blob<"u"?Blob:null,Ft=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Ut=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),R={isBrowser:!0,classes:{URLSearchParams:_t,FormData:xt,Blob:Dt},isStandardBrowserEnv:Ft,isStandardBrowserWebWorkerEnv:Ut,protocols:["http","https","file","blob","url","data"]};function Lt(e,t){return H(e,new R.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return R.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function Bt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function It(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function Fe(e){function t(n,r,s,o){let i=n[o++];const c=Number.isFinite(+i),f=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,f?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=It(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(Bt(r),s,n,0)}),n}return null}const kt={"Content-Type":void 0};function jt(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const z={transitional:De,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s&&s?JSON.stringify(Fe(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Lt(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return H(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),jt(t)):t}],transformResponse:[function(t){const n=this.transitional||z.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?m.from(c,m.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:R.classes.FormData,Blob:R.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};a.forEach(["delete","get","head"],function(t){z.headers[t]={}}),a.forEach(["post","put","patch"],function(t){z.headers[t]=a.merge(kt)});const re=z,qt=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$t=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
|
-
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&qt[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ue=Symbol("internals");function I(e){return e&&String(e).trim().toLowerCase()}function V(e){return e===!1||e==null?e:a.isArray(e)?e.map(V):String(e)}function Ht(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}function zt(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function
|
|
3
|
-
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[Ue]=this[Ue]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=I(i);r[c]||(Jt(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};J.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.freezeMethods(J.prototype),a.freezeMethods(J);const T=J;function oe(e,t){const n=this||re,r=t||n,s=T.from(r.headers);let o=r.data;return a.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function Le(e){return!!(e&&e.__CANCEL__)}function k(e,t,n){m.call(this,e??"canceled",m.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(k,m,{__CANCEL__:!0});function Kt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new m("Request failed with status code "+n.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const vt=R.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const f=[];f.push(n+"="+encodeURIComponent(r)),a.isNumber(s)&&f.push("expires="+new Date(s).toGMTString()),a.isString(o)&&f.push("path="+o),a.isString(i)&&f.push("domain="+i),c===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Mt(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Wt(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function Be(e,t){return e&&!Mt(t)?Wt(e,t):t}const Gt=R.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=a.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function Xt(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Yt(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(f){const u=Date.now(),l=r[o];i||(i=u),n[s]=f,r[s]=u;let p=o,w=0;for(;p!==s;)w+=n[p++],p=p%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const y=l&&u-l;return y?Math.round(w*1e3/y):void 0}}function Ie(e,t){let n=0;const r=Yt(50,250);return s=>{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,f=r(c),u=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:f||void 0,estimated:f&&i&&u?(i-o)/f:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const K={http:Ot,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=T.from(e.headers).normalize(),i=e.responseType;let c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}a.isFormData(s)&&(R.isStandardBrowserEnv||R.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let u=new XMLHttpRequest;if(e.auth){const y=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(y+":"+d))}const l=Be(e.baseURL,e.url);u.open(e.method.toUpperCase(),_e(l,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function p(){if(!u)return;const y=T.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),h={data:!i||i==="text"||i==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:y,config:e,request:u};Kt(function(b){n(b),f()},function(b){r(b),f()},h),u=null}if("onloadend"in u?u.onloadend=p:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(p)},u.onabort=function(){u&&(r(new m("Request aborted",m.ECONNABORTED,e,u)),u=null)},u.onerror=function(){r(new m("Network Error",m.ERR_NETWORK,e,u)),u=null},u.ontimeout=function(){let d=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const h=e.transitional||De;e.timeoutErrorMessage&&(d=e.timeoutErrorMessage),r(new m(d,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,u)),u=null},R.isStandardBrowserEnv){const y=(e.withCredentials||Gt(l))&&e.xsrfCookieName&&vt.read(e.xsrfCookieName);y&&o.set(e.xsrfHeaderName,y)}s===void 0&&o.setContentType(null),"setRequestHeader"in u&&a.forEach(o.toJSON(),function(d,h){u.setRequestHeader(h,d)}),a.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),i&&i!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",Ie(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",Ie(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=y=>{u&&(r(!y||y.type?new k(null,e,u):y),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const w=Xt(l);if(w&&R.protocols.indexOf(w)===-1){r(new m("Unsupported protocol "+w+":",m.ERR_BAD_REQUEST,e));return}u.send(s||null)})}};a.forEach(K,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Qt={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;s<t&&(n=e[s],!(r=a.isString(n)?K[n.toLowerCase()]:n));s++);if(!r)throw r===!1?new m(`Adapter ${n} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(K,n)?`Adapter '${n}' is not available in the build`:`Unknown adapter '${n}'`);if(!a.isFunction(r))throw new TypeError("adapter is not a function");return r},adapters:K};function ie(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new k(null,e)}function ke(e){return ie(e),e.headers=T.from(e.headers),e.data=oe.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Qt.getAdapter(e.adapter||re.adapter)(e).then(function(r){return ie(e),r.data=oe.call(e,e.transformResponse,r),r.headers=T.from(r.headers),r},function(r){return Le(r)||(ie(e),r&&r.response&&(r.response.data=oe.call(e,e.transformResponse,r.response),r.response.headers=T.from(r.response.headers))),Promise.reject(r)})}const je=e=>e instanceof T?e.toJSON():e;function F(e,t){t=t||{};const n={};function r(u,l,p){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:p},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,p){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u,p)}else return r(u,l,p)}function o(u,l){if(!a.isUndefined(l))return r(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function c(u,l,p){if(p in t)return r(u,l);if(p in e)return r(void 0,u)}const f={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l)=>s(je(u),je(l),!0)};return a.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const p=f[l]||s,w=p(e[l],t[l],l);a.isUndefined(w)&&p!==c||(n[l]=w)}),n}const qe="1.3.4",ae={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ae[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const $e={};ae.transitional=function(t,n,r){function s(o,i){return"[Axios v"+qe+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new m(s(i," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!$e[i]&&($e[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Zt(e,t,n){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],f=c===void 0||i(c,o,e);if(f!==!0)throw new m("option "+o+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+o,m.ERR_BAD_OPTION)}}const ce={assertOptions:Zt,validators:ae},_=ce.validators;let v=class{constructor(t){this.defaults=t,this.interceptors={request:new xe,response:new xe}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=F(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ce.assertOptions(r,{silentJSONParsing:_.transitional(_.boolean),forcedJSONParsing:_.transitional(_.boolean),clarifyTimeoutError:_.transitional(_.boolean)},!1),s!==void 0&&ce.assertOptions(s,{encode:_.function,serialize:_.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&a.merge(o.common,o[n.method]),i&&a.forEach(["delete","get","head","post","put","patch","common"],d=>{delete o[d]}),n.headers=T.concat(i,o);const c=[];let f=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(f=f&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let l,p=0,w;if(!f){const d=[ke.bind(this),void 0];for(d.unshift.apply(d,c),d.push.apply(d,u),w=d.length,l=Promise.resolve(n);p<w;)l=l.then(d[p++],d[p++]);return l}w=c.length;let y=n;for(p=0;p<w;){const d=c[p++],h=c[p++];try{y=d(y)}catch(C){h.call(this,C);break}}try{l=ke.call(this,y)}catch(d){return Promise.reject(d)}for(p=0,w=u.length;p<w;)l=l.then(u[p++],u[p++]);return l}getUri(t){t=F(this.defaults,t);const n=Be(t.baseURL,t.url);return _e(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){v.prototype[t]=function(n,r){return this.request(F(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,c){return this.request(F(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}v.prototype[t]=n(),v.prototype[t+"Form"]=n(!0)});const M=v,en=class Me{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new k(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Me(function(s){t=s}),cancel:t}}};function tn(e){return function(n){return e.apply(null,n)}}function nn(e){return a.isObject(e)&&e.isAxiosError===!0}const ue={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(ue).forEach(([e,t])=>{ue[t]=e});const rn=ue;function He(e){const t=new M(e),n=g(M.prototype.request,t);return a.extend(n,M.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return He(F(e,s))},n}const E=He(re);E.Axios=M,E.CanceledError=k,E.CancelToken=en,E.isCancel=Le,E.VERSION=qe,E.toFormData=H,E.AxiosError=m,E.Cancel=E.CanceledError,E.all=function(t){return Promise.all(t)},E.spread=tn,E.isAxiosError=nn,E.mergeConfig=F,E.AxiosHeaders=T,E.formToJSON=e=>Fe(a.isHTMLForm(e)?new FormData(e):e),E.HttpStatusCode=rn,E.default=E;const ze=E,{Axios:vn,AxiosError:sn,CanceledError:Mn,isCancel:Wn,CancelToken:Gn,VERSION:Xn,all:Yn,Cancel:Qn,isAxiosError:Zn,spread:er,toFormData:tr,AxiosHeaders:nr,HttpStatusCode:rr,formToJSON:sr,mergeConfig:or}=ze;class on extends Error{constructor(n){super(n.join(", "));A(this,"errors");this.name="ValidationError",this.errors=n}}class an extends Error{constructor(n){super(`Address already used: ${n}`);A(this,"address");this.name="AddressInUseError",this.address=n}}class cn extends Error{constructor(n){super(`Code already used: ${n}`);A(this,"code");this.name="CodeInUseError",this.code=n}}class un extends Error{constructor(){super("Invalid signature provided"),this.name="InvalidSignatureError"}}class ln{constructor(t){A(this,"httpClient");A(this,"_debug");this.httpClient=t.httpClient,this._debug=t.debug}async create(t,n,r,s){var o;try{await this.httpClient.post("/affiliates",{address:t,name:n,code:n,signature:r,signature_message:s})}catch(i){if(i instanceof sn){const c=(o=i.response)==null?void 0:o.data;if(typeof(c==null?void 0:c.message)=="string"){const f=c.message.toLowerCase();throw f=="invalid signature"?new un:f=="address in use"?new an(t):f=="code in use"?new cn(n):new Error(f)}else if((c==null?void 0:c.message)instanceof Array)throw new on(c.message)}throw i}}async getCode(t){try{const n=await this.httpClient.get(`/affiliates/${t}`);return n.status!==200?null:n.data.code}catch(n){return console.error("Fuul SDK: Could not get affiliate code",n),null}}}class fn{constructor(t){A(this,"httpClient");this.httpClient=t.httpClient}async getAll(){const{data:t}=await this.httpClient.get("conversions");return t}}const Ve="fuul.sent",dn=60;class pn{constructor(t){A(this,"debug");A(this,"httpClient");this.httpClient=t.httpClient,this.debug=!!t.debug}async sendEvent(t){if(this.isDuplicate(t)){this.debug&&console.debug("Fuul SDK: Event is considered duplicate and will not be sent");return}await this.httpClient.post("events",t),this.debug&&console.debug(`Fuul SDK: Sent '${t.name}' event`),this.saveSentEvent(t)}isDuplicate(t){const n=`${Ve}_${t.name}`,r=localStorage.getItem(n);if(!r)return!1;const s=JSON.parse(r);if(this.getCurrentTimestamp()-s.timestamp>dn)return!1;let f=!1;t.metadata&&(f=s.metadata.tracking_id===t.metadata.tracking_id&&s.metadata.project_id===t.metadata.project_id&&s.metadata.referrer===t.metadata.referrer&&s.metadata.source===t.metadata.source&&s.metadata.category===t.metadata.category&&s.metadata.title===t.metadata.title&&s.metadata.tag===t.metadata.tag&&s.user_address===t.user_address&&s.signature===t.signature&&s.signature_message===t.signature_message);let u=!1;return t.args&&s.args&&(u=s.args.page===t.args.page),u&&f}getCurrentTimestamp(){return Date.now()/1e3}saveSentEvent(t){const n=`${Ve}_${t.name}`,r=this.getCurrentTimestamp(),s={...t,timestamp:r};localStorage.setItem(n,JSON.stringify(s))}}class hn{constructor(t){A(this,"client");A(this,"queryParams");this.client=ze.create({...t,headers:{Authorization:`Bearer ${t.apiKey}`,"X-Fuul-Sdk-Version":"3.0.1"}}),this.queryParams=t.queryParams?this.buildQueryParams(t.queryParams):""}buildQueryParams(t){let n="";return Object.keys(t).forEach(r=>{n=n===""?n+`?${r}=${t[r]}`:n+`&${r}=${t[r]}`}),n}async get(t,n){return this.client.get(t+this.queryParams,{params:n})}async post(t,n){return this.client.post(t+this.queryParams,n)}async put(t,n){return this.client.put(t+this.queryParams,n)}async delete(t){return this.client.delete(t+this.queryParams)}}let mn=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");const yn="fuul.tracking_id",En=["google.com","bing.com","yahoo.com"],wn=()=>Tn(yn,()=>mn()),gn=()=>x("af")||x("referrer"),Sn=()=>document.referrer,bn=()=>Cn(),An=()=>x("category"),Rn=()=>x("title"),On=()=>x("tag"),Tn=(e,t)=>{const n=localStorage.getItem(e);if(n)return n;{const r=t();return r?localStorage.setItem(e,r):localStorage.removeItem(e),r}},x=e=>new URLSearchParams(window.location.search).get(e),Cn=()=>{const e=x("source"),t=x("af")||x("referrer");if(e)return e;if(t)return"affiliate";const n=Pn(document.referrer);return En.includes(n)?"organic":"direct"},Pn=e=>{var r;return(r=new URL(e).hostname)==null?void 0:r.split(".").slice(-2).join(".")},Nn="https://api.fuul.xyz/api/v1/";let j=!1,le=!1,fe,W,Je,de,Ke;function _n(e){j=!!e.debug,!le&&(fe=e.apiKey,In(),W=kn(e.baseApiUrl??Nn,e.defaultQueryParams??{}),Je=new fn({httpClient:W,debug:j}),Ke=new pn({httpClient:W,debug:j}),de=new ln({httpClient:W,debug:j}),le=!0,j&&console.debug("Fuul SDK: init() complete"))}function ve(){if(!le)throw new Error("Fuul SDK: You need to call init() to initialize the library before using any methods")}async function pe(e,t,n){ve(),Bn();const r=wn(),s=gn(),o=bn(),i=An(),c=Rn(),f=On(),u=Sn(),l={name:e,args:t||{},metadata:{tracking_id:r??""}};n!=null&&n.address&&(l.user_address=n.address),n!=null&&n.signature&&(l.signature=n==null?void 0:n.signature,l.signature_message=n==null?void 0:n.message),s&&(l.metadata.referrer=s,l.metadata.affiliate_id=s),u&&(l.metadata.referrer_url=u),o&&(l.metadata.source=o),i&&(l.metadata.category=i),c&&(l.metadata.title=c),f&&(l.metadata.tag=f),Ke.sendEvent(l)}async function xn(e){await pe("pageview",{page:e??document.location.pathname,locationOrigin:document.location.origin})}async function Dn(e){await pe("connect_wallet",{},e)}async function Fn(e,t,n){const r=`I confirm that I am creating the ${t} code on Fuul`;await de.create(e,t,n,r)}async function Un(e,t,n){const r=await de.getCode(t),s=new URLSearchParams({af:r??t});return n!=null&&n.title&&s.append("af_title",n.title),n!=null&&n.format&&s.append("af_format",n.format),n!=null&&n.place&&s.append("af_place",n.place),`${e}?${s.toString()}`}async function Ln(){return ve(),Je.getAll()}function Bn(){if(typeof window>"u"||typeof document>"u")throw new Error("Fuul SDK: Browser context required")}function In(){if(!fe)throw new Error("Fuul SDK: Invalid API key")}function kn(e,t){return new hn({baseURL:e,timeout:1e4,apiKey:fe,queryParams:t})}const jn={init:_n,sendEvent:pe,sendPageview:xn,sendConnectWallet:Dn,generateTrackingLink:Un,getConversions:Ln,createAffiliateCode:Fn};S.Fuul=jn,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(S,g){typeof exports=="object"&&typeof module<"u"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(S=typeof globalThis<"u"?globalThis:S||self,g(S.Fuul={}))})(this,function(S){"use strict";var Hn=Object.defineProperty;var zn=(S,g,P)=>g in S?Hn(S,g,{enumerable:!0,configurable:!0,writable:!0,value:P}):S[g]=P;var A=(S,g,P)=>(zn(S,typeof g!="symbol"?g+"":g,P),P);function g(e,t){return function(){return e.apply(t,arguments)}}const{toString:P}=Object.prototype,{getPrototypeOf:Y}=Object,Q=(e=>t=>{const n=P.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),O=e=>(e=e.toLowerCase(),t=>Q(t)===e),q=e=>t=>typeof t===e,{isArray:D}=Array,L=q("undefined");function We(e){return e!==null&&!L(e)&&e.constructor!==null&&!L(e.constructor)&&N(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const he=O("ArrayBuffer");function Ge(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&he(e.buffer),t}const Xe=q("string"),N=q("function"),me=q("number"),Z=e=>e!==null&&typeof e=="object",Ye=e=>e===!0||e===!1,$=e=>{if(Q(e)!=="object")return!1;const t=Y(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Qe=O("Date"),Ze=O("File"),et=O("Blob"),tt=O("FileList"),nt=e=>Z(e)&&N(e.pipe),rt=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||P.call(e)===t||N(e.toString)&&e.toString()===t)},st=O("URLSearchParams"),ot=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function B(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),D(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{const o=n?Object.getOwnPropertyNames(e):Object.keys(e),i=o.length;let c;for(r=0;r<i;r++)c=o[r],t.call(null,e[c],c,e)}}function ye(e,t){t=t.toLowerCase();const n=Object.keys(e);let r=n.length,s;for(;r-- >0;)if(s=n[r],t===s.toLowerCase())return s;return null}const Ee=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),we=e=>!L(e)&&e!==Ee;function ee(){const{caseless:e}=we(this)&&this||{},t={},n=(r,s)=>{const o=e&&ye(t,s)||s;$(t[o])&&$(r)?t[o]=ee(t[o],r):$(r)?t[o]=ee({},r):D(r)?t[o]=r.slice():t[o]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&B(arguments[r],n);return t}const it=(e,t,n,{allOwnKeys:r}={})=>(B(t,(s,o)=>{n&&N(s)?e[o]=g(s,n):e[o]=s},{allOwnKeys:r}),e),at=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ct=(e,t,n,r)=>{e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},ut=(e,t,n,r)=>{let s,o,i;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),o=s.length;o-- >0;)i=s[o],(!r||r(i,e,t))&&!c[i]&&(t[i]=e[i],c[i]=!0);e=n!==!1&&Y(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},lt=(e,t,n)=>{e=String(e),(n===void 0||n>e.length)&&(n=e.length),n-=t.length;const r=e.indexOf(t,n);return r!==-1&&r===n},ft=e=>{if(!e)return null;if(D(e))return e;let t=e.length;if(!me(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},dt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&Y(Uint8Array)),pt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const o=s.value;t.call(e,o[0],o[1])}},ht=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},mt=O("HTMLFormElement"),yt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),ge=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Et=O("RegExp"),Se=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};B(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},wt=e=>{Se(e,(t,n)=>{if(N(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(N(r)){if(t.enumerable=!1,"writable"in t){t.writable=!1;return}t.set||(t.set=()=>{throw Error("Can not rewrite read-only method '"+n+"'")})}})},gt=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return D(e)?r(e):r(String(e).split(t)),n},St=()=>{},bt=(e,t)=>(e=+e,Number.isFinite(e)?e:t),te="abcdefghijklmnopqrstuvwxyz",be="0123456789",Ae={DIGIT:be,ALPHA:te,ALPHA_DIGIT:te+te.toUpperCase()+be},At=(e=16,t=Ae.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n};function Rt(e){return!!(e&&N(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const a={isArray:D,isArrayBuffer:he,isBuffer:We,isFormData:rt,isArrayBufferView:Ge,isString:Xe,isNumber:me,isBoolean:Ye,isObject:Z,isPlainObject:$,isUndefined:L,isDate:Qe,isFile:Ze,isBlob:et,isRegExp:Et,isFunction:N,isStream:nt,isURLSearchParams:st,isTypedArray:dt,isFileList:tt,forEach:B,merge:ee,extend:it,trim:ot,stripBOM:at,inherits:ct,toFlatObject:ut,kindOf:Q,kindOfTest:O,endsWith:lt,toArray:ft,forEachEntry:pt,matchAll:ht,isHTMLForm:mt,hasOwnProperty:ge,hasOwnProp:ge,reduceDescriptors:Se,freezeMethods:wt,toObjectSet:gt,toCamelCase:yt,noop:St,toFiniteNumber:bt,findKey:ye,global:Ee,isContextDefined:we,ALPHABET:Ae,generateString:At,isSpecCompliantForm:Rt,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(Z(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=D(r)?[]:{};return B(r,(i,c)=>{const f=n(i,s+1);!L(f)&&(o[c]=f)}),t[s]=void 0,o}}return r};return n(e,0)}};function m(e,t,n,r,s){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),s&&(this.response=s)}a.inherits(m,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:a.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Re=m.prototype,Oe={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(e=>{Oe[e]={value:e}}),Object.defineProperties(m,Oe),Object.defineProperty(Re,"isAxiosError",{value:!0}),m.from=(e,t,n,r,s,o)=>{const i=Object.create(Re);return a.toFlatObject(e,i,function(f){return f!==Error.prototype},c=>c!=="isAxiosError"),m.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};const Ot=null;function ne(e){return a.isPlainObject(e)||a.isArray(e)}function Te(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ce(e,t,n){return e?e.concat(t).map(function(s,o){return s=Te(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Tt(e){return a.isArray(e)&&!e.some(ne)}const Ct=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function H(e,t,n){if(!a.isObject(e))throw new TypeError("target must be an object");t=t||new FormData,n=a.toFlatObject(n,{metaTokens:!0,dots:!1,indexes:!1},!1,function(h,C){return!a.isUndefined(C[h])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,f=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function u(d){if(d===null)return"";if(a.isDate(d))return d.toISOString();if(!f&&a.isBlob(d))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(d)||a.isTypedArray(d)?f&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,h,C){let b=d;if(d&&!C&&typeof d=="object"){if(a.endsWith(h,"{}"))h=r?h:h.slice(0,-2),d=JSON.stringify(d);else if(a.isArray(d)&&Tt(d)||(a.isFileList(d)||a.endsWith(h,"[]"))&&(b=a.toArray(d)))return h=Te(h),b.forEach(function(X,$n){!(a.isUndefined(X)||X===null)&&t.append(i===!0?Ce([h],$n,o):i===null?h:h+"[]",u(X))}),!1}return ne(d)?!0:(t.append(Ce(C,h,o),u(d)),!1)}const p=[],w=Object.assign(Ct,{defaultVisitor:l,convertValue:u,isVisitable:ne});function y(d,h){if(!a.isUndefined(d)){if(p.indexOf(d)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(d),a.forEach(d,function(b,U){(!(a.isUndefined(b)||b===null)&&s.call(t,b,a.isString(U)?U.trim():U,h,w))===!0&&y(b,h?h.concat(U):[U])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Pe(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function re(e,t){this._pairs=[],e&&H(e,this,t)}const Ne=re.prototype;Ne.append=function(t,n){this._pairs.push([t,n])},Ne.toString=function(t){const n=t?function(r){return t.call(this,r,Pe)}:Pe;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Pt(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function _e(e,t,n){if(!t)return e;const r=n&&n.encode||Pt,s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new re(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Nt{constructor(){this.handlers=[]}use(t,n,r){return this.handlers.push({fulfilled:t,rejected:n,synchronous:r?r.synchronous:!1,runWhen:r?r.runWhen:null}),this.handlers.length-1}eject(t){this.handlers[t]&&(this.handlers[t]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(t){a.forEach(this.handlers,function(r){r!==null&&t(r)})}}const xe=Nt,De={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},_t=typeof URLSearchParams<"u"?URLSearchParams:re,xt=typeof FormData<"u"?FormData:null,Dt=typeof Blob<"u"?Blob:null,Ft=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Ut=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),R={isBrowser:!0,classes:{URLSearchParams:_t,FormData:xt,Blob:Dt},isStandardBrowserEnv:Ft,isStandardBrowserWebWorkerEnv:Ut,protocols:["http","https","file","blob","url","data"]};function Lt(e,t){return H(e,new R.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,o){return R.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):o.defaultVisitor.apply(this,arguments)}},t))}function Bt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function It(e){const t={},n=Object.keys(e);let r;const s=n.length;let o;for(r=0;r<s;r++)o=n[r],t[o]=e[o];return t}function Fe(e){function t(n,r,s,o){let i=n[o++];const c=Number.isFinite(+i),f=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,f?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!c):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=It(s[i])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(Bt(r),s,n,0)}),n}return null}const kt={"Content-Type":void 0};function jt(e,t,n){if(a.isString(e))try{return(t||JSON.parse)(e),a.trim(e)}catch(r){if(r.name!=="SyntaxError")throw r}return(n||JSON.stringify)(e)}const z={transitional:De,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,o=a.isObject(t);if(o&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s&&s?JSON.stringify(Fe(t)):t;if(a.isArrayBuffer(t)||a.isBuffer(t)||a.isStream(t)||a.isFile(t)||a.isBlob(t))return t;if(a.isArrayBufferView(t))return t.buffer;if(a.isURLSearchParams(t))return n.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),t.toString();let c;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Lt(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const f=this.env&&this.env.FormData;return H(c?{"files[]":t}:t,f&&new f,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),jt(t)):t}],transformResponse:[function(t){const n=this.transitional||z.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&a.isString(t)&&(r&&!this.responseType||s)){const i=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(i)throw c.name==="SyntaxError"?m.from(c,m.ERR_BAD_RESPONSE,this,null,this.response):c}}return t}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:R.classes.FormData,Blob:R.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};a.forEach(["delete","get","head"],function(t){z.headers[t]={}}),a.forEach(["post","put","patch"],function(t){z.headers[t]=a.merge(kt)});const se=z,qt=a.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),$t=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
|
+
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&qt[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Ue=Symbol("internals");function I(e){return e&&String(e).trim().toLowerCase()}function V(e){return e===!1||e==null?e:a.isArray(e)?e.map(V):String(e)}function Ht(e){const t=Object.create(null),n=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let r;for(;r=n.exec(e);)t[r[1]]=r[2];return t}function zt(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function oe(e,t,n,r,s){if(a.isFunction(r))return r.call(this,t,n);if(s&&(t=n),!!a.isString(t)){if(a.isString(r))return t.indexOf(r)!==-1;if(a.isRegExp(r))return r.test(t)}}function Vt(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Jt(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,o,i){return this[r].call(this,t,s,o,i)},configurable:!0})})}let J=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(c,f,u){const l=I(f);if(!l)throw new Error("header name must be a non-empty string");const p=a.findKey(s,l);(!p||s[p]===void 0||u===!0||u===void 0&&s[p]!==!1)&&(s[p||f]=V(c))}const i=(c,f)=>a.forEach(c,(u,l)=>o(u,l,f));return a.isPlainObject(t)||t instanceof this.constructor?i(t,n):a.isString(t)&&(t=t.trim())&&!zt(t)?i($t(t),n):t!=null&&o(n,t,r),this}get(t,n){if(t=I(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return Ht(s);if(a.isFunction(n))return n.call(this,s,r);if(a.isRegExp(n))return n.exec(s);throw new TypeError("parser must be boolean|regexp|function")}}}has(t,n){if(t=I(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||oe(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function o(i){if(i=I(i),i){const c=a.findKey(r,i);c&&(!n||oe(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(t)?t.forEach(o):o(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const o=n[r];(!t||oe(this,this[o],o,t,!0))&&(delete this[o],s=!0)}return s}normalize(t){const n=this,r={};return a.forEach(this,(s,o)=>{const i=a.findKey(r,o);if(i){n[i]=V(s),delete n[o];return}const c=t?Vt(o):String(o).trim();c!==o&&delete n[o],n[c]=V(s),r[c]=!0}),this}concat(...t){return this.constructor.concat(this,...t)}toJSON(t){const n=Object.create(null);return a.forEach(this,(r,s)=>{r!=null&&r!==!1&&(n[s]=t&&a.isArray(r)?r.join(", "):r)}),n}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([t,n])=>t+": "+n).join(`
|
|
3
|
+
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(t){return t instanceof this?t:new this(t)}static concat(t,...n){const r=new this(t);return n.forEach(s=>r.set(s)),r}static accessor(t){const r=(this[Ue]=this[Ue]={accessors:{}}).accessors,s=this.prototype;function o(i){const c=I(i);r[c]||(Jt(s,i),r[c]=!0)}return a.isArray(t)?t.forEach(o):o(t),this}};J.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.freezeMethods(J.prototype),a.freezeMethods(J);const T=J;function ie(e,t){const n=this||se,r=t||n,s=T.from(r.headers);let o=r.data;return a.forEach(e,function(c){o=c.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function Le(e){return!!(e&&e.__CANCEL__)}function k(e,t,n){m.call(this,e??"canceled",m.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(k,m,{__CANCEL__:!0});function Kt(e,t,n){const r=n.config.validateStatus;!n.status||!r||r(n.status)?e(n):t(new m("Request failed with status code "+n.status,[m.ERR_BAD_REQUEST,m.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n))}const vt=R.isStandardBrowserEnv?function(){return{write:function(n,r,s,o,i,c){const f=[];f.push(n+"="+encodeURIComponent(r)),a.isNumber(s)&&f.push("expires="+new Date(s).toGMTString()),a.isString(o)&&f.push("path="+o),a.isString(i)&&f.push("domain="+i),c===!0&&f.push("secure"),document.cookie=f.join("; ")},read:function(n){const r=document.cookie.match(new RegExp("(^|;\\s*)("+n+")=([^;]*)"));return r?decodeURIComponent(r[3]):null},remove:function(n){this.write(n,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}();function Mt(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Wt(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function Be(e,t){return e&&!Mt(t)?Wt(e,t):t}const Gt=R.isStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(o){let i=o;return t&&(n.setAttribute("href",i),i=n.href),n.setAttribute("href",i),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:n.pathname.charAt(0)==="/"?n.pathname:"/"+n.pathname}}return r=s(window.location.href),function(i){const c=a.isString(i)?s(i):i;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function Xt(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Yt(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,o=0,i;return t=t!==void 0?t:1e3,function(f){const u=Date.now(),l=r[o];i||(i=u),n[s]=f,r[s]=u;let p=o,w=0;for(;p!==s;)w+=n[p++],p=p%e;if(s=(s+1)%e,s===o&&(o=(o+1)%e),u-i<t)return;const y=l&&u-l;return y?Math.round(w*1e3/y):void 0}}function Ie(e,t){let n=0;const r=Yt(50,250);return s=>{const o=s.loaded,i=s.lengthComputable?s.total:void 0,c=o-n,f=r(c),u=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:c,rate:f||void 0,estimated:f&&i&&u?(i-o)/f:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const K={http:Ot,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=T.from(e.headers).normalize(),i=e.responseType;let c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}a.isFormData(s)&&(R.isStandardBrowserEnv||R.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let u=new XMLHttpRequest;if(e.auth){const y=e.auth.username||"",d=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(y+":"+d))}const l=Be(e.baseURL,e.url);u.open(e.method.toUpperCase(),_e(l,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function p(){if(!u)return;const y=T.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),h={data:!i||i==="text"||i==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:y,config:e,request:u};Kt(function(b){n(b),f()},function(b){r(b),f()},h),u=null}if("onloadend"in u?u.onloadend=p:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(p)},u.onabort=function(){u&&(r(new m("Request aborted",m.ECONNABORTED,e,u)),u=null)},u.onerror=function(){r(new m("Network Error",m.ERR_NETWORK,e,u)),u=null},u.ontimeout=function(){let d=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const h=e.transitional||De;e.timeoutErrorMessage&&(d=e.timeoutErrorMessage),r(new m(d,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,u)),u=null},R.isStandardBrowserEnv){const y=(e.withCredentials||Gt(l))&&e.xsrfCookieName&&vt.read(e.xsrfCookieName);y&&o.set(e.xsrfHeaderName,y)}s===void 0&&o.setContentType(null),"setRequestHeader"in u&&a.forEach(o.toJSON(),function(d,h){u.setRequestHeader(h,d)}),a.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),i&&i!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",Ie(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",Ie(e.onUploadProgress)),(e.cancelToken||e.signal)&&(c=y=>{u&&(r(!y||y.type?new k(null,e,u):y),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c)));const w=Xt(l);if(w&&R.protocols.indexOf(w)===-1){r(new m("Unsupported protocol "+w+":",m.ERR_BAD_REQUEST,e));return}u.send(s||null)})}};a.forEach(K,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Qt={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let n,r;for(let s=0;s<t&&(n=e[s],!(r=a.isString(n)?K[n.toLowerCase()]:n));s++);if(!r)throw r===!1?new m(`Adapter ${n} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(a.hasOwnProp(K,n)?`Adapter '${n}' is not available in the build`:`Unknown adapter '${n}'`);if(!a.isFunction(r))throw new TypeError("adapter is not a function");return r},adapters:K};function ae(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new k(null,e)}function ke(e){return ae(e),e.headers=T.from(e.headers),e.data=ie.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Qt.getAdapter(e.adapter||se.adapter)(e).then(function(r){return ae(e),r.data=ie.call(e,e.transformResponse,r),r.headers=T.from(r.headers),r},function(r){return Le(r)||(ae(e),r&&r.response&&(r.response.data=ie.call(e,e.transformResponse,r.response),r.response.headers=T.from(r.response.headers))),Promise.reject(r)})}const je=e=>e instanceof T?e.toJSON():e;function F(e,t){t=t||{};const n={};function r(u,l,p){return a.isPlainObject(u)&&a.isPlainObject(l)?a.merge.call({caseless:p},u,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(u,l,p){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u,p)}else return r(u,l,p)}function o(u,l){if(!a.isUndefined(l))return r(void 0,l)}function i(u,l){if(a.isUndefined(l)){if(!a.isUndefined(u))return r(void 0,u)}else return r(void 0,l)}function c(u,l,p){if(p in t)return r(u,l);if(p in e)return r(void 0,u)}const f={url:o,method:o,data:o,baseURL:i,transformRequest:i,transformResponse:i,paramsSerializer:i,timeout:i,timeoutMessage:i,withCredentials:i,adapter:i,responseType:i,xsrfCookieName:i,xsrfHeaderName:i,onUploadProgress:i,onDownloadProgress:i,decompress:i,maxContentLength:i,maxBodyLength:i,beforeRedirect:i,transport:i,httpAgent:i,httpsAgent:i,cancelToken:i,socketPath:i,responseEncoding:i,validateStatus:c,headers:(u,l)=>s(je(u),je(l),!0)};return a.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const p=f[l]||s,w=p(e[l],t[l],l);a.isUndefined(w)&&p!==c||(n[l]=w)}),n}const qe="1.3.4",ce={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ce[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const $e={};ce.transitional=function(t,n,r){function s(o,i){return"[Axios v"+qe+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,c)=>{if(t===!1)throw new m(s(i," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!$e[i]&&($e[i]=!0,console.warn(s(i," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(o,i,c):!0}};function Zt(e,t,n){if(typeof e!="object")throw new m("options must be an object",m.ERR_BAD_OPTION_VALUE);const r=Object.keys(e);let s=r.length;for(;s-- >0;){const o=r[s],i=t[o];if(i){const c=e[o],f=c===void 0||i(c,o,e);if(f!==!0)throw new m("option "+o+" must be "+f,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+o,m.ERR_BAD_OPTION)}}const ue={assertOptions:Zt,validators:ce},_=ue.validators;let v=class{constructor(t){this.defaults=t,this.interceptors={request:new xe,response:new xe}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=F(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ue.assertOptions(r,{silentJSONParsing:_.transitional(_.boolean),forcedJSONParsing:_.transitional(_.boolean),clarifyTimeoutError:_.transitional(_.boolean)},!1),s!==void 0&&ue.assertOptions(s,{encode:_.function,serialize:_.function},!0),n.method=(n.method||this.defaults.method||"get").toLowerCase();let i;i=o&&a.merge(o.common,o[n.method]),i&&a.forEach(["delete","get","head","post","put","patch","common"],d=>{delete o[d]}),n.headers=T.concat(i,o);const c=[];let f=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(f=f&&h.synchronous,c.unshift(h.fulfilled,h.rejected))});const u=[];this.interceptors.response.forEach(function(h){u.push(h.fulfilled,h.rejected)});let l,p=0,w;if(!f){const d=[ke.bind(this),void 0];for(d.unshift.apply(d,c),d.push.apply(d,u),w=d.length,l=Promise.resolve(n);p<w;)l=l.then(d[p++],d[p++]);return l}w=c.length;let y=n;for(p=0;p<w;){const d=c[p++],h=c[p++];try{y=d(y)}catch(C){h.call(this,C);break}}try{l=ke.call(this,y)}catch(d){return Promise.reject(d)}for(p=0,w=u.length;p<w;)l=l.then(u[p++],u[p++]);return l}getUri(t){t=F(this.defaults,t);const n=Be(t.baseURL,t.url);return _e(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){v.prototype[t]=function(n,r){return this.request(F(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,c){return this.request(F(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:o,data:i}))}}v.prototype[t]=n(),v.prototype[t+"Form"]=n(!0)});const M=v,en=class Me{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(o){n=o});const r=this;this.promise.then(s=>{if(!r._listeners)return;let o=r._listeners.length;for(;o-- >0;)r._listeners[o](s);r._listeners=null}),this.promise.then=s=>{let o;const i=new Promise(c=>{r.subscribe(c),o=c}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,c){r.reason||(r.reason=new k(o,i,c),n(r.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(t){if(this.reason){t(this.reason);return}this._listeners?this._listeners.push(t):this._listeners=[t]}unsubscribe(t){if(!this._listeners)return;const n=this._listeners.indexOf(t);n!==-1&&this._listeners.splice(n,1)}static source(){let t;return{token:new Me(function(s){t=s}),cancel:t}}};function tn(e){return function(n){return e.apply(null,n)}}function nn(e){return a.isObject(e)&&e.isAxiosError===!0}const le={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(le).forEach(([e,t])=>{le[t]=e});const rn=le;function He(e){const t=new M(e),n=g(M.prototype.request,t);return a.extend(n,M.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return He(F(e,s))},n}const E=He(se);E.Axios=M,E.CanceledError=k,E.CancelToken=en,E.isCancel=Le,E.VERSION=qe,E.toFormData=H,E.AxiosError=m,E.Cancel=E.CanceledError,E.all=function(t){return Promise.all(t)},E.spread=tn,E.isAxiosError=nn,E.mergeConfig=F,E.AxiosHeaders=T,E.formToJSON=e=>Fe(a.isHTMLForm(e)?new FormData(e):e),E.HttpStatusCode=rn,E.default=E;const ze=E,{Axios:Mn,AxiosError:sn,CanceledError:Wn,isCancel:Gn,CancelToken:Xn,VERSION:Yn,all:Qn,Cancel:Zn,isAxiosError:er,spread:tr,toFormData:nr,AxiosHeaders:rr,HttpStatusCode:sr,formToJSON:or,mergeConfig:ir}=ze;class on extends Error{constructor(n){super(n.join(", "));A(this,"errors");this.name="ValidationError",this.errors=n}}class an extends Error{constructor(n){super(`Address already used: ${n}`);A(this,"address");this.name="AddressInUseError",this.address=n}}class cn extends Error{constructor(n){super(`Code already used: ${n}`);A(this,"code");this.name="CodeInUseError",this.code=n}}class un extends Error{constructor(){super("Invalid signature provided"),this.name="InvalidSignatureError"}}class ln{constructor(t){A(this,"httpClient");A(this,"_debug");this.httpClient=t.httpClient,this._debug=t.debug}async create(t,n,r,s){var o;try{await this.httpClient.post("/affiliates",{address:t,name:n,code:n,signature:r,signature_message:s})}catch(i){if(i instanceof sn){const c=(o=i.response)==null?void 0:o.data;if(typeof(c==null?void 0:c.message)=="string"){const f=c.message.toLowerCase();throw f=="invalid signature"?new un:f=="address in use"?new an(t):f=="code in use"?new cn(n):new Error(f)}else if((c==null?void 0:c.message)instanceof Array)throw new on(c.message)}throw i}}async getCode(t){try{const n=await this.httpClient.get(`/affiliates/${t}`);return n.status!==200?null:n.data.code}catch(n){return console.error("Fuul SDK: Could not get affiliate code",n),null}}}class fn{constructor(t){A(this,"httpClient");this.httpClient=t.httpClient}async getAll(){const{data:t}=await this.httpClient.get("conversions");return t}}const Ve="fuul.sent",dn=60;class pn{constructor(t){A(this,"debug");A(this,"httpClient");this.httpClient=t.httpClient,this.debug=!!t.debug}async sendEvent(t){if(this.isDuplicate(t)){this.debug&&console.debug("Fuul SDK: Event is considered duplicate and will not be sent");return}await this.httpClient.post("events",t),this.debug&&console.debug(`Fuul SDK: Sent '${t.name}' event`),this.saveSentEvent(t)}isDuplicate(t){const n=`${Ve}_${t.name}`,r=localStorage.getItem(n);if(!r)return!1;const s=JSON.parse(r);if(this.getCurrentTimestamp()-s.timestamp>dn)return!1;let f=!1;t.metadata&&(f=s.metadata.tracking_id===t.metadata.tracking_id&&s.metadata.project_id===t.metadata.project_id&&s.metadata.referrer===t.metadata.referrer&&s.metadata.source===t.metadata.source&&s.metadata.category===t.metadata.category&&s.metadata.title===t.metadata.title&&s.metadata.tag===t.metadata.tag&&s.user_address===t.user_address&&s.signature===t.signature&&s.signature_message===t.signature_message);let u=!1;return t.args&&s.args&&(u=s.args.page===t.args.page),u&&f}getCurrentTimestamp(){return Date.now()/1e3}saveSentEvent(t){const n=`${Ve}_${t.name}`,r=this.getCurrentTimestamp(),s={...t,timestamp:r};localStorage.setItem(n,JSON.stringify(s))}}class hn{constructor(t){A(this,"client");A(this,"queryParams");this.client=ze.create({...t,headers:{Authorization:`Bearer ${t.apiKey}`,"X-Fuul-Sdk-Version":"3.1.1"}}),this.queryParams=t.queryParams?this.buildQueryParams(t.queryParams):""}buildQueryParams(t){let n="";return Object.keys(t).forEach(r=>{n=n===""?n+`?${r}=${t[r]}`:n+`&${r}=${t[r]}`}),n}async get(t,n){return this.client.get(t+this.queryParams,{params:n})}async post(t,n){return this.client.post(t+this.queryParams,n)}async put(t,n){return this.client.put(t+this.queryParams,n)}async delete(t){return this.client.delete(t+this.queryParams)}}let mn=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((t,n)=>(n&=63,n<36?t+=n.toString(36):n<62?t+=(n-26).toString(36).toUpperCase():n>62?t+="-":t+="_",t),"");const yn="fuul.tracking_id",En=["google.com","bing.com","yahoo.com"],wn=()=>Tn(yn,()=>mn()),gn=()=>x("af")||x("referrer"),Sn=()=>document.referrer,bn=()=>Cn(),An=()=>x("category"),Rn=()=>x("title"),On=()=>x("tag"),Tn=(e,t)=>{const n=localStorage.getItem(e);if(n)return n;{const r=t();return r?localStorage.setItem(e,r):localStorage.removeItem(e),r}},x=e=>new URLSearchParams(window.location.search).get(e),Cn=()=>{const e=x("source"),t=x("af")||x("referrer");if(e)return e;if(t)return"affiliate";const n=Pn(document.referrer);return En.includes(n)?"organic":"direct"},Pn=e=>{var r;return(r=new URL(e).hostname)==null?void 0:r.split(".").slice(-2).join(".")},Nn="https://api.fuul.xyz/api/v1/";let j=!1,fe=!1,de,W,Je,G,Ke;function _n(e){j=!!e.debug,!fe&&(de=e.apiKey,kn(),W=jn(e.baseApiUrl??Nn,e.defaultQueryParams??{}),Je=new fn({httpClient:W,debug:j}),Ke=new pn({httpClient:W,debug:j}),G=new ln({httpClient:W,debug:j}),fe=!0,j&&console.debug("Fuul SDK: init() complete"))}function ve(){if(!fe)throw new Error("Fuul SDK: You need to call init() to initialize the library before using any methods")}async function pe(e,t,n){ve(),In();const r=wn(),s=gn(),o=bn(),i=An(),c=Rn(),f=On(),u=Sn(),l={name:e,args:t||{},metadata:{tracking_id:r??""}};n!=null&&n.address&&(l.user_address=n.address),n!=null&&n.signature&&(l.signature=n==null?void 0:n.signature,l.signature_message=n==null?void 0:n.message),s&&(l.metadata.referrer=s,l.metadata.affiliate_id=s),u&&(l.metadata.referrer_url=u),o&&(l.metadata.source=o),i&&(l.metadata.category=i),c&&(l.metadata.title=c),f&&(l.metadata.tag=f),Ke.sendEvent(l)}async function xn(e){await pe("pageview",{page:e??document.location.pathname,locationOrigin:document.location.origin})}async function Dn(e){await pe("connect_wallet",{},e)}async function Fn(e,t,n){const r=`I confirm that I am creating the ${t} code on Fuul`;await G.create(e,t,n,r)}async function Un(e,t,n){const r=await G.getCode(t),s=new URLSearchParams({af:r??t});return n!=null&&n.title&&s.append("af_title",n.title),n!=null&&n.format&&s.append("af_format",n.format),n!=null&&n.place&&s.append("af_place",n.place),`${e}?${s.toString()}`}async function Ln(e){return await G.getCode(e)}async function Bn(){return ve(),Je.getAll()}function In(){if(typeof window>"u"||typeof document>"u")throw new Error("Fuul SDK: Browser context required")}function kn(){if(!de)throw new Error("Fuul SDK: Invalid API key")}function jn(e,t){return new hn({baseURL:e,timeout:1e4,apiKey:de,queryParams:t})}const qn={init:_n,sendEvent:pe,sendPageview:xn,sendConnectWallet:Dn,generateTrackingLink:Un,getConversions:Bn,createAffiliateCode:Fn,getAffiliateCode:Ln};S.Fuul=qn,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|