vendors~report_log~save_log.4f48e20a6aa09ee73148.js 23 KB

1
  1. (window.webpackJsonp=window.webpackJsonp||[]).push([[0],[,,,,,,,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return p}));var r=n(19),o=n(2),a=n(0),i=function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function u(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))},u=function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}},c=1,s="logan_web_db",l="logan_detail_table",f="logReportName",d="logCreateTime",h="log_day_table",p="logDay",m=7*o.a,b=1*o.a,v=function(){function e(e){var t;this.DB=new r.CustomDB({dbName:e||s,dbVersion:c,tables:(t={},t[l]={indexList:[{indexName:f,unique:!1},{indexName:d,unique:!1}]},t[h]={primaryKey:p},t)})}return e.prototype.logReportNameFormatter=function(e,t){return e+"_"+t},e.prototype.logReportNameParser=function(e){var t=e.split("_");return{logDay:t[0],pageIndex:+t[1]}},e.prototype.getLogDayInfo=function(e){return i(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.DB.getItem(h,e)];case 1:return[2,t.sent()]}}))}))},e.prototype.getLogDaysInfo=function(e,t){return i(this,void 0,void 0,(function(){var n;return u(this,(function(r){switch(r.label){case 0:return e!==t?[3,2]:[4,this.DB.getItem(h,e)];case 1:return[2,(n=r.sent())?[n]:[]];case 2:return[4,this.DB.getItemsInRange({tableName:h,indexRange:{indexName:p,lowerIndex:e,upperIndex:t,lowerExclusive:!1,upperExclusive:!1}})];case 3:return[2,r.sent()]}}))}))},e.prototype.getLogsByReportName=function(e){return i(this,void 0,void 0,(function(){return u(this,(function(t){switch(t.label){case 0:return[4,this.DB.getItemsInRange({tableName:l,indexRange:{indexName:f,onlyIndex:e}})];case 1:return[2,t.sent()]}}))}))},e.prototype.addLog=function(e){return i(this,void 0,void 0,(function(){var t,n,r,i,c,s,v,y,g,w,x,I,N,D,k;return u(this,(function(u){switch(u.label){case 0:return t=Object(o.g)(e),n=new Date,r=Object(o.c)(n),[4,this.getLogDayInfo(r)];case 1:if((i=u.sent()||((N={})[p]=r,N.totalSize=0,N.reportPagesInfo={pageSizes:[0]},N)).totalSize+t>m)throw new Error(a.b.EXCEED_LOG_SIZE_LIMIT);return c=i.reportPagesInfo.pageSizes,s=c.length-1,v=c[s],y=v>0&&v+t>b,E=c.slice(),y?E.push(t):E[s]+=t,g=E,(D={})[f]=this.logReportNameFormatter(r,y?s+1:s),D[d]=+n,D.logSize=t,D.logString=e,w=D,(k={})[p]=r,k.totalSize=i.totalSize+t,k.reportPagesInfo={pageSizes:g},x=k,I=6048e5-(+new Date-Object(o.e)(new Date)),[4,this.DB.addItems([{tableName:l,item:w,itemDuration:I},{tableName:h,item:x,itemDuration:I}])];case 2:return u.sent(),[2]}var E}))}))},e.idbIsSupported=r.idbIsSupported,e.deleteDB=r.deleteDB,e}();t.b=v},,,function(e,t,n){"use strict";function r(e){return!isNaN(e)&&e>=0}Object.defineProperty(t,"__esModule",{value:!0}),t.ParamCheckerEnum={NonNegativeInteger:{rule:r,desc:"needs to be a non-negative integer"},NotNullObject:{rule:function(e){return e&&"object"==typeof e},desc:"needs to be a not-null object"},String:{rule:function(e){return"string"==typeof e},desc:"needs to be a string"},Array:{rule:function(e){return e instanceof Array},desc:"needs to be an Array"},Boolean:{rule:function(e){return"boolean"==typeof e},desc:"needs to be a boolean"}},t.isNonNegativeInteger=r,t.optionWithBackup=function(e,t){return void 0!==e?e:t},t.paramChecker=function(e,t,n,r){var o=n+" "+t.desc;if(r){if(void 0!==e&&!t.rule(e))throw new Error(o+" if defined")}else if(!t.rule(e))throw new Error(o)},t.deduplicateList=function(e){return e.reduce((function(e,t){return e.indexOf(t)<0?e.concat(t):e}),[])}},,,function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function u(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(20),u=n(21),c=n(16),s=1,l=!0;function f(e){if(c.paramChecker(e,c.ParamCheckerEnum.NotNullObject,"tableIndexRange",!l),c.paramChecker(e.tableName,c.ParamCheckerEnum.String,"tableIndexRange's",!l),c.paramChecker(e.indexRange,c.ParamCheckerEnum.NotNullObject,"tableIndexRange's indexRange",l),e.indexRange){var t=e.indexRange,n=t.indexName,r=t.onlyIndex,o=t.lowerIndex,a=t.upperIndex,i=t.lowerExclusive,u=t.upperExclusive;if(c.paramChecker(n,c.ParamCheckerEnum.String,"indexRange's indexName",!l),void 0===r&&void 0===o&&void 0===a)throw new Error("indexRange should have bounds or value for the index");if(void 0!==o&&void 0!==a&&o>=a)throw new Error("lowerIndex should be less than upperIndex");o&&a&&c.paramChecker(i,c.ParamCheckerEnum.Boolean,"indexRange's lowerExclusive",l),c.paramChecker(u,c.ParamCheckerEnum.Boolean,"indexRange's upperExclusive",l)}}function d(){try{return i.default(),!0}catch(e){return!1}}t.idbIsSupported=d;var h=function(){function e(e){i.default(),function(e){c.paramChecker(e,c.ParamCheckerEnum.NotNullObject,"dbConfig",!l),c.paramChecker(e.dbName,c.ParamCheckerEnum.String,"dbName",!l),c.paramChecker(e.dbVersion,c.ParamCheckerEnum.NonNegativeInteger,"dbVersion",l),c.paramChecker(e.itemDuration,c.ParamCheckerEnum.NonNegativeInteger,"itemDuration of dbConfig",l),c.paramChecker(e.tables,c.ParamCheckerEnum.NotNullObject,"tables",l),Object.keys(e.tables||{}).forEach((function(t){var n=e.tables[t];c.paramChecker(n.primaryKey,c.ParamCheckerEnum.String,"primaryKey",l),c.paramChecker(n.itemDuration,c.ParamCheckerEnum.NonNegativeInteger,"itemDuration of table",l),c.paramChecker(n.indexList,c.ParamCheckerEnum.Array,"indexList",l),(n.indexList||[]).forEach((function(e){c.paramChecker(e.indexName,c.ParamCheckerEnum.String,"indexName",!l),c.paramChecker(e.unique,c.ParamCheckerEnum.Boolean,"unique",l)}))}))}(e),this.name=e.dbName,this.version=c.optionWithBackup(e.dbVersion,s),this.tableList=Object.keys(e.tables||{}).map((function(t){return r({tableName:t},e.tables[t])})),this.itemDuration=e.itemDuration}return e.prototype.addItems=function(e){return o(this,void 0,void 0,(function(){var t,n,o=this;return a(this,(function(a){switch(a.label){case 0:return t=function(e,t,n){return void 0!==n?n:void 0!==t?t:e},i=e,s=this.tableList,c.paramChecker(i,c.ParamCheckerEnum.Array,"items",!l),i.forEach((function(e){c.paramChecker(e.tableName,c.ParamCheckerEnum.String,"item's tableName",!l),c.paramChecker(e.itemDuration,c.ParamCheckerEnum.NonNegativeInteger,"item's itemDuration",l);var t=s.filter((function(t){return t.tableName===e.tableName}))[0];if(!t)throw new Error("Table "+e.tableName+" does not exist");if(void 0!==t.primaryKey&&Object.getOwnPropertyNames(e.item).indexOf(t.primaryKey)<0)throw new Error("primaryKey is needed for item in table "+e.tableName)})),n=e.map((function(e){var n=o.tableList.filter((function(t){return t.tableName===e.tableName}))[0];return r({itemDuration:t(o.itemDuration,n.itemDuration,e.itemDuration)},e)})),[4,u.default.addItems({name:this.name,tableList:this.tableList,version:this.version},n)];case 1:return a.sent(),[2]}var i,s}))}))},e.prototype.getItem=function(e,t){return o(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return[4,m(this.name,e,t)];case 1:return[2,n.sent()]}}))}))},e.prototype.getItemsInRange=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,b(this.name,e)];case 1:return[2,t.sent()]}}))}))},e.prototype.deleteItemsInRange=function(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return c.paramChecker(e,c.ParamCheckerEnum.Array,"tableIndexRanges",!l),e.forEach((function(e){f(e)})),[4,u.default.deleteItems(this.name,e)];case 1:return t.sent(),[2]}}))}))},e}();function p(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return i.default(),c.paramChecker(e,c.ParamCheckerEnum.String,"dbName",!l),[4,u.default.deleteDB(e)];case 1:return t.sent(),[2]}}))}))}function m(e,t,n){return o(this,void 0,void 0,(function(){return a(this,(function(r){switch(r.label){case 0:return c.paramChecker(e,c.ParamCheckerEnum.String,"dbName",!l),c.paramChecker(t,c.ParamCheckerEnum.String,"tableName",!l),[4,u.default.getItem(e,t,n)];case 1:return[2,r.sent()]}}))}))}function b(e,t){return o(this,void 0,void 0,(function(){return a(this,(function(n){switch(n.label){case 0:return c.paramChecker(e,c.ParamCheckerEnum.String,"dbName",!l),f(t),[4,u.default.getItemsInRange(e,t)];case 1:return[2,n.sent()]}}))}))}t.CustomDB=h,t.deleteDB=p,t.getItemFromDB=m,t.getItemsInRangeFromDB=b,t.default={idbIsSupported:d,CustomDB:h,deleteDB:p,getItemFromDB:m,getItemsInRangeFromDB:b}},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(){if(!window)throw new Error("idb-managed can not run in non-browser environment");for(var e=0,t=["indexedDB","IDBDatabase","IDBObjectStore","IDBTransaction","IDBIndex","IDBCursor","IDBKeyRange","IDBRequest"];e<t.length;e++){var n=t[e];if(!window.hasOwnProperty(n)||!window[n])throw new Error(n+" is not supported in window")}}},function(e,t,n){"use strict";var r=this&&this.__assign||function(){return(r=Object.assign||function(e){for(var t,n=1,r=arguments.length;n<r;n++)for(var o in t=arguments[n])Object.prototype.hasOwnProperty.call(t,o)&&(e[o]=t[o]);return e}).apply(this,arguments)},o=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,a){function i(e){try{c(r.next(e))}catch(e){a(e)}}function u(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(i,u)}c((r=r.apply(e,t||[])).next())}))},a=this&&this.__generator||function(e,t){var n,r,o,a,i={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return a={next:u(0),throw:u(1),return:u(2)},"function"==typeof Symbol&&(a[Symbol.iterator]=function(){return this}),a;function u(a){return function(u){return function(a){if(n)throw new TypeError("Generator is already executing.");for(;i;)try{if(n=1,r&&(o=2&a[0]?r.return:a[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,a[1])).done)return o;switch(r=0,o&&(a=[2&a[0],o.value]),a[0]){case 0:case 1:o=a;break;case 4:return i.label++,{value:a[1],done:!1};case 5:i.label++,r=a[1],a=[0];continue;case 7:a=i.ops.pop(),i.trys.pop();continue;default:if(!(o=(o=i.trys).length>0&&o[o.length-1])&&(6===a[0]||2===a[0])){i=0;continue}if(3===a[0]&&(!o||a[1]>o[0]&&a[1]<o[3])){i.label=a[1];break}if(6===a[0]&&i.label<o[1]){i.label=o[1],o=a;break}if(o&&i.label<o[2]){i.label=o[2],i.ops.push(a);break}o[2]&&i.ops.pop(),i.trys.pop();continue}a=t.call(e,i)}catch(e){a=[6,e],r=0}finally{n=o=0}if(5&a[0])throw a[1];return{value:a[0]?a[1]:void 0,done:!0}}([a,u])}}};Object.defineProperty(t,"__esModule",{value:!0});var i=n(16),u=n(22),c=1,s="IDB_MANAGER_DB",l="IDB_MANAGER_STORE",f="dbName",d="updateTime",h="expireTime";function p(e){var t=e.onlyIndex,n=e.lowerIndex,r=e.upperIndex,o=e.lowerExclusive,a=void 0!==o&&o,i=e.upperExclusive,u=void 0!==i&&i;return void 0!==t?IDBKeyRange.only(t):void 0!==n&&void 0!==r?IDBKeyRange.bound(n,r,a,u):void 0!==n?IDBKeyRange.lowerBound(n,a):IDBKeyRange.upperBound(r,u)}function m(e){var t,n=Date.now();return r(r({},e.item),((t={})[d]=n,t[h]=void 0!==e.itemDuration?e.itemDuration+n:-1,t))}function b(e){return e?e.expireTime>0&&e.expireTime<Date.now()?null:(delete e.updateTime,delete e.expireTime,e):null}function v(e){return o(this,void 0,void 0,(function(){var t,n,r,o,i;return a(this,(function(a){switch(a.label){case 0:return[4,w()];case 1:return[4,I(t=a.sent(),l,e.name)];case 2:return!(n=a.sent())||e.version>n.version?(r=t.transaction(l,"readwrite"),o=r.objectStore(l),i={dbName:e.name,tableList:e.tableList,version:e.version},o.put(m({item:i,tableName:l})),[4,r.complete]):[3,4];case 3:a.sent(),t.close(),a.label=4;case 4:return[2]}}))}))}function y(e){return o(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return[4,w()];case 1:return t=r.sent(),n=t.transaction(l,"readwrite"),n.objectStore(l).delete(e),[4,n.complete];case 2:return r.sent(),t.close(),[2]}}))}))}function g(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,v(e)];case 1:return t.sent(),[4,u.open(e.name,e.version,(function(t){N(t,e.tableList)}))];case 2:return[2,t.sent()]}}))}))}function w(){return o(this,void 0,void 0,(function(){return a(this,(function(e){switch(e.label){case 0:return[4,u.open(s,c,(function(e){!function(e){e.createObjectStore(l,{keyPath:f})}(e)}))];case 1:return[2,e.sent()]}}))}))}function x(e){return o(this,void 0,void 0,(function(){var t,n;return a(this,(function(r){switch(r.label){case 0:return[4,w()];case 1:return[4,I(t=r.sent(),l,e)];case 2:return n=r.sent(),t.close(),n?[4,u.open(n.dbName,n.version,(function(e){N(e,n.tableList||[])}))]:[3,4];case 3:return[2,r.sent()];case 4:return[2,null]}}))}))}function I(e,t,n){return o(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:return e.objectStoreNames.contains(t)?(r=e.transaction(t,"readonly"),[4,r.objectStore(t).get(n)]):[3,2];case 1:return[2,b(o.sent())];case 2:return[2,null]}}))}))}function N(e,t){try{t.forEach((function(t){if(e.objectStoreNames.contains(t.tableName)){var n=e.transaction(t.tableName).objectStore(t.tableName);(t.indexList||[]).forEach((function(e){n.indexNames.contains(e.indexName)||n.createIndex(e.indexName,e.indexName,{unique:e.unique})}))}else{var o=t.primaryKey||"id",a=e.createObjectStore(t.tableName,r({keyPath:o},"id"===o?{autoIncrement:!0}:{}));a.createIndex(o,o,{unique:!0}),(t.indexList||[]).forEach((function(e){a.createIndex(e.indexName,e.indexName,{unique:e.unique})})),a.createIndex(d,d,{unique:!1}),a.createIndex(h,h,{unique:!1})}}))}catch(t){e.close()}}function D(e,t,n){return o(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:return o.trys.push([0,2,7,8]),[4,n()];case 1:return o.sent(),[3,8];case 2:r=o.sent();try{e.abort()}catch(e){}o.label=3;case 3:return o.trys.push([3,5,,6]),[4,e.complete];case 4:return o.sent(),[3,6];case 5:throw o.sent(),r;case 6:return[3,8];case 7:return t.close(),[7];case 8:return[2]}}))}))}function k(e,t){return o(this,void 0,void 0,(function(){var n,r,u,c=this;return a(this,(function(s){switch(s.label){case 0:return n=t.filter((function(t){return e.objectStoreNames.contains(t.tableName)})),r=i.deduplicateList(n.map((function(e){return e.tableName}))),[4,D(u=e.transaction(r,"readwrite"),e,(function(){return o(c,void 0,void 0,(function(){var e,t,r,o,i,c,s;return a(this,(function(a){switch(a.label){case 0:e=0,t=n,a.label=1;case 1:return e<t.length?(r=t[e],o=r.tableName,i=r.indexRange,c=u.objectStore(o),i?[3,3]:[4,c.clear()]):[3,8];case 2:return a.sent(),[3,7];case 3:return[4,c.index(i.indexName).openCursor(p(i))];case 4:s=a.sent(),a.label=5;case 5:return s?(c.delete(s.primaryKey),[4,s.continue()]):[3,7];case 6:return s=a.sent(),[3,5];case 7:return e++,[3,1];case 8:return[2]}}))}))}))];case 1:return s.sent(),[2]}}))}))}function E(e,t){return o(this,void 0,void 0,(function(){var n,r,u,c=this;return a(this,(function(s){switch(s.label){case 0:return n=i.deduplicateList(t.map((function(e){return e.tableName}))),[4,S(e.name,n.map((function(e){return{tableName:e,indexRange:{indexName:h,upperIndex:+new Date,upperExclusive:!1}}})))];case 1:return s.sent(),[4,g(e)];case 2:return r=s.sent(),[4,D(u=r.transaction(n,"readwrite"),r,(function(){return o(c,void 0,void 0,(function(){var e,n,r;return a(this,(function(o){switch(o.label){case 0:e=0,n=t,o.label=1;case 1:return e<n.length?(r=n[e],[4,u.objectStore(r.tableName).put(m(r))]):[3,4];case 2:o.sent(),o.label=3;case 3:return e++,[3,1];case 4:return[2]}}))}))}))];case 3:return s.sent(),[2]}}))}))}function _(e,t,n){return o(this,void 0,void 0,(function(){var r;return a(this,(function(o){switch(o.label){case 0:return[4,x(e)];case 1:if(!(r=o.sent()))return[3,7];o.label=2;case 2:return o.trys.push([2,4,5,6]),[4,I(r,t,n)];case 3:return[2,o.sent()];case 4:throw o.sent();case 5:return r.close(),[7];case 6:return[3,8];case 7:return[2,null];case 8:return[2]}}))}))}function C(e,t){return o(this,void 0,void 0,(function(){var n,r,o,i,u,c,s,l,f;return a(this,(function(a){switch(a.label){case 0:return n=t.tableName,r=t.indexRange,[4,x(e)];case 1:if(!(o=a.sent()))return[3,13];a.label=2;case 2:return a.trys.push([2,10,11,12]),i=[],o.objectStoreNames.contains(n)?[3,3]:[3,9];case 3:return u=o.transaction(n,"readonly"),c=u.objectStore(n),r?[3,5]:[4,c.getAll()];case 4:return s=a.sent(),i=(s||[]).map(b).filter((function(e){return null!==e})),[3,9];case 5:return[4,c.index(r.indexName).openCursor(p(r))];case 6:l=a.sent(),a.label=7;case 7:return l?((f=b(l.value))&&i.push(f),[4,l.continue()]):[3,9];case 8:return l=a.sent(),[3,7];case 9:return[2,i];case 10:throw a.sent();case 11:return o.close(),[7];case 12:return[3,14];case 13:return[2,[]];case 14:return[2]}}))}))}function B(e){return o(this,void 0,void 0,(function(){return a(this,(function(t){switch(t.label){case 0:return[4,y(e)];case 1:return t.sent(),[4,u.delete(e)];case 2:return t.sent(),[2]}}))}))}function S(e,t){return o(this,void 0,void 0,(function(){var n;return a(this,(function(r){switch(r.label){case 0:return[4,x(e)];case 1:return(n=r.sent())?[4,k(n,t)]:[3,3];case 2:return r.sent(),[3,4];case 3:case 4:return[2]}}))}))}t.addItems=E,t.getItem=_,t.getItemsInRange=C,t.deleteDB=B,t.deleteItems=S,t.default={addItems:E,getItem:_,getItemsInRange:C,deleteDB:B,deleteItems:S}},function(e,t){function n(e){return Array.prototype.slice.call(e)}function r(e){return new Promise((function(t,n){e.onsuccess=function(){t(e.result)},e.onerror=function(){n(e.error)}}))}function o(e,t,n){var o,a=new Promise((function(a,i){r(o=e[t].apply(e,n)).then(a,i)}));return a.request=o,a}function a(e,t,n){var r=o(e,t,n);return r.then((function(e){if(e)return new f(e,r.request)}))}function i(e,t,n){n.forEach((function(n){Object.defineProperty(e.prototype,n,{get:function(){return this[t][n]},set:function(e){this[t][n]=e}})}))}function u(e,t,n,r){r.forEach((function(r){r in n.prototype&&(e.prototype[r]=function(){return o(this[t],r,arguments)})}))}function c(e,t,n,r){r.forEach((function(r){r in n.prototype&&(e.prototype[r]=function(){return this[t][r].apply(this[t],arguments)})}))}function s(e,t,n,r){r.forEach((function(r){r in n.prototype&&(e.prototype[r]=function(){return a(this[t],r,arguments)})}))}function l(e){this._index=e}function f(e,t){this._cursor=e,this._request=t}function d(e){this._store=e}function h(e){this._tx=e,this.complete=new Promise((function(t,n){e.oncomplete=function(){t()},e.onerror=function(){n(e.error)},e.onabort=function(){n(e.error)}}))}function p(e,t,n){this._db=e,this.oldVersion=t,this.transaction=new h(n)}function m(e){this._db=e}var b;if(d.prototype.createIndex=function(){return new l(this._store.createIndex.apply(this._store,arguments))},d.prototype.index=function(){return new l(this._store.index.apply(this._store,arguments))},h.prototype.objectStore=function(){return new d(this._tx.objectStore.apply(this._tx,arguments))},p.prototype.createObjectStore=function(){return new d(this._db.createObjectStore.apply(this._db,arguments))},m.prototype.transaction=function(){return new h(this._db.transaction.apply(this._db,arguments))},function(){try{return["IDBIndex","IDBCursor","IDBObjectStore","IDBTransaction","IDBDatabase"].forEach((function(e){if(window&&(!window[e]||!window.hasOwnProperty(e)))throw new Error(e)})),!0}catch(e){return!1}}())i(l,"_index",["name","keyPath","multiEntry","unique"]),u(l,"_index",IDBIndex,["get","getKey","getAll","getAllKeys","count"]),s(l,"_index",IDBIndex,["openCursor","openKeyCursor"]),i(f,"_cursor",["direction","key","primaryKey","value"]),u(f,"_cursor",IDBCursor,["update","delete"]),["advance","continue","continuePrimaryKey"].forEach((function(e){e in IDBCursor.prototype&&(f.prototype[e]=function(){var t=this,n=arguments;return Promise.resolve().then((function(){return t._cursor[e].apply(t._cursor,n),r(t._request).then((function(e){if(e)return new f(e,t._request)}))}))})})),i(d,"_store",["name","keyPath","indexNames","autoIncrement"]),u(d,"_store",IDBObjectStore,["put","add","delete","clear","get","getAll","getKey","getAllKeys","count"]),s(d,"_store",IDBObjectStore,["openCursor","openKeyCursor"]),c(d,"_store",IDBObjectStore,["deleteIndex"]),i(h,"_tx",["objectStoreNames","mode"]),c(h,"_tx",IDBTransaction,["abort"]),i(p,"_db",["name","version","objectStoreNames"]),c(p,"_db",IDBDatabase,["deleteObjectStore","close"]),i(m,"_db",["name","version","objectStoreNames"]),c(m,"_db",IDBDatabase,["close"]),["openCursor","openKeyCursor"].forEach((function(e){[d,l].forEach((function(t){e in t.prototype&&(t.prototype[e.replace("open","iterate")]=function(){var t=n(arguments),r=t[t.length-1],o=this._store||this._index,a=o[e].apply(o,t.slice(0,-1));a.onsuccess=function(){r(a.result)}})}))})),[l,d].forEach((function(e){e.prototype.getAll||(e.prototype.getAll=function(e,t){var n=this,r=[];return new Promise((function(o){n.iterateCursor(e,(function(e){e?(r.push(e.value),void 0===t||r.length!=t?e.continue():o(r)):o(r)}))}))})})),b={open:function(e,t,n){var r=o(indexedDB,"open",[e,t]),a=r.request;return a&&(a.onupgradeneeded=function(e){n&&n(new p(a.result,e.oldVersion,a.transaction))}),r.then((function(e){return new m(e)}))},delete:function(e){return o(indexedDB,"deleteDatabase",[e])}};else{var v="indexedDB is not supported";b={open:function(){return Promise.reject(new Error(v))},delete:function(){return Promise.reject(new Error(v))}}}e.exports=b}]]);