magic-sdk 31.2.0-canary.f2a57c0.0 → 31.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";var et=Object.create;var ge=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var ke=(_,m)=>()=>(m||_((m={exports:{}}).exports,m),m.exports),it=(_,m)=>{for(var O in m)ge(_,O,{get:m[O],enumerable:!0})},pe=(_,m,O,C)=>{if(m&&typeof m=="object"||typeof m=="function")for(let W of tt(m))!ot.call(_,W)&&W!==O&&ge(_,W,{get:()=>m[W],enumerable:!(C=rt(m,W))||C.enumerable});return _},j=(_,m,O)=>(pe(_,m,"default"),O&&pe(O,m,"default")),er=(_,m,O)=>(O=_!=null?et(nt(_)):{},pe(m||!_||!_.__esModule?ge(O,"default",{value:_,enumerable:!0}):O,_)),at=_=>pe(ge({},"__esModule",{value:!0}),_);var tr=ke((rr,Oe)=>{"use strict";(function(_){if(typeof rr=="object"&&typeof Oe<"u")Oe.exports=_();else if(typeof define=="function"&&define.amd)define([],_);else{var m;typeof window<"u"?m=window:typeof global<"u"?m=global:typeof self<"u"?m=self:m=this,m.localforage=_()}})(function(){var _,m,O;return function C(W,k,L){function G(K,Z){if(!k[K]){if(!W[K]){var y=typeof require=="function"&&require;if(!Z&&y)return y(K,!0);if(D)return D(K,!0);var w=new Error("Cannot find module '"+K+"'");throw w.code="MODULE_NOT_FOUND",w}var T=k[K]={exports:{}};W[K][0].call(T.exports,function(F){var q=W[K][1][F];return G(q||F)},T,T.exports,C,W,k,L)}return k[K].exports}for(var D=typeof require=="function"&&require,z=0;z<L.length;z++)G(L[z]);return G}({1:[function(C,W,k){(function(L){"use strict";var G=L.MutationObserver||L.WebKitMutationObserver,D;if(G){var z=0,K=new G(F),Z=L.document.createTextNode("");K.observe(Z,{characterData:!0}),D=function(){Z.data=z=++z%2}}else if(!L.setImmediate&&typeof L.MessageChannel<"u"){var y=new L.MessageChannel;y.port1.onmessage=F,D=function(){y.port2.postMessage(0)}}else"document"in L&&"onreadystatechange"in L.document.createElement("script")?D=function(){var P=L.document.createElement("script");P.onreadystatechange=function(){F(),P.onreadystatechange=null,P.parentNode.removeChild(P),P=null},L.document.documentElement.appendChild(P)}:D=function(){setTimeout(F,0)};var w,T=[];function F(){w=!0;for(var P,re,M=T.length;M;){for(re=T,T=[],P=-1;++P<M;)re[P]();M=T.length}w=!1}W.exports=q;function q(P){T.push(P)===1&&!w&&D()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(C,W,k){"use strict";var L=C(1);function G(){}var D={},z=["REJECTED"],K=["FULFILLED"],Z=["PENDING"];W.exports=y;function y(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=Z,this.queue=[],this.outcome=void 0,h!==G&&q(this,h)}y.prototype.catch=function(h){return this.then(null,h)},y.prototype.then=function(h,A){if(typeof h!="function"&&this.state===K||typeof A!="function"&&this.state===z)return this;var E=new this.constructor(G);if(this.state!==Z){var N=this.state===K?h:A;T(E,N,this.outcome)}else this.queue.push(new w(E,h,A));return E};function w(h,A,E){this.promise=h,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(h){D.resolve(this.promise,h)},w.prototype.otherCallFulfilled=function(h){T(this.promise,this.onFulfilled,h)},w.prototype.callRejected=function(h){D.reject(this.promise,h)},w.prototype.otherCallRejected=function(h){T(this.promise,this.onRejected,h)};function T(h,A,E){L(function(){var N;try{N=A(E)}catch(H){return D.reject(h,H)}N===h?D.reject(h,new TypeError("Cannot resolve promise with itself")):D.resolve(h,N)})}D.resolve=function(h,A){var E=P(F,A);if(E.status==="error")return D.reject(h,E.value);var N=E.value;if(N)q(h,N);else{h.state=K,h.outcome=A;for(var H=-1,Q=h.queue.length;++H<Q;)h.queue[H].callFulfilled(A)}return h},D.reject=function(h,A){h.state=z,h.outcome=A;for(var E=-1,N=h.queue.length;++E<N;)h.queue[E].callRejected(A);return h};function F(h){var A=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof A=="function")return function(){A.apply(h,arguments)}}function q(h,A){var E=!1;function N($){E||(E=!0,D.reject(h,$))}function H($){E||(E=!0,D.resolve(h,$))}function Q(){A(H,N)}var J=P(Q);J.status==="error"&&N(J.value)}function P(h,A){var E={};try{E.value=h(A),E.status="success"}catch(N){E.status="error",E.value=N}return E}y.resolve=re;function re(h){return h instanceof this?h:D.resolve(new this(G),h)}y.reject=M;function M(h){var A=new this(G);return D.reject(A,h)}y.all=ue;function ue(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=new Array(E),Q=0,J=-1,$=new this(G);++J<E;)te(h[J],J);return $;function te(fe,a){A.resolve(fe).then(u,function(v){N||(N=!0,D.reject($,v))});function u(v){H[a]=v,++Q===E&&!N&&(N=!0,D.resolve($,H))}}}y.race=ne;function ne(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=-1,Q=new this(G);++H<E;)J(h[H]);return Q;function J($){A.resolve($).then(function(te){N||(N=!0,D.resolve(Q,te))},function(te){N||(N=!0,D.reject(Q,te))})}}},{1:1}],3:[function(C,W,k){(function(L){"use strict";typeof L.Promise!="function"&&(L.Promise=C(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(C,W,k){"use strict";var L=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function G(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var z=D();function K(){try{if(!z||!z.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function Z(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new r,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(t.type)}}typeof Promise>"u"&&C(3);var y=Promise;function w(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function T(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function F(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function q(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var P="local-forage-detect-blob-support",re=void 0,M={},ue=Object.prototype.toString,ne="readonly",h="readwrite";function A(e){for(var t=e.length,r=new ArrayBuffer(t),o=new Uint8Array(r),i=0;i<t;i++)o[i]=e.charCodeAt(i);return r}function E(e){return new y(function(t){var r=e.transaction(P,h),o=Z([""]);r.objectStore(P).put(o,"key"),r.onabort=function(i){i.preventDefault(),i.stopPropagation(),t(!1)},r.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function N(e){return typeof re=="boolean"?y.resolve(re):E(e).then(function(t){return re=t,re})}function H(e){var t=M[e.name],r={};r.promise=new y(function(o,i){r.resolve=o,r.reject=i}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function Q(e){var t=M[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function J(e,t){var r=M[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function $(e,t){return new y(function(r,o){if(M[e.name]=M[e.name]||X(),e.db)if(t)H(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=z.open.apply(z,i);t&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(P)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),o(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},r(f),Q(e)}})}function te(e){return $(e,!1)}function fe(e){return $(e,!0)}function a(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=e.version>e.db.version;if(o&&(e.version!==t&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new y(function(t,r){var o=new FileReader;o.onerror=r,o.onloadend=function(i){var n=btoa(i.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function v(e){var t=A(atob(e.data));return Z([t],{type:e.type})}function g(e){return e&&e.__local_forage_encoded_blob}function b(e){var t=this,r=t._initReady().then(function(){var o=M[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(r,e,e),r}function I(e){H(e);for(var t=M[e.name],r=t.forages,o=0;o<r.length;o++){var i=r[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,te(e).then(function(n){return e.db=n,a(e)?fe(e):n}).then(function(n){e.db=t.db=n;for(var f=0;f<r.length;f++)r[f]._dbInfo.db=n}).catch(function(n){throw J(e,n),n})}function R(e,t,r,o){o===void 0&&(o=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return y.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),fe(e)}).then(function(){return I(e).then(function(){R(e,t,r,o-1)})}).catch(r);r(n)}}function X(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function ce(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=M[r.name];i||(i=X(),M[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=b);var n=[];function f(){return y.resolve()}for(var s=0;s<i.forages.length;s++){var c=i.forages[s];c!==t&&n.push(c._initReady().catch(f))}var l=i.forages.slice(0);return y.all(n).then(function(){return r.db=i.db,te(r)}).then(function(d){return r.db=d,a(r,t._defaultConfig.version)?fe(r):d}).then(function(d){r.db=i.db=d,t._dbInfo=r;for(var p=0;p<l.length;p++){var S=l[p];S!==t&&(S._dbInfo.db=r.db,S._dbInfo.version=r.version)}})}function se(e,t){var r=this;e=F(e);var o=new y(function(i,n){r.ready().then(function(){R(r._dbInfo,ne,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),g(d)&&(d=v(d)),i(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function de(e,t){var r=this,o=new y(function(i,n){r.ready().then(function(){R(r._dbInfo,ne,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var p=l.result;if(p){var S=p.value;g(S)&&(S=v(S));var B=e(S,p.key,d++);B!==void 0?i(B):p.continue()}else i()},l.onerror=function(){n(l.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function ar(e,t,r){var o=this;e=F(e);var i=new y(function(n,f){var s;o.ready().then(function(){return s=o._dbInfo,ue.call(t)==="[object Blob]"?N(s.db).then(function(c){return c?t:u(t)}):t}).then(function(c){R(o._dbInfo,h,function(l,d){if(l)return f(l);try{var p=d.objectStore(o._dbInfo.storeName);c===null&&(c=void 0);var S=p.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var B=S.error?S.error:S.transaction.error;f(B)}}catch(B){f(B)}})}).catch(f)});return w(i,r),i}function fr(e,t){var r=this;e=F(e);var o=new y(function(i,n){r.ready().then(function(){R(r._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){i()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function sr(e){var t=this,r=new y(function(o,i){t.ready().then(function(){R(t._dbInfo,h,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.clear();f.oncomplete=function(){o()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;i(l)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ur(e){var t=this,r=new y(function(o,i){t.ready().then(function(){R(t._dbInfo,ne,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.count();c.onsuccess=function(){o(c.result)},c.onerror=function(){i(c.error)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function cr(e,t){var r=this,o=new y(function(i,n){if(e<0){i(null);return}r.ready().then(function(){R(r._dbInfo,ne,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var p=d.result;if(!p){i(null);return}e===0||l?i(p.key):(l=!0,p.advance(e))},d.onerror=function(){n(d.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function lr(e){var t=this,r=new y(function(o,i){t.ready().then(function(){R(t._dbInfo,ne,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){o(l);return}l.push(d.key),d.continue()},c.onerror=function(){i(c.error)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function dr(e,t){t=q.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;if(!e.name)i=y.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,f=n?y.resolve(o._dbInfo.db):te(e).then(function(s){var c=M[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?i=f.then(function(s){if(s.objectStoreNames.contains(e.storeName)){var c=s.version+1;H(e);var l=M[e.name],d=l.forages;s.close();for(var p=0;p<d.length;p++){var S=d[p];S._dbInfo.db=null,S._dbInfo.version=c}var B=new y(function(x,Y){var U=z.open(e.name,c);U.onerror=function(ee){var he=U.result;he.close(),Y(ee)},U.onupgradeneeded=function(){var ee=U.result;ee.deleteObjectStore(e.storeName)},U.onsuccess=function(){var ee=U.result;ee.close(),x(ee)}});return B.then(function(x){l.db=x;for(var Y=0;Y<d.length;Y++){var U=d[Y];U._dbInfo.db=x,Q(U._dbInfo)}}).catch(function(x){throw(J(e,x)||y.resolve()).catch(function(){}),x})}}):i=f.then(function(s){H(e);var c=M[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var p=l[d];p._dbInfo.db=null}var S=new y(function(B,x){var Y=z.deleteDatabase(e.name);Y.onerror=function(){var U=Y.result;U&&U.close(),x(Y.error)},Y.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},Y.onsuccess=function(){var U=Y.result;U&&U.close(),B(U)}});return S.then(function(B){c.db=B;for(var x=0;x<l.length;x++){var Y=l[x];Q(Y._dbInfo)}}).catch(function(B){throw(J(e,B)||y.resolve()).catch(function(){}),B})})}return w(i,t),i}var vr={_driver:"asyncStorage",_initStorage:ce,_support:K(),iterate:de,getItem:se,setItem:ar,removeItem:fr,clear:sr,length:ur,key:cr,keys:lr,dropInstance:dr};function hr(){return typeof openDatabase=="function"}var ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mr="~~local_forage_type~",Le=/^~~local_forage_type~([^~]+)~/,me="__lfsc__:",Ee=me.length,Se="arbf",Ae="blob",Pe="si08",Me="ui08",Fe="uic8",Ue="si16",We="si32",ze="ur16",Ye="ui32",Ke="fl32",He="fl64",Ve=Ee+Se.length,Ge=Object.prototype.toString;function je(e){var t=e.length*.75,r=e.length,o,i=0,n,f,s,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var l=new ArrayBuffer(t),d=new Uint8Array(l);for(o=0;o<r;o+=4)n=ie.indexOf(e[o]),f=ie.indexOf(e[o+1]),s=ie.indexOf(e[o+2]),c=ie.indexOf(e[o+3]),d[i++]=n<<2|f>>4,d[i++]=(f&15)<<4|s>>2,d[i++]=(s&3)<<6|c&63;return l}function Re(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=ie[t[o]>>2],r+=ie[(t[o]&3)<<4|t[o+1]>>4],r+=ie[(t[o+1]&15)<<2|t[o+2]>>6],r+=ie[t[o+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}function yr(e,t){var r="";if(e&&(r=Ge.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&Ge.call(e.buffer)==="[object ArrayBuffer]")){var o,i=me;e instanceof ArrayBuffer?(o=e,i+=Se):(o=e.buffer,r==="[object Int8Array]"?i+=Pe:r==="[object Uint8Array]"?i+=Me:r==="[object Uint8ClampedArray]"?i+=Fe:r==="[object Int16Array]"?i+=Ue:r==="[object Uint16Array]"?i+=ze:r==="[object Int32Array]"?i+=We:r==="[object Uint32Array]"?i+=Ye:r==="[object Float32Array]"?i+=Ke:r==="[object Float64Array]"?i+=He:t(new Error("Failed to get type for BinaryArray"))),t(i+Re(o))}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=mr+e.type+"~"+Re(this.result);t(me+Ae+f)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),t(null,f)}}function pr(e){if(e.substring(0,Ee)!==me)return JSON.parse(e);var t=e.substring(Ve),r=e.substring(Ee,Ve),o;if(r===Ae&&Le.test(t)){var i=t.match(Le);o=i[1],t=t.substring(i[0].length)}var n=je(t);switch(r){case Se:return n;case Ae:return Z([n],{type:o});case Pe:return new Int8Array(n);case Me:return new Uint8Array(n);case Fe:return new Uint8ClampedArray(n);case Ue:return new Int16Array(n);case ze:return new Uint16Array(n);case We:return new Int32Array(n);case Ye:return new Uint32Array(n);case Ke:return new Float32Array(n);case He:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var De={serialize:yr,deserialize:pr,stringToBuffer:je,bufferToString:Re};function Xe(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function gr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=typeof e[o]!="string"?e[o].toString():e[o];var i=new y(function(n,f){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(s){return f(s)}r.db.transaction(function(s){Xe(s,r,function(){t._dbInfo=r,n()},function(c,l){f(l)})},f)});return r.serializer=De,i}function ae(e,t,r,o,i,n){e.executeSql(r,o,i,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(c,l){l.rows.length?n(c,s):Xe(c,t,function(){c.executeSql(r,o,i,n)},n)},n):n(f,s)},n)}function br(e,t){var r=this;e=F(e);var o=new y(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ae(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function _r(e,t){var r=this,o=new y(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ae(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,p=d.length,S=0;S<p;S++){var B=d.item(S),x=B.value;if(x&&(x=f.serializer.deserialize(x)),x=e(x,B.key,S+1),x!==void 0){i(x);return}}i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Qe(e,t,r,o){var i=this;e=F(e);var n=new y(function(f,s){i.ready().then(function(){t===void 0&&(t=null);var c=t,l=i._dbInfo;l.serializer.serialize(t,function(d,p){p?s(p):l.db.transaction(function(S){ae(S,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(B,x){s(x)})},function(S){if(S.code===S.QUOTA_ERR){if(o>0){f(Qe.apply(i,[e,c,r,o-1]));return}s(S)}})})}).catch(s)});return w(n,r),n}function wr(e,t,r){return Qe.apply(this,[e,t,r,1])}function Ir(e,t){var r=this;e=F(e);var o=new y(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ae(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Er(e){var t=this,r=new y(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ae(f,n,"DELETE FROM "+n.storeName,[],function(){o()},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Sr(e){var t=this,r=new y(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ae(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Ar(e,t){var r=this,o=new y(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ae(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Rr(e){var t=this,r=new y(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ae(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Dr(e){return new y(function(t,r){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);t({db:e,storeNames:f})},function(i,n){r(n)})},function(o){r(o)})})}function Tr(e,t){t=q.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;return e.name?i=new y(function(n){var f;e.name===r.name?f=o._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Dr(f))}).then(function(n){return new y(function(f,s){n.db.transaction(function(c){function l(B){return new y(function(x,Y){c.executeSql("DROP TABLE IF EXISTS "+B,[],function(){x()},function(U,ee){Y(ee)})})}for(var d=[],p=0,S=n.storeNames.length;p<S;p++)d.push(l(n.storeNames[p]));y.all(d).then(function(){f()}).catch(function(B){s(B)})},function(c){s(c)})})}):i=y.reject("Invalid arguments"),w(i,t),i}var Br={_driver:"webSQLStorage",_initStorage:gr,_support:hr(),iterate:_r,getItem:br,setItem:wr,removeItem:Ir,clear:Er,length:Sr,key:Ar,keys:Rr,dropInstance:Tr};function Nr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Je(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function xr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Or(){return!xr()||localStorage.length>0}function Cr(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=Je(e,t._defaultConfig),Or()?(t._dbInfo=r,r.serializer=De,y.resolve()):y.reject()}function Lr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(o)===0&&localStorage.removeItem(n)}});return w(r,e),r}function Pr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return w(o,t),o}function Mr(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var p=localStorage.getItem(d);if(p&&(p=i.serializer.deserialize(p)),p=e(p,d.substring(f),c++),p!==void 0)return p}}});return w(o,t),o}function Fr(e,t){var r=this,o=r.ready().then(function(){var i=r._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return w(o,t),o}function Ur(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],f=0;f<i;f++){var s=localStorage.key(f);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length))}return n});return w(r,e),r}function Wr(e){var t=this,r=t.keys().then(function(o){return o.length});return w(r,e),r}function zr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return w(o,t),o}function Yr(e,t,r){var o=this;e=F(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new y(function(f,s){var c=o._dbInfo;c.serializer.serialize(t,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(p){(p.name==="QuotaExceededError"||p.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(p),s(p)}})})});return w(i,r),i}function Kr(e,t){if(t=q.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var o=this,i;return e.name?i=new y(function(n){e.storeName?n(Je(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):i=y.reject("Invalid arguments"),w(i,t),i}var Hr={_driver:"localStorageWrapper",_initStorage:Cr,_support:Nr(),iterate:Mr,getItem:Pr,setItem:Yr,removeItem:zr,clear:Lr,length:Wr,key:Fr,keys:Ur,dropInstance:Kr},Vr=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},Gr=function(t,r){for(var o=t.length,i=0;i<o;){if(Vr(t[i],r))return!0;i++}return!1},$e=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},ve={},Ze={},le={INDEXEDDB:vr,WEBSQL:Br,LOCALSTORAGE:Hr},jr=[le.INDEXEDDB._driver,le.WEBSQL._driver,le.LOCALSTORAGE._driver],ye=["dropInstance"],Te=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ye),Xr={description:"",driver:jr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Qr(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Be(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&($e(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var Jr=function(){function e(t){G(this,e);for(var r in le)if(le.hasOwnProperty(r)){var o=le[r],i=o._driver;this[r]=i,ve[i]||this.defineDriver(o)}this._defaultConfig=Be({},Xr),this._config=Be({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(r){if((typeof r>"u"?"undefined":L(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in r){if(o==="storeName"&&(r[o]=r[o].replace(/\W/g,"_")),o==="version"&&typeof r[o]!="number")return new Error("Database version must be a number.");this._config[o]=r[o]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,o,i){var n=new y(function(f,s){try{var c=r._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){s(l);return}for(var d=Te.concat("_initStorage"),p=0,S=d.length;p<S;p++){var B=d[p],x=!Gr(ye,B);if((x||r[B])&&typeof r[B]!="function"){s(l);return}}var Y=function(){for(var he=function(qr){return function(){var kr=new Error("Method "+qr+" is not implemented by the current driver"),qe=y.reject(kr);return w(qe,arguments[arguments.length-1]),qe}},Ne=0,Zr=ye.length;Ne<Zr;Ne++){var xe=ye[Ne];r[xe]||(r[xe]=he(xe))}};Y();var U=function(he){ve[c]&&console.info("Redefining LocalForage driver: "+c),ve[c]=r,Ze[c]=he,f()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(U,s):U(!!r._support):U(!0)}catch(ee){s(ee)}});return T(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=ve[r]?y.resolve(ve[r]):y.reject(new Error("Driver not found."));return T(n,o,i),n},e.prototype.getSerializer=function(r){var o=y.resolve(De);return T(o,r),o},e.prototype.ready=function(r){var o=this,i=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;$e(r)||(r=[r]);var f=this._getSupportedDrivers(r);function s(){n._config.driver=n.driver()}function c(p){return n._extend(p),s(),n._ready=n._initStorage(n._config),n._ready}function l(p){return function(){var S=0;function B(){for(;S<p.length;){var x=p[S];return S++,n._dbInfo=null,n._ready=null,n.getDriver(x).then(c).catch(B)}s();var Y=new Error("No available storage method found.");return n._driverSet=y.reject(Y),n._driverSet}return B()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return y.resolve()}):y.resolve();return this._driverSet=d.then(function(){var p=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(p).then(function(S){n._driver=S._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var p=new Error("No available storage method found.");return n._driverSet=y.reject(p),n._driverSet}),T(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!Ze[r]},e.prototype._extend=function(r){Be(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var f=r[i];this.supports(f)&&o.push(f)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Te.length;r<o;r++)Qr(this,Te[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),$r=new Jr;W.exports=$r},{3:3}]},{},[4])(4)})});var or=ke((be,nr)=>{"use strict";(function(_,m){typeof be=="object"&&typeof nr<"u"?m(be):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],m):m(_.LocalforageDriverMemory={})})(typeof self<"u"?self:be,function(_){"use strict";var m="localforage-driver-memory";function O(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function C(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(I){if(I.name!=="TypeError")throw I;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,g=new v,b=0;b<a.length;b+=1)g.append(a[b]);return g.getBlob(u.type)}}var W=/^~~local_forage_type~([^~]+)~/,k=9,L=k+4,G=Object.prototype.toString;function D(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var g=new ArrayBuffer(u),b=new Uint8Array(g),I=0,R=0;I<v;I+=4){var X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I]),ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+1]),se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+2]),de="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+3]);b[R++]=X<<2|ce>>4,b[R++]=(ce&15)<<4|se>>2,b[R++]=(se&3)<<6|de&63}return g}function z(a){for(var u=new Uint8Array(a),v="",g=0;g<u.length;g+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g]&3)<<4|u[g+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g+1]&15)<<2|u[g+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function K(a,u){var v="";if(a&&(v=G.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&G.call(a.buffer)==="[object ArrayBuffer]")){var g=void 0,b="__lfsc__:";a instanceof ArrayBuffer?(g=a,b+="arbf"):(g=a.buffer,v==="[object Int8Array]"?b+="si08":v==="[object Uint8Array]"?b+="ui08":v==="[object Uint8ClampedArray]"?b+="uic8":v==="[object Int16Array]"?b+="si16":v==="[object Uint16Array]"?b+="ur16":v==="[object Int32Array]"?b+="si32":v==="[object Uint32Array]"?b+="ui32":v==="[object Float32Array]"?b+="fl32":v==="[object Float64Array]"?b+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(b+z(g))}else if(v==="[object Blob]"){var I=new FileReader;I.onload=function(){var R="~~local_forage_type~"+a.type+"~"+z(this.result);u("__lfsc__:blob"+R)},I.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(R){console.error("Couldn't convert value into a JSON string: ",a),u(null,R)}}function Z(a){if(a.substring(0,k)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(L),v=a.substring(k,L),g;if(v==="blob"&&W.test(u)){var b=u.match(W);g=b[1],u=u.substring(b[0].length)}var I=D(u);switch(v){case"arbf":return I;case"blob":return C([I],{type:g});case"si08":return new Int8Array(I);case"ui08":return new Uint8Array(I);case"uic8":return new Uint8ClampedArray(I);case"si16":return new Int16Array(I);case"ur16":return new Uint16Array(I);case"si32":return new Int32Array(I);case"ui32":return new Uint32Array(I);case"fl32":return new Float32Array(I);case"fl64":return new Float64Array(I);default:throw new Error("Unkown type: "+v)}}function y(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var g=a instanceof Date?new Date(a):a.constructor();try{for(var b=O(Object.keys(a)),I=b.next();!I.done;I=b.next()){var R=I.value;Object.prototype.hasOwnProperty.call(a,R)&&(a.isActiveClone=null,g[R]=y(a[R]),delete a.isActiveClone)}}catch(X){u={error:X}}finally{try{I&&!I.done&&(v=b.return)&&v.call(b)}finally{if(u)throw u.error}}return g}function w(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function T(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function F(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function q(a,u){var v=this;if(u=F.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var g=this.config();a.name=a.name||g.name,a.storeName=a.storeName||g.storeName}var b;return a.name?b=new Promise(function(I){a.storeName?I(w(a,v._defaultConfig)):I(a.name+"/")}):b=Promise.reject("Invalid arguments"),{promise:b,callback:u}}function P(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var re={bufferToString:z,deserialize:Z,serialize:K,stringToBuffer:D},M={},ue=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return M[u]||(M[u]=new a(u)),M[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete M[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function ne(a){var u=a?y(a):{},v=w(u,this._defaultConfig),g=ue.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=re,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=g,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return T(v,a),v}function A(a,u){var v=q.apply(this,arguments),g=v.promise,b=v.callback,I=g.then(function(R){ue.resolve(R).drop()});return T(I,b),g}function E(a,u){var v=this;a=P(a);var g=this.ready().then(function(){var b=v._dbInfo.mStore.get(a);return b==null?null:v._dbInfo.serializer.deserialize(b)});return T(g,u),g}function N(a,u){var v=this,g=this.ready().then(function(){for(var b=v._dbInfo.mStore,I=b.keys(),R=0;R<I.length;R++){var X=b.get(I[R]);if(X&&(X=v._dbInfo.serializer.deserialize(X)),X=a(X,I[R],R+1),X!==void 0)return X}});return T(g,u),g}function H(a,u){var v=this,g=this.ready().then(function(){var b;try{b=v._dbInfo.mStore.key(a),b===void 0&&(b=null)}catch{b=null}return b});return T(g,u),g}function Q(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return T(v,a),v}function J(a){var u=this.keys().then(function(v){return v.length});return T(u,a),u}function $(a,u){var v=this;a=P(a);var g=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return T(g,u),g}function te(a,u,v){var g=this;a=P(a);var b=this.ready().then(function(){u===void 0&&(u=null);var I=u;return new Promise(function(R,X){g._dbInfo.serializer.serialize(u,function(ce,se){if(se)X(se);else try{g._dbInfo.mStore.set(a,ce),R(I)}catch(de){X(de)}})})});return T(b,v),b}var fe=!0;_._support=fe,_._driver=m,_._initStorage=ne,_.clear=h,_.dropInstance=A,_.getItem=E,_.iterate=N,_.key=H,_.keys=Q,_.length=J,_.removeItem=$,_.setItem=te,Object.defineProperty(_,"__esModule",{value:!0})})});var V={};it(V,{Magic:()=>ct});module.exports=at(V);var Ie=require("@magic-sdk/provider"),we=er(tr()),Ce=er(or());var oe=require("@magic-sdk/provider"),ir=require("@magic-sdk/types"),ft={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function st(_){for(let[m,O]of Object.entries(ft))_.style[m]=O}function ut(_){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(O=>O.src.includes(_))}var _e=class extends oe.ViewController{activeElement=null;iframe;relayerSrc=(0,oe.createURL)(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(m=>{let O=()=>{if(ut(encodeURIComponent(this.parameters)))(0,oe.createDuplicateIframeWarning)().log();else{let C=document.createElement("iframe");C.classList.add("magic-iframe"),C.dataset.magicIframeLabel=(0,oe.createURL)(this.endpoint).host,C.title="Secure Modal",C.src=this.relayerSrc,C.allow="clipboard-read; clipboard-write",st(C),document.body.appendChild(C),m(C)}};["loaded","interactive","complete"].includes(document.readyState)?O():window.addEventListener("load",O,!1)}),this.iframe.then(m=>{m instanceof HTMLIFrameElement&&m.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",m=>{if(m.origin===this.endpoint&&m.data.msgType&&(m.data.msgType.includes(ir.MagicIncomingWindowMessage.MAGIC_PONG)&&(this.lastPongTime=Date.now()),m.data&&this.messageHandlers.size)){m.data.response=m.data.response??{},this.stopHeartBeat();for(let O of this.messageHandlers.values())O(m)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let m=await this.iframe;m.style.display="block",m.style.zIndex="2147483647",m.style.opacity="1",this.activeElement=document.activeElement,m.focus()}async hideOverlay(){let m=await this.iframe;m.style.display="none",m.style.zIndex="-1",m.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(m){let O=await this.iframe;if(O&&O.contentWindow)O.contentWindow.postMessage(m,this.endpoint);else throw(0,oe.createModalNotReadyError)()}async checkRelayerExistsInDOM(){let m=await this.iframe;return!m||!m.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(C=>C.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let m=await this.iframe;if(this.stopHeartBeat(),!m){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!m.contentWindow){document.body.appendChild(m),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}m&&(m.src=this.relayerSrc)}};j(V,require("@magic-sdk/provider"),module.exports);j(V,require("@magic-sdk/types"),module.exports);var ct=(0,Ie.createSDK)(Ie.SDKBase,{platform:"web",sdkName:"magic-sdk",version:"31.1.0",defaultEndpoint:"https://auth.magic.link/",ViewController:_e,configureStorage:async()=>{let _=we.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await _.defineDriver(Ce),await _.setDriver([we.default.INDEXEDDB,we.default.LOCALSTORAGE,Ce._driver]),_}});
1
+ "use strict";var et=Object.create;var ge=Object.defineProperty;var rt=Object.getOwnPropertyDescriptor;var tt=Object.getOwnPropertyNames;var nt=Object.getPrototypeOf,ot=Object.prototype.hasOwnProperty;var ke=(_,m)=>()=>(m||_((m={exports:{}}).exports,m),m.exports),it=(_,m)=>{for(var O in m)ge(_,O,{get:m[O],enumerable:!0})},pe=(_,m,O,C)=>{if(m&&typeof m=="object"||typeof m=="function")for(let W of tt(m))!ot.call(_,W)&&W!==O&&ge(_,W,{get:()=>m[W],enumerable:!(C=rt(m,W))||C.enumerable});return _},j=(_,m,O)=>(pe(_,m,"default"),O&&pe(O,m,"default")),er=(_,m,O)=>(O=_!=null?et(nt(_)):{},pe(m||!_||!_.__esModule?ge(O,"default",{value:_,enumerable:!0}):O,_)),at=_=>pe(ge({},"__esModule",{value:!0}),_);var tr=ke((rr,Oe)=>{"use strict";(function(_){if(typeof rr=="object"&&typeof Oe<"u")Oe.exports=_();else if(typeof define=="function"&&define.amd)define([],_);else{var m;typeof window<"u"?m=window:typeof global<"u"?m=global:typeof self<"u"?m=self:m=this,m.localforage=_()}})(function(){var _,m,O;return function C(W,k,L){function G(K,Z){if(!k[K]){if(!W[K]){var y=typeof require=="function"&&require;if(!Z&&y)return y(K,!0);if(D)return D(K,!0);var w=new Error("Cannot find module '"+K+"'");throw w.code="MODULE_NOT_FOUND",w}var T=k[K]={exports:{}};W[K][0].call(T.exports,function(F){var q=W[K][1][F];return G(q||F)},T,T.exports,C,W,k,L)}return k[K].exports}for(var D=typeof require=="function"&&require,z=0;z<L.length;z++)G(L[z]);return G}({1:[function(C,W,k){(function(L){"use strict";var G=L.MutationObserver||L.WebKitMutationObserver,D;if(G){var z=0,K=new G(F),Z=L.document.createTextNode("");K.observe(Z,{characterData:!0}),D=function(){Z.data=z=++z%2}}else if(!L.setImmediate&&typeof L.MessageChannel<"u"){var y=new L.MessageChannel;y.port1.onmessage=F,D=function(){y.port2.postMessage(0)}}else"document"in L&&"onreadystatechange"in L.document.createElement("script")?D=function(){var P=L.document.createElement("script");P.onreadystatechange=function(){F(),P.onreadystatechange=null,P.parentNode.removeChild(P),P=null},L.document.documentElement.appendChild(P)}:D=function(){setTimeout(F,0)};var w,T=[];function F(){w=!0;for(var P,re,M=T.length;M;){for(re=T,T=[],P=-1;++P<M;)re[P]();M=T.length}w=!1}W.exports=q;function q(P){T.push(P)===1&&!w&&D()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(C,W,k){"use strict";var L=C(1);function G(){}var D={},z=["REJECTED"],K=["FULFILLED"],Z=["PENDING"];W.exports=y;function y(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=Z,this.queue=[],this.outcome=void 0,h!==G&&q(this,h)}y.prototype.catch=function(h){return this.then(null,h)},y.prototype.then=function(h,A){if(typeof h!="function"&&this.state===K||typeof A!="function"&&this.state===z)return this;var E=new this.constructor(G);if(this.state!==Z){var N=this.state===K?h:A;T(E,N,this.outcome)}else this.queue.push(new w(E,h,A));return E};function w(h,A,E){this.promise=h,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(h){D.resolve(this.promise,h)},w.prototype.otherCallFulfilled=function(h){T(this.promise,this.onFulfilled,h)},w.prototype.callRejected=function(h){D.reject(this.promise,h)},w.prototype.otherCallRejected=function(h){T(this.promise,this.onRejected,h)};function T(h,A,E){L(function(){var N;try{N=A(E)}catch(H){return D.reject(h,H)}N===h?D.reject(h,new TypeError("Cannot resolve promise with itself")):D.resolve(h,N)})}D.resolve=function(h,A){var E=P(F,A);if(E.status==="error")return D.reject(h,E.value);var N=E.value;if(N)q(h,N);else{h.state=K,h.outcome=A;for(var H=-1,Q=h.queue.length;++H<Q;)h.queue[H].callFulfilled(A)}return h},D.reject=function(h,A){h.state=z,h.outcome=A;for(var E=-1,N=h.queue.length;++E<N;)h.queue[E].callRejected(A);return h};function F(h){var A=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof A=="function")return function(){A.apply(h,arguments)}}function q(h,A){var E=!1;function N($){E||(E=!0,D.reject(h,$))}function H($){E||(E=!0,D.resolve(h,$))}function Q(){A(H,N)}var J=P(Q);J.status==="error"&&N(J.value)}function P(h,A){var E={};try{E.value=h(A),E.status="success"}catch(N){E.status="error",E.value=N}return E}y.resolve=re;function re(h){return h instanceof this?h:D.resolve(new this(G),h)}y.reject=M;function M(h){var A=new this(G);return D.reject(A,h)}y.all=ue;function ue(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=new Array(E),Q=0,J=-1,$=new this(G);++J<E;)te(h[J],J);return $;function te(fe,a){A.resolve(fe).then(u,function(v){N||(N=!0,D.reject($,v))});function u(v){H[a]=v,++Q===E&&!N&&(N=!0,D.resolve($,H))}}}y.race=ne;function ne(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=-1,Q=new this(G);++H<E;)J(h[H]);return Q;function J($){A.resolve($).then(function(te){N||(N=!0,D.resolve(Q,te))},function(te){N||(N=!0,D.reject(Q,te))})}}},{1:1}],3:[function(C,W,k){(function(L){"use strict";typeof L.Promise!="function"&&(L.Promise=C(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(C,W,k){"use strict";var L=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function G(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var z=D();function K(){try{if(!z||!z.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function Z(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new r,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(t.type)}}typeof Promise>"u"&&C(3);var y=Promise;function w(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function T(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function F(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function q(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var P="local-forage-detect-blob-support",re=void 0,M={},ue=Object.prototype.toString,ne="readonly",h="readwrite";function A(e){for(var t=e.length,r=new ArrayBuffer(t),o=new Uint8Array(r),i=0;i<t;i++)o[i]=e.charCodeAt(i);return r}function E(e){return new y(function(t){var r=e.transaction(P,h),o=Z([""]);r.objectStore(P).put(o,"key"),r.onabort=function(i){i.preventDefault(),i.stopPropagation(),t(!1)},r.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function N(e){return typeof re=="boolean"?y.resolve(re):E(e).then(function(t){return re=t,re})}function H(e){var t=M[e.name],r={};r.promise=new y(function(o,i){r.resolve=o,r.reject=i}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function Q(e){var t=M[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function J(e,t){var r=M[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function $(e,t){return new y(function(r,o){if(M[e.name]=M[e.name]||X(),e.db)if(t)H(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=z.open.apply(z,i);t&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(P)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),o(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},r(f),Q(e)}})}function te(e){return $(e,!1)}function fe(e){return $(e,!0)}function a(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=e.version>e.db.version;if(o&&(e.version!==t&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new y(function(t,r){var o=new FileReader;o.onerror=r,o.onloadend=function(i){var n=btoa(i.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function v(e){var t=A(atob(e.data));return Z([t],{type:e.type})}function g(e){return e&&e.__local_forage_encoded_blob}function b(e){var t=this,r=t._initReady().then(function(){var o=M[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(r,e,e),r}function I(e){H(e);for(var t=M[e.name],r=t.forages,o=0;o<r.length;o++){var i=r[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,te(e).then(function(n){return e.db=n,a(e)?fe(e):n}).then(function(n){e.db=t.db=n;for(var f=0;f<r.length;f++)r[f]._dbInfo.db=n}).catch(function(n){throw J(e,n),n})}function R(e,t,r,o){o===void 0&&(o=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return y.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),fe(e)}).then(function(){return I(e).then(function(){R(e,t,r,o-1)})}).catch(r);r(n)}}function X(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function ce(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=M[r.name];i||(i=X(),M[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=b);var n=[];function f(){return y.resolve()}for(var s=0;s<i.forages.length;s++){var c=i.forages[s];c!==t&&n.push(c._initReady().catch(f))}var l=i.forages.slice(0);return y.all(n).then(function(){return r.db=i.db,te(r)}).then(function(d){return r.db=d,a(r,t._defaultConfig.version)?fe(r):d}).then(function(d){r.db=i.db=d,t._dbInfo=r;for(var p=0;p<l.length;p++){var S=l[p];S!==t&&(S._dbInfo.db=r.db,S._dbInfo.version=r.version)}})}function se(e,t){var r=this;e=F(e);var o=new y(function(i,n){r.ready().then(function(){R(r._dbInfo,ne,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),g(d)&&(d=v(d)),i(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function de(e,t){var r=this,o=new y(function(i,n){r.ready().then(function(){R(r._dbInfo,ne,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var p=l.result;if(p){var S=p.value;g(S)&&(S=v(S));var B=e(S,p.key,d++);B!==void 0?i(B):p.continue()}else i()},l.onerror=function(){n(l.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function ar(e,t,r){var o=this;e=F(e);var i=new y(function(n,f){var s;o.ready().then(function(){return s=o._dbInfo,ue.call(t)==="[object Blob]"?N(s.db).then(function(c){return c?t:u(t)}):t}).then(function(c){R(o._dbInfo,h,function(l,d){if(l)return f(l);try{var p=d.objectStore(o._dbInfo.storeName);c===null&&(c=void 0);var S=p.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var B=S.error?S.error:S.transaction.error;f(B)}}catch(B){f(B)}})}).catch(f)});return w(i,r),i}function fr(e,t){var r=this;e=F(e);var o=new y(function(i,n){r.ready().then(function(){R(r._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){i()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function sr(e){var t=this,r=new y(function(o,i){t.ready().then(function(){R(t._dbInfo,h,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.clear();f.oncomplete=function(){o()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;i(l)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ur(e){var t=this,r=new y(function(o,i){t.ready().then(function(){R(t._dbInfo,ne,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.count();c.onsuccess=function(){o(c.result)},c.onerror=function(){i(c.error)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function cr(e,t){var r=this,o=new y(function(i,n){if(e<0){i(null);return}r.ready().then(function(){R(r._dbInfo,ne,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var p=d.result;if(!p){i(null);return}e===0||l?i(p.key):(l=!0,p.advance(e))},d.onerror=function(){n(d.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function lr(e){var t=this,r=new y(function(o,i){t.ready().then(function(){R(t._dbInfo,ne,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){o(l);return}l.push(d.key),d.continue()},c.onerror=function(){i(c.error)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function dr(e,t){t=q.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;if(!e.name)i=y.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,f=n?y.resolve(o._dbInfo.db):te(e).then(function(s){var c=M[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?i=f.then(function(s){if(s.objectStoreNames.contains(e.storeName)){var c=s.version+1;H(e);var l=M[e.name],d=l.forages;s.close();for(var p=0;p<d.length;p++){var S=d[p];S._dbInfo.db=null,S._dbInfo.version=c}var B=new y(function(x,Y){var U=z.open(e.name,c);U.onerror=function(ee){var he=U.result;he.close(),Y(ee)},U.onupgradeneeded=function(){var ee=U.result;ee.deleteObjectStore(e.storeName)},U.onsuccess=function(){var ee=U.result;ee.close(),x(ee)}});return B.then(function(x){l.db=x;for(var Y=0;Y<d.length;Y++){var U=d[Y];U._dbInfo.db=x,Q(U._dbInfo)}}).catch(function(x){throw(J(e,x)||y.resolve()).catch(function(){}),x})}}):i=f.then(function(s){H(e);var c=M[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var p=l[d];p._dbInfo.db=null}var S=new y(function(B,x){var Y=z.deleteDatabase(e.name);Y.onerror=function(){var U=Y.result;U&&U.close(),x(Y.error)},Y.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},Y.onsuccess=function(){var U=Y.result;U&&U.close(),B(U)}});return S.then(function(B){c.db=B;for(var x=0;x<l.length;x++){var Y=l[x];Q(Y._dbInfo)}}).catch(function(B){throw(J(e,B)||y.resolve()).catch(function(){}),B})})}return w(i,t),i}var vr={_driver:"asyncStorage",_initStorage:ce,_support:K(),iterate:de,getItem:se,setItem:ar,removeItem:fr,clear:sr,length:ur,key:cr,keys:lr,dropInstance:dr};function hr(){return typeof openDatabase=="function"}var ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",mr="~~local_forage_type~",Le=/^~~local_forage_type~([^~]+)~/,me="__lfsc__:",Ee=me.length,Se="arbf",Ae="blob",Pe="si08",Me="ui08",Fe="uic8",Ue="si16",We="si32",ze="ur16",Ye="ui32",Ke="fl32",He="fl64",Ve=Ee+Se.length,Ge=Object.prototype.toString;function je(e){var t=e.length*.75,r=e.length,o,i=0,n,f,s,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var l=new ArrayBuffer(t),d=new Uint8Array(l);for(o=0;o<r;o+=4)n=ie.indexOf(e[o]),f=ie.indexOf(e[o+1]),s=ie.indexOf(e[o+2]),c=ie.indexOf(e[o+3]),d[i++]=n<<2|f>>4,d[i++]=(f&15)<<4|s>>2,d[i++]=(s&3)<<6|c&63;return l}function Re(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=ie[t[o]>>2],r+=ie[(t[o]&3)<<4|t[o+1]>>4],r+=ie[(t[o+1]&15)<<2|t[o+2]>>6],r+=ie[t[o+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}function yr(e,t){var r="";if(e&&(r=Ge.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&Ge.call(e.buffer)==="[object ArrayBuffer]")){var o,i=me;e instanceof ArrayBuffer?(o=e,i+=Se):(o=e.buffer,r==="[object Int8Array]"?i+=Pe:r==="[object Uint8Array]"?i+=Me:r==="[object Uint8ClampedArray]"?i+=Fe:r==="[object Int16Array]"?i+=Ue:r==="[object Uint16Array]"?i+=ze:r==="[object Int32Array]"?i+=We:r==="[object Uint32Array]"?i+=Ye:r==="[object Float32Array]"?i+=Ke:r==="[object Float64Array]"?i+=He:t(new Error("Failed to get type for BinaryArray"))),t(i+Re(o))}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=mr+e.type+"~"+Re(this.result);t(me+Ae+f)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),t(null,f)}}function pr(e){if(e.substring(0,Ee)!==me)return JSON.parse(e);var t=e.substring(Ve),r=e.substring(Ee,Ve),o;if(r===Ae&&Le.test(t)){var i=t.match(Le);o=i[1],t=t.substring(i[0].length)}var n=je(t);switch(r){case Se:return n;case Ae:return Z([n],{type:o});case Pe:return new Int8Array(n);case Me:return new Uint8Array(n);case Fe:return new Uint8ClampedArray(n);case Ue:return new Int16Array(n);case ze:return new Uint16Array(n);case We:return new Int32Array(n);case Ye:return new Uint32Array(n);case Ke:return new Float32Array(n);case He:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var De={serialize:yr,deserialize:pr,stringToBuffer:je,bufferToString:Re};function Xe(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function gr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=typeof e[o]!="string"?e[o].toString():e[o];var i=new y(function(n,f){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(s){return f(s)}r.db.transaction(function(s){Xe(s,r,function(){t._dbInfo=r,n()},function(c,l){f(l)})},f)});return r.serializer=De,i}function ae(e,t,r,o,i,n){e.executeSql(r,o,i,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(c,l){l.rows.length?n(c,s):Xe(c,t,function(){c.executeSql(r,o,i,n)},n)},n):n(f,s)},n)}function br(e,t){var r=this;e=F(e);var o=new y(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ae(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function _r(e,t){var r=this,o=new y(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ae(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,p=d.length,S=0;S<p;S++){var B=d.item(S),x=B.value;if(x&&(x=f.serializer.deserialize(x)),x=e(x,B.key,S+1),x!==void 0){i(x);return}}i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Qe(e,t,r,o){var i=this;e=F(e);var n=new y(function(f,s){i.ready().then(function(){t===void 0&&(t=null);var c=t,l=i._dbInfo;l.serializer.serialize(t,function(d,p){p?s(p):l.db.transaction(function(S){ae(S,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(B,x){s(x)})},function(S){if(S.code===S.QUOTA_ERR){if(o>0){f(Qe.apply(i,[e,c,r,o-1]));return}s(S)}})})}).catch(s)});return w(n,r),n}function wr(e,t,r){return Qe.apply(this,[e,t,r,1])}function Ir(e,t){var r=this;e=F(e);var o=new y(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ae(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Er(e){var t=this,r=new y(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ae(f,n,"DELETE FROM "+n.storeName,[],function(){o()},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Sr(e){var t=this,r=new y(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ae(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Ar(e,t){var r=this,o=new y(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ae(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Rr(e){var t=this,r=new y(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ae(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Dr(e){return new y(function(t,r){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);t({db:e,storeNames:f})},function(i,n){r(n)})},function(o){r(o)})})}function Tr(e,t){t=q.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;return e.name?i=new y(function(n){var f;e.name===r.name?f=o._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Dr(f))}).then(function(n){return new y(function(f,s){n.db.transaction(function(c){function l(B){return new y(function(x,Y){c.executeSql("DROP TABLE IF EXISTS "+B,[],function(){x()},function(U,ee){Y(ee)})})}for(var d=[],p=0,S=n.storeNames.length;p<S;p++)d.push(l(n.storeNames[p]));y.all(d).then(function(){f()}).catch(function(B){s(B)})},function(c){s(c)})})}):i=y.reject("Invalid arguments"),w(i,t),i}var Br={_driver:"webSQLStorage",_initStorage:gr,_support:hr(),iterate:_r,getItem:br,setItem:wr,removeItem:Ir,clear:Er,length:Sr,key:Ar,keys:Rr,dropInstance:Tr};function Nr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Je(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function xr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Or(){return!xr()||localStorage.length>0}function Cr(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=Je(e,t._defaultConfig),Or()?(t._dbInfo=r,r.serializer=De,y.resolve()):y.reject()}function Lr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(o)===0&&localStorage.removeItem(n)}});return w(r,e),r}function Pr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return w(o,t),o}function Mr(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var p=localStorage.getItem(d);if(p&&(p=i.serializer.deserialize(p)),p=e(p,d.substring(f),c++),p!==void 0)return p}}});return w(o,t),o}function Fr(e,t){var r=this,o=r.ready().then(function(){var i=r._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return w(o,t),o}function Ur(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],f=0;f<i;f++){var s=localStorage.key(f);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length))}return n});return w(r,e),r}function Wr(e){var t=this,r=t.keys().then(function(o){return o.length});return w(r,e),r}function zr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return w(o,t),o}function Yr(e,t,r){var o=this;e=F(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new y(function(f,s){var c=o._dbInfo;c.serializer.serialize(t,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(p){(p.name==="QuotaExceededError"||p.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(p),s(p)}})})});return w(i,r),i}function Kr(e,t){if(t=q.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var o=this,i;return e.name?i=new y(function(n){e.storeName?n(Je(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):i=y.reject("Invalid arguments"),w(i,t),i}var Hr={_driver:"localStorageWrapper",_initStorage:Cr,_support:Nr(),iterate:Mr,getItem:Pr,setItem:Yr,removeItem:zr,clear:Lr,length:Wr,key:Fr,keys:Ur,dropInstance:Kr},Vr=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},Gr=function(t,r){for(var o=t.length,i=0;i<o;){if(Vr(t[i],r))return!0;i++}return!1},$e=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},ve={},Ze={},le={INDEXEDDB:vr,WEBSQL:Br,LOCALSTORAGE:Hr},jr=[le.INDEXEDDB._driver,le.WEBSQL._driver,le.LOCALSTORAGE._driver],ye=["dropInstance"],Te=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ye),Xr={description:"",driver:jr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Qr(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Be(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&($e(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var Jr=function(){function e(t){G(this,e);for(var r in le)if(le.hasOwnProperty(r)){var o=le[r],i=o._driver;this[r]=i,ve[i]||this.defineDriver(o)}this._defaultConfig=Be({},Xr),this._config=Be({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(r){if((typeof r>"u"?"undefined":L(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in r){if(o==="storeName"&&(r[o]=r[o].replace(/\W/g,"_")),o==="version"&&typeof r[o]!="number")return new Error("Database version must be a number.");this._config[o]=r[o]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,o,i){var n=new y(function(f,s){try{var c=r._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){s(l);return}for(var d=Te.concat("_initStorage"),p=0,S=d.length;p<S;p++){var B=d[p],x=!Gr(ye,B);if((x||r[B])&&typeof r[B]!="function"){s(l);return}}var Y=function(){for(var he=function(qr){return function(){var kr=new Error("Method "+qr+" is not implemented by the current driver"),qe=y.reject(kr);return w(qe,arguments[arguments.length-1]),qe}},Ne=0,Zr=ye.length;Ne<Zr;Ne++){var xe=ye[Ne];r[xe]||(r[xe]=he(xe))}};Y();var U=function(he){ve[c]&&console.info("Redefining LocalForage driver: "+c),ve[c]=r,Ze[c]=he,f()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(U,s):U(!!r._support):U(!0)}catch(ee){s(ee)}});return T(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=ve[r]?y.resolve(ve[r]):y.reject(new Error("Driver not found."));return T(n,o,i),n},e.prototype.getSerializer=function(r){var o=y.resolve(De);return T(o,r),o},e.prototype.ready=function(r){var o=this,i=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;$e(r)||(r=[r]);var f=this._getSupportedDrivers(r);function s(){n._config.driver=n.driver()}function c(p){return n._extend(p),s(),n._ready=n._initStorage(n._config),n._ready}function l(p){return function(){var S=0;function B(){for(;S<p.length;){var x=p[S];return S++,n._dbInfo=null,n._ready=null,n.getDriver(x).then(c).catch(B)}s();var Y=new Error("No available storage method found.");return n._driverSet=y.reject(Y),n._driverSet}return B()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return y.resolve()}):y.resolve();return this._driverSet=d.then(function(){var p=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(p).then(function(S){n._driver=S._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var p=new Error("No available storage method found.");return n._driverSet=y.reject(p),n._driverSet}),T(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!Ze[r]},e.prototype._extend=function(r){Be(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var f=r[i];this.supports(f)&&o.push(f)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Te.length;r<o;r++)Qr(this,Te[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),$r=new Jr;W.exports=$r},{3:3}]},{},[4])(4)})});var or=ke((be,nr)=>{"use strict";(function(_,m){typeof be=="object"&&typeof nr<"u"?m(be):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],m):m(_.LocalforageDriverMemory={})})(typeof self<"u"?self:be,function(_){"use strict";var m="localforage-driver-memory";function O(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function C(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(I){if(I.name!=="TypeError")throw I;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,g=new v,b=0;b<a.length;b+=1)g.append(a[b]);return g.getBlob(u.type)}}var W=/^~~local_forage_type~([^~]+)~/,k=9,L=k+4,G=Object.prototype.toString;function D(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var g=new ArrayBuffer(u),b=new Uint8Array(g),I=0,R=0;I<v;I+=4){var X="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I]),ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+1]),se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+2]),de="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+3]);b[R++]=X<<2|ce>>4,b[R++]=(ce&15)<<4|se>>2,b[R++]=(se&3)<<6|de&63}return g}function z(a){for(var u=new Uint8Array(a),v="",g=0;g<u.length;g+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g]&3)<<4|u[g+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g+1]&15)<<2|u[g+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function K(a,u){var v="";if(a&&(v=G.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&G.call(a.buffer)==="[object ArrayBuffer]")){var g=void 0,b="__lfsc__:";a instanceof ArrayBuffer?(g=a,b+="arbf"):(g=a.buffer,v==="[object Int8Array]"?b+="si08":v==="[object Uint8Array]"?b+="ui08":v==="[object Uint8ClampedArray]"?b+="uic8":v==="[object Int16Array]"?b+="si16":v==="[object Uint16Array]"?b+="ur16":v==="[object Int32Array]"?b+="si32":v==="[object Uint32Array]"?b+="ui32":v==="[object Float32Array]"?b+="fl32":v==="[object Float64Array]"?b+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(b+z(g))}else if(v==="[object Blob]"){var I=new FileReader;I.onload=function(){var R="~~local_forage_type~"+a.type+"~"+z(this.result);u("__lfsc__:blob"+R)},I.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(R){console.error("Couldn't convert value into a JSON string: ",a),u(null,R)}}function Z(a){if(a.substring(0,k)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(L),v=a.substring(k,L),g;if(v==="blob"&&W.test(u)){var b=u.match(W);g=b[1],u=u.substring(b[0].length)}var I=D(u);switch(v){case"arbf":return I;case"blob":return C([I],{type:g});case"si08":return new Int8Array(I);case"ui08":return new Uint8Array(I);case"uic8":return new Uint8ClampedArray(I);case"si16":return new Int16Array(I);case"ur16":return new Uint16Array(I);case"si32":return new Int32Array(I);case"ui32":return new Uint32Array(I);case"fl32":return new Float32Array(I);case"fl64":return new Float64Array(I);default:throw new Error("Unkown type: "+v)}}function y(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var g=a instanceof Date?new Date(a):a.constructor();try{for(var b=O(Object.keys(a)),I=b.next();!I.done;I=b.next()){var R=I.value;Object.prototype.hasOwnProperty.call(a,R)&&(a.isActiveClone=null,g[R]=y(a[R]),delete a.isActiveClone)}}catch(X){u={error:X}}finally{try{I&&!I.done&&(v=b.return)&&v.call(b)}finally{if(u)throw u.error}}return g}function w(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function T(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function F(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function q(a,u){var v=this;if(u=F.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var g=this.config();a.name=a.name||g.name,a.storeName=a.storeName||g.storeName}var b;return a.name?b=new Promise(function(I){a.storeName?I(w(a,v._defaultConfig)):I(a.name+"/")}):b=Promise.reject("Invalid arguments"),{promise:b,callback:u}}function P(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var re={bufferToString:z,deserialize:Z,serialize:K,stringToBuffer:D},M={},ue=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return M[u]||(M[u]=new a(u)),M[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete M[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function ne(a){var u=a?y(a):{},v=w(u,this._defaultConfig),g=ue.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=re,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=g,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return T(v,a),v}function A(a,u){var v=q.apply(this,arguments),g=v.promise,b=v.callback,I=g.then(function(R){ue.resolve(R).drop()});return T(I,b),g}function E(a,u){var v=this;a=P(a);var g=this.ready().then(function(){var b=v._dbInfo.mStore.get(a);return b==null?null:v._dbInfo.serializer.deserialize(b)});return T(g,u),g}function N(a,u){var v=this,g=this.ready().then(function(){for(var b=v._dbInfo.mStore,I=b.keys(),R=0;R<I.length;R++){var X=b.get(I[R]);if(X&&(X=v._dbInfo.serializer.deserialize(X)),X=a(X,I[R],R+1),X!==void 0)return X}});return T(g,u),g}function H(a,u){var v=this,g=this.ready().then(function(){var b;try{b=v._dbInfo.mStore.key(a),b===void 0&&(b=null)}catch{b=null}return b});return T(g,u),g}function Q(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return T(v,a),v}function J(a){var u=this.keys().then(function(v){return v.length});return T(u,a),u}function $(a,u){var v=this;a=P(a);var g=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return T(g,u),g}function te(a,u,v){var g=this;a=P(a);var b=this.ready().then(function(){u===void 0&&(u=null);var I=u;return new Promise(function(R,X){g._dbInfo.serializer.serialize(u,function(ce,se){if(se)X(se);else try{g._dbInfo.mStore.set(a,ce),R(I)}catch(de){X(de)}})})});return T(b,v),b}var fe=!0;_._support=fe,_._driver=m,_._initStorage=ne,_.clear=h,_.dropInstance=A,_.getItem=E,_.iterate=N,_.key=H,_.keys=Q,_.length=J,_.removeItem=$,_.setItem=te,Object.defineProperty(_,"__esModule",{value:!0})})});var V={};it(V,{Magic:()=>ct});module.exports=at(V);var Ie=require("@magic-sdk/provider"),we=er(tr()),Ce=er(or());var oe=require("@magic-sdk/provider"),ir=require("@magic-sdk/types"),ft={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function st(_){for(let[m,O]of Object.entries(ft))_.style[m]=O}function ut(_){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(O=>O.src.includes(_))}var _e=class extends oe.ViewController{activeElement=null;iframe;relayerSrc=(0,oe.createURL)(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(m=>{let O=()=>{if(ut(encodeURIComponent(this.parameters)))(0,oe.createDuplicateIframeWarning)().log();else{let C=document.createElement("iframe");C.classList.add("magic-iframe"),C.dataset.magicIframeLabel=(0,oe.createURL)(this.endpoint).host,C.title="Secure Modal",C.src=this.relayerSrc,C.allow="clipboard-read; clipboard-write",st(C),document.body.appendChild(C),m(C)}};["loaded","interactive","complete"].includes(document.readyState)?O():window.addEventListener("load",O,!1)}),this.iframe.then(m=>{m instanceof HTMLIFrameElement&&m.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",m=>{if(m.origin===this.endpoint&&m.data.msgType&&(m.data.msgType.includes(ir.MagicIncomingWindowMessage.MAGIC_PONG)&&(this.lastPongTime=Date.now()),m.data&&this.messageHandlers.size)){m.data.response=m.data.response??{},this.stopHeartBeat();for(let O of this.messageHandlers.values())O(m)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let m=await this.iframe;m.style.display="block",m.style.zIndex="2147483647",m.style.opacity="1",this.activeElement=document.activeElement,m.focus()}async hideOverlay(){let m=await this.iframe;m.style.display="none",m.style.zIndex="-1",m.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(m){let O=await this.iframe;if(O&&O.contentWindow)O.contentWindow.postMessage(m,this.endpoint);else throw(0,oe.createModalNotReadyError)()}async checkRelayerExistsInDOM(){let m=await this.iframe;return!m||!m.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(C=>C.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let m=await this.iframe;if(this.stopHeartBeat(),!m){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!m.contentWindow){document.body.appendChild(m),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}m&&(m.src=this.relayerSrc)}};j(V,require("@magic-sdk/provider"),module.exports);j(V,require("@magic-sdk/types"),module.exports);var ct=(0,Ie.createSDK)(Ie.SDKBase,{platform:"web",sdkName:"magic-sdk",version:"31.2.0",defaultEndpoint:"https://auth.magic.link/",ViewController:_e,configureStorage:async()=>{let _=we.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await _.defineDriver(Ce),await _.setDriver([we.default.INDEXEDDB,we.default.LOCALSTORAGE,Ce._driver]),_}});
2
2
  //# sourceMappingURL=index.js.map
package/dist/es/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var $r=Object.create;var Qe=Object.defineProperty;var Zr=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var kr=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var de=(_=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(_,{get:(y,O)=>(typeof require<"u"?require:y)[O]}):_)(function(_){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+_+'" is not supported')});var Je=(_,y)=>()=>(y||_((y={exports:{}}).exports,y),y.exports);var rt=(_,y,O,C)=>{if(y&&typeof y=="object"||typeof y=="function")for(let W of qr(y))!et.call(_,W)&&W!==O&&Qe(_,W,{get:()=>y[W],enumerable:!(C=Zr(y,W))||C.enumerable});return _};var $e=(_,y,O)=>(O=_!=null?$r(kr(_)):{},rt(y||!_||!_.__esModule?Qe(O,"default",{value:_,enumerable:!0}):O,_));var qe=Je((Ze,De)=>{"use strict";(function(_){if(typeof Ze=="object"&&typeof De<"u")De.exports=_();else if(typeof define=="function"&&define.amd)define([],_);else{var y;typeof window<"u"?y=window:typeof global<"u"?y=global:typeof self<"u"?y=self:y=this,y.localforage=_()}})(function(){var _,y,O;return function C(W,Z,L){function V(K,J){if(!Z[K]){if(!W[K]){var m=typeof de=="function"&&de;if(!J&&m)return m(K,!0);if(D)return D(K,!0);var w=new Error("Cannot find module '"+K+"'");throw w.code="MODULE_NOT_FOUND",w}var T=Z[K]={exports:{}};W[K][0].call(T.exports,function(F){var $=W[K][1][F];return V($||F)},T,T.exports,C,W,Z,L)}return Z[K].exports}for(var D=typeof de=="function"&&de,z=0;z<L.length;z++)V(L[z]);return V}({1:[function(C,W,Z){(function(L){"use strict";var V=L.MutationObserver||L.WebKitMutationObserver,D;if(V){var z=0,K=new V(F),J=L.document.createTextNode("");K.observe(J,{characterData:!0}),D=function(){J.data=z=++z%2}}else if(!L.setImmediate&&typeof L.MessageChannel<"u"){var m=new L.MessageChannel;m.port1.onmessage=F,D=function(){m.port2.postMessage(0)}}else"document"in L&&"onreadystatechange"in L.document.createElement("script")?D=function(){var P=L.document.createElement("script");P.onreadystatechange=function(){F(),P.onreadystatechange=null,P.parentNode.removeChild(P),P=null},L.document.documentElement.appendChild(P)}:D=function(){setTimeout(F,0)};var w,T=[];function F(){w=!0;for(var P,k,M=T.length;M;){for(k=T,T=[],P=-1;++P<M;)k[P]();M=T.length}w=!1}W.exports=$;function $(P){T.push(P)===1&&!w&&D()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(C,W,Z){"use strict";var L=C(1);function V(){}var D={},z=["REJECTED"],K=["FULFILLED"],J=["PENDING"];W.exports=m;function m(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=J,this.queue=[],this.outcome=void 0,h!==V&&$(this,h)}m.prototype.catch=function(h){return this.then(null,h)},m.prototype.then=function(h,A){if(typeof h!="function"&&this.state===K||typeof A!="function"&&this.state===z)return this;var E=new this.constructor(V);if(this.state!==J){var N=this.state===K?h:A;T(E,N,this.outcome)}else this.queue.push(new w(E,h,A));return E};function w(h,A,E){this.promise=h,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(h){D.resolve(this.promise,h)},w.prototype.otherCallFulfilled=function(h){T(this.promise,this.onFulfilled,h)},w.prototype.callRejected=function(h){D.reject(this.promise,h)},w.prototype.otherCallRejected=function(h){T(this.promise,this.onRejected,h)};function T(h,A,E){L(function(){var N;try{N=A(E)}catch(H){return D.reject(h,H)}N===h?D.reject(h,new TypeError("Cannot resolve promise with itself")):D.resolve(h,N)})}D.resolve=function(h,A){var E=P(F,A);if(E.status==="error")return D.reject(h,E.value);var N=E.value;if(N)$(h,N);else{h.state=K,h.outcome=A;for(var H=-1,j=h.queue.length;++H<j;)h.queue[H].callFulfilled(A)}return h},D.reject=function(h,A){h.state=z,h.outcome=A;for(var E=-1,N=h.queue.length;++E<N;)h.queue[E].callRejected(A);return h};function F(h){var A=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof A=="function")return function(){A.apply(h,arguments)}}function $(h,A){var E=!1;function N(Q){E||(E=!0,D.reject(h,Q))}function H(Q){E||(E=!0,D.resolve(h,Q))}function j(){A(H,N)}var X=P(j);X.status==="error"&&N(X.value)}function P(h,A){var E={};try{E.value=h(A),E.status="success"}catch(N){E.status="error",E.value=N}return E}m.resolve=k;function k(h){return h instanceof this?h:D.resolve(new this(V),h)}m.reject=M;function M(h){var A=new this(V);return D.reject(A,h)}m.all=ae;function ae(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=new Array(E),j=0,X=-1,Q=new this(V);++X<E;)ee(h[X],X);return Q;function ee(oe,a){A.resolve(oe).then(u,function(v){N||(N=!0,D.reject(Q,v))});function u(v){H[a]=v,++j===E&&!N&&(N=!0,D.resolve(Q,H))}}}m.race=re;function re(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=-1,j=new this(V);++H<E;)X(h[H]);return j;function X(Q){A.resolve(Q).then(function(ee){N||(N=!0,D.resolve(j,ee))},function(ee){N||(N=!0,D.reject(j,ee))})}}},{1:1}],3:[function(C,W,Z){(function(L){"use strict";typeof L.Promise!="function"&&(L.Promise=C(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(C,W,Z){"use strict";var L=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function V(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var z=D();function K(){try{if(!z||!z.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function J(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new r,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(t.type)}}typeof Promise>"u"&&C(3);var m=Promise;function w(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function T(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function F(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function $(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var P="local-forage-detect-blob-support",k=void 0,M={},ae=Object.prototype.toString,re="readonly",h="readwrite";function A(e){for(var t=e.length,r=new ArrayBuffer(t),o=new Uint8Array(r),i=0;i<t;i++)o[i]=e.charCodeAt(i);return r}function E(e){return new m(function(t){var r=e.transaction(P,h),o=J([""]);r.objectStore(P).put(o,"key"),r.onabort=function(i){i.preventDefault(),i.stopPropagation(),t(!1)},r.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function N(e){return typeof k=="boolean"?m.resolve(k):E(e).then(function(t){return k=t,k})}function H(e){var t=M[e.name],r={};r.promise=new m(function(o,i){r.resolve=o,r.reject=i}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function j(e){var t=M[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function X(e,t){var r=M[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function Q(e,t){return new m(function(r,o){if(M[e.name]=M[e.name]||G(),e.db)if(t)H(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=z.open.apply(z,i);t&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(P)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),o(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},r(f),j(e)}})}function ee(e){return Q(e,!1)}function oe(e){return Q(e,!0)}function a(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=e.version>e.db.version;if(o&&(e.version!==t&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new m(function(t,r){var o=new FileReader;o.onerror=r,o.onloadend=function(i){var n=btoa(i.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function v(e){var t=A(atob(e.data));return J([t],{type:e.type})}function g(e){return e&&e.__local_forage_encoded_blob}function b(e){var t=this,r=t._initReady().then(function(){var o=M[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(r,e,e),r}function I(e){H(e);for(var t=M[e.name],r=t.forages,o=0;o<r.length;o++){var i=r[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,ee(e).then(function(n){return e.db=n,a(e)?oe(e):n}).then(function(n){e.db=t.db=n;for(var f=0;f<r.length;f++)r[f]._dbInfo.db=n}).catch(function(n){throw X(e,n),n})}function R(e,t,r,o){o===void 0&&(o=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return m.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),oe(e)}).then(function(){return I(e).then(function(){R(e,t,r,o-1)})}).catch(r);r(n)}}function G(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function fe(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=M[r.name];i||(i=G(),M[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=b);var n=[];function f(){return m.resolve()}for(var s=0;s<i.forages.length;s++){var c=i.forages[s];c!==t&&n.push(c._initReady().catch(f))}var l=i.forages.slice(0);return m.all(n).then(function(){return r.db=i.db,ee(r)}).then(function(d){return r.db=d,a(r,t._defaultConfig.version)?oe(r):d}).then(function(d){r.db=i.db=d,t._dbInfo=r;for(var p=0;p<l.length;p++){var S=l[p];S!==t&&(S._dbInfo.db=r.db,S._dbInfo.version=r.version)}})}function ie(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),g(d)&&(d=v(d)),i(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function ue(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var p=l.result;if(p){var S=p.value;g(S)&&(S=v(S));var B=e(S,p.key,d++);B!==void 0?i(B):p.continue()}else i()},l.onerror=function(){n(l.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function tr(e,t,r){var o=this;e=F(e);var i=new m(function(n,f){var s;o.ready().then(function(){return s=o._dbInfo,ae.call(t)==="[object Blob]"?N(s.db).then(function(c){return c?t:u(t)}):t}).then(function(c){R(o._dbInfo,h,function(l,d){if(l)return f(l);try{var p=d.objectStore(o._dbInfo.storeName);c===null&&(c=void 0);var S=p.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var B=S.error?S.error:S.transaction.error;f(B)}}catch(B){f(B)}})}).catch(f)});return w(i,r),i}function nr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){i()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function or(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,h,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.clear();f.oncomplete=function(){o()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;i(l)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.count();c.onsuccess=function(){o(c.result)},c.onerror=function(){i(c.error)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ar(e,t){var r=this,o=new m(function(i,n){if(e<0){i(null);return}r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var p=d.result;if(!p){i(null);return}e===0||l?i(p.key):(l=!0,p.advance(e))},d.onerror=function(){n(d.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function fr(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){o(l);return}l.push(d.key),d.continue()},c.onerror=function(){i(c.error)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function sr(e,t){t=$.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;if(!e.name)i=m.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,f=n?m.resolve(o._dbInfo.db):ee(e).then(function(s){var c=M[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?i=f.then(function(s){if(s.objectStoreNames.contains(e.storeName)){var c=s.version+1;H(e);var l=M[e.name],d=l.forages;s.close();for(var p=0;p<d.length;p++){var S=d[p];S._dbInfo.db=null,S._dbInfo.version=c}var B=new m(function(x,Y){var U=z.open(e.name,c);U.onerror=function(q){var le=U.result;le.close(),Y(q)},U.onupgradeneeded=function(){var q=U.result;q.deleteObjectStore(e.storeName)},U.onsuccess=function(){var q=U.result;q.close(),x(q)}});return B.then(function(x){l.db=x;for(var Y=0;Y<d.length;Y++){var U=d[Y];U._dbInfo.db=x,j(U._dbInfo)}}).catch(function(x){throw(X(e,x)||m.resolve()).catch(function(){}),x})}}):i=f.then(function(s){H(e);var c=M[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var p=l[d];p._dbInfo.db=null}var S=new m(function(B,x){var Y=z.deleteDatabase(e.name);Y.onerror=function(){var U=Y.result;U&&U.close(),x(Y.error)},Y.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},Y.onsuccess=function(){var U=Y.result;U&&U.close(),B(U)}});return S.then(function(B){c.db=B;for(var x=0;x<l.length;x++){var Y=l[x];j(Y._dbInfo)}}).catch(function(B){throw(X(e,B)||m.resolve()).catch(function(){}),B})})}return w(i,t),i}var ur={_driver:"asyncStorage",_initStorage:fe,_support:K(),iterate:ue,getItem:ie,setItem:tr,removeItem:nr,clear:or,length:ir,key:ar,keys:fr,dropInstance:sr};function cr(){return typeof openDatabase=="function"}var te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lr="~~local_forage_type~",Be=/^~~local_forage_type~([^~]+)~/,ve="__lfsc__:",ge=ve.length,be="arbf",_e="blob",Ne="si08",xe="ui08",Oe="uic8",Ce="si16",Le="si32",Pe="ur16",Me="ui32",Fe="fl32",Ue="fl64",We=ge+be.length,ze=Object.prototype.toString;function Ye(e){var t=e.length*.75,r=e.length,o,i=0,n,f,s,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var l=new ArrayBuffer(t),d=new Uint8Array(l);for(o=0;o<r;o+=4)n=te.indexOf(e[o]),f=te.indexOf(e[o+1]),s=te.indexOf(e[o+2]),c=te.indexOf(e[o+3]),d[i++]=n<<2|f>>4,d[i++]=(f&15)<<4|s>>2,d[i++]=(s&3)<<6|c&63;return l}function we(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=te[t[o]>>2],r+=te[(t[o]&3)<<4|t[o+1]>>4],r+=te[(t[o+1]&15)<<2|t[o+2]>>6],r+=te[t[o+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}function dr(e,t){var r="";if(e&&(r=ze.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&ze.call(e.buffer)==="[object ArrayBuffer]")){var o,i=ve;e instanceof ArrayBuffer?(o=e,i+=be):(o=e.buffer,r==="[object Int8Array]"?i+=Ne:r==="[object Uint8Array]"?i+=xe:r==="[object Uint8ClampedArray]"?i+=Oe:r==="[object Int16Array]"?i+=Ce:r==="[object Uint16Array]"?i+=Pe:r==="[object Int32Array]"?i+=Le:r==="[object Uint32Array]"?i+=Me:r==="[object Float32Array]"?i+=Fe:r==="[object Float64Array]"?i+=Ue:t(new Error("Failed to get type for BinaryArray"))),t(i+we(o))}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=lr+e.type+"~"+we(this.result);t(ve+_e+f)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),t(null,f)}}function vr(e){if(e.substring(0,ge)!==ve)return JSON.parse(e);var t=e.substring(We),r=e.substring(ge,We),o;if(r===_e&&Be.test(t)){var i=t.match(Be);o=i[1],t=t.substring(i[0].length)}var n=Ye(t);switch(r){case be:return n;case _e:return J([n],{type:o});case Ne:return new Int8Array(n);case xe:return new Uint8Array(n);case Oe:return new Uint8ClampedArray(n);case Ce:return new Int16Array(n);case Pe:return new Uint16Array(n);case Le:return new Int32Array(n);case Me:return new Uint32Array(n);case Fe:return new Float32Array(n);case Ue:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var Ie={serialize:dr,deserialize:vr,stringToBuffer:Ye,bufferToString:we};function Ke(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function hr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=typeof e[o]!="string"?e[o].toString():e[o];var i=new m(function(n,f){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(s){return f(s)}r.db.transaction(function(s){Ke(s,r,function(){t._dbInfo=r,n()},function(c,l){f(l)})},f)});return r.serializer=Ie,i}function ne(e,t,r,o,i,n){e.executeSql(r,o,i,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(c,l){l.rows.length?n(c,s):Ke(c,t,function(){c.executeSql(r,o,i,n)},n)},n):n(f,s)},n)}function mr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function yr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,p=d.length,S=0;S<p;S++){var B=d.item(S),x=B.value;if(x&&(x=f.serializer.deserialize(x)),x=e(x,B.key,S+1),x!==void 0){i(x);return}}i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function He(e,t,r,o){var i=this;e=F(e);var n=new m(function(f,s){i.ready().then(function(){t===void 0&&(t=null);var c=t,l=i._dbInfo;l.serializer.serialize(t,function(d,p){p?s(p):l.db.transaction(function(S){ne(S,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(B,x){s(x)})},function(S){if(S.code===S.QUOTA_ERR){if(o>0){f(He.apply(i,[e,c,r,o-1]));return}s(S)}})})}).catch(s)});return w(n,r),n}function pr(e,t,r){return He.apply(this,[e,t,r,1])}function gr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function br(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"DELETE FROM "+n.storeName,[],function(){o()},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function _r(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function wr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Er(e){return new m(function(t,r){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);t({db:e,storeNames:f})},function(i,n){r(n)})},function(o){r(o)})})}function Sr(e,t){t=$.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;return e.name?i=new m(function(n){var f;e.name===r.name?f=o._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Er(f))}).then(function(n){return new m(function(f,s){n.db.transaction(function(c){function l(B){return new m(function(x,Y){c.executeSql("DROP TABLE IF EXISTS "+B,[],function(){x()},function(U,q){Y(q)})})}for(var d=[],p=0,S=n.storeNames.length;p<S;p++)d.push(l(n.storeNames[p]));m.all(d).then(function(){f()}).catch(function(B){s(B)})},function(c){s(c)})})}):i=m.reject("Invalid arguments"),w(i,t),i}var Ar={_driver:"webSQLStorage",_initStorage:hr,_support:cr(),iterate:yr,getItem:mr,setItem:pr,removeItem:gr,clear:br,length:_r,key:wr,keys:Ir,dropInstance:Sr};function Rr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ve(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Dr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Tr(){return!Dr()||localStorage.length>0}function Br(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=Ve(e,t._defaultConfig),Tr()?(t._dbInfo=r,r.serializer=Ie,m.resolve()):m.reject()}function Nr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(o)===0&&localStorage.removeItem(n)}});return w(r,e),r}function xr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return w(o,t),o}function Or(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var p=localStorage.getItem(d);if(p&&(p=i.serializer.deserialize(p)),p=e(p,d.substring(f),c++),p!==void 0)return p}}});return w(o,t),o}function Cr(e,t){var r=this,o=r.ready().then(function(){var i=r._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return w(o,t),o}function Lr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],f=0;f<i;f++){var s=localStorage.key(f);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length))}return n});return w(r,e),r}function Pr(e){var t=this,r=t.keys().then(function(o){return o.length});return w(r,e),r}function Mr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return w(o,t),o}function Fr(e,t,r){var o=this;e=F(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new m(function(f,s){var c=o._dbInfo;c.serializer.serialize(t,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(p){(p.name==="QuotaExceededError"||p.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(p),s(p)}})})});return w(i,r),i}function Ur(e,t){if(t=$.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var o=this,i;return e.name?i=new m(function(n){e.storeName?n(Ve(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):i=m.reject("Invalid arguments"),w(i,t),i}var Wr={_driver:"localStorageWrapper",_initStorage:Br,_support:Rr(),iterate:Or,getItem:xr,setItem:Fr,removeItem:Mr,clear:Nr,length:Pr,key:Cr,keys:Lr,dropInstance:Ur},zr=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},Yr=function(t,r){for(var o=t.length,i=0;i<o;){if(zr(t[i],r))return!0;i++}return!1},Ge=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},ce={},je={},se={INDEXEDDB:ur,WEBSQL:Ar,LOCALSTORAGE:Wr},Kr=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],he=["dropInstance"],Ee=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(he),Hr={description:"",driver:Kr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Vr(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Se(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(Ge(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var Gr=function(){function e(t){V(this,e);for(var r in se)if(se.hasOwnProperty(r)){var o=se[r],i=o._driver;this[r]=i,ce[i]||this.defineDriver(o)}this._defaultConfig=Se({},Hr),this._config=Se({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(r){if((typeof r>"u"?"undefined":L(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in r){if(o==="storeName"&&(r[o]=r[o].replace(/\W/g,"_")),o==="version"&&typeof r[o]!="number")return new Error("Database version must be a number.");this._config[o]=r[o]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,o,i){var n=new m(function(f,s){try{var c=r._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){s(l);return}for(var d=Ee.concat("_initStorage"),p=0,S=d.length;p<S;p++){var B=d[p],x=!Yr(he,B);if((x||r[B])&&typeof r[B]!="function"){s(l);return}}var Y=function(){for(var le=function(Qr){return function(){var Jr=new Error("Method "+Qr+" is not implemented by the current driver"),Xe=m.reject(Jr);return w(Xe,arguments[arguments.length-1]),Xe}},Ae=0,Xr=he.length;Ae<Xr;Ae++){var Re=he[Ae];r[Re]||(r[Re]=le(Re))}};Y();var U=function(le){ce[c]&&console.info("Redefining LocalForage driver: "+c),ce[c]=r,je[c]=le,f()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(U,s):U(!!r._support):U(!0)}catch(q){s(q)}});return T(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=ce[r]?m.resolve(ce[r]):m.reject(new Error("Driver not found."));return T(n,o,i),n},e.prototype.getSerializer=function(r){var o=m.resolve(Ie);return T(o,r),o},e.prototype.ready=function(r){var o=this,i=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;Ge(r)||(r=[r]);var f=this._getSupportedDrivers(r);function s(){n._config.driver=n.driver()}function c(p){return n._extend(p),s(),n._ready=n._initStorage(n._config),n._ready}function l(p){return function(){var S=0;function B(){for(;S<p.length;){var x=p[S];return S++,n._dbInfo=null,n._ready=null,n.getDriver(x).then(c).catch(B)}s();var Y=new Error("No available storage method found.");return n._driverSet=m.reject(Y),n._driverSet}return B()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=d.then(function(){var p=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(p).then(function(S){n._driver=S._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var p=new Error("No available storage method found.");return n._driverSet=m.reject(p),n._driverSet}),T(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!je[r]},e.prototype._extend=function(r){Se(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var f=r[i];this.supports(f)&&o.push(f)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Ee.length;r<o;r++)Vr(this,Ee[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),jr=new Gr;W.exports=jr},{3:3}]},{},[4])(4)})});var er=Je((me,ke)=>{"use strict";(function(_,y){typeof me=="object"&&typeof ke<"u"?y(me):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],y):y(_.LocalforageDriverMemory={})})(typeof self<"u"?self:me,function(_){"use strict";var y="localforage-driver-memory";function O(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function C(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(I){if(I.name!=="TypeError")throw I;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,g=new v,b=0;b<a.length;b+=1)g.append(a[b]);return g.getBlob(u.type)}}var W=/^~~local_forage_type~([^~]+)~/,Z=9,L=Z+4,V=Object.prototype.toString;function D(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var g=new ArrayBuffer(u),b=new Uint8Array(g),I=0,R=0;I<v;I+=4){var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I]),fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+1]),ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+2]),ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+3]);b[R++]=G<<2|fe>>4,b[R++]=(fe&15)<<4|ie>>2,b[R++]=(ie&3)<<6|ue&63}return g}function z(a){for(var u=new Uint8Array(a),v="",g=0;g<u.length;g+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g]&3)<<4|u[g+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g+1]&15)<<2|u[g+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function K(a,u){var v="";if(a&&(v=V.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&V.call(a.buffer)==="[object ArrayBuffer]")){var g=void 0,b="__lfsc__:";a instanceof ArrayBuffer?(g=a,b+="arbf"):(g=a.buffer,v==="[object Int8Array]"?b+="si08":v==="[object Uint8Array]"?b+="ui08":v==="[object Uint8ClampedArray]"?b+="uic8":v==="[object Int16Array]"?b+="si16":v==="[object Uint16Array]"?b+="ur16":v==="[object Int32Array]"?b+="si32":v==="[object Uint32Array]"?b+="ui32":v==="[object Float32Array]"?b+="fl32":v==="[object Float64Array]"?b+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(b+z(g))}else if(v==="[object Blob]"){var I=new FileReader;I.onload=function(){var R="~~local_forage_type~"+a.type+"~"+z(this.result);u("__lfsc__:blob"+R)},I.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(R){console.error("Couldn't convert value into a JSON string: ",a),u(null,R)}}function J(a){if(a.substring(0,Z)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(L),v=a.substring(Z,L),g;if(v==="blob"&&W.test(u)){var b=u.match(W);g=b[1],u=u.substring(b[0].length)}var I=D(u);switch(v){case"arbf":return I;case"blob":return C([I],{type:g});case"si08":return new Int8Array(I);case"ui08":return new Uint8Array(I);case"uic8":return new Uint8ClampedArray(I);case"si16":return new Int16Array(I);case"ur16":return new Uint16Array(I);case"si32":return new Int32Array(I);case"ui32":return new Uint32Array(I);case"fl32":return new Float32Array(I);case"fl64":return new Float64Array(I);default:throw new Error("Unkown type: "+v)}}function m(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var g=a instanceof Date?new Date(a):a.constructor();try{for(var b=O(Object.keys(a)),I=b.next();!I.done;I=b.next()){var R=I.value;Object.prototype.hasOwnProperty.call(a,R)&&(a.isActiveClone=null,g[R]=m(a[R]),delete a.isActiveClone)}}catch(G){u={error:G}}finally{try{I&&!I.done&&(v=b.return)&&v.call(b)}finally{if(u)throw u.error}}return g}function w(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function T(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function F(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function $(a,u){var v=this;if(u=F.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var g=this.config();a.name=a.name||g.name,a.storeName=a.storeName||g.storeName}var b;return a.name?b=new Promise(function(I){a.storeName?I(w(a,v._defaultConfig)):I(a.name+"/")}):b=Promise.reject("Invalid arguments"),{promise:b,callback:u}}function P(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var k={bufferToString:z,deserialize:J,serialize:K,stringToBuffer:D},M={},ae=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return M[u]||(M[u]=new a(u)),M[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete M[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function re(a){var u=a?m(a):{},v=w(u,this._defaultConfig),g=ae.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=k,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=g,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return T(v,a),v}function A(a,u){var v=$.apply(this,arguments),g=v.promise,b=v.callback,I=g.then(function(R){ae.resolve(R).drop()});return T(I,b),g}function E(a,u){var v=this;a=P(a);var g=this.ready().then(function(){var b=v._dbInfo.mStore.get(a);return b==null?null:v._dbInfo.serializer.deserialize(b)});return T(g,u),g}function N(a,u){var v=this,g=this.ready().then(function(){for(var b=v._dbInfo.mStore,I=b.keys(),R=0;R<I.length;R++){var G=b.get(I[R]);if(G&&(G=v._dbInfo.serializer.deserialize(G)),G=a(G,I[R],R+1),G!==void 0)return G}});return T(g,u),g}function H(a,u){var v=this,g=this.ready().then(function(){var b;try{b=v._dbInfo.mStore.key(a),b===void 0&&(b=null)}catch{b=null}return b});return T(g,u),g}function j(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return T(v,a),v}function X(a){var u=this.keys().then(function(v){return v.length});return T(u,a),u}function Q(a,u){var v=this;a=P(a);var g=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return T(g,u),g}function ee(a,u,v){var g=this;a=P(a);var b=this.ready().then(function(){u===void 0&&(u=null);var I=u;return new Promise(function(R,G){g._dbInfo.serializer.serialize(u,function(fe,ie){if(ie)G(ie);else try{g._dbInfo.mStore.set(a,fe),R(I)}catch(ue){G(ue)}})})});return T(b,v),b}var oe=!0;_._support=oe,_._driver=y,_._initStorage=re,_.clear=h,_.dropInstance=A,_.getItem=E,_.iterate=N,_.key=H,_.keys=j,_.length=X,_.removeItem=Q,_.setItem=ee,Object.defineProperty(_,"__esModule",{value:!0})})});var pe=$e(qe()),Te=$e(er());import{SDKBase as ut,createSDK as ct}from"@magic-sdk/provider";import{createDuplicateIframeWarning as tt,createModalNotReadyError as nt,createURL as rr,ViewController as ot}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as it}from"@magic-sdk/types";var at={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function ft(_){for(let[y,O]of Object.entries(at))_.style[y]=O}function st(_){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(O=>O.src.includes(_))}var ye=class extends ot{activeElement=null;iframe;relayerSrc=rr(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(y=>{let O=()=>{if(st(encodeURIComponent(this.parameters)))tt().log();else{let C=document.createElement("iframe");C.classList.add("magic-iframe"),C.dataset.magicIframeLabel=rr(this.endpoint).host,C.title="Secure Modal",C.src=this.relayerSrc,C.allow="clipboard-read; clipboard-write",ft(C),document.body.appendChild(C),y(C)}};["loaded","interactive","complete"].includes(document.readyState)?O():window.addEventListener("load",O,!1)}),this.iframe.then(y=>{y instanceof HTMLIFrameElement&&y.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",y=>{if(y.origin===this.endpoint&&y.data.msgType&&(y.data.msgType.includes(it.MAGIC_PONG)&&(this.lastPongTime=Date.now()),y.data&&this.messageHandlers.size)){y.data.response=y.data.response??{},this.stopHeartBeat();for(let O of this.messageHandlers.values())O(y)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let y=await this.iframe;y.style.display="block",y.style.zIndex="2147483647",y.style.opacity="1",this.activeElement=document.activeElement,y.focus()}async hideOverlay(){let y=await this.iframe;y.style.display="none",y.style.zIndex="-1",y.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(y){let O=await this.iframe;if(O&&O.contentWindow)O.contentWindow.postMessage(y,this.endpoint);else throw nt()}async checkRelayerExistsInDOM(){let y=await this.iframe;return!y||!y.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(C=>C.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let y=await this.iframe;if(this.stopHeartBeat(),!y){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!y.contentWindow){document.body.appendChild(y),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}y&&(y.src=this.relayerSrc)}};export*from"@magic-sdk/provider";export*from"@magic-sdk/types";var wt=ct(ut,{platform:"web",sdkName:"magic-sdk",version:"31.1.0",defaultEndpoint:"https://auth.magic.link/",ViewController:ye,configureStorage:async()=>{let _=pe.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await _.defineDriver(Te),await _.setDriver([pe.default.INDEXEDDB,pe.default.LOCALSTORAGE,Te._driver]),_}});export{wt as Magic};
1
+ var $r=Object.create;var Qe=Object.defineProperty;var Zr=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var kr=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var de=(_=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(_,{get:(y,O)=>(typeof require<"u"?require:y)[O]}):_)(function(_){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+_+'" is not supported')});var Je=(_,y)=>()=>(y||_((y={exports:{}}).exports,y),y.exports);var rt=(_,y,O,C)=>{if(y&&typeof y=="object"||typeof y=="function")for(let W of qr(y))!et.call(_,W)&&W!==O&&Qe(_,W,{get:()=>y[W],enumerable:!(C=Zr(y,W))||C.enumerable});return _};var $e=(_,y,O)=>(O=_!=null?$r(kr(_)):{},rt(y||!_||!_.__esModule?Qe(O,"default",{value:_,enumerable:!0}):O,_));var qe=Je((Ze,De)=>{"use strict";(function(_){if(typeof Ze=="object"&&typeof De<"u")De.exports=_();else if(typeof define=="function"&&define.amd)define([],_);else{var y;typeof window<"u"?y=window:typeof global<"u"?y=global:typeof self<"u"?y=self:y=this,y.localforage=_()}})(function(){var _,y,O;return function C(W,Z,L){function V(K,J){if(!Z[K]){if(!W[K]){var m=typeof de=="function"&&de;if(!J&&m)return m(K,!0);if(D)return D(K,!0);var w=new Error("Cannot find module '"+K+"'");throw w.code="MODULE_NOT_FOUND",w}var T=Z[K]={exports:{}};W[K][0].call(T.exports,function(F){var $=W[K][1][F];return V($||F)},T,T.exports,C,W,Z,L)}return Z[K].exports}for(var D=typeof de=="function"&&de,z=0;z<L.length;z++)V(L[z]);return V}({1:[function(C,W,Z){(function(L){"use strict";var V=L.MutationObserver||L.WebKitMutationObserver,D;if(V){var z=0,K=new V(F),J=L.document.createTextNode("");K.observe(J,{characterData:!0}),D=function(){J.data=z=++z%2}}else if(!L.setImmediate&&typeof L.MessageChannel<"u"){var m=new L.MessageChannel;m.port1.onmessage=F,D=function(){m.port2.postMessage(0)}}else"document"in L&&"onreadystatechange"in L.document.createElement("script")?D=function(){var P=L.document.createElement("script");P.onreadystatechange=function(){F(),P.onreadystatechange=null,P.parentNode.removeChild(P),P=null},L.document.documentElement.appendChild(P)}:D=function(){setTimeout(F,0)};var w,T=[];function F(){w=!0;for(var P,k,M=T.length;M;){for(k=T,T=[],P=-1;++P<M;)k[P]();M=T.length}w=!1}W.exports=$;function $(P){T.push(P)===1&&!w&&D()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(C,W,Z){"use strict";var L=C(1);function V(){}var D={},z=["REJECTED"],K=["FULFILLED"],J=["PENDING"];W.exports=m;function m(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=J,this.queue=[],this.outcome=void 0,h!==V&&$(this,h)}m.prototype.catch=function(h){return this.then(null,h)},m.prototype.then=function(h,A){if(typeof h!="function"&&this.state===K||typeof A!="function"&&this.state===z)return this;var E=new this.constructor(V);if(this.state!==J){var N=this.state===K?h:A;T(E,N,this.outcome)}else this.queue.push(new w(E,h,A));return E};function w(h,A,E){this.promise=h,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(h){D.resolve(this.promise,h)},w.prototype.otherCallFulfilled=function(h){T(this.promise,this.onFulfilled,h)},w.prototype.callRejected=function(h){D.reject(this.promise,h)},w.prototype.otherCallRejected=function(h){T(this.promise,this.onRejected,h)};function T(h,A,E){L(function(){var N;try{N=A(E)}catch(H){return D.reject(h,H)}N===h?D.reject(h,new TypeError("Cannot resolve promise with itself")):D.resolve(h,N)})}D.resolve=function(h,A){var E=P(F,A);if(E.status==="error")return D.reject(h,E.value);var N=E.value;if(N)$(h,N);else{h.state=K,h.outcome=A;for(var H=-1,j=h.queue.length;++H<j;)h.queue[H].callFulfilled(A)}return h},D.reject=function(h,A){h.state=z,h.outcome=A;for(var E=-1,N=h.queue.length;++E<N;)h.queue[E].callRejected(A);return h};function F(h){var A=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof A=="function")return function(){A.apply(h,arguments)}}function $(h,A){var E=!1;function N(Q){E||(E=!0,D.reject(h,Q))}function H(Q){E||(E=!0,D.resolve(h,Q))}function j(){A(H,N)}var X=P(j);X.status==="error"&&N(X.value)}function P(h,A){var E={};try{E.value=h(A),E.status="success"}catch(N){E.status="error",E.value=N}return E}m.resolve=k;function k(h){return h instanceof this?h:D.resolve(new this(V),h)}m.reject=M;function M(h){var A=new this(V);return D.reject(A,h)}m.all=ae;function ae(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=new Array(E),j=0,X=-1,Q=new this(V);++X<E;)ee(h[X],X);return Q;function ee(oe,a){A.resolve(oe).then(u,function(v){N||(N=!0,D.reject(Q,v))});function u(v){H[a]=v,++j===E&&!N&&(N=!0,D.resolve(Q,H))}}}m.race=re;function re(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=-1,j=new this(V);++H<E;)X(h[H]);return j;function X(Q){A.resolve(Q).then(function(ee){N||(N=!0,D.resolve(j,ee))},function(ee){N||(N=!0,D.reject(j,ee))})}}},{1:1}],3:[function(C,W,Z){(function(L){"use strict";typeof L.Promise!="function"&&(L.Promise=C(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(C,W,Z){"use strict";var L=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function V(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var z=D();function K(){try{if(!z||!z.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function J(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new r,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(t.type)}}typeof Promise>"u"&&C(3);var m=Promise;function w(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function T(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function F(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function $(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var P="local-forage-detect-blob-support",k=void 0,M={},ae=Object.prototype.toString,re="readonly",h="readwrite";function A(e){for(var t=e.length,r=new ArrayBuffer(t),o=new Uint8Array(r),i=0;i<t;i++)o[i]=e.charCodeAt(i);return r}function E(e){return new m(function(t){var r=e.transaction(P,h),o=J([""]);r.objectStore(P).put(o,"key"),r.onabort=function(i){i.preventDefault(),i.stopPropagation(),t(!1)},r.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function N(e){return typeof k=="boolean"?m.resolve(k):E(e).then(function(t){return k=t,k})}function H(e){var t=M[e.name],r={};r.promise=new m(function(o,i){r.resolve=o,r.reject=i}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function j(e){var t=M[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function X(e,t){var r=M[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function Q(e,t){return new m(function(r,o){if(M[e.name]=M[e.name]||G(),e.db)if(t)H(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=z.open.apply(z,i);t&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(P)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),o(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},r(f),j(e)}})}function ee(e){return Q(e,!1)}function oe(e){return Q(e,!0)}function a(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=e.version>e.db.version;if(o&&(e.version!==t&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new m(function(t,r){var o=new FileReader;o.onerror=r,o.onloadend=function(i){var n=btoa(i.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function v(e){var t=A(atob(e.data));return J([t],{type:e.type})}function g(e){return e&&e.__local_forage_encoded_blob}function b(e){var t=this,r=t._initReady().then(function(){var o=M[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(r,e,e),r}function I(e){H(e);for(var t=M[e.name],r=t.forages,o=0;o<r.length;o++){var i=r[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,ee(e).then(function(n){return e.db=n,a(e)?oe(e):n}).then(function(n){e.db=t.db=n;for(var f=0;f<r.length;f++)r[f]._dbInfo.db=n}).catch(function(n){throw X(e,n),n})}function R(e,t,r,o){o===void 0&&(o=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return m.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),oe(e)}).then(function(){return I(e).then(function(){R(e,t,r,o-1)})}).catch(r);r(n)}}function G(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function fe(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=M[r.name];i||(i=G(),M[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=b);var n=[];function f(){return m.resolve()}for(var s=0;s<i.forages.length;s++){var c=i.forages[s];c!==t&&n.push(c._initReady().catch(f))}var l=i.forages.slice(0);return m.all(n).then(function(){return r.db=i.db,ee(r)}).then(function(d){return r.db=d,a(r,t._defaultConfig.version)?oe(r):d}).then(function(d){r.db=i.db=d,t._dbInfo=r;for(var p=0;p<l.length;p++){var S=l[p];S!==t&&(S._dbInfo.db=r.db,S._dbInfo.version=r.version)}})}function ie(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),g(d)&&(d=v(d)),i(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function ue(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var p=l.result;if(p){var S=p.value;g(S)&&(S=v(S));var B=e(S,p.key,d++);B!==void 0?i(B):p.continue()}else i()},l.onerror=function(){n(l.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function tr(e,t,r){var o=this;e=F(e);var i=new m(function(n,f){var s;o.ready().then(function(){return s=o._dbInfo,ae.call(t)==="[object Blob]"?N(s.db).then(function(c){return c?t:u(t)}):t}).then(function(c){R(o._dbInfo,h,function(l,d){if(l)return f(l);try{var p=d.objectStore(o._dbInfo.storeName);c===null&&(c=void 0);var S=p.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var B=S.error?S.error:S.transaction.error;f(B)}}catch(B){f(B)}})}).catch(f)});return w(i,r),i}function nr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){i()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function or(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,h,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.clear();f.oncomplete=function(){o()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;i(l)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.count();c.onsuccess=function(){o(c.result)},c.onerror=function(){i(c.error)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ar(e,t){var r=this,o=new m(function(i,n){if(e<0){i(null);return}r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var p=d.result;if(!p){i(null);return}e===0||l?i(p.key):(l=!0,p.advance(e))},d.onerror=function(){n(d.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function fr(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){o(l);return}l.push(d.key),d.continue()},c.onerror=function(){i(c.error)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function sr(e,t){t=$.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;if(!e.name)i=m.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,f=n?m.resolve(o._dbInfo.db):ee(e).then(function(s){var c=M[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?i=f.then(function(s){if(s.objectStoreNames.contains(e.storeName)){var c=s.version+1;H(e);var l=M[e.name],d=l.forages;s.close();for(var p=0;p<d.length;p++){var S=d[p];S._dbInfo.db=null,S._dbInfo.version=c}var B=new m(function(x,Y){var U=z.open(e.name,c);U.onerror=function(q){var le=U.result;le.close(),Y(q)},U.onupgradeneeded=function(){var q=U.result;q.deleteObjectStore(e.storeName)},U.onsuccess=function(){var q=U.result;q.close(),x(q)}});return B.then(function(x){l.db=x;for(var Y=0;Y<d.length;Y++){var U=d[Y];U._dbInfo.db=x,j(U._dbInfo)}}).catch(function(x){throw(X(e,x)||m.resolve()).catch(function(){}),x})}}):i=f.then(function(s){H(e);var c=M[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var p=l[d];p._dbInfo.db=null}var S=new m(function(B,x){var Y=z.deleteDatabase(e.name);Y.onerror=function(){var U=Y.result;U&&U.close(),x(Y.error)},Y.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},Y.onsuccess=function(){var U=Y.result;U&&U.close(),B(U)}});return S.then(function(B){c.db=B;for(var x=0;x<l.length;x++){var Y=l[x];j(Y._dbInfo)}}).catch(function(B){throw(X(e,B)||m.resolve()).catch(function(){}),B})})}return w(i,t),i}var ur={_driver:"asyncStorage",_initStorage:fe,_support:K(),iterate:ue,getItem:ie,setItem:tr,removeItem:nr,clear:or,length:ir,key:ar,keys:fr,dropInstance:sr};function cr(){return typeof openDatabase=="function"}var te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lr="~~local_forage_type~",Be=/^~~local_forage_type~([^~]+)~/,ve="__lfsc__:",ge=ve.length,be="arbf",_e="blob",Ne="si08",xe="ui08",Oe="uic8",Ce="si16",Le="si32",Pe="ur16",Me="ui32",Fe="fl32",Ue="fl64",We=ge+be.length,ze=Object.prototype.toString;function Ye(e){var t=e.length*.75,r=e.length,o,i=0,n,f,s,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var l=new ArrayBuffer(t),d=new Uint8Array(l);for(o=0;o<r;o+=4)n=te.indexOf(e[o]),f=te.indexOf(e[o+1]),s=te.indexOf(e[o+2]),c=te.indexOf(e[o+3]),d[i++]=n<<2|f>>4,d[i++]=(f&15)<<4|s>>2,d[i++]=(s&3)<<6|c&63;return l}function we(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=te[t[o]>>2],r+=te[(t[o]&3)<<4|t[o+1]>>4],r+=te[(t[o+1]&15)<<2|t[o+2]>>6],r+=te[t[o+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}function dr(e,t){var r="";if(e&&(r=ze.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&ze.call(e.buffer)==="[object ArrayBuffer]")){var o,i=ve;e instanceof ArrayBuffer?(o=e,i+=be):(o=e.buffer,r==="[object Int8Array]"?i+=Ne:r==="[object Uint8Array]"?i+=xe:r==="[object Uint8ClampedArray]"?i+=Oe:r==="[object Int16Array]"?i+=Ce:r==="[object Uint16Array]"?i+=Pe:r==="[object Int32Array]"?i+=Le:r==="[object Uint32Array]"?i+=Me:r==="[object Float32Array]"?i+=Fe:r==="[object Float64Array]"?i+=Ue:t(new Error("Failed to get type for BinaryArray"))),t(i+we(o))}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=lr+e.type+"~"+we(this.result);t(ve+_e+f)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),t(null,f)}}function vr(e){if(e.substring(0,ge)!==ve)return JSON.parse(e);var t=e.substring(We),r=e.substring(ge,We),o;if(r===_e&&Be.test(t)){var i=t.match(Be);o=i[1],t=t.substring(i[0].length)}var n=Ye(t);switch(r){case be:return n;case _e:return J([n],{type:o});case Ne:return new Int8Array(n);case xe:return new Uint8Array(n);case Oe:return new Uint8ClampedArray(n);case Ce:return new Int16Array(n);case Pe:return new Uint16Array(n);case Le:return new Int32Array(n);case Me:return new Uint32Array(n);case Fe:return new Float32Array(n);case Ue:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var Ie={serialize:dr,deserialize:vr,stringToBuffer:Ye,bufferToString:we};function Ke(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function hr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=typeof e[o]!="string"?e[o].toString():e[o];var i=new m(function(n,f){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(s){return f(s)}r.db.transaction(function(s){Ke(s,r,function(){t._dbInfo=r,n()},function(c,l){f(l)})},f)});return r.serializer=Ie,i}function ne(e,t,r,o,i,n){e.executeSql(r,o,i,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(c,l){l.rows.length?n(c,s):Ke(c,t,function(){c.executeSql(r,o,i,n)},n)},n):n(f,s)},n)}function mr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function yr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,p=d.length,S=0;S<p;S++){var B=d.item(S),x=B.value;if(x&&(x=f.serializer.deserialize(x)),x=e(x,B.key,S+1),x!==void 0){i(x);return}}i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function He(e,t,r,o){var i=this;e=F(e);var n=new m(function(f,s){i.ready().then(function(){t===void 0&&(t=null);var c=t,l=i._dbInfo;l.serializer.serialize(t,function(d,p){p?s(p):l.db.transaction(function(S){ne(S,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(B,x){s(x)})},function(S){if(S.code===S.QUOTA_ERR){if(o>0){f(He.apply(i,[e,c,r,o-1]));return}s(S)}})})}).catch(s)});return w(n,r),n}function pr(e,t,r){return He.apply(this,[e,t,r,1])}function gr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function br(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"DELETE FROM "+n.storeName,[],function(){o()},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function _r(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function wr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Er(e){return new m(function(t,r){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);t({db:e,storeNames:f})},function(i,n){r(n)})},function(o){r(o)})})}function Sr(e,t){t=$.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;return e.name?i=new m(function(n){var f;e.name===r.name?f=o._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Er(f))}).then(function(n){return new m(function(f,s){n.db.transaction(function(c){function l(B){return new m(function(x,Y){c.executeSql("DROP TABLE IF EXISTS "+B,[],function(){x()},function(U,q){Y(q)})})}for(var d=[],p=0,S=n.storeNames.length;p<S;p++)d.push(l(n.storeNames[p]));m.all(d).then(function(){f()}).catch(function(B){s(B)})},function(c){s(c)})})}):i=m.reject("Invalid arguments"),w(i,t),i}var Ar={_driver:"webSQLStorage",_initStorage:hr,_support:cr(),iterate:yr,getItem:mr,setItem:pr,removeItem:gr,clear:br,length:_r,key:wr,keys:Ir,dropInstance:Sr};function Rr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ve(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Dr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Tr(){return!Dr()||localStorage.length>0}function Br(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=Ve(e,t._defaultConfig),Tr()?(t._dbInfo=r,r.serializer=Ie,m.resolve()):m.reject()}function Nr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(o)===0&&localStorage.removeItem(n)}});return w(r,e),r}function xr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return w(o,t),o}function Or(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var p=localStorage.getItem(d);if(p&&(p=i.serializer.deserialize(p)),p=e(p,d.substring(f),c++),p!==void 0)return p}}});return w(o,t),o}function Cr(e,t){var r=this,o=r.ready().then(function(){var i=r._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return w(o,t),o}function Lr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],f=0;f<i;f++){var s=localStorage.key(f);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length))}return n});return w(r,e),r}function Pr(e){var t=this,r=t.keys().then(function(o){return o.length});return w(r,e),r}function Mr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return w(o,t),o}function Fr(e,t,r){var o=this;e=F(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new m(function(f,s){var c=o._dbInfo;c.serializer.serialize(t,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(p){(p.name==="QuotaExceededError"||p.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(p),s(p)}})})});return w(i,r),i}function Ur(e,t){if(t=$.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var o=this,i;return e.name?i=new m(function(n){e.storeName?n(Ve(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):i=m.reject("Invalid arguments"),w(i,t),i}var Wr={_driver:"localStorageWrapper",_initStorage:Br,_support:Rr(),iterate:Or,getItem:xr,setItem:Fr,removeItem:Mr,clear:Nr,length:Pr,key:Cr,keys:Lr,dropInstance:Ur},zr=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},Yr=function(t,r){for(var o=t.length,i=0;i<o;){if(zr(t[i],r))return!0;i++}return!1},Ge=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},ce={},je={},se={INDEXEDDB:ur,WEBSQL:Ar,LOCALSTORAGE:Wr},Kr=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],he=["dropInstance"],Ee=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(he),Hr={description:"",driver:Kr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Vr(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Se(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(Ge(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var Gr=function(){function e(t){V(this,e);for(var r in se)if(se.hasOwnProperty(r)){var o=se[r],i=o._driver;this[r]=i,ce[i]||this.defineDriver(o)}this._defaultConfig=Se({},Hr),this._config=Se({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(r){if((typeof r>"u"?"undefined":L(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in r){if(o==="storeName"&&(r[o]=r[o].replace(/\W/g,"_")),o==="version"&&typeof r[o]!="number")return new Error("Database version must be a number.");this._config[o]=r[o]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,o,i){var n=new m(function(f,s){try{var c=r._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){s(l);return}for(var d=Ee.concat("_initStorage"),p=0,S=d.length;p<S;p++){var B=d[p],x=!Yr(he,B);if((x||r[B])&&typeof r[B]!="function"){s(l);return}}var Y=function(){for(var le=function(Qr){return function(){var Jr=new Error("Method "+Qr+" is not implemented by the current driver"),Xe=m.reject(Jr);return w(Xe,arguments[arguments.length-1]),Xe}},Ae=0,Xr=he.length;Ae<Xr;Ae++){var Re=he[Ae];r[Re]||(r[Re]=le(Re))}};Y();var U=function(le){ce[c]&&console.info("Redefining LocalForage driver: "+c),ce[c]=r,je[c]=le,f()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(U,s):U(!!r._support):U(!0)}catch(q){s(q)}});return T(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=ce[r]?m.resolve(ce[r]):m.reject(new Error("Driver not found."));return T(n,o,i),n},e.prototype.getSerializer=function(r){var o=m.resolve(Ie);return T(o,r),o},e.prototype.ready=function(r){var o=this,i=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;Ge(r)||(r=[r]);var f=this._getSupportedDrivers(r);function s(){n._config.driver=n.driver()}function c(p){return n._extend(p),s(),n._ready=n._initStorage(n._config),n._ready}function l(p){return function(){var S=0;function B(){for(;S<p.length;){var x=p[S];return S++,n._dbInfo=null,n._ready=null,n.getDriver(x).then(c).catch(B)}s();var Y=new Error("No available storage method found.");return n._driverSet=m.reject(Y),n._driverSet}return B()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=d.then(function(){var p=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(p).then(function(S){n._driver=S._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var p=new Error("No available storage method found.");return n._driverSet=m.reject(p),n._driverSet}),T(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!je[r]},e.prototype._extend=function(r){Se(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var f=r[i];this.supports(f)&&o.push(f)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Ee.length;r<o;r++)Vr(this,Ee[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),jr=new Gr;W.exports=jr},{3:3}]},{},[4])(4)})});var er=Je((me,ke)=>{"use strict";(function(_,y){typeof me=="object"&&typeof ke<"u"?y(me):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],y):y(_.LocalforageDriverMemory={})})(typeof self<"u"?self:me,function(_){"use strict";var y="localforage-driver-memory";function O(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function C(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(I){if(I.name!=="TypeError")throw I;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,g=new v,b=0;b<a.length;b+=1)g.append(a[b]);return g.getBlob(u.type)}}var W=/^~~local_forage_type~([^~]+)~/,Z=9,L=Z+4,V=Object.prototype.toString;function D(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var g=new ArrayBuffer(u),b=new Uint8Array(g),I=0,R=0;I<v;I+=4){var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I]),fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+1]),ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+2]),ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+3]);b[R++]=G<<2|fe>>4,b[R++]=(fe&15)<<4|ie>>2,b[R++]=(ie&3)<<6|ue&63}return g}function z(a){for(var u=new Uint8Array(a),v="",g=0;g<u.length;g+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g]&3)<<4|u[g+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g+1]&15)<<2|u[g+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function K(a,u){var v="";if(a&&(v=V.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&V.call(a.buffer)==="[object ArrayBuffer]")){var g=void 0,b="__lfsc__:";a instanceof ArrayBuffer?(g=a,b+="arbf"):(g=a.buffer,v==="[object Int8Array]"?b+="si08":v==="[object Uint8Array]"?b+="ui08":v==="[object Uint8ClampedArray]"?b+="uic8":v==="[object Int16Array]"?b+="si16":v==="[object Uint16Array]"?b+="ur16":v==="[object Int32Array]"?b+="si32":v==="[object Uint32Array]"?b+="ui32":v==="[object Float32Array]"?b+="fl32":v==="[object Float64Array]"?b+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(b+z(g))}else if(v==="[object Blob]"){var I=new FileReader;I.onload=function(){var R="~~local_forage_type~"+a.type+"~"+z(this.result);u("__lfsc__:blob"+R)},I.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(R){console.error("Couldn't convert value into a JSON string: ",a),u(null,R)}}function J(a){if(a.substring(0,Z)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(L),v=a.substring(Z,L),g;if(v==="blob"&&W.test(u)){var b=u.match(W);g=b[1],u=u.substring(b[0].length)}var I=D(u);switch(v){case"arbf":return I;case"blob":return C([I],{type:g});case"si08":return new Int8Array(I);case"ui08":return new Uint8Array(I);case"uic8":return new Uint8ClampedArray(I);case"si16":return new Int16Array(I);case"ur16":return new Uint16Array(I);case"si32":return new Int32Array(I);case"ui32":return new Uint32Array(I);case"fl32":return new Float32Array(I);case"fl64":return new Float64Array(I);default:throw new Error("Unkown type: "+v)}}function m(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var g=a instanceof Date?new Date(a):a.constructor();try{for(var b=O(Object.keys(a)),I=b.next();!I.done;I=b.next()){var R=I.value;Object.prototype.hasOwnProperty.call(a,R)&&(a.isActiveClone=null,g[R]=m(a[R]),delete a.isActiveClone)}}catch(G){u={error:G}}finally{try{I&&!I.done&&(v=b.return)&&v.call(b)}finally{if(u)throw u.error}}return g}function w(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function T(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function F(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function $(a,u){var v=this;if(u=F.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var g=this.config();a.name=a.name||g.name,a.storeName=a.storeName||g.storeName}var b;return a.name?b=new Promise(function(I){a.storeName?I(w(a,v._defaultConfig)):I(a.name+"/")}):b=Promise.reject("Invalid arguments"),{promise:b,callback:u}}function P(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var k={bufferToString:z,deserialize:J,serialize:K,stringToBuffer:D},M={},ae=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return M[u]||(M[u]=new a(u)),M[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete M[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function re(a){var u=a?m(a):{},v=w(u,this._defaultConfig),g=ae.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=k,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=g,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return T(v,a),v}function A(a,u){var v=$.apply(this,arguments),g=v.promise,b=v.callback,I=g.then(function(R){ae.resolve(R).drop()});return T(I,b),g}function E(a,u){var v=this;a=P(a);var g=this.ready().then(function(){var b=v._dbInfo.mStore.get(a);return b==null?null:v._dbInfo.serializer.deserialize(b)});return T(g,u),g}function N(a,u){var v=this,g=this.ready().then(function(){for(var b=v._dbInfo.mStore,I=b.keys(),R=0;R<I.length;R++){var G=b.get(I[R]);if(G&&(G=v._dbInfo.serializer.deserialize(G)),G=a(G,I[R],R+1),G!==void 0)return G}});return T(g,u),g}function H(a,u){var v=this,g=this.ready().then(function(){var b;try{b=v._dbInfo.mStore.key(a),b===void 0&&(b=null)}catch{b=null}return b});return T(g,u),g}function j(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return T(v,a),v}function X(a){var u=this.keys().then(function(v){return v.length});return T(u,a),u}function Q(a,u){var v=this;a=P(a);var g=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return T(g,u),g}function ee(a,u,v){var g=this;a=P(a);var b=this.ready().then(function(){u===void 0&&(u=null);var I=u;return new Promise(function(R,G){g._dbInfo.serializer.serialize(u,function(fe,ie){if(ie)G(ie);else try{g._dbInfo.mStore.set(a,fe),R(I)}catch(ue){G(ue)}})})});return T(b,v),b}var oe=!0;_._support=oe,_._driver=y,_._initStorage=re,_.clear=h,_.dropInstance=A,_.getItem=E,_.iterate=N,_.key=H,_.keys=j,_.length=X,_.removeItem=Q,_.setItem=ee,Object.defineProperty(_,"__esModule",{value:!0})})});var pe=$e(qe()),Te=$e(er());import{SDKBase as ut,createSDK as ct}from"@magic-sdk/provider";import{createDuplicateIframeWarning as tt,createModalNotReadyError as nt,createURL as rr,ViewController as ot}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as it}from"@magic-sdk/types";var at={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function ft(_){for(let[y,O]of Object.entries(at))_.style[y]=O}function st(_){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(O=>O.src.includes(_))}var ye=class extends ot{activeElement=null;iframe;relayerSrc=rr(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(y=>{let O=()=>{if(st(encodeURIComponent(this.parameters)))tt().log();else{let C=document.createElement("iframe");C.classList.add("magic-iframe"),C.dataset.magicIframeLabel=rr(this.endpoint).host,C.title="Secure Modal",C.src=this.relayerSrc,C.allow="clipboard-read; clipboard-write",ft(C),document.body.appendChild(C),y(C)}};["loaded","interactive","complete"].includes(document.readyState)?O():window.addEventListener("load",O,!1)}),this.iframe.then(y=>{y instanceof HTMLIFrameElement&&y.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",y=>{if(y.origin===this.endpoint&&y.data.msgType&&(y.data.msgType.includes(it.MAGIC_PONG)&&(this.lastPongTime=Date.now()),y.data&&this.messageHandlers.size)){y.data.response=y.data.response??{},this.stopHeartBeat();for(let O of this.messageHandlers.values())O(y)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let y=await this.iframe;y.style.display="block",y.style.zIndex="2147483647",y.style.opacity="1",this.activeElement=document.activeElement,y.focus()}async hideOverlay(){let y=await this.iframe;y.style.display="none",y.style.zIndex="-1",y.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(y){let O=await this.iframe;if(O&&O.contentWindow)O.contentWindow.postMessage(y,this.endpoint);else throw nt()}async checkRelayerExistsInDOM(){let y=await this.iframe;return!y||!y.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(C=>C.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let y=await this.iframe;if(this.stopHeartBeat(),!y){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!y.contentWindow){document.body.appendChild(y),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}y&&(y.src=this.relayerSrc)}};export*from"@magic-sdk/provider";export*from"@magic-sdk/types";var wt=ct(ut,{platform:"web",sdkName:"magic-sdk",version:"31.2.0",defaultEndpoint:"https://auth.magic.link/",ViewController:ye,configureStorage:async()=>{let _=pe.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await _.defineDriver(Te),await _.setDriver([pe.default.INDEXEDDB,pe.default.LOCALSTORAGE,Te._driver]),_}});export{wt as Magic};
2
2
  //# sourceMappingURL=index.js.map
package/dist/es/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var $r=Object.create;var Qe=Object.defineProperty;var Zr=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var kr=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var de=(_=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(_,{get:(y,O)=>(typeof require<"u"?require:y)[O]}):_)(function(_){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+_+'" is not supported')});var Je=(_,y)=>()=>(y||_((y={exports:{}}).exports,y),y.exports);var rt=(_,y,O,C)=>{if(y&&typeof y=="object"||typeof y=="function")for(let W of qr(y))!et.call(_,W)&&W!==O&&Qe(_,W,{get:()=>y[W],enumerable:!(C=Zr(y,W))||C.enumerable});return _};var $e=(_,y,O)=>(O=_!=null?$r(kr(_)):{},rt(y||!_||!_.__esModule?Qe(O,"default",{value:_,enumerable:!0}):O,_));var qe=Je((Ze,De)=>{"use strict";(function(_){if(typeof Ze=="object"&&typeof De<"u")De.exports=_();else if(typeof define=="function"&&define.amd)define([],_);else{var y;typeof window<"u"?y=window:typeof global<"u"?y=global:typeof self<"u"?y=self:y=this,y.localforage=_()}})(function(){var _,y,O;return function C(W,Z,L){function V(K,J){if(!Z[K]){if(!W[K]){var m=typeof de=="function"&&de;if(!J&&m)return m(K,!0);if(D)return D(K,!0);var w=new Error("Cannot find module '"+K+"'");throw w.code="MODULE_NOT_FOUND",w}var T=Z[K]={exports:{}};W[K][0].call(T.exports,function(F){var $=W[K][1][F];return V($||F)},T,T.exports,C,W,Z,L)}return Z[K].exports}for(var D=typeof de=="function"&&de,z=0;z<L.length;z++)V(L[z]);return V}({1:[function(C,W,Z){(function(L){"use strict";var V=L.MutationObserver||L.WebKitMutationObserver,D;if(V){var z=0,K=new V(F),J=L.document.createTextNode("");K.observe(J,{characterData:!0}),D=function(){J.data=z=++z%2}}else if(!L.setImmediate&&typeof L.MessageChannel<"u"){var m=new L.MessageChannel;m.port1.onmessage=F,D=function(){m.port2.postMessage(0)}}else"document"in L&&"onreadystatechange"in L.document.createElement("script")?D=function(){var P=L.document.createElement("script");P.onreadystatechange=function(){F(),P.onreadystatechange=null,P.parentNode.removeChild(P),P=null},L.document.documentElement.appendChild(P)}:D=function(){setTimeout(F,0)};var w,T=[];function F(){w=!0;for(var P,k,M=T.length;M;){for(k=T,T=[],P=-1;++P<M;)k[P]();M=T.length}w=!1}W.exports=$;function $(P){T.push(P)===1&&!w&&D()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(C,W,Z){"use strict";var L=C(1);function V(){}var D={},z=["REJECTED"],K=["FULFILLED"],J=["PENDING"];W.exports=m;function m(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=J,this.queue=[],this.outcome=void 0,h!==V&&$(this,h)}m.prototype.catch=function(h){return this.then(null,h)},m.prototype.then=function(h,A){if(typeof h!="function"&&this.state===K||typeof A!="function"&&this.state===z)return this;var E=new this.constructor(V);if(this.state!==J){var N=this.state===K?h:A;T(E,N,this.outcome)}else this.queue.push(new w(E,h,A));return E};function w(h,A,E){this.promise=h,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(h){D.resolve(this.promise,h)},w.prototype.otherCallFulfilled=function(h){T(this.promise,this.onFulfilled,h)},w.prototype.callRejected=function(h){D.reject(this.promise,h)},w.prototype.otherCallRejected=function(h){T(this.promise,this.onRejected,h)};function T(h,A,E){L(function(){var N;try{N=A(E)}catch(H){return D.reject(h,H)}N===h?D.reject(h,new TypeError("Cannot resolve promise with itself")):D.resolve(h,N)})}D.resolve=function(h,A){var E=P(F,A);if(E.status==="error")return D.reject(h,E.value);var N=E.value;if(N)$(h,N);else{h.state=K,h.outcome=A;for(var H=-1,j=h.queue.length;++H<j;)h.queue[H].callFulfilled(A)}return h},D.reject=function(h,A){h.state=z,h.outcome=A;for(var E=-1,N=h.queue.length;++E<N;)h.queue[E].callRejected(A);return h};function F(h){var A=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof A=="function")return function(){A.apply(h,arguments)}}function $(h,A){var E=!1;function N(Q){E||(E=!0,D.reject(h,Q))}function H(Q){E||(E=!0,D.resolve(h,Q))}function j(){A(H,N)}var X=P(j);X.status==="error"&&N(X.value)}function P(h,A){var E={};try{E.value=h(A),E.status="success"}catch(N){E.status="error",E.value=N}return E}m.resolve=k;function k(h){return h instanceof this?h:D.resolve(new this(V),h)}m.reject=M;function M(h){var A=new this(V);return D.reject(A,h)}m.all=ae;function ae(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=new Array(E),j=0,X=-1,Q=new this(V);++X<E;)ee(h[X],X);return Q;function ee(oe,a){A.resolve(oe).then(u,function(v){N||(N=!0,D.reject(Q,v))});function u(v){H[a]=v,++j===E&&!N&&(N=!0,D.resolve(Q,H))}}}m.race=re;function re(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=-1,j=new this(V);++H<E;)X(h[H]);return j;function X(Q){A.resolve(Q).then(function(ee){N||(N=!0,D.resolve(j,ee))},function(ee){N||(N=!0,D.reject(j,ee))})}}},{1:1}],3:[function(C,W,Z){(function(L){"use strict";typeof L.Promise!="function"&&(L.Promise=C(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(C,W,Z){"use strict";var L=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function V(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var z=D();function K(){try{if(!z||!z.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function J(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new r,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(t.type)}}typeof Promise>"u"&&C(3);var m=Promise;function w(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function T(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function F(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function $(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var P="local-forage-detect-blob-support",k=void 0,M={},ae=Object.prototype.toString,re="readonly",h="readwrite";function A(e){for(var t=e.length,r=new ArrayBuffer(t),o=new Uint8Array(r),i=0;i<t;i++)o[i]=e.charCodeAt(i);return r}function E(e){return new m(function(t){var r=e.transaction(P,h),o=J([""]);r.objectStore(P).put(o,"key"),r.onabort=function(i){i.preventDefault(),i.stopPropagation(),t(!1)},r.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function N(e){return typeof k=="boolean"?m.resolve(k):E(e).then(function(t){return k=t,k})}function H(e){var t=M[e.name],r={};r.promise=new m(function(o,i){r.resolve=o,r.reject=i}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function j(e){var t=M[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function X(e,t){var r=M[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function Q(e,t){return new m(function(r,o){if(M[e.name]=M[e.name]||G(),e.db)if(t)H(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=z.open.apply(z,i);t&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(P)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),o(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},r(f),j(e)}})}function ee(e){return Q(e,!1)}function oe(e){return Q(e,!0)}function a(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=e.version>e.db.version;if(o&&(e.version!==t&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new m(function(t,r){var o=new FileReader;o.onerror=r,o.onloadend=function(i){var n=btoa(i.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function v(e){var t=A(atob(e.data));return J([t],{type:e.type})}function g(e){return e&&e.__local_forage_encoded_blob}function b(e){var t=this,r=t._initReady().then(function(){var o=M[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(r,e,e),r}function I(e){H(e);for(var t=M[e.name],r=t.forages,o=0;o<r.length;o++){var i=r[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,ee(e).then(function(n){return e.db=n,a(e)?oe(e):n}).then(function(n){e.db=t.db=n;for(var f=0;f<r.length;f++)r[f]._dbInfo.db=n}).catch(function(n){throw X(e,n),n})}function R(e,t,r,o){o===void 0&&(o=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return m.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),oe(e)}).then(function(){return I(e).then(function(){R(e,t,r,o-1)})}).catch(r);r(n)}}function G(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function fe(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=M[r.name];i||(i=G(),M[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=b);var n=[];function f(){return m.resolve()}for(var s=0;s<i.forages.length;s++){var c=i.forages[s];c!==t&&n.push(c._initReady().catch(f))}var l=i.forages.slice(0);return m.all(n).then(function(){return r.db=i.db,ee(r)}).then(function(d){return r.db=d,a(r,t._defaultConfig.version)?oe(r):d}).then(function(d){r.db=i.db=d,t._dbInfo=r;for(var p=0;p<l.length;p++){var S=l[p];S!==t&&(S._dbInfo.db=r.db,S._dbInfo.version=r.version)}})}function ie(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),g(d)&&(d=v(d)),i(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function ue(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var p=l.result;if(p){var S=p.value;g(S)&&(S=v(S));var B=e(S,p.key,d++);B!==void 0?i(B):p.continue()}else i()},l.onerror=function(){n(l.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function tr(e,t,r){var o=this;e=F(e);var i=new m(function(n,f){var s;o.ready().then(function(){return s=o._dbInfo,ae.call(t)==="[object Blob]"?N(s.db).then(function(c){return c?t:u(t)}):t}).then(function(c){R(o._dbInfo,h,function(l,d){if(l)return f(l);try{var p=d.objectStore(o._dbInfo.storeName);c===null&&(c=void 0);var S=p.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var B=S.error?S.error:S.transaction.error;f(B)}}catch(B){f(B)}})}).catch(f)});return w(i,r),i}function nr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){i()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function or(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,h,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.clear();f.oncomplete=function(){o()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;i(l)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.count();c.onsuccess=function(){o(c.result)},c.onerror=function(){i(c.error)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ar(e,t){var r=this,o=new m(function(i,n){if(e<0){i(null);return}r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var p=d.result;if(!p){i(null);return}e===0||l?i(p.key):(l=!0,p.advance(e))},d.onerror=function(){n(d.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function fr(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){o(l);return}l.push(d.key),d.continue()},c.onerror=function(){i(c.error)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function sr(e,t){t=$.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;if(!e.name)i=m.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,f=n?m.resolve(o._dbInfo.db):ee(e).then(function(s){var c=M[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?i=f.then(function(s){if(s.objectStoreNames.contains(e.storeName)){var c=s.version+1;H(e);var l=M[e.name],d=l.forages;s.close();for(var p=0;p<d.length;p++){var S=d[p];S._dbInfo.db=null,S._dbInfo.version=c}var B=new m(function(x,Y){var U=z.open(e.name,c);U.onerror=function(q){var le=U.result;le.close(),Y(q)},U.onupgradeneeded=function(){var q=U.result;q.deleteObjectStore(e.storeName)},U.onsuccess=function(){var q=U.result;q.close(),x(q)}});return B.then(function(x){l.db=x;for(var Y=0;Y<d.length;Y++){var U=d[Y];U._dbInfo.db=x,j(U._dbInfo)}}).catch(function(x){throw(X(e,x)||m.resolve()).catch(function(){}),x})}}):i=f.then(function(s){H(e);var c=M[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var p=l[d];p._dbInfo.db=null}var S=new m(function(B,x){var Y=z.deleteDatabase(e.name);Y.onerror=function(){var U=Y.result;U&&U.close(),x(Y.error)},Y.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},Y.onsuccess=function(){var U=Y.result;U&&U.close(),B(U)}});return S.then(function(B){c.db=B;for(var x=0;x<l.length;x++){var Y=l[x];j(Y._dbInfo)}}).catch(function(B){throw(X(e,B)||m.resolve()).catch(function(){}),B})})}return w(i,t),i}var ur={_driver:"asyncStorage",_initStorage:fe,_support:K(),iterate:ue,getItem:ie,setItem:tr,removeItem:nr,clear:or,length:ir,key:ar,keys:fr,dropInstance:sr};function cr(){return typeof openDatabase=="function"}var te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lr="~~local_forage_type~",Be=/^~~local_forage_type~([^~]+)~/,ve="__lfsc__:",ge=ve.length,be="arbf",_e="blob",Ne="si08",xe="ui08",Oe="uic8",Ce="si16",Le="si32",Pe="ur16",Me="ui32",Fe="fl32",Ue="fl64",We=ge+be.length,ze=Object.prototype.toString;function Ye(e){var t=e.length*.75,r=e.length,o,i=0,n,f,s,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var l=new ArrayBuffer(t),d=new Uint8Array(l);for(o=0;o<r;o+=4)n=te.indexOf(e[o]),f=te.indexOf(e[o+1]),s=te.indexOf(e[o+2]),c=te.indexOf(e[o+3]),d[i++]=n<<2|f>>4,d[i++]=(f&15)<<4|s>>2,d[i++]=(s&3)<<6|c&63;return l}function we(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=te[t[o]>>2],r+=te[(t[o]&3)<<4|t[o+1]>>4],r+=te[(t[o+1]&15)<<2|t[o+2]>>6],r+=te[t[o+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}function dr(e,t){var r="";if(e&&(r=ze.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&ze.call(e.buffer)==="[object ArrayBuffer]")){var o,i=ve;e instanceof ArrayBuffer?(o=e,i+=be):(o=e.buffer,r==="[object Int8Array]"?i+=Ne:r==="[object Uint8Array]"?i+=xe:r==="[object Uint8ClampedArray]"?i+=Oe:r==="[object Int16Array]"?i+=Ce:r==="[object Uint16Array]"?i+=Pe:r==="[object Int32Array]"?i+=Le:r==="[object Uint32Array]"?i+=Me:r==="[object Float32Array]"?i+=Fe:r==="[object Float64Array]"?i+=Ue:t(new Error("Failed to get type for BinaryArray"))),t(i+we(o))}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=lr+e.type+"~"+we(this.result);t(ve+_e+f)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),t(null,f)}}function vr(e){if(e.substring(0,ge)!==ve)return JSON.parse(e);var t=e.substring(We),r=e.substring(ge,We),o;if(r===_e&&Be.test(t)){var i=t.match(Be);o=i[1],t=t.substring(i[0].length)}var n=Ye(t);switch(r){case be:return n;case _e:return J([n],{type:o});case Ne:return new Int8Array(n);case xe:return new Uint8Array(n);case Oe:return new Uint8ClampedArray(n);case Ce:return new Int16Array(n);case Pe:return new Uint16Array(n);case Le:return new Int32Array(n);case Me:return new Uint32Array(n);case Fe:return new Float32Array(n);case Ue:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var Ie={serialize:dr,deserialize:vr,stringToBuffer:Ye,bufferToString:we};function Ke(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function hr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=typeof e[o]!="string"?e[o].toString():e[o];var i=new m(function(n,f){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(s){return f(s)}r.db.transaction(function(s){Ke(s,r,function(){t._dbInfo=r,n()},function(c,l){f(l)})},f)});return r.serializer=Ie,i}function ne(e,t,r,o,i,n){e.executeSql(r,o,i,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(c,l){l.rows.length?n(c,s):Ke(c,t,function(){c.executeSql(r,o,i,n)},n)},n):n(f,s)},n)}function mr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function yr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,p=d.length,S=0;S<p;S++){var B=d.item(S),x=B.value;if(x&&(x=f.serializer.deserialize(x)),x=e(x,B.key,S+1),x!==void 0){i(x);return}}i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function He(e,t,r,o){var i=this;e=F(e);var n=new m(function(f,s){i.ready().then(function(){t===void 0&&(t=null);var c=t,l=i._dbInfo;l.serializer.serialize(t,function(d,p){p?s(p):l.db.transaction(function(S){ne(S,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(B,x){s(x)})},function(S){if(S.code===S.QUOTA_ERR){if(o>0){f(He.apply(i,[e,c,r,o-1]));return}s(S)}})})}).catch(s)});return w(n,r),n}function pr(e,t,r){return He.apply(this,[e,t,r,1])}function gr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function br(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"DELETE FROM "+n.storeName,[],function(){o()},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function _r(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function wr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Er(e){return new m(function(t,r){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);t({db:e,storeNames:f})},function(i,n){r(n)})},function(o){r(o)})})}function Sr(e,t){t=$.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;return e.name?i=new m(function(n){var f;e.name===r.name?f=o._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Er(f))}).then(function(n){return new m(function(f,s){n.db.transaction(function(c){function l(B){return new m(function(x,Y){c.executeSql("DROP TABLE IF EXISTS "+B,[],function(){x()},function(U,q){Y(q)})})}for(var d=[],p=0,S=n.storeNames.length;p<S;p++)d.push(l(n.storeNames[p]));m.all(d).then(function(){f()}).catch(function(B){s(B)})},function(c){s(c)})})}):i=m.reject("Invalid arguments"),w(i,t),i}var Ar={_driver:"webSQLStorage",_initStorage:hr,_support:cr(),iterate:yr,getItem:mr,setItem:pr,removeItem:gr,clear:br,length:_r,key:wr,keys:Ir,dropInstance:Sr};function Rr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ve(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Dr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Tr(){return!Dr()||localStorage.length>0}function Br(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=Ve(e,t._defaultConfig),Tr()?(t._dbInfo=r,r.serializer=Ie,m.resolve()):m.reject()}function Nr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(o)===0&&localStorage.removeItem(n)}});return w(r,e),r}function xr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return w(o,t),o}function Or(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var p=localStorage.getItem(d);if(p&&(p=i.serializer.deserialize(p)),p=e(p,d.substring(f),c++),p!==void 0)return p}}});return w(o,t),o}function Cr(e,t){var r=this,o=r.ready().then(function(){var i=r._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return w(o,t),o}function Lr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],f=0;f<i;f++){var s=localStorage.key(f);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length))}return n});return w(r,e),r}function Pr(e){var t=this,r=t.keys().then(function(o){return o.length});return w(r,e),r}function Mr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return w(o,t),o}function Fr(e,t,r){var o=this;e=F(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new m(function(f,s){var c=o._dbInfo;c.serializer.serialize(t,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(p){(p.name==="QuotaExceededError"||p.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(p),s(p)}})})});return w(i,r),i}function Ur(e,t){if(t=$.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var o=this,i;return e.name?i=new m(function(n){e.storeName?n(Ve(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):i=m.reject("Invalid arguments"),w(i,t),i}var Wr={_driver:"localStorageWrapper",_initStorage:Br,_support:Rr(),iterate:Or,getItem:xr,setItem:Fr,removeItem:Mr,clear:Nr,length:Pr,key:Cr,keys:Lr,dropInstance:Ur},zr=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},Yr=function(t,r){for(var o=t.length,i=0;i<o;){if(zr(t[i],r))return!0;i++}return!1},Ge=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},ce={},je={},se={INDEXEDDB:ur,WEBSQL:Ar,LOCALSTORAGE:Wr},Kr=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],he=["dropInstance"],Ee=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(he),Hr={description:"",driver:Kr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Vr(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Se(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(Ge(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var Gr=function(){function e(t){V(this,e);for(var r in se)if(se.hasOwnProperty(r)){var o=se[r],i=o._driver;this[r]=i,ce[i]||this.defineDriver(o)}this._defaultConfig=Se({},Hr),this._config=Se({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(r){if((typeof r>"u"?"undefined":L(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in r){if(o==="storeName"&&(r[o]=r[o].replace(/\W/g,"_")),o==="version"&&typeof r[o]!="number")return new Error("Database version must be a number.");this._config[o]=r[o]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,o,i){var n=new m(function(f,s){try{var c=r._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){s(l);return}for(var d=Ee.concat("_initStorage"),p=0,S=d.length;p<S;p++){var B=d[p],x=!Yr(he,B);if((x||r[B])&&typeof r[B]!="function"){s(l);return}}var Y=function(){for(var le=function(Qr){return function(){var Jr=new Error("Method "+Qr+" is not implemented by the current driver"),Xe=m.reject(Jr);return w(Xe,arguments[arguments.length-1]),Xe}},Ae=0,Xr=he.length;Ae<Xr;Ae++){var Re=he[Ae];r[Re]||(r[Re]=le(Re))}};Y();var U=function(le){ce[c]&&console.info("Redefining LocalForage driver: "+c),ce[c]=r,je[c]=le,f()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(U,s):U(!!r._support):U(!0)}catch(q){s(q)}});return T(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=ce[r]?m.resolve(ce[r]):m.reject(new Error("Driver not found."));return T(n,o,i),n},e.prototype.getSerializer=function(r){var o=m.resolve(Ie);return T(o,r),o},e.prototype.ready=function(r){var o=this,i=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;Ge(r)||(r=[r]);var f=this._getSupportedDrivers(r);function s(){n._config.driver=n.driver()}function c(p){return n._extend(p),s(),n._ready=n._initStorage(n._config),n._ready}function l(p){return function(){var S=0;function B(){for(;S<p.length;){var x=p[S];return S++,n._dbInfo=null,n._ready=null,n.getDriver(x).then(c).catch(B)}s();var Y=new Error("No available storage method found.");return n._driverSet=m.reject(Y),n._driverSet}return B()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=d.then(function(){var p=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(p).then(function(S){n._driver=S._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var p=new Error("No available storage method found.");return n._driverSet=m.reject(p),n._driverSet}),T(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!je[r]},e.prototype._extend=function(r){Se(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var f=r[i];this.supports(f)&&o.push(f)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Ee.length;r<o;r++)Vr(this,Ee[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),jr=new Gr;W.exports=jr},{3:3}]},{},[4])(4)})});var er=Je((me,ke)=>{"use strict";(function(_,y){typeof me=="object"&&typeof ke<"u"?y(me):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],y):y(_.LocalforageDriverMemory={})})(typeof self<"u"?self:me,function(_){"use strict";var y="localforage-driver-memory";function O(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function C(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(I){if(I.name!=="TypeError")throw I;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,g=new v,b=0;b<a.length;b+=1)g.append(a[b]);return g.getBlob(u.type)}}var W=/^~~local_forage_type~([^~]+)~/,Z=9,L=Z+4,V=Object.prototype.toString;function D(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var g=new ArrayBuffer(u),b=new Uint8Array(g),I=0,R=0;I<v;I+=4){var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I]),fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+1]),ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+2]),ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+3]);b[R++]=G<<2|fe>>4,b[R++]=(fe&15)<<4|ie>>2,b[R++]=(ie&3)<<6|ue&63}return g}function z(a){for(var u=new Uint8Array(a),v="",g=0;g<u.length;g+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g]&3)<<4|u[g+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g+1]&15)<<2|u[g+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function K(a,u){var v="";if(a&&(v=V.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&V.call(a.buffer)==="[object ArrayBuffer]")){var g=void 0,b="__lfsc__:";a instanceof ArrayBuffer?(g=a,b+="arbf"):(g=a.buffer,v==="[object Int8Array]"?b+="si08":v==="[object Uint8Array]"?b+="ui08":v==="[object Uint8ClampedArray]"?b+="uic8":v==="[object Int16Array]"?b+="si16":v==="[object Uint16Array]"?b+="ur16":v==="[object Int32Array]"?b+="si32":v==="[object Uint32Array]"?b+="ui32":v==="[object Float32Array]"?b+="fl32":v==="[object Float64Array]"?b+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(b+z(g))}else if(v==="[object Blob]"){var I=new FileReader;I.onload=function(){var R="~~local_forage_type~"+a.type+"~"+z(this.result);u("__lfsc__:blob"+R)},I.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(R){console.error("Couldn't convert value into a JSON string: ",a),u(null,R)}}function J(a){if(a.substring(0,Z)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(L),v=a.substring(Z,L),g;if(v==="blob"&&W.test(u)){var b=u.match(W);g=b[1],u=u.substring(b[0].length)}var I=D(u);switch(v){case"arbf":return I;case"blob":return C([I],{type:g});case"si08":return new Int8Array(I);case"ui08":return new Uint8Array(I);case"uic8":return new Uint8ClampedArray(I);case"si16":return new Int16Array(I);case"ur16":return new Uint16Array(I);case"si32":return new Int32Array(I);case"ui32":return new Uint32Array(I);case"fl32":return new Float32Array(I);case"fl64":return new Float64Array(I);default:throw new Error("Unkown type: "+v)}}function m(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var g=a instanceof Date?new Date(a):a.constructor();try{for(var b=O(Object.keys(a)),I=b.next();!I.done;I=b.next()){var R=I.value;Object.prototype.hasOwnProperty.call(a,R)&&(a.isActiveClone=null,g[R]=m(a[R]),delete a.isActiveClone)}}catch(G){u={error:G}}finally{try{I&&!I.done&&(v=b.return)&&v.call(b)}finally{if(u)throw u.error}}return g}function w(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function T(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function F(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function $(a,u){var v=this;if(u=F.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var g=this.config();a.name=a.name||g.name,a.storeName=a.storeName||g.storeName}var b;return a.name?b=new Promise(function(I){a.storeName?I(w(a,v._defaultConfig)):I(a.name+"/")}):b=Promise.reject("Invalid arguments"),{promise:b,callback:u}}function P(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var k={bufferToString:z,deserialize:J,serialize:K,stringToBuffer:D},M={},ae=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return M[u]||(M[u]=new a(u)),M[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete M[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function re(a){var u=a?m(a):{},v=w(u,this._defaultConfig),g=ae.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=k,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=g,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return T(v,a),v}function A(a,u){var v=$.apply(this,arguments),g=v.promise,b=v.callback,I=g.then(function(R){ae.resolve(R).drop()});return T(I,b),g}function E(a,u){var v=this;a=P(a);var g=this.ready().then(function(){var b=v._dbInfo.mStore.get(a);return b==null?null:v._dbInfo.serializer.deserialize(b)});return T(g,u),g}function N(a,u){var v=this,g=this.ready().then(function(){for(var b=v._dbInfo.mStore,I=b.keys(),R=0;R<I.length;R++){var G=b.get(I[R]);if(G&&(G=v._dbInfo.serializer.deserialize(G)),G=a(G,I[R],R+1),G!==void 0)return G}});return T(g,u),g}function H(a,u){var v=this,g=this.ready().then(function(){var b;try{b=v._dbInfo.mStore.key(a),b===void 0&&(b=null)}catch{b=null}return b});return T(g,u),g}function j(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return T(v,a),v}function X(a){var u=this.keys().then(function(v){return v.length});return T(u,a),u}function Q(a,u){var v=this;a=P(a);var g=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return T(g,u),g}function ee(a,u,v){var g=this;a=P(a);var b=this.ready().then(function(){u===void 0&&(u=null);var I=u;return new Promise(function(R,G){g._dbInfo.serializer.serialize(u,function(fe,ie){if(ie)G(ie);else try{g._dbInfo.mStore.set(a,fe),R(I)}catch(ue){G(ue)}})})});return T(b,v),b}var oe=!0;_._support=oe,_._driver=y,_._initStorage=re,_.clear=h,_.dropInstance=A,_.getItem=E,_.iterate=N,_.key=H,_.keys=j,_.length=X,_.removeItem=Q,_.setItem=ee,Object.defineProperty(_,"__esModule",{value:!0})})});var pe=$e(qe()),Te=$e(er());import{SDKBase as ut,createSDK as ct}from"@magic-sdk/provider";import{createDuplicateIframeWarning as tt,createModalNotReadyError as nt,createURL as rr,ViewController as ot}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as it}from"@magic-sdk/types";var at={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function ft(_){for(let[y,O]of Object.entries(at))_.style[y]=O}function st(_){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(O=>O.src.includes(_))}var ye=class extends ot{activeElement=null;iframe;relayerSrc=rr(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(y=>{let O=()=>{if(st(encodeURIComponent(this.parameters)))tt().log();else{let C=document.createElement("iframe");C.classList.add("magic-iframe"),C.dataset.magicIframeLabel=rr(this.endpoint).host,C.title="Secure Modal",C.src=this.relayerSrc,C.allow="clipboard-read; clipboard-write",ft(C),document.body.appendChild(C),y(C)}};["loaded","interactive","complete"].includes(document.readyState)?O():window.addEventListener("load",O,!1)}),this.iframe.then(y=>{y instanceof HTMLIFrameElement&&y.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",y=>{if(y.origin===this.endpoint&&y.data.msgType&&(y.data.msgType.includes(it.MAGIC_PONG)&&(this.lastPongTime=Date.now()),y.data&&this.messageHandlers.size)){y.data.response=y.data.response??{},this.stopHeartBeat();for(let O of this.messageHandlers.values())O(y)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let y=await this.iframe;y.style.display="block",y.style.zIndex="2147483647",y.style.opacity="1",this.activeElement=document.activeElement,y.focus()}async hideOverlay(){let y=await this.iframe;y.style.display="none",y.style.zIndex="-1",y.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(y){let O=await this.iframe;if(O&&O.contentWindow)O.contentWindow.postMessage(y,this.endpoint);else throw nt()}async checkRelayerExistsInDOM(){let y=await this.iframe;return!y||!y.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(C=>C.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let y=await this.iframe;if(this.stopHeartBeat(),!y){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!y.contentWindow){document.body.appendChild(y),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}y&&(y.src=this.relayerSrc)}};export*from"@magic-sdk/provider";export*from"@magic-sdk/types";var wt=ct(ut,{platform:"web",sdkName:"magic-sdk",version:"31.1.0",defaultEndpoint:"https://auth.magic.link/",ViewController:ye,configureStorage:async()=>{let _=pe.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await _.defineDriver(Te),await _.setDriver([pe.default.INDEXEDDB,pe.default.LOCALSTORAGE,Te._driver]),_}});export{wt as Magic};
1
+ var $r=Object.create;var Qe=Object.defineProperty;var Zr=Object.getOwnPropertyDescriptor;var qr=Object.getOwnPropertyNames;var kr=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var de=(_=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(_,{get:(y,O)=>(typeof require<"u"?require:y)[O]}):_)(function(_){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+_+'" is not supported')});var Je=(_,y)=>()=>(y||_((y={exports:{}}).exports,y),y.exports);var rt=(_,y,O,C)=>{if(y&&typeof y=="object"||typeof y=="function")for(let W of qr(y))!et.call(_,W)&&W!==O&&Qe(_,W,{get:()=>y[W],enumerable:!(C=Zr(y,W))||C.enumerable});return _};var $e=(_,y,O)=>(O=_!=null?$r(kr(_)):{},rt(y||!_||!_.__esModule?Qe(O,"default",{value:_,enumerable:!0}):O,_));var qe=Je((Ze,De)=>{"use strict";(function(_){if(typeof Ze=="object"&&typeof De<"u")De.exports=_();else if(typeof define=="function"&&define.amd)define([],_);else{var y;typeof window<"u"?y=window:typeof global<"u"?y=global:typeof self<"u"?y=self:y=this,y.localforage=_()}})(function(){var _,y,O;return function C(W,Z,L){function V(K,J){if(!Z[K]){if(!W[K]){var m=typeof de=="function"&&de;if(!J&&m)return m(K,!0);if(D)return D(K,!0);var w=new Error("Cannot find module '"+K+"'");throw w.code="MODULE_NOT_FOUND",w}var T=Z[K]={exports:{}};W[K][0].call(T.exports,function(F){var $=W[K][1][F];return V($||F)},T,T.exports,C,W,Z,L)}return Z[K].exports}for(var D=typeof de=="function"&&de,z=0;z<L.length;z++)V(L[z]);return V}({1:[function(C,W,Z){(function(L){"use strict";var V=L.MutationObserver||L.WebKitMutationObserver,D;if(V){var z=0,K=new V(F),J=L.document.createTextNode("");K.observe(J,{characterData:!0}),D=function(){J.data=z=++z%2}}else if(!L.setImmediate&&typeof L.MessageChannel<"u"){var m=new L.MessageChannel;m.port1.onmessage=F,D=function(){m.port2.postMessage(0)}}else"document"in L&&"onreadystatechange"in L.document.createElement("script")?D=function(){var P=L.document.createElement("script");P.onreadystatechange=function(){F(),P.onreadystatechange=null,P.parentNode.removeChild(P),P=null},L.document.documentElement.appendChild(P)}:D=function(){setTimeout(F,0)};var w,T=[];function F(){w=!0;for(var P,k,M=T.length;M;){for(k=T,T=[],P=-1;++P<M;)k[P]();M=T.length}w=!1}W.exports=$;function $(P){T.push(P)===1&&!w&&D()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(C,W,Z){"use strict";var L=C(1);function V(){}var D={},z=["REJECTED"],K=["FULFILLED"],J=["PENDING"];W.exports=m;function m(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=J,this.queue=[],this.outcome=void 0,h!==V&&$(this,h)}m.prototype.catch=function(h){return this.then(null,h)},m.prototype.then=function(h,A){if(typeof h!="function"&&this.state===K||typeof A!="function"&&this.state===z)return this;var E=new this.constructor(V);if(this.state!==J){var N=this.state===K?h:A;T(E,N,this.outcome)}else this.queue.push(new w(E,h,A));return E};function w(h,A,E){this.promise=h,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(h){D.resolve(this.promise,h)},w.prototype.otherCallFulfilled=function(h){T(this.promise,this.onFulfilled,h)},w.prototype.callRejected=function(h){D.reject(this.promise,h)},w.prototype.otherCallRejected=function(h){T(this.promise,this.onRejected,h)};function T(h,A,E){L(function(){var N;try{N=A(E)}catch(H){return D.reject(h,H)}N===h?D.reject(h,new TypeError("Cannot resolve promise with itself")):D.resolve(h,N)})}D.resolve=function(h,A){var E=P(F,A);if(E.status==="error")return D.reject(h,E.value);var N=E.value;if(N)$(h,N);else{h.state=K,h.outcome=A;for(var H=-1,j=h.queue.length;++H<j;)h.queue[H].callFulfilled(A)}return h},D.reject=function(h,A){h.state=z,h.outcome=A;for(var E=-1,N=h.queue.length;++E<N;)h.queue[E].callRejected(A);return h};function F(h){var A=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof A=="function")return function(){A.apply(h,arguments)}}function $(h,A){var E=!1;function N(Q){E||(E=!0,D.reject(h,Q))}function H(Q){E||(E=!0,D.resolve(h,Q))}function j(){A(H,N)}var X=P(j);X.status==="error"&&N(X.value)}function P(h,A){var E={};try{E.value=h(A),E.status="success"}catch(N){E.status="error",E.value=N}return E}m.resolve=k;function k(h){return h instanceof this?h:D.resolve(new this(V),h)}m.reject=M;function M(h){var A=new this(V);return D.reject(A,h)}m.all=ae;function ae(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=new Array(E),j=0,X=-1,Q=new this(V);++X<E;)ee(h[X],X);return Q;function ee(oe,a){A.resolve(oe).then(u,function(v){N||(N=!0,D.reject(Q,v))});function u(v){H[a]=v,++j===E&&!N&&(N=!0,D.resolve(Q,H))}}}m.race=re;function re(h){var A=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,N=!1;if(!E)return this.resolve([]);for(var H=-1,j=new this(V);++H<E;)X(h[H]);return j;function X(Q){A.resolve(Q).then(function(ee){N||(N=!0,D.resolve(j,ee))},function(ee){N||(N=!0,D.reject(j,ee))})}}},{1:1}],3:[function(C,W,Z){(function(L){"use strict";typeof L.Promise!="function"&&(L.Promise=C(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(C,W,Z){"use strict";var L=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function V(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(){try{if(typeof indexedDB<"u")return indexedDB;if(typeof webkitIndexedDB<"u")return webkitIndexedDB;if(typeof mozIndexedDB<"u")return mozIndexedDB;if(typeof OIndexedDB<"u")return OIndexedDB;if(typeof msIndexedDB<"u")return msIndexedDB}catch{return}}var z=D();function K(){try{if(!z||!z.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),t=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||t)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function J(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(n){if(n.name!=="TypeError")throw n;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new r,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(t.type)}}typeof Promise>"u"&&C(3);var m=Promise;function w(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function T(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function F(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function $(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var P="local-forage-detect-blob-support",k=void 0,M={},ae=Object.prototype.toString,re="readonly",h="readwrite";function A(e){for(var t=e.length,r=new ArrayBuffer(t),o=new Uint8Array(r),i=0;i<t;i++)o[i]=e.charCodeAt(i);return r}function E(e){return new m(function(t){var r=e.transaction(P,h),o=J([""]);r.objectStore(P).put(o,"key"),r.onabort=function(i){i.preventDefault(),i.stopPropagation(),t(!1)},r.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);t(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function N(e){return typeof k=="boolean"?m.resolve(k):E(e).then(function(t){return k=t,k})}function H(e){var t=M[e.name],r={};r.promise=new m(function(o,i){r.resolve=o,r.reject=i}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function j(e){var t=M[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function X(e,t){var r=M[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function Q(e,t){return new m(function(r,o){if(M[e.name]=M[e.name]||G(),e.db)if(t)H(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=z.open.apply(z,i);t&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(P)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),o(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},r(f),j(e)}})}function ee(e){return Q(e,!1)}function oe(e){return Q(e,!0)}function a(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=e.version>e.db.version;if(o&&(e.version!==t&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),i||r){if(r){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new m(function(t,r){var o=new FileReader;o.onerror=r,o.onloadend=function(i){var n=btoa(i.target.result||"");t({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function v(e){var t=A(atob(e.data));return J([t],{type:e.type})}function g(e){return e&&e.__local_forage_encoded_blob}function b(e){var t=this,r=t._initReady().then(function(){var o=M[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(r,e,e),r}function I(e){H(e);for(var t=M[e.name],r=t.forages,o=0;o<r.length;o++){var i=r[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,ee(e).then(function(n){return e.db=n,a(e)?oe(e):n}).then(function(n){e.db=t.db=n;for(var f=0;f<r.length;f++)r[f]._dbInfo.db=n}).catch(function(n){throw X(e,n),n})}function R(e,t,r,o){o===void 0&&(o=1);try{var i=e.db.transaction(e.storeName,t);r(null,i)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return m.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),oe(e)}).then(function(){return I(e).then(function(){R(e,t,r,o-1)})}).catch(r);r(n)}}function G(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function fe(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=M[r.name];i||(i=G(),M[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=b);var n=[];function f(){return m.resolve()}for(var s=0;s<i.forages.length;s++){var c=i.forages[s];c!==t&&n.push(c._initReady().catch(f))}var l=i.forages.slice(0);return m.all(n).then(function(){return r.db=i.db,ee(r)}).then(function(d){return r.db=d,a(r,t._defaultConfig.version)?oe(r):d}).then(function(d){r.db=i.db=d,t._dbInfo=r;for(var p=0;p<l.length;p++){var S=l[p];S!==t&&(S._dbInfo.db=r.db,S._dbInfo.version=r.version)}})}function ie(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),g(d)&&(d=v(d)),i(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function ue(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var p=l.result;if(p){var S=p.value;g(S)&&(S=v(S));var B=e(S,p.key,d++);B!==void 0?i(B):p.continue()}else i()},l.onerror=function(){n(l.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function tr(e,t,r){var o=this;e=F(e);var i=new m(function(n,f){var s;o.ready().then(function(){return s=o._dbInfo,ae.call(t)==="[object Blob]"?N(s.db).then(function(c){return c?t:u(t)}):t}).then(function(c){R(o._dbInfo,h,function(l,d){if(l)return f(l);try{var p=d.objectStore(o._dbInfo.storeName);c===null&&(c=void 0);var S=p.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var B=S.error?S.error:S.transaction.error;f(B)}}catch(B){f(B)}})}).catch(f)});return w(i,r),i}function nr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){R(r._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){i()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return w(o,t),o}function or(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,h,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.clear();f.oncomplete=function(){o()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;i(l)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.count();c.onsuccess=function(){o(c.result)},c.onerror=function(){i(c.error)}}catch(l){i(l)}})}).catch(i)});return w(r,e),r}function ar(e,t){var r=this,o=new m(function(i,n){if(e<0){i(null);return}r.ready().then(function(){R(r._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(r._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var p=d.result;if(!p){i(null);return}e===0||l?i(p.key):(l=!0,p.advance(e))},d.onerror=function(){n(d.error)}}catch(p){n(p)}})}).catch(n)});return w(o,t),o}function fr(e){var t=this,r=new m(function(o,i){t.ready().then(function(){R(t._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(t._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){o(l);return}l.push(d.key),d.continue()},c.onerror=function(){i(c.error)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function sr(e,t){t=$.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;if(!e.name)i=m.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,f=n?m.resolve(o._dbInfo.db):ee(e).then(function(s){var c=M[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?i=f.then(function(s){if(s.objectStoreNames.contains(e.storeName)){var c=s.version+1;H(e);var l=M[e.name],d=l.forages;s.close();for(var p=0;p<d.length;p++){var S=d[p];S._dbInfo.db=null,S._dbInfo.version=c}var B=new m(function(x,Y){var U=z.open(e.name,c);U.onerror=function(q){var le=U.result;le.close(),Y(q)},U.onupgradeneeded=function(){var q=U.result;q.deleteObjectStore(e.storeName)},U.onsuccess=function(){var q=U.result;q.close(),x(q)}});return B.then(function(x){l.db=x;for(var Y=0;Y<d.length;Y++){var U=d[Y];U._dbInfo.db=x,j(U._dbInfo)}}).catch(function(x){throw(X(e,x)||m.resolve()).catch(function(){}),x})}}):i=f.then(function(s){H(e);var c=M[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var p=l[d];p._dbInfo.db=null}var S=new m(function(B,x){var Y=z.deleteDatabase(e.name);Y.onerror=function(){var U=Y.result;U&&U.close(),x(Y.error)},Y.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},Y.onsuccess=function(){var U=Y.result;U&&U.close(),B(U)}});return S.then(function(B){c.db=B;for(var x=0;x<l.length;x++){var Y=l[x];j(Y._dbInfo)}}).catch(function(B){throw(X(e,B)||m.resolve()).catch(function(){}),B})})}return w(i,t),i}var ur={_driver:"asyncStorage",_initStorage:fe,_support:K(),iterate:ue,getItem:ie,setItem:tr,removeItem:nr,clear:or,length:ir,key:ar,keys:fr,dropInstance:sr};function cr(){return typeof openDatabase=="function"}var te="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",lr="~~local_forage_type~",Be=/^~~local_forage_type~([^~]+)~/,ve="__lfsc__:",ge=ve.length,be="arbf",_e="blob",Ne="si08",xe="ui08",Oe="uic8",Ce="si16",Le="si32",Pe="ur16",Me="ui32",Fe="fl32",Ue="fl64",We=ge+be.length,ze=Object.prototype.toString;function Ye(e){var t=e.length*.75,r=e.length,o,i=0,n,f,s,c;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var l=new ArrayBuffer(t),d=new Uint8Array(l);for(o=0;o<r;o+=4)n=te.indexOf(e[o]),f=te.indexOf(e[o+1]),s=te.indexOf(e[o+2]),c=te.indexOf(e[o+3]),d[i++]=n<<2|f>>4,d[i++]=(f&15)<<4|s>>2,d[i++]=(s&3)<<6|c&63;return l}function we(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=te[t[o]>>2],r+=te[(t[o]&3)<<4|t[o+1]>>4],r+=te[(t[o+1]&15)<<2|t[o+2]>>6],r+=te[t[o+2]&63];return t.length%3===2?r=r.substring(0,r.length-1)+"=":t.length%3===1&&(r=r.substring(0,r.length-2)+"=="),r}function dr(e,t){var r="";if(e&&(r=ze.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&ze.call(e.buffer)==="[object ArrayBuffer]")){var o,i=ve;e instanceof ArrayBuffer?(o=e,i+=be):(o=e.buffer,r==="[object Int8Array]"?i+=Ne:r==="[object Uint8Array]"?i+=xe:r==="[object Uint8ClampedArray]"?i+=Oe:r==="[object Int16Array]"?i+=Ce:r==="[object Uint16Array]"?i+=Pe:r==="[object Int32Array]"?i+=Le:r==="[object Uint32Array]"?i+=Me:r==="[object Float32Array]"?i+=Fe:r==="[object Float64Array]"?i+=Ue:t(new Error("Failed to get type for BinaryArray"))),t(i+we(o))}else if(r==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=lr+e.type+"~"+we(this.result);t(ve+_e+f)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),t(null,f)}}function vr(e){if(e.substring(0,ge)!==ve)return JSON.parse(e);var t=e.substring(We),r=e.substring(ge,We),o;if(r===_e&&Be.test(t)){var i=t.match(Be);o=i[1],t=t.substring(i[0].length)}var n=Ye(t);switch(r){case be:return n;case _e:return J([n],{type:o});case Ne:return new Int8Array(n);case xe:return new Uint8Array(n);case Oe:return new Uint8ClampedArray(n);case Ce:return new Int16Array(n);case Pe:return new Uint16Array(n);case Le:return new Int32Array(n);case Me:return new Uint32Array(n);case Fe:return new Float32Array(n);case Ue:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var Ie={serialize:dr,deserialize:vr,stringToBuffer:Ye,bufferToString:we};function Ke(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function hr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=typeof e[o]!="string"?e[o].toString():e[o];var i=new m(function(n,f){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(s){return f(s)}r.db.transaction(function(s){Ke(s,r,function(){t._dbInfo=r,n()},function(c,l){f(l)})},f)});return r.serializer=Ie,i}function ne(e,t,r,o,i,n){e.executeSql(r,o,i,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(c,l){l.rows.length?n(c,s):Ke(c,t,function(){c.executeSql(r,o,i,n)},n)},n):n(f,s)},n)}function mr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function yr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,p=d.length,S=0;S<p;S++){var B=d.item(S),x=B.value;if(x&&(x=f.serializer.deserialize(x)),x=e(x,B.key,S+1),x!==void 0){i(x);return}}i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function He(e,t,r,o){var i=this;e=F(e);var n=new m(function(f,s){i.ready().then(function(){t===void 0&&(t=null);var c=t,l=i._dbInfo;l.serializer.serialize(t,function(d,p){p?s(p):l.db.transaction(function(S){ne(S,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(B,x){s(x)})},function(S){if(S.code===S.QUOTA_ERR){if(o>0){f(He.apply(i,[e,c,r,o-1]));return}s(S)}})})}).catch(s)});return w(n,r),n}function pr(e,t,r){return He.apply(this,[e,t,r,1])}function gr(e,t){var r=this;e=F(e);var o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){i()},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function br(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"DELETE FROM "+n.storeName,[],function(){o()},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function _r(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function wr(e,t){var r=this,o=new m(function(i,n){r.ready().then(function(){var f=r._dbInfo;f.db.transaction(function(s){ne(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;i(d)},function(c,l){n(l)})})}).catch(n)});return w(o,t),o}function Ir(e){var t=this,r=new m(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(f){ne(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);o(l)},function(s,c){i(c)})})}).catch(i)});return w(r,e),r}function Er(e){return new m(function(t,r){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);t({db:e,storeNames:f})},function(i,n){r(n)})},function(o){r(o)})})}function Sr(e,t){t=$.apply(this,arguments);var r=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||r.name,e.storeName=e.storeName||r.storeName);var o=this,i;return e.name?i=new m(function(n){var f;e.name===r.name?f=o._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Er(f))}).then(function(n){return new m(function(f,s){n.db.transaction(function(c){function l(B){return new m(function(x,Y){c.executeSql("DROP TABLE IF EXISTS "+B,[],function(){x()},function(U,q){Y(q)})})}for(var d=[],p=0,S=n.storeNames.length;p<S;p++)d.push(l(n.storeNames[p]));m.all(d).then(function(){f()}).catch(function(B){s(B)})},function(c){s(c)})})}):i=m.reject("Invalid arguments"),w(i,t),i}var Ar={_driver:"webSQLStorage",_initStorage:hr,_support:cr(),iterate:yr,getItem:mr,setItem:pr,removeItem:gr,clear:br,length:_r,key:wr,keys:Ir,dropInstance:Sr};function Rr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ve(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Dr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Tr(){return!Dr()||localStorage.length>0}function Br(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=Ve(e,t._defaultConfig),Tr()?(t._dbInfo=r,r.serializer=Ie,m.resolve()):m.reject()}function Nr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(o)===0&&localStorage.removeItem(n)}});return w(r,e),r}function xr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return w(o,t),o}function Or(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var p=localStorage.getItem(d);if(p&&(p=i.serializer.deserialize(p)),p=e(p,d.substring(f),c++),p!==void 0)return p}}});return w(o,t),o}function Cr(e,t){var r=this,o=r.ready().then(function(){var i=r._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return w(o,t),o}function Lr(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],f=0;f<i;f++){var s=localStorage.key(f);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length))}return n});return w(r,e),r}function Pr(e){var t=this,r=t.keys().then(function(o){return o.length});return w(r,e),r}function Mr(e,t){var r=this;e=F(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return w(o,t),o}function Fr(e,t,r){var o=this;e=F(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new m(function(f,s){var c=o._dbInfo;c.serializer.serialize(t,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(p){(p.name==="QuotaExceededError"||p.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(p),s(p)}})})});return w(i,r),i}function Ur(e,t){if(t=$.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var r=this.config();e.name=e.name||r.name,e.storeName=e.storeName||r.storeName}var o=this,i;return e.name?i=new m(function(n){e.storeName?n(Ve(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):i=m.reject("Invalid arguments"),w(i,t),i}var Wr={_driver:"localStorageWrapper",_initStorage:Br,_support:Rr(),iterate:Or,getItem:xr,setItem:Fr,removeItem:Mr,clear:Nr,length:Pr,key:Cr,keys:Lr,dropInstance:Ur},zr=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},Yr=function(t,r){for(var o=t.length,i=0;i<o;){if(zr(t[i],r))return!0;i++}return!1},Ge=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},ce={},je={},se={INDEXEDDB:ur,WEBSQL:Ar,LOCALSTORAGE:Wr},Kr=[se.INDEXEDDB._driver,se.WEBSQL._driver,se.LOCALSTORAGE._driver],he=["dropInstance"],Ee=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(he),Hr={description:"",driver:Kr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Vr(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Se(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(Ge(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var Gr=function(){function e(t){V(this,e);for(var r in se)if(se.hasOwnProperty(r)){var o=se[r],i=o._driver;this[r]=i,ce[i]||this.defineDriver(o)}this._defaultConfig=Se({},Hr),this._config=Se({},this._defaultConfig,t),this._driverSet=null,this._initDriver=null,this._ready=!1,this._dbInfo=null,this._wrapLibraryMethodsWithReady(),this.setDriver(this._config.driver).catch(function(){})}return e.prototype.config=function(r){if((typeof r>"u"?"undefined":L(r))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in r){if(o==="storeName"&&(r[o]=r[o].replace(/\W/g,"_")),o==="version"&&typeof r[o]!="number")return new Error("Database version must be a number.");this._config[o]=r[o]}return"driver"in r&&r.driver?this.setDriver(this._config.driver):!0}else return typeof r=="string"?this._config[r]:this._config},e.prototype.defineDriver=function(r,o,i){var n=new m(function(f,s){try{var c=r._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){s(l);return}for(var d=Ee.concat("_initStorage"),p=0,S=d.length;p<S;p++){var B=d[p],x=!Yr(he,B);if((x||r[B])&&typeof r[B]!="function"){s(l);return}}var Y=function(){for(var le=function(Qr){return function(){var Jr=new Error("Method "+Qr+" is not implemented by the current driver"),Xe=m.reject(Jr);return w(Xe,arguments[arguments.length-1]),Xe}},Ae=0,Xr=he.length;Ae<Xr;Ae++){var Re=he[Ae];r[Re]||(r[Re]=le(Re))}};Y();var U=function(le){ce[c]&&console.info("Redefining LocalForage driver: "+c),ce[c]=r,je[c]=le,f()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(U,s):U(!!r._support):U(!0)}catch(q){s(q)}});return T(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=ce[r]?m.resolve(ce[r]):m.reject(new Error("Driver not found."));return T(n,o,i),n},e.prototype.getSerializer=function(r){var o=m.resolve(Ie);return T(o,r),o},e.prototype.ready=function(r){var o=this,i=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;Ge(r)||(r=[r]);var f=this._getSupportedDrivers(r);function s(){n._config.driver=n.driver()}function c(p){return n._extend(p),s(),n._ready=n._initStorage(n._config),n._ready}function l(p){return function(){var S=0;function B(){for(;S<p.length;){var x=p[S];return S++,n._dbInfo=null,n._ready=null,n.getDriver(x).then(c).catch(B)}s();var Y=new Error("No available storage method found.");return n._driverSet=m.reject(Y),n._driverSet}return B()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=d.then(function(){var p=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(p).then(function(S){n._driver=S._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var p=new Error("No available storage method found.");return n._driverSet=m.reject(p),n._driverSet}),T(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!je[r]},e.prototype._extend=function(r){Se(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var f=r[i];this.supports(f)&&o.push(f)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Ee.length;r<o;r++)Vr(this,Ee[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),jr=new Gr;W.exports=jr},{3:3}]},{},[4])(4)})});var er=Je((me,ke)=>{"use strict";(function(_,y){typeof me=="object"&&typeof ke<"u"?y(me):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],y):y(_.LocalforageDriverMemory={})})(typeof self<"u"?self:me,function(_){"use strict";var y="localforage-driver-memory";function O(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function C(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(I){if(I.name!=="TypeError")throw I;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,g=new v,b=0;b<a.length;b+=1)g.append(a[b]);return g.getBlob(u.type)}}var W=/^~~local_forage_type~([^~]+)~/,Z=9,L=Z+4,V=Object.prototype.toString;function D(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var g=new ArrayBuffer(u),b=new Uint8Array(g),I=0,R=0;I<v;I+=4){var G="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I]),fe="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+1]),ie="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+2]),ue="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[I+3]);b[R++]=G<<2|fe>>4,b[R++]=(fe&15)<<4|ie>>2,b[R++]=(ie&3)<<6|ue&63}return g}function z(a){for(var u=new Uint8Array(a),v="",g=0;g<u.length;g+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g]&3)<<4|u[g+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g+1]&15)<<2|u[g+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function K(a,u){var v="";if(a&&(v=V.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&V.call(a.buffer)==="[object ArrayBuffer]")){var g=void 0,b="__lfsc__:";a instanceof ArrayBuffer?(g=a,b+="arbf"):(g=a.buffer,v==="[object Int8Array]"?b+="si08":v==="[object Uint8Array]"?b+="ui08":v==="[object Uint8ClampedArray]"?b+="uic8":v==="[object Int16Array]"?b+="si16":v==="[object Uint16Array]"?b+="ur16":v==="[object Int32Array]"?b+="si32":v==="[object Uint32Array]"?b+="ui32":v==="[object Float32Array]"?b+="fl32":v==="[object Float64Array]"?b+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(b+z(g))}else if(v==="[object Blob]"){var I=new FileReader;I.onload=function(){var R="~~local_forage_type~"+a.type+"~"+z(this.result);u("__lfsc__:blob"+R)},I.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(R){console.error("Couldn't convert value into a JSON string: ",a),u(null,R)}}function J(a){if(a.substring(0,Z)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(L),v=a.substring(Z,L),g;if(v==="blob"&&W.test(u)){var b=u.match(W);g=b[1],u=u.substring(b[0].length)}var I=D(u);switch(v){case"arbf":return I;case"blob":return C([I],{type:g});case"si08":return new Int8Array(I);case"ui08":return new Uint8Array(I);case"uic8":return new Uint8ClampedArray(I);case"si16":return new Int16Array(I);case"ur16":return new Uint16Array(I);case"si32":return new Int32Array(I);case"ui32":return new Uint32Array(I);case"fl32":return new Float32Array(I);case"fl64":return new Float64Array(I);default:throw new Error("Unkown type: "+v)}}function m(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var g=a instanceof Date?new Date(a):a.constructor();try{for(var b=O(Object.keys(a)),I=b.next();!I.done;I=b.next()){var R=I.value;Object.prototype.hasOwnProperty.call(a,R)&&(a.isActiveClone=null,g[R]=m(a[R]),delete a.isActiveClone)}}catch(G){u={error:G}}finally{try{I&&!I.done&&(v=b.return)&&v.call(b)}finally{if(u)throw u.error}}return g}function w(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function T(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function F(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function $(a,u){var v=this;if(u=F.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var g=this.config();a.name=a.name||g.name,a.storeName=a.storeName||g.storeName}var b;return a.name?b=new Promise(function(I){a.storeName?I(w(a,v._defaultConfig)):I(a.name+"/")}):b=Promise.reject("Invalid arguments"),{promise:b,callback:u}}function P(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var k={bufferToString:z,deserialize:J,serialize:K,stringToBuffer:D},M={},ae=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return M[u]||(M[u]=new a(u)),M[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete M[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function re(a){var u=a?m(a):{},v=w(u,this._defaultConfig),g=ae.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=k,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=g,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return T(v,a),v}function A(a,u){var v=$.apply(this,arguments),g=v.promise,b=v.callback,I=g.then(function(R){ae.resolve(R).drop()});return T(I,b),g}function E(a,u){var v=this;a=P(a);var g=this.ready().then(function(){var b=v._dbInfo.mStore.get(a);return b==null?null:v._dbInfo.serializer.deserialize(b)});return T(g,u),g}function N(a,u){var v=this,g=this.ready().then(function(){for(var b=v._dbInfo.mStore,I=b.keys(),R=0;R<I.length;R++){var G=b.get(I[R]);if(G&&(G=v._dbInfo.serializer.deserialize(G)),G=a(G,I[R],R+1),G!==void 0)return G}});return T(g,u),g}function H(a,u){var v=this,g=this.ready().then(function(){var b;try{b=v._dbInfo.mStore.key(a),b===void 0&&(b=null)}catch{b=null}return b});return T(g,u),g}function j(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return T(v,a),v}function X(a){var u=this.keys().then(function(v){return v.length});return T(u,a),u}function Q(a,u){var v=this;a=P(a);var g=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return T(g,u),g}function ee(a,u,v){var g=this;a=P(a);var b=this.ready().then(function(){u===void 0&&(u=null);var I=u;return new Promise(function(R,G){g._dbInfo.serializer.serialize(u,function(fe,ie){if(ie)G(ie);else try{g._dbInfo.mStore.set(a,fe),R(I)}catch(ue){G(ue)}})})});return T(b,v),b}var oe=!0;_._support=oe,_._driver=y,_._initStorage=re,_.clear=h,_.dropInstance=A,_.getItem=E,_.iterate=N,_.key=H,_.keys=j,_.length=X,_.removeItem=Q,_.setItem=ee,Object.defineProperty(_,"__esModule",{value:!0})})});var pe=$e(qe()),Te=$e(er());import{SDKBase as ut,createSDK as ct}from"@magic-sdk/provider";import{createDuplicateIframeWarning as tt,createModalNotReadyError as nt,createURL as rr,ViewController as ot}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as it}from"@magic-sdk/types";var at={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function ft(_){for(let[y,O]of Object.entries(at))_.style[y]=O}function st(_){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(O=>O.src.includes(_))}var ye=class extends ot{activeElement=null;iframe;relayerSrc=rr(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(y=>{let O=()=>{if(st(encodeURIComponent(this.parameters)))tt().log();else{let C=document.createElement("iframe");C.classList.add("magic-iframe"),C.dataset.magicIframeLabel=rr(this.endpoint).host,C.title="Secure Modal",C.src=this.relayerSrc,C.allow="clipboard-read; clipboard-write",ft(C),document.body.appendChild(C),y(C)}};["loaded","interactive","complete"].includes(document.readyState)?O():window.addEventListener("load",O,!1)}),this.iframe.then(y=>{y instanceof HTMLIFrameElement&&y.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",y=>{if(y.origin===this.endpoint&&y.data.msgType&&(y.data.msgType.includes(it.MAGIC_PONG)&&(this.lastPongTime=Date.now()),y.data&&this.messageHandlers.size)){y.data.response=y.data.response??{},this.stopHeartBeat();for(let O of this.messageHandlers.values())O(y)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let y=await this.iframe;y.style.display="block",y.style.zIndex="2147483647",y.style.opacity="1",this.activeElement=document.activeElement,y.focus()}async hideOverlay(){let y=await this.iframe;y.style.display="none",y.style.zIndex="-1",y.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(y){let O=await this.iframe;if(O&&O.contentWindow)O.contentWindow.postMessage(y,this.endpoint);else throw nt()}async checkRelayerExistsInDOM(){let y=await this.iframe;return!y||!y.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(C=>C.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let y=await this.iframe;if(this.stopHeartBeat(),!y){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!y.contentWindow){document.body.appendChild(y),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}y&&(y.src=this.relayerSrc)}};export*from"@magic-sdk/provider";export*from"@magic-sdk/types";var wt=ct(ut,{platform:"web",sdkName:"magic-sdk",version:"31.2.0",defaultEndpoint:"https://auth.magic.link/",ViewController:ye,configureStorage:async()=>{let _=pe.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await _.defineDriver(Te),await _.setDriver([pe.default.INDEXEDDB,pe.default.LOCALSTORAGE,Te._driver]),_}});export{wt as Magic};
2
2
  //# sourceMappingURL=index.mjs.map
package/dist/magic.js CHANGED
@@ -2,5 +2,5 @@
2
2
  - Extension \`${r.name}\` supports version(s) \`${i}\``:i||(t+=`
3
3
  - Extension \`${r.name}\` does not support ${Y.platform} environments.`)}),new De(Re.IncompatibleExtensions,t)}function Xr(e){let t=r=>{let i=r+1,a=i%10,s=i%100;return a===1&&s!==11?`${i}st`:a===2&&s!==12?`${i}nd`:a===3&&s!==13?`${i}rd`:`${i}th`};return new De(Re.InvalidArgument,`Invalid ${t(e.argument)} argument given to \`${e.procedure}\`.
4
4
  Expected: \`${e.expected}\`
5
- Received: \`${e.received}\``)}function Wt(){return new je(be.DuplicateIframe,"Duplicate iframes found.")}function zr(){return new je(be.SyncWeb3Method,"Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.")}function Jr(){return new je(be.ReactNativeEndpointConfiguration,`CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${Y.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function Qr(e){let{method:t,removalVersions:r,useInstead:i}=e,a=r[Y.sdkName],s=i?` Use \`${i}\` instead.`:"",p=`\`${t}\` will be removed from \`${Y.sdkName}\` in version \`${a}\`.${s}`;return new je(be.DeprecationNotice,p)}function*qa(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}var Ka=qa();function Bt(){return Ka.next().value}var Gt={};zi(Gt,{clear:()=>Ya,getItem:()=>de,iterate:()=>Zr,key:()=>za,keys:()=>Ja,length:()=>Xa,removeItem:()=>Be,setItem:()=>Oe});var ct;function Te(e){return async(...t)=>(ct||(ct=await Y.configureStorage()),await ct.ready(),ct[e](...t))}var de=Te("getItem"),Oe=Te("setItem"),Be=Te("removeItem"),Ya=Te("clear"),Xa=Te("length"),za=Te("key"),Ja=Te("keys"),Zr=Te("iterate");function en(){let e=window.crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&191|128;let t="";return t+=e[0].toString(16),t+=e[1].toString(16),t+=e[2].toString(16),t+=e[3].toString(16),t+="-",t+=e[4].toString(16),t+=e[5].toString(16),t+="-",t+=e[6].toString(16),t+=e[7].toString(16),t+="-",t+=e[8].toString(16),t+=e[9].toString(16),t+="-",t+=e[10].toString(16),t+=e[11].toString(16),t+=e[12].toString(16),t+=e[13].toString(16),t+=e[14].toString(16),t+=e[15].toString(16),t}var vt="STORE_KEY_PRIVATE_KEY",Qe="STORE_KEY_PUBLIC_JWK",tn="ECDSA",Qa="P-256",Za={name:tn,namedCurve:Qa};function et(){let e=typeof window<"u"&&!!window.crypto,t=e&&!!window.crypto.subtle;return e&&t}function rn(){Be(Qe),Be(vt)}async function nn(){let e=await eo();if(!e){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,r=await de(vt);if(!r||!t){console.info("unable to find private key or webcrypto unsupported");return}let i={iat:Math.floor(new Date().getTime()/1e3),jti:en()},a={protected:Pr(JSON.stringify({typ:"dpop+jwt",alg:"ES256",jwk:e})),claims:Pr(JSON.stringify(i))},s=ro(`${a.protected}.${a.claims}`),p={name:tn,hash:{name:"SHA-256"}},h=io(new Uint8Array(await t.sign(p,r,s)));return`${a.protected}.${a.claims}.${h}`}async function eo(){if(!et()){console.info("webcrypto is not supported");return}return await de(Qe)||await to(),de(Qe)}async function to(){let{subtle:e}=window.crypto,t=await e.generateKey(Za,!1,["sign"]),r=await e.exportKey("jwk",t.publicKey);await Oe(vt,t.privateKey),await Oe(Qe,r)}function Pr(e){return an(no(e))}function ro(e){return new TextEncoder().encode(e)}function an(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function no(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(r,16)))}function io(e){let t="";return e.forEach(r=>{t+=String.fromCharCode(r)}),an(t)}var on=Symbol("Payload pre-processed by Magic SDK");function sn(e){return Object.defineProperty(e,on,{value:!0,enumerable:!1}),e}function ao(e){return!!e[on]}function ht(e){return ao(e)||(e.jsonrpc=e.jsonrpc??"2.0",e.id=Bt(),e.method=e.method??"noop",e.params=e.params??[],sn(e)),e}function G(e,t=[]){return sn({params:t,method:e,jsonrpc:"2.0",id:Bt()})}var cn=class ln{_jsonrpc;_id;_result;_error;constructor(t){t instanceof ln?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):kr(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return this._error?.code===Pe.DpopInvalidated&&rn(),typeof this._error<"u"&&this._error!==null}get hasResult(){return typeof this._result<"u"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}},oo=Qi(Zi()),un=class extends oo.default{};function Vt(){let e=new un;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...i)=>(e[t].apply(e,i),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}var dn=Symbol("isPromiEvent");function fn(e){return!!e[dn]}function me(e){let t=jt(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:i}=Vt(),a=Symbol("Promise.then"),s=Symbol("Promise.catch"),p=Symbol("Promise.finally"),h=(y,O)=>(...E)=>{let N=O[y].apply(O,E);return w(N)},w=y=>Object.assign(y,{[dn]:!0,[a]:y[a]||y.then,[s]:y[s]||y.catch,[p]:y[p]||y.finally,then:h(a,y),catch:h(s,y),finally:h(p,y),on:i("on",y),once:i("once",y),addListener:i("addListener",y),off:i("off",y),removeListener:i("removeListener",y),removeAllListeners:i("removeAllListeners",y),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),v=w(t.then(y=>(v.emit("done",y),v.emit("settled"),y),y=>{throw v.emit("error",y),v.emit("settled"),y}));return v.on(Mt.ClosedByUser,()=>{v.emit(Tt.ClosedByUser)}),v}function jt(e){return new Promise((t,r)=>{let i=e(t,r);Promise.resolve(i).catch(r)})}var Me=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){if(this.sdk.thirdPartyWallets.isConnected&&!Rr.includes(e.method))return me((a,s)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(a).catch(s)});let t=this.overlay.post(Se.MAGIC_HANDLE_REQUEST,ht(e)),r=me((a,s)=>{t.then(p=>{if(i(),p.hasError)s(new ft(p.payload.error));else if(p.hasResult)a(p.payload.result);else throw qr()}).catch(p=>{i(),s(p)})}),i=this.overlay.on(he.MAGIC_HANDLE_EVENT,a=>{let{response:s}=a.data;if(s.id===e.id&&s.result?.event){let{event:p,params:h=[]}=s.result;r.emit(p,...h)}});return r}createIntermediaryEvent(e,t){return r=>{let i=G(M.IntermediaryEvent,[{payloadId:t,eventType:e,args:r}]);this.request(i)}}};function hn(e,t){let[r]=e.split(".").map(Number);return r>=t}var so={"magic-sdk":"v18.0.0","@magic-sdk/react-native":"v14.0.0","@magic-sdk/react-native-bare":"v19.0.0","@magic-sdk/react-native-expo":"v19.0.0"},co=class extends Me{loginWithMagicLink(e){let t=Y.sdkName==="@magic-sdk/react-native"||Y.sdkName==="@magic-sdk/react-native-bare"||Y.sdkName==="@magic-sdk/react-native-expo";if(t&&hn(Y.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utilize a passcode method like loginWithSMS or loginWithEmailOTP instead.");t&&Qr({method:"auth.loginWithMagicLink()",removalVersions:so,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:i=!0,redirectURI:a,overrides:s,lifespan:p}=e,h=G(this.sdk.testMode?M.LoginWithMagicLinkTestMode:M.LoginWithMagicLink,[{email:r,showUI:i,redirectURI:a,overrides:s,lifespan:p}]);return this.request(h)}loginWithSMS(e){let{phoneNumber:t,showUI:r=!0,lifespan:i}=e,a=G(this.sdk.testMode?M.LoginWithSmsTestMode:M.LoginWithSms,[{phoneNumber:t,showUI:r,lifespan:i}]),s=this.request(a);return!r&&s&&(s.on(xe.VerifySmsOtp,p=>{this.createIntermediaryEvent(xe.VerifySmsOtp,a.id)(p)}),s.on(xe.Cancel,()=>{this.createIntermediaryEvent(xe.Cancel,a.id)()})),s}loginWithEmailOTP(e){let{email:t,showUI:r,deviceCheckUI:i,overrides:a,lifespan:s}=e,p=G(this.sdk.testMode?M.LoginWithEmailOTPTestMode:M.LoginWithEmailOTP,[{email:t,showUI:r,deviceCheckUI:i,overrides:a,lifespan:s}]),h=this.request(p);return!i&&h&&h.on(it.Retry,()=>{this.createIntermediaryEvent(it.Retry,p.id)()}),!r&&h&&(h.on(ue.VerifyEmailOtp,w=>{this.createIntermediaryEvent(ue.VerifyEmailOtp,p.id)(w)}),h.on(ue.VerifyMFACode,w=>{this.createIntermediaryEvent(ue.VerifyMFACode,p.id)(w)}),h.on(ue.LostDevice,()=>{this.createIntermediaryEvent(ue.LostDevice,p.id)()}),h.on(ue.VerifyRecoveryCode,w=>{this.createIntermediaryEvent(ue.VerifyRecoveryCode,p.id)(w)}),h.on(ue.Cancel,()=>{this.createIntermediaryEvent(ue.Cancel,p.id)()})),h}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:r}=e||{},i=t??"";if(!t&&Y.platform==="web"){i=window.location.search;let s=window.location.origin+window.location.pathname;window.history.replaceState(null,"",s)}let a=G(this.sdk.testMode?M.LoginWithCredentialTestMode:M.LoginWithCredential,[i,r]);return this.request(a)}setAuthorizationToken(e){let t=G(M.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:r=!0}=e,i=G(this.sdk.testMode?M.UpdateEmailTestMode:M.UpdateEmail,[{email:t,showUI:r}]),a=this.request(i);return r||(a.on(ce.Retry,()=>{this.createIntermediaryEvent(ce.Retry,i.id)()}),a.on(ce.Cancel,()=>{this.createIntermediaryEvent(ce.Cancel,i.id)()}),a.on(ce.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ce.VerifyEmailOtp,i.id)(s)}),a.on(ce.VerifyMFACode,s=>{this.createIntermediaryEvent(ce.VerifyMFACode,i.id)(s)}),a.on(ie.RetryWithNewEmail,s=>{this.createIntermediaryEvent(ie.RetryWithNewEmail,i.id)(s)}),a.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()}),a.on(ie.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ie.VerifyEmailOtp,i.id)(s)})),a}},Ht="ds",qt="ek",Kt="iv",Yt="AES-GCM",lo=256;async function mn(){let e=[];await Zr((t,r,i)=>{r.startsWith(`${Ht}_`)&&e.push(r)});for(let t of e)await Be(t)}function pn(e){let t="",r=new Uint8Array(e),i=r.byteLength;for(let a=0;a<i;a++)t+=String.fromCharCode(r[a]);return window.btoa(t)}function vn(e){let t=window.atob(e),r=t.length,i=new Uint8Array(r);for(let a=0;a<r;a++)i[a]=t.charCodeAt(a);return i.buffer}async function uo(){if(!et()){console.info("webcrypto is not supported");return}let{crypto:e}=window;return await de(Kt)||e.getRandomValues(new Uint8Array(12))}async function fo(){if(!et()){console.info("webcrypto is not supported");return}let{subtle:e}=window.crypto;return await de(qt)||await e.generateKey({name:Yt,length:lo},!1,["encrypt","decrypt"])}async function ho(e,t){let r=await uo(),i=await fo();if(!r||!i||!e)return;let a=vn(e),{subtle:s}=window.crypto,p=await s.encrypt({name:Yt,iv:r},i,a),h=pn(p);await Oe(`${Ht}_${t}`,h),await Oe(qt,i),await Oe(Kt,r)}async function mo(e){let t=await de(`${Ht}_${e}`),r=await de(Kt),i=await de(qt);if(!r||!t||!i||!et())return;let{subtle:a}=window.crypto,s=await a.decrypt({name:Yt,iv:r},i,vn(t));return pn(s)}function Ge(e,t){return t?new URL(e,t):new URL(e)}var po=class extends Me{getIdToken(e){let t=G(this.sdk.testMode?M.GetIdTokenTestMode:M.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=G(this.sdk.testMode?M.GenerateIdTokenTestMode:M.GenerateIdToken,[e]);return this.request(t)}getInfo(){let e=G(M.GetInfo,[]);return this.request(e)}isLoggedIn(){return me(async(e,t)=>{try{let r=!1;this.sdk.useStorageCache&&(r=await de(this.localForageIsLoggedInKey)==="true",r&&e(!0));let i=G(this.sdk.testMode?M.IsLoggedInTestMode:M.IsLoggedIn),a=await this.request(i);this.sdk.useStorageCache&&(a?Oe(this.localForageIsLoggedInKey,!0):Be(this.localForageIsLoggedInKey),r&&!a&&this.emitUserLoggedOut(!0)),e(a)}catch(r){t(r)}})}logout(){return Be(this.localForageIsLoggedInKey),mn(),me(async(e,t)=>{try{let r=G(this.sdk.testMode?M.LogoutTestMode:M.Logout),i=await this.request(r);this.sdk.useStorageCache&&this.emitUserLoggedOut(i),e(i)}catch(r){t(r)}})}requestInfoWithUI(e){let t=G(M.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}showSettings(e){let{showUI:t=!0}=e||{},r=G(this.sdk.testMode?M.UserSettingsTestMode:M.UserSettings,[e]),i=this.request(r);return!t&&i&&(i.on(pe.SendNewPhoneNumber,a=>{this.createIntermediaryEvent(pe.SendNewPhoneNumber,r.id)(a)}),i.on(pe.SendOtpCode,a=>{this.createIntermediaryEvent(pe.SendOtpCode,r.id)(a)}),i.on(pe.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(pe.StartEditPhoneNumber,r.id)()}),i.on(pe.Cancel,()=>{this.createIntermediaryEvent(pe.Cancel,r.id)()}),i.on(ce.VerifyEmailOtp,a=>{this.createIntermediaryEvent(ce.VerifyEmailOtp,r.id)(a)})),i}recoverAccount(e){let{email:t,showUI:r}=e,i=G(this.sdk.testMode?M.RecoverAccountTestMode:M.RecoverAccount,[{email:t,showUI:r}]),a=this.request(i);return!r&&a&&(a.on(ve.Cancel,()=>{this.createIntermediaryEvent(ve.Cancel,i.id)()}),a.on(ve.ResendSms,()=>{this.createIntermediaryEvent(ve.ResendSms,i.id)()}),a.on(ve.VerifyOtp,s=>{this.createIntermediaryEvent(ve.VerifyOtp,i.id)(s)}),a.on(ve.UpdateEmail,s=>{this.createIntermediaryEvent(ve.UpdateEmail,i.id)(s)}),a.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()}),a.on(ie.RetryWithNewEmail,s=>{this.createIntermediaryEvent(ie.RetryWithNewEmail,i.id)(s)}),a.on(ie.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ie.VerifyEmailOtp,i.id)(s)})),a}revealEVMPrivateKey(){let e=G(M.RevealPK,[{chain:"ETH"}]);return this.request(e)}revealPrivateKey(){throw new Error("revealPrivateKey() has been decommissioned. For EVM chains, use `user.revealEVMPrivateKey()` instead. For non-EVM chains, use `[extension].revealPrivateKey()` instead.")}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:t=!0}=e,r=G(M.EnableMFA,[{showUI:t}]),i=this.request(r);return!t&&i&&(i.on(Fe.VerifyMFACode,a=>{this.createIntermediaryEvent(Fe.VerifyMFACode,r.id)(a)}),i.on(Fe.Cancel,()=>{this.createIntermediaryEvent(Fe.Cancel,r.id)()})),i}disableMFA(e){let{showUI:t=!0}=e,r=G(M.DisableMFA,[{showUI:t}]),i=this.request(r);return!t&&i&&(i.on(Ae.VerifyMFACode,a=>{this.createIntermediaryEvent(Ae.VerifyMFACode,r.id)(a)}),i.on(Ae.LostDevice,a=>{this.createIntermediaryEvent(Ae.LostDevice,r.id)(a)}),i.on(Ae.Cancel,()=>{this.createIntermediaryEvent(Ae.Cancel,r.id)()})),i}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(t=>{t(e)})}localForageIsLoggedInKey="magic_auth_is_logged_in";userLoggedOutCallbacks=[]},vo=class extends Me{connectWithUI(e){let t=me(async(r,i)=>{try{let a=G(M.Login,[{enabledWallets:this.sdk.thirdPartyWallets.enabledWallets,...e}]),s=this.request(a);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:h,callback:w})=>{s.on(h,()=>w(a.id))}),s.on("id-token-created",h=>{t.emit("id-token-created",h)});let p=await s;p.error&&i(p),r(p)}catch(a){i(a)}});return t}showUI(e){return this.request(G(M.ShowUI,[e]))}showAddress(){return this.request(G(M.ShowAddress))}showSendTokensUI(){return this.request(G(M.ShowSendTokensUI))}showOnRamp(){return this.request(G(M.ShowOnRamp))}showNFTs(){return this.request(G(M.ShowNFTs))}showBalances(){return this.request(G(M.ShowBalances))}sendGaslessTransaction(e,t){return this.request(G(M.SendGaslessTransaction,[e,t]))}},yo=class extends Me{eventListeners=[];enabledWallets={};isConnected=!1;resetThirdPartyWalletState(){localStorage.removeItem(ge.PROVIDER),localStorage.removeItem(ge.ADDRESS),localStorage.removeItem(ge.CHAIN_ID),this.isConnected=!1}requestOverride(e){if(e.method===M.Login)return this.resetThirdPartyWalletState(),super.request(e);if(e.method===M.GetInfo)return this.getInfo(e);if(e.method===M.IsLoggedIn)return this.isLoggedIn(e);if(e.method===M.Logout)return this.logout(e);switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalRequest(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}isLoggedIn(e){switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalIsLoggedIn();default:return this.resetThirdPartyWalletState(),super.request(e)}}getInfo(e){switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalGetInfo();default:return this.resetThirdPartyWalletState(),super.request(e)}}logout(e){let t=localStorage.getItem(ge.PROVIDER);switch(this.resetThirdPartyWalletState(),t){case"web3modal":return this.web3modalLogout();default:return super.request(e)}}web3modalRequest(e){return me((t,r)=>{this.sdk.web3modal.modal.getWalletProvider().request(e).then(t).catch(r)})}web3modalIsLoggedIn(){return me(e=>{let t=this.sdk.web3modal.modal.getStatus();if(t==="connected"&&e(!0),t==="disconnected"&&(this.resetThirdPartyWalletState(),e(!1)),t==="reconnecting"){let r=this.sdk.web3modal.modal.subscribeProvider(({status:i})=>{i==="connected"&&(r(),e(!0)),i==="disconnected"&&(r(),this.resetThirdPartyWalletState(),e(!1))})}})}formatWeb3modalGetInfoResponse(){let e=this.sdk.web3modal.modal.getWalletInfo()?.name,t=this.sdk.web3modal.modal.getAddress();return{publicAddress:t,email:null,issuer:`did:ethr:${t}`,phoneNumber:null,isMfaEnabled:!1,recoveryFactors:[],walletType:e||"web3modal",firstLoginAt:null}}web3modalGetInfo(){return me((e,t)=>{let r=this.sdk.web3modal.modal.getStatus();if(r==="connected"&&e(this.formatWeb3modalGetInfoResponse()),r==="disconnected"&&(this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access.")),r==="reconnecting"){let i=this.sdk.web3modal.modal.subscribeProvider(({status:a})=>{a==="connected"&&(i(),e(this.formatWeb3modalGetInfoResponse())),a==="disconnected"&&(i(),this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access."))})}})}web3modalLogout(){return me(async e=>{try{await this.sdk.web3modal.modal.disconnect()}catch(t){console.error(t)}e(!0)})}},{createBoundEmitterMethod:lt,createChainingEmitterMethod:We}=Vt(),go=class extends Me{isMagic=!0;sendAsync(e,t){if(!t)throw Xr({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:t===null?"null":typeof t});if(Array.isArray(e))this.overlay.post(Se.MAGIC_HANDLE_REQUEST,e.map(r=>{let i=ht(r);return this.prefixPayloadMethodForTestMode(i),i})).then(r=>{t(null,r.map(i=>({...i.payload,error:i.hasError?new ft(i.payload.error):null})))});else{let r=ht(e);this.prefixPayloadMethodForTestMode(r),this.overlay.post(Se.MAGIC_HANDLE_REQUEST,r).then(i=>{t(i.hasError?new ft(i.payload.error):null,i.payload)})}}send(e,t){if(typeof e=="string"){let i=G(e,Array.isArray(t)?t:[]);return this.request(i)}if(Array.isArray(e)||t){this.sendAsync(e,t);return}let r=zr();return r.log(),new cn(e).applyError({code:-32603,message:r.rawMessage}).payload}enable(){let e=G(M.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let t="testMode/eth/";this.sdk.testMode&&(e.method=`${t}${e.method}`)}on=We("on",this);once=We("once",this);addListener=We("addListener",this);off=We("off",this);removeListener=We("removeListener",this);removeAllListeners=We("removeAllListeners",this);emit=lt("emit");eventNames=lt("eventNames");listeners=lt("listeners");listenerCount=lt("listenerCount")},Eo=class extends Me{purchase(e){let t=G(M.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,r=G(M.NFTCheckout,[{...e,walletProvider:t?"web3modal":"magic"}]),i=this.request(r);return t&&(i.on(ke.Initiated,async a=>{try{let s=await this.request({method:"eth_sendTransaction",params:[a]});this.createIntermediaryEvent(ke.Success,r.id)(s)}catch{this.createIntermediaryEvent(ke.Failure,r.id)()}}),i.on(ke.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),i.emit("disconnect")})),i}transfer(e){let t=G(M.NFTTransfer,[e]);return this.request(t)}};function Dr(e){return e.compat&&e.compat[Y.sdkName]!=null?typeof e.compat[Y.sdkName]=="string"?Pa(xa(Y.version),e.compat[Y.sdkName]):!!e.compat[Y.sdkName]:!0}function _o(e,t,r){return!t&&!r?`${e}_eth_mainnet`:r?`${e}_${JSON.stringify(r)}`:t?typeof t=="string"?`${e}_eth_${t}`:`${e}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${e}_unknown`}function Io(e){let t=e?.extensions??[],r={},i=[];if(Array.isArray(t)?t.forEach(a=>{Dr(a)?(a.init(this),a.name&&(this[a.name]=a),Je(a.config)||(r[a.name]=a.config)):i.push(a)}):Object.keys(t).forEach(a=>{if(Dr(t[a])){t[a].init(this);let s=t[a];this[a]=s,Je(s.config)||(r[t[a].name]=s.config)}else i.push(t[a])}),i.length)throw Yr(i);return r}var Xt=class dt{constructor(t,r){if(this.apiKey=t,!t)throw Hr();Y.platform==="react-native"&&r?.endpoint&&Jr().log();let{defaultEndpoint:i,version:a}=Y;this.testMode=!!r?.testMode,this.useStorageCache=!!r?.useStorageCache,this.endpoint=Ge(r?.endpoint??i).origin,this.auth=new co(this),this.user=new po(this),this.wallet=new vo(this),this.nft=new Eo(this),this.thirdPartyWallets=new yo(this),this.rpcProvider=new go(this);let s=Io.call(this,r);this.parameters=Ft({API_KEY:this.apiKey,DOMAIN_ORIGIN:typeof window<"u"&&window?.location?window?.location.origin:"",ETH_NETWORK:r?.network,host:Ge(this.endpoint).host,sdk:Ha[Y.sdkName],version:a,ext:Je(s)?void 0:s,locale:r?.locale||"en_US",authConfig:r?.authConfig?{...r.authConfig}:void 0,...Y.bundleId?{bundleId:Y.bundleId}:{},meta:r?.meta}),this.networkHash=_o(this.apiKey,r?.network,Je(s)?void 0:s),r?.deferPreload||this.preload()}static __overlays__=new Map;endpoint;parameters;networkHash;testMode;useStorageCache;auth;user;wallet;nft;thirdPartyWallets;rpcProvider;get overlay(){if(!dt.__overlays__.has(this.parameters)){let t=new Y.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),dt.__overlays__.set(this.parameters,t)}return dt.__overlays__.get(this.parameters)}async preload(){await this.overlay.waitForReady()}};function wo(e,t){return t&&Array.isArray(e)?e.find(r=>r.id===t):e}function Ro(e,t){let r=t.data.response?.id,i=wo(e,r);if(r&&i){let a=new cn(i).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:r,response:a}}return{}}async function bo(e,t,r){let i=await de("rt"),a;if(Y.platform==="web")try{a=await de("jwt")??await nn()}catch(h){console.error("webcrypto error",h)}let s={msgType:e,payload:t};a&&(s.jwt=a),a&&i&&(s.rt=i);let p=await mo(r);return p&&(s.deviceShare=p),s}async function So(e){e.data.rt&&await Oe("rt",e.data.rt)}function Ao(e,t){let r=null;return function(...i){r&&clearTimeout(r),r=setTimeout(()=>{e(...i)},t)}}var Oo=1e3,yn=60*Oo,$r=5*yn,No=60*yn,zt=class{constructor(e,t,r){this.endpoint=e,this.parameters=t,this.networkHash=r,this.listen()}isReadyForRequest=!1;messageHandlers=new Set;isConnectedToInternet=!0;lastPongTime=null;heartbeatIntervalTimer=null;heartbeatDebounce=Ao(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},No);async post(e,t){return jt(async(r,i)=>{if(!this.isConnectedToInternet){let v=pt();i(v)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let a=[],s=Array.isArray(t)?t.map(v=>v.id):[],p=await bo(`${e}-${this.parameters}`,t,this.networkHash);await this._post(p);let h=v=>y=>{let{id:O,response:E}=Ro(t,y);if(So(y),E?.payload.error?.message==="User denied account access.")mn();else if(y.data.deviceShare){let{deviceShare:N}=y.data;ho(N,this.networkHash)}O&&E&&Array.isArray(t)&&s.includes(O)?(a.push(E),a.length===t.length&&(v(),r(a))):O&&E&&!Array.isArray(t)&&O===t.id&&(v(),r(E))},w=this.on(he.MAGIC_HANDLE_RESPONSE,h(()=>w()))})}on(e,t){let r=t.bind(window),i=a=>{a.data.msgType===`${e}-${this.parameters}`&&r(a)};return this.messageHandlers.add(i),()=>this.messageHandlers.delete(i)}waitForReady(){return new Promise(e=>{let t=this.on(he.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}listen(){this.on(he.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(he.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(he.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new je(be.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=async()=>{let r={msgType:`${Se.MAGIC_PING}-${this.parameters}`,payload:[]};await this._post(r)};this.heartbeatIntervalTimer=setInterval(async()=>{if(this.lastPongTime){if(Date.now()-this.lastPongTime>$r*2){this.reloadRelayer(),e=!0;return}}else if(!e){this.reloadRelayer(),e=!0;return}await t(),e=!1},$r)}stopHeartBeat(){this.heartbeatDebounce(),this.lastPongTime=null,this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}},Ur=["request","overlay","sdk"];function To(e){let t=Object.getPrototypeOf(e),r=[t];for(;t!==Me.prototype;)t=Object.getPrototypeOf(t),r.push(t);return r}var Mo=class extends Me{compat;__sdk_access_field_descriptors__=new Map;__is_initialized__=!1;utils={createPromiEvent:me,isPromiEvent:fn,encodeJSON:Ft,decodeJSON:Fr,createJsonRpcRequestPayload:G,standardizeJsonRpcRequestPayload:ht,storage:Gt};constructor(){super(void 0);let e=[this,...To(this)];Ur.forEach(t=>{let r=e.map(p=>Object.getOwnPropertyDescriptor(p,t)),i=r.findIndex(p=>!!p),a=i>0,s=r[i];s&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:s,isPrototypeField:a}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw Kr(t)}}))})}init(e){this.__is_initialized__||(Ur.forEach(t=>{if(this.__sdk_access_field_descriptors__.has(t)){let{descriptor:r,isPrototypeField:i}=this.__sdk_access_field_descriptors__.get(t);i?delete this[t]:Object.defineProperty(this,t,r)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:r,useInstead:i}=e,a=i?` Use \`${i}\` instead.`:"",s=`\`${t}\` will be removed from this Extension in version \`${r}\`.${a}`;return new $t(this,"DEPRECATION_NOTICE",s)}createWarning(e,t){return new $t(this,e,t)}createError(e,t,r){return new Vr(this,e,t,r)}},gn=class extends Mo{},Lo=class{static Internal=gn},Co=class extends gn{constructor(e){super(),this.config=e,this.chain=e.chainType}chain;getPublicAddress(){return this.request(this.utils.createJsonRpcRequestPayload(M.GetMultichainPublicAddress,[{chain:this.chain}]))}revealPrivateKey(){return this.request(this.utils.createJsonRpcRequestPayload(M.RevealPK,[{chain:this.chain}]))}};var Et=wr(_n()),Zt=wr(wn());var Po={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function Do(e){for(let[t,r]of Object.entries(Po))e.style[t]=r}function $o(e){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(r=>r.src.includes(e))}var gt=class extends zt{activeElement=null;iframe;relayerSrc=Ge(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(t=>{let r=()=>{if($o(encodeURIComponent(this.parameters)))Wt().log();else{let i=document.createElement("iframe");i.classList.add("magic-iframe"),i.dataset.magicIframeLabel=Ge(this.endpoint).host,i.title="Secure Modal",i.src=this.relayerSrc,i.allow="clipboard-read; clipboard-write",Do(i),document.body.appendChild(i),t(i)}};["loaded","interactive","complete"].includes(document.readyState)?r():window.addEventListener("load",r,!1)}),this.iframe.then(t=>{t instanceof HTMLIFrameElement&&t.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",t=>{if(t.origin===this.endpoint&&t.data.msgType&&(t.data.msgType.includes(he.MAGIC_PONG)&&(this.lastPongTime=Date.now()),t.data&&this.messageHandlers.size)){t.data.response=t.data.response??{},this.stopHeartBeat();for(let r of this.messageHandlers.values())r(t)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let t=await this.iframe;t.style.display="block",t.style.zIndex="2147483647",t.style.opacity="1",this.activeElement=document.activeElement,t.focus()}async hideOverlay(){let t=await this.iframe;t.style.display="none",t.style.zIndex="-1",t.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(t){let r=await this.iframe;if(r&&r.contentWindow)r.contentWindow.postMessage(t,this.endpoint);else throw pt()}async checkRelayerExistsInDOM(){let t=await this.iframe;return!t||!t.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(i=>i.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let t=await this.iframe;if(this.stopHeartBeat(),!t){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!t.contentWindow){document.body.appendChild(t),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}t&&(t.src=this.relayerSrc)}};var Uo=Object.assign(kt(Xt,{platform:"web",sdkName:"magic-sdk",version:"31.1.0",defaultEndpoint:"https://auth.magic.link/",ViewController:gt,configureStorage:async()=>{let e=Et.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await e.defineDriver(Zt),await e.setDriver([Et.default.INDEXEDDB,Et.default.LOCALSTORAGE,Zt._driver]),e}}),{...Jt}),xo=Uo;return wi(Fo);})();
5
+ Received: \`${e.received}\``)}function Wt(){return new je(be.DuplicateIframe,"Duplicate iframes found.")}function zr(){return new je(be.SyncWeb3Method,"Non-async web3 methods are deprecated in web3 > 1.0 and are not supported by the Magic web3 provider. Please use an async method instead.")}function Jr(){return new je(be.ReactNativeEndpointConfiguration,`CUSTOM DOMAINS ARE NOT SUPPORTED WHEN USING MAGIC SDK WITH REACT NATIVE! The \`endpoint\` parameter SHOULD NOT be provided. The Magic \`<iframe>\` is automatically wrapped by a WebView pointed at \`${Y.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function Qr(e){let{method:t,removalVersions:r,useInstead:i}=e,a=r[Y.sdkName],s=i?` Use \`${i}\` instead.`:"",p=`\`${t}\` will be removed from \`${Y.sdkName}\` in version \`${a}\`.${s}`;return new je(be.DeprecationNotice,p)}function*qa(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}var Ka=qa();function Bt(){return Ka.next().value}var Gt={};zi(Gt,{clear:()=>Ya,getItem:()=>de,iterate:()=>Zr,key:()=>za,keys:()=>Ja,length:()=>Xa,removeItem:()=>Be,setItem:()=>Oe});var ct;function Te(e){return async(...t)=>(ct||(ct=await Y.configureStorage()),await ct.ready(),ct[e](...t))}var de=Te("getItem"),Oe=Te("setItem"),Be=Te("removeItem"),Ya=Te("clear"),Xa=Te("length"),za=Te("key"),Ja=Te("keys"),Zr=Te("iterate");function en(){let e=window.crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&191|128;let t="";return t+=e[0].toString(16),t+=e[1].toString(16),t+=e[2].toString(16),t+=e[3].toString(16),t+="-",t+=e[4].toString(16),t+=e[5].toString(16),t+="-",t+=e[6].toString(16),t+=e[7].toString(16),t+="-",t+=e[8].toString(16),t+=e[9].toString(16),t+="-",t+=e[10].toString(16),t+=e[11].toString(16),t+=e[12].toString(16),t+=e[13].toString(16),t+=e[14].toString(16),t+=e[15].toString(16),t}var vt="STORE_KEY_PRIVATE_KEY",Qe="STORE_KEY_PUBLIC_JWK",tn="ECDSA",Qa="P-256",Za={name:tn,namedCurve:Qa};function et(){let e=typeof window<"u"&&!!window.crypto,t=e&&!!window.crypto.subtle;return e&&t}function rn(){Be(Qe),Be(vt)}async function nn(){let e=await eo();if(!e){console.info("unable to create public key or webcrypto is unsupported");return}let{subtle:t}=window.crypto,r=await de(vt);if(!r||!t){console.info("unable to find private key or webcrypto unsupported");return}let i={iat:Math.floor(new Date().getTime()/1e3),jti:en()},a={protected:Pr(JSON.stringify({typ:"dpop+jwt",alg:"ES256",jwk:e})),claims:Pr(JSON.stringify(i))},s=ro(`${a.protected}.${a.claims}`),p={name:tn,hash:{name:"SHA-256"}},h=io(new Uint8Array(await t.sign(p,r,s)));return`${a.protected}.${a.claims}.${h}`}async function eo(){if(!et()){console.info("webcrypto is not supported");return}return await de(Qe)||await to(),de(Qe)}async function to(){let{subtle:e}=window.crypto,t=await e.generateKey(Za,!1,["sign"]),r=await e.exportKey("jwk",t.publicKey);await Oe(vt,t.privateKey),await Oe(Qe,r)}function Pr(e){return an(no(e))}function ro(e){return new TextEncoder().encode(e)}function an(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function no(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(r,16)))}function io(e){let t="";return e.forEach(r=>{t+=String.fromCharCode(r)}),an(t)}var on=Symbol("Payload pre-processed by Magic SDK");function sn(e){return Object.defineProperty(e,on,{value:!0,enumerable:!1}),e}function ao(e){return!!e[on]}function ht(e){return ao(e)||(e.jsonrpc=e.jsonrpc??"2.0",e.id=Bt(),e.method=e.method??"noop",e.params=e.params??[],sn(e)),e}function G(e,t=[]){return sn({params:t,method:e,jsonrpc:"2.0",id:Bt()})}var cn=class ln{_jsonrpc;_id;_result;_error;constructor(t){t instanceof ln?(this._jsonrpc=t.payload.jsonrpc,this._id=t.payload.id,this._result=t.payload.result,this._error=t.payload.error):kr(t)?(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=t.result,this._error=t.error):(this._jsonrpc=t.jsonrpc,this._id=t.id,this._result=void 0,this._error=void 0)}applyError(t){return this._error=t,this}applyResult(t){return this._result=t,this}get hasError(){return this._error?.code===Pe.DpopInvalidated&&rn(),typeof this._error<"u"&&this._error!==null}get hasResult(){return typeof this._result<"u"}get payload(){return{jsonrpc:this._jsonrpc,id:this._id,result:this._result,error:this._error}}},oo=Qi(Zi()),un=class extends oo.default{};function Vt(){let e=new un;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...i)=>(e[t].apply(e,i),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}var dn=Symbol("isPromiEvent");function fn(e){return!!e[dn]}function me(e){let t=jt(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:i}=Vt(),a=Symbol("Promise.then"),s=Symbol("Promise.catch"),p=Symbol("Promise.finally"),h=(y,O)=>(...E)=>{let N=O[y].apply(O,E);return w(N)},w=y=>Object.assign(y,{[dn]:!0,[a]:y[a]||y.then,[s]:y[s]||y.catch,[p]:y[p]||y.finally,then:h(a,y),catch:h(s,y),finally:h(p,y),on:i("on",y),once:i("once",y),addListener:i("addListener",y),off:i("off",y),removeListener:i("removeListener",y),removeAllListeners:i("removeAllListeners",y),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),v=w(t.then(y=>(v.emit("done",y),v.emit("settled"),y),y=>{throw v.emit("error",y),v.emit("settled"),y}));return v.on(Mt.ClosedByUser,()=>{v.emit(Tt.ClosedByUser)}),v}function jt(e){return new Promise((t,r)=>{let i=e(t,r);Promise.resolve(i).catch(r)})}var Me=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){if(this.sdk.thirdPartyWallets.isConnected&&!Rr.includes(e.method))return me((a,s)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(a).catch(s)});let t=this.overlay.post(Se.MAGIC_HANDLE_REQUEST,ht(e)),r=me((a,s)=>{t.then(p=>{if(i(),p.hasError)s(new ft(p.payload.error));else if(p.hasResult)a(p.payload.result);else throw qr()}).catch(p=>{i(),s(p)})}),i=this.overlay.on(he.MAGIC_HANDLE_EVENT,a=>{let{response:s}=a.data;if(s.id===e.id&&s.result?.event){let{event:p,params:h=[]}=s.result;r.emit(p,...h)}});return r}createIntermediaryEvent(e,t){return r=>{let i=G(M.IntermediaryEvent,[{payloadId:t,eventType:e,args:r}]);this.request(i)}}};function hn(e,t){let[r]=e.split(".").map(Number);return r>=t}var so={"magic-sdk":"v18.0.0","@magic-sdk/react-native":"v14.0.0","@magic-sdk/react-native-bare":"v19.0.0","@magic-sdk/react-native-expo":"v19.0.0"},co=class extends Me{loginWithMagicLink(e){let t=Y.sdkName==="@magic-sdk/react-native"||Y.sdkName==="@magic-sdk/react-native-bare"||Y.sdkName==="@magic-sdk/react-native-expo";if(t&&hn(Y.version,19))throw new Error("loginWithMagicLink() is deprecated for this package, please utilize a passcode method like loginWithSMS or loginWithEmailOTP instead.");t&&Qr({method:"auth.loginWithMagicLink()",removalVersions:so,useInstead:"auth.loginWithEmailOTP()"}).log();let{email:r,showUI:i=!0,redirectURI:a,overrides:s,lifespan:p}=e,h=G(this.sdk.testMode?M.LoginWithMagicLinkTestMode:M.LoginWithMagicLink,[{email:r,showUI:i,redirectURI:a,overrides:s,lifespan:p}]);return this.request(h)}loginWithSMS(e){let{phoneNumber:t,showUI:r=!0,lifespan:i}=e,a=G(this.sdk.testMode?M.LoginWithSmsTestMode:M.LoginWithSms,[{phoneNumber:t,showUI:r,lifespan:i}]),s=this.request(a);return!r&&s&&(s.on(xe.VerifySmsOtp,p=>{this.createIntermediaryEvent(xe.VerifySmsOtp,a.id)(p)}),s.on(xe.Cancel,()=>{this.createIntermediaryEvent(xe.Cancel,a.id)()})),s}loginWithEmailOTP(e){let{email:t,showUI:r,deviceCheckUI:i,overrides:a,lifespan:s}=e,p=G(this.sdk.testMode?M.LoginWithEmailOTPTestMode:M.LoginWithEmailOTP,[{email:t,showUI:r,deviceCheckUI:i,overrides:a,lifespan:s}]),h=this.request(p);return!i&&h&&h.on(it.Retry,()=>{this.createIntermediaryEvent(it.Retry,p.id)()}),!r&&h&&(h.on(ue.VerifyEmailOtp,w=>{this.createIntermediaryEvent(ue.VerifyEmailOtp,p.id)(w)}),h.on(ue.VerifyMFACode,w=>{this.createIntermediaryEvent(ue.VerifyMFACode,p.id)(w)}),h.on(ue.LostDevice,()=>{this.createIntermediaryEvent(ue.LostDevice,p.id)()}),h.on(ue.VerifyRecoveryCode,w=>{this.createIntermediaryEvent(ue.VerifyRecoveryCode,p.id)(w)}),h.on(ue.Cancel,()=>{this.createIntermediaryEvent(ue.Cancel,p.id)()})),h}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:r}=e||{},i=t??"";if(!t&&Y.platform==="web"){i=window.location.search;let s=window.location.origin+window.location.pathname;window.history.replaceState(null,"",s)}let a=G(this.sdk.testMode?M.LoginWithCredentialTestMode:M.LoginWithCredential,[i,r]);return this.request(a)}setAuthorizationToken(e){let t=G(M.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:r=!0}=e,i=G(this.sdk.testMode?M.UpdateEmailTestMode:M.UpdateEmail,[{email:t,showUI:r}]),a=this.request(i);return r||(a.on(ce.Retry,()=>{this.createIntermediaryEvent(ce.Retry,i.id)()}),a.on(ce.Cancel,()=>{this.createIntermediaryEvent(ce.Cancel,i.id)()}),a.on(ce.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ce.VerifyEmailOtp,i.id)(s)}),a.on(ce.VerifyMFACode,s=>{this.createIntermediaryEvent(ce.VerifyMFACode,i.id)(s)}),a.on(ie.RetryWithNewEmail,s=>{this.createIntermediaryEvent(ie.RetryWithNewEmail,i.id)(s)}),a.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()}),a.on(ie.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ie.VerifyEmailOtp,i.id)(s)})),a}},Ht="ds",qt="ek",Kt="iv",Yt="AES-GCM",lo=256;async function mn(){let e=[];await Zr((t,r,i)=>{r.startsWith(`${Ht}_`)&&e.push(r)});for(let t of e)await Be(t)}function pn(e){let t="",r=new Uint8Array(e),i=r.byteLength;for(let a=0;a<i;a++)t+=String.fromCharCode(r[a]);return window.btoa(t)}function vn(e){let t=window.atob(e),r=t.length,i=new Uint8Array(r);for(let a=0;a<r;a++)i[a]=t.charCodeAt(a);return i.buffer}async function uo(){if(!et()){console.info("webcrypto is not supported");return}let{crypto:e}=window;return await de(Kt)||e.getRandomValues(new Uint8Array(12))}async function fo(){if(!et()){console.info("webcrypto is not supported");return}let{subtle:e}=window.crypto;return await de(qt)||await e.generateKey({name:Yt,length:lo},!1,["encrypt","decrypt"])}async function ho(e,t){let r=await uo(),i=await fo();if(!r||!i||!e)return;let a=vn(e),{subtle:s}=window.crypto,p=await s.encrypt({name:Yt,iv:r},i,a),h=pn(p);await Oe(`${Ht}_${t}`,h),await Oe(qt,i),await Oe(Kt,r)}async function mo(e){let t=await de(`${Ht}_${e}`),r=await de(Kt),i=await de(qt);if(!r||!t||!i||!et())return;let{subtle:a}=window.crypto,s=await a.decrypt({name:Yt,iv:r},i,vn(t));return pn(s)}function Ge(e,t){return t?new URL(e,t):new URL(e)}var po=class extends Me{getIdToken(e){let t=G(this.sdk.testMode?M.GetIdTokenTestMode:M.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=G(this.sdk.testMode?M.GenerateIdTokenTestMode:M.GenerateIdToken,[e]);return this.request(t)}getInfo(){let e=G(M.GetInfo,[]);return this.request(e)}isLoggedIn(){return me(async(e,t)=>{try{let r=!1;this.sdk.useStorageCache&&(r=await de(this.localForageIsLoggedInKey)==="true",r&&e(!0));let i=G(this.sdk.testMode?M.IsLoggedInTestMode:M.IsLoggedIn),a=await this.request(i);this.sdk.useStorageCache&&(a?Oe(this.localForageIsLoggedInKey,!0):Be(this.localForageIsLoggedInKey),r&&!a&&this.emitUserLoggedOut(!0)),e(a)}catch(r){t(r)}})}logout(){return Be(this.localForageIsLoggedInKey),mn(),me(async(e,t)=>{try{let r=G(this.sdk.testMode?M.LogoutTestMode:M.Logout),i=await this.request(r);this.sdk.useStorageCache&&this.emitUserLoggedOut(i),e(i)}catch(r){t(r)}})}requestInfoWithUI(e){let t=G(M.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}showSettings(e){let{showUI:t=!0}=e||{},r=G(this.sdk.testMode?M.UserSettingsTestMode:M.UserSettings,[e]),i=this.request(r);return!t&&i&&(i.on(pe.SendNewPhoneNumber,a=>{this.createIntermediaryEvent(pe.SendNewPhoneNumber,r.id)(a)}),i.on(pe.SendOtpCode,a=>{this.createIntermediaryEvent(pe.SendOtpCode,r.id)(a)}),i.on(pe.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(pe.StartEditPhoneNumber,r.id)()}),i.on(pe.Cancel,()=>{this.createIntermediaryEvent(pe.Cancel,r.id)()}),i.on(ce.VerifyEmailOtp,a=>{this.createIntermediaryEvent(ce.VerifyEmailOtp,r.id)(a)})),i}recoverAccount(e){let{email:t,showUI:r}=e,i=G(this.sdk.testMode?M.RecoverAccountTestMode:M.RecoverAccount,[{email:t,showUI:r}]),a=this.request(i);return!r&&a&&(a.on(ve.Cancel,()=>{this.createIntermediaryEvent(ve.Cancel,i.id)()}),a.on(ve.ResendSms,()=>{this.createIntermediaryEvent(ve.ResendSms,i.id)()}),a.on(ve.VerifyOtp,s=>{this.createIntermediaryEvent(ve.VerifyOtp,i.id)(s)}),a.on(ve.UpdateEmail,s=>{this.createIntermediaryEvent(ve.UpdateEmail,i.id)(s)}),a.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()}),a.on(ie.RetryWithNewEmail,s=>{this.createIntermediaryEvent(ie.RetryWithNewEmail,i.id)(s)}),a.on(ie.VerifyEmailOtp,s=>{this.createIntermediaryEvent(ie.VerifyEmailOtp,i.id)(s)})),a}revealEVMPrivateKey(){let e=G(M.RevealPK,[{chain:"ETH"}]);return this.request(e)}revealPrivateKey(){throw new Error("revealPrivateKey() has been decommissioned. For EVM chains, use `user.revealEVMPrivateKey()` instead. For non-EVM chains, use `[extension].revealPrivateKey()` instead.")}onUserLoggedOut(e){this.userLoggedOutCallbacks.push(e)}enableMFA(e){let{showUI:t=!0}=e,r=G(M.EnableMFA,[{showUI:t}]),i=this.request(r);return!t&&i&&(i.on(Fe.VerifyMFACode,a=>{this.createIntermediaryEvent(Fe.VerifyMFACode,r.id)(a)}),i.on(Fe.Cancel,()=>{this.createIntermediaryEvent(Fe.Cancel,r.id)()})),i}disableMFA(e){let{showUI:t=!0}=e,r=G(M.DisableMFA,[{showUI:t}]),i=this.request(r);return!t&&i&&(i.on(Ae.VerifyMFACode,a=>{this.createIntermediaryEvent(Ae.VerifyMFACode,r.id)(a)}),i.on(Ae.LostDevice,a=>{this.createIntermediaryEvent(Ae.LostDevice,r.id)(a)}),i.on(Ae.Cancel,()=>{this.createIntermediaryEvent(Ae.Cancel,r.id)()})),i}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(t=>{t(e)})}localForageIsLoggedInKey="magic_auth_is_logged_in";userLoggedOutCallbacks=[]},vo=class extends Me{connectWithUI(e){let t=me(async(r,i)=>{try{let a=G(M.Login,[{enabledWallets:this.sdk.thirdPartyWallets.enabledWallets,...e}]),s=this.request(a);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:h,callback:w})=>{s.on(h,()=>w(a.id))}),s.on("id-token-created",h=>{t.emit("id-token-created",h)});let p=await s;p.error&&i(p),r(p)}catch(a){i(a)}});return t}showUI(e){return this.request(G(M.ShowUI,[e]))}showAddress(){return this.request(G(M.ShowAddress))}showSendTokensUI(){return this.request(G(M.ShowSendTokensUI))}showOnRamp(){return this.request(G(M.ShowOnRamp))}showNFTs(){return this.request(G(M.ShowNFTs))}showBalances(){return this.request(G(M.ShowBalances))}sendGaslessTransaction(e,t){return this.request(G(M.SendGaslessTransaction,[e,t]))}},yo=class extends Me{eventListeners=[];enabledWallets={};isConnected=!1;resetThirdPartyWalletState(){localStorage.removeItem(ge.PROVIDER),localStorage.removeItem(ge.ADDRESS),localStorage.removeItem(ge.CHAIN_ID),this.isConnected=!1}requestOverride(e){if(e.method===M.Login)return this.resetThirdPartyWalletState(),super.request(e);if(e.method===M.GetInfo)return this.getInfo(e);if(e.method===M.IsLoggedIn)return this.isLoggedIn(e);if(e.method===M.Logout)return this.logout(e);switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalRequest(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}isLoggedIn(e){switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalIsLoggedIn();default:return this.resetThirdPartyWalletState(),super.request(e)}}getInfo(e){switch(localStorage.getItem(ge.PROVIDER)){case"web3modal":return this.web3modalGetInfo();default:return this.resetThirdPartyWalletState(),super.request(e)}}logout(e){let t=localStorage.getItem(ge.PROVIDER);switch(this.resetThirdPartyWalletState(),t){case"web3modal":return this.web3modalLogout();default:return super.request(e)}}web3modalRequest(e){return me((t,r)=>{this.sdk.web3modal.modal.getWalletProvider().request(e).then(t).catch(r)})}web3modalIsLoggedIn(){return me(e=>{let t=this.sdk.web3modal.modal.getStatus();if(t==="connected"&&e(!0),t==="disconnected"&&(this.resetThirdPartyWalletState(),e(!1)),t==="reconnecting"){let r=this.sdk.web3modal.modal.subscribeProvider(({status:i})=>{i==="connected"&&(r(),e(!0)),i==="disconnected"&&(r(),this.resetThirdPartyWalletState(),e(!1))})}})}formatWeb3modalGetInfoResponse(){let e=this.sdk.web3modal.modal.getWalletInfo()?.name,t=this.sdk.web3modal.modal.getAddress();return{publicAddress:t,email:null,issuer:`did:ethr:${t}`,phoneNumber:null,isMfaEnabled:!1,recoveryFactors:[],walletType:e||"web3modal",firstLoginAt:null}}web3modalGetInfo(){return me((e,t)=>{let r=this.sdk.web3modal.modal.getStatus();if(r==="connected"&&e(this.formatWeb3modalGetInfoResponse()),r==="disconnected"&&(this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access.")),r==="reconnecting"){let i=this.sdk.web3modal.modal.subscribeProvider(({status:a})=>{a==="connected"&&(i(),e(this.formatWeb3modalGetInfoResponse())),a==="disconnected"&&(i(),this.resetThirdPartyWalletState(),t("Magic RPC Error: [-32603] Internal error: User denied account access."))})}})}web3modalLogout(){return me(async e=>{try{await this.sdk.web3modal.modal.disconnect()}catch(t){console.error(t)}e(!0)})}},{createBoundEmitterMethod:lt,createChainingEmitterMethod:We}=Vt(),go=class extends Me{isMagic=!0;sendAsync(e,t){if(!t)throw Xr({procedure:"Magic.rpcProvider.sendAsync",argument:1,expected:"function",received:t===null?"null":typeof t});if(Array.isArray(e))this.overlay.post(Se.MAGIC_HANDLE_REQUEST,e.map(r=>{let i=ht(r);return this.prefixPayloadMethodForTestMode(i),i})).then(r=>{t(null,r.map(i=>({...i.payload,error:i.hasError?new ft(i.payload.error):null})))});else{let r=ht(e);this.prefixPayloadMethodForTestMode(r),this.overlay.post(Se.MAGIC_HANDLE_REQUEST,r).then(i=>{t(i.hasError?new ft(i.payload.error):null,i.payload)})}}send(e,t){if(typeof e=="string"){let i=G(e,Array.isArray(t)?t:[]);return this.request(i)}if(Array.isArray(e)||t){this.sendAsync(e,t);return}let r=zr();return r.log(),new cn(e).applyError({code:-32603,message:r.rawMessage}).payload}enable(){let e=G(M.Login);return this.request(e)}request(e){return this.prefixPayloadMethodForTestMode(e),super.request(e)}prefixPayloadMethodForTestMode(e){let t="testMode/eth/";this.sdk.testMode&&(e.method=`${t}${e.method}`)}on=We("on",this);once=We("once",this);addListener=We("addListener",this);off=We("off",this);removeListener=We("removeListener",this);removeAllListeners=We("removeAllListeners",this);emit=lt("emit");eventNames=lt("eventNames");listeners=lt("listeners");listenerCount=lt("listenerCount")},Eo=class extends Me{purchase(e){let t=G(M.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,r=G(M.NFTCheckout,[{...e,walletProvider:t?"web3modal":"magic"}]),i=this.request(r);return t&&(i.on(ke.Initiated,async a=>{try{let s=await this.request({method:"eth_sendTransaction",params:[a]});this.createIntermediaryEvent(ke.Success,r.id)(s)}catch{this.createIntermediaryEvent(ke.Failure,r.id)()}}),i.on(ke.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),i.emit("disconnect")})),i}transfer(e){let t=G(M.NFTTransfer,[e]);return this.request(t)}};function Dr(e){return e.compat&&e.compat[Y.sdkName]!=null?typeof e.compat[Y.sdkName]=="string"?Pa(xa(Y.version),e.compat[Y.sdkName]):!!e.compat[Y.sdkName]:!0}function _o(e,t,r){return!t&&!r?`${e}_eth_mainnet`:r?`${e}_${JSON.stringify(r)}`:t?typeof t=="string"?`${e}_eth_${t}`:`${e}_${t.rpcUrl}_${t.chainId}_${t.chainType}`:`${e}_unknown`}function Io(e){let t=e?.extensions??[],r={},i=[];if(Array.isArray(t)?t.forEach(a=>{Dr(a)?(a.init(this),a.name&&(this[a.name]=a),Je(a.config)||(r[a.name]=a.config)):i.push(a)}):Object.keys(t).forEach(a=>{if(Dr(t[a])){t[a].init(this);let s=t[a];this[a]=s,Je(s.config)||(r[t[a].name]=s.config)}else i.push(t[a])}),i.length)throw Yr(i);return r}var Xt=class dt{constructor(t,r){if(this.apiKey=t,!t)throw Hr();Y.platform==="react-native"&&r?.endpoint&&Jr().log();let{defaultEndpoint:i,version:a}=Y;this.testMode=!!r?.testMode,this.useStorageCache=!!r?.useStorageCache,this.endpoint=Ge(r?.endpoint??i).origin,this.auth=new co(this),this.user=new po(this),this.wallet=new vo(this),this.nft=new Eo(this),this.thirdPartyWallets=new yo(this),this.rpcProvider=new go(this);let s=Io.call(this,r);this.parameters=Ft({API_KEY:this.apiKey,DOMAIN_ORIGIN:typeof window<"u"&&window?.location?window?.location.origin:"",ETH_NETWORK:r?.network,host:Ge(this.endpoint).host,sdk:Ha[Y.sdkName],version:a,ext:Je(s)?void 0:s,locale:r?.locale||"en_US",authConfig:r?.authConfig?{...r.authConfig}:void 0,...Y.bundleId?{bundleId:Y.bundleId}:{},meta:r?.meta}),this.networkHash=_o(this.apiKey,r?.network,Je(s)?void 0:s),r?.deferPreload||this.preload()}static __overlays__=new Map;endpoint;parameters;networkHash;testMode;useStorageCache;auth;user;wallet;nft;thirdPartyWallets;rpcProvider;get overlay(){if(!dt.__overlays__.has(this.parameters)){let t=new Y.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),dt.__overlays__.set(this.parameters,t)}return dt.__overlays__.get(this.parameters)}async preload(){await this.overlay.waitForReady()}};function wo(e,t){return t&&Array.isArray(e)?e.find(r=>r.id===t):e}function Ro(e,t){let r=t.data.response?.id,i=wo(e,r);if(r&&i){let a=new cn(i).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:r,response:a}}return{}}async function bo(e,t,r){let i=await de("rt"),a;if(Y.platform==="web")try{a=await de("jwt")??await nn()}catch(h){console.error("webcrypto error",h)}let s={msgType:e,payload:t};a&&(s.jwt=a),a&&i&&(s.rt=i);let p=await mo(r);return p&&(s.deviceShare=p),s}async function So(e){e.data.rt&&await Oe("rt",e.data.rt)}function Ao(e,t){let r=null;return function(...i){r&&clearTimeout(r),r=setTimeout(()=>{e(...i)},t)}}var Oo=1e3,yn=60*Oo,$r=5*yn,No=60*yn,zt=class{constructor(e,t,r){this.endpoint=e,this.parameters=t,this.networkHash=r,this.listen()}isReadyForRequest=!1;messageHandlers=new Set;isConnectedToInternet=!0;lastPongTime=null;heartbeatIntervalTimer=null;heartbeatDebounce=Ao(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},No);async post(e,t){return jt(async(r,i)=>{if(!this.isConnectedToInternet){let v=pt();i(v)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let a=[],s=Array.isArray(t)?t.map(v=>v.id):[],p=await bo(`${e}-${this.parameters}`,t,this.networkHash);await this._post(p);let h=v=>y=>{let{id:O,response:E}=Ro(t,y);if(So(y),E?.payload.error?.message==="User denied account access.")mn();else if(y.data.deviceShare){let{deviceShare:N}=y.data;ho(N,this.networkHash)}O&&E&&Array.isArray(t)&&s.includes(O)?(a.push(E),a.length===t.length&&(v(),r(a))):O&&E&&!Array.isArray(t)&&O===t.id&&(v(),r(E))},w=this.on(he.MAGIC_HANDLE_RESPONSE,h(()=>w()))})}on(e,t){let r=t.bind(window),i=a=>{a.data.msgType===`${e}-${this.parameters}`&&r(a)};return this.messageHandlers.add(i),()=>this.messageHandlers.delete(i)}waitForReady(){return new Promise(e=>{let t=this.on(he.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}listen(){this.on(he.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(he.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(he.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new je(be.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=async()=>{let r={msgType:`${Se.MAGIC_PING}-${this.parameters}`,payload:[]};await this._post(r)};this.heartbeatIntervalTimer=setInterval(async()=>{if(this.lastPongTime){if(Date.now()-this.lastPongTime>$r*2){this.reloadRelayer(),e=!0;return}}else if(!e){this.reloadRelayer(),e=!0;return}await t(),e=!1},$r)}stopHeartBeat(){this.heartbeatDebounce(),this.lastPongTime=null,this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}},Ur=["request","overlay","sdk"];function To(e){let t=Object.getPrototypeOf(e),r=[t];for(;t!==Me.prototype;)t=Object.getPrototypeOf(t),r.push(t);return r}var Mo=class extends Me{compat;__sdk_access_field_descriptors__=new Map;__is_initialized__=!1;utils={createPromiEvent:me,isPromiEvent:fn,encodeJSON:Ft,decodeJSON:Fr,createJsonRpcRequestPayload:G,standardizeJsonRpcRequestPayload:ht,storage:Gt};constructor(){super(void 0);let e=[this,...To(this)];Ur.forEach(t=>{let r=e.map(p=>Object.getOwnPropertyDescriptor(p,t)),i=r.findIndex(p=>!!p),a=i>0,s=r[i];s&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:s,isPrototypeField:a}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw Kr(t)}}))})}init(e){this.__is_initialized__||(Ur.forEach(t=>{if(this.__sdk_access_field_descriptors__.has(t)){let{descriptor:r,isPrototypeField:i}=this.__sdk_access_field_descriptors__.get(t);i?delete this[t]:Object.defineProperty(this,t,r)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:r,useInstead:i}=e,a=i?` Use \`${i}\` instead.`:"",s=`\`${t}\` will be removed from this Extension in version \`${r}\`.${a}`;return new $t(this,"DEPRECATION_NOTICE",s)}createWarning(e,t){return new $t(this,e,t)}createError(e,t,r){return new Vr(this,e,t,r)}},gn=class extends Mo{},Lo=class{static Internal=gn},Co=class extends gn{constructor(e){super(),this.config=e,this.chain=e.chainType}chain;getPublicAddress(){return this.request(this.utils.createJsonRpcRequestPayload(M.GetMultichainPublicAddress,[{chain:this.chain}]))}revealPrivateKey(){return this.request(this.utils.createJsonRpcRequestPayload(M.RevealPK,[{chain:this.chain}]))}};var Et=wr(_n()),Zt=wr(wn());var Po={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function Do(e){for(let[t,r]of Object.entries(Po))e.style[t]=r}function $o(e){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(r=>r.src.includes(e))}var gt=class extends zt{activeElement=null;iframe;relayerSrc=Ge(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(t=>{let r=()=>{if($o(encodeURIComponent(this.parameters)))Wt().log();else{let i=document.createElement("iframe");i.classList.add("magic-iframe"),i.dataset.magicIframeLabel=Ge(this.endpoint).host,i.title="Secure Modal",i.src=this.relayerSrc,i.allow="clipboard-read; clipboard-write",Do(i),document.body.appendChild(i),t(i)}};["loaded","interactive","complete"].includes(document.readyState)?r():window.addEventListener("load",r,!1)}),this.iframe.then(t=>{t instanceof HTMLIFrameElement&&t.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",t=>{if(t.origin===this.endpoint&&t.data.msgType&&(t.data.msgType.includes(he.MAGIC_PONG)&&(this.lastPongTime=Date.now()),t.data&&this.messageHandlers.size)){t.data.response=t.data.response??{},this.stopHeartBeat();for(let r of this.messageHandlers.values())r(t)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let t=await this.iframe;t.style.display="block",t.style.zIndex="2147483647",t.style.opacity="1",this.activeElement=document.activeElement,t.focus()}async hideOverlay(){let t=await this.iframe;t.style.display="none",t.style.zIndex="-1",t.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(t){let r=await this.iframe;if(r&&r.contentWindow)r.contentWindow.postMessage(t,this.endpoint);else throw pt()}async checkRelayerExistsInDOM(){let t=await this.iframe;return!t||!t.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(i=>i.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let t=await this.iframe;if(this.stopHeartBeat(),!t){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!t.contentWindow){document.body.appendChild(t),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}t&&(t.src=this.relayerSrc)}};var Uo=Object.assign(kt(Xt,{platform:"web",sdkName:"magic-sdk",version:"31.2.0",defaultEndpoint:"https://auth.magic.link/",ViewController:gt,configureStorage:async()=>{let e=Et.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await e.defineDriver(Zt),await e.setDriver([Et.default.INDEXEDDB,Et.default.LOCALSTORAGE,Zt._driver]),e}}),{...Jt}),xo=Uo;return wi(Fo);})();
6
6
  if (Magic && Magic.default != null) { Magic = Object.assign(Magic.default, Magic); delete Magic.default; }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "magic-sdk",
3
- "version": "31.2.0-canary.f2a57c0.0",
3
+ "version": "31.2.0",
4
4
  "description": "Passwordless authentication for the web.",
5
5
  "author": "Magic Labs <team@magic.link> (https://magic.link/)",
6
6
  "license": "MIT",
@@ -29,9 +29,9 @@
29
29
  ]
30
30
  },
31
31
  "dependencies": {
32
- "@magic-sdk/provider": "31.2.0-canary.f2a57c0.0",
33
- "@magic-sdk/types": "25.2.0-canary.f2a57c0.0",
32
+ "@magic-sdk/provider": "^31.2.0",
33
+ "@magic-sdk/types": "^25.2.0",
34
34
  "localforage": "^1.7.4"
35
35
  },
36
- "gitHead": "f2a57c03d0cc8893478bfd2d70c1d43930649f60"
36
+ "gitHead": "03fc97720800add4f98474ca6649991b694b43b3"
37
37
  }