@kbve/droid 0.0.4 → 0.0.6
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.
- package/README.md +4 -2
- package/droid.mjs +76 -0
- package/index.js +2972 -0
- package/lib/workers/canvas-worker.js +303 -0
- package/lib/workers/db-worker.js +3639 -0
- package/lib/workers/ws-worker.js +274 -0
- package/package.json +13 -9
- package/reference.js +259 -0
- package/src/lib/workers/main.ts +177 -134
- package/workers/main.js +616 -582
|
@@ -0,0 +1,3639 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2019 Google LLC
|
|
4
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
5
|
+
*/
|
|
6
|
+
const Hr = Symbol("Comlink.proxy"), ji = Symbol("Comlink.endpoint"), Bi = Symbol("Comlink.releaseProxy"), zn = Symbol("Comlink.finalizer"), Xt = Symbol("Comlink.thrown"), zr = (s) => typeof s == "object" && s !== null || typeof s == "function", Fi = {
|
|
7
|
+
canHandle: (s) => zr(s) && s[Hr],
|
|
8
|
+
serialize(s) {
|
|
9
|
+
const { port1: _, port2: O } = new MessageChannel();
|
|
10
|
+
return Jn(s, _), [O, [O]];
|
|
11
|
+
},
|
|
12
|
+
deserialize(s) {
|
|
13
|
+
return s.start(), Ui(s);
|
|
14
|
+
}
|
|
15
|
+
}, qi = {
|
|
16
|
+
canHandle: (s) => zr(s) && Xt in s,
|
|
17
|
+
serialize({ value: s }) {
|
|
18
|
+
let _;
|
|
19
|
+
return s instanceof Error ? _ = {
|
|
20
|
+
isError: !0,
|
|
21
|
+
value: {
|
|
22
|
+
message: s.message,
|
|
23
|
+
name: s.name,
|
|
24
|
+
stack: s.stack
|
|
25
|
+
}
|
|
26
|
+
} : _ = { isError: !1, value: s }, [_, []];
|
|
27
|
+
},
|
|
28
|
+
deserialize(s) {
|
|
29
|
+
throw s.isError ? Object.assign(new Error(s.value.message), s.value) : s.value;
|
|
30
|
+
}
|
|
31
|
+
}, $r = /* @__PURE__ */ new Map([
|
|
32
|
+
["proxy", Fi],
|
|
33
|
+
["throw", qi]
|
|
34
|
+
]);
|
|
35
|
+
function Mi(s, _) {
|
|
36
|
+
for (const O of s)
|
|
37
|
+
if (_ === O || O === "*" || O instanceof RegExp && O.test(_))
|
|
38
|
+
return !0;
|
|
39
|
+
return !1;
|
|
40
|
+
}
|
|
41
|
+
function Jn(s, _ = globalThis, O = ["*"]) {
|
|
42
|
+
_.addEventListener("message", function k(j) {
|
|
43
|
+
if (!j || !j.data)
|
|
44
|
+
return;
|
|
45
|
+
if (!Mi(O, j.origin)) {
|
|
46
|
+
console.warn(`Invalid origin '${j.origin}' for comlink proxy`);
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
const { id: N, type: F, path: B } = Object.assign({ path: [] }, j.data), W = (j.data.argumentList || []).map(ze);
|
|
50
|
+
let Y;
|
|
51
|
+
try {
|
|
52
|
+
const Z = B.slice(0, -1).reduce((X, ce) => X[ce], s), z = B.reduce((X, ce) => X[ce], s);
|
|
53
|
+
switch (F) {
|
|
54
|
+
case "GET":
|
|
55
|
+
Y = z;
|
|
56
|
+
break;
|
|
57
|
+
case "SET":
|
|
58
|
+
Z[B.slice(-1)[0]] = ze(j.data.value), Y = !0;
|
|
59
|
+
break;
|
|
60
|
+
case "APPLY":
|
|
61
|
+
Y = z.apply(Z, W);
|
|
62
|
+
break;
|
|
63
|
+
case "CONSTRUCT":
|
|
64
|
+
{
|
|
65
|
+
const X = new z(...W);
|
|
66
|
+
Y = $i(X);
|
|
67
|
+
}
|
|
68
|
+
break;
|
|
69
|
+
case "ENDPOINT":
|
|
70
|
+
{
|
|
71
|
+
const { port1: X, port2: ce } = new MessageChannel();
|
|
72
|
+
Jn(s, ce), Y = zi(X, [X]);
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case "RELEASE":
|
|
76
|
+
Y = void 0;
|
|
77
|
+
break;
|
|
78
|
+
default:
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
} catch (Z) {
|
|
82
|
+
Y = { value: Z, [Xt]: 0 };
|
|
83
|
+
}
|
|
84
|
+
Promise.resolve(Y).catch((Z) => ({ value: Z, [Xt]: 0 })).then((Z) => {
|
|
85
|
+
const [z, X] = nn(Z);
|
|
86
|
+
_.postMessage(Object.assign(Object.assign({}, z), { id: N }), X), F === "RELEASE" && (_.removeEventListener("message", k), Yr(_), zn in s && typeof s[zn] == "function" && s[zn]());
|
|
87
|
+
}).catch((Z) => {
|
|
88
|
+
const [z, X] = nn({
|
|
89
|
+
value: new TypeError("Unserializable return value"),
|
|
90
|
+
[Xt]: 0
|
|
91
|
+
});
|
|
92
|
+
_.postMessage(Object.assign(Object.assign({}, z), { id: N }), X);
|
|
93
|
+
});
|
|
94
|
+
}), _.start && _.start();
|
|
95
|
+
}
|
|
96
|
+
function Li(s) {
|
|
97
|
+
return s.constructor.name === "MessagePort";
|
|
98
|
+
}
|
|
99
|
+
function Yr(s) {
|
|
100
|
+
Li(s) && s.close();
|
|
101
|
+
}
|
|
102
|
+
function Ui(s, _) {
|
|
103
|
+
const O = /* @__PURE__ */ new Map();
|
|
104
|
+
return s.addEventListener("message", function(j) {
|
|
105
|
+
const { data: N } = j;
|
|
106
|
+
if (!N || !N.id)
|
|
107
|
+
return;
|
|
108
|
+
const F = O.get(N.id);
|
|
109
|
+
if (F)
|
|
110
|
+
try {
|
|
111
|
+
F(N);
|
|
112
|
+
} finally {
|
|
113
|
+
O.delete(N.id);
|
|
114
|
+
}
|
|
115
|
+
}), Gn(s, O, [], _);
|
|
116
|
+
}
|
|
117
|
+
function Qt(s) {
|
|
118
|
+
if (s)
|
|
119
|
+
throw new Error("Proxy has been released and is not useable");
|
|
120
|
+
}
|
|
121
|
+
function Gr(s) {
|
|
122
|
+
return it(s, /* @__PURE__ */ new Map(), {
|
|
123
|
+
type: "RELEASE"
|
|
124
|
+
}).then(() => {
|
|
125
|
+
Yr(s);
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const en = /* @__PURE__ */ new WeakMap(), tn = "FinalizationRegistry" in globalThis && new FinalizationRegistry((s) => {
|
|
129
|
+
const _ = (en.get(s) || 0) - 1;
|
|
130
|
+
en.set(s, _), _ === 0 && Gr(s);
|
|
131
|
+
});
|
|
132
|
+
function Wi(s, _) {
|
|
133
|
+
const O = (en.get(_) || 0) + 1;
|
|
134
|
+
en.set(_, O), tn && tn.register(s, _, s);
|
|
135
|
+
}
|
|
136
|
+
function Vi(s) {
|
|
137
|
+
tn && tn.unregister(s);
|
|
138
|
+
}
|
|
139
|
+
function Gn(s, _, O = [], k = function() {
|
|
140
|
+
}) {
|
|
141
|
+
let j = !1;
|
|
142
|
+
const N = new Proxy(k, {
|
|
143
|
+
get(F, B) {
|
|
144
|
+
if (Qt(j), B === Bi)
|
|
145
|
+
return () => {
|
|
146
|
+
Vi(N), Gr(s), _.clear(), j = !0;
|
|
147
|
+
};
|
|
148
|
+
if (B === "then") {
|
|
149
|
+
if (O.length === 0)
|
|
150
|
+
return { then: () => N };
|
|
151
|
+
const W = it(s, _, {
|
|
152
|
+
type: "GET",
|
|
153
|
+
path: O.map((Y) => Y.toString())
|
|
154
|
+
}).then(ze);
|
|
155
|
+
return W.then.bind(W);
|
|
156
|
+
}
|
|
157
|
+
return Gn(s, _, [...O, B]);
|
|
158
|
+
},
|
|
159
|
+
set(F, B, W) {
|
|
160
|
+
Qt(j);
|
|
161
|
+
const [Y, Z] = nn(W);
|
|
162
|
+
return it(s, _, {
|
|
163
|
+
type: "SET",
|
|
164
|
+
path: [...O, B].map((z) => z.toString()),
|
|
165
|
+
value: Y
|
|
166
|
+
}, Z).then(ze);
|
|
167
|
+
},
|
|
168
|
+
apply(F, B, W) {
|
|
169
|
+
Qt(j);
|
|
170
|
+
const Y = O[O.length - 1];
|
|
171
|
+
if (Y === ji)
|
|
172
|
+
return it(s, _, {
|
|
173
|
+
type: "ENDPOINT"
|
|
174
|
+
}).then(ze);
|
|
175
|
+
if (Y === "bind")
|
|
176
|
+
return Gn(s, _, O.slice(0, -1));
|
|
177
|
+
const [Z, z] = qr(W);
|
|
178
|
+
return it(s, _, {
|
|
179
|
+
type: "APPLY",
|
|
180
|
+
path: O.map((X) => X.toString()),
|
|
181
|
+
argumentList: Z
|
|
182
|
+
}, z).then(ze);
|
|
183
|
+
},
|
|
184
|
+
construct(F, B) {
|
|
185
|
+
Qt(j);
|
|
186
|
+
const [W, Y] = qr(B);
|
|
187
|
+
return it(s, _, {
|
|
188
|
+
type: "CONSTRUCT",
|
|
189
|
+
path: O.map((Z) => Z.toString()),
|
|
190
|
+
argumentList: W
|
|
191
|
+
}, Y).then(ze);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
return Wi(N, s), N;
|
|
195
|
+
}
|
|
196
|
+
function Hi(s) {
|
|
197
|
+
return Array.prototype.concat.apply([], s);
|
|
198
|
+
}
|
|
199
|
+
function qr(s) {
|
|
200
|
+
const _ = s.map(nn);
|
|
201
|
+
return [_.map((O) => O[0]), Hi(_.map((O) => O[1]))];
|
|
202
|
+
}
|
|
203
|
+
const Qr = /* @__PURE__ */ new WeakMap();
|
|
204
|
+
function zi(s, _) {
|
|
205
|
+
return Qr.set(s, _), s;
|
|
206
|
+
}
|
|
207
|
+
function $i(s) {
|
|
208
|
+
return Object.assign(s, { [Hr]: !0 });
|
|
209
|
+
}
|
|
210
|
+
function nn(s) {
|
|
211
|
+
for (const [_, O] of $r)
|
|
212
|
+
if (O.canHandle(s)) {
|
|
213
|
+
const [k, j] = O.serialize(s);
|
|
214
|
+
return [
|
|
215
|
+
{
|
|
216
|
+
type: "HANDLER",
|
|
217
|
+
name: _,
|
|
218
|
+
value: k
|
|
219
|
+
},
|
|
220
|
+
j
|
|
221
|
+
];
|
|
222
|
+
}
|
|
223
|
+
return [
|
|
224
|
+
{
|
|
225
|
+
type: "RAW",
|
|
226
|
+
value: s
|
|
227
|
+
},
|
|
228
|
+
Qr.get(s) || []
|
|
229
|
+
];
|
|
230
|
+
}
|
|
231
|
+
function ze(s) {
|
|
232
|
+
switch (s.type) {
|
|
233
|
+
case "HANDLER":
|
|
234
|
+
return $r.get(s.name).deserialize(s.value);
|
|
235
|
+
case "RAW":
|
|
236
|
+
return s.value;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
function it(s, _, O, k) {
|
|
240
|
+
return new Promise((j) => {
|
|
241
|
+
const N = Yi();
|
|
242
|
+
_.set(N, j), s.start && s.start(), s.postMessage(Object.assign({ id: N }, O), k);
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
function Yi() {
|
|
246
|
+
return new Array(4).fill(0).map(() => Math.floor(Math.random() * Number.MAX_SAFE_INTEGER).toString(16)).join("-");
|
|
247
|
+
}
|
|
248
|
+
var Gi = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
|
|
249
|
+
function Qi(s) {
|
|
250
|
+
return s && s.__esModule && Object.prototype.hasOwnProperty.call(s, "default") ? s.default : s;
|
|
251
|
+
}
|
|
252
|
+
var Jt = { exports: {} }, Xi = Jt.exports, Mr;
|
|
253
|
+
function Ji() {
|
|
254
|
+
return Mr || (Mr = 1, function(s, _) {
|
|
255
|
+
(function(O, k) {
|
|
256
|
+
s.exports = k();
|
|
257
|
+
})(Xi, function() {
|
|
258
|
+
var O = function(e, t) {
|
|
259
|
+
return (O = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(n, r) {
|
|
260
|
+
n.__proto__ = r;
|
|
261
|
+
} || function(n, r) {
|
|
262
|
+
for (var i in r) Object.prototype.hasOwnProperty.call(r, i) && (n[i] = r[i]);
|
|
263
|
+
})(e, t);
|
|
264
|
+
}, k = function() {
|
|
265
|
+
return (k = Object.assign || function(e) {
|
|
266
|
+
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]);
|
|
267
|
+
return e;
|
|
268
|
+
}).apply(this, arguments);
|
|
269
|
+
};
|
|
270
|
+
function j(e, t, n) {
|
|
271
|
+
for (var r, i = 0, o = t.length; i < o; i++) !r && i in t || ((r = r || Array.prototype.slice.call(t, 0, i))[i] = t[i]);
|
|
272
|
+
return e.concat(r || Array.prototype.slice.call(t));
|
|
273
|
+
}
|
|
274
|
+
var N = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : Gi, F = Object.keys, B = Array.isArray;
|
|
275
|
+
function W(e, t) {
|
|
276
|
+
return typeof t != "object" || F(t).forEach(function(n) {
|
|
277
|
+
e[n] = t[n];
|
|
278
|
+
}), e;
|
|
279
|
+
}
|
|
280
|
+
typeof Promise > "u" || N.Promise || (N.Promise = Promise);
|
|
281
|
+
var Y = Object.getPrototypeOf, Z = {}.hasOwnProperty;
|
|
282
|
+
function z(e, t) {
|
|
283
|
+
return Z.call(e, t);
|
|
284
|
+
}
|
|
285
|
+
function X(e, t) {
|
|
286
|
+
typeof t == "function" && (t = t(Y(e))), (typeof Reflect > "u" ? F : Reflect.ownKeys)(t).forEach(function(n) {
|
|
287
|
+
ve(e, n, t[n]);
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
var ce = Object.defineProperty;
|
|
291
|
+
function ve(e, t, n, r) {
|
|
292
|
+
ce(e, t, W(n && z(n, "get") && typeof n.get == "function" ? { get: n.get, set: n.set, configurable: !0 } : { value: n, configurable: !0, writable: !0 }, r));
|
|
293
|
+
}
|
|
294
|
+
function $e(e) {
|
|
295
|
+
return { from: function(t) {
|
|
296
|
+
return e.prototype = Object.create(t.prototype), ve(e.prototype, "constructor", e), { extend: X.bind(null, e.prototype) };
|
|
297
|
+
} };
|
|
298
|
+
}
|
|
299
|
+
var Zr = Object.getOwnPropertyDescriptor, ei = [].slice;
|
|
300
|
+
function _t(e, t, n) {
|
|
301
|
+
return ei.call(e, t, n);
|
|
302
|
+
}
|
|
303
|
+
function Zn(e, t) {
|
|
304
|
+
return t(e);
|
|
305
|
+
}
|
|
306
|
+
function ot(e) {
|
|
307
|
+
if (!e) throw new Error("Assertion Failed");
|
|
308
|
+
}
|
|
309
|
+
function er(e) {
|
|
310
|
+
N.setImmediate ? setImmediate(e) : setTimeout(e, 0);
|
|
311
|
+
}
|
|
312
|
+
function _e(e, t) {
|
|
313
|
+
if (typeof t == "string" && z(e, t)) return e[t];
|
|
314
|
+
if (!t) return e;
|
|
315
|
+
if (typeof t != "string") {
|
|
316
|
+
for (var n = [], r = 0, i = t.length; r < i; ++r) {
|
|
317
|
+
var o = _e(e, t[r]);
|
|
318
|
+
n.push(o);
|
|
319
|
+
}
|
|
320
|
+
return n;
|
|
321
|
+
}
|
|
322
|
+
var a = t.indexOf(".");
|
|
323
|
+
if (a !== -1) {
|
|
324
|
+
var u = e[t.substr(0, a)];
|
|
325
|
+
return u == null ? void 0 : _e(u, t.substr(a + 1));
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
function le(e, t, n) {
|
|
329
|
+
if (e && t !== void 0 && !("isFrozen" in Object && Object.isFrozen(e))) if (typeof t != "string" && "length" in t) {
|
|
330
|
+
ot(typeof n != "string" && "length" in n);
|
|
331
|
+
for (var r = 0, i = t.length; r < i; ++r) le(e, t[r], n[r]);
|
|
332
|
+
} else {
|
|
333
|
+
var o, a, u = t.indexOf(".");
|
|
334
|
+
u !== -1 ? (o = t.substr(0, u), (a = t.substr(u + 1)) === "" ? n === void 0 ? B(e) && !isNaN(parseInt(o)) ? e.splice(o, 1) : delete e[o] : e[o] = n : le(u = !(u = e[o]) || !z(e, o) ? e[o] = {} : u, a, n)) : n === void 0 ? B(e) && !isNaN(parseInt(t)) ? e.splice(t, 1) : delete e[t] : e[t] = n;
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
function tr(e) {
|
|
338
|
+
var t, n = {};
|
|
339
|
+
for (t in e) z(e, t) && (n[t] = e[t]);
|
|
340
|
+
return n;
|
|
341
|
+
}
|
|
342
|
+
var ti = [].concat;
|
|
343
|
+
function nr(e) {
|
|
344
|
+
return ti.apply([], e);
|
|
345
|
+
}
|
|
346
|
+
var je = "BigUint64Array,BigInt64Array,Array,Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,FileSystemDirectoryHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(nr([8, 16, 32, 64].map(function(e) {
|
|
347
|
+
return ["Int", "Uint", "Float"].map(function(t) {
|
|
348
|
+
return t + e + "Array";
|
|
349
|
+
});
|
|
350
|
+
}))).filter(function(e) {
|
|
351
|
+
return N[e];
|
|
352
|
+
}), rr = new Set(je.map(function(e) {
|
|
353
|
+
return N[e];
|
|
354
|
+
})), at = null;
|
|
355
|
+
function Ke(e) {
|
|
356
|
+
return at = /* @__PURE__ */ new WeakMap(), e = function t(n) {
|
|
357
|
+
if (!n || typeof n != "object") return n;
|
|
358
|
+
var r = at.get(n);
|
|
359
|
+
if (r) return r;
|
|
360
|
+
if (B(n)) {
|
|
361
|
+
r = [], at.set(n, r);
|
|
362
|
+
for (var i = 0, o = n.length; i < o; ++i) r.push(t(n[i]));
|
|
363
|
+
} else if (rr.has(n.constructor)) r = n;
|
|
364
|
+
else {
|
|
365
|
+
var a, u = Y(n);
|
|
366
|
+
for (a in r = u === Object.prototype ? {} : Object.create(u), at.set(n, r), n) z(n, a) && (r[a] = t(n[a]));
|
|
367
|
+
}
|
|
368
|
+
return r;
|
|
369
|
+
}(e), at = null, e;
|
|
370
|
+
}
|
|
371
|
+
var ni = {}.toString;
|
|
372
|
+
function an(e) {
|
|
373
|
+
return ni.call(e).slice(8, -1);
|
|
374
|
+
}
|
|
375
|
+
var sn = typeof Symbol < "u" ? Symbol.iterator : "@@iterator", ri = typeof sn == "symbol" ? function(e) {
|
|
376
|
+
var t;
|
|
377
|
+
return e != null && (t = e[sn]) && t.apply(e);
|
|
378
|
+
} : function() {
|
|
379
|
+
return null;
|
|
380
|
+
};
|
|
381
|
+
function Ne(e, t) {
|
|
382
|
+
return t = e.indexOf(t), 0 <= t && e.splice(t, 1), 0 <= t;
|
|
383
|
+
}
|
|
384
|
+
var Ye = {};
|
|
385
|
+
function xe(e) {
|
|
386
|
+
var t, n, r, i;
|
|
387
|
+
if (arguments.length === 1) {
|
|
388
|
+
if (B(e)) return e.slice();
|
|
389
|
+
if (this === Ye && typeof e == "string") return [e];
|
|
390
|
+
if (i = ri(e)) {
|
|
391
|
+
for (n = []; !(r = i.next()).done; ) n.push(r.value);
|
|
392
|
+
return n;
|
|
393
|
+
}
|
|
394
|
+
if (e == null) return [e];
|
|
395
|
+
if (typeof (t = e.length) != "number") return [e];
|
|
396
|
+
for (n = new Array(t); t--; ) n[t] = e[t];
|
|
397
|
+
return n;
|
|
398
|
+
}
|
|
399
|
+
for (t = arguments.length, n = new Array(t); t--; ) n[t] = arguments[t];
|
|
400
|
+
return n;
|
|
401
|
+
}
|
|
402
|
+
var un = typeof Symbol < "u" ? function(e) {
|
|
403
|
+
return e[Symbol.toStringTag] === "AsyncFunction";
|
|
404
|
+
} : function() {
|
|
405
|
+
return !1;
|
|
406
|
+
}, ct = ["Unknown", "Constraint", "Data", "TransactionInactive", "ReadOnly", "Version", "NotFound", "InvalidState", "InvalidAccess", "Abort", "Timeout", "QuotaExceeded", "Syntax", "DataClone"], pe = ["Modify", "Bulk", "OpenFailed", "VersionChange", "Schema", "Upgrade", "InvalidTable", "MissingAPI", "NoSuchDatabase", "InvalidArgument", "SubTransaction", "Unsupported", "Internal", "DatabaseClosed", "PrematureCommit", "ForeignAwait"].concat(ct), ii = { VersionChanged: "Database version changed by other database connection", DatabaseClosed: "Database has been closed", Abort: "Transaction aborted", TransactionInactive: "Transaction has already completed or failed", MissingAPI: "IndexedDB API missing. Please visit https://tinyurl.com/y2uuvskb" };
|
|
407
|
+
function Ge(e, t) {
|
|
408
|
+
this.name = e, this.message = t;
|
|
409
|
+
}
|
|
410
|
+
function ir(e, t) {
|
|
411
|
+
return e + ". Errors: " + Object.keys(t).map(function(n) {
|
|
412
|
+
return t[n].toString();
|
|
413
|
+
}).filter(function(n, r, i) {
|
|
414
|
+
return i.indexOf(n) === r;
|
|
415
|
+
}).join(`
|
|
416
|
+
`);
|
|
417
|
+
}
|
|
418
|
+
function xt(e, t, n, r) {
|
|
419
|
+
this.failures = t, this.failedKeys = r, this.successCount = n, this.message = ir(e, t);
|
|
420
|
+
}
|
|
421
|
+
function Qe(e, t) {
|
|
422
|
+
this.name = "BulkError", this.failures = Object.keys(t).map(function(n) {
|
|
423
|
+
return t[n];
|
|
424
|
+
}), this.failuresByPos = t, this.message = ir(e, this.failures);
|
|
425
|
+
}
|
|
426
|
+
$e(Ge).from(Error).extend({ toString: function() {
|
|
427
|
+
return this.name + ": " + this.message;
|
|
428
|
+
} }), $e(xt).from(Ge), $e(Qe).from(Ge);
|
|
429
|
+
var cn = pe.reduce(function(e, t) {
|
|
430
|
+
return e[t] = t + "Error", e;
|
|
431
|
+
}, {}), oi = Ge, D = pe.reduce(function(e, t) {
|
|
432
|
+
var n = t + "Error";
|
|
433
|
+
function r(i, o) {
|
|
434
|
+
this.name = n, i ? typeof i == "string" ? (this.message = "".concat(i).concat(o ? `
|
|
435
|
+
` + o : ""), this.inner = o || null) : typeof i == "object" && (this.message = "".concat(i.name, " ").concat(i.message), this.inner = i) : (this.message = ii[t] || n, this.inner = null);
|
|
436
|
+
}
|
|
437
|
+
return $e(r).from(oi), e[t] = r, e;
|
|
438
|
+
}, {});
|
|
439
|
+
D.Syntax = SyntaxError, D.Type = TypeError, D.Range = RangeError;
|
|
440
|
+
var or = ct.reduce(function(e, t) {
|
|
441
|
+
return e[t + "Error"] = D[t], e;
|
|
442
|
+
}, {}), Ot = pe.reduce(function(e, t) {
|
|
443
|
+
return ["Syntax", "Type", "Range"].indexOf(t) === -1 && (e[t + "Error"] = D[t]), e;
|
|
444
|
+
}, {});
|
|
445
|
+
function G() {
|
|
446
|
+
}
|
|
447
|
+
function st(e) {
|
|
448
|
+
return e;
|
|
449
|
+
}
|
|
450
|
+
function ai(e, t) {
|
|
451
|
+
return e == null || e === st ? t : function(n) {
|
|
452
|
+
return t(e(n));
|
|
453
|
+
};
|
|
454
|
+
}
|
|
455
|
+
function De(e, t) {
|
|
456
|
+
return function() {
|
|
457
|
+
e.apply(this, arguments), t.apply(this, arguments);
|
|
458
|
+
};
|
|
459
|
+
}
|
|
460
|
+
function si(e, t) {
|
|
461
|
+
return e === G ? t : function() {
|
|
462
|
+
var n = e.apply(this, arguments);
|
|
463
|
+
n !== void 0 && (arguments[0] = n);
|
|
464
|
+
var r = this.onsuccess, i = this.onerror;
|
|
465
|
+
this.onsuccess = null, this.onerror = null;
|
|
466
|
+
var o = t.apply(this, arguments);
|
|
467
|
+
return r && (this.onsuccess = this.onsuccess ? De(r, this.onsuccess) : r), i && (this.onerror = this.onerror ? De(i, this.onerror) : i), o !== void 0 ? o : n;
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
function ui(e, t) {
|
|
471
|
+
return e === G ? t : function() {
|
|
472
|
+
e.apply(this, arguments);
|
|
473
|
+
var n = this.onsuccess, r = this.onerror;
|
|
474
|
+
this.onsuccess = this.onerror = null, t.apply(this, arguments), n && (this.onsuccess = this.onsuccess ? De(n, this.onsuccess) : n), r && (this.onerror = this.onerror ? De(r, this.onerror) : r);
|
|
475
|
+
};
|
|
476
|
+
}
|
|
477
|
+
function ci(e, t) {
|
|
478
|
+
return e === G ? t : function(n) {
|
|
479
|
+
var r = e.apply(this, arguments);
|
|
480
|
+
W(n, r);
|
|
481
|
+
var i = this.onsuccess, o = this.onerror;
|
|
482
|
+
return this.onsuccess = null, this.onerror = null, n = t.apply(this, arguments), i && (this.onsuccess = this.onsuccess ? De(i, this.onsuccess) : i), o && (this.onerror = this.onerror ? De(o, this.onerror) : o), r === void 0 ? n === void 0 ? void 0 : n : W(r, n);
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function li(e, t) {
|
|
486
|
+
return e === G ? t : function() {
|
|
487
|
+
return t.apply(this, arguments) !== !1 && e.apply(this, arguments);
|
|
488
|
+
};
|
|
489
|
+
}
|
|
490
|
+
function ln(e, t) {
|
|
491
|
+
return e === G ? t : function() {
|
|
492
|
+
var n = e.apply(this, arguments);
|
|
493
|
+
if (n && typeof n.then == "function") {
|
|
494
|
+
for (var r = this, i = arguments.length, o = new Array(i); i--; ) o[i] = arguments[i];
|
|
495
|
+
return n.then(function() {
|
|
496
|
+
return t.apply(r, o);
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
return t.apply(this, arguments);
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
Ot.ModifyError = xt, Ot.DexieError = Ge, Ot.BulkError = Qe;
|
|
503
|
+
var ge = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
|
|
504
|
+
function ar(e) {
|
|
505
|
+
ge = e;
|
|
506
|
+
}
|
|
507
|
+
var ut = {}, sr = 100, je = typeof Promise > "u" ? [] : function() {
|
|
508
|
+
var e = Promise.resolve();
|
|
509
|
+
if (typeof crypto > "u" || !crypto.subtle) return [e, Y(e), e];
|
|
510
|
+
var t = crypto.subtle.digest("SHA-512", new Uint8Array([0]));
|
|
511
|
+
return [t, Y(t), e];
|
|
512
|
+
}(), ct = je[0], pe = je[1], je = je[2], pe = pe && pe.then, Be = ct && ct.constructor, fn = !!je, lt = function(e, t) {
|
|
513
|
+
ft.push([e, t]), kt && (queueMicrotask(hi), kt = !1);
|
|
514
|
+
}, hn = !0, kt = !0, Fe = [], Et = [], dn = st, Te = { id: "global", global: !0, ref: 0, unhandleds: [], onunhandled: G, pgp: !1, env: {}, finalize: G }, K = Te, ft = [], qe = 0, Tt = [];
|
|
515
|
+
function S(e) {
|
|
516
|
+
if (typeof this != "object") throw new TypeError("Promises must be constructed via new");
|
|
517
|
+
this._listeners = [], this._lib = !1;
|
|
518
|
+
var t = this._PSD = K;
|
|
519
|
+
if (typeof e != "function") {
|
|
520
|
+
if (e !== ut) throw new TypeError("Not a function");
|
|
521
|
+
return this._state = arguments[1], this._value = arguments[2], void (this._state === !1 && yn(this, this._value));
|
|
522
|
+
}
|
|
523
|
+
this._state = null, this._value = null, ++t.ref, function n(r, i) {
|
|
524
|
+
try {
|
|
525
|
+
i(function(o) {
|
|
526
|
+
if (r._state === null) {
|
|
527
|
+
if (o === r) throw new TypeError("A promise cannot be resolved with itself.");
|
|
528
|
+
var a = r._lib && Xe();
|
|
529
|
+
o && typeof o.then == "function" ? n(r, function(u, l) {
|
|
530
|
+
o instanceof S ? o._then(u, l) : o.then(u, l);
|
|
531
|
+
}) : (r._state = !0, r._value = o, cr(r)), a && Je();
|
|
532
|
+
}
|
|
533
|
+
}, yn.bind(null, r));
|
|
534
|
+
} catch (o) {
|
|
535
|
+
yn(r, o);
|
|
536
|
+
}
|
|
537
|
+
}(this, e);
|
|
538
|
+
}
|
|
539
|
+
var pn = { get: function() {
|
|
540
|
+
var e = K, t = At;
|
|
541
|
+
function n(r, i) {
|
|
542
|
+
var o = this, a = !e.global && (e !== K || t !== At), u = a && !Pe(), l = new S(function(h, y) {
|
|
543
|
+
mn(o, new ur(fr(r, e, a, u), fr(i, e, a, u), h, y, e));
|
|
544
|
+
});
|
|
545
|
+
return this._consoleTask && (l._consoleTask = this._consoleTask), l;
|
|
546
|
+
}
|
|
547
|
+
return n.prototype = ut, n;
|
|
548
|
+
}, set: function(e) {
|
|
549
|
+
ve(this, "then", e && e.prototype === ut ? pn : { get: function() {
|
|
550
|
+
return e;
|
|
551
|
+
}, set: pn.set });
|
|
552
|
+
} };
|
|
553
|
+
function ur(e, t, n, r, i) {
|
|
554
|
+
this.onFulfilled = typeof e == "function" ? e : null, this.onRejected = typeof t == "function" ? t : null, this.resolve = n, this.reject = r, this.psd = i;
|
|
555
|
+
}
|
|
556
|
+
function yn(e, t) {
|
|
557
|
+
var n, r;
|
|
558
|
+
Et.push(t), e._state === null && (n = e._lib && Xe(), t = dn(t), e._state = !1, e._value = t, r = e, Fe.some(function(i) {
|
|
559
|
+
return i._value === r._value;
|
|
560
|
+
}) || Fe.push(r), cr(e), n && Je());
|
|
561
|
+
}
|
|
562
|
+
function cr(e) {
|
|
563
|
+
var t = e._listeners;
|
|
564
|
+
e._listeners = [];
|
|
565
|
+
for (var n = 0, r = t.length; n < r; ++n) mn(e, t[n]);
|
|
566
|
+
var i = e._PSD;
|
|
567
|
+
--i.ref || i.finalize(), qe === 0 && (++qe, lt(function() {
|
|
568
|
+
--qe == 0 && vn();
|
|
569
|
+
}, []));
|
|
570
|
+
}
|
|
571
|
+
function mn(e, t) {
|
|
572
|
+
if (e._state !== null) {
|
|
573
|
+
var n = e._state ? t.onFulfilled : t.onRejected;
|
|
574
|
+
if (n === null) return (e._state ? t.resolve : t.reject)(e._value);
|
|
575
|
+
++t.psd.ref, ++qe, lt(fi, [n, e, t]);
|
|
576
|
+
} else e._listeners.push(t);
|
|
577
|
+
}
|
|
578
|
+
function fi(e, t, n) {
|
|
579
|
+
try {
|
|
580
|
+
var r, i = t._value;
|
|
581
|
+
!t._state && Et.length && (Et = []), r = ge && t._consoleTask ? t._consoleTask.run(function() {
|
|
582
|
+
return e(i);
|
|
583
|
+
}) : e(i), t._state || Et.indexOf(i) !== -1 || function(o) {
|
|
584
|
+
for (var a = Fe.length; a; ) if (Fe[--a]._value === o._value) return Fe.splice(a, 1);
|
|
585
|
+
}(t), n.resolve(r);
|
|
586
|
+
} catch (o) {
|
|
587
|
+
n.reject(o);
|
|
588
|
+
} finally {
|
|
589
|
+
--qe == 0 && vn(), --n.psd.ref || n.psd.finalize();
|
|
590
|
+
}
|
|
591
|
+
}
|
|
592
|
+
function hi() {
|
|
593
|
+
Me(Te, function() {
|
|
594
|
+
Xe() && Je();
|
|
595
|
+
});
|
|
596
|
+
}
|
|
597
|
+
function Xe() {
|
|
598
|
+
var e = hn;
|
|
599
|
+
return kt = hn = !1, e;
|
|
600
|
+
}
|
|
601
|
+
function Je() {
|
|
602
|
+
var e, t, n;
|
|
603
|
+
do
|
|
604
|
+
for (; 0 < ft.length; ) for (e = ft, ft = [], n = e.length, t = 0; t < n; ++t) {
|
|
605
|
+
var r = e[t];
|
|
606
|
+
r[0].apply(null, r[1]);
|
|
607
|
+
}
|
|
608
|
+
while (0 < ft.length);
|
|
609
|
+
kt = hn = !0;
|
|
610
|
+
}
|
|
611
|
+
function vn() {
|
|
612
|
+
var e = Fe;
|
|
613
|
+
Fe = [], e.forEach(function(r) {
|
|
614
|
+
r._PSD.onunhandled.call(null, r._value, r);
|
|
615
|
+
});
|
|
616
|
+
for (var t = Tt.slice(0), n = t.length; n; ) t[--n]();
|
|
617
|
+
}
|
|
618
|
+
function It(e) {
|
|
619
|
+
return new S(ut, !1, e);
|
|
620
|
+
}
|
|
621
|
+
function ee(e, t) {
|
|
622
|
+
var n = K;
|
|
623
|
+
return function() {
|
|
624
|
+
var r = Xe(), i = K;
|
|
625
|
+
try {
|
|
626
|
+
return Ce(n, !0), e.apply(this, arguments);
|
|
627
|
+
} catch (o) {
|
|
628
|
+
t && t(o);
|
|
629
|
+
} finally {
|
|
630
|
+
Ce(i, !1), r && Je();
|
|
631
|
+
}
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
X(S.prototype, { then: pn, _then: function(e, t) {
|
|
635
|
+
mn(this, new ur(null, null, e, t, K));
|
|
636
|
+
}, catch: function(e) {
|
|
637
|
+
if (arguments.length === 1) return this.then(null, e);
|
|
638
|
+
var t = e, n = arguments[1];
|
|
639
|
+
return typeof t == "function" ? this.then(null, function(r) {
|
|
640
|
+
return (r instanceof t ? n : It)(r);
|
|
641
|
+
}) : this.then(null, function(r) {
|
|
642
|
+
return (r && r.name === t ? n : It)(r);
|
|
643
|
+
});
|
|
644
|
+
}, finally: function(e) {
|
|
645
|
+
return this.then(function(t) {
|
|
646
|
+
return S.resolve(e()).then(function() {
|
|
647
|
+
return t;
|
|
648
|
+
});
|
|
649
|
+
}, function(t) {
|
|
650
|
+
return S.resolve(e()).then(function() {
|
|
651
|
+
return It(t);
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
}, timeout: function(e, t) {
|
|
655
|
+
var n = this;
|
|
656
|
+
return e < 1 / 0 ? new S(function(r, i) {
|
|
657
|
+
var o = setTimeout(function() {
|
|
658
|
+
return i(new D.Timeout(t));
|
|
659
|
+
}, e);
|
|
660
|
+
n.then(r, i).finally(clearTimeout.bind(null, o));
|
|
661
|
+
}) : this;
|
|
662
|
+
} }), typeof Symbol < "u" && Symbol.toStringTag && ve(S.prototype, Symbol.toStringTag, "Dexie.Promise"), Te.env = lr(), X(S, { all: function() {
|
|
663
|
+
var e = xe.apply(null, arguments).map(St);
|
|
664
|
+
return new S(function(t, n) {
|
|
665
|
+
e.length === 0 && t([]);
|
|
666
|
+
var r = e.length;
|
|
667
|
+
e.forEach(function(i, o) {
|
|
668
|
+
return S.resolve(i).then(function(a) {
|
|
669
|
+
e[o] = a, --r || t(e);
|
|
670
|
+
}, n);
|
|
671
|
+
});
|
|
672
|
+
});
|
|
673
|
+
}, resolve: function(e) {
|
|
674
|
+
return e instanceof S ? e : e && typeof e.then == "function" ? new S(function(t, n) {
|
|
675
|
+
e.then(t, n);
|
|
676
|
+
}) : new S(ut, !0, e);
|
|
677
|
+
}, reject: It, race: function() {
|
|
678
|
+
var e = xe.apply(null, arguments).map(St);
|
|
679
|
+
return new S(function(t, n) {
|
|
680
|
+
e.map(function(r) {
|
|
681
|
+
return S.resolve(r).then(t, n);
|
|
682
|
+
});
|
|
683
|
+
});
|
|
684
|
+
}, PSD: { get: function() {
|
|
685
|
+
return K;
|
|
686
|
+
}, set: function(e) {
|
|
687
|
+
return K = e;
|
|
688
|
+
} }, totalEchoes: { get: function() {
|
|
689
|
+
return At;
|
|
690
|
+
} }, newPSD: Ie, usePSD: Me, scheduler: { get: function() {
|
|
691
|
+
return lt;
|
|
692
|
+
}, set: function(e) {
|
|
693
|
+
lt = e;
|
|
694
|
+
} }, rejectionMapper: { get: function() {
|
|
695
|
+
return dn;
|
|
696
|
+
}, set: function(e) {
|
|
697
|
+
dn = e;
|
|
698
|
+
} }, follow: function(e, t) {
|
|
699
|
+
return new S(function(n, r) {
|
|
700
|
+
return Ie(function(i, o) {
|
|
701
|
+
var a = K;
|
|
702
|
+
a.unhandleds = [], a.onunhandled = o, a.finalize = De(function() {
|
|
703
|
+
var u, l = this;
|
|
704
|
+
u = function() {
|
|
705
|
+
l.unhandleds.length === 0 ? i() : o(l.unhandleds[0]);
|
|
706
|
+
}, Tt.push(function h() {
|
|
707
|
+
u(), Tt.splice(Tt.indexOf(h), 1);
|
|
708
|
+
}), ++qe, lt(function() {
|
|
709
|
+
--qe == 0 && vn();
|
|
710
|
+
}, []);
|
|
711
|
+
}, a.finalize), e();
|
|
712
|
+
}, t, n, r);
|
|
713
|
+
});
|
|
714
|
+
} }), Be && (Be.allSettled && ve(S, "allSettled", function() {
|
|
715
|
+
var e = xe.apply(null, arguments).map(St);
|
|
716
|
+
return new S(function(t) {
|
|
717
|
+
e.length === 0 && t([]);
|
|
718
|
+
var n = e.length, r = new Array(n);
|
|
719
|
+
e.forEach(function(i, o) {
|
|
720
|
+
return S.resolve(i).then(function(a) {
|
|
721
|
+
return r[o] = { status: "fulfilled", value: a };
|
|
722
|
+
}, function(a) {
|
|
723
|
+
return r[o] = { status: "rejected", reason: a };
|
|
724
|
+
}).then(function() {
|
|
725
|
+
return --n || t(r);
|
|
726
|
+
});
|
|
727
|
+
});
|
|
728
|
+
});
|
|
729
|
+
}), Be.any && typeof AggregateError < "u" && ve(S, "any", function() {
|
|
730
|
+
var e = xe.apply(null, arguments).map(St);
|
|
731
|
+
return new S(function(t, n) {
|
|
732
|
+
e.length === 0 && n(new AggregateError([]));
|
|
733
|
+
var r = e.length, i = new Array(r);
|
|
734
|
+
e.forEach(function(o, a) {
|
|
735
|
+
return S.resolve(o).then(function(u) {
|
|
736
|
+
return t(u);
|
|
737
|
+
}, function(u) {
|
|
738
|
+
i[a] = u, --r || n(new AggregateError(i));
|
|
739
|
+
});
|
|
740
|
+
});
|
|
741
|
+
});
|
|
742
|
+
}), Be.withResolvers && (S.withResolvers = Be.withResolvers));
|
|
743
|
+
var re = { awaits: 0, echoes: 0, id: 0 }, di = 0, Pt = [], Ct = 0, At = 0, pi = 0;
|
|
744
|
+
function Ie(e, t, n, r) {
|
|
745
|
+
var i = K, o = Object.create(i);
|
|
746
|
+
return o.parent = i, o.ref = 0, o.global = !1, o.id = ++pi, Te.env, o.env = fn ? { Promise: S, PromiseProp: { value: S, configurable: !0, writable: !0 }, all: S.all, race: S.race, allSettled: S.allSettled, any: S.any, resolve: S.resolve, reject: S.reject } : {}, t && W(o, t), ++i.ref, o.finalize = function() {
|
|
747
|
+
--this.parent.ref || this.parent.finalize();
|
|
748
|
+
}, r = Me(o, e, n, r), o.ref === 0 && o.finalize(), r;
|
|
749
|
+
}
|
|
750
|
+
function Ze() {
|
|
751
|
+
return re.id || (re.id = ++di), ++re.awaits, re.echoes += sr, re.id;
|
|
752
|
+
}
|
|
753
|
+
function Pe() {
|
|
754
|
+
return !!re.awaits && (--re.awaits == 0 && (re.id = 0), re.echoes = re.awaits * sr, !0);
|
|
755
|
+
}
|
|
756
|
+
function St(e) {
|
|
757
|
+
return re.echoes && e && e.constructor === Be ? (Ze(), e.then(function(t) {
|
|
758
|
+
return Pe(), t;
|
|
759
|
+
}, function(t) {
|
|
760
|
+
return Pe(), te(t);
|
|
761
|
+
})) : e;
|
|
762
|
+
}
|
|
763
|
+
function yi() {
|
|
764
|
+
var e = Pt[Pt.length - 1];
|
|
765
|
+
Pt.pop(), Ce(e, !1);
|
|
766
|
+
}
|
|
767
|
+
function Ce(e, t) {
|
|
768
|
+
var n, r = K;
|
|
769
|
+
(t ? !re.echoes || Ct++ && e === K : !Ct || --Ct && e === K) || queueMicrotask(t ? function(i) {
|
|
770
|
+
++At, re.echoes && --re.echoes != 0 || (re.echoes = re.awaits = re.id = 0), Pt.push(K), Ce(i, !0);
|
|
771
|
+
}.bind(null, e) : yi), e !== K && (K = e, r === Te && (Te.env = lr()), fn && (n = Te.env.Promise, t = e.env, (r.global || e.global) && (Object.defineProperty(N, "Promise", t.PromiseProp), n.all = t.all, n.race = t.race, n.resolve = t.resolve, n.reject = t.reject, t.allSettled && (n.allSettled = t.allSettled), t.any && (n.any = t.any))));
|
|
772
|
+
}
|
|
773
|
+
function lr() {
|
|
774
|
+
var e = N.Promise;
|
|
775
|
+
return fn ? { Promise: e, PromiseProp: Object.getOwnPropertyDescriptor(N, "Promise"), all: e.all, race: e.race, allSettled: e.allSettled, any: e.any, resolve: e.resolve, reject: e.reject } : {};
|
|
776
|
+
}
|
|
777
|
+
function Me(e, t, n, r, i) {
|
|
778
|
+
var o = K;
|
|
779
|
+
try {
|
|
780
|
+
return Ce(e, !0), t(n, r, i);
|
|
781
|
+
} finally {
|
|
782
|
+
Ce(o, !1);
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function fr(e, t, n, r) {
|
|
786
|
+
return typeof e != "function" ? e : function() {
|
|
787
|
+
var i = K;
|
|
788
|
+
n && Ze(), Ce(t, !0);
|
|
789
|
+
try {
|
|
790
|
+
return e.apply(this, arguments);
|
|
791
|
+
} finally {
|
|
792
|
+
Ce(i, !1), r && queueMicrotask(Pe);
|
|
793
|
+
}
|
|
794
|
+
};
|
|
795
|
+
}
|
|
796
|
+
function gn(e) {
|
|
797
|
+
Promise === Be && re.echoes === 0 ? Ct === 0 ? e() : enqueueNativeMicroTask(e) : setTimeout(e, 0);
|
|
798
|
+
}
|
|
799
|
+
("" + pe).indexOf("[native code]") === -1 && (Ze = Pe = G);
|
|
800
|
+
var te = S.reject, Le = "", Oe = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.", hr = "String expected.", et = [], Rt = "__dbnames", bn = "readonly", wn = "readwrite";
|
|
801
|
+
function Ue(e, t) {
|
|
802
|
+
return e ? t ? function() {
|
|
803
|
+
return e.apply(this, arguments) && t.apply(this, arguments);
|
|
804
|
+
} : e : t;
|
|
805
|
+
}
|
|
806
|
+
var dr = { type: 3, lower: -1 / 0, lowerOpen: !1, upper: [[]], upperOpen: !1 };
|
|
807
|
+
function Kt(e) {
|
|
808
|
+
return typeof e != "string" || /\./.test(e) ? function(t) {
|
|
809
|
+
return t;
|
|
810
|
+
} : function(t) {
|
|
811
|
+
return t[e] === void 0 && e in t && delete (t = Ke(t))[e], t;
|
|
812
|
+
};
|
|
813
|
+
}
|
|
814
|
+
function pr() {
|
|
815
|
+
throw D.Type();
|
|
816
|
+
}
|
|
817
|
+
function H(e, t) {
|
|
818
|
+
try {
|
|
819
|
+
var n = yr(e), r = yr(t);
|
|
820
|
+
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" ? NaN : -1;
|
|
821
|
+
switch (n) {
|
|
822
|
+
case "number":
|
|
823
|
+
case "Date":
|
|
824
|
+
case "string":
|
|
825
|
+
return t < e ? 1 : e < t ? -1 : 0;
|
|
826
|
+
case "binary":
|
|
827
|
+
return function(i, o) {
|
|
828
|
+
for (var a = i.length, u = o.length, l = a < u ? a : u, h = 0; h < l; ++h) if (i[h] !== o[h]) return i[h] < o[h] ? -1 : 1;
|
|
829
|
+
return a === u ? 0 : a < u ? -1 : 1;
|
|
830
|
+
}(mr(e), mr(t));
|
|
831
|
+
case "Array":
|
|
832
|
+
return function(i, o) {
|
|
833
|
+
for (var a = i.length, u = o.length, l = a < u ? a : u, h = 0; h < l; ++h) {
|
|
834
|
+
var y = H(i[h], o[h]);
|
|
835
|
+
if (y !== 0) return y;
|
|
836
|
+
}
|
|
837
|
+
return a === u ? 0 : a < u ? -1 : 1;
|
|
838
|
+
}(e, t);
|
|
839
|
+
}
|
|
840
|
+
} catch {
|
|
841
|
+
}
|
|
842
|
+
return NaN;
|
|
843
|
+
}
|
|
844
|
+
function yr(e) {
|
|
845
|
+
var t = typeof e;
|
|
846
|
+
return t != "object" ? t : ArrayBuffer.isView(e) ? "binary" : (e = an(e), e === "ArrayBuffer" ? "binary" : e);
|
|
847
|
+
}
|
|
848
|
+
function mr(e) {
|
|
849
|
+
return e instanceof Uint8Array ? e : ArrayBuffer.isView(e) ? new Uint8Array(e.buffer, e.byteOffset, e.byteLength) : new Uint8Array(e);
|
|
850
|
+
}
|
|
851
|
+
var vr = (J.prototype._trans = function(e, t, n) {
|
|
852
|
+
var r = this._tx || K.trans, i = this.name, o = ge && typeof console < "u" && console.createTask && console.createTask("Dexie: ".concat(e === "readonly" ? "read" : "write", " ").concat(this.name));
|
|
853
|
+
function a(h, y, c) {
|
|
854
|
+
if (!c.schema[i]) throw new D.NotFound("Table " + i + " not part of transaction");
|
|
855
|
+
return t(c.idbtrans, c);
|
|
856
|
+
}
|
|
857
|
+
var u = Xe();
|
|
858
|
+
try {
|
|
859
|
+
var l = r && r.db._novip === this.db._novip ? r === K.trans ? r._promise(e, a, n) : Ie(function() {
|
|
860
|
+
return r._promise(e, a, n);
|
|
861
|
+
}, { trans: r, transless: K.transless || K }) : function h(y, c, v, f) {
|
|
862
|
+
if (y.idbdb && (y._state.openComplete || K.letThrough || y._vip)) {
|
|
863
|
+
var p = y._createTransaction(c, v, y._dbSchema);
|
|
864
|
+
try {
|
|
865
|
+
p.create(), y._state.PR1398_maxLoop = 3;
|
|
866
|
+
} catch (m) {
|
|
867
|
+
return m.name === cn.InvalidState && y.isOpen() && 0 < --y._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), y.close({ disableAutoOpen: !1 }), y.open().then(function() {
|
|
868
|
+
return h(y, c, v, f);
|
|
869
|
+
})) : te(m);
|
|
870
|
+
}
|
|
871
|
+
return p._promise(c, function(m, d) {
|
|
872
|
+
return Ie(function() {
|
|
873
|
+
return K.trans = p, f(m, d, p);
|
|
874
|
+
});
|
|
875
|
+
}).then(function(m) {
|
|
876
|
+
if (c === "readwrite") try {
|
|
877
|
+
p.idbtrans.commit();
|
|
878
|
+
} catch {
|
|
879
|
+
}
|
|
880
|
+
return c === "readonly" ? m : p._completion.then(function() {
|
|
881
|
+
return m;
|
|
882
|
+
});
|
|
883
|
+
});
|
|
884
|
+
}
|
|
885
|
+
if (y._state.openComplete) return te(new D.DatabaseClosed(y._state.dbOpenError));
|
|
886
|
+
if (!y._state.isBeingOpened) {
|
|
887
|
+
if (!y._state.autoOpen) return te(new D.DatabaseClosed());
|
|
888
|
+
y.open().catch(G);
|
|
889
|
+
}
|
|
890
|
+
return y._state.dbReadyPromise.then(function() {
|
|
891
|
+
return h(y, c, v, f);
|
|
892
|
+
});
|
|
893
|
+
}(this.db, e, [this.name], a);
|
|
894
|
+
return o && (l._consoleTask = o, l = l.catch(function(h) {
|
|
895
|
+
return console.trace(h), te(h);
|
|
896
|
+
})), l;
|
|
897
|
+
} finally {
|
|
898
|
+
u && Je();
|
|
899
|
+
}
|
|
900
|
+
}, J.prototype.get = function(e, t) {
|
|
901
|
+
var n = this;
|
|
902
|
+
return e && e.constructor === Object ? this.where(e).first(t) : e == null ? te(new D.Type("Invalid argument to Table.get()")) : this._trans("readonly", function(r) {
|
|
903
|
+
return n.core.get({ trans: r, key: e }).then(function(i) {
|
|
904
|
+
return n.hook.reading.fire(i);
|
|
905
|
+
});
|
|
906
|
+
}).then(t);
|
|
907
|
+
}, J.prototype.where = function(e) {
|
|
908
|
+
if (typeof e == "string") return new this.db.WhereClause(this, e);
|
|
909
|
+
if (B(e)) return new this.db.WhereClause(this, "[".concat(e.join("+"), "]"));
|
|
910
|
+
var t = F(e);
|
|
911
|
+
if (t.length === 1) return this.where(t[0]).equals(e[t[0]]);
|
|
912
|
+
var n = this.schema.indexes.concat(this.schema.primKey).filter(function(u) {
|
|
913
|
+
if (u.compound && t.every(function(h) {
|
|
914
|
+
return 0 <= u.keyPath.indexOf(h);
|
|
915
|
+
})) {
|
|
916
|
+
for (var l = 0; l < t.length; ++l) if (t.indexOf(u.keyPath[l]) === -1) return !1;
|
|
917
|
+
return !0;
|
|
918
|
+
}
|
|
919
|
+
return !1;
|
|
920
|
+
}).sort(function(u, l) {
|
|
921
|
+
return u.keyPath.length - l.keyPath.length;
|
|
922
|
+
})[0];
|
|
923
|
+
if (n && this.db._maxKey !== Le) {
|
|
924
|
+
var o = n.keyPath.slice(0, t.length);
|
|
925
|
+
return this.where(o).equals(o.map(function(l) {
|
|
926
|
+
return e[l];
|
|
927
|
+
}));
|
|
928
|
+
}
|
|
929
|
+
!n && ge && console.warn("The query ".concat(JSON.stringify(e), " on ").concat(this.name, " would benefit from a ") + "compound index [".concat(t.join("+"), "]"));
|
|
930
|
+
var r = this.schema.idxByName;
|
|
931
|
+
function i(u, l) {
|
|
932
|
+
return H(u, l) === 0;
|
|
933
|
+
}
|
|
934
|
+
var a = t.reduce(function(c, l) {
|
|
935
|
+
var h = c[0], y = c[1], c = r[l], v = e[l];
|
|
936
|
+
return [h || c, h || !c ? Ue(y, c && c.multi ? function(f) {
|
|
937
|
+
return f = _e(f, l), B(f) && f.some(function(p) {
|
|
938
|
+
return i(v, p);
|
|
939
|
+
});
|
|
940
|
+
} : function(f) {
|
|
941
|
+
return i(v, _e(f, l));
|
|
942
|
+
}) : y];
|
|
943
|
+
}, [null, null]), o = a[0], a = a[1];
|
|
944
|
+
return o ? this.where(o.name).equals(e[o.keyPath]).filter(a) : n ? this.filter(a) : this.where(t).equals("");
|
|
945
|
+
}, J.prototype.filter = function(e) {
|
|
946
|
+
return this.toCollection().and(e);
|
|
947
|
+
}, J.prototype.count = function(e) {
|
|
948
|
+
return this.toCollection().count(e);
|
|
949
|
+
}, J.prototype.offset = function(e) {
|
|
950
|
+
return this.toCollection().offset(e);
|
|
951
|
+
}, J.prototype.limit = function(e) {
|
|
952
|
+
return this.toCollection().limit(e);
|
|
953
|
+
}, J.prototype.each = function(e) {
|
|
954
|
+
return this.toCollection().each(e);
|
|
955
|
+
}, J.prototype.toArray = function(e) {
|
|
956
|
+
return this.toCollection().toArray(e);
|
|
957
|
+
}, J.prototype.toCollection = function() {
|
|
958
|
+
return new this.db.Collection(new this.db.WhereClause(this));
|
|
959
|
+
}, J.prototype.orderBy = function(e) {
|
|
960
|
+
return new this.db.Collection(new this.db.WhereClause(this, B(e) ? "[".concat(e.join("+"), "]") : e));
|
|
961
|
+
}, J.prototype.reverse = function() {
|
|
962
|
+
return this.toCollection().reverse();
|
|
963
|
+
}, J.prototype.mapToClass = function(e) {
|
|
964
|
+
var t, n = this.db, r = this.name;
|
|
965
|
+
function i() {
|
|
966
|
+
return t !== null && t.apply(this, arguments) || this;
|
|
967
|
+
}
|
|
968
|
+
(this.schema.mappedClass = e).prototype instanceof pr && (function(l, h) {
|
|
969
|
+
if (typeof h != "function" && h !== null) throw new TypeError("Class extends value " + String(h) + " is not a constructor or null");
|
|
970
|
+
function y() {
|
|
971
|
+
this.constructor = l;
|
|
972
|
+
}
|
|
973
|
+
O(l, h), l.prototype = h === null ? Object.create(h) : (y.prototype = h.prototype, new y());
|
|
974
|
+
}(i, t = e), Object.defineProperty(i.prototype, "db", { get: function() {
|
|
975
|
+
return n;
|
|
976
|
+
}, enumerable: !1, configurable: !0 }), i.prototype.table = function() {
|
|
977
|
+
return r;
|
|
978
|
+
}, e = i);
|
|
979
|
+
for (var o = /* @__PURE__ */ new Set(), a = e.prototype; a; a = Y(a)) Object.getOwnPropertyNames(a).forEach(function(l) {
|
|
980
|
+
return o.add(l);
|
|
981
|
+
});
|
|
982
|
+
function u(l) {
|
|
983
|
+
if (!l) return l;
|
|
984
|
+
var h, y = Object.create(e.prototype);
|
|
985
|
+
for (h in l) if (!o.has(h)) try {
|
|
986
|
+
y[h] = l[h];
|
|
987
|
+
} catch {
|
|
988
|
+
}
|
|
989
|
+
return y;
|
|
990
|
+
}
|
|
991
|
+
return this.schema.readHook && this.hook.reading.unsubscribe(this.schema.readHook), this.schema.readHook = u, this.hook("reading", u), e;
|
|
992
|
+
}, J.prototype.defineClass = function() {
|
|
993
|
+
return this.mapToClass(function(e) {
|
|
994
|
+
W(this, e);
|
|
995
|
+
});
|
|
996
|
+
}, J.prototype.add = function(e, t) {
|
|
997
|
+
var n = this, r = this.schema.primKey, i = r.auto, o = r.keyPath, a = e;
|
|
998
|
+
return o && i && (a = Kt(o)(e)), this._trans("readwrite", function(u) {
|
|
999
|
+
return n.core.mutate({ trans: u, type: "add", keys: t != null ? [t] : null, values: [a] });
|
|
1000
|
+
}).then(function(u) {
|
|
1001
|
+
return u.numFailures ? S.reject(u.failures[0]) : u.lastResult;
|
|
1002
|
+
}).then(function(u) {
|
|
1003
|
+
if (o) try {
|
|
1004
|
+
le(e, o, u);
|
|
1005
|
+
} catch {
|
|
1006
|
+
}
|
|
1007
|
+
return u;
|
|
1008
|
+
});
|
|
1009
|
+
}, J.prototype.update = function(e, t) {
|
|
1010
|
+
return typeof e != "object" || B(e) ? this.where(":id").equals(e).modify(t) : (e = _e(e, this.schema.primKey.keyPath), e === void 0 ? te(new D.InvalidArgument("Given object does not contain its primary key")) : this.where(":id").equals(e).modify(t));
|
|
1011
|
+
}, J.prototype.put = function(e, t) {
|
|
1012
|
+
var n = this, r = this.schema.primKey, i = r.auto, o = r.keyPath, a = e;
|
|
1013
|
+
return o && i && (a = Kt(o)(e)), this._trans("readwrite", function(u) {
|
|
1014
|
+
return n.core.mutate({ trans: u, type: "put", values: [a], keys: t != null ? [t] : null });
|
|
1015
|
+
}).then(function(u) {
|
|
1016
|
+
return u.numFailures ? S.reject(u.failures[0]) : u.lastResult;
|
|
1017
|
+
}).then(function(u) {
|
|
1018
|
+
if (o) try {
|
|
1019
|
+
le(e, o, u);
|
|
1020
|
+
} catch {
|
|
1021
|
+
}
|
|
1022
|
+
return u;
|
|
1023
|
+
});
|
|
1024
|
+
}, J.prototype.delete = function(e) {
|
|
1025
|
+
var t = this;
|
|
1026
|
+
return this._trans("readwrite", function(n) {
|
|
1027
|
+
return t.core.mutate({ trans: n, type: "delete", keys: [e] });
|
|
1028
|
+
}).then(function(n) {
|
|
1029
|
+
return n.numFailures ? S.reject(n.failures[0]) : void 0;
|
|
1030
|
+
});
|
|
1031
|
+
}, J.prototype.clear = function() {
|
|
1032
|
+
var e = this;
|
|
1033
|
+
return this._trans("readwrite", function(t) {
|
|
1034
|
+
return e.core.mutate({ trans: t, type: "deleteRange", range: dr });
|
|
1035
|
+
}).then(function(t) {
|
|
1036
|
+
return t.numFailures ? S.reject(t.failures[0]) : void 0;
|
|
1037
|
+
});
|
|
1038
|
+
}, J.prototype.bulkGet = function(e) {
|
|
1039
|
+
var t = this;
|
|
1040
|
+
return this._trans("readonly", function(n) {
|
|
1041
|
+
return t.core.getMany({ keys: e, trans: n }).then(function(r) {
|
|
1042
|
+
return r.map(function(i) {
|
|
1043
|
+
return t.hook.reading.fire(i);
|
|
1044
|
+
});
|
|
1045
|
+
});
|
|
1046
|
+
});
|
|
1047
|
+
}, J.prototype.bulkAdd = function(e, t, n) {
|
|
1048
|
+
var r = this, i = Array.isArray(t) ? t : void 0, o = (n = n || (i ? void 0 : t)) ? n.allKeys : void 0;
|
|
1049
|
+
return this._trans("readwrite", function(a) {
|
|
1050
|
+
var h = r.schema.primKey, u = h.auto, h = h.keyPath;
|
|
1051
|
+
if (h && i) throw new D.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
|
|
1052
|
+
if (i && i.length !== e.length) throw new D.InvalidArgument("Arguments objects and keys must have the same length");
|
|
1053
|
+
var l = e.length, h = h && u ? e.map(Kt(h)) : e;
|
|
1054
|
+
return r.core.mutate({ trans: a, type: "add", keys: i, values: h, wantResults: o }).then(function(p) {
|
|
1055
|
+
var c = p.numFailures, v = p.results, f = p.lastResult, p = p.failures;
|
|
1056
|
+
if (c === 0) return o ? v : f;
|
|
1057
|
+
throw new Qe("".concat(r.name, ".bulkAdd(): ").concat(c, " of ").concat(l, " operations failed"), p);
|
|
1058
|
+
});
|
|
1059
|
+
});
|
|
1060
|
+
}, J.prototype.bulkPut = function(e, t, n) {
|
|
1061
|
+
var r = this, i = Array.isArray(t) ? t : void 0, o = (n = n || (i ? void 0 : t)) ? n.allKeys : void 0;
|
|
1062
|
+
return this._trans("readwrite", function(a) {
|
|
1063
|
+
var h = r.schema.primKey, u = h.auto, h = h.keyPath;
|
|
1064
|
+
if (h && i) throw new D.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
|
|
1065
|
+
if (i && i.length !== e.length) throw new D.InvalidArgument("Arguments objects and keys must have the same length");
|
|
1066
|
+
var l = e.length, h = h && u ? e.map(Kt(h)) : e;
|
|
1067
|
+
return r.core.mutate({ trans: a, type: "put", keys: i, values: h, wantResults: o }).then(function(p) {
|
|
1068
|
+
var c = p.numFailures, v = p.results, f = p.lastResult, p = p.failures;
|
|
1069
|
+
if (c === 0) return o ? v : f;
|
|
1070
|
+
throw new Qe("".concat(r.name, ".bulkPut(): ").concat(c, " of ").concat(l, " operations failed"), p);
|
|
1071
|
+
});
|
|
1072
|
+
});
|
|
1073
|
+
}, J.prototype.bulkUpdate = function(e) {
|
|
1074
|
+
var t = this, n = this.core, r = e.map(function(a) {
|
|
1075
|
+
return a.key;
|
|
1076
|
+
}), i = e.map(function(a) {
|
|
1077
|
+
return a.changes;
|
|
1078
|
+
}), o = [];
|
|
1079
|
+
return this._trans("readwrite", function(a) {
|
|
1080
|
+
return n.getMany({ trans: a, keys: r, cache: "clone" }).then(function(u) {
|
|
1081
|
+
var l = [], h = [];
|
|
1082
|
+
e.forEach(function(c, v) {
|
|
1083
|
+
var f = c.key, p = c.changes, m = u[v];
|
|
1084
|
+
if (m) {
|
|
1085
|
+
for (var d = 0, g = Object.keys(p); d < g.length; d++) {
|
|
1086
|
+
var b = g[d], w = p[b];
|
|
1087
|
+
if (b === t.schema.primKey.keyPath) {
|
|
1088
|
+
if (H(w, f) !== 0) throw new D.Constraint("Cannot update primary key in bulkUpdate()");
|
|
1089
|
+
} else le(m, b, w);
|
|
1090
|
+
}
|
|
1091
|
+
o.push(v), l.push(f), h.push(m);
|
|
1092
|
+
}
|
|
1093
|
+
});
|
|
1094
|
+
var y = l.length;
|
|
1095
|
+
return n.mutate({ trans: a, type: "put", keys: l, values: h, updates: { keys: r, changeSpecs: i } }).then(function(c) {
|
|
1096
|
+
var v = c.numFailures, f = c.failures;
|
|
1097
|
+
if (v === 0) return y;
|
|
1098
|
+
for (var p = 0, m = Object.keys(f); p < m.length; p++) {
|
|
1099
|
+
var d, g = m[p], b = o[Number(g)];
|
|
1100
|
+
b != null && (d = f[g], delete f[g], f[b] = d);
|
|
1101
|
+
}
|
|
1102
|
+
throw new Qe("".concat(t.name, ".bulkUpdate(): ").concat(v, " of ").concat(y, " operations failed"), f);
|
|
1103
|
+
});
|
|
1104
|
+
});
|
|
1105
|
+
});
|
|
1106
|
+
}, J.prototype.bulkDelete = function(e) {
|
|
1107
|
+
var t = this, n = e.length;
|
|
1108
|
+
return this._trans("readwrite", function(r) {
|
|
1109
|
+
return t.core.mutate({ trans: r, type: "delete", keys: e });
|
|
1110
|
+
}).then(function(a) {
|
|
1111
|
+
var i = a.numFailures, o = a.lastResult, a = a.failures;
|
|
1112
|
+
if (i === 0) return o;
|
|
1113
|
+
throw new Qe("".concat(t.name, ".bulkDelete(): ").concat(i, " of ").concat(n, " operations failed"), a);
|
|
1114
|
+
});
|
|
1115
|
+
}, J);
|
|
1116
|
+
function J() {
|
|
1117
|
+
}
|
|
1118
|
+
function ht(e) {
|
|
1119
|
+
function t(a, u) {
|
|
1120
|
+
if (u) {
|
|
1121
|
+
for (var l = arguments.length, h = new Array(l - 1); --l; ) h[l - 1] = arguments[l];
|
|
1122
|
+
return n[a].subscribe.apply(null, h), e;
|
|
1123
|
+
}
|
|
1124
|
+
if (typeof a == "string") return n[a];
|
|
1125
|
+
}
|
|
1126
|
+
var n = {};
|
|
1127
|
+
t.addEventType = o;
|
|
1128
|
+
for (var r = 1, i = arguments.length; r < i; ++r) o(arguments[r]);
|
|
1129
|
+
return t;
|
|
1130
|
+
function o(a, u, l) {
|
|
1131
|
+
if (typeof a != "object") {
|
|
1132
|
+
var h;
|
|
1133
|
+
u = u || li;
|
|
1134
|
+
var y = { subscribers: [], fire: l = l || G, subscribe: function(c) {
|
|
1135
|
+
y.subscribers.indexOf(c) === -1 && (y.subscribers.push(c), y.fire = u(y.fire, c));
|
|
1136
|
+
}, unsubscribe: function(c) {
|
|
1137
|
+
y.subscribers = y.subscribers.filter(function(v) {
|
|
1138
|
+
return v !== c;
|
|
1139
|
+
}), y.fire = y.subscribers.reduce(u, l);
|
|
1140
|
+
} };
|
|
1141
|
+
return n[a] = t[a] = y;
|
|
1142
|
+
}
|
|
1143
|
+
F(h = a).forEach(function(c) {
|
|
1144
|
+
var v = h[c];
|
|
1145
|
+
if (B(v)) o(c, h[c][0], h[c][1]);
|
|
1146
|
+
else {
|
|
1147
|
+
if (v !== "asap") throw new D.InvalidArgument("Invalid event config");
|
|
1148
|
+
var f = o(c, st, function() {
|
|
1149
|
+
for (var p = arguments.length, m = new Array(p); p--; ) m[p] = arguments[p];
|
|
1150
|
+
f.subscribers.forEach(function(d) {
|
|
1151
|
+
er(function() {
|
|
1152
|
+
d.apply(null, m);
|
|
1153
|
+
});
|
|
1154
|
+
});
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
}
|
|
1160
|
+
function dt(e, t) {
|
|
1161
|
+
return $e(t).from({ prototype: e }), t;
|
|
1162
|
+
}
|
|
1163
|
+
function tt(e, t) {
|
|
1164
|
+
return !(e.filter || e.algorithm || e.or) && (t ? e.justLimit : !e.replayFilter);
|
|
1165
|
+
}
|
|
1166
|
+
function _n(e, t) {
|
|
1167
|
+
e.filter = Ue(e.filter, t);
|
|
1168
|
+
}
|
|
1169
|
+
function xn(e, t, n) {
|
|
1170
|
+
var r = e.replayFilter;
|
|
1171
|
+
e.replayFilter = r ? function() {
|
|
1172
|
+
return Ue(r(), t());
|
|
1173
|
+
} : t, e.justLimit = n && !r;
|
|
1174
|
+
}
|
|
1175
|
+
function Nt(e, t) {
|
|
1176
|
+
if (e.isPrimKey) return t.primaryKey;
|
|
1177
|
+
var n = t.getIndexByKeyPath(e.index);
|
|
1178
|
+
if (!n) throw new D.Schema("KeyPath " + e.index + " on object store " + t.name + " is not indexed");
|
|
1179
|
+
return n;
|
|
1180
|
+
}
|
|
1181
|
+
function gr(e, t, n) {
|
|
1182
|
+
var r = Nt(e, t.schema);
|
|
1183
|
+
return t.openCursor({ trans: n, values: !e.keysOnly, reverse: e.dir === "prev", unique: !!e.unique, query: { index: r, range: e.range } });
|
|
1184
|
+
}
|
|
1185
|
+
function Dt(e, t, n, r) {
|
|
1186
|
+
var i = e.replayFilter ? Ue(e.filter, e.replayFilter()) : e.filter;
|
|
1187
|
+
if (e.or) {
|
|
1188
|
+
var o = {}, a = function(u, l, h) {
|
|
1189
|
+
var y, c;
|
|
1190
|
+
i && !i(l, h, function(v) {
|
|
1191
|
+
return l.stop(v);
|
|
1192
|
+
}, function(v) {
|
|
1193
|
+
return l.fail(v);
|
|
1194
|
+
}) || ((c = "" + (y = l.primaryKey)) == "[object ArrayBuffer]" && (c = "" + new Uint8Array(y)), z(o, c) || (o[c] = !0, t(u, l, h)));
|
|
1195
|
+
};
|
|
1196
|
+
return Promise.all([e.or._iterate(a, n), br(gr(e, r, n), e.algorithm, a, !e.keysOnly && e.valueMapper)]);
|
|
1197
|
+
}
|
|
1198
|
+
return br(gr(e, r, n), Ue(e.algorithm, i), t, !e.keysOnly && e.valueMapper);
|
|
1199
|
+
}
|
|
1200
|
+
function br(e, t, n, r) {
|
|
1201
|
+
var i = ee(r ? function(o, a, u) {
|
|
1202
|
+
return n(r(o), a, u);
|
|
1203
|
+
} : n);
|
|
1204
|
+
return e.then(function(o) {
|
|
1205
|
+
if (o) return o.start(function() {
|
|
1206
|
+
var a = function() {
|
|
1207
|
+
return o.continue();
|
|
1208
|
+
};
|
|
1209
|
+
t && !t(o, function(u) {
|
|
1210
|
+
return a = u;
|
|
1211
|
+
}, function(u) {
|
|
1212
|
+
o.stop(u), a = G;
|
|
1213
|
+
}, function(u) {
|
|
1214
|
+
o.fail(u), a = G;
|
|
1215
|
+
}) || i(o.value, o, function(u) {
|
|
1216
|
+
return a = u;
|
|
1217
|
+
}), a();
|
|
1218
|
+
});
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
var pt = (wr.prototype.execute = function(e) {
|
|
1222
|
+
var t = this["@@propmod"];
|
|
1223
|
+
if (t.add !== void 0) {
|
|
1224
|
+
var n = t.add;
|
|
1225
|
+
if (B(n)) return j(j([], B(e) ? e : [], !0), n).sort();
|
|
1226
|
+
if (typeof n == "number") return (Number(e) || 0) + n;
|
|
1227
|
+
if (typeof n == "bigint") try {
|
|
1228
|
+
return BigInt(e) + n;
|
|
1229
|
+
} catch {
|
|
1230
|
+
return BigInt(0) + n;
|
|
1231
|
+
}
|
|
1232
|
+
throw new TypeError("Invalid term ".concat(n));
|
|
1233
|
+
}
|
|
1234
|
+
if (t.remove !== void 0) {
|
|
1235
|
+
var r = t.remove;
|
|
1236
|
+
if (B(r)) return B(e) ? e.filter(function(i) {
|
|
1237
|
+
return !r.includes(i);
|
|
1238
|
+
}).sort() : [];
|
|
1239
|
+
if (typeof r == "number") return Number(e) - r;
|
|
1240
|
+
if (typeof r == "bigint") try {
|
|
1241
|
+
return BigInt(e) - r;
|
|
1242
|
+
} catch {
|
|
1243
|
+
return BigInt(0) - r;
|
|
1244
|
+
}
|
|
1245
|
+
throw new TypeError("Invalid subtrahend ".concat(r));
|
|
1246
|
+
}
|
|
1247
|
+
return n = (n = t.replacePrefix) === null || n === void 0 ? void 0 : n[0], n && typeof e == "string" && e.startsWith(n) ? t.replacePrefix[1] + e.substring(n.length) : e;
|
|
1248
|
+
}, wr);
|
|
1249
|
+
function wr(e) {
|
|
1250
|
+
this["@@propmod"] = e;
|
|
1251
|
+
}
|
|
1252
|
+
var mi = ($.prototype._read = function(e, t) {
|
|
1253
|
+
var n = this._ctx;
|
|
1254
|
+
return n.error ? n.table._trans(null, te.bind(null, n.error)) : n.table._trans("readonly", e).then(t);
|
|
1255
|
+
}, $.prototype._write = function(e) {
|
|
1256
|
+
var t = this._ctx;
|
|
1257
|
+
return t.error ? t.table._trans(null, te.bind(null, t.error)) : t.table._trans("readwrite", e, "locked");
|
|
1258
|
+
}, $.prototype._addAlgorithm = function(e) {
|
|
1259
|
+
var t = this._ctx;
|
|
1260
|
+
t.algorithm = Ue(t.algorithm, e);
|
|
1261
|
+
}, $.prototype._iterate = function(e, t) {
|
|
1262
|
+
return Dt(this._ctx, e, t, this._ctx.table.core);
|
|
1263
|
+
}, $.prototype.clone = function(e) {
|
|
1264
|
+
var t = Object.create(this.constructor.prototype), n = Object.create(this._ctx);
|
|
1265
|
+
return e && W(n, e), t._ctx = n, t;
|
|
1266
|
+
}, $.prototype.raw = function() {
|
|
1267
|
+
return this._ctx.valueMapper = null, this;
|
|
1268
|
+
}, $.prototype.each = function(e) {
|
|
1269
|
+
var t = this._ctx;
|
|
1270
|
+
return this._read(function(n) {
|
|
1271
|
+
return Dt(t, e, n, t.table.core);
|
|
1272
|
+
});
|
|
1273
|
+
}, $.prototype.count = function(e) {
|
|
1274
|
+
var t = this;
|
|
1275
|
+
return this._read(function(n) {
|
|
1276
|
+
var r = t._ctx, i = r.table.core;
|
|
1277
|
+
if (tt(r, !0)) return i.count({ trans: n, query: { index: Nt(r, i.schema), range: r.range } }).then(function(a) {
|
|
1278
|
+
return Math.min(a, r.limit);
|
|
1279
|
+
});
|
|
1280
|
+
var o = 0;
|
|
1281
|
+
return Dt(r, function() {
|
|
1282
|
+
return ++o, !1;
|
|
1283
|
+
}, n, i).then(function() {
|
|
1284
|
+
return o;
|
|
1285
|
+
});
|
|
1286
|
+
}).then(e);
|
|
1287
|
+
}, $.prototype.sortBy = function(e, t) {
|
|
1288
|
+
var n = e.split(".").reverse(), r = n[0], i = n.length - 1;
|
|
1289
|
+
function o(l, h) {
|
|
1290
|
+
return h ? o(l[n[h]], h - 1) : l[r];
|
|
1291
|
+
}
|
|
1292
|
+
var a = this._ctx.dir === "next" ? 1 : -1;
|
|
1293
|
+
function u(l, h) {
|
|
1294
|
+
return H(o(l, i), o(h, i)) * a;
|
|
1295
|
+
}
|
|
1296
|
+
return this.toArray(function(l) {
|
|
1297
|
+
return l.sort(u);
|
|
1298
|
+
}).then(t);
|
|
1299
|
+
}, $.prototype.toArray = function(e) {
|
|
1300
|
+
var t = this;
|
|
1301
|
+
return this._read(function(n) {
|
|
1302
|
+
var r = t._ctx;
|
|
1303
|
+
if (r.dir === "next" && tt(r, !0) && 0 < r.limit) {
|
|
1304
|
+
var i = r.valueMapper, o = Nt(r, r.table.core.schema);
|
|
1305
|
+
return r.table.core.query({ trans: n, limit: r.limit, values: !0, query: { index: o, range: r.range } }).then(function(u) {
|
|
1306
|
+
return u = u.result, i ? u.map(i) : u;
|
|
1307
|
+
});
|
|
1308
|
+
}
|
|
1309
|
+
var a = [];
|
|
1310
|
+
return Dt(r, function(u) {
|
|
1311
|
+
return a.push(u);
|
|
1312
|
+
}, n, r.table.core).then(function() {
|
|
1313
|
+
return a;
|
|
1314
|
+
});
|
|
1315
|
+
}, e);
|
|
1316
|
+
}, $.prototype.offset = function(e) {
|
|
1317
|
+
var t = this._ctx;
|
|
1318
|
+
return e <= 0 || (t.offset += e, tt(t) ? xn(t, function() {
|
|
1319
|
+
var n = e;
|
|
1320
|
+
return function(r, i) {
|
|
1321
|
+
return n === 0 || (n === 1 ? --n : i(function() {
|
|
1322
|
+
r.advance(n), n = 0;
|
|
1323
|
+
}), !1);
|
|
1324
|
+
};
|
|
1325
|
+
}) : xn(t, function() {
|
|
1326
|
+
var n = e;
|
|
1327
|
+
return function() {
|
|
1328
|
+
return --n < 0;
|
|
1329
|
+
};
|
|
1330
|
+
})), this;
|
|
1331
|
+
}, $.prototype.limit = function(e) {
|
|
1332
|
+
return this._ctx.limit = Math.min(this._ctx.limit, e), xn(this._ctx, function() {
|
|
1333
|
+
var t = e;
|
|
1334
|
+
return function(n, r, i) {
|
|
1335
|
+
return --t <= 0 && r(i), 0 <= t;
|
|
1336
|
+
};
|
|
1337
|
+
}, !0), this;
|
|
1338
|
+
}, $.prototype.until = function(e, t) {
|
|
1339
|
+
return _n(this._ctx, function(n, r, i) {
|
|
1340
|
+
return !e(n.value) || (r(i), t);
|
|
1341
|
+
}), this;
|
|
1342
|
+
}, $.prototype.first = function(e) {
|
|
1343
|
+
return this.limit(1).toArray(function(t) {
|
|
1344
|
+
return t[0];
|
|
1345
|
+
}).then(e);
|
|
1346
|
+
}, $.prototype.last = function(e) {
|
|
1347
|
+
return this.reverse().first(e);
|
|
1348
|
+
}, $.prototype.filter = function(e) {
|
|
1349
|
+
var t;
|
|
1350
|
+
return _n(this._ctx, function(n) {
|
|
1351
|
+
return e(n.value);
|
|
1352
|
+
}), (t = this._ctx).isMatch = Ue(t.isMatch, e), this;
|
|
1353
|
+
}, $.prototype.and = function(e) {
|
|
1354
|
+
return this.filter(e);
|
|
1355
|
+
}, $.prototype.or = function(e) {
|
|
1356
|
+
return new this.db.WhereClause(this._ctx.table, e, this);
|
|
1357
|
+
}, $.prototype.reverse = function() {
|
|
1358
|
+
return this._ctx.dir = this._ctx.dir === "prev" ? "next" : "prev", this._ondirectionchange && this._ondirectionchange(this._ctx.dir), this;
|
|
1359
|
+
}, $.prototype.desc = function() {
|
|
1360
|
+
return this.reverse();
|
|
1361
|
+
}, $.prototype.eachKey = function(e) {
|
|
1362
|
+
var t = this._ctx;
|
|
1363
|
+
return t.keysOnly = !t.isMatch, this.each(function(n, r) {
|
|
1364
|
+
e(r.key, r);
|
|
1365
|
+
});
|
|
1366
|
+
}, $.prototype.eachUniqueKey = function(e) {
|
|
1367
|
+
return this._ctx.unique = "unique", this.eachKey(e);
|
|
1368
|
+
}, $.prototype.eachPrimaryKey = function(e) {
|
|
1369
|
+
var t = this._ctx;
|
|
1370
|
+
return t.keysOnly = !t.isMatch, this.each(function(n, r) {
|
|
1371
|
+
e(r.primaryKey, r);
|
|
1372
|
+
});
|
|
1373
|
+
}, $.prototype.keys = function(e) {
|
|
1374
|
+
var t = this._ctx;
|
|
1375
|
+
t.keysOnly = !t.isMatch;
|
|
1376
|
+
var n = [];
|
|
1377
|
+
return this.each(function(r, i) {
|
|
1378
|
+
n.push(i.key);
|
|
1379
|
+
}).then(function() {
|
|
1380
|
+
return n;
|
|
1381
|
+
}).then(e);
|
|
1382
|
+
}, $.prototype.primaryKeys = function(e) {
|
|
1383
|
+
var t = this._ctx;
|
|
1384
|
+
if (t.dir === "next" && tt(t, !0) && 0 < t.limit) return this._read(function(r) {
|
|
1385
|
+
var i = Nt(t, t.table.core.schema);
|
|
1386
|
+
return t.table.core.query({ trans: r, values: !1, limit: t.limit, query: { index: i, range: t.range } });
|
|
1387
|
+
}).then(function(r) {
|
|
1388
|
+
return r.result;
|
|
1389
|
+
}).then(e);
|
|
1390
|
+
t.keysOnly = !t.isMatch;
|
|
1391
|
+
var n = [];
|
|
1392
|
+
return this.each(function(r, i) {
|
|
1393
|
+
n.push(i.primaryKey);
|
|
1394
|
+
}).then(function() {
|
|
1395
|
+
return n;
|
|
1396
|
+
}).then(e);
|
|
1397
|
+
}, $.prototype.uniqueKeys = function(e) {
|
|
1398
|
+
return this._ctx.unique = "unique", this.keys(e);
|
|
1399
|
+
}, $.prototype.firstKey = function(e) {
|
|
1400
|
+
return this.limit(1).keys(function(t) {
|
|
1401
|
+
return t[0];
|
|
1402
|
+
}).then(e);
|
|
1403
|
+
}, $.prototype.lastKey = function(e) {
|
|
1404
|
+
return this.reverse().firstKey(e);
|
|
1405
|
+
}, $.prototype.distinct = function() {
|
|
1406
|
+
var e = this._ctx, e = e.index && e.table.schema.idxByName[e.index];
|
|
1407
|
+
if (!e || !e.multi) return this;
|
|
1408
|
+
var t = {};
|
|
1409
|
+
return _n(this._ctx, function(i) {
|
|
1410
|
+
var r = i.primaryKey.toString(), i = z(t, r);
|
|
1411
|
+
return t[r] = !0, !i;
|
|
1412
|
+
}), this;
|
|
1413
|
+
}, $.prototype.modify = function(e) {
|
|
1414
|
+
var t = this, n = this._ctx;
|
|
1415
|
+
return this._write(function(r) {
|
|
1416
|
+
var i, o, a;
|
|
1417
|
+
a = typeof e == "function" ? e : (i = F(e), o = i.length, function(d) {
|
|
1418
|
+
for (var g = !1, b = 0; b < o; ++b) {
|
|
1419
|
+
var w = i[b], x = e[w], E = _e(d, w);
|
|
1420
|
+
x instanceof pt ? (le(d, w, x.execute(E)), g = !0) : E !== x && (le(d, w, x), g = !0);
|
|
1421
|
+
}
|
|
1422
|
+
return g;
|
|
1423
|
+
});
|
|
1424
|
+
var u = n.table.core, c = u.schema.primaryKey, l = c.outbound, h = c.extractKey, y = 200, c = t.db._options.modifyChunkSize;
|
|
1425
|
+
c && (y = typeof c == "object" ? c[u.name] || c["*"] || 200 : c);
|
|
1426
|
+
function v(d, w) {
|
|
1427
|
+
var b = w.failures, w = w.numFailures;
|
|
1428
|
+
p += d - w;
|
|
1429
|
+
for (var x = 0, E = F(b); x < E.length; x++) {
|
|
1430
|
+
var C = E[x];
|
|
1431
|
+
f.push(b[C]);
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
var f = [], p = 0, m = [];
|
|
1435
|
+
return t.clone().primaryKeys().then(function(d) {
|
|
1436
|
+
function g(w) {
|
|
1437
|
+
var x = Math.min(y, d.length - w);
|
|
1438
|
+
return u.getMany({ trans: r, keys: d.slice(w, w + x), cache: "immutable" }).then(function(E) {
|
|
1439
|
+
for (var C = [], T = [], I = l ? [] : null, A = [], P = 0; P < x; ++P) {
|
|
1440
|
+
var R = E[P], M = { value: Ke(R), primKey: d[w + P] };
|
|
1441
|
+
a.call(M, M.value, M) !== !1 && (M.value == null ? A.push(d[w + P]) : l || H(h(R), h(M.value)) === 0 ? (T.push(M.value), l && I.push(d[w + P])) : (A.push(d[w + P]), C.push(M.value)));
|
|
1442
|
+
}
|
|
1443
|
+
return Promise.resolve(0 < C.length && u.mutate({ trans: r, type: "add", values: C }).then(function(L) {
|
|
1444
|
+
for (var U in L.failures) A.splice(parseInt(U), 1);
|
|
1445
|
+
v(C.length, L);
|
|
1446
|
+
})).then(function() {
|
|
1447
|
+
return (0 < T.length || b && typeof e == "object") && u.mutate({ trans: r, type: "put", keys: I, values: T, criteria: b, changeSpec: typeof e != "function" && e, isAdditionalChunk: 0 < w }).then(function(L) {
|
|
1448
|
+
return v(T.length, L);
|
|
1449
|
+
});
|
|
1450
|
+
}).then(function() {
|
|
1451
|
+
return (0 < A.length || b && e === On) && u.mutate({ trans: r, type: "delete", keys: A, criteria: b, isAdditionalChunk: 0 < w }).then(function(L) {
|
|
1452
|
+
return v(A.length, L);
|
|
1453
|
+
});
|
|
1454
|
+
}).then(function() {
|
|
1455
|
+
return d.length > w + x && g(w + y);
|
|
1456
|
+
});
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
var b = tt(n) && n.limit === 1 / 0 && (typeof e != "function" || e === On) && { index: n.index, range: n.range };
|
|
1460
|
+
return g(0).then(function() {
|
|
1461
|
+
if (0 < f.length) throw new xt("Error modifying one or more objects", f, p, m);
|
|
1462
|
+
return d.length;
|
|
1463
|
+
});
|
|
1464
|
+
});
|
|
1465
|
+
});
|
|
1466
|
+
}, $.prototype.delete = function() {
|
|
1467
|
+
var e = this._ctx, t = e.range;
|
|
1468
|
+
return tt(e) && (e.isPrimKey || t.type === 3) ? this._write(function(n) {
|
|
1469
|
+
var r = e.table.core.schema.primaryKey, i = t;
|
|
1470
|
+
return e.table.core.count({ trans: n, query: { index: r, range: i } }).then(function(o) {
|
|
1471
|
+
return e.table.core.mutate({ trans: n, type: "deleteRange", range: i }).then(function(a) {
|
|
1472
|
+
var u = a.failures;
|
|
1473
|
+
if (a.lastResult, a.results, a = a.numFailures, a) throw new xt("Could not delete some values", Object.keys(u).map(function(l) {
|
|
1474
|
+
return u[l];
|
|
1475
|
+
}), o - a);
|
|
1476
|
+
return o - a;
|
|
1477
|
+
});
|
|
1478
|
+
});
|
|
1479
|
+
}) : this.modify(On);
|
|
1480
|
+
}, $);
|
|
1481
|
+
function $() {
|
|
1482
|
+
}
|
|
1483
|
+
var On = function(e, t) {
|
|
1484
|
+
return t.value = null;
|
|
1485
|
+
};
|
|
1486
|
+
function vi(e, t) {
|
|
1487
|
+
return e < t ? -1 : e === t ? 0 : 1;
|
|
1488
|
+
}
|
|
1489
|
+
function gi(e, t) {
|
|
1490
|
+
return t < e ? -1 : e === t ? 0 : 1;
|
|
1491
|
+
}
|
|
1492
|
+
function fe(e, t, n) {
|
|
1493
|
+
return e = e instanceof xr ? new e.Collection(e) : e, e._ctx.error = new (n || TypeError)(t), e;
|
|
1494
|
+
}
|
|
1495
|
+
function nt(e) {
|
|
1496
|
+
return new e.Collection(e, function() {
|
|
1497
|
+
return _r("");
|
|
1498
|
+
}).limit(0);
|
|
1499
|
+
}
|
|
1500
|
+
function jt(e, t, n, r) {
|
|
1501
|
+
var i, o, a, u, l, h, y, c = n.length;
|
|
1502
|
+
if (!n.every(function(p) {
|
|
1503
|
+
return typeof p == "string";
|
|
1504
|
+
})) return fe(e, hr);
|
|
1505
|
+
function v(p) {
|
|
1506
|
+
i = p === "next" ? function(d) {
|
|
1507
|
+
return d.toUpperCase();
|
|
1508
|
+
} : function(d) {
|
|
1509
|
+
return d.toLowerCase();
|
|
1510
|
+
}, o = p === "next" ? function(d) {
|
|
1511
|
+
return d.toLowerCase();
|
|
1512
|
+
} : function(d) {
|
|
1513
|
+
return d.toUpperCase();
|
|
1514
|
+
}, a = p === "next" ? vi : gi;
|
|
1515
|
+
var m = n.map(function(d) {
|
|
1516
|
+
return { lower: o(d), upper: i(d) };
|
|
1517
|
+
}).sort(function(d, g) {
|
|
1518
|
+
return a(d.lower, g.lower);
|
|
1519
|
+
});
|
|
1520
|
+
u = m.map(function(d) {
|
|
1521
|
+
return d.upper;
|
|
1522
|
+
}), l = m.map(function(d) {
|
|
1523
|
+
return d.lower;
|
|
1524
|
+
}), y = (h = p) === "next" ? "" : r;
|
|
1525
|
+
}
|
|
1526
|
+
v("next"), e = new e.Collection(e, function() {
|
|
1527
|
+
return Ae(u[0], l[c - 1] + r);
|
|
1528
|
+
}), e._ondirectionchange = function(p) {
|
|
1529
|
+
v(p);
|
|
1530
|
+
};
|
|
1531
|
+
var f = 0;
|
|
1532
|
+
return e._addAlgorithm(function(p, m, d) {
|
|
1533
|
+
var g = p.key;
|
|
1534
|
+
if (typeof g != "string") return !1;
|
|
1535
|
+
var b = o(g);
|
|
1536
|
+
if (t(b, l, f)) return !0;
|
|
1537
|
+
for (var w = null, x = f; x < c; ++x) {
|
|
1538
|
+
var E = function(C, T, I, A, P, R) {
|
|
1539
|
+
for (var M = Math.min(C.length, A.length), L = -1, U = 0; U < M; ++U) {
|
|
1540
|
+
var he = T[U];
|
|
1541
|
+
if (he !== A[U]) return P(C[U], I[U]) < 0 ? C.substr(0, U) + I[U] + I.substr(U + 1) : P(C[U], A[U]) < 0 ? C.substr(0, U) + A[U] + I.substr(U + 1) : 0 <= L ? C.substr(0, L) + T[L] + I.substr(L + 1) : null;
|
|
1542
|
+
P(C[U], he) < 0 && (L = U);
|
|
1543
|
+
}
|
|
1544
|
+
return M < A.length && R === "next" ? C + I.substr(C.length) : M < C.length && R === "prev" ? C.substr(0, I.length) : L < 0 ? null : C.substr(0, L) + A[L] + I.substr(L + 1);
|
|
1545
|
+
}(g, b, u[x], l[x], a, h);
|
|
1546
|
+
E === null && w === null ? f = x + 1 : (w === null || 0 < a(w, E)) && (w = E);
|
|
1547
|
+
}
|
|
1548
|
+
return m(w !== null ? function() {
|
|
1549
|
+
p.continue(w + y);
|
|
1550
|
+
} : d), !1;
|
|
1551
|
+
}), e;
|
|
1552
|
+
}
|
|
1553
|
+
function Ae(e, t, n, r) {
|
|
1554
|
+
return { type: 2, lower: e, upper: t, lowerOpen: n, upperOpen: r };
|
|
1555
|
+
}
|
|
1556
|
+
function _r(e) {
|
|
1557
|
+
return { type: 1, lower: e, upper: e };
|
|
1558
|
+
}
|
|
1559
|
+
var xr = (Object.defineProperty(ie.prototype, "Collection", { get: function() {
|
|
1560
|
+
return this._ctx.table.db.Collection;
|
|
1561
|
+
}, enumerable: !1, configurable: !0 }), ie.prototype.between = function(e, t, n, r) {
|
|
1562
|
+
n = n !== !1, r = r === !0;
|
|
1563
|
+
try {
|
|
1564
|
+
return 0 < this._cmp(e, t) || this._cmp(e, t) === 0 && (n || r) && (!n || !r) ? nt(this) : new this.Collection(this, function() {
|
|
1565
|
+
return Ae(e, t, !n, !r);
|
|
1566
|
+
});
|
|
1567
|
+
} catch {
|
|
1568
|
+
return fe(this, Oe);
|
|
1569
|
+
}
|
|
1570
|
+
}, ie.prototype.equals = function(e) {
|
|
1571
|
+
return e == null ? fe(this, Oe) : new this.Collection(this, function() {
|
|
1572
|
+
return _r(e);
|
|
1573
|
+
});
|
|
1574
|
+
}, ie.prototype.above = function(e) {
|
|
1575
|
+
return e == null ? fe(this, Oe) : new this.Collection(this, function() {
|
|
1576
|
+
return Ae(e, void 0, !0);
|
|
1577
|
+
});
|
|
1578
|
+
}, ie.prototype.aboveOrEqual = function(e) {
|
|
1579
|
+
return e == null ? fe(this, Oe) : new this.Collection(this, function() {
|
|
1580
|
+
return Ae(e, void 0, !1);
|
|
1581
|
+
});
|
|
1582
|
+
}, ie.prototype.below = function(e) {
|
|
1583
|
+
return e == null ? fe(this, Oe) : new this.Collection(this, function() {
|
|
1584
|
+
return Ae(void 0, e, !1, !0);
|
|
1585
|
+
});
|
|
1586
|
+
}, ie.prototype.belowOrEqual = function(e) {
|
|
1587
|
+
return e == null ? fe(this, Oe) : new this.Collection(this, function() {
|
|
1588
|
+
return Ae(void 0, e);
|
|
1589
|
+
});
|
|
1590
|
+
}, ie.prototype.startsWith = function(e) {
|
|
1591
|
+
return typeof e != "string" ? fe(this, hr) : this.between(e, e + Le, !0, !0);
|
|
1592
|
+
}, ie.prototype.startsWithIgnoreCase = function(e) {
|
|
1593
|
+
return e === "" ? this.startsWith(e) : jt(this, function(t, n) {
|
|
1594
|
+
return t.indexOf(n[0]) === 0;
|
|
1595
|
+
}, [e], Le);
|
|
1596
|
+
}, ie.prototype.equalsIgnoreCase = function(e) {
|
|
1597
|
+
return jt(this, function(t, n) {
|
|
1598
|
+
return t === n[0];
|
|
1599
|
+
}, [e], "");
|
|
1600
|
+
}, ie.prototype.anyOfIgnoreCase = function() {
|
|
1601
|
+
var e = xe.apply(Ye, arguments);
|
|
1602
|
+
return e.length === 0 ? nt(this) : jt(this, function(t, n) {
|
|
1603
|
+
return n.indexOf(t) !== -1;
|
|
1604
|
+
}, e, "");
|
|
1605
|
+
}, ie.prototype.startsWithAnyOfIgnoreCase = function() {
|
|
1606
|
+
var e = xe.apply(Ye, arguments);
|
|
1607
|
+
return e.length === 0 ? nt(this) : jt(this, function(t, n) {
|
|
1608
|
+
return n.some(function(r) {
|
|
1609
|
+
return t.indexOf(r) === 0;
|
|
1610
|
+
});
|
|
1611
|
+
}, e, Le);
|
|
1612
|
+
}, ie.prototype.anyOf = function() {
|
|
1613
|
+
var e = this, t = xe.apply(Ye, arguments), n = this._cmp;
|
|
1614
|
+
try {
|
|
1615
|
+
t.sort(n);
|
|
1616
|
+
} catch {
|
|
1617
|
+
return fe(this, Oe);
|
|
1618
|
+
}
|
|
1619
|
+
if (t.length === 0) return nt(this);
|
|
1620
|
+
var r = new this.Collection(this, function() {
|
|
1621
|
+
return Ae(t[0], t[t.length - 1]);
|
|
1622
|
+
});
|
|
1623
|
+
r._ondirectionchange = function(o) {
|
|
1624
|
+
n = o === "next" ? e._ascending : e._descending, t.sort(n);
|
|
1625
|
+
};
|
|
1626
|
+
var i = 0;
|
|
1627
|
+
return r._addAlgorithm(function(o, a, u) {
|
|
1628
|
+
for (var l = o.key; 0 < n(l, t[i]); ) if (++i === t.length) return a(u), !1;
|
|
1629
|
+
return n(l, t[i]) === 0 || (a(function() {
|
|
1630
|
+
o.continue(t[i]);
|
|
1631
|
+
}), !1);
|
|
1632
|
+
}), r;
|
|
1633
|
+
}, ie.prototype.notEqual = function(e) {
|
|
1634
|
+
return this.inAnyRange([[-1 / 0, e], [e, this.db._maxKey]], { includeLowers: !1, includeUppers: !1 });
|
|
1635
|
+
}, ie.prototype.noneOf = function() {
|
|
1636
|
+
var e = xe.apply(Ye, arguments);
|
|
1637
|
+
if (e.length === 0) return new this.Collection(this);
|
|
1638
|
+
try {
|
|
1639
|
+
e.sort(this._ascending);
|
|
1640
|
+
} catch {
|
|
1641
|
+
return fe(this, Oe);
|
|
1642
|
+
}
|
|
1643
|
+
var t = e.reduce(function(n, r) {
|
|
1644
|
+
return n ? n.concat([[n[n.length - 1][1], r]]) : [[-1 / 0, r]];
|
|
1645
|
+
}, null);
|
|
1646
|
+
return t.push([e[e.length - 1], this.db._maxKey]), this.inAnyRange(t, { includeLowers: !1, includeUppers: !1 });
|
|
1647
|
+
}, ie.prototype.inAnyRange = function(g, t) {
|
|
1648
|
+
var n = this, r = this._cmp, i = this._ascending, o = this._descending, a = this._min, u = this._max;
|
|
1649
|
+
if (g.length === 0) return nt(this);
|
|
1650
|
+
if (!g.every(function(b) {
|
|
1651
|
+
return b[0] !== void 0 && b[1] !== void 0 && i(b[0], b[1]) <= 0;
|
|
1652
|
+
})) return fe(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", D.InvalidArgument);
|
|
1653
|
+
var l = !t || t.includeLowers !== !1, h = t && t.includeUppers === !0, y, c = i;
|
|
1654
|
+
function v(b, w) {
|
|
1655
|
+
return c(b[0], w[0]);
|
|
1656
|
+
}
|
|
1657
|
+
try {
|
|
1658
|
+
(y = g.reduce(function(b, w) {
|
|
1659
|
+
for (var x = 0, E = b.length; x < E; ++x) {
|
|
1660
|
+
var C = b[x];
|
|
1661
|
+
if (r(w[0], C[1]) < 0 && 0 < r(w[1], C[0])) {
|
|
1662
|
+
C[0] = a(C[0], w[0]), C[1] = u(C[1], w[1]);
|
|
1663
|
+
break;
|
|
1664
|
+
}
|
|
1665
|
+
}
|
|
1666
|
+
return x === E && b.push(w), b;
|
|
1667
|
+
}, [])).sort(v);
|
|
1668
|
+
} catch {
|
|
1669
|
+
return fe(this, Oe);
|
|
1670
|
+
}
|
|
1671
|
+
var f = 0, p = h ? function(b) {
|
|
1672
|
+
return 0 < i(b, y[f][1]);
|
|
1673
|
+
} : function(b) {
|
|
1674
|
+
return 0 <= i(b, y[f][1]);
|
|
1675
|
+
}, m = l ? function(b) {
|
|
1676
|
+
return 0 < o(b, y[f][0]);
|
|
1677
|
+
} : function(b) {
|
|
1678
|
+
return 0 <= o(b, y[f][0]);
|
|
1679
|
+
}, d = p, g = new this.Collection(this, function() {
|
|
1680
|
+
return Ae(y[0][0], y[y.length - 1][1], !l, !h);
|
|
1681
|
+
});
|
|
1682
|
+
return g._ondirectionchange = function(b) {
|
|
1683
|
+
c = b === "next" ? (d = p, i) : (d = m, o), y.sort(v);
|
|
1684
|
+
}, g._addAlgorithm(function(b, w, x) {
|
|
1685
|
+
for (var E, C = b.key; d(C); ) if (++f === y.length) return w(x), !1;
|
|
1686
|
+
return !p(E = C) && !m(E) || (n._cmp(C, y[f][1]) === 0 || n._cmp(C, y[f][0]) === 0 || w(function() {
|
|
1687
|
+
c === i ? b.continue(y[f][0]) : b.continue(y[f][1]);
|
|
1688
|
+
}), !1);
|
|
1689
|
+
}), g;
|
|
1690
|
+
}, ie.prototype.startsWithAnyOf = function() {
|
|
1691
|
+
var e = xe.apply(Ye, arguments);
|
|
1692
|
+
return e.every(function(t) {
|
|
1693
|
+
return typeof t == "string";
|
|
1694
|
+
}) ? e.length === 0 ? nt(this) : this.inAnyRange(e.map(function(t) {
|
|
1695
|
+
return [t, t + Le];
|
|
1696
|
+
})) : fe(this, "startsWithAnyOf() only works with strings");
|
|
1697
|
+
}, ie);
|
|
1698
|
+
function ie() {
|
|
1699
|
+
}
|
|
1700
|
+
function be(e) {
|
|
1701
|
+
return ee(function(t) {
|
|
1702
|
+
return yt(t), e(t.target.error), !1;
|
|
1703
|
+
});
|
|
1704
|
+
}
|
|
1705
|
+
function yt(e) {
|
|
1706
|
+
e.stopPropagation && e.stopPropagation(), e.preventDefault && e.preventDefault();
|
|
1707
|
+
}
|
|
1708
|
+
var mt = "storagemutated", kn = "x-storagemutated-1", Se = ht(null, mt), bi = (we.prototype._lock = function() {
|
|
1709
|
+
return ot(!K.global), ++this._reculock, this._reculock !== 1 || K.global || (K.lockOwnerFor = this), this;
|
|
1710
|
+
}, we.prototype._unlock = function() {
|
|
1711
|
+
if (ot(!K.global), --this._reculock == 0) for (K.global || (K.lockOwnerFor = null); 0 < this._blockedFuncs.length && !this._locked(); ) {
|
|
1712
|
+
var e = this._blockedFuncs.shift();
|
|
1713
|
+
try {
|
|
1714
|
+
Me(e[1], e[0]);
|
|
1715
|
+
} catch {
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
return this;
|
|
1719
|
+
}, we.prototype._locked = function() {
|
|
1720
|
+
return this._reculock && K.lockOwnerFor !== this;
|
|
1721
|
+
}, we.prototype.create = function(e) {
|
|
1722
|
+
var t = this;
|
|
1723
|
+
if (!this.mode) return this;
|
|
1724
|
+
var n = this.db.idbdb, r = this.db._state.dbOpenError;
|
|
1725
|
+
if (ot(!this.idbtrans), !e && !n) switch (r && r.name) {
|
|
1726
|
+
case "DatabaseClosedError":
|
|
1727
|
+
throw new D.DatabaseClosed(r);
|
|
1728
|
+
case "MissingAPIError":
|
|
1729
|
+
throw new D.MissingAPI(r.message, r);
|
|
1730
|
+
default:
|
|
1731
|
+
throw new D.OpenFailed(r);
|
|
1732
|
+
}
|
|
1733
|
+
if (!this.active) throw new D.TransactionInactive();
|
|
1734
|
+
return ot(this._completion._state === null), (e = this.idbtrans = e || (this.db.core || n).transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability })).onerror = ee(function(i) {
|
|
1735
|
+
yt(i), t._reject(e.error);
|
|
1736
|
+
}), e.onabort = ee(function(i) {
|
|
1737
|
+
yt(i), t.active && t._reject(new D.Abort(e.error)), t.active = !1, t.on("abort").fire(i);
|
|
1738
|
+
}), e.oncomplete = ee(function() {
|
|
1739
|
+
t.active = !1, t._resolve(), "mutatedParts" in e && Se.storagemutated.fire(e.mutatedParts);
|
|
1740
|
+
}), this;
|
|
1741
|
+
}, we.prototype._promise = function(e, t, n) {
|
|
1742
|
+
var r = this;
|
|
1743
|
+
if (e === "readwrite" && this.mode !== "readwrite") return te(new D.ReadOnly("Transaction is readonly"));
|
|
1744
|
+
if (!this.active) return te(new D.TransactionInactive());
|
|
1745
|
+
if (this._locked()) return new S(function(o, a) {
|
|
1746
|
+
r._blockedFuncs.push([function() {
|
|
1747
|
+
r._promise(e, t, n).then(o, a);
|
|
1748
|
+
}, K]);
|
|
1749
|
+
});
|
|
1750
|
+
if (n) return Ie(function() {
|
|
1751
|
+
var o = new S(function(a, u) {
|
|
1752
|
+
r._lock();
|
|
1753
|
+
var l = t(a, u, r);
|
|
1754
|
+
l && l.then && l.then(a, u);
|
|
1755
|
+
});
|
|
1756
|
+
return o.finally(function() {
|
|
1757
|
+
return r._unlock();
|
|
1758
|
+
}), o._lib = !0, o;
|
|
1759
|
+
});
|
|
1760
|
+
var i = new S(function(o, a) {
|
|
1761
|
+
var u = t(o, a, r);
|
|
1762
|
+
u && u.then && u.then(o, a);
|
|
1763
|
+
});
|
|
1764
|
+
return i._lib = !0, i;
|
|
1765
|
+
}, we.prototype._root = function() {
|
|
1766
|
+
return this.parent ? this.parent._root() : this;
|
|
1767
|
+
}, we.prototype.waitFor = function(e) {
|
|
1768
|
+
var t, n = this._root(), r = S.resolve(e);
|
|
1769
|
+
n._waitingFor ? n._waitingFor = n._waitingFor.then(function() {
|
|
1770
|
+
return r;
|
|
1771
|
+
}) : (n._waitingFor = r, n._waitingQueue = [], t = n.idbtrans.objectStore(n.storeNames[0]), function o() {
|
|
1772
|
+
for (++n._spinCount; n._waitingQueue.length; ) n._waitingQueue.shift()();
|
|
1773
|
+
n._waitingFor && (t.get(-1 / 0).onsuccess = o);
|
|
1774
|
+
}());
|
|
1775
|
+
var i = n._waitingFor;
|
|
1776
|
+
return new S(function(o, a) {
|
|
1777
|
+
r.then(function(u) {
|
|
1778
|
+
return n._waitingQueue.push(ee(o.bind(null, u)));
|
|
1779
|
+
}, function(u) {
|
|
1780
|
+
return n._waitingQueue.push(ee(a.bind(null, u)));
|
|
1781
|
+
}).finally(function() {
|
|
1782
|
+
n._waitingFor === i && (n._waitingFor = null);
|
|
1783
|
+
});
|
|
1784
|
+
});
|
|
1785
|
+
}, we.prototype.abort = function() {
|
|
1786
|
+
this.active && (this.active = !1, this.idbtrans && this.idbtrans.abort(), this._reject(new D.Abort()));
|
|
1787
|
+
}, we.prototype.table = function(e) {
|
|
1788
|
+
var t = this._memoizedTables || (this._memoizedTables = {});
|
|
1789
|
+
if (z(t, e)) return t[e];
|
|
1790
|
+
var n = this.schema[e];
|
|
1791
|
+
if (!n) throw new D.NotFound("Table " + e + " not part of transaction");
|
|
1792
|
+
return n = new this.db.Table(e, n, this), n.core = this.db.core.table(e), t[e] = n;
|
|
1793
|
+
}, we);
|
|
1794
|
+
function we() {
|
|
1795
|
+
}
|
|
1796
|
+
function En(e, t, n, r, i, o, a) {
|
|
1797
|
+
return { name: e, keyPath: t, unique: n, multi: r, auto: i, compound: o, src: (n && !a ? "&" : "") + (r ? "*" : "") + (i ? "++" : "") + Or(t) };
|
|
1798
|
+
}
|
|
1799
|
+
function Or(e) {
|
|
1800
|
+
return typeof e == "string" ? e : e ? "[" + [].join.call(e, "+") + "]" : "";
|
|
1801
|
+
}
|
|
1802
|
+
function Tn(e, t, n) {
|
|
1803
|
+
return { name: e, primKey: t, indexes: n, mappedClass: null, idxByName: (r = function(i) {
|
|
1804
|
+
return [i.name, i];
|
|
1805
|
+
}, n.reduce(function(i, o, a) {
|
|
1806
|
+
return a = r(o, a), a && (i[a[0]] = a[1]), i;
|
|
1807
|
+
}, {})) };
|
|
1808
|
+
var r;
|
|
1809
|
+
}
|
|
1810
|
+
var vt = function(e) {
|
|
1811
|
+
try {
|
|
1812
|
+
return e.only([[]]), vt = function() {
|
|
1813
|
+
return [[]];
|
|
1814
|
+
}, [[]];
|
|
1815
|
+
} catch {
|
|
1816
|
+
return vt = function() {
|
|
1817
|
+
return Le;
|
|
1818
|
+
}, Le;
|
|
1819
|
+
}
|
|
1820
|
+
};
|
|
1821
|
+
function In(e) {
|
|
1822
|
+
return e == null ? function() {
|
|
1823
|
+
} : typeof e == "string" ? (t = e).split(".").length === 1 ? function(n) {
|
|
1824
|
+
return n[t];
|
|
1825
|
+
} : function(n) {
|
|
1826
|
+
return _e(n, t);
|
|
1827
|
+
} : function(n) {
|
|
1828
|
+
return _e(n, e);
|
|
1829
|
+
};
|
|
1830
|
+
var t;
|
|
1831
|
+
}
|
|
1832
|
+
function kr(e) {
|
|
1833
|
+
return [].slice.call(e);
|
|
1834
|
+
}
|
|
1835
|
+
var wi = 0;
|
|
1836
|
+
function gt(e) {
|
|
1837
|
+
return e == null ? ":id" : typeof e == "string" ? e : "[".concat(e.join("+"), "]");
|
|
1838
|
+
}
|
|
1839
|
+
function _i(e, t, l) {
|
|
1840
|
+
function r(d) {
|
|
1841
|
+
if (d.type === 3) return null;
|
|
1842
|
+
if (d.type === 4) throw new Error("Cannot convert never type to IDBKeyRange");
|
|
1843
|
+
var f = d.lower, p = d.upper, m = d.lowerOpen, d = d.upperOpen;
|
|
1844
|
+
return f === void 0 ? p === void 0 ? null : t.upperBound(p, !!d) : p === void 0 ? t.lowerBound(f, !!m) : t.bound(f, p, !!m, !!d);
|
|
1845
|
+
}
|
|
1846
|
+
function i(v) {
|
|
1847
|
+
var f, p = v.name;
|
|
1848
|
+
return { name: p, schema: v, mutate: function(m) {
|
|
1849
|
+
var d = m.trans, g = m.type, b = m.keys, w = m.values, x = m.range;
|
|
1850
|
+
return new Promise(function(E, C) {
|
|
1851
|
+
E = ee(E);
|
|
1852
|
+
var T = d.objectStore(p), I = T.keyPath == null, A = g === "put" || g === "add";
|
|
1853
|
+
if (!A && g !== "delete" && g !== "deleteRange") throw new Error("Invalid operation type: " + g);
|
|
1854
|
+
var P, R = (b || w || { length: 1 }).length;
|
|
1855
|
+
if (b && w && b.length !== w.length) throw new Error("Given keys array must have same length as given values array.");
|
|
1856
|
+
if (R === 0) return E({ numFailures: 0, failures: {}, results: [], lastResult: void 0 });
|
|
1857
|
+
function M(ue) {
|
|
1858
|
+
++he, yt(ue);
|
|
1859
|
+
}
|
|
1860
|
+
var L = [], U = [], he = 0;
|
|
1861
|
+
if (g === "deleteRange") {
|
|
1862
|
+
if (x.type === 4) return E({ numFailures: he, failures: U, results: [], lastResult: void 0 });
|
|
1863
|
+
x.type === 3 ? L.push(P = T.clear()) : L.push(P = T.delete(r(x)));
|
|
1864
|
+
} else {
|
|
1865
|
+
var I = A ? I ? [w, b] : [w, null] : [b, null], q = I[0], ae = I[1];
|
|
1866
|
+
if (A) for (var se = 0; se < R; ++se) L.push(P = ae && ae[se] !== void 0 ? T[g](q[se], ae[se]) : T[g](q[se])), P.onerror = M;
|
|
1867
|
+
else for (se = 0; se < R; ++se) L.push(P = T[g](q[se])), P.onerror = M;
|
|
1868
|
+
}
|
|
1869
|
+
function Gt(ue) {
|
|
1870
|
+
ue = ue.target.result, L.forEach(function(He, Hn) {
|
|
1871
|
+
return He.error != null && (U[Hn] = He.error);
|
|
1872
|
+
}), E({ numFailures: he, failures: U, results: g === "delete" ? b : L.map(function(He) {
|
|
1873
|
+
return He.result;
|
|
1874
|
+
}), lastResult: ue });
|
|
1875
|
+
}
|
|
1876
|
+
P.onerror = function(ue) {
|
|
1877
|
+
M(ue), Gt(ue);
|
|
1878
|
+
}, P.onsuccess = Gt;
|
|
1879
|
+
});
|
|
1880
|
+
}, getMany: function(m) {
|
|
1881
|
+
var d = m.trans, g = m.keys;
|
|
1882
|
+
return new Promise(function(b, w) {
|
|
1883
|
+
b = ee(b);
|
|
1884
|
+
for (var x, E = d.objectStore(p), C = g.length, T = new Array(C), I = 0, A = 0, P = function(L) {
|
|
1885
|
+
L = L.target, T[L._pos] = L.result, ++A === I && b(T);
|
|
1886
|
+
}, R = be(w), M = 0; M < C; ++M) g[M] != null && ((x = E.get(g[M]))._pos = M, x.onsuccess = P, x.onerror = R, ++I);
|
|
1887
|
+
I === 0 && b(T);
|
|
1888
|
+
});
|
|
1889
|
+
}, get: function(m) {
|
|
1890
|
+
var d = m.trans, g = m.key;
|
|
1891
|
+
return new Promise(function(b, w) {
|
|
1892
|
+
b = ee(b);
|
|
1893
|
+
var x = d.objectStore(p).get(g);
|
|
1894
|
+
x.onsuccess = function(E) {
|
|
1895
|
+
return b(E.target.result);
|
|
1896
|
+
}, x.onerror = be(w);
|
|
1897
|
+
});
|
|
1898
|
+
}, query: (f = h, function(m) {
|
|
1899
|
+
return new Promise(function(d, g) {
|
|
1900
|
+
d = ee(d);
|
|
1901
|
+
var b, w, x, I = m.trans, E = m.values, C = m.limit, P = m.query, T = C === 1 / 0 ? void 0 : C, A = P.index, P = P.range, I = I.objectStore(p), A = A.isPrimaryKey ? I : I.index(A.name), P = r(P);
|
|
1902
|
+
if (C === 0) return d({ result: [] });
|
|
1903
|
+
f ? ((T = E ? A.getAll(P, T) : A.getAllKeys(P, T)).onsuccess = function(R) {
|
|
1904
|
+
return d({ result: R.target.result });
|
|
1905
|
+
}, T.onerror = be(g)) : (b = 0, w = !E && "openKeyCursor" in A ? A.openKeyCursor(P) : A.openCursor(P), x = [], w.onsuccess = function(R) {
|
|
1906
|
+
var M = w.result;
|
|
1907
|
+
return M ? (x.push(E ? M.value : M.primaryKey), ++b === C ? d({ result: x }) : void M.continue()) : d({ result: x });
|
|
1908
|
+
}, w.onerror = be(g));
|
|
1909
|
+
});
|
|
1910
|
+
}), openCursor: function(m) {
|
|
1911
|
+
var d = m.trans, g = m.values, b = m.query, w = m.reverse, x = m.unique;
|
|
1912
|
+
return new Promise(function(E, C) {
|
|
1913
|
+
E = ee(E);
|
|
1914
|
+
var A = b.index, T = b.range, I = d.objectStore(p), I = A.isPrimaryKey ? I : I.index(A.name), A = w ? x ? "prevunique" : "prev" : x ? "nextunique" : "next", P = !g && "openKeyCursor" in I ? I.openKeyCursor(r(T), A) : I.openCursor(r(T), A);
|
|
1915
|
+
P.onerror = be(C), P.onsuccess = ee(function(R) {
|
|
1916
|
+
var M, L, U, he, q = P.result;
|
|
1917
|
+
q ? (q.___id = ++wi, q.done = !1, M = q.continue.bind(q), L = (L = q.continuePrimaryKey) && L.bind(q), U = q.advance.bind(q), he = function() {
|
|
1918
|
+
throw new Error("Cursor not stopped");
|
|
1919
|
+
}, q.trans = d, q.stop = q.continue = q.continuePrimaryKey = q.advance = function() {
|
|
1920
|
+
throw new Error("Cursor not started");
|
|
1921
|
+
}, q.fail = ee(C), q.next = function() {
|
|
1922
|
+
var ae = this, se = 1;
|
|
1923
|
+
return this.start(function() {
|
|
1924
|
+
return se-- ? ae.continue() : ae.stop();
|
|
1925
|
+
}).then(function() {
|
|
1926
|
+
return ae;
|
|
1927
|
+
});
|
|
1928
|
+
}, q.start = function(ae) {
|
|
1929
|
+
function se() {
|
|
1930
|
+
if (P.result) try {
|
|
1931
|
+
ae();
|
|
1932
|
+
} catch (ue) {
|
|
1933
|
+
q.fail(ue);
|
|
1934
|
+
}
|
|
1935
|
+
else q.done = !0, q.start = function() {
|
|
1936
|
+
throw new Error("Cursor behind last entry");
|
|
1937
|
+
}, q.stop();
|
|
1938
|
+
}
|
|
1939
|
+
var Gt = new Promise(function(ue, He) {
|
|
1940
|
+
ue = ee(ue), P.onerror = be(He), q.fail = He, q.stop = function(Hn) {
|
|
1941
|
+
q.stop = q.continue = q.continuePrimaryKey = q.advance = he, ue(Hn);
|
|
1942
|
+
};
|
|
1943
|
+
});
|
|
1944
|
+
return P.onsuccess = ee(function(ue) {
|
|
1945
|
+
P.onsuccess = se, se();
|
|
1946
|
+
}), q.continue = M, q.continuePrimaryKey = L, q.advance = U, se(), Gt;
|
|
1947
|
+
}, E(q)) : E(null);
|
|
1948
|
+
}, C);
|
|
1949
|
+
});
|
|
1950
|
+
}, count: function(m) {
|
|
1951
|
+
var d = m.query, g = m.trans, b = d.index, w = d.range;
|
|
1952
|
+
return new Promise(function(x, E) {
|
|
1953
|
+
var C = g.objectStore(p), T = b.isPrimaryKey ? C : C.index(b.name), C = r(w), T = C ? T.count(C) : T.count();
|
|
1954
|
+
T.onsuccess = ee(function(I) {
|
|
1955
|
+
return x(I.target.result);
|
|
1956
|
+
}), T.onerror = be(E);
|
|
1957
|
+
});
|
|
1958
|
+
} };
|
|
1959
|
+
}
|
|
1960
|
+
var o, a, u, y = (a = l, u = kr((o = e).objectStoreNames), { schema: { name: o.name, tables: u.map(function(v) {
|
|
1961
|
+
return a.objectStore(v);
|
|
1962
|
+
}).map(function(v) {
|
|
1963
|
+
var f = v.keyPath, d = v.autoIncrement, p = B(f), m = {}, d = { name: v.name, primaryKey: { name: null, isPrimaryKey: !0, outbound: f == null, compound: p, keyPath: f, autoIncrement: d, unique: !0, extractKey: In(f) }, indexes: kr(v.indexNames).map(function(g) {
|
|
1964
|
+
return v.index(g);
|
|
1965
|
+
}).map(function(x) {
|
|
1966
|
+
var b = x.name, w = x.unique, E = x.multiEntry, x = x.keyPath, E = { name: b, compound: B(x), keyPath: x, unique: w, multiEntry: E, extractKey: In(x) };
|
|
1967
|
+
return m[gt(x)] = E;
|
|
1968
|
+
}), getIndexByKeyPath: function(g) {
|
|
1969
|
+
return m[gt(g)];
|
|
1970
|
+
} };
|
|
1971
|
+
return m[":id"] = d.primaryKey, f != null && (m[gt(f)] = d.primaryKey), d;
|
|
1972
|
+
}) }, hasGetAll: 0 < u.length && "getAll" in a.objectStore(u[0]) && !(typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604) }), l = y.schema, h = y.hasGetAll, y = l.tables.map(i), c = {};
|
|
1973
|
+
return y.forEach(function(v) {
|
|
1974
|
+
return c[v.name] = v;
|
|
1975
|
+
}), { stack: "dbcore", transaction: e.transaction.bind(e), table: function(v) {
|
|
1976
|
+
if (!c[v]) throw new Error("Table '".concat(v, "' not found"));
|
|
1977
|
+
return c[v];
|
|
1978
|
+
}, MIN_KEY: -1 / 0, MAX_KEY: vt(t), schema: l };
|
|
1979
|
+
}
|
|
1980
|
+
function xi(e, t, n, r) {
|
|
1981
|
+
var i = n.IDBKeyRange;
|
|
1982
|
+
return n.indexedDB, { dbcore: (r = _i(t, i, r), e.dbcore.reduce(function(o, a) {
|
|
1983
|
+
return a = a.create, k(k({}, o), a(o));
|
|
1984
|
+
}, r)) };
|
|
1985
|
+
}
|
|
1986
|
+
function Bt(e, r) {
|
|
1987
|
+
var n = r.db, r = xi(e._middlewares, n, e._deps, r);
|
|
1988
|
+
e.core = r.dbcore, e.tables.forEach(function(i) {
|
|
1989
|
+
var o = i.name;
|
|
1990
|
+
e.core.schema.tables.some(function(a) {
|
|
1991
|
+
return a.name === o;
|
|
1992
|
+
}) && (i.core = e.core.table(o), e[o] instanceof e.Table && (e[o].core = i.core));
|
|
1993
|
+
});
|
|
1994
|
+
}
|
|
1995
|
+
function Ft(e, t, n, r) {
|
|
1996
|
+
n.forEach(function(i) {
|
|
1997
|
+
var o = r[i];
|
|
1998
|
+
t.forEach(function(a) {
|
|
1999
|
+
var u = function l(h, y) {
|
|
2000
|
+
return Zr(h, y) || (h = Y(h)) && l(h, y);
|
|
2001
|
+
}(a, i);
|
|
2002
|
+
(!u || "value" in u && u.value === void 0) && (a === e.Transaction.prototype || a instanceof e.Transaction ? ve(a, i, { get: function() {
|
|
2003
|
+
return this.table(i);
|
|
2004
|
+
}, set: function(l) {
|
|
2005
|
+
ce(this, i, { value: l, writable: !0, configurable: !0, enumerable: !0 });
|
|
2006
|
+
} }) : a[i] = new e.Table(i, o));
|
|
2007
|
+
});
|
|
2008
|
+
});
|
|
2009
|
+
}
|
|
2010
|
+
function Pn(e, t) {
|
|
2011
|
+
t.forEach(function(n) {
|
|
2012
|
+
for (var r in n) n[r] instanceof e.Table && delete n[r];
|
|
2013
|
+
});
|
|
2014
|
+
}
|
|
2015
|
+
function Oi(e, t) {
|
|
2016
|
+
return e._cfg.version - t._cfg.version;
|
|
2017
|
+
}
|
|
2018
|
+
function ki(e, t, n, r) {
|
|
2019
|
+
var i = e._dbSchema;
|
|
2020
|
+
n.objectStoreNames.contains("$meta") && !i.$meta && (i.$meta = Tn("$meta", Tr("")[0], []), e._storeNames.push("$meta"));
|
|
2021
|
+
var o = e._createTransaction("readwrite", e._storeNames, i);
|
|
2022
|
+
o.create(n), o._completion.catch(r);
|
|
2023
|
+
var a = o._reject.bind(o), u = K.transless || K;
|
|
2024
|
+
Ie(function() {
|
|
2025
|
+
return K.trans = o, K.transless = u, t !== 0 ? (Bt(e, n), h = t, ((l = o).storeNames.includes("$meta") ? l.table("$meta").get("version").then(function(y) {
|
|
2026
|
+
return y ?? h;
|
|
2027
|
+
}) : S.resolve(h)).then(function(y) {
|
|
2028
|
+
return v = y, f = o, p = n, m = [], y = (c = e)._versions, d = c._dbSchema = Mt(0, c.idbdb, p), (y = y.filter(function(g) {
|
|
2029
|
+
return g._cfg.version >= v;
|
|
2030
|
+
})).length !== 0 ? (y.forEach(function(g) {
|
|
2031
|
+
m.push(function() {
|
|
2032
|
+
var b = d, w = g._cfg.dbschema;
|
|
2033
|
+
Lt(c, b, p), Lt(c, w, p), d = c._dbSchema = w;
|
|
2034
|
+
var x = Cn(b, w);
|
|
2035
|
+
x.add.forEach(function(A) {
|
|
2036
|
+
An(p, A[0], A[1].primKey, A[1].indexes);
|
|
2037
|
+
}), x.change.forEach(function(A) {
|
|
2038
|
+
if (A.recreate) throw new D.Upgrade("Not yet support for changing primary key");
|
|
2039
|
+
var P = p.objectStore(A.name);
|
|
2040
|
+
A.add.forEach(function(R) {
|
|
2041
|
+
return qt(P, R);
|
|
2042
|
+
}), A.change.forEach(function(R) {
|
|
2043
|
+
P.deleteIndex(R.name), qt(P, R);
|
|
2044
|
+
}), A.del.forEach(function(R) {
|
|
2045
|
+
return P.deleteIndex(R);
|
|
2046
|
+
});
|
|
2047
|
+
});
|
|
2048
|
+
var E = g._cfg.contentUpgrade;
|
|
2049
|
+
if (E && g._cfg.version > v) {
|
|
2050
|
+
Bt(c, p), f._memoizedTables = {};
|
|
2051
|
+
var C = tr(w);
|
|
2052
|
+
x.del.forEach(function(A) {
|
|
2053
|
+
C[A] = b[A];
|
|
2054
|
+
}), Pn(c, [c.Transaction.prototype]), Ft(c, [c.Transaction.prototype], F(C), C), f.schema = C;
|
|
2055
|
+
var T, I = un(E);
|
|
2056
|
+
return I && Ze(), x = S.follow(function() {
|
|
2057
|
+
var A;
|
|
2058
|
+
(T = E(f)) && I && (A = Pe.bind(null, null), T.then(A, A));
|
|
2059
|
+
}), T && typeof T.then == "function" ? S.resolve(T) : x.then(function() {
|
|
2060
|
+
return T;
|
|
2061
|
+
});
|
|
2062
|
+
}
|
|
2063
|
+
}), m.push(function(b) {
|
|
2064
|
+
var w, x, E = g._cfg.dbschema;
|
|
2065
|
+
w = E, x = b, [].slice.call(x.db.objectStoreNames).forEach(function(C) {
|
|
2066
|
+
return w[C] == null && x.db.deleteObjectStore(C);
|
|
2067
|
+
}), Pn(c, [c.Transaction.prototype]), Ft(c, [c.Transaction.prototype], c._storeNames, c._dbSchema), f.schema = c._dbSchema;
|
|
2068
|
+
}), m.push(function(b) {
|
|
2069
|
+
c.idbdb.objectStoreNames.contains("$meta") && (Math.ceil(c.idbdb.version / 10) === g._cfg.version ? (c.idbdb.deleteObjectStore("$meta"), delete c._dbSchema.$meta, c._storeNames = c._storeNames.filter(function(w) {
|
|
2070
|
+
return w !== "$meta";
|
|
2071
|
+
})) : b.objectStore("$meta").put(g._cfg.version, "version"));
|
|
2072
|
+
});
|
|
2073
|
+
}), function g() {
|
|
2074
|
+
return m.length ? S.resolve(m.shift()(f.idbtrans)).then(g) : S.resolve();
|
|
2075
|
+
}().then(function() {
|
|
2076
|
+
Er(d, p);
|
|
2077
|
+
})) : S.resolve();
|
|
2078
|
+
var c, v, f, p, m, d;
|
|
2079
|
+
}).catch(a)) : (F(i).forEach(function(y) {
|
|
2080
|
+
An(n, y, i[y].primKey, i[y].indexes);
|
|
2081
|
+
}), Bt(e, n), void S.follow(function() {
|
|
2082
|
+
return e.on.populate.fire(o);
|
|
2083
|
+
}).catch(a));
|
|
2084
|
+
var l, h;
|
|
2085
|
+
});
|
|
2086
|
+
}
|
|
2087
|
+
function Ei(e, t) {
|
|
2088
|
+
Er(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");
|
|
2089
|
+
var n = Mt(0, e.idbdb, t);
|
|
2090
|
+
Lt(e, e._dbSchema, t);
|
|
2091
|
+
for (var r = 0, i = Cn(n, e._dbSchema).change; r < i.length; r++) {
|
|
2092
|
+
var o = function(a) {
|
|
2093
|
+
if (a.change.length || a.recreate) return console.warn("Unable to patch indexes of table ".concat(a.name, " because it has changes on the type of index or primary key.")), { value: void 0 };
|
|
2094
|
+
var u = t.objectStore(a.name);
|
|
2095
|
+
a.add.forEach(function(l) {
|
|
2096
|
+
ge && console.debug("Dexie upgrade patch: Creating missing index ".concat(a.name, ".").concat(l.src)), qt(u, l);
|
|
2097
|
+
});
|
|
2098
|
+
}(i[r]);
|
|
2099
|
+
if (typeof o == "object") return o.value;
|
|
2100
|
+
}
|
|
2101
|
+
}
|
|
2102
|
+
function Cn(e, t) {
|
|
2103
|
+
var n, r = { del: [], add: [], change: [] };
|
|
2104
|
+
for (n in e) t[n] || r.del.push(n);
|
|
2105
|
+
for (n in t) {
|
|
2106
|
+
var i = e[n], o = t[n];
|
|
2107
|
+
if (i) {
|
|
2108
|
+
var a = { name: n, def: o, recreate: !1, del: [], add: [], change: [] };
|
|
2109
|
+
if ("" + (i.primKey.keyPath || "") != "" + (o.primKey.keyPath || "") || i.primKey.auto !== o.primKey.auto) a.recreate = !0, r.change.push(a);
|
|
2110
|
+
else {
|
|
2111
|
+
var u = i.idxByName, l = o.idxByName, h = void 0;
|
|
2112
|
+
for (h in u) l[h] || a.del.push(h);
|
|
2113
|
+
for (h in l) {
|
|
2114
|
+
var y = u[h], c = l[h];
|
|
2115
|
+
y ? y.src !== c.src && a.change.push(c) : a.add.push(c);
|
|
2116
|
+
}
|
|
2117
|
+
(0 < a.del.length || 0 < a.add.length || 0 < a.change.length) && r.change.push(a);
|
|
2118
|
+
}
|
|
2119
|
+
} else r.add.push([n, o]);
|
|
2120
|
+
}
|
|
2121
|
+
return r;
|
|
2122
|
+
}
|
|
2123
|
+
function An(e, t, n, r) {
|
|
2124
|
+
var i = e.db.createObjectStore(t, n.keyPath ? { keyPath: n.keyPath, autoIncrement: n.auto } : { autoIncrement: n.auto });
|
|
2125
|
+
return r.forEach(function(o) {
|
|
2126
|
+
return qt(i, o);
|
|
2127
|
+
}), i;
|
|
2128
|
+
}
|
|
2129
|
+
function Er(e, t) {
|
|
2130
|
+
F(e).forEach(function(n) {
|
|
2131
|
+
t.db.objectStoreNames.contains(n) || (ge && console.debug("Dexie: Creating missing table", n), An(t, n, e[n].primKey, e[n].indexes));
|
|
2132
|
+
});
|
|
2133
|
+
}
|
|
2134
|
+
function qt(e, t) {
|
|
2135
|
+
e.createIndex(t.name, t.keyPath, { unique: t.unique, multiEntry: t.multi });
|
|
2136
|
+
}
|
|
2137
|
+
function Mt(e, t, n) {
|
|
2138
|
+
var r = {};
|
|
2139
|
+
return _t(t.objectStoreNames, 0).forEach(function(i) {
|
|
2140
|
+
for (var o = n.objectStore(i), a = En(Or(h = o.keyPath), h || "", !0, !1, !!o.autoIncrement, h && typeof h != "string", !0), u = [], l = 0; l < o.indexNames.length; ++l) {
|
|
2141
|
+
var y = o.index(o.indexNames[l]), h = y.keyPath, y = En(y.name, h, !!y.unique, !!y.multiEntry, !1, h && typeof h != "string", !1);
|
|
2142
|
+
u.push(y);
|
|
2143
|
+
}
|
|
2144
|
+
r[i] = Tn(i, a, u);
|
|
2145
|
+
}), r;
|
|
2146
|
+
}
|
|
2147
|
+
function Lt(e, t, n) {
|
|
2148
|
+
for (var r = n.db.objectStoreNames, i = 0; i < r.length; ++i) {
|
|
2149
|
+
var o = r[i], a = n.objectStore(o);
|
|
2150
|
+
e._hasGetAll = "getAll" in a;
|
|
2151
|
+
for (var u = 0; u < a.indexNames.length; ++u) {
|
|
2152
|
+
var l = a.indexNames[u], h = a.index(l).keyPath, y = typeof h == "string" ? h : "[" + _t(h).join("+") + "]";
|
|
2153
|
+
!t[o] || (h = t[o].idxByName[y]) && (h.name = l, delete t[o].idxByName[y], t[o].idxByName[l] = h);
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && N.WorkerGlobalScope && N instanceof N.WorkerGlobalScope && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604 && (e._hasGetAll = !1);
|
|
2157
|
+
}
|
|
2158
|
+
function Tr(e) {
|
|
2159
|
+
return e.split(",").map(function(t, n) {
|
|
2160
|
+
var r = (t = t.trim()).replace(/([&*]|\+\+)/g, ""), i = /^\[/.test(r) ? r.match(/^\[(.*)\]$/)[1].split("+") : r;
|
|
2161
|
+
return En(r, i || null, /\&/.test(t), /\*/.test(t), /\+\+/.test(t), B(i), n === 0);
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
var Ti = (Ut.prototype._parseStoresSpec = function(e, t) {
|
|
2165
|
+
F(e).forEach(function(n) {
|
|
2166
|
+
if (e[n] !== null) {
|
|
2167
|
+
var r = Tr(e[n]), i = r.shift();
|
|
2168
|
+
if (i.unique = !0, i.multi) throw new D.Schema("Primary key cannot be multi-valued");
|
|
2169
|
+
r.forEach(function(o) {
|
|
2170
|
+
if (o.auto) throw new D.Schema("Only primary key can be marked as autoIncrement (++)");
|
|
2171
|
+
if (!o.keyPath) throw new D.Schema("Index must have a name and cannot be an empty string");
|
|
2172
|
+
}), t[n] = Tn(n, i, r);
|
|
2173
|
+
}
|
|
2174
|
+
});
|
|
2175
|
+
}, Ut.prototype.stores = function(n) {
|
|
2176
|
+
var t = this.db;
|
|
2177
|
+
this._cfg.storesSource = this._cfg.storesSource ? W(this._cfg.storesSource, n) : n;
|
|
2178
|
+
var n = t._versions, r = {}, i = {};
|
|
2179
|
+
return n.forEach(function(o) {
|
|
2180
|
+
W(r, o._cfg.storesSource), i = o._cfg.dbschema = {}, o._parseStoresSpec(r, i);
|
|
2181
|
+
}), t._dbSchema = i, Pn(t, [t._allTables, t, t.Transaction.prototype]), Ft(t, [t._allTables, t, t.Transaction.prototype, this._cfg.tables], F(i), i), t._storeNames = F(i), this;
|
|
2182
|
+
}, Ut.prototype.upgrade = function(e) {
|
|
2183
|
+
return this._cfg.contentUpgrade = ln(this._cfg.contentUpgrade || G, e), this;
|
|
2184
|
+
}, Ut);
|
|
2185
|
+
function Ut() {
|
|
2186
|
+
}
|
|
2187
|
+
function Sn(e, t) {
|
|
2188
|
+
var n = e._dbNamesDB;
|
|
2189
|
+
return n || (n = e._dbNamesDB = new ke(Rt, { addons: [], indexedDB: e, IDBKeyRange: t })).version(1).stores({ dbnames: "name" }), n.table("dbnames");
|
|
2190
|
+
}
|
|
2191
|
+
function Rn(e) {
|
|
2192
|
+
return e && typeof e.databases == "function";
|
|
2193
|
+
}
|
|
2194
|
+
function Kn(e) {
|
|
2195
|
+
return Ie(function() {
|
|
2196
|
+
return K.letThrough = !0, e();
|
|
2197
|
+
});
|
|
2198
|
+
}
|
|
2199
|
+
function Nn(e) {
|
|
2200
|
+
return !("from" in e);
|
|
2201
|
+
}
|
|
2202
|
+
var oe = function(e, t) {
|
|
2203
|
+
if (!this) {
|
|
2204
|
+
var n = new oe();
|
|
2205
|
+
return e && "d" in e && W(n, e), n;
|
|
2206
|
+
}
|
|
2207
|
+
W(this, arguments.length ? { d: 1, from: e, to: 1 < arguments.length ? t : e } : { d: 0 });
|
|
2208
|
+
};
|
|
2209
|
+
function bt(e, t, n) {
|
|
2210
|
+
var r = H(t, n);
|
|
2211
|
+
if (!isNaN(r)) {
|
|
2212
|
+
if (0 < r) throw RangeError();
|
|
2213
|
+
if (Nn(e)) return W(e, { from: t, to: n, d: 1 });
|
|
2214
|
+
var i = e.l, r = e.r;
|
|
2215
|
+
if (H(n, e.from) < 0) return i ? bt(i, t, n) : e.l = { from: t, to: n, d: 1, l: null, r: null }, Pr(e);
|
|
2216
|
+
if (0 < H(t, e.to)) return r ? bt(r, t, n) : e.r = { from: t, to: n, d: 1, l: null, r: null }, Pr(e);
|
|
2217
|
+
H(t, e.from) < 0 && (e.from = t, e.l = null, e.d = r ? r.d + 1 : 1), 0 < H(n, e.to) && (e.to = n, e.r = null, e.d = e.l ? e.l.d + 1 : 1), n = !e.r, i && !e.l && wt(e, i), r && n && wt(e, r);
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
function wt(e, t) {
|
|
2221
|
+
Nn(t) || function n(r, l) {
|
|
2222
|
+
var o = l.from, a = l.to, u = l.l, l = l.r;
|
|
2223
|
+
bt(r, o, a), u && n(r, u), l && n(r, l);
|
|
2224
|
+
}(e, t);
|
|
2225
|
+
}
|
|
2226
|
+
function Ir(e, t) {
|
|
2227
|
+
var n = Wt(t), r = n.next();
|
|
2228
|
+
if (r.done) return !1;
|
|
2229
|
+
for (var i = r.value, o = Wt(e), a = o.next(i.from), u = a.value; !r.done && !a.done; ) {
|
|
2230
|
+
if (H(u.from, i.to) <= 0 && 0 <= H(u.to, i.from)) return !0;
|
|
2231
|
+
H(i.from, u.from) < 0 ? i = (r = n.next(u.from)).value : u = (a = o.next(i.from)).value;
|
|
2232
|
+
}
|
|
2233
|
+
return !1;
|
|
2234
|
+
}
|
|
2235
|
+
function Wt(e) {
|
|
2236
|
+
var t = Nn(e) ? null : { s: 0, n: e };
|
|
2237
|
+
return { next: function(n) {
|
|
2238
|
+
for (var r = 0 < arguments.length; t; ) switch (t.s) {
|
|
2239
|
+
case 0:
|
|
2240
|
+
if (t.s = 1, r) for (; t.n.l && H(n, t.n.from) < 0; ) t = { up: t, n: t.n.l, s: 1 };
|
|
2241
|
+
else for (; t.n.l; ) t = { up: t, n: t.n.l, s: 1 };
|
|
2242
|
+
case 1:
|
|
2243
|
+
if (t.s = 2, !r || H(n, t.n.to) <= 0) return { value: t.n, done: !1 };
|
|
2244
|
+
case 2:
|
|
2245
|
+
if (t.n.r) {
|
|
2246
|
+
t.s = 3, t = { up: t, n: t.n.r, s: 0 };
|
|
2247
|
+
continue;
|
|
2248
|
+
}
|
|
2249
|
+
case 3:
|
|
2250
|
+
t = t.up;
|
|
2251
|
+
}
|
|
2252
|
+
return { done: !0 };
|
|
2253
|
+
} };
|
|
2254
|
+
}
|
|
2255
|
+
function Pr(e) {
|
|
2256
|
+
var t, n, r = (((t = e.r) === null || t === void 0 ? void 0 : t.d) || 0) - (((n = e.l) === null || n === void 0 ? void 0 : n.d) || 0), i = 1 < r ? "r" : r < -1 ? "l" : "";
|
|
2257
|
+
i && (t = i == "r" ? "l" : "r", n = k({}, e), r = e[i], e.from = r.from, e.to = r.to, e[i] = r[i], n[i] = r[t], (e[t] = n).d = Cr(n)), e.d = Cr(e);
|
|
2258
|
+
}
|
|
2259
|
+
function Cr(n) {
|
|
2260
|
+
var t = n.r, n = n.l;
|
|
2261
|
+
return (t ? n ? Math.max(t.d, n.d) : t.d : n ? n.d : 0) + 1;
|
|
2262
|
+
}
|
|
2263
|
+
function Vt(e, t) {
|
|
2264
|
+
return F(t).forEach(function(n) {
|
|
2265
|
+
e[n] ? wt(e[n], t[n]) : e[n] = function r(i) {
|
|
2266
|
+
var o, a, u = {};
|
|
2267
|
+
for (o in i) z(i, o) && (a = i[o], u[o] = !a || typeof a != "object" || rr.has(a.constructor) ? a : r(a));
|
|
2268
|
+
return u;
|
|
2269
|
+
}(t[n]);
|
|
2270
|
+
}), e;
|
|
2271
|
+
}
|
|
2272
|
+
function Dn(e, t) {
|
|
2273
|
+
return e.all || t.all || Object.keys(e).some(function(n) {
|
|
2274
|
+
return t[n] && Ir(t[n], e[n]);
|
|
2275
|
+
});
|
|
2276
|
+
}
|
|
2277
|
+
X(oe.prototype, ((pe = { add: function(e) {
|
|
2278
|
+
return wt(this, e), this;
|
|
2279
|
+
}, addKey: function(e) {
|
|
2280
|
+
return bt(this, e, e), this;
|
|
2281
|
+
}, addKeys: function(e) {
|
|
2282
|
+
var t = this;
|
|
2283
|
+
return e.forEach(function(n) {
|
|
2284
|
+
return bt(t, n, n);
|
|
2285
|
+
}), this;
|
|
2286
|
+
}, hasKey: function(e) {
|
|
2287
|
+
var t = Wt(this).next(e).value;
|
|
2288
|
+
return t && H(t.from, e) <= 0 && 0 <= H(t.to, e);
|
|
2289
|
+
} })[sn] = function() {
|
|
2290
|
+
return Wt(this);
|
|
2291
|
+
}, pe));
|
|
2292
|
+
var We = {}, jn = {}, Bn = !1;
|
|
2293
|
+
function Ht(e) {
|
|
2294
|
+
Vt(jn, e), Bn || (Bn = !0, setTimeout(function() {
|
|
2295
|
+
Bn = !1, Fn(jn, !(jn = {}));
|
|
2296
|
+
}, 0));
|
|
2297
|
+
}
|
|
2298
|
+
function Fn(e, t) {
|
|
2299
|
+
t === void 0 && (t = !1);
|
|
2300
|
+
var n = /* @__PURE__ */ new Set();
|
|
2301
|
+
if (e.all) for (var r = 0, i = Object.values(We); r < i.length; r++) Ar(a = i[r], e, n, t);
|
|
2302
|
+
else for (var o in e) {
|
|
2303
|
+
var a, u = /^idb\:\/\/(.*)\/(.*)\//.exec(o);
|
|
2304
|
+
u && (o = u[1], u = u[2], (a = We["idb://".concat(o, "/").concat(u)]) && Ar(a, e, n, t));
|
|
2305
|
+
}
|
|
2306
|
+
n.forEach(function(l) {
|
|
2307
|
+
return l();
|
|
2308
|
+
});
|
|
2309
|
+
}
|
|
2310
|
+
function Ar(e, t, n, r) {
|
|
2311
|
+
for (var i = [], o = 0, a = Object.entries(e.queries.query); o < a.length; o++) {
|
|
2312
|
+
for (var u = a[o], l = u[0], h = [], y = 0, c = u[1]; y < c.length; y++) {
|
|
2313
|
+
var v = c[y];
|
|
2314
|
+
Dn(t, v.obsSet) ? v.subscribers.forEach(function(d) {
|
|
2315
|
+
return n.add(d);
|
|
2316
|
+
}) : r && h.push(v);
|
|
2317
|
+
}
|
|
2318
|
+
r && i.push([l, h]);
|
|
2319
|
+
}
|
|
2320
|
+
if (r) for (var f = 0, p = i; f < p.length; f++) {
|
|
2321
|
+
var m = p[f], l = m[0], h = m[1];
|
|
2322
|
+
e.queries.query[l] = h;
|
|
2323
|
+
}
|
|
2324
|
+
}
|
|
2325
|
+
function Ii(e) {
|
|
2326
|
+
var t = e._state, n = e._deps.indexedDB;
|
|
2327
|
+
if (t.isBeingOpened || e.idbdb) return t.dbReadyPromise.then(function() {
|
|
2328
|
+
return t.dbOpenError ? te(t.dbOpenError) : e;
|
|
2329
|
+
});
|
|
2330
|
+
t.isBeingOpened = !0, t.dbOpenError = null, t.openComplete = !1;
|
|
2331
|
+
var r = t.openCanceller, i = Math.round(10 * e.verno), o = !1;
|
|
2332
|
+
function a() {
|
|
2333
|
+
if (t.openCanceller !== r) throw new D.DatabaseClosed("db.open() was cancelled");
|
|
2334
|
+
}
|
|
2335
|
+
function u() {
|
|
2336
|
+
return new S(function(v, f) {
|
|
2337
|
+
if (a(), !n) throw new D.MissingAPI();
|
|
2338
|
+
var p = e.name, m = t.autoSchema || !i ? n.open(p) : n.open(p, i);
|
|
2339
|
+
if (!m) throw new D.MissingAPI();
|
|
2340
|
+
m.onerror = be(f), m.onblocked = ee(e._fireOnBlocked), m.onupgradeneeded = ee(function(d) {
|
|
2341
|
+
var g;
|
|
2342
|
+
y = m.transaction, t.autoSchema && !e._options.allowEmptyDB ? (m.onerror = yt, y.abort(), m.result.close(), (g = n.deleteDatabase(p)).onsuccess = g.onerror = ee(function() {
|
|
2343
|
+
f(new D.NoSuchDatabase("Database ".concat(p, " doesnt exist")));
|
|
2344
|
+
})) : (y.onerror = be(f), d = d.oldVersion > Math.pow(2, 62) ? 0 : d.oldVersion, c = d < 1, e.idbdb = m.result, o && Ei(e, y), ki(e, d / 10, y, f));
|
|
2345
|
+
}, f), m.onsuccess = ee(function() {
|
|
2346
|
+
y = null;
|
|
2347
|
+
var d, g, b, w, x, E = e.idbdb = m.result, C = _t(E.objectStoreNames);
|
|
2348
|
+
if (0 < C.length) try {
|
|
2349
|
+
var T = E.transaction((w = C).length === 1 ? w[0] : w, "readonly");
|
|
2350
|
+
if (t.autoSchema) g = E, b = T, (d = e).verno = g.version / 10, b = d._dbSchema = Mt(0, g, b), d._storeNames = _t(g.objectStoreNames, 0), Ft(d, [d._allTables], F(b), b);
|
|
2351
|
+
else if (Lt(e, e._dbSchema, T), ((x = Cn(Mt(0, (x = e).idbdb, T), x._dbSchema)).add.length || x.change.some(function(I) {
|
|
2352
|
+
return I.add.length || I.change.length;
|
|
2353
|
+
})) && !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."), E.close(), i = E.version + 1, o = !0, v(u());
|
|
2354
|
+
Bt(e, T);
|
|
2355
|
+
} catch {
|
|
2356
|
+
}
|
|
2357
|
+
et.push(e), E.onversionchange = ee(function(I) {
|
|
2358
|
+
t.vcFired = !0, e.on("versionchange").fire(I);
|
|
2359
|
+
}), E.onclose = ee(function(I) {
|
|
2360
|
+
e.on("close").fire(I);
|
|
2361
|
+
}), c && (x = e._deps, T = p, E = x.indexedDB, x = x.IDBKeyRange, Rn(E) || T === Rt || Sn(E, x).put({ name: T }).catch(G)), v();
|
|
2362
|
+
}, f);
|
|
2363
|
+
}).catch(function(v) {
|
|
2364
|
+
switch (v?.name) {
|
|
2365
|
+
case "UnknownError":
|
|
2366
|
+
if (0 < t.PR1398_maxLoop) return t.PR1398_maxLoop--, console.warn("Dexie: Workaround for Chrome UnknownError on open()"), u();
|
|
2367
|
+
break;
|
|
2368
|
+
case "VersionError":
|
|
2369
|
+
if (0 < i) return i = 0, u();
|
|
2370
|
+
}
|
|
2371
|
+
return S.reject(v);
|
|
2372
|
+
});
|
|
2373
|
+
}
|
|
2374
|
+
var l, h = t.dbReadyResolve, y = null, c = !1;
|
|
2375
|
+
return S.race([r, (typeof navigator > "u" ? S.resolve() : !navigator.userAgentData && /Safari\//.test(navigator.userAgent) && !/Chrom(e|ium)\//.test(navigator.userAgent) && indexedDB.databases ? new Promise(function(v) {
|
|
2376
|
+
function f() {
|
|
2377
|
+
return indexedDB.databases().finally(v);
|
|
2378
|
+
}
|
|
2379
|
+
l = setInterval(f, 100), f();
|
|
2380
|
+
}).finally(function() {
|
|
2381
|
+
return clearInterval(l);
|
|
2382
|
+
}) : Promise.resolve()).then(u)]).then(function() {
|
|
2383
|
+
return a(), t.onReadyBeingFired = [], S.resolve(Kn(function() {
|
|
2384
|
+
return e.on.ready.fire(e.vip);
|
|
2385
|
+
})).then(function v() {
|
|
2386
|
+
if (0 < t.onReadyBeingFired.length) {
|
|
2387
|
+
var f = t.onReadyBeingFired.reduce(ln, G);
|
|
2388
|
+
return t.onReadyBeingFired = [], S.resolve(Kn(function() {
|
|
2389
|
+
return f(e.vip);
|
|
2390
|
+
})).then(v);
|
|
2391
|
+
}
|
|
2392
|
+
});
|
|
2393
|
+
}).finally(function() {
|
|
2394
|
+
t.openCanceller === r && (t.onReadyBeingFired = null, t.isBeingOpened = !1);
|
|
2395
|
+
}).catch(function(v) {
|
|
2396
|
+
t.dbOpenError = v;
|
|
2397
|
+
try {
|
|
2398
|
+
y && y.abort();
|
|
2399
|
+
} catch {
|
|
2400
|
+
}
|
|
2401
|
+
return r === t.openCanceller && e._close(), te(v);
|
|
2402
|
+
}).finally(function() {
|
|
2403
|
+
t.openComplete = !0, h();
|
|
2404
|
+
}).then(function() {
|
|
2405
|
+
var v;
|
|
2406
|
+
return c && (v = {}, e.tables.forEach(function(f) {
|
|
2407
|
+
f.schema.indexes.forEach(function(p) {
|
|
2408
|
+
p.name && (v["idb://".concat(e.name, "/").concat(f.name, "/").concat(p.name)] = new oe(-1 / 0, [[[]]]));
|
|
2409
|
+
}), v["idb://".concat(e.name, "/").concat(f.name, "/")] = v["idb://".concat(e.name, "/").concat(f.name, "/:dels")] = new oe(-1 / 0, [[[]]]);
|
|
2410
|
+
}), Se(mt).fire(v), Fn(v, !0)), e;
|
|
2411
|
+
});
|
|
2412
|
+
}
|
|
2413
|
+
function qn(e) {
|
|
2414
|
+
function t(o) {
|
|
2415
|
+
return e.next(o);
|
|
2416
|
+
}
|
|
2417
|
+
var n = i(t), r = i(function(o) {
|
|
2418
|
+
return e.throw(o);
|
|
2419
|
+
});
|
|
2420
|
+
function i(o) {
|
|
2421
|
+
return function(l) {
|
|
2422
|
+
var u = o(l), l = u.value;
|
|
2423
|
+
return u.done ? l : l && typeof l.then == "function" ? l.then(n, r) : B(l) ? Promise.all(l).then(n, r) : n(l);
|
|
2424
|
+
};
|
|
2425
|
+
}
|
|
2426
|
+
return i(t)();
|
|
2427
|
+
}
|
|
2428
|
+
function zt(e, t, n) {
|
|
2429
|
+
for (var r = B(e) ? e.slice() : [e], i = 0; i < n; ++i) r.push(t);
|
|
2430
|
+
return r;
|
|
2431
|
+
}
|
|
2432
|
+
var Pi = { stack: "dbcore", name: "VirtualIndexMiddleware", level: 1, create: function(e) {
|
|
2433
|
+
return k(k({}, e), { table: function(t) {
|
|
2434
|
+
var n = e.table(t), r = n.schema, i = {}, o = [];
|
|
2435
|
+
function a(c, v, f) {
|
|
2436
|
+
var p = gt(c), m = i[p] = i[p] || [], d = c == null ? 0 : typeof c == "string" ? 1 : c.length, g = 0 < v, g = k(k({}, f), { name: g ? "".concat(p, "(virtual-from:").concat(f.name, ")") : f.name, lowLevelIndex: f, isVirtual: g, keyTail: v, keyLength: d, extractKey: In(c), unique: !g && f.unique });
|
|
2437
|
+
return m.push(g), g.isPrimaryKey || o.push(g), 1 < d && a(d === 2 ? c[0] : c.slice(0, d - 1), v + 1, f), m.sort(function(b, w) {
|
|
2438
|
+
return b.keyTail - w.keyTail;
|
|
2439
|
+
}), g;
|
|
2440
|
+
}
|
|
2441
|
+
t = a(r.primaryKey.keyPath, 0, r.primaryKey), i[":id"] = [t];
|
|
2442
|
+
for (var u = 0, l = r.indexes; u < l.length; u++) {
|
|
2443
|
+
var h = l[u];
|
|
2444
|
+
a(h.keyPath, 0, h);
|
|
2445
|
+
}
|
|
2446
|
+
function y(c) {
|
|
2447
|
+
var v, f = c.query.index;
|
|
2448
|
+
return f.isVirtual ? k(k({}, c), { query: { index: f.lowLevelIndex, range: (v = c.query.range, f = f.keyTail, { type: v.type === 1 ? 2 : v.type, lower: zt(v.lower, v.lowerOpen ? e.MAX_KEY : e.MIN_KEY, f), lowerOpen: !0, upper: zt(v.upper, v.upperOpen ? e.MIN_KEY : e.MAX_KEY, f), upperOpen: !0 }) } }) : c;
|
|
2449
|
+
}
|
|
2450
|
+
return k(k({}, n), { schema: k(k({}, r), { primaryKey: t, indexes: o, getIndexByKeyPath: function(c) {
|
|
2451
|
+
return (c = i[gt(c)]) && c[0];
|
|
2452
|
+
} }), count: function(c) {
|
|
2453
|
+
return n.count(y(c));
|
|
2454
|
+
}, query: function(c) {
|
|
2455
|
+
return n.query(y(c));
|
|
2456
|
+
}, openCursor: function(c) {
|
|
2457
|
+
var v = c.query.index, f = v.keyTail, p = v.isVirtual, m = v.keyLength;
|
|
2458
|
+
return p ? n.openCursor(y(c)).then(function(g) {
|
|
2459
|
+
return g && d(g);
|
|
2460
|
+
}) : n.openCursor(c);
|
|
2461
|
+
function d(g) {
|
|
2462
|
+
return Object.create(g, { continue: { value: function(b) {
|
|
2463
|
+
b != null ? g.continue(zt(b, c.reverse ? e.MAX_KEY : e.MIN_KEY, f)) : c.unique ? g.continue(g.key.slice(0, m).concat(c.reverse ? e.MIN_KEY : e.MAX_KEY, f)) : g.continue();
|
|
2464
|
+
} }, continuePrimaryKey: { value: function(b, w) {
|
|
2465
|
+
g.continuePrimaryKey(zt(b, e.MAX_KEY, f), w);
|
|
2466
|
+
} }, primaryKey: { get: function() {
|
|
2467
|
+
return g.primaryKey;
|
|
2468
|
+
} }, key: { get: function() {
|
|
2469
|
+
var b = g.key;
|
|
2470
|
+
return m === 1 ? b[0] : b.slice(0, m);
|
|
2471
|
+
} }, value: { get: function() {
|
|
2472
|
+
return g.value;
|
|
2473
|
+
} } });
|
|
2474
|
+
}
|
|
2475
|
+
} });
|
|
2476
|
+
} });
|
|
2477
|
+
} };
|
|
2478
|
+
function Mn(e, t, n, r) {
|
|
2479
|
+
return n = n || {}, r = r || "", F(e).forEach(function(i) {
|
|
2480
|
+
var o, a, u;
|
|
2481
|
+
z(t, i) ? (o = e[i], a = t[i], typeof o == "object" && typeof a == "object" && o && a ? (u = an(o)) !== an(a) ? n[r + i] = t[i] : u === "Object" ? Mn(o, a, n, r + i + ".") : o !== a && (n[r + i] = t[i]) : o !== a && (n[r + i] = t[i])) : n[r + i] = void 0;
|
|
2482
|
+
}), F(t).forEach(function(i) {
|
|
2483
|
+
z(e, i) || (n[r + i] = t[i]);
|
|
2484
|
+
}), n;
|
|
2485
|
+
}
|
|
2486
|
+
function Ln(e, t) {
|
|
2487
|
+
return t.type === "delete" ? t.keys : t.keys || t.values.map(e.extractKey);
|
|
2488
|
+
}
|
|
2489
|
+
var Ci = { stack: "dbcore", name: "HooksMiddleware", level: 2, create: function(e) {
|
|
2490
|
+
return k(k({}, e), { table: function(t) {
|
|
2491
|
+
var n = e.table(t), r = n.schema.primaryKey;
|
|
2492
|
+
return k(k({}, n), { mutate: function(i) {
|
|
2493
|
+
var o = K.trans, a = o.table(t).hook, u = a.deleting, l = a.creating, h = a.updating;
|
|
2494
|
+
switch (i.type) {
|
|
2495
|
+
case "add":
|
|
2496
|
+
if (l.fire === G) break;
|
|
2497
|
+
return o._promise("readwrite", function() {
|
|
2498
|
+
return y(i);
|
|
2499
|
+
}, !0);
|
|
2500
|
+
case "put":
|
|
2501
|
+
if (l.fire === G && h.fire === G) break;
|
|
2502
|
+
return o._promise("readwrite", function() {
|
|
2503
|
+
return y(i);
|
|
2504
|
+
}, !0);
|
|
2505
|
+
case "delete":
|
|
2506
|
+
if (u.fire === G) break;
|
|
2507
|
+
return o._promise("readwrite", function() {
|
|
2508
|
+
return y(i);
|
|
2509
|
+
}, !0);
|
|
2510
|
+
case "deleteRange":
|
|
2511
|
+
if (u.fire === G) break;
|
|
2512
|
+
return o._promise("readwrite", function() {
|
|
2513
|
+
return function c(v, f, p) {
|
|
2514
|
+
return n.query({ trans: v, values: !1, query: { index: r, range: f }, limit: p }).then(function(m) {
|
|
2515
|
+
var d = m.result;
|
|
2516
|
+
return y({ type: "delete", keys: d, trans: v }).then(function(g) {
|
|
2517
|
+
return 0 < g.numFailures ? Promise.reject(g.failures[0]) : d.length < p ? { failures: [], numFailures: 0, lastResult: void 0 } : c(v, k(k({}, f), { lower: d[d.length - 1], lowerOpen: !0 }), p);
|
|
2518
|
+
});
|
|
2519
|
+
});
|
|
2520
|
+
}(i.trans, i.range, 1e4);
|
|
2521
|
+
}, !0);
|
|
2522
|
+
}
|
|
2523
|
+
return n.mutate(i);
|
|
2524
|
+
function y(c) {
|
|
2525
|
+
var v, f, p, m = K.trans, d = c.keys || Ln(r, c);
|
|
2526
|
+
if (!d) throw new Error("Keys missing");
|
|
2527
|
+
return (c = c.type === "add" || c.type === "put" ? k(k({}, c), { keys: d }) : k({}, c)).type !== "delete" && (c.values = j([], c.values)), c.keys && (c.keys = j([], c.keys)), v = n, p = d, ((f = c).type === "add" ? Promise.resolve([]) : v.getMany({ trans: f.trans, keys: p, cache: "immutable" })).then(function(g) {
|
|
2528
|
+
var b = d.map(function(w, x) {
|
|
2529
|
+
var E, C, T, I = g[x], A = { onerror: null, onsuccess: null };
|
|
2530
|
+
return c.type === "delete" ? u.fire.call(A, w, I, m) : c.type === "add" || I === void 0 ? (E = l.fire.call(A, w, c.values[x], m), w == null && E != null && (c.keys[x] = w = E, r.outbound || le(c.values[x], r.keyPath, w))) : (E = Mn(I, c.values[x]), (C = h.fire.call(A, E, w, I, m)) && (T = c.values[x], Object.keys(C).forEach(function(P) {
|
|
2531
|
+
z(T, P) ? T[P] = C[P] : le(T, P, C[P]);
|
|
2532
|
+
}))), A;
|
|
2533
|
+
});
|
|
2534
|
+
return n.mutate(c).then(function(w) {
|
|
2535
|
+
for (var x = w.failures, E = w.results, C = w.numFailures, w = w.lastResult, T = 0; T < d.length; ++T) {
|
|
2536
|
+
var I = (E || d)[T], A = b[T];
|
|
2537
|
+
I == null ? A.onerror && A.onerror(x[T]) : A.onsuccess && A.onsuccess(c.type === "put" && g[T] ? c.values[T] : I);
|
|
2538
|
+
}
|
|
2539
|
+
return { failures: x, results: E, numFailures: C, lastResult: w };
|
|
2540
|
+
}).catch(function(w) {
|
|
2541
|
+
return b.forEach(function(x) {
|
|
2542
|
+
return x.onerror && x.onerror(w);
|
|
2543
|
+
}), Promise.reject(w);
|
|
2544
|
+
});
|
|
2545
|
+
});
|
|
2546
|
+
}
|
|
2547
|
+
} });
|
|
2548
|
+
} });
|
|
2549
|
+
} };
|
|
2550
|
+
function Sr(e, t, n) {
|
|
2551
|
+
try {
|
|
2552
|
+
if (!t || t.keys.length < e.length) return null;
|
|
2553
|
+
for (var r = [], i = 0, o = 0; i < t.keys.length && o < e.length; ++i) H(t.keys[i], e[o]) === 0 && (r.push(n ? Ke(t.values[i]) : t.values[i]), ++o);
|
|
2554
|
+
return r.length === e.length ? r : null;
|
|
2555
|
+
} catch {
|
|
2556
|
+
return null;
|
|
2557
|
+
}
|
|
2558
|
+
}
|
|
2559
|
+
var Ai = { stack: "dbcore", level: -1, create: function(e) {
|
|
2560
|
+
return { table: function(t) {
|
|
2561
|
+
var n = e.table(t);
|
|
2562
|
+
return k(k({}, n), { getMany: function(r) {
|
|
2563
|
+
if (!r.cache) return n.getMany(r);
|
|
2564
|
+
var i = Sr(r.keys, r.trans._cache, r.cache === "clone");
|
|
2565
|
+
return i ? S.resolve(i) : n.getMany(r).then(function(o) {
|
|
2566
|
+
return r.trans._cache = { keys: r.keys, values: r.cache === "clone" ? Ke(o) : o }, o;
|
|
2567
|
+
});
|
|
2568
|
+
}, mutate: function(r) {
|
|
2569
|
+
return r.type !== "add" && (r.trans._cache = null), n.mutate(r);
|
|
2570
|
+
} });
|
|
2571
|
+
} };
|
|
2572
|
+
} };
|
|
2573
|
+
function Rr(e, t) {
|
|
2574
|
+
return e.trans.mode === "readonly" && !!e.subscr && !e.trans.explicit && e.trans.db._options.cache !== "disabled" && !t.schema.primaryKey.outbound;
|
|
2575
|
+
}
|
|
2576
|
+
function Kr(e, t) {
|
|
2577
|
+
switch (e) {
|
|
2578
|
+
case "query":
|
|
2579
|
+
return t.values && !t.unique;
|
|
2580
|
+
case "get":
|
|
2581
|
+
case "getMany":
|
|
2582
|
+
case "count":
|
|
2583
|
+
case "openCursor":
|
|
2584
|
+
return !1;
|
|
2585
|
+
}
|
|
2586
|
+
}
|
|
2587
|
+
var Si = { stack: "dbcore", level: 0, name: "Observability", create: function(e) {
|
|
2588
|
+
var t = e.schema.name, n = new oe(e.MIN_KEY, e.MAX_KEY);
|
|
2589
|
+
return k(k({}, e), { transaction: function(r, i, o) {
|
|
2590
|
+
if (K.subscr && i !== "readonly") throw new D.ReadOnly("Readwrite transaction in liveQuery context. Querier source: ".concat(K.querier));
|
|
2591
|
+
return e.transaction(r, i, o);
|
|
2592
|
+
}, table: function(r) {
|
|
2593
|
+
var i = e.table(r), o = i.schema, a = o.primaryKey, c = o.indexes, u = a.extractKey, l = a.outbound, h = a.autoIncrement && c.filter(function(f) {
|
|
2594
|
+
return f.compound && f.keyPath.includes(a.keyPath);
|
|
2595
|
+
}), y = k(k({}, i), { mutate: function(f) {
|
|
2596
|
+
function p(P) {
|
|
2597
|
+
return P = "idb://".concat(t, "/").concat(r, "/").concat(P), w[P] || (w[P] = new oe());
|
|
2598
|
+
}
|
|
2599
|
+
var m, d, g, b = f.trans, w = f.mutatedParts || (f.mutatedParts = {}), x = p(""), E = p(":dels"), C = f.type, A = f.type === "deleteRange" ? [f.range] : f.type === "delete" ? [f.keys] : f.values.length < 50 ? [Ln(a, f).filter(function(P) {
|
|
2600
|
+
return P;
|
|
2601
|
+
}), f.values] : [], T = A[0], I = A[1], A = f.trans._cache;
|
|
2602
|
+
return B(T) ? (x.addKeys(T), (A = C === "delete" || T.length === I.length ? Sr(T, A) : null) || E.addKeys(T), (A || I) && (m = p, d = A, g = I, o.indexes.forEach(function(P) {
|
|
2603
|
+
var R = m(P.name || "");
|
|
2604
|
+
function M(U) {
|
|
2605
|
+
return U != null ? P.extractKey(U) : null;
|
|
2606
|
+
}
|
|
2607
|
+
function L(U) {
|
|
2608
|
+
return P.multiEntry && B(U) ? U.forEach(function(he) {
|
|
2609
|
+
return R.addKey(he);
|
|
2610
|
+
}) : R.addKey(U);
|
|
2611
|
+
}
|
|
2612
|
+
(d || g).forEach(function(U, ae) {
|
|
2613
|
+
var q = d && M(d[ae]), ae = g && M(g[ae]);
|
|
2614
|
+
H(q, ae) !== 0 && (q != null && L(q), ae != null && L(ae));
|
|
2615
|
+
});
|
|
2616
|
+
}))) : T ? (I = { from: (I = T.lower) !== null && I !== void 0 ? I : e.MIN_KEY, to: (I = T.upper) !== null && I !== void 0 ? I : e.MAX_KEY }, E.add(I), x.add(I)) : (x.add(n), E.add(n), o.indexes.forEach(function(P) {
|
|
2617
|
+
return p(P.name).add(n);
|
|
2618
|
+
})), i.mutate(f).then(function(P) {
|
|
2619
|
+
return !T || f.type !== "add" && f.type !== "put" || (x.addKeys(P.results), h && h.forEach(function(R) {
|
|
2620
|
+
for (var M = f.values.map(function(q) {
|
|
2621
|
+
return R.extractKey(q);
|
|
2622
|
+
}), L = R.keyPath.findIndex(function(q) {
|
|
2623
|
+
return q === a.keyPath;
|
|
2624
|
+
}), U = 0, he = P.results.length; U < he; ++U) M[U][L] = P.results[U];
|
|
2625
|
+
p(R.name).addKeys(M);
|
|
2626
|
+
})), b.mutatedParts = Vt(b.mutatedParts || {}, w), P;
|
|
2627
|
+
});
|
|
2628
|
+
} }), c = function(p) {
|
|
2629
|
+
var m = p.query, p = m.index, m = m.range;
|
|
2630
|
+
return [p, new oe((p = m.lower) !== null && p !== void 0 ? p : e.MIN_KEY, (m = m.upper) !== null && m !== void 0 ? m : e.MAX_KEY)];
|
|
2631
|
+
}, v = { get: function(f) {
|
|
2632
|
+
return [a, new oe(f.key)];
|
|
2633
|
+
}, getMany: function(f) {
|
|
2634
|
+
return [a, new oe().addKeys(f.keys)];
|
|
2635
|
+
}, count: c, query: c, openCursor: c };
|
|
2636
|
+
return F(v).forEach(function(f) {
|
|
2637
|
+
y[f] = function(p) {
|
|
2638
|
+
var m = K.subscr, d = !!m, g = Rr(K, i) && Kr(f, p) ? p.obsSet = {} : m;
|
|
2639
|
+
if (d) {
|
|
2640
|
+
var b = function(I) {
|
|
2641
|
+
return I = "idb://".concat(t, "/").concat(r, "/").concat(I), g[I] || (g[I] = new oe());
|
|
2642
|
+
}, w = b(""), x = b(":dels"), m = v[f](p), d = m[0], m = m[1];
|
|
2643
|
+
if ((f === "query" && d.isPrimaryKey && !p.values ? x : b(d.name || "")).add(m), !d.isPrimaryKey) {
|
|
2644
|
+
if (f !== "count") {
|
|
2645
|
+
var E = f === "query" && l && p.values && i.query(k(k({}, p), { values: !1 }));
|
|
2646
|
+
return i[f].apply(this, arguments).then(function(I) {
|
|
2647
|
+
if (f === "query") {
|
|
2648
|
+
if (l && p.values) return E.then(function(M) {
|
|
2649
|
+
return M = M.result, w.addKeys(M), I;
|
|
2650
|
+
});
|
|
2651
|
+
var A = p.values ? I.result.map(u) : I.result;
|
|
2652
|
+
(p.values ? w : x).addKeys(A);
|
|
2653
|
+
} else if (f === "openCursor") {
|
|
2654
|
+
var P = I, R = p.values;
|
|
2655
|
+
return P && Object.create(P, { key: { get: function() {
|
|
2656
|
+
return x.addKey(P.primaryKey), P.key;
|
|
2657
|
+
} }, primaryKey: { get: function() {
|
|
2658
|
+
var M = P.primaryKey;
|
|
2659
|
+
return x.addKey(M), M;
|
|
2660
|
+
} }, value: { get: function() {
|
|
2661
|
+
return R && w.addKey(P.primaryKey), P.value;
|
|
2662
|
+
} } });
|
|
2663
|
+
}
|
|
2664
|
+
return I;
|
|
2665
|
+
});
|
|
2666
|
+
}
|
|
2667
|
+
x.add(n);
|
|
2668
|
+
}
|
|
2669
|
+
}
|
|
2670
|
+
return i[f].apply(this, arguments);
|
|
2671
|
+
};
|
|
2672
|
+
}), y;
|
|
2673
|
+
} });
|
|
2674
|
+
} };
|
|
2675
|
+
function Nr(e, t, n) {
|
|
2676
|
+
if (n.numFailures === 0) return t;
|
|
2677
|
+
if (t.type === "deleteRange") return null;
|
|
2678
|
+
var r = t.keys ? t.keys.length : "values" in t && t.values ? t.values.length : 1;
|
|
2679
|
+
return n.numFailures === r ? null : (t = k({}, t), B(t.keys) && (t.keys = t.keys.filter(function(i, o) {
|
|
2680
|
+
return !(o in n.failures);
|
|
2681
|
+
})), "values" in t && B(t.values) && (t.values = t.values.filter(function(i, o) {
|
|
2682
|
+
return !(o in n.failures);
|
|
2683
|
+
})), t);
|
|
2684
|
+
}
|
|
2685
|
+
function Un(e, t) {
|
|
2686
|
+
return n = e, ((r = t).lower === void 0 || (r.lowerOpen ? 0 < H(n, r.lower) : 0 <= H(n, r.lower))) && (e = e, (t = t).upper === void 0 || (t.upperOpen ? H(e, t.upper) < 0 : H(e, t.upper) <= 0));
|
|
2687
|
+
var n, r;
|
|
2688
|
+
}
|
|
2689
|
+
function Dr(e, t, v, r, i, o) {
|
|
2690
|
+
if (!v || v.length === 0) return e;
|
|
2691
|
+
var a = t.query.index, u = a.multiEntry, l = t.query.range, h = r.schema.primaryKey.extractKey, y = a.extractKey, c = (a.lowLevelIndex || a).extractKey, v = v.reduce(function(f, p) {
|
|
2692
|
+
var m = f, d = [];
|
|
2693
|
+
if (p.type === "add" || p.type === "put") for (var g = new oe(), b = p.values.length - 1; 0 <= b; --b) {
|
|
2694
|
+
var w, x = p.values[b], E = h(x);
|
|
2695
|
+
g.hasKey(E) || (w = y(x), (u && B(w) ? w.some(function(P) {
|
|
2696
|
+
return Un(P, l);
|
|
2697
|
+
}) : Un(w, l)) && (g.addKey(E), d.push(x)));
|
|
2698
|
+
}
|
|
2699
|
+
switch (p.type) {
|
|
2700
|
+
case "add":
|
|
2701
|
+
var C = new oe().addKeys(t.values ? f.map(function(R) {
|
|
2702
|
+
return h(R);
|
|
2703
|
+
}) : f), m = f.concat(t.values ? d.filter(function(R) {
|
|
2704
|
+
return R = h(R), !C.hasKey(R) && (C.addKey(R), !0);
|
|
2705
|
+
}) : d.map(function(R) {
|
|
2706
|
+
return h(R);
|
|
2707
|
+
}).filter(function(R) {
|
|
2708
|
+
return !C.hasKey(R) && (C.addKey(R), !0);
|
|
2709
|
+
}));
|
|
2710
|
+
break;
|
|
2711
|
+
case "put":
|
|
2712
|
+
var T = new oe().addKeys(p.values.map(function(R) {
|
|
2713
|
+
return h(R);
|
|
2714
|
+
}));
|
|
2715
|
+
m = f.filter(function(R) {
|
|
2716
|
+
return !T.hasKey(t.values ? h(R) : R);
|
|
2717
|
+
}).concat(t.values ? d : d.map(function(R) {
|
|
2718
|
+
return h(R);
|
|
2719
|
+
}));
|
|
2720
|
+
break;
|
|
2721
|
+
case "delete":
|
|
2722
|
+
var I = new oe().addKeys(p.keys);
|
|
2723
|
+
m = f.filter(function(R) {
|
|
2724
|
+
return !I.hasKey(t.values ? h(R) : R);
|
|
2725
|
+
});
|
|
2726
|
+
break;
|
|
2727
|
+
case "deleteRange":
|
|
2728
|
+
var A = p.range;
|
|
2729
|
+
m = f.filter(function(R) {
|
|
2730
|
+
return !Un(h(R), A);
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
return m;
|
|
2734
|
+
}, e);
|
|
2735
|
+
return v === e ? e : (v.sort(function(f, p) {
|
|
2736
|
+
return H(c(f), c(p)) || H(h(f), h(p));
|
|
2737
|
+
}), t.limit && t.limit < 1 / 0 && (v.length > t.limit ? v.length = t.limit : e.length === t.limit && v.length < t.limit && (i.dirty = !0)), o ? Object.freeze(v) : v);
|
|
2738
|
+
}
|
|
2739
|
+
function jr(e, t) {
|
|
2740
|
+
return H(e.lower, t.lower) === 0 && H(e.upper, t.upper) === 0 && !!e.lowerOpen == !!t.lowerOpen && !!e.upperOpen == !!t.upperOpen;
|
|
2741
|
+
}
|
|
2742
|
+
function Ri(e, t) {
|
|
2743
|
+
return function(n, r, i, o) {
|
|
2744
|
+
if (n === void 0) return r !== void 0 ? -1 : 0;
|
|
2745
|
+
if (r === void 0) return 1;
|
|
2746
|
+
if ((r = H(n, r)) === 0) {
|
|
2747
|
+
if (i && o) return 0;
|
|
2748
|
+
if (i) return 1;
|
|
2749
|
+
if (o) return -1;
|
|
2750
|
+
}
|
|
2751
|
+
return r;
|
|
2752
|
+
}(e.lower, t.lower, e.lowerOpen, t.lowerOpen) <= 0 && 0 <= function(n, r, i, o) {
|
|
2753
|
+
if (n === void 0) return r !== void 0 ? 1 : 0;
|
|
2754
|
+
if (r === void 0) return -1;
|
|
2755
|
+
if ((r = H(n, r)) === 0) {
|
|
2756
|
+
if (i && o) return 0;
|
|
2757
|
+
if (i) return -1;
|
|
2758
|
+
if (o) return 1;
|
|
2759
|
+
}
|
|
2760
|
+
return r;
|
|
2761
|
+
}(e.upper, t.upper, e.upperOpen, t.upperOpen);
|
|
2762
|
+
}
|
|
2763
|
+
function Ki(e, t, n, r) {
|
|
2764
|
+
e.subscribers.add(n), r.addEventListener("abort", function() {
|
|
2765
|
+
var i, o;
|
|
2766
|
+
e.subscribers.delete(n), e.subscribers.size === 0 && (i = e, o = t, setTimeout(function() {
|
|
2767
|
+
i.subscribers.size === 0 && Ne(o, i);
|
|
2768
|
+
}, 3e3));
|
|
2769
|
+
});
|
|
2770
|
+
}
|
|
2771
|
+
var Ni = { stack: "dbcore", level: 0, name: "Cache", create: function(e) {
|
|
2772
|
+
var t = e.schema.name;
|
|
2773
|
+
return k(k({}, e), { transaction: function(n, r, i) {
|
|
2774
|
+
var o, a, u = e.transaction(n, r, i);
|
|
2775
|
+
return r === "readwrite" && (a = (o = new AbortController()).signal, i = function(l) {
|
|
2776
|
+
return function() {
|
|
2777
|
+
if (o.abort(), r === "readwrite") {
|
|
2778
|
+
for (var h = /* @__PURE__ */ new Set(), y = 0, c = n; y < c.length; y++) {
|
|
2779
|
+
var v = c[y], f = We["idb://".concat(t, "/").concat(v)];
|
|
2780
|
+
if (f) {
|
|
2781
|
+
var p = e.table(v), m = f.optimisticOps.filter(function(R) {
|
|
2782
|
+
return R.trans === u;
|
|
2783
|
+
});
|
|
2784
|
+
if (u._explicit && l && u.mutatedParts) for (var d = 0, g = Object.values(f.queries.query); d < g.length; d++) for (var b = 0, w = (C = g[d]).slice(); b < w.length; b++) Dn((T = w[b]).obsSet, u.mutatedParts) && (Ne(C, T), T.subscribers.forEach(function(R) {
|
|
2785
|
+
return h.add(R);
|
|
2786
|
+
}));
|
|
2787
|
+
else if (0 < m.length) {
|
|
2788
|
+
f.optimisticOps = f.optimisticOps.filter(function(R) {
|
|
2789
|
+
return R.trans !== u;
|
|
2790
|
+
});
|
|
2791
|
+
for (var x = 0, E = Object.values(f.queries.query); x < E.length; x++) for (var C, T, I, A = 0, P = (C = E[x]).slice(); A < P.length; A++) (T = P[A]).res != null && u.mutatedParts && (l && !T.dirty ? (I = Object.isFrozen(T.res), I = Dr(T.res, T.req, m, p, T, I), T.dirty ? (Ne(C, T), T.subscribers.forEach(function(R) {
|
|
2792
|
+
return h.add(R);
|
|
2793
|
+
})) : I !== T.res && (T.res = I, T.promise = S.resolve({ result: I }))) : (T.dirty && Ne(C, T), T.subscribers.forEach(function(R) {
|
|
2794
|
+
return h.add(R);
|
|
2795
|
+
})));
|
|
2796
|
+
}
|
|
2797
|
+
}
|
|
2798
|
+
}
|
|
2799
|
+
h.forEach(function(R) {
|
|
2800
|
+
return R();
|
|
2801
|
+
});
|
|
2802
|
+
}
|
|
2803
|
+
};
|
|
2804
|
+
}, u.addEventListener("abort", i(!1), { signal: a }), u.addEventListener("error", i(!1), { signal: a }), u.addEventListener("complete", i(!0), { signal: a })), u;
|
|
2805
|
+
}, table: function(n) {
|
|
2806
|
+
var r = e.table(n), i = r.schema.primaryKey;
|
|
2807
|
+
return k(k({}, r), { mutate: function(o) {
|
|
2808
|
+
var a = K.trans;
|
|
2809
|
+
if (i.outbound || a.db._options.cache === "disabled" || a.explicit || a.idbtrans.mode !== "readwrite") return r.mutate(o);
|
|
2810
|
+
var u = We["idb://".concat(t, "/").concat(n)];
|
|
2811
|
+
return u ? (a = r.mutate(o), o.type !== "add" && o.type !== "put" || !(50 <= o.values.length || Ln(i, o).some(function(l) {
|
|
2812
|
+
return l == null;
|
|
2813
|
+
})) ? (u.optimisticOps.push(o), o.mutatedParts && Ht(o.mutatedParts), a.then(function(l) {
|
|
2814
|
+
0 < l.numFailures && (Ne(u.optimisticOps, o), (l = Nr(0, o, l)) && u.optimisticOps.push(l), o.mutatedParts && Ht(o.mutatedParts));
|
|
2815
|
+
}), a.catch(function() {
|
|
2816
|
+
Ne(u.optimisticOps, o), o.mutatedParts && Ht(o.mutatedParts);
|
|
2817
|
+
})) : a.then(function(l) {
|
|
2818
|
+
var h = Nr(0, k(k({}, o), { values: o.values.map(function(y, c) {
|
|
2819
|
+
var v;
|
|
2820
|
+
return l.failures[c] ? y : (y = (v = i.keyPath) !== null && v !== void 0 && v.includes(".") ? Ke(y) : k({}, y), le(y, i.keyPath, l.results[c]), y);
|
|
2821
|
+
}) }), l);
|
|
2822
|
+
u.optimisticOps.push(h), queueMicrotask(function() {
|
|
2823
|
+
return o.mutatedParts && Ht(o.mutatedParts);
|
|
2824
|
+
});
|
|
2825
|
+
}), a) : r.mutate(o);
|
|
2826
|
+
}, query: function(o) {
|
|
2827
|
+
if (!Rr(K, r) || !Kr("query", o)) return r.query(o);
|
|
2828
|
+
var a = ((h = K.trans) === null || h === void 0 ? void 0 : h.db._options.cache) === "immutable", c = K, u = c.requery, l = c.signal, h = function(p, m, d, g) {
|
|
2829
|
+
var b = We["idb://".concat(p, "/").concat(m)];
|
|
2830
|
+
if (!b) return [];
|
|
2831
|
+
if (!(m = b.queries[d])) return [null, !1, b, null];
|
|
2832
|
+
var w = m[(g.query ? g.query.index.name : null) || ""];
|
|
2833
|
+
if (!w) return [null, !1, b, null];
|
|
2834
|
+
switch (d) {
|
|
2835
|
+
case "query":
|
|
2836
|
+
var x = w.find(function(E) {
|
|
2837
|
+
return E.req.limit === g.limit && E.req.values === g.values && jr(E.req.query.range, g.query.range);
|
|
2838
|
+
});
|
|
2839
|
+
return x ? [x, !0, b, w] : [w.find(function(E) {
|
|
2840
|
+
return ("limit" in E.req ? E.req.limit : 1 / 0) >= g.limit && (!g.values || E.req.values) && Ri(E.req.query.range, g.query.range);
|
|
2841
|
+
}), !1, b, w];
|
|
2842
|
+
case "count":
|
|
2843
|
+
return x = w.find(function(E) {
|
|
2844
|
+
return jr(E.req.query.range, g.query.range);
|
|
2845
|
+
}), [x, !!x, b, w];
|
|
2846
|
+
}
|
|
2847
|
+
}(t, n, "query", o), y = h[0], c = h[1], v = h[2], f = h[3];
|
|
2848
|
+
return y && c ? y.obsSet = o.obsSet : (c = r.query(o).then(function(p) {
|
|
2849
|
+
var m = p.result;
|
|
2850
|
+
if (y && (y.res = m), a) {
|
|
2851
|
+
for (var d = 0, g = m.length; d < g; ++d) Object.freeze(m[d]);
|
|
2852
|
+
Object.freeze(m);
|
|
2853
|
+
} else p.result = Ke(m);
|
|
2854
|
+
return p;
|
|
2855
|
+
}).catch(function(p) {
|
|
2856
|
+
return f && y && Ne(f, y), Promise.reject(p);
|
|
2857
|
+
}), y = { obsSet: o.obsSet, promise: c, subscribers: /* @__PURE__ */ new Set(), type: "query", req: o, dirty: !1 }, f ? f.push(y) : (f = [y], (v = v || (We["idb://".concat(t, "/").concat(n)] = { queries: { query: {}, count: {} }, objs: /* @__PURE__ */ new Map(), optimisticOps: [], unsignaledParts: {} })).queries.query[o.query.index.name || ""] = f)), Ki(y, f, u, l), y.promise.then(function(p) {
|
|
2858
|
+
return { result: Dr(p.result, o, v?.optimisticOps, r, y, a) };
|
|
2859
|
+
});
|
|
2860
|
+
} });
|
|
2861
|
+
} });
|
|
2862
|
+
} };
|
|
2863
|
+
function $t(e, t) {
|
|
2864
|
+
return new Proxy(e, { get: function(n, r, i) {
|
|
2865
|
+
return r === "db" ? t : Reflect.get(n, r, i);
|
|
2866
|
+
} });
|
|
2867
|
+
}
|
|
2868
|
+
var ke = (ne.prototype.version = function(e) {
|
|
2869
|
+
if (isNaN(e) || e < 0.1) throw new D.Type("Given version is not a positive number");
|
|
2870
|
+
if (e = Math.round(10 * e) / 10, this.idbdb || this._state.isBeingOpened) throw new D.Schema("Cannot add version when database is open");
|
|
2871
|
+
this.verno = Math.max(this.verno, e);
|
|
2872
|
+
var t = this._versions, n = t.filter(function(r) {
|
|
2873
|
+
return r._cfg.version === e;
|
|
2874
|
+
})[0];
|
|
2875
|
+
return n || (n = new this.Version(e), t.push(n), t.sort(Oi), n.stores({}), this._state.autoSchema = !1, n);
|
|
2876
|
+
}, ne.prototype._whenReady = function(e) {
|
|
2877
|
+
var t = this;
|
|
2878
|
+
return this.idbdb && (this._state.openComplete || K.letThrough || this._vip) ? e() : new S(function(n, r) {
|
|
2879
|
+
if (t._state.openComplete) return r(new D.DatabaseClosed(t._state.dbOpenError));
|
|
2880
|
+
if (!t._state.isBeingOpened) {
|
|
2881
|
+
if (!t._state.autoOpen) return void r(new D.DatabaseClosed());
|
|
2882
|
+
t.open().catch(G);
|
|
2883
|
+
}
|
|
2884
|
+
t._state.dbReadyPromise.then(n, r);
|
|
2885
|
+
}).then(e);
|
|
2886
|
+
}, ne.prototype.use = function(e) {
|
|
2887
|
+
var t = e.stack, n = e.create, r = e.level, i = e.name;
|
|
2888
|
+
return i && this.unuse({ stack: t, name: i }), e = this._middlewares[t] || (this._middlewares[t] = []), e.push({ stack: t, create: n, level: r ?? 10, name: i }), e.sort(function(o, a) {
|
|
2889
|
+
return o.level - a.level;
|
|
2890
|
+
}), this;
|
|
2891
|
+
}, ne.prototype.unuse = function(e) {
|
|
2892
|
+
var t = e.stack, n = e.name, r = e.create;
|
|
2893
|
+
return t && this._middlewares[t] && (this._middlewares[t] = this._middlewares[t].filter(function(i) {
|
|
2894
|
+
return r ? i.create !== r : !!n && i.name !== n;
|
|
2895
|
+
})), this;
|
|
2896
|
+
}, ne.prototype.open = function() {
|
|
2897
|
+
var e = this;
|
|
2898
|
+
return Me(Te, function() {
|
|
2899
|
+
return Ii(e);
|
|
2900
|
+
});
|
|
2901
|
+
}, ne.prototype._close = function() {
|
|
2902
|
+
var e = this._state, t = et.indexOf(this);
|
|
2903
|
+
if (0 <= t && et.splice(t, 1), this.idbdb) {
|
|
2904
|
+
try {
|
|
2905
|
+
this.idbdb.close();
|
|
2906
|
+
} catch {
|
|
2907
|
+
}
|
|
2908
|
+
this.idbdb = null;
|
|
2909
|
+
}
|
|
2910
|
+
e.isBeingOpened || (e.dbReadyPromise = new S(function(n) {
|
|
2911
|
+
e.dbReadyResolve = n;
|
|
2912
|
+
}), e.openCanceller = new S(function(n, r) {
|
|
2913
|
+
e.cancelOpen = r;
|
|
2914
|
+
}));
|
|
2915
|
+
}, ne.prototype.close = function(n) {
|
|
2916
|
+
var t = (n === void 0 ? { disableAutoOpen: !0 } : n).disableAutoOpen, n = this._state;
|
|
2917
|
+
t ? (n.isBeingOpened && n.cancelOpen(new D.DatabaseClosed()), this._close(), n.autoOpen = !1, n.dbOpenError = new D.DatabaseClosed()) : (this._close(), n.autoOpen = this._options.autoOpen || n.isBeingOpened, n.openComplete = !1, n.dbOpenError = null);
|
|
2918
|
+
}, ne.prototype.delete = function(e) {
|
|
2919
|
+
var t = this;
|
|
2920
|
+
e === void 0 && (e = { disableAutoOpen: !0 });
|
|
2921
|
+
var n = 0 < arguments.length && typeof arguments[0] != "object", r = this._state;
|
|
2922
|
+
return new S(function(i, o) {
|
|
2923
|
+
function a() {
|
|
2924
|
+
t.close(e);
|
|
2925
|
+
var u = t._deps.indexedDB.deleteDatabase(t.name);
|
|
2926
|
+
u.onsuccess = ee(function() {
|
|
2927
|
+
var l, h, y;
|
|
2928
|
+
l = t._deps, h = t.name, y = l.indexedDB, l = l.IDBKeyRange, Rn(y) || h === Rt || Sn(y, l).delete(h).catch(G), i();
|
|
2929
|
+
}), u.onerror = be(o), u.onblocked = t._fireOnBlocked;
|
|
2930
|
+
}
|
|
2931
|
+
if (n) throw new D.InvalidArgument("Invalid closeOptions argument to db.delete()");
|
|
2932
|
+
r.isBeingOpened ? r.dbReadyPromise.then(a) : a();
|
|
2933
|
+
});
|
|
2934
|
+
}, ne.prototype.backendDB = function() {
|
|
2935
|
+
return this.idbdb;
|
|
2936
|
+
}, ne.prototype.isOpen = function() {
|
|
2937
|
+
return this.idbdb !== null;
|
|
2938
|
+
}, ne.prototype.hasBeenClosed = function() {
|
|
2939
|
+
var e = this._state.dbOpenError;
|
|
2940
|
+
return e && e.name === "DatabaseClosed";
|
|
2941
|
+
}, ne.prototype.hasFailed = function() {
|
|
2942
|
+
return this._state.dbOpenError !== null;
|
|
2943
|
+
}, ne.prototype.dynamicallyOpened = function() {
|
|
2944
|
+
return this._state.autoSchema;
|
|
2945
|
+
}, Object.defineProperty(ne.prototype, "tables", { get: function() {
|
|
2946
|
+
var e = this;
|
|
2947
|
+
return F(this._allTables).map(function(t) {
|
|
2948
|
+
return e._allTables[t];
|
|
2949
|
+
});
|
|
2950
|
+
}, enumerable: !1, configurable: !0 }), ne.prototype.transaction = function() {
|
|
2951
|
+
var e = function(t, n, r) {
|
|
2952
|
+
var i = arguments.length;
|
|
2953
|
+
if (i < 2) throw new D.InvalidArgument("Too few arguments");
|
|
2954
|
+
for (var o = new Array(i - 1); --i; ) o[i - 1] = arguments[i];
|
|
2955
|
+
return r = o.pop(), [t, nr(o), r];
|
|
2956
|
+
}.apply(this, arguments);
|
|
2957
|
+
return this._transaction.apply(this, e);
|
|
2958
|
+
}, ne.prototype._transaction = function(e, t, n) {
|
|
2959
|
+
var r = this, i = K.trans;
|
|
2960
|
+
i && i.db === this && e.indexOf("!") === -1 || (i = null);
|
|
2961
|
+
var o, a, u = e.indexOf("?") !== -1;
|
|
2962
|
+
e = e.replace("!", "").replace("?", "");
|
|
2963
|
+
try {
|
|
2964
|
+
if (a = t.map(function(h) {
|
|
2965
|
+
if (h = h instanceof r.Table ? h.name : h, typeof h != "string") throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");
|
|
2966
|
+
return h;
|
|
2967
|
+
}), e == "r" || e === bn) o = bn;
|
|
2968
|
+
else {
|
|
2969
|
+
if (e != "rw" && e != wn) throw new D.InvalidArgument("Invalid transaction mode: " + e);
|
|
2970
|
+
o = wn;
|
|
2971
|
+
}
|
|
2972
|
+
if (i) {
|
|
2973
|
+
if (i.mode === bn && o === wn) {
|
|
2974
|
+
if (!u) throw new D.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
|
|
2975
|
+
i = null;
|
|
2976
|
+
}
|
|
2977
|
+
i && a.forEach(function(h) {
|
|
2978
|
+
if (i && i.storeNames.indexOf(h) === -1) {
|
|
2979
|
+
if (!u) throw new D.SubTransaction("Table " + h + " not included in parent transaction.");
|
|
2980
|
+
i = null;
|
|
2981
|
+
}
|
|
2982
|
+
}), u && i && !i.active && (i = null);
|
|
2983
|
+
}
|
|
2984
|
+
} catch (h) {
|
|
2985
|
+
return i ? i._promise(null, function(y, c) {
|
|
2986
|
+
c(h);
|
|
2987
|
+
}) : te(h);
|
|
2988
|
+
}
|
|
2989
|
+
var l = function h(y, c, v, f, p) {
|
|
2990
|
+
return S.resolve().then(function() {
|
|
2991
|
+
var m = K.transless || K, d = y._createTransaction(c, v, y._dbSchema, f);
|
|
2992
|
+
if (d.explicit = !0, m = { trans: d, transless: m }, f) d.idbtrans = f.idbtrans;
|
|
2993
|
+
else try {
|
|
2994
|
+
d.create(), d.idbtrans._explicit = !0, y._state.PR1398_maxLoop = 3;
|
|
2995
|
+
} catch (w) {
|
|
2996
|
+
return w.name === cn.InvalidState && y.isOpen() && 0 < --y._state.PR1398_maxLoop ? (console.warn("Dexie: Need to reopen db"), y.close({ disableAutoOpen: !1 }), y.open().then(function() {
|
|
2997
|
+
return h(y, c, v, null, p);
|
|
2998
|
+
})) : te(w);
|
|
2999
|
+
}
|
|
3000
|
+
var g, b = un(p);
|
|
3001
|
+
return b && Ze(), m = S.follow(function() {
|
|
3002
|
+
var w;
|
|
3003
|
+
(g = p.call(d, d)) && (b ? (w = Pe.bind(null, null), g.then(w, w)) : typeof g.next == "function" && typeof g.throw == "function" && (g = qn(g)));
|
|
3004
|
+
}, m), (g && typeof g.then == "function" ? S.resolve(g).then(function(w) {
|
|
3005
|
+
return d.active ? w : te(new D.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"));
|
|
3006
|
+
}) : m.then(function() {
|
|
3007
|
+
return g;
|
|
3008
|
+
})).then(function(w) {
|
|
3009
|
+
return f && d._resolve(), d._completion.then(function() {
|
|
3010
|
+
return w;
|
|
3011
|
+
});
|
|
3012
|
+
}).catch(function(w) {
|
|
3013
|
+
return d._reject(w), te(w);
|
|
3014
|
+
});
|
|
3015
|
+
});
|
|
3016
|
+
}.bind(null, this, o, a, i, n);
|
|
3017
|
+
return i ? i._promise(o, l, "lock") : K.trans ? Me(K.transless, function() {
|
|
3018
|
+
return r._whenReady(l);
|
|
3019
|
+
}) : this._whenReady(l);
|
|
3020
|
+
}, ne.prototype.table = function(e) {
|
|
3021
|
+
if (!z(this._allTables, e)) throw new D.InvalidTable("Table ".concat(e, " does not exist"));
|
|
3022
|
+
return this._allTables[e];
|
|
3023
|
+
}, ne);
|
|
3024
|
+
function ne(e, t) {
|
|
3025
|
+
var n = this;
|
|
3026
|
+
this._middlewares = {}, this.verno = 0;
|
|
3027
|
+
var r = ne.dependencies;
|
|
3028
|
+
this._options = t = k({ addons: ne.addons, autoOpen: !0, indexedDB: r.indexedDB, IDBKeyRange: r.IDBKeyRange, cache: "cloned" }, t), this._deps = { indexedDB: t.indexedDB, IDBKeyRange: t.IDBKeyRange }, r = t.addons, this._dbSchema = {}, this._versions = [], this._storeNames = [], this._allTables = {}, this.idbdb = null, this._novip = this;
|
|
3029
|
+
var i, o, a, u, l, h = { dbOpenError: null, isBeingOpened: !1, onReadyBeingFired: null, openComplete: !1, dbReadyResolve: G, dbReadyPromise: null, cancelOpen: G, openCanceller: null, autoSchema: !0, PR1398_maxLoop: 3, autoOpen: t.autoOpen };
|
|
3030
|
+
h.dbReadyPromise = new S(function(c) {
|
|
3031
|
+
h.dbReadyResolve = c;
|
|
3032
|
+
}), h.openCanceller = new S(function(c, v) {
|
|
3033
|
+
h.cancelOpen = v;
|
|
3034
|
+
}), this._state = h, this.name = e, this.on = ht(this, "populate", "blocked", "versionchange", "close", { ready: [ln, G] }), this.on.ready.subscribe = Zn(this.on.ready.subscribe, function(c) {
|
|
3035
|
+
return function(v, f) {
|
|
3036
|
+
ne.vip(function() {
|
|
3037
|
+
var p, m = n._state;
|
|
3038
|
+
m.openComplete ? (m.dbOpenError || S.resolve().then(v), f && c(v)) : m.onReadyBeingFired ? (m.onReadyBeingFired.push(v), f && c(v)) : (c(v), p = n, f || c(function d() {
|
|
3039
|
+
p.on.ready.unsubscribe(v), p.on.ready.unsubscribe(d);
|
|
3040
|
+
}));
|
|
3041
|
+
});
|
|
3042
|
+
};
|
|
3043
|
+
}), this.Collection = (i = this, dt(mi.prototype, function(g, d) {
|
|
3044
|
+
this.db = i;
|
|
3045
|
+
var f = dr, p = null;
|
|
3046
|
+
if (d) try {
|
|
3047
|
+
f = d();
|
|
3048
|
+
} catch (b) {
|
|
3049
|
+
p = b;
|
|
3050
|
+
}
|
|
3051
|
+
var m = g._ctx, d = m.table, g = d.hook.reading.fire;
|
|
3052
|
+
this._ctx = { table: d, index: m.index, isPrimKey: !m.index || d.schema.primKey.keyPath && m.index === d.schema.primKey.name, range: f, keysOnly: !1, dir: "next", unique: "", algorithm: null, filter: null, replayFilter: null, justLimit: !0, isMatch: null, offset: 0, limit: 1 / 0, error: p, or: m.or, valueMapper: g !== st ? g : null };
|
|
3053
|
+
})), this.Table = (o = this, dt(vr.prototype, function(c, v, f) {
|
|
3054
|
+
this.db = o, this._tx = f, this.name = c, this.schema = v, this.hook = o._allTables[c] ? o._allTables[c].hook : ht(null, { creating: [si, G], reading: [ai, st], updating: [ci, G], deleting: [ui, G] });
|
|
3055
|
+
})), this.Transaction = (a = this, dt(bi.prototype, function(c, v, f, p, m) {
|
|
3056
|
+
var d = this;
|
|
3057
|
+
this.db = a, this.mode = c, this.storeNames = v, this.schema = f, this.chromeTransactionDurability = p, this.idbtrans = null, this.on = ht(this, "complete", "error", "abort"), this.parent = m || 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 S(function(g, b) {
|
|
3058
|
+
d._resolve = g, d._reject = b;
|
|
3059
|
+
}), this._completion.then(function() {
|
|
3060
|
+
d.active = !1, d.on.complete.fire();
|
|
3061
|
+
}, function(g) {
|
|
3062
|
+
var b = d.active;
|
|
3063
|
+
return d.active = !1, d.on.error.fire(g), d.parent ? d.parent._reject(g) : b && d.idbtrans && d.idbtrans.abort(), te(g);
|
|
3064
|
+
});
|
|
3065
|
+
})), this.Version = (u = this, dt(Ti.prototype, function(c) {
|
|
3066
|
+
this.db = u, this._cfg = { version: c, storesSource: null, dbschema: {}, tables: {}, contentUpgrade: null };
|
|
3067
|
+
})), this.WhereClause = (l = this, dt(xr.prototype, function(c, v, f) {
|
|
3068
|
+
if (this.db = l, this._ctx = { table: c, index: v === ":id" ? null : v, or: f }, this._cmp = this._ascending = H, this._descending = function(p, m) {
|
|
3069
|
+
return H(m, p);
|
|
3070
|
+
}, this._max = function(p, m) {
|
|
3071
|
+
return 0 < H(p, m) ? p : m;
|
|
3072
|
+
}, this._min = function(p, m) {
|
|
3073
|
+
return H(p, m) < 0 ? p : m;
|
|
3074
|
+
}, this._IDBKeyRange = l._deps.IDBKeyRange, !this._IDBKeyRange) throw new D.MissingAPI();
|
|
3075
|
+
})), this.on("versionchange", function(c) {
|
|
3076
|
+
0 < c.newVersion ? console.warn("Another connection wants to upgrade database '".concat(n.name, "'. Closing db now to resume the upgrade.")) : console.warn("Another connection wants to delete database '".concat(n.name, "'. Closing db now to resume the delete request.")), n.close({ disableAutoOpen: !1 });
|
|
3077
|
+
}), this.on("blocked", function(c) {
|
|
3078
|
+
!c.newVersion || c.newVersion < c.oldVersion ? console.warn("Dexie.delete('".concat(n.name, "') was blocked")) : console.warn("Upgrade '".concat(n.name, "' blocked by other connection holding version ").concat(c.oldVersion / 10));
|
|
3079
|
+
}), this._maxKey = vt(t.IDBKeyRange), this._createTransaction = function(c, v, f, p) {
|
|
3080
|
+
return new n.Transaction(c, v, f, n._options.chromeTransactionDurability, p);
|
|
3081
|
+
}, this._fireOnBlocked = function(c) {
|
|
3082
|
+
n.on("blocked").fire(c), et.filter(function(v) {
|
|
3083
|
+
return v.name === n.name && v !== n && !v._state.vcFired;
|
|
3084
|
+
}).map(function(v) {
|
|
3085
|
+
return v.on("versionchange").fire(c);
|
|
3086
|
+
});
|
|
3087
|
+
}, this.use(Ai), this.use(Ni), this.use(Si), this.use(Pi), this.use(Ci);
|
|
3088
|
+
var y = new Proxy(this, { get: function(c, v, f) {
|
|
3089
|
+
if (v === "_vip") return !0;
|
|
3090
|
+
if (v === "table") return function(m) {
|
|
3091
|
+
return $t(n.table(m), y);
|
|
3092
|
+
};
|
|
3093
|
+
var p = Reflect.get(c, v, f);
|
|
3094
|
+
return p instanceof vr ? $t(p, y) : v === "tables" ? p.map(function(m) {
|
|
3095
|
+
return $t(m, y);
|
|
3096
|
+
}) : v === "_createTransaction" ? function() {
|
|
3097
|
+
return $t(p.apply(this, arguments), y);
|
|
3098
|
+
} : p;
|
|
3099
|
+
} });
|
|
3100
|
+
this.vip = y, r.forEach(function(c) {
|
|
3101
|
+
return c(n);
|
|
3102
|
+
});
|
|
3103
|
+
}
|
|
3104
|
+
var Yt, pe = typeof Symbol < "u" && "observable" in Symbol ? Symbol.observable : "@@observable", Di = (Wn.prototype.subscribe = function(e, t, n) {
|
|
3105
|
+
return this._subscribe(e && typeof e != "function" ? e : { next: e, error: t, complete: n });
|
|
3106
|
+
}, Wn.prototype[pe] = function() {
|
|
3107
|
+
return this;
|
|
3108
|
+
}, Wn);
|
|
3109
|
+
function Wn(e) {
|
|
3110
|
+
this._subscribe = e;
|
|
3111
|
+
}
|
|
3112
|
+
try {
|
|
3113
|
+
Yt = { indexedDB: N.indexedDB || N.mozIndexedDB || N.webkitIndexedDB || N.msIndexedDB, IDBKeyRange: N.IDBKeyRange || N.webkitIDBKeyRange };
|
|
3114
|
+
} catch {
|
|
3115
|
+
Yt = { indexedDB: null, IDBKeyRange: null };
|
|
3116
|
+
}
|
|
3117
|
+
function Br(e) {
|
|
3118
|
+
var t, n = !1, r = new Di(function(i) {
|
|
3119
|
+
var o = un(e), a, u = !1, l = {}, h = {}, y = { get closed() {
|
|
3120
|
+
return u;
|
|
3121
|
+
}, unsubscribe: function() {
|
|
3122
|
+
u || (u = !0, a && a.abort(), c && Se.storagemutated.unsubscribe(f));
|
|
3123
|
+
} };
|
|
3124
|
+
i.start && i.start(y);
|
|
3125
|
+
var c = !1, v = function() {
|
|
3126
|
+
return gn(p);
|
|
3127
|
+
}, f = function(m) {
|
|
3128
|
+
Vt(l, m), Dn(h, l) && v();
|
|
3129
|
+
}, p = function() {
|
|
3130
|
+
var m, d, g;
|
|
3131
|
+
!u && Yt.indexedDB && (l = {}, m = {}, a && a.abort(), a = new AbortController(), g = function(b) {
|
|
3132
|
+
var w = Xe();
|
|
3133
|
+
try {
|
|
3134
|
+
o && Ze();
|
|
3135
|
+
var x = Ie(e, b);
|
|
3136
|
+
return x = o ? x.finally(Pe) : x;
|
|
3137
|
+
} finally {
|
|
3138
|
+
w && Je();
|
|
3139
|
+
}
|
|
3140
|
+
}(d = { subscr: m, signal: a.signal, requery: v, querier: e, trans: null }), Promise.resolve(g).then(function(b) {
|
|
3141
|
+
n = !0, t = b, u || d.signal.aborted || (l = {}, function(w) {
|
|
3142
|
+
for (var x in w) if (z(w, x)) return;
|
|
3143
|
+
return 1;
|
|
3144
|
+
}(h = m) || c || (Se(mt, f), c = !0), gn(function() {
|
|
3145
|
+
return !u && i.next && i.next(b);
|
|
3146
|
+
}));
|
|
3147
|
+
}, function(b) {
|
|
3148
|
+
n = !1, ["DatabaseClosedError", "AbortError"].includes(b?.name) || u || gn(function() {
|
|
3149
|
+
u || i.error && i.error(b);
|
|
3150
|
+
});
|
|
3151
|
+
}));
|
|
3152
|
+
};
|
|
3153
|
+
return setTimeout(v, 0), y;
|
|
3154
|
+
});
|
|
3155
|
+
return r.hasValue = function() {
|
|
3156
|
+
return n;
|
|
3157
|
+
}, r.getValue = function() {
|
|
3158
|
+
return t;
|
|
3159
|
+
}, r;
|
|
3160
|
+
}
|
|
3161
|
+
var Ve = ke;
|
|
3162
|
+
function Vn(e) {
|
|
3163
|
+
var t = Re;
|
|
3164
|
+
try {
|
|
3165
|
+
Re = !0, Se.storagemutated.fire(e), Fn(e, !0);
|
|
3166
|
+
} finally {
|
|
3167
|
+
Re = t;
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
X(Ve, k(k({}, Ot), { delete: function(e) {
|
|
3171
|
+
return new Ve(e, { addons: [] }).delete();
|
|
3172
|
+
}, exists: function(e) {
|
|
3173
|
+
return new Ve(e, { addons: [] }).open().then(function(t) {
|
|
3174
|
+
return t.close(), !0;
|
|
3175
|
+
}).catch("NoSuchDatabaseError", function() {
|
|
3176
|
+
return !1;
|
|
3177
|
+
});
|
|
3178
|
+
}, getDatabaseNames: function(e) {
|
|
3179
|
+
try {
|
|
3180
|
+
return t = Ve.dependencies, n = t.indexedDB, t = t.IDBKeyRange, (Rn(n) ? Promise.resolve(n.databases()).then(function(r) {
|
|
3181
|
+
return r.map(function(i) {
|
|
3182
|
+
return i.name;
|
|
3183
|
+
}).filter(function(i) {
|
|
3184
|
+
return i !== Rt;
|
|
3185
|
+
});
|
|
3186
|
+
}) : Sn(n, t).toCollection().primaryKeys()).then(e);
|
|
3187
|
+
} catch {
|
|
3188
|
+
return te(new D.MissingAPI());
|
|
3189
|
+
}
|
|
3190
|
+
var t, n;
|
|
3191
|
+
}, defineClass: function() {
|
|
3192
|
+
return function(e) {
|
|
3193
|
+
W(this, e);
|
|
3194
|
+
};
|
|
3195
|
+
}, ignoreTransaction: function(e) {
|
|
3196
|
+
return K.trans ? Me(K.transless, e) : e();
|
|
3197
|
+
}, vip: Kn, async: function(e) {
|
|
3198
|
+
return function() {
|
|
3199
|
+
try {
|
|
3200
|
+
var t = qn(e.apply(this, arguments));
|
|
3201
|
+
return t && typeof t.then == "function" ? t : S.resolve(t);
|
|
3202
|
+
} catch (n) {
|
|
3203
|
+
return te(n);
|
|
3204
|
+
}
|
|
3205
|
+
};
|
|
3206
|
+
}, spawn: function(e, t, n) {
|
|
3207
|
+
try {
|
|
3208
|
+
var r = qn(e.apply(n, t || []));
|
|
3209
|
+
return r && typeof r.then == "function" ? r : S.resolve(r);
|
|
3210
|
+
} catch (i) {
|
|
3211
|
+
return te(i);
|
|
3212
|
+
}
|
|
3213
|
+
}, currentTransaction: { get: function() {
|
|
3214
|
+
return K.trans || null;
|
|
3215
|
+
} }, waitFor: function(e, t) {
|
|
3216
|
+
return t = S.resolve(typeof e == "function" ? Ve.ignoreTransaction(e) : e).timeout(t || 6e4), K.trans ? K.trans.waitFor(t) : t;
|
|
3217
|
+
}, Promise: S, debug: { get: function() {
|
|
3218
|
+
return ge;
|
|
3219
|
+
}, set: function(e) {
|
|
3220
|
+
ar(e);
|
|
3221
|
+
} }, derive: $e, extend: W, props: X, override: Zn, Events: ht, on: Se, liveQuery: Br, extendObservabilitySet: Vt, getByKeyPath: _e, setByKeyPath: le, delByKeyPath: function(e, t) {
|
|
3222
|
+
typeof t == "string" ? le(e, t, void 0) : "length" in t && [].map.call(t, function(n) {
|
|
3223
|
+
le(e, n, void 0);
|
|
3224
|
+
});
|
|
3225
|
+
}, shallowClone: tr, deepClone: Ke, getObjectDiff: Mn, cmp: H, asap: er, minKey: -1 / 0, addons: [], connections: et, errnames: cn, dependencies: Yt, cache: We, semVer: "4.0.11", version: "4.0.11".split(".").map(function(e) {
|
|
3226
|
+
return parseInt(e);
|
|
3227
|
+
}).reduce(function(e, t, n) {
|
|
3228
|
+
return e + t / Math.pow(10, 2 * n);
|
|
3229
|
+
}) })), Ve.maxKey = vt(Ve.dependencies.IDBKeyRange), typeof dispatchEvent < "u" && typeof addEventListener < "u" && (Se(mt, function(e) {
|
|
3230
|
+
Re || (e = new CustomEvent(kn, { detail: e }), Re = !0, dispatchEvent(e), Re = !1);
|
|
3231
|
+
}), addEventListener(kn, function(e) {
|
|
3232
|
+
e = e.detail, Re || Vn(e);
|
|
3233
|
+
}));
|
|
3234
|
+
var rt, Re = !1, Fr = function() {
|
|
3235
|
+
};
|
|
3236
|
+
return typeof BroadcastChannel < "u" && ((Fr = function() {
|
|
3237
|
+
(rt = new BroadcastChannel(kn)).onmessage = function(e) {
|
|
3238
|
+
return e.data && Vn(e.data);
|
|
3239
|
+
};
|
|
3240
|
+
})(), typeof rt.unref == "function" && rt.unref(), Se(mt, function(e) {
|
|
3241
|
+
Re || rt.postMessage(e);
|
|
3242
|
+
})), typeof addEventListener < "u" && (addEventListener("pagehide", function(e) {
|
|
3243
|
+
if (!ke.disableBfCache && e.persisted) {
|
|
3244
|
+
ge && console.debug("Dexie: handling persisted pagehide"), rt?.close();
|
|
3245
|
+
for (var t = 0, n = et; t < n.length; t++) n[t].close({ disableAutoOpen: !1 });
|
|
3246
|
+
}
|
|
3247
|
+
}), addEventListener("pageshow", function(e) {
|
|
3248
|
+
!ke.disableBfCache && e.persisted && (ge && console.debug("Dexie: handling persisted pageshow"), Fr(), Vn({ all: new oe(-1 / 0, [[]]) }));
|
|
3249
|
+
})), S.rejectionMapper = function(e, t) {
|
|
3250
|
+
return !e || e instanceof Ge || e instanceof TypeError || e instanceof SyntaxError || !e.name || !or[e.name] ? e : (t = new or[e.name](t || e.message, e), "stack" in e && ve(t, "stack", { get: function() {
|
|
3251
|
+
return this.inner.stack;
|
|
3252
|
+
} }), t);
|
|
3253
|
+
}, ar(ge), k(ke, Object.freeze({ __proto__: null, Dexie: ke, liveQuery: Br, Entity: pr, cmp: H, PropModification: pt, replacePrefix: function(e, t) {
|
|
3254
|
+
return new pt({ replacePrefix: [e, t] });
|
|
3255
|
+
}, add: function(e) {
|
|
3256
|
+
return new pt({ add: e });
|
|
3257
|
+
}, remove: function(e) {
|
|
3258
|
+
return new pt({ remove: e });
|
|
3259
|
+
}, default: ke, RangeSet: oe, mergeRanges: wt, rangesOverlap: Ir }), { default: ke }), ke;
|
|
3260
|
+
});
|
|
3261
|
+
}(Jt)), Jt.exports;
|
|
3262
|
+
}
|
|
3263
|
+
var Zi = Ji(), Qn = /* @__PURE__ */ Qi(Zi);
|
|
3264
|
+
const Lr = Symbol.for("Dexie"), rn = globalThis[Lr] || (globalThis[Lr] = Qn);
|
|
3265
|
+
if (Qn.semVer !== rn.semVer)
|
|
3266
|
+
throw new Error(`Two different versions of Dexie loaded in the same app: ${Qn.semVer} and ${rn.semVer}`);
|
|
3267
|
+
const {
|
|
3268
|
+
liveQuery: ho,
|
|
3269
|
+
mergeRanges: po,
|
|
3270
|
+
rangesOverlap: yo,
|
|
3271
|
+
RangeSet: mo,
|
|
3272
|
+
cmp: vo,
|
|
3273
|
+
Entity: go,
|
|
3274
|
+
PropModification: bo,
|
|
3275
|
+
replacePrefix: wo,
|
|
3276
|
+
add: _o,
|
|
3277
|
+
remove: xo
|
|
3278
|
+
} = rn;
|
|
3279
|
+
var Ee = /* @__PURE__ */ ((s) => (s[s.WIDTH8 = 0] = "WIDTH8", s[s.WIDTH16 = 1] = "WIDTH16", s[s.WIDTH32 = 2] = "WIDTH32", s[s.WIDTH64 = 3] = "WIDTH64", s))(Ee || {});
|
|
3280
|
+
function de(s) {
|
|
3281
|
+
return s === 1 ? Ee.WIDTH8 : s === 2 ? Ee.WIDTH16 : s === 4 ? Ee.WIDTH32 : Ee.WIDTH64;
|
|
3282
|
+
}
|
|
3283
|
+
function Xr(s) {
|
|
3284
|
+
return new TextDecoder().decode(s);
|
|
3285
|
+
}
|
|
3286
|
+
function eo(s) {
|
|
3287
|
+
return new TextEncoder().encode(s);
|
|
3288
|
+
}
|
|
3289
|
+
var V = /* @__PURE__ */ ((s) => (s[s.NULL = 0] = "NULL", s[s.INT = 1] = "INT", s[s.UINT = 2] = "UINT", s[s.FLOAT = 3] = "FLOAT", s[s.KEY = 4] = "KEY", s[s.STRING = 5] = "STRING", s[s.INDIRECT_INT = 6] = "INDIRECT_INT", s[s.INDIRECT_UINT = 7] = "INDIRECT_UINT", s[s.INDIRECT_FLOAT = 8] = "INDIRECT_FLOAT", s[s.MAP = 9] = "MAP", s[s.VECTOR = 10] = "VECTOR", s[s.VECTOR_INT = 11] = "VECTOR_INT", s[s.VECTOR_UINT = 12] = "VECTOR_UINT", s[s.VECTOR_FLOAT = 13] = "VECTOR_FLOAT", s[s.VECTOR_KEY = 14] = "VECTOR_KEY", s[s.VECTOR_STRING_DEPRECATED = 15] = "VECTOR_STRING_DEPRECATED", s[s.VECTOR_INT2 = 16] = "VECTOR_INT2", s[s.VECTOR_UINT2 = 17] = "VECTOR_UINT2", s[s.VECTOR_FLOAT2 = 18] = "VECTOR_FLOAT2", s[s.VECTOR_INT3 = 19] = "VECTOR_INT3", s[s.VECTOR_UINT3 = 20] = "VECTOR_UINT3", s[s.VECTOR_FLOAT3 = 21] = "VECTOR_FLOAT3", s[s.VECTOR_INT4 = 22] = "VECTOR_INT4", s[s.VECTOR_UINT4 = 23] = "VECTOR_UINT4", s[s.VECTOR_FLOAT4 = 24] = "VECTOR_FLOAT4", s[s.BLOB = 25] = "BLOB", s[s.BOOL = 26] = "BOOL", s[s.VECTOR_BOOL = 36] = "VECTOR_BOOL", s))(V || {});
|
|
3290
|
+
function to(s) {
|
|
3291
|
+
return s >= V.INT && s <= V.FLOAT;
|
|
3292
|
+
}
|
|
3293
|
+
function no(s) {
|
|
3294
|
+
return s >= V.INDIRECT_INT && s <= V.INDIRECT_FLOAT;
|
|
3295
|
+
}
|
|
3296
|
+
function Jr(s) {
|
|
3297
|
+
return s === V.VECTOR_BOOL || s >= V.VECTOR_INT && s <= V.VECTOR_STRING_DEPRECATED;
|
|
3298
|
+
}
|
|
3299
|
+
function Xn(s) {
|
|
3300
|
+
return s >= V.VECTOR_INT2 && s <= V.VECTOR_FLOAT4;
|
|
3301
|
+
}
|
|
3302
|
+
function $n(s) {
|
|
3303
|
+
return Jr(s) || Xn(s) || s === V.VECTOR;
|
|
3304
|
+
}
|
|
3305
|
+
function ro(s) {
|
|
3306
|
+
return s - V.VECTOR_INT + V.INT;
|
|
3307
|
+
}
|
|
3308
|
+
function io(s) {
|
|
3309
|
+
return (s - V.VECTOR_INT2) % 3 + V.INT;
|
|
3310
|
+
}
|
|
3311
|
+
function oo(s) {
|
|
3312
|
+
return ((s - V.VECTOR_INT2) / 3 >> 0) + 2;
|
|
3313
|
+
}
|
|
3314
|
+
function Ur(s, _) {
|
|
3315
|
+
return _ | s << 2;
|
|
3316
|
+
}
|
|
3317
|
+
function Yn(s, _, O) {
|
|
3318
|
+
return O < 2 ? O < 1 ? s.getInt8(_) : s.getInt16(_, !0) : O < 3 ? s.getInt32(_, !0) : s.setBigInt64 === void 0 ? BigInt(s.getUint32(_, !0)) + (BigInt(s.getUint32(_ + 4, !0)) << BigInt(32)) : s.getBigInt64(_, !0);
|
|
3319
|
+
}
|
|
3320
|
+
function me(s, _, O) {
|
|
3321
|
+
return O < 2 ? O < 1 ? s.getUint8(_) : s.getUint16(_, !0) : O < 3 ? s.getUint32(_, !0) : s.getBigUint64 === void 0 ? BigInt(s.getUint32(_, !0)) + (BigInt(s.getUint32(_ + 4, !0)) << BigInt(32)) : s.getBigUint64(_, !0);
|
|
3322
|
+
}
|
|
3323
|
+
function Wr(s, _, O) {
|
|
3324
|
+
if (O < Ee.WIDTH32)
|
|
3325
|
+
throw "Bad width: " + O;
|
|
3326
|
+
return O === Ee.WIDTH32 ? s.getFloat32(_, !0) : s.getFloat64(_, !0);
|
|
3327
|
+
}
|
|
3328
|
+
function ye(s, _, O) {
|
|
3329
|
+
const k = me(s, _, O);
|
|
3330
|
+
return _ - k;
|
|
3331
|
+
}
|
|
3332
|
+
function ao(s, _, O, k, j, N) {
|
|
3333
|
+
const F = eo(s), B = ye(_, O, k) - j * 3, W = de(j), Y = B - Number(me(_, B, W)), Z = Number(me(_, B + j, W));
|
|
3334
|
+
let z = 0, X = N - 1;
|
|
3335
|
+
for (; z <= X; ) {
|
|
3336
|
+
const ce = X + z >> 1, ve = so(F, ce, _, Y, Z);
|
|
3337
|
+
if (ve === 0) return ce;
|
|
3338
|
+
ve < 0 ? X = ce - 1 : z = ce + 1;
|
|
3339
|
+
}
|
|
3340
|
+
return null;
|
|
3341
|
+
}
|
|
3342
|
+
function so(s, _, O, k, j) {
|
|
3343
|
+
const N = k + _ * j, F = N - Number(me(O, N, de(j)));
|
|
3344
|
+
for (let B = 0; B < s.length; B++) {
|
|
3345
|
+
const W = s[B] - O.getUint8(F + B);
|
|
3346
|
+
if (W !== 0)
|
|
3347
|
+
return W;
|
|
3348
|
+
}
|
|
3349
|
+
return O.getUint8(F + s.length) === 0 ? 0 : -1;
|
|
3350
|
+
}
|
|
3351
|
+
function uo(s, _, O, k, j) {
|
|
3352
|
+
const N = ye(_, O, k) - j * 3, F = de(j), B = N - Number(me(_, N, F)), W = Number(me(_, N + j, F)), Y = B + s * W, Z = Y - Number(me(_, Y, de(W)));
|
|
3353
|
+
let z = 0;
|
|
3354
|
+
for (; _.getUint8(Z + z) !== 0; )
|
|
3355
|
+
z++;
|
|
3356
|
+
return Xr(new Uint8Array(_.buffer, Z, z));
|
|
3357
|
+
}
|
|
3358
|
+
function co(s) {
|
|
3359
|
+
const _ = s.byteLength;
|
|
3360
|
+
if (_ < 3)
|
|
3361
|
+
throw "Buffer needs to be bigger than 3";
|
|
3362
|
+
const O = new DataView(s), k = O.getUint8(_ - 1), j = O.getUint8(_ - 2), N = de(k), F = _ - k - 2;
|
|
3363
|
+
return new on(O, F, N, j, "/");
|
|
3364
|
+
}
|
|
3365
|
+
function Vr(s, _, O, k, j, N, F, B) {
|
|
3366
|
+
const W = ye(O, k, j), Y = W + s * N, Z = O.getUint8(W + F * N + s);
|
|
3367
|
+
return new on(O, Y, de(N), Z, `${B}/${_}`);
|
|
3368
|
+
}
|
|
3369
|
+
class on {
|
|
3370
|
+
constructor(_, O, k, j, N) {
|
|
3371
|
+
this.dataView = _, this.offset = O, this.parentWidth = k, this.packedType = j, this.path = N, this._length = -1, this.byteWidth = 1 << (j & 3), this.valueType = j >> 2;
|
|
3372
|
+
}
|
|
3373
|
+
isNull() {
|
|
3374
|
+
return this.valueType === V.NULL;
|
|
3375
|
+
}
|
|
3376
|
+
isNumber() {
|
|
3377
|
+
return to(this.valueType) || no(this.valueType);
|
|
3378
|
+
}
|
|
3379
|
+
isFloat() {
|
|
3380
|
+
return V.FLOAT === this.valueType || V.INDIRECT_FLOAT === this.valueType;
|
|
3381
|
+
}
|
|
3382
|
+
isInt() {
|
|
3383
|
+
return this.isNumber() && !this.isFloat();
|
|
3384
|
+
}
|
|
3385
|
+
isString() {
|
|
3386
|
+
return V.STRING === this.valueType || V.KEY === this.valueType;
|
|
3387
|
+
}
|
|
3388
|
+
isBool() {
|
|
3389
|
+
return V.BOOL === this.valueType;
|
|
3390
|
+
}
|
|
3391
|
+
isBlob() {
|
|
3392
|
+
return V.BLOB === this.valueType;
|
|
3393
|
+
}
|
|
3394
|
+
isVector() {
|
|
3395
|
+
return $n(this.valueType);
|
|
3396
|
+
}
|
|
3397
|
+
isMap() {
|
|
3398
|
+
return V.MAP === this.valueType;
|
|
3399
|
+
}
|
|
3400
|
+
boolValue() {
|
|
3401
|
+
return this.isBool() ? Yn(this.dataView, this.offset, this.parentWidth) > 0 : null;
|
|
3402
|
+
}
|
|
3403
|
+
intValue() {
|
|
3404
|
+
return this.valueType === V.INT ? Yn(this.dataView, this.offset, this.parentWidth) : this.valueType === V.UINT ? me(this.dataView, this.offset, this.parentWidth) : this.valueType === V.INDIRECT_INT ? Yn(this.dataView, ye(this.dataView, this.offset, this.parentWidth), de(this.byteWidth)) : this.valueType === V.INDIRECT_UINT ? me(this.dataView, ye(this.dataView, this.offset, this.parentWidth), de(this.byteWidth)) : null;
|
|
3405
|
+
}
|
|
3406
|
+
floatValue() {
|
|
3407
|
+
return this.valueType === V.FLOAT ? Wr(this.dataView, this.offset, this.parentWidth) : this.valueType === V.INDIRECT_FLOAT ? Wr(this.dataView, ye(this.dataView, this.offset, this.parentWidth), de(this.byteWidth)) : null;
|
|
3408
|
+
}
|
|
3409
|
+
numericValue() {
|
|
3410
|
+
return this.floatValue() || this.intValue();
|
|
3411
|
+
}
|
|
3412
|
+
stringValue() {
|
|
3413
|
+
if (this.valueType === V.STRING || this.valueType === V.KEY) {
|
|
3414
|
+
const _ = ye(this.dataView, this.offset, this.parentWidth);
|
|
3415
|
+
return Xr(new Uint8Array(this.dataView.buffer, _, this.length()));
|
|
3416
|
+
}
|
|
3417
|
+
return null;
|
|
3418
|
+
}
|
|
3419
|
+
blobValue() {
|
|
3420
|
+
if (this.isBlob()) {
|
|
3421
|
+
const _ = ye(this.dataView, this.offset, this.parentWidth);
|
|
3422
|
+
return new Uint8Array(this.dataView.buffer, _, this.length());
|
|
3423
|
+
}
|
|
3424
|
+
return null;
|
|
3425
|
+
}
|
|
3426
|
+
get(_) {
|
|
3427
|
+
const O = this.length();
|
|
3428
|
+
if (Number.isInteger(_) && $n(this.valueType)) {
|
|
3429
|
+
if (_ >= O || _ < 0)
|
|
3430
|
+
throw `Key: [${_}] is not applicable on ${this.path} of ${this.valueType} length: ${O}`;
|
|
3431
|
+
const k = ye(this.dataView, this.offset, this.parentWidth), j = k + _ * this.byteWidth;
|
|
3432
|
+
let N = this.dataView.getUint8(k + O * this.byteWidth + _);
|
|
3433
|
+
if (Jr(this.valueType)) {
|
|
3434
|
+
const F = ro(this.valueType);
|
|
3435
|
+
N = Ur(F, Ee.WIDTH8);
|
|
3436
|
+
} else if (Xn(this.valueType)) {
|
|
3437
|
+
const F = io(this.valueType);
|
|
3438
|
+
N = Ur(F, Ee.WIDTH8);
|
|
3439
|
+
}
|
|
3440
|
+
return new on(this.dataView, j, de(this.byteWidth), N, `${this.path}[${_}]`);
|
|
3441
|
+
}
|
|
3442
|
+
if (typeof _ == "string") {
|
|
3443
|
+
const k = ao(_, this.dataView, this.offset, this.parentWidth, this.byteWidth, O);
|
|
3444
|
+
if (k !== null)
|
|
3445
|
+
return Vr(k, _, this.dataView, this.offset, this.parentWidth, this.byteWidth, O, this.path);
|
|
3446
|
+
}
|
|
3447
|
+
throw `Key [${_}] is not applicable on ${this.path} of ${this.valueType}`;
|
|
3448
|
+
}
|
|
3449
|
+
length() {
|
|
3450
|
+
let _;
|
|
3451
|
+
if (this._length > -1)
|
|
3452
|
+
return this._length;
|
|
3453
|
+
if (Xn(this.valueType))
|
|
3454
|
+
this._length = oo(this.valueType);
|
|
3455
|
+
else if (this.valueType === V.BLOB || this.valueType === V.MAP || $n(this.valueType))
|
|
3456
|
+
this._length = me(this.dataView, ye(this.dataView, this.offset, this.parentWidth) - this.byteWidth, de(this.byteWidth));
|
|
3457
|
+
else if (this.valueType === V.NULL)
|
|
3458
|
+
this._length = 0;
|
|
3459
|
+
else if (this.valueType === V.STRING) {
|
|
3460
|
+
const O = ye(this.dataView, this.offset, this.parentWidth);
|
|
3461
|
+
let k = this.byteWidth;
|
|
3462
|
+
for (_ = me(this.dataView, O - k, de(this.byteWidth)); this.dataView.getInt8(O + _) !== 0; )
|
|
3463
|
+
k <<= 1, _ = me(this.dataView, O - k, de(this.byteWidth));
|
|
3464
|
+
this._length = _;
|
|
3465
|
+
} else if (this.valueType === V.KEY) {
|
|
3466
|
+
const O = ye(this.dataView, this.offset, this.parentWidth);
|
|
3467
|
+
for (_ = 1; this.dataView.getInt8(O + _) !== 0; )
|
|
3468
|
+
_++;
|
|
3469
|
+
this._length = _;
|
|
3470
|
+
} else
|
|
3471
|
+
this._length = 1;
|
|
3472
|
+
return Number(this._length);
|
|
3473
|
+
}
|
|
3474
|
+
toObject() {
|
|
3475
|
+
const _ = this.length();
|
|
3476
|
+
if (this.isVector()) {
|
|
3477
|
+
const O = [];
|
|
3478
|
+
for (let k = 0; k < _; k++)
|
|
3479
|
+
O.push(this.get(k).toObject());
|
|
3480
|
+
return O;
|
|
3481
|
+
}
|
|
3482
|
+
if (this.isMap()) {
|
|
3483
|
+
const O = {};
|
|
3484
|
+
for (let k = 0; k < _; k++) {
|
|
3485
|
+
const j = uo(k, this.dataView, this.offset, this.parentWidth, this.byteWidth);
|
|
3486
|
+
O[j] = Vr(k, j, this.dataView, this.offset, this.parentWidth, this.byteWidth, _, this.path).toObject();
|
|
3487
|
+
}
|
|
3488
|
+
return O;
|
|
3489
|
+
}
|
|
3490
|
+
return this.isNull() ? null : this.isBool() ? this.boolValue() : this.isNumber() ? this.numericValue() : this.blobValue() || this.stringValue();
|
|
3491
|
+
}
|
|
3492
|
+
}
|
|
3493
|
+
class lo extends rn {
|
|
3494
|
+
settings;
|
|
3495
|
+
meta;
|
|
3496
|
+
i18n;
|
|
3497
|
+
htmlservers;
|
|
3498
|
+
servers;
|
|
3499
|
+
tags;
|
|
3500
|
+
profiles;
|
|
3501
|
+
ws_messages;
|
|
3502
|
+
constructor() {
|
|
3503
|
+
super("AppStorage"), this.version(3).stores({
|
|
3504
|
+
settings: "&id",
|
|
3505
|
+
meta: "&key",
|
|
3506
|
+
i18n: "&key",
|
|
3507
|
+
htmlservers: "&key",
|
|
3508
|
+
servers: "&server_id",
|
|
3509
|
+
tags: "&tag_id",
|
|
3510
|
+
profiles: "&profile_id",
|
|
3511
|
+
ws_messages: "&key"
|
|
3512
|
+
});
|
|
3513
|
+
}
|
|
3514
|
+
}
|
|
3515
|
+
const Q = new lo();
|
|
3516
|
+
function fo(s) {
|
|
3517
|
+
return `
|
|
3518
|
+
<div class="flex flex-col gap-2 p-2">
|
|
3519
|
+
<img src="${s.logo}" alt="${s.name}" class="w-12 h-12 rounded-full" />
|
|
3520
|
+
<h3 class="text-lg font-bold">${s.name}</h3>
|
|
3521
|
+
<p class="text-sm opacity-70">${s.summary}</p>
|
|
3522
|
+
<a href="${s.invite}" class="text-purple-400 underline text-xs">Join Join Join</a>
|
|
3523
|
+
</div>
|
|
3524
|
+
`.trim();
|
|
3525
|
+
}
|
|
3526
|
+
const Zt = {
|
|
3527
|
+
// WebSocket
|
|
3528
|
+
async storeWsMessage(s, _) {
|
|
3529
|
+
const O = co(_).toObject();
|
|
3530
|
+
await Q.ws_messages.put({ key: s, message: O });
|
|
3531
|
+
},
|
|
3532
|
+
async getWsMessage(s) {
|
|
3533
|
+
return (await Q.ws_messages.get(s))?.message ?? null;
|
|
3534
|
+
},
|
|
3535
|
+
async getAllWsMessages() {
|
|
3536
|
+
return (await Q.ws_messages.toArray()).sort((_, O) => {
|
|
3537
|
+
const k = Number(_.key.split(":")[1]);
|
|
3538
|
+
return Number(O.key.split(":")[1]) - k;
|
|
3539
|
+
});
|
|
3540
|
+
},
|
|
3541
|
+
async clearWsMessages() {
|
|
3542
|
+
await Q.ws_messages.clear();
|
|
3543
|
+
},
|
|
3544
|
+
// I18n
|
|
3545
|
+
async getTranslation(s) {
|
|
3546
|
+
return (await Q.i18n.get(s))?.value ?? null;
|
|
3547
|
+
},
|
|
3548
|
+
async getTranslations(s) {
|
|
3549
|
+
const _ = {};
|
|
3550
|
+
for (const O of s) {
|
|
3551
|
+
const k = await Q.i18n.get(O);
|
|
3552
|
+
k && (_[O] = k.value);
|
|
3553
|
+
}
|
|
3554
|
+
return _;
|
|
3555
|
+
},
|
|
3556
|
+
async putI18nBatch(s) {
|
|
3557
|
+
const _ = Object.entries(s).map(([O, k]) => ({
|
|
3558
|
+
key: O,
|
|
3559
|
+
value: k
|
|
3560
|
+
}));
|
|
3561
|
+
await Q.i18n.bulkPut(_);
|
|
3562
|
+
},
|
|
3563
|
+
async loadI18nFromJSON(s = "https://discord.sh/i18n/db.json") {
|
|
3564
|
+
const O = await (await fetch(s)).json();
|
|
3565
|
+
await Zt.putI18nBatch(O);
|
|
3566
|
+
},
|
|
3567
|
+
async getAllI18nKeys() {
|
|
3568
|
+
return await Q.i18n.toCollection().primaryKeys();
|
|
3569
|
+
},
|
|
3570
|
+
async loadServersFromJSON(s = "https://discord.sh/data/servers.json") {
|
|
3571
|
+
const O = await (await fetch(s)).json(), k = Object.values(O);
|
|
3572
|
+
await Zt.putServers(k), await Zt.syncHtmlFromServers();
|
|
3573
|
+
},
|
|
3574
|
+
// HTML PreRender
|
|
3575
|
+
async syncHtmlFromServers() {
|
|
3576
|
+
const s = await Q.servers.toArray(), _ = await Q.htmlservers.toCollection().primaryKeys(), O = [];
|
|
3577
|
+
for (const k of s)
|
|
3578
|
+
if (!_.includes(k.server_id)) {
|
|
3579
|
+
const j = fo(k);
|
|
3580
|
+
O.push({ key: k.server_id, value: j });
|
|
3581
|
+
}
|
|
3582
|
+
O.length > 0 ? (await Q.htmlservers.bulkPut(O), console.info(`[syncHtmlFromServers] Generated ${O.length} HTML cards.`)) : console.info("[syncHtmlFromServers] All servers already have HTML cards.");
|
|
3583
|
+
},
|
|
3584
|
+
// Settings
|
|
3585
|
+
async dbSet(s, _) {
|
|
3586
|
+
await Q.settings.put({ id: s, value: _ });
|
|
3587
|
+
},
|
|
3588
|
+
async dbGet(s) {
|
|
3589
|
+
return (await Q.settings.get(s))?.value ?? null;
|
|
3590
|
+
},
|
|
3591
|
+
async dbClear() {
|
|
3592
|
+
await Q.settings.clear();
|
|
3593
|
+
},
|
|
3594
|
+
// Meta
|
|
3595
|
+
async setVersion(s) {
|
|
3596
|
+
await Q.meta.put({ key: "version", value: s });
|
|
3597
|
+
},
|
|
3598
|
+
async getVersion() {
|
|
3599
|
+
return (await Q.meta.get("version"))?.value ?? null;
|
|
3600
|
+
},
|
|
3601
|
+
async markSeeded() {
|
|
3602
|
+
await Q.meta.put({ key: "db_seeded", value: !0 });
|
|
3603
|
+
},
|
|
3604
|
+
async checkSeeded() {
|
|
3605
|
+
return (await Q.meta.get("db_seeded"))?.value === !0;
|
|
3606
|
+
},
|
|
3607
|
+
// Servers
|
|
3608
|
+
async putServers(s) {
|
|
3609
|
+
await Q.servers.bulkPut(s);
|
|
3610
|
+
},
|
|
3611
|
+
async getAllServers() {
|
|
3612
|
+
return await Q.servers.toArray();
|
|
3613
|
+
},
|
|
3614
|
+
// HTML servers
|
|
3615
|
+
async putHtmlCards(s) {
|
|
3616
|
+
await Q.htmlservers.bulkPut(s);
|
|
3617
|
+
},
|
|
3618
|
+
async getHtmlCard(s) {
|
|
3619
|
+
return (await Q.htmlservers.get(s))?.value ?? null;
|
|
3620
|
+
},
|
|
3621
|
+
// Tags
|
|
3622
|
+
async putTags(s) {
|
|
3623
|
+
await Q.tags.bulkPut(s);
|
|
3624
|
+
},
|
|
3625
|
+
async getAllTags() {
|
|
3626
|
+
return await Q.tags.toArray();
|
|
3627
|
+
},
|
|
3628
|
+
// Profiles
|
|
3629
|
+
async putProfiles(s) {
|
|
3630
|
+
await Q.profiles.bulkPut(s);
|
|
3631
|
+
},
|
|
3632
|
+
async getAllProfiles() {
|
|
3633
|
+
return await Q.profiles.toArray();
|
|
3634
|
+
}
|
|
3635
|
+
};
|
|
3636
|
+
self.onconnect = (s) => {
|
|
3637
|
+
const _ = s.ports[0];
|
|
3638
|
+
_.start(), Jn(Zt, _);
|
|
3639
|
+
};
|