7 lines
25 KiB
JavaScript
7 lines
25 KiB
JavaScript
/*!
|
|
localForage -- Offline Storage, Improved
|
|
Version 1.5.0
|
|
https://localforage.github.io/localForage
|
|
(c) 2013-2017 Mozilla, Apache License 2.0
|
|
*/(function(R){if(typeof exports=="object"&&typeof module!="undefined")module.exports=R();else if(typeof define=="function"&&define.amd)define([],R);else{var A;A=typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:this,A.localforage=R()}})(function(){return function R(A,B,b){function D(S,L){if(!B[S]){if(!A[S]){var h=typeof require=="function"&&require;if(!L&&h)return h(S,!0);if(x)return x(S,!0);var O=new Error("Cannot find module '"+S+"'");throw O.code="MODULE_NOT_FOUND",O}var F=B[S]={exports:{}};A[S][0].call(F.exports,function(z){var C=A[S][1][z];return D(C||z)},F,F.exports,R,A,B,b)}return B[S].exports}for(var x=typeof require=="function"&&require,N=0;N<b.length;N++)D(b[N]);return D}({1:[function(R,A,B){(function(b){"use strict";function D(){z=!0;for(var E,w,P=C.length;P;){for(w=C,C=[],E=-1;++E<P;)w[E]();P=C.length}z=!1}function x(E){C.push(E)!==1||z||N()}var N,S=b.MutationObserver||b.WebKitMutationObserver;if(S){var L=0,h=new S(D),O=b.document.createTextNode("");h.observe(O,{characterData:!0}),N=function(){O.data=L=++L%2}}else if(b.setImmediate||typeof b.MessageChannel=="undefined")N="document"in b&&"onreadystatechange"in b.document.createElement("script")?function(){var E=b.document.createElement("script");E.onreadystatechange=function(){D(),E.onreadystatechange=null,E.parentNode.removeChild(E),E=null},b.document.documentElement.appendChild(E)}:function(){setTimeout(D,0)};else{var F=new b.MessageChannel;F.port1.onmessage=D,N=function(){F.port2.postMessage(0)}}var z,C=[];A.exports=x}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{}],2:[function(R,A,B){"use strict";function b(){}function D(s){if(typeof s!="function")throw new TypeError("resolver must be a function");this.state=J,this.queue=[],this.outcome=void 0,s!==b&&L(this,s)}function x(s,p,y){this.promise=s,typeof p=="function"&&(this.onFulfilled=p,this.callFulfilled=this.otherCallFulfilled),typeof y=="function"&&(this.onRejected=y,this.callRejected=this.otherCallRejected)}function N(s,p,y){E(function(){var m;try{m=p(y)}catch(_){return w.reject(s,_)}m===s?w.reject(s,new TypeError("Cannot resolve promise with itself")):w.resolve(s,m)})}function S(s){var p=s&&s.then;if(s&&typeof s=="object"&&typeof p=="function")return function(){p.apply(s,arguments)}}function L(s,p){function y(T){k||(k=!0,w.reject(s,T))}function m(T){k||(k=!0,w.resolve(s,T))}function _(){p(m,y)}var k=!1,M=h(_);M.status==="error"&&y(M.value)}function h(s,p){var y={};try{y.value=s(p),y.status="success"}catch(m){y.status="error",y.value=m}return y}function O(s){return s instanceof this?s:w.resolve(new this(b),s)}function F(s){var p=new this(b);return w.reject(p,s)}function z(s){function p(V,Y){function Z(X){k[Y]=X,++M!==m||_||(_=!0,w.resolve(q,k))}y.resolve(V).then(Z,function(X){_||(_=!0,w.reject(q,X))})}var y=this;if(Object.prototype.toString.call(s)!=="[object Array]")return this.reject(new TypeError("must be an array"));var m=s.length,_=!1;if(!m)return this.resolve([]);for(var k=new Array(m),M=0,T=-1,q=new this(b);++T<m;)p(s[T],T);return q}function C(s){function p(T){y.resolve(T).then(function(q){_||(_=!0,w.resolve(M,q))},function(q){_||(_=!0,w.reject(M,q))})}var y=this;if(Object.prototype.toString.call(s)!=="[object Array]")return this.reject(new TypeError("must be an array"));var m=s.length,_=!1;if(!m)return this.resolve([]);for(var k=-1,M=new this(b);++k<m;)p(s[k]);return M}var E=R(1),w={},P=["REJECTED"],G=["FULFILLED"],J=["PENDING"];A.exports=B=D,D.prototype.catch=function(s){return this.then(null,s)},D.prototype.then=function(s,p){if(typeof s!="function"&&this.state===G||typeof p!="function"&&this.state===P)return this;var y=new this.constructor(b);if(this.state!==J){var m=this.state===G?s:p;N(y,m,this.outcome)}else this.queue.push(new x(y,s,p));return y},x.prototype.callFulfilled=function(s){w.resolve(this.promise,s)},x.prototype.otherCallFulfilled=function(s){N(this.promise,this.onFulfilled,s)},x.prototype.callRejected=function(s){w.reject(this.promise,s)},x.prototype.otherCallRejected=function(s){N(this.promise,this.onRejected,s)},w.resolve=function(s,p){var y=h(S,p);if(y.status==="error")return w.reject(s,y.value);var m=y.value;if(m)L(s,m);else{s.state=G,s.outcome=p;for(var _=-1,k=s.queue.length;++_<k;)s.queue[_].callFulfilled(p)}return s},w.reject=function(s,p){s.state=P,s.outcome=p;for(var y=-1,m=s.queue.length;++y<m;)s.queue[y].callRejected(p);return s},B.resolve=O,B.reject=F,B.all=z,B.race=C},{1:1}],3:[function(R,A,B){(function(b){"use strict";typeof b.Promise!="function"&&(b.Promise=R(2))}).call(this,typeof global!="undefined"?global:typeof self!="undefined"?self:typeof window!="undefined"?window:{})},{2:2}],4:[function(R,A,B){"use strict";function b(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function D(){try{if(typeof indexedDB!="undefined")return indexedDB;if(typeof webkitIndexedDB!="undefined")return webkitIndexedDB;if(typeof mozIndexedDB!="undefined")return mozIndexedDB;if(typeof OIndexedDB!="undefined")return OIndexedDB;if(typeof msIndexedDB!="undefined")return msIndexedDB}catch(e){}}function x(){try{if(!te)return!1;var e=typeof openDatabase!="undefined"&&/(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!="undefined"&&typeof IDBKeyRange!="undefined"}catch(r){return!1}}function N(){return typeof openDatabase=="function"}function S(){try{return typeof localStorage!="undefined"&&"setItem"in localStorage&&localStorage.setItem}catch(e){return!1}}function L(e,t){e=e||[],t=t||{};try{return new Blob(e,t)}catch(i){if(i.name!=="TypeError")throw i;for(var r=typeof BlobBuilder!="undefined"?BlobBuilder:typeof MSBlobBuilder!="undefined"?MSBlobBuilder:typeof MozBlobBuilder!="undefined"?MozBlobBuilder:WebKitBlobBuilder,n=new r,o=0;o<e.length;o+=1)n.append(e[o]);return n.getBlob(t.type)}}function h(e,t){t&&e.then(function(r){t(null,r)},function(r){t(r)})}function O(e,t,r){typeof t=="function"&&e.then(t),typeof r=="function"&&e.catch(r)}function F(e){for(var t=e.length,r=new ArrayBuffer(t),n=new Uint8Array(r),o=0;o<t;o++)n[o]=e.charCodeAt(o);return r}function z(e){return new v(function(t){var r=e.transaction(ne,"readwrite"),n=L([""]);r.objectStore(ne).put(n,"key"),r.onabort=function(o){o.preventDefault(),o.stopPropagation(),t(!1)},r.oncomplete=function(){var o=navigator.userAgent.match(/Chrome\/(\d+)/),i=navigator.userAgent.match(/Edge\//);t(i||!o||parseInt(o[1],10)>=43)}}).catch(function(){return!1})}function C(e){return typeof re=="boolean"?v.resolve(re):z(e).then(function(t){return re=t})}function E(e){var t=Q[e.name],r={};r.promise=new v(function(n){r.resolve=n}),t.deferredOperations.push(r),t.dbReady?t.dbReady=t.dbReady.then(function(){return r.promise}):t.dbReady=r.promise}function w(e){var t=Q[e.name],r=t.deferredOperations.pop();r&&r.resolve()}function P(e,t){return new v(function(r,n){if(e.db){if(!t)return r(e.db);E(e),e.db.close()}var o=[e.name];t&&o.push(e.version);var i=te.open.apply(te,o);t&&(i.onupgradeneeded=function(a){var u=i.result;try{u.createObjectStore(e.storeName),a.oldVersion<=1&&u.createObjectStore(ne)}catch(c){if(c.name!=="ConstraintError")throw c;console.warn('The database "'+e.name+'" has been upgraded from version '+a.oldVersion+" to version "+a.newVersion+', but the storage "'+e.storeName+'" already exists.')}}),i.onerror=function(a){a.preventDefault(),n(i.error)},i.onsuccess=function(){r(i.result),w(e)}})}function G(e){return P(e,!1)}function J(e){return P(e,!0)}function s(e,t){if(!e.db)return!0;var r=!e.db.objectStoreNames.contains(e.storeName),n=e.version<e.db.version,o=e.version>e.db.version;if(n&&(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),o||r){if(r){var i=e.db.version+1;i>e.version&&(e.version=i)}return!0}return!1}function p(e){return new v(function(t,r){var n=new FileReader;n.onerror=r,n.onloadend=function(o){var i=btoa(o.target.result||"");t({__local_forage_encoded_blob:!0,data:i,type:e.type})},n.readAsBinaryString(e)})}function y(e){var t=F(atob(e.data));return L([t],{type:e.type})}function m(e){return e&&e.__local_forage_encoded_blob}function _(e){var t=this,r=t._initReady().then(function(){var n=Q[t._dbInfo.name];if(n&&n.dbReady)return n.dbReady});return O(r,e,e),r}function k(e){function t(){return v.resolve()}var r=this,n={db:null};if(e)for(var o in e)n[o]=e[o];Q||(Q={});var i=Q[n.name];i||(i={forages:[],db:null,dbReady:null,deferredOperations:[]},Q[n.name]=i),i.forages.push(r),r._initReady||(r._initReady=r.ready,r.ready=_);for(var a=[],u=0;u<i.forages.length;u++){var c=i.forages[u];c!==r&&a.push(c._initReady().catch(t))}var f=i.forages.slice(0);return v.all(a).then(function(){return n.db=i.db,G(n)}).then(function(l){return n.db=l,s(n,r._defaultConfig.version)?J(n):l}).then(function(l){n.db=i.db=l,r._dbInfo=n;for(var d=0;d<f.length;d++){var g=f[d];g!==r&&(g._dbInfo.db=n.db,g._dbInfo.version=n.version)}})}function M(e,t){var r=this;typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e));var n=new v(function(o,i){r.ready().then(function(){var a=r._dbInfo,u=a.db.transaction(a.storeName,"readonly").objectStore(a.storeName),c=u.get(e);c.onsuccess=function(){var f=c.result;f===void 0&&(f=null),m(f)&&(f=y(f)),o(f)},c.onerror=function(){i(c.error)}}).catch(i)});return h(n,t),n}function T(e,t){var r=this,n=new v(function(o,i){r.ready().then(function(){var a=r._dbInfo,u=a.db.transaction(a.storeName,"readonly").objectStore(a.storeName),c=u.openCursor(),f=1;c.onsuccess=function(){var l=c.result;if(l){var d=l.value;m(d)&&(d=y(d));var g=e(d,l.key,f++);g!==void 0?o(g):l.continue()}else o()},c.onerror=function(){i(c.error)}}).catch(i)});return h(n,t),n}function q(e,t,r){var n=this;typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e));var o=new v(function(i,a){var u;n.ready().then(function(){return u=n._dbInfo,Ke.call(t)==="[object Blob]"?C(u.db).then(function(c){return c?t:p(t)}):t}).then(function(c){var f=u.db.transaction(u.storeName,"readwrite"),l=f.objectStore(u.storeName),d=l.put(c,e);c===null&&(c=void 0),f.oncomplete=function(){c===void 0&&(c=null),i(c)},f.onabort=f.onerror=function(){var g=d.error?d.error:d.transaction.error;a(g)}}).catch(a)});return h(o,r),o}function V(e,t){var r=this;typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e));var n=new v(function(o,i){r.ready().then(function(){var a=r._dbInfo,u=a.db.transaction(a.storeName,"readwrite"),c=u.objectStore(a.storeName),f=c.delete(e);u.oncomplete=function(){o()},u.onerror=function(){i(f.error)},u.onabort=function(){var l=f.error?f.error:f.transaction.error;i(l)}}).catch(i)});return h(n,t),n}function Y(e){var t=this,r=new v(function(n,o){t.ready().then(function(){var i=t._dbInfo,a=i.db.transaction(i.storeName,"readwrite"),u=a.objectStore(i.storeName),c=u.clear();a.oncomplete=function(){n()},a.onabort=a.onerror=function(){var f=c.error?c.error:c.transaction.error;o(f)}}).catch(o)});return h(r,e),r}function Z(e){var t=this,r=new v(function(n,o){t.ready().then(function(){var i=t._dbInfo,a=i.db.transaction(i.storeName,"readonly").objectStore(i.storeName),u=a.count();u.onsuccess=function(){n(u.result)},u.onerror=function(){o(u.error)}}).catch(o)});return h(r,e),r}function X(e,t){var r=this,n=new v(function(o,i){return e<0?void o(null):void r.ready().then(function(){var a=r._dbInfo,u=a.db.transaction(a.storeName,"readonly").objectStore(a.storeName),c=!1,f=u.openCursor();f.onsuccess=function(){var l=f.result;return l?void(e===0||c?o(l.key):(c=!0,l.advance(e))):void o(null)},f.onerror=function(){i(f.error)}}).catch(i)});return h(n,t),n}function De(e){var t=this,r=new v(function(n,o){t.ready().then(function(){var i=t._dbInfo,a=i.db.transaction(i.storeName,"readonly").objectStore(i.storeName),u=a.openCursor(),c=[];u.onsuccess=function(){var f=u.result;return f?(c.push(f.key),void f.continue()):void n(c)},u.onerror=function(){o(u.error)}}).catch(o)});return h(r,e),r}function se(e){var t,r,n,o,i,a=.75*e.length,u=e.length,c=0;e[e.length-1]==="="&&(a--,e[e.length-2]==="="&&a--);var f=new ArrayBuffer(a),l=new Uint8Array(f);for(t=0;t<u;t+=4)r=U.indexOf(e[t]),n=U.indexOf(e[t+1]),o=U.indexOf(e[t+2]),i=U.indexOf(e[t+3]),l[c++]=r<<2|n>>4,l[c++]=(15&n)<<4|o>>2,l[c++]=(3&o)<<6|63&i;return f}function $(e){var t,r=new Uint8Array(e),n="";for(t=0;t<r.length;t+=3)n+=U[r[t]>>2],n+=U[(3&r[t])<<4|r[t+1]>>4],n+=U[(15&r[t+1])<<2|r[t+2]>>6],n+=U[63&r[t+2]];return r.length%3==2?n=n.substring(0,n.length-1)+"=":r.length%3==1&&(n=n.substring(0,n.length-2)+"=="),n}function Ne(e,t){var r="";if(e&&(r=Ie.call(e)),e&&(r==="[object ArrayBuffer]"||e.buffer&&Ie.call(e.buffer)==="[object ArrayBuffer]")){var n,o=K;e instanceof ArrayBuffer?(n=e,o+=ie):(n=e.buffer,r==="[object Int8Array]"?o+=he:r==="[object Uint8Array]"?o+=ye:r==="[object Uint8ClampedArray]"?o+=pe:r==="[object Int16Array]"?o+=ge:r==="[object Uint16Array]"?o+=me:r==="[object Int32Array]"?o+=be:r==="[object Uint32Array]"?o+=we:r==="[object Float32Array]"?o+=_e:r==="[object Float64Array]"?o+=Se:t(new Error("Failed to get type for BinaryArray"))),t(o+$(n))}else if(r==="[object Blob]"){var i=new FileReader;i.onload=function(){var a=Ye+e.type+"~"+$(this.result);t(K+ue+a)},i.readAsArrayBuffer(e)}else try{t(JSON.stringify(e))}catch(a){console.error("Couldn't convert value into a JSON string: ",e),t(null,a)}}function Oe(e){if(e.substring(0,oe)!==K)return JSON.parse(e);var t,r=e.substring(Ee),n=e.substring(oe,Ee);if(n===ue&&ve.test(r)){var o=r.match(ve);t=o[1],r=r.substring(o[0].length)}var i=se(r);switch(n){case ie:return i;case ue:return L([i],{type:t});case he:return new Int8Array(i);case ye:return new Uint8Array(i);case pe:return new Uint8ClampedArray(i);case ge:return new Int16Array(i);case me:return new Uint16Array(i);case be:return new Int32Array(i);case we:return new Uint32Array(i);case _e:return new Float32Array(i);case Se:return new Float64Array(i);default:throw new Error("Unkown type: "+n)}}function ke(e){var t=this,r={db:null};if(e)for(var n in e)r[n]=typeof e[n]!="string"?e[n].toString():e[n];var o=new v(function(i,a){try{r.db=openDatabase(r.name,String(r.version),r.description,r.size)}catch(u){return a(u)}r.db.transaction(function(u){u.executeSql("CREATE TABLE IF NOT EXISTS "+r.storeName+" (id INTEGER PRIMARY KEY, key unique, value)",[],function(){t._dbInfo=r,i()},function(c,f){a(f)})})});return r.serializer=ae,o}function Be(e,t){var r=this;typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e));var n=new v(function(o,i){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(u){u.executeSql("SELECT * FROM "+a.storeName+" WHERE key = ? LIMIT 1",[e],function(c,f){var l=f.rows.length?f.rows.item(0).value:null;l&&(l=a.serializer.deserialize(l)),o(l)},function(c,f){i(f)})})}).catch(i)});return h(n,t),n}function Re(e,t){var r=this,n=new v(function(o,i){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(u){u.executeSql("SELECT * FROM "+a.storeName,[],function(c,f){for(var l=f.rows,d=l.length,g=0;g<d;g++){var W=l.item(g),I=W.value;if(I&&(I=a.serializer.deserialize(I)),I=e(I,W.key,g+1),I!==void 0)return void o(I)}o()},function(c,f){i(f)})})}).catch(i)});return h(n,t),n}function le(e,t,r,n){var o=this;typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e));var i=new v(function(a,u){o.ready().then(function(){t===void 0&&(t=null);var c=t,f=o._dbInfo;f.serializer.serialize(t,function(l,d){d?u(d):f.db.transaction(function(g){g.executeSql("INSERT OR REPLACE INTO "+f.storeName+" (key, value) VALUES (?, ?)",[e,l],function(){a(c)},function(W,I){u(I)})},function(g){if(g.code===g.QUOTA_ERR){if(n>0)return void a(le.apply(o,[e,c,r,n-1]));u(g)}})})}).catch(u)});return h(i,r),i}function xe(e,t,r){return le.apply(this,[e,t,r,1])}function Ce(e,t){var r=this;typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e));var n=new v(function(o,i){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(u){u.executeSql("DELETE FROM "+a.storeName+" WHERE key = ?",[e],function(){o()},function(c,f){i(f)})})}).catch(i)});return h(n,t),n}function je(e){var t=this,r=new v(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(a){a.executeSql("DELETE FROM "+i.storeName,[],function(){n()},function(u,c){o(c)})})}).catch(o)});return h(r,e),r}function Le(e){var t=this,r=new v(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(a){a.executeSql("SELECT COUNT(key) as c FROM "+i.storeName,[],function(u,c){var f=c.rows.item(0).c;n(f)},function(u,c){o(c)})})}).catch(o)});return h(r,e),r}function Te(e,t){var r=this,n=new v(function(o,i){r.ready().then(function(){var a=r._dbInfo;a.db.transaction(function(u){u.executeSql("SELECT key FROM "+a.storeName+" WHERE id = ? LIMIT 1",[e+1],function(c,f){var l=f.rows.length?f.rows.item(0).key:null;o(l)},function(c,f){i(f)})})}).catch(i)});return h(n,t),n}function Fe(e){var t=this,r=new v(function(n,o){t.ready().then(function(){var i=t._dbInfo;i.db.transaction(function(a){a.executeSql("SELECT key FROM "+i.storeName,[],function(u,c){for(var f=[],l=0;l<c.rows.length;l++)f.push(c.rows.item(l).key);n(f)},function(u,c){o(c)})})}).catch(o)});return h(r,e),r}function ze(e){var t=this,r={};if(e)for(var n in e)r[n]=e[n];return r.keyPrefix=r.name+"/",r.storeName!==t._defaultConfig.storeName&&(r.keyPrefix+=r.storeName+"/"),t._dbInfo=r,r.serializer=ae,v.resolve()}function Me(e){var t=this,r=t.ready().then(function(){for(var n=t._dbInfo.keyPrefix,o=localStorage.length-1;o>=0;o--){var i=localStorage.key(o);i.indexOf(n)===0&&localStorage.removeItem(i)}});return h(r,e),r}function Pe(e,t){var r=this;typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e));var n=r.ready().then(function(){var o=r._dbInfo,i=localStorage.getItem(o.keyPrefix+e);return i&&(i=o.serializer.deserialize(i)),i});return h(n,t),n}function qe(e,t){var r=this,n=r.ready().then(function(){for(var o=r._dbInfo,i=o.keyPrefix,a=i.length,u=localStorage.length,c=1,f=0;f<u;f++){var l=localStorage.key(f);if(l.indexOf(i)===0){var d=localStorage.getItem(l);if(d&&(d=o.serializer.deserialize(d)),d=e(d,l.substring(a),c++),d!==void 0)return d}}});return h(n,t),n}function Ue(e,t){var r=this,n=r.ready().then(function(){var o,i=r._dbInfo;try{o=localStorage.key(e)}catch(a){o=null}return o&&(o=o.substring(i.keyPrefix.length)),o});return h(n,t),n}function We(e){var t=this,r=t.ready().then(function(){for(var n=t._dbInfo,o=localStorage.length,i=[],a=0;a<o;a++)localStorage.key(a).indexOf(n.keyPrefix)===0&&i.push(localStorage.key(a).substring(n.keyPrefix.length));return i});return h(r,e),r}function Qe(e){var t=this,r=t.keys().then(function(n){return n.length});return h(r,e),r}function Ge(e,t){var r=this;typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e));var n=r.ready().then(function(){var o=r._dbInfo;localStorage.removeItem(o.keyPrefix+e)});return h(n,t),n}function Xe(e,t,r){var n=this;typeof e!="string"&&(console.warn(e+" used as a key, but it is not a string."),e=String(e));var o=n.ready().then(function(){t===void 0&&(t=null);var i=t;return new v(function(a,u){var c=n._dbInfo;c.serializer.serialize(t,function(f,l){if(l)u(l);else try{localStorage.setItem(c.keyPrefix+e,f),a(i)}catch(d){d.name!=="QuotaExceededError"&&d.name!=="NS_ERROR_DOM_QUOTA_REACHED"||u(d),u(d)}})})});return h(o,r),o}function He(e,t){e[t]=function(){var r=arguments;return e.ready().then(function(){return e[t].apply(e,r)})}}function ee(){for(var e=1;e<arguments.length;e++){var t=arguments[e];if(t)for(var r in t)t.hasOwnProperty(r)&&(Ae(t[r])?arguments[0][r]=t[r].slice():arguments[0][r]=t[r])}return arguments[0]}function de(e){for(var t in j)if(j.hasOwnProperty(t)&&j[t]===e)return!0;return!1}var Je=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},te=D();typeof Promise=="undefined"&&R(3);var re,Q,v=Promise,ne="local-forage-detect-blob-support",Ke=Object.prototype.toString,Ve={_driver:"asyncStorage",_initStorage:k,iterate:T,getItem:M,setItem:q,removeItem:V,clear:Y,length:Z,key:X,keys:De},U="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",Ye="~~local_forage_type~",ve=/^~~local_forage_type~([^~]+)~/,K="__lfsc__:",oe=K.length,ie="arbf",ue="blob",he="si08",ye="ui08",pe="uic8",ge="si16",be="si32",me="ur16",we="ui32",_e="fl32",Se="fl64",Ee=oe+ie.length,Ie=Object.prototype.toString,ae={serialize:Ne,deserialize:Oe,stringToBuffer:se,bufferToString:$},Ze={_driver:"webSQLStorage",_initStorage:ke,iterate:Re,getItem:Be,setItem:xe,removeItem:Ce,clear:je,length:Le,key:Te,keys:Fe},$e={_driver:"localStorageWrapper",_initStorage:ze,iterate:qe,getItem:Pe,setItem:Xe,removeItem:Ge,clear:Me,length:Qe,key:Ue,keys:We},ce={},j={INDEXEDDB:"asyncStorage",LOCALSTORAGE:"localStorageWrapper",WEBSQL:"webSQLStorage"},et=[j.INDEXEDDB,j.WEBSQL,j.LOCALSTORAGE],fe=["clear","getItem","iterate","key","keys","length","removeItem","setItem"],tt={description:"",driver:et.slice(),name:"localforage",size:4980736,storeName:"keyvaluepairs",version:1},H={};H[j.INDEXEDDB]=x(),H[j.WEBSQL]=N(),H[j.LOCALSTORAGE]=S();var Ae=Array.isArray||function(e){return Object.prototype.toString.call(e)==="[object Array]"},rt=function(){function e(t){b(this,e),this.INDEXEDDB=j.INDEXEDDB,this.LOCALSTORAGE=j.LOCALSTORAGE,this.WEBSQL=j.WEBSQL,this._defaultConfig=ee({},tt),this._config=ee({},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(t){if((typeof t=="undefined"?"undefined":Je(t))==="object"){if(this._ready)return new Error("Can't call config() after localforage has been used.");for(var r in t){if(r==="storeName"&&(t[r]=t[r].replace(/\W/g,"_")),r==="version"&&typeof t[r]!="number")return new Error("Database version must be a number.");this._config[r]=t[r]}return!("driver"in t&&t.driver)||this.setDriver(this._config.driver)}return typeof t=="string"?this._config[t]:this._config},e.prototype.defineDriver=function(t,r,n){var o=new v(function(i,a){try{var u=t._driver,c=new Error("Custom driver not compliant; see https://mozilla.github.io/localForage/#definedriver"),f=new Error("Custom driver name already in use: "+t._driver);if(!t._driver)return void a(c);if(de(t._driver))return void a(f);for(var l=fe.concat("_initStorage"),d=0;d<l.length;d++){var g=l[d];if(!g||!t[g]||typeof t[g]!="function")return void a(c)}var W=v.resolve(!0);"_support"in t&&(W=t._support&&typeof t._support=="function"?t._support():v.resolve(!!t._support)),W.then(function(I){H[u]=I,ce[u]=t,i()},a)}catch(I){a(I)}});return O(o,r,n),o},e.prototype.driver=function(){return this._driver||null},e.prototype.getDriver=function(t,r,n){var o=this,i=v.resolve().then(function(){if(!de(t)){if(ce[t])return ce[t];throw new Error("Driver not found.")}switch(t){case o.INDEXEDDB:return Ve;case o.LOCALSTORAGE:return $e;case o.WEBSQL:return Ze}});return O(i,r,n),i},e.prototype.getSerializer=function(t){var r=v.resolve(ae);return O(r,t),r},e.prototype.ready=function(t){var r=this,n=r._driverSet.then(function(){return r._ready===null&&(r._ready=r._initDriver()),r._ready});return O(n,t,t),n},e.prototype.setDriver=function(t,r,n){function o(){u._config.driver=u.driver()}function i(l){return u._extend(l),o(),u._ready=u._initStorage(u._config),u._ready}function a(l){return function(){function d(){for(;g<l.length;){var W=l[g];return g++,u._dbInfo=null,u._ready=null,u.getDriver(W).then(i).catch(d)}o();var I=new Error("No available storage method found.");return u._driverSet=v.reject(I),u._driverSet}var g=0;return d()}}var u=this;Ae(t)||(t=[t]);var c=this._getSupportedDrivers(t),f=this._driverSet!==null?this._driverSet.catch(function(){return v.resolve()}):v.resolve();return this._driverSet=f.then(function(){var l=c[0];return u._dbInfo=null,u._ready=null,u.getDriver(l).then(function(d){u._driver=d._driver,o(),u._wrapLibraryMethodsWithReady(),u._initDriver=a(c)})}).catch(function(){o();var l=new Error("No available storage method found.");return u._driverSet=v.reject(l),u._driverSet}),O(this._driverSet,r,n),this._driverSet},e.prototype.supports=function(t){return!!H[t]},e.prototype._extend=function(t){ee(this,t)},e.prototype._getSupportedDrivers=function(t){for(var r=[],n=0,o=t.length;n<o;n++){var i=t[n];this.supports(i)&&r.push(i)}return r},e.prototype._wrapLibraryMethodsWithReady=function(){for(var t=0;t<fe.length;t++)He(this,fe[t])},e.prototype.createInstance=function(t){return new e(t)},e}(),nt=new rt;A.exports=nt},{3:3}]},{},[4])(4)});
|