/* esm.sh - idb@7.1.1/build/wrap-idb-value */
var I=(e,n)=>n.some(r=>e instanceof r),m,D;function h(){return m||(m=[IDBDatabase,IDBObjectStore,IDBIndex,IDBCursor,IDBTransaction])}function B(){return D||(D=[IDBCursor.prototype.advance,IDBCursor.prototype.continue,IDBCursor.prototype.continuePrimaryKey])}var b=new WeakMap,f=new WeakMap,y=new WeakMap,a=new WeakMap,d=new WeakMap;function w(e){let n=new Promise((r,o)=>{let s=()=>{e.removeEventListener("success",i),e.removeEventListener("error",t)},i=()=>{r(c(e.result)),s()},t=()=>{o(e.error),s()};e.addEventListener("success",i),e.addEventListener("error",t)});return n.then(r=>{r instanceof IDBCursor&&b.set(r,e)}).catch(()=>{}),d.set(n,e),n}function E(e){if(f.has(e))return;let n=new Promise((r,o)=>{let s=()=>{e.removeEventListener("complete",i),e.removeEventListener("error",t),e.removeEventListener("abort",t)},i=()=>{r(),s()},t=()=>{o(e.error||new DOMException("AbortError","AbortError")),s()};e.addEventListener("complete",i),e.addEventListener("error",t),e.addEventListener("abort",t)});f.set(e,n)}var p={get(e,n,r){if(e instanceof IDBTransaction){if(n==="done")return f.get(e);if(n==="objectStoreNames")return e.objectStoreNames||y.get(e);if(n==="store")return r.objectStoreNames[1]?void 0:r.objectStore(r.objectStoreNames[0])}return c(e[n])},set(e,n,r){return e[n]=r,!0},has(e,n){return e instanceof IDBTransaction&&(n==="done"||n==="store")?!0:n in e}};function L(e){p=e(p)}function M(e){return e===IDBDatabase.prototype.transaction&&!("objectStoreNames"in IDBTransaction.prototype)?function(n,...r){let o=e.call(u(this),n,...r);return y.set(o,n.sort?n.sort():[n]),c(o)}:B().includes(e)?function(...n){return e.apply(u(this),n),c(b.get(this))}:function(...n){return c(e.apply(u(this),n))}}function T(e){return typeof e=="function"?M(e):(e instanceof IDBTransaction&&E(e),I(e,h())?new Proxy(e,p):e)}function c(e){if(e instanceof IDBRequest)return w(e);if(a.has(e))return a.get(e);let n=T(e);return n!==e&&(a.set(e,n),d.set(n,e)),n}var u=e=>d.get(e);export{d as a,I as i,L as r,u,c as w};
//# sourceMappingURL=wrap-idb-value.mjs.map