skapi-js 1.0.161 → 1.0.162

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 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 n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>(()=>{var e={914:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RawSha256=void 0;var r=n(945),i=function(){function e(){this.state=Int32Array.from(r.INIT),this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}return e.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=0,n=e.byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>r.MAX_HASHABLE_LENGTH)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;n>0;)this.buffer[this.bufferLength++]=e[t++],n--,this.bufferLength===r.BLOCK_SIZE&&(this.hashBuffer(),this.bufferLength=0)},e.prototype.digest=function(){if(!this.finished){var e=8*this.bytesHashed,t=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),n=this.bufferLength;if(t.setUint8(this.bufferLength++,128),n%r.BLOCK_SIZE>=r.BLOCK_SIZE-8){for(var i=this.bufferLength;i<r.BLOCK_SIZE;i++)t.setUint8(i,0);this.hashBuffer(),this.bufferLength=0}for(i=this.bufferLength;i<r.BLOCK_SIZE-8;i++)t.setUint8(i,0);t.setUint32(r.BLOCK_SIZE-8,Math.floor(e/4294967296),!0),t.setUint32(r.BLOCK_SIZE-4,e),this.hashBuffer(),this.finished=!0}var s=new Uint8Array(r.DIGEST_LENGTH);for(i=0;i<8;i++)s[4*i]=this.state[i]>>>24&255,s[4*i+1]=this.state[i]>>>16&255,s[4*i+2]=this.state[i]>>>8&255,s[4*i+3]=this.state[i]>>>0&255;return s},e.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],i=t[1],s=t[2],o=t[3],a=t[4],u=t[5],c=t[6],l=t[7],h=0;h<r.BLOCK_SIZE;h++){if(h<16)this.temp[h]=(255&e[4*h])<<24|(255&e[4*h+1])<<16|(255&e[4*h+2])<<8|255&e[4*h+3];else{var f=this.temp[h-2],d=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,p=((f=this.temp[h-15])>>>7|f<<25)^(f>>>18|f<<14)^f>>>3;this.temp[h]=(d+this.temp[h-7]|0)+(p+this.temp[h-16]|0)}var g=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&u^~a&c)|0)+(l+(r.KEY[h]+this.temp[h]|0)|0)|0,_=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&i^n&s^i&s)|0;l=c,c=u,u=a,a=o+g|0,o=s,s=i,i=n,n=g+_|0}t[0]+=n,t[1]+=i,t[2]+=s,t[3]+=o,t[4]+=a,t[5]+=u,t[6]+=c,t[7]+=l},e}();t.RawSha256=i},945:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_HASHABLE_LENGTH=t.INIT=t.KEY=t.DIGEST_LENGTH=t.BLOCK_SIZE=void 0,t.BLOCK_SIZE=64,t.DIGEST_LENGTH=32,t.KEY=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),t.INIT=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],t.MAX_HASHABLE_LENGTH=Math.pow(2,53)-1},938:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),(0,n(655).__exportStar)(n(430),t)},430:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Sha256=void 0;var r=n(655),i=n(945),s=n(914),o=n(658),a=function(){function e(e){if(this.hash=new s.RawSha256,e){this.outer=new s.RawSha256;var t=function(e){var t=(0,o.convertToBuffer)(e);if(t.byteLength>i.BLOCK_SIZE){var n=new s.RawSha256;n.update(t),t=n.digest()}var r=new Uint8Array(i.BLOCK_SIZE);return r.set(t),r}(e),n=new Uint8Array(i.BLOCK_SIZE);n.set(t);for(var r=0;r<i.BLOCK_SIZE;r++)t[r]^=54,n[r]^=92;for(this.hash.update(t),this.outer.update(n),r=0;r<t.byteLength;r++)t[r]=0}}return e.prototype.update=function(e){if(!(0,o.isEmptyData)(e)&&!this.error)try{this.hash.update((0,o.convertToBuffer)(e))}catch(e){this.error=e}},e.prototype.digestSync=function(){if(this.error)throw this.error;return this.outer?(this.outer.finished||this.outer.update(this.hash.digest()),this.outer.digest()):this.hash.digest()},e.prototype.digest=function(){return(0,r.__awaiter)(this,void 0,void 0,(function(){return(0,r.__generator)(this,(function(e){return[2,this.digestSync()]}))}))},e}();t.Sha256=a},106:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertToBuffer=void 0;var r=n(84),i="undefined"!=typeof Buffer&&Buffer.from?function(e){return Buffer.from(e,"utf8")}:r.fromUtf8;t.convertToBuffer=function(e){return e instanceof Uint8Array?e:"string"==typeof e?i(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}},658:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uint32ArrayFrom=t.numToUint8=t.isEmptyData=t.convertToBuffer=void 0;var r=n(106);Object.defineProperty(t,"convertToBuffer",{enumerable:!0,get:function(){return r.convertToBuffer}});var i=n(304);Object.defineProperty(t,"isEmptyData",{enumerable:!0,get:function(){return i.isEmptyData}});var s=n(174);Object.defineProperty(t,"numToUint8",{enumerable:!0,get:function(){return s.numToUint8}});var o=n(558);Object.defineProperty(t,"uint32ArrayFrom",{enumerable:!0,get:function(){return o.uint32ArrayFrom}})},304:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEmptyData=void 0,t.isEmptyData=function(e){return"string"==typeof e?0===e.length:0===e.byteLength}},174:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.numToUint8=void 0,t.numToUint8=function(e){return new Uint8Array([(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e])}},558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uint32ArrayFrom=void 0,t.uint32ArrayFrom=function(e){if(!Array.from){for(var t=new Uint32Array(e.length);0<e.length;)t[0]=e[0];return t}return Uint32Array.from(e)}},84:(e,t,n)=>{"use strict";n.r(t),n.d(t,{fromUtf8:()=>r,toUtf8:()=>i});const r=e=>"function"==typeof TextEncoder?function(e){return(new TextEncoder).encode(e)}(e):(e=>{const t=[];for(let n=0,r=e.length;n<r;n++){const r=e.charCodeAt(n);if(r<128)t.push(r);else if(r<2048)t.push(r>>6|192,63&r|128);else if(n+1<e.length&&55296==(64512&r)&&56320==(64512&e.charCodeAt(n+1))){const i=65536+((1023&r)<<10)+(1023&e.charCodeAt(++n));t.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}else t.push(r>>12|224,r>>6&63|128,63&r|128)}return Uint8Array.from(t)})(e),i=e=>"function"==typeof TextDecoder?function(e){return new TextDecoder("utf-8").decode(e)}(e):(e=>{let t="";for(let n=0,r=e.length;n<r;n++){const r=e[n];if(r<128)t+=String.fromCharCode(r);else if(192<=r&&r<224){const i=e[++n];t+=String.fromCharCode((31&r)<<6|63&i)}else if(240<=r&&r<365){const i="%"+[r,e[++n],e[++n],e[++n]].map((e=>e.toString(16))).join("%");t+=decodeURIComponent(i)}else t+=String.fromCharCode((15&r)<<12|(63&e[++n])<<6|63&e[++n])}return t})(e)},742:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,s=a(e),o=s[0],u=s[1],c=new i(function(e,t,n){return 3*(t+n)/4-n}(0,o,u)),l=0,h=u>0?o-4:o;for(n=0;n<h;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===u&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,c[l++]=255&t),1===u&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,s=[],o=16383,a=0,c=r-i;a<c;a+=o)s.push(u(e,a,a+o>c?c:a+o));return 1===i?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),s.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)n[o]=s[o],r[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e,t,r){for(var i,s,o=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(n[(s=i)>>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},764:(e,t,n)=>{"use strict";var r=n(742),i=n(645),s=n(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,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return c(this,e,t,n)}function c(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=f(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(t,n),i=(e=a(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(u.isBuffer(t)){var n=0|d(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):f(e,t);if("Buffer"===t.type&&s(t.data))return f(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(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 h(e,t){if(l(t),e=a(e,t<0?0:0|d(t)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function f(e,t){var n=t.length<0?0:0|d(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];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 n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(e).length;default:if(r)return B(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return U(this,t,n);case"latin1":case"binary":return D(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function _(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function m(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,i){var s,o=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,u/=2,n/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var l=-1;for(s=n;s<a;s++)if(c(e,s)===c(t,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===u)return l*o}else-1!==l&&(s-=s-l),l=-1}else for(n+u>a&&(n=a-u),s=n;s>=0;s--){for(var h=!0,f=0;f<u;f++)if(c(e,s+f)!==c(t,f)){h=!1;break}if(h)return s}return-1}function w(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[n+o]=a}return o}function b(e,t,n,r){return q(B(t,e.length-n),e,n,r)}function A(e,t,n,r){return q(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function v(e,t,n,r){return A(e,t,n,r)}function E(e,t,n,r){return q($(t),e,n,r)}function S(e,t,n,r){return q(function(e,t){for(var n,r,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=(n=e.charCodeAt(o))>>8,i=n%256,s.push(i),s.push(r);return s}(t,e.length-n),e,n,r)}function I(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,o,a,u,c=e[i],l=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=n)switch(h){case 1:c<128&&(l=c);break;case 2:128==(192&(s=e[i+1]))&&(u=(31&c)<<6|63&s)>127&&(l=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)&&(l=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&&(l=u)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=h}return function(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=R));return n}(r)}t.lW=u,t.h2=50,u.TYPED_ARRAY_SUPPORT=void 0!==n.g.TYPED_ARRAY_SUPPORT?n.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,n){return c(null,e,t,n)},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,n){return function(e,t,n,r){return l(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},u.allocUnsafe=function(e){return h(null,e)},u.allocUnsafeSlow=function(e){return h(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 n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?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 n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},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)_(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)_(this,t,t+3),_(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)_(this,t,t+7),_(this,t+1,t+6),_(this,t+2,t+5),_(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="",n=t.h2;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,n,r,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),a=Math.min(s,o),c=this.slice(r,i),l=e.slice(t,n),h=0;h<a;++h)if(c[h]!==l[h]){s=c[h],o=l[h];break}return s<o?-1:o<s?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return m(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return m(this,e,t,n,!1)},u.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return A(this,e,t,n);case"latin1":case"binary":return v(this,e,t,n);case"base64":return E(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).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,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function D(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function C(e,t,n){var r,i=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>i)&&(n=i);for(var s="",o=t;o<n;++o)s+=(r=e[o])<16?"0"+r.toString(16):r.toString(16);return s}function P(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function N(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,n,r,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(n+r>e.length)throw new RangeError("Index out of range")}function O(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-n,2);i<s;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function L(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-n,4);i<s;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function M(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function V(e,t,n,r,s){return s||M(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,s){return s||M(e,0,n,8),i.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;n=new u(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+e]}return n},u.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},u.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},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,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*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 n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){t||N(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},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,n,r){e=+e,t|=0,n|=0,r||k(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[t]=255&e;++s<n&&(i*=256);)this[t+s]=e/i&255;return t+n},u.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||k(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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):L(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||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):L(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);k(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<n&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);k(this,e,t,n,i-1,-i)}var s=n-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+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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):L(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||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):L(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,n){return V(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return V(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,s=r-n;if(this===e&&n<t&&t<r)for(i=s-1;i>=0;--i)e[i+t]=this[i+n];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},u.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var o=u.isBuffer(e)?e:B(new u(e,r).toString()),a=o.length;for(s=0;s<n-t;++s)this[s+t]=o[s%a]}return this};var x=/[^+\/0-9A-Za-z-_]/g;function B(e,t){var n;t=t||1/0;for(var r=e.length,i=null,s=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function $(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(x,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}},645:(e,t)=>{t.read=function(e,t,n,r,i){var s,o,a=8*i-r-1,u=(1<<a)-1,c=u>>1,l=-7,h=n?i-1:0,f=n?-1:1,d=e[t+h];for(h+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+e[t+h],h+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=r;l>0;o=256*o+e[t+h],h+=f,l-=8);if(0===s)s=1-c;else{if(s===u)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),s-=c}return(d?-1:1)*o*Math.pow(2,s-r)},t.write=function(e,t,n,r,i,s){var o,a,u,c=8*s-i-1,l=(1<<c)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,p=r?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=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),(t+=o+h>=1?f/u:f*Math.pow(2,1-h))*u>=2&&(o++,u/=2),o+h>=l?(a=0,o=l):o+h>=1?(a=(t*u-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[n+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;e[n+d]=255&o,d+=p,o/=256,c-=8);e[n+d-p]|=128*g}},826:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},204:(e,t,n)=>{e.exports=self.fetch||(self.fetch=n(869).default||n(869))},808:(e,t,n)=>{var r,i,s;void 0===(i="function"==typeof(r=s=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function i(){}function s(t,n,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(n);/^[\{\[]/.test(o)&&(n=o)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).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+"="+n+a}}function o(e,n){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("=");n||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var c=t(a[0]);if(u=(r.read||r)(u,c)||t(u),n)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,n){s(t,"",e(n,{expires:-1}))},i.defaults={},i.withConverter=n,i}((function(){}))})?r.call(t,n,t,e):r)||(e.exports=i),e.exports=s()},655:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__assign:()=>s,__asyncDelegator:()=>b,__asyncGenerator:()=>w,__asyncValues:()=>A,__await:()=>y,__awaiter:()=>l,__classPrivateFieldGet:()=>I,__classPrivateFieldSet:()=>T,__createBinding:()=>f,__decorate:()=>a,__exportStar:()=>d,__extends:()=>i,__generator:()=>h,__importDefault:()=>S,__importStar:()=>E,__makeTemplateObject:()=>v,__metadata:()=>c,__param:()=>u,__read:()=>g,__rest:()=>o,__spread:()=>_,__spreadArrays:()=>m,__values:()=>p});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)};function i(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},s.apply(this,arguments)};function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function a(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o}function u(e,t){return function(n,r){t(n,r,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function l(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}u((r=r.apply(e,t||[])).next())}))}function h(e,t){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function f(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}function d(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||(t[n]=e[n])}function p(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function _(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function m(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)r[i]=s[o];return r}function y(e){return this instanceof y?(this.v=e,this):new y(e)}function w(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),s=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(e){i[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=i[e](t)).value instanceof y?Promise.resolve(n.value.v).then(u,c):l(s[0][2],n)}catch(e){l(s[0][3],e)}var n}function u(e){a("next",e)}function c(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function b(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:y(e[r](t)),done:"return"===r}:i?i(t):t}:i}}function A(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=p(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,i,(t=e[n](t)).done,t.value)}))}}}function v(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function E(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function S(e){return e&&e.__esModule?e:{default:e}}function I(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function T(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}},869:(e,t,n)=>{"use strict";function r(e,t){return t=t||{},new Promise((function(n,r){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,n){s.push(t=t.toLowerCase()),o.push([t,n]),a[t]=a[t]?a[t]+","+n:n})),n(u())},i.onerror=r,i.withCredentials="include"==t.credentials,t.headers)i.setRequestHeader(c,t.headers[c]);i.send(t.body||null)}))}n.r(t),n.d(t,{default:()=>r})},249:()=>{}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{Skapi:()=>Bt,SkapiError:()=>ee});var e,t=function(){function e(e){var t=e||{},n=t.ValidationData,r=t.Username,i=t.Password,s=t.AuthParameters,o=t.ClientMetadata;this.validationData=n||{},this.authParameters=s||{},this.clientMetadata=o||{},this.username=r,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=n(764);if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==n.g&&n.g.crypto&&(e=n.g.crypto),!e)try{e=n(249)}catch(e){}function s(){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 o=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 n=[],r=0;r<t;r+=4)n.push(s());return new e(n,t)},t.toString=function(){return function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var s=t[i>>>2]>>>24-i%4*8&255;r.push((s>>>4).toString(16)),r.push((15&s).toString(16))}return r.join("")}(this)},e}(),a=n(938);const u=c;function c(e,t){null!=e&&this.fromString(e,t)}function l(){return new c(null)}var h,f="undefined"!=typeof navigator;f&&"Microsoft Internet Explorer"==navigator.appName?(c.prototype.am=function(e,t,n,r,i,s){for(var o=32767&t,a=t>>15;--s>=0;){var u=32767&this[e],c=this[e++]>>15,l=a*u+c*o;i=((u=o*u+((32767&l)<<15)+n[r]+(1073741823&i))>>>30)+(l>>>15)+a*c+(i>>>30),n[r++]=1073741823&u}return i},h=30):f&&"Netscape"!=navigator.appName?(c.prototype.am=function(e,t,n,r,i,s){for(;--s>=0;){var o=t*this[e++]+n[r]+i;i=Math.floor(o/67108864),n[r++]=67108863&o}return i},h=26):(c.prototype.am=function(e,t,n,r,i,s){for(var o=16383&t,a=t>>14;--s>=0;){var u=16383&this[e],c=this[e++]>>14,l=a*u+c*o;i=((u=o*u+((16383&l)<<14)+n[r]+i)>>28)+(l>>14)+a*c,n[r++]=268435455&u}return i},h=28),c.prototype.DB=h,c.prototype.DM=(1<<h)-1,c.prototype.DV=1<<h,c.prototype.FV=Math.pow(2,52),c.prototype.F1=52-h,c.prototype.F2=2*h-52;var d,p,g=new Array;for(d="0".charCodeAt(0),p=0;p<=9;++p)g[d++]=p;for(d="a".charCodeAt(0),p=10;p<36;++p)g[d++]=p;for(d="A".charCodeAt(0),p=10;p<36;++p)g[d++]=p;function _(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function m(e,t){var n=g[e.charCodeAt(t)];return null==n?-1:n}function y(e){var t=l();return t.fromInt(e),t}function w(e){var t,n=1;return 0!=(t=e>>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}function b(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 A(e){return i.lW.from((new o).random(e).toString(),"hex")}b.prototype.convert=function(e){var t=l();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(c.ZERO)>0&&this.m.subTo(t,t),t},b.prototype.revert=function(e){var t=l();return e.copyTo(t),this.reduce(t),t},b.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var n=32767&e[t],r=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,r,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},b.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},b.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},c.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},c.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},c.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");n=2}this.t=0,this.s=0;for(var r=e.length,i=!1,s=0;--r>=0;){var o=m(e,r);o<0?"-"==e.charAt(r)&&(i=!0):(i=!1,0==s?this[this.t++]=o:s+n>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+=n)>=this.DB&&(s-=this.DB))}this.clamp(),i&&c.ZERO.subTo(this,this)},c.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},c.prototype.dlShiftTo=function(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s},c.prototype.drShiftTo=function(e,t){for(var n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s},c.prototype.lShiftTo=function(e,t){var n,r=e%this.DB,i=this.DB-r,s=(1<<i)-1,o=Math.floor(e/this.DB),a=this.s<<r&this.DM;for(n=this.t-1;n>=0;--n)t[n+o+1]=this[n]>>i|a,a=(this[n]&s)<<r;for(n=o-1;n>=0;--n)t[n]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},c.prototype.rShiftTo=function(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var r=e%this.DB,i=this.DB-r,s=(1<<r)-1;t[0]=this[n]>>r;for(var o=n+1;o<this.t;++o)t[o-n-1]|=(this[o]&s)<<i,t[o-n]=this[o]>>r;r>0&&(t[this.t-n-1]|=(this.s&s)<<i),t.t=this.t-n,t.clamp()}},c.prototype.subTo=function(e,t){for(var n=0,r=0,i=Math.min(e.t,this.t);n<i;)r+=this[n]-e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r-=e[n],t[n++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t[n++]=this.DV+r:r>0&&(t[n++]=r),t.t=n,t.clamp()},c.prototype.multiplyTo=function(e,t){var n=this.abs(),r=e.abs(),i=n.t;for(t.t=i+r.t;--i>=0;)t[i]=0;for(i=0;i<r.t;++i)t[i+n.t]=n.am(0,r[i],t,i,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&c.ZERO.subTo(t,t)},c.prototype.squareTo=function(e){for(var t=this.abs(),n=e.t=2*t.t;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){var r=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,r,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()},c.prototype.divRemTo=function(e,t,n){var r=e.abs();if(!(r.t<=0)){var i=this.abs();if(i.t<r.t)return null!=t&&t.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=l());var s=l(),o=this.s,a=e.s,u=this.DB-w(r[r.t-1]);u>0?(r.lShiftTo(u,s),i.lShiftTo(u,n)):(r.copyTo(s),i.copyTo(n));var h=s.t,f=s[h-1];if(0!=f){var d=f*(1<<this.F1)+(h>1?s[h-2]>>this.F2:0),p=this.FV/d,g=(1<<this.F1)/d,_=1<<this.F2,m=n.t,y=m-h,b=null==t?l():t;for(s.dlShiftTo(y,b),n.compareTo(b)>=0&&(n[n.t++]=1,n.subTo(b,n)),c.ONE.dlShiftTo(h,b),b.subTo(s,s);s.t<h;)s[s.t++]=0;for(;--y>=0;){var A=n[--m]==f?this.DM:Math.floor(n[m]*p+(n[m-1]+_)*g);if((n[m]+=s.am(0,A,n,y,0,h))<A)for(s.dlShiftTo(y,b),n.subTo(b,n);n[m]<--A;)n.subTo(b,n)}null!=t&&(n.drShiftTo(h,t),o!=a&&c.ZERO.subTo(t,t)),n.t=h,n.clamp(),u>0&&n.rShiftTo(u,n),o<0&&c.ZERO.subTo(n,n)}}},c.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},c.prototype.addTo=function(e,t){for(var n=0,r=0,i=Math.min(e.t,this.t);n<i;)r+=this[n]+e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r+=e[n],t[n++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t[n++]=r:r<-1&&(t[n++]=this.DV+r),t.t=n,t.clamp()},c.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 n,r=(1<<t)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0)for(a<this.DB&&(n=this[o]>>a)>0&&(i=!0,s=_(n));o>=0;)a<t?(n=(this[o]&(1<<a)-1)<<t-a,n|=this[--o]>>(a+=this.DB-t)):(n=this[o]>>(a-=t)&r,a<=0&&(a+=this.DB,--o)),n>0&&(i=!0),i&&(s+=_(n));return i?s:"0"},c.prototype.negate=function(){var e=l();return c.ZERO.subTo(this,e),e},c.prototype.abs=function(){return this.s<0?this.negate():this},c.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0},c.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+w(this[this.t-1]^this.s&this.DM)},c.prototype.mod=function(e){var t=l();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(c.ZERO)>0&&e.subTo(t,t),t},c.prototype.equals=function(e){return 0==this.compareTo(e)},c.prototype.add=function(e){var t=l();return this.addTo(e,t),t},c.prototype.subtract=function(e){var t=l();return this.subTo(e,t),t},c.prototype.multiply=function(e){var t=l();return this.multiplyTo(e,t),t},c.prototype.divide=function(e){var t=l();return this.divRemTo(e,t,null),t},c.prototype.modPow=function(e,t,n){var r,i=e.bitLength(),s=y(1),o=new b(t);if(i<=0)return s;r=i<18?1:i<48?3:i<144?4:i<768?5:6;var a=new Array,u=3,c=r-1,h=(1<<r)-1;if(a[1]=o.convert(this),r>1){var f=l();for(o.sqrTo(a[1],f);u<=h;)a[u]=l(),o.mulTo(f,a[u-2],a[u]),u+=2}var d,p,g=e.t-1,_=!0,m=l();for(i=w(e[g])-1;g>=0;){for(i>=c?d=e[g]>>i-c&h:(d=(e[g]&(1<<i+1)-1)<<c-i,g>0&&(d|=e[g-1]>>this.DB+i-c)),u=r;0==(1&d);)d>>=1,--u;if((i-=u)<0&&(i+=this.DB,--g),_)a[d].copyTo(s),_=!1;else{for(;u>1;)o.sqrTo(s,m),o.sqrTo(m,s),u-=2;u>0?o.sqrTo(s,m):(p=s,s=m,m=p),o.mulTo(m,a[d],s)}for(;g>=0&&0==(e[g]&1<<i);)o.sqrTo(s,m),p=s,s=m,m=p,--i<0&&(i=this.DB-1,--g)}var A=o.revert(s);return n(null,A),A},c.ZERO=y(0),c.ONE=y(1);var v=/^[89a-f]/i,E=function(){function e(e){this.N=new u("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",16),this.g=new u("2",16),this.k=new u(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(n,r){n&&e(n,null),t.largeAValue=r,e(null,t.largeAValue)}))},t.generateRandomSmallA=function(){var e=A(128).toString("hex");return new u(e,16)},t.generateRandomString=function(){return A(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,n){var r=this;this.randomPassword=this.generateRandomString();var i=""+e+t+":"+this.randomPassword,s=this.hash(i),o=A(16).toString("hex");this.SaltToHashDevices=this.padHex(new u(o,16)),this.g.modPow(new u(this.hexHash(this.SaltToHashDevices+s),16),this.N,(function(e,t){e&&n(e,null),r.verifierDevices=r.padHex(t),n(null,null)}))},t.calculateA=function(e,t){var n=this;this.g.modPow(e,this.N,(function(e,r){e&&t(e,null),r.mod(n.N).equals(u.ZERO)&&t(new Error("Illegal paramater. A mod N cannot be 0."),null),t(null,r)}))},t.calculateU=function(e,t){return this.UHexHash=this.hexHash(this.padHex(e)+this.padHex(t)),new u(this.UHexHash,16)},t.hash=function(e){var t=new a.Sha256;t.update(e);var n=t.digestSync(),r=i.lW.from(n).toString("hex");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 n=i.lW.concat([this.infoBits,i.lW.from(String.fromCharCode(1),"utf8")]),r=new a.Sha256(t);r.update(e);var s=r.digestSync(),o=new a.Sha256(s);return o.update(n),o.digestSync().slice(0,16)},t.getPasswordAuthenticationKey=function(e,t,n,r,s){var o=this;if(n.mod(this.N).equals(u.ZERO))throw new Error("B cannot be zero.");if(this.UValue=this.calculateU(this.largeAValue,n),this.UValue.equals(u.ZERO))throw new Error("U cannot be zero.");var a=""+this.poolName+e+":"+t,c=this.hash(a),l=new u(this.hexHash(this.padHex(r)+c),16);this.calculateS(l,n,(function(e,t){e&&s(e,null);var n=o.computehkdf(i.lW.from(o.padHex(t),"hex"),i.lW.from(o.padHex(o.UValue),"hex"));s(null,n)}))},t.calculateS=function(e,t,n){var r=this;this.g.modPow(e,this.N,(function(i,s){i&&n(i,null),t.subtract(r.k.multiply(s)).modPow(r.smallAValue.add(r.UValue.multiply(e)),r.N,(function(e,t){e&&n(e,null),n(null,t.mod(r.N))}))}))},t.getNewPasswordRequiredChallengeUserAttributePrefix=function(){return"userAttributes."},t.padHex=function(e){if(!(e instanceof u))throw new Error("Not a BigInteger");var t=e.compareTo(u.ZERO)<0,n=e.abs().toString(16);if(n=n.length%2!=0?"0"+n:n,n=v.test(n)?"00"+n:n,t){var r=n.split("").map((function(e){var t=15&~parseInt(e,16);return"0123456789ABCDEF".charAt(t)})).join("");(n=new u(r,16).add(u.ONE).toString(16)).toUpperCase().startsWith("FF8")&&(n=n.substring(2))}return n},e}(),S=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 I(e,t){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},I(e,t)}var T=function(e){var t,n;function r(t){var n=(void 0===t?{}:t).AccessToken;return e.call(this,n||"")||this}return n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,I(t,n),r}(S);function R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},R(e,t)}var U=function(e){var t,n;function r(t){var n=(void 0===t?{}:t).IdToken;return e.call(this,n||"")||this}return n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,R(t,n),r}(S),D="aws-amplify/5.0.4",C="undefined"!=typeof navigator&&"ReactNative"===navigator.product,P=function(){function e(e){var t=(void 0===e?{}:e).RefreshToken;this.token=t||""}return e.prototype.getToken=function(){return this.token},e}(),N=function(){function e(e){var t=void 0===e?{}:e,n=t.IdToken,r=t.RefreshToken,i=t.AccessToken,s=t.ClockDrift;if(null==i||null==n)throw new Error("Id token and Access Token must be present.");this.idToken=n,this.refreshToken=r,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}(),k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],O=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],L=function(){function e(){}return e.prototype.getNowString=function(){var e=new Date,t=O[e.getUTCDay()],n=k[e.getUTCMonth()],r=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+" "+n+" "+r+" "+i+":"+s+":"+o+" UTC "+e.getUTCFullYear()},e}(),M=function(){function e(e){var t=void 0===e?{}:e,n=t.Name,r=t.Value;this.Name=n||"",this.Value=r||""}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}(),V={},F=function(){function e(){}return e.setItem=function(e,t){return V[e]=t,V[e]},e.getItem=function(e){return Object.prototype.hasOwnProperty.call(V,e)?V[e]:void 0},e.removeItem=function(e){return delete V[e]},e.clear=function(){return V={}},e}(),x=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=F}}return e.prototype.getStorage=function(){return this.storageWindow},e}(),B="undefined"!=typeof navigator?C?"react-native":navigator.userAgent:"nodejs",$=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 x).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 n=this,r=e.getAuthParameters();r.USERNAME=this.username;var i=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),s={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:r,ClientMetadata:i};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",s,(function(e,r){if(e)return t.onFailure(e);var i=r.ChallengeName,s=r.ChallengeParameters;return"CUSTOM_CHALLENGE"===i?(n.Session=r.Session,t.customChallenge(s)):(n.signInUserSession=n.getCognitoUserSession(r.AuthenticationResult),n.cacheTokens(),t.onSuccess(n.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 n,r,s=this,o=new E(this.pool.getUserPoolName()),c=new L,l={};null!=this.deviceKey&&(l.DEVICE_KEY=this.deviceKey),l.USERNAME=this.username,o.getLargeAValue((function(h,f){h&&t.onFailure(h),l.SRP_A=f.toString(16),"CUSTOM_AUTH"===s.authenticationFlowType&&(l.CHALLENGE_NAME="SRP_A");var d=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),p={AuthFlow:s.authenticationFlowType,ClientId:s.pool.getClientId(),AuthParameters:l,ClientMetadata:d};s.getUserContextData(s.username)&&(p.UserContextData=s.getUserContextData(s.username)),s.client.request("InitiateAuth",p,(function(l,h){if(l)return t.onFailure(l);var f=h.ChallengeParameters;s.username=f.USER_ID_FOR_SRP,s.userDataKey=s.keyPrefix+"."+s.username+".userData",n=new u(f.SRP_B,16),r=new u(f.SALT,16),s.getCachedDeviceKeyAndPassword(),o.getPasswordAuthenticationKey(s.username,e.getPassword(),n,r,(function(e,n){e&&t.onFailure(e);var r=c.getNowString(),u=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(r,"utf8")]),l=new a.Sha256(n);l.update(u);var p=l.digestSync(),g=i.lW.from(p).toString("base64"),_={};_.USERNAME=s.username,_.PASSWORD_CLAIM_SECRET_BLOCK=f.SECRET_BLOCK,_.TIMESTAMP=r,_.PASSWORD_CLAIM_SIGNATURE=g,null!=s.deviceKey&&(_.DEVICE_KEY=s.deviceKey);var m={ChallengeName:"PASSWORD_VERIFIER",ClientId:s.pool.getClientId(),ChallengeResponses:_,Session:h.Session,ClientMetadata:d};s.getUserContextData()&&(m.UserContextData=s.getUserContextData()),function e(t,n){return s.client.request("RespondToAuthChallenge",t,(function(r,i){return r&&"ResourceNotFoundException"===r.code&&-1!==r.message.toLowerCase().indexOf("device")?(_.DEVICE_KEY=null,s.deviceKey=null,s.randomPassword=null,s.deviceGroupKey=null,s.clearCachedDeviceKeyAndPassword(),e(t,n)):n(r,i)}))}(m,(function(e,n){return e?t.onFailure(e):s.authenticateUserInternal(n,o,t)}))}))}))}))},t.authenticateUserPlainUsernamePassword=function(e,t){var n=this,r={};if(r.USERNAME=this.username,r.PASSWORD=e.getPassword(),r.PASSWORD){var i=new E(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(r.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:r,ClientMetadata:s};this.getUserContextData(this.username)&&(o.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",o,(function(e,r){return e?t.onFailure(e):n.authenticateUserInternal(r,i,t)}))}else t.onFailure(new Error("PASSWORD parameter is required"))},t.authenticateUserInternal=function(e,t,n){var r=this,s=e.ChallengeName,o=e.ChallengeParameters;if("SMS_MFA"===s)return this.Session=e.Session,n.mfaRequired(s,o);if("SELECT_MFA_TYPE"===s)return this.Session=e.Session,n.selectMFAType(s,o);if("MFA_SETUP"===s)return this.Session=e.Session,n.mfaSetup(s,o);if("SOFTWARE_TOKEN_MFA"===s)return this.Session=e.Session,n.totpRequired(s,o);if("CUSTOM_CHALLENGE"===s)return this.Session=e.Session,n.customChallenge(o);if("NEW_PASSWORD_REQUIRED"===s){this.Session=e.Session;var a=null,u=null,c=[],l=t.getNewPasswordRequiredChallengeUserAttributePrefix();if(o&&(a=JSON.parse(e.ChallengeParameters.userAttributes),u=JSON.parse(e.ChallengeParameters.requiredAttributes)),u)for(var h=0;h<u.length;h++)c[h]=u[h].substr(l.length);return n.newPasswordRequired(a,c)}if("DEVICE_SRP_AUTH"===s)return this.Session=e.Session,void this.getDeviceResponse(n);this.signInUserSession=this.getCognitoUserSession(e.AuthenticationResult),this.challengeName=s,this.cacheTokens();var f=e.AuthenticationResult.NewDeviceMetadata;if(null==f)return n.onSuccess(this.signInUserSession);t.generateHashDevice(e.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,e.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(s){if(s)return n.onFailure(s);var o={Salt:i.lW.from(t.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:i.lW.from(t.getVerifierDevices(),"hex").toString("base64")};r.verifierDevices=o.PasswordVerifier,r.deviceGroupKey=f.DeviceGroupKey,r.randomPassword=t.getRandomPassword(),r.client.request("ConfirmDevice",{DeviceKey:f.DeviceKey,AccessToken:r.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:o,DeviceName:B},(function(t,i){return t?n.onFailure(t):(r.deviceKey=e.AuthenticationResult.NewDeviceMetadata.DeviceKey,r.cacheDeviceKeyAndPassword(),!0===i.UserConfirmationNecessary?n.onSuccess(r.signInUserSession,i.UserConfirmationNecessary):n.onSuccess(r.signInUserSession))}))}))},t.completeNewPasswordChallenge=function(e,t,n,r){var i=this;if(!e)return n.onFailure(new Error("New password is required."));var s=new E(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:r};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,t){return e?n.onFailure(e):i.authenticateUserInternal(t,s,n)}))},t.getDeviceResponse=function(e,t){var n=this,r=new E(this.deviceGroupKey),s=new L,o={};o.USERNAME=this.username,o.DEVICE_KEY=this.deviceKey,r.getLargeAValue((function(c,l){c&&e.onFailure(c),o.SRP_A=l.toString(16);var h={ChallengeName:"DEVICE_SRP_AUTH",ClientId:n.pool.getClientId(),ChallengeResponses:o,ClientMetadata:t,Session:n.Session};n.getUserContextData()&&(h.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",h,(function(t,o){if(t)return e.onFailure(t);var c=o.ChallengeParameters,l=new u(c.SRP_B,16),h=new u(c.SALT,16);r.getPasswordAuthenticationKey(n.deviceKey,n.randomPassword,l,h,(function(t,r){if(t)return e.onFailure(t);var u=s.getNowString(),l=i.lW.concat([i.lW.from(n.deviceGroupKey,"utf8"),i.lW.from(n.deviceKey,"utf8"),i.lW.from(c.SECRET_BLOCK,"base64"),i.lW.from(u,"utf8")]),h=new a.Sha256(r);h.update(l);var f=h.digestSync(),d=i.lW.from(f).toString("base64"),p={};p.USERNAME=n.username,p.PASSWORD_CLAIM_SECRET_BLOCK=c.SECRET_BLOCK,p.TIMESTAMP=u,p.PASSWORD_CLAIM_SIGNATURE=d,p.DEVICE_KEY=n.deviceKey;var g={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:n.pool.getClientId(),ChallengeResponses:p,Session:o.Session};n.getUserContextData()&&(g.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",g,(function(t,r){return t?e.onFailure(t):(n.signInUserSession=n.getCognitoUserSession(r.AuthenticationResult),n.cacheTokens(),e.onSuccess(n.signInUserSession))}))}))}))}))},t.confirmRegistration=function(e,t,n,r){var i={ClientId:this.pool.getClientId(),ConfirmationCode:e,Username:this.username,ForceAliasCreation:t,ClientMetadata:r};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",i,(function(e){return e?n(e,null):n(null,"SUCCESS")}))},t.sendCustomChallengeAnswer=function(e,t,n){var r=this,i={};i.USERNAME=this.username,i.ANSWER=e;var s=new E(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:n};this.getUserContextData()&&(o.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",o,(function(e,n){return e?t.onFailure(e):r.authenticateUserInternal(n,s,t)}))},t.sendMFACode=function(e,t,n,r){var s=this,o={};o.USERNAME=this.username,o.SMS_MFA_CODE=e;var a=n||"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:r};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,n){if(e)return t.onFailure(e);if("DEVICE_SRP_AUTH"!==n.ChallengeName){if(s.signInUserSession=s.getCognitoUserSession(n.AuthenticationResult),s.cacheTokens(),null==n.AuthenticationResult.NewDeviceMetadata)return t.onSuccess(s.signInUserSession);var r=new E(s.pool.getUserPoolName());r.generateHashDevice(n.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,n.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(e){if(e)return t.onFailure(e);var o={Salt:i.lW.from(r.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:i.lW.from(r.getVerifierDevices(),"hex").toString("base64")};s.verifierDevices=o.PasswordVerifier,s.deviceGroupKey=n.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,s.randomPassword=r.getRandomPassword(),s.client.request("ConfirmDevice",{DeviceKey:n.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:s.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:o,DeviceName:B},(function(e,r){return e?t.onFailure(e):(s.deviceKey=n.AuthenticationResult.NewDeviceMetadata.DeviceKey,s.cacheDeviceKeyAndPassword(),!0===r.UserConfirmationNecessary?t.onSuccess(s.signInUserSession,r.UserConfirmationNecessary):t.onSuccess(s.signInUserSession))}))}))}else s.getDeviceResponse(t)}))},t.changePassword=function(e,t,n,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:e,ProposedPassword:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:r},(function(e){return e?n(e,null):n(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,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:e,SoftwareTokenMfaSettings:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?n(e,null):n(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 n=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):(n.clearCachedUser(),e(null,"SUCCESS"))}))},t.updateAttributes=function(e,t,n){var r=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:n},(function(e,n){return e?t(e,null):r.getUserData((function(){return t(null,"SUCCESS",n)}),{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,n){if(t)return e(t,null);for(var r=[],i=0;i<n.UserAttributes.length;i++){var s={Name:n.UserAttributes[i].Name,Value:n.UserAttributes[i].Value},o=new M(s);r.push(o)}return e(null,r)}))},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,n){return t?e(t,null):e(null,n.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(n){var r=t.signInUserSession.getRefreshToken();r&&r.getToken()?t.refreshSession(r,n,e.clientMetadata):n()}))},t.getUserData=function(e,t){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return this.clearCachedUserData(),e(new Error("User is not authenticated"),null);var r=this.getUserDataFromCache();if(r)if(this.isFetchUserDataAndTokenRequired(t))this.fetchUserData().then((function(e){return n.refreshSessionIfPossible(t).then((function(){return e}))})).then((function(t){return e(null,t)})).catch(e);else try{return void e(null,JSON.parse(r))}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 n=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):n.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.resendConfirmationCode=function(e,t){var n={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.client.request("ResendConfirmationCode",n,(function(t,n){return t?e(t,null):e(null,n)}))},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 n="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,r=n+".idToken",i=n+".accessToken",s=n+".refreshToken",o=n+".clockDrift";if(this.storage.getItem(r)){var a=new U({IdToken:this.storage.getItem(r)}),u=new T({AccessToken:this.storage.getItem(i)}),c=new P({RefreshToken:this.storage.getItem(s)}),l=parseInt(this.storage.getItem(o),0)||0,h=new N({IdToken:a,AccessToken:u,RefreshToken:c,ClockDrift:l});if(h.isValid())return this.signInUserSession=h,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,n){var r=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:n};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",c,(function(t,n){if(t)return"NotAuthorizedException"===t.code&&r.clearCachedUser(),i(t,null);if(n){var s=n.AuthenticationResult;return Object.prototype.hasOwnProperty.call(s,"RefreshToken")||(s.RefreshToken=e.getToken()),r.signInUserSession=r.getCognitoUserSession(s),r.cacheTokens(),i(null,r.signInUserSession)}}))},t.cacheTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",n=e+"."+this.username+".accessToken",r=e+"."+this.username+".refreshToken",i=e+"."+this.username+".clockDrift",s=e+".LastAuthUser";this.storage.setItem(t,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(n,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(r,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",n=e+".randomPasswordKey",r=e+".deviceGroupKey";this.storage.setItem(t,this.deviceKey),this.storage.setItem(n,this.randomPassword),this.storage.setItem(r,this.deviceGroupKey)},t.getCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",n=e+".randomPasswordKey",r=e+".deviceGroupKey";this.storage.getItem(t)&&(this.deviceKey=this.storage.getItem(t),this.randomPassword=this.storage.getItem(n),this.deviceGroupKey=this.storage.getItem(r))},t.clearCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",n=e+".randomPasswordKey",r=e+".deviceGroupKey";this.storage.removeItem(t),this.storage.removeItem(n),this.storage.removeItem(r)},t.clearCachedTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",n=e+"."+this.username+".accessToken",r=e+"."+this.username+".refreshToken",i=e+".LastAuthUser",s=e+"."+this.username+".clockDrift";this.storage.removeItem(t),this.storage.removeItem(n),this.storage.removeItem(r),this.storage.removeItem(i),this.storage.removeItem(s)},t.getCognitoUserSession=function(e){var t=new U(e),n=new T(e),r=new P(e);return new N({IdToken:t,AccessToken:n,RefreshToken:r})},t.forgotPassword=function(e,t){var n={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.getUserContextData()&&(n.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",n,(function(t,n){return t?e.onFailure(t):"function"==typeof e.inputVerificationCode?e.inputVerificationCode(n):e.onSuccess(n)}))},t.confirmPassword=function(e,t,n,r){var i={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:e,Password:t,ClientMetadata:r};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",i,(function(e){return e?n.onFailure(e):n.onSuccess("SUCCESS")}))},t.getAttributeVerificationCode=function(e,t,n){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:n},(function(e,n){return e?t.onFailure(e):"function"==typeof t.inputVerificationCode?t.inputVerificationCode(n):t.onSuccess("SUCCESS")}))},t.verifyAttribute=function(e,t,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:e,Code:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?n.onFailure(e):n.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,n){return t?e.onFailure(t):e.onSuccess(n)}))},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(n){return t.deviceKey=null,t.deviceGroupKey=null,t.randomPassword=null,t.clearCachedDeviceKeyAndPassword(),e.onSuccess(n)}})},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,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n.onFailure(new Error("User is not authenticated"));var r={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:e};t&&(r.PaginationToken=t),this.client.request("ListDevices",r,(function(e,t){return e?n.onFailure(e):n.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(n){return n?e.onFailure(n):(t.clearCachedUser(),e.onSuccess("SUCCESS"))}))},t.signOut=function(e){var t=this;e&&"function"==typeof e?this.getSession((function(n,r){if(n)return e(n);t.revokeTokens((function(n){t.cleanClientData(),e(n)}))})):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(),n=this.signInUserSession.getAccessToken();if(this.isSessionRevocable(n)&&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,n=e.callback;this.client.requestWithRetry("RevokeToken",{Token:t,ClientId:this.pool.getClientId()},(function(e){if(e)return n(e);n()}))},t.sendMFASelectionAnswer=function(e,t){var n=this,r={};r.USERNAME=this.username,r.ANSWER=e;var i={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:r,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",i,(function(r,i){return r?t.onFailure(r):(n.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,n){return t?e.onFailure(t):e.associateSecretCode(n.SecretCode)})):this.client.request("AssociateSoftwareToken",{Session:this.Session},(function(n,r){return n?e.onFailure(n):(t.Session=r.Session,e.associateSecretCode(r.SecretCode))}))},t.verifySoftwareToken=function(e,t,n){var r=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?n.onFailure(e):n.onSuccess(t)})):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:e,FriendlyDeviceName:t},(function(e,t){if(e)return n.onFailure(e);r.Session=t.Session;var i={};i.USERNAME=r.username;var s={ChallengeName:"MFA_SETUP",ClientId:r.pool.getClientId(),ChallengeResponses:i,Session:r.Session};r.getUserContextData()&&(s.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",s,(function(e,t){return e?n.onFailure(e):(r.signInUserSession=r.getCognitoUserSession(t.AuthenticationResult),r.cacheTokens(),n.onSuccess(r.signInUserSession))}))}))},e}();function q(){}function j(e){var t="function"==typeof Map?new Map:void 0;return j=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;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 K(e,arguments,J(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),H(n,e)},j(e)}function K(e,t,n){return K=function(){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}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&H(i,n.prototype),i},K.apply(null,arguments)}function H(e,t){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},H(e,t)}function J(e){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},J(e)}n(204),q.prototype.userAgent=D;var W=function(e){function t(t,n,r,i){var s;return(s=e.call(this,t)||this).code=n,s.name=r,s.statusCode=i,s}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,H(n,r),t;var n,r}(j(Error)),Q=function(){function e(e,t,n){this.endpoint=t||"https://cognito-idp."+e+".amazonaws.com/";var r=(n||{}).credentials;this.fetchOptions=r?{credentials:r}:{}}var t=e.prototype;return t.promisifyRequest=function(e,t){var n=this;return new Promise((function(r,i){n.request(e,t,(function(e,t){e?i(new W(e.message,e.code,e.name,e.statusCode)):r(t)}))}))},t.requestWithRetry=function(e,t,n){var r,i,s=this;(r=[t],i=5e3,void 0===i&&(i=Z),z((function(t){return new Promise((function(n,r){s.request(e,t,(function(e,t){e?r(e):n(t)}))}))}),r,function(e){return function(t){var n=100*Math.pow(2,t)+100*Math.random();return!(n>e)&&n}}(i))).then((function(e){return n(null,e)})).catch((function(e){return n(e)}))},t.request=function(e,t,n){var r,i,s,o={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+e,"X-Amz-User-Agent":(r=q.category?" "+q.category:"",i=q.framework?" framework/"+q.framework:"",""+q.prototype.userAgent+r+i),"Cache-Control":"no-store"},a=Object.assign({},this.fetchOptions,{headers:o,method:"POST",mode:"cors",body:JSON.stringify(t)});fetch(this.endpoint,a).then((function(e){return s=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(s.ok)return n(null,e);var t=(e.__type||e.code).split("#").pop(),r=new Error(e.message||e.Message||null);return r.name=t,r.code=t,n(r)})).catch((function(e){if(s&&s.headers&&s.headers.get("x-amzn-errortype"))try{var t=s.headers.get("x-amzn-errortype").split(":")[0],r=new Error(s.status?s.status.toString():null);return r.code=t,r.name=t,r.statusCode=s.status,n(r)}catch(t){return n(e)}else e instanceof Error&&"Network error"===e.message&&(e.code="NetworkError");return n(e)}))},e}(),Y={debug:function(){}},G=function(e){return e&&e.nonRetryable};function z(e,t,n,r){if(void 0===r&&(r=1),"function"!=typeof e)throw Error("functionToRetry must be a function");return Y.debug(e.name+" attempt #"+r+" with args: "+JSON.stringify(t)),e.apply(void 0,t).catch((function(i){if(Y.debug("error on "+e.name,i),G(i))throw Y.debug(e.name+" non retryable error",i),i;var s=n(r,t,i);if(Y.debug(e.name+" retrying in "+s+" ms"),!1!==s)return new Promise((function(e){return setTimeout(e,s)})).then((function(){return z(e,t,n,r+1)}));throw i}))}var Z=3e5,X=function(){function e(e,t){var n=e||{},r=n.UserPoolId,i=n.ClientId,s=n.endpoint,o=n.fetchOptions,a=n.AdvancedSecurityDataCollectionFlag;if(!r||!i)throw new Error("Both UserPoolId and ClientId are required.");if(r.length>55||!/^[\w-]+_[0-9a-zA-Z]+$/.test(r))throw new Error("Invalid UserPoolId format.");var u=r.split("_")[0];this.userPoolId=r,this.clientId=i,this.client=new Q(u,s,o),this.advancedSecurityDataCollectionFlag=!1!==a,this.storage=e.Storage||(new x).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,n,r,i,s){var o=this,a={ClientId:this.clientId,Username:e,Password:t,UserAttributes:n,ValidationData:r,ClientMetadata:s};this.getUserContextData(e)&&(a.UserContextData=this.getUserContextData(e)),this.client.request("SignUp",a,(function(t,n){if(t)return i(t,null);var r={Username:e,Pool:o,Storage:o.storage},s={user:new $(r),userConfirmed:n.UserConfirmed,userSub:n.UserSub,codeDeliveryDetails:n.CodeDeliveryDetails};return i(null,s)}))},t.getCurrentUser=function(){var e="CognitoIdentityServiceProvider."+this.clientId+".LastAuthUser",t=this.storage.getItem(e);if(t){var n={Username:t,Pool:this,Storage:this.storage};return new $(n)}return null},t.getUserContextData=function(e){if("undefined"!=typeof AmazonCognitoAdvancedSecurityData){var t=AmazonCognitoAdvancedSecurityData;if(this.advancedSecurityDataCollectionFlag){var n=t.getData(e,this.userPoolId,this.clientId);if(n)return{EncodedData:n}}return{}}},e}();n(808);class ee extends Error{constructor(e,t){if(Array.isArray(e)&&e.length<=2){let n=e[1];if(e.length>2)for(let t=2;t<e.length&&"string"==typeof e[t];t++)n+=e[t];super((n||"Something went wrong.").trim()),this.name=t?.name||"SKAPI",this.code=t?.code||e[0]||"ERROR",t?.cause&&(this.cause=t.cause)}else"string"==typeof e?(super((e||"Something went wrong.").trim()),this.name=t?.name||"SKAPI",this.code=t?.code||"ERROR",t?.cause&&(this.cause=t.cause)):e instanceof Error&&(super((e.message||"Something went wrong.").trim()),this.cause=e,this.name=e.name,e.hasOwnProperty("code")&&(this.code=e.code))}}class te{static hash(e){"string"!=typeof e&&(console.warn("coercing non-string value to empty string"),e="");const t=te.sb(e);let n,r,i,s,o=1732584193,a=-271733879,u=-1732584194,c=271733878;for(let e=0;e<t.length;e+=16)n=o,r=a,i=u,s=c,o=te.ff(o,a,u,c,t[e],7,-680876936),c=te.ff(c,o,a,u,t[e+1],12,-389564586),u=te.ff(u,c,o,a,t[e+2],17,606105819),a=te.ff(a,u,c,o,t[e+3],22,-1044525330),o=te.ff(o,a,u,c,t[e+4],7,-176418897),c=te.ff(c,o,a,u,t[e+5],12,1200080426),u=te.ff(u,c,o,a,t[e+6],17,-1473231341),a=te.ff(a,u,c,o,t[e+7],22,-45705983),o=te.ff(o,a,u,c,t[e+8],7,1770035416),c=te.ff(c,o,a,u,t[e+9],12,-1958414417),u=te.ff(u,c,o,a,t[e+10],17,-42063),a=te.ff(a,u,c,o,t[e+11],22,-1990404162),o=te.ff(o,a,u,c,t[e+12],7,1804603682),c=te.ff(c,o,a,u,t[e+13],12,-40341101),u=te.ff(u,c,o,a,t[e+14],17,-1502002290),a=te.ff(a,u,c,o,t[e+15],22,1236535329),o=te.gg(o,a,u,c,t[e+1],5,-165796510),c=te.gg(c,o,a,u,t[e+6],9,-1069501632),u=te.gg(u,c,o,a,t[e+11],14,643717713),a=te.gg(a,u,c,o,t[e],20,-373897302),o=te.gg(o,a,u,c,t[e+5],5,-701558691),c=te.gg(c,o,a,u,t[e+10],9,38016083),u=te.gg(u,c,o,a,t[e+15],14,-660478335),a=te.gg(a,u,c,o,t[e+4],20,-405537848),o=te.gg(o,a,u,c,t[e+9],5,568446438),c=te.gg(c,o,a,u,t[e+14],9,-1019803690),u=te.gg(u,c,o,a,t[e+3],14,-187363961),a=te.gg(a,u,c,o,t[e+8],20,1163531501),o=te.gg(o,a,u,c,t[e+13],5,-1444681467),c=te.gg(c,o,a,u,t[e+2],9,-51403784),u=te.gg(u,c,o,a,t[e+7],14,1735328473),a=te.gg(a,u,c,o,t[e+12],20,-1926607734),o=te.hh(o,a,u,c,t[e+5],4,-378558),c=te.hh(c,o,a,u,t[e+8],11,-2022574463),u=te.hh(u,c,o,a,t[e+11],16,1839030562),a=te.hh(a,u,c,o,t[e+14],23,-35309556),o=te.hh(o,a,u,c,t[e+1],4,-1530992060),c=te.hh(c,o,a,u,t[e+4],11,1272893353),u=te.hh(u,c,o,a,t[e+7],16,-155497632),a=te.hh(a,u,c,o,t[e+10],23,-1094730640),o=te.hh(o,a,u,c,t[e+13],4,681279174),c=te.hh(c,o,a,u,t[e],11,-358537222),u=te.hh(u,c,o,a,t[e+3],16,-722521979),a=te.hh(a,u,c,o,t[e+6],23,76029189),o=te.hh(o,a,u,c,t[e+9],4,-640364487),c=te.hh(c,o,a,u,t[e+12],11,-421815835),u=te.hh(u,c,o,a,t[e+15],16,530742520),a=te.hh(a,u,c,o,t[e+2],23,-995338651),o=te.ii(o,a,u,c,t[e],6,-198630844),c=te.ii(c,o,a,u,t[e+7],10,1126891415),u=te.ii(u,c,o,a,t[e+14],15,-1416354905),a=te.ii(a,u,c,o,t[e+5],21,-57434055),o=te.ii(o,a,u,c,t[e+12],6,1700485571),c=te.ii(c,o,a,u,t[e+3],10,-1894986606),u=te.ii(u,c,o,a,t[e+10],15,-1051523),a=te.ii(a,u,c,o,t[e+1],21,-2054922799),o=te.ii(o,a,u,c,t[e+8],6,1873313359),c=te.ii(c,o,a,u,t[e+15],10,-30611744),u=te.ii(u,c,o,a,t[e+6],15,-1560198380),a=te.ii(a,u,c,o,t[e+13],21,1309151649),o=te.ii(o,a,u,c,t[e+4],6,-145523070),c=te.ii(c,o,a,u,t[e+11],10,-1120210379),u=te.ii(u,c,o,a,t[e+2],15,718787259),a=te.ii(a,u,c,o,t[e+9],21,-343485551),o=te.ad(o,n),a=te.ad(a,r),u=te.ad(u,i),c=te.ad(c,s);return te.rh(o)+te.rh(a)+te.rh(u)+te.rh(c)}static rh(e){let t="";for(let n=0;n<=3;n++)t+=te.alphabet.charAt(e>>8*n+4&15)+te.alphabet.charAt(e>>8*n&15);return t}static ad(e,t){const n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}static rl(e,t){return e<<t|e>>>32-t}static cm(e,t,n,r,i,s){return te.ad(te.rl(te.ad(te.ad(t,e),te.ad(r,s)),i),n)}static ff(e,t,n,r,i,s,o){return te.cm(t&n|~t&r,e,t,i,s,o)}static gg(e,t,n,r,i,s,o){return te.cm(t&r|n&~r,e,t,i,s,o)}static hh(e,t,n,r,i,s,o){return te.cm(t^n^r,e,t,i,s,o)}static ii(e,t,n,r,i,s,o){return te.cm(n^(t|~r),e,t,i,s,o)}static sb(e){let t;const n=1+(e.length+8>>6),r=new Array(16*n);for(t=0;t<16*n;t++)r[t]=0;for(t=0;t<e.length;t++)r[t>>2]|=e.charCodeAt(t)<<t%4*8;return r[t>>2]|=128<<t%4*8,r[16*n-2]=8*e.length,r}}function ne(e){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";if(0===e)return t[0];let n="";for(;e>0;)n=t[e%62]+n,e=Math.floor(e/62);return n}function re(e){return e.split("").reverse().reduce(((e,t,n)=>e+"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(t)*62**n),0)}function ie(e=6){let t="";let n=0;for(;n<e;)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random())),n+=1;return t}function se(e,t,n){let r={},i=[];function s(e){let t;try{t=JSON.stringify(e)}catch(e){throw new ee("Invalid data type.",{code:"INVALID_REQUEST"})}return new Blob([t]).size}function o(e,r,i){if(t?.ignoreEmpty&&""===i)return;if(t?.nullIfEmpty&&""===i&&(i=null),"function"==typeof n){let e=n(r,i);void 0!==e&&(i=e)}let s=r.split("[").map((e=>{let t=e.replace("]",""),n=Number(t);return isNaN(n)||t.includes(".")?('"'===t[0]&&'"'===t[t.length-1]||"'"===t[0]&&"'"===t[t.length-1])&&(t=t.replace(/"/g,"").replace(/'/g,"")):t=n,t})),o=e;if("number"==typeof s[0])throw new ee("Form key cannot start with an array index.",{code:"INVALID_REQUEST"});for(let e=0;e<s.length;e++){let t=s[e];if(e<s.length-1){if(void 0===o[t]){let n=s[e+1];o[t]="number"==typeof n?[]:{}}o=o[t]}else void 0===o[t]?o[t]=i:Array.isArray(o[t])?o[t].push(i):o[t]=[o[t],i]}}function a(e,t,n){if(n instanceof File)e.push({name:t,file:n});else if(n instanceof FileList&&n&&n.length>0)for(let r=0;r<=n.length-1;r++){let i=n.item(r);i&&e.push({name:t,file:i})}}if(e instanceof FormData){for(let t of e.entries()){let e=t[0],n=t[1];n instanceof File||n instanceof FileList?a(i,e,n):o(r,e,n)}if(s(r)>2097152)throw new ee("Data should not exceed 2MB",{code:"INVALID_REQUEST"});return{data:r,files:i}}if(e instanceof SubmitEvent&&(e=e.target),e instanceof HTMLFormElement){let t=e.querySelectorAll("input"),n=e.querySelectorAll("select"),u=e.querySelectorAll("textarea");for(let e=0;e<n.length;e++){let t=n[e];t.name&&o(r,t.name,t.value)}for(let e=0;e<u.length;e++){let t=u[e];t.name&&o(r,t.name,t.value)}for(let e=0;e<t.length;e++){let n=t[e];n.name&&("number"===n.type?n.value&&o(r,n.name,Number(n.value)):"checkbox"===n.type||"radio"===n.type?n.checked?""===n.value&&"checkbox"===n.type||"on"===n.value||"true"===n.value?o(r,n.name,!0):"false"===n.value?o(r,n.name,!1):n.value&&o(r,n.name,n.value):"checkbox"===n.type&&(""===n.value||"on"===n.value||"true"===n.value?o(r,n.name,!1):"false"===n.value&&o(r,n.name,!0)):"file"===n.type?n.files&&n.files.length>0&&a(i,n.name,n.files):o(r,n.name,n.value))}if(s(r)>2097152)throw new ee("Data should not exceed 2MB",{code:"INVALID_REQUEST"});return{data:r,files:i}}if(s(e)>2097152)throw new ee("Data should not exceed 2MB",{code:"INVALID_REQUEST"});return{data:e,files:i}}function oe(e,t,n=[],r=null){function i(e){return e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length}function s(e){return Array.isArray(e)&&e.length}if(null===r&&!i(t))throw'Argument "struct" is required.';let o=null!==r?` in key "${r}" is invalid.`:". Parameter should be type <object>.";if(s(t)){let i="";t.forEach((e=>{["string","number","boolean","object","array"].includes(e)?i+=`Type<${e}>, `:"function"!=typeof e&&(i+=JSON.stringify(e,null,2)+", ")})),i=i?" Should be: "+i.slice(0,-2):"";let s,a=!1,u="";for(let i of t)try{s=oe(e,i,n,r),a=!0;break}catch(e){u="function"==typeof i?e?.message||e:"",a=!1}if(!a)throw u||`Invalid type "${typeof e}"${o}${i}.`;return s}if(i(e)){if(i(t))for(let i in t){let o=(null===r?"":r)+(null!==r?"["+i+"]":i);if(!e.hasOwnProperty(i)){if(n.includes(o))throw`Key "${o}" is required.`;s(t[i])&&"function"==typeof t[i][t[i].length-1]&&(e[i]=t[i][t[i].length-1]())}}if("object"===t)return e;if("function"==typeof t)return t(e);for(let i in e){let o=(null===r?"":r)+(null!==r?"["+i+"]":i);if(s(t)||t.hasOwnProperty(i))if(s(e[i])){if("array"===t[i])continue;if("function"==typeof t[i]){e[i]=t[i](e[i]);continue}for(let r=0;r<e[i].length;r++)e[i][r]=oe(e[i][r],t[i],n,o+`[${r}]`)}else e[i]=oe(e[i],t[i],n,o)}return e}if("function"==typeof t)return t(e);if("array"===t&&Array.isArray(e)||t===typeof e||e===t)return e;if(null==e||(a=e)&&"object"==typeof a&&!Array.isArray(a)&&!Object.keys(a).length)return e;var a;throw`Invalid type "${typeof e}"${o} Should be: ${["string","number","boolean","object","array"].includes(t)?`Type<${t}>`:JSON.stringify(t,null,2)}`}te.alphabet="0123456789abcdef";const ae={UserId:function(e,t="User ID"){if(!e)throw new ee(`${t} is empty.`,{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ee(`${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 ee(`${t} is invalid.`,{code:"INVALID_PARAMETER"});return e},PhoneNumber:function(e){if(e&&("string"!=typeof e||"+"!==e.charAt(0)||isNaN(Number(e.substring(1)))))throw new ee('"phone_number" is invalid. The format should be "+00123456789". Type: string.',{code:"INVALID_PARAMETER"});return e||""},Birthdate:function(e){if(e){if("string"!=typeof e)throw new ee('"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 ee('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"})}}return e||""},Password:function(e){if(!e)throw new ee('"password" is required.',{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ee('"password" should be type: string.',{code:"INVALID_PARAMETER"});if(e.length<6)throw new ee('"password" should be at least 6 characters.',{code:"INVALID_PARAMETER"});if(e.length>60)throw new ee('"password" can be up to 60 characters max.',{code:"INVALID_PARAMETER"});return e},Email:function(e,t="email"){if(!e)throw new ee(`"${t}" is required.`,{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ee(`"${t}"should be type: string.`,{code:"INVALID_PARAMETER"});if(e.length<5)throw new ee(`"${t}" should be at least 5 characters.`,{code:"INVALID_PARAMETER"});if(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(e)&&(e=e.trim()).split("@")[1].split(".").length>=2)return e.toLowerCase();throw new ee(`"${e}" is an invalid email.`,{code:"INVALID_PARAMETER"})},Url:function(e){const t=(()=>{let e=window.location.origin||null;return e&&"/"===e.slice(-1)&&(e=e.slice(0,-1)),e})();let n=e=>{if("string"==typeof e){if("*"===e)return"*";{let n,r=e.trim();if("/"===r[0]&&t){if("file:"===t.slice(0,5))throw new ee(`"${e}" is an invalid url. Relative URL does not work on local file system. Use full URL string.`,{code:"INVALID_PARAMETER"});r=t+r}else if("."===r[0]&&t){if("file:"===t.slice(0,5))throw new ee(`"${e}" is an invalid url. Relative URL does not work on local file system. Use full URL string.`,{code:"INVALID_PARAMETER"});let n=window.location.href.split("?")[0];"/"!==n.slice(-1)&&(n+="/"),r=n+r.slice(1)}try{n=new URL(r)}catch(t){throw new ee(`"${e}" is an invalid url.`,{code:"INVALID_PARAMETER"})}if(n.protocol)return n.href}}throw new ee(`"${e}" is an invalid url.`,{code:"INVALID_PARAMETER"})};return Array.isArray(e)?e.map((e=>n(e))):n(e)},specialChars:function(e,t="parameter",n=!1,r=!1){let i=e=>{if("string"!=typeof e)throw new ee(`${t} should be type: <string | string[]>.`,{code:"INVALID_PARAMETER"});if(!r&&e.includes(" "))throw new ee(`${t} should not have whitespace.`,{code:"INVALID_PARAMETER"});if(!n&&e.includes("."))throw new ee(`${t} should not have periods.`,{code:"INVALID_PARAMETER"});if(/[!@#$%&*()+\-={};':"\|,<>\/?~]/.test(e))throw new ee(`${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},Params:function(e,t,n=[]){let r=se(e).data;t.service="string",t.owner="string";let i={};for(let e in t)if(r&&"object"==typeof r&&!Array.isArray(r)&&r.hasOwnProperty(e))if("function"==typeof r[e])i[e]=r[e];else try{i[e]=JSON.parse(JSON.stringify(r[e]))}catch(t){i[e]=r[e]}try{return oe(i,t,n)}catch(e){throw new ee(e,{code:"INVALID_PARAMETER"})}}};let ue=null;function ce(e){let t={tkid:"ticket_id",cond:"condition",actn:"action",cnt:"count",ttl:"time_to_live",stmp:"timestamp",plch:"placeholder",hash:"hash",desc:"description"},n={};for(let r in e)if("tkid"===r){let t=e[r].split("#");if(1===t.length){n.ticket_id=t[0];continue}n.ticket_id=t[1],n.consume_id=t[2],n.user_id=t[3],e.stmp||(n.timestamp=re(t[2].slice(0,-4)))}else t[r]?n[t[r]]=e[r]:n[r]=e[r];return n}async function le(e){if(!e.ticket_id)throw new ee("Ticket ID is required.",{code:"INVALID_PARAMETER"});let t=e.ticket_id;return await this.__connection,ce(await Fe.bind(this)(`https://${this.service.slice(0,4)}.skapi.dev/auth/consume/${this.service}/${this.owner}/${t}`,e,{auth:!0}))}async function he(e,t){await this.__connection;let n=await Fe.bind(this)("ticket",Object.assign({exec:"list"},e||{}),{auth:!0,fetchOptions:t});return n.list=n.list.map(ce),n}async function fe(e,t){await this.__connection;let n=await Fe.bind(this)("ticket",Object.assign({exec:"consumed"},e||{}),{auth:!0,fetchOptions:t});return n.list=n.list.map(ce),n}async function de(e){return Fe.bind(this)("register-ticket",Object.assign({exec:"reg"},e),{auth:!0})}async function pe(e){return Fe.bind(this)("register-ticket",Object.assign({exec:"unreg"},e),{auth:!0})}function ge(){if(!this.userPool)throw new ee("User pool is missing",{code:"INVALID_REQUEST"});const e=()=>{let e=ue.getSignInUserSession().getIdToken().payload||null,t={};this.log("attributes to normalize:",e);for(let n in e){let r=e[n],i={auth_time:"log",sub:"user_id"};if(!["aud","cognito:username","event_id","exp","iat","iss","jti","origin_jti","secret_key","token_use"].includes(n))if(i[n])n=i[n];else if(n.includes("custom:")){if("custom:service"===n&&r!==this.service)throw new ee("The user is not registered to the service.",{code:"INVALID_REQUEST"});t[n.replace("custom:","")]=r}else if("address"===n){let e=r;if(e&&"object"==typeof e&&Object.keys(e).length){if(e?.formatted)try{t[n]=JSON.parse(e.formatted)}catch(r){t[n]=e.formatted}}else t[n]=e}else t[n]=r}for(let e of["address_public","birthdate_public","email_public","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]=t.hasOwnProperty(e)?Number(t[e]):0;for(let e of["email","phone_number"])t.hasOwnProperty(e)?t[e+"_verified"]=!0===t[e+"_verified"]:delete t[e+"_verified"];return this.__user=t,t},n=async t=>{let{refreshToken:n=!1}=t||{};return new Promise(((t,r)=>{if(ue=this.userPool.getCurrentUser(),!ue)return this.log("getSession:cognitoUser",ue),void r(null);ue.getSession(((i,s)=>{if(this.log("getSession:getSessionCallback",{err:i,session:s}),i)return ye.bind(this)(),void r(i);if(!s)return ye.bind(this)(),void r(new ee("Current session does not exist.",{code:"INVALID_REQUEST"}));let o=async n=>{let i=n.getIdToken().payload;if(this.log("getSession:respond:sessionAttribute",i),i["custom:service"]!==this.service)return this.log("getSession:respond","invalid service, signing out"),ye.bind(this)(),void r(new ee("Invalid session.",{code:"INVALID_REQUEST"}));this.session=n,e(),"function"==typeof this.onLogin&&this.onLogin(this.user),t(this.session)};n||!s.isValid()?ue.refreshSession(s.getRefreshToken(),(async(e,t)=>{this.log("getSession:refreshSessionCallback:",{err:i,refreshedSession:t}),e?(ye.bind(this)(),r(e)):t.isValid()?o(t):(ye.bind(this)(),r(new ee("Invalid session.",{code:"INVALID_REQUEST"})))})):o(s)}))}))},r=e=>{let t=e.includes(this.service+"-")?e:this.service+"-"+te.hash(e);return{cognitoUser:new $({Username:t,Pool:this.userPool}),cognitoUsername:t}};return{getSession:n,authenticateUser:(e,i)=>new Promise(((s,o)=>{this.__request_signup_confirmation=null,this.__disabledAccount=null;let a=r(e),u=a.cognitoUsername,c=new t({Username:u,Password:i});a.cognitoUser.authenticateUser(c,{newPasswordRequired:(e,t)=>{this.__disabledAccount=null,this.__request_signup_confirmation=u,"PASS"===e["custom:signup_ticket"]||"MEMBER"===e["custom:signup_ticket"]?a.cognitoUser.completeNewPasswordChallenge(i,{},{onSuccess:e=>{ue=a.cognitoUser,n().then((e=>s(this.user)))},onFailure:e=>{o(new ee(e.message||"Failed to authenticate user.",{code:e.code}))}}):o(new ee("User's signup confirmation is required.",{code:"SIGNUP_CONFIRMATION_NEEDED"}))},onSuccess:e=>n().then((e=>{this.__disabledAccount=null,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=u,t=["This account is disabled.","USER_IS_DISABLED"]):t=["Incorrect username or password.","INCORRECT_USERNAME_OR_PASSWORD"]:"UserNotFoundException"===e.code?t=["Incorrect username or password.","INCORRECT_USERNAME_OR_PASSWORD"]:"UserNotConfirmedException"===e.code?(this.__request_signup_confirmation=u,t=["User's signup confirmation is required.","SIGNUP_CONFIRMATION_NEEDED"]):"TooManyRequestsException"!==e.code&&"LimitExceededException"!==e.code||(t=["Too many attempts. Please try again later.","REQUEST_EXCEED"]);let n=t[1],r=t[0],i=t[0].split("#");if(i.length>1&&(i=i[i.length-1].split(":"),n=i[0],r=i[1],"CONFIRM_REQUIRED"===n))return this.__request_signup_confirmation=u,void o(new ee("User's signup confirmation is required.",{code:"SIGNUP_CONFIRMATION_NEEDED"}));o(new ee(r,{code:n,cause:e}))}})})),createCognitoUser:r,signup:(e,t,n)=>new Promise(((r,i)=>{this.userPool.signUp(e,t,n,null,((e,t)=>{e?i(e):r(t)}))}))}}async function _e(e){await this.__authConnection;try{return await ge.bind(this)().getSession(e),this.user}catch(e){return null}}async function me(){return await this.__connection,this.__user?.service===this.service?this.__user?.owner===this.host:(await we.bind(this)(),!1)}function ye(){ue&&ue.signOut();let e={session:null,__startKeyHistory:{},__cached_requests:{},__user:null};for(let t in e)this[t]=e[t];"function"==typeof this.onLogin&&this.onLogin(null)}async function we(){return await this.__connection,ye.bind(this)(),"SUCCESS: The user has been logged out."}async function be(e){if(!this.__request_signup_confirmation)throw new ee("Least one login attempt is required.",{code:"INVALID_REQUEST"});return e=e?ae.Url(e):void 0,await Fe.bind(this)("confirm-signup",{username:this.__request_signup_confirmation,redirect:e})}async function Ae(e=!1){if("string"==typeof e)e=ae.Url(e);else if("boolean"!=typeof e)throw new ee("Argument should be type: <boolean | string>.",{code:"INVALID_REQUEST"});if(!this.__disabledAccount)throw new ee("Least one signin attempt of disabled account is required.",{code:"INVALID_REQUEST"});return await Fe.bind(this)("recover-account",{username:this.__disabledAccount,redirect:e}),"SUCCESS: Recovery e-mail has been sent."}async function ve(e){ae.Params(e,{idToken:"string",clientId:"string",keyUrl:e=>ae.Url(e),provider:"string",nonce:"string"},["idToken","keyUrl","clientId"]);let{hashedPassword:t,username:n,email:r}=await Fe.bind(this)("jwt-login",e);try{return Ee.bind(this)({username:n,password:t,email:r})}catch(e){if("INCORRECT_USERNAME_OR_PASSWORD"===e?.code)throw new ee("User has migrated the account. Login with the service email and password.",{code:"INVALID_REQUEST"})}}async function Ee(e){let t=ae.Params(e,{username:"string",email:"string",password:"string"},["password"]);if(t.email)try{ae.Email(t.email)}catch(e){t.username=t.email,delete t.email}if(!t.username&&!t.email)throw new ee('Least one of "username" or "email" is required.',{code:"INVALID_PARAMETER"});return ge.bind(this)().authenticateUser(t.username||t.email,t.password)}async function Se(e,t){let n={username:"string",password:e=>ae.Password(e),email:e=>ae.Email(e),name:"string",address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):void 0:"",gender:"string",birthdate:e=>ae.Birthdate(e),phone_number:e=>ae.PhoneNumber(e),email_public:["boolean",()=>!1],address_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1],access_group:"number",misc:"string",picture:e=>e?ae.Url(e):void 0,profile:e=>e?ae.Url(e):void 0,family_name:"string",given_name:"string",middle_name:"string",nickname:"string",website:e=>e?ae.Url(e):void 0},r=ae.Params(e||{},n,["email","password"]);await we.bind(this)(),t=ae.Params(t||{},{email_subscription:e=>{if("boolean"!=typeof e)throw new ee('"option.email_subscription" should be type: <boolean>.',{code:"INVALID_PARAMETER"});if(!t?.signup_confirmation)throw new ee('"option.signup_confirmation" is required for email subscription.',{code:"INVALID_PARAMETER"});return e},signup_confirmation:e=>{let t=e;if("string"==typeof e)t=ae.Url(e);else{if("boolean"!=typeof e)throw new ee('"option.signup_confirmation" should be type: <string | boolean>.',{code:"INVALID_PARAMETER"});t=e}if(t&&!r.email)throw new ee('"email" is required for signup confirmation.',{code:"INVALID_PARAMETER"});return t},login:e=>{if("boolean"==typeof e){if(t.signup_confirmation&&e)throw new ee('"login" is not allowed when "option.signup_confirmation" is true.',{code:"INVALID_PARAMETER"});return e}throw new ee('"option.login" should be type: boolean.',{code:"INVALID_PARAMETER"})}});let i=t?.login||!1;if(r.signup_confirmation=t?.signup_confirmation||!1,r.email_subscription=t?.email_subscription||!1,r.email_public&&!r.signup_confirmation)throw new ee('"option.signup_confirmation" should be true if "email_public" is set to true.',{code:"INVALID_PARAMETER"});r.service=this.service,r.owner=this.owner;let s=ge.bind(this)().createCognitoUser(r.username||r.email);for(let e of["email_public","address_public","gender_public","birthdate_public","phone_number_public"])r[e]=r[e]?"1":"0";r.access_group&&(r.access_group=r.access_group.toString());let o=(await Fe.bind(this)("signupkey",{username:s.cognitoUsername,signup_confirmation:"boolean"==typeof r.signup_confirmation?JSON.stringify(r.signup_confirmation):r.signup_confirmation,email_subscription:r.email_subscription})).split(":"),a=o.slice(1).join(":"),u=[new M({Name:"custom:signup",Value:o[0]}),new M({Name:"locale",Value:a.split("#")[1]}),new M({Name:"custom:signup_ticket",Value:a})];for(let e in n){let t=["email_public","address_public","gender_public","birthdate_public","phone_number_public","misc","service","owner"];""!==r[e]&&"username"!==e&&"password"!==e&&"access_group"!==e&&(t.includes(e)?u.push(new M({Name:"custom:"+e,Value:r[e]})):u.push(new M({Name:e,Value:r[e]})))}return await ge.bind(this)().signup(s.cognitoUsername,r.password,u),r.signup_confirmation?(ue=s.cognitoUser,this.__request_signup_confirmation=s.cognitoUsername,"SUCCESS: The account has been created. User's signup confirmation is required."):i?Ee.bind(this)({email:r.username||r.email,password:r.password}):"SUCCESS: The account has been created."}async function Ie(){await this.__connection;let e=await Fe.bind(this)("remove-account",{disable:this.__user.user_id},{auth:!0});return await we.bind(this)(),e}async function Te(e){await this.__connection;let t=ae.Params(e,{email:e=>ae.Email(e),code:["number","string"],new_password:e=>ae.Password(e)},["email","code","new_password"]),n=t.code,r=t.new_password;return"number"==typeof n&&(n=n.toString()),new Promise((async(e,i)=>{ge.bind(this)().createCognitoUser(t.email).cognitoUser.confirmPassword(n,r,{onSuccess:t=>{e("SUCCESS: New password has been set.")},onFailure:e=>{i(new ee(e?.message||"Failed to reset password.",{code:e?.code}))}})}))}async function Re(e,t){let n;if(await this.__connection,!ue)throw new ee("The user has to be logged in.",{code:"INVALID_REQUEST"});if("email"===e||"phone_number"===e){if(!this.__user.hasOwnProperty(e))throw new ee(`No ${"email"===e?"e-mail":"phone number"} to verify`,{code:"INVALID_REQUEST"});return this.__user?.[`${e}_verified`]?`SUCCESS: "${e}" is verified.`:(n=(t?ae.Params(t,{code:["string"]}):{}).code||"",new Promise(((t,r)=>{let i={onSuccess:i=>{n?ge.bind(this)().getSession({refreshToken:!0}).then((()=>{this.__user&&(this.__user[e+"_verified"]=!0),t(`SUCCESS: "${e}" is verified.`)})).catch((e=>{r(e)})):t("SUCCESS: Verification code has been sent.")},onFailure:e=>{r(new ee(e.message||"Failed to request verification code.",{code:e?.code}))}};n?ue?.verifyAttribute(e,n,i):(i.inputVerificationCode=null,ue?.getAttributeVerificationCode(e,i))})))}}function Ue(e){return Re.bind(this)("phone_number",e)}function De(e){return Re.bind(this)("email",e)}async function Ce(e){await this.__connection;let t=ae.Params(e,{email:e=>ae.Email(e)},["email"]);return new Promise((async(e,n)=>{ge.bind(this)().createCognitoUser(t.email).cognitoUser.forgotPassword({onSuccess:t=>{e("SUCCESS: Verification code has been sent.")},onFailure:e=>{n(new ee(e?.message||"Failed to send verification code.",{code:e?.code||"ERROR"}))}})}))}async function Pe(e){if(await this.__connection,!this.session)throw new ee("User login is required.",{code:"INVALID_REQUEST"});let t=ae.Params(e,{current_password:"string",new_password:"string"});if(!t?.current_password)throw new ee('"current_password" is required to change password.',{code:"INVALID_PARAMETER"});if(!t?.new_password)throw new ee('"new_password" is required to change password.',{code:"INVALID_PARAMETER"});return ae.Password(t.current_password),ae.Password(t.new_password),new Promise(((e,n)=>{ue.changePassword(t.current_password,t.new_password,((t,r)=>{t&&n("InvalidParameterException"===t?.code?new ee("Invalid password parameter.",{code:"INVALID_PARAMETER"}):"NotAuthorizedException"===t?.code?new ee("Incorrect password.",{code:"INVALID_REQUEST"}):"TooManyRequestsException"===t?.code||"LimitExceededException"===t?.code?new ee("Too many attempts. Please try again later.",{code:"REQUEST_EXCEED"}):new ee(t?.message||"Failed to change user password.",{code:t?.code||t?.name})),e("SUCCESS: Password has been changed.")}))}))}async function Ne(e){if(await this.__connection,!this.session)throw new ee("User login is required.",{code:"INVALID_REQUEST"});let t=ae.Params(e||{},{email:e=>ae.Email(e),address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):void 0:"",name:"string",gender:"string",birthdate:e=>ae.Birthdate(e),phone_number:e=>ae.PhoneNumber(e),email_public:"boolean",phone_number_public:"boolean",address_public:"boolean",gender_public:"boolean",birthdate_public:"boolean",misc:"string",picture:e=>ae.Url(e),profile:e=>ae.Url(e),family_name:"string",given_name:"string",middle_name:"string",nickname:"string",website:e=>ae.Url(e)});if(t&&"object"==typeof t&&!Object.keys(t).length)return this.user;t.email&&(t.preferred_username=this.service+"-"+te.hash(t.email));let n=[["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(t[e[0]]&&!this.__user[e[1]])throw new ee(`${e[2]} "${e[0]}" to true.`,{code:"INVALID_REQUEST"});let r=[];for(let e in t)if(t[e]!==this.user[e]){if(["email_public","phone_number_public","address_public","gender_public","birthdate_public","misc"].includes(e)){let n=t[e];"boolean"==typeof n&&(n=n?"1":"0"),t["custom:"+e]=n,r.push(e)}}else r.push(e);for(let e of r)delete t[e];if(t&&"object"==typeof t&&Object.keys(t).length){let e=[];for(let n in t)e.push(new M({Name:n,Value:t[n]}));return await new Promise(((t,n)=>{ue?.updateAttributes(e,((e,r)=>{e&&n([e?.code||e?.name,e?.message||"Failed to update user settings."]),t(r)}))})),await ge.bind(this)().getSession({refreshToken:!0}),this.user}return this.user}async function ke(e,t){e||(e={searchFor:"timestamp",condition:">",value:0},t||(t={}),t.ascending=!1),await this.__connection;const n={user_id:e=>ae.UserId(e),email:e=>ae.Email(e),phone_number:e=>ae.PhoneNumber(e),locale:e=>{if("string"!=typeof e||"string"==typeof e&&e.length>5)throw new ee('Value of "locale" should be a country code.',{code:"INVALID_PARAMETER"});return e},name:"string",address:"string",gender:"string",birthdate:e=>ae.Birthdate(e),subscribers:"number",timestamp:"number",access_group:"number",approved:e=>e?"by_admin:approved":"by_admin:suspended"};if(e=ae.Params(e,{searchFor:["user_id","name","email","phone_number","address","gender","birthdate","locale","subscribers","timestamp","access_group","approved"],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 ee(`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 ee(`Range does not match the type of "${e.searchFor}" index.`,{code:"INVALID_PARAMETER"});return t}},["searchFor","value"]),e?.condition&&"="!==e?.condition&&e.hasOwnProperty("range"))throw new ee("Conditions does not apply on range search.",{code:"INVALID_PARAMETER"});if(["user_id","phone_number","email"].includes(e.searchFor)&&("="!==e.condition||e.range))throw new ee(`Conditions are not allowed on "${e.searchFor}"`,{code:"INVALID_PARAMETER"});if("string"==typeof e?.value&&!e?.value)throw new ee("Value should not be an empty string.",{code:"INVALID_PARAMETER"});if("string"==typeof e?.searchFor&&!e?.searchFor)throw new ee('"searchFor" should not be an empty string.',{code:"INVALID_PARAMETER"});return Fe.bind(this)("get-users",e,{auth:!0,fetchOptions:t})}async function Oe(e){await this.__connection;let t=await Fe.bind(this)("last-verified-email",e,{auth:!0});return t.includes("SUCCESS")?(await ge.bind(this)().getSession({refreshToken:!0}),this.user):t}async function Le(e){return await this.__connection,e=ae.Params(e,{username:ae.Email,redirect:ae.Url},["username"]),await Fe.bind(this)("request-username-change",e,{auth:!0})}async function Me(e,t){const n=await Promise.all([this.admin_endpoint,this.record_endpoint]),r=n[0],i=n[1];let s=e.split("?"),o=s.length>1?"?"+s[1]:"";switch(e=s[0]){case"get-newsletters":case"get-public-newsletters":case"get-users":case"post-userdata":case"remove-account":case"post-secure":case"subscribe-newsletter":case"subscribe-public-newsletter":case"admin-signup":case"confirm-signup":case"recover-account":case"mock":case"service":case"grant-access":case"last-verified-email":case"ticket":case"register-ticket":case"get-newsletter-subscription":case"request-username-change":case"jwt-login":case"client-secret-request":case"signupkey":case"send-inquiry":case"client-secret-request-public":case"block-account":case"grant-access":return(t?r.admin_private:r.admin_public)+e+o;case"post-record":case"get-records":case"subscription":case"get-subscription":case"del-records":case"get-table":case"get-tag":case"get-index":case"get-signed-url":case"grant-private-access":case"request-private-access-key":case"get-ws-group":case"del-files":case"check-schema":return(t?i.record_private:i.record_public)+e+o;default:return ae.Url(e)}}const Ve={};async function Fe(e,t=null,n,r){this.log("request:",{url:e,data:t,options:n,_etc:r||{}}),n=n||{};let{auth:i=!1,method:s="post",bypassAwaitConnection:o=!1}=n;s=s.toUpperCase();let a=null,u=this.service,c=this.owner,l=null,h=await Me.bind(this)(e,!!i);if(!o&&(a=await this.__connection,!a))throw new ee("Invalid connection. The service could have been disabled, or has a restricted CORS.",{code:"INVALID_REQUEST"});if(i){if(!this.session)throw this.log("request:No session",null),new ee("User login is required.",{code:"INVALID_REQUEST"});{this.log("request:session",this.session);let e=Math.floor(Date.now()/1e3);if(this.log("request:tokens:",{exp:this.session.idToken.payload.exp,currTime:e,expiresIn:this.session.idToken.payload.exp-e,token:this.session.accessToken.jwtToken,refreshToken:this.session.refreshToken.token}),this.session.idToken.payload.exp<e){this.log("request:New token",null);try{await ge.bind(this)().getSession({refreshToken:!0})}catch(e){throw this.log("request:New token error",e),new ee("User login is required.",{code:"INVALID_REQUEST"})}}l=this.session?.idToken?.jwtToken,this.log("request:token to use",l)}}let f={},{fetchMore:d=!1,progress:p}=n?.fetchOptions||{};if(n?.fetchOptions&&Object.keys(n.fetchOptions).length){for(let e of["limit","startKey","ascending"])n.fetchOptions.hasOwnProperty(e)&&(f[e]=n.fetchOptions[e]);f=ae.Params(f,{limit:e=>{if("number"!=typeof e)throw new ee("Fetch limit should be a number.",{code:"INVALID_REQUEST"});if(e>1e3)throw new ee("Fetch limit should be below 1000.",{code:"INVALID_REQUEST"});return e},startKey:e=>e,ascending:"boolean"})}let g=r?.ignoreService?{}:{service:u,owner:c};Object.assign(g,f),(t=se(t).data)?t&&"object"==typeof t&&(t=Object.assign(g,t)):t=g;let _=(()=>{if(t&&"object"==typeof t&&Object.keys(t).length&&!(t instanceof FormData)){function n(e){return"object"==typeof e&&null!==e?Object.keys(e).sort().reduce(((t,r)=>("object"==typeof e[r]&&null!==e[r]?t[r]=n(e[r]):t[r]=e[r],t)),{}):e}return te.hash(e+"/"+JSON.stringify(n(t)))}return te.hash(e+"/"+this.service)})(),m=xe.bind(this)({params:t,url:e,fetchMore:d,hashedParams:_});if(!m||m&&"object"==typeof m)return m;if("string"==typeof m&&Ve[m]instanceof Promise)return Ve[m];let y={Accept:"*/*","Content-Type":n.hasOwnProperty("contentType")?null===n.contentType?"application/x-www-form-urlencoded":n.contentType||"application/json":"application/json"};l&&(y.Authorization=l),"application/json"!==y["Content-Type"]&&(y["Content-Meta"]=JSON.stringify({service:u,owner:c}));let w={headers:y};if(n?.responseType&&(w.responseType=n.responseType),"GET"===s){if(t){let e=[];if(t instanceof FormData)for(let[n,r]of t.entries())"string"==typeof r&&(r=encodeURIComponent(r),e.push(`&${n}=${r}`));else e=Object.keys(t).map((e=>{let n=t[e];return"string"!=typeof n&&(n=JSON.stringify(n)),encodeURIComponent(e)+"="+encodeURIComponent(n)}));e.length&&("?"!==h.substring(h.length-1)&&(h+="?"),h+=e.join("&"))}w.body=null}else w.body=t?JSON.stringify(t):null;w.method=s;let b=Be.bind(this)(h,w,p);Ve[m]=b;try{let t=$e.bind(this)({hashedParam:m,url:e,fetched:await b});return m&&Ve.hasOwnProperty(m)&&delete Ve[m],this.log("request:end",t),t}catch(e){throw m&&Ve.hasOwnProperty(m)&&delete Ve[m],this.log("request:err",e),e}}function xe(e){let{params:t={},url:n,fetchMore:r=!1,hashedParams:i}=e||{};if(t.startKey){if(("object"!=typeof t.startKey||!Object.keys(t.startKey).length)&&"start"!==t.startKey&&"end"!==t.startKey)throw new ee(`"${t.startKey}" is invalid startKey key.`,{code:"INVALID_PARAMETER"});"start"===t.startKey&&(r=!1,delete t.startKey)}if(!r&&this.__startKeyHistory?.[n]?.[i]){if(this.__cached_requests?.[n]?.[i]&&delete this.__cached_requests[n][i],Array.isArray(this.__startKeyHistory[n][i])&&this.__startKeyHistory[n][i].length)for(let e of this.__startKeyHistory[n][i]){let t=i+te.hash(e);this.__cached_requests?.[n]&&this.__cached_requests?.[n]?.[t]&&delete this.__cached_requests[n][t]}return delete this.__startKeyHistory[n][i],i}if(!Array.isArray(this.__startKeyHistory?.[n]?.[i]))return i;let s=this.__startKeyHistory[n][i],o=s[s.length-1],a=i;if(o){if("end"===o)return{list:[],startKey:"end",endOfList:!0,startKeyHistory:s};a+=te.hash(o),t.startKey=JSON.parse(o)}return this.__cached_requests?.[n]?.[a]?this.__cached_requests[n][a]:i}function Be(e,t,n){return new Promise(((r,i)=>{let s=new XMLHttpRequest;for(var o in s.open(t.method||"GET",e),t.headers||{})s.setRequestHeader(o,t.headers[o]);t.responseType&&(s.responseType=t.responseType),s.onload=()=>{if(s.status<400)if("json"==t.responseType||"blob"==t.responseType)r(s.response);else{let e=s.responseText;try{e=JSON.parse(e)}catch(e){}r(e)}else if(429===s.status){let o=s.getResponseHeader("Retry-After");o?setTimeout((()=>{Be(e,t,n).then(r,i)}),1e3*parseInt(o)):i("Too many requests")}else{let e=s.status,t=["INVALID_CORS","INVALID_REQUEST","SERVICE_DISABLED","INVALID_PARAMETER","ERROR","EXISTS","NOT_EXISTS"],n=s.responseText;try{n=JSON.parse(n)}catch(e){}if("string"==typeof n){let e=s.response.split(":"),n=e.splice(0,1)[0].trim();i(new ee(e.join(":").trim(),{code:t.includes(n)?n:"ERROR"}))}else if("object"==typeof n&&n?.message){let t=n?.code||(e?e.toString():null)||"ERROR",r=n.message;"string"==typeof r&&(r=r.trim()),i(new ee(r,{code:t}))}else i(n)}},s.onerror=()=>i("Network error"),s.onabort=()=>i("Aborted"),s.ontimeout=()=>i("Timeout"),"function"==typeof n&&(s.onprogress=e=>{n({status:"download",progress:e.loaded/e.total*100,loaded:e.loaded,total:e.total,abort:()=>s.abort()})},s.upload&&(s.upload.onprogress=e=>{n({status:"upload",progress:e.loaded/e.total*100,loaded:e.loaded,total:e.total,abort:()=>s.abort()})})),s.send(t.body)}))}function $e(e){let{hashedParam:t,url:n,fetched:r}=e;if(!r?.startKey)return r;this.__startKeyHistory.hasOwnProperty(n)||(this.__startKeyHistory[n]={}),this.__cached_requests?.[n]||(this.__cached_requests[n]={}),this.__cached_requests[n][t]=r,this.__startKeyHistory[n].hasOwnProperty(t)||(this.__startKeyHistory[n][t]=[]);let i="end"===r.startKey?"end":JSON.stringify(r.startKey);return this.__startKeyHistory[n][t].includes(i)||this.__startKeyHistory[n][t].push(i),Object.assign({startKeyHistory:this.__startKeyHistory[n][t]},r)}async function qe(e,t){await this.__connection;let{record_id:n,service:r=this.service,progress:i}=t;if(!n)throw new ee('"record_id" is required.',{code:"INVALID_PARAMETER"});if(e instanceof SubmitEvent&&(e=e.target),e instanceof HTMLFormElement&&(e=new FormData(e)),!(e instanceof FormData))throw new ee('"fileList" should be a FormData or HTMLFormElement.',{code:"INVALID_PARAMETER"});let s,o={reserved_key:ie(),service:r,request:"post"};t?.record_id&&(o.id=t.record_id);let a=(e,t,n)=>new Promise(((r,i)=>{s=new XMLHttpRequest,s.open("POST",e),s.onload=()=>{let o=s.responseText;try{o=JSON.parse(o)}catch(e){}if(s.status>=200&&s.status<300)r(o);else if(429===s.status){let o=s.getResponseHeader("Retry-After");o?setTimeout((()=>{a(e,t,n).then(r,i)}),1e3*parseInt(o)):i("Too many requests")}else i(o)},s.onerror=()=>i("Network error"),s.onabort=()=>i("Aborted"),s.ontimeout=()=>i("Timeout"),s.upload&&"function"==typeof n&&(s.upload.onprogress=n),s.send(t)})),u=[],c=[];function l(e){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";if(0===e)return t[0];let n="";for(;e>0;)n=t[e%62]+n,e=Math.floor(e/62);return n}let h=[];for(let[t,n]of e.entries()){if(!(n instanceof File))continue;let e=Object.assign({key:t+"/"+n.name,sizeKey:l(n.size),contentType:n.type||null},o),{fields:r=null,url:f,cdn:d}=await Fe.bind(this)("get-signed-url",e,{auth:!0});h.push(d);let p=new FormData;for(let e in r)p.append(e,r[e]);p.append("file",n);try{await a(f,p,"function"==typeof i?e=>i({status:"upload",progress:e.loaded/e.total*100,currentFile:n,completed:u,failed:c,loaded:e.loaded,total:e.total,abort:()=>s.abort()}):null),u.push(n)}catch(e){c.push(n)}}return{completed:u,failed:c,bin_endpoints:h}}const je={};function Ke(e){let{preventMultipleCalls:t=!1}=e||{};return function(e,n,r){const i=r.value;r.value=function(...e){let r=e[0],s=!0,o=null,a="",u={},c=!1;if(r instanceof SubmitEvent){r.preventDefault();let e=window.location.href;o=r.target;let t=new URL(o.action);a=t.href;let n=a?a.match(/(?<=\{).*?(?=\})/g):"";if(n)for(let e of n){if(!e)continue;let t=o.querySelector(`[name="${e}"]`);if(t)if("file"===t.type)for(let n=0;n<=t.files.length-1;n++)t.files[n]&&(u[e]||(u[e]=[]),u[e].push(new Promise(((e,r)=>{let i=new FileReader;i.onload=function(){e(i.result)},i.readAsDataURL(t.files[n]),i.onerror=r}))));else a=a.replace(`{${e}}`,t.value)}null===o.getAttribute("action")?s=!1:c=t.href===e}const l=async e=>{if(a)for(let e in u)u[e].length&&(a=a.replace(`{${e}}`,(await Promise.all(u[e])).join(",")));return o&&s&&(window.sessionStorage.setItem(`${this.service}:${te.hash(a)}`,JSON.stringify(e)),c?window.location.replace(a):window.location.href=a),e};let h;const f=async()=>{try{if(h=i.bind(this)(...e),h instanceof Promise){let e=await h;return await l(e),h}}catch(e){throw(e=>{throw e instanceof ee?e.name=n+"()":e=e instanceof Error?e:new ee(e,{name:n+"()"}),e})(e)}};return t?(je?.[n]||(je[n]=f().finally((()=>{delete je[n]}))),je[n]):f()}}}async function He(){await this.__connection;let e=`${this.service}:${te.hash(window.location.href.split("?")[0])}`,t=window.sessionStorage.getItem(e);if(null!==t){try{t=JSON.parse(t)}catch(e){}return t}return null}const Je=4503599627370496;async function We(e){const t={user_id:"",record_id:"",updated:0,uploaded:0,table:{name:"",access_group:0},reference:{reference_limit:null,allow_multiple_reference:!0,referenced_count:0},ip:"",bin:{}},n={ip:e=>{"R"===e.slice(-1)?(t.readonly=!0,e=e.slice(0,-1)):t.readonly=!1,t.ip=e},rec:e=>{if(!e)return;t.record_id=e;let n=re(e.substring(0,e.length-9));t.uploaded=n},usr:e=>{t.user_id=e},tbl:e=>{if(e&&!t.table.name){let n=e.split("/");t.table.name=n[0];let r="**"==n[2]?"private":parseInt(n[2]);r=0==r?"public":1==r?"authorized":r,t.table.access_group=r,t.table.subscription=!!n?.[3]}},usr_tbl:e=>{let n=e.split("/");if(t.user_id||(t.user_id=n[0]),!t.table.name){t.table.name=n[1];let e="**"==n[3]?"private":parseInt(n[3]);e=0==e?"public":1==e?"authorized":e,t.table.access_group=e,t.table.subscription=!!n?.[4]}},idx:e=>{if(!e)return;let n=e.split("!"),r=n.splice(0,1)[0],i=function(e){let t=e.substring(3);switch(e.substring(0,3)){case"!S%":return t;case"!N%":let n=t.split("."),r=Number(n[0])-4503599627370496;return 1===n.length?r:parseFloat(r.toString()+"."+n[1]);case"!B%":return"1"===t;case"!L%":case"!D%":try{return JSON.parse(t)}catch(e){throw new ee("Value parse error.",{code:"PARSE_ERROR"})}default:return e}}("!"+n.join("!"));t.index={name:r,value:i}},ref:e=>{e&&(t.reference.record_id=e.split("/")[0])},tags:e=>{t.tags=e},upd:e=>{t.updated=e},acpt_mrf:e=>{t.reference.allow_multiple_reference=e},ref_limt:e=>{t.reference.reference_limit=e},rfd:e=>{t.reference.referenced_count=e},bin:async e=>{let n={};if(Array.isArray(e))for(let t of e){let e=t.split("/").slice(3).join("/"),r=e.split("/"),i=decodeURIComponent(r.slice(-1)[0]),s=decodeURIComponent(r[10]),o=r[9],a=r[8],u="**"==r[6]?"private":parseInt(r[6]);u=0==u?"public":1==u?"authorized":u;let c=t;"public"!==u&&(c="private"===u&&this.__user?.user_id!==r[3]?t:await Ye.bind(this)(t,{dataType:"endpoint"}));let l={access_group:u,filename:i,url:c,path:e,size:re(o),uploaded:re(a),getFile:(e,n)=>{let r={dataType:e||"download",progress:n};return Ye.bind(this)(t,r)}};n[s]?n[s].push(l):n[s]=[l]}t.bin=n},data:e=>{let n=e;"!D%{}"===e?n={}:"!L%[]"===e&&(n=[]),t.data=n}};if(e.record_id)return e;for(let t in n)if(e.hasOwnProperty(t)){let r=n[t](e[t]);r instanceof Promise&&await r}return e.private_key&&(this.__private_access_key[t.record_id]=e.private_key),t}async function Qe(e){let{endpoints:t}=e;if("string"==typeof t&&(t=[t]),!Array.isArray(t))throw new ee('"endpoints" should be type: array | string.',{code:"INVALID_PARAMETER"});let n=await Fe.bind(this)("del-files",{endpoints:t,storage:"records"},{auth:!0,method:"post"});for(let e in n)n[e]=We.bind(this)(n[e]);return await Promise.all(n)}async function Ye(e,t){if("string"!=typeof e)throw new ee('"url" should be type: string.',{code:"INVALID_PARAMETER"});ae.Url(e);let n=!1,r=e.split("/"),i=r[2].split("."),s=null;3===i.length&&"skapi"===i[1]&&(s=i[0],n=!0);let o=r.slice(3),a=!1;if(!n&&("auth"===o[0]||"publ"===o[0]))try{ae.UserId(o[2]),ae.UserId(o[3]),a="auth"==o[0],n=!0}catch{throw new ee("Invalid file url.",{code:"INVALID_PARAMETER"})}let u=s?null:o[1];t=ae.Params(t,{expires:["number",()=>0],dataType:["base64","blob","endpoint","text",()=>"download"],progress:"function"});let c=e.split("/").slice(-1)[0],l=t.expires;if(l){if(!n)throw new ee("Expires option can only be used on skapi cdn endpoints.",{code:"INVALID_PARAMETER"});if(l<0)throw new ee('"config.expires" should be > 0. (seconds)',{code:"INVALID_PARAMETER"});let t={request:s?"get-host":"get",id:s||o[5],key:e,expires:l};u&&(t.service=u),e=(await Fe.bind(this)("get-signed-url",t,{auth:!0})).url}else if(a){let t=this.session?.idToken?.jwtToken,n="**"===o[6]?"**":parseInt(o[6]);if(!t)throw new ee("User login is required.",{code:"INVALID_REQUEST"});{let e=Math.floor(Date.now()/1e3);if(this.session.idToken.payload.exp<e){this.log("request:New token",null);try{await ge.bind(this)().getSession()}catch(e){throw this.log("request:New token error",e),new ee("User login is required.",{code:"INVALID_REQUEST"})}}t=this.session?.idToken?.jwtToken}if("**"===n){if(this.__user.user_id!==o[3])throw new ee("User has no access.",{code:"INVALID_REQUEST"})}else if(this.__user.access_group<n)throw new ee("User has no access.",{code:"INVALID_REQUEST"});e+=`?t=${t}`}if("endpoint"===t?.dataType)return e;if("download"===t?.dataType){let t=document.createElement("a");return t.href=e,document.body.appendChild(t),t.setAttribute("download",c),t.target="_blank",t.click(),document.body.removeChild(t),null}return new Promise((async(n,r)=>{try{let r=await Fe.bind(this)(e,null,{method:"get",contentType:null,responseType:"text"===t?.dataType?"text":"blob",fetchOptions:{progress:t?.progress}},{ignoreService:!0});if("base64"===t?.dataType){const e=new FileReader;e.onloadend=()=>n(e.result),e.readAsDataURL(r)}else n(r)}catch(e){r(e)}}))}async function Ge(e,t){await this.__connection,"string"==typeof e?.table&&(e.table={name:e.table,access_group:0});let n="",r="";if(e?.record_id){ae.specialChars(e.record_id,"record_id",!1,!1);let t={record_id:e.record_id};e?.service&&(t.service=e.service),e=t,this.__private_access_key[e.record_id]&&(e.private_key=this.__private_access_key[e.record_id])}else{const t={table:{name:[e=>{if(!e)throw new ee('"table.name" cannot be empty string.',{code:"INVALID_PARAMETER"});return ae.specialChars(e,"table name",!0,!0)}],access_group:[t=>{if(void 0===t)return!this.__user&&e.table.hasOwnProperty("subscription")?1:0;if("number"==typeof t){if((this.__user?.access_group||0)<t)throw new ee("User has no access",{code:"INVALID_REQUEST"})}else{if("string"!=typeof t)throw new ee('"table.access_group" should be type: <number | string>.',{code:"INVALID_PARAMETER"});if("private"===(t={private:"private",public:0,authorized:1}[t])&&!this.__user)throw new ee("Unsigned users have no access to private records.",{code:"INVALID_REQUEST"});if(void 0===t)throw new ee('"table.access_group" is invalid.',{code:"INVALID_PARAMETER"})}return t}],subscription:e=>{if(null==e)return e;if(ae.UserId(e,'User ID in "subscription"'),!this.__user)throw new ee("Unsigned users have no access to subscription records.",{code:"INVALID_REQUEST"});return{user_id:e,group:1}}},reference:t=>{if(null==t)return t;if("string"==typeof t){try{r=ae.UserId(t)}catch(r){ae.specialChars(t,"reference",!1,!1),n=t,this.__private_access_key[n]&&(e.private_key=this.__private_access_key[n])}return n=t,t}throw new ee('"reference" should be type: string.',{code:"INVALID_PARAMETER"})},index:{name:["$updated","$uploaded","$referenced_count","$user_id",e=>{if(void 0===e)throw new ee('"index.name" is required.',{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ee('"index.name" should be type: string.',{code:"INVALID_PARAMETER"});return ae.specialChars(e,"index.name",!0,!1)}],value:t=>{const n={$updated:"number",$uploaded:"number",$referenced_count:"number",$user_id:ae.UserId};if(n.hasOwnProperty(e.index.name)){let r=n[e.index.name];if("function"==typeof r)return r(t);if(r!==typeof t)throw new ee(`"index.value" should be type: ${r}.`,{code:"INVALID_PARAMETER"});return t}if("number"==typeof t){if(t>Je||t<-4503599627370496)throw new ee("Number value should be within range -4503599627370496 ~ +4503599627370496",{code:"INVALID_PARAMETER"});return t}if("boolean"==typeof t)return t;if("string"==typeof t)return t;throw new ee('"index.value" should be type: <number | boolean | string>.',{code:"INVALID_PARAMETER"})},condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"],range:t=>{if(!e.index||!("value"in e.index))throw new ee('"index.value" is required.',{code:"INVALID_PARAMETER"});if("$record_id"===e.index.name)throw new ee(`Cannot do "index.range" on ${e.index.name}`,{code:"INVALID_PARAMETER"});if(typeof e.index.value!=typeof t)throw new ee('"index.range" type should match the type of "index.value".',{code:"INVALID_PARAMETER"});return"string"==typeof t?ae.specialChars(t,"index.range",!1,!0):t}},tag:e=>{if(null==e)return e;if("string"==typeof e)return ae.specialChars(e,"tag",!1,!0);throw new ee('"tag" should be type: string.',{code:"INVALID_PARAMETER"})},private_key:"string"};let i=await me.bind(this)();e=ae.Params(e||{},t,r||i?[]:["table"])}let i=await Fe.bind(this)("get-records",e,{fetchOptions:t,auth:!!this.__user,method:this.__user?"post":"get"});for(let e in i.list)i.list[e]=We.bind(this)(i.list[e]);return i.list=await Promise.all(i.list),n&&i?.reference_private_key&&(this.__private_access_key[n]=i.reference_private_key),i}async function ze(e){return Fe.bind(this)("check-schema",e)}async function Ze(e,t){let n=await me.bind(this)();if(!t)throw new ee('"config" argument is required.',{code:"INVALID_PARAMETER"});if(!this.user)throw new ee("Login is required.",{code:"INVALID_REQUEST"});"string"==typeof t.table&&(t.table={name:t.table},t.record_id||(t.table.access_group=0)),"string"==typeof t.reference&&(t.reference={record_id:t.reference});let r=ae.Params(t||{},{record_id:["string",()=>{if(!t.table||!t.table.name)throw new ee('"table.name" is required.',{code:"INVALID_PARAMETER"})}],readonly:"boolean",table:{name:e=>{if(!e)throw new ee('"table.name" cannot be empty string.',{code:"INVALID_PARAMETER"});return ae.specialChars(e,"table name",!0,!0)},subscription:e=>{if(e&&(!t.record_id&&!t.table.access_group||0===t.table.access_group||"public"===t.table.access_group))throw new ee("Public records cannot require subscription.",{code:"INVALID_REQUEST"});return e},access_group:e=>{if("string"==typeof e&&(e={private:"private",public:0,authorized:1}[e]),"number"==typeof e&&!n&&this.user.access_group<e)throw new ee("User has no access",{code:"INVALID_REQUEST"});if(void 0===e)throw new ee('"table.access_group" is invalid.',{code:"INVALID_PARAMETER"});return e}},reference:{record_id:e=>(ae.specialChars(e,'"reference.record_id"',!1,!1),this.__private_access_key[e]&&(t.reference_private_key=this.__private_access_key[e]),e),reference_limit:e=>{if(null===e)return null;if("number"==typeof e){if(0>e)throw new ee('"reference_limit" should be >= 0',{code:"INVALID_PARAMETER"});if(e>4503599627370546)throw new ee('"reference_limit" should be <= 4503599627370546',{code:"INVALID_PARAMETER"});return e}throw new ee('"reference_limit" should be type: <number | null>',{code:"INVALID_PARAMETER"})},allow_multiple_reference:"boolean"},index:{name:["$uploaded","$updated","$referenced_count","$user_id",e=>{if(!e)throw new ee('"index.name" is required.',{code:"INVALID_PARAMETER"});if("string"==typeof e)return ae.specialChars(e,"index name",!0),e;throw new ee('"index.name" should be type: string.',{code:"INVALID_PARAMETER"})}],value:[e=>{if(!e&&"boolean"!=typeof e&&0!==e)throw new ee('"index.value" is required.',{code:"INVALID_PARAMETER"});if(!["boolean","string","number"].includes(typeof e))throw new ee('"index.value" should be type: <boolean | string | number>.',{code:"INVALID_PARAMETER"});if("string"==typeof e)ae.specialChars(e,"index value",!1,!0);else if("number"==typeof e&&(e>Je||e<-4503599627370496))throw new ee("Number value should be within range -4503599627370496 ~ +4503599627370496",{code:"INVALID_PARAMETER"});return e}]},tags:e=>null==e?e:("string"==typeof e&&(e=e.split(",").map((e=>e.trim()))),ae.specialChars(e,"tag",!1,!0)),remove_bin:e=>{if(!e)return null;let t=[];if(!Array.isArray(e))throw new ee('"remove_bin" should be type: <string[] | BinaryFile[]>',{code:"INVALID_PARAMETER"});for(let n of e)if("string"==typeof n)t.push(n);else{if(!(n.url&&n.size&&n.filename))throw new ee('"remove_bin" should be type: <string[] | BinaryFile[]>',{code:"INVALID_PARAMETER"});t.push(n.url)}return t},progress:"function"}),i=t.progress||null;t.table&&t.table.hasOwnProperty("subscription")&&(r.table.subscription_group=t.table.subscription?1:null,delete r.table.subscription),delete r.progress;let s={auth:!0},o=null,a=null,u=se(e);u.files.length&&(a=u.files),o=Object.assign({data:u.data},r);let c={};"function"==typeof i&&(c.progress=i),Object.keys(c).length&&Object.assign(s,{fetchOptions:c}),o.schema_pass=await ze.bind(this)(r);let l=await Fe.bind(this)("post-record",o,s);if(a){let e=new FormData;for(let t of a)e.append(t.name,t.file,t.file.name);let t={record_id:l.rec,progress:i};r.hasOwnProperty("service")&&(t.service=r.service);let{bin_endpoints:n}=await qe.bind(this)(e,t);l.bin?l.bin.push(...n):l.bin=n}return We.bind(this)(l)}async function Xe(e,t){let n=await Fe.bind(this)("get-table",ae.Params(e||{},{table:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!!this.__user},{fetchOptions:t})),r={cnt_rec:"number_of_records",tbl:"table",srvc:"service"};if(Array.isArray(n?.list))for(let e of n.list)for(let t in r)e.hasOwnProperty(t)&&(e[r[t]]=e[t],delete e[t]);return n}async function et(e,t){if(!e?.table)throw new ee('"table" is required.',{code:"INVALID_PARAMETER"});let n=ae.Params(e||{},{table:"string",index:e=>ae.specialChars(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(n.hasOwnProperty("order")){if(!n.order?.by)throw new ee('"order.by" is required.',{code:"INVALID_PARAMETER"});if(n.order.hasOwnProperty("condition")&&!n.order.hasOwnProperty("value"))throw new ee('"value" is required for "condition".',{code:"INVALID_PARAMETER"});if(n.hasOwnProperty("index")&&"."!==n.index.substring(n.index.length-1))throw new ee('"index" should be a parent index name of the compound index when using "order.by"',{code:"INVALID_PARAMETER"})}let r=await Fe.bind(this)("get-index",n,Object.assign({auth:!!this.__user},{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(r?.list)&&(r.list=r.list.map((e=>{let t=e.idx.split("/"),n={table:t[1],index:t[2],number_of_records:e.cnt_rec};for(let t in i)e?.[t]&&(n[i[t]]=e[t]);return n}))),r}async function tt(e,t){let n=await Fe.bind(this)("get-tag",ae.Params(e||{},{table:"string",tag:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!!this.__user},{fetchOptions:t}));if(Array.isArray(n?.list))for(let e in n.list){let t=n.list[e],r=t.tag.split("/");n.list[e]={table:r[1],tag:r[0],number_of_records:t.cnt_rec}}return n}async function nt(e){let t=await me.bind(this)();if(t&&!e?.service)throw new ee("Service ID is required.",{code:"INVALID_PARAMETER"});if(e?.record_id)return await Fe.bind(this)("del-records",{service:e.service||this.service,record_id:(e=>{if("string"==typeof e)return[e];if(!Array.isArray(e))throw new ee('"record_id" should be type: <string | string[]>',{code:"INVALID_PARAMETER"});if(e.length>100)throw new ee('"record_id" should not exceed 100 items.',{code:"INVALID_PARAMETER"});return ae.specialChars(e,"record_id",!1,!1)})(e.record_id)},{auth:!0});{if(!e?.table)throw new ee('Either "table" or "record_id" is required.',{code:"INVALID_PARAMETER"});let n={access_group:e=>{if("string"==typeof e&&["private","public","authorized"].includes(e))switch(e){case"private":return e;case"public":return 0;case"authorized":return 1}else if("number"==typeof e&&e>=0&&e<100)return e;throw new ee('Invalid "table.access_group". Access group should be type <number (0~99) | "private" | "public" | "authorized">.',{code:"INVALID_PARAMETER"})},name:"string",subscription:n=>{if("boolean"==typeof n&&n)return this.__user.user_id;if(!e.table.hasOwnProperty("access_group"))throw new ee('"table.access_group" is required for subscription records.',{code:"INVALID_PARAMETER"});if(0===e.table.access_group)throw new ee("Public tables does not hold subscription records.",{code:"INVALID_REQUEST"});if(t&&"string"==typeof n)return ae.UserId(n,'User ID in "table.subscription"');throw new ee('"table.subscription" is an invalid parameter key.',{code:"INVALID_PARAMETER"})}},r=ae.Params(e.table||{},n,t?[]:["name"]);r.subscription&&(r.subscription_group=1);let i=Object.assign({},e,{table:r});return await Fe.bind(this)("del-records",i,{auth:!0})}}function rt(e){if(!e.record_id)throw new ee("Record ID is required.",{code:"INVALID_PARAMETER"});if(!e.user_id||Array.isArray(e.user_id)&&!e.user_id.length)throw new ee("User ID is required.",{code:"INVALID_PARAMETER"});return at.bind(this)({record_id:e.record_id,user_id:e.user_id||null,execute:"add"})}function it(e){if(!e.record_id)throw new ee("Record ID is required.",{code:"INVALID_PARAMETER"});if(!e.user_id||Array.isArray(e.user_id)&&!e.user_id.length)throw new ee("User ID is required.",{code:"INVALID_PARAMETER"});return at.bind(this)({record_id:e.record_id,user_id:e.user_id||null,execute:"remove"})}async function st(e){let t=await at.bind(this)({record_id:e.record_id,user_id:e.user_id||null,execute:"list"});return t.list=t.list.map((e=>(e.record_id=e.rec_usr.split("/")[0],e.user_id=e.rec_usr.split("/")[1],e))),t}function ot(e){return Fe.bind(this)("request-private-access-key",{record_id:e},{auth:!0})}function at(e){let t=e.execute,n=ae.Params(e,{record_id:"string",user_id:e=>{if(!e){if("list"==t)return null;throw new ee("User ID is required.",{code:"INVALID_PARAMETER"})}let n=e;if("string"==typeof n&&(n=[n]),n.length>100)throw new ee("Cannot process more than 100 users at once.",{code:"INVALID_REQUEST"});for(let e of n)ae.UserId(e,'User ID in "user_id"');return n},execute:["add","remove","list"]},["execute","record_id","user_id"]);return n.user_id||(n.user_id=null),Fe.bind(this)("grant-private-access",n,{auth:!0})}async function ut(){if(await this.getProfile(),!this.session)throw new ee("No access.",{code:"INVALID_REQUEST"});let e=await this.record_endpoint;return new WebSocket(e.websocket_private+"?token="+this.session.accessToken.jwtToken)}let ct=0,lt={},ht={},ft=null;function dt(e,t=0){if("function"!=typeof e)throw new ee("Callback must be a function.",{code:"INVALID_REQUEST"});return!ct&&this.__socket instanceof Promise||(this.__socket=new Promise((async n=>{setTimeout((async()=>{if(await this.__connection,!await this.getProfile())throw new ee("No access.",{code:"INVALID_REQUEST"});let t=await ut.bind(this)();t.onopen=()=>{ct=0,e({type:"success",message:"Connected to WebSocket server."}),this.__socket_room&&t.send(JSON.stringify({action:"joinRoom",rid:this.__socket_room,token:this.session.accessToken.jwtToken})),ft=setInterval((()=>{1===t.readyState&&t.send(JSON.stringify({action:"keepAlive",token:this.session.accessToken.jwtToken}))}),3e4),n(t)},t.onmessage=async t=>{let n=JSON.parse(decodeURI(t.data)),r="message";n?.["#private"]?r="private":n?.["#notice"]&&(r="notice");let i={type:r,message:n?.["#message"]||n?.["#private"]||n?.["#notice"]||null};if(n?.["#user_id"]&&(i.sender=n["#user_id"]),n?.["#scid"]&&(i.sender_cid=n["#scid"]),"notice"===r)if(this.__socket_room&&(i.message.includes("has left the message group.")||i.message.includes("has been disconnected."))){ht[this.__socket_room]&&await ht[this.__socket_room];let e=i.sender;if(lt?.[this.__socket_room]?.[e]&&(lt[this.__socket_room][e]=lt[this.__socket_room][e].filter((e=>e!==i.sender_cid))),lt?.[this.__socket_room]?.[e]&&0===lt[this.__socket_room][e].length&&delete lt[this.__socket_room][e],lt?.[this.__socket_room]?.[e])return}else if(this.__socket_room&&i.message.includes("has joined the message group.")){ht[this.__socket_room]&&await ht[this.__socket_room];let e=i.sender;if(lt?.[this.__socket_room]||(lt[this.__socket_room]={}),lt[this.__socket_room][e])return void(lt[this.__socket_room][e].includes(i.sender_cid)||lt[this.__socket_room][e].push(i.sender_cid));lt[this.__socket_room][e]=[i.sender_cid]}e(i)},t.onclose=t=>{if(t.wasClean)clearInterval(ft),ft=null,e({type:"close",message:"WebSocket connection closed."}),this.__socket=null,this.__socket_room=null;else if(ct++,ct<10){let t=Math.min(1e3*2**ct,3e4);e({type:"error",message:`Skapi: WebSocket connection error. Reconnecting in ${t/1e3} seconds...`}),dt.bind(this)(e,t)}else e({type:"error",message:"Skapi: WebSocket connection error. Max reconnection attempts reached."}),this.__socket=null},t.onerror=()=>{throw e({type:"error",message:"Skapi: WebSocket connection error."}),new ee("Skapi: WebSocket connection error.",{code:"ERROR"})}}),t)}))),this.__socket}async function pt(){let e=this.__socket?await this.__socket:this.__socket;return e&&e.close(),this.__socket=null,this.__socket_room=null,null}async function gt(e,t){let n=this.__socket?await this.__socket:this.__socket;if(!n)throw new ee("No realtime connection. Execute connectRealtime() before this method.",{code:"INVALID_REQUEST"});if(!t)throw new ee("No recipient.",{code:"INVALID_REQUEST"});if(e=se(e).data,1===n.readyState){try{ae.UserId(t),n.send(JSON.stringify({action:"sendMessage",uid:t,content:e,token:this.session.accessToken.jwtToken}))}catch(r){if(this.__socket_room!==t)throw new ee(`User has not joined to the recipient group. Run joinRealtime({ group: "${t}" })`,{code:"INVALID_REQUEST"});n.send(JSON.stringify({action:"broadcast",rid:t,content:e,token:this.session.accessToken.jwtToken}))}return{type:"success",message:"Message sent."}}throw new ee("Realtime connection is not open. Try reconnecting with connectRealtime().",{code:"INVALID_REQUEST"})}async function _t(e){let t=this.__socket?await this.__socket:this.__socket;if(!t)throw new ee("No realtime connection. Execute connectRealtime() before this method.",{code:"INVALID_REQUEST"});e=se(e).data;let{group:n=null}=e;if(!n&&!this.__socket_room)return{type:"success",message:"Left realtime message group."};if(null!==n&&"string"!=typeof n)throw new ee('"group" must be a string | null.',{code:"INVALID_PARAMETER"});return t.send(JSON.stringify({action:"joinRoom",rid:n,token:this.session.accessToken.jwtToken})),this.__socket_room=n,{type:"success",message:n?`Joined realtime message group: "${n}".`:"Left realtime message group."}}async function mt(e,t){if(await this.__connection,!(e=ae.Params(e,{user_id:e=>ae.UserId(e,'User ID in "user_id"'),group:"string"},["group"])).group)throw new ee('"group" is required.',{code:"INVALID_PARAMETER"});if(!e.user_id&&ht[e.group])return ht[e.group];let n=Fe.bind(this)("get-ws-group",e,{fetchOptions:t,auth:!0,method:"post"}).then((t=>(t.list=t.list.map((t=>{let n=t.uid.split("#")[1];return e.user_id||(lt[e.group]||(lt[e.group]={}),lt[e.group][n]?lt[e.group][n].includes(t.cid)||lt[e.group][n].push(t.cid):lt[e.group][n]=[t.cid]),{user_id:n,connection_id:t.cid}})),t))).finally((()=>{delete ht[e.group]}));return e.user_id||ht[e.group]||(ht[e.group]=n),n}async function yt(e,t){if(await this.__connection,e||(e={searchFor:"group"}),(e=ae.Params(e,{searchFor:["group","number_of_users",()=>"group"],value:["string","number",()=>e?.searchFor&&"number_of_users"===e?.searchFor?0:" "],condition:[">",">=","=","<","<=","!=","gt","gte","eq","lt","lte","ne"],range:["string","number"]})).condition||(" "!==e.value&&e.value?e.condition="=":e.condition=">"),e.range&&e.condition&&delete e.condition,"number_of_users"===e.searchFor&&"number"!=typeof e.value)throw new ee('"value" must be a number.',{code:"INVALID_PARAMETER"});if("group"===e.searchFor&&"string"!=typeof e.value)throw new ee('"value" must be a string.',{code:"INVALID_PARAMETER"});if(e.hasOwnProperty("range")&&typeof e.range!=typeof e.value)throw new ee(`"range" must be a ${typeof e.value}.`,{code:"INVALID_PARAMETER"});let n=await Fe.bind(this)("get-ws-group",e,{fetchOptions:t,auth:!0,method:"post"});return n.list=n.list.map((e=>({group:e.rid.split("#")[1],number_of_users:e.cnt}))),n}async function wt(e){let t=!1,n=e=>{for(let n in e)if("string"==typeof e[n]&&e[n].includes("$CLIENT_SECRET")){t=!0;break}};if(ae.Params(e,{url:e=>{if(!e||"string"!=typeof e)throw new ee('"url" should be type: <string>.',{code:"INVALID_PARAMETER"});return ae.Url(e),e.includes("$CLIENT_SECRET")&&(t=!0),e},clientSecretName:"string",method:e=>{if(e&&"string"!=typeof e)throw new ee('"method" should be either "GET" or "POST" or "DELETE" or "PUT".',{code:"INVALID_PARAMETER"});let t=e.toLowerCase();if("get"!==t&&"post"!==t&&"delete"!==t&&"put"!==t)throw new ee('"method" should be either "GET" or "POST" or "DELETE" or "PUT".',{code:"INVALID_PARAMETER"});return t},headers:e=>{if(e&&"object"!=typeof e)throw new ee('"headers" should be type: <object>.',{code:"INVALID_PARAMETER"});return n(e),e},data:e=>{if(e&&"object"!=typeof e)throw new ee('"data" should be type: <object>.',{code:"INVALID_PARAMETER"});return n(e),e},params:e=>{if(e&&"object"!=typeof e)throw new ee('"params" should be type: <object>.',{code:"INVALID_PARAMETER"});return n(e),e}},["clientSecretName","method","url"]),!t)throw new ee(`At least one parameter value should include "$CLIENT_SECRET" in ${"post"===e.method.toLowerCase()?'"data"':'"params"'} or "headers".`,{code:"INVALID_PARAMETER"});await this.__connection;let r=!!this.__user;return Fe.bind(this)("client-secret-request"+(r?"-public":""),e,{auth:r})}async function bt(e){await this.__connection;let t={name:"string",email:e=>(ae.Email(e),e),subject:"string",message:"string"};return e=ae.Params(e,t,["name","email","subject","message"]),await Fe.bind(this)("send-inquiry",e),"SUCCESS: Inquiry has been sent."}async function At(e,t){if(await this.__connection,e instanceof FormData||e instanceof HTMLFormElement||e instanceof SubmitEvent){if(!t)throw new ee("Url string as a second argument is required when form is passed.",{code:"INVALID_PARAMETER"});e={url:t,data:se(e).data,sync:!0}}let n={url:e=>ae.Url(e),data:e=>e,sync:["boolean",()=>!0]};if(Array.isArray(e))for(let t of e)t=ae.Params(t,n);else e=ae.Params(e,n);return Fe.bind(this)("post-secure",e,{auth:!0})}async function vt(e,t){await this.__connection;let{auth:n=!1,method:r="POST",bypassAwaitConnection:i=!1,responseType:s,contentType:o,progress:a}=t||{};if(t=Object.assign({auth:n,method:r,bypassAwaitConnection:i,responseType:s,contentType:o},{fetchOptions:{progress:a}}),"object"!=typeof e&&("application/json"===o||void 0===o))throw new ee('"data" should be type: <object>.',{code:"INVALID_PARAMETER"});return Fe.bind(this)("mock",e,t)}function Et(e){return ae.Params(e,{user_id:e=>{if(!this.__user)throw new ee("User should be logged in.",{code:"INVALID_REQUEST"});if(e===this.__user.user_id)throw new ee('"user_id" cannot be the user\'s own ID.',{code:"INVALID_PARAMETER"});return ae.UserId(e,'"user_id"')}},["user_id"])}async function St(e,t,n){if(!(e=ae.Params(e,{subscriber:e=>ae.UserId(e,'User ID in "subscriber"'),subscription:e=>ae.UserId(e,'User ID in "subscription"'),blocked:"boolean"})).subscriber&&!e.subscription)throw new ee('At least either "subscriber" or "subscription" should have a value.',{code:"INVALID_PARAMETER"});Object.assign(e,{group:1});let r=await Fe.bind(this)("get-subscription",e,Object.assign({auth:!0},{fetchOptions:t}));return r.list=r.list.map(n||(e=>{let t={},n=e.sub.split("#");return t.subscriber=n[2],t.subscription=n[0],t.group=parseInt(n[1]),t.timestamp=e.stmp,t.blocked="N"===e.grp.substring(0,1),t})),r}async function It(e){await this.__connection;let{user_id:t}=Et.bind(this)(e);return await Fe.bind(this)("subscription",{subscribe:t,group:1},{auth:!0})}async function Tt(e){await this.__connection;let{user_id:t}=Et.bind(this)(e);return await Fe.bind(this)("subscription",{unsubscribe:t,group:1},{auth:!0})}async function Rt(e){await this.__connection;let{user_id:t}=Et.bind(this)(e);return await Fe.bind(this)("subscription",{block:t,group:1},{auth:!0})}async function Ut(e){await this.__connection;let{user_id:t}=Et.bind(this)(e);return await Fe.bind(this)("subscription",{unblock:t,group:1},{auth:!0})}async function Dt(e){await this.__connection;let t=await me.bind(this)();e=ae.Params(e,{user_id:e=>{if(e!==this.__user.user_id&&!t)throw new ee("No access.",{code:"INVALID_REQUEST"});return e},group:e=>{if("public"===e&&(e=0),"authorized"===e&&(e=1),"number"!=typeof e)throw new ee('"group" should be type number | "public" | "authorized".',{code:"INVALID_PARAMETER"});return e}});let n=await Fe.bind(this)("get-newsletter-subscription",e,{auth:!0}),r=[];for(let e of n){let t=e.subt.split("#"),n=!0;"@"===t[0].charAt(0)&&(n=!1,t[0]=t[0].substring(1));let i=parseInt(t[0]);r.push({timestamp:e.stmp,group:i,subscribed_email:t[1],active:n})}return r}async function Ct(e){await this.__connection;let t=ae.Params(e||{},{email:e=>ae.Email(e),group:["number","public","authorized"],redirect:e=>ae.Url(e)},this.__user?["group"]:["email","group"]);return Fe.bind(this)(`subscribe-${this.__user?"":"public-"}newsletter`,t,{auth:!!this.__user})}async function Pt(e){await this.__connection,e=ae.Params(e,{group:["number","public","authorized"]},["group"]);let t=Object.assign({action:"unsubscribe"},e);return Fe.bind(this)("subscribe-newsletter",t,{auth:!0})}async function Nt(e,t){let n=await me.bind(this)(),r={message_id:"string",timestamp:"number",read:"number",complaint:"number",subject:"string"};e||(t=Object.assign({ascending:!1},t||{})),e=e||{searchFor:"timestamp",value:Date.now(),condition:"<",group:"public"};let i=0===(e=ae.Params(e,{searchFor:["message_id","timestamp","read","complaint","group","subject"],value:t=>{if(typeof t!==r[e.searchFor])throw new ee(`"value" type does not match the type of "${e.searchFor}" index.`,{code:"INVALID_PARAMETER"});if("string"==typeof t&&!t)throw new ee('"value" should not be empty string.',{code:"INVALID_PARAMETER"});return t},range:t=>{if(!e.hasOwnProperty("value")||typeof t!=typeof e.value)throw new ee('"range" should match type of "value".',{code:"INVALID_PARAMETER"});return t},condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],group:e=>{if("public"===e)return 0;if(!this.session)throw new ee("User should be logged in.",{code:"INVALID_REQUEST"});if("authorized"===e)return 1;if("number"==typeof e){if(!n&&e>parseInt(this.session.idToken.payload.access_group))throw new ee("User has no access.",{code:"INVALID_REQUEST"});return e}throw new ee('"group" should be type: number | "public" | "authorized".',{code:"INVALID_PARAMETER"})}},["searchFor","value","group"])).group?"get-public-newsletters":"get-newsletters",s=await Fe.bind(this)(i,e,Object.assign({method:"get",auth:"get-public-newsletters"!==i||!!this.__user},{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 n in o)t[n]=e[o[n]]||a[n];return t})),s}async function kt(e){let t=ae.Params(e,{user_id:e=>ae.UserId(e,'"user_id"')},["user_id"]);if(t=t?.service&&t?.owner?{service:t?.service,owner:t?.owner,block:t.user_id}:{block:t.user_id},!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("block-account",t,{auth:!0})}async function Ot(e){let t=ae.Params(e,{user_id:e=>ae.UserId(e,'"user_id"')},["user_id"]);if(t=t?.service&&t?.owner?{service:t?.service,owner:t?.owner,unblock:t.user_id}:{unblock:t.user_id},!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("block-account",t,{auth:!0})}async function Lt(e){let t=ae.Params(e,{user_id:e=>ae.UserId(e,'"user_id"')},["user_id"]);if(t=t?.service&&t?.owner?{service:t?.service,owner:t?.owner,delete:t.user_id}:{delete:t.user_id},!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("remove-account",t,{auth:!0})}async function Mt(e,t){let n={email:e=>ae.Email(e),password:e=>ae.Password(e),name:"string",username:"string",gender:"string",address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):void 0:"",birthdate:e=>ae.Birthdate(e),phone_number:e=>ae.PhoneNumber(e),picture:e=>e?ae.Url(e):void 0,profile:e=>e?ae.Url(e):void 0,website:e=>e?ae.Url(e):void 0,nickname:"string",misc:"string",email_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],address_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1]},r=ae.Params(e,n,["email"]);if(t=ae.Params(t,{confirmation_url:e=>{let t=e;if("string"!=typeof e)throw new ee('"options.confirmation_url" should be type: <string>.',{code:"INVALID_PARAMETER"});if(t=ae.Url(e),t&&!r.email)throw new ee('"email" is required for signup confirmation.',{code:"INVALID_PARAMETER"});return t},email_subscription:e=>{if("boolean"!=typeof e)throw new ee('"options.email_subscription" should be type: <boolean>.',{code:"INVALID_PARAMETER"});if(!t?.confirmation_url)throw new ee('"options.confirmation_url" is required for email subscription.',{code:"INVALID_PARAMETER"});return e}}),r.signup_confirmation=t?.confirmation_url||!0,r.email_subscription=t?.email_subscription||!1,!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("admin-signup",Object.assign({access_group:1},r),{auth:!0})}async function Vt(e,t){let n={email:e=>ae.Email(e),password:e=>ae.Password(e),name:"string",username:"string",gender:"string",address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):void 0:"",birthdate:e=>ae.Birthdate(e),phone_number:e=>ae.PhoneNumber(e),picture:e=>e?ae.Url(e):void 0,profile:e=>e?ae.Url(e):void 0,website:e=>e?ae.Url(e):void 0,nickname:"string",misc:"string",email_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],address_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1]},r=ae.Params(e,n,["email","password"]);if(t=ae.Params(t,{email_subscription:e=>{if("boolean"!=typeof e)throw new ee('"options.email_subscription" should be type: <boolean>.',{code:"INVALID_PARAMETER"});return e}}),r.email_subscription=t?.email_subscription||!1,!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("admin-signup",Object.assign({access_group:1},r),{auth:!0})}async function Ft(e){if(e=ae.Params(e,{user_id:e=>ae.UserId(e,'"user_id"'),access_group:e=>{if(e>0&&e<100)return e;throw new ee('"access_group" is invalid.',{code:"INVALID_PARAMETER"})}},["user_id","access_group"]),!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("grant-access",e,{auth:!0})}var xt=function(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o};class Bt{get user(){return this.__user&&Object.keys(this.__user).length?JSON.parse(JSON.stringify(this.__user)):null}set user(e){}constructor(e,t,n,r){if(this.__version="1.0.161",this.session=null,this.connection=null,this.userPool=null,this.host="skapi",this.hostDomain="skapi.com",this.target_cdn="d3e9syvbtso631",this.__disabledAccount=null,this.__cached_requests={},this.__startKeyHistory={},this.__request_signup_confirmation=null,this.__private_access_key={},this.__class_properties_has_been_cached=!1,this.__user=null,this.onLogin=e=>{},this.validate={userId(e){try{return ae.UserId(e),!0}catch(e){return!1}},url(e){try{return ae.Url(e),!0}catch(e){return!1}},phoneNumber(e){try{return ae.PhoneNumber(e),!0}catch(e){return!1}},birthdate(e){try{return ae.Birthdate(e),!0}catch(e){return!1}},email(e){try{return ae.Email(e),!0}catch(e){return!1}}},this.util={MD5:te,generateRandom:ie,toBase62:ne,fromBase62:re,extractFormData:se,request:(e,t,n)=>Fe.bind(this)(e,t,n,{ignoreService:!0})},this.__network_logs=!1,this.registerTicket=de.bind(this),this.unregisterTicket=pe.bind(this),"string"!=typeof e||"string"!=typeof t)throw new ee('"service" and "owner" should be type <string>.',{code:"INVALID_PARAMETER"});if(!e||!t)throw new ee('"service" and "owner" is required',{code:"INVALID_PARAMETER"});t!==this.host&&ae.UserId(t,'"owner"'),this.service=e,this.owner=t;let i=!0;n&&"boolean"==typeof n.autoLogin&&(i=n.autoLogin),this.target_cdn=r?.target_cdn||this.target_cdn,this.hostDomain=r?.hostDomain||this.hostDomain,this.__network_logs=!!r?.network_logs;const s=`https://${this.target_cdn}.cloudfront.net`;let o=e.substring(0,4);if(this.admin_endpoint=fetch(`${s}/${o}/admin.json`).then((e=>e.blob())).then((e=>new Promise(((t,n)=>{const r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.record_endpoint=fetch(`${s}/${o}/record.json`).then((e=>e.blob())).then((e=>new Promise(((t,n)=>{const r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),!window.sessionStorage)throw new Error("This browser does not support skapi.");const a=JSON.parse(window.sessionStorage.getItem(`${e}#${t}`)||"null");if(this.log("constructor:restore",a),a?.connection)for(let e in a)this[e]=a[e];this.__authConnection=(async()=>{const e=await this.admin_endpoint;if(this.userPool=new X({UserPoolId:e.userpool_id,ClientId:e.userpool_client}),a?.connection||i)try{await ge.bind(this)().getSession()}catch(e){}})(),this.__connection=(async()=>{let n=null;a?.connection||(n=this.updateConnection());const r=()=>{if(this.__class_properties_has_been_cached)return;let r=()=>{let n={};const r=["__startKeyHistory","__disabledAccount","__cached_requests","__request_signup_confirmation","connection"];if(this.connection){for(let e of r)n[e]=this[e];window.sessionStorage.setItem(`${e}#${t}`,JSON.stringify(n)),this.__class_properties_has_been_cached=!0}};return n instanceof Promise?n.then((()=>r())):r()};return window.addEventListener("beforeunload",(()=>{this.closeRealtime(),r()})),window.addEventListener("visibilitychange",(()=>{r()})),await n,await this.__authConnection,this.connection})(),this.__connection.then((e=>{((e?.group||0)<3||this.__network_logs)&&this.version()}))}async updateConnection(){try{this.connection=await Fe.bind(this)("service",{service:this.service,owner:this.owner},{bypassAwaitConnection:!0,method:"get"})}catch(e){throw window&&window.alert("Service is not available: "+(e.message||e.toString())),this.connection=null,e}return this.connection}async version(){return await this.__connection,console.log(`Built with:\n%c\r\n $$\\ $$\\ \r\n $$ | \\__|\r\n $$$$$$$\\ $$ | $$\\ $$$$$$\\ $$$$$$\\ $$\\ \r\n$$ _____|$$ | $$ |\\____$$\\ $$ __$$\\ $$ |\r\n\\$$$$$$\\ $$$$$$ / $$$$$$$ |$$ / $$ |$$ |\r\n \\____$$\\ $$ _$$< $$ __$$ |$$ | $$ |$$ |\r\n$$$$$$$ |$$ | \\$$\\\\$$$$$$$ |$$$$$$$ |$$ |\r\n\\_______/ \\__| \\__|\\_______|$$ ____/ \\__|\r\n $$ | \r\n $$ | \r\n \\__| \r\nVersion: ${this.__version}\n\nDocumentation: https://docs.skapi.com`,"font-family: monospace; color:blue;"),1===this.connection.group&&console.log("%cSKAPI: THE SERVICE IS IN TRIAL MODE. ALL THE USERS AND DATA WILL BE INITIALIZED EVERY 30 DAYS.","font-family: monospace; color:red;"),this.__version}log(e,t){if(this.__network_logs)try{console.log(e,JSON.parse(JSON.stringify(t)))}catch(n){console.log(e,t)}}connectRealtime(e){return dt.bind(this)(e)}jwtLogin(e){return ve.bind(this)(e)}clientSecretRequest(e){return wt.bind(this)(e)}consumeTicket(e){return le.bind(this)(e)}getConsumedTickets(e,t){return fe.bind(this)(e,t)}getTickets(e,t){return he.bind(this)(e,t)}closeRealtime(){return pt.bind(this)()}getRealtimeUsers(e,t){return mt.bind(this)(e,t)}sendInquiry(e){return bt.bind(this)(e)}blockAccount(e){return kt.bind(this)(e)}unblockAccount(e){return Ot.bind(this)(e)}deleteAccount(e){return Lt.bind(this)(e)}inviteUser(e,t){return Mt.bind(this)(e,t)}createAccount(e,t){return Vt.bind(this)(e,t)}grantAccess(e){return Ft.bind(this)(e)}getRealtimeGroups(e,t){return yt.bind(this)(e,t)}postRealtime(e,t){return gt.bind(this)(e,t)}joinRealtime(e){return _t.bind(this)(e)}getConnection(){return this.__connection}getProfile(e){return _e.bind(this)(e)}getFile(e,t){return Ye.bind(this)(e,t)}secureRequest(e,t){return At.bind(this)(e,t)}getFormResponse(){return He.bind(this)()}getRecords(e,t){return Ge.bind(this)(e,t)}getTables(e,t){return Xe.bind(this)(e,t)}getIndexes(e,t){return et.bind(this)(e,t)}getTags(e,t){return tt.bind(this)(e,t)}deleteRecords(e){return nt.bind(this)(e)}resendSignupConfirmation(e){return be.bind(this)(e)}recoverAccount(e=!1){return Ae.bind(this)(e)}getUsers(e,t){return ke.bind(this)(e,t)}disableAccount(){return Ie.bind(this)()}lastVerifiedEmail(e){return Oe.bind(this)(e)}unsubscribeNewsletter(e){return Pt.bind(this)(e)}getNewsletters(e,t){return Nt.bind(this)(e,t)}getNewsletterSubscription(e){return Dt.bind(this)(e)}requestUsernameChange(e){return Le.bind(this)(e)}grantPrivateRecordAccess(e){return rt.bind(this)(e)}removePrivateRecordAccess(e){return it.bind(this)(e)}listPrivateRecordAccess(e){return st.bind(this)(e)}requestPrivateRecordAccessKey(e){return ot.bind(this)(e)}deleteFiles(e){return Qe.bind(this)(e)}uploadFiles(e,t){return qe.bind(this)(e,t)}mock(e,t){return vt.bind(this)(e,t)}login(e){return Ee.bind(this)(e)}logout(){return we.bind(this)()}signup(e,t){return Se.bind(this)(e,t)}resetPassword(e){return Te.bind(this)(e)}verifyEmail(e){return De.bind(this)(e)}verifyPhoneNumber(e){return Ue.bind(this)(e)}forgotPassword(e){return Ce.bind(this)(e)}changePassword(e){return Pe.bind(this)(e)}updateProfile(e){return Ne.bind(this)(e)}postRecord(e,t){return Ze.bind(this)(e,t)}getSubscriptions(e,t){return St.bind(this)(e,t)}subscribe(e){return It.bind(this)(e)}unsubscribe(e){return Tt.bind(this)(e)}blockSubscriber(e){return Rt.bind(this)(e)}unblockSubscriber(e){return Ut.bind(this)(e)}subscribeNewsletter(e){return Ct.bind(this)(e)}}xt([Ke()],Bt.prototype,"clientSecretRequest",null),xt([Ke()],Bt.prototype,"consumeTicket",null),xt([Ke()],Bt.prototype,"getConsumedTickets",null),xt([Ke()],Bt.prototype,"getTickets",null),xt([Ke()],Bt.prototype,"getRealtimeUsers",null),xt([Ke()],Bt.prototype,"sendInquiry",null),xt([Ke()],Bt.prototype,"blockAccount",null),xt([Ke()],Bt.prototype,"unblockAccount",null),xt([Ke()],Bt.prototype,"deleteAccount",null),xt([Ke()],Bt.prototype,"inviteUser",null),xt([Ke()],Bt.prototype,"createAccount",null),xt([Ke()],Bt.prototype,"grantAccess",null),xt([Ke()],Bt.prototype,"getRealtimeGroups",null),xt([Ke()],Bt.prototype,"postRealtime",null),xt([Ke()],Bt.prototype,"joinRealtime",null),xt([Ke()],Bt.prototype,"getProfile",null),xt([Ke()],Bt.prototype,"getFile",null),xt([Ke()],Bt.prototype,"secureRequest",null),xt([Ke()],Bt.prototype,"getFormResponse",null),xt([Ke()],Bt.prototype,"getRecords",null),xt([Ke()],Bt.prototype,"getTables",null),xt([Ke()],Bt.prototype,"getIndexes",null),xt([Ke()],Bt.prototype,"getTags",null),xt([Ke()],Bt.prototype,"deleteRecords",null),xt([Ke()],Bt.prototype,"resendSignupConfirmation",null),xt([Ke()],Bt.prototype,"recoverAccount",null),xt([Ke()],Bt.prototype,"getUsers",null),xt([Ke()],Bt.prototype,"disableAccount",null),xt([Ke()],Bt.prototype,"lastVerifiedEmail",null),xt([Ke()],Bt.prototype,"unsubscribeNewsletter",null),xt([Ke()],Bt.prototype,"getNewsletters",null),xt([Ke()],Bt.prototype,"getNewsletterSubscription",null),xt([Ke()],Bt.prototype,"requestUsernameChange",null),xt([Ke()],Bt.prototype,"grantPrivateRecordAccess",null),xt([Ke()],Bt.prototype,"removePrivateRecordAccess",null),xt([Ke()],Bt.prototype,"listPrivateRecordAccess",null),xt([Ke()],Bt.prototype,"requestPrivateRecordAccessKey",null),xt([Ke()],Bt.prototype,"deleteFiles",null),xt([Ke()],Bt.prototype,"uploadFiles",null),xt([Ke()],Bt.prototype,"mock",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"login",null),xt([Ke()],Bt.prototype,"logout",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"signup",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"resetPassword",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"verifyEmail",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"verifyPhoneNumber",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"forgotPassword",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"changePassword",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"updateProfile",null),xt([Ke()],Bt.prototype,"postRecord",null),xt([Ke()],Bt.prototype,"getSubscriptions",null),xt([Ke()],Bt.prototype,"subscribe",null),xt([Ke()],Bt.prototype,"unsubscribe",null),xt([Ke()],Bt.prototype,"blockSubscriber",null),xt([Ke()],Bt.prototype,"unblockSubscriber",null),xt([Ke()],Bt.prototype,"subscribeNewsletter",null)})(),r})()));
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 n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(self,(()=>(()=>{var e={914:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.RawSha256=void 0;var r=n(945),i=function(){function e(){this.state=Int32Array.from(r.INIT),this.temp=new Int32Array(64),this.buffer=new Uint8Array(64),this.bufferLength=0,this.bytesHashed=0,this.finished=!1}return e.prototype.update=function(e){if(this.finished)throw new Error("Attempted to update an already finished hash.");var t=0,n=e.byteLength;if(this.bytesHashed+=n,8*this.bytesHashed>r.MAX_HASHABLE_LENGTH)throw new Error("Cannot hash more than 2^53 - 1 bits");for(;n>0;)this.buffer[this.bufferLength++]=e[t++],n--,this.bufferLength===r.BLOCK_SIZE&&(this.hashBuffer(),this.bufferLength=0)},e.prototype.digest=function(){if(!this.finished){var e=8*this.bytesHashed,t=new DataView(this.buffer.buffer,this.buffer.byteOffset,this.buffer.byteLength),n=this.bufferLength;if(t.setUint8(this.bufferLength++,128),n%r.BLOCK_SIZE>=r.BLOCK_SIZE-8){for(var i=this.bufferLength;i<r.BLOCK_SIZE;i++)t.setUint8(i,0);this.hashBuffer(),this.bufferLength=0}for(i=this.bufferLength;i<r.BLOCK_SIZE-8;i++)t.setUint8(i,0);t.setUint32(r.BLOCK_SIZE-8,Math.floor(e/4294967296),!0),t.setUint32(r.BLOCK_SIZE-4,e),this.hashBuffer(),this.finished=!0}var s=new Uint8Array(r.DIGEST_LENGTH);for(i=0;i<8;i++)s[4*i]=this.state[i]>>>24&255,s[4*i+1]=this.state[i]>>>16&255,s[4*i+2]=this.state[i]>>>8&255,s[4*i+3]=this.state[i]>>>0&255;return s},e.prototype.hashBuffer=function(){for(var e=this.buffer,t=this.state,n=t[0],i=t[1],s=t[2],o=t[3],a=t[4],u=t[5],c=t[6],l=t[7],h=0;h<r.BLOCK_SIZE;h++){if(h<16)this.temp[h]=(255&e[4*h])<<24|(255&e[4*h+1])<<16|(255&e[4*h+2])<<8|255&e[4*h+3];else{var f=this.temp[h-2],d=(f>>>17|f<<15)^(f>>>19|f<<13)^f>>>10,p=((f=this.temp[h-15])>>>7|f<<25)^(f>>>18|f<<14)^f>>>3;this.temp[h]=(d+this.temp[h-7]|0)+(p+this.temp[h-16]|0)}var g=(((a>>>6|a<<26)^(a>>>11|a<<21)^(a>>>25|a<<7))+(a&u^~a&c)|0)+(l+(r.KEY[h]+this.temp[h]|0)|0)|0,_=((n>>>2|n<<30)^(n>>>13|n<<19)^(n>>>22|n<<10))+(n&i^n&s^i&s)|0;l=c,c=u,u=a,a=o+g|0,o=s,s=i,i=n,n=g+_|0}t[0]+=n,t[1]+=i,t[2]+=s,t[3]+=o,t[4]+=a,t[5]+=u,t[6]+=c,t[7]+=l},e}();t.RawSha256=i},945:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.MAX_HASHABLE_LENGTH=t.INIT=t.KEY=t.DIGEST_LENGTH=t.BLOCK_SIZE=void 0,t.BLOCK_SIZE=64,t.DIGEST_LENGTH=32,t.KEY=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),t.INIT=[1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225],t.MAX_HASHABLE_LENGTH=Math.pow(2,53)-1},938:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),(0,n(655).__exportStar)(n(430),t)},430:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.Sha256=void 0;var r=n(655),i=n(945),s=n(914),o=n(658),a=function(){function e(e){if(this.hash=new s.RawSha256,e){this.outer=new s.RawSha256;var t=function(e){var t=(0,o.convertToBuffer)(e);if(t.byteLength>i.BLOCK_SIZE){var n=new s.RawSha256;n.update(t),t=n.digest()}var r=new Uint8Array(i.BLOCK_SIZE);return r.set(t),r}(e),n=new Uint8Array(i.BLOCK_SIZE);n.set(t);for(var r=0;r<i.BLOCK_SIZE;r++)t[r]^=54,n[r]^=92;for(this.hash.update(t),this.outer.update(n),r=0;r<t.byteLength;r++)t[r]=0}}return e.prototype.update=function(e){if(!(0,o.isEmptyData)(e)&&!this.error)try{this.hash.update((0,o.convertToBuffer)(e))}catch(e){this.error=e}},e.prototype.digestSync=function(){if(this.error)throw this.error;return this.outer?(this.outer.finished||this.outer.update(this.hash.digest()),this.outer.digest()):this.hash.digest()},e.prototype.digest=function(){return(0,r.__awaiter)(this,void 0,void 0,(function(){return(0,r.__generator)(this,(function(e){return[2,this.digestSync()]}))}))},e}();t.Sha256=a},106:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.convertToBuffer=void 0;var r=n(84),i="undefined"!=typeof Buffer&&Buffer.from?function(e){return Buffer.from(e,"utf8")}:r.fromUtf8;t.convertToBuffer=function(e){return e instanceof Uint8Array?e:"string"==typeof e?i(e):ArrayBuffer.isView(e)?new Uint8Array(e.buffer,e.byteOffset,e.byteLength/Uint8Array.BYTES_PER_ELEMENT):new Uint8Array(e)}},658:(e,t,n)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uint32ArrayFrom=t.numToUint8=t.isEmptyData=t.convertToBuffer=void 0;var r=n(106);Object.defineProperty(t,"convertToBuffer",{enumerable:!0,get:function(){return r.convertToBuffer}});var i=n(304);Object.defineProperty(t,"isEmptyData",{enumerable:!0,get:function(){return i.isEmptyData}});var s=n(174);Object.defineProperty(t,"numToUint8",{enumerable:!0,get:function(){return s.numToUint8}});var o=n(558);Object.defineProperty(t,"uint32ArrayFrom",{enumerable:!0,get:function(){return o.uint32ArrayFrom}})},304:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.isEmptyData=void 0,t.isEmptyData=function(e){return"string"==typeof e?0===e.length:0===e.byteLength}},174:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.numToUint8=void 0,t.numToUint8=function(e){return new Uint8Array([(4278190080&e)>>24,(16711680&e)>>16,(65280&e)>>8,255&e])}},558:(e,t)=>{"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.uint32ArrayFrom=void 0,t.uint32ArrayFrom=function(e){if(!Array.from){for(var t=new Uint32Array(e.length);0<e.length;)t[0]=e[0];return t}return Uint32Array.from(e)}},84:(e,t,n)=>{"use strict";n.r(t),n.d(t,{fromUtf8:()=>r,toUtf8:()=>i});const r=e=>"function"==typeof TextEncoder?function(e){return(new TextEncoder).encode(e)}(e):(e=>{const t=[];for(let n=0,r=e.length;n<r;n++){const r=e.charCodeAt(n);if(r<128)t.push(r);else if(r<2048)t.push(r>>6|192,63&r|128);else if(n+1<e.length&&55296==(64512&r)&&56320==(64512&e.charCodeAt(n+1))){const i=65536+((1023&r)<<10)+(1023&e.charCodeAt(++n));t.push(i>>18|240,i>>12&63|128,i>>6&63|128,63&i|128)}else t.push(r>>12|224,r>>6&63|128,63&r|128)}return Uint8Array.from(t)})(e),i=e=>"function"==typeof TextDecoder?function(e){return new TextDecoder("utf-8").decode(e)}(e):(e=>{let t="";for(let n=0,r=e.length;n<r;n++){const r=e[n];if(r<128)t+=String.fromCharCode(r);else if(192<=r&&r<224){const i=e[++n];t+=String.fromCharCode((31&r)<<6|63&i)}else if(240<=r&&r<365){const i="%"+[r,e[++n],e[++n],e[++n]].map((e=>e.toString(16))).join("%");t+=decodeURIComponent(i)}else t+=String.fromCharCode((15&r)<<12|(63&e[++n])<<6|63&e[++n])}return t})(e)},742:(e,t)=>{"use strict";t.byteLength=function(e){var t=a(e),n=t[0],r=t[1];return 3*(n+r)/4-r},t.toByteArray=function(e){var t,n,s=a(e),o=s[0],u=s[1],c=new i(function(e,t,n){return 3*(t+n)/4-n}(0,o,u)),l=0,h=u>0?o-4:o;for(n=0;n<h;n+=4)t=r[e.charCodeAt(n)]<<18|r[e.charCodeAt(n+1)]<<12|r[e.charCodeAt(n+2)]<<6|r[e.charCodeAt(n+3)],c[l++]=t>>16&255,c[l++]=t>>8&255,c[l++]=255&t;return 2===u&&(t=r[e.charCodeAt(n)]<<2|r[e.charCodeAt(n+1)]>>4,c[l++]=255&t),1===u&&(t=r[e.charCodeAt(n)]<<10|r[e.charCodeAt(n+1)]<<4|r[e.charCodeAt(n+2)]>>2,c[l++]=t>>8&255,c[l++]=255&t),c},t.fromByteArray=function(e){for(var t,r=e.length,i=r%3,s=[],o=16383,a=0,c=r-i;a<c;a+=o)s.push(u(e,a,a+o>c?c:a+o));return 1===i?(t=e[r-1],s.push(n[t>>2]+n[t<<4&63]+"==")):2===i&&(t=(e[r-2]<<8)+e[r-1],s.push(n[t>>10]+n[t>>4&63]+n[t<<2&63]+"=")),s.join("")};for(var n=[],r=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,s="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",o=0;o<64;++o)n[o]=s[o],r[s.charCodeAt(o)]=o;function a(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function u(e,t,r){for(var i,s,o=[],a=t;a<r;a+=3)i=(e[a]<<16&16711680)+(e[a+1]<<8&65280)+(255&e[a+2]),o.push(n[(s=i)>>18&63]+n[s>>12&63]+n[s>>6&63]+n[63&s]);return o.join("")}r["-".charCodeAt(0)]=62,r["_".charCodeAt(0)]=63},764:(e,t,n)=>{"use strict";var r=n(742),i=n(645),s=n(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,n){if(!(u.TYPED_ARRAY_SUPPORT||this instanceof u))return new u(e,t,n);if("number"==typeof e){if("string"==typeof t)throw new Error("If encoding is specified then the first argument must be a string");return h(this,e)}return c(this,e,t,n)}function c(e,t,n,r){if("number"==typeof t)throw new TypeError('"value" argument must not be a number');return"undefined"!=typeof ArrayBuffer&&t instanceof ArrayBuffer?function(e,t,n,r){if(t.byteLength,n<0||t.byteLength<n)throw new RangeError("'offset' is out of bounds");if(t.byteLength<n+(r||0))throw new RangeError("'length' is out of bounds");return t=void 0===n&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,n):new Uint8Array(t,n,r),u.TYPED_ARRAY_SUPPORT?(e=t).__proto__=u.prototype:e=f(e,t),e}(e,t,n,r):"string"==typeof t?function(e,t,n){if("string"==typeof n&&""!==n||(n="utf8"),!u.isEncoding(n))throw new TypeError('"encoding" must be a valid string encoding');var r=0|p(t,n),i=(e=a(e,r)).write(t,n);return i!==r&&(e=e.slice(0,i)),e}(e,t,n):function(e,t){if(u.isBuffer(t)){var n=0|d(t.length);return 0===(e=a(e,n)).length||t.copy(e,0,0,n),e}if(t){if("undefined"!=typeof ArrayBuffer&&t.buffer instanceof ArrayBuffer||"length"in t)return"number"!=typeof t.length||(r=t.length)!=r?a(e,0):f(e,t);if("Buffer"===t.type&&s(t.data))return f(e,t.data)}var r;throw new TypeError("First argument must be a string, Buffer, ArrayBuffer, Array, or array-like object.")}(e,t)}function l(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 h(e,t){if(l(t),e=a(e,t<0?0:0|d(t)),!u.TYPED_ARRAY_SUPPORT)for(var n=0;n<t;++n)e[n]=0;return e}function f(e,t){var n=t.length<0?0:0|d(t.length);e=a(e,n);for(var r=0;r<n;r+=1)e[r]=255&t[r];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 n=e.length;if(0===n)return 0;for(var r=!1;;)switch(t){case"ascii":case"latin1":case"binary":return n;case"utf8":case"utf-8":case void 0:return B(e).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*n;case"hex":return n>>>1;case"base64":return $(e).length;default:if(r)return B(e).length;t=(""+t).toLowerCase(),r=!0}}function g(e,t,n){var r=!1;if((void 0===t||t<0)&&(t=0),t>this.length)return"";if((void 0===n||n>this.length)&&(n=this.length),n<=0)return"";if((n>>>=0)<=(t>>>=0))return"";for(e||(e="utf8");;)switch(e){case"hex":return C(this,t,n);case"utf8":case"utf-8":return T(this,t,n);case"ascii":return U(this,t,n);case"latin1":case"binary":return D(this,t,n);case"base64":return I(this,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return P(this,t,n);default:if(r)throw new TypeError("Unknown encoding: "+e);e=(e+"").toLowerCase(),r=!0}}function _(e,t,n){var r=e[t];e[t]=e[n],e[n]=r}function m(e,t,n,r,i){if(0===e.length)return-1;if("string"==typeof n?(r=n,n=0):n>2147483647?n=2147483647:n<-2147483648&&(n=-2147483648),n=+n,isNaN(n)&&(n=i?0:e.length-1),n<0&&(n=e.length+n),n>=e.length){if(i)return-1;n=e.length-1}else if(n<0){if(!i)return-1;n=0}if("string"==typeof t&&(t=u.from(t,r)),u.isBuffer(t))return 0===t.length?-1:y(e,t,n,r,i);if("number"==typeof t)return t&=255,u.TYPED_ARRAY_SUPPORT&&"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(e,t,n):Uint8Array.prototype.lastIndexOf.call(e,t,n):y(e,[t],n,r,i);throw new TypeError("val must be string, number or Buffer")}function y(e,t,n,r,i){var s,o=1,a=e.length,u=t.length;if(void 0!==r&&("ucs2"===(r=String(r).toLowerCase())||"ucs-2"===r||"utf16le"===r||"utf-16le"===r)){if(e.length<2||t.length<2)return-1;o=2,a/=2,u/=2,n/=2}function c(e,t){return 1===o?e[t]:e.readUInt16BE(t*o)}if(i){var l=-1;for(s=n;s<a;s++)if(c(e,s)===c(t,-1===l?0:s-l)){if(-1===l&&(l=s),s-l+1===u)return l*o}else-1!==l&&(s-=s-l),l=-1}else for(n+u>a&&(n=a-u),s=n;s>=0;s--){for(var h=!0,f=0;f<u;f++)if(c(e,s+f)!==c(t,f)){h=!1;break}if(h)return s}return-1}function w(e,t,n,r){n=Number(n)||0;var i=e.length-n;r?(r=Number(r))>i&&(r=i):r=i;var s=t.length;if(s%2!=0)throw new TypeError("Invalid hex string");r>s/2&&(r=s/2);for(var o=0;o<r;++o){var a=parseInt(t.substr(2*o,2),16);if(isNaN(a))return o;e[n+o]=a}return o}function b(e,t,n,r){return q(B(t,e.length-n),e,n,r)}function A(e,t,n,r){return q(function(e){for(var t=[],n=0;n<e.length;++n)t.push(255&e.charCodeAt(n));return t}(t),e,n,r)}function v(e,t,n,r){return A(e,t,n,r)}function E(e,t,n,r){return q($(t),e,n,r)}function S(e,t,n,r){return q(function(e,t){for(var n,r,i,s=[],o=0;o<e.length&&!((t-=2)<0);++o)r=(n=e.charCodeAt(o))>>8,i=n%256,s.push(i),s.push(r);return s}(t,e.length-n),e,n,r)}function I(e,t,n){return 0===t&&n===e.length?r.fromByteArray(e):r.fromByteArray(e.slice(t,n))}function T(e,t,n){n=Math.min(e.length,n);for(var r=[],i=t;i<n;){var s,o,a,u,c=e[i],l=null,h=c>239?4:c>223?3:c>191?2:1;if(i+h<=n)switch(h){case 1:c<128&&(l=c);break;case 2:128==(192&(s=e[i+1]))&&(u=(31&c)<<6|63&s)>127&&(l=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)&&(l=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&&(l=u)}null===l?(l=65533,h=1):l>65535&&(l-=65536,r.push(l>>>10&1023|55296),l=56320|1023&l),r.push(l),i+=h}return function(e){var t=e.length;if(t<=R)return String.fromCharCode.apply(String,e);for(var n="",r=0;r<t;)n+=String.fromCharCode.apply(String,e.slice(r,r+=R));return n}(r)}t.lW=u,t.h2=50,u.TYPED_ARRAY_SUPPORT=void 0!==n.g.TYPED_ARRAY_SUPPORT?n.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,n){return c(null,e,t,n)},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,n){return function(e,t,n,r){return l(t),t<=0?a(e,t):void 0!==n?"string"==typeof r?a(e,t).fill(n,r):a(e,t).fill(n):a(e,t)}(null,e,t,n)},u.allocUnsafe=function(e){return h(null,e)},u.allocUnsafeSlow=function(e){return h(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 n=e.length,r=t.length,i=0,s=Math.min(n,r);i<s;++i)if(e[i]!==t[i]){n=e[i],r=t[i];break}return n<r?-1:r<n?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 n;if(void 0===t)for(t=0,n=0;n<e.length;++n)t+=e[n].length;var r=u.allocUnsafe(t),i=0;for(n=0;n<e.length;++n){var o=e[n];if(!u.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(r,i),i+=o.length}return r},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)_(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)_(this,t,t+3),_(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)_(this,t,t+7),_(this,t+1,t+6),_(this,t+2,t+5),_(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="",n=t.h2;return this.length>0&&(e=this.toString("hex",0,n).match(/.{2}/g).join(" "),this.length>n&&(e+=" ... ")),"<Buffer "+e+">"},u.prototype.compare=function(e,t,n,r,i){if(!u.isBuffer(e))throw new TypeError("Argument must be a Buffer");if(void 0===t&&(t=0),void 0===n&&(n=e?e.length:0),void 0===r&&(r=0),void 0===i&&(i=this.length),t<0||n>e.length||r<0||i>this.length)throw new RangeError("out of range index");if(r>=i&&t>=n)return 0;if(r>=i)return-1;if(t>=n)return 1;if(this===e)return 0;for(var s=(i>>>=0)-(r>>>=0),o=(n>>>=0)-(t>>>=0),a=Math.min(s,o),c=this.slice(r,i),l=e.slice(t,n),h=0;h<a;++h)if(c[h]!==l[h]){s=c[h],o=l[h];break}return s<o?-1:o<s?1:0},u.prototype.includes=function(e,t,n){return-1!==this.indexOf(e,t,n)},u.prototype.indexOf=function(e,t,n){return m(this,e,t,n,!0)},u.prototype.lastIndexOf=function(e,t,n){return m(this,e,t,n,!1)},u.prototype.write=function(e,t,n,r){if(void 0===t)r="utf8",n=this.length,t=0;else if(void 0===n&&"string"==typeof t)r=t,n=this.length,t=0;else{if(!isFinite(t))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");t|=0,isFinite(n)?(n|=0,void 0===r&&(r="utf8")):(r=n,n=void 0)}var i=this.length-t;if((void 0===n||n>i)&&(n=i),e.length>0&&(n<0||t<0)||t>this.length)throw new RangeError("Attempt to write outside buffer bounds");r||(r="utf8");for(var s=!1;;)switch(r){case"hex":return w(this,e,t,n);case"utf8":case"utf-8":return b(this,e,t,n);case"ascii":return A(this,e,t,n);case"latin1":case"binary":return v(this,e,t,n);case"base64":return E(this,e,t,n);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return S(this,e,t,n);default:if(s)throw new TypeError("Unknown encoding: "+r);r=(""+r).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,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(127&e[i]);return r}function D(e,t,n){var r="";n=Math.min(e.length,n);for(var i=t;i<n;++i)r+=String.fromCharCode(e[i]);return r}function C(e,t,n){var r,i=e.length;(!t||t<0)&&(t=0),(!n||n<0||n>i)&&(n=i);for(var s="",o=t;o<n;++o)s+=(r=e[o])<16?"0"+r.toString(16):r.toString(16);return s}function P(e,t,n){for(var r=e.slice(t,n),i="",s=0;s<r.length;s+=2)i+=String.fromCharCode(r[s]+256*r[s+1]);return i}function N(e,t,n){if(e%1!=0||e<0)throw new RangeError("offset is not uint");if(e+t>n)throw new RangeError("Trying to access beyond buffer length")}function k(e,t,n,r,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(n+r>e.length)throw new RangeError("Index out of range")}function O(e,t,n,r){t<0&&(t=65535+t+1);for(var i=0,s=Math.min(e.length-n,2);i<s;++i)e[n+i]=(t&255<<8*(r?i:1-i))>>>8*(r?i:1-i)}function L(e,t,n,r){t<0&&(t=4294967295+t+1);for(var i=0,s=Math.min(e.length-n,4);i<s;++i)e[n+i]=t>>>8*(r?i:3-i)&255}function M(e,t,n,r,i,s){if(n+r>e.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("Index out of range")}function V(e,t,n,r,s){return s||M(e,0,n,4),i.write(e,t,n,r,23,4),n+4}function F(e,t,n,r,s){return s||M(e,0,n,8),i.write(e,t,n,r,52,8),n+8}u.prototype.slice=function(e,t){var n,r=this.length;if((e=~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),(t=void 0===t?r:~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),t<e&&(t=e),u.TYPED_ARRAY_SUPPORT)(n=this.subarray(e,t)).__proto__=u.prototype;else{var i=t-e;n=new u(i,void 0);for(var s=0;s<i;++s)n[s]=this[s+e]}return n},u.prototype.readUIntLE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r},u.prototype.readUIntBE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e+--t],i=1;t>0&&(i*=256);)r+=this[e+--t]*i;return r},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,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=this[e],i=1,s=0;++s<t&&(i*=256);)r+=this[e+s]*i;return r>=(i*=128)&&(r-=Math.pow(2,8*t)),r},u.prototype.readIntBE=function(e,t,n){e|=0,t|=0,n||N(e,t,this.length);for(var r=t,i=1,s=this[e+--r];r>0&&(i*=256);)s+=this[e+--r]*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 n=this[e]|this[e+1]<<8;return 32768&n?4294901760|n:n},u.prototype.readInt16BE=function(e,t){t||N(e,2,this.length);var n=this[e+1]|this[e]<<8;return 32768&n?4294901760|n:n},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,n,r){e=+e,t|=0,n|=0,r||k(this,e,t,n,Math.pow(2,8*n)-1,0);var i=1,s=0;for(this[t]=255&e;++s<n&&(i*=256);)this[t+s]=e/i&255;return t+n},u.prototype.writeUIntBE=function(e,t,n,r){e=+e,t|=0,n|=0,r||k(this,e,t,n,Math.pow(2,8*n)-1,0);var i=n-1,s=1;for(this[t+i]=255&e;--i>=0&&(s*=256);)this[t+i]=e/s&255;return t+n},u.prototype.writeUInt8=function(e,t,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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):L(this,e,t,!0),t+4},u.prototype.writeUInt32BE=function(e,t,n){return e=+e,t|=0,n||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):L(this,e,t,!1),t+4},u.prototype.writeIntLE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);k(this,e,t,n,i-1,-i)}var s=0,o=1,a=0;for(this[t]=255&e;++s<n&&(o*=256);)e<0&&0===a&&0!==this[t+s-1]&&(a=1),this[t+s]=(e/o>>0)-a&255;return t+n},u.prototype.writeIntBE=function(e,t,n,r){if(e=+e,t|=0,!r){var i=Math.pow(2,8*n-1);k(this,e,t,n,i-1,-i)}var s=n-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+n},u.prototype.writeInt8=function(e,t,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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,n){return e=+e,t|=0,n||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):L(this,e,t,!0),t+4},u.prototype.writeInt32BE=function(e,t,n){return e=+e,t|=0,n||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):L(this,e,t,!1),t+4},u.prototype.writeFloatLE=function(e,t,n){return V(this,e,t,!0,n)},u.prototype.writeFloatBE=function(e,t,n){return V(this,e,t,!1,n)},u.prototype.writeDoubleLE=function(e,t,n){return F(this,e,t,!0,n)},u.prototype.writeDoubleBE=function(e,t,n){return F(this,e,t,!1,n)},u.prototype.copy=function(e,t,n,r){if(n||(n=0),r||0===r||(r=this.length),t>=e.length&&(t=e.length),t||(t=0),r>0&&r<n&&(r=n),r===n)return 0;if(0===e.length||0===this.length)return 0;if(t<0)throw new RangeError("targetStart out of bounds");if(n<0||n>=this.length)throw new RangeError("sourceStart out of bounds");if(r<0)throw new RangeError("sourceEnd out of bounds");r>this.length&&(r=this.length),e.length-t<r-n&&(r=e.length-t+n);var i,s=r-n;if(this===e&&n<t&&t<r)for(i=s-1;i>=0;--i)e[i+t]=this[i+n];else if(s<1e3||!u.TYPED_ARRAY_SUPPORT)for(i=0;i<s;++i)e[i+t]=this[i+n];else Uint8Array.prototype.set.call(e,this.subarray(n,n+s),t);return s},u.prototype.fill=function(e,t,n,r){if("string"==typeof e){if("string"==typeof t?(r=t,t=0,n=this.length):"string"==typeof n&&(r=n,n=this.length),1===e.length){var i=e.charCodeAt(0);i<256&&(e=i)}if(void 0!==r&&"string"!=typeof r)throw new TypeError("encoding must be a string");if("string"==typeof r&&!u.isEncoding(r))throw new TypeError("Unknown encoding: "+r)}else"number"==typeof e&&(e&=255);if(t<0||this.length<t||this.length<n)throw new RangeError("Out of range index");if(n<=t)return this;var s;if(t>>>=0,n=void 0===n?this.length:n>>>0,e||(e=0),"number"==typeof e)for(s=t;s<n;++s)this[s]=e;else{var o=u.isBuffer(e)?e:B(new u(e,r).toString()),a=o.length;for(s=0;s<n-t;++s)this[s+t]=o[s%a]}return this};var x=/[^+\/0-9A-Za-z-_]/g;function B(e,t){var n;t=t||1/0;for(var r=e.length,i=null,s=[],o=0;o<r;++o){if((n=e.charCodeAt(o))>55295&&n<57344){if(!i){if(n>56319){(t-=3)>-1&&s.push(239,191,189);continue}if(o+1===r){(t-=3)>-1&&s.push(239,191,189);continue}i=n;continue}if(n<56320){(t-=3)>-1&&s.push(239,191,189),i=n;continue}n=65536+(i-55296<<10|n-56320)}else i&&(t-=3)>-1&&s.push(239,191,189);if(i=null,n<128){if((t-=1)<0)break;s.push(n)}else if(n<2048){if((t-=2)<0)break;s.push(n>>6|192,63&n|128)}else if(n<65536){if((t-=3)<0)break;s.push(n>>12|224,n>>6&63|128,63&n|128)}else{if(!(n<1114112))throw new Error("Invalid code point");if((t-=4)<0)break;s.push(n>>18|240,n>>12&63|128,n>>6&63|128,63&n|128)}}return s}function $(e){return r.toByteArray(function(e){if((e=function(e){return e.trim?e.trim():e.replace(/^\s+|\s+$/g,"")}(e).replace(x,"")).length<2)return"";for(;e.length%4!=0;)e+="=";return e}(e))}function q(e,t,n,r){for(var i=0;i<r&&!(i+n>=t.length||i>=e.length);++i)t[i+n]=e[i];return i}},645:(e,t)=>{t.read=function(e,t,n,r,i){var s,o,a=8*i-r-1,u=(1<<a)-1,c=u>>1,l=-7,h=n?i-1:0,f=n?-1:1,d=e[t+h];for(h+=f,s=d&(1<<-l)-1,d>>=-l,l+=a;l>0;s=256*s+e[t+h],h+=f,l-=8);for(o=s&(1<<-l)-1,s>>=-l,l+=r;l>0;o=256*o+e[t+h],h+=f,l-=8);if(0===s)s=1-c;else{if(s===u)return o?NaN:1/0*(d?-1:1);o+=Math.pow(2,r),s-=c}return(d?-1:1)*o*Math.pow(2,s-r)},t.write=function(e,t,n,r,i,s){var o,a,u,c=8*s-i-1,l=(1<<c)-1,h=l>>1,f=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,d=r?0:s-1,p=r?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=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(u=Math.pow(2,-o))<1&&(o--,u*=2),(t+=o+h>=1?f/u:f*Math.pow(2,1-h))*u>=2&&(o++,u/=2),o+h>=l?(a=0,o=l):o+h>=1?(a=(t*u-1)*Math.pow(2,i),o+=h):(a=t*Math.pow(2,h-1)*Math.pow(2,i),o=0));i>=8;e[n+d]=255&a,d+=p,a/=256,i-=8);for(o=o<<i|a,c+=i;c>0;e[n+d]=255&o,d+=p,o/=256,c-=8);e[n+d-p]|=128*g}},826:e=>{var t={}.toString;e.exports=Array.isArray||function(e){return"[object Array]"==t.call(e)}},204:(e,t,n)=>{e.exports=self.fetch||(self.fetch=n(869).default||n(869))},808:(e,t,n)=>{var r,i,s;void 0===(i="function"==typeof(r=s=function(){function e(){for(var e=0,t={};e<arguments.length;e++){var n=arguments[e];for(var r in n)t[r]=n[r]}return t}function t(e){return e.replace(/(%[0-9A-Z]{2})+/g,decodeURIComponent)}return function n(r){function i(){}function s(t,n,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(n);/^[\{\[]/.test(o)&&(n=o)}catch(e){}n=r.write?r.write(n,t):encodeURIComponent(String(n)).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+"="+n+a}}function o(e,n){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("=");n||'"'!==u.charAt(0)||(u=u.slice(1,-1));try{var c=t(a[0]);if(u=(r.read||r)(u,c)||t(u),n)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,n){s(t,"",e(n,{expires:-1}))},i.defaults={},i.withConverter=n,i}((function(){}))})?r.call(t,n,t,e):r)||(e.exports=i),e.exports=s()},655:(e,t,n)=>{"use strict";n.r(t),n.d(t,{__assign:()=>s,__asyncDelegator:()=>b,__asyncGenerator:()=>w,__asyncValues:()=>A,__await:()=>y,__awaiter:()=>l,__classPrivateFieldGet:()=>I,__classPrivateFieldSet:()=>T,__createBinding:()=>f,__decorate:()=>a,__exportStar:()=>d,__extends:()=>i,__generator:()=>h,__importDefault:()=>S,__importStar:()=>E,__makeTemplateObject:()=>v,__metadata:()=>c,__param:()=>u,__read:()=>g,__rest:()=>o,__spread:()=>_,__spreadArrays:()=>m,__values:()=>p});var r=function(e,t){return r=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var n in t)t.hasOwnProperty(n)&&(e[n]=t[n])},r(e,t)};function i(e,t){function n(){this.constructor=e}r(e,t),e.prototype=null===t?Object.create(t):(n.prototype=t.prototype,new n)}var s=function(){return s=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var i in t=arguments[n])Object.prototype.hasOwnProperty.call(t,i)&&(e[i]=t[i]);return e},s.apply(this,arguments)};function o(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var i=0;for(r=Object.getOwnPropertySymbols(e);i<r.length;i++)t.indexOf(r[i])<0&&Object.prototype.propertyIsEnumerable.call(e,r[i])&&(n[r[i]]=e[r[i]])}return n}function a(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o}function u(e,t){return function(n,r){t(n,r,e)}}function c(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)}function l(e,t,n,r){return new(n||(n=Promise))((function(i,s){function o(e){try{u(r.next(e))}catch(e){s(e)}}function a(e){try{u(r.throw(e))}catch(e){s(e)}}function u(e){var t;e.done?i(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(o,a)}u((r=r.apply(e,t||[])).next())}))}function h(e,t){var n,r,i,s,o={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return s={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(s[Symbol.iterator]=function(){return this}),s;function a(s){return function(a){return function(s){if(n)throw new TypeError("Generator is already executing.");for(;o;)try{if(n=1,r&&(i=2&s[0]?r.return:s[0]?r.throw||((i=r.return)&&i.call(r),0):r.next)&&!(i=i.call(r,s[1])).done)return i;switch(r=0,i&&(s=[2&s[0],i.value]),s[0]){case 0:case 1:i=s;break;case 4:return o.label++,{value:s[1],done:!1};case 5:o.label++,r=s[1],s=[0];continue;case 7:s=o.ops.pop(),o.trys.pop();continue;default:if(!((i=(i=o.trys).length>0&&i[i.length-1])||6!==s[0]&&2!==s[0])){o=0;continue}if(3===s[0]&&(!i||s[1]>i[0]&&s[1]<i[3])){o.label=s[1];break}if(6===s[0]&&o.label<i[1]){o.label=i[1],i=s;break}if(i&&o.label<i[2]){o.label=i[2],o.ops.push(s);break}i[2]&&o.ops.pop(),o.trys.pop();continue}s=t.call(e,o)}catch(e){s=[6,e],r=0}finally{n=i=0}if(5&s[0])throw s[1];return{value:s[0]?s[1]:void 0,done:!0}}([s,a])}}}function f(e,t,n,r){void 0===r&&(r=n),e[r]=t[n]}function d(e,t){for(var n in e)"default"===n||t.hasOwnProperty(n)||(t[n]=e[n])}function p(e){var t="function"==typeof Symbol&&Symbol.iterator,n=t&&e[t],r=0;if(n)return n.call(e);if(e&&"number"==typeof e.length)return{next:function(){return e&&r>=e.length&&(e=void 0),{value:e&&e[r++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function g(e,t){var n="function"==typeof Symbol&&e[Symbol.iterator];if(!n)return e;var r,i,s=n.call(e),o=[];try{for(;(void 0===t||t-- >0)&&!(r=s.next()).done;)o.push(r.value)}catch(e){i={error:e}}finally{try{r&&!r.done&&(n=s.return)&&n.call(s)}finally{if(i)throw i.error}}return o}function _(){for(var e=[],t=0;t<arguments.length;t++)e=e.concat(g(arguments[t]));return e}function m(){for(var e=0,t=0,n=arguments.length;t<n;t++)e+=arguments[t].length;var r=Array(e),i=0;for(t=0;t<n;t++)for(var s=arguments[t],o=0,a=s.length;o<a;o++,i++)r[i]=s[o];return r}function y(e){return this instanceof y?(this.v=e,this):new y(e)}function w(e,t,n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var r,i=n.apply(e,t||[]),s=[];return r={},o("next"),o("throw"),o("return"),r[Symbol.asyncIterator]=function(){return this},r;function o(e){i[e]&&(r[e]=function(t){return new Promise((function(n,r){s.push([e,t,n,r])>1||a(e,t)}))})}function a(e,t){try{(n=i[e](t)).value instanceof y?Promise.resolve(n.value.v).then(u,c):l(s[0][2],n)}catch(e){l(s[0][3],e)}var n}function u(e){a("next",e)}function c(e){a("throw",e)}function l(e,t){e(t),s.shift(),s.length&&a(s[0][0],s[0][1])}}function b(e){var t,n;return t={},r("next"),r("throw",(function(e){throw e})),r("return"),t[Symbol.iterator]=function(){return this},t;function r(r,i){t[r]=e[r]?function(t){return(n=!n)?{value:y(e[r](t)),done:"return"===r}:i?i(t):t}:i}}function A(e){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var t,n=e[Symbol.asyncIterator];return n?n.call(e):(e=p(e),t={},r("next"),r("throw"),r("return"),t[Symbol.asyncIterator]=function(){return this},t);function r(n){t[n]=e[n]&&function(t){return new Promise((function(r,i){!function(e,t,n,r){Promise.resolve(r).then((function(t){e({value:t,done:n})}),t)}(r,i,(t=e[n](t)).done,t.value)}))}}}function v(e,t){return Object.defineProperty?Object.defineProperty(e,"raw",{value:t}):e.raw=t,e}function E(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n in e)Object.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t.default=e,t}function S(e){return e&&e.__esModule?e:{default:e}}function I(e,t){if(!t.has(e))throw new TypeError("attempted to get private field on non-instance");return t.get(e)}function T(e,t,n){if(!t.has(e))throw new TypeError("attempted to set private field on non-instance");return t.set(e,n),n}},869:(e,t,n)=>{"use strict";function r(e,t){return t=t||{},new Promise((function(n,r){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,n){s.push(t=t.toLowerCase()),o.push([t,n]),a[t]=a[t]?a[t]+","+n:n})),n(u())},i.onerror=r,i.withCredentials="include"==t.credentials,t.headers)i.setRequestHeader(c,t.headers[c]);i.send(t.body||null)}))}n.r(t),n.d(t,{default:()=>r})},249:()=>{}},t={};function n(r){var i=t[r];if(void 0!==i)return i.exports;var s=t[r]={exports:{}};return e[r](s,s.exports,n),s.exports}n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";n.r(r),n.d(r,{Skapi:()=>Bt,SkapiError:()=>ee});var e,t=function(){function e(e){var t=e||{},n=t.ValidationData,r=t.Username,i=t.Password,s=t.AuthParameters,o=t.ClientMetadata;this.validationData=n||{},this.authParameters=s||{},this.clientMetadata=o||{},this.username=r,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=n(764);if("undefined"!=typeof window&&window.crypto&&(e=window.crypto),!e&&"undefined"!=typeof window&&window.msCrypto&&(e=window.msCrypto),!e&&void 0!==n.g&&n.g.crypto&&(e=n.g.crypto),!e)try{e=n(249)}catch(e){}function s(){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 o=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 n=[],r=0;r<t;r+=4)n.push(s());return new e(n,t)},t.toString=function(){return function(e){for(var t=e.words,n=e.sigBytes,r=[],i=0;i<n;i++){var s=t[i>>>2]>>>24-i%4*8&255;r.push((s>>>4).toString(16)),r.push((15&s).toString(16))}return r.join("")}(this)},e}(),a=n(938);const u=c;function c(e,t){null!=e&&this.fromString(e,t)}function l(){return new c(null)}var h,f="undefined"!=typeof navigator;f&&"Microsoft Internet Explorer"==navigator.appName?(c.prototype.am=function(e,t,n,r,i,s){for(var o=32767&t,a=t>>15;--s>=0;){var u=32767&this[e],c=this[e++]>>15,l=a*u+c*o;i=((u=o*u+((32767&l)<<15)+n[r]+(1073741823&i))>>>30)+(l>>>15)+a*c+(i>>>30),n[r++]=1073741823&u}return i},h=30):f&&"Netscape"!=navigator.appName?(c.prototype.am=function(e,t,n,r,i,s){for(;--s>=0;){var o=t*this[e++]+n[r]+i;i=Math.floor(o/67108864),n[r++]=67108863&o}return i},h=26):(c.prototype.am=function(e,t,n,r,i,s){for(var o=16383&t,a=t>>14;--s>=0;){var u=16383&this[e],c=this[e++]>>14,l=a*u+c*o;i=((u=o*u+((16383&l)<<14)+n[r]+i)>>28)+(l>>14)+a*c,n[r++]=268435455&u}return i},h=28),c.prototype.DB=h,c.prototype.DM=(1<<h)-1,c.prototype.DV=1<<h,c.prototype.FV=Math.pow(2,52),c.prototype.F1=52-h,c.prototype.F2=2*h-52;var d,p,g=new Array;for(d="0".charCodeAt(0),p=0;p<=9;++p)g[d++]=p;for(d="a".charCodeAt(0),p=10;p<36;++p)g[d++]=p;for(d="A".charCodeAt(0),p=10;p<36;++p)g[d++]=p;function _(e){return"0123456789abcdefghijklmnopqrstuvwxyz".charAt(e)}function m(e,t){var n=g[e.charCodeAt(t)];return null==n?-1:n}function y(e){var t=l();return t.fromInt(e),t}function w(e){var t,n=1;return 0!=(t=e>>>16)&&(e=t,n+=16),0!=(t=e>>8)&&(e=t,n+=8),0!=(t=e>>4)&&(e=t,n+=4),0!=(t=e>>2)&&(e=t,n+=2),0!=(t=e>>1)&&(e=t,n+=1),n}function b(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 A(e){return i.lW.from((new o).random(e).toString(),"hex")}b.prototype.convert=function(e){var t=l();return e.abs().dlShiftTo(this.m.t,t),t.divRemTo(this.m,null,t),e.s<0&&t.compareTo(c.ZERO)>0&&this.m.subTo(t,t),t},b.prototype.revert=function(e){var t=l();return e.copyTo(t),this.reduce(t),t},b.prototype.reduce=function(e){for(;e.t<=this.mt2;)e[e.t++]=0;for(var t=0;t<this.m.t;++t){var n=32767&e[t],r=n*this.mpl+((n*this.mph+(e[t]>>15)*this.mpl&this.um)<<15)&e.DM;for(e[n=t+this.m.t]+=this.m.am(0,r,e,t,0,this.m.t);e[n]>=e.DV;)e[n]-=e.DV,e[++n]++}e.clamp(),e.drShiftTo(this.m.t,e),e.compareTo(this.m)>=0&&e.subTo(this.m,e)},b.prototype.mulTo=function(e,t,n){e.multiplyTo(t,n),this.reduce(n)},b.prototype.sqrTo=function(e,t){e.squareTo(t),this.reduce(t)},c.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},c.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},c.prototype.fromString=function(e,t){var n;if(16==t)n=4;else if(8==t)n=3;else if(2==t)n=1;else if(32==t)n=5;else{if(4!=t)throw new Error("Only radix 2, 4, 8, 16, 32 are supported");n=2}this.t=0,this.s=0;for(var r=e.length,i=!1,s=0;--r>=0;){var o=m(e,r);o<0?"-"==e.charAt(r)&&(i=!0):(i=!1,0==s?this[this.t++]=o:s+n>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+=n)>=this.DB&&(s-=this.DB))}this.clamp(),i&&c.ZERO.subTo(this,this)},c.prototype.clamp=function(){for(var e=this.s&this.DM;this.t>0&&this[this.t-1]==e;)--this.t},c.prototype.dlShiftTo=function(e,t){var n;for(n=this.t-1;n>=0;--n)t[n+e]=this[n];for(n=e-1;n>=0;--n)t[n]=0;t.t=this.t+e,t.s=this.s},c.prototype.drShiftTo=function(e,t){for(var n=e;n<this.t;++n)t[n-e]=this[n];t.t=Math.max(this.t-e,0),t.s=this.s},c.prototype.lShiftTo=function(e,t){var n,r=e%this.DB,i=this.DB-r,s=(1<<i)-1,o=Math.floor(e/this.DB),a=this.s<<r&this.DM;for(n=this.t-1;n>=0;--n)t[n+o+1]=this[n]>>i|a,a=(this[n]&s)<<r;for(n=o-1;n>=0;--n)t[n]=0;t[o]=a,t.t=this.t+o+1,t.s=this.s,t.clamp()},c.prototype.rShiftTo=function(e,t){t.s=this.s;var n=Math.floor(e/this.DB);if(n>=this.t)t.t=0;else{var r=e%this.DB,i=this.DB-r,s=(1<<r)-1;t[0]=this[n]>>r;for(var o=n+1;o<this.t;++o)t[o-n-1]|=(this[o]&s)<<i,t[o-n]=this[o]>>r;r>0&&(t[this.t-n-1]|=(this.s&s)<<i),t.t=this.t-n,t.clamp()}},c.prototype.subTo=function(e,t){for(var n=0,r=0,i=Math.min(e.t,this.t);n<i;)r+=this[n]-e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r-=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r-=e[n],t[n++]=r&this.DM,r>>=this.DB;r-=e.s}t.s=r<0?-1:0,r<-1?t[n++]=this.DV+r:r>0&&(t[n++]=r),t.t=n,t.clamp()},c.prototype.multiplyTo=function(e,t){var n=this.abs(),r=e.abs(),i=n.t;for(t.t=i+r.t;--i>=0;)t[i]=0;for(i=0;i<r.t;++i)t[i+n.t]=n.am(0,r[i],t,i,0,n.t);t.s=0,t.clamp(),this.s!=e.s&&c.ZERO.subTo(t,t)},c.prototype.squareTo=function(e){for(var t=this.abs(),n=e.t=2*t.t;--n>=0;)e[n]=0;for(n=0;n<t.t-1;++n){var r=t.am(n,t[n],e,2*n,0,1);(e[n+t.t]+=t.am(n+1,2*t[n],e,2*n+1,r,t.t-n-1))>=t.DV&&(e[n+t.t]-=t.DV,e[n+t.t+1]=1)}e.t>0&&(e[e.t-1]+=t.am(n,t[n],e,2*n,0,1)),e.s=0,e.clamp()},c.prototype.divRemTo=function(e,t,n){var r=e.abs();if(!(r.t<=0)){var i=this.abs();if(i.t<r.t)return null!=t&&t.fromInt(0),void(null!=n&&this.copyTo(n));null==n&&(n=l());var s=l(),o=this.s,a=e.s,u=this.DB-w(r[r.t-1]);u>0?(r.lShiftTo(u,s),i.lShiftTo(u,n)):(r.copyTo(s),i.copyTo(n));var h=s.t,f=s[h-1];if(0!=f){var d=f*(1<<this.F1)+(h>1?s[h-2]>>this.F2:0),p=this.FV/d,g=(1<<this.F1)/d,_=1<<this.F2,m=n.t,y=m-h,b=null==t?l():t;for(s.dlShiftTo(y,b),n.compareTo(b)>=0&&(n[n.t++]=1,n.subTo(b,n)),c.ONE.dlShiftTo(h,b),b.subTo(s,s);s.t<h;)s[s.t++]=0;for(;--y>=0;){var A=n[--m]==f?this.DM:Math.floor(n[m]*p+(n[m-1]+_)*g);if((n[m]+=s.am(0,A,n,y,0,h))<A)for(s.dlShiftTo(y,b),n.subTo(b,n);n[m]<--A;)n.subTo(b,n)}null!=t&&(n.drShiftTo(h,t),o!=a&&c.ZERO.subTo(t,t)),n.t=h,n.clamp(),u>0&&n.rShiftTo(u,n),o<0&&c.ZERO.subTo(n,n)}}},c.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},c.prototype.addTo=function(e,t){for(var n=0,r=0,i=Math.min(e.t,this.t);n<i;)r+=this[n]+e[n],t[n++]=r&this.DM,r>>=this.DB;if(e.t<this.t){for(r+=e.s;n<this.t;)r+=this[n],t[n++]=r&this.DM,r>>=this.DB;r+=this.s}else{for(r+=this.s;n<e.t;)r+=e[n],t[n++]=r&this.DM,r>>=this.DB;r+=e.s}t.s=r<0?-1:0,r>0?t[n++]=r:r<-1&&(t[n++]=this.DV+r),t.t=n,t.clamp()},c.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 n,r=(1<<t)-1,i=!1,s="",o=this.t,a=this.DB-o*this.DB%t;if(o-- >0)for(a<this.DB&&(n=this[o]>>a)>0&&(i=!0,s=_(n));o>=0;)a<t?(n=(this[o]&(1<<a)-1)<<t-a,n|=this[--o]>>(a+=this.DB-t)):(n=this[o]>>(a-=t)&r,a<=0&&(a+=this.DB,--o)),n>0&&(i=!0),i&&(s+=_(n));return i?s:"0"},c.prototype.negate=function(){var e=l();return c.ZERO.subTo(this,e),e},c.prototype.abs=function(){return this.s<0?this.negate():this},c.prototype.compareTo=function(e){var t=this.s-e.s;if(0!=t)return t;var n=this.t;if(0!=(t=n-e.t))return this.s<0?-t:t;for(;--n>=0;)if(0!=(t=this[n]-e[n]))return t;return 0},c.prototype.bitLength=function(){return this.t<=0?0:this.DB*(this.t-1)+w(this[this.t-1]^this.s&this.DM)},c.prototype.mod=function(e){var t=l();return this.abs().divRemTo(e,null,t),this.s<0&&t.compareTo(c.ZERO)>0&&e.subTo(t,t),t},c.prototype.equals=function(e){return 0==this.compareTo(e)},c.prototype.add=function(e){var t=l();return this.addTo(e,t),t},c.prototype.subtract=function(e){var t=l();return this.subTo(e,t),t},c.prototype.multiply=function(e){var t=l();return this.multiplyTo(e,t),t},c.prototype.divide=function(e){var t=l();return this.divRemTo(e,t,null),t},c.prototype.modPow=function(e,t,n){var r,i=e.bitLength(),s=y(1),o=new b(t);if(i<=0)return s;r=i<18?1:i<48?3:i<144?4:i<768?5:6;var a=new Array,u=3,c=r-1,h=(1<<r)-1;if(a[1]=o.convert(this),r>1){var f=l();for(o.sqrTo(a[1],f);u<=h;)a[u]=l(),o.mulTo(f,a[u-2],a[u]),u+=2}var d,p,g=e.t-1,_=!0,m=l();for(i=w(e[g])-1;g>=0;){for(i>=c?d=e[g]>>i-c&h:(d=(e[g]&(1<<i+1)-1)<<c-i,g>0&&(d|=e[g-1]>>this.DB+i-c)),u=r;0==(1&d);)d>>=1,--u;if((i-=u)<0&&(i+=this.DB,--g),_)a[d].copyTo(s),_=!1;else{for(;u>1;)o.sqrTo(s,m),o.sqrTo(m,s),u-=2;u>0?o.sqrTo(s,m):(p=s,s=m,m=p),o.mulTo(m,a[d],s)}for(;g>=0&&0==(e[g]&1<<i);)o.sqrTo(s,m),p=s,s=m,m=p,--i<0&&(i=this.DB-1,--g)}var A=o.revert(s);return n(null,A),A},c.ZERO=y(0),c.ONE=y(1);var v=/^[89a-f]/i,E=function(){function e(e){this.N=new u("FFFFFFFFFFFFFFFFC90FDAA22168C234C4C6628B80DC1CD129024E088A67CC74020BBEA63B139B22514A08798E3404DDEF9519B3CD3A431B302B0A6DF25F14374FE1356D6D51C245E485B576625E7EC6F44C42E9A637ED6B0BFF5CB6F406B7EDEE386BFB5A899FA5AE9F24117C4B1FE649286651ECE45B3DC2007CB8A163BF0598DA48361C55D39A69163FA8FD24CF5F83655D23DCA3AD961C62F356208552BB9ED529077096966D670C354E4ABC9804F1746C08CA18217C32905E462E36CE3BE39E772C180E86039B2783A2EC07A28FB5C55DF06F4C52C9DE2BCBF6955817183995497CEA956AE515D2261898FA051015728E5A8AAAC42DAD33170D04507A33A85521ABDF1CBA64ECFB850458DBEF0A8AEA71575D060C7DB3970F85A6E1E4C7ABF5AE8CDB0933D71E8C94E04A25619DCEE3D2261AD2EE6BF12FFA06D98A0864D87602733EC86A64521F2B18177B200CBBE117577A615D6C770988C0BAD946E208E24FA074E5AB3143DB5BFCE0FD108E4B82D120A93AD2CAFFFFFFFFFFFFFFFF",16),this.g=new u("2",16),this.k=new u(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(n,r){n&&e(n,null),t.largeAValue=r,e(null,t.largeAValue)}))},t.generateRandomSmallA=function(){var e=A(128).toString("hex");return new u(e,16)},t.generateRandomString=function(){return A(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,n){var r=this;this.randomPassword=this.generateRandomString();var i=""+e+t+":"+this.randomPassword,s=this.hash(i),o=A(16).toString("hex");this.SaltToHashDevices=this.padHex(new u(o,16)),this.g.modPow(new u(this.hexHash(this.SaltToHashDevices+s),16),this.N,(function(e,t){e&&n(e,null),r.verifierDevices=r.padHex(t),n(null,null)}))},t.calculateA=function(e,t){var n=this;this.g.modPow(e,this.N,(function(e,r){e&&t(e,null),r.mod(n.N).equals(u.ZERO)&&t(new Error("Illegal paramater. A mod N cannot be 0."),null),t(null,r)}))},t.calculateU=function(e,t){return this.UHexHash=this.hexHash(this.padHex(e)+this.padHex(t)),new u(this.UHexHash,16)},t.hash=function(e){var t=new a.Sha256;t.update(e);var n=t.digestSync(),r=i.lW.from(n).toString("hex");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 n=i.lW.concat([this.infoBits,i.lW.from(String.fromCharCode(1),"utf8")]),r=new a.Sha256(t);r.update(e);var s=r.digestSync(),o=new a.Sha256(s);return o.update(n),o.digestSync().slice(0,16)},t.getPasswordAuthenticationKey=function(e,t,n,r,s){var o=this;if(n.mod(this.N).equals(u.ZERO))throw new Error("B cannot be zero.");if(this.UValue=this.calculateU(this.largeAValue,n),this.UValue.equals(u.ZERO))throw new Error("U cannot be zero.");var a=""+this.poolName+e+":"+t,c=this.hash(a),l=new u(this.hexHash(this.padHex(r)+c),16);this.calculateS(l,n,(function(e,t){e&&s(e,null);var n=o.computehkdf(i.lW.from(o.padHex(t),"hex"),i.lW.from(o.padHex(o.UValue),"hex"));s(null,n)}))},t.calculateS=function(e,t,n){var r=this;this.g.modPow(e,this.N,(function(i,s){i&&n(i,null),t.subtract(r.k.multiply(s)).modPow(r.smallAValue.add(r.UValue.multiply(e)),r.N,(function(e,t){e&&n(e,null),n(null,t.mod(r.N))}))}))},t.getNewPasswordRequiredChallengeUserAttributePrefix=function(){return"userAttributes."},t.padHex=function(e){if(!(e instanceof u))throw new Error("Not a BigInteger");var t=e.compareTo(u.ZERO)<0,n=e.abs().toString(16);if(n=n.length%2!=0?"0"+n:n,n=v.test(n)?"00"+n:n,t){var r=n.split("").map((function(e){var t=15&~parseInt(e,16);return"0123456789ABCDEF".charAt(t)})).join("");(n=new u(r,16).add(u.ONE).toString(16)).toUpperCase().startsWith("FF8")&&(n=n.substring(2))}return n},e}(),S=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 I(e,t){return I=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},I(e,t)}var T=function(e){var t,n;function r(t){var n=(void 0===t?{}:t).AccessToken;return e.call(this,n||"")||this}return n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,I(t,n),r}(S);function R(e,t){return R=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},R(e,t)}var U=function(e){var t,n;function r(t){var n=(void 0===t?{}:t).IdToken;return e.call(this,n||"")||this}return n=e,(t=r).prototype=Object.create(n.prototype),t.prototype.constructor=t,R(t,n),r}(S),D="aws-amplify/5.0.4",C="undefined"!=typeof navigator&&"ReactNative"===navigator.product,P=function(){function e(e){var t=(void 0===e?{}:e).RefreshToken;this.token=t||""}return e.prototype.getToken=function(){return this.token},e}(),N=function(){function e(e){var t=void 0===e?{}:e,n=t.IdToken,r=t.RefreshToken,i=t.AccessToken,s=t.ClockDrift;if(null==i||null==n)throw new Error("Id token and Access Token must be present.");this.idToken=n,this.refreshToken=r,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}(),k=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],O=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],L=function(){function e(){}return e.prototype.getNowString=function(){var e=new Date,t=O[e.getUTCDay()],n=k[e.getUTCMonth()],r=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+" "+n+" "+r+" "+i+":"+s+":"+o+" UTC "+e.getUTCFullYear()},e}(),M=function(){function e(e){var t=void 0===e?{}:e,n=t.Name,r=t.Value;this.Name=n||"",this.Value=r||""}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}(),V={},F=function(){function e(){}return e.setItem=function(e,t){return V[e]=t,V[e]},e.getItem=function(e){return Object.prototype.hasOwnProperty.call(V,e)?V[e]:void 0},e.removeItem=function(e){return delete V[e]},e.clear=function(){return V={}},e}(),x=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=F}}return e.prototype.getStorage=function(){return this.storageWindow},e}(),B="undefined"!=typeof navigator?C?"react-native":navigator.userAgent:"nodejs",$=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 x).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 n=this,r=e.getAuthParameters();r.USERNAME=this.username;var i=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),s={AuthFlow:"CUSTOM_AUTH",ClientId:this.pool.getClientId(),AuthParameters:r,ClientMetadata:i};this.getUserContextData()&&(s.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",s,(function(e,r){if(e)return t.onFailure(e);var i=r.ChallengeName,s=r.ChallengeParameters;return"CUSTOM_CHALLENGE"===i?(n.Session=r.Session,t.customChallenge(s)):(n.signInUserSession=n.getCognitoUserSession(r.AuthenticationResult),n.cacheTokens(),t.onSuccess(n.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 n,r,s=this,o=new E(this.pool.getUserPoolName()),c=new L,l={};null!=this.deviceKey&&(l.DEVICE_KEY=this.deviceKey),l.USERNAME=this.username,o.getLargeAValue((function(h,f){h&&t.onFailure(h),l.SRP_A=f.toString(16),"CUSTOM_AUTH"===s.authenticationFlowType&&(l.CHALLENGE_NAME="SRP_A");var d=0!==Object.keys(e.getValidationData()).length?e.getValidationData():e.getClientMetadata(),p={AuthFlow:s.authenticationFlowType,ClientId:s.pool.getClientId(),AuthParameters:l,ClientMetadata:d};s.getUserContextData(s.username)&&(p.UserContextData=s.getUserContextData(s.username)),s.client.request("InitiateAuth",p,(function(l,h){if(l)return t.onFailure(l);var f=h.ChallengeParameters;s.username=f.USER_ID_FOR_SRP,s.userDataKey=s.keyPrefix+"."+s.username+".userData",n=new u(f.SRP_B,16),r=new u(f.SALT,16),s.getCachedDeviceKeyAndPassword(),o.getPasswordAuthenticationKey(s.username,e.getPassword(),n,r,(function(e,n){e&&t.onFailure(e);var r=c.getNowString(),u=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(r,"utf8")]),l=new a.Sha256(n);l.update(u);var p=l.digestSync(),g=i.lW.from(p).toString("base64"),_={};_.USERNAME=s.username,_.PASSWORD_CLAIM_SECRET_BLOCK=f.SECRET_BLOCK,_.TIMESTAMP=r,_.PASSWORD_CLAIM_SIGNATURE=g,null!=s.deviceKey&&(_.DEVICE_KEY=s.deviceKey);var m={ChallengeName:"PASSWORD_VERIFIER",ClientId:s.pool.getClientId(),ChallengeResponses:_,Session:h.Session,ClientMetadata:d};s.getUserContextData()&&(m.UserContextData=s.getUserContextData()),function e(t,n){return s.client.request("RespondToAuthChallenge",t,(function(r,i){return r&&"ResourceNotFoundException"===r.code&&-1!==r.message.toLowerCase().indexOf("device")?(_.DEVICE_KEY=null,s.deviceKey=null,s.randomPassword=null,s.deviceGroupKey=null,s.clearCachedDeviceKeyAndPassword(),e(t,n)):n(r,i)}))}(m,(function(e,n){return e?t.onFailure(e):s.authenticateUserInternal(n,o,t)}))}))}))}))},t.authenticateUserPlainUsernamePassword=function(e,t){var n=this,r={};if(r.USERNAME=this.username,r.PASSWORD=e.getPassword(),r.PASSWORD){var i=new E(this.pool.getUserPoolName());this.getCachedDeviceKeyAndPassword(),null!=this.deviceKey&&(r.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:r,ClientMetadata:s};this.getUserContextData(this.username)&&(o.UserContextData=this.getUserContextData(this.username)),this.client.request("InitiateAuth",o,(function(e,r){return e?t.onFailure(e):n.authenticateUserInternal(r,i,t)}))}else t.onFailure(new Error("PASSWORD parameter is required"))},t.authenticateUserInternal=function(e,t,n){var r=this,s=e.ChallengeName,o=e.ChallengeParameters;if("SMS_MFA"===s)return this.Session=e.Session,n.mfaRequired(s,o);if("SELECT_MFA_TYPE"===s)return this.Session=e.Session,n.selectMFAType(s,o);if("MFA_SETUP"===s)return this.Session=e.Session,n.mfaSetup(s,o);if("SOFTWARE_TOKEN_MFA"===s)return this.Session=e.Session,n.totpRequired(s,o);if("CUSTOM_CHALLENGE"===s)return this.Session=e.Session,n.customChallenge(o);if("NEW_PASSWORD_REQUIRED"===s){this.Session=e.Session;var a=null,u=null,c=[],l=t.getNewPasswordRequiredChallengeUserAttributePrefix();if(o&&(a=JSON.parse(e.ChallengeParameters.userAttributes),u=JSON.parse(e.ChallengeParameters.requiredAttributes)),u)for(var h=0;h<u.length;h++)c[h]=u[h].substr(l.length);return n.newPasswordRequired(a,c)}if("DEVICE_SRP_AUTH"===s)return this.Session=e.Session,void this.getDeviceResponse(n);this.signInUserSession=this.getCognitoUserSession(e.AuthenticationResult),this.challengeName=s,this.cacheTokens();var f=e.AuthenticationResult.NewDeviceMetadata;if(null==f)return n.onSuccess(this.signInUserSession);t.generateHashDevice(e.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,e.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(s){if(s)return n.onFailure(s);var o={Salt:i.lW.from(t.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:i.lW.from(t.getVerifierDevices(),"hex").toString("base64")};r.verifierDevices=o.PasswordVerifier,r.deviceGroupKey=f.DeviceGroupKey,r.randomPassword=t.getRandomPassword(),r.client.request("ConfirmDevice",{DeviceKey:f.DeviceKey,AccessToken:r.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:o,DeviceName:B},(function(t,i){return t?n.onFailure(t):(r.deviceKey=e.AuthenticationResult.NewDeviceMetadata.DeviceKey,r.cacheDeviceKeyAndPassword(),!0===i.UserConfirmationNecessary?n.onSuccess(r.signInUserSession,i.UserConfirmationNecessary):n.onSuccess(r.signInUserSession))}))}))},t.completeNewPasswordChallenge=function(e,t,n,r){var i=this;if(!e)return n.onFailure(new Error("New password is required."));var s=new E(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:r};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,t){return e?n.onFailure(e):i.authenticateUserInternal(t,s,n)}))},t.getDeviceResponse=function(e,t){var n=this,r=new E(this.deviceGroupKey),s=new L,o={};o.USERNAME=this.username,o.DEVICE_KEY=this.deviceKey,r.getLargeAValue((function(c,l){c&&e.onFailure(c),o.SRP_A=l.toString(16);var h={ChallengeName:"DEVICE_SRP_AUTH",ClientId:n.pool.getClientId(),ChallengeResponses:o,ClientMetadata:t,Session:n.Session};n.getUserContextData()&&(h.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",h,(function(t,o){if(t)return e.onFailure(t);var c=o.ChallengeParameters,l=new u(c.SRP_B,16),h=new u(c.SALT,16);r.getPasswordAuthenticationKey(n.deviceKey,n.randomPassword,l,h,(function(t,r){if(t)return e.onFailure(t);var u=s.getNowString(),l=i.lW.concat([i.lW.from(n.deviceGroupKey,"utf8"),i.lW.from(n.deviceKey,"utf8"),i.lW.from(c.SECRET_BLOCK,"base64"),i.lW.from(u,"utf8")]),h=new a.Sha256(r);h.update(l);var f=h.digestSync(),d=i.lW.from(f).toString("base64"),p={};p.USERNAME=n.username,p.PASSWORD_CLAIM_SECRET_BLOCK=c.SECRET_BLOCK,p.TIMESTAMP=u,p.PASSWORD_CLAIM_SIGNATURE=d,p.DEVICE_KEY=n.deviceKey;var g={ChallengeName:"DEVICE_PASSWORD_VERIFIER",ClientId:n.pool.getClientId(),ChallengeResponses:p,Session:o.Session};n.getUserContextData()&&(g.UserContextData=n.getUserContextData()),n.client.request("RespondToAuthChallenge",g,(function(t,r){return t?e.onFailure(t):(n.signInUserSession=n.getCognitoUserSession(r.AuthenticationResult),n.cacheTokens(),e.onSuccess(n.signInUserSession))}))}))}))}))},t.confirmRegistration=function(e,t,n,r){var i={ClientId:this.pool.getClientId(),ConfirmationCode:e,Username:this.username,ForceAliasCreation:t,ClientMetadata:r};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmSignUp",i,(function(e){return e?n(e,null):n(null,"SUCCESS")}))},t.sendCustomChallengeAnswer=function(e,t,n){var r=this,i={};i.USERNAME=this.username,i.ANSWER=e;var s=new E(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:n};this.getUserContextData()&&(o.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",o,(function(e,n){return e?t.onFailure(e):r.authenticateUserInternal(n,s,t)}))},t.sendMFACode=function(e,t,n,r){var s=this,o={};o.USERNAME=this.username,o.SMS_MFA_CODE=e;var a=n||"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:r};this.getUserContextData()&&(u.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",u,(function(e,n){if(e)return t.onFailure(e);if("DEVICE_SRP_AUTH"!==n.ChallengeName){if(s.signInUserSession=s.getCognitoUserSession(n.AuthenticationResult),s.cacheTokens(),null==n.AuthenticationResult.NewDeviceMetadata)return t.onSuccess(s.signInUserSession);var r=new E(s.pool.getUserPoolName());r.generateHashDevice(n.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,n.AuthenticationResult.NewDeviceMetadata.DeviceKey,(function(e){if(e)return t.onFailure(e);var o={Salt:i.lW.from(r.getSaltDevices(),"hex").toString("base64"),PasswordVerifier:i.lW.from(r.getVerifierDevices(),"hex").toString("base64")};s.verifierDevices=o.PasswordVerifier,s.deviceGroupKey=n.AuthenticationResult.NewDeviceMetadata.DeviceGroupKey,s.randomPassword=r.getRandomPassword(),s.client.request("ConfirmDevice",{DeviceKey:n.AuthenticationResult.NewDeviceMetadata.DeviceKey,AccessToken:s.signInUserSession.getAccessToken().getJwtToken(),DeviceSecretVerifierConfig:o,DeviceName:B},(function(e,r){return e?t.onFailure(e):(s.deviceKey=n.AuthenticationResult.NewDeviceMetadata.DeviceKey,s.cacheDeviceKeyAndPassword(),!0===r.UserConfirmationNecessary?t.onSuccess(s.signInUserSession,r.UserConfirmationNecessary):t.onSuccess(s.signInUserSession))}))}))}else s.getDeviceResponse(t)}))},t.changePassword=function(e,t,n,r){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n(new Error("User is not authenticated"),null);this.client.request("ChangePassword",{PreviousPassword:e,ProposedPassword:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),ClientMetadata:r},(function(e){return e?n(e,null):n(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,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n(new Error("User is not authenticated"),null);this.client.request("SetUserMFAPreference",{SMSMfaSettings:e,SoftwareTokenMfaSettings:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?n(e,null):n(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 n=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):(n.clearCachedUser(),e(null,"SUCCESS"))}))},t.updateAttributes=function(e,t,n){var r=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:n},(function(e,n){return e?t(e,null):r.getUserData((function(){return t(null,"SUCCESS",n)}),{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,n){if(t)return e(t,null);for(var r=[],i=0;i<n.UserAttributes.length;i++){var s={Name:n.UserAttributes[i].Name,Value:n.UserAttributes[i].Value},o=new M(s);r.push(o)}return e(null,r)}))},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,n){return t?e(t,null):e(null,n.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(n){var r=t.signInUserSession.getRefreshToken();r&&r.getToken()?t.refreshSession(r,n,e.clientMetadata):n()}))},t.getUserData=function(e,t){var n=this;if(null==this.signInUserSession||!this.signInUserSession.isValid())return this.clearCachedUserData(),e(new Error("User is not authenticated"),null);var r=this.getUserDataFromCache();if(r)if(this.isFetchUserDataAndTokenRequired(t))this.fetchUserData().then((function(e){return n.refreshSessionIfPossible(t).then((function(){return e}))})).then((function(t){return e(null,t)})).catch(e);else try{return void e(null,JSON.parse(r))}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 n=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):n.getUserData((function(){return t(null,"SUCCESS")}),{bypassCache:!0})}))},t.resendConfirmationCode=function(e,t){var n={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.client.request("ResendConfirmationCode",n,(function(t,n){return t?e(t,null):e(null,n)}))},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 n="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,r=n+".idToken",i=n+".accessToken",s=n+".refreshToken",o=n+".clockDrift";if(this.storage.getItem(r)){var a=new U({IdToken:this.storage.getItem(r)}),u=new T({AccessToken:this.storage.getItem(i)}),c=new P({RefreshToken:this.storage.getItem(s)}),l=parseInt(this.storage.getItem(o),0)||0,h=new N({IdToken:a,AccessToken:u,RefreshToken:c,ClockDrift:l});if(h.isValid())return this.signInUserSession=h,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,n){var r=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:n};this.getUserContextData()&&(c.UserContextData=this.getUserContextData()),this.client.request("InitiateAuth",c,(function(t,n){if(t)return"NotAuthorizedException"===t.code&&r.clearCachedUser(),i(t,null);if(n){var s=n.AuthenticationResult;return Object.prototype.hasOwnProperty.call(s,"RefreshToken")||(s.RefreshToken=e.getToken()),r.signInUserSession=r.getCognitoUserSession(s),r.cacheTokens(),i(null,r.signInUserSession)}}))},t.cacheTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",n=e+"."+this.username+".accessToken",r=e+"."+this.username+".refreshToken",i=e+"."+this.username+".clockDrift",s=e+".LastAuthUser";this.storage.setItem(t,this.signInUserSession.getIdToken().getJwtToken()),this.storage.setItem(n,this.signInUserSession.getAccessToken().getJwtToken()),this.storage.setItem(r,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",n=e+".randomPasswordKey",r=e+".deviceGroupKey";this.storage.setItem(t,this.deviceKey),this.storage.setItem(n,this.randomPassword),this.storage.setItem(r,this.deviceGroupKey)},t.getCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",n=e+".randomPasswordKey",r=e+".deviceGroupKey";this.storage.getItem(t)&&(this.deviceKey=this.storage.getItem(t),this.randomPassword=this.storage.getItem(n),this.deviceGroupKey=this.storage.getItem(r))},t.clearCachedDeviceKeyAndPassword=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId()+"."+this.username,t=e+".deviceKey",n=e+".randomPasswordKey",r=e+".deviceGroupKey";this.storage.removeItem(t),this.storage.removeItem(n),this.storage.removeItem(r)},t.clearCachedTokens=function(){var e="CognitoIdentityServiceProvider."+this.pool.getClientId(),t=e+"."+this.username+".idToken",n=e+"."+this.username+".accessToken",r=e+"."+this.username+".refreshToken",i=e+".LastAuthUser",s=e+"."+this.username+".clockDrift";this.storage.removeItem(t),this.storage.removeItem(n),this.storage.removeItem(r),this.storage.removeItem(i),this.storage.removeItem(s)},t.getCognitoUserSession=function(e){var t=new U(e),n=new T(e),r=new P(e);return new N({IdToken:t,AccessToken:n,RefreshToken:r})},t.forgotPassword=function(e,t){var n={ClientId:this.pool.getClientId(),Username:this.username,ClientMetadata:t};this.getUserContextData()&&(n.UserContextData=this.getUserContextData()),this.client.request("ForgotPassword",n,(function(t,n){return t?e.onFailure(t):"function"==typeof e.inputVerificationCode?e.inputVerificationCode(n):e.onSuccess(n)}))},t.confirmPassword=function(e,t,n,r){var i={ClientId:this.pool.getClientId(),Username:this.username,ConfirmationCode:e,Password:t,ClientMetadata:r};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("ConfirmForgotPassword",i,(function(e){return e?n.onFailure(e):n.onSuccess("SUCCESS")}))},t.getAttributeVerificationCode=function(e,t,n){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:n},(function(e,n){return e?t.onFailure(e):"function"==typeof t.inputVerificationCode?t.inputVerificationCode(n):t.onSuccess("SUCCESS")}))},t.verifyAttribute=function(e,t,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n.onFailure(new Error("User is not authenticated"));this.client.request("VerifyUserAttribute",{AttributeName:e,Code:t,AccessToken:this.signInUserSession.getAccessToken().getJwtToken()},(function(e){return e?n.onFailure(e):n.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,n){return t?e.onFailure(t):e.onSuccess(n)}))},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(n){return t.deviceKey=null,t.deviceGroupKey=null,t.randomPassword=null,t.clearCachedDeviceKeyAndPassword(),e.onSuccess(n)}})},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,n){if(null==this.signInUserSession||!this.signInUserSession.isValid())return n.onFailure(new Error("User is not authenticated"));var r={AccessToken:this.signInUserSession.getAccessToken().getJwtToken(),Limit:e};t&&(r.PaginationToken=t),this.client.request("ListDevices",r,(function(e,t){return e?n.onFailure(e):n.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(n){return n?e.onFailure(n):(t.clearCachedUser(),e.onSuccess("SUCCESS"))}))},t.signOut=function(e){var t=this;e&&"function"==typeof e?this.getSession((function(n,r){if(n)return e(n);t.revokeTokens((function(n){t.cleanClientData(),e(n)}))})):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(),n=this.signInUserSession.getAccessToken();if(this.isSessionRevocable(n)&&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,n=e.callback;this.client.requestWithRetry("RevokeToken",{Token:t,ClientId:this.pool.getClientId()},(function(e){if(e)return n(e);n()}))},t.sendMFASelectionAnswer=function(e,t){var n=this,r={};r.USERNAME=this.username,r.ANSWER=e;var i={ChallengeName:"SELECT_MFA_TYPE",ChallengeResponses:r,ClientId:this.pool.getClientId(),Session:this.Session};this.getUserContextData()&&(i.UserContextData=this.getUserContextData()),this.client.request("RespondToAuthChallenge",i,(function(r,i){return r?t.onFailure(r):(n.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,n){return t?e.onFailure(t):e.associateSecretCode(n.SecretCode)})):this.client.request("AssociateSoftwareToken",{Session:this.Session},(function(n,r){return n?e.onFailure(n):(t.Session=r.Session,e.associateSecretCode(r.SecretCode))}))},t.verifySoftwareToken=function(e,t,n){var r=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?n.onFailure(e):n.onSuccess(t)})):this.client.request("VerifySoftwareToken",{Session:this.Session,UserCode:e,FriendlyDeviceName:t},(function(e,t){if(e)return n.onFailure(e);r.Session=t.Session;var i={};i.USERNAME=r.username;var s={ChallengeName:"MFA_SETUP",ClientId:r.pool.getClientId(),ChallengeResponses:i,Session:r.Session};r.getUserContextData()&&(s.UserContextData=r.getUserContextData()),r.client.request("RespondToAuthChallenge",s,(function(e,t){return e?n.onFailure(e):(r.signInUserSession=r.getCognitoUserSession(t.AuthenticationResult),r.cacheTokens(),n.onSuccess(r.signInUserSession))}))}))},e}();function q(){}function j(e){var t="function"==typeof Map?new Map:void 0;return j=function(e){if(null===e||!function(e){try{return-1!==Function.toString.call(e).indexOf("[native code]")}catch(t){return"function"==typeof e}}(e))return e;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 K(e,arguments,J(this).constructor)}return n.prototype=Object.create(e.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),H(n,e)},j(e)}function K(e,t,n){return K=function(){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}}()?Reflect.construct.bind():function(e,t,n){var r=[null];r.push.apply(r,t);var i=new(Function.bind.apply(e,r));return n&&H(i,n.prototype),i},K.apply(null,arguments)}function H(e,t){return H=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(e,t){return e.__proto__=t,e},H(e,t)}function J(e){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(e){return e.__proto__||Object.getPrototypeOf(e)},J(e)}n(204),q.prototype.userAgent=D;var W=function(e){function t(t,n,r,i){var s;return(s=e.call(this,t)||this).code=n,s.name=r,s.statusCode=i,s}return r=e,(n=t).prototype=Object.create(r.prototype),n.prototype.constructor=n,H(n,r),t;var n,r}(j(Error)),Q=function(){function e(e,t,n){this.endpoint=t||"https://cognito-idp."+e+".amazonaws.com/";var r=(n||{}).credentials;this.fetchOptions=r?{credentials:r}:{}}var t=e.prototype;return t.promisifyRequest=function(e,t){var n=this;return new Promise((function(r,i){n.request(e,t,(function(e,t){e?i(new W(e.message,e.code,e.name,e.statusCode)):r(t)}))}))},t.requestWithRetry=function(e,t,n){var r,i,s=this;(r=[t],i=5e3,void 0===i&&(i=Z),z((function(t){return new Promise((function(n,r){s.request(e,t,(function(e,t){e?r(e):n(t)}))}))}),r,function(e){return function(t){var n=100*Math.pow(2,t)+100*Math.random();return!(n>e)&&n}}(i))).then((function(e){return n(null,e)})).catch((function(e){return n(e)}))},t.request=function(e,t,n){var r,i,s,o={"Content-Type":"application/x-amz-json-1.1","X-Amz-Target":"AWSCognitoIdentityProviderService."+e,"X-Amz-User-Agent":(r=q.category?" "+q.category:"",i=q.framework?" framework/"+q.framework:"",""+q.prototype.userAgent+r+i),"Cache-Control":"no-store"},a=Object.assign({},this.fetchOptions,{headers:o,method:"POST",mode:"cors",body:JSON.stringify(t)});fetch(this.endpoint,a).then((function(e){return s=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(s.ok)return n(null,e);var t=(e.__type||e.code).split("#").pop(),r=new Error(e.message||e.Message||null);return r.name=t,r.code=t,n(r)})).catch((function(e){if(s&&s.headers&&s.headers.get("x-amzn-errortype"))try{var t=s.headers.get("x-amzn-errortype").split(":")[0],r=new Error(s.status?s.status.toString():null);return r.code=t,r.name=t,r.statusCode=s.status,n(r)}catch(t){return n(e)}else e instanceof Error&&"Network error"===e.message&&(e.code="NetworkError");return n(e)}))},e}(),Y={debug:function(){}},G=function(e){return e&&e.nonRetryable};function z(e,t,n,r){if(void 0===r&&(r=1),"function"!=typeof e)throw Error("functionToRetry must be a function");return Y.debug(e.name+" attempt #"+r+" with args: "+JSON.stringify(t)),e.apply(void 0,t).catch((function(i){if(Y.debug("error on "+e.name,i),G(i))throw Y.debug(e.name+" non retryable error",i),i;var s=n(r,t,i);if(Y.debug(e.name+" retrying in "+s+" ms"),!1!==s)return new Promise((function(e){return setTimeout(e,s)})).then((function(){return z(e,t,n,r+1)}));throw i}))}var Z=3e5,X=function(){function e(e,t){var n=e||{},r=n.UserPoolId,i=n.ClientId,s=n.endpoint,o=n.fetchOptions,a=n.AdvancedSecurityDataCollectionFlag;if(!r||!i)throw new Error("Both UserPoolId and ClientId are required.");if(r.length>55||!/^[\w-]+_[0-9a-zA-Z]+$/.test(r))throw new Error("Invalid UserPoolId format.");var u=r.split("_")[0];this.userPoolId=r,this.clientId=i,this.client=new Q(u,s,o),this.advancedSecurityDataCollectionFlag=!1!==a,this.storage=e.Storage||(new x).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,n,r,i,s){var o=this,a={ClientId:this.clientId,Username:e,Password:t,UserAttributes:n,ValidationData:r,ClientMetadata:s};this.getUserContextData(e)&&(a.UserContextData=this.getUserContextData(e)),this.client.request("SignUp",a,(function(t,n){if(t)return i(t,null);var r={Username:e,Pool:o,Storage:o.storage},s={user:new $(r),userConfirmed:n.UserConfirmed,userSub:n.UserSub,codeDeliveryDetails:n.CodeDeliveryDetails};return i(null,s)}))},t.getCurrentUser=function(){var e="CognitoIdentityServiceProvider."+this.clientId+".LastAuthUser",t=this.storage.getItem(e);if(t){var n={Username:t,Pool:this,Storage:this.storage};return new $(n)}return null},t.getUserContextData=function(e){if("undefined"!=typeof AmazonCognitoAdvancedSecurityData){var t=AmazonCognitoAdvancedSecurityData;if(this.advancedSecurityDataCollectionFlag){var n=t.getData(e,this.userPoolId,this.clientId);if(n)return{EncodedData:n}}return{}}},e}();n(808);class ee extends Error{constructor(e,t){if(Array.isArray(e)&&e.length<=2){let n=e[1];if(e.length>2)for(let t=2;t<e.length&&"string"==typeof e[t];t++)n+=e[t];super((n||"Something went wrong.").trim()),this.name=t?.name||"SKAPI",this.code=t?.code||e[0]||"ERROR",t?.cause&&(this.cause=t.cause)}else"string"==typeof e?(super((e||"Something went wrong.").trim()),this.name=t?.name||"SKAPI",this.code=t?.code||"ERROR",t?.cause&&(this.cause=t.cause)):e instanceof Error&&(super((e.message||"Something went wrong.").trim()),this.cause=e,this.name=e.name,e.hasOwnProperty("code")&&(this.code=e.code))}}class te{static hash(e){"string"!=typeof e&&(console.warn("coercing non-string value to empty string"),e="");const t=te.sb(e);let n,r,i,s,o=1732584193,a=-271733879,u=-1732584194,c=271733878;for(let e=0;e<t.length;e+=16)n=o,r=a,i=u,s=c,o=te.ff(o,a,u,c,t[e],7,-680876936),c=te.ff(c,o,a,u,t[e+1],12,-389564586),u=te.ff(u,c,o,a,t[e+2],17,606105819),a=te.ff(a,u,c,o,t[e+3],22,-1044525330),o=te.ff(o,a,u,c,t[e+4],7,-176418897),c=te.ff(c,o,a,u,t[e+5],12,1200080426),u=te.ff(u,c,o,a,t[e+6],17,-1473231341),a=te.ff(a,u,c,o,t[e+7],22,-45705983),o=te.ff(o,a,u,c,t[e+8],7,1770035416),c=te.ff(c,o,a,u,t[e+9],12,-1958414417),u=te.ff(u,c,o,a,t[e+10],17,-42063),a=te.ff(a,u,c,o,t[e+11],22,-1990404162),o=te.ff(o,a,u,c,t[e+12],7,1804603682),c=te.ff(c,o,a,u,t[e+13],12,-40341101),u=te.ff(u,c,o,a,t[e+14],17,-1502002290),a=te.ff(a,u,c,o,t[e+15],22,1236535329),o=te.gg(o,a,u,c,t[e+1],5,-165796510),c=te.gg(c,o,a,u,t[e+6],9,-1069501632),u=te.gg(u,c,o,a,t[e+11],14,643717713),a=te.gg(a,u,c,o,t[e],20,-373897302),o=te.gg(o,a,u,c,t[e+5],5,-701558691),c=te.gg(c,o,a,u,t[e+10],9,38016083),u=te.gg(u,c,o,a,t[e+15],14,-660478335),a=te.gg(a,u,c,o,t[e+4],20,-405537848),o=te.gg(o,a,u,c,t[e+9],5,568446438),c=te.gg(c,o,a,u,t[e+14],9,-1019803690),u=te.gg(u,c,o,a,t[e+3],14,-187363961),a=te.gg(a,u,c,o,t[e+8],20,1163531501),o=te.gg(o,a,u,c,t[e+13],5,-1444681467),c=te.gg(c,o,a,u,t[e+2],9,-51403784),u=te.gg(u,c,o,a,t[e+7],14,1735328473),a=te.gg(a,u,c,o,t[e+12],20,-1926607734),o=te.hh(o,a,u,c,t[e+5],4,-378558),c=te.hh(c,o,a,u,t[e+8],11,-2022574463),u=te.hh(u,c,o,a,t[e+11],16,1839030562),a=te.hh(a,u,c,o,t[e+14],23,-35309556),o=te.hh(o,a,u,c,t[e+1],4,-1530992060),c=te.hh(c,o,a,u,t[e+4],11,1272893353),u=te.hh(u,c,o,a,t[e+7],16,-155497632),a=te.hh(a,u,c,o,t[e+10],23,-1094730640),o=te.hh(o,a,u,c,t[e+13],4,681279174),c=te.hh(c,o,a,u,t[e],11,-358537222),u=te.hh(u,c,o,a,t[e+3],16,-722521979),a=te.hh(a,u,c,o,t[e+6],23,76029189),o=te.hh(o,a,u,c,t[e+9],4,-640364487),c=te.hh(c,o,a,u,t[e+12],11,-421815835),u=te.hh(u,c,o,a,t[e+15],16,530742520),a=te.hh(a,u,c,o,t[e+2],23,-995338651),o=te.ii(o,a,u,c,t[e],6,-198630844),c=te.ii(c,o,a,u,t[e+7],10,1126891415),u=te.ii(u,c,o,a,t[e+14],15,-1416354905),a=te.ii(a,u,c,o,t[e+5],21,-57434055),o=te.ii(o,a,u,c,t[e+12],6,1700485571),c=te.ii(c,o,a,u,t[e+3],10,-1894986606),u=te.ii(u,c,o,a,t[e+10],15,-1051523),a=te.ii(a,u,c,o,t[e+1],21,-2054922799),o=te.ii(o,a,u,c,t[e+8],6,1873313359),c=te.ii(c,o,a,u,t[e+15],10,-30611744),u=te.ii(u,c,o,a,t[e+6],15,-1560198380),a=te.ii(a,u,c,o,t[e+13],21,1309151649),o=te.ii(o,a,u,c,t[e+4],6,-145523070),c=te.ii(c,o,a,u,t[e+11],10,-1120210379),u=te.ii(u,c,o,a,t[e+2],15,718787259),a=te.ii(a,u,c,o,t[e+9],21,-343485551),o=te.ad(o,n),a=te.ad(a,r),u=te.ad(u,i),c=te.ad(c,s);return te.rh(o)+te.rh(a)+te.rh(u)+te.rh(c)}static rh(e){let t="";for(let n=0;n<=3;n++)t+=te.alphabet.charAt(e>>8*n+4&15)+te.alphabet.charAt(e>>8*n&15);return t}static ad(e,t){const n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}static rl(e,t){return e<<t|e>>>32-t}static cm(e,t,n,r,i,s){return te.ad(te.rl(te.ad(te.ad(t,e),te.ad(r,s)),i),n)}static ff(e,t,n,r,i,s,o){return te.cm(t&n|~t&r,e,t,i,s,o)}static gg(e,t,n,r,i,s,o){return te.cm(t&r|n&~r,e,t,i,s,o)}static hh(e,t,n,r,i,s,o){return te.cm(t^n^r,e,t,i,s,o)}static ii(e,t,n,r,i,s,o){return te.cm(n^(t|~r),e,t,i,s,o)}static sb(e){let t;const n=1+(e.length+8>>6),r=new Array(16*n);for(t=0;t<16*n;t++)r[t]=0;for(t=0;t<e.length;t++)r[t>>2]|=e.charCodeAt(t)<<t%4*8;return r[t>>2]|=128<<t%4*8,r[16*n-2]=8*e.length,r}}function ne(e){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";if(0===e)return t[0];let n="";for(;e>0;)n=t[e%62]+n,e=Math.floor(e/62);return n}function re(e){return e.split("").reverse().reduce(((e,t,n)=>e+"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz".indexOf(t)*62**n),0)}function ie(e=6){let t="";let n=0;for(;n<e;)t+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789".charAt(Math.floor(62*Math.random())),n+=1;return t}function se(e,t,n){let r={},i=[];function s(e){let t;try{t=JSON.stringify(e)}catch(e){throw new ee("Invalid data type.",{code:"INVALID_REQUEST"})}return new Blob([t]).size}function o(e,r,i){if(t?.ignoreEmpty&&""===i)return;if(t?.nullIfEmpty&&""===i&&(i=null),"function"==typeof n){let e=n(r,i);void 0!==e&&(i=e)}let s=r.split("[").map((e=>{let t=e.replace("]",""),n=Number(t);return isNaN(n)||t.includes(".")?('"'===t[0]&&'"'===t[t.length-1]||"'"===t[0]&&"'"===t[t.length-1])&&(t=t.replace(/"/g,"").replace(/'/g,"")):t=n,t})),o=e;if("number"==typeof s[0])throw new ee("Form key cannot start with an array index.",{code:"INVALID_REQUEST"});for(let e=0;e<s.length;e++){let t=s[e];if(e<s.length-1){if(void 0===o[t]){let n=s[e+1];o[t]="number"==typeof n?[]:{}}o=o[t]}else void 0===o[t]?o[t]=i:Array.isArray(o[t])?o[t].push(i):o[t]=[o[t],i]}}function a(e,t,n){if(n instanceof File)e.push({name:t,file:n});else if(n instanceof FileList&&n&&n.length>0)for(let r=0;r<=n.length-1;r++){let i=n.item(r);i&&e.push({name:t,file:i})}}if(e instanceof FormData){for(let t of e.entries()){let e=t[0],n=t[1];n instanceof File||n instanceof FileList?a(i,e,n):o(r,e,n)}if(s(r)>2097152)throw new ee("Data should not exceed 2MB",{code:"INVALID_REQUEST"});return{data:r,files:i}}if(e instanceof SubmitEvent&&(e=e.target),e instanceof HTMLFormElement){let t=e.querySelectorAll("input"),n=e.querySelectorAll("select"),u=e.querySelectorAll("textarea");for(let e=0;e<n.length;e++){let t=n[e];t.name&&o(r,t.name,t.value)}for(let e=0;e<u.length;e++){let t=u[e];t.name&&o(r,t.name,t.value)}for(let e=0;e<t.length;e++){let n=t[e];n.name&&("number"===n.type?n.value&&o(r,n.name,Number(n.value)):"checkbox"===n.type||"radio"===n.type?n.checked?""===n.value&&"checkbox"===n.type||"on"===n.value||"true"===n.value?o(r,n.name,!0):"false"===n.value?o(r,n.name,!1):n.value&&o(r,n.name,n.value):"checkbox"===n.type&&(""===n.value||"on"===n.value||"true"===n.value?o(r,n.name,!1):"false"===n.value&&o(r,n.name,!0)):"file"===n.type?n.files&&n.files.length>0&&a(i,n.name,n.files):o(r,n.name,n.value))}if(s(r)>2097152)throw new ee("Data should not exceed 2MB",{code:"INVALID_REQUEST"});return{data:r,files:i}}if(s(e)>2097152)throw new ee("Data should not exceed 2MB",{code:"INVALID_REQUEST"});return{data:e,files:i}}function oe(e,t,n=[],r=null){function i(e){return e&&"object"==typeof e&&!Array.isArray(e)&&Object.keys(e).length}function s(e){return Array.isArray(e)&&e.length}if(null===r&&!i(t))throw'Argument "struct" is required.';let o=null!==r?` in key "${r}" is invalid.`:". Parameter should be type <object>.";if(s(t)){let i="";t.forEach((e=>{["string","number","boolean","object","array"].includes(e)?i+=`Type<${e}>, `:"function"!=typeof e&&(i+=JSON.stringify(e,null,2)+", ")})),i=i?" Should be: "+i.slice(0,-2):"";let s,a=!1,u="";for(let i of t)try{s=oe(e,i,n,r),a=!0;break}catch(e){u="function"==typeof i?e?.message||e:"",a=!1}if(!a)throw u||`Invalid type "${typeof e}"${o}${i}.`;return s}if(i(e)){if(i(t))for(let i in t){let o=(null===r?"":r)+(null!==r?"["+i+"]":i);if(!e.hasOwnProperty(i)){if(n.includes(o))throw`Key "${o}" is required.`;s(t[i])&&"function"==typeof t[i][t[i].length-1]&&(e[i]=t[i][t[i].length-1]())}}if("object"===t)return e;if("function"==typeof t)return t(e);for(let i in e){let o=(null===r?"":r)+(null!==r?"["+i+"]":i);if(s(t)||t.hasOwnProperty(i))if(s(e[i])){if("array"===t[i])continue;if("function"==typeof t[i]){e[i]=t[i](e[i]);continue}for(let r=0;r<e[i].length;r++)e[i][r]=oe(e[i][r],t[i],n,o+`[${r}]`)}else e[i]=oe(e[i],t[i],n,o)}return e}if("function"==typeof t)return t(e);if("array"===t&&Array.isArray(e)||t===typeof e||e===t)return e;if(null==e||(a=e)&&"object"==typeof a&&!Array.isArray(a)&&!Object.keys(a).length)return e;var a;throw`Invalid type "${typeof e}"${o} Should be: ${["string","number","boolean","object","array"].includes(t)?`Type<${t}>`:JSON.stringify(t,null,2)}`}te.alphabet="0123456789abcdef";const ae={UserId:function(e,t="User ID"){if(!e)throw new ee(`${t} is empty.`,{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ee(`${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 ee(`${t} is invalid.`,{code:"INVALID_PARAMETER"});return e},PhoneNumber:function(e){if(e&&("string"!=typeof e||"+"!==e.charAt(0)||isNaN(Number(e.substring(1)))))throw new ee('"phone_number" is invalid. The format should be "+00123456789". Type: string.',{code:"INVALID_PARAMETER"});return e||""},Birthdate:function(e){if(e){if("string"!=typeof e)throw new ee('"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 ee('"birthdate" is invalid. The format should be "yyyy-mm-dd". Type: string.',{code:"INVALID_PARAMETER"})}}return e||""},Password:function(e){if(!e)throw new ee('"password" is required.',{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ee('"password" should be type: string.',{code:"INVALID_PARAMETER"});if(e.length<6)throw new ee('"password" should be at least 6 characters.',{code:"INVALID_PARAMETER"});if(e.length>60)throw new ee('"password" can be up to 60 characters max.',{code:"INVALID_PARAMETER"});return e},Email:function(e,t="email"){if(!e)throw new ee(`"${t}" is required.`,{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ee(`"${t}"should be type: string.`,{code:"INVALID_PARAMETER"});if(e.length<5)throw new ee(`"${t}" should be at least 5 characters.`,{code:"INVALID_PARAMETER"});if(/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(e)&&(e=e.trim()).split("@")[1].split(".").length>=2)return e.toLowerCase();throw new ee(`"${e}" is an invalid email.`,{code:"INVALID_PARAMETER"})},Url:function(e){const t=(()=>{let e=window.location.origin||null;return e&&"/"===e.slice(-1)&&(e=e.slice(0,-1)),e})();let n=e=>{if("string"==typeof e){if("*"===e)return"*";{let n,r=e.trim();if("/"===r[0]&&t){if("file:"===t.slice(0,5))throw new ee(`"${e}" is an invalid url. Relative URL does not work on local file system. Use full URL string.`,{code:"INVALID_PARAMETER"});r=t+r}else if("."===r[0]&&t){if("file:"===t.slice(0,5))throw new ee(`"${e}" is an invalid url. Relative URL does not work on local file system. Use full URL string.`,{code:"INVALID_PARAMETER"});let n=window.location.href.split("?")[0];"/"!==n.slice(-1)&&(n+="/"),r=n+r.slice(1)}try{n=new URL(r)}catch(t){throw new ee(`"${e}" is an invalid url.`,{code:"INVALID_PARAMETER"})}if(n.protocol)return n.href}}throw new ee(`"${e}" is an invalid url.`,{code:"INVALID_PARAMETER"})};return Array.isArray(e)?e.map((e=>n(e))):n(e)},specialChars:function(e,t="parameter",n=!1,r=!1){let i=e=>{if("string"!=typeof e)throw new ee(`${t} should be type: <string | string[]>.`,{code:"INVALID_PARAMETER"});if(!r&&e.includes(" "))throw new ee(`${t} should not have whitespace.`,{code:"INVALID_PARAMETER"});if(!n&&e.includes("."))throw new ee(`${t} should not have periods.`,{code:"INVALID_PARAMETER"});if(/[!@#$%&*()+\-={};':"\|,<>\/?~]/.test(e))throw new ee(`${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},Params:function(e,t,n=[]){let r=se(e).data;t.service="string",t.owner="string";let i={};for(let e in t)if(r&&"object"==typeof r&&!Array.isArray(r)&&r.hasOwnProperty(e))if("function"==typeof r[e])i[e]=r[e];else try{i[e]=JSON.parse(JSON.stringify(r[e]))}catch(t){i[e]=r[e]}try{return oe(i,t,n)}catch(e){throw new ee(e,{code:"INVALID_PARAMETER"})}}};let ue=null;function ce(e){let t={tkid:"ticket_id",cond:"condition",actn:"action",cnt:"count",ttl:"time_to_live",stmp:"timestamp",plch:"placeholder",hash:"hash",desc:"description"},n={};for(let r in e)if("tkid"===r){let t=e[r].split("#");if(1===t.length){n.ticket_id=t[0];continue}n.ticket_id=t[1],n.consume_id=t[2],n.user_id=t[3],e.stmp||(n.timestamp=re(t[2].slice(0,-4)))}else t[r]?n[t[r]]=e[r]:n[r]=e[r];return n}async function le(e){if(!e.ticket_id)throw new ee("Ticket ID is required.",{code:"INVALID_PARAMETER"});let t=e.ticket_id;return await this.__connection,ce(await Fe.bind(this)(`https://${this.service.slice(0,4)}.skapi.dev/auth/consume/${this.service}/${this.owner}/${t}`,e,{auth:!0}))}async function he(e,t){await this.__connection;let n=await Fe.bind(this)("ticket",Object.assign({exec:"list"},e||{}),{auth:!0,fetchOptions:t});return n.list=n.list.map(ce),n}async function fe(e,t){await this.__connection;let n=await Fe.bind(this)("ticket",Object.assign({exec:"consumed"},e||{}),{auth:!0,fetchOptions:t});return n.list=n.list.map(ce),n}async function de(e){return Fe.bind(this)("register-ticket",Object.assign({exec:"reg"},e),{auth:!0})}async function pe(e){return Fe.bind(this)("register-ticket",Object.assign({exec:"unreg"},e),{auth:!0})}function ge(){if(!this.userPool)throw new ee("User pool is missing",{code:"INVALID_REQUEST"});const e=()=>{let e=ue.getSignInUserSession().getIdToken().payload||null,t={};this.log("attributes to normalize:",e);for(let n in e){let r=e[n],i={auth_time:"log",sub:"user_id"};if(!["aud","cognito:username","event_id","exp","iat","iss","jti","origin_jti","secret_key","token_use"].includes(n))if(i[n])t[i[n]]=r;else if(n.includes("custom:")){if("custom:service"===n&&r!==this.service)throw new ee("The user is not registered to the service.",{code:"INVALID_REQUEST"});t[n.replace("custom:","")]=r}else if("address"===n){let e=r;if(e&&"object"==typeof e&&Object.keys(e).length){if(e?.formatted)try{t[n]=JSON.parse(e.formatted)}catch(r){t[n]=e.formatted}}else t[n]=e}else t[n]=r}for(let e of["address_public","birthdate_public","email_public","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]=t.hasOwnProperty(e)?Number(t[e]):0;for(let e of["email","phone_number"])t.hasOwnProperty(e)?t[e+"_verified"]=!0===t[e+"_verified"]:delete t[e+"_verified"];return this.__user=t,t},n=async t=>{let{refreshToken:n=!1}=t||{};return new Promise(((t,r)=>{if(ue=this.userPool.getCurrentUser(),!ue)return this.log("getSession:cognitoUser",ue),void r(null);ue.getSession(((i,s)=>{if(this.log("getSession:getSessionCallback",{err:i,session:s}),i)return ye.bind(this)(),void r(i);if(!s)return ye.bind(this)(),void r(new ee("Current session does not exist.",{code:"INVALID_REQUEST"}));let o=async n=>{let i=n.getIdToken().payload;if(this.log("getSession:respond:sessionAttribute",i),i["custom:service"]!==this.service)return this.log("getSession:respond","invalid service, signing out"),ye.bind(this)(),void r(new ee("Invalid session.",{code:"INVALID_REQUEST"}));this.session=n,e(),"function"==typeof this.onLogin&&this.onLogin(this.user),t(this.session)};n||!s.isValid()?ue.refreshSession(s.getRefreshToken(),(async(e,t)=>{this.log("getSession:refreshSessionCallback:",{err:i,refreshedSession:t}),e?(ye.bind(this)(),r(e)):t.isValid()?o(t):(ye.bind(this)(),r(new ee("Invalid session.",{code:"INVALID_REQUEST"})))})):o(s)}))}))},r=e=>{let t=e.includes(this.service+"-")?e:this.service+"-"+te.hash(e);return{cognitoUser:new $({Username:t,Pool:this.userPool}),cognitoUsername:t}};return{getSession:n,authenticateUser:(e,i)=>new Promise(((s,o)=>{this.__request_signup_confirmation=null,this.__disabledAccount=null;let a=r(e),u=a.cognitoUsername,c=new t({Username:u,Password:i});a.cognitoUser.authenticateUser(c,{newPasswordRequired:(e,t)=>{this.__disabledAccount=null,this.__request_signup_confirmation=u,"PASS"===e["custom:signup_ticket"]||"MEMBER"===e["custom:signup_ticket"]?a.cognitoUser.completeNewPasswordChallenge(i,{},{onSuccess:e=>{ue=a.cognitoUser,n().then((e=>s(this.user)))},onFailure:e=>{o(new ee(e.message||"Failed to authenticate user.",{code:e.code}))}}):o(new ee("User's signup confirmation is required.",{code:"SIGNUP_CONFIRMATION_NEEDED"}))},onSuccess:e=>n().then((e=>{this.__disabledAccount=null,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=u,t=["This account is disabled.","USER_IS_DISABLED"]):t=["Incorrect username or password.","INCORRECT_USERNAME_OR_PASSWORD"]:"UserNotFoundException"===e.code?t=["Incorrect username or password.","INCORRECT_USERNAME_OR_PASSWORD"]:"UserNotConfirmedException"===e.code?(this.__request_signup_confirmation=u,t=["User's signup confirmation is required.","SIGNUP_CONFIRMATION_NEEDED"]):"TooManyRequestsException"!==e.code&&"LimitExceededException"!==e.code||(t=["Too many attempts. Please try again later.","REQUEST_EXCEED"]);let n=t[1],r=t[0],i=t[0].split("#");if(i.length>1&&(i=i[i.length-1].split(":"),n=i[0],r=i[1],"CONFIRM_REQUIRED"===n))return this.__request_signup_confirmation=u,void o(new ee("User's signup confirmation is required.",{code:"SIGNUP_CONFIRMATION_NEEDED"}));o(new ee(r,{code:n,cause:e}))}})})),createCognitoUser:r,signup:(e,t,n)=>new Promise(((r,i)=>{this.userPool.signUp(e,t,n,null,((e,t)=>{e?i(e):r(t)}))}))}}async function _e(e){await this.__authConnection;try{return await ge.bind(this)().getSession(e),this.user}catch(e){return null}}async function me(){return await this.__connection,this.__user?.service===this.service?this.__user?.owner===this.host:(await we.bind(this)(),!1)}function ye(){ue&&ue.signOut();let e={session:null,__startKeyHistory:{},__cached_requests:{},__user:null};for(let t in e)this[t]=e[t];"function"==typeof this.onLogin&&this.onLogin(null)}async function we(){return await this.__connection,ye.bind(this)(),"SUCCESS: The user has been logged out."}async function be(e){if(!this.__request_signup_confirmation)throw new ee("Least one login attempt is required.",{code:"INVALID_REQUEST"});return e=e?ae.Url(e):void 0,await Fe.bind(this)("confirm-signup",{username:this.__request_signup_confirmation,redirect:e})}async function Ae(e=!1){if("string"==typeof e)e=ae.Url(e);else if("boolean"!=typeof e)throw new ee("Argument should be type: <boolean | string>.",{code:"INVALID_REQUEST"});if(!this.__disabledAccount)throw new ee("Least one signin attempt of disabled account is required.",{code:"INVALID_REQUEST"});return await Fe.bind(this)("recover-account",{username:this.__disabledAccount,redirect:e}),"SUCCESS: Recovery e-mail has been sent."}async function ve(e){ae.Params(e,{idToken:"string",clientId:"string",keyUrl:e=>ae.Url(e),provider:"string",nonce:"string"},["idToken","keyUrl","clientId"]);let{hashedPassword:t,username:n,email:r}=await Fe.bind(this)("jwt-login",e);try{return Ee.bind(this)({username:n,password:t,email:r})}catch(e){if("INCORRECT_USERNAME_OR_PASSWORD"===e?.code)throw new ee("User has migrated the account. Login with the service email and password.",{code:"INVALID_REQUEST"})}}async function Ee(e){let t=ae.Params(e,{username:"string",email:"string",password:"string"},["password"]);if(t.email)try{ae.Email(t.email)}catch(e){t.username=t.email,delete t.email}if(!t.username&&!t.email)throw new ee('Least one of "username" or "email" is required.',{code:"INVALID_PARAMETER"});return ge.bind(this)().authenticateUser(t.username||t.email,t.password)}async function Se(e,t){let n={username:"string",password:e=>ae.Password(e),email:e=>ae.Email(e),name:"string",address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):void 0:"",gender:"string",birthdate:e=>ae.Birthdate(e),phone_number:e=>ae.PhoneNumber(e),email_public:["boolean",()=>!1],address_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1],access_group:"number",misc:"string",picture:e=>e?ae.Url(e):void 0,profile:e=>e?ae.Url(e):void 0,family_name:"string",given_name:"string",middle_name:"string",nickname:"string",website:e=>e?ae.Url(e):void 0},r=ae.Params(e||{},n,["email","password"]);await we.bind(this)(),t=ae.Params(t||{},{email_subscription:e=>{if("boolean"!=typeof e)throw new ee('"option.email_subscription" should be type: <boolean>.',{code:"INVALID_PARAMETER"});if(!t?.signup_confirmation)throw new ee('"option.signup_confirmation" is required for email subscription.',{code:"INVALID_PARAMETER"});return e},signup_confirmation:e=>{let t=e;if("string"==typeof e)t=ae.Url(e);else{if("boolean"!=typeof e)throw new ee('"option.signup_confirmation" should be type: <string | boolean>.',{code:"INVALID_PARAMETER"});t=e}if(t&&!r.email)throw new ee('"email" is required for signup confirmation.',{code:"INVALID_PARAMETER"});return t},login:e=>{if("boolean"==typeof e){if(t.signup_confirmation&&e)throw new ee('"login" is not allowed when "option.signup_confirmation" is true.',{code:"INVALID_PARAMETER"});return e}throw new ee('"option.login" should be type: boolean.',{code:"INVALID_PARAMETER"})}});let i=t?.login||!1;if(r.signup_confirmation=t?.signup_confirmation||!1,r.email_subscription=t?.email_subscription||!1,r.email_public&&!r.signup_confirmation)throw new ee('"option.signup_confirmation" should be true if "email_public" is set to true.',{code:"INVALID_PARAMETER"});r.service=this.service,r.owner=this.owner;let s=ge.bind(this)().createCognitoUser(r.username||r.email);for(let e of["email_public","address_public","gender_public","birthdate_public","phone_number_public"])r[e]=r[e]?"1":"0";r.access_group&&(r.access_group=r.access_group.toString());let o=(await Fe.bind(this)("signupkey",{username:s.cognitoUsername,signup_confirmation:"boolean"==typeof r.signup_confirmation?JSON.stringify(r.signup_confirmation):r.signup_confirmation,email_subscription:r.email_subscription})).split(":"),a=o.slice(1).join(":"),u=[new M({Name:"custom:signup",Value:o[0]}),new M({Name:"locale",Value:a.split("#")[1]}),new M({Name:"custom:signup_ticket",Value:a})];for(let e in n){let t=["email_public","address_public","gender_public","birthdate_public","phone_number_public","misc","service","owner"];""!==r[e]&&"username"!==e&&"password"!==e&&"access_group"!==e&&(t.includes(e)?u.push(new M({Name:"custom:"+e,Value:r[e]})):u.push(new M({Name:e,Value:r[e]})))}return await ge.bind(this)().signup(s.cognitoUsername,r.password,u),r.signup_confirmation?(ue=s.cognitoUser,this.__request_signup_confirmation=s.cognitoUsername,"SUCCESS: The account has been created. User's signup confirmation is required."):i?Ee.bind(this)({email:r.username||r.email,password:r.password}):"SUCCESS: The account has been created."}async function Ie(){await this.__connection;let e=await Fe.bind(this)("remove-account",{disable:this.__user.user_id},{auth:!0});return await we.bind(this)(),e}async function Te(e){await this.__connection;let t=ae.Params(e,{email:e=>ae.Email(e),code:["number","string"],new_password:e=>ae.Password(e)},["email","code","new_password"]),n=t.code,r=t.new_password;return"number"==typeof n&&(n=n.toString()),new Promise((async(e,i)=>{ge.bind(this)().createCognitoUser(t.email).cognitoUser.confirmPassword(n,r,{onSuccess:t=>{e("SUCCESS: New password has been set.")},onFailure:e=>{i(new ee(e?.message||"Failed to reset password.",{code:e?.code}))}})}))}async function Re(e,t){let n;if(await this.__connection,!ue)throw new ee("The user has to be logged in.",{code:"INVALID_REQUEST"});if("email"===e||"phone_number"===e){if(!this.__user.hasOwnProperty(e))throw new ee(`No ${"email"===e?"e-mail":"phone number"} to verify`,{code:"INVALID_REQUEST"});return this.__user?.[`${e}_verified`]?`SUCCESS: "${e}" is verified.`:(n=(t?ae.Params(t,{code:["string"]}):{}).code||"",new Promise(((t,r)=>{let i={onSuccess:i=>{n?ge.bind(this)().getSession({refreshToken:!0}).then((()=>{this.__user&&(this.__user[e+"_verified"]=!0),t(`SUCCESS: "${e}" is verified.`)})).catch((e=>{r(e)})):t("SUCCESS: Verification code has been sent.")},onFailure:e=>{r(new ee(e.message||"Failed to request verification code.",{code:e?.code}))}};n?ue?.verifyAttribute(e,n,i):(i.inputVerificationCode=null,ue?.getAttributeVerificationCode(e,i))})))}}function Ue(e){return Re.bind(this)("phone_number",e)}function De(e){return Re.bind(this)("email",e)}async function Ce(e){await this.__connection;let t=ae.Params(e,{email:e=>ae.Email(e)},["email"]);return new Promise((async(e,n)=>{ge.bind(this)().createCognitoUser(t.email).cognitoUser.forgotPassword({onSuccess:t=>{e("SUCCESS: Verification code has been sent.")},onFailure:e=>{n(new ee(e?.message||"Failed to send verification code.",{code:e?.code||"ERROR"}))}})}))}async function Pe(e){if(await this.__connection,!this.session)throw new ee("User login is required.",{code:"INVALID_REQUEST"});let t=ae.Params(e,{current_password:"string",new_password:"string"});if(!t?.current_password)throw new ee('"current_password" is required to change password.',{code:"INVALID_PARAMETER"});if(!t?.new_password)throw new ee('"new_password" is required to change password.',{code:"INVALID_PARAMETER"});return ae.Password(t.current_password),ae.Password(t.new_password),new Promise(((e,n)=>{ue.changePassword(t.current_password,t.new_password,((t,r)=>{t&&n("InvalidParameterException"===t?.code?new ee("Invalid password parameter.",{code:"INVALID_PARAMETER"}):"NotAuthorizedException"===t?.code?new ee("Incorrect password.",{code:"INVALID_REQUEST"}):"TooManyRequestsException"===t?.code||"LimitExceededException"===t?.code?new ee("Too many attempts. Please try again later.",{code:"REQUEST_EXCEED"}):new ee(t?.message||"Failed to change user password.",{code:t?.code||t?.name})),e("SUCCESS: Password has been changed.")}))}))}async function Ne(e){if(await this.__connection,!this.session)throw new ee("User login is required.",{code:"INVALID_REQUEST"});let t=ae.Params(e||{},{email:e=>ae.Email(e),address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):void 0:"",name:"string",gender:"string",birthdate:e=>ae.Birthdate(e),phone_number:e=>ae.PhoneNumber(e),email_public:"boolean",phone_number_public:"boolean",address_public:"boolean",gender_public:"boolean",birthdate_public:"boolean",misc:"string",picture:e=>ae.Url(e),profile:e=>ae.Url(e),family_name:"string",given_name:"string",middle_name:"string",nickname:"string",website:e=>ae.Url(e)});if(t&&"object"==typeof t&&!Object.keys(t).length)return this.user;t.email&&(t.preferred_username=this.service+"-"+te.hash(t.email));let n=[["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(t[e[0]]&&!this.__user[e[1]])throw new ee(`${e[2]} "${e[0]}" to true.`,{code:"INVALID_REQUEST"});let r=[];for(let e in t)if(t[e]!==this.user[e]){if(["email_public","phone_number_public","address_public","gender_public","birthdate_public","misc"].includes(e)){let n=t[e];"boolean"==typeof n&&(n=n?"1":"0"),t["custom:"+e]=n,r.push(e)}}else r.push(e);for(let e of r)delete t[e];if(t&&"object"==typeof t&&Object.keys(t).length){let e=[];for(let n in t)e.push(new M({Name:n,Value:t[n]}));return await new Promise(((t,n)=>{ue?.updateAttributes(e,((e,r)=>{e&&n([e?.code||e?.name,e?.message||"Failed to update user settings."]),t(r)}))})),await ge.bind(this)().getSession({refreshToken:!0}),this.user}return this.user}async function ke(e,t){e||(e={searchFor:"timestamp",condition:">",value:0},t||(t={}),t.ascending=!1),await this.__connection;const n={user_id:e=>ae.UserId(e),email:e=>ae.Email(e),phone_number:e=>ae.PhoneNumber(e),locale:e=>{if("string"!=typeof e||"string"==typeof e&&e.length>5)throw new ee('Value of "locale" should be a country code.',{code:"INVALID_PARAMETER"});return e},name:"string",address:"string",gender:"string",birthdate:e=>ae.Birthdate(e),subscribers:"number",timestamp:"number",access_group:"number",approved:e=>e?"by_admin:approved":"by_admin:suspended"};if(e=ae.Params(e,{searchFor:["user_id","name","email","phone_number","address","gender","birthdate","locale","subscribers","timestamp","access_group","approved"],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 ee(`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 ee(`Range does not match the type of "${e.searchFor}" index.`,{code:"INVALID_PARAMETER"});return t}},["searchFor","value"]),e?.condition&&"="!==e?.condition&&e.hasOwnProperty("range"))throw new ee("Conditions does not apply on range search.",{code:"INVALID_PARAMETER"});if(["user_id","phone_number","email"].includes(e.searchFor)&&("="!==e.condition||e.range))throw new ee(`Conditions are not allowed on "${e.searchFor}"`,{code:"INVALID_PARAMETER"});if("string"==typeof e?.value&&!e?.value)throw new ee("Value should not be an empty string.",{code:"INVALID_PARAMETER"});if("string"==typeof e?.searchFor&&!e?.searchFor)throw new ee('"searchFor" should not be an empty string.',{code:"INVALID_PARAMETER"});return Fe.bind(this)("get-users",e,{auth:!0,fetchOptions:t})}async function Oe(e){await this.__connection;let t=await Fe.bind(this)("last-verified-email",e,{auth:!0});return t.includes("SUCCESS")?(await ge.bind(this)().getSession({refreshToken:!0}),this.user):t}async function Le(e){return await this.__connection,e=ae.Params(e,{username:ae.Email,redirect:ae.Url},["username"]),await Fe.bind(this)("request-username-change",e,{auth:!0})}async function Me(e,t){const n=await Promise.all([this.admin_endpoint,this.record_endpoint]),r=n[0],i=n[1];let s=e.split("?"),o=s.length>1?"?"+s[1]:"";switch(e=s[0]){case"get-newsletters":case"get-public-newsletters":case"get-users":case"post-userdata":case"remove-account":case"post-secure":case"subscribe-newsletter":case"subscribe-public-newsletter":case"admin-signup":case"confirm-signup":case"recover-account":case"mock":case"service":case"grant-access":case"last-verified-email":case"ticket":case"register-ticket":case"get-newsletter-subscription":case"request-username-change":case"jwt-login":case"client-secret-request":case"signupkey":case"send-inquiry":case"client-secret-request-public":case"block-account":case"grant-access":return(t?r.admin_private:r.admin_public)+e+o;case"post-record":case"get-records":case"subscription":case"get-subscription":case"del-records":case"get-table":case"get-tag":case"get-index":case"get-signed-url":case"grant-private-access":case"request-private-access-key":case"get-ws-group":case"del-files":case"check-schema":return(t?i.record_private:i.record_public)+e+o;default:return ae.Url(e)}}const Ve={};async function Fe(e,t=null,n,r){this.log("request:",{url:e,data:t,options:n,_etc:r||{}}),n=n||{};let{auth:i=!1,method:s="post",bypassAwaitConnection:o=!1}=n;s=s.toUpperCase();let a=null,u=this.service,c=this.owner,l=null,h=await Me.bind(this)(e,!!i);if(!o&&(a=await this.__connection,!a))throw new ee("Invalid connection. The service could have been disabled, or has a restricted CORS.",{code:"INVALID_REQUEST"});if(i){if(!this.session)throw this.log("request:No session",null),new ee("User login is required.",{code:"INVALID_REQUEST"});{this.log("request:session",this.session);let e=Math.floor(Date.now()/1e3);if(this.log("request:tokens:",{exp:this.session.idToken.payload.exp,currTime:e,expiresIn:this.session.idToken.payload.exp-e,token:this.session.accessToken.jwtToken,refreshToken:this.session.refreshToken.token}),this.session.idToken.payload.exp<e){this.log("request:New token",null);try{await ge.bind(this)().getSession({refreshToken:!0})}catch(e){throw this.log("request:New token error",e),new ee("User login is required.",{code:"INVALID_REQUEST"})}}l=this.session?.idToken?.jwtToken,this.log("request:token to use",l)}}let f={},{fetchMore:d=!1,progress:p}=n?.fetchOptions||{};if(n?.fetchOptions&&Object.keys(n.fetchOptions).length){for(let e of["limit","startKey","ascending"])n.fetchOptions.hasOwnProperty(e)&&(f[e]=n.fetchOptions[e]);f=ae.Params(f,{limit:e=>{if("number"!=typeof e)throw new ee("Fetch limit should be a number.",{code:"INVALID_REQUEST"});if(e>1e3)throw new ee("Fetch limit should be below 1000.",{code:"INVALID_REQUEST"});return e},startKey:e=>e,ascending:"boolean"})}let g=r?.ignoreService?{}:{service:u,owner:c};Object.assign(g,f),(t=se(t).data)?t&&"object"==typeof t&&(t=Object.assign(g,t)):t=g;let _=(()=>{if(t&&"object"==typeof t&&Object.keys(t).length&&!(t instanceof FormData)){function n(e){return"object"==typeof e&&null!==e?Object.keys(e).sort().reduce(((t,r)=>("object"==typeof e[r]&&null!==e[r]?t[r]=n(e[r]):t[r]=e[r],t)),{}):e}return te.hash(e+"/"+JSON.stringify(n(t)))}return te.hash(e+"/"+this.service)})(),m=xe.bind(this)({params:t,url:e,fetchMore:d,hashedParams:_});if(!m||m&&"object"==typeof m)return m;if("string"==typeof m&&Ve[m]instanceof Promise)return Ve[m];let y={Accept:"*/*","Content-Type":n.hasOwnProperty("contentType")?null===n.contentType?"application/x-www-form-urlencoded":n.contentType||"application/json":"application/json"};l&&(y.Authorization=l),"application/json"!==y["Content-Type"]&&(y["Content-Meta"]=JSON.stringify({service:u,owner:c}));let w={headers:y};if(n?.responseType&&(w.responseType=n.responseType),"GET"===s){if(t){let e=[];if(t instanceof FormData)for(let[n,r]of t.entries())"string"==typeof r&&(r=encodeURIComponent(r),e.push(`&${n}=${r}`));else e=Object.keys(t).map((e=>{let n=t[e];return"string"!=typeof n&&(n=JSON.stringify(n)),encodeURIComponent(e)+"="+encodeURIComponent(n)}));e.length&&("?"!==h.substring(h.length-1)&&(h+="?"),h+=e.join("&"))}w.body=null}else w.body=t?JSON.stringify(t):null;w.method=s;let b=Be.bind(this)(h,w,p);Ve[m]=b;try{let t=$e.bind(this)({hashedParam:m,url:e,fetched:await b});return m&&Ve.hasOwnProperty(m)&&delete Ve[m],this.log("request:end",t),t}catch(e){throw m&&Ve.hasOwnProperty(m)&&delete Ve[m],this.log("request:err",e),e}}function xe(e){let{params:t={},url:n,fetchMore:r=!1,hashedParams:i}=e||{};if(t.startKey){if(("object"!=typeof t.startKey||!Object.keys(t.startKey).length)&&"start"!==t.startKey&&"end"!==t.startKey)throw new ee(`"${t.startKey}" is invalid startKey key.`,{code:"INVALID_PARAMETER"});"start"===t.startKey&&(r=!1,delete t.startKey)}if(!r&&this.__startKeyHistory?.[n]?.[i]){if(this.__cached_requests?.[n]?.[i]&&delete this.__cached_requests[n][i],Array.isArray(this.__startKeyHistory[n][i])&&this.__startKeyHistory[n][i].length)for(let e of this.__startKeyHistory[n][i]){let t=i+te.hash(e);this.__cached_requests?.[n]&&this.__cached_requests?.[n]?.[t]&&delete this.__cached_requests[n][t]}return delete this.__startKeyHistory[n][i],i}if(!Array.isArray(this.__startKeyHistory?.[n]?.[i]))return i;let s=this.__startKeyHistory[n][i],o=s[s.length-1],a=i;if(o){if("end"===o)return{list:[],startKey:"end",endOfList:!0,startKeyHistory:s};a+=te.hash(o),t.startKey=JSON.parse(o)}return this.__cached_requests?.[n]?.[a]?this.__cached_requests[n][a]:i}function Be(e,t,n){return new Promise(((r,i)=>{let s=new XMLHttpRequest;for(var o in s.open(t.method||"GET",e),t.headers||{})s.setRequestHeader(o,t.headers[o]);t.responseType&&(s.responseType=t.responseType),s.onload=()=>{if(s.status<400)if("json"==t.responseType||"blob"==t.responseType)r(s.response);else{let e=s.responseText;try{e=JSON.parse(e)}catch(e){}r(e)}else if(429===s.status){let o=s.getResponseHeader("Retry-After");o?setTimeout((()=>{Be(e,t,n).then(r,i)}),1e3*parseInt(o)):i("Too many requests")}else{let e=s.status,t=["INVALID_CORS","INVALID_REQUEST","SERVICE_DISABLED","INVALID_PARAMETER","ERROR","EXISTS","NOT_EXISTS"],n=s.responseText;try{n=JSON.parse(n)}catch(e){}if("string"==typeof n){let e=s.response.split(":"),n=e.splice(0,1)[0].trim();i(new ee(e.join(":").trim(),{code:t.includes(n)?n:"ERROR"}))}else if("object"==typeof n&&n?.message){let t=n?.code||(e?e.toString():null)||"ERROR",r=n.message;"string"==typeof r&&(r=r.trim()),i(new ee(r,{code:t}))}else i(n)}},s.onerror=()=>i("Network error"),s.onabort=()=>i("Aborted"),s.ontimeout=()=>i("Timeout"),"function"==typeof n&&(s.onprogress=e=>{n({status:"download",progress:e.loaded/e.total*100,loaded:e.loaded,total:e.total,abort:()=>s.abort()})},s.upload&&(s.upload.onprogress=e=>{n({status:"upload",progress:e.loaded/e.total*100,loaded:e.loaded,total:e.total,abort:()=>s.abort()})})),s.send(t.body)}))}function $e(e){let{hashedParam:t,url:n,fetched:r}=e;if(!r?.startKey)return r;this.__startKeyHistory.hasOwnProperty(n)||(this.__startKeyHistory[n]={}),this.__cached_requests?.[n]||(this.__cached_requests[n]={}),this.__cached_requests[n][t]=r,this.__startKeyHistory[n].hasOwnProperty(t)||(this.__startKeyHistory[n][t]=[]);let i="end"===r.startKey?"end":JSON.stringify(r.startKey);return this.__startKeyHistory[n][t].includes(i)||this.__startKeyHistory[n][t].push(i),Object.assign({startKeyHistory:this.__startKeyHistory[n][t]},r)}async function qe(e,t){await this.__connection;let{record_id:n,service:r=this.service,progress:i}=t;if(!n)throw new ee('"record_id" is required.',{code:"INVALID_PARAMETER"});if(e instanceof SubmitEvent&&(e=e.target),e instanceof HTMLFormElement&&(e=new FormData(e)),!(e instanceof FormData))throw new ee('"fileList" should be a FormData or HTMLFormElement.',{code:"INVALID_PARAMETER"});let s,o={reserved_key:ie(),service:r,request:"post"};t?.record_id&&(o.id=t.record_id);let a=(e,t,n)=>new Promise(((r,i)=>{s=new XMLHttpRequest,s.open("POST",e),s.onload=()=>{let o=s.responseText;try{o=JSON.parse(o)}catch(e){}if(s.status>=200&&s.status<300)r(o);else if(429===s.status){let o=s.getResponseHeader("Retry-After");o?setTimeout((()=>{a(e,t,n).then(r,i)}),1e3*parseInt(o)):i("Too many requests")}else i(o)},s.onerror=()=>i("Network error"),s.onabort=()=>i("Aborted"),s.ontimeout=()=>i("Timeout"),s.upload&&"function"==typeof n&&(s.upload.onprogress=n),s.send(t)})),u=[],c=[];function l(e){const t="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";if(0===e)return t[0];let n="";for(;e>0;)n=t[e%62]+n,e=Math.floor(e/62);return n}let h=[];for(let[t,n]of e.entries()){if(!(n instanceof File))continue;let e=Object.assign({key:t+"/"+n.name,sizeKey:l(n.size),contentType:n.type||null},o),{fields:r=null,url:f,cdn:d}=await Fe.bind(this)("get-signed-url",e,{auth:!0});h.push(d);let p=new FormData;for(let e in r)p.append(e,r[e]);p.append("file",n);try{await a(f,p,"function"==typeof i?e=>i({status:"upload",progress:e.loaded/e.total*100,currentFile:n,completed:u,failed:c,loaded:e.loaded,total:e.total,abort:()=>s.abort()}):null),u.push(n)}catch(e){c.push(n)}}return{completed:u,failed:c,bin_endpoints:h}}const je={};function Ke(e){let{preventMultipleCalls:t=!1}=e||{};return function(e,n,r){const i=r.value;r.value=function(...e){let r=e[0],s=!0,o=null,a="",u={},c=!1;if(r instanceof SubmitEvent){r.preventDefault();let e=window.location.href;o=r.target;let t=new URL(o.action);a=t.href;let n=a?a.match(/(?<=\{).*?(?=\})/g):"";if(n)for(let e of n){if(!e)continue;let t=o.querySelector(`[name="${e}"]`);if(t)if("file"===t.type)for(let n=0;n<=t.files.length-1;n++)t.files[n]&&(u[e]||(u[e]=[]),u[e].push(new Promise(((e,r)=>{let i=new FileReader;i.onload=function(){e(i.result)},i.readAsDataURL(t.files[n]),i.onerror=r}))));else a=a.replace(`{${e}}`,t.value)}null===o.getAttribute("action")?s=!1:c=t.href===e}const l=async e=>{if(a)for(let e in u)u[e].length&&(a=a.replace(`{${e}}`,(await Promise.all(u[e])).join(",")));return o&&s&&(window.sessionStorage.setItem(`${this.service}:${te.hash(a)}`,JSON.stringify(e)),c?window.location.replace(a):window.location.href=a),e};let h;const f=async()=>{try{if(h=i.bind(this)(...e),h instanceof Promise){let e=await h;return await l(e),h}}catch(e){throw(e=>{throw e instanceof ee?e.name=n+"()":e=e instanceof Error?e:new ee(e,{name:n+"()"}),e})(e)}};return t?(je?.[n]||(je[n]=f().finally((()=>{delete je[n]}))),je[n]):f()}}}async function He(){await this.__connection;let e=`${this.service}:${te.hash(window.location.href.split("?")[0])}`,t=window.sessionStorage.getItem(e);if(null!==t){try{t=JSON.parse(t)}catch(e){}return t}return null}const Je=4503599627370496;async function We(e){const t={user_id:"",record_id:"",updated:0,uploaded:0,table:{name:"",access_group:0},reference:{reference_limit:null,allow_multiple_reference:!0,referenced_count:0},ip:"",bin:{}},n={ip:e=>{"R"===e.slice(-1)?(t.readonly=!0,e=e.slice(0,-1)):t.readonly=!1,t.ip=e},rec:e=>{if(!e)return;t.record_id=e;let n=re(e.substring(0,e.length-9));t.uploaded=n},usr:e=>{t.user_id=e},tbl:e=>{if(e&&!t.table.name){let n=e.split("/");t.table.name=n[0];let r="**"==n[2]?"private":parseInt(n[2]);r=0==r?"public":1==r?"authorized":r,t.table.access_group=r,t.table.subscription=!!n?.[3]}},usr_tbl:e=>{let n=e.split("/");if(t.user_id||(t.user_id=n[0]),!t.table.name){t.table.name=n[1];let e="**"==n[3]?"private":parseInt(n[3]);e=0==e?"public":1==e?"authorized":e,t.table.access_group=e,t.table.subscription=!!n?.[4]}},idx:e=>{if(!e)return;let n=e.split("!"),r=n.splice(0,1)[0],i=function(e){let t=e.substring(3);switch(e.substring(0,3)){case"!S%":return t;case"!N%":let n=t.split("."),r=Number(n[0])-4503599627370496;return 1===n.length?r:parseFloat(r.toString()+"."+n[1]);case"!B%":return"1"===t;case"!L%":case"!D%":try{return JSON.parse(t)}catch(e){throw new ee("Value parse error.",{code:"PARSE_ERROR"})}default:return e}}("!"+n.join("!"));t.index={name:r,value:i}},ref:e=>{e&&(t.reference.record_id=e.split("/")[0])},tags:e=>{t.tags=e},upd:e=>{t.updated=e},acpt_mrf:e=>{t.reference.allow_multiple_reference=e},ref_limt:e=>{t.reference.reference_limit=e},rfd:e=>{t.reference.referenced_count=e},bin:async e=>{let n={};if(Array.isArray(e))for(let t of e){let e=t.split("/").slice(3).join("/"),r=e.split("/"),i=decodeURIComponent(r.slice(-1)[0]),s=decodeURIComponent(r[10]),o=r[9],a=r[8],u="**"==r[6]?"private":parseInt(r[6]);u=0==u?"public":1==u?"authorized":u;let c=t;"public"!==u&&(c="private"===u&&this.__user?.user_id!==r[3]?t:await Ye.bind(this)(t,{dataType:"endpoint"}));let l={access_group:u,filename:i,url:c,path:e,size:re(o),uploaded:re(a),getFile:(e,n)=>{let r={dataType:e||"download",progress:n};return Ye.bind(this)(t,r)}};n[s]?n[s].push(l):n[s]=[l]}t.bin=n},data:e=>{let n=e;"!D%{}"===e?n={}:"!L%[]"===e&&(n=[]),t.data=n}};if(e.record_id)return e;for(let t in n)if(e.hasOwnProperty(t)){let r=n[t](e[t]);r instanceof Promise&&await r}return e.private_key&&(this.__private_access_key[t.record_id]=e.private_key),t}async function Qe(e){let{endpoints:t}=e;if("string"==typeof t&&(t=[t]),!Array.isArray(t))throw new ee('"endpoints" should be type: array | string.',{code:"INVALID_PARAMETER"});let n=await Fe.bind(this)("del-files",{endpoints:t,storage:"records"},{auth:!0,method:"post"});for(let e in n)n[e]=We.bind(this)(n[e]);return await Promise.all(n)}async function Ye(e,t){if("string"!=typeof e)throw new ee('"url" should be type: string.',{code:"INVALID_PARAMETER"});ae.Url(e);let n=!1,r=e.split("/"),i=r[2].split("."),s=null;3===i.length&&"skapi"===i[1]&&(s=i[0],n=!0);let o=r.slice(3),a=!1;if(!n&&("auth"===o[0]||"publ"===o[0]))try{ae.UserId(o[2]),ae.UserId(o[3]),a="auth"==o[0],n=!0}catch{throw new ee("Invalid file url.",{code:"INVALID_PARAMETER"})}let u=s?null:o[1];t=ae.Params(t,{expires:["number",()=>0],dataType:["base64","blob","endpoint","text",()=>"download"],progress:"function"});let c=e.split("/").slice(-1)[0],l=t.expires;if(l){if(!n)throw new ee("Expires option can only be used on skapi cdn endpoints.",{code:"INVALID_PARAMETER"});if(l<0)throw new ee('"config.expires" should be > 0. (seconds)',{code:"INVALID_PARAMETER"});let t={request:s?"get-host":"get",id:s||o[5],key:e,expires:l};u&&(t.service=u),e=(await Fe.bind(this)("get-signed-url",t,{auth:!0})).url}else if(a){let t=this.session?.idToken?.jwtToken,n="**"===o[6]?"**":parseInt(o[6]);if(!t)throw new ee("User login is required.",{code:"INVALID_REQUEST"});{let e=Math.floor(Date.now()/1e3);if(this.session.idToken.payload.exp<e){this.log("request:New token",null);try{await ge.bind(this)().getSession()}catch(e){throw this.log("request:New token error",e),new ee("User login is required.",{code:"INVALID_REQUEST"})}}t=this.session?.idToken?.jwtToken}if("**"===n){if(this.__user.user_id!==o[3])throw new ee("User has no access.",{code:"INVALID_REQUEST"})}else if(this.__user.access_group<n)throw new ee("User has no access.",{code:"INVALID_REQUEST"});e+=`?t=${t}`}if("endpoint"===t?.dataType)return e;if("download"===t?.dataType){let t=document.createElement("a");return t.href=e,document.body.appendChild(t),t.setAttribute("download",c),t.target="_blank",t.click(),document.body.removeChild(t),null}return new Promise((async(n,r)=>{try{let r=await Fe.bind(this)(e,null,{method:"get",contentType:null,responseType:"text"===t?.dataType?"text":"blob",fetchOptions:{progress:t?.progress}},{ignoreService:!0});if("base64"===t?.dataType){const e=new FileReader;e.onloadend=()=>n(e.result),e.readAsDataURL(r)}else n(r)}catch(e){r(e)}}))}async function Ge(e,t){await this.__connection,"string"==typeof e?.table&&(e.table={name:e.table,access_group:0});let n="",r="";if(e?.record_id){ae.specialChars(e.record_id,"record_id",!1,!1);let t={record_id:e.record_id};e?.service&&(t.service=e.service),e=t,this.__private_access_key[e.record_id]&&(e.private_key=this.__private_access_key[e.record_id])}else{const t={table:{name:[e=>{if(!e)throw new ee('"table.name" cannot be empty string.',{code:"INVALID_PARAMETER"});return ae.specialChars(e,"table name",!0,!0)}],access_group:[t=>{if(void 0===t)return!this.__user&&e.table.hasOwnProperty("subscription")?1:0;if("number"==typeof t){if((this.__user?.access_group||0)<t)throw new ee("User has no access",{code:"INVALID_REQUEST"})}else{if("string"!=typeof t)throw new ee('"table.access_group" should be type: <number | string>.',{code:"INVALID_PARAMETER"});if("private"===(t={private:"private",public:0,authorized:1}[t])&&!this.__user)throw new ee("Unsigned users have no access to private records.",{code:"INVALID_REQUEST"});if(void 0===t)throw new ee('"table.access_group" is invalid.',{code:"INVALID_PARAMETER"})}return t}],subscription:e=>{if(null==e)return e;if(ae.UserId(e,'User ID in "subscription"'),!this.__user)throw new ee("Unsigned users have no access to subscription records.",{code:"INVALID_REQUEST"});return{user_id:e,group:1}}},reference:t=>{if(null==t)return t;if("string"==typeof t){try{r=ae.UserId(t)}catch(r){ae.specialChars(t,"reference",!1,!1),n=t,this.__private_access_key[n]&&(e.private_key=this.__private_access_key[n])}return n=t,t}throw new ee('"reference" should be type: string.',{code:"INVALID_PARAMETER"})},index:{name:["$updated","$uploaded","$referenced_count","$user_id",e=>{if(void 0===e)throw new ee('"index.name" is required.',{code:"INVALID_PARAMETER"});if("string"!=typeof e)throw new ee('"index.name" should be type: string.',{code:"INVALID_PARAMETER"});return ae.specialChars(e,"index.name",!0,!1)}],value:t=>{const n={$updated:"number",$uploaded:"number",$referenced_count:"number",$user_id:ae.UserId};if(n.hasOwnProperty(e.index.name)){let r=n[e.index.name];if("function"==typeof r)return r(t);if(r!==typeof t)throw new ee(`"index.value" should be type: ${r}.`,{code:"INVALID_PARAMETER"});return t}if("number"==typeof t){if(t>Je||t<-4503599627370496)throw new ee("Number value should be within range -4503599627370496 ~ +4503599627370496",{code:"INVALID_PARAMETER"});return t}if("boolean"==typeof t)return t;if("string"==typeof t)return t;throw new ee('"index.value" should be type: <number | boolean | string>.',{code:"INVALID_PARAMETER"})},condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"],range:t=>{if(!e.index||!("value"in e.index))throw new ee('"index.value" is required.',{code:"INVALID_PARAMETER"});if("$record_id"===e.index.name)throw new ee(`Cannot do "index.range" on ${e.index.name}`,{code:"INVALID_PARAMETER"});if(typeof e.index.value!=typeof t)throw new ee('"index.range" type should match the type of "index.value".',{code:"INVALID_PARAMETER"});return"string"==typeof t?ae.specialChars(t,"index.range",!1,!0):t}},tag:e=>{if(null==e)return e;if("string"==typeof e)return ae.specialChars(e,"tag",!1,!0);throw new ee('"tag" should be type: string.',{code:"INVALID_PARAMETER"})},private_key:"string"};let i=await me.bind(this)();e=ae.Params(e||{},t,r||i?[]:["table"])}let i=await Fe.bind(this)("get-records",e,{fetchOptions:t,auth:!!this.__user,method:this.__user?"post":"get"});for(let e in i.list)i.list[e]=We.bind(this)(i.list[e]);return i.list=await Promise.all(i.list),n&&i?.reference_private_key&&(this.__private_access_key[n]=i.reference_private_key),i}async function ze(e){return Fe.bind(this)("check-schema",e)}async function Ze(e,t){let n=await me.bind(this)();if(!t)throw new ee('"config" argument is required.',{code:"INVALID_PARAMETER"});if(!this.user)throw new ee("Login is required.",{code:"INVALID_REQUEST"});"string"==typeof t.table&&(t.table={name:t.table},t.record_id||(t.table.access_group=0)),"string"==typeof t.reference&&(t.reference={record_id:t.reference});let r=ae.Params(t||{},{record_id:["string",()=>{if(!t.table||!t.table.name)throw new ee('"table.name" is required.',{code:"INVALID_PARAMETER"})}],readonly:"boolean",table:{name:e=>{if(!e)throw new ee('"table.name" cannot be empty string.',{code:"INVALID_PARAMETER"});return ae.specialChars(e,"table name",!0,!0)},subscription:e=>{if(e&&(!t.record_id&&!t.table.access_group||0===t.table.access_group||"public"===t.table.access_group))throw new ee("Public records cannot require subscription.",{code:"INVALID_REQUEST"});return e},access_group:e=>{if("string"==typeof e&&(e={private:"private",public:0,authorized:1}[e]),"number"==typeof e&&!n&&this.user.access_group<e)throw new ee("User has no access",{code:"INVALID_REQUEST"});if(void 0===e)throw new ee('"table.access_group" is invalid.',{code:"INVALID_PARAMETER"});return e}},reference:{record_id:e=>(ae.specialChars(e,'"reference.record_id"',!1,!1),this.__private_access_key[e]&&(t.reference_private_key=this.__private_access_key[e]),e),reference_limit:e=>{if(null===e)return null;if("number"==typeof e){if(0>e)throw new ee('"reference_limit" should be >= 0',{code:"INVALID_PARAMETER"});if(e>4503599627370546)throw new ee('"reference_limit" should be <= 4503599627370546',{code:"INVALID_PARAMETER"});return e}throw new ee('"reference_limit" should be type: <number | null>',{code:"INVALID_PARAMETER"})},allow_multiple_reference:"boolean"},index:{name:["$uploaded","$updated","$referenced_count","$user_id",e=>{if(!e)throw new ee('"index.name" is required.',{code:"INVALID_PARAMETER"});if("string"==typeof e)return ae.specialChars(e,"index name",!0),e;throw new ee('"index.name" should be type: string.',{code:"INVALID_PARAMETER"})}],value:[e=>{if(!e&&"boolean"!=typeof e&&0!==e)throw new ee('"index.value" is required.',{code:"INVALID_PARAMETER"});if(!["boolean","string","number"].includes(typeof e))throw new ee('"index.value" should be type: <boolean | string | number>.',{code:"INVALID_PARAMETER"});if("string"==typeof e)ae.specialChars(e,"index value",!1,!0);else if("number"==typeof e&&(e>Je||e<-4503599627370496))throw new ee("Number value should be within range -4503599627370496 ~ +4503599627370496",{code:"INVALID_PARAMETER"});return e}]},tags:e=>null==e?e:("string"==typeof e&&(e=e.split(",").map((e=>e.trim()))),ae.specialChars(e,"tag",!1,!0)),remove_bin:e=>{if(!e)return null;let t=[];if(!Array.isArray(e))throw new ee('"remove_bin" should be type: <string[] | BinaryFile[]>',{code:"INVALID_PARAMETER"});for(let n of e)if("string"==typeof n)t.push(n);else{if(!(n.url&&n.size&&n.filename))throw new ee('"remove_bin" should be type: <string[] | BinaryFile[]>',{code:"INVALID_PARAMETER"});t.push(n.url)}return t},progress:"function"}),i=t.progress||null;t.table&&t.table.hasOwnProperty("subscription")&&(r.table.subscription_group=t.table.subscription?1:null,delete r.table.subscription),delete r.progress;let s={auth:!0},o=null,a=null,u=se(e);u.files.length&&(a=u.files),o=Object.assign({data:u.data},r);let c={};"function"==typeof i&&(c.progress=i),Object.keys(c).length&&Object.assign(s,{fetchOptions:c}),o.schema_pass=await ze.bind(this)(r);let l=await Fe.bind(this)("post-record",o,s);if(a){let e=new FormData;for(let t of a)e.append(t.name,t.file,t.file.name);let t={record_id:l.rec,progress:i};r.hasOwnProperty("service")&&(t.service=r.service);let{bin_endpoints:n}=await qe.bind(this)(e,t);l.bin?l.bin.push(...n):l.bin=n}return We.bind(this)(l)}async function Xe(e,t){let n=await Fe.bind(this)("get-table",ae.Params(e||{},{table:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!!this.__user},{fetchOptions:t})),r={cnt_rec:"number_of_records",tbl:"table",srvc:"service"};if(Array.isArray(n?.list))for(let e of n.list)for(let t in r)e.hasOwnProperty(t)&&(e[r[t]]=e[t],delete e[t]);return n}async function et(e,t){if(!e?.table)throw new ee('"table" is required.',{code:"INVALID_PARAMETER"});let n=ae.Params(e||{},{table:"string",index:e=>ae.specialChars(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(n.hasOwnProperty("order")){if(!n.order?.by)throw new ee('"order.by" is required.',{code:"INVALID_PARAMETER"});if(n.order.hasOwnProperty("condition")&&!n.order.hasOwnProperty("value"))throw new ee('"value" is required for "condition".',{code:"INVALID_PARAMETER"});if(n.hasOwnProperty("index")&&"."!==n.index.substring(n.index.length-1))throw new ee('"index" should be a parent index name of the compound index when using "order.by"',{code:"INVALID_PARAMETER"})}let r=await Fe.bind(this)("get-index",n,Object.assign({auth:!!this.__user},{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(r?.list)&&(r.list=r.list.map((e=>{let t=e.idx.split("/"),n={table:t[1],index:t[2],number_of_records:e.cnt_rec};for(let t in i)e?.[t]&&(n[i[t]]=e[t]);return n}))),r}async function tt(e,t){let n=await Fe.bind(this)("get-tag",ae.Params(e||{},{table:"string",tag:"string",condition:["gt","gte","lt","lte",">",">=","<","<=","=","eq","!=","ne"]}),Object.assign({auth:!!this.__user},{fetchOptions:t}));if(Array.isArray(n?.list))for(let e in n.list){let t=n.list[e],r=t.tag.split("/");n.list[e]={table:r[1],tag:r[0],number_of_records:t.cnt_rec}}return n}async function nt(e){let t=await me.bind(this)();if(t&&!e?.service)throw new ee("Service ID is required.",{code:"INVALID_PARAMETER"});if(e?.record_id)return await Fe.bind(this)("del-records",{service:e.service||this.service,record_id:(e=>{if("string"==typeof e)return[e];if(!Array.isArray(e))throw new ee('"record_id" should be type: <string | string[]>',{code:"INVALID_PARAMETER"});if(e.length>100)throw new ee('"record_id" should not exceed 100 items.',{code:"INVALID_PARAMETER"});return ae.specialChars(e,"record_id",!1,!1)})(e.record_id)},{auth:!0});{if(!e?.table)throw new ee('Either "table" or "record_id" is required.',{code:"INVALID_PARAMETER"});let n={access_group:e=>{if("string"==typeof e&&["private","public","authorized"].includes(e))switch(e){case"private":return e;case"public":return 0;case"authorized":return 1}else if("number"==typeof e&&e>=0&&e<100)return e;throw new ee('Invalid "table.access_group". Access group should be type <number (0~99) | "private" | "public" | "authorized">.',{code:"INVALID_PARAMETER"})},name:"string",subscription:n=>{if("boolean"==typeof n&&n)return this.__user.user_id;if(!e.table.hasOwnProperty("access_group"))throw new ee('"table.access_group" is required for subscription records.',{code:"INVALID_PARAMETER"});if(0===e.table.access_group)throw new ee("Public tables does not hold subscription records.",{code:"INVALID_REQUEST"});if(t&&"string"==typeof n)return ae.UserId(n,'User ID in "table.subscription"');throw new ee('"table.subscription" is an invalid parameter key.',{code:"INVALID_PARAMETER"})}},r=ae.Params(e.table||{},n,t?[]:["name"]);r.subscription&&(r.subscription_group=1);let i=Object.assign({},e,{table:r});return await Fe.bind(this)("del-records",i,{auth:!0})}}function rt(e){if(!e.record_id)throw new ee("Record ID is required.",{code:"INVALID_PARAMETER"});if(!e.user_id||Array.isArray(e.user_id)&&!e.user_id.length)throw new ee("User ID is required.",{code:"INVALID_PARAMETER"});return at.bind(this)({record_id:e.record_id,user_id:e.user_id||null,execute:"add"})}function it(e){if(!e.record_id)throw new ee("Record ID is required.",{code:"INVALID_PARAMETER"});if(!e.user_id||Array.isArray(e.user_id)&&!e.user_id.length)throw new ee("User ID is required.",{code:"INVALID_PARAMETER"});return at.bind(this)({record_id:e.record_id,user_id:e.user_id||null,execute:"remove"})}async function st(e){let t=await at.bind(this)({record_id:e.record_id,user_id:e.user_id||null,execute:"list"});return t.list=t.list.map((e=>(e.record_id=e.rec_usr.split("/")[0],e.user_id=e.rec_usr.split("/")[1],e))),t}function ot(e){return Fe.bind(this)("request-private-access-key",{record_id:e},{auth:!0})}function at(e){let t=e.execute,n=ae.Params(e,{record_id:"string",user_id:e=>{if(!e){if("list"==t)return null;throw new ee("User ID is required.",{code:"INVALID_PARAMETER"})}let n=e;if("string"==typeof n&&(n=[n]),n.length>100)throw new ee("Cannot process more than 100 users at once.",{code:"INVALID_REQUEST"});for(let e of n)ae.UserId(e,'User ID in "user_id"');return n},execute:["add","remove","list"]},["execute","record_id","user_id"]);return n.user_id||(n.user_id=null),Fe.bind(this)("grant-private-access",n,{auth:!0})}async function ut(){if(await this.getProfile(),!this.session)throw new ee("No access.",{code:"INVALID_REQUEST"});let e=await this.record_endpoint;return new WebSocket(e.websocket_private+"?token="+this.session.accessToken.jwtToken)}let ct=0,lt={},ht={},ft=null;function dt(e,t=0){if("function"!=typeof e)throw new ee("Callback must be a function.",{code:"INVALID_REQUEST"});return!ct&&this.__socket instanceof Promise||(this.__socket=new Promise((async n=>{setTimeout((async()=>{if(await this.__connection,!await this.getProfile())throw new ee("No access.",{code:"INVALID_REQUEST"});let t=await ut.bind(this)();t.onopen=()=>{ct=0,e({type:"success",message:"Connected to WebSocket server."}),this.__socket_room&&t.send(JSON.stringify({action:"joinRoom",rid:this.__socket_room,token:this.session.accessToken.jwtToken})),ft=setInterval((()=>{1===t.readyState&&t.send(JSON.stringify({action:"keepAlive",token:this.session.accessToken.jwtToken}))}),3e4),n(t)},t.onmessage=async t=>{let n=JSON.parse(decodeURI(t.data)),r="message";n?.["#private"]?r="private":n?.["#notice"]&&(r="notice");let i={type:r,message:n?.["#message"]||n?.["#private"]||n?.["#notice"]||null};if(n?.["#user_id"]&&(i.sender=n["#user_id"]),n?.["#scid"]&&(i.sender_cid=n["#scid"]),"notice"===r)if(this.__socket_room&&(i.message.includes("has left the message group.")||i.message.includes("has been disconnected."))){ht[this.__socket_room]&&await ht[this.__socket_room];let e=i.sender;if(lt?.[this.__socket_room]?.[e]&&(lt[this.__socket_room][e]=lt[this.__socket_room][e].filter((e=>e!==i.sender_cid))),lt?.[this.__socket_room]?.[e]&&0===lt[this.__socket_room][e].length&&delete lt[this.__socket_room][e],lt?.[this.__socket_room]?.[e])return}else if(this.__socket_room&&i.message.includes("has joined the message group.")){ht[this.__socket_room]&&await ht[this.__socket_room];let e=i.sender;if(lt?.[this.__socket_room]||(lt[this.__socket_room]={}),lt[this.__socket_room][e])return void(lt[this.__socket_room][e].includes(i.sender_cid)||lt[this.__socket_room][e].push(i.sender_cid));lt[this.__socket_room][e]=[i.sender_cid]}e(i)},t.onclose=t=>{if(t.wasClean)clearInterval(ft),ft=null,e({type:"close",message:"WebSocket connection closed."}),this.__socket=null,this.__socket_room=null;else if(ct++,ct<10){let t=Math.min(1e3*2**ct,3e4);e({type:"error",message:`Skapi: WebSocket connection error. Reconnecting in ${t/1e3} seconds...`}),dt.bind(this)(e,t)}else e({type:"error",message:"Skapi: WebSocket connection error. Max reconnection attempts reached."}),this.__socket=null},t.onerror=()=>{throw e({type:"error",message:"Skapi: WebSocket connection error."}),new ee("Skapi: WebSocket connection error.",{code:"ERROR"})}}),t)}))),this.__socket}async function pt(){let e=this.__socket?await this.__socket:this.__socket;return e&&e.close(),this.__socket=null,this.__socket_room=null,null}async function gt(e,t){let n=this.__socket?await this.__socket:this.__socket;if(!n)throw new ee("No realtime connection. Execute connectRealtime() before this method.",{code:"INVALID_REQUEST"});if(!t)throw new ee("No recipient.",{code:"INVALID_REQUEST"});if(e=se(e).data,1===n.readyState){try{ae.UserId(t),n.send(JSON.stringify({action:"sendMessage",uid:t,content:e,token:this.session.accessToken.jwtToken}))}catch(r){if(this.__socket_room!==t)throw new ee(`User has not joined to the recipient group. Run joinRealtime({ group: "${t}" })`,{code:"INVALID_REQUEST"});n.send(JSON.stringify({action:"broadcast",rid:t,content:e,token:this.session.accessToken.jwtToken}))}return{type:"success",message:"Message sent."}}throw new ee("Realtime connection is not open. Try reconnecting with connectRealtime().",{code:"INVALID_REQUEST"})}async function _t(e){let t=this.__socket?await this.__socket:this.__socket;if(!t)throw new ee("No realtime connection. Execute connectRealtime() before this method.",{code:"INVALID_REQUEST"});e=se(e).data;let{group:n=null}=e;if(!n&&!this.__socket_room)return{type:"success",message:"Left realtime message group."};if(null!==n&&"string"!=typeof n)throw new ee('"group" must be a string | null.',{code:"INVALID_PARAMETER"});return t.send(JSON.stringify({action:"joinRoom",rid:n,token:this.session.accessToken.jwtToken})),this.__socket_room=n,{type:"success",message:n?`Joined realtime message group: "${n}".`:"Left realtime message group."}}async function mt(e,t){if(await this.__connection,!(e=ae.Params(e,{user_id:e=>ae.UserId(e,'User ID in "user_id"'),group:"string"},["group"])).group)throw new ee('"group" is required.',{code:"INVALID_PARAMETER"});if(!e.user_id&&ht[e.group])return ht[e.group];let n=Fe.bind(this)("get-ws-group",e,{fetchOptions:t,auth:!0,method:"post"}).then((t=>(t.list=t.list.map((t=>{let n=t.uid.split("#")[1];return e.user_id||(lt[e.group]||(lt[e.group]={}),lt[e.group][n]?lt[e.group][n].includes(t.cid)||lt[e.group][n].push(t.cid):lt[e.group][n]=[t.cid]),{user_id:n,connection_id:t.cid}})),t))).finally((()=>{delete ht[e.group]}));return e.user_id||ht[e.group]||(ht[e.group]=n),n}async function yt(e,t){if(await this.__connection,e||(e={searchFor:"group"}),(e=ae.Params(e,{searchFor:["group","number_of_users",()=>"group"],value:["string","number",()=>e?.searchFor&&"number_of_users"===e?.searchFor?0:" "],condition:[">",">=","=","<","<=","!=","gt","gte","eq","lt","lte","ne"],range:["string","number"]})).condition||(" "!==e.value&&e.value?e.condition="=":e.condition=">"),e.range&&e.condition&&delete e.condition,"number_of_users"===e.searchFor&&"number"!=typeof e.value)throw new ee('"value" must be a number.',{code:"INVALID_PARAMETER"});if("group"===e.searchFor&&"string"!=typeof e.value)throw new ee('"value" must be a string.',{code:"INVALID_PARAMETER"});if(e.hasOwnProperty("range")&&typeof e.range!=typeof e.value)throw new ee(`"range" must be a ${typeof e.value}.`,{code:"INVALID_PARAMETER"});let n=await Fe.bind(this)("get-ws-group",e,{fetchOptions:t,auth:!0,method:"post"});return n.list=n.list.map((e=>({group:e.rid.split("#")[1],number_of_users:e.cnt}))),n}async function wt(e){let t=!1,n=e=>{for(let n in e)if("string"==typeof e[n]&&e[n].includes("$CLIENT_SECRET")){t=!0;break}};if(ae.Params(e,{url:e=>{if(!e||"string"!=typeof e)throw new ee('"url" should be type: <string>.',{code:"INVALID_PARAMETER"});return ae.Url(e),e.includes("$CLIENT_SECRET")&&(t=!0),e},clientSecretName:"string",method:e=>{if(e&&"string"!=typeof e)throw new ee('"method" should be either "GET" or "POST" or "DELETE" or "PUT".',{code:"INVALID_PARAMETER"});let t=e.toLowerCase();if("get"!==t&&"post"!==t&&"delete"!==t&&"put"!==t)throw new ee('"method" should be either "GET" or "POST" or "DELETE" or "PUT".',{code:"INVALID_PARAMETER"});return t},headers:e=>{if(e&&"object"!=typeof e)throw new ee('"headers" should be type: <object>.',{code:"INVALID_PARAMETER"});return n(e),e},data:e=>{if(e&&"object"!=typeof e)throw new ee('"data" should be type: <object>.',{code:"INVALID_PARAMETER"});return n(e),e},params:e=>{if(e&&"object"!=typeof e)throw new ee('"params" should be type: <object>.',{code:"INVALID_PARAMETER"});return n(e),e}},["clientSecretName","method","url"]),!t)throw new ee(`At least one parameter value should include "$CLIENT_SECRET" in ${"post"===e.method.toLowerCase()?'"data"':'"params"'} or "headers".`,{code:"INVALID_PARAMETER"});await this.__connection;let r=!!this.__user;return Fe.bind(this)("client-secret-request"+(r?"-public":""),e,{auth:r})}async function bt(e){await this.__connection;let t={name:"string",email:e=>(ae.Email(e),e),subject:"string",message:"string"};return e=ae.Params(e,t,["name","email","subject","message"]),await Fe.bind(this)("send-inquiry",e),"SUCCESS: Inquiry has been sent."}async function At(e,t){if(await this.__connection,e instanceof FormData||e instanceof HTMLFormElement||e instanceof SubmitEvent){if(!t)throw new ee("Url string as a second argument is required when form is passed.",{code:"INVALID_PARAMETER"});e={url:t,data:se(e).data,sync:!0}}let n={url:e=>ae.Url(e),data:e=>e,sync:["boolean",()=>!0]};if(Array.isArray(e))for(let t of e)t=ae.Params(t,n);else e=ae.Params(e,n);return Fe.bind(this)("post-secure",e,{auth:!0})}async function vt(e,t){await this.__connection;let{auth:n=!1,method:r="POST",bypassAwaitConnection:i=!1,responseType:s,contentType:o,progress:a}=t||{};if(t=Object.assign({auth:n,method:r,bypassAwaitConnection:i,responseType:s,contentType:o},{fetchOptions:{progress:a}}),"object"!=typeof e&&("application/json"===o||void 0===o))throw new ee('"data" should be type: <object>.',{code:"INVALID_PARAMETER"});return Fe.bind(this)("mock",e,t)}function Et(e){return ae.Params(e,{user_id:e=>{if(!this.__user)throw new ee("User should be logged in.",{code:"INVALID_REQUEST"});if(e===this.__user.user_id)throw new ee('"user_id" cannot be the user\'s own ID.',{code:"INVALID_PARAMETER"});return ae.UserId(e,'"user_id"')}},["user_id"])}async function St(e,t,n){if(!(e=ae.Params(e,{subscriber:e=>ae.UserId(e,'User ID in "subscriber"'),subscription:e=>ae.UserId(e,'User ID in "subscription"'),blocked:"boolean"})).subscriber&&!e.subscription)throw new ee('At least either "subscriber" or "subscription" should have a value.',{code:"INVALID_PARAMETER"});Object.assign(e,{group:1});let r=await Fe.bind(this)("get-subscription",e,Object.assign({auth:!0},{fetchOptions:t}));return r.list=r.list.map(n||(e=>{let t={},n=e.sub.split("#");return t.subscriber=n[2],t.subscription=n[0],t.group=parseInt(n[1]),t.timestamp=e.stmp,t.blocked="N"===e.grp.substring(0,1),t})),r}async function It(e){await this.__connection;let{user_id:t}=Et.bind(this)(e);return await Fe.bind(this)("subscription",{subscribe:t,group:1},{auth:!0})}async function Tt(e){await this.__connection;let{user_id:t}=Et.bind(this)(e);return await Fe.bind(this)("subscription",{unsubscribe:t,group:1},{auth:!0})}async function Rt(e){await this.__connection;let{user_id:t}=Et.bind(this)(e);return await Fe.bind(this)("subscription",{block:t,group:1},{auth:!0})}async function Ut(e){await this.__connection;let{user_id:t}=Et.bind(this)(e);return await Fe.bind(this)("subscription",{unblock:t,group:1},{auth:!0})}async function Dt(e){await this.__connection;let t=await me.bind(this)();e=ae.Params(e,{user_id:e=>{if(e!==this.__user.user_id&&!t)throw new ee("No access.",{code:"INVALID_REQUEST"});return e},group:e=>{if("public"===e&&(e=0),"authorized"===e&&(e=1),"number"!=typeof e)throw new ee('"group" should be type number | "public" | "authorized".',{code:"INVALID_PARAMETER"});return e}});let n=await Fe.bind(this)("get-newsletter-subscription",e,{auth:!0}),r=[];for(let e of n){let t=e.subt.split("#"),n=!0;"@"===t[0].charAt(0)&&(n=!1,t[0]=t[0].substring(1));let i=parseInt(t[0]);r.push({timestamp:e.stmp,group:i,subscribed_email:t[1],active:n})}return r}async function Ct(e){await this.__connection;let t=ae.Params(e||{},{email:e=>ae.Email(e),group:["number","public","authorized"],redirect:e=>ae.Url(e)},this.__user?["group"]:["email","group"]);return Fe.bind(this)(`subscribe-${this.__user?"":"public-"}newsletter`,t,{auth:!!this.__user})}async function Pt(e){await this.__connection,e=ae.Params(e,{group:["number","public","authorized"]},["group"]);let t=Object.assign({action:"unsubscribe"},e);return Fe.bind(this)("subscribe-newsletter",t,{auth:!0})}async function Nt(e,t){let n=await me.bind(this)(),r={message_id:"string",timestamp:"number",read:"number",complaint:"number",subject:"string"};e||(t=Object.assign({ascending:!1},t||{})),e=e||{searchFor:"timestamp",value:Date.now(),condition:"<",group:"public"};let i=0===(e=ae.Params(e,{searchFor:["message_id","timestamp","read","complaint","group","subject"],value:t=>{if(typeof t!==r[e.searchFor])throw new ee(`"value" type does not match the type of "${e.searchFor}" index.`,{code:"INVALID_PARAMETER"});if("string"==typeof t&&!t)throw new ee('"value" should not be empty string.',{code:"INVALID_PARAMETER"});return t},range:t=>{if(!e.hasOwnProperty("value")||typeof t!=typeof e.value)throw new ee('"range" should match type of "value".',{code:"INVALID_PARAMETER"});return t},condition:[">",">=","=","<","<=","gt","gte","eq","lt","lte",()=>"="],group:e=>{if("public"===e)return 0;if(!this.session)throw new ee("User should be logged in.",{code:"INVALID_REQUEST"});if("authorized"===e)return 1;if("number"==typeof e){if(!n&&e>parseInt(this.session.idToken.payload.access_group))throw new ee("User has no access.",{code:"INVALID_REQUEST"});return e}throw new ee('"group" should be type: number | "public" | "authorized".',{code:"INVALID_PARAMETER"})}},["searchFor","value","group"])).group?"get-public-newsletters":"get-newsletters",s=await Fe.bind(this)(i,e,Object.assign({method:"get",auth:"get-public-newsletters"!==i||!!this.__user},{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 n in o)t[n]=e[o[n]]||a[n];return t})),s}async function kt(e){let t=ae.Params(e,{user_id:e=>ae.UserId(e,'"user_id"')},["user_id"]);if(t=t?.service&&t?.owner?{service:t?.service,owner:t?.owner,block:t.user_id}:{block:t.user_id},!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("block-account",t,{auth:!0})}async function Ot(e){let t=ae.Params(e,{user_id:e=>ae.UserId(e,'"user_id"')},["user_id"]);if(t=t?.service&&t?.owner?{service:t?.service,owner:t?.owner,unblock:t.user_id}:{unblock:t.user_id},!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("block-account",t,{auth:!0})}async function Lt(e){let t=ae.Params(e,{user_id:e=>ae.UserId(e,'"user_id"')},["user_id"]);if(t=t?.service&&t?.owner?{service:t?.service,owner:t?.owner,delete:t.user_id}:{delete:t.user_id},!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("remove-account",t,{auth:!0})}async function Mt(e,t){let n={email:e=>ae.Email(e),password:e=>ae.Password(e),name:"string",username:"string",gender:"string",address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):void 0:"",birthdate:e=>ae.Birthdate(e),phone_number:e=>ae.PhoneNumber(e),picture:e=>e?ae.Url(e):void 0,profile:e=>e?ae.Url(e):void 0,website:e=>e?ae.Url(e):void 0,nickname:"string",misc:"string",email_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],address_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1]},r=ae.Params(e,n,["email"]);if(t=ae.Params(t,{confirmation_url:e=>{let t=e;if("string"!=typeof e)throw new ee('"options.confirmation_url" should be type: <string>.',{code:"INVALID_PARAMETER"});if(t=ae.Url(e),t&&!r.email)throw new ee('"email" is required for signup confirmation.',{code:"INVALID_PARAMETER"});return t},email_subscription:e=>{if("boolean"!=typeof e)throw new ee('"options.email_subscription" should be type: <boolean>.',{code:"INVALID_PARAMETER"});if(!t?.confirmation_url)throw new ee('"options.confirmation_url" is required for email subscription.',{code:"INVALID_PARAMETER"});return e}}),r.signup_confirmation=t?.confirmation_url||!0,r.email_subscription=t?.email_subscription||!1,!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("admin-signup",Object.assign({access_group:1},r),{auth:!0})}async function Vt(e,t){let n={email:e=>ae.Email(e),password:e=>ae.Password(e),name:"string",username:"string",gender:"string",address:e=>e?"string"==typeof e?e:"object"==typeof e?JSON.stringify(e):void 0:"",birthdate:e=>ae.Birthdate(e),phone_number:e=>ae.PhoneNumber(e),picture:e=>e?ae.Url(e):void 0,profile:e=>e?ae.Url(e):void 0,website:e=>e?ae.Url(e):void 0,nickname:"string",misc:"string",email_public:["boolean",()=>!1],gender_public:["boolean",()=>!1],address_public:["boolean",()=>!1],birthdate_public:["boolean",()=>!1],phone_number_public:["boolean",()=>!1]},r=ae.Params(e,n,["email","password"]);if(t=ae.Params(t,{email_subscription:e=>{if("boolean"!=typeof e)throw new ee('"options.email_subscription" should be type: <boolean>.',{code:"INVALID_PARAMETER"});return e}}),r.email_subscription=t?.email_subscription||!1,!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("admin-signup",Object.assign({access_group:1},r),{auth:!0})}async function Ft(e){if(e=ae.Params(e,{user_id:e=>ae.UserId(e,'"user_id"'),access_group:e=>{if(e>0&&e<100)return e;throw new ee('"access_group" is invalid.',{code:"INVALID_PARAMETER"})}},["user_id","access_group"]),!await me.bind(this)()){if(!this.__user)throw new ee("User needs to login.",{code:"INVALID_REQUEST"});if(99!==this.__user.access_group)throw new ee("Invalid access.",{code:"INVALID_REQUEST"})}return await Fe.bind(this)("grant-access",e,{auth:!0})}var xt=function(e,t,n,r){var i,s=arguments.length,o=s<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(i=e[a])&&(o=(s<3?i(o):s>3?i(t,n,o):i(t,n))||o);return s>3&&o&&Object.defineProperty(t,n,o),o};class Bt{get user(){return this.__user&&Object.keys(this.__user).length?JSON.parse(JSON.stringify(this.__user)):null}set user(e){}constructor(e,t,n,r){if(this.__version="1.0.162",this.session=null,this.connection=null,this.userPool=null,this.host="skapi",this.hostDomain="skapi.com",this.target_cdn="d3e9syvbtso631",this.__disabledAccount=null,this.__cached_requests={},this.__startKeyHistory={},this.__request_signup_confirmation=null,this.__private_access_key={},this.__class_properties_has_been_cached=!1,this.__user=null,this.onLogin=e=>{},this.validate={userId(e){try{return ae.UserId(e),!0}catch(e){return!1}},url(e){try{return ae.Url(e),!0}catch(e){return!1}},phoneNumber(e){try{return ae.PhoneNumber(e),!0}catch(e){return!1}},birthdate(e){try{return ae.Birthdate(e),!0}catch(e){return!1}},email(e){try{return ae.Email(e),!0}catch(e){return!1}}},this.util={MD5:te,generateRandom:ie,toBase62:ne,fromBase62:re,extractFormData:se,request:(e,t,n)=>Fe.bind(this)(e,t,n,{ignoreService:!0})},this.__network_logs=!1,this.registerTicket=de.bind(this),this.unregisterTicket=pe.bind(this),"string"!=typeof e||"string"!=typeof t)throw new ee('"service" and "owner" should be type <string>.',{code:"INVALID_PARAMETER"});if(!e||!t)throw new ee('"service" and "owner" is required',{code:"INVALID_PARAMETER"});t!==this.host&&ae.UserId(t,'"owner"'),this.service=e,this.owner=t;let i=!0;n&&"boolean"==typeof n.autoLogin&&(i=n.autoLogin),this.target_cdn=r?.target_cdn||this.target_cdn,this.hostDomain=r?.hostDomain||this.hostDomain,this.__network_logs=!!r?.network_logs;const s=`https://${this.target_cdn}.cloudfront.net`;let o=e.substring(0,4);if(this.admin_endpoint=fetch(`${s}/${o}/admin.json`).then((e=>e.blob())).then((e=>new Promise(((t,n)=>{const r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),this.record_endpoint=fetch(`${s}/${o}/record.json`).then((e=>e.blob())).then((e=>new Promise(((t,n)=>{const r=new FileReader;r.onloadend=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})))).then((e=>"string"==typeof e?JSON.parse(window.atob(e.split(",")[1])):null)),!window.sessionStorage)throw new Error("This browser does not support skapi.");const a=JSON.parse(window.sessionStorage.getItem(`${e}#${t}`)||"null");if(this.log("constructor:restore",a),a?.connection)for(let e in a)this[e]=a[e];this.__authConnection=(async()=>{const e=await this.admin_endpoint;if(this.userPool=new X({UserPoolId:e.userpool_id,ClientId:e.userpool_client}),a?.connection||i)try{await ge.bind(this)().getSession()}catch(e){}})(),this.__connection=(async()=>{let n=null;a?.connection||(n=this.updateConnection());const r=()=>{if(this.__class_properties_has_been_cached)return;let r=()=>{let n={};const r=["__startKeyHistory","__disabledAccount","__cached_requests","__request_signup_confirmation","connection"];if(this.connection){for(let e of r)n[e]=this[e];window.sessionStorage.setItem(`${e}#${t}`,JSON.stringify(n)),this.__class_properties_has_been_cached=!0}};return n instanceof Promise?n.then((()=>r())):r()};return window.addEventListener("beforeunload",(()=>{this.closeRealtime(),r()})),window.addEventListener("visibilitychange",(()=>{r()})),await n,await this.__authConnection,this.connection})(),this.__connection.then((e=>{((e?.group||0)<3||this.__network_logs)&&this.version()}))}async updateConnection(){try{this.connection=await Fe.bind(this)("service",{service:this.service,owner:this.owner},{bypassAwaitConnection:!0,method:"get"})}catch(e){throw window&&window.alert("Service is not available: "+(e.message||e.toString())),this.connection=null,e}return this.connection}async version(){return await this.__connection,console.log(`Built with:\n%c\r\n $$\\ $$\\ \r\n $$ | \\__|\r\n $$$$$$$\\ $$ | $$\\ $$$$$$\\ $$$$$$\\ $$\\ \r\n$$ _____|$$ | $$ |\\____$$\\ $$ __$$\\ $$ |\r\n\\$$$$$$\\ $$$$$$ / $$$$$$$ |$$ / $$ |$$ |\r\n \\____$$\\ $$ _$$< $$ __$$ |$$ | $$ |$$ |\r\n$$$$$$$ |$$ | \\$$\\\\$$$$$$$ |$$$$$$$ |$$ |\r\n\\_______/ \\__| \\__|\\_______|$$ ____/ \\__|\r\n $$ | \r\n $$ | \r\n \\__| \r\nVersion: ${this.__version}\n\nDocumentation: https://docs.skapi.com`,"font-family: monospace; color:blue;"),1===this.connection.group&&console.log("%cSKAPI: THE SERVICE IS IN TRIAL MODE. ALL THE USERS AND DATA WILL BE INITIALIZED EVERY 30 DAYS.","font-family: monospace; color:red;"),this.__version}log(e,t){if(this.__network_logs)try{console.log(e,JSON.parse(JSON.stringify(t)))}catch(n){console.log(e,t)}}connectRealtime(e){return dt.bind(this)(e)}jwtLogin(e){return ve.bind(this)(e)}clientSecretRequest(e){return wt.bind(this)(e)}consumeTicket(e){return le.bind(this)(e)}getConsumedTickets(e,t){return fe.bind(this)(e,t)}getTickets(e,t){return he.bind(this)(e,t)}closeRealtime(){return pt.bind(this)()}getRealtimeUsers(e,t){return mt.bind(this)(e,t)}sendInquiry(e){return bt.bind(this)(e)}blockAccount(e){return kt.bind(this)(e)}unblockAccount(e){return Ot.bind(this)(e)}deleteAccount(e){return Lt.bind(this)(e)}inviteUser(e,t){return Mt.bind(this)(e,t)}createAccount(e,t){return Vt.bind(this)(e,t)}grantAccess(e){return Ft.bind(this)(e)}getRealtimeGroups(e,t){return yt.bind(this)(e,t)}postRealtime(e,t){return gt.bind(this)(e,t)}joinRealtime(e){return _t.bind(this)(e)}getConnection(){return this.__connection}getProfile(e){return _e.bind(this)(e)}getFile(e,t){return Ye.bind(this)(e,t)}secureRequest(e,t){return At.bind(this)(e,t)}getFormResponse(){return He.bind(this)()}getRecords(e,t){return Ge.bind(this)(e,t)}getTables(e,t){return Xe.bind(this)(e,t)}getIndexes(e,t){return et.bind(this)(e,t)}getTags(e,t){return tt.bind(this)(e,t)}deleteRecords(e){return nt.bind(this)(e)}resendSignupConfirmation(e){return be.bind(this)(e)}recoverAccount(e=!1){return Ae.bind(this)(e)}getUsers(e,t){return ke.bind(this)(e,t)}disableAccount(){return Ie.bind(this)()}lastVerifiedEmail(e){return Oe.bind(this)(e)}unsubscribeNewsletter(e){return Pt.bind(this)(e)}getNewsletters(e,t){return Nt.bind(this)(e,t)}getNewsletterSubscription(e){return Dt.bind(this)(e)}requestUsernameChange(e){return Le.bind(this)(e)}grantPrivateRecordAccess(e){return rt.bind(this)(e)}removePrivateRecordAccess(e){return it.bind(this)(e)}listPrivateRecordAccess(e){return st.bind(this)(e)}requestPrivateRecordAccessKey(e){return ot.bind(this)(e)}deleteFiles(e){return Qe.bind(this)(e)}uploadFiles(e,t){return qe.bind(this)(e,t)}mock(e,t){return vt.bind(this)(e,t)}login(e){return Ee.bind(this)(e)}logout(){return we.bind(this)()}signup(e,t){return Se.bind(this)(e,t)}resetPassword(e){return Te.bind(this)(e)}verifyEmail(e){return De.bind(this)(e)}verifyPhoneNumber(e){return Ue.bind(this)(e)}forgotPassword(e){return Ce.bind(this)(e)}changePassword(e){return Pe.bind(this)(e)}updateProfile(e){return Ne.bind(this)(e)}postRecord(e,t){return Ze.bind(this)(e,t)}getSubscriptions(e,t){return St.bind(this)(e,t)}subscribe(e){return It.bind(this)(e)}unsubscribe(e){return Tt.bind(this)(e)}blockSubscriber(e){return Rt.bind(this)(e)}unblockSubscriber(e){return Ut.bind(this)(e)}subscribeNewsletter(e){return Ct.bind(this)(e)}}xt([Ke()],Bt.prototype,"clientSecretRequest",null),xt([Ke()],Bt.prototype,"consumeTicket",null),xt([Ke()],Bt.prototype,"getConsumedTickets",null),xt([Ke()],Bt.prototype,"getTickets",null),xt([Ke()],Bt.prototype,"getRealtimeUsers",null),xt([Ke()],Bt.prototype,"sendInquiry",null),xt([Ke()],Bt.prototype,"blockAccount",null),xt([Ke()],Bt.prototype,"unblockAccount",null),xt([Ke()],Bt.prototype,"deleteAccount",null),xt([Ke()],Bt.prototype,"inviteUser",null),xt([Ke()],Bt.prototype,"createAccount",null),xt([Ke()],Bt.prototype,"grantAccess",null),xt([Ke()],Bt.prototype,"getRealtimeGroups",null),xt([Ke()],Bt.prototype,"postRealtime",null),xt([Ke()],Bt.prototype,"joinRealtime",null),xt([Ke()],Bt.prototype,"getProfile",null),xt([Ke()],Bt.prototype,"getFile",null),xt([Ke()],Bt.prototype,"secureRequest",null),xt([Ke()],Bt.prototype,"getFormResponse",null),xt([Ke()],Bt.prototype,"getRecords",null),xt([Ke()],Bt.prototype,"getTables",null),xt([Ke()],Bt.prototype,"getIndexes",null),xt([Ke()],Bt.prototype,"getTags",null),xt([Ke()],Bt.prototype,"deleteRecords",null),xt([Ke()],Bt.prototype,"resendSignupConfirmation",null),xt([Ke()],Bt.prototype,"recoverAccount",null),xt([Ke()],Bt.prototype,"getUsers",null),xt([Ke()],Bt.prototype,"disableAccount",null),xt([Ke()],Bt.prototype,"lastVerifiedEmail",null),xt([Ke()],Bt.prototype,"unsubscribeNewsletter",null),xt([Ke()],Bt.prototype,"getNewsletters",null),xt([Ke()],Bt.prototype,"getNewsletterSubscription",null),xt([Ke()],Bt.prototype,"requestUsernameChange",null),xt([Ke()],Bt.prototype,"grantPrivateRecordAccess",null),xt([Ke()],Bt.prototype,"removePrivateRecordAccess",null),xt([Ke()],Bt.prototype,"listPrivateRecordAccess",null),xt([Ke()],Bt.prototype,"requestPrivateRecordAccessKey",null),xt([Ke()],Bt.prototype,"deleteFiles",null),xt([Ke()],Bt.prototype,"uploadFiles",null),xt([Ke()],Bt.prototype,"mock",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"login",null),xt([Ke()],Bt.prototype,"logout",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"signup",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"resetPassword",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"verifyEmail",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"verifyPhoneNumber",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"forgotPassword",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"changePassword",null),xt([Ke({preventMultipleCalls:!0})],Bt.prototype,"updateProfile",null),xt([Ke()],Bt.prototype,"postRecord",null),xt([Ke()],Bt.prototype,"getSubscriptions",null),xt([Ke()],Bt.prototype,"subscribe",null),xt([Ke()],Bt.prototype,"unsubscribe",null),xt([Ke()],Bt.prototype,"blockSubscriber",null),xt([Ke()],Bt.prototype,"unblockSubscriber",null),xt([Ke()],Bt.prototype,"subscribeNewsletter",null)})(),r})()));
3
3
  //# sourceMappingURL=skapi.js.map