function _slicedToArray(e,t){return function _arrayWithHoles(e){if(Array.isArray(e))return e}(e)||function _iterableToArrayLimit(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==r)return;var n,u,o=[],i=!0,a=!1;try{for(r=r.call(e);!(i=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);i=!0);}catch(e){a=!0,u=e}finally{try{i||null==r.return||r.return()}finally{if(a)throw u}}return o}(e,t)||function _unsupportedIterableToArray(e,t){if(!e)return;if("string"==typeof e)return _arrayLikeToArray(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return _arrayLikeToArray(e,t)}(e,t)||function _nonIterableRest(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}import e from"../../safari-14-idb-fix/dist/index.js";function promisifyRequest(e){return new Promise((function(t,r){e.oncomplete=e.onsuccess=function(){return t(e.result)},e.onabort=e.onerror=function(){return r(e.error)}}))}function createStore(t,r){var n=e().then((function(){var e=indexedDB.open(t);return e.onupgradeneeded=function(){return e.result.createObjectStore(r)},promisifyRequest(e)}));return function(e,t){return n.then((function(n){return t(n.transaction(r,e).objectStore(r))}))}}var t;function defaultGetStore(){return t||(t=createStore("keyval-store","keyval")),t}function get(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:defaultGetStore())("readonly",(function(t){return promisifyRequest(t.get(e))}))}function set(e,t){return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:defaultGetStore())("readwrite",(function(r){return r.put(t,e),promisifyRequest(r.transaction)}))}function setMany(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:defaultGetStore())("readwrite",(function(t){return e.forEach((function(e){return t.put(e[1],e[0])})),promisifyRequest(t.transaction)}))}function getMany(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:defaultGetStore())("readonly",(function(t){return Promise.all(e.map((function(e){return promisifyRequest(t.get(e))})))}))}function update(e,t){return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:defaultGetStore())("readwrite",(function(r){return new Promise((function(n,u){r.get(e).onsuccess=function(){try{r.put(t(this.result),e),n(promisifyRequest(r.transaction))}catch(e){u(e)}}}))}))}function del(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:defaultGetStore())("readwrite",(function(t){return t.delete(e),promisifyRequest(t.transaction)}))}function delMany(e){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:defaultGetStore())("readwrite",(function(t){return e.forEach((function(e){return t.delete(e)})),promisifyRequest(t.transaction)}))}function clear(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:defaultGetStore())("readwrite",(function(e){return e.clear(),promisifyRequest(e.transaction)}))}function eachCursor(e,t){return e.openCursor().onsuccess=function(){this.result&&(t(this.result),this.result.continue())},promisifyRequest(e.transaction)}function keys(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:defaultGetStore())("readonly",(function(e){if(e.getAllKeys)return promisifyRequest(e.getAllKeys());var t=[];return eachCursor(e,(function(e){return t.push(e.key)})).then((function(){return t}))}))}function values(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:defaultGetStore())("readonly",(function(e){if(e.getAll)return promisifyRequest(e.getAll());var t=[];return eachCursor(e,(function(e){return t.push(e.value)})).then((function(){return t}))}))}function entries(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:defaultGetStore();return e("readonly",(function(t){if(t.getAll&&t.getAllKeys)return Promise.all([promisifyRequest(t.getAllKeys()),promisifyRequest(t.getAll())]).then((function(e){var t=_slicedToArray(e,2),r=t[0],n=t[1];return r.map((function(e,t){return[e,n[t]]}))}));var r=[];return e("readonly",(function(e){return eachCursor(e,(function(e){return r.push([e.key,e.value])})).then((function(){return r}))}))}))}export{clear,createStore,del,delMany,entries,get,getMany,keys,promisifyRequest,set,setMany,update,values};