magic-sdk 33.7.1-canary.b65c8d0.0 → 33.7.1

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 dt=Object.create;var ce=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty;var pt=(f,a)=>()=>(a||f((a={exports:{}}).exports,a),a.exports),tr=(f,a)=>{for(var s in a)ce(f,s,{get:a[s],enumerable:!0})},se=(f,a,s,h)=>{if(a&&typeof a=="object"||typeof a=="function")for(let m of ht(a))!mt.call(f,m)&&m!==s&&ce(f,m,{get:()=>a[m],enumerable:!(h=vt(a,m))||h.enumerable});return f},W=(f,a,s)=>(se(f,a,"default"),s&&se(s,a,"default")),gt=(f,a,s)=>(s=f!=null?dt(yt(f)):{},se(a||!f||!f.__esModule?ce(s,"default",{value:f,enumerable:!0}):s,f)),_t=f=>se(ce({},"__esModule",{value:!0}),f);var or=pt((nr,Re)=>{"use strict";(function(f){if(typeof nr=="object"&&typeof Re<"u")Re.exports=f();else if(typeof define=="function"&&define.amd)define([],f);else{var a;typeof window<"u"?a=window:typeof global<"u"?a=global:typeof self<"u"?a=self:a=this,a.localforage=f()}})(function(){var f,a,s;return function h(m,_,b){function x(B,G){if(!_[B]){if(!m[B]){var p=typeof require=="function"&&require;if(!G&&p)return p(B,!0);if(I)return I(B,!0);var w=new Error("Cannot find module '"+B+"'");throw w.code="MODULE_NOT_FOUND",w}var P=_[B]={exports:{}};m[B][0].call(P.exports,function(L){var V=m[B][1][L];return x(V||L)},P,P.exports,h,m,_,b)}return _[B].exports}for(var I=typeof require=="function"&&require,O=0;O<b.length;O++)x(b[O]);return x}({1:[function(h,m,_){(function(b){"use strict";var x=b.MutationObserver||b.WebKitMutationObserver,I;if(x){var O=0,B=new x(L),G=b.document.createTextNode("");B.observe(G,{characterData:!0}),I=function(){G.data=O=++O%2}}else if(!b.setImmediate&&typeof b.MessageChannel<"u"){var p=new b.MessageChannel;p.port1.onmessage=L,I=function(){p.port2.postMessage(0)}}else"document"in b&&"onreadystatechange"in b.document.createElement("script")?I=function(){var M=b.document.createElement("script");M.onreadystatechange=function(){L(),M.onreadystatechange=null,M.parentNode.removeChild(M),M=null},b.document.documentElement.appendChild(M)}:I=function(){setTimeout(L,0)};var w,P=[];function L(){w=!0;for(var M,X,U=P.length;U;){for(X=P,P=[],M=-1;++M<U;)X[M]();U=P.length}w=!1}m.exports=V;function V(M){P.push(M)===1&&!w&&I()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(h,m,_){"use strict";var b=h(1);function x(){}var I={},O=["REJECTED"],B=["FULFILLED"],G=["PENDING"];m.exports=p;function p(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=G,this.queue=[],this.outcome=void 0,y!==x&&V(this,y)}p.prototype.catch=function(y){return this.then(null,y)},p.prototype.then=function(y,A){if(typeof y!="function"&&this.state===B||typeof A!="function"&&this.state===O)return this;var E=new this.constructor(x);if(this.state!==G){var D=this.state===B?y:A;P(E,D,this.outcome)}else this.queue.push(new w(E,y,A));return E};function w(y,A,E){this.promise=y,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(y){I.resolve(this.promise,y)},w.prototype.otherCallFulfilled=function(y){P(this.promise,this.onFulfilled,y)},w.prototype.callRejected=function(y){I.reject(this.promise,y)},w.prototype.otherCallRejected=function(y){P(this.promise,this.onRejected,y)};function P(y,A,E){b(function(){var D;try{D=A(E)}catch(z){return I.reject(y,z)}D===y?I.reject(y,new TypeError("Cannot resolve promise with itself")):I.resolve(y,D)})}I.resolve=function(y,A){var E=M(L,A);if(E.status==="error")return I.reject(y,E.value);var D=E.value;if(D)V(y,D);else{y.state=B,y.outcome=A;for(var z=-1,Y=y.queue.length;++z<Y;)y.queue[z].callFulfilled(A)}return y},I.reject=function(y,A){y.state=O,y.outcome=A;for(var E=-1,D=y.queue.length;++E<D;)y.queue[E].callRejected(A);return y};function L(y){var A=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof A=="function")return function(){A.apply(y,arguments)}}function V(y,A){var E=!1;function D(K){E||(E=!0,I.reject(y,K))}function z(K){E||(E=!0,I.resolve(y,K))}function Y(){A(z,D)}var j=M(Y);j.status==="error"&&D(j.value)}function M(y,A){var E={};try{E.value=y(A),E.status="success"}catch(D){E.status="error",E.value=D}return E}p.resolve=X;function X(y){return y instanceof this?y:I.resolve(new this(x),y)}p.reject=U;function U(y){var A=new this(x);return I.reject(A,y)}p.all=me;function me(y){var A=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=y.length,D=!1;if(!E)return this.resolve([]);for(var z=new Array(E),Y=0,j=-1,K=new this(x);++j<E;)J(y[j],j);return K;function J(ne,ae){A.resolve(ne).then(pe,function(re){D||(D=!0,I.reject(K,re))});function pe(re){z[ae]=re,++Y===E&&!D&&(D=!0,I.resolve(K,z))}}}p.race=ee;function ee(y){var A=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=y.length,D=!1;if(!E)return this.resolve([]);for(var z=-1,Y=new this(x);++z<E;)j(y[z]);return Y;function j(K){A.resolve(K).then(function(J){D||(D=!0,I.resolve(Y,J))},function(J){D||(D=!0,I.reject(Y,J))})}}},{1:1}],3:[function(h,m,_){(function(b){"use strict";typeof b.Promise!="function"&&(b.Promise=h(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(h,m,_){"use strict";var b=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 x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(){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 O=I();function B(){try{if(!O||!O.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 G(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"&&h(3);var p=Promise;function w(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function P(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function L(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function V(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var M="local-forage-detect-blob-support",X=void 0,U={},me=Object.prototype.toString,ee="readonly",y="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 p(function(t){var r=e.transaction(M,y),o=G([""]);r.objectStore(M).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 D(e){return typeof X=="boolean"?p.resolve(X):E(e).then(function(t){return X=t,X})}function z(e){var t=U[e.name],r={};r.promise=new p(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 Y(e){var t=U[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function j(e,t){var r=U[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function K(e,t){return new p(function(r,o){if(U[e.name]=U[e.name]||Me(),e.db)if(t)z(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=O.open.apply(O,i);t&&(n.onupgradeneeded=function(u){var c=n.result;try{c.createObjectStore(e.storeName),u.oldVersion<=1&&c.createObjectStore(M)}catch(l){if(l.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+u.oldVersion+" to version "+u.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw l}}),n.onerror=function(u){u.preventDefault(),o(n.error)},n.onsuccess=function(){var u=n.result;u.onversionchange=function(c){c.target.close()},r(u),Y(e)}})}function J(e){return K(e,!1)}function ne(e){return K(e,!0)}function ae(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 pe(e){return new p(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 re(e){var t=A(atob(e.data));return G([t],{type:e.type})}function Le(e){return e&&e.__local_forage_encoded_blob}function vr(e){var t=this,r=t._initReady().then(function(){var o=U[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return P(r,e,e),r}function hr(e){z(e);for(var t=U[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,J(e).then(function(n){return e.db=n,ae(e)?ne(e):n}).then(function(n){e.db=t.db=n;for(var u=0;u<r.length;u++)r[u]._dbInfo.db=n}).catch(function(n){throw j(e,n),n})}function $(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 p.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),ne(e)}).then(function(){return hr(e).then(function(){$(e,t,r,o-1)})}).catch(r);r(n)}}function Me(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function yr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=U[r.name];i||(i=Me(),U[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=vr);var n=[];function u(){return p.resolve()}for(var c=0;c<i.forages.length;c++){var l=i.forages[c];l!==t&&n.push(l._initReady().catch(u))}var d=i.forages.slice(0);return p.all(n).then(function(){return r.db=i.db,J(r)}).then(function(v){return r.db=v,ae(r,t._defaultConfig.version)?ne(r):v}).then(function(v){r.db=i.db=v,t._dbInfo=r;for(var g=0;g<d.length;g++){var S=d[g];S!==t&&(S._dbInfo.db=r.db,S._dbInfo.version=r.version)}})}function mr(e,t){var r=this;e=L(e);var o=new p(function(i,n){r.ready().then(function(){$(r._dbInfo,ee,function(u,c){if(u)return n(u);try{var l=c.objectStore(r._dbInfo.storeName),d=l.get(e);d.onsuccess=function(){var v=d.result;v===void 0&&(v=null),Le(v)&&(v=re(v)),i(v)},d.onerror=function(){n(d.error)}}catch(v){n(v)}})}).catch(n)});return w(o,t),o}function pr(e,t){var r=this,o=new p(function(i,n){r.ready().then(function(){$(r._dbInfo,ee,function(u,c){if(u)return n(u);try{var l=c.objectStore(r._dbInfo.storeName),d=l.openCursor(),v=1;d.onsuccess=function(){var g=d.result;if(g){var S=g.value;Le(S)&&(S=re(S));var R=e(S,g.key,v++);R!==void 0?i(R):g.continue()}else i()},d.onerror=function(){n(d.error)}}catch(g){n(g)}})}).catch(n)});return w(o,t),o}function gr(e,t,r){var o=this;e=L(e);var i=new p(function(n,u){var c;o.ready().then(function(){return c=o._dbInfo,me.call(t)==="[object Blob]"?D(c.db).then(function(l){return l?t:pe(t)}):t}).then(function(l){$(o._dbInfo,y,function(d,v){if(d)return u(d);try{var g=v.objectStore(o._dbInfo.storeName);l===null&&(l=void 0);var S=g.put(l,e);v.oncomplete=function(){l===void 0&&(l=null),n(l)},v.onabort=v.onerror=function(){var R=S.error?S.error:S.transaction.error;u(R)}}catch(R){u(R)}})}).catch(u)});return w(i,r),i}function _r(e,t){var r=this;e=L(e);var o=new p(function(i,n){r.ready().then(function(){$(r._dbInfo,y,function(u,c){if(u)return n(u);try{var l=c.objectStore(r._dbInfo.storeName),d=l.delete(e);c.oncomplete=function(){i()},c.onerror=function(){n(d.error)},c.onabort=function(){var v=d.error?d.error:d.transaction.error;n(v)}}catch(v){n(v)}})}).catch(n)});return w(o,t),o}function br(e){var t=this,r=new p(function(o,i){t.ready().then(function(){$(t._dbInfo,y,function(n,u){if(n)return i(n);try{var c=u.objectStore(t._dbInfo.storeName),l=c.clear();u.oncomplete=function(){o()},u.onabort=u.onerror=function(){var d=l.error?l.error:l.transaction.error;i(d)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function wr(e){var t=this,r=new p(function(o,i){t.ready().then(function(){$(t._dbInfo,ee,function(n,u){if(n)return i(n);try{var c=u.objectStore(t._dbInfo.storeName),l=c.count();l.onsuccess=function(){o(l.result)},l.onerror=function(){i(l.error)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function Sr(e,t){var r=this,o=new p(function(i,n){if(e<0){i(null);return}r.ready().then(function(){$(r._dbInfo,ee,function(u,c){if(u)return n(u);try{var l=c.objectStore(r._dbInfo.storeName),d=!1,v=l.openKeyCursor();v.onsuccess=function(){var g=v.result;if(!g){i(null);return}e===0||d?i(g.key):(d=!0,g.advance(e))},v.onerror=function(){n(v.error)}}catch(g){n(g)}})}).catch(n)});return w(o,t),o}function Er(e){var t=this,r=new p(function(o,i){t.ready().then(function(){$(t._dbInfo,ee,function(n,u){if(n)return i(n);try{var c=u.objectStore(t._dbInfo.storeName),l=c.openKeyCursor(),d=[];l.onsuccess=function(){var v=l.result;if(!v){o(d);return}d.push(v.key),v.continue()},l.onerror=function(){i(l.error)}}catch(v){i(v)}})}).catch(i)});return w(r,e),r}function Ir(e,t){t=V.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=p.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,u=n?p.resolve(o._dbInfo.db):J(e).then(function(c){var l=U[e.name],d=l.forages;l.db=c;for(var v=0;v<d.length;v++)d[v]._dbInfo.db=c;return c});e.storeName?i=u.then(function(c){if(c.objectStoreNames.contains(e.storeName)){var l=c.version+1;z(e);var d=U[e.name],v=d.forages;c.close();for(var g=0;g<v.length;g++){var S=v[g];S._dbInfo.db=null,S._dbInfo.version=l}var R=new p(function(T,C){var N=O.open(e.name,l);N.onerror=function(H){var ie=N.result;ie.close(),C(H)},N.onupgradeneeded=function(){var H=N.result;H.deleteObjectStore(e.storeName)},N.onsuccess=function(){var H=N.result;H.close(),T(H)}});return R.then(function(T){d.db=T;for(var C=0;C<v.length;C++){var N=v[C];N._dbInfo.db=T,Y(N._dbInfo)}}).catch(function(T){throw(j(e,T)||p.resolve()).catch(function(){}),T})}}):i=u.then(function(c){z(e);var l=U[e.name],d=l.forages;c.close();for(var v=0;v<d.length;v++){var g=d[v];g._dbInfo.db=null}var S=new p(function(R,T){var C=O.deleteDatabase(e.name);C.onerror=function(){var N=C.result;N&&N.close(),T(C.error)},C.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},C.onsuccess=function(){var N=C.result;N&&N.close(),R(N)}});return S.then(function(R){l.db=R;for(var T=0;T<d.length;T++){var C=d[T];Y(C._dbInfo)}}).catch(function(R){throw(j(e,R)||p.resolve()).catch(function(){}),R})})}return w(i,t),i}var xr={_driver:"asyncStorage",_initStorage:yr,_support:B(),iterate:pr,getItem:mr,setItem:gr,removeItem:_r,clear:br,length:wr,key:Sr,keys:Er,dropInstance:Ir};function Ar(){return typeof openDatabase=="function"}var q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rr="~~local_forage_type~",Fe=/^~~local_forage_type~([^~]+)~/,fe="__lfsc__:",ge=fe.length,_e="arbf",be="blob",Ue="si08",We="ui08",ze="uic8",Ye="si16",je="si32",Ke="ur16",He="ui32",Ge="fl32",Ve="fl64",Qe=ge+_e.length,Xe=Object.prototype.toString;function Je(e){var t=e.length*.75,r=e.length,o,i=0,n,u,c,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var d=new ArrayBuffer(t),v=new Uint8Array(d);for(o=0;o<r;o+=4)n=q.indexOf(e[o]),u=q.indexOf(e[o+1]),c=q.indexOf(e[o+2]),l=q.indexOf(e[o+3]),v[i++]=n<<2|u>>4,v[i++]=(u&15)<<4|c>>2,v[i++]=(c&3)<<6|l&63;return d}function we(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=q[t[o]>>2],r+=q[(t[o]&3)<<4|t[o+1]>>4],r+=q[(t[o+1]&15)<<2|t[o+2]>>6],r+=q[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 Tr(e,t){var r="";if(e&&(r=Xe.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&Xe.call(e.buffer)==="[object ArrayBuffer]")){var o,i=fe;e instanceof ArrayBuffer?(o=e,i+=_e):(o=e.buffer,r==="[object Int8Array]"?i+=Ue:r==="[object Uint8Array]"?i+=We:r==="[object Uint8ClampedArray]"?i+=ze:r==="[object Int16Array]"?i+=Ye:r==="[object Uint16Array]"?i+=Ke:r==="[object Int32Array]"?i+=je:r==="[object Uint32Array]"?i+=He:r==="[object Float32Array]"?i+=Ge:r==="[object Float64Array]"?i+=Ve: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 u=Rr+e.type+"~"+we(this.result);t(fe+be+u)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(u){console.error("Couldn't convert value into a JSON string: ",e),t(null,u)}}function Dr(e){if(e.substring(0,ge)!==fe)return JSON.parse(e);var t=e.substring(Qe),r=e.substring(ge,Qe),o;if(r===be&&Fe.test(t)){var i=t.match(Fe);o=i[1],t=t.substring(i[0].length)}var n=Je(t);switch(r){case _e:return n;case be:return G([n],{type:o});case Ue:return new Int8Array(n);case We:return new Uint8Array(n);case ze:return new Uint8ClampedArray(n);case Ye:return new Int16Array(n);case Ke:return new Uint16Array(n);case je:return new Int32Array(n);case He:return new Uint32Array(n);case Ge:return new Float32Array(n);case Ve:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var Se={serialize:Tr,deserialize:Dr,stringToBuffer:Je,bufferToString:we};function $e(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function Or(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 p(function(n,u){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(c){return u(c)}r.db.transaction(function(c){$e(c,r,function(){t._dbInfo=r,n()},function(l,d){u(d)})},u)});return r.serializer=Se,i}function k(e,t,r,o,i,n){e.executeSql(r,o,i,function(u,c){c.code===c.SYNTAX_ERR?u.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(l,d){d.rows.length?n(l,c):$e(l,t,function(){l.executeSql(r,o,i,n)},n)},n):n(u,c)},n)}function Br(e,t){var r=this;e=L(e);var o=new p(function(i,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(c){k(c,u,"SELECT * FROM "+u.storeName+" WHERE key = ? LIMIT 1",[e],function(l,d){var v=d.rows.length?d.rows.item(0).value:null;v&&(v=u.serializer.deserialize(v)),i(v)},function(l,d){n(d)})})}).catch(n)});return w(o,t),o}function Nr(e,t){var r=this,o=new p(function(i,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(c){k(c,u,"SELECT * FROM "+u.storeName,[],function(l,d){for(var v=d.rows,g=v.length,S=0;S<g;S++){var R=v.item(S),T=R.value;if(T&&(T=u.serializer.deserialize(T)),T=e(T,R.key,S+1),T!==void 0){i(T);return}}i()},function(l,d){n(d)})})}).catch(n)});return w(o,t),o}function Ze(e,t,r,o){var i=this;e=L(e);var n=new p(function(u,c){i.ready().then(function(){t===void 0&&(t=null);var l=t,d=i._dbInfo;d.serializer.serialize(t,function(v,g){g?c(g):d.db.transaction(function(S){k(S,d,"INSERT OR REPLACE INTO "+d.storeName+" (key, value) VALUES (?, ?)",[e,v],function(){u(l)},function(R,T){c(T)})},function(S){if(S.code===S.QUOTA_ERR){if(o>0){u(Ze.apply(i,[e,l,r,o-1]));return}c(S)}})})}).catch(c)});return w(n,r),n}function Pr(e,t,r){return Ze.apply(this,[e,t,r,1])}function Cr(e,t){var r=this;e=L(e);var o=new p(function(i,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(c){k(c,u,"DELETE FROM "+u.storeName+" WHERE key = ?",[e],function(){i()},function(l,d){n(d)})})}).catch(n)});return w(o,t),o}function Lr(e){var t=this,r=new p(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(u){k(u,n,"DELETE FROM "+n.storeName,[],function(){o()},function(c,l){i(l)})})}).catch(i)});return w(r,e),r}function Mr(e){var t=this,r=new p(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(u){k(u,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(c,l){var d=l.rows.item(0).c;o(d)},function(c,l){i(l)})})}).catch(i)});return w(r,e),r}function Fr(e,t){var r=this,o=new p(function(i,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(c){k(c,u,"SELECT key FROM "+u.storeName+" WHERE id = ? LIMIT 1",[e+1],function(l,d){var v=d.rows.length?d.rows.item(0).key:null;i(v)},function(l,d){n(d)})})}).catch(n)});return w(o,t),o}function Ur(e){var t=this,r=new p(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(u){k(u,n,"SELECT key FROM "+n.storeName,[],function(c,l){for(var d=[],v=0;v<l.rows.length;v++)d.push(l.rows.item(v).key);o(d)},function(c,l){i(l)})})}).catch(i)});return w(r,e),r}function Wr(e){return new p(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 u=[],c=0;c<n.rows.length;c++)u.push(n.rows.item(c).name);t({db:e,storeNames:u})},function(i,n){r(n)})},function(o){r(o)})})}function zr(e,t){t=V.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 p(function(n){var u;e.name===r.name?u=o._dbInfo.db:u=openDatabase(e.name,"","",0),e.storeName?n({db:u,storeNames:[e.storeName]}):n(Wr(u))}).then(function(n){return new p(function(u,c){n.db.transaction(function(l){function d(R){return new p(function(T,C){l.executeSql("DROP TABLE IF EXISTS "+R,[],function(){T()},function(N,H){C(H)})})}for(var v=[],g=0,S=n.storeNames.length;g<S;g++)v.push(d(n.storeNames[g]));p.all(v).then(function(){u()}).catch(function(R){c(R)})},function(l){c(l)})})}):i=p.reject("Invalid arguments"),w(i,t),i}var Yr={_driver:"webSQLStorage",_initStorage:Or,_support:Ar(),iterate:Nr,getItem:Br,setItem:Pr,removeItem:Cr,clear:Lr,length:Mr,key:Fr,keys:Ur,dropInstance:zr};function jr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function qe(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Kr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Hr(){return!Kr()||localStorage.length>0}function Gr(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=qe(e,t._defaultConfig),Hr()?(t._dbInfo=r,r.serializer=Se,p.resolve()):p.reject()}function Vr(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 Qr(e,t){var r=this;e=L(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 Xr(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,u=n.length,c=localStorage.length,l=1,d=0;d<c;d++){var v=localStorage.key(d);if(v.indexOf(n)===0){var g=localStorage.getItem(v);if(g&&(g=i.serializer.deserialize(g)),g=e(g,v.substring(u),l++),g!==void 0)return g}}});return w(o,t),o}function Jr(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 $r(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],u=0;u<i;u++){var c=localStorage.key(u);c.indexOf(o.keyPrefix)===0&&n.push(c.substring(o.keyPrefix.length))}return n});return w(r,e),r}function Zr(e){var t=this,r=t.keys().then(function(o){return o.length});return w(r,e),r}function qr(e,t){var r=this;e=L(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return w(o,t),o}function kr(e,t,r){var o=this;e=L(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new p(function(u,c){var l=o._dbInfo;l.serializer.serialize(t,function(d,v){if(v)c(v);else try{localStorage.setItem(l.keyPrefix+e,d),u(n)}catch(g){(g.name==="QuotaExceededError"||g.name==="NS_ERROR_DOM_QUOTA_REACHED")&&c(g),c(g)}})})});return w(i,r),i}function et(e,t){if(t=V.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 p(function(n){e.storeName?n(qe(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var u=localStorage.length-1;u>=0;u--){var c=localStorage.key(u);c.indexOf(n)===0&&localStorage.removeItem(c)}}):i=p.reject("Invalid arguments"),w(i,t),i}var rt={_driver:"localStorageWrapper",_initStorage:Gr,_support:jr(),iterate:Xr,getItem:Qr,setItem:kr,removeItem:qr,clear:Vr,length:Zr,key:Jr,keys:$r,dropInstance:et},tt=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},nt=function(t,r){for(var o=t.length,i=0;i<o;){if(tt(t[i],r))return!0;i++}return!1},ke=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},oe={},er={},te={INDEXEDDB:xr,WEBSQL:Yr,LOCALSTORAGE:rt},ot=[te.INDEXEDDB._driver,te.WEBSQL._driver,te.LOCALSTORAGE._driver],ue=["dropInstance"],Ee=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ue),it={description:"",driver:ot.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function at(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Ie(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(ke(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var ft=function(){function e(t){x(this,e);for(var r in te)if(te.hasOwnProperty(r)){var o=te[r],i=o._driver;this[r]=i,oe[i]||this.defineDriver(o)}this._defaultConfig=Ie({},it),this._config=Ie({},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":b(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 p(function(u,c){try{var l=r._driver,d=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){c(d);return}for(var v=Ee.concat("_initStorage"),g=0,S=v.length;g<S;g++){var R=v[g],T=!nt(ue,R);if((T||r[R])&&typeof r[R]!="function"){c(d);return}}var C=function(){for(var ie=function(ct){return function(){var lt=new Error("Method "+ct+" is not implemented by the current driver"),rr=p.reject(lt);return w(rr,arguments[arguments.length-1]),rr}},xe=0,st=ue.length;xe<st;xe++){var Ae=ue[xe];r[Ae]||(r[Ae]=ie(Ae))}};C();var N=function(ie){oe[l]&&console.info("Redefining LocalForage driver: "+l),oe[l]=r,er[l]=ie,u()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(N,c):N(!!r._support):N(!0)}catch(H){c(H)}});return P(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=oe[r]?p.resolve(oe[r]):p.reject(new Error("Driver not found."));return P(n,o,i),n},e.prototype.getSerializer=function(r){var o=p.resolve(Se);return P(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 P(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;ke(r)||(r=[r]);var u=this._getSupportedDrivers(r);function c(){n._config.driver=n.driver()}function l(g){return n._extend(g),c(),n._ready=n._initStorage(n._config),n._ready}function d(g){return function(){var S=0;function R(){for(;S<g.length;){var T=g[S];return S++,n._dbInfo=null,n._ready=null,n.getDriver(T).then(l).catch(R)}c();var C=new Error("No available storage method found.");return n._driverSet=p.reject(C),n._driverSet}return R()}}var v=this._driverSet!==null?this._driverSet.catch(function(){return p.resolve()}):p.resolve();return this._driverSet=v.then(function(){var g=u[0];return n._dbInfo=null,n._ready=null,n.getDriver(g).then(function(S){n._driver=S._driver,c(),n._wrapLibraryMethodsWithReady(),n._initDriver=d(u)})}).catch(function(){c();var g=new Error("No available storage method found.");return n._driverSet=p.reject(g),n._driverSet}),P(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!er[r]},e.prototype._extend=function(r){Ie(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var u=r[i];this.supports(u)&&o.push(u)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Ee.length;r<o;r++)at(this,Ee[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),ut=new ft;m.exports=ut},{3:3}]},{},[4])(4)})});var F={};tr(F,{Magic:()=>Ut});module.exports=_t(F);var ye=require("@magic-sdk/provider"),he=gt(or());var Pe={};tr(Pe,{_driver:()=>Ne,_initStorage:()=>It,_support:()=>Ct,clear:()=>xt,dropInstance:()=>At,getItem:()=>Rt,iterate:()=>Tt,key:()=>Dt,keys:()=>Ot,length:()=>Bt,removeItem:()=>Nt,setItem:()=>Pt});function ir(f){var a=typeof Symbol=="function"&&Symbol.iterator,s=a&&f[a],h=0;if(s)return s.call(f);if(f&&typeof f.length=="number")return{next:function(){return f&&h>=f.length&&(f=void 0),{value:f&&f[h++],done:!f}}};throw new TypeError(a?"Object is not iterable.":"Symbol.iterator is not defined.")}function bt(f,a){f=f||[],a=a||{};try{return new Blob(f,a)}catch(_){if(_.name!=="TypeError")throw _;for(var s=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,h=new s,m=0;m<f.length;m+=1)h.append(f[m]);return h.getBlob(a.type)}}var ar=/^~~local_forage_type~([^~]+)~/,Te=9,fr=Te+4,ur=Object.prototype.toString;function sr(f){var a=f.length*.75,s=f.length;f[f.length-1]==="="&&(a--,f[f.length-2]==="="&&a--);for(var h=new ArrayBuffer(a),m=new Uint8Array(h),_=0,b=0;_<s;_+=4){var x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[_]),I="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[_+1]),O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[_+2]),B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[_+3]);m[b++]=x<<2|I>>4,m[b++]=(I&15)<<4|O>>2,m[b++]=(O&3)<<6|B&63}return h}function De(f){for(var a=new Uint8Array(f),s="",h=0;h<a.length;h+=3)s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[h]>>2],s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[h]&3)<<4|a[h+1]>>4],s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[h+1]&15)<<2|a[h+2]>>6],s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[h+2]&63];return a.length%3===2?s=s.substring(0,s.length-1)+"=":a.length%3===1&&(s=s.substring(0,s.length-2)+"=="),s}function wt(f,a){var s="";if(f&&(s=ur.call(f)),f&&(s==="[object ArrayBuffer]"||f.buffer&&ur.call(f.buffer)==="[object ArrayBuffer]")){var h=void 0,m="__lfsc__:";f instanceof ArrayBuffer?(h=f,m+="arbf"):(h=f.buffer,s==="[object Int8Array]"?m+="si08":s==="[object Uint8Array]"?m+="ui08":s==="[object Uint8ClampedArray]"?m+="uic8":s==="[object Int16Array]"?m+="si16":s==="[object Uint16Array]"?m+="ur16":s==="[object Int32Array]"?m+="si32":s==="[object Uint32Array]"?m+="ui32":s==="[object Float32Array]"?m+="fl32":s==="[object Float64Array]"?m+="fl64":a(new Error("Failed to get type for BinaryArray"))),a(m+De(h))}else if(s==="[object Blob]"){var _=new FileReader;_.onload=function(){var b="~~local_forage_type~"+f.type+"~"+De(this.result);a("__lfsc__:blob"+b)},_.readAsArrayBuffer(f)}else try{a(JSON.stringify(f))}catch(b){console.error("Couldn't convert value into a JSON string: ",f),a(null,b)}}function St(f){if(f.substring(0,Te)!=="__lfsc__:")return JSON.parse(f);var a=f.substring(fr),s=f.substring(Te,fr),h;if(s==="blob"&&ar.test(a)){var m=a.match(ar);h=m[1],a=a.substring(m[0].length)}var _=sr(a);switch(s){case"arbf":return _;case"blob":return bt([_],{type:h});case"si08":return new Int8Array(_);case"ui08":return new Uint8Array(_);case"uic8":return new Uint8ClampedArray(_);case"si16":return new Int16Array(_);case"ur16":return new Uint16Array(_);case"si32":return new Int32Array(_);case"ui32":return new Uint32Array(_);case"fl32":return new Float32Array(_);case"fl64":return new Float64Array(_);default:throw new Error("Unkown type: "+s)}}function Oe(f){var a,s;if(f===null||typeof f!="object"||"isActiveClone"in f)return f;var h=f instanceof Date?new Date(f):f.constructor();try{for(var m=ir(Object.keys(f)),_=m.next();!_.done;_=m.next()){var b=_.value;Object.prototype.hasOwnProperty.call(f,b)&&(f.isActiveClone=null,h[b]=Oe(f[b]),delete f.isActiveClone)}}catch(x){a={error:x}}finally{try{_&&!_.done&&(s=m.return)&&s.call(m)}finally{if(a)throw a.error}}return h}function Be(f,a){return(f.name||a.name)+"/"+(f.storeName||a.storeName)+"/"}function Q(f,a){a&&f.then(function(s){a(null,s)},function(s){a(s)})}function Et(){for(var f=[],a=0;a<arguments.length;a++)f[a]=arguments[a];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function cr(f,a){var s=this;if(a=Et.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var h=this.config();f.name=f.name||h.name,f.storeName=f.storeName||h.storeName}var m;return f.name?m=new Promise(function(_){f.storeName?_(Be(f,s._defaultConfig)):_(f.name+"/")}):m=Promise.reject("Invalid arguments"),{promise:m,callback:a}}function le(f){return typeof f!="string"&&(console.warn(f+" used as a key, but it is not a string."),f=String(f)),f}var lr={bufferToString:De,deserialize:St,serialize:wt,stringToBuffer:sr};var Ne="localforage-driver-memory",de={},dr=function(){function f(a){this.kp=a,this.data={}}return f.resolve=function(a){return de[a]||(de[a]=new f(a)),de[a]},f.prototype.clear=function(){this.data={}},f.prototype.drop=function(){this.clear(),delete de[this.kp]},f.prototype.get=function(a){return this.data[a]},f.prototype.key=function(a){return this.keys()[a]},f.prototype.keys=function(){return Object.keys(this.data)},f.prototype.rm=function(a){delete this.data[a]},f.prototype.set=function(a,s){this.data[a]=s},f}();function It(f){var a=f?Oe(f):{},s=Be(a,this._defaultConfig),h=dr.resolve(s);return this._dbInfo=a,this._dbInfo.serializer=lr,this._dbInfo.keyPrefix=s,this._dbInfo.mStore=h,Promise.resolve()}function xt(f){var a=this,s=this.ready().then(function(){a._dbInfo.mStore.clear()});return Q(s,f),s}function At(f,a){var s=cr.apply(this,arguments),h=s.promise,m=s.callback,_=h.then(function(b){dr.resolve(b).drop()});return Q(_,m),h}function Rt(f,a){var s=this;f=le(f);var h=this.ready().then(function(){var m=s._dbInfo.mStore.get(f);return m==null?null:s._dbInfo.serializer.deserialize(m)});return Q(h,a),h}function Tt(f,a){var s=this,h=this.ready().then(function(){for(var m=s._dbInfo.mStore,_=m.keys(),b=0;b<_.length;b++){var x=m.get(_[b]);if(x&&(x=s._dbInfo.serializer.deserialize(x)),x=f(x,_[b],b+1),x!==void 0)return x}});return Q(h,a),h}function Dt(f,a){var s=this,h=this.ready().then(function(){var m;try{m=s._dbInfo.mStore.key(f),m===void 0&&(m=null)}catch{m=null}return m});return Q(h,a),h}function Ot(f){var a=this,s=this.ready().then(function(){return a._dbInfo.mStore.keys()});return Q(s,f),s}function Bt(f){var a=this.keys().then(function(s){return s.length});return Q(a,f),a}function Nt(f,a){var s=this;f=le(f);var h=this.ready().then(function(){s._dbInfo.mStore.rm(f)});return Q(h,a),h}function Pt(f,a,s){var h=this;f=le(f);var m=this.ready().then(function(){a===void 0&&(a=null);var _=a;return new Promise(function(b,x){h._dbInfo.serializer.serialize(a,function(I,O){if(O)x(O);else try{h._dbInfo.mStore.set(f,I),b(_)}catch(B){x(B)}})})});return Q(m,s),m}var Ct=!0;var Z=require("@magic-sdk/provider"),Ce=require("@magic-sdk/types"),Lt={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function Mt(f){for(let[a,s]of Object.entries(Lt))f.style[a]=s}function Ft(f){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(s=>s.src.includes(f))}var ve=class extends Z.ViewController{activeElement=null;iframe;relayerSrc=(0,Z.createURL)(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(a=>{let s=()=>{if(Ft(encodeURIComponent(this.parameters)))(0,Z.createDuplicateIframeWarning)().log();else{let h=document.createElement("iframe");h.classList.add("magic-iframe"),h.dataset.magicIframeLabel=(0,Z.createURL)(this.endpoint).host,h.title="Secure Modal",h.src=this.relayerSrc,h.allow="clipboard-read; clipboard-write",Mt(h),document.body.appendChild(h),a(h)}};["loaded","interactive","complete"].includes(document.readyState)?s():window.addEventListener("load",s,!1)}),this.iframe.then(a=>{a instanceof HTMLIFrameElement&&a.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",a=>{if(a.origin===this.endpoint&&a.data.msgType){if(a.data.msgType.includes(Ce.MagicIncomingWindowMessage.MAGIC_PONG))this.lastPongTime=Date.now();else if(a.data.msgType.includes(Ce.MagicIncomingWindowMessage.MAGIC_THIRD_PARTY_WALLET_REQUEST)){this.thirdPartyWalletRequestHandler(a.data);return}if(a.data&&this.messageHandlers.size){a.data.response=a.data.response??{},this.stopHeartBeat();for(let s of this.messageHandlers.values())s(a)}}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let a=await this.iframe;a.style.display="block",a.style.zIndex="2147483647",a.style.opacity="1",this.activeElement=document.activeElement,a.focus()}async hideOverlay(){let a=await this.iframe;a.style.display="none",a.style.zIndex="-1",a.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(a){let s=await this.iframe;if(s&&s.contentWindow)s.contentWindow.postMessage(a,this.endpoint);else throw(0,Z.createModalNotReadyError)()}async checkRelayerExistsInDOM(){let a=await this.iframe;return!a||!a.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(h=>h.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let a=await this.iframe;if(this.stopHeartBeat(),!a){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!a.contentWindow){document.body.appendChild(a),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}a&&(a.src=this.relayerSrc)}};W(F,require("@magic-sdk/provider"),module.exports);W(F,require("@magic-sdk/types"),module.exports);var Ut=(0,ye.createSDK)(ye.SDKBase,{platform:"web",sdkName:"magic-sdk",version:"33.7.0",defaultEndpoint:"https://auth.magic.link/",ViewController:ve,configureStorage:async()=>{let f=he.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await f.defineDriver(Pe),await f.setDriver([he.default.INDEXEDDB,he.default.LOCALSTORAGE,Ne]),f}});
1
+ "use strict";var dt=Object.create;var ce=Object.defineProperty;var vt=Object.getOwnPropertyDescriptor;var ht=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,mt=Object.prototype.hasOwnProperty;var pt=(f,a)=>()=>(a||f((a={exports:{}}).exports,a),a.exports),tr=(f,a)=>{for(var s in a)ce(f,s,{get:a[s],enumerable:!0})},se=(f,a,s,h)=>{if(a&&typeof a=="object"||typeof a=="function")for(let m of ht(a))!mt.call(f,m)&&m!==s&&ce(f,m,{get:()=>a[m],enumerable:!(h=vt(a,m))||h.enumerable});return f},W=(f,a,s)=>(se(f,a,"default"),s&&se(s,a,"default")),gt=(f,a,s)=>(s=f!=null?dt(yt(f)):{},se(a||!f||!f.__esModule?ce(s,"default",{value:f,enumerable:!0}):s,f)),_t=f=>se(ce({},"__esModule",{value:!0}),f);var or=pt((nr,Re)=>{"use strict";(function(f){if(typeof nr=="object"&&typeof Re<"u")Re.exports=f();else if(typeof define=="function"&&define.amd)define([],f);else{var a;typeof window<"u"?a=window:typeof global<"u"?a=global:typeof self<"u"?a=self:a=this,a.localforage=f()}})(function(){var f,a,s;return function h(m,_,b){function x(B,G){if(!_[B]){if(!m[B]){var p=typeof require=="function"&&require;if(!G&&p)return p(B,!0);if(I)return I(B,!0);var w=new Error("Cannot find module '"+B+"'");throw w.code="MODULE_NOT_FOUND",w}var P=_[B]={exports:{}};m[B][0].call(P.exports,function(L){var V=m[B][1][L];return x(V||L)},P,P.exports,h,m,_,b)}return _[B].exports}for(var I=typeof require=="function"&&require,O=0;O<b.length;O++)x(b[O]);return x}({1:[function(h,m,_){(function(b){"use strict";var x=b.MutationObserver||b.WebKitMutationObserver,I;if(x){var O=0,B=new x(L),G=b.document.createTextNode("");B.observe(G,{characterData:!0}),I=function(){G.data=O=++O%2}}else if(!b.setImmediate&&typeof b.MessageChannel<"u"){var p=new b.MessageChannel;p.port1.onmessage=L,I=function(){p.port2.postMessage(0)}}else"document"in b&&"onreadystatechange"in b.document.createElement("script")?I=function(){var M=b.document.createElement("script");M.onreadystatechange=function(){L(),M.onreadystatechange=null,M.parentNode.removeChild(M),M=null},b.document.documentElement.appendChild(M)}:I=function(){setTimeout(L,0)};var w,P=[];function L(){w=!0;for(var M,X,U=P.length;U;){for(X=P,P=[],M=-1;++M<U;)X[M]();U=P.length}w=!1}m.exports=V;function V(M){P.push(M)===1&&!w&&I()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(h,m,_){"use strict";var b=h(1);function x(){}var I={},O=["REJECTED"],B=["FULFILLED"],G=["PENDING"];m.exports=p;function p(y){if(typeof y!="function")throw new TypeError("resolver must be a function");this.state=G,this.queue=[],this.outcome=void 0,y!==x&&V(this,y)}p.prototype.catch=function(y){return this.then(null,y)},p.prototype.then=function(y,A){if(typeof y!="function"&&this.state===B||typeof A!="function"&&this.state===O)return this;var E=new this.constructor(x);if(this.state!==G){var D=this.state===B?y:A;P(E,D,this.outcome)}else this.queue.push(new w(E,y,A));return E};function w(y,A,E){this.promise=y,typeof A=="function"&&(this.onFulfilled=A,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}w.prototype.callFulfilled=function(y){I.resolve(this.promise,y)},w.prototype.otherCallFulfilled=function(y){P(this.promise,this.onFulfilled,y)},w.prototype.callRejected=function(y){I.reject(this.promise,y)},w.prototype.otherCallRejected=function(y){P(this.promise,this.onRejected,y)};function P(y,A,E){b(function(){var D;try{D=A(E)}catch(z){return I.reject(y,z)}D===y?I.reject(y,new TypeError("Cannot resolve promise with itself")):I.resolve(y,D)})}I.resolve=function(y,A){var E=M(L,A);if(E.status==="error")return I.reject(y,E.value);var D=E.value;if(D)V(y,D);else{y.state=B,y.outcome=A;for(var z=-1,Y=y.queue.length;++z<Y;)y.queue[z].callFulfilled(A)}return y},I.reject=function(y,A){y.state=O,y.outcome=A;for(var E=-1,D=y.queue.length;++E<D;)y.queue[E].callRejected(A);return y};function L(y){var A=y&&y.then;if(y&&(typeof y=="object"||typeof y=="function")&&typeof A=="function")return function(){A.apply(y,arguments)}}function V(y,A){var E=!1;function D(K){E||(E=!0,I.reject(y,K))}function z(K){E||(E=!0,I.resolve(y,K))}function Y(){A(z,D)}var j=M(Y);j.status==="error"&&D(j.value)}function M(y,A){var E={};try{E.value=y(A),E.status="success"}catch(D){E.status="error",E.value=D}return E}p.resolve=X;function X(y){return y instanceof this?y:I.resolve(new this(x),y)}p.reject=U;function U(y){var A=new this(x);return I.reject(A,y)}p.all=me;function me(y){var A=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=y.length,D=!1;if(!E)return this.resolve([]);for(var z=new Array(E),Y=0,j=-1,K=new this(x);++j<E;)J(y[j],j);return K;function J(ne,ae){A.resolve(ne).then(pe,function(re){D||(D=!0,I.reject(K,re))});function pe(re){z[ae]=re,++Y===E&&!D&&(D=!0,I.resolve(K,z))}}}p.race=ee;function ee(y){var A=this;if(Object.prototype.toString.call(y)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=y.length,D=!1;if(!E)return this.resolve([]);for(var z=-1,Y=new this(x);++z<E;)j(y[z]);return Y;function j(K){A.resolve(K).then(function(J){D||(D=!0,I.resolve(Y,J))},function(J){D||(D=!0,I.reject(Y,J))})}}},{1:1}],3:[function(h,m,_){(function(b){"use strict";typeof b.Promise!="function"&&(b.Promise=h(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(h,m,_){"use strict";var b=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 x(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function I(){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 O=I();function B(){try{if(!O||!O.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 G(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"&&h(3);var p=Promise;function w(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function P(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function L(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function V(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var M="local-forage-detect-blob-support",X=void 0,U={},me=Object.prototype.toString,ee="readonly",y="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 p(function(t){var r=e.transaction(M,y),o=G([""]);r.objectStore(M).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 D(e){return typeof X=="boolean"?p.resolve(X):E(e).then(function(t){return X=t,X})}function z(e){var t=U[e.name],r={};r.promise=new p(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 Y(e){var t=U[e.name],r=t.deferredOperations.pop();if(r)return r.resolve(),r.promise}function j(e,t){var r=U[e.name],o=r.deferredOperations.pop();if(o)return o.reject(t),o.promise}function K(e,t){return new p(function(r,o){if(U[e.name]=U[e.name]||Me(),e.db)if(t)z(e),e.db.close();else return r(e.db);var i=[e.name];t&&i.push(e.version);var n=O.open.apply(O,i);t&&(n.onupgradeneeded=function(u){var c=n.result;try{c.createObjectStore(e.storeName),u.oldVersion<=1&&c.createObjectStore(M)}catch(l){if(l.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+u.oldVersion+" to version "+u.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw l}}),n.onerror=function(u){u.preventDefault(),o(n.error)},n.onsuccess=function(){var u=n.result;u.onversionchange=function(c){c.target.close()},r(u),Y(e)}})}function J(e){return K(e,!1)}function ne(e){return K(e,!0)}function ae(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 pe(e){return new p(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 re(e){var t=A(atob(e.data));return G([t],{type:e.type})}function Le(e){return e&&e.__local_forage_encoded_blob}function vr(e){var t=this,r=t._initReady().then(function(){var o=U[t._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return P(r,e,e),r}function hr(e){z(e);for(var t=U[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,J(e).then(function(n){return e.db=n,ae(e)?ne(e):n}).then(function(n){e.db=t.db=n;for(var u=0;u<r.length;u++)r[u]._dbInfo.db=n}).catch(function(n){throw j(e,n),n})}function $(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 p.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),ne(e)}).then(function(){return hr(e).then(function(){$(e,t,r,o-1)})}).catch(r);r(n)}}function Me(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function yr(e){var t=this,r={db:null};if(e)for(var o in e)r[o]=e[o];var i=U[r.name];i||(i=Me(),U[r.name]=i),i.forages.push(t),t._initReady||(t._initReady=t.ready,t.ready=vr);var n=[];function u(){return p.resolve()}for(var c=0;c<i.forages.length;c++){var l=i.forages[c];l!==t&&n.push(l._initReady().catch(u))}var d=i.forages.slice(0);return p.all(n).then(function(){return r.db=i.db,J(r)}).then(function(v){return r.db=v,ae(r,t._defaultConfig.version)?ne(r):v}).then(function(v){r.db=i.db=v,t._dbInfo=r;for(var g=0;g<d.length;g++){var S=d[g];S!==t&&(S._dbInfo.db=r.db,S._dbInfo.version=r.version)}})}function mr(e,t){var r=this;e=L(e);var o=new p(function(i,n){r.ready().then(function(){$(r._dbInfo,ee,function(u,c){if(u)return n(u);try{var l=c.objectStore(r._dbInfo.storeName),d=l.get(e);d.onsuccess=function(){var v=d.result;v===void 0&&(v=null),Le(v)&&(v=re(v)),i(v)},d.onerror=function(){n(d.error)}}catch(v){n(v)}})}).catch(n)});return w(o,t),o}function pr(e,t){var r=this,o=new p(function(i,n){r.ready().then(function(){$(r._dbInfo,ee,function(u,c){if(u)return n(u);try{var l=c.objectStore(r._dbInfo.storeName),d=l.openCursor(),v=1;d.onsuccess=function(){var g=d.result;if(g){var S=g.value;Le(S)&&(S=re(S));var R=e(S,g.key,v++);R!==void 0?i(R):g.continue()}else i()},d.onerror=function(){n(d.error)}}catch(g){n(g)}})}).catch(n)});return w(o,t),o}function gr(e,t,r){var o=this;e=L(e);var i=new p(function(n,u){var c;o.ready().then(function(){return c=o._dbInfo,me.call(t)==="[object Blob]"?D(c.db).then(function(l){return l?t:pe(t)}):t}).then(function(l){$(o._dbInfo,y,function(d,v){if(d)return u(d);try{var g=v.objectStore(o._dbInfo.storeName);l===null&&(l=void 0);var S=g.put(l,e);v.oncomplete=function(){l===void 0&&(l=null),n(l)},v.onabort=v.onerror=function(){var R=S.error?S.error:S.transaction.error;u(R)}}catch(R){u(R)}})}).catch(u)});return w(i,r),i}function _r(e,t){var r=this;e=L(e);var o=new p(function(i,n){r.ready().then(function(){$(r._dbInfo,y,function(u,c){if(u)return n(u);try{var l=c.objectStore(r._dbInfo.storeName),d=l.delete(e);c.oncomplete=function(){i()},c.onerror=function(){n(d.error)},c.onabort=function(){var v=d.error?d.error:d.transaction.error;n(v)}}catch(v){n(v)}})}).catch(n)});return w(o,t),o}function br(e){var t=this,r=new p(function(o,i){t.ready().then(function(){$(t._dbInfo,y,function(n,u){if(n)return i(n);try{var c=u.objectStore(t._dbInfo.storeName),l=c.clear();u.oncomplete=function(){o()},u.onabort=u.onerror=function(){var d=l.error?l.error:l.transaction.error;i(d)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function wr(e){var t=this,r=new p(function(o,i){t.ready().then(function(){$(t._dbInfo,ee,function(n,u){if(n)return i(n);try{var c=u.objectStore(t._dbInfo.storeName),l=c.count();l.onsuccess=function(){o(l.result)},l.onerror=function(){i(l.error)}}catch(d){i(d)}})}).catch(i)});return w(r,e),r}function Sr(e,t){var r=this,o=new p(function(i,n){if(e<0){i(null);return}r.ready().then(function(){$(r._dbInfo,ee,function(u,c){if(u)return n(u);try{var l=c.objectStore(r._dbInfo.storeName),d=!1,v=l.openKeyCursor();v.onsuccess=function(){var g=v.result;if(!g){i(null);return}e===0||d?i(g.key):(d=!0,g.advance(e))},v.onerror=function(){n(v.error)}}catch(g){n(g)}})}).catch(n)});return w(o,t),o}function Er(e){var t=this,r=new p(function(o,i){t.ready().then(function(){$(t._dbInfo,ee,function(n,u){if(n)return i(n);try{var c=u.objectStore(t._dbInfo.storeName),l=c.openKeyCursor(),d=[];l.onsuccess=function(){var v=l.result;if(!v){o(d);return}d.push(v.key),v.continue()},l.onerror=function(){i(l.error)}}catch(v){i(v)}})}).catch(i)});return w(r,e),r}function Ir(e,t){t=V.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=p.reject("Invalid arguments");else{var n=e.name===r.name&&o._dbInfo.db,u=n?p.resolve(o._dbInfo.db):J(e).then(function(c){var l=U[e.name],d=l.forages;l.db=c;for(var v=0;v<d.length;v++)d[v]._dbInfo.db=c;return c});e.storeName?i=u.then(function(c){if(c.objectStoreNames.contains(e.storeName)){var l=c.version+1;z(e);var d=U[e.name],v=d.forages;c.close();for(var g=0;g<v.length;g++){var S=v[g];S._dbInfo.db=null,S._dbInfo.version=l}var R=new p(function(T,C){var N=O.open(e.name,l);N.onerror=function(H){var ie=N.result;ie.close(),C(H)},N.onupgradeneeded=function(){var H=N.result;H.deleteObjectStore(e.storeName)},N.onsuccess=function(){var H=N.result;H.close(),T(H)}});return R.then(function(T){d.db=T;for(var C=0;C<v.length;C++){var N=v[C];N._dbInfo.db=T,Y(N._dbInfo)}}).catch(function(T){throw(j(e,T)||p.resolve()).catch(function(){}),T})}}):i=u.then(function(c){z(e);var l=U[e.name],d=l.forages;c.close();for(var v=0;v<d.length;v++){var g=d[v];g._dbInfo.db=null}var S=new p(function(R,T){var C=O.deleteDatabase(e.name);C.onerror=function(){var N=C.result;N&&N.close(),T(C.error)},C.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},C.onsuccess=function(){var N=C.result;N&&N.close(),R(N)}});return S.then(function(R){l.db=R;for(var T=0;T<d.length;T++){var C=d[T];Y(C._dbInfo)}}).catch(function(R){throw(j(e,R)||p.resolve()).catch(function(){}),R})})}return w(i,t),i}var xr={_driver:"asyncStorage",_initStorage:yr,_support:B(),iterate:pr,getItem:mr,setItem:gr,removeItem:_r,clear:br,length:wr,key:Sr,keys:Er,dropInstance:Ir};function Ar(){return typeof openDatabase=="function"}var q="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Rr="~~local_forage_type~",Fe=/^~~local_forage_type~([^~]+)~/,fe="__lfsc__:",ge=fe.length,_e="arbf",be="blob",Ue="si08",We="ui08",ze="uic8",Ye="si16",je="si32",Ke="ur16",He="ui32",Ge="fl32",Ve="fl64",Qe=ge+_e.length,Xe=Object.prototype.toString;function Je(e){var t=e.length*.75,r=e.length,o,i=0,n,u,c,l;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);var d=new ArrayBuffer(t),v=new Uint8Array(d);for(o=0;o<r;o+=4)n=q.indexOf(e[o]),u=q.indexOf(e[o+1]),c=q.indexOf(e[o+2]),l=q.indexOf(e[o+3]),v[i++]=n<<2|u>>4,v[i++]=(u&15)<<4|c>>2,v[i++]=(c&3)<<6|l&63;return d}function we(e){var t=new Uint8Array(e),r="",o;for(o=0;o<t.length;o+=3)r+=q[t[o]>>2],r+=q[(t[o]&3)<<4|t[o+1]>>4],r+=q[(t[o+1]&15)<<2|t[o+2]>>6],r+=q[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 Tr(e,t){var r="";if(e&&(r=Xe.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&Xe.call(e.buffer)==="[object ArrayBuffer]")){var o,i=fe;e instanceof ArrayBuffer?(o=e,i+=_e):(o=e.buffer,r==="[object Int8Array]"?i+=Ue:r==="[object Uint8Array]"?i+=We:r==="[object Uint8ClampedArray]"?i+=ze:r==="[object Int16Array]"?i+=Ye:r==="[object Uint16Array]"?i+=Ke:r==="[object Int32Array]"?i+=je:r==="[object Uint32Array]"?i+=He:r==="[object Float32Array]"?i+=Ge:r==="[object Float64Array]"?i+=Ve: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 u=Rr+e.type+"~"+we(this.result);t(fe+be+u)},n.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(u){console.error("Couldn't convert value into a JSON string: ",e),t(null,u)}}function Dr(e){if(e.substring(0,ge)!==fe)return JSON.parse(e);var t=e.substring(Qe),r=e.substring(ge,Qe),o;if(r===be&&Fe.test(t)){var i=t.match(Fe);o=i[1],t=t.substring(i[0].length)}var n=Je(t);switch(r){case _e:return n;case be:return G([n],{type:o});case Ue:return new Int8Array(n);case We:return new Uint8Array(n);case ze:return new Uint8ClampedArray(n);case Ye:return new Int16Array(n);case Ke:return new Uint16Array(n);case je:return new Int32Array(n);case He:return new Uint32Array(n);case Ge:return new Float32Array(n);case Ve:return new Float64Array(n);default:throw new Error("Unkown type: "+r)}}var Se={serialize:Tr,deserialize:Dr,stringToBuffer:Je,bufferToString:we};function $e(e,t,r,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+t.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],r,o)}function Or(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 p(function(n,u){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(c){return u(c)}r.db.transaction(function(c){$e(c,r,function(){t._dbInfo=r,n()},function(l,d){u(d)})},u)});return r.serializer=Se,i}function k(e,t,r,o,i,n){e.executeSql(r,o,i,function(u,c){c.code===c.SYNTAX_ERR?u.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[t.storeName],function(l,d){d.rows.length?n(l,c):$e(l,t,function(){l.executeSql(r,o,i,n)},n)},n):n(u,c)},n)}function Br(e,t){var r=this;e=L(e);var o=new p(function(i,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(c){k(c,u,"SELECT * FROM "+u.storeName+" WHERE key = ? LIMIT 1",[e],function(l,d){var v=d.rows.length?d.rows.item(0).value:null;v&&(v=u.serializer.deserialize(v)),i(v)},function(l,d){n(d)})})}).catch(n)});return w(o,t),o}function Nr(e,t){var r=this,o=new p(function(i,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(c){k(c,u,"SELECT * FROM "+u.storeName,[],function(l,d){for(var v=d.rows,g=v.length,S=0;S<g;S++){var R=v.item(S),T=R.value;if(T&&(T=u.serializer.deserialize(T)),T=e(T,R.key,S+1),T!==void 0){i(T);return}}i()},function(l,d){n(d)})})}).catch(n)});return w(o,t),o}function Ze(e,t,r,o){var i=this;e=L(e);var n=new p(function(u,c){i.ready().then(function(){t===void 0&&(t=null);var l=t,d=i._dbInfo;d.serializer.serialize(t,function(v,g){g?c(g):d.db.transaction(function(S){k(S,d,"INSERT OR REPLACE INTO "+d.storeName+" (key, value) VALUES (?, ?)",[e,v],function(){u(l)},function(R,T){c(T)})},function(S){if(S.code===S.QUOTA_ERR){if(o>0){u(Ze.apply(i,[e,l,r,o-1]));return}c(S)}})})}).catch(c)});return w(n,r),n}function Pr(e,t,r){return Ze.apply(this,[e,t,r,1])}function Cr(e,t){var r=this;e=L(e);var o=new p(function(i,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(c){k(c,u,"DELETE FROM "+u.storeName+" WHERE key = ?",[e],function(){i()},function(l,d){n(d)})})}).catch(n)});return w(o,t),o}function Lr(e){var t=this,r=new p(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(u){k(u,n,"DELETE FROM "+n.storeName,[],function(){o()},function(c,l){i(l)})})}).catch(i)});return w(r,e),r}function Mr(e){var t=this,r=new p(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(u){k(u,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(c,l){var d=l.rows.item(0).c;o(d)},function(c,l){i(l)})})}).catch(i)});return w(r,e),r}function Fr(e,t){var r=this,o=new p(function(i,n){r.ready().then(function(){var u=r._dbInfo;u.db.transaction(function(c){k(c,u,"SELECT key FROM "+u.storeName+" WHERE id = ? LIMIT 1",[e+1],function(l,d){var v=d.rows.length?d.rows.item(0).key:null;i(v)},function(l,d){n(d)})})}).catch(n)});return w(o,t),o}function Ur(e){var t=this,r=new p(function(o,i){t.ready().then(function(){var n=t._dbInfo;n.db.transaction(function(u){k(u,n,"SELECT key FROM "+n.storeName,[],function(c,l){for(var d=[],v=0;v<l.rows.length;v++)d.push(l.rows.item(v).key);o(d)},function(c,l){i(l)})})}).catch(i)});return w(r,e),r}function Wr(e){return new p(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 u=[],c=0;c<n.rows.length;c++)u.push(n.rows.item(c).name);t({db:e,storeNames:u})},function(i,n){r(n)})},function(o){r(o)})})}function zr(e,t){t=V.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 p(function(n){var u;e.name===r.name?u=o._dbInfo.db:u=openDatabase(e.name,"","",0),e.storeName?n({db:u,storeNames:[e.storeName]}):n(Wr(u))}).then(function(n){return new p(function(u,c){n.db.transaction(function(l){function d(R){return new p(function(T,C){l.executeSql("DROP TABLE IF EXISTS "+R,[],function(){T()},function(N,H){C(H)})})}for(var v=[],g=0,S=n.storeNames.length;g<S;g++)v.push(d(n.storeNames[g]));p.all(v).then(function(){u()}).catch(function(R){c(R)})},function(l){c(l)})})}):i=p.reject("Invalid arguments"),w(i,t),i}var Yr={_driver:"webSQLStorage",_initStorage:Or,_support:Ar(),iterate:Nr,getItem:Br,setItem:Pr,removeItem:Cr,clear:Lr,length:Mr,key:Fr,keys:Ur,dropInstance:zr};function jr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function qe(e,t){var r=e.name+"/";return e.storeName!==t.storeName&&(r+=e.storeName+"/"),r}function Kr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function Hr(){return!Kr()||localStorage.length>0}function Gr(e){var t=this,r={};if(e)for(var o in e)r[o]=e[o];return r.keyPrefix=qe(e,t._defaultConfig),Hr()?(t._dbInfo=r,r.serializer=Se,p.resolve()):p.reject()}function Vr(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 Qr(e,t){var r=this;e=L(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 Xr(e,t){var r=this,o=r.ready().then(function(){for(var i=r._dbInfo,n=i.keyPrefix,u=n.length,c=localStorage.length,l=1,d=0;d<c;d++){var v=localStorage.key(d);if(v.indexOf(n)===0){var g=localStorage.getItem(v);if(g&&(g=i.serializer.deserialize(g)),g=e(g,v.substring(u),l++),g!==void 0)return g}}});return w(o,t),o}function Jr(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 $r(e){var t=this,r=t.ready().then(function(){for(var o=t._dbInfo,i=localStorage.length,n=[],u=0;u<i;u++){var c=localStorage.key(u);c.indexOf(o.keyPrefix)===0&&n.push(c.substring(o.keyPrefix.length))}return n});return w(r,e),r}function Zr(e){var t=this,r=t.keys().then(function(o){return o.length});return w(r,e),r}function qr(e,t){var r=this;e=L(e);var o=r.ready().then(function(){var i=r._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return w(o,t),o}function kr(e,t,r){var o=this;e=L(e);var i=o.ready().then(function(){t===void 0&&(t=null);var n=t;return new p(function(u,c){var l=o._dbInfo;l.serializer.serialize(t,function(d,v){if(v)c(v);else try{localStorage.setItem(l.keyPrefix+e,d),u(n)}catch(g){(g.name==="QuotaExceededError"||g.name==="NS_ERROR_DOM_QUOTA_REACHED")&&c(g),c(g)}})})});return w(i,r),i}function et(e,t){if(t=V.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 p(function(n){e.storeName?n(qe(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var u=localStorage.length-1;u>=0;u--){var c=localStorage.key(u);c.indexOf(n)===0&&localStorage.removeItem(c)}}):i=p.reject("Invalid arguments"),w(i,t),i}var rt={_driver:"localStorageWrapper",_initStorage:Gr,_support:jr(),iterate:Xr,getItem:Qr,setItem:kr,removeItem:qr,clear:Vr,length:Zr,key:Jr,keys:$r,dropInstance:et},tt=function(t,r){return t===r||typeof t=="number"&&typeof r=="number"&&isNaN(t)&&isNaN(r)},nt=function(t,r){for(var o=t.length,i=0;i<o;){if(tt(t[i],r))return!0;i++}return!1},ke=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},oe={},er={},te={INDEXEDDB:xr,WEBSQL:Yr,LOCALSTORAGE:rt},ot=[te.INDEXEDDB._driver,te.WEBSQL._driver,te.LOCALSTORAGE._driver],ue=["dropInstance"],Ee=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(ue),it={description:"",driver:ot.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function at(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function Ie(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(ke(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}var ft=function(){function e(t){x(this,e);for(var r in te)if(te.hasOwnProperty(r)){var o=te[r],i=o._driver;this[r]=i,oe[i]||this.defineDriver(o)}this._defaultConfig=Ie({},it),this._config=Ie({},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":b(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 p(function(u,c){try{var l=r._driver,d=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!r._driver){c(d);return}for(var v=Ee.concat("_initStorage"),g=0,S=v.length;g<S;g++){var R=v[g],T=!nt(ue,R);if((T||r[R])&&typeof r[R]!="function"){c(d);return}}var C=function(){for(var ie=function(ct){return function(){var lt=new Error("Method "+ct+" is not implemented by the current driver"),rr=p.reject(lt);return w(rr,arguments[arguments.length-1]),rr}},xe=0,st=ue.length;xe<st;xe++){var Ae=ue[xe];r[Ae]||(r[Ae]=ie(Ae))}};C();var N=function(ie){oe[l]&&console.info("Redefining LocalForage driver: "+l),oe[l]=r,er[l]=ie,u()};"_support"in r?r._support&&typeof r._support=="function"?r._support().then(N,c):N(!!r._support):N(!0)}catch(H){c(H)}});return P(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(r,o,i){var n=oe[r]?p.resolve(oe[r]):p.reject(new Error("Driver not found."));return P(n,o,i),n},e.prototype.getSerializer=function(r){var o=p.resolve(Se);return P(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 P(i,r,r),i},e.prototype.setDriver=function(r,o,i){var n=this;ke(r)||(r=[r]);var u=this._getSupportedDrivers(r);function c(){n._config.driver=n.driver()}function l(g){return n._extend(g),c(),n._ready=n._initStorage(n._config),n._ready}function d(g){return function(){var S=0;function R(){for(;S<g.length;){var T=g[S];return S++,n._dbInfo=null,n._ready=null,n.getDriver(T).then(l).catch(R)}c();var C=new Error("No available storage method found.");return n._driverSet=p.reject(C),n._driverSet}return R()}}var v=this._driverSet!==null?this._driverSet.catch(function(){return p.resolve()}):p.resolve();return this._driverSet=v.then(function(){var g=u[0];return n._dbInfo=null,n._ready=null,n.getDriver(g).then(function(S){n._driver=S._driver,c(),n._wrapLibraryMethodsWithReady(),n._initDriver=d(u)})}).catch(function(){c();var g=new Error("No available storage method found.");return n._driverSet=p.reject(g),n._driverSet}),P(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(r){return!!er[r]},e.prototype._extend=function(r){Ie(this,r)},e.prototype._getSupportedDrivers=function(r){for(var o=[],i=0,n=r.length;i<n;i++){var u=r[i];this.supports(u)&&o.push(u)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var r=0,o=Ee.length;r<o;r++)at(this,Ee[r])},e.prototype.createInstance=function(r){return new e(r)},e}(),ut=new ft;m.exports=ut},{3:3}]},{},[4])(4)})});var F={};tr(F,{Magic:()=>Ut});module.exports=_t(F);var ye=require("@magic-sdk/provider"),he=gt(or());var Pe={};tr(Pe,{_driver:()=>Ne,_initStorage:()=>It,_support:()=>Ct,clear:()=>xt,dropInstance:()=>At,getItem:()=>Rt,iterate:()=>Tt,key:()=>Dt,keys:()=>Ot,length:()=>Bt,removeItem:()=>Nt,setItem:()=>Pt});function ir(f){var a=typeof Symbol=="function"&&Symbol.iterator,s=a&&f[a],h=0;if(s)return s.call(f);if(f&&typeof f.length=="number")return{next:function(){return f&&h>=f.length&&(f=void 0),{value:f&&f[h++],done:!f}}};throw new TypeError(a?"Object is not iterable.":"Symbol.iterator is not defined.")}function bt(f,a){f=f||[],a=a||{};try{return new Blob(f,a)}catch(_){if(_.name!=="TypeError")throw _;for(var s=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,h=new s,m=0;m<f.length;m+=1)h.append(f[m]);return h.getBlob(a.type)}}var ar=/^~~local_forage_type~([^~]+)~/,Te=9,fr=Te+4,ur=Object.prototype.toString;function sr(f){var a=f.length*.75,s=f.length;f[f.length-1]==="="&&(a--,f[f.length-2]==="="&&a--);for(var h=new ArrayBuffer(a),m=new Uint8Array(h),_=0,b=0;_<s;_+=4){var x="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[_]),I="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[_+1]),O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[_+2]),B="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(f[_+3]);m[b++]=x<<2|I>>4,m[b++]=(I&15)<<4|O>>2,m[b++]=(O&3)<<6|B&63}return h}function De(f){for(var a=new Uint8Array(f),s="",h=0;h<a.length;h+=3)s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[h]>>2],s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[h]&3)<<4|a[h+1]>>4],s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(a[h+1]&15)<<2|a[h+2]>>6],s+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[a[h+2]&63];return a.length%3===2?s=s.substring(0,s.length-1)+"=":a.length%3===1&&(s=s.substring(0,s.length-2)+"=="),s}function wt(f,a){var s="";if(f&&(s=ur.call(f)),f&&(s==="[object ArrayBuffer]"||f.buffer&&ur.call(f.buffer)==="[object ArrayBuffer]")){var h=void 0,m="__lfsc__:";f instanceof ArrayBuffer?(h=f,m+="arbf"):(h=f.buffer,s==="[object Int8Array]"?m+="si08":s==="[object Uint8Array]"?m+="ui08":s==="[object Uint8ClampedArray]"?m+="uic8":s==="[object Int16Array]"?m+="si16":s==="[object Uint16Array]"?m+="ur16":s==="[object Int32Array]"?m+="si32":s==="[object Uint32Array]"?m+="ui32":s==="[object Float32Array]"?m+="fl32":s==="[object Float64Array]"?m+="fl64":a(new Error("Failed to get type for BinaryArray"))),a(m+De(h))}else if(s==="[object Blob]"){var _=new FileReader;_.onload=function(){var b="~~local_forage_type~"+f.type+"~"+De(this.result);a("__lfsc__:blob"+b)},_.readAsArrayBuffer(f)}else try{a(JSON.stringify(f))}catch(b){console.error("Couldn't convert value into a JSON string: ",f),a(null,b)}}function St(f){if(f.substring(0,Te)!=="__lfsc__:")return JSON.parse(f);var a=f.substring(fr),s=f.substring(Te,fr),h;if(s==="blob"&&ar.test(a)){var m=a.match(ar);h=m[1],a=a.substring(m[0].length)}var _=sr(a);switch(s){case"arbf":return _;case"blob":return bt([_],{type:h});case"si08":return new Int8Array(_);case"ui08":return new Uint8Array(_);case"uic8":return new Uint8ClampedArray(_);case"si16":return new Int16Array(_);case"ur16":return new Uint16Array(_);case"si32":return new Int32Array(_);case"ui32":return new Uint32Array(_);case"fl32":return new Float32Array(_);case"fl64":return new Float64Array(_);default:throw new Error("Unkown type: "+s)}}function Oe(f){var a,s;if(f===null||typeof f!="object"||"isActiveClone"in f)return f;var h=f instanceof Date?new Date(f):f.constructor();try{for(var m=ir(Object.keys(f)),_=m.next();!_.done;_=m.next()){var b=_.value;Object.prototype.hasOwnProperty.call(f,b)&&(f.isActiveClone=null,h[b]=Oe(f[b]),delete f.isActiveClone)}}catch(x){a={error:x}}finally{try{_&&!_.done&&(s=m.return)&&s.call(m)}finally{if(a)throw a.error}}return h}function Be(f,a){return(f.name||a.name)+"/"+(f.storeName||a.storeName)+"/"}function Q(f,a){a&&f.then(function(s){a(null,s)},function(s){a(s)})}function Et(){for(var f=[],a=0;a<arguments.length;a++)f[a]=arguments[a];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function cr(f,a){var s=this;if(a=Et.apply(this,arguments),f=typeof f!="function"&&f||{},!f.name){var h=this.config();f.name=f.name||h.name,f.storeName=f.storeName||h.storeName}var m;return f.name?m=new Promise(function(_){f.storeName?_(Be(f,s._defaultConfig)):_(f.name+"/")}):m=Promise.reject("Invalid arguments"),{promise:m,callback:a}}function le(f){return typeof f!="string"&&(console.warn(f+" used as a key, but it is not a string."),f=String(f)),f}var lr={bufferToString:De,deserialize:St,serialize:wt,stringToBuffer:sr};var Ne="localforage-driver-memory",de={},dr=function(){function f(a){this.kp=a,this.data={}}return f.resolve=function(a){return de[a]||(de[a]=new f(a)),de[a]},f.prototype.clear=function(){this.data={}},f.prototype.drop=function(){this.clear(),delete de[this.kp]},f.prototype.get=function(a){return this.data[a]},f.prototype.key=function(a){return this.keys()[a]},f.prototype.keys=function(){return Object.keys(this.data)},f.prototype.rm=function(a){delete this.data[a]},f.prototype.set=function(a,s){this.data[a]=s},f}();function It(f){var a=f?Oe(f):{},s=Be(a,this._defaultConfig),h=dr.resolve(s);return this._dbInfo=a,this._dbInfo.serializer=lr,this._dbInfo.keyPrefix=s,this._dbInfo.mStore=h,Promise.resolve()}function xt(f){var a=this,s=this.ready().then(function(){a._dbInfo.mStore.clear()});return Q(s,f),s}function At(f,a){var s=cr.apply(this,arguments),h=s.promise,m=s.callback,_=h.then(function(b){dr.resolve(b).drop()});return Q(_,m),h}function Rt(f,a){var s=this;f=le(f);var h=this.ready().then(function(){var m=s._dbInfo.mStore.get(f);return m==null?null:s._dbInfo.serializer.deserialize(m)});return Q(h,a),h}function Tt(f,a){var s=this,h=this.ready().then(function(){for(var m=s._dbInfo.mStore,_=m.keys(),b=0;b<_.length;b++){var x=m.get(_[b]);if(x&&(x=s._dbInfo.serializer.deserialize(x)),x=f(x,_[b],b+1),x!==void 0)return x}});return Q(h,a),h}function Dt(f,a){var s=this,h=this.ready().then(function(){var m;try{m=s._dbInfo.mStore.key(f),m===void 0&&(m=null)}catch{m=null}return m});return Q(h,a),h}function Ot(f){var a=this,s=this.ready().then(function(){return a._dbInfo.mStore.keys()});return Q(s,f),s}function Bt(f){var a=this.keys().then(function(s){return s.length});return Q(a,f),a}function Nt(f,a){var s=this;f=le(f);var h=this.ready().then(function(){s._dbInfo.mStore.rm(f)});return Q(h,a),h}function Pt(f,a,s){var h=this;f=le(f);var m=this.ready().then(function(){a===void 0&&(a=null);var _=a;return new Promise(function(b,x){h._dbInfo.serializer.serialize(a,function(I,O){if(O)x(O);else try{h._dbInfo.mStore.set(f,I),b(_)}catch(B){x(B)}})})});return Q(m,s),m}var Ct=!0;var Z=require("@magic-sdk/provider"),Ce=require("@magic-sdk/types"),Lt={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function Mt(f){for(let[a,s]of Object.entries(Lt))f.style[a]=s}function Ft(f){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(s=>s.src.includes(f))}var ve=class extends Z.ViewController{activeElement=null;iframe;relayerSrc=(0,Z.createURL)(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(a=>{let s=()=>{if(Ft(encodeURIComponent(this.parameters)))(0,Z.createDuplicateIframeWarning)().log();else{let h=document.createElement("iframe");h.classList.add("magic-iframe"),h.dataset.magicIframeLabel=(0,Z.createURL)(this.endpoint).host,h.title="Secure Modal",h.src=this.relayerSrc,h.allow="clipboard-read; clipboard-write",Mt(h),document.body.appendChild(h),a(h)}};["loaded","interactive","complete"].includes(document.readyState)?s():window.addEventListener("load",s,!1)}),this.iframe.then(a=>{a instanceof HTMLIFrameElement&&a.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",a=>{if(a.origin===this.endpoint&&a.data.msgType){if(a.data.msgType.includes(Ce.MagicIncomingWindowMessage.MAGIC_PONG))this.lastPongTime=Date.now();else if(a.data.msgType.includes(Ce.MagicIncomingWindowMessage.MAGIC_THIRD_PARTY_WALLET_REQUEST)){this.thirdPartyWalletRequestHandler(a.data);return}if(a.data&&this.messageHandlers.size){a.data.response=a.data.response??{},this.stopHeartBeat();for(let s of this.messageHandlers.values())s(a)}}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let a=await this.iframe;a.style.display="block",a.style.zIndex="2147483647",a.style.opacity="1",this.activeElement=document.activeElement,a.focus()}async hideOverlay(){let a=await this.iframe;a.style.display="none",a.style.zIndex="-1",a.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(a){let s=await this.iframe;if(s&&s.contentWindow)s.contentWindow.postMessage(a,this.endpoint);else throw(0,Z.createModalNotReadyError)()}async checkRelayerExistsInDOM(){let a=await this.iframe;return!a||!a.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(h=>h.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let a=await this.iframe;if(this.stopHeartBeat(),!a){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!a.contentWindow){document.body.appendChild(a),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}a&&(a.src=this.relayerSrc)}};W(F,require("@magic-sdk/provider"),module.exports);W(F,require("@magic-sdk/types"),module.exports);var Ut=(0,ye.createSDK)(ye.SDKBase,{platform:"web",sdkName:"magic-sdk",version:"33.7.1",defaultEndpoint:"https://auth.magic.link/",ViewController:ve,configureStorage:async()=>{let f=he.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await f.defineDriver(Pe),await f.setDriver([he.default.INDEXEDDB,he.default.LOCALSTORAGE,Ne]),f}});
2
2
  //# sourceMappingURL=index.js.map
package/dist/es/index.js CHANGED
@@ -1,2 +1,2 @@
1
- var Mr=Object.create;var Ae=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,Wr=Object.prototype.hasOwnProperty;var ae=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(u,n)=>(typeof require<"u"?require:u)[n]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var tt=(i,u)=>()=>(u||i((u={exports:{}}).exports,u),u.exports),zr=(i,u)=>{for(var n in u)Ae(i,n,{get:u[n],enumerable:!0})},Yr=(i,u,n,s)=>{if(u&&typeof u=="object"||typeof u=="function")for(let c of Ur(u))!Wr.call(i,c)&&c!==n&&Ae(i,c,{get:()=>u[c],enumerable:!(s=Fr(u,c))||s.enumerable});return i};var rt=(i,u,n)=>(n=i!=null?Mr(jr(i)):{},Yr(u||!i||!i.__esModule?Ae(n,"default",{value:i,enumerable:!0}):n,i));var at=tt((nt,Re)=>{"use strict";(function(i){if(typeof nt=="object"&&typeof Re<"u")Re.exports=i();else if(typeof define=="function"&&define.amd)define([],i);else{var u;typeof window<"u"?u=window:typeof global<"u"?u=global:typeof self<"u"?u=self:u=this,u.localforage=i()}})(function(){var i,u,n;return function s(c,d,y){function v(O,E){if(!d[O]){if(!c[O]){var g=typeof ae=="function"&&ae;if(!E&&g)return g(O,!0);if(b)return b(O,!0);var I=new Error("Cannot find module '"+O+"'");throw I.code="MODULE_NOT_FOUND",I}var T=d[O]={exports:{}};c[O][0].call(T.exports,function(C){var W=c[O][1][C];return v(W||C)},T,T.exports,s,c,d,y)}return d[O].exports}for(var b=typeof ae=="function"&&ae,A=0;A<y.length;A++)v(y[A]);return v}({1:[function(s,c,d){(function(y){"use strict";var v=y.MutationObserver||y.WebKitMutationObserver,b;if(v){var A=0,O=new v(C),E=y.document.createTextNode("");O.observe(E,{characterData:!0}),b=function(){E.data=A=++A%2}}else if(!y.setImmediate&&typeof y.MessageChannel<"u"){var g=new y.MessageChannel;g.port1.onmessage=C,b=function(){g.port2.postMessage(0)}}else"document"in y&&"onreadystatechange"in y.document.createElement("script")?b=function(){var L=y.document.createElement("script");L.onreadystatechange=function(){C(),L.onreadystatechange=null,L.parentNode.removeChild(L),L=null},y.document.documentElement.appendChild(L)}:b=function(){setTimeout(C,0)};var I,T=[];function C(){I=!0;for(var L,V,U=T.length;U;){for(V=T,T=[],L=-1;++L<U;)V[L]();U=T.length}I=!1}c.exports=W;function W(L){T.push(L)===1&&!I&&b()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(s,c,d){"use strict";var y=s(1);function v(){}var b={},A=["REJECTED"],O=["FULFILLED"],E=["PENDING"];c.exports=g;function g(w){if(typeof w!="function")throw new TypeError("resolver must be a function");this.state=E,this.queue=[],this.outcome=void 0,w!==v&&W(this,w)}g.prototype.catch=function(w){return this.then(null,w)},g.prototype.then=function(w,B){if(typeof w!="function"&&this.state===O||typeof B!="function"&&this.state===A)return this;var D=new this.constructor(v);if(this.state!==E){var P=this.state===O?w:B;T(D,P,this.outcome)}else this.queue.push(new I(D,w,B));return D};function I(w,B,D){this.promise=w,typeof B=="function"&&(this.onFulfilled=B,this.callFulfilled=this.otherCallFulfilled),typeof D=="function"&&(this.onRejected=D,this.callRejected=this.otherCallRejected)}I.prototype.callFulfilled=function(w){b.resolve(this.promise,w)},I.prototype.otherCallFulfilled=function(w){T(this.promise,this.onFulfilled,w)},I.prototype.callRejected=function(w){b.reject(this.promise,w)},I.prototype.otherCallRejected=function(w){T(this.promise,this.onRejected,w)};function T(w,B,D){y(function(){var P;try{P=B(D)}catch(j){return b.reject(w,j)}P===w?b.reject(w,new TypeError("Cannot resolve promise with itself")):b.resolve(w,P)})}b.resolve=function(w,B){var D=L(C,B);if(D.status==="error")return b.reject(w,D.value);var P=D.value;if(P)W(w,P);else{w.state=O,w.outcome=B;for(var j=-1,z=w.queue.length;++j<z;)w.queue[j].callFulfilled(B)}return w},b.reject=function(w,B){w.state=A,w.outcome=B;for(var D=-1,P=w.queue.length;++D<P;)w.queue[D].callRejected(B);return w};function C(w){var B=w&&w.then;if(w&&(typeof w=="object"||typeof w=="function")&&typeof B=="function")return function(){B.apply(w,arguments)}}function W(w,B){var D=!1;function P(K){D||(D=!0,b.reject(w,K))}function j(K){D||(D=!0,b.resolve(w,K))}function z(){B(j,P)}var Y=L(z);Y.status==="error"&&P(Y.value)}function L(w,B){var D={};try{D.value=w(B),D.status="success"}catch(P){D.status="error",D.value=P}return D}g.resolve=V;function V(w){return w instanceof this?w:b.resolve(new this(v),w)}g.reject=U;function U(w){var B=new this(v);return b.reject(B,w)}g.all=he;function he(w){var B=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=w.length,P=!1;if(!D)return this.resolve([]);for(var j=new Array(D),z=0,Y=-1,K=new this(v);++Y<D;)Q(w[Y],Y);return K;function Q(te,oe){B.resolve(te).then(ye,function(q){P||(P=!0,b.reject(K,q))});function ye(q){j[oe]=q,++z===D&&!P&&(P=!0,b.resolve(K,j))}}}g.race=Z;function Z(w){var B=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=w.length,P=!1;if(!D)return this.resolve([]);for(var j=-1,z=new this(v);++j<D;)Y(w[j]);return z;function Y(K){B.resolve(K).then(function(Q){P||(P=!0,b.resolve(z,Q))},function(Q){P||(P=!0,b.reject(z,Q))})}}},{1:1}],3:[function(s,c,d){(function(y){"use strict";typeof y.Promise!="function"&&(y.Promise=s(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(s,c,d){"use strict";var y=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,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function b(){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 A=b();function O(){try{if(!A||!A.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),r=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||r)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function E(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(a){if(a.name!=="TypeError")throw a;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new t,f=0;f<e.length;f+=1)o.append(e[f]);return o.getBlob(r.type)}}typeof Promise>"u"&&s(3);var g=Promise;function I(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function T(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function C(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function W(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var L="local-forage-detect-blob-support",V=void 0,U={},he=Object.prototype.toString,Z="readonly",w="readwrite";function B(e){for(var r=e.length,t=new ArrayBuffer(r),o=new Uint8Array(t),f=0;f<r;f++)o[f]=e.charCodeAt(f);return t}function D(e){return new g(function(r){var t=e.transaction(L,w),o=E([""]);t.objectStore(L).put(o,"key"),t.onabort=function(f){f.preventDefault(),f.stopPropagation(),r(!1)},t.oncomplete=function(){var f=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);r(a||!f||parseInt(f[1],10)>=43)}}).catch(function(){return!1})}function P(e){return typeof V=="boolean"?g.resolve(V):D(e).then(function(r){return V=r,V})}function j(e){var r=U[e.name],t={};t.promise=new g(function(o,f){t.resolve=o,t.reject=f}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function z(e){var r=U[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function Y(e,r){var t=U[e.name],o=t.deferredOperations.pop();if(o)return o.reject(r),o.promise}function K(e,r){return new g(function(t,o){if(U[e.name]=U[e.name]||Le(),e.db)if(r)j(e),e.db.close();else return t(e.db);var f=[e.name];r&&f.push(e.version);var a=A.open.apply(A,f);r&&(a.onupgradeneeded=function(l){var h=a.result;try{h.createObjectStore(e.storeName),l.oldVersion<=1&&h.createObjectStore(L)}catch(m){if(m.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+l.oldVersion+" to version "+l.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw m}}),a.onerror=function(l){l.preventDefault(),o(a.error)},a.onsuccess=function(){var l=a.result;l.onversionchange=function(h){h.target.close()},t(l),z(e)}})}function Q(e){return K(e,!1)}function te(e){return K(e,!0)}function oe(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,f=e.version>e.db.version;if(o&&(e.version!==r&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),f||t){if(t){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function ye(e){return new g(function(r,t){var o=new FileReader;o.onerror=t,o.onloadend=function(f){var a=btoa(f.target.result||"");r({__local_forage_encoded_blob:!0,data:a,type:e.type})},o.readAsBinaryString(e)})}function q(e){var r=B(atob(e.data));return E([r],{type:e.type})}function Ce(e){return e&&e.__local_forage_encoded_blob}function Ft(e){var r=this,t=r._initReady().then(function(){var o=U[r._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(t,e,e),t}function Ut(e){j(e);for(var r=U[e.name],t=r.forages,o=0;o<t.length;o++){var f=t[o];f._dbInfo.db&&(f._dbInfo.db.close(),f._dbInfo.db=null)}return e.db=null,Q(e).then(function(a){return e.db=a,oe(e)?te(e):a}).then(function(a){e.db=r.db=a;for(var l=0;l<t.length;l++)t[l]._dbInfo.db=a}).catch(function(a){throw Y(e,a),a})}function X(e,r,t,o){o===void 0&&(o=1);try{var f=e.db.transaction(e.storeName,r);t(null,f)}catch(a){if(o>0&&(!e.db||a.name==="InvalidStateError"||a.name==="NotFoundError"))return g.resolve().then(function(){if(!e.db||a.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),te(e)}).then(function(){return Ut(e).then(function(){X(e,r,t,o-1)})}).catch(t);t(a)}}function Le(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function jt(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=e[o];var f=U[t.name];f||(f=Le(),U[t.name]=f),f.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=Ft);var a=[];function l(){return g.resolve()}for(var h=0;h<f.forages.length;h++){var m=f.forages[h];m!==r&&a.push(m._initReady().catch(l))}var _=f.forages.slice(0);return g.all(a).then(function(){return t.db=f.db,Q(t)}).then(function(p){return t.db=p,oe(t,r._defaultConfig.version)?te(t):p}).then(function(p){t.db=f.db=p,r._dbInfo=t;for(var S=0;S<_.length;S++){var R=_[S];R!==r&&(R._dbInfo.db=t.db,R._dbInfo.version=t.version)}})}function Wt(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.get(e);_.onsuccess=function(){var p=_.result;p===void 0&&(p=null),Ce(p)&&(p=q(p)),f(p)},_.onerror=function(){a(_.error)}}catch(p){a(p)}})}).catch(a)});return I(o,r),o}function zt(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.openCursor(),p=1;_.onsuccess=function(){var S=_.result;if(S){var R=S.value;Ce(R)&&(R=q(R));var x=e(R,S.key,p++);x!==void 0?f(x):S.continue()}else f()},_.onerror=function(){a(_.error)}}catch(S){a(S)}})}).catch(a)});return I(o,r),o}function Yt(e,r,t){var o=this;e=C(e);var f=new g(function(a,l){var h;o.ready().then(function(){return h=o._dbInfo,he.call(r)==="[object Blob]"?P(h.db).then(function(m){return m?r:ye(r)}):r}).then(function(m){X(o._dbInfo,w,function(_,p){if(_)return l(_);try{var S=p.objectStore(o._dbInfo.storeName);m===null&&(m=void 0);var R=S.put(m,e);p.oncomplete=function(){m===void 0&&(m=null),a(m)},p.onabort=p.onerror=function(){var x=R.error?R.error:R.transaction.error;l(x)}}catch(x){l(x)}})}).catch(l)});return I(f,t),f}function Kt(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,w,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.delete(e);h.oncomplete=function(){f()},h.onerror=function(){a(_.error)},h.onabort=function(){var p=_.error?_.error:_.transaction.error;a(p)}}catch(p){a(p)}})}).catch(a)});return I(o,r),o}function Ht(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,w,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.clear();l.oncomplete=function(){o()},l.onabort=l.onerror=function(){var _=m.error?m.error:m.transaction.error;f(_)}}catch(_){f(_)}})}).catch(f)});return I(t,e),t}function Gt(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,Z,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.count();m.onsuccess=function(){o(m.result)},m.onerror=function(){f(m.error)}}catch(_){f(_)}})}).catch(f)});return I(t,e),t}function Vt(e,r){var t=this,o=new g(function(f,a){if(e<0){f(null);return}t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=!1,p=m.openKeyCursor();p.onsuccess=function(){var S=p.result;if(!S){f(null);return}e===0||_?f(S.key):(_=!0,S.advance(e))},p.onerror=function(){a(p.error)}}catch(S){a(S)}})}).catch(a)});return I(o,r),o}function Qt(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,Z,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.openKeyCursor(),_=[];m.onsuccess=function(){var p=m.result;if(!p){o(_);return}_.push(p.key),p.continue()},m.onerror=function(){f(m.error)}}catch(p){f(p)}})}).catch(f)});return I(t,e),t}function Xt(e,r){r=W.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,f;if(!e.name)f=g.reject("Invalid arguments");else{var a=e.name===t.name&&o._dbInfo.db,l=a?g.resolve(o._dbInfo.db):Q(e).then(function(h){var m=U[e.name],_=m.forages;m.db=h;for(var p=0;p<_.length;p++)_[p]._dbInfo.db=h;return h});e.storeName?f=l.then(function(h){if(h.objectStoreNames.contains(e.storeName)){var m=h.version+1;j(e);var _=U[e.name],p=_.forages;h.close();for(var S=0;S<p.length;S++){var R=p[S];R._dbInfo.db=null,R._dbInfo.version=m}var x=new g(function(N,F){var M=A.open(e.name,m);M.onerror=function(H){var ne=M.result;ne.close(),F(H)},M.onupgradeneeded=function(){var H=M.result;H.deleteObjectStore(e.storeName)},M.onsuccess=function(){var H=M.result;H.close(),N(H)}});return x.then(function(N){_.db=N;for(var F=0;F<p.length;F++){var M=p[F];M._dbInfo.db=N,z(M._dbInfo)}}).catch(function(N){throw(Y(e,N)||g.resolve()).catch(function(){}),N})}}):f=l.then(function(h){j(e);var m=U[e.name],_=m.forages;h.close();for(var p=0;p<_.length;p++){var S=_[p];S._dbInfo.db=null}var R=new g(function(x,N){var F=A.deleteDatabase(e.name);F.onerror=function(){var M=F.result;M&&M.close(),N(F.error)},F.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},F.onsuccess=function(){var M=F.result;M&&M.close(),x(M)}});return R.then(function(x){m.db=x;for(var N=0;N<_.length;N++){var F=_[N];z(F._dbInfo)}}).catch(function(x){throw(Y(e,x)||g.resolve()).catch(function(){}),x})})}return I(f,r),f}var Jt={_driver:"asyncStorage",_initStorage:jt,_support:O(),iterate:zt,getItem:Wt,setItem:Yt,removeItem:Kt,clear:Ht,length:Gt,key:Vt,keys:Qt,dropInstance:Xt};function $t(){return typeof openDatabase=="function"}var J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zt="~~local_forage_type~",Me=/^~~local_forage_type~([^~]+)~/,ie="__lfsc__:",me=ie.length,_e="arbf",pe="blob",Fe="si08",Ue="ui08",je="uic8",We="si16",ze="si32",Ye="ur16",Ke="ui32",He="fl32",Ge="fl64",Ve=me+_e.length,Qe=Object.prototype.toString;function Xe(e){var r=e.length*.75,t=e.length,o,f=0,a,l,h,m;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var _=new ArrayBuffer(r),p=new Uint8Array(_);for(o=0;o<t;o+=4)a=J.indexOf(e[o]),l=J.indexOf(e[o+1]),h=J.indexOf(e[o+2]),m=J.indexOf(e[o+3]),p[f++]=a<<2|l>>4,p[f++]=(l&15)<<4|h>>2,p[f++]=(h&3)<<6|m&63;return _}function ge(e){var r=new Uint8Array(e),t="",o;for(o=0;o<r.length;o+=3)t+=J[r[o]>>2],t+=J[(r[o]&3)<<4|r[o+1]>>4],t+=J[(r[o+1]&15)<<2|r[o+2]>>6],t+=J[r[o+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}function qt(e,r){var t="";if(e&&(t=Qe.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&Qe.call(e.buffer)==="[object ArrayBuffer]")){var o,f=ie;e instanceof ArrayBuffer?(o=e,f+=_e):(o=e.buffer,t==="[object Int8Array]"?f+=Fe:t==="[object Uint8Array]"?f+=Ue:t==="[object Uint8ClampedArray]"?f+=je:t==="[object Int16Array]"?f+=We:t==="[object Uint16Array]"?f+=Ye:t==="[object Int32Array]"?f+=ze:t==="[object Uint32Array]"?f+=Ke:t==="[object Float32Array]"?f+=He:t==="[object Float64Array]"?f+=Ge:r(new Error("Failed to get type for BinaryArray"))),r(f+ge(o))}else if(t==="[object Blob]"){var a=new FileReader;a.onload=function(){var l=Zt+e.type+"~"+ge(this.result);r(ie+pe+l)},a.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(l){console.error("Couldn't convert value into a JSON string: ",e),r(null,l)}}function kt(e){if(e.substring(0,me)!==ie)return JSON.parse(e);var r=e.substring(Ve),t=e.substring(me,Ve),o;if(t===pe&&Me.test(r)){var f=r.match(Me);o=f[1],r=r.substring(f[0].length)}var a=Xe(r);switch(t){case _e:return a;case pe:return E([a],{type:o});case Fe:return new Int8Array(a);case Ue:return new Uint8Array(a);case je:return new Uint8ClampedArray(a);case We:return new Int16Array(a);case Ye:return new Uint16Array(a);case ze:return new Int32Array(a);case Ke:return new Uint32Array(a);case He:return new Float32Array(a);case Ge:return new Float64Array(a);default:throw new Error("Unkown type: "+t)}}var be={serialize:qt,deserialize:kt,stringToBuffer:Xe,bufferToString:ge};function Je(e,r,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function er(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=typeof e[o]!="string"?e[o].toString():e[o];var f=new g(function(a,l){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(h){return l(h)}t.db.transaction(function(h){Je(h,t,function(){r._dbInfo=t,a()},function(m,_){l(_)})},l)});return t.serializer=be,f}function $(e,r,t,o,f,a){e.executeSql(t,o,f,function(l,h){h.code===h.SYNTAX_ERR?l.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(m,_){_.rows.length?a(m,h):Je(m,r,function(){m.executeSql(t,o,f,a)},a)},a):a(l,h)},a)}function tr(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT * FROM "+l.storeName+" WHERE key = ? LIMIT 1",[e],function(m,_){var p=_.rows.length?_.rows.item(0).value:null;p&&(p=l.serializer.deserialize(p)),f(p)},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function rr(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT * FROM "+l.storeName,[],function(m,_){for(var p=_.rows,S=p.length,R=0;R<S;R++){var x=p.item(R),N=x.value;if(N&&(N=l.serializer.deserialize(N)),N=e(N,x.key,R+1),N!==void 0){f(N);return}}f()},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function $e(e,r,t,o){var f=this;e=C(e);var a=new g(function(l,h){f.ready().then(function(){r===void 0&&(r=null);var m=r,_=f._dbInfo;_.serializer.serialize(r,function(p,S){S?h(S):_.db.transaction(function(R){$(R,_,"INSERT OR REPLACE INTO "+_.storeName+" (key, value) VALUES (?, ?)",[e,p],function(){l(m)},function(x,N){h(N)})},function(R){if(R.code===R.QUOTA_ERR){if(o>0){l($e.apply(f,[e,m,t,o-1]));return}h(R)}})})}).catch(h)});return I(a,t),a}function nr(e,r,t){return $e.apply(this,[e,r,t,1])}function ar(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"DELETE FROM "+l.storeName+" WHERE key = ?",[e],function(){f()},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function or(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"DELETE FROM "+a.storeName,[],function(){o()},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function ir(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"SELECT COUNT(key) as c FROM "+a.storeName,[],function(h,m){var _=m.rows.item(0).c;o(_)},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function fr(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT key FROM "+l.storeName+" WHERE id = ? LIMIT 1",[e+1],function(m,_){var p=_.rows.length?_.rows.item(0).key:null;f(p)},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function ur(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"SELECT key FROM "+a.storeName,[],function(h,m){for(var _=[],p=0;p<m.rows.length;p++)_.push(m.rows.item(p).key);o(_)},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function sr(e){return new g(function(r,t){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(f,a){for(var l=[],h=0;h<a.rows.length;h++)l.push(a.rows.item(h).name);r({db:e,storeNames:l})},function(f,a){t(a)})},function(o){t(o)})})}function cr(e,r){r=W.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,f;return e.name?f=new g(function(a){var l;e.name===t.name?l=o._dbInfo.db:l=openDatabase(e.name,"","",0),e.storeName?a({db:l,storeNames:[e.storeName]}):a(sr(l))}).then(function(a){return new g(function(l,h){a.db.transaction(function(m){function _(x){return new g(function(N,F){m.executeSql("DROP TABLE IF EXISTS "+x,[],function(){N()},function(M,H){F(H)})})}for(var p=[],S=0,R=a.storeNames.length;S<R;S++)p.push(_(a.storeNames[S]));g.all(p).then(function(){l()}).catch(function(x){h(x)})},function(m){h(m)})})}):f=g.reject("Invalid arguments"),I(f,r),f}var lr={_driver:"webSQLStorage",_initStorage:er,_support:$t(),iterate:rr,getItem:tr,setItem:nr,removeItem:ar,clear:or,length:ir,key:fr,keys:ur,dropInstance:cr};function dr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ze(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function vr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function hr(){return!vr()||localStorage.length>0}function yr(e){var r=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=Ze(e,r._defaultConfig),hr()?(r._dbInfo=t,t.serializer=be,g.resolve()):g.reject()}function mr(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo.keyPrefix,f=localStorage.length-1;f>=0;f--){var a=localStorage.key(f);a.indexOf(o)===0&&localStorage.removeItem(a)}});return I(t,e),t}function _r(e,r){var t=this;e=C(e);var o=t.ready().then(function(){var f=t._dbInfo,a=localStorage.getItem(f.keyPrefix+e);return a&&(a=f.serializer.deserialize(a)),a});return I(o,r),o}function pr(e,r){var t=this,o=t.ready().then(function(){for(var f=t._dbInfo,a=f.keyPrefix,l=a.length,h=localStorage.length,m=1,_=0;_<h;_++){var p=localStorage.key(_);if(p.indexOf(a)===0){var S=localStorage.getItem(p);if(S&&(S=f.serializer.deserialize(S)),S=e(S,p.substring(l),m++),S!==void 0)return S}}});return I(o,r),o}function gr(e,r){var t=this,o=t.ready().then(function(){var f=t._dbInfo,a;try{a=localStorage.key(e)}catch{a=null}return a&&(a=a.substring(f.keyPrefix.length)),a});return I(o,r),o}function br(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo,f=localStorage.length,a=[],l=0;l<f;l++){var h=localStorage.key(l);h.indexOf(o.keyPrefix)===0&&a.push(h.substring(o.keyPrefix.length))}return a});return I(t,e),t}function wr(e){var r=this,t=r.keys().then(function(o){return o.length});return I(t,e),t}function Sr(e,r){var t=this;e=C(e);var o=t.ready().then(function(){var f=t._dbInfo;localStorage.removeItem(f.keyPrefix+e)});return I(o,r),o}function Er(e,r,t){var o=this;e=C(e);var f=o.ready().then(function(){r===void 0&&(r=null);var a=r;return new g(function(l,h){var m=o._dbInfo;m.serializer.serialize(r,function(_,p){if(p)h(p);else try{localStorage.setItem(m.keyPrefix+e,_),l(a)}catch(S){(S.name==="QuotaExceededError"||S.name==="NS_ERROR_DOM_QUOTA_REACHED")&&h(S),h(S)}})})});return I(f,t),f}function Ir(e,r){if(r=W.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var o=this,f;return e.name?f=new g(function(a){e.storeName?a(Ze(e,o._defaultConfig)):a(e.name+"/")}).then(function(a){for(var l=localStorage.length-1;l>=0;l--){var h=localStorage.key(l);h.indexOf(a)===0&&localStorage.removeItem(h)}}):f=g.reject("Invalid arguments"),I(f,r),f}var Ar={_driver:"localStorageWrapper",_initStorage:yr,_support:dr(),iterate:pr,getItem:_r,setItem:Er,removeItem:Sr,clear:mr,length:wr,key:gr,keys:br,dropInstance:Ir},Rr=function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},Tr=function(r,t){for(var o=r.length,f=0;f<o;){if(Rr(r[f],t))return!0;f++}return!1},qe=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},re={},ke={},k={INDEXEDDB:Jt,WEBSQL:lr,LOCALSTORAGE:Ar},Dr=[k.INDEXEDDB._driver,k.WEBSQL._driver,k.LOCALSTORAGE._driver],fe=["dropInstance"],we=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(fe),Or={description:"",driver:Dr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Br(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function Se(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(qe(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var xr=function(){function e(r){v(this,e);for(var t in k)if(k.hasOwnProperty(t)){var o=k[t],f=o._driver;this[t]=f,re[f]||this.defineDriver(o)}this._defaultConfig=Se({},Or),this._config=Se({},this._defaultConfig,r),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(t){if((typeof t>"u"?"undefined":y(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in t){if(o==="storeName"&&(t[o]=t[o].replace(/\W/g,"_")),o==="version"&&typeof t[o]!="number")return new Error("Database version must be a number.");this._config[o]=t[o]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},e.prototype.defineDriver=function(t,o,f){var a=new g(function(l,h){try{var m=t._driver,_=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){h(_);return}for(var p=we.concat("_initStorage"),S=0,R=p.length;S<R;S++){var x=p[S],N=!Tr(fe,x);if((N||t[x])&&typeof t[x]!="function"){h(_);return}}var F=function(){for(var ne=function(Cr){return function(){var Lr=new Error("Method "+Cr+" is not implemented by the current driver"),et=g.reject(Lr);return I(et,arguments[arguments.length-1]),et}},Ee=0,Pr=fe.length;Ee<Pr;Ee++){var Ie=fe[Ee];t[Ie]||(t[Ie]=ne(Ie))}};F();var M=function(ne){re[m]&&console.info("Redefining LocalForage driver: "+m),re[m]=t,ke[m]=ne,l()};"_support"in t?t._support&&typeof t._support=="function"?t._support().then(M,h):M(!!t._support):M(!0)}catch(H){h(H)}});return T(a,o,f),a},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,o,f){var a=re[t]?g.resolve(re[t]):g.reject(new Error("Driver not found."));return T(a,o,f),a},e.prototype.getSerializer=function(t){var o=g.resolve(be);return T(o,t),o},e.prototype.ready=function(t){var o=this,f=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(f,t,t),f},e.prototype.setDriver=function(t,o,f){var a=this;qe(t)||(t=[t]);var l=this._getSupportedDrivers(t);function h(){a._config.driver=a.driver()}function m(S){return a._extend(S),h(),a._ready=a._initStorage(a._config),a._ready}function _(S){return function(){var R=0;function x(){for(;R<S.length;){var N=S[R];return R++,a._dbInfo=null,a._ready=null,a.getDriver(N).then(m).catch(x)}h();var F=new Error("No available storage method found.");return a._driverSet=g.reject(F),a._driverSet}return x()}}var p=this._driverSet!==null?this._driverSet.catch(function(){return g.resolve()}):g.resolve();return this._driverSet=p.then(function(){var S=l[0];return a._dbInfo=null,a._ready=null,a.getDriver(S).then(function(R){a._driver=R._driver,h(),a._wrapLibraryMethodsWithReady(),a._initDriver=_(l)})}).catch(function(){h();var S=new Error("No available storage method found.");return a._driverSet=g.reject(S),a._driverSet}),T(this._driverSet,o,f),this._driverSet},e.prototype.supports=function(t){return!!ke[t]},e.prototype._extend=function(t){Se(this,t)},e.prototype._getSupportedDrivers=function(t){for(var o=[],f=0,a=t.length;f<a;f++){var l=t[f];this.supports(l)&&o.push(l)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,o=we.length;t<o;t++)Br(this,we[t])},e.prototype.createInstance=function(t){return new e(t)},e}(),Nr=new xr;c.exports=Nr},{3:3}]},{},[4])(4)})});var At=tt((mn,se)=>{"use strict";var ot,it,ft,ut,st,ct,lt,dt,vt,ue,Te,ht,yt,ee,mt,_t,pt,gt,bt,wt,St,Et,It;(function(i){var u=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(s){i(n(u,n(s)))}):typeof se=="object"&&typeof se.exports=="object"?i(n(u,n(se.exports))):i(n(u));function n(s,c){return s!==u&&(typeof Object.create=="function"?Object.defineProperty(s,"__esModule",{value:!0}):s.__esModule=!0),function(d,y){return s[d]=c?c(d,y):y}}})(function(i){var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,s){n.__proto__=s}||function(n,s){for(var c in s)s.hasOwnProperty(c)&&(n[c]=s[c])};ot=function(n,s){u(n,s);function c(){this.constructor=n}n.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)},it=Object.assign||function(n){for(var s,c=1,d=arguments.length;c<d;c++){s=arguments[c];for(var y in s)Object.prototype.hasOwnProperty.call(s,y)&&(n[y]=s[y])}return n},ft=function(n,s){var c={};for(var d in n)Object.prototype.hasOwnProperty.call(n,d)&&s.indexOf(d)<0&&(c[d]=n[d]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var y=0,d=Object.getOwnPropertySymbols(n);y<d.length;y++)s.indexOf(d[y])<0&&Object.prototype.propertyIsEnumerable.call(n,d[y])&&(c[d[y]]=n[d[y]]);return c},ut=function(n,s,c,d){var y=arguments.length,v=y<3?s:d===null?d=Object.getOwnPropertyDescriptor(s,c):d,b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(n,s,c,d);else for(var A=n.length-1;A>=0;A--)(b=n[A])&&(v=(y<3?b(v):y>3?b(s,c,v):b(s,c))||v);return y>3&&v&&Object.defineProperty(s,c,v),v},st=function(n,s){return function(c,d){s(c,d,n)}},ct=function(n,s){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,s)},lt=function(n,s,c,d){function y(v){return v instanceof c?v:new c(function(b){b(v)})}return new(c||(c=Promise))(function(v,b){function A(g){try{E(d.next(g))}catch(I){b(I)}}function O(g){try{E(d.throw(g))}catch(I){b(I)}}function E(g){g.done?v(g.value):y(g.value).then(A,O)}E((d=d.apply(n,s||[])).next())})},dt=function(n,s){var c={label:0,sent:function(){if(v[0]&1)throw v[1];return v[1]},trys:[],ops:[]},d,y,v,b;return b={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function A(E){return function(g){return O([E,g])}}function O(E){if(d)throw new TypeError("Generator is already executing.");for(;c;)try{if(d=1,y&&(v=E[0]&2?y.return:E[0]?y.throw||((v=y.return)&&v.call(y),0):y.next)&&!(v=v.call(y,E[1])).done)return v;switch(y=0,v&&(E=[E[0]&2,v.value]),E[0]){case 0:case 1:v=E;break;case 4:return c.label++,{value:E[1],done:!1};case 5:c.label++,y=E[1],E=[0];continue;case 7:E=c.ops.pop(),c.trys.pop();continue;default:if(v=c.trys,!(v=v.length>0&&v[v.length-1])&&(E[0]===6||E[0]===2)){c=0;continue}if(E[0]===3&&(!v||E[1]>v[0]&&E[1]<v[3])){c.label=E[1];break}if(E[0]===6&&c.label<v[1]){c.label=v[1],v=E;break}if(v&&c.label<v[2]){c.label=v[2],c.ops.push(E);break}v[2]&&c.ops.pop(),c.trys.pop();continue}E=s.call(n,c)}catch(g){E=[6,g],y=0}finally{d=v=0}if(E[0]&5)throw E[1];return{value:E[0]?E[1]:void 0,done:!0}}},It=function(n,s,c,d){d===void 0&&(d=c),n[d]=s[c]},vt=function(n,s){for(var c in n)c!=="default"&&!s.hasOwnProperty(c)&&(s[c]=n[c])},ue=function(n){var s=typeof Symbol=="function"&&Symbol.iterator,c=s&&n[s],d=0;if(c)return c.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&d>=n.length&&(n=void 0),{value:n&&n[d++],done:!n}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")},Te=function(n,s){var c=typeof Symbol=="function"&&n[Symbol.iterator];if(!c)return n;var d=c.call(n),y,v=[],b;try{for(;(s===void 0||s-- >0)&&!(y=d.next()).done;)v.push(y.value)}catch(A){b={error:A}}finally{try{y&&!y.done&&(c=d.return)&&c.call(d)}finally{if(b)throw b.error}}return v},ht=function(){for(var n=[],s=0;s<arguments.length;s++)n=n.concat(Te(arguments[s]));return n},yt=function(){for(var n=0,s=0,c=arguments.length;s<c;s++)n+=arguments[s].length;for(var d=Array(n),y=0,s=0;s<c;s++)for(var v=arguments[s],b=0,A=v.length;b<A;b++,y++)d[y]=v[b];return d},ee=function(n){return this instanceof ee?(this.v=n,this):new ee(n)},mt=function(n,s,c){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var d=c.apply(n,s||[]),y,v=[];return y={},b("next"),b("throw"),b("return"),y[Symbol.asyncIterator]=function(){return this},y;function b(T){d[T]&&(y[T]=function(C){return new Promise(function(W,L){v.push([T,C,W,L])>1||A(T,C)})})}function A(T,C){try{O(d[T](C))}catch(W){I(v[0][3],W)}}function O(T){T.value instanceof ee?Promise.resolve(T.value.v).then(E,g):I(v[0][2],T)}function E(T){A("next",T)}function g(T){A("throw",T)}function I(T,C){T(C),v.shift(),v.length&&A(v[0][0],v[0][1])}},_t=function(n){var s,c;return s={},d("next"),d("throw",function(y){throw y}),d("return"),s[Symbol.iterator]=function(){return this},s;function d(y,v){s[y]=n[y]?function(b){return(c=!c)?{value:ee(n[y](b)),done:y==="return"}:v?v(b):b}:v}},pt=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n[Symbol.asyncIterator],c;return s?s.call(n):(n=typeof ue=="function"?ue(n):n[Symbol.iterator](),c={},d("next"),d("throw"),d("return"),c[Symbol.asyncIterator]=function(){return this},c);function d(v){c[v]=n[v]&&function(b){return new Promise(function(A,O){b=n[v](b),y(A,O,b.done,b.value)})}}function y(v,b,A,O){Promise.resolve(O).then(function(E){v({value:E,done:A})},b)}},gt=function(n,s){return Object.defineProperty?Object.defineProperty(n,"raw",{value:s}):n.raw=s,n},bt=function(n){if(n&&n.__esModule)return n;var s={};if(n!=null)for(var c in n)Object.hasOwnProperty.call(n,c)&&(s[c]=n[c]);return s.default=n,s},wt=function(n){return n&&n.__esModule?n:{default:n}},St=function(n,s){if(!s.has(n))throw new TypeError("attempted to get private field on non-instance");return s.get(n)},Et=function(n,s,c){if(!s.has(n))throw new TypeError("attempted to set private field on non-instance");return s.set(n,c),c},i("__extends",ot),i("__assign",it),i("__rest",ft),i("__decorate",ut),i("__param",st),i("__metadata",ct),i("__awaiter",lt),i("__generator",dt),i("__exportStar",vt),i("__createBinding",It),i("__values",ue),i("__read",Te),i("__spread",ht),i("__spreadArrays",yt),i("__await",ee),i("__asyncGenerator",mt),i("__asyncDelegator",_t),i("__asyncValues",pt),i("__makeTemplateObject",gt),i("__importStar",bt),i("__importDefault",wt),i("__classPrivateFieldGet",St),i("__classPrivateFieldSet",Et)})});var ve=rt(at());import{SDKBase as ln,createSDK as dn}from"@magic-sdk/provider";var Pe={};zr(Pe,{_driver:()=>Ne,_initStorage:()=>Qr,_support:()=>nn,clear:()=>Xr,dropInstance:()=>Jr,getItem:()=>$r,iterate:()=>Zr,key:()=>qr,keys:()=>kr,length:()=>en,removeItem:()=>tn,setItem:()=>rn});var Rt=rt(At(),1),{__extends:_n,__assign:pn,__rest:gn,__decorate:bn,__param:wn,__metadata:Sn,__awaiter:En,__generator:In,__exportStar:An,__createBinding:Rn,__values:Tt,__read:Tn,__spread:Dn,__spreadArrays:On,__await:Bn,__asyncGenerator:xn,__asyncDelegator:Nn,__asyncValues:Pn,__makeTemplateObject:Cn,__importStar:Ln,__importDefault:Mn,__classPrivateFieldGet:Fn,__classPrivateFieldSet:Un}=Rt.default;function Kr(i,u){i=i||[],u=u||{};try{return new Blob(i,u)}catch(d){if(d.name!=="TypeError")throw d;for(var n=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,s=new n,c=0;c<i.length;c+=1)s.append(i[c]);return s.getBlob(u.type)}}var Dt=/^~~local_forage_type~([^~]+)~/,De=9,Ot=De+4,Bt=Object.prototype.toString;function xt(i){var u=i.length*.75,n=i.length;i[i.length-1]==="="&&(u--,i[i.length-2]==="="&&u--);for(var s=new ArrayBuffer(u),c=new Uint8Array(s),d=0,y=0;d<n;d+=4){var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d]),b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+1]),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+2]),O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+3]);c[y++]=v<<2|b>>4,c[y++]=(b&15)<<4|A>>2,c[y++]=(A&3)<<6|O&63}return s}function Oe(i){for(var u=new Uint8Array(i),n="",s=0;s<u.length;s+=3)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[s]>>2],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[s]&3)<<4|u[s+1]>>4],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[s+1]&15)<<2|u[s+2]>>6],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[s+2]&63];return u.length%3===2?n=n.substring(0,n.length-1)+"=":u.length%3===1&&(n=n.substring(0,n.length-2)+"=="),n}function Hr(i,u){var n="";if(i&&(n=Bt.call(i)),i&&(n==="[object ArrayBuffer]"||i.buffer&&Bt.call(i.buffer)==="[object ArrayBuffer]")){var s=void 0,c="__lfsc__:";i instanceof ArrayBuffer?(s=i,c+="arbf"):(s=i.buffer,n==="[object Int8Array]"?c+="si08":n==="[object Uint8Array]"?c+="ui08":n==="[object Uint8ClampedArray]"?c+="uic8":n==="[object Int16Array]"?c+="si16":n==="[object Uint16Array]"?c+="ur16":n==="[object Int32Array]"?c+="si32":n==="[object Uint32Array]"?c+="ui32":n==="[object Float32Array]"?c+="fl32":n==="[object Float64Array]"?c+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(c+Oe(s))}else if(n==="[object Blob]"){var d=new FileReader;d.onload=function(){var y="~~local_forage_type~"+i.type+"~"+Oe(this.result);u("__lfsc__:blob"+y)},d.readAsArrayBuffer(i)}else try{u(JSON.stringify(i))}catch(y){console.error("Couldn't convert value into a JSON string: ",i),u(null,y)}}function Gr(i){if(i.substring(0,De)!=="__lfsc__:")return JSON.parse(i);var u=i.substring(Ot),n=i.substring(De,Ot),s;if(n==="blob"&&Dt.test(u)){var c=u.match(Dt);s=c[1],u=u.substring(c[0].length)}var d=xt(u);switch(n){case"arbf":return d;case"blob":return Kr([d],{type:s});case"si08":return new Int8Array(d);case"ui08":return new Uint8Array(d);case"uic8":return new Uint8ClampedArray(d);case"si16":return new Int16Array(d);case"ur16":return new Uint16Array(d);case"si32":return new Int32Array(d);case"ui32":return new Uint32Array(d);case"fl32":return new Float32Array(d);case"fl64":return new Float64Array(d);default:throw new Error("Unkown type: "+n)}}function Be(i){var u,n;if(i===null||typeof i!="object"||"isActiveClone"in i)return i;var s=i instanceof Date?new Date(i):i.constructor();try{for(var c=Tt(Object.keys(i)),d=c.next();!d.done;d=c.next()){var y=d.value;Object.prototype.hasOwnProperty.call(i,y)&&(i.isActiveClone=null,s[y]=Be(i[y]),delete i.isActiveClone)}}catch(v){u={error:v}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(u)throw u.error}}return s}function xe(i,u){return(i.name||u.name)+"/"+(i.storeName||u.storeName)+"/"}function G(i,u){u&&i.then(function(n){u(null,n)},function(n){u(n)})}function Vr(){for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Nt(i,u){var n=this;if(u=Vr.apply(this,arguments),i=typeof i!="function"&&i||{},!i.name){var s=this.config();i.name=i.name||s.name,i.storeName=i.storeName||s.storeName}var c;return i.name?c=new Promise(function(d){i.storeName?d(xe(i,n._defaultConfig)):d(i.name+"/")}):c=Promise.reject("Invalid arguments"),{promise:c,callback:u}}function ce(i){return typeof i!="string"&&(console.warn(i+" used as a key, but it is not a string."),i=String(i)),i}var Pt={bufferToString:Oe,deserialize:Gr,serialize:Hr,stringToBuffer:xt};var Ne="localforage-driver-memory",le={},Ct=function(){function i(u){this.kp=u,this.data={}}return i.resolve=function(u){return le[u]||(le[u]=new i(u)),le[u]},i.prototype.clear=function(){this.data={}},i.prototype.drop=function(){this.clear(),delete le[this.kp]},i.prototype.get=function(u){return this.data[u]},i.prototype.key=function(u){return this.keys()[u]},i.prototype.keys=function(){return Object.keys(this.data)},i.prototype.rm=function(u){delete this.data[u]},i.prototype.set=function(u,n){this.data[u]=n},i}();function Qr(i){var u=i?Be(i):{},n=xe(u,this._defaultConfig),s=Ct.resolve(n);return this._dbInfo=u,this._dbInfo.serializer=Pt,this._dbInfo.keyPrefix=n,this._dbInfo.mStore=s,Promise.resolve()}function Xr(i){var u=this,n=this.ready().then(function(){u._dbInfo.mStore.clear()});return G(n,i),n}function Jr(i,u){var n=Nt.apply(this,arguments),s=n.promise,c=n.callback,d=s.then(function(y){Ct.resolve(y).drop()});return G(d,c),s}function $r(i,u){var n=this;i=ce(i);var s=this.ready().then(function(){var c=n._dbInfo.mStore.get(i);return c==null?null:n._dbInfo.serializer.deserialize(c)});return G(s,u),s}function Zr(i,u){var n=this,s=this.ready().then(function(){for(var c=n._dbInfo.mStore,d=c.keys(),y=0;y<d.length;y++){var v=c.get(d[y]);if(v&&(v=n._dbInfo.serializer.deserialize(v)),v=i(v,d[y],y+1),v!==void 0)return v}});return G(s,u),s}function qr(i,u){var n=this,s=this.ready().then(function(){var c;try{c=n._dbInfo.mStore.key(i),c===void 0&&(c=null)}catch{c=null}return c});return G(s,u),s}function kr(i){var u=this,n=this.ready().then(function(){return u._dbInfo.mStore.keys()});return G(n,i),n}function en(i){var u=this.keys().then(function(n){return n.length});return G(u,i),u}function tn(i,u){var n=this;i=ce(i);var s=this.ready().then(function(){n._dbInfo.mStore.rm(i)});return G(s,u),s}function rn(i,u,n){var s=this;i=ce(i);var c=this.ready().then(function(){u===void 0&&(u=null);var d=u;return new Promise(function(y,v){s._dbInfo.serializer.serialize(u,function(b,A){if(A)v(A);else try{s._dbInfo.mStore.set(i,b),y(d)}catch(O){v(O)}})})});return G(c,n),c}var nn=!0;import{createDuplicateIframeWarning as an,createModalNotReadyError as on,createURL as Lt,ViewController as fn}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as Mt}from"@magic-sdk/types";var un={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function sn(i){for(let[u,n]of Object.entries(un))i.style[u]=n}function cn(i){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(n=>n.src.includes(i))}var de=class extends fn{activeElement=null;iframe;relayerSrc=Lt(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(u=>{let n=()=>{if(cn(encodeURIComponent(this.parameters)))an().log();else{let s=document.createElement("iframe");s.classList.add("magic-iframe"),s.dataset.magicIframeLabel=Lt(this.endpoint).host,s.title="Secure Modal",s.src=this.relayerSrc,s.allow="clipboard-read; clipboard-write",sn(s),document.body.appendChild(s),u(s)}};["loaded","interactive","complete"].includes(document.readyState)?n():window.addEventListener("load",n,!1)}),this.iframe.then(u=>{u instanceof HTMLIFrameElement&&u.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",u=>{if(u.origin===this.endpoint&&u.data.msgType){if(u.data.msgType.includes(Mt.MAGIC_PONG))this.lastPongTime=Date.now();else if(u.data.msgType.includes(Mt.MAGIC_THIRD_PARTY_WALLET_REQUEST)){this.thirdPartyWalletRequestHandler(u.data);return}if(u.data&&this.messageHandlers.size){u.data.response=u.data.response??{},this.stopHeartBeat();for(let n of this.messageHandlers.values())n(u)}}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let u=await this.iframe;u.style.display="block",u.style.zIndex="2147483647",u.style.opacity="1",this.activeElement=document.activeElement,u.focus()}async hideOverlay(){let u=await this.iframe;u.style.display="none",u.style.zIndex="-1",u.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(u){let n=await this.iframe;if(n&&n.contentWindow)n.contentWindow.postMessage(u,this.endpoint);else throw on()}async checkRelayerExistsInDOM(){let u=await this.iframe;return!u||!u.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(s=>s.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let u=await this.iframe;if(this.stopHeartBeat(),!u){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!u.contentWindow){document.body.appendChild(u),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}u&&(u.src=this.relayerSrc)}};export*from"@magic-sdk/provider";export*from"@magic-sdk/types";var $n=dn(ln,{platform:"web",sdkName:"magic-sdk",version:"33.7.0",defaultEndpoint:"https://auth.magic.link/",ViewController:de,configureStorage:async()=>{let i=ve.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await i.defineDriver(Pe),await i.setDriver([ve.default.INDEXEDDB,ve.default.LOCALSTORAGE,Ne]),i}});export{$n as Magic};
1
+ var Mr=Object.create;var Ae=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,Wr=Object.prototype.hasOwnProperty;var ae=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(u,n)=>(typeof require<"u"?require:u)[n]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var tt=(i,u)=>()=>(u||i((u={exports:{}}).exports,u),u.exports),zr=(i,u)=>{for(var n in u)Ae(i,n,{get:u[n],enumerable:!0})},Yr=(i,u,n,s)=>{if(u&&typeof u=="object"||typeof u=="function")for(let c of Ur(u))!Wr.call(i,c)&&c!==n&&Ae(i,c,{get:()=>u[c],enumerable:!(s=Fr(u,c))||s.enumerable});return i};var rt=(i,u,n)=>(n=i!=null?Mr(jr(i)):{},Yr(u||!i||!i.__esModule?Ae(n,"default",{value:i,enumerable:!0}):n,i));var at=tt((nt,Re)=>{"use strict";(function(i){if(typeof nt=="object"&&typeof Re<"u")Re.exports=i();else if(typeof define=="function"&&define.amd)define([],i);else{var u;typeof window<"u"?u=window:typeof global<"u"?u=global:typeof self<"u"?u=self:u=this,u.localforage=i()}})(function(){var i,u,n;return function s(c,d,y){function v(O,E){if(!d[O]){if(!c[O]){var g=typeof ae=="function"&&ae;if(!E&&g)return g(O,!0);if(b)return b(O,!0);var I=new Error("Cannot find module '"+O+"'");throw I.code="MODULE_NOT_FOUND",I}var T=d[O]={exports:{}};c[O][0].call(T.exports,function(C){var W=c[O][1][C];return v(W||C)},T,T.exports,s,c,d,y)}return d[O].exports}for(var b=typeof ae=="function"&&ae,A=0;A<y.length;A++)v(y[A]);return v}({1:[function(s,c,d){(function(y){"use strict";var v=y.MutationObserver||y.WebKitMutationObserver,b;if(v){var A=0,O=new v(C),E=y.document.createTextNode("");O.observe(E,{characterData:!0}),b=function(){E.data=A=++A%2}}else if(!y.setImmediate&&typeof y.MessageChannel<"u"){var g=new y.MessageChannel;g.port1.onmessage=C,b=function(){g.port2.postMessage(0)}}else"document"in y&&"onreadystatechange"in y.document.createElement("script")?b=function(){var L=y.document.createElement("script");L.onreadystatechange=function(){C(),L.onreadystatechange=null,L.parentNode.removeChild(L),L=null},y.document.documentElement.appendChild(L)}:b=function(){setTimeout(C,0)};var I,T=[];function C(){I=!0;for(var L,V,U=T.length;U;){for(V=T,T=[],L=-1;++L<U;)V[L]();U=T.length}I=!1}c.exports=W;function W(L){T.push(L)===1&&!I&&b()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(s,c,d){"use strict";var y=s(1);function v(){}var b={},A=["REJECTED"],O=["FULFILLED"],E=["PENDING"];c.exports=g;function g(w){if(typeof w!="function")throw new TypeError("resolver must be a function");this.state=E,this.queue=[],this.outcome=void 0,w!==v&&W(this,w)}g.prototype.catch=function(w){return this.then(null,w)},g.prototype.then=function(w,B){if(typeof w!="function"&&this.state===O||typeof B!="function"&&this.state===A)return this;var D=new this.constructor(v);if(this.state!==E){var P=this.state===O?w:B;T(D,P,this.outcome)}else this.queue.push(new I(D,w,B));return D};function I(w,B,D){this.promise=w,typeof B=="function"&&(this.onFulfilled=B,this.callFulfilled=this.otherCallFulfilled),typeof D=="function"&&(this.onRejected=D,this.callRejected=this.otherCallRejected)}I.prototype.callFulfilled=function(w){b.resolve(this.promise,w)},I.prototype.otherCallFulfilled=function(w){T(this.promise,this.onFulfilled,w)},I.prototype.callRejected=function(w){b.reject(this.promise,w)},I.prototype.otherCallRejected=function(w){T(this.promise,this.onRejected,w)};function T(w,B,D){y(function(){var P;try{P=B(D)}catch(j){return b.reject(w,j)}P===w?b.reject(w,new TypeError("Cannot resolve promise with itself")):b.resolve(w,P)})}b.resolve=function(w,B){var D=L(C,B);if(D.status==="error")return b.reject(w,D.value);var P=D.value;if(P)W(w,P);else{w.state=O,w.outcome=B;for(var j=-1,z=w.queue.length;++j<z;)w.queue[j].callFulfilled(B)}return w},b.reject=function(w,B){w.state=A,w.outcome=B;for(var D=-1,P=w.queue.length;++D<P;)w.queue[D].callRejected(B);return w};function C(w){var B=w&&w.then;if(w&&(typeof w=="object"||typeof w=="function")&&typeof B=="function")return function(){B.apply(w,arguments)}}function W(w,B){var D=!1;function P(K){D||(D=!0,b.reject(w,K))}function j(K){D||(D=!0,b.resolve(w,K))}function z(){B(j,P)}var Y=L(z);Y.status==="error"&&P(Y.value)}function L(w,B){var D={};try{D.value=w(B),D.status="success"}catch(P){D.status="error",D.value=P}return D}g.resolve=V;function V(w){return w instanceof this?w:b.resolve(new this(v),w)}g.reject=U;function U(w){var B=new this(v);return b.reject(B,w)}g.all=he;function he(w){var B=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=w.length,P=!1;if(!D)return this.resolve([]);for(var j=new Array(D),z=0,Y=-1,K=new this(v);++Y<D;)Q(w[Y],Y);return K;function Q(te,oe){B.resolve(te).then(ye,function(q){P||(P=!0,b.reject(K,q))});function ye(q){j[oe]=q,++z===D&&!P&&(P=!0,b.resolve(K,j))}}}g.race=Z;function Z(w){var B=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=w.length,P=!1;if(!D)return this.resolve([]);for(var j=-1,z=new this(v);++j<D;)Y(w[j]);return z;function Y(K){B.resolve(K).then(function(Q){P||(P=!0,b.resolve(z,Q))},function(Q){P||(P=!0,b.reject(z,Q))})}}},{1:1}],3:[function(s,c,d){(function(y){"use strict";typeof y.Promise!="function"&&(y.Promise=s(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(s,c,d){"use strict";var y=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,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function b(){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 A=b();function O(){try{if(!A||!A.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),r=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||r)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function E(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(a){if(a.name!=="TypeError")throw a;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new t,f=0;f<e.length;f+=1)o.append(e[f]);return o.getBlob(r.type)}}typeof Promise>"u"&&s(3);var g=Promise;function I(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function T(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function C(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function W(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var L="local-forage-detect-blob-support",V=void 0,U={},he=Object.prototype.toString,Z="readonly",w="readwrite";function B(e){for(var r=e.length,t=new ArrayBuffer(r),o=new Uint8Array(t),f=0;f<r;f++)o[f]=e.charCodeAt(f);return t}function D(e){return new g(function(r){var t=e.transaction(L,w),o=E([""]);t.objectStore(L).put(o,"key"),t.onabort=function(f){f.preventDefault(),f.stopPropagation(),r(!1)},t.oncomplete=function(){var f=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);r(a||!f||parseInt(f[1],10)>=43)}}).catch(function(){return!1})}function P(e){return typeof V=="boolean"?g.resolve(V):D(e).then(function(r){return V=r,V})}function j(e){var r=U[e.name],t={};t.promise=new g(function(o,f){t.resolve=o,t.reject=f}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function z(e){var r=U[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function Y(e,r){var t=U[e.name],o=t.deferredOperations.pop();if(o)return o.reject(r),o.promise}function K(e,r){return new g(function(t,o){if(U[e.name]=U[e.name]||Le(),e.db)if(r)j(e),e.db.close();else return t(e.db);var f=[e.name];r&&f.push(e.version);var a=A.open.apply(A,f);r&&(a.onupgradeneeded=function(l){var h=a.result;try{h.createObjectStore(e.storeName),l.oldVersion<=1&&h.createObjectStore(L)}catch(m){if(m.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+l.oldVersion+" to version "+l.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw m}}),a.onerror=function(l){l.preventDefault(),o(a.error)},a.onsuccess=function(){var l=a.result;l.onversionchange=function(h){h.target.close()},t(l),z(e)}})}function Q(e){return K(e,!1)}function te(e){return K(e,!0)}function oe(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,f=e.version>e.db.version;if(o&&(e.version!==r&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),f||t){if(t){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function ye(e){return new g(function(r,t){var o=new FileReader;o.onerror=t,o.onloadend=function(f){var a=btoa(f.target.result||"");r({__local_forage_encoded_blob:!0,data:a,type:e.type})},o.readAsBinaryString(e)})}function q(e){var r=B(atob(e.data));return E([r],{type:e.type})}function Ce(e){return e&&e.__local_forage_encoded_blob}function Ft(e){var r=this,t=r._initReady().then(function(){var o=U[r._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(t,e,e),t}function Ut(e){j(e);for(var r=U[e.name],t=r.forages,o=0;o<t.length;o++){var f=t[o];f._dbInfo.db&&(f._dbInfo.db.close(),f._dbInfo.db=null)}return e.db=null,Q(e).then(function(a){return e.db=a,oe(e)?te(e):a}).then(function(a){e.db=r.db=a;for(var l=0;l<t.length;l++)t[l]._dbInfo.db=a}).catch(function(a){throw Y(e,a),a})}function X(e,r,t,o){o===void 0&&(o=1);try{var f=e.db.transaction(e.storeName,r);t(null,f)}catch(a){if(o>0&&(!e.db||a.name==="InvalidStateError"||a.name==="NotFoundError"))return g.resolve().then(function(){if(!e.db||a.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),te(e)}).then(function(){return Ut(e).then(function(){X(e,r,t,o-1)})}).catch(t);t(a)}}function Le(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function jt(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=e[o];var f=U[t.name];f||(f=Le(),U[t.name]=f),f.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=Ft);var a=[];function l(){return g.resolve()}for(var h=0;h<f.forages.length;h++){var m=f.forages[h];m!==r&&a.push(m._initReady().catch(l))}var _=f.forages.slice(0);return g.all(a).then(function(){return t.db=f.db,Q(t)}).then(function(p){return t.db=p,oe(t,r._defaultConfig.version)?te(t):p}).then(function(p){t.db=f.db=p,r._dbInfo=t;for(var S=0;S<_.length;S++){var R=_[S];R!==r&&(R._dbInfo.db=t.db,R._dbInfo.version=t.version)}})}function Wt(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.get(e);_.onsuccess=function(){var p=_.result;p===void 0&&(p=null),Ce(p)&&(p=q(p)),f(p)},_.onerror=function(){a(_.error)}}catch(p){a(p)}})}).catch(a)});return I(o,r),o}function zt(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.openCursor(),p=1;_.onsuccess=function(){var S=_.result;if(S){var R=S.value;Ce(R)&&(R=q(R));var x=e(R,S.key,p++);x!==void 0?f(x):S.continue()}else f()},_.onerror=function(){a(_.error)}}catch(S){a(S)}})}).catch(a)});return I(o,r),o}function Yt(e,r,t){var o=this;e=C(e);var f=new g(function(a,l){var h;o.ready().then(function(){return h=o._dbInfo,he.call(r)==="[object Blob]"?P(h.db).then(function(m){return m?r:ye(r)}):r}).then(function(m){X(o._dbInfo,w,function(_,p){if(_)return l(_);try{var S=p.objectStore(o._dbInfo.storeName);m===null&&(m=void 0);var R=S.put(m,e);p.oncomplete=function(){m===void 0&&(m=null),a(m)},p.onabort=p.onerror=function(){var x=R.error?R.error:R.transaction.error;l(x)}}catch(x){l(x)}})}).catch(l)});return I(f,t),f}function Kt(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,w,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.delete(e);h.oncomplete=function(){f()},h.onerror=function(){a(_.error)},h.onabort=function(){var p=_.error?_.error:_.transaction.error;a(p)}}catch(p){a(p)}})}).catch(a)});return I(o,r),o}function Ht(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,w,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.clear();l.oncomplete=function(){o()},l.onabort=l.onerror=function(){var _=m.error?m.error:m.transaction.error;f(_)}}catch(_){f(_)}})}).catch(f)});return I(t,e),t}function Gt(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,Z,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.count();m.onsuccess=function(){o(m.result)},m.onerror=function(){f(m.error)}}catch(_){f(_)}})}).catch(f)});return I(t,e),t}function Vt(e,r){var t=this,o=new g(function(f,a){if(e<0){f(null);return}t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=!1,p=m.openKeyCursor();p.onsuccess=function(){var S=p.result;if(!S){f(null);return}e===0||_?f(S.key):(_=!0,S.advance(e))},p.onerror=function(){a(p.error)}}catch(S){a(S)}})}).catch(a)});return I(o,r),o}function Qt(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,Z,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.openKeyCursor(),_=[];m.onsuccess=function(){var p=m.result;if(!p){o(_);return}_.push(p.key),p.continue()},m.onerror=function(){f(m.error)}}catch(p){f(p)}})}).catch(f)});return I(t,e),t}function Xt(e,r){r=W.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,f;if(!e.name)f=g.reject("Invalid arguments");else{var a=e.name===t.name&&o._dbInfo.db,l=a?g.resolve(o._dbInfo.db):Q(e).then(function(h){var m=U[e.name],_=m.forages;m.db=h;for(var p=0;p<_.length;p++)_[p]._dbInfo.db=h;return h});e.storeName?f=l.then(function(h){if(h.objectStoreNames.contains(e.storeName)){var m=h.version+1;j(e);var _=U[e.name],p=_.forages;h.close();for(var S=0;S<p.length;S++){var R=p[S];R._dbInfo.db=null,R._dbInfo.version=m}var x=new g(function(N,F){var M=A.open(e.name,m);M.onerror=function(H){var ne=M.result;ne.close(),F(H)},M.onupgradeneeded=function(){var H=M.result;H.deleteObjectStore(e.storeName)},M.onsuccess=function(){var H=M.result;H.close(),N(H)}});return x.then(function(N){_.db=N;for(var F=0;F<p.length;F++){var M=p[F];M._dbInfo.db=N,z(M._dbInfo)}}).catch(function(N){throw(Y(e,N)||g.resolve()).catch(function(){}),N})}}):f=l.then(function(h){j(e);var m=U[e.name],_=m.forages;h.close();for(var p=0;p<_.length;p++){var S=_[p];S._dbInfo.db=null}var R=new g(function(x,N){var F=A.deleteDatabase(e.name);F.onerror=function(){var M=F.result;M&&M.close(),N(F.error)},F.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},F.onsuccess=function(){var M=F.result;M&&M.close(),x(M)}});return R.then(function(x){m.db=x;for(var N=0;N<_.length;N++){var F=_[N];z(F._dbInfo)}}).catch(function(x){throw(Y(e,x)||g.resolve()).catch(function(){}),x})})}return I(f,r),f}var Jt={_driver:"asyncStorage",_initStorage:jt,_support:O(),iterate:zt,getItem:Wt,setItem:Yt,removeItem:Kt,clear:Ht,length:Gt,key:Vt,keys:Qt,dropInstance:Xt};function $t(){return typeof openDatabase=="function"}var J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zt="~~local_forage_type~",Me=/^~~local_forage_type~([^~]+)~/,ie="__lfsc__:",me=ie.length,_e="arbf",pe="blob",Fe="si08",Ue="ui08",je="uic8",We="si16",ze="si32",Ye="ur16",Ke="ui32",He="fl32",Ge="fl64",Ve=me+_e.length,Qe=Object.prototype.toString;function Xe(e){var r=e.length*.75,t=e.length,o,f=0,a,l,h,m;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var _=new ArrayBuffer(r),p=new Uint8Array(_);for(o=0;o<t;o+=4)a=J.indexOf(e[o]),l=J.indexOf(e[o+1]),h=J.indexOf(e[o+2]),m=J.indexOf(e[o+3]),p[f++]=a<<2|l>>4,p[f++]=(l&15)<<4|h>>2,p[f++]=(h&3)<<6|m&63;return _}function ge(e){var r=new Uint8Array(e),t="",o;for(o=0;o<r.length;o+=3)t+=J[r[o]>>2],t+=J[(r[o]&3)<<4|r[o+1]>>4],t+=J[(r[o+1]&15)<<2|r[o+2]>>6],t+=J[r[o+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}function qt(e,r){var t="";if(e&&(t=Qe.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&Qe.call(e.buffer)==="[object ArrayBuffer]")){var o,f=ie;e instanceof ArrayBuffer?(o=e,f+=_e):(o=e.buffer,t==="[object Int8Array]"?f+=Fe:t==="[object Uint8Array]"?f+=Ue:t==="[object Uint8ClampedArray]"?f+=je:t==="[object Int16Array]"?f+=We:t==="[object Uint16Array]"?f+=Ye:t==="[object Int32Array]"?f+=ze:t==="[object Uint32Array]"?f+=Ke:t==="[object Float32Array]"?f+=He:t==="[object Float64Array]"?f+=Ge:r(new Error("Failed to get type for BinaryArray"))),r(f+ge(o))}else if(t==="[object Blob]"){var a=new FileReader;a.onload=function(){var l=Zt+e.type+"~"+ge(this.result);r(ie+pe+l)},a.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(l){console.error("Couldn't convert value into a JSON string: ",e),r(null,l)}}function kt(e){if(e.substring(0,me)!==ie)return JSON.parse(e);var r=e.substring(Ve),t=e.substring(me,Ve),o;if(t===pe&&Me.test(r)){var f=r.match(Me);o=f[1],r=r.substring(f[0].length)}var a=Xe(r);switch(t){case _e:return a;case pe:return E([a],{type:o});case Fe:return new Int8Array(a);case Ue:return new Uint8Array(a);case je:return new Uint8ClampedArray(a);case We:return new Int16Array(a);case Ye:return new Uint16Array(a);case ze:return new Int32Array(a);case Ke:return new Uint32Array(a);case He:return new Float32Array(a);case Ge:return new Float64Array(a);default:throw new Error("Unkown type: "+t)}}var be={serialize:qt,deserialize:kt,stringToBuffer:Xe,bufferToString:ge};function Je(e,r,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function er(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=typeof e[o]!="string"?e[o].toString():e[o];var f=new g(function(a,l){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(h){return l(h)}t.db.transaction(function(h){Je(h,t,function(){r._dbInfo=t,a()},function(m,_){l(_)})},l)});return t.serializer=be,f}function $(e,r,t,o,f,a){e.executeSql(t,o,f,function(l,h){h.code===h.SYNTAX_ERR?l.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(m,_){_.rows.length?a(m,h):Je(m,r,function(){m.executeSql(t,o,f,a)},a)},a):a(l,h)},a)}function tr(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT * FROM "+l.storeName+" WHERE key = ? LIMIT 1",[e],function(m,_){var p=_.rows.length?_.rows.item(0).value:null;p&&(p=l.serializer.deserialize(p)),f(p)},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function rr(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT * FROM "+l.storeName,[],function(m,_){for(var p=_.rows,S=p.length,R=0;R<S;R++){var x=p.item(R),N=x.value;if(N&&(N=l.serializer.deserialize(N)),N=e(N,x.key,R+1),N!==void 0){f(N);return}}f()},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function $e(e,r,t,o){var f=this;e=C(e);var a=new g(function(l,h){f.ready().then(function(){r===void 0&&(r=null);var m=r,_=f._dbInfo;_.serializer.serialize(r,function(p,S){S?h(S):_.db.transaction(function(R){$(R,_,"INSERT OR REPLACE INTO "+_.storeName+" (key, value) VALUES (?, ?)",[e,p],function(){l(m)},function(x,N){h(N)})},function(R){if(R.code===R.QUOTA_ERR){if(o>0){l($e.apply(f,[e,m,t,o-1]));return}h(R)}})})}).catch(h)});return I(a,t),a}function nr(e,r,t){return $e.apply(this,[e,r,t,1])}function ar(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"DELETE FROM "+l.storeName+" WHERE key = ?",[e],function(){f()},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function or(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"DELETE FROM "+a.storeName,[],function(){o()},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function ir(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"SELECT COUNT(key) as c FROM "+a.storeName,[],function(h,m){var _=m.rows.item(0).c;o(_)},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function fr(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT key FROM "+l.storeName+" WHERE id = ? LIMIT 1",[e+1],function(m,_){var p=_.rows.length?_.rows.item(0).key:null;f(p)},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function ur(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"SELECT key FROM "+a.storeName,[],function(h,m){for(var _=[],p=0;p<m.rows.length;p++)_.push(m.rows.item(p).key);o(_)},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function sr(e){return new g(function(r,t){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(f,a){for(var l=[],h=0;h<a.rows.length;h++)l.push(a.rows.item(h).name);r({db:e,storeNames:l})},function(f,a){t(a)})},function(o){t(o)})})}function cr(e,r){r=W.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,f;return e.name?f=new g(function(a){var l;e.name===t.name?l=o._dbInfo.db:l=openDatabase(e.name,"","",0),e.storeName?a({db:l,storeNames:[e.storeName]}):a(sr(l))}).then(function(a){return new g(function(l,h){a.db.transaction(function(m){function _(x){return new g(function(N,F){m.executeSql("DROP TABLE IF EXISTS "+x,[],function(){N()},function(M,H){F(H)})})}for(var p=[],S=0,R=a.storeNames.length;S<R;S++)p.push(_(a.storeNames[S]));g.all(p).then(function(){l()}).catch(function(x){h(x)})},function(m){h(m)})})}):f=g.reject("Invalid arguments"),I(f,r),f}var lr={_driver:"webSQLStorage",_initStorage:er,_support:$t(),iterate:rr,getItem:tr,setItem:nr,removeItem:ar,clear:or,length:ir,key:fr,keys:ur,dropInstance:cr};function dr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ze(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function vr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function hr(){return!vr()||localStorage.length>0}function yr(e){var r=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=Ze(e,r._defaultConfig),hr()?(r._dbInfo=t,t.serializer=be,g.resolve()):g.reject()}function mr(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo.keyPrefix,f=localStorage.length-1;f>=0;f--){var a=localStorage.key(f);a.indexOf(o)===0&&localStorage.removeItem(a)}});return I(t,e),t}function _r(e,r){var t=this;e=C(e);var o=t.ready().then(function(){var f=t._dbInfo,a=localStorage.getItem(f.keyPrefix+e);return a&&(a=f.serializer.deserialize(a)),a});return I(o,r),o}function pr(e,r){var t=this,o=t.ready().then(function(){for(var f=t._dbInfo,a=f.keyPrefix,l=a.length,h=localStorage.length,m=1,_=0;_<h;_++){var p=localStorage.key(_);if(p.indexOf(a)===0){var S=localStorage.getItem(p);if(S&&(S=f.serializer.deserialize(S)),S=e(S,p.substring(l),m++),S!==void 0)return S}}});return I(o,r),o}function gr(e,r){var t=this,o=t.ready().then(function(){var f=t._dbInfo,a;try{a=localStorage.key(e)}catch{a=null}return a&&(a=a.substring(f.keyPrefix.length)),a});return I(o,r),o}function br(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo,f=localStorage.length,a=[],l=0;l<f;l++){var h=localStorage.key(l);h.indexOf(o.keyPrefix)===0&&a.push(h.substring(o.keyPrefix.length))}return a});return I(t,e),t}function wr(e){var r=this,t=r.keys().then(function(o){return o.length});return I(t,e),t}function Sr(e,r){var t=this;e=C(e);var o=t.ready().then(function(){var f=t._dbInfo;localStorage.removeItem(f.keyPrefix+e)});return I(o,r),o}function Er(e,r,t){var o=this;e=C(e);var f=o.ready().then(function(){r===void 0&&(r=null);var a=r;return new g(function(l,h){var m=o._dbInfo;m.serializer.serialize(r,function(_,p){if(p)h(p);else try{localStorage.setItem(m.keyPrefix+e,_),l(a)}catch(S){(S.name==="QuotaExceededError"||S.name==="NS_ERROR_DOM_QUOTA_REACHED")&&h(S),h(S)}})})});return I(f,t),f}function Ir(e,r){if(r=W.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var o=this,f;return e.name?f=new g(function(a){e.storeName?a(Ze(e,o._defaultConfig)):a(e.name+"/")}).then(function(a){for(var l=localStorage.length-1;l>=0;l--){var h=localStorage.key(l);h.indexOf(a)===0&&localStorage.removeItem(h)}}):f=g.reject("Invalid arguments"),I(f,r),f}var Ar={_driver:"localStorageWrapper",_initStorage:yr,_support:dr(),iterate:pr,getItem:_r,setItem:Er,removeItem:Sr,clear:mr,length:wr,key:gr,keys:br,dropInstance:Ir},Rr=function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},Tr=function(r,t){for(var o=r.length,f=0;f<o;){if(Rr(r[f],t))return!0;f++}return!1},qe=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},re={},ke={},k={INDEXEDDB:Jt,WEBSQL:lr,LOCALSTORAGE:Ar},Dr=[k.INDEXEDDB._driver,k.WEBSQL._driver,k.LOCALSTORAGE._driver],fe=["dropInstance"],we=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(fe),Or={description:"",driver:Dr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Br(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function Se(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(qe(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var xr=function(){function e(r){v(this,e);for(var t in k)if(k.hasOwnProperty(t)){var o=k[t],f=o._driver;this[t]=f,re[f]||this.defineDriver(o)}this._defaultConfig=Se({},Or),this._config=Se({},this._defaultConfig,r),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(t){if((typeof t>"u"?"undefined":y(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in t){if(o==="storeName"&&(t[o]=t[o].replace(/\W/g,"_")),o==="version"&&typeof t[o]!="number")return new Error("Database version must be a number.");this._config[o]=t[o]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},e.prototype.defineDriver=function(t,o,f){var a=new g(function(l,h){try{var m=t._driver,_=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){h(_);return}for(var p=we.concat("_initStorage"),S=0,R=p.length;S<R;S++){var x=p[S],N=!Tr(fe,x);if((N||t[x])&&typeof t[x]!="function"){h(_);return}}var F=function(){for(var ne=function(Cr){return function(){var Lr=new Error("Method "+Cr+" is not implemented by the current driver"),et=g.reject(Lr);return I(et,arguments[arguments.length-1]),et}},Ee=0,Pr=fe.length;Ee<Pr;Ee++){var Ie=fe[Ee];t[Ie]||(t[Ie]=ne(Ie))}};F();var M=function(ne){re[m]&&console.info("Redefining LocalForage driver: "+m),re[m]=t,ke[m]=ne,l()};"_support"in t?t._support&&typeof t._support=="function"?t._support().then(M,h):M(!!t._support):M(!0)}catch(H){h(H)}});return T(a,o,f),a},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,o,f){var a=re[t]?g.resolve(re[t]):g.reject(new Error("Driver not found."));return T(a,o,f),a},e.prototype.getSerializer=function(t){var o=g.resolve(be);return T(o,t),o},e.prototype.ready=function(t){var o=this,f=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(f,t,t),f},e.prototype.setDriver=function(t,o,f){var a=this;qe(t)||(t=[t]);var l=this._getSupportedDrivers(t);function h(){a._config.driver=a.driver()}function m(S){return a._extend(S),h(),a._ready=a._initStorage(a._config),a._ready}function _(S){return function(){var R=0;function x(){for(;R<S.length;){var N=S[R];return R++,a._dbInfo=null,a._ready=null,a.getDriver(N).then(m).catch(x)}h();var F=new Error("No available storage method found.");return a._driverSet=g.reject(F),a._driverSet}return x()}}var p=this._driverSet!==null?this._driverSet.catch(function(){return g.resolve()}):g.resolve();return this._driverSet=p.then(function(){var S=l[0];return a._dbInfo=null,a._ready=null,a.getDriver(S).then(function(R){a._driver=R._driver,h(),a._wrapLibraryMethodsWithReady(),a._initDriver=_(l)})}).catch(function(){h();var S=new Error("No available storage method found.");return a._driverSet=g.reject(S),a._driverSet}),T(this._driverSet,o,f),this._driverSet},e.prototype.supports=function(t){return!!ke[t]},e.prototype._extend=function(t){Se(this,t)},e.prototype._getSupportedDrivers=function(t){for(var o=[],f=0,a=t.length;f<a;f++){var l=t[f];this.supports(l)&&o.push(l)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,o=we.length;t<o;t++)Br(this,we[t])},e.prototype.createInstance=function(t){return new e(t)},e}(),Nr=new xr;c.exports=Nr},{3:3}]},{},[4])(4)})});var At=tt((mn,se)=>{"use strict";var ot,it,ft,ut,st,ct,lt,dt,vt,ue,Te,ht,yt,ee,mt,_t,pt,gt,bt,wt,St,Et,It;(function(i){var u=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(s){i(n(u,n(s)))}):typeof se=="object"&&typeof se.exports=="object"?i(n(u,n(se.exports))):i(n(u));function n(s,c){return s!==u&&(typeof Object.create=="function"?Object.defineProperty(s,"__esModule",{value:!0}):s.__esModule=!0),function(d,y){return s[d]=c?c(d,y):y}}})(function(i){var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,s){n.__proto__=s}||function(n,s){for(var c in s)s.hasOwnProperty(c)&&(n[c]=s[c])};ot=function(n,s){u(n,s);function c(){this.constructor=n}n.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)},it=Object.assign||function(n){for(var s,c=1,d=arguments.length;c<d;c++){s=arguments[c];for(var y in s)Object.prototype.hasOwnProperty.call(s,y)&&(n[y]=s[y])}return n},ft=function(n,s){var c={};for(var d in n)Object.prototype.hasOwnProperty.call(n,d)&&s.indexOf(d)<0&&(c[d]=n[d]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var y=0,d=Object.getOwnPropertySymbols(n);y<d.length;y++)s.indexOf(d[y])<0&&Object.prototype.propertyIsEnumerable.call(n,d[y])&&(c[d[y]]=n[d[y]]);return c},ut=function(n,s,c,d){var y=arguments.length,v=y<3?s:d===null?d=Object.getOwnPropertyDescriptor(s,c):d,b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(n,s,c,d);else for(var A=n.length-1;A>=0;A--)(b=n[A])&&(v=(y<3?b(v):y>3?b(s,c,v):b(s,c))||v);return y>3&&v&&Object.defineProperty(s,c,v),v},st=function(n,s){return function(c,d){s(c,d,n)}},ct=function(n,s){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,s)},lt=function(n,s,c,d){function y(v){return v instanceof c?v:new c(function(b){b(v)})}return new(c||(c=Promise))(function(v,b){function A(g){try{E(d.next(g))}catch(I){b(I)}}function O(g){try{E(d.throw(g))}catch(I){b(I)}}function E(g){g.done?v(g.value):y(g.value).then(A,O)}E((d=d.apply(n,s||[])).next())})},dt=function(n,s){var c={label:0,sent:function(){if(v[0]&1)throw v[1];return v[1]},trys:[],ops:[]},d,y,v,b;return b={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function A(E){return function(g){return O([E,g])}}function O(E){if(d)throw new TypeError("Generator is already executing.");for(;c;)try{if(d=1,y&&(v=E[0]&2?y.return:E[0]?y.throw||((v=y.return)&&v.call(y),0):y.next)&&!(v=v.call(y,E[1])).done)return v;switch(y=0,v&&(E=[E[0]&2,v.value]),E[0]){case 0:case 1:v=E;break;case 4:return c.label++,{value:E[1],done:!1};case 5:c.label++,y=E[1],E=[0];continue;case 7:E=c.ops.pop(),c.trys.pop();continue;default:if(v=c.trys,!(v=v.length>0&&v[v.length-1])&&(E[0]===6||E[0]===2)){c=0;continue}if(E[0]===3&&(!v||E[1]>v[0]&&E[1]<v[3])){c.label=E[1];break}if(E[0]===6&&c.label<v[1]){c.label=v[1],v=E;break}if(v&&c.label<v[2]){c.label=v[2],c.ops.push(E);break}v[2]&&c.ops.pop(),c.trys.pop();continue}E=s.call(n,c)}catch(g){E=[6,g],y=0}finally{d=v=0}if(E[0]&5)throw E[1];return{value:E[0]?E[1]:void 0,done:!0}}},It=function(n,s,c,d){d===void 0&&(d=c),n[d]=s[c]},vt=function(n,s){for(var c in n)c!=="default"&&!s.hasOwnProperty(c)&&(s[c]=n[c])},ue=function(n){var s=typeof Symbol=="function"&&Symbol.iterator,c=s&&n[s],d=0;if(c)return c.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&d>=n.length&&(n=void 0),{value:n&&n[d++],done:!n}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")},Te=function(n,s){var c=typeof Symbol=="function"&&n[Symbol.iterator];if(!c)return n;var d=c.call(n),y,v=[],b;try{for(;(s===void 0||s-- >0)&&!(y=d.next()).done;)v.push(y.value)}catch(A){b={error:A}}finally{try{y&&!y.done&&(c=d.return)&&c.call(d)}finally{if(b)throw b.error}}return v},ht=function(){for(var n=[],s=0;s<arguments.length;s++)n=n.concat(Te(arguments[s]));return n},yt=function(){for(var n=0,s=0,c=arguments.length;s<c;s++)n+=arguments[s].length;for(var d=Array(n),y=0,s=0;s<c;s++)for(var v=arguments[s],b=0,A=v.length;b<A;b++,y++)d[y]=v[b];return d},ee=function(n){return this instanceof ee?(this.v=n,this):new ee(n)},mt=function(n,s,c){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var d=c.apply(n,s||[]),y,v=[];return y={},b("next"),b("throw"),b("return"),y[Symbol.asyncIterator]=function(){return this},y;function b(T){d[T]&&(y[T]=function(C){return new Promise(function(W,L){v.push([T,C,W,L])>1||A(T,C)})})}function A(T,C){try{O(d[T](C))}catch(W){I(v[0][3],W)}}function O(T){T.value instanceof ee?Promise.resolve(T.value.v).then(E,g):I(v[0][2],T)}function E(T){A("next",T)}function g(T){A("throw",T)}function I(T,C){T(C),v.shift(),v.length&&A(v[0][0],v[0][1])}},_t=function(n){var s,c;return s={},d("next"),d("throw",function(y){throw y}),d("return"),s[Symbol.iterator]=function(){return this},s;function d(y,v){s[y]=n[y]?function(b){return(c=!c)?{value:ee(n[y](b)),done:y==="return"}:v?v(b):b}:v}},pt=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n[Symbol.asyncIterator],c;return s?s.call(n):(n=typeof ue=="function"?ue(n):n[Symbol.iterator](),c={},d("next"),d("throw"),d("return"),c[Symbol.asyncIterator]=function(){return this},c);function d(v){c[v]=n[v]&&function(b){return new Promise(function(A,O){b=n[v](b),y(A,O,b.done,b.value)})}}function y(v,b,A,O){Promise.resolve(O).then(function(E){v({value:E,done:A})},b)}},gt=function(n,s){return Object.defineProperty?Object.defineProperty(n,"raw",{value:s}):n.raw=s,n},bt=function(n){if(n&&n.__esModule)return n;var s={};if(n!=null)for(var c in n)Object.hasOwnProperty.call(n,c)&&(s[c]=n[c]);return s.default=n,s},wt=function(n){return n&&n.__esModule?n:{default:n}},St=function(n,s){if(!s.has(n))throw new TypeError("attempted to get private field on non-instance");return s.get(n)},Et=function(n,s,c){if(!s.has(n))throw new TypeError("attempted to set private field on non-instance");return s.set(n,c),c},i("__extends",ot),i("__assign",it),i("__rest",ft),i("__decorate",ut),i("__param",st),i("__metadata",ct),i("__awaiter",lt),i("__generator",dt),i("__exportStar",vt),i("__createBinding",It),i("__values",ue),i("__read",Te),i("__spread",ht),i("__spreadArrays",yt),i("__await",ee),i("__asyncGenerator",mt),i("__asyncDelegator",_t),i("__asyncValues",pt),i("__makeTemplateObject",gt),i("__importStar",bt),i("__importDefault",wt),i("__classPrivateFieldGet",St),i("__classPrivateFieldSet",Et)})});var ve=rt(at());import{SDKBase as ln,createSDK as dn}from"@magic-sdk/provider";var Pe={};zr(Pe,{_driver:()=>Ne,_initStorage:()=>Qr,_support:()=>nn,clear:()=>Xr,dropInstance:()=>Jr,getItem:()=>$r,iterate:()=>Zr,key:()=>qr,keys:()=>kr,length:()=>en,removeItem:()=>tn,setItem:()=>rn});var Rt=rt(At(),1),{__extends:_n,__assign:pn,__rest:gn,__decorate:bn,__param:wn,__metadata:Sn,__awaiter:En,__generator:In,__exportStar:An,__createBinding:Rn,__values:Tt,__read:Tn,__spread:Dn,__spreadArrays:On,__await:Bn,__asyncGenerator:xn,__asyncDelegator:Nn,__asyncValues:Pn,__makeTemplateObject:Cn,__importStar:Ln,__importDefault:Mn,__classPrivateFieldGet:Fn,__classPrivateFieldSet:Un}=Rt.default;function Kr(i,u){i=i||[],u=u||{};try{return new Blob(i,u)}catch(d){if(d.name!=="TypeError")throw d;for(var n=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,s=new n,c=0;c<i.length;c+=1)s.append(i[c]);return s.getBlob(u.type)}}var Dt=/^~~local_forage_type~([^~]+)~/,De=9,Ot=De+4,Bt=Object.prototype.toString;function xt(i){var u=i.length*.75,n=i.length;i[i.length-1]==="="&&(u--,i[i.length-2]==="="&&u--);for(var s=new ArrayBuffer(u),c=new Uint8Array(s),d=0,y=0;d<n;d+=4){var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d]),b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+1]),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+2]),O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+3]);c[y++]=v<<2|b>>4,c[y++]=(b&15)<<4|A>>2,c[y++]=(A&3)<<6|O&63}return s}function Oe(i){for(var u=new Uint8Array(i),n="",s=0;s<u.length;s+=3)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[s]>>2],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[s]&3)<<4|u[s+1]>>4],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[s+1]&15)<<2|u[s+2]>>6],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[s+2]&63];return u.length%3===2?n=n.substring(0,n.length-1)+"=":u.length%3===1&&(n=n.substring(0,n.length-2)+"=="),n}function Hr(i,u){var n="";if(i&&(n=Bt.call(i)),i&&(n==="[object ArrayBuffer]"||i.buffer&&Bt.call(i.buffer)==="[object ArrayBuffer]")){var s=void 0,c="__lfsc__:";i instanceof ArrayBuffer?(s=i,c+="arbf"):(s=i.buffer,n==="[object Int8Array]"?c+="si08":n==="[object Uint8Array]"?c+="ui08":n==="[object Uint8ClampedArray]"?c+="uic8":n==="[object Int16Array]"?c+="si16":n==="[object Uint16Array]"?c+="ur16":n==="[object Int32Array]"?c+="si32":n==="[object Uint32Array]"?c+="ui32":n==="[object Float32Array]"?c+="fl32":n==="[object Float64Array]"?c+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(c+Oe(s))}else if(n==="[object Blob]"){var d=new FileReader;d.onload=function(){var y="~~local_forage_type~"+i.type+"~"+Oe(this.result);u("__lfsc__:blob"+y)},d.readAsArrayBuffer(i)}else try{u(JSON.stringify(i))}catch(y){console.error("Couldn't convert value into a JSON string: ",i),u(null,y)}}function Gr(i){if(i.substring(0,De)!=="__lfsc__:")return JSON.parse(i);var u=i.substring(Ot),n=i.substring(De,Ot),s;if(n==="blob"&&Dt.test(u)){var c=u.match(Dt);s=c[1],u=u.substring(c[0].length)}var d=xt(u);switch(n){case"arbf":return d;case"blob":return Kr([d],{type:s});case"si08":return new Int8Array(d);case"ui08":return new Uint8Array(d);case"uic8":return new Uint8ClampedArray(d);case"si16":return new Int16Array(d);case"ur16":return new Uint16Array(d);case"si32":return new Int32Array(d);case"ui32":return new Uint32Array(d);case"fl32":return new Float32Array(d);case"fl64":return new Float64Array(d);default:throw new Error("Unkown type: "+n)}}function Be(i){var u,n;if(i===null||typeof i!="object"||"isActiveClone"in i)return i;var s=i instanceof Date?new Date(i):i.constructor();try{for(var c=Tt(Object.keys(i)),d=c.next();!d.done;d=c.next()){var y=d.value;Object.prototype.hasOwnProperty.call(i,y)&&(i.isActiveClone=null,s[y]=Be(i[y]),delete i.isActiveClone)}}catch(v){u={error:v}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(u)throw u.error}}return s}function xe(i,u){return(i.name||u.name)+"/"+(i.storeName||u.storeName)+"/"}function G(i,u){u&&i.then(function(n){u(null,n)},function(n){u(n)})}function Vr(){for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Nt(i,u){var n=this;if(u=Vr.apply(this,arguments),i=typeof i!="function"&&i||{},!i.name){var s=this.config();i.name=i.name||s.name,i.storeName=i.storeName||s.storeName}var c;return i.name?c=new Promise(function(d){i.storeName?d(xe(i,n._defaultConfig)):d(i.name+"/")}):c=Promise.reject("Invalid arguments"),{promise:c,callback:u}}function ce(i){return typeof i!="string"&&(console.warn(i+" used as a key, but it is not a string."),i=String(i)),i}var Pt={bufferToString:Oe,deserialize:Gr,serialize:Hr,stringToBuffer:xt};var Ne="localforage-driver-memory",le={},Ct=function(){function i(u){this.kp=u,this.data={}}return i.resolve=function(u){return le[u]||(le[u]=new i(u)),le[u]},i.prototype.clear=function(){this.data={}},i.prototype.drop=function(){this.clear(),delete le[this.kp]},i.prototype.get=function(u){return this.data[u]},i.prototype.key=function(u){return this.keys()[u]},i.prototype.keys=function(){return Object.keys(this.data)},i.prototype.rm=function(u){delete this.data[u]},i.prototype.set=function(u,n){this.data[u]=n},i}();function Qr(i){var u=i?Be(i):{},n=xe(u,this._defaultConfig),s=Ct.resolve(n);return this._dbInfo=u,this._dbInfo.serializer=Pt,this._dbInfo.keyPrefix=n,this._dbInfo.mStore=s,Promise.resolve()}function Xr(i){var u=this,n=this.ready().then(function(){u._dbInfo.mStore.clear()});return G(n,i),n}function Jr(i,u){var n=Nt.apply(this,arguments),s=n.promise,c=n.callback,d=s.then(function(y){Ct.resolve(y).drop()});return G(d,c),s}function $r(i,u){var n=this;i=ce(i);var s=this.ready().then(function(){var c=n._dbInfo.mStore.get(i);return c==null?null:n._dbInfo.serializer.deserialize(c)});return G(s,u),s}function Zr(i,u){var n=this,s=this.ready().then(function(){for(var c=n._dbInfo.mStore,d=c.keys(),y=0;y<d.length;y++){var v=c.get(d[y]);if(v&&(v=n._dbInfo.serializer.deserialize(v)),v=i(v,d[y],y+1),v!==void 0)return v}});return G(s,u),s}function qr(i,u){var n=this,s=this.ready().then(function(){var c;try{c=n._dbInfo.mStore.key(i),c===void 0&&(c=null)}catch{c=null}return c});return G(s,u),s}function kr(i){var u=this,n=this.ready().then(function(){return u._dbInfo.mStore.keys()});return G(n,i),n}function en(i){var u=this.keys().then(function(n){return n.length});return G(u,i),u}function tn(i,u){var n=this;i=ce(i);var s=this.ready().then(function(){n._dbInfo.mStore.rm(i)});return G(s,u),s}function rn(i,u,n){var s=this;i=ce(i);var c=this.ready().then(function(){u===void 0&&(u=null);var d=u;return new Promise(function(y,v){s._dbInfo.serializer.serialize(u,function(b,A){if(A)v(A);else try{s._dbInfo.mStore.set(i,b),y(d)}catch(O){v(O)}})})});return G(c,n),c}var nn=!0;import{createDuplicateIframeWarning as an,createModalNotReadyError as on,createURL as Lt,ViewController as fn}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as Mt}from"@magic-sdk/types";var un={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function sn(i){for(let[u,n]of Object.entries(un))i.style[u]=n}function cn(i){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(n=>n.src.includes(i))}var de=class extends fn{activeElement=null;iframe;relayerSrc=Lt(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(u=>{let n=()=>{if(cn(encodeURIComponent(this.parameters)))an().log();else{let s=document.createElement("iframe");s.classList.add("magic-iframe"),s.dataset.magicIframeLabel=Lt(this.endpoint).host,s.title="Secure Modal",s.src=this.relayerSrc,s.allow="clipboard-read; clipboard-write",sn(s),document.body.appendChild(s),u(s)}};["loaded","interactive","complete"].includes(document.readyState)?n():window.addEventListener("load",n,!1)}),this.iframe.then(u=>{u instanceof HTMLIFrameElement&&u.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",u=>{if(u.origin===this.endpoint&&u.data.msgType){if(u.data.msgType.includes(Mt.MAGIC_PONG))this.lastPongTime=Date.now();else if(u.data.msgType.includes(Mt.MAGIC_THIRD_PARTY_WALLET_REQUEST)){this.thirdPartyWalletRequestHandler(u.data);return}if(u.data&&this.messageHandlers.size){u.data.response=u.data.response??{},this.stopHeartBeat();for(let n of this.messageHandlers.values())n(u)}}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let u=await this.iframe;u.style.display="block",u.style.zIndex="2147483647",u.style.opacity="1",this.activeElement=document.activeElement,u.focus()}async hideOverlay(){let u=await this.iframe;u.style.display="none",u.style.zIndex="-1",u.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(u){let n=await this.iframe;if(n&&n.contentWindow)n.contentWindow.postMessage(u,this.endpoint);else throw on()}async checkRelayerExistsInDOM(){let u=await this.iframe;return!u||!u.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(s=>s.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let u=await this.iframe;if(this.stopHeartBeat(),!u){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!u.contentWindow){document.body.appendChild(u),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}u&&(u.src=this.relayerSrc)}};export*from"@magic-sdk/provider";export*from"@magic-sdk/types";var $n=dn(ln,{platform:"web",sdkName:"magic-sdk",version:"33.7.1",defaultEndpoint:"https://auth.magic.link/",ViewController:de,configureStorage:async()=>{let i=ve.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await i.defineDriver(Pe),await i.setDriver([ve.default.INDEXEDDB,ve.default.LOCALSTORAGE,Ne]),i}});export{$n as Magic};
2
2
  //# sourceMappingURL=index.js.map
package/dist/es/index.mjs CHANGED
@@ -1,2 +1,2 @@
1
- var Mr=Object.create;var Ae=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,Wr=Object.prototype.hasOwnProperty;var ae=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(u,n)=>(typeof require<"u"?require:u)[n]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var tt=(i,u)=>()=>(u||i((u={exports:{}}).exports,u),u.exports),zr=(i,u)=>{for(var n in u)Ae(i,n,{get:u[n],enumerable:!0})},Yr=(i,u,n,s)=>{if(u&&typeof u=="object"||typeof u=="function")for(let c of Ur(u))!Wr.call(i,c)&&c!==n&&Ae(i,c,{get:()=>u[c],enumerable:!(s=Fr(u,c))||s.enumerable});return i};var rt=(i,u,n)=>(n=i!=null?Mr(jr(i)):{},Yr(u||!i||!i.__esModule?Ae(n,"default",{value:i,enumerable:!0}):n,i));var at=tt((nt,Re)=>{"use strict";(function(i){if(typeof nt=="object"&&typeof Re<"u")Re.exports=i();else if(typeof define=="function"&&define.amd)define([],i);else{var u;typeof window<"u"?u=window:typeof global<"u"?u=global:typeof self<"u"?u=self:u=this,u.localforage=i()}})(function(){var i,u,n;return function s(c,d,y){function v(O,E){if(!d[O]){if(!c[O]){var g=typeof ae=="function"&&ae;if(!E&&g)return g(O,!0);if(b)return b(O,!0);var I=new Error("Cannot find module '"+O+"'");throw I.code="MODULE_NOT_FOUND",I}var T=d[O]={exports:{}};c[O][0].call(T.exports,function(C){var W=c[O][1][C];return v(W||C)},T,T.exports,s,c,d,y)}return d[O].exports}for(var b=typeof ae=="function"&&ae,A=0;A<y.length;A++)v(y[A]);return v}({1:[function(s,c,d){(function(y){"use strict";var v=y.MutationObserver||y.WebKitMutationObserver,b;if(v){var A=0,O=new v(C),E=y.document.createTextNode("");O.observe(E,{characterData:!0}),b=function(){E.data=A=++A%2}}else if(!y.setImmediate&&typeof y.MessageChannel<"u"){var g=new y.MessageChannel;g.port1.onmessage=C,b=function(){g.port2.postMessage(0)}}else"document"in y&&"onreadystatechange"in y.document.createElement("script")?b=function(){var L=y.document.createElement("script");L.onreadystatechange=function(){C(),L.onreadystatechange=null,L.parentNode.removeChild(L),L=null},y.document.documentElement.appendChild(L)}:b=function(){setTimeout(C,0)};var I,T=[];function C(){I=!0;for(var L,V,U=T.length;U;){for(V=T,T=[],L=-1;++L<U;)V[L]();U=T.length}I=!1}c.exports=W;function W(L){T.push(L)===1&&!I&&b()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(s,c,d){"use strict";var y=s(1);function v(){}var b={},A=["REJECTED"],O=["FULFILLED"],E=["PENDING"];c.exports=g;function g(w){if(typeof w!="function")throw new TypeError("resolver must be a function");this.state=E,this.queue=[],this.outcome=void 0,w!==v&&W(this,w)}g.prototype.catch=function(w){return this.then(null,w)},g.prototype.then=function(w,B){if(typeof w!="function"&&this.state===O||typeof B!="function"&&this.state===A)return this;var D=new this.constructor(v);if(this.state!==E){var P=this.state===O?w:B;T(D,P,this.outcome)}else this.queue.push(new I(D,w,B));return D};function I(w,B,D){this.promise=w,typeof B=="function"&&(this.onFulfilled=B,this.callFulfilled=this.otherCallFulfilled),typeof D=="function"&&(this.onRejected=D,this.callRejected=this.otherCallRejected)}I.prototype.callFulfilled=function(w){b.resolve(this.promise,w)},I.prototype.otherCallFulfilled=function(w){T(this.promise,this.onFulfilled,w)},I.prototype.callRejected=function(w){b.reject(this.promise,w)},I.prototype.otherCallRejected=function(w){T(this.promise,this.onRejected,w)};function T(w,B,D){y(function(){var P;try{P=B(D)}catch(j){return b.reject(w,j)}P===w?b.reject(w,new TypeError("Cannot resolve promise with itself")):b.resolve(w,P)})}b.resolve=function(w,B){var D=L(C,B);if(D.status==="error")return b.reject(w,D.value);var P=D.value;if(P)W(w,P);else{w.state=O,w.outcome=B;for(var j=-1,z=w.queue.length;++j<z;)w.queue[j].callFulfilled(B)}return w},b.reject=function(w,B){w.state=A,w.outcome=B;for(var D=-1,P=w.queue.length;++D<P;)w.queue[D].callRejected(B);return w};function C(w){var B=w&&w.then;if(w&&(typeof w=="object"||typeof w=="function")&&typeof B=="function")return function(){B.apply(w,arguments)}}function W(w,B){var D=!1;function P(K){D||(D=!0,b.reject(w,K))}function j(K){D||(D=!0,b.resolve(w,K))}function z(){B(j,P)}var Y=L(z);Y.status==="error"&&P(Y.value)}function L(w,B){var D={};try{D.value=w(B),D.status="success"}catch(P){D.status="error",D.value=P}return D}g.resolve=V;function V(w){return w instanceof this?w:b.resolve(new this(v),w)}g.reject=U;function U(w){var B=new this(v);return b.reject(B,w)}g.all=he;function he(w){var B=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=w.length,P=!1;if(!D)return this.resolve([]);for(var j=new Array(D),z=0,Y=-1,K=new this(v);++Y<D;)Q(w[Y],Y);return K;function Q(te,oe){B.resolve(te).then(ye,function(q){P||(P=!0,b.reject(K,q))});function ye(q){j[oe]=q,++z===D&&!P&&(P=!0,b.resolve(K,j))}}}g.race=Z;function Z(w){var B=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=w.length,P=!1;if(!D)return this.resolve([]);for(var j=-1,z=new this(v);++j<D;)Y(w[j]);return z;function Y(K){B.resolve(K).then(function(Q){P||(P=!0,b.resolve(z,Q))},function(Q){P||(P=!0,b.reject(z,Q))})}}},{1:1}],3:[function(s,c,d){(function(y){"use strict";typeof y.Promise!="function"&&(y.Promise=s(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(s,c,d){"use strict";var y=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,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function b(){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 A=b();function O(){try{if(!A||!A.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),r=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||r)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function E(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(a){if(a.name!=="TypeError")throw a;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new t,f=0;f<e.length;f+=1)o.append(e[f]);return o.getBlob(r.type)}}typeof Promise>"u"&&s(3);var g=Promise;function I(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function T(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function C(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function W(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var L="local-forage-detect-blob-support",V=void 0,U={},he=Object.prototype.toString,Z="readonly",w="readwrite";function B(e){for(var r=e.length,t=new ArrayBuffer(r),o=new Uint8Array(t),f=0;f<r;f++)o[f]=e.charCodeAt(f);return t}function D(e){return new g(function(r){var t=e.transaction(L,w),o=E([""]);t.objectStore(L).put(o,"key"),t.onabort=function(f){f.preventDefault(),f.stopPropagation(),r(!1)},t.oncomplete=function(){var f=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);r(a||!f||parseInt(f[1],10)>=43)}}).catch(function(){return!1})}function P(e){return typeof V=="boolean"?g.resolve(V):D(e).then(function(r){return V=r,V})}function j(e){var r=U[e.name],t={};t.promise=new g(function(o,f){t.resolve=o,t.reject=f}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function z(e){var r=U[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function Y(e,r){var t=U[e.name],o=t.deferredOperations.pop();if(o)return o.reject(r),o.promise}function K(e,r){return new g(function(t,o){if(U[e.name]=U[e.name]||Le(),e.db)if(r)j(e),e.db.close();else return t(e.db);var f=[e.name];r&&f.push(e.version);var a=A.open.apply(A,f);r&&(a.onupgradeneeded=function(l){var h=a.result;try{h.createObjectStore(e.storeName),l.oldVersion<=1&&h.createObjectStore(L)}catch(m){if(m.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+l.oldVersion+" to version "+l.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw m}}),a.onerror=function(l){l.preventDefault(),o(a.error)},a.onsuccess=function(){var l=a.result;l.onversionchange=function(h){h.target.close()},t(l),z(e)}})}function Q(e){return K(e,!1)}function te(e){return K(e,!0)}function oe(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,f=e.version>e.db.version;if(o&&(e.version!==r&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),f||t){if(t){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function ye(e){return new g(function(r,t){var o=new FileReader;o.onerror=t,o.onloadend=function(f){var a=btoa(f.target.result||"");r({__local_forage_encoded_blob:!0,data:a,type:e.type})},o.readAsBinaryString(e)})}function q(e){var r=B(atob(e.data));return E([r],{type:e.type})}function Ce(e){return e&&e.__local_forage_encoded_blob}function Ft(e){var r=this,t=r._initReady().then(function(){var o=U[r._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(t,e,e),t}function Ut(e){j(e);for(var r=U[e.name],t=r.forages,o=0;o<t.length;o++){var f=t[o];f._dbInfo.db&&(f._dbInfo.db.close(),f._dbInfo.db=null)}return e.db=null,Q(e).then(function(a){return e.db=a,oe(e)?te(e):a}).then(function(a){e.db=r.db=a;for(var l=0;l<t.length;l++)t[l]._dbInfo.db=a}).catch(function(a){throw Y(e,a),a})}function X(e,r,t,o){o===void 0&&(o=1);try{var f=e.db.transaction(e.storeName,r);t(null,f)}catch(a){if(o>0&&(!e.db||a.name==="InvalidStateError"||a.name==="NotFoundError"))return g.resolve().then(function(){if(!e.db||a.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),te(e)}).then(function(){return Ut(e).then(function(){X(e,r,t,o-1)})}).catch(t);t(a)}}function Le(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function jt(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=e[o];var f=U[t.name];f||(f=Le(),U[t.name]=f),f.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=Ft);var a=[];function l(){return g.resolve()}for(var h=0;h<f.forages.length;h++){var m=f.forages[h];m!==r&&a.push(m._initReady().catch(l))}var _=f.forages.slice(0);return g.all(a).then(function(){return t.db=f.db,Q(t)}).then(function(p){return t.db=p,oe(t,r._defaultConfig.version)?te(t):p}).then(function(p){t.db=f.db=p,r._dbInfo=t;for(var S=0;S<_.length;S++){var R=_[S];R!==r&&(R._dbInfo.db=t.db,R._dbInfo.version=t.version)}})}function Wt(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.get(e);_.onsuccess=function(){var p=_.result;p===void 0&&(p=null),Ce(p)&&(p=q(p)),f(p)},_.onerror=function(){a(_.error)}}catch(p){a(p)}})}).catch(a)});return I(o,r),o}function zt(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.openCursor(),p=1;_.onsuccess=function(){var S=_.result;if(S){var R=S.value;Ce(R)&&(R=q(R));var x=e(R,S.key,p++);x!==void 0?f(x):S.continue()}else f()},_.onerror=function(){a(_.error)}}catch(S){a(S)}})}).catch(a)});return I(o,r),o}function Yt(e,r,t){var o=this;e=C(e);var f=new g(function(a,l){var h;o.ready().then(function(){return h=o._dbInfo,he.call(r)==="[object Blob]"?P(h.db).then(function(m){return m?r:ye(r)}):r}).then(function(m){X(o._dbInfo,w,function(_,p){if(_)return l(_);try{var S=p.objectStore(o._dbInfo.storeName);m===null&&(m=void 0);var R=S.put(m,e);p.oncomplete=function(){m===void 0&&(m=null),a(m)},p.onabort=p.onerror=function(){var x=R.error?R.error:R.transaction.error;l(x)}}catch(x){l(x)}})}).catch(l)});return I(f,t),f}function Kt(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,w,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.delete(e);h.oncomplete=function(){f()},h.onerror=function(){a(_.error)},h.onabort=function(){var p=_.error?_.error:_.transaction.error;a(p)}}catch(p){a(p)}})}).catch(a)});return I(o,r),o}function Ht(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,w,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.clear();l.oncomplete=function(){o()},l.onabort=l.onerror=function(){var _=m.error?m.error:m.transaction.error;f(_)}}catch(_){f(_)}})}).catch(f)});return I(t,e),t}function Gt(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,Z,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.count();m.onsuccess=function(){o(m.result)},m.onerror=function(){f(m.error)}}catch(_){f(_)}})}).catch(f)});return I(t,e),t}function Vt(e,r){var t=this,o=new g(function(f,a){if(e<0){f(null);return}t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=!1,p=m.openKeyCursor();p.onsuccess=function(){var S=p.result;if(!S){f(null);return}e===0||_?f(S.key):(_=!0,S.advance(e))},p.onerror=function(){a(p.error)}}catch(S){a(S)}})}).catch(a)});return I(o,r),o}function Qt(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,Z,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.openKeyCursor(),_=[];m.onsuccess=function(){var p=m.result;if(!p){o(_);return}_.push(p.key),p.continue()},m.onerror=function(){f(m.error)}}catch(p){f(p)}})}).catch(f)});return I(t,e),t}function Xt(e,r){r=W.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,f;if(!e.name)f=g.reject("Invalid arguments");else{var a=e.name===t.name&&o._dbInfo.db,l=a?g.resolve(o._dbInfo.db):Q(e).then(function(h){var m=U[e.name],_=m.forages;m.db=h;for(var p=0;p<_.length;p++)_[p]._dbInfo.db=h;return h});e.storeName?f=l.then(function(h){if(h.objectStoreNames.contains(e.storeName)){var m=h.version+1;j(e);var _=U[e.name],p=_.forages;h.close();for(var S=0;S<p.length;S++){var R=p[S];R._dbInfo.db=null,R._dbInfo.version=m}var x=new g(function(N,F){var M=A.open(e.name,m);M.onerror=function(H){var ne=M.result;ne.close(),F(H)},M.onupgradeneeded=function(){var H=M.result;H.deleteObjectStore(e.storeName)},M.onsuccess=function(){var H=M.result;H.close(),N(H)}});return x.then(function(N){_.db=N;for(var F=0;F<p.length;F++){var M=p[F];M._dbInfo.db=N,z(M._dbInfo)}}).catch(function(N){throw(Y(e,N)||g.resolve()).catch(function(){}),N})}}):f=l.then(function(h){j(e);var m=U[e.name],_=m.forages;h.close();for(var p=0;p<_.length;p++){var S=_[p];S._dbInfo.db=null}var R=new g(function(x,N){var F=A.deleteDatabase(e.name);F.onerror=function(){var M=F.result;M&&M.close(),N(F.error)},F.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},F.onsuccess=function(){var M=F.result;M&&M.close(),x(M)}});return R.then(function(x){m.db=x;for(var N=0;N<_.length;N++){var F=_[N];z(F._dbInfo)}}).catch(function(x){throw(Y(e,x)||g.resolve()).catch(function(){}),x})})}return I(f,r),f}var Jt={_driver:"asyncStorage",_initStorage:jt,_support:O(),iterate:zt,getItem:Wt,setItem:Yt,removeItem:Kt,clear:Ht,length:Gt,key:Vt,keys:Qt,dropInstance:Xt};function $t(){return typeof openDatabase=="function"}var J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zt="~~local_forage_type~",Me=/^~~local_forage_type~([^~]+)~/,ie="__lfsc__:",me=ie.length,_e="arbf",pe="blob",Fe="si08",Ue="ui08",je="uic8",We="si16",ze="si32",Ye="ur16",Ke="ui32",He="fl32",Ge="fl64",Ve=me+_e.length,Qe=Object.prototype.toString;function Xe(e){var r=e.length*.75,t=e.length,o,f=0,a,l,h,m;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var _=new ArrayBuffer(r),p=new Uint8Array(_);for(o=0;o<t;o+=4)a=J.indexOf(e[o]),l=J.indexOf(e[o+1]),h=J.indexOf(e[o+2]),m=J.indexOf(e[o+3]),p[f++]=a<<2|l>>4,p[f++]=(l&15)<<4|h>>2,p[f++]=(h&3)<<6|m&63;return _}function ge(e){var r=new Uint8Array(e),t="",o;for(o=0;o<r.length;o+=3)t+=J[r[o]>>2],t+=J[(r[o]&3)<<4|r[o+1]>>4],t+=J[(r[o+1]&15)<<2|r[o+2]>>6],t+=J[r[o+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}function qt(e,r){var t="";if(e&&(t=Qe.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&Qe.call(e.buffer)==="[object ArrayBuffer]")){var o,f=ie;e instanceof ArrayBuffer?(o=e,f+=_e):(o=e.buffer,t==="[object Int8Array]"?f+=Fe:t==="[object Uint8Array]"?f+=Ue:t==="[object Uint8ClampedArray]"?f+=je:t==="[object Int16Array]"?f+=We:t==="[object Uint16Array]"?f+=Ye:t==="[object Int32Array]"?f+=ze:t==="[object Uint32Array]"?f+=Ke:t==="[object Float32Array]"?f+=He:t==="[object Float64Array]"?f+=Ge:r(new Error("Failed to get type for BinaryArray"))),r(f+ge(o))}else if(t==="[object Blob]"){var a=new FileReader;a.onload=function(){var l=Zt+e.type+"~"+ge(this.result);r(ie+pe+l)},a.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(l){console.error("Couldn't convert value into a JSON string: ",e),r(null,l)}}function kt(e){if(e.substring(0,me)!==ie)return JSON.parse(e);var r=e.substring(Ve),t=e.substring(me,Ve),o;if(t===pe&&Me.test(r)){var f=r.match(Me);o=f[1],r=r.substring(f[0].length)}var a=Xe(r);switch(t){case _e:return a;case pe:return E([a],{type:o});case Fe:return new Int8Array(a);case Ue:return new Uint8Array(a);case je:return new Uint8ClampedArray(a);case We:return new Int16Array(a);case Ye:return new Uint16Array(a);case ze:return new Int32Array(a);case Ke:return new Uint32Array(a);case He:return new Float32Array(a);case Ge:return new Float64Array(a);default:throw new Error("Unkown type: "+t)}}var be={serialize:qt,deserialize:kt,stringToBuffer:Xe,bufferToString:ge};function Je(e,r,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function er(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=typeof e[o]!="string"?e[o].toString():e[o];var f=new g(function(a,l){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(h){return l(h)}t.db.transaction(function(h){Je(h,t,function(){r._dbInfo=t,a()},function(m,_){l(_)})},l)});return t.serializer=be,f}function $(e,r,t,o,f,a){e.executeSql(t,o,f,function(l,h){h.code===h.SYNTAX_ERR?l.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(m,_){_.rows.length?a(m,h):Je(m,r,function(){m.executeSql(t,o,f,a)},a)},a):a(l,h)},a)}function tr(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT * FROM "+l.storeName+" WHERE key = ? LIMIT 1",[e],function(m,_){var p=_.rows.length?_.rows.item(0).value:null;p&&(p=l.serializer.deserialize(p)),f(p)},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function rr(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT * FROM "+l.storeName,[],function(m,_){for(var p=_.rows,S=p.length,R=0;R<S;R++){var x=p.item(R),N=x.value;if(N&&(N=l.serializer.deserialize(N)),N=e(N,x.key,R+1),N!==void 0){f(N);return}}f()},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function $e(e,r,t,o){var f=this;e=C(e);var a=new g(function(l,h){f.ready().then(function(){r===void 0&&(r=null);var m=r,_=f._dbInfo;_.serializer.serialize(r,function(p,S){S?h(S):_.db.transaction(function(R){$(R,_,"INSERT OR REPLACE INTO "+_.storeName+" (key, value) VALUES (?, ?)",[e,p],function(){l(m)},function(x,N){h(N)})},function(R){if(R.code===R.QUOTA_ERR){if(o>0){l($e.apply(f,[e,m,t,o-1]));return}h(R)}})})}).catch(h)});return I(a,t),a}function nr(e,r,t){return $e.apply(this,[e,r,t,1])}function ar(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"DELETE FROM "+l.storeName+" WHERE key = ?",[e],function(){f()},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function or(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"DELETE FROM "+a.storeName,[],function(){o()},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function ir(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"SELECT COUNT(key) as c FROM "+a.storeName,[],function(h,m){var _=m.rows.item(0).c;o(_)},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function fr(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT key FROM "+l.storeName+" WHERE id = ? LIMIT 1",[e+1],function(m,_){var p=_.rows.length?_.rows.item(0).key:null;f(p)},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function ur(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"SELECT key FROM "+a.storeName,[],function(h,m){for(var _=[],p=0;p<m.rows.length;p++)_.push(m.rows.item(p).key);o(_)},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function sr(e){return new g(function(r,t){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(f,a){for(var l=[],h=0;h<a.rows.length;h++)l.push(a.rows.item(h).name);r({db:e,storeNames:l})},function(f,a){t(a)})},function(o){t(o)})})}function cr(e,r){r=W.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,f;return e.name?f=new g(function(a){var l;e.name===t.name?l=o._dbInfo.db:l=openDatabase(e.name,"","",0),e.storeName?a({db:l,storeNames:[e.storeName]}):a(sr(l))}).then(function(a){return new g(function(l,h){a.db.transaction(function(m){function _(x){return new g(function(N,F){m.executeSql("DROP TABLE IF EXISTS "+x,[],function(){N()},function(M,H){F(H)})})}for(var p=[],S=0,R=a.storeNames.length;S<R;S++)p.push(_(a.storeNames[S]));g.all(p).then(function(){l()}).catch(function(x){h(x)})},function(m){h(m)})})}):f=g.reject("Invalid arguments"),I(f,r),f}var lr={_driver:"webSQLStorage",_initStorage:er,_support:$t(),iterate:rr,getItem:tr,setItem:nr,removeItem:ar,clear:or,length:ir,key:fr,keys:ur,dropInstance:cr};function dr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ze(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function vr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function hr(){return!vr()||localStorage.length>0}function yr(e){var r=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=Ze(e,r._defaultConfig),hr()?(r._dbInfo=t,t.serializer=be,g.resolve()):g.reject()}function mr(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo.keyPrefix,f=localStorage.length-1;f>=0;f--){var a=localStorage.key(f);a.indexOf(o)===0&&localStorage.removeItem(a)}});return I(t,e),t}function _r(e,r){var t=this;e=C(e);var o=t.ready().then(function(){var f=t._dbInfo,a=localStorage.getItem(f.keyPrefix+e);return a&&(a=f.serializer.deserialize(a)),a});return I(o,r),o}function pr(e,r){var t=this,o=t.ready().then(function(){for(var f=t._dbInfo,a=f.keyPrefix,l=a.length,h=localStorage.length,m=1,_=0;_<h;_++){var p=localStorage.key(_);if(p.indexOf(a)===0){var S=localStorage.getItem(p);if(S&&(S=f.serializer.deserialize(S)),S=e(S,p.substring(l),m++),S!==void 0)return S}}});return I(o,r),o}function gr(e,r){var t=this,o=t.ready().then(function(){var f=t._dbInfo,a;try{a=localStorage.key(e)}catch{a=null}return a&&(a=a.substring(f.keyPrefix.length)),a});return I(o,r),o}function br(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo,f=localStorage.length,a=[],l=0;l<f;l++){var h=localStorage.key(l);h.indexOf(o.keyPrefix)===0&&a.push(h.substring(o.keyPrefix.length))}return a});return I(t,e),t}function wr(e){var r=this,t=r.keys().then(function(o){return o.length});return I(t,e),t}function Sr(e,r){var t=this;e=C(e);var o=t.ready().then(function(){var f=t._dbInfo;localStorage.removeItem(f.keyPrefix+e)});return I(o,r),o}function Er(e,r,t){var o=this;e=C(e);var f=o.ready().then(function(){r===void 0&&(r=null);var a=r;return new g(function(l,h){var m=o._dbInfo;m.serializer.serialize(r,function(_,p){if(p)h(p);else try{localStorage.setItem(m.keyPrefix+e,_),l(a)}catch(S){(S.name==="QuotaExceededError"||S.name==="NS_ERROR_DOM_QUOTA_REACHED")&&h(S),h(S)}})})});return I(f,t),f}function Ir(e,r){if(r=W.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var o=this,f;return e.name?f=new g(function(a){e.storeName?a(Ze(e,o._defaultConfig)):a(e.name+"/")}).then(function(a){for(var l=localStorage.length-1;l>=0;l--){var h=localStorage.key(l);h.indexOf(a)===0&&localStorage.removeItem(h)}}):f=g.reject("Invalid arguments"),I(f,r),f}var Ar={_driver:"localStorageWrapper",_initStorage:yr,_support:dr(),iterate:pr,getItem:_r,setItem:Er,removeItem:Sr,clear:mr,length:wr,key:gr,keys:br,dropInstance:Ir},Rr=function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},Tr=function(r,t){for(var o=r.length,f=0;f<o;){if(Rr(r[f],t))return!0;f++}return!1},qe=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},re={},ke={},k={INDEXEDDB:Jt,WEBSQL:lr,LOCALSTORAGE:Ar},Dr=[k.INDEXEDDB._driver,k.WEBSQL._driver,k.LOCALSTORAGE._driver],fe=["dropInstance"],we=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(fe),Or={description:"",driver:Dr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Br(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function Se(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(qe(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var xr=function(){function e(r){v(this,e);for(var t in k)if(k.hasOwnProperty(t)){var o=k[t],f=o._driver;this[t]=f,re[f]||this.defineDriver(o)}this._defaultConfig=Se({},Or),this._config=Se({},this._defaultConfig,r),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(t){if((typeof t>"u"?"undefined":y(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in t){if(o==="storeName"&&(t[o]=t[o].replace(/\W/g,"_")),o==="version"&&typeof t[o]!="number")return new Error("Database version must be a number.");this._config[o]=t[o]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},e.prototype.defineDriver=function(t,o,f){var a=new g(function(l,h){try{var m=t._driver,_=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){h(_);return}for(var p=we.concat("_initStorage"),S=0,R=p.length;S<R;S++){var x=p[S],N=!Tr(fe,x);if((N||t[x])&&typeof t[x]!="function"){h(_);return}}var F=function(){for(var ne=function(Cr){return function(){var Lr=new Error("Method "+Cr+" is not implemented by the current driver"),et=g.reject(Lr);return I(et,arguments[arguments.length-1]),et}},Ee=0,Pr=fe.length;Ee<Pr;Ee++){var Ie=fe[Ee];t[Ie]||(t[Ie]=ne(Ie))}};F();var M=function(ne){re[m]&&console.info("Redefining LocalForage driver: "+m),re[m]=t,ke[m]=ne,l()};"_support"in t?t._support&&typeof t._support=="function"?t._support().then(M,h):M(!!t._support):M(!0)}catch(H){h(H)}});return T(a,o,f),a},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,o,f){var a=re[t]?g.resolve(re[t]):g.reject(new Error("Driver not found."));return T(a,o,f),a},e.prototype.getSerializer=function(t){var o=g.resolve(be);return T(o,t),o},e.prototype.ready=function(t){var o=this,f=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(f,t,t),f},e.prototype.setDriver=function(t,o,f){var a=this;qe(t)||(t=[t]);var l=this._getSupportedDrivers(t);function h(){a._config.driver=a.driver()}function m(S){return a._extend(S),h(),a._ready=a._initStorage(a._config),a._ready}function _(S){return function(){var R=0;function x(){for(;R<S.length;){var N=S[R];return R++,a._dbInfo=null,a._ready=null,a.getDriver(N).then(m).catch(x)}h();var F=new Error("No available storage method found.");return a._driverSet=g.reject(F),a._driverSet}return x()}}var p=this._driverSet!==null?this._driverSet.catch(function(){return g.resolve()}):g.resolve();return this._driverSet=p.then(function(){var S=l[0];return a._dbInfo=null,a._ready=null,a.getDriver(S).then(function(R){a._driver=R._driver,h(),a._wrapLibraryMethodsWithReady(),a._initDriver=_(l)})}).catch(function(){h();var S=new Error("No available storage method found.");return a._driverSet=g.reject(S),a._driverSet}),T(this._driverSet,o,f),this._driverSet},e.prototype.supports=function(t){return!!ke[t]},e.prototype._extend=function(t){Se(this,t)},e.prototype._getSupportedDrivers=function(t){for(var o=[],f=0,a=t.length;f<a;f++){var l=t[f];this.supports(l)&&o.push(l)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,o=we.length;t<o;t++)Br(this,we[t])},e.prototype.createInstance=function(t){return new e(t)},e}(),Nr=new xr;c.exports=Nr},{3:3}]},{},[4])(4)})});var At=tt((mn,se)=>{"use strict";var ot,it,ft,ut,st,ct,lt,dt,vt,ue,Te,ht,yt,ee,mt,_t,pt,gt,bt,wt,St,Et,It;(function(i){var u=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(s){i(n(u,n(s)))}):typeof se=="object"&&typeof se.exports=="object"?i(n(u,n(se.exports))):i(n(u));function n(s,c){return s!==u&&(typeof Object.create=="function"?Object.defineProperty(s,"__esModule",{value:!0}):s.__esModule=!0),function(d,y){return s[d]=c?c(d,y):y}}})(function(i){var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,s){n.__proto__=s}||function(n,s){for(var c in s)s.hasOwnProperty(c)&&(n[c]=s[c])};ot=function(n,s){u(n,s);function c(){this.constructor=n}n.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)},it=Object.assign||function(n){for(var s,c=1,d=arguments.length;c<d;c++){s=arguments[c];for(var y in s)Object.prototype.hasOwnProperty.call(s,y)&&(n[y]=s[y])}return n},ft=function(n,s){var c={};for(var d in n)Object.prototype.hasOwnProperty.call(n,d)&&s.indexOf(d)<0&&(c[d]=n[d]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var y=0,d=Object.getOwnPropertySymbols(n);y<d.length;y++)s.indexOf(d[y])<0&&Object.prototype.propertyIsEnumerable.call(n,d[y])&&(c[d[y]]=n[d[y]]);return c},ut=function(n,s,c,d){var y=arguments.length,v=y<3?s:d===null?d=Object.getOwnPropertyDescriptor(s,c):d,b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(n,s,c,d);else for(var A=n.length-1;A>=0;A--)(b=n[A])&&(v=(y<3?b(v):y>3?b(s,c,v):b(s,c))||v);return y>3&&v&&Object.defineProperty(s,c,v),v},st=function(n,s){return function(c,d){s(c,d,n)}},ct=function(n,s){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,s)},lt=function(n,s,c,d){function y(v){return v instanceof c?v:new c(function(b){b(v)})}return new(c||(c=Promise))(function(v,b){function A(g){try{E(d.next(g))}catch(I){b(I)}}function O(g){try{E(d.throw(g))}catch(I){b(I)}}function E(g){g.done?v(g.value):y(g.value).then(A,O)}E((d=d.apply(n,s||[])).next())})},dt=function(n,s){var c={label:0,sent:function(){if(v[0]&1)throw v[1];return v[1]},trys:[],ops:[]},d,y,v,b;return b={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function A(E){return function(g){return O([E,g])}}function O(E){if(d)throw new TypeError("Generator is already executing.");for(;c;)try{if(d=1,y&&(v=E[0]&2?y.return:E[0]?y.throw||((v=y.return)&&v.call(y),0):y.next)&&!(v=v.call(y,E[1])).done)return v;switch(y=0,v&&(E=[E[0]&2,v.value]),E[0]){case 0:case 1:v=E;break;case 4:return c.label++,{value:E[1],done:!1};case 5:c.label++,y=E[1],E=[0];continue;case 7:E=c.ops.pop(),c.trys.pop();continue;default:if(v=c.trys,!(v=v.length>0&&v[v.length-1])&&(E[0]===6||E[0]===2)){c=0;continue}if(E[0]===3&&(!v||E[1]>v[0]&&E[1]<v[3])){c.label=E[1];break}if(E[0]===6&&c.label<v[1]){c.label=v[1],v=E;break}if(v&&c.label<v[2]){c.label=v[2],c.ops.push(E);break}v[2]&&c.ops.pop(),c.trys.pop();continue}E=s.call(n,c)}catch(g){E=[6,g],y=0}finally{d=v=0}if(E[0]&5)throw E[1];return{value:E[0]?E[1]:void 0,done:!0}}},It=function(n,s,c,d){d===void 0&&(d=c),n[d]=s[c]},vt=function(n,s){for(var c in n)c!=="default"&&!s.hasOwnProperty(c)&&(s[c]=n[c])},ue=function(n){var s=typeof Symbol=="function"&&Symbol.iterator,c=s&&n[s],d=0;if(c)return c.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&d>=n.length&&(n=void 0),{value:n&&n[d++],done:!n}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")},Te=function(n,s){var c=typeof Symbol=="function"&&n[Symbol.iterator];if(!c)return n;var d=c.call(n),y,v=[],b;try{for(;(s===void 0||s-- >0)&&!(y=d.next()).done;)v.push(y.value)}catch(A){b={error:A}}finally{try{y&&!y.done&&(c=d.return)&&c.call(d)}finally{if(b)throw b.error}}return v},ht=function(){for(var n=[],s=0;s<arguments.length;s++)n=n.concat(Te(arguments[s]));return n},yt=function(){for(var n=0,s=0,c=arguments.length;s<c;s++)n+=arguments[s].length;for(var d=Array(n),y=0,s=0;s<c;s++)for(var v=arguments[s],b=0,A=v.length;b<A;b++,y++)d[y]=v[b];return d},ee=function(n){return this instanceof ee?(this.v=n,this):new ee(n)},mt=function(n,s,c){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var d=c.apply(n,s||[]),y,v=[];return y={},b("next"),b("throw"),b("return"),y[Symbol.asyncIterator]=function(){return this},y;function b(T){d[T]&&(y[T]=function(C){return new Promise(function(W,L){v.push([T,C,W,L])>1||A(T,C)})})}function A(T,C){try{O(d[T](C))}catch(W){I(v[0][3],W)}}function O(T){T.value instanceof ee?Promise.resolve(T.value.v).then(E,g):I(v[0][2],T)}function E(T){A("next",T)}function g(T){A("throw",T)}function I(T,C){T(C),v.shift(),v.length&&A(v[0][0],v[0][1])}},_t=function(n){var s,c;return s={},d("next"),d("throw",function(y){throw y}),d("return"),s[Symbol.iterator]=function(){return this},s;function d(y,v){s[y]=n[y]?function(b){return(c=!c)?{value:ee(n[y](b)),done:y==="return"}:v?v(b):b}:v}},pt=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n[Symbol.asyncIterator],c;return s?s.call(n):(n=typeof ue=="function"?ue(n):n[Symbol.iterator](),c={},d("next"),d("throw"),d("return"),c[Symbol.asyncIterator]=function(){return this},c);function d(v){c[v]=n[v]&&function(b){return new Promise(function(A,O){b=n[v](b),y(A,O,b.done,b.value)})}}function y(v,b,A,O){Promise.resolve(O).then(function(E){v({value:E,done:A})},b)}},gt=function(n,s){return Object.defineProperty?Object.defineProperty(n,"raw",{value:s}):n.raw=s,n},bt=function(n){if(n&&n.__esModule)return n;var s={};if(n!=null)for(var c in n)Object.hasOwnProperty.call(n,c)&&(s[c]=n[c]);return s.default=n,s},wt=function(n){return n&&n.__esModule?n:{default:n}},St=function(n,s){if(!s.has(n))throw new TypeError("attempted to get private field on non-instance");return s.get(n)},Et=function(n,s,c){if(!s.has(n))throw new TypeError("attempted to set private field on non-instance");return s.set(n,c),c},i("__extends",ot),i("__assign",it),i("__rest",ft),i("__decorate",ut),i("__param",st),i("__metadata",ct),i("__awaiter",lt),i("__generator",dt),i("__exportStar",vt),i("__createBinding",It),i("__values",ue),i("__read",Te),i("__spread",ht),i("__spreadArrays",yt),i("__await",ee),i("__asyncGenerator",mt),i("__asyncDelegator",_t),i("__asyncValues",pt),i("__makeTemplateObject",gt),i("__importStar",bt),i("__importDefault",wt),i("__classPrivateFieldGet",St),i("__classPrivateFieldSet",Et)})});var ve=rt(at());import{SDKBase as ln,createSDK as dn}from"@magic-sdk/provider";var Pe={};zr(Pe,{_driver:()=>Ne,_initStorage:()=>Qr,_support:()=>nn,clear:()=>Xr,dropInstance:()=>Jr,getItem:()=>$r,iterate:()=>Zr,key:()=>qr,keys:()=>kr,length:()=>en,removeItem:()=>tn,setItem:()=>rn});var Rt=rt(At(),1),{__extends:_n,__assign:pn,__rest:gn,__decorate:bn,__param:wn,__metadata:Sn,__awaiter:En,__generator:In,__exportStar:An,__createBinding:Rn,__values:Tt,__read:Tn,__spread:Dn,__spreadArrays:On,__await:Bn,__asyncGenerator:xn,__asyncDelegator:Nn,__asyncValues:Pn,__makeTemplateObject:Cn,__importStar:Ln,__importDefault:Mn,__classPrivateFieldGet:Fn,__classPrivateFieldSet:Un}=Rt.default;function Kr(i,u){i=i||[],u=u||{};try{return new Blob(i,u)}catch(d){if(d.name!=="TypeError")throw d;for(var n=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,s=new n,c=0;c<i.length;c+=1)s.append(i[c]);return s.getBlob(u.type)}}var Dt=/^~~local_forage_type~([^~]+)~/,De=9,Ot=De+4,Bt=Object.prototype.toString;function xt(i){var u=i.length*.75,n=i.length;i[i.length-1]==="="&&(u--,i[i.length-2]==="="&&u--);for(var s=new ArrayBuffer(u),c=new Uint8Array(s),d=0,y=0;d<n;d+=4){var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d]),b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+1]),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+2]),O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+3]);c[y++]=v<<2|b>>4,c[y++]=(b&15)<<4|A>>2,c[y++]=(A&3)<<6|O&63}return s}function Oe(i){for(var u=new Uint8Array(i),n="",s=0;s<u.length;s+=3)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[s]>>2],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[s]&3)<<4|u[s+1]>>4],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[s+1]&15)<<2|u[s+2]>>6],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[s+2]&63];return u.length%3===2?n=n.substring(0,n.length-1)+"=":u.length%3===1&&(n=n.substring(0,n.length-2)+"=="),n}function Hr(i,u){var n="";if(i&&(n=Bt.call(i)),i&&(n==="[object ArrayBuffer]"||i.buffer&&Bt.call(i.buffer)==="[object ArrayBuffer]")){var s=void 0,c="__lfsc__:";i instanceof ArrayBuffer?(s=i,c+="arbf"):(s=i.buffer,n==="[object Int8Array]"?c+="si08":n==="[object Uint8Array]"?c+="ui08":n==="[object Uint8ClampedArray]"?c+="uic8":n==="[object Int16Array]"?c+="si16":n==="[object Uint16Array]"?c+="ur16":n==="[object Int32Array]"?c+="si32":n==="[object Uint32Array]"?c+="ui32":n==="[object Float32Array]"?c+="fl32":n==="[object Float64Array]"?c+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(c+Oe(s))}else if(n==="[object Blob]"){var d=new FileReader;d.onload=function(){var y="~~local_forage_type~"+i.type+"~"+Oe(this.result);u("__lfsc__:blob"+y)},d.readAsArrayBuffer(i)}else try{u(JSON.stringify(i))}catch(y){console.error("Couldn't convert value into a JSON string: ",i),u(null,y)}}function Gr(i){if(i.substring(0,De)!=="__lfsc__:")return JSON.parse(i);var u=i.substring(Ot),n=i.substring(De,Ot),s;if(n==="blob"&&Dt.test(u)){var c=u.match(Dt);s=c[1],u=u.substring(c[0].length)}var d=xt(u);switch(n){case"arbf":return d;case"blob":return Kr([d],{type:s});case"si08":return new Int8Array(d);case"ui08":return new Uint8Array(d);case"uic8":return new Uint8ClampedArray(d);case"si16":return new Int16Array(d);case"ur16":return new Uint16Array(d);case"si32":return new Int32Array(d);case"ui32":return new Uint32Array(d);case"fl32":return new Float32Array(d);case"fl64":return new Float64Array(d);default:throw new Error("Unkown type: "+n)}}function Be(i){var u,n;if(i===null||typeof i!="object"||"isActiveClone"in i)return i;var s=i instanceof Date?new Date(i):i.constructor();try{for(var c=Tt(Object.keys(i)),d=c.next();!d.done;d=c.next()){var y=d.value;Object.prototype.hasOwnProperty.call(i,y)&&(i.isActiveClone=null,s[y]=Be(i[y]),delete i.isActiveClone)}}catch(v){u={error:v}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(u)throw u.error}}return s}function xe(i,u){return(i.name||u.name)+"/"+(i.storeName||u.storeName)+"/"}function G(i,u){u&&i.then(function(n){u(null,n)},function(n){u(n)})}function Vr(){for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Nt(i,u){var n=this;if(u=Vr.apply(this,arguments),i=typeof i!="function"&&i||{},!i.name){var s=this.config();i.name=i.name||s.name,i.storeName=i.storeName||s.storeName}var c;return i.name?c=new Promise(function(d){i.storeName?d(xe(i,n._defaultConfig)):d(i.name+"/")}):c=Promise.reject("Invalid arguments"),{promise:c,callback:u}}function ce(i){return typeof i!="string"&&(console.warn(i+" used as a key, but it is not a string."),i=String(i)),i}var Pt={bufferToString:Oe,deserialize:Gr,serialize:Hr,stringToBuffer:xt};var Ne="localforage-driver-memory",le={},Ct=function(){function i(u){this.kp=u,this.data={}}return i.resolve=function(u){return le[u]||(le[u]=new i(u)),le[u]},i.prototype.clear=function(){this.data={}},i.prototype.drop=function(){this.clear(),delete le[this.kp]},i.prototype.get=function(u){return this.data[u]},i.prototype.key=function(u){return this.keys()[u]},i.prototype.keys=function(){return Object.keys(this.data)},i.prototype.rm=function(u){delete this.data[u]},i.prototype.set=function(u,n){this.data[u]=n},i}();function Qr(i){var u=i?Be(i):{},n=xe(u,this._defaultConfig),s=Ct.resolve(n);return this._dbInfo=u,this._dbInfo.serializer=Pt,this._dbInfo.keyPrefix=n,this._dbInfo.mStore=s,Promise.resolve()}function Xr(i){var u=this,n=this.ready().then(function(){u._dbInfo.mStore.clear()});return G(n,i),n}function Jr(i,u){var n=Nt.apply(this,arguments),s=n.promise,c=n.callback,d=s.then(function(y){Ct.resolve(y).drop()});return G(d,c),s}function $r(i,u){var n=this;i=ce(i);var s=this.ready().then(function(){var c=n._dbInfo.mStore.get(i);return c==null?null:n._dbInfo.serializer.deserialize(c)});return G(s,u),s}function Zr(i,u){var n=this,s=this.ready().then(function(){for(var c=n._dbInfo.mStore,d=c.keys(),y=0;y<d.length;y++){var v=c.get(d[y]);if(v&&(v=n._dbInfo.serializer.deserialize(v)),v=i(v,d[y],y+1),v!==void 0)return v}});return G(s,u),s}function qr(i,u){var n=this,s=this.ready().then(function(){var c;try{c=n._dbInfo.mStore.key(i),c===void 0&&(c=null)}catch{c=null}return c});return G(s,u),s}function kr(i){var u=this,n=this.ready().then(function(){return u._dbInfo.mStore.keys()});return G(n,i),n}function en(i){var u=this.keys().then(function(n){return n.length});return G(u,i),u}function tn(i,u){var n=this;i=ce(i);var s=this.ready().then(function(){n._dbInfo.mStore.rm(i)});return G(s,u),s}function rn(i,u,n){var s=this;i=ce(i);var c=this.ready().then(function(){u===void 0&&(u=null);var d=u;return new Promise(function(y,v){s._dbInfo.serializer.serialize(u,function(b,A){if(A)v(A);else try{s._dbInfo.mStore.set(i,b),y(d)}catch(O){v(O)}})})});return G(c,n),c}var nn=!0;import{createDuplicateIframeWarning as an,createModalNotReadyError as on,createURL as Lt,ViewController as fn}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as Mt}from"@magic-sdk/types";var un={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function sn(i){for(let[u,n]of Object.entries(un))i.style[u]=n}function cn(i){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(n=>n.src.includes(i))}var de=class extends fn{activeElement=null;iframe;relayerSrc=Lt(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(u=>{let n=()=>{if(cn(encodeURIComponent(this.parameters)))an().log();else{let s=document.createElement("iframe");s.classList.add("magic-iframe"),s.dataset.magicIframeLabel=Lt(this.endpoint).host,s.title="Secure Modal",s.src=this.relayerSrc,s.allow="clipboard-read; clipboard-write",sn(s),document.body.appendChild(s),u(s)}};["loaded","interactive","complete"].includes(document.readyState)?n():window.addEventListener("load",n,!1)}),this.iframe.then(u=>{u instanceof HTMLIFrameElement&&u.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",u=>{if(u.origin===this.endpoint&&u.data.msgType){if(u.data.msgType.includes(Mt.MAGIC_PONG))this.lastPongTime=Date.now();else if(u.data.msgType.includes(Mt.MAGIC_THIRD_PARTY_WALLET_REQUEST)){this.thirdPartyWalletRequestHandler(u.data);return}if(u.data&&this.messageHandlers.size){u.data.response=u.data.response??{},this.stopHeartBeat();for(let n of this.messageHandlers.values())n(u)}}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let u=await this.iframe;u.style.display="block",u.style.zIndex="2147483647",u.style.opacity="1",this.activeElement=document.activeElement,u.focus()}async hideOverlay(){let u=await this.iframe;u.style.display="none",u.style.zIndex="-1",u.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(u){let n=await this.iframe;if(n&&n.contentWindow)n.contentWindow.postMessage(u,this.endpoint);else throw on()}async checkRelayerExistsInDOM(){let u=await this.iframe;return!u||!u.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(s=>s.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let u=await this.iframe;if(this.stopHeartBeat(),!u){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!u.contentWindow){document.body.appendChild(u),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}u&&(u.src=this.relayerSrc)}};export*from"@magic-sdk/provider";export*from"@magic-sdk/types";var $n=dn(ln,{platform:"web",sdkName:"magic-sdk",version:"33.7.0",defaultEndpoint:"https://auth.magic.link/",ViewController:de,configureStorage:async()=>{let i=ve.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await i.defineDriver(Pe),await i.setDriver([ve.default.INDEXEDDB,ve.default.LOCALSTORAGE,Ne]),i}});export{$n as Magic};
1
+ var Mr=Object.create;var Ae=Object.defineProperty;var Fr=Object.getOwnPropertyDescriptor;var Ur=Object.getOwnPropertyNames;var jr=Object.getPrototypeOf,Wr=Object.prototype.hasOwnProperty;var ae=(i=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(i,{get:(u,n)=>(typeof require<"u"?require:u)[n]}):i)(function(i){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+i+'" is not supported')});var tt=(i,u)=>()=>(u||i((u={exports:{}}).exports,u),u.exports),zr=(i,u)=>{for(var n in u)Ae(i,n,{get:u[n],enumerable:!0})},Yr=(i,u,n,s)=>{if(u&&typeof u=="object"||typeof u=="function")for(let c of Ur(u))!Wr.call(i,c)&&c!==n&&Ae(i,c,{get:()=>u[c],enumerable:!(s=Fr(u,c))||s.enumerable});return i};var rt=(i,u,n)=>(n=i!=null?Mr(jr(i)):{},Yr(u||!i||!i.__esModule?Ae(n,"default",{value:i,enumerable:!0}):n,i));var at=tt((nt,Re)=>{"use strict";(function(i){if(typeof nt=="object"&&typeof Re<"u")Re.exports=i();else if(typeof define=="function"&&define.amd)define([],i);else{var u;typeof window<"u"?u=window:typeof global<"u"?u=global:typeof self<"u"?u=self:u=this,u.localforage=i()}})(function(){var i,u,n;return function s(c,d,y){function v(O,E){if(!d[O]){if(!c[O]){var g=typeof ae=="function"&&ae;if(!E&&g)return g(O,!0);if(b)return b(O,!0);var I=new Error("Cannot find module '"+O+"'");throw I.code="MODULE_NOT_FOUND",I}var T=d[O]={exports:{}};c[O][0].call(T.exports,function(C){var W=c[O][1][C];return v(W||C)},T,T.exports,s,c,d,y)}return d[O].exports}for(var b=typeof ae=="function"&&ae,A=0;A<y.length;A++)v(y[A]);return v}({1:[function(s,c,d){(function(y){"use strict";var v=y.MutationObserver||y.WebKitMutationObserver,b;if(v){var A=0,O=new v(C),E=y.document.createTextNode("");O.observe(E,{characterData:!0}),b=function(){E.data=A=++A%2}}else if(!y.setImmediate&&typeof y.MessageChannel<"u"){var g=new y.MessageChannel;g.port1.onmessage=C,b=function(){g.port2.postMessage(0)}}else"document"in y&&"onreadystatechange"in y.document.createElement("script")?b=function(){var L=y.document.createElement("script");L.onreadystatechange=function(){C(),L.onreadystatechange=null,L.parentNode.removeChild(L),L=null},y.document.documentElement.appendChild(L)}:b=function(){setTimeout(C,0)};var I,T=[];function C(){I=!0;for(var L,V,U=T.length;U;){for(V=T,T=[],L=-1;++L<U;)V[L]();U=T.length}I=!1}c.exports=W;function W(L){T.push(L)===1&&!I&&b()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(s,c,d){"use strict";var y=s(1);function v(){}var b={},A=["REJECTED"],O=["FULFILLED"],E=["PENDING"];c.exports=g;function g(w){if(typeof w!="function")throw new TypeError("resolver must be a function");this.state=E,this.queue=[],this.outcome=void 0,w!==v&&W(this,w)}g.prototype.catch=function(w){return this.then(null,w)},g.prototype.then=function(w,B){if(typeof w!="function"&&this.state===O||typeof B!="function"&&this.state===A)return this;var D=new this.constructor(v);if(this.state!==E){var P=this.state===O?w:B;T(D,P,this.outcome)}else this.queue.push(new I(D,w,B));return D};function I(w,B,D){this.promise=w,typeof B=="function"&&(this.onFulfilled=B,this.callFulfilled=this.otherCallFulfilled),typeof D=="function"&&(this.onRejected=D,this.callRejected=this.otherCallRejected)}I.prototype.callFulfilled=function(w){b.resolve(this.promise,w)},I.prototype.otherCallFulfilled=function(w){T(this.promise,this.onFulfilled,w)},I.prototype.callRejected=function(w){b.reject(this.promise,w)},I.prototype.otherCallRejected=function(w){T(this.promise,this.onRejected,w)};function T(w,B,D){y(function(){var P;try{P=B(D)}catch(j){return b.reject(w,j)}P===w?b.reject(w,new TypeError("Cannot resolve promise with itself")):b.resolve(w,P)})}b.resolve=function(w,B){var D=L(C,B);if(D.status==="error")return b.reject(w,D.value);var P=D.value;if(P)W(w,P);else{w.state=O,w.outcome=B;for(var j=-1,z=w.queue.length;++j<z;)w.queue[j].callFulfilled(B)}return w},b.reject=function(w,B){w.state=A,w.outcome=B;for(var D=-1,P=w.queue.length;++D<P;)w.queue[D].callRejected(B);return w};function C(w){var B=w&&w.then;if(w&&(typeof w=="object"||typeof w=="function")&&typeof B=="function")return function(){B.apply(w,arguments)}}function W(w,B){var D=!1;function P(K){D||(D=!0,b.reject(w,K))}function j(K){D||(D=!0,b.resolve(w,K))}function z(){B(j,P)}var Y=L(z);Y.status==="error"&&P(Y.value)}function L(w,B){var D={};try{D.value=w(B),D.status="success"}catch(P){D.status="error",D.value=P}return D}g.resolve=V;function V(w){return w instanceof this?w:b.resolve(new this(v),w)}g.reject=U;function U(w){var B=new this(v);return b.reject(B,w)}g.all=he;function he(w){var B=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=w.length,P=!1;if(!D)return this.resolve([]);for(var j=new Array(D),z=0,Y=-1,K=new this(v);++Y<D;)Q(w[Y],Y);return K;function Q(te,oe){B.resolve(te).then(ye,function(q){P||(P=!0,b.reject(K,q))});function ye(q){j[oe]=q,++z===D&&!P&&(P=!0,b.resolve(K,j))}}}g.race=Z;function Z(w){var B=this;if(Object.prototype.toString.call(w)!=="[object Array]")return this.reject(new TypeError("must be an array"));var D=w.length,P=!1;if(!D)return this.resolve([]);for(var j=-1,z=new this(v);++j<D;)Y(w[j]);return z;function Y(K){B.resolve(K).then(function(Q){P||(P=!0,b.resolve(z,Q))},function(Q){P||(P=!0,b.reject(z,Q))})}}},{1:1}],3:[function(s,c,d){(function(y){"use strict";typeof y.Promise!="function"&&(y.Promise=s(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(s,c,d){"use strict";var y=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,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function b(){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 A=b();function O(){try{if(!A||!A.open)return!1;var e=typeof openDatabase<"u"&&/(Safari|iPhone|iPad|iPod)/.test(navigator.userAgent)&&!/Chrome/.test(navigator.userAgent)&&!/BlackBerry/.test(navigator.platform),r=typeof fetch=="function"&&fetch.toString().indexOf("[native code")!==-1;return(!e||r)&&typeof indexedDB<"u"&&typeof IDBKeyRange<"u"}catch{return!1}}function E(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(a){if(a.name!=="TypeError")throw a;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new t,f=0;f<e.length;f+=1)o.append(e[f]);return o.getBlob(r.type)}}typeof Promise>"u"&&s(3);var g=Promise;function I(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function T(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function C(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function W(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var L="local-forage-detect-blob-support",V=void 0,U={},he=Object.prototype.toString,Z="readonly",w="readwrite";function B(e){for(var r=e.length,t=new ArrayBuffer(r),o=new Uint8Array(t),f=0;f<r;f++)o[f]=e.charCodeAt(f);return t}function D(e){return new g(function(r){var t=e.transaction(L,w),o=E([""]);t.objectStore(L).put(o,"key"),t.onabort=function(f){f.preventDefault(),f.stopPropagation(),r(!1)},t.oncomplete=function(){var f=navigator.userAgent.match(/Chrome\/(\d+)/),a=navigator.userAgent.match(/Edge\//);r(a||!f||parseInt(f[1],10)>=43)}}).catch(function(){return!1})}function P(e){return typeof V=="boolean"?g.resolve(V):D(e).then(function(r){return V=r,V})}function j(e){var r=U[e.name],t={};t.promise=new g(function(o,f){t.resolve=o,t.reject=f}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function z(e){var r=U[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function Y(e,r){var t=U[e.name],o=t.deferredOperations.pop();if(o)return o.reject(r),o.promise}function K(e,r){return new g(function(t,o){if(U[e.name]=U[e.name]||Le(),e.db)if(r)j(e),e.db.close();else return t(e.db);var f=[e.name];r&&f.push(e.version);var a=A.open.apply(A,f);r&&(a.onupgradeneeded=function(l){var h=a.result;try{h.createObjectStore(e.storeName),l.oldVersion<=1&&h.createObjectStore(L)}catch(m){if(m.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+l.oldVersion+" to version "+l.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw m}}),a.onerror=function(l){l.preventDefault(),o(a.error)},a.onsuccess=function(){var l=a.result;l.onversionchange=function(h){h.target.close()},t(l),z(e)}})}function Q(e){return K(e,!1)}function te(e){return K(e,!0)}function oe(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,f=e.version>e.db.version;if(o&&(e.version!==r&&console.warn('The database "'+e.name+`" can't be downgraded from version `+e.db.version+" to version "+e.version+"."),e.version=e.db.version),f||t){if(t){var a=e.db.version+1;a>e.version&&(e.version=a)}return!0}return!1}function ye(e){return new g(function(r,t){var o=new FileReader;o.onerror=t,o.onloadend=function(f){var a=btoa(f.target.result||"");r({__local_forage_encoded_blob:!0,data:a,type:e.type})},o.readAsBinaryString(e)})}function q(e){var r=B(atob(e.data));return E([r],{type:e.type})}function Ce(e){return e&&e.__local_forage_encoded_blob}function Ft(e){var r=this,t=r._initReady().then(function(){var o=U[r._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return T(t,e,e),t}function Ut(e){j(e);for(var r=U[e.name],t=r.forages,o=0;o<t.length;o++){var f=t[o];f._dbInfo.db&&(f._dbInfo.db.close(),f._dbInfo.db=null)}return e.db=null,Q(e).then(function(a){return e.db=a,oe(e)?te(e):a}).then(function(a){e.db=r.db=a;for(var l=0;l<t.length;l++)t[l]._dbInfo.db=a}).catch(function(a){throw Y(e,a),a})}function X(e,r,t,o){o===void 0&&(o=1);try{var f=e.db.transaction(e.storeName,r);t(null,f)}catch(a){if(o>0&&(!e.db||a.name==="InvalidStateError"||a.name==="NotFoundError"))return g.resolve().then(function(){if(!e.db||a.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),te(e)}).then(function(){return Ut(e).then(function(){X(e,r,t,o-1)})}).catch(t);t(a)}}function Le(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function jt(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=e[o];var f=U[t.name];f||(f=Le(),U[t.name]=f),f.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=Ft);var a=[];function l(){return g.resolve()}for(var h=0;h<f.forages.length;h++){var m=f.forages[h];m!==r&&a.push(m._initReady().catch(l))}var _=f.forages.slice(0);return g.all(a).then(function(){return t.db=f.db,Q(t)}).then(function(p){return t.db=p,oe(t,r._defaultConfig.version)?te(t):p}).then(function(p){t.db=f.db=p,r._dbInfo=t;for(var S=0;S<_.length;S++){var R=_[S];R!==r&&(R._dbInfo.db=t.db,R._dbInfo.version=t.version)}})}function Wt(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.get(e);_.onsuccess=function(){var p=_.result;p===void 0&&(p=null),Ce(p)&&(p=q(p)),f(p)},_.onerror=function(){a(_.error)}}catch(p){a(p)}})}).catch(a)});return I(o,r),o}function zt(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.openCursor(),p=1;_.onsuccess=function(){var S=_.result;if(S){var R=S.value;Ce(R)&&(R=q(R));var x=e(R,S.key,p++);x!==void 0?f(x):S.continue()}else f()},_.onerror=function(){a(_.error)}}catch(S){a(S)}})}).catch(a)});return I(o,r),o}function Yt(e,r,t){var o=this;e=C(e);var f=new g(function(a,l){var h;o.ready().then(function(){return h=o._dbInfo,he.call(r)==="[object Blob]"?P(h.db).then(function(m){return m?r:ye(r)}):r}).then(function(m){X(o._dbInfo,w,function(_,p){if(_)return l(_);try{var S=p.objectStore(o._dbInfo.storeName);m===null&&(m=void 0);var R=S.put(m,e);p.oncomplete=function(){m===void 0&&(m=null),a(m)},p.onabort=p.onerror=function(){var x=R.error?R.error:R.transaction.error;l(x)}}catch(x){l(x)}})}).catch(l)});return I(f,t),f}function Kt(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){X(t._dbInfo,w,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=m.delete(e);h.oncomplete=function(){f()},h.onerror=function(){a(_.error)},h.onabort=function(){var p=_.error?_.error:_.transaction.error;a(p)}}catch(p){a(p)}})}).catch(a)});return I(o,r),o}function Ht(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,w,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.clear();l.oncomplete=function(){o()},l.onabort=l.onerror=function(){var _=m.error?m.error:m.transaction.error;f(_)}}catch(_){f(_)}})}).catch(f)});return I(t,e),t}function Gt(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,Z,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.count();m.onsuccess=function(){o(m.result)},m.onerror=function(){f(m.error)}}catch(_){f(_)}})}).catch(f)});return I(t,e),t}function Vt(e,r){var t=this,o=new g(function(f,a){if(e<0){f(null);return}t.ready().then(function(){X(t._dbInfo,Z,function(l,h){if(l)return a(l);try{var m=h.objectStore(t._dbInfo.storeName),_=!1,p=m.openKeyCursor();p.onsuccess=function(){var S=p.result;if(!S){f(null);return}e===0||_?f(S.key):(_=!0,S.advance(e))},p.onerror=function(){a(p.error)}}catch(S){a(S)}})}).catch(a)});return I(o,r),o}function Qt(e){var r=this,t=new g(function(o,f){r.ready().then(function(){X(r._dbInfo,Z,function(a,l){if(a)return f(a);try{var h=l.objectStore(r._dbInfo.storeName),m=h.openKeyCursor(),_=[];m.onsuccess=function(){var p=m.result;if(!p){o(_);return}_.push(p.key),p.continue()},m.onerror=function(){f(m.error)}}catch(p){f(p)}})}).catch(f)});return I(t,e),t}function Xt(e,r){r=W.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,f;if(!e.name)f=g.reject("Invalid arguments");else{var a=e.name===t.name&&o._dbInfo.db,l=a?g.resolve(o._dbInfo.db):Q(e).then(function(h){var m=U[e.name],_=m.forages;m.db=h;for(var p=0;p<_.length;p++)_[p]._dbInfo.db=h;return h});e.storeName?f=l.then(function(h){if(h.objectStoreNames.contains(e.storeName)){var m=h.version+1;j(e);var _=U[e.name],p=_.forages;h.close();for(var S=0;S<p.length;S++){var R=p[S];R._dbInfo.db=null,R._dbInfo.version=m}var x=new g(function(N,F){var M=A.open(e.name,m);M.onerror=function(H){var ne=M.result;ne.close(),F(H)},M.onupgradeneeded=function(){var H=M.result;H.deleteObjectStore(e.storeName)},M.onsuccess=function(){var H=M.result;H.close(),N(H)}});return x.then(function(N){_.db=N;for(var F=0;F<p.length;F++){var M=p[F];M._dbInfo.db=N,z(M._dbInfo)}}).catch(function(N){throw(Y(e,N)||g.resolve()).catch(function(){}),N})}}):f=l.then(function(h){j(e);var m=U[e.name],_=m.forages;h.close();for(var p=0;p<_.length;p++){var S=_[p];S._dbInfo.db=null}var R=new g(function(x,N){var F=A.deleteDatabase(e.name);F.onerror=function(){var M=F.result;M&&M.close(),N(F.error)},F.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},F.onsuccess=function(){var M=F.result;M&&M.close(),x(M)}});return R.then(function(x){m.db=x;for(var N=0;N<_.length;N++){var F=_[N];z(F._dbInfo)}}).catch(function(x){throw(Y(e,x)||g.resolve()).catch(function(){}),x})})}return I(f,r),f}var Jt={_driver:"asyncStorage",_initStorage:jt,_support:O(),iterate:zt,getItem:Wt,setItem:Yt,removeItem:Kt,clear:Ht,length:Gt,key:Vt,keys:Qt,dropInstance:Xt};function $t(){return typeof openDatabase=="function"}var J="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Zt="~~local_forage_type~",Me=/^~~local_forage_type~([^~]+)~/,ie="__lfsc__:",me=ie.length,_e="arbf",pe="blob",Fe="si08",Ue="ui08",je="uic8",We="si16",ze="si32",Ye="ur16",Ke="ui32",He="fl32",Ge="fl64",Ve=me+_e.length,Qe=Object.prototype.toString;function Xe(e){var r=e.length*.75,t=e.length,o,f=0,a,l,h,m;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var _=new ArrayBuffer(r),p=new Uint8Array(_);for(o=0;o<t;o+=4)a=J.indexOf(e[o]),l=J.indexOf(e[o+1]),h=J.indexOf(e[o+2]),m=J.indexOf(e[o+3]),p[f++]=a<<2|l>>4,p[f++]=(l&15)<<4|h>>2,p[f++]=(h&3)<<6|m&63;return _}function ge(e){var r=new Uint8Array(e),t="",o;for(o=0;o<r.length;o+=3)t+=J[r[o]>>2],t+=J[(r[o]&3)<<4|r[o+1]>>4],t+=J[(r[o+1]&15)<<2|r[o+2]>>6],t+=J[r[o+2]&63];return r.length%3===2?t=t.substring(0,t.length-1)+"=":r.length%3===1&&(t=t.substring(0,t.length-2)+"=="),t}function qt(e,r){var t="";if(e&&(t=Qe.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&Qe.call(e.buffer)==="[object ArrayBuffer]")){var o,f=ie;e instanceof ArrayBuffer?(o=e,f+=_e):(o=e.buffer,t==="[object Int8Array]"?f+=Fe:t==="[object Uint8Array]"?f+=Ue:t==="[object Uint8ClampedArray]"?f+=je:t==="[object Int16Array]"?f+=We:t==="[object Uint16Array]"?f+=Ye:t==="[object Int32Array]"?f+=ze:t==="[object Uint32Array]"?f+=Ke:t==="[object Float32Array]"?f+=He:t==="[object Float64Array]"?f+=Ge:r(new Error("Failed to get type for BinaryArray"))),r(f+ge(o))}else if(t==="[object Blob]"){var a=new FileReader;a.onload=function(){var l=Zt+e.type+"~"+ge(this.result);r(ie+pe+l)},a.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(l){console.error("Couldn't convert value into a JSON string: ",e),r(null,l)}}function kt(e){if(e.substring(0,me)!==ie)return JSON.parse(e);var r=e.substring(Ve),t=e.substring(me,Ve),o;if(t===pe&&Me.test(r)){var f=r.match(Me);o=f[1],r=r.substring(f[0].length)}var a=Xe(r);switch(t){case _e:return a;case pe:return E([a],{type:o});case Fe:return new Int8Array(a);case Ue:return new Uint8Array(a);case je:return new Uint8ClampedArray(a);case We:return new Int16Array(a);case Ye:return new Uint16Array(a);case ze:return new Int32Array(a);case Ke:return new Uint32Array(a);case He:return new Float32Array(a);case Ge:return new Float64Array(a);default:throw new Error("Unkown type: "+t)}}var be={serialize:qt,deserialize:kt,stringToBuffer:Xe,bufferToString:ge};function Je(e,r,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function er(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=typeof e[o]!="string"?e[o].toString():e[o];var f=new g(function(a,l){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(h){return l(h)}t.db.transaction(function(h){Je(h,t,function(){r._dbInfo=t,a()},function(m,_){l(_)})},l)});return t.serializer=be,f}function $(e,r,t,o,f,a){e.executeSql(t,o,f,function(l,h){h.code===h.SYNTAX_ERR?l.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(m,_){_.rows.length?a(m,h):Je(m,r,function(){m.executeSql(t,o,f,a)},a)},a):a(l,h)},a)}function tr(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT * FROM "+l.storeName+" WHERE key = ? LIMIT 1",[e],function(m,_){var p=_.rows.length?_.rows.item(0).value:null;p&&(p=l.serializer.deserialize(p)),f(p)},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function rr(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT * FROM "+l.storeName,[],function(m,_){for(var p=_.rows,S=p.length,R=0;R<S;R++){var x=p.item(R),N=x.value;if(N&&(N=l.serializer.deserialize(N)),N=e(N,x.key,R+1),N!==void 0){f(N);return}}f()},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function $e(e,r,t,o){var f=this;e=C(e);var a=new g(function(l,h){f.ready().then(function(){r===void 0&&(r=null);var m=r,_=f._dbInfo;_.serializer.serialize(r,function(p,S){S?h(S):_.db.transaction(function(R){$(R,_,"INSERT OR REPLACE INTO "+_.storeName+" (key, value) VALUES (?, ?)",[e,p],function(){l(m)},function(x,N){h(N)})},function(R){if(R.code===R.QUOTA_ERR){if(o>0){l($e.apply(f,[e,m,t,o-1]));return}h(R)}})})}).catch(h)});return I(a,t),a}function nr(e,r,t){return $e.apply(this,[e,r,t,1])}function ar(e,r){var t=this;e=C(e);var o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"DELETE FROM "+l.storeName+" WHERE key = ?",[e],function(){f()},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function or(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"DELETE FROM "+a.storeName,[],function(){o()},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function ir(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"SELECT COUNT(key) as c FROM "+a.storeName,[],function(h,m){var _=m.rows.item(0).c;o(_)},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function fr(e,r){var t=this,o=new g(function(f,a){t.ready().then(function(){var l=t._dbInfo;l.db.transaction(function(h){$(h,l,"SELECT key FROM "+l.storeName+" WHERE id = ? LIMIT 1",[e+1],function(m,_){var p=_.rows.length?_.rows.item(0).key:null;f(p)},function(m,_){a(_)})})}).catch(a)});return I(o,r),o}function ur(e){var r=this,t=new g(function(o,f){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(l){$(l,a,"SELECT key FROM "+a.storeName,[],function(h,m){for(var _=[],p=0;p<m.rows.length;p++)_.push(m.rows.item(p).key);o(_)},function(h,m){f(m)})})}).catch(f)});return I(t,e),t}function sr(e){return new g(function(r,t){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(f,a){for(var l=[],h=0;h<a.rows.length;h++)l.push(a.rows.item(h).name);r({db:e,storeNames:l})},function(f,a){t(a)})},function(o){t(o)})})}function cr(e,r){r=W.apply(this,arguments);var t=this.config();e=typeof e!="function"&&e||{},e.name||(e.name=e.name||t.name,e.storeName=e.storeName||t.storeName);var o=this,f;return e.name?f=new g(function(a){var l;e.name===t.name?l=o._dbInfo.db:l=openDatabase(e.name,"","",0),e.storeName?a({db:l,storeNames:[e.storeName]}):a(sr(l))}).then(function(a){return new g(function(l,h){a.db.transaction(function(m){function _(x){return new g(function(N,F){m.executeSql("DROP TABLE IF EXISTS "+x,[],function(){N()},function(M,H){F(H)})})}for(var p=[],S=0,R=a.storeNames.length;S<R;S++)p.push(_(a.storeNames[S]));g.all(p).then(function(){l()}).catch(function(x){h(x)})},function(m){h(m)})})}):f=g.reject("Invalid arguments"),I(f,r),f}var lr={_driver:"webSQLStorage",_initStorage:er,_support:$t(),iterate:rr,getItem:tr,setItem:nr,removeItem:ar,clear:or,length:ir,key:fr,keys:ur,dropInstance:cr};function dr(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ze(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function vr(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function hr(){return!vr()||localStorage.length>0}function yr(e){var r=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=Ze(e,r._defaultConfig),hr()?(r._dbInfo=t,t.serializer=be,g.resolve()):g.reject()}function mr(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo.keyPrefix,f=localStorage.length-1;f>=0;f--){var a=localStorage.key(f);a.indexOf(o)===0&&localStorage.removeItem(a)}});return I(t,e),t}function _r(e,r){var t=this;e=C(e);var o=t.ready().then(function(){var f=t._dbInfo,a=localStorage.getItem(f.keyPrefix+e);return a&&(a=f.serializer.deserialize(a)),a});return I(o,r),o}function pr(e,r){var t=this,o=t.ready().then(function(){for(var f=t._dbInfo,a=f.keyPrefix,l=a.length,h=localStorage.length,m=1,_=0;_<h;_++){var p=localStorage.key(_);if(p.indexOf(a)===0){var S=localStorage.getItem(p);if(S&&(S=f.serializer.deserialize(S)),S=e(S,p.substring(l),m++),S!==void 0)return S}}});return I(o,r),o}function gr(e,r){var t=this,o=t.ready().then(function(){var f=t._dbInfo,a;try{a=localStorage.key(e)}catch{a=null}return a&&(a=a.substring(f.keyPrefix.length)),a});return I(o,r),o}function br(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo,f=localStorage.length,a=[],l=0;l<f;l++){var h=localStorage.key(l);h.indexOf(o.keyPrefix)===0&&a.push(h.substring(o.keyPrefix.length))}return a});return I(t,e),t}function wr(e){var r=this,t=r.keys().then(function(o){return o.length});return I(t,e),t}function Sr(e,r){var t=this;e=C(e);var o=t.ready().then(function(){var f=t._dbInfo;localStorage.removeItem(f.keyPrefix+e)});return I(o,r),o}function Er(e,r,t){var o=this;e=C(e);var f=o.ready().then(function(){r===void 0&&(r=null);var a=r;return new g(function(l,h){var m=o._dbInfo;m.serializer.serialize(r,function(_,p){if(p)h(p);else try{localStorage.setItem(m.keyPrefix+e,_),l(a)}catch(S){(S.name==="QuotaExceededError"||S.name==="NS_ERROR_DOM_QUOTA_REACHED")&&h(S),h(S)}})})});return I(f,t),f}function Ir(e,r){if(r=W.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var t=this.config();e.name=e.name||t.name,e.storeName=e.storeName||t.storeName}var o=this,f;return e.name?f=new g(function(a){e.storeName?a(Ze(e,o._defaultConfig)):a(e.name+"/")}).then(function(a){for(var l=localStorage.length-1;l>=0;l--){var h=localStorage.key(l);h.indexOf(a)===0&&localStorage.removeItem(h)}}):f=g.reject("Invalid arguments"),I(f,r),f}var Ar={_driver:"localStorageWrapper",_initStorage:yr,_support:dr(),iterate:pr,getItem:_r,setItem:Er,removeItem:Sr,clear:mr,length:wr,key:gr,keys:br,dropInstance:Ir},Rr=function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},Tr=function(r,t){for(var o=r.length,f=0;f<o;){if(Rr(r[f],t))return!0;f++}return!1},qe=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},re={},ke={},k={INDEXEDDB:Jt,WEBSQL:lr,LOCALSTORAGE:Ar},Dr=[k.INDEXEDDB._driver,k.WEBSQL._driver,k.LOCALSTORAGE._driver],fe=["dropInstance"],we=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(fe),Or={description:"",driver:Dr.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Br(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function Se(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(qe(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var xr=function(){function e(r){v(this,e);for(var t in k)if(k.hasOwnProperty(t)){var o=k[t],f=o._driver;this[t]=f,re[f]||this.defineDriver(o)}this._defaultConfig=Se({},Or),this._config=Se({},this._defaultConfig,r),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(t){if((typeof t>"u"?"undefined":y(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var o in t){if(o==="storeName"&&(t[o]=t[o].replace(/\W/g,"_")),o==="version"&&typeof t[o]!="number")return new Error("Database version must be a number.");this._config[o]=t[o]}return"driver"in t&&t.driver?this.setDriver(this._config.driver):!0}else return typeof t=="string"?this._config[t]:this._config},e.prototype.defineDriver=function(t,o,f){var a=new g(function(l,h){try{var m=t._driver,_=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){h(_);return}for(var p=we.concat("_initStorage"),S=0,R=p.length;S<R;S++){var x=p[S],N=!Tr(fe,x);if((N||t[x])&&typeof t[x]!="function"){h(_);return}}var F=function(){for(var ne=function(Cr){return function(){var Lr=new Error("Method "+Cr+" is not implemented by the current driver"),et=g.reject(Lr);return I(et,arguments[arguments.length-1]),et}},Ee=0,Pr=fe.length;Ee<Pr;Ee++){var Ie=fe[Ee];t[Ie]||(t[Ie]=ne(Ie))}};F();var M=function(ne){re[m]&&console.info("Redefining LocalForage driver: "+m),re[m]=t,ke[m]=ne,l()};"_support"in t?t._support&&typeof t._support=="function"?t._support().then(M,h):M(!!t._support):M(!0)}catch(H){h(H)}});return T(a,o,f),a},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,o,f){var a=re[t]?g.resolve(re[t]):g.reject(new Error("Driver not found."));return T(a,o,f),a},e.prototype.getSerializer=function(t){var o=g.resolve(be);return T(o,t),o},e.prototype.ready=function(t){var o=this,f=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return T(f,t,t),f},e.prototype.setDriver=function(t,o,f){var a=this;qe(t)||(t=[t]);var l=this._getSupportedDrivers(t);function h(){a._config.driver=a.driver()}function m(S){return a._extend(S),h(),a._ready=a._initStorage(a._config),a._ready}function _(S){return function(){var R=0;function x(){for(;R<S.length;){var N=S[R];return R++,a._dbInfo=null,a._ready=null,a.getDriver(N).then(m).catch(x)}h();var F=new Error("No available storage method found.");return a._driverSet=g.reject(F),a._driverSet}return x()}}var p=this._driverSet!==null?this._driverSet.catch(function(){return g.resolve()}):g.resolve();return this._driverSet=p.then(function(){var S=l[0];return a._dbInfo=null,a._ready=null,a.getDriver(S).then(function(R){a._driver=R._driver,h(),a._wrapLibraryMethodsWithReady(),a._initDriver=_(l)})}).catch(function(){h();var S=new Error("No available storage method found.");return a._driverSet=g.reject(S),a._driverSet}),T(this._driverSet,o,f),this._driverSet},e.prototype.supports=function(t){return!!ke[t]},e.prototype._extend=function(t){Se(this,t)},e.prototype._getSupportedDrivers=function(t){for(var o=[],f=0,a=t.length;f<a;f++){var l=t[f];this.supports(l)&&o.push(l)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,o=we.length;t<o;t++)Br(this,we[t])},e.prototype.createInstance=function(t){return new e(t)},e}(),Nr=new xr;c.exports=Nr},{3:3}]},{},[4])(4)})});var At=tt((mn,se)=>{"use strict";var ot,it,ft,ut,st,ct,lt,dt,vt,ue,Te,ht,yt,ee,mt,_t,pt,gt,bt,wt,St,Et,It;(function(i){var u=typeof global=="object"?global:typeof self=="object"?self:typeof this=="object"?this:{};typeof define=="function"&&define.amd?define("tslib",["exports"],function(s){i(n(u,n(s)))}):typeof se=="object"&&typeof se.exports=="object"?i(n(u,n(se.exports))):i(n(u));function n(s,c){return s!==u&&(typeof Object.create=="function"?Object.defineProperty(s,"__esModule",{value:!0}):s.__esModule=!0),function(d,y){return s[d]=c?c(d,y):y}}})(function(i){var u=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(n,s){n.__proto__=s}||function(n,s){for(var c in s)s.hasOwnProperty(c)&&(n[c]=s[c])};ot=function(n,s){u(n,s);function c(){this.constructor=n}n.prototype=s===null?Object.create(s):(c.prototype=s.prototype,new c)},it=Object.assign||function(n){for(var s,c=1,d=arguments.length;c<d;c++){s=arguments[c];for(var y in s)Object.prototype.hasOwnProperty.call(s,y)&&(n[y]=s[y])}return n},ft=function(n,s){var c={};for(var d in n)Object.prototype.hasOwnProperty.call(n,d)&&s.indexOf(d)<0&&(c[d]=n[d]);if(n!=null&&typeof Object.getOwnPropertySymbols=="function")for(var y=0,d=Object.getOwnPropertySymbols(n);y<d.length;y++)s.indexOf(d[y])<0&&Object.prototype.propertyIsEnumerable.call(n,d[y])&&(c[d[y]]=n[d[y]]);return c},ut=function(n,s,c,d){var y=arguments.length,v=y<3?s:d===null?d=Object.getOwnPropertyDescriptor(s,c):d,b;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(n,s,c,d);else for(var A=n.length-1;A>=0;A--)(b=n[A])&&(v=(y<3?b(v):y>3?b(s,c,v):b(s,c))||v);return y>3&&v&&Object.defineProperty(s,c,v),v},st=function(n,s){return function(c,d){s(c,d,n)}},ct=function(n,s){if(typeof Reflect=="object"&&typeof Reflect.metadata=="function")return Reflect.metadata(n,s)},lt=function(n,s,c,d){function y(v){return v instanceof c?v:new c(function(b){b(v)})}return new(c||(c=Promise))(function(v,b){function A(g){try{E(d.next(g))}catch(I){b(I)}}function O(g){try{E(d.throw(g))}catch(I){b(I)}}function E(g){g.done?v(g.value):y(g.value).then(A,O)}E((d=d.apply(n,s||[])).next())})},dt=function(n,s){var c={label:0,sent:function(){if(v[0]&1)throw v[1];return v[1]},trys:[],ops:[]},d,y,v,b;return b={next:A(0),throw:A(1),return:A(2)},typeof Symbol=="function"&&(b[Symbol.iterator]=function(){return this}),b;function A(E){return function(g){return O([E,g])}}function O(E){if(d)throw new TypeError("Generator is already executing.");for(;c;)try{if(d=1,y&&(v=E[0]&2?y.return:E[0]?y.throw||((v=y.return)&&v.call(y),0):y.next)&&!(v=v.call(y,E[1])).done)return v;switch(y=0,v&&(E=[E[0]&2,v.value]),E[0]){case 0:case 1:v=E;break;case 4:return c.label++,{value:E[1],done:!1};case 5:c.label++,y=E[1],E=[0];continue;case 7:E=c.ops.pop(),c.trys.pop();continue;default:if(v=c.trys,!(v=v.length>0&&v[v.length-1])&&(E[0]===6||E[0]===2)){c=0;continue}if(E[0]===3&&(!v||E[1]>v[0]&&E[1]<v[3])){c.label=E[1];break}if(E[0]===6&&c.label<v[1]){c.label=v[1],v=E;break}if(v&&c.label<v[2]){c.label=v[2],c.ops.push(E);break}v[2]&&c.ops.pop(),c.trys.pop();continue}E=s.call(n,c)}catch(g){E=[6,g],y=0}finally{d=v=0}if(E[0]&5)throw E[1];return{value:E[0]?E[1]:void 0,done:!0}}},It=function(n,s,c,d){d===void 0&&(d=c),n[d]=s[c]},vt=function(n,s){for(var c in n)c!=="default"&&!s.hasOwnProperty(c)&&(s[c]=n[c])},ue=function(n){var s=typeof Symbol=="function"&&Symbol.iterator,c=s&&n[s],d=0;if(c)return c.call(n);if(n&&typeof n.length=="number")return{next:function(){return n&&d>=n.length&&(n=void 0),{value:n&&n[d++],done:!n}}};throw new TypeError(s?"Object is not iterable.":"Symbol.iterator is not defined.")},Te=function(n,s){var c=typeof Symbol=="function"&&n[Symbol.iterator];if(!c)return n;var d=c.call(n),y,v=[],b;try{for(;(s===void 0||s-- >0)&&!(y=d.next()).done;)v.push(y.value)}catch(A){b={error:A}}finally{try{y&&!y.done&&(c=d.return)&&c.call(d)}finally{if(b)throw b.error}}return v},ht=function(){for(var n=[],s=0;s<arguments.length;s++)n=n.concat(Te(arguments[s]));return n},yt=function(){for(var n=0,s=0,c=arguments.length;s<c;s++)n+=arguments[s].length;for(var d=Array(n),y=0,s=0;s<c;s++)for(var v=arguments[s],b=0,A=v.length;b<A;b++,y++)d[y]=v[b];return d},ee=function(n){return this instanceof ee?(this.v=n,this):new ee(n)},mt=function(n,s,c){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var d=c.apply(n,s||[]),y,v=[];return y={},b("next"),b("throw"),b("return"),y[Symbol.asyncIterator]=function(){return this},y;function b(T){d[T]&&(y[T]=function(C){return new Promise(function(W,L){v.push([T,C,W,L])>1||A(T,C)})})}function A(T,C){try{O(d[T](C))}catch(W){I(v[0][3],W)}}function O(T){T.value instanceof ee?Promise.resolve(T.value.v).then(E,g):I(v[0][2],T)}function E(T){A("next",T)}function g(T){A("throw",T)}function I(T,C){T(C),v.shift(),v.length&&A(v[0][0],v[0][1])}},_t=function(n){var s,c;return s={},d("next"),d("throw",function(y){throw y}),d("return"),s[Symbol.iterator]=function(){return this},s;function d(y,v){s[y]=n[y]?function(b){return(c=!c)?{value:ee(n[y](b)),done:y==="return"}:v?v(b):b}:v}},pt=function(n){if(!Symbol.asyncIterator)throw new TypeError("Symbol.asyncIterator is not defined.");var s=n[Symbol.asyncIterator],c;return s?s.call(n):(n=typeof ue=="function"?ue(n):n[Symbol.iterator](),c={},d("next"),d("throw"),d("return"),c[Symbol.asyncIterator]=function(){return this},c);function d(v){c[v]=n[v]&&function(b){return new Promise(function(A,O){b=n[v](b),y(A,O,b.done,b.value)})}}function y(v,b,A,O){Promise.resolve(O).then(function(E){v({value:E,done:A})},b)}},gt=function(n,s){return Object.defineProperty?Object.defineProperty(n,"raw",{value:s}):n.raw=s,n},bt=function(n){if(n&&n.__esModule)return n;var s={};if(n!=null)for(var c in n)Object.hasOwnProperty.call(n,c)&&(s[c]=n[c]);return s.default=n,s},wt=function(n){return n&&n.__esModule?n:{default:n}},St=function(n,s){if(!s.has(n))throw new TypeError("attempted to get private field on non-instance");return s.get(n)},Et=function(n,s,c){if(!s.has(n))throw new TypeError("attempted to set private field on non-instance");return s.set(n,c),c},i("__extends",ot),i("__assign",it),i("__rest",ft),i("__decorate",ut),i("__param",st),i("__metadata",ct),i("__awaiter",lt),i("__generator",dt),i("__exportStar",vt),i("__createBinding",It),i("__values",ue),i("__read",Te),i("__spread",ht),i("__spreadArrays",yt),i("__await",ee),i("__asyncGenerator",mt),i("__asyncDelegator",_t),i("__asyncValues",pt),i("__makeTemplateObject",gt),i("__importStar",bt),i("__importDefault",wt),i("__classPrivateFieldGet",St),i("__classPrivateFieldSet",Et)})});var ve=rt(at());import{SDKBase as ln,createSDK as dn}from"@magic-sdk/provider";var Pe={};zr(Pe,{_driver:()=>Ne,_initStorage:()=>Qr,_support:()=>nn,clear:()=>Xr,dropInstance:()=>Jr,getItem:()=>$r,iterate:()=>Zr,key:()=>qr,keys:()=>kr,length:()=>en,removeItem:()=>tn,setItem:()=>rn});var Rt=rt(At(),1),{__extends:_n,__assign:pn,__rest:gn,__decorate:bn,__param:wn,__metadata:Sn,__awaiter:En,__generator:In,__exportStar:An,__createBinding:Rn,__values:Tt,__read:Tn,__spread:Dn,__spreadArrays:On,__await:Bn,__asyncGenerator:xn,__asyncDelegator:Nn,__asyncValues:Pn,__makeTemplateObject:Cn,__importStar:Ln,__importDefault:Mn,__classPrivateFieldGet:Fn,__classPrivateFieldSet:Un}=Rt.default;function Kr(i,u){i=i||[],u=u||{};try{return new Blob(i,u)}catch(d){if(d.name!=="TypeError")throw d;for(var n=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,s=new n,c=0;c<i.length;c+=1)s.append(i[c]);return s.getBlob(u.type)}}var Dt=/^~~local_forage_type~([^~]+)~/,De=9,Ot=De+4,Bt=Object.prototype.toString;function xt(i){var u=i.length*.75,n=i.length;i[i.length-1]==="="&&(u--,i[i.length-2]==="="&&u--);for(var s=new ArrayBuffer(u),c=new Uint8Array(s),d=0,y=0;d<n;d+=4){var v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d]),b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+1]),A="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+2]),O="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(i[d+3]);c[y++]=v<<2|b>>4,c[y++]=(b&15)<<4|A>>2,c[y++]=(A&3)<<6|O&63}return s}function Oe(i){for(var u=new Uint8Array(i),n="",s=0;s<u.length;s+=3)n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[s]>>2],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[s]&3)<<4|u[s+1]>>4],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[s+1]&15)<<2|u[s+2]>>6],n+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[s+2]&63];return u.length%3===2?n=n.substring(0,n.length-1)+"=":u.length%3===1&&(n=n.substring(0,n.length-2)+"=="),n}function Hr(i,u){var n="";if(i&&(n=Bt.call(i)),i&&(n==="[object ArrayBuffer]"||i.buffer&&Bt.call(i.buffer)==="[object ArrayBuffer]")){var s=void 0,c="__lfsc__:";i instanceof ArrayBuffer?(s=i,c+="arbf"):(s=i.buffer,n==="[object Int8Array]"?c+="si08":n==="[object Uint8Array]"?c+="ui08":n==="[object Uint8ClampedArray]"?c+="uic8":n==="[object Int16Array]"?c+="si16":n==="[object Uint16Array]"?c+="ur16":n==="[object Int32Array]"?c+="si32":n==="[object Uint32Array]"?c+="ui32":n==="[object Float32Array]"?c+="fl32":n==="[object Float64Array]"?c+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(c+Oe(s))}else if(n==="[object Blob]"){var d=new FileReader;d.onload=function(){var y="~~local_forage_type~"+i.type+"~"+Oe(this.result);u("__lfsc__:blob"+y)},d.readAsArrayBuffer(i)}else try{u(JSON.stringify(i))}catch(y){console.error("Couldn't convert value into a JSON string: ",i),u(null,y)}}function Gr(i){if(i.substring(0,De)!=="__lfsc__:")return JSON.parse(i);var u=i.substring(Ot),n=i.substring(De,Ot),s;if(n==="blob"&&Dt.test(u)){var c=u.match(Dt);s=c[1],u=u.substring(c[0].length)}var d=xt(u);switch(n){case"arbf":return d;case"blob":return Kr([d],{type:s});case"si08":return new Int8Array(d);case"ui08":return new Uint8Array(d);case"uic8":return new Uint8ClampedArray(d);case"si16":return new Int16Array(d);case"ur16":return new Uint16Array(d);case"si32":return new Int32Array(d);case"ui32":return new Uint32Array(d);case"fl32":return new Float32Array(d);case"fl64":return new Float64Array(d);default:throw new Error("Unkown type: "+n)}}function Be(i){var u,n;if(i===null||typeof i!="object"||"isActiveClone"in i)return i;var s=i instanceof Date?new Date(i):i.constructor();try{for(var c=Tt(Object.keys(i)),d=c.next();!d.done;d=c.next()){var y=d.value;Object.prototype.hasOwnProperty.call(i,y)&&(i.isActiveClone=null,s[y]=Be(i[y]),delete i.isActiveClone)}}catch(v){u={error:v}}finally{try{d&&!d.done&&(n=c.return)&&n.call(c)}finally{if(u)throw u.error}}return s}function xe(i,u){return(i.name||u.name)+"/"+(i.storeName||u.storeName)+"/"}function G(i,u){u&&i.then(function(n){u(null,n)},function(n){u(n)})}function Vr(){for(var i=[],u=0;u<arguments.length;u++)i[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Nt(i,u){var n=this;if(u=Vr.apply(this,arguments),i=typeof i!="function"&&i||{},!i.name){var s=this.config();i.name=i.name||s.name,i.storeName=i.storeName||s.storeName}var c;return i.name?c=new Promise(function(d){i.storeName?d(xe(i,n._defaultConfig)):d(i.name+"/")}):c=Promise.reject("Invalid arguments"),{promise:c,callback:u}}function ce(i){return typeof i!="string"&&(console.warn(i+" used as a key, but it is not a string."),i=String(i)),i}var Pt={bufferToString:Oe,deserialize:Gr,serialize:Hr,stringToBuffer:xt};var Ne="localforage-driver-memory",le={},Ct=function(){function i(u){this.kp=u,this.data={}}return i.resolve=function(u){return le[u]||(le[u]=new i(u)),le[u]},i.prototype.clear=function(){this.data={}},i.prototype.drop=function(){this.clear(),delete le[this.kp]},i.prototype.get=function(u){return this.data[u]},i.prototype.key=function(u){return this.keys()[u]},i.prototype.keys=function(){return Object.keys(this.data)},i.prototype.rm=function(u){delete this.data[u]},i.prototype.set=function(u,n){this.data[u]=n},i}();function Qr(i){var u=i?Be(i):{},n=xe(u,this._defaultConfig),s=Ct.resolve(n);return this._dbInfo=u,this._dbInfo.serializer=Pt,this._dbInfo.keyPrefix=n,this._dbInfo.mStore=s,Promise.resolve()}function Xr(i){var u=this,n=this.ready().then(function(){u._dbInfo.mStore.clear()});return G(n,i),n}function Jr(i,u){var n=Nt.apply(this,arguments),s=n.promise,c=n.callback,d=s.then(function(y){Ct.resolve(y).drop()});return G(d,c),s}function $r(i,u){var n=this;i=ce(i);var s=this.ready().then(function(){var c=n._dbInfo.mStore.get(i);return c==null?null:n._dbInfo.serializer.deserialize(c)});return G(s,u),s}function Zr(i,u){var n=this,s=this.ready().then(function(){for(var c=n._dbInfo.mStore,d=c.keys(),y=0;y<d.length;y++){var v=c.get(d[y]);if(v&&(v=n._dbInfo.serializer.deserialize(v)),v=i(v,d[y],y+1),v!==void 0)return v}});return G(s,u),s}function qr(i,u){var n=this,s=this.ready().then(function(){var c;try{c=n._dbInfo.mStore.key(i),c===void 0&&(c=null)}catch{c=null}return c});return G(s,u),s}function kr(i){var u=this,n=this.ready().then(function(){return u._dbInfo.mStore.keys()});return G(n,i),n}function en(i){var u=this.keys().then(function(n){return n.length});return G(u,i),u}function tn(i,u){var n=this;i=ce(i);var s=this.ready().then(function(){n._dbInfo.mStore.rm(i)});return G(s,u),s}function rn(i,u,n){var s=this;i=ce(i);var c=this.ready().then(function(){u===void 0&&(u=null);var d=u;return new Promise(function(y,v){s._dbInfo.serializer.serialize(u,function(b,A){if(A)v(A);else try{s._dbInfo.mStore.set(i,b),y(d)}catch(O){v(O)}})})});return G(c,n),c}var nn=!0;import{createDuplicateIframeWarning as an,createModalNotReadyError as on,createURL as Lt,ViewController as fn}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as Mt}from"@magic-sdk/types";var un={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function sn(i){for(let[u,n]of Object.entries(un))i.style[u]=n}function cn(i){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(n=>n.src.includes(i))}var de=class extends fn{activeElement=null;iframe;relayerSrc=Lt(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(u=>{let n=()=>{if(cn(encodeURIComponent(this.parameters)))an().log();else{let s=document.createElement("iframe");s.classList.add("magic-iframe"),s.dataset.magicIframeLabel=Lt(this.endpoint).host,s.title="Secure Modal",s.src=this.relayerSrc,s.allow="clipboard-read; clipboard-write",sn(s),document.body.appendChild(s),u(s)}};["loaded","interactive","complete"].includes(document.readyState)?n():window.addEventListener("load",n,!1)}),this.iframe.then(u=>{u instanceof HTMLIFrameElement&&u.addEventListener("load",async()=>{this.heartbeatDebounce()})}),window.addEventListener("message",u=>{if(u.origin===this.endpoint&&u.data.msgType){if(u.data.msgType.includes(Mt.MAGIC_PONG))this.lastPongTime=Date.now();else if(u.data.msgType.includes(Mt.MAGIC_THIRD_PARTY_WALLET_REQUEST)){this.thirdPartyWalletRequestHandler(u.data);return}if(u.data&&this.messageHandlers.size){u.data.response=u.data.response??{},this.stopHeartBeat();for(let n of this.messageHandlers.values())n(u)}}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}async showOverlay(){let u=await this.iframe;u.style.display="block",u.style.zIndex="2147483647",u.style.opacity="1",this.activeElement=document.activeElement,u.focus()}async hideOverlay(){let u=await this.iframe;u.style.display="none",u.style.zIndex="-1",u.style.opacity="0",this.activeElement?.focus&&this.activeElement.focus(),this.activeElement=null}async _post(u){let n=await this.iframe;if(n&&n.contentWindow)n.contentWindow.postMessage(u,this.endpoint);else throw on()}async checkRelayerExistsInDOM(){let u=await this.iframe;return!u||!u.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(s=>s.src.includes(encodeURIComponent(this.parameters)))}async reloadRelayer(){let u=await this.iframe;if(this.stopHeartBeat(),!u){this.init(),console.warn("Magic SDK: Modal lost, re-initiating");return}if(!u.contentWindow){document.body.appendChild(u),console.warn("Magic SDK: Modal did not append in the iframe, re-initiating");return}u&&(u.src=this.relayerSrc)}};export*from"@magic-sdk/provider";export*from"@magic-sdk/types";var $n=dn(ln,{platform:"web",sdkName:"magic-sdk",version:"33.7.1",defaultEndpoint:"https://auth.magic.link/",ViewController:de,configureStorage:async()=>{let i=ve.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await i.defineDriver(Pe),await i.setDriver([ve.default.INDEXEDDB,ve.default.LOCALSTORAGE,Ne]),i}});export{$n 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) \`${n}\``:n||(t+=`
3
3
  - Extension \`${r.name}\` does not support ${k.platform} environments.`)}),new Oe(ye.IncompatibleExtensions,t)}function Xr(e){let t=r=>{let n=r+1,i=n%10,s=n%100;return i===1&&s!==11?`${n}st`:i===2&&s!==12?`${n}nd`:i===3&&s!==13?`${n}rd`:`${n}th`};return new Oe(ye.InvalidArgument,`Invalid ${t(e.argument)} argument given to \`${e.procedure}\`.
4
4
  Expected: \`${e.expected}\`
5
- Received: \`${e.received}\``)}function Ut(){return new xe(ge.DuplicateIframe,"Duplicate iframes found.")}function zr(){return new xe(ge.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 xe(ge.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 \`${k.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function Qr(e){let{method:t,removalVersions:r,useInstead:n}=e,i=r[k.sdkName],s=n?` Use \`${n}\` instead.`:"",f=`\`${t}\` will be removed from \`${k.sdkName}\` in version \`${i}\`.${s}`;return new xe(ge.DeprecationNotice,f)}function*lo(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}var uo=lo();function fo(){return Math.floor(Math.random()*1e5)+1}function Ft(){return k.sdkName==="@magic-sdk/react-native-bare"||k.sdkName==="@magic-sdk/react-native-expo"?fo():uo.next().value}var Wt={};ha(Wt,{clear:()=>ho,getItem:()=>ae,iterate:()=>Zr,key:()=>po,keys:()=>vo,length:()=>mo,removeItem:()=>Se,setItem:()=>_e});var nt;function we(e){return async(...t)=>(nt||(nt=await k.configureStorage()),await nt.ready(),nt[e](...t))}var ae=we("getItem"),_e=we("setItem"),Se=we("removeItem"),ho=we("clear"),mo=we("length"),po=we("key"),vo=we("keys"),Zr=we("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 lt="STORE_KEY_PRIVATE_KEY",He="STORE_KEY_PUBLIC_JWK",tn="ECDSA",yo="P-256",go={name:tn,namedCurve:yo};function Ye(){let e=typeof window<"u"&&!!window.crypto,t=e&&!!window.crypto.subtle;return e&&t}function rn(){Se(He),Se(lt)}async function nn(){let e=await Eo();if(!e){console.info("unable to creat kee publicy or webcrypto is unsupported");return}let{subtle:t}=window.crypto,r=await ae(lt);if(!r||!t){console.info("unable to find private key or webcrypto unsupported");return}let n={iat:Math.floor(new Date().getTime()/1e3),jti:en()},i={protected:Lr(JSON.stringify({typ:"dpop+jwt",alg:"ES256",jwk:e})),claims:Lr(JSON.stringify(n))},s=Io(`${i.protected}.${i.claims}`),f={name:tn,hash:{name:"SHA-256"}},h=Ro(new Uint8Array(await t.sign(f,r,s)));return`${i.protected}.${i.claims}.${h}`}async function Eo(){if(!Ye()){console.info("webcrypto is not supported");return}return await ae(He)||await _o(),ae(He)}async function _o(){let{subtle:e}=window.crypto,t=await e.generateKey(go,!1,["sign"]),r=await e.exportKey("jwk",t.publicKey);await _e(lt,t.privateKey),await _e(He,r)}function Lr(e){return an(wo(e))}function Io(e){return new TextEncoder().encode(e)}function an(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function wo(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(r,16)))}function Ro(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 bo(e){return!!e[on]}function st(e){return bo(e)||(e.jsonrpc=e.jsonrpc??"2.0",e.id=Ft(),e.method=e.method??"noop",e.params=e.params??[],sn(e)),e}function D(e,t=[]){return sn({params:t,method:e,jsonrpc:"2.0",id:Ft()})}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):Wr(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===be.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}}},Ao=pa(va()),un=class extends Ao.default{};function kt(){let e=new un;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...n)=>(e[t].apply(e,n),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}var dn=Symbol("isPromiEvent");function fn(e){return!!e[dn]}function me(e){let t=je(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:n}=kt(),i=Symbol("Promise.then"),s=Symbol("Promise.catch"),f=Symbol("Promise.finally"),h=(v,b)=>(...g)=>{let A=b[v].apply(b,g);return E(A)},E=v=>Object.assign(v,{[dn]:!0,[i]:v[i]||v.then,[s]:v[s]||v.catch,[f]:v[f]||v.finally,then:h(i,v),catch:h(s,v),finally:h(f,v),on:n("on",v),once:n("once",v),addListener:n("addListener",v),off:n("off",v),removeListener:n("removeListener",v),removeAllListeners:n("removeAllListeners",v),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),p=E(t.then(v=>(p.emit("done",v),p.emit("settled"),v),v=>{throw p.emit("error",v),p.emit("settled"),v}));return p.on(St.ClosedByUser,()=>{p.emit(At.ClosedByUser)}),p}function je(e){return new Promise((t,r)=>{let n=e(t,r);Promise.resolve(n).catch(r)})}var Re=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){return this.sdk.thirdPartyWallets.isConnected&&!Rr.includes(e.method)?this.requestThirdPartyWallets(e):this.requestOverlay(e)}requestThirdPartyWallets(e){return me((t,r)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(t).catch(r)})}requestOverlay(e){let t=this.overlay.post(Ae.MAGIC_HANDLE_REQUEST,st(e)),r=me((i,s)=>{t.then(f=>{if(n(),f.hasError)s(new xt(f.payload.error));else if(f.hasResult)i(f.payload.result);else throw Hr()}).catch(f=>{n(),s(f)})}),n=this.overlay.on(re.MAGIC_HANDLE_EVENT,i=>{let{response:s}=i.data;if(s.id===e.id&&s.result?.event){let{event:f,params:h=[]}=s.result;r.emit(f,...h)}});return r}createIntermediaryEvent(e,t){return r=>{let n=D(O.IntermediaryEvent,[{payloadId:t,eventType:e,args:r}]);this.request(n)}}};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"},Oo=class extends Re{loginWithMagicLink(e){let t=k.sdkName==="@magic-sdk/react-native"||k.sdkName==="@magic-sdk/react-native-bare"||k.sdkName==="@magic-sdk/react-native-expo";if(t&&hn(k.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:n=!0,redirectURI:i,overrides:s,lifespan:f}=e,h=D(this.sdk.testMode?O.LoginWithMagicLinkTestMode:O.LoginWithMagicLink,[{email:r,showUI:n,redirectURI:i,overrides:s,lifespan:f}]);return this.request(h)}loginWithSMS(e){let{phoneNumber:t,showUI:r=!0,lifespan:n}=e,i=D(this.sdk.testMode?O.LoginWithSmsTestMode:O.LoginWithSms,[{phoneNumber:t,showUI:r,lifespan:n}]),s=this.request(i);return!r&&s&&(s.on(ie.VerifySmsOtp,f=>{this.createIntermediaryEvent(ie.VerifySmsOtp,i.id)(f)}),s.on(ie.VerifyMFACode,f=>{this.createIntermediaryEvent(ie.VerifyMFACode,i.id)(f)}),s.on(ie.LostDevice,()=>{this.createIntermediaryEvent(ie.LostDevice,i.id)()}),s.on(ie.VerifyRecoveryCode,f=>{this.createIntermediaryEvent(ie.VerifyRecoveryCode,i.id)(f)}),s.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()})),s}loginWithEmailOTP(e){let{email:t,showUI:r,deviceCheckUI:n,overrides:i,lifespan:s}=e,f=D(this.sdk.testMode?O.LoginWithEmailOTPTestMode:O.LoginWithEmailOTP,[{email:t,showUI:r,deviceCheckUI:n,overrides:i,lifespan:s}]),h=this.request(f);return!n&&h&&h.on(Ze.Retry,()=>{this.createIntermediaryEvent(Ze.Retry,f.id)()}),!r&&h&&(h.on(ne.VerifyEmailOtp,E=>{this.createIntermediaryEvent(ne.VerifyEmailOtp,f.id)(E)}),h.on(ne.VerifyMFACode,E=>{this.createIntermediaryEvent(ne.VerifyMFACode,f.id)(E)}),h.on(ne.LostDevice,()=>{this.createIntermediaryEvent(ne.LostDevice,f.id)()}),h.on(ne.VerifyRecoveryCode,E=>{this.createIntermediaryEvent(ne.VerifyRecoveryCode,f.id)(E)}),h.on(ne.Cancel,()=>{this.createIntermediaryEvent(ne.Cancel,f.id)()})),h}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:r}=e||{},n=t??"";if(!t&&k.platform==="web"){n=window.location.search;let s=window.location.origin+window.location.pathname;window.history.replaceState(null,"",s)}let i=D(this.sdk.testMode?O.LoginWithCredentialTestMode:O.LoginWithCredential,[n,r]);return this.request(i)}setAuthorizationToken(e){let t=D(O.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:r=!0}=e,n=D(this.sdk.testMode?O.UpdateEmailTestMode:O.UpdateEmail,[{email:t,showUI:r}]),i=this.request(n);return r||(i.on(Q.Retry,()=>{this.createIntermediaryEvent(Q.Retry,n.id)()}),i.on(Q.Cancel,()=>{this.createIntermediaryEvent(Q.Cancel,n.id)()}),i.on(Q.VerifyEmailOtp,s=>{this.createIntermediaryEvent(Q.VerifyEmailOtp,n.id)(s)}),i.on(Q.VerifyMFACode,s=>{this.createIntermediaryEvent(Q.VerifyMFACode,n.id)(s)}),i.on(Y.RetryWithNewEmail,s=>{this.createIntermediaryEvent(Y.RetryWithNewEmail,n.id)(s)}),i.on(Y.Cancel,()=>{this.createIntermediaryEvent(Y.Cancel,n.id)()}),i.on(Y.VerifyEmailOtp,s=>{this.createIntermediaryEvent(Y.VerifyEmailOtp,n.id)(s)})),i}},Bt="ds",Gt="ek",Vt="iv",jt="AES-GCM",To=256;async function mn(){let e=[];await Zr((t,r,n)=>{r.startsWith(`${Bt}_`)&&e.push(r)});for(let t of e)await Se(t)}function pn(e){let t="",r=new Uint8Array(e),n=r.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(r[i]);return window.btoa(t)}function vn(e){let t=window.atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer}async function No(){if(!Ye()){console.info("webcrypto is not supported");return}let{crypto:e}=window;return await ae(Vt)||e.getRandomValues(new Uint8Array(12))}async function Mo(){if(!Ye()){console.info("webcrypto is not supported");return}let{subtle:e}=window.crypto;return await ae(Gt)||await e.generateKey({name:jt,length:To},!1,["encrypt","decrypt"])}async function Co(e,t){let r=await No(),n=await Mo();if(!r||!n||!e)return;let i=vn(e),{subtle:s}=window.crypto,f=await s.encrypt({name:jt,iv:r},n,i),h=pn(f);await _e(`${Bt}_${t}`,h),await _e(Gt,n),await _e(Vt,r)}async function Po(e){let t=await ae(`${Bt}_${e}`),r=await ae(Vt),n=await ae(Gt);if(!r||!t||!n||!Ye())return;let{subtle:i}=window.crypto,s=await i.decrypt({name:jt,iv:r},n,vn(t));return pn(s)}function De(e,t){return t?new URL(e,t):new URL(e)}var Lo=class extends Re{getIdToken(e){let t=D(this.sdk.testMode?O.GetIdTokenTestMode:O.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=D(this.sdk.testMode?O.GenerateIdTokenTestMode:O.GenerateIdToken,[e]);return this.request(t)}getInfo(){let e=D(O.GetInfo,[]);return this.request(e)}isLoggedIn(){return me(async(e,t)=>{try{let r=!1;this.sdk.useStorageCache&&(r=await ae(this.localForageIsLoggedInKey)==="true",r&&e(!0));let n=D(this.sdk.testMode?O.IsLoggedInTestMode:O.IsLoggedIn),i=await this.request(n);this.sdk.useStorageCache&&(i?_e(this.localForageIsLoggedInKey,!0):Se(this.localForageIsLoggedInKey),r&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(r){t(r)}})}logout(){return Se(this.localForageIsLoggedInKey),Se("rt"),mn(),me(async(e,t)=>{try{let r=D(this.sdk.testMode?O.LogoutTestMode:O.Logout),n=await this.request(r);this.sdk.useStorageCache&&this.emitUserLoggedOut(n),e(n)}catch(r){t(r)}})}requestInfoWithUI(e){let t=D(O.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}showSettings(e){let{showUI:t=!0}=e||{},r=D(this.sdk.testMode?O.UserSettingsTestMode:O.UserSettings,[e]),n=this.request(r);return!t&&n&&(n.on(oe.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(oe.SendNewPhoneNumber,r.id)(i)}),n.on(oe.SendOtpCode,i=>{this.createIntermediaryEvent(oe.SendOtpCode,r.id)(i)}),n.on(oe.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(oe.StartEditPhoneNumber,r.id)()}),n.on(oe.Cancel,()=>{this.createIntermediaryEvent(oe.Cancel,r.id)()}),n.on(Q.VerifyEmailOtp,i=>{this.createIntermediaryEvent(Q.VerifyEmailOtp,r.id)(i)})),n}recoverAccount(e){let{email:t,showUI:r}=e,n=D(this.sdk.testMode?O.RecoverAccountTestMode:O.RecoverAccount,[{email:t,showUI:r}]),i=this.request(n);return!r&&i&&(i.on(se.Cancel,()=>{this.createIntermediaryEvent(se.Cancel,n.id)()}),i.on(se.ResendSms,()=>{this.createIntermediaryEvent(se.ResendSms,n.id)()}),i.on(se.VerifyOtp,s=>{this.createIntermediaryEvent(se.VerifyOtp,n.id)(s)}),i.on(se.UpdateEmail,s=>{this.createIntermediaryEvent(se.UpdateEmail,n.id)(s)}),i.on(Y.Cancel,()=>{this.createIntermediaryEvent(Y.Cancel,n.id)()}),i.on(Y.RetryWithNewEmail,s=>{this.createIntermediaryEvent(Y.RetryWithNewEmail,n.id)(s)}),i.on(Y.VerifyEmailOtp,s=>{this.createIntermediaryEvent(Y.VerifyEmailOtp,n.id)(s)})),i}revealEVMPrivateKey(){let e=D(O.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=D(O.EnableMFA,[{showUI:t}]),n=this.request(r);return!t&&n&&(n.on(Me.VerifyMFACode,i=>{this.createIntermediaryEvent(Me.VerifyMFACode,r.id)(i)}),n.on(Me.Cancel,()=>{this.createIntermediaryEvent(Me.Cancel,r.id)()})),n}disableMFA(e){let{showUI:t=!0}=e,r=D(O.DisableMFA,[{showUI:t}]),n=this.request(r);return!t&&n&&(n.on(Ee.VerifyMFACode,i=>{this.createIntermediaryEvent(Ee.VerifyMFACode,r.id)(i)}),n.on(Ee.LostDevice,i=>{this.createIntermediaryEvent(Ee.LostDevice,r.id)(i)}),n.on(Ee.Cancel,()=>{this.createIntermediaryEvent(Ee.Cancel,r.id)()})),n}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(t=>{t(e)})}localForageIsLoggedInKey="magic_auth_is_logged_in";userLoggedOutCallbacks=[]},Do=class extends Re{connectWithUI(e){let t=me(async(r,n)=>{try{let i=D(O.Login,[{enabledWallets:this.sdk.thirdPartyWallets.enabledWallets,...e}]),s=this.request(i);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:h,callback:E})=>{s.on(h,()=>E(i.id))}),s.on("id-token-created",h=>{t.emit("id-token-created",h)});let f=await s;f.error&&n(f),r(f)}catch(i){n(i)}});return t}showUI(e){return this.request(D(O.ShowUI,[e]))}showAddress(){return this.request(D(O.ShowAddress))}showSendTokensUI(){return this.request(D(O.ShowSendTokensUI))}showOnRamp(){return this.request(D(O.ShowOnRamp))}showNFTs(){return this.request(D(O.ShowNFTs))}showBalances(){return this.request(D(O.ShowBalances))}sign7702Authorization(e){return this.request(D(O.Sign7702Authorization,[e]))}send7702Transaction(e){return this.request(D(O.Send7702Transaction,[e]))}},$o=class extends Re{eventListeners=[];enabledWallets={};isConnected=!1;resetThirdPartyWalletState(){localStorage.removeItem(fe.PROVIDER),localStorage.removeItem(fe.ADDRESS),localStorage.removeItem(fe.CHAIN_ID),this.isConnected=!1}requestOverride(e){if(e.method===O.Login)return this.resetThirdPartyWalletState(),super.request(e);if(e.method===O.GetInfo)return this.getInfo(e);if(e.method===O.IsLoggedIn)return this.isLoggedIn(e);if(e.method===O.Logout)return this.logout(e);switch(localStorage.getItem(fe.PROVIDER)){case"magic-widget":return this.magicWidgetRequest(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}isLoggedIn(e){switch(localStorage.getItem(fe.PROVIDER)){case"magic-widget":return super.requestOverlay(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}getInfo(e){switch(localStorage.getItem(fe.PROVIDER)){case"magic-widget":return super.requestOverlay(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}logout(e){let t=localStorage.getItem(fe.PROVIDER);switch(this.resetThirdPartyWalletState(),t){case"magic-widget":return this.magicWidgetLogout(e);default:return super.request(e)}}magicWidgetRequest(e){return["eth_","wallet_","net_","web3_"].some(t=>e.method?.startsWith(t))||["personal_sign"].includes(e.method)?me((t,r)=>{this.sdk.walletKit.walletRequest(e).then(t).catch(n=>r(new xt(n)))}):super.requestOverlay(e)}magicWidgetLogout(e){return me(async t=>{try{this.sdk.walletKit.clearConnectedState()}catch(r){console.error(r)}return super.requestOverlay(e)})}handleIframeThirdPartyWalletRequest(e){this.magicWidgetRequest(e.payload).then(t=>{this.overlay.postThirdPartyWalletResponse({id:e.payload.id,jsonrpc:"2.0",result:t})}).catch(t=>{this.overlay.postThirdPartyWalletResponse({id:e.payload.id,jsonrpc:"2.0",error:{code:t.code||-32603,message:t.message||"Internal error",data:t.data}})})}},{createBoundEmitterMethod:it,createChainingEmitterMethod:Pe}=kt(),xo=class extends Re{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)){let r=e.map(n=>st(n)).map(n=>this.request(n).then(i=>({jsonrpc:n.jsonrpc??"2.0",id:n.id??null,result:i,error:null})).catch(i=>({jsonrpc:n.jsonrpc??"2.0",id:n.id??null,error:i})));Promise.all(r).then(n=>{t(null,n)})}else this.request(st(e)).then(r=>{t(null,{jsonrpc:e.jsonrpc??"2.0",id:e.id??null,result:r,error:null})}).catch(r=>{t(r,{jsonrpc:e.jsonrpc??"2.0",id:e.id??null,error:r})})}send(e,t){if(typeof e=="string"){let n=D(e,Array.isArray(t)?t:[]);return this.request(n)}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=D(O.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=Pe("on",this);once=Pe("once",this);addListener=Pe("addListener",this);off=Pe("off",this);removeListener=Pe("removeListener",this);removeAllListeners=Pe("removeAllListeners",this);emit=it("emit");eventNames=it("eventNames");listeners=it("listeners");listenerCount=it("listenerCount")},Uo=class extends Re{purchase(e){let t=D(O.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,r=D(O.NFTCheckout,[{...e,walletProvider:t?"web3modal":"magic"}]),n=this.request(r);return t&&(n.on(Ce.Initiated,async i=>{try{let s=await this.request({method:"eth_sendTransaction",params:[i]});this.createIntermediaryEvent(Ce.Success,r.id)(s)}catch{this.createIntermediaryEvent(Ce.Failure,r.id)()}}),n.on(Ce.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),n.emit("disconnect")})),n}transfer(e){let t=D(O.NFTTransfer,[e]);return this.request(t)}};function Dr(e){return e.compat&&e.compat[k.sdkName]!=null?typeof e.compat[k.sdkName]=="string"?za(eo(k.version),e.compat[k.sdkName]):!!e.compat[k.sdkName]:!0}function Fo(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 Wo(e){let t=e?.extensions??[],r={},n=[];if(Array.isArray(t)?t.forEach(i=>{Dr(i)?(i.init(this),i.name&&(this[i.name]=i),qe(i.config)||(r[i.name]=i.config)):n.push(i)}):Object.keys(t).forEach(i=>{if(Dr(t[i])){t[i].init(this);let s=t[i];this[i]=s,qe(s.config)||(r[t[i].name]=s.config)}else n.push(t[i])}),n.length)throw Yr(n);return r}var qt=class ot{constructor(t,r){if(this.apiKey=t,!t)throw qr();k.platform==="react-native"&&r?.endpoint&&Jr().log();let{defaultEndpoint:n,version:i}=k;this.testMode=!!r?.testMode,this.useStorageCache=!!r?.useStorageCache,this.endpoint=De(r?.endpoint??n).origin,this.auth=new Oo(this),this.user=new Lo(this),this.wallet=new Do(this),this.nft=new Uo(this),this.thirdPartyWallets=new $o(this),this.rpcProvider=new xo(this);let s=Wo.call(this,r);this.parameters=Dt({API_KEY:this.apiKey,DOMAIN_ORIGIN:typeof window<"u"&&window?.location?window?.location.origin:"",ETH_NETWORK:r?.network,host:De(this.endpoint).host,sdk:co[k.sdkName],version:i,ext:qe(s)?void 0:s,locale:r?.locale||"en_US",authConfig:r?.authConfig?{...r.authConfig}:void 0,...k.bundleId?{bundleId:k.bundleId}:{},meta:r?.meta}),this.networkHash=Fo(this.apiKey,r?.network,qe(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(!ot.__overlays__.has(this.parameters)){let t=new k.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),t.onThirdPartyWalletRequest(r=>this.thirdPartyWallets.handleIframeThirdPartyWalletRequest(r)),ot.__overlays__.set(this.parameters,t)}return ot.__overlays__.get(this.parameters)}async preload(){await this.overlay.waitForReady()}};function ko(e,t){return t&&Array.isArray(e)?e.find(r=>r.id===t):e}function Bo(e,t){let r=t.data.response?.id,n=ko(e,r);if(r&&n){let i=new cn(n).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:r,response:i}}return{}}function Go(e,t){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{e(...n)},t)}}var Vo=1e3,yn=60*Vo,$r=5*yn,jo=60*yn,Ht=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=Go(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},jo);thirdPartyWalletRequestHandler=()=>{};async post(e,t){return je(async(r,n)=>{if(!this.isConnectedToInternet){let p=Le();n(p)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let i=[],s=Array.isArray(t)?t.map(p=>p.id):[],f=await this.createMagicRequest(`${e}-${this.parameters}`,t,this.networkHash);await this._post(f);let h=p=>v=>{let{id:b,response:g}=Bo(t,v);if(this.persistMagicEventRefreshToken(v),g?.payload.error?.message==="User denied account access.")mn();else if(v.data.deviceShare){let{deviceShare:A}=v.data;Co(A,this.networkHash)}b&&g&&Array.isArray(t)&&s.includes(b)?(i.push(g),i.length===t.length&&(p(),r(i))):b&&g&&!Array.isArray(t)&&b===t.id&&(p(),r(g))},E=this.on(re.MAGIC_HANDLE_RESPONSE,h(()=>E()))})}async postThirdPartyWalletResponse(e){return je(async(t,r)=>{if(!this.isConnectedToInternet){let i=Le();r(i)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let n={msgType:`${Ae.MAGIC_THIRD_PARTY_WALLET_RESPONSE}-${this.parameters}`,response:e};await this._post(n),t()})}async postThirdPartyWalletUpdate(e){return je(async(t,r)=>{if(!this.isConnectedToInternet){let s=Le();r(s)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let n=JSON.parse(JSON.stringify(e,(s,f)=>typeof f=="function"?void 0:f)),i={msgType:`${Ae.MAGIC_THIRD_PARTY_WALLET_UPDATE}-${this.parameters}`,details:n};await this._post(i),t()})}on(e,t){let r=t.bind(window),n=i=>{i.data.msgType===`${e}-${this.parameters}`&&r(i)};return this.messageHandlers.add(n),()=>this.messageHandlers.delete(n)}waitForReady(){return new Promise(e=>{let t=this.on(re.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}onThirdPartyWalletRequest(e){this.thirdPartyWalletRequestHandler=e}listen(){this.on(re.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(re.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(re.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new xe(ge.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=async()=>{let r={msgType:`${Ae.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)}async persistMagicEventRefreshToken(e){e.data.rt&&await _e("rt",e.data.rt)}async createMagicRequest(e,t,r){let n={msgType:e,payload:t},i=await this.getRT(),s=await this.getJWT(),f=await this.getDecryptedDeviceShare(r);return s&&(n.jwt=s),s&&i&&(n.rt=i),f&&(n.deviceShare=f),n}async getJWT(){if(k.platform==="web")try{return await ae("jwt")||await nn()}catch(e){return console.error("webcrypto error",e),null}else return null}async getRT(){return await ae("rt")}async getDecryptedDeviceShare(e){return await Po(e)}},xr=["request","overlay","sdk"];function qo(e){let t=Object.getPrototypeOf(e),r=[t];for(;t&&t!==Re.prototype;)t=Object.getPrototypeOf(t),r.push(t);return r}var Ho=class extends Re{compat;__sdk_access_field_descriptors__=new Map;__is_initialized__=!1;utils={createPromiEvent:me,isPromiEvent:fn,encodeJSON:Dt,decodeJSON:Fr,createJsonRpcRequestPayload:D,standardizeJsonRpcRequestPayload:st,storage:Wt};constructor(){super(void 0);let e=[this,...qo(this)];xr.forEach(t=>{let r=e.map(f=>Object.getOwnPropertyDescriptor(f,t)),n=r.findIndex(f=>!!f),i=n>0,s=r[n];s&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:s,isPrototypeField:i}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw Kr(t)}}))})}init(e){this.__is_initialized__||(xr.forEach(t=>{if(this.__sdk_access_field_descriptors__.has(t)){let{descriptor:r,isPrototypeField:n}=this.__sdk_access_field_descriptors__.get(t);n?delete this[t]:Object.defineProperty(this,t,r)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:r,useInstead:n}=e,i=n?` Use \`${n}\` instead.`:"",s=`\`${t}\` will be removed from this Extension in version \`${r}\`.${i}`;return new Ct(this,"DEPRECATION_NOTICE",s)}createWarning(e,t){return new Ct(this,e,t)}createError(e,t,r){return new Vr(this,e,t,r)}},gn=class extends Ho{},Ko=class{static Internal=gn},Yo=class extends gn{constructor(e){super(),this.config=e,this.chain=e.chainType}chain;getPublicAddress(){return this.request(this.utils.createJsonRpcRequestPayload(O.GetMultichainPublicAddress,[{chain:this.chain}]))}revealPrivateKey(){return this.request(this.utils.createJsonRpcRequestPayload(O.RevealPK,[{chain:this.chain}]))}};var ht=Di(_n());var er={};bt(er,{_driver:()=>Zt,_initStorage:()=>Zo,_support:()=>ls,clear:()=>es,dropInstance:()=>ts,getItem:()=>rs,iterate:()=>ns,key:()=>is,keys:()=>as,length:()=>os,removeItem:()=>ss,setItem:()=>cs});function In(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Xo(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(s){if(s.name!=="TypeError")throw s;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,n=new r,i=0;i<e.length;i+=1)n.append(e[i]);return n.getBlob(t.type)}}var wn=/^~~local_forage_type~([^~]+)~/,Xt=9,Rn=Xt+4,bn=Object.prototype.toString;function An(e){var t=e.length*.75,r=e.length;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);for(var n=new ArrayBuffer(t),i=new Uint8Array(n),s=0,f=0;s<r;s+=4){var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[s]),E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[s+1]),p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[s+2]),v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[s+3]);i[f++]=h<<2|E>>4,i[f++]=(E&15)<<4|p>>2,i[f++]=(p&3)<<6|v&63}return n}function zt(e){for(var t=new Uint8Array(e),r="",n=0;n<t.length;n+=3)r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t[n]>>2],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(t[n]&3)<<4|t[n+1]>>4],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(t[n+1]&15)<<2|t[n+2]>>6],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t[n+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 zo(e,t){var r="";if(e&&(r=bn.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&bn.call(e.buffer)==="[object ArrayBuffer]")){var n=void 0,i="__lfsc__:";e instanceof ArrayBuffer?(n=e,i+="arbf"):(n=e.buffer,r==="[object Int8Array]"?i+="si08":r==="[object Uint8Array]"?i+="ui08":r==="[object Uint8ClampedArray]"?i+="uic8":r==="[object Int16Array]"?i+="si16":r==="[object Uint16Array]"?i+="ur16":r==="[object Int32Array]"?i+="si32":r==="[object Uint32Array]"?i+="ui32":r==="[object Float32Array]"?i+="fl32":r==="[object Float64Array]"?i+="fl64":t(new Error("Failed to get type for BinaryArray"))),t(i+zt(n))}else if(r==="[object Blob]"){var s=new FileReader;s.onload=function(){var f="~~local_forage_type~"+e.type+"~"+zt(this.result);t("__lfsc__:blob"+f)},s.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 Jo(e){if(e.substring(0,Xt)!=="__lfsc__:")return JSON.parse(e);var t=e.substring(Rn),r=e.substring(Xt,Rn),n;if(r==="blob"&&wn.test(t)){var i=t.match(wn);n=i[1],t=t.substring(i[0].length)}var s=An(t);switch(r){case"arbf":return s;case"blob":return Xo([s],{type:n});case"si08":return new Int8Array(s);case"ui08":return new Uint8Array(s);case"uic8":return new Uint8ClampedArray(s);case"si16":return new Int16Array(s);case"ur16":return new Uint16Array(s);case"si32":return new Int32Array(s);case"ui32":return new Uint32Array(s);case"fl32":return new Float32Array(s);case"fl64":return new Float64Array(s);default:throw new Error("Unkown type: "+r)}}function Jt(e){var t,r;if(e===null||typeof e!="object"||"isActiveClone"in e)return e;var n=e instanceof Date?new Date(e):e.constructor();try{for(var i=In(Object.keys(e)),s=i.next();!s.done;s=i.next()){var f=s.value;Object.prototype.hasOwnProperty.call(e,f)&&(e.isActiveClone=null,n[f]=Jt(e[f]),delete e.isActiveClone)}}catch(h){t={error:h}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return n}function Qt(e,t){return(e.name||t.name)+"/"+(e.storeName||t.storeName)+"/"}function le(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function Qo(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Sn(e,t){var r=this;if(t=Qo.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var i;return e.name?i=new Promise(function(s){e.storeName?s(Qt(e,r._defaultConfig)):s(e.name+"/")}):i=Promise.reject("Invalid arguments"),{promise:i,callback:t}}function ut(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}var On={bufferToString:zt,deserialize:Jo,serialize:zo,stringToBuffer:An};var Zt="localforage-driver-memory",dt={},Tn=function(){function e(t){this.kp=t,this.data={}}return e.resolve=function(t){return dt[t]||(dt[t]=new e(t)),dt[t]},e.prototype.clear=function(){this.data={}},e.prototype.drop=function(){this.clear(),delete dt[this.kp]},e.prototype.get=function(t){return this.data[t]},e.prototype.key=function(t){return this.keys()[t]},e.prototype.keys=function(){return Object.keys(this.data)},e.prototype.rm=function(t){delete this.data[t]},e.prototype.set=function(t,r){this.data[t]=r},e}();function Zo(e){var t=e?Jt(e):{},r=Qt(t,this._defaultConfig),n=Tn.resolve(r);return this._dbInfo=t,this._dbInfo.serializer=On,this._dbInfo.keyPrefix=r,this._dbInfo.mStore=n,Promise.resolve()}function es(e){var t=this,r=this.ready().then(function(){t._dbInfo.mStore.clear()});return le(r,e),r}function ts(e,t){var r=Sn.apply(this,arguments),n=r.promise,i=r.callback,s=n.then(function(f){Tn.resolve(f).drop()});return le(s,i),n}function rs(e,t){var r=this;e=ut(e);var n=this.ready().then(function(){var i=r._dbInfo.mStore.get(e);return i==null?null:r._dbInfo.serializer.deserialize(i)});return le(n,t),n}function ns(e,t){var r=this,n=this.ready().then(function(){for(var i=r._dbInfo.mStore,s=i.keys(),f=0;f<s.length;f++){var h=i.get(s[f]);if(h&&(h=r._dbInfo.serializer.deserialize(h)),h=e(h,s[f],f+1),h!==void 0)return h}});return le(n,t),n}function is(e,t){var r=this,n=this.ready().then(function(){var i;try{i=r._dbInfo.mStore.key(e),i===void 0&&(i=null)}catch{i=null}return i});return le(n,t),n}function as(e){var t=this,r=this.ready().then(function(){return t._dbInfo.mStore.keys()});return le(r,e),r}function os(e){var t=this.keys().then(function(r){return r.length});return le(t,e),t}function ss(e,t){var r=this;e=ut(e);var n=this.ready().then(function(){r._dbInfo.mStore.rm(e)});return le(n,t),n}function cs(e,t,r){var n=this;e=ut(e);var i=this.ready().then(function(){t===void 0&&(t=null);var s=t;return new Promise(function(f,h){n._dbInfo.serializer.serialize(t,function(E,p){if(p)h(p);else try{n._dbInfo.mStore.set(e,E),f(s)}catch(v){h(v)}})})});return le(i,r),i}var ls=!0;var us={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function ds(e){for(let[t,r]of Object.entries(us))e.style[t]=r}function fs(e){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(r=>r.src.includes(e))}var ft=class extends Ht{activeElement=null;iframe;relayerSrc=De(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(t=>{let r=()=>{if(fs(encodeURIComponent(this.parameters)))Ut().log();else{let n=document.createElement("iframe");n.classList.add("magic-iframe"),n.dataset.magicIframeLabel=De(this.endpoint).host,n.title="Secure Modal",n.src=this.relayerSrc,n.allow="clipboard-read; clipboard-write",ds(n),document.body.appendChild(n),t(n)}};["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){if(t.data.msgType.includes(re.MAGIC_PONG))this.lastPongTime=Date.now();else if(t.data.msgType.includes(re.MAGIC_THIRD_PARTY_WALLET_REQUEST)){this.thirdPartyWalletRequestHandler(t.data);return}if(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 Le()}async checkRelayerExistsInDOM(){let t=await this.iframe;return!t||!t.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(n=>n.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 hs=Object.assign($t(qt,{platform:"web",sdkName:"magic-sdk",version:"33.7.0",defaultEndpoint:"https://auth.magic.link/",ViewController:ft,configureStorage:async()=>{let e=ht.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await e.defineDriver(er),await e.setDriver([ht.default.INDEXEDDB,ht.default.LOCALSTORAGE,Zt]),e}}),{...Kt}),ms=hs;return $i(ps);})();
5
+ Received: \`${e.received}\``)}function Ut(){return new xe(ge.DuplicateIframe,"Duplicate iframes found.")}function zr(){return new xe(ge.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 xe(ge.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 \`${k.defaultEndpoint}\`. Changing this default behavior will lead to unexpected results and potentially security-threatening bugs.`)}function Qr(e){let{method:t,removalVersions:r,useInstead:n}=e,i=r[k.sdkName],s=n?` Use \`${n}\` instead.`:"",f=`\`${t}\` will be removed from \`${k.sdkName}\` in version \`${i}\`.${s}`;return new xe(ge.DeprecationNotice,f)}function*lo(){let e=0;for(;;)e<Number.MAX_SAFE_INTEGER?yield++e:e=0}var uo=lo();function fo(){return Math.floor(Math.random()*1e5)+1}function Ft(){return k.sdkName==="@magic-sdk/react-native-bare"||k.sdkName==="@magic-sdk/react-native-expo"?fo():uo.next().value}var Wt={};ha(Wt,{clear:()=>ho,getItem:()=>ae,iterate:()=>Zr,key:()=>po,keys:()=>vo,length:()=>mo,removeItem:()=>Se,setItem:()=>_e});var nt;function we(e){return async(...t)=>(nt||(nt=await k.configureStorage()),await nt.ready(),nt[e](...t))}var ae=we("getItem"),_e=we("setItem"),Se=we("removeItem"),ho=we("clear"),mo=we("length"),po=we("key"),vo=we("keys"),Zr=we("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 lt="STORE_KEY_PRIVATE_KEY",He="STORE_KEY_PUBLIC_JWK",tn="ECDSA",yo="P-256",go={name:tn,namedCurve:yo};function Ye(){let e=typeof window<"u"&&!!window.crypto,t=e&&!!window.crypto.subtle;return e&&t}function rn(){Se(He),Se(lt)}async function nn(){let e=await Eo();if(!e){console.info("unable to creat kee publicy or webcrypto is unsupported");return}let{subtle:t}=window.crypto,r=await ae(lt);if(!r||!t){console.info("unable to find private key or webcrypto unsupported");return}let n={iat:Math.floor(new Date().getTime()/1e3),jti:en()},i={protected:Lr(JSON.stringify({typ:"dpop+jwt",alg:"ES256",jwk:e})),claims:Lr(JSON.stringify(n))},s=Io(`${i.protected}.${i.claims}`),f={name:tn,hash:{name:"SHA-256"}},h=Ro(new Uint8Array(await t.sign(f,r,s)));return`${i.protected}.${i.claims}.${h}`}async function Eo(){if(!Ye()){console.info("webcrypto is not supported");return}return await ae(He)||await _o(),ae(He)}async function _o(){let{subtle:e}=window.crypto,t=await e.generateKey(go,!1,["sign"]),r=await e.exportKey("jwk",t.publicKey);await _e(lt,t.privateKey),await _e(He,r)}function Lr(e){return an(wo(e))}function Io(e){return new TextEncoder().encode(e)}function an(e){return btoa(e).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+/g,"")}function wo(e){return encodeURIComponent(e).replace(/%([0-9A-F]{2})/g,(t,r)=>String.fromCharCode(parseInt(r,16)))}function Ro(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 bo(e){return!!e[on]}function st(e){return bo(e)||(e.jsonrpc=e.jsonrpc??"2.0",e.id=Ft(),e.method=e.method??"noop",e.params=e.params??[],sn(e)),e}function D(e,t=[]){return sn({params:t,method:e,jsonrpc:"2.0",id:Ft()})}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):Wr(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===be.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}}},Ao=pa(va()),un=class extends Ao.default{};function kt(){let e=new un;return{emitter:e,createChainingEmitterMethod:(t,r)=>(...n)=>(e[t].apply(e,n),r),createBoundEmitterMethod:t=>(...r)=>e[t].apply(e,r)}}var dn=Symbol("isPromiEvent");function fn(e){return!!e[dn]}function me(e){let t=je(e),{createBoundEmitterMethod:r,createChainingEmitterMethod:n}=kt(),i=Symbol("Promise.then"),s=Symbol("Promise.catch"),f=Symbol("Promise.finally"),h=(v,b)=>(...g)=>{let A=b[v].apply(b,g);return E(A)},E=v=>Object.assign(v,{[dn]:!0,[i]:v[i]||v.then,[s]:v[s]||v.catch,[f]:v[f]||v.finally,then:h(i,v),catch:h(s,v),finally:h(f,v),on:n("on",v),once:n("once",v),addListener:n("addListener",v),off:n("off",v),removeListener:n("removeListener",v),removeAllListeners:n("removeAllListeners",v),emit:r("emit"),eventNames:r("eventNames"),listeners:r("listeners"),listenerCount:r("listenerCount")}),p=E(t.then(v=>(p.emit("done",v),p.emit("settled"),v),v=>{throw p.emit("error",v),p.emit("settled"),v}));return p.on(St.ClosedByUser,()=>{p.emit(At.ClosedByUser)}),p}function je(e){return new Promise((t,r)=>{let n=e(t,r);Promise.resolve(n).catch(r)})}var Re=class{constructor(e){this.sdk=e}get overlay(){return this.sdk.overlay}request(e){return this.sdk.thirdPartyWallets.isConnected&&!Rr.includes(e.method)?this.requestThirdPartyWallets(e):this.requestOverlay(e)}requestThirdPartyWallets(e){return me((t,r)=>{this.sdk.thirdPartyWallets.requestOverride(e).then(t).catch(r)})}requestOverlay(e){let t=this.overlay.post(Ae.MAGIC_HANDLE_REQUEST,st(e)),r=me((i,s)=>{t.then(f=>{if(n(),f.hasError)s(new xt(f.payload.error));else if(f.hasResult)i(f.payload.result);else throw Hr()}).catch(f=>{n(),s(f)})}),n=this.overlay.on(re.MAGIC_HANDLE_EVENT,i=>{let{response:s}=i.data;if(s.id===e.id&&s.result?.event){let{event:f,params:h=[]}=s.result;r.emit(f,...h)}});return r}createIntermediaryEvent(e,t){return r=>{let n=D(O.IntermediaryEvent,[{payloadId:t,eventType:e,args:r}]);this.request(n)}}};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"},Oo=class extends Re{loginWithMagicLink(e){let t=k.sdkName==="@magic-sdk/react-native"||k.sdkName==="@magic-sdk/react-native-bare"||k.sdkName==="@magic-sdk/react-native-expo";if(t&&hn(k.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:n=!0,redirectURI:i,overrides:s,lifespan:f}=e,h=D(this.sdk.testMode?O.LoginWithMagicLinkTestMode:O.LoginWithMagicLink,[{email:r,showUI:n,redirectURI:i,overrides:s,lifespan:f}]);return this.request(h)}loginWithSMS(e){let{phoneNumber:t,showUI:r=!0,lifespan:n}=e,i=D(this.sdk.testMode?O.LoginWithSmsTestMode:O.LoginWithSms,[{phoneNumber:t,showUI:r,lifespan:n}]),s=this.request(i);return!r&&s&&(s.on(ie.VerifySmsOtp,f=>{this.createIntermediaryEvent(ie.VerifySmsOtp,i.id)(f)}),s.on(ie.VerifyMFACode,f=>{this.createIntermediaryEvent(ie.VerifyMFACode,i.id)(f)}),s.on(ie.LostDevice,()=>{this.createIntermediaryEvent(ie.LostDevice,i.id)()}),s.on(ie.VerifyRecoveryCode,f=>{this.createIntermediaryEvent(ie.VerifyRecoveryCode,i.id)(f)}),s.on(ie.Cancel,()=>{this.createIntermediaryEvent(ie.Cancel,i.id)()})),s}loginWithEmailOTP(e){let{email:t,showUI:r,deviceCheckUI:n,overrides:i,lifespan:s}=e,f=D(this.sdk.testMode?O.LoginWithEmailOTPTestMode:O.LoginWithEmailOTP,[{email:t,showUI:r,deviceCheckUI:n,overrides:i,lifespan:s}]),h=this.request(f);return!n&&h&&h.on(Ze.Retry,()=>{this.createIntermediaryEvent(Ze.Retry,f.id)()}),!r&&h&&(h.on(ne.VerifyEmailOtp,E=>{this.createIntermediaryEvent(ne.VerifyEmailOtp,f.id)(E)}),h.on(ne.VerifyMFACode,E=>{this.createIntermediaryEvent(ne.VerifyMFACode,f.id)(E)}),h.on(ne.LostDevice,()=>{this.createIntermediaryEvent(ne.LostDevice,f.id)()}),h.on(ne.VerifyRecoveryCode,E=>{this.createIntermediaryEvent(ne.VerifyRecoveryCode,f.id)(E)}),h.on(ne.Cancel,()=>{this.createIntermediaryEvent(ne.Cancel,f.id)()})),h}loginWithCredential(e){let{credentialOrQueryString:t,lifespan:r}=e||{},n=t??"";if(!t&&k.platform==="web"){n=window.location.search;let s=window.location.origin+window.location.pathname;window.history.replaceState(null,"",s)}let i=D(this.sdk.testMode?O.LoginWithCredentialTestMode:O.LoginWithCredential,[n,r]);return this.request(i)}setAuthorizationToken(e){let t=D(O.SetAuthorizationToken,[{jwt:e}]);return this.request(t)}updateEmailWithUI(e){let{email:t,showUI:r=!0}=e,n=D(this.sdk.testMode?O.UpdateEmailTestMode:O.UpdateEmail,[{email:t,showUI:r}]),i=this.request(n);return r||(i.on(Q.Retry,()=>{this.createIntermediaryEvent(Q.Retry,n.id)()}),i.on(Q.Cancel,()=>{this.createIntermediaryEvent(Q.Cancel,n.id)()}),i.on(Q.VerifyEmailOtp,s=>{this.createIntermediaryEvent(Q.VerifyEmailOtp,n.id)(s)}),i.on(Q.VerifyMFACode,s=>{this.createIntermediaryEvent(Q.VerifyMFACode,n.id)(s)}),i.on(Y.RetryWithNewEmail,s=>{this.createIntermediaryEvent(Y.RetryWithNewEmail,n.id)(s)}),i.on(Y.Cancel,()=>{this.createIntermediaryEvent(Y.Cancel,n.id)()}),i.on(Y.VerifyEmailOtp,s=>{this.createIntermediaryEvent(Y.VerifyEmailOtp,n.id)(s)})),i}},Bt="ds",Gt="ek",Vt="iv",jt="AES-GCM",To=256;async function mn(){let e=[];await Zr((t,r,n)=>{r.startsWith(`${Bt}_`)&&e.push(r)});for(let t of e)await Se(t)}function pn(e){let t="",r=new Uint8Array(e),n=r.byteLength;for(let i=0;i<n;i++)t+=String.fromCharCode(r[i]);return window.btoa(t)}function vn(e){let t=window.atob(e),r=t.length,n=new Uint8Array(r);for(let i=0;i<r;i++)n[i]=t.charCodeAt(i);return n.buffer}async function No(){if(!Ye()){console.info("webcrypto is not supported");return}let{crypto:e}=window;return await ae(Vt)||e.getRandomValues(new Uint8Array(12))}async function Mo(){if(!Ye()){console.info("webcrypto is not supported");return}let{subtle:e}=window.crypto;return await ae(Gt)||await e.generateKey({name:jt,length:To},!1,["encrypt","decrypt"])}async function Co(e,t){let r=await No(),n=await Mo();if(!r||!n||!e)return;let i=vn(e),{subtle:s}=window.crypto,f=await s.encrypt({name:jt,iv:r},n,i),h=pn(f);await _e(`${Bt}_${t}`,h),await _e(Gt,n),await _e(Vt,r)}async function Po(e){let t=await ae(`${Bt}_${e}`),r=await ae(Vt),n=await ae(Gt);if(!r||!t||!n||!Ye())return;let{subtle:i}=window.crypto,s=await i.decrypt({name:jt,iv:r},n,vn(t));return pn(s)}function De(e,t){return t?new URL(e,t):new URL(e)}var Lo=class extends Re{getIdToken(e){let t=D(this.sdk.testMode?O.GetIdTokenTestMode:O.GetIdToken,[e]);return this.request(t)}generateIdToken(e){let t=D(this.sdk.testMode?O.GenerateIdTokenTestMode:O.GenerateIdToken,[e]);return this.request(t)}getInfo(){let e=D(O.GetInfo,[]);return this.request(e)}isLoggedIn(){return me(async(e,t)=>{try{let r=!1;this.sdk.useStorageCache&&(r=await ae(this.localForageIsLoggedInKey)==="true",r&&e(!0));let n=D(this.sdk.testMode?O.IsLoggedInTestMode:O.IsLoggedIn),i=await this.request(n);this.sdk.useStorageCache&&(i?_e(this.localForageIsLoggedInKey,!0):Se(this.localForageIsLoggedInKey),r&&!i&&this.emitUserLoggedOut(!0)),e(i)}catch(r){t(r)}})}logout(){return Se(this.localForageIsLoggedInKey),Se("rt"),mn(),me(async(e,t)=>{try{let r=D(this.sdk.testMode?O.LogoutTestMode:O.Logout),n=await this.request(r);this.sdk.useStorageCache&&this.emitUserLoggedOut(n),e(n)}catch(r){t(r)}})}requestInfoWithUI(e){let t=D(O.RequestUserInfoWithUI,e?[e]:[]);return this.request(t)}showSettings(e){let{showUI:t=!0}=e||{},r=D(this.sdk.testMode?O.UserSettingsTestMode:O.UserSettings,[e]),n=this.request(r);return!t&&n&&(n.on(oe.SendNewPhoneNumber,i=>{this.createIntermediaryEvent(oe.SendNewPhoneNumber,r.id)(i)}),n.on(oe.SendOtpCode,i=>{this.createIntermediaryEvent(oe.SendOtpCode,r.id)(i)}),n.on(oe.StartEditPhoneNumber,()=>{this.createIntermediaryEvent(oe.StartEditPhoneNumber,r.id)()}),n.on(oe.Cancel,()=>{this.createIntermediaryEvent(oe.Cancel,r.id)()}),n.on(Q.VerifyEmailOtp,i=>{this.createIntermediaryEvent(Q.VerifyEmailOtp,r.id)(i)})),n}recoverAccount(e){let{email:t,showUI:r}=e,n=D(this.sdk.testMode?O.RecoverAccountTestMode:O.RecoverAccount,[{email:t,showUI:r}]),i=this.request(n);return!r&&i&&(i.on(se.Cancel,()=>{this.createIntermediaryEvent(se.Cancel,n.id)()}),i.on(se.ResendSms,()=>{this.createIntermediaryEvent(se.ResendSms,n.id)()}),i.on(se.VerifyOtp,s=>{this.createIntermediaryEvent(se.VerifyOtp,n.id)(s)}),i.on(se.UpdateEmail,s=>{this.createIntermediaryEvent(se.UpdateEmail,n.id)(s)}),i.on(Y.Cancel,()=>{this.createIntermediaryEvent(Y.Cancel,n.id)()}),i.on(Y.RetryWithNewEmail,s=>{this.createIntermediaryEvent(Y.RetryWithNewEmail,n.id)(s)}),i.on(Y.VerifyEmailOtp,s=>{this.createIntermediaryEvent(Y.VerifyEmailOtp,n.id)(s)})),i}revealEVMPrivateKey(){let e=D(O.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=D(O.EnableMFA,[{showUI:t}]),n=this.request(r);return!t&&n&&(n.on(Me.VerifyMFACode,i=>{this.createIntermediaryEvent(Me.VerifyMFACode,r.id)(i)}),n.on(Me.Cancel,()=>{this.createIntermediaryEvent(Me.Cancel,r.id)()})),n}disableMFA(e){let{showUI:t=!0}=e,r=D(O.DisableMFA,[{showUI:t}]),n=this.request(r);return!t&&n&&(n.on(Ee.VerifyMFACode,i=>{this.createIntermediaryEvent(Ee.VerifyMFACode,r.id)(i)}),n.on(Ee.LostDevice,i=>{this.createIntermediaryEvent(Ee.LostDevice,r.id)(i)}),n.on(Ee.Cancel,()=>{this.createIntermediaryEvent(Ee.Cancel,r.id)()})),n}emitUserLoggedOut(e){this.userLoggedOutCallbacks.forEach(t=>{t(e)})}localForageIsLoggedInKey="magic_auth_is_logged_in";userLoggedOutCallbacks=[]},Do=class extends Re{connectWithUI(e){let t=me(async(r,n)=>{try{let i=D(O.Login,[{enabledWallets:this.sdk.thirdPartyWallets.enabledWallets,...e}]),s=this.request(i);this.sdk.thirdPartyWallets.eventListeners.forEach(({event:h,callback:E})=>{s.on(h,()=>E(i.id))}),s.on("id-token-created",h=>{t.emit("id-token-created",h)});let f=await s;f.error&&n(f),r(f)}catch(i){n(i)}});return t}showUI(e){return this.request(D(O.ShowUI,[e]))}showAddress(){return this.request(D(O.ShowAddress))}showSendTokensUI(){return this.request(D(O.ShowSendTokensUI))}showOnRamp(){return this.request(D(O.ShowOnRamp))}showNFTs(){return this.request(D(O.ShowNFTs))}showBalances(){return this.request(D(O.ShowBalances))}sign7702Authorization(e){return this.request(D(O.Sign7702Authorization,[e]))}send7702Transaction(e){return this.request(D(O.Send7702Transaction,[e]))}},$o=class extends Re{eventListeners=[];enabledWallets={};isConnected=!1;resetThirdPartyWalletState(){localStorage.removeItem(fe.PROVIDER),localStorage.removeItem(fe.ADDRESS),localStorage.removeItem(fe.CHAIN_ID),this.isConnected=!1}requestOverride(e){if(e.method===O.Login)return this.resetThirdPartyWalletState(),super.request(e);if(e.method===O.GetInfo)return this.getInfo(e);if(e.method===O.IsLoggedIn)return this.isLoggedIn(e);if(e.method===O.Logout)return this.logout(e);switch(localStorage.getItem(fe.PROVIDER)){case"magic-widget":return this.magicWidgetRequest(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}isLoggedIn(e){switch(localStorage.getItem(fe.PROVIDER)){case"magic-widget":return super.requestOverlay(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}getInfo(e){switch(localStorage.getItem(fe.PROVIDER)){case"magic-widget":return super.requestOverlay(e);default:return this.resetThirdPartyWalletState(),super.request(e)}}logout(e){let t=localStorage.getItem(fe.PROVIDER);switch(this.resetThirdPartyWalletState(),t){case"magic-widget":return this.magicWidgetLogout(e);default:return super.request(e)}}magicWidgetRequest(e){return["eth_","wallet_","net_","web3_"].some(t=>e.method?.startsWith(t))||["personal_sign"].includes(e.method)?me((t,r)=>{this.sdk.walletKit.walletRequest(e).then(t).catch(n=>r(new xt(n)))}):super.requestOverlay(e)}magicWidgetLogout(e){return me(async t=>{try{this.sdk.walletKit.clearConnectedState()}catch(r){console.error(r)}return super.requestOverlay(e)})}handleIframeThirdPartyWalletRequest(e){this.magicWidgetRequest(e.payload).then(t=>{this.overlay.postThirdPartyWalletResponse({id:e.payload.id,jsonrpc:"2.0",result:t})}).catch(t=>{this.overlay.postThirdPartyWalletResponse({id:e.payload.id,jsonrpc:"2.0",error:{code:t.code||-32603,message:t.message||"Internal error",data:t.data}})})}},{createBoundEmitterMethod:it,createChainingEmitterMethod:Pe}=kt(),xo=class extends Re{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)){let r=e.map(n=>st(n)).map(n=>this.request(n).then(i=>({jsonrpc:n.jsonrpc??"2.0",id:n.id??null,result:i,error:null})).catch(i=>({jsonrpc:n.jsonrpc??"2.0",id:n.id??null,error:i})));Promise.all(r).then(n=>{t(null,n)})}else this.request(st(e)).then(r=>{t(null,{jsonrpc:e.jsonrpc??"2.0",id:e.id??null,result:r,error:null})}).catch(r=>{t(r,{jsonrpc:e.jsonrpc??"2.0",id:e.id??null,error:r})})}send(e,t){if(typeof e=="string"){let n=D(e,Array.isArray(t)?t:[]);return this.request(n)}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=D(O.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=Pe("on",this);once=Pe("once",this);addListener=Pe("addListener",this);off=Pe("off",this);removeListener=Pe("removeListener",this);removeAllListeners=Pe("removeAllListeners",this);emit=it("emit");eventNames=it("eventNames");listeners=it("listeners");listenerCount=it("listenerCount")},Uo=class extends Re{purchase(e){let t=D(O.NFTPurchase,[e]);return this.request(t)}checkout(e){let t=this.sdk.thirdPartyWallets.isConnected,r=D(O.NFTCheckout,[{...e,walletProvider:t?"web3modal":"magic"}]),n=this.request(r);return t&&(n.on(Ce.Initiated,async i=>{try{let s=await this.request({method:"eth_sendTransaction",params:[i]});this.createIntermediaryEvent(Ce.Success,r.id)(s)}catch{this.createIntermediaryEvent(Ce.Failure,r.id)()}}),n.on(Ce.Disconnect,()=>{this.sdk.thirdPartyWallets.resetThirdPartyWalletState(),n.emit("disconnect")})),n}transfer(e){let t=D(O.NFTTransfer,[e]);return this.request(t)}};function Dr(e){return e.compat&&e.compat[k.sdkName]!=null?typeof e.compat[k.sdkName]=="string"?za(eo(k.version),e.compat[k.sdkName]):!!e.compat[k.sdkName]:!0}function Fo(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 Wo(e){let t=e?.extensions??[],r={},n=[];if(Array.isArray(t)?t.forEach(i=>{Dr(i)?(i.init(this),i.name&&(this[i.name]=i),qe(i.config)||(r[i.name]=i.config)):n.push(i)}):Object.keys(t).forEach(i=>{if(Dr(t[i])){t[i].init(this);let s=t[i];this[i]=s,qe(s.config)||(r[t[i].name]=s.config)}else n.push(t[i])}),n.length)throw Yr(n);return r}var qt=class ot{constructor(t,r){if(this.apiKey=t,!t)throw qr();k.platform==="react-native"&&r?.endpoint&&Jr().log();let{defaultEndpoint:n,version:i}=k;this.testMode=!!r?.testMode,this.useStorageCache=!!r?.useStorageCache,this.endpoint=De(r?.endpoint??n).origin,this.auth=new Oo(this),this.user=new Lo(this),this.wallet=new Do(this),this.nft=new Uo(this),this.thirdPartyWallets=new $o(this),this.rpcProvider=new xo(this);let s=Wo.call(this,r);this.parameters=Dt({API_KEY:this.apiKey,DOMAIN_ORIGIN:typeof window<"u"&&window?.location?window?.location.origin:"",ETH_NETWORK:r?.network,host:De(this.endpoint).host,sdk:co[k.sdkName],version:i,ext:qe(s)?void 0:s,locale:r?.locale||"en_US",authConfig:r?.authConfig?{...r.authConfig}:void 0,...k.bundleId?{bundleId:k.bundleId}:{},meta:r?.meta}),this.networkHash=Fo(this.apiKey,r?.network,qe(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(!ot.__overlays__.has(this.parameters)){let t=new k.ViewController(this.endpoint,this.parameters,this.networkHash);t.init(),t.onThirdPartyWalletRequest(r=>this.thirdPartyWallets.handleIframeThirdPartyWalletRequest(r)),ot.__overlays__.set(this.parameters,t)}return ot.__overlays__.get(this.parameters)}async preload(){await this.overlay.waitForReady()}};function ko(e,t){return t&&Array.isArray(e)?e.find(r=>r.id===t):e}function Bo(e,t){let r=t.data.response?.id,n=ko(e,r);if(r&&n){let i=new cn(n).applyResult(t.data.response.result).applyError(t.data.response.error);return{id:r,response:i}}return{}}function Go(e,t){let r=null;return function(...n){r&&clearTimeout(r),r=setTimeout(()=>{e(...n)},t)}}var Vo=1e3,yn=60*Vo,$r=5*yn,jo=60*yn,Ht=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=Go(()=>{this.endpoint==="https://auth.magic.link/"&&this.heartBeatCheck()},jo);thirdPartyWalletRequestHandler=()=>{};async post(e,t){return je(async(r,n)=>{if(!this.isConnectedToInternet){let p=Le();n(p)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let i=[],s=Array.isArray(t)?t.map(p=>p.id):[],f=await this.createMagicRequest(`${e}-${this.parameters}`,t,this.networkHash);await this._post(f);let h=p=>v=>{let{id:b,response:g}=Bo(t,v);if(this.persistMagicEventRefreshToken(v),g?.payload.error?.message==="User denied account access.")mn();else if(v.data.deviceShare){let{deviceShare:A}=v.data;Co(A,this.networkHash)}b&&g&&Array.isArray(t)&&s.includes(b)?(i.push(g),i.length===t.length&&(p(),r(i))):b&&g&&!Array.isArray(t)&&b===t.id&&(p(),r(g))},E=this.on(re.MAGIC_HANDLE_RESPONSE,h(()=>E()))})}async postThirdPartyWalletResponse(e){return je(async(t,r)=>{if(!this.isConnectedToInternet){let i=Le();r(i)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let n={msgType:`${Ae.MAGIC_THIRD_PARTY_WALLET_RESPONSE}-${this.parameters}`,response:e};await this._post(n),t()})}async postThirdPartyWalletUpdate(e){return je(async(t,r)=>{if(!this.isConnectedToInternet){let s=Le();r(s)}await this.checkRelayerExistsInDOM()||(this.isReadyForRequest=!1,await this.reloadRelayer()),this.isReadyForRequest||await this.waitForReady();let n=JSON.parse(JSON.stringify(e,(s,f)=>typeof f=="function"?void 0:f)),i={msgType:`${Ae.MAGIC_THIRD_PARTY_WALLET_UPDATE}-${this.parameters}`,details:n};await this._post(i),t()})}on(e,t){let r=t.bind(window),n=i=>{i.data.msgType===`${e}-${this.parameters}`&&r(i)};return this.messageHandlers.add(n),()=>this.messageHandlers.delete(n)}waitForReady(){return new Promise(e=>{let t=this.on(re.MAGIC_OVERLAY_READY,()=>{this.isReadyForRequest=!0,e(),t()})})}onThirdPartyWalletRequest(e){this.thirdPartyWalletRequestHandler=e}listen(){this.on(re.MAGIC_HIDE_OVERLAY,()=>{this.hideOverlay()}),this.on(re.MAGIC_SHOW_OVERLAY,()=>{this.showOverlay()}),this.on(re.MAGIC_SEND_PRODUCT_ANNOUNCEMENT,e=>{e.data.response.result.product_announcement&&new xe(ge.ProductAnnouncement,e.data.response.result.product_announcement).log()})}heartBeatCheck(){let e=!0,t=async()=>{let r={msgType:`${Ae.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)}async persistMagicEventRefreshToken(e){e.data.rt&&await _e("rt",e.data.rt)}async createMagicRequest(e,t,r){let n={msgType:e,payload:t},i=await this.getRT(),s=await this.getJWT(),f=await this.getDecryptedDeviceShare(r);return s&&(n.jwt=s),s&&i&&(n.rt=i),f&&(n.deviceShare=f),n}async getJWT(){if(k.platform==="web")try{return await ae("jwt")||await nn()}catch(e){return console.error("webcrypto error",e),null}else return null}async getRT(){return await ae("rt")}async getDecryptedDeviceShare(e){return await Po(e)}},xr=["request","overlay","sdk"];function qo(e){let t=Object.getPrototypeOf(e),r=[t];for(;t&&t!==Re.prototype;)t=Object.getPrototypeOf(t),r.push(t);return r}var Ho=class extends Re{compat;__sdk_access_field_descriptors__=new Map;__is_initialized__=!1;utils={createPromiEvent:me,isPromiEvent:fn,encodeJSON:Dt,decodeJSON:Fr,createJsonRpcRequestPayload:D,standardizeJsonRpcRequestPayload:st,storage:Wt};constructor(){super(void 0);let e=[this,...qo(this)];xr.forEach(t=>{let r=e.map(f=>Object.getOwnPropertyDescriptor(f,t)),n=r.findIndex(f=>!!f),i=n>0,s=r[n];s&&(this.__sdk_access_field_descriptors__.set(t,{descriptor:s,isPrototypeField:i}),Object.defineProperty(this,t,{configurable:!0,get:()=>{throw Kr(t)}}))})}init(e){this.__is_initialized__||(xr.forEach(t=>{if(this.__sdk_access_field_descriptors__.has(t)){let{descriptor:r,isPrototypeField:n}=this.__sdk_access_field_descriptors__.get(t);n?delete this[t]:Object.defineProperty(this,t,r)}}),this.sdk=e,this.__is_initialized__=!0)}createDeprecationWarning(e){let{method:t,removalVersion:r,useInstead:n}=e,i=n?` Use \`${n}\` instead.`:"",s=`\`${t}\` will be removed from this Extension in version \`${r}\`.${i}`;return new Ct(this,"DEPRECATION_NOTICE",s)}createWarning(e,t){return new Ct(this,e,t)}createError(e,t,r){return new Vr(this,e,t,r)}},gn=class extends Ho{},Ko=class{static Internal=gn},Yo=class extends gn{constructor(e){super(),this.config=e,this.chain=e.chainType}chain;getPublicAddress(){return this.request(this.utils.createJsonRpcRequestPayload(O.GetMultichainPublicAddress,[{chain:this.chain}]))}revealPrivateKey(){return this.request(this.utils.createJsonRpcRequestPayload(O.RevealPK,[{chain:this.chain}]))}};var ht=Di(_n());var er={};bt(er,{_driver:()=>Zt,_initStorage:()=>Zo,_support:()=>ls,clear:()=>es,dropInstance:()=>ts,getItem:()=>rs,iterate:()=>ns,key:()=>is,keys:()=>as,length:()=>os,removeItem:()=>ss,setItem:()=>cs});function In(e){var t=typeof Symbol=="function"&&Symbol.iterator,r=t&&e[t],n=0;if(r)return r.call(e);if(e&&typeof e.length=="number")return{next:function(){return e&&n>=e.length&&(e=void 0),{value:e&&e[n++],done:!e}}};throw new TypeError(t?"Object is not iterable.":"Symbol.iterator is not defined.")}function Xo(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(s){if(s.name!=="TypeError")throw s;for(var r=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,n=new r,i=0;i<e.length;i+=1)n.append(e[i]);return n.getBlob(t.type)}}var wn=/^~~local_forage_type~([^~]+)~/,Xt=9,Rn=Xt+4,bn=Object.prototype.toString;function An(e){var t=e.length*.75,r=e.length;e[e.length-1]==="="&&(t--,e[e.length-2]==="="&&t--);for(var n=new ArrayBuffer(t),i=new Uint8Array(n),s=0,f=0;s<r;s+=4){var h="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[s]),E="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[s+1]),p="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[s+2]),v="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(e[s+3]);i[f++]=h<<2|E>>4,i[f++]=(E&15)<<4|p>>2,i[f++]=(p&3)<<6|v&63}return n}function zt(e){for(var t=new Uint8Array(e),r="",n=0;n<t.length;n+=3)r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t[n]>>2],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(t[n]&3)<<4|t[n+1]>>4],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(t[n+1]&15)<<2|t[n+2]>>6],r+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[t[n+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 zo(e,t){var r="";if(e&&(r=bn.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&bn.call(e.buffer)==="[object ArrayBuffer]")){var n=void 0,i="__lfsc__:";e instanceof ArrayBuffer?(n=e,i+="arbf"):(n=e.buffer,r==="[object Int8Array]"?i+="si08":r==="[object Uint8Array]"?i+="ui08":r==="[object Uint8ClampedArray]"?i+="uic8":r==="[object Int16Array]"?i+="si16":r==="[object Uint16Array]"?i+="ur16":r==="[object Int32Array]"?i+="si32":r==="[object Uint32Array]"?i+="ui32":r==="[object Float32Array]"?i+="fl32":r==="[object Float64Array]"?i+="fl64":t(new Error("Failed to get type for BinaryArray"))),t(i+zt(n))}else if(r==="[object Blob]"){var s=new FileReader;s.onload=function(){var f="~~local_forage_type~"+e.type+"~"+zt(this.result);t("__lfsc__:blob"+f)},s.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 Jo(e){if(e.substring(0,Xt)!=="__lfsc__:")return JSON.parse(e);var t=e.substring(Rn),r=e.substring(Xt,Rn),n;if(r==="blob"&&wn.test(t)){var i=t.match(wn);n=i[1],t=t.substring(i[0].length)}var s=An(t);switch(r){case"arbf":return s;case"blob":return Xo([s],{type:n});case"si08":return new Int8Array(s);case"ui08":return new Uint8Array(s);case"uic8":return new Uint8ClampedArray(s);case"si16":return new Int16Array(s);case"ur16":return new Uint16Array(s);case"si32":return new Int32Array(s);case"ui32":return new Uint32Array(s);case"fl32":return new Float32Array(s);case"fl64":return new Float64Array(s);default:throw new Error("Unkown type: "+r)}}function Jt(e){var t,r;if(e===null||typeof e!="object"||"isActiveClone"in e)return e;var n=e instanceof Date?new Date(e):e.constructor();try{for(var i=In(Object.keys(e)),s=i.next();!s.done;s=i.next()){var f=s.value;Object.prototype.hasOwnProperty.call(e,f)&&(e.isActiveClone=null,n[f]=Jt(e[f]),delete e.isActiveClone)}}catch(h){t={error:h}}finally{try{s&&!s.done&&(r=i.return)&&r.call(i)}finally{if(t)throw t.error}}return n}function Qt(e,t){return(e.name||t.name)+"/"+(e.storeName||t.storeName)+"/"}function le(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function Qo(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Sn(e,t){var r=this;if(t=Qo.apply(this,arguments),e=typeof e!="function"&&e||{},!e.name){var n=this.config();e.name=e.name||n.name,e.storeName=e.storeName||n.storeName}var i;return e.name?i=new Promise(function(s){e.storeName?s(Qt(e,r._defaultConfig)):s(e.name+"/")}):i=Promise.reject("Invalid arguments"),{promise:i,callback:t}}function ut(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}var On={bufferToString:zt,deserialize:Jo,serialize:zo,stringToBuffer:An};var Zt="localforage-driver-memory",dt={},Tn=function(){function e(t){this.kp=t,this.data={}}return e.resolve=function(t){return dt[t]||(dt[t]=new e(t)),dt[t]},e.prototype.clear=function(){this.data={}},e.prototype.drop=function(){this.clear(),delete dt[this.kp]},e.prototype.get=function(t){return this.data[t]},e.prototype.key=function(t){return this.keys()[t]},e.prototype.keys=function(){return Object.keys(this.data)},e.prototype.rm=function(t){delete this.data[t]},e.prototype.set=function(t,r){this.data[t]=r},e}();function Zo(e){var t=e?Jt(e):{},r=Qt(t,this._defaultConfig),n=Tn.resolve(r);return this._dbInfo=t,this._dbInfo.serializer=On,this._dbInfo.keyPrefix=r,this._dbInfo.mStore=n,Promise.resolve()}function es(e){var t=this,r=this.ready().then(function(){t._dbInfo.mStore.clear()});return le(r,e),r}function ts(e,t){var r=Sn.apply(this,arguments),n=r.promise,i=r.callback,s=n.then(function(f){Tn.resolve(f).drop()});return le(s,i),n}function rs(e,t){var r=this;e=ut(e);var n=this.ready().then(function(){var i=r._dbInfo.mStore.get(e);return i==null?null:r._dbInfo.serializer.deserialize(i)});return le(n,t),n}function ns(e,t){var r=this,n=this.ready().then(function(){for(var i=r._dbInfo.mStore,s=i.keys(),f=0;f<s.length;f++){var h=i.get(s[f]);if(h&&(h=r._dbInfo.serializer.deserialize(h)),h=e(h,s[f],f+1),h!==void 0)return h}});return le(n,t),n}function is(e,t){var r=this,n=this.ready().then(function(){var i;try{i=r._dbInfo.mStore.key(e),i===void 0&&(i=null)}catch{i=null}return i});return le(n,t),n}function as(e){var t=this,r=this.ready().then(function(){return t._dbInfo.mStore.keys()});return le(r,e),r}function os(e){var t=this.keys().then(function(r){return r.length});return le(t,e),t}function ss(e,t){var r=this;e=ut(e);var n=this.ready().then(function(){r._dbInfo.mStore.rm(e)});return le(n,t),n}function cs(e,t,r){var n=this;e=ut(e);var i=this.ready().then(function(){t===void 0&&(t=null);var s=t;return new Promise(function(f,h){n._dbInfo.serializer.serialize(t,function(E,p){if(p)h(p);else try{n._dbInfo.mStore.set(e,E),f(s)}catch(v){h(v)}})})});return le(i,r),i}var ls=!0;var us={display:"none",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function ds(e){for(let[t,r]of Object.entries(us))e.style[t]=r}function fs(e){return!![].slice.call(document.querySelectorAll(".magic-iframe")).find(r=>r.src.includes(e))}var ft=class extends Ht{activeElement=null;iframe;relayerSrc=De(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href;init(){this.test="hello",this.iframe=new Promise(t=>{let r=()=>{if(fs(encodeURIComponent(this.parameters)))Ut().log();else{let n=document.createElement("iframe");n.classList.add("magic-iframe"),n.dataset.magicIframeLabel=De(this.endpoint).host,n.title="Secure Modal",n.src=this.relayerSrc,n.allow="clipboard-read; clipboard-write",ds(n),document.body.appendChild(n),t(n)}};["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){if(t.data.msgType.includes(re.MAGIC_PONG))this.lastPongTime=Date.now();else if(t.data.msgType.includes(re.MAGIC_THIRD_PARTY_WALLET_REQUEST)){this.thirdPartyWalletRequestHandler(t.data);return}if(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 Le()}async checkRelayerExistsInDOM(){let t=await this.iframe;return!t||!t.contentWindow?!1:!![].slice.call(document.querySelectorAll(".magic-iframe")).find(n=>n.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 hs=Object.assign($t(qt,{platform:"web",sdkName:"magic-sdk",version:"33.7.1",defaultEndpoint:"https://auth.magic.link/",ViewController:ft,configureStorage:async()=>{let e=ht.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return await e.defineDriver(er),await e.setDriver([ht.default.INDEXEDDB,ht.default.LOCALSTORAGE,Zt]),e}}),{...Kt}),ms=hs;return $i(ps);})();
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": "33.7.1-canary.b65c8d0.0",
3
+ "version": "33.7.1",
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": "33.7.1-canary.b65c8d0.0",
33
- "@magic-sdk/types": "27.7.1-canary.b65c8d0.0",
32
+ "@magic-sdk/provider": "^33.7.1",
33
+ "@magic-sdk/types": "^27.7.1",
34
34
  "localforage": "^1.7.4"
35
35
  },
36
- "gitHead": "b65c8d0c41288038946408d2bf402349a615a3b1"
36
+ "gitHead": "cccc2417b4074ccddd99e3a821956c8b90a7f0b9"
37
37
  }