@nhost/nhost-js 1.6.2 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/{functions.d.ts → functions/index.d.ts} +11 -23
- package/dist/clients/functions/index.d.ts.map +1 -0
- package/dist/clients/functions/types.d.ts +36 -0
- package/dist/clients/functions/types.d.ts.map +1 -0
- package/dist/clients/{graphql.d.ts → graphql/index.d.ts} +10 -31
- package/dist/clients/graphql/index.d.ts.map +1 -0
- package/dist/clients/graphql/types.d.ts +32 -0
- package/dist/clients/graphql/types.d.ts.map +1 -0
- package/dist/clients/nhost.d.ts.map +1 -1
- package/dist/index.cjs.js +1 -1
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +151 -118
- package/dist/index.esm.js.map +1 -1
- package/dist/utils/types.d.ts +5 -20
- package/dist/utils/types.d.ts.map +1 -1
- package/package.json +5 -6
- package/umd/nhost-js.umd.js +8 -8
- package/umd/nhost-js.umd.js.map +1 -1
- package/dist/clients/functions.d.ts.map +0 -1
- package/dist/clients/graphql.d.ts.map +0 -1
package/umd/nhost-js.umd.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(E,Le){typeof exports=="object"&&typeof module<"u"?Le(exports,require("graphql")):typeof define=="function"&&define.amd?define(["exports","graphql"],Le):(E=typeof globalThis<"u"?globalThis:E||self,Le(E["@nhost/nhost-js"]={},E.graphql))})(this,function(E,Le){"use strict";function Vt(t){this.message=t}Vt.prototype=new Error,Vt.prototype.name="InvalidCharacterError";var Ur=typeof window<"u"&&window.atob&&window.atob.bind(window)||function(t){var e=String(t).replace(/=+$/,"");if(e.length%4==1)throw new Vt("'atob' failed: The string to be decoded is not correctly encoded.");for(var r,n,i=0,s=0,o="";n=e.charAt(s++);~n&&(r=i%4?64*r+n:n,i++%4)?o+=String.fromCharCode(255&r>>(-2*i&6)):0)n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(n);return o};function $i(t){var e=t.replace(/-/g,"+").replace(/_/g,"/");switch(e.length%4){case 0:break;case 2:e+="==";break;case 3:e+="=";break;default:throw"Illegal base64url string!"}try{return function(r){return decodeURIComponent(Ur(r).replace(/(.)/g,function(n,i){var s=i.charCodeAt(0).toString(16).toUpperCase();return s.length<2&&(s="0"+s),"%"+s}))}(e)}catch{return Ur(e)}}function nt(t){this.message=t}function Bi(t,e){if(typeof t!="string")throw new nt("Invalid token specified");var r=(e=e||{}).header===!0?0:1;try{return JSON.parse($i(t.split(".")[r]))}catch(n){throw new nt("Invalid token specified: "+n.message)}}nt.prototype=new Error,nt.prototype.name="InvalidTokenError";/*! *****************************************************************************
|
|
2
2
|
Copyright (c) Microsoft Corporation.
|
|
3
3
|
|
|
4
4
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
@@ -11,12 +11,12 @@
|
|
|
11
11
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
12
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
13
|
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
-
***************************************************************************** */var w=function(){return w=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},w.apply(this,arguments)};function Ct(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 x(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 D(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 C;(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"})(C||(C={}));var ce;(function(t){t.Parent="#_parent",t.Internal="#_internal"})(ce||(ce={}));var Ut=C.Start,Dt=C.Stop,Se=C.Raise,Ee=C.Send,hr=C.Cancel,Fn=C.NullEvent,_t=C.Assign;C.After,C.DoneState;var pr=C.Log,$n=C.Init,jt=C.Invoke;C.ErrorExecution;var vr=C.ErrorPlatform,qn=C.ErrorCustom,mr=C.Update,Bn=C.Choose,zn=C.Pure,yr=".",gr={},Lt="xstate.guard",Vn="",M=process.env.NODE_ENV==="production",Qe;function Mt(t,e,r){r===void 0&&(r=yr);var n=je(t,r),i=je(e,r);return R(i)?R(n)?i===n:!1:R(n)?n in i:Object.keys(n).every(function(s){return s in i?Mt(n[s],i[s]):!1})}function wr(t){try{return R(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 Ft(t,e){try{return Te(t)?t:t.toString().split(e)}catch{throw new Error("'".concat(t,"' is not a valid state path."))}}function Kn(t){return typeof t=="object"&&"value"in t&&"context"in t&&"event"in t&&"_event"in t}function je(t,e){if(Kn(t))return t.value;if(Te(t))return Xe(t);if(typeof t!="string")return t;var r=Ft(t,e);return Xe(r)}function Xe(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 Le(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 Sr(t,e,r){var n,i,s={};try{for(var o=b(Object.keys(t)),a=o.next();!a.done;a=o.next()){var u=a.value,c=t[u];!r(c)||(s[u]=e(c,u,t))}}catch(f){n={error:f}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}var Hn=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(u){r={error:u}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}};function Jn(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 u=a.value;s=s[e][u]}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}}function Ze(t){if(!t)return[[]];if(R(t))return[[t]];var e=L(Object.keys(t).map(function(r){var n=t[r];return typeof n!="string"&&(!n||!Object.keys(n).length)?[[r]]:Ze(t[r]).map(function(i){return[r].concat(i)})}));return e}function L(t){var e;return(e=[]).concat.apply(e,D([],x(t),!1))}function Er(t){return Te(t)?t:[t]}function Y(t){return t===void 0?[]:Er(t)}function et(t,e,r){var n,i;if(U(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 u=a.value,c=t[u];U(c)?s[u]=c(e,r.data):s[u]=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 Gn(t){return/^(done|error)\./.test(t)}function Tr(t){return!!(t instanceof Promise||t!==null&&(U(t)||typeof t=="object")&&U(t.then))}function Wn(t){return t!==null&&typeof t=="object"&&"transition"in t&&typeof t.transition=="function"}function Yn(t,e){var r,n,i=x([[],[]],2),s=i[0],o=i[1];try{for(var a=b(t),u=a.next();!u.done;u=a.next()){var c=u.value;e(c)?s.push(c):o.push(c)}}catch(f){r={error:f}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return[s,o]}function br(t,e){return Le(t.states,function(r,n){if(!!r){var i=(R(e)?void 0:e[n])||(r?r.current:void 0);if(!!i)return{current:i,states:br(r,i)}}})}function Qn(t,e){return{current:e,states:br(t,e)}}function xr(t,e,r,n){M||B(!!t,"Attempting to update undefined context");var i=t&&r.reduce(function(s,o){var a,u,c=o.assignment,f={state:n,action:o,_event:e},v={};if(U(c))v=c(s,e.data,f);else try{for(var h=b(Object.keys(c)),d=h.next();!d.done;d=h.next()){var l=d.value,p=c[l];v[l]=U(p)?p(s,e.data,f):p}}catch(y){a={error:y}}finally{try{d&&!d.done&&(u=h.return)&&u.call(h)}finally{if(a)throw a.error}}return Object.assign({},s,v)},t);return i}var B=function(){};M||(B=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 Te(t){return Array.isArray(t)}function U(t){return typeof t=="function"}function R(t){return typeof t=="string"}function Ar(t,e){if(!!t)return R(t)?{type:Lt,name:t,predicate:e?e[t]:void 0}:U(t)?{type:Lt,name:t.name,predicate:t}:t}function Xn(t){try{return"subscribe"in t&&U(t.subscribe)}catch{return!1}}var ue=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();Qe={},Qe[ue]=function(){return this},Qe[Symbol.observable]=function(){return this};function ve(t){return!!t&&"__xstatenode"in t}function Zn(t){return!!t&&typeof t.send=="function"}function $t(t,e){return R(t)||typeof t=="number"?w({type:t},e):t}function z(t,e){if(!R(t)&&"$$type"in t&&t.$$type==="scxml")return t;var r=$t(t);return w({name:r.type,data:r,$$type:"scxml",type:"external"},e)}function be(t,e){var r=Er(e).map(function(n){return typeof n>"u"||typeof n=="string"||ve(n)?{target:n,event:t}:w(w({},n),{event:t})});return r}function ei(t){if(!(t===void 0||t===Vn))return Y(t)}function ti(t,e,r){if(!M){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 Or(t,e,r,n,i){var s=t.options.guards,o={state:i,cond:e,_event:n};if(e.type===Lt)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 kr(t){return typeof t=="string"?{type:t}:t}function tt(t,e,r){var n=function(){},i=typeof t=="object",s=i?t:null;return{next:((i?t.next:t)||n).bind(s),error:((i?t.error:e)||n).bind(s),complete:((i?t.complete:r)||n).bind(s)}}function rt(t,e){return"".concat(t,":invocation[").concat(e,"]")}var xe=z({type:$n});function qt(t,e){return e&&e[t]||void 0}function Me(t,e){var r;if(R(t)||typeof t=="number"){var n=qt(t,e);U(n)?r={type:t,exec:n}:n?r=n:r={type:t,exec:void 0}}else if(U(t))r={type:t.name||t.toString(),exec:t};else{var n=qt(t.type,e);if(U(n))r=w(w({},t),{exec:n});else if(n){var i=n.type||t.type;r=w(w(w({},n),t),{type:i})}else r=t}return r}var le=function(t,e){if(!t)return[];var r=Te(t)?t:[t];return r.map(function(n){return Me(n,e)})};function Bt(t){var e=Me(t);return w(w({id:R(t)?t:e.id},e),{type:e.type})}function ri(t){return R(t)?{type:Se,event:t}:zt(t,{to:ce.Internal})}function ni(t){return{type:Se,_event:z(t.event)}}function zt(t,e){return{to:e?e.to:void 0,type:Ee,event:U(t)?t:$t(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:U(t)?t.name:wr(t)}}function ii(t,e,r,n){var i={_event:r},s=z(U(t.event)?t.event(e,r.data,i):t.event),o;if(R(t.delay)){var a=n&&n[t.delay];o=U(a)?a(e,r.data,i):a}else o=U(t.delay)?t.delay(e,r.data,i):t.delay;var u=U(t.to)?t.to(e,r.data,i):t.to;return w(w({},t),{to:u,_event:s,event:s.data,delay:o})}var si=function(t,e,r){return w(w({},t),{value:R(t.expr)?t.expr:t.expr(e,r.data,{_event:r})})},oi=function(t){return{type:hr,sendId:t}};function ai(t){var e=Bt(t);return{type:C.Start,activity:e,exec:void 0}}function ci(t){var e=U(t)?t:Bt(t);return{type:C.Stop,activity:e,exec:void 0}}function ui(t,e,r){var n=U(t.activity)?t.activity(e,r.data):t.activity,i=typeof n=="string"?{id:n}:n,s={type:C.Stop,activity:i};return s}var li=function(t){return{type:_t,assignment:t}};function fi(t,e){var r=e?"#".concat(e):"";return"".concat(C.After,"(").concat(t,")").concat(r)}function nt(t,e){var r="".concat(C.DoneState,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function it(t,e){var r="".concat(C.DoneInvoke,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Fe(t,e){var r="".concat(C.ErrorPlatform,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}var di=function(t){var e,r,n=[];try{for(var i=b(t),s=i.next();!s.done;s=i.next())for(var o=s.value,a=0;a<o.length;){if(o[a].type===_t){n.push(o[a]),o.splice(a,1);continue}a++}}catch(u){e={error:u}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n};function st(t,e,r,n,i,s,o){o===void 0&&(o=!1);var a=o?[]:di(i),u=a.length?xr(r,n,a,e):r,c=o?[r]:void 0,f=[];function v(l){var p;switch(l.type){case Se:return ni(l);case Ee:var y=ii(l,u,n,t.options.delays);return M||B(!R(l.delay)||typeof y.delay=="number","No delay reference for delay expression '".concat(l.delay,"' was found on machine '").concat(t.id,"'")),s&&y.to!==ce.Internal&&f.push(y),y;case pr:{var S=si(l,u,n);return s==null||s(S,u,n),S}case Bn:{var g=l,E=(p=g.conds.find(function(X){var ae=Ar(X.cond,t.options.guards);return!ae||Or(t,ae,u,n,s?void 0:e)}))===null||p===void 0?void 0:p.actions;if(!E)return[];var N=x(st(t,e,u,n,[le(Y(E),t.options.actions)],s,o),2),A=N[0],j=N[1];return u=j,c==null||c.push(u),A}case zn:{var E=l.get(u,n.data);if(!E)return[];var O=x(st(t,e,u,n,[le(Y(E),t.options.actions)],s,o),2),I=O[0],P=O[1];return u=P,c==null||c.push(u),I}case Dt:{var S=ui(l,u,n);return s==null||s(S,r,n),S}case _t:{u=xr(u,n,[l],s?void 0:e),c==null||c.push(u);break}default:var T=Me(l,t.options.actions),_=T.exec;if(s)s(T,u,n);else if(_&&c){var G=c.length-1;T=w(w({},T),{exec:function(X){for(var ae=[],Ue=1;Ue<arguments.length;Ue++)ae[Ue-1]=arguments[Ue];_.apply(void 0,D([c[G]],x(ae),!1))}})}return T}}function h(l){var p,y,S=[];try{for(var g=b(l),E=g.next();!E.done;E=g.next()){var N=E.value,A=v(N);A&&(S=S.concat(A))}}catch(j){p={error:j}}finally{try{E&&!E.done&&(y=g.return)&&y.call(g)}finally{if(p)throw p.error}}return f.forEach(function(j){s(j,u,n)}),f.length=0,S}var d=L(i.map(h));return[d,u]}var Ae=function(t,e){var r=e(t);return r};function Rr(t){var e;return e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}},e[ue]=function(){return this},e}function hi(t,e,r,n){var i,s=kr(t.src),o=(i=e==null?void 0:e.options.services)===null||i===void 0?void 0:i[s.type],a=t.data?et(t.data,r,n):void 0,u=o?Nr(o,t.id,a):Rr(t.id);return u.meta=t,u}function Nr(t,e,r){var n=Rr(e);if(n.deferred=!0,ve(t)){var i=n.state=Ae(void 0,function(){return(r?t.withContext(r):t).initialState});n.getSnapshot=function(){return i}}return n}function pi(t){try{return typeof t.send=="function"}catch{return!1}}function vi(t){return pi(t)&&"id"in t}function mi(t){var e;return w((e={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}},e[ue]=function(){return this},e),t)}var ot=function(t){return t.type==="atomic"||t.type==="final"};function Ir(t){return Object.keys(t.states).map(function(e){return t.states[e]})}function $e(t){return Ir(t).filter(function(e){return e.type!=="history"})}function Pr(t){var e=[t];return ot(t)?e:e.concat(L($e(t).map(Pr)))}function qe(t,e){var r,n,i,s,o,a,u,c,f=new Set(t),v=Vt(f),h=new Set(e);try{for(var d=b(h),l=d.next();!l.done;l=d.next())for(var p=l.value,y=p.parent;y&&!h.has(y);)h.add(y),y=y.parent}catch(P){r={error:P}}finally{try{l&&!l.done&&(n=d.return)&&n.call(d)}finally{if(r)throw r.error}}var S=Vt(h);try{for(var g=b(h),E=g.next();!E.done;E=g.next()){var p=E.value;if(p.type==="compound"&&(!S.get(p)||!S.get(p).length))v.get(p)?v.get(p).forEach(function(T){return h.add(T)}):p.initialStateNodes.forEach(function(T){return h.add(T)});else if(p.type==="parallel")try{for(var N=(o=void 0,b($e(p))),A=N.next();!A.done;A=N.next()){var j=A.value;h.has(j)||(h.add(j),v.get(j)?v.get(j).forEach(function(T){return h.add(T)}):j.initialStateNodes.forEach(function(T){return h.add(T)}))}}catch(T){o={error:T}}finally{try{A&&!A.done&&(a=N.return)&&a.call(N)}finally{if(o)throw o.error}}}}catch(P){i={error:P}}finally{try{E&&!E.done&&(s=g.return)&&s.call(g)}finally{if(i)throw i.error}}try{for(var O=b(h),I=O.next();!I.done;I=O.next())for(var p=I.value,y=p.parent;y&&!h.has(y);)h.add(y),y=y.parent}catch(P){u={error:P}}finally{try{I&&!I.done&&(c=O.return)&&c.call(O)}finally{if(u)throw u.error}}return h}function Cr(t,e){var r=e.get(t);if(!r)return{};if(t.type==="compound"){var n=r[0];if(n){if(ot(n))return n.key}else return{}}var i={};return r.forEach(function(s){i[s.key]=Cr(s,e)}),i}function Vt(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 yi(t,e){var r=qe([t],e);return Cr(t,Vt(r))}function Be(t,e){return Array.isArray(t)?t.some(function(r){return r===e}):t instanceof Set?t.has(e):!1}function gi(t){return D([],x(new Set(L(D([],x(t.map(function(e){return e.ownEvents})),!1)))),!1)}function at(t,e){return e.type==="compound"?$e(e).some(function(r){return r.type==="final"&&Be(t,r)}):e.type==="parallel"?$e(e).every(function(r){return at(t,r)}):!1}function wi(t){return t===void 0&&(t=[]),t.reduce(function(e,r){return r.meta!==void 0&&(e[r.id]=r.meta),e},{})}function Ur(t){return new Set(L(t.map(function(e){return e.tags})))}function Dr(t,e){if(t===e)return!0;if(t===void 0||e===void 0)return!1;if(R(t)||R(e))return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(i){return Dr(t[i],e[i])})}function Si(t){return typeof t!="object"||t===null?!1:"value"in t&&"_event"in t}function Ei(t,e){var r=t.exec,n=w(w({},t),{exec:r!==void 0?function(){return r(e.context,e.event,{action:t,state:e,_event:e._event})}:void 0});return n}var ee=function(){function t(e){var r=this,n;this.actions=[],this.activities=gr,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||gr,this.meta=wi(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 gi(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=xe;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=xe;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="."),R(e))return[e];var i=Object.keys(e);return i.concat.apply(i,D([],x(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=Ct(e,["configuration","transitions","tags","machine"]);return w(w({},n),{tags:Array.from(r)})},t.prototype.matches=function(e){return Mt(e,this.value)},t.prototype.hasTag=function(e){return this.tags.has(e)},t.prototype.can=function(e){var r;M&&B(!!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}(),Ti={deferEvents:!1},_r=function(){function t(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=w(w({},Ti),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}(),Kt=new Map,bi=0,ct={bookId:function(){return"x:".concat(bi++)},register:function(t,e){return Kt.set(t,e),t},get:function(t){return Kt.get(t)},free:function(t){Kt.delete(t)}};function Ht(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;M||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 xi(){var t=Ht();if(t&&"__xstate__"in t)return t.__xstate__}function Ai(t){if(!!Ht()){var e=xi();e&&e.register(t)}}function Oi(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 c=i.shift();r=t.transition(r,c,u),n.forEach(function(f){return f.next(r)})}s=!1}},a=mi({id:e.id,send:function(c){i.push(c),o()},getSnapshot:function(){return r},subscribe:function(c,f,v){var h=tt(c,f,v);return n.add(h),h.next(r),{unsubscribe:function(){n.delete(h)}}}}),u={parent:e.parent,self:a,id:e.id||"anonymous",observers:n};return r=t.start?t.start(u):r,a}var ki={sync:!1,autoForward:!1},q;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(q||(q={}));var Ri=function(){function t(e,r){r===void 0&&(r=t.defaultOptions);var n=this;this.machine=e,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=q.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(f,v){if(Te(f))return n.batch(f),n.state;var h=z($t(f,v));if(n.status===q.Stopped)return M||B(!1,'Event "'.concat(h.name,'" was sent to stopped service "').concat(n.machine.id,`". This service has already reached its final state, and will not transition.
|
|
14
|
+
***************************************************************************** */var y=function(){return y=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},y.apply(this,arguments)};function zt(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 R(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 A(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 L(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 C;(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"})(C||(C={}));var ee;(function(t){t.Parent="#_parent",t.Internal="#_internal"})(ee||(ee={}));var it=C.Start,st=C.Stop,ge=C.Raise,ye=C.Send,Ht=C.Cancel,Cr=C.NullEvent,ot=C.Assign,qi=C.After,Vi=C.DoneState,at=C.Log,_r=C.Init,ct=C.Invoke,zi=C.ErrorExecution,Kt=C.ErrorPlatform,Gt=C.ErrorCustom,ut=C.Update,Dr=C.Choose,Lr=C.Pure;const Hi=Object.freeze(Object.defineProperty({__proto__:null,after:qi,assign:ot,cancel:Ht,choose:Dr,doneState:Vi,error:Gt,errorExecution:zi,errorPlatform:Kt,init:_r,invoke:ct,log:at,nullEvent:Cr,pure:Lr,raise:ge,send:ye,start:it,stop:st,update:ut},Symbol.toStringTag,{value:"Module"}));var Mr=".",jr={},Jt="xstate.guard",Ki="",F=process.env.NODE_ENV==="production",lt;function Wt(t,e,r){r===void 0&&(r=Mr);var n=Me(t,r),i=Me(e,r);return I(i)?I(n)?i===n:!1:I(n)?n in i:Object.keys(n).every(function(s){return s in i?Wt(n[s],i[s]):!1})}function Fr(t){try{return I(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 Yt(t,e){try{return Te(t)?t:t.toString().split(e)}catch{throw new Error("'".concat(t,"' is not a valid state path."))}}function Gi(t){return typeof t=="object"&&"value"in t&&"context"in t&&"event"in t&&"_event"in t}function Me(t,e){if(Gi(t))return t.value;if(Te(t))return dt(t);if(typeof t!="string")return t;var r=Yt(t,e);return dt(r)}function dt(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 je(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 $r(t,e,r){var n,i,s={};try{for(var o=R(Object.keys(t)),a=o.next();!a.done;a=o.next()){var u=a.value,c=t[u];r(c)&&(s[u]=e(c,u,t))}}catch(l){n={error:l}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}var Ji=function(t){return function(e){var r,n,i=e;try{for(var s=R(t),o=s.next();!o.done;o=s.next()){var a=o.value;i=i[a]}}catch(u){r={error:u}}finally{try{o&&!o.done&&(n=s.return)&&n.call(s)}finally{if(r)throw r.error}}return i}};function Wi(t,e){return function(r){var n,i,s=r;try{for(var o=R(t),a=o.next();!a.done;a=o.next()){var u=a.value;s=s[e][u]}}catch(c){n={error:c}}finally{try{a&&!a.done&&(i=o.return)&&i.call(o)}finally{if(n)throw n.error}}return s}}function ft(t){if(!t)return[[]];if(I(t))return[[t]];var e=$(Object.keys(t).map(function(r){var n=t[r];return typeof n!="string"&&(!n||!Object.keys(n).length)?[[r]]:ft(t[r]).map(function(i){return[r].concat(i)})}));return e}function $(t){var e;return(e=[]).concat.apply(e,L([],A(t),!1))}function Br(t){return Te(t)?t:[t]}function W(t){return t===void 0?[]:Br(t)}function ht(t,e,r){var n,i;if(_(t))return t(e,r.data);var s={};try{for(var o=R(Object.keys(t)),a=o.next();!a.done;a=o.next()){var u=a.value,c=t[u];_(c)?s[u]=c(e,r.data):s[u]=c}}catch(l){n={error:l}}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 qr(t){return!!(t instanceof Promise||t!==null&&(_(t)||typeof t=="object")&&_(t.then))}function Qi(t){return t!==null&&typeof t=="object"&&"transition"in t&&typeof t.transition=="function"}function Xi(t,e){var r,n,i=A([[],[]],2),s=i[0],o=i[1];try{for(var a=R(t),u=a.next();!u.done;u=a.next()){var c=u.value;e(c)?s.push(c):o.push(c)}}catch(l){r={error:l}}finally{try{u&&!u.done&&(n=a.return)&&n.call(a)}finally{if(r)throw r.error}}return[s,o]}function Vr(t,e){return je(t.states,function(r,n){if(r){var i=(I(e)?void 0:e[n])||(r?r.current:void 0);if(i)return{current:i,states:Vr(r,i)}}})}function Zi(t,e){return{current:e,states:Vr(t,e)}}function zr(t,e,r,n){F||B(!!t,"Attempting to update undefined context");var i=t&&r.reduce(function(s,o){var a,u,c=o.assignment,l={state:n,action:o,_event:e},v={};if(_(c))v=c(s,e.data,l);else try{for(var h=R(Object.keys(c)),f=h.next();!f.done;f=h.next()){var d=f.value,p=c[d];v[d]=_(p)?p(s,e.data,l):p}}catch(g){a={error:g}}finally{try{f&&!f.done&&(u=h.return)&&u.call(h)}finally{if(a)throw a.error}}return Object.assign({},s,v)},t);return i}var B=function(){};F||(B=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 Te(t){return Array.isArray(t)}function _(t){return typeof t=="function"}function I(t){return typeof t=="string"}function Hr(t,e){if(t)return I(t)?{type:Jt,name:t,predicate:e?e[t]:void 0}:_(t)?{type:Jt,name:t.name,predicate:t}:t}function es(t){try{return"subscribe"in t&&_(t.subscribe)}catch{return!1}}var de=function(){return typeof Symbol=="function"&&Symbol.observable||"@@observable"}();lt={},lt[de]=function(){return this},lt[Symbol.observable]=function(){return this};function ne(t){return!!t&&"__xstatenode"in t}function ts(t){return!!t&&typeof t.send=="function"}var rs=function(){var t=0;return function(){return t++,t.toString(16)}}();function Qt(t,e){return I(t)||typeof t=="number"?y({type:t},e):t}function z(t,e){if(!I(t)&&"$$type"in t&&t.$$type==="scxml")return t;var r=Qt(t);return y({name:r.type,data:r,$$type:"scxml",type:"external"},e)}function be(t,e){var r=Br(e).map(function(n){return typeof n>"u"||typeof n=="string"||ne(n)?{target:n,event:t}:y(y({},n),{event:t})});return r}function ns(t){if(!(t===void 0||t===Ki))return W(t)}function is(t,e,r){if(!F){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 Kr(t,e,r,n,i){var s=t.options.guards,o={state:i,cond:e,_event:n};if(e.type===Jt)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 Gr(t){return typeof t=="string"?{type:t}:t}function pt(t,e,r){var n=function(){},i=typeof t=="object",s=i?t:null;return{next:((i?t.next:t)||n).bind(s),error:((i?t.error:e)||n).bind(s),complete:((i?t.complete:r)||n).bind(s)}}function vt(t,e){return"".concat(t,":invocation[").concat(e,"]")}var Ee=z({type:_r});function mt(t,e){return e&&e[t]||void 0}function Ae(t,e){var r;if(I(t)||typeof t=="number"){var n=mt(t,e);_(n)?r={type:t,exec:n}:n?r=n:r={type:t,exec:void 0}}else if(_(t))r={type:t.name||t.toString(),exec:t};else{var n=mt(t.type,e);if(_(n))r=y(y({},t),{exec:n});else if(n){var i=n.type||t.type;r=y(y(y({},n),t),{type:i})}else r=t}return r}var ie=function(t,e){if(!t)return[];var r=Te(t)?t:[t];return r.map(function(n){return Ae(n,e)})};function gt(t){var e=Ae(t);return y(y({id:I(t)?t:e.id},e),{type:e.type})}function Jr(t){return I(t)?{type:ge,event:t}:fe(t,{to:ee.Internal})}function Wr(t){return{type:ge,_event:z(t.event)}}function fe(t,e){return{to:e?e.to:void 0,type:ye,event:_(t)?t:Qt(t),delay:e?e.delay:void 0,id:e&&e.id!==void 0?e.id:_(t)?t.name:Fr(t)}}function Yr(t,e,r,n){var i={_event:r},s=z(_(t.event)?t.event(e,r.data,i):t.event),o;if(I(t.delay)){var a=n&&n[t.delay];o=_(a)?a(e,r.data,i):a}else o=_(t.delay)?t.delay(e,r.data,i):t.delay;var u=_(t.to)?t.to(e,r.data,i):t.to;return y(y({},t),{to:u,_event:s,event:s.data,delay:o})}function Xt(t,e){return fe(t,y(y({},e),{to:ee.Parent}))}function ss(t,e,r){return fe(e,y(y({},r),{to:t}))}function os(){return Xt(ut)}function as(t,e){return fe(t,y(y({},e),{to:function(r,n,i){var s=i._event;return s.origin}}))}var cs=function(t,e){return{context:t,event:e}};function us(t,e){return t===void 0&&(t=cs),{type:at,label:e,expr:t}}var Qr=function(t,e,r){return y(y({},t),{value:I(t.expr)?t.expr:t.expr(e,r.data,{_event:r})})},Xr=function(t){return{type:Ht,sendId:t}};function Zr(t){var e=gt(t);return{type:C.Start,activity:e,exec:void 0}}function en(t){var e=_(t)?t:gt(t);return{type:C.Stop,activity:e,exec:void 0}}function tn(t,e,r){var n=_(t.activity)?t.activity(e,r.data):t.activity,i=typeof n=="string"?{id:n}:n,s={type:C.Stop,activity:i};return s}var rn=function(t){return{type:ot,assignment:t}};function ls(t){return typeof t=="object"&&"type"in t}function nn(t,e){var r=e?"#".concat(e):"";return"".concat(C.After,"(").concat(t,")").concat(r)}function Fe(t,e){var r="".concat(C.DoneState,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function $e(t,e){var r="".concat(C.DoneInvoke,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function Oe(t,e){var r="".concat(C.ErrorPlatform,".").concat(t),n={type:r,data:e};return n.toString=function(){return r},n}function ds(t){return{type:C.Pure,get:t}}function fs(t,e){if(!F&&(!t||typeof t=="function")){var r=t;t=function(){for(var n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var s=typeof r=="function"?r.apply(void 0,L([],A(n),!1)):r;if(!s)throw new Error("Attempted to forward event to undefined actor. This risks an infinite loop in the sender.");return s}}return fe(function(n,i){return i},y(y({},e),{to:t}))}function hs(t,e){return Xt(function(r,n,i){return{type:Gt,data:_(t)?t(r,n,i):t}},y(y({},e),{to:ee.Parent}))}function ps(t){return{type:C.Choose,conds:t}}var vs=function(t){var e,r,n=[];try{for(var i=R(t),s=i.next();!s.done;s=i.next())for(var o=s.value,a=0;a<o.length;){if(o[a].type===ot){n.push(o[a]),o.splice(a,1);continue}a++}}catch(u){e={error:u}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(e)throw e.error}}return n};function Be(t,e,r,n,i,s,o){o===void 0&&(o=!1);var a=o?[]:vs(i),u=a.length?zr(r,n,a,e):r,c=o?[r]:void 0,l=[];function v(d){var p;switch(d.type){case ge:return Wr(d);case ye:var g=Yr(d,u,n,t.options.delays);return F||B(!I(d.delay)||typeof g.delay=="number","No delay reference for delay expression '".concat(d.delay,"' was found on machine '").concat(t.id,"'")),s&&g.to!==ee.Internal&&l.push(g),g;case at:{var w=Qr(d,u,n);return s==null||s(w,u,n),w}case Dr:{var S=d,T=(p=S.conds.find(function(X){var le=Hr(X.cond,t.options.guards);return!le||Kr(t,le,u,n,s?void 0:e)}))===null||p===void 0?void 0:p.actions;if(!T)return[];var P=A(Be(t,e,u,n,[ie(W(T),t.options.actions)],s,o),2),k=P[0],j=P[1];return u=j,c==null||c.push(u),k}case Lr:{var T=d.get(u,n.data);if(!T)return[];var x=A(Be(t,e,u,n,[ie(W(T),t.options.actions)],s,o),2),U=x[0],D=x[1];return u=D,c==null||c.push(u),U}case st:{var w=tn(d,u,n);return s==null||s(w,r,n),w}case ot:{u=zr(u,n,[d],s?void 0:e),c==null||c.push(u);break}default:var b=Ae(d,t.options.actions),M=b.exec;if(s)s(b,u,n);else if(M&&c){var J=c.length-1;b=y(y({},b),{exec:function(X){for(var le=[],Ce=1;Ce<arguments.length;Ce++)le[Ce-1]=arguments[Ce];M.apply(void 0,L([c[J]],A(le),!1))}})}return b}}function h(d){var p,g,w=[];try{for(var S=R(d),T=S.next();!T.done;T=S.next()){var P=T.value,k=v(P);k&&(w=w.concat(k))}}catch(j){p={error:j}}finally{try{T&&!T.done&&(g=S.return)&&g.call(S)}finally{if(p)throw p.error}}return l.forEach(function(j){s(j,u,n)}),l.length=0,w}var f=$(i.map(h));return[f,u]}const ms=Object.freeze(Object.defineProperty({__proto__:null,actionTypes:Hi,after:nn,assign:rn,cancel:Xr,choose:ps,done:Fe,doneInvoke:$e,error:Oe,escalate:hs,forwardTo:fs,getActionFunction:mt,initEvent:Ee,isActionObject:ls,log:us,pure:ds,raise:Jr,resolveActions:Be,resolveLog:Qr,resolveRaise:Wr,resolveSend:Yr,resolveStop:tn,respond:as,send:fe,sendParent:Xt,sendTo:ss,sendUpdate:os,start:Zr,stop:en,toActionObject:Ae,toActionObjects:ie,toActivityDefinition:gt},Symbol.toStringTag,{value:"Module"}));var yt=[],Re=function(t,e){yt.push(t);var r=e(t);return yt.pop(),r},gs=function(t){return t(yt[yt.length-1])};function sn(t){var e;return e={id:t,send:function(){},subscribe:function(){return{unsubscribe:function(){}}},getSnapshot:function(){},toJSON:function(){return{id:t}}},e[de]=function(){return this},e}function ys(t,e,r,n){var i,s=Gr(t.src),o=(i=e==null?void 0:e.options.services)===null||i===void 0?void 0:i[s.type],a=t.data?ht(t.data,r,n):void 0,u=o?Zt(o,t.id,a):sn(t.id);return u.meta=t,u}function Zt(t,e,r){var n=sn(e);if(n.deferred=!0,ne(t)){var i=n.state=Re(void 0,function(){return(r?t.withContext(r):t).initialState});n.getSnapshot=function(){return i}}return n}function Es(t){try{return typeof t.send=="function"}catch{return!1}}function ws(t){return Es(t)&&"id"in t}function Ss(t){var e;return y((e={subscribe:function(){return{unsubscribe:function(){}}},id:"anonymous",getSnapshot:function(){}},e[de]=function(){return this},e),t)}var Et=function(t){return t.type==="atomic"||t.type==="final"};function on(t){return Object.keys(t.states).map(function(e){return t.states[e]})}function qe(t){return on(t).filter(function(e){return e.type!=="history"})}function an(t){var e=[t];return Et(t)?e:e.concat($(qe(t).map(an)))}function Ve(t,e){var r,n,i,s,o,a,u,c,l=new Set(t),v=er(l),h=new Set(e);try{for(var f=R(h),d=f.next();!d.done;d=f.next())for(var p=d.value,g=p.parent;g&&!h.has(g);)h.add(g),g=g.parent}catch(D){r={error:D}}finally{try{d&&!d.done&&(n=f.return)&&n.call(f)}finally{if(r)throw r.error}}var w=er(h);try{for(var S=R(h),T=S.next();!T.done;T=S.next()){var p=T.value;if(p.type==="compound"&&(!w.get(p)||!w.get(p).length))v.get(p)?v.get(p).forEach(function(b){return h.add(b)}):p.initialStateNodes.forEach(function(b){return h.add(b)});else if(p.type==="parallel")try{for(var P=(o=void 0,R(qe(p))),k=P.next();!k.done;k=P.next()){var j=k.value;h.has(j)||(h.add(j),v.get(j)?v.get(j).forEach(function(b){return h.add(b)}):j.initialStateNodes.forEach(function(b){return h.add(b)}))}}catch(b){o={error:b}}finally{try{k&&!k.done&&(a=P.return)&&a.call(P)}finally{if(o)throw o.error}}}}catch(D){i={error:D}}finally{try{T&&!T.done&&(s=S.return)&&s.call(S)}finally{if(i)throw i.error}}try{for(var x=R(h),U=x.next();!U.done;U=x.next())for(var p=U.value,g=p.parent;g&&!h.has(g);)h.add(g),g=g.parent}catch(D){u={error:D}}finally{try{U&&!U.done&&(c=x.return)&&c.call(x)}finally{if(u)throw u.error}}return h}function cn(t,e){var r=e.get(t);if(!r)return{};if(t.type==="compound"){var n=r[0];if(n){if(Et(n))return n.key}else return{}}var i={};return r.forEach(function(s){i[s.key]=cn(s,e)}),i}function er(t){var e,r,n=new Map;try{for(var i=R(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 Ts(t,e){var r=Ve([t],e);return cn(t,er(r))}function ze(t,e){return Array.isArray(t)?t.some(function(r){return r===e}):t instanceof Set?t.has(e):!1}function bs(t){return L([],A(new Set($(L([],A(t.map(function(e){return e.ownEvents})),!1)))),!1)}function wt(t,e){return e.type==="compound"?qe(e).some(function(r){return r.type==="final"&&ze(t,r)}):e.type==="parallel"?qe(e).every(function(r){return wt(t,r)}):!1}function As(t){return t===void 0&&(t=[]),t.reduce(function(e,r){return r.meta!==void 0&&(e[r.id]=r.meta),e},{})}function un(t){return new Set($(t.map(function(e){return e.tags})))}function ln(t,e){if(t===e)return!0;if(t===void 0||e===void 0)return!1;if(I(t)||I(e))return t===e;var r=Object.keys(t),n=Object.keys(e);return r.length===n.length&&r.every(function(i){return ln(t[i],e[i])})}function Os(t){return typeof t!="object"||t===null?!1:"value"in t&&"_event"in t}function Rs(t,e){var r=t.exec,n=y(y({},t),{exec:r!==void 0?function(){return r(e.context,e.event,{action:t,state:e,_event:e._event})}:void 0});return n}var te=function(){function t(e){var r=this,n;this.actions=[],this.activities=jr,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||jr,this.meta=As(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 bs(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=Ee;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=Ee;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="."),I(e))return[e];var i=Object.keys(e);return i.concat.apply(i,L([],A(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=zt(e,["configuration","transitions","tags","machine"]);return y(y({},n),{tags:Array.from(r)})},t.prototype.matches=function(e){return Wt(e,this.value)},t.prototype.hasTag=function(e){return this.tags.has(e)},t.prototype.can=function(e){var r;F&&B(!!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}(),ks={deferEvents:!1},dn=function(){function t(e){this.processingEvent=!1,this.queue=[],this.initialized=!1,this.options=y(y({},ks),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}(),tr=new Map,xs=0,St={bookId:function(){return"x:".concat(xs++)},register:function(t,e){return tr.set(t,e),t},get:function(t){return tr.get(t)},free:function(t){tr.delete(t)}};function rr(){if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;F||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 Is(){var t=rr();if(t&&"__xstate__"in t)return t.__xstate__}function Ns(t){if(rr()){var e=Is();e&&e.register(t)}}function Ps(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 c=i.shift();r=t.transition(r,c,u),n.forEach(function(l){return l.next(r)})}s=!1}},a=Ss({id:e.id,send:function(c){i.push(c),o()},getSnapshot:function(){return r},subscribe:function(c,l,v){var h=pt(c,l,v);return n.add(h),h.next(r),{unsubscribe:function(){n.delete(h)}}}}),u={parent:e.parent,self:a,id:e.id||"anonymous",observers:n};return r=t.start?t.start(u):r,a}var nr={sync:!1,autoForward:!1},q;(function(t){t[t.NotStarted=0]="NotStarted",t[t.Running=1]="Running",t[t.Stopped=2]="Stopped"})(q||(q={}));var Us=function(){function t(e,r){r===void 0&&(r=t.defaultOptions);var n=this;this.machine=e,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=q.NotStarted,this.children=new Map,this.forwardTo=new Set,this._outgoingQueue=[],this.init=this.start,this.send=function(l,v){if(Te(l))return n.batch(l),n.state;var h=z(Qt(l,v));if(n.status===q.Stopped)return F||B(!1,'Event "'.concat(h.name,'" was sent to stopped service "').concat(n.machine.id,`". This service has already reached its final state, and will not transition.
|
|
15
15
|
Event: `).concat(JSON.stringify(h.data))),n.state;if(n.status!==q.Running&&!n.options.deferEvents)throw new Error('Event "'.concat(h.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.
|
|
16
|
-
Event: `).concat(JSON.stringify(h.data)));return n.scheduler.schedule(function(){n.forward(h);var
|
|
17
|
-
Event: `).concat(JSON.stringify(event)));else if(this.status!==q.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.'));if(!!e.length){var n=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule(function(){var i,s,o=r.state,a=!1,u=[],c=function(d){var l=z(d);r.forward(l),o=Ae(r,function(){return r.machine.transition(o,l,void 0,n||void 0)}),u.push.apply(u,D([],x(r.machine.config.predictableActionArguments?o.actions:o.actions.map(function(p){return Ei(p,o)})),!1)),a=a||!!o.changed};try{for(var f=b(e),v=f.next();!v.done;v=f.next()){var h=v.value;c(h)}}catch(d){i={error:d}}finally{try{v&&!v.done&&(s=f.return)&&s.call(f)}finally{if(i)throw i.error}}o.changed=a,o.actions=u,r.update(o,z(e[e.length-1]))})}},t.prototype.sender=function(e){return this.send.bind(this,e)},t.prototype._nextState=function(e,r){var n=this;r===void 0&&(r=!!this.machine.config.predictableActionArguments&&this._exec);var i=z(e);if(i.name.indexOf(vr)===0&&!this.state.nextEvents.some(function(o){return o.indexOf(vr)===0}))throw i.data.data;var s=Ae(this,function(){return n.machine.transition(n.state,i,void 0,r||void 0)});return s},t.prototype.nextState=function(e){return this._nextState(e,!1)},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(u){r={error:u}}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,!0):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),this._exec(e,r.context,r._event,n)},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),U(r.stop)&&r.stop())},t.prototype.spawn=function(e,r,n){if(this.status!==q.Running)return Nr(e,r);if(Tr(e))return this.spawnPromise(Promise.resolve(e),r);if(U(e))return this.spawnCallback(e,r);if(vi(e))return this.spawnActor(e,r);if(Xn(e))return this.spawnObservable(e,r);if(ve(e))return this.spawnMachine(e,w(w({},n),{id:r}));if(Wn(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,w(w({},this.options),{parent:this,id:r.id||e.id})),s=w(w({},ki),r);s.sync&&i.onTransition(function(a){n.send(mr,{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(z(a,{origin:i.id}))}).start(),o},t.prototype.spawnBehavior=function(e,r){var n=Oi(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(u){s||(o=u,i.removeChild(r),i.send(z(it(r,u),{origin:r})))},function(u){if(!s){i.removeChild(r);var c=Fe(r,u);try{i.send(z(c,{origin:r}))}catch(f){ti(u,f,r),i.devTools&&i.devTools.send(c,i.state),i.machine.strict&&i.stop()}}});var a=(n={id:r,send:function(){},subscribe:function(u,c,f){var v=tt(u,c,f),h=!1;return e.then(function(d){h||(v.next(d),!h&&v.complete())},function(d){h||v.error(d)}),{unsubscribe:function(){return h=!0}}},stop:function(){s=!0},toJSON:function(){return{id:r}},getSnapshot:function(){return o}},n[ue]=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,u,c=function(h){u=h,a.forEach(function(d){return d(h)}),!s&&i.send(z(h,{origin:r}))},f;try{f=e(c,function(h){o.add(h)})}catch(h){this.send(Fe(r,h))}if(Tr(f))return this.spawnPromise(f,r);var v=(n={id:r,send:function(h){return o.forEach(function(d){return d(h)})},subscribe:function(h){var d=tt(h);return a.add(d.next),{unsubscribe:function(){a.delete(d.next)}}},stop:function(){s=!0,U(f)&&f()},toJSON:function(){return{id:r}},getSnapshot:function(){return u}},n[ue]=function(){return this},n);return this.children.set(r,v),v},t.prototype.spawnObservable=function(e,r){var n,i=this,s,o=e.subscribe(function(u){s=u,i.send(z(u,{origin:r}))},function(u){i.removeChild(r),i.send(z(Fe(r,u),{origin:r}))},function(){i.removeChild(r),i.send(z(it(r),{origin:r}))}),a=(n={id:r,send:function(){},subscribe:function(u,c,f){return e.subscribe(u,c,f)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return s},toJSON:function(){return{id:r}}},n[ue]=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){M||B(!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[ue]=function(){return this},n))},t.prototype.attachDev=function(){var e=Ht();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(w(w({name:this.id,autoPause:!0,stateSanitizer:function(n){return{value:n.value,context:n.context,actions:n.actions}}},r),{features:w({jump:!1,skip:!1},r?r.features:void 0)}),this.machine),this.devTools.init(this.state)}Ai(this)}},t.prototype.toJSON=function(){return{id:this.id}},t.prototype[ue]=function(){return this},t.prototype.getSnapshot=function(){return this.status===q.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=Oe,t}();function Oe(t,e){var r=new Ri(t,e);return r}function Ni(t){if(typeof t=="string"){var e={type:t};return e.toString=function(){return t},e}return t}function ut(t){return w(w({type:jt},t),{toJSON:function(){t.onDone,t.onError;var e=Ct(t,["onDone","onError"]);return w(w({},e),{type:jt,src:Ni(t.src)})}})}var ke="",Jt="#",ze="*",Re={},Ne=function(t){return t[0]===Jt},Ii=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},Pi=function(t,e,r){var n=r.slice(0,-1).some(function(s){return!("cond"in s)&&!("in"in s)&&(R(s.target)||ve(s.target))}),i=e===ke?"the transient event":"event '".concat(e,"'");B(!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.")},Ci=function(){function t(e,r,n,i){n===void 0&&(n="context"in e?e.context:void 0);var s=this,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(Ii(),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:yr),this.id=this.config.id||D([this.machine.key],x(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,M||B(!("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?Le(this.config.states,function(c,f){var v,h=new t(c,{},void 0,{parent:s,key:f});return Object.assign(s.idMap,w((v={},v[h.id]=h,v),h.idMap)),h}):Re;var a=0;function u(c){var f,v;c.order=a++;try{for(var h=b(Ir(c)),d=h.next();!d.done;d=h.next()){var l=d.value;u(l)}}catch(p){f={error:p}}finally{try{d&&!d.done&&(v=h.return)&&v.call(h)}finally{if(f)throw f.error}}}u(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(c){var f=c.event;return f===ke}):ke in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=Y(this.config.entry||this.config.onEntry).map(function(c){return Me(c)}),this.onExit=Y(this.config.exit||this.config.onExit).map(function(c){return Me(c)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=Y(this.config.invoke).map(function(c,f){var v,h;if(ve(c)){var d=rt(s.id,f);return s.machine.options.services=w((v={},v[d]=c,v),s.machine.options.services),ut({src:d,id:d})}else if(R(c.src)){var d=c.id||rt(s.id,f);return ut(w(w({},c),{id:d,src:c.src}))}else if(ve(c.src)||U(c.src)){var d=c.id||rt(s.id,f);return s.machine.options.services=w((h={},h[d]=c.src,h),s.machine.options.services),ut(w(w({id:d},c),{src:d}))}else{var l=c.src;return ut(w(w({id:rt(s.id,f)},c),{src:l}))}}),this.activities=Y(this.config.activities).concat(this.invoke).map(function(c){return Bt(c)}),this.transition=this.transition.bind(this),this.tags=Y(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||Pr(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,u=n.delays;return new t(this.config,{actions:w(w({},i),e.actions),activities:w(w({},s),e.activities),guards:w(w({},o),e.guards),services:w(w({},a),e.services),delays:w(w({},u),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 U(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:Le(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===ke,n=this.transitions.filter(function(i){var s=i.eventType===e;return r?s:s||i.eventType===ze});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=U(s)?"".concat(e.id,":delay[").concat(o,"]"):s,u=fi(a,e.id);return e.onEntry.push(zt(u,{delay:s})),e.onExit.push(oi(u)),u},i=Te(r)?r.map(function(s,o){var a=n(s.delay,o);return w(w({},s),{event:a})}):L(Object.keys(r).map(function(s,o){var a=r[s],u=R(a)?{target:a}:a,c=isNaN(+s)?s:+s,f=n(c,o);return Y(u).map(function(v){return w(w({},v),{event:f,delay:c})})}));return i.map(function(s){var o=s.delay;return w(w({},e.formatTransition(s)),{delay:o})})},t.prototype.getStateNodes=function(e){var r,n=this;if(!e)return[];var i=e instanceof ee?e.value:je(e,this.delimiter);if(R(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,D([],x(L(o.map(function(u){return n.getStateNode(u).getStateNodes(i[u])}))),!1)),a},t.prototype.handles=function(e){var r=wr(e);return this.events.includes(r)},t.prototype.resolveState=function(e){var r=e instanceof ee?e:ee.create(e),n=Array.from(qe([],this.getStateNodes(r.value)));return new ee(w(w({},r),{value:this.resolve(r.value),configuration:n,done:at(n,this),tags:Ur(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)),u=a.next();!u.done;u=a.next()){var c=u.value,f=e[c];if(!!f){var v=this.getStateNode(c),h=v._transition(f,r,n);h&&(o[c]=h)}}}catch(g){i={error:g}}finally{try{u&&!u.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}var d=Object.keys(o).map(function(g){return o[g]}),l=L(d.map(function(g){return g.transitions})),p=d.some(function(g){return g.transitions.length>0});if(!p)return this.next(r,n);var y=L(d.map(function(g){return g.entrySet})),S=L(Object.keys(o).map(function(g){return o[g].configuration}));return{transitions:l,entrySet:y,exitSet:L(d.map(function(g){return g.exitSet})),configuration:S,source:r,actions:L(Object.keys(o).map(function(g){return o[g].actions}))}},t.prototype._transition=function(e,r,n){return R(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,z(r))},t.prototype.next=function(e,r){var n,i,s=this,o=r.name,a=[],u=[],c;try{for(var f=b(this.getCandidates(o)),v=f.next();!v.done;v=f.next()){var h=v.value,d=h.cond,l=h.in,p=e.context,y=l?R(l)&&Ne(l)?e.matches(je(this.getStateNodeById(l).path,this.delimiter)):Mt(je(l,this.delimiter),Hn(this.path.slice(0,-2))(e.value)):!0,S=!1;try{S=!d||Or(this.machine,d,p,r,e)}catch(A){throw new Error("Unable to evaluate guard '".concat(d.name||d.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,`':
|
|
18
|
-
`).concat(A.message))}if(S&&y){h.target!==void 0&&(u=h.target),a.push.apply(a,D([],x(h.actions),!1)),c=h;break}}}catch(A){n={error:A}}finally{try{v&&!v.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}if(!!c){if(!u.length)return{transitions:[c],entrySet:[],exitSet:[],configuration:e.value?[this]:[],source:e,actions:a};var g=L(u.map(function(A){return s.getRelativeStateNodes(A,e.historyValue)})),E=!!c.internal,N=[];return E||u.forEach(function(A){N.push.apply(N,D([],x(s.getExternalReentryNodes(A)),!1))}),{transitions:[c],entrySet:N,exitSet:E?[]:[this],configuration:g,source:e,actions:a}}},t.prototype.getExternalReentryNodes=function(e){for(var r=[],n=x(e.order>this.order?[e,this]:[this,e],2),i=n[0],s=n[1];i&&i!==s;)r.push(i),i=i.parent;return i!==s?[]:(r.push(s),r)},t.prototype.getActions=function(e,r,n,i,s,o,a){var u,c,f,v,h=this,d=qe([],o?this.getStateNodes(o.value):[this]);try{for(var l=b(e),p=l.next();!p.done;p=l.next()){var y=p.value;(!Be(d,y)||Be(n.entrySet,y.parent))&&n.entrySet.push(y)}}catch(T){u={error:T}}finally{try{p&&!p.done&&(c=l.return)&&c.call(l)}finally{if(u)throw u.error}}try{for(var S=b(d),g=S.next();!g.done;g=S.next()){var y=g.value;(!Be(e,y)||Be(n.exitSet,y.parent))&&n.exitSet.push(y)}}catch(T){f={error:T}}finally{try{g&&!g.done&&(v=S.return)&&v.call(S)}finally{if(f)throw f.error}}var E=L(n.entrySet.map(function(T){var _=[];if(T.type!=="final")return _;var G=T.parent;if(!G.parent)return _;_.push(nt(T.id,T.doneData),nt(G.id,T.doneData?et(T.doneData,i,s):void 0));var X=G.parent;return X.type==="parallel"&&$e(X).every(function(ae){return at(n.configuration,ae)})&&_.push(nt(X.id)),_}));n.exitSet.sort(function(T,_){return _.order-T.order}),n.entrySet.sort(function(T,_){return T.order-_.order});var N=new Set(n.entrySet),A=new Set(n.exitSet),j=Array.from(N).map(function(T){var _=T.onEntry,G=T.activities.map(function(X){return ai(X)});return le(a?D(D([],x(_),!1),x(G),!1):D(D([],x(G),!1),x(_),!1),h.machine.options.actions)}).concat([E.map(ri)]),O=Array.from(A).map(function(T){return le(D(D([],x(T.onExit),!1),x(T.activities.map(function(_){return ci(_)})),!1),h.machine.options.actions)}),I=O.concat([le(n.actions,this.machine.options.actions)]).concat(j);if(r){var P=le(L(D([],x(e),!1).sort(function(T,_){return _.order-T.order}).map(function(T){return T.onExit})),this.machine.options.actions).filter(function(T){return T.type!==Se&&(T.type!==Ee||!!T.to&&T.to!==ce.Internal)});return I.concat([P])}return I},t.prototype.transition=function(e,r,n,i){e===void 0&&(e=this.initialState);var s=z(r),o;if(e instanceof ee)o=n===void 0?e:this.resolveState(ee.from(e,n));else{var a=R(e)?this.resolve(Xe(this.getResolvedPath(e))):this.resolve(e),u=n!=null?n:this.machine.context;o=this.resolveState(ee.from(a,u))}if(!M&&s.name===ze)throw new Error("An event cannot have the wildcard type ('".concat(ze,"')"));if(this.strict&&!this.events.includes(s.name)&&!Gn(s.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(s.name,"'"));var c=this._transition(o.value,o,s)||{transitions:[],configuration:[],entrySet:[],exitSet:[],source:o,actions:[]},f=qe([],this.getStateNodes(o.value)),v=c.configuration.length?qe(f,c.configuration):f;return c.configuration=D([],x(v),!1),this.resolveTransition(c,o,o.context,i,s)},t.prototype.resolveRaisedTransition=function(e,r,n,i){var s,o=e.actions;return e=this.transition(e,r,void 0,i),e._event=n,e.event=n.data,(s=e.actions).unshift.apply(s,D([],x(o),!1)),e},t.prototype.resolveTransition=function(e,r,n,i,s){var o,a,u,c,f=this;s===void 0&&(s=xe);var v=e.configuration,h=!r||e.transitions.length>0,d=h?e.configuration:r?r.configuration:[],l=at(d,this),p=h?yi(this.machine,v):void 0,y=r?r.historyValue?r.historyValue:e.source?this.machine.historyValue(r.value):void 0:void 0,S=this.getActions(new Set(d),l,e,n,s,r,i),g=r?w({},r.activities):{};try{for(var E=b(S),N=E.next();!N.done;N=E.next()){var A=N.value;try{for(var j=(u=void 0,b(A)),O=j.next();!O.done;O=j.next()){var I=O.value;I.type===Ut?g[I.activity.id||I.activity.type]=I:I.type===Dt&&(g[I.activity.id||I.activity.type]=!1)}}catch(H){u={error:H}}finally{try{O&&!O.done&&(c=j.return)&&c.call(j)}finally{if(u)throw u.error}}}}catch(H){o={error:H}}finally{try{N&&!N.done&&(a=E.return)&&a.call(E)}finally{if(o)throw o.error}}var P=x(st(this,r,n,s,S,i,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),T=P[0],_=P[1],G=x(Yn(T,function(H){return H.type===Se||H.type===Ee&&H.to===ce.Internal}),2),X=G[0],ae=G[1],Ue=T.filter(function(H){var _e;return H.type===Ut&&((_e=H.activity)===null||_e===void 0?void 0:_e.type)===jt}),Fo=Ue.reduce(function(H,_e){return H[_e.activity.id]=hi(_e.activity,f.machine,_,s),H},r?w({},r.children):{}),Pt=new ee({value:p||r.value,context:_,_event:s,_sessionid:r?r._sessionid:null,historyValue:p?y?Qn(y,p):void 0:r?r.historyValue:void 0,history:!p||e.source?r:void 0,actions:p?ae:[],activities:p?g:r?r.activities:{},events:[],configuration:d,transitions:e.transitions,children:Fo,done:l,tags:Ur(d),machine:this}),_n=n!==_;Pt.changed=s.name===mr||_n;var De=Pt.history;De&&delete De.history;var jn=!l&&(this._transient||v.some(function(H){return H._transient}));if(!h&&(!jn||s.name===ke))return Pt;var Z=Pt;if(!l)for(jn&&(Z=this.resolveRaisedTransition(Z,{type:Fn},s,i));X.length;){var $o=X.shift();Z=this.resolveRaisedTransition(Z,$o._event,s,i)}var qo=Z.changed||(De?!!Z.actions.length||_n||typeof De.value!=typeof Z.value||!Dr(Z.value,De.value):void 0);return Z.changed=qo,Z.history=De,Z},t.prototype.getStateNode=function(e){if(Ne(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=Ne(e)?e.slice(Jt.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"&&Ne(e))try{return this.getStateNodeById(e.slice(1))}catch{}for(var r=Ft(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||Re;switch(this.type){case"parallel":return Le(this.initialStateValue,function(s,o){return s?n.getStateNode(o).resolve(e[o]||s):Re});case"compound":if(R(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?Le(e,function(s,o){return s?n.getStateNode(o).resolve(s):Re}):this.initialStateValue||{};default:return e||Re}},t.prototype.getResolvedPath=function(e){if(Ne(e)){var r=this.machine.idMap[e.slice(Jt.length)];if(!r)throw new Error("Unable to find state node '".concat(e,"'"));return r.path}return Ft(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=Sr(this.states,function(n){return n.initialStateValue||Re},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=ot(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:D([],x(n),!1),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;R(r.target)?e=Ne(r.target)?Xe(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(ot(this))return[this];if(this.type==="compound"&&!this.initial)return M||B(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var r=Ze(this.initialStateValue);return L(r.map(function(n){return e.getFromRelativePath(n)}))},enumerable:!1,configurable:!0}),t.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var r=x(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:Sr(this.states,function(r,n){if(!e)return r.historyValue();var i=R(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?L(Ze(i).map(function(o){return n.getFromRelativePath(o)})):n.initialStateNodes}var s=Jn(n.path,"states")(e).current;return R(s)?[n.getStateNode(s)]:L(Ze(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=L(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)),u=a.next();!u.done;u=a.next()){var c=u.value,f=s[c];if(f.states)try{for(var v=(n=void 0,b(f.events)),h=v.next();!h.done;h=v.next()){var d=h.value;o.add("".concat(d))}}catch(l){n={error:l}}finally{try{h&&!h.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}}}catch(l){e={error:l}}finally{try{u&&!u.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(!R(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,`':
|
|
19
|
-
`).concat(a.message))}else return r.getStateNodeByPath(s)})},t.prototype.formatTransition=function(e){var r=this,n=ei(e.target),i="internal"in e?e.internal:n?n.some(function(u){return R(u)&&u[0]===r.delimiter}):!0,s=this.machine.options.guards,o=this.resolveTarget(n),a=w(w({},e),{actions:le(Y(e.actions)),cond:Ar(e.cond,s),target:o,source:this,internal:i,eventType:e.event,toJSON:function(){return w(w({},a),{target:a.target?a.target.map(function(u){return"#".concat(u.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=ze,a=s[o],u=a===void 0?[]:a,c=Ct(s,[typeof o=="symbol"?o:o+""]);i=L(Object.keys(c).map(function(g){!M&&g===ke&&B(!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 E=be(g,c[g]);return M||Pi(n,g,E),E}).concat(be(ze,u)))}var f=this.config.always?be("",this.config.always):[],v=this.config.onDone?be(String(nt(this.id)),this.config.onDone):[];M||B(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var h=L(this.invoke.map(function(g){var E=[];return g.onDone&&E.push.apply(E,D([],x(be(String(it(g.id)),g.onDone)),!1)),g.onError&&E.push.apply(E,D([],x(be(String(Fe(g.id)),g.onError)),!1)),E})),d=this.after,l=L(D(D(D(D([],x(v),!1),x(h),!1),x(i),!1),x(f),!1).map(function(g){return Y(g).map(function(E){return n.formatTransition(E)})}));try{for(var p=b(d),y=p.next();!y.done;y=p.next()){var S=y.value;l.push(S)}}catch(g){e={error:g}}finally{try{y&&!y.done&&(r=p.return)&&r.call(p)}finally{if(e)throw e.error}}return l},t}(),jr=!1;function Ve(t,e){return!M&&!t.predictableActionArguments&&!jr&&(jr=!0,console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html")),new Ci(t,e)}var $=li,Q=zt;function Lr(t,e){return function(){return t.apply(e,arguments)}}const{toString:Mr}=Object.prototype,{getPrototypeOf:Gt}=Object,Wt=(t=>e=>{const r=Mr.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),ne=t=>(t=t.toLowerCase(),e=>Wt(e)===t),lt=t=>e=>typeof e===t,{isArray:Ie}=Array,Ke=lt("undefined");function Ui(t){return t!==null&&!Ke(t)&&t.constructor!==null&&!Ke(t.constructor)&&me(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const Fr=ne("ArrayBuffer");function Di(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&Fr(t.buffer),e}const _i=lt("string"),me=lt("function"),$r=lt("number"),Yt=t=>t!==null&&typeof t=="object",ji=t=>t===!0||t===!1,ft=t=>{if(Wt(t)!=="object")return!1;const e=Gt(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},Li=ne("Date"),Mi=ne("File"),Fi=ne("Blob"),$i=ne("FileList"),qi=t=>Yt(t)&&me(t.pipe),Bi=t=>{const e="[object FormData]";return t&&(typeof FormData=="function"&&t instanceof FormData||Mr.call(t)===e||me(t.toString)&&t.toString()===e)},zi=ne("URLSearchParams"),Vi=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function He(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),Ie(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{const s=r?Object.getOwnPropertyNames(t):Object.keys(t),o=s.length;let a;for(n=0;n<o;n++)a=s[n],e.call(null,t[a],a,t)}}function qr(t,e){e=e.toLowerCase();const r=Object.keys(t);let n=r.length,i;for(;n-- >0;)if(i=r[n],e===i.toLowerCase())return i;return null}const Br=typeof self>"u"?typeof global>"u"?globalThis:global:self,zr=t=>!Ke(t)&&t!==Br;function Qt(){const{caseless:t}=zr(this)&&this||{},e={},r=(n,i)=>{const s=t&&qr(e,i)||i;ft(e[s])&&ft(n)?e[s]=Qt(e[s],n):ft(n)?e[s]=Qt({},n):Ie(n)?e[s]=n.slice():e[s]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&He(arguments[n],r);return e}const Ki=(t,e,r,{allOwnKeys:n}={})=>(He(e,(i,s)=>{r&&me(i)?t[s]=Lr(i,r):t[s]=i},{allOwnKeys:n}),t),Hi=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),Ji=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},Gi=(t,e,r,n)=>{let i,s,o;const a={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),s=i.length;s-- >0;)o=i[s],(!n||n(o,t,e))&&!a[o]&&(e[o]=t[o],a[o]=!0);t=r!==!1&&Gt(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},Wi=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},Yi=t=>{if(!t)return null;if(Ie(t))return t;let e=t.length;if(!$r(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},Qi=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&Gt(Uint8Array)),Xi=(t,e)=>{const n=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(t,s[0],s[1])}},Zi=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},es=ne("HTMLFormElement"),ts=t=>t.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),Vr=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),rs=ne("RegExp"),Kr=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};He(r,(i,s)=>{e(i,s,t)!==!1&&(n[s]=i)}),Object.defineProperties(t,n)},m={isArray:Ie,isArrayBuffer:Fr,isBuffer:Ui,isFormData:Bi,isArrayBufferView:Di,isString:_i,isNumber:$r,isBoolean:ji,isObject:Yt,isPlainObject:ft,isUndefined:Ke,isDate:Li,isFile:Mi,isBlob:Fi,isRegExp:rs,isFunction:me,isStream:qi,isURLSearchParams:zi,isTypedArray:Qi,isFileList:$i,forEach:He,merge:Qt,extend:Ki,trim:Vi,stripBOM:Hi,inherits:Ji,toFlatObject:Gi,kindOf:Wt,kindOfTest:ne,endsWith:Wi,toArray:Yi,forEachEntry:Xi,matchAll:Zi,isHTMLForm:es,hasOwnProperty:Vr,hasOwnProp:Vr,reduceDescriptors:Kr,freezeMethods:t=>{Kr(t,(e,r)=>{if(me(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(!!me(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},toObjectSet:(t,e)=>{const r={},n=i=>{i.forEach(s=>{r[s]=!0})};return Ie(t)?n(t):n(String(t).split(e)),r},toCamelCase:ts,noop:()=>{},toFiniteNumber:(t,e)=>(t=+t,Number.isFinite(t)?t:e),findKey:qr,global:Br,isContextDefined:zr,toJSONObject:t=>{const e=new Array(10),r=(n,i)=>{if(Yt(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[i]=n;const s=Ie(n)?[]:{};return He(n,(o,a)=>{const u=r(o,i+1);!Ke(u)&&(s[a]=u)}),e[i]=void 0,s}}return n};return r(t,0)}};function k(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}m.inherits(k,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:m.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Hr=k.prototype,Jr={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{Jr[t]={value:t}}),Object.defineProperties(k,Jr),Object.defineProperty(Hr,"isAxiosError",{value:!0}),k.from=(t,e,r,n,i,s)=>{const o=Object.create(Hr);return m.toFlatObject(t,o,function(u){return u!==Error.prototype},a=>a!=="isAxiosError"),k.call(o,t.message,e,r,n,i),o.cause=t,o.name=t.name,s&&Object.assign(o,s),o};var Gr=typeof self=="object"?self.FormData:window.FormData;function Xt(t){return m.isPlainObject(t)||m.isArray(t)}function Wr(t){return m.endsWith(t,"[]")?t.slice(0,-2):t}function Yr(t,e,r){return t?t.concat(e).map(function(i,s){return i=Wr(i),!r&&s?"["+i+"]":i}).join(r?".":""):e}function ns(t){return m.isArray(t)&&!t.some(Xt)}const is=m.toFlatObject(m,{},null,function(e){return/^is[A-Z]/.test(e)});function ss(t){return t&&m.isFunction(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator]}function dt(t,e,r){if(!m.isObject(t))throw new TypeError("target must be an object");e=e||new(Gr||FormData),r=m.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,y){return!m.isUndefined(y[p])});const n=r.metaTokens,i=r.visitor||f,s=r.dots,o=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&ss(e);if(!m.isFunction(i))throw new TypeError("visitor must be a function");function c(l){if(l===null)return"";if(m.isDate(l))return l.toISOString();if(!u&&m.isBlob(l))throw new k("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(l)||m.isTypedArray(l)?u&&typeof Blob=="function"?new Blob([l]):Buffer.from(l):l}function f(l,p,y){let S=l;if(l&&!y&&typeof l=="object"){if(m.endsWith(p,"{}"))p=n?p:p.slice(0,-2),l=JSON.stringify(l);else if(m.isArray(l)&&ns(l)||m.isFileList(l)||m.endsWith(p,"[]")&&(S=m.toArray(l)))return p=Wr(p),S.forEach(function(E,N){!(m.isUndefined(E)||E===null)&&e.append(o===!0?Yr([p],N,s):o===null?p:p+"[]",c(E))}),!1}return Xt(l)?!0:(e.append(Yr(y,p,s),c(l)),!1)}const v=[],h=Object.assign(is,{defaultVisitor:f,convertValue:c,isVisitable:Xt});function d(l,p){if(!m.isUndefined(l)){if(v.indexOf(l)!==-1)throw Error("Circular reference detected in "+p.join("."));v.push(l),m.forEach(l,function(S,g){(!(m.isUndefined(S)||S===null)&&i.call(e,S,m.isString(g)?g.trim():g,p,h))===!0&&d(S,p?p.concat(g):[g])}),v.pop()}}if(!m.isObject(t))throw new TypeError("data must be an object");return d(t),e}function Qr(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function Zt(t,e){this._pairs=[],t&&dt(t,this,e)}const Xr=Zt.prototype;Xr.append=function(e,r){this._pairs.push([e,r])},Xr.toString=function(e){const r=e?function(n){return e.call(this,n,Qr)}:Qr;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function os(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function Zr(t,e,r){if(!e)return t;const n=r&&r.encode||os,i=r&&r.serialize;let s;if(i?s=i(e,r):s=m.isURLSearchParams(e)?e.toString():new Zt(e,r).toString(n),s){const o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}class as{constructor(){this.handlers=[]}use(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}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){m.forEach(this.handlers,function(n){n!==null&&e(n)})}}const en=as,tn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},cs=typeof URLSearchParams<"u"?URLSearchParams:Zt,us=FormData,ls=(()=>{let t;return typeof navigator<"u"&&((t=navigator.product)==="ReactNative"||t==="NativeScript"||t==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),ie={isBrowser:!0,classes:{URLSearchParams:cs,FormData:us,Blob},isStandardBrowserEnv:ls,protocols:["http","https","file","blob","url","data"]};function fs(t,e){return dt(t,new ie.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,s){return ie.isNode&&m.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},e))}function ds(t){return m.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function hs(t){const e={},r=Object.keys(t);let n;const i=r.length;let s;for(n=0;n<i;n++)s=r[n],e[s]=t[s];return e}function rn(t){function e(r,n,i,s){let o=r[s++];const a=Number.isFinite(+o),u=s>=r.length;return o=!o&&m.isArray(i)?i.length:o,u?(m.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!a):((!i[o]||!m.isObject(i[o]))&&(i[o]=[]),e(r,n,i[o],s)&&m.isArray(i[o])&&(i[o]=hs(i[o])),!a)}if(m.isFormData(t)&&m.isFunction(t.entries)){const r={};return m.forEachEntry(t,(n,i)=>{e(ds(n),i,r,0)}),r}return null}const ps={"Content-Type":void 0};function vs(t,e,r){if(m.isString(t))try{return(e||JSON.parse)(t),m.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const ht={transitional:tn,adapter:["xhr","http"],transformRequest:[function(e,r){const n=r.getContentType()||"",i=n.indexOf("application/json")>-1,s=m.isObject(e);if(s&&m.isHTMLForm(e)&&(e=new FormData(e)),m.isFormData(e))return i&&i?JSON.stringify(rn(e)):e;if(m.isArrayBuffer(e)||m.isBuffer(e)||m.isStream(e)||m.isFile(e)||m.isBlob(e))return e;if(m.isArrayBufferView(e))return e.buffer;if(m.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return fs(e,this.formSerializer).toString();if((a=m.isFileList(e))||n.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return dt(a?{"files[]":e}:e,u&&new u,this.formSerializer)}}return s||i?(r.setContentType("application/json",!1),vs(e)):e}],transformResponse:[function(e){const r=this.transitional||ht.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(e&&m.isString(e)&&(n&&!this.responseType||i)){const o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?k.from(a,k.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:ie.classes.FormData,Blob:ie.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};m.forEach(["delete","get","head"],function(e){ht.headers[e]={}}),m.forEach(["post","put","patch"],function(e){ht.headers[e]=m.merge(ps)});const er=ht,ms=m.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),ys=t=>{const e={};let r,n,i;return t&&t.split(`
|
|
20
|
-
`).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||e[r]&&
|
|
21
|
-
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const n=new this(e);return r.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[nn]=this[nn]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=Je(o);n[a]||(Es(i,o),n[a]=!0)}return m.isArray(e)?e.forEach(s):s(e),this}}vt.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),m.freezeMethods(vt.prototype),m.freezeMethods(vt);const se=vt;function tr(t,e){const r=this||er,n=e||r,i=se.from(n.headers);let s=n.data;return m.forEach(t,function(a){s=a.call(r,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function on(t){return!!(t&&t.__CANCEL__)}function Ge(t,e,r){k.call(this,t==null?"canceled":t,k.ERR_CANCELED,e,r),this.name="CanceledError"}m.inherits(Ge,k,{__CANCEL__:!0});const Ts=null;function bs(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new k("Request failed with status code "+r.status,[k.ERR_BAD_REQUEST,k.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}const xs=ie.isStandardBrowserEnv?function(){return{write:function(r,n,i,s,o,a){const u=[];u.push(r+"="+encodeURIComponent(n)),m.isNumber(i)&&u.push("expires="+new Date(i).toGMTString()),m.isString(s)&&u.push("path="+s),m.isString(o)&&u.push("domain="+o),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(r){const 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(){}}}();function As(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function Os(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}function an(t,e){return t&&!As(e)?Os(t,e):e}const ks=ie.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");let n;function i(s){let 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){const a=m.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}();function Rs(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Ns(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(u){const c=Date.now(),f=n[s];o||(o=c),r[i]=u,n[i]=c;let v=s,h=0;for(;v!==i;)h+=r[v++],v=v%t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),c-o<e)return;const d=f&&c-f;return d?Math.round(h*1e3/d):void 0}}function cn(t,e){let r=0;const n=Ns(50,250);return i=>{const s=i.loaded,o=i.lengthComputable?i.total:void 0,a=s-r,u=n(a),c=s<=o;r=s;const f={loaded:s,total:o,progress:o?s/o:void 0,bytes:a,rate:u||void 0,estimated:u&&o&&c?(o-s)/u:void 0,event:i};f[e?"download":"upload"]=!0,t(f)}}const mt={http:Ts,xhr:typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){let i=t.data;const s=se.from(t.headers).normalize(),o=t.responseType;let a;function u(){t.cancelToken&&t.cancelToken.unsubscribe(a),t.signal&&t.signal.removeEventListener("abort",a)}m.isFormData(i)&&ie.isStandardBrowserEnv&&s.setContentType(!1);let c=new XMLHttpRequest;if(t.auth){const d=t.auth.username||"",l=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";s.set("Authorization","Basic "+btoa(d+":"+l))}const f=an(t.baseURL,t.url);c.open(t.method.toUpperCase(),Zr(f,t.params,t.paramsSerializer),!0),c.timeout=t.timeout;function v(){if(!c)return;const d=se.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),p={data:!o||o==="text"||o==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:d,config:t,request:c};bs(function(S){r(S),u()},function(S){n(S),u()},p),c=null}if("onloadend"in c?c.onloadend=v:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(v)},c.onabort=function(){!c||(n(new k("Request aborted",k.ECONNABORTED,t,c)),c=null)},c.onerror=function(){n(new k("Network Error",k.ERR_NETWORK,t,c)),c=null},c.ontimeout=function(){let l=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";const p=t.transitional||tn;t.timeoutErrorMessage&&(l=t.timeoutErrorMessage),n(new k(l,p.clarifyTimeoutError?k.ETIMEDOUT:k.ECONNABORTED,t,c)),c=null},ie.isStandardBrowserEnv){const d=(t.withCredentials||ks(f))&&t.xsrfCookieName&&xs.read(t.xsrfCookieName);d&&s.set(t.xsrfHeaderName,d)}i===void 0&&s.setContentType(null),"setRequestHeader"in c&&m.forEach(s.toJSON(),function(l,p){c.setRequestHeader(p,l)}),m.isUndefined(t.withCredentials)||(c.withCredentials=!!t.withCredentials),o&&o!=="json"&&(c.responseType=t.responseType),typeof t.onDownloadProgress=="function"&&c.addEventListener("progress",cn(t.onDownloadProgress,!0)),typeof t.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",cn(t.onUploadProgress)),(t.cancelToken||t.signal)&&(a=d=>{!c||(n(!d||d.type?new Ge(null,t,c):d),c.abort(),c=null)},t.cancelToken&&t.cancelToken.subscribe(a),t.signal&&(t.signal.aborted?a():t.signal.addEventListener("abort",a)));const h=Rs(f);if(h&&ie.protocols.indexOf(h)===-1){n(new k("Unsupported protocol "+h+":",k.ERR_BAD_REQUEST,t));return}c.send(i||null)})}};m.forEach(mt,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const Is={getAdapter:t=>{t=m.isArray(t)?t:[t];const{length:e}=t;let r,n;for(let i=0;i<e&&(r=t[i],!(n=m.isString(r)?mt[r.toLowerCase()]:r));i++);if(!n)throw n===!1?new k(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(m.hasOwnProp(mt,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!m.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:mt};function rr(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new Ge}function un(t){return rr(t),t.headers=se.from(t.headers),t.data=tr.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),Is.getAdapter(t.adapter||er.adapter)(t).then(function(n){return rr(t),n.data=tr.call(t,t.transformResponse,n),n.headers=se.from(n.headers),n},function(n){return on(n)||(rr(t),n&&n.response&&(n.response.data=tr.call(t,t.transformResponse,n.response),n.response.headers=se.from(n.response.headers))),Promise.reject(n)})}const ln=t=>t instanceof se?t.toJSON():t;function We(t,e){e=e||{};const r={};function n(c,f,v){return m.isPlainObject(c)&&m.isPlainObject(f)?m.merge.call({caseless:v},c,f):m.isPlainObject(f)?m.merge({},f):m.isArray(f)?f.slice():f}function i(c,f,v){if(m.isUndefined(f)){if(!m.isUndefined(c))return n(void 0,c,v)}else return n(c,f,v)}function s(c,f){if(!m.isUndefined(f))return n(void 0,f)}function o(c,f){if(m.isUndefined(f)){if(!m.isUndefined(c))return n(void 0,c)}else return n(void 0,f)}function a(c,f,v){if(v in e)return n(c,f);if(v in t)return n(void 0,c)}const u={url:s,method:s,data:s,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,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(c,f)=>i(ln(c),ln(f),!0)};return m.forEach(Object.keys(t).concat(Object.keys(e)),function(f){const v=u[f]||i,h=v(t[f],e[f],f);m.isUndefined(h)&&v!==a||(r[f]=h)}),r}const fn="1.2.0",nr={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{nr[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const dn={};nr.transitional=function(e,r,n){function i(s,o){return"[Axios v"+fn+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return(s,o,a)=>{if(e===!1)throw new k(i(o," has been removed"+(r?" in "+r:"")),k.ERR_DEPRECATED);return r&&!dn[o]&&(dn[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 Ps(t,e,r){if(typeof t!="object")throw new k("options must be an object",k.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const s=n[i],o=e[s];if(o){const a=t[s],u=a===void 0||o(a,s,t);if(u!==!0)throw new k("option "+s+" must be "+u,k.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new k("Unknown option "+s,k.ERR_BAD_OPTION)}}const ir={assertOptions:Ps,validators:nr},fe=ir.validators;class yt{constructor(e){this.defaults=e,this.interceptors={request:new en,response:new en}}request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=We(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:s}=r;n!==void 0&&ir.assertOptions(n,{silentJSONParsing:fe.transitional(fe.boolean),forcedJSONParsing:fe.transitional(fe.boolean),clarifyTimeoutError:fe.transitional(fe.boolean)},!1),i!==void 0&&ir.assertOptions(i,{encode:fe.function,serialize:fe.function},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o;o=s&&m.merge(s.common,s[r.method]),o&&m.forEach(["delete","get","head","post","put","patch","common"],l=>{delete s[l]}),r.headers=se.concat(o,s);const a=[];let u=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(r)===!1||(u=u&&p.synchronous,a.unshift(p.fulfilled,p.rejected))});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let f,v=0,h;if(!u){const l=[un.bind(this),void 0];for(l.unshift.apply(l,a),l.push.apply(l,c),h=l.length,f=Promise.resolve(r);v<h;)f=f.then(l[v++],l[v++]);return f}h=a.length;let d=r;for(v=0;v<h;){const l=a[v++],p=a[v++];try{d=l(d)}catch(y){p.call(this,y);break}}try{f=un.call(this,d)}catch(l){return Promise.reject(l)}for(v=0,h=c.length;v<h;)f=f.then(c[v++],c[v++]);return f}getUri(e){e=We(this.defaults,e);const r=an(e.baseURL,e.url);return Zr(r,e.params,e.paramsSerializer)}}m.forEach(["delete","get","head","options"],function(e){yt.prototype[e]=function(r,n){return this.request(We(n||{},{method:e,url:r,data:(n||{}).data}))}}),m.forEach(["post","put","patch"],function(e){function r(n){return function(s,o,a){return this.request(We(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}yt.prototype[e]=r(),yt.prototype[e+"Form"]=r(!0)});const gt=yt;class sr{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},e(function(s,o,a){n.reason||(n.reason=new Ge(s,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}static source(){let e;return{token:new sr(function(i){e=i}),cancel:e}}}const Cs=sr;function Us(t){return function(r){return t.apply(null,r)}}function Ds(t){return m.isObject(t)&&t.isAxiosError===!0}function hn(t){const e=new gt(t),r=Lr(gt.prototype.request,e);return m.extend(r,gt.prototype,e,{allOwnKeys:!0}),m.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return hn(We(t,i))},r}const V=hn(er);V.Axios=gt,V.CanceledError=Ge,V.CancelToken=Cs,V.isCancel=on,V.VERSION=fn,V.toFormData=dt,V.AxiosError=k,V.Cancel=V.CanceledError,V.all=function(e){return Promise.all(e)},V.spread=Us,V.isAxiosError=Ds,V.AxiosHeaders=se,V.formToJSON=t=>rn(m.isHTMLForm(t)?new FormData(t):t),V.default=V;const wt=V;/*! js-cookie v3.0.1 | MIT */function St(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 _s={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 or(t,e){function r(i,s,o){if(!(typeof document>"u")){o=St({},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 u in o)!o[u]||(a+="; "+u,o[u]!==!0&&(a+="="+o[u].split(";")[0]));return document.cookie=i+"="+t.write(s,i)+a}}function n(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var s=document.cookie?document.cookie.split("; "):[],o={},a=0;a<s.length;a++){var u=s[a].split("="),c=u.slice(1).join("=");try{var f=decodeURIComponent(u[0]);if(o[f]=t.read(c,f),i===f)break}catch{}}return i?o[i]:o}}return Object.create({set:r,get:n,remove:function(i,s){r(i,"",St({},s,{expires:-1}))},withAttributes:function(i){return or(this.converter,St({},this.attributes,i))},withConverter:function(i){return or(St({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var ar=or(_s,{path:"/"}),js=Object.defineProperty,Ls=(t,e,r)=>e in t?js(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,ye=(t,e,r)=>(Ls(t,typeof e!="symbol"?e+"":e,r),r);function Ms(t){return new TextEncoder().encode(t)}function ge(t){const e=new Uint8Array(t);let r="";for(const n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function cr(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),r=(4-e.length%4)%4,n=e.padEnd(e.length+r,"="),i=atob(n),s=new ArrayBuffer(i.length),o=new Uint8Array(s);for(let a=0;a<i.length;a++)o[a]=i.charCodeAt(a);return s}function pn(){return(window==null?void 0:window.PublicKeyCredential)!==void 0&&typeof window.PublicKeyCredential=="function"}function vn(t){const{id:e}=t;return{...t,id:cr(e),transports:t.transports}}function mn(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}class K extends Error{constructor(e,r="WebAuthnError"){super(e),this.name=r}}function Fs({error:t,options:e}){var r,n;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal===new AbortController().signal)return new K("Registration ceremony was sent an abort signal","AbortError")}else if(t.name==="ConstraintError"){if(((r=i.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new K("Discoverable credentials were required but no available authenticator supported it","ConstraintError");if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new K("User verification was required but no available authenticator supported it","ConstraintError")}else{if(t.name==="InvalidStateError")return new K("The authenticator was previously registered","InvalidStateError");if(t.name==="NotAllowedError")return new K("User clicked cancel, or the registration ceremony timed out","NotAllowedError");if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(s=>s.type==="public-key").length===0?new K('No entry in pubKeyCredParams was of type "public-key"',"NotSupportedError"):new K("No available authenticator supported any of the specified pubKeyCredParams algorithms","NotSupportedError");if(t.name==="SecurityError"){const s=window.location.hostname;if(mn(s)){if(i.rp.id!==s)return new K(`The RP ID "${i.rp.id}" is invalid for this domain`,"SecurityError")}else return new K(`${window.location.hostname} is an invalid domain`,"SecurityError")}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new K("User ID was not between 1 and 64 characters","TypeError")}else if(t.name==="UnknownError")return new K("The authenticator was unable to process the specified options, or could not create a new credential","UnknownError")}return t}class $s{createNewAbortSignal(){return this.controller&&this.controller.abort(),this.controller=new AbortController,this.controller.signal}reset(){this.controller=void 0}}const Et=new $s;async function yn(t){if(!pn())throw new Error("WebAuthn is not supported in this browser");const e={publicKey:{...t,challenge:cr(t.challenge),user:{...t.user,id:Ms(t.user.id)},excludeCredentials:t.excludeCredentials.map(vn)}};e.signal=Et.createNewAbortSignal();let r;try{r=await navigator.credentials.create(e)}catch(u){throw Fs({error:u,options:e})}finally{Et.reset()}if(!r)throw new Error("Registration was not completed");const{id:n,rawId:i,response:s,type:o}=r,a={id:n,rawId:ge(i),response:{attestationObject:ge(s.attestationObject),clientDataJSON:ge(s.clientDataJSON)},type:o,clientExtensionResults:r.getClientExtensionResults(),authenticatorAttachment:r.authenticatorAttachment};return typeof s.getTransports=="function"&&(a.transports=s.getTransports()),a}function qs(t){return new TextDecoder("utf-8").decode(t)}async function Bs(){if(navigator.credentials.conditionalMediationSupported)return!0;const t=window.PublicKeyCredential;return t.isConditionalMediationAvailable!==void 0&&t.isConditionalMediationAvailable()}function zs({error:t,options:e}){var r;const{publicKey:n}=e;if(!n)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal===new AbortController().signal)return new K("Authentication ceremony was sent an abort signal","AbortError")}else{if(t.name==="NotAllowedError")return!((r=n.allowCredentials)===null||r===void 0)&&r.length?new K("No available authenticator recognized any of the allowed credentials","NotAllowedError"):new K("User clicked cancel, or the authentication ceremony timed out","NotAllowedError");if(t.name==="SecurityError"){const i=window.location.hostname;if(mn(i)){if(n.rpId!==i)return new K(`The RP ID "${n.rpId}" is invalid for this domain`,"SecurityError")}else return new K(`${window.location.hostname} is an invalid domain`,"SecurityError")}else if(t.name==="UnknownError")return new K("The authenticator was unable to process the specified options, or could not create a new assertion signature","UnknownError")}return t}async function Vs(t,e=!1){var r,n;if(!pn())throw new Error("WebAuthn is not supported in this browser");let i;((r=t.allowCredentials)===null||r===void 0?void 0:r.length)!==0&&(i=(n=t.allowCredentials)===null||n===void 0?void 0:n.map(vn));const s={...t,challenge:cr(t.challenge),allowCredentials:i},o={};if(e){if(!await Bs())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete*='webauthn']").length<1)throw Error('No <input> with `"webauthn"` in its `autocomplete` attribute was detected');o.mediation="conditional",s.allowCredentials=[]}o.publicKey=s,o.signal=Et.createNewAbortSignal();let a;try{a=await navigator.credentials.get(o)}catch(d){throw zs({error:d,options:o})}finally{Et.reset()}if(!a)throw new Error("Authentication was not completed");const{id:u,rawId:c,response:f,type:v}=a;let h;return f.userHandle&&(h=qs(f.userHandle)),{id:u,rawId:ge(c),response:{authenticatorData:ge(f.authenticatorData),clientDataJSON:ge(f.clientDataJSON),signature:ge(f.signature),userHandle:h},type:v,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:a.authenticatorAttachment}}const Tt="nhostRefreshToken",bt="nhostRefreshTokenExpiresAt",Ks=3,Hs=300,Js=5,gn=0,wn=1,de=10,xt=20;class At extends Error{constructor(e){super(e.message),ye(this,"error"),Error.captureStackTrace(this,this.constructor),e instanceof Error?(this.name=e.name,this.error={error:e.name,status:wn,message:e.message}):(this.name=e.error,this.error=e)}}const he={status:de,error:"invalid-email",message:"Email is incorrectly formatted"},ur={status:de,error:"invalid-password",message:"Password is incorrectly formatted"},Sn={status:de,error:"invalid-phone-number",message:"Phone number is incorrectly formatted"},Gs={status:de,error:"invalid-mfa-ticket",message:"MFA ticket is invalid"},Ws={status:de,error:"no-mfa-ticket",message:"No MFA ticket has been provided"},Ys={status:de,error:"no-refresh-token",message:"No refresh token has been provided"},Qs={status:xt,error:"refresher-already-running",message:"The token refresher is already running. You must wait until is has finished before submitting a new token."},oe={status:xt,error:"already-signed-in",message:"User is already signed in"},Xs={status:xt,error:"unauthenticated-user",message:"User is not authenticated"},Zs={status:xt,error:"unverified-user",message:"Email needs verification"},eo={status:de,error:"invalid-refresh-token",message:"Invalid or expired refresh token"},to={status:wn,error:"invalid-sign-in-method",message:"Invalid sign-in method"},Pe=t=>{const e=wt.create({baseURL:t});return e.interceptors.response.use(r=>r,r=>{var n,i,s,o,a,u,c,f,v,h,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:(h=(v=(u=r.response)==null?void 0:u.status)!=null?v:(f=(c=r.response)==null?void 0:c.data)==null?void 0:f.statusCode)!=null?h:gn,error:((l=(d=r.response)==null?void 0:d.data)==null?void 0:l.error)||r.request.statusText||"network"}})}),e},Ot=typeof window<"u",kt=new Map,ro=t=>{var e;return Ot&&typeof localStorage<"u"?localStorage.getItem(t):(e=kt.get(t))!=null?e:null},no=(t,e)=>{Ot&&typeof localStorage<"u"?e?localStorage.setItem(t,e):localStorage.removeItem(t):e?kt.set(t,e):kt.has(t)&&kt.delete(t)},io=(t,e)=>{if(t==="localStorage"||t==="web")return ro;if(t==="cookie")return r=>{var n;return Ot&&(n=ar.get(r))!=null?n:null};if(!e)throw Error(`clientStorageType is set to '${t}' but no clientStorage has been given`);if(t==="react-native")return r=>{var n;return(n=e.getItem)==null?void 0:n.call(e,r)};if(t==="capacitor")return r=>{var n;return(n=e.get)==null?void 0:n.call(e,{key:r})};if(t==="expo-secure-storage")return r=>{var n;return(n=e.getItemAsync)==null?void 0:n.call(e,r)};if(t==="custom"){if(e.getItem&&e.removeItem)return e.getItem;if(e.getItemAsync)return e.getItemAsync;throw Error(`clientStorageType is set to 'custom' but clientStorage is missing either "getItem" and "removeItem" properties or "getItemAsync" property`)}throw Error(`Unknown storage type: ${t}`)},so=(t,e)=>{if(t==="localStorage"||t==="web")return no;if(t==="cookie")return(r,n)=>{Ot&&(n?ar.set(r,n,{expires:30,sameSite:"lax",httpOnly:!1}):ar.remove(r))};if(!e)throw Error(`clientStorageType is set to '${t}' but no clienStorage has been given`);if(t==="react-native")return(r,n)=>{var i,s;return n?(i=e.setItem)==null?void 0:i.call(e,r,n):(s=e.removeItem)==null?void 0:s.call(e,r)};if(t==="capacitor")return(r,n)=>{var i,s;return n?(i=e.set)==null?void 0:i.call(e,{key:r,value:n}):(s=e.remove)==null?void 0:s.call(e,{key:r})};if(t==="expo-secure-storage")return async(r,n)=>{var i,s;return n?(i=e.setItemAsync)==null?void 0:i.call(e,r,n):(s=e.deleteItemAsync)==null?void 0:s.call(e,r)};if(t==="custom"){if(!e.removeItem)throw Error("clientStorageType is set to 'custom' but clientStorage is missing a removeItem property");if(e.setItem)return(r,n)=>{var i,s;return n?(i=e.setItem)==null?void 0:i.call(e,r,n):(s=e.removeItem)==null?void 0:s.call(e,r)};if(e.setItemAsync)return async(r,n)=>{var i,s;return n?(i=e.setItemAsync)==null?void 0:i.call(e,r,n):(s=e.removeItem)==null?void 0:s.call(e,r)};throw Error("clientStorageType is set to 'custom' but clientStorage is missing setItem or setItemAsync property")}throw Error(`Unknown storage type: ${t}`)},En=(t,e)=>{const r=e&&Object.entries(e).map(([n,i])=>{const s=Array.isArray(i)?i.join(","):typeof i=="object"?JSON.stringify(i):i;return`${n}=${encodeURIComponent(s)}`}).join("&");return r?`${t}?${r}`:t},te=(t,e)=>{if(!(e!=null&&e.redirectTo))return e;const{redirectTo:r,...n}=e;if(!t)return r.startsWith("/")?n:e;const i=new URL(t),s=Object.fromEntries(new URLSearchParams(i.search)),o=new URL(r.startsWith("/")?i.origin+r:r),a=new URLSearchParams(o.search);let u=Object.fromEntries(a);r.startsWith("/")&&(u={...s,...u});let c=i.pathname;return o.pathname.length>1&&(c+=o.pathname.slice(1)),{...n,redirectTo:En(o.origin+c,u)}};function Rt(t,e){var r;if(!e){if(typeof window>"u")return;e=((r=window.location)==null?void 0:r.href)||""}t=t.replace(/[\[\]]/g,"\\$&");const n=new RegExp("[?&#]"+t+"(=([^&#]*)|&|#|$)"),i=n.exec(e);return i?i[2]?decodeURIComponent(i[2].replace(/\+/g," ")):"":null}function Tn(t){var e;if(typeof window>"u")return;const r=window==null?void 0:window.location;if(!!r&&r){const n=new URLSearchParams(r.search),i=new URLSearchParams((e=r.hash)==null?void 0:e.slice(1));n.delete(t),i.delete(t);let s=window.location.pathname;Array.from(n).length&&(s+=`?${n.toString()}`),Array.from(i).length&&(s+=`#${i.toString()}`),window.history.pushState({},"",s)}}const pe=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>=Ks,bn=t=>!!t&&typeof t=="string",oo=t=>t&&typeof t=="string"&&t.match(/^mfaTotp:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),fr={user:null,mfa:null,accessToken:{value:null,expiresAt:null},refreshTimer:{startedAt:null,attempts:0,lastAttempt:null},refreshToken:{value:null},importTokenAttempts:0,errors:{}},ao=({backendUrl:t,clientUrl:e,interpreter:r})=>{const n=Pe(t);return Ve({schema:{context:{},events:{},services:{}},tsTypes:{},predictableActionArguments:!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:$({error:i=>he}),saveRequestError:$({error:(i,{data:{error:s}})=>s}),reportError:Q(i=>({type:"ERROR",error:i.error})),reportSuccess:Q("SUCCESS")},guards:{invalidEmail:(i,{email:s})=>!pe(s)},services:{requestChange:async(i,{email:s,options:o})=>(await n.post("/user/email/change",{newEmail:s,options:te(e,o)},{headers:{authorization:`Bearer ${r==null?void 0:r.getSnapshot().context.accessToken.value}`}})).data}})},co=({backendUrl:t,interpreter:e})=>{const r=Pe(t);return Ve({schema:{context:{},events:{},services:{}},tsTypes:{},predictableActionArguments:!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:$({error:n=>ur}),saveRequestError:$({error:(n,{data:{error:i}})=>i}),reportError:Q(n=>({type:"ERROR",error:n.error})),reportSuccess:Q("SUCCESS")},guards:{invalidPassword:(n,{password:i})=>!lr(i)},services:{requestChange:(n,{password:i,ticket:s})=>r.post("/user/password",{newPassword:i,ticket:s},{headers:{authorization:`Bearer ${e==null?void 0:e.getSnapshot().context.accessToken.value}`}})}})},uo=({backendUrl:t,clientUrl:e})=>{const r=Pe(t);return Ve({schema:{context:{},events:{},services:{}},tsTypes:{},predictableActionArguments:!0,id:"changePassword",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:$({error:n=>he}),saveRequestError:$({error:(n,{data:{error:i}})=>i}),reportError:Q(n=>({type:"ERROR",error:n.error})),reportSuccess:Q("SUCCESS")},guards:{invalidEmail:(n,{email:i})=>!pe(i)},services:{requestChange:(n,{email:i,options:s})=>r.post("/user/password/reset",{email:i,options:te(e,s)})}})},lo=({backendUrl:t,clientUrl:e})=>{const r=Pe(t);return Ve({schema:{context:{},events:{},services:{}},tsTypes:{},predictableActionArguments:!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:$({error:n=>he}),saveRequestError:$({error:(n,{data:{error:i}})=>i}),reportError:Q(n=>({type:"ERROR",error:n.error})),reportSuccess:Q("SUCCESS")},guards:{invalidEmail:(n,{email:i})=>!pe(i)},services:{request:async(n,{email:i,options:s})=>(await r.post("/user/email/send-verification-email",{email:i,options:te(e,s)})).data}})},fo=({backendUrl:t,clientUrl:e,clientStorageGetter:r,clientStorageSetter:n,clientStorageType:i="web",clientStorage:s,refreshIntervalTime:o,autoRefreshToken:a=!0,autoSignIn:u=!0})=>{const c=r||io(i,s),f=n||so(i,s),v=Pe(t),h=async(d,l,p)=>(await v.post(d,l,p)).data;return Ve({schema:{context:{},events:{},services:{}},tsTypes:{},context:fr,predictableActionArguments:!0,id:"nhost",type:"parallel",states:{authentication:{initial:"starting",on:{SESSION_UPDATE:[{cond:"hasSession",actions:["saveSession","resetTimer","reportTokenChanged"],target:".signedIn"}]},states:{starting:{tags:["loading"],always:{cond:"isSignedIn",target:"signedIn"},invoke:{id:"importRefreshToken",src:"importRefreshToken",onDone:[{cond:"hasSession",actions:["saveSession","reportTokenChanged"],target:"signedIn"},{target:"signedOut"}],onError:[{cond:"shouldRetryImportToken",actions:"incrementTokenImportAttempts",target:"retryTokenImport"},{actions:["saveAuthenticationError"],target:"signedOut"}]}},retryTokenImport:{tags:["loading"],after:{RETRY_IMPORT_TOKEN_DELAY:"starting"}},signedOut:{initial:"noErrors",entry:"reportSignedOut",states:{noErrors:{},success:{},needsSmsOtp:{},needsMfa:{},failed:{},signingOut:{entry:["clearContextExceptRefreshToken"],exit:["destroyRefreshToken","reportTokenChanged"],invoke:{src:"signout",id:"signingOut",onDone:{target:"success"},onError:{target:"failed",actions:["saveAuthenticationError"]}}}},on:{SIGNIN_PASSWORD:"authenticating.password",SIGNIN_ANONYMOUS:"authenticating.anonymous",SIGNIN_SECURITY_KEY_EMAIL:"authenticating.securityKeyEmail",SIGNIN_MFA_TOTP:"authenticating.mfa.totp"}},authenticating:{entry:"resetErrors",states:{password:{invoke:{src:"signInPassword",id:"authenticateUserWithPassword",onDone:[{cond:"hasMfaTicket",actions:["saveMfaTicket"],target:"#nhost.authentication.signedOut.needsMfa"},{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"}],onError:[{cond:"unverified",target:["#nhost.authentication.signedOut","#nhost.registration.incomplete.needsEmailVerification"]},{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed"}]}},anonymous:{invoke:{src:"signInAnonymous",id:"authenticateAnonymously",onDone:{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed"}}},mfa:{states:{totp:{invoke:{src:"signInMfaTotp",id:"signInMfaTotp",onDone:{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:["saveAuthenticationError"],target:"#nhost.authentication.signedOut.failed"}}}}},securityKeyEmail:{invoke:{src:"signInSecurityKeyEmail",id:"authenticateUserWithSecurityKey",onDone:{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:[{cond:"unverified",target:["#nhost.authentication.signedOut","#nhost.registration.incomplete.needsEmailVerification"]},{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed"}]}}}},signedIn:{type:"parallel",entry:["reportSignedIn","cleanUrl","broadcastToken","resetErrors"],on:{SIGNOUT:"signedOut.signingOut"},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:{1e3:{internal:!1,target:"pending"}},always:{cond:"refreshTimerShouldRefresh",target:"refreshing"}},refreshing:{invoke:{src:"refreshToken",id:"refreshToken",onDone:{actions:["saveSession","resetTimer","reportTokenChanged"],target:"pending"},onError:[{actions:"saveRefreshAttempt",target:"pending"}]}}}}}}}}}},token:{initial:"idle",states:{idle:{on:{TRY_TOKEN:"running"},initial:"noErrors",states:{noErrors:{},error:{}}},running:{invoke:{src:"refreshToken",id:"authenticateWithToken",onDone:{actions:["saveSession","reportTokenChanged"],target:["#nhost.authentication.signedIn","idle.noErrors"]},onError:[{cond:"isSignedIn",target:"idle.error"},{actions:"saveAuthenticationError",target:["#nhost.authentication.signedOut.failed","idle.error"]}]}}}},registration:{initial:"incomplete",on:{SIGNED_IN:[{cond:"isAnonymous",target:".incomplete"},".complete"]},states:{incomplete:{on:{SIGNUP_EMAIL_PASSWORD:"emailPassword",SIGNUP_SECURITY_KEY:"securityKey",PASSWORDLESS_EMAIL:"passwordlessEmail",PASSWORDLESS_SMS:"passwordlessSms",PASSWORDLESS_SMS_OTP:"passwordlessSmsOtp"},initial:"noErrors",states:{noErrors:{},needsEmailVerification:{},needsOtp:{},failed:{}}},emailPassword:{entry:["resetErrors"],invoke:{src:"signUpEmailPassword",id:"signUpEmailPassword",onDone:[{cond:"hasSession",actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},{actions:"clearContext",target:["#nhost.authentication.signedOut","incomplete.needsEmailVerification"]}],onError:[{cond:"unverified",target:"incomplete.needsEmailVerification"},{actions:"saveRegistrationError",target:"incomplete.failed"}]}},securityKey:{entry:["resetErrors"],invoke:{src:"signUpSecurityKey",id:"signUpSecurityKey",onDone:[{cond:"hasSession",actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},{actions:"clearContext",target:["#nhost.authentication.signedOut","incomplete.needsEmailVerification"]}],onError:[{cond:"unverified",target:"incomplete.needsEmailVerification"},{actions:"saveRegistrationError",target:"incomplete.failed"}]}},passwordlessEmail:{entry:["resetErrors"],invoke:{src:"passwordlessEmail",id:"passwordlessEmail",onDone:{actions:"clearContext",target:["#nhost.authentication.signedOut","incomplete.needsEmailVerification"]},onError:{actions:"saveRegistrationError",target:"incomplete.failed"}}},passwordlessSms:{entry:["resetErrors"],invoke:{src:"passwordlessSms",id:"passwordlessSms",onDone:{actions:"clearContext",target:["#nhost.authentication.signedOut","incomplete.needsOtp"]},onError:{actions:"saveRegistrationError",target:"incomplete.failed"}}},passwordlessSmsOtp:{entry:["resetErrors"],invoke:{src:"passwordlessSmsOtp",id:"passwordlessSmsOtp",onDone:{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveRegistrationError",target:"incomplete.failed"}}},complete:{on:{SIGNED_OUT:"incomplete"}}}}}},{actions:{reportSignedIn:Q("SIGNED_IN"),reportSignedOut:Q("SIGNED_OUT"),reportTokenChanged:Q("TOKEN_CHANGED"),incrementTokenImportAttempts:$({importTokenAttempts:({importTokenAttempts:d})=>d+1}),clearContext:$(()=>(f(bt,null),f(Tt,null),{...fr})),clearContextExceptRefreshToken:$(({refreshToken:{value:d}})=>(f(bt,null),{...fr,refreshToken:{value:d}})),saveSession:$({user:(d,{data:l})=>{var p;return((p=l==null?void 0:l.session)==null?void 0:p.user)||null},accessToken:(d,{data:l})=>{if(l.session){const{accessTokenExpiresIn:p,accessToken:y}=l.session,S=new Date(Date.now()+p*1e3);return f(bt,S.toISOString()),{value:y,expiresAt:S}}return f(bt,null),{value:null,expiresAt:null}},refreshToken:(d,{data:l})=>{var p;const y=((p=l.session)==null?void 0:p.refreshToken)||null;return y&&f(Tt,y),{value:y}}}),saveMfaTicket:$({mfa:(d,l)=>{var p;return(p=l.data)==null?void 0:p.mfa}}),resetTimer:$({refreshTimer:d=>({startedAt:new Date,attempts:0,lastAttempt:null})}),saveRefreshAttempt:$({refreshTimer:(d,l)=>({startedAt:d.refreshTimer.startedAt,attempts:d.refreshTimer.attempts+1,lastAttempt:new Date})}),saveAuthenticationError:$({errors:({errors:d},{data:{error:l}})=>({...d,authentication:l})}),resetErrors:$({errors:d=>({}),importTokenAttempts:d=>0}),saveRegistrationError:$({errors:({errors:d},{data:{error:l}})=>({...d,registration:l})}),destroyRefreshToken:$({refreshToken:d=>(f(Tt,null),{value:null})}),cleanUrl:()=>{u&&Rt("refreshToken")&&(Tn("refreshToken"),Tn("type"))},broadcastToken:d=>{if(u)try{new BroadcastChannel("nhost").postMessage(d.refreshToken.value)}catch{}}},guards:{isAnonymous:(d,l)=>{var p;return!!((p=d.user)!=null&&p.isAnonymous)},isSignedIn:d=>!!d.user&&!!d.refreshToken.value&&!!d.accessToken.value,noToken:d=>!d.refreshToken.value,hasRefreshToken:d=>!!d.refreshToken.value,isAutoRefreshDisabled:()=>!a,refreshTimerShouldRefresh:d=>{const{expiresAt:l}=d.accessToken;return l?d.refreshTimer.lastAttempt?Date.now()-d.refreshTimer.lastAttempt.getTime()>Js*1e3:o&&Date.now()-d.refreshTimer.startedAt.getTime()>o*1e3?!0:l.getTime()-Date.now()-1e3*Hs<=0:!1},shouldRetryImportToken:(d,l)=>l.data.error.status===gn||l.data.error.status>=500,unverified:(d,{data:{error:l}})=>l.status===401&&(l.message==="Email is not verified"||l.error==="unverified-user"),hasSession:(d,l)=>{var p;return!!((p=l.data)!=null&&p.session)},hasMfaTicket:(d,l)=>{var p;return!!((p=l.data)!=null&&p.mfa)}},services:{signInPassword:(d,{email:l,password:p})=>pe(l)?lr(p)?h("/signin/email-password",{email:l,password:p}):Promise.reject({error:ur}):Promise.reject({error:he}),passwordlessSms:(d,{phoneNumber:l,options:p})=>{var y;return bn(l)?(y=d.user)!=null&&y.isAnonymous?(console.warn("Deanonymisation from a phone number is not yet implemented in hasura-auth"),h("/user/deanonymize",{signInMethod:"passwordless",connection:"sms",phoneNumber:l,options:te(e,p)},{headers:{authorization:`Bearer ${d.accessToken.value}`}})):h("/signin/passwordless/sms",{phoneNumber:l,options:te(e,p)}):Promise.reject({error:Sn})},passwordlessSmsOtp:(d,{phoneNumber:l,otp:p})=>bn(l)?h("/signin/passwordless/sms/otp",{phoneNumber:l,otp:p}):Promise.reject({error:Sn}),passwordlessEmail:(d,{email:l,options:p})=>{var y;return pe(l)?(y=d.user)!=null&&y.isAnonymous?h("/user/deanonymize",{signInMethod:"passwordless",connection:"email",email:l,options:te(e,p)},{headers:{authorization:`Bearer ${d.accessToken.value}`}}):h("/signin/passwordless/email",{email:l,options:te(e,p)}):Promise.reject({error:he})},signInAnonymous:d=>h("/signin/anonymous"),signInMfaTotp:(d,l)=>{var p;const y=l.ticket||((p=d.mfa)==null?void 0:p.ticket);return y?oo(y)?h("/signin/mfa/totp",{ticket:y,otp:l.otp}):Promise.reject({error:Gs}):Promise.reject({error:Ws})},signInSecurityKeyEmail:async(d,{email:l})=>{if(!pe(l))throw new At(he);const p=await h("/signin/webauthn",{email:l});let y;try{y=await Vs(p)}catch(S){throw new At(S)}return h("/signin/webauthn/verify",{email:l,credential:y})},refreshToken:async(d,l)=>{const p=l.type==="TRY_TOKEN"?l.token:d.refreshToken.value;return{session:await h("/token",{refreshToken:p}),error:null}},signout:(d,l)=>h("/signout",{refreshToken:d.refreshToken.value,all:!!l.all}),signUpEmailPassword:async(d,{email:l,password:p,options:y})=>{var S;return pe(l)?lr(p)?(S=d.user)!=null&&S.isAnonymous?h("/user/deanonymize",{signInMethod:"email-password",email:l,password:p,options:te(e,y)},{headers:{authorization:`Bearer ${d.accessToken.value}`}}):h("/signup/email-password",{email:l,password:p,options:te(e,y)}):Promise.reject({error:ur}):Promise.reject({error:he})},signUpSecurityKey:async(d,{email:l,options:p})=>{if(!pe(l))return Promise.reject({error:he});const y=p==null?void 0:p.nickname;y&&delete p.nickname;const S=await h("/signup/webauthn",{email:l,options:p});let g;try{g=await yn(S)}catch(E){throw new At(E)}return h("/signup/webauthn/verify",{credential:g,options:{redirectTo:p==null?void 0:p.redirectTo,nickname:y}})},importRefreshToken:async()=>{let d=null;if(u){const p=Rt("refreshToken")||null;if(p)try{return{session:await h("/token",{refreshToken:p}),error:null}}catch(y){d=y.error}else{const y=Rt("error");if(y)return Promise.reject({session:null,error:{status:de,error:y,message:Rt("errorDescription")||y}})}}const l=await c(Tt);if(l)try{return{session:await h("/token",{refreshToken:l}),error:null}}catch(p){d=p.error}return d?Promise.reject({error:d,session:null}):{error:null,session:null}}},delays:{RETRY_IMPORT_TOKEN_DELAY:({importTokenAttempts:d})=>d<5?1e3:5e3}})};class ho{constructor({clientStorageType:e="web",autoSignIn:r=!0,autoRefreshToken:n=!0,start:i=!0,backendUrl:s,clientUrl:o,devTools:a,...u}){if(ye(this,"backendUrl"),ye(this,"clientUrl"),ye(this,"machine"),ye(this,"_interpreter"),ye(this,"_channel"),ye(this,"_subscriptions",new Set),this.backendUrl=s,this.clientUrl=o,this.machine=fo({...u,backendUrl:s,clientUrl:o,clientStorageType:e,autoSignIn:r,autoRefreshToken:n}),i&&(this.interpreter=Oe(this.machine,{devTools:a}),this.interpreter.start()),typeof window<"u"&&r)try{this._channel=new BroadcastChannel("nhost"),this._channel.addEventListener("message",c=>{var f;const v=(f=this.interpreter)==null?void 0:f.getSnapshot().context.refreshToken.value;this.interpreter&&c.data!==v&&this.interpreter.send("TRY_TOKEN",{token:c.data})})}catch{}}get interpreter(){return this._interpreter}set interpreter(e){this._interpreter=e,e&&this._subscriptions.forEach(r=>r(this))}onStart(e){this.interpreter?e(this):this._subscriptions.add(e)}}const po=async({backendUrl:t,interpreter:e},r)=>{const n=Pe(t);try{const{data:i}=await n.post("/user/webauthn/add",{},{headers:{authorization:`Bearer ${e==null?void 0:e.getSnapshot().context.accessToken.value}`}});let s;try{s=await yn(i)}catch(a){throw new At(a)}const{data:o}=await n.post("/user/webauthn/verify",{credential:s,nickname:r},{headers:{authorization:`Bearer ${e==null?void 0:e.getSnapshot().context.accessToken.value}`}});return{key:o,isError:!1,error:null,isSuccess:!0}}catch(i){const{error:s}=i;return{isError:!0,error:s,isSuccess:!1}}},vo=async(t,e,r)=>new Promise(n=>{t.send("REQUEST",{email:e,options:r}),t.onTransition(i=>{i.matches({idle:"error"})?n({error:i.context.error,isError:!0,needsEmailVerification:!1}):i.matches({idle:"success"})&&n({error:null,isError:!1,needsEmailVerification:!0})})}),mo=async(t,e,r)=>new Promise(n=>{t.send("REQUEST",{password:e,ticket:r}),t.onTransition(i=>{i.matches({idle:"error"})?n({error:i.context.error,isError:!0,isSuccess:!1}):i.matches({idle:"success"})&&n({error:null,isError:!1,isSuccess:!0})})}),yo=async(t,e,r)=>new Promise(n=>{t.send("REQUEST",{email:e,options:r}),t.onTransition(i=>{i.matches({idle:"error"})?n({error:i.context.error,isError:!0,isSent:!1}):i.matches({idle:"success"})&&n({error:null,isError:!1,isSent:!0})})}),go=(t,e,r)=>new Promise(n=>{t.send("REQUEST",{email:e,options:r}),t.onTransition(i=>{i.matches({idle:"error"})?n({error:i.context.error,isError:!0,isSent:!1}):i.matches({idle:"success"})&&n({error:null,isError:!1,isSent:!0})})}),wo=t=>new Promise(e=>{const{changed:r}=t.send("SIGNIN_ANONYMOUS");r||e({isSuccess:!1,isError:!0,error:oe,user:null,accessToken:null}),t.onTransition(n=>{n.matches({authentication:"signedIn"})&&e({isSuccess:!0,isError:!1,error:null,user:n.context.user,accessToken:n.context.accessToken.value}),n.matches({authentication:{signedOut:"failed"}})&&e({isSuccess:!1,isError:!0,error:n.context.errors.authentication||null,user:null,accessToken:null})})}),So=(t,e,r)=>new Promise(n=>{const{changed:i,context:s}=t.send("SIGNIN_PASSWORD",{email:e,password:r});if(!i)return n({accessToken:s.accessToken.value,error:oe,isError:!0,isSuccess:!1,needsEmailVerification:!1,needsMfaOtp:!1,mfa:null,user:s.user});t.onTransition(o=>{o.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})?n({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!0,needsMfaOtp:!1,mfa:null,user:null}):o.matches({authentication:{signedOut:"needsMfa"}})?n({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!1,needsMfaOtp:!0,mfa:o.context.mfa,user:null}):o.matches({authentication:{signedOut:"failed"}})?n({accessToken:null,error:o.context.errors.authentication||null,isError:!0,isSuccess:!1,needsEmailVerification:!1,needsMfaOtp:!1,mfa:null,user:null}):o.matches({authentication:"signedIn"})&&n({accessToken:o.context.accessToken.value,error:null,isError:!1,isSuccess:!0,needsEmailVerification:!1,needsMfaOtp:!1,mfa:null,user:o.context.user})})}),xn=(t,e,r)=>new Promise(n=>{const{changed:i}=t.send("PASSWORDLESS_EMAIL",{email:e,options:r});if(!i)return n({error:oe,isError:!0,isSuccess:!1});t.onTransition(s=>{s.matches("registration.incomplete.failed")?n({error:s.context.errors.registration||null,isError:!0,isSuccess:!1}):s.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})&&n({error:null,isError:!1,isSuccess:!0})})}),Eo=(t,e)=>new Promise(r=>{const{changed:n,context:i}=t.send({type:"SIGNIN_SECURITY_KEY_EMAIL",email:e});if(!n)return r({accessToken:i.accessToken.value,error:oe,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:i.user});t.onTransition(s=>{s.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})?r({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!0,user:null}):s.matches({authentication:{signedOut:"failed"}})?r({accessToken:null,error:s.context.errors.authentication||null,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:null}):s.matches({authentication:"signedIn"})&&r({accessToken:s.context.accessToken.value,error:null,isError:!1,isSuccess:!0,needsEmailVerification:!1,user:s.context.user})})}),To=(t,e,r)=>new Promise(n=>{const{changed:i,context:s}=t.send("SIGNIN_MFA_TOTP",{otp:e,ticket:r});if(!i)return n({accessToken:s.accessToken.value,error:oe,isError:!0,isSuccess:!1,user:s.user});t.onTransition(o=>{o.matches({authentication:{signedOut:"failed"}})?n({accessToken:null,error:o.context.errors.authentication||null,isError:!0,isSuccess:!1,user:null}):o.matches({authentication:"signedIn"})&&n({accessToken:o.context.accessToken.value,error:null,isError:!1,isSuccess:!0,user:o.context.user})})}),An=(t,e,r)=>new Promise(n=>{const{changed:i}=t.send("PASSWORDLESS_SMS",{phoneNumber:e,options:r});if(!i)return n({error:oe,isError:!0,isSuccess:!1,needsOtp:!1});t.onTransition(s=>{s.matches("registration.incomplete.needsOtp")?n({error:null,isError:!1,isSuccess:!1,needsOtp:!0}):s.matches("registration.incomplete.failed")&&n({error:s.context.errors.authentication||null,isError:!0,isSuccess:!1,needsOtp:!1})})}),bo=(t,e,r)=>new Promise(n=>{const{changed:i}=t.send({type:"PASSWORDLESS_SMS_OTP",phoneNumber:e,otp:r});if(!i)return n({error:oe,isError:!0,isSuccess:!1,user:null,accessToken:null});t.onTransition(s=>{s.matches({authentication:"signedIn"})?n({error:null,isError:!1,isSuccess:!0,user:s.context.user,accessToken:s.context.accessToken.value}):s.matches({registration:{incomplete:"failed"}})&&n({error:s.context.errors.authentication||null,isError:!0,isSuccess:!1,user:null,accessToken:null})})}),xo=async(t,e)=>new Promise(r=>{const{event:n}=t.send("SIGNOUT",{all:e});if(n.type!=="SIGNED_OUT")return r({isSuccess:!1,isError:!0,error:Xs});t.onTransition(i=>{i.matches({authentication:{signedOut:"success"}})?r({isSuccess:!0,isError:!1,error:null}):i.matches("authentication.signedOut.failed")&&r({isSuccess:!1,isError:!0,error:i.context.errors.signout||null})})}),On=(t,e,r,n)=>new Promise(i=>{const{changed:s,context:o}=t.send("SIGNUP_EMAIL_PASSWORD",{email:e,password:r,options:n});if(!s)return i({error:oe,accessToken:o.accessToken.value,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:o.user});t.onTransition(a=>{a.matches("registration.incomplete.failed")?i({accessToken:null,error:a.context.errors.registration||null,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:null}):a.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})?i({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!0,user:null}):a.matches({authentication:"signedIn",registration:"complete"})&&i({accessToken:a.context.accessToken.value,error:null,isError:!1,isSuccess:!0,needsEmailVerification:!1,user:a.context.user})})}),Ao=(t,e,r)=>new Promise(n=>{const{changed:i,context:s}=t.send("SIGNUP_SECURITY_KEY",{email:e,options:r});if(!i)return n({error:oe,accessToken:s.accessToken.value,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:s.user});t.onTransition(o=>{o.matches("registration.incomplete.failed")?n({accessToken:null,error:o.context.errors.registration||null,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:null}):o.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})?n({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!0,user:null}):o.matches({authentication:"signedIn",registration:"complete"})&&n({accessToken:o.context.accessToken.value,error:null,isError:!1,isSuccess:!0,needsEmailVerification:!1,user:o.context.user})})});var Oo=Object.defineProperty,ko=(t,e,r)=>e in t?Oo(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,kn=(t,e,r)=>(ko(t,typeof e!="symbol"?e+"":e,r),r);const Ro=()=>typeof window<"u",Nt=t=>!t||!t.accessToken.value||!t.refreshToken.value||!t.accessToken.expiresAt||!t.user?null:{accessToken:t.accessToken.value,accessTokenExpiresIn:(t.accessToken.expiresAt.getTime()-Date.now())/1e3,refreshToken:t.refreshToken.value,user:t.user},we=({accessToken:t,isError:e,user:r,error:n})=>e?{session:null,error:n}:r&&t?{session:{accessToken:t,accessTokenExpiresIn:0,refreshToken:"",user:r},error:null}:{session:null,error:null};class No{constructor({url:e,autoRefreshToken:r=!0,autoSignIn:n=!0,autoLogin:i,clientStorage:s,clientStorageType:o,clientStorageGetter:a,clientStorageSetter:u,refreshIntervalTime:c,start:f=!0}){kn(this,"_client"),kn(this,"url");var v;this.url=e,this._client=new ho({backendUrl:e,clientUrl:typeof window<"u"&&((v=window.location)==null?void 0:v.origin)||"",autoRefreshToken:r,autoSignIn:typeof i=="boolean"?i:n,start:f,clientStorage:s,clientStorageType:o,clientStorageGetter:a,clientStorageSetter:u,refreshIntervalTime:c})}async signUp(e){const r=await this.waitUntilReady(),{email:n,options:i}=e;return"securityKey"in e?we(await Ao(r,n,i)):we(await On(r,n,e.password,i))}async signIn(e){const r=await this.waitUntilReady();if(!e){const n=await wo(r);return{...we(n),mfa:null}}if("provider"in e){const{provider:n,options:i}=e,s=En(`${this._client.backendUrl}/signin/provider/${n}`,te(this._client.clientUrl,i));return Ro()&&(window.location.href=s),{providerUrl:s,provider:n,session:null,mfa:null,error:null}}if("email"in e&&"password"in e){const n=await So(r,e.email,e.password);return n.needsEmailVerification?{session:null,mfa:null,error:Zs}:n.needsMfaOtp?{session:null,mfa:n.mfa,error:null}:{...we(n),mfa:null}}if("email"in e&&"securityKey"in e){if(e.securityKey!==!0)throw Error("securityKey must be true");const n=await Eo(r,e.email);return{...we(n),mfa:null}}if("email"in e){const{email:n,options:i}=e,{error:s}=await xn(r,n,i);return{session:null,mfa:null,error:s}}if("phoneNumber"in e&&"otp"in e){const n=await bo(r,e.phoneNumber,e.otp);return{...we(n),mfa:null}}if("phoneNumber"in e){const{error:n}=await An(r,e.phoneNumber,e.options);return{error:n,mfa:null,session:null}}if("otp"in e){const n=await To(r,e.otp,e.ticket);return{...we(n),mfa:null}}return{error:to,mfa:null,session:null}}async signOut(e){const r=await this.waitUntilReady(),{error:n}=await xo(r,e==null?void 0:e.all);return{error:n}}async resetPassword({email:e,options:r}){const n=Oe(uo(this._client)).start(),{error:i}=await yo(n,e,r);return{error:i}}async changePassword({newPassword:e,ticket:r}){const n=Oe(co(this._client)).start(),{error:i}=await mo(n,e,r);return{error:i}}async sendVerificationEmail({email:e,options:r}){const n=Oe(lo(this._client)).start(),{error:i}=await go(n,e,r);return{error:i}}async changeEmail({newEmail:e,options:r}){const n=Oe(ao(this._client)).start(),{error:i}=await vo(n,e,r);return{error:i}}async deanonymize(e){const r=await this.waitUntilReady();if(e.signInMethod==="passwordless"){if(e.connection==="email"){const{error:n}=await xn(r,e.email,e.options);return{error:n}}if(e.connection==="sms"){const{error:n}=await An(r,e.phoneNumber,e.options);return{error:n}}}if(e.signInMethod==="email-password"){const{error:n}=await On(r,e.email,e.password,e.options);return{error:n}}throw Error("Unknown deanonymization method")}async addSecurityKey(e){const{error:r,key:n}=await po(this._client,e);return{error:r,key:n}}onTokenChanged(e){const r=n=>n.onTransition(({event:i,context:s})=>{i.type==="TOKEN_CHANGED"&&e(Nt(s))});if(this._client.interpreter){const n=r(this._client.interpreter);return()=>n.stop()}else return this._client.onStart(n=>{r(n.interpreter)}),()=>{console.log("onTokenChanged was added before the interpreter started. Cannot unsubscribe listener.")}}onAuthStateChanged(e){const r=n=>n.onTransition(({event:i,context:s})=>{(i.type==="SIGNED_IN"||i.type==="SIGNED_OUT")&&e(i.type,Nt(s))});if(this._client.interpreter){const n=r(this._client.interpreter);return()=>n.stop()}else return this._client.onStart(n=>{r(n.interpreter)}),()=>{console.log("onAuthStateChanged was added before the interpreter started. Cannot unsubscribe listener.")}}isAuthenticated(){var e;return!!((e=this._client.interpreter)!=null&&e.getSnapshot().matches({authentication:"signedIn"}))}async isAuthenticatedAsync(){return(await this.waitUntilReady()).getSnapshot().matches({authentication:"signedIn"})}getAuthenticationStatus(){var e;const r=((e=this.client.interpreter)==null?void 0:e.getSnapshot().context.importTokenAttempts)||0;return this.isReady()?{isAuthenticated:this.isAuthenticated(),isLoading:!1,connectionAttempts:r}:{isAuthenticated:!1,isLoading:!0,connectionAttempts:r}}getJWTToken(){return this.getAccessToken()}getAccessToken(){var e,r;return(r=(e=this._client.interpreter)==null?void 0:e.getSnapshot().context.accessToken.value)!=null?r:void 0}getDecodedAccessToken(){const e=this.getAccessToken();return e?Mn(e):null}getHasuraClaims(){var e;return((e=this.getDecodedAccessToken())==null?void 0:e["https://hasura.io/jwt/claims"])||null}getHasuraClaim(e){var r;return((r=this.getHasuraClaims())==null?void 0:r[e.startsWith("x-hasura-")?e:`x-hasura-${e}`])||null}async refreshSession(e){try{const r=await this.waitUntilReady();return new Promise(n=>{const i=e||r.getSnapshot().context.refreshToken.value;if(!i)return n({session:null,error:Ys});const{changed:s}=r.send("TRY_TOKEN",{token:i});if(!s)return n({session:null,error:Qs});r.onTransition(o=>{o.matches({token:{idle:"error"}})?n({session:null,error:eo}):o.event.type==="TOKEN_CHANGED"&&n({session:Nt(o.context),error:null})})})}catch(r){return{session:null,error:r.message}}}getSession(){var e,r;return Nt((r=(e=this._client.interpreter)==null?void 0:e.getSnapshot())==null?void 0:r.context)}getUser(){var e,r,n;return((n=(r=(e=this._client.interpreter)==null?void 0:e.getSnapshot())==null?void 0:r.context)==null?void 0:n.user)||null}waitUntilReady(){const e=this._client.interpreter;if(!e)throw Error("Auth interpreter not set");return e.getSnapshot().hasTag("loading")?new Promise((r,n)=>{let i=setTimeout(()=>n(`The state machine is not yet ready after ${15} seconds.`),15e3);e.onTransition(s=>{if(!s.hasTag("loading"))return clearTimeout(i),r(e)})}):Promise.resolve(e)}isReady(){var e,r;return!((r=(e=this._client.interpreter)==null?void 0:e.getSnapshot())!=null&&r.hasTag("loading"))}get client(){return this._client}}const Io=/^((?<protocol>http[s]?):\/\/)?(?<host>localhost)(:(?<port>(\d+|__\w+__)))?$/;function It(t,e){const{backendUrl:r,subdomain:n,region:i}=t;if(r)return`${r}/v1/${e}`;if(!n)throw new Error("Either `backendUrl` or `subdomain` must be set.");const s=n.match(Io);if(s!=null&&s.groups){const{protocol:o="http",host:a,port:u=1337}=s.groups,c=Uo(e);return c||`${o}://${a}:${u}/v1/${e}`}if(!i)throw new Error('`region` must be set when using a `subdomain` other than "localhost".');return`https://${n}.${e}.${i}.nhost.run/v1`}function Po(){return typeof window<"u"}function Co(){return typeof process<"u"&&process.env}function Uo(t){return Po()||!Co()?null:process.env[`NHOST_${t.toUpperCase()}_URL`]}function Rn(t){const e="subdomain"in t||"backendUrl"in t?It(t,"auth"):t.authUrl;if(!e)throw new Error("Please provide `subdomain` or `authUrl`.");return new No({url:e,...t})}function Nn(t){const e="subdomain"in t||"backendUrl"in t?It(t,"functions"):t.functionsUrl;if(!e)throw new Error("Please provide `subdomain` or `functionsUrl`.");return new In({url:e,...t})}class In{constructor(e){J(this,"url");J(this,"instance");J(this,"accessToken");J(this,"adminSecret");const{url:r,adminSecret:n}=e;this.url=r,this.accessToken=null,this.adminSecret=n,this.instance=wt.create({baseURL:r})}async call(e,r,n){const i={...this.generateAccessTokenHeaders(),...n==null?void 0:n.headers};let 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(){return this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:{}}}function Pn(t){const e="subdomain"in t||"backendUrl"in t?It(t,"graphql"):t.graphqlUrl;if(!e)throw new Error("Please provide `subdomain` or `graphqlUrl`.");return new Cn({url:e,...t})}class Cn{constructor(e){J(this,"url");J(this,"instance");J(this,"accessToken");J(this,"adminSecret");const{url:r,adminSecret:n}=e;this.url=r,this.accessToken=null,this.adminSecret=n,this.instance=wt.create({baseURL:r})}async request(e,r,n){const i={...this.generateAccessTokenHeaders(),...n==null?void 0:n.headers,"Accept-Encoding":"*"};try{const s="",a=(await this.instance.post("",{operationName:s||void 0,query:typeof e=="string"?e:W.print(e),variables:r},{...n,headers:i})).data,{data:u}=a;return a.errors?{data:null,error:a.errors}:typeof u!="object"||Array.isArray(u)||u===null?{data:null,error:new Error("incorrect response data from GraphQL server")}:{data:u,error:null}}catch(s){return s instanceof Error?{data:null,error:s}:(console.error(s),{data:null,error:new Error("Unable to get do GraphQL request")})}}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){return this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:{}}}var Do=Object.defineProperty,_o=(t,e,r)=>e in t?Do(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,Ce=(t,e,r)=>(_o(t,typeof e!="symbol"?e+"":e,r),r);class jo{constructor({url:e}){Ce(this,"url"),Ce(this,"httpClient"),Ce(this,"accessToken"),Ce(this,"adminSecret"),this.url=e,this.httpClient=wt.create({baseURL:this.url})}async upload(e){const{formData:r}=e;try{return{fileMetadata:(await this.httpClient.post("/files",r,{headers:{...this.generateUploadHeaders(e),...this.generateAuthHeaders(),"Content-Type":"multipart/form-data"}})).data,error:null}}catch(n){return{fileMetadata:null,error:n}}}async getPresignedUrl(e){try{const{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{const{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){const{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}`}}}class Lo{constructor({url:e,adminSecret:r}){Ce(this,"url"),Ce(this,"api"),this.url=e,this.api=new jo({url:e}),this.setAdminSecret(r)}async upload(e){let r;"file"in e?(r=new Gr,r.append("file",e.file)):r=e.formData;const{fileMetadata:n,error:i}=await this.api.upload({...e,formData: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){const{fileId:r}=e;return`${this.url}/files/${r}`}async getPresignedUrl(e){const{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){const{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}}function Un(t){const e="subdomain"in t||"backendUrl"in t?It(t,"storage"):t.storageUrl;if(!e)throw new Error("Please provide `subdomain` or `storageUrl`.");return new Lo({url:e,...t})}const Mo=t=>new Dn(t);class Dn{constructor({refreshIntervalTime:e,clientStorageGetter:r,clientStorageSetter:n,clientStorage:i,clientStorageType:s,autoRefreshToken:o,autoSignIn:a,adminSecret:u,devTools:c,start:f=!0,...v}){J(this,"auth");J(this,"storage");J(this,"functions");J(this,"graphql");J(this,"_adminSecret");J(this,"devTools");this.auth=Rn({refreshIntervalTime:e,clientStorageGetter:r,clientStorageSetter:n,clientStorage:i,clientStorageType:s,autoRefreshToken:o,autoSignIn:a,start:f,...v}),this.storage=Un({adminSecret:u,...v}),this.functions=Nn({adminSecret:u,...v}),this.graphql=Pn({adminSecret:u,...v}),this.auth.client.onStart(()=>{const h=this.auth.getAccessToken();this.storage.setAccessToken(h),this.functions.setAccessToken(h),this.graphql.setAccessToken(h),this.auth.onAuthStateChanged((d,l)=>{d==="SIGNED_OUT"&&(this.storage.setAccessToken(void 0),this.functions.setAccessToken(void 0),this.graphql.setAccessToken(void 0))}),this.auth.onTokenChanged(d=>{const l=d==null?void 0:d.accessToken;this.storage.setAccessToken(l),this.functions.setAccessToken(l),this.graphql.setAccessToken(l)})}),this._adminSecret=u,this.devTools=c}get adminSecret(){return this._adminSecret}set adminSecret(e){this._adminSecret=e,this.storage.setAdminSecret(e)}}F.NhostClient=Dn,F.NhostFunctionsClient=In,F.NhostGraphqlClient=Cn,F.createAuthClient=Rn,F.createFunctionsClient=Nn,F.createGraphqlClient=Pn,F.createNhostClient=Mo,F.createStorageClient=Un,Object.defineProperties(F,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
16
|
+
Event: `).concat(JSON.stringify(h.data)));return n.scheduler.schedule(function(){n.forward(h);var f=n._nextState(h);n.update(f,h)}),n._state},this.sendTo=function(l,v,h){var f=n.parent&&(v===ee.Parent||n.parent.id===v),d=f?n.parent:I(v)?n.children.get(v)||St.get(v):ts(v)?v:void 0;if(!d){if(!f)throw new Error("Unable to send event to child '".concat(v,"' from service '").concat(n.id,"'."));F||B(!1,"Service '".concat(n.id,"' has no parent: unable to send event ").concat(l.type));return}if("machine"in d){if(n.status!==q.Stopped||n.parent!==d||n.state.done){var p=y(y({},l),{name:l.name===Gt?"".concat(Oe(n.id)):l.name,origin:n.sessionId});!h&&n.machine.config.predictableActionArguments?n._outgoingQueue.push([d,p]):d.send(p)}}else!h&&n.machine.config.predictableActionArguments?n._outgoingQueue.push([d,l.data]):d.send(l.data)},this._exec=function(l,v,h,f){f===void 0&&(f=n.machine.options.actions);var d=l.exec||mt(l.type,f),p=_(d)?d:d?d.exec:l.exec;if(p)try{return p(v,h.data,n.machine.config.predictableActionArguments?{action:l,_event:h}:{action:l,state:n.state,_event:h})}catch(J){throw n.parent&&n.parent.send({type:"xstate.error",data:J}),J}switch(l.type){case ye:var g=l;if(typeof g.delay=="number"){n.defer(g);return}else g.to?n.sendTo(g._event,g.to,h===Ee):n.send(g._event);break;case Ht:n.cancel(l.sendId);break;case it:{if(n.status!==q.Running)return;var w=l.activity;if(!n.machine.config.predictableActionArguments&&!n.state.activities[w.id||w.type])break;if(w.type===C.Invoke){var S=Gr(w.src),T=n.machine.options.services?n.machine.options.services[S.type]:void 0,P=w.id,k=w.data;F||B(!("forward"in w),"`forward` property is deprecated (found in invocation of '".concat(w.src,"' in in machine '").concat(n.machine.id,"'). ")+"Please use `autoForward` instead.");var j="autoForward"in w?w.autoForward:!!w.forward;if(!T){F||B(!1,"No service found for invocation '".concat(w.src,"' in machine '").concat(n.machine.id,"'."));return}var x=k?ht(k,v,h):void 0;if(typeof T=="string")return;var U=_(T)?T(v,h.data,{data:x,src:S,meta:w.meta}):T;if(!U)return;var D=void 0;ne(U)&&(U=x?U.withContext(x):U,D={autoForward:j}),n.spawn(U,P,D)}else n.spawnActivity(w);break}case st:{n.stopChild(l.activity.id);break}case at:var b=l.label,M=l.value;b?n.logger(b,M):n.logger(M);break;default:F||B(!1,"No implementation found for action type '".concat(l.type,"'"));break}};var i=y(y({},t.defaultOptions),r),s=i.clock,o=i.logger,a=i.parent,u=i.id,c=u!==void 0?u:e.id;this.id=c,this.logger=o,this.clock=s,this.parent=a,this.options=i,this.scheduler=new dn({deferEvents:this.options.deferEvents}),this.sessionId=St.bookId()}return Object.defineProperty(t.prototype,"initialState",{get:function(){var e=this;return this._initialState?this._initialState:Re(this,function(){return e._initialState=e.machine.initialState,e._initialState})},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"state",{get:function(){return F||B(this.status!==q.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=R(e.actions),o=s.next();!o.done;o=s.next()){var a=o.value;this.exec(a,e,r)}}catch(u){n={error:u}}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,u,c,l,v=this;if(e._sessionid=this.sessionId,this._state=e,(!this.machine.config.predictableActionArguments||r===Ee)&&this.options.execute)this.execute(this.state);else for(var h=void 0;h=this._outgoingQueue.shift();)h[0].send(h[1]);if(this.children.forEach(function(D){v.state.children[D.id]=D}),this.devTools&&this.devTools.send(r.data,e),e.event)try{for(var f=R(this.eventListeners),d=f.next();!d.done;d=f.next()){var p=d.value;p(e.event)}}catch(D){n={error:D}}finally{try{d&&!d.done&&(i=f.return)&&i.call(f)}finally{if(n)throw n.error}}try{for(var g=R(this.listeners),w=g.next();!w.done;w=g.next()){var p=w.value;p(e,e.event)}}catch(D){s={error:D}}finally{try{w&&!w.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}try{for(var S=R(this.contextListeners),T=S.next();!T.done;T=S.next()){var P=T.value;P(this.state.context,this.state.history?this.state.history.context:void 0)}}catch(D){a={error:D}}finally{try{T&&!T.done&&(u=S.return)&&u.call(S)}finally{if(a)throw a.error}}if(this.state.done){var k=e.configuration.find(function(D){return D.type==="final"&&D.parent===v.machine}),j=k&&k.doneData?ht(k.doneData,e.context,r):void 0;try{for(var x=R(this.doneListeners),U=x.next();!U.done;U=x.next()){var p=U.value;p($e(this.id,j))}}catch(D){c={error:D}}finally{try{U&&!U.done&&(l=x.return)&&l.call(x)}finally{if(c)throw c.error}}this._stop(),this._stopChildren()}},t.prototype.onTransition=function(e){return this.listeners.add(e),this.status===q.Running&&e(this.state,this.state.event),this},t.prototype.subscribe=function(e,r,n){var i=this,s=pt(e,r,n);this.listeners.add(s.next),this.status!==q.NotStarted&&s.next(this.state);var o=function(){i.doneListeners.delete(o),i.stopListeners.delete(o),s.complete()};return this.status===q.Stopped?s.complete():(this.onDone(o),this.onStop(o)),{unsubscribe:function(){i.listeners.delete(s.next),i.doneListeners.delete(o),i.stopListeners.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===q.Running)return this;this.machine._init(),St.register(this.sessionId,this),this.initialized=!0,this.status=q.Running;var n=e===void 0?this.initialState:Re(this,function(){return Os(e)?r.machine.resolveState(e):r.machine.resolveState(te.from(e,r.machine.context))});return this.options.devTools&&this.attachDev(),this.scheduler.initialize(function(){r.update(n,Ee)}),this},t.prototype._stopChildren=function(){this.children.forEach(function(e){_(e.stop)&&e.stop()}),this.children.clear()},t.prototype._stop=function(){var e,r,n,i,s,o,a,u,c,l;try{for(var v=R(this.listeners),h=v.next();!h.done;h=v.next()){var f=h.value;this.listeners.delete(f)}}catch(x){e={error:x}}finally{try{h&&!h.done&&(r=v.return)&&r.call(v)}finally{if(e)throw e.error}}try{for(var d=R(this.stopListeners),p=d.next();!p.done;p=d.next()){var f=p.value;f(),this.stopListeners.delete(f)}}catch(x){n={error:x}}finally{try{p&&!p.done&&(i=d.return)&&i.call(d)}finally{if(n)throw n.error}}try{for(var g=R(this.contextListeners),w=g.next();!w.done;w=g.next()){var f=w.value;this.contextListeners.delete(f)}}catch(x){s={error:x}}finally{try{w&&!w.done&&(o=g.return)&&o.call(g)}finally{if(s)throw s.error}}try{for(var S=R(this.doneListeners),T=S.next();!T.done;T=S.next()){var f=T.value;this.doneListeners.delete(f)}}catch(x){a={error:x}}finally{try{T&&!T.done&&(u=S.return)&&u.call(S)}finally{if(a)throw a.error}}if(!this.initialized)return this;this.initialized=!1,this.status=q.Stopped,this._initialState=void 0;try{for(var P=R(Object.keys(this.delayedEventsMap)),k=P.next();!k.done;k=P.next()){var j=k.value;this.clock.clearTimeout(this.delayedEventsMap[j])}}catch(x){c={error:x}}finally{try{k&&!k.done&&(l=P.return)&&l.call(P)}finally{if(c)throw c.error}}this.scheduler.clear(),this.scheduler=new dn({deferEvents:this.options.deferEvents})},t.prototype.stop=function(){var e=this,r=this.scheduler;return this._stop(),r.schedule(function(){var n=z({type:"xstate.stop"}),i=Re(e,function(){var s=$(L([],A(e.state.configuration),!1).sort(function(l,v){return v.order-l.order}).map(function(l){return ie(l.onExit,e.machine.options.actions)})),o=A(Be(e.machine,e.state,e.state.context,n,[s],e.machine.config.predictableActionArguments?e._exec:void 0,e.machine.config.predictableActionArguments||e.machine.config.preserveActionOrder),2),a=o[0],u=o[1],c=new te({value:e.state.value,context:u,_event:n,_sessionid:e.sessionId,historyValue:void 0,history:e.state,actions:a.filter(function(l){return l.type!==ge&&(l.type!==ye||!!l.to&&l.to!==ee.Internal)}),activities:{},events:[],configuration:[],transitions:[],children:{},done:e.state.done,tags:e.state.tags,machine:e.machine});return c.changed=!0,c});e.update(i,n),e._stopChildren(),St.free(e.sessionId)}),this},t.prototype.batch=function(e){var r=this;if(this.status===q.NotStarted&&this.options.deferEvents)F||B(!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.
|
|
17
|
+
Event: `).concat(JSON.stringify(event)));else if(this.status!==q.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.'));if(e.length){var n=!!this.machine.config.predictableActionArguments&&this._exec;this.scheduler.schedule(function(){var i,s,o=r.state,a=!1,u=[],c=function(f){var d=z(f);r.forward(d),o=Re(r,function(){return r.machine.transition(o,d,void 0,n||void 0)}),u.push.apply(u,L([],A(r.machine.config.predictableActionArguments?o.actions:o.actions.map(function(p){return Rs(p,o)})),!1)),a=a||!!o.changed};try{for(var l=R(e),v=l.next();!v.done;v=l.next()){var h=v.value;c(h)}}catch(f){i={error:f}}finally{try{v&&!v.done&&(s=l.return)&&s.call(l)}finally{if(i)throw i.error}}o.changed=a,o.actions=u,r.update(o,z(e[e.length-1]))})}},t.prototype.sender=function(e){return this.send.bind(this,e)},t.prototype._nextState=function(e,r){var n=this;r===void 0&&(r=!!this.machine.config.predictableActionArguments&&this._exec);var i=z(e);if(i.name.indexOf(Kt)===0&&!this.state.nextEvents.some(function(o){return o.indexOf(Kt)===0}))throw i.data.data;var s=Re(this,function(){return n.machine.transition(n.state,i,void 0,r||void 0)});return s},t.prototype.nextState=function(e){return this._nextState(e,!1)},t.prototype.forward=function(e){var r,n;try{for(var i=R(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(u){r={error:u}}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,!0):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),this._exec(e,r.context,r._event,n)},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),_(r.stop)&&r.stop())},t.prototype.spawn=function(e,r,n){if(this.status!==q.Running)return Zt(e,r);if(qr(e))return this.spawnPromise(Promise.resolve(e),r);if(_(e))return this.spawnCallback(e,r);if(ws(e))return this.spawnActor(e,r);if(es(e))return this.spawnObservable(e,r);if(ne(e))return this.spawnMachine(e,y(y({},n),{id:r}));if(Qi(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,y(y({},this.options),{parent:this,id:r.id||e.id})),s=y(y({},nr),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(z(a,{origin:i.id}))}).start(),o},t.prototype.spawnBehavior=function(e,r){var n=Ps(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(u){s||(o=u,i.removeChild(r),i.send(z($e(r,u),{origin:r})))},function(u){if(!s){i.removeChild(r);var c=Oe(r,u);try{i.send(z(c,{origin:r}))}catch(l){is(u,l,r),i.devTools&&i.devTools.send(c,i.state),i.machine.strict&&i.stop()}}});var a=(n={id:r,send:function(){},subscribe:function(u,c,l){var v=pt(u,c,l),h=!1;return e.then(function(f){h||(v.next(f),!h&&v.complete())},function(f){h||v.error(f)}),{unsubscribe:function(){return h=!0}}},stop:function(){s=!0},toJSON:function(){return{id:r}},getSnapshot:function(){return o}},n[de]=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,u,c=function(h){u=h,a.forEach(function(f){return f(h)}),!s&&i.send(z(h,{origin:r}))},l;try{l=e(c,function(h){o.add(h)})}catch(h){this.send(Oe(r,h))}if(qr(l))return this.spawnPromise(l,r);var v=(n={id:r,send:function(h){return o.forEach(function(f){return f(h)})},subscribe:function(h){var f=pt(h);return a.add(f.next),{unsubscribe:function(){a.delete(f.next)}}},stop:function(){s=!0,_(l)&&l()},toJSON:function(){return{id:r}},getSnapshot:function(){return u}},n[de]=function(){return this},n);return this.children.set(r,v),v},t.prototype.spawnObservable=function(e,r){var n,i=this,s,o=e.subscribe(function(u){s=u,i.send(z(u,{origin:r}))},function(u){i.removeChild(r),i.send(z(Oe(r,u),{origin:r}))},function(){i.removeChild(r),i.send(z($e(r),{origin:r}))}),a=(n={id:r,send:function(){},subscribe:function(u,c,l){return e.subscribe(u,c,l)},stop:function(){return o.unsubscribe()},getSnapshot:function(){return s},toJSON:function(){return{id:r}}},n[de]=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){F||B(!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[de]=function(){return this},n))},t.prototype.attachDev=function(){var e=rr();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(y(y({name:this.id,autoPause:!0,stateSanitizer:function(n){return{value:n.value,context:n.context,actions:n.actions}}},r),{features:y({jump:!1,skip:!1},r?r.features:void 0)}),this.machine),this.devTools.init(this.state)}Ns(this)}},t.prototype.toJSON=function(){return{id:this.id}},t.prototype[de]=function(){return this},t.prototype.getSnapshot=function(){return this.status===q.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=ke,t}(),Cs=function(t){return I(t)?y(y({},nr),{name:t}):y(y(y({},nr),{name:rs()}),t)};function _s(t,e){var r=Cs(e);return gs(function(n){if(!F){var i=ne(t)||_(t);B(!!n||i,'Attempted to spawn an Actor (ID: "'.concat(ne(t)?t.id:"undefined",'") outside of a service. This will have no effect.'))}return n?n.spawn(t,r.name,r):Zt(t,r.name)})}function ke(t,e){var r=new Us(t,e);return r}function Ds(t){if(typeof t=="string"){var e={type:t};return e.toString=function(){return t},e}return t}function Tt(t){return y(y({type:ct},t),{toJSON:function(){t.onDone,t.onError;var e=zt(t,["onDone","onError"]);return y(y({},e),{type:ct,src:Ds(t.src)})}})}var xe="",ir="#",He="*",Ie={},Ne=function(t){return t[0]===ir},Ls=function(){return{actions:{},guards:{},services:{},activities:{},delays:{}}},Ms=function(t,e,r){var n=r.slice(0,-1).some(function(s){return!("cond"in s)&&!("in"in s)&&(I(s.target)||ne(s.target))}),i=e===xe?"the transient event":"event '".concat(e,"'");B(!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.")},js=function(){function t(e,r,n,i){n===void 0&&(n="context"in e?e.context:void 0);var s=this,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(Ls(),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:Mr),this.id=this.config.id||L([this.machine.key],A(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,F||B(!("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?je(this.config.states,function(c,l){var v,h=new t(c,{},void 0,{parent:s,key:l});return Object.assign(s.idMap,y((v={},v[h.id]=h,v),h.idMap)),h}):Ie;var a=0;function u(c){var l,v;c.order=a++;try{for(var h=R(on(c)),f=h.next();!f.done;f=h.next()){var d=f.value;u(d)}}catch(p){l={error:p}}finally{try{f&&!f.done&&(v=h.return)&&v.call(h)}finally{if(l)throw l.error}}}u(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(c){var l=c.event;return l===xe}):xe in this.config.on:!1),this.strict=!!this.config.strict,this.onEntry=W(this.config.entry||this.config.onEntry).map(function(c){return Ae(c)}),this.onExit=W(this.config.exit||this.config.onExit).map(function(c){return Ae(c)}),this.meta=this.config.meta,this.doneData=this.type==="final"?this.config.data:void 0,this.invoke=W(this.config.invoke).map(function(c,l){var v,h;if(ne(c)){var f=vt(s.id,l);return s.machine.options.services=y((v={},v[f]=c,v),s.machine.options.services),Tt({src:f,id:f})}else if(I(c.src)){var f=c.id||vt(s.id,l);return Tt(y(y({},c),{id:f,src:c.src}))}else if(ne(c.src)||_(c.src)){var f=c.id||vt(s.id,l);return s.machine.options.services=y((h={},h[f]=c.src,h),s.machine.options.services),Tt(y(y({id:f},c),{src:f}))}else{var d=c.src;return Tt(y(y({id:vt(s.id,l)},c),{src:d}))}}),this.activities=W(this.config.activities).concat(this.invoke).map(function(c){return gt(c)}),this.transition=this.transition.bind(this),this.tags=W(this.config.tags)}return t.prototype._init=function(){this.__cache.transitions||an(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,u=n.delays;return new t(this.config,{actions:y(y({},i),e.actions),activities:y(y({},s),e.activities),guards:y(y({},o),e.guards),services:y(y({},a),e.services),delays:y(y({},u),e.delays)},r??this.context)},t.prototype.withContext=function(e){return new t(this.config,this.options,e)},Object.defineProperty(t.prototype,"context",{get:function(){return _(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:je(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===xe,n=this.transitions.filter(function(i){var s=i.eventType===e;return r?s:s||i.eventType===He});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=_(s)?"".concat(e.id,":delay[").concat(o,"]"):s,u=nn(a,e.id);return e.onEntry.push(fe(u,{delay:s})),e.onExit.push(Xr(u)),u},i=Te(r)?r.map(function(s,o){var a=n(s.delay,o);return y(y({},s),{event:a})}):$(Object.keys(r).map(function(s,o){var a=r[s],u=I(a)?{target:a}:a,c=isNaN(+s)?s:+s,l=n(c,o);return W(u).map(function(v){return y(y({},v),{event:l,delay:c})})}));return i.map(function(s){var o=s.delay;return y(y({},e.formatTransition(s)),{delay:o})})},t.prototype.getStateNodes=function(e){var r,n=this;if(!e)return[];var i=e instanceof te?e.value:Me(e,this.delimiter);if(I(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,L([],A($(o.map(function(u){return n.getStateNode(u).getStateNodes(i[u])}))),!1)),a},t.prototype.handles=function(e){var r=Fr(e);return this.events.includes(r)},t.prototype.resolveState=function(e){var r=e instanceof te?e:te.create(e),n=Array.from(Ve([],this.getStateNodes(r.value)));return new te(y(y({},r),{value:this.resolve(r.value),configuration:n,done:wt(n,this),tags:un(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=R(Object.keys(e)),u=a.next();!u.done;u=a.next()){var c=u.value,l=e[c];if(l){var v=this.getStateNode(c),h=v._transition(l,r,n);h&&(o[c]=h)}}}catch(S){i={error:S}}finally{try{u&&!u.done&&(s=a.return)&&s.call(a)}finally{if(i)throw i.error}}var f=Object.keys(o).map(function(S){return o[S]}),d=$(f.map(function(S){return S.transitions})),p=f.some(function(S){return S.transitions.length>0});if(!p)return this.next(r,n);var g=$(f.map(function(S){return S.entrySet})),w=$(Object.keys(o).map(function(S){return o[S].configuration}));return{transitions:d,entrySet:g,exitSet:$(f.map(function(S){return S.exitSet})),configuration:w,source:r,actions:$(Object.keys(o).map(function(S){return o[S].actions}))}},t.prototype._transition=function(e,r,n){return I(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,z(r))},t.prototype.next=function(e,r){var n,i,s=this,o=r.name,a=[],u=[],c;try{for(var l=R(this.getCandidates(o)),v=l.next();!v.done;v=l.next()){var h=v.value,f=h.cond,d=h.in,p=e.context,g=d?I(d)&&Ne(d)?e.matches(Me(this.getStateNodeById(d).path,this.delimiter)):Wt(Me(d,this.delimiter),Ji(this.path.slice(0,-2))(e.value)):!0,w=!1;try{w=!f||Kr(this.machine,f,p,r,e)}catch(k){throw new Error("Unable to evaluate guard '".concat(f.name||f.type,"' in transition for event '").concat(o,"' in state node '").concat(this.id,`':
|
|
18
|
+
`).concat(k.message))}if(w&&g){h.target!==void 0&&(u=h.target),a.push.apply(a,L([],A(h.actions),!1)),c=h;break}}}catch(k){n={error:k}}finally{try{v&&!v.done&&(i=l.return)&&i.call(l)}finally{if(n)throw n.error}}if(c){if(!u.length)return{transitions:[c],entrySet:[],exitSet:[],configuration:e.value?[this]:[],source:e,actions:a};var S=$(u.map(function(k){return s.getRelativeStateNodes(k,e.historyValue)})),T=!!c.internal,P=[];return T||u.forEach(function(k){P.push.apply(P,L([],A(s.getExternalReentryNodes(k)),!1))}),{transitions:[c],entrySet:P,exitSet:T?[]:[this],configuration:S,source:e,actions:a}}},t.prototype.getExternalReentryNodes=function(e){for(var r=[],n=A(e.order>this.order?[e,this]:[this,e],2),i=n[0],s=n[1];i&&i!==s;)r.push(i),i=i.parent;return i!==s?[]:(r.push(s),r)},t.prototype.getActions=function(e,r,n,i,s,o,a){var u,c,l,v,h=this,f=Ve([],o?this.getStateNodes(o.value):[this]);try{for(var d=R(e),p=d.next();!p.done;p=d.next()){var g=p.value;(!ze(f,g)||ze(n.entrySet,g.parent))&&n.entrySet.push(g)}}catch(b){u={error:b}}finally{try{p&&!p.done&&(c=d.return)&&c.call(d)}finally{if(u)throw u.error}}try{for(var w=R(f),S=w.next();!S.done;S=w.next()){var g=S.value;(!ze(e,g)||ze(n.exitSet,g.parent))&&n.exitSet.push(g)}}catch(b){l={error:b}}finally{try{S&&!S.done&&(v=w.return)&&v.call(w)}finally{if(l)throw l.error}}var T=$(n.entrySet.map(function(b){var M=[];if(b.type!=="final")return M;var J=b.parent;if(!J.parent)return M;M.push(Fe(b.id,b.doneData),Fe(J.id,b.doneData?ht(b.doneData,i,s):void 0));var X=J.parent;return X.type==="parallel"&&qe(X).every(function(le){return wt(n.configuration,le)})&&M.push(Fe(X.id)),M}));n.exitSet.sort(function(b,M){return M.order-b.order}),n.entrySet.sort(function(b,M){return b.order-M.order});var P=new Set(n.entrySet),k=new Set(n.exitSet),j=Array.from(P).map(function(b){var M=b.onEntry,J=b.activities.map(function(X){return Zr(X)});return ie(a?L(L([],A(M),!1),A(J),!1):L(L([],A(J),!1),A(M),!1),h.machine.options.actions)}).concat([T.map(Jr)]),x=Array.from(k).map(function(b){return ie(L(L([],A(b.onExit),!1),A(b.activities.map(function(M){return en(M)})),!1),h.machine.options.actions)}),U=x.concat([ie(n.actions,this.machine.options.actions)]).concat(j);if(r){var D=ie($(L([],A(e),!1).sort(function(b,M){return M.order-b.order}).map(function(b){return b.onExit})),this.machine.options.actions).filter(function(b){return b.type!==ge&&(b.type!==ye||!!b.to&&b.to!==ee.Internal)});return U.concat([D])}return U},t.prototype.transition=function(e,r,n,i){e===void 0&&(e=this.initialState);var s=z(r),o;if(e instanceof te)o=n===void 0?e:this.resolveState(te.from(e,n));else{var a=I(e)?this.resolve(dt(this.getResolvedPath(e))):this.resolve(e),u=n??this.machine.context;o=this.resolveState(te.from(a,u))}if(!F&&s.name===He)throw new Error("An event cannot have the wildcard type ('".concat(He,"')"));if(this.strict&&!this.events.includes(s.name)&&!Yi(s.name))throw new Error("Machine '".concat(this.id,"' does not accept event '").concat(s.name,"'"));var c=this._transition(o.value,o,s)||{transitions:[],configuration:[],entrySet:[],exitSet:[],source:o,actions:[]},l=Ve([],this.getStateNodes(o.value)),v=c.configuration.length?Ve(l,c.configuration):l;return c.configuration=L([],A(v),!1),this.resolveTransition(c,o,o.context,i,s)},t.prototype.resolveRaisedTransition=function(e,r,n,i){var s,o=e.actions;return e=this.transition(e,r,void 0,i),e._event=n,e.event=n.data,(s=e.actions).unshift.apply(s,L([],A(o),!1)),e},t.prototype.resolveTransition=function(e,r,n,i,s){var o,a,u,c,l=this;s===void 0&&(s=Ee);var v=e.configuration,h=!r||e.transitions.length>0,f=h?e.configuration:r?r.configuration:[],d=wt(f,this),p=h?Ts(this.machine,v):void 0,g=r?r.historyValue?r.historyValue:e.source?this.machine.historyValue(r.value):void 0:void 0,w=this.getActions(new Set(f),d,e,n,s,r,i),S=r?y({},r.activities):{};try{for(var T=R(w),P=T.next();!P.done;P=T.next()){var k=P.value;try{for(var j=(u=void 0,R(k)),x=j.next();!x.done;x=j.next()){var U=x.value;U.type===it?S[U.activity.id||U.activity.type]=U:U.type===st&&(S[U.activity.id||U.activity.type]=!1)}}catch(G){u={error:G}}finally{try{x&&!x.done&&(c=j.return)&&c.call(j)}finally{if(u)throw u.error}}}}catch(G){o={error:G}}finally{try{P&&!P.done&&(a=T.return)&&a.call(T)}finally{if(o)throw o.error}}var D=A(Be(this,r,n,s,w,i,this.machine.config.predictableActionArguments||this.machine.config.preserveActionOrder),2),b=D[0],M=D[1],J=A(Xi(b,function(G){return G.type===ge||G.type===ye&&G.to===ee.Internal}),2),X=J[0],le=J[1],Ce=b.filter(function(G){var De;return G.type===it&&((De=G.activity)===null||De===void 0?void 0:De.type)===ct}),da=Ce.reduce(function(G,De){return G[De.activity.id]=ys(De.activity,l.machine,M,s),G},r?y({},r.children):{}),qt=new te({value:p||r.value,context:M,_event:s,_sessionid:r?r._sessionid:null,historyValue:p?g?Zi(g,p):void 0:r?r.historyValue:void 0,history:!p||e.source?r:void 0,actions:p?le:[],activities:p?S:r?r.activities:{},events:[],configuration:f,transitions:e.transitions,children:da,done:d,tags:un(f),machine:this}),ji=n!==M;qt.changed=s.name===ut||ji;var _e=qt.history;_e&&delete _e.history;var Fi=!d&&(this._transient||v.some(function(G){return G._transient}));if(!h&&(!Fi||s.name===xe))return qt;var Z=qt;if(!d)for(Fi&&(Z=this.resolveRaisedTransition(Z,{type:Cr},s,i));X.length;){var fa=X.shift();Z=this.resolveRaisedTransition(Z,fa._event,s,i)}var ha=Z.changed||(_e?!!Z.actions.length||ji||typeof _e.value!=typeof Z.value||!ln(Z.value,_e.value):void 0);return Z.changed=ha,Z.history=_e,Z},t.prototype.getStateNode=function(e){if(Ne(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=Ne(e)?e.slice(ir.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"&&Ne(e))try{return this.getStateNodeById(e.slice(1))}catch{}for(var r=Yt(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||Ie;switch(this.type){case"parallel":return je(this.initialStateValue,function(s,o){return s?n.getStateNode(o).resolve(e[o]||s):Ie});case"compound":if(I(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?je(e,function(s,o){return s?n.getStateNode(o).resolve(s):Ie}):this.initialStateValue||{};default:return e||Ie}},t.prototype.getResolvedPath=function(e){if(Ne(e)){var r=this.machine.idMap[e.slice(ir.length)];if(!r)throw new Error("Unable to find state node '".concat(e,"'"));return r.path}return Yt(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=$r(this.states,function(n){return n.initialStateValue||Ie},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=Et(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:L([],A(n),!1),exitSet:[],transitions:[],source:void 0,actions:[]},void 0,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;I(r.target)?e=Ne(r.target)?dt(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(Et(this))return[this];if(this.type==="compound"&&!this.initial)return F||B(!1,"Compound state node '".concat(this.id,"' has no initial state.")),[this];var r=ft(this.initialStateValue);return $(r.map(function(n){return e.getFromRelativePath(n)}))},enumerable:!1,configurable:!0}),t.prototype.getFromRelativePath=function(e){if(!e.length)return[this];var r=A(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:$r(this.states,function(r,n){if(!e)return r.historyValue();var i=I(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?$(ft(i).map(function(o){return n.getFromRelativePath(o)})):n.initialStateNodes}var s=Wi(n.path,"states")(e).current;return I(s)?[n.getStateNode(s)]:$(ft(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=$(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=R(Object.keys(s)),u=a.next();!u.done;u=a.next()){var c=u.value,l=s[c];if(l.states)try{for(var v=(n=void 0,R(l.events)),h=v.next();!h.done;h=v.next()){var f=h.value;o.add("".concat(f))}}catch(d){n={error:d}}finally{try{h&&!h.done&&(i=v.return)&&i.call(v)}finally{if(n)throw n.error}}}}catch(d){e={error:d}}finally{try{u&&!u.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(!I(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,`':
|
|
19
|
+
`).concat(a.message))}else return r.getStateNodeByPath(s)})},t.prototype.formatTransition=function(e){var r=this,n=ns(e.target),i="internal"in e?e.internal:n?n.some(function(u){return I(u)&&u[0]===r.delimiter}):!0,s=this.machine.options.guards,o=this.resolveTarget(n),a=y(y({},e),{actions:ie(W(e.actions)),cond:Hr(e.cond,s),target:o,source:this,internal:i,eventType:e.event,toJSON:function(){return y(y({},a),{target:a.target?a.target.map(function(u){return"#".concat(u.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=He,a=s[o],u=a===void 0?[]:a,c=zt(s,[typeof o=="symbol"?o:o+""]);i=$(Object.keys(c).map(function(S){!F&&S===xe&&B(!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 T=be(S,c[S]);return F||Ms(n,S,T),T}).concat(be(He,u)))}var l=this.config.always?be("",this.config.always):[],v=this.config.onDone?be(String(Fe(this.id)),this.config.onDone):[];F||B(!(this.config.onDone&&!this.parent),'Root nodes cannot have an ".onDone" transition. Please check the config of "'.concat(this.id,'".'));var h=$(this.invoke.map(function(S){var T=[];return S.onDone&&T.push.apply(T,L([],A(be(String($e(S.id)),S.onDone)),!1)),S.onError&&T.push.apply(T,L([],A(be(String(Oe(S.id)),S.onError)),!1)),T})),f=this.after,d=$(L(L(L(L([],A(v),!1),A(h),!1),A(i),!1),A(l),!1).map(function(S){return W(S).map(function(T){return n.formatTransition(T)})}));try{for(var p=R(f),g=p.next();!g.done;g=p.next()){var w=g.value;d.push(w)}}catch(S){e={error:S}}finally{try{g&&!g.done&&(r=p.return)&&r.call(p)}finally{if(e)throw e.error}}return d},t}(),fn=!1;function he(t,e){return!F&&!t.predictableActionArguments&&!fn&&(fn=!0,console.warn("It is highly recommended to set `predictableActionArguments` to `true` when using `createMachine`. https://xstate.js.org/docs/guides/actions.html")),new js(t,e)}var O=rn,V=fe;/*! js-cookie v3.0.1 | MIT */function bt(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 Fs={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 sr(t,e){function r(i,s,o){if(!(typeof document>"u")){o=bt({},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 u in o)o[u]&&(a+="; "+u,o[u]!==!0&&(a+="="+o[u].split(";")[0]));return document.cookie=i+"="+t.write(s,i)+a}}function n(i){if(!(typeof document>"u"||arguments.length&&!i)){for(var s=document.cookie?document.cookie.split("; "):[],o={},a=0;a<s.length;a++){var u=s[a].split("="),c=u.slice(1).join("=");try{var l=decodeURIComponent(u[0]);if(o[l]=t.read(c,l),i===l)break}catch{}}return i?o[i]:o}}return Object.create({set:r,get:n,remove:function(i,s){r(i,"",bt({},s,{expires:-1}))},withAttributes:function(i){return sr(this.converter,bt({},this.attributes,i))},withConverter:function(i){return sr(bt({},this.converter,i),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var or=sr(Fs,{path:"/"});function hn(t,e){return function(){return t.apply(e,arguments)}}const{toString:pn}=Object.prototype,{getPrototypeOf:ar}=Object,cr=(t=>e=>{const r=pn.call(e);return t[r]||(t[r]=r.slice(8,-1).toLowerCase())})(Object.create(null)),se=t=>(t=t.toLowerCase(),e=>cr(e)===t),At=t=>e=>typeof e===t,{isArray:Pe}=Array,Ke=At("undefined");function $s(t){return t!==null&&!Ke(t)&&t.constructor!==null&&!Ke(t.constructor)&&we(t.constructor.isBuffer)&&t.constructor.isBuffer(t)}const vn=se("ArrayBuffer");function Bs(t){let e;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?e=ArrayBuffer.isView(t):e=t&&t.buffer&&vn(t.buffer),e}const qs=At("string"),we=At("function"),mn=At("number"),ur=t=>t!==null&&typeof t=="object",Vs=t=>t===!0||t===!1,Ot=t=>{if(cr(t)!=="object")return!1;const e=ar(t);return(e===null||e===Object.prototype||Object.getPrototypeOf(e)===null)&&!(Symbol.toStringTag in t)&&!(Symbol.iterator in t)},zs=se("Date"),Hs=se("File"),Ks=se("Blob"),Gs=se("FileList"),Js=t=>ur(t)&&we(t.pipe),Ws=t=>{const e="[object FormData]";return t&&(typeof FormData=="function"&&t instanceof FormData||pn.call(t)===e||we(t.toString)&&t.toString()===e)},Ys=se("URLSearchParams"),Qs=t=>t.trim?t.trim():t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"");function Ge(t,e,{allOwnKeys:r=!1}={}){if(t===null||typeof t>"u")return;let n,i;if(typeof t!="object"&&(t=[t]),Pe(t))for(n=0,i=t.length;n<i;n++)e.call(null,t[n],n,t);else{const s=r?Object.getOwnPropertyNames(t):Object.keys(t),o=s.length;let a;for(n=0;n<o;n++)a=s[n],e.call(null,t[a],a,t)}}function gn(t,e){e=e.toLowerCase();const r=Object.keys(t);let n=r.length,i;for(;n-- >0;)if(i=r[n],e===i.toLowerCase())return i;return null}const yn=typeof self>"u"?typeof global>"u"?globalThis:global:self,En=t=>!Ke(t)&&t!==yn;function lr(){const{caseless:t}=En(this)&&this||{},e={},r=(n,i)=>{const s=t&&gn(e,i)||i;Ot(e[s])&&Ot(n)?e[s]=lr(e[s],n):Ot(n)?e[s]=lr({},n):Pe(n)?e[s]=n.slice():e[s]=n};for(let n=0,i=arguments.length;n<i;n++)arguments[n]&&Ge(arguments[n],r);return e}const Xs=(t,e,r,{allOwnKeys:n}={})=>(Ge(e,(i,s)=>{r&&we(i)?t[s]=hn(i,r):t[s]=i},{allOwnKeys:n}),t),Zs=t=>(t.charCodeAt(0)===65279&&(t=t.slice(1)),t),eo=(t,e,r,n)=>{t.prototype=Object.create(e.prototype,n),t.prototype.constructor=t,Object.defineProperty(t,"super",{value:e.prototype}),r&&Object.assign(t.prototype,r)},to=(t,e,r,n)=>{let i,s,o;const a={};if(e=e||{},t==null)return e;do{for(i=Object.getOwnPropertyNames(t),s=i.length;s-- >0;)o=i[s],(!n||n(o,t,e))&&!a[o]&&(e[o]=t[o],a[o]=!0);t=r!==!1&&ar(t)}while(t&&(!r||r(t,e))&&t!==Object.prototype);return e},ro=(t,e,r)=>{t=String(t),(r===void 0||r>t.length)&&(r=t.length),r-=e.length;const n=t.indexOf(e,r);return n!==-1&&n===r},no=t=>{if(!t)return null;if(Pe(t))return t;let e=t.length;if(!mn(e))return null;const r=new Array(e);for(;e-- >0;)r[e]=t[e];return r},io=(t=>e=>t&&e instanceof t)(typeof Uint8Array<"u"&&ar(Uint8Array)),so=(t,e)=>{const n=(t&&t[Symbol.iterator]).call(t);let i;for(;(i=n.next())&&!i.done;){const s=i.value;e.call(t,s[0],s[1])}},oo=(t,e)=>{let r;const n=[];for(;(r=t.exec(e))!==null;)n.push(r);return n},ao=se("HTMLFormElement"),co=t=>t.toLowerCase().replace(/[_-\s]([a-z\d])(\w*)/g,function(r,n,i){return n.toUpperCase()+i}),wn=(({hasOwnProperty:t})=>(e,r)=>t.call(e,r))(Object.prototype),uo=se("RegExp"),Sn=(t,e)=>{const r=Object.getOwnPropertyDescriptors(t),n={};Ge(r,(i,s)=>{e(i,s,t)!==!1&&(n[s]=i)}),Object.defineProperties(t,n)},m={isArray:Pe,isArrayBuffer:vn,isBuffer:$s,isFormData:Ws,isArrayBufferView:Bs,isString:qs,isNumber:mn,isBoolean:Vs,isObject:ur,isPlainObject:Ot,isUndefined:Ke,isDate:zs,isFile:Hs,isBlob:Ks,isRegExp:uo,isFunction:we,isStream:Js,isURLSearchParams:Ys,isTypedArray:io,isFileList:Gs,forEach:Ge,merge:lr,extend:Xs,trim:Qs,stripBOM:Zs,inherits:eo,toFlatObject:to,kindOf:cr,kindOfTest:se,endsWith:ro,toArray:no,forEachEntry:so,matchAll:oo,isHTMLForm:ao,hasOwnProperty:wn,hasOwnProp:wn,reduceDescriptors:Sn,freezeMethods:t=>{Sn(t,(e,r)=>{if(we(t)&&["arguments","caller","callee"].indexOf(r)!==-1)return!1;const n=t[r];if(we(n)){if(e.enumerable=!1,"writable"in e){e.writable=!1;return}e.set||(e.set=()=>{throw Error("Can not rewrite read-only method '"+r+"'")})}})},toObjectSet:(t,e)=>{const r={},n=i=>{i.forEach(s=>{r[s]=!0})};return Pe(t)?n(t):n(String(t).split(e)),r},toCamelCase:co,noop:()=>{},toFiniteNumber:(t,e)=>(t=+t,Number.isFinite(t)?t:e),findKey:gn,global:yn,isContextDefined:En,toJSONObject:t=>{const e=new Array(10),r=(n,i)=>{if(ur(n)){if(e.indexOf(n)>=0)return;if(!("toJSON"in n)){e[i]=n;const s=Pe(n)?[]:{};return Ge(n,(o,a)=>{const u=r(o,i+1);!Ke(u)&&(s[a]=u)}),e[i]=void 0,s}}return n};return r(t,0)}};function N(t,e,r,n,i){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack,this.message=t,this.name="AxiosError",e&&(this.code=e),r&&(this.config=r),n&&(this.request=n),i&&(this.response=i)}m.inherits(N,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:m.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});const Tn=N.prototype,bn={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach(t=>{bn[t]={value:t}}),Object.defineProperties(N,bn),Object.defineProperty(Tn,"isAxiosError",{value:!0}),N.from=(t,e,r,n,i,s)=>{const o=Object.create(Tn);return m.toFlatObject(t,o,function(u){return u!==Error.prototype},a=>a!=="isAxiosError"),N.call(o,t.message,e,r,n,i),o.cause=t,o.name=t.name,s&&Object.assign(o,s),o};var An=typeof self=="object"?self.FormData:window.FormData;function dr(t){return m.isPlainObject(t)||m.isArray(t)}function On(t){return m.endsWith(t,"[]")?t.slice(0,-2):t}function Rn(t,e,r){return t?t.concat(e).map(function(i,s){return i=On(i),!r&&s?"["+i+"]":i}).join(r?".":""):e}function lo(t){return m.isArray(t)&&!t.some(dr)}const fo=m.toFlatObject(m,{},null,function(e){return/^is[A-Z]/.test(e)});function ho(t){return t&&m.isFunction(t.append)&&t[Symbol.toStringTag]==="FormData"&&t[Symbol.iterator]}function Rt(t,e,r){if(!m.isObject(t))throw new TypeError("target must be an object");e=e||new(An||FormData),r=m.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,function(p,g){return!m.isUndefined(g[p])});const n=r.metaTokens,i=r.visitor||l,s=r.dots,o=r.indexes,u=(r.Blob||typeof Blob<"u"&&Blob)&&ho(e);if(!m.isFunction(i))throw new TypeError("visitor must be a function");function c(d){if(d===null)return"";if(m.isDate(d))return d.toISOString();if(!u&&m.isBlob(d))throw new N("Blob is not supported. Use a Buffer instead.");return m.isArrayBuffer(d)||m.isTypedArray(d)?u&&typeof Blob=="function"?new Blob([d]):Buffer.from(d):d}function l(d,p,g){let w=d;if(d&&!g&&typeof d=="object"){if(m.endsWith(p,"{}"))p=n?p:p.slice(0,-2),d=JSON.stringify(d);else if(m.isArray(d)&&lo(d)||m.isFileList(d)||m.endsWith(p,"[]")&&(w=m.toArray(d)))return p=On(p),w.forEach(function(T,P){!(m.isUndefined(T)||T===null)&&e.append(o===!0?Rn([p],P,s):o===null?p:p+"[]",c(T))}),!1}return dr(d)?!0:(e.append(Rn(g,p,s),c(d)),!1)}const v=[],h=Object.assign(fo,{defaultVisitor:l,convertValue:c,isVisitable:dr});function f(d,p){if(!m.isUndefined(d)){if(v.indexOf(d)!==-1)throw Error("Circular reference detected in "+p.join("."));v.push(d),m.forEach(d,function(w,S){(!(m.isUndefined(w)||w===null)&&i.call(e,w,m.isString(S)?S.trim():S,p,h))===!0&&f(w,p?p.concat(S):[S])}),v.pop()}}if(!m.isObject(t))throw new TypeError("data must be an object");return f(t),e}function kn(t){const e={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(t).replace(/[!'()~]|%20|%00/g,function(n){return e[n]})}function fr(t,e){this._pairs=[],t&&Rt(t,this,e)}const xn=fr.prototype;xn.append=function(e,r){this._pairs.push([e,r])},xn.toString=function(e){const r=e?function(n){return e.call(this,n,kn)}:kn;return this._pairs.map(function(i){return r(i[0])+"="+r(i[1])},"").join("&")};function po(t){return encodeURIComponent(t).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function In(t,e,r){if(!e)return t;const n=r&&r.encode||po,i=r&&r.serialize;let s;if(i?s=i(e,r):s=m.isURLSearchParams(e)?e.toString():new fr(e,r).toString(n),s){const o=t.indexOf("#");o!==-1&&(t=t.slice(0,o)),t+=(t.indexOf("?")===-1?"?":"&")+s}return t}class vo{constructor(){this.handlers=[]}use(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}eject(e){this.handlers[e]&&(this.handlers[e]=null)}clear(){this.handlers&&(this.handlers=[])}forEach(e){m.forEach(this.handlers,function(n){n!==null&&e(n)})}}const Nn=vo,Pn={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},mo=typeof URLSearchParams<"u"?URLSearchParams:fr,go=FormData,yo=(()=>{let t;return typeof navigator<"u"&&((t=navigator.product)==="ReactNative"||t==="NativeScript"||t==="NS")?!1:typeof window<"u"&&typeof document<"u"})(),oe={isBrowser:!0,classes:{URLSearchParams:mo,FormData:go,Blob},isStandardBrowserEnv:yo,protocols:["http","https","file","blob","url","data"]};function Eo(t,e){return Rt(t,new oe.classes.URLSearchParams,Object.assign({visitor:function(r,n,i,s){return oe.isNode&&m.isBuffer(r)?(this.append(n,r.toString("base64")),!1):s.defaultVisitor.apply(this,arguments)}},e))}function wo(t){return m.matchAll(/\w+|\[(\w*)]/g,t).map(e=>e[0]==="[]"?"":e[1]||e[0])}function So(t){const e={},r=Object.keys(t);let n;const i=r.length;let s;for(n=0;n<i;n++)s=r[n],e[s]=t[s];return e}function Un(t){function e(r,n,i,s){let o=r[s++];const a=Number.isFinite(+o),u=s>=r.length;return o=!o&&m.isArray(i)?i.length:o,u?(m.hasOwnProp(i,o)?i[o]=[i[o],n]:i[o]=n,!a):((!i[o]||!m.isObject(i[o]))&&(i[o]=[]),e(r,n,i[o],s)&&m.isArray(i[o])&&(i[o]=So(i[o])),!a)}if(m.isFormData(t)&&m.isFunction(t.entries)){const r={};return m.forEachEntry(t,(n,i)=>{e(wo(n),i,r,0)}),r}return null}const To={"Content-Type":void 0};function bo(t,e,r){if(m.isString(t))try{return(e||JSON.parse)(t),m.trim(t)}catch(n){if(n.name!=="SyntaxError")throw n}return(r||JSON.stringify)(t)}const kt={transitional:Pn,adapter:["xhr","http"],transformRequest:[function(e,r){const n=r.getContentType()||"",i=n.indexOf("application/json")>-1,s=m.isObject(e);if(s&&m.isHTMLForm(e)&&(e=new FormData(e)),m.isFormData(e))return i&&i?JSON.stringify(Un(e)):e;if(m.isArrayBuffer(e)||m.isBuffer(e)||m.isStream(e)||m.isFile(e)||m.isBlob(e))return e;if(m.isArrayBufferView(e))return e.buffer;if(m.isURLSearchParams(e))return r.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();let a;if(s){if(n.indexOf("application/x-www-form-urlencoded")>-1)return Eo(e,this.formSerializer).toString();if((a=m.isFileList(e))||n.indexOf("multipart/form-data")>-1){const u=this.env&&this.env.FormData;return Rt(a?{"files[]":e}:e,u&&new u,this.formSerializer)}}return s||i?(r.setContentType("application/json",!1),bo(e)):e}],transformResponse:[function(e){const r=this.transitional||kt.transitional,n=r&&r.forcedJSONParsing,i=this.responseType==="json";if(e&&m.isString(e)&&(n&&!this.responseType||i)){const o=!(r&&r.silentJSONParsing)&&i;try{return JSON.parse(e)}catch(a){if(o)throw a.name==="SyntaxError"?N.from(a,N.ERR_BAD_RESPONSE,this,null,this.response):a}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:oe.classes.FormData,Blob:oe.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*"}}};m.forEach(["delete","get","head"],function(e){kt.headers[e]={}}),m.forEach(["post","put","patch"],function(e){kt.headers[e]=m.merge(To)});const hr=kt,Ao=m.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),Oo=t=>{const e={};let r,n,i;return t&&t.split(`
|
|
20
|
+
`).forEach(function(o){i=o.indexOf(":"),r=o.substring(0,i).trim().toLowerCase(),n=o.substring(i+1).trim(),!(!r||e[r]&&Ao[r])&&(r==="set-cookie"?e[r]?e[r].push(n):e[r]=[n]:e[r]=e[r]?e[r]+", "+n:n)}),e},Cn=Symbol("internals");function Je(t){return t&&String(t).trim().toLowerCase()}function xt(t){return t===!1||t==null?t:m.isArray(t)?t.map(xt):String(t)}function Ro(t){const e=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;let n;for(;n=r.exec(t);)e[n[1]]=n[2];return e}function ko(t){return/^[-_a-zA-Z]+$/.test(t.trim())}function _n(t,e,r,n){if(m.isFunction(n))return n.call(this,e,r);if(m.isString(e)){if(m.isString(n))return e.indexOf(n)!==-1;if(m.isRegExp(n))return n.test(e)}}function xo(t){return t.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(e,r,n)=>r.toUpperCase()+n)}function Io(t,e){const r=m.toCamelCase(" "+e);["get","set","has"].forEach(n=>{Object.defineProperty(t,n+r,{value:function(i,s,o){return this[n].call(this,e,i,s,o)},configurable:!0})})}class It{constructor(e){e&&this.set(e)}set(e,r,n){const i=this;function s(a,u,c){const l=Je(u);if(!l)throw new Error("header name must be a non-empty string");const v=m.findKey(i,l);(!v||i[v]===void 0||c===!0||c===void 0&&i[v]!==!1)&&(i[v||u]=xt(a))}const o=(a,u)=>m.forEach(a,(c,l)=>s(c,l,u));return m.isPlainObject(e)||e instanceof this.constructor?o(e,r):m.isString(e)&&(e=e.trim())&&!ko(e)?o(Oo(e),r):e!=null&&s(r,e,n),this}get(e,r){if(e=Je(e),e){const n=m.findKey(this,e);if(n){const i=this[n];if(!r)return i;if(r===!0)return Ro(i);if(m.isFunction(r))return r.call(this,i,n);if(m.isRegExp(r))return r.exec(i);throw new TypeError("parser must be boolean|regexp|function")}}}has(e,r){if(e=Je(e),e){const n=m.findKey(this,e);return!!(n&&(!r||_n(this,this[n],n,r)))}return!1}delete(e,r){const n=this;let i=!1;function s(o){if(o=Je(o),o){const a=m.findKey(n,o);a&&(!r||_n(n,n[a],a,r))&&(delete n[a],i=!0)}}return m.isArray(e)?e.forEach(s):s(e),i}clear(){return Object.keys(this).forEach(this.delete.bind(this))}normalize(e){const r=this,n={};return m.forEach(this,(i,s)=>{const o=m.findKey(n,s);if(o){r[o]=xt(i),delete r[s];return}const a=e?xo(s):String(s).trim();a!==s&&delete r[s],r[a]=xt(i),n[a]=!0}),this}concat(...e){return this.constructor.concat(this,...e)}toJSON(e){const r=Object.create(null);return m.forEach(this,(n,i)=>{n!=null&&n!==!1&&(r[i]=e&&m.isArray(n)?n.join(", "):n)}),r}[Symbol.iterator](){return Object.entries(this.toJSON())[Symbol.iterator]()}toString(){return Object.entries(this.toJSON()).map(([e,r])=>e+": "+r).join(`
|
|
21
|
+
`)}get[Symbol.toStringTag](){return"AxiosHeaders"}static from(e){return e instanceof this?e:new this(e)}static concat(e,...r){const n=new this(e);return r.forEach(i=>n.set(i)),n}static accessor(e){const n=(this[Cn]=this[Cn]={accessors:{}}).accessors,i=this.prototype;function s(o){const a=Je(o);n[a]||(Io(i,o),n[a]=!0)}return m.isArray(e)?e.forEach(s):s(e),this}}It.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent"]),m.freezeMethods(It.prototype),m.freezeMethods(It);const ae=It;function pr(t,e){const r=this||hr,n=e||r,i=ae.from(n.headers);let s=n.data;return m.forEach(t,function(a){s=a.call(r,s,i.normalize(),e?e.status:void 0)}),i.normalize(),s}function Dn(t){return!!(t&&t.__CANCEL__)}function We(t,e,r){N.call(this,t??"canceled",N.ERR_CANCELED,e,r),this.name="CanceledError"}m.inherits(We,N,{__CANCEL__:!0});const No=null;function Po(t,e,r){const n=r.config.validateStatus;!r.status||!n||n(r.status)?t(r):e(new N("Request failed with status code "+r.status,[N.ERR_BAD_REQUEST,N.ERR_BAD_RESPONSE][Math.floor(r.status/100)-4],r.config,r.request,r))}const Uo=oe.isStandardBrowserEnv?function(){return{write:function(r,n,i,s,o,a){const u=[];u.push(r+"="+encodeURIComponent(n)),m.isNumber(i)&&u.push("expires="+new Date(i).toGMTString()),m.isString(s)&&u.push("path="+s),m.isString(o)&&u.push("domain="+o),a===!0&&u.push("secure"),document.cookie=u.join("; ")},read:function(r){const 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(){}}}();function Co(t){return/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)}function _o(t,e){return e?t.replace(/\/+$/,"")+"/"+e.replace(/^\/+/,""):t}function Ln(t,e){return t&&!Co(e)?_o(t,e):e}const Do=oe.isStandardBrowserEnv?function(){const e=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");let n;function i(s){let 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){const a=m.isString(o)?i(o):o;return a.protocol===n.protocol&&a.host===n.host}}():function(){return function(){return!0}}();function Lo(t){const e=/^([-+\w]{1,25})(:?\/\/|:)/.exec(t);return e&&e[1]||""}function Mo(t,e){t=t||10;const r=new Array(t),n=new Array(t);let i=0,s=0,o;return e=e!==void 0?e:1e3,function(u){const c=Date.now(),l=n[s];o||(o=c),r[i]=u,n[i]=c;let v=s,h=0;for(;v!==i;)h+=r[v++],v=v%t;if(i=(i+1)%t,i===s&&(s=(s+1)%t),c-o<e)return;const f=l&&c-l;return f?Math.round(h*1e3/f):void 0}}function Mn(t,e){let r=0;const n=Mo(50,250);return i=>{const s=i.loaded,o=i.lengthComputable?i.total:void 0,a=s-r,u=n(a),c=s<=o;r=s;const l={loaded:s,total:o,progress:o?s/o:void 0,bytes:a,rate:u||void 0,estimated:u&&o&&c?(o-s)/u:void 0,event:i};l[e?"download":"upload"]=!0,t(l)}}const Nt={http:No,xhr:typeof XMLHttpRequest<"u"&&function(t){return new Promise(function(r,n){let i=t.data;const s=ae.from(t.headers).normalize(),o=t.responseType;let a;function u(){t.cancelToken&&t.cancelToken.unsubscribe(a),t.signal&&t.signal.removeEventListener("abort",a)}m.isFormData(i)&&oe.isStandardBrowserEnv&&s.setContentType(!1);let c=new XMLHttpRequest;if(t.auth){const f=t.auth.username||"",d=t.auth.password?unescape(encodeURIComponent(t.auth.password)):"";s.set("Authorization","Basic "+btoa(f+":"+d))}const l=Ln(t.baseURL,t.url);c.open(t.method.toUpperCase(),In(l,t.params,t.paramsSerializer),!0),c.timeout=t.timeout;function v(){if(!c)return;const f=ae.from("getAllResponseHeaders"in c&&c.getAllResponseHeaders()),p={data:!o||o==="text"||o==="json"?c.responseText:c.response,status:c.status,statusText:c.statusText,headers:f,config:t,request:c};Po(function(w){r(w),u()},function(w){n(w),u()},p),c=null}if("onloadend"in c?c.onloadend=v:c.onreadystatechange=function(){!c||c.readyState!==4||c.status===0&&!(c.responseURL&&c.responseURL.indexOf("file:")===0)||setTimeout(v)},c.onabort=function(){c&&(n(new N("Request aborted",N.ECONNABORTED,t,c)),c=null)},c.onerror=function(){n(new N("Network Error",N.ERR_NETWORK,t,c)),c=null},c.ontimeout=function(){let d=t.timeout?"timeout of "+t.timeout+"ms exceeded":"timeout exceeded";const p=t.transitional||Pn;t.timeoutErrorMessage&&(d=t.timeoutErrorMessage),n(new N(d,p.clarifyTimeoutError?N.ETIMEDOUT:N.ECONNABORTED,t,c)),c=null},oe.isStandardBrowserEnv){const f=(t.withCredentials||Do(l))&&t.xsrfCookieName&&Uo.read(t.xsrfCookieName);f&&s.set(t.xsrfHeaderName,f)}i===void 0&&s.setContentType(null),"setRequestHeader"in c&&m.forEach(s.toJSON(),function(d,p){c.setRequestHeader(p,d)}),m.isUndefined(t.withCredentials)||(c.withCredentials=!!t.withCredentials),o&&o!=="json"&&(c.responseType=t.responseType),typeof t.onDownloadProgress=="function"&&c.addEventListener("progress",Mn(t.onDownloadProgress,!0)),typeof t.onUploadProgress=="function"&&c.upload&&c.upload.addEventListener("progress",Mn(t.onUploadProgress)),(t.cancelToken||t.signal)&&(a=f=>{c&&(n(!f||f.type?new We(null,t,c):f),c.abort(),c=null)},t.cancelToken&&t.cancelToken.subscribe(a),t.signal&&(t.signal.aborted?a():t.signal.addEventListener("abort",a)));const h=Lo(l);if(h&&oe.protocols.indexOf(h)===-1){n(new N("Unsupported protocol "+h+":",N.ERR_BAD_REQUEST,t));return}c.send(i||null)})}};m.forEach(Nt,(t,e)=>{if(t){try{Object.defineProperty(t,"name",{value:e})}catch{}Object.defineProperty(t,"adapterName",{value:e})}});const jo={getAdapter:t=>{t=m.isArray(t)?t:[t];const{length:e}=t;let r,n;for(let i=0;i<e&&(r=t[i],!(n=m.isString(r)?Nt[r.toLowerCase()]:r));i++);if(!n)throw n===!1?new N(`Adapter ${r} is not supported by the environment`,"ERR_NOT_SUPPORT"):new Error(m.hasOwnProp(Nt,r)?`Adapter '${r}' is not available in the build`:`Unknown adapter '${r}'`);if(!m.isFunction(n))throw new TypeError("adapter is not a function");return n},adapters:Nt};function vr(t){if(t.cancelToken&&t.cancelToken.throwIfRequested(),t.signal&&t.signal.aborted)throw new We}function jn(t){return vr(t),t.headers=ae.from(t.headers),t.data=pr.call(t,t.transformRequest),["post","put","patch"].indexOf(t.method)!==-1&&t.headers.setContentType("application/x-www-form-urlencoded",!1),jo.getAdapter(t.adapter||hr.adapter)(t).then(function(n){return vr(t),n.data=pr.call(t,t.transformResponse,n),n.headers=ae.from(n.headers),n},function(n){return Dn(n)||(vr(t),n&&n.response&&(n.response.data=pr.call(t,t.transformResponse,n.response),n.response.headers=ae.from(n.response.headers))),Promise.reject(n)})}const Fn=t=>t instanceof ae?t.toJSON():t;function Ye(t,e){e=e||{};const r={};function n(c,l,v){return m.isPlainObject(c)&&m.isPlainObject(l)?m.merge.call({caseless:v},c,l):m.isPlainObject(l)?m.merge({},l):m.isArray(l)?l.slice():l}function i(c,l,v){if(m.isUndefined(l)){if(!m.isUndefined(c))return n(void 0,c,v)}else return n(c,l,v)}function s(c,l){if(!m.isUndefined(l))return n(void 0,l)}function o(c,l){if(m.isUndefined(l)){if(!m.isUndefined(c))return n(void 0,c)}else return n(void 0,l)}function a(c,l,v){if(v in e)return n(c,l);if(v in t)return n(void 0,c)}const u={url:s,method:s,data:s,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,beforeRedirect:o,transport:o,httpAgent:o,httpsAgent:o,cancelToken:o,socketPath:o,responseEncoding:o,validateStatus:a,headers:(c,l)=>i(Fn(c),Fn(l),!0)};return m.forEach(Object.keys(t).concat(Object.keys(e)),function(l){const v=u[l]||i,h=v(t[l],e[l],l);m.isUndefined(h)&&v!==a||(r[l]=h)}),r}const $n="1.2.0",mr={};["object","boolean","number","function","string","symbol"].forEach((t,e)=>{mr[t]=function(n){return typeof n===t||"a"+(e<1?"n ":" ")+t}});const Bn={};mr.transitional=function(e,r,n){function i(s,o){return"[Axios v"+$n+"] Transitional option '"+s+"'"+o+(n?". "+n:"")}return(s,o,a)=>{if(e===!1)throw new N(i(o," has been removed"+(r?" in "+r:"")),N.ERR_DEPRECATED);return r&&!Bn[o]&&(Bn[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 Fo(t,e,r){if(typeof t!="object")throw new N("options must be an object",N.ERR_BAD_OPTION_VALUE);const n=Object.keys(t);let i=n.length;for(;i-- >0;){const s=n[i],o=e[s];if(o){const a=t[s],u=a===void 0||o(a,s,t);if(u!==!0)throw new N("option "+s+" must be "+u,N.ERR_BAD_OPTION_VALUE);continue}if(r!==!0)throw new N("Unknown option "+s,N.ERR_BAD_OPTION)}}const gr={assertOptions:Fo,validators:mr},pe=gr.validators;class Pt{constructor(e){this.defaults=e,this.interceptors={request:new Nn,response:new Nn}}request(e,r){typeof e=="string"?(r=r||{},r.url=e):r=e||{},r=Ye(this.defaults,r);const{transitional:n,paramsSerializer:i,headers:s}=r;n!==void 0&&gr.assertOptions(n,{silentJSONParsing:pe.transitional(pe.boolean),forcedJSONParsing:pe.transitional(pe.boolean),clarifyTimeoutError:pe.transitional(pe.boolean)},!1),i!==void 0&&gr.assertOptions(i,{encode:pe.function,serialize:pe.function},!0),r.method=(r.method||this.defaults.method||"get").toLowerCase();let o;o=s&&m.merge(s.common,s[r.method]),o&&m.forEach(["delete","get","head","post","put","patch","common"],d=>{delete s[d]}),r.headers=ae.concat(o,s);const a=[];let u=!0;this.interceptors.request.forEach(function(p){typeof p.runWhen=="function"&&p.runWhen(r)===!1||(u=u&&p.synchronous,a.unshift(p.fulfilled,p.rejected))});const c=[];this.interceptors.response.forEach(function(p){c.push(p.fulfilled,p.rejected)});let l,v=0,h;if(!u){const d=[jn.bind(this),void 0];for(d.unshift.apply(d,a),d.push.apply(d,c),h=d.length,l=Promise.resolve(r);v<h;)l=l.then(d[v++],d[v++]);return l}h=a.length;let f=r;for(v=0;v<h;){const d=a[v++],p=a[v++];try{f=d(f)}catch(g){p.call(this,g);break}}try{l=jn.call(this,f)}catch(d){return Promise.reject(d)}for(v=0,h=c.length;v<h;)l=l.then(c[v++],c[v++]);return l}getUri(e){e=Ye(this.defaults,e);const r=Ln(e.baseURL,e.url);return In(r,e.params,e.paramsSerializer)}}m.forEach(["delete","get","head","options"],function(e){Pt.prototype[e]=function(r,n){return this.request(Ye(n||{},{method:e,url:r,data:(n||{}).data}))}}),m.forEach(["post","put","patch"],function(e){function r(n){return function(s,o,a){return this.request(Ye(a||{},{method:e,headers:n?{"Content-Type":"multipart/form-data"}:{},url:s,data:o}))}}Pt.prototype[e]=r(),Pt.prototype[e+"Form"]=r(!0)});const Ut=Pt;class yr{constructor(e){if(typeof e!="function")throw new TypeError("executor must be a function.");let r;this.promise=new Promise(function(s){r=s});const n=this;this.promise.then(i=>{if(!n._listeners)return;let s=n._listeners.length;for(;s-- >0;)n._listeners[s](i);n._listeners=null}),this.promise.then=i=>{let s;const o=new Promise(a=>{n.subscribe(a),s=a}).then(i);return o.cancel=function(){n.unsubscribe(s)},o},e(function(s,o,a){n.reason||(n.reason=new We(s,o,a),r(n.reason))})}throwIfRequested(){if(this.reason)throw this.reason}subscribe(e){if(this.reason){e(this.reason);return}this._listeners?this._listeners.push(e):this._listeners=[e]}unsubscribe(e){if(!this._listeners)return;const r=this._listeners.indexOf(e);r!==-1&&this._listeners.splice(r,1)}static source(){let e;return{token:new yr(function(i){e=i}),cancel:e}}}const $o=yr;function Bo(t){return function(r){return t.apply(null,r)}}function qo(t){return m.isObject(t)&&t.isAxiosError===!0}function qn(t){const e=new Ut(t),r=hn(Ut.prototype.request,e);return m.extend(r,Ut.prototype,e,{allOwnKeys:!0}),m.extend(r,e,null,{allOwnKeys:!0}),r.create=function(i){return qn(Ye(t,i))},r}const H=qn(hr);H.Axios=Ut,H.CanceledError=We,H.CancelToken=$o,H.isCancel=Dn,H.VERSION=$n,H.toFormData=Rt,H.AxiosError=N,H.Cancel=H.CanceledError,H.all=function(e){return Promise.all(e)},H.spread=Bo,H.isAxiosError=qo,H.AxiosHeaders=ae,H.formToJSON=t=>Un(m.isHTMLForm(t)?new FormData(t):t),H.default=H;const Qe=H,Xe="nhostRefreshToken",Ze="nhostRefreshTokenExpiresAt",Vn=3,zn=300,Hn=5,Er=0,wr=1,Y=10,Ue=20;let et=class extends Error{constructor(e){super(e.message),Error.captureStackTrace(this,this.constructor),e instanceof Error?(this.name=e.name,this.error={error:e.name,status:wr,message:e.message}):(this.name=e.error,this.error=e)}};const ce={status:Y,error:"invalid-email",message:"Email is incorrectly formatted"},Kn={status:Y,error:"invalid-mfa-type",message:"MFA type is invalid"},Gn={status:Y,error:"invalid-mfa-code",message:"MFA code is invalid"},Ct={status:Y,error:"invalid-password",message:"Password is incorrectly formatted"},Sr={status:Y,error:"invalid-phone-number",message:"Phone number is incorrectly formatted"},Jn={status:Y,error:"invalid-mfa-ticket",message:"MFA ticket is invalid"},Wn={status:Y,error:"no-mfa-ticket",message:"No MFA ticket has been provided"},Yn={status:Y,error:"no-refresh-token",message:"No refresh token has been provided"},Qn={status:Ue,error:"refresher-already-running",message:"The token refresher is already running. You must wait until is has finished before submitting a new token."},re={status:Ue,error:"already-signed-in",message:"User is already signed in"},Xn={status:Ue,error:"unauthenticated-user",message:"User is not authenticated"},Vo={status:Ue,error:"user-not-anonymous",message:"User is not anonymous"},Zn={status:Ue,error:"unverified-user",message:"Email needs verification"},ei={status:Y,error:"invalid-refresh-token",message:"Invalid or expired refresh token"},ti={status:wr,error:"invalid-sign-in-method",message:"Invalid sign-in method"},_t={user:null,mfa:null,accessToken:{value:null,expiresAt:null},refreshTimer:{startedAt:null,attempts:0,lastAttempt:null},refreshToken:{value:null},importTokenAttempts:0,errors:{}};function zo(t){return new TextEncoder().encode(t)}function Se(t){const e=new Uint8Array(t);let r="";for(const n of e)r+=String.fromCharCode(n);return btoa(r).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function Tr(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),r=(4-e.length%4)%4,n=e.padEnd(e.length+r,"="),i=atob(n),s=new ArrayBuffer(i.length),o=new Uint8Array(s);for(let a=0;a<i.length;a++)o[a]=i.charCodeAt(a);return s}function ri(){return(window==null?void 0:window.PublicKeyCredential)!==void 0&&typeof window.PublicKeyCredential=="function"}function ni(t){const{id:e}=t;return{...t,id:Tr(e),transports:t.transports}}function ii(t){return t==="localhost"||/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/i.test(t)}let K=class extends Error{constructor(e,r="WebAuthnError"){super(e),this.name=r}};function Ho({error:t,options:e}){var r,n;const{publicKey:i}=e;if(!i)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal===new AbortController().signal)return new K("Registration ceremony was sent an abort signal","AbortError")}else if(t.name==="ConstraintError"){if(((r=i.authenticatorSelection)===null||r===void 0?void 0:r.requireResidentKey)===!0)return new K("Discoverable credentials were required but no available authenticator supported it","ConstraintError");if(((n=i.authenticatorSelection)===null||n===void 0?void 0:n.userVerification)==="required")return new K("User verification was required but no available authenticator supported it","ConstraintError")}else{if(t.name==="InvalidStateError")return new K("The authenticator was previously registered","InvalidStateError");if(t.name==="NotAllowedError")return new K("User clicked cancel, or the registration ceremony timed out","NotAllowedError");if(t.name==="NotSupportedError")return i.pubKeyCredParams.filter(s=>s.type==="public-key").length===0?new K('No entry in pubKeyCredParams was of type "public-key"',"NotSupportedError"):new K("No available authenticator supported any of the specified pubKeyCredParams algorithms","NotSupportedError");if(t.name==="SecurityError"){const s=window.location.hostname;if(ii(s)){if(i.rp.id!==s)return new K(`The RP ID "${i.rp.id}" is invalid for this domain`,"SecurityError")}else return new K(`${window.location.hostname} is an invalid domain`,"SecurityError")}else if(t.name==="TypeError"){if(i.user.id.byteLength<1||i.user.id.byteLength>64)return new K("User ID was not between 1 and 64 characters","TypeError")}else if(t.name==="UnknownError")return new K("The authenticator was unable to process the specified options, or could not create a new credential","UnknownError")}return t}class Ko{createNewAbortSignal(){return this.controller&&this.controller.abort(),this.controller=new AbortController,this.controller.signal}reset(){this.controller=void 0}}const Dt=new Ko;async function si(t){if(!ri())throw new Error("WebAuthn is not supported in this browser");const e={publicKey:{...t,challenge:Tr(t.challenge),user:{...t.user,id:zo(t.user.id)},excludeCredentials:t.excludeCredentials.map(ni)}};e.signal=Dt.createNewAbortSignal();let r;try{r=await navigator.credentials.create(e)}catch(u){throw Ho({error:u,options:e})}finally{Dt.reset()}if(!r)throw new Error("Registration was not completed");const{id:n,rawId:i,response:s,type:o}=r,a={id:n,rawId:Se(i),response:{attestationObject:Se(s.attestationObject),clientDataJSON:Se(s.clientDataJSON)},type:o,clientExtensionResults:r.getClientExtensionResults(),authenticatorAttachment:r.authenticatorAttachment};return typeof s.getTransports=="function"&&(a.transports=s.getTransports()),a}function Go(t){return new TextDecoder("utf-8").decode(t)}async function Jo(){if(navigator.credentials.conditionalMediationSupported)return!0;const t=window.PublicKeyCredential;return t.isConditionalMediationAvailable!==void 0&&t.isConditionalMediationAvailable()}function Wo({error:t,options:e}){var r;const{publicKey:n}=e;if(!n)throw Error("options was missing required publicKey property");if(t.name==="AbortError"){if(e.signal===new AbortController().signal)return new K("Authentication ceremony was sent an abort signal","AbortError")}else{if(t.name==="NotAllowedError")return!((r=n.allowCredentials)===null||r===void 0)&&r.length?new K("No available authenticator recognized any of the allowed credentials","NotAllowedError"):new K("User clicked cancel, or the authentication ceremony timed out","NotAllowedError");if(t.name==="SecurityError"){const i=window.location.hostname;if(ii(i)){if(n.rpId!==i)return new K(`The RP ID "${n.rpId}" is invalid for this domain`,"SecurityError")}else return new K(`${window.location.hostname} is an invalid domain`,"SecurityError")}else if(t.name==="UnknownError")return new K("The authenticator was unable to process the specified options, or could not create a new assertion signature","UnknownError")}return t}async function Yo(t,e=!1){var r,n;if(!ri())throw new Error("WebAuthn is not supported in this browser");let i;((r=t.allowCredentials)===null||r===void 0?void 0:r.length)!==0&&(i=(n=t.allowCredentials)===null||n===void 0?void 0:n.map(ni));const s={...t,challenge:Tr(t.challenge),allowCredentials:i},o={};if(e){if(!await Jo())throw Error("Browser does not support WebAuthn autofill");if(document.querySelectorAll("input[autocomplete*='webauthn']").length<1)throw Error('No <input> with `"webauthn"` in its `autocomplete` attribute was detected');o.mediation="conditional",s.allowCredentials=[]}o.publicKey=s,o.signal=Dt.createNewAbortSignal();let a;try{a=await navigator.credentials.get(o)}catch(f){throw Wo({error:f,options:o})}finally{Dt.reset()}if(!a)throw new Error("Authentication was not completed");const{id:u,rawId:c,response:l,type:v}=a;let h;return l.userHandle&&(h=Go(l.userHandle)),{id:u,rawId:Se(c),response:{authenticatorData:Se(l.authenticatorData),clientDataJSON:Se(l.clientDataJSON),signature:Se(l.signature),userHandle:h},type:v,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:a.authenticatorAttachment}}const Lt=typeof window<"u",Mt=new Map,Qo=t=>Lt&&typeof localStorage<"u"?localStorage.getItem(t):Mt.get(t)??null,Xo=(t,e)=>{Lt&&typeof localStorage<"u"?e?localStorage.setItem(t,e):localStorage.removeItem(t):e?Mt.set(t,e):Mt.has(t)&&Mt.delete(t)},oi=(t,e)=>{if(t==="localStorage"||t==="web")return Qo;if(t==="cookie")return r=>Lt?or.get(r)??null:null;if(!e)throw Error(`clientStorageType is set to '${t}' but no clientStorage has been given`);if(t==="react-native")return r=>{var n;return(n=e.getItem)==null?void 0:n.call(e,r)};if(t==="capacitor")return r=>{var n;return(n=e.get)==null?void 0:n.call(e,{key:r})};if(t==="expo-secure-storage")return r=>{var n;return(n=e.getItemAsync)==null?void 0:n.call(e,r)};if(t==="custom"){if(e.getItem&&e.removeItem)return e.getItem;if(e.getItemAsync)return e.getItemAsync;throw Error(`clientStorageType is set to 'custom' but clientStorage is missing either "getItem" and "removeItem" properties or "getItemAsync" property`)}throw Error(`Unknown storage type: ${t}`)},ai=(t,e)=>{if(t==="localStorage"||t==="web")return Xo;if(t==="cookie")return(r,n)=>{Lt&&(n?or.set(r,n,{expires:30,sameSite:"lax",httpOnly:!1}):or.remove(r))};if(!e)throw Error(`clientStorageType is set to '${t}' but no clienStorage has been given`);if(t==="react-native")return(r,n)=>{var i,s;return n?(i=e.setItem)==null?void 0:i.call(e,r,n):(s=e.removeItem)==null?void 0:s.call(e,r)};if(t==="capacitor")return(r,n)=>{var i,s;return n?(i=e.set)==null?void 0:i.call(e,{key:r,value:n}):(s=e.remove)==null?void 0:s.call(e,{key:r})};if(t==="expo-secure-storage")return async(r,n)=>{var i,s;return n?(i=e.setItemAsync)==null?void 0:i.call(e,r,n):(s=e.deleteItemAsync)==null?void 0:s.call(e,r)};if(t==="custom"){if(!e.removeItem)throw Error("clientStorageType is set to 'custom' but clientStorage is missing a removeItem property");if(e.setItem)return(r,n)=>{var i,s;return n?(i=e.setItem)==null?void 0:i.call(e,r,n):(s=e.removeItem)==null?void 0:s.call(e,r)};if(e.setItemAsync)return async(r,n)=>{var i,s;return n?(i=e.setItemAsync)==null?void 0:i.call(e,r,n):(s=e.removeItem)==null?void 0:s.call(e,r)};throw Error("clientStorageType is set to 'custom' but clientStorage is missing setItem or setItemAsync property")}throw Error(`Unknown storage type: ${t}`)},ve=t=>{const e=Qe.create({baseURL:t});return e.interceptors.response.use(r=>r,r=>{var n,i,s,o,a,u,c;return Promise.reject({error:{message:((i=(n=r.response)==null?void 0:n.data)==null?void 0:i.message)??r.message??r.request.responseText??JSON.stringify(r),status:((s=r.response)==null?void 0:s.status)??((a=(o=r.response)==null?void 0:o.data)==null?void 0:a.statusCode)??Er,error:((c=(u=r.response)==null?void 0:u.data)==null?void 0:c.error)||r.request.statusText||"network"}})}),e},tt=t=>!t||!t.accessToken.value||!t.refreshToken.value||!t.accessToken.expiresAt||!t.user?null:{accessToken:t.accessToken.value,accessTokenExpiresIn:(t.accessToken.expiresAt.getTime()-Date.now())/1e3,refreshToken:t.refreshToken.value,user:t.user},me=({accessToken:t,isError:e,user:r,error:n})=>e?{session:null,error:n}:r&&t?{session:{accessToken:t,accessTokenExpiresIn:0,refreshToken:"",user:r},error:null}:{session:null,error:null},jt=()=>typeof window<"u",br=(t,e)=>{const r=e&&Object.entries(e).map(([n,i])=>{const s=Array.isArray(i)?i.join(","):typeof i=="object"?JSON.stringify(i):i;return`${n}=${encodeURIComponent(s)}`}).join("&");return r?`${t}?${r}`:t},Q=(t,e)=>{if(!(e!=null&&e.redirectTo))return e;const{redirectTo:r,...n}=e;if(!t)return r.startsWith("/")?n:e;const i=new URL(t),s=Object.fromEntries(new URLSearchParams(i.search)),o=new URL(r.startsWith("/")?i.origin+r:r),a=new URLSearchParams(o.search);let u=Object.fromEntries(a);r.startsWith("/")&&(u={...s,...u});let c=i.pathname;return o.pathname.length>1&&(c+=o.pathname.slice(1)),{...n,redirectTo:br(o.origin+c,u)}};function rt(t,e){var r;if(!e){if(typeof window>"u")return;e=((r=window.location)==null?void 0:r.href)||""}t=t.replace(/[\[\]]/g,"\\$&");const n=new RegExp("[?&#]"+t+"(=([^&#]*)|&|#|$)"),i=n.exec(e);return i?i[2]?decodeURIComponent(i[2].replace(/\+/g," ")):"":null}function Ar(t){var e;if(typeof window>"u")return;const r=window==null?void 0:window.location;if(r&&r){const n=new URLSearchParams(r.search),i=new URLSearchParams((e=r.hash)==null?void 0:e.slice(1));n.delete(t),i.delete(t);let s=window.location.pathname;Array.from(n).length&&(s+=`?${n.toString()}`),Array.from(i).length&&(s+=`#${i.toString()}`),window.history.pushState({},"",s)}}const ue=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,}))$/),Ft=t=>!!t&&typeof t=="string"&&t.length>=Vn,Or=t=>!!t&&typeof t=="string",ci=t=>t&&typeof t=="string"&&t.match(/^mfaTotp:[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),ui=({backendUrl:t,clientUrl:e,clientStorageGetter:r,clientStorageSetter:n,clientStorageType:i="web",clientStorage:s,refreshIntervalTime:o,autoRefreshToken:a=!0,autoSignIn:u=!0})=>{const c=r||oi(i,s),l=n||ai(i,s),v=ve(t),h=async(f,d,p)=>(await v.post(f,d,p)).data;return he({schema:{context:{},events:{},services:{}},tsTypes:{},context:_t,predictableActionArguments:!0,id:"nhost",type:"parallel",states:{authentication:{initial:"starting",on:{SESSION_UPDATE:[{cond:"hasSession",actions:["saveSession","resetTimer","reportTokenChanged"],target:".signedIn"}]},states:{starting:{tags:["loading"],always:{cond:"isSignedIn",target:"signedIn"},invoke:{id:"importRefreshToken",src:"importRefreshToken",onDone:[{cond:"hasSession",actions:["saveSession","reportTokenChanged"],target:"signedIn"},{target:"signedOut"}],onError:[{cond:"shouldRetryImportToken",actions:"incrementTokenImportAttempts",target:"retryTokenImport"},{actions:["saveAuthenticationError"],target:"signedOut"}]}},retryTokenImport:{tags:["loading"],after:{RETRY_IMPORT_TOKEN_DELAY:"starting"}},signedOut:{initial:"noErrors",entry:"reportSignedOut",states:{noErrors:{},success:{},needsSmsOtp:{},needsMfa:{},failed:{},signingOut:{entry:["clearContextExceptRefreshToken"],exit:["destroyRefreshToken","reportTokenChanged"],invoke:{src:"signout",id:"signingOut",onDone:{target:"success"},onError:{target:"failed",actions:["saveAuthenticationError"]}}}},on:{SIGNIN_PASSWORD:"authenticating.password",SIGNIN_ANONYMOUS:"authenticating.anonymous",SIGNIN_SECURITY_KEY_EMAIL:"authenticating.securityKeyEmail",SIGNIN_MFA_TOTP:"authenticating.mfa.totp"}},authenticating:{entry:"resetErrors",states:{password:{invoke:{src:"signInPassword",id:"authenticateUserWithPassword",onDone:[{cond:"hasMfaTicket",actions:["saveMfaTicket"],target:"#nhost.authentication.signedOut.needsMfa"},{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"}],onError:[{cond:"unverified",target:["#nhost.authentication.signedOut","#nhost.registration.incomplete.needsEmailVerification"]},{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed"}]}},anonymous:{invoke:{src:"signInAnonymous",id:"authenticateAnonymously",onDone:{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed"}}},mfa:{states:{totp:{invoke:{src:"signInMfaTotp",id:"signInMfaTotp",onDone:{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:["saveAuthenticationError"],target:"#nhost.authentication.signedOut.failed"}}}}},securityKeyEmail:{invoke:{src:"signInSecurityKeyEmail",id:"authenticateUserWithSecurityKey",onDone:{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:[{cond:"unverified",target:["#nhost.authentication.signedOut","#nhost.registration.incomplete.needsEmailVerification"]},{actions:"saveAuthenticationError",target:"#nhost.authentication.signedOut.failed"}]}}}},signedIn:{type:"parallel",entry:["reportSignedIn","cleanUrl","broadcastToken","resetErrors"],on:{SIGNOUT:"signedOut.signingOut"},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:{1e3:{internal:!1,target:"pending"}},always:{cond:"refreshTimerShouldRefresh",target:"refreshing"}},refreshing:{invoke:{src:"refreshToken",id:"refreshToken",onDone:{actions:["saveSession","resetTimer","reportTokenChanged"],target:"pending"},onError:[{actions:"saveRefreshAttempt",target:"pending"}]}}}}}}}}}},token:{initial:"idle",states:{idle:{on:{TRY_TOKEN:"running"},initial:"noErrors",states:{noErrors:{},error:{}}},running:{invoke:{src:"refreshToken",id:"authenticateWithToken",onDone:{actions:["saveSession","reportTokenChanged"],target:["#nhost.authentication.signedIn","idle.noErrors"]},onError:[{cond:"isSignedIn",target:"idle.error"},{actions:"saveAuthenticationError",target:["#nhost.authentication.signedOut.failed","idle.error"]}]}}}},registration:{initial:"incomplete",on:{SIGNED_IN:[{cond:"isAnonymous",target:".incomplete"},".complete"]},states:{incomplete:{on:{SIGNUP_EMAIL_PASSWORD:"emailPassword",SIGNUP_SECURITY_KEY:"securityKey",PASSWORDLESS_EMAIL:"passwordlessEmail",PASSWORDLESS_SMS:"passwordlessSms",PASSWORDLESS_SMS_OTP:"passwordlessSmsOtp"},initial:"noErrors",states:{noErrors:{},needsEmailVerification:{},needsOtp:{},failed:{}}},emailPassword:{entry:["resetErrors"],invoke:{src:"signUpEmailPassword",id:"signUpEmailPassword",onDone:[{cond:"hasSession",actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},{actions:"clearContext",target:["#nhost.authentication.signedOut","incomplete.needsEmailVerification"]}],onError:[{cond:"unverified",target:"incomplete.needsEmailVerification"},{actions:"saveRegistrationError",target:"incomplete.failed"}]}},securityKey:{entry:["resetErrors"],invoke:{src:"signUpSecurityKey",id:"signUpSecurityKey",onDone:[{cond:"hasSession",actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},{actions:"clearContext",target:["#nhost.authentication.signedOut","incomplete.needsEmailVerification"]}],onError:[{cond:"unverified",target:"incomplete.needsEmailVerification"},{actions:"saveRegistrationError",target:"incomplete.failed"}]}},passwordlessEmail:{entry:["resetErrors"],invoke:{src:"passwordlessEmail",id:"passwordlessEmail",onDone:{actions:"clearContext",target:["#nhost.authentication.signedOut","incomplete.needsEmailVerification"]},onError:{actions:"saveRegistrationError",target:"incomplete.failed"}}},passwordlessSms:{entry:["resetErrors"],invoke:{src:"passwordlessSms",id:"passwordlessSms",onDone:{actions:"clearContext",target:["#nhost.authentication.signedOut","incomplete.needsOtp"]},onError:{actions:"saveRegistrationError",target:"incomplete.failed"}}},passwordlessSmsOtp:{entry:["resetErrors"],invoke:{src:"passwordlessSmsOtp",id:"passwordlessSmsOtp",onDone:{actions:["saveSession","reportTokenChanged"],target:"#nhost.authentication.signedIn"},onError:{actions:"saveRegistrationError",target:"incomplete.failed"}}},complete:{on:{SIGNED_OUT:"incomplete"}}}}}},{actions:{reportSignedIn:V("SIGNED_IN"),reportSignedOut:V("SIGNED_OUT"),reportTokenChanged:V("TOKEN_CHANGED"),incrementTokenImportAttempts:O({importTokenAttempts:({importTokenAttempts:f})=>f+1}),clearContext:O(()=>(l(Ze,null),l(Xe,null),{..._t})),clearContextExceptRefreshToken:O(({refreshToken:{value:f}})=>(l(Ze,null),{..._t,refreshToken:{value:f}})),saveSession:O({user:(f,{data:d})=>{var p;return((p=d==null?void 0:d.session)==null?void 0:p.user)||null},accessToken:(f,{data:d})=>{if(d.session){const{accessTokenExpiresIn:p,accessToken:g}=d.session,w=new Date(Date.now()+p*1e3);return l(Ze,w.toISOString()),{value:g,expiresAt:w}}return l(Ze,null),{value:null,expiresAt:null}},refreshToken:(f,{data:d})=>{var p;const g=((p=d.session)==null?void 0:p.refreshToken)||null;return g&&l(Xe,g),{value:g}}}),saveMfaTicket:O({mfa:(f,d)=>{var p;return(p=d.data)==null?void 0:p.mfa}}),resetTimer:O({refreshTimer:f=>({startedAt:new Date,attempts:0,lastAttempt:null})}),saveRefreshAttempt:O({refreshTimer:(f,d)=>({startedAt:f.refreshTimer.startedAt,attempts:f.refreshTimer.attempts+1,lastAttempt:new Date})}),saveAuthenticationError:O({errors:({errors:f},{data:{error:d}})=>({...f,authentication:d})}),resetErrors:O({errors:f=>({}),importTokenAttempts:f=>0}),saveRegistrationError:O({errors:({errors:f},{data:{error:d}})=>({...f,registration:d})}),destroyRefreshToken:O({refreshToken:f=>(l(Xe,null),{value:null})}),cleanUrl:()=>{u&&rt("refreshToken")&&(Ar("refreshToken"),Ar("type"))},broadcastToken:f=>{if(u)try{new BroadcastChannel("nhost").postMessage(f.refreshToken.value)}catch{}}},guards:{isAnonymous:(f,d)=>{var p;return!!((p=f.user)!=null&&p.isAnonymous)},isSignedIn:f=>!!f.user&&!!f.refreshToken.value&&!!f.accessToken.value,noToken:f=>!f.refreshToken.value,hasRefreshToken:f=>!!f.refreshToken.value,isAutoRefreshDisabled:()=>!a,refreshTimerShouldRefresh:f=>{const{expiresAt:d}=f.accessToken;return d?f.refreshTimer.lastAttempt?Date.now()-f.refreshTimer.lastAttempt.getTime()>Hn*1e3:o&&Date.now()-f.refreshTimer.startedAt.getTime()>o*1e3?!0:d.getTime()-Date.now()-1e3*zn<=0:!1},shouldRetryImportToken:(f,d)=>d.data.error.status===Er||d.data.error.status>=500,unverified:(f,{data:{error:d}})=>d.status===401&&(d.message==="Email is not verified"||d.error==="unverified-user"),hasSession:(f,d)=>{var p;return!!((p=d.data)!=null&&p.session)},hasMfaTicket:(f,d)=>{var p;return!!((p=d.data)!=null&&p.mfa)}},services:{signInPassword:(f,{email:d,password:p})=>ue(d)?Ft(p)?h("/signin/email-password",{email:d,password:p}):Promise.reject({error:Ct}):Promise.reject({error:ce}),passwordlessSms:(f,{phoneNumber:d,options:p})=>{var g;return Or(d)?(g=f.user)!=null&&g.isAnonymous?(console.warn("Deanonymisation from a phone number is not yet implemented in hasura-auth"),h("/user/deanonymize",{signInMethod:"passwordless",connection:"sms",phoneNumber:d,options:Q(e,p)},{headers:{authorization:`Bearer ${f.accessToken.value}`}})):h("/signin/passwordless/sms",{phoneNumber:d,options:Q(e,p)}):Promise.reject({error:Sr})},passwordlessSmsOtp:(f,{phoneNumber:d,otp:p})=>Or(d)?h("/signin/passwordless/sms/otp",{phoneNumber:d,otp:p}):Promise.reject({error:Sr}),passwordlessEmail:(f,{email:d,options:p})=>{var g;return ue(d)?(g=f.user)!=null&&g.isAnonymous?h("/user/deanonymize",{signInMethod:"passwordless",connection:"email",email:d,options:Q(e,p)},{headers:{authorization:`Bearer ${f.accessToken.value}`}}):h("/signin/passwordless/email",{email:d,options:Q(e,p)}):Promise.reject({error:ce})},signInAnonymous:f=>h("/signin/anonymous"),signInMfaTotp:(f,d)=>{var p;const g=d.ticket||((p=f.mfa)==null?void 0:p.ticket);return g?ci(g)?h("/signin/mfa/totp",{ticket:g,otp:d.otp}):Promise.reject({error:Jn}):Promise.reject({error:Wn})},signInSecurityKeyEmail:async(f,{email:d})=>{if(!ue(d))throw new et(ce);const p=await h("/signin/webauthn",{email:d});let g;try{g=await Yo(p)}catch(w){throw new et(w)}return h("/signin/webauthn/verify",{email:d,credential:g})},refreshToken:async(f,d)=>{const p=d.type==="TRY_TOKEN"?d.token:f.refreshToken.value;return{session:await h("/token",{refreshToken:p}),error:null}},signout:(f,d)=>h("/signout",{refreshToken:f.refreshToken.value,all:!!d.all}),signUpEmailPassword:async(f,{email:d,password:p,options:g})=>{var w;return ue(d)?Ft(p)?(w=f.user)!=null&&w.isAnonymous?h("/user/deanonymize",{signInMethod:"email-password",email:d,password:p,options:Q(e,g)},{headers:{authorization:`Bearer ${f.accessToken.value}`}}):h("/signup/email-password",{email:d,password:p,options:Q(e,g)}):Promise.reject({error:Ct}):Promise.reject({error:ce})},signUpSecurityKey:async(f,{email:d,options:p})=>{if(!ue(d))return Promise.reject({error:ce});const g=p==null?void 0:p.nickname;g&&delete p.nickname;const w=await h("/signup/webauthn",{email:d,options:p});let S;try{S=await si(w)}catch(T){throw new et(T)}return h("/signup/webauthn/verify",{credential:S,options:{redirectTo:p==null?void 0:p.redirectTo,nickname:g}})},importRefreshToken:async f=>{if(f.user&&f.refreshToken.value&&f.accessToken.value&&f.accessToken.expiresAt)return{session:{accessToken:f.accessToken.value,accessTokenExpiresIn:f.accessToken.expiresAt.getTime()-Date.now(),refreshToken:f.refreshToken.value,user:f.user},error:null};let d=null;if(u){const g=rt("refreshToken")||null;if(g)try{return{session:await h("/token",{refreshToken:g}),error:null}}catch(w){d=w.error}else{const w=rt("error");if(w)return Promise.reject({session:null,error:{status:Y,error:w,message:rt("errorDescription")||w}})}}const p=await c(Xe);if(p)try{return{session:await h("/token",{refreshToken:p}),error:null}}catch(g){d=g.error}return d?Promise.reject({error:d,session:null}):{error:null,session:null}}},delays:{RETRY_IMPORT_TOKEN_DELAY:({importTokenAttempts:f})=>f<5?1e3:5e3}})},li=({backendUrl:t,clientUrl:e,interpreter:r})=>{const n=ve(t);return he({schema:{context:{},events:{},services:{}},tsTypes:{},predictableActionArguments:!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:O({error:i=>ce}),saveRequestError:O({error:(i,{data:{error:s}})=>s}),reportError:V(i=>({type:"ERROR",error:i.error})),reportSuccess:V("SUCCESS")},guards:{invalidEmail:(i,{email:s})=>!ue(s)},services:{requestChange:async(i,{email:s,options:o})=>(await n.post("/user/email/change",{newEmail:s,options:Q(e,o)},{headers:{authorization:`Bearer ${r==null?void 0:r.getSnapshot().context.accessToken.value}`}})).data}})},di=({backendUrl:t,interpreter:e})=>{const r=ve(t);return he({schema:{context:{},events:{},services:{}},tsTypes:{},predictableActionArguments:!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:O({error:n=>Ct}),saveRequestError:O({error:(n,{data:{error:i}})=>i}),reportError:V(n=>({type:"ERROR",error:n.error})),reportSuccess:V("SUCCESS")},guards:{invalidPassword:(n,{password:i})=>!Ft(i)},services:{requestChange:(n,{password:i,ticket:s})=>r.post("/user/password",{newPassword:i,ticket:s},{headers:{authorization:`Bearer ${e==null?void 0:e.getSnapshot().context.accessToken.value}`}})}})},Zo=({backendUrl:t,interpreter:e})=>{const r=ve(t);return he({schema:{context:{},events:{}},tsTypes:{},predictableActionArguments:!0,id:"enableMfa",initial:"idle",context:{error:null,imageUrl:null,secret:null},states:{idle:{initial:"initial",on:{GENERATE:"generating"},states:{initial:{},error:{}}},generating:{invoke:{src:"generate",id:"generate",onDone:{target:"generated",actions:["reportGeneratedSuccess","saveGeneration"]},onError:{actions:["saveError","reportGeneratedError"],target:"idle.error"}}},generated:{initial:"idle",states:{idle:{initial:"idle",on:{ACTIVATE:[{cond:"invalidMfaType",actions:"saveInvalidMfaTypeError",target:".error"},{cond:"invalidMfaCode",actions:"saveInvalidMfaCodeError",target:".error"},{target:"activating"}]},states:{idle:{},error:{}}},activating:{invoke:{src:"activate",id:"activate",onDone:{target:"activated",actions:"reportSuccess"},onError:{actions:["saveError","reportError"],target:"idle.error"}}},activated:{type:"final"}}}}},{actions:{saveInvalidMfaTypeError:O({error:n=>Kn}),saveInvalidMfaCodeError:O({error:n=>Gn}),saveError:O({error:(n,{data:{error:i}})=>i}),saveGeneration:O({imageUrl:(n,{data:{imageUrl:i}})=>i,secret:(n,{data:{totpSecret:i}})=>i}),reportError:V(n=>({type:"ERROR",error:n.error})),reportSuccess:V("SUCCESS"),reportGeneratedSuccess:V("GENERATED"),reportGeneratedError:V(n=>({type:"GENERATED_ERROR",error:n.error}))},guards:{invalidMfaCode:(n,{code:i})=>!i,invalidMfaType:(n,{activeMfaType:i})=>!i||i!=="totp"},services:{generate:async n=>{const{data:i}=await r.get("/mfa/totp/generate",{headers:{authorization:`Bearer ${e==null?void 0:e.getSnapshot().context.accessToken.value}`}});return i},activate:(n,{code:i,activeMfaType:s})=>r.post("/user/mfa",{code:i,activeMfaType:s},{headers:{authorization:`Bearer ${e==null?void 0:e.getSnapshot().context.accessToken.value}`}})}})},fi=({backendUrl:t,clientUrl:e})=>{const r=ve(t);return he({schema:{context:{},events:{},services:{}},tsTypes:{},predictableActionArguments:!0,id:"changePassword",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:O({error:n=>ce}),saveRequestError:O({error:(n,{data:{error:i}})=>i}),reportError:V(n=>({type:"ERROR",error:n.error})),reportSuccess:V("SUCCESS")},guards:{invalidEmail:(n,{email:i})=>!ue(i)},services:{requestChange:(n,{email:i,options:s})=>r.post("/user/password/reset",{email:i,options:Q(e,s)})}})},hi=({backendUrl:t,clientUrl:e})=>{const r=ve(t);return he({schema:{context:{},events:{},services:{}},tsTypes:{},predictableActionArguments:!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:O({error:n=>ce}),saveRequestError:O({error:(n,{data:{error:i}})=>i}),reportError:V(n=>({type:"ERROR",error:n.error})),reportSuccess:V("SUCCESS")},guards:{invalidEmail:(n,{email:i})=>!ue(i)},services:{request:async(n,{email:i,options:s})=>(await r.post("/user/email/send-verification-email",{email:i,options:Q(e,s)})).data}})};class Rr{constructor({clientStorageType:e="web",autoSignIn:r=!0,autoRefreshToken:n=!0,start:i=!0,backendUrl:s,clientUrl:o,devTools:a,...u}){if(this._started=!1,this._subscriptionsQueue=new Set,this._subscriptions=new Set,this.backendUrl=s,this.clientUrl=o,this._machine=ui({...u,backendUrl:s,clientUrl:o,clientStorageType:e,autoSignIn:r,autoRefreshToken:n}),i&&this.start({devTools:a}),typeof window<"u"&&r)try{this._channel=new BroadcastChannel("nhost"),this._channel.addEventListener("message",c=>{var l;const v=(l=this.interpreter)==null?void 0:l.getSnapshot().context.refreshToken.value;this.interpreter&&c.data!==v&&this.interpreter.send("TRY_TOKEN",{token:c.data})})}catch{}}start({devTools:e=!1,initialSession:r,interpreter:n}={}){const i={...this.machine.context};r&&(i.user=r.user,i.refreshToken.value=r.refreshToken??null,i.accessToken.value=r.accessToken??null,i.accessToken.expiresAt=new Date(Date.now()+r.accessTokenExpiresIn*1e3));const s=this.machine.withContext(i);this._interpreter||(this._interpreter=n||ke(s,{devTools:e})),(!this._started||typeof window>"u")&&(this._interpreter.initialized&&(this._interpreter.stop(),this._subscriptions.forEach(o=>o())),this._interpreter.start(s.initialState),this._subscriptionsQueue.forEach(o=>o(this))),this._started=!0}get machine(){return this._machine}get interpreter(){return this._interpreter}get started(){return this._started}subscribe(e){if(this.started){const r=e(this);return this._subscriptions.add(r),r}else return this._subscriptionsQueue.add(e),()=>{console.log("onTokenChanged was added before the interpreter started. Cannot unsubscribe listener.")}}}class pi extends Rr{constructor({...e}){super({...e,autoSignIn:jt()&&e.autoSignIn,autoRefreshToken:jt()&&e.autoRefreshToken,clientStorageType:"cookie"})}}const ea=pi,vi=async({backendUrl:t,interpreter:e},r)=>{const n=ve(t);try{const{data:i}=await n.post("/user/webauthn/add",{},{headers:{authorization:`Bearer ${e==null?void 0:e.getSnapshot().context.accessToken.value}`}});let s;try{s=await si(i)}catch(a){throw new et(a)}const{data:o}=await n.post("/user/webauthn/verify",{credential:s,nickname:r},{headers:{authorization:`Bearer ${e==null?void 0:e.getSnapshot().context.accessToken.value}`}});return{key:o,isError:!1,error:null,isSuccess:!0}}catch(i){const{error:s}=i;return{isError:!0,error:s,isSuccess:!1}}},mi=async(t,e,r)=>new Promise(n=>{t.send("REQUEST",{email:e,options:r}),t.onTransition(i=>{i.matches({idle:"error"})?n({error:i.context.error,isError:!0,needsEmailVerification:!1}):i.matches({idle:"success"})&&n({error:null,isError:!1,needsEmailVerification:!0})})}),gi=async(t,e,r)=>new Promise(n=>{t.send("REQUEST",{password:e,ticket:r}),t.onTransition(i=>{i.matches({idle:"error"})?n({error:i.context.error,isError:!0,isSuccess:!1}):i.matches({idle:"success"})&&n({error:null,isError:!1,isSuccess:!0})})}),ta=t=>new Promise(e=>{t.send("GENERATE"),t.onTransition(r=>{r.matches("generated")?e({error:null,isError:!1,isGenerated:!0,qrCodeDataUrl:r.context.imageUrl||""}):r.matches({idle:"error"})&&e({error:r.context.error||null,isError:!0,isGenerated:!1,qrCodeDataUrl:""})})}),ra=(t,e)=>new Promise(r=>{t.send("ACTIVATE",{activeMfaType:"totp",code:e}),t.onTransition(n=>{n.matches({generated:"activated"})?r({error:null,isActivated:!0,isError:!1}):n.matches({generated:{idle:"error"}})&&r({error:n.context.error,isActivated:!1,isError:!0})})}),yi=async(t,e,r)=>new Promise(n=>{t.send("REQUEST",{email:e,options:r}),t.onTransition(i=>{i.matches({idle:"error"})?n({error:i.context.error,isError:!0,isSent:!1}):i.matches({idle:"success"})&&n({error:null,isError:!1,isSent:!0})})}),Ei=(t,e,r)=>new Promise(n=>{t.send("REQUEST",{email:e,options:r}),t.onTransition(i=>{i.matches({idle:"error"})?n({error:i.context.error,isError:!0,isSent:!1}):i.matches({idle:"success"})&&n({error:null,isError:!1,isSent:!0})})}),wi=t=>new Promise(e=>{const{changed:r}=t.send("SIGNIN_ANONYMOUS");r||e({isSuccess:!1,isError:!0,error:re,user:null,accessToken:null}),t.onTransition(n=>{n.matches({authentication:"signedIn"})&&e({isSuccess:!0,isError:!1,error:null,user:n.context.user,accessToken:n.context.accessToken.value}),n.matches({authentication:{signedOut:"failed"}})&&e({isSuccess:!1,isError:!0,error:n.context.errors.authentication||null,user:null,accessToken:null})})}),Si=(t,e,r)=>new Promise(n=>{const{changed:i,context:s}=t.send("SIGNIN_PASSWORD",{email:e,password:r});if(!i)return n({accessToken:s.accessToken.value,error:re,isError:!0,isSuccess:!1,needsEmailVerification:!1,needsMfaOtp:!1,mfa:null,user:s.user});t.onTransition(o=>{o.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})?n({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!0,needsMfaOtp:!1,mfa:null,user:null}):o.matches({authentication:{signedOut:"needsMfa"}})?n({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!1,needsMfaOtp:!0,mfa:o.context.mfa,user:null}):o.matches({authentication:{signedOut:"failed"}})?n({accessToken:null,error:o.context.errors.authentication||null,isError:!0,isSuccess:!1,needsEmailVerification:!1,needsMfaOtp:!1,mfa:null,user:null}):o.matches({authentication:"signedIn"})&&n({accessToken:o.context.accessToken.value,error:null,isError:!1,isSuccess:!0,needsEmailVerification:!1,needsMfaOtp:!1,mfa:null,user:o.context.user})})}),kr=(t,e,r)=>new Promise(n=>{const{changed:i}=t.send("PASSWORDLESS_EMAIL",{email:e,options:r});if(!i)return n({error:re,isError:!0,isSuccess:!1});t.onTransition(s=>{s.matches("registration.incomplete.failed")?n({error:s.context.errors.registration||null,isError:!0,isSuccess:!1}):s.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})&&n({error:null,isError:!1,isSuccess:!0})})}),Ti=(t,e)=>new Promise(r=>{const{changed:n,context:i}=t.send({type:"SIGNIN_SECURITY_KEY_EMAIL",email:e});if(!n)return r({accessToken:i.accessToken.value,error:re,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:i.user});t.onTransition(s=>{s.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})?r({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!0,user:null}):s.matches({authentication:{signedOut:"failed"}})?r({accessToken:null,error:s.context.errors.authentication||null,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:null}):s.matches({authentication:"signedIn"})&&r({accessToken:s.context.accessToken.value,error:null,isError:!1,isSuccess:!0,needsEmailVerification:!1,user:s.context.user})})}),bi=(t,e,r)=>new Promise(n=>{const{changed:i,context:s}=t.send("SIGNIN_MFA_TOTP",{otp:e,ticket:r});if(!i)return n({accessToken:s.accessToken.value,error:re,isError:!0,isSuccess:!1,user:s.user});t.onTransition(o=>{o.matches({authentication:{signedOut:"failed"}})?n({accessToken:null,error:o.context.errors.authentication||null,isError:!0,isSuccess:!1,user:null}):o.matches({authentication:"signedIn"})&&n({accessToken:o.context.accessToken.value,error:null,isError:!1,isSuccess:!0,user:o.context.user})})}),xr=(t,e,r)=>new Promise(n=>{const{changed:i}=t.send("PASSWORDLESS_SMS",{phoneNumber:e,options:r});if(!i)return n({error:re,isError:!0,isSuccess:!1,needsOtp:!1});t.onTransition(s=>{s.matches("registration.incomplete.needsOtp")?n({error:null,isError:!1,isSuccess:!1,needsOtp:!0}):s.matches("registration.incomplete.failed")&&n({error:s.context.errors.authentication||null,isError:!0,isSuccess:!1,needsOtp:!1})})}),Ai=(t,e,r)=>new Promise(n=>{const{changed:i}=t.send({type:"PASSWORDLESS_SMS_OTP",phoneNumber:e,otp:r});if(!i)return n({error:re,isError:!0,isSuccess:!1,user:null,accessToken:null});t.onTransition(s=>{s.matches({authentication:"signedIn"})?n({error:null,isError:!1,isSuccess:!0,user:s.context.user,accessToken:s.context.accessToken.value}):s.matches({registration:{incomplete:"failed"}})&&n({error:s.context.errors.authentication||null,isError:!0,isSuccess:!1,user:null,accessToken:null})})}),Oi=async(t,e)=>new Promise(r=>{const{event:n}=t.send("SIGNOUT",{all:e});if(n.type!=="SIGNED_OUT")return r({isSuccess:!1,isError:!0,error:Xn});t.onTransition(i=>{i.matches({authentication:{signedOut:"success"}})?r({isSuccess:!0,isError:!1,error:null}):i.matches("authentication.signedOut.failed")&&r({isSuccess:!1,isError:!0,error:i.context.errors.signout||null})})}),Ir=(t,e,r,n)=>new Promise(i=>{const{changed:s,context:o}=t.send("SIGNUP_EMAIL_PASSWORD",{email:e,password:r,options:n});if(!s)return i({error:re,accessToken:o.accessToken.value,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:o.user});t.onTransition(a=>{a.matches("registration.incomplete.failed")?i({accessToken:null,error:a.context.errors.registration||null,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:null}):a.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})?i({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!0,user:null}):a.matches({authentication:"signedIn",registration:"complete"})&&i({accessToken:a.context.accessToken.value,error:null,isError:!1,isSuccess:!0,needsEmailVerification:!1,user:a.context.user})})}),Ri=(t,e,r)=>new Promise(n=>{const{changed:i,context:s}=t.send("SIGNUP_SECURITY_KEY",{email:e,options:r});if(!i)return n({error:re,accessToken:s.accessToken.value,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:s.user});t.onTransition(o=>{o.matches("registration.incomplete.failed")?n({accessToken:null,error:o.context.errors.registration||null,isError:!0,isSuccess:!1,needsEmailVerification:!1,user:null}):o.matches({authentication:{signedOut:"noErrors"},registration:{incomplete:"needsEmailVerification"}})?n({accessToken:null,error:null,isError:!1,isSuccess:!1,needsEmailVerification:!0,user:null}):o.matches({authentication:"signedIn",registration:"complete"})&&n({accessToken:o.context.accessToken.value,error:null,isError:!1,isSuccess:!0,needsEmailVerification:!1,user:o.context.user})})});class ki{constructor({url:e,autoRefreshToken:r=!0,autoSignIn:n=!0,autoLogin:i,clientStorage:s,clientStorageType:o,clientStorageGetter:a,clientStorageSetter:u,refreshIntervalTime:c,start:l=!0}){var v;this.url=e,this._client=new Rr({backendUrl:e,clientUrl:typeof window<"u"&&((v=window.location)==null?void 0:v.origin)||"",autoRefreshToken:r,autoSignIn:typeof i=="boolean"?i:n,start:l,clientStorage:s,clientStorageType:o,clientStorageGetter:a,clientStorageSetter:u,refreshIntervalTime:c})}async signUp(e){const r=await this.waitUntilReady(),{email:n,options:i}=e;return"securityKey"in e?me(await Ri(r,n,i)):me(await Ir(r,n,e.password,i))}async signIn(e){const r=await this.waitUntilReady();if(!e){const n=await wi(r);return{...me(n),mfa:null}}if("provider"in e){const{provider:n,options:i}=e,s=br(`${this._client.backendUrl}/signin/provider/${n}`,Q(this._client.clientUrl,i));return jt()&&(window.location.href=s),{providerUrl:s,provider:n,session:null,mfa:null,error:null}}if("email"in e&&"password"in e){const n=await Si(r,e.email,e.password);return n.needsEmailVerification?{session:null,mfa:null,error:Zn}:n.needsMfaOtp?{session:null,mfa:n.mfa,error:null}:{...me(n),mfa:null}}if("email"in e&&"securityKey"in e){if(e.securityKey!==!0)throw Error("securityKey must be true");const n=await Ti(r,e.email);return{...me(n),mfa:null}}if("email"in e){const{email:n,options:i}=e,{error:s}=await kr(r,n,i);return{session:null,mfa:null,error:s}}if("phoneNumber"in e&&"otp"in e){const n=await Ai(r,e.phoneNumber,e.otp);return{...me(n),mfa:null}}if("phoneNumber"in e){const{error:n}=await xr(r,e.phoneNumber,e.options);return{error:n,mfa:null,session:null}}if("otp"in e){const n=await bi(r,e.otp,e.ticket);return{...me(n),mfa:null}}return{error:ti,mfa:null,session:null}}async signOut(e){const r=await this.waitUntilReady(),{error:n}=await Oi(r,e==null?void 0:e.all);return{error:n}}async resetPassword({email:e,options:r}){const n=ke(fi(this._client)).start(),{error:i}=await yi(n,e,r);return{error:i}}async changePassword({newPassword:e,ticket:r}){const n=ke(di(this._client)).start(),{error:i}=await gi(n,e,r);return{error:i}}async sendVerificationEmail({email:e,options:r}){const n=ke(hi(this._client)).start(),{error:i}=await Ei(n,e,r);return{error:i}}async changeEmail({newEmail:e,options:r}){const n=ke(li(this._client)).start(),{error:i}=await mi(n,e,r);return{error:i}}async deanonymize(e){const r=await this.waitUntilReady();if(e.signInMethod==="passwordless"){if(e.connection==="email"){const{error:n}=await kr(r,e.email,e.options);return{error:n}}if(e.connection==="sms"){const{error:n}=await xr(r,e.phoneNumber,e.options);return{error:n}}}if(e.signInMethod==="email-password"){const{error:n}=await Ir(r,e.email,e.password,e.options);return{error:n}}throw Error("Unknown deanonymization method")}async addSecurityKey(e){const{error:r,key:n}=await vi(this._client,e);return{error:r,key:n}}onTokenChanged(e){return this._client.subscribe(()=>{var r;const n=(r=this._client.interpreter)==null?void 0:r.onTransition(({event:i,context:s})=>{i.type==="TOKEN_CHANGED"&&e(tt(s))});return()=>n==null?void 0:n.stop()})}onAuthStateChanged(e){return this._client.subscribe(()=>{var r;const n=(r=this._client.interpreter)==null?void 0:r.onTransition(({event:i,context:s})=>{(i.type==="SIGNED_IN"||i.type==="SIGNED_OUT")&&e(i.type,tt(s))});return()=>n==null?void 0:n.stop()})}isAuthenticated(){var e;return!!((e=this._client.interpreter)!=null&&e.getSnapshot().matches({authentication:"signedIn"}))}async isAuthenticatedAsync(){return(await this.waitUntilReady()).getSnapshot().matches({authentication:"signedIn"})}getAuthenticationStatus(){var e;const r=((e=this.client.interpreter)==null?void 0:e.getSnapshot().context.importTokenAttempts)||0;return this.isReady()?{isAuthenticated:this.isAuthenticated(),isLoading:!1,connectionAttempts:r}:{isAuthenticated:!1,isLoading:!0,connectionAttempts:r}}getJWTToken(){return this.getAccessToken()}getAccessToken(){var e;return((e=this._client.interpreter)==null?void 0:e.getSnapshot().context.accessToken.value)??void 0}getDecodedAccessToken(){const e=this.getAccessToken();return e?Bi(e):null}getHasuraClaims(){var e;return((e=this.getDecodedAccessToken())==null?void 0:e["https://hasura.io/jwt/claims"])||null}getHasuraClaim(e){var r;return((r=this.getHasuraClaims())==null?void 0:r[e.startsWith("x-hasura-")?e:`x-hasura-${e}`])||null}async refreshSession(e){try{const r=await this.waitUntilReady();return new Promise(n=>{const i=e||r.getSnapshot().context.refreshToken.value;if(!i)return n({session:null,error:Yn});const{changed:s}=r.send("TRY_TOKEN",{token:i});if(!s)return n({session:null,error:Qn});r.onTransition(o=>{o.matches({token:{idle:"error"}})?n({session:null,error:ei}):o.event.type==="TOKEN_CHANGED"&&n({session:tt(o.context),error:null})})})}catch(r){return{session:null,error:r.message}}}getSession(){var e,r;return tt((r=(e=this._client.interpreter)==null?void 0:e.getSnapshot())==null?void 0:r.context)}getUser(){var e,r,n;return((n=(r=(e=this._client.interpreter)==null?void 0:e.getSnapshot())==null?void 0:r.context)==null?void 0:n.user)||null}waitUntilReady(){const e=this._client.interpreter;if(!e)throw Error("Auth interpreter not set");return e.getSnapshot().hasTag("loading")?new Promise((r,n)=>{let i=setTimeout(()=>n(`The state machine is not yet ready after ${15} seconds.`),15e3);e.onTransition(s=>{if(!s.hasTag("loading"))return clearTimeout(i),r(e)})}):Promise.resolve(e)}isReady(){var e,r;return!((r=(e=this._client.interpreter)==null?void 0:e.getSnapshot())!=null&&r.hasTag("loading"))}get client(){return this._client}}class xi{constructor({url:e}){this.url=e,this.httpClient=Qe.create({baseURL:this.url})}async upload(e){const{formData:r}=e;try{return{fileMetadata:(await this.httpClient.post("/files",r,{headers:{...this.generateUploadHeaders(e),...this.generateAuthHeaders(),"Content-Type":"multipart/form-data"}})).data,error:null}}catch(n){return{fileMetadata:null,error:n}}}async getPresignedUrl(e){try{const{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{const{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){const{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}`}}}class Ii{constructor({url:e,adminSecret:r}){this.url=e,this.api=new xi({url:e}),this.setAdminSecret(r)}async upload(e){let r;"file"in e?(r=new An,r.append("file",e.file)):r=e.formData;const{fileMetadata:n,error:i}=await this.api.upload({...e,formData: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){const{fileId:r}=e;return`${this.url}/files/${r}`}async getPresignedUrl(e){const{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){const{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}}const Nr={progress:null,loaded:0,error:null},Ni=()=>he({predictableActionArguments:!0,schema:{context:{},events:{}},tsTypes:{},context:{...Nr},initial:"idle",on:{DESTROY:{actions:"sendDestroy",target:"stopped"}},states:{idle:{on:{ADD:{actions:"addFile"},UPLOAD:{cond:"hasFile",target:"uploading"}}},uploading:{entry:"resetProgress",on:{UPLOAD_PROGRESS:{actions:["incrementProgress","sendProgress"]},UPLOAD_DONE:"uploaded",UPLOAD_ERROR:"error",CANCEL:"idle"},invoke:{src:"uploadFile"}},uploaded:{entry:["setFileMetadata","sendDone"]},error:{entry:["setError","sendError"]},stopped:{type:"final"}}},{guards:{hasFile:(t,e)=>!!t.file||!!e.file},actions:{incrementProgress:O({loaded:(t,{loaded:e})=>e,progress:(t,{progress:e})=>e}),setFileMetadata:O({id:(t,{id:e})=>e,bucketId:(t,{bucketId:e})=>e,progress:t=>100}),setError:O({error:(t,{error:e})=>e}),sendProgress:()=>{},sendError:()=>{},sendDestroy:()=>{},sendDone:()=>{},resetProgress:O({progress:t=>null,loaded:t=>0}),addFile:O({file:(t,{file:e})=>e,bucketId:(t,{bucketId:e})=>e,id:(t,{id:e})=>e})},services:{uploadFile:(t,e)=>r=>{const n={"Content-Type":"multipart/form-data"},i=e.id||t.id;i&&(n["x-nhost-file-id"]=i);const s=e.bucketId||t.bucketId;s&&(n["x-nhost-bucket-id"]=s);const o=e.file||t.file;n["x-nhost-file-name"]=e.name||o.name;const a=new FormData;a.append("file",o),e.adminSecret&&(n["x-hasura-admin-secret"]=e.adminSecret),e.accessToken&&(n.Authorization=`Bearer ${e.accessToken}`);let u=0;const c=new AbortController;return Qe.post(e.url+"/files",a,{headers:n,signal:c.signal,onUploadProgress:l=>{const v=l.total?Math.round(l.loaded*o.size/l.total):0,h=v-u;u=v,r({type:"UPLOAD_PROGRESS",progress:l.total?Math.round(v*100/l.total):0,loaded:v,additions:h})}}).then(({data:{id:l,bucketId:v}})=>{r({type:"UPLOAD_DONE",id:l,bucketId:v})}).catch(({response:l,message:v})=>{var h,f,d,p;r({type:"UPLOAD_ERROR",error:{status:(l==null?void 0:l.status)??0,message:((f=(h=l==null?void 0:l.data)==null?void 0:h.error)==null?void 0:f.message)||v,error:((p=(d=l==null?void 0:l.data)==null?void 0:d.error)==null?void 0:p.message)||v}})}),()=>{c.abort()}}}}),{pure:Pr,sendParent:$t}=ms,na=()=>he({id:"files-list",schema:{context:{},events:{}},tsTypes:{},predictableActionArguments:!0,context:{progress:null,files:[],loaded:0,total:0},initial:"idle",on:{UPLOAD:{cond:"hasFileToDownload",actions:"addItem",target:"uploading"},ADD:{actions:"addItem"},REMOVE:{actions:"removeItem"}},states:{idle:{entry:["resetProgress","resetLoaded","resetTotal"],on:{CLEAR:{actions:"clearList",target:"idle"}}},uploading:{entry:["upload","startProgress","resetLoaded","resetTotal"],on:{UPLOAD_PROGRESS:{actions:["incrementProgress"]},UPLOAD_DONE:[{cond:"isAllUploaded",target:"uploaded"},{cond:"isAllUploadedOrError",target:"error"}],UPLOAD_ERROR:[{cond:"isAllUploaded",target:"uploaded"},{cond:"isAllUploadedOrError",target:"error"}],CANCEL:{actions:"cancel",target:"idle"}}},uploaded:{entry:"setUploaded",on:{CLEAR:{actions:"clearList",target:"idle"}}},error:{on:{CLEAR:{actions:"clearList",target:"idle"}}}}},{guards:{hasFileToDownload:(t,e)=>t.files.some(r=>r.getSnapshot().matches("idle"))||!!e.files,isAllUploaded:t=>t.files.every(e=>{var r;return(r=e.getSnapshot())==null?void 0:r.matches("uploaded")}),isAllUploadedOrError:t=>t.files.every(e=>{const r=e.getSnapshot();return(r==null?void 0:r.matches("error"))||(r==null?void 0:r.matches("uploaded"))})},actions:{incrementProgress:O((t,e)=>{const r=t.loaded+e.additions,n=Math.round(r*100/t.total);return{...t,loaded:r,progress:n}}),setUploaded:O({progress:t=>100,loaded:({files:t})=>t.map(e=>e.getSnapshot()).filter(e=>e.matches("uploaded")).reduce((e,r)=>{var n;return e+((n=r.context.file)==null?void 0:n.size)},0)}),resetTotal:O({total:({files:t})=>t.map(e=>e.getSnapshot()).filter(e=>!e.matches("uploaded")).reduce((e,r)=>{var n;return e+((n=r.context.file)==null?void 0:n.size)},0)}),resetLoaded:O({loaded:t=>0}),startProgress:O({progress:t=>0}),resetProgress:O({progress:t=>null}),addItem:O((t,{files:e,bucketId:r})=>{const n=e?Array.isArray(e)?e:"length"in e?Array.from(e):[e]:[],i=t.total+n.reduce((o,a)=>o+a.size,0),s=Math.round(t.loaded*100/i);return{files:[...t.files,...n.map(o=>_s(Ni().withConfig({actions:{sendProgress:$t((a,{additions:u})=>({type:"UPLOAD_PROGRESS",additions:u})),sendDone:$t("UPLOAD_DONE"),sendError:$t("UPLOAD_ERROR"),sendDestroy:$t("REMOVE")}}).withContext({...Nr,file:o,bucketId:r}),{sync:!0}))],total:i,loaded:t.loaded,progress:s}}),removeItem:O({files:t=>t.files.filter(e=>{var r,n;const i=(r=e.getSnapshot())==null?void 0:r.matches("stopped");return i&&((n=e.stop)==null||n.call(e)),!i})}),clearList:Pr(t=>t.files.map(e=>V({type:"DESTROY"},{to:e.id}))),upload:Pr((t,e)=>t.files.map(r=>V(e,{to:r.id}))),cancel:Pr(t=>t.files.map(e=>V({type:"CANCEL"},{to:e.id})))}}),ia=async(t,e)=>new Promise(r=>{e.send({type:"UPLOAD",...t}),e.subscribe(n=>{var i;n.matches("error")?r({error:n.context.error,isError:!0,isUploaded:!1}):n.matches("uploaded")&&r({error:null,isError:!1,isUploaded:!0,id:n.context.id,bucketId:n.context.id,name:(i=n.context.file)==null?void 0:i.name})})}),sa=async(t,e)=>new Promise(r=>{e.send({type:"UPLOAD",...t,files:t.files}),e.onTransition(n=>{n.matches("error")?r({errors:n.context.files.filter(i=>{var s;return(s=i.getSnapshot())==null?void 0:s.context.error}),isError:!0,files:[]}):n.matches("uploaded")&&r({errors:[],isError:!1,files:n.context.files})})}),oa=/^((?<protocol>http[s]?):\/\/)?(?<host>localhost)(:(?<port>(\d+|__\w+__)))?$/;function Bt(t,e){const{backendUrl:r,subdomain:n,region:i}=t;if(r)return`${r}/v1/${e}`;if(!n)throw new Error("Either `backendUrl` or `subdomain` must be set.");const s=n.match(oa);if(s!=null&&s.groups){const{protocol:o="http",host:a,port:u=1337}=s.groups,c=ua(e);return c||`${o}://${a}:${u}/v1/${e}`}if(!i)throw new Error('`region` must be set when using a `subdomain` other than "localhost".');return`https://${n}.${e}.${i}.nhost.run/v1`}function aa(){return typeof window<"u"}function ca(){return typeof process<"u"&&process.env}function ua(t){return aa()||!ca()?null:process.env[`NHOST_${t.toUpperCase()}_URL`]}function Pi(t){const e="subdomain"in t||"backendUrl"in t?Bt(t,"auth"):t.authUrl;if(!e)throw new Error("Please provide `subdomain` or `authUrl`.");return new ki({url:e,...t})}function Ui(t){const e="subdomain"in t||"backendUrl"in t?Bt(t,"functions"):t.functionsUrl;if(!e)throw new Error("Please provide `subdomain` or `functionsUrl`.");return new Ci({url:e,...t})}class Ci{constructor(e){const{url:r,adminSecret:n}=e;this.url=r,this.accessToken=null,this.adminSecret=n,this.instance=Qe.create({baseURL:r})}async call(e,r,{useAxios:n=!0,...i}={}){n&&console.warn("nhost.functions.call() will no longer use Axios in the near future. Please add `useAxios: false` in the config argument to use the new implementation.");const s={...this.generateAccessTokenHeaders(),...i==null?void 0:i.headers};let o;try{o=await this.instance.post(e,r,{...i,headers:s})}catch(a){if(a instanceof Error){if(n)return{res:null,error:a};const u=a;return{res:null,error:{error:u.code||"unknown",status:u.status||0,message:u.message}}}}return o?n?{res:o,error:null}:{res:{status:o.status,statusText:o.statusText,data:o.data},error:null}:n?{res:null,error:new Error("Unable to make post request to function")}:{res:null,error:{error:"invalid-response",status:0,message:"Unable to make post request to function"}}}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){return this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:{}}}function _i(t){const e="subdomain"in t||"backendUrl"in t?Bt(t,"graphql"):t.graphqlUrl;if(!e)throw new Error("Please provide `subdomain` or `graphqlUrl`.");return new Di({url:e,...t})}class Di{constructor(e){const{url:r,adminSecret:n}=e;this.url=r,this.accessToken=null,this.adminSecret=n,this.instance=Qe.create({baseURL:r})}async request(e,r,{useAxios:n=!0,...i}={}){const s={"Accept-Encoding":"*",...this.generateAccessTokenHeaders(),...i==null?void 0:i.headers};try{const o="",u=(await this.instance.post("",{operationName:o||void 0,query:typeof e=="string"?e:Le.print(e),variables:r},{...i,headers:s})).data,{data:c}=u;return u.errors?{data:null,error:u.errors}:typeof c!="object"||Array.isArray(c)||c===null?n?{data:null,error:new Error("incorrect response data from GraphQL server")}:{data:null,error:{error:"invalid-response",status:0,message:"incorrect response data from GraphQL server"}}:{data:c,error:null}}catch(o){if(console.error(o),n)return o instanceof Error?{data:null,error:o}:{data:null,error:new Error("Unable to get do GraphQL request")};const a=o;return{data:null,error:{error:a.code||"unknown",status:a.status||0,message:a.message}}}}getUrl(){return this.url}setAccessToken(e){if(!e){this.accessToken=null;return}this.accessToken=e}generateAccessTokenHeaders(){return this.adminSecret?{"x-hasura-admin-secret":this.adminSecret}:this.accessToken?{Authorization:`Bearer ${this.accessToken}`}:{}}}function Li(t){const e="subdomain"in t||"backendUrl"in t?Bt(t,"storage"):t.storageUrl;if(!e)throw new Error("Please provide `subdomain` or `storageUrl`.");return new Ii({url:e,...t})}const la=t=>new Mi(t);class Mi{constructor({refreshIntervalTime:e,clientStorageGetter:r,clientStorageSetter:n,clientStorage:i,clientStorageType:s,autoRefreshToken:o,autoSignIn:a,adminSecret:u,devTools:c,start:l=!0,...v}){this.auth=Pi({refreshIntervalTime:e,clientStorageGetter:r,clientStorageSetter:n,clientStorage:i,clientStorageType:s,autoRefreshToken:o,autoSignIn:a,start:l,...v}),this.storage=Li({adminSecret:u,...v}),this.functions=Ui({adminSecret:u,...v}),this.graphql=_i({adminSecret:u,...v}),this.auth.onAuthStateChanged((h,f)=>{h==="SIGNED_OUT"&&(this.storage.setAccessToken(void 0),this.functions.setAccessToken(void 0),this.graphql.setAccessToken(void 0))}),this.auth.onTokenChanged(h=>{const f=h==null?void 0:h.accessToken;this.storage.setAccessToken(f),this.functions.setAccessToken(f),this.graphql.setAccessToken(f)}),this._adminSecret=u,this.devTools=c}get adminSecret(){return this._adminSecret}set adminSecret(e){this._adminSecret=e,this.storage.setAdminSecret(e)}}E.AuthClient=Rr,E.AuthClientSSR=ea,E.AuthCookieClient=pi,E.CodifiedError=et,E.EMAIL_NEEDS_VERIFICATION=Zn,E.HasuraAuthClient=ki,E.HasuraStorageApi=xi,E.HasuraStorageClient=Ii,E.INITIAL_FILE_CONTEXT=Nr,E.INITIAL_MACHINE_CONTEXT=_t,E.INVALID_EMAIL_ERROR=ce,E.INVALID_MFA_CODE_ERROR=Gn,E.INVALID_MFA_TICKET_ERROR=Jn,E.INVALID_MFA_TYPE_ERROR=Kn,E.INVALID_PASSWORD_ERROR=Ct,E.INVALID_PHONE_NUMBER_ERROR=Sr,E.INVALID_REFRESH_TOKEN=ei,E.INVALID_SIGN_IN_METHOD=ti,E.MIN_PASSWORD_LENGTH=Vn,E.NETWORK_ERROR_CODE=Er,E.NHOST_JWT_EXPIRES_AT_KEY=Ze,E.NHOST_REFRESH_TOKEN_KEY=Xe,E.NO_MFA_TICKET_ERROR=Wn,E.NO_REFRESH_TOKEN=Yn,E.NhostClient=Mi,E.NhostFunctionsClient=Ci,E.NhostGraphqlClient=Di,E.OTHER_ERROR_CODE=wr,E.REFRESH_TOKEN_RETRY_INTERVAL=Hn,E.STATE_ERROR_CODE=Ue,E.TOKEN_REFRESHER_RUNNING_ERROR=Qn,E.TOKEN_REFRESH_MARGIN=zn,E.USER_ALREADY_SIGNED_IN=re,E.USER_NOT_ANONYMOUS=Vo,E.USER_UNAUTHENTICATED=Xn,E.VALIDATION_ERROR_CODE=Y,E.activateMfaPromise=ra,E.addSecurityKeyPromise=vi,E.changeEmailPromise=mi,E.changePasswordPromise=gi,E.createAuthClient=Pi,E.createAuthMachine=ui,E.createChangeEmailMachine=li,E.createChangePasswordMachine=di,E.createEnableMfaMachine=Zo,E.createFileUploadMachine=Ni,E.createFunctionsClient=Ui,E.createGraphqlClient=_i,E.createMultipleFilesUploadMachine=na,E.createNhostClient=la,E.createResetPasswordMachine=fi,E.createSendVerificationEmailMachine=hi,E.createStorageClient=Li,E.encodeQueryParameters=br,E.generateQrCodePromise=ta,E.getAuthenticationResult=me,E.getParameterByName=rt,E.getSession=tt,E.isBrowser=jt,E.isValidEmail=ue,E.isValidPassword=Ft,E.isValidPhoneNumber=Or,E.isValidTicket=ci,E.localStorageGetter=oi,E.localStorageSetter=ai,E.nhostApiClient=ve,E.removeParameterFromWindow=Ar,E.resetPasswordPromise=yi,E.rewriteRedirectTo=Q,E.sendVerificationEmailPromise=Ei,E.signInAnonymousPromise=wi,E.signInEmailPasswordPromise=Si,E.signInEmailPasswordlessPromise=kr,E.signInEmailSecurityKeyPromise=Ti,E.signInMfaTotpPromise=bi,E.signInSmsPasswordlessOtpPromise=Ai,E.signInSmsPasswordlessPromise=xr,E.signOutPromise=Oi,E.signUpEmailPasswordPromise=Ir,E.signUpEmailSecurityKeyPromise=Ri,E.uploadFilePromise=ia,E.uploadMultipleFilesPromise=sa,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
|
22
22
|
//# sourceMappingURL=nhost-js.umd.js.map
|