@septkit/ui 0.0.88 → 0.0.89

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/dist/dialecte/composables/change-id-window.js +14 -0
  2. package/dist/dialecte/composables/use-live-data.js +154 -31
  3. package/dist/dialecte/create-document-store.js +16 -7
  4. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/dialecte-DHj8__Ch.js +7293 -0
  5. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/helpers-Bfv2XDC-.js +351 -0
  6. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/index.js +6 -0
  7. package/dist/external/.pnpm/{@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/open-connections-D59wm6nb.js → @dialecte_core@0.12.1/node_modules/@dialecte/core/dist/open-connections-ClJo0-Af.js} +2 -2
  8. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/project-key-DD8DyQ8-.js +1751 -0
  9. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/qname-definition-C6GUFWL8.js +56 -0
  10. package/dist/external/.pnpm/{@dialecte_core@0.11.0 → @dialecte_core@0.12.1}/node_modules/@dialecte/core/dist/rolldown-runtime-CYdcPHCu.js +1 -1
  11. package/dist/external/.pnpm/{@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/same-json-value-boJ4pSRe.js → @dialecte_core@0.12.1/node_modules/@dialecte/core/dist/same-json-value-DTtSsGUF.js} +491 -370
  12. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/utils-Q5zsKl3Y.js +2449 -0
  13. package/dist/external/.pnpm/@dialecte_core@0.12.1/node_modules/@dialecte/core/dist/utils.js +2 -0
  14. package/dist/external/.pnpm/@tanstack_virtual-core@3.17.3/node_modules/@tanstack/virtual-core/dist/esm/index.js +627 -0
  15. package/dist/external/.pnpm/@tanstack_virtual-core@3.17.3/node_modules/@tanstack/virtual-core/dist/esm/lazy-measurements.js +31 -0
  16. package/dist/external/.pnpm/@tanstack_virtual-core@3.17.3/node_modules/@tanstack/virtual-core/dist/esm/utils.js +38 -0
  17. package/dist/external/.pnpm/@tanstack_vue-virtual@3.13.31_vue@3.5.39_typescript@5.8.3_/node_modules/@tanstack/vue-virtual/dist/esm/index.js +28 -0
  18. package/dist/external/.pnpm/@vueuse_core@14.3.0_vue@3.5.39_typescript@5.8.3_/node_modules/@vueuse/core/dist/index.js +24 -2
  19. package/dist/index.d.ts +266 -7
  20. package/dist/index.js +7 -1
  21. package/dist/ui.css +1 -1
  22. package/dist/virtual/grid-aria.js +16 -0
  23. package/dist/virtual/grid-navigation.js +84 -0
  24. package/dist/virtual/index.js +6 -0
  25. package/dist/virtual/kept-range.js +32 -0
  26. package/dist/virtual/use-virtual-scroller.js +180 -0
  27. package/dist/virtual/virtual.constants.js +7 -0
  28. package/package.json +6 -4
  29. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/dialecte-Cs_XRP4I.js +0 -4426
  30. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/helpers-D8p0KiJu.js +0 -130
  31. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/index.js +0 -6
  32. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/project-key-sr4wkl2Q.js +0 -1371
  33. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/utils-Cv4oHia0.js +0 -865
  34. package/dist/external/.pnpm/@dialecte_core@0.11.0/node_modules/@dialecte/core/dist/utils.js +0 -2
@@ -1,4426 +0,0 @@
1
- import { W as e } from "./utils-Cv4oHia0.js";
2
- import { n as t, t as n } from "./rolldown-runtime-CYdcPHCu.js";
3
- import { i as r, n as i, r as a, t as o } from "./open-connections-D59wm6nb.js";
4
- import { F as s, G as c, H as l, L as u, M as d, R as f, U as p, W as m, h, j as g, k as _, n as v, t as y, z as b } from "./project-key-sr4wkl2Q.js";
5
- import "./helpers-D8p0KiJu.js";
6
- import { E as x, d as S, f as C, h as ee, i as w, m as te, n as T, p as E, r as ne, t as re, u as ie } from "./same-json-value-boJ4pSRe.js";
7
- //#region node_modules/.pnpm/@dialecte+core@0.11.0/node_modules/@dialecte/core/dist/dialecte-Cs_XRP4I.js
8
- async function ae(e) {
9
- let { store: t, isRunning: n } = e, r = await t.getDocuments();
10
- for (let e of r) e.status === "importing" && (await n?.(e) || (await t.getDocument(e.id))?.status === "importing" && await t.removeDocument(e.id));
11
- }
12
- function D(e) {
13
- let { held: t, registered: n } = e;
14
- return !t || !n || t.status !== "importing" ? !1 : t.id === n.id && t.writeId === n.writeId && t.createdAt === n.createdAt;
15
- }
16
- o(), i();
17
- var O = /* @__PURE__ */ t((/* @__PURE__ */ n(((e, t, n) => {
18
- ((n, r) => {
19
- typeof e == "object" && t !== void 0 ? t.exports = r() : typeof define == "function" && define.amd ? define(r) : (n = typeof globalThis < "u" ? globalThis : n || self).Dexie = r();
20
- })(n, function() {
21
- var e = function(t, n) {
22
- return (e = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array ? function(e, t) {
23
- e.__proto__ = t;
24
- } : function(e, t) {
25
- for (var n in t) Object.prototype.hasOwnProperty.call(t, n) && (e[n] = t[n]);
26
- }))(t, n);
27
- }, t = function() {
28
- return (t = Object.assign || function(e) {
29
- for (var t, n = 1, r = arguments.length; n < r; n++) for (var i in t = arguments[n]) Object.prototype.hasOwnProperty.call(t, i) && (e[i] = t[i]);
30
- return e;
31
- }).apply(this, arguments);
32
- };
33
- function n(e, t, n) {
34
- if (n || arguments.length === 2) for (var r, i = 0, a = t.length; i < a; i++) !r && i in t || ((r ||= Array.prototype.slice.call(t, 0, i))[i] = t[i]);
35
- return e.concat(r || Array.prototype.slice.call(t));
36
- }
37
- var r = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, i = Object.keys, a = Array.isArray;
38
- function o(e, t) {
39
- return typeof t == "object" && i(t).forEach(function(n) {
40
- e[n] = t[n];
41
- }), e;
42
- }
43
- typeof Promise > "u" || r.Promise || (r.Promise = Promise);
44
- var s = Object.getPrototypeOf, c = {}.hasOwnProperty;
45
- function l(e, t) {
46
- return c.call(e, t);
47
- }
48
- function u(e, t) {
49
- typeof t == "function" && (t = t(s(e))), (typeof Reflect > "u" ? i : Reflect.ownKeys)(t).forEach(function(n) {
50
- f(e, n, t[n]);
51
- });
52
- }
53
- var d = Object.defineProperty;
54
- function f(e, t, n, r) {
55
- d(e, t, o(n && l(n, "get") && typeof n.get == "function" ? {
56
- get: n.get,
57
- set: n.set,
58
- configurable: !0
59
- } : {
60
- value: n,
61
- configurable: !0,
62
- writable: !0
63
- }, r));
64
- }
65
- function p(e) {
66
- return { from: function(t) {
67
- return e.prototype = Object.create(t.prototype), f(e.prototype, "constructor", e), { extend: u.bind(null, e.prototype) };
68
- } };
69
- }
70
- var m = Object.getOwnPropertyDescriptor, h = [].slice;
71
- function g(e, t, n) {
72
- return h.call(e, t, n);
73
- }
74
- function _(e, t) {
75
- return t(e);
76
- }
77
- function v(e) {
78
- if (!e) throw Error("Assertion Failed");
79
- }
80
- function y(e) {
81
- r.setImmediate ? setImmediate(e) : setTimeout(e, 0);
82
- }
83
- function b(e, t) {
84
- if (typeof t == "string" && l(e, t)) return e[t];
85
- if (!t) return e;
86
- if (typeof t != "string") {
87
- for (var n = [], r = 0, i = t.length; r < i; ++r) {
88
- var a = b(e, t[r]);
89
- n.push(a);
90
- }
91
- return n;
92
- }
93
- var o, s = t.indexOf(".");
94
- return s === -1 || (o = e[t.substr(0, s)]) == null ? void 0 : b(o, t.substr(s + 1));
95
- }
96
- function x(e, t, n) {
97
- if (e && t !== void 0 && !("isFrozen" in Object && Object.isFrozen(e))) if (typeof t != "string" && "length" in t) {
98
- v(typeof n != "string" && "length" in n);
99
- for (var r = 0, i = t.length; r < i; ++r) x(e, t[r], n[r]);
100
- } else {
101
- var o = t.indexOf(".");
102
- if (o !== -1) {
103
- var s = t.substr(0, o), o = t.substr(o + 1);
104
- if (o === "") n === void 0 ? a(e) && !isNaN(parseInt(s)) ? e.splice(s, 1) : delete e[s] : e[s] = n;
105
- else {
106
- var c = e[s];
107
- if (!c || !l(e, s)) {
108
- if (n === void 0) return;
109
- c = e[s] = {};
110
- }
111
- x(c, o, n);
112
- }
113
- } else n === void 0 ? a(e) && !isNaN(parseInt(t)) ? e.splice(t, 1) : delete e[t] : e[t] = n;
114
- }
115
- }
116
- function S(e) {
117
- var t, n = {};
118
- for (t in e) l(e, t) && (n[t] = e[t]);
119
- return n;
120
- }
121
- var C = [].concat;
122
- function ee(e) {
123
- return C.apply([], e);
124
- }
125
- var w = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(ee([
126
- 8,
127
- 16,
128
- 32,
129
- 64
130
- ].map(function(e) {
131
- return [
132
- "Int",
133
- "Uint",
134
- "Float"
135
- ].map(function(t) {
136
- return t + e + "Array";
137
- });
138
- }))).filter(function(e) {
139
- return r[e];
140
- }), te = new Set(w.map(function(e) {
141
- return r[e];
142
- })), T = null;
143
- function E(e) {
144
- return T = /* @__PURE__ */ new WeakMap(), e = function e(t) {
145
- if (!t || typeof t != "object") return t;
146
- var n = T.get(t);
147
- if (n) return n;
148
- if (a(t)) {
149
- n = [], T.set(t, n);
150
- for (var r = 0, i = t.length; r < i; ++r) n.push(e(t[r]));
151
- } else if (te.has(t.constructor)) n = t;
152
- else {
153
- var o, c = s(t);
154
- for (o in n = c === Object.prototype ? {} : Object.create(c), T.set(t, n), t) l(t, o) && (n[o] = e(t[o]));
155
- }
156
- return n;
157
- }(e), T = null, e;
158
- }
159
- var ne = {}.toString;
160
- function re(e) {
161
- return ne.call(e).slice(8, -1);
162
- }
163
- var ie = typeof Symbol < "u" ? Symbol.iterator : "@@iterator", ae = typeof ie == "symbol" ? function(e) {
164
- var t;
165
- return e != null && (t = e[ie]) && t.apply(e);
166
- } : function() {
167
- return null;
168
- };
169
- function D(e, t) {
170
- t = e.indexOf(t), 0 <= t && e.splice(t, 1);
171
- }
172
- var O = {};
173
- function k(e) {
174
- var t, n, r, i;
175
- if (arguments.length === 1) {
176
- if (a(e)) return e.slice();
177
- if (this === O && typeof e == "string") return [e];
178
- if (i = ae(e)) for (n = []; !(r = i.next()).done;) n.push(r.value);
179
- else {
180
- if (e == null || typeof (t = e.length) != "number") return [e];
181
- for (n = Array(t); t--;) n[t] = e[t];
182
- }
183
- } else for (t = arguments.length, n = Array(t); t--;) n[t] = arguments[t];
184
- return n;
185
- }
186
- var oe = typeof Symbol < "u" ? function(e) {
187
- return e[Symbol.toStringTag] === "AsyncFunction";
188
- } : function() {
189
- return !1;
190
- }, w = [
191
- "Unknown",
192
- "Constraint",
193
- "Data",
194
- "TransactionInactive",
195
- "ReadOnly",
196
- "Version",
197
- "NotFound",
198
- "InvalidState",
199
- "InvalidAccess",
200
- "Abort",
201
- "Timeout",
202
- "QuotaExceeded",
203
- "Syntax",
204
- "DataClone"
205
- ], A = [
206
- "Modify",
207
- "Bulk",
208
- "OpenFailed",
209
- "VersionChange",
210
- "Schema",
211
- "Upgrade",
212
- "InvalidTable",
213
- "MissingAPI",
214
- "NoSuchDatabase",
215
- "InvalidArgument",
216
- "SubTransaction",
217
- "Unsupported",
218
- "Internal",
219
- "DatabaseClosed",
220
- "PrematureCommit",
221
- "ForeignAwait"
222
- ].concat(w), se = {
223
- VersionChanged: "Database version changed by other database connection",
224
- DatabaseClosed: "Database has been closed",
225
- Abort: "Transaction aborted",
226
- TransactionInactive: "Transaction has already completed or failed",
227
- MissingAPI: "IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb"
228
- };
229
- function ce(e, t) {
230
- this.name = e, this.message = t;
231
- }
232
- function le(e, t) {
233
- return e + ". Errors: " + Object.keys(t).map(function(e) {
234
- return t[e].toString();
235
- }).filter(function(e, t, n) {
236
- return n.indexOf(e) === t;
237
- }).join("\n");
238
- }
239
- function ue(e, t, n, r) {
240
- this.failures = t, this.failedKeys = r, this.successCount = n, this.message = le(e, t);
241
- }
242
- function de(e, t) {
243
- this.name = "BulkError", this.failures = Object.keys(t).map(function(e) {
244
- return t[e];
245
- }), this.failuresByPos = t, this.message = le(e, this.failures);
246
- }
247
- p(ce).from(Error).extend({ toString: function() {
248
- return this.name + ": " + this.message;
249
- } }), p(ue).from(ce), p(de).from(ce);
250
- var fe = A.reduce(function(e, t) {
251
- return e[t] = t + "Error", e;
252
- }, {}), pe = ce, j = A.reduce(function(e, t) {
253
- var n = t + "Error";
254
- function r(e, r) {
255
- this.name = n, e ? typeof e == "string" ? (this.message = `${e}${r ? "\n " + r : ""}`, this.inner = r || null) : typeof e == "object" && (this.message = `${e.name} ${e.message}`, this.inner = e) : (this.message = se[t] || n, this.inner = null);
256
- }
257
- return p(r).from(pe), e[t] = r, e;
258
- }, {}), me = (j.Syntax = SyntaxError, j.Type = TypeError, j.Range = RangeError, w.reduce(function(e, t) {
259
- return e[t + "Error"] = j[t], e;
260
- }, {}));
261
- w = A.reduce(function(e, t) {
262
- return [
263
- "Syntax",
264
- "Type",
265
- "Range"
266
- ].indexOf(t) === -1 && (e[t + "Error"] = j[t]), e;
267
- }, {});
268
- function M() {}
269
- function N(e) {
270
- return e;
271
- }
272
- function he(e, t) {
273
- return e == null || e === N ? t : function(n) {
274
- return t(e(n));
275
- };
276
- }
277
- function P(e, t) {
278
- return function() {
279
- e.apply(this, arguments), t.apply(this, arguments);
280
- };
281
- }
282
- function ge(e, t) {
283
- return e === M ? t : function() {
284
- var n = e.apply(this, arguments), r = (n !== void 0 && (arguments[0] = n), this.onsuccess), i = this.onerror, a = (this.onsuccess = null, this.onerror = null, t.apply(this, arguments));
285
- return r && (this.onsuccess = this.onsuccess ? P(r, this.onsuccess) : r), i && (this.onerror = this.onerror ? P(i, this.onerror) : i), a === void 0 ? n : a;
286
- };
287
- }
288
- function _e(e, t) {
289
- return e === M ? t : function() {
290
- e.apply(this, arguments);
291
- var n = this.onsuccess, r = this.onerror;
292
- this.onsuccess = this.onerror = null, t.apply(this, arguments), n && (this.onsuccess = this.onsuccess ? P(n, this.onsuccess) : n), r && (this.onerror = this.onerror ? P(r, this.onerror) : r);
293
- };
294
- }
295
- function ve(e, t) {
296
- return e === M ? t : function() {
297
- var n = e.apply(this, arguments), r = (o(arguments[0], n), this.onsuccess), i = this.onerror, a = (this.onsuccess = null, this.onerror = null, t.apply(this, arguments));
298
- return r && (this.onsuccess = this.onsuccess ? P(r, this.onsuccess) : r), i && (this.onerror = this.onerror ? P(i, this.onerror) : i), n === void 0 ? a === void 0 ? void 0 : a : o(n, a);
299
- };
300
- }
301
- function ye(e, t) {
302
- return e === M ? t : function() {
303
- return !1 !== t.apply(this, arguments) && e.apply(this, arguments);
304
- };
305
- }
306
- function be(e, t) {
307
- return e === M ? t : function() {
308
- var n = e.apply(this, arguments);
309
- if (n && typeof n.then == "function") {
310
- for (var r = this, i = arguments.length, a = Array(i); i--;) a[i] = arguments[i];
311
- return n.then(function() {
312
- return t.apply(r, a);
313
- });
314
- }
315
- return t.apply(this, arguments);
316
- };
317
- }
318
- w.ModifyError = ue, w.DexieError = ce, w.BulkError = de;
319
- var F = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
320
- function xe(e) {
321
- F = e;
322
- }
323
- var Se = {}, Ce = 100, we = typeof Promise > "u" ? [] : (A = Promise.resolve(), typeof crypto < "u" && crypto.subtle ? [
324
- we = crypto.subtle.digest("SHA-512", new Uint8Array([0])),
325
- s(we),
326
- A
327
- ] : [
328
- A,
329
- s(A),
330
- A
331
- ]), A = we[0], Te = we[1], Te = Te && Te.then, I = A && A.constructor, Ee = !!we[2], De = function(e, t) {
332
- Ne.push([e, t]), ke &&= (queueMicrotask(He), !1);
333
- }, Oe = !0, ke = !0, Ae = [], je = [], Me = N, L = {
334
- id: "global",
335
- global: !0,
336
- ref: 0,
337
- unhandleds: [],
338
- onunhandled: M,
339
- pgp: !1,
340
- env: {},
341
- finalize: M
342
- }, R = L, Ne = [], Pe = 0, Fe = [];
343
- function z(e) {
344
- if (typeof this != "object") throw TypeError("Promises must be constructed via new");
345
- this._listeners = [], this._lib = !1;
346
- var t = this._PSD = R;
347
- if (typeof e != "function") {
348
- if (e !== Se) throw TypeError("Not a function");
349
- this._state = arguments[1], this._value = arguments[2], !1 === this._state && Re(this, this._value);
350
- } else this._state = null, this._value = null, ++t.ref, function e(t, n) {
351
- try {
352
- n(function(n) {
353
- if (t._state === null) {
354
- if (n === t) throw TypeError("A promise cannot be resolved with itself.");
355
- var r = t._lib && Ue();
356
- n && typeof n.then == "function" ? e(t, function(e, t) {
357
- n instanceof z ? n._then(e, t) : n.then(e, t);
358
- }) : (t._state = !0, t._value = n, ze(t)), r && We();
359
- }
360
- }, Re.bind(null, t));
361
- } catch (e) {
362
- Re(t, e);
363
- }
364
- }(this, e);
365
- }
366
- var Ie = {
367
- get: function() {
368
- var e = R, t = Xe;
369
- function n(n, r) {
370
- var i = this, a = !e.global && (e !== R || t !== Xe), o = a && !et(), s = new z(function(t, s) {
371
- Be(i, new Le(ot(n, e, a, o), ot(r, e, a, o), t, s, e));
372
- });
373
- return this._consoleTask && (s._consoleTask = this._consoleTask), s;
374
- }
375
- return n.prototype = Se, n;
376
- },
377
- set: function(e) {
378
- f(this, "then", e && e.prototype === Se ? Ie : {
379
- get: function() {
380
- return e;
381
- },
382
- set: Ie.set
383
- });
384
- }
385
- };
386
- function Le(e, t, n, r, i) {
387
- this.onFulfilled = typeof e == "function" ? e : null, this.onRejected = typeof t == "function" ? t : null, this.resolve = n, this.reject = r, this.psd = i;
388
- }
389
- function Re(e, t) {
390
- var n, r;
391
- je.push(t), e._state === null && (n = e._lib && Ue(), t = Me(t), e._state = !1, e._value = t, r = e, Ae.some(function(e) {
392
- return e._value === r._value;
393
- }) || Ae.push(r), ze(e), n) && We();
394
- }
395
- function ze(e) {
396
- var t = e._listeners;
397
- e._listeners = [];
398
- for (var n = 0, r = t.length; n < r; ++n) Be(e, t[n]);
399
- var i = e._PSD;
400
- --i.ref || i.finalize(), Pe === 0 && (++Pe, De(function() {
401
- --Pe == 0 && Ge();
402
- }, []));
403
- }
404
- function Be(e, t) {
405
- if (e._state === null) e._listeners.push(t);
406
- else {
407
- var n = e._state ? t.onFulfilled : t.onRejected;
408
- if (n === null) return (e._state ? t.resolve : t.reject)(e._value);
409
- ++t.psd.ref, ++Pe, De(Ve, [
410
- n,
411
- e,
412
- t
413
- ]);
414
- }
415
- }
416
- function Ve(e, t, n) {
417
- try {
418
- var r, i = t._value;
419
- !t._state && je.length && (je = []), r = F && t._consoleTask ? t._consoleTask.run(function() {
420
- return e(i);
421
- }) : e(i), t._state || je.indexOf(i) !== -1 || ((e) => {
422
- for (var t = Ae.length; t;) if (Ae[--t]._value === e._value) return Ae.splice(t, 1);
423
- })(t), n.resolve(r);
424
- } catch (e) {
425
- n.reject(e);
426
- } finally {
427
- --Pe == 0 && Ge(), --n.psd.ref || n.psd.finalize();
428
- }
429
- }
430
- function He() {
431
- at(L, function() {
432
- Ue() && We();
433
- });
434
- }
435
- function Ue() {
436
- var e = Oe;
437
- return ke = Oe = !1, e;
438
- }
439
- function We() {
440
- var e, t, n;
441
- do
442
- for (; 0 < Ne.length;) for (e = Ne, Ne = [], n = e.length, t = 0; t < n; ++t) {
443
- var r = e[t];
444
- r[0].apply(null, r[1]);
445
- }
446
- while (0 < Ne.length);
447
- ke = Oe = !0;
448
- }
449
- function Ge() {
450
- for (var e = Ae, t = (Ae = [], e.forEach(function(e) {
451
- e._PSD.onunhandled.call(null, e._value, e);
452
- }), Fe.slice(0)), n = t.length; n;) t[--n]();
453
- }
454
- function Ke(e) {
455
- return new z(Se, !1, e);
456
- }
457
- function B(e, t) {
458
- var n = R;
459
- return function() {
460
- var r = Ue(), i = R;
461
- try {
462
- return rt(n, !0), e.apply(this, arguments);
463
- } catch (e) {
464
- t && t(e);
465
- } finally {
466
- rt(i, !1), r && We();
467
- }
468
- };
469
- }
470
- u(z.prototype, {
471
- then: Ie,
472
- _then: function(e, t) {
473
- Be(this, new Le(null, null, e, t, R));
474
- },
475
- catch: function(e) {
476
- var t, n;
477
- return arguments.length === 1 ? this.then(null, e) : (t = e, n = arguments[1], typeof t == "function" ? this.then(null, function(e) {
478
- return (e instanceof t ? n : Ke)(e);
479
- }) : this.then(null, function(e) {
480
- return (e && e.name === t ? n : Ke)(e);
481
- }));
482
- },
483
- finally: function(e) {
484
- return this.then(function(t) {
485
- return z.resolve(e()).then(function() {
486
- return t;
487
- });
488
- }, function(t) {
489
- return z.resolve(e()).then(function() {
490
- return Ke(t);
491
- });
492
- });
493
- },
494
- timeout: function(e, t) {
495
- var n = this;
496
- return e < Infinity ? new z(function(r, i) {
497
- var a = setTimeout(function() {
498
- return i(new j.Timeout(t));
499
- }, e);
500
- n.then(r, i).finally(clearTimeout.bind(null, a));
501
- }) : this;
502
- }
503
- }), typeof Symbol < "u" && Symbol.toStringTag && f(z.prototype, Symbol.toStringTag, "Dexie.Promise"), L.env = it(), u(z, {
504
- all: function() {
505
- var e = k.apply(null, arguments).map(tt);
506
- return new z(function(t, n) {
507
- e.length === 0 && t([]);
508
- var r = e.length;
509
- e.forEach(function(i, a) {
510
- return z.resolve(i).then(function(n) {
511
- e[a] = n, --r || t(e);
512
- }, n);
513
- });
514
- });
515
- },
516
- resolve: function(e) {
517
- return e instanceof z ? e : e && typeof e.then == "function" ? new z(function(t, n) {
518
- e.then(t, n);
519
- }) : new z(Se, !0, e);
520
- },
521
- reject: Ke,
522
- race: function() {
523
- var e = k.apply(null, arguments).map(tt);
524
- return new z(function(t, n) {
525
- e.map(function(e) {
526
- return z.resolve(e).then(t, n);
527
- });
528
- });
529
- },
530
- PSD: {
531
- get: function() {
532
- return R;
533
- },
534
- set: function(e) {
535
- return R = e;
536
- }
537
- },
538
- totalEchoes: { get: function() {
539
- return Xe;
540
- } },
541
- newPSD: Qe,
542
- usePSD: at,
543
- scheduler: {
544
- get: function() {
545
- return De;
546
- },
547
- set: function(e) {
548
- De = e;
549
- }
550
- },
551
- rejectionMapper: {
552
- get: function() {
553
- return Me;
554
- },
555
- set: function(e) {
556
- Me = e;
557
- }
558
- },
559
- follow: function(e, t) {
560
- return new z(function(n, r) {
561
- return Qe(function(t, n) {
562
- var r = R;
563
- r.unhandleds = [], r.onunhandled = n, r.finalize = P(function() {
564
- var e, r = this;
565
- e = function() {
566
- r.unhandleds.length === 0 ? t() : n(r.unhandleds[0]);
567
- }, Fe.push(function t() {
568
- e(), Fe.splice(Fe.indexOf(t), 1);
569
- }), ++Pe, De(function() {
570
- --Pe == 0 && Ge();
571
- }, []);
572
- }, r.finalize), e();
573
- }, t, n, r);
574
- });
575
- }
576
- }), I && (I.allSettled && f(z, "allSettled", function() {
577
- var e = k.apply(null, arguments).map(tt);
578
- return new z(function(t) {
579
- e.length === 0 && t([]);
580
- var n = e.length, r = Array(n);
581
- e.forEach(function(e, i) {
582
- return z.resolve(e).then(function(e) {
583
- return r[i] = {
584
- status: "fulfilled",
585
- value: e
586
- };
587
- }, function(e) {
588
- return r[i] = {
589
- status: "rejected",
590
- reason: e
591
- };
592
- }).then(function() {
593
- return --n || t(r);
594
- });
595
- });
596
- });
597
- }), I.any && typeof AggregateError < "u" && f(z, "any", function() {
598
- var e = k.apply(null, arguments).map(tt);
599
- return new z(function(t, n) {
600
- e.length === 0 && n(/* @__PURE__ */ AggregateError([]));
601
- var r = e.length, i = Array(r);
602
- e.forEach(function(e, a) {
603
- return z.resolve(e).then(function(e) {
604
- return t(e);
605
- }, function(e) {
606
- i[a] = e, --r || n(AggregateError(i));
607
- });
608
- });
609
- });
610
- }), I.withResolvers) && (z.withResolvers = I.withResolvers);
611
- var V = {
612
- awaits: 0,
613
- echoes: 0,
614
- id: 0
615
- }, qe = 0, Je = [], Ye = 0, Xe = 0, Ze = 0;
616
- function Qe(e, t, n, r) {
617
- var i = R, a = Object.create(i), t = (a.parent = i, a.ref = 0, a.global = !1, a.id = ++Ze, L.env, a.env = Ee ? {
618
- Promise: z,
619
- PromiseProp: {
620
- value: z,
621
- configurable: !0,
622
- writable: !0
623
- },
624
- all: z.all,
625
- race: z.race,
626
- allSettled: z.allSettled,
627
- any: z.any,
628
- resolve: z.resolve,
629
- reject: z.reject
630
- } : {}, t && o(a, t), ++i.ref, a.finalize = function() {
631
- --this.parent.ref || this.parent.finalize();
632
- }, at(a, e, n, r));
633
- return a.ref === 0 && a.finalize(), t;
634
- }
635
- function $e() {
636
- return V.id ||= ++qe, ++V.awaits, V.echoes += Ce, V.id;
637
- }
638
- function et() {
639
- return !!V.awaits && (--V.awaits == 0 && (V.id = 0), V.echoes = V.awaits * Ce, !0);
640
- }
641
- function tt(e) {
642
- return V.echoes && e && e.constructor === I ? ($e(), e.then(function(e) {
643
- return et(), e;
644
- }, function(e) {
645
- return et(), H(e);
646
- })) : e;
647
- }
648
- function nt() {
649
- var e = Je[Je.length - 1];
650
- Je.pop(), rt(e, !1);
651
- }
652
- function rt(e, t) {
653
- var n, i, a = R;
654
- (t ? !V.echoes || Ye++ && e === R : !Ye || --Ye && e === R) || queueMicrotask(t ? function(e) {
655
- ++Xe, V.echoes && --V.echoes != 0 || (V.echoes = V.awaits = V.id = 0), Je.push(R), rt(e, !0);
656
- }.bind(null, e) : nt), e !== R && (R = e, a === L && (L.env = it()), Ee) && (n = L.env.Promise, i = e.env, a.global || e.global) && (Object.defineProperty(r, "Promise", i.PromiseProp), n.all = i.all, n.race = i.race, n.resolve = i.resolve, n.reject = i.reject, i.allSettled && (n.allSettled = i.allSettled), i.any) && (n.any = i.any);
657
- }
658
- function it() {
659
- var e = r.Promise;
660
- return Ee ? {
661
- Promise: e,
662
- PromiseProp: Object.getOwnPropertyDescriptor(r, "Promise"),
663
- all: e.all,
664
- race: e.race,
665
- allSettled: e.allSettled,
666
- any: e.any,
667
- resolve: e.resolve,
668
- reject: e.reject
669
- } : {};
670
- }
671
- function at(e, t, n, r, i) {
672
- var a = R;
673
- try {
674
- return rt(e, !0), t(n, r, i);
675
- } finally {
676
- rt(a, !1);
677
- }
678
- }
679
- function ot(e, t, n, r) {
680
- return typeof e == "function" ? function() {
681
- var i = R;
682
- n && $e(), rt(t, !0);
683
- try {
684
- return e.apply(this, arguments);
685
- } finally {
686
- rt(i, !1), r && queueMicrotask(et);
687
- }
688
- } : e;
689
- }
690
- function st(e) {
691
- Promise === I && V.echoes === 0 ? Ye === 0 ? e() : enqueueNativeMicroTask(e) : setTimeout(e, 0);
692
- }
693
- ("" + Te).indexOf("[native code]") === -1 && ($e = et = M);
694
- var H = z.reject, ct = "￿", U = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.", lt = "String expected.", ut = "__dbnames", dt = "readonly", ft = "readwrite";
695
- function pt(e, t) {
696
- return e ? t ? function() {
697
- return e.apply(this, arguments) && t.apply(this, arguments);
698
- } : e : t;
699
- }
700
- var mt = {
701
- type: 3,
702
- lower: -Infinity,
703
- lowerOpen: !1,
704
- upper: [[]],
705
- upperOpen: !1
706
- };
707
- function ht(e) {
708
- return typeof e != "string" || /\./.test(e) ? function(e) {
709
- return e;
710
- } : function(t) {
711
- return t[e] === void 0 && e in t && delete (t = E(t))[e], t;
712
- };
713
- }
714
- function gt() {
715
- throw j.Type("Entity instances must never be new:ed. Instances are generated by the framework bypassing the constructor.");
716
- }
717
- function W(e, t) {
718
- try {
719
- var n = _t(e), r = _t(t);
720
- if (n !== r) return n === "Array" ? 1 : r === "Array" ? -1 : n === "binary" ? 1 : r === "binary" ? -1 : n === "string" ? 1 : r === "string" ? -1 : n === "Date" ? 1 : r === "Date" ? -1 : NaN;
721
- switch (n) {
722
- case "number":
723
- case "Date":
724
- case "string": return t < e ? 1 : e < t ? -1 : 0;
725
- case "binary":
726
- for (var i = vt(e), a = vt(t), o = i.length, s = a.length, c = o < s ? o : s, l = 0; l < c; ++l) if (i[l] !== a[l]) return i[l] < a[l] ? -1 : 1;
727
- return o === s ? 0 : o < s ? -1 : 1;
728
- case "Array":
729
- for (var u = e, d = t, f = u.length, p = d.length, m = f < p ? f : p, h = 0; h < m; ++h) {
730
- var g = W(u[h], d[h]);
731
- if (g !== 0) return g;
732
- }
733
- return f === p ? 0 : f < p ? -1 : 1;
734
- }
735
- } catch {}
736
- return NaN;
737
- }
738
- function _t(e) {
739
- var t = typeof e;
740
- return t == "object" && (ArrayBuffer.isView(e) || (t = re(e)) === "ArrayBuffer") ? "binary" : t;
741
- }
742
- function vt(e) {
743
- return e instanceof Uint8Array ? e : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : new Uint8Array(e);
744
- }
745
- function yt(e, t, n) {
746
- var r = e.schema.yProps;
747
- return r ? (t && 0 < n.numFailures && (t = t.filter(function(e, t) {
748
- return !n.failures[t];
749
- })), Promise.all(r.map(function(n) {
750
- return n = n.updatesTable, t ? e.db.table(n).where("k").anyOf(t).delete() : e.db.table(n).clear();
751
- })).then(function() {
752
- return n;
753
- })) : n;
754
- }
755
- xt.prototype.execute = function(e) {
756
- var t = this["@@propmod"];
757
- if (t.add !== void 0) {
758
- var r = t.add;
759
- if (a(r)) return n(n([], a(e) ? e : [], !0), r, !0).sort();
760
- if (typeof r == "number") return (Number(e) || 0) + r;
761
- if (typeof r == "bigint") try {
762
- return BigInt(e) + r;
763
- } catch {
764
- return BigInt(0) + r;
765
- }
766
- throw TypeError(`Invalid term ${r}`);
767
- }
768
- if (t.remove !== void 0) {
769
- var i = t.remove;
770
- if (a(i)) return a(e) ? e.filter(function(e) {
771
- return !i.includes(e);
772
- }).sort() : [];
773
- if (typeof i == "number") return Number(e) - i;
774
- if (typeof i == "bigint") try {
775
- return BigInt(e) - i;
776
- } catch {
777
- return BigInt(0) - i;
778
- }
779
- throw TypeError(`Invalid subtrahend ${i}`);
780
- }
781
- return r = (r = t.replacePrefix)?.[0], r && typeof e == "string" && e.startsWith(r) ? t.replacePrefix[1] + e.substring(r.length) : e;
782
- };
783
- var bt = xt;
784
- function xt(e) {
785
- this["@@propmod"] = e;
786
- }
787
- function St(e, t) {
788
- for (var n = i(t), r = n.length, a = !1, o = 0; o < r; ++o) {
789
- var s = n[o], c = t[s], l = b(e, s);
790
- c instanceof bt ? (x(e, s, c.execute(l)), a = !0) : l !== c && (x(e, s, c), a = !0);
791
- }
792
- return a;
793
- }
794
- G.prototype._trans = function(e, t, n) {
795
- var r = this._tx || R.trans, i = this.name, a = F && typeof console < "u" && console.createTask && console.createTask(`Dexie: ${e === "readonly" ? "read" : "write"} ${this.name}`);
796
- function o(e, n, r) {
797
- if (r.schema[i]) return t(r.idbtrans, r);
798
- throw new j.NotFound("Table " + i + " not part of transaction");
799
- }
800
- var s = Ue();
801
- try {
802
- var c = r && r.db._novip === this.db._novip ? r === R.trans ? r._promise(e, o, n) : Qe(function() {
803
- return r._promise(e, o, n);
804
- }, {
805
- trans: r,
806
- transless: R.transless || R
807
- }) : function e(t, n, r, i) {
808
- if (t.idbdb && (t._state.openComplete || R.letThrough || t._vip)) {
809
- var a = t._createTransaction(n, r, t._dbSchema);
810
- try {
811
- a.create(), t._state.PR1398_maxLoop = 3;
812
- } catch (a) {
813
- return a.name === fe.InvalidState && t.isOpen() && 0 < --t._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), t.close({ disableAutoOpen: !1 }), t.open().then(function() {
814
- return e(t, n, r, i);
815
- })) : H(a);
816
- }
817
- return a._promise(n, function(e, t) {
818
- return Qe(function() {
819
- return R.trans = a, i(e, t, a);
820
- });
821
- }).then(function(e) {
822
- if (n === "readwrite") try {
823
- a.idbtrans.commit();
824
- } catch {}
825
- return n === "readonly" ? e : a._completion.then(function() {
826
- return e;
827
- });
828
- });
829
- }
830
- if (t._state.openComplete) return H(new j.DatabaseClosed(t._state.dbOpenError));
831
- if (!t._state.isBeingOpened) {
832
- if (!t._state.autoOpen) return H(new j.DatabaseClosed());
833
- t.open().catch(M);
834
- }
835
- return t._state.dbReadyPromise.then(function() {
836
- return e(t, n, r, i);
837
- });
838
- }(this.db, e, [this.name], o);
839
- return a && (c._consoleTask = a, c = c.catch(function(e) {
840
- return console.trace(e), H(e);
841
- })), c;
842
- } finally {
843
- s && We();
844
- }
845
- }, G.prototype.get = function(e, t) {
846
- var n = this;
847
- return e && e.constructor === Object ? this.where(e).first(t) : e == null ? H(new j.Type("Invalid argument to Table.get()")) : this._trans("readonly", function(t) {
848
- return n.core.get({
849
- trans: t,
850
- key: e
851
- }).then(function(e) {
852
- return n.hook.reading.fire(e);
853
- });
854
- }).then(t);
855
- }, G.prototype.where = function(e) {
856
- if (typeof e == "string") return new this.db.WhereClause(this, e);
857
- if (a(e)) return new this.db.WhereClause(this, `[${e.join("+")}]`);
858
- var t = i(e);
859
- if (t.length === 1) return this.where(t[0]).equals(e[t[0]]);
860
- var n = this.schema.indexes.concat(this.schema.primKey).filter(function(e) {
861
- if (e.compound && t.every(function(t) {
862
- return 0 <= e.keyPath.indexOf(t);
863
- })) {
864
- for (var n = 0; n < t.length; ++n) if (t.indexOf(e.keyPath[n]) === -1) return !1;
865
- return !0;
866
- }
867
- return !1;
868
- }).sort(function(e, t) {
869
- return e.keyPath.length - t.keyPath.length;
870
- })[0];
871
- if (n && this.db._maxKey !== ct) return s = n.keyPath.slice(0, t.length), this.where(s).equals(s.map(function(t) {
872
- return e[t];
873
- }));
874
- !n && F && console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit from a compound index [${t.join("+")}]`);
875
- var r = this.schema.idxByName;
876
- function o(e, t) {
877
- return W(e, t) === 0;
878
- }
879
- var s = t.reduce(function(t, n) {
880
- var i = t[0], t = t[1], s = r[n], c = e[n];
881
- return [i || s, i || !s ? pt(t, s && s.multi ? function(e) {
882
- return e = b(e, n), a(e) && e.some(function(e) {
883
- return o(c, e);
884
- });
885
- } : function(e) {
886
- return o(c, b(e, n));
887
- }) : t];
888
- }, [null, null]), c = s[0], s = s[1];
889
- return c ? this.where(c.name).equals(e[c.keyPath]).filter(s) : n ? this.filter(s) : this.where(t).equals("");
890
- }, G.prototype.filter = function(e) {
891
- return this.toCollection().and(e);
892
- }, G.prototype.count = function(e) {
893
- return this.toCollection().count(e);
894
- }, G.prototype.offset = function(e) {
895
- return this.toCollection().offset(e);
896
- }, G.prototype.limit = function(e) {
897
- return this.toCollection().limit(e);
898
- }, G.prototype.each = function(e) {
899
- return this.toCollection().each(e);
900
- }, G.prototype.toArray = function(e) {
901
- return this.toCollection().toArray(e);
902
- }, G.prototype.toCollection = function() {
903
- return new this.db.Collection(new this.db.WhereClause(this));
904
- }, G.prototype.orderBy = function(e) {
905
- return new this.db.Collection(new this.db.WhereClause(this, a(e) ? `[${e.join("+")}]` : e));
906
- }, G.prototype.reverse = function() {
907
- return this.toCollection().reverse();
908
- }, G.prototype.mapToClass = function(t) {
909
- for (var n = this.db, r = this.name, i = ((this.schema.mappedClass = t).prototype instanceof gt && (t = ((t) => {
910
- var i = s, a = t;
911
- if (typeof a != "function" && a !== null) throw TypeError("Class extends value " + String(a) + " is not a constructor or null");
912
- function o() {
913
- this.constructor = i;
914
- }
915
- function s() {
916
- return t !== null && t.apply(this, arguments) || this;
917
- }
918
- return e(i, a), i.prototype = a === null ? Object.create(a) : (o.prototype = a.prototype, new o()), Object.defineProperty(s.prototype, "db", {
919
- get: function() {
920
- return n;
921
- },
922
- enumerable: !1,
923
- configurable: !0
924
- }), s.prototype.table = function() {
925
- return r;
926
- }, s;
927
- })(t)), /* @__PURE__ */ new Set()), a = t.prototype; a; a = s(a)) Object.getOwnPropertyNames(a).forEach(function(e) {
928
- return i.add(e);
929
- });
930
- function o(e) {
931
- if (!e) return e;
932
- var n, r = Object.create(t.prototype);
933
- for (n in e) if (!i.has(n)) try {
934
- r[n] = e[n];
935
- } catch {}
936
- return r;
937
- }
938
- return this.schema.readHook && this.hook.reading.unsubscribe(this.schema.readHook), this.schema.readHook = o, this.hook("reading", o), t;
939
- }, G.prototype.defineClass = function() {
940
- return this.mapToClass(function(e) {
941
- o(this, e);
942
- });
943
- }, G.prototype.add = function(e, t) {
944
- var n = this, r = this.schema.primKey, i = r.auto, a = r.keyPath, o = e;
945
- return a && i && (o = ht(a)(e)), this._trans("readwrite", function(e) {
946
- return n.core.mutate({
947
- trans: e,
948
- type: "add",
949
- keys: t == null ? null : [t],
950
- values: [o]
951
- });
952
- }).then(function(e) {
953
- return e.numFailures ? z.reject(e.failures[0]) : e.lastResult;
954
- }).then(function(t) {
955
- if (a) try {
956
- x(e, a, t);
957
- } catch {}
958
- return t;
959
- });
960
- }, G.prototype.upsert = function(e, t) {
961
- var n = this, r = this.schema.primKey.keyPath;
962
- return this._trans("readwrite", function(i) {
963
- return n.core.get({
964
- trans: i,
965
- key: e
966
- }).then(function(a) {
967
- var o = a ?? {};
968
- return St(o, t), r && x(o, r, e), n.core.mutate({
969
- trans: i,
970
- type: "put",
971
- values: [o],
972
- keys: [e],
973
- upsert: !0,
974
- updates: {
975
- keys: [e],
976
- changeSpecs: [t]
977
- }
978
- }).then(function(e) {
979
- return e.numFailures ? z.reject(e.failures[0]) : !!a;
980
- });
981
- });
982
- });
983
- }, G.prototype.update = function(e, t) {
984
- return typeof e != "object" || a(e) ? this.where(":id").equals(e).modify(t) : (e = b(e, this.schema.primKey.keyPath)) === void 0 ? H(new j.InvalidArgument("Given object does not contain its primary key")) : this.where(":id").equals(e).modify(t);
985
- }, G.prototype.put = function(e, t) {
986
- var n = this, r = this.schema.primKey, i = r.auto, a = r.keyPath, o = e;
987
- return a && i && (o = ht(a)(e)), this._trans("readwrite", function(e) {
988
- return n.core.mutate({
989
- trans: e,
990
- type: "put",
991
- values: [o],
992
- keys: t == null ? null : [t]
993
- });
994
- }).then(function(e) {
995
- return e.numFailures ? z.reject(e.failures[0]) : e.lastResult;
996
- }).then(function(t) {
997
- if (a) try {
998
- x(e, a, t);
999
- } catch {}
1000
- return t;
1001
- });
1002
- }, G.prototype.delete = function(e) {
1003
- var t = this;
1004
- return this._trans("readwrite", function(n) {
1005
- return t.core.mutate({
1006
- trans: n,
1007
- type: "delete",
1008
- keys: [e]
1009
- }).then(function(n) {
1010
- return yt(t, [e], n);
1011
- }).then(function(e) {
1012
- return e.numFailures ? z.reject(e.failures[0]) : void 0;
1013
- });
1014
- });
1015
- }, G.prototype.clear = function() {
1016
- var e = this;
1017
- return this._trans("readwrite", function(t) {
1018
- return e.core.mutate({
1019
- trans: t,
1020
- type: "deleteRange",
1021
- range: mt
1022
- }).then(function(t) {
1023
- return yt(e, null, t);
1024
- });
1025
- }).then(function(e) {
1026
- return e.numFailures ? z.reject(e.failures[0]) : void 0;
1027
- });
1028
- }, G.prototype.bulkGet = function(e) {
1029
- var t = this;
1030
- return this._trans("readonly", function(n) {
1031
- return t.core.getMany({
1032
- keys: e,
1033
- trans: n
1034
- }).then(function(e) {
1035
- return e.map(function(e) {
1036
- return t.hook.reading.fire(e);
1037
- });
1038
- });
1039
- });
1040
- }, G.prototype.bulkAdd = function(e, t, n) {
1041
- var r = this, i = Array.isArray(t) ? t : void 0, a = (n ||= i ? void 0 : t) ? n.allKeys : void 0;
1042
- return this._trans("readwrite", function(t) {
1043
- var n = r.schema.primKey, o = n.auto, n = n.keyPath;
1044
- if (n && i) throw new j.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
1045
- if (i && i.length !== e.length) throw new j.InvalidArgument("Arguments objects and keys must have the same length");
1046
- var s = e.length, o = n && o ? e.map(ht(n)) : e;
1047
- return r.core.mutate({
1048
- trans: t,
1049
- type: "add",
1050
- keys: i,
1051
- values: o,
1052
- wantResults: a
1053
- }).then(function(e) {
1054
- var t = e.numFailures, n = e.failures;
1055
- if (t === 0) return a ? e.results : e.lastResult;
1056
- throw new de(`${r.name}.bulkAdd(): ${t} of ${s} operations failed`, n);
1057
- });
1058
- });
1059
- }, G.prototype.bulkPut = function(e, t, n) {
1060
- var r = this, i = Array.isArray(t) ? t : void 0, a = (n ||= i ? void 0 : t) ? n.allKeys : void 0;
1061
- return this._trans("readwrite", function(t) {
1062
- var n = r.schema.primKey, o = n.auto, n = n.keyPath;
1063
- if (n && i) throw new j.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
1064
- if (i && i.length !== e.length) throw new j.InvalidArgument("Arguments objects and keys must have the same length");
1065
- var s = e.length, o = n && o ? e.map(ht(n)) : e;
1066
- return r.core.mutate({
1067
- trans: t,
1068
- type: "put",
1069
- keys: i,
1070
- values: o,
1071
- wantResults: a
1072
- }).then(function(e) {
1073
- var t = e.numFailures, n = e.failures;
1074
- if (t === 0) return a ? e.results : e.lastResult;
1075
- throw new de(`${r.name}.bulkPut(): ${t} of ${s} operations failed`, n);
1076
- });
1077
- });
1078
- }, G.prototype.bulkUpdate = function(e) {
1079
- var t = this, n = this.core, r = e.map(function(e) {
1080
- return e.key;
1081
- }), i = e.map(function(e) {
1082
- return e.changes;
1083
- }), a = [];
1084
- return this._trans("readwrite", function(o) {
1085
- return n.getMany({
1086
- trans: o,
1087
- keys: r,
1088
- cache: "clone"
1089
- }).then(function(s) {
1090
- var c = [], l = [], u = (e.forEach(function(e, n) {
1091
- var r = e.key, i = e.changes, o = s[n];
1092
- if (o) {
1093
- for (var u = 0, d = Object.keys(i); u < d.length; u++) {
1094
- var f = d[u], p = i[f];
1095
- if (f === t.schema.primKey.keyPath) {
1096
- if (W(p, r) !== 0) throw new j.Constraint("Cannot update primary key in bulkUpdate()");
1097
- } else x(o, f, p);
1098
- }
1099
- a.push(n), c.push(r), l.push(o);
1100
- }
1101
- }), c.length);
1102
- return n.mutate({
1103
- trans: o,
1104
- type: "put",
1105
- keys: c,
1106
- values: l,
1107
- updates: {
1108
- keys: r,
1109
- changeSpecs: i
1110
- }
1111
- }).then(function(e) {
1112
- var n = e.numFailures, r = e.failures;
1113
- if (n === 0) return u;
1114
- for (var i = 0, o = Object.keys(r); i < o.length; i++) {
1115
- var s, c = o[i], l = a[Number(c)];
1116
- l != null && (s = r[c], delete r[c], r[l] = s);
1117
- }
1118
- throw new de(`${t.name}.bulkUpdate(): ${n} of ${u} operations failed`, r);
1119
- });
1120
- });
1121
- });
1122
- }, G.prototype.bulkDelete = function(e) {
1123
- var t = this, n = e.length;
1124
- return this._trans("readwrite", function(n) {
1125
- return t.core.mutate({
1126
- trans: n,
1127
- type: "delete",
1128
- keys: e
1129
- }).then(function(n) {
1130
- return yt(t, e, n);
1131
- });
1132
- }).then(function(e) {
1133
- var r = e.numFailures, i = e.failures;
1134
- if (r === 0) return e.lastResult;
1135
- throw new de(`${t.name}.bulkDelete(): ${r} of ${n} operations failed`, i);
1136
- });
1137
- };
1138
- var Ct = G;
1139
- function G() {}
1140
- function wt(e) {
1141
- function t(t, r) {
1142
- if (r) {
1143
- for (var i = arguments.length, a = Array(i - 1); --i;) a[i - 1] = arguments[i];
1144
- return n[t].subscribe.apply(null, a), e;
1145
- }
1146
- if (typeof t == "string") return n[t];
1147
- }
1148
- var n = {};
1149
- t.addEventType = s;
1150
- for (var r = 1, o = arguments.length; r < o; ++r) s(arguments[r]);
1151
- return t;
1152
- function s(e, r, o) {
1153
- var c, l;
1154
- if (typeof e != "object") return r ||= ye, l = {
1155
- subscribers: [],
1156
- fire: o ||= M,
1157
- subscribe: function(e) {
1158
- l.subscribers.indexOf(e) === -1 && (l.subscribers.push(e), l.fire = r(l.fire, e));
1159
- },
1160
- unsubscribe: function(e) {
1161
- l.subscribers = l.subscribers.filter(function(t) {
1162
- return t !== e;
1163
- }), l.fire = l.subscribers.reduce(r, o);
1164
- }
1165
- }, n[e] = t[e] = l;
1166
- i(c = e).forEach(function(e) {
1167
- var t = c[e];
1168
- if (a(t)) s(e, c[e][0], c[e][1]);
1169
- else {
1170
- if (t !== "asap") throw new j.InvalidArgument("Invalid event config");
1171
- var n = s(e, N, function() {
1172
- for (var e = arguments.length, t = Array(e); e--;) t[e] = arguments[e];
1173
- n.subscribers.forEach(function(e) {
1174
- y(function() {
1175
- e.apply(null, t);
1176
- });
1177
- });
1178
- });
1179
- }
1180
- });
1181
- }
1182
- }
1183
- function Tt(e, t) {
1184
- return p(t).from({ prototype: e }), t;
1185
- }
1186
- function Et(e, t) {
1187
- return !(e.filter || e.algorithm || e.or) && (t ? e.justLimit : !e.replayFilter);
1188
- }
1189
- function Dt(e, t) {
1190
- e.filter = pt(e.filter, t);
1191
- }
1192
- function Ot(e, t, n) {
1193
- var r = e.replayFilter;
1194
- e.replayFilter = r ? function() {
1195
- return pt(r(), t());
1196
- } : t, e.justLimit = n && !r;
1197
- }
1198
- function kt(e, t) {
1199
- if (e.isPrimKey) return t.primaryKey;
1200
- var n = t.getIndexByKeyPath(e.index);
1201
- if (n) return n;
1202
- throw new j.Schema("KeyPath " + e.index + " on object store " + t.name + " is not indexed");
1203
- }
1204
- function At(e, t, n) {
1205
- var r = kt(e, t.schema);
1206
- return t.openCursor({
1207
- trans: n,
1208
- values: !e.keysOnly,
1209
- reverse: e.dir === "prev",
1210
- unique: !!e.unique,
1211
- query: {
1212
- index: r,
1213
- range: e.range
1214
- }
1215
- });
1216
- }
1217
- function jt(e, t, n, r) {
1218
- var i, a, o = e.replayFilter ? pt(e.filter, e.replayFilter()) : e.filter;
1219
- return e.or ? (i = {}, a = function(e, n, r) {
1220
- var a, s;
1221
- o && !o(n, r, function(e) {
1222
- return n.stop(e);
1223
- }, function(e) {
1224
- return n.fail(e);
1225
- }) || ((s = "" + (a = n.primaryKey)) == "[object ArrayBuffer]" && (s = "" + new Uint8Array(a)), l(i, s)) || (i[s] = !0, t(e, n, r));
1226
- }, Promise.all([e.or._iterate(a, n), Mt(At(e, r, n), e.algorithm, a, !e.keysOnly && e.valueMapper)])) : Mt(At(e, r, n), pt(e.algorithm, o), t, !e.keysOnly && e.valueMapper);
1227
- }
1228
- function Mt(e, t, n, r) {
1229
- var i = B(r ? function(e, t, i) {
1230
- return n(r(e), t, i);
1231
- } : n);
1232
- return e.then(function(e) {
1233
- if (e) return e.start(function() {
1234
- var n = function() {
1235
- return e.continue();
1236
- };
1237
- t && !t(e, function(e) {
1238
- return n = e;
1239
- }, function(t) {
1240
- e.stop(t), n = M;
1241
- }, function(t) {
1242
- e.fail(t), n = M;
1243
- }) || i(e.value, e, function(e) {
1244
- return n = e;
1245
- }), n();
1246
- });
1247
- });
1248
- }
1249
- K.prototype._read = function(e, t) {
1250
- var n = this._ctx;
1251
- return n.error ? n.table._trans(null, H.bind(null, n.error)) : n.table._trans("readonly", e).then(t);
1252
- }, K.prototype._write = function(e) {
1253
- var t = this._ctx;
1254
- return t.error ? t.table._trans(null, H.bind(null, t.error)) : t.table._trans("readwrite", e, "locked");
1255
- }, K.prototype._addAlgorithm = function(e) {
1256
- var t = this._ctx;
1257
- t.algorithm = pt(t.algorithm, e);
1258
- }, K.prototype._iterate = function(e, t) {
1259
- return jt(this._ctx, e, t, this._ctx.table.core);
1260
- }, K.prototype.clone = function(e) {
1261
- var t = Object.create(this.constructor.prototype), n = Object.create(this._ctx);
1262
- return e && o(n, e), t._ctx = n, t;
1263
- }, K.prototype.raw = function() {
1264
- return this._ctx.valueMapper = null, this;
1265
- }, K.prototype.each = function(e) {
1266
- var t = this._ctx;
1267
- return this._read(function(n) {
1268
- return jt(t, e, n, t.table.core);
1269
- });
1270
- }, K.prototype.count = function(e) {
1271
- var t = this;
1272
- return this._read(function(e) {
1273
- var n, r = t._ctx, i = r.table.core;
1274
- return Et(r, !0) ? i.count({
1275
- trans: e,
1276
- query: {
1277
- index: kt(r, i.schema),
1278
- range: r.range
1279
- }
1280
- }).then(function(e) {
1281
- return Math.min(e, r.limit);
1282
- }) : (n = 0, jt(r, function() {
1283
- return ++n, !1;
1284
- }, e, i).then(function() {
1285
- return n;
1286
- }));
1287
- }).then(e);
1288
- }, K.prototype.sortBy = function(e, t) {
1289
- var n = e.split(".").reverse(), r = n[0], i = n.length - 1;
1290
- function a(e, t) {
1291
- return t ? a(e[n[t]], t - 1) : e[r];
1292
- }
1293
- var o = this._ctx.dir === "next" ? 1 : -1;
1294
- function s(e, t) {
1295
- return W(a(e, i), a(t, i)) * o;
1296
- }
1297
- return this.toArray(function(e) {
1298
- return e.slice().sort(s);
1299
- }).then(t);
1300
- }, K.prototype.toArray = function(e) {
1301
- var t = this;
1302
- return this._read(function(e) {
1303
- var n, r, i, a = t._ctx;
1304
- return Et(a, !0) && 0 < a.limit ? (n = a.valueMapper, r = kt(a, a.table.core.schema), a.table.core.query({
1305
- trans: e,
1306
- limit: a.limit,
1307
- values: !0,
1308
- direction: a.dir === "prev" ? "prev" : void 0,
1309
- query: {
1310
- index: r,
1311
- range: a.range
1312
- }
1313
- }).then(function(e) {
1314
- return e = e.result, n ? e.map(n) : e;
1315
- })) : (i = [], jt(a, function(e) {
1316
- return i.push(e);
1317
- }, e, a.table.core).then(function() {
1318
- return i;
1319
- }));
1320
- }, e);
1321
- }, K.prototype.offset = function(e) {
1322
- var t = this._ctx;
1323
- return e <= 0 || (t.offset += e, Et(t) ? Ot(t, function() {
1324
- var t = e;
1325
- return function(e, n) {
1326
- return t === 0 || (t === 1 ? --t : n(function() {
1327
- e.advance(t), t = 0;
1328
- }), !1);
1329
- };
1330
- }) : Ot(t, function() {
1331
- var t = e;
1332
- return function() {
1333
- return --t < 0;
1334
- };
1335
- })), this;
1336
- }, K.prototype.limit = function(e) {
1337
- return this._ctx.limit = Math.min(this._ctx.limit, e), Ot(this._ctx, function() {
1338
- var t = e;
1339
- return function(e, n, r) {
1340
- return --t <= 0 && n(r), 0 <= t;
1341
- };
1342
- }, !0), this;
1343
- }, K.prototype.until = function(e, t) {
1344
- return Dt(this._ctx, function(n, r, i) {
1345
- return !e(n.value) || (r(i), t);
1346
- }), this;
1347
- }, K.prototype.first = function(e) {
1348
- return this.limit(1).toArray(function(e) {
1349
- return e[0];
1350
- }).then(e);
1351
- }, K.prototype.last = function(e) {
1352
- return this.reverse().first(e);
1353
- }, K.prototype.filter = function(e) {
1354
- var t;
1355
- return Dt(this._ctx, function(t) {
1356
- return e(t.value);
1357
- }), (t = this._ctx).isMatch = pt(t.isMatch, e), this;
1358
- }, K.prototype.and = function(e) {
1359
- return this.filter(e);
1360
- }, K.prototype.or = function(e) {
1361
- return new this.db.WhereClause(this._ctx.table, e, this);
1362
- }, K.prototype.reverse = function() {
1363
- return this._ctx.dir = this._ctx.dir === "prev" ? "next" : "prev", this._ondirectionchange && this._ondirectionchange(this._ctx.dir), this;
1364
- }, K.prototype.desc = function() {
1365
- return this.reverse();
1366
- }, K.prototype.eachKey = function(e) {
1367
- var t = this._ctx;
1368
- return t.keysOnly = !t.isMatch, this.each(function(t, n) {
1369
- e(n.key, n);
1370
- });
1371
- }, K.prototype.eachUniqueKey = function(e) {
1372
- return this._ctx.unique = "unique", this.eachKey(e);
1373
- }, K.prototype.eachPrimaryKey = function(e) {
1374
- var t = this._ctx;
1375
- return t.keysOnly = !t.isMatch, this.each(function(t, n) {
1376
- e(n.primaryKey, n);
1377
- });
1378
- }, K.prototype.keys = function(e) {
1379
- var t = this._ctx, n = (t.keysOnly = !t.isMatch, []);
1380
- return this.each(function(e, t) {
1381
- n.push(t.key);
1382
- }).then(function() {
1383
- return n;
1384
- }).then(e);
1385
- }, K.prototype.primaryKeys = function(e) {
1386
- var t = this._ctx;
1387
- if (Et(t, !0) && 0 < t.limit) return this._read(function(e) {
1388
- var n = kt(t, t.table.core.schema);
1389
- return t.table.core.query({
1390
- trans: e,
1391
- values: !1,
1392
- limit: t.limit,
1393
- direction: t.dir === "prev" ? "prev" : void 0,
1394
- query: {
1395
- index: n,
1396
- range: t.range
1397
- }
1398
- });
1399
- }).then(function(e) {
1400
- return e.result;
1401
- }).then(e);
1402
- t.keysOnly = !t.isMatch;
1403
- var n = [];
1404
- return this.each(function(e, t) {
1405
- n.push(t.primaryKey);
1406
- }).then(function() {
1407
- return n;
1408
- }).then(e);
1409
- }, K.prototype.uniqueKeys = function(e) {
1410
- return this._ctx.unique = "unique", this.keys(e);
1411
- }, K.prototype.firstKey = function(e) {
1412
- return this.limit(1).keys(function(e) {
1413
- return e[0];
1414
- }).then(e);
1415
- }, K.prototype.lastKey = function(e) {
1416
- return this.reverse().firstKey(e);
1417
- }, K.prototype.distinct = function() {
1418
- var e, t = this._ctx, t = t.index && t.table.schema.idxByName[t.index];
1419
- return t && t.multi && (e = {}, Dt(this._ctx, function(t) {
1420
- var t = t.primaryKey.toString(), n = l(e, t);
1421
- return e[t] = !0, !n;
1422
- })), this;
1423
- }, K.prototype.modify = function(e) {
1424
- var t = this, n = this._ctx;
1425
- return this._write(function(r) {
1426
- function a(e, t) {
1427
- var n = t.failures;
1428
- p += e - t.numFailures;
1429
- for (var r = 0, a = i(n); r < a.length; r++) {
1430
- var o = a[r];
1431
- f.push(n[o]);
1432
- }
1433
- }
1434
- var o = typeof e == "function" ? e : function(t) {
1435
- return St(t, e);
1436
- }, s = n.table.core, c = s.schema.primaryKey, l = c.outbound, u = c.extractKey, d = 200, c = t.db._options.modifyChunkSize, f = (c && (d = typeof c == "object" ? c[s.name] || c["*"] || 200 : c), []), p = 0, m = [], h = e === Pt;
1437
- return t.clone().primaryKeys().then(function(t) {
1438
- function i(f) {
1439
- var p = Math.min(d, t.length - f), m = t.slice(f, f + p);
1440
- return (h ? Promise.resolve([]) : s.getMany({
1441
- trans: r,
1442
- keys: m,
1443
- cache: "immutable"
1444
- })).then(function(g) {
1445
- var _ = [], v = [], y = l ? [] : null, b = h ? m : [];
1446
- if (!h) for (var x = 0; x < p; ++x) {
1447
- var S = g[x], C = {
1448
- value: E(S),
1449
- primKey: t[f + x]
1450
- };
1451
- !1 !== o.call(C, C.value, C) && (C.value == null ? b.push(t[f + x]) : l || W(u(S), u(C.value)) === 0 ? (v.push(C.value), l && y.push(t[f + x])) : (b.push(t[f + x]), _.push(C.value)));
1452
- }
1453
- return Promise.resolve(0 < _.length && s.mutate({
1454
- trans: r,
1455
- type: "add",
1456
- values: _
1457
- }).then(function(e) {
1458
- for (var t in e.failures) b.splice(parseInt(t), 1);
1459
- a(_.length, e);
1460
- })).then(function() {
1461
- return (0 < v.length || c && typeof e == "object") && s.mutate({
1462
- trans: r,
1463
- type: "put",
1464
- keys: y,
1465
- values: v,
1466
- criteria: c,
1467
- changeSpec: typeof e != "function" && e,
1468
- isAdditionalChunk: 0 < f
1469
- }).then(function(e) {
1470
- return a(v.length, e);
1471
- });
1472
- }).then(function() {
1473
- return (0 < b.length || c && h) && s.mutate({
1474
- trans: r,
1475
- type: "delete",
1476
- keys: b,
1477
- criteria: c,
1478
- isAdditionalChunk: 0 < f
1479
- }).then(function(e) {
1480
- return yt(n.table, b, e);
1481
- }).then(function(e) {
1482
- return a(b.length, e);
1483
- });
1484
- }).then(function() {
1485
- return t.length > f + p && i(f + d);
1486
- });
1487
- });
1488
- }
1489
- var c = Et(n) && n.limit === Infinity && (typeof e != "function" || h) && {
1490
- index: n.index,
1491
- range: n.range
1492
- };
1493
- return i(0).then(function() {
1494
- if (0 < f.length) throw new ue("Error modifying one or more objects", f, p, m);
1495
- return t.length;
1496
- });
1497
- });
1498
- });
1499
- }, K.prototype.delete = function() {
1500
- var e = this._ctx, t = e.range;
1501
- return !Et(e) || e.table.schema.yProps || !e.isPrimKey && t.type !== 3 ? this.modify(Pt) : this._write(function(n) {
1502
- var r = e.table.core.schema.primaryKey, i = t;
1503
- return e.table.core.count({
1504
- trans: n,
1505
- query: {
1506
- index: r,
1507
- range: i
1508
- }
1509
- }).then(function(t) {
1510
- return e.table.core.mutate({
1511
- trans: n,
1512
- type: "deleteRange",
1513
- range: i
1514
- }).then(function(e) {
1515
- var n = e.failures, e = e.numFailures;
1516
- if (e) throw new ue("Could not delete some values", Object.keys(n).map(function(e) {
1517
- return n[e];
1518
- }), t - e);
1519
- return t - e;
1520
- });
1521
- });
1522
- });
1523
- };
1524
- var Nt = K;
1525
- function K() {}
1526
- var Pt = function(e, t) {
1527
- return t.value = null;
1528
- };
1529
- function Ft(e, t) {
1530
- return e < t ? -1 : e === t ? 0 : 1;
1531
- }
1532
- function It(e, t) {
1533
- return t < e ? -1 : e === t ? 0 : 1;
1534
- }
1535
- function q(e, t, n) {
1536
- return e = e instanceof Vt ? new e.Collection(e) : e, e._ctx.error = new (n || TypeError)(t), e;
1537
- }
1538
- function Lt(e) {
1539
- return new e.Collection(e, function() {
1540
- return Bt("");
1541
- }).limit(0);
1542
- }
1543
- function Rt(e, t, n, r) {
1544
- var i, a, o, s, c, l, u, d = n.length;
1545
- if (!n.every(function(e) {
1546
- return typeof e == "string";
1547
- })) return q(e, lt);
1548
- function f(e) {
1549
- i = e === "next" ? function(e) {
1550
- return e.toUpperCase();
1551
- } : function(e) {
1552
- return e.toLowerCase();
1553
- }, a = e === "next" ? function(e) {
1554
- return e.toLowerCase();
1555
- } : function(e) {
1556
- return e.toUpperCase();
1557
- }, o = e === "next" ? Ft : It;
1558
- var t = n.map(function(e) {
1559
- return {
1560
- lower: a(e),
1561
- upper: i(e)
1562
- };
1563
- }).sort(function(e, t) {
1564
- return o(e.lower, t.lower);
1565
- });
1566
- s = t.map(function(e) {
1567
- return e.upper;
1568
- }), c = t.map(function(e) {
1569
- return e.lower;
1570
- }), u = (l = e) === "next" ? "" : r;
1571
- }
1572
- f("next");
1573
- var e = new e.Collection(e, function() {
1574
- return zt(s[0], c[d - 1] + r);
1575
- }), p = (e._ondirectionchange = function(e) {
1576
- f(e);
1577
- }, 0);
1578
- return e._addAlgorithm(function(e, n, r) {
1579
- var i = e.key;
1580
- if (typeof i == "string") {
1581
- var f = a(i);
1582
- if (t(f, c, p)) return !0;
1583
- for (var m = null, h = p; h < d; ++h) {
1584
- var g = ((e, t, n, r, i, a) => {
1585
- for (var o = Math.min(e.length, r.length), s = -1, c = 0; c < o; ++c) {
1586
- var l = t[c];
1587
- if (l !== r[c]) return i(e[c], n[c]) < 0 ? e.substr(0, c) + n[c] + n.substr(c + 1) : i(e[c], r[c]) < 0 ? e.substr(0, c) + r[c] + n.substr(c + 1) : 0 <= s ? e.substr(0, s) + t[s] + n.substr(s + 1) : null;
1588
- i(e[c], l) < 0 && (s = c);
1589
- }
1590
- return o < r.length && a === "next" ? e + n.substr(e.length) : o < e.length && a === "prev" ? e.substr(0, n.length) : s < 0 ? null : e.substr(0, s) + r[s] + n.substr(s + 1);
1591
- })(i, f, s[h], c[h], o, l);
1592
- g === null && m === null ? p = h + 1 : (m === null || 0 < o(m, g)) && (m = g);
1593
- }
1594
- n(m === null ? r : function() {
1595
- e.continue(m + u);
1596
- });
1597
- }
1598
- return !1;
1599
- }), e;
1600
- }
1601
- function zt(e, t, n, r) {
1602
- return {
1603
- type: 2,
1604
- lower: e,
1605
- upper: t,
1606
- lowerOpen: n,
1607
- upperOpen: r
1608
- };
1609
- }
1610
- function Bt(e) {
1611
- return {
1612
- type: 1,
1613
- lower: e,
1614
- upper: e
1615
- };
1616
- }
1617
- Object.defineProperty(J.prototype, "Collection", {
1618
- get: function() {
1619
- return this._ctx.table.db.Collection;
1620
- },
1621
- enumerable: !1,
1622
- configurable: !0
1623
- }), J.prototype.between = function(e, t, n, r) {
1624
- n = !1 !== n, r = !0 === r;
1625
- try {
1626
- return 0 < this._cmp(e, t) || this._cmp(e, t) === 0 && (n || r) && (!n || !r) ? Lt(this) : new this.Collection(this, function() {
1627
- return zt(e, t, !n, !r);
1628
- });
1629
- } catch {
1630
- return q(this, U);
1631
- }
1632
- }, J.prototype.equals = function(e) {
1633
- return e == null ? q(this, U) : new this.Collection(this, function() {
1634
- return Bt(e);
1635
- });
1636
- }, J.prototype.above = function(e) {
1637
- return e == null ? q(this, U) : new this.Collection(this, function() {
1638
- return zt(e, void 0, !0);
1639
- });
1640
- }, J.prototype.aboveOrEqual = function(e) {
1641
- return e == null ? q(this, U) : new this.Collection(this, function() {
1642
- return zt(e, void 0, !1);
1643
- });
1644
- }, J.prototype.below = function(e) {
1645
- return e == null ? q(this, U) : new this.Collection(this, function() {
1646
- return zt(void 0, e, !1, !0);
1647
- });
1648
- }, J.prototype.belowOrEqual = function(e) {
1649
- return e == null ? q(this, U) : new this.Collection(this, function() {
1650
- return zt(void 0, e);
1651
- });
1652
- }, J.prototype.startsWith = function(e) {
1653
- return typeof e == "string" ? this.between(e, e + ct, !0, !0) : q(this, lt);
1654
- }, J.prototype.startsWithIgnoreCase = function(e) {
1655
- return e === "" ? this.startsWith(e) : Rt(this, function(e, t) {
1656
- return e.indexOf(t[0]) === 0;
1657
- }, [e], ct);
1658
- }, J.prototype.equalsIgnoreCase = function(e) {
1659
- return Rt(this, function(e, t) {
1660
- return e === t[0];
1661
- }, [e], "");
1662
- }, J.prototype.anyOfIgnoreCase = function() {
1663
- var e = k.apply(O, arguments);
1664
- return e.length === 0 ? Lt(this) : Rt(this, function(e, t) {
1665
- return t.indexOf(e) !== -1;
1666
- }, e, "");
1667
- }, J.prototype.startsWithAnyOfIgnoreCase = function() {
1668
- var e = k.apply(O, arguments);
1669
- return e.length === 0 ? Lt(this) : Rt(this, function(e, t) {
1670
- return t.some(function(t) {
1671
- return e.indexOf(t) === 0;
1672
- });
1673
- }, e, ct);
1674
- }, J.prototype.anyOf = function() {
1675
- var e, t, n = this, r = k.apply(O, arguments), i = this._cmp;
1676
- try {
1677
- r.sort(i);
1678
- } catch {
1679
- return q(this, U);
1680
- }
1681
- return r.length === 0 ? Lt(this) : ((e = new this.Collection(this, function() {
1682
- return zt(r[0], r[r.length - 1]);
1683
- }))._ondirectionchange = function(e) {
1684
- i = e === "next" ? n._ascending : n._descending, r.sort(i);
1685
- }, t = 0, e._addAlgorithm(function(e, n, a) {
1686
- for (var o = e.key; 0 < i(o, r[t]);) if (++t === r.length) return n(a), !1;
1687
- return i(o, r[t]) === 0 || (n(function() {
1688
- e.continue(r[t]);
1689
- }), !1);
1690
- }), e);
1691
- }, J.prototype.notEqual = function(e) {
1692
- return this.inAnyRange([[-Infinity, e], [e, this.db._maxKey]], {
1693
- includeLowers: !1,
1694
- includeUppers: !1
1695
- });
1696
- }, J.prototype.noneOf = function() {
1697
- var e = k.apply(O, arguments);
1698
- if (e.length === 0) return new this.Collection(this);
1699
- try {
1700
- e.sort(this._ascending);
1701
- } catch {
1702
- return q(this, U);
1703
- }
1704
- var t = e.reduce(function(e, t) {
1705
- return e ? e.concat([[e[e.length - 1][1], t]]) : [[-Infinity, t]];
1706
- }, null);
1707
- return t.push([e[e.length - 1], this.db._maxKey]), this.inAnyRange(t, {
1708
- includeLowers: !1,
1709
- includeUppers: !1
1710
- });
1711
- }, J.prototype.inAnyRange = function(e, t) {
1712
- var n = this, r = this._cmp, i = this._ascending, a = this._descending, o = this._min, s = this._max;
1713
- if (e.length === 0) return Lt(this);
1714
- if (!e.every(function(e) {
1715
- return e[0] !== void 0 && e[1] !== void 0 && i(e[0], e[1]) <= 0;
1716
- })) return q(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", j.InvalidArgument);
1717
- var c = !t || !1 !== t.includeLowers, l = t && !0 === t.includeUppers, u, d = i;
1718
- function f(e, t) {
1719
- return d(e[0], t[0]);
1720
- }
1721
- try {
1722
- (u = e.reduce(function(e, t) {
1723
- for (var n = 0, i = e.length; n < i; ++n) {
1724
- var a = e[n];
1725
- if (r(t[0], a[1]) < 0 && 0 < r(t[1], a[0])) {
1726
- a[0] = o(a[0], t[0]), a[1] = s(a[1], t[1]);
1727
- break;
1728
- }
1729
- }
1730
- return n === i && e.push(t), e;
1731
- }, [])).sort(f);
1732
- } catch {
1733
- return q(this, U);
1734
- }
1735
- var p = 0, m = l ? function(e) {
1736
- return 0 < i(e, u[p][1]);
1737
- } : function(e) {
1738
- return 0 <= i(e, u[p][1]);
1739
- }, h = c ? function(e) {
1740
- return 0 < a(e, u[p][0]);
1741
- } : function(e) {
1742
- return 0 <= a(e, u[p][0]);
1743
- }, g = m, t = new this.Collection(this, function() {
1744
- return zt(u[0][0], u[u.length - 1][1], !c, !l);
1745
- });
1746
- return t._ondirectionchange = function(e) {
1747
- d = e === "next" ? (g = m, i) : (g = h, a), u.sort(f);
1748
- }, t._addAlgorithm(function(e, t, r) {
1749
- for (var a, o = e.key; g(o);) if (++p === u.length) return t(r), !1;
1750
- return !m(a = o) && !h(a) || (n._cmp(o, u[p][1]) === 0 || n._cmp(o, u[p][0]) === 0 || t(function() {
1751
- d === i ? e.continue(u[p][0]) : e.continue(u[p][1]);
1752
- }), !1);
1753
- }), t;
1754
- }, J.prototype.startsWithAnyOf = function() {
1755
- var e = k.apply(O, arguments);
1756
- return e.every(function(e) {
1757
- return typeof e == "string";
1758
- }) ? e.length === 0 ? Lt(this) : this.inAnyRange(e.map(function(e) {
1759
- return [e, e + ct];
1760
- })) : q(this, "startsWithAnyOf() only works with strings");
1761
- };
1762
- var Vt = J;
1763
- function J() {}
1764
- function Y(e) {
1765
- return B(function(t) {
1766
- return Ht(t), e(t.target.error), !1;
1767
- });
1768
- }
1769
- function Ht(e) {
1770
- e.stopPropagation && e.stopPropagation(), e.preventDefault && e.preventDefault();
1771
- }
1772
- var Ut = "storagemutated", Wt = "x-storagemutated-1", Gt = wt(null, Ut), Kt = (X.prototype._lock = function() {
1773
- return v(!R.global), ++this._reculock, this._reculock !== 1 || R.global || (R.lockOwnerFor = this), this;
1774
- }, X.prototype._unlock = function() {
1775
- if (v(!R.global), --this._reculock == 0) for (R.global || (R.lockOwnerFor = null); 0 < this._blockedFuncs.length && !this._locked();) {
1776
- var e = this._blockedFuncs.shift();
1777
- try {
1778
- at(e[1], e[0]);
1779
- } catch {}
1780
- }
1781
- return this;
1782
- }, X.prototype._locked = function() {
1783
- return this._reculock && R.lockOwnerFor !== this;
1784
- }, X.prototype.create = function(e) {
1785
- var t = this;
1786
- if (this.mode) {
1787
- var n = this.db.idbdb, r = this.db._state.dbOpenError;
1788
- if (v(!this.idbtrans), !e && !n) switch (r && r.name) {
1789
- case "DatabaseClosedError": throw new j.DatabaseClosed(r);
1790
- case "MissingAPIError": throw new j.MissingAPI(r.message, r);
1791
- default: throw new j.OpenFailed(r);
1792
- }
1793
- if (!this.active) throw new j.TransactionInactive();
1794
- v(this._completion._state === null), (e = this.idbtrans = e || (this.db.core || n).transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability })).onerror = B(function(n) {
1795
- Ht(n), t._reject(e.error);
1796
- }), e.onabort = B(function(n) {
1797
- Ht(n), t.active && t._reject(new j.Abort(e.error)), t.active = !1, t.on("abort").fire(n);
1798
- }), e.oncomplete = B(function() {
1799
- t.active = !1, t._resolve(), "mutatedParts" in e && Gt.storagemutated.fire(e.mutatedParts);
1800
- });
1801
- }
1802
- return this;
1803
- }, X.prototype._promise = function(e, t, n) {
1804
- var r, i = this;
1805
- return e === "readwrite" && this.mode !== "readwrite" ? H(new j.ReadOnly("Transaction is readonly")) : this.active ? this._locked() ? new z(function(r, a) {
1806
- i._blockedFuncs.push([function() {
1807
- i._promise(e, t, n).then(r, a);
1808
- }, R]);
1809
- }) : n ? Qe(function() {
1810
- var e = new z(function(e, n) {
1811
- i._lock();
1812
- var r = t(e, n, i);
1813
- r && r.then && r.then(e, n);
1814
- });
1815
- return e.finally(function() {
1816
- return i._unlock();
1817
- }), e._lib = !0, e;
1818
- }) : ((r = new z(function(e, n) {
1819
- var r = t(e, n, i);
1820
- r && r.then && r.then(e, n);
1821
- }))._lib = !0, r) : H(new j.TransactionInactive());
1822
- }, X.prototype._root = function() {
1823
- return this.parent ? this.parent._root() : this;
1824
- }, X.prototype.waitFor = function(e) {
1825
- var t, n = this._root(), r = z.resolve(e), i = (n._waitingFor ? n._waitingFor = n._waitingFor.then(function() {
1826
- return r;
1827
- }) : (n._waitingFor = r, n._waitingQueue = [], t = n.idbtrans.objectStore(n.storeNames[0]), function e() {
1828
- for (++n._spinCount; n._waitingQueue.length;) n._waitingQueue.shift()();
1829
- n._waitingFor && (t.get(-Infinity).onsuccess = e);
1830
- }()), n._waitingFor);
1831
- return new z(function(e, t) {
1832
- r.then(function(t) {
1833
- return n._waitingQueue.push(B(e.bind(null, t)));
1834
- }, function(e) {
1835
- return n._waitingQueue.push(B(t.bind(null, e)));
1836
- }).finally(function() {
1837
- n._waitingFor === i && (n._waitingFor = null);
1838
- });
1839
- });
1840
- }, X.prototype.abort = function() {
1841
- this.active && (this.active = !1, this.idbtrans && this.idbtrans.abort(), this._reject(new j.Abort()));
1842
- }, X.prototype.table = function(e) {
1843
- var t = this._memoizedTables ||= {};
1844
- if (l(t, e)) return t[e];
1845
- var n = this.schema[e];
1846
- if (n) return (n = new this.db.Table(e, n, this)).core = this.db.core.table(e), t[e] = n;
1847
- throw new j.NotFound("Table " + e + " not part of transaction");
1848
- }, X);
1849
- function X() {}
1850
- function qt(e, t, n, r, i, a, o, s) {
1851
- return {
1852
- name: e,
1853
- keyPath: t,
1854
- unique: n,
1855
- multi: r,
1856
- auto: i,
1857
- compound: a,
1858
- src: (n && !o ? "&" : "") + (r ? "*" : "") + (i ? "++" : "") + Jt(t),
1859
- type: s
1860
- };
1861
- }
1862
- function Jt(e) {
1863
- return typeof e == "string" ? e : e ? "[" + [].join.call(e, "+") + "]" : "";
1864
- }
1865
- function Yt(e, t, n) {
1866
- return {
1867
- name: e,
1868
- primKey: t,
1869
- indexes: n,
1870
- mappedClass: null,
1871
- idxByName: (r = function(e) {
1872
- return [e.name, e];
1873
- }, n.reduce(function(e, t, n) {
1874
- return t = r(t, n), t && (e[t[0]] = t[1]), e;
1875
- }, {}))
1876
- };
1877
- var r;
1878
- }
1879
- var Xt = function(e) {
1880
- try {
1881
- return e.only([[]]), Xt = function() {
1882
- return [[]];
1883
- }, [[]];
1884
- } catch {
1885
- return Xt = function() {
1886
- return ct;
1887
- }, ct;
1888
- }
1889
- };
1890
- function Zt(e) {
1891
- return e == null ? function() {} : typeof e == "string" ? (t = e).split(".").length === 1 ? function(e) {
1892
- return e[t];
1893
- } : function(e) {
1894
- return b(e, t);
1895
- } : function(t) {
1896
- return b(t, e);
1897
- };
1898
- var t;
1899
- }
1900
- function Qt(e) {
1901
- return [].slice.call(e);
1902
- }
1903
- var $t = 0;
1904
- function en(e) {
1905
- return e == null ? ":id" : typeof e == "string" ? e : `[${e.join("+")}]`;
1906
- }
1907
- function tn(e, t, n) {
1908
- function r(e) {
1909
- if (e.type === 3) return null;
1910
- if (e.type === 4) throw Error("Cannot convert never type to IDBKeyRange");
1911
- var n = e.lower, r = e.upper, i = e.lowerOpen, e = e.upperOpen;
1912
- return n === void 0 ? r === void 0 ? null : t.upperBound(r, !!e) : r === void 0 ? t.lowerBound(n, !!i) : t.bound(n, r, !!i, !!e);
1913
- }
1914
- function i(e) {
1915
- var t, n, i = e.name;
1916
- return {
1917
- name: i,
1918
- schema: e,
1919
- mutate: function(e) {
1920
- var t = e.trans, n = e.type, a = e.keys, o = e.values, s = e.range;
1921
- return new Promise(function(e, c) {
1922
- e = B(e);
1923
- var l = t.objectStore(i), u = l.keyPath == null, d = n === "put" || n === "add";
1924
- if (!d && n !== "delete" && n !== "deleteRange") throw Error("Invalid operation type: " + n);
1925
- var f, p = (a || o || { length: 1 }).length;
1926
- if (a && o && a.length !== o.length) throw Error("Given keys array must have same length as given values array.");
1927
- if (p === 0) return e({
1928
- numFailures: 0,
1929
- failures: {},
1930
- results: [],
1931
- lastResult: void 0
1932
- });
1933
- function m(e) {
1934
- ++_, Ht(e);
1935
- }
1936
- var h = [], g = [], _ = 0;
1937
- if (n === "deleteRange") {
1938
- if (s.type === 4) return e({
1939
- numFailures: _,
1940
- failures: g,
1941
- results: [],
1942
- lastResult: void 0
1943
- });
1944
- s.type === 3 ? h.push(f = l.clear()) : h.push(f = l.delete(r(s)));
1945
- } else {
1946
- var u = d ? u ? [o, a] : [o, null] : [a, null], v = u[0], y = u[1];
1947
- if (d) for (var b = 0; b < p; ++b) h.push(f = y && y[b] !== void 0 ? l[n](v[b], y[b]) : l[n](v[b])), f.onerror = m;
1948
- else for (b = 0; b < p; ++b) h.push(f = l[n](v[b])), f.onerror = m;
1949
- }
1950
- function x(t) {
1951
- t = t.target.result, h.forEach(function(e, t) {
1952
- return e.error != null && (g[t] = e.error);
1953
- }), e({
1954
- numFailures: _,
1955
- failures: g,
1956
- results: n === "delete" ? a : h.map(function(e) {
1957
- return e.result;
1958
- }),
1959
- lastResult: t
1960
- });
1961
- }
1962
- f.onerror = function(e) {
1963
- m(e), x(e);
1964
- }, f.onsuccess = x;
1965
- });
1966
- },
1967
- getMany: function(e) {
1968
- var t = e.trans, n = e.keys;
1969
- return new Promise(function(e, r) {
1970
- e = B(e);
1971
- for (var a, o = t.objectStore(i), s = n.length, c = Array(s), l = 0, u = 0, d = function(t) {
1972
- t = t.target, c[t._pos] = t.result, ++u === l && e(c);
1973
- }, f = Y(r), p = 0; p < s; ++p) n[p] != null && ((a = o.get(n[p]))._pos = p, a.onsuccess = d, a.onerror = f, ++l);
1974
- l === 0 && e(c);
1975
- });
1976
- },
1977
- get: function(e) {
1978
- var t = e.trans, n = e.key;
1979
- return new Promise(function(e, r) {
1980
- e = B(e);
1981
- var a = t.objectStore(i).get(n);
1982
- a.onsuccess = function(t) {
1983
- return e(t.target.result);
1984
- }, a.onerror = Y(r);
1985
- });
1986
- },
1987
- query: (t = c, n = l, function(e) {
1988
- return new Promise(function(a, o) {
1989
- a = B(a);
1990
- var s, c, l, u, d = e.trans, f = e.values, p = e.limit, m = e.query, h = (h = e.direction) ?? "next", g = p === Infinity ? void 0 : p, _ = m.index, m = m.range, d = d.objectStore(i), d = _.isPrimaryKey ? d : d.index(_.name), _ = r(m);
1991
- if (p === 0) return a({ result: [] });
1992
- n ? (m = {
1993
- query: _,
1994
- count: g,
1995
- direction: h
1996
- }, (s = f ? d.getAll(m) : d.getAllKeys(m)).onsuccess = function(e) {
1997
- return a({ result: e.target.result });
1998
- }, s.onerror = Y(o)) : t && h === "next" ? ((s = f ? d.getAll(_, g) : d.getAllKeys(_, g)).onsuccess = function(e) {
1999
- return a({ result: e.target.result });
2000
- }, s.onerror = Y(o)) : (c = 0, l = !f && "openKeyCursor" in d ? d.openKeyCursor(_, h) : d.openCursor(_, h), u = [], l.onsuccess = function() {
2001
- var e = l.result;
2002
- return !e || (u.push(f ? e.value : e.primaryKey), ++c === p) ? a({ result: u }) : void e.continue();
2003
- }, l.onerror = Y(o));
2004
- });
2005
- }),
2006
- openCursor: function(e) {
2007
- var t = e.trans, n = e.values, a = e.query, o = e.reverse, s = e.unique;
2008
- return new Promise(function(e, c) {
2009
- e = B(e);
2010
- var l = a.index, u = a.range, d = t.objectStore(i), d = l.isPrimaryKey ? d : d.index(l.name), l = o ? s ? "prevunique" : "prev" : s ? "nextunique" : "next", f = !n && "openKeyCursor" in d ? d.openKeyCursor(r(u), l) : d.openCursor(r(u), l);
2011
- f.onerror = Y(c), f.onsuccess = B(function(n) {
2012
- var r, i, a, o, s = f.result;
2013
- s ? (s.___id = ++$t, s.done = !1, r = s.continue.bind(s), i = (i = s.continuePrimaryKey) && i.bind(s), a = s.advance.bind(s), o = function() {
2014
- throw Error("Cursor not stopped");
2015
- }, s.trans = t, s.stop = s.continue = s.continuePrimaryKey = s.advance = function() {
2016
- throw Error("Cursor not started");
2017
- }, s.fail = B(c), s.next = function() {
2018
- var e = this, t = 1;
2019
- return this.start(function() {
2020
- return t-- ? e.continue() : e.stop();
2021
- }).then(function() {
2022
- return e;
2023
- });
2024
- }, s.start = function(e) {
2025
- function t() {
2026
- if (f.result) try {
2027
- e();
2028
- } catch (e) {
2029
- s.fail(e);
2030
- }
2031
- else s.done = !0, s.start = function() {
2032
- throw Error("Cursor behind last entry");
2033
- }, s.stop();
2034
- }
2035
- var n = new Promise(function(e, t) {
2036
- e = B(e), f.onerror = Y(t), s.fail = t, s.stop = function(t) {
2037
- s.stop = s.continue = s.continuePrimaryKey = s.advance = o, e(t);
2038
- };
2039
- });
2040
- return f.onsuccess = B(function(e) {
2041
- f.onsuccess = t, t();
2042
- }), s.continue = r, s.continuePrimaryKey = i, s.advance = a, t(), n;
2043
- }, e(s)) : e(null);
2044
- }, c);
2045
- });
2046
- },
2047
- count: function(e) {
2048
- var t = e.query, n = e.trans, a = t.index, o = t.range;
2049
- return new Promise(function(e, t) {
2050
- var s = n.objectStore(i), s = a.isPrimaryKey ? s : s.index(a.name), c = r(o), c = c ? s.count(c) : s.count();
2051
- c.onsuccess = B(function(t) {
2052
- return e(t.target.result);
2053
- }), c.onerror = Y(t);
2054
- });
2055
- }
2056
- };
2057
- }
2058
- o = n, s = Qt((n = e).objectStoreNames), u = 0 < s.length ? o.objectStore(s[0]) : {};
2059
- var o, n = {
2060
- schema: {
2061
- name: n.name,
2062
- tables: s.map(function(e) {
2063
- return o.objectStore(e);
2064
- }).map(function(e) {
2065
- var t = e.keyPath, n = e.autoIncrement, r = a(t), i = {}, r = {
2066
- name: e.name,
2067
- primaryKey: {
2068
- name: null,
2069
- isPrimaryKey: !0,
2070
- outbound: t == null,
2071
- compound: r,
2072
- keyPath: t,
2073
- autoIncrement: n,
2074
- unique: !0,
2075
- extractKey: Zt(t)
2076
- },
2077
- indexes: Qt(e.indexNames).map(function(t) {
2078
- return e.index(t);
2079
- }).map(function(e) {
2080
- var t = e.name, n = e.unique, r = e.multiEntry, e = e.keyPath, t = {
2081
- name: t,
2082
- compound: a(e),
2083
- keyPath: e,
2084
- unique: n,
2085
- multiEntry: r,
2086
- extractKey: Zt(e)
2087
- };
2088
- return i[en(e)] = t;
2089
- }),
2090
- getIndexByKeyPath: function(e) {
2091
- return i[en(e)];
2092
- }
2093
- };
2094
- return i[":id"] = r.primaryKey, t != null && (i[en(t)] = r.primaryKey), r;
2095
- })
2096
- },
2097
- hasGetAll: 0 < s.length && "getAll" in u && !(typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604),
2098
- hasIdb3Features: "getAllRecords" in u
2099
- }, s = n.schema, c = n.hasGetAll, l = n.hasIdb3Features, u = s.tables.map(i), d = {};
2100
- return u.forEach(function(e) {
2101
- return d[e.name] = e;
2102
- }), {
2103
- stack: "dbcore",
2104
- transaction: e.transaction.bind(e),
2105
- table: function(e) {
2106
- if (d[e]) return d[e];
2107
- throw Error(`Table '${e}' not found`);
2108
- },
2109
- MIN_KEY: -Infinity,
2110
- MAX_KEY: Xt(t),
2111
- schema: s
2112
- };
2113
- }
2114
- function nn(e, n, r, i) {
2115
- return r = r.IDBKeyRange, n = tn(n, r, i), { dbcore: e.dbcore.reduce(function(e, n) {
2116
- return n = n.create, t(t({}, e), n(e));
2117
- }, n) };
2118
- }
2119
- function rn(e, t) {
2120
- var n = t.db, n = nn(e._middlewares, n, e._deps, t);
2121
- e.core = n.dbcore, e.tables.forEach(function(t) {
2122
- var n = t.name;
2123
- e.core.schema.tables.some(function(e) {
2124
- return e.name === n;
2125
- }) && (t.core = e.core.table(n), e[n] instanceof e.Table) && (e[n].core = t.core);
2126
- });
2127
- }
2128
- function an(e, t, n, r) {
2129
- n.forEach(function(n) {
2130
- var i = r[n];
2131
- t.forEach(function(t) {
2132
- var r = function e(t, n) {
2133
- return m(t, n) || (t = s(t)) && e(t, n);
2134
- }(t, n);
2135
- (!r || "value" in r && r.value === void 0) && (t === e.Transaction.prototype || t instanceof e.Transaction ? f(t, n, {
2136
- get: function() {
2137
- return this.table(n);
2138
- },
2139
- set: function(e) {
2140
- d(this, n, {
2141
- value: e,
2142
- writable: !0,
2143
- configurable: !0,
2144
- enumerable: !0
2145
- });
2146
- }
2147
- }) : t[n] = new e.Table(n, i));
2148
- });
2149
- });
2150
- }
2151
- function on(e, t) {
2152
- t.forEach(function(t) {
2153
- for (var n in t) t[n] instanceof e.Table && delete t[n];
2154
- });
2155
- }
2156
- function sn(e, t) {
2157
- return e._cfg.version - t._cfg.version;
2158
- }
2159
- function cn(e, t, n, r) {
2160
- var a = e._dbSchema, o = (n.objectStoreNames.contains("$meta") && !a.$meta && (a.$meta = Yt("$meta", gn("")[0], []), e._storeNames.push("$meta")), e._createTransaction("readwrite", e._storeNames, a)), s = (o.create(n), o._completion.catch(r), o._reject.bind(o)), c = R.transless || R;
2161
- Qe(function() {
2162
- if (R.trans = o, R.transless = c, t !== 0) return rn(e, n), l = t, ((r = o).storeNames.includes("$meta") ? r.table("$meta").get("version").then(function(e) {
2163
- return e ?? l;
2164
- }) : z.resolve(l)).then(function(t) {
2165
- var r = e, a = t, s = o, c = n, l = [], t = r._versions, u = r._dbSchema = mn(0, r.idbdb, c);
2166
- return (t = t.filter(function(e) {
2167
- return e._cfg.version >= a;
2168
- })).length === 0 ? z.resolve() : (t.forEach(function(e) {
2169
- l.push(function() {
2170
- var t, n, o, l = u, d = e._cfg.dbschema, f = (hn(r, l, c), hn(r, d, c), u = r._dbSchema = d, un(l, d)), p = (f.add.forEach(function(e) {
2171
- dn(c, e[0], e[1].primKey, e[1].indexes);
2172
- }), f.change.forEach(function(e) {
2173
- if (e.recreate) throw new j.Upgrade("Not yet support for changing primary key");
2174
- var t = c.objectStore(e.name);
2175
- e.add.forEach(function(e) {
2176
- return pn(t, e);
2177
- }), e.change.forEach(function(e) {
2178
- t.deleteIndex(e.name), pn(t, e);
2179
- }), e.del.forEach(function(e) {
2180
- return t.deleteIndex(e);
2181
- });
2182
- }), e._cfg.contentUpgrade);
2183
- if (p && e._cfg.version > a) return rn(r, c), s._memoizedTables = {}, t = S(d), f.del.forEach(function(e) {
2184
- t[e] = l[e];
2185
- }), on(r, [r.Transaction.prototype]), an(r, [r.Transaction.prototype], i(t), t), s.schema = t, (n = oe(p)) && $e(), d = z.follow(function() {
2186
- var e;
2187
- (o = p(s)) && n && (e = et.bind(null, null), o.then(e, e));
2188
- }), o && typeof o.then == "function" ? z.resolve(o) : d.then(function() {
2189
- return o;
2190
- });
2191
- }), l.push(function(t) {
2192
- var n = e._cfg.dbschema, i = t;
2193
- [].slice.call(i.db.objectStoreNames).forEach(function(e) {
2194
- return n[e] == null && i.db.deleteObjectStore(e);
2195
- }), on(r, [r.Transaction.prototype]), an(r, [r.Transaction.prototype], r._storeNames, r._dbSchema), s.schema = r._dbSchema;
2196
- }), l.push(function(t) {
2197
- r.idbdb.objectStoreNames.contains("$meta") && (Math.ceil(r.idbdb.version / 10) === e._cfg.version ? (r.idbdb.deleteObjectStore("$meta"), delete r._dbSchema.$meta, r._storeNames = r._storeNames.filter(function(e) {
2198
- return e !== "$meta";
2199
- })) : t.objectStore("$meta").put(e._cfg.version, "version"));
2200
- });
2201
- }), function e() {
2202
- return l.length ? z.resolve(l.shift()(s.idbtrans)).then(e) : z.resolve();
2203
- }().then(function() {
2204
- fn(u, c);
2205
- }));
2206
- }).catch(s);
2207
- var r, l;
2208
- i(a).forEach(function(e) {
2209
- dn(n, e, a[e].primKey, a[e].indexes);
2210
- }), rn(e, n), z.follow(function() {
2211
- return e.on.populate.fire(o);
2212
- }).catch(s);
2213
- });
2214
- }
2215
- function ln(e, t) {
2216
- fn(e._dbSchema, t), t.db.version % 10 != 0 || t.objectStoreNames.contains("$meta") || t.db.createObjectStore("$meta").add(Math.ceil(t.db.version / 10 - 1), "version");
2217
- var n = mn(0, e.idbdb, t);
2218
- hn(e, e._dbSchema, t);
2219
- for (var r = 0, i = un(n, e._dbSchema).change; r < i.length; r++) {
2220
- var a = ((e) => {
2221
- if (e.change.length || e.recreate) return console.warn(`Unable to patch indexes of table ${e.name} because it has changes on the type of index or primary key.`), { value: void 0 };
2222
- var n = t.objectStore(e.name);
2223
- e.add.forEach(function(t) {
2224
- F && console.debug(`Dexie upgrade patch: Creating missing index ${e.name}.${t.src}`), pn(n, t);
2225
- });
2226
- })(i[r]);
2227
- if (typeof a == "object") return a.value;
2228
- }
2229
- }
2230
- function un(e, t) {
2231
- var n, r = {
2232
- del: [],
2233
- add: [],
2234
- change: []
2235
- };
2236
- for (n in e) t[n] || r.del.push(n);
2237
- for (n in t) {
2238
- var i = e[n], a = t[n];
2239
- if (i) {
2240
- var o = {
2241
- name: n,
2242
- def: a,
2243
- recreate: !1,
2244
- del: [],
2245
- add: [],
2246
- change: []
2247
- };
2248
- if ("" + (i.primKey.keyPath || "") != "" + (a.primKey.keyPath || "") || i.primKey.auto !== a.primKey.auto) o.recreate = !0, r.change.push(o);
2249
- else {
2250
- var s = i.idxByName, c = a.idxByName, l = void 0;
2251
- for (l in s) c[l] || o.del.push(l);
2252
- for (l in c) {
2253
- var u = s[l], d = c[l];
2254
- u ? u.src !== d.src && o.change.push(d) : o.add.push(d);
2255
- }
2256
- (0 < o.del.length || 0 < o.add.length || 0 < o.change.length) && r.change.push(o);
2257
- }
2258
- } else r.add.push([n, a]);
2259
- }
2260
- return r;
2261
- }
2262
- function dn(e, t, n, r) {
2263
- var i = e.db.createObjectStore(t, n.keyPath ? {
2264
- keyPath: n.keyPath,
2265
- autoIncrement: n.auto
2266
- } : { autoIncrement: n.auto });
2267
- r.forEach(function(e) {
2268
- return pn(i, e);
2269
- });
2270
- }
2271
- function fn(e, t) {
2272
- i(e).forEach(function(n) {
2273
- t.db.objectStoreNames.contains(n) || (F && console.debug("Dexie: Creating missing table", n), dn(t, n, e[n].primKey, e[n].indexes));
2274
- });
2275
- }
2276
- function pn(e, t) {
2277
- e.createIndex(t.name, t.keyPath, {
2278
- unique: t.unique,
2279
- multiEntry: t.multi
2280
- });
2281
- }
2282
- function mn(e, t, n) {
2283
- var r = {};
2284
- return g(t.objectStoreNames, 0).forEach(function(e) {
2285
- for (var t = n.objectStore(e), i = qt(Jt(c = t.keyPath), c || "", !0, !1, !!t.autoIncrement, c && typeof c != "string", !0), a = [], o = 0; o < t.indexNames.length; ++o) {
2286
- var s = t.index(t.indexNames[o]), c = s.keyPath, s = qt(s.name, c, !!s.unique, !!s.multiEntry, !1, c && typeof c != "string", !1);
2287
- a.push(s);
2288
- }
2289
- r[e] = Yt(e, i, a);
2290
- }), r;
2291
- }
2292
- function hn(e, t, n) {
2293
- for (var i = n.db.objectStoreNames, a = 0; a < i.length; ++a) {
2294
- var o = i[a], s = n.objectStore(o);
2295
- e._hasGetAll = "getAll" in s;
2296
- for (var c = 0; c < s.indexNames.length; ++c) {
2297
- var l, u = s.indexNames[c], d = s.index(u).keyPath, d = typeof d == "string" ? d : "[" + g(d).join("+") + "]";
2298
- t[o] && (l = t[o].idxByName[d]) && (l.name = u, delete t[o].idxByName[d], t[o].idxByName[u] = l);
2299
- }
2300
- }
2301
- typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && r.WorkerGlobalScope && r instanceof r.WorkerGlobalScope && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604 && (e._hasGetAll = !1);
2302
- }
2303
- function gn(e) {
2304
- return e.split(",").map(function(e, t) {
2305
- var n = e.split(":"), r = (r = n[1])?.trim(), n = (e = n[0].trim()).replace(/([&*]|\+\+)/g, ""), i = /^\[/.test(n) ? n.match(/^\[(.*)\]$/)[1].split("+") : n;
2306
- return qt(n, i || null, /\&/.test(e), /\*/.test(e), /\+\+/.test(e), a(i), t === 0, r);
2307
- });
2308
- }
2309
- vn.prototype._createTableSchema = Yt, vn.prototype._parseIndexSyntax = gn, vn.prototype._parseStoresSpec = function(e, t) {
2310
- var n = this;
2311
- i(e).forEach(function(r) {
2312
- if (e[r] !== null) {
2313
- var i = n._parseIndexSyntax(e[r]), a = i.shift();
2314
- if (!a) throw new j.Schema("Invalid schema for table " + r + ": " + e[r]);
2315
- if (a.unique = !0, a.multi) throw new j.Schema("Primary key cannot be multiEntry*");
2316
- i.forEach(function(e) {
2317
- if (e.auto) throw new j.Schema("Only primary key can be marked as autoIncrement (++)");
2318
- if (!e.keyPath) throw new j.Schema("Index must have a name and cannot be an empty string");
2319
- }), a = n._createTableSchema(r, a, i), t[r] = a;
2320
- }
2321
- });
2322
- }, vn.prototype.stores = function(e) {
2323
- var t = this.db, e = (this._cfg.storesSource = this._cfg.storesSource ? o(this._cfg.storesSource, e) : e, t._versions), n = {}, r = {};
2324
- return e.forEach(function(e) {
2325
- o(n, e._cfg.storesSource), r = e._cfg.dbschema = {}, e._parseStoresSpec(n, r);
2326
- }), t._dbSchema = r, on(t, [
2327
- t._allTables,
2328
- t,
2329
- t.Transaction.prototype
2330
- ]), an(t, [
2331
- t._allTables,
2332
- t,
2333
- t.Transaction.prototype,
2334
- this._cfg.tables
2335
- ], i(r), r), t._storeNames = i(r), this;
2336
- }, vn.prototype.upgrade = function(e) {
2337
- return this._cfg.contentUpgrade = be(this._cfg.contentUpgrade || M, e), this;
2338
- };
2339
- var _n = vn;
2340
- function vn() {}
2341
- var yn = (() => {
2342
- var e, t, n;
2343
- return typeof FinalizationRegistry < "u" && typeof WeakRef < "u" ? (e = /* @__PURE__ */ new Set(), t = new FinalizationRegistry(function(t) {
2344
- e.delete(t);
2345
- }), {
2346
- toArray: function() {
2347
- return Array.from(e).map(function(e) {
2348
- return e.deref();
2349
- }).filter(function(e) {
2350
- return e !== void 0;
2351
- });
2352
- },
2353
- add: function(n) {
2354
- var r = new WeakRef(n._novip);
2355
- e.add(r), t.register(n._novip, r, r), e.size > n._options.maxConnections && (r = e.values().next().value, e.delete(r), t.unregister(r));
2356
- },
2357
- remove: function(n) {
2358
- if (n) for (var r = e.values(), i = r.next(); !i.done;) {
2359
- var a = i.value;
2360
- if (a.deref() === n._novip) return e.delete(a), void t.unregister(a);
2361
- i = r.next();
2362
- }
2363
- }
2364
- }) : (n = [], {
2365
- toArray: function() {
2366
- return n;
2367
- },
2368
- add: function(e) {
2369
- n.push(e._novip);
2370
- },
2371
- remove: function(e) {
2372
- e && (e = n.indexOf(e._novip)) !== -1 && n.splice(e, 1);
2373
- }
2374
- });
2375
- })();
2376
- function bn(e, t) {
2377
- var n = e._dbNamesDB;
2378
- return n || (n = e._dbNamesDB = new Q(ut, {
2379
- addons: [],
2380
- indexedDB: e,
2381
- IDBKeyRange: t
2382
- })).version(1).stores({ dbnames: "name" }), n.table("dbnames");
2383
- }
2384
- function xn(e) {
2385
- return e && typeof e.databases == "function";
2386
- }
2387
- function Sn(e) {
2388
- return Qe(function() {
2389
- return R.letThrough = !0, e();
2390
- });
2391
- }
2392
- function Cn(e) {
2393
- return !("from" in e);
2394
- }
2395
- var Z = function(e, t) {
2396
- var n;
2397
- if (!this) return n = new Z(), e && "d" in e && o(n, e), n;
2398
- o(this, arguments.length ? {
2399
- d: 1,
2400
- from: e,
2401
- to: 1 < arguments.length ? t : e
2402
- } : { d: 0 });
2403
- };
2404
- function wn(e, t, n) {
2405
- var r = W(t, n);
2406
- if (!isNaN(r)) {
2407
- if (0 < r) throw RangeError();
2408
- if (Cn(e)) return o(e, {
2409
- from: t,
2410
- to: n,
2411
- d: 1
2412
- });
2413
- var r = e.l, i = e.r;
2414
- if (W(n, e.from) < 0) return r ? wn(r, t, n) : e.l = {
2415
- from: t,
2416
- to: n,
2417
- d: 1,
2418
- l: null,
2419
- r: null
2420
- }, On(e);
2421
- if (0 < W(t, e.to)) return i ? wn(i, t, n) : e.r = {
2422
- from: t,
2423
- to: n,
2424
- d: 1,
2425
- l: null,
2426
- r: null
2427
- }, On(e);
2428
- W(t, e.from) < 0 && (e.from = t, e.l = null, e.d = i ? i.d + 1 : 1), 0 < W(n, e.to) && (e.to = n, e.r = null, e.d = e.l ? e.l.d + 1 : 1), t = !e.r, r && !e.l && Tn(e, r), i && t && Tn(e, i);
2429
- }
2430
- }
2431
- function Tn(e, t) {
2432
- Cn(t) || function e(t, n) {
2433
- var r = n.from, i = n.l, a = n.r;
2434
- wn(t, r, n.to), i && e(t, i), a && e(t, a);
2435
- }(e, t);
2436
- }
2437
- function En(e, t) {
2438
- var n = Dn(t), r = n.next();
2439
- if (!r.done) for (var i = r.value, a = Dn(e), o = a.next(i.from), s = o.value; !r.done && !o.done;) {
2440
- if (W(s.from, i.to) <= 0 && 0 <= W(s.to, i.from)) return !0;
2441
- W(i.from, s.from) < 0 ? i = (r = n.next(s.from)).value : s = (o = a.next(i.from)).value;
2442
- }
2443
- return !1;
2444
- }
2445
- function Dn(e) {
2446
- var t = Cn(e) ? null : {
2447
- s: 0,
2448
- n: e
2449
- };
2450
- return { next: function(e) {
2451
- for (var n = 0 < arguments.length; t;) switch (t.s) {
2452
- case 0: if (t.s = 1, n) for (; t.n.l && W(e, t.n.from) < 0;) t = {
2453
- up: t,
2454
- n: t.n.l,
2455
- s: 1
2456
- };
2457
- else for (; t.n.l;) t = {
2458
- up: t,
2459
- n: t.n.l,
2460
- s: 1
2461
- };
2462
- case 1: if (t.s = 2, !n || W(e, t.n.to) <= 0) return {
2463
- value: t.n,
2464
- done: !1
2465
- };
2466
- case 2: if (t.n.r) {
2467
- t.s = 3, t = {
2468
- up: t,
2469
- n: t.n.r,
2470
- s: 0
2471
- };
2472
- continue;
2473
- }
2474
- case 3: t = t.up;
2475
- }
2476
- return { done: !0 };
2477
- } };
2478
- }
2479
- function On(e) {
2480
- var n, r, i, a = ((a = e.r)?.d || 0) - ((a = e.l)?.d || 0), a = 1 < a ? "r" : a < -1 ? "l" : "";
2481
- a && (n = a == "r" ? "l" : "r", r = t({}, e), i = e[a], e.from = i.from, e.to = i.to, e[a] = i[a], r[a] = i[n], (e[n] = r).d = kn(r)), e.d = kn(e);
2482
- }
2483
- function kn(e) {
2484
- var t = e.r, e = e.l;
2485
- return (t ? e ? Math.max(t.d, e.d) : t.d : e ? e.d : 0) + 1;
2486
- }
2487
- function An(e, t) {
2488
- return i(t).forEach(function(n) {
2489
- e[n] ? Tn(e[n], t[n]) : e[n] = function e(t) {
2490
- var n, r, i = {};
2491
- for (n in t) l(t, n) && (r = t[n], i[n] = !r || typeof r != "object" || te.has(r.constructor) ? r : e(r));
2492
- return i;
2493
- }(t[n]);
2494
- }), e;
2495
- }
2496
- function jn(e, t) {
2497
- return e.all || t.all || Object.keys(e).some(function(n) {
2498
- return t[n] && En(t[n], e[n]);
2499
- });
2500
- }
2501
- u(Z.prototype, ((A = {
2502
- add: function(e) {
2503
- return Tn(this, e), this;
2504
- },
2505
- addKey: function(e) {
2506
- return wn(this, e, e), this;
2507
- },
2508
- addKeys: function(e) {
2509
- var t = this;
2510
- return e.forEach(function(e) {
2511
- return wn(t, e, e);
2512
- }), this;
2513
- },
2514
- hasKey: function(e) {
2515
- var t = Dn(this).next(e).value;
2516
- return t && W(t.from, e) <= 0 && 0 <= W(t.to, e);
2517
- }
2518
- })[ie] = function() {
2519
- return Dn(this);
2520
- }, A));
2521
- var Mn = {}, Nn = {}, Pn = !1;
2522
- function Fn(e) {
2523
- An(Nn, e), Pn || (Pn = !0, setTimeout(function() {
2524
- Pn = !1, In(Nn, !(Nn = {}));
2525
- }, 0));
2526
- }
2527
- function In(e, t) {
2528
- t === void 0 && (t = !1);
2529
- var n = /* @__PURE__ */ new Set();
2530
- if (e.all) for (var r = 0, i = Object.values(Mn); r < i.length; r++) Ln(s = i[r], e, n, t);
2531
- else for (var a in e) {
2532
- var o, s, a = /^idb\:\/\/(.*)\/(.*)\//.exec(a);
2533
- a && (o = a[1], a = a[2], s = Mn[`idb://${o}/${a}`]) && Ln(s, e, n, t);
2534
- }
2535
- n.forEach(function(e) {
2536
- return e();
2537
- });
2538
- }
2539
- function Ln(e, t, n, r) {
2540
- for (var i = [], a = 0, o = Object.entries(e.queries.query); a < o.length; a++) {
2541
- for (var s = o[a], c = s[0], l = [], u = 0, d = s[1]; u < d.length; u++) {
2542
- var f = d[u];
2543
- jn(t, f.obsSet) ? f.subscribers.forEach(function(e) {
2544
- return n.add(e);
2545
- }) : r && l.push(f);
2546
- }
2547
- r && i.push([c, l]);
2548
- }
2549
- if (r) for (var p = 0, m = i; p < m.length; p++) {
2550
- var h = m[p], c = h[0], l = h[1];
2551
- e.queries.query[c] = l;
2552
- }
2553
- }
2554
- function Rn(e) {
2555
- var t = e._state, n = e._deps.indexedDB;
2556
- if (t.isBeingOpened || e.idbdb) return t.dbReadyPromise.then(function() {
2557
- return t.dbOpenError ? H(t.dbOpenError) : e;
2558
- });
2559
- t.isBeingOpened = !0, t.dbOpenError = null, t.openComplete = !1;
2560
- var r = t.openCanceller, a = Math.round(10 * e.verno), o = !1;
2561
- function s() {
2562
- if (t.openCanceller !== r) throw new j.DatabaseClosed("db.open() was cancelled");
2563
- }
2564
- function c() {
2565
- return new z(function(r, l) {
2566
- if (s(), !n) throw new j.MissingAPI();
2567
- var u = e.name, p = t.autoSchema || !a ? n.open(u) : n.open(u, a);
2568
- if (!p) throw new j.MissingAPI();
2569
- p.onerror = Y(l), p.onblocked = B(e._fireOnBlocked), p.onupgradeneeded = B(function(r) {
2570
- var i;
2571
- d = p.transaction, t.autoSchema && !e._options.allowEmptyDB ? (p.onerror = Ht, d.abort(), p.result.close(), (i = n.deleteDatabase(u)).onsuccess = i.onerror = B(function() {
2572
- l(new j.NoSuchDatabase(`Database ${u} doesnt exist`));
2573
- })) : (d.onerror = Y(l), i = r.oldVersion > 2 ** 62 ? 0 : r.oldVersion, f = i < 1, e.idbdb = p.result, o && ln(e, d), cn(e, i / 10, d, l));
2574
- }, l), p.onsuccess = B(function() {
2575
- d = null;
2576
- var n, s, l, m, h, _, v = e.idbdb = p.result, y = g(v.objectStoreNames);
2577
- if (0 < y.length) try {
2578
- var b = v.transaction((h = y).length === 1 ? h[0] : h, "readonly");
2579
- if (t.autoSchema) _ = v, m = b, (l = e).verno = _.version / 10, m = l._dbSchema = mn(0, _, m), l._storeNames = g(_.objectStoreNames, 0), an(l, [l._allTables], i(m), m);
2580
- else if (hn(e, e._dbSchema, b), s = b, ((s = un(mn(0, (n = e).idbdb, s), n._dbSchema)).add.length || s.change.some(function(e) {
2581
- return e.add.length || e.change.length;
2582
- })) && !o) return console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Dexie will add missing parts and increment native version number to workaround this."), v.close(), a = v.version + 1, o = !0, r(c());
2583
- rn(e, b);
2584
- } catch {}
2585
- yn.add(e), v.onversionchange = B(function(n) {
2586
- t.vcFired = !0, e.on("versionchange").fire(n);
2587
- }), v.onclose = B(function() {
2588
- e.close({ disableAutoOpen: !1 });
2589
- }), f && (y = e._deps, h = u, xn(_ = y.indexedDB) || h === ut || bn(_, y.IDBKeyRange).put({ name: h }).catch(M)), r();
2590
- }, l);
2591
- }).catch(function(e) {
2592
- switch (e?.name) {
2593
- case "UnknownError":
2594
- if (0 < t.PR1398_maxLoop) return t.PR1398_maxLoop--, console.warn("Dexie: Workaround for Chrome UnknownError on open()"), c();
2595
- break;
2596
- case "VersionError": if (0 < a) return a = 0, c();
2597
- }
2598
- return z.reject(e);
2599
- });
2600
- }
2601
- var l, u = t.dbReadyResolve, d = null, f = !1;
2602
- return z.race([r, (typeof navigator > "u" ? z.resolve() : !navigator.userAgentData && /Safari\//.test(navigator.userAgent) && !/Chrom(e|ium)\//.test(navigator.userAgent) && indexedDB.databases ? new Promise(function(e) {
2603
- function t() {
2604
- return indexedDB.databases().finally(e);
2605
- }
2606
- l = setInterval(t, 100), t();
2607
- }).finally(function() {
2608
- return clearInterval(l);
2609
- }) : Promise.resolve()).then(c)]).then(function() {
2610
- return s(), t.onReadyBeingFired = [], z.resolve(Sn(function() {
2611
- return e.on.ready.fire(e.vip);
2612
- })).then(function n() {
2613
- var r;
2614
- if (0 < t.onReadyBeingFired.length) return r = t.onReadyBeingFired.reduce(be, M), t.onReadyBeingFired = [], z.resolve(Sn(function() {
2615
- return r(e.vip);
2616
- })).then(n);
2617
- });
2618
- }).finally(function() {
2619
- t.openCanceller === r && (t.onReadyBeingFired = null, t.isBeingOpened = !1);
2620
- }).catch(function(n) {
2621
- t.dbOpenError = n;
2622
- try {
2623
- d && d.abort();
2624
- } catch {}
2625
- return r === t.openCanceller && e._close(), H(n);
2626
- }).finally(function() {
2627
- t.openComplete = !0, u();
2628
- }).then(function() {
2629
- var t;
2630
- return f && (t = {}, e.tables.forEach(function(n) {
2631
- n.schema.indexes.forEach(function(r) {
2632
- r.name && (t[`idb://${e.name}/${n.name}/${r.name}`] = new Z(-Infinity, [[[]]]));
2633
- }), t[`idb://${e.name}/${n.name}/`] = t[`idb://${e.name}/${n.name}/:dels`] = new Z(-Infinity, [[[]]]);
2634
- }), Gt(Ut).fire(t), In(t, !0)), e;
2635
- });
2636
- }
2637
- function zn(e) {
2638
- function t(t) {
2639
- return e.next(t);
2640
- }
2641
- var n = i(t), r = i(function(t) {
2642
- return e.throw(t);
2643
- });
2644
- function i(e) {
2645
- return function(t) {
2646
- var t = e(t), i = t.value;
2647
- return t.done ? i : i && typeof i.then == "function" ? i.then(n, r) : a(i) ? Promise.all(i).then(n, r) : n(i);
2648
- };
2649
- }
2650
- return i(t)();
2651
- }
2652
- function Bn(e, t, n) {
2653
- for (var r = a(e) ? e.slice() : [e], i = 0; i < n; ++i) r.push(t);
2654
- return r;
2655
- }
2656
- var Vn = {
2657
- stack: "dbcore",
2658
- name: "VirtualIndexMiddleware",
2659
- level: 1,
2660
- create: function(e) {
2661
- return t(t({}, e), { table: function(n) {
2662
- var r = e.table(n), n = r.schema, i = Object.create(null), a = [];
2663
- function o(e, n, r) {
2664
- var s = en(e), c = i[s] = i[s] || [], l = e == null ? 0 : typeof e == "string" ? 1 : e.length, u = 0 < n, s = t(t({}, r), {
2665
- name: u ? `${s}(virtual-from:${r.name})` : r.name,
2666
- lowLevelIndex: r,
2667
- isVirtual: u,
2668
- keyTail: n,
2669
- keyLength: l,
2670
- extractKey: Zt(e),
2671
- unique: !u && r.unique
2672
- });
2673
- return c.push(s), s.isPrimaryKey || a.push(s), 1 < l && o(l === 2 ? e[0] : e.slice(0, l - 1), n + 1, r), c.sort(function(e, t) {
2674
- return e.keyTail - t.keyTail;
2675
- }), s;
2676
- }
2677
- var s = o(n.primaryKey.keyPath, 0, n.primaryKey);
2678
- i[":id"] = [s];
2679
- for (var c = 0, l = n.indexes; c < l.length; c++) {
2680
- var u = l[c];
2681
- o(u.keyPath, 0, u);
2682
- }
2683
- function d(n) {
2684
- var r, i = n.query.index;
2685
- return i.isVirtual ? t(t({}, n), { query: {
2686
- index: i.lowLevelIndex,
2687
- range: (r = n.query.range, i = i.keyTail, {
2688
- type: r.type === 1 ? 2 : r.type,
2689
- lower: Bn(r.lower, r.lowerOpen ? e.MAX_KEY : e.MIN_KEY, i),
2690
- lowerOpen: !0,
2691
- upper: Bn(r.upper, r.upperOpen ? e.MIN_KEY : e.MAX_KEY, i),
2692
- upperOpen: !0
2693
- })
2694
- } }) : n;
2695
- }
2696
- return t(t({}, r), {
2697
- schema: t(t({}, n), {
2698
- primaryKey: s,
2699
- indexes: a,
2700
- getIndexByKeyPath: function(e) {
2701
- return (e = i[en(e)]) && e[0];
2702
- }
2703
- }),
2704
- count: function(e) {
2705
- return r.count(d(e));
2706
- },
2707
- query: function(e) {
2708
- return r.query(d(e));
2709
- },
2710
- openCursor: function(t) {
2711
- var n = t.query.index, i = n.keyTail, a = n.keyLength;
2712
- return n.isVirtual ? r.openCursor(d(t)).then(function(e) {
2713
- return e && o(e);
2714
- }) : r.openCursor(t);
2715
- function o(n) {
2716
- return Object.create(n, {
2717
- continue: { value: function(r) {
2718
- r == null ? t.unique ? n.continue(n.key.slice(0, a).concat(t.reverse ? e.MIN_KEY : e.MAX_KEY, i)) : n.continue() : n.continue(Bn(r, t.reverse ? e.MAX_KEY : e.MIN_KEY, i));
2719
- } },
2720
- continuePrimaryKey: { value: function(t, r) {
2721
- n.continuePrimaryKey(Bn(t, e.MAX_KEY, i), r);
2722
- } },
2723
- primaryKey: { get: function() {
2724
- return n.primaryKey;
2725
- } },
2726
- key: { get: function() {
2727
- var e = n.key;
2728
- return a === 1 ? e[0] : e.slice(0, a);
2729
- } },
2730
- value: { get: function() {
2731
- return n.value;
2732
- } }
2733
- });
2734
- }
2735
- }
2736
- });
2737
- } });
2738
- }
2739
- };
2740
- function Hn(e, t, n, r) {
2741
- return n ||= {}, r ||= "", i(e).forEach(function(i) {
2742
- var a, o, s;
2743
- l(t, i) ? (a = e[i], o = t[i], typeof a == "object" && typeof o == "object" && a && o ? (s = re(a)) === re(o) ? s === "Object" ? Hn(a, o, n, r + i + ".") : a !== o && (n[r + i] = t[i]) : n[r + i] = t[i] : a !== o && (n[r + i] = t[i])) : n[r + i] = void 0;
2744
- }), i(t).forEach(function(i) {
2745
- l(e, i) || (n[r + i] = t[i]);
2746
- }), n;
2747
- }
2748
- function Un(e, t) {
2749
- return t.type === "delete" ? t.keys : t.keys || t.values.map(e.extractKey);
2750
- }
2751
- var Wn = {
2752
- stack: "dbcore",
2753
- name: "HooksMiddleware",
2754
- level: 2,
2755
- create: function(e) {
2756
- return t(t({}, e), { table: function(r) {
2757
- var i = e.table(r), a = i.schema.primaryKey;
2758
- return t(t({}, i), { mutate: function(e) {
2759
- var o = R.trans, s = o.table(r).hook, c = s.deleting, u = s.creating, d = s.updating;
2760
- switch (e.type) {
2761
- case "add":
2762
- if (u.fire === M) break;
2763
- return o._promise("readwrite", function() {
2764
- return f(e);
2765
- }, !0);
2766
- case "put":
2767
- if (u.fire === M && d.fire === M) break;
2768
- return o._promise("readwrite", function() {
2769
- return f(e);
2770
- }, !0);
2771
- case "delete":
2772
- if (c.fire === M) break;
2773
- return o._promise("readwrite", function() {
2774
- return f(e);
2775
- }, !0);
2776
- case "deleteRange":
2777
- if (c.fire === M) break;
2778
- return o._promise("readwrite", function() {
2779
- return function e(n, r, o) {
2780
- return i.query({
2781
- trans: n,
2782
- values: !1,
2783
- query: {
2784
- index: a,
2785
- range: r
2786
- },
2787
- limit: o
2788
- }).then(function(i) {
2789
- var a = i.result;
2790
- return f({
2791
- type: "delete",
2792
- keys: a,
2793
- trans: n
2794
- }).then(function(i) {
2795
- return 0 < i.numFailures ? Promise.reject(i.failures[0]) : a.length < o ? {
2796
- failures: [],
2797
- numFailures: 0,
2798
- lastResult: void 0
2799
- } : e(n, t(t({}, r), {
2800
- lower: a[a.length - 1],
2801
- lowerOpen: !0
2802
- }), o);
2803
- });
2804
- });
2805
- }(e.trans, e.range, 1e4);
2806
- }, !0);
2807
- }
2808
- return i.mutate(e);
2809
- function f(e) {
2810
- var r, o, s, f = R.trans, p = e.keys || Un(a, e);
2811
- if (p) return (e = e.type === "add" || e.type === "put" ? t(t({}, e), { keys: p }) : t({}, e)).type !== "delete" && (e.values = n([], e.values, !0)), e.keys &&= n([], e.keys, !0), r = i, s = p, ((o = e).type === "add" ? Promise.resolve([]) : r.getMany({
2812
- trans: o.trans,
2813
- keys: s,
2814
- cache: "immutable"
2815
- })).then(function(t) {
2816
- var n = p.map(function(n, r) {
2817
- var i, o, s, p = t[r], m = {
2818
- onerror: null,
2819
- onsuccess: null
2820
- };
2821
- return e.type === "delete" ? c.fire.call(m, n, p, f) : e.type === "add" || p === void 0 ? (i = u.fire.call(m, n, e.values[r], f), n == null && i != null && (e.keys[r] = n = i, a.outbound || x(e.values[r], a.keyPath, n))) : (i = Hn(p, e.values[r]), (o = d.fire.call(m, i, n, p, f)) && (s = e.values[r], Object.keys(o).forEach(function(e) {
2822
- l(s, e) ? s[e] = o[e] : x(s, e, o[e]);
2823
- }))), m;
2824
- });
2825
- return i.mutate(e).then(function(r) {
2826
- for (var i = r.failures, a = r.results, o = r.numFailures, r = r.lastResult, s = 0; s < p.length; ++s) {
2827
- var c = (a || p)[s], l = n[s];
2828
- c == null ? l.onerror && l.onerror(i[s]) : l.onsuccess && l.onsuccess(e.type === "put" && t[s] ? e.values[s] : c);
2829
- }
2830
- return {
2831
- failures: i,
2832
- results: a,
2833
- numFailures: o,
2834
- lastResult: r
2835
- };
2836
- }).catch(function(e) {
2837
- return n.forEach(function(t) {
2838
- return t.onerror && t.onerror(e);
2839
- }), Promise.reject(e);
2840
- });
2841
- });
2842
- throw Error("Keys missing");
2843
- }
2844
- } });
2845
- } });
2846
- }
2847
- };
2848
- function Gn(e, t, n) {
2849
- try {
2850
- if (!t || t.keys.length < e.length) return null;
2851
- for (var r = [], i = 0, a = 0; i < t.keys.length && a < e.length; ++i) W(t.keys[i], e[a]) === 0 && (r.push(n ? E(t.values[i]) : t.values[i]), ++a);
2852
- return r.length === e.length ? r : null;
2853
- } catch {
2854
- return null;
2855
- }
2856
- }
2857
- var Kn = {
2858
- stack: "dbcore",
2859
- level: -1,
2860
- create: function(e) {
2861
- return { table: function(n) {
2862
- var r = e.table(n);
2863
- return t(t({}, r), {
2864
- getMany: function(e) {
2865
- var t;
2866
- return e.cache ? (t = Gn(e.keys, e.trans._cache, e.cache === "clone")) ? z.resolve(t) : r.getMany(e).then(function(t) {
2867
- return e.trans._cache = {
2868
- keys: e.keys,
2869
- values: e.cache === "clone" ? E(t) : t
2870
- }, t;
2871
- }) : r.getMany(e);
2872
- },
2873
- mutate: function(e) {
2874
- return e.type !== "add" && (e.trans._cache = null), r.mutate(e);
2875
- }
2876
- });
2877
- } };
2878
- }
2879
- };
2880
- function qn(e, t) {
2881
- return e.trans.mode === "readonly" && !!e.subscr && !e.trans.explicit && e.trans.db._options.cache !== "disabled" && !t.schema.primaryKey.outbound;
2882
- }
2883
- function Jn(e, t) {
2884
- switch (e) {
2885
- case "query": return t.values && !t.unique;
2886
- case "get":
2887
- case "getMany":
2888
- case "count":
2889
- case "openCursor": return !1;
2890
- }
2891
- }
2892
- var Yn = {
2893
- stack: "dbcore",
2894
- level: 0,
2895
- name: "Observability",
2896
- create: function(e) {
2897
- var n = e.schema.name, r = new Z(e.MIN_KEY, e.MAX_KEY);
2898
- return t(t({}, e), {
2899
- transaction: function(t, n, r) {
2900
- if (R.subscr && n !== "readonly") throw new j.ReadOnly(`Readwrite transaction in liveQuery context. Querier source: ${R.querier}`);
2901
- return e.transaction(t, n, r);
2902
- },
2903
- table: function(o) {
2904
- function s(t) {
2905
- var t = t.query;
2906
- return [t.index, new Z((t = t.range).lower ?? e.MIN_KEY, t.upper ?? e.MAX_KEY)];
2907
- }
2908
- var c = e.table(o), l = c.schema, u = l.primaryKey, d = l.indexes, f = u.extractKey, p = u.outbound, m = u.autoIncrement && d.filter(function(e) {
2909
- return e.compound && e.keyPath.includes(u.keyPath);
2910
- }), h = t(t({}, c), { mutate: function(t) {
2911
- function i(e) {
2912
- return e = `idb://${n}/${o}/${e}`, h[e] || (h[e] = new Z());
2913
- }
2914
- var s, d, f, p = t.trans, h = t.mutatedParts ||= {}, g = i(""), _ = i(":dels"), v = t.type, y = t.type === "deleteRange" ? [t.range] : t.type === "delete" ? [t.keys] : t.values.length < 50 ? [Un(u, t).filter(function(e) {
2915
- return e;
2916
- }), t.values] : [], b = y[0], y = y[1], x = t.trans._cache;
2917
- return a(b) ? (g.addKeys(b), (v = v === "delete" || b.length === y.length ? Gn(b, x) : null) || _.addKeys(b), (v || y) && (s = i, d = v, f = y, l.indexes.forEach(function(e) {
2918
- var t = s(e.name || "");
2919
- function n(t) {
2920
- return t == null ? null : e.extractKey(t);
2921
- }
2922
- function r(n) {
2923
- e.multiEntry && a(n) ? n.forEach(function(e) {
2924
- return t.addKey(e);
2925
- }) : t.addKey(n);
2926
- }
2927
- (d || f).forEach(function(e, t) {
2928
- var i = d && n(d[t]), t = f && n(f[t]);
2929
- W(i, t) !== 0 && (i != null && r(i), t != null) && r(t);
2930
- });
2931
- }))) : b ? (y = {
2932
- from: (x = b.lower) ?? e.MIN_KEY,
2933
- to: (v = b.upper) ?? e.MAX_KEY
2934
- }, _.add(y), g.add(y)) : (g.add(r), _.add(r), l.indexes.forEach(function(e) {
2935
- return i(e.name).add(r);
2936
- })), c.mutate(t).then(function(e) {
2937
- return !b || t.type !== "add" && t.type !== "put" || (g.addKeys(e.results), m && m.forEach(function(n) {
2938
- for (var r = t.values.map(function(e) {
2939
- return n.extractKey(e);
2940
- }), a = n.keyPath.findIndex(function(e) {
2941
- return e === u.keyPath;
2942
- }), o = 0, s = e.results.length; o < s; ++o) r[o][a] = e.results[o];
2943
- i(n.name).addKeys(r);
2944
- })), p.mutatedParts = An(p.mutatedParts || {}, h), e;
2945
- });
2946
- } }), g = {
2947
- get: function(e) {
2948
- return [u, new Z(e.key)];
2949
- },
2950
- getMany: function(e) {
2951
- return [u, new Z().addKeys(e.keys)];
2952
- },
2953
- count: s,
2954
- query: s,
2955
- openCursor: s
2956
- };
2957
- return i(g).forEach(function(e) {
2958
- h[e] = function(i) {
2959
- var a = R.subscr, s = !!a, l = qn(R, c) && Jn(e, i) ? i.obsSet = {} : a;
2960
- if (s) {
2961
- var u, a = function(e) {
2962
- return e = `idb://${n}/${o}/${e}`, l[e] || (l[e] = new Z());
2963
- }, d = a(""), m = a(":dels"), s = g[e](i), h = s[0], s = s[1];
2964
- if ((e === "query" && h.isPrimaryKey && !i.values ? m : a(h.name || "")).add(s), !h.isPrimaryKey) {
2965
- if (e !== "count") return u = e === "query" && p && i.values && c.query(t(t({}, i), { values: !1 })), c[e].apply(this, arguments).then(function(t) {
2966
- if (e === "query") {
2967
- if (p && i.values) return u.then(function(e) {
2968
- return e = e.result, d.addKeys(e), t;
2969
- });
2970
- var n = i.values ? t.result.map(f) : t.result;
2971
- (i.values ? d : m).addKeys(n);
2972
- } else {
2973
- var r, a;
2974
- if (e === "openCursor") return a = i.values, (r = t) && Object.create(r, {
2975
- key: { get: function() {
2976
- return m.addKey(r.primaryKey), r.key;
2977
- } },
2978
- primaryKey: { get: function() {
2979
- var e = r.primaryKey;
2980
- return m.addKey(e), e;
2981
- } },
2982
- value: { get: function() {
2983
- return a && d.addKey(r.primaryKey), r.value;
2984
- } }
2985
- });
2986
- }
2987
- return t;
2988
- });
2989
- m.add(r);
2990
- }
2991
- }
2992
- return c[e].apply(this, arguments);
2993
- };
2994
- }), h;
2995
- }
2996
- });
2997
- }
2998
- };
2999
- function Xn(e, n, r) {
3000
- var i;
3001
- return r.numFailures === 0 ? n : n.type === "deleteRange" || (i = n.keys ? n.keys.length : "values" in n && n.values ? n.values.length : 1, r.numFailures === i) ? null : (i = t({}, n), a(i.keys) && (i.keys = i.keys.filter(function(e, t) {
3002
- return !(t in r.failures);
3003
- })), "values" in i && a(i.values) && (i.values = i.values.filter(function(e, t) {
3004
- return !(t in r.failures);
3005
- })), i);
3006
- }
3007
- function Zn(e, t) {
3008
- return n = e, ((r = t).lower === void 0 || (r.lowerOpen ? 0 < W(n, r.lower) : 0 <= W(n, r.lower))) && (n = e, (r = t).upper === void 0 || (r.upperOpen ? W(n, r.upper) < 0 : W(n, r.upper) <= 0));
3009
- var n, r;
3010
- }
3011
- function Qn(e, t, n, r, i, o) {
3012
- var s, c, l, u, d, f, p;
3013
- return !n || n.length === 0 || (s = t.query.index, c = s.multiEntry, l = t.query.range, u = r.schema.primaryKey.extractKey, d = s.extractKey, f = (s.lowLevelIndex || s).extractKey, (r = n.reduce(function(e, n) {
3014
- var r = e, i = [];
3015
- if (n.type === "add" || n.type === "put") for (var o = new Z(), s = n.values.length - 1; 0 <= s; --s) {
3016
- var f, p = n.values[s], m = u(p);
3017
- !o.hasKey(m) && (f = d(p), c && a(f) ? f.some(function(e) {
3018
- return Zn(e, l);
3019
- }) : Zn(f, l)) && (o.addKey(m), i.push(p));
3020
- }
3021
- switch (n.type) {
3022
- case "add":
3023
- var h = new Z().addKeys(t.values ? e.map(function(e) {
3024
- return u(e);
3025
- }) : e), r = e.concat(t.values ? i.filter(function(e) {
3026
- return e = u(e), !h.hasKey(e) && (h.addKey(e), !0);
3027
- }) : i.map(function(e) {
3028
- return u(e);
3029
- }).filter(function(e) {
3030
- return !h.hasKey(e) && (h.addKey(e), !0);
3031
- }));
3032
- break;
3033
- case "put":
3034
- var g = new Z().addKeys(n.values.map(function(e) {
3035
- return u(e);
3036
- }));
3037
- r = e.filter(function(e) {
3038
- return !g.hasKey(t.values ? u(e) : e);
3039
- }).concat(t.values ? i : i.map(function(e) {
3040
- return u(e);
3041
- }));
3042
- break;
3043
- case "delete":
3044
- var _ = new Z().addKeys(n.keys);
3045
- r = e.filter(function(e) {
3046
- return !_.hasKey(t.values ? u(e) : e);
3047
- });
3048
- break;
3049
- case "deleteRange":
3050
- var v = n.range;
3051
- r = e.filter(function(e) {
3052
- return !Zn(u(e), v);
3053
- });
3054
- }
3055
- return r;
3056
- }, e)) === e) ? e : (p = function(e, t) {
3057
- return W(f(e), f(t)) || W(u(e), u(t));
3058
- }, r.sort(t.direction === "prev" || t.direction === "prevunique" ? function(e, t) {
3059
- return p(t, e);
3060
- } : p), t.limit && t.limit < Infinity && (r.length > t.limit ? r.length = t.limit : e.length === t.limit && r.length < t.limit && (i.dirty = !0)), o ? Object.freeze(r) : r);
3061
- }
3062
- function $n(e, t) {
3063
- return W(e.lower, t.lower) === 0 && W(e.upper, t.upper) === 0 && !!e.lowerOpen == !!t.lowerOpen && !!e.upperOpen == !!t.upperOpen;
3064
- }
3065
- function er(e, t) {
3066
- return ((e, t, n, r) => {
3067
- if (e === void 0) return t === void 0 ? 0 : -1;
3068
- if (t === void 0) return 1;
3069
- if ((e = W(e, t)) === 0) {
3070
- if (n && r) return 0;
3071
- if (n) return 1;
3072
- if (r) return -1;
3073
- }
3074
- return e;
3075
- })(e.lower, t.lower, e.lowerOpen, t.lowerOpen) <= 0 && 0 <= ((e, t, n, r) => {
3076
- if (e === void 0) return t === void 0 ? 0 : 1;
3077
- if (t === void 0) return -1;
3078
- if ((e = W(e, t)) === 0) {
3079
- if (n && r) return 0;
3080
- if (n) return -1;
3081
- if (r) return 1;
3082
- }
3083
- return e;
3084
- })(e.upper, t.upper, e.upperOpen, t.upperOpen);
3085
- }
3086
- function tr(e, t, n, r) {
3087
- e.subscribers.add(n), r.addEventListener("abort", function() {
3088
- var r, i;
3089
- e.subscribers.delete(n), e.subscribers.size === 0 && (r = e, i = t, setTimeout(function() {
3090
- r.subscribers.size === 0 && D(i, r);
3091
- }, 3e3));
3092
- });
3093
- }
3094
- var nr = {
3095
- stack: "dbcore",
3096
- level: 0,
3097
- name: "Cache",
3098
- create: function(e) {
3099
- var n = e.schema.name;
3100
- return t(t({}, e), {
3101
- transaction: function(t, r, i) {
3102
- var a, o, s = e.transaction(t, r, i);
3103
- return r === "readwrite" && (i = (a = new AbortController()).signal, s.addEventListener("abort", (o = function(i) {
3104
- return function() {
3105
- if (a.abort(), r === "readwrite") {
3106
- for (var o = /* @__PURE__ */ new Set(), c = 0, l = t; c < l.length; c++) {
3107
- var u = l[c], d = Mn[`idb://${n}/${u}`];
3108
- if (d) {
3109
- var f = e.table(u), p = d.optimisticOps.filter(function(e) {
3110
- return e.trans === s;
3111
- });
3112
- if (s._explicit && i && s.mutatedParts) for (var m = 0, h = Object.values(d.queries.query); m < h.length; m++) for (var g = 0, _ = (b = h[m]).slice(); g < _.length; g++) jn((x = _[g]).obsSet, s.mutatedParts) && (D(b, x), x.subscribers.forEach(function(e) {
3113
- return o.add(e);
3114
- }));
3115
- else if (0 < p.length) {
3116
- d.optimisticOps = d.optimisticOps.filter(function(e) {
3117
- return e.trans !== s;
3118
- });
3119
- for (var v = 0, y = Object.values(d.queries.query); v < y.length; v++) for (var b, x, S, C = 0, ee = (b = y[v]).slice(); C < ee.length; C++) (x = ee[C]).res != null && s.mutatedParts && (i && !x.dirty ? (S = Object.isFrozen(x.res), S = Qn(x.res, x.req, p, f, x, S), x.dirty ? (D(b, x), x.subscribers.forEach(function(e) {
3120
- return o.add(e);
3121
- })) : S !== x.res && (x.res = S, x.promise = z.resolve({ result: S }))) : (x.dirty && D(b, x), x.subscribers.forEach(function(e) {
3122
- return o.add(e);
3123
- })));
3124
- }
3125
- }
3126
- }
3127
- o.forEach(function(e) {
3128
- return e();
3129
- });
3130
- }
3131
- };
3132
- })(!1), { signal: i }), s.addEventListener("error", o(!1), { signal: i }), s.addEventListener("complete", o(!0), { signal: i })), s;
3133
- },
3134
- table: function(r) {
3135
- var i = e.table(r), a = i.schema.primaryKey;
3136
- return t(t({}, i), {
3137
- mutate: function(e) {
3138
- var o, s = R.trans;
3139
- return !a.outbound && s.db._options.cache !== "disabled" && !s.explicit && s.idbtrans.mode === "readwrite" && (o = Mn[`idb://${n}/${r}`]) ? (s = i.mutate(e), e.type !== "add" && e.type !== "put" || !(50 <= e.values.length || Un(a, e).some(function(e) {
3140
- return e == null;
3141
- })) ? (o.optimisticOps.push(e), e.mutatedParts && Fn(e.mutatedParts), s.then(function(t) {
3142
- 0 < t.numFailures && (D(o.optimisticOps, e), (t = Xn(0, e, t)) && o.optimisticOps.push(t), e.mutatedParts) && Fn(e.mutatedParts);
3143
- }), s.catch(function() {
3144
- D(o.optimisticOps, e), e.mutatedParts && Fn(e.mutatedParts);
3145
- })) : s.then(function(n) {
3146
- var r = Xn(0, t(t({}, e), { values: e.values.map(function(e, r) {
3147
- var i;
3148
- return n.failures[r] ? e : (x(i = (i = a.keyPath) != null && i.includes(".") ? E(e) : t({}, e), a.keyPath, n.results[r]), i);
3149
- }) }), n);
3150
- o.optimisticOps.push(r), queueMicrotask(function() {
3151
- return e.mutatedParts && Fn(e.mutatedParts);
3152
- });
3153
- }), s) : i.mutate(e);
3154
- },
3155
- query: function(e) {
3156
- var t, a, o, s, c, l, u;
3157
- return qn(R, i) && Jn("query", e) ? (t = (o = R.trans)?.db._options.cache === "immutable", a = (o = R).requery, o = o.signal, l = ((e, t, n, r) => {
3158
- var i = Mn[`idb://${e}/${t}`];
3159
- if (!i) return [];
3160
- if (!(e = i.queries[n])) return [
3161
- null,
3162
- !1,
3163
- i,
3164
- null
3165
- ];
3166
- var a = e[(r.query ? r.query.index.name : null) || ""];
3167
- if (!a) return [
3168
- null,
3169
- !1,
3170
- i,
3171
- null
3172
- ];
3173
- var o = (s = r.direction) ?? "next", s = a.find(function(e) {
3174
- return e.req.limit === r.limit && e.req.values === r.values && (e.req.direction ?? "next") === o && $n(e.req.query.range, r.query.range);
3175
- });
3176
- return s ? [
3177
- s,
3178
- !0,
3179
- i,
3180
- a
3181
- ] : [
3182
- a.find(function(e) {
3183
- return ("limit" in e.req ? e.req.limit : Infinity) >= r.limit && (e.req.direction ?? "next") === o && (!r.values || e.req.values) && er(e.req.query.range, r.query.range);
3184
- }),
3185
- !1,
3186
- i,
3187
- a
3188
- ];
3189
- })(n, r, "query", e), u = l[0], s = l[2], c = l[3], u && l[1] ? u.obsSet = e.obsSet : (l = i.query(e).then(function(e) {
3190
- var n = e.result;
3191
- if (u && (u.res = n), t) {
3192
- for (var r = 0, i = n.length; r < i; ++r) Object.freeze(n[r]);
3193
- Object.freeze(n);
3194
- }
3195
- return e;
3196
- }).catch(function(e) {
3197
- return c && u && D(c, u), Promise.reject(e);
3198
- }), u = {
3199
- obsSet: e.obsSet,
3200
- promise: l,
3201
- subscribers: /* @__PURE__ */ new Set(),
3202
- type: "query",
3203
- req: e,
3204
- dirty: !1
3205
- }, c ? c.push(u) : (c = [u], (s ||= Mn[`idb://${n}/${r}`] = {
3206
- queries: {
3207
- query: {},
3208
- count: {}
3209
- },
3210
- objs: /* @__PURE__ */ new Map(),
3211
- optimisticOps: [],
3212
- unsignaledParts: {}
3213
- }).queries.query[e.query.index.name || ""] = c)), tr(u, c, a, o), u.promise.then(function(n) {
3214
- return n = Qn(n.result, e, s?.optimisticOps, i, u, t), { result: t ? n : E(n) };
3215
- })) : i.query(e);
3216
- }
3217
- });
3218
- }
3219
- });
3220
- }
3221
- };
3222
- function rr(e, t) {
3223
- return new Proxy(e, { get: function(e, n, r) {
3224
- return n === "db" ? t : Reflect.get(e, n, r);
3225
- } });
3226
- }
3227
- $.prototype.version = function(e) {
3228
- if (isNaN(e) || e < .1) throw new j.Type("Given version is not a positive number");
3229
- if (e = Math.round(10 * e) / 10, this.idbdb || this._state.isBeingOpened) throw new j.Schema("Cannot add version when database is open");
3230
- this.verno = Math.max(this.verno, e);
3231
- var t = this._versions, n = t.filter(function(t) {
3232
- return t._cfg.version === e;
3233
- })[0];
3234
- return n || (n = new this.Version(e), t.push(n), t.sort(sn), n.stores({}), this._state.autoSchema = !1), n;
3235
- }, $.prototype._whenReady = function(e) {
3236
- var t = this;
3237
- return this.idbdb && (this._state.openComplete || R.letThrough || this._vip) ? e() : new z(function(e, n) {
3238
- if (t._state.openComplete) return n(new j.DatabaseClosed(t._state.dbOpenError));
3239
- if (!t._state.isBeingOpened) {
3240
- if (!t._state.autoOpen) return void n(new j.DatabaseClosed());
3241
- t.open().catch(M);
3242
- }
3243
- t._state.dbReadyPromise.then(e, n);
3244
- }).then(e);
3245
- }, $.prototype.use = function(e) {
3246
- var t = e.stack, n = e.create, r = e.level, e = e.name, i = (e && this.unuse({
3247
- stack: t,
3248
- name: e
3249
- }), this._middlewares[t] || (this._middlewares[t] = []));
3250
- return i.push({
3251
- stack: t,
3252
- create: n,
3253
- level: r ?? 10,
3254
- name: e
3255
- }), i.sort(function(e, t) {
3256
- return e.level - t.level;
3257
- }), this;
3258
- }, $.prototype.unuse = function(e) {
3259
- var t = e.stack, n = e.name, r = e.create;
3260
- return t && this._middlewares[t] && (this._middlewares[t] = this._middlewares[t].filter(function(e) {
3261
- return r ? e.create !== r : !!n && e.name !== n;
3262
- })), this;
3263
- }, $.prototype.open = function() {
3264
- var e = this;
3265
- return at(L, function() {
3266
- return Rn(e);
3267
- });
3268
- }, $.prototype._close = function() {
3269
- this.on.close.fire(new CustomEvent("close"));
3270
- var e = this._state;
3271
- if (yn.remove(this), this.idbdb) {
3272
- try {
3273
- this.idbdb.close();
3274
- } catch {}
3275
- this.idbdb = null;
3276
- }
3277
- e.isBeingOpened || (e.dbReadyPromise = new z(function(t) {
3278
- e.dbReadyResolve = t;
3279
- }), e.openCanceller = new z(function(t, n) {
3280
- e.cancelOpen = n;
3281
- }));
3282
- }, $.prototype.close = function(e) {
3283
- var e = (e === void 0 ? { disableAutoOpen: !0 } : e).disableAutoOpen, t = this._state;
3284
- e ? (t.isBeingOpened && t.cancelOpen(new j.DatabaseClosed()), this._close(), t.autoOpen = !1, t.dbOpenError = new j.DatabaseClosed()) : (this._close(), t.autoOpen = this._options.autoOpen || t.isBeingOpened, t.openComplete = !1, t.dbOpenError = null);
3285
- }, $.prototype.delete = function(e) {
3286
- var t = this, n = (e === void 0 && (e = { disableAutoOpen: !0 }), 0 < arguments.length && typeof arguments[0] != "object"), r = this._state;
3287
- return new z(function(i, a) {
3288
- function o() {
3289
- t.close(e);
3290
- var n = t._deps.indexedDB.deleteDatabase(t.name);
3291
- n.onsuccess = B(function() {
3292
- var e = t._deps, n = t.name, r;
3293
- xn(r = e.indexedDB) || n === ut || bn(r, e.IDBKeyRange).delete(n).catch(M), i();
3294
- }), n.onerror = Y(a), n.onblocked = t._fireOnBlocked;
3295
- }
3296
- if (n) throw new j.InvalidArgument("Invalid closeOptions argument to db.delete()");
3297
- r.isBeingOpened ? r.dbReadyPromise.then(o) : o();
3298
- });
3299
- }, $.prototype.backendDB = function() {
3300
- return this.idbdb;
3301
- }, $.prototype.isOpen = function() {
3302
- return this.idbdb !== null;
3303
- }, $.prototype.hasBeenClosed = function() {
3304
- var e = this._state.dbOpenError;
3305
- return e && e.name === "DatabaseClosed";
3306
- }, $.prototype.hasFailed = function() {
3307
- return this._state.dbOpenError !== null;
3308
- }, $.prototype.dynamicallyOpened = function() {
3309
- return this._state.autoSchema;
3310
- }, Object.defineProperty($.prototype, "tables", {
3311
- get: function() {
3312
- var e = this;
3313
- return i(this._allTables).map(function(t) {
3314
- return e._allTables[t];
3315
- });
3316
- },
3317
- enumerable: !1,
3318
- configurable: !0
3319
- }), $.prototype.transaction = function() {
3320
- var e = function(e, t, n) {
3321
- var r = arguments.length;
3322
- if (r < 2) throw new j.InvalidArgument("Too few arguments");
3323
- for (var i = Array(r - 1); --r;) i[r - 1] = arguments[r];
3324
- return n = i.pop(), [
3325
- e,
3326
- ee(i),
3327
- n
3328
- ];
3329
- }.apply(this, arguments);
3330
- return this._transaction.apply(this, e);
3331
- }, $.prototype._transaction = function(e, t, n) {
3332
- var r, i, a = this, o = R.trans, s = (o && o.db === this && e.indexOf("!") === -1 || (o = null), e.indexOf("?") !== -1);
3333
- e = e.replace("!", "").replace("?", "");
3334
- try {
3335
- if (i = t.map(function(e) {
3336
- if (e = e instanceof a.Table ? e.name : e, typeof e != "string") throw TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");
3337
- return e;
3338
- }), e == "r" || e === dt) r = dt;
3339
- else {
3340
- if (e != "rw" && e != ft) throw new j.InvalidArgument("Invalid transaction mode: " + e);
3341
- r = ft;
3342
- }
3343
- if (o) {
3344
- if (o.mode === dt && r === ft) {
3345
- if (!s) throw new j.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
3346
- o = null;
3347
- }
3348
- o && i.forEach(function(e) {
3349
- if (o && o.storeNames.indexOf(e) === -1) {
3350
- if (!s) throw new j.SubTransaction("Table " + e + " not included in parent transaction.");
3351
- o = null;
3352
- }
3353
- }), s && o && !o.active && (o = null);
3354
- }
3355
- } catch (e) {
3356
- return o ? o._promise(null, function(t, n) {
3357
- n(e);
3358
- }) : H(e);
3359
- }
3360
- var c = function e(t, n, r, i, a) {
3361
- return z.resolve().then(function() {
3362
- var o = R.transless || R, s = t._createTransaction(n, r, t._dbSchema, i), o = (s.explicit = !0, {
3363
- trans: s,
3364
- transless: o
3365
- });
3366
- if (i) s.idbtrans = i.idbtrans;
3367
- else try {
3368
- s.create(), s.idbtrans._explicit = !0, t._state.PR1398_maxLoop = 3;
3369
- } catch (i) {
3370
- return i.name === fe.InvalidState && t.isOpen() && 0 < --t._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), t.close({ disableAutoOpen: !1 }), t.open().then(function() {
3371
- return e(t, n, r, null, a);
3372
- })) : H(i);
3373
- }
3374
- var c, l = oe(a), o = (l && $e(), z.follow(function() {
3375
- var e;
3376
- (c = a.call(s, s)) && (l ? (e = et.bind(null, null), c.then(e, e)) : typeof c.next == "function" && typeof c.throw == "function" && (c = zn(c)));
3377
- }, o));
3378
- return (c && typeof c.then == "function" ? z.resolve(c).then(function(e) {
3379
- return s.active ? e : H(new j.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"));
3380
- }) : o.then(function() {
3381
- return c;
3382
- })).then(function(e) {
3383
- return i && s._resolve(), s._completion.then(function() {
3384
- return e;
3385
- });
3386
- }).catch(function(e) {
3387
- return s._reject(e), H(e);
3388
- });
3389
- });
3390
- }.bind(null, this, r, i, o, n);
3391
- return o ? o._promise(r, c, "lock") : R.trans ? at(R.transless, function() {
3392
- return a._whenReady(c);
3393
- }) : this._whenReady(c);
3394
- }, $.prototype.table = function(e) {
3395
- if (l(this._allTables, e)) return this._allTables[e];
3396
- throw new j.InvalidTable(`Table ${e} does not exist`);
3397
- };
3398
- var Q = $;
3399
- function $(e, n) {
3400
- var r, i, a, o, s, c = this, l = (this._middlewares = {}, this.verno = 0, $.dependencies), l = (this._options = n = t({
3401
- addons: $.addons,
3402
- autoOpen: !0,
3403
- indexedDB: l.indexedDB,
3404
- IDBKeyRange: l.IDBKeyRange,
3405
- cache: "cloned",
3406
- maxConnections: 1e3
3407
- }, n), this._deps = {
3408
- indexedDB: n.indexedDB,
3409
- IDBKeyRange: n.IDBKeyRange
3410
- }, n.addons), u = (this._dbSchema = {}, this._versions = [], this._storeNames = [], this._allTables = {}, this.idbdb = null, this._novip = this, {
3411
- dbOpenError: null,
3412
- isBeingOpened: !1,
3413
- onReadyBeingFired: null,
3414
- openComplete: !1,
3415
- dbReadyResolve: M,
3416
- dbReadyPromise: null,
3417
- cancelOpen: M,
3418
- openCanceller: null,
3419
- autoSchema: !0,
3420
- PR1398_maxLoop: 3,
3421
- autoOpen: n.autoOpen
3422
- }), d = (u.dbReadyPromise = new z(function(e) {
3423
- u.dbReadyResolve = e;
3424
- }), u.openCanceller = new z(function(e, t) {
3425
- u.cancelOpen = t;
3426
- }), this._state = u, this.name = e, this.on = wt(this, "populate", "blocked", "versionchange", "close", { ready: [be, M] }), this.once = function(e, t) {
3427
- var n = function() {
3428
- var r = [...arguments];
3429
- c.on(e).unsubscribe(n), t.apply(c, r);
3430
- };
3431
- return c.on(e, n);
3432
- }, this.on.ready.subscribe = _(this.on.ready.subscribe, function(e) {
3433
- return function(t, n) {
3434
- $.vip(function() {
3435
- var r, i = c._state;
3436
- i.openComplete ? (i.dbOpenError || z.resolve().then(t), n && e(t)) : i.onReadyBeingFired ? (i.onReadyBeingFired.push(t), n && e(t)) : (e(t), r = c, n || e(function e() {
3437
- r.on.ready.unsubscribe(t), r.on.ready.unsubscribe(e);
3438
- }));
3439
- });
3440
- };
3441
- }), this.Collection = (r = this, Tt(Nt.prototype, function(e, t) {
3442
- this.db = r;
3443
- var n = mt, i = null;
3444
- if (t) try {
3445
- n = t();
3446
- } catch (e) {
3447
- i = e;
3448
- }
3449
- var t = e._ctx, e = t.table, a = e.hook.reading.fire;
3450
- this._ctx = {
3451
- table: e,
3452
- index: t.index,
3453
- isPrimKey: !t.index || e.schema.primKey.keyPath && t.index === e.schema.primKey.name,
3454
- range: n,
3455
- keysOnly: !1,
3456
- dir: "next",
3457
- unique: "",
3458
- algorithm: null,
3459
- filter: null,
3460
- replayFilter: null,
3461
- justLimit: !0,
3462
- isMatch: null,
3463
- offset: 0,
3464
- limit: Infinity,
3465
- error: i,
3466
- or: t.or,
3467
- valueMapper: a === N ? null : a
3468
- };
3469
- })), this.Table = (i = this, Tt(Ct.prototype, function(e, t, n) {
3470
- this.db = i, this._tx = n, this.name = e, this.schema = t, this.hook = i._allTables[e] ? i._allTables[e].hook : wt(null, {
3471
- creating: [ge, M],
3472
- reading: [he, N],
3473
- updating: [ve, M],
3474
- deleting: [_e, M]
3475
- });
3476
- })), this.Transaction = (a = this, Tt(Kt.prototype, function(e, t, n, r, i) {
3477
- var o = this;
3478
- e !== "readonly" && t.forEach(function(e) {
3479
- e = (e = n[e])?.yProps, e && (t = t.concat(e.map(function(e) {
3480
- return e.updatesTable;
3481
- })));
3482
- }), this.db = a, this.mode = e, this.storeNames = t, this.schema = n, this.chromeTransactionDurability = r, this.idbtrans = null, this.on = wt(this, "complete", "error", "abort"), this.parent = i || null, this.active = !0, this._reculock = 0, this._blockedFuncs = [], this._resolve = null, this._reject = null, this._waitingFor = null, this._waitingQueue = null, this._spinCount = 0, this._completion = new z(function(e, t) {
3483
- o._resolve = e, o._reject = t;
3484
- }), this._completion.then(function() {
3485
- o.active = !1, o.on.complete.fire();
3486
- }, function(e) {
3487
- var t = o.active;
3488
- return o.active = !1, o.on.error.fire(e), o.parent ? o.parent._reject(e) : t && o.idbtrans && o.idbtrans.abort(), H(e);
3489
- });
3490
- })), this.Version = (o = this, Tt(_n.prototype, function(e) {
3491
- this.db = o, this._cfg = {
3492
- version: e,
3493
- storesSource: null,
3494
- dbschema: {},
3495
- tables: {},
3496
- contentUpgrade: null
3497
- };
3498
- })), this.WhereClause = (s = this, Tt(Vt.prototype, function(e, t, n) {
3499
- if (this.db = s, this._ctx = {
3500
- table: e,
3501
- index: t === ":id" ? null : t,
3502
- or: n
3503
- }, this._cmp = this._ascending = W, this._descending = function(e, t) {
3504
- return W(t, e);
3505
- }, this._max = function(e, t) {
3506
- return 0 < W(e, t) ? e : t;
3507
- }, this._min = function(e, t) {
3508
- return W(e, t) < 0 ? e : t;
3509
- }, this._IDBKeyRange = s._deps.IDBKeyRange, !this._IDBKeyRange) throw new j.MissingAPI();
3510
- })), this.on("versionchange", function(e) {
3511
- 0 < e.newVersion ? console.warn(`Another connection wants to upgrade database '${c.name}'. Closing db now to resume the upgrade.`) : console.warn(`Another connection wants to delete database '${c.name}'. Closing db now to resume the delete request.`), c.close({ disableAutoOpen: !1 });
3512
- }), this.on("blocked", function(e) {
3513
- !e.newVersion || e.newVersion < e.oldVersion ? console.warn(`Dexie.delete('${c.name}') was blocked`) : console.warn(`Upgrade '${c.name}' blocked by other connection holding version ${e.oldVersion / 10}`);
3514
- }), this._maxKey = Xt(n.IDBKeyRange), this._createTransaction = function(e, t, n, r) {
3515
- return new c.Transaction(e, t, n, c._options.chromeTransactionDurability, r);
3516
- }, this._fireOnBlocked = function(e) {
3517
- c.on("blocked").fire(e), yn.toArray().filter(function(e) {
3518
- return e.name === c.name && e !== c && !e._state.vcFired;
3519
- }).map(function(t) {
3520
- return t.on("versionchange").fire(e);
3521
- });
3522
- }, this.use(Kn), this.use(nr), this.use(Yn), this.use(Vn), this.use(Wn), new Proxy(this, { get: function(e, t, n) {
3523
- var r;
3524
- return t === "_vip" || (t === "table" ? function(e) {
3525
- return rr(c.table(e), d);
3526
- } : (r = Reflect.get(e, t, n)) instanceof Ct ? rr(r, d) : t === "tables" ? r.map(function(e) {
3527
- return rr(e, d);
3528
- }) : t === "_createTransaction" ? function() {
3529
- return rr(r.apply(this, arguments), d);
3530
- } : r);
3531
- } }));
3532
- this.vip = d, l.forEach(function(e) {
3533
- return e(c);
3534
- });
3535
- }
3536
- var ir, Te = typeof Symbol < "u" && "observable" in Symbol ? Symbol.observable : "@@observable", ar = (or.prototype.subscribe = function(e, t, n) {
3537
- return this._subscribe(e && typeof e != "function" ? e : {
3538
- next: e,
3539
- error: t,
3540
- complete: n
3541
- });
3542
- }, or.prototype[Te] = function() {
3543
- return this;
3544
- }, or);
3545
- function or(e) {
3546
- this._subscribe = e;
3547
- }
3548
- try {
3549
- ir = {
3550
- indexedDB: r.indexedDB || r.mozIndexedDB || r.webkitIndexedDB || r.msIndexedDB,
3551
- IDBKeyRange: r.IDBKeyRange || r.webkitIDBKeyRange
3552
- };
3553
- } catch {
3554
- ir = {
3555
- indexedDB: null,
3556
- IDBKeyRange: null
3557
- };
3558
- }
3559
- function sr(e) {
3560
- var t, n = !1, r = new ar(function(r) {
3561
- var i = oe(e), a, o = !1, s = {}, c = {}, l = {
3562
- get closed() {
3563
- return o;
3564
- },
3565
- unsubscribe: function() {
3566
- o || (o = !0, a && a.abort(), u && Gt.storagemutated.unsubscribe(p));
3567
- }
3568
- }, u = (r.start && r.start(l), !1), d = function() {
3569
- return st(m);
3570
- };
3571
- function f() {
3572
- return jn(c, s);
3573
- }
3574
- var p = function(e) {
3575
- An(s, e), f() && d();
3576
- }, m = function() {
3577
- var l, m, h;
3578
- !o && ir.indexedDB && (s = {}, l = {}, a && a.abort(), a = new AbortController(), h = ((t) => {
3579
- var n = Ue();
3580
- try {
3581
- i && $e();
3582
- var r = Qe(e, t);
3583
- return r = i ? r.finally(et) : r;
3584
- } finally {
3585
- n && We();
3586
- }
3587
- })(m = {
3588
- subscr: l,
3589
- signal: a.signal,
3590
- requery: d,
3591
- querier: e,
3592
- trans: null
3593
- }), u ||= (Gt.storagemutated.subscribe(p), !0), Promise.resolve(h).then(function(e) {
3594
- n = !0, t = e, o || m.signal.aborted || (f() || (c = l, f()) ? d() : (s = {}, st(function() {
3595
- return !o && r.next && r.next(e);
3596
- })));
3597
- }, function(e) {
3598
- n = !1, ["DatabaseClosedError", "AbortError"].includes(e?.name) || o || st(function() {
3599
- o || r.error && r.error(e);
3600
- });
3601
- }));
3602
- };
3603
- return setTimeout(d, 0), l;
3604
- });
3605
- return r.hasValue = function() {
3606
- return n;
3607
- }, r.getValue = function() {
3608
- return t;
3609
- }, r;
3610
- }
3611
- var cr = Q;
3612
- function lr(e) {
3613
- var t = dr;
3614
- try {
3615
- dr = !0, Gt.storagemutated.fire(e), In(e, !0);
3616
- } finally {
3617
- dr = t;
3618
- }
3619
- }
3620
- u(cr, t(t({}, w), {
3621
- delete: function(e) {
3622
- return new cr(e, { addons: [] }).delete();
3623
- },
3624
- exists: function(e) {
3625
- return new cr(e, { addons: [] }).open().then(function(e) {
3626
- return e.close(), !0;
3627
- }).catch("NoSuchDatabaseError", function() {
3628
- return !1;
3629
- });
3630
- },
3631
- getDatabaseNames: function(e) {
3632
- try {
3633
- return t = cr.dependencies, n = t.indexedDB, t = t.IDBKeyRange, (xn(n) ? Promise.resolve(n.databases()).then(function(e) {
3634
- return e.map(function(e) {
3635
- return e.name;
3636
- }).filter(function(e) {
3637
- return e !== ut;
3638
- });
3639
- }) : bn(n, t).toCollection().primaryKeys()).then(e);
3640
- } catch {
3641
- return H(new j.MissingAPI());
3642
- }
3643
- var t, n;
3644
- },
3645
- defineClass: function() {
3646
- return function(e) {
3647
- o(this, e);
3648
- };
3649
- },
3650
- ignoreTransaction: function(e) {
3651
- return R.trans ? at(R.transless || L, e) : e();
3652
- },
3653
- vip: Sn,
3654
- async: function(e) {
3655
- return function() {
3656
- try {
3657
- var t = zn(e.apply(this, arguments));
3658
- return t && typeof t.then == "function" ? t : z.resolve(t);
3659
- } catch (e) {
3660
- return H(e);
3661
- }
3662
- };
3663
- },
3664
- spawn: function(e, t, n) {
3665
- try {
3666
- var r = zn(e.apply(n, t || []));
3667
- return r && typeof r.then == "function" ? r : z.resolve(r);
3668
- } catch (e) {
3669
- return H(e);
3670
- }
3671
- },
3672
- currentTransaction: { get: function() {
3673
- return R.trans || null;
3674
- } },
3675
- waitFor: function(e, t) {
3676
- return e = z.resolve(typeof e == "function" ? cr.ignoreTransaction(e) : e).timeout(t || 6e4), R.trans ? R.trans.waitFor(e) : e;
3677
- },
3678
- Promise: z,
3679
- debug: {
3680
- get: function() {
3681
- return F;
3682
- },
3683
- set: function(e) {
3684
- xe(e);
3685
- }
3686
- },
3687
- derive: p,
3688
- extend: o,
3689
- props: u,
3690
- override: _,
3691
- Events: wt,
3692
- on: Gt,
3693
- liveQuery: sr,
3694
- extendObservabilitySet: An,
3695
- getByKeyPath: b,
3696
- setByKeyPath: x,
3697
- delByKeyPath: function(e, t) {
3698
- typeof t == "string" ? x(e, t, void 0) : "length" in t && [].map.call(t, function(t) {
3699
- x(e, t, void 0);
3700
- });
3701
- },
3702
- shallowClone: S,
3703
- deepClone: E,
3704
- getObjectDiff: Hn,
3705
- cmp: W,
3706
- asap: y,
3707
- minKey: -Infinity,
3708
- addons: [],
3709
- connections: { get: yn.toArray },
3710
- errnames: fe,
3711
- dependencies: ir,
3712
- cache: Mn,
3713
- semVer: "4.4.6",
3714
- version: "4.4.6".split(".").map(function(e) {
3715
- return parseInt(e);
3716
- }).reduce(function(e, t, n) {
3717
- return e + t / 10 ** (2 * n);
3718
- })
3719
- })), cr.maxKey = Xt(cr.dependencies.IDBKeyRange), typeof dispatchEvent < "u" && typeof addEventListener < "u" && (Gt(Ut, function(e) {
3720
- dr ||= (e = new CustomEvent(Wt, { detail: e }), dr = !0, dispatchEvent(e), !1);
3721
- }), addEventListener(Wt, function(e) {
3722
- e = e.detail, dr || lr(e);
3723
- }));
3724
- var ur, dr = !1, fr = function() {};
3725
- return typeof BroadcastChannel < "u" && ((fr = function() {
3726
- (ur = new BroadcastChannel(Wt)).onmessage = function(e) {
3727
- return e.data && lr(e.data);
3728
- };
3729
- })(), typeof ur.unref == "function" && ur.unref(), Gt(Ut, function(e) {
3730
- dr || ur.postMessage(e);
3731
- })), typeof addEventListener < "u" && (addEventListener("pagehide", function(e) {
3732
- if (!Q.disableBfCache && e.persisted) {
3733
- F && console.debug("Dexie: handling persisted pagehide"), ur?.close();
3734
- for (var t = 0, n = yn.toArray(); t < n.length; t++) n[t].close({ disableAutoOpen: !1 });
3735
- }
3736
- }), addEventListener("pageshow", function(e) {
3737
- !Q.disableBfCache && e.persisted && (F && console.debug("Dexie: handling persisted pageshow"), fr(), lr({ all: new Z(-Infinity, [[]]) }));
3738
- })), z.rejectionMapper = function(e, t) {
3739
- return !e || e instanceof ce || e instanceof TypeError || e instanceof SyntaxError || !e.name || !me[e.name] ? e : (t = new me[e.name](t || e.message, e), "stack" in e && f(t, "stack", { get: function() {
3740
- return this.inner.stack;
3741
- } }), t);
3742
- }, xe(F), t(Q, Object.freeze({
3743
- __proto__: null,
3744
- DEFAULT_MAX_CONNECTIONS: 1e3,
3745
- Dexie: Q,
3746
- Entity: gt,
3747
- PropModification: bt,
3748
- RangeSet: Z,
3749
- add: function(e) {
3750
- return new bt({ add: e });
3751
- },
3752
- cmp: W,
3753
- default: Q,
3754
- liveQuery: sr,
3755
- mergeRanges: Tn,
3756
- rangesOverlap: En,
3757
- remove: function(e) {
3758
- return new bt({ remove: e });
3759
- },
3760
- replacePrefix: function(e, t) {
3761
- return new bt({ replacePrefix: [e, t] });
3762
- }
3763
- }), { default: Q }), Q;
3764
- });
3765
- })))(), 1), k = Symbol.for("Dexie"), oe = globalThis[k] || (globalThis[k] = O.default);
3766
- if (O.default.semVer !== oe.semVer) throw Error(`Two different versions of Dexie loaded in the same app: ${O.default.semVer} and ${oe.semVer}`);
3767
- var { liveQuery: A, mergeRanges: se, rangesOverlap: ce, RangeSet: le, cmp: ue, Entity: de, PropModification: fe, replacePrefix: pe, add: j, remove: me, DexieYProvider: M } = oe, N = /* @__PURE__ */ new Map(), he = o(), P = i(), ge = /* @__PURE__ */ new Map();
3768
- function _e(e) {
3769
- let { key: t, connection: n, listener: r } = e, i = ge.get(t) ?? /* @__PURE__ */ new Set();
3770
- ge.set(t, i);
3771
- let a = {
3772
- connection: n,
3773
- listener: r
3774
- };
3775
- return i.add(a), function() {
3776
- i.delete(a), i.size === 0 && ge.get(t) === i && ge.delete(t);
3777
- };
3778
- }
3779
- function ve(e) {
3780
- let { key: t, name: n, connection: r, change: i } = e, a = {
3781
- ...i,
3782
- timestamp: Date.now()
3783
- };
3784
- for (let e of Array.from(ge.get(t) ?? [])) d({
3785
- listener: e.listener,
3786
- value: {
3787
- type: "change",
3788
- message: a,
3789
- own: e.connection === r
3790
- },
3791
- of: g({ name: n })
3792
- });
3793
- }
3794
- function ye(e) {
3795
- let { project: t, dialecteId: n } = e;
3796
- return n === void 0 ? encodeURIComponent(t) : y({
3797
- dialecteId: n,
3798
- project: t
3799
- });
3800
- }
3801
- function be(e) {
3802
- return N.get(e.key);
3803
- }
3804
- function F(e) {
3805
- let { key: t } = e, n = N.get(t);
3806
- if (n) return n;
3807
- let r = Se();
3808
- return N.set(t, r), r;
3809
- }
3810
- function xe(e) {
3811
- N.delete(e.key);
3812
- }
3813
- function Se() {
3814
- return {
3815
- documents: /* @__PURE__ */ new Map(),
3816
- records: /* @__PURE__ */ new Map(),
3817
- changelog: /* @__PURE__ */ new Map(),
3818
- heads: /* @__PURE__ */ new Map(),
3819
- discardedCommits: /* @__PURE__ */ new Map(),
3820
- blobs: /* @__PURE__ */ new Map(),
3821
- blobData: /* @__PURE__ */ new Map(),
3822
- runningImports: /* @__PURE__ */ new Set(),
3823
- versions: /* @__PURE__ */ new Map()
3824
- };
3825
- }
3826
- function Ce(e) {
3827
- let { state: t, documentId: n } = e;
3828
- t.versions.set(n, (t.versions.get(n) ?? 0) + 1);
3829
- }
3830
- var we = /* @__PURE__ */ new Map(), Te = Se();
3831
- function I(e) {
3832
- let { table: t, creates: n, documentId: r } = e, i = /* @__PURE__ */ new Set(), a = [], o = [];
3833
- for (let { id: e } of n) t.has(e) && a.push(e), i.has(e) && o.push(e), i.add(e);
3834
- (a.length > 0 || o.length > 0) && l({
3835
- documentId: r,
3836
- held: a,
3837
- repeated: o
3838
- });
3839
- }
3840
- (class t {
3841
- static {
3842
- this.reconcileWarned = !1;
3843
- }
3844
- constructor(e, t) {
3845
- this.closed = !1, this.closings = 0, this.operations = a(), h({
3846
- project: e,
3847
- dialecteId: t?.dialecteId
3848
- }), this.name = e, this.writable = t?.writable ?? !0, this.runtime = t?.runtime, this.stateKey = ye({
3849
- project: e,
3850
- dialecteId: t?.dialecteId
3851
- });
3852
- }
3853
- async open() {
3854
- let e = this.closings;
3855
- for (await this.operations.whenIdle(); this.destroying;) await this.destroying.catch(r);
3856
- this.closings !== e && c({ storeName: this.name }), this.closed = !1, this.writable && he.markOpen({
3857
- name: this.stateKey,
3858
- connection: this
3859
- }), await ae({
3860
- store: this,
3861
- isRunning: (e) => e.writeId !== void 0 && this.readState().runningImports.has(e.writeId)
3862
- });
3863
- }
3864
- async close() {
3865
- if (this.closed = !0, this.closings += 1, he.markClosed({
3866
- name: this.stateKey,
3867
- connection: this
3868
- }), this.operations.count === 0) return;
3869
- let e = this.operations.whenIdle();
3870
- P.markClosing({
3871
- name: this.stateKey,
3872
- until: e
3873
- }), await e;
3874
- }
3875
- async destroy() {
3876
- if (!this.writable) return;
3877
- for (; this.destroying;) await this.destroying.catch(r);
3878
- let e = this.destroyOnceIdle();
3879
- this.destroying = e;
3880
- try {
3881
- await e;
3882
- } finally {
3883
- this.destroying === e && (this.destroying = void 0);
3884
- }
3885
- }
3886
- async destroyOnceIdle() {
3887
- await this.operations.whenIdle(), await P.settled({ name: this.stateKey });
3888
- let e = he.others({
3889
- name: this.stateKey,
3890
- connection: this
3891
- });
3892
- e > 0 && p({
3893
- storeName: this.name,
3894
- connections: e
3895
- }), xe({ key: this.stateKey }), he.markClosed({
3896
- name: this.stateKey,
3897
- connection: this
3898
- });
3899
- }
3900
- async reconcile() {
3901
- await this.guardOpen(), t.reconcileWarned || (t.reconcileWarned = !0, console.warn("[dialecte] InMemoryStore.reconcile() is a no-op: in-memory documents are not shared across realms/tabs. Use a store shared across realms (the local store, or a registered kind) for cross-realm sync."));
3902
- }
3903
- async isDocumentReadable(e) {
3904
- return await this.guardOpen(), this.readState().documents.has(e);
3905
- }
3906
- async registerDocument(e) {
3907
- await this.guardOpen(), await this.registerDocumentUnguarded(e), this.announce({
3908
- type: "init-empty-document",
3909
- documentId: e.id
3910
- });
3911
- }
3912
- async getDocument(e) {
3913
- return await this.guardOpen(), this.getDocumentUnguarded(e);
3914
- }
3915
- async getDocuments() {
3916
- return await this.guardOpen(), structuredClone([...this.readState().documents.values()].sort(T));
3917
- }
3918
- async updateDocument(e, t) {
3919
- await this.guardOpen();
3920
- let n = this.readState().documents.get(e);
3921
- await this.updateDocumentUnguarded(e, t), re({
3922
- first: n,
3923
- second: this.readState().documents.get(e)
3924
- }) || this.announce({
3925
- type: "document-updated",
3926
- documentId: e
3927
- });
3928
- }
3929
- async removeDocument(e) {
3930
- await this.guardOpen();
3931
- let t = this.readState().documents.has(e);
3932
- await this.removeDocumentUnguarded(e), t && this.announce({
3933
- type: "document-removed",
3934
- documentId: e
3935
- });
3936
- }
3937
- async get(e, t) {
3938
- return await this.guardOpen(), structuredClone(this.readTable(t).get(e));
3939
- }
3940
- async getByDocumentId(e) {
3941
- return await this.guardOpen(), structuredClone([...this.readTable(e).values()].sort(T));
3942
- }
3943
- async count(e) {
3944
- return await this.guardOpen(), this.countUnguarded(e);
3945
- }
3946
- async getByTagNameInDocument(e, t) {
3947
- return await this.guardOpen(), this.getByTagNameInDocumentUnguarded(e, t);
3948
- }
3949
- async getMany(e, t) {
3950
- return await this.guardOpen(), this.getManyUnguarded(e, t);
3951
- }
3952
- async importFile(e) {
3953
- let t = this.guardOpen();
3954
- t && await t, this.guardWritable();
3955
- let { file: n, options: r, writeId: i = crypto.randomUUID(), onProgress: a, signal: o } = e, s = ne({
3956
- runtime: this.runtime,
3957
- storeName: this.name,
3958
- operation: "import"
3959
- }), { runningImports: c } = F({ key: this.stateKey });
3960
- c.add(i), this.operations.start();
3961
- try {
3962
- let e = await w({
3963
- store: this.ownImportTarget(),
3964
- runtime: s,
3965
- file: n,
3966
- options: r,
3967
- writeId: i
3968
- }, {
3969
- onProgress: a,
3970
- signal: o
3971
- });
3972
- return this.announce({
3973
- type: "document-imported",
3974
- documentId: e.record.id
3975
- }), e;
3976
- } finally {
3977
- c.delete(i), this.operations.end();
3978
- }
3979
- }
3980
- async exportFile(e) {
3981
- let t = this.guardOpen();
3982
- t && await t;
3983
- let { documentId: n, options: r, onProgress: i, signal: a } = e, o = ne({
3984
- runtime: this.runtime,
3985
- storeName: this.name,
3986
- operation: "export"
3987
- });
3988
- this.operations.start();
3989
- try {
3990
- return await v({
3991
- source: this.ownExportSource(),
3992
- runtime: o,
3993
- documentId: n,
3994
- options: r
3995
- }, {
3996
- onProgress: i,
3997
- signal: a
3998
- });
3999
- } finally {
4000
- this.operations.end();
4001
- }
4002
- }
4003
- async getWriteOutcome(e) {
4004
- await this.guardOpen();
4005
- let { writeId: t } = e, { documents: n, changelog: r, discardedCommits: i, runningImports: a } = this.readState(), o = [...r.values()].some((e) => e.some((e) => e.writeId === t)) || [...i.values()].some((e) => e.has(t));
4006
- return x({
4007
- documents: [...n.values()],
4008
- writeId: t,
4009
- committed: o,
4010
- isRunning: (e) => a.has(e.writeId)
4011
- });
4012
- }
4013
- async bulkWrite(e, t) {
4014
- await this.guardOpen();
4015
- let n = this.readTable(e), r = (t.deletes ?? []).filter(function(e) {
4016
- return n.has(e);
4017
- });
4018
- await this.bulkWriteUnguarded(e, t), (t.creates?.length ?? 0) + (t.updates?.length ?? 0) + r.length > 0 && this.announce({
4019
- type: "commit",
4020
- documentId: e
4021
- });
4022
- }
4023
- async commit(e) {
4024
- await this.guardOpen(), this.guardWritable();
4025
- let { documentId: t, writeId: n = crypto.randomUUID(), deletes: r, onProgress: i } = e, { state: a, table: o } = this.writeTarget(t);
4026
- a.documents.get(t)?.status === "importing" && b({
4027
- documentId: t,
4028
- what: "a commit"
4029
- }), s({ writeId: n });
4030
- let c = e.updates.map((e) => {
4031
- let n = o.get(e.id);
4032
- return n || m({
4033
- documentId: t,
4034
- recordId: e.id
4035
- }), n;
4036
- }), l = E({ records: e.creates });
4037
- I({
4038
- table: o,
4039
- creates: l,
4040
- documentId: t
4041
- });
4042
- let u = E({ records: e.updates });
4043
- Ce({
4044
- state: a,
4045
- documentId: t
4046
- });
4047
- for (let e of l) o.set(e.id, e);
4048
- for (let e of u) o.set(e.id, e);
4049
- let d = r.flatMap((e) => {
4050
- let t = o.get(e);
4051
- return t ? [t] : [];
4052
- });
4053
- for (let e of r) o.delete(e);
4054
- let { heads: f, changelog: p, discardedCommits: h } = a, g = f.get(t) ?? 0, _ = p.get(t) ?? [], v = _.filter((e) => e.sequenceNumber <= g), y = h.get(t) ?? /* @__PURE__ */ new Set();
4055
- for (let e of _) e.sequenceNumber > g && y.add(e.writeId);
4056
- h.set(t, y);
4057
- let x = g + 1, C = {
4058
- id: v.length + 1,
4059
- documentId: t,
4060
- sequenceNumber: x,
4061
- timestamp: Date.now(),
4062
- writeId: n,
4063
- operations: {
4064
- creates: l,
4065
- updates: u.map((e, t) => ({
4066
- before: c[t],
4067
- after: e
4068
- })),
4069
- deletes: d
4070
- }
4071
- };
4072
- v.push(C), p.set(t, v), f.set(t, x), S({
4073
- onProgress: i,
4074
- parts: [
4075
- l.length,
4076
- u.length,
4077
- r.length
4078
- ]
4079
- }), this.announce({
4080
- type: "commit",
4081
- documentId: t
4082
- });
4083
- }
4084
- async undo(e) {
4085
- await this.guardOpen(), this.guardWritable();
4086
- let t = this.writeState(), n = t?.heads.get(e) ?? 0;
4087
- if (!t || n === 0) return;
4088
- let r = (t.changelog.get(e) ?? []).find((e) => e.sequenceNumber === n);
4089
- if (!r) return;
4090
- let { table: i } = this.writeTarget(e), { creates: a, updates: o, deletes: s } = r.operations;
4091
- for (let e of s) i.set(e.id, e);
4092
- for (let e of o) i.set(e.before.id, e.before);
4093
- for (let e of a) i.delete(e.id);
4094
- t.heads.set(e, n - 1), Ce({
4095
- state: t,
4096
- documentId: e
4097
- }), this.announce({
4098
- type: "commit",
4099
- documentId: e
4100
- });
4101
- }
4102
- async redo(e) {
4103
- await this.guardOpen(), this.guardWritable();
4104
- let t = this.writeState();
4105
- if (!t) return;
4106
- let n = (t.heads.get(e) ?? 0) + 1, r = (t.changelog.get(e) ?? []).find((e) => e.sequenceNumber === n);
4107
- if (!r) return;
4108
- let { table: i } = this.writeTarget(e), { creates: a, updates: o, deletes: s } = r.operations;
4109
- for (let e of a) i.set(e.id, e);
4110
- for (let e of o) i.set(e.after.id, e.after);
4111
- for (let e of s) i.delete(e.id);
4112
- t.heads.set(e, n), Ce({
4113
- state: t,
4114
- documentId: e
4115
- }), this.announce({
4116
- type: "commit",
4117
- documentId: e
4118
- });
4119
- }
4120
- async getHistoryStatus(e) {
4121
- await this.guardOpen();
4122
- let { heads: t, changelog: n } = this.readState(), r = t.get(e) ?? 0, i = n.get(e) ?? [];
4123
- return {
4124
- canUndo: r > 0,
4125
- canRedo: i.some((e) => e.sequenceNumber === r + 1)
4126
- };
4127
- }
4128
- async getChangeLog(e) {
4129
- return await this.guardOpen(), structuredClone([...this.readState().changelog.get(e) ?? []]);
4130
- }
4131
- getDatabaseInstance() {
4132
- return null;
4133
- }
4134
- async addBlob(e, t) {
4135
- await this.guardOpen(), this.guardWritable();
4136
- let n = this.writeState();
4137
- n?.documents.has(e.documentId) || b({
4138
- documentId: e.documentId,
4139
- what: "a blob"
4140
- }), n.blobs.set(e.id, u({ value: e }));
4141
- let r = n.blobData.get(e.documentId) ?? /* @__PURE__ */ new Map();
4142
- n.blobData.set(e.documentId, r.set(e.id, t)), this.announce({
4143
- type: "blob-added",
4144
- blobId: e.id,
4145
- documentId: e.documentId
4146
- });
4147
- }
4148
- async getBlob(e) {
4149
- await this.guardOpen();
4150
- let { blobs: t, blobData: n } = this.readState(), r = t.get(e);
4151
- if (!r) return;
4152
- let i = n.get(r.documentId)?.get(e);
4153
- if (i) return {
4154
- entry: structuredClone(r),
4155
- data: i
4156
- };
4157
- }
4158
- async getBlobsByDocument(e) {
4159
- return await this.guardOpen(), structuredClone([...this.readState().blobs.values()].filter((t) => t.attachedTo.some((t) => t.documentId === e)).sort(T));
4160
- }
4161
- async getBlobsByRecord(e, t) {
4162
- return await this.guardOpen(), structuredClone([...this.readState().blobs.values()].filter((n) => n.attachedTo.some((n) => n.documentId === e && n.recordRef === t)).sort(T));
4163
- }
4164
- async getStandaloneBlobs() {
4165
- return await this.guardOpen(), structuredClone([...this.readState().blobs.values()].filter((e) => e.attachedTo.length === 0).sort(T));
4166
- }
4167
- async attachBlob(t, n) {
4168
- await this.guardOpen(), this.guardWritable();
4169
- let r = this.writeState(), i = r?.blobs.get(t);
4170
- r && i || e("STORE_BLOB_NOT_FOUND", { detail: `Blob "${t}" not found` });
4171
- let a = u({ value: n });
4172
- i.attachedTo.some((e) => e.documentId === n.documentId && e.recordRef === n.recordRef && e.attribute === n.attribute) || (r.blobs.set(t, {
4173
- ...i,
4174
- attachedTo: [...i.attachedTo, a]
4175
- }), this.announce({
4176
- type: "blob-attached",
4177
- blobId: t,
4178
- ref: a
4179
- }));
4180
- }
4181
- async detachBlob(t, n) {
4182
- await this.guardOpen(), this.guardWritable();
4183
- let r = this.writeState(), i = r?.blobs.get(t);
4184
- r && i || e("STORE_BLOB_NOT_FOUND", { detail: `Blob "${t}" not found` });
4185
- let a = i.attachedTo.filter((e) => e.documentId !== n.documentId || e.recordRef !== n.recordRef);
4186
- a.length !== i.attachedTo.length && (r.blobs.set(t, {
4187
- ...i,
4188
- attachedTo: a
4189
- }), this.announce({
4190
- type: "blob-detached",
4191
- blobId: t,
4192
- ref: {
4193
- documentId: n.documentId,
4194
- recordRef: n.recordRef
4195
- }
4196
- }));
4197
- }
4198
- async removeBlob(e) {
4199
- await this.guardOpen(), this.guardWritable();
4200
- let t = this.writeState(), n = t?.blobs.get(e);
4201
- t && n && (t.blobs.delete(e), t.blobData.get(n.documentId)?.delete(e), this.announce({
4202
- type: "blob-removed",
4203
- blobId: e
4204
- }));
4205
- }
4206
- subscribe(e) {
4207
- return this.writable ? _e({
4208
- key: this.stateKey,
4209
- connection: this,
4210
- listener: (t) => {
4211
- this.closed || e(t);
4212
- }
4213
- }) : Ee;
4214
- }
4215
- announce(e) {
4216
- ve({
4217
- key: this.stateKey,
4218
- name: this.name,
4219
- connection: this,
4220
- change: e
4221
- });
4222
- }
4223
- async registerDocumentUnguarded(e) {
4224
- this.guardWritable();
4225
- let t = F({ key: this.stateKey });
4226
- t.documents.has(e.id) && f({ documentId: e.id });
4227
- let n = u({ value: e });
4228
- ee({
4229
- document: n,
4230
- documents: [...t.documents.values()]
4231
- }), t.documents.set(e.id, n), t.records.set(_(e.id), /* @__PURE__ */ new Map()), t.blobData.set(e.id, /* @__PURE__ */ new Map());
4232
- }
4233
- async getDocumentUnguarded(e) {
4234
- return structuredClone(this.readState().documents.get(e));
4235
- }
4236
- async updateDocumentUnguarded(e, t) {
4237
- this.guardWritable();
4238
- let n = u({ value: t }), r = this.writeState(), i = r?.documents.get(e);
4239
- if (!r || !i) return;
4240
- let a = te({
4241
- document: i,
4242
- updates: n
4243
- });
4244
- a.path !== i.path && ee({
4245
- document: a,
4246
- documents: [...r.documents.values()]
4247
- }), r.documents.set(e, a);
4248
- }
4249
- async markReadyUnguarded(e) {
4250
- let { documentId: t, registered: n } = e;
4251
- this.guardWritable();
4252
- let r = this.writeState(), i = r?.documents.get(t);
4253
- r && i && D({
4254
- held: i,
4255
- registered: n
4256
- }) || b({
4257
- documentId: t,
4258
- what: "its ready state"
4259
- }), r.documents.set(t, {
4260
- ...i,
4261
- status: "ready"
4262
- });
4263
- }
4264
- async bulkWriteOwnImport(e) {
4265
- let { documentId: t, ops: n, registered: r } = e, i = this.writeState()?.documents.get(t);
4266
- D({
4267
- held: i,
4268
- registered: r
4269
- }) || b({
4270
- documentId: t,
4271
- what: "records"
4272
- }), await this.bulkWriteUnguarded(t, n);
4273
- }
4274
- async removeOwnImport(e) {
4275
- let { documentId: t, registered: n } = e, r = this.writeState()?.documents.get(t);
4276
- D({
4277
- held: r,
4278
- registered: n
4279
- }) && await this.removeDocumentUnguarded(t);
4280
- }
4281
- async removeDocumentUnguarded(e) {
4282
- this.guardWritable();
4283
- let t = this.writeState();
4284
- if (t) {
4285
- t.documents.delete(e), t.records.delete(_(e)), t.changelog.delete(e), t.heads.delete(e), t.discardedCommits.delete(e), t.blobData.delete(e);
4286
- for (let [n, r] of t.blobs) r.documentId === e && t.blobs.delete(n);
4287
- }
4288
- }
4289
- async bulkWriteUnguarded(e, t) {
4290
- this.guardWritable();
4291
- let { state: n, table: r } = this.writeTarget(e), i = E({ records: t.creates ?? [] });
4292
- I({
4293
- table: r,
4294
- creates: i,
4295
- documentId: e
4296
- });
4297
- let a = new Set(i.map((e) => e.id)), o = u({ value: (t.updates ?? []).filter((e) => r.has(e.recordId) || a.has(e.recordId)) });
4298
- for (let e of i) r.set(e.id, e);
4299
- for (let e of o) {
4300
- let t = r.get(e.recordId);
4301
- t && r.set(e.recordId, C({
4302
- record: t,
4303
- patch: e
4304
- }));
4305
- }
4306
- if (t.deletes) for (let e of t.deletes) r.delete(e);
4307
- Ce({
4308
- state: n,
4309
- documentId: e
4310
- });
4311
- }
4312
- readState() {
4313
- return this.writable ? be({ key: this.stateKey }) ?? Te : Te;
4314
- }
4315
- writeState() {
4316
- return be({ key: this.stateKey });
4317
- }
4318
- readTable(e) {
4319
- return this.readState().records.get(_(e)) ?? we;
4320
- }
4321
- writeTarget(e) {
4322
- let t = this.writeState(), n = t?.records.get(_(e));
4323
- return t && n || b({
4324
- documentId: e,
4325
- what: "records"
4326
- }), {
4327
- state: t,
4328
- table: n
4329
- };
4330
- }
4331
- guardOpen() {
4332
- if (this.closed && c({ storeName: this.name }), this.destroying) return this.guardOpenAfterOwnDestroy({ destroying: this.destroying });
4333
- this.writable && he.markOpen({
4334
- name: this.stateKey,
4335
- connection: this
4336
- });
4337
- }
4338
- async guardOpenAfterOwnDestroy(e) {
4339
- await e.destroying.catch(r), await this.guardOpen();
4340
- }
4341
- async writeOwnSession(e) {
4342
- let { documentId: t, ops: n, control: r, registered: i } = e;
4343
- await this.bulkWriteOwnImport({
4344
- documentId: t,
4345
- ops: n,
4346
- registered: i
4347
- }), ie({
4348
- ops: n,
4349
- control: r
4350
- });
4351
- }
4352
- ownImportTarget() {
4353
- let e;
4354
- return {
4355
- registerDocument: (t) => (e = t, this.registerDocumentUnguarded(t)),
4356
- getDocument: (e) => this.getDocumentUnguarded(e),
4357
- markReady: (t) => this.markReadyUnguarded({
4358
- documentId: t,
4359
- registered: e
4360
- }),
4361
- removeDocument: (t) => this.removeOwnImport({
4362
- documentId: t,
4363
- registered: e
4364
- }),
4365
- bulkWrite: (t, n) => this.bulkWriteOwnImport({
4366
- documentId: t,
4367
- ops: n,
4368
- registered: e
4369
- }),
4370
- writeSession: (t, n, r) => this.writeOwnSession({
4371
- documentId: t,
4372
- ops: n,
4373
- control: r,
4374
- registered: e
4375
- })
4376
- };
4377
- }
4378
- ownExportSource() {
4379
- return {
4380
- getDocument: (e) => this.getDocumentUnguarded(e),
4381
- count: (e) => this.countUnguarded(e),
4382
- getByTagNameInDocument: (e, t) => this.getByTagNameInDocumentUnguarded(e, t),
4383
- getMany: (e, t) => this.getManyUnguarded(e, t),
4384
- getExportVersion: (e) => this.getExportVersion(e)
4385
- };
4386
- }
4387
- async getExportVersion(e) {
4388
- let { documentId: t } = e, { documents: n, versions: r } = this.readState();
4389
- if (n.get(t)?.status === "ready") return r.get(t) ?? 0;
4390
- }
4391
- async countUnguarded(e) {
4392
- return this.readTable(e).size;
4393
- }
4394
- async getByTagNameInDocumentUnguarded(e, t) {
4395
- let n = [];
4396
- for (let r of this.readTable(t).values()) r.tagName === e && n.push(r);
4397
- return structuredClone(n.sort(T));
4398
- }
4399
- async getManyUnguarded(e, t) {
4400
- let n = this.readTable(t);
4401
- return structuredClone(e.map((e) => n.get(e)));
4402
- }
4403
- guardWritable() {
4404
- this.writable || e("STORE_NOT_WRITABLE", { detail: "In-memory store is read-only. Hydrate with a real document before writing." });
4405
- }
4406
- });
4407
- function Ee() {}
4408
- function De(e, t) {
4409
- return e ? Oe(e, t) : {};
4410
- }
4411
- function Oe(e, t) {
4412
- let n = {};
4413
- for (let r of Object.keys(e)) {
4414
- let i = e[r];
4415
- n[r] = typeof i == "function" ? (...e) => i(t, ...e) : Oe(i, t);
4416
- }
4417
- return n;
4418
- }
4419
- Object.freeze({
4420
- plan() {},
4421
- nextStep() {},
4422
- endPlan() {},
4423
- forceClear() {}
4424
- });
4425
- //#endregion
4426
- export { De as V, ae as Y };