@nhost/nhost-js 0.3.13 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/nhost-client.d.ts +4 -9
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +2 -2
- package/dist/index.es.js +24 -4
- package/dist/index.es.js.map +3 -3
- package/package.json +24 -22
- package/LICENSE +0 -21
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,25 @@
|
|
|
1
|
-
var
|
|
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
|
-
`),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){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};
|
|
1
|
+
var tc=Object.create;var _r=Object.defineProperty;var rc=Object.getOwnPropertyDescriptor;var nc=Object.getOwnPropertyNames;var ic=Object.getPrototypeOf,sc=Object.prototype.hasOwnProperty;var oc=t=>_r(t,"__esModule",{value:!0});var m=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports);var ac=(t,e,r,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of nc(e))!sc.call(t,i)&&(r||i!=="default")&&_r(t,i,{get:()=>e[i],enumerable:!(n=rc(e,i))||n.enumerable});return t},Lt=(t,e)=>ac(oc(_r(t!=null?tc(ic(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t);var ui=(t,e,r)=>{if(!e.has(t))throw TypeError("Cannot "+r)};var M=(t,e,r)=>(ui(t,e,"read from private field"),r?r.call(t):e.get(t)),Le=(t,e,r)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,r)},st=(t,e,r,n)=>(ui(t,e,"write to private field"),n?n.call(t,r):e.set(t,r),r);var Kr=m((dm,vs)=>{"use strict";vs.exports=function(e,r){return function(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];return e.apply(r,i)}}});var K=m((hm,Ss)=>{"use strict";var vf=Kr(),we=Object.prototype.toString;function Qr(t){return Array.isArray(t)}function Xr(t){return typeof t=="undefined"}function yf(t){return t!==null&&!Xr(t)&&t.constructor!==null&&!Xr(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function ys(t){return we.call(t)==="[object ArrayBuffer]"}function gf(t){return we.call(t)==="[object FormData]"}function Ef(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&ys(t.buffer),e}function Sf(t){return typeof t=="string"}function wf(t){return typeof t=="number"}function gs(t){return t!==null&&typeof t=="object"}function ir(t){if(we.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function xf(t){return we.call(t)==="[object Date]"}function Tf(t){return we.call(t)==="[object File]"}function bf(t){return we.call(t)==="[object Blob]"}function Es(t){return we.call(t)==="[object Function]"}function Rf(t){return gs(t)&&Es(t.pipe)}function Af(t){return we.call(t)==="[object URLSearchParams]"}function Of(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Cf(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Zr(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Qr(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function Yr(){var t={};function e(i,s){ir(t[s])&&ir(i)?t[s]=Yr(t[s],i):ir(i)?t[s]=Yr({},i):Qr(i)?t[s]=i.slice():t[s]=i}for(var r=0,n=arguments.length;r<n;r++)Zr(arguments[r],e);return t}function Pf(t,e,r){return Zr(e,function(i,s){r&&typeof i=="function"?t[s]=vf(i,r):t[s]=i}),t}function Nf(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Ss.exports={isArray:Qr,isArrayBuffer:ys,isBuffer:yf,isFormData:gf,isArrayBufferView:Ef,isString:Sf,isNumber:wf,isObject:gs,isPlainObject:ir,isUndefined:Xr,isDate:xf,isFile:Tf,isBlob:bf,isFunction:Es,isStream:Rf,isURLSearchParams:Af,isStandardBrowserEnv:Cf,forEach:Zr,merge:Yr,extend:Pf,trim:Of,stripBOM:Nf}});var en=m((pm,xs)=>{"use strict";var Ke=K();function ws(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}xs.exports=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(Ke.isURLSearchParams(r))i=r.toString();else{var s=[];Ke.forEach(r,function(c,f){c===null||typeof c=="undefined"||(Ke.isArray(c)?f=f+"[]":c=[c],Ke.forEach(c,function(d){Ke.isDate(d)?d=d.toISOString():Ke.isObject(d)&&(d=JSON.stringify(d)),s.push(ws(f)+"="+ws(d))}))}),i=s.join("&")}if(i){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var bs=m((mm,Ts)=>{"use strict";var If=K();function sr(){this.handlers=[]}sr.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};sr.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};sr.prototype.forEach=function(e){If.forEach(this.handlers,function(n){n!==null&&e(n)})};Ts.exports=sr});var As=m((vm,Rs)=>{"use strict";var _f=K();Rs.exports=function(e,r){_f.forEach(e,function(i,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[s])})}});var tn=m((ym,Os)=>{"use strict";Os.exports=function(e,r,n,i,s){return e.config=r,n&&(e.code=n),e.request=i,e.response=s,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 rn=m((gm,Cs)=>{"use strict";var kf=tn();Cs.exports=function(e,r,n,i,s){var o=new Error(e);return kf(o,r,n,i,s)}});var Ns=m((Em,Ps)=>{"use strict";var qf=rn();Ps.exports=function(e,r,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):r(qf("Request failed with status code "+n.status,n.config,null,n.request,n))}});var _s=m((Sm,Is)=>{"use strict";var or=K();Is.exports=or.isStandardBrowserEnv()?function(){return{write:function(r,n,i,s,o,a){var c=[];c.push(r+"="+encodeURIComponent(n)),or.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),or.isString(s)&&c.push("path="+s),or.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.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 qs=m((wm,ks)=>{"use strict";ks.exports=function(e){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(e)}});var Us=m((xm,Ds)=>{"use strict";Ds.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var Ls=m((Tm,Ms)=>{"use strict";var Df=qs(),Uf=Us();Ms.exports=function(e,r){return e&&!Df(r)?Uf(e,r):r}});var Bs=m((bm,js)=>{"use strict";var nn=K(),Mf=["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"];js.exports=function(e){var r={},n,i,s;return e&&nn.forEach(e.split(`
|
|
2
|
+
`),function(a){if(s=a.indexOf(":"),n=nn.trim(a.substr(0,s)).toLowerCase(),i=nn.trim(a.substr(s+1)),n){if(r[n]&&Mf.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([i]):r[n]=r[n]?r[n]+", "+i:i}}),r}});var Hs=m((Rm,Vs)=>{"use strict";var Fs=K();Vs.exports=Fs.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function i(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{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=i(window.location.href),function(o){var a=Fs.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}()});var At=m((Am,Gs)=>{"use strict";function sn(t){this.message=t}sn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};sn.prototype.__CANCEL__=!0;Gs.exports=sn});var an=m((Om,Js)=>{"use strict";var ar=K(),Lf=Ns(),jf=_s(),Bf=en(),Ff=Ls(),Vf=Bs(),Hf=Hs(),on=rn(),Gf=Ot(),Jf=At();Js.exports=function(e){return new Promise(function(n,i){var s=e.data,o=e.headers,a=e.responseType,c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}ar.isFormData(s)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",l=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(d+":"+l)}var h=Ff(e.baseURL,e.url);u.open(e.method.toUpperCase(),Bf(h,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function g(){if(!!u){var p="getAllResponseHeaders"in u?Vf(u.getAllResponseHeaders()):null,w=!a||a==="text"||a==="json"?u.responseText:u.response,y={data:w,status:u.status,statusText:u.statusText,headers:p,config:e,request:u};Lf(function(C){n(C),f()},function(C){i(C),f()},y),u=null}}if("onloadend"in u?u.onloadend=g:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(g)},u.onabort=function(){!u||(i(on("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){i(on("Network Error",e,null,u)),u=null},u.ontimeout=function(){var w=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",y=e.transitional||Gf.transitional;e.timeoutErrorMessage&&(w=e.timeoutErrorMessage),i(on(w,e,y.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},ar.isStandardBrowserEnv()){var E=(e.withCredentials||Hf(h))&&e.xsrfCookieName?jf.read(e.xsrfCookieName):void 0;E&&(o[e.xsrfHeaderName]=E)}"setRequestHeader"in u&&ar.forEach(o,function(w,y){typeof s=="undefined"&&y.toLowerCase()==="content-type"?delete o[y]:u.setRequestHeader(y,w)}),ar.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),a&&a!=="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.signal)&&(c=function(p){!u||(i(!p||p&&p.type?new Jf("canceled"):p),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c))),s||(s=null),u.send(s)})}});var Ot=m((Cm,Ws)=>{"use strict";var H=K(),zs=As(),zf=tn(),$f={"Content-Type":"application/x-www-form-urlencoded"};function $s(t,e){!H.isUndefined(t)&&H.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Wf(){var t;return typeof XMLHttpRequest!="undefined"?t=an():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=an()),t}function Kf(t,e,r){if(H.isString(t))try{return(e||JSON.parse)(t),H.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var ur={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Wf(),transformRequest:[function(e,r){return zs(r,"Accept"),zs(r,"Content-Type"),H.isFormData(e)||H.isArrayBuffer(e)||H.isBuffer(e)||H.isStream(e)||H.isFile(e)||H.isBlob(e)?e:H.isArrayBufferView(e)?e.buffer:H.isURLSearchParams(e)?($s(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):H.isObject(e)||r&&r["Content-Type"]==="application/json"?($s(r,"application/json"),Kf(e)):e}],transformResponse:[function(e){var r=this.transitional||ur.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||i&&H.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?zf(o,this,"E_JSON_PARSE"):o}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, */*"}}};H.forEach(["delete","get","head"],function(e){ur.headers[e]={}});H.forEach(["post","put","patch"],function(e){ur.headers[e]=H.merge($f)});Ws.exports=ur});var Xs=m((Pm,Ks)=>{"use strict";var Xf=K(),Yf=Ot();Ks.exports=function(e,r,n){var i=this||Yf;return Xf.forEach(n,function(o){e=o.call(i,e,r)}),e}});var un=m((Nm,Ys)=>{"use strict";Ys.exports=function(e){return!!(e&&e.__CANCEL__)}});var eo=m((Im,Zs)=>{"use strict";var Qs=K(),cn=Xs(),Qf=un(),Zf=Ot(),el=At();function fn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new el("canceled")}Zs.exports=function(e){fn(e),e.headers=e.headers||{},e.data=cn.call(e,e.data,e.headers,e.transformRequest),e.headers=Qs.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Qs.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||Zf.adapter;return r(e).then(function(i){return fn(e),i.data=cn.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Qf(i)||(fn(e),i&&i.response&&(i.response.data=cn.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var ln=m((_m,to)=>{"use strict";var re=K();to.exports=function(e,r){r=r||{};var n={};function i(u,d){return re.isPlainObject(u)&&re.isPlainObject(d)?re.merge(u,d):re.isPlainObject(d)?re.merge({},d):re.isArray(d)?d.slice():d}function s(u){if(re.isUndefined(r[u])){if(!re.isUndefined(e[u]))return i(void 0,e[u])}else return i(e[u],r[u])}function o(u){if(!re.isUndefined(r[u]))return i(void 0,r[u])}function a(u){if(re.isUndefined(r[u])){if(!re.isUndefined(e[u]))return i(void 0,e[u])}else return i(void 0,r[u])}function c(u){if(u in r)return i(e[u],r[u]);if(u in e)return i(void 0,e[u])}var f={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return re.forEach(Object.keys(e).concat(Object.keys(r)),function(d){var l=f[d]||s,h=l(d);re.isUndefined(h)&&l!==c||(n[d]=h)}),n}});var dn=m((km,ro)=>{ro.exports={version:"0.25.0"}});var so=m((qm,io)=>{"use strict";var tl=dn().version,hn={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){hn[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var no={};hn.transitional=function(e,r,n){function i(s,o){return"[Axios v"+tl+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return function(s,o,a){if(e===!1)throw new Error(i(o," has been removed"+(r?" in "+r:"")));return r&&!no[o]&&(no[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,o,a):!0}};function rl(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],o=e[s];if(o){var a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}io.exports={assertOptions:rl,validators:hn}});var lo=m((Dm,fo)=>{"use strict";var uo=K(),nl=en(),oo=bs(),ao=eo(),cr=ln(),co=so(),Xe=co.validators;function Ct(t){this.defaults=t,this.interceptors={request:new oo,response:new oo}}Ct.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=cr(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&&co.assertOptions(n,{silentJSONParsing:Xe.transitional(Xe.boolean),forcedJSONParsing:Xe.transitional(Xe.boolean),clarifyTimeoutError:Xe.transitional(Xe.boolean)},!1);var i=[],s=!0;this.interceptors.request.forEach(function(h){typeof h.runWhen=="function"&&h.runWhen(r)===!1||(s=s&&h.synchronous,i.unshift(h.fulfilled,h.rejected))});var o=[];this.interceptors.response.forEach(function(h){o.push(h.fulfilled,h.rejected)});var a;if(!s){var c=[ao,void 0];for(Array.prototype.unshift.apply(c,i),c=c.concat(o),a=Promise.resolve(r);c.length;)a=a.then(c.shift(),c.shift());return a}for(var f=r;i.length;){var u=i.shift(),d=i.shift();try{f=u(f)}catch(l){d(l);break}}try{a=ao(f)}catch(l){return Promise.reject(l)}for(;o.length;)a=a.then(o.shift(),o.shift());return a};Ct.prototype.getUri=function(e){if(!e.url)throw new Error("Provided config url is not valid");return e=cr(this.defaults,e),nl(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};uo.forEach(["delete","get","head","options"],function(e){Ct.prototype[e]=function(r,n){return this.request(cr(n||{},{method:e,url:r,data:(n||{}).data}))}});uo.forEach(["post","put","patch"],function(e){Ct.prototype[e]=function(r,n,i){return this.request(cr(i||{},{method:e,url:r,data:n}))}});fo.exports=Ct});var po=m((Um,ho)=>{"use strict";var il=At();function Ye(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var r=this;this.promise.then(function(n){if(!!r._listeners){var i,s=r._listeners.length;for(i=0;i<s;i++)r._listeners[i](n);r._listeners=null}}),this.promise.then=function(n){var i,s=new Promise(function(o){r.subscribe(o),i=o}).then(n);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i){r.reason||(r.reason=new il(i),e(r.reason))})}Ye.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Ye.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};Ye.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};Ye.source=function(){var e,r=new Ye(function(i){e=i});return{token:r,cancel:e}};ho.exports=Ye});var vo=m((Mm,mo)=>{"use strict";mo.exports=function(e){return function(n){return e.apply(null,n)}}});var go=m((Lm,yo)=>{"use strict";var sl=K();yo.exports=function(e){return sl.isObject(e)&&e.isAxiosError===!0}});var wo=m((jm,pn)=>{"use strict";var Eo=K(),ol=Kr(),fr=lo(),al=ln(),ul=Ot();function So(t){var e=new fr(t),r=ol(fr.prototype.request,e);return Eo.extend(r,fr.prototype,e),Eo.extend(r,e),r.create=function(i){return So(al(t,i))},r}var de=So(ul);de.Axios=fr;de.Cancel=At();de.CancelToken=po();de.isCancel=un();de.VERSION=dn().version;de.all=function(e){return Promise.all(e)};de.spread=vo();de.isAxiosError=go();pn.exports=de;pn.exports.default=de});var To=m((Bm,xo)=>{xo.exports=wo()});var gn=m((Ry,Mo)=>{"use strict";Mo.exports=function(e,r){return function(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];return e.apply(r,i)}}});var X=m((Ay,Bo)=>{"use strict";var yl=gn(),De=Object.prototype.toString;function wn(t){return De.call(t)==="[object Array]"}function En(t){return typeof t=="undefined"}function gl(t){return t!==null&&!En(t)&&t.constructor!==null&&!En(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function El(t){return De.call(t)==="[object ArrayBuffer]"}function Sl(t){return typeof FormData!="undefined"&&t instanceof FormData}function wl(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function xl(t){return typeof t=="string"}function Tl(t){return typeof t=="number"}function Lo(t){return t!==null&&typeof t=="object"}function vr(t){if(De.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function bl(t){return De.call(t)==="[object Date]"}function Rl(t){return De.call(t)==="[object File]"}function Al(t){return De.call(t)==="[object Blob]"}function jo(t){return De.call(t)==="[object Function]"}function Ol(t){return Lo(t)&&jo(t.pipe)}function Cl(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function Pl(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function Nl(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function xn(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),wn(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function Sn(){var t={};function e(i,s){vr(t[s])&&vr(i)?t[s]=Sn(t[s],i):vr(i)?t[s]=Sn({},i):wn(i)?t[s]=i.slice():t[s]=i}for(var r=0,n=arguments.length;r<n;r++)xn(arguments[r],e);return t}function Il(t,e,r){return xn(e,function(i,s){r&&typeof i=="function"?t[s]=yl(i,r):t[s]=i}),t}function _l(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Bo.exports={isArray:wn,isArrayBuffer:El,isBuffer:gl,isFormData:Sl,isArrayBufferView:wl,isString:xl,isNumber:Tl,isObject:Lo,isPlainObject:vr,isUndefined:En,isDate:bl,isFile:Rl,isBlob:Al,isFunction:jo,isStream:Ol,isURLSearchParams:Cl,isStandardBrowserEnv:Nl,forEach:xn,merge:Sn,extend:Il,trim:Pl,stripBOM:_l}});var Tn=m((Oy,Vo)=>{"use strict";var et=X();function Fo(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Vo.exports=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(et.isURLSearchParams(r))i=r.toString();else{var s=[];et.forEach(r,function(c,f){c===null||typeof c=="undefined"||(et.isArray(c)?f=f+"[]":c=[c],et.forEach(c,function(d){et.isDate(d)?d=d.toISOString():et.isObject(d)&&(d=JSON.stringify(d)),s.push(Fo(f)+"="+Fo(d))}))}),i=s.join("&")}if(i){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Go=m((Cy,Ho)=>{"use strict";var kl=X();function yr(){this.handlers=[]}yr.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};yr.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};yr.prototype.forEach=function(e){kl.forEach(this.handlers,function(n){n!==null&&e(n)})};Ho.exports=yr});var zo=m((Py,Jo)=>{"use strict";var ql=X();Jo.exports=function(e,r){ql.forEach(e,function(i,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[s])})}});var bn=m((Ny,$o)=>{"use strict";$o.exports=function(e,r,n,i,s){return e.config=r,n&&(e.code=n),e.request=i,e.response=s,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 Rn=m((Iy,Wo)=>{"use strict";var Dl=bn();Wo.exports=function(e,r,n,i,s){var o=new Error(e);return Dl(o,r,n,i,s)}});var Xo=m((_y,Ko)=>{"use strict";var Ul=Rn();Ko.exports=function(e,r,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):r(Ul("Request failed with status code "+n.status,n.config,null,n.request,n))}});var Qo=m((ky,Yo)=>{"use strict";var gr=X();Yo.exports=gr.isStandardBrowserEnv()?function(){return{write:function(r,n,i,s,o,a){var c=[];c.push(r+"="+encodeURIComponent(n)),gr.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),gr.isString(s)&&c.push("path="+s),gr.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.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 ea=m((qy,Zo)=>{"use strict";Zo.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var ra=m((Dy,ta)=>{"use strict";ta.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var ia=m((Uy,na)=>{"use strict";var Ml=ea(),Ll=ra();na.exports=function(e,r){return e&&!Ml(r)?Ll(e,r):r}});var oa=m((My,sa)=>{"use strict";var An=X(),jl=["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"];sa.exports=function(e){var r={},n,i,s;return e&&An.forEach(e.split(`
|
|
3
|
+
`),function(a){if(s=a.indexOf(":"),n=An.trim(a.substr(0,s)).toLowerCase(),i=An.trim(a.substr(s+1)),n){if(r[n]&&jl.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([i]):r[n]=r[n]?r[n]+", "+i:i}}),r}});var ca=m((Ly,ua)=>{"use strict";var aa=X();ua.exports=aa.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function i(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{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=i(window.location.href),function(o){var a=aa.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}()});var Cn=m((jy,fa)=>{"use strict";var Er=X(),Bl=Xo(),Fl=Qo(),Vl=Tn(),Hl=ia(),Gl=oa(),Jl=ca(),On=Rn();fa.exports=function(e){return new Promise(function(n,i){var s=e.data,o=e.headers,a=e.responseType;Er.isFormData(s)&&delete o["Content-Type"];var c=new XMLHttpRequest;if(e.auth){var f=e.auth.username||"",u=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(f+":"+u)}var d=Hl(e.baseURL,e.url);c.open(e.method.toUpperCase(),Vl(d,e.params,e.paramsSerializer),!0),c.timeout=e.timeout;function l(){if(!!c){var g="getAllResponseHeaders"in c?Gl(c.getAllResponseHeaders()):null,E=!a||a==="text"||a==="json"?c.responseText:c.response,p={data:E,status:c.status,statusText:c.statusText,headers:g,config:e,request:c};Bl(n,i,p),c=null}}if("onloadend"in c?c.onloadend=l:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(l)},c.onabort=function(){!c||(i(On("Request aborted",e,"ECONNABORTED",c)),c=null)},c.onerror=function(){i(On("Network Error",e,null,c)),c=null},c.ontimeout=function(){var E="timeout of "+e.timeout+"ms exceeded";e.timeoutErrorMessage&&(E=e.timeoutErrorMessage),i(On(E,e,e.transitional&&e.transitional.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",c)),c=null},Er.isStandardBrowserEnv()){var h=(e.withCredentials||Jl(d))&&e.xsrfCookieName?Fl.read(e.xsrfCookieName):void 0;h&&(o[e.xsrfHeaderName]=h)}"setRequestHeader"in c&&Er.forEach(o,function(E,p){typeof s=="undefined"&&p.toLowerCase()==="content-type"?delete o[p]:c.setRequestHeader(p,E)}),Er.isUndefined(e.withCredentials)||(c.withCredentials=!!e.withCredentials),a&&a!=="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.cancelToken.promise.then(function(E){!c||(c.abort(),i(E),c=null)}),s||(s=null),c.send(s)})}});var wr=m((By,ha)=>{"use strict";var G=X(),la=zo(),zl=bn(),$l={"Content-Type":"application/x-www-form-urlencoded"};function da(t,e){!G.isUndefined(t)&&G.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Wl(){var t;return typeof XMLHttpRequest!="undefined"?t=Cn():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Cn()),t}function Kl(t,e,r){if(G.isString(t))try{return(e||JSON.parse)(t),G.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Sr={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Wl(),transformRequest:[function(e,r){return la(r,"Accept"),la(r,"Content-Type"),G.isFormData(e)||G.isArrayBuffer(e)||G.isBuffer(e)||G.isStream(e)||G.isFile(e)||G.isBlob(e)?e:G.isArrayBufferView(e)?e.buffer:G.isURLSearchParams(e)?(da(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):G.isObject(e)||r&&r["Content-Type"]==="application/json"?(da(r,"application/json"),Kl(e)):e}],transformResponse:[function(e){var r=this.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||i&&G.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?zl(o,this,"E_JSON_PARSE"):o}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,validateStatus:function(e){return e>=200&&e<300}};Sr.headers={common:{Accept:"application/json, text/plain, */*"}};G.forEach(["delete","get","head"],function(e){Sr.headers[e]={}});G.forEach(["post","put","patch"],function(e){Sr.headers[e]=G.merge($l)});ha.exports=Sr});var ma=m((Fy,pa)=>{"use strict";var Xl=X(),Yl=wr();pa.exports=function(e,r,n){var i=this||Yl;return Xl.forEach(n,function(o){e=o.call(i,e,r)}),e}});var Pn=m((Vy,va)=>{"use strict";va.exports=function(e){return!!(e&&e.__CANCEL__)}});var Ea=m((Hy,ga)=>{"use strict";var ya=X(),Nn=ma(),Ql=Pn(),Zl=wr();function In(t){t.cancelToken&&t.cancelToken.throwIfRequested()}ga.exports=function(e){In(e),e.headers=e.headers||{},e.data=Nn.call(e,e.data,e.headers,e.transformRequest),e.headers=ya.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),ya.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||Zl.adapter;return r(e).then(function(i){return In(e),i.data=Nn.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Ql(i)||(In(e),i&&i.response&&(i.response.data=Nn.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var _n=m((Gy,Sa)=>{"use strict";var W=X();Sa.exports=function(e,r){r=r||{};var n={},i=["url","method","data"],s=["headers","auth","proxy","params"],o=["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","timeoutMessage","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","decompress","maxContentLength","maxBodyLength","maxRedirects","transport","httpAgent","httpsAgent","cancelToken","socketPath","responseEncoding"],a=["validateStatus"];function c(l,h){return W.isPlainObject(l)&&W.isPlainObject(h)?W.merge(l,h):W.isPlainObject(h)?W.merge({},h):W.isArray(h)?h.slice():h}function f(l){W.isUndefined(r[l])?W.isUndefined(e[l])||(n[l]=c(void 0,e[l])):n[l]=c(e[l],r[l])}W.forEach(i,function(h){W.isUndefined(r[h])||(n[h]=c(void 0,r[h]))}),W.forEach(s,f),W.forEach(o,function(h){W.isUndefined(r[h])?W.isUndefined(e[h])||(n[h]=c(void 0,e[h])):n[h]=c(void 0,r[h])}),W.forEach(a,function(h){h in r?n[h]=c(e[h],r[h]):h in e&&(n[h]=c(void 0,e[h]))});var u=i.concat(s).concat(o).concat(a),d=Object.keys(e).concat(Object.keys(r)).filter(function(h){return u.indexOf(h)===-1});return W.forEach(d,f),n}});var wa=m((Jy,ed)=>{ed.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 Aa=m((zy,Ra)=>{"use strict";var Ta=wa(),kn={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){kn[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var xa={},td=Ta.version.split(".");function ba(t,e){for(var r=e?e.split("."):td,n=t.split("."),i=0;i<3;i++){if(r[i]>n[i])return!0;if(r[i]<n[i])return!1}return!1}kn.transitional=function(e,r,n){var i=r&&ba(r);function s(o,a){return"[Axios v"+Ta.version+"] Transitional option '"+o+"'"+a+(n?". "+n:"")}return function(o,a,c){if(e===!1)throw new Error(s(a," has been removed in "+r));return i&&!xa[a]&&(xa[a]=!0,console.warn(s(a," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(o,a,c):!0}};function rd(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],o=e[s];if(o){var a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}Ra.exports={isOlderVersion:ba,assertOptions:rd,validators:kn}});var _a=m(($y,Ia)=>{"use strict";var Pa=X(),nd=Tn(),Oa=Go(),Ca=Ea(),xr=_n(),Na=Aa(),tt=Na.validators;function kt(t){this.defaults=t,this.interceptors={request:new Oa,response:new Oa}}kt.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=xr(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&&Na.assertOptions(r,{silentJSONParsing:tt.transitional(tt.boolean,"1.0.0"),forcedJSONParsing:tt.transitional(tt.boolean,"1.0.0"),clarifyTimeoutError:tt.transitional(tt.boolean,"1.0.0")},!1);var n=[],i=!0;this.interceptors.request.forEach(function(l){typeof l.runWhen=="function"&&l.runWhen(e)===!1||(i=i&&l.synchronous,n.unshift(l.fulfilled,l.rejected))});var s=[];this.interceptors.response.forEach(function(l){s.push(l.fulfilled,l.rejected)});var o;if(!i){var a=[Ca,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),o=Promise.resolve(e);a.length;)o=o.then(a.shift(),a.shift());return o}for(var c=e;n.length;){var f=n.shift(),u=n.shift();try{c=f(c)}catch(d){u(d);break}}try{o=Ca(c)}catch(d){return Promise.reject(d)}for(;s.length;)o=o.then(s.shift(),s.shift());return o};kt.prototype.getUri=function(e){return e=xr(this.defaults,e),nd(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Pa.forEach(["delete","get","head","options"],function(e){kt.prototype[e]=function(r,n){return this.request(xr(n||{},{method:e,url:r,data:(n||{}).data}))}});Pa.forEach(["post","put","patch"],function(e){kt.prototype[e]=function(r,n,i){return this.request(xr(i||{},{method:e,url:r,data:n}))}});Ia.exports=kt});var Dn=m((Wy,ka)=>{"use strict";function qn(t){this.message=t}qn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};qn.prototype.__CANCEL__=!0;ka.exports=qn});var Da=m((Ky,qa)=>{"use strict";var id=Dn();function Tr(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var r=this;t(function(i){r.reason||(r.reason=new id(i),e(r.reason))})}Tr.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};Tr.source=function(){var e,r=new Tr(function(i){e=i});return{token:r,cancel:e}};qa.exports=Tr});var Ma=m((Xy,Ua)=>{"use strict";Ua.exports=function(e){return function(n){return e.apply(null,n)}}});var ja=m((Yy,La)=>{"use strict";La.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Va=m((Qy,Un)=>{"use strict";var Ba=X(),sd=gn(),br=_a(),od=_n(),ad=wr();function Fa(t){var e=new br(t),r=sd(br.prototype.request,e);return Ba.extend(r,br.prototype,e),Ba.extend(r,e),r}var ue=Fa(ad);ue.Axios=br;ue.create=function(e){return Fa(od(ue.defaults,e))};ue.Cancel=Dn();ue.CancelToken=Da();ue.isCancel=Pn();ue.all=function(e){return Promise.all(e)};ue.spread=Ma();ue.isAxiosError=ja();Un.exports=ue;Un.exports.default=ue});var Ga=m((Zy,Ha)=>{Ha.exports=Va()});var jn=m((ug,za)=>{"use strict";za.exports=function(e,r){return function(){for(var i=new Array(arguments.length),s=0;s<i.length;s++)i[s]=arguments[s];return e.apply(r,i)}}});var Y=m((cg,Ka)=>{"use strict";var ud=jn(),Ue=Object.prototype.toString;function Vn(t){return Ue.call(t)==="[object Array]"}function Bn(t){return typeof t=="undefined"}function cd(t){return t!==null&&!Bn(t)&&t.constructor!==null&&!Bn(t.constructor)&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}function fd(t){return Ue.call(t)==="[object ArrayBuffer]"}function ld(t){return typeof FormData!="undefined"&&t instanceof FormData}function dd(t){var e;return typeof ArrayBuffer!="undefined"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&t.buffer instanceof ArrayBuffer,e}function hd(t){return typeof t=="string"}function pd(t){return typeof t=="number"}function $a(t){return t!==null&&typeof t=="object"}function Rr(t){if(Ue.call(t)!=="[object Object]")return!1;var e=Object.getPrototypeOf(t);return e===null||e===Object.prototype}function md(t){return Ue.call(t)==="[object Date]"}function vd(t){return Ue.call(t)==="[object File]"}function yd(t){return Ue.call(t)==="[object Blob]"}function Wa(t){return Ue.call(t)==="[object Function]"}function gd(t){return $a(t)&&Wa(t.pipe)}function Ed(t){return typeof URLSearchParams!="undefined"&&t instanceof URLSearchParams}function Sd(t){return t.trim?t.trim():t.replace(/^\s+|\s+$/g,"")}function wd(){return typeof navigator!="undefined"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window!="undefined"&&typeof document!="undefined"}function Hn(t,e){if(!(t===null||typeof t=="undefined"))if(typeof t!="object"&&(t=[t]),Vn(t))for(var r=0,n=t.length;r<n;r++)e.call(null,t[r],r,t);else for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.call(null,t[i],i,t)}function Fn(){var t={};function e(i,s){Rr(t[s])&&Rr(i)?t[s]=Fn(t[s],i):Rr(i)?t[s]=Fn({},i):Vn(i)?t[s]=i.slice():t[s]=i}for(var r=0,n=arguments.length;r<n;r++)Hn(arguments[r],e);return t}function xd(t,e,r){return Hn(e,function(i,s){r&&typeof i=="function"?t[s]=ud(i,r):t[s]=i}),t}function Td(t){return t.charCodeAt(0)===65279&&(t=t.slice(1)),t}Ka.exports={isArray:Vn,isArrayBuffer:fd,isBuffer:cd,isFormData:ld,isArrayBufferView:dd,isString:hd,isNumber:pd,isObject:$a,isPlainObject:Rr,isUndefined:Bn,isDate:md,isFile:vd,isBlob:yd,isFunction:Wa,isStream:gd,isURLSearchParams:Ed,isStandardBrowserEnv:wd,forEach:Hn,merge:Fn,extend:xd,trim:Sd,stripBOM:Td}});var Gn=m((fg,Ya)=>{"use strict";var rt=Y();function Xa(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}Ya.exports=function(e,r,n){if(!r)return e;var i;if(n)i=n(r);else if(rt.isURLSearchParams(r))i=r.toString();else{var s=[];rt.forEach(r,function(c,f){c===null||typeof c=="undefined"||(rt.isArray(c)?f=f+"[]":c=[c],rt.forEach(c,function(d){rt.isDate(d)?d=d.toISOString():rt.isObject(d)&&(d=JSON.stringify(d)),s.push(Xa(f)+"="+Xa(d))}))}),i=s.join("&")}if(i){var o=e.indexOf("#");o!==-1&&(e=e.slice(0,o)),e+=(e.indexOf("?")===-1?"?":"&")+i}return e}});var Za=m((lg,Qa)=>{"use strict";var bd=Y();function Ar(){this.handlers=[]}Ar.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};Ar.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)};Ar.prototype.forEach=function(e){bd.forEach(this.handlers,function(n){n!==null&&e(n)})};Qa.exports=Ar});var tu=m((dg,eu)=>{"use strict";var Rd=Y();eu.exports=function(e,r){Rd.forEach(e,function(i,s){s!==r&&s.toUpperCase()===r.toUpperCase()&&(e[r]=i,delete e[s])})}});var Jn=m((hg,ru)=>{"use strict";ru.exports=function(e,r,n,i,s){return e.config=r,n&&(e.code=n),e.request=i,e.response=s,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 zn=m((pg,nu)=>{"use strict";var Ad=Jn();nu.exports=function(e,r,n,i,s){var o=new Error(e);return Ad(o,r,n,i,s)}});var su=m((mg,iu)=>{"use strict";var Od=zn();iu.exports=function(e,r,n){var i=n.config.validateStatus;!n.status||!i||i(n.status)?e(n):r(Od("Request failed with status code "+n.status,n.config,null,n.request,n))}});var au=m((vg,ou)=>{"use strict";var Or=Y();ou.exports=Or.isStandardBrowserEnv()?function(){return{write:function(r,n,i,s,o,a){var c=[];c.push(r+"="+encodeURIComponent(n)),Or.isNumber(i)&&c.push("expires="+new Date(i).toGMTString()),Or.isString(s)&&c.push("path="+s),Or.isString(o)&&c.push("domain="+o),a===!0&&c.push("secure"),document.cookie=c.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 cu=m((yg,uu)=>{"use strict";uu.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}});var lu=m((gg,fu)=>{"use strict";fu.exports=function(e,r){return r?e.replace(/\/+$/,"")+"/"+r.replace(/^\/+/,""):e}});var hu=m((Eg,du)=>{"use strict";var Cd=cu(),Pd=lu();du.exports=function(e,r){return e&&!Cd(r)?Pd(e,r):r}});var mu=m((Sg,pu)=>{"use strict";var $n=Y(),Nd=["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"];pu.exports=function(e){var r={},n,i,s;return e&&$n.forEach(e.split(`
|
|
4
|
+
`),function(a){if(s=a.indexOf(":"),n=$n.trim(a.substr(0,s)).toLowerCase(),i=$n.trim(a.substr(s+1)),n){if(r[n]&&Nd.indexOf(n)>=0)return;n==="set-cookie"?r[n]=(r[n]?r[n]:[]).concat([i]):r[n]=r[n]?r[n]+", "+i:i}}),r}});var gu=m((wg,yu)=>{"use strict";var vu=Y();yu.exports=vu.isStandardBrowserEnv()?function(){var e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),n;function i(s){var o=s;return e&&(r.setAttribute("href",o),o=r.href),r.setAttribute("href",o),{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=i(window.location.href),function(o){var a=vu.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}()});var qt=m((xg,Eu)=>{"use strict";function Wn(t){this.message=t}Wn.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")};Wn.prototype.__CANCEL__=!0;Eu.exports=Wn});var Xn=m((Tg,Su)=>{"use strict";var Cr=Y(),Id=su(),_d=au(),kd=Gn(),qd=hu(),Dd=mu(),Ud=gu(),Kn=zn(),Md=Dt(),Ld=qt();Su.exports=function(e){return new Promise(function(n,i){var s=e.data,o=e.headers,a=e.responseType,c;function f(){e.cancelToken&&e.cancelToken.unsubscribe(c),e.signal&&e.signal.removeEventListener("abort",c)}Cr.isFormData(s)&&delete o["Content-Type"];var u=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",l=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";o.Authorization="Basic "+btoa(d+":"+l)}var h=qd(e.baseURL,e.url);u.open(e.method.toUpperCase(),kd(h,e.params,e.paramsSerializer),!0),u.timeout=e.timeout;function g(){if(!!u){var p="getAllResponseHeaders"in u?Dd(u.getAllResponseHeaders()):null,w=!a||a==="text"||a==="json"?u.responseText:u.response,y={data:w,status:u.status,statusText:u.statusText,headers:p,config:e,request:u};Id(function(C){n(C),f()},function(C){i(C),f()},y),u=null}}if("onloadend"in u?u.onloadend=g:u.onreadystatechange=function(){!u||u.readyState!==4||u.status===0&&!(u.responseURL&&u.responseURL.indexOf("file:")===0)||setTimeout(g)},u.onabort=function(){!u||(i(Kn("Request aborted",e,"ECONNABORTED",u)),u=null)},u.onerror=function(){i(Kn("Network Error",e,null,u)),u=null},u.ontimeout=function(){var w=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",y=e.transitional||Md.transitional;e.timeoutErrorMessage&&(w=e.timeoutErrorMessage),i(Kn(w,e,y.clarifyTimeoutError?"ETIMEDOUT":"ECONNABORTED",u)),u=null},Cr.isStandardBrowserEnv()){var E=(e.withCredentials||Ud(h))&&e.xsrfCookieName?_d.read(e.xsrfCookieName):void 0;E&&(o[e.xsrfHeaderName]=E)}"setRequestHeader"in u&&Cr.forEach(o,function(w,y){typeof s=="undefined"&&y.toLowerCase()==="content-type"?delete o[y]:u.setRequestHeader(y,w)}),Cr.isUndefined(e.withCredentials)||(u.withCredentials=!!e.withCredentials),a&&a!=="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.signal)&&(c=function(p){!u||(i(!p||p&&p.type?new Ld("canceled"):p),u.abort(),u=null)},e.cancelToken&&e.cancelToken.subscribe(c),e.signal&&(e.signal.aborted?c():e.signal.addEventListener("abort",c))),s||(s=null),u.send(s)})}});var Dt=m((bg,Tu)=>{"use strict";var J=Y(),wu=tu(),jd=Jn(),Bd={"Content-Type":"application/x-www-form-urlencoded"};function xu(t,e){!J.isUndefined(t)&&J.isUndefined(t["Content-Type"])&&(t["Content-Type"]=e)}function Fd(){var t;return typeof XMLHttpRequest!="undefined"?t=Xn():typeof process!="undefined"&&Object.prototype.toString.call(process)==="[object process]"&&(t=Xn()),t}function Vd(t,e,r){if(J.isString(t))try{return(e||JSON.parse)(t),J.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}var Pr={transitional:{silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},adapter:Fd(),transformRequest:[function(e,r){return wu(r,"Accept"),wu(r,"Content-Type"),J.isFormData(e)||J.isArrayBuffer(e)||J.isBuffer(e)||J.isStream(e)||J.isFile(e)||J.isBlob(e)?e:J.isArrayBufferView(e)?e.buffer:J.isURLSearchParams(e)?(xu(r,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):J.isObject(e)||r&&r["Content-Type"]==="application/json"?(xu(r,"application/json"),Vd(e)):e}],transformResponse:[function(e){var r=this.transitional||Pr.transitional,n=r&&r.silentJSONParsing,i=r&&r.forcedJSONParsing,s=!n&&this.responseType==="json";if(s||i&&J.isString(e)&&e.length)try{return JSON.parse(e)}catch(o){if(s)throw o.name==="SyntaxError"?jd(o,this,"E_JSON_PARSE"):o}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, */*"}}};J.forEach(["delete","get","head"],function(e){Pr.headers[e]={}});J.forEach(["post","put","patch"],function(e){Pr.headers[e]=J.merge(Bd)});Tu.exports=Pr});var Ru=m((Rg,bu)=>{"use strict";var Hd=Y(),Gd=Dt();bu.exports=function(e,r,n){var i=this||Gd;return Hd.forEach(n,function(o){e=o.call(i,e,r)}),e}});var Yn=m((Ag,Au)=>{"use strict";Au.exports=function(e){return!!(e&&e.__CANCEL__)}});var Pu=m((Og,Cu)=>{"use strict";var Ou=Y(),Qn=Ru(),Jd=Yn(),zd=Dt(),$d=qt();function Zn(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new $d("canceled")}Cu.exports=function(e){Zn(e),e.headers=e.headers||{},e.data=Qn.call(e,e.data,e.headers,e.transformRequest),e.headers=Ou.merge(e.headers.common||{},e.headers[e.method]||{},e.headers),Ou.forEach(["delete","get","head","post","put","patch","common"],function(i){delete e.headers[i]});var r=e.adapter||zd.adapter;return r(e).then(function(i){return Zn(e),i.data=Qn.call(e,i.data,i.headers,e.transformResponse),i},function(i){return Jd(i)||(Zn(e),i&&i.response&&(i.response.data=Qn.call(e,i.response.data,i.response.headers,e.transformResponse))),Promise.reject(i)})}});var ei=m((Cg,Nu)=>{"use strict";var ne=Y();Nu.exports=function(e,r){r=r||{};var n={};function i(u,d){return ne.isPlainObject(u)&&ne.isPlainObject(d)?ne.merge(u,d):ne.isPlainObject(d)?ne.merge({},d):ne.isArray(d)?d.slice():d}function s(u){if(ne.isUndefined(r[u])){if(!ne.isUndefined(e[u]))return i(void 0,e[u])}else return i(e[u],r[u])}function o(u){if(!ne.isUndefined(r[u]))return i(void 0,r[u])}function a(u){if(ne.isUndefined(r[u])){if(!ne.isUndefined(e[u]))return i(void 0,e[u])}else return i(void 0,r[u])}function c(u){if(u in r)return i(e[u],r[u]);if(u in e)return i(void 0,e[u])}var f={url:o,method:o,data:o,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:c};return ne.forEach(Object.keys(e).concat(Object.keys(r)),function(d){var l=f[d]||s,h=l(d);ne.isUndefined(h)&&l!==c||(n[d]=h)}),n}});var ti=m((Pg,Iu)=>{Iu.exports={version:"0.23.0"}});var qu=m((Ng,ku)=>{"use strict";var Wd=ti().version,ri={};["object","boolean","number","function","string","symbol"].forEach(function(t,e){ri[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});var _u={};ri.transitional=function(e,r,n){function i(s,o){return"[Axios v"+Wd+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return function(s,o,a){if(e===!1)throw new Error(i(o," has been removed"+(r?" in "+r:"")));return r&&!_u[o]&&(_u[o]=!0,console.warn(i(o," has been deprecated since v"+r+" and will be removed in the near future"))),e?e(s,o,a):!0}};function Kd(t,e,r){if(typeof t!="object")throw new TypeError("options must be an object");for(var n=Object.keys(t),i=n.length;i-- >0;){var s=n[i],o=e[s];if(o){var a=t[s],c=a===void 0||o(a,s,t);if(c!==!0)throw new TypeError("option "+s+" must be "+c);continue}if(r!==!0)throw Error("Unknown option "+s)}}ku.exports={assertOptions:Kd,validators:ri}});var Bu=m((Ig,ju)=>{"use strict";var Mu=Y(),Xd=Gn(),Du=Za(),Uu=Pu(),Nr=ei(),Lu=qu(),nt=Lu.validators;function Ut(t){this.defaults=t,this.interceptors={request:new Du,response:new Du}}Ut.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=Nr(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&&Lu.assertOptions(r,{silentJSONParsing:nt.transitional(nt.boolean),forcedJSONParsing:nt.transitional(nt.boolean),clarifyTimeoutError:nt.transitional(nt.boolean)},!1);var n=[],i=!0;this.interceptors.request.forEach(function(l){typeof l.runWhen=="function"&&l.runWhen(e)===!1||(i=i&&l.synchronous,n.unshift(l.fulfilled,l.rejected))});var s=[];this.interceptors.response.forEach(function(l){s.push(l.fulfilled,l.rejected)});var o;if(!i){var a=[Uu,void 0];for(Array.prototype.unshift.apply(a,n),a=a.concat(s),o=Promise.resolve(e);a.length;)o=o.then(a.shift(),a.shift());return o}for(var c=e;n.length;){var f=n.shift(),u=n.shift();try{c=f(c)}catch(d){u(d);break}}try{o=Uu(c)}catch(d){return Promise.reject(d)}for(;s.length;)o=o.then(s.shift(),s.shift());return o};Ut.prototype.getUri=function(e){return e=Nr(this.defaults,e),Xd(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")};Mu.forEach(["delete","get","head","options"],function(e){Ut.prototype[e]=function(r,n){return this.request(Nr(n||{},{method:e,url:r,data:(n||{}).data}))}});Mu.forEach(["post","put","patch"],function(e){Ut.prototype[e]=function(r,n,i){return this.request(Nr(i||{},{method:e,url:r,data:n}))}});ju.exports=Ut});var Vu=m((_g,Fu)=>{"use strict";var Yd=qt();function it(t){if(typeof t!="function")throw new TypeError("executor must be a function.");var e;this.promise=new Promise(function(i){e=i});var r=this;this.promise.then(function(n){if(!!r._listeners){var i,s=r._listeners.length;for(i=0;i<s;i++)r._listeners[i](n);r._listeners=null}}),this.promise.then=function(n){var i,s=new Promise(function(o){r.subscribe(o),i=o}).then(n);return s.cancel=function(){r.unsubscribe(i)},s},t(function(i){r.reason||(r.reason=new Yd(i),e(r.reason))})}it.prototype.throwIfRequested=function(){if(this.reason)throw this.reason};it.prototype.subscribe=function(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]};it.prototype.unsubscribe=function(e){if(!!this._listeners){var r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}};it.source=function(){var e,r=new it(function(i){e=i});return{token:r,cancel:e}};Fu.exports=it});var Gu=m((kg,Hu)=>{"use strict";Hu.exports=function(e){return function(n){return e.apply(null,n)}}});var zu=m((qg,Ju)=>{"use strict";Ju.exports=function(e){return typeof e=="object"&&e.isAxiosError===!0}});var Ku=m((Dg,ni)=>{"use strict";var $u=Y(),Qd=jn(),Ir=Bu(),Zd=ei(),eh=Dt();function Wu(t){var e=new Ir(t),r=Qd(Ir.prototype.request,e);return $u.extend(r,Ir.prototype,e),$u.extend(r,e),r.create=function(i){return Wu(Zd(t,i))},r}var he=Wu(eh);he.Axios=Ir;he.Cancel=qt();he.CancelToken=Vu();he.isCancel=Yn();he.VERSION=ti().version;he.all=function(e){return Promise.all(e)};he.spread=Gu();he.isAxiosError=zu();ni.exports=he;ni.exports.default=he});var ii=m((Ug,Xu)=>{Xu.exports=Ku()});var v=function(){return v=Object.assign||function(e){for(var r,n=1,i=arguments.length;n<i;n++){r=arguments[n];for(var s in r)Object.prototype.hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e},v.apply(this,arguments)};function je(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(t!=null&&typeof Object.getOwnPropertySymbols=="function")for(var i=0,n=Object.getOwnPropertySymbols(t);i<n.length;i++)e.indexOf(n[i])<0&&Object.prototype.propertyIsEnumerable.call(t,n[i])&&(r[n[i]]=t[n[i]]);return r}function b(t){var e=typeof Symbol=="function"&&Symbol.iterator,r=e&&t[e],n=0;if(r)return r.call(t);if(t&&typeof t.length=="number")return{next:function(){return t&&n>=t.length&&(t=void 0),{value:t&&t[n++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}function R(t,e){var r=typeof Symbol=="function"&&t[Symbol.iterator];if(!r)return t;var n=r.call(t),i,s=[],o;try{for(;(e===void 0||e-- >0)&&!(i=n.next()).done;)s.push(i.value)}catch(a){o={error:a}}finally{try{i&&!i.done&&(r=n.return)&&r.call(n)}finally{if(o)throw o.error}}return s}function _(t,e,r){if(r||arguments.length===2)for(var n=0,i=e.length,s;n<i;n++)(s||!(n in e))&&(s||(s=Array.prototype.slice.call(e,0,n)),s[n]=e[n]);return t.concat(s||Array.prototype.slice.call(e))}var P;(function(t){t.Start="xstate.start",t.Stop="xstate.stop",t.Raise="xstate.raise",t.Send="xstate.send",t.Cancel="xstate.cancel",t.NullEvent="",t.Assign="xstate.assign",t.After="xstate.after",t.DoneState="done.state",t.DoneInvoke="done.invoke",t.Log="xstate.log",t.Init="xstate.init",t.Invoke="xstate.invoke",t.ErrorExecution="error.execution",t.ErrorCommunication="error.communication",t.ErrorPlatform="error.platform",t.ErrorCustom="xstate.error",t.Update="xstate.update",t.Pure="xstate.pure",t.Choose="xstate.choose"})(P||(P={}));var ge;(function(t){t.Parent="#_parent",t.Internal="#_internal"})(ge||(ge={}));var ot=P.Start,Be=P.Stop,Fe=P.Raise,Te=P.Send,jt=P.Cancel,ci=P.NullEvent,Bt=P.Assign,sh=P.After,oh=P.DoneState,Ft=P.Log,fi=P.Init,at=P.Invoke,ah=P.ErrorExecution,kr=P.ErrorPlatform,qr=P.ErrorCustom,ut=P.Update,li=P.Choose,di=P.Pure;var Vt=".",Dr={},Ht="xstate.guard",hi="";var D=!0;var Gt;function ft(t,e,r){r===void 0&&(r=Vt);var n=Ve(t,r),i=Ve(e,r);return A(i)?A(n)?i===n:!1:A(n)?n in i:Object.keys(n).every(function(s){return s in i?ft(n[s],i[s]):!1})}function Jt(t){try{return A(t)||typeof t=="number"?"".concat(t):t.type}catch{throw new Error("Events must be strings or objects with a string event.type property.")}}function zt(t,e){try{return pe(t)?t:t.toString().split(e)}catch{throw new Error("'".concat(t,"' is not a valid state path."))}}function uc(t){return typeof t=="object"&&"value"in t&&"context"in t&&"event"in t&&"_event"in t}function Ve(t,e){if(uc(t))return t.value;if(pe(t))return ct(t);if(typeof t!="string")return t;var r=zt(t,e);return ct(r)}function ct(t){if(t.length===1)return t[0];for(var e={},r=e,n=0;n<t.length-1;n++)n===t.length-2?r[t[n]]=t[n+1]:(r[t[n]]={},r=r[t[n]]);return e}function He(t,e){for(var r={},n=Object.keys(t),i=0;i<n.length;i++){var s=n[i];r[s]=e(t[s],s,t,i)}return r}function Ur(t,e,r){var n,i,s={};try{for(var o=b(Object.keys(t)),a=o.next();!a.done;a=o.next()){var c=a.value,f=t[c];!r(f)||(s[c]=e(f,c,t))}}catch(u){n={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}var pi=function(t){return function(e){var r,n,i=e;try{for(var s=b(t),o=s.next();!o.done;o=s.next()){var a=o.value;i=i[a]}}catch(c){r={error:c}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}};function mi(t,e){return function(r){var n,i,s=r;try{for(var o=b(t),a=o.next();!a.done;a=o.next()){var c=a.value;s=s[e][c]}}catch(f){n={error:f}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}}function lt(t){if(!t)return[[]];if(A(t))return[[t]];var e=q(Object.keys(t).map(function(r){var n=t[r];return typeof n!="string"&&(!n||!Object.keys(n).length)?[[r]]:lt(t[r]).map(function(i){return[r].concat(i)})}));return e}function q(t){var e;return(e=[]).concat.apply(e,_([],R(t),!1))}function vi(t){return pe(t)?t:[t]}function te(t){return t===void 0?[]:vi(t)}function be(t,e,r){var n,i;if(N(t))return t(e,r.data);var s={};try{for(var o=b(Object.keys(t)),a=o.next();!a.done;a=o.next()){var c=a.value,f=t[c];N(f)?s[c]=f(e,r.data):s[c]=f}}catch(u){n={error:u}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}function yi(t){return/^(done|error)\./.test(t)}function Mr(t){return!!(t instanceof Promise||t!==null&&(N(t)||typeof t=="object")&&N(t.then))}function gi(t){return t!==null&&typeof t=="object"&&"transition"in t&&typeof t.transition=="function"}function $t(t,e){var r,n,i=R([[],[]],2),s=i[0],o=i[1];try{for(var a=b(t),c=a.next();!c.done;c=a.next()){var f=c.value;e(f)?s.push(f):o.push(f)}}catch(u){r={error:u}}finally{try{c&&!c.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return[s,o]}function Ei(t,e){return He(t.states,function(r,n){if(!!r){var i=(A(e)?void 0:e[n])||(r?r.current:void 0);if(!!i)return{current:i,states:Ei(r,i)}}})}function Si(t,e){return{current:e,states:Ei(t,e)}}function Lr(t,e,r,n){D||L(!!t,"Attempting to update undefined context");var i=t&&r.reduce(function(s,o){var a,c,f=o.assignment,u={state:n,action:o,_event:e},d={};if(N(f))d=f(s,e.data,u);else try{for(var l=b(Object.keys(f)),h=l.next();!h.done;h=l.next()){var g=h.value,E=f[g];d[g]=N(E)?E(s,e.data,u):E}}catch(p){a={error:p}}finally{try{h&&!h.done&&(c=l.return)&&c.call(l)}finally{if(a)throw a.error}}return Object.assign({},s,d)},t);return i}var L=function(){};D||(L=function(t,e){var r=t instanceof Error?t:void 0;if(!(!r&&t)&&console!==void 0){var n=["Warning: ".concat(e)];r&&n.push(r),console.warn.apply(console,n)}});function pe(t){return Array.isArray(t)}function N(t){return typeof t=="function"}function A(t){return typeof t=="string"}function Wt(t,e){if(!!t)return A(t)?{type:Ht,name:t,predicate:e?e[t]:void 0}:N(t)?{type:Ht,name:t.name,predicate:t}:t}function wi(t){try{return"subscribe"in t&&N(t.subscribe)}catch{return!1}}var ce=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}(),ph=(Gt={},Gt[ce]=function(){return this},Gt[Symbol.observable]=function(){return this},Gt);function fe(t){return!!t&&"__xstatenode"in t}function xi(t){return!!t&&typeof t.send=="function"}function dt(t,e){return A(t)||typeof t=="number"?v({type:t},e):t}function F(t,e){if(!A(t)&&"$$type"in t&&t.$$type==="scxml")return t;var r=dt(t);return v({name:r.type,data:r,$$type:"scxml",type:"external"},e)}function Re(t,e){var r=vi(e).map(function(n){return typeof n=="undefined"||typeof n=="string"||fe(n)?{target:n,event:t}:v(v({},n),{event:t})});return r}function Ti(t){if(!(t===void 0||t===hi))return te(t)}function bi(t,e,r){if(!D){var n=t.stack?" Stacktrace was '".concat(t.stack,"'"):"";if(t===e)console.error("Missing onError handler for invocation '".concat(r,"', error was '").concat(t,"'.").concat(n));else{var i=e.stack?" Stacktrace was '".concat(e.stack,"'"):"";console.error("Missing onError handler and/or unhandled exception/promise rejection for invocation '".concat(r,"'. ")+"Original error: '".concat(t,"'. ").concat(n," Current error is '").concat(e,"'.").concat(i))}}}function Kt(t,e,r,n,i){var s=t.options.guards,o={state:i,cond:e,_event:n};if(e.type===Ht)return((s==null?void 0:s[e.name])||e.predicate)(r,n.data,o);var a=s==null?void 0:s[e.type];if(!a)throw new Error("Guard '".concat(e.type,"' is not implemented on machine '").concat(t.id,"'."));return a(r,n.data,o)}function Xt(t){return typeof t=="string"?{type:t}:t}function ht(t,e,r){if(typeof t=="object")return t;var n=function(){};return{next:t,error:e||n,complete:r||n}}function pt(t,e){return"".concat(t,":invocation[").concat(e,"]")}var Ae=F({type:fi});function Yt(t,e){return e&&e[t]||void 0}function Ge(t,e){var r;if(A(t)||typeof t=="number"){var n=Yt(t,e);N(n)?r={type:t,exec:n}:n?r=n:r={type:t,exec:void 0}}else if(N(t))r={type:t.name||t.toString(),exec:t};else{var n=Yt(t.type,e);if(N(n))r=v(v({},t),{exec:n});else if(n){var i=n.type||t.type;r=v(v(v({},n),t),{type:i})}else r=t}return r}var mt=function(t,e){if(!t)return[];var r=pe(t)?t:[t];return r.map(function(n){return Ge(n,e)})};function Zt(t){var e=Ge(t);return v(v({id:A(t)?t:e.id},e),{type:e.type})}function Ri(t){return A(t)?{type:Fe,event:t}:vt(t,{to:ge.Internal})}function cc(t){return{type:Fe,_event:F(t.event)}}function vt(t,e){return{to:e?e.to:void 0,type:Te,event:N(t)?t:dt(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:N(t)?t.name:Jt(t)}}function fc(t,e,r,n){var i={_event:r},s=F(N(t.event)?t.event(e,r.data,i):t.event),o;if(A(t.delay)){var a=n&&n[t.delay];o=N(a)?a(e,r.data,i):a}else o=N(t.delay)?t.delay(e,r.data,i):t.delay;var c=N(t.to)?t.to(e,r.data,i):t.to;return v(v({},t),{to:c,_event:s,event:s.data,delay:o})}var lc=function(t,e,r){return v(v({},t),{value:A(t.expr)?t.expr:t.expr(e,r.data,{_event:r})})},Ai=function(t){return{type:jt,sendId:t}};function Oi(t){var e=Zt(t);return{type:P.Start,activity:e,exec:void 0}}function Ci(t){var e=N(t)?t:Zt(t);return{type:P.Stop,activity:e,exec:void 0}}function dc(t,e,r){var n=N(t.activity)?t.activity(e,r.data):t.activity,i=typeof n=="string"?{id:n}:n,s={type:P.Stop,activity:i};return s}var Pi=function(t){return{type:Bt,assignment:t}};function Ni(t,e){var r=e?"#".concat(e):"";return"".concat(P.After,"(").concat(t,")").concat(r)}function yt(t,e){var r="".concat(P.DoneState,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Oe(t,e){var r="".concat(P.DoneInvoke,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Ce(t,e){var r="".concat(P.ErrorPlatform,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Qt(t,e,r,n,i,s){s===void 0&&(s=!1);var o=R(s?[[],i]:$t(i,function(l){return l.type===Bt}),2),a=o[0],c=o[1],f=a.length?Lr(r,n,a,e):r,u=s?[r]:void 0,d=q(c.map(function(l){var h;switch(l.type){case Fe:return cc(l);case Te:var g=fc(l,f,n,t.options.delays);return D||L(!A(l.delay)||typeof g.delay=="number","No delay reference for delay expression '".concat(l.delay,"' was found on machine '").concat(t.id,"'")),g;case Ft:return lc(l,f,n);case li:{var E=l,p=(h=E.conds.find(function(U){var V=Wt(U.cond,t.options.guards);return!V||Kt(t,V,f,n,e)}))===null||h===void 0?void 0:h.actions;if(!p)return[];var w=R(Qt(t,e,f,n,mt(te(p),t.options.actions),s),2),y=w[0],x=w[1];return f=x,u==null||u.push(f),y}case di:{var p=l.get(f,n.data);if(!p)return[];var C=R(Qt(t,e,f,n,mt(te(p),t.options.actions),s),2),I=C[0],B=C[1];return f=B,u==null||u.push(f),I}case Be:return dc(l,f,n);case Bt:{f=Lr(f,n,[l],e),u==null||u.push(f);break}default:var T=Ge(l,t.options.actions),S=T.exec;if(S&&u){var O=u.length-1;T=v(v({},T),{exec:function(U){for(var V=[],Q=1;Q<arguments.length;Q++)V[Q-1]=arguments[Q];S.apply(void 0,_([u[O]],R(V),!1))}})}return T}}).filter(function(l){return!!l}));return[d,f]}var Ii=[],Pe=function(t,e){Ii.push(t);var r=e(t);return Ii.pop(),r};function _i(t){var e;return e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}},e[ce]=function(){return this},e}function ki(t,e,r,n){var i,s=Xt(t.src),o=(i=e==null?void 0:e.options.services)===null||i===void 0?void 0:i[s.type],a=t.data?be(t.data,r,n):void 0,c=o?qi(o,t.id,a):_i(t.id);return c.meta=t,c}function qi(t,e,r){var n=_i(e);if(n.deferred=!0,fe(t)){var i=n.state=Pe(void 0,function(){return(r?t.withContext(r):t).initialState});n.getSnapshot=function(){return i}}return n}function hc(t){try{return typeof t.send=="function"}catch{return!1}}function Di(t){return hc(t)&&"id"in t}function Ui(t){var e;return v((e={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}},e[ce]=function(){return this},e),t)}var gt=function(t){return t.type==="atomic"||t.type==="final"};function Ne(t){return Object.keys(t.states).map(function(e){return t.states[e]})}function Br(t){var e=[t];return gt(t)?e:e.concat(q(Ne(t).map(Br)))}function Ie(t,e){var r,n,i,s,o,a,c,f,u=new Set(t),d=jr(u),l=new Set(e);try{for(var h=b(l),g=h.next();!g.done;g=h.next())for(var E=g.value,p=E.parent;p&&!l.has(p);)l.add(p),p=p.parent}catch(O){r={error:O}}finally{try{g&&!g.done&&(n=h.return)&&n.call(h)}finally{if(r)throw r.error}}var w=jr(l);try{for(var y=b(l),x=y.next();!x.done;x=y.next()){var E=x.value;if(E.type==="compound"&&(!w.get(E)||!w.get(E).length))d.get(E)?d.get(E).forEach(function(U){return l.add(U)}):E.initialStateNodes.forEach(function(U){return l.add(U)});else if(E.type==="parallel")try{for(var C=(o=void 0,b(Ne(E))),I=C.next();!I.done;I=C.next()){var B=I.value;B.type!=="history"&&(l.has(B)||(l.add(B),d.get(B)?d.get(B).forEach(function(U){return l.add(U)}):B.initialStateNodes.forEach(function(U){return l.add(U)})))}}catch(U){o={error:U}}finally{try{I&&!I.done&&(a=C.return)&&a.call(C)}finally{if(o)throw o.error}}}}catch(O){i={error:O}}finally{try{x&&!x.done&&(s=y.return)&&s.call(y)}finally{if(i)throw i.error}}try{for(var T=b(l),S=T.next();!S.done;S=T.next())for(var E=S.value,p=E.parent;p&&!l.has(p);)l.add(p),p=p.parent}catch(O){c={error:O}}finally{try{S&&!S.done&&(f=T.return)&&f.call(T)}finally{if(c)throw c.error}}return l}function Mi(t,e){var r=e.get(t);if(!r)return{};if(t.type==="compound"){var n=r[0];if(n){if(gt(n))return n.key}else return{}}var i={};return r.forEach(function(s){i[s.key]=Mi(s,e)}),i}function jr(t){var e,r,n=new Map;try{for(var i=b(t),s=i.next();!s.done;s=i.next()){var o=s.value;n.has(o)||n.set(o,[]),o.parent&&(n.has(o.parent)||n.set(o.parent,[]),n.get(o.parent).push(o))}}catch(a){e={error:a}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n}function Li(t,e){var r=Ie([t],e);return Mi(t,jr(r))}function Et(t,e){return Array.isArray(t)?t.some(function(r){return r===e}):t instanceof Set?t.has(e):!1}function ji(t){return _([],R(new Set(q(_([],R(t.map(function(e){return e.ownEvents})),!1)))),!1)}function _e(t,e){return e.type==="compound"?Ne(e).some(function(r){return r.type==="final"&&Et(t,r)}):e.type==="parallel"?Ne(e).every(function(r){return _e(t,r)}):!1}function Bi(t){return t===void 0&&(t=[]),t.reduce(function(e,r){return r.meta!==void 0&&(e[r.id]=r.meta),e},{})}function Fr(t){return new Set(q(t.map(function(e){return e.tags})))}function Vr(t,e){if(t===e)return!0;if(t===void 0||e===void 0)return!1;if(A(t)||A(e))return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(i){return Vr(t[i],e[i])})}function Fi(t){return typeof t!="object"||t===null?!1:"value"in t&&"_event"in t}function Vi(t,e){var r=t.exec,n=v(v({},t),{exec:r!==void 0?function(){return r(e.context,e.event,{action:t,state:e,_event:e._event})}:void 0});return n}var se=function(){function t(e){var r=this,n;this.actions=[],this.activities=Dr,this.meta={},this.events=[],this.value=e.value,this.context=e.context,this._event=e._event,this._sessionid=e._sessionid,this.event=this._event.data,this.historyValue=e.historyValue,this.history=e.history,this.actions=e.actions||[],this.activities=e.activities||Dr,this.meta=Bi(e.configuration),this.events=e.events||[],this.matches=this.matches.bind(this),this.toStrings=this.toStrings.bind(this),this.configuration=e.configuration,this.transitions=e.transitions,this.children=e.children,this.done=!!e.done,this.tags=(n=Array.isArray(e.tags)?new Set(e.tags):e.tags)!==null&&n!==void 0?n:new Set,this.machine=e.machine,Object.defineProperty(this,"nextEvents",{get:function(){return ji(r.configuration)}})}return t.from=function(e,r){if(e instanceof t)return e.context!==r?new t({value:e.value,context:r,_event:e._event,_sessionid:null,historyValue:e.historyValue,history:e.history,actions:[],activities:e.activities,meta:{},events:[],configuration:[],transitions:[],children:{}}):e;var n=Ae;return new t({value:e,context:r,_event:n,_sessionid:null,historyValue:void 0,history:void 0,actions:[],activities:void 0,meta:void 0,events:[],configuration:[],transitions:[],children:{}})},t.create=function(e){return new t(e)},t.inert=function(e,r){if(e instanceof t){if(!e.actions.length)return e;var n=Ae;return new t({value:e.value,context:r,_event:n,_sessionid:null,historyValue:e.historyValue,history:e.history,activities:e.activities,configuration:e.configuration,transitions:[],children:{}})}return t.from(e,r)},t.prototype.toStrings=function(e,r){var n=this;if(e===void 0&&(e=this.value),r===void 0&&(r="."),A(e))return[e];var i=Object.keys(e);return i.concat.apply(i,_([],R(i.map(function(s){return n.toStrings(e[s],r).map(function(o){return s+r+o})})),!1))},t.prototype.toJSON=function(){var e=this;e.configuration,e.transitions;var r=e.tags;e.machine;var n=je(e,["configuration","transitions","tags","machine"]);return v(v({},n),{tags:Array.from(r)})},t.prototype.matches=function(e){return ft(e,this.value)},t.prototype.hasTag=function(e){return this.tags.has(e)},t.prototype.can=function(e){var r;D&&L(!!this.machine,"state.can(...) used outside of a machine-created State object; this will always return false.");var n=(r=this.machine)===null||r===void 0?void 0:r.getTransitionData(this,e);return!!(n!=null&&n.transitions.length)&&n.transitions.some(function(i){return i.target!==void 0||i.actions.length})},t}();var pc={deferEvents:!1},Hr=function(){function t(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=v(v({},pc),e)}return t.prototype.initialize=function(e){if(this.initialized=!0,e){if(!this.options.deferEvents){this.schedule(e);return}this.process(e)}this.flushEvents()},t.prototype.schedule=function(e){if(!this.initialized||this.processingEvent){this.queue.push(e);return}if(this.queue.length!==0)throw new Error("Event queue should be empty when it is not processing events");this.process(e),this.flushEvents()},t.prototype.clear=function(){this.queue=[]},t.prototype.flushEvents=function(){for(var e=this.queue.shift();e;)this.process(e),e=this.queue.shift()},t.prototype.process=function(e){this.processingEvent=!0;try{e()}catch(r){throw this.clear(),r}finally{this.processingEvent=!1}},t}();var Gr=new Map,mc=0,St={bookId:function(){return"x:".concat(mc++)},register:function(t,e){return Gr.set(t,e),t},get:function(t){return Gr.get(t)},free:function(t){Gr.delete(t)}};function er(){if(typeof globalThis!="undefined")return globalThis;if(typeof self!="undefined")return self;if(typeof window!="undefined")return window;if(typeof global!="undefined")return global;D||console.warn("XState could not find a global object in this environment. Please let the maintainers know and raise an issue here: https://github.com/statelyai/xstate/issues")}function vc(){var t=er();if(t&&"__xstate__"in t)return t.__xstate__}function Hi(t){if(!!er()){var e=vc();e&&e.register(t)}}function Gi(t,e){e===void 0&&(e={});var r=t.initialState,n=new Set,i=[],s=!1,o=function(){if(!s){for(s=!0;i.length>0;){var f=i.shift();r=t.transition(r,f,c),n.forEach(function(u){return u.next(r)})}s=!1}},a=Ui({id:e.id,send:function(f){i.push(f),o()},getSnapshot:function(){return r},subscribe:function(f,u,d){var l=ht(f,u,d);return n.add(l),l.next(r),{unsubscribe:function(){n.delete(l)}}}}),c={parent:e.parent,self:a,id:e.id||"anonymous",observers:n};return r=t.start?t.start(c):r,a}var yc={sync:!1,autoForward:!1},z;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(z||(z={}));var Ji=function(){function t(e,r){var n=this;r===void 0&&(r=t.defaultOptions),this.machine=e,this.scheduler=new Hr,this.delayedEventsMap={},this.listeners=new Set,this.contextListeners=new Set,this.stopListeners=new Set,this.doneListeners=new Set,this.eventListeners=new Set,this.sendListeners=new Set,this.initialized=!1,this.status=z.NotStarted,this.children=new Map,this.forwardTo=new Set,this.init=this.start,this.send=function(u,d){if(pe(u))return n.batch(u),n.state;var l=F(dt(u,d));if(n.status===z.Stopped)return D||L(!1,'Event "'.concat(l.name,'" was sent to stopped service "').concat(n.machine.id,`". This service has already reached its final state, and will not transition.
|
|
5
|
+
Event: `).concat(JSON.stringify(l.data))),n.state;if(n.status!==z.Running&&!n.options.deferEvents)throw new Error('Event "'.concat(l.name,'" was sent to uninitialized service "').concat(n.machine.id,`". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.
|
|
6
|
+
Event: `).concat(JSON.stringify(l.data)));return n.scheduler.schedule(function(){n.forward(l);var h=n.nextState(l);n.update(h,l)}),n._state},this.sendTo=function(u,d){var l=n.parent&&(d===ge.Parent||n.parent.id===d),h=l?n.parent:A(d)?n.children.get(d)||St.get(d):xi(d)?d:void 0;if(!h){if(!l)throw new Error("Unable to send event to child '".concat(d,"' from service '").concat(n.id,"'."));D||L(!1,"Service '".concat(n.id,"' has no parent: unable to send event ").concat(u.type));return}"machine"in h?h.send(v(v({},u),{name:u.name===qr?"".concat(Ce(n.id)):u.name,origin:n.sessionId})):h.send(u.data)};var i=v(v({},t.defaultOptions),r),s=i.clock,o=i.logger,a=i.parent,c=i.id,f=c!==void 0?c:e.id;this.id=f,this.logger=o,this.clock=s,this.parent=a,this.options=i,this.scheduler=new Hr({deferEvents:this.options.deferEvents}),this.sessionId=St.bookId()}return Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:Pe(this,function(){return e._initialState=e.machine.initialState,e._initialState})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return D||L(this.status!==z.NotStarted,"Attempted to read state from uninitialized service '".concat(this.id,"'. Make sure the service is started first.")),this._state},enumerable:!1,configurable:!0}),t.prototype.execute=function(e,r){var n,i;try{for(var s=b(e.actions),o=s.next();!o.done;o=s.next()){var a=o.value;this.exec(a,e,r)}}catch(c){n={error:c}}finally{try{o&&!o.done&&(i=s.return)&&i.call(s)}finally{if(n)throw n.error}}},t.prototype.update=function(e,r){var n,i,s,o,a,c,f,u,d=this;if(e._sessionid=this.sessionId,this._state=e,this.options.execute&&this.execute(this.state),this.children.forEach(function(O){d.state.children[O.id]=O}),this.devTools&&this.devTools.send(r.data,e),e.event)try{for(var l=b(this.eventListeners),h=l.next();!h.done;h=l.next()){var g=h.value;g(e.event)}}catch(O){n={error:O}}finally{try{h&&!h.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}try{for(var E=b(this.listeners),p=E.next();!p.done;p=E.next()){var g=p.value;g(e,e.event)}}catch(O){s={error:O}}finally{try{p&&!p.done&&(o=E.return)&&o.call(E)}finally{if(s)throw s.error}}try{for(var w=b(this.contextListeners),y=w.next();!y.done;y=w.next()){var x=y.value;x(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(O){a={error:O}}finally{try{y&&!y.done&&(c=w.return)&&c.call(w)}finally{if(a)throw a.error}}var C=_e(e.configuration||[],this.machine);if(this.state.configuration&&C){var I=e.configuration.find(function(O){return O.type==="final"&&O.parent===d.machine}),B=I&&I.doneData?be(I.doneData,e.context,r):void 0;try{for(var T=b(this.doneListeners),S=T.next();!S.done;S=T.next()){var g=S.value;g(Oe(this.id,B))}}catch(O){f={error:O}}finally{try{S&&!S.done&&(u=T.return)&&u.call(T)}finally{if(f)throw f.error}}this.stop()}},t.prototype.onTransition=function(e){return this.listeners.add(e),this.status===z.Running&&e(this.state,this.state.event),this},t.prototype.subscribe=function(e,r,n){var i=this;if(!e)return{unsubscribe:function(){}};var s,o=n;return typeof e=="function"?s=e:(s=e.next.bind(e),o=e.complete.bind(e)),this.listeners.add(s),this.status===z.Running&&s(this.state),o&&this.onDone(o),{unsubscribe:function(){s&&i.listeners.delete(s),o&&i.doneListeners.delete(o)}}},t.prototype.onEvent=function(e){return this.eventListeners.add(e),this},t.prototype.onSend=function(e){return this.sendListeners.add(e),this},t.prototype.onChange=function(e){return this.contextListeners.add(e),this},t.prototype.onStop=function(e){return this.stopListeners.add(e),this},t.prototype.onDone=function(e){return this.doneListeners.add(e),this},t.prototype.off=function(e){return this.listeners.delete(e),this.eventListeners.delete(e),this.sendListeners.delete(e),this.stopListeners.delete(e),this.doneListeners.delete(e),this.contextListeners.delete(e),this},t.prototype.start=function(e){var r=this;if(this.status===z.Running)return this;this.machine._init(),St.register(this.sessionId,this),this.initialized=!0,this.status=z.Running;var n=e===void 0?this.initialState:Pe(this,function(){return Fi(e)?r.machine.resolveState(e):r.machine.resolveState(se.from(e,r.machine.context))});return this.options.devTools&&this.attachDev(),this.scheduler.initialize(function(){r.update(n,Ae)}),this},t.prototype.stop=function(){var e,r,n,i,s,o,a,c,f,u,d=this;try{for(var l=b(this.listeners),h=l.next();!h.done;h=l.next()){var g=h.value;this.listeners.delete(g)}}catch(S){e={error:S}}finally{try{h&&!h.done&&(r=l.return)&&r.call(l)}finally{if(e)throw e.error}}try{for(var E=b(this.stopListeners),p=E.next();!p.done;p=E.next()){var g=p.value;g(),this.stopListeners.delete(g)}}catch(S){n={error:S}}finally{try{p&&!p.done&&(i=E.return)&&i.call(E)}finally{if(n)throw n.error}}try{for(var w=b(this.contextListeners),y=w.next();!y.done;y=w.next()){var g=y.value;this.contextListeners.delete(g)}}catch(S){s={error:S}}finally{try{y&&!y.done&&(o=w.return)&&o.call(w)}finally{if(s)throw s.error}}try{for(var x=b(this.doneListeners),C=x.next();!C.done;C=x.next()){var g=C.value;this.doneListeners.delete(g)}}catch(S){a={error:S}}finally{try{C&&!C.done&&(c=x.return)&&c.call(x)}finally{if(a)throw a.error}}if(!this.initialized)return this;_([],R(this.state.configuration),!1).sort(function(S,O){return O.order-S.order}).forEach(function(S){var O,U;try{for(var V=b(S.definition.exit),Q=V.next();!Q.done;Q=V.next()){var ye=Q.value;d.exec(ye,d.state)}}catch(Mt){O={error:Mt}}finally{try{Q&&!Q.done&&(U=V.return)&&U.call(V)}finally{if(O)throw O.error}}}),this.children.forEach(function(S){N(S.stop)&&S.stop()});try{for(var I=b(Object.keys(this.delayedEventsMap)),B=I.next();!B.done;B=I.next()){var T=B.value;this.clock.clearTimeout(this.delayedEventsMap[T])}}catch(S){f={error:S}}finally{try{B&&!B.done&&(u=I.return)&&u.call(I)}finally{if(f)throw f.error}}return this.scheduler.clear(),this.initialized=!1,this.status=z.Stopped,St.free(this.sessionId),this},t.prototype.batch=function(e){var r=this;if(this.status===z.NotStarted&&this.options.deferEvents)D||L(!1,"".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,`" and are deferred. Make sure .start() is called for this service.
|
|
7
|
+
Event: `).concat(JSON.stringify(event)));else if(this.status!==z.Running)throw new Error("".concat(e.length,' event(s) were sent to uninitialized service "').concat(this.machine.id,'". Make sure .start() is called for this service, or set { deferEvents: true } in the service options.'));this.scheduler.schedule(function(){var n,i,s=r.state,o=!1,a=[],c=function(l){var h=F(l);r.forward(h),s=Pe(r,function(){return r.machine.transition(s,h)}),a.push.apply(a,_([],R(s.actions.map(function(g){return Vi(g,s)})),!1)),o=o||!!s.changed};try{for(var f=b(e),u=f.next();!u.done;u=f.next()){var d=u.value;c(d)}}catch(l){n={error:l}}finally{try{u&&!u.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}s.changed=o,s.actions=a,r.update(s,F(e[e.length-1]))})},t.prototype.sender=function(e){return this.send.bind(this,e)},t.prototype.nextState=function(e){var r=this,n=F(e);if(n.name.indexOf(kr)===0&&!this.state.nextEvents.some(function(s){return s.indexOf(kr)===0}))throw n.data.data;var i=Pe(this,function(){return r.machine.transition(r.state,n)});return i},t.prototype.forward=function(e){var r,n;try{for(var i=b(this.forwardTo),s=i.next();!s.done;s=i.next()){var o=s.value,a=this.children.get(o);if(!a)throw new Error("Unable to forward event '".concat(e,"' from interpreter '").concat(this.id,"' to nonexistant child '").concat(o,"'."));a.send(e)}}catch(c){r={error:c}}finally{try{s&&!s.done&&(n=i.return)&&n.call(i)}finally{if(r)throw r.error}}},t.prototype.defer=function(e){var r=this;this.delayedEventsMap[e.id]=this.clock.setTimeout(function(){e.to?r.sendTo(e._event,e.to):r.send(e._event)},e.delay)},t.prototype.cancel=function(e){this.clock.clearTimeout(this.delayedEventsMap[e]),delete this.delayedEventsMap[e]},t.prototype.exec=function(e,r,n){n===void 0&&(n=this.machine.options.actions);var i=r.context,s=r._event,o=e.exec||Yt(e.type,n),a=N(o)?o:o?o.exec:e.exec;if(a)try{return a(i,s.data,{action:e,state:this.state,_event:s})}catch(C){throw this.parent&&this.parent.send({type:"xstate.error",data:C}),C}switch(e.type){case Te:var c=e;if(typeof c.delay=="number"){this.defer(c);return}else c.to?this.sendTo(c._event,c.to):this.send(c._event);break;case jt:this.cancel(e.sendId);break;case ot:{if(this.status!==z.Running)return;var f=e.activity;if(!this.state.activities[f.id||f.type])break;if(f.type===P.Invoke){var u=Xt(f.src),d=this.machine.options.services?this.machine.options.services[u.type]:void 0,l=f.id,h=f.data;D||L(!("forward"in f),"`forward` property is deprecated (found in invocation of '".concat(f.src,"' in in machine '").concat(this.machine.id,"'). ")+"Please use `autoForward` instead.");var g="autoForward"in f?f.autoForward:!!f.forward;if(!d){D||L(!1,"No service found for invocation '".concat(f.src,"' in machine '").concat(this.machine.id,"'."));return}var E=h?be(h,i,s):void 0;if(typeof d=="string")return;var p=N(d)?d(i,s.data,{data:E,src:u,meta:f.meta}):d;if(!p)return;var w=void 0;fe(p)&&(p=E?p.withContext(E):p,w={autoForward:g}),this.spawn(p,l,w)}else this.spawnActivity(f);break}case Be:{this.stopChild(e.activity.id);break}case Ft:var y=e.label,x=e.value;y?this.logger(y,x):this.logger(x);break;default:D||L(!1,"No implementation found for action type '".concat(e.type,"'"));break}},t.prototype.removeChild=function(e){var r;this.children.delete(e),this.forwardTo.delete(e),(r=this.state)===null||r===void 0||delete r.children[e]},t.prototype.stopChild=function(e){var r=this.children.get(e);!r||(this.removeChild(e),N(r.stop)&&r.stop())},t.prototype.spawn=function(e,r,n){if(Mr(e))return this.spawnPromise(Promise.resolve(e),r);if(N(e))return this.spawnCallback(e,r);if(Di(e))return this.spawnActor(e,r);if(wi(e))return this.spawnObservable(e,r);if(fe(e))return this.spawnMachine(e,v(v({},n),{id:r}));if(gi(e))return this.spawnBehavior(e,r);throw new Error('Unable to spawn entity "'.concat(r,'" of type "').concat(typeof e,'".'))},t.prototype.spawnMachine=function(e,r){var n=this;r===void 0&&(r={});var i=new t(e,v(v({},this.options),{parent:this,id:r.id||e.id})),s=v(v({},yc),r);s.sync&&i.onTransition(function(a){n.send(ut,{state:a,id:i.id})});var o=i;return this.children.set(i.id,o),s.autoForward&&this.forwardTo.add(i.id),i.onDone(function(a){n.removeChild(i.id),n.send(F(a,{origin:i.id}))}).start(),o},t.prototype.spawnBehavior=function(e,r){var n=Gi(e,{id:r,parent:this});return this.children.set(r,n),n},t.prototype.spawnPromise=function(e,r){var n,i=this,s=!1,o;e.then(function(c){s||(o=c,i.removeChild(r),i.send(F(Oe(r,c),{origin:r})))},function(c){if(!s){i.removeChild(r);var f=Ce(r,c);try{i.send(F(f,{origin:r}))}catch(u){bi(c,u,r),i.devTools&&i.devTools.send(f,i.state),i.machine.strict&&i.stop()}}});var a=(n={id:r,send:function(){},subscribe:function(c,f,u){var d=ht(c,f,u),l=!1;return e.then(function(h){l||(d.next(h),!l&&d.complete())},function(h){l||d.error(h)}),{unsubscribe:function(){return l=!0}}},stop:function(){s=!0},toJSON:function(){return{id:r}},getSnapshot:function(){return o}},n[ce]=function(){return this},n);return this.children.set(r,a),a},t.prototype.spawnCallback=function(e,r){var n,i=this,s=!1,o=new Set,a=new Set,c,f=function(l){c=l,a.forEach(function(h){return h(l)}),!s&&i.send(F(l,{origin:r}))},u;try{u=e(f,function(l){o.add(l)})}catch(l){this.send(Ce(r,l))}if(Mr(u))return this.spawnPromise(u,r);var d=(n={id:r,send:function(l){return o.forEach(function(h){return h(l)})},subscribe:function(l){var h=ht(l);return a.add(h.next),{unsubscribe:function(){a.delete(h.next)}}},stop:function(){s=!0,N(u)&&u()},toJSON:function(){return{id:r}},getSnapshot:function(){return c}},n[ce]=function(){return this},n);return this.children.set(r,d),d},t.prototype.spawnObservable=function(e,r){var n,i=this,s,o=e.subscribe(function(c){s=c,i.send(F(c,{origin:r}))},function(c){i.removeChild(r),i.send(F(Ce(r,c),{origin:r}))},function(){i.removeChild(r),i.send(F(Oe(r),{origin:r}))}),a=(n={id:r,send:function(){},subscribe:function(c,f,u){return e.subscribe(c,f,u)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return s},toJSON:function(){return{id:r}}},n[ce]=function(){return this},n);return this.children.set(r,a),a},t.prototype.spawnActor=function(e,r){return this.children.set(r,e),e},t.prototype.spawnActivity=function(e){var r=this.machine.options&&this.machine.options.activities?this.machine.options.activities[e.type]:void 0;if(!r){D||L(!1,"No implementation found for activity '".concat(e.type,"'"));return}var n=r(this.state.context,e);this.spawnEffect(e.id,n)},t.prototype.spawnEffect=function(e,r){var n;this.children.set(e,(n={id:e,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},stop:r||void 0,getSnapshot:function(){},toJSON:function(){return{id:e}}},n[ce]=function(){return this},n))},t.prototype.attachDev=function(){var e=er();if(this.options.devTools&&e){if(e.__REDUX_DEVTOOLS_EXTENSION__){var r=typeof this.options.devTools=="object"?this.options.devTools:void 0;this.devTools=e.__REDUX_DEVTOOLS_EXTENSION__.connect(v(v({name:this.id,autoPause:!0,stateSanitizer:function(n){return{value:n.value,context:n.context,actions:n.actions}}},r),{features:v({jump:!1,skip:!1},r?r.features:void 0)}),this.machine),this.devTools.init(this.state)}Hi(this)}},t.prototype.toJSON=function(){return{id:this.id}},t.prototype[ce]=function(){return this},t.prototype.getSnapshot=function(){return this.status===z.NotStarted?this.initialState:this._state},t.defaultOptions={execute:!0,deferEvents:!0,clock:{setTimeout:function(e,r){return setTimeout(e,r)},clearTimeout:function(e){return clearTimeout(e)}},logger:console.log.bind(console),devTools:!1},t.interpret=me,t}();function me(t,e){var r=new Ji(t,e);return r}function gc(t){if(typeof t=="string"){var e={type:t};return e.toString=function(){return t},e}return t}function wt(t){return v(v({type:at},t),{toJSON:function(){t.onDone,t.onError;var e=je(t,["onDone","onError"]);return v(v({},e),{type:at,src:gc(t.src)})}})}var $e="",Jr="#",xt="*",Je={},ze=function(t){return t[0]===Jr},Ec=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},Sc=function(t,e,r){var n=r.slice(0,-1).some(function(s){return!("cond"in s)&&!("in"in s)&&(A(s.target)||fe(s.target))}),i=e===$e?"the transient event":"event '".concat(e,"'");L(!n,"One or more transitions for ".concat(i," on state '").concat(t.id,"' are unreachable. ")+"Make sure that the default transition is the last one defined.")},zi=function(){function t(e,r,n,i){var s=this;n===void 0&&(n="context"in e?e.context:void 0);var o;this.config=e,this._context=n,this.order=-1,this.__xstatenode=!0,this.__cache={events:void 0,relativeValue:new Map,initialStateValue:void 0,initialState:void 0,on:void 0,transitions:void 0,candidates:{},delayedTransitions:void 0},this.idMap={},this.tags=[],this.options=Object.assign(Ec(),r),this.parent=i==null?void 0:i.parent,this.key=this.config.key||(i==null?void 0:i.key)||this.config.id||"(machine)",this.machine=this.parent?this.parent.machine:this,this.path=this.parent?this.parent.path.concat(this.key):[],this.delimiter=this.config.delimiter||(this.parent?this.parent.delimiter:Vt),this.id=this.config.id||_([this.machine.key],R(this.path),!1).join(this.delimiter),this.version=this.parent?this.parent.version:this.config.version,this.type=this.config.type||(this.config.parallel?"parallel":this.config.states&&Object.keys(this.config.states).length?"compound":this.config.history?"history":"atomic"),this.schema=this.parent?this.machine.schema:(o=this.config.schema)!==null&&o!==void 0?o:{},this.description=this.config.description,D||L(!("parallel"in this.config),'The "parallel" property is deprecated and will be removed in version 4.1. '.concat(this.config.parallel?"Replace with `type: 'parallel'`":"Use `type: '".concat(this.type,"'`")," in the config for state node '").concat(this.id,"' instead.")),this.initial=this.config.initial,this.states=this.config.states?He(this.config.states,function(f,u){var d,l=new t(f,{},void 0,{parent:s,key:u});return Object.assign(s.idMap,v((d={},d[l.id]=l,d),l.idMap)),l}):Je;var a=0;function c(f){var u,d;f.order=a++;try{for(var l=b(Ne(f)),h=l.next();!h.done;h=l.next()){var g=h.value;c(g)}}catch(E){u={error:E}}finally{try{h&&!h.done&&(d=l.return)&&d.call(l)}finally{if(u)throw u.error}}}c(this),this.history=this.config.history===!0?"shallow":this.config.history||!1,this._transient=!!this.config.always||(this.config.on?Array.isArray(this.config.on)?this.config.on.some(function(f){var u=f.event;return u===$e}):$e in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=te(this.config.entry||this.config.onEntry).map(function(f){return Ge(f)}),this.onExit=te(this.config.exit||this.config.onExit).map(function(f){return Ge(f)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=te(this.config.invoke).map(function(f,u){var d,l;if(fe(f)){var h=pt(s.id,u);return s.machine.options.services=v((d={},d[h]=f,d),s.machine.options.services),wt({src:h,id:h})}else if(A(f.src)){var h=f.id||pt(s.id,u);return wt(v(v({},f),{id:h,src:f.src}))}else if(fe(f.src)||N(f.src)){var h=f.id||pt(s.id,u);return s.machine.options.services=v((l={},l[h]=f.src,l),s.machine.options.services),wt(v(v({id:h},f),{src:h}))}else{var g=f.src;return wt(v(v({id:pt(s.id,u)},f),{src:g}))}}),this.activities=te(this.config.activities).concat(this.invoke).map(function(f){return Zt(f)}),this.transition=this.transition.bind(this),this.tags=te(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||Br(this).forEach(function(e){return e.on})},t.prototype.withConfig=function(e,r){var n=this.options,i=n.actions,s=n.activities,o=n.guards,a=n.services,c=n.delays;return new t(this.config,{actions:v(v({},i),e.actions),activities:v(v({},s),e.activities),guards:v(v({},o),e.guards),services:v(v({},a),e.services),delays:v(v({},c),e.delays)},r!=null?r:this.context)},t.prototype.withContext=function(e){return new t(this.config,this.options,e)},Object.defineProperty(t.prototype,"context",{get:function(){return N(this._context)?this._context():this._context},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"definition",{get:function(){return{id:this.id,key:this.key,version:this.version,context:this.context,type:this.type,initial:this.initial,history:this.history,states:He(this.states,function(e){return e.definition}),on:this.on,transitions:this.transitions,entry:this.onEntry,exit:this.onExit,activities:this.activities||[],meta:this.meta,order:this.order||-1,data:this.doneData,invoke:this.invoke,description:this.description,tags:this.tags}},enumerable:!1,configurable:!0}),t.prototype.toJSON=function(){return this.definition},Object.defineProperty(t.prototype,"on",{get:function(){if(this.__cache.on)return this.__cache.on;var e=this.transitions;return this.__cache.on=e.reduce(function(r,n){return r[n.eventType]=r[n.eventType]||[],r[n.eventType].push(n),r},{})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"after",{get:function(){return this.__cache.delayedTransitions||(this.__cache.delayedTransitions=this.getDelayedTransitions(),this.__cache.delayedTransitions)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"transitions",{get:function(){return this.__cache.transitions||(this.__cache.transitions=this.formatTransitions(),this.__cache.transitions)},enumerable:!1,configurable:!0}),t.prototype.getCandidates=function(e){if(this.__cache.candidates[e])return this.__cache.candidates[e];var r=e===$e,n=this.transitions.filter(function(i){var s=i.eventType===e;return r?s:s||i.eventType===xt});return this.__cache.candidates[e]=n,n},t.prototype.getDelayedTransitions=function(){var e=this,r=this.config.after;if(!r)return[];var n=function(s,o){var a=N(s)?"".concat(e.id,":delay[").concat(o,"]"):s,c=Ni(a,e.id);return e.onEntry.push(vt(c,{delay:s})),e.onExit.push(Ai(c)),c},i=pe(r)?r.map(function(s,o){var a=n(s.delay,o);return v(v({},s),{event:a})}):q(Object.keys(r).map(function(s,o){var a=r[s],c=A(a)?{target:a}:a,f=isNaN(+s)?s:+s,u=n(f,o);return te(c).map(function(d){return v(v({},d),{event:u,delay:f})})}));return i.map(function(s){var o=s.delay;return v(v({},e.formatTransition(s)),{delay:o})})},t.prototype.getStateNodes=function(e){var r,n=this;if(!e)return[];var i=e instanceof se?e.value:Ve(e,this.delimiter);if(A(i)){var s=this.getStateNode(i).initial;return s!==void 0?this.getStateNodes((r={},r[i]=s,r)):[this,this.states[i]]}var o=Object.keys(i),a=[this];return a.push.apply(a,_([],R(q(o.map(function(c){return n.getStateNode(c).getStateNodes(i[c])}))),!1)),a},t.prototype.handles=function(e){var r=Jt(e);return this.events.includes(r)},t.prototype.resolveState=function(e){var r=e instanceof se?e:se.create(e),n=Array.from(Ie([],this.getStateNodes(r.value)));return new se(v(v({},r),{value:this.resolve(r.value),configuration:n,done:_e(n,this),tags:Fr(n),machine:this.machine}))},t.prototype.transitionLeafNode=function(e,r,n){var i=this.getStateNode(e),s=i.next(r,n);return!s||!s.transitions.length?this.next(r,n):s},t.prototype.transitionCompoundNode=function(e,r,n){var i=Object.keys(e),s=this.getStateNode(i[0]),o=s._transition(e[i[0]],r,n);return!o||!o.transitions.length?this.next(r,n):o},t.prototype.transitionParallelNode=function(e,r,n){var i,s,o={};try{for(var a=b(Object.keys(e)),c=a.next();!c.done;c=a.next()){var f=c.value,u=e[f];if(!!u){var d=this.getStateNode(f),l=d._transition(u,r,n);l&&(o[f]=l)}}}catch(y){i={error:y}}finally{try{c&&!c.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}var h=Object.keys(o).map(function(y){return o[y]}),g=q(h.map(function(y){return y.transitions})),E=h.some(function(y){return y.transitions.length>0});if(!E)return this.next(r,n);var p=q(h.map(function(y){return y.entrySet})),w=q(Object.keys(o).map(function(y){return o[y].configuration}));return{transitions:g,entrySet:p,exitSet:q(h.map(function(y){return y.exitSet})),configuration:w,source:r,actions:q(Object.keys(o).map(function(y){return o[y].actions}))}},t.prototype._transition=function(e,r,n){return A(e)?this.transitionLeafNode(e,r,n):Object.keys(e).length===1?this.transitionCompoundNode(e,r,n):this.transitionParallelNode(e,r,n)},t.prototype.getTransitionData=function(e,r){return this._transition(e.value,e,F(r))},t.prototype.next=function(e,r){var n,i,s=this,o=r.name,a=[],c=[],f;try{for(var u=b(this.getCandidates(o)),d=u.next();!d.done;d=u.next()){var l=d.value,h=l.cond,g=l.in,E=e.context,p=g?A(g)&&ze(g)?e.matches(Ve(this.getStateNodeById(g).path,this.delimiter)):ft(Ve(g,this.delimiter),pi(this.path.slice(0,-2))(e.value)):!0,w=!1;try{w=!h||Kt(this.machine,h,E,r,e)}catch(I){throw new Error("Unable to evaluate guard '".concat(h.name||h.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,`':
|
|
8
|
+
`).concat(I.message))}if(w&&p){l.target!==void 0&&(c=l.target),a.push.apply(a,_([],R(l.actions),!1)),f=l;break}}}catch(I){n={error:I}}finally{try{d&&!d.done&&(i=u.return)&&i.call(u)}finally{if(n)throw n.error}}if(!!f){if(!c.length)return{transitions:[f],entrySet:[],exitSet:[],configuration:e.value?[this]:[],source:e,actions:a};var y=q(c.map(function(I){return s.getRelativeStateNodes(I,e.historyValue)})),x=!!f.internal,C=x?[]:q(y.map(function(I){return s.nodesFromChild(I)}));return{transitions:[f],entrySet:C,exitSet:x?[]:[this],configuration:y,source:e,actions:a}}},t.prototype.nodesFromChild=function(e){if(e.escapes(this))return[];for(var r=[],n=e;n&&n!==this;)r.push(n),n=n.parent;return r.push(this),r},t.prototype.escapes=function(e){if(this===e)return!1;for(var r=this.parent;r;){if(r===e)return!1;r=r.parent}return!0},t.prototype.getActions=function(e,r,n,i){var s,o,a,c,f=Ie([],i?this.getStateNodes(i.value):[this]),u=e.configuration.length?Ie(f,e.configuration):f;try{for(var d=b(u),l=d.next();!l.done;l=d.next()){var h=l.value;Et(f,h)||e.entrySet.push(h)}}catch(T){s={error:T}}finally{try{l&&!l.done&&(o=d.return)&&o.call(d)}finally{if(s)throw s.error}}try{for(var g=b(f),E=g.next();!E.done;E=g.next()){var h=E.value;(!Et(u,h)||Et(e.exitSet,h.parent))&&e.exitSet.push(h)}}catch(T){a={error:T}}finally{try{E&&!E.done&&(c=g.return)&&c.call(g)}finally{if(a)throw a.error}}var p=q(e.entrySet.map(function(T){var S=[];if(T.type!=="final")return S;var O=T.parent;if(!O.parent)return S;S.push(yt(T.id,T.doneData),yt(O.id,T.doneData?be(T.doneData,r,n):void 0));var U=O.parent;return U.type==="parallel"&&Ne(U).every(function(V){return _e(e.configuration,V)})&&S.push(yt(U.id)),S}));e.exitSet.sort(function(T,S){return S.order-T.order}),e.entrySet.sort(function(T,S){return T.order-S.order});var w=new Set(e.entrySet),y=new Set(e.exitSet),x=R([q(Array.from(w).map(function(T){return _(_([],R(T.activities.map(function(S){return Oi(S)})),!1),R(T.onEntry),!1)})).concat(p.map(Ri)),q(Array.from(y).map(function(T){return _(_([],R(T.onExit),!1),R(T.activities.map(function(S){return Ci(S)})),!1)}))],2),C=x[0],I=x[1],B=mt(I.concat(e.actions).concat(C),this.machine.options.actions);return B},t.prototype.transition=function(e,r,n){e===void 0&&(e=this.initialState);var i=F(r),s;if(e instanceof se)s=n===void 0?e:this.resolveState(se.from(e,n));else{var o=A(e)?this.resolve(ct(this.getResolvedPath(e))):this.resolve(e),a=n!=null?n:this.machine.context;s=this.resolveState(se.from(o,a))}if(!D&&i.name===xt)throw new Error("An event cannot have the wildcard type ('".concat(xt,"')"));if(this.strict&&!this.events.includes(i.name)&&!yi(i.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(i.name,"'"));var c=this._transition(s.value,s,i)||{transitions:[],configuration:[],entrySet:[],exitSet:[],source:s,actions:[]},f=Ie([],this.getStateNodes(s.value)),u=c.configuration.length?Ie(f,c.configuration):f;return c.configuration=_([],R(u),!1),this.resolveTransition(c,s,s.context,i)},t.prototype.resolveRaisedTransition=function(e,r,n){var i,s=e.actions;return e=this.transition(e,r),e._event=n,e.event=n.data,(i=e.actions).unshift.apply(i,_([],R(s),!1)),e},t.prototype.resolveTransition=function(e,r,n,i){var s,o,a=this;i===void 0&&(i=Ae);var c=e.configuration,f=!r||e.transitions.length>0,u=f?Li(this.machine,c):void 0,d=r?r.historyValue?r.historyValue:e.source?this.machine.historyValue(r.value):void 0:void 0,l=this.getActions(e,n,i,r),h=r?v({},r.activities):{};try{for(var g=b(l),E=g.next();!E.done;E=g.next()){var p=E.value;p.type===ot?h[p.activity.id||p.activity.type]=p:p.type===Be&&(h[p.activity.id||p.activity.type]=!1)}}catch(ee){s={error:ee}}finally{try{E&&!E.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}var w=R(Qt(this,r,n,i,l,this.machine.config.preserveActionOrder),2),y=w[0],x=w[1],C=R($t(y,function(ee){return ee.type===Fe||ee.type===Te&&ee.to===ge.Internal}),2),I=C[0],B=C[1],T=y.filter(function(ee){var Me;return ee.type===ot&&((Me=ee.activity)===null||Me===void 0?void 0:Me.type)===at}),S=T.reduce(function(ee,Me){return ee[Me.activity.id]=ki(Me.activity,a.machine,x,i),ee},r?v({},r.children):{}),O=f?e.configuration:r?r.configuration:[],U=_e(O,this),V=new se({value:u||r.value,context:x,_event:i,_sessionid:r?r._sessionid:null,historyValue:u?d?Si(d,u):void 0:r?r.historyValue:void 0,history:!u||e.source?r:void 0,actions:u?B:[],activities:u?h:r?r.activities:{},events:[],configuration:O,transitions:e.transitions,children:S,done:U,tags:r==null?void 0:r.tags,machine:this}),Q=n!==x;V.changed=i.name===ut||Q;var ye=V.history;ye&&delete ye.history;var Mt=!U&&(this._transient||c.some(function(ee){return ee._transient}));if(!f&&(!Mt||i.name===$e))return V;var Z=V;if(!U)for(Mt&&(Z=this.resolveRaisedTransition(Z,{type:ci},i));I.length;){var Zu=I.shift();Z=this.resolveRaisedTransition(Z,Zu._event,i)}var ec=Z.changed||(ye?!!Z.actions.length||Q||typeof ye.value!=typeof Z.value||!Vr(Z.value,ye.value):void 0);return Z.changed=ec,Z.history=ye,Z.tags=Fr(Z.configuration),Z},t.prototype.getStateNode=function(e){if(ze(e))return this.machine.getStateNodeById(e);if(!this.states)throw new Error("Unable to retrieve child state '".concat(e,"' from '").concat(this.id,"'; no child states exist."));var r=this.states[e];if(!r)throw new Error("Child state '".concat(e,"' does not exist on '").concat(this.id,"'"));return r},t.prototype.getStateNodeById=function(e){var r=ze(e)?e.slice(Jr.length):e;if(r===this.id)return this;var n=this.machine.idMap[r];if(!n)throw new Error("Child state node '#".concat(r,"' does not exist on machine '").concat(this.id,"'"));return n},t.prototype.getStateNodeByPath=function(e){if(typeof e=="string"&&ze(e))try{return this.getStateNodeById(e.slice(1))}catch{}for(var r=zt(e,this.delimiter).slice(),n=this;r.length;){var i=r.shift();if(!i.length)break;n=n.getStateNode(i)}return n},t.prototype.resolve=function(e){var r,n=this;if(!e)return this.initialStateValue||Je;switch(this.type){case"parallel":return He(this.initialStateValue,function(s,o){return s?n.getStateNode(o).resolve(e[o]||s):Je});case"compound":if(A(e)){var i=this.getStateNode(e);return i.type==="parallel"||i.type==="compound"?(r={},r[e]=i.initialStateValue,r):e}return Object.keys(e).length?He(e,function(s,o){return s?n.getStateNode(o).resolve(s):Je}):this.initialStateValue||{};default:return e||Je}},t.prototype.getResolvedPath=function(e){if(ze(e)){var r=this.machine.idMap[e.slice(Jr.length)];if(!r)throw new Error("Unable to find state node '".concat(e,"'"));return r.path}return zt(e,this.delimiter)},Object.defineProperty(t.prototype,"initialStateValue",{get:function(){var e;if(this.__cache.initialStateValue)return this.__cache.initialStateValue;var r;if(this.type==="parallel")r=Ur(this.states,function(n){return n.initialStateValue||Je},function(n){return n.type!=="history"});else if(this.initial!==void 0){if(!this.states[this.initial])throw new Error("Initial state '".concat(this.initial,"' not found on '").concat(this.key,"'"));r=gt(this.states[this.initial])?this.initial:(e={},e[this.initial]=this.states[this.initial].initialStateValue,e)}else r={};return this.__cache.initialStateValue=r,this.__cache.initialStateValue},enumerable:!1,configurable:!0}),t.prototype.getInitialState=function(e,r){this._init();var n=this.getStateNodes(e);return this.resolveTransition({configuration:n,entrySet:n,exitSet:[],transitions:[],source:void 0,actions:[]},void 0,r!=null?r:this.machine.context,void 0)},Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this.initialStateValue;if(!e)throw new Error("Cannot retrieve initial state from simple state '".concat(this.id,"'."));return this.getInitialState(e)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"target",{get:function(){var e;if(this.type==="history"){var r=this.config;A(r.target)?e=ze(r.target)?ct(this.machine.getStateNodeById(r.target).path.slice(this.path.length-1)):r.target:e=r.target}return e},enumerable:!1,configurable:!0}),t.prototype.getRelativeStateNodes=function(e,r,n){return n===void 0&&(n=!0),n?e.type==="history"?e.resolveHistory(r):e.initialStateNodes:[e]},Object.defineProperty(t.prototype,"initialStateNodes",{get:function(){var e=this;if(gt(this))return[this];if(this.type==="compound"&&!this.initial)return D||L(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var r=lt(this.initialStateValue);return q(r.map(function(n){return e.getFromRelativePath(n)}))},enumerable:!1,configurable:!0}),t.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var r=R(e),n=r[0],i=r.slice(1);if(!this.states)throw new Error("Cannot retrieve subPath '".concat(n,"' from node with no states"));var s=this.getStateNode(n);if(s.type==="history")return s.resolveHistory();if(!this.states[n])throw new Error("Child state '".concat(n,"' does not exist on '").concat(this.id,"'"));return this.states[n].getFromRelativePath(i)},t.prototype.historyValue=function(e){if(!!Object.keys(this.states).length)return{current:e||this.initialStateValue,states:Ur(this.states,function(r,n){if(!e)return r.historyValue();var i=A(e)?void 0:e[n];return r.historyValue(i||r.initialStateValue)},function(r){return!r.history})}},t.prototype.resolveHistory=function(e){var r=this;if(this.type!=="history")return[this];var n=this.parent;if(!e){var i=this.target;return i?q(lt(i).map(function(o){return n.getFromRelativePath(o)})):n.initialStateNodes}var s=mi(n.path,"states")(e).current;return A(s)?[n.getStateNode(s)]:q(lt(s).map(function(o){return r.history==="deep"?n.getFromRelativePath(o):[n.states[o[0]]]}))},Object.defineProperty(t.prototype,"stateIds",{get:function(){var e=this,r=q(Object.keys(this.states).map(function(n){return e.states[n].stateIds}));return[this.id].concat(r)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"events",{get:function(){var e,r,n,i;if(this.__cache.events)return this.__cache.events;var s=this.states,o=new Set(this.ownEvents);if(s)try{for(var a=b(Object.keys(s)),c=a.next();!c.done;c=a.next()){var f=c.value,u=s[f];if(u.states)try{for(var d=(n=void 0,b(u.events)),l=d.next();!l.done;l=d.next()){var h=l.value;o.add("".concat(h))}}catch(g){n={error:g}}finally{try{l&&!l.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}}}catch(g){e={error:g}}finally{try{c&&!c.done&&(r=a.return)&&r.call(a)}finally{if(e)throw e.error}}return this.__cache.events=Array.from(o)},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"ownEvents",{get:function(){var e=new Set(this.transitions.filter(function(r){return!(!r.target&&!r.actions.length&&r.internal)}).map(function(r){return r.eventType}));return Array.from(e)},enumerable:!1,configurable:!0}),t.prototype.resolveTarget=function(e){var r=this;if(e!==void 0)return e.map(function(n){if(!A(n))return n;var i=n[0]===r.delimiter;if(i&&!r.parent)return r.getStateNodeByPath(n.slice(1));var s=i?r.key+n:n;if(r.parent)try{var o=r.parent.getStateNodeByPath(s);return o}catch(a){throw new Error("Invalid transition definition for state node '".concat(r.id,`':
|
|
9
|
+
`).concat(a.message))}else return r.getStateNodeByPath(s)})},t.prototype.formatTransition=function(e){var r=this,n=Ti(e.target),i="internal"in e?e.internal:n?n.some(function(c){return A(c)&&c[0]===r.delimiter}):!0,s=this.machine.options.guards,o=this.resolveTarget(n),a=v(v({},e),{actions:mt(te(e.actions)),cond:Wt(e.cond,s),target:o,source:this,internal:i,eventType:e.event,toJSON:function(){return v(v({},a),{target:a.target?a.target.map(function(c){return"#".concat(c.id)}):void 0,source:"#".concat(r.id)})}});return a},t.prototype.formatTransitions=function(){var e,r,n=this,i;if(!this.config.on)i=[];else if(Array.isArray(this.config.on))i=this.config.on;else{var s=this.config.on,o=xt,a=s[o],c=a===void 0?[]:a,f=je(s,[typeof o=="symbol"?o:o+""]);i=q(Object.keys(f).map(function(y){!D&&y===$e&&L(!1,"Empty string transition configs (e.g., `{ on: { '': ... }}`) for transient transitions are deprecated. Specify the transition in the `{ always: ... }` property instead. "+'Please check the `on` configuration for "#'.concat(n.id,'".'));var x=Re(y,f[y]);return D||Sc(n,y,x),x}).concat(Re(xt,c)))}var u=this.config.always?Re("",this.config.always):[],d=this.config.onDone?Re(String(yt(this.id)),this.config.onDone):[];D||L(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var l=q(this.invoke.map(function(y){var x=[];return y.onDone&&x.push.apply(x,_([],R(Re(String(Oe(y.id)),y.onDone)),!1)),y.onError&&x.push.apply(x,_([],R(Re(String(Ce(y.id)),y.onError)),!1)),x})),h=this.after,g=q(_(_(_(_([],R(d),!1),R(l),!1),R(i),!1),R(u),!1).map(function(y){return te(y).map(function(x){return n.formatTransition(x)})}));try{for(var E=b(h),p=E.next();!p.done;p=E.next()){var w=p.value;g.push(w)}}catch(y){e={error:y}}finally{try{p&&!p.done&&(r=E.return)&&r.call(E)}finally{if(e)throw e.error}}return g},t}();function oe(t,e){return new zi(t,e)}var k=Pi,$=vt;function Wi(t){return!!(t&&typeof t.then=="function")}var wc=Promise.resolve(!1),qp=Promise.resolve(!0),le=Promise.resolve();function tr(t,e){return t||(t=0),new Promise(function(r){return setTimeout(function(){return r(e)},t)})}function Ki(t,e){return Math.floor(Math.random()*(e-t+1)+t)}function Tt(){return Math.random().toString(36).substring(2)}var $i=0,zr=0;function Ee(){var t=new Date().getTime();return t===$i?(zr++,t*1e3+zr):($i=t,zr=0,t*1e3)}var Se=Object.prototype.toString.call(typeof process!="undefined"?process:0)==="[object process]";var xc=Ee,Tc="native";function bc(t){var e={messagesCallback:null,bc:new BroadcastChannel(t),subFns:[]};return e.bc.onmessage=function(r){e.messagesCallback&&e.messagesCallback(r.data)},e}function Rc(t){t.bc.close(),t.subFns=[]}function Ac(t,e){try{return t.bc.postMessage(e,!1),le}catch(r){return Promise.reject(r)}}function Oc(t,e){t.messagesCallback=e}function Cc(){if(Se&&typeof window=="undefined")return!1;if(typeof BroadcastChannel=="function"){if(BroadcastChannel._pubkey)throw new Error("BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill");return!0}else return!1}function Pc(){return 150}var Xi={create:bc,close:Rc,onMessage:Oc,postMessage:Ac,canBeUsed:Cc,type:Tc,averageResponseTime:Pc,microSeconds:xc};var rr=function(){function t(e){this.ttl=e,this.set=new Set,this.timeMap=new Map}return t.prototype.has=function(e){return this.set.has(e)},t.prototype.add=function(e){var r=this;this.timeMap.set(e,Yi()),this.set.add(e),setTimeout(function(){Nc(r)},0)},t.prototype.clear=function(){this.set.clear(),this.timeMap.clear()},t}();function Nc(t){for(var e=Yi()-t.ttl,r=t.set[Symbol.iterator]();;){var n=r.next().value;if(!n)return;var i=t.timeMap.get(n);if(i<e)t.timeMap.delete(n),t.set.delete(n);else return}}function Yi(){return new Date().getTime()}function We(){var t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},e=JSON.parse(JSON.stringify(t));return typeof e.webWorkerSupport=="undefined"&&(e.webWorkerSupport=!0),e.idb||(e.idb={}),e.idb.ttl||(e.idb.ttl=1e3*45),e.idb.fallbackInterval||(e.idb.fallbackInterval=150),t.idb&&typeof t.idb.onclose=="function"&&(e.idb.onclose=t.idb.onclose),e.localstorage||(e.localstorage={}),e.localstorage.removeTimeout||(e.localstorage.removeTimeout=1e3*60),t.methods&&(e.methods=t.methods),e.node||(e.node={}),e.node.ttl||(e.node.ttl=1e3*60*2),e.node.maxParallelWrites||(e.node.maxParallelWrites=2048),typeof e.node.useFastPath=="undefined"&&(e.node.useFastPath=!0),e}var Ic=Ee,_c="pubkey.broadcast-channel-0-",ve="messages",kc="idb";function Qi(){if(typeof indexedDB!="undefined")return indexedDB;if(typeof window!="undefined"){if(typeof window.mozIndexedDB!="undefined")return window.mozIndexedDB;if(typeof window.webkitIndexedDB!="undefined")return window.webkitIndexedDB;if(typeof window.msIndexedDB!="undefined")return window.msIndexedDB}return!1}function qc(t){var e=Qi(),r=_c+t,n=e.open(r,1);n.onupgradeneeded=function(s){var o=s.target.result;o.createObjectStore(ve,{keyPath:"id",autoIncrement:!0})};var i=new Promise(function(s,o){n.onerror=function(a){return o(a)},n.onsuccess=function(){s(n.result)}});return i}function Dc(t,e,r){var n=new Date().getTime(),i={uuid:e,time:n,data:r},s=t.transaction([ve],"readwrite");return new Promise(function(o,a){s.oncomplete=function(){return o()},s.onerror=function(f){return a(f)};var c=s.objectStore(ve);c.add(i)})}function Uc(t,e){var r=t.transaction(ve).objectStore(ve),n=[];function i(){try{var s=IDBKeyRange.bound(e+1,1/0);return r.openCursor(s)}catch{return r.openCursor()}}return new Promise(function(s){i().onsuccess=function(o){var a=o.target.result;a?a.value.id<e+1?a.continue(e+1):(n.push(a.value),a.continue()):s(n)}})}function Mc(t,e){var r=t.transaction([ve],"readwrite").objectStore(ve).delete(e);return new Promise(function(n){r.onsuccess=function(){return n()}})}function Lc(t,e){var r=new Date().getTime()-e,n=t.transaction(ve).objectStore(ve),i=[];return new Promise(function(s){n.openCursor().onsuccess=function(o){var a=o.target.result;if(a){var c=a.value;if(c.time<r)i.push(c),a.continue();else{s(i);return}}else s(i)}})}function jc(t,e){return Lc(t,e).then(function(r){return Promise.all(r.map(function(n){return Mc(t,n.id)}))})}function Bc(t,e){return e=We(e),qc(t).then(function(r){var n={closed:!1,lastCursorId:0,channelName:t,options:e,uuid:Tt(),eMIs:new rr(e.idb.ttl*2),writeBlockPromise:le,messagesCallback:null,readQueuePromises:[],db:r};return r.onclose=function(){n.closed=!0,e.idb.onclose&&e.idb.onclose()},Zi(n),n})}function Zi(t){t.closed||es(t).then(function(){return tr(t.options.idb.fallbackInterval)}).then(function(){return Zi(t)})}function Fc(t,e){return!(t.uuid===e.uuid||e.eMIs.has(t.id)||t.data.time<e.messagesCallbackTime)}function es(t){return t.closed?le:t.messagesCallback?Uc(t.db,t.lastCursorId).then(function(e){var r=e.filter(function(n){return!!n}).map(function(n){return n.id>t.lastCursorId&&(t.lastCursorId=n.id),n}).filter(function(n){return Fc(n,t)}).sort(function(n,i){return n.time-i.time});return r.forEach(function(n){t.messagesCallback&&(t.eMIs.add(n.id),t.messagesCallback(n.data))}),le}):le}function Vc(t){t.closed=!0,t.db.close()}function Hc(t,e){return t.writeBlockPromise=t.writeBlockPromise.then(function(){return Dc(t.db,t.uuid,e)}).then(function(){Ki(0,10)===0&&jc(t.db,t.options.idb.ttl)}),t.writeBlockPromise}function Gc(t,e,r){t.messagesCallbackTime=r,t.messagesCallback=e,es(t)}function Jc(){if(Se)return!1;var t=Qi();return!!t}function zc(t){return t.idb.fallbackInterval*2}var ts={create:Bc,close:Vc,onMessage:Gc,postMessage:Hc,canBeUsed:Jc,type:kc,averageResponseTime:zc,microSeconds:Ic};var $c=Ee,Wc="pubkey.broadcastChannel-",Kc="localstorage";function rs(){var t;if(typeof window=="undefined")return null;try{t=window.localStorage,t=window["ie8-eventlistener/storage"]||window.localStorage}catch{}return t}function ns(t){return Wc+t}function Xc(t,e){return new Promise(function(r){tr().then(function(){var n=ns(t.channelName),i={token:Tt(),time:new Date().getTime(),data:e,uuid:t.uuid},s=JSON.stringify(i);rs().setItem(n,s);var o=document.createEvent("Event");o.initEvent("storage",!0,!0),o.key=n,o.newValue=s,window.dispatchEvent(o),r()})})}function Yc(t,e){var r=ns(t),n=function(s){s.key===r&&e(JSON.parse(s.newValue))};return window.addEventListener("storage",n),n}function Qc(t){window.removeEventListener("storage",t)}function Zc(t,e){if(e=We(e),!is())throw new Error("BroadcastChannel: localstorage cannot be used");var r=Tt(),n=new rr(e.localstorage.removeTimeout),i={channelName:t,uuid:r,eMIs:n};return i.listener=Yc(t,function(s){!i.messagesCallback||s.uuid!==r&&(!s.token||n.has(s.token)||s.data.time&&s.data.time<i.messagesCallbackTime||(n.add(s.token),i.messagesCallback(s.data)))}),i}function ef(t){Qc(t.listener)}function tf(t,e,r){t.messagesCallbackTime=r,t.messagesCallback=e}function is(){if(Se)return!1;var t=rs();if(!t)return!1;try{var e="__broadcastchannel_check";t.setItem(e,"works"),t.removeItem(e)}catch{return!1}return!0}function rf(){var t=120,e=navigator.userAgent.toLowerCase();return e.includes("safari")&&!e.includes("chrome")?t*2:t}var ss={create:Zc,close:ef,onMessage:tf,postMessage:Xc,canBeUsed:is,type:Kc,averageResponseTime:rf,microSeconds:$c};var nf=Ee,sf="simulate",$r=new Set;function of(t){var e={name:t,messagesCallback:null};return $r.add(e),e}function af(t){$r.delete(t)}function uf(t,e){return new Promise(function(r){return setTimeout(function(){var n=Array.from($r);n.filter(function(i){return i.name===t.name}).filter(function(i){return i!==t}).filter(function(i){return!!i.messagesCallback}).forEach(function(i){return i.messagesCallback(e)}),r()},5)})}function cf(t,e){t.messagesCallback=e}function ff(){return!0}function lf(){return 5}var os={create:of,close:af,onMessage:cf,postMessage:uf,canBeUsed:ff,type:sf,averageResponseTime:lf,microSeconds:nf};var as=[Xi,ts,ss];function us(t){var e=[].concat(t.methods,as).filter(Boolean);if(t.type){if(t.type==="simulate")return os;var r=e.find(function(i){return i.type===t.type});if(r)return r;throw new Error("method-type "+t.type+" not found")}!t.webWorkerSupport&&!Se&&(e=e.filter(function(i){return i.type!=="idb"}));var n=e.find(function(i){return i.canBeUsed()});if(n)return n;throw new Error("No useable method found in "+JSON.stringify(as.map(function(i){return i.type})))}var Wr=new Set,df=0,ke=function(e,r){this.id=df++,Wr.add(this),this.name=e,cs&&(r=cs),this.options=We(r),this.method=us(this.options),this._iL=!1,this._onML=null,this._addEL={message:[],internal:[]},this._uMP=new Set,this._befC=[],this._prepP=null,hf(this)};ke._pubkey=!0;var cs;ke.prototype={postMessage:function(e){if(this.closed)throw new Error("BroadcastChannel.postMessage(): Cannot post message after channel has closed "+JSON.stringify(e));return fs(this,"message",e)},postInternal:function(e){return fs(this,"internal",e)},set onmessage(t){var e=this.method.microSeconds(),r={time:e,fn:t};ds(this,"message",this._onML),t&&typeof t=="function"?(this._onML=r,ls(this,"message",r)):this._onML=null},addEventListener:function(e,r){var n=this.method.microSeconds(),i={time:n,fn:r};ls(this,e,i)},removeEventListener:function(e,r){var n=this._addEL[e].find(function(i){return i.fn===r});ds(this,e,n)},close:function(){var e=this;if(!this.closed){Wr.delete(this),this.closed=!0;var r=this._prepP?this._prepP:le;return this._onML=null,this._addEL.message=[],r.then(function(){return Promise.all(Array.from(e._uMP))}).then(function(){return Promise.all(e._befC.map(function(n){return n()}))}).then(function(){return e.method.close(e._state)})}},get type(){return this.method.type},get isClosed(){return this.closed}};function fs(t,e,r){var n=t.method.microSeconds(),i={time:n,type:e,data:r},s=t._prepP?t._prepP:le;return s.then(function(){var o=t.method.postMessage(t._state,i);return t._uMP.add(o),o.catch().then(function(){return t._uMP.delete(o)}),o})}function hf(t){var e=t.method.create(t.name,t.options);Wi(e)?(t._prepP=e,e.then(function(r){t._state=r})):t._state=e}function hs(t){return t._addEL.message.length>0||t._addEL.internal.length>0}function ls(t,e,r){t._addEL[e].push(r),pf(t)}function ds(t,e,r){t._addEL[e]=t._addEL[e].filter(function(n){return n!==r}),mf(t)}function pf(t){if(!t._iL&&hs(t)){var e=function(i){t._addEL[i.type].forEach(function(s){var o=1e5,a=s.time-o;i.time>=a&&s.fn(i.data)})},r=t.method.microSeconds();t._prepP?t._prepP.then(function(){t._iL=!0,t.method.onMessage(t._state,e,r)}):(t._iL=!0,t.method.onMessage(t._state,e,r))}}function mf(t){if(t._iL&&!hs(t)){t._iL=!1;var e=t.method.microSeconds();t.method.onMessage(t._state,null,e)}}var nr="nhostRefreshToken",bt="nhostRefreshTokenExpiresAt";var qe={status:10,error:"invalid-email",message:"Email is incorrectly formatted"};var Rt={status:10,error:"invalid-password",message:"Password is incorrectly formatted"},ps={status:10,error:"invalid-phone-number",message:"Phone number is incorrectly formatted"},ms={status:10,error:"no-mfa-ticket",message:"No MFA ticket has been provided"};var bo=Lt(To());var ae=t=>{let e=bo.default.create({baseURL:t});return e.interceptors.response.use(r=>r,r=>{var n,i,s,o,a,c,f,u,d,l;return Promise.reject({error:{message:(a=(o=(s=(i=(n=r.response)==null?void 0:n.data)==null?void 0:i.message)!=null?s:r.message)!=null?o:r.request.responseText)!=null?a:JSON.stringify(r),status:(d=(u=(c=r.response)==null?void 0:c.status)!=null?u:(f=r.response)==null?void 0:f.data.statusCode)!=null?d:0,error:((l=r.response)==null?void 0:l.data.error)||r.request.statusText||"network"}})}),e};var Ro=(t,e)=>{let r=e&&Object.entries(e).map(([n,i])=>{let s=Array.isArray(i)?i.join(","):typeof i=="object"?JSON.stringify(i):i;return`${n}=${encodeURIComponent(s)}`}).join("&");return r?`${t}?${r}`:t},ie=(t,e)=>{var r;return e!=null&&e.redirectTo?{...e,redirectTo:(r=e==null?void 0:e.redirectTo)!=null&&r.startsWith("/")?t+e.redirectTo:e==null?void 0:e.redirectTo}:e};var Qe=t=>!!t&&typeof t=="string"&&!!String(t).toLowerCase().match(/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/),lr=t=>!!t&&typeof t=="string"&&t.length>=3,Ao=t=>!!t&&typeof t=="string";var mn={user:null,mfa:null,accessToken:{value:null,expiresAt:new Date},refreshTimer:{elapsed:0,attempts:0},refreshToken:{value:null},errors:{}};var Oo=({backendUrl:t,clientUrl:e,interpreter:r})=>{let n=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"changeEmail",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:[{cond:"invalidEmail",actions:"saveInvalidEmailError",target:".error"},{target:"requesting"}]},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"requestChange",id:"requestChange",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveInvalidEmailError:k({error:i=>qe}),saveRequestError:k({error:(i,{data:{error:s}})=>s}),reportError:$(i=>({type:"ERROR",error:i.error})),reportSuccess:$("SUCCESS")},guards:{invalidEmail:(i,{email:s})=>!Qe(s)},services:{requestChange:async(i,{email:s,options:o})=>(await n.post("/user/email/change",{newEmail:s,options:ie(e,o)},{headers:{authorization:`Bearer ${r==null?void 0:r.state.context.accessToken.value}`}})).data}})};var Co=({backendUrl:t,interpreter:e})=>{let r=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"changePassword",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:[{cond:"invalidPassword",actions:"saveInvalidPasswordError",target:".error"},{target:"requesting"}]},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"requestChange",id:"requestChange",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveInvalidPasswordError:k({error:n=>Rt}),saveRequestError:k({error:(n,{data:{error:i}})=>(console.log(i),i)}),reportError:$(n=>({type:"ERROR",error:n.error})),reportSuccess:$("SUCCESS")},guards:{invalidPassword:(n,{password:i})=>!lr(i)},services:{requestChange:(n,{password:i})=>r.post("/user/password",{newPassword:i},{headers:{authorization:`Bearer ${e==null?void 0:e.state.context.accessToken.value}`}})}})};var Po=({backendUrl:t,clientUrl:e})=>{let r=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"changePassword",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:"requesting"},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"requestChange",id:"requestChange",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveRequestError:k({error:(n,{data:{error:i}})=>(console.log(i),i)}),reportError:$(n=>({type:"ERROR",error:n.error})),reportSuccess:$("SUCCESS")},services:{requestChange:(n,{email:i,options:s})=>r.post("/user/password/reset",{email:i,options:ie(e,s)})}})};var No=({backendUrl:t,clientUrl:e,interpreter:r})=>{let n=ae(t);return oe({schema:{context:{},events:{}},tsTypes:{},preserveActionOrder:!0,id:"sendVerificationEmail",initial:"idle",context:{error:null},states:{idle:{on:{REQUEST:[{cond:"invalidEmail",actions:"saveInvalidEmailError",target:".error"},{target:"requesting"}]},initial:"initial",states:{initial:{},success:{},error:{}}},requesting:{invoke:{src:"request",id:"request",onDone:{target:"idle.success",actions:"reportSuccess"},onError:{actions:["saveRequestError","reportError"],target:"idle.error"}}}}},{actions:{saveInvalidEmailError:k({error:i=>qe}),saveRequestError:k({error:(i,{data:{error:s}})=>s}),reportError:$(i=>({type:"ERROR",error:i.error})),reportSuccess:$("SUCCESS")},guards:{invalidEmail:(i,{email:s})=>!Qe(s)},services:{request:async(i,{email:s,options:o})=>(await n.post("/user/email/send-verification-email",{email:s,options:ie(e,o)})).data}})};var Io=({backendUrl:t,clientUrl:e,clientStorageGetter:r,clientStorageSetter:n,refreshIntervalTime:i,autoRefreshToken:s=!0,autoSignIn:o=!0})=>{let a=ae(t),c=async(f,u,d)=>(await a.post(f,u,d)).data;return oe({schema:{context:{},events:{}},tsTypes:{},context:mn,preserveActionOrder:!0,id:"nhost",type:"parallel",states:{authentication:{initial:"checkAutoSignIn",on:{SESSION_UPDATE:[{cond:"hasSession",actions:["saveSession","persist","resetTimer","reportTokenChanged"],target:".signedIn"}]},states:{checkAutoSignIn:{always:[{cond:"isAutoSignInDisabled",target:"importingRefreshToken"}],invoke:{id:"autoSignIn",src:"autoSignIn",onDone:{target:"signedIn",actions:["saveSession","persist","reportTokenChanged"]},onError:"importingRefreshToken"}},importingRefreshToken:{invoke:{id:"importRefreshToken",src:"importRefreshToken",onDone:{actions:"saveRefreshToken",target:"starting"}}},starting:{always:[{cond:"isSignedIn",target:"signedIn"},{cond:"hasRefreshTokenWithoutSession",target:["authenticating.token","#nhost.token.running"]},"signedOut"]},signedOut:{tags:["ready"],initial:"noErrors",entry:"reportSignedOut",states:{noErrors:{},success:{},needsEmailVerification:{},needsSmsOtp:{},needsMfa:{},failed:{exit:"resetAuthenticationError",initial:"server",states:{server:{},validation:{states:{password:{},email:{},phoneNumber:{}}}}},signingOut:{entry:"destroyToken",exit:"clearContext",invoke:{src:"signout",id:"signingOut",onDone:{target:"success"},onError:{target:"failed.server"}}}},on:{SIGNIN_PASSWORD:[{cond:"invalidEmail",actions:["saveInvalidEmail"],target:".failed.validation.email"},{cond:"invalidPassword",actions:["saveInvalidPassword"],target:".failed.validation.password"},"#nhost.authentication.authenticating.password"],SIGNIN_PASSWORDLESS_EMAIL:[{cond:"invalidEmail",actions:"saveInvalidEmail",target:".failed.validation.email"},"#nhost.authentication.authenticating.passwordlessEmail"],SIGNIN_PASSWORDLESS_SMS:[{cond:"invalidPhoneNumber",actions:"saveInvalidPhoneNumber",target:".failed.validation.phoneNumber"},"#nhost.authentication.authenticating.passwordlessSms"],SIGNIN_PASSWORDLESS_SMS_OTP:[{cond:"invalidPhoneNumber",actions:"saveInvalidPhoneNumber",target:".failed.validation.phoneNumber"},"#nhost.authentication.authenticating.passwordlessSmsOtp"],SIGNUP_EMAIL_PASSWORD:[{cond:"invalidEmail",actions:"saveInvalidSignUpEmail",target:".failed.validation.email"},{cond:"invalidPassword",actions:"saveInvalidSignUpPassword",target:".failed.validation.password"},"#nhost.authentication.registering"],SIGNIN_ANONYMOUS:"#nhost.authentication.authenticating.anonymous",SIGNIN_MFA_TOTP:[{cond:"noMfaTicket",actions:["saveNoMfaTicketError"],target:".failed"},"#nhost.authentication.authenticating.mfa.totp"]}},authenticating:{states:{passwordlessEmail:{invoke:{src:"signInPasswordlessEmail",id:"authenticatePasswordlessEmail",onDone:"#nhost.authentication.signedOut.needsEmailVerification",onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},passwordlessSms:{invoke:{src:"signInPasswordlessSms",id:"authenticatePasswordlessSms",onDone:"#nhost.authentication.signedOut.needsSmsOtp",onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},passwordlessSmsOtp:{invoke:{src:"signInPasswordlessSmsOtp",id:"authenticatePasswordlessSmsOtp",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},password:{invoke:{src:"signInPassword",id:"authenticateUserWithPassword",onDone:[{cond:"hasMfaTicket",actions:["saveMfaTicket"],target:"#nhost.authentication.signedOut.needsMfa"},{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"}],onError:[{cond:"unverified",target:"#nhost.authentication.signedOut.needsEmailVerification"},{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}]}},token:{},anonymous:{invoke:{src:"signInAnonymous",id:"authenticateAnonymously",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed.server"}}},mfa:{states:{totp:{invoke:{src:"signInMfaTotp",id:"signInMfaTotp",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:["saveAuthenticationError"],target:"#nhost.authentication.signedOut.failed.server"}}}}}}},registering:{entry:"resetSignUpError",invoke:{src:"registerUser",id:"registerUser",onDone:[{cond:"hasSession",target:"#nhost.authentication.signedIn",actions:["saveSession","persist","reportTokenChanged"]},{target:"#nhost.authentication.signedOut.needsEmailVerification"}],onError:[{cond:"unverified",target:"#nhost.authentication.signedOut.needsEmailVerification"},{actions:"saveRegisrationError",target:"#nhost.authentication.signedOut.failed.server"}]}},signedIn:{tags:["ready"],type:"parallel",entry:"reportSignedIn",on:{SIGNOUT:"#nhost.authentication.signedOut.signingOut",DEANONYMIZE:{target:".deanonymizing"}},states:{refreshTimer:{id:"timer",initial:"idle",states:{disabled:{type:"final"},stopped:{always:{cond:"noToken",target:"idle"}},idle:{always:[{cond:"isAutoRefreshDisabled",target:"disabled"},{cond:"hasRefreshToken",target:"running"}]},running:{initial:"pending",entry:"resetTimer",states:{pending:{after:{"1000":{actions:"tickRefreshTimer",internal:!1,target:"pending"}},always:{cond:"refreshTimerShouldRefresh",target:"refreshing"}},refreshing:{invoke:{src:"refreshToken",id:"refreshToken",onDone:{actions:["saveSession","persist","resetTimer"],target:"pending"},onError:[]}}}}}},deanonymizing:{initial:"error",states:{error:{},success:{}}}}}}},token:{initial:"idle",states:{idle:{on:{TRY_TOKEN:"running"},initial:"noErrors",states:{noErrors:{},error:{}}},running:{invoke:{src:"refreshToken",id:"authenticateWithToken",onDone:{actions:["saveSession","persist","reportTokenChanged"],target:["#nhost.authentication.signedIn","idle.noErrors"]},onError:[{cond:"isSignedIn",target:"idle.error"},{target:["#nhost.authentication.signedOut","idle.error"]}]}}}}}},{actions:{reportSignedIn:$("SIGNED_IN"),reportSignedOut:$("SIGNED_OUT"),reportTokenChanged:$("TOKEN_CHANGED"),clearContext:k(()=>mn),saveSession:k({user:(f,u)=>{var d,l;return(l=(d=u.data)==null?void 0:d.session)==null?void 0:l.user},accessToken:(f,u)=>{var d,l,h,g;return{value:(l=(d=u.data)==null?void 0:d.session)==null?void 0:l.accessToken,expiresAt:new Date(Date.now()+((g=(h=u.data)==null?void 0:h.session)==null?void 0:g.accessTokenExpiresIn)*1e3)}},refreshToken:(f,u)=>{var d,l;return{value:(l=(d=u.data)==null?void 0:d.session)==null?void 0:l.refreshToken}}}),saveMfaTicket:k({mfa:(f,u)=>{var d,l;return(l=(d=u.data)==null?void 0:d.mfa)!=null?l:null}}),resetTimer:k({refreshTimer:(f,u)=>({elapsed:0,attempts:0})}),tickRefreshTimer:k({refreshTimer:(f,u)=>({elapsed:f.refreshTimer.elapsed+1,attempts:f.refreshTimer.attempts})}),saveAuthenticationError:k({errors:({errors:f},{data:{error:u}})=>({...f,authentication:u})}),resetAuthenticationError:k({errors:({errors:{authentication:f,...u}})=>u}),saveInvalidEmail:k({errors:({errors:f})=>({...f,authentication:qe})}),saveInvalidPassword:k({errors:({errors:f})=>({...f,authentication:Rt})}),saveInvalidPhoneNumber:k({errors:({errors:f})=>({...f,authentication:ps})}),saveRegisrationError:k({errors:({errors:f},{data:{error:u}})=>({...f,registration:u})}),resetSignUpError:k({errors:({errors:{registration:f,...u}})=>u}),saveInvalidSignUpPassword:k({errors:({errors:f})=>({...f,registration:qe})}),saveInvalidSignUpEmail:k({errors:({errors:f})=>({...f,registration:Rt})}),saveNoMfaTicketError:k({errors:({errors:f})=>({...f,registration:ms})}),saveRefreshToken:k({accessToken:(f,u)=>({...f.accessToken,expiresAt:u.data.expiresAt}),refreshToken:(f,u)=>({...f.refreshToken,value:u.data.refreshToken})}),persist:(f,{data:u})=>{if(n(nr,u.session.refreshToken),u.session.accessTokenExpiresIn){let d=new Date(Date.now()+u.session.accessTokenExpiresIn*1e3).toISOString();n(bt,d)}else n(bt,null)},destroyToken:()=>{n(nr,null),n(bt,null)}},guards:{isSignedIn:f=>!!f.user&&!!f.refreshToken.value&&!!f.accessToken.value,hasRefreshTokenWithoutSession:f=>!!f.refreshToken.value&&!f.user&&!f.accessToken.value,noToken:f=>!f.refreshToken.value,noMfaTicket:(f,{ticket:u})=>{var d;return!u&&!((d=f.mfa)!=null&&d.ticket)},hasRefreshToken:f=>!!f.refreshToken.value,isAutoRefreshDisabled:()=>!s,isAutoSignInDisabled:()=>!o,refreshTimerShouldRefresh:f=>f.refreshTimer.elapsed>Math.max((Date.now()-f.accessToken.expiresAt.getTime())/1e3-900,i),unverified:(f,{data:{error:u}})=>u.status===401&&u.message==="Email is not verified",hasSession:(f,u)=>{var d;return!!((d=u.data)!=null&&d.session)},hasMfaTicket:(f,u)=>{var d;return!!((d=u.data)!=null&&d.mfa)},invalidEmail:(f,{email:u})=>!Qe(u),invalidPassword:(f,{password:u})=>!lr(u),invalidPhoneNumber:(f,{phoneNumber:u})=>!Ao(u)},services:{signInPassword:(f,{email:u,password:d})=>c("/signin/email-password",{email:u,password:d}),signInPasswordlessSms:(f,{phoneNumber:u,options:d})=>c("/signin/passwordless/sms",{phoneNumber:u,options:ie(e,d)}),signInPasswordlessSmsOtp:(f,{phoneNumber:u,otp:d})=>c("/signin/passwordless/sms/otp",{phoneNumber:u,otp:d}),signInPasswordlessEmail:(f,{email:u,options:d})=>c("/signin/passwordless/email",{email:u,options:ie(e,d)}),signInAnonymous:f=>c("/signin/anonymous"),signInMfaTotp:(f,{ticket:u,otp:d})=>{var l;return c("/signin/mfa/totp",{ticket:u||((l=f.mfa)==null?void 0:l.ticket),otp:d})},refreshToken:async(f,u)=>{let d=u.type==="TRY_TOKEN"?u.token:f.refreshToken.value;return{session:await c("/token",{refreshToken:d})}},signout:(f,u)=>c("/signout",{refreshToken:f.refreshToken.value,all:!!u.all}),registerUser:(f,{email:u,password:d,options:l})=>c("/signup/email-password",{email:u,password:d,options:ie(e,l)}),autoSignIn:async()=>{if(typeof window=="undefined"||!window.location)throw Error("window is undefined or location does not exist");let{hash:f}=window.location;if(!f)return;let d=new URLSearchParams(f.slice(1)).get("refreshToken");if(d){let l=await c("/token",{refreshToken:d});return new ke("nhost").postMessage(d),{session:l}}},importRefreshToken:async()=>{let f=await r(bt),u=f?new Date(f):null;return{refreshToken:await r(nr),expiresAt:u}}}})};function dr(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}var dl={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};function vn(t,e){function r(i,s,o){if(typeof document!="undefined"){o=dr({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),i=encodeURIComponent(i).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var c in o)!o[c]||(a+="; "+c,o[c]!==!0&&(a+="="+o[c].split(";")[0]));return document.cookie=i+"="+t.write(s,i)+a}}function n(i){if(!(typeof document=="undefined"||arguments.length&&!i)){for(var s=document.cookie?document.cookie.split("; "):[],o={},a=0;a<s.length;a++){var c=s[a].split("="),f=c.slice(1).join("=");try{var u=decodeURIComponent(c[0]);if(o[u]=t.read(f,u),i===u)break}catch{}}return i?o[i]:o}}return Object.create({set:r,get:n,remove:function(i,s){r(i,"",dr({},s,{expires:-1}))},withAttributes:function(i){return vn(this.converter,dr({},this.attributes,i))},withConverter:function(i){return vn(dr({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var Lv=vn(dl,{path:"/"});var _o=typeof window!="undefined",hr=new Map,pr=t=>{var e;return _o&&localStorage?localStorage.getItem(t):(e=hr.get(t))!=null?e:null},mr=(t,e)=>{_o&&localStorage?e?localStorage.setItem(t,e):localStorage.removeItem(t):e?hr.set(t,e):hr.has(t)&&hr.delete(t)};var Pt,Nt,It,_t=class{constructor({backendUrl:e,clientUrl:r=typeof window!="undefined"&&(f=>(f=window.location)==null?void 0:f.origin)()||"",clientStorageGetter:n=pr,clientStorageSetter:i=mr,refreshIntervalTime:s=60,autoSignIn:o=!0,autoRefreshToken:a=!0,start:c=!0}){Le(this,Pt,void 0);Le(this,Nt,void 0);Le(this,It,new Set);this.backendUrl=e,this.clientUrl=r,this.machine=Io({backendUrl:e,clientUrl:r,refreshIntervalTime:s,clientStorageGetter:n,clientStorageSetter:i,autoSignIn:o,autoRefreshToken:a}),c&&(this.interpreter=me(this.machine),this.interpreter.start()),typeof window!="undefined"&&o&&(st(this,Nt,new ke("nhost")),M(this,Nt).addEventListener("message",u=>{var l;let d=(l=this.interpreter)==null?void 0:l.state.context.refreshToken;this.interpreter&&u!==d&&this.interpreter.send({type:"TRY_TOKEN",token:u})}))}get interpreter(){return M(this,Pt)}set interpreter(e){st(this,Pt,e),e&&M(this,It).forEach(r=>r(this))}onStart(e){M(this,It).add(e)}};Pt=new WeakMap,Nt=new WeakMap,It=new WeakMap;var ko=()=>typeof window!="undefined",xe=t=>!t||!t.accessToken.value||!t.refreshToken.value?null:{accessToken:t.accessToken.value,accessTokenExpiresIn:(t.accessToken.expiresAt.getTime()-Date.now())/1e3,refreshToken:t.refreshToken.value,user:t.user},Ze=(t,e)=>{e.forEach(r=>{typeof t[r]!="function"&&console.error(`clientStorage.${r} is not a function`)})},qo=(t,e)=>{if(e){if(t==="react-native"||t==="custom")return Ze(e,["getItem"]),r=>{var n;return(n=e.getItem)==null?void 0:n.call(e,r)};if(t==="capacitor")return Ze(e,["get"]),r=>{var n;return(n=e.get)==null?void 0:n.call(e,{key:r})};if(t==="expo-secure-storage")return Ze(e,["getItemAsync"]),r=>{var n;return(n=e.getItemAsync)==null?void 0:n.call(e,r)}}return pr},Do=(t,e)=>{if(e){if(t==="react-native"||t==="custom")return Ze(e,["setItem","removeItem"]),(r,n)=>{var i,s;n?(i=e.setItem)==null||i.call(e,r,n):(s=e.removeItem)==null||s.call(e,r)};if(t==="capacitor")return Ze(e,["set","remove"]),(r,n)=>{var i,s;n?(i=e.set)==null||i.call(e,{key:r,value:n}):(s=e.remove)==null||s.call(e,{key:r})};if(t==="expo-secure-storage")return Ze(e,["setItemAsync","deleteItemAsync"]),async(r,n)=>{var i,s;n?await((i=e.setItemAsync)==null?void 0:i.call(e,r,n)):(s=e.deleteItemAsync)==null||s.call(e,r)}}return mr};var Uo={message:"User is already signed in",status:100},pl={message:"User is not authenticated",status:101},ml={message:"User is not anonymous",status:101},vl={message:"Email needs verification",status:102},j,yn=class{constructor({url:e,autoRefreshToken:r=!0,autoLogin:n=!0,clientStorage:i,clientStorageType:s="web",clientStorageGetter:o,clientStorageSetter:a,refreshIntervalTime:c,start:f=!0,Client:u=_t}){Le(this,j,void 0);this.onTokenChangedSubscriptions=new Set;this.onAuthStateChangedSubscriptions=new Set;st(this,j,new u({backendUrl:e,autoRefreshToken:r,autoSignIn:n,start:f,clientStorageGetter:o||qo(s,i),clientStorageSetter:a||Do(s,i),refreshIntervalTime:c}))}async signUp(e){let r=await this.waitUntilReady(),{email:n,password:i,options:s}=e;return this.isAuthenticated()?{session:null,error:Uo}:new Promise(o=>{r.send({type:"SIGNUP_EMAIL_PASSWORD",email:n,password:i,options:s}),r.onTransition(a=>{if(a.matches({authentication:{signedOut:"needsEmailVerification"}}))return o({session:null,error:null});if(a.matches({authentication:{signedOut:"failed"}}))return o({session:null,error:a.context.errors.registration||null});if(a.matches({authentication:"signedIn"}))return o({session:xe(a.context),error:null})})})}async signIn(e){let r=await this.waitUntilReady();if(this.isAuthenticated())return{session:null,mfa:null,error:Uo};if("provider"in e){let{provider:n,options:i}=e,s=Ro(`${M(this,j).backendUrl}/v1/auth/signin/provider/${n}`,ie(M(this,j).clientUrl,i));return ko()&&(window.location.href=s),{providerUrl:s,provider:n,session:null,mfa:null,error:null}}return"email"in e&&"password"in e?new Promise(n=>{r.send({type:"SIGNIN_PASSWORD",...e}),r.onTransition(i=>{i.matches({authentication:"signedIn"})?n({session:xe(i.context),mfa:null,error:null}):i.matches({authentication:{signedOut:"needsEmailVerification"}})?n({session:null,mfa:null,error:vl}):i.matches({authentication:{signedOut:"needsMfa"}})?n({session:null,mfa:i.context.mfa,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})})}):"email"in e&&!("otp"in e)?new Promise(n=>{r.onTransition(i=>{i.matches({authentication:{signedOut:"needsEmailVerification"}})?n({session:null,mfa:null,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})}),r.send({type:"SIGNIN_PASSWORDLESS_EMAIL",...e})}):"phoneNumber"in e&&!("otp"in e)?new Promise(n=>{r.onTransition(i=>{i.matches({authentication:{signedOut:"needsSmsOtp"}})?n({session:null,mfa:null,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})}),r.send({type:"SIGNIN_PASSWORDLESS_SMS",...e})}):"otp"in e?new Promise(n=>{r.onTransition(i=>{i.matches({authentication:"signedIn"})?n({session:xe(i.context),mfa:null,error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({session:null,mfa:null,error:i.context.errors.authentication||null})}),r.send({type:"SIGNIN_PASSWORDLESS_SMS_OTP",...e})}):{session:null,mfa:null,error:{message:"Incorrect parameters",status:500}}}async signOut(e){let r=await this.waitUntilReady();return this.isAuthenticated()?new Promise(n=>{r.send({type:"SIGNOUT",all:e==null?void 0:e.all}),r.onTransition(i=>{i.matches({authentication:{signedOut:"success"}})?n({error:null}):i.matches({authentication:{signedOut:"failed"}})&&n({error:i.context.errors.signout||null})})}):{error:pl}}async resetPassword({email:e,options:r}){return new Promise(n=>{let i=me(Po(M(this,j)));i.onTransition(({event:s})=>{if(s.type==="ERROR")return n({error:s.error});if(s.type==="SUCCESS")return n({error:null})}),i.start(),i.send({type:"REQUEST",email:e,options:r})})}async changePassword(e){return new Promise(r=>{let n=me(Co(M(this,j)));n.onTransition(({event:i})=>{if(i.type==="ERROR")return r({error:i.error});if(i.type==="SUCCESS")return r({error:null})}),n.start(),n.send({type:"REQUEST",password:e.newPassword})})}async sendVerificationEmail(e){return new Promise(r=>{let n=me(No(M(this,j)));n.onTransition(({event:i})=>{if(i.type==="ERROR")return r({error:i.error});if(i.type==="SUCCESS")return r({error:null})}),n.start(),n.send({type:"REQUEST",email:e.email,options:e.options})})}async changeEmail({newEmail:e,options:r}){return new Promise(n=>{let i=me(Oo(M(this,j)));i.onTransition(({event:s})=>{if(s.type==="ERROR")return n({error:s.error});if(s.type==="SUCCESS")return n({error:null})}),i.start(),i.send({type:"REQUEST",email:e,options:r})})}async deanonymize(e){let r=await this.waitUntilReady();return new Promise(n=>{var a;if(!this.isAuthenticated()||!((a=r.state.context.user)!=null&&a.isAnonymous))return{error:ml};r.onTransition(c=>{c.matches({authentication:{signedIn:{deanonymizing:"success"}}})?n({error:null}):c.matches({authentication:{signedIn:{deanonymizing:"error"}}})&&n({error:c.context.errors.authentication||null})}),r.start();let{signInMethod:i,connection:s,...o}=e;r.send({type:"DEANONYMIZE",signInMethod:i,connection:s,options:o})})}onTokenChanged(e){var r;return M(this,j).interpreter?this.onTokenChangedSubscriptions.add((r=M(this,j).interpreter)==null?void 0:r.onTransition(({event:n,context:i})=>{n.type==="TOKEN_CHANGED"&&e(xe(i))})):console.log("onTokenChanged: no interpreter is set yet",e),()=>{this.onTokenChangedSubscriptions.forEach(n=>n.stop())}}onAuthStateChanged(e){var r;return M(this,j).interpreter?this.onAuthStateChangedSubscriptions.add((r=M(this,j).interpreter)==null?void 0:r.onTransition(({event:n,context:i})=>{n.type==="SIGNED_IN"?e("SIGNED_IN",xe(i)):n.type==="SIGNED_OUT"&&e("SIGNED_OUT",xe(i))})):console.log("onAuthStateChanged: no interpreter is set yet",e),()=>{this.onAuthStateChangedSubscriptions.forEach(n=>n.stop())}}isAuthenticated(){var e;return!!((e=M(this,j).interpreter)!=null&&e.state.matches({authentication:"signedIn"}))}async isAuthenticatedAsync(){return(await this.waitUntilReady()).state.matches({authentication:"signedIn"})}getAuthenticationStatus(){return this.isReady()?{isAuthenticated:this.isAuthenticated(),isLoading:!1}:{isAuthenticated:!1,isLoading:!0}}getJWTToken(){return this.getAccessToken()}getAccessToken(){var e,r;return(r=(e=M(this,j).interpreter)==null?void 0:e.state.context.accessToken.value)!=null?r:void 0}async refreshSession(e){try{let r=await this.waitUntilReady();return r.state.matches({token:"idle"})?void 0:new Promise(n=>{let i=e||r.state.context.refreshToken.value;if(!i)return n();r==null||r.onTransition(s=>{(s.matches({token:{idle:"error"}})||s.event.type==="TOKEN_CHANGED")&&n()}),r.send({type:"TRY_TOKEN",token:i})})}catch{return}}getSession(){var e,r;return xe((r=(e=M(this,j).interpreter)==null?void 0:e.state)==null?void 0:r.context)}getUser(){var e,r,n;return((n=(r=(e=M(this,j).interpreter)==null?void 0:e.state)==null?void 0:r.context)==null?void 0:n.user)||null}waitUntilReady(){let r=M(this,j).interpreter;if(!r)throw Error("Auth interpreter not set");return r.state.hasTag("ready")?Promise.resolve(r):new Promise((n,i)=>{let s=setTimeout(()=>i(`The state machine is not yet ready after ${15} seconds.`),15e3);r.onTransition(o=>{if(o.hasTag("ready"))return clearTimeout(s),n(r)})})}isReady(){var e,r;return!!((r=(e=M(this,j).interpreter)==null?void 0:e.state)!=null&&r.hasTag("ready"))}get client(){return M(this,j)}};j=new WeakMap;var Ja=Lt(Ga()),Mn=class{constructor({url:e}){this.url=e,this.httpClient=Ja.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:i}=e,s={};return r&&(s["x-nhost-bucket-id"]=r),i&&(s["x-nhost-file-id"]=i),n&&(s["x-nhost-file-name"]=n),s}generateAuthHeaders(){return!this.adminSecret&&!this.accessToken?null:this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:{Authorization:`Bearer ${this.accessToken}`}}};var Ln=class{constructor({url:e}){this.url=e,this.api=new Mn({url:e})}async upload(e){let r=new FormData;r.append("file",e.file);let{fileMetadata:n,error:i}=await this.api.upload({...e,file:r});return i?{fileMetadata:null,error:i}: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 Yu=Lt(ii()),si=class{constructor(e){let{url:r}=e;this.accessToken=null,this.instance=Yu.default.create({baseURL:r})}async call(e,r,n){let i={...this.generateAccessTokenHeaders(),...n==null?void 0:n.headers},s;try{s=await this.instance.post(e,r,{...n,headers:i})}catch(o){if(o instanceof Error)return{res:null,error:o}}return s?{res:s,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 Qu=Lt(ii()),oi=class{constructor(e){let{url:r}=e;this.url=r,this.accessToken=null,this.instance=Qu.default.create({baseURL:r})}async request(e,r,n){let i={...n==null?void 0:n.headers,...this.generateAccessTokenHeaders()},s="",o;try{o=(await this.instance.post("",{operationName:s||void 0,query:e,variables:r},{...n,headers:i})).data}catch(a){return a instanceof Error?{data:null,error:a}:(console.error(a),{data:null,error:new Error("Unable to get do GraphQL request")})}return typeof o!="object"||Array.isArray(o)||o===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:(o=o,o.errors?{data:null,error:o.errors}:{data:o.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 ai=class{constructor({backendUrl:e,refreshIntervalTime:r,clientStorageGetter:n,clientStorageSetter:i,clientStorage:s,clientStorageType:o,autoRefreshToken:a,autoLogin:c,start:f=!0,Client:u}){if(!e)throw new Error("Please specify a `backendUrl`. Docs: [todo]!");this.auth=new yn({url:`${e}/v1/auth`,refreshIntervalTime:r,clientStorageGetter:n,clientStorageSetter:i,clientStorage:s,clientStorageType:o,autoRefreshToken:a,autoLogin:c,start:f,Client:u}),this.storage=new Ln({url:`${e}/v1/storage`}),this.functions=new si({url:`${e}/v1/functions`}),this.graphql=new oi({url:`${e}/v1/graphql`}),this.storage.setAccessToken(this.auth.getAccessToken()),this.functions.setAccessToken(this.auth.getAccessToken()),this.graphql.setAccessToken(this.auth.getAccessToken()),this.auth.client.onStart(()=>{this.auth.onAuthStateChanged((d,l)=>{this.storage.setAccessToken(l==null?void 0:l.accessToken),this.functions.setAccessToken(l==null?void 0:l.accessToken),this.graphql.setAccessToken(l==null?void 0:l.accessToken)}),this.auth.onTokenChanged(d=>{this.storage.setAccessToken(d==null?void 0:d.accessToken),this.functions.setAccessToken(d==null?void 0:d.accessToken),this.graphql.setAccessToken(d==null?void 0:d.accessToken)})})}};var Zg=t=>new ai(t);export{ai as NhostClient,Zg as createClient};
|
|
10
|
+
/*! *****************************************************************************
|
|
11
|
+
Copyright (c) Microsoft Corporation.
|
|
12
|
+
|
|
13
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
14
|
+
purpose with or without fee is hereby granted.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
17
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
18
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
19
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
20
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
21
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
22
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
23
|
+
***************************************************************************** */
|
|
24
|
+
/*! js-cookie v3.0.1 | MIT */
|
|
5
25
|
//# sourceMappingURL=index.es.js.map
|