@nhost/nhost-js 0.3.12 → 0.3.13

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/index.es.js CHANGED
@@ -1,5 +1,5 @@
1
1
  var Ui=Object.create;var Re=Object.defineProperty;var ki=Object.getOwnPropertyDescriptor;var Fi=Object.getOwnPropertyNames;var ji=Object.getPrototypeOf,Di=Object.prototype.hasOwnProperty;var Li=t=>Re(t,"__esModule",{value:!0});var l=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var Bi=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Fi(e))!Di.call(t,s)&&(r||s!=="default")&&Re(t,s,{get:()=>e[s],enumerable:!(n=ki(e,s))||n.enumerable});return t},W=(t,e)=>Bi(Li(Re(t!=null?Ui(ji(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var qe=l((Tu,Mr)=>{"use strict";Mr.exports=function(e,r){return function(){for(var s=new Array(arguments.length),i=0;i<s.length;i++)s[i]=arguments[i];return e.apply(r,s)}}});var E=l((Ou,Vr)=>{"use strict";var _i=qe(),j=Object.prototype.toString;function Ie(t){return Array.isArray(t)}function Te(t){return typeof t=="undefined"}function Hi(t){return t!==null&&!Te(t)&&t.constructor!==null&&!Te(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Jr(t){return j.call(t)==="[object ArrayBuffer]"}function Mi(t){return j.call(t)==="[object FormData]"}function Ji(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Jr(t.buffer),e}function $i(t){return typeof t=="string"}function zi(t){return typeof t=="number"}function $r(t){return t!==null&&typeof t=="object"}function ne(t){if(j.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Vi(t){return j.call(t)==="[object Date]"}function Gi(t){return j.call(t)==="[object File]"}function Wi(t){return j.call(t)==="[object Blob]"}function zr(t){return j.call(t)==="[object Function]"}function Xi(t){return $r(t)&&zr(t.pipe)}function Ki(t){return j.call(t)==="[object URLSearchParams]"}function Qi(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Yi(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Ne(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Ie(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.call(null,t[s],s,t)}function Oe(){var t={};function e(s,i){ne(t[i])&&ne(s)?t[i]=Oe(t[i],s):ne(s)?t[i]=Oe({},s):Ie(s)?t[i]=s.slice():t[i]=s}for(var r=0,n=arguments.length;r<n;r++)Ne(arguments[r],e);return t}function Zi(t,e,r){return Ne(e,function(s,i){r&&typeof s=="function"?t[i]=_i(s,r):t[i]=s}),t}function ea(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Vr.exports={isArray:Ie,isArrayBuffer:Jr,isBuffer:Hi,isFormData:Mi,isArrayBufferView:Ji,isString:$i,isNumber:zi,isObject:$r,isPlainObject:ne,isUndefined:Te,isDate:Vi,isFile:Gi,isBlob:Wi,isFunction:zr,isStream:Xi,isURLSearchParams:Ki,isStandardBrowserEnv:Yi,forEach:Ne,merge:Oe,extend:Zi,trim:Qi,stripBOM:ea}});var Ue=l((Iu,Wr)=>{"use strict";var _=E();function Gr(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Wr.exports=function(e,r,n){if(!r)return e;var s;if(n)s=n(r);else if(_.isURLSearchParams(r))s=r.toString();else{var i=[];_.forEach(r,function(u,p){u===null||typeof u=="undefined"||(_.isArray(u)?p=p+"[]":u=[u],_.forEach(u,function(f){_.isDate(f)?f=f.toISOString():_.isObject(f)&&(f=JSON.stringify(f)),i.push(Gr(p)+"="+Gr(f))}))}),s=i.join("&")}if(s){var a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}});var Kr=l((Nu,Xr)=>{"use strict";var ra=E();function se(){this.handlers=[]}se.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};se.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};se.prototype.forEach=function(e){ra.forEach(this.handlers,function(n){n!==null&&e(n)})};Xr.exports=se});var Yr=l((Uu,Qr)=>{"use strict";var ta=E();Qr.exports=function(e,r){ta.forEach(e,function(s,i){i!==r&&i.toUpperCase()===r.toUpperCase()&&(e[r]=s,delete e[i])})}});var ke=l((ku,Zr)=>{"use strict";Zr.exports=function(e,r,n,s,i){return e.config=r,n&&(e.code=n),e.request=s,e.response=i,e.isAxiosError=!0,e.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:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var Fe=l((Fu,et)=>{"use strict";var na=ke();et.exports=function(e,r,n,s,i){var a=new Error(e);return na(a,r,n,s,i)}});var tt=l((ju,rt)=>{"use strict";var sa=Fe();rt.exports=function(e,r,n){var s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):r(sa("Request failed with status code "+n.status,n.config,null,n.request,n))}});var st=l((Du,nt)=>{"use strict";var ie=E();nt.exports=ie.isStandardBrowserEnv()?function(){return{write:function(r,n,s,i,a,o){var u=[];u.push(r+"="+encodeURIComponent(n)),ie.isNumber(s)&&u.push("expires="+new Date(s).toGMTString()),ie.isString(i)&&u.push("path="+i),ie.isString(a)&&u.push("domain="+a),o===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var at=l((Lu,it)=>{"use strict";it.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}});var ut=l((Bu,ot)=>{"use strict";ot.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var lt=l((_u,ct)=>{"use strict";var ia=at(),aa=ut();ct.exports=function(e,r){return e&&!ia(r)?aa(e,r):r}});var dt=l((Hu,ft)=>{"use strict";var je=E(),oa=["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"];ft.exports=function(e){var r={},n,s,i;return e&&je.forEach(e.split(`
2
2
  `),function(o){if(i=o.indexOf(":"),n=je.trim(o.substr(0,i)).toLowerCase(),s=je.trim(o.substr(i+1)),n){if(r[n]&&oa.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([s]):r[n]=r[n]?r[n]+", "+s:s}}),r}});var mt=l((Mu,pt)=>{"use strict";var ht=E();pt.exports=ht.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function s(i){var a=i;return e&&(r.setAttribute("href",a),a=r.href),r.setAttribute("href",a),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(a){var o=ht.isString(a)?s(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}()});var X=l((Ju,gt)=>{"use strict";function De(t){this.message=t}De.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};De.prototype.__CANCEL__=!0;gt.exports=De});var Be=l(($u,vt)=>{"use strict";var ae=E(),ua=tt(),ca=st(),la=Ue(),fa=lt(),da=dt(),ha=mt(),Le=Fe(),pa=K(),ma=X();vt.exports=function(e){return new Promise(function(n,s){var i=e.data,a=e.headers,o=e.responseType,u;function p(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}ae.isFormData(i)&&delete a["Content-Type"];var c=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.Authorization="Basic "+btoa(f+":"+h)}var d=fa(e.baseURL,e.url);c.open(e.method.toUpperCase(),la(d,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function R(){if(!!c){var m="getAllResponseHeaders"in c?da(c.getAllResponseHeaders()):null,q=!o||o==="text"||o==="json"?c.responseText:c.response,b={data:q,status:c.status,statusText:c.statusText,headers:m,config:e,request:c};ua(function(D){n(D),p()},function(D){s(D),p()},b),c=null}}if("onloadend"in c?c.onloadend=R:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(R)},c.onabort=function(){!c||(s(Le("Request aborted",e,"ECONNABORTED",c)),c=null)},c.onerror=function(){s(Le("Network Error",e,null,c)),c=null},c.ontimeout=function(){var q=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",b=e.transitional||pa.transitional;e.timeoutErrorMessage&&(q=e.timeoutErrorMessage),s(Le(q,e,b.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",c)),c=null},ae.isStandardBrowserEnv()){var A=(e.withCredentials||ha(d))&&e.xsrfCookieName?ca.read(e.xsrfCookieName):void 0;A&&(a[e.xsrfHeaderName]=A)}"setRequestHeader"in c&&ae.forEach(a,function(q,b){typeof i=="undefined"&&b.toLowerCase()==="content-type"?delete a[b]:c.setRequestHeader(b,q)}),ae.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),o&&o!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(u=function(m){!c||(s(!m||m&&m.type?new ma("canceled"):m),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u))),i||(i=null),c.send(i)})}});var K=l((zu,St)=>{"use strict";var v=E(),yt=Yr(),ga=ke(),va={"Content-Type":"application/x-www-form-urlencoded"};function wt(t,e){!v.isUndefined(t)&&v.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function ya(){var t;return typeof XMLHttpRequest!="undefined"?t=Be():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Be()),t}function wa(t,e,r){if(v.isString(t))try{return(e||JSON.parse)(t),v.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var oe={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:ya(),transformRequest:[function(e,r){return yt(r,"Accept"),yt(r,"Content-Type"),v.isFormData(e)||v.isArrayBuffer(e)||v.isBuffer(e)||v.isStream(e)||v.isFile(e)||v.isBlob(e)?e:v.isArrayBufferView(e)?e.buffer:v.isURLSearchParams(e)?(wt(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):v.isObject(e)||r&&r["Content-Type"]==="application/json"?(wt(r,"application/json"),wa(e)):e}],transformResponse:[function(e){var r=this.transitional||oe.transitional,n=r&&r.silentJSONParsing,s=r&&r.forcedJSONParsing,i=!n&&this.responseType==="json";if(i||s&&v.isString(e)&&e.length)try{return JSON.parse(e)}catch(a){if(i)throw a.name==="SyntaxError"?ga(a,this,"E_JSON_PARSE"):a}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};v.forEach(["delete","get","head"],function(e){oe.headers[e]={}});v.forEach(["post","put","patch"],function(e){oe.headers[e]=v.merge(va)});St.exports=oe});var Et=l((Vu,bt)=>{"use strict";var Sa=E(),ba=K();bt.exports=function(e,r,n){var s=this||ba;return Sa.forEach(n,function(a){e=a.call(s,e,r)}),e}});var _e=l((Gu,At)=>{"use strict";At.exports=function(e){return!!(e&&e.__CANCEL__)}});var Pt=l((Wu,Ct)=>{"use strict";var xt=E(),He=Et(),Ea=_e(),Aa=K(),xa=X();function Me(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new xa("canceled")}Ct.exports=function(e){Me(e),e.headers=e.headers||{},e.data=He.call(e,e.data,e.headers,e.transformRequest),e.headers=xt.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),xt.forEach(["delete","get","head","post","put","patch","common"],function(s){delete e.headers[s]});var r=e.adapter||Aa.adapter;return r(e).then(function(s){return Me(e),s.data=He.call(e,s.data,s.headers,e.transformResponse),s},function(s){return Ea(s)||(Me(e),s&&s.response&&(s.response.data=He.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})}});var Je=l((Xu,Rt)=>{"use strict";var T=E();Rt.exports=function(e,r){r=r||{};var n={};function s(c,f){return T.isPlainObject(c)&&T.isPlainObject(f)?T.merge(c,f):T.isPlainObject(f)?T.merge({},f):T.isArray(f)?f.slice():f}function i(c){if(T.isUndefined(r[c])){if(!T.isUndefined(e[c]))return s(void 0,e[c])}else return s(e[c],r[c])}function a(c){if(!T.isUndefined(r[c]))return s(void 0,r[c])}function o(c){if(T.isUndefined(r[c])){if(!T.isUndefined(e[c]))return s(void 0,e[c])}else return s(void 0,r[c])}function u(c){if(c in r)return s(e[c],r[c]);if(c in e)return s(void 0,e[c])}var p={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:u};return T.forEach(Object.keys(e).concat(Object.keys(r)),function(f){var h=p[f]||i,d=h(f);T.isUndefined(d)&&h!==u||(n[f]=d)}),n}});var $e=l((Ku,qt)=>{qt.exports={version:"0.25.0"}});var It=l((Qu,Ot)=>{"use strict";var Ca=$e().version,ze={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){ze[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var Tt={};ze.transitional=function(e,r,n){function s(i,a){return"[Axios v"+Ca+"] Transitional option '"+i+"'"+a+(n?". "+n:"")}return function(i,a,o){if(e===!1)throw new Error(s(a," has been removed"+(r?" in "+r:"")));return r&&!Tt[a]&&(Tt[a]=!0,console.warn(s(a," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,a,o):!0}};function Pa(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),s=n.length;s-- >0;){var i=n[s],a=e[i];if(a){var o=t[i],u=o===void 0||a(o,i,t);if(u!==!0)throw new TypeError("option "+i+" must be "+u);continue}if(r!==!0)throw Error("Unknown option "+i)}}Ot.exports={assertOptions:Pa,validators:ze}});var Dt=l((Yu,jt)=>{"use strict";var kt=E(),Ra=Ue(),Nt=Kr(),Ut=Pt(),ue=Je(),Ft=It(),H=Ft.validators;function Q(t){this.defaults=t,this.interceptors={request:new Nt,response:new Nt}}Q.prototype.request=function(e,r){if(typeof e=="string"?(r=r||{},r.url=e):r=e||{},!r.url)throw new Error("Provided config url is not valid");r=ue(this.defaults,r),r.method?r.method=r.method.toLowerCase():this.defaults.method?r.method=this.defaults.method.toLowerCase():r.method="get";var n=r.transitional;n!==void 0&&Ft.assertOptions(n,{silentJSONParsing:H.transitional(H.boolean),forcedJSONParsing:H.transitional(H.boolean),clarifyTimeoutError:H.transitional(H.boolean)},!1);var s=[],i=!0;this.interceptors.request.forEach(function(d){typeof d.runWhen=="function"&&d.runWhen(r)===!1||(i=i&&d.synchronous,s.unshift(d.fulfilled,d.rejected))});var a=[];this.interceptors.response.forEach(function(d){a.push(d.fulfilled,d.rejected)});var o;if(!i){var u=[Ut,void 0];for(Array.prototype.unshift.apply(u,s),u=u.concat(a),o=Promise.resolve(r);u.length;)o=o.then(u.shift(),u.shift());return o}for(var p=r;s.length;){var c=s.shift(),f=s.shift();try{p=c(p)}catch(h){f(h);break}}try{o=Ut(p)}catch(h){return Promise.reject(h)}for(;a.length;)o=o.then(a.shift(),a.shift());return o};Q.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=ue(this.defaults,e),Ra(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};kt.forEach(["delete","get","head","options"],function(e){Q.prototype[e]=function(r,n){return this.request(ue(n||{},{method:e,url:r,data:(n||{}).data}))}});kt.forEach(["post","put","patch"],function(e){Q.prototype[e]=function(r,n,s){return this.request(ue(s||{},{method:e,url:r,data:n}))}});jt.exports=Q});var Bt=l((Zu,Lt)=>{"use strict";var qa=X();function M(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(s){e=s});var r=this;this.promise.then(function(n){if(!!r._listeners){var s,i=r._listeners.length;for(s=0;s<i;s++)r._listeners[s](n);r._listeners=null}}),this.promise.then=function(n){var s,i=new Promise(function(a){r.subscribe(a),s=a}).then(n);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s){r.reason||(r.reason=new qa(s),e(r.reason))})}M.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};M.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};M.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};M.source=function(){var e,r=new M(function(s){e=s});return{token:r,cancel:e}};Lt.exports=M});var Ht=l((ec,_t)=>{"use strict";_t.exports=function(e){return function(n){return e.apply(null,n)}}});var Jt=l((rc,Mt)=>{"use strict";var Ta=E();Mt.exports=function(e){return Ta.isObject(e)&&e.isAxiosError===!0}});var Vt=l((tc,Ve)=>{"use strict";var $t=E(),Oa=qe(),ce=Dt(),Ia=Je(),Na=K();function zt(t){var e=new ce(t),r=Oa(ce.prototype.request,e);return $t.extend(r,ce.prototype,e),$t.extend(r,e),r.create=function(s){return zt(Ia(t,s))},r}var N=zt(Na);N.Axios=ce;N.Cancel=X();N.CancelToken=Bt();N.isCancel=_e();N.VERSION=$e().version;N.all=function(e){return Promise.all(e)};N.spread=Ht();N.isAxiosError=Jt();Ve.exports=N;Ve.exports.default=N});var Wt=l((nc,Gt)=>{Gt.exports=Vt()});var Qt=l((oc,Kt)=>{"use strict";Kt.exports=t=>encodeURIComponent(t).replace(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`)});var tn=l((uc,rn)=>{"use strict";var en="%[a-f0-9]{2}",Yt=new RegExp(en,"gi"),Zt=new RegExp("("+en+")+","gi");function We(t,e){try{return decodeURIComponent(t.join(""))}catch{}if(t.length===1)return t;e=e||1;var r=t.slice(0,e),n=t.slice(e);return Array.prototype.concat.call([],We(r),We(n))}function ka(t){try{return decodeURIComponent(t)}catch{for(var e=t.match(Yt),r=1;r<e.length;r++)t=We(e,r).join(""),e=t.match(Yt);return t}}function Fa(t){for(var e={"%FE%FF":"\uFFFD\uFFFD","%FF%FE":"\uFFFD\uFFFD"},r=Zt.exec(t);r;){try{e[r[0]]=decodeURIComponent(r[0])}catch{var n=ka(r[0]);n!==r[0]&&(e[r[0]]=n)}r=Zt.exec(t)}e["%C2"]="\uFFFD";for(var s=Object.keys(e),i=0;i<s.length;i++){var a=s[i];t=t.replace(new RegExp(a,"g"),e[a])}return t}rn.exports=function(t){if(typeof t!="string")throw new TypeError("Expected `encodedURI` to be of type `string`, got `"+typeof t+"`");try{return t=t.replace(/\+/g," "),decodeURIComponent(t)}catch{return Fa(t)}}});var sn=l((cc,nn)=>{"use strict";nn.exports=(t,e)=>{if(!(typeof t=="string"&&typeof e=="string"))throw new TypeError("Expected the arguments to be of type `string`");if(e==="")return[t];let r=t.indexOf(e);return r===-1?[t]:[t.slice(0,r),t.slice(r+e.length)]}});var on=l((lc,an)=>{"use strict";an.exports=function(t,e){for(var r={},n=Object.keys(t),s=Array.isArray(e),i=0;i<n.length;i++){var a=n[i],o=t[a];(s?e.indexOf(a)!==-1:e(a,o,t))&&(r[a]=o)}return r}});var mn=l(x=>{"use strict";var ja=Qt(),Da=tn(),cn=sn(),La=on(),Ba=t=>t==null,Xe=Symbol("encodeFragmentIdentifier");function _a(t){switch(t.arrayFormat){case"index":return e=>(r,n)=>{let s=r.length;return n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,[g(e,t),"[",s,"]"].join("")]:[...r,[g(e,t),"[",g(s,t),"]=",g(n,t)].join("")]};case"bracket":return e=>(r,n)=>n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,[g(e,t),"[]"].join("")]:[...r,[g(e,t),"[]=",g(n,t)].join("")];case"colon-list-separator":return e=>(r,n)=>n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,[g(e,t),":list="].join("")]:[...r,[g(e,t),":list=",g(n,t)].join("")];case"comma":case"separator":case"bracket-separator":{let e=t.arrayFormat==="bracket-separator"?"[]=":"=";return r=>(n,s)=>s===void 0||t.skipNull&&s===null||t.skipEmptyString&&s===""?n:(s=s===null?"":s,n.length===0?[[g(r,t),e,g(s,t)].join("")]:[[n,g(s,t)].join(t.arrayFormatSeparator)])}default:return e=>(r,n)=>n===void 0||t.skipNull&&n===null||t.skipEmptyString&&n===""?r:n===null?[...r,g(e,t)]:[...r,[g(e,t),"=",g(n,t)].join("")]}}function Ha(t){let e;switch(t.arrayFormat){case"index":return(r,n,s)=>{if(e=/\[(\d*)\]$/.exec(r),r=r.replace(/\[\d*\]$/,""),!e){s[r]=n;return}s[r]===void 0&&(s[r]={}),s[r][e[1]]=n};case"bracket":return(r,n,s)=>{if(e=/(\[\])$/.exec(r),r=r.replace(/\[\]$/,""),!e){s[r]=n;return}if(s[r]===void 0){s[r]=[n];return}s[r]=[].concat(s[r],n)};case"colon-list-separator":return(r,n,s)=>{if(e=/(:list)$/.exec(r),r=r.replace(/:list$/,""),!e){s[r]=n;return}if(s[r]===void 0){s[r]=[n];return}s[r]=[].concat(s[r],n)};case"comma":case"separator":return(r,n,s)=>{let i=typeof n=="string"&&n.includes(t.arrayFormatSeparator),a=typeof n=="string"&&!i&&k(n,t).includes(t.arrayFormatSeparator);n=a?k(n,t):n;let o=i||a?n.split(t.arrayFormatSeparator).map(u=>k(u,t)):n===null?n:k(n,t);s[r]=o};case"bracket-separator":return(r,n,s)=>{let i=/(\[\])$/.test(r);if(r=r.replace(/\[\]$/,""),!i){s[r]=n&&k(n,t);return}let a=n===null?[]:n.split(t.arrayFormatSeparator).map(o=>k(o,t));if(s[r]===void 0){s[r]=a;return}s[r]=[].concat(s[r],a)};default:return(r,n,s)=>{if(s[r]===void 0){s[r]=n;return}s[r]=[].concat(s[r],n)}}}function ln(t){if(typeof t!="string"||t.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(t,e){return e.encode?e.strict?ja(t):encodeURIComponent(t):t}function k(t,e){return e.decode?Da(t):t}function fn(t){return Array.isArray(t)?t.sort():typeof t=="object"?fn(Object.keys(t)).sort((e,r)=>Number(e)-Number(r)).map(e=>t[e]):t}function dn(t){let e=t.indexOf("#");return e!==-1&&(t=t.slice(0,e)),t}function Ma(t){let e="",r=t.indexOf("#");return r!==-1&&(e=t.slice(r)),e}function hn(t){t=dn(t);let e=t.indexOf("?");return e===-1?"":t.slice(e+1)}function un(t,e){return e.parseNumbers&&!Number.isNaN(Number(t))&&typeof t=="string"&&t.trim()!==""?t=Number(t):e.parseBooleans&&t!==null&&(t.toLowerCase()==="true"||t.toLowerCase()==="false")&&(t=t.toLowerCase()==="true"),t}function pn(t,e){e=Object.assign({decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1},e),ln(e.arrayFormatSeparator);let r=Ha(e),n=Object.create(null);if(typeof t!="string"||(t=t.trim().replace(/^[?#&]/,""),!t))return n;for(let s of t.split("&")){if(s==="")continue;let[i,a]=cn(e.decode?s.replace(/\+/g," "):s,"=");a=a===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?a:k(a,e),r(k(i,e),a,n)}for(let s of Object.keys(n)){let i=n[s];if(typeof i=="object"&&i!==null)for(let a of Object.keys(i))i[a]=un(i[a],e);else n[s]=un(i,e)}return e.sort===!1?n:(e.sort===!0?Object.keys(n).sort():Object.keys(n).sort(e.sort)).reduce((s,i)=>{let a=n[i];return Boolean(a)&&typeof a=="object"&&!Array.isArray(a)?s[i]=fn(a):s[i]=a,s},Object.create(null))}x.extract=hn;x.parse=pn;x.stringify=(t,e)=>{if(!t)return"";e=Object.assign({encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:","},e),ln(e.arrayFormatSeparator);let r=a=>e.skipNull&&Ba(t[a])||e.skipEmptyString&&t[a]==="",n=_a(e),s={};for(let a of Object.keys(t))r(a)||(s[a]=t[a]);let i=Object.keys(s);return e.sort!==!1&&i.sort(e.sort),i.map(a=>{let o=t[a];return o===void 0?"":o===null?g(a,e):Array.isArray(o)?o.length===0&&e.arrayFormat==="bracket-separator"?g(a,e)+"[]":o.reduce(n(a),[]).join("&"):g(a,e)+"="+g(o,e)}).filter(a=>a.length>0).join("&")};x.parseUrl=(t,e)=>{e=Object.assign({decode:!0},e);let[r,n]=cn(t,"#");return Object.assign({url:r.split("?")[0]||"",query:pn(hn(t),e)},e&&e.parseFragmentIdentifier&&n?{fragmentIdentifier:k(n,e)}:{})};x.stringifyUrl=(t,e)=>{e=Object.assign({encode:!0,strict:!0,[Xe]:!0},e);let r=dn(t.url).split("?")[0]||"",n=x.extract(t.url),s=x.parse(n,{sort:!1}),i=Object.assign(s,t.query),a=x.stringify(i,e);a&&(a=`?${a}`);let o=Ma(t.url);return t.fragmentIdentifier&&(o=`#${e[Xe]?g(t.fragmentIdentifier,e):t.fragmentIdentifier}`),`${r}${a}${o}`};x.pick=(t,e,r)=>{r=Object.assign({parseFragmentIdentifier:!0,[Xe]:!1},r);let{url:n,query:s,fragmentIdentifier:i}=x.parseUrl(t,r);return x.stringifyUrl({url:n,query:La(s,e),fragmentIdentifier:i},r)};x.exclude=(t,e,r)=>{let n=Array.isArray(e)?s=>!e.includes(s):(s,i)=>!e(s,i);return x.pick(t,n,r)}});var Ye=l((Ec,vn)=>{"use strict";vn.exports=function(e,r){return function(){for(var s=new Array(arguments.length),i=0;i<s.length;i++)s[i]=arguments[i];return e.apply(r,s)}}});var C=l((Ac,Sn)=>{"use strict";var Ja=Ye(),L=Object.prototype.toString;function rr(t){return L.call(t)==="[object Array]"}function Ze(t){return typeof t=="undefined"}function $a(t){return t!==null&&!Ze(t)&&t.constructor!==null&&!Ze(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function za(t){return L.call(t)==="[object ArrayBuffer]"}function Va(t){return typeof FormData!="undefined"&&t instanceof FormData}function Ga(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function Wa(t){return typeof t=="string"}function Xa(t){return typeof t=="number"}function yn(t){return t!==null&&typeof t=="object"}function le(t){if(L.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Ka(t){return L.call(t)==="[object Date]"}function Qa(t){return L.call(t)==="[object File]"}function Ya(t){return L.call(t)==="[object Blob]"}function wn(t){return L.call(t)==="[object Function]"}function Za(t){return yn(t)&&wn(t.pipe)}function eo(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function ro(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function to(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function tr(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),rr(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.call(null,t[s],s,t)}function er(){var t={};function e(s,i){le(t[i])&&le(s)?t[i]=er(t[i],s):le(s)?t[i]=er({},s):rr(s)?t[i]=s.slice():t[i]=s}for(var r=0,n=arguments.length;r<n;r++)tr(arguments[r],e);return t}function no(t,e,r){return tr(e,function(s,i){r&&typeof s=="function"?t[i]=Ja(s,r):t[i]=s}),t}function so(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Sn.exports={isArray:rr,isArrayBuffer:za,isBuffer:$a,isFormData:Va,isArrayBufferView:Ga,isString:Wa,isNumber:Xa,isObject:yn,isPlainObject:le,isUndefined:Ze,isDate:Ka,isFile:Qa,isBlob:Ya,isFunction:wn,isStream:Za,isURLSearchParams:eo,isStandardBrowserEnv:to,forEach:tr,merge:er,extend:no,trim:ro,stripBOM:so}});var nr=l((xc,En)=>{"use strict";var J=C();function bn(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}En.exports=function(e,r,n){if(!r)return e;var s;if(n)s=n(r);else if(J.isURLSearchParams(r))s=r.toString();else{var i=[];J.forEach(r,function(u,p){u===null||typeof u=="undefined"||(J.isArray(u)?p=p+"[]":u=[u],J.forEach(u,function(f){J.isDate(f)?f=f.toISOString():J.isObject(f)&&(f=JSON.stringify(f)),i.push(bn(p)+"="+bn(f))}))}),s=i.join("&")}if(s){var a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}});var xn=l((Cc,An)=>{"use strict";var io=C();function fe(){this.handlers=[]}fe.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};fe.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};fe.prototype.forEach=function(e){io.forEach(this.handlers,function(n){n!==null&&e(n)})};An.exports=fe});var Pn=l((Pc,Cn)=>{"use strict";var ao=C();Cn.exports=function(e,r){ao.forEach(e,function(s,i){i!==r&&i.toUpperCase()===r.toUpperCase()&&(e[r]=s,delete e[i])})}});var sr=l((Rc,Rn)=>{"use strict";Rn.exports=function(e,r,n,s,i){return e.config=r,n&&(e.code=n),e.request=s,e.response=i,e.isAxiosError=!0,e.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:this.config,code:this.code}},e}});var ir=l((qc,qn)=>{"use strict";var oo=sr();qn.exports=function(e,r,n,s,i){var a=new Error(e);return oo(a,r,n,s,i)}});var On=l((Tc,Tn)=>{"use strict";var uo=ir();Tn.exports=function(e,r,n){var s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):r(uo("Request failed with status code "+n.status,n.config,null,n.request,n))}});var Nn=l((Oc,In)=>{"use strict";var de=C();In.exports=de.isStandardBrowserEnv()?function(){return{write:function(r,n,s,i,a,o){var u=[];u.push(r+"="+encodeURIComponent(n)),de.isNumber(s)&&u.push("expires="+new Date(s).toGMTString()),de.isString(i)&&u.push("path="+i),de.isString(a)&&u.push("domain="+a),o===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var kn=l((Ic,Un)=>{"use strict";Un.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var jn=l((Nc,Fn)=>{"use strict";Fn.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var Ln=l((Uc,Dn)=>{"use strict";var co=kn(),lo=jn();Dn.exports=function(e,r){return e&&!co(r)?lo(e,r):r}});var _n=l((kc,Bn)=>{"use strict";var ar=C(),fo=["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"];Bn.exports=function(e){var r={},n,s,i;return e&&ar.forEach(e.split(`
3
3
  `),function(o){if(i=o.indexOf(":"),n=ar.trim(o.substr(0,i)).toLowerCase(),s=ar.trim(o.substr(i+1)),n){if(r[n]&&fo.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([s]):r[n]=r[n]?r[n]+", "+s:s}}),r}});var Jn=l((Fc,Mn)=>{"use strict";var Hn=C();Mn.exports=Hn.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function s(i){var a=i;return e&&(r.setAttribute("href",a),a=r.href),r.setAttribute("href",a),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(a){var o=Hn.isString(a)?s(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}()});var ur=l((jc,$n)=>{"use strict";var he=C(),ho=On(),po=Nn(),mo=nr(),go=Ln(),vo=_n(),yo=Jn(),or=ir();$n.exports=function(e){return new Promise(function(n,s){var i=e.data,a=e.headers,o=e.responseType;he.isFormData(i)&&delete a["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var p=e.auth.username||"",c=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.Authorization="Basic "+btoa(p+":"+c)}var f=go(e.baseURL,e.url);u.open(e.method.toUpperCase(),mo(f,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function h(){if(!!u){var R="getAllResponseHeaders"in u?vo(u.getAllResponseHeaders()):null,A=!o||o==="text"||o==="json"?u.responseText:u.response,m={data:A,status:u.status,statusText:u.statusText,headers:R,config:e,request:u};ho(n,s,m),u=null}}if("onloadend"in u?u.onloadend=h:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(h)},u.onabort=function(){!u||(s(or("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){s(or("Network Error",e,null,u)),u=null},u.ontimeout=function(){var A="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(A=e.timeoutErrorMessage),s(or(A,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},he.isStandardBrowserEnv()){var d=(e.withCredentials||yo(f))&&e.xsrfCookieName?po.read(e.xsrfCookieName):void 0;d&&(a[e.xsrfHeaderName]=d)}"setRequestHeader"in u&&he.forEach(a,function(A,m){typeof i=="undefined"&&m.toLowerCase()==="content-type"?delete a[m]:u.setRequestHeader(m,A)}),he.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),o&&o!=="json"&&(u.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&u.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&u.upload&&u.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(A){!u||(u.abort(),s(A),u=null)}),i||(i=null),u.send(i)})}});var me=l((Dc,Gn)=>{"use strict";var y=C(),zn=Pn(),wo=sr(),So={"Content-Type":"application/x-www-form-urlencoded"};function Vn(t,e){!y.isUndefined(t)&&y.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function bo(){var t;return typeof XMLHttpRequest!="undefined"?t=ur():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=ur()),t}function Eo(t,e,r){if(y.isString(t))try{return(e||JSON.parse)(t),y.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var pe={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:bo(),transformRequest:[function(e,r){return zn(r,"Accept"),zn(r,"Content-Type"),y.isFormData(e)||y.isArrayBuffer(e)||y.isBuffer(e)||y.isStream(e)||y.isFile(e)||y.isBlob(e)?e:y.isArrayBufferView(e)?e.buffer:y.isURLSearchParams(e)?(Vn(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):y.isObject(e)||r&&r["Content-Type"]==="application/json"?(Vn(r,"application/json"),Eo(e)):e}],transformResponse:[function(e){var r=this.transitional,n=r&&r.silentJSONParsing,s=r&&r.forcedJSONParsing,i=!n&&this.responseType==="json";if(i||s&&y.isString(e)&&e.length)try{return JSON.parse(e)}catch(a){if(i)throw a.name==="SyntaxError"?wo(a,this,"E_JSON_PARSE"):a}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};pe.headers={common:{Accept:"application/json, text/plain, */*"}};y.forEach(["delete","get","head"],function(e){pe.headers[e]={}});y.forEach(["post","put","patch"],function(e){pe.headers[e]=y.merge(So)});Gn.exports=pe});var Xn=l((Lc,Wn)=>{"use strict";var Ao=C(),xo=me();Wn.exports=function(e,r,n){var s=this||xo;return Ao.forEach(n,function(a){e=a.call(s,e,r)}),e}});var cr=l((Bc,Kn)=>{"use strict";Kn.exports=function(e){return!!(e&&e.__CANCEL__)}});var Zn=l((_c,Yn)=>{"use strict";var Qn=C(),lr=Xn(),Co=cr(),Po=me();function fr(t){t.cancelToken&&t.cancelToken.throwIfRequested()}Yn.exports=function(e){fr(e),e.headers=e.headers||{},e.data=lr.call(e,e.data,e.headers,e.transformRequest),e.headers=Qn.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Qn.forEach(["delete","get","head","post","put","patch","common"],function(s){delete e.headers[s]});var r=e.adapter||Po.adapter;return r(e).then(function(s){return fr(e),s.data=lr.call(e,s.data,s.headers,e.transformResponse),s},function(s){return Co(s)||(fr(e),s&&s.response&&(s.response.data=lr.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})}});var dr=l((Hc,es)=>{"use strict";var S=C();es.exports=function(e,r){r=r||{};var n={},s=["url","method","data"],i=["headers","auth","proxy","params"],a=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],o=["validateStatus"];function u(h,d){return S.isPlainObject(h)&&S.isPlainObject(d)?S.merge(h,d):S.isPlainObject(d)?S.merge({},d):S.isArray(d)?d.slice():d}function p(h){S.isUndefined(r[h])?S.isUndefined(e[h])||(n[h]=u(void 0,e[h])):n[h]=u(e[h],r[h])}S.forEach(s,function(d){S.isUndefined(r[d])||(n[d]=u(void 0,r[d]))}),S.forEach(i,p),S.forEach(a,function(d){S.isUndefined(r[d])?S.isUndefined(e[d])||(n[d]=u(void 0,e[d])):n[d]=u(void 0,r[d])}),S.forEach(o,function(d){d in r?n[d]=u(e[d],r[d]):d in e&&(n[d]=u(void 0,e[d]))});var c=s.concat(i).concat(a).concat(o),f=Object.keys(e).concat(Object.keys(r)).filter(function(d){return c.indexOf(d)===-1});return S.forEach(f,p),n}});var rs=l((Mc,Ro)=>{Ro.exports={name:"axios",version:"0.21.4",description:"Promise based HTTP client for the browser and node.js",main:"index.js",scripts:{test:"grunt test",start:"node ./sandbox/server.js",build:"NODE_ENV=production grunt build",preversion:"npm test",version:"npm run build && grunt version && git add -A dist && git add CHANGELOG.md bower.json package.json",postversion:"git push && git push --tags",examples:"node ./examples/server.js",coveralls:"cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",fix:"eslint --fix lib/**/*.js"},repository:{type:"git",url:"https://github.com/axios/axios.git"},keywords:["xhr","http","ajax","promise","node"],author:"Matt Zabriskie",license:"MIT",bugs:{url:"https://github.com/axios/axios/issues"},homepage:"https://axios-http.com",devDependencies:{coveralls:"^3.0.0","es6-promise":"^4.2.4",grunt:"^1.3.0","grunt-banner":"^0.6.0","grunt-cli":"^1.2.0","grunt-contrib-clean":"^1.1.0","grunt-contrib-watch":"^1.0.0","grunt-eslint":"^23.0.0","grunt-karma":"^4.0.0","grunt-mocha-test":"^0.13.3","grunt-ts":"^6.0.0-beta.19","grunt-webpack":"^4.0.2","istanbul-instrumenter-loader":"^1.0.0","jasmine-core":"^2.4.1",karma:"^6.3.2","karma-chrome-launcher":"^3.1.0","karma-firefox-launcher":"^2.1.0","karma-jasmine":"^1.1.1","karma-jasmine-ajax":"^0.1.13","karma-safari-launcher":"^1.0.0","karma-sauce-launcher":"^4.3.6","karma-sinon":"^1.0.5","karma-sourcemap-loader":"^0.3.8","karma-webpack":"^4.0.2","load-grunt-tasks":"^3.5.2",minimist:"^1.2.0",mocha:"^8.2.1",sinon:"^4.5.0","terser-webpack-plugin":"^4.2.3",typescript:"^4.0.5","url-search-params":"^0.10.0",webpack:"^4.44.2","webpack-dev-server":"^3.11.0"},browser:{"./lib/adapters/http.js":"./lib/adapters/xhr.js"},jsdelivr:"dist/axios.min.js",unpkg:"dist/axios.min.js",typings:"./index.d.ts",dependencies:{"follow-redirects":"^1.14.0"},bundlesize:[{path:"./dist/axios.min.js",threshold:"5kB"}]}});var as=l((Jc,is)=>{"use strict";var ns=rs(),hr={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){hr[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var ts={},qo=ns.version.split(".");function ss(t,e){for(var r=e?e.split("."):qo,n=t.split("."),s=0;s<3;s++){if(r[s]>n[s])return!0;if(r[s]<n[s])return!1}return!1}hr.transitional=function(e,r,n){var s=r&&ss(r);function i(a,o){return"[Axios v"+ns.version+"] Transitional option '"+a+"'"+o+(n?". "+n:"")}return function(a,o,u){if(e===!1)throw new Error(i(o," has been removed in "+r));return s&&!ts[o]&&(ts[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(a,o,u):!0}};function To(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),s=n.length;s-- >0;){var i=n[s],a=e[i];if(a){var o=t[i],u=o===void 0||a(o,i,t);if(u!==!0)throw new TypeError("option "+i+" must be "+u);continue}if(r!==!0)throw Error("Unknown option "+i)}}is.exports={isOlderVersion:ss,assertOptions:To,validators:hr}});var ds=l(($c,fs)=>{"use strict";var cs=C(),Oo=nr(),os=xn(),us=Zn(),ge=dr(),ls=as(),$=ls.validators;function Z(t){this.defaults=t,this.interceptors={request:new os,response:new os}}Z.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=ge(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&ls.assertOptions(r,{silentJSONParsing:$.transitional($.boolean,"1.0.0"),forcedJSONParsing:$.transitional($.boolean,"1.0.0"),clarifyTimeoutError:$.transitional($.boolean,"1.0.0")},!1);var n=[],s=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(e)===!1||(s=s&&h.synchronous,n.unshift(h.fulfilled,h.rejected))});var i=[];this.interceptors.response.forEach(function(h){i.push(h.fulfilled,h.rejected)});var a;if(!s){var o=[us,void 0];for(Array.prototype.unshift.apply(o,n),o=o.concat(i),a=Promise.resolve(e);o.length;)a=a.then(o.shift(),o.shift());return a}for(var u=e;n.length;){var p=n.shift(),c=n.shift();try{u=p(u)}catch(f){c(f);break}}try{a=us(u)}catch(f){return Promise.reject(f)}for(;i.length;)a=a.then(i.shift(),i.shift());return a};Z.prototype.getUri=function(e){return e=ge(this.defaults,e),Oo(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};cs.forEach(["delete","get","head","options"],function(e){Z.prototype[e]=function(r,n){return this.request(ge(n||{},{method:e,url:r,data:(n||{}).data}))}});cs.forEach(["post","put","patch"],function(e){Z.prototype[e]=function(r,n,s){return this.request(ge(s||{},{method:e,url:r,data:n}))}});fs.exports=Z});var mr=l((zc,hs)=>{"use strict";function pr(t){this.message=t}pr.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};pr.prototype.__CANCEL__=!0;hs.exports=pr});var ms=l((Vc,ps)=>{"use strict";var Io=mr();function ve(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(s){e=s});var r=this;t(function(s){r.reason||(r.reason=new Io(s),e(r.reason))})}ve.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};ve.source=function(){var e,r=new ve(function(s){e=s});return{token:r,cancel:e}};ps.exports=ve});var vs=l((Gc,gs)=>{"use strict";gs.exports=function(e){return function(n){return e.apply(null,n)}}});var ws=l((Wc,ys)=>{"use strict";ys.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Es=l((Xc,gr)=>{"use strict";var Ss=C(),No=Ye(),ye=ds(),Uo=dr(),ko=me();function bs(t){var e=new ye(t),r=No(ye.prototype.request,e);return Ss.extend(r,ye.prototype,e),Ss.extend(r,e),r}var I=bs(ko);I.Axios=ye;I.create=function(e){return bs(Uo(I.defaults,e))};I.Cancel=mr();I.CancelToken=ms();I.isCancel=cr();I.all=function(e){return Promise.all(e)};I.spread=vs();I.isAxiosError=ws();gr.exports=I;gr.exports.default=I});var xs=l((Kc,As)=>{As.exports=Es()});var wr=l((il,Ps)=>{"use strict";Ps.exports=function(e,r){return function(){for(var s=new Array(arguments.length),i=0;i<s.length;i++)s[i]=arguments[i];return e.apply(r,s)}}});var P=l((al,Ts)=>{"use strict";var Fo=wr(),B=Object.prototype.toString;function Er(t){return B.call(t)==="[object Array]"}function Sr(t){return typeof t=="undefined"}function jo(t){return t!==null&&!Sr(t)&&t.constructor!==null&&!Sr(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function Do(t){return B.call(t)==="[object ArrayBuffer]"}function Lo(t){return typeof FormData!="undefined"&&t instanceof FormData}function Bo(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function _o(t){return typeof t=="string"}function Ho(t){return typeof t=="number"}function Rs(t){return t!==null&&typeof t=="object"}function we(t){if(B.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function Mo(t){return B.call(t)==="[object Date]"}function Jo(t){return B.call(t)==="[object File]"}function $o(t){return B.call(t)==="[object Blob]"}function qs(t){return B.call(t)==="[object Function]"}function zo(t){return Rs(t)&&qs(t.pipe)}function Vo(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function Go(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Wo(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Ar(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Er(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var s in t)Object.prototype.hasOwnProperty.call(t,s)&&e.call(null,t[s],s,t)}function br(){var t={};function e(s,i){we(t[i])&&we(s)?t[i]=br(t[i],s):we(s)?t[i]=br({},s):Er(s)?t[i]=s.slice():t[i]=s}for(var r=0,n=arguments.length;r<n;r++)Ar(arguments[r],e);return t}function Xo(t,e,r){return Ar(e,function(s,i){r&&typeof s=="function"?t[i]=Fo(s,r):t[i]=s}),t}function Ko(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Ts.exports={isArray:Er,isArrayBuffer:Do,isBuffer:jo,isFormData:Lo,isArrayBufferView:Bo,isString:_o,isNumber:Ho,isObject:Rs,isPlainObject:we,isUndefined:Sr,isDate:Mo,isFile:Jo,isBlob:$o,isFunction:qs,isStream:zo,isURLSearchParams:Vo,isStandardBrowserEnv:Wo,forEach:Ar,merge:br,extend:Xo,trim:Go,stripBOM:Ko}});var xr=l((ol,Is)=>{"use strict";var z=P();function Os(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Is.exports=function(e,r,n){if(!r)return e;var s;if(n)s=n(r);else if(z.isURLSearchParams(r))s=r.toString();else{var i=[];z.forEach(r,function(u,p){u===null||typeof u=="undefined"||(z.isArray(u)?p=p+"[]":u=[u],z.forEach(u,function(f){z.isDate(f)?f=f.toISOString():z.isObject(f)&&(f=JSON.stringify(f)),i.push(Os(p)+"="+Os(f))}))}),s=i.join("&")}if(s){var a=e.indexOf("#");a!==-1&&(e=e.slice(0,a)),e+=(e.indexOf("?")===-1?"?":"&")+s}return e}});var Us=l((ul,Ns)=>{"use strict";var Qo=P();function Se(){this.handlers=[]}Se.prototype.use=function(e,r,n){return this.handlers.push({fulfilled:e,rejected:r,synchronous:n?n.synchronous:!1,runWhen:n?n.runWhen:null}),this.handlers.length-1};Se.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};Se.prototype.forEach=function(e){Qo.forEach(this.handlers,function(n){n!==null&&e(n)})};Ns.exports=Se});var Fs=l((cl,ks)=>{"use strict";var Yo=P();ks.exports=function(e,r){Yo.forEach(e,function(s,i){i!==r&&i.toUpperCase()===r.toUpperCase()&&(e[r]=s,delete e[i])})}});var Cr=l((ll,js)=>{"use strict";js.exports=function(e,r,n,s,i){return e.config=r,n&&(e.code=n),e.request=s,e.response=i,e.isAxiosError=!0,e.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:this.config,code:this.code,status:this.response&&this.response.status?this.response.status:null}},e}});var Pr=l((fl,Ds)=>{"use strict";var Zo=Cr();Ds.exports=function(e,r,n,s,i){var a=new Error(e);return Zo(a,r,n,s,i)}});var Bs=l((dl,Ls)=>{"use strict";var eu=Pr();Ls.exports=function(e,r,n){var s=n.config.validateStatus;!n.status||!s||s(n.status)?e(n):r(eu("Request failed with status code "+n.status,n.config,null,n.request,n))}});var Hs=l((hl,_s)=>{"use strict";var be=P();_s.exports=be.isStandardBrowserEnv()?function(){return{write:function(r,n,s,i,a,o){var u=[];u.push(r+"="+encodeURIComponent(n)),be.isNumber(s)&&u.push("expires="+new Date(s).toGMTString()),be.isString(i)&&u.push("path="+i),be.isString(a)&&u.push("domain="+a),o===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(r){var n=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return n?decodeURIComponent(n[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()});var Js=l((pl,Ms)=>{"use strict";Ms.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var zs=l((ml,$s)=>{"use strict";$s.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var Gs=l((gl,Vs)=>{"use strict";var ru=Js(),tu=zs();Vs.exports=function(e,r){return e&&!ru(r)?tu(e,r):r}});var Xs=l((vl,Ws)=>{"use strict";var Rr=P(),nu=["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"];Ws.exports=function(e){var r={},n,s,i;return e&&Rr.forEach(e.split(`
4
- `),function(o){if(i=o.indexOf(":"),n=Rr.trim(o.substr(0,i)).toLowerCase(),s=Rr.trim(o.substr(i+1)),n){if(r[n]&&nu.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([s]):r[n]=r[n]?r[n]+", "+s:s}}),r}});var Ys=l((yl,Qs)=>{"use strict";var Ks=P();Qs.exports=Ks.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function s(i){var a=i;return e&&(r.setAttribute("href",a),a=r.href),r.setAttribute("href",a),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(a){var o=Ks.isString(a)?s(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}()});var ee=l((wl,Zs)=>{"use strict";function qr(t){this.message=t}qr.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};qr.prototype.__CANCEL__=!0;Zs.exports=qr});var Or=l((Sl,ei)=>{"use strict";var Ee=P(),su=Bs(),iu=Hs(),au=xr(),ou=Gs(),uu=Xs(),cu=Ys(),Tr=Pr(),lu=re(),fu=ee();ei.exports=function(e){return new Promise(function(n,s){var i=e.data,a=e.headers,o=e.responseType,u;function p(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}Ee.isFormData(i)&&delete a["Content-Type"];var c=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.Authorization="Basic "+btoa(f+":"+h)}var d=ou(e.baseURL,e.url);c.open(e.method.toUpperCase(),au(d,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function R(){if(!!c){var m="getAllResponseHeaders"in c?uu(c.getAllResponseHeaders()):null,q=!o||o==="text"||o==="json"?c.responseText:c.response,b={data:q,status:c.status,statusText:c.statusText,headers:m,config:e,request:c};su(function(D){n(D),p()},function(D){s(D),p()},b),c=null}}if("onloadend"in c?c.onloadend=R:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(R)},c.onabort=function(){!c||(s(Tr("Request aborted",e,"ECONNABORTED",c)),c=null)},c.onerror=function(){s(Tr("Network Error",e,null,c)),c=null},c.ontimeout=function(){var q=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",b=e.transitional||lu.transitional;e.timeoutErrorMessage&&(q=e.timeoutErrorMessage),s(Tr(q,e,b.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",c)),c=null},Ee.isStandardBrowserEnv()){var A=(e.withCredentials||cu(d))&&e.xsrfCookieName?iu.read(e.xsrfCookieName):void 0;A&&(a[e.xsrfHeaderName]=A)}"setRequestHeader"in c&&Ee.forEach(a,function(q,b){typeof i=="undefined"&&b.toLowerCase()==="content-type"?delete a[b]:c.setRequestHeader(b,q)}),Ee.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),o&&o!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(u=function(m){!c||(s(!m||m&&m.type?new fu("canceled"):m),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u))),i||(i=null),c.send(i)})}});var re=l((bl,ni)=>{"use strict";var w=P(),ri=Fs(),du=Cr(),hu={"Content-Type":"application/x-www-form-urlencoded"};function ti(t,e){!w.isUndefined(t)&&w.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function pu(){var t;return typeof XMLHttpRequest!="undefined"?t=Or():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Or()),t}function mu(t,e,r){if(w.isString(t))try{return(e||JSON.parse)(t),w.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Ae={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:pu(),transformRequest:[function(e,r){return ri(r,"Accept"),ri(r,"Content-Type"),w.isFormData(e)||w.isArrayBuffer(e)||w.isBuffer(e)||w.isStream(e)||w.isFile(e)||w.isBlob(e)?e:w.isArrayBufferView(e)?e.buffer:w.isURLSearchParams(e)?(ti(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):w.isObject(e)||r&&r["Content-Type"]==="application/json"?(ti(r,"application/json"),mu(e)):e}],transformResponse:[function(e){var r=this.transitional||Ae.transitional,n=r&&r.silentJSONParsing,s=r&&r.forcedJSONParsing,i=!n&&this.responseType==="json";if(i||s&&w.isString(e)&&e.length)try{return JSON.parse(e)}catch(a){if(i)throw a.name==="SyntaxError"?du(a,this,"E_JSON_PARSE"):a}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};w.forEach(["delete","get","head"],function(e){Ae.headers[e]={}});w.forEach(["post","put","patch"],function(e){Ae.headers[e]=w.merge(hu)});ni.exports=Ae});var ii=l((El,si)=>{"use strict";var gu=P(),vu=re();si.exports=function(e,r,n){var s=this||vu;return gu.forEach(n,function(a){e=a.call(s,e,r)}),e}});var Ir=l((Al,ai)=>{"use strict";ai.exports=function(e){return!!(e&&e.__CANCEL__)}});var ci=l((xl,ui)=>{"use strict";var oi=P(),Nr=ii(),yu=Ir(),wu=re(),Su=ee();function Ur(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Su("canceled")}ui.exports=function(e){Ur(e),e.headers=e.headers||{},e.data=Nr.call(e,e.data,e.headers,e.transformRequest),e.headers=oi.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),oi.forEach(["delete","get","head","post","put","patch","common"],function(s){delete e.headers[s]});var r=e.adapter||wu.adapter;return r(e).then(function(s){return Ur(e),s.data=Nr.call(e,s.data,s.headers,e.transformResponse),s},function(s){return yu(s)||(Ur(e),s&&s.response&&(s.response.data=Nr.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})}});var kr=l((Cl,li)=>{"use strict";var O=P();li.exports=function(e,r){r=r||{};var n={};function s(c,f){return O.isPlainObject(c)&&O.isPlainObject(f)?O.merge(c,f):O.isPlainObject(f)?O.merge({},f):O.isArray(f)?f.slice():f}function i(c){if(O.isUndefined(r[c])){if(!O.isUndefined(e[c]))return s(void 0,e[c])}else return s(e[c],r[c])}function a(c){if(!O.isUndefined(r[c]))return s(void 0,r[c])}function o(c){if(O.isUndefined(r[c])){if(!O.isUndefined(e[c]))return s(void 0,e[c])}else return s(void 0,r[c])}function u(c){if(c in r)return s(e[c],r[c]);if(c in e)return s(void 0,e[c])}var p={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:u};return O.forEach(Object.keys(e).concat(Object.keys(r)),function(f){var h=p[f]||i,d=h(f);O.isUndefined(d)&&h!==u||(n[f]=d)}),n}});var Fr=l((Pl,fi)=>{fi.exports={version:"0.23.0"}});var pi=l((Rl,hi)=>{"use strict";var bu=Fr().version,jr={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){jr[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var di={};jr.transitional=function(e,r,n){function s(i,a){return"[Axios v"+bu+"] Transitional option '"+i+"'"+a+(n?". "+n:"")}return function(i,a,o){if(e===!1)throw new Error(s(a," has been removed"+(r?" in "+r:"")));return r&&!di[a]&&(di[a]=!0,console.warn(s(a," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,a,o):!0}};function Eu(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),s=n.length;s-- >0;){var i=n[s],a=e[i];if(a){var o=t[i],u=o===void 0||a(o,i,t);if(u!==!0)throw new TypeError("option "+i+" must be "+u);continue}if(r!==!0)throw Error("Unknown option "+i)}}hi.exports={assertOptions:Eu,validators:jr}});var Si=l((ql,wi)=>{"use strict";var vi=P(),Au=xr(),mi=Us(),gi=ci(),xe=kr(),yi=pi(),V=yi.validators;function te(t){this.defaults=t,this.interceptors={request:new mi,response:new mi}}te.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=xe(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&yi.assertOptions(r,{silentJSONParsing:V.transitional(V.boolean),forcedJSONParsing:V.transitional(V.boolean),clarifyTimeoutError:V.transitional(V.boolean)},!1);var n=[],s=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(e)===!1||(s=s&&h.synchronous,n.unshift(h.fulfilled,h.rejected))});var i=[];this.interceptors.response.forEach(function(h){i.push(h.fulfilled,h.rejected)});var a;if(!s){var o=[gi,void 0];for(Array.prototype.unshift.apply(o,n),o=o.concat(i),a=Promise.resolve(e);o.length;)a=a.then(o.shift(),o.shift());return a}for(var u=e;n.length;){var p=n.shift(),c=n.shift();try{u=p(u)}catch(f){c(f);break}}try{a=gi(u)}catch(f){return Promise.reject(f)}for(;i.length;)a=a.then(i.shift(),i.shift());return a};te.prototype.getUri=function(e){return e=xe(this.defaults,e),Au(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};vi.forEach(["delete","get","head","options"],function(e){te.prototype[e]=function(r,n){return this.request(xe(n||{},{method:e,url:r,data:(n||{}).data}))}});vi.forEach(["post","put","patch"],function(e){te.prototype[e]=function(r,n,s){return this.request(xe(s||{},{method:e,url:r,data:n}))}});wi.exports=te});var Ei=l((Tl,bi)=>{"use strict";var xu=ee();function G(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(s){e=s});var r=this;this.promise.then(function(n){if(!!r._listeners){var s,i=r._listeners.length;for(s=0;s<i;s++)r._listeners[s](n);r._listeners=null}}),this.promise.then=function(n){var s,i=new Promise(function(a){r.subscribe(a),s=a}).then(n);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s){r.reason||(r.reason=new xu(s),e(r.reason))})}G.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};G.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};G.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};G.source=function(){var e,r=new G(function(s){e=s});return{token:r,cancel:e}};bi.exports=G});var xi=l((Ol,Ai)=>{"use strict";Ai.exports=function(e){return function(n){return e.apply(null,n)}}});var Pi=l((Il,Ci)=>{"use strict";Ci.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Ti=l((Nl,Dr)=>{"use strict";var Ri=P(),Cu=wr(),Ce=Si(),Pu=kr(),Ru=re();function qi(t){var e=new Ce(t),r=Cu(Ce.prototype.request,e);return Ri.extend(r,Ce.prototype,e),Ri.extend(r,e),r.create=function(s){return qi(Pu(t,s))},r}var U=qi(Ru);U.Axios=Ce;U.Cancel=ee();U.CancelToken=Ei();U.isCancel=Ir();U.VERSION=Fr().version;U.all=function(e){return Promise.all(e)};U.spread=xi();U.isAxiosError=Pi();Dr.exports=U;Dr.exports.default=U});var Lr=l((Ul,Oi)=>{Oi.exports=Ti()});var Xt=W(Wt()),Ua=500,Ge=class{constructor({url:e=""}){this.url=e,this.httpClient=Xt.default.create({baseURL:this.url}),this.httpClient.interceptors.response.use(r=>r,r=>{var n,s,i,a,o,u;return Promise.reject({message:(a=(i=(s=(n=r.response)==null?void 0:n.data)==null?void 0:s.message)!=null?i:r.message)!=null?a:JSON.stringify(r),status:(u=(o=r.response)==null?void 0:o.status)!=null?u:Ua})})}async signUpEmailPassword(e){try{return{data:(await this.httpClient.post("/signup/email-password",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInEmailPassword(e){try{return{data:(await this.httpClient.post("/signin/email-password",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInPasswordlessEmail(e){try{return{data:(await this.httpClient.post("/signin/passwordless/email",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInPasswordlessSms(e){try{return{data:(await this.httpClient.post("/signin/passwordless/sms",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInPasswordlessSmsOtp(e){try{return{data:(await this.httpClient.post("/signin/passwordless/sms/otp",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signOut(e){try{return await this.httpClient.post("/signout",e),{error:null}}catch(r){return{error:r}}}async refreshToken(e){try{let r=await this.httpClient.post("/token",e);return{error:null,session:r.data}}catch(r){return{error:r,session:null}}}async resetPassword(e){try{return await this.httpClient.post("/user/password/reset",e),{error:null}}catch(r){return{error:r}}}async changePassword(e){try{return await this.httpClient.post("/user/password",e,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(r){return{error:r}}}async sendVerificationEmail(e){try{return await this.httpClient.post("/user/email/send-verification-email",e),{error:null}}catch(r){return{error:r}}}async changeEmail(e){try{return await this.httpClient.post("/user/email/change",e,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(r){return{error:r}}}async deanonymize(e){try{return await this.httpClient.post("/user/deanonymize",e),{error:null}}catch(r){return{error:r}}}async verifyEmail(e){try{return{data:(await this.httpClient.post("/user/email/verify",e)).data,error:null}}catch(r){return{data:null,error:r}}}setAccessToken(e){this.accessToken=e}generateAuthHeaders(){return this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:null}};var gn=W(mn());var F="nhostRefreshToken";var Y=()=>typeof window!="undefined",Ke=class{constructor(){this.memory={}}setItem(e,r){this.memory[e]=r}getItem(e){return this.memory[e]}removeItem(e){delete this.memory[e]}};var Qe=class{constructor({url:e,autoRefreshToken:r=!0,autoLogin:n=!0,refreshIntervalTime:s,clientStorage:i,clientStorageType:a="web"}){this.refreshIntervalTime=s,i?this.clientStorage=i:this.clientStorage=Y()?localStorage:new Ke,this.clientStorageType=a,this.onTokenChangedFunctions=[],this.onAuthChangedFunctions=[],this.refreshInterval,this.refreshSleepCheckInterval=0,this.refreshIntervalSleepCheckLastSample=Date.now(),this.sampleRate=2e3,this.url=e,this.autoRefreshToken=r,this.initAuthLoading=!0,this.session=null,this.api=new Ge({url:this.url});let o=null,u=!1;if(n&&Y()&&window.location){let p=gn.default.parse(window.location.toString().split("#")[1]);if("refreshToken"in p&&(o=p.refreshToken),"otp"in p&&"email"in p){let{otp:c,email:f}=p;this.signIn({otp:c,email:f}),u=!0}}!u&&n?this._autoLogin(o):o&&this._setItem(F,o)}async signUp(e){let{email:r,password:n}=e;if(r&&n){let{data:s,error:i}=await this.api.signUpEmailPassword(e);if(i)return{session:null,error:i};if(!s)return{session:null,error:{message:"An error occurred on sign up.",status:500}};let{session:a}=s;return a&&await this._setSession(a),{session:a,error:null}}return{session:null,error:{message:"Incorrect parameters",status:500}}}async signIn(e){if("provider"in e){let{provider:r,options:n}=e,s=`${this.url}/signin/provider/${r}`;return n&&(s+="?",n.locale&&(s+=`locale=${encodeURIComponent(n.locale)}&`),n.allowedRoles&&(s+=`allowedRoles=${encodeURIComponent(n.allowedRoles.join(","))}&`),n.defaultRole&&(s+=`defaultRole=${encodeURIComponent(n.defaultRole)}&`),n.displayName&&(s+=`displayName=${encodeURIComponent(n.displayName)}&`),n.redirectTo&&(s+=`redirectTo=${encodeURIComponent(n.redirectTo)}&`),n.metadata&&(s+=`metadata=${encodeURIComponent(JSON.stringify(n.metadata))}&`),s=s.slice(0,-1)),Y()&&(window.location.href=s),{providerUrl:s,provider:r,session:null,mfa:null,error:null}}if("email"in e&&"password"in e){let{data:r,error:n}=await this.api.signInEmailPassword(e);if(n)return{session:null,mfa:null,error:n};if(!r)return{session:null,mfa:null,error:{message:"Incorrect Data",status:500}};let{session:s,mfa:i}=r;return s&&await this._setSession(s),{session:s,mfa:i,error:null}}if("email"in e&&!("otp"in e)){let{error:r}=await this.api.signInPasswordlessEmail(e);return r?{session:null,mfa:null,error:r}:{session:null,mfa:null,error:null}}if("phoneNumber"in e&&!("otp"in e)){let{error:r}=await this.api.signInPasswordlessSms(e);return r?{session:null,mfa:null,error:r}:{session:null,mfa:null,error:null}}if("otp"in e){let{data:r,error:n}=await this.api.signInPasswordlessSmsOtp(e);if(n)return{session:null,mfa:null,error:n};if(!r)return{session:null,mfa:null,error:{message:"Incorrect data",status:500}};let{session:s,mfa:i}=r;return s&&await this._setSession(s),{session:s,mfa:i,error:null}}return{session:null,mfa:null,error:{message:"Incorrect parameters",status:500}}}async signOut(e){let r=await this._getItem(F);this._clearSession();let{error:n}=await this.api.signOut({refreshToken:r,all:e==null?void 0:e.all});return{error:n}}async verifyEmail(e){return await this.api.verifyEmail(e)}async resetPassword(e){let{error:r}=await this.api.resetPassword(e);return{error:r}}async changePassword(e){let{error:r}=await this.api.changePassword(e);return{error:r}}async sendVerificationEmail(e){let{error:r}=await this.api.sendVerificationEmail(e);return{error:r}}async changeEmail(e){let{error:r}=await this.api.changeEmail(e);return{error:r}}async deanonymize(e){let{error:r}=await this.api.deanonymize(e);return{error:r}}onTokenChanged(e){this.onTokenChangedFunctions.push(e);let r=this.onTokenChangedFunctions.length-1;return()=>{try{this.onTokenChangedFunctions[r]=()=>{}}catch{console.warn("Unable to unsubscribe onTokenChanged function. Maybe the functions is already unsubscribed?")}}}onAuthStateChanged(e){this.onAuthChangedFunctions.push(e);let r=this.onAuthChangedFunctions.length-1;return()=>{try{this.onAuthChangedFunctions[r]=()=>{}}catch{console.warn("Unable to unsubscribe onAuthStateChanged function. Maybe you already did?")}}}isAuthenticated(){return this.session!==null}async isAuthenticatedAsync(){return new Promise(e=>{if(!this.initAuthLoading)e(this.isAuthenticated());else{let r=this.onAuthStateChanged((n,s)=>{e(n==="SIGNED_IN"),r()})}})}getAuthenticationStatus(){return this.initAuthLoading?{isAuthenticated:!1,isLoading:!0}:{isAuthenticated:this.session!==null,isLoading:!1}}getJWTToken(){return this.getAccessToken()}getAccessToken(){if(!!this.session)return this.session.accessToken}async refreshSession(e){let r=e||await this._getItem(F);return r||console.warn("no refresh token found. No way of refreshing session"),this._refreshTokens(r)}getSession(){return this.session}getUser(){return this.session?this.session.user:null}async _setItem(e,r){if(typeof r!="string"){console.error('value is not of type "string"');return}switch(this.clientStorageType){case"web":if(typeof this.clientStorage.setItem!="function"){console.error("this.clientStorage.setItem is not a function");break}this.clientStorage.setItem(e,r);break;case"custom":case"react-native":if(typeof this.clientStorage.setItem!="function"){console.error("this.clientStorage.setItem is not a function");break}await this.clientStorage.setItem(e,r);break;case"capacitor":if(typeof this.clientStorage.set!="function"){console.error("this.clientStorage.set is not a function");break}await this.clientStorage.set({key:e,value:r});break;case"expo-secure-storage":if(typeof this.clientStorage.setItemAsync!="function"){console.error("this.clientStorage.setItemAsync is not a function");break}this.clientStorage.setItemAsync(e,r);break;default:break}}async _getItem(e){switch(this.clientStorageType){case"web":if(typeof this.clientStorage.getItem!="function"){console.error("this.clientStorage.getItem is not a function");break}return this.clientStorage.getItem(e);case"custom":case"react-native":if(typeof this.clientStorage.getItem!="function"){console.error("this.clientStorage.getItem is not a function");break}return await this.clientStorage.getItem(e);case"capacitor":if(typeof this.clientStorage.get!="function"){console.error("this.clientStorage.get is not a function");break}return(await this.clientStorage.get({key:e})).value;case"expo-secure-storage":if(typeof this.clientStorage.getItemAsync!="function"){console.error("this.clientStorage.getItemAsync is not a function");break}return this.clientStorage.getItemAsync(e);default:return""}return""}async _removeItem(e){switch(this.clientStorageType){case"web":if(typeof this.clientStorage.removeItem!="function"){console.error("this.clientStorage.removeItem is not a function");break}return void this.clientStorage.removeItem(e);case"custom":case"react-native":if(typeof this.clientStorage.removeItem!="function"){console.error("this.clientStorage.removeItem is not a function");break}return void this.clientStorage.removeItem(e);case"capacitor":if(typeof this.clientStorage.remove!="function"){console.error("this.clientStorage.remove is not a function");break}await this.clientStorage.remove({key:e});break;case"expo-secure-storage":if(typeof this.clientStorage.deleteItemAsync!="function"){console.error("this.clientStorage.deleteItemAsync is not a function");break}this.clientStorage.deleteItemAsync(e);break;default:break}}_autoLogin(e){!Y()||this._refreshTokens(e)}async _refreshTokens(e){let r=e||await this._getItem(F);if(!r){setTimeout(async()=>{await this._clearSession()},0);return}try{let{session:n,error:s}=await this.api.refreshToken({refreshToken:r});if(s&&s.status===401){await this._clearSession();return}if(!n)throw new Error("Invalid session data");await this._setSession(n),this.tokenChanged()}catch{}}tokenChanged(){for(let e of this.onTokenChangedFunctions)e(this.session)}authStateChanged({event:e,session:r}){e==="SIGNED_IN"&&r?this.api.setAccessToken(r.accessToken):this.api.setAccessToken(void 0);for(let n of this.onAuthChangedFunctions)n(e,r)}async _clearSession(){let{isLoading:e,isAuthenticated:r}=this.getAuthenticationStatus();this.session=null,this.initAuthLoading=!1,await this._removeItem(F),(e||r)&&(clearInterval(this.refreshInterval),clearInterval(this.refreshSleepCheckInterval),this.authStateChanged({event:"SIGNED_OUT",session:null}))}async _setSession(e){let{isAuthenticated:r}=this.getAuthenticationStatus();if(this.session=e,await this._setItem(F,e.refreshToken),this.autoRefreshToken&&!r){let n=e.accessTokenExpiresIn,s=this.refreshIntervalTime?this.refreshIntervalTime:Math.max(1,n-1);this.refreshInterval=setInterval(async()=>{let i=await this._getItem(F);await this._refreshTokens(i)},s*1e3),this.refreshIntervalSleepCheckLastSample=Date.now(),this.refreshSleepCheckInterval=setInterval(async()=>{if(Date.now()-this.refreshIntervalSleepCheckLastSample>=this.sampleRate*2){let i=await this._getItem(F);await this._refreshTokens(i)}this.refreshIntervalSleepCheckLastSample=Date.now()},this.sampleRate),this.authStateChanged({event:"SIGNED_IN",session:this.session})}this.initAuthLoading=!1}};var Cs=W(xs()),vr=class{constructor({url:e}){this.url=e,this.httpClient=Cs.default.create({baseURL:this.url})}async upload(e){try{return{fileMetadata:(await this.httpClient.post("/files",e.file,{headers:{...this.generateUploadHeaders(e),...this.generateAuthHeaders()}})).data,error:null}}catch(r){return{fileMetadata:null,error:r}}}async getPresignedUrl(e){try{let{fileId:r}=e;return{presignedUrl:(await this.httpClient.get(`/files/${r}/presignedurl`,{headers:{...this.generateAuthHeaders()}})).data,error:null}}catch(r){return{presignedUrl:null,error:r}}}async delete(e){try{let{fileId:r}=e;return await this.httpClient.delete(`/files/${r}`,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(r){return{error:r}}}setAccessToken(e){this.accessToken=e}generateUploadHeaders(e){let{bucketId:r,name:n,id:s}=e,i={};return r&&(i["x-nhost-bucket-id"]=r),s&&(i["x-nhost-file-id"]=s),n&&(i["x-nhost-file-name"]=n),i}generateAuthHeaders(){return this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:null}};var yr=class{constructor({url:e}){this.url=e,this.api=new vr({url:e})}async upload(e){let r=new FormData;r.append("file",e.file);let{fileMetadata:n,error:s}=await this.api.upload({...e,file:r});return s?{fileMetadata:null,error:s}:n?{fileMetadata:n,error:null}:{fileMetadata:null,error:new Error("Invalid file returned")}}getUrl(e){return this.getPublicUrl(e)}getPublicUrl(e){let{fileId:r}=e;return`${this.url}/files/${r}`}async getPresignedUrl(e){let{presignedUrl:r,error:n}=await this.api.getPresignedUrl(e);return n?{presignedUrl:null,error:n}:r?{presignedUrl:r,error:null}:{presignedUrl:null,error:new Error("Invalid file id")}}async delete(e){let{error:r}=await this.api.delete(e);return r?{error:r}:{error:null}}setAccessToken(e){this.api.setAccessToken(e)}};var Ii=W(Lr()),Br=class{constructor(e){let{url:r}=e;this.accessToken=null,this.instance=Ii.default.create({baseURL:r})}async call(e,r,n){let s={...this.generateAccessTokenHeaders(),...n==null?void 0:n.headers},i;try{i=await this.instance.post(e,r,{...n,headers:s})}catch(a){if(a instanceof Error)return{res:null,error:a}}return i?{res:i,error:null}:{res:null,error:new Error("Unable to make post request to funtion")}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var Ni=W(Lr()),_r=class{constructor(e){let{url:r}=e;this.url=r,this.accessToken=null,this.instance=Ni.default.create({baseURL:r})}async request(e,r,n){let s={...n==null?void 0:n.headers,...this.generateAccessTokenHeaders()},i="",a;try{a=(await this.instance.post("",{operationName:i||void 0,query:e,variables:r},{...n,headers:s})).data}catch(o){return o instanceof Error?{data:null,error:o}:(console.error(o),{data:null,error:new Error("Unable to get do GraphQL request")})}return typeof a!="object"||Array.isArray(a)||a===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:(a=a,a.errors?{data:null,error:a.errors}:{data:a.data,error:null})}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var Hr=class{constructor(e){if(!e.backendUrl)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");let{backendUrl:r,refreshIntervalTime:n,clientStorage:s,clientStorageType:i,autoRefreshToken:a,autoLogin:o}=e;this.auth=new Qe({url:`${r}/v1/auth`,refreshIntervalTime:n,clientStorage:s,clientStorageType:i,autoRefreshToken:a,autoLogin:o}),this.storage=new yr({url:`${r}/v1/storage`}),this.functions=new Br({url:`${r}/v1/functions`}),this.graphql=new _r({url:`${r}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),this.auth.onAuthStateChanged((u,p)=>{this.storage.setAccessToken(p==null?void 0:p.accessToken),this.functions.setAccessToken(p==null?void 0:p.accessToken),this.graphql.setAccessToken(p==null?void 0:p.accessToken)}),this.auth.onTokenChanged(u=>{this.storage.setAccessToken(u==null?void 0:u.accessToken),this.functions.setAccessToken(u==null?void 0:u.accessToken),this.graphql.setAccessToken(u==null?void 0:u.accessToken)})}};var Ql=t=>new Hr(t);export{Hr as NhostClient,Ql as createClient};
4
+ `),function(o){if(i=o.indexOf(":"),n=Rr.trim(o.substr(0,i)).toLowerCase(),s=Rr.trim(o.substr(i+1)),n){if(r[n]&&nu.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([s]):r[n]=r[n]?r[n]+", "+s:s}}),r}});var Ys=l((yl,Qs)=>{"use strict";var Ks=P();Qs.exports=Ks.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function s(i){var a=i;return e&&(r.setAttribute("href",a),a=r.href),r.setAttribute("href",a),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return n=s(window.location.href),function(a){var o=Ks.isString(a)?s(a):a;return o.protocol===n.protocol&&o.host===n.host}}():function(){return function(){return!0}}()});var ee=l((wl,Zs)=>{"use strict";function qr(t){this.message=t}qr.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};qr.prototype.__CANCEL__=!0;Zs.exports=qr});var Or=l((Sl,ei)=>{"use strict";var Ee=P(),su=Bs(),iu=Hs(),au=xr(),ou=Gs(),uu=Xs(),cu=Ys(),Tr=Pr(),lu=re(),fu=ee();ei.exports=function(e){return new Promise(function(n,s){var i=e.data,a=e.headers,o=e.responseType,u;function p(){e.cancelToken&&e.cancelToken.unsubscribe(u),e.signal&&e.signal.removeEventListener("abort",u)}Ee.isFormData(i)&&delete a["Content-Type"];var c=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",h=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";a.Authorization="Basic "+btoa(f+":"+h)}var d=ou(e.baseURL,e.url);c.open(e.method.toUpperCase(),au(d,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function R(){if(!!c){var m="getAllResponseHeaders"in c?uu(c.getAllResponseHeaders()):null,q=!o||o==="text"||o==="json"?c.responseText:c.response,b={data:q,status:c.status,statusText:c.statusText,headers:m,config:e,request:c};su(function(D){n(D),p()},function(D){s(D),p()},b),c=null}}if("onloadend"in c?c.onloadend=R:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(R)},c.onabort=function(){!c||(s(Tr("Request aborted",e,"ECONNABORTED",c)),c=null)},c.onerror=function(){s(Tr("Network Error",e,null,c)),c=null},c.ontimeout=function(){var q=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",b=e.transitional||lu.transitional;e.timeoutErrorMessage&&(q=e.timeoutErrorMessage),s(Tr(q,e,b.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",c)),c=null},Ee.isStandardBrowserEnv()){var A=(e.withCredentials||cu(d))&&e.xsrfCookieName?iu.read(e.xsrfCookieName):void 0;A&&(a[e.xsrfHeaderName]=A)}"setRequestHeader"in c&&Ee.forEach(a,function(q,b){typeof i=="undefined"&&b.toLowerCase()==="content-type"?delete a[b]:c.setRequestHeader(b,q)}),Ee.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),o&&o!=="json"&&(c.responseType=e.responseType),typeof e.onDownloadProgress=="function"&&c.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",e.onUploadProgress),(e.cancelToken||e.signal)&&(u=function(m){!c||(s(!m||m&&m.type?new fu("canceled"):m),c.abort(),c=null)},e.cancelToken&&e.cancelToken.subscribe(u),e.signal&&(e.signal.aborted?u():e.signal.addEventListener("abort",u))),i||(i=null),c.send(i)})}});var re=l((bl,ni)=>{"use strict";var w=P(),ri=Fs(),du=Cr(),hu={"Content-Type":"application/x-www-form-urlencoded"};function ti(t,e){!w.isUndefined(t)&&w.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function pu(){var t;return typeof XMLHttpRequest!="undefined"?t=Or():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Or()),t}function mu(t,e,r){if(w.isString(t))try{return(e||JSON.parse)(t),w.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Ae={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:pu(),transformRequest:[function(e,r){return ri(r,"Accept"),ri(r,"Content-Type"),w.isFormData(e)||w.isArrayBuffer(e)||w.isBuffer(e)||w.isStream(e)||w.isFile(e)||w.isBlob(e)?e:w.isArrayBufferView(e)?e.buffer:w.isURLSearchParams(e)?(ti(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):w.isObject(e)||r&&r["Content-Type"]==="application/json"?(ti(r,"application/json"),mu(e)):e}],transformResponse:[function(e){var r=this.transitional||Ae.transitional,n=r&&r.silentJSONParsing,s=r&&r.forcedJSONParsing,i=!n&&this.responseType==="json";if(i||s&&w.isString(e)&&e.length)try{return JSON.parse(e)}catch(a){if(i)throw a.name==="SyntaxError"?du(a,this,"E_JSON_PARSE"):a}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};w.forEach(["delete","get","head"],function(e){Ae.headers[e]={}});w.forEach(["post","put","patch"],function(e){Ae.headers[e]=w.merge(hu)});ni.exports=Ae});var ii=l((El,si)=>{"use strict";var gu=P(),vu=re();si.exports=function(e,r,n){var s=this||vu;return gu.forEach(n,function(a){e=a.call(s,e,r)}),e}});var Ir=l((Al,ai)=>{"use strict";ai.exports=function(e){return!!(e&&e.__CANCEL__)}});var ci=l((xl,ui)=>{"use strict";var oi=P(),Nr=ii(),yu=Ir(),wu=re(),Su=ee();function Ur(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Su("canceled")}ui.exports=function(e){Ur(e),e.headers=e.headers||{},e.data=Nr.call(e,e.data,e.headers,e.transformRequest),e.headers=oi.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),oi.forEach(["delete","get","head","post","put","patch","common"],function(s){delete e.headers[s]});var r=e.adapter||wu.adapter;return r(e).then(function(s){return Ur(e),s.data=Nr.call(e,s.data,s.headers,e.transformResponse),s},function(s){return yu(s)||(Ur(e),s&&s.response&&(s.response.data=Nr.call(e,s.response.data,s.response.headers,e.transformResponse))),Promise.reject(s)})}});var kr=l((Cl,li)=>{"use strict";var O=P();li.exports=function(e,r){r=r||{};var n={};function s(c,f){return O.isPlainObject(c)&&O.isPlainObject(f)?O.merge(c,f):O.isPlainObject(f)?O.merge({},f):O.isArray(f)?f.slice():f}function i(c){if(O.isUndefined(r[c])){if(!O.isUndefined(e[c]))return s(void 0,e[c])}else return s(e[c],r[c])}function a(c){if(!O.isUndefined(r[c]))return s(void 0,r[c])}function o(c){if(O.isUndefined(r[c])){if(!O.isUndefined(e[c]))return s(void 0,e[c])}else return s(void 0,r[c])}function u(c){if(c in r)return s(e[c],r[c]);if(c in e)return s(void 0,e[c])}var p={url:a,method:a,data:a,baseURL:o,transformRequest:o,transformResponse:o,paramsSerializer:o,timeout:o,timeoutMessage:o,withCredentials:o,adapter:o,responseType:o,xsrfCookieName:o,xsrfHeaderName:o,onUploadProgress:o,onDownloadProgress:o,decompress:o,maxContentLength:o,maxBodyLength:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:u};return O.forEach(Object.keys(e).concat(Object.keys(r)),function(f){var h=p[f]||i,d=h(f);O.isUndefined(d)&&h!==u||(n[f]=d)}),n}});var Fr=l((Pl,fi)=>{fi.exports={version:"0.23.0"}});var pi=l((Rl,hi)=>{"use strict";var bu=Fr().version,jr={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){jr[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var di={};jr.transitional=function(e,r,n){function s(i,a){return"[Axios v"+bu+"] Transitional option '"+i+"'"+a+(n?". "+n:"")}return function(i,a,o){if(e===!1)throw new Error(s(a," has been removed"+(r?" in "+r:"")));return r&&!di[a]&&(di[a]=!0,console.warn(s(a," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(i,a,o):!0}};function Eu(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),s=n.length;s-- >0;){var i=n[s],a=e[i];if(a){var o=t[i],u=o===void 0||a(o,i,t);if(u!==!0)throw new TypeError("option "+i+" must be "+u);continue}if(r!==!0)throw Error("Unknown option "+i)}}hi.exports={assertOptions:Eu,validators:jr}});var Si=l((ql,wi)=>{"use strict";var vi=P(),Au=xr(),mi=Us(),gi=ci(),xe=kr(),yi=pi(),V=yi.validators;function te(t){this.defaults=t,this.interceptors={request:new mi,response:new mi}}te.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=xe(this.defaults,e),e.method?e.method=e.method.toLowerCase():this.defaults.method?e.method=this.defaults.method.toLowerCase():e.method="get";var r=e.transitional;r!==void 0&&yi.assertOptions(r,{silentJSONParsing:V.transitional(V.boolean),forcedJSONParsing:V.transitional(V.boolean),clarifyTimeoutError:V.transitional(V.boolean)},!1);var n=[],s=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(e)===!1||(s=s&&h.synchronous,n.unshift(h.fulfilled,h.rejected))});var i=[];this.interceptors.response.forEach(function(h){i.push(h.fulfilled,h.rejected)});var a;if(!s){var o=[gi,void 0];for(Array.prototype.unshift.apply(o,n),o=o.concat(i),a=Promise.resolve(e);o.length;)a=a.then(o.shift(),o.shift());return a}for(var u=e;n.length;){var p=n.shift(),c=n.shift();try{u=p(u)}catch(f){c(f);break}}try{a=gi(u)}catch(f){return Promise.reject(f)}for(;i.length;)a=a.then(i.shift(),i.shift());return a};te.prototype.getUri=function(e){return e=xe(this.defaults,e),Au(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};vi.forEach(["delete","get","head","options"],function(e){te.prototype[e]=function(r,n){return this.request(xe(n||{},{method:e,url:r,data:(n||{}).data}))}});vi.forEach(["post","put","patch"],function(e){te.prototype[e]=function(r,n,s){return this.request(xe(s||{},{method:e,url:r,data:n}))}});wi.exports=te});var Ei=l((Tl,bi)=>{"use strict";var xu=ee();function G(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(s){e=s});var r=this;this.promise.then(function(n){if(!!r._listeners){var s,i=r._listeners.length;for(s=0;s<i;s++)r._listeners[s](n);r._listeners=null}}),this.promise.then=function(n){var s,i=new Promise(function(a){r.subscribe(a),s=a}).then(n);return i.cancel=function(){r.unsubscribe(s)},i},t(function(s){r.reason||(r.reason=new xu(s),e(r.reason))})}G.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};G.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};G.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};G.source=function(){var e,r=new G(function(s){e=s});return{token:r,cancel:e}};bi.exports=G});var xi=l((Ol,Ai)=>{"use strict";Ai.exports=function(e){return function(n){return e.apply(null,n)}}});var Pi=l((Il,Ci)=>{"use strict";Ci.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Ti=l((Nl,Dr)=>{"use strict";var Ri=P(),Cu=wr(),Ce=Si(),Pu=kr(),Ru=re();function qi(t){var e=new Ce(t),r=Cu(Ce.prototype.request,e);return Ri.extend(r,Ce.prototype,e),Ri.extend(r,e),r.create=function(s){return qi(Pu(t,s))},r}var U=qi(Ru);U.Axios=Ce;U.Cancel=ee();U.CancelToken=Ei();U.isCancel=Ir();U.VERSION=Fr().version;U.all=function(e){return Promise.all(e)};U.spread=xi();U.isAxiosError=Pi();Dr.exports=U;Dr.exports.default=U});var Lr=l((Ul,Oi)=>{Oi.exports=Ti()});var Xt=W(Wt()),Ua=500,Ge=class{constructor({url:e=""}){this.url=e,this.httpClient=Xt.default.create({baseURL:this.url}),this.httpClient.interceptors.response.use(r=>r,r=>{var n,s,i,a,o,u;return Promise.reject({message:(a=(i=(s=(n=r.response)==null?void 0:n.data)==null?void 0:s.message)!=null?i:r.message)!=null?a:JSON.stringify(r),status:(u=(o=r.response)==null?void 0:o.status)!=null?u:Ua})})}async signUpEmailPassword(e){try{return{data:(await this.httpClient.post("/signup/email-password",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInEmailPassword(e){try{return{data:(await this.httpClient.post("/signin/email-password",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInPasswordlessEmail(e){try{return{data:(await this.httpClient.post("/signin/passwordless/email",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInPasswordlessSms(e){try{return{data:(await this.httpClient.post("/signin/passwordless/sms",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signInPasswordlessSmsOtp(e){try{return{data:(await this.httpClient.post("/signin/passwordless/sms/otp",e)).data,error:null}}catch(r){return{data:null,error:r}}}async signOut(e){try{return await this.httpClient.post("/signout",e),{error:null}}catch(r){return{error:r}}}async refreshToken(e){try{let r=await this.httpClient.post("/token",e);return{error:null,session:r.data}}catch(r){return{error:r,session:null}}}async resetPassword(e){try{return await this.httpClient.post("/user/password/reset",e),{error:null}}catch(r){return{error:r}}}async changePassword(e){try{return await this.httpClient.post("/user/password",e,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(r){return{error:r}}}async sendVerificationEmail(e){try{return await this.httpClient.post("/user/email/send-verification-email",e),{error:null}}catch(r){return{error:r}}}async changeEmail(e){try{return await this.httpClient.post("/user/email/change",e,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(r){return{error:r}}}async deanonymize(e){try{return await this.httpClient.post("/user/deanonymize",e),{error:null}}catch(r){return{error:r}}}async verifyEmail(e){try{return{data:(await this.httpClient.post("/user/email/verify",e)).data,error:null}}catch(r){return{data:null,error:r}}}setAccessToken(e){this.accessToken=e}generateAuthHeaders(){return this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:null}};var gn=W(mn());var F="nhostRefreshToken";var Y=()=>typeof window!="undefined",Ke=class{constructor(){this.memory={}}setItem(e,r){this.memory[e]=r}getItem(e){return this.memory[e]}removeItem(e){delete this.memory[e]}};var Qe=class{constructor({url:e,autoRefreshToken:r=!0,autoLogin:n=!0,refreshIntervalTime:s,clientStorage:i,clientStorageType:a="web"}){this.refreshIntervalTime=s,i?this.clientStorage=i:this.clientStorage=Y()?localStorage:new Ke,this.clientStorageType=a,this.onTokenChangedFunctions=[],this.onAuthChangedFunctions=[],this.refreshInterval,this.refreshSleepCheckInterval=0,this.refreshIntervalSleepCheckLastSample=Date.now(),this.sampleRate=2e3,this.url=e,this.autoRefreshToken=r,this.initAuthLoading=!0,this.session=null,this.api=new Ge({url:this.url});let o=null,u=!1;if(n&&Y()&&window.location){let p=gn.default.parse(window.location.toString().split("#")[1]);if("refreshToken"in p&&(o=p.refreshToken),"otp"in p&&"email"in p){let{otp:c,email:f}=p;this.signIn({otp:c,email:f}),u=!0}}!u&&n?this._autoLogin(o):o&&this._setItem(F,o)}async signUp(e){let{email:r,password:n}=e;if(r&&n){let{data:s,error:i}=await this.api.signUpEmailPassword(e);if(i)return{session:null,error:i};if(!s)return{session:null,error:{message:"An error occurred on sign up.",status:500}};let{session:a}=s;return a&&await this._setSession(a),{session:a,error:null}}return{session:null,error:{message:"Incorrect parameters",status:500}}}async signIn(e){if("provider"in e){let{provider:r,options:n}=e,s=`${this.url}/signin/provider/${r}`;return n&&(s+="?",n.locale&&(s+=`locale=${encodeURIComponent(n.locale)}&`),n.allowedRoles&&(s+=`allowedRoles=${encodeURIComponent(n.allowedRoles.join(","))}&`),n.defaultRole&&(s+=`defaultRole=${encodeURIComponent(n.defaultRole)}&`),n.displayName&&(s+=`displayName=${encodeURIComponent(n.displayName)}&`),n.redirectTo&&(s+=`redirectTo=${encodeURIComponent(n.redirectTo)}&`),n.metadata&&(s+=`metadata=${encodeURIComponent(JSON.stringify(n.metadata))}&`),s=s.slice(0,-1)),Y()&&(window.location.href=s),{providerUrl:s,provider:r,session:null,mfa:null,error:null}}if("email"in e&&"password"in e){let{data:r,error:n}=await this.api.signInEmailPassword(e);if(n)return{session:null,mfa:null,error:n};if(!r)return{session:null,mfa:null,error:{message:"Incorrect Data",status:500}};let{session:s,mfa:i}=r;return s&&await this._setSession(s),{session:s,mfa:i,error:null}}if("email"in e&&!("otp"in e)){let{error:r}=await this.api.signInPasswordlessEmail(e);return r?{session:null,mfa:null,error:r}:{session:null,mfa:null,error:null}}if("phoneNumber"in e&&!("otp"in e)){let{error:r}=await this.api.signInPasswordlessSms(e);return r?{session:null,mfa:null,error:r}:{session:null,mfa:null,error:null}}if("otp"in e){let{data:r,error:n}=await this.api.signInPasswordlessSmsOtp(e);if(n)return{session:null,mfa:null,error:n};if(!r)return{session:null,mfa:null,error:{message:"Incorrect data",status:500}};let{session:s,mfa:i}=r;return s&&await this._setSession(s),{session:s,mfa:i,error:null}}return{session:null,mfa:null,error:{message:"Incorrect parameters",status:500}}}async signOut(e){let r=await this._getItem(F);this._clearSession();let{error:n}=await this.api.signOut({refreshToken:r,all:e==null?void 0:e.all});return{error:n}}async verifyEmail(e){return await this.api.verifyEmail(e)}async resetPassword(e){let{error:r}=await this.api.resetPassword(e);return{error:r}}async changePassword(e){let{error:r}=await this.api.changePassword(e);return{error:r}}async sendVerificationEmail(e){let{error:r}=await this.api.sendVerificationEmail(e);return{error:r}}async changeEmail(e){let{error:r}=await this.api.changeEmail(e);return{error:r}}async deanonymize(e){let{error:r}=await this.api.deanonymize(e);return{error:r}}onTokenChanged(e){this.onTokenChangedFunctions.push(e);let r=this.onTokenChangedFunctions.length-1;return()=>{try{this.onTokenChangedFunctions[r]=()=>{}}catch{console.warn("Unable to unsubscribe onTokenChanged function. Maybe the functions is already unsubscribed?")}}}onAuthStateChanged(e){this.onAuthChangedFunctions.push(e);let r=this.onAuthChangedFunctions.length-1;return()=>{try{this.onAuthChangedFunctions[r]=()=>{}}catch{console.warn("Unable to unsubscribe onAuthStateChanged function. Maybe you already did?")}}}isAuthenticated(){return this.session!==null}async isAuthenticatedAsync(){return new Promise(e=>{if(!this.initAuthLoading)e(this.isAuthenticated());else{let r=this.onAuthStateChanged((n,s)=>{e(n==="SIGNED_IN"),r()})}})}getAuthenticationStatus(){return this.initAuthLoading?{isAuthenticated:!1,isLoading:!0}:{isAuthenticated:this.session!==null,isLoading:!1}}getJWTToken(){return this.getAccessToken()}getAccessToken(){if(!!this.session)return this.session.accessToken}async refreshSession(e){let r=e||await this._getItem(F);return r||console.warn("no refresh token found. No way of refreshing session"),this._refreshTokens(r)}getSession(){return this.session}getUser(){return this.session?this.session.user:null}async _setItem(e,r){if(typeof r!="string"){console.error('value is not of type "string"');return}switch(this.clientStorageType){case"web":if(typeof this.clientStorage.setItem!="function"){console.error("this.clientStorage.setItem is not a function");break}this.clientStorage.setItem(e,r);break;case"custom":case"react-native":if(typeof this.clientStorage.setItem!="function"){console.error("this.clientStorage.setItem is not a function");break}await this.clientStorage.setItem(e,r);break;case"capacitor":if(typeof this.clientStorage.set!="function"){console.error("this.clientStorage.set is not a function");break}await this.clientStorage.set({key:e,value:r});break;case"expo-secure-storage":if(typeof this.clientStorage.setItemAsync!="function"){console.error("this.clientStorage.setItemAsync is not a function");break}this.clientStorage.setItemAsync(e,r);break;default:break}}async _getItem(e){switch(this.clientStorageType){case"web":if(typeof this.clientStorage.getItem!="function"){console.error("this.clientStorage.getItem is not a function");break}return this.clientStorage.getItem(e);case"custom":case"react-native":if(typeof this.clientStorage.getItem!="function"){console.error("this.clientStorage.getItem is not a function");break}return await this.clientStorage.getItem(e);case"capacitor":if(typeof this.clientStorage.get!="function"){console.error("this.clientStorage.get is not a function");break}return(await this.clientStorage.get({key:e})).value;case"expo-secure-storage":if(typeof this.clientStorage.getItemAsync!="function"){console.error("this.clientStorage.getItemAsync is not a function");break}return this.clientStorage.getItemAsync(e);default:return""}return""}async _removeItem(e){switch(this.clientStorageType){case"web":if(typeof this.clientStorage.removeItem!="function"){console.error("this.clientStorage.removeItem is not a function");break}return void this.clientStorage.removeItem(e);case"custom":case"react-native":if(typeof this.clientStorage.removeItem!="function"){console.error("this.clientStorage.removeItem is not a function");break}return void this.clientStorage.removeItem(e);case"capacitor":if(typeof this.clientStorage.remove!="function"){console.error("this.clientStorage.remove is not a function");break}await this.clientStorage.remove({key:e});break;case"expo-secure-storage":if(typeof this.clientStorage.deleteItemAsync!="function"){console.error("this.clientStorage.deleteItemAsync is not a function");break}this.clientStorage.deleteItemAsync(e);break;default:break}}_autoLogin(e){!Y()||this._refreshTokens(e)}async _refreshTokens(e){let r=e||await this._getItem(F);if(!r){setTimeout(async()=>{await this._clearSession()},0);return}try{let{session:n,error:s}=await this.api.refreshToken({refreshToken:r});if(s&&s.status===401){await this._clearSession();return}if(!n)throw new Error("Invalid session data");await this._setSession(n),this.tokenChanged()}catch{}}tokenChanged(){for(let e of this.onTokenChangedFunctions)e(this.session)}authStateChanged({event:e,session:r}){e==="SIGNED_IN"&&r?this.api.setAccessToken(r.accessToken):this.api.setAccessToken(void 0);for(let n of this.onAuthChangedFunctions)n(e,r)}async _clearSession(){let{isLoading:e,isAuthenticated:r}=this.getAuthenticationStatus();this.session=null,this.initAuthLoading=!1,await this._removeItem(F),(e||r)&&(clearInterval(this.refreshInterval),clearInterval(this.refreshSleepCheckInterval),this.authStateChanged({event:"SIGNED_OUT",session:null}))}async _setSession(e){let{isAuthenticated:r}=this.getAuthenticationStatus();if(this.session=e,await this._setItem(F,e.refreshToken),this.autoRefreshToken&&!r){let n=e.accessTokenExpiresIn,s=this.refreshIntervalTime?this.refreshIntervalTime:Math.max(1,n-1);this.refreshInterval=setInterval(async()=>{let i=await this._getItem(F);await this._refreshTokens(i)},s*1e3),this.refreshIntervalSleepCheckLastSample=Date.now(),this.refreshSleepCheckInterval=setInterval(async()=>{if(Date.now()-this.refreshIntervalSleepCheckLastSample>=this.sampleRate*2){let i=await this._getItem(F);await this._refreshTokens(i)}this.refreshIntervalSleepCheckLastSample=Date.now()},this.sampleRate),this.authStateChanged({event:"SIGNED_IN",session:this.session})}this.initAuthLoading=!1}};var Cs=W(xs()),vr=class{constructor({url:e}){this.url=e,this.httpClient=Cs.default.create({baseURL:this.url})}async upload(e){try{return{fileMetadata:(await this.httpClient.post("/files",e.file,{headers:{...this.generateUploadHeaders(e),...this.generateAuthHeaders()}})).data,error:null}}catch(r){return{fileMetadata:null,error:r}}}async getPresignedUrl(e){try{let{fileId:r}=e;return{presignedUrl:(await this.httpClient.get(`/files/${r}/presignedurl`,{headers:{...this.generateAuthHeaders()}})).data,error:null}}catch(r){return{presignedUrl:null,error:r}}}async delete(e){try{let{fileId:r}=e;return await this.httpClient.delete(`/files/${r}`,{headers:{...this.generateAuthHeaders()}}),{error:null}}catch(r){return{error:r}}}setAccessToken(e){return this.accessToken=e,this}setAdminSecret(e){return this.adminSecret=e,this}generateUploadHeaders(e){let{bucketId:r,name:n,id:s}=e,i={};return r&&(i["x-nhost-bucket-id"]=r),s&&(i["x-nhost-file-id"]=s),n&&(i["x-nhost-file-name"]=n),i}generateAuthHeaders(){return!this.adminSecret&&!this.accessToken?null:this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:{Authorization:`Bearer ${this.accessToken}`}}};var yr=class{constructor({url:e}){this.url=e,this.api=new vr({url:e})}async upload(e){let r=new FormData;r.append("file",e.file);let{fileMetadata:n,error:s}=await this.api.upload({...e,file:r});return s?{fileMetadata:null,error:s}:n?{fileMetadata:n,error:null}:{fileMetadata:null,error:new Error("Invalid file returned")}}getUrl(e){return this.getPublicUrl(e)}getPublicUrl(e){let{fileId:r}=e;return`${this.url}/files/${r}`}async getPresignedUrl(e){let{presignedUrl:r,error:n}=await this.api.getPresignedUrl(e);return n?{presignedUrl:null,error:n}:r?{presignedUrl:r,error:null}:{presignedUrl:null,error:new Error("Invalid file id")}}async delete(e){let{error:r}=await this.api.delete(e);return r?{error:r}:{error:null}}setAccessToken(e){return this.api.setAccessToken(e),this}setAdminSecret(e){return this.api.setAdminSecret(e),this}};var Ii=W(Lr()),Br=class{constructor(e){let{url:r}=e;this.accessToken=null,this.instance=Ii.default.create({baseURL:r})}async call(e,r,n){let s={...this.generateAccessTokenHeaders(),...n==null?void 0:n.headers},i;try{i=await this.instance.post(e,r,{...n,headers:s})}catch(a){if(a instanceof Error)return{res:null,error:a}}return i?{res:i,error:null}:{res:null,error:new Error("Unable to make post request to funtion")}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var Ni=W(Lr()),_r=class{constructor(e){let{url:r}=e;this.url=r,this.accessToken=null,this.instance=Ni.default.create({baseURL:r})}async request(e,r,n){let s={...n==null?void 0:n.headers,...this.generateAccessTokenHeaders()},i="",a;try{a=(await this.instance.post("",{operationName:i||void 0,query:e,variables:r},{...n,headers:s})).data}catch(o){return o instanceof Error?{data:null,error:o}:(console.error(o),{data:null,error:new Error("Unable to get do GraphQL request")})}return typeof a!="object"||Array.isArray(a)||a===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:(a=a,a.errors?{data:null,error:a.errors}:{data:a.data,error:null})}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){if(!!this.accessToken)return{Authorization:`Bearer ${this.accessToken}`}}};var Hr=class{constructor(e){if(!e.backendUrl)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");let{backendUrl:r,refreshIntervalTime:n,clientStorage:s,clientStorageType:i,autoRefreshToken:a,autoLogin:o}=e;this.auth=new Qe({url:`${r}/v1/auth`,refreshIntervalTime:n,clientStorage:s,clientStorageType:i,autoRefreshToken:a,autoLogin:o}),this.storage=new yr({url:`${r}/v1/storage`}),this.functions=new Br({url:`${r}/v1/functions`}),this.graphql=new _r({url:`${r}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),this.auth.onAuthStateChanged((u,p)=>{this.storage.setAccessToken(p==null?void 0:p.accessToken),this.functions.setAccessToken(p==null?void 0:p.accessToken),this.graphql.setAccessToken(p==null?void 0:p.accessToken)}),this.auth.onTokenChanged(u=>{this.storage.setAccessToken(u==null?void 0:u.accessToken),this.functions.setAccessToken(u==null?void 0:u.accessToken),this.graphql.setAccessToken(u==null?void 0:u.accessToken)})}};var Ql=t=>new Hr(t);export{Hr as NhostClient,Ql as createClient};
5
5
  //# sourceMappingURL=index.es.js.map