@fuul/sdk 4.8.0 → 4.9.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.map +1 -1
- package/dist/index.mjs +315 -311
- package/dist/index.umd.js +5 -5
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
(function(E,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(E=typeof globalThis<"u"?globalThis:E||self,S(E.Fuul={}))})(this,function(E){"use strict";var sr=Object.defineProperty;var or=(E,S,D)=>S in E?sr(E,S,{enumerable:!0,configurable:!0,writable:!0,value:D}):E[S]=D;var C=(E,S,D)=>(or(E,typeof S!="symbol"?S+"":S,D),D);function S(e,t){return function(){return e.apply(t,arguments)}}const{toString:D}=Object.prototype,{getPrototypeOf:ne}=Object,K=(e=>t=>{const n=D.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),O=e=>(e=e.toLowerCase(),t=>K(t)===e),J=e=>t=>typeof t===e,{isArray:B}=Array,q=J("undefined");function at(e){return e!==null&&!q(e)&&e.constructor!==null&&!q(e.constructor)&&A(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Re=O("ArrayBuffer");function ct(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Re(e.buffer),t}const ut=J("string"),A=J("function"),Oe=J("number"),M=e=>e!==null&&typeof e=="object",lt=e=>e===!0||e===!1,W=e=>{if(K(e)!=="object")return!1;const t=ne(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},ft=O("Date"),dt=O("File"),pt=O("Blob"),ht=O("FileList"),mt=e=>M(e)&&A(e.pipe),yt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||A(e.append)&&((t=K(e))==="formdata"||t==="object"&&A(e.toString)&&e.toString()==="[object FormData]"))},gt=O("URLSearchParams"),wt=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function H(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),B(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let c;for(r=0;r<o;r++)c=i[r],t.call(null,e[c],c,e)}}function Te(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 Pe=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),_e=e=>!q(e)&&e!==Pe;function re(){const{caseless:e}=_e(this)&&this||{},t={},n=(r,s)=>{const i=e&&Te(t,s)||s;W(t[i])&&W(r)?t[i]=re(t[i],r):W(r)?t[i]=re({},r):B(r)?t[i]=r.slice():t[i]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&H(arguments[r],n);return t}const Et=(e,t,n,{allOwnKeys:r}={})=>(H(t,(s,i)=>{n&&A(s)?e[i]=S(s,n):e[i]=s},{allOwnKeys:r}),e),bt=e=>(e.charCodeAt(0)===65279&&(e=e.slice(1)),e),St=(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)},Ct=(e,t,n,r)=>{let s,i,o;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)o=s[i],(!r||r(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=n!==!1&&ne(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},At=(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},Rt=e=>{if(!e)return null;if(B(e))return e;let t=e.length;if(!Oe(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Ot=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ne(Uint8Array)),Tt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},Pt=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},_t=O("HTMLFormElement"),Nt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),Ne=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),xt=O("RegExp"),xe=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};H(n,(s,i)=>{let o;(o=t(s,i,e))!==!1&&(r[i]=o||s)}),Object.defineProperties(e,r)},Ut=e=>{xe(e,(t,n)=>{if(A(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(A(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+"'")})}})},Ft=(e,t)=>{const n={},r=s=>{s.forEach(i=>{n[i]=!0})};return B(e)?r(e):r(String(e).split(t)),n},Dt=()=>{},Lt=(e,t)=>(e=+e,Number.isFinite(e)?e:t),se="abcdefghijklmnopqrstuvwxyz",Ue="0123456789",Fe={DIGIT:Ue,ALPHA:se,ALPHA_DIGIT:se+se.toUpperCase()+Ue},Bt=(e=16,t=Fe.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n};function It(e){return!!(e&&A(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const jt=e=>{const t=new Array(10),n=(r,s)=>{if(M(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const i=B(r)?[]:{};return H(r,(o,c)=>{const p=n(o,s+1);!q(p)&&(i[c]=p)}),t[s]=void 0,i}}return r};return n(e,0)},kt=O("AsyncFunction"),a={isArray:B,isArrayBuffer:Re,isBuffer:at,isFormData:yt,isArrayBufferView:ct,isString:ut,isNumber:Oe,isBoolean:lt,isObject:M,isPlainObject:W,isUndefined:q,isDate:ft,isFile:dt,isBlob:pt,isRegExp:xt,isFunction:A,isStream:mt,isURLSearchParams:gt,isTypedArray:Ot,isFileList:ht,forEach:H,merge:re,extend:Et,trim:wt,stripBOM:bt,inherits:St,toFlatObject:Ct,kindOf:K,kindOfTest:O,endsWith:At,toArray:Rt,forEachEntry:Tt,matchAll:Pt,isHTMLForm:_t,hasOwnProperty:Ne,hasOwnProp:Ne,reduceDescriptors:xe,freezeMethods:Ut,toObjectSet:Ft,toCamelCase:Nt,noop:Dt,toFiniteNumber:Lt,findKey:Te,global:Pe,isContextDefined:_e,ALPHABET:Fe,generateString:Bt,isSpecCompliantForm:It,toJSONObject:jt,isAsyncFn:kt,isThenable:e=>e&&(M(e)||A(e))&&A(e.then)&&A(e.catch)};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 De=m.prototype,Le={};["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=>{Le[e]={value:e}}),Object.defineProperties(m,Le),Object.defineProperty(De,"isAxiosError",{value:!0}),m.from=(e,t,n,r,s,i)=>{const o=Object.create(De);return a.toFlatObject(e,o,function(p){return p!==Error.prototype},c=>c!=="isAxiosError"),m.call(o,e.message,t,n,r,s),o.cause=e,o.name=e.name,i&&Object.assign(o,i),o};const vt=null;function oe(e){return a.isPlainObject(e)||a.isArray(e)}function Be(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function Ie(e,t,n){return e?e.concat(t).map(function(s,i){return s=Be(s),!n&&i?"["+s+"]":s}).join(n?".":""):t}function $t(e){return a.isArray(e)&&!e.some(oe)}const qt=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function X(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(d,w){return!a.isUndefined(w[d])});const r=n.metaTokens,s=n.visitor||l,i=n.dots,o=n.indexes,p=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function h(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(!p&&a.isBlob(f))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?p&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,d,w){let b=f;if(f&&!w&&typeof f=="object"){if(a.endsWith(d,"{}"))d=r?d:d.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&$t(f)||(a.isFileList(f)||a.endsWith(d,"[]"))&&(b=a.toArray(f)))return d=Be(d),b.forEach(function(F,rr){!(a.isUndefined(F)||F===null)&&t.append(o===!0?Ie([d],rr,i):o===null?d:d+"[]",h(F))}),!1}return oe(f)?!0:(t.append(Ie(w,d,i),h(f)),!1)}const u=[],g=Object.assign(qt,{defaultVisitor:l,convertValue:h,isVisitable:oe});function R(f,d){if(!a.isUndefined(f)){if(u.indexOf(f)!==-1)throw Error("Circular reference detected in "+d.join("."));u.push(f),a.forEach(f,function(b,U){(!(a.isUndefined(b)||b===null)&&s.call(t,b,a.isString(U)?U.trim():U,d,g))===!0&&R(b,d?d.concat(U):[U])}),u.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return R(e),t}function je(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ie(e,t){this._pairs=[],e&&X(e,this,t)}const ke=ie.prototype;ke.append=function(t,n){this._pairs.push([t,n])},ke.toString=function(t){const n=t?function(r){return t.call(this,r,je)}:je;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Ht(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function ve(e,t,n){if(!t)return e;const r=n&&n.encode||Ht,s=n&&n.serialize;let i;if(s?i=s(t,n):i=a.isURLSearchParams(t)?t.toString():new ie(t,n).toString(r),i){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class Vt{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 $e=Vt,qe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},zt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ie,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},He=typeof window<"u"&&typeof document<"u",Kt=(e=>He&&["ReactNative","NativeScript","NS"].indexOf(e)<0)(typeof navigator<"u"&&navigator.product),Jt=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),T={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:He,hasStandardBrowserEnv:Kt,hasStandardBrowserWebWorkerEnv:Jt},Symbol.toStringTag,{value:"Module"})),...zt};function Mt(e,t){return X(e,new T.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,i){return T.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function Wt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Xt(e){const t={},n=Object.keys(e);let r;const s=n.length;let i;for(r=0;r<s;r++)i=n[r],t[i]=e[i];return t}function Ve(e){function t(n,r,s,i){let o=n[i++];const c=Number.isFinite(+o),p=i>=n.length;return o=!o&&a.isArray(s)?s.length:o,p?(a.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!c):((!s[o]||!a.isObject(s[o]))&&(s[o]=[]),t(n,r,s[o],i)&&a.isArray(s[o])&&(s[o]=Xt(s[o])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(Wt(r),s,n,0)}),n}return null}function Gt(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 ae={transitional:qe,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,i=a.isObject(t);if(i&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s&&s?JSON.stringify(Ve(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(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Mt(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const p=this.env&&this.env.FormData;return X(c?{"files[]":t}:t,p&&new p,this.formSerializer)}}return i||s?(n.setContentType("application/json",!1),Gt(t)):t}],transformResponse:[function(t){const n=this.transitional||ae.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&a.isString(t)&&(r&&!this.responseType||s)){const o=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(o)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:T.classes.FormData,Blob:T.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{ae.headers[e]={}});const ce=ae,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"]),Yt=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
|
-
`).forEach(function(o){s=o.indexOf(":"),n=o.substring(0,s).trim().toLowerCase(),r=o.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},
|
|
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[
|
|
4
|
-
`+i.map(
|
|
5
|
-
`):" "+We(i[0]):"as no adapter specified";throw new m("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r},adapters:fe};function de(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new z(null,e)}function Ge(e){return de(e),e.headers=_.from(e.headers),e.data=le.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Xe.getAdapter(e.adapter||ce.adapter)(e).then(function(r){return de(e),r.data=le.call(e,e.transformResponse,r),r.headers=_.from(r.headers),r},function(r){return Ke(r)||(de(e),r&&r.response&&(r.response.data=le.call(e,e.transformResponse,r.response),r.response.headers=_.from(r.response.headers))),Promise.reject(r)})}const Qe=e=>e instanceof _?e.toJSON():e;function I(e,t){t=t||{};const n={};function r(h,l,u){return a.isPlainObject(h)&&a.isPlainObject(l)?a.merge.call({caseless:u},h,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(h,l,u){if(a.isUndefined(l)){if(!a.isUndefined(h))return r(void 0,h,u)}else return r(h,l,u)}function i(h,l){if(!a.isUndefined(l))return r(void 0,l)}function o(h,l){if(a.isUndefined(l)){if(!a.isUndefined(h))return r(void 0,h)}else return r(void 0,l)}function c(h,l,u){if(u in t)return r(h,l);if(u in e)return r(void 0,h)}const p={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(h,l)=>s(Qe(h),Qe(l),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(l){const u=p[l]||s,g=u(e[l],t[l],l);a.isUndefined(g)&&u!==c||(n[l]=g)}),n}const Ye="1.6.3",pe={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{pe[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const Ze={};pe.transitional=function(t,n,r){function s(i,o){return"[Axios v"+Ye+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,c)=>{if(t===!1)throw new m(s(o," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!Ze[o]&&(Ze[o]=!0,console.warn(s(o," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,o,c):!0}};function dn(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 i=r[s],o=t[i];if(o){const c=e[i],p=c===void 0||o(c,i,e);if(p!==!0)throw new m("option "+i+" must be "+p,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}const he={assertOptions:dn,validators:pe},N=he.validators;let Y=class{constructor(t){this.defaults=t,this.interceptors={request:new $e,response:new $e}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=I(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&he.assertOptions(r,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:he.assertOptions(s,{encode:N.function,serialize:N.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&a.merge(i.common,i[n.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),n.headers=_.concat(o,i);const c=[];let p=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(n)===!1||(p=p&&d.synchronous,c.unshift(d.fulfilled,d.rejected))});const h=[];this.interceptors.response.forEach(function(d){h.push(d.fulfilled,d.rejected)});let l,u=0,g;if(!p){const f=[Ge.bind(this),void 0];for(f.unshift.apply(f,c),f.push.apply(f,h),g=f.length,l=Promise.resolve(n);u<g;)l=l.then(f[u++],f[u++]);return l}g=c.length;let R=n;for(u=0;u<g;){const f=c[u++],d=c[u++];try{R=f(R)}catch(w){d.call(this,w);break}}try{l=Ge.call(this,R)}catch(f){return Promise.reject(f)}for(u=0,g=h.length;u<g;)l=l.then(h[u++],h[u++]);return l}getUri(t){t=I(this.defaults,t);const n=Je(t.baseURL,t.url);return ve(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){Y.prototype[t]=function(n,r){return this.request(I(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(i,o,c){return this.request(I(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Y.prototype[t]=n(),Y.prototype[t+"Form"]=n(!0)});const Z=Y,pn=class it{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(c=>{r.subscribe(c),i=c}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},t(function(i,o,c){r.reason||(r.reason=new z(i,o,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 it(function(s){t=s}),cancel:t}}};function hn(e){return function(n){return e.apply(null,n)}}function mn(e){return a.isObject(e)&&e.isAxiosError===!0}const me={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(me).forEach(([e,t])=>{me[t]=e});const yn=me;function et(e){const t=new Z(e),n=S(Z.prototype.request,t);return a.extend(n,Z.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return et(I(e,s))},n}const y=et(ce);y.Axios=Z,y.CanceledError=z,y.CancelToken=pn,y.isCancel=Ke,y.VERSION=Ye,y.toFormData=X,y.AxiosError=m,y.Cancel=y.CanceledError,y.all=function(t){return Promise.all(t)},y.spread=hn,y.isAxiosError=mn,y.mergeConfig=I,y.AxiosHeaders=_,y.formToJSON=e=>Ve(a.isHTMLForm(e)?new FormData(e):e),y.getAdapter=Xe.getAdapter,y.HttpStatusCode=yn,y.default=y;const tt=y,{Axios:hr,AxiosError:ee,CanceledError:mr,isCancel:yr,CancelToken:gr,VERSION:wr,all:Er,Cancel:br,isAxiosError:Sr,spread:Cr,toFormData:Ar,AxiosHeaders:Rr,HttpStatusCode:Or,formToJSON:Tr,getAdapter:Pr,mergeConfig:_r}=tt;class ye extends Error{constructor(n){super(n.join(", "));C(this,"errors");this.name="ValidationError",this.errors=n}}class ge extends Error{constructor(n){super("Address already registered.");C(this,"address");this.name="AddressInUseError",this.address=n}}class we extends Error{constructor(n){super("Code already registered.");C(this,"code");this.name="CodeInUseError",this.code=n}}class Ee extends Error{constructor(){super("Invalid signature provided"),this.name="InvalidSignatureError"}}class gn{constructor(t){C(this,"httpClient");C(this,"_debug");this.httpClient=t.httpClient,this._debug=t.debug}async create(t,n,r){var s;try{await this.httpClient.post("/affiliates",{address:t,name:n,code:n,signature:r})}catch(i){if(i instanceof ee){const o=(s=i.response)==null?void 0:s.data;if(typeof(o==null?void 0:o.message)=="string"){const c=o.message.toLowerCase();throw c=="invalid signature"?new Ee:c=="address in use"?new ge(t):c=="code in use"?new we(n):new Error(c)}else if((o==null?void 0:o.message)instanceof Array)throw new ye(o.message)}throw i}}async update(t,n,r){var s;try{await this.httpClient.post(`/affiliates/${t}`,{code:n,address:t,signature:r})}catch(i){if(i instanceof ee){const o=(s=i.response)==null?void 0:s.data;if(typeof(o==null?void 0:o.message)=="string"){const c=o.message.toLowerCase();throw c=="invalid signature"?new Ee:c=="address in use"?new ge(t):c=="code in use"?new we(n):new Error(c)}else if((o==null?void 0:o.message)instanceof Array)throw new ye(o.message)}throw i}}async isCodeFree(t){var n;try{return await this.httpClient.get(`/affiliates/codes/${t}`),!1}catch(r){if(r instanceof ee&&((n=r.response)==null?void 0:n.status)===404)return!0;throw console.error("Fuul SDK: Could not check affiliate code",r),r}}async getCode(t){var n;try{return(await this.httpClient.get(`/affiliates/${t}`)).data.code}catch(r){if(r instanceof ee&&((n=r.response)==null?void 0:n.status)===404)return null;throw console.error("Fuul SDK: Could not get affiliate code",r),r}}}class wn{constructor(t){C(this,"httpClient");this.httpClient=t.httpClient}async getAll(t){const{data:n}=await this.httpClient.get("conversions",t);return n}}const nt="fuul.sent",En=60;class bn{constructor(t){C(this,"debug");C(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=`${nt}_${t.name}`,r=localStorage.getItem(n);if(!r)return!1;const s=JSON.parse(r);if(this.getCurrentTimestamp()-s.timestamp>En)return!1;let p=!1;t.metadata&&(p=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 h=!1;return t.args&&s.args&&(h=s.args.page===t.args.page),h&&p}getCurrentTimestamp(){return Date.now()/1e3}saveSentEvent(t){const n=`${nt}_${t.name}`,r=this.getCurrentTimestamp(),s={...t,timestamp:r};localStorage.setItem(n,JSON.stringify(s))}}const Sn={version:"4.8.0"};class Cn{constructor(t){C(this,"client");C(this,"queryParams");this.client=tt.create({...t,headers:{Authorization:`Bearer ${t.apiKey}`,"X-Fuul-Sdk-Version":Sn.version}}),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)}}const L="/payouts";class An{constructor(t){C(this,"httpClient");C(this,"_debug");this.httpClient=t.httpClient,this._debug=t.debug}async getPayoutsLeaderboard(t){return(await this.httpClient.get(`${L}/leaderboard`,t)).data}async getPointsLeaderboard(t){return(await this.httpClient.get(`${L}/leaderboard`,t)).data}async getUserPayoutsByConversion(t){return(await this.httpClient.get(L,{...t,type:"onchain-currency"})).data}async getUserPointsByConversion(t){return(await this.httpClient.get(L,{...t,type:"point"})).data}async getUserPayoutMovements(t){return(await this.httpClient.get(`${L}/movements`,{...t,type:"onchain-currency"})).data}async getUserPointsMovements(t){return(await this.httpClient.get(`${L}/movements`,{...t,type:"point"})).data}async getVolumeLeaderboard(t){return(await this.httpClient.get(`${L}/leaderboard/volume`,t)).data}}let Rn=(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 On="fuul.tracking_id",be=()=>Un(On,()=>Rn()),rt=()=>j("af")||j("referrer"),Tn=()=>document.referrer,Pn=()=>Fn(),_n=()=>j("category"),Nn=()=>j("title"),xn=()=>j("tag"),Un=(e,t)=>{const n=localStorage.getItem(e);if(n)return n;{const r=t();return r?localStorage.setItem(e,r):localStorage.removeItem(e),r}},j=e=>new URLSearchParams(window.location.search).get(e),Fn=()=>{const e=j("source");if(e)return e},Dn="/user";class Ln{constructor(t){C(this,"httpClient");this.httpClient=t.httpClient}async getUserAffiliates(t){return(await this.httpClient.get(Dn,t)).data.affiliates}}const Bn="https://api.fuul.xyz/api/v1/";let k=!1,Se=!1,Ce,v,st,ot,$,te,x;function In(e){k=!!e.debug,!Se&&(Ce=e.apiKey,er(),v=tr(e.baseApiUrl??Bn,e.defaultQueryParams??{}),st=new wn({httpClient:v,debug:k}),te=new bn({httpClient:v,debug:k}),$=new gn({httpClient:v,debug:k}),x=new An({httpClient:v,debug:k}),ot=new Ln({httpClient:v}),Se=!0,k&&console.debug("Fuul SDK: init() complete"))}function P(){if(!Se)throw new Error("Fuul SDK: You need to call init() to initialize the library before using any methods")}async function jn(e,t){P(),Ae();const n={name:e,args:t??{},metadata:{tracking_id:be()}};await te.sendEvent(n)}async function kn(e){P(),Ae();const t={name:"pageview",args:{page:e??document.location.pathname,locationOrigin:document.location.origin},metadata:{tracking_id:be(),referrer_url:Tn(),source:Pn(),affiliate_id:rt()??void 0,referrer:rt()??void 0,category:_n()??void 0,title:Nn()??void 0,tag:xn()??void 0}};await te.sendEvent(t)}async function vn(e){P(),Ae();const t={name:"connect_wallet",args:{page:document.location.pathname,locationOrigin:document.location.origin},metadata:{tracking_id:be()}};e!=null&&e.address&&(t.user_address=e.address),e!=null&&e.signature&&(t.signature=e==null?void 0:e.signature,t.signature_message=e==null?void 0:e.message),e!=null&&e.accountChainId&&(t.account_chain_id=e.accountChainId),await te.sendEvent(t)}async function $n(e,t,n){P(),await $.create(e,t,n)}async function qn(e,t,n){P(),await $.update(e,t,n)}async function Hn(e){return P(),await $.getCode(e)}async function Vn(e){return P(),await $.isCodeFree(e)}async function zn(e,t,n){P();const r=await $.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()}`}function Kn(e){return x.getPayoutsLeaderboard(e)}function Jn(e){return x.getPointsLeaderboard(e)}function Mn(e){return x.getVolumeLeaderboard(e)}function Wn(e){return x.getUserPayoutsByConversion(e)}function Xn(e){return x.getUserPointsByConversion(e)}function Gn(e){return x.getUserPayoutMovements(e)}function Qn(e){return x.getUserPointsMovements(e)}async function Yn(e){return P(),st.getAll(e)}async function Zn(e){return P(),ot.getUserAffiliates(e)}function Ae(){if(typeof window>"u"||typeof document>"u")throw new Error("Fuul SDK: Browser context required")}function er(){if(!Ce)throw new Error("Fuul SDK: Invalid API key")}function tr(e,t){return new Cn({baseURL:e,timeout:1e4,apiKey:Ce,queryParams:t})}const nr={init:In,sendEvent:jn,sendPageview:kn,sendConnectWallet:vn,generateTrackingLink:zn,getConversions:Yn,createAffiliateCode:$n,updateAffiliateCode:qn,getAffiliateCode:Hn,isAffiliateCodeFree:Vn,getPayoutsLeaderboard:Kn,getPointsLeaderboard:Jn,getUserPayoutsByConversion:Wn,getUserPointsByConversion:Xn,getUserPointsMovements:Qn,getUserPayoutMovements:Gn,getUserAffiliates:Zn,getVolumeLeaderboard:Mn};E.AddressInUseError=ge,E.CodeInUseError=we,E.Fuul=nr,E.InvalidSignatureError=Ee,E.ValidationError=ye,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(E,S){typeof exports=="object"&&typeof module<"u"?S(exports):typeof define=="function"&&define.amd?define(["exports"],S):(E=typeof globalThis<"u"?globalThis:E||self,S(E.Fuul={}))})(this,function(E){"use strict";var or=Object.defineProperty;var ir=(E,S,D)=>S in E?or(E,S,{enumerable:!0,configurable:!0,writable:!0,value:D}):E[S]=D;var C=(E,S,D)=>(ir(E,typeof S!="symbol"?S+"":S,D),D);function S(e,t){return function(){return e.apply(t,arguments)}}const{toString:D}=Object.prototype,{getPrototypeOf:ne}=Object,K=(e=>t=>{const n=D.call(t);return e[n]||(e[n]=n.slice(8,-1).toLowerCase())})(Object.create(null)),O=e=>(e=e.toLowerCase(),t=>K(t)===e),J=e=>t=>typeof t===e,{isArray:B}=Array,q=J("undefined");function ct(e){return e!==null&&!q(e)&&e.constructor!==null&&!q(e.constructor)&&A(e.constructor.isBuffer)&&e.constructor.isBuffer(e)}const Oe=O("ArrayBuffer");function ut(e){let t;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?t=ArrayBuffer.isView(e):t=e&&e.buffer&&Oe(e.buffer),t}const lt=J("string"),A=J("function"),Te=J("number"),M=e=>e!==null&&typeof e=="object",ft=e=>e===!0||e===!1,W=e=>{if(K(e)!=="object")return!1;const t=ne(e);return(t===null||t===Object.prototype||Object.getPrototypeOf(t)===null)&&!(Symbol.toStringTag in e)&&!(Symbol.iterator in e)},dt=O("Date"),pt=O("File"),ht=O("Blob"),mt=O("FileList"),yt=e=>M(e)&&A(e.pipe),gt=e=>{let t;return e&&(typeof FormData=="function"&&e instanceof FormData||A(e.append)&&((t=K(e))==="formdata"||t==="object"&&A(e.toString)&&e.toString()==="[object FormData]"))},wt=O("URLSearchParams"),Et=e=>e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function H(e,t,{allOwnKeys:n=!1}={}){if(e===null||typeof e>"u")return;let r,s;if(typeof e!="object"&&(e=[e]),B(e))for(r=0,s=e.length;r<s;r++)t.call(null,e[r],r,e);else{const i=n?Object.getOwnPropertyNames(e):Object.keys(e),o=i.length;let c;for(r=0;r<o;r++)c=i[r],t.call(null,e[c],c,e)}}function Pe(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 _e=(()=>typeof globalThis<"u"?globalThis:typeof self<"u"?self:typeof window<"u"?window:global)(),Ne=e=>!q(e)&&e!==_e;function re(){const{caseless:e}=Ne(this)&&this||{},t={},n=(r,s)=>{const i=e&&Pe(t,s)||s;W(t[i])&&W(r)?t[i]=re(t[i],r):W(r)?t[i]=re({},r):B(r)?t[i]=r.slice():t[i]=r};for(let r=0,s=arguments.length;r<s;r++)arguments[r]&&H(arguments[r],n);return t}const bt=(e,t,n,{allOwnKeys:r}={})=>(H(t,(s,i)=>{n&&A(s)?e[i]=S(s,n):e[i]=s},{allOwnKeys:r}),e),St=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)},At=(e,t,n,r)=>{let s,i,o;const c={};if(t=t||{},e==null)return t;do{for(s=Object.getOwnPropertyNames(e),i=s.length;i-- >0;)o=s[i],(!r||r(o,e,t))&&!c[o]&&(t[o]=e[o],c[o]=!0);e=n!==!1&&ne(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},Rt=(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},Ot=e=>{if(!e)return null;if(B(e))return e;let t=e.length;if(!Te(t))return null;const n=new Array(t);for(;t-- >0;)n[t]=e[t];return n},Tt=(e=>t=>e&&t instanceof e)(typeof Uint8Array<"u"&&ne(Uint8Array)),Pt=(e,t)=>{const r=(e&&e[Symbol.iterator]).call(e);let s;for(;(s=r.next())&&!s.done;){const i=s.value;t.call(e,i[0],i[1])}},_t=(e,t)=>{let n;const r=[];for(;(n=e.exec(t))!==null;)r.push(n);return r},Nt=O("HTMLFormElement"),xt=e=>e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,function(n,r,s){return r.toUpperCase()+s}),xe=(({hasOwnProperty:e})=>(t,n)=>e.call(t,n))(Object.prototype),Ut=O("RegExp"),Ue=(e,t)=>{const n=Object.getOwnPropertyDescriptors(e),r={};H(n,(s,i)=>{let o;(o=t(s,i,e))!==!1&&(r[i]=o||s)}),Object.defineProperties(e,r)},Ft=e=>{Ue(e,(t,n)=>{if(A(e)&&["arguments","caller","callee"].indexOf(n)!==-1)return!1;const r=e[n];if(A(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+"'")})}})},Dt=(e,t)=>{const n={},r=s=>{s.forEach(i=>{n[i]=!0})};return B(e)?r(e):r(String(e).split(t)),n},Lt=()=>{},Bt=(e,t)=>(e=+e,Number.isFinite(e)?e:t),se="abcdefghijklmnopqrstuvwxyz",Fe="0123456789",De={DIGIT:Fe,ALPHA:se,ALPHA_DIGIT:se+se.toUpperCase()+Fe},It=(e=16,t=De.ALPHA_DIGIT)=>{let n="";const{length:r}=t;for(;e--;)n+=t[Math.random()*r|0];return n};function jt(e){return!!(e&&A(e.append)&&e[Symbol.toStringTag]==="FormData"&&e[Symbol.iterator])}const kt=e=>{const t=new Array(10),n=(r,s)=>{if(M(r)){if(t.indexOf(r)>=0)return;if(!("toJSON"in r)){t[s]=r;const i=B(r)?[]:{};return H(r,(o,c)=>{const p=n(o,s+1);!q(p)&&(i[c]=p)}),t[s]=void 0,i}}return r};return n(e,0)},vt=O("AsyncFunction"),a={isArray:B,isArrayBuffer:Oe,isBuffer:ct,isFormData:gt,isArrayBufferView:ut,isString:lt,isNumber:Te,isBoolean:ft,isObject:M,isPlainObject:W,isUndefined:q,isDate:dt,isFile:pt,isBlob:ht,isRegExp:Ut,isFunction:A,isStream:yt,isURLSearchParams:wt,isTypedArray:Tt,isFileList:mt,forEach:H,merge:re,extend:bt,trim:Et,stripBOM:St,inherits:Ct,toFlatObject:At,kindOf:K,kindOfTest:O,endsWith:Rt,toArray:Ot,forEachEntry:Pt,matchAll:_t,isHTMLForm:Nt,hasOwnProperty:xe,hasOwnProp:xe,reduceDescriptors:Ue,freezeMethods:Ft,toObjectSet:Dt,toCamelCase:xt,noop:Lt,toFiniteNumber:Bt,findKey:Pe,global:_e,isContextDefined:Ne,ALPHABET:De,generateString:It,isSpecCompliantForm:jt,toJSONObject:kt,isAsyncFn:vt,isThenable:e=>e&&(M(e)||A(e))&&A(e.then)&&A(e.catch)};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 Le=m.prototype,Be={};["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=>{Be[e]={value:e}}),Object.defineProperties(m,Be),Object.defineProperty(Le,"isAxiosError",{value:!0}),m.from=(e,t,n,r,s,i)=>{const o=Object.create(Le);return a.toFlatObject(e,o,function(p){return p!==Error.prototype},c=>c!=="isAxiosError"),m.call(o,e.message,t,n,r,s),o.cause=e,o.name=e.name,i&&Object.assign(o,i),o};const $t=null;function oe(e){return a.isPlainObject(e)||a.isArray(e)}function Ie(e){return a.endsWith(e,"[]")?e.slice(0,-2):e}function je(e,t,n){return e?e.concat(t).map(function(s,i){return s=Ie(s),!n&&i?"["+s+"]":s}).join(n?".":""):t}function qt(e){return a.isArray(e)&&!e.some(oe)}const Ht=a.toFlatObject(a,{},null,function(t){return/^is[A-Z]/.test(t)});function X(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(d,w){return!a.isUndefined(w[d])});const r=n.metaTokens,s=n.visitor||l,i=n.dots,o=n.indexes,p=(n.Blob||typeof Blob<"u"&&Blob)&&a.isSpecCompliantForm(t);if(!a.isFunction(s))throw new TypeError("visitor must be a function");function h(f){if(f===null)return"";if(a.isDate(f))return f.toISOString();if(!p&&a.isBlob(f))throw new m("Blob is not supported. Use a Buffer instead.");return a.isArrayBuffer(f)||a.isTypedArray(f)?p&&typeof Blob=="function"?new Blob([f]):Buffer.from(f):f}function l(f,d,w){let b=f;if(f&&!w&&typeof f=="object"){if(a.endsWith(d,"{}"))d=r?d:d.slice(0,-2),f=JSON.stringify(f);else if(a.isArray(f)&&qt(f)||(a.isFileList(f)||a.endsWith(d,"[]"))&&(b=a.toArray(f)))return d=Ie(d),b.forEach(function(F,sr){!(a.isUndefined(F)||F===null)&&t.append(o===!0?je([d],sr,i):o===null?d:d+"[]",h(F))}),!1}return oe(f)?!0:(t.append(je(w,d,i),h(f)),!1)}const u=[],g=Object.assign(Ht,{defaultVisitor:l,convertValue:h,isVisitable:oe});function R(f,d){if(!a.isUndefined(f)){if(u.indexOf(f)!==-1)throw Error("Circular reference detected in "+d.join("."));u.push(f),a.forEach(f,function(b,U){(!(a.isUndefined(b)||b===null)&&s.call(t,b,a.isString(U)?U.trim():U,d,g))===!0&&R(b,d?d.concat(U):[U])}),u.pop()}}if(!a.isObject(e))throw new TypeError("data must be an object");return R(e),t}function ke(e){const t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,function(r){return t[r]})}function ie(e,t){this._pairs=[],e&&X(e,this,t)}const ve=ie.prototype;ve.append=function(t,n){this._pairs.push([t,n])},ve.toString=function(t){const n=t?function(r){return t.call(this,r,ke)}:ke;return this._pairs.map(function(s){return n(s[0])+"="+n(s[1])},"").join("&")};function Vt(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||Vt,s=n&&n.serialize;let i;if(s?i=s(t,n):i=a.isURLSearchParams(t)?t.toString():new ie(t,n).toString(r),i){const o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}class zt{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 qe=zt,He={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},Kt={isBrowser:!0,classes:{URLSearchParams:typeof URLSearchParams<"u"?URLSearchParams:ie,FormData:typeof FormData<"u"?FormData:null,Blob:typeof Blob<"u"?Blob:null},protocols:["http","https","file","blob","url","data"]},Ve=typeof window<"u"&&typeof document<"u",Jt=(e=>Ve&&["ReactNative","NativeScript","NS"].indexOf(e)<0)(typeof navigator<"u"&&navigator.product),Mt=(()=>typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof self.importScripts=="function")(),T={...Object.freeze(Object.defineProperty({__proto__:null,hasBrowserEnv:Ve,hasStandardBrowserEnv:Jt,hasStandardBrowserWebWorkerEnv:Mt},Symbol.toStringTag,{value:"Module"})),...Kt};function Wt(e,t){return X(e,new T.classes.URLSearchParams,Object.assign({visitor:function(n,r,s,i){return T.isNode&&a.isBuffer(n)?(this.append(r,n.toString("base64")),!1):i.defaultVisitor.apply(this,arguments)}},t))}function Xt(e){return a.matchAll(/\w+|\[(\w*)]/g,e).map(t=>t[0]==="[]"?"":t[1]||t[0])}function Gt(e){const t={},n=Object.keys(e);let r;const s=n.length;let i;for(r=0;r<s;r++)i=n[r],t[i]=e[i];return t}function ze(e){function t(n,r,s,i){let o=n[i++];const c=Number.isFinite(+o),p=i>=n.length;return o=!o&&a.isArray(s)?s.length:o,p?(a.hasOwnProp(s,o)?s[o]=[s[o],r]:s[o]=r,!c):((!s[o]||!a.isObject(s[o]))&&(s[o]=[]),t(n,r,s[o],i)&&a.isArray(s[o])&&(s[o]=Gt(s[o])),!c)}if(a.isFormData(e)&&a.isFunction(e.entries)){const n={};return a.forEachEntry(e,(r,s)=>{t(Xt(r),s,n,0)}),n}return null}function Yt(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 ae={transitional:He,adapter:["xhr","http"],transformRequest:[function(t,n){const r=n.getContentType()||"",s=r.indexOf("application/json")>-1,i=a.isObject(t);if(i&&a.isHTMLForm(t)&&(t=new FormData(t)),a.isFormData(t))return s&&s?JSON.stringify(ze(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(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return Wt(t,this.formSerializer).toString();if((c=a.isFileList(t))||r.indexOf("multipart/form-data")>-1){const p=this.env&&this.env.FormData;return X(c?{"files[]":t}:t,p&&new p,this.formSerializer)}}return i||s?(n.setContentType("application/json",!1),Yt(t)):t}],transformResponse:[function(t){const n=this.transitional||ae.transitional,r=n&&n.forcedJSONParsing,s=this.responseType==="json";if(t&&a.isString(t)&&(r&&!this.responseType||s)){const o=!(n&&n.silentJSONParsing)&&s;try{return JSON.parse(t)}catch(c){if(o)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:T.classes.FormData,Blob:T.classes.Blob},validateStatus:function(t){return t>=200&&t<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};a.forEach(["delete","get","head","post","put","patch"],e=>{ae.headers[e]={}});const ce=ae,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"]),Zt=e=>{const t={};let n,r,s;return e&&e.split(`
|
|
2
|
+
`).forEach(function(o){s=o.indexOf(":"),n=o.substring(0,s).trim().toLowerCase(),r=o.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},Ke=Symbol("internals");function V(e){return e&&String(e).trim().toLowerCase()}function G(e){return e===!1||e==null?e:a.isArray(e)?e.map(G):String(e)}function en(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}const tn=e=>/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim());function ue(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 nn(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(t,n,r)=>n.toUpperCase()+r)}function rn(e,t){const n=a.toCamelCase(" "+t);["get","set","has"].forEach(r=>{Object.defineProperty(e,r+n,{value:function(s,i,o){return this[r].call(this,t,s,i,o)},configurable:!0})})}let Y=class{constructor(t){t&&this.set(t)}set(t,n,r){const s=this;function i(c,p,h){const l=V(p);if(!l)throw new Error("header name must be a non-empty string");const u=a.findKey(s,l);(!u||s[u]===void 0||h===!0||h===void 0&&s[u]!==!1)&&(s[u||p]=G(c))}const o=(c,p)=>a.forEach(c,(h,l)=>i(h,l,p));return a.isPlainObject(t)||t instanceof this.constructor?o(t,n):a.isString(t)&&(t=t.trim())&&!tn(t)?o(Zt(t),n):t!=null&&i(n,t,r),this}get(t,n){if(t=V(t),t){const r=a.findKey(this,t);if(r){const s=this[r];if(!n)return s;if(n===!0)return en(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=V(t),t){const r=a.findKey(this,t);return!!(r&&this[r]!==void 0&&(!n||ue(this,this[r],r,n)))}return!1}delete(t,n){const r=this;let s=!1;function i(o){if(o=V(o),o){const c=a.findKey(r,o);c&&(!n||ue(r,r[c],c,n))&&(delete r[c],s=!0)}}return a.isArray(t)?t.forEach(i):i(t),s}clear(t){const n=Object.keys(this);let r=n.length,s=!1;for(;r--;){const i=n[r];(!t||ue(this,this[i],i,t,!0))&&(delete this[i],s=!0)}return s}normalize(t){const n=this,r={};return a.forEach(this,(s,i)=>{const o=a.findKey(r,i);if(o){n[o]=G(s),delete n[i];return}const c=t?nn(i):String(i).trim();c!==i&&delete n[i],n[c]=G(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[Ke]=this[Ke]={accessors:{}}).accessors,s=this.prototype;function i(o){const c=V(o);r[c]||(rn(s,o),r[c]=!0)}return a.isArray(t)?t.forEach(i):i(t),this}};Y.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),a.reduceDescriptors(Y.prototype,({value:e},t)=>{let n=t[0].toUpperCase()+t.slice(1);return{get:()=>e,set(r){this[n]=r}}}),a.freezeMethods(Y);const _=Y;function le(e,t){const n=this||ce,r=t||n,s=_.from(r.headers);let i=r.data;return a.forEach(e,function(c){i=c.call(n,i,s.normalize(),t?t.status:void 0)}),s.normalize(),i}function Je(e){return!!(e&&e.__CANCEL__)}function z(e,t,n){m.call(this,e??"canceled",m.ERR_CANCELED,t,n),this.name="CanceledError"}a.inherits(z,m,{__CANCEL__:!0});function sn(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 on=T.hasStandardBrowserEnv?{write(e,t,n,r,s,i){const o=[e+"="+encodeURIComponent(t)];a.isNumber(n)&&o.push("expires="+new Date(n).toGMTString()),a.isString(r)&&o.push("path="+r),a.isString(s)&&o.push("domain="+s),i===!0&&o.push("secure"),document.cookie=o.join("; ")},read(e){const t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove(e){this.write(e,"",Date.now()-864e5)}}:{write(){},read(){return null},remove(){}};function an(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}function cn(e,t){return t?e.replace(/\/?\/$/,"")+"/"+t.replace(/^\/+/,""):e}function Me(e,t){return e&&!an(t)?cn(e,t):t}const un=T.hasStandardBrowserEnv?function(){const t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");let r;function s(i){let o=i;return t&&(n.setAttribute("href",o),o=n.href),n.setAttribute("href",o),{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(o){const c=a.isString(o)?s(o):o;return c.protocol===r.protocol&&c.host===r.host}}():function(){return function(){return!0}}();function ln(e){const t=/^([-+\w]{1,25})(:?\/\/|:)/.exec(e);return t&&t[1]||""}function fn(e,t){e=e||10;const n=new Array(e),r=new Array(e);let s=0,i=0,o;return t=t!==void 0?t:1e3,function(p){const h=Date.now(),l=r[i];o||(o=h),n[s]=p,r[s]=h;let u=i,g=0;for(;u!==s;)g+=n[u++],u=u%e;if(s=(s+1)%e,s===i&&(i=(i+1)%e),h-o<t)return;const R=l&&h-l;return R?Math.round(g*1e3/R):void 0}}function We(e,t){let n=0;const r=fn(50,250);return s=>{const i=s.loaded,o=s.lengthComputable?s.total:void 0,c=i-n,p=r(c),h=i<=o;n=i;const l={loaded:i,total:o,progress:o?i/o:void 0,bytes:c,rate:p||void 0,estimated:p&&o&&h?(o-i)/p:void 0,event:s};l[t?"download":"upload"]=!0,e(l)}}const fe={http:$t,xhr:typeof XMLHttpRequest<"u"&&function(e){return new Promise(function(n,r){let s=e.data;const i=_.from(e.headers).normalize();let{responseType:o,withXSRFToken:c}=e,p;function h(){e.cancelToken&&e.cancelToken.unsubscribe(p),e.signal&&e.signal.removeEventListener("abort",p)}let l;if(a.isFormData(s)){if(T.hasStandardBrowserEnv||T.hasStandardBrowserWebWorkerEnv)i.setContentType(!1);else if((l=i.getContentType())!==!1){const[d,...w]=l?l.split(";").map(b=>b.trim()).filter(Boolean):[];i.setContentType([d||"multipart/form-data",...w].join("; "))}}let u=new XMLHttpRequest;if(e.auth){const d=e.auth.username||"",w=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";i.set("Authorization","Basic "+btoa(d+":"+w))}const g=Me(e.baseURL,e.url);u.open(e.method.toUpperCase(),$e(g,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function R(){if(!u)return;const d=_.from("getAllResponseHeaders"in u&&u.getAllResponseHeaders()),b={data:!o||o==="text"||o==="json"?u.responseText:u.response,status:u.status,statusText:u.statusText,headers:d,config:e,request:u};sn(function(F){n(F),h()},function(F){r(F),h()},b),u=null}if("onloadend"in u?u.onloadend=R:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(R)},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 w=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded";const b=e.transitional||He;e.timeoutErrorMessage&&(w=e.timeoutErrorMessage),r(new m(w,b.clarifyTimeoutError?m.ETIMEDOUT:m.ECONNABORTED,e,u)),u=null},T.hasStandardBrowserEnv&&(c&&a.isFunction(c)&&(c=c(e)),c||c!==!1&&un(g))){const d=e.xsrfHeaderName&&e.xsrfCookieName&&on.read(e.xsrfCookieName);d&&i.set(e.xsrfHeaderName,d)}s===void 0&&i.setContentType(null),"setRequestHeader"in u&&a.forEach(i.toJSON(),function(w,b){u.setRequestHeader(b,w)}),a.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),o&&o!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",We(e.onDownloadProgress,!0)),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",We(e.onUploadProgress)),(e.cancelToken||e.signal)&&(p=d=>{u&&(r(!d||d.type?new z(null,e,u):d),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(p),e.signal&&(e.signal.aborted?p():e.signal.addEventListener("abort",p)));const f=ln(g);if(f&&T.protocols.indexOf(f)===-1){r(new m("Unsupported protocol "+f+":",m.ERR_BAD_REQUEST,e));return}u.send(s||null)})}};a.forEach(fe,(e,t)=>{if(e){try{Object.defineProperty(e,"name",{value:t})}catch{}Object.defineProperty(e,"adapterName",{value:t})}});const Xe=e=>`- ${e}`,dn=e=>a.isFunction(e)||e===null||e===!1,Ge={getAdapter:e=>{e=a.isArray(e)?e:[e];const{length:t}=e;let n,r;const s={};for(let i=0;i<t;i++){n=e[i];let o;if(r=n,!dn(n)&&(r=fe[(o=String(n)).toLowerCase()],r===void 0))throw new m(`Unknown adapter '${o}'`);if(r)break;s[o||"#"+i]=r}if(!r){const i=Object.entries(s).map(([c,p])=>`adapter ${c} `+(p===!1?"is not supported by the environment":"is not available in the build"));let o=t?i.length>1?`since :
|
|
4
|
+
`+i.map(Xe).join(`
|
|
5
|
+
`):" "+Xe(i[0]):"as no adapter specified";throw new m("There is no suitable adapter to dispatch the request "+o,"ERR_NOT_SUPPORT")}return r},adapters:fe};function de(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new z(null,e)}function Ye(e){return de(e),e.headers=_.from(e.headers),e.data=le.call(e,e.transformRequest),["post","put","patch"].indexOf(e.method)!==-1&&e.headers.setContentType("application/x-www-form-urlencoded",!1),Ge.getAdapter(e.adapter||ce.adapter)(e).then(function(r){return de(e),r.data=le.call(e,e.transformResponse,r),r.headers=_.from(r.headers),r},function(r){return Je(r)||(de(e),r&&r.response&&(r.response.data=le.call(e,e.transformResponse,r.response),r.response.headers=_.from(r.response.headers))),Promise.reject(r)})}const Qe=e=>e instanceof _?e.toJSON():e;function I(e,t){t=t||{};const n={};function r(h,l,u){return a.isPlainObject(h)&&a.isPlainObject(l)?a.merge.call({caseless:u},h,l):a.isPlainObject(l)?a.merge({},l):a.isArray(l)?l.slice():l}function s(h,l,u){if(a.isUndefined(l)){if(!a.isUndefined(h))return r(void 0,h,u)}else return r(h,l,u)}function i(h,l){if(!a.isUndefined(l))return r(void 0,l)}function o(h,l){if(a.isUndefined(l)){if(!a.isUndefined(h))return r(void 0,h)}else return r(void 0,l)}function c(h,l,u){if(u in t)return r(h,l);if(u in e)return r(void 0,h)}const p={url:i,method:i,data:i,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,withXSRFToken:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:c,headers:(h,l)=>s(Qe(h),Qe(l),!0)};return a.forEach(Object.keys(Object.assign({},e,t)),function(l){const u=p[l]||s,g=u(e[l],t[l],l);a.isUndefined(g)&&u!==c||(n[l]=g)}),n}const Ze="1.6.3",pe={};["object","boolean","number","function","string","symbol"].forEach((e,t)=>{pe[e]=function(r){return typeof r===e||"a"+(t<1?"n ":" ")+e}});const et={};pe.transitional=function(t,n,r){function s(i,o){return"[Axios v"+Ze+"] Transitional option '"+i+"'"+o+(r?". "+r:"")}return(i,o,c)=>{if(t===!1)throw new m(s(o," has been removed"+(n?" in "+n:"")),m.ERR_DEPRECATED);return n&&!et[o]&&(et[o]=!0,console.warn(s(o," has been deprecated since v"+n+" and will be removed in the near future"))),t?t(i,o,c):!0}};function pn(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 i=r[s],o=t[i];if(o){const c=e[i],p=c===void 0||o(c,i,e);if(p!==!0)throw new m("option "+i+" must be "+p,m.ERR_BAD_OPTION_VALUE);continue}if(n!==!0)throw new m("Unknown option "+i,m.ERR_BAD_OPTION)}}const he={assertOptions:pn,validators:pe},N=he.validators;let Q=class{constructor(t){this.defaults=t,this.interceptors={request:new qe,response:new qe}}request(t,n){typeof t=="string"?(n=n||{},n.url=t):n=t||{},n=I(this.defaults,n);const{transitional:r,paramsSerializer:s,headers:i}=n;r!==void 0&&he.assertOptions(r,{silentJSONParsing:N.transitional(N.boolean),forcedJSONParsing:N.transitional(N.boolean),clarifyTimeoutError:N.transitional(N.boolean)},!1),s!=null&&(a.isFunction(s)?n.paramsSerializer={serialize:s}:he.assertOptions(s,{encode:N.function,serialize:N.function},!0)),n.method=(n.method||this.defaults.method||"get").toLowerCase();let o=i&&a.merge(i.common,i[n.method]);i&&a.forEach(["delete","get","head","post","put","patch","common"],f=>{delete i[f]}),n.headers=_.concat(o,i);const c=[];let p=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(n)===!1||(p=p&&d.synchronous,c.unshift(d.fulfilled,d.rejected))});const h=[];this.interceptors.response.forEach(function(d){h.push(d.fulfilled,d.rejected)});let l,u=0,g;if(!p){const f=[Ye.bind(this),void 0];for(f.unshift.apply(f,c),f.push.apply(f,h),g=f.length,l=Promise.resolve(n);u<g;)l=l.then(f[u++],f[u++]);return l}g=c.length;let R=n;for(u=0;u<g;){const f=c[u++],d=c[u++];try{R=f(R)}catch(w){d.call(this,w);break}}try{l=Ye.call(this,R)}catch(f){return Promise.reject(f)}for(u=0,g=h.length;u<g;)l=l.then(h[u++],h[u++]);return l}getUri(t){t=I(this.defaults,t);const n=Me(t.baseURL,t.url);return $e(n,t.params,t.paramsSerializer)}};a.forEach(["delete","get","head","options"],function(t){Q.prototype[t]=function(n,r){return this.request(I(r||{},{method:t,url:n,data:(r||{}).data}))}}),a.forEach(["post","put","patch"],function(t){function n(r){return function(i,o,c){return this.request(I(c||{},{method:t,headers:r?{"Content-Type":"multipart/form-data"}:{},url:i,data:o}))}}Q.prototype[t]=n(),Q.prototype[t+"Form"]=n(!0)});const Z=Q,hn=class at{constructor(t){if(typeof t!="function")throw new TypeError("executor must be a function.");let n;this.promise=new Promise(function(i){n=i});const r=this;this.promise.then(s=>{if(!r._listeners)return;let i=r._listeners.length;for(;i-- >0;)r._listeners[i](s);r._listeners=null}),this.promise.then=s=>{let i;const o=new Promise(c=>{r.subscribe(c),i=c}).then(s);return o.cancel=function(){r.unsubscribe(i)},o},t(function(i,o,c){r.reason||(r.reason=new z(i,o,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 at(function(s){t=s}),cancel:t}}};function mn(e){return function(n){return e.apply(null,n)}}function yn(e){return a.isObject(e)&&e.isAxiosError===!0}const me={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(me).forEach(([e,t])=>{me[t]=e});const gn=me;function tt(e){const t=new Z(e),n=S(Z.prototype.request,t);return a.extend(n,Z.prototype,t,{allOwnKeys:!0}),a.extend(n,t,null,{allOwnKeys:!0}),n.create=function(s){return tt(I(e,s))},n}const y=tt(ce);y.Axios=Z,y.CanceledError=z,y.CancelToken=hn,y.isCancel=Je,y.VERSION=Ze,y.toFormData=X,y.AxiosError=m,y.Cancel=y.CanceledError,y.all=function(t){return Promise.all(t)},y.spread=mn,y.isAxiosError=yn,y.mergeConfig=I,y.AxiosHeaders=_,y.formToJSON=e=>ze(a.isHTMLForm(e)?new FormData(e):e),y.getAdapter=Ge.getAdapter,y.HttpStatusCode=gn,y.default=y;const nt=y,{Axios:mr,AxiosError:ee,CanceledError:yr,isCancel:gr,CancelToken:wr,VERSION:Er,all:br,Cancel:Sr,isAxiosError:Cr,spread:Ar,toFormData:Rr,AxiosHeaders:Or,HttpStatusCode:Tr,formToJSON:Pr,getAdapter:_r,mergeConfig:Nr}=nt;class ye extends Error{constructor(n){super(n.join(", "));C(this,"errors");this.name="ValidationError",this.errors=n}}class ge extends Error{constructor(n){super("Address already registered.");C(this,"address");this.name="AddressInUseError",this.address=n}}class we extends Error{constructor(n){super("Code already registered.");C(this,"code");this.name="CodeInUseError",this.code=n}}class Ee extends Error{constructor(){super("Invalid signature provided"),this.name="InvalidSignatureError"}}class wn{constructor(t){C(this,"httpClient");C(this,"_debug");this.httpClient=t.httpClient,this._debug=t.debug}async create(t,n,r){var s;try{await this.httpClient.post("/affiliates",{address:t,name:n,code:n,signature:r})}catch(i){if(i instanceof ee){const o=(s=i.response)==null?void 0:s.data;if(typeof(o==null?void 0:o.message)=="string"){const c=o.message.toLowerCase();throw c=="invalid signature"?new Ee:c=="address in use"?new ge(t):c=="code in use"?new we(n):new Error(c)}else if((o==null?void 0:o.message)instanceof Array)throw new ye(o.message)}throw i}}async update(t,n,r){var s;try{await this.httpClient.post(`/affiliates/${t}`,{code:n,address:t,signature:r})}catch(i){if(i instanceof ee){const o=(s=i.response)==null?void 0:s.data;if(typeof(o==null?void 0:o.message)=="string"){const c=o.message.toLowerCase();throw c=="invalid signature"?new Ee:c=="address in use"?new ge(t):c=="code in use"?new we(n):new Error(c)}else if((o==null?void 0:o.message)instanceof Array)throw new ye(o.message)}throw i}}async isCodeFree(t){var n;try{return await this.httpClient.get(`/affiliates/codes/${t}`),!1}catch(r){if(r instanceof ee&&((n=r.response)==null?void 0:n.status)===404)return!0;throw console.error("Fuul SDK: Could not check affiliate code",r),r}}async getCode(t){var n;try{return(await this.httpClient.get(`/affiliates/${t}`)).data.code}catch(r){if(r instanceof ee&&((n=r.response)==null?void 0:n.status)===404)return null;throw console.error("Fuul SDK: Could not get affiliate code",r),r}}}class En{constructor(t){C(this,"httpClient");this.httpClient=t.httpClient}async getAll(t){const{data:n}=await this.httpClient.get("conversions",t);return n}}const rt="fuul.sent",bn=60;class Sn{constructor(t){C(this,"debug");C(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=`${rt}_${t.name}`,r=localStorage.getItem(n);if(!r)return!1;const s=JSON.parse(r);if(this.getCurrentTimestamp()-s.timestamp>bn)return!1;let p=!1;t.metadata&&(p=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 h=!1;return t.args&&s.args&&(h=s.args.page===t.args.page),h&&p}getCurrentTimestamp(){return Date.now()/1e3}saveSentEvent(t){const n=`${rt}_${t.name}`,r=this.getCurrentTimestamp(),s={...t,timestamp:r};localStorage.setItem(n,JSON.stringify(s))}}const Cn={version:"4.9.0"};class An{constructor(t){C(this,"client");C(this,"queryParams");this.client=nt.create({...t,headers:{Authorization:`Bearer ${t.apiKey}`,"X-Fuul-Sdk-Version":Cn.version}}),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)}}const L="/payouts";class Rn{constructor(t){C(this,"httpClient");C(this,"_debug");this.httpClient=t.httpClient,this._debug=t.debug}async getPayoutsLeaderboard(t){return(await this.httpClient.get(`${L}/leaderboard`,t)).data}async getPointsLeaderboard(t){return(await this.httpClient.get(`${L}/leaderboard`,t)).data}async getUserPayoutsByConversion(t){return(await this.httpClient.get(L,{...t,type:"onchain-currency"})).data}async getUserPointsByConversion(t){return(await this.httpClient.get(L,{...t,type:"point"})).data}async getUserPayoutMovements(t){return(await this.httpClient.get(`${L}/movements`,{...t,type:"onchain-currency"})).data}async getUserPointsMovements(t){return(await this.httpClient.get(`${L}/movements`,{...t,type:"point"})).data}async getVolumeLeaderboard(t){return(await this.httpClient.get(`${L}/leaderboard/volume`,t)).data}}let On=(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 Tn="fuul.tracking_id",be=()=>Fn(Tn,()=>On()),st=()=>j("af")||j("referrer"),Pn=()=>document.referrer,_n=()=>Dn(),Nn=()=>j("category"),xn=()=>j("title"),Un=()=>j("tag"),Fn=(e,t)=>{const n=localStorage.getItem(e);if(n)return n;{const r=t();return r?localStorage.setItem(e,r):localStorage.removeItem(e),r}},j=e=>new URLSearchParams(window.location.search).get(e),Dn=()=>{const e=j("source");if(e)return e},Ln="/user";class Bn{constructor(t){C(this,"httpClient");this.httpClient=t.httpClient}async getUserAffiliates(t){return(await this.httpClient.get(Ln,t)).data.affiliates}}const In="https://api.fuul.xyz/api/v1/";let k=!1,Se=!1,Ce,v,ot,it,$,te,x;function jn(e){k=!!e.debug,!Se&&(Ce=e.apiKey,tr(),v=nr(e.baseApiUrl??In,e.defaultQueryParams??{}),ot=new En({httpClient:v,debug:k}),te=new Sn({httpClient:v,debug:k}),$=new wn({httpClient:v,debug:k}),x=new Rn({httpClient:v,debug:k}),it=new Bn({httpClient:v}),Se=!0,k&&console.debug("Fuul SDK: init() complete"))}function P(){if(!Se)throw new Error("Fuul SDK: You need to call init() to initialize the library before using any methods")}async function kn(e,t){P(),Ae(),Re();const n={name:e,args:t??{},metadata:{tracking_id:be()}};await te.sendEvent(n)}async function vn(e){P(),Ae(),Re();const t={name:"pageview",args:{page:e??document.location.pathname,locationOrigin:document.location.origin},metadata:{tracking_id:be(),referrer_url:Pn(),source:_n(),affiliate_id:st()??void 0,referrer:st()??void 0,category:Nn()??void 0,title:xn()??void 0,tag:Un()??void 0}};await te.sendEvent(t)}async function $n(e){P(),Ae(),Re();const t={name:"connect_wallet",args:{page:document.location.pathname,locationOrigin:document.location.origin},metadata:{tracking_id:be()}};e!=null&&e.address&&(t.user_address=e.address),e!=null&&e.signature&&(t.signature=e==null?void 0:e.signature,t.signature_message=e==null?void 0:e.message),e!=null&&e.accountChainId&&(t.account_chain_id=e.accountChainId),await te.sendEvent(t)}async function qn(e,t,n){P(),await $.create(e,t,n)}async function Hn(e,t,n){P(),await $.update(e,t,n)}async function Vn(e){return P(),await $.getCode(e)}async function zn(e){return P(),await $.isCodeFree(e)}async function Kn(e,t,n){P();const r=await $.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()}`}function Jn(e){return x.getPayoutsLeaderboard(e)}function Mn(e){return x.getPointsLeaderboard(e)}function Wn(e){return x.getVolumeLeaderboard(e)}function Xn(e){return x.getUserPayoutsByConversion(e)}function Gn(e){return x.getUserPointsByConversion(e)}function Yn(e){return x.getUserPayoutMovements(e)}function Qn(e){return x.getUserPointsMovements(e)}async function Zn(e){return P(),ot.getAll(e)}async function er(e){return P(),it.getUserAffiliates(e)}function Ae(){if(typeof window>"u"||typeof document>"u")throw new Error("Fuul SDK: Browser context required")}function Re(){if(navigator.webdriver)throw new Error("Fuul SDK: You are using a browser automation tool")}function tr(){if(!Ce)throw new Error("Fuul SDK: Invalid API key")}function nr(e,t){return new An({baseURL:e,timeout:1e4,apiKey:Ce,queryParams:t})}const rr={init:jn,sendEvent:kn,sendPageview:vn,sendConnectWallet:$n,generateTrackingLink:Kn,getConversions:Zn,createAffiliateCode:qn,updateAffiliateCode:Hn,getAffiliateCode:Vn,isAffiliateCodeFree:zn,getPayoutsLeaderboard:Jn,getPointsLeaderboard:Mn,getUserPayoutsByConversion:Xn,getUserPointsByConversion:Gn,getUserPointsMovements:Qn,getUserPayoutMovements:Yn,getUserAffiliates:er,getVolumeLeaderboard:Wn};E.AddressInUseError=ge,E.CodeInUseError=we,E.Fuul=rr,E.InvalidSignatureError=Ee,E.ValidationError=ye,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|