skapi-js 0.0.78 → 0.0.80
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/skapi.js +1 -1
- package/dist/skapi.js.map +1 -1
- package/dist/skapi.module.js +1 -1
- package/dist/skapi.module.js.map +1 -1
- package/package.json +1 -1
package/dist/skapi.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see skapi.js.LICENSE.txt */
|
|
2
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,(()=>(()=>{var e={742:(e,t)=>{"use strict";t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,s=u(e),o=s[0],a=s[1],c=new i(function(e,t,r){return 3*(t+r)/4-r}(0,o,a)),h=0,l=a>0?o-4:o;for(r=0;r<l;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],c[h++]=t>>16&255,c[h++]=t>>8&255,c[h++]=255&t;return 2===a&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[h++]=255&t),1===a&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[h++]=t>>8&255,c[h++]=255&t),c},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,s=[],o=16383,a=0,u=n-i;a<u;a+=o)s.push(c(e,a,a+o>u?u:a+o));return 1===i?(t=e[n-1],s.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],s.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),s.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=s.length;o<a;++o)r[o]=s[o],n[s.charCodeAt(o)]=o;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,n){for(var i,s,o=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(r[(s=i)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},764:(e,t,r)=>{"use strict";var n=r(742),i=r(645),s=r(826);function o(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=f(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=a(e,n)).write(t,r);return i!==n&&(e=e.slice(0,i)),e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|d(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):f(e,t);if("Buffer"===t.type&&s(t.data))return f(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(h(t),e=a(e,t<0?0:0|d(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function f(e,t){var r=t.length<0?0:0|d(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function d(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return B(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return T(this,t,r);case"ascii":return U(this,t,r);case"latin1":case"binary":return D(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var s,o=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,u/=2,r/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var h=-1;for(s=r;s<a;s++)if(c(e,s)===c(t,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===u)return h*o}else-1!==h&&(s-=s-h),h=-1}else for(r+u>a&&(r=a-u),s=r;s>=0;s--){for(var l=!0,f=0;f<u;f++)if(c(e,s+f)!==c(t,f)){l=!1;break}if(l)return s}return-1}function _(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function A(e,t,r,n){return K(B(t,e.length-r),e,r,n)}function v(e,t,r,n){return K(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function b(e,t,r,n){return v(e,t,r,n)}function S(e,t,r,n){return K(q(t),e,r,n)}function E(e,t,r,n){return K(function(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)n=(r=e.charCodeAt(o))>>8,i=r%256,s.push(i),s.push(n);return s}(t,e.length-r),e,r,n)}function I(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function T(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,o,a,u,c=e[i],h=null,l=c>239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(s=e[i+1]))&&(u=(31&c)<<6|63&s)>127&&(h=u);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(u=(15&c)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=R));return r}(n)}t.lW=u,t.h2=50,u.TYPED_ARRAY_SUPPORT=void 0!==r.g.TYPED_ARRAY_SUPPORT?r.g.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),o(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return h(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return l(null,e)},u.allocUnsafeSlow=function(e){return l(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?T(this,0,e):g.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.h2;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),c=this.slice(n,i),h=e.slice(t,r),l=0;l<a;++l)if(c[l]!==h[l]){s=c[l],o=h[l];break}return s<o?-1:o<s?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return w(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return w(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return _(this,e,t,r);case"utf8":case"utf-8":return A(this,e,t,r);case"ascii":return v(this,e,t,r);case"latin1":case"binary":return b(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var R=4096;function U(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function D(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function C(e,t,r){var n,i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var s="",o=t;o<r;++o)s+=(n=e[o])<16?"0"+n.toString(16):n.toString(16);return s}function P(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function N(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,r,n,i,s){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function M(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function F(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function x(e,t,r,n,s){return s||F(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function V(e,t,r,n,s){return s||F(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;r=new u(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||N(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||N(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||N(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},u.prototype.readInt8=function(e,t){return t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||N(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||N(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){e=+e,t|=0,r|=0,n||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<r&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return x(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return x(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return V(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return V(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,s=n-r;if(this===e&&r<t&&t<n)for(i=s-1;i>=0;--i)e[i+t]=this[i+r];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var o=u.isBuffer(e)?e:B(new u(e,n).toString()),a=o.length;for(s=0;s<r-t;++s)this[s+t]=o[s%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function B(e,t){var r;t=t||1/0;for(var n=e.length,i=null,s=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function K(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}},249:function(e,t,r){var n;e.exports=(n=n||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==r.g&&r.g.crypto&&(n=r.g.crypto),!n)try{n=r(480)}catch(e){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),o={},a=o.lib={},u=a.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=u.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s++){var o=r[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=o<<24-(n+s)%4*8}else for(var a=0;a<i;a+=4)t[n+a>>>2]=r[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=u.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new c.init(t,e)}}),h=o.enc={},l=h.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new c.init(r,t/2)}},f=h.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(r,t)}},d=h.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},p=a.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,s=n.sigBytes,o=this.blockSize,a=s/(4*o),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,h=e.min(4*u,s);if(u){for(var l=0;l<u;l+=o)this._doProcessBlock(i,l);r=i.splice(0,u),n.sigBytes-=h}return new c.init(r,h)},clone:function(){var e=u.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(a.Hasher=p.extend({cfg:u.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new g.HMAC.init(e,r).finalize(t)}}}),o.algo={});return o}(Math),n)},269:function(e,t,r){var n,i,s;e.exports=(n=r(249),s=(i=n).lib.WordArray,i.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],s=0;s<r;s+=3)for(var o=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;a<4&&s+.75*a<r;a++)i.push(n.charAt(o>>>6*(3-a)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var i=0;i<r.length;i++)n[r.charCodeAt(i)]=i}var o=r.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return function(e,t,r){for(var n=[],i=0,o=0;o<t;o++)if(o%4){var a=r[e.charCodeAt(o-1)]<<o%4*2|r[e.charCodeAt(o)]>>>6-o%4*2;n[i>>>2]|=a<<24-i%4*8,i++}return s.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)},10:function(e,t,r){var n;e.exports=(n=r(249),r(153),r(824),n.HmacSHA256)},824:function(e,t,r){var n,i,s;e.exports=(i=(n=r(249)).lib.Base,s=n.enc.Utf8,void(n.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),a=i.words,u=o.words,c=0;c<r;c++)a[c]^=1549556828,u[c]^=909522486;i.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))},433:function(e,t,r){var n;e.exports=(n=r(249),function(){if("function"==typeof ArrayBuffer){var e=n.lib.WordArray,t=e.init,r=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};r.prototype=e}}(),n.lib.WordArray)},153:function(e,t,r){var n;e.exports=(n=r(249),function(e){var t=n,r=t.lib,i=r.WordArray,s=r.Hasher,o=t.algo,a=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],h=o.SHA256=s.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],a=r[4],h=r[5],l=r[6],f=r[7],d=0;d<64;d++){if(d<16)c[d]=0|e[t+d];else{var p=c[d-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],w=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=g+c[d-7]+w+c[d-16]}var m=n&i^n&s^i&s,_=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),A=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&h^~a&l)+u[d]+c[d];f=l,l=h,h=a,a=o+A|0,o=s,s=i,i=n,n=A+(_+m)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+h|0,r[6]=r[6]+l|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=s._createHelper(h),t.HmacSHA256=s._createHmacHelper(h)}(Math),n.SHA256)},645:(e,t)=>{t.read=function(e,t,r,n,i){var s,o,a=8*i-n-1,u=(1<<a)-1,c=u>>1,h=-7,l=r?i-1:0,f=r?-1:1,d=e[t+l];for(l+=f,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+e[t+l],l+=f,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+l],l+=f,h-=8);if(0===s)s=1-c;else{if(s===u)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=c}return(d?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var o,a,u,c=8*s-i-1,h=(1<<c)-1,l=h>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),(t+=o+l>=1?f/u:f*Math.pow(2,1-l))*u>=2&&(o++,u/=2),o+l>=h?(a=0,o=h):o+l>=1?(a=(t*u-1)*Math.pow(2,i),o+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;e[r+d]=255&o,d+=p,o/=256,c-=8);e[r+d-p]|=128*g}},826:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},204:(e,t,r)=>{e.exports=self.fetch||(self.fetch=r(869).default||r(869))},808:(e,t,r)=>{var n,i,s;void 0===(i="function"==typeof(n=s=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(n){function i(){}function s(t,r,s){if("undefined"!=typeof document){"number"==typeof(s=e({path:"/"},i.defaults,s)).expires&&(s.expires=new Date(1*new Date+864e5*s.expires)),s.expires=s.expires?s.expires.toUTCString():"";try{var o=JSON.stringify(r);/^[\{\[]/.test(o)&&(r=o)}catch(e){}r=n.write?n.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var u in s)s[u]&&(a+="; "+u,!0!==s[u]&&(a+="="+s[u].split(";")[0]));return document.cookie=t+"="+r+a}}function o(e,r){if("undefined"!=typeof document){for(var i={},s=document.cookie?document.cookie.split("; "):[],o=0;o<s.length;o++){var a=s[o].split("="),u=a.slice(1).join("=");r||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var c=t(a[0]);if(u=(n.read||n)(u,c)||t(u),r)try{u=JSON.parse(u)}catch(e){}if(i[c]=u,e===c)break}catch(e){}}return e?i[e]:i}}return i.set=s,i.get=function(e){return o(e,!1)},i.getJSON=function(e){return o(e,!0)},i.remove=function(t,r){s(t,"",e(r,{expires:-1}))},i.defaults={},i.withConverter=r,i}((function(){}))})?n.call(t,r,t,e):n)||(e.exports=i),e.exports=s()},869:(e,t,r)=>{"use strict";function n(e,t){return t=t||{},new Promise((function(r,n){var i=new XMLHttpRequest,s=[],o=[],a={},u=function(){return{ok:2==(i.status/100|0),statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:u,headers:{keys:function(){return s},entries:function(){return o},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var c in i.open(t.method||"get",e,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,r){s.push(t=t.toLowerCase()),o.push([t,r]),a[t]=a[t]?a[t]+","+r:r})),r(u())},i.onerror=n,i.withCredentials="include"==t.credentials,t.headers)i.setRequestHeader(c,t.headers[c]);i.send(t.body||null)}))}r.r(t),r.d(t,{default:()=>n})},296:()=>{},480:()=>{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{Skapi:()=>ve,SkapiError:()=>ae});var e,t=function(){function e(e){var t=e||{},r=t.ValidationData,n=t.Username,i=t.Password,s=t.AuthParameters,o=t.ClientMetadata;this.validationData=r||{},this.authParameters=s||{},this.clientMetadata=o||{},this.username=n,this.password=i}var t=e.prototype;return t.getUsername=function(){return this.username},t.getPassword=function(){return this.password},t.getValidationData=function(){return this.validationData},t.getAuthParameters=function(){return this.authParameters},t.getClientMetadata=function(){return this.clientMetadata},e}(),i=r(764),s=r(249),o=r.n(s),a=(r(433),r(153)),u=r.n(a),c=r(10),h=r.n(c);if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==r.g&&r.g.crypto&&(e=r.g.crypto),!e)try{e=r(296)}catch(e){}function l(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")}var f=function(){function e(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length}var t=e.prototype;return t.random=function(t){for(var r=[],n=0;n<t;n+=4)r.push(l());return new e(r,t)},t.toString=function(){return function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")}(this)},e}();const d=p;function p(e,t){null!=e&&this.fromString(e,t)}function g(){return new p(null)}var y,w="undefined"!=typeof navigator;w&&"Microsoft Internet Explorer"==navigator.appName?(p.prototype.am=function(e,t,r,n,i,s){for(var o=32767&t,a=t>>15;--s>=0;){var u=32767&this[e],c=this[e++]>>15,h=a*u+c*o;i=((u=o*u+((32767&h)<<15)+r[n]+(1073741823&i))>>>30)+(h>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i},y=30):w&&"Netscape"!=navigator.appName?(p.prototype.am=function(e,t,r,n,i,s){for(;--s>=0;){var o=t*this[e++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},y=26):(p.prototype.am=function(e,t,r,n,i,s){for(var o=16383&t,a=t>>14;--s>=0;){var u=16383&this[e],c=this[e++]>>14,h=a*u+c*o;i=((u=o*u+((16383&h)<<14)+r[n]+i)>>28)+(h>>14)+a*c,r[n++]=268435455&u}return i},y=28),p.prototype.DB=y,p.prototype.DM=(1<<y)-1,p.prototype.DV=1<<y,p.prototype.FV=Math.pow(2,52),p.prototype.F1=52-y,p.prototype.F2=2*y-52;var m,_,A=new Array;for(m="0".charCodeAt(0),_=0;_<=9;++_)A[m++]=_;for(m="a".charCodeAt(0),_=10;_<36;++_)A[m++]=_;for(m="A".charCodeAt(0),_=10;_<36;++_)A[m++]=_;function v(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function b(e,t){var r=A[e.charCodeAt(t)];return null==r?-1:r}function S(e){var t=g();return t.fromInt(e),t}function E(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function I(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function T(e){return i.lW.from((new f).random(e).toString(),"hex")}I.prototype.convert=function(e){var t=g();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(p.ZERO)>0&&this.m.subTo(t,t),t},I.prototype.revert=function(e){var t=g();return e.copyTo(t),this.reduce(t),t},I.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},I.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},I.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},p.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},p.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},p.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,s=0;--n>=0;){var o=b(e,n);o<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==s?this[this.t++]=o:s+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=r)>=this.DB&&(s-=this.DB))}this.clamp(),i&&p.ZERO.subTo(this,this)},p.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},p.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},p.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s},p.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,s=(1<<i)-1,o=Math.floor(e/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t[r+o+1]=this[r]>>i|a,a=(this[r]&s)<<n;for(r=o-1;r>=0;--r)t[r]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},p.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,s=(1<<n)-1;t[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)t[o-r-1]|=(this[o]&s)<<i,t[o-r]=this[o]>>n;n>0&&(t[this.t-r-1]|=(this.s&s)<<i),t.t=this.t-r,t.clamp()}},p.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},p.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i<n.t;++i)t[i+r.t]=r.am(0,n[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&p.ZERO.subTo(t,t)},p.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},p.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=g());var s=g(),o=this.s,a=e.s,u=this.DB-E(n[n.t-1]);u>0?(n.lShiftTo(u,s),i.lShiftTo(u,r)):(n.copyTo(s),i.copyTo(r));var c=s.t,h=s[c-1];if(0!=h){var l=h*(1<<this.F1)+(c>1?s[c-2]>>this.F2:0),f=this.FV/l,d=(1<<this.F1)/l,y=1<<this.F2,w=r.t,m=w-c,_=null==t?g():t;for(s.dlShiftTo(m,_),r.compareTo(_)>=0&&(r[r.t++]=1,r.subTo(_,r)),p.ONE.dlShiftTo(c,_),_.subTo(s,s);s.t<c;)s[s.t++]=0;for(;--m>=0;){var A=r[--w]==h?this.DM:Math.floor(r[w]*f+(r[w-1]+y)*d);if((r[w]+=s.am(0,A,r,m,0,c))<A)for(s.dlShiftTo(m,_),r.subTo(_,r);r[w]<--A;)r.subTo(_,r)}null!=t&&(r.drShiftTo(c,t),o!=a&&p.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),o<0&&p.ZERO.subTo(r,r)}}},p.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},p.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},p.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");t=2}var r,n=(1<<t)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(i=!0,s=v(r));o>=0;)a<t?(r=(this[o]&(1<<a)-1)<<t-a,r|=this[--o]>>(a+=this.DB-t)):(r=this[o]>>(a-=t)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=v(r));return i?s:"0"},p.prototype.negate=function(){var e=g();return p.ZERO.subTo(this,e),e},p.prototype.abs=function(){return this.s<0?this.negate():this},p.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},p.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+E(this[this.t-1]^this.s&this.DM)},p.prototype.mod=function(e){var t=g();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(p.ZERO)>0&&e.subTo(t,t),t},p.prototype.equals=function(e){return 0==this.compareTo(e)},p.prototype.add=function(e){var t=g();return this.addTo(e,t),t},p.prototype.subtract=function(e){var t=g();return this.subTo(e,t),t},p.prototype.multiply=function(e){var t=g();return this.multiplyTo(e,t),t},p.prototype.divide=function(e){var t=g();return this.divRemTo(e,t,null),t},p.prototype.modPow=function(e,t,r){var n,i=e.bitLength(),s=S(1),o=new I(t);if(i<=0)return s;n=i<18?1:i<48?3:i<144?4:i<768?5:6;var a=new Array,u=3,c=n-1,h=(1<<n)-1;if(a[1]=o.convert(this),n>1){var l=g();for(o.sqrTo(a[1],l);u<=h;)a[u]=g(),o.mulTo(l,a[u-2],a[u]),u+=2}var f,d,p=e.t-1,y=!0,w=g();for(i=E(e[p])-1;p>=0;){for(i>=c?f=e[p]>>i-c&h:(f=(e[p]&(1<<i+1)-1)<<c-i,p>0&&(f|=e[p-1]>>this.DB+i-c)),u=n;0==(1&f);)f>>=1,--u;if((i-=u)<0&&(i+=this.DB,--p),y)a[f].copyTo(s),y=!1;else{for(;u>1;)o.sqrTo(s,w),o.sqrTo(w,s),u-=2;u>0?o.sqrTo(s,w):(d=s,s=w,w=d),o.mulTo(w,a[f],s)}for(;p>=0&&0==(e[p]&1<<i);)o.sqrTo(s,w),d=s,s=w,w=d,--i<0&&(i=this.DB-1,--p)}var m=o.revert(s);return r(null,m),m},p.ZERO=S(0),p.ONE=S(1);var R=/^[89a-f]/i,U=function(){function e(e){this.N=new d("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",16),this.g=new d("2",16),this.k=new d(this.hexHash(""+this.padHex(this.N)+this.padHex(this.g)),16),this.smallAValue=this.generateRandomSmallA(),this.getLargeAValue((function(){})),this.infoBits=i.lW.from("Caldera Derived Key","utf8"),this.poolName=e}var t=e.prototype;return t.getSmallAValue=function(){return this.smallAValue},t.getLargeAValue=function(e){var t=this;this.largeAValue?e(null,this.largeAValue):this.calculateA(this.smallAValue,(function(r,n){r&&e(r,null),t.largeAValue=n,e(null,t.largeAValue)}))},t.generateRandomSmallA=function(){var e=T(128).toString("hex");return new d(e,16)},t.generateRandomString=function(){return T(40).toString("base64")},t.getRandomPassword=function(){return this.randomPassword},t.getSaltDevices=function(){return this.SaltToHashDevices},t.getVerifierDevices=function(){return this.verifierDevices},t.generateHashDevice=function(e,t,r){var n=this;this.randomPassword=this.generateRandomString();var i=""+e+t+":"+this.randomPassword,s=this.hash(i),o=T(16).toString("hex");this.SaltToHashDevices=this.padHex(new d(o,16)),this.g.modPow(new d(this.hexHash(this.SaltToHashDevices+s),16),this.N,(function(e,t){e&&r(e,null),n.verifierDevices=n.padHex(t),r(null,null)}))},t.calculateA=function(e,t){var r=this;this.g.modPow(e,this.N,(function(e,n){e&&t(e,null),n.mod(r.N).equals(d.ZERO)&&t(new Error("Illegal paramater. A mod N cannot be 0."),null),t(null,n)}))},t.calculateU=function(e,t){return this.UHexHash=this.hexHash(this.padHex(e)+this.padHex(t)),new d(this.UHexHash,16)},t.hash=function(e){var t=e instanceof i.lW?o().lib.WordArray.create(e):e,r=u()(t).toString();return new Array(64-r.length).join("0")+r},t.hexHash=function(e){return this.hash(i.lW.from(e,"hex"))},t.computehkdf=function(e,t){var r=o().lib.WordArray.create(i.lW.concat([this.infoBits,i.lW.from(String.fromCharCode(1),"utf8")])),n=e instanceof i.lW?o().lib.WordArray.create(e):e,s=t instanceof i.lW?o().lib.WordArray.create(t):t,a=h()(n,s),u=h()(r,a);return i.lW.from(u.toString(),"hex").slice(0,16)},t.getPasswordAuthenticationKey=function(e,t,r,n,s){var o=this;if(r.mod(this.N).equals(d.ZERO))throw new Error("B cannot be zero.");if(this.UValue=this.calculateU(this.largeAValue,r),this.UValue.equals(d.ZERO))throw new Error("U cannot be zero.");var a=""+this.poolName+e+":"+t,u=this.hash(a),c=new d(this.hexHash(this.padHex(n)+u),16);this.calculateS(c,r,(function(e,t){e&&s(e,null);var r=o.computehkdf(i.lW.from(o.padHex(t),"hex"),i.lW.from(o.padHex(o.UValue),"hex"));s(null,r)}))},t.calculateS=function(e,t,r){var n=this;this.g.modPow(e,this.N,(function(i,s){i&&r(i,null),t.subtract(n.k.multiply(s)).modPow(n.smallAValue.add(n.UValue.multiply(e)),n.N,(function(e,t){e&&r(e,null),r(null,t.mod(n.N))}))}))},t.getNewPasswordRequiredChallengeUserAttributePrefix=function(){return"userAttributes."},t.padHex=function(e){if(!(e instanceof d))throw new Error("Not a BigInteger");var t=e.compareTo(d.ZERO)<0,r=e.abs().toString(16);if(r=r.length%2!=0?"0"+r:r,r=R.test(r)?"00"+r:r,t){var n=r.split("").map((function(e){var t=15&~parseInt(e,16);return"0123456789ABCDEF".charAt(t)})).join("");(r=new d(n,16).add(d.ONE).toString(16)).toUpperCase().startsWith("FF8")&&(r=r.substring(2))}return r},e}(),D=function(){function e(e){this.jwtToken=e||"",this.payload=this.decodePayload()}var t=e.prototype;return t.getJwtToken=function(){return this.jwtToken},t.getExpiration=function(){return this.payload.exp},t.getIssuedAt=function(){return this.payload.iat},t.decodePayload=function(){var e=this.jwtToken.split(".")[1];try{return JSON.parse(i.lW.from(e,"base64").toString("utf8"))}catch(e){return{}}},e}();function C(e,t){return C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},C(e,t)}var P=function(e){var t,r;function n(t){var r=(void 0===t?{}:t).AccessToken;return e.call(this,r||"")||this}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,C(t,r),n}(D);function N(e,t){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},N(e,t)}var k=function(e){var t,r;function n(t){var r=(void 0===t?{}:t).IdToken;return e.call(this,r||"")||this}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,N(t,r),n}(D),O=r(269),M=r.n(O),F=function(){function e(e){var t=(void 0===e?{}:e).RefreshToken;this.token=t||""}return e.prototype.getToken=function(){return this.token},e}(),x=function(){function e(e){var t=void 0===e?{}:e,r=t.IdToken,n=t.RefreshToken,i=t.AccessToken,s=t.ClockDrift;if(null==i||null==r)throw new Error("Id token and Access Token must be present.");this.idToken=r,this.refreshToken=n,this.accessToken=i,this.clockDrift=void 0===s?this.calculateClockDrift():s}var t=e.prototype;return t.getIdToken=function(){return this.idToken},t.getRefreshToken=function(){return this.refreshToken},t.getAccessToken=function(){return this.accessToken},t.getClockDrift=function(){return this.clockDrift},t.calculateClockDrift=function(){return Math.floor(new Date/1e3)-Math.min(this.accessToken.getIssuedAt(),this.idToken.getIssuedAt())},t.isValid=function(){var e=Math.floor(new Date/1e3)-this.clockDrift;return e<this.accessToken.getExpiration()&&e<this.idToken.getExpiration()},e}(),V=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],L=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],B=function(){function e(){}return e.prototype.getNowString=function(){var e=new Date,t=L[e.getUTCDay()],r=V[e.getUTCMonth()],n=e.getUTCDate(),i=e.getUTCHours();i<10&&(i="0"+i);var s=e.getUTCMinutes();s<10&&(s="0"+s);var o=e.getUTCSeconds();return o<10&&(o="0"+o),t+" "+r+" "+n+" "+i+":"+s+":"+o+" UTC "+e.getUTCFullYear()},e}(),q=function(){function e(e){var t=void 0===e?{}:e,r=t.Name,n=t.Value;this.Name=r||"",this.Value=n||""}var t=e.prototype;return t.getValue=function(){return this.Value},t.setValue=function(e){return this.Value=e,this},t.getName=function(){return this.Name},t.setName=function(e){return this.Name=e,this},t.toString=function(){return JSON.stringify(this)},t.toJSON=function(){return{Name:this.Name,Value:this.Value}},e}(),K={},j=function(){function e(){}return e.setItem=function(e,t){return K[e]=t,K[e]},e.getItem=function(e){return Object.prototype.hasOwnProperty.call(K,e)?K[e]:void 0},e.removeItem=function(e){return delete K[e]},e.clear=function(){return K={}},e}(),W=function(){function e(){try{this.storageWindow=window.localStorage,this.storageWindow.setItem("aws.cognito.test-ls",1),this.storageWindow.removeItem("aws.cognito.test-ls")}catch(e){this.storageWindow=j}}return e.prototype.getStorage=function(){return this.storageWindow},e}(),H="undefined"!=typeof navigator?navigator.userAgent:"nodejs",J=function(){function e(e){if(null==e||null==e.Username||null==e.Pool)throw new Error("Username and Pool information are required.");this.username=e.Username||"",this.pool=e.Pool,this.Session=null,this.client=e.Pool.client,this.signInUserSession=null,this.authenticationFlowType="USER_SRP_AUTH",this.storage=e.Storage||(new W).getStorage(),this.keyPrefix="CognitoIdentityServiceProvider."+this.pool.getClientId(),this.userDataKey=this.keyPrefix+"."+this.username+".userData"}var t=e.prototype;return t.setSignInUserSession=function(e){this.clearCachedUserData(),this.signInUserSession=e,this.cacheTokens()},t.getSignInUserSession=function(){return this.signInUserSession},t.getUsername=function(){return this.username},t.getAuthenticationFlowType=function(){return this.authenticationFlowType},t.setAuthenticationFlowType=function(e){this.authenticationFlowType=e},t.initiateAuth=function(e,t){var r=this,n=e.getAuthParameters();n.USERNAME=this.username;var i=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),s={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:n,ClientMetadata:i};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",s,(function(e,n){if(e)return t.onFailure(e);var i=n.ChallengeName,s=n.ChallengeParameters;return"CUSTOM_CHALLENGE"===i?(r.Session=n.Session,t.customChallenge(s)):(r.signInUserSession=r.getCognitoUserSession(n.AuthenticationResult),r.cacheTokens(),t.onSuccess(r.signInUserSession))}))},t.authenticateUser=function(e,t){return"USER_PASSWORD_AUTH"===this.authenticationFlowType?this.authenticateUserPlainUsernamePassword(e,t):"USER_SRP_AUTH"===this.authenticationFlowType||"CUSTOM_AUTH"===this.authenticationFlowType?this.authenticateUserDefaultAuth(e,t):t.onFailure(new Error("Authentication flow type is invalid."))},t.authenticateUserDefaultAuth=function(e,t){var r,n,s=this,a=new U(this.pool.getUserPoolName()),u=new B,c={};null!=this.deviceKey&&(c.DEVICE_KEY=this.deviceKey),c.USERNAME=this.username,a.getLargeAValue((function(l,f){l&&t.onFailure(l),c.SRP_A=f.toString(16),"CUSTOM_AUTH"===s.authenticationFlowType&&(c.CHALLENGE_NAME="SRP_A");var p=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),g={AuthFlow:s.authenticationFlowType,ClientId:s.pool.getClientId(),AuthParameters:c,ClientMetadata:p};s.getUserContextData(s.username)&&(g.UserContextData=s.getUserContextData(s.username)),s.client.request("InitiateAuth",g,(function(c,l){if(c)return t.onFailure(c);var f=l.ChallengeParameters;s.username=f.USER_ID_FOR_SRP,s.userDataKey=s.keyPrefix+"."+s.username+".userData",r=new d(f.SRP_B,16),n=new d(f.SALT,16),s.getCachedDeviceKeyAndPassword(),a.getPasswordAuthenticationKey(s.username,e.getPassword(),r,n,(function(e,r){e&&t.onFailure(e);var n=u.getNowString(),c=o().lib.WordArray.create(i.lW.concat([i.lW.from(s.pool.getUserPoolName(),"utf8"),i.lW.from(s.username,"utf8"),i.lW.from(f.SECRET_BLOCK,"base64"),i.lW.from(n,"utf8")])),d=o().lib.WordArray.create(r),g=M().stringify(h()(c,d)),y={};y.USERNAME=s.username,y.PASSWORD_CLAIM_SECRET_BLOCK=f.SECRET_BLOCK,y.TIMESTAMP=n,y.PASSWORD_CLAIM_SIGNATURE=g,null!=s.deviceKey&&(y.DEVICE_KEY=s.deviceKey);var w={ChallengeName:"PASSWORD_VERIFIER",ClientId:s.pool.getClientId(),ChallengeResponses:y,Session:l.Session,ClientMetadata:p};s.getUserContextData()&&(w.UserContextData=s.getUserContextData()),function e(t,r){return s.client.request("RespondToAuthChallenge",t,(function(n,i){return n&&"ResourceNotFoundException"===n.code&&-1!==n.message.toLowerCase().indexOf("device")?(y.DEVICE_KEY=null,s.deviceKey=null,s.randomPassword=null,s.deviceGroupKey=null,s.clearCachedDeviceKeyAndPassword(),e(t,r)):r(n,i)}))}(w,(function(e,r){return e?t.onFailure(e):s.authenticateUserInternal(r,a,t)}))}))}))}))},t.authenticateUserPlainUsernamePassword=function(e,t){var r=this,n={};if(n.USERNAME=this.username,n.PASSWORD=e.getPassword(),n.PASSWORD){var i=new U(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(n.DEVICE_KEY=this.deviceKey);var s=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),o={AuthFlow:"USER_PASSWORD_AUTH",ClientId:this.pool.getClientId(),AuthParameters:n,ClientMetadata:s};this.getUserContextData(this.username)&&(o.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",o,(function(e,n){return e?t.onFailure(e):r.authenticateUserInternal(n,i,t)}))}else t.onFailure(new Error("PASSWORD parameter is required"))},t.authenticateUserInternal=function(e,t,r){var n=this,s=e.ChallengeName,o=e.ChallengeParameters;if("SMS_MFA"===s)return this.Session=e.Session,r.mfaRequired(s,o);if("SELECT_MFA_TYPE"===s)return this.Session=e.Session,r.selectMFAType(s,o);if("MFA_SETUP"===s)return this.Session=e.Session,r.mfaSetup(s,o);if("SOFTWARE_TOKEN_MFA"===s)return this.Session=e.Session,r.totpRequired(s,o);if("CUSTOM_CHALLENGE"===s)return this.Session=e.Session,r.customChallenge(o);if("NEW_PASSWORD_REQUIRED"===s){this.Session=e.Session;var a=null,u=null,c=[],h=t.getNewPasswordRequiredChallengeUserAttributePrefix();if(o&&(a=JSON.parse(e.ChallengeParameters.userAttributes),u=JSON.parse(e.ChallengeParameters.requiredAttributes)),u)for(var l=0;l<u.length;l++)c[l]=u[l].substr(h.length);return r.newPasswordRequired(a,c)}if("DEVICE_SRP_AUTH"===s)return this.Session=e.Session,void this.getDeviceResponse(r);this.signInUserSession=this.getCognitoUserSession(e.AuthenticationResult),this.challengeName=s,this.cacheTokens();var f=e.AuthenticationResult.NewDeviceMetadata;if(null==f)return r.onSuccess(this.signInUserSession);t.generateHashDevice(e.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,e.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(s){if(s)return r.onFailure(s);var o={Salt:i.lW.from(t.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:i.lW.from(t.getVerifierDevices(),"hex").toString("base64")};n.verifierDevices=o.PasswordVerifier,n.deviceGroupKey=f.DeviceGroupKey,n.randomPassword=t.getRandomPassword(),n.client.request("ConfirmDevice",{DeviceKey:f.DeviceKey,AccessToken:n.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:o,DeviceName:H},(function(t,i){return t?r.onFailure(t):(n.deviceKey=e.AuthenticationResult.NewDeviceMetadata.DeviceKey,n.cacheDeviceKeyAndPassword(),!0===i.UserConfirmationNecessary?r.onSuccess(n.signInUserSession,i.UserConfirmationNecessary):r.onSuccess(n.signInUserSession))}))}))},t.completeNewPasswordChallenge=function(e,t,r,n){var i=this;if(!e)return r.onFailure(new Error("New password is required."));var s=new U(this.pool.getUserPoolName()),o=s.getNewPasswordRequiredChallengeUserAttributePrefix(),a={};t&&Object.keys(t).forEach((function(e){a[o+e]=t[e]})),a.NEW_PASSWORD=e,a.USERNAME=this.username;var u={ChallengeName:"NEW_PASSWORD_REQUIRED",ClientId:this.pool.getClientId(),ChallengeResponses:a,Session:this.Session,ClientMetadata:n};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,t){return e?r.onFailure(e):i.authenticateUserInternal(t,s,r)}))},t.getDeviceResponse=function(e,t){var r=this,n=new U(this.deviceGroupKey),s=new B,a={};a.USERNAME=this.username,a.DEVICE_KEY=this.deviceKey,n.getLargeAValue((function(u,c){u&&e.onFailure(u),a.SRP_A=c.toString(16);var l={ChallengeName:"DEVICE_SRP_AUTH",ClientId:r.pool.getClientId(),ChallengeResponses:a,ClientMetadata:t,Session:r.Session};r.getUserContextData()&&(l.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",l,(function(t,a){if(t)return e.onFailure(t);var u=a.ChallengeParameters,c=new d(u.SRP_B,16),l=new d(u.SALT,16);n.getPasswordAuthenticationKey(r.deviceKey,r.randomPassword,c,l,(function(t,n){if(t)return e.onFailure(t);var c=s.getNowString(),l=o().lib.WordArray.create(i.lW.concat([i.lW.from(r.deviceGroupKey,"utf8"),i.lW.from(r.deviceKey,"utf8"),i.lW.from(u.SECRET_BLOCK,"base64"),i.lW.from(c,"utf8")])),f=o().lib.WordArray.create(n),d=M().stringify(h()(l,f)),p={};p.USERNAME=r.username,p.PASSWORD_CLAIM_SECRET_BLOCK=u.SECRET_BLOCK,p.TIMESTAMP=c,p.PASSWORD_CLAIM_SIGNATURE=d,p.DEVICE_KEY=r.deviceKey;var g={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:r.pool.getClientId(),ChallengeResponses:p,Session:a.Session};r.getUserContextData()&&(g.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",g,(function(t,n){return t?e.onFailure(t):(r.signInUserSession=r.getCognitoUserSession(n.AuthenticationResult),r.cacheTokens(),e.onSuccess(r.signInUserSession))}))}))}))}))},t.confirmRegistration=function(e,t,r,n){var i={ClientId:this.pool.getClientId(),ConfirmationCode:e,Username:this.username,ForceAliasCreation:t,ClientMetadata:n};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",i,(function(e){return e?r(e,null):r(null,"SUCCESS")}))},t.sendCustomChallengeAnswer=function(e,t,r){var n=this,i={};i.USERNAME=this.username,i.ANSWER=e;var s=new U(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(i.DEVICE_KEY=this.deviceKey);var o={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:i,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:r};this.getUserContextData()&&(o.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",o,(function(e,r){return e?t.onFailure(e):n.authenticateUserInternal(r,s,t)}))},t.sendMFACode=function(e,t,r,n){var s=this,o={};o.USERNAME=this.username,o.SMS_MFA_CODE=e;var a=r||"SMS_MFA";"SOFTWARE_TOKEN_MFA"===a&&(o.SOFTWARE_TOKEN_MFA_CODE=e),null!=this.deviceKey&&(o.DEVICE_KEY=this.deviceKey);var u={ChallengeName:a,ChallengeResponses:o,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:n};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,r){if(e)return t.onFailure(e);if("DEVICE_SRP_AUTH"!==r.ChallengeName){if(s.signInUserSession=s.getCognitoUserSession(r.AuthenticationResult),s.cacheTokens(),null==r.AuthenticationResult.NewDeviceMetadata)return t.onSuccess(s.signInUserSession);var n=new U(s.pool.getUserPoolName());n.generateHashDevice(r.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,r.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(e){if(e)return t.onFailure(e);var o={Salt:i.lW.from(n.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:i.lW.from(n.getVerifierDevices(),"hex").toString("base64")};s.verifierDevices=o.PasswordVerifier,s.deviceGroupKey=r.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,s.randomPassword=n.getRandomPassword(),s.client.request("ConfirmDevice",{DeviceKey:r.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:s.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:o,DeviceName:H},(function(e,n){return e?t.onFailure(e):(s.deviceKey=r.AuthenticationResult.NewDeviceMetadata.DeviceKey,s.cacheDeviceKeyAndPassword(),!0===n.UserConfirmationNecessary?t.onSuccess(s.signInUserSession,n.UserConfirmationNecessary):t.onSuccess(s.signInUserSession))}))}))}else s.getDeviceResponse(t)}))},t.changePassword=function(e,t,r,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:e,ProposedPassword:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:n},(function(e){return e?r(e,null):r(null,"SUCCESS")}))},t.enableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var t=[];t.push({DeliveryMedium:"SMS",AttributeName:"phone_number"}),this.client.request("SetUserSettings",{MFAOptions:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.setUserMfaPreference=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:e,SoftwareTokenMfaSettings:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?r(e,null):r(null,"SUCCESS")}))},t.disableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("SetUserSettings",{MFAOptions:[],AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.deleteUser=function(e,t){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("DeleteUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:t},(function(t){return t?e(t,null):(r.clearCachedUser(),e(null,"SUCCESS"))}))},t.updateAttributes=function(e,t,r){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("UpdateUserAttributes",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserAttributes:e,ClientMetadata:r},(function(e){return e?t(e,null):n.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.getUserAttributes=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,r){if(t)return e(t,null);for(var n=[],i=0;i<r.UserAttributes.length;i++){var s={Name:r.UserAttributes[i].Name,Value:r.UserAttributes[i].Value},o=new q(s);n.push(o)}return e(null,n)}))},t.getMFAOptions=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,r){return t?e(t,null):e(null,r.MFAOptions)}))},t.createGetUserRequest=function(){return this.client.promisifyRequest("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()})},t.refreshSessionIfPossible=function(e){var t=this;return void 0===e&&(e={}),new Promise((function(r){var n=t.signInUserSession.getRefreshToken();n&&n.getToken()?t.refreshSession(n,r,e.clientMetadata):r()}))},t.getUserData=function(e,t){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return this.clearCachedUserData(),e(new Error("User is not authenticated"),null);var n=this.getUserDataFromCache();if(n)if(this.isFetchUserDataAndTokenRequired(t))this.fetchUserData().then((function(e){return r.refreshSessionIfPossible(t).then((function(){return e}))})).then((function(t){return e(null,t)})).catch(e);else try{return void e(null,JSON.parse(n))}catch(t){return this.clearCachedUserData(),void e(t,null)}else this.fetchUserData().then((function(t){e(null,t)})).catch(e)},t.getUserDataFromCache=function(){return this.storage.getItem(this.userDataKey)},t.isFetchUserDataAndTokenRequired=function(e){var t=(e||{}).bypassCache;return void 0!==t&&t},t.fetchUserData=function(){var e=this;return this.createGetUserRequest().then((function(t){return e.cacheUserData(t),t}))},t.deleteAttributes=function(e,t){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("DeleteUserAttributes",{UserAttributeNames:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?t(e,null):r.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.resendConfirmationCode=function(e,t){var r={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.client.request("ResendConfirmationCode",r,(function(t,r){return t?e(t,null):e(null,r)}))},t.getSession=function(e,t){if(void 0===t&&(t={}),null==this.username)return e(new Error("Username is null. Cannot retrieve a new session"),null);if(null!=this.signInUserSession&&this.signInUserSession.isValid())return e(null,this.signInUserSession);var r="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,n=r+".idToken",i=r+".accessToken",s=r+".refreshToken",o=r+".clockDrift";if(this.storage.getItem(n)){var a=new k({IdToken:this.storage.getItem(n)}),u=new P({AccessToken:this.storage.getItem(i)}),c=new F({RefreshToken:this.storage.getItem(s)}),h=parseInt(this.storage.getItem(o),0)||0,l=new x({IdToken:a,AccessToken:u,RefreshToken:c,ClockDrift:h});if(l.isValid())return this.signInUserSession=l,e(null,this.signInUserSession);if(!c.getToken())return e(new Error("Cannot retrieve a new session. Please authenticate."),null);this.refreshSession(c,e,t.clientMetadata)}else e(new Error("Local storage is missing an ID Token, Please authenticate"),null)},t.refreshSession=function(e,t,r){var n=this,i=this.pool.wrapRefreshSessionCallback?this.pool.wrapRefreshSessionCallback(t):t,s={};s.REFRESH_TOKEN=e.getToken();var o="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=o+".LastAuthUser";if(this.storage.getItem(a)){this.username=this.storage.getItem(a);var u=o+"."+this.username+".deviceKey";this.deviceKey=this.storage.getItem(u),s.DEVICE_KEY=this.deviceKey}var c={ClientId:this.pool.getClientId(),AuthFlow:"REFRESH_TOKEN_AUTH",AuthParameters:s,ClientMetadata:r};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",c,(function(t,r){if(t)return"NotAuthorizedException"===t.code&&n.clearCachedUser(),i(t,null);if(r){var s=r.AuthenticationResult;return Object.prototype.hasOwnProperty.call(s,"RefreshToken")||(s.RefreshToken=e.getToken()),n.signInUserSession=n.getCognitoUserSession(s),n.cacheTokens(),i(null,n.signInUserSession)}}))},t.cacheTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",r=e+"."+this.username+".accessToken",n=e+"."+this.username+".refreshToken",i=e+"."+this.username+".clockDrift",s=e+".LastAuthUser";this.storage.setItem(t,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(r,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(n,this.signInUserSession.getRefreshToken().getToken()),this.storage.setItem(i,""+this.signInUserSession.getClockDrift()),this.storage.setItem(s,this.username)},t.cacheUserData=function(e){this.storage.setItem(this.userDataKey,JSON.stringify(e))},t.clearCachedUserData=function(){this.storage.removeItem(this.userDataKey)},t.clearCachedUser=function(){this.clearCachedTokens(),this.clearCachedUserData()},t.cacheDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",r=e+".randomPasswordKey",n=e+".deviceGroupKey";this.storage.setItem(t,this.deviceKey),this.storage.setItem(r,this.randomPassword),this.storage.setItem(n,this.deviceGroupKey)},t.getCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",r=e+".randomPasswordKey",n=e+".deviceGroupKey";this.storage.getItem(t)&&(this.deviceKey=this.storage.getItem(t),this.randomPassword=this.storage.getItem(r),this.deviceGroupKey=this.storage.getItem(n))},t.clearCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",r=e+".randomPasswordKey",n=e+".deviceGroupKey";this.storage.removeItem(t),this.storage.removeItem(r),this.storage.removeItem(n)},t.clearCachedTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",r=e+"."+this.username+".accessToken",n=e+"."+this.username+".refreshToken",i=e+".LastAuthUser",s=e+"."+this.username+".clockDrift";this.storage.removeItem(t),this.storage.removeItem(r),this.storage.removeItem(n),this.storage.removeItem(i),this.storage.removeItem(s)},t.getCognitoUserSession=function(e){var t=new k(e),r=new P(e),n=new F(e);return new x({IdToken:t,AccessToken:r,RefreshToken:n})},t.forgotPassword=function(e,t){var r={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.getUserContextData()&&(r.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",r,(function(t,r){return t?e.onFailure(t):"function"==typeof e.inputVerificationCode?e.inputVerificationCode(r):e.onSuccess(r)}))},t.confirmPassword=function(e,t,r,n){var i={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:e,Password:t,ClientMetadata:n};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",i,(function(e){return e?r.onFailure(e):r.onSuccess("SUCCESS")}))},t.getAttributeVerificationCode=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("GetUserAttributeVerificationCode",{AttributeName:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:r},(function(e,r){return e?t.onFailure(e):"function"==typeof t.inputVerificationCode?t.inputVerificationCode(r):t.onSuccess("SUCCESS")}))},t.verifyAttribute=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:e,Code:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?r.onFailure(e):r.onSuccess("SUCCESS")}))},t.getDevice=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey},(function(t,r){return t?e.onFailure(t):e.onSuccess(r)}))},t.forgetSpecificDevice=function(e,t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("ForgetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:e},(function(e){return e?t.onFailure(e):t.onSuccess("SUCCESS")}))},t.forgetDevice=function(e){var t=this;this.forgetSpecificDevice(this.deviceKey,{onFailure:e.onFailure,onSuccess:function(r){return t.deviceKey=null,t.deviceGroupKey=null,t.randomPassword=null,t.clearCachedDeviceKeyAndPassword(),e.onSuccess(r)}})},t.setDeviceStatusRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.setDeviceStatusNotRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"not_remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.listDevices=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r.onFailure(new Error("User is not authenticated"));var n={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:e};t&&(n.PaginationToken=t),this.client.request("ListDevices",n,(function(e,t){return e?r.onFailure(e):r.onSuccess(t)}))},t.globalSignOut=function(e){var t=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GlobalSignOut",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(r){return r?e.onFailure(r):(t.clearCachedUser(),e.onSuccess("SUCCESS"))}))},t.signOut=function(e){var t=this;e&&"function"==typeof e?this.getSession((function(r,n){if(r)return e(r);t.revokeTokens((function(r){t.cleanClientData(),e(r)}))})):this.cleanClientData()},t.revokeTokens=function(e){if(void 0===e&&(e=function(){}),"function"!=typeof e)throw new Error("Invalid revokeTokenCallback. It should be a function.");if(!this.signInUserSession)return e(new Error("User is not authenticated"));if(!this.signInUserSession.getAccessToken())return e(new Error("No Access token available"));var t=this.signInUserSession.getRefreshToken().getToken(),r=this.signInUserSession.getAccessToken();if(this.isSessionRevocable(r)&&t)return this.revokeToken({token:t,callback:e});e()},t.isSessionRevocable=function(e){if(e&&"function"==typeof e.decodePayload)try{return!!e.decodePayload().origin_jti}catch(e){}return!1},t.cleanClientData=function(){this.signInUserSession=null,this.clearCachedUser()},t.revokeToken=function(e){var t=e.token,r=e.callback;this.client.requestWithRetry("RevokeToken",{Token:t,ClientId:this.pool.getClientId()},(function(e){if(e)return r(e);r()}))},t.sendMFASelectionAnswer=function(e,t){var r=this,n={};n.USERNAME=this.username,n.ANSWER=e;var i={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:n,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",i,(function(n,i){return n?t.onFailure(n):(r.Session=i.Session,"SMS_MFA"===e?t.mfaRequired(i.ChallengeName,i.ChallengeParameters):"SOFTWARE_TOKEN_MFA"===e?t.totpRequired(i.ChallengeName,i.ChallengeParameters):void 0)}))},t.getUserContextData=function(){return this.pool.getUserContextData(this.username)},t.associateSoftwareToken=function(e){var t=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("AssociateSoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,r){return t?e.onFailure(t):e.associateSecretCode(r.SecretCode)})):this.client.request("AssociateSoftwareToken",{Session:this.Session},(function(r,n){return r?e.onFailure(r):(t.Session=n.Session,e.associateSecretCode(n.SecretCode))}))},t.verifySoftwareToken=function(e,t,r){var n=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("VerifySoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserCode:e,FriendlyDeviceName:t},(function(e,t){return e?r.onFailure(e):r.onSuccess(t)})):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:e,FriendlyDeviceName:t},(function(e,t){if(e)return r.onFailure(e);n.Session=t.Session;var i={};i.USERNAME=n.username;var s={ChallengeName:"MFA_SETUP",ClientId:n.pool.getClientId(),ChallengeResponses:i,Session:n.Session};n.getUserContextData()&&(s.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",s,(function(e,t){return e?r.onFailure(e):(n.signInUserSession=n.getCognitoUserSession(t.AuthenticationResult),n.cacheTokens(),r.onSuccess(n.signInUserSession))}))}))},e}(),$=(r(204),"aws-amplify/5.0.4"),Y={userAgent:$+" js",product:"",navigator:null,isReactNative:!1};function z(){}"undefined"!=typeof navigator&&navigator.product&&(Y.product=navigator.product||"",Y.navigator=navigator||null,"ReactNative"===navigator.product?(Y.userAgent=$+" react-native",Y.isReactNative=!0):(Y.userAgent=$+" js",Y.isReactNative=!1)),z.prototype.userAgent=Y.userAgent;const G=z;function Q(e){var t="function"==typeof Map?new Map:void 0;return Q=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return Z(e,arguments,te(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ee(n,e)},Q(e)}function Z(e,t,r){return Z=X()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&ee(i,r.prototype),i},Z.apply(null,arguments)}function X(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function ee(e,t){return ee=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ee(e,t)}function te(e){return te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},te(e)}var re=function(e){function t(t,r,n,i){var s;return(s=e.call(this,t)||this).code=r,s.name=n,s.statusCode=i,s}return n=e,(r=t).prototype=Object.create(n.prototype),r.prototype.constructor=r,ee(r,n),t;var r,n}(Q(Error)),ne=function(){function e(e,t,r){this.endpoint=t||"https://cognito-idp."+e+".amazonaws.com/";var n=(r||{}).credentials;this.fetchOptions=n?{credentials:n}:{}}var t=e.prototype;return t.promisifyRequest=function(e,t){var r=this;return new Promise((function(n,i){r.request(e,t,(function(e,t){e?i(new re(e.message,e.code,e.name,e.statusCode)):n(t)}))}))},t.requestWithRetry=function(e,t,r){var n,i,s=this;(n=[t],i=5e3,void 0===i&&(i=se),ie((function(t){return new Promise((function(r,n){s.request(e,t,(function(e,t){e?n(e):r(t)}))}))}),n,function(e){return function(t){var r=100*Math.pow(2,t)+100*Math.random();return!(r>e)&&r}}(i))).then((function(e){return r(null,e)})).catch((function(e){return r(e)}))},t.request=function(e,t,r){var n,i={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+e,"X-Amz-User-Agent":G.prototype.userAgent},s=Object.assign({},this.fetchOptions,{headers:i,method:"POST",mode:"cors",cache:"no-cache",body:JSON.stringify(t)});fetch(this.endpoint,s).then((function(e){return n=e,e}),(function(e){if(e instanceof TypeError)throw new Error("Network error");throw e})).then((function(e){return e.json().catch((function(){return{}}))})).then((function(e){if(n.ok)return r(null,e);var t=(e.__type||e.code).split("#").pop(),i=new Error(e.message||e.Message||null);return i.name=t,i.code=t,r(i)})).catch((function(e){if(n&&n.headers&&n.headers.get("x-amzn-errortype"))try{var t=n.headers.get("x-amzn-errortype").split(":")[0],i=new Error(n.status?n.status.toString():null);return i.code=t,i.name=t,i.statusCode=n.status,r(i)}catch(t){return r(e)}else e instanceof Error&&"Network error"===e.message&&(e.code="NetworkError");return r(e)}))},e}();function ie(e,t,r,n){if(void 0===n&&(n=1),"function"!=typeof e)throw Error("functionToRetry must be a function");return e.name,JSON.stringify(t),e.apply(void 0,t).catch((function(i){if(e.name,(s=i)&&s.nonRetryable)throw e.name,i;var s,o=r(n,t,i);if(e.name,!1!==o)return new Promise((function(e){return setTimeout(e,o)})).then((function(){return ie(e,t,r,n+1)}));throw i}))}Error;var se=3e5,oe=function(){function e(e,t){var r=e||{},n=r.UserPoolId,i=r.ClientId,s=r.endpoint,o=r.fetchOptions,a=r.AdvancedSecurityDataCollectionFlag;if(!n||!i)throw new Error("Both UserPoolId and ClientId are required.");if(n.length>55||!/^[\w-]+_[0-9a-zA-Z]+$/.test(n))throw new Error("Invalid UserPoolId format.");var u=n.split("_")[0];this.userPoolId=n,this.clientId=i,this.client=new ne(u,s,o),this.advancedSecurityDataCollectionFlag=!1!==a,this.storage=e.Storage||(new W).getStorage(),t&&(this.wrapRefreshSessionCallback=t)}var t=e.prototype;return t.getUserPoolId=function(){return this.userPoolId},t.getUserPoolName=function(){return this.getUserPoolId().split("_")[1]},t.getClientId=function(){return this.clientId},t.signUp=function(e,t,r,n,i,s){var o=this,a={ClientId:this.clientId,Username:e,Password:t,UserAttributes:r,ValidationData:n,ClientMetadata:s};this.getUserContextData(e)&&(a.UserContextData=this.getUserContextData(e)),this.client.request("SignUp",a,(function(t,r){if(t)return i(t,null);var n={Username:e,Pool:o,Storage:o.storage},s={user:new J(n),userConfirmed:r.UserConfirmed,userSub:r.UserSub,codeDeliveryDetails:r.CodeDeliveryDetails};return i(null,s)}))},t.getCurrentUser=function(){var e="CognitoIdentityServiceProvider."+this.clientId+".LastAuthUser",t=this.storage.getItem(e);if(t){var r={Username:t,Pool:this,Storage:this.storage};return new J(r)}return null},t.getUserContextData=function(e){if("undefined"!=typeof AmazonCognitoAdvancedSecurityData){var t=AmazonCognitoAdvancedSecurityData;if(this.advancedSecurityDataCollectionFlag){var r=t.getData(e,this.userPoolId,this.clientId);if(r)return{EncodedData:r}}return{}}},e}();r(808);class ae extends Error{constructor(e,t){e instanceof Error?(super(e.message||"Something went wrong."),this.cause=e,this.name=e.name,e.hasOwnProperty("code")&&(this.code=e.code)):"string"==typeof e&&(super(e||"Something went wrong."),this.name="SkapiError",this.code="ERROR",t&&(t.code&&(this.code=t.code),t.cause&&(this.cause=t.cause)))}}class ue{static hash(e){"string"!=typeof e&&(console.warn("coercing non-string value to empty string"),e="");const t=ue.sb(e);let r,n,i,s,o=1732584193,a=-271733879,u=-1732584194,c=271733878;for(let e=0;e<t.length;e+=16)r=o,n=a,i=u,s=c,o=ue.ff(o,a,u,c,t[e],7,-680876936),c=ue.ff(c,o,a,u,t[e+1],12,-389564586),u=ue.ff(u,c,o,a,t[e+2],17,606105819),a=ue.ff(a,u,c,o,t[e+3],22,-1044525330),o=ue.ff(o,a,u,c,t[e+4],7,-176418897),c=ue.ff(c,o,a,u,t[e+5],12,1200080426),u=ue.ff(u,c,o,a,t[e+6],17,-1473231341),a=ue.ff(a,u,c,o,t[e+7],22,-45705983),o=ue.ff(o,a,u,c,t[e+8],7,1770035416),c=ue.ff(c,o,a,u,t[e+9],12,-1958414417),u=ue.ff(u,c,o,a,t[e+10],17,-42063),a=ue.ff(a,u,c,o,t[e+11],22,-1990404162),o=ue.ff(o,a,u,c,t[e+12],7,1804603682),c=ue.ff(c,o,a,u,t[e+13],12,-40341101),u=ue.ff(u,c,o,a,t[e+14],17,-1502002290),a=ue.ff(a,u,c,o,t[e+15],22,1236535329),o=ue.gg(o,a,u,c,t[e+1],5,-165796510),c=ue.gg(c,o,a,u,t[e+6],9,-1069501632),u=ue.gg(u,c,o,a,t[e+11],14,643717713),a=ue.gg(a,u,c,o,t[e],20,-373897302),o=ue.gg(o,a,u,c,t[e+5],5,-701558691),c=ue.gg(c,o,a,u,t[e+10],9,38016083),u=ue.gg(u,c,o,a,t[e+15],14,-660478335),a=ue.gg(a,u,c,o,t[e+4],20,-405537848),o=ue.gg(o,a,u,c,t[e+9],5,568446438),c=ue.gg(c,o,a,u,t[e+14],9,-1019803690),u=ue.gg(u,c,o,a,t[e+3],14,-187363961),a=ue.gg(a,u,c,o,t[e+8],20,1163531501),o=ue.gg(o,a,u,c,t[e+13],5,-1444681467),c=ue.gg(c,o,a,u,t[e+2],9,-51403784),u=ue.gg(u,c,o,a,t[e+7],14,1735328473),a=ue.gg(a,u,c,o,t[e+12],20,-1926607734),o=ue.hh(o,a,u,c,t[e+5],4,-378558),c=ue.hh(c,o,a,u,t[e+8],11,-2022574463),u=ue.hh(u,c,o,a,t[e+11],16,1839030562),a=ue.hh(a,u,c,o,t[e+14],23,-35309556),o=ue.hh(o,a,u,c,t[e+1],4,-1530992060),c=ue.hh(c,o,a,u,t[e+4],11,1272893353),u=ue.hh(u,c,o,a,t[e+7],16,-155497632),a=ue.hh(a,u,c,o,t[e+10],23,-1094730640),o=ue.hh(o,a,u,c,t[e+13],4,681279174),c=ue.hh(c,o,a,u,t[e],11,-358537222),u=ue.hh(u,c,o,a,t[e+3],16,-722521979),a=ue.hh(a,u,c,o,t[e+6],23,76029189),o=ue.hh(o,a,u,c,t[e+9],4,-640364487),c=ue.hh(c,o,a,u,t[e+12],11,-421815835),u=ue.hh(u,c,o,a,t[e+15],16,530742520),a=ue.hh(a,u,c,o,t[e+2],23,-995338651),o=ue.ii(o,a,u,c,t[e],6,-198630844),c=ue.ii(c,o,a,u,t[e+7],10,1126891415),u=ue.ii(u,c,o,a,t[e+14],15,-1416354905),a=ue.ii(a,u,c,o,t[e+5],21,-57434055),o=ue.ii(o,a,u,c,t[e+12],6,1700485571),c=ue.ii(c,o,a,u,t[e+3],10,-1894986606),u=ue.ii(u,c,o,a,t[e+10],15,-1051523),a=ue.ii(a,u,c,o,t[e+1],21,-2054922799),o=ue.ii(o,a,u,c,t[e+8],6,1873313359),c=ue.ii(c,o,a,u,t[e+15],10,-30611744),u=ue.ii(u,c,o,a,t[e+6],15,-1560198380),a=ue.ii(a,u,c,o,t[e+13],21,1309151649),o=ue.ii(o,a,u,c,t[e+4],6,-145523070),c=ue.ii(c,o,a,u,t[e+11],10,-1120210379),u=ue.ii(u,c,o,a,t[e+2],15,718787259),a=ue.ii(a,u,c,o,t[e+9],21,-343485551),o=ue.ad(o,r),a=ue.ad(a,n),u=ue.ad(u,i),c=ue.ad(c,s);return ue.rh(o)+ue.rh(a)+ue.rh(u)+ue.rh(c)}static rh(e){let t="";for(let r=0;r<=3;r++)t+=ue.alphabet.charAt(e>>8*r+4&15)+ue.alphabet.charAt(e>>8*r&15);return t}static ad(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}static rl(e,t){return e<<t|e>>>32-t}static cm(e,t,r,n,i,s){return ue.ad(ue.rl(ue.ad(ue.ad(t,e),ue.ad(n,s)),i),r)}static ff(e,t,r,n,i,s,o){return ue.cm(t&r|~t&n,e,t,i,s,o)}static gg(e,t,r,n,i,s,o){return ue.cm(t&n|r&~n,e,t,i,s,o)}static hh(e,t,r,n,i,s,o){return ue.cm(t^r^n,e,t,i,s,o)}static ii(e,t,r,n,i,s,o){return ue.cm(r^(t|~n),e,t,i,s,o)}static sb(e){let t;const r=1+(e.length+8>>6),n=new Array(16*r);for(t=0;t<16*r;t++)n[t]=0;for(t=0;t<e.length;t++)n[t>>2]|=e.charCodeAt(t)<<t%4*8;return n[t>>2]|=128<<t%4*8,n[16*r-2]=8*e.length,n}}function ce(e,t="User ID"){if(!e)throw new ae(`${t} is empty.`,{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ae(`${t} should be type: string.`,{code:"INVALID_PARAMETER"});if(!e.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i))throw new ae(`${t} is invalid.`,{code:"INVALID_PARAMETER"});return e}function he(e){if("string"!=typeof e||"+"!==e.charAt(0)||isNaN(Number(e.substring(1))))throw new ae('"phone_number" is invalid. The format should be "+00123456789". Type: string.',{code:"INVALID_PARAMETER"});return e}function le(e){if("string"!=typeof e)throw new ae('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"});{let t=new RegExp(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/);if(10!==e.length||3!==e.split("-").length||!t.test(e))throw new ae('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"})}return e}function fe(e){if(!e)throw new ae('"password" is required.',{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ae('"password" should be type: string.',{code:"INVALID_PARAMETER"});if(e.length<6)throw new ae('"password" should be at least 6 characters.',{code:"INVALID_PARAMETER"});if(e.length>60)throw new ae('"password" can be up to 60 characters max.',{code:"INVALID_PARAMETER"});return e}function de(e,t="email"){if(!e)throw new ae(`"${t}" is required.`,{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ae(`"${t}"should be type: string.`,{code:"INVALID_PARAMETER"});if(e.length<5||e.length>64)throw new ae(`"${t}" should be at least 5 characters and max 64 characters.`,{code:"INVALID_PARAMETER"});if(/^[a-zA-Z0-9.!#$%&'+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z]+[a-zA-Z0-9-]+)$/.test(e)&&(e=e.trim()).split("@")[1].split(".").length>=2)return e.toLowerCase();throw new ae(`"${e}" is an invalid email.`,{code:"INVALID_PARAMETER"})}function pe(e){const t=(()=>{let e=window.location.origin||null;return"/"===e.slice(-1)&&(e=e.slice(0,-1)),e})();let r=e=>{if("string"==typeof e){if("*"===e)return"*";{let r=e.trim();if(!r.includes(" ")&&!r.includes(",")){"/"===r.slice(0,1)&&t?r=t+r:"."===r.slice(0,1)&&t&&(r=window.location.href.split("/").slice(0,-1).join("/")+r);let n=null;try{n=new URL(r)}catch(t){throw new ae(`"${e}" is an invalid url.`,{code:"INVALID_PARAMETER"})}if(n.protocol){let e=n.href;return"/"===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}}}throw new ae(`"${e}" is an invalid url.`,{code:"INVALID_PARAMETER"})};return Array.isArray(e)?e.map((e=>r(e))):r(e)}function ge(e){const t={config:{reference_limit:null}},r={ip:e=>{t.ip=e},rec:e=>{if(!e)return;t.record_id=e;let r=e.substring(0,e.length-9).split("").reverse().reduce(((e,t,r)=>e+"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(t)*62**r),0);t.uploaded=r},usr:e=>{t.user_id=e},tbl:e=>{if(!e)return;let r=e.split("/");t.table=r[0],t.access_group="**"==r[2]?"private":parseInt(r[2]),r?.[3]&&(t.subscription={user_id:r[3],group:parseInt(r[4])})},idx:e=>{if(!e)return;let r=e.split("!"),n=r.splice(0,1)[0],i=function(e){let t=e.substring(3);switch(e.substring(0,3)){case"!S%":return t;case"!N%":return Number(t)-4503599627370496;case"!B%":return"1"===t;case"!L%":case"!D%":try{return JSON.parse(t)}catch(e){throw new ae("Value parse error.",{code:"PARSE_ERROR"})}default:return e}}("!"+r.join("!"));t.index={name:n,value:i}},ref:e=>{e&&(t.reference=e.split("/")[0])},tags:e=>{t.tags=e},upd:e=>{t.updated=e},acpt_mrf:e=>{t.config.allow_multiple_reference=e},ref_limt:e=>{t.config.reference_limit=e},rfd:e=>{t.referenced_count=e},data:e=>{let r=e;"!D%{}"===e?r={}:"!L%[]"===e&&(r=[]),t.data=r}};if(e.record_id)return e;for(let t in r)r[t](e[t]);return t}function ye(e,t="parameter",r=!1,n=!1){let i=i=>{if("string"!=typeof i)throw new ae(`${t} should be type: <string | string[]>.`,{code:"INVALID_PARAMETER"});if(!n&&e.includes(" "))throw new ae(`${t} should not have whitespace.`,{code:"INVALID_PARAMETER"});if(!r&&e.includes("."))throw new ae(`${t} should not have periods.`,{code:"INVALID_PARAMETER"});if(/[`!@#$%^&*()_+\-=\[\]{};':"\\|,<>\/?~]/.test(i))throw new ae(`${t} should not have special characters.`,{code:"INVALID_PARAMETER"})};if(Array.isArray(e))for(let t of e)i(t);else i(e);return e}function we(e,t,r=null,n=[],i=null){function s(e){if(e instanceof Promise)throw new ae("Parameter should not be a promise",{code:"INVALID_PARAMETER"});return e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length}Array.isArray(n)&&(n=n.concat(["service","service_owner"]));let o,a=e,u=null,c=i?` in "${i}" is invalid.`:". Parameter should be type <object>.";if(null===i){if(s(a)){a=a instanceof HTMLFormElement||a instanceof FormData||a instanceof SubmitEvent?me(e)?.meta:JSON.parse(JSON.stringify(e));for(let e in a)if(!t.hasOwnProperty(e)&&Array.isArray(n)&&!n.includes(e))throw new ae(`Key name "${e}" is invalid in parameter.`,{code:"INVALID_PARAMETER"});if(Array.isArray(r)&&r.length)for(let e of r)if(!Object.keys(a).includes(e))throw new ae(`Key "${e}" is required in parameter.`,{code:"INVALID_PARAMETER"})}else if((h=a)&&"object"==typeof h&&!Array.isArray(h)&&!Object.keys(h).length||void 0===a){let e={};for(let r in t){let n=t[r];Array.isArray(n)&&"function"==typeof n[n.length-1]&&(e[r]=n[n.length-1]())}return Object.keys(e).length?e:a}if(null===a)return null}var h;if(s(t)&&s(a)){for(let e in t){let r=t[e];if(a.hasOwnProperty(e)&&void 0!==a[e])a[e]=we(a[e],r,null,null,e);else{let t=Array.isArray(r)&&"function"==typeof r[r.length-1]?r[r.length-1]:null;if(t){let r=t();void 0!==r&&(a[e]=r)}}}o=a}else if(Array.isArray(t))for(let e of t)try{void 0!==typeof a&&"function"!=typeof e&&(o=we(a,e,null,null,i));break}catch(e){if("string"==typeof e&&"BREAK:"===e.substring(0,6)){let t=(e=e.substring(6)).split(":");u=new ae(t[1],{code:t[0]});break}u=e}else{if("function"==typeof t)return t(a);if("string"==typeof t)if(Array.isArray(a)){if("array"!==t)throw new ae(`Invalid type "${typeof a}"${c}`,{code:"INVALID_PARAMETER"});for(let e of a)if(!["number","string","boolean"].includes(typeof e)&&null!==e)throw new ae(`Invalid type "${typeof e}" in "${i}" array value.`,{code:"INVALID_PARAMETER"});o=a}else if(["number","string","boolean","array","function"].includes(t)){if(typeof a!==t)throw new ae(`Value: ${a}${c}`,{code:"INVALID_PARAMETER"});if("number"===t&&Math.abs(a)>4503599627370496)throw`BREAK:INVALID_PARAMETER:"${i}" integer value should be within -4503599627370496 ~ +4503599627370546.`;o=a}else{if(a!==t)throw new ae(`Value: ${a}${c}`,{code:"INVALID_PARAMETER"});o=a}else null===t&&(o=a)}if(void 0===o&&u)throw u;return o}function me(e){function t(e,t,r){let n=t.slice(0,1),i=t.slice(-1);if("."===n&&(t=t.slice(1)),"."===i&&(t=t.slice(0,-1)),t.includes(".")){let r=t.split(".");t=r.pop();for(let t of r)t&&(e.hasOwnProperty(t)||(e[t]={}),e=e[t])}e.hasOwnProperty(t)?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:e[t]=r}if(e instanceof FormData){let r={},n=0,i=[];for(let s of e.entries()){let e=s[0],o=s[1];if(o instanceof File)i.includes(e)||i.push(e),n+=Math.round(o.size/1024);else if(o instanceof FileList){if(i.includes(e)||i.push(e),o&&o.length>0)for(let e=0;e<=o.length-1;e++)n+=Math.round(o.item(e).size/1024)}else t(r,e,o)}if(n>5120)throw new ae("Files cannot exceed 5MB. Use skapi.uploadFiles(...) instead.",{code:"INVALID_REQUEST"});return{meta:r,files:i}}if(e instanceof SubmitEvent&&(e=e.target),e instanceof HTMLFormElement){let r={},n=[],i=0,s=e.querySelectorAll("input"),o=e.querySelectorAll("textarea");for(let e of o)e.name&&t(r,e.name,e.value);for(let e of s)if(e.name)if("number"===e.type)e.value&&t(r,e.name,Number(e.value));else if("checkbox"===e.type||"radio"===e.type)e.checked&&("on"===e.value||"true"===e.value?t(r,e.name,!0):"false"===e.value?t(r,e.name,!1):e.checked&&e.value&&t(r,e.name,e.value));else if("file"===e.type){if(n.includes(e.name)||n.push(e.name),e.files&&e.files.length>0)for(let t=0;t<=e.files.length-1;t++)i+=Math.round(e.files.item(t).size/1024)}else t(r,e.name,e.value);if(i>5120)throw new ae("Files cannot exceed 5MB. Use skapi.uploadFiles(...) instead.",{code:"INVALID_REQUEST"});return{meta:r,files:n}}return null}function _e(){return function(e,t,r){const n=r.value;r.value=function(...e){let t=e[0],r=e?.[1]||{},i=!0,s=null,o="";if(t instanceof SubmitEvent){t.preventDefault();let e=window.location.href;s=t.target;let r=new URL(s.action);o=r.href,s.action&&r.href!==e||(i=!1)}const a=e=>{if(r?.response){if("function"==typeof r.response)return r.response(e);throw new ae('Callback "response" should be type: function.',{code:"INVALID_PARAMETER"})}return s&&i&&(window.sessionStorage.setItem(`${this.service}:${ue.hash(o)}`,JSON.stringify(e)),window.location.href=o),e};let u;function c(e){let t=e instanceof Error?e:new ae(e);if(r?.onerror){if("function"==typeof r.onerror)return r.onerror(t);throw new ae('Callback "onerror" should be type: function.',{code:"INVALID_PARAMETER"})}throw t}try{u=n.bind(this)(...e)}catch(e){let t=c(e);if(t instanceof Error)throw t;return t}return u instanceof Promise?(async()=>{try{let e=await u;return a(e)}catch(e){return c(e)}})():a(u)}}}ue.alphabet="0123456789abcdef";var Ae=function(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o};class ve{get user(){return this.__user&&Object.keys(this.__user).length?JSON.parse(JSON.stringify(this.__user)):null}set user(e){}getConnection(){return this.__connection}constructor(e,t,r){if(this.cognitoUser=null,this.__disabledAccount=null,this.__serviceHash={},this.__pendingRequest={},this.__cached_requests={},this.__startKey_keys={},this.__request_signup_confirmation=null,this.__index_number_range=4503599627370496,this.__class_properties_has_been_cached=!1,this.session=null,this.origin=null,this.__user=null,this.connection=null,this.host="skapi",this.hostDomain="skapi.com",this.userPool=null,this.validate={userId(e){try{return ce(e),!0}catch(e){return!1}},url(e){try{return pe(e),!0}catch(e){return!1}},phoneNumber(e){try{return he(e),!0}catch(e){return!1}},birthdate(e){try{return le(e),!0}catch(e){return!1}},email(e){try{return de(e),!0}catch(e){return!1}}},this.getFormResponse=async()=>{await this.__connection;let e=`${this.service}:${ue.hash(window.location.href)}`,t=window.sessionStorage.getItem(e);if(null!==t){try{t=JSON.parse(t)}catch(e){}return t}throw new ae("Form response doesn't exist.",{code:"NOT_EXISTS"})},this.request=async(e,t=null,r)=>{r=r||{};let{auth:n=!1,method:i="post",meta:s=null,bypassAwaitConnection:o=!1}=r,a=o?null:await this.__connection,u=n?this.session?.idToken?.jwtToken:null;if(n){if(!u)throw this.logout(),new ae("User login is required.",{code:"INVALID_REQUEST"});{let e=Date.now()/1e3;if(this.session.idToken.payload.exp<e)try{await this.authentication().getSession({refreshToken:!0}),u=this.session?.idToken?.jwtToken}catch(e){throw this.logout(),new ae("User login is required.",{code:"INVALID_REQUEST"})}}}let c="";try{c=pe(e)}catch(e){}let h=c||await(async(e,t)=>{const r=await Promise.all([this.admin_endpoint,this.record_endpoint]),n=r[0],i=r[1];return(()=>{switch(e){case"get-serviceletters":case"delete-newsletter":case"block-account":case"register-service":case"get-users":case"post-userdata":case"remove-account":case"post-secure":case"get-newsletters":case"subscribe-newsletter":case"signup":case"confirm-signup":case"recover-account":case"mock":case"get-services":case"service":return{public:n.admin_public,private:n.admin_private};case"post-record":case"get-records":case"subscription":case"get-subscription":case"del-records":case"get-table":case"get-tag":case"get-index":case"storage-info":return{private:i.record_private,public:i.record_public}}})()[t?"private":"public"]+e})(e,!!n),l=this.session?.attributes?.["custom:service"]||a?.service||this.service,f=this.session?.attributes?.["custom:service_owner"]||a?.owner||this.service_owner;if(s){if("object"!=typeof s||Array.isArray(s))throw new ae("Invalid meta data.",{code:"INVALID_REQUEST"});s=JSON.parse(JSON.stringify(s))}if(Array.isArray(t)||t&&"object"!=typeof t)throw new ae("Request data should be a JSON Object | FormData | HTMLFormElement.",{code:"INVALID_REQUEST"});let d={service:l,service_owner:f},p={},{fetchMore:g=!1}=r?.fetchOptions||{};if(r?.fetchOptions&&Object.keys(r.fetchOptions).length){let e=we({limit:r.fetchOptions?.limit||100,startKey:r.fetchOptions?.startKey||null,ascending:"boolean"!=typeof r.fetchOptions?.ascending||r.fetchOptions.ascending},{limit:["number",()=>100],startKey:null,ascending:["boolean",()=>!0]});if(e.hasOwnProperty("limit")&&"number"==typeof e.limit){if(e.limit>1e3)throw new ae("Fetch limit should be below 1000.",{code:"INVALID_REQUEST"});Object.assign(p,{limit:e.limit})}e.hasOwnProperty("startKey")&&"object"==typeof e.startKey&&e.startKey&&Object.keys(e.startKey)&&Object.assign(p,{startKey:e.startKey}),e.hasOwnProperty("ascending")&&"boolean"==typeof e.ascending&&Object.assign(p,{ascending:e.ascending})}Object.assign(d,p);let y=!1;if(t instanceof SubmitEvent&&(t=t?.target),t instanceof HTMLFormElement&&(t=new FormData(t)),t instanceof FormData&&(y=!0),s)s=Object.assign(d,s);else if(t)if(y)for(let e in d)void 0!==d[e]&&t.set(e,new Blob([JSON.stringify(d[e])],{type:"application/json"}));else t=Object.assign(d,t);else t=d;if(y&&"function"==typeof r?.fetchOptions?.formData){let e=r.fetchOptions.formData(t);if(e instanceof Promise&&(e=await e),!(e instanceof FormData))throw new ae("Callback for extractFormData() should return FormData",{code:"INVALID_PARAMETER"});t=e}let w=this.load_startKey_keys({params:t,url:c||e,fetchMore:!y&&g});if(w&&"object"==typeof w)return w;if("string"==typeof w){if(!(this.__pendingRequest[w]instanceof Promise)){let e={Accept:"*/*"};u&&(e.Authorization=u),s&&(e["Content-Meta"]=JSON.stringify(s)),r.hasOwnProperty("contentType")?r?.contentType&&(e["Content-Type"]=r.contentType):t instanceof FormData||(e["Content-Type"]="application/json");let n={headers:e};r?.responseType&&(n.responseType=r.responseType),"post"===i?this.__pendingRequest[w]=this._post(h,t,n):"get"===i&&(this.__pendingRequest[w]=this._get(h,t,n))}try{let t=await this.__pendingRequest[w];return y?t:await this.update_startKey_keys({hashedParam:w,url:e,response:t})}catch(e){throw e}finally{w&&this.__pendingRequest.hasOwnProperty(w)&&delete this.__pendingRequest[w]}}},this.load_startKey_keys=e=>{let{params:t={},url:r,fetchMore:n=!1}=e||{};if(t.hasOwnProperty("startKey")&&t.startKey){if("object"!=typeof t.startKey&&!Object.keys(t.startKey).length&&"start"!==t.startKey&&"end"!==t.startKey)throw new ae(`"${t.startKey}" is invalid startKey key.`,{code:"INVALID_PARAMETER"});switch(t.startKey){case"end":return{list:[],startKey:"end",endOfList:!0};case"start":delete t.startKey}}let i=(()=>{if(t&&"object"==typeof t&&Object.keys(t).length){function e(e){function t(e){return"object"==typeof e&&e?Object.keys(e).sort().reduce(((t,r)=>(t[r]=e[r],t)),{}):e}let r=t(e);for(let n in r)r[n]&&"object"==typeof r[n]&&(r[n]=t(e[n]));return r}return ue.hash(r+"/"+JSON.stringify(e(t)))}return ue.hash(r+"/"+this.service)})();if(!n&&this.__startKey_keys?.[r]?.[i]){if(this.__cached_requests?.[r]&&this.__cached_requests?.[r]?.[i]&&delete this.__cached_requests[r][i],Array.isArray(this.__startKey_keys[r][i])&&this.__startKey_keys[r][i].length)for(let e of this.__startKey_keys[r][i]){let t=i+"/"+ue.hash(JSON.stringify(e));this.__cached_requests?.[r]&&this.__cached_requests?.[r]?.[t]&&delete this.__cached_requests[r][t]}return delete this.__startKey_keys[r][i],i}if(!Array.isArray(this.__startKey_keys?.[r]?.[i]))return i;let s=this.__startKey_keys[r][i],o=s[s.length-1],a=i;if(o){if('"end"'===o)return{list:[],startKey:"end",endOfList:!0};a+=ue.hash(o),t.startKey=JSON.parse(o)}return this.__cached_requests?.[r]?.[a]?this.__cached_requests?.[r]?.[a]:i},this.update_startKey_keys=async e=>{let{hashedParam:t,url:r,response:n}=e,i=null;if(i=n instanceof Promise?await n:n,"object"!=typeof i||!i.hasOwnProperty("startKey")||!t||!r)return i;this.__startKey_keys.hasOwnProperty(r)||(this.__startKey_keys[r]={}),this.__cached_requests?.[r]||(this.__cached_requests[r]={}),this.__cached_requests[r][t]=i,this.__startKey_keys[r].hasOwnProperty(t)||(this.__startKey_keys[r][t]=[]);let s=JSON.stringify(i.startKey);return this.__startKey_keys[r][t].includes(s)||this.__startKey_keys[r][t].push(s),this.__cached_requests[r][t]=i,Object.assign({startKey_list:this.__startKey_keys[r][t]},i)},this._fetch=async(e,t,r)=>{let n=await fetch(e,t);if(r){if(200===n.status)return await n[r]();throw n}let i=await n.text();try{i=JSON.parse(i)}catch(e){}if(200===n.status){if("object"==typeof i&&"GET"===t.method&&i.hasOwnProperty("body"))try{i=JSON.parse(i.body)}catch(e){}return i}{let e=n?.status,t=["INVALID_CORS","INVALID_REQUEST","SERVICE_DISABLED","INVALID_PARAMETER","ERROR","EXISTS","NOT_EXISTS"];if("object"==typeof i&&i?.message){let t=i?.code||(e?e.toString():null)||"ERROR";throw new ae(i?.message,{code:t})}if("string"==typeof i){let e=i.split(":"),r=e.splice(0,1)[0].trim();throw new ae(e.join("").trim(),{code:t.includes(r)?r:"ERROR"})}throw n}},this._get=async(e,t,r)=>{t&&"object"==typeof t&&Object.keys(t).length&&("?"!==e.substring(e.length-1)&&(e+="?"),e+=Object.keys(t).map((e=>{let r=t[e];return"string"!=typeof r&&(r=JSON.stringify(r)),encodeURIComponent(e)+"="+encodeURIComponent(r)})).join("&"));let n=null;r.hasOwnProperty("responseType")&&(n=r.responseType,delete r.responseType);let i=Object.assign({method:"GET"},r);return this._fetch(e,i,n)},this.getRecords=async(e,t)=>{const r={$updated:"number",$uploaded:"number",$referenced_count:"number"},n={table:"string",reference:"string",access_group:["number","private"],subscription:{user_id:e=>ce(e,'User ID in "subscription.user_id"'),group:e=>{if("number"!=typeof e)throw new ae('"subscription.group" should be type: number.',{code:"INVALID_PARAMETER"});if(e>99||e<0)throw new ae('"subscription.group" should be within range: 0 ~ 99.',{code:"INVALID_PARAMETER"});return e}},index:{name:e=>{if("string"!=typeof e)throw new ae('"index.name" should be type: string.',{code:"INVALID_PARAMETER"});return r.hasOwnProperty(e)?e:ye(e,"index.name",!0,!1)},value:t=>{if(e.index?.name&&r.hasOwnProperty(e.index.name)){let n=r[e.index.name];if(typeof t===n)return t;throw new ae(`"index.value" should be type: ${n}.`,{code:"INVALID_PARAMETER"})}if("number"==typeof t){if(t>this.__index_number_range||t<-this.__index_number_range)throw new ae(`Number value should be within range -${this.__index_number_range} ~ +${this.__index_number_range}`,{code:"INVALID_PARAMETER"});return t}return"boolean"==typeof t?t:ye(t,"index.value",!1,!0)},condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"],range:t=>{if(!("value"in e.index))throw new ae('"index.value" is required.',{code:"INVALID_PARAMETER"});if("$record_id"===e.index.name)throw new ae(`Cannot do "index.range" on ${e.index.name}`,{code:"INVALID_PARAMETER"});if(typeof e.index.value!=typeof t)throw new ae('"index.range" type should match the type of "index.value".',{code:"INVALID_PARAMETER"});return"string"==typeof t?ye(t,"index.value"):t}},tag:"string"};if(e?.record_id)ye(e.record_id,"record_id",!1,!1),e={record_id:e.record_id,service:e?.service};else{let t;if(e?.reference)try{t=ce(e?.reference,'User ID in "subscription.user_id"')}catch(e){}if((e=we(e||{},n,t?[]:["table"]))?.subscription&&!this.session)throw new ae("Requires login.",{code:"INVALID_REQUEST"})}let i=!(!e.hasOwnProperty("access_group")||!("private"===e.access_group||e.access_group>0))||!!this.__user,s=await this.request("get-records",e,{fetchOptions:t,auth:i,method:i?"post":"get"});for(let e in s.list)s.list[e]=ge(s.list[e]);return s},this.getTable=async(e,t)=>{let r=await this.request("get-table",we(e||{},{table:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!0},{fetchOptions:t})),n={cnt_rec:"number_of_records",tbl:"table",srvc:"service"};if(Array.isArray(r.list))for(let e of r.list)for(let t in n)e.hasOwnProperty(t)&&(e[n[t]]=e[t],delete e[t]);return r},this.getIndex=async(e,t)=>{let r=we(e||{},{table:"string",index:e=>ye(e,"index name",!0,!1),order_by:{name:["average_number","total_number","number_count","average_bool","total_bool","bool_count","string_count","index_name"],value:["string","number","boolean"],condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}},["table"]);if(r.hasOwnProperty("order_by")){if("index_name"===r.order_by){if(!r.hasOwnProperty("index"))throw new ae('"index" is required for ordered by "index_name".',{code:"INVALID_PARAMETER"});if("."!==r.index.substring(r.index.length-1))throw new ae('"index" should be parent "index name".',{code:"INVALID_PARAMETER"})}if(r.order_by.hasOwnProperty("condition")&&!r.order_by.hasOwnProperty("value"))throw new ae('"value" is required for "condition".',{code:"INVALID_PARAMETER"})}let n=await this.request("get-index",r,Object.assign({auth:!0},{fetchOptions:t})),i={cnt_bool:"boolean_count",cnt_numb:"number_count",totl_numb:"total_number",totl_bool:"total_bool",avrg_numb:"average_number",avrg_bool:"average_bool",cnt_str:"string_count"};return Array.isArray(n.list)&&(n.list=n.list.map((e=>{let t=e.idx.split("/"),r={table:t[1],index:t[2],number_of_records:e.cnt_rec};for(let t in i)e?.[t]&&(r[i[t]]=e[t]),r?.number_of_number_values&&(r.average_of_number_values=e.totl_numb/e.cnt_numb),r?.number_of_boolean_values&&(r.average_of_boolean_values=e.totl_bool/e.cnt_bool);return r}))),n},this.getTag=async(e,t)=>{let r=await this.request("get-tag",we(e||{},{table:"string",tag:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!0},{fetchOptions:t}));if(Array.isArray(r.list))for(let e in r.list){let t=r.list[e],n=t.tag.split("/");r.list[e]={table:n[1],tag:n[0],number_of_records:t.cnt_rec}}return r},this.deleteRecords=async e=>{let t=await this.checkAdmin();if(t&&!e?.service)throw new ae("Service ID is required.",{code:"INVALID_PARAMETER"});if(!t&&!e?.table)throw new ae('"table" is required.',{code:"INVALID_PARAMETER"});if(e?.record_id)return await this.request("del-records",{service:e.service,record_id:(e=>{let t=ye(e,"record_id",!1);return"string"==typeof t?[t]:t})(e.record_id)},{auth:!0});if(!e?.table)throw new ae('Either "table" or "record_id" is required.',{code:"INVALID_PARAMETER"});return e=we(e||{},{access_group:["number","private"],table:{name:"string",subscription:e=>{if(t)return ce(e,'User ID in "table.subscription"');throw new ae('"table.subscription" is an invalid parameter key.',{code:"INVALID_PARAMETER"})},subscription_group:r=>{if(t&&"string"!=typeof e?.table?.subscription)throw new ae('"table.subscription" is required.',{code:"INVALID_PARAMETER"});if("number"==typeof r&&r>0&&r<99)return r;throw new ae("Subscription group should be between 0 ~ 99.",{code:"INVALID_PARAMETER"})}}},t?["service"]:["table","access_group"]),await this.request("del-records",e,{auth:!0})},this.subscriptionGroupCheck=async e=>{if(await this.__connection,e=we(e,{user_id:e=>ce(e,'"user_id"'),group:e=>{if("*"===e)return e;if("number"!=typeof e)throw new ae('"group" should be type: number.',{code:"INVALID_PARAMETER"});if(e<1&&e>9)throw new ae('"group" should be within range 1 ~ 9.',{code:"INVALID_PARAMETER"});return e}},["user_id","group"]),this.__user&&e.user_id===this.__user.user_id)throw new ae('"user_id" cannot be the user\'s own ID.',{code:"INVALID_PARAMETER"});return e},"string"!=typeof e||"string"!=typeof t)throw new ae('"service_id" and "service_owner" should be type <string>.',{code:"INVALID_PARAMETER"});if(!e||!t)throw new ae('"service_id" and "service_owner" is required',{code:"INVALID_PARAMETER"});t!==this.host&&ce(t,'"service_owner"'),this.service=e,this.service_owner=t;let n=r?.autoLogin||!1;const i="https://dkls9pxkgz855.cloudfront.net";let s=e.substring(0,4);this.admin_endpoint=fetch(`${i}/${s}/admin.json`).then((e=>e.blob())).then((e=>new Promise(((t,r)=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.record_endpoint=fetch(`${i}/${s}/record.json`).then((e=>e.blob())).then((e=>new Promise(((t,r)=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.__connection=(async r=>{if(!window.sessionStorage)throw new Error("This browser does not support skapi.");const i=JSON.parse(window.sessionStorage.getItem(`${e}#${t}`)||"null");if(i?.connection)for(let e in i)r[e]=i[e];const s=await r.admin_endpoint;r.userPool=new oe({UserPoolId:s.userpool_id,ClientId:s.userpool_client});const o=[];if(i?.connection||o.push(r.updateConnection()),!i?.connection&&!n){let e=this.userPool?.getCurrentUser()||null;e&&e.signOut()}let a;(i?.connection||n)&&o.push(r.authentication().getSession({refreshToken:!i?.connection}).catch((e=>{r.__user=null}))),o.length&&(a=await Promise.all(o));const u=()=>{if(r.__class_properties_has_been_cached)return;let n=()=>{let n={};const i=["__startKey_keys","__cached_requests","__request_signup_confirmation","connection"];if(r.connection){for(let e of i)n[e]=r[e];window.sessionStorage.setItem(`${e}#${t}`,JSON.stringify(n)),r.__class_properties_has_been_cached=!0}};return a instanceof Promise?a.then((()=>n())):n()};return window.addEventListener("beforeunload",u),window.addEventListener("visibilitychange",u),r.connection})(this).catch((e=>{throw e}))}authentication(){if(!this.userPool)throw new ae("User pool is missing",{code:"INVALID_REQUEST"});const e=e=>{let t={};if(Array.isArray(e)){let t={};for(let r of e)if(t[r.Name]=r.Value,"custom:service"===r.Name&&t[r.Name]!==this.service)throw new ae("The user is not registered to the service.",{code:"INVALID_REQUEST"});e=t}for(let r in e)r.includes("custom:")?t[r.replace("custom:","")]=e[r]:t[r]=e[r];for(let e of["address_public","birthdate_public","email_public","email_subscription","gender_public","phone_number_public","access_group"])e.includes("_public")?t.hasOwnProperty(e.split("_")[0])?t[e]=!!t.hasOwnProperty(e)&&!!Number(t[e]):delete t[e]:t[e]="email_subscription"===e?!!t.hasOwnProperty(e)&&!!Number(t[e]):t.hasOwnProperty(e)?Number(t[e]):0;for(let e of["email","phone_number"])t.hasOwnProperty(e)?!0===t[e+"_verified"]||"true"===t[e+"_verified"]?t[e+"_verified"]=!0:t[e+"_verified"]=!1:delete t[e+"_verified"];for(let e of["aud",{from:"auth_time",to:"log"},"cognito:username","event_id","exp","iat","iss","jti","origin_jti","secret_key",{from:"sub",to:"user_id"},"token_use"])"string"==typeof e?delete t[e]:(t[e.to]=t[e.from],delete t[e.from]);this.__user=t},r=t=>{let{refreshToken:r=!1}=t||{};return new Promise(((t,n)=>{let i=this.userPool?.getCurrentUser()||null;this.cognitoUser=i,null===i&&n(null),i.getSession(((s,o)=>{s&&n(s),o||n(new ae("Current session does not exist.",{code:"INVALID_REQUEST"})),r||!o.isValid()?i.refreshSession(o.getRefreshToken(),((r,i)=>{r?n(r):i.isValid()?(this.session=i,e(i.getIdToken().payload),t(i)):n(new ae("Invalid session.",{code:"INVALID_REQUEST"}))})):(this.session=o,e(o.getIdToken().payload),t(o))}))}))},n=async e=>{if(!e)throw new ae("E-Mail is required.",{code:"INVALID_PARAMETER"});let t=this.__serviceHash[e]||(await this.updateConnection({request_hash:e})).hash;return{cognitoUser:new J({Username:t,Pool:this.userPool}),cognitoUsername:t}};return{getSession:r,authenticateUser:(e,i)=>new Promise(((s,o)=>{this.__request_signup_confirmation=null,this.__disabledAccount=null,n(e).then((e=>{this.cognitoUser=e.cognitoUser;let n=e.cognitoUsername,a=new t({Username:n,Password:i});this.cognitoUser.authenticateUser(a,{newPasswordRequired:(e,t)=>{this.__request_signup_confirmation=n,o(new ae("User's signup confirmation is required.",{code:"SIGNUP_CONFIRMATION_NEEDED"}))},onSuccess:e=>r().then((e=>s(this.user))),onFailure:e=>{let t=[e.message||"Failed to authenticate user.",e?.code||"INVALID_REQUEST"];"NotAuthorizedException"===e.code&&("User is disabled."===e.message?(this.__disabledAccount=n,t=["This account is disabled.","USER_IS_DISABLED"]):t=["Incorrect username or password.","INCORRECT_USERNAME_OR_PASSWORD"]),o(new ae(t[0],{code:t[1],cause:e}))}})}))})),createCognitoUser:n,getUser:()=>this.session?new Promise(((t,r)=>{null===this.cognitoUser?r(new ae("Invalid session",{code:"INVALID_REQUEST"})):this.cognitoUser.getUserAttributes(((n,i)=>{n?r(n):(e(i),t(this.user))}))})):null}}async getProfile(e){await this.__connection;try{return await this.authentication().getSession(e),this.user}catch(e){return null}}async checkAdmin(){return await this.__connection,this.__user?.service===this.service?this.__user?.service_owner===this.host:(await this.logout(),!1)}async getBlob(e,t){let r=we(e,{url:e=>pe(e)},["url"]);return await this.request(r.url,t||null,{method:"get",auth:r.url.includes("/auth/"),contentType:null,responseType:"blob"})}async mock(e,t){return this.request("mock",e,t)}async secureRequest(e){let t={url:e=>pe(e),data:null,sync:["boolean",()=>!0]};if(Array.isArray(e))for(let r of e)r=we(r,t);else e=we(e,t);return await this.request("post-secure",e,{auth:!0})}_post(e,t,r){let n=null;r.hasOwnProperty("responseType")&&(n=r.responseType,delete r.responseType);let i=Object.assign({method:"POST"},r,{body:t instanceof FormData?t:JSON.stringify(t)});return this._fetch(e,i,n)}async postRecord(e,t){let r=await this.checkAdmin();if(!t)throw new ae(["INVALID_PARAMETER",'"option" argument is required.']);let{formData:n}=t,i={};if("function"==typeof n&&(i.formData=n),delete(t=we(t||{},{record_id:"string",access_group:["number","private"],table:"string",subscription_group:"number",reference:["string",null],index:{name:"string",value:["string","number","boolean"]},tags:e=>{if(null===e)return e;if("string"==typeof e)return[e];if(Array.isArray(e)){for(let t of e)if("string"!=typeof t)throw new ae('"tags" should be type: <string | string[]>',{code:"INVALID_PARAMETER"});return e}throw new ae('"tags" should be type: <string | string[]>',{code:"INVALID_PARAMETER"})},config:{reference_limit:e=>{if(null===e)return null;if("number"==typeof e){if(0>e)throw new ae('"reference_limit" should be >= 0',{code:"INVALID_PARAMETER"});if(e>4503599627370546)throw new ae('"reference_limit" should be <= 4503599627370546',{code:"INVALID_PARAMETER"});return e}throw new ae('"reference_limit" should be type: <number | null>',{code:"INVALID_PARAMETER"})},allow_multiple_reference:"boolean",private_access:e=>{let t="config.private_access";if(null===e)return null;if(e&&"string"==typeof e&&(e=[e]),!Array.isArray(e))throw new ae(`"${t}" should be an array of user ID.`,{code:"INVALID_PARAMETER"});for(let r of e)if(ce(r,`User ID in "${t}"`),this.__user&&r===this.__user.user_id)throw new ae(`"${t}" should not be the uploader's user ID.`,{code:"INVALID_PARAMETER"});return e}}},[],["response","formData","onerror"])).response,delete t.formData,delete t.onerror,""===t?.table)throw new ae('"table" cannot be empty string.',{code:"INVALID_PARAMETER"});if(!t?.table&&!t?.record_id)throw new ae('Either "record_id" or "table" should have a value.',{code:"INVALID_PARAMETER"});if(t?.index){if(!t.index?.name||"string"!=typeof t.index?.name)throw new ae('"index.name" is required. type: string.',{code:"INVALID_PARAMETER"});if(ye(t.index.name,"index name",!0),!t.index.hasOwnProperty("value"))throw new ae('"index.value" is required.',{code:"INVALID_PARAMETER"});if("string"==typeof t.index.value)ye(t.index.value,"index value",!1,!0);else if("number"==typeof t.index.value&&(t.index.value>this.__index_number_range||t.index.value<-this.__index_number_range))throw new ae(`Number value should be within range -${this.__index_number_range} ~ +${this.__index_number_range}`,{code:"INVALID_PARAMETER"})}if(r){if("private"===t?.access_group)throw new ae("Service owner cannot write private records.",{code:"INVALID_REQUEST"});if(t.hasOwnProperty("subscription_group"))throw new ae("Service owner cannot write to subscription table.",{code:"INVALID_REQUEST"})}let s={auth:!0},o=null;if(e instanceof HTMLFormElement||e instanceof FormData||e instanceof SubmitEvent){let r=e instanceof SubmitEvent?e.target:e,n=e instanceof FormData?e:new FormData(r),i=me(e);s.meta=t,Object.keys(i.meta).length&&(s.meta.data=i.meta);let a=[];for(const e of n.entries())i.files.includes(e[0])||a.push(e[0]);if(a.length)for(let e of a)n.delete(e);o=n}else o=Object.assign({data:e},t);return Object.keys(i).length&&Object.assign(s,{fetchOptions:i}),ge(await this.request("post-record",o,s))}subscribeNewsletter(e,t){let r=we(e||{},{email:e=>de(e),bypassWelcome:["boolean",()=>!0]},["email"]);return this.request("subscribe-newsletter",r)}async subscribe(e){let{user_id:t,group:r}=await this.subscriptionGroupCheck(e);if("*"===r)throw new ae("Cannot subscribe to all groups at once.",{code:"INVALID_PARAMETER"});return await this.request("subscription",{subscribe:t,group:r},{auth:!0})}async unsubscribe(e){let{user_id:t,group:r}=await this.subscriptionGroupCheck(e);return await this.request("subscription",{unsubscribe:t,group:r},{auth:!0})}async blockSubscriber(e){let{user_id:t,group:r}=await this.subscriptionGroupCheck(e);return await this.request("subscription",{block:t,group:r},{auth:!0})}async unblockSubscriber(e){let{user_id:t,group:r}=await this.subscriptionGroupCheck(e);return await this.request("subscription",{unblock:t,group:r},{auth:!0})}async getUserSubscriptions(e){return await this.__connection,e=we(e,{user_id:e=>{try{return ce(e,'"user_id"')}catch(e){}try{return de(e)}catch(e){}throw new ae('"subscriber" should be either valid user ID or E-Mail.',{code:"INVALID_PARAMETER"})},group:"number"})||{},this.getSubscriptions({subscriber:e.user_id||this.__user?.user_id,group:e.group})}async getUserSubscribers(e){await this.__connection;let t={subscription:(e=we(e,{user_id:e=>ce(e,'"user_id"'),group:"number"})||{}).user_id||this.__user?.user_id,group:e.group};return this.getSubscriptions(t)}async getSubscriptions(e,t,r){let n=!1;if(e=we(e,{subscriber:e=>{try{return ce(e,'User ID in "subscriber"')}catch(e){}try{let t=de(e);return n=!0,t}catch(e){}throw new ae('"subscriber" should be either valid user ID or E-Mail.',{code:"INVALID_PARAMETER"})},group:"number",subscription:e=>{try{return ce(e,'User ID in "subscription"')}catch(e){}if("string"==typeof e&&14===e.length)return e;throw new ae('"subscriber" should be either valid service ID or user ID.',{code:"INVALID_PARAMETER"})},blocked:"boolean"}),n&&!e?.subscription&&(e.subscription=this.service),!e.subscriber&&!e.subscription)throw new ae('At least either "subscriber" or "subscription" should have a value.',{code:"INVALID_PARAMETER"});let i=await this.request("get-subscription",e,Object.assign({auth:!n},{fetchOptions:t}));return i.list=i.list.map(r||(e=>{let t={},r=e.sub.split("#");return t.subscriber=r[2],t.subscription=r[0],t.group=parseInt(r[1]),t.timestamp=e.stmp,t.blocked="N"===e.grp.substring(0,1),t})),i}async getNewsletters(e,t){let r=await this.checkAdmin(),n={message_id:"string",timestamp:"number",read:"number",complaint:"number",subject:"string"};e||(t||(t={}),t.ascending=!1);let i=e||{searchFor:"timestamp",value:0,condition:">"};e=we(i,{searchFor:["message_id","timestamp","read","complaint","group","subject"],value:e=>{if(typeof e!==n[i.searchFor])throw new ae(`"value" type does not match the type of "${i.searchFor}" index.`,{code:"INVALID_PARAMETER"});if("string"==typeof e&&!e)throw new ae('"value" should not be empty string.',{code:"INVALID_PARAMETER"});return e},range:e=>{if(!i.hasOwnProperty("value")||typeof e!=typeof i.value)throw new ae('"range" should match type of "value".',{code:"INVALID_PARAMETER"});return e},condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],group:e=>{if("newsletter"!==e&&!this.session)throw new ae("User should be logged in.",{code:"INVALID_REQUEST"});if("string"==typeof e&&"newsletter"!==e)throw new ae('Group should be either "newsletter" or access group number.',{code:"INVALID_PARAMETER"});if(!r&&e>parseInt(this.session.idToken.payload.access_group))throw new ae("User has no access.",{code:"INVALID_REQUEST"});return"newsletter"===e?0:e}},["searchFor","value","group"]);let s=await this.request(0===e.group?"get-newsletters":"get-serviceletters",e,Object.assign({method:"get",auth:0!==e.group},{fetchOptions:t})),o={message_id:"mid",timestamp:"stmp",complaint:"cmpl",read:"read",subject:"subj",bounced:"bnce",url:"url"},a={message_id:"",timestamp:0,complaint:0,read:0,subject:"",bounced:0,url:""};return s.list=s.list.map((e=>{let t={};for(let r in o)t[r]=e[o[r]]||a[o[r]];return t})),s}async signup(e,t){await this.logout();let r=we(e||{},{email:e=>de(e),password:e=>fe(e),name:"string",address:"string",gender:"string",birthdate:e=>le(e),phone_number:e=>he(e),email_public:["boolean",()=>!1],address_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1],email_subscription:["boolean",()=>!1]},["email","password"]);t=we(t||{},{confirmation:e=>{if("string"==typeof e)return pe(e);if("boolean"==typeof e)return e;throw new ae('"option.confirmation" should be type: <string | boolean>.',{code:"INVALID_PARAMETER"})},login:e=>{if("boolean"==typeof e){if(t.confirmation&&e)throw new ae('"login" is not allowed when "option.confirmation" is true.',{code:"INVALID_PARAMETER"});return e}throw new ae('"option.login" should be type: boolean.',{code:"INVALID_PARAMETER"})}});let{login:n=!1,confirmation:i=!1}=t||{};if(!i&&r.email_public)throw new ae('"option.confirmation" should be true if "email_public" is set to true.',{code:"INVALID_PARAMETER"});if(await this.request("signup",r,{meta:t}),i){let e=await this.authentication().createCognitoUser(r.email);return this.cognitoUser=e.cognitoUser,this.__request_signup_confirmation=e.cognitoUsername,"SUCCESS: The account has been created. User's email confirmation is required."}return n?await this.login({email:r.email,password:r.password}):"SUCCESS: The account has been created."}async logout(){await this.__connection,this.cognitoUser&&this.cognitoUser.signOut();let e={session:null,__startKey_keys:{},__cached_requests:{},__user:null};for(let t in e)this[t]=e[t];return"SUCCESS: The user has been logged out."}async resendSignupConfirmation(e){if(!this.__request_signup_confirmation)throw new ae("Least one login attempt is required.",{code:"INVALID_REQUEST"});return e&&pe(e),await this.request("confirm-signup",{username:this.__request_signup_confirmation,redirect:e})}async recoverAccount(e=!1){if("string"==typeof e)pe(e);else if("boolean"!=typeof e)throw new ae("Argument should be type: <boolean | string>.",{code:"INVALID_REQUEST"});if(!this.__disabledAccount)throw new ae("Least one signin attempt of disabled account is required.",{code:"INVALID_REQUEST"});return await this.request("recover-account",{username:this.__disabledAccount,redirect:e}),this.__disabledAccount=null,"SUCCESS: Recovery e-mail has been sent."}async login(e,t){await this.__connection,await this.logout();let r=we(e,{email:e=>de(e),password:e=>fe(e)},["email","password"]);return this.authentication().authenticateUser(r.email,r.password)}async verifyAttribute(e,t){if(await this.__connection,!this.cognitoUser)throw new ae("The user has to be logged in.",{code:"INVALID_REQUEST"});return new Promise(((r,n)=>{let i={onSuccess:i=>{t?this.authentication().getSession({refreshToken:!0}).then((()=>{this.__user&&(this.__user[e+"_verified"]=!0),r(`SUCCESS: "${e}" is verified.`)})).catch((e=>{n(e)})):r("SUCCESS: Verification code has been sent.")},onFailure:e=>{n(new ae(e.message||"Failed to request verification code.",{code:e?.code}))}};t?this.cognitoUser?.verifyAttribute(e,t,i):(i.inputVerificationCode=null,this.cognitoUser?.getAttributeVerificationCode(e,i))}))}async verifyEmail(e,t){if(await this.__connection,!this.__user.hasOwnProperty("email"))throw new ae("No e-mail to verify",{code:"INVALID_REQUEST"});let r=(e?we(e,{code:["number","string"]}):{}).code||"";return this.verifyAttribute("email",r.toString())}async verifyPhoneNumber(e,t){if(await this.__connection,!this.__user.hasOwnProperty("phone_number"))throw new ae("No phone number to verify",{code:"INVALID_REQUEST"});let r=(e?we(e,{code:["number","string"]}):{}).code||null;return this.verifyAttribute("phone_number",r.toString())}async forgotPassword(e,t){await this.__connection;let r=we(e,{email:e=>de(e)},["email"]);return new Promise((async(e,t)=>{(await this.authentication().createCognitoUser(r.email)).cognitoUser.forgotPassword({onSuccess:t=>{e("SUCCESS: Verification code has been sent.")},onFailure:e=>{t(new ae(e?.message||"Failed to send verification code.",{code:e?.code||"ERROR"}))}})}))}async resetPassword(e,t){await this.__connection;let r=we(e,{email:e=>de(e),code:["number","string"],new_password:e=>fe(e)},["email","code","new_password"]),n=r.code,i=r.new_password;return"number"==typeof n&&(n=n.toString()),new Promise((async(e,t)=>{(await this.authentication().createCognitoUser(r.email)).cognitoUser.confirmPassword(n,i,{onSuccess:t=>{e("SUCCESS: New password has been set.")},onFailure:e=>{t(new ae(e?.message||"Failed to reset password.",{code:e?.code}))}})}))}async disableAccount(){await this.__connection;let e=await this.request("remove-account",{disable:!0},{auth:!0});return await this.logout(),e}async updateProfile(e,t){if(await this.__connection,!this.session)throw new ae("User login is required.",{code:"INVALID_REQUEST"});let r=we(e||{},{email:e=>de(e),name:"string",address:"string",gender:"string",birthdate:e=>le(e),phone_number:e=>he(e),email_public:"boolean",phone_number_public:"boolean",address_public:"boolean",gender_public:"boolean",birthdate_public:"boolean",email_subscription:"boolean"});if(r&&"object"==typeof r&&!Object.keys(r).length)return this.user;r.email&&(r.preferred_username=(await this.updateConnection({request_hash:r.email})).hash);let n=[["email_subscription","email_verified","User's E-Mail should be verified to set"],["email_public","email_verified","User's E-Mail should be verified to set"],["phone_number_public","phone_number_verified","User's phone number should be verified to set"]];if(this.__user)for(let e of n)if(r[e[0]]&&!this.__user[e[1]])throw new ae(`${e[2]} "${e[0]}" to true.`,{code:"INVALID_REQUEST"});let i=[];for(let e in r)if(r[e]!==this.user[e]){if(["email_public","phone_number_public","address_public","gender_public","birthdate_public","email_subscription"].includes(e)){let t=r[e];"boolean"==typeof t&&(t=t?"1":"0"),r["custom:"+e]=t,i.push(e)}}else i.push(e);for(let e of i)delete r[e];if(r&&"object"==typeof r&&Object.keys(r).length){let e=[];for(let t in r)e.push(new q({Name:t,Value:r[t]}));return await new Promise(((t,r)=>{this.cognitoUser?.updateAttributes(e,((e,n)=>{e&&r([e?.code||e?.name,e?.message||"Failed to update user settings."]),t(n)}))})),await this.authentication().getSession({refreshToken:!0}),this.user}return this.user}async changePassword(e){if(await this.__connection,!this.session)throw new ae("User login is required.",{code:"INVALID_REQUEST"});let t=we(e,{current_password:"string",new_password:"string"});if(!t?.current_password)throw new ae('"current_password" is required to change password.',{code:"INVALID_PARAMETER"});if(!t?.new_password)throw new ae('"new_password" is required to change password.',{code:"INVALID_PARAMETER"});return fe(t.current_password),fe(t.new_password),t.new_password!==t.current_password?new Promise(((e,r)=>{this.cognitoUser.changePassword(t.current_password,t.new_password,((t,n)=>{t&&("InvalidParameterException"===t?.code&&r(new ae("Invalid password parameter.",{code:"INVALID_PARAMETER"})),r(new ae(t?.message||"Failed to change user password.",{code:t?.code||t?.name}))),e("SUCCESS: Password has been changed.")}))})):"SUCCESS: Password has been changed."}async getUsers(e,t){e||(e={searchFor:"timestamp",condition:">",value:0},t||(t={}),t.ascending=!1);let r=await this.checkAdmin();if(r&&!e.hasOwnProperty("service"))throw new ae("Service ID is required.",{code:"INVALID_PARAMETER"});const n={user_id:e=>ce(e),name:"string",email:e=>de(e),phone_number:e=>he(e),address:"string",gender:"string",birthdate:e=>le(e),locale:e=>{if("string"!=typeof e||"string"==typeof e&&e.length>5)throw new ae('Value of "locale" should be a country code.');return e},subscribers:"number",timestamp:"number",access_group:"number",email_subscription:e=>{if(!r)throw new ae('Only admin is allowed to search "email_subscription".',{code:"INVALID_REQUEST"});return e},suspended:e=>e?"by_admin:suspended":"by_admin:approved"};if((e=we(e,{searchFor:["user_id","name","email","phone_number","address","gender","birthdate","locale","subscribers","timestamp","access_group","email_subscription","suspended"],condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],value:t=>{let r=n[e.searchFor];if("function"==typeof r)return r(t);if(typeof t!==r)throw new ae(`Value does not match the type of "${e.searchFor}" index.`,{code:"INVALID_PARAMETER"});return t},range:t=>{let r=n[e.searchFor];if("function"==typeof r)return r(t);if(typeof t!==r)throw new ae(`Range does not match the type of "${e.searchFor}" index.`,{code:"INVALID_PARAMETER"});return t}},["searchFor","value"]))?.condition&&"="!==e?.condition&&e.hasOwnProperty("range"))throw new ae("Conditions does not apply on range search.",{code:"INVALID_PARAMETER"});if("user_id"===e.searchFor&&"="!==e.condition)throw new ae('Conditions are not allowed on "user_id"',{code:"INVALID_PARAMETER"});if("access_group"===e.searchFor&&(e.searchFor="group"),"string"==typeof e?.value&&!e?.value)throw new ae("Value should not be an empty string.",{code:"INVALID_PARAMETER"});if("string"==typeof e?.searchFor&&!e?.searchFor)throw new ae('"searchFor" should not be an empty string.',{code:"INVALID_PARAMETER"});return this.request("get-users",e,{auth:!0,fetchOptions:t})}async updateConnection(e){let t=null,r={};e?.request_hash&&(this.__serviceHash[e.request_hash]?Object.assign(r,{hash:this.__serviceHash[e.request_hash]}):t={request_hash:de(e.request_hash)}),this.connection&&this.connection.service===this.service&&!t||(null===t&&(t={}),Object.assign(t,{service:this.service,service_owner:this.service_owner})),Object.assign(r,t?await this.request("service",t,{bypassAwaitConnection:!0}):this.connection),e?.request_hash&&(this.__serviceHash[e.request_hash]=r.hash);let n=JSON.parse(JSON.stringify(r));return delete n.hash,this.connection=n,r}}Ae([_e()],ve.prototype,"postRecord",null),Ae([_e()],ve.prototype,"subscribeNewsletter",null),Ae([_e()],ve.prototype,"subscribe",null),Ae([_e()],ve.prototype,"unsubscribe",null),Ae([_e()],ve.prototype,"blockSubscriber",null),Ae([_e()],ve.prototype,"unblockSubscriber",null),Ae([_e()],ve.prototype,"signup",null),Ae([_e()],ve.prototype,"login",null),Ae([_e()],ve.prototype,"verifyEmail",null),Ae([_e()],ve.prototype,"verifyPhoneNumber",null),Ae([_e()],ve.prototype,"forgotPassword",null),Ae([_e()],ve.prototype,"resetPassword",null),Ae([_e()],ve.prototype,"updateProfile",null),Ae([_e()],ve.prototype,"changePassword",null)})(),n})()));
|
|
2
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(self,(()=>(()=>{var e={742:(e,t)=>{"use strict";t.byteLength=function(e){var t=u(e),r=t[0],n=t[1];return 3*(r+n)/4-n},t.toByteArray=function(e){var t,r,s=u(e),o=s[0],a=s[1],c=new i(function(e,t,r){return 3*(t+r)/4-r}(0,o,a)),h=0,l=a>0?o-4:o;for(r=0;r<l;r+=4)t=n[e.charCodeAt(r)]<<18|n[e.charCodeAt(r+1)]<<12|n[e.charCodeAt(r+2)]<<6|n[e.charCodeAt(r+3)],c[h++]=t>>16&255,c[h++]=t>>8&255,c[h++]=255&t;return 2===a&&(t=n[e.charCodeAt(r)]<<2|n[e.charCodeAt(r+1)]>>4,c[h++]=255&t),1===a&&(t=n[e.charCodeAt(r)]<<10|n[e.charCodeAt(r+1)]<<4|n[e.charCodeAt(r+2)]>>2,c[h++]=t>>8&255,c[h++]=255&t),c},t.fromByteArray=function(e){for(var t,n=e.length,i=n%3,s=[],o=16383,a=0,u=n-i;a<u;a+=o)s.push(c(e,a,a+o>u?u:a+o));return 1===i?(t=e[n-1],s.push(r[t>>2]+r[t<<4&63]+"==")):2===i&&(t=(e[n-2]<<8)+e[n-1],s.push(r[t>>10]+r[t>>4&63]+r[t<<2&63]+"=")),s.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0,a=s.length;o<a;++o)r[o]=s[o],n[s.charCodeAt(o)]=o;function u(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");return-1===r&&(r=t),[r,r===t?0:4-r%4]}function c(e,t,n){for(var i,s,o=[],a=t;a<n;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(r[(s=i)>>18&63]+r[s>>12&63]+r[s>>6&63]+r[63&s]);return o.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},764:(e,t,r)=>{"use strict";var n=r(742),i=r(645),s=r(826);function o(){return u.TYPED_ARRAY_SUPPORT?2147483647:1073741823}function a(e,t){if(o()<t)throw new RangeError("Invalid typed array length");return u.TYPED_ARRAY_SUPPORT?(e=new Uint8Array(t)).__proto__=u.prototype:(null===e&&(e=new u(t)),e.length=t),e}function u(e,t,r){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,r);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return l(this,e)}return c(this,e,t,r)}function c(e,t,r,n){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,r,n){if(t.byteLength,r<0||t.byteLength<r)throw new RangeError("'offset' is out of bounds");if(t.byteLength<r+(n||0))throw new RangeError("'length' is out of bounds");return t=void 0===r&&void 0===n?new Uint8Array(t):void 0===n?new Uint8Array(t,r):new Uint8Array(t,r,n),u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=f(e,t),e}(e,t,r,n):"string"==typeof t?function(e,t,r){if("string"==typeof r&&""!==r||(r="utf8"),!u.isEncoding(r))throw new TypeError('"encoding" must be a valid string encoding');var n=0|p(t,r),i=(e=a(e,n)).write(t,r);return i!==n&&(e=e.slice(0,i)),e}(e,t,r):function(e,t){if(u.isBuffer(t)){var r=0|d(t.length);return 0===(e=a(e,r)).length||t.copy(e,0,0,r),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(n=t.length)!=n?a(e,0):f(e,t);if("Buffer"===t.type&&s(t.data))return f(e,t.data)}var n;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function h(e){if("number"!=typeof e)throw new TypeError('"size" argument must be a number');if(e<0)throw new RangeError('"size" argument must not be negative')}function l(e,t){if(h(t),e=a(e,t<0?0:0|d(t)),!u.TYPED_ARRAY_SUPPORT)for(var r=0;r<t;++r)e[r]=0;return e}function f(e,t){var r=t.length<0?0:0|d(t.length);e=a(e,r);for(var n=0;n<r;n+=1)e[n]=255&t[n];return e}function d(e){if(e>=o())throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o().toString(16)+" bytes");return 0|e}function p(e,t){if(u.isBuffer(e))return e.length;if("undefined"!=typeof ArrayBuffer&&"function"==typeof ArrayBuffer.isView&&(ArrayBuffer.isView(e)||e instanceof ArrayBuffer))return e.byteLength;"string"!=typeof e&&(e=""+e);var r=e.length;if(0===r)return 0;for(var n=!1;;)switch(t){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(e).length;default:if(n)return B(e).length;t=(""+t).toLowerCase(),n=!0}}function g(e,t,r){var n=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,r);case"utf8":case"utf-8":return R(this,t,r);case"ascii":return U(this,t,r);case"latin1":case"binary":return D(this,t,r);case"base64":return I(this,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,r);default:if(n)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),n=!0}}function y(e,t,r){var n=e[t];e[t]=e[r],e[r]=n}function w(e,t,r,n,i){if(0===e.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),r=+r,isNaN(r)&&(r=i?0:e.length-1),r<0&&(r=e.length+r),r>=e.length){if(i)return-1;r=e.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof t&&(t=u.from(t,n)),u.isBuffer(t))return 0===t.length?-1:m(e,t,r,n,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,r):Uint8Array.prototype.lastIndexOf.call(e,t,r):m(e,[t],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(e,t,r,n,i){var s,o=1,a=e.length,u=t.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(e.length<2||t.length<2)return-1;o=2,a/=2,u/=2,r/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var h=-1;for(s=r;s<a;s++)if(c(e,s)===c(t,-1===h?0:s-h)){if(-1===h&&(h=s),s-h+1===u)return h*o}else-1!==h&&(s-=s-h),h=-1}else for(r+u>a&&(r=a-u),s=r;s>=0;s--){for(var l=!0,f=0;f<u;f++)if(c(e,s+f)!==c(t,f)){l=!1;break}if(l)return s}return-1}function _(e,t,r,n){r=Number(r)||0;var i=e.length-r;n?(n=Number(n))>i&&(n=i):n=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");n>s/2&&(n=s/2);for(var o=0;o<n;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[r+o]=a}return o}function A(e,t,r,n){return K(B(t,e.length-r),e,r,n)}function v(e,t,r,n){return K(function(e){for(var t=[],r=0;r<e.length;++r)t.push(255&e.charCodeAt(r));return t}(t),e,r,n)}function b(e,t,r,n){return v(e,t,r,n)}function S(e,t,r,n){return K(q(t),e,r,n)}function E(e,t,r,n){return K(function(e,t){for(var r,n,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)n=(r=e.charCodeAt(o))>>8,i=r%256,s.push(i),s.push(n);return s}(t,e.length-r),e,r,n)}function I(e,t,r){return 0===t&&r===e.length?n.fromByteArray(e):n.fromByteArray(e.slice(t,r))}function R(e,t,r){r=Math.min(e.length,r);for(var n=[],i=t;i<r;){var s,o,a,u,c=e[i],h=null,l=c>239?4:c>223?3:c>191?2:1;if(i+l<=r)switch(l){case 1:c<128&&(h=c);break;case 2:128==(192&(s=e[i+1]))&&(u=(31&c)<<6|63&s)>127&&(h=u);break;case 3:s=e[i+1],o=e[i+2],128==(192&s)&&128==(192&o)&&(u=(15&c)<<12|(63&s)<<6|63&o)>2047&&(u<55296||u>57343)&&(h=u);break;case 4:s=e[i+1],o=e[i+2],a=e[i+3],128==(192&s)&&128==(192&o)&&128==(192&a)&&(u=(15&c)<<18|(63&s)<<12|(63&o)<<6|63&a)>65535&&u<1114112&&(h=u)}null===h?(h=65533,l=1):h>65535&&(h-=65536,n.push(h>>>10&1023|55296),h=56320|1023&h),n.push(h),i+=l}return function(e){var t=e.length;if(t<=T)return String.fromCharCode.apply(String,e);for(var r="",n=0;n<t;)r+=String.fromCharCode.apply(String,e.slice(n,n+=T));return r}(n)}t.lW=u,t.h2=50,u.TYPED_ARRAY_SUPPORT=void 0!==r.g.TYPED_ARRAY_SUPPORT?r.g.TYPED_ARRAY_SUPPORT:function(){try{var e=new Uint8Array(1);return e.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},42===e.foo()&&"function"==typeof e.subarray&&0===e.subarray(1,1).byteLength}catch(e){return!1}}(),o(),u.poolSize=8192,u._augment=function(e){return e.__proto__=u.prototype,e},u.from=function(e,t,r){return c(null,e,t,r)},u.TYPED_ARRAY_SUPPORT&&(u.prototype.__proto__=Uint8Array.prototype,u.__proto__=Uint8Array,"undefined"!=typeof Symbol&&Symbol.species&&u[Symbol.species]===u&&Object.defineProperty(u,Symbol.species,{value:null,configurable:!0})),u.alloc=function(e,t,r){return function(e,t,r,n){return h(t),t<=0?a(e,t):void 0!==r?"string"==typeof n?a(e,t).fill(r,n):a(e,t).fill(r):a(e,t)}(null,e,t,r)},u.allocUnsafe=function(e){return l(null,e)},u.allocUnsafeSlow=function(e){return l(null,e)},u.isBuffer=function(e){return!(null==e||!e._isBuffer)},u.compare=function(e,t){if(!u.isBuffer(e)||!u.isBuffer(t))throw new TypeError("Arguments must be Buffers");if(e===t)return 0;for(var r=e.length,n=t.length,i=0,s=Math.min(r,n);i<s;++i)if(e[i]!==t[i]){r=e[i],n=t[i];break}return r<n?-1:n<r?1:0},u.isEncoding=function(e){switch(String(e).toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},u.concat=function(e,t){if(!s(e))throw new TypeError('"list" argument must be an Array of Buffers');if(0===e.length)return u.alloc(0);var r;if(void 0===t)for(t=0,r=0;r<e.length;++r)t+=e[r].length;var n=u.allocUnsafe(t),i=0;for(r=0;r<e.length;++r){var o=e[r];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i),i+=o.length}return n},u.byteLength=p,u.prototype._isBuffer=!0,u.prototype.swap16=function(){var e=this.length;if(e%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var t=0;t<e;t+=2)y(this,t,t+1);return this},u.prototype.swap32=function(){var e=this.length;if(e%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var t=0;t<e;t+=4)y(this,t,t+3),y(this,t+1,t+2);return this},u.prototype.swap64=function(){var e=this.length;if(e%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var t=0;t<e;t+=8)y(this,t,t+7),y(this,t+1,t+6),y(this,t+2,t+5),y(this,t+3,t+4);return this},u.prototype.toString=function(){var e=0|this.length;return 0===e?"":0===arguments.length?R(this,0,e):g.apply(this,arguments)},u.prototype.equals=function(e){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");return this===e||0===u.compare(this,e)},u.prototype.inspect=function(){var e="",r=t.h2;return this.length>0&&(e=this.toString("hex",0,r).match(/.{2}/g).join(" "),this.length>r&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,r,n,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===r&&(r=e?e.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),t<0||r>e.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&t>=r)return 0;if(n>=i)return-1;if(t>=r)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(n>>>=0),o=(r>>>=0)-(t>>>=0),a=Math.min(s,o),c=this.slice(n,i),h=e.slice(t,r),l=0;l<a;++l)if(c[l]!==h[l]){s=c[l],o=h[l];break}return s<o?-1:o<s?1:0},u.prototype.includes=function(e,t,r){return-1!==this.indexOf(e,t,r)},u.prototype.indexOf=function(e,t,r){return w(this,e,t,r,!0)},u.prototype.lastIndexOf=function(e,t,r){return w(this,e,t,r,!1)},u.prototype.write=function(e,t,r,n){if(void 0===t)n="utf8",r=this.length,t=0;else if(void 0===r&&"string"==typeof t)n=t,r=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(r)?(r|=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-t;if((void 0===r||r>i)&&(r=i),e.length>0&&(r<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var s=!1;;)switch(n){case"hex":return _(this,e,t,r);case"utf8":case"utf-8":return A(this,e,t,r);case"ascii":return v(this,e,t,r);case"latin1":case"binary":return b(this,e,t,r);case"base64":return S(this,e,t,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return E(this,e,t,r);default:if(s)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),s=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var T=4096;function U(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(127&e[i]);return n}function D(e,t,r){var n="";r=Math.min(e.length,r);for(var i=t;i<r;++i)n+=String.fromCharCode(e[i]);return n}function C(e,t,r){var n,i=e.length;(!t||t<0)&&(t=0),(!r||r<0||r>i)&&(r=i);for(var s="",o=t;o<r;++o)s+=(n=e[o])<16?"0"+n.toString(16):n.toString(16);return s}function P(e,t,r){for(var n=e.slice(t,r),i="",s=0;s<n.length;s+=2)i+=String.fromCharCode(n[s]+256*n[s+1]);return i}function N(e,t,r){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>r)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,r,n,i,s){if(!u.isBuffer(e))throw new TypeError('"buffer" argument must be a Buffer instance');if(t>i||t<s)throw new RangeError('"value" argument is out of bounds');if(r+n>e.length)throw new RangeError("Index out of range")}function O(e,t,r,n){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-r,2);i<s;++i)e[r+i]=(t&255<<8*(n?i:1-i))>>>8*(n?i:1-i)}function M(e,t,r,n){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-r,4);i<s;++i)e[r+i]=t>>>8*(n?i:3-i)&255}function F(e,t,r,n,i,s){if(r+n>e.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function V(e,t,r,n,s){return s||F(e,0,r,4),i.write(e,t,r,n,23,4),r+4}function x(e,t,r,n,s){return s||F(e,0,r,8),i.write(e,t,r,n,52,8),r+8}u.prototype.slice=function(e,t){var r,n=this.length;if((e=~~e)<0?(e+=n)<0&&(e=0):e>n&&(e=n),(t=void 0===t?n:~~t)<0?(t+=n)<0&&(t=0):t>n&&(t=n),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(r=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;r=new u(i,void 0);for(var s=0;s<i;++s)r[s]=this[s+e]}return r},u.prototype.readUIntLE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n},u.prototype.readUIntBE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e+--t],i=1;t>0&&(i*=256);)n+=this[e+--t]*i;return n},u.prototype.readUInt8=function(e,t){return t||N(e,1,this.length),this[e]},u.prototype.readUInt16LE=function(e,t){return t||N(e,2,this.length),this[e]|this[e+1]<<8},u.prototype.readUInt16BE=function(e,t){return t||N(e,2,this.length),this[e]<<8|this[e+1]},u.prototype.readUInt32LE=function(e,t){return t||N(e,4,this.length),(this[e]|this[e+1]<<8|this[e+2]<<16)+16777216*this[e+3]},u.prototype.readUInt32BE=function(e,t){return t||N(e,4,this.length),16777216*this[e]+(this[e+1]<<16|this[e+2]<<8|this[e+3])},u.prototype.readIntLE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=this[e],i=1,s=0;++s<t&&(i*=256);)n+=this[e+s]*i;return n>=(i*=128)&&(n-=Math.pow(2,8*t)),n},u.prototype.readIntBE=function(e,t,r){e|=0,t|=0,r||N(e,t,this.length);for(var n=t,i=1,s=this[e+--n];n>0&&(i*=256);)s+=this[e+--n]*i;return s>=(i*=128)&&(s-=Math.pow(2,8*t)),s},u.prototype.readInt8=function(e,t){return t||N(e,1,this.length),128&this[e]?-1*(255-this[e]+1):this[e]},u.prototype.readInt16LE=function(e,t){t||N(e,2,this.length);var r=this[e]|this[e+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(e,t){t||N(e,2,this.length);var r=this[e+1]|this[e]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(e,t){return t||N(e,4,this.length),this[e]|this[e+1]<<8|this[e+2]<<16|this[e+3]<<24},u.prototype.readInt32BE=function(e,t){return t||N(e,4,this.length),this[e]<<24|this[e+1]<<16|this[e+2]<<8|this[e+3]},u.prototype.readFloatLE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!0,23,4)},u.prototype.readFloatBE=function(e,t){return t||N(e,4,this.length),i.read(this,e,!1,23,4)},u.prototype.readDoubleLE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!0,52,8)},u.prototype.readDoubleBE=function(e,t){return t||N(e,8,this.length),i.read(this,e,!1,52,8)},u.prototype.writeUIntLE=function(e,t,r,n){e=+e,t|=0,r|=0,n||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=1,s=0;for(this[t]=255&e;++s<r&&(i*=256);)this[t+s]=e/i&255;return t+r},u.prototype.writeUIntBE=function(e,t,r,n){e=+e,t|=0,r|=0,n||k(this,e,t,r,Math.pow(2,8*r)-1,0);var i=r-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+r},u.prototype.writeUInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,255,0),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),this[t]=255&e,t+1},u.prototype.writeUInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeUInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,65535,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeUInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t+3]=e>>>24,this[t+2]=e>>>16,this[t+1]=e>>>8,this[t]=255&e):M(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,4294967295,0),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<r&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},u.prototype.writeIntBE=function(e,t,r,n){if(e=+e,t|=0,!n){var i=Math.pow(2,8*r-1);k(this,e,t,r,i-1,-i)}var s=r-1,o=1,a=0;for(this[t+s]=255&e;--s>=0&&(o*=256);)e<0&&0===a&&0!==this[t+s+1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+r},u.prototype.writeInt8=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,1,127,-128),u.TYPED_ARRAY_SUPPORT||(e=Math.floor(e)),e<0&&(e=255+e+1),this[t]=255&e,t+1},u.prototype.writeInt16LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8):O(this,e,t,!0),t+2},u.prototype.writeInt16BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,2,32767,-32768),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>8,this[t+1]=255&e):O(this,e,t,!1),t+2},u.prototype.writeInt32LE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),u.TYPED_ARRAY_SUPPORT?(this[t]=255&e,this[t+1]=e>>>8,this[t+2]=e>>>16,this[t+3]=e>>>24):M(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,r){return e=+e,t|=0,r||k(this,e,t,4,2147483647,-2147483648),e<0&&(e=4294967295+e+1),u.TYPED_ARRAY_SUPPORT?(this[t]=e>>>24,this[t+1]=e>>>16,this[t+2]=e>>>8,this[t+3]=255&e):M(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,r){return V(this,e,t,!0,r)},u.prototype.writeFloatBE=function(e,t,r){return V(this,e,t,!1,r)},u.prototype.writeDoubleLE=function(e,t,r){return x(this,e,t,!0,r)},u.prototype.writeDoubleBE=function(e,t,r){return x(this,e,t,!1,r)},u.prototype.copy=function(e,t,r,n){if(r||(r=0),n||0===n||(n=this.length),t>=e.length&&(t=e.length),t||(t=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("sourceStart out of bounds");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),e.length-t<n-r&&(n=e.length-t+r);var i,s=n-r;if(this===e&&r<t&&t<n)for(i=s-1;i>=0;--i)e[i+t]=this[i+r];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+r];else Uint8Array.prototype.set.call(e,this.subarray(r,r+s),t);return s},u.prototype.fill=function(e,t,r,n){if("string"==typeof e){if("string"==typeof t?(n=t,t=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<r)throw new RangeError("Out of range index");if(r<=t)return this;var s;if(t>>>=0,r=void 0===r?this.length:r>>>0,e||(e=0),"number"==typeof e)for(s=t;s<r;++s)this[s]=e;else{var o=u.isBuffer(e)?e:B(new u(e,n).toString()),a=o.length;for(s=0;s<r-t;++s)this[s+t]=o[s%a]}return this};var L=/[^+\/0-9A-Za-z-_]/g;function B(e,t){var r;t=t||1/0;for(var n=e.length,i=null,s=[],o=0;o<n;++o){if((r=e.charCodeAt(o))>55295&&r<57344){if(!i){if(r>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===n){(t-=3)>-1&&s.push(239,191,189);continue}i=r;continue}if(r<56320){(t-=3)>-1&&s.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,r<128){if((t-=1)<0)break;s.push(r)}else if(r<2048){if((t-=2)<0)break;s.push(r>>6|192,63&r|128)}else if(r<65536){if((t-=3)<0)break;s.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return s}function q(e){return n.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(L,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function K(e,t,r,n){for(var i=0;i<n&&!(i+r>=t.length||i>=e.length);++i)t[i+r]=e[i];return i}},249:function(e,t,r){var n;e.exports=(n=n||function(e,t){var n;if("undefined"!=typeof window&&window.crypto&&(n=window.crypto),"undefined"!=typeof self&&self.crypto&&(n=self.crypto),"undefined"!=typeof globalThis&&globalThis.crypto&&(n=globalThis.crypto),!n&&"undefined"!=typeof window&&window.msCrypto&&(n=window.msCrypto),!n&&void 0!==r.g&&r.g.crypto&&(n=r.g.crypto),!n)try{n=r(480)}catch(e){}var i=function(){if(n){if("function"==typeof n.getRandomValues)try{return n.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof n.randomBytes)try{return n.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")},s=Object.create||function(){function e(){}return function(t){var r;return e.prototype=t,r=new e,e.prototype=null,r}}(),o={},a=o.lib={},u=a.Base={extend:function(e){var t=s(this);return e&&t.mixIn(e),t.hasOwnProperty("init")&&this.init!==t.init||(t.init=function(){t.$super.init.apply(this,arguments)}),t.init.prototype=t,t.$super=this,t},create:function(){var e=this.extend();return e.init.apply(e,arguments),e},init:function(){},mixIn:function(e){for(var t in e)e.hasOwnProperty(t)&&(this[t]=e[t]);e.hasOwnProperty("toString")&&(this.toString=e.toString)},clone:function(){return this.init.prototype.extend(this)}},c=a.WordArray=u.extend({init:function(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length},toString:function(e){return(e||l).stringify(this)},concat:function(e){var t=this.words,r=e.words,n=this.sigBytes,i=e.sigBytes;if(this.clamp(),n%4)for(var s=0;s<i;s++){var o=r[s>>>2]>>>24-s%4*8&255;t[n+s>>>2]|=o<<24-(n+s)%4*8}else for(var a=0;a<i;a+=4)t[n+a>>>2]=r[a>>>2];return this.sigBytes+=i,this},clamp:function(){var t=this.words,r=this.sigBytes;t[r>>>2]&=4294967295<<32-r%4*8,t.length=e.ceil(r/4)},clone:function(){var e=u.clone.call(this);return e.words=this.words.slice(0),e},random:function(e){for(var t=[],r=0;r<e;r+=4)t.push(i());return new c.init(t,e)}}),h=o.enc={},l=h.Hex={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n+=2)r[n>>>3]|=parseInt(e.substr(n,2),16)<<24-n%8*4;return new c.init(r,t/2)}},f=h.Latin1={stringify:function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push(String.fromCharCode(s))}return n.join("")},parse:function(e){for(var t=e.length,r=[],n=0;n<t;n++)r[n>>>2]|=(255&e.charCodeAt(n))<<24-n%4*8;return new c.init(r,t)}},d=h.Utf8={stringify:function(e){try{return decodeURIComponent(escape(f.stringify(e)))}catch(e){throw new Error("Malformed UTF-8 data")}},parse:function(e){return f.parse(unescape(encodeURIComponent(e)))}},p=a.BufferedBlockAlgorithm=u.extend({reset:function(){this._data=new c.init,this._nDataBytes=0},_append:function(e){"string"==typeof e&&(e=d.parse(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes},_process:function(t){var r,n=this._data,i=n.words,s=n.sigBytes,o=this.blockSize,a=s/(4*o),u=(a=t?e.ceil(a):e.max((0|a)-this._minBufferSize,0))*o,h=e.min(4*u,s);if(u){for(var l=0;l<u;l+=o)this._doProcessBlock(i,l);r=i.splice(0,u),n.sigBytes-=h}return new c.init(r,h)},clone:function(){var e=u.clone.call(this);return e._data=this._data.clone(),e},_minBufferSize:0}),g=(a.Hasher=p.extend({cfg:u.extend(),init:function(e){this.cfg=this.cfg.extend(e),this.reset()},reset:function(){p.reset.call(this),this._doReset()},update:function(e){return this._append(e),this._process(),this},finalize:function(e){return e&&this._append(e),this._doFinalize()},blockSize:16,_createHelper:function(e){return function(t,r){return new e.init(r).finalize(t)}},_createHmacHelper:function(e){return function(t,r){return new g.HMAC.init(e,r).finalize(t)}}}),o.algo={});return o}(Math),n)},269:function(e,t,r){var n,i,s;e.exports=(n=r(249),s=(i=n).lib.WordArray,i.enc.Base64={stringify:function(e){var t=e.words,r=e.sigBytes,n=this._map;e.clamp();for(var i=[],s=0;s<r;s+=3)for(var o=(t[s>>>2]>>>24-s%4*8&255)<<16|(t[s+1>>>2]>>>24-(s+1)%4*8&255)<<8|t[s+2>>>2]>>>24-(s+2)%4*8&255,a=0;a<4&&s+.75*a<r;a++)i.push(n.charAt(o>>>6*(3-a)&63));var u=n.charAt(64);if(u)for(;i.length%4;)i.push(u);return i.join("")},parse:function(e){var t=e.length,r=this._map,n=this._reverseMap;if(!n){n=this._reverseMap=[];for(var i=0;i<r.length;i++)n[r.charCodeAt(i)]=i}var o=r.charAt(64);if(o){var a=e.indexOf(o);-1!==a&&(t=a)}return function(e,t,r){for(var n=[],i=0,o=0;o<t;o++)if(o%4){var a=r[e.charCodeAt(o-1)]<<o%4*2|r[e.charCodeAt(o)]>>>6-o%4*2;n[i>>>2]|=a<<24-i%4*8,i++}return s.create(n,i)}(e,t,n)},_map:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="},n.enc.Base64)},10:function(e,t,r){var n;e.exports=(n=r(249),r(153),r(824),n.HmacSHA256)},824:function(e,t,r){var n,i,s;e.exports=(i=(n=r(249)).lib.Base,s=n.enc.Utf8,void(n.algo.HMAC=i.extend({init:function(e,t){e=this._hasher=new e.init,"string"==typeof t&&(t=s.parse(t));var r=e.blockSize,n=4*r;t.sigBytes>n&&(t=e.finalize(t)),t.clamp();for(var i=this._oKey=t.clone(),o=this._iKey=t.clone(),a=i.words,u=o.words,c=0;c<r;c++)a[c]^=1549556828,u[c]^=909522486;i.sigBytes=o.sigBytes=n,this.reset()},reset:function(){var e=this._hasher;e.reset(),e.update(this._iKey)},update:function(e){return this._hasher.update(e),this},finalize:function(e){var t=this._hasher,r=t.finalize(e);return t.reset(),t.finalize(this._oKey.clone().concat(r))}})))},433:function(e,t,r){var n;e.exports=(n=r(249),function(){if("function"==typeof ArrayBuffer){var e=n.lib.WordArray,t=e.init,r=e.init=function(e){if(e instanceof ArrayBuffer&&(e=new Uint8Array(e)),(e instanceof Int8Array||"undefined"!=typeof Uint8ClampedArray&&e instanceof Uint8ClampedArray||e instanceof Int16Array||e instanceof Uint16Array||e instanceof Int32Array||e instanceof Uint32Array||e instanceof Float32Array||e instanceof Float64Array)&&(e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength)),e instanceof Uint8Array){for(var r=e.byteLength,n=[],i=0;i<r;i++)n[i>>>2]|=e[i]<<24-i%4*8;t.call(this,n,r)}else t.apply(this,arguments)};r.prototype=e}}(),n.lib.WordArray)},153:function(e,t,r){var n;e.exports=(n=r(249),function(e){var t=n,r=t.lib,i=r.WordArray,s=r.Hasher,o=t.algo,a=[],u=[];!function(){function t(t){for(var r=e.sqrt(t),n=2;n<=r;n++)if(!(t%n))return!1;return!0}function r(e){return 4294967296*(e-(0|e))|0}for(var n=2,i=0;i<64;)t(n)&&(i<8&&(a[i]=r(e.pow(n,.5))),u[i]=r(e.pow(n,1/3)),i++),n++}();var c=[],h=o.SHA256=s.extend({_doReset:function(){this._hash=new i.init(a.slice(0))},_doProcessBlock:function(e,t){for(var r=this._hash.words,n=r[0],i=r[1],s=r[2],o=r[3],a=r[4],h=r[5],l=r[6],f=r[7],d=0;d<64;d++){if(d<16)c[d]=0|e[t+d];else{var p=c[d-15],g=(p<<25|p>>>7)^(p<<14|p>>>18)^p>>>3,y=c[d-2],w=(y<<15|y>>>17)^(y<<13|y>>>19)^y>>>10;c[d]=g+c[d-7]+w+c[d-16]}var m=n&i^n&s^i&s,_=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),A=f+((a<<26|a>>>6)^(a<<21|a>>>11)^(a<<7|a>>>25))+(a&h^~a&l)+u[d]+c[d];f=l,l=h,h=a,a=o+A|0,o=s,s=i,i=n,n=A+(_+m)|0}r[0]=r[0]+n|0,r[1]=r[1]+i|0,r[2]=r[2]+s|0,r[3]=r[3]+o|0,r[4]=r[4]+a|0,r[5]=r[5]+h|0,r[6]=r[6]+l|0,r[7]=r[7]+f|0},_doFinalize:function(){var t=this._data,r=t.words,n=8*this._nDataBytes,i=8*t.sigBytes;return r[i>>>5]|=128<<24-i%32,r[14+(i+64>>>9<<4)]=e.floor(n/4294967296),r[15+(i+64>>>9<<4)]=n,t.sigBytes=4*r.length,this._process(),this._hash},clone:function(){var e=s.clone.call(this);return e._hash=this._hash.clone(),e}});t.SHA256=s._createHelper(h),t.HmacSHA256=s._createHmacHelper(h)}(Math),n.SHA256)},645:(e,t)=>{t.read=function(e,t,r,n,i){var s,o,a=8*i-n-1,u=(1<<a)-1,c=u>>1,h=-7,l=r?i-1:0,f=r?-1:1,d=e[t+l];for(l+=f,s=d&(1<<-h)-1,d>>=-h,h+=a;h>0;s=256*s+e[t+l],l+=f,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=n;h>0;o=256*o+e[t+l],l+=f,h-=8);if(0===s)s=1-c;else{if(s===u)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,n),s-=c}return(d?-1:1)*o*Math.pow(2,s-n)},t.write=function(e,t,r,n,i,s){var o,a,u,c=8*s-i-1,h=(1<<c)-1,l=h>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=n?0:s-1,p=n?1:-1,g=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(a=isNaN(t)?1:0,o=h):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),(t+=o+l>=1?f/u:f*Math.pow(2,1-l))*u>=2&&(o++,u/=2),o+l>=h?(a=0,o=h):o+l>=1?(a=(t*u-1)*Math.pow(2,i),o+=l):(a=t*Math.pow(2,l-1)*Math.pow(2,i),o=0));i>=8;e[r+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;e[r+d]=255&o,d+=p,o/=256,c-=8);e[r+d-p]|=128*g}},826:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},204:(e,t,r)=>{e.exports=self.fetch||(self.fetch=r(869).default||r(869))},808:(e,t,r)=>{var n,i,s;void 0===(i="function"==typeof(n=s=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var r=arguments[e];for(var n in r)t[n]=r[n]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function r(n){function i(){}function s(t,r,s){if("undefined"!=typeof document){"number"==typeof(s=e({path:"/"},i.defaults,s)).expires&&(s.expires=new Date(1*new Date+864e5*s.expires)),s.expires=s.expires?s.expires.toUTCString():"";try{var o=JSON.stringify(r);/^[\{\[]/.test(o)&&(r=o)}catch(e){}r=n.write?n.write(r,t):encodeURIComponent(String(r)).replace(/%(23|24|26|2B|3A|3C|3E|3D|2F|3F|40|5B|5D|5E|60|7B|7D|7C)/g,decodeURIComponent),t=encodeURIComponent(String(t)).replace(/%(23|24|26|2B|5E|60|7C)/g,decodeURIComponent).replace(/[\(\)]/g,escape);var a="";for(var u in s)s[u]&&(a+="; "+u,!0!==s[u]&&(a+="="+s[u].split(";")[0]));return document.cookie=t+"="+r+a}}function o(e,r){if("undefined"!=typeof document){for(var i={},s=document.cookie?document.cookie.split("; "):[],o=0;o<s.length;o++){var a=s[o].split("="),u=a.slice(1).join("=");r||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var c=t(a[0]);if(u=(n.read||n)(u,c)||t(u),r)try{u=JSON.parse(u)}catch(e){}if(i[c]=u,e===c)break}catch(e){}}return e?i[e]:i}}return i.set=s,i.get=function(e){return o(e,!1)},i.getJSON=function(e){return o(e,!0)},i.remove=function(t,r){s(t,"",e(r,{expires:-1}))},i.defaults={},i.withConverter=r,i}((function(){}))})?n.call(t,r,t,e):n)||(e.exports=i),e.exports=s()},869:(e,t,r)=>{"use strict";function n(e,t){return t=t||{},new Promise((function(r,n){var i=new XMLHttpRequest,s=[],o=[],a={},u=function(){return{ok:2==(i.status/100|0),statusText:i.statusText,status:i.status,url:i.responseURL,text:function(){return Promise.resolve(i.responseText)},json:function(){return Promise.resolve(i.responseText).then(JSON.parse)},blob:function(){return Promise.resolve(new Blob([i.response]))},clone:u,headers:{keys:function(){return s},entries:function(){return o},get:function(e){return a[e.toLowerCase()]},has:function(e){return e.toLowerCase()in a}}}};for(var c in i.open(t.method||"get",e,!0),i.onload=function(){i.getAllResponseHeaders().replace(/^(.*?):[^\S\n]*([\s\S]*?)$/gm,(function(e,t,r){s.push(t=t.toLowerCase()),o.push([t,r]),a[t]=a[t]?a[t]+","+r:r})),r(u())},i.onerror=n,i.withCredentials="include"==t.credentials,t.headers)i.setRequestHeader(c,t.headers[c]);i.send(t.body||null)}))}r.r(t),r.d(t,{default:()=>n})},296:()=>{},480:()=>{}},t={};function r(n){var i=t[n];if(void 0!==i)return i.exports;var s=t[n]={exports:{}};return e[n].call(s.exports,s,s.exports,r),s.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};return(()=>{"use strict";r.r(n),r.d(n,{Skapi:()=>ve,SkapiError:()=>ae});var e,t=function(){function e(e){var t=e||{},r=t.ValidationData,n=t.Username,i=t.Password,s=t.AuthParameters,o=t.ClientMetadata;this.validationData=r||{},this.authParameters=s||{},this.clientMetadata=o||{},this.username=n,this.password=i}var t=e.prototype;return t.getUsername=function(){return this.username},t.getPassword=function(){return this.password},t.getValidationData=function(){return this.validationData},t.getAuthParameters=function(){return this.authParameters},t.getClientMetadata=function(){return this.clientMetadata},e}(),i=r(764),s=r(249),o=r.n(s),a=(r(433),r(153)),u=r.n(a),c=r(10),h=r.n(c);if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==r.g&&r.g.crypto&&(e=r.g.crypto),!e)try{e=r(296)}catch(e){}function l(){if(e){if("function"==typeof e.getRandomValues)try{return e.getRandomValues(new Uint32Array(1))[0]}catch(e){}if("function"==typeof e.randomBytes)try{return e.randomBytes(4).readInt32LE()}catch(e){}}throw new Error("Native crypto module could not be used to get secure random number.")}var f=function(){function e(e,t){e=this.words=e||[],this.sigBytes=null!=t?t:4*e.length}var t=e.prototype;return t.random=function(t){for(var r=[],n=0;n<t;n+=4)r.push(l());return new e(r,t)},t.toString=function(){return function(e){for(var t=e.words,r=e.sigBytes,n=[],i=0;i<r;i++){var s=t[i>>>2]>>>24-i%4*8&255;n.push((s>>>4).toString(16)),n.push((15&s).toString(16))}return n.join("")}(this)},e}();const d=p;function p(e,t){null!=e&&this.fromString(e,t)}function g(){return new p(null)}var y,w="undefined"!=typeof navigator;w&&"Microsoft Internet Explorer"==navigator.appName?(p.prototype.am=function(e,t,r,n,i,s){for(var o=32767&t,a=t>>15;--s>=0;){var u=32767&this[e],c=this[e++]>>15,h=a*u+c*o;i=((u=o*u+((32767&h)<<15)+r[n]+(1073741823&i))>>>30)+(h>>>15)+a*c+(i>>>30),r[n++]=1073741823&u}return i},y=30):w&&"Netscape"!=navigator.appName?(p.prototype.am=function(e,t,r,n,i,s){for(;--s>=0;){var o=t*this[e++]+r[n]+i;i=Math.floor(o/67108864),r[n++]=67108863&o}return i},y=26):(p.prototype.am=function(e,t,r,n,i,s){for(var o=16383&t,a=t>>14;--s>=0;){var u=16383&this[e],c=this[e++]>>14,h=a*u+c*o;i=((u=o*u+((16383&h)<<14)+r[n]+i)>>28)+(h>>14)+a*c,r[n++]=268435455&u}return i},y=28),p.prototype.DB=y,p.prototype.DM=(1<<y)-1,p.prototype.DV=1<<y,p.prototype.FV=Math.pow(2,52),p.prototype.F1=52-y,p.prototype.F2=2*y-52;var m,_,A=new Array;for(m="0".charCodeAt(0),_=0;_<=9;++_)A[m++]=_;for(m="a".charCodeAt(0),_=10;_<36;++_)A[m++]=_;for(m="A".charCodeAt(0),_=10;_<36;++_)A[m++]=_;function v(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function b(e,t){var r=A[e.charCodeAt(t)];return null==r?-1:r}function S(e){var t=g();return t.fromInt(e),t}function E(e){var t,r=1;return 0!=(t=e>>>16)&&(e=t,r+=16),0!=(t=e>>8)&&(e=t,r+=8),0!=(t=e>>4)&&(e=t,r+=4),0!=(t=e>>2)&&(e=t,r+=2),0!=(t=e>>1)&&(e=t,r+=1),r}function I(e){this.m=e,this.mp=e.invDigit(),this.mpl=32767&this.mp,this.mph=this.mp>>15,this.um=(1<<e.DB-15)-1,this.mt2=2*e.t}function R(e){return i.lW.from((new f).random(e).toString(),"hex")}I.prototype.convert=function(e){var t=g();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(p.ZERO)>0&&this.m.subTo(t,t),t},I.prototype.revert=function(e){var t=g();return e.copyTo(t),this.reduce(t),t},I.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var r=32767&e[t],n=r*this.mpl+((r*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[r=t+this.m.t]+=this.m.am(0,n,e,t,0,this.m.t);e[r]>=e.DV;)e[r]-=e.DV,e[++r]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},I.prototype.mulTo=function(e,t,r){e.multiplyTo(t,r),this.reduce(r)},I.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},p.prototype.copyTo=function(e){for(var t=this.t-1;t>=0;--t)e[t]=this[t];e.t=this.t,e.s=this.s},p.prototype.fromInt=function(e){this.t=1,this.s=e<0?-1:0,e>0?this[0]=e:e<-1?this[0]=e+this.DV:this.t=0},p.prototype.fromString=function(e,t){var r;if(16==t)r=4;else if(8==t)r=3;else if(2==t)r=1;else if(32==t)r=5;else{if(4!=t)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");r=2}this.t=0,this.s=0;for(var n=e.length,i=!1,s=0;--n>=0;){var o=b(e,n);o<0?"-"==e.charAt(n)&&(i=!0):(i=!1,0==s?this[this.t++]=o:s+r>this.DB?(this[this.t-1]|=(o&(1<<this.DB-s)-1)<<s,this[this.t++]=o>>this.DB-s):this[this.t-1]|=o<<s,(s+=r)>=this.DB&&(s-=this.DB))}this.clamp(),i&&p.ZERO.subTo(this,this)},p.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},p.prototype.dlShiftTo=function(e,t){var r;for(r=this.t-1;r>=0;--r)t[r+e]=this[r];for(r=e-1;r>=0;--r)t[r]=0;t.t=this.t+e,t.s=this.s},p.prototype.drShiftTo=function(e,t){for(var r=e;r<this.t;++r)t[r-e]=this[r];t.t=Math.max(this.t-e,0),t.s=this.s},p.prototype.lShiftTo=function(e,t){var r,n=e%this.DB,i=this.DB-n,s=(1<<i)-1,o=Math.floor(e/this.DB),a=this.s<<n&this.DM;for(r=this.t-1;r>=0;--r)t[r+o+1]=this[r]>>i|a,a=(this[r]&s)<<n;for(r=o-1;r>=0;--r)t[r]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},p.prototype.rShiftTo=function(e,t){t.s=this.s;var r=Math.floor(e/this.DB);if(r>=this.t)t.t=0;else{var n=e%this.DB,i=this.DB-n,s=(1<<n)-1;t[0]=this[r]>>n;for(var o=r+1;o<this.t;++o)t[o-r-1]|=(this[o]&s)<<i,t[o-r]=this[o]>>n;n>0&&(t[this.t-r-1]|=(this.s&s)<<i),t.t=this.t-r,t.clamp()}},p.prototype.subTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]-e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n-=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n-=e[r],t[r++]=n&this.DM,n>>=this.DB;n-=e.s}t.s=n<0?-1:0,n<-1?t[r++]=this.DV+n:n>0&&(t[r++]=n),t.t=r,t.clamp()},p.prototype.multiplyTo=function(e,t){var r=this.abs(),n=e.abs(),i=r.t;for(t.t=i+n.t;--i>=0;)t[i]=0;for(i=0;i<n.t;++i)t[i+r.t]=r.am(0,n[i],t,i,0,r.t);t.s=0,t.clamp(),this.s!=e.s&&p.ZERO.subTo(t,t)},p.prototype.squareTo=function(e){for(var t=this.abs(),r=e.t=2*t.t;--r>=0;)e[r]=0;for(r=0;r<t.t-1;++r){var n=t.am(r,t[r],e,2*r,0,1);(e[r+t.t]+=t.am(r+1,2*t[r],e,2*r+1,n,t.t-r-1))>=t.DV&&(e[r+t.t]-=t.DV,e[r+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(r,t[r],e,2*r,0,1)),e.s=0,e.clamp()},p.prototype.divRemTo=function(e,t,r){var n=e.abs();if(!(n.t<=0)){var i=this.abs();if(i.t<n.t)return null!=t&&t.fromInt(0),void(null!=r&&this.copyTo(r));null==r&&(r=g());var s=g(),o=this.s,a=e.s,u=this.DB-E(n[n.t-1]);u>0?(n.lShiftTo(u,s),i.lShiftTo(u,r)):(n.copyTo(s),i.copyTo(r));var c=s.t,h=s[c-1];if(0!=h){var l=h*(1<<this.F1)+(c>1?s[c-2]>>this.F2:0),f=this.FV/l,d=(1<<this.F1)/l,y=1<<this.F2,w=r.t,m=w-c,_=null==t?g():t;for(s.dlShiftTo(m,_),r.compareTo(_)>=0&&(r[r.t++]=1,r.subTo(_,r)),p.ONE.dlShiftTo(c,_),_.subTo(s,s);s.t<c;)s[s.t++]=0;for(;--m>=0;){var A=r[--w]==h?this.DM:Math.floor(r[w]*f+(r[w-1]+y)*d);if((r[w]+=s.am(0,A,r,m,0,c))<A)for(s.dlShiftTo(m,_),r.subTo(_,r);r[w]<--A;)r.subTo(_,r)}null!=t&&(r.drShiftTo(c,t),o!=a&&p.ZERO.subTo(t,t)),r.t=c,r.clamp(),u>0&&r.rShiftTo(u,r),o<0&&p.ZERO.subTo(r,r)}}},p.prototype.invDigit=function(){if(this.t<1)return 0;var e=this[0];if(0==(1&e))return 0;var t=3&e;return(t=(t=(t=(t=t*(2-(15&e)*t)&15)*(2-(255&e)*t)&255)*(2-((65535&e)*t&65535))&65535)*(2-e*t%this.DV)%this.DV)>0?this.DV-t:-t},p.prototype.addTo=function(e,t){for(var r=0,n=0,i=Math.min(e.t,this.t);r<i;)n+=this[r]+e[r],t[r++]=n&this.DM,n>>=this.DB;if(e.t<this.t){for(n+=e.s;r<this.t;)n+=this[r],t[r++]=n&this.DM,n>>=this.DB;n+=this.s}else{for(n+=this.s;r<e.t;)n+=e[r],t[r++]=n&this.DM,n>>=this.DB;n+=e.s}t.s=n<0?-1:0,n>0?t[r++]=n:n<-1&&(t[r++]=this.DV+n),t.t=r,t.clamp()},p.prototype.toString=function(e){if(this.s<0)return"-"+this.negate().toString(e);var t;if(16==e)t=4;else if(8==e)t=3;else if(2==e)t=1;else if(32==e)t=5;else{if(4!=e)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");t=2}var r,n=(1<<t)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0)for(a<this.DB&&(r=this[o]>>a)>0&&(i=!0,s=v(r));o>=0;)a<t?(r=(this[o]&(1<<a)-1)<<t-a,r|=this[--o]>>(a+=this.DB-t)):(r=this[o]>>(a-=t)&n,a<=0&&(a+=this.DB,--o)),r>0&&(i=!0),i&&(s+=v(r));return i?s:"0"},p.prototype.negate=function(){var e=g();return p.ZERO.subTo(this,e),e},p.prototype.abs=function(){return this.s<0?this.negate():this},p.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var r=this.t;if(0!=(t=r-e.t))return this.s<0?-t:t;for(;--r>=0;)if(0!=(t=this[r]-e[r]))return t;return 0},p.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+E(this[this.t-1]^this.s&this.DM)},p.prototype.mod=function(e){var t=g();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(p.ZERO)>0&&e.subTo(t,t),t},p.prototype.equals=function(e){return 0==this.compareTo(e)},p.prototype.add=function(e){var t=g();return this.addTo(e,t),t},p.prototype.subtract=function(e){var t=g();return this.subTo(e,t),t},p.prototype.multiply=function(e){var t=g();return this.multiplyTo(e,t),t},p.prototype.divide=function(e){var t=g();return this.divRemTo(e,t,null),t},p.prototype.modPow=function(e,t,r){var n,i=e.bitLength(),s=S(1),o=new I(t);if(i<=0)return s;n=i<18?1:i<48?3:i<144?4:i<768?5:6;var a=new Array,u=3,c=n-1,h=(1<<n)-1;if(a[1]=o.convert(this),n>1){var l=g();for(o.sqrTo(a[1],l);u<=h;)a[u]=g(),o.mulTo(l,a[u-2],a[u]),u+=2}var f,d,p=e.t-1,y=!0,w=g();for(i=E(e[p])-1;p>=0;){for(i>=c?f=e[p]>>i-c&h:(f=(e[p]&(1<<i+1)-1)<<c-i,p>0&&(f|=e[p-1]>>this.DB+i-c)),u=n;0==(1&f);)f>>=1,--u;if((i-=u)<0&&(i+=this.DB,--p),y)a[f].copyTo(s),y=!1;else{for(;u>1;)o.sqrTo(s,w),o.sqrTo(w,s),u-=2;u>0?o.sqrTo(s,w):(d=s,s=w,w=d),o.mulTo(w,a[f],s)}for(;p>=0&&0==(e[p]&1<<i);)o.sqrTo(s,w),d=s,s=w,w=d,--i<0&&(i=this.DB-1,--p)}var m=o.revert(s);return r(null,m),m},p.ZERO=S(0),p.ONE=S(1);var T=/^[89a-f]/i,U=function(){function e(e){this.N=new d("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",16),this.g=new d("2",16),this.k=new d(this.hexHash(""+this.padHex(this.N)+this.padHex(this.g)),16),this.smallAValue=this.generateRandomSmallA(),this.getLargeAValue((function(){})),this.infoBits=i.lW.from("Caldera Derived Key","utf8"),this.poolName=e}var t=e.prototype;return t.getSmallAValue=function(){return this.smallAValue},t.getLargeAValue=function(e){var t=this;this.largeAValue?e(null,this.largeAValue):this.calculateA(this.smallAValue,(function(r,n){r&&e(r,null),t.largeAValue=n,e(null,t.largeAValue)}))},t.generateRandomSmallA=function(){var e=R(128).toString("hex");return new d(e,16)},t.generateRandomString=function(){return R(40).toString("base64")},t.getRandomPassword=function(){return this.randomPassword},t.getSaltDevices=function(){return this.SaltToHashDevices},t.getVerifierDevices=function(){return this.verifierDevices},t.generateHashDevice=function(e,t,r){var n=this;this.randomPassword=this.generateRandomString();var i=""+e+t+":"+this.randomPassword,s=this.hash(i),o=R(16).toString("hex");this.SaltToHashDevices=this.padHex(new d(o,16)),this.g.modPow(new d(this.hexHash(this.SaltToHashDevices+s),16),this.N,(function(e,t){e&&r(e,null),n.verifierDevices=n.padHex(t),r(null,null)}))},t.calculateA=function(e,t){var r=this;this.g.modPow(e,this.N,(function(e,n){e&&t(e,null),n.mod(r.N).equals(d.ZERO)&&t(new Error("Illegal paramater. A mod N cannot be 0."),null),t(null,n)}))},t.calculateU=function(e,t){return this.UHexHash=this.hexHash(this.padHex(e)+this.padHex(t)),new d(this.UHexHash,16)},t.hash=function(e){var t=e instanceof i.lW?o().lib.WordArray.create(e):e,r=u()(t).toString();return new Array(64-r.length).join("0")+r},t.hexHash=function(e){return this.hash(i.lW.from(e,"hex"))},t.computehkdf=function(e,t){var r=o().lib.WordArray.create(i.lW.concat([this.infoBits,i.lW.from(String.fromCharCode(1),"utf8")])),n=e instanceof i.lW?o().lib.WordArray.create(e):e,s=t instanceof i.lW?o().lib.WordArray.create(t):t,a=h()(n,s),u=h()(r,a);return i.lW.from(u.toString(),"hex").slice(0,16)},t.getPasswordAuthenticationKey=function(e,t,r,n,s){var o=this;if(r.mod(this.N).equals(d.ZERO))throw new Error("B cannot be zero.");if(this.UValue=this.calculateU(this.largeAValue,r),this.UValue.equals(d.ZERO))throw new Error("U cannot be zero.");var a=""+this.poolName+e+":"+t,u=this.hash(a),c=new d(this.hexHash(this.padHex(n)+u),16);this.calculateS(c,r,(function(e,t){e&&s(e,null);var r=o.computehkdf(i.lW.from(o.padHex(t),"hex"),i.lW.from(o.padHex(o.UValue),"hex"));s(null,r)}))},t.calculateS=function(e,t,r){var n=this;this.g.modPow(e,this.N,(function(i,s){i&&r(i,null),t.subtract(n.k.multiply(s)).modPow(n.smallAValue.add(n.UValue.multiply(e)),n.N,(function(e,t){e&&r(e,null),r(null,t.mod(n.N))}))}))},t.getNewPasswordRequiredChallengeUserAttributePrefix=function(){return"userAttributes."},t.padHex=function(e){if(!(e instanceof d))throw new Error("Not a BigInteger");var t=e.compareTo(d.ZERO)<0,r=e.abs().toString(16);if(r=r.length%2!=0?"0"+r:r,r=T.test(r)?"00"+r:r,t){var n=r.split("").map((function(e){var t=15&~parseInt(e,16);return"0123456789ABCDEF".charAt(t)})).join("");(r=new d(n,16).add(d.ONE).toString(16)).toUpperCase().startsWith("FF8")&&(r=r.substring(2))}return r},e}(),D=function(){function e(e){this.jwtToken=e||"",this.payload=this.decodePayload()}var t=e.prototype;return t.getJwtToken=function(){return this.jwtToken},t.getExpiration=function(){return this.payload.exp},t.getIssuedAt=function(){return this.payload.iat},t.decodePayload=function(){var e=this.jwtToken.split(".")[1];try{return JSON.parse(i.lW.from(e,"base64").toString("utf8"))}catch(e){return{}}},e}();function C(e,t){return C=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},C(e,t)}var P=function(e){var t,r;function n(t){var r=(void 0===t?{}:t).AccessToken;return e.call(this,r||"")||this}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,C(t,r),n}(D);function N(e,t){return N=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},N(e,t)}var k=function(e){var t,r;function n(t){var r=(void 0===t?{}:t).IdToken;return e.call(this,r||"")||this}return r=e,(t=n).prototype=Object.create(r.prototype),t.prototype.constructor=t,N(t,r),n}(D),O=r(269),M=r.n(O),F=function(){function e(e){var t=(void 0===e?{}:e).RefreshToken;this.token=t||""}return e.prototype.getToken=function(){return this.token},e}(),V=function(){function e(e){var t=void 0===e?{}:e,r=t.IdToken,n=t.RefreshToken,i=t.AccessToken,s=t.ClockDrift;if(null==i||null==r)throw new Error("Id token and Access Token must be present.");this.idToken=r,this.refreshToken=n,this.accessToken=i,this.clockDrift=void 0===s?this.calculateClockDrift():s}var t=e.prototype;return t.getIdToken=function(){return this.idToken},t.getRefreshToken=function(){return this.refreshToken},t.getAccessToken=function(){return this.accessToken},t.getClockDrift=function(){return this.clockDrift},t.calculateClockDrift=function(){return Math.floor(new Date/1e3)-Math.min(this.accessToken.getIssuedAt(),this.idToken.getIssuedAt())},t.isValid=function(){var e=Math.floor(new Date/1e3)-this.clockDrift;return e<this.accessToken.getExpiration()&&e<this.idToken.getExpiration()},e}(),x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],L=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],B=function(){function e(){}return e.prototype.getNowString=function(){var e=new Date,t=L[e.getUTCDay()],r=x[e.getUTCMonth()],n=e.getUTCDate(),i=e.getUTCHours();i<10&&(i="0"+i);var s=e.getUTCMinutes();s<10&&(s="0"+s);var o=e.getUTCSeconds();return o<10&&(o="0"+o),t+" "+r+" "+n+" "+i+":"+s+":"+o+" UTC "+e.getUTCFullYear()},e}(),q=function(){function e(e){var t=void 0===e?{}:e,r=t.Name,n=t.Value;this.Name=r||"",this.Value=n||""}var t=e.prototype;return t.getValue=function(){return this.Value},t.setValue=function(e){return this.Value=e,this},t.getName=function(){return this.Name},t.setName=function(e){return this.Name=e,this},t.toString=function(){return JSON.stringify(this)},t.toJSON=function(){return{Name:this.Name,Value:this.Value}},e}(),K={},j=function(){function e(){}return e.setItem=function(e,t){return K[e]=t,K[e]},e.getItem=function(e){return Object.prototype.hasOwnProperty.call(K,e)?K[e]:void 0},e.removeItem=function(e){return delete K[e]},e.clear=function(){return K={}},e}(),W=function(){function e(){try{this.storageWindow=window.localStorage,this.storageWindow.setItem("aws.cognito.test-ls",1),this.storageWindow.removeItem("aws.cognito.test-ls")}catch(e){this.storageWindow=j}}return e.prototype.getStorage=function(){return this.storageWindow},e}(),H="undefined"!=typeof navigator?navigator.userAgent:"nodejs",J=function(){function e(e){if(null==e||null==e.Username||null==e.Pool)throw new Error("Username and Pool information are required.");this.username=e.Username||"",this.pool=e.Pool,this.Session=null,this.client=e.Pool.client,this.signInUserSession=null,this.authenticationFlowType="USER_SRP_AUTH",this.storage=e.Storage||(new W).getStorage(),this.keyPrefix="CognitoIdentityServiceProvider."+this.pool.getClientId(),this.userDataKey=this.keyPrefix+"."+this.username+".userData"}var t=e.prototype;return t.setSignInUserSession=function(e){this.clearCachedUserData(),this.signInUserSession=e,this.cacheTokens()},t.getSignInUserSession=function(){return this.signInUserSession},t.getUsername=function(){return this.username},t.getAuthenticationFlowType=function(){return this.authenticationFlowType},t.setAuthenticationFlowType=function(e){this.authenticationFlowType=e},t.initiateAuth=function(e,t){var r=this,n=e.getAuthParameters();n.USERNAME=this.username;var i=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),s={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:n,ClientMetadata:i};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",s,(function(e,n){if(e)return t.onFailure(e);var i=n.ChallengeName,s=n.ChallengeParameters;return"CUSTOM_CHALLENGE"===i?(r.Session=n.Session,t.customChallenge(s)):(r.signInUserSession=r.getCognitoUserSession(n.AuthenticationResult),r.cacheTokens(),t.onSuccess(r.signInUserSession))}))},t.authenticateUser=function(e,t){return"USER_PASSWORD_AUTH"===this.authenticationFlowType?this.authenticateUserPlainUsernamePassword(e,t):"USER_SRP_AUTH"===this.authenticationFlowType||"CUSTOM_AUTH"===this.authenticationFlowType?this.authenticateUserDefaultAuth(e,t):t.onFailure(new Error("Authentication flow type is invalid."))},t.authenticateUserDefaultAuth=function(e,t){var r,n,s=this,a=new U(this.pool.getUserPoolName()),u=new B,c={};null!=this.deviceKey&&(c.DEVICE_KEY=this.deviceKey),c.USERNAME=this.username,a.getLargeAValue((function(l,f){l&&t.onFailure(l),c.SRP_A=f.toString(16),"CUSTOM_AUTH"===s.authenticationFlowType&&(c.CHALLENGE_NAME="SRP_A");var p=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),g={AuthFlow:s.authenticationFlowType,ClientId:s.pool.getClientId(),AuthParameters:c,ClientMetadata:p};s.getUserContextData(s.username)&&(g.UserContextData=s.getUserContextData(s.username)),s.client.request("InitiateAuth",g,(function(c,l){if(c)return t.onFailure(c);var f=l.ChallengeParameters;s.username=f.USER_ID_FOR_SRP,s.userDataKey=s.keyPrefix+"."+s.username+".userData",r=new d(f.SRP_B,16),n=new d(f.SALT,16),s.getCachedDeviceKeyAndPassword(),a.getPasswordAuthenticationKey(s.username,e.getPassword(),r,n,(function(e,r){e&&t.onFailure(e);var n=u.getNowString(),c=o().lib.WordArray.create(i.lW.concat([i.lW.from(s.pool.getUserPoolName(),"utf8"),i.lW.from(s.username,"utf8"),i.lW.from(f.SECRET_BLOCK,"base64"),i.lW.from(n,"utf8")])),d=o().lib.WordArray.create(r),g=M().stringify(h()(c,d)),y={};y.USERNAME=s.username,y.PASSWORD_CLAIM_SECRET_BLOCK=f.SECRET_BLOCK,y.TIMESTAMP=n,y.PASSWORD_CLAIM_SIGNATURE=g,null!=s.deviceKey&&(y.DEVICE_KEY=s.deviceKey);var w={ChallengeName:"PASSWORD_VERIFIER",ClientId:s.pool.getClientId(),ChallengeResponses:y,Session:l.Session,ClientMetadata:p};s.getUserContextData()&&(w.UserContextData=s.getUserContextData()),function e(t,r){return s.client.request("RespondToAuthChallenge",t,(function(n,i){return n&&"ResourceNotFoundException"===n.code&&-1!==n.message.toLowerCase().indexOf("device")?(y.DEVICE_KEY=null,s.deviceKey=null,s.randomPassword=null,s.deviceGroupKey=null,s.clearCachedDeviceKeyAndPassword(),e(t,r)):r(n,i)}))}(w,(function(e,r){return e?t.onFailure(e):s.authenticateUserInternal(r,a,t)}))}))}))}))},t.authenticateUserPlainUsernamePassword=function(e,t){var r=this,n={};if(n.USERNAME=this.username,n.PASSWORD=e.getPassword(),n.PASSWORD){var i=new U(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(n.DEVICE_KEY=this.deviceKey);var s=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),o={AuthFlow:"USER_PASSWORD_AUTH",ClientId:this.pool.getClientId(),AuthParameters:n,ClientMetadata:s};this.getUserContextData(this.username)&&(o.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",o,(function(e,n){return e?t.onFailure(e):r.authenticateUserInternal(n,i,t)}))}else t.onFailure(new Error("PASSWORD parameter is required"))},t.authenticateUserInternal=function(e,t,r){var n=this,s=e.ChallengeName,o=e.ChallengeParameters;if("SMS_MFA"===s)return this.Session=e.Session,r.mfaRequired(s,o);if("SELECT_MFA_TYPE"===s)return this.Session=e.Session,r.selectMFAType(s,o);if("MFA_SETUP"===s)return this.Session=e.Session,r.mfaSetup(s,o);if("SOFTWARE_TOKEN_MFA"===s)return this.Session=e.Session,r.totpRequired(s,o);if("CUSTOM_CHALLENGE"===s)return this.Session=e.Session,r.customChallenge(o);if("NEW_PASSWORD_REQUIRED"===s){this.Session=e.Session;var a=null,u=null,c=[],h=t.getNewPasswordRequiredChallengeUserAttributePrefix();if(o&&(a=JSON.parse(e.ChallengeParameters.userAttributes),u=JSON.parse(e.ChallengeParameters.requiredAttributes)),u)for(var l=0;l<u.length;l++)c[l]=u[l].substr(h.length);return r.newPasswordRequired(a,c)}if("DEVICE_SRP_AUTH"===s)return this.Session=e.Session,void this.getDeviceResponse(r);this.signInUserSession=this.getCognitoUserSession(e.AuthenticationResult),this.challengeName=s,this.cacheTokens();var f=e.AuthenticationResult.NewDeviceMetadata;if(null==f)return r.onSuccess(this.signInUserSession);t.generateHashDevice(e.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,e.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(s){if(s)return r.onFailure(s);var o={Salt:i.lW.from(t.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:i.lW.from(t.getVerifierDevices(),"hex").toString("base64")};n.verifierDevices=o.PasswordVerifier,n.deviceGroupKey=f.DeviceGroupKey,n.randomPassword=t.getRandomPassword(),n.client.request("ConfirmDevice",{DeviceKey:f.DeviceKey,AccessToken:n.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:o,DeviceName:H},(function(t,i){return t?r.onFailure(t):(n.deviceKey=e.AuthenticationResult.NewDeviceMetadata.DeviceKey,n.cacheDeviceKeyAndPassword(),!0===i.UserConfirmationNecessary?r.onSuccess(n.signInUserSession,i.UserConfirmationNecessary):r.onSuccess(n.signInUserSession))}))}))},t.completeNewPasswordChallenge=function(e,t,r,n){var i=this;if(!e)return r.onFailure(new Error("New password is required."));var s=new U(this.pool.getUserPoolName()),o=s.getNewPasswordRequiredChallengeUserAttributePrefix(),a={};t&&Object.keys(t).forEach((function(e){a[o+e]=t[e]})),a.NEW_PASSWORD=e,a.USERNAME=this.username;var u={ChallengeName:"NEW_PASSWORD_REQUIRED",ClientId:this.pool.getClientId(),ChallengeResponses:a,Session:this.Session,ClientMetadata:n};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,t){return e?r.onFailure(e):i.authenticateUserInternal(t,s,r)}))},t.getDeviceResponse=function(e,t){var r=this,n=new U(this.deviceGroupKey),s=new B,a={};a.USERNAME=this.username,a.DEVICE_KEY=this.deviceKey,n.getLargeAValue((function(u,c){u&&e.onFailure(u),a.SRP_A=c.toString(16);var l={ChallengeName:"DEVICE_SRP_AUTH",ClientId:r.pool.getClientId(),ChallengeResponses:a,ClientMetadata:t,Session:r.Session};r.getUserContextData()&&(l.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",l,(function(t,a){if(t)return e.onFailure(t);var u=a.ChallengeParameters,c=new d(u.SRP_B,16),l=new d(u.SALT,16);n.getPasswordAuthenticationKey(r.deviceKey,r.randomPassword,c,l,(function(t,n){if(t)return e.onFailure(t);var c=s.getNowString(),l=o().lib.WordArray.create(i.lW.concat([i.lW.from(r.deviceGroupKey,"utf8"),i.lW.from(r.deviceKey,"utf8"),i.lW.from(u.SECRET_BLOCK,"base64"),i.lW.from(c,"utf8")])),f=o().lib.WordArray.create(n),d=M().stringify(h()(l,f)),p={};p.USERNAME=r.username,p.PASSWORD_CLAIM_SECRET_BLOCK=u.SECRET_BLOCK,p.TIMESTAMP=c,p.PASSWORD_CLAIM_SIGNATURE=d,p.DEVICE_KEY=r.deviceKey;var g={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:r.pool.getClientId(),ChallengeResponses:p,Session:a.Session};r.getUserContextData()&&(g.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",g,(function(t,n){return t?e.onFailure(t):(r.signInUserSession=r.getCognitoUserSession(n.AuthenticationResult),r.cacheTokens(),e.onSuccess(r.signInUserSession))}))}))}))}))},t.confirmRegistration=function(e,t,r,n){var i={ClientId:this.pool.getClientId(),ConfirmationCode:e,Username:this.username,ForceAliasCreation:t,ClientMetadata:n};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",i,(function(e){return e?r(e,null):r(null,"SUCCESS")}))},t.sendCustomChallengeAnswer=function(e,t,r){var n=this,i={};i.USERNAME=this.username,i.ANSWER=e;var s=new U(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(i.DEVICE_KEY=this.deviceKey);var o={ChallengeName:"CUSTOM_CHALLENGE",ChallengeResponses:i,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:r};this.getUserContextData()&&(o.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",o,(function(e,r){return e?t.onFailure(e):n.authenticateUserInternal(r,s,t)}))},t.sendMFACode=function(e,t,r,n){var s=this,o={};o.USERNAME=this.username,o.SMS_MFA_CODE=e;var a=r||"SMS_MFA";"SOFTWARE_TOKEN_MFA"===a&&(o.SOFTWARE_TOKEN_MFA_CODE=e),null!=this.deviceKey&&(o.DEVICE_KEY=this.deviceKey);var u={ChallengeName:a,ChallengeResponses:o,ClientId:this.pool.getClientId(),Session:this.Session,ClientMetadata:n};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,r){if(e)return t.onFailure(e);if("DEVICE_SRP_AUTH"!==r.ChallengeName){if(s.signInUserSession=s.getCognitoUserSession(r.AuthenticationResult),s.cacheTokens(),null==r.AuthenticationResult.NewDeviceMetadata)return t.onSuccess(s.signInUserSession);var n=new U(s.pool.getUserPoolName());n.generateHashDevice(r.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,r.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(e){if(e)return t.onFailure(e);var o={Salt:i.lW.from(n.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:i.lW.from(n.getVerifierDevices(),"hex").toString("base64")};s.verifierDevices=o.PasswordVerifier,s.deviceGroupKey=r.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,s.randomPassword=n.getRandomPassword(),s.client.request("ConfirmDevice",{DeviceKey:r.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:s.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:o,DeviceName:H},(function(e,n){return e?t.onFailure(e):(s.deviceKey=r.AuthenticationResult.NewDeviceMetadata.DeviceKey,s.cacheDeviceKeyAndPassword(),!0===n.UserConfirmationNecessary?t.onSuccess(s.signInUserSession,n.UserConfirmationNecessary):t.onSuccess(s.signInUserSession))}))}))}else s.getDeviceResponse(t)}))},t.changePassword=function(e,t,r,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:e,ProposedPassword:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:n},(function(e){return e?r(e,null):r(null,"SUCCESS")}))},t.enableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);var t=[];t.push({DeliveryMedium:"SMS",AttributeName:"phone_number"}),this.client.request("SetUserSettings",{MFAOptions:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.setUserMfaPreference=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:e,SoftwareTokenMfaSettings:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?r(e,null):r(null,"SUCCESS")}))},t.disableMFA=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("SetUserSettings",{MFAOptions:[],AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t){return t?e(t,null):e(null,"SUCCESS")}))},t.deleteUser=function(e,t){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("DeleteUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:t},(function(t){return t?e(t,null):(r.clearCachedUser(),e(null,"SUCCESS"))}))},t.updateAttributes=function(e,t,r){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("UpdateUserAttributes",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserAttributes:e,ClientMetadata:r},(function(e){return e?t(e,null):n.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.getUserAttributes=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,r){if(t)return e(t,null);for(var n=[],i=0;i<r.UserAttributes.length;i++){var s={Name:r.UserAttributes[i].Name,Value:r.UserAttributes[i].Value},o=new q(s);n.push(o)}return e(null,n)}))},t.getMFAOptions=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e(new Error("User is not authenticated"),null);this.client.request("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,r){return t?e(t,null):e(null,r.MFAOptions)}))},t.createGetUserRequest=function(){return this.client.promisifyRequest("GetUser",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()})},t.refreshSessionIfPossible=function(e){var t=this;return void 0===e&&(e={}),new Promise((function(r){var n=t.signInUserSession.getRefreshToken();n&&n.getToken()?t.refreshSession(n,r,e.clientMetadata):r()}))},t.getUserData=function(e,t){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return this.clearCachedUserData(),e(new Error("User is not authenticated"),null);var n=this.getUserDataFromCache();if(n)if(this.isFetchUserDataAndTokenRequired(t))this.fetchUserData().then((function(e){return r.refreshSessionIfPossible(t).then((function(){return e}))})).then((function(t){return e(null,t)})).catch(e);else try{return void e(null,JSON.parse(n))}catch(t){return this.clearCachedUserData(),void e(t,null)}else this.fetchUserData().then((function(t){e(null,t)})).catch(e)},t.getUserDataFromCache=function(){return this.storage.getItem(this.userDataKey)},t.isFetchUserDataAndTokenRequired=function(e){var t=(e||{}).bypassCache;return void 0!==t&&t},t.fetchUserData=function(){var e=this;return this.createGetUserRequest().then((function(t){return e.cacheUserData(t),t}))},t.deleteAttributes=function(e,t){var r=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return t(new Error("User is not authenticated"),null);this.client.request("DeleteUserAttributes",{UserAttributeNames:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?t(e,null):r.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.resendConfirmationCode=function(e,t){var r={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.client.request("ResendConfirmationCode",r,(function(t,r){return t?e(t,null):e(null,r)}))},t.getSession=function(e,t){if(void 0===t&&(t={}),null==this.username)return e(new Error("Username is null. Cannot retrieve a new session"),null);if(null!=this.signInUserSession&&this.signInUserSession.isValid())return e(null,this.signInUserSession);var r="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,n=r+".idToken",i=r+".accessToken",s=r+".refreshToken",o=r+".clockDrift";if(this.storage.getItem(n)){var a=new k({IdToken:this.storage.getItem(n)}),u=new P({AccessToken:this.storage.getItem(i)}),c=new F({RefreshToken:this.storage.getItem(s)}),h=parseInt(this.storage.getItem(o),0)||0,l=new V({IdToken:a,AccessToken:u,RefreshToken:c,ClockDrift:h});if(l.isValid())return this.signInUserSession=l,e(null,this.signInUserSession);if(!c.getToken())return e(new Error("Cannot retrieve a new session. Please authenticate."),null);this.refreshSession(c,e,t.clientMetadata)}else e(new Error("Local storage is missing an ID Token, Please authenticate"),null)},t.refreshSession=function(e,t,r){var n=this,i=this.pool.wrapRefreshSessionCallback?this.pool.wrapRefreshSessionCallback(t):t,s={};s.REFRESH_TOKEN=e.getToken();var o="CognitoIdentityServiceProvider."+this.pool.getClientId(),a=o+".LastAuthUser";if(this.storage.getItem(a)){this.username=this.storage.getItem(a);var u=o+"."+this.username+".deviceKey";this.deviceKey=this.storage.getItem(u),s.DEVICE_KEY=this.deviceKey}var c={ClientId:this.pool.getClientId(),AuthFlow:"REFRESH_TOKEN_AUTH",AuthParameters:s,ClientMetadata:r};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",c,(function(t,r){if(t)return"NotAuthorizedException"===t.code&&n.clearCachedUser(),i(t,null);if(r){var s=r.AuthenticationResult;return Object.prototype.hasOwnProperty.call(s,"RefreshToken")||(s.RefreshToken=e.getToken()),n.signInUserSession=n.getCognitoUserSession(s),n.cacheTokens(),i(null,n.signInUserSession)}}))},t.cacheTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",r=e+"."+this.username+".accessToken",n=e+"."+this.username+".refreshToken",i=e+"."+this.username+".clockDrift",s=e+".LastAuthUser";this.storage.setItem(t,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(r,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(n,this.signInUserSession.getRefreshToken().getToken()),this.storage.setItem(i,""+this.signInUserSession.getClockDrift()),this.storage.setItem(s,this.username)},t.cacheUserData=function(e){this.storage.setItem(this.userDataKey,JSON.stringify(e))},t.clearCachedUserData=function(){this.storage.removeItem(this.userDataKey)},t.clearCachedUser=function(){this.clearCachedTokens(),this.clearCachedUserData()},t.cacheDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",r=e+".randomPasswordKey",n=e+".deviceGroupKey";this.storage.setItem(t,this.deviceKey),this.storage.setItem(r,this.randomPassword),this.storage.setItem(n,this.deviceGroupKey)},t.getCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",r=e+".randomPasswordKey",n=e+".deviceGroupKey";this.storage.getItem(t)&&(this.deviceKey=this.storage.getItem(t),this.randomPassword=this.storage.getItem(r),this.deviceGroupKey=this.storage.getItem(n))},t.clearCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",r=e+".randomPasswordKey",n=e+".deviceGroupKey";this.storage.removeItem(t),this.storage.removeItem(r),this.storage.removeItem(n)},t.clearCachedTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",r=e+"."+this.username+".accessToken",n=e+"."+this.username+".refreshToken",i=e+".LastAuthUser",s=e+"."+this.username+".clockDrift";this.storage.removeItem(t),this.storage.removeItem(r),this.storage.removeItem(n),this.storage.removeItem(i),this.storage.removeItem(s)},t.getCognitoUserSession=function(e){var t=new k(e),r=new P(e),n=new F(e);return new V({IdToken:t,AccessToken:r,RefreshToken:n})},t.forgotPassword=function(e,t){var r={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.getUserContextData()&&(r.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",r,(function(t,r){return t?e.onFailure(t):"function"==typeof e.inputVerificationCode?e.inputVerificationCode(r):e.onSuccess(r)}))},t.confirmPassword=function(e,t,r,n){var i={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:e,Password:t,ClientMetadata:n};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",i,(function(e){return e?r.onFailure(e):r.onSuccess("SUCCESS")}))},t.getAttributeVerificationCode=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("GetUserAttributeVerificationCode",{AttributeName:e,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:r},(function(e,r){return e?t.onFailure(e):"function"==typeof t.inputVerificationCode?t.inputVerificationCode(r):t.onSuccess("SUCCESS")}))},t.verifyAttribute=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:e,Code:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?r.onFailure(e):r.onSuccess("SUCCESS")}))},t.getDevice=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey},(function(t,r){return t?e.onFailure(t):e.onSuccess(r)}))},t.forgetSpecificDevice=function(e,t){if(null==this.signInUserSession||!this.signInUserSession.isValid())return t.onFailure(new Error("User is not authenticated"));this.client.request("ForgetDevice",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:e},(function(e){return e?t.onFailure(e):t.onSuccess("SUCCESS")}))},t.forgetDevice=function(e){var t=this;this.forgetSpecificDevice(this.deviceKey,{onFailure:e.onFailure,onSuccess:function(r){return t.deviceKey=null,t.deviceGroupKey=null,t.randomPassword=null,t.clearCachedDeviceKeyAndPassword(),e.onSuccess(r)}})},t.setDeviceStatusRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.setDeviceStatusNotRemembered=function(e){if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("UpdateDeviceStatus",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),DeviceKey:this.deviceKey,DeviceRememberedStatus:"not_remembered"},(function(t){return t?e.onFailure(t):e.onSuccess("SUCCESS")}))},t.listDevices=function(e,t,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return r.onFailure(new Error("User is not authenticated"));var n={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:e};t&&(n.PaginationToken=t),this.client.request("ListDevices",n,(function(e,t){return e?r.onFailure(e):r.onSuccess(t)}))},t.globalSignOut=function(e){var t=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return e.onFailure(new Error("User is not authenticated"));this.client.request("GlobalSignOut",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(r){return r?e.onFailure(r):(t.clearCachedUser(),e.onSuccess("SUCCESS"))}))},t.signOut=function(e){var t=this;e&&"function"==typeof e?this.getSession((function(r,n){if(r)return e(r);t.revokeTokens((function(r){t.cleanClientData(),e(r)}))})):this.cleanClientData()},t.revokeTokens=function(e){if(void 0===e&&(e=function(){}),"function"!=typeof e)throw new Error("Invalid revokeTokenCallback. It should be a function.");if(!this.signInUserSession)return e(new Error("User is not authenticated"));if(!this.signInUserSession.getAccessToken())return e(new Error("No Access token available"));var t=this.signInUserSession.getRefreshToken().getToken(),r=this.signInUserSession.getAccessToken();if(this.isSessionRevocable(r)&&t)return this.revokeToken({token:t,callback:e});e()},t.isSessionRevocable=function(e){if(e&&"function"==typeof e.decodePayload)try{return!!e.decodePayload().origin_jti}catch(e){}return!1},t.cleanClientData=function(){this.signInUserSession=null,this.clearCachedUser()},t.revokeToken=function(e){var t=e.token,r=e.callback;this.client.requestWithRetry("RevokeToken",{Token:t,ClientId:this.pool.getClientId()},(function(e){if(e)return r(e);r()}))},t.sendMFASelectionAnswer=function(e,t){var r=this,n={};n.USERNAME=this.username,n.ANSWER=e;var i={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:n,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",i,(function(n,i){return n?t.onFailure(n):(r.Session=i.Session,"SMS_MFA"===e?t.mfaRequired(i.ChallengeName,i.ChallengeParameters):"SOFTWARE_TOKEN_MFA"===e?t.totpRequired(i.ChallengeName,i.ChallengeParameters):void 0)}))},t.getUserContextData=function(){return this.pool.getUserContextData(this.username)},t.associateSoftwareToken=function(e){var t=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("AssociateSoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(t,r){return t?e.onFailure(t):e.associateSecretCode(r.SecretCode)})):this.client.request("AssociateSoftwareToken",{Session:this.Session},(function(r,n){return r?e.onFailure(r):(t.Session=n.Session,e.associateSecretCode(n.SecretCode))}))},t.verifySoftwareToken=function(e,t,r){var n=this;null!=this.signInUserSession&&this.signInUserSession.isValid()?this.client.request("VerifySoftwareToken",{AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),UserCode:e,FriendlyDeviceName:t},(function(e,t){return e?r.onFailure(e):r.onSuccess(t)})):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:e,FriendlyDeviceName:t},(function(e,t){if(e)return r.onFailure(e);n.Session=t.Session;var i={};i.USERNAME=n.username;var s={ChallengeName:"MFA_SETUP",ClientId:n.pool.getClientId(),ChallengeResponses:i,Session:n.Session};n.getUserContextData()&&(s.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",s,(function(e,t){return e?r.onFailure(e):(n.signInUserSession=n.getCognitoUserSession(t.AuthenticationResult),n.cacheTokens(),r.onSuccess(n.signInUserSession))}))}))},e}(),$=(r(204),"aws-amplify/5.0.4"),Y={userAgent:$+" js",product:"",navigator:null,isReactNative:!1};function z(){}"undefined"!=typeof navigator&&navigator.product&&(Y.product=navigator.product||"",Y.navigator=navigator||null,"ReactNative"===navigator.product?(Y.userAgent=$+" react-native",Y.isReactNative=!0):(Y.userAgent=$+" js",Y.isReactNative=!1)),z.prototype.userAgent=Y.userAgent;const G=z;function Q(e){var t="function"==typeof Map?new Map:void 0;return Q=function(e){if(null===e||(r=e,-1===Function.toString.call(r).indexOf("[native code]")))return e;var r;if("function"!=typeof e)throw new TypeError("Super expression must either be null or a function");if(void 0!==t){if(t.has(e))return t.get(e);t.set(e,n)}function n(){return Z(e,arguments,te(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),ee(n,e)},Q(e)}function Z(e,t,r){return Z=X()?Reflect.construct.bind():function(e,t,r){var n=[null];n.push.apply(n,t);var i=new(Function.bind.apply(e,n));return r&&ee(i,r.prototype),i},Z.apply(null,arguments)}function X(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}function ee(e,t){return ee=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},ee(e,t)}function te(e){return te=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},te(e)}var re=function(e){function t(t,r,n,i){var s;return(s=e.call(this,t)||this).code=r,s.name=n,s.statusCode=i,s}return n=e,(r=t).prototype=Object.create(n.prototype),r.prototype.constructor=r,ee(r,n),t;var r,n}(Q(Error)),ne=function(){function e(e,t,r){this.endpoint=t||"https://cognito-idp."+e+".amazonaws.com/";var n=(r||{}).credentials;this.fetchOptions=n?{credentials:n}:{}}var t=e.prototype;return t.promisifyRequest=function(e,t){var r=this;return new Promise((function(n,i){r.request(e,t,(function(e,t){e?i(new re(e.message,e.code,e.name,e.statusCode)):n(t)}))}))},t.requestWithRetry=function(e,t,r){var n,i,s=this;(n=[t],i=5e3,void 0===i&&(i=se),ie((function(t){return new Promise((function(r,n){s.request(e,t,(function(e,t){e?n(e):r(t)}))}))}),n,function(e){return function(t){var r=100*Math.pow(2,t)+100*Math.random();return!(r>e)&&r}}(i))).then((function(e){return r(null,e)})).catch((function(e){return r(e)}))},t.request=function(e,t,r){var n,i={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+e,"X-Amz-User-Agent":G.prototype.userAgent},s=Object.assign({},this.fetchOptions,{headers:i,method:"POST",mode:"cors",cache:"no-cache",body:JSON.stringify(t)});fetch(this.endpoint,s).then((function(e){return n=e,e}),(function(e){if(e instanceof TypeError)throw new Error("Network error");throw e})).then((function(e){return e.json().catch((function(){return{}}))})).then((function(e){if(n.ok)return r(null,e);var t=(e.__type||e.code).split("#").pop(),i=new Error(e.message||e.Message||null);return i.name=t,i.code=t,r(i)})).catch((function(e){if(n&&n.headers&&n.headers.get("x-amzn-errortype"))try{var t=n.headers.get("x-amzn-errortype").split(":")[0],i=new Error(n.status?n.status.toString():null);return i.code=t,i.name=t,i.statusCode=n.status,r(i)}catch(t){return r(e)}else e instanceof Error&&"Network error"===e.message&&(e.code="NetworkError");return r(e)}))},e}();function ie(e,t,r,n){if(void 0===n&&(n=1),"function"!=typeof e)throw Error("functionToRetry must be a function");return e.name,JSON.stringify(t),e.apply(void 0,t).catch((function(i){if(e.name,(s=i)&&s.nonRetryable)throw e.name,i;var s,o=r(n,t,i);if(e.name,!1!==o)return new Promise((function(e){return setTimeout(e,o)})).then((function(){return ie(e,t,r,n+1)}));throw i}))}Error;var se=3e5,oe=function(){function e(e,t){var r=e||{},n=r.UserPoolId,i=r.ClientId,s=r.endpoint,o=r.fetchOptions,a=r.AdvancedSecurityDataCollectionFlag;if(!n||!i)throw new Error("Both UserPoolId and ClientId are required.");if(n.length>55||!/^[\w-]+_[0-9a-zA-Z]+$/.test(n))throw new Error("Invalid UserPoolId format.");var u=n.split("_")[0];this.userPoolId=n,this.clientId=i,this.client=new ne(u,s,o),this.advancedSecurityDataCollectionFlag=!1!==a,this.storage=e.Storage||(new W).getStorage(),t&&(this.wrapRefreshSessionCallback=t)}var t=e.prototype;return t.getUserPoolId=function(){return this.userPoolId},t.getUserPoolName=function(){return this.getUserPoolId().split("_")[1]},t.getClientId=function(){return this.clientId},t.signUp=function(e,t,r,n,i,s){var o=this,a={ClientId:this.clientId,Username:e,Password:t,UserAttributes:r,ValidationData:n,ClientMetadata:s};this.getUserContextData(e)&&(a.UserContextData=this.getUserContextData(e)),this.client.request("SignUp",a,(function(t,r){if(t)return i(t,null);var n={Username:e,Pool:o,Storage:o.storage},s={user:new J(n),userConfirmed:r.UserConfirmed,userSub:r.UserSub,codeDeliveryDetails:r.CodeDeliveryDetails};return i(null,s)}))},t.getCurrentUser=function(){var e="CognitoIdentityServiceProvider."+this.clientId+".LastAuthUser",t=this.storage.getItem(e);if(t){var r={Username:t,Pool:this,Storage:this.storage};return new J(r)}return null},t.getUserContextData=function(e){if("undefined"!=typeof AmazonCognitoAdvancedSecurityData){var t=AmazonCognitoAdvancedSecurityData;if(this.advancedSecurityDataCollectionFlag){var r=t.getData(e,this.userPoolId,this.clientId);if(r)return{EncodedData:r}}return{}}},e}();r(808);class ae extends Error{constructor(e,t){e instanceof Error?(super(e.message||"Something went wrong."),this.cause=e,this.name=e.name,e.hasOwnProperty("code")&&(this.code=e.code)):"string"==typeof e&&(super(e||"Something went wrong."),this.name="SkapiError",this.code="ERROR",t&&(t.code&&(this.code=t.code),t.cause&&(this.cause=t.cause)))}}class ue{static hash(e){"string"!=typeof e&&(console.warn("coercing non-string value to empty string"),e="");const t=ue.sb(e);let r,n,i,s,o=1732584193,a=-271733879,u=-1732584194,c=271733878;for(let e=0;e<t.length;e+=16)r=o,n=a,i=u,s=c,o=ue.ff(o,a,u,c,t[e],7,-680876936),c=ue.ff(c,o,a,u,t[e+1],12,-389564586),u=ue.ff(u,c,o,a,t[e+2],17,606105819),a=ue.ff(a,u,c,o,t[e+3],22,-1044525330),o=ue.ff(o,a,u,c,t[e+4],7,-176418897),c=ue.ff(c,o,a,u,t[e+5],12,1200080426),u=ue.ff(u,c,o,a,t[e+6],17,-1473231341),a=ue.ff(a,u,c,o,t[e+7],22,-45705983),o=ue.ff(o,a,u,c,t[e+8],7,1770035416),c=ue.ff(c,o,a,u,t[e+9],12,-1958414417),u=ue.ff(u,c,o,a,t[e+10],17,-42063),a=ue.ff(a,u,c,o,t[e+11],22,-1990404162),o=ue.ff(o,a,u,c,t[e+12],7,1804603682),c=ue.ff(c,o,a,u,t[e+13],12,-40341101),u=ue.ff(u,c,o,a,t[e+14],17,-1502002290),a=ue.ff(a,u,c,o,t[e+15],22,1236535329),o=ue.gg(o,a,u,c,t[e+1],5,-165796510),c=ue.gg(c,o,a,u,t[e+6],9,-1069501632),u=ue.gg(u,c,o,a,t[e+11],14,643717713),a=ue.gg(a,u,c,o,t[e],20,-373897302),o=ue.gg(o,a,u,c,t[e+5],5,-701558691),c=ue.gg(c,o,a,u,t[e+10],9,38016083),u=ue.gg(u,c,o,a,t[e+15],14,-660478335),a=ue.gg(a,u,c,o,t[e+4],20,-405537848),o=ue.gg(o,a,u,c,t[e+9],5,568446438),c=ue.gg(c,o,a,u,t[e+14],9,-1019803690),u=ue.gg(u,c,o,a,t[e+3],14,-187363961),a=ue.gg(a,u,c,o,t[e+8],20,1163531501),o=ue.gg(o,a,u,c,t[e+13],5,-1444681467),c=ue.gg(c,o,a,u,t[e+2],9,-51403784),u=ue.gg(u,c,o,a,t[e+7],14,1735328473),a=ue.gg(a,u,c,o,t[e+12],20,-1926607734),o=ue.hh(o,a,u,c,t[e+5],4,-378558),c=ue.hh(c,o,a,u,t[e+8],11,-2022574463),u=ue.hh(u,c,o,a,t[e+11],16,1839030562),a=ue.hh(a,u,c,o,t[e+14],23,-35309556),o=ue.hh(o,a,u,c,t[e+1],4,-1530992060),c=ue.hh(c,o,a,u,t[e+4],11,1272893353),u=ue.hh(u,c,o,a,t[e+7],16,-155497632),a=ue.hh(a,u,c,o,t[e+10],23,-1094730640),o=ue.hh(o,a,u,c,t[e+13],4,681279174),c=ue.hh(c,o,a,u,t[e],11,-358537222),u=ue.hh(u,c,o,a,t[e+3],16,-722521979),a=ue.hh(a,u,c,o,t[e+6],23,76029189),o=ue.hh(o,a,u,c,t[e+9],4,-640364487),c=ue.hh(c,o,a,u,t[e+12],11,-421815835),u=ue.hh(u,c,o,a,t[e+15],16,530742520),a=ue.hh(a,u,c,o,t[e+2],23,-995338651),o=ue.ii(o,a,u,c,t[e],6,-198630844),c=ue.ii(c,o,a,u,t[e+7],10,1126891415),u=ue.ii(u,c,o,a,t[e+14],15,-1416354905),a=ue.ii(a,u,c,o,t[e+5],21,-57434055),o=ue.ii(o,a,u,c,t[e+12],6,1700485571),c=ue.ii(c,o,a,u,t[e+3],10,-1894986606),u=ue.ii(u,c,o,a,t[e+10],15,-1051523),a=ue.ii(a,u,c,o,t[e+1],21,-2054922799),o=ue.ii(o,a,u,c,t[e+8],6,1873313359),c=ue.ii(c,o,a,u,t[e+15],10,-30611744),u=ue.ii(u,c,o,a,t[e+6],15,-1560198380),a=ue.ii(a,u,c,o,t[e+13],21,1309151649),o=ue.ii(o,a,u,c,t[e+4],6,-145523070),c=ue.ii(c,o,a,u,t[e+11],10,-1120210379),u=ue.ii(u,c,o,a,t[e+2],15,718787259),a=ue.ii(a,u,c,o,t[e+9],21,-343485551),o=ue.ad(o,r),a=ue.ad(a,n),u=ue.ad(u,i),c=ue.ad(c,s);return ue.rh(o)+ue.rh(a)+ue.rh(u)+ue.rh(c)}static rh(e){let t="";for(let r=0;r<=3;r++)t+=ue.alphabet.charAt(e>>8*r+4&15)+ue.alphabet.charAt(e>>8*r&15);return t}static ad(e,t){const r=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(r>>16)<<16|65535&r}static rl(e,t){return e<<t|e>>>32-t}static cm(e,t,r,n,i,s){return ue.ad(ue.rl(ue.ad(ue.ad(t,e),ue.ad(n,s)),i),r)}static ff(e,t,r,n,i,s,o){return ue.cm(t&r|~t&n,e,t,i,s,o)}static gg(e,t,r,n,i,s,o){return ue.cm(t&n|r&~n,e,t,i,s,o)}static hh(e,t,r,n,i,s,o){return ue.cm(t^r^n,e,t,i,s,o)}static ii(e,t,r,n,i,s,o){return ue.cm(r^(t|~n),e,t,i,s,o)}static sb(e){let t;const r=1+(e.length+8>>6),n=new Array(16*r);for(t=0;t<16*r;t++)n[t]=0;for(t=0;t<e.length;t++)n[t>>2]|=e.charCodeAt(t)<<t%4*8;return n[t>>2]|=128<<t%4*8,n[16*r-2]=8*e.length,n}}function ce(e,t="User ID"){if(!e)throw new ae(`${t} is empty.`,{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ae(`${t} should be type: string.`,{code:"INVALID_PARAMETER"});if(!e.match(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i))throw new ae(`${t} is invalid.`,{code:"INVALID_PARAMETER"});return e}function he(e){if("string"!=typeof e||"+"!==e.charAt(0)||isNaN(Number(e.substring(1))))throw new ae('"phone_number" is invalid. The format should be "+00123456789". Type: string.',{code:"INVALID_PARAMETER"});return e}function le(e){if("string"!=typeof e)throw new ae('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"});{let t=new RegExp(/([12]\d{3}-(0[1-9]|1[0-2])-(0[1-9]|[12]\d|3[01]))/);if(10!==e.length||3!==e.split("-").length||!t.test(e))throw new ae('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"})}return e}function fe(e){if(!e)throw new ae('"password" is required.',{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ae('"password" should be type: string.',{code:"INVALID_PARAMETER"});if(e.length<6)throw new ae('"password" should be at least 6 characters.',{code:"INVALID_PARAMETER"});if(e.length>60)throw new ae('"password" can be up to 60 characters max.',{code:"INVALID_PARAMETER"});return e}function de(e,t="email"){if(!e)throw new ae(`"${t}" is required.`,{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ae(`"${t}"should be type: string.`,{code:"INVALID_PARAMETER"});if(e.length<5||e.length>64)throw new ae(`"${t}" should be at least 5 characters and max 64 characters.`,{code:"INVALID_PARAMETER"});if(/^[a-zA-Z0-9.!#$%&'+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z]+[a-zA-Z0-9-]+)$/.test(e)&&(e=e.trim()).split("@")[1].split(".").length>=2)return e.toLowerCase();throw new ae(`"${e}" is an invalid email.`,{code:"INVALID_PARAMETER"})}function pe(e){const t=(()=>{let e=window.location.origin||null;return"/"===e.slice(-1)&&(e=e.slice(0,-1)),e})();let r=e=>{if("string"==typeof e){if("*"===e)return"*";{let r=e.trim();if(!r.includes(" ")&&!r.includes(",")){"/"===r.slice(0,1)&&t?r=t+r:"."===r.slice(0,1)&&t&&(r=window.location.href.split("/").slice(0,-1).join("/")+r);let n=null;try{n=new URL(r)}catch(t){throw new ae(`"${e}" is an invalid url.`,{code:"INVALID_PARAMETER"})}if(n.protocol){let e=n.href;return"/"===e.charAt(e.length-1)&&(e=e.substring(0,e.length-1)),e}}}}throw new ae(`"${e}" is an invalid url.`,{code:"INVALID_PARAMETER"})};return Array.isArray(e)?e.map((e=>r(e))):r(e)}function ge(e){const t={config:{reference_limit:null}},r={ip:e=>{t.ip=e},rec:e=>{if(!e)return;t.record_id=e;let r=e.substring(0,e.length-9).split("").reverse().reduce(((e,t,r)=>e+"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(t)*62**r),0);t.uploaded=r},usr:e=>{t.user_id=e},tbl:e=>{if(!e)return;let r=e.split("/");t.table=r[0],t.access_group="**"==r[2]?"private":parseInt(r[2]),r?.[3]&&(t.subscription={user_id:r[3],group:parseInt(r[4])})},idx:e=>{if(!e)return;let r=e.split("!"),n=r.splice(0,1)[0],i=function(e){let t=e.substring(3);switch(e.substring(0,3)){case"!S%":return t;case"!N%":return Number(t)-4503599627370496;case"!B%":return"1"===t;case"!L%":case"!D%":try{return JSON.parse(t)}catch(e){throw new ae("Value parse error.",{code:"PARSE_ERROR"})}default:return e}}("!"+r.join("!"));t.index={name:n,value:i}},ref:e=>{e&&(t.hasOwnProperty("reference")||(t.reference={}),t.reference.record_id=e.split("/")[0])},tags:e=>{t.tags=e},upd:e=>{t.updated=e},acpt_mrf:e=>{t.hasOwnProperty("reference")||(t.reference={}),t.reference.allow_multiple_reference=e},ref_limt:e=>{t.hasOwnProperty("reference")||(t.reference={}),t.reference.reference_limit=e},rfd:e=>{t.referenced_count=e},data:e=>{let r=e;"!D%{}"===e?r={}:"!L%[]"===e&&(r=[]),t.data=r}};if(e.record_id)return e;for(let t in r)r[t](e[t]);return t}function ye(e,t="parameter",r=!1,n=!1){let i=i=>{if("string"!=typeof i)throw new ae(`${t} should be type: <string | string[]>.`,{code:"INVALID_PARAMETER"});if(!n&&e.includes(" "))throw new ae(`${t} should not have whitespace.`,{code:"INVALID_PARAMETER"});if(!r&&e.includes("."))throw new ae(`${t} should not have periods.`,{code:"INVALID_PARAMETER"});if(/[`!@#$%^&*()_+\-=\[\]{};':"\\|,<>\/?~]/.test(i))throw new ae(`${t} should not have special characters.`,{code:"INVALID_PARAMETER"})};if(Array.isArray(e))for(let t of e)i(t);else i(e);return e}function we(e,t,r=null,n=[],i=null){function s(e){if(e instanceof Promise)throw new ae("Parameter should not be a promise",{code:"INVALID_PARAMETER"});return e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length}Array.isArray(n)&&(n=n.concat(["service","service_owner"]));let o,a=e,u=null,c=i?` in "${i}" is invalid.`:". Parameter should be type <object>.";if(null===i){if(s(a)){a=a instanceof HTMLFormElement||a instanceof FormData||a instanceof SubmitEvent?me(e)?.meta:JSON.parse(JSON.stringify(e));for(let e in a)if(!t.hasOwnProperty(e)&&Array.isArray(n)&&!n.includes(e))throw new ae(`Key name "${e}" is invalid in parameter.`,{code:"INVALID_PARAMETER"});if(Array.isArray(r)&&r.length)for(let e of r)if(!Object.keys(a).includes(e))throw new ae(`Key "${e}" is required in parameter.`,{code:"INVALID_PARAMETER"})}else if((h=a)&&"object"==typeof h&&!Array.isArray(h)&&!Object.keys(h).length||void 0===a){let e={};for(let r in t){let n=t[r];Array.isArray(n)&&"function"==typeof n[n.length-1]&&(e[r]=n[n.length-1]())}return Object.keys(e).length?e:a}if(null===a)return null}var h;if(s(t)&&s(a)){for(let e in t){let r=t[e];if(a.hasOwnProperty(e)&&void 0!==a[e])a[e]=we(a[e],r,null,null,e);else{let t=Array.isArray(r)&&"function"==typeof r[r.length-1]?r[r.length-1]:null;if(t){let r=t();void 0!==r&&(a[e]=r)}}}o=a}else if(Array.isArray(t))for(let e of t)try{void 0!==typeof a&&"function"!=typeof e&&(o=we(a,e,null,null,i));break}catch(e){if("string"==typeof e&&"BREAK:"===e.substring(0,6)){let t=(e=e.substring(6)).split(":");u=new ae(t[1],{code:t[0]});break}u=e}else{if("function"==typeof t)return t(a);if("string"==typeof t)if(Array.isArray(a)){if("array"!==t)throw new ae(`Invalid type "${typeof a}"${c}`,{code:"INVALID_PARAMETER"});for(let e of a)if(!["number","string","boolean"].includes(typeof e)&&null!==e)throw new ae(`Invalid type "${typeof e}" in "${i}" array value.`,{code:"INVALID_PARAMETER"});o=a}else if(["number","string","boolean","array","function"].includes(t)){if(typeof a!==t)throw new ae(`Value: ${a}${c}`,{code:"INVALID_PARAMETER"});if("number"===t&&Math.abs(a)>4503599627370496)throw`BREAK:INVALID_PARAMETER:"${i}" integer value should be within -4503599627370496 ~ +4503599627370546.`;o=a}else{if(a!==t)throw new ae(`Value: ${a}${c}`,{code:"INVALID_PARAMETER"});o=a}else null===t&&(o=a)}if(void 0===o&&u)throw u;return o}function me(e){function t(e,t,r){let n=t.slice(0,1),i=t.slice(-1);if("."===n&&(t=t.slice(1)),"."===i&&(t=t.slice(0,-1)),t.includes(".")){let r=t.split(".");t=r.pop();for(let t of r)t&&(e.hasOwnProperty(t)||(e[t]={}),e=e[t])}e.hasOwnProperty(t)?Array.isArray(e[t])?e[t].push(r):e[t]=[e[t],r]:e[t]=r}if(e instanceof FormData){let r={},n=0,i=[];for(let s of e.entries()){let e=s[0],o=s[1];if(o instanceof File)i.includes(e)||i.push(e),n+=Math.round(o.size/1024);else if(o instanceof FileList){if(i.includes(e)||i.push(e),o&&o.length>0)for(let e=0;e<=o.length-1;e++)n+=Math.round(o.item(e).size/1024)}else t(r,e,o)}if(n>5120)throw new ae("Files cannot exceed 5MB. Use skapi.uploadFiles(...) instead.",{code:"INVALID_REQUEST"});return{meta:r,files:i}}if(e instanceof SubmitEvent&&(e=e.target),e instanceof HTMLFormElement){let r={},n=[],i=0,s=e.querySelectorAll("input"),o=e.querySelectorAll("textarea");for(let e of o)e.name&&t(r,e.name,e.value);for(let e of s)if(e.name)if("number"===e.type)e.value&&t(r,e.name,Number(e.value));else if("checkbox"===e.type||"radio"===e.type)e.checked&&("on"===e.value||"true"===e.value?t(r,e.name,!0):"false"===e.value?t(r,e.name,!1):e.checked&&e.value&&t(r,e.name,e.value));else if("file"===e.type){if(n.includes(e.name)||n.push(e.name),e.files&&e.files.length>0)for(let t=0;t<=e.files.length-1;t++)i+=Math.round(e.files.item(t).size/1024)}else t(r,e.name,e.value);if(i>5120)throw new ae("Files cannot exceed 5MB. Use skapi.uploadFiles(...) instead.",{code:"INVALID_REQUEST"});return{meta:r,files:n}}return null}function _e(){return function(e,t,r){const n=r.value;r.value=function(...e){let t=e[0],r=e?.[1]||{},i=!0,s=null,o="";if(t instanceof SubmitEvent){t.preventDefault();let e=window.location.href;s=t.target;let r=new URL(s.action);o=r.href,s.action&&r.href!==e||(i=!1)}const a=e=>{if(r?.response){if("function"==typeof r.response)return r.response(e);throw new ae('Callback "response" should be type: function.',{code:"INVALID_PARAMETER"})}return s&&i&&(window.sessionStorage.setItem(`${this.service}:${ue.hash(o)}`,JSON.stringify(e)),window.location.href=o),e};let u;function c(e){let t=e instanceof Error?e:new ae(e);if(r?.onerror){if("function"==typeof r.onerror)return r.onerror(t);throw new ae('Callback "onerror" should be type: function.',{code:"INVALID_PARAMETER"})}throw t}try{u=n.bind(this)(...e)}catch(e){let t=c(e);if(t instanceof Error)throw t;return t}return u instanceof Promise?(async()=>{try{let e=await u;return a(e)}catch(e){return c(e)}})():a(u)}}}ue.alphabet="0123456789abcdef";var Ae=function(e,t,r,n){var i,s=arguments.length,o=s<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,r,o):i(t,r))||o);return s>3&&o&&Object.defineProperty(t,r,o),o};class ve{get user(){return this.__user&&Object.keys(this.__user).length?JSON.parse(JSON.stringify(this.__user)):null}set user(e){}async getConnection(){return await this.__connection,this.connection}constructor(e,t,r){if(this.cognitoUser=null,this.__disabledAccount=null,this.__serviceHash={},this.__pendingRequest={},this.__cached_requests={},this.__startKey_keys={},this.__request_signup_confirmation=null,this.__index_number_range=4503599627370496,this.__class_properties_has_been_cached=!1,this.session=null,this.origin=null,this.__user=null,this.connection=null,this.host="skapi",this.hostDomain="skapi.com",this.userPool=null,this.validate={userId(e){try{return ce(e),!0}catch(e){return!1}},url(e){try{return pe(e),!0}catch(e){return!1}},phoneNumber(e){try{return he(e),!0}catch(e){return!1}},birthdate(e){try{return le(e),!0}catch(e){return!1}},email(e){try{return de(e),!0}catch(e){return!1}}},this.getFormResponse=async()=>{await this.__connection;let e=`${this.service}:${ue.hash(window.location.href)}`,t=window.sessionStorage.getItem(e);if(null!==t){try{t=JSON.parse(t)}catch(e){}return t}throw new ae("Form response doesn't exist.",{code:"NOT_EXISTS"})},this.request=async(e,t=null,r)=>{r=r||{};let{auth:n=!1,method:i="post",meta:s=null,bypassAwaitConnection:o=!1}=r,a=o?null:await this.__connection,u=n?this.session?.idToken?.jwtToken:null;if(n){if(!u)throw this.logout(),new ae("User login is required.",{code:"INVALID_REQUEST"});{let e=Date.now()/1e3;if(this.session.idToken.payload.exp<e)try{await this.authentication().getSession({refreshToken:!0}),u=this.session?.idToken?.jwtToken}catch(e){throw this.logout(),new ae("User login is required.",{code:"INVALID_REQUEST"})}}}let c="";try{c=pe(e)}catch(e){}let h=c||await(async(e,t)=>{const r=await Promise.all([this.admin_endpoint,this.record_endpoint]),n=r[0],i=r[1];return(()=>{switch(e){case"get-serviceletters":case"delete-newsletter":case"block-account":case"register-service":case"get-users":case"post-userdata":case"remove-account":case"post-secure":case"get-newsletters":case"subscribe-newsletter":case"signup":case"confirm-signup":case"recover-account":case"mock":case"get-services":case"service":return{public:n.admin_public,private:n.admin_private};case"post-record":case"get-records":case"subscription":case"get-subscription":case"del-records":case"get-table":case"get-tag":case"get-index":case"storage-info":return{private:i.record_private,public:i.record_public}}})()[t?"private":"public"]+e})(e,!!n),l=this.session?.attributes?.["custom:service"]||a?.service||this.service,f=this.session?.attributes?.["custom:service_owner"]||a?.owner||this.service_owner;if(s){if("object"!=typeof s||Array.isArray(s))throw new ae("Invalid meta data.",{code:"INVALID_REQUEST"});s=JSON.parse(JSON.stringify(s))}if(Array.isArray(t)||t&&"object"!=typeof t)throw new ae("Request data should be a JSON Object | FormData | HTMLFormElement.",{code:"INVALID_REQUEST"});let d={service:l,service_owner:f},p={},{fetchMore:g=!1}=r?.fetchOptions||{};if(r?.fetchOptions&&Object.keys(r.fetchOptions).length){let e=we({limit:r.fetchOptions?.limit||100,startKey:r.fetchOptions?.startKey||null,ascending:"boolean"!=typeof r.fetchOptions?.ascending||r.fetchOptions.ascending},{limit:["number",()=>100],startKey:null,ascending:["boolean",()=>!0]});if(e.hasOwnProperty("limit")&&"number"==typeof e.limit){if(e.limit>1e3)throw new ae("Fetch limit should be below 1000.",{code:"INVALID_REQUEST"});Object.assign(p,{limit:e.limit})}e.hasOwnProperty("startKey")&&"object"==typeof e.startKey&&e.startKey&&Object.keys(e.startKey)&&Object.assign(p,{startKey:e.startKey}),e.hasOwnProperty("ascending")&&"boolean"==typeof e.ascending&&Object.assign(p,{ascending:e.ascending})}Object.assign(d,p);let y=!1;if(t instanceof SubmitEvent&&(t=t?.target),t instanceof HTMLFormElement&&(t=new FormData(t)),t instanceof FormData&&(y=!0),s)s=Object.assign(d,s);else if(t)if(y)for(let e in d)void 0!==d[e]&&t.set(e,new Blob([JSON.stringify(d[e])],{type:"application/json"}));else t=Object.assign(d,t);else t=d;if(y&&"function"==typeof r?.fetchOptions?.formData){let e=r.fetchOptions.formData(t);if(e instanceof Promise&&(e=await e),!(e instanceof FormData))throw new ae("Callback for extractFormData() should return FormData",{code:"INVALID_PARAMETER"});t=e}let w=this.load_startKey_keys({params:t,url:c||e,fetchMore:!y&&g});if(w&&"object"==typeof w)return w;if("string"==typeof w){if(!(this.__pendingRequest[w]instanceof Promise)){let e={Accept:"*/*"};u&&(e.Authorization=u),s&&(e["Content-Meta"]=JSON.stringify(s)),r.hasOwnProperty("contentType")?r?.contentType&&(e["Content-Type"]=r.contentType):t instanceof FormData||(e["Content-Type"]="application/json");let n={headers:e};r?.responseType&&(n.responseType=r.responseType),"post"===i?this.__pendingRequest[w]=this._post(h,t,n):"get"===i&&(this.__pendingRequest[w]=this._get(h,t,n))}try{let t=await this.__pendingRequest[w];return y?t:await this.update_startKey_keys({hashedParam:w,url:e,response:t})}catch(e){throw e}finally{w&&this.__pendingRequest.hasOwnProperty(w)&&delete this.__pendingRequest[w]}}},this.load_startKey_keys=e=>{let{params:t={},url:r,fetchMore:n=!1}=e||{};if(t.hasOwnProperty("startKey")&&t.startKey){if("object"!=typeof t.startKey&&!Object.keys(t.startKey).length&&"start"!==t.startKey&&"end"!==t.startKey)throw new ae(`"${t.startKey}" is invalid startKey key.`,{code:"INVALID_PARAMETER"});switch(t.startKey){case"end":return{list:[],startKey:"end",endOfList:!0};case"start":delete t.startKey}}let i=(()=>{if(t&&"object"==typeof t&&Object.keys(t).length){function e(e){function t(e){return"object"==typeof e&&e?Object.keys(e).sort().reduce(((t,r)=>(t[r]=e[r],t)),{}):e}let r=t(e);for(let n in r)r[n]&&"object"==typeof r[n]&&(r[n]=t(e[n]));return r}return ue.hash(r+"/"+JSON.stringify(e(t)))}return ue.hash(r+"/"+this.service)})();if(!n&&this.__startKey_keys?.[r]?.[i]){if(this.__cached_requests?.[r]&&this.__cached_requests?.[r]?.[i]&&delete this.__cached_requests[r][i],Array.isArray(this.__startKey_keys[r][i])&&this.__startKey_keys[r][i].length)for(let e of this.__startKey_keys[r][i]){let t=i+"/"+ue.hash(JSON.stringify(e));this.__cached_requests?.[r]&&this.__cached_requests?.[r]?.[t]&&delete this.__cached_requests[r][t]}return delete this.__startKey_keys[r][i],i}if(!Array.isArray(this.__startKey_keys?.[r]?.[i]))return i;let s=this.__startKey_keys[r][i],o=s[s.length-1],a=i;if(o){if('"end"'===o)return{list:[],startKey:"end",endOfList:!0};a+=ue.hash(o),t.startKey=JSON.parse(o)}return this.__cached_requests?.[r]?.[a]?this.__cached_requests?.[r]?.[a]:i},this.update_startKey_keys=async e=>{let{hashedParam:t,url:r,response:n}=e,i=null;if(i=n instanceof Promise?await n:n,"object"!=typeof i||!i.hasOwnProperty("startKey")||!t||!r)return i;this.__startKey_keys.hasOwnProperty(r)||(this.__startKey_keys[r]={}),this.__cached_requests?.[r]||(this.__cached_requests[r]={}),this.__cached_requests[r][t]=i,this.__startKey_keys[r].hasOwnProperty(t)||(this.__startKey_keys[r][t]=[]);let s=JSON.stringify(i.startKey);return this.__startKey_keys[r][t].includes(s)||this.__startKey_keys[r][t].push(s),this.__cached_requests[r][t]=i,Object.assign({startKey_list:this.__startKey_keys[r][t]},i)},this._fetch=async(e,t,r)=>{let n=await fetch(e,t);if(r){if(200===n.status)return await n[r]();throw n}let i=await n.text();try{i=JSON.parse(i)}catch(e){}if(200===n.status){if("object"==typeof i&&"GET"===t.method&&i.hasOwnProperty("body"))try{i=JSON.parse(i.body)}catch(e){}return i}{let e=n?.status,t=["INVALID_CORS","INVALID_REQUEST","SERVICE_DISABLED","INVALID_PARAMETER","ERROR","EXISTS","NOT_EXISTS"];if("object"==typeof i&&i?.message){let t=i?.code||(e?e.toString():null)||"ERROR";throw new ae(i?.message,{code:t})}if("string"==typeof i){let e=i.split(":"),r=e.splice(0,1)[0].trim();throw new ae(e.join("").trim(),{code:t.includes(r)?r:"ERROR"})}throw n}},this._get=async(e,t,r)=>{t&&"object"==typeof t&&Object.keys(t).length&&("?"!==e.substring(e.length-1)&&(e+="?"),e+=Object.keys(t).map((e=>{let r=t[e];return"string"!=typeof r&&(r=JSON.stringify(r)),encodeURIComponent(e)+"="+encodeURIComponent(r)})).join("&"));let n=null;r.hasOwnProperty("responseType")&&(n=r.responseType,delete r.responseType);let i=Object.assign({method:"GET"},r);return this._fetch(e,i,n)},this.getRecords=async(e,t)=>{const r={$updated:"number",$uploaded:"number",$referenced_count:"number"},n={table:"string",reference:"string",access_group:["number","private"],subscription:{user_id:e=>ce(e,'User ID in "subscription.user_id"'),group:e=>{if("number"!=typeof e)throw new ae('"subscription.group" should be type: number.',{code:"INVALID_PARAMETER"});if(e>99||e<0)throw new ae('"subscription.group" should be within range: 0 ~ 99.',{code:"INVALID_PARAMETER"});return e}},index:{name:e=>{if("string"!=typeof e)throw new ae('"index.name" should be type: string.',{code:"INVALID_PARAMETER"});return r.hasOwnProperty(e)?e:ye(e,"index.name",!0,!1)},value:t=>{if(e.index?.name&&r.hasOwnProperty(e.index.name)){let n=r[e.index.name];if(typeof t===n)return t;throw new ae(`"index.value" should be type: ${n}.`,{code:"INVALID_PARAMETER"})}if("number"==typeof t){if(t>this.__index_number_range||t<-this.__index_number_range)throw new ae(`Number value should be within range -${this.__index_number_range} ~ +${this.__index_number_range}`,{code:"INVALID_PARAMETER"});return t}return"boolean"==typeof t?t:ye(t,"index.value",!1,!0)},condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"],range:t=>{if(!("value"in e.index))throw new ae('"index.value" is required.',{code:"INVALID_PARAMETER"});if("$record_id"===e.index.name)throw new ae(`Cannot do "index.range" on ${e.index.name}`,{code:"INVALID_PARAMETER"});if(typeof e.index.value!=typeof t)throw new ae('"index.range" type should match the type of "index.value".',{code:"INVALID_PARAMETER"});return"string"==typeof t?ye(t,"index.value"):t}},tag:"string"};if(e?.record_id)ye(e.record_id,"record_id",!1,!1),e={record_id:e.record_id,service:e?.service};else{let t;if(e?.reference)try{t=ce(e?.reference,'User ID in "subscription.user_id"')}catch(e){}if((e=we(e||{},n,t?[]:["table"]))?.subscription&&!this.session)throw new ae("Requires login.",{code:"INVALID_REQUEST"})}let i=!(!e.hasOwnProperty("access_group")||!("private"===e.access_group||e.access_group>0))||!!this.__user,s=await this.request("get-records",e,{fetchOptions:t,auth:i,method:i?"post":"get"});for(let e in s.list)s.list[e]=ge(s.list[e]);return s},this.getTable=async(e,t)=>{let r=await this.request("get-table",we(e||{},{table:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!0},{fetchOptions:t})),n={cnt_rec:"number_of_records",tbl:"table",srvc:"service"};if(Array.isArray(r.list))for(let e of r.list)for(let t in n)e.hasOwnProperty(t)&&(e[n[t]]=e[t],delete e[t]);return r},this.getTag=async(e,t)=>{let r=await this.request("get-tag",we(e||{},{table:"string",tag:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!0},{fetchOptions:t}));if(Array.isArray(r.list))for(let e in r.list){let t=r.list[e],n=t.tag.split("/");r.list[e]={table:n[1],tag:n[0],number_of_records:t.cnt_rec}}return r},this.deleteRecords=async e=>{let t=await this.checkAdmin();if(t&&!e?.service)throw new ae("Service ID is required.",{code:"INVALID_PARAMETER"});if(!t&&!e?.table)throw new ae('"table" is required.',{code:"INVALID_PARAMETER"});if(e?.record_id)return await this.request("del-records",{service:e.service,record_id:(e=>{let t=ye(e,"record_id",!1);return"string"==typeof t?[t]:t})(e.record_id)},{auth:!0});if(!e?.table)throw new ae('Either "table" or "record_id" is required.',{code:"INVALID_PARAMETER"});return e=we(e||{},{access_group:["number","private"],table:{name:"string",subscription:e=>{if(t)return ce(e,'User ID in "table.subscription"');throw new ae('"table.subscription" is an invalid parameter key.',{code:"INVALID_PARAMETER"})},subscription_group:r=>{if(t&&"string"!=typeof e?.table?.subscription)throw new ae('"table.subscription" is required.',{code:"INVALID_PARAMETER"});if("number"==typeof r&&r>0&&r<99)return r;throw new ae("Subscription group should be between 0 ~ 99.",{code:"INVALID_PARAMETER"})}}},t?["service"]:["table","access_group"]),await this.request("del-records",e,{auth:!0})},this.subscriptionGroupCheck=async e=>{if(await this.__connection,e=we(e,{user_id:e=>ce(e,'"user_id"'),group:e=>{if("*"===e)return e;if("number"!=typeof e)throw new ae('"group" should be type: number.',{code:"INVALID_PARAMETER"});if(e<1&&e>9)throw new ae('"group" should be within range 1 ~ 9.',{code:"INVALID_PARAMETER"});return e}},["user_id","group"]),this.__user&&e.user_id===this.__user.user_id)throw new ae('"user_id" cannot be the user\'s own ID.',{code:"INVALID_PARAMETER"});return e},"string"!=typeof e||"string"!=typeof t)throw new ae('"service_id" and "service_owner" should be type <string>.',{code:"INVALID_PARAMETER"});if(!e||!t)throw new ae('"service_id" and "service_owner" is required',{code:"INVALID_PARAMETER"});t!==this.host&&ce(t,'"service_owner"'),this.service=e,this.service_owner=t;let n=r?.autoLogin||!1;const i="https://dkls9pxkgz855.cloudfront.net";let s=e.substring(0,4);this.admin_endpoint=fetch(`${i}/${s}/admin.json`).then((e=>e.blob())).then((e=>new Promise(((t,r)=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.record_endpoint=fetch(`${i}/${s}/record.json`).then((e=>e.blob())).then((e=>new Promise(((t,r)=>{const n=new FileReader;n.onloadend=()=>t(n.result),n.onerror=r,n.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.__connection=(async r=>{if(!window.sessionStorage)throw new Error("This browser does not support skapi.");const i=JSON.parse(window.sessionStorage.getItem(`${e}#${t}`)||"null");if(i?.connection)for(let e in i)r[e]=i[e];const s=await r.admin_endpoint;r.userPool=new oe({UserPoolId:s.userpool_id,ClientId:s.userpool_client});const o=[];if(i?.connection||o.push(r.updateConnection()),!i?.connection&&!n){let e=this.userPool?.getCurrentUser()||null;e&&e.signOut()}let a;(i?.connection||n)&&(o.push(r.authentication().getSession({refreshToken:!i?.connection}).catch((e=>{r.__user=null}))),r.updateConnection()),o.length&&(a=await Promise.all(o));const u=()=>{if(r.__class_properties_has_been_cached)return;let n=()=>{let n={};const i=["__startKey_keys","__cached_requests","__request_signup_confirmation","connection"];if(r.connection){for(let e of i)n[e]=r[e];window.sessionStorage.setItem(`${e}#${t}`,JSON.stringify(n)),r.__class_properties_has_been_cached=!0}};return a instanceof Promise?a.then((()=>n())):n()};return window.addEventListener("beforeunload",u),window.addEventListener("visibilitychange",u),r.connection})(this).catch((e=>{throw e}))}authentication(){if(!this.userPool)throw new ae("User pool is missing",{code:"INVALID_REQUEST"});const e=e=>{let t={};if(Array.isArray(e)){let t={};for(let r of e)if(t[r.Name]=r.Value,"custom:service"===r.Name&&t[r.Name]!==this.service)throw new ae("The user is not registered to the service.",{code:"INVALID_REQUEST"});e=t}for(let r in e)r.includes("custom:")?t[r.replace("custom:","")]=e[r]:t[r]=e[r];for(let e of["address_public","birthdate_public","email_public","email_subscription","gender_public","phone_number_public","access_group"])e.includes("_public")?t.hasOwnProperty(e.split("_")[0])?t[e]=!!t.hasOwnProperty(e)&&!!Number(t[e]):delete t[e]:t[e]="email_subscription"===e?!!t.hasOwnProperty(e)&&!!Number(t[e]):t.hasOwnProperty(e)?Number(t[e]):0;for(let e of["email","phone_number"])t.hasOwnProperty(e)?!0===t[e+"_verified"]||"true"===t[e+"_verified"]?t[e+"_verified"]=!0:t[e+"_verified"]=!1:delete t[e+"_verified"];for(let e of["aud",{from:"auth_time",to:"log"},"cognito:username","event_id","exp","iat","iss","jti","origin_jti","secret_key",{from:"sub",to:"user_id"},"token_use"])"string"==typeof e?delete t[e]:(t[e.to]=t[e.from],delete t[e.from]);this.__user=t},r=t=>{let{refreshToken:r=!1}=t||{};return new Promise(((t,n)=>{let i=this.userPool?.getCurrentUser()||null;this.cognitoUser=i,null===i&&n(null),i.getSession(((s,o)=>{s&&n(s),o||n(new ae("Current session does not exist.",{code:"INVALID_REQUEST"})),r||!o.isValid()?i.refreshSession(o.getRefreshToken(),((r,i)=>{r?n(r):i.isValid()?(this.session=i,e(i.getIdToken().payload),t(i)):n(new ae("Invalid session.",{code:"INVALID_REQUEST"}))})):(this.session=o,e(o.getIdToken().payload),t(o))}))}))},n=async e=>{if(!e)throw new ae("E-Mail is required.",{code:"INVALID_PARAMETER"});let t=this.__serviceHash[e]||(await this.updateConnection({request_hash:e})).hash;return{cognitoUser:new J({Username:t,Pool:this.userPool}),cognitoUsername:t}};return{getSession:r,authenticateUser:(e,i)=>new Promise(((s,o)=>{this.__request_signup_confirmation=null,this.__disabledAccount=null,n(e).then((e=>{this.cognitoUser=e.cognitoUser;let n=e.cognitoUsername,a=new t({Username:n,Password:i});this.cognitoUser.authenticateUser(a,{newPasswordRequired:(e,t)=>{this.__request_signup_confirmation=n,o(new ae("User's signup confirmation is required.",{code:"SIGNUP_CONFIRMATION_NEEDED"}))},onSuccess:e=>r().then((e=>s(this.user))),onFailure:e=>{let t=[e.message||"Failed to authenticate user.",e?.code||"INVALID_REQUEST"];"NotAuthorizedException"===e.code&&("User is disabled."===e.message?(this.__disabledAccount=n,t=["This account is disabled.","USER_IS_DISABLED"]):t=["Incorrect username or password.","INCORRECT_USERNAME_OR_PASSWORD"]),o(new ae(t[0],{code:t[1],cause:e}))}})}))})),createCognitoUser:n,getUser:()=>this.session?new Promise(((t,r)=>{null===this.cognitoUser?r(new ae("Invalid session",{code:"INVALID_REQUEST"})):this.cognitoUser.getUserAttributes(((n,i)=>{n?r(n):(e(i),t(this.user))}))})):null}}async getProfile(e){await this.__connection;try{return await this.authentication().getSession(e),this.user}catch(e){return null}}async checkAdmin(){return await this.__connection,this.__user?.service===this.service?this.__user?.service_owner===this.host:(await this.logout(),!1)}async getBlob(e,t){let r=we(e,{url:e=>pe(e)},["url"]);return await this.request(r.url,t||null,{method:"get",auth:r.url.includes("/auth/"),contentType:null,responseType:"blob"})}async mock(e,t){return this.request("mock",e,t)}async secureRequest(e){let t={url:e=>pe(e),data:null,sync:["boolean",()=>!0]};if(Array.isArray(e))for(let r of e)r=we(r,t);else e=we(e,t);return await this.request("post-secure",e,{auth:!0})}_post(e,t,r){let n=null;r.hasOwnProperty("responseType")&&(n=r.responseType,delete r.responseType);let i=Object.assign({method:"POST"},r,{body:t instanceof FormData?t:JSON.stringify(t)});return this._fetch(e,i,n)}async postRecord(e,t){let r=await this.checkAdmin();if(!t)throw new ae(["INVALID_PARAMETER",'"config" argument is required.']);let{formData:n}=t,i={};if("function"==typeof n&&(i.formData=n),"number"==typeof(t=we(t||{},{record_id:"string",access_group:["number","private"],table:"string",subscription_group:["number",null],reference:{record_id:["string",null],reference_limit:e=>{if(null===e)return null;if("number"==typeof e){if(0>e)throw new ae('"reference_limit" should be >= 0',{code:"INVALID_PARAMETER"});if(e>4503599627370546)throw new ae('"reference_limit" should be <= 4503599627370546',{code:"INVALID_PARAMETER"});return e}throw new ae('"reference_limit" should be type: <number | null>',{code:"INVALID_PARAMETER"})},allow_multiple_reference:"boolean"},index:{name:"string",value:["string","number","boolean"]},tags:e=>{if(null===e)return e;if("string"==typeof e)return[e];if(Array.isArray(e)){for(let t of e)if("string"!=typeof t)throw new ae('"tags" should be type: <string | string[]>',{code:"INVALID_PARAMETER"});return e}throw new ae('"tags" should be type: <string | string[]>',{code:"INVALID_PARAMETER"})},private_access:e=>{let t="config.private_access";if(null===e)return null;if(e&&"string"==typeof e&&(e=[e]),!Array.isArray(e))throw new ae(`"${t}" should be an array of user ID.`,{code:"INVALID_PARAMETER"});for(let r of e)if(ce(r,`User ID in "${t}"`),this.__user&&r===this.__user.user_id)throw new ae(`"${t}" should not be the uploader's user ID.`,{code:"INVALID_PARAMETER"});return e}},[],["response","formData","onerror"]))?.access_group&&this.user.access_group<t.access_group)throw new ae("User has no access",{code:"INVALID_REQUEST"});if("number"==typeof t?.subscription_group&&t.subscription_group<0||t.subscription_group>99)throw new ae("Subscription group should be within range: 0 ~ 99",{code:"INVALID_PARAMETER"});if(delete t.response,delete t.formData,delete t.onerror,""===t?.table)throw new ae('"table" cannot be empty string.',{code:"INVALID_PARAMETER"});if(!t?.table&&!t?.record_id)throw new ae('Either "record_id" or "table" should have a value.',{code:"INVALID_PARAMETER"});if(t?.index){if(!t.index?.name||"string"!=typeof t.index?.name)throw new ae('"index.name" is required. type: string.',{code:"INVALID_PARAMETER"});if(ye(t.index.name,"index name",!0),!t.index.hasOwnProperty("value"))throw new ae('"index.value" is required.',{code:"INVALID_PARAMETER"});if("string"==typeof t.index.value)ye(t.index.value,"index value",!1,!0);else if("number"==typeof t.index.value&&(t.index.value>this.__index_number_range||t.index.value<-this.__index_number_range))throw new ae(`Number value should be within range -${this.__index_number_range} ~ +${this.__index_number_range}`,{code:"INVALID_PARAMETER"})}if(r){if("private"===t?.access_group)throw new ae("Service owner cannot write private records.",{code:"INVALID_REQUEST"});if(t.hasOwnProperty("subscription_group"))throw new ae("Service owner cannot write to subscription table.",{code:"INVALID_REQUEST"})}let s={auth:!0},o=null;if(e instanceof HTMLFormElement||e instanceof FormData||e instanceof SubmitEvent){let r=e instanceof SubmitEvent?e.target:e,n=e instanceof FormData?e:new FormData(r),i=me(e);s.meta=t,Object.keys(i.meta).length&&(s.meta.data=i.meta);let a=[];for(const e of n.entries())i.files.includes(e[0])||a.push(e[0]);if(a.length)for(let e of a)n.delete(e);o=n}else o=Object.assign({data:e},t);return Object.keys(i).length&&Object.assign(s,{fetchOptions:i}),ge(await this.request("post-record",o,s))}async getIndex(e,t){let r=we(e||{},{table:"string",index:e=>ye(e,"index name",!0,!1),order:{by:["average_number","total_number","number_count","average_bool","total_bool","bool_count","string_count","index_name","number_of_records"],value:["string","number","boolean"],condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}},["table"]);if(r.hasOwnProperty("order")&&r.hasOwnProperty("index")){if("."!==r.index.substring(r.index.length-1))throw new ae('"index" should be parent "index name".',{code:"INVALID_PARAMETER"});if(!r.order?.by)throw new ae('"order.by" is required.',{code:"INVALID_PARAMETER"});if(r.order.hasOwnProperty("condition")&&!r.order.hasOwnProperty("value"))throw new ae('"value" is required for "condition".',{code:"INVALID_PARAMETER"})}let n=await this.request("get-index",r,Object.assign({auth:!0},{fetchOptions:t})),i={cnt_bool:"boolean_count",cnt_numb:"number_count",totl_numb:"total_number",totl_bool:"total_bool",avrg_numb:"average_number",avrg_bool:"average_bool",cnt_str:"string_count"};return Array.isArray(n.list)&&(n.list=n.list.map((e=>{let t=e.idx.split("/"),r={table:t[1],index:t[2],number_of_records:e.cnt_rec};for(let t in i)e?.[t]&&(r[i[t]]=e[t]);return r}))),n}subscribeNewsletter(e,t){let r=we(e||{},{email:e=>de(e),bypassWelcome:["boolean",()=>!0]},["email"]);return this.request("subscribe-newsletter",r)}async subscribe(e){let{user_id:t,group:r}=await this.subscriptionGroupCheck(e);if("*"===r)throw new ae("Cannot subscribe to all groups at once.",{code:"INVALID_PARAMETER"});return await this.request("subscription",{subscribe:t,group:r},{auth:!0})}async unsubscribe(e){let{user_id:t,group:r}=await this.subscriptionGroupCheck(e);return await this.request("subscription",{unsubscribe:t,group:r},{auth:!0})}async blockSubscriber(e){let{user_id:t,group:r}=await this.subscriptionGroupCheck(e);return await this.request("subscription",{block:t,group:r},{auth:!0})}async unblockSubscriber(e){let{user_id:t,group:r}=await this.subscriptionGroupCheck(e);return await this.request("subscription",{unblock:t,group:r},{auth:!0})}async getUserSubscriptions(e){return await this.__connection,e=we(e,{user_id:e=>{try{return ce(e,'"user_id"')}catch(e){}try{return de(e)}catch(e){}throw new ae('"subscriber" should be either valid user ID or E-Mail.',{code:"INVALID_PARAMETER"})},group:"number"})||{},this.getSubscriptions({subscriber:e.user_id||this.__user?.user_id,group:e.group})}async getUserSubscribers(e){await this.__connection;let t={subscription:(e=we(e,{user_id:e=>ce(e,'"user_id"'),group:"number"})||{}).user_id||this.__user?.user_id,group:e.group};return this.getSubscriptions(t)}async getSubscriptions(e,t,r){let n=!1;if(e=we(e,{subscriber:e=>{try{return ce(e,'User ID in "subscriber"')}catch(e){}try{let t=de(e);return n=!0,t}catch(e){}throw new ae('"subscriber" should be either valid user ID or E-Mail.',{code:"INVALID_PARAMETER"})},group:"number",subscription:e=>{try{return ce(e,'User ID in "subscription"')}catch(e){}if("string"==typeof e&&14===e.length)return e;throw new ae('"subscriber" should be either valid service ID or user ID.',{code:"INVALID_PARAMETER"})},blocked:"boolean"}),n&&!e?.subscription&&(e.subscription=this.service),!e.subscriber&&!e.subscription)throw new ae('At least either "subscriber" or "subscription" should have a value.',{code:"INVALID_PARAMETER"});let i=await this.request("get-subscription",e,Object.assign({auth:!n},{fetchOptions:t}));return i.list=i.list.map(r||(e=>{let t={},r=e.sub.split("#");return t.subscriber=r[2],t.subscription=r[0],t.group=parseInt(r[1]),t.timestamp=e.stmp,t.blocked="N"===e.grp.substring(0,1),t})),i}async getNewsletters(e,t){let r=await this.checkAdmin(),n={message_id:"string",timestamp:"number",read:"number",complaint:"number",subject:"string"};e||(t||(t={}),t.ascending=!1);let i=e||{searchFor:"timestamp",value:0,condition:">"};e=we(i,{searchFor:["message_id","timestamp","read","complaint","group","subject"],value:e=>{if(typeof e!==n[i.searchFor])throw new ae(`"value" type does not match the type of "${i.searchFor}" index.`,{code:"INVALID_PARAMETER"});if("string"==typeof e&&!e)throw new ae('"value" should not be empty string.',{code:"INVALID_PARAMETER"});return e},range:e=>{if(!i.hasOwnProperty("value")||typeof e!=typeof i.value)throw new ae('"range" should match type of "value".',{code:"INVALID_PARAMETER"});return e},condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],group:e=>{if("newsletter"!==e&&!this.session)throw new ae("User should be logged in.",{code:"INVALID_REQUEST"});if("string"==typeof e&&"newsletter"!==e)throw new ae('Group should be either "newsletter" or access group number.',{code:"INVALID_PARAMETER"});if(!r&&e>parseInt(this.session.idToken.payload.access_group))throw new ae("User has no access.",{code:"INVALID_REQUEST"});return"newsletter"===e?0:e}},["searchFor","value","group"]);let s=await this.request(0===e.group?"get-newsletters":"get-serviceletters",e,Object.assign({method:"get",auth:0!==e.group},{fetchOptions:t})),o={message_id:"mid",timestamp:"stmp",complaint:"cmpl",read:"read",subject:"subj",bounced:"bnce",url:"url"},a={message_id:"",timestamp:0,complaint:0,read:0,subject:"",bounced:0,url:""};return s.list=s.list.map((e=>{let t={};for(let r in o)t[r]=e[o[r]]||a[o[r]];return t})),s}async signup(e,t){await this.logout();let r=we(e||{},{email:e=>de(e),password:e=>fe(e),name:"string",address:"string",gender:"string",birthdate:e=>le(e),phone_number:e=>he(e),email_public:["boolean",()=>!1],address_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1],email_subscription:["boolean",()=>!1]},["email","password"]);t=we(t||{},{confirmation:e=>{if("string"==typeof e)return pe(e);if("boolean"==typeof e)return e;throw new ae('"option.confirmation" should be type: <string | boolean>.',{code:"INVALID_PARAMETER"})},login:e=>{if("boolean"==typeof e){if(t.confirmation&&e)throw new ae('"login" is not allowed when "option.confirmation" is true.',{code:"INVALID_PARAMETER"});return e}throw new ae('"option.login" should be type: boolean.',{code:"INVALID_PARAMETER"})}});let{login:n=!1,confirmation:i=!1}=t||{};if(!i&&r.email_public)throw new ae('"option.confirmation" should be true if "email_public" is set to true.',{code:"INVALID_PARAMETER"});if(await this.request("signup",r,{meta:t}),i){let e=await this.authentication().createCognitoUser(r.email);return this.cognitoUser=e.cognitoUser,this.__request_signup_confirmation=e.cognitoUsername,"SUCCESS: The account has been created. User's email confirmation is required."}return n?await this.login({email:r.email,password:r.password}):"SUCCESS: The account has been created."}async logout(){await this.__connection,this.cognitoUser&&this.cognitoUser.signOut();let e={session:null,__startKey_keys:{},__cached_requests:{},__user:null};for(let t in e)this[t]=e[t];return"SUCCESS: The user has been logged out."}async resendSignupConfirmation(e){if(!this.__request_signup_confirmation)throw new ae("Least one login attempt is required.",{code:"INVALID_REQUEST"});return e&&pe(e),await this.request("confirm-signup",{username:this.__request_signup_confirmation,redirect:e})}async recoverAccount(e=!1){if("string"==typeof e)pe(e);else if("boolean"!=typeof e)throw new ae("Argument should be type: <boolean | string>.",{code:"INVALID_REQUEST"});if(!this.__disabledAccount)throw new ae("Least one signin attempt of disabled account is required.",{code:"INVALID_REQUEST"});return await this.request("recover-account",{username:this.__disabledAccount,redirect:e}),this.__disabledAccount=null,"SUCCESS: Recovery e-mail has been sent."}async login(e,t){await this.__connection,await this.logout();let r=we(e,{email:e=>de(e),password:e=>fe(e)},["email","password"]);return this.authentication().authenticateUser(r.email,r.password)}async verifyAttribute(e,t){if(await this.__connection,!this.cognitoUser)throw new ae("The user has to be logged in.",{code:"INVALID_REQUEST"});return new Promise(((r,n)=>{let i={onSuccess:i=>{t?this.authentication().getSession({refreshToken:!0}).then((()=>{this.__user&&(this.__user[e+"_verified"]=!0),r(`SUCCESS: "${e}" is verified.`)})).catch((e=>{n(e)})):r("SUCCESS: Verification code has been sent.")},onFailure:e=>{n(new ae(e.message||"Failed to request verification code.",{code:e?.code}))}};t?this.cognitoUser?.verifyAttribute(e,t,i):(i.inputVerificationCode=null,this.cognitoUser?.getAttributeVerificationCode(e,i))}))}async verifyEmail(e,t){if(await this.__connection,!this.__user.hasOwnProperty("email"))throw new ae("No e-mail to verify",{code:"INVALID_REQUEST"});let r=(e?we(e,{code:["number","string"]}):{}).code||"";return this.verifyAttribute("email",r.toString())}async verifyPhoneNumber(e,t){if(await this.__connection,!this.__user.hasOwnProperty("phone_number"))throw new ae("No phone number to verify",{code:"INVALID_REQUEST"});let r=(e?we(e,{code:["number","string"]}):{}).code||null;return this.verifyAttribute("phone_number",r.toString())}async forgotPassword(e,t){await this.__connection;let r=we(e,{email:e=>de(e)},["email"]);return new Promise((async(e,t)=>{(await this.authentication().createCognitoUser(r.email)).cognitoUser.forgotPassword({onSuccess:t=>{e("SUCCESS: Verification code has been sent.")},onFailure:e=>{t(new ae(e?.message||"Failed to send verification code.",{code:e?.code||"ERROR"}))}})}))}async resetPassword(e,t){await this.__connection;let r=we(e,{email:e=>de(e),code:["number","string"],new_password:e=>fe(e)},["email","code","new_password"]),n=r.code,i=r.new_password;return"number"==typeof n&&(n=n.toString()),new Promise((async(e,t)=>{(await this.authentication().createCognitoUser(r.email)).cognitoUser.confirmPassword(n,i,{onSuccess:t=>{e("SUCCESS: New password has been set.")},onFailure:e=>{t(new ae(e?.message||"Failed to reset password.",{code:e?.code}))}})}))}async disableAccount(){await this.__connection;let e=await this.request("remove-account",{disable:!0},{auth:!0});return await this.logout(),e}async updateProfile(e,t){if(await this.__connection,!this.session)throw new ae("User login is required.",{code:"INVALID_REQUEST"});let r=we(e||{},{email:e=>de(e),name:"string",address:"string",gender:"string",birthdate:e=>le(e),phone_number:e=>he(e),email_public:"boolean",phone_number_public:"boolean",address_public:"boolean",gender_public:"boolean",birthdate_public:"boolean",email_subscription:"boolean"});if(r&&"object"==typeof r&&!Object.keys(r).length)return this.user;r.email&&(r.preferred_username=(await this.updateConnection({request_hash:r.email})).hash);let n=[["email_subscription","email_verified","User's E-Mail should be verified to set"],["email_public","email_verified","User's E-Mail should be verified to set"],["phone_number_public","phone_number_verified","User's phone number should be verified to set"]];if(this.__user)for(let e of n)if(r[e[0]]&&!this.__user[e[1]])throw new ae(`${e[2]} "${e[0]}" to true.`,{code:"INVALID_REQUEST"});let i=[];for(let e in r)if(r[e]!==this.user[e]){if(["email_public","phone_number_public","address_public","gender_public","birthdate_public","email_subscription"].includes(e)){let t=r[e];"boolean"==typeof t&&(t=t?"1":"0"),r["custom:"+e]=t,i.push(e)}}else i.push(e);for(let e of i)delete r[e];if(r&&"object"==typeof r&&Object.keys(r).length){let e=[];for(let t in r)e.push(new q({Name:t,Value:r[t]}));return await new Promise(((t,r)=>{this.cognitoUser?.updateAttributes(e,((e,n)=>{e&&r([e?.code||e?.name,e?.message||"Failed to update user settings."]),t(n)}))})),await this.authentication().getSession({refreshToken:!0}),this.user}return this.user}async changePassword(e){if(await this.__connection,!this.session)throw new ae("User login is required.",{code:"INVALID_REQUEST"});let t=we(e,{current_password:"string",new_password:"string"});if(!t?.current_password)throw new ae('"current_password" is required to change password.',{code:"INVALID_PARAMETER"});if(!t?.new_password)throw new ae('"new_password" is required to change password.',{code:"INVALID_PARAMETER"});return fe(t.current_password),fe(t.new_password),t.new_password!==t.current_password?new Promise(((e,r)=>{this.cognitoUser.changePassword(t.current_password,t.new_password,((t,n)=>{t&&("InvalidParameterException"===t?.code&&r(new ae("Invalid password parameter.",{code:"INVALID_PARAMETER"})),r(new ae(t?.message||"Failed to change user password.",{code:t?.code||t?.name}))),e("SUCCESS: Password has been changed.")}))})):"SUCCESS: Password has been changed."}async getUsers(e,t){e||(e={searchFor:"timestamp",condition:">",value:0},t||(t={}),t.ascending=!1);let r=await this.checkAdmin();if(r&&!e.hasOwnProperty("service"))throw new ae("Service ID is required.",{code:"INVALID_PARAMETER"});const n={user_id:e=>ce(e),name:"string",email:e=>de(e),phone_number:e=>he(e),address:"string",gender:"string",birthdate:e=>le(e),locale:e=>{if("string"!=typeof e||"string"==typeof e&&e.length>5)throw new ae('Value of "locale" should be a country code.');return e},subscribers:"number",timestamp:"number",access_group:"number",email_subscription:e=>{if(!r)throw new ae('Only admin is allowed to search "email_subscription".',{code:"INVALID_REQUEST"});return e},suspended:e=>e?"by_admin:suspended":"by_admin:approved"};if((e=we(e,{searchFor:["user_id","name","email","phone_number","address","gender","birthdate","locale","subscribers","timestamp","access_group","email_subscription","suspended"],condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],value:t=>{let r=n[e.searchFor];if("function"==typeof r)return r(t);if(typeof t!==r)throw new ae(`Value does not match the type of "${e.searchFor}" index.`,{code:"INVALID_PARAMETER"});return t},range:t=>{let r=n[e.searchFor];if("function"==typeof r)return r(t);if(typeof t!==r)throw new ae(`Range does not match the type of "${e.searchFor}" index.`,{code:"INVALID_PARAMETER"});return t}},["searchFor","value"]))?.condition&&"="!==e?.condition&&e.hasOwnProperty("range"))throw new ae("Conditions does not apply on range search.",{code:"INVALID_PARAMETER"});if("user_id"===e.searchFor&&"="!==e.condition)throw new ae('Conditions are not allowed on "user_id"',{code:"INVALID_PARAMETER"});if("access_group"===e.searchFor&&(e.searchFor="group"),"string"==typeof e?.value&&!e?.value)throw new ae("Value should not be an empty string.",{code:"INVALID_PARAMETER"});if("string"==typeof e?.searchFor&&!e?.searchFor)throw new ae('"searchFor" should not be an empty string.',{code:"INVALID_PARAMETER"});return this.request("get-users",e,{auth:!0,fetchOptions:t})}async updateConnection(e){let t=null,r={};e?.request_hash&&(this.__serviceHash[e.request_hash]?Object.assign(r,{hash:this.__serviceHash[e.request_hash]}):t={request_hash:de(e.request_hash)}),this.connection&&this.connection.service===this.service&&!t||(null===t&&(t={}),Object.assign(t,{service:this.service,service_owner:this.service_owner})),Object.assign(r,t?await this.request("service",t,{bypassAwaitConnection:!0}):this.connection),e?.request_hash&&(this.__serviceHash[e.request_hash]=r.hash);let n=JSON.parse(JSON.stringify(r));return delete n.hash,this.connection=n,r}}Ae([_e()],ve.prototype,"postRecord",null),Ae([_e()],ve.prototype,"subscribeNewsletter",null),Ae([_e()],ve.prototype,"subscribe",null),Ae([_e()],ve.prototype,"unsubscribe",null),Ae([_e()],ve.prototype,"blockSubscriber",null),Ae([_e()],ve.prototype,"unblockSubscriber",null),Ae([_e()],ve.prototype,"signup",null),Ae([_e()],ve.prototype,"login",null),Ae([_e()],ve.prototype,"verifyEmail",null),Ae([_e()],ve.prototype,"verifyPhoneNumber",null),Ae([_e()],ve.prototype,"forgotPassword",null),Ae([_e()],ve.prototype,"resetPassword",null),Ae([_e()],ve.prototype,"updateProfile",null),Ae([_e()],ve.prototype,"changePassword",null)})(),n})()));
|
|
3
3
|
//# sourceMappingURL=skapi.js.map
|