define(["exports","./idbcore.js"],function(_exports,_idbcore){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;var databaseInstance,dbName="useractions",dbVersion=2;function getActionDb(){return new Promise(function(resolve,reject){var request;databaseInstance?resolve(databaseInstance):((request=indexedDB.open(dbName,dbVersion)).onerror=reject,request.onblocked=reject,request.onupgradeneeded=function(event){var db=request.result;event.oldVersion<1&&db.createObjectStore(dbName),event.oldVersion<2&&request.transaction.objectStore(dbName).createIndex("Index_ServerId","ServerId")},request.onsuccess=function(event){var db=event.target.result;db.onversionchange=function(){db.close(),databaseInstance=null},resolve(databaseInstance=db)})})}function deleteUserAction(key){return getActionDb().then(function(db){return _idbcore.default.deleteObject(db,key)})}_exports.default={getUserAction:function(key){return getActionDb().then(function(db){return _idbcore.default.getObjectByKey(db,key)})},addUserAction:function(key,val){return getActionDb().then(function(db){return _idbcore.default.addObject(db,key,val)})},deleteUserAction:deleteUserAction,deleteUserActions:function(keys){return Promise.all(keys.map(deleteUserAction))},clearUserActions:function(){return getActionDb().then(function(db){return _idbcore.default.clearObjects(db)})},getByServerId:function(serverId){return getActionDb().then(function(db){return _idbcore.default.getObjectsByIndexKeys(db,"Index_ServerId",serverId)})}}});