@fuul/sdk 2.1.1 → 2.1.2
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 +3 -2
- package/dist/core.d.ts.map +1 -1
- package/dist/index.mjs +32 -29
- package/dist/index.umd.js +2 -2
- package/dist/types/sdk.d.ts +5 -0
- package/dist/types/sdk.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Conversion } from './types/api';
|
|
2
|
-
import { EventArgs, FuulSettings, UserMetadata } from './types/sdk';
|
|
2
|
+
import { AffiliateLinkParams, EventArgs, FuulSettings, UserMetadata } from './types/sdk';
|
|
3
3
|
export declare function init(settings: FuulSettings): void;
|
|
4
4
|
/**
|
|
5
5
|
* @param {string} name Event name
|
|
@@ -41,6 +41,7 @@ export declare function sendConnectWallet(userMetadata: UserMetadata): Promise<v
|
|
|
41
41
|
* Generates a tracking link for an affiliate
|
|
42
42
|
* @param {string} baseUrl - Base url of the project
|
|
43
43
|
* @param {string} affiliateAddress - Affiliate wallet address
|
|
44
|
+
* @param {AffiliateLinkParams} params - Optional tracking parameters
|
|
44
45
|
* @returns {string} Tracking link
|
|
45
46
|
* @example
|
|
46
47
|
* ```typescript
|
|
@@ -49,7 +50,7 @@ export declare function sendConnectWallet(userMetadata: UserMetadata): Promise<v
|
|
|
49
50
|
* ```
|
|
50
51
|
* @see https://docs.fuul.xyz/technical-guide-for-projects/creating-partners-tracking-links-using-the-fuul-sdk
|
|
51
52
|
**/
|
|
52
|
-
export declare function generateTrackingLink(baseUrl: string, affiliateAddress: string): string;
|
|
53
|
+
export declare function generateTrackingLink(baseUrl: string, affiliateAddress: string, params?: AffiliateLinkParams): string;
|
|
53
54
|
export declare function getConversions(): Promise<Conversion[]>;
|
|
54
55
|
declare const _default: {
|
|
55
56
|
init: typeof init;
|
package/dist/core.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/core.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,UAAU,EAAa,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,mBAAmB,EAAE,SAAS,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAWzF,wBAAgB,IAAI,CAAC,QAAQ,EAAE,YAAY,QAoB1C;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;;;;;;;;;;;;IAYI;AACJ,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,mBAAmB,GAAG,MAAM,CAgBpH;AAED,wBAAsB,cAAc,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC,CAG5D;;;;;;;;;AAuBD,wBAOE"}
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
var Me = Object.defineProperty;
|
|
2
2
|
var ve = (e, t, n) => t in e ? Me(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
-
var
|
|
3
|
+
var _ = (e, t, n) => (ve(e, typeof t != "symbol" ? t + "" : t, n), n);
|
|
4
4
|
class We {
|
|
5
5
|
constructor(t) {
|
|
6
|
-
|
|
6
|
+
_(this, "httpClient");
|
|
7
7
|
this.httpClient = t.httpClient;
|
|
8
8
|
}
|
|
9
9
|
async getAll() {
|
|
@@ -14,8 +14,8 @@ class We {
|
|
|
14
14
|
const fe = "fuul.sent", Ge = 60;
|
|
15
15
|
class Ye {
|
|
16
16
|
constructor(t) {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
_(this, "debug");
|
|
18
|
+
_(this, "httpClient");
|
|
19
19
|
this.httpClient = t.httpClient, this.debug = !!t.debug;
|
|
20
20
|
}
|
|
21
21
|
async sendEvent(t) {
|
|
@@ -94,9 +94,9 @@ function Pe(e, t) {
|
|
|
94
94
|
return s;
|
|
95
95
|
return null;
|
|
96
96
|
}
|
|
97
|
-
const Ne = (() => typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global)(),
|
|
97
|
+
const Ne = (() => typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global)(), _e = (e) => !F(e) && e !== Ne;
|
|
98
98
|
function Q() {
|
|
99
|
-
const { caseless: e } =
|
|
99
|
+
const { caseless: e } = _e(this) && this || {}, t = {}, n = (r, s) => {
|
|
100
100
|
const o = e && Pe(t, s) || s;
|
|
101
101
|
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;
|
|
102
102
|
};
|
|
@@ -155,13 +155,13 @@ const ut = (e, t, n, { allOwnKeys: r } = {}) => (U(t, (s, o) => {
|
|
|
155
155
|
function(n, r, s) {
|
|
156
156
|
return r.toUpperCase() + s;
|
|
157
157
|
}
|
|
158
|
-
), de = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), St = O("RegExp"),
|
|
158
|
+
), de = (({ hasOwnProperty: e }) => (t, n) => e.call(t, n))(Object.prototype), St = O("RegExp"), Ce = (e, t) => {
|
|
159
159
|
const n = Object.getOwnPropertyDescriptors(e), r = {};
|
|
160
160
|
U(n, (s, o) => {
|
|
161
161
|
t(s, o, e) !== !1 && (r[o] = s);
|
|
162
162
|
}), Object.defineProperties(e, r);
|
|
163
163
|
}, bt = (e) => {
|
|
164
|
-
|
|
164
|
+
Ce(e, (t, n) => {
|
|
165
165
|
if (P(e) && ["arguments", "caller", "callee"].indexOf(n) !== -1)
|
|
166
166
|
return !1;
|
|
167
167
|
const r = e[n];
|
|
@@ -252,7 +252,7 @@ const Nt = (e) => {
|
|
|
252
252
|
hasOwnProperty: de,
|
|
253
253
|
hasOwnProp: de,
|
|
254
254
|
// an alias to avoid ESLint no-prototype-builtins detection
|
|
255
|
-
reduceDescriptors:
|
|
255
|
+
reduceDescriptors: Ce,
|
|
256
256
|
freezeMethods: bt,
|
|
257
257
|
toObjectSet: Rt,
|
|
258
258
|
toCamelCase: gt,
|
|
@@ -260,7 +260,7 @@ const Nt = (e) => {
|
|
|
260
260
|
toFiniteNumber: At,
|
|
261
261
|
findKey: Pe,
|
|
262
262
|
global: Ne,
|
|
263
|
-
isContextDefined:
|
|
263
|
+
isContextDefined: _e,
|
|
264
264
|
ALPHABET: xe,
|
|
265
265
|
generateString: Tt,
|
|
266
266
|
isSpecCompliantForm: Pt,
|
|
@@ -316,7 +316,7 @@ m.from = (e, t, n, r, s, o) => {
|
|
|
316
316
|
return d !== Error.prototype;
|
|
317
317
|
}, (u) => u !== "isAxiosError"), m.call(i, e.message, t, n, r, s), i.cause = e, i.name = e.name, o && Object.assign(i, o), i;
|
|
318
318
|
};
|
|
319
|
-
const
|
|
319
|
+
const _t = null;
|
|
320
320
|
function X(e) {
|
|
321
321
|
return a.isPlainObject(e) || a.isArray(e);
|
|
322
322
|
}
|
|
@@ -328,7 +328,7 @@ function he(e, t, n) {
|
|
|
328
328
|
return s = Ue(s), !n && o ? "[" + s + "]" : s;
|
|
329
329
|
}).join(n ? "." : "") : t;
|
|
330
330
|
}
|
|
331
|
-
function
|
|
331
|
+
function Ct(e) {
|
|
332
332
|
return a.isArray(e) && !e.some(X);
|
|
333
333
|
}
|
|
334
334
|
const xt = a.toFlatObject(a, {}, null, function(t) {
|
|
@@ -361,7 +361,7 @@ function K(e, t, n) {
|
|
|
361
361
|
if (f && !b && typeof f == "object") {
|
|
362
362
|
if (a.endsWith(h, "{}"))
|
|
363
363
|
h = r ? h : h.slice(0, -2), f = JSON.stringify(f);
|
|
364
|
-
else if (a.isArray(f) &&
|
|
364
|
+
else if (a.isArray(f) && Ct(f) || (a.isFileList(f) || a.endsWith(h, "[]")) && (g = a.toArray(f)))
|
|
365
365
|
return h = Ue(h), g.forEach(function(B, Ve) {
|
|
366
366
|
!(a.isUndefined(B) || B === null) && t.append(
|
|
367
367
|
// eslint-disable-next-line no-nested-ternary
|
|
@@ -1009,7 +1009,7 @@ const nn = typeof XMLHttpRequest < "u", rn = nn && function(e) {
|
|
|
1009
1009
|
c.send(s || null);
|
|
1010
1010
|
});
|
|
1011
1011
|
}, q = {
|
|
1012
|
-
http:
|
|
1012
|
+
http: _t,
|
|
1013
1013
|
xhr: rn
|
|
1014
1014
|
};
|
|
1015
1015
|
a.forEach(q, (e, t) => {
|
|
@@ -1064,7 +1064,7 @@ function ge(e) {
|
|
|
1064
1064
|
});
|
|
1065
1065
|
}
|
|
1066
1066
|
const Se = (e) => e instanceof R ? e.toJSON() : e;
|
|
1067
|
-
function
|
|
1067
|
+
function C(e, t) {
|
|
1068
1068
|
t = t || {};
|
|
1069
1069
|
const n = {};
|
|
1070
1070
|
function r(c, l, p) {
|
|
@@ -1191,7 +1191,7 @@ class z {
|
|
|
1191
1191
|
* @returns {Promise} The Promise to be fulfilled
|
|
1192
1192
|
*/
|
|
1193
1193
|
request(t, n) {
|
|
1194
|
-
typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n =
|
|
1194
|
+
typeof t == "string" ? (n = n || {}, n.url = t) : n = t || {}, n = C(this.defaults, n);
|
|
1195
1195
|
const { transitional: r, paramsSerializer: s, headers: o } = n;
|
|
1196
1196
|
r !== void 0 && Z.assertOptions(r, {
|
|
1197
1197
|
silentJSONParsing: A.transitional(A.boolean),
|
|
@@ -1248,14 +1248,14 @@ class z {
|
|
|
1248
1248
|
return l;
|
|
1249
1249
|
}
|
|
1250
1250
|
getUri(t) {
|
|
1251
|
-
t =
|
|
1251
|
+
t = C(this.defaults, t);
|
|
1252
1252
|
const n = qe(t.baseURL, t.url);
|
|
1253
1253
|
return Be(n, t.params, t.paramsSerializer);
|
|
1254
1254
|
}
|
|
1255
1255
|
}
|
|
1256
1256
|
a.forEach(["delete", "get", "head", "options"], function(t) {
|
|
1257
1257
|
z.prototype[t] = function(n, r) {
|
|
1258
|
-
return this.request(
|
|
1258
|
+
return this.request(C(r || {}, {
|
|
1259
1259
|
method: t,
|
|
1260
1260
|
url: n,
|
|
1261
1261
|
data: (r || {}).data
|
|
@@ -1265,7 +1265,7 @@ a.forEach(["delete", "get", "head", "options"], function(t) {
|
|
|
1265
1265
|
a.forEach(["post", "put", "patch"], function(t) {
|
|
1266
1266
|
function n(r) {
|
|
1267
1267
|
return function(o, i, u) {
|
|
1268
|
-
return this.request(
|
|
1268
|
+
return this.request(C(u || {}, {
|
|
1269
1269
|
method: t,
|
|
1270
1270
|
headers: r ? {
|
|
1271
1271
|
"Content-Type": "multipart/form-data"
|
|
@@ -1427,7 +1427,7 @@ const ln = ee;
|
|
|
1427
1427
|
function ze(e) {
|
|
1428
1428
|
const t = new H(e), n = Re(H.prototype.request, t);
|
|
1429
1429
|
return a.extend(n, H.prototype, t, { allOwnKeys: !0 }), a.extend(n, t, null, { allOwnKeys: !0 }), n.create = function(s) {
|
|
1430
|
-
return ze(
|
|
1430
|
+
return ze(C(e, s));
|
|
1431
1431
|
}, n;
|
|
1432
1432
|
}
|
|
1433
1433
|
const E = ze(ie);
|
|
@@ -1444,7 +1444,7 @@ E.all = function(t) {
|
|
|
1444
1444
|
};
|
|
1445
1445
|
E.spread = cn;
|
|
1446
1446
|
E.isAxiosError = un;
|
|
1447
|
-
E.mergeConfig =
|
|
1447
|
+
E.mergeConfig = C;
|
|
1448
1448
|
E.AxiosHeaders = R;
|
|
1449
1449
|
E.formToJSON = (e) => je(a.isHTMLForm(e) ? new FormData(e) : e);
|
|
1450
1450
|
E.HttpStatusCode = ln;
|
|
@@ -1452,8 +1452,8 @@ E.default = E;
|
|
|
1452
1452
|
const fn = E;
|
|
1453
1453
|
class dn {
|
|
1454
1454
|
constructor(t) {
|
|
1455
|
-
|
|
1456
|
-
|
|
1455
|
+
_(this, "client");
|
|
1456
|
+
_(this, "queryParams");
|
|
1457
1457
|
this.client = fn.create({
|
|
1458
1458
|
...t,
|
|
1459
1459
|
headers: {
|
|
@@ -1523,17 +1523,20 @@ async function le(e, t, n) {
|
|
|
1523
1523
|
};
|
|
1524
1524
|
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), c && (l.metadata.referrer_url = c), o && (l.metadata.source = o), i && (l.metadata.category = i), u && (l.metadata.title = u), d && (l.metadata.tag = d), Ke.sendEvent(l);
|
|
1525
1525
|
}
|
|
1526
|
-
async function
|
|
1526
|
+
async function _n(e) {
|
|
1527
1527
|
await le("pageview", {
|
|
1528
1528
|
page: e ?? document.location.pathname,
|
|
1529
1529
|
locationOrigin: document.location.origin
|
|
1530
1530
|
});
|
|
1531
1531
|
}
|
|
1532
|
-
async function
|
|
1532
|
+
async function Cn(e) {
|
|
1533
1533
|
await le("connect_wallet", {}, e);
|
|
1534
1534
|
}
|
|
1535
|
-
function xn(e, t) {
|
|
1536
|
-
|
|
1535
|
+
function xn(e, t, n) {
|
|
1536
|
+
const r = new URLSearchParams({
|
|
1537
|
+
af: t
|
|
1538
|
+
});
|
|
1539
|
+
return n != null && n.title && r.append("af_title", n.title), n != null && n.format && r.append("af_format", n.format), n != null && n.place && r.append("af_place", n.place), `${e}?${r.toString()}`;
|
|
1537
1540
|
}
|
|
1538
1541
|
async function Dn() {
|
|
1539
1542
|
return Je(), $e.getAll();
|
|
@@ -1557,8 +1560,8 @@ function Ln(e, t) {
|
|
|
1557
1560
|
const In = {
|
|
1558
1561
|
init: Nn,
|
|
1559
1562
|
sendEvent: le,
|
|
1560
|
-
sendPageview:
|
|
1561
|
-
sendConnectWallet:
|
|
1563
|
+
sendPageview: _n,
|
|
1564
|
+
sendConnectWallet: Cn,
|
|
1562
1565
|
generateTrackingLink: xn,
|
|
1563
1566
|
getConversions: Dn
|
|
1564
1567
|
};
|
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 Fn=Object.defineProperty;var Un=(S,g,P)=>g in S?Fn(S,g,{enumerable:!0,configurable:!0,writable:!0,value:P}):S[g]=P;var U=(S,g,P)=>(Un(S,typeof g!="symbol"?g+"":g,P),P);class g{constructor(t){U(this,"httpClient");this.httpClient=t.httpClient}async getAll(){const{data:t}=await this.httpClient.get("conversions");return t}}const P="fuul.sent",ve=60;class We{constructor(t){U(this,"debug");U(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=`${P}_${t.name}`,r=localStorage.getItem(n);if(!r)return!1;const s=JSON.parse(r);if(this.getCurrentTimestamp()-s.timestamp>ve)return!1;let d=!1;t.metadata&&(d=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 c=!1;return t.args&&s.args&&(c=s.args.page===t.args.page),c&&d}getCurrentTimestamp(){return Date.now()/1e3}saveSentEvent(t){const n=`${P}_${t.name}`,r=this.getCurrentTimestamp(),s={...t,timestamp:r};localStorage.setItem(n,JSON.stringify(s))}}function he(e,t){return function(){return e.apply(t,arguments)}}const{toString:me}=Object.prototype,{getPrototypeOf:G}=Object,X=(e=>t=>{const n=me.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),O=e=>(e=e.toLowerCase(),t=>X(t)===e),k=e=>t=>typeof t===e,{isArray:x}=Array,L=k("undefined");function Ge(e){return e!==null&&!L(e)&&e.constructor!==null&&!L(e.constructor)&&N(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ye=O("ArrayBuffer");function Xe(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ye(e.buffer),t}const Ye=k("string"),N=k("function"),Ee=k("number"),Y=e=>e!==null&&typeof e=="object",Qe=e=>e===!0||e===!1,q=e=>{if(X(e)!=="object")return!1;const t=G(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Ze=O("Date"),et=O("File"),tt=O("Blob"),nt=O("FileList"),rt=e=>Y(e)&&N(e.pipe),st=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||me.call(e)===t||N(e.toString)&&e.toString()===t)},ot=O("URLSearchParams"),it=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]),x(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 u;for(r=0;r<i;r++)u=o[r],t.call(null,e[u],u,e)}}function we(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 ge=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),Se=e=>!L(e)&&e!==ge;function Q(){const{caseless:e}=Se(this)&&this||{},t={},n=(r,s)=>{const o=e&&we(t,s)||s;q(t[o])&&q(r)?t[o]=Q(t[o],r):q(r)?t[o]=Q({},r):x(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 at=(e,t,n,{allOwnKeys:r}={})=>(B(t,(s,o)=>{n&&N(s)?e[o]=he(s,n):e[o]=s},{allOwnKeys:r}),e),ct=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ut=(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)},lt=(e,t,n,r)=>{let s,o,i;const u={};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))&&!u[i]&&(t[i]=e[i],u[i]=!0);e=n!==!1&&G(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},ft=(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},dt=e=>{if(!e)return null;if(x(e))return e;let t=e.length;if(!Ee(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},pt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&G(Uint8Array)),ht=(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])}},mt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},yt=O("HTMLFormElement"),Et=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),be=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),wt=O("RegExp"),Re=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};B(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},gt=e=>{Re(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+"'")})}})},St=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return x(e)?r(e):r(String(e).split(t)),n},bt=()=>{},Rt=(e,t)=>(e=+e,Number.isFinite(e)?e:t),Z="abcdefghijklmnopqrstuvwxyz",Oe="0123456789",Ae={DIGIT:Oe,ALPHA:Z,ALPHA_DIGIT:Z+Z.toUpperCase()+Oe},Ot=(e=16,t=Ae.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n};function At(e){return!!(e&&N(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const a={isArray:x,isArrayBuffer:ye,isBuffer:Ge,isFormData:st,isArrayBufferView:Xe,isString:Ye,isNumber:Ee,isBoolean:Qe,isObject:Y,isPlainObject:q,isUndefined:L,isDate:Ze,isFile:et,isBlob:tt,isRegExp:wt,isFunction:N,isStream:rt,isURLSearchParams:ot,isTypedArray:pt,isFileList:nt,forEach:B,merge:Q,extend:at,trim:it,stripBOM:ct,inherits:ut,toFlatObject:lt,kindOf:X,kindOfTest:O,endsWith:ft,toArray:dt,forEachEntry:ht,matchAll:mt,isHTMLForm:yt,hasOwnProperty:be,hasOwnProp:be,reduceDescriptors:Re,freezeMethods:gt,toObjectSet:St,toCamelCase:Et,noop:bt,toFiniteNumber:Rt,findKey:we,global:ge,isContextDefined:Se,ALPHABET:Ae,generateString:Ot,isSpecCompliantForm:At,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(Y(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=x(r)?[]:{};return B(r,(i,u)=>{const d=n(i,s+1);!L(d)&&(o[u]=d)}),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 Te=m.prototype,Pe={};["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=>{Pe[e]={value:e}}),Object.defineProperties(m,Pe),Object.defineProperty(Te,"isAxiosError",{value:!0}),m.from=(e,t,n,r,s,o)=>{const i=Object.create(Te);return a.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError"),m.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};const Tt=null;function ee(e){return a.isPlainObject(e)||a.isArray(e)}function Ne(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=Ne(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Pt(e){return a.isArray(e)&&!e.some(ee)}const Nt=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,T){return!a.isUndefined(T[h])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function c(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(!d&&a.isBlob(f))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,h,T){let b=f;if(f&&!T&&typeof f=="object"){if(a.endsWith(h,"{}"))h=r?h:h.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Pt(f)||(a.isFileList(f)||a.endsWith(h,"[]"))&&(b=a.toArray(f)))return h=Ne(h),b.forEach(function(W,Dn){!(a.isUndefined(W)||W===null)&&t.append(i===!0?Ce([h],Dn,o):i===null?h:h+"[]",c(W))}),!1}return ee(f)?!0:(t.append(Ce(T,h,o),c(f)),!1)}const p=[],w=Object.assign(Nt,{defaultVisitor:l,convertValue:c,isVisitable:ee});function y(f,h){if(!a.isUndefined(f)){if(p.indexOf(f)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(f),a.forEach(f,function(b,F){(!(a.isUndefined(b)||b===null)&&s.call(t,b,a.isString(F)?F.trim():F,h,w))===!0&&y(b,h?h.concat(F):[F])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return y(e),t}function _e(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function te(e,t){this._pairs=[],e&&H(e,this,t)}const xe=te.prototype;xe.append=function(t,n){this._pairs.push([t,n])},xe.toString=function(t){const n=t?function(r){return t.call(this,r,_e)}:_e;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Ct(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function De(e,t,n){if(!t)return e;const r=n&&n.encode||Ct,s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new te(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class _t{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 Fe=_t,Ue={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},xt=typeof URLSearchParams<"u"?URLSearchParams:te,Dt=typeof FormData<"u"?FormData:null,Ft=typeof Blob<"u"?Blob:null,Ut=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Lt=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),R={isBrowser:!0,classes:{URLSearchParams:xt,FormData:Dt,Blob:Ft},isStandardBrowserEnv:Ut,isStandardBrowserWebWorkerEnv:Lt,protocols:["http","https","file","blob","url","data"]};function Bt(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 It(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function jt(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 Le(e){function t(n,r,s,o){let i=n[o++];const u=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!u):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=jt(s[i])),!u)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(It(r),s,n,0)}),n}return null}const kt={"Content-Type":void 0};function qt(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:Ue,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(Le(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 u;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Bt(t,this.formSerializer).toString();if((u=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return H(u?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),qt(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(u){if(i)throw u.name==="SyntaxError"?m.from(u,m.ERR_BAD_RESPONSE,this,null,this.response):u}}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 ne=z,Ht=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"]),zt=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
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 Fn=Object.defineProperty;var Un=(S,g,P)=>g in S?Fn(S,g,{enumerable:!0,configurable:!0,writable:!0,value:P}):S[g]=P;var U=(S,g,P)=>(Un(S,typeof g!="symbol"?g+"":g,P),P);class g{constructor(t){U(this,"httpClient");this.httpClient=t.httpClient}async getAll(){const{data:t}=await this.httpClient.get("conversions");return t}}const P="fuul.sent",ve=60;class We{constructor(t){U(this,"debug");U(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=`${P}_${t.name}`,r=localStorage.getItem(n);if(!r)return!1;const s=JSON.parse(r);if(this.getCurrentTimestamp()-s.timestamp>ve)return!1;let d=!1;t.metadata&&(d=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 c=!1;return t.args&&s.args&&(c=s.args.page===t.args.page),c&&d}getCurrentTimestamp(){return Date.now()/1e3}saveSentEvent(t){const n=`${P}_${t.name}`,r=this.getCurrentTimestamp(),s={...t,timestamp:r};localStorage.setItem(n,JSON.stringify(s))}}function he(e,t){return function(){return e.apply(t,arguments)}}const{toString:me}=Object.prototype,{getPrototypeOf:G}=Object,X=(e=>t=>{const n=me.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),O=e=>(e=e.toLowerCase(),t=>X(t)===e),k=e=>t=>typeof t===e,{isArray:x}=Array,L=k("undefined");function Ge(e){return e!==null&&!L(e)&&e.constructor!==null&&!L(e.constructor)&&N(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const ye=O("ArrayBuffer");function Xe(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&ye(e.buffer),t}const Ye=k("string"),N=k("function"),Ee=k("number"),Y=e=>e!==null&&typeof e=="object",Qe=e=>e===!0||e===!1,q=e=>{if(X(e)!=="object")return!1;const t=G(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},Ze=O("Date"),et=O("File"),tt=O("Blob"),nt=O("FileList"),rt=e=>Y(e)&&N(e.pipe),st=e=>{const t="[object FormData]";return e&&(typeof FormData=="function"&&e instanceof FormData||me.call(e)===t||N(e.toString)&&e.toString()===t)},ot=O("URLSearchParams"),it=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]),x(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 u;for(r=0;r<i;r++)u=o[r],t.call(null,e[u],u,e)}}function we(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 ge=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),Se=e=>!L(e)&&e!==ge;function Q(){const{caseless:e}=Se(this)&&this||{},t={},n=(r,s)=>{const o=e&&we(t,s)||s;q(t[o])&&q(r)?t[o]=Q(t[o],r):q(r)?t[o]=Q({},r):x(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 at=(e,t,n,{allOwnKeys:r}={})=>(B(t,(s,o)=>{n&&N(s)?e[o]=he(s,n):e[o]=s},{allOwnKeys:r}),e),ct=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),ut=(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)},lt=(e,t,n,r)=>{let s,o,i;const u={};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))&&!u[i]&&(t[i]=e[i],u[i]=!0);e=n!==!1&&G(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},ft=(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},dt=e=>{if(!e)return null;if(x(e))return e;let t=e.length;if(!Ee(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},pt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&G(Uint8Array)),ht=(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])}},mt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},yt=O("HTMLFormElement"),Et=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),be=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),wt=O("RegExp"),Re=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};B(n,(s,o)=>{t(s,o,e)!==!1&&(r[o]=s)}),Object.defineProperties(e,r)},gt=e=>{Re(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+"'")})}})},St=(e,t)=>{const n={},r=s=>{s.forEach(o=>{n[o]=!0})};return x(e)?r(e):r(String(e).split(t)),n},bt=()=>{},Rt=(e,t)=>(e=+e,Number.isFinite(e)?e:t),Z="abcdefghijklmnopqrstuvwxyz",Oe="0123456789",Ae={DIGIT:Oe,ALPHA:Z,ALPHA_DIGIT:Z+Z.toUpperCase()+Oe},Ot=(e=16,t=Ae.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n};function At(e){return!!(e&&N(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const a={isArray:x,isArrayBuffer:ye,isBuffer:Ge,isFormData:st,isArrayBufferView:Xe,isString:Ye,isNumber:Ee,isBoolean:Qe,isObject:Y,isPlainObject:q,isUndefined:L,isDate:Ze,isFile:et,isBlob:tt,isRegExp:wt,isFunction:N,isStream:rt,isURLSearchParams:ot,isTypedArray:pt,isFileList:nt,forEach:B,merge:Q,extend:at,trim:it,stripBOM:ct,inherits:ut,toFlatObject:lt,kindOf:X,kindOfTest:O,endsWith:ft,toArray:dt,forEachEntry:ht,matchAll:mt,isHTMLForm:yt,hasOwnProperty:be,hasOwnProp:be,reduceDescriptors:Re,freezeMethods:gt,toObjectSet:St,toCamelCase:Et,noop:bt,toFiniteNumber:Rt,findKey:we,global:ge,isContextDefined:Se,ALPHABET:Ae,generateString:Ot,isSpecCompliantForm:At,toJSONObject:e=>{const t=new Array(10),n=(r,s)=>{if(Y(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const o=x(r)?[]:{};return B(r,(i,u)=>{const d=n(i,s+1);!L(d)&&(o[u]=d)}),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 Te=m.prototype,Pe={};["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=>{Pe[e]={value:e}}),Object.defineProperties(m,Pe),Object.defineProperty(Te,"isAxiosError",{value:!0}),m.from=(e,t,n,r,s,o)=>{const i=Object.create(Te);return a.toFlatObject(e,i,function(d){return d!==Error.prototype},u=>u!=="isAxiosError"),m.call(i,e.message,t,n,r,s),i.cause=e,i.name=e.name,o&&Object.assign(i,o),i};const Tt=null;function ee(e){return a.isPlainObject(e)||a.isArray(e)}function Ne(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function _e(e,t,n){return e?e.concat(t).map(function(s,o){return s=Ne(s),!n&&o?"["+s+"]":s}).join(n?".":""):t}function Pt(e){return a.isArray(e)&&!e.some(ee)}const Nt=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,T){return!a.isUndefined(T[h])});const r=n.metaTokens,s=n.visitor||l,o=n.dots,i=n.indexes,d=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function c(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(!d&&a.isBlob(f))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?d&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,h,T){let b=f;if(f&&!T&&typeof f=="object"){if(a.endsWith(h,"{}"))h=r?h:h.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&Pt(f)||(a.isFileList(f)||a.endsWith(h,"[]"))&&(b=a.toArray(f)))return h=Ne(h),b.forEach(function(W,Dn){!(a.isUndefined(W)||W===null)&&t.append(i===!0?_e([h],Dn,o):i===null?h:h+"[]",c(W))}),!1}return ee(f)?!0:(t.append(_e(T,h,o),c(f)),!1)}const p=[],w=Object.assign(Nt,{defaultVisitor:l,convertValue:c,isVisitable:ee});function y(f,h){if(!a.isUndefined(f)){if(p.indexOf(f)!==-1)throw Error("Circular reference detected in "+h.join("."));p.push(f),a.forEach(f,function(b,F){(!(a.isUndefined(b)||b===null)&&s.call(t,b,a.isString(F)?F.trim():F,h,w))===!0&&y(b,h?h.concat(F):[F])}),p.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return y(e),t}function Ce(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function te(e,t){this._pairs=[],e&&H(e,this,t)}const xe=te.prototype;xe.append=function(t,n){this._pairs.push([t,n])},xe.toString=function(t){const n=t?function(r){return t.call(this,r,Ce)}:Ce;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function _t(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function De(e,t,n){if(!t)return e;const r=n&&n.encode||_t,s=n&&n.serialize;let o;if(s?o=s(t,n):o=a.isURLSearchParams(t)?t.toString():new te(t,n).toString(r),o){const i=e.indexOf("#");i!==-1&&(e=e.slice(0,i)),e+=(e.indexOf("?")===-1?"?":"&")+o}return e}class Ct{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 Fe=Ct,Ue={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},xt=typeof URLSearchParams<"u"?URLSearchParams:te,Dt=typeof FormData<"u"?FormData:null,Ft=typeof Blob<"u"?Blob:null,Ut=(()=>{let e;return typeof navigator<"u"&&((e=navigator.product)==="ReactNative"||e==="NativeScript"||e==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),Lt=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),R={isBrowser:!0,classes:{URLSearchParams:xt,FormData:Dt,Blob:Ft},isStandardBrowserEnv:Ut,isStandardBrowserWebWorkerEnv:Lt,protocols:["http","https","file","blob","url","data"]};function Bt(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 It(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function jt(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 Le(e){function t(n,r,s,o){let i=n[o++];const u=Number.isFinite(+i),d=o>=n.length;return i=!i&&a.isArray(s)?s.length:i,d?(a.hasOwnProp(s,i)?s[i]=[s[i],r]:s[i]=r,!u):((!s[i]||!a.isObject(s[i]))&&(s[i]=[]),t(n,r,s[i],o)&&a.isArray(s[i])&&(s[i]=jt(s[i])),!u)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(It(r),s,n,0)}),n}return null}const kt={"Content-Type":void 0};function qt(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:Ue,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(Le(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 u;if(o){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Bt(t,this.formSerializer).toString();if((u=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const d=this.env&&this.env.FormData;return H(u?{"files[]":t}:t,d&&new d,this.formSerializer)}}return o||s?(n.setContentType("application/json",!1),qt(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(u){if(i)throw u.name==="SyntaxError"?m.from(u,m.ERR_BAD_RESPONSE,this,null,this.response):u}}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 ne=z,Ht=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"]),zt=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
2
|
`).forEach(function(i){s=i.indexOf(":"),n=i.substring(0,s).trim().toLowerCase(),r=i.substring(s+1).trim(),!(!n||t[n]&&Ht[n])&&(n==="set-cookie"?t[n]?t[n].push(r):t[n]=[r]:t[n]=t[n]?t[n]+", "+r:r)}),t},Be=Symbol("internals");function I(e){return e&&String(e).trim().toLowerCase()}function $(e){return e===!1||e==null?e:a.isArray(e)?e.map($):String(e)}function $t(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 Jt(e){return/^[-_a-zA-Z]+$/.test(e.trim())}function re(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 Kt(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function Vt(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})})}class J{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function o(u,d,c){const l=I(d);if(!l)throw new Error("header name must be a non-empty string");const p=a.findKey(s,l);(!p||s[p]===void 0||c===!0||c===void 0&&s[p]!==!1)&&(s[p||d]=$(u))}const i=(u,d)=>a.forEach(u,(c,l)=>o(c,l,d));return a.isPlainObject(t)||t instanceof this.constructor?i(t,n):a.isString(t)&&(t=t.trim())&&!Jt(t)?i(zt(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 $t(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||re(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 u=a.findKey(r,i);u&&(!n||re(r,r[u],u,n))&&(delete r[u],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||re(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]=$(s),delete n[o];return}const u=t?Kt(o):String(o).trim();u!==o&&delete n[o],n[u]=$(s),r[u]=!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[Be]=this[Be]={accessors:{}}).accessors,s=this.prototype;function o(i){const u=I(i);r[u]||(Vt(s,i),r[u]=!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 A=J;function se(e,t){const n=this||ne,r=t||n,s=A.from(r.headers);let o=r.data;return a.forEach(e,function(u){o=u.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function Ie(e){return!!(e&&e.__CANCEL__)}function j(e,t,n){m.call(this,e??"canceled",m.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(j,m,{__CANCEL__:!0});function Mt(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,u){const d=[];d.push(n+"="+encodeURIComponent(r)),a.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),a.isString(o)&&d.push("path="+o),a.isString(i)&&d.push("domain="+i),u===!0&&d.push("secure"),document.cookie=d.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 Wt(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Gt(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function je(e,t){return e&&!Wt(t)?Gt(e,t):t}const Xt=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 u=a.isString(i)?s(i):i;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function Yt(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Qt(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(d){const c=Date.now(),l=r[o];i||(i=c),n[s]=d,r[s]=c;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),c-i<t)return;const y=l&&c-l;return y?Math.round(w*1e3/y):void 0}}function ke(e,t){let n=0;const r=Qt(50,250);return s=>{const o=s.loaded,i=s.lengthComputable?s.total:void 0,u=o-n,d=r(u),c=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:u,rate:d||void 0,estimated:d&&i&&c?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const K={http:Tt,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=A.from(e.headers).normalize(),i=e.responseType;let u;function d(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}a.isFormData(s)&&(R.isStandardBrowserEnv||R.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let c=new XMLHttpRequest;if(e.auth){const y=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(y+":"+f))}const l=je(e.baseURL,e.url);c.open(e.method.toUpperCase(),De(l,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function p(){if(!c)return;const y=A.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),h={data:!i||i==="text"||i==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:y,config:e,request:c};Mt(function(b){n(b),d()},function(b){r(b),d()},h),c=null}if("onloadend"in c?c.onloadend=p:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(p)},c.onabort=function(){c&&(r(new m("Request aborted",m.ECONNABORTED,e,c)),c=null)},c.onerror=function(){r(new m("Network Error",m.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let f=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const h=e.transitional||Ue;e.timeoutErrorMessage&&(f=e.timeoutErrorMessage),r(new m(f,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,c)),c=null},R.isStandardBrowserEnv){const y=(e.withCredentials||Xt(l))&&e.xsrfCookieName&&vt.read(e.xsrfCookieName);y&&o.set(e.xsrfHeaderName,y)}s===void 0&&o.setContentType(null),"setRequestHeader"in c&&a.forEach(o.toJSON(),function(f,h){c.setRequestHeader(h,f)}),a.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),i&&i!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",ke(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",ke(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=y=>{c&&(r(!y||y.type?new j(null,e,c):y),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const w=Yt(l);if(w&&R.protocols.indexOf(w)===-1){r(new m("Unsupported protocol "+w+":",m.ERR_BAD_REQUEST,e));return}c.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 Zt={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 oe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new j(null,e)}function qe(e){return oe(e),e.headers=A.from(e.headers),e.data=se.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Zt.getAdapter(e.adapter||ne.adapter)(e).then(function(r){return oe(e),r.data=se.call(e,e.transformResponse,r),r.headers=A.from(r.headers),r},function(r){return Ie(r)||(oe(e),r&&r.response&&(r.response.data=se.call(e,e.transformResponse,r.response),r.response.headers=A.from(r.response.headers))),Promise.reject(r)})}const He=e=>e instanceof A?e.toJSON():e;function D(e,t){t=t||{};const n={};function r(c,l,p){return a.isPlainObject(c)&&a.isPlainObject(l)?a.merge.call({caseless:p},c,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(c,l,p){if(a.isUndefined(l)){if(!a.isUndefined(c))return r(void 0,c,p)}else return r(c,l,p)}function o(c,l){if(!a.isUndefined(l))return r(void 0,l)}function i(c,l){if(a.isUndefined(l)){if(!a.isUndefined(c))return r(void 0,c)}else return r(void 0,l)}function u(c,l,p){if(p in t)return r(c,l);if(p in e)return r(void 0,c)}const d={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:u,headers:(c,l)=>s(He(c),He(l),!0)};return a.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const p=d[l]||s,w=p(e[l],t[l],l);a.isUndefined(w)&&p!==u||(n[l]=w)}),n}const ze="1.3.4",ie={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ie[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const $e={};ie.transitional=function(t,n,r){function s(o,i){return"[Axios v"+ze+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,u)=>{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,u):!0}};function en(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 u=e[o],d=u===void 0||i(u,o,e);if(d!==!0)throw new m("option "+o+" must be "+d,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+o,m.ERR_BAD_OPTION)}}const ae={assertOptions:en,validators:ie},C=ae.validators;class V{constructor(t){this.defaults=t,this.interceptors={request:new Fe,response:new Fe}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=D(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ae.assertOptions(r,{silentJSONParsing:C.transitional(C.boolean),forcedJSONParsing:C.transitional(C.boolean),clarifyTimeoutError:C.transitional(C.boolean)},!1),s!==void 0&&ae.assertOptions(s,{encode:C.function,serialize:C.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"],f=>{delete o[f]}),n.headers=A.concat(i,o);const u=[];let d=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(d=d&&h.synchronous,u.unshift(h.fulfilled,h.rejected))});const c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let l,p=0,w;if(!d){const f=[qe.bind(this),void 0];for(f.unshift.apply(f,u),f.push.apply(f,c),w=f.length,l=Promise.resolve(n);p<w;)l=l.then(f[p++],f[p++]);return l}w=u.length;let y=n;for(p=0;p<w;){const f=u[p++],h=u[p++];try{y=f(y)}catch(T){h.call(this,T);break}}try{l=qe.call(this,y)}catch(f){return Promise.reject(f)}for(p=0,w=c.length;p<w;)l=l.then(c[p++],c[p++]);return l}getUri(t){t=D(this.defaults,t);const n=je(t.baseURL,t.url);return De(n,t.params,t.paramsSerializer)}}a.forEach(["delete","get","head","options"],function(t){V.prototype[t]=function(n,r){return this.request(D(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,u){return this.request(D(u||{},{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;class ce{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(u=>{r.subscribe(u),o=u}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,u){r.reason||(r.reason=new j(o,i,u),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 ce(function(s){t=s}),cancel:t}}}const tn=ce;function nn(e){return function(n){return e.apply(null,n)}}function rn(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 sn=ue;function Je(e){const t=new M(e),n=he(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 Je(D(e,s))},n}const E=Je(ne);E.Axios=M,E.CanceledError=j,E.CancelToken=tn,E.isCancel=Ie,E.VERSION=ze,E.toFormData=H,E.AxiosError=m,E.Cancel=E.CanceledError,E.all=function(t){return Promise.all(t)},E.spread=nn,E.isAxiosError=rn,E.mergeConfig=D,E.AxiosHeaders=A,E.formToJSON=e=>Le(a.isHTMLForm(e)?new FormData(e):e),E.HttpStatusCode=sn,E.default=E;const on=E;class an{constructor(t){U(this,"client");U(this,"queryParams");this.client=on.create({...t,headers:{Authorization:`Bearer ${t.apiKey}`}}),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 cn=(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 un="fuul.tracking_id",ln=["google.com","bing.com","yahoo.com"],fn=()=>wn(un,()=>cn()),dn=()=>_("af")||_("referrer"),pn=()=>document.referrer,hn=()=>gn(),mn=()=>_("category"),yn=()=>_("title"),En=()=>_("tag"),wn=(e,t)=>{const n=localStorage.getItem(e);if(n)return n;{const r=t();return r?localStorage.setItem(e,r):localStorage.removeItem(e),r}},_=e=>new URLSearchParams(window.location.search).get(e),gn=()=>{const e=_("source"),t=_("af")||_("referrer");if(e)return e;if(t)return"affiliate";const n=Sn(document.referrer);return ln.includes(n)?"organic":"direct"},Sn=e=>{var r;return(r=new URL(e).hostname)==null?void 0:r.split(".").slice(-2).join(".")},bn="https://api.fuul.xyz/api/v1/";let v=!1,le=!1,fe,de,Ke,Ve;function Rn(e){v=!!e.debug,!le&&(fe=e.apiKey,Cn(),de=_n(e.baseApiUrl??bn,e.defaultQueryParams??{}),Ke=new g({httpClient:de,debug:v}),Ve=new We({httpClient:de,debug:v}),le=!0,v&&console.debug("Fuul SDK: init() complete"))}function Me(){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){Me(),Nn();const r=fn(),s=dn(),o=hn(),i=mn(),u=yn(),d=En(),c=pn(),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),c&&(l.metadata.referrer_url=c),o&&(l.metadata.source=o),i&&(l.metadata.category=i),u&&(l.metadata.title=u),d&&(l.metadata.tag=d),Ve.sendEvent(l)}async function On(e){await pe("pageview",{page:e??document.location.pathname,locationOrigin:document.location.origin})}async function An(e){await pe("connect_wallet",{},e)}function Tn(e,t){return`${e}?af=${t}`}async function Pn(){return Me(),Ke.getAll()}function Nn(){if(typeof window>"u"||typeof document>"u")throw new Error("Fuul SDK: Browser context required")}function Cn(){if(!fe)throw new Error("Fuul SDK: Invalid API key")}function _n(e,t){return new an({baseURL:e,timeout:1e4,apiKey:fe,queryParams:t})}const xn={init:Rn,sendEvent:pe,sendPageview:On,sendConnectWallet:An,generateTrackingLink:Tn,getConversions:Pn};S.Fuul=xn,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
|
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[Be]=this[Be]={accessors:{}}).accessors,s=this.prototype;function o(i){const u=I(i);r[u]||(Vt(s,i),r[u]=!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 A=J;function se(e,t){const n=this||ne,r=t||n,s=A.from(r.headers);let o=r.data;return a.forEach(e,function(u){o=u.call(n,o,s.normalize(),t?t.status:void 0)}),s.normalize(),o}function Ie(e){return!!(e&&e.__CANCEL__)}function j(e,t,n){m.call(this,e??"canceled",m.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(j,m,{__CANCEL__:!0});function Mt(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,u){const d=[];d.push(n+"="+encodeURIComponent(r)),a.isNumber(s)&&d.push("expires="+new Date(s).toGMTString()),a.isString(o)&&d.push("path="+o),a.isString(i)&&d.push("domain="+i),u===!0&&d.push("secure"),document.cookie=d.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 Wt(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function Gt(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}function je(e,t){return e&&!Wt(t)?Gt(e,t):t}const Xt=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 u=a.isString(i)?s(i):i;return u.protocol===r.protocol&&u.host===r.host}}():function(){return function(){return!0}}();function Yt(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function Qt(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(d){const c=Date.now(),l=r[o];i||(i=c),n[s]=d,r[s]=c;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),c-i<t)return;const y=l&&c-l;return y?Math.round(w*1e3/y):void 0}}function ke(e,t){let n=0;const r=Qt(50,250);return s=>{const o=s.loaded,i=s.lengthComputable?s.total:void 0,u=o-n,d=r(u),c=o<=i;n=o;const l={loaded:o,total:i,progress:i?o/i:void 0,bytes:u,rate:d||void 0,estimated:d&&i&&c?(i-o)/d:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const K={http:Tt,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const o=A.from(e.headers).normalize(),i=e.responseType;let u;function d(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}a.isFormData(s)&&(R.isStandardBrowserEnv||R.isStandardBrowserWebWorkerEnv)&&o.setContentType(!1);let c=new XMLHttpRequest;if(e.auth){const y=e.auth.username||"",f=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.set("Authorization","Basic "+btoa(y+":"+f))}const l=je(e.baseURL,e.url);c.open(e.method.toUpperCase(),De(l,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function p(){if(!c)return;const y=A.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),h={data:!i||i==="text"||i==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:y,config:e,request:c};Mt(function(b){n(b),d()},function(b){r(b),d()},h),c=null}if("onloadend"in c?c.onloadend=p:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(p)},c.onabort=function(){c&&(r(new m("Request aborted",m.ECONNABORTED,e,c)),c=null)},c.onerror=function(){r(new m("Network Error",m.ERR_NETWORK,e,c)),c=null},c.ontimeout=function(){let f=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const h=e.transitional||Ue;e.timeoutErrorMessage&&(f=e.timeoutErrorMessage),r(new m(f,h.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,c)),c=null},R.isStandardBrowserEnv){const y=(e.withCredentials||Xt(l))&&e.xsrfCookieName&&vt.read(e.xsrfCookieName);y&&o.set(e.xsrfHeaderName,y)}s===void 0&&o.setContentType(null),"setRequestHeader"in c&&a.forEach(o.toJSON(),function(f,h){c.setRequestHeader(h,f)}),a.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),i&&i!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",ke(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",ke(e.onUploadProgress)),(e.cancelToken||e.signal)&&(u=y=>{c&&(r(!y||y.type?new j(null,e,c):y),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u)));const w=Yt(l);if(w&&R.protocols.indexOf(w)===-1){r(new m("Unsupported protocol "+w+":",m.ERR_BAD_REQUEST,e));return}c.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 Zt={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 oe(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new j(null,e)}function qe(e){return oe(e),e.headers=A.from(e.headers),e.data=se.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Zt.getAdapter(e.adapter||ne.adapter)(e).then(function(r){return oe(e),r.data=se.call(e,e.transformResponse,r),r.headers=A.from(r.headers),r},function(r){return Ie(r)||(oe(e),r&&r.response&&(r.response.data=se.call(e,e.transformResponse,r.response),r.response.headers=A.from(r.response.headers))),Promise.reject(r)})}const He=e=>e instanceof A?e.toJSON():e;function D(e,t){t=t||{};const n={};function r(c,l,p){return a.isPlainObject(c)&&a.isPlainObject(l)?a.merge.call({caseless:p},c,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(c,l,p){if(a.isUndefined(l)){if(!a.isUndefined(c))return r(void 0,c,p)}else return r(c,l,p)}function o(c,l){if(!a.isUndefined(l))return r(void 0,l)}function i(c,l){if(a.isUndefined(l)){if(!a.isUndefined(c))return r(void 0,c)}else return r(void 0,l)}function u(c,l,p){if(p in t)return r(c,l);if(p in e)return r(void 0,c)}const d={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:u,headers:(c,l)=>s(He(c),He(l),!0)};return a.forEach(Object.keys(e).concat(Object.keys(t)),function(l){const p=d[l]||s,w=p(e[l],t[l],l);a.isUndefined(w)&&p!==u||(n[l]=w)}),n}const ze="1.3.4",ie={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{ie[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const $e={};ie.transitional=function(t,n,r){function s(o,i){return"[Axios v"+ze+"] Transitional option '"+o+"'"+i+(r?". "+r:"")}return(o,i,u)=>{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,u):!0}};function en(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 u=e[o],d=u===void 0||i(u,o,e);if(d!==!0)throw new m("option "+o+" must be "+d,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+o,m.ERR_BAD_OPTION)}}const ae={assertOptions:en,validators:ie},_=ae.validators;class V{constructor(t){this.defaults=t,this.interceptors={request:new Fe,response:new Fe}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=D(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:o}=n;r!==void 0&&ae.assertOptions(r,{silentJSONParsing:_.transitional(_.boolean),forcedJSONParsing:_.transitional(_.boolean),clarifyTimeoutError:_.transitional(_.boolean)},!1),s!==void 0&&ae.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"],f=>{delete o[f]}),n.headers=A.concat(i,o);const u=[];let d=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(n)===!1||(d=d&&h.synchronous,u.unshift(h.fulfilled,h.rejected))});const c=[];this.interceptors.response.forEach(function(h){c.push(h.fulfilled,h.rejected)});let l,p=0,w;if(!d){const f=[qe.bind(this),void 0];for(f.unshift.apply(f,u),f.push.apply(f,c),w=f.length,l=Promise.resolve(n);p<w;)l=l.then(f[p++],f[p++]);return l}w=u.length;let y=n;for(p=0;p<w;){const f=u[p++],h=u[p++];try{y=f(y)}catch(T){h.call(this,T);break}}try{l=qe.call(this,y)}catch(f){return Promise.reject(f)}for(p=0,w=c.length;p<w;)l=l.then(c[p++],c[p++]);return l}getUri(t){t=D(this.defaults,t);const n=je(t.baseURL,t.url);return De(n,t.params,t.paramsSerializer)}}a.forEach(["delete","get","head","options"],function(t){V.prototype[t]=function(n,r){return this.request(D(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(o,i,u){return this.request(D(u||{},{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;class ce{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(u=>{r.subscribe(u),o=u}).then(s);return i.cancel=function(){r.unsubscribe(o)},i},t(function(o,i,u){r.reason||(r.reason=new j(o,i,u),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 ce(function(s){t=s}),cancel:t}}}const tn=ce;function nn(e){return function(n){return e.apply(null,n)}}function rn(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 sn=ue;function Je(e){const t=new M(e),n=he(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 Je(D(e,s))},n}const E=Je(ne);E.Axios=M,E.CanceledError=j,E.CancelToken=tn,E.isCancel=Ie,E.VERSION=ze,E.toFormData=H,E.AxiosError=m,E.Cancel=E.CanceledError,E.all=function(t){return Promise.all(t)},E.spread=nn,E.isAxiosError=rn,E.mergeConfig=D,E.AxiosHeaders=A,E.formToJSON=e=>Le(a.isHTMLForm(e)?new FormData(e):e),E.HttpStatusCode=sn,E.default=E;const on=E;class an{constructor(t){U(this,"client");U(this,"queryParams");this.client=on.create({...t,headers:{Authorization:`Bearer ${t.apiKey}`}}),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 cn=(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 un="fuul.tracking_id",ln=["google.com","bing.com","yahoo.com"],fn=()=>wn(un,()=>cn()),dn=()=>C("af")||C("referrer"),pn=()=>document.referrer,hn=()=>gn(),mn=()=>C("category"),yn=()=>C("title"),En=()=>C("tag"),wn=(e,t)=>{const n=localStorage.getItem(e);if(n)return n;{const r=t();return r?localStorage.setItem(e,r):localStorage.removeItem(e),r}},C=e=>new URLSearchParams(window.location.search).get(e),gn=()=>{const e=C("source"),t=C("af")||C("referrer");if(e)return e;if(t)return"affiliate";const n=Sn(document.referrer);return ln.includes(n)?"organic":"direct"},Sn=e=>{var r;return(r=new URL(e).hostname)==null?void 0:r.split(".").slice(-2).join(".")},bn="https://api.fuul.xyz/api/v1/";let v=!1,le=!1,fe,de,Ke,Ve;function Rn(e){v=!!e.debug,!le&&(fe=e.apiKey,_n(),de=Cn(e.baseApiUrl??bn,e.defaultQueryParams??{}),Ke=new g({httpClient:de,debug:v}),Ve=new We({httpClient:de,debug:v}),le=!0,v&&console.debug("Fuul SDK: init() complete"))}function Me(){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){Me(),Nn();const r=fn(),s=dn(),o=hn(),i=mn(),u=yn(),d=En(),c=pn(),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),c&&(l.metadata.referrer_url=c),o&&(l.metadata.source=o),i&&(l.metadata.category=i),u&&(l.metadata.title=u),d&&(l.metadata.tag=d),Ve.sendEvent(l)}async function On(e){await pe("pageview",{page:e??document.location.pathname,locationOrigin:document.location.origin})}async function An(e){await pe("connect_wallet",{},e)}function Tn(e,t,n){const r=new URLSearchParams({af:t});return n!=null&&n.title&&r.append("af_title",n.title),n!=null&&n.format&&r.append("af_format",n.format),n!=null&&n.place&&r.append("af_place",n.place),`${e}?${r.toString()}`}async function Pn(){return Me(),Ke.getAll()}function Nn(){if(typeof window>"u"||typeof document>"u")throw new Error("Fuul SDK: Browser context required")}function _n(){if(!fe)throw new Error("Fuul SDK: Invalid API key")}function Cn(e,t){return new an({baseURL:e,timeout:1e4,apiKey:fe,queryParams:t})}const xn={init:Rn,sendEvent:pe,sendPageview:On,sendConnectWallet:An,generateTrackingLink:Tn,getConversions:Pn};S.Fuul=xn,Object.defineProperty(S,Symbol.toStringTag,{value:"Module"})});
|
package/dist/types/sdk.d.ts
CHANGED
package/dist/types/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/types/sdk.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC"}
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../../src/types/sdk.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC"}
|