magic-sdk 29.0.2-canary.863.13981623997.0 → 29.0.2-canary.863.13981938615.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/index.js.map +3 -3
- package/dist/es/index.js +1 -1
- package/dist/es/index.js.map +3 -3
- package/dist/es/index.mjs +1 -1
- package/dist/es/index.mjs.map +3 -3
- package/dist/magic.js +2 -2
- package/dist/types/iframe-controller.d.ts +3 -2
- package/package.json +5 -5
package/dist/es/index.mjs
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
var kt=Object.create;var $e=Object.defineProperty;var er=Object.getOwnPropertyDescriptor;var tr=Object.getOwnPropertyNames;var rr=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty;var ve=(b=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(b,{get:(T,_)=>(typeof require!="undefined"?require:T)[_]}):b)(function(b){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+b+'" is not supported')});var Je=(b,T)=>()=>(T||b((T={exports:{}}).exports,T),T.exports);var ir=(b,T,_,D)=>{if(T&&typeof T=="object"||typeof T=="function")for(let R of tr(T))!nr.call(b,R)&&R!==_&&$e(b,R,{get:()=>T[R],enumerable:!(D=er(T,R))||D.enumerable});return b};var Ze=(b,T,_)=>(_=b!=null?kt(rr(b)):{},ir(T||!b||!b.__esModule?$e(_,"default",{value:b,enumerable:!0}):_,b));var te=(b,T,_)=>new Promise((D,R)=>{var V=S=>{try{Y(_.next(S))}catch(M){R(M)}},P=S=>{try{Y(_.throw(S))}catch(M){R(M)}},Y=S=>S.done?D(S.value):Promise.resolve(S.value).then(V,P);Y((_=_.apply(b,T)).next())});var ke=Je((qe,De)=>{(function(b){if(typeof qe=="object"&&typeof De<"u")De.exports=b();else if(typeof define=="function"&&define.amd)define([],b);else{var T;typeof window<"u"?T=window:typeof global<"u"?T=global:typeof self<"u"?T=self:T=this,T.localforage=b()}})(function(){var b,T,_;return function D(R,V,P){function Y(K,J){if(!V[K]){if(!R[K]){var m=typeof ve=="function"&&ve;if(!J&&m)return m(K,!0);if(S)return S(K,!0);var I=new Error("Cannot find module '"+K+"'");throw I.code="MODULE_NOT_FOUND",I}var x=V[K]={exports:{}};R[K][0].call(x.exports,function(z){var Z=R[K][1][z];return Y(Z||z)},x,x.exports,D,R,V,P)}return V[K].exports}for(var S=typeof ve=="function"&&ve,M=0;M<P.length;M++)Y(P[M]);return Y}({1:[function(D,R,V){(function(P){"use strict";var Y=P.MutationObserver||P.WebKitMutationObserver,S;if(Y){var M=0,K=new Y(z),J=P.document.createTextNode("");K.observe(J,{characterData:!0}),S=function(){J.data=M=++M%2}}else if(!P.setImmediate&&typeof P.MessageChannel<"u"){var m=new P.MessageChannel;m.port1.onmessage=z,S=function(){m.port2.postMessage(0)}}else"document"in P&&"onreadystatechange"in P.document.createElement("script")?S=function(){var F=P.document.createElement("script");F.onreadystatechange=function(){z(),F.onreadystatechange=null,F.parentNode.removeChild(F),F=null},P.document.documentElement.appendChild(F)}:S=function(){setTimeout(z,0)};var I,x=[];function z(){I=!0;for(var F,k,U=x.length;U;){for(k=x,x=[],F=-1;++F<U;)k[F]();U=x.length}I=!1}R.exports=Z;function Z(F){x.push(F)===1&&!I&&S()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(D,R,V){"use strict";var P=D(1);function Y(){}var S={},M=["REJECTED"],K=["FULFILLED"],J=["PENDING"];R.exports=m;function m(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=J,this.queue=[],this.outcome=void 0,h!==Y&&Z(this,h)}m.prototype.catch=function(h){return this.then(null,h)},m.prototype.then=function(h,N){if(typeof h!="function"&&this.state===K||typeof N!="function"&&this.state===M)return this;var E=new this.constructor(Y);if(this.state!==J){var O=this.state===K?h:N;x(E,O,this.outcome)}else this.queue.push(new I(E,h,N));return E};function I(h,N,E){this.promise=h,typeof N=="function"&&(this.onFulfilled=N,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}I.prototype.callFulfilled=function(h){S.resolve(this.promise,h)},I.prototype.otherCallFulfilled=function(h){x(this.promise,this.onFulfilled,h)},I.prototype.callRejected=function(h){S.reject(this.promise,h)},I.prototype.otherCallRejected=function(h){x(this.promise,this.onRejected,h)};function x(h,N,E){P(function(){var O;try{O=N(E)}catch(G){return S.reject(h,G)}O===h?S.reject(h,new TypeError("Cannot resolve promise with itself")):S.resolve(h,O)})}S.resolve=function(h,N){var E=F(z,N);if(E.status==="error")return S.reject(h,E.value);var O=E.value;if(O)Z(h,O);else{h.state=K,h.outcome=N;for(var G=-1,X=h.queue.length;++G<X;)h.queue[G].callFulfilled(N)}return h},S.reject=function(h,N){h.state=M,h.outcome=N;for(var E=-1,O=h.queue.length;++E<O;)h.queue[E].callRejected(N);return h};function z(h){var N=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof N=="function")return function(){N.apply(h,arguments)}}function Z(h,N){var E=!1;function O($){E||(E=!0,S.reject(h,$))}function G($){E||(E=!0,S.resolve(h,$))}function X(){N(G,O)}var Q=F(X);Q.status==="error"&&O(Q.value)}function F(h,N){var E={};try{E.value=h(N),E.status="success"}catch(O){E.status="error",E.value=O}return E}m.resolve=k;function k(h){return h instanceof this?h:S.resolve(new this(Y),h)}m.reject=U;function U(h){var N=new this(Y);return S.reject(N,h)}m.all=fe;function fe(h){var N=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,O=!1;if(!E)return this.resolve([]);for(var G=new Array(E),X=0,Q=-1,$=new this(Y);++Q<E;)ee(h[Q],Q);return $;function ee(oe,a){N.resolve(oe).then(u,function(v){O||(O=!0,S.reject($,v))});function u(v){G[a]=v,++X===E&&!O&&(O=!0,S.resolve($,G))}}}m.race=re;function re(h){var N=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,O=!1;if(!E)return this.resolve([]);for(var G=-1,X=new this(Y);++G<E;)Q(h[G]);return X;function Q($){N.resolve($).then(function(ee){O||(O=!0,S.resolve(X,ee))},function(ee){O||(O=!0,S.reject(X,ee))})}}},{1:1}],3:[function(D,R,V){(function(P){"use strict";typeof P.Promise!="function"&&(P.Promise=D(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(D,R,V){"use strict";var P=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 Y(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function S(){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 M=S();function K(){try{if(!M||!M.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 J(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(n){if(n.name!=="TypeError")throw n;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,i=new t,o=0;o<e.length;o+=1)i.append(e[o]);return i.getBlob(r.type)}}typeof Promise>"u"&&D(3);var m=Promise;function I(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function x(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function z(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function Z(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var F="local-forage-detect-blob-support",k=void 0,U={},fe=Object.prototype.toString,re="readonly",h="readwrite";function N(e){for(var r=e.length,t=new ArrayBuffer(r),i=new Uint8Array(t),o=0;o<r;o++)i[o]=e.charCodeAt(o);return t}function E(e){return new m(function(r){var t=e.transaction(F,h),i=J([""]);t.objectStore(F).put(i,"key"),t.onabort=function(o){o.preventDefault(),o.stopPropagation(),r(!1)},t.oncomplete=function(){var o=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);r(n||!o||parseInt(o[1],10)>=43)}}).catch(function(){return!1})}function O(e){return typeof k=="boolean"?m.resolve(k):E(e).then(function(r){return k=r,k})}function G(e){var r=U[e.name],t={};t.promise=new m(function(i,o){t.resolve=i,t.reject=o}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function X(e){var r=U[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function Q(e,r){var t=U[e.name],i=t.deferredOperations.pop();if(i)return i.reject(r),i.promise}function $(e,r){return new m(function(t,i){if(U[e.name]=U[e.name]||j(),e.db)if(r)G(e),e.db.close();else return t(e.db);var o=[e.name];r&&o.push(e.version);var n=M.open.apply(M,o);r&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(F)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),i(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},t(f),X(e)}})}function ee(e){return $(e,!1)}function oe(e){return $(e,!0)}function a(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),i=e.version<e.db.version,o=e.version>e.db.version;if(i&&(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),o||t){if(t){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new m(function(r,t){var i=new FileReader;i.onerror=t,i.onloadend=function(o){var n=btoa(o.target.result||"");r({__local_forage_encoded_blob:!0,data:n,type:e.type})},i.readAsBinaryString(e)})}function v(e){var r=N(atob(e.data));return J([r],{type:e.type})}function g(e){return e&&e.__local_forage_encoded_blob}function p(e){var r=this,t=r._initReady().then(function(){var i=U[r._dbInfo.name];if(i&&i.dbReady)return i.dbReady});return x(t,e,e),t}function w(e){G(e);for(var r=U[e.name],t=r.forages,i=0;i<t.length;i++){var o=t[i];o._dbInfo.db&&(o._dbInfo.db.close(),o._dbInfo.db=null)}return e.db=null,ee(e).then(function(n){return e.db=n,a(e)?oe(e):n}).then(function(n){e.db=r.db=n;for(var f=0;f<t.length;f++)t[f]._dbInfo.db=n}).catch(function(n){throw Q(e,n),n})}function B(e,r,t,i){i===void 0&&(i=1);try{var o=e.db.transaction(e.storeName,r);t(null,o)}catch(n){if(i>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return m.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),oe(e)}).then(function(){return w(e).then(function(){B(e,r,t,i-1)})}).catch(t);t(n)}}function j(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function se(e){var r=this,t={db:null};if(e)for(var i in e)t[i]=e[i];var o=U[t.name];o||(o=j(),U[t.name]=o),o.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=p);var n=[];function f(){return m.resolve()}for(var s=0;s<o.forages.length;s++){var c=o.forages[s];c!==r&&n.push(c._initReady().catch(f))}var l=o.forages.slice(0);return m.all(n).then(function(){return t.db=o.db,ee(t)}).then(function(d){return t.db=d,a(t,r._defaultConfig.version)?oe(t):d}).then(function(d){t.db=o.db=d,r._dbInfo=t;for(var y=0;y<l.length;y++){var A=l[y];A!==r&&(A._dbInfo.db=t.db,A._dbInfo.version=t.version)}})}function ae(e,r){var t=this;e=z(e);var i=new m(function(o,n){t.ready().then(function(){B(t._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(t._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),g(d)&&(d=v(d)),o(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return I(i,r),i}function ce(e,r){var t=this,i=new m(function(o,n){t.ready().then(function(){B(t._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(t._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var y=l.result;if(y){var A=y.value;g(A)&&(A=v(A));var L=e(A,y.key,d++);L!==void 0?o(L):y.continue()}else o()},l.onerror=function(){n(l.error)}}catch(y){n(y)}})}).catch(n)});return I(i,r),i}function ot(e,r,t){var i=this;e=z(e);var o=new m(function(n,f){var s;i.ready().then(function(){return s=i._dbInfo,fe.call(r)==="[object Blob]"?O(s.db).then(function(c){return c?r:u(r)}):r}).then(function(c){B(i._dbInfo,h,function(l,d){if(l)return f(l);try{var y=d.objectStore(i._dbInfo.storeName);c===null&&(c=void 0);var A=y.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var L=A.error?A.error:A.transaction.error;f(L)}}catch(L){f(L)}})}).catch(f)});return I(o,t),o}function at(e,r){var t=this;e=z(e);var i=new m(function(o,n){t.ready().then(function(){B(t._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(t._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){o()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return I(i,r),i}function ft(e){var r=this,t=new m(function(i,o){r.ready().then(function(){B(r._dbInfo,h,function(n,f){if(n)return o(n);try{var s=f.objectStore(r._dbInfo.storeName),c=s.clear();f.oncomplete=function(){i()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;o(l)}}catch(l){o(l)}})}).catch(o)});return I(t,e),t}function st(e){var r=this,t=new m(function(i,o){r.ready().then(function(){B(r._dbInfo,re,function(n,f){if(n)return o(n);try{var s=f.objectStore(r._dbInfo.storeName),c=s.count();c.onsuccess=function(){i(c.result)},c.onerror=function(){o(c.error)}}catch(l){o(l)}})}).catch(o)});return I(t,e),t}function ut(e,r){var t=this,i=new m(function(o,n){if(e<0){o(null);return}t.ready().then(function(){B(t._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(t._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var y=d.result;if(!y){o(null);return}e===0||l?o(y.key):(l=!0,y.advance(e))},d.onerror=function(){n(d.error)}}catch(y){n(y)}})}).catch(n)});return I(i,r),i}function ct(e){var r=this,t=new m(function(i,o){r.ready().then(function(){B(r._dbInfo,re,function(n,f){if(n)return o(n);try{var s=f.objectStore(r._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){i(l);return}l.push(d.key),d.continue()},c.onerror=function(){o(c.error)}}catch(d){o(d)}})}).catch(o)});return I(t,e),t}function lt(e,r){r=Z.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 i=this,o;if(!e.name)o=m.reject("Invalid arguments");else{var n=e.name===t.name&&i._dbInfo.db,f=n?m.resolve(i._dbInfo.db):ee(e).then(function(s){var c=U[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?o=f.then(function(s){if(!!s.objectStoreNames.contains(e.storeName)){var c=s.version+1;G(e);var l=U[e.name],d=l.forages;s.close();for(var y=0;y<d.length;y++){var A=d[y];A._dbInfo.db=null,A._dbInfo.version=c}var L=new m(function(C,H){var W=M.open(e.name,c);W.onerror=function(q){var de=W.result;de.close(),H(q)},W.onupgradeneeded=function(){var q=W.result;q.deleteObjectStore(e.storeName)},W.onsuccess=function(){var q=W.result;q.close(),C(q)}});return L.then(function(C){l.db=C;for(var H=0;H<d.length;H++){var W=d[H];W._dbInfo.db=C,X(W._dbInfo)}}).catch(function(C){throw(Q(e,C)||m.resolve()).catch(function(){}),C})}}):o=f.then(function(s){G(e);var c=U[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var y=l[d];y._dbInfo.db=null}var A=new m(function(L,C){var H=M.deleteDatabase(e.name);H.onerror=function(){var W=H.result;W&&W.close(),C(H.error)},H.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},H.onsuccess=function(){var W=H.result;W&&W.close(),L(W)}});return A.then(function(L){c.db=L;for(var C=0;C<l.length;C++){var H=l[C];X(H._dbInfo)}}).catch(function(L){throw(Q(e,L)||m.resolve()).catch(function(){}),L})})}return I(o,r),o}var dt={_driver:"asyncStorage",_initStorage:se,_support:K(),iterate:ce,getItem:ae,setItem:ot,removeItem:at,clear:ft,length:st,key:ut,keys:ct,dropInstance:lt};function vt(){return typeof openDatabase=="function"}var ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ht="~~local_forage_type~",Be=/^~~local_forage_type~([^~]+)~/,he="__lfsc__:",be=he.length,_e="arbf",Ie="blob",xe="si08",Le="ui08",Oe="uic8",Ce="si16",Pe="si32",Me="ur16",Fe="ui32",Ue="fl32",Ye="fl64",ze=be+_e.length,We=Object.prototype.toString;function He(e){var r=e.length*.75,t=e.length,i,o=0,n,f,s,c;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var l=new ArrayBuffer(r),d=new Uint8Array(l);for(i=0;i<t;i+=4)n=ne.indexOf(e[i]),f=ne.indexOf(e[i+1]),s=ne.indexOf(e[i+2]),c=ne.indexOf(e[i+3]),d[o++]=n<<2|f>>4,d[o++]=(f&15)<<4|s>>2,d[o++]=(s&3)<<6|c&63;return l}function we(e){var r=new Uint8Array(e),t="",i;for(i=0;i<r.length;i+=3)t+=ne[r[i]>>2],t+=ne[(r[i]&3)<<4|r[i+1]>>4],t+=ne[(r[i+1]&15)<<2|r[i+2]>>6],t+=ne[r[i+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 mt(e,r){var t="";if(e&&(t=We.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&We.call(e.buffer)==="[object ArrayBuffer]")){var i,o=he;e instanceof ArrayBuffer?(i=e,o+=_e):(i=e.buffer,t==="[object Int8Array]"?o+=xe:t==="[object Uint8Array]"?o+=Le:t==="[object Uint8ClampedArray]"?o+=Oe:t==="[object Int16Array]"?o+=Ce:t==="[object Uint16Array]"?o+=Me:t==="[object Int32Array]"?o+=Pe:t==="[object Uint32Array]"?o+=Fe:t==="[object Float32Array]"?o+=Ue:t==="[object Float64Array]"?o+=Ye:r(new Error("Failed to get type for BinaryArray"))),r(o+we(i))}else if(t==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=ht+e.type+"~"+we(this.result);r(he+Ie+f)},n.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),r(null,f)}}function yt(e){if(e.substring(0,be)!==he)return JSON.parse(e);var r=e.substring(ze),t=e.substring(be,ze),i;if(t===Ie&&Be.test(r)){var o=r.match(Be);i=o[1],r=r.substring(o[0].length)}var n=He(r);switch(t){case _e:return n;case Ie:return J([n],{type:i});case xe:return new Int8Array(n);case Le:return new Uint8Array(n);case Oe:return new Uint8ClampedArray(n);case Ce:return new Int16Array(n);case Me:return new Uint16Array(n);case Pe:return new Int32Array(n);case Fe:return new Uint32Array(n);case Ue:return new Float32Array(n);case Ye:return new Float64Array(n);default:throw new Error("Unkown type: "+t)}}var Ee={serialize:mt,deserialize:yt,stringToBuffer:He,bufferToString:we};function Ke(e,r,t,i){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,i)}function gt(e){var r=this,t={db:null};if(e)for(var i in e)t[i]=typeof e[i]!="string"?e[i].toString():e[i];var o=new m(function(n,f){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(s){return f(s)}t.db.transaction(function(s){Ke(s,t,function(){r._dbInfo=t,n()},function(c,l){f(l)})},f)});return t.serializer=Ee,o}function ie(e,r,t,i,o,n){e.executeSql(t,i,o,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(c,l){l.rows.length?n(c,s):Ke(c,r,function(){c.executeSql(t,i,o,n)},n)},n):n(f,s)},n)}function pt(e,r){var t=this;e=z(e);var i=new m(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(s){ie(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),o(d)},function(c,l){n(l)})})}).catch(n)});return I(i,r),i}function bt(e,r){var t=this,i=new m(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(s){ie(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,y=d.length,A=0;A<y;A++){var L=d.item(A),C=L.value;if(C&&(C=f.serializer.deserialize(C)),C=e(C,L.key,A+1),C!==void 0){o(C);return}}o()},function(c,l){n(l)})})}).catch(n)});return I(i,r),i}function Ge(e,r,t,i){var o=this;e=z(e);var n=new m(function(f,s){o.ready().then(function(){r===void 0&&(r=null);var c=r,l=o._dbInfo;l.serializer.serialize(r,function(d,y){y?s(y):l.db.transaction(function(A){ie(A,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(L,C){s(C)})},function(A){if(A.code===A.QUOTA_ERR){if(i>0){f(Ge.apply(o,[e,c,t,i-1]));return}s(A)}})})}).catch(s)});return I(n,t),n}function _t(e,r,t){return Ge.apply(this,[e,r,t,1])}function It(e,r){var t=this;e=z(e);var i=new m(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(s){ie(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){o()},function(c,l){n(l)})})}).catch(n)});return I(i,r),i}function wt(e){var r=this,t=new m(function(i,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){ie(f,n,"DELETE FROM "+n.storeName,[],function(){i()},function(s,c){o(c)})})}).catch(o)});return I(t,e),t}function Et(e){var r=this,t=new m(function(i,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){ie(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;i(l)},function(s,c){o(c)})})}).catch(o)});return I(t,e),t}function St(e,r){var t=this,i=new m(function(o,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(s){ie(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;o(d)},function(c,l){n(l)})})}).catch(n)});return I(i,r),i}function At(e){var r=this,t=new m(function(i,o){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){ie(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);i(l)},function(s,c){o(c)})})}).catch(o)});return I(t,e),t}function Tt(e){return new m(function(r,t){e.transaction(function(i){i.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(o,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);r({db:e,storeNames:f})},function(o,n){t(n)})},function(i){t(i)})})}function Rt(e,r){r=Z.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 i=this,o;return e.name?o=new m(function(n){var f;e.name===t.name?f=i._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Tt(f))}).then(function(n){return new m(function(f,s){n.db.transaction(function(c){function l(L){return new m(function(C,H){c.executeSql("DROP TABLE IF EXISTS "+L,[],function(){C()},function(W,q){H(q)})})}for(var d=[],y=0,A=n.storeNames.length;y<A;y++)d.push(l(n.storeNames[y]));m.all(d).then(function(){f()}).catch(function(L){s(L)})},function(c){s(c)})})}):o=m.reject("Invalid arguments"),I(o,r),o}var Dt={_driver:"webSQLStorage",_initStorage:gt,_support:vt(),iterate:bt,getItem:pt,setItem:_t,removeItem:It,clear:wt,length:Et,key:St,keys:At,dropInstance:Rt};function Nt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ve(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function Bt(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function xt(){return!Bt()||localStorage.length>0}function Lt(e){var r=this,t={};if(e)for(var i in e)t[i]=e[i];return t.keyPrefix=Ve(e,r._defaultConfig),xt()?(r._dbInfo=t,t.serializer=Ee,m.resolve()):m.reject()}function Ot(e){var r=this,t=r.ready().then(function(){for(var i=r._dbInfo.keyPrefix,o=localStorage.length-1;o>=0;o--){var n=localStorage.key(o);n.indexOf(i)===0&&localStorage.removeItem(n)}});return I(t,e),t}function Ct(e,r){var t=this;e=z(e);var i=t.ready().then(function(){var o=t._dbInfo,n=localStorage.getItem(o.keyPrefix+e);return n&&(n=o.serializer.deserialize(n)),n});return I(i,r),i}function Pt(e,r){var t=this,i=t.ready().then(function(){for(var o=t._dbInfo,n=o.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var y=localStorage.getItem(d);if(y&&(y=o.serializer.deserialize(y)),y=e(y,d.substring(f),c++),y!==void 0)return y}}});return I(i,r),i}function Mt(e,r){var t=this,i=t.ready().then(function(){var o=t._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(o.keyPrefix.length)),n});return I(i,r),i}function Ft(e){var r=this,t=r.ready().then(function(){for(var i=r._dbInfo,o=localStorage.length,n=[],f=0;f<o;f++){var s=localStorage.key(f);s.indexOf(i.keyPrefix)===0&&n.push(s.substring(i.keyPrefix.length))}return n});return I(t,e),t}function Ut(e){var r=this,t=r.keys().then(function(i){return i.length});return I(t,e),t}function Yt(e,r){var t=this;e=z(e);var i=t.ready().then(function(){var o=t._dbInfo;localStorage.removeItem(o.keyPrefix+e)});return I(i,r),i}function zt(e,r,t){var i=this;e=z(e);var o=i.ready().then(function(){r===void 0&&(r=null);var n=r;return new m(function(f,s){var c=i._dbInfo;c.serializer.serialize(r,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(y){(y.name==="QuotaExceededError"||y.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(y),s(y)}})})});return I(o,t),o}function Wt(e,r){if(r=Z.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 i=this,o;return e.name?o=new m(function(n){e.storeName?n(Ve(e,i._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):o=m.reject("Invalid arguments"),I(o,r),o}var Ht={_driver:"localStorageWrapper",_initStorage:Lt,_support:Nt(),iterate:Pt,getItem:Ct,setItem:zt,removeItem:Yt,clear:Ot,length:Ut,key:Mt,keys:Ft,dropInstance:Wt},Kt=function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},Gt=function(r,t){for(var i=r.length,o=0;o<i;){if(Kt(r[o],t))return!0;o++}return!1},je=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},le={},Xe={},ue={INDEXEDDB:dt,WEBSQL:Dt,LOCALSTORAGE:Ht},Vt=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],me=["dropInstance"],Se=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(me),jt={description:"",driver:Vt.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Xt(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function Ae(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(je(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var Qt=function(){function e(r){Y(this,e);for(var t in ue)if(ue.hasOwnProperty(t)){var i=ue[t],o=i._driver;this[t]=o,le[o]||this.defineDriver(i)}this._defaultConfig=Ae({},jt),this._config=Ae({},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":P(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var i in t){if(i==="storeName"&&(t[i]=t[i].replace(/\W/g,"_")),i==="version"&&typeof t[i]!="number")return new Error("Database version must be a number.");this._config[i]=t[i]}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,i,o){var n=new m(function(f,s){try{var c=t._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){s(l);return}for(var d=Se.concat("_initStorage"),y=0,A=d.length;y<A;y++){var L=d[y],C=!Gt(me,L);if((C||t[L])&&typeof t[L]!="function"){s(l);return}}var H=function(){for(var de=function(Zt){return function(){var qt=new Error("Method "+Zt+" is not implemented by the current driver"),Qe=m.reject(qt);return I(Qe,arguments[arguments.length-1]),Qe}},Te=0,Jt=me.length;Te<Jt;Te++){var Re=me[Te];t[Re]||(t[Re]=de(Re))}};H();var W=function(de){le[c]&&console.info("Redefining LocalForage driver: "+c),le[c]=t,Xe[c]=de,f()};"_support"in t?t._support&&typeof t._support=="function"?t._support().then(W,s):W(!!t._support):W(!0)}catch(q){s(q)}});return x(n,i,o),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,i,o){var n=le[t]?m.resolve(le[t]):m.reject(new Error("Driver not found."));return x(n,i,o),n},e.prototype.getSerializer=function(t){var i=m.resolve(Ee);return x(i,t),i},e.prototype.ready=function(t){var i=this,o=i._driverSet.then(function(){return i._ready===null&&(i._ready=i._initDriver()),i._ready});return x(o,t,t),o},e.prototype.setDriver=function(t,i,o){var n=this;je(t)||(t=[t]);var f=this._getSupportedDrivers(t);function s(){n._config.driver=n.driver()}function c(y){return n._extend(y),s(),n._ready=n._initStorage(n._config),n._ready}function l(y){return function(){var A=0;function L(){for(;A<y.length;){var C=y[A];return A++,n._dbInfo=null,n._ready=null,n.getDriver(C).then(c).catch(L)}s();var H=new Error("No available storage method found.");return n._driverSet=m.reject(H),n._driverSet}return L()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=d.then(function(){var y=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(y).then(function(A){n._driver=A._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var y=new Error("No available storage method found.");return n._driverSet=m.reject(y),n._driverSet}),x(this._driverSet,i,o),this._driverSet},e.prototype.supports=function(t){return!!Xe[t]},e.prototype._extend=function(t){Ae(this,t)},e.prototype._getSupportedDrivers=function(t){for(var i=[],o=0,n=t.length;o<n;o++){var f=t[o];this.supports(f)&&i.push(f)}return i},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,i=Se.length;t<i;t++)Xt(this,Se[t])},e.prototype.createInstance=function(t){return new e(t)},e}(),$t=new Qt;R.exports=$t},{3:3}]},{},[4])(4)})});var tt=Je((ye,et)=>{(function(b,T){typeof ye=="object"&&typeof et<"u"?T(ye):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],T):T(b.LocalforageDriverMemory={})})(typeof self<"u"?self:ye,function(b){"use strict";var T="localforage-driver-memory";function _(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function D(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(w){if(w.name!=="TypeError")throw w;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,g=new v,p=0;p<a.length;p+=1)g.append(a[p]);return g.getBlob(u.type)}}var R=/^~~local_forage_type~([^~]+)~/,V=9,P=V+4,Y=Object.prototype.toString;function S(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var g=new ArrayBuffer(u),p=new Uint8Array(g),w=0,B=0;w<v;w+=4){var j="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w]),se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w+1]),ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w+2]),ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w+3]);p[B++]=j<<2|se>>4,p[B++]=(se&15)<<4|ae>>2,p[B++]=(ae&3)<<6|ce&63}return g}function M(a){for(var u=new Uint8Array(a),v="",g=0;g<u.length;g+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g]&3)<<4|u[g+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[g+1]&15)<<2|u[g+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[g+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function K(a,u){var v="";if(a&&(v=Y.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&Y.call(a.buffer)==="[object ArrayBuffer]")){var g=void 0,p="__lfsc__:";a instanceof ArrayBuffer?(g=a,p+="arbf"):(g=a.buffer,v==="[object Int8Array]"?p+="si08":v==="[object Uint8Array]"?p+="ui08":v==="[object Uint8ClampedArray]"?p+="uic8":v==="[object Int16Array]"?p+="si16":v==="[object Uint16Array]"?p+="ur16":v==="[object Int32Array]"?p+="si32":v==="[object Uint32Array]"?p+="ui32":v==="[object Float32Array]"?p+="fl32":v==="[object Float64Array]"?p+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(p+M(g))}else if(v==="[object Blob]"){var w=new FileReader;w.onload=function(){var B="~~local_forage_type~"+a.type+"~"+M(this.result);u("__lfsc__:blob"+B)},w.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(B){console.error("Couldn't convert value into a JSON string: ",a),u(null,B)}}function J(a){if(a.substring(0,V)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(P),v=a.substring(V,P),g;if(v==="blob"&&R.test(u)){var p=u.match(R);g=p[1],u=u.substring(p[0].length)}var w=S(u);switch(v){case"arbf":return w;case"blob":return D([w],{type:g});case"si08":return new Int8Array(w);case"ui08":return new Uint8Array(w);case"uic8":return new Uint8ClampedArray(w);case"si16":return new Int16Array(w);case"ur16":return new Uint16Array(w);case"si32":return new Int32Array(w);case"ui32":return new Uint32Array(w);case"fl32":return new Float32Array(w);case"fl64":return new Float64Array(w);default:throw new Error("Unkown type: "+v)}}function m(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var g=a instanceof Date?new Date(a):a.constructor();try{for(var p=_(Object.keys(a)),w=p.next();!w.done;w=p.next()){var B=w.value;Object.prototype.hasOwnProperty.call(a,B)&&(a.isActiveClone=null,g[B]=m(a[B]),delete a.isActiveClone)}}catch(j){u={error:j}}finally{try{w&&!w.done&&(v=p.return)&&v.call(p)}finally{if(u)throw u.error}}return g}function I(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function x(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function z(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Z(a,u){var v=this;if(u=z.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var g=this.config();a.name=a.name||g.name,a.storeName=a.storeName||g.storeName}var p;return a.name?p=new Promise(function(w){a.storeName?w(I(a,v._defaultConfig)):w(a.name+"/")}):p=Promise.reject("Invalid arguments"),{promise:p,callback:u}}function F(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var k={bufferToString:M,deserialize:J,serialize:K,stringToBuffer:S},U={},fe=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return U[u]||(U[u]=new a(u)),U[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete U[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function re(a){var u=a?m(a):{},v=I(u,this._defaultConfig),g=fe.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=k,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=g,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return x(v,a),v}function N(a,u){var v=Z.apply(this,arguments),g=v.promise,p=v.callback,w=g.then(function(B){fe.resolve(B).drop()});return x(w,p),g}function E(a,u){var v=this;a=F(a);var g=this.ready().then(function(){var p=v._dbInfo.mStore.get(a);return p==null?null:v._dbInfo.serializer.deserialize(p)});return x(g,u),g}function O(a,u){var v=this,g=this.ready().then(function(){for(var p=v._dbInfo.mStore,w=p.keys(),B=0;B<w.length;B++){var j=p.get(w[B]);if(j&&(j=v._dbInfo.serializer.deserialize(j)),j=a(j,w[B],B+1),j!==void 0)return j}});return x(g,u),g}function G(a,u){var v=this,g=this.ready().then(function(){var p;try{p=v._dbInfo.mStore.key(a),p===void 0&&(p=null)}catch{p=null}return p});return x(g,u),g}function X(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return x(v,a),v}function Q(a){var u=this.keys().then(function(v){return v.length});return x(u,a),u}function $(a,u){var v=this;a=F(a);var g=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return x(g,u),g}function ee(a,u,v){var g=this;a=F(a);var p=this.ready().then(function(){u===void 0&&(u=null);var w=u;return new Promise(function(B,j){g._dbInfo.serializer.serialize(u,function(se,ae){if(ae)j(ae);else try{g._dbInfo.mStore.set(a,se),B(w)}catch(ce){j(ce)}})})});return x(p,v),p}var oe=!0;b._support=oe,b._driver=T,b._initStorage=re,b.clear=h,b.dropInstance=N,b.getItem=E,b.iterate=O,b.key=G,b.keys=X,b.length=Q,b.removeItem=$,b.setItem=ee,Object.defineProperty(b,"__esModule",{value:!0})})});var pe=Ze(ke()),Ne=Ze(tt());import{SDKBase as gr,createSDK as pr}from"@magic-sdk/provider";import{createDuplicateIframeWarning as or,createModalLostError as ar,createModalNotReadyError as fr,createURL as rt,ViewController as sr}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as ur,MagicOutgoingWindowMessage as cr}from"@magic-sdk/types";var lr={display:"block",visibility:"hidden",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function dr(b){for(let[T,_]of Object.entries(lr))b.style[T]=_}function vr(b){let T=[].slice.call(document.querySelectorAll(".magic-iframe"));return Boolean(T.find(_=>_.src.includes(b)))}var nt=1e3,it=60*nt,hr=15*nt,mr=5*it,yr=60*it,ge=class extends sr{constructor(){super(...arguments);this.activeElement=null;this.lastPingTime=Date.now();this.heartbeatIntervalTimer=null;this.heartbeatTimeoutTimer=null}getIframeSrc(){return rt(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href}init(){this.test="hello",this.iframe=new Promise(_=>{let D=()=>{if(vr(encodeURIComponent(this.parameters)))or().log();else{let R=document.createElement("iframe");R.classList.add("magic-iframe"),R.dataset.magicIframeLabel=rt(this.endpoint).host,R.title="Secure Modal",R.src=this.getIframeSrc(),R.allow="clipboard-read; clipboard-write",dr(R),document.body.appendChild(R),_(R)}};["loaded","interactive","complete"].includes(document.readyState)?D():window.addEventListener("load",D,!1)}),this.iframe.then(_=>{_ instanceof HTMLIFrameElement&&_.addEventListener("load",()=>te(this,null,function*(){yield this.startHeartBeat()}))}),window.addEventListener("message",_=>{var D;if(_.origin===this.endpoint&&_.data&&_.data.msgType&&this.messageHandlers.size){_.data.msgType.includes(ur.MAGIC_PONG)&&(this.lastPingTime=Date.now()),_.data.response=(D=_.data.response)!=null?D:{};for(let V of this.messageHandlers.values())V(_)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}showOverlay(){return te(this,null,function*(){let _=yield this.iframe;_.style.visibility="visible",_.style.zIndex="2147483647",_.style.opacity="1",this.activeElement=document.activeElement,_.focus()})}hideOverlay(){return te(this,null,function*(){var D;let _=yield this.iframe;_.style.visibility="hidden",_.style.zIndex="-1",_.style.opacity="0",(D=this.activeElement)!=null&&D.focus&&this.activeElement.focus(),this.activeElement=null})}_post(_){return te(this,null,function*(){let D=yield this.checkIframeExists();if(!D)throw this.init(),ar();if(D&&D.contentWindow)D.contentWindow.postMessage(_,this.endpoint);else throw fr()})}startHeartBeat(){return te(this,null,function*(){if(yield this.iframe){let D=()=>{this.heartbeatIntervalTimer=setInterval(()=>te(this,null,function*(){let R={msgType:`${cr.MAGIC_PING}-${this.parameters}`,payload:[]};yield this._post(R),Date.now()-this.lastPingTime>hr&&(yield this.reloadIframe(),this.lastPingTime=Date.now())}),mr)};this.heartbeatTimeoutTimer=setTimeout(()=>D(),yr)}})}stopHeartBeat(){this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}reloadIframe(){return te(this,null,function*(){let _=yield this.iframe;_?_.src=this.getIframeSrc():(this.init(),console.log("Magic SDK: iframe lost, re-initiating")),this.stopHeartBeat(),this.startHeartBeat()})}checkIframeExists(){return te(this,null,function*(){return[].slice.call(document.querySelectorAll(".magic-iframe")).find(D=>D.src.includes(encodeURIComponent(this.parameters)))})}};export*from"@magic-sdk/commons";var Dr=pr(gr,{platform:"web",sdkName:"magic-sdk",version:"29.0.1",defaultEndpoint:"https://auth.magic.link/",ViewController:ge,configureStorage:()=>te(void 0,null,function*(){let b=pe.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return yield b.defineDriver(Ne),yield b.setDriver([pe.default.INDEXEDDB,pe.default.LOCALSTORAGE,Ne._driver]),b})});export{Dr as Magic};
|
1
|
+
var kt=Object.create;var $e=Object.defineProperty;var er=Object.getOwnPropertyDescriptor;var tr=Object.getOwnPropertyNames;var rr=Object.getPrototypeOf,nr=Object.prototype.hasOwnProperty;var ve=(b=>typeof require!="undefined"?require:typeof Proxy!="undefined"?new Proxy(b,{get:(T,_)=>(typeof require!="undefined"?require:T)[_]}):b)(function(b){if(typeof require!="undefined")return require.apply(this,arguments);throw new Error('Dynamic require of "'+b+'" is not supported')});var Je=(b,T)=>()=>(T||b((T={exports:{}}).exports,T),T.exports);var or=(b,T,_,R)=>{if(T&&typeof T=="object"||typeof T=="function")for(let D of tr(T))!nr.call(b,D)&&D!==_&&$e(b,D,{get:()=>T[D],enumerable:!(R=er(T,D))||R.enumerable});return b};var Ze=(b,T,_)=>(_=b!=null?kt(rr(b)):{},or(T||!b||!b.__esModule?$e(_,"default",{value:b,enumerable:!0}):_,b));var te=(b,T,_)=>new Promise((R,D)=>{var j=S=>{try{z(_.next(S))}catch(M){D(M)}},P=S=>{try{z(_.throw(S))}catch(M){D(M)}},z=S=>S.done?R(S.value):Promise.resolve(S.value).then(j,P);z((_=_.apply(b,T)).next())});var ke=Je((qe,De)=>{(function(b){if(typeof qe=="object"&&typeof De<"u")De.exports=b();else if(typeof define=="function"&&define.amd)define([],b);else{var T;typeof window<"u"?T=window:typeof global<"u"?T=global:typeof self<"u"?T=self:T=this,T.localforage=b()}})(function(){var b,T,_;return function R(D,j,P){function z(K,J){if(!j[K]){if(!D[K]){var m=typeof ve=="function"&&ve;if(!J&&m)return m(K,!0);if(S)return S(K,!0);var I=new Error("Cannot find module '"+K+"'");throw I.code="MODULE_NOT_FOUND",I}var x=j[K]={exports:{}};D[K][0].call(x.exports,function(W){var Z=D[K][1][W];return z(Z||W)},x,x.exports,R,D,j,P)}return j[K].exports}for(var S=typeof ve=="function"&&ve,M=0;M<P.length;M++)z(P[M]);return z}({1:[function(R,D,j){(function(P){"use strict";var z=P.MutationObserver||P.WebKitMutationObserver,S;if(z){var M=0,K=new z(W),J=P.document.createTextNode("");K.observe(J,{characterData:!0}),S=function(){J.data=M=++M%2}}else if(!P.setImmediate&&typeof P.MessageChannel<"u"){var m=new P.MessageChannel;m.port1.onmessage=W,S=function(){m.port2.postMessage(0)}}else"document"in P&&"onreadystatechange"in P.document.createElement("script")?S=function(){var F=P.document.createElement("script");F.onreadystatechange=function(){W(),F.onreadystatechange=null,F.parentNode.removeChild(F),F=null},P.document.documentElement.appendChild(F)}:S=function(){setTimeout(W,0)};var I,x=[];function W(){I=!0;for(var F,k,U=x.length;U;){for(k=x,x=[],F=-1;++F<U;)k[F]();U=x.length}I=!1}D.exports=Z;function Z(F){x.push(F)===1&&!I&&S()}}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{}],2:[function(R,D,j){"use strict";var P=R(1);function z(){}var S={},M=["REJECTED"],K=["FULFILLED"],J=["PENDING"];D.exports=m;function m(h){if(typeof h!="function")throw new TypeError("resolver must be a function");this.state=J,this.queue=[],this.outcome=void 0,h!==z&&Z(this,h)}m.prototype.catch=function(h){return this.then(null,h)},m.prototype.then=function(h,N){if(typeof h!="function"&&this.state===K||typeof N!="function"&&this.state===M)return this;var E=new this.constructor(z);if(this.state!==J){var C=this.state===K?h:N;x(E,C,this.outcome)}else this.queue.push(new I(E,h,N));return E};function I(h,N,E){this.promise=h,typeof N=="function"&&(this.onFulfilled=N,this.callFulfilled=this.otherCallFulfilled),typeof E=="function"&&(this.onRejected=E,this.callRejected=this.otherCallRejected)}I.prototype.callFulfilled=function(h){S.resolve(this.promise,h)},I.prototype.otherCallFulfilled=function(h){x(this.promise,this.onFulfilled,h)},I.prototype.callRejected=function(h){S.reject(this.promise,h)},I.prototype.otherCallRejected=function(h){x(this.promise,this.onRejected,h)};function x(h,N,E){P(function(){var C;try{C=N(E)}catch(G){return S.reject(h,G)}C===h?S.reject(h,new TypeError("Cannot resolve promise with itself")):S.resolve(h,C)})}S.resolve=function(h,N){var E=F(W,N);if(E.status==="error")return S.reject(h,E.value);var C=E.value;if(C)Z(h,C);else{h.state=K,h.outcome=N;for(var G=-1,X=h.queue.length;++G<X;)h.queue[G].callFulfilled(N)}return h},S.reject=function(h,N){h.state=M,h.outcome=N;for(var E=-1,C=h.queue.length;++E<C;)h.queue[E].callRejected(N);return h};function W(h){var N=h&&h.then;if(h&&(typeof h=="object"||typeof h=="function")&&typeof N=="function")return function(){N.apply(h,arguments)}}function Z(h,N){var E=!1;function C($){E||(E=!0,S.reject(h,$))}function G($){E||(E=!0,S.resolve(h,$))}function X(){N(G,C)}var Q=F(X);Q.status==="error"&&C(Q.value)}function F(h,N){var E={};try{E.value=h(N),E.status="success"}catch(C){E.status="error",E.value=C}return E}m.resolve=k;function k(h){return h instanceof this?h:S.resolve(new this(z),h)}m.reject=U;function U(h){var N=new this(z);return S.reject(N,h)}m.all=fe;function fe(h){var N=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,C=!1;if(!E)return this.resolve([]);for(var G=new Array(E),X=0,Q=-1,$=new this(z);++Q<E;)ee(h[Q],Q);return $;function ee(ie,a){N.resolve(ie).then(u,function(v){C||(C=!0,S.reject($,v))});function u(v){G[a]=v,++X===E&&!C&&(C=!0,S.resolve($,G))}}}m.race=re;function re(h){var N=this;if(Object.prototype.toString.call(h)!=="[object Array]")return this.reject(new TypeError("must be an array"));var E=h.length,C=!1;if(!E)return this.resolve([]);for(var G=-1,X=new this(z);++G<E;)Q(h[G]);return X;function Q($){N.resolve($).then(function(ee){C||(C=!0,S.resolve(X,ee))},function(ee){C||(C=!0,S.reject(X,ee))})}}},{1:1}],3:[function(R,D,j){(function(P){"use strict";typeof P.Promise!="function"&&(P.Promise=R(2))}).call(this,typeof global<"u"?global:typeof self<"u"?self:typeof window<"u"?window:{})},{2:2}],4:[function(R,D,j){"use strict";var P=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 z(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")}function S(){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 M=S();function K(){try{if(!M||!M.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 J(e,r){e=e||[],r=r||{};try{return new Blob(e,r)}catch(n){if(n.name!=="TypeError")throw n;for(var t=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,o=new t,i=0;i<e.length;i+=1)o.append(e[i]);return o.getBlob(r.type)}}typeof Promise>"u"&&R(3);var m=Promise;function I(e,r){r&&e.then(function(t){r(null,t)},function(t){r(t)})}function x(e,r,t){typeof r=="function"&&e.then(r),typeof t=="function"&&e.catch(t)}function W(e){return typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e)),e}function Z(){if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}var F="local-forage-detect-blob-support",k=void 0,U={},fe=Object.prototype.toString,re="readonly",h="readwrite";function N(e){for(var r=e.length,t=new ArrayBuffer(r),o=new Uint8Array(t),i=0;i<r;i++)o[i]=e.charCodeAt(i);return t}function E(e){return new m(function(r){var t=e.transaction(F,h),o=J([""]);t.objectStore(F).put(o,"key"),t.onabort=function(i){i.preventDefault(),i.stopPropagation(),r(!1)},t.oncomplete=function(){var i=navigator.userAgent.match(/Chrome\/(\d+)/),n=navigator.userAgent.match(/Edge\//);r(n||!i||parseInt(i[1],10)>=43)}}).catch(function(){return!1})}function C(e){return typeof k=="boolean"?m.resolve(k):E(e).then(function(r){return k=r,k})}function G(e){var r=U[e.name],t={};t.promise=new m(function(o,i){t.resolve=o,t.reject=i}),r.deferredOperations.push(t),r.dbReady?r.dbReady=r.dbReady.then(function(){return t.promise}):r.dbReady=t.promise}function X(e){var r=U[e.name],t=r.deferredOperations.pop();if(t)return t.resolve(),t.promise}function Q(e,r){var t=U[e.name],o=t.deferredOperations.pop();if(o)return o.reject(r),o.promise}function $(e,r){return new m(function(t,o){if(U[e.name]=U[e.name]||V(),e.db)if(r)G(e),e.db.close();else return t(e.db);var i=[e.name];r&&i.push(e.version);var n=M.open.apply(M,i);r&&(n.onupgradeneeded=function(f){var s=n.result;try{s.createObjectStore(e.storeName),f.oldVersion<=1&&s.createObjectStore(F)}catch(c){if(c.name==="ConstraintError")console.warn('The database "'+e.name+'" has been upgraded from version '+f.oldVersion+" to version "+f.newVersion+', but the storage "'+e.storeName+'" already exists.');else throw c}}),n.onerror=function(f){f.preventDefault(),o(n.error)},n.onsuccess=function(){var f=n.result;f.onversionchange=function(s){s.target.close()},t(f),X(e)}})}function ee(e){return $(e,!1)}function ie(e){return $(e,!0)}function a(e,r){if(!e.db)return!0;var t=!e.db.objectStoreNames.contains(e.storeName),o=e.version<e.db.version,i=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),i||t){if(t){var n=e.db.version+1;n>e.version&&(e.version=n)}return!0}return!1}function u(e){return new m(function(r,t){var o=new FileReader;o.onerror=t,o.onloadend=function(i){var n=btoa(i.target.result||"");r({__local_forage_encoded_blob:!0,data:n,type:e.type})},o.readAsBinaryString(e)})}function v(e){var r=N(atob(e.data));return J([r],{type:e.type})}function p(e){return e&&e.__local_forage_encoded_blob}function g(e){var r=this,t=r._initReady().then(function(){var o=U[r._dbInfo.name];if(o&&o.dbReady)return o.dbReady});return x(t,e,e),t}function w(e){G(e);for(var r=U[e.name],t=r.forages,o=0;o<t.length;o++){var i=t[o];i._dbInfo.db&&(i._dbInfo.db.close(),i._dbInfo.db=null)}return e.db=null,ee(e).then(function(n){return e.db=n,a(e)?ie(e):n}).then(function(n){e.db=r.db=n;for(var f=0;f<t.length;f++)t[f]._dbInfo.db=n}).catch(function(n){throw Q(e,n),n})}function B(e,r,t,o){o===void 0&&(o=1);try{var i=e.db.transaction(e.storeName,r);t(null,i)}catch(n){if(o>0&&(!e.db||n.name==="InvalidStateError"||n.name==="NotFoundError"))return m.resolve().then(function(){if(!e.db||n.name==="NotFoundError"&&!e.db.objectStoreNames.contains(e.storeName)&&e.version<=e.db.version)return e.db&&(e.version=e.db.version+1),ie(e)}).then(function(){return w(e).then(function(){B(e,r,t,o-1)})}).catch(t);t(n)}}function V(){return{forages:[],db:null,dbReady:null,deferredOperations:[]}}function se(e){var r=this,t={db:null};if(e)for(var o in e)t[o]=e[o];var i=U[t.name];i||(i=V(),U[t.name]=i),i.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=g);var n=[];function f(){return m.resolve()}for(var s=0;s<i.forages.length;s++){var c=i.forages[s];c!==r&&n.push(c._initReady().catch(f))}var l=i.forages.slice(0);return m.all(n).then(function(){return t.db=i.db,ee(t)}).then(function(d){return t.db=d,a(t,r._defaultConfig.version)?ie(t):d}).then(function(d){t.db=i.db=d,r._dbInfo=t;for(var y=0;y<l.length;y++){var A=l[y];A!==r&&(A._dbInfo.db=t.db,A._dbInfo.version=t.version)}})}function ae(e,r){var t=this;e=W(e);var o=new m(function(i,n){t.ready().then(function(){B(t._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(t._dbInfo.storeName),l=c.get(e);l.onsuccess=function(){var d=l.result;d===void 0&&(d=null),p(d)&&(d=v(d)),i(d)},l.onerror=function(){n(l.error)}}catch(d){n(d)}})}).catch(n)});return I(o,r),o}function ce(e,r){var t=this,o=new m(function(i,n){t.ready().then(function(){B(t._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(t._dbInfo.storeName),l=c.openCursor(),d=1;l.onsuccess=function(){var y=l.result;if(y){var A=y.value;p(A)&&(A=v(A));var O=e(A,y.key,d++);O!==void 0?i(O):y.continue()}else i()},l.onerror=function(){n(l.error)}}catch(y){n(y)}})}).catch(n)});return I(o,r),o}function it(e,r,t){var o=this;e=W(e);var i=new m(function(n,f){var s;o.ready().then(function(){return s=o._dbInfo,fe.call(r)==="[object Blob]"?C(s.db).then(function(c){return c?r:u(r)}):r}).then(function(c){B(o._dbInfo,h,function(l,d){if(l)return f(l);try{var y=d.objectStore(o._dbInfo.storeName);c===null&&(c=void 0);var A=y.put(c,e);d.oncomplete=function(){c===void 0&&(c=null),n(c)},d.onabort=d.onerror=function(){var O=A.error?A.error:A.transaction.error;f(O)}}catch(O){f(O)}})}).catch(f)});return I(i,t),i}function at(e,r){var t=this;e=W(e);var o=new m(function(i,n){t.ready().then(function(){B(t._dbInfo,h,function(f,s){if(f)return n(f);try{var c=s.objectStore(t._dbInfo.storeName),l=c.delete(e);s.oncomplete=function(){i()},s.onerror=function(){n(l.error)},s.onabort=function(){var d=l.error?l.error:l.transaction.error;n(d)}}catch(d){n(d)}})}).catch(n)});return I(o,r),o}function ft(e){var r=this,t=new m(function(o,i){r.ready().then(function(){B(r._dbInfo,h,function(n,f){if(n)return i(n);try{var s=f.objectStore(r._dbInfo.storeName),c=s.clear();f.oncomplete=function(){o()},f.onabort=f.onerror=function(){var l=c.error?c.error:c.transaction.error;i(l)}}catch(l){i(l)}})}).catch(i)});return I(t,e),t}function st(e){var r=this,t=new m(function(o,i){r.ready().then(function(){B(r._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(r._dbInfo.storeName),c=s.count();c.onsuccess=function(){o(c.result)},c.onerror=function(){i(c.error)}}catch(l){i(l)}})}).catch(i)});return I(t,e),t}function ut(e,r){var t=this,o=new m(function(i,n){if(e<0){i(null);return}t.ready().then(function(){B(t._dbInfo,re,function(f,s){if(f)return n(f);try{var c=s.objectStore(t._dbInfo.storeName),l=!1,d=c.openKeyCursor();d.onsuccess=function(){var y=d.result;if(!y){i(null);return}e===0||l?i(y.key):(l=!0,y.advance(e))},d.onerror=function(){n(d.error)}}catch(y){n(y)}})}).catch(n)});return I(o,r),o}function ct(e){var r=this,t=new m(function(o,i){r.ready().then(function(){B(r._dbInfo,re,function(n,f){if(n)return i(n);try{var s=f.objectStore(r._dbInfo.storeName),c=s.openKeyCursor(),l=[];c.onsuccess=function(){var d=c.result;if(!d){o(l);return}l.push(d.key),d.continue()},c.onerror=function(){i(c.error)}}catch(d){i(d)}})}).catch(i)});return I(t,e),t}function lt(e,r){r=Z.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,i;if(!e.name)i=m.reject("Invalid arguments");else{var n=e.name===t.name&&o._dbInfo.db,f=n?m.resolve(o._dbInfo.db):ee(e).then(function(s){var c=U[e.name],l=c.forages;c.db=s;for(var d=0;d<l.length;d++)l[d]._dbInfo.db=s;return s});e.storeName?i=f.then(function(s){if(!!s.objectStoreNames.contains(e.storeName)){var c=s.version+1;G(e);var l=U[e.name],d=l.forages;s.close();for(var y=0;y<d.length;y++){var A=d[y];A._dbInfo.db=null,A._dbInfo.version=c}var O=new m(function(L,H){var Y=M.open(e.name,c);Y.onerror=function(q){var de=Y.result;de.close(),H(q)},Y.onupgradeneeded=function(){var q=Y.result;q.deleteObjectStore(e.storeName)},Y.onsuccess=function(){var q=Y.result;q.close(),L(q)}});return O.then(function(L){l.db=L;for(var H=0;H<d.length;H++){var Y=d[H];Y._dbInfo.db=L,X(Y._dbInfo)}}).catch(function(L){throw(Q(e,L)||m.resolve()).catch(function(){}),L})}}):i=f.then(function(s){G(e);var c=U[e.name],l=c.forages;s.close();for(var d=0;d<l.length;d++){var y=l[d];y._dbInfo.db=null}var A=new m(function(O,L){var H=M.deleteDatabase(e.name);H.onerror=function(){var Y=H.result;Y&&Y.close(),L(H.error)},H.onblocked=function(){console.warn('dropInstance blocked for database "'+e.name+'" until all open connections are closed')},H.onsuccess=function(){var Y=H.result;Y&&Y.close(),O(Y)}});return A.then(function(O){c.db=O;for(var L=0;L<l.length;L++){var H=l[L];X(H._dbInfo)}}).catch(function(O){throw(Q(e,O)||m.resolve()).catch(function(){}),O})})}return I(i,r),i}var dt={_driver:"asyncStorage",_initStorage:se,_support:K(),iterate:ce,getItem:ae,setItem:it,removeItem:at,clear:ft,length:st,key:ut,keys:ct,dropInstance:lt};function vt(){return typeof openDatabase=="function"}var ne="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",ht="~~local_forage_type~",Be=/^~~local_forage_type~([^~]+)~/,he="__lfsc__:",be=he.length,_e="arbf",Ie="blob",xe="si08",Oe="ui08",Ce="uic8",Le="si16",Pe="si32",Me="ur16",Fe="ui32",Ue="fl32",ze="fl64",We=be+_e.length,Ye=Object.prototype.toString;function He(e){var r=e.length*.75,t=e.length,o,i=0,n,f,s,c;e[e.length-1]==="="&&(r--,e[e.length-2]==="="&&r--);var l=new ArrayBuffer(r),d=new Uint8Array(l);for(o=0;o<t;o+=4)n=ne.indexOf(e[o]),f=ne.indexOf(e[o+1]),s=ne.indexOf(e[o+2]),c=ne.indexOf(e[o+3]),d[i++]=n<<2|f>>4,d[i++]=(f&15)<<4|s>>2,d[i++]=(s&3)<<6|c&63;return l}function we(e){var r=new Uint8Array(e),t="",o;for(o=0;o<r.length;o+=3)t+=ne[r[o]>>2],t+=ne[(r[o]&3)<<4|r[o+1]>>4],t+=ne[(r[o+1]&15)<<2|r[o+2]>>6],t+=ne[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 mt(e,r){var t="";if(e&&(t=Ye.call(e)),e&&(t==="[object ArrayBuffer]"||e.buffer&&Ye.call(e.buffer)==="[object ArrayBuffer]")){var o,i=he;e instanceof ArrayBuffer?(o=e,i+=_e):(o=e.buffer,t==="[object Int8Array]"?i+=xe:t==="[object Uint8Array]"?i+=Oe:t==="[object Uint8ClampedArray]"?i+=Ce:t==="[object Int16Array]"?i+=Le:t==="[object Uint16Array]"?i+=Me:t==="[object Int32Array]"?i+=Pe:t==="[object Uint32Array]"?i+=Fe:t==="[object Float32Array]"?i+=Ue:t==="[object Float64Array]"?i+=ze:r(new Error("Failed to get type for BinaryArray"))),r(i+we(o))}else if(t==="[object Blob]"){var n=new FileReader;n.onload=function(){var f=ht+e.type+"~"+we(this.result);r(he+Ie+f)},n.readAsArrayBuffer(e)}else try{r(JSON.stringify(e))}catch(f){console.error("Couldn't convert value into a JSON string: ",e),r(null,f)}}function yt(e){if(e.substring(0,be)!==he)return JSON.parse(e);var r=e.substring(We),t=e.substring(be,We),o;if(t===Ie&&Be.test(r)){var i=r.match(Be);o=i[1],r=r.substring(i[0].length)}var n=He(r);switch(t){case _e:return n;case Ie:return J([n],{type:o});case xe:return new Int8Array(n);case Oe:return new Uint8Array(n);case Ce:return new Uint8ClampedArray(n);case Le:return new Int16Array(n);case Me:return new Uint16Array(n);case Pe:return new Int32Array(n);case Fe:return new Uint32Array(n);case Ue:return new Float32Array(n);case ze:return new Float64Array(n);default:throw new Error("Unkown type: "+t)}}var Ee={serialize:mt,deserialize:yt,stringToBuffer:He,bufferToString:we};function Ke(e,r,t,o){e.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],t,o)}function pt(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 i=new m(function(n,f){try{t.db=openDatabase(t.name,String(t.version),t.description,t.size)}catch(s){return f(s)}t.db.transaction(function(s){Ke(s,t,function(){r._dbInfo=t,n()},function(c,l){f(l)})},f)});return t.serializer=Ee,i}function oe(e,r,t,o,i,n){e.executeSql(t,o,i,function(f,s){s.code===s.SYNTAX_ERR?f.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name = ?",[r.storeName],function(c,l){l.rows.length?n(c,s):Ke(c,r,function(){c.executeSql(t,o,i,n)},n)},n):n(f,s)},n)}function gt(e,r){var t=this;e=W(e);var o=new m(function(i,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(s){oe(s,f,"SELECT * FROM "+f.storeName+" WHERE key = ? LIMIT 1",[e],function(c,l){var d=l.rows.length?l.rows.item(0).value:null;d&&(d=f.serializer.deserialize(d)),i(d)},function(c,l){n(l)})})}).catch(n)});return I(o,r),o}function bt(e,r){var t=this,o=new m(function(i,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(s){oe(s,f,"SELECT * FROM "+f.storeName,[],function(c,l){for(var d=l.rows,y=d.length,A=0;A<y;A++){var O=d.item(A),L=O.value;if(L&&(L=f.serializer.deserialize(L)),L=e(L,O.key,A+1),L!==void 0){i(L);return}}i()},function(c,l){n(l)})})}).catch(n)});return I(o,r),o}function Ge(e,r,t,o){var i=this;e=W(e);var n=new m(function(f,s){i.ready().then(function(){r===void 0&&(r=null);var c=r,l=i._dbInfo;l.serializer.serialize(r,function(d,y){y?s(y):l.db.transaction(function(A){oe(A,l,"INSERT OR REPLACE INTO "+l.storeName+" (key, value) VALUES (?, ?)",[e,d],function(){f(c)},function(O,L){s(L)})},function(A){if(A.code===A.QUOTA_ERR){if(o>0){f(Ge.apply(i,[e,c,t,o-1]));return}s(A)}})})}).catch(s)});return I(n,t),n}function _t(e,r,t){return Ge.apply(this,[e,r,t,1])}function It(e,r){var t=this;e=W(e);var o=new m(function(i,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(s){oe(s,f,"DELETE FROM "+f.storeName+" WHERE key = ?",[e],function(){i()},function(c,l){n(l)})})}).catch(n)});return I(o,r),o}function wt(e){var r=this,t=new m(function(o,i){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){oe(f,n,"DELETE FROM "+n.storeName,[],function(){o()},function(s,c){i(c)})})}).catch(i)});return I(t,e),t}function Et(e){var r=this,t=new m(function(o,i){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){oe(f,n,"SELECT COUNT(key) as c FROM "+n.storeName,[],function(s,c){var l=c.rows.item(0).c;o(l)},function(s,c){i(c)})})}).catch(i)});return I(t,e),t}function St(e,r){var t=this,o=new m(function(i,n){t.ready().then(function(){var f=t._dbInfo;f.db.transaction(function(s){oe(s,f,"SELECT key FROM "+f.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,l){var d=l.rows.length?l.rows.item(0).key:null;i(d)},function(c,l){n(l)})})}).catch(n)});return I(o,r),o}function At(e){var r=this,t=new m(function(o,i){r.ready().then(function(){var n=r._dbInfo;n.db.transaction(function(f){oe(f,n,"SELECT key FROM "+n.storeName,[],function(s,c){for(var l=[],d=0;d<c.rows.length;d++)l.push(c.rows.item(d).key);o(l)},function(s,c){i(c)})})}).catch(i)});return I(t,e),t}function Tt(e){return new m(function(r,t){e.transaction(function(o){o.executeSql("SELECT name FROM sqlite_master WHERE type='table' AND name <> '__WebKitDatabaseInfoTable__'",[],function(i,n){for(var f=[],s=0;s<n.rows.length;s++)f.push(n.rows.item(s).name);r({db:e,storeNames:f})},function(i,n){t(n)})},function(o){t(o)})})}function Rt(e,r){r=Z.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,i;return e.name?i=new m(function(n){var f;e.name===t.name?f=o._dbInfo.db:f=openDatabase(e.name,"","",0),e.storeName?n({db:f,storeNames:[e.storeName]}):n(Tt(f))}).then(function(n){return new m(function(f,s){n.db.transaction(function(c){function l(O){return new m(function(L,H){c.executeSql("DROP TABLE IF EXISTS "+O,[],function(){L()},function(Y,q){H(q)})})}for(var d=[],y=0,A=n.storeNames.length;y<A;y++)d.push(l(n.storeNames[y]));m.all(d).then(function(){f()}).catch(function(O){s(O)})},function(c){s(c)})})}):i=m.reject("Invalid arguments"),I(i,r),i}var Dt={_driver:"webSQLStorage",_initStorage:pt,_support:vt(),iterate:bt,getItem:gt,setItem:_t,removeItem:It,clear:wt,length:Et,key:St,keys:At,dropInstance:Rt};function Nt(){try{return typeof localStorage<"u"&&"setItem"in localStorage&&!!localStorage.setItem}catch{return!1}}function Ve(e,r){var t=e.name+"/";return e.storeName!==r.storeName&&(t+=e.storeName+"/"),t}function Bt(){var e="_localforage_support_test";try{return localStorage.setItem(e,!0),localStorage.removeItem(e),!1}catch{return!0}}function xt(){return!Bt()||localStorage.length>0}function Ot(e){var r=this,t={};if(e)for(var o in e)t[o]=e[o];return t.keyPrefix=Ve(e,r._defaultConfig),xt()?(r._dbInfo=t,t.serializer=Ee,m.resolve()):m.reject()}function Ct(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo.keyPrefix,i=localStorage.length-1;i>=0;i--){var n=localStorage.key(i);n.indexOf(o)===0&&localStorage.removeItem(n)}});return I(t,e),t}function Lt(e,r){var t=this;e=W(e);var o=t.ready().then(function(){var i=t._dbInfo,n=localStorage.getItem(i.keyPrefix+e);return n&&(n=i.serializer.deserialize(n)),n});return I(o,r),o}function Pt(e,r){var t=this,o=t.ready().then(function(){for(var i=t._dbInfo,n=i.keyPrefix,f=n.length,s=localStorage.length,c=1,l=0;l<s;l++){var d=localStorage.key(l);if(d.indexOf(n)===0){var y=localStorage.getItem(d);if(y&&(y=i.serializer.deserialize(y)),y=e(y,d.substring(f),c++),y!==void 0)return y}}});return I(o,r),o}function Mt(e,r){var t=this,o=t.ready().then(function(){var i=t._dbInfo,n;try{n=localStorage.key(e)}catch{n=null}return n&&(n=n.substring(i.keyPrefix.length)),n});return I(o,r),o}function Ft(e){var r=this,t=r.ready().then(function(){for(var o=r._dbInfo,i=localStorage.length,n=[],f=0;f<i;f++){var s=localStorage.key(f);s.indexOf(o.keyPrefix)===0&&n.push(s.substring(o.keyPrefix.length))}return n});return I(t,e),t}function Ut(e){var r=this,t=r.keys().then(function(o){return o.length});return I(t,e),t}function zt(e,r){var t=this;e=W(e);var o=t.ready().then(function(){var i=t._dbInfo;localStorage.removeItem(i.keyPrefix+e)});return I(o,r),o}function Wt(e,r,t){var o=this;e=W(e);var i=o.ready().then(function(){r===void 0&&(r=null);var n=r;return new m(function(f,s){var c=o._dbInfo;c.serializer.serialize(r,function(l,d){if(d)s(d);else try{localStorage.setItem(c.keyPrefix+e,l),f(n)}catch(y){(y.name==="QuotaExceededError"||y.name==="NS_ERROR_DOM_QUOTA_REACHED")&&s(y),s(y)}})})});return I(i,t),i}function Yt(e,r){if(r=Z.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,i;return e.name?i=new m(function(n){e.storeName?n(Ve(e,o._defaultConfig)):n(e.name+"/")}).then(function(n){for(var f=localStorage.length-1;f>=0;f--){var s=localStorage.key(f);s.indexOf(n)===0&&localStorage.removeItem(s)}}):i=m.reject("Invalid arguments"),I(i,r),i}var Ht={_driver:"localStorageWrapper",_initStorage:Ot,_support:Nt(),iterate:Pt,getItem:Lt,setItem:Wt,removeItem:zt,clear:Ct,length:Ut,key:Mt,keys:Ft,dropInstance:Yt},Kt=function(r,t){return r===t||typeof r=="number"&&typeof t=="number"&&isNaN(r)&&isNaN(t)},Gt=function(r,t){for(var o=r.length,i=0;i<o;){if(Kt(r[i],t))return!0;i++}return!1},je=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},le={},Xe={},ue={INDEXEDDB:dt,WEBSQL:Dt,LOCALSTORAGE:Ht},Vt=[ue.INDEXEDDB._driver,ue.WEBSQL._driver,ue.LOCALSTORAGE._driver],me=["dropInstance"],Se=["clear","getItem","iterate","key","keys","length","removeItem","setItem"].concat(me),jt={description:"",driver:Vt.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1};function Xt(e,r){e[r]=function(){var t=arguments;return e.ready().then(function(){return e[r].apply(e,t)})}}function Ae(){for(var e=1;e<arguments.length;e++){var r=arguments[e];if(r)for(var t in r)r.hasOwnProperty(t)&&(je(r[t])?arguments[0][t]=r[t].slice():arguments[0][t]=r[t])}return arguments[0]}var Qt=function(){function e(r){z(this,e);for(var t in ue)if(ue.hasOwnProperty(t)){var o=ue[t],i=o._driver;this[t]=i,le[i]||this.defineDriver(o)}this._defaultConfig=Ae({},jt),this._config=Ae({},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":P(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,i){var n=new m(function(f,s){try{var c=t._driver,l=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver");if(!t._driver){s(l);return}for(var d=Se.concat("_initStorage"),y=0,A=d.length;y<A;y++){var O=d[y],L=!Gt(me,O);if((L||t[O])&&typeof t[O]!="function"){s(l);return}}var H=function(){for(var de=function(Zt){return function(){var qt=new Error("Method "+Zt+" is not implemented by the current driver"),Qe=m.reject(qt);return I(Qe,arguments[arguments.length-1]),Qe}},Te=0,Jt=me.length;Te<Jt;Te++){var Re=me[Te];t[Re]||(t[Re]=de(Re))}};H();var Y=function(de){le[c]&&console.info("Redefining LocalForage driver: "+c),le[c]=t,Xe[c]=de,f()};"_support"in t?t._support&&typeof t._support=="function"?t._support().then(Y,s):Y(!!t._support):Y(!0)}catch(q){s(q)}});return x(n,o,i),n},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,o,i){var n=le[t]?m.resolve(le[t]):m.reject(new Error("Driver not found."));return x(n,o,i),n},e.prototype.getSerializer=function(t){var o=m.resolve(Ee);return x(o,t),o},e.prototype.ready=function(t){var o=this,i=o._driverSet.then(function(){return o._ready===null&&(o._ready=o._initDriver()),o._ready});return x(i,t,t),i},e.prototype.setDriver=function(t,o,i){var n=this;je(t)||(t=[t]);var f=this._getSupportedDrivers(t);function s(){n._config.driver=n.driver()}function c(y){return n._extend(y),s(),n._ready=n._initStorage(n._config),n._ready}function l(y){return function(){var A=0;function O(){for(;A<y.length;){var L=y[A];return A++,n._dbInfo=null,n._ready=null,n.getDriver(L).then(c).catch(O)}s();var H=new Error("No available storage method found.");return n._driverSet=m.reject(H),n._driverSet}return O()}}var d=this._driverSet!==null?this._driverSet.catch(function(){return m.resolve()}):m.resolve();return this._driverSet=d.then(function(){var y=f[0];return n._dbInfo=null,n._ready=null,n.getDriver(y).then(function(A){n._driver=A._driver,s(),n._wrapLibraryMethodsWithReady(),n._initDriver=l(f)})}).catch(function(){s();var y=new Error("No available storage method found.");return n._driverSet=m.reject(y),n._driverSet}),x(this._driverSet,o,i),this._driverSet},e.prototype.supports=function(t){return!!Xe[t]},e.prototype._extend=function(t){Ae(this,t)},e.prototype._getSupportedDrivers=function(t){for(var o=[],i=0,n=t.length;i<n;i++){var f=t[i];this.supports(f)&&o.push(f)}return o},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0,o=Se.length;t<o;t++)Xt(this,Se[t])},e.prototype.createInstance=function(t){return new e(t)},e}(),$t=new Qt;D.exports=$t},{3:3}]},{},[4])(4)})});var tt=Je((ye,et)=>{(function(b,T){typeof ye=="object"&&typeof et<"u"?T(ye):typeof define=="function"&&define.amd?define("localforage-driver-memory",["exports"],T):T(b.LocalforageDriverMemory={})})(typeof self<"u"?self:ye,function(b){"use strict";var T="localforage-driver-memory";function _(a){var u=typeof Symbol=="function"&&a[Symbol.iterator],v=0;return u?u.call(a):{next:function(){return a&&v>=a.length&&(a=void 0),{value:a&&a[v++],done:!a}}}}function R(a,u){a=a||[],u=u||{};try{return new Blob(a,u)}catch(w){if(w.name!=="TypeError")throw w;for(var v=typeof BlobBuilder<"u"?BlobBuilder:typeof MSBlobBuilder<"u"?MSBlobBuilder:typeof MozBlobBuilder<"u"?MozBlobBuilder:WebKitBlobBuilder,p=new v,g=0;g<a.length;g+=1)p.append(a[g]);return p.getBlob(u.type)}}var D=/^~~local_forage_type~([^~]+)~/,j=9,P=j+4,z=Object.prototype.toString;function S(a){var u=a.length*.75,v=a.length;a[a.length-1]==="="&&(u--,a[a.length-2]==="="&&u--);for(var p=new ArrayBuffer(u),g=new Uint8Array(p),w=0,B=0;w<v;w+=4){var V="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w]),se="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w+1]),ae="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w+2]),ce="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/".indexOf(a[w+3]);g[B++]=V<<2|se>>4,g[B++]=(se&15)<<4|ae>>2,g[B++]=(ae&3)<<6|ce&63}return p}function M(a){for(var u=new Uint8Array(a),v="",p=0;p<u.length;p+=3)v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[p]>>2],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[p]&3)<<4|u[p+1]>>4],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[(u[p+1]&15)<<2|u[p+2]>>6],v+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[u[p+2]&63];return u.length%3===2?v=v.substring(0,v.length-1)+"=":u.length%3===1&&(v=v.substring(0,v.length-2)+"=="),v}function K(a,u){var v="";if(a&&(v=z.call(a)),a&&(v==="[object ArrayBuffer]"||a.buffer&&z.call(a.buffer)==="[object ArrayBuffer]")){var p=void 0,g="__lfsc__:";a instanceof ArrayBuffer?(p=a,g+="arbf"):(p=a.buffer,v==="[object Int8Array]"?g+="si08":v==="[object Uint8Array]"?g+="ui08":v==="[object Uint8ClampedArray]"?g+="uic8":v==="[object Int16Array]"?g+="si16":v==="[object Uint16Array]"?g+="ur16":v==="[object Int32Array]"?g+="si32":v==="[object Uint32Array]"?g+="ui32":v==="[object Float32Array]"?g+="fl32":v==="[object Float64Array]"?g+="fl64":u(new Error("Failed to get type for BinaryArray"))),u(g+M(p))}else if(v==="[object Blob]"){var w=new FileReader;w.onload=function(){var B="~~local_forage_type~"+a.type+"~"+M(this.result);u("__lfsc__:blob"+B)},w.readAsArrayBuffer(a)}else try{u(JSON.stringify(a))}catch(B){console.error("Couldn't convert value into a JSON string: ",a),u(null,B)}}function J(a){if(a.substring(0,j)!=="__lfsc__:")return JSON.parse(a);var u=a.substring(P),v=a.substring(j,P),p;if(v==="blob"&&D.test(u)){var g=u.match(D);p=g[1],u=u.substring(g[0].length)}var w=S(u);switch(v){case"arbf":return w;case"blob":return R([w],{type:p});case"si08":return new Int8Array(w);case"ui08":return new Uint8Array(w);case"uic8":return new Uint8ClampedArray(w);case"si16":return new Int16Array(w);case"ur16":return new Uint16Array(w);case"si32":return new Int32Array(w);case"ui32":return new Uint32Array(w);case"fl32":return new Float32Array(w);case"fl64":return new Float64Array(w);default:throw new Error("Unkown type: "+v)}}function m(a){var u,v;if(a===null||typeof a!="object"||"isActiveClone"in a)return a;var p=a instanceof Date?new Date(a):a.constructor();try{for(var g=_(Object.keys(a)),w=g.next();!w.done;w=g.next()){var B=w.value;Object.prototype.hasOwnProperty.call(a,B)&&(a.isActiveClone=null,p[B]=m(a[B]),delete a.isActiveClone)}}catch(V){u={error:V}}finally{try{w&&!w.done&&(v=g.return)&&v.call(g)}finally{if(u)throw u.error}}return p}function I(a,u){return(a.name||u.name)+"/"+(a.storeName||u.storeName)+"/"}function x(a,u){u&&a.then(function(v){u(null,v)},function(v){u(v)})}function W(){for(var a=[],u=0;u<arguments.length;u++)a[u]=arguments[u];if(arguments.length&&typeof arguments[arguments.length-1]=="function")return arguments[arguments.length-1]}function Z(a,u){var v=this;if(u=W.apply(this,arguments),a=typeof a!="function"&&a||{},!a.name){var p=this.config();a.name=a.name||p.name,a.storeName=a.storeName||p.storeName}var g;return a.name?g=new Promise(function(w){a.storeName?w(I(a,v._defaultConfig)):w(a.name+"/")}):g=Promise.reject("Invalid arguments"),{promise:g,callback:u}}function F(a){return typeof a!="string"&&(console.warn(a+" used as a key, but it is not a string."),a=String(a)),a}var k={bufferToString:M,deserialize:J,serialize:K,stringToBuffer:S},U={},fe=function(){function a(u){this.kp=u,this.data={}}return a.resolve=function(u){return U[u]||(U[u]=new a(u)),U[u]},a.prototype.clear=function(){this.data={}},a.prototype.drop=function(){this.clear(),delete U[this.kp]},a.prototype.get=function(u){return this.data[u]},a.prototype.key=function(u){return this.keys()[u]},a.prototype.keys=function(){return Object.keys(this.data)},a.prototype.rm=function(u){delete this.data[u]},a.prototype.set=function(u,v){this.data[u]=v},a}();function re(a){var u=a?m(a):{},v=I(u,this._defaultConfig),p=fe.resolve(v);return this._dbInfo=u,this._dbInfo.serializer=k,this._dbInfo.keyPrefix=v,this._dbInfo.mStore=p,Promise.resolve()}function h(a){var u=this,v=this.ready().then(function(){u._dbInfo.mStore.clear()});return x(v,a),v}function N(a,u){var v=Z.apply(this,arguments),p=v.promise,g=v.callback,w=p.then(function(B){fe.resolve(B).drop()});return x(w,g),p}function E(a,u){var v=this;a=F(a);var p=this.ready().then(function(){var g=v._dbInfo.mStore.get(a);return g==null?null:v._dbInfo.serializer.deserialize(g)});return x(p,u),p}function C(a,u){var v=this,p=this.ready().then(function(){for(var g=v._dbInfo.mStore,w=g.keys(),B=0;B<w.length;B++){var V=g.get(w[B]);if(V&&(V=v._dbInfo.serializer.deserialize(V)),V=a(V,w[B],B+1),V!==void 0)return V}});return x(p,u),p}function G(a,u){var v=this,p=this.ready().then(function(){var g;try{g=v._dbInfo.mStore.key(a),g===void 0&&(g=null)}catch{g=null}return g});return x(p,u),p}function X(a){var u=this,v=this.ready().then(function(){return u._dbInfo.mStore.keys()});return x(v,a),v}function Q(a){var u=this.keys().then(function(v){return v.length});return x(u,a),u}function $(a,u){var v=this;a=F(a);var p=this.ready().then(function(){v._dbInfo.mStore.rm(a)});return x(p,u),p}function ee(a,u,v){var p=this;a=F(a);var g=this.ready().then(function(){u===void 0&&(u=null);var w=u;return new Promise(function(B,V){p._dbInfo.serializer.serialize(u,function(se,ae){if(ae)V(ae);else try{p._dbInfo.mStore.set(a,se),B(w)}catch(ce){V(ce)}})})});return x(g,v),g}var ie=!0;b._support=ie,b._driver=T,b._initStorage=re,b.clear=h,b.dropInstance=N,b.getItem=E,b.iterate=C,b.key=G,b.keys=X,b.length=Q,b.removeItem=$,b.setItem=ee,Object.defineProperty(b,"__esModule",{value:!0})})});var ge=Ze(ke()),Ne=Ze(tt());import{SDKBase as yr,createSDK as pr}from"@magic-sdk/provider";import{createDuplicateIframeWarning as ir,createModalLostError as ar,createModalNotReadyError as fr,createURL as rt,ViewController as sr}from"@magic-sdk/provider";import{MagicIncomingWindowMessage as ur,MagicOutgoingWindowMessage as cr}from"@magic-sdk/types";var lr={display:"block",visibility:"hidden",position:"fixed",top:"0",right:"0",width:"100%",height:"100%",borderRadius:"0",border:"none",opacity:"0",zIndex:"-1"};function dr(b){for(let[T,_]of Object.entries(lr))b.style[T]=_}function vr(b){let T=[].slice.call(document.querySelectorAll(".magic-iframe"));return Boolean(T.find(_=>_.src.includes(b)))}var hr=1e3,ot=60*hr,nt=5*ot,mr=60*ot,pe=class extends sr{constructor(){super(...arguments);this.activeElement=null;this.lastPongTime=Date.now();this.heartbeatIntervalTimer=null;this.heartbeatTimeoutTimer=null}getIframeSrc(){return rt(`/send?params=${encodeURIComponent(this.parameters)}`,this.endpoint).href}init(){this.test="hello",this.iframe=new Promise(_=>{let R=()=>{if(vr(encodeURIComponent(this.parameters)))ir().log();else{let D=document.createElement("iframe");D.classList.add("magic-iframe"),D.dataset.magicIframeLabel=rt(this.endpoint).host,D.title="Secure Modal",D.src=this.getIframeSrc(),D.allow="clipboard-read; clipboard-write",dr(D),document.body.appendChild(D),_(D)}};["loaded","interactive","complete"].includes(document.readyState)?R():window.addEventListener("load",R,!1)}),this.iframe.then(_=>{_ instanceof HTMLIFrameElement&&_.addEventListener("load",()=>te(this,null,function*(){yield this.startHeartBeat()}))}),window.addEventListener("message",_=>{var R;if(_.origin===this.endpoint&&_.data&&_.data.msgType&&this.messageHandlers.size){_.data.msgType.includes(ur.MAGIC_PONG)&&(this.lastPongTime=Date.now()),_.data.response=(R=_.data.response)!=null?R:{};for(let j of this.messageHandlers.values())j(_)}}),window.addEventListener("beforeunload",()=>{this.stopHeartBeat()})}showOverlay(){return te(this,null,function*(){let _=yield this.iframe;_.style.visibility="visible",_.style.zIndex="2147483647",_.style.opacity="1",this.activeElement=document.activeElement,_.focus()})}hideOverlay(){return te(this,null,function*(){var R;let _=yield this.iframe;_.style.visibility="hidden",_.style.zIndex="-1",_.style.opacity="0",(R=this.activeElement)!=null&&R.focus&&this.activeElement.focus(),this.activeElement=null})}_post(_){return te(this,null,function*(){let R=yield this.checkIframeExistsInDOM();if(!R)throw this.init(),ar();if(R&&R.contentWindow)R.contentWindow.postMessage(_,this.endpoint);else throw fr()})}heartBeatCheck(){this.heartbeatIntervalTimer=setInterval(()=>te(this,null,function*(){if(Date.now()-this.lastPongTime>nt)this.reloadIframe(),this.lastPongTime=Date.now();else{let R={msgType:`${cr.MAGIC_PING}-${this.parameters}`,payload:[]};yield this._post(R)}}),nt)}startHeartBeat(){return te(this,null,function*(){(yield this.iframe)&&(this.heartbeatTimeoutTimer=setTimeout(()=>this.heartBeatCheck(),mr))})}stopHeartBeat(){this.heartbeatTimeoutTimer&&(clearTimeout(this.heartbeatTimeoutTimer),this.heartbeatTimeoutTimer=null),this.heartbeatIntervalTimer&&(clearInterval(this.heartbeatIntervalTimer),this.heartbeatIntervalTimer=null)}reloadIframe(){return te(this,null,function*(){let _=yield this.iframe;this.stopHeartBeat(),_?_.src=this.getIframeSrc():(this.init(),console.warn("Magic SDK: Modal lost, re-initiating"))})}checkIframeExistsInDOM(){return te(this,null,function*(){return[].slice.call(document.querySelectorAll(".magic-iframe")).find(R=>R.src.includes(encodeURIComponent(this.parameters)))})}};export*from"@magic-sdk/commons";var Rr=pr(yr,{platform:"web",sdkName:"magic-sdk",version:"29.0.1",defaultEndpoint:"https://auth.magic.link/",ViewController:pe,configureStorage:()=>te(void 0,null,function*(){let b=ge.default.createInstance({name:"MagicAuthLocalStorageDB",storeName:"MagicAuthLocalStorage"});return yield b.defineDriver(Ne),yield b.setDriver([ge.default.INDEXEDDB,ge.default.LOCALSTORAGE,Ne._driver]),b})});export{Rr as Magic};
|
2
2
|
//# sourceMappingURL=index.mjs.map
|