@nylas/react 1.0.0-prealpha1
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/LICENSE.md +22 -0
- package/README.md +3 -0
- package/dist/_commonjsHelpers-57e89916-4a3ae7d8.cjs +1 -0
- package/dist/_commonjsHelpers-57e89916-af061c86.js +19 -0
- package/dist/archive-icon_7.entry-53aede1b.js +75 -0
- package/dist/archive-icon_7.entry-8c90815a.cjs +1 -0
- package/dist/arrow-icon.entry-2867f4fb.js +15 -0
- package/dist/arrow-icon.entry-a2f53919.cjs +1 -0
- package/dist/bold-icon_3.entry-ad806730.js +35 -0
- package/dist/bold-icon_3.entry-e0bc6774.cjs +1 -0
- package/dist/calendar-cancel-icon.entry-546b7bd4.cjs +1 -0
- package/dist/calendar-cancel-icon.entry-74051835.js +15 -0
- package/dist/calendar-check-icon_3.entry-42bab0b4.js +35 -0
- package/dist/calendar-check-icon_3.entry-f5846fee.cjs +1 -0
- package/dist/calendar-icon.entry-25474b1e.cjs +1 -0
- package/dist/calendar-icon.entry-c751873f.js +15 -0
- package/dist/chevron-icon.entry-60842fb6.js +15 -0
- package/dist/chevron-icon.entry-97e4621e.cjs +1 -0
- package/dist/close-icon_2.entry-aa015993.cjs +1 -0
- package/dist/close-icon_2.entry-ef03bd27.js +25 -0
- package/dist/core-js-38e53e34.cjs +4 -0
- package/dist/core-js-a9d3b6e1.js +3297 -0
- package/dist/document-refresh-icon.entry-b27207eb.js +15 -0
- package/dist/document-refresh-icon.entry-ca2ef29e.cjs +1 -0
- package/dist/dom-68f08be9.cjs +15 -0
- package/dist/dom-86e17616.js +664 -0
- package/dist/duration-bddc4a13-05d3e3e2.cjs +1 -0
- package/dist/duration-bddc4a13-179ce826.js +41 -0
- package/dist/elements/index.d.ts +56 -0
- package/dist/elements/react-component-lib/createComponent.d.ts +10 -0
- package/dist/elements/react-component-lib/createOverlayComponent.d.ts +21 -0
- package/dist/elements/react-component-lib/index.d.ts +2 -0
- package/dist/elements/react-component-lib/interfaces.d.ts +29 -0
- package/dist/elements/react-component-lib/utils/attachProps.d.ts +9 -0
- package/dist/elements/react-component-lib/utils/case.d.ts +2 -0
- package/dist/elements/react-component-lib/utils/dev.d.ts +2 -0
- package/dist/elements/react-component-lib/utils/index.d.ts +10 -0
- package/dist/elements-60ebdb01-24595598.cjs +16494 -0
- package/dist/elements-60ebdb01-5d144002.js +27455 -0
- package/dist/flow-40ff9cea-6f8c30e2.cjs +9 -0
- package/dist/flow-40ff9cea-ee70fdf5.js +505 -0
- package/dist/focus-visible-e8093c16-28fc08a0.js +82 -0
- package/dist/focus-visible-e8093c16-f380b705.cjs +1 -0
- package/dist/forward-icon_6.entry-725d1be4.cjs +3 -0
- package/dist/forward-icon_6.entry-dc8f7235.js +955 -0
- package/dist/globe-icon.entry-796d3f48.js +15 -0
- package/dist/globe-icon.entry-918cfd35.cjs +1 -0
- package/dist/index-29d0e781.cjs +30 -0
- package/dist/index-2b85580a-bfc3ceac.cjs +7 -0
- package/dist/index-2b85580a-f9211f23.js +3238 -0
- package/dist/index-4f65b6f9.js +1489 -0
- package/dist/index.d.ts +4 -0
- package/dist/loading-icon.entry-8e49fab0.js +15 -0
- package/dist/loading-icon.entry-b2534e3e.cjs +1 -0
- package/dist/mailbox-store-0019772c-06d31a90.js +380 -0
- package/dist/mailbox-store-0019772c-d1254c5c.cjs +1 -0
- package/dist/nylas-booked-event-card_9.entry-d995d7cb.js +4567 -0
- package/dist/nylas-booked-event-card_9.entry-ea02f083.cjs +148 -0
- package/dist/nylas-if-state_3.entry-ce816adb.js +291 -0
- package/dist/nylas-if-state_3.entry-e8c831b7.cjs +1 -0
- package/dist/nylas-list-folders.entry-8134344b.js +121 -0
- package/dist/nylas-list-folders.entry-de8cca60.cjs +1 -0
- package/dist/nylas-list-threads.entry-1367fe30.js +71 -0
- package/dist/nylas-list-threads.entry-93b70a1a.cjs +1 -0
- package/dist/nylas-mailbox-pagination.entry-568ac217.js +102 -0
- package/dist/nylas-mailbox-pagination.entry-6bb0ee37.cjs +1 -0
- package/dist/nylas-mailbox-toolbar-button.entry-9214b283.js +83 -0
- package/dist/nylas-mailbox-toolbar-button.entry-d4ad5c15.cjs +1 -0
- package/dist/nylas-open-hours-picker.entry-109f13f5.js +186 -0
- package/dist/nylas-open-hours-picker.entry-2c19643f.cjs +1 -0
- package/dist/nylas-provider.entry-2cfe5f0e.js +134 -0
- package/dist/nylas-provider.entry-87fa9276.cjs +1 -0
- package/dist/nylas-scheduler.entry-6ec8e574.js +195 -0
- package/dist/nylas-scheduler.entry-b41cbf99.cjs +1 -0
- package/dist/nylas-threads-refresh.entry-6d61a689.cjs +1 -0
- package/dist/nylas-threads-refresh.entry-9111a403.js +75 -0
- package/dist/nylas-threads-search.entry-03073490.cjs +1 -0
- package/dist/nylas-threads-search.entry-2124f663.js +70 -0
- package/dist/nylas-view-thread.entry-4ecbcd78.cjs +1 -0
- package/dist/nylas-view-thread.entry-fe51c1f6.js +204 -0
- package/dist/play-icon_2.entry-8e156535.js +25 -0
- package/dist/play-icon_2.entry-cf1cbc8d.cjs +1 -0
- package/dist/property-0065dde7-83dc9cc4.cjs +23 -0
- package/dist/property-0065dde7-c57b8fa3.js +589 -0
- package/dist/react.cjs +1 -0
- package/dist/react.js +62 -0
- package/dist/refresh-icon.entry-4ddd53b0.js +15 -0
- package/dist/refresh-icon.entry-9f24e833.cjs +1 -0
- package/dist/register-component-55376f31-5eaf8954.js +105 -0
- package/dist/register-component-55376f31-8d6ddee4.cjs +1 -0
- package/dist/scheduler-store-5a39585a-117668e3.js +173 -0
- package/dist/scheduler-store-5a39585a-2c848bec.cjs +1 -0
- package/dist/translate-icon.entry-0cd24de4.cjs +1 -0
- package/dist/translate-icon.entry-db2cdf1d.js +15 -0
- package/dist/utils-5074a070-ce33ee6b.js +119 -0
- package/dist/utils-5074a070-d5ba6add.cjs +2 -0
- package/package.json +47 -0
|
@@ -0,0 +1,3238 @@
|
|
|
1
|
+
import { d as T, u as or, e as dn } from "./utils-5074a070-ce33ee6b.js";
|
|
2
|
+
import { a as fn, f as pn } from "./index-4f65b6f9.js";
|
|
3
|
+
class ar {
|
|
4
|
+
constructor(e, n, r = !0, s) {
|
|
5
|
+
this.automaticComponentRegistration = !0, this.registeredComponents = {}, this.propStateRegistrations = /* @__PURE__ */ new Map(), this.eventListenerRegistrations = /* @__PURE__ */ new Map(), this.host = e, this.stores = n, this.automaticComponentRegistration = r, this.eventOverrides = s, T(`[${this.hostTagName}] Initializing (abstract) provider.`, { eventOverrides: s }), this.registerComponent = this.registerComponent.bind(this), this.getStore = this.getStore.bind(this), Object.keys(this.stores).forEach((i) => {
|
|
6
|
+
this.propStateRegistrations.set(i, /* @__PURE__ */ new Map());
|
|
7
|
+
});
|
|
8
|
+
}
|
|
9
|
+
async componentWillLoad(e) {
|
|
10
|
+
T(`[${this.hostTagName}] Will load`), this.setupStoreListeners(), this.nylasConnector = e;
|
|
11
|
+
const n = Array.from(this.host.querySelectorAll("*")).filter((r) => r.tagName.toLowerCase().startsWith("nylas-"));
|
|
12
|
+
T(`[${this.hostTagName}] Found ${n.length} child component(s).`, { childComponents: n }), n.forEach((r) => {
|
|
13
|
+
const s = r;
|
|
14
|
+
if (!s) {
|
|
15
|
+
T(`[~${this.hostTagName}] Component ${s.tagName} does not have a name. Skipping.`);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (!s.registerNylasComponent) {
|
|
19
|
+
T(`[~${this.hostTagName}] Component ${s.tagName} is not a component that can be registered. Skipping.`, { component: s });
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
const i = {
|
|
23
|
+
element: s,
|
|
24
|
+
name: s.tagName.toLowerCase(),
|
|
25
|
+
getStoresToProp: s.getStoresToProp,
|
|
26
|
+
storeToProps: s.storeToProps,
|
|
27
|
+
stateToProps: s.stateToProps,
|
|
28
|
+
authToProp: s.authToProp,
|
|
29
|
+
eventToProps: s.eventToProps,
|
|
30
|
+
connectorToProp: s.connectorToProp
|
|
31
|
+
};
|
|
32
|
+
this.registerComponent(i);
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
async componentDidLoad() {
|
|
36
|
+
T(`[${this.hostTagName}] Did load`);
|
|
37
|
+
}
|
|
38
|
+
async componentDisconnected() {
|
|
39
|
+
Object.values(this.stores).forEach((e) => {
|
|
40
|
+
e.dispose();
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async registerComponentHandler(e) {
|
|
44
|
+
if (e.stopPropagation(), !this.automaticComponentRegistration) {
|
|
45
|
+
T(`[${this.hostTagName}] Automatic component registration disabled. Skipping registration of ${e.detail.name}.`);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
this.registerComponent(e.detail);
|
|
49
|
+
}
|
|
50
|
+
async unregisterComponentHandler(e) {
|
|
51
|
+
if (e.stopPropagation(), !this.automaticComponentRegistration) {
|
|
52
|
+
T(`[${this.hostTagName}] Automatic component registration disabled. Skipping unregistration of ${e.detail.name}.`);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
this.unregisterComponent(e.detail);
|
|
56
|
+
}
|
|
57
|
+
registerComponent(e) {
|
|
58
|
+
T(`[${this.hostTagName}] Registering component ${e.name}.`);
|
|
59
|
+
const n = e.element.dataset.nylasId;
|
|
60
|
+
if (n && this.registeredComponents[n]) {
|
|
61
|
+
T(`[${this.hostTagName}] Component ${e.name} already registered. Skipping.`);
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const { stateToProps: r, getStoresToProp: s, eventToProps: i, storeToProps: o, connectorToProp: u, element: a } = e;
|
|
65
|
+
a.dataset.nylasId = or(), this.registeredComponents[a.dataset.nylasId] = e;
|
|
66
|
+
const l = this.eventOverrides;
|
|
67
|
+
i == null || i.forEach((h, c) => {
|
|
68
|
+
var y;
|
|
69
|
+
const d = this.nylasConnector, m = async (g) => {
|
|
70
|
+
T(`[${this.hostTagName}] Handling "${e.name}" prop "${String(c)}" event.`, { eventOverrides: l }), c in l && (T(`[${this.hostTagName}] Found event override for "${String(c)}" event. Calling override.`), await l[c](g, d)), g.defaultPrevented || await h(g, d);
|
|
71
|
+
}, p = e.element.dataset.nylasId;
|
|
72
|
+
p && !this.eventListenerRegistrations.has(p) && this.eventListenerRegistrations.set(p, []), p && ((y = this.eventListenerRegistrations.get(p)) == null || y.push([a, c, m])), T(`[${this.hostTagName}] Setting "${e.name}" event "${String(c)}" to automcially call NylasConnector method.`);
|
|
73
|
+
const f = dn(c.toString());
|
|
74
|
+
T(`[${this.hostTagName}] Adding event listener for "${f}" on "${a.tagName}"`), a.addEventListener(f, m);
|
|
75
|
+
}), r == null || r.forEach((h, c) => {
|
|
76
|
+
var y, g, v, b;
|
|
77
|
+
const [d, m] = c.split("."), f = this.getStore(d).state[m];
|
|
78
|
+
if (!a.dataset.nylasId) {
|
|
79
|
+
T(`[${this.hostTagName}] Component "${e.name}" not registered. Skipping.`, { component: e });
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
this.propStateRegistrations.has(d) || this.propStateRegistrations.set(d, /* @__PURE__ */ new Map()), (y = this.propStateRegistrations.get(d)) != null && y.has(m) ? (b = (v = this.propStateRegistrations.get(d)) == null ? void 0 : v.get(m)) == null || b.push({
|
|
83
|
+
elementId: a.dataset.nylasId,
|
|
84
|
+
propKey: h
|
|
85
|
+
}) : (g = this.propStateRegistrations.get(d)) == null || g.set(m, [
|
|
86
|
+
{
|
|
87
|
+
elementId: a.dataset.nylasId,
|
|
88
|
+
propKey: h
|
|
89
|
+
}
|
|
90
|
+
]), a[h.toString()] = f, T(`[${this.hostTagName}] Setting "${e.name}" prop "${h.toString()}" to "${c}" value.`, { stateValue: f });
|
|
91
|
+
}), s && (a[s == null ? void 0 : s.toString()] = this.getStore, T(`[${this.hostTagName}] Setting "${e.name}" prop "${s.toString()}" to "getStore" method.`)), o == null || o.forEach((h, c) => {
|
|
92
|
+
const d = this.getStore(c);
|
|
93
|
+
a[h.toString()] = d, T(`[${this.hostTagName}] Setting "${e.name}" prop "${h.toString()}" to "${c}" store.`, { store: d });
|
|
94
|
+
}), u && (a[u == null ? void 0 : u.toString()] = this.nylasConnector, T(`[${this.hostTagName}] Setting "${e.name}" prop "${u.toString()}" to "nylasConnector" value.`, { connectorToProp: u })), T(`[${this.hostTagName}] Component ${e.name} registered.`);
|
|
95
|
+
}
|
|
96
|
+
unregisterComponent(e) {
|
|
97
|
+
T(`[${this.hostTagName}] Unregistering component ${e.name}.`);
|
|
98
|
+
const n = e.element.dataset.nylasId;
|
|
99
|
+
if (!n) {
|
|
100
|
+
T(`[${this.hostTagName}] Component ${e.name} not registered. Skipping.`);
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
if (this.registeredComponents[n]) {
|
|
104
|
+
T(`[${this.hostTagName}] Component ${e.name} not registered. Skipping.`);
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
this.propStateRegistrations.forEach((s, i) => {
|
|
108
|
+
s.forEach((o, u) => {
|
|
109
|
+
var h, c;
|
|
110
|
+
const a = (h = this.propStateRegistrations.get(i)) == null ? void 0 : h.get(u), l = a == null ? void 0 : a.filter((d) => d.elementId !== n);
|
|
111
|
+
l && ((c = this.propStateRegistrations.get(i)) == null || c.set(u, l));
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
const r = this.eventListenerRegistrations.get(n);
|
|
115
|
+
r == null || r.forEach(([s, i, o]) => {
|
|
116
|
+
const u = dn(i.toString());
|
|
117
|
+
T(`[${this.hostTagName}] Removing event listener for "${u}" on "${s.tagName}"`), s.removeEventListener(u, o);
|
|
118
|
+
}), delete this.registeredComponents[n];
|
|
119
|
+
}
|
|
120
|
+
getStore(e) {
|
|
121
|
+
const n = this.stores[e];
|
|
122
|
+
if (!n)
|
|
123
|
+
throw new Error(`[${this.hostTagName}] Store "${e.toString()}" not found.`);
|
|
124
|
+
return n;
|
|
125
|
+
}
|
|
126
|
+
async setupStoreListeners() {
|
|
127
|
+
const e = this;
|
|
128
|
+
Object.entries(this.stores).forEach(([n, r]) => {
|
|
129
|
+
T(`[${e.hostTagName}] Listening for changes in "${n}" store.`), r.use({
|
|
130
|
+
set(s, i, o) {
|
|
131
|
+
var l;
|
|
132
|
+
if (T(`[${e.hostTagName}] Store "${n}" state "${s.toString()}" changed`, { newValue: i, oldValue: o }), i === o) {
|
|
133
|
+
T(`[${e.hostTagName}] Store "${n}" state "${s.toString()}" unchanged. Skipping.`);
|
|
134
|
+
return;
|
|
135
|
+
}
|
|
136
|
+
const u = e.registeredComponents;
|
|
137
|
+
if (!u) {
|
|
138
|
+
T(`[${e.hostTagName}] No registered components found. Skipping.`);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
const a = ((l = e.propStateRegistrations.get(n)) == null ? void 0 : l.get(s.toString())) || [];
|
|
142
|
+
T(`[${e.hostTagName}] Found ${a.length} prop(s) registered for "${s.toString()}" store.`, {
|
|
143
|
+
props: a,
|
|
144
|
+
propStateRegistrations: e.propStateRegistrations
|
|
145
|
+
}), a.forEach(({ elementId: h, propKey: c }) => {
|
|
146
|
+
const d = u[h];
|
|
147
|
+
if (!d) {
|
|
148
|
+
T(`[${e.hostTagName}] Component "${h}" not found. Skipping.`, { component: d });
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
const p = e.getStore(n).state[s];
|
|
152
|
+
d.element[c.toString()] = p, T(`[${e.hostTagName}] Setting "${d.name}" prop "${c.toString()}" to "${s.toString()}" value.`, { stateValue: p });
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
get hostTagName() {
|
|
159
|
+
var e, n;
|
|
160
|
+
return ((n = (e = this.host) == null ? void 0 : e.tagName) == null ? void 0 : n.toLowerCase()) ?? "nylas-provider";
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
class ds extends ar {
|
|
164
|
+
}
|
|
165
|
+
var ur = Object.defineProperty, cr = (t, e, n) => e in t ? ur(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, ut = (t, e, n) => (cr(t, typeof e != "symbol" ? e + "" : e, n), n), lr = /* @__PURE__ */ ((t) => (t.Error = "error", t.Warning = "warning", t.Info = "info", t.Success = "success", t))(lr || {});
|
|
166
|
+
const fs = (t) => "error" in t;
|
|
167
|
+
class ps extends Error {
|
|
168
|
+
constructor(e) {
|
|
169
|
+
super(e == null ? void 0 : e.message), ut(this, "apiError"), this.name = "NylasAPIError", this.stack = new Error().stack, this.apiError = e;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
async function mn(t) {
|
|
173
|
+
const e = new TextEncoder().encode(t), n = await crypto.subtle.digest("SHA-256", e), r = Array.from(new Uint8Array(n)).map((s) => s.toString(16).padStart(2, "0")).join("");
|
|
174
|
+
return btoa(r).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
175
|
+
}
|
|
176
|
+
const K = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : global, $ = Object.keys, F = Array.isArray;
|
|
177
|
+
function U(t, e) {
|
|
178
|
+
return typeof e != "object" || $(e).forEach(function(n) {
|
|
179
|
+
t[n] = e[n];
|
|
180
|
+
}), t;
|
|
181
|
+
}
|
|
182
|
+
typeof Promise > "u" || K.Promise || (K.Promise = Promise);
|
|
183
|
+
const Be = Object.getPrototypeOf, hr = {}.hasOwnProperty;
|
|
184
|
+
function z(t, e) {
|
|
185
|
+
return hr.call(t, e);
|
|
186
|
+
}
|
|
187
|
+
function Ee(t, e) {
|
|
188
|
+
typeof e == "function" && (e = e(Be(t))), (typeof Reflect > "u" ? $ : Reflect.ownKeys)(e).forEach((n) => {
|
|
189
|
+
ee(t, n, e[n]);
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
const An = Object.defineProperty;
|
|
193
|
+
function ee(t, e, n, r) {
|
|
194
|
+
An(t, e, U(n && z(n, "get") && typeof n.get == "function" ? { get: n.get, set: n.set, configurable: !0 } : { value: n, configurable: !0, writable: !0 }, r));
|
|
195
|
+
}
|
|
196
|
+
function ke(t) {
|
|
197
|
+
return { from: function(e) {
|
|
198
|
+
return t.prototype = Object.create(e.prototype), ee(t.prototype, "constructor", t), { extend: Ee.bind(null, t.prototype) };
|
|
199
|
+
} };
|
|
200
|
+
}
|
|
201
|
+
const dr = Object.getOwnPropertyDescriptor;
|
|
202
|
+
function Zt(t, e) {
|
|
203
|
+
let n;
|
|
204
|
+
return dr(t, e) || (n = Be(t)) && Zt(n, e);
|
|
205
|
+
}
|
|
206
|
+
const fr = [].slice;
|
|
207
|
+
function ct(t, e, n) {
|
|
208
|
+
return fr.call(t, e, n);
|
|
209
|
+
}
|
|
210
|
+
function On(t, e) {
|
|
211
|
+
return e(t);
|
|
212
|
+
}
|
|
213
|
+
function Ie(t) {
|
|
214
|
+
if (!t)
|
|
215
|
+
throw new Error("Assertion Failed");
|
|
216
|
+
}
|
|
217
|
+
function In(t) {
|
|
218
|
+
K.setImmediate ? setImmediate(t) : setTimeout(t, 0);
|
|
219
|
+
}
|
|
220
|
+
function Kn(t, e) {
|
|
221
|
+
return t.reduce((n, r, s) => {
|
|
222
|
+
var i = e(r, s);
|
|
223
|
+
return i && (n[i[0]] = i[1]), n;
|
|
224
|
+
}, {});
|
|
225
|
+
}
|
|
226
|
+
function te(t, e) {
|
|
227
|
+
if (z(t, e))
|
|
228
|
+
return t[e];
|
|
229
|
+
if (!e)
|
|
230
|
+
return t;
|
|
231
|
+
if (typeof e != "string") {
|
|
232
|
+
for (var n = [], r = 0, s = e.length; r < s; ++r) {
|
|
233
|
+
var i = te(t, e[r]);
|
|
234
|
+
n.push(i);
|
|
235
|
+
}
|
|
236
|
+
return n;
|
|
237
|
+
}
|
|
238
|
+
var o = e.indexOf(".");
|
|
239
|
+
if (o !== -1) {
|
|
240
|
+
var u = t[e.substr(0, o)];
|
|
241
|
+
return u === void 0 ? void 0 : te(u, e.substr(o + 1));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
function H(t, e, n) {
|
|
245
|
+
if (t && e !== void 0 && (!("isFrozen" in Object) || !Object.isFrozen(t)))
|
|
246
|
+
if (typeof e != "string" && "length" in e) {
|
|
247
|
+
Ie(typeof n != "string" && "length" in n);
|
|
248
|
+
for (var r = 0, s = e.length; r < s; ++r)
|
|
249
|
+
H(t, e[r], n[r]);
|
|
250
|
+
} else {
|
|
251
|
+
var i = e.indexOf(".");
|
|
252
|
+
if (i !== -1) {
|
|
253
|
+
var o = e.substr(0, i), u = e.substr(i + 1);
|
|
254
|
+
if (u === "")
|
|
255
|
+
n === void 0 ? F(t) && !isNaN(parseInt(o)) ? t.splice(o, 1) : delete t[o] : t[o] = n;
|
|
256
|
+
else {
|
|
257
|
+
var a = t[o];
|
|
258
|
+
a && z(t, o) || (a = t[o] = {}), H(a, u, n);
|
|
259
|
+
}
|
|
260
|
+
} else
|
|
261
|
+
n === void 0 ? F(t) && !isNaN(parseInt(e)) ? t.splice(e, 1) : delete t[e] : t[e] = n;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
function Rn(t) {
|
|
265
|
+
var e = {};
|
|
266
|
+
for (var n in t)
|
|
267
|
+
z(t, n) && (e[n] = t[n]);
|
|
268
|
+
return e;
|
|
269
|
+
}
|
|
270
|
+
const pr = [].concat;
|
|
271
|
+
function jn(t) {
|
|
272
|
+
return pr.apply([], t);
|
|
273
|
+
}
|
|
274
|
+
const Dn = "Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(jn([8, 16, 32, 64].map((t) => ["Int", "Uint", "Float"].map((e) => e + t + "Array")))).filter((t) => K[t]), mr = Dn.map((t) => K[t]);
|
|
275
|
+
Kn(Dn, (t) => [t, !0]);
|
|
276
|
+
let se = null;
|
|
277
|
+
function We(t) {
|
|
278
|
+
se = typeof WeakMap < "u" && /* @__PURE__ */ new WeakMap();
|
|
279
|
+
const e = Tt(t);
|
|
280
|
+
return se = null, e;
|
|
281
|
+
}
|
|
282
|
+
function Tt(t) {
|
|
283
|
+
if (!t || typeof t != "object")
|
|
284
|
+
return t;
|
|
285
|
+
let e = se && se.get(t);
|
|
286
|
+
if (e)
|
|
287
|
+
return e;
|
|
288
|
+
if (F(t)) {
|
|
289
|
+
e = [], se && se.set(t, e);
|
|
290
|
+
for (var n = 0, r = t.length; n < r; ++n)
|
|
291
|
+
e.push(Tt(t[n]));
|
|
292
|
+
} else if (mr.indexOf(t.constructor) >= 0)
|
|
293
|
+
e = t;
|
|
294
|
+
else {
|
|
295
|
+
const i = Be(t);
|
|
296
|
+
for (var s in e = i === Object.prototype ? {} : Object.create(i), se && se.set(t, e), t)
|
|
297
|
+
z(t, s) && (e[s] = Tt(t[s]));
|
|
298
|
+
}
|
|
299
|
+
return e;
|
|
300
|
+
}
|
|
301
|
+
const { toString: gr } = {};
|
|
302
|
+
function At(t) {
|
|
303
|
+
return gr.call(t).slice(8, -1);
|
|
304
|
+
}
|
|
305
|
+
const Ot = typeof Symbol < "u" ? Symbol.iterator : "@@iterator", yr = typeof Ot == "symbol" ? function(t) {
|
|
306
|
+
var e;
|
|
307
|
+
return t != null && (e = t[Ot]) && e.apply(t);
|
|
308
|
+
} : function() {
|
|
309
|
+
return null;
|
|
310
|
+
}, _e = {};
|
|
311
|
+
function J(t) {
|
|
312
|
+
var e, n, r, s;
|
|
313
|
+
if (arguments.length === 1) {
|
|
314
|
+
if (F(t))
|
|
315
|
+
return t.slice();
|
|
316
|
+
if (this === _e && typeof t == "string")
|
|
317
|
+
return [t];
|
|
318
|
+
if (s = yr(t)) {
|
|
319
|
+
for (n = []; !(r = s.next()).done; )
|
|
320
|
+
n.push(r.value);
|
|
321
|
+
return n;
|
|
322
|
+
}
|
|
323
|
+
if (t == null)
|
|
324
|
+
return [t];
|
|
325
|
+
if (typeof (e = t.length) == "number") {
|
|
326
|
+
for (n = new Array(e); e--; )
|
|
327
|
+
n[e] = t[e];
|
|
328
|
+
return n;
|
|
329
|
+
}
|
|
330
|
+
return [t];
|
|
331
|
+
}
|
|
332
|
+
for (e = arguments.length, n = new Array(e); e--; )
|
|
333
|
+
n[e] = arguments[e];
|
|
334
|
+
return n;
|
|
335
|
+
}
|
|
336
|
+
const en = typeof Symbol < "u" ? (t) => t[Symbol.toStringTag] === "AsyncFunction" : () => !1;
|
|
337
|
+
var G = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
|
|
338
|
+
function $n(t, e) {
|
|
339
|
+
G = t, Nn = e;
|
|
340
|
+
}
|
|
341
|
+
var Nn = () => !0;
|
|
342
|
+
const vr = !new Error("").stack;
|
|
343
|
+
function Pe() {
|
|
344
|
+
if (vr)
|
|
345
|
+
try {
|
|
346
|
+
throw new Error();
|
|
347
|
+
} catch (t) {
|
|
348
|
+
return t;
|
|
349
|
+
}
|
|
350
|
+
return new Error();
|
|
351
|
+
}
|
|
352
|
+
function It(t, e) {
|
|
353
|
+
var n = t.stack;
|
|
354
|
+
return n ? (e = e || 0, n.indexOf(t.name) === 0 && (e += (t.name + t.message).split(`
|
|
355
|
+
`).length), n.split(`
|
|
356
|
+
`).slice(e).filter(Nn).map((r) => `
|
|
357
|
+
` + r).join("")) : "";
|
|
358
|
+
}
|
|
359
|
+
var Bn = ["Unknown", "Constraint", "Data", "TransactionInactive", "ReadOnly", "Version", "NotFound", "InvalidState", "InvalidAccess", "Abort", "Timeout", "QuotaExceeded", "Syntax", "DataClone"], tn = ["Modify", "Bulk", "OpenFailed", "VersionChange", "Schema", "Upgrade", "InvalidTable", "MissingAPI", "NoSuchDatabase", "InvalidArgument", "SubTransaction", "Unsupported", "Internal", "DatabaseClosed", "PrematureCommit", "ForeignAwait"].concat(Bn), br = { 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" };
|
|
360
|
+
function xe(t, e) {
|
|
361
|
+
this._e = Pe(), this.name = t, this.message = e;
|
|
362
|
+
}
|
|
363
|
+
function Mn(t, e) {
|
|
364
|
+
return t + ". Errors: " + Object.keys(e).map((n) => e[n].toString()).filter((n, r, s) => s.indexOf(n) === r).join(`
|
|
365
|
+
`);
|
|
366
|
+
}
|
|
367
|
+
function lt(t, e, n, r) {
|
|
368
|
+
this._e = Pe(), this.failures = e, this.failedKeys = r, this.successCount = n, this.message = Mn(t, e);
|
|
369
|
+
}
|
|
370
|
+
function Re(t, e) {
|
|
371
|
+
this._e = Pe(), this.name = "BulkError", this.failures = Object.keys(e).map((n) => e[n]), this.failuresByPos = e, this.message = Mn(t, e);
|
|
372
|
+
}
|
|
373
|
+
ke(xe).from(Error).extend({ stack: { get: function() {
|
|
374
|
+
return this._stack || (this._stack = this.name + ": " + this.message + It(this._e, 2));
|
|
375
|
+
} }, toString: function() {
|
|
376
|
+
return this.name + ": " + this.message;
|
|
377
|
+
} }), ke(lt).from(xe), ke(Re).from(xe);
|
|
378
|
+
var nn = tn.reduce((t, e) => (t[e] = e + "Error", t), {});
|
|
379
|
+
const wr = xe;
|
|
380
|
+
var C = tn.reduce((t, e) => {
|
|
381
|
+
var n = e + "Error";
|
|
382
|
+
function r(s, i) {
|
|
383
|
+
this._e = Pe(), this.name = n, s ? typeof s == "string" ? (this.message = `${s}${i ? `
|
|
384
|
+
` + i : ""}`, this.inner = i || null) : typeof s == "object" && (this.message = `${s.name} ${s.message}`, this.inner = s) : (this.message = br[e] || n, this.inner = null);
|
|
385
|
+
}
|
|
386
|
+
return ke(r).from(wr), t[e] = r, t;
|
|
387
|
+
}, {});
|
|
388
|
+
C.Syntax = SyntaxError, C.Type = TypeError, C.Range = RangeError;
|
|
389
|
+
var gn = Bn.reduce((t, e) => (t[e + "Error"] = C[e], t), {}), tt = tn.reduce((t, e) => (["Syntax", "Type", "Range"].indexOf(e) === -1 && (t[e + "Error"] = C[e]), t), {});
|
|
390
|
+
function I() {
|
|
391
|
+
}
|
|
392
|
+
function Me(t) {
|
|
393
|
+
return t;
|
|
394
|
+
}
|
|
395
|
+
function _r(t, e) {
|
|
396
|
+
return t == null || t === Me ? e : function(n) {
|
|
397
|
+
return e(t(n));
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function me(t, e) {
|
|
401
|
+
return function() {
|
|
402
|
+
t.apply(this, arguments), e.apply(this, arguments);
|
|
403
|
+
};
|
|
404
|
+
}
|
|
405
|
+
function kr(t, e) {
|
|
406
|
+
return t === I ? e : function() {
|
|
407
|
+
var n = t.apply(this, arguments);
|
|
408
|
+
n !== void 0 && (arguments[0] = n);
|
|
409
|
+
var r = this.onsuccess, s = this.onerror;
|
|
410
|
+
this.onsuccess = null, this.onerror = null;
|
|
411
|
+
var i = e.apply(this, arguments);
|
|
412
|
+
return r && (this.onsuccess = this.onsuccess ? me(r, this.onsuccess) : r), s && (this.onerror = this.onerror ? me(s, this.onerror) : s), i !== void 0 ? i : n;
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
function xr(t, e) {
|
|
416
|
+
return t === I ? e : function() {
|
|
417
|
+
t.apply(this, arguments);
|
|
418
|
+
var n = this.onsuccess, r = this.onerror;
|
|
419
|
+
this.onsuccess = this.onerror = null, e.apply(this, arguments), n && (this.onsuccess = this.onsuccess ? me(n, this.onsuccess) : n), r && (this.onerror = this.onerror ? me(r, this.onerror) : r);
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
function Sr(t, e) {
|
|
423
|
+
return t === I ? e : function(n) {
|
|
424
|
+
var r = t.apply(this, arguments);
|
|
425
|
+
U(n, r);
|
|
426
|
+
var s = this.onsuccess, i = this.onerror;
|
|
427
|
+
this.onsuccess = null, this.onerror = null;
|
|
428
|
+
var o = e.apply(this, arguments);
|
|
429
|
+
return s && (this.onsuccess = this.onsuccess ? me(s, this.onsuccess) : s), i && (this.onerror = this.onerror ? me(i, this.onerror) : i), r === void 0 ? o === void 0 ? void 0 : o : U(r, o);
|
|
430
|
+
};
|
|
431
|
+
}
|
|
432
|
+
function Er(t, e) {
|
|
433
|
+
return t === I ? e : function() {
|
|
434
|
+
return e.apply(this, arguments) !== !1 && t.apply(this, arguments);
|
|
435
|
+
};
|
|
436
|
+
}
|
|
437
|
+
function rn(t, e) {
|
|
438
|
+
return t === I ? e : function() {
|
|
439
|
+
var n = t.apply(this, arguments);
|
|
440
|
+
if (n && typeof n.then == "function") {
|
|
441
|
+
for (var r = this, s = arguments.length, i = new Array(s); s--; )
|
|
442
|
+
i[s] = arguments[s];
|
|
443
|
+
return n.then(function() {
|
|
444
|
+
return e.apply(r, i);
|
|
445
|
+
});
|
|
446
|
+
}
|
|
447
|
+
return e.apply(this, arguments);
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
tt.ModifyError = lt, tt.DexieError = xe, tt.BulkError = Re;
|
|
451
|
+
var Fe = {};
|
|
452
|
+
const Fn = 100, [Kt, ht, Rt] = typeof Promise > "u" ? [] : (() => {
|
|
453
|
+
let t = Promise.resolve();
|
|
454
|
+
if (typeof crypto > "u" || !crypto.subtle)
|
|
455
|
+
return [t, Be(t), t];
|
|
456
|
+
const e = crypto.subtle.digest("SHA-512", new Uint8Array([0]));
|
|
457
|
+
return [e, Be(e), t];
|
|
458
|
+
})(), qn = ht && ht.then, nt = Kt && Kt.constructor, sn = !!Rt;
|
|
459
|
+
var jt = !1, Pr = Rt ? () => {
|
|
460
|
+
Rt.then(Ye);
|
|
461
|
+
} : K.setImmediate ? setImmediate.bind(null, Ye) : K.MutationObserver ? () => {
|
|
462
|
+
var t = document.createElement("div");
|
|
463
|
+
new MutationObserver(() => {
|
|
464
|
+
Ye(), t = null;
|
|
465
|
+
}).observe(t, { attributes: !0 }), t.setAttribute("i", "1");
|
|
466
|
+
} : () => {
|
|
467
|
+
setTimeout(Ye, 0);
|
|
468
|
+
}, je = function(t, e) {
|
|
469
|
+
Ke.push([t, e]), dt && (Pr(), dt = !1);
|
|
470
|
+
}, Dt = !0, dt = !0, de = [], rt = [], $t = null, Nt = Me, Se = { id: "global", global: !0, ref: 0, unhandleds: [], onunhandled: bn, pgp: !1, env: {}, finalize: function() {
|
|
471
|
+
this.unhandleds.forEach((t) => {
|
|
472
|
+
try {
|
|
473
|
+
bn(t[0], t[1]);
|
|
474
|
+
} catch {
|
|
475
|
+
}
|
|
476
|
+
});
|
|
477
|
+
} }, P = Se, Ke = [], fe = 0, st = [];
|
|
478
|
+
function S(t) {
|
|
479
|
+
if (typeof this != "object")
|
|
480
|
+
throw new TypeError("Promises must be constructed via new");
|
|
481
|
+
this._listeners = [], this.onuncatched = I, this._lib = !1;
|
|
482
|
+
var e = this._PSD = P;
|
|
483
|
+
if (G && (this._stackHolder = Pe(), this._prev = null, this._numPrev = 0), typeof t != "function") {
|
|
484
|
+
if (t !== Fe)
|
|
485
|
+
throw new TypeError("Not a function");
|
|
486
|
+
return this._state = arguments[1], this._value = arguments[2], void (this._state === !1 && Mt(this, this._value));
|
|
487
|
+
}
|
|
488
|
+
this._state = null, this._value = null, ++e.ref, Un(this, t);
|
|
489
|
+
}
|
|
490
|
+
const Bt = { get: function() {
|
|
491
|
+
var t = P, e = ft;
|
|
492
|
+
function n(r, s) {
|
|
493
|
+
var i = !t.global && (t !== P || e !== ft);
|
|
494
|
+
const o = i && !ne();
|
|
495
|
+
var u = new S((a, l) => {
|
|
496
|
+
on(this, new Ln(pt(r, t, i, o), pt(s, t, i, o), a, l, t));
|
|
497
|
+
});
|
|
498
|
+
return G && zn(u, this), u;
|
|
499
|
+
}
|
|
500
|
+
return n.prototype = Fe, n;
|
|
501
|
+
}, set: function(t) {
|
|
502
|
+
ee(this, "then", t && t.prototype === Fe ? Bt : { get: function() {
|
|
503
|
+
return t;
|
|
504
|
+
}, set: Bt.set });
|
|
505
|
+
} };
|
|
506
|
+
function Ln(t, e, n, r, s) {
|
|
507
|
+
this.onFulfilled = typeof t == "function" ? t : null, this.onRejected = typeof e == "function" ? e : null, this.resolve = n, this.reject = r, this.psd = s;
|
|
508
|
+
}
|
|
509
|
+
function Un(t, e) {
|
|
510
|
+
try {
|
|
511
|
+
e((n) => {
|
|
512
|
+
if (t._state === null) {
|
|
513
|
+
if (n === t)
|
|
514
|
+
throw new TypeError("A promise cannot be resolved with itself.");
|
|
515
|
+
var r = t._lib && ze();
|
|
516
|
+
n && typeof n.then == "function" ? Un(t, (s, i) => {
|
|
517
|
+
n instanceof S ? n._then(s, i) : n.then(s, i);
|
|
518
|
+
}) : (t._state = !0, t._value = n, Vn(t)), r && He();
|
|
519
|
+
}
|
|
520
|
+
}, Mt.bind(null, t));
|
|
521
|
+
} catch (n) {
|
|
522
|
+
Mt(t, n);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
function Mt(t, e) {
|
|
526
|
+
if (rt.push(e), t._state === null) {
|
|
527
|
+
var n = t._lib && ze();
|
|
528
|
+
e = Nt(e), t._state = !1, t._value = e, G && e !== null && typeof e == "object" && !e._promise && function(r, s, i) {
|
|
529
|
+
try {
|
|
530
|
+
r.apply(null, i);
|
|
531
|
+
} catch (o) {
|
|
532
|
+
s && s(o);
|
|
533
|
+
}
|
|
534
|
+
}(() => {
|
|
535
|
+
var r = Zt(e, "stack");
|
|
536
|
+
e._promise = t, ee(e, "stack", { get: () => jt ? r && (r.get ? r.get.apply(e) : r.value) : t.stack });
|
|
537
|
+
}), function(r) {
|
|
538
|
+
de.some((s) => s._value === r._value) || de.push(r);
|
|
539
|
+
}(t), Vn(t), n && He();
|
|
540
|
+
}
|
|
541
|
+
}
|
|
542
|
+
function Vn(t) {
|
|
543
|
+
var e = t._listeners;
|
|
544
|
+
t._listeners = [];
|
|
545
|
+
for (var n = 0, r = e.length; n < r; ++n)
|
|
546
|
+
on(t, e[n]);
|
|
547
|
+
var s = t._PSD;
|
|
548
|
+
--s.ref || s.finalize(), fe === 0 && (++fe, je(() => {
|
|
549
|
+
--fe == 0 && an();
|
|
550
|
+
}, []));
|
|
551
|
+
}
|
|
552
|
+
function on(t, e) {
|
|
553
|
+
if (t._state !== null) {
|
|
554
|
+
var n = t._state ? e.onFulfilled : e.onRejected;
|
|
555
|
+
if (n === null)
|
|
556
|
+
return (t._state ? e.resolve : e.reject)(t._value);
|
|
557
|
+
++e.psd.ref, ++fe, je(Cr, [n, t, e]);
|
|
558
|
+
} else
|
|
559
|
+
t._listeners.push(e);
|
|
560
|
+
}
|
|
561
|
+
function Cr(t, e, n) {
|
|
562
|
+
try {
|
|
563
|
+
$t = e;
|
|
564
|
+
var r, s = e._value;
|
|
565
|
+
e._state ? r = t(s) : (rt.length && (rt = []), r = t(s), rt.indexOf(s) === -1 && function(i) {
|
|
566
|
+
for (var o = de.length; o; )
|
|
567
|
+
if (de[--o]._value === i._value)
|
|
568
|
+
return void de.splice(o, 1);
|
|
569
|
+
}(e)), n.resolve(r);
|
|
570
|
+
} catch (i) {
|
|
571
|
+
n.reject(i);
|
|
572
|
+
} finally {
|
|
573
|
+
$t = null, --fe == 0 && an(), --n.psd.ref || n.psd.finalize();
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
function Wn(t, e, n) {
|
|
577
|
+
if (e.length === n)
|
|
578
|
+
return e;
|
|
579
|
+
var r = "";
|
|
580
|
+
if (t._state === !1) {
|
|
581
|
+
var s, i, o = t._value;
|
|
582
|
+
o != null ? (s = o.name || "Error", i = o.message || o, r = It(o, 0)) : (s = o, i = ""), e.push(s + (i ? ": " + i : "") + r);
|
|
583
|
+
}
|
|
584
|
+
return G && ((r = It(t._stackHolder, 2)) && e.indexOf(r) === -1 && e.push(r), t._prev && Wn(t._prev, e, n)), e;
|
|
585
|
+
}
|
|
586
|
+
function zn(t, e) {
|
|
587
|
+
var n = e ? e._numPrev + 1 : 0;
|
|
588
|
+
n < 100 && (t._prev = e, t._numPrev = n);
|
|
589
|
+
}
|
|
590
|
+
function Ye() {
|
|
591
|
+
ze() && He();
|
|
592
|
+
}
|
|
593
|
+
function ze() {
|
|
594
|
+
var t = Dt;
|
|
595
|
+
return Dt = !1, dt = !1, t;
|
|
596
|
+
}
|
|
597
|
+
function He() {
|
|
598
|
+
var t, e, n;
|
|
599
|
+
do
|
|
600
|
+
for (; Ke.length > 0; )
|
|
601
|
+
for (t = Ke, Ke = [], n = t.length, e = 0; e < n; ++e) {
|
|
602
|
+
var r = t[e];
|
|
603
|
+
r[0].apply(null, r[1]);
|
|
604
|
+
}
|
|
605
|
+
while (Ke.length > 0);
|
|
606
|
+
Dt = !0, dt = !0;
|
|
607
|
+
}
|
|
608
|
+
function an() {
|
|
609
|
+
var t = de;
|
|
610
|
+
de = [], t.forEach((r) => {
|
|
611
|
+
r._PSD.onunhandled.call(null, r._value, r);
|
|
612
|
+
});
|
|
613
|
+
for (var e = st.slice(0), n = e.length; n; )
|
|
614
|
+
e[--n]();
|
|
615
|
+
}
|
|
616
|
+
function Ge(t) {
|
|
617
|
+
return new S(Fe, !1, t);
|
|
618
|
+
}
|
|
619
|
+
function R(t, e) {
|
|
620
|
+
var n = P;
|
|
621
|
+
return function() {
|
|
622
|
+
var r = ze(), s = P;
|
|
623
|
+
try {
|
|
624
|
+
return ae(n, !0), t.apply(this, arguments);
|
|
625
|
+
} catch (i) {
|
|
626
|
+
e && e(i);
|
|
627
|
+
} finally {
|
|
628
|
+
ae(s, !1), r && He();
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
Ee(S.prototype, { then: Bt, _then: function(t, e) {
|
|
633
|
+
on(this, new Ln(null, null, t, e, P));
|
|
634
|
+
}, catch: function(t) {
|
|
635
|
+
if (arguments.length === 1)
|
|
636
|
+
return this.then(null, t);
|
|
637
|
+
var e = arguments[0], n = arguments[1];
|
|
638
|
+
return typeof e == "function" ? this.then(null, (r) => r instanceof e ? n(r) : Ge(r)) : this.then(null, (r) => r && r.name === e ? n(r) : Ge(r));
|
|
639
|
+
}, finally: function(t) {
|
|
640
|
+
return this.then((e) => (t(), e), (e) => (t(), Ge(e)));
|
|
641
|
+
}, stack: { get: function() {
|
|
642
|
+
if (this._stack)
|
|
643
|
+
return this._stack;
|
|
644
|
+
try {
|
|
645
|
+
jt = !0;
|
|
646
|
+
var t = Wn(this, [], 20).join(`
|
|
647
|
+
From previous: `);
|
|
648
|
+
return this._state !== null && (this._stack = t), t;
|
|
649
|
+
} finally {
|
|
650
|
+
jt = !1;
|
|
651
|
+
}
|
|
652
|
+
} }, timeout: function(t, e) {
|
|
653
|
+
return t < 1 / 0 ? new S((n, r) => {
|
|
654
|
+
var s = setTimeout(() => r(new C.Timeout(e)), t);
|
|
655
|
+
this.then(n, r).finally(clearTimeout.bind(null, s));
|
|
656
|
+
}) : this;
|
|
657
|
+
} }), typeof Symbol < "u" && Symbol.toStringTag && ee(S.prototype, Symbol.toStringTag, "Dexie.Promise"), Se.env = Hn(), Ee(S, { all: function() {
|
|
658
|
+
var t = J.apply(null, arguments).map(Xe);
|
|
659
|
+
return new S(function(e, n) {
|
|
660
|
+
t.length === 0 && e([]);
|
|
661
|
+
var r = t.length;
|
|
662
|
+
t.forEach((s, i) => S.resolve(s).then((o) => {
|
|
663
|
+
t[i] = o, --r || e(t);
|
|
664
|
+
}, n));
|
|
665
|
+
});
|
|
666
|
+
}, resolve: (t) => {
|
|
667
|
+
if (t instanceof S)
|
|
668
|
+
return t;
|
|
669
|
+
if (t && typeof t.then == "function")
|
|
670
|
+
return new S((n, r) => {
|
|
671
|
+
t.then(n, r);
|
|
672
|
+
});
|
|
673
|
+
var e = new S(Fe, !0, t);
|
|
674
|
+
return zn(e, $t), e;
|
|
675
|
+
}, reject: Ge, race: function() {
|
|
676
|
+
var t = J.apply(null, arguments).map(Xe);
|
|
677
|
+
return new S((e, n) => {
|
|
678
|
+
t.map((r) => S.resolve(r).then(e, n));
|
|
679
|
+
});
|
|
680
|
+
}, PSD: { get: () => P, set: (t) => P = t }, totalEchoes: { get: () => ft }, newPSD: oe, usePSD: Te, scheduler: { get: () => je, set: (t) => {
|
|
681
|
+
je = t;
|
|
682
|
+
} }, rejectionMapper: { get: () => Nt, set: (t) => {
|
|
683
|
+
Nt = t;
|
|
684
|
+
} }, follow: (t, e) => new S((n, r) => oe((s, i) => {
|
|
685
|
+
var o = P;
|
|
686
|
+
o.unhandleds = [], o.onunhandled = i, o.finalize = me(function() {
|
|
687
|
+
(function(u) {
|
|
688
|
+
function a() {
|
|
689
|
+
u(), st.splice(st.indexOf(a), 1);
|
|
690
|
+
}
|
|
691
|
+
st.push(a), ++fe, je(() => {
|
|
692
|
+
--fe == 0 && an();
|
|
693
|
+
}, []);
|
|
694
|
+
})(() => {
|
|
695
|
+
this.unhandleds.length === 0 ? s() : i(this.unhandleds[0]);
|
|
696
|
+
});
|
|
697
|
+
}, o.finalize), t();
|
|
698
|
+
}, e, n, r)) }), nt && (nt.allSettled && ee(S, "allSettled", function() {
|
|
699
|
+
const t = J.apply(null, arguments).map(Xe);
|
|
700
|
+
return new S((e) => {
|
|
701
|
+
t.length === 0 && e([]);
|
|
702
|
+
let n = t.length;
|
|
703
|
+
const r = new Array(n);
|
|
704
|
+
t.forEach((s, i) => S.resolve(s).then((o) => r[i] = { status: "fulfilled", value: o }, (o) => r[i] = { status: "rejected", reason: o }).then(() => --n || e(r)));
|
|
705
|
+
});
|
|
706
|
+
}), nt.any && typeof AggregateError < "u" && ee(S, "any", function() {
|
|
707
|
+
const t = J.apply(null, arguments).map(Xe);
|
|
708
|
+
return new S((e, n) => {
|
|
709
|
+
t.length === 0 && n(new AggregateError([]));
|
|
710
|
+
let r = t.length;
|
|
711
|
+
const s = new Array(r);
|
|
712
|
+
t.forEach((i, o) => S.resolve(i).then((u) => e(u), (u) => {
|
|
713
|
+
s[o] = u, --r || n(new AggregateError(s));
|
|
714
|
+
}));
|
|
715
|
+
});
|
|
716
|
+
}));
|
|
717
|
+
const M = { awaits: 0, echoes: 0, id: 0 };
|
|
718
|
+
var Tr = 0, it = [], wt = 0, ft = 0, Ar = 0;
|
|
719
|
+
function oe(t, e, n, r) {
|
|
720
|
+
var s = P, i = Object.create(s);
|
|
721
|
+
i.parent = s, i.ref = 0, i.global = !1, i.id = ++Ar;
|
|
722
|
+
var o = Se.env;
|
|
723
|
+
i.env = sn ? { 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, nthen: yn(o.nthen, i), gthen: yn(o.gthen, i) } : {}, e && U(i, e), ++s.ref, i.finalize = function() {
|
|
724
|
+
--this.parent.ref || this.parent.finalize();
|
|
725
|
+
};
|
|
726
|
+
var u = Te(i, t, n, r);
|
|
727
|
+
return i.ref === 0 && i.finalize(), u;
|
|
728
|
+
}
|
|
729
|
+
function Ce() {
|
|
730
|
+
return M.id || (M.id = ++Tr), ++M.awaits, M.echoes += Fn, M.id;
|
|
731
|
+
}
|
|
732
|
+
function ne() {
|
|
733
|
+
return !!M.awaits && (--M.awaits == 0 && (M.id = 0), M.echoes = M.awaits * Fn, !0);
|
|
734
|
+
}
|
|
735
|
+
function Xe(t) {
|
|
736
|
+
return M.echoes && t && t.constructor === nt ? (Ce(), t.then((e) => (ne(), e), (e) => (ne(), N(e)))) : t;
|
|
737
|
+
}
|
|
738
|
+
function Or(t) {
|
|
739
|
+
++ft, M.echoes && --M.echoes != 0 || (M.echoes = M.id = 0), it.push(P), ae(t, !0);
|
|
740
|
+
}
|
|
741
|
+
function Ir() {
|
|
742
|
+
var t = it[it.length - 1];
|
|
743
|
+
it.pop(), ae(t, !1);
|
|
744
|
+
}
|
|
745
|
+
function ae(t, e) {
|
|
746
|
+
var n = P;
|
|
747
|
+
if ((e ? !M.echoes || wt++ && t === P : !wt || --wt && t === P) || Yn(e ? Or.bind(null, t) : Ir), t !== P && (P = t, n === Se && (Se.env = Hn()), sn)) {
|
|
748
|
+
var r = Se.env.Promise, s = t.env;
|
|
749
|
+
ht.then = s.nthen, r.prototype.then = s.gthen, (n.global || t.global) && (Object.defineProperty(K, "Promise", s.PromiseProp), r.all = s.all, r.race = s.race, r.resolve = s.resolve, r.reject = s.reject, s.allSettled && (r.allSettled = s.allSettled), s.any && (r.any = s.any));
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
function Hn() {
|
|
753
|
+
var t = K.Promise;
|
|
754
|
+
return sn ? { Promise: t, PromiseProp: Object.getOwnPropertyDescriptor(K, "Promise"), all: t.all, race: t.race, allSettled: t.allSettled, any: t.any, resolve: t.resolve, reject: t.reject, nthen: ht.then, gthen: t.prototype.then } : {};
|
|
755
|
+
}
|
|
756
|
+
function Te(t, e, n, r, s) {
|
|
757
|
+
var i = P;
|
|
758
|
+
try {
|
|
759
|
+
return ae(t, !0), e(n, r, s);
|
|
760
|
+
} finally {
|
|
761
|
+
ae(i, !1);
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
function Yn(t) {
|
|
765
|
+
qn.call(Kt, t);
|
|
766
|
+
}
|
|
767
|
+
function pt(t, e, n, r) {
|
|
768
|
+
return typeof t != "function" ? t : function() {
|
|
769
|
+
var s = P;
|
|
770
|
+
n && Ce(), ae(e, !0);
|
|
771
|
+
try {
|
|
772
|
+
return t.apply(this, arguments);
|
|
773
|
+
} finally {
|
|
774
|
+
ae(s, !1), r && Yn(ne);
|
|
775
|
+
}
|
|
776
|
+
};
|
|
777
|
+
}
|
|
778
|
+
function yn(t, e) {
|
|
779
|
+
return function(n, r) {
|
|
780
|
+
return t.call(this, pt(n, e), pt(r, e));
|
|
781
|
+
};
|
|
782
|
+
}
|
|
783
|
+
("" + qn).indexOf("[native code]") === -1 && (Ce = ne = I);
|
|
784
|
+
const vn = "unhandledrejection";
|
|
785
|
+
function bn(t, e) {
|
|
786
|
+
var n;
|
|
787
|
+
try {
|
|
788
|
+
n = e.onuncatched(t);
|
|
789
|
+
} catch {
|
|
790
|
+
}
|
|
791
|
+
if (n !== !1)
|
|
792
|
+
try {
|
|
793
|
+
var r, s = { promise: e, reason: t };
|
|
794
|
+
if (K.document && document.createEvent ? ((r = document.createEvent("Event")).initEvent(vn, !0, !0), U(r, s)) : K.CustomEvent && U(r = new CustomEvent(vn, { detail: s }), s), r && K.dispatchEvent && (dispatchEvent(r), !K.PromiseRejectionEvent && K.onunhandledrejection))
|
|
795
|
+
try {
|
|
796
|
+
K.onunhandledrejection(r);
|
|
797
|
+
} catch {
|
|
798
|
+
}
|
|
799
|
+
G && r && !r.defaultPrevented && console.warn(`Unhandled rejection: ${t.stack || t}`);
|
|
800
|
+
} catch {
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
var N = S.reject;
|
|
804
|
+
function Ft(t, e, n, r) {
|
|
805
|
+
if (t.idbdb && (t._state.openComplete || P.letThrough || t._vip)) {
|
|
806
|
+
var s = t._createTransaction(e, n, t._dbSchema);
|
|
807
|
+
try {
|
|
808
|
+
s.create(), t._state.PR1398_maxLoop = 3;
|
|
809
|
+
} catch (i) {
|
|
810
|
+
return i.name === nn.InvalidState && t.isOpen() && --t._state.PR1398_maxLoop > 0 ? (console.warn("Dexie: Need to reopen db"), t._close(), t.open().then(() => Ft(t, e, n, r))) : N(i);
|
|
811
|
+
}
|
|
812
|
+
return s._promise(e, (i, o) => oe(() => (P.trans = s, r(i, o, s)))).then((i) => s._completion.then(() => i));
|
|
813
|
+
}
|
|
814
|
+
if (t._state.openComplete)
|
|
815
|
+
return N(new C.DatabaseClosed(t._state.dbOpenError));
|
|
816
|
+
if (!t._state.isBeingOpened) {
|
|
817
|
+
if (!t._options.autoOpen)
|
|
818
|
+
return N(new C.DatabaseClosed());
|
|
819
|
+
t.open().catch(I);
|
|
820
|
+
}
|
|
821
|
+
return t._state.dbReadyPromise.then(() => Ft(t, e, n, r));
|
|
822
|
+
}
|
|
823
|
+
const wn = "3.2.4", he = String.fromCharCode(65535), qt = -1 / 0, X = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.", Gn = "String expected.", De = [], yt = typeof navigator < "u" && /(MSIE|Trident|Edge)/.test(navigator.userAgent), Kr = yt, Rr = yt, Xn = (t) => !/(dexie\.js|dexie\.min\.js)/.test(t), vt = "__dbnames", _t = "readonly", kt = "readwrite";
|
|
824
|
+
function ge(t, e) {
|
|
825
|
+
return t ? e ? function() {
|
|
826
|
+
return t.apply(this, arguments) && e.apply(this, arguments);
|
|
827
|
+
} : t : e;
|
|
828
|
+
}
|
|
829
|
+
const Qn = { type: 3, lower: -1 / 0, lowerOpen: !1, upper: [[]], upperOpen: !1 };
|
|
830
|
+
function Qe(t) {
|
|
831
|
+
return typeof t != "string" || /\./.test(t) ? (e) => e : (e) => (e[t] === void 0 && t in e && delete (e = We(e))[t], e);
|
|
832
|
+
}
|
|
833
|
+
class jr {
|
|
834
|
+
_trans(e, n, r) {
|
|
835
|
+
const s = this._tx || P.trans, i = this.name;
|
|
836
|
+
function o(a, l, h) {
|
|
837
|
+
if (!h.schema[i])
|
|
838
|
+
throw new C.NotFound("Table " + i + " not part of transaction");
|
|
839
|
+
return n(h.idbtrans, h);
|
|
840
|
+
}
|
|
841
|
+
const u = ze();
|
|
842
|
+
try {
|
|
843
|
+
return s && s.db === this.db ? s === P.trans ? s._promise(e, o, r) : oe(() => s._promise(e, o, r), { trans: s, transless: P.transless || P }) : Ft(this.db, e, [this.name], o);
|
|
844
|
+
} finally {
|
|
845
|
+
u && He();
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
get(e, n) {
|
|
849
|
+
return e && e.constructor === Object ? this.where(e).first(n) : this._trans("readonly", (r) => this.core.get({ trans: r, key: e }).then((s) => this.hook.reading.fire(s))).then(n);
|
|
850
|
+
}
|
|
851
|
+
where(e) {
|
|
852
|
+
if (typeof e == "string")
|
|
853
|
+
return new this.db.WhereClause(this, e);
|
|
854
|
+
if (F(e))
|
|
855
|
+
return new this.db.WhereClause(this, `[${e.join("+")}]`);
|
|
856
|
+
const n = $(e);
|
|
857
|
+
if (n.length === 1)
|
|
858
|
+
return this.where(n[0]).equals(e[n[0]]);
|
|
859
|
+
const r = this.schema.indexes.concat(this.schema.primKey).filter((l) => l.compound && n.every((h) => l.keyPath.indexOf(h) >= 0) && l.keyPath.every((h) => n.indexOf(h) >= 0))[0];
|
|
860
|
+
if (r && this.db._maxKey !== he)
|
|
861
|
+
return this.where(r.name).equals(r.keyPath.map((l) => e[l]));
|
|
862
|
+
!r && G && console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);
|
|
863
|
+
const { idxByName: s } = this.schema, i = this.db._deps.indexedDB;
|
|
864
|
+
function o(l, h) {
|
|
865
|
+
try {
|
|
866
|
+
return i.cmp(l, h) === 0;
|
|
867
|
+
} catch {
|
|
868
|
+
return !1;
|
|
869
|
+
}
|
|
870
|
+
}
|
|
871
|
+
const [u, a] = n.reduce(([l, h], c) => {
|
|
872
|
+
const d = s[c], m = e[c];
|
|
873
|
+
return [l || d, l || !d ? ge(h, d && d.multi ? (p) => {
|
|
874
|
+
const f = te(p, c);
|
|
875
|
+
return F(f) && f.some((y) => o(m, y));
|
|
876
|
+
} : (p) => o(m, te(p, c))) : h];
|
|
877
|
+
}, [null, null]);
|
|
878
|
+
return u ? this.where(u.name).equals(e[u.keyPath]).filter(a) : r ? this.filter(a) : this.where(n).equals("");
|
|
879
|
+
}
|
|
880
|
+
filter(e) {
|
|
881
|
+
return this.toCollection().and(e);
|
|
882
|
+
}
|
|
883
|
+
count(e) {
|
|
884
|
+
return this.toCollection().count(e);
|
|
885
|
+
}
|
|
886
|
+
offset(e) {
|
|
887
|
+
return this.toCollection().offset(e);
|
|
888
|
+
}
|
|
889
|
+
limit(e) {
|
|
890
|
+
return this.toCollection().limit(e);
|
|
891
|
+
}
|
|
892
|
+
each(e) {
|
|
893
|
+
return this.toCollection().each(e);
|
|
894
|
+
}
|
|
895
|
+
toArray(e) {
|
|
896
|
+
return this.toCollection().toArray(e);
|
|
897
|
+
}
|
|
898
|
+
toCollection() {
|
|
899
|
+
return new this.db.Collection(new this.db.WhereClause(this));
|
|
900
|
+
}
|
|
901
|
+
orderBy(e) {
|
|
902
|
+
return new this.db.Collection(new this.db.WhereClause(this, F(e) ? `[${e.join("+")}]` : e));
|
|
903
|
+
}
|
|
904
|
+
reverse() {
|
|
905
|
+
return this.toCollection().reverse();
|
|
906
|
+
}
|
|
907
|
+
mapToClass(e) {
|
|
908
|
+
this.schema.mappedClass = e;
|
|
909
|
+
const n = (r) => {
|
|
910
|
+
if (!r)
|
|
911
|
+
return r;
|
|
912
|
+
const s = Object.create(e.prototype);
|
|
913
|
+
for (var i in r)
|
|
914
|
+
if (z(r, i))
|
|
915
|
+
try {
|
|
916
|
+
s[i] = r[i];
|
|
917
|
+
} catch {
|
|
918
|
+
}
|
|
919
|
+
return s;
|
|
920
|
+
};
|
|
921
|
+
return this.schema.readHook && this.hook.reading.unsubscribe(this.schema.readHook), this.schema.readHook = n, this.hook("reading", n), e;
|
|
922
|
+
}
|
|
923
|
+
defineClass() {
|
|
924
|
+
return this.mapToClass(function(e) {
|
|
925
|
+
U(this, e);
|
|
926
|
+
});
|
|
927
|
+
}
|
|
928
|
+
add(e, n) {
|
|
929
|
+
const { auto: r, keyPath: s } = this.schema.primKey;
|
|
930
|
+
let i = e;
|
|
931
|
+
return s && r && (i = Qe(s)(e)), this._trans("readwrite", (o) => this.core.mutate({ trans: o, type: "add", keys: n != null ? [n] : null, values: [i] })).then((o) => o.numFailures ? S.reject(o.failures[0]) : o.lastResult).then((o) => {
|
|
932
|
+
if (s)
|
|
933
|
+
try {
|
|
934
|
+
H(e, s, o);
|
|
935
|
+
} catch {
|
|
936
|
+
}
|
|
937
|
+
return o;
|
|
938
|
+
});
|
|
939
|
+
}
|
|
940
|
+
update(e, n) {
|
|
941
|
+
if (typeof e != "object" || F(e))
|
|
942
|
+
return this.where(":id").equals(e).modify(n);
|
|
943
|
+
{
|
|
944
|
+
const r = te(e, this.schema.primKey.keyPath);
|
|
945
|
+
if (r === void 0)
|
|
946
|
+
return N(new C.InvalidArgument("Given object does not contain its primary key"));
|
|
947
|
+
try {
|
|
948
|
+
typeof n != "function" ? $(n).forEach((s) => {
|
|
949
|
+
H(e, s, n[s]);
|
|
950
|
+
}) : n(e, { value: e, primKey: r });
|
|
951
|
+
} catch {
|
|
952
|
+
}
|
|
953
|
+
return this.where(":id").equals(r).modify(n);
|
|
954
|
+
}
|
|
955
|
+
}
|
|
956
|
+
put(e, n) {
|
|
957
|
+
const { auto: r, keyPath: s } = this.schema.primKey;
|
|
958
|
+
let i = e;
|
|
959
|
+
return s && r && (i = Qe(s)(e)), this._trans("readwrite", (o) => this.core.mutate({ trans: o, type: "put", values: [i], keys: n != null ? [n] : null })).then((o) => o.numFailures ? S.reject(o.failures[0]) : o.lastResult).then((o) => {
|
|
960
|
+
if (s)
|
|
961
|
+
try {
|
|
962
|
+
H(e, s, o);
|
|
963
|
+
} catch {
|
|
964
|
+
}
|
|
965
|
+
return o;
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
delete(e) {
|
|
969
|
+
return this._trans("readwrite", (n) => this.core.mutate({ trans: n, type: "delete", keys: [e] })).then((n) => n.numFailures ? S.reject(n.failures[0]) : void 0);
|
|
970
|
+
}
|
|
971
|
+
clear() {
|
|
972
|
+
return this._trans("readwrite", (e) => this.core.mutate({ trans: e, type: "deleteRange", range: Qn })).then((e) => e.numFailures ? S.reject(e.failures[0]) : void 0);
|
|
973
|
+
}
|
|
974
|
+
bulkGet(e) {
|
|
975
|
+
return this._trans("readonly", (n) => this.core.getMany({ keys: e, trans: n }).then((r) => r.map((s) => this.hook.reading.fire(s))));
|
|
976
|
+
}
|
|
977
|
+
bulkAdd(e, n, r) {
|
|
978
|
+
const s = Array.isArray(n) ? n : void 0, i = (r = r || (s ? void 0 : n)) ? r.allKeys : void 0;
|
|
979
|
+
return this._trans("readwrite", (o) => {
|
|
980
|
+
const { auto: u, keyPath: a } = this.schema.primKey;
|
|
981
|
+
if (a && s)
|
|
982
|
+
throw new C.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
|
|
983
|
+
if (s && s.length !== e.length)
|
|
984
|
+
throw new C.InvalidArgument("Arguments objects and keys must have the same length");
|
|
985
|
+
const l = e.length;
|
|
986
|
+
let h = a && u ? e.map(Qe(a)) : e;
|
|
987
|
+
return this.core.mutate({ trans: o, type: "add", keys: s, values: h, wantResults: i }).then(({ numFailures: c, results: d, lastResult: m, failures: p }) => {
|
|
988
|
+
if (c === 0)
|
|
989
|
+
return i ? d : m;
|
|
990
|
+
throw new Re(`${this.name}.bulkAdd(): ${c} of ${l} operations failed`, p);
|
|
991
|
+
});
|
|
992
|
+
});
|
|
993
|
+
}
|
|
994
|
+
bulkPut(e, n, r) {
|
|
995
|
+
const s = Array.isArray(n) ? n : void 0, i = (r = r || (s ? void 0 : n)) ? r.allKeys : void 0;
|
|
996
|
+
return this._trans("readwrite", (o) => {
|
|
997
|
+
const { auto: u, keyPath: a } = this.schema.primKey;
|
|
998
|
+
if (a && s)
|
|
999
|
+
throw new C.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
|
|
1000
|
+
if (s && s.length !== e.length)
|
|
1001
|
+
throw new C.InvalidArgument("Arguments objects and keys must have the same length");
|
|
1002
|
+
const l = e.length;
|
|
1003
|
+
let h = a && u ? e.map(Qe(a)) : e;
|
|
1004
|
+
return this.core.mutate({ trans: o, type: "put", keys: s, values: h, wantResults: i }).then(({ numFailures: c, results: d, lastResult: m, failures: p }) => {
|
|
1005
|
+
if (c === 0)
|
|
1006
|
+
return i ? d : m;
|
|
1007
|
+
throw new Re(`${this.name}.bulkPut(): ${c} of ${l} operations failed`, p);
|
|
1008
|
+
});
|
|
1009
|
+
});
|
|
1010
|
+
}
|
|
1011
|
+
bulkDelete(e) {
|
|
1012
|
+
const n = e.length;
|
|
1013
|
+
return this._trans("readwrite", (r) => this.core.mutate({ trans: r, type: "delete", keys: e })).then(({ numFailures: r, lastResult: s, failures: i }) => {
|
|
1014
|
+
if (r === 0)
|
|
1015
|
+
return s;
|
|
1016
|
+
throw new Re(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`, i);
|
|
1017
|
+
});
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
function $e(t) {
|
|
1021
|
+
var e = {}, n = function(o, u) {
|
|
1022
|
+
if (u) {
|
|
1023
|
+
for (var a = arguments.length, l = new Array(a - 1); --a; )
|
|
1024
|
+
l[a - 1] = arguments[a];
|
|
1025
|
+
return e[o].subscribe.apply(null, l), t;
|
|
1026
|
+
}
|
|
1027
|
+
if (typeof o == "string")
|
|
1028
|
+
return e[o];
|
|
1029
|
+
};
|
|
1030
|
+
n.addEventType = i;
|
|
1031
|
+
for (var r = 1, s = arguments.length; r < s; ++r)
|
|
1032
|
+
i(arguments[r]);
|
|
1033
|
+
return n;
|
|
1034
|
+
function i(o, u, a) {
|
|
1035
|
+
if (typeof o != "object") {
|
|
1036
|
+
var l;
|
|
1037
|
+
u || (u = Er), a || (a = I);
|
|
1038
|
+
var h = { subscribers: [], fire: a, subscribe: function(c) {
|
|
1039
|
+
h.subscribers.indexOf(c) === -1 && (h.subscribers.push(c), h.fire = u(h.fire, c));
|
|
1040
|
+
}, unsubscribe: function(c) {
|
|
1041
|
+
h.subscribers = h.subscribers.filter(function(d) {
|
|
1042
|
+
return d !== c;
|
|
1043
|
+
}), h.fire = h.subscribers.reduce(u, a);
|
|
1044
|
+
} };
|
|
1045
|
+
return e[o] = n[o] = h, h;
|
|
1046
|
+
}
|
|
1047
|
+
$(l = o).forEach(function(c) {
|
|
1048
|
+
var d = l[c];
|
|
1049
|
+
if (F(d))
|
|
1050
|
+
i(c, l[c][0], l[c][1]);
|
|
1051
|
+
else {
|
|
1052
|
+
if (d !== "asap")
|
|
1053
|
+
throw new C.InvalidArgument("Invalid event config");
|
|
1054
|
+
var m = i(c, Me, function() {
|
|
1055
|
+
for (var p = arguments.length, f = new Array(p); p--; )
|
|
1056
|
+
f[p] = arguments[p];
|
|
1057
|
+
m.subscribers.forEach(function(y) {
|
|
1058
|
+
In(function() {
|
|
1059
|
+
y.apply(null, f);
|
|
1060
|
+
});
|
|
1061
|
+
});
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
});
|
|
1065
|
+
}
|
|
1066
|
+
}
|
|
1067
|
+
function Oe(t, e) {
|
|
1068
|
+
return ke(e).from({ prototype: t }), e;
|
|
1069
|
+
}
|
|
1070
|
+
function be(t, e) {
|
|
1071
|
+
return !(t.filter || t.algorithm || t.or) && (e ? t.justLimit : !t.replayFilter);
|
|
1072
|
+
}
|
|
1073
|
+
function xt(t, e) {
|
|
1074
|
+
t.filter = ge(t.filter, e);
|
|
1075
|
+
}
|
|
1076
|
+
function St(t, e, n) {
|
|
1077
|
+
var r = t.replayFilter;
|
|
1078
|
+
t.replayFilter = r ? () => ge(r(), e()) : e, t.justLimit = n && !r;
|
|
1079
|
+
}
|
|
1080
|
+
function ot(t, e) {
|
|
1081
|
+
if (t.isPrimKey)
|
|
1082
|
+
return e.primaryKey;
|
|
1083
|
+
const n = e.getIndexByKeyPath(t.index);
|
|
1084
|
+
if (!n)
|
|
1085
|
+
throw new C.Schema("KeyPath " + t.index + " on object store " + e.name + " is not indexed");
|
|
1086
|
+
return n;
|
|
1087
|
+
}
|
|
1088
|
+
function _n(t, e, n) {
|
|
1089
|
+
const r = ot(t, e.schema);
|
|
1090
|
+
return e.openCursor({ trans: n, values: !t.keysOnly, reverse: t.dir === "prev", unique: !!t.unique, query: { index: r, range: t.range } });
|
|
1091
|
+
}
|
|
1092
|
+
function Je(t, e, n, r) {
|
|
1093
|
+
const s = t.replayFilter ? ge(t.filter, t.replayFilter()) : t.filter;
|
|
1094
|
+
if (t.or) {
|
|
1095
|
+
const i = {}, o = (u, a, l) => {
|
|
1096
|
+
if (!s || s(a, l, (d) => a.stop(d), (d) => a.fail(d))) {
|
|
1097
|
+
var h = a.primaryKey, c = "" + h;
|
|
1098
|
+
c === "[object ArrayBuffer]" && (c = "" + new Uint8Array(h)), z(i, c) || (i[c] = !0, e(u, a, l));
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
1101
|
+
return Promise.all([t.or._iterate(o, n), kn(_n(t, r, n), t.algorithm, o, !t.keysOnly && t.valueMapper)]);
|
|
1102
|
+
}
|
|
1103
|
+
return kn(_n(t, r, n), ge(t.algorithm, s), e, !t.keysOnly && t.valueMapper);
|
|
1104
|
+
}
|
|
1105
|
+
function kn(t, e, n, r) {
|
|
1106
|
+
var s = R(r ? (i, o, u) => n(r(i), o, u) : n);
|
|
1107
|
+
return t.then((i) => {
|
|
1108
|
+
if (i)
|
|
1109
|
+
return i.start(() => {
|
|
1110
|
+
var o = () => i.continue();
|
|
1111
|
+
e && !e(i, (u) => o = u, (u) => {
|
|
1112
|
+
i.stop(u), o = I;
|
|
1113
|
+
}, (u) => {
|
|
1114
|
+
i.fail(u), o = I;
|
|
1115
|
+
}) || s(i.value, i, (u) => o = u), o();
|
|
1116
|
+
});
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
function L(t, e) {
|
|
1120
|
+
try {
|
|
1121
|
+
const n = xn(t), r = xn(e);
|
|
1122
|
+
if (n !== r)
|
|
1123
|
+
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;
|
|
1124
|
+
switch (n) {
|
|
1125
|
+
case "number":
|
|
1126
|
+
case "Date":
|
|
1127
|
+
case "string":
|
|
1128
|
+
return t > e ? 1 : t < e ? -1 : 0;
|
|
1129
|
+
case "binary":
|
|
1130
|
+
return function(s, i) {
|
|
1131
|
+
const o = s.length, u = i.length, a = o < u ? o : u;
|
|
1132
|
+
for (let l = 0; l < a; ++l)
|
|
1133
|
+
if (s[l] !== i[l])
|
|
1134
|
+
return s[l] < i[l] ? -1 : 1;
|
|
1135
|
+
return o === u ? 0 : o < u ? -1 : 1;
|
|
1136
|
+
}(Sn(t), Sn(e));
|
|
1137
|
+
case "Array":
|
|
1138
|
+
return function(s, i) {
|
|
1139
|
+
const o = s.length, u = i.length, a = o < u ? o : u;
|
|
1140
|
+
for (let l = 0; l < a; ++l) {
|
|
1141
|
+
const h = L(s[l], i[l]);
|
|
1142
|
+
if (h !== 0)
|
|
1143
|
+
return h;
|
|
1144
|
+
}
|
|
1145
|
+
return o === u ? 0 : o < u ? -1 : 1;
|
|
1146
|
+
}(t, e);
|
|
1147
|
+
}
|
|
1148
|
+
} catch {
|
|
1149
|
+
}
|
|
1150
|
+
return NaN;
|
|
1151
|
+
}
|
|
1152
|
+
function xn(t) {
|
|
1153
|
+
const e = typeof t;
|
|
1154
|
+
if (e !== "object")
|
|
1155
|
+
return e;
|
|
1156
|
+
if (ArrayBuffer.isView(t))
|
|
1157
|
+
return "binary";
|
|
1158
|
+
const n = At(t);
|
|
1159
|
+
return n === "ArrayBuffer" ? "binary" : n;
|
|
1160
|
+
}
|
|
1161
|
+
function Sn(t) {
|
|
1162
|
+
return t instanceof Uint8Array ? t : ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(t);
|
|
1163
|
+
}
|
|
1164
|
+
class Dr {
|
|
1165
|
+
_read(e, n) {
|
|
1166
|
+
var r = this._ctx;
|
|
1167
|
+
return r.error ? r.table._trans(null, N.bind(null, r.error)) : r.table._trans("readonly", e).then(n);
|
|
1168
|
+
}
|
|
1169
|
+
_write(e) {
|
|
1170
|
+
var n = this._ctx;
|
|
1171
|
+
return n.error ? n.table._trans(null, N.bind(null, n.error)) : n.table._trans("readwrite", e, "locked");
|
|
1172
|
+
}
|
|
1173
|
+
_addAlgorithm(e) {
|
|
1174
|
+
var n = this._ctx;
|
|
1175
|
+
n.algorithm = ge(n.algorithm, e);
|
|
1176
|
+
}
|
|
1177
|
+
_iterate(e, n) {
|
|
1178
|
+
return Je(this._ctx, e, n, this._ctx.table.core);
|
|
1179
|
+
}
|
|
1180
|
+
clone(e) {
|
|
1181
|
+
var n = Object.create(this.constructor.prototype), r = Object.create(this._ctx);
|
|
1182
|
+
return e && U(r, e), n._ctx = r, n;
|
|
1183
|
+
}
|
|
1184
|
+
raw() {
|
|
1185
|
+
return this._ctx.valueMapper = null, this;
|
|
1186
|
+
}
|
|
1187
|
+
each(e) {
|
|
1188
|
+
var n = this._ctx;
|
|
1189
|
+
return this._read((r) => Je(n, e, r, n.table.core));
|
|
1190
|
+
}
|
|
1191
|
+
count(e) {
|
|
1192
|
+
return this._read((n) => {
|
|
1193
|
+
const r = this._ctx, s = r.table.core;
|
|
1194
|
+
if (be(r, !0))
|
|
1195
|
+
return s.count({ trans: n, query: { index: ot(r, s.schema), range: r.range } }).then((o) => Math.min(o, r.limit));
|
|
1196
|
+
var i = 0;
|
|
1197
|
+
return Je(r, () => (++i, !1), n, s).then(() => i);
|
|
1198
|
+
}).then(e);
|
|
1199
|
+
}
|
|
1200
|
+
sortBy(e, n) {
|
|
1201
|
+
const r = e.split(".").reverse(), s = r[0], i = r.length - 1;
|
|
1202
|
+
function o(l, h) {
|
|
1203
|
+
return h ? o(l[r[h]], h - 1) : l[s];
|
|
1204
|
+
}
|
|
1205
|
+
var u = this._ctx.dir === "next" ? 1 : -1;
|
|
1206
|
+
function a(l, h) {
|
|
1207
|
+
var c = o(l, i), d = o(h, i);
|
|
1208
|
+
return c < d ? -u : c > d ? u : 0;
|
|
1209
|
+
}
|
|
1210
|
+
return this.toArray(function(l) {
|
|
1211
|
+
return l.sort(a);
|
|
1212
|
+
}).then(n);
|
|
1213
|
+
}
|
|
1214
|
+
toArray(e) {
|
|
1215
|
+
return this._read((n) => {
|
|
1216
|
+
var r = this._ctx;
|
|
1217
|
+
if (r.dir === "next" && be(r, !0) && r.limit > 0) {
|
|
1218
|
+
const { valueMapper: s } = r, i = ot(r, r.table.core.schema);
|
|
1219
|
+
return r.table.core.query({ trans: n, limit: r.limit, values: !0, query: { index: i, range: r.range } }).then(({ result: o }) => s ? o.map(s) : o);
|
|
1220
|
+
}
|
|
1221
|
+
{
|
|
1222
|
+
const s = [];
|
|
1223
|
+
return Je(r, (i) => s.push(i), n, r.table.core).then(() => s);
|
|
1224
|
+
}
|
|
1225
|
+
}, e);
|
|
1226
|
+
}
|
|
1227
|
+
offset(e) {
|
|
1228
|
+
var n = this._ctx;
|
|
1229
|
+
return e <= 0 || (n.offset += e, be(n) ? St(n, () => {
|
|
1230
|
+
var r = e;
|
|
1231
|
+
return (s, i) => r === 0 || (r === 1 ? (--r, !1) : (i(() => {
|
|
1232
|
+
s.advance(r), r = 0;
|
|
1233
|
+
}), !1));
|
|
1234
|
+
}) : St(n, () => {
|
|
1235
|
+
var r = e;
|
|
1236
|
+
return () => --r < 0;
|
|
1237
|
+
})), this;
|
|
1238
|
+
}
|
|
1239
|
+
limit(e) {
|
|
1240
|
+
return this._ctx.limit = Math.min(this._ctx.limit, e), St(this._ctx, () => {
|
|
1241
|
+
var n = e;
|
|
1242
|
+
return function(r, s, i) {
|
|
1243
|
+
return --n <= 0 && s(i), n >= 0;
|
|
1244
|
+
};
|
|
1245
|
+
}, !0), this;
|
|
1246
|
+
}
|
|
1247
|
+
until(e, n) {
|
|
1248
|
+
return xt(this._ctx, function(r, s, i) {
|
|
1249
|
+
return !e(r.value) || (s(i), n);
|
|
1250
|
+
}), this;
|
|
1251
|
+
}
|
|
1252
|
+
first(e) {
|
|
1253
|
+
return this.limit(1).toArray(function(n) {
|
|
1254
|
+
return n[0];
|
|
1255
|
+
}).then(e);
|
|
1256
|
+
}
|
|
1257
|
+
last(e) {
|
|
1258
|
+
return this.reverse().first(e);
|
|
1259
|
+
}
|
|
1260
|
+
filter(e) {
|
|
1261
|
+
var n, r;
|
|
1262
|
+
return xt(this._ctx, function(s) {
|
|
1263
|
+
return e(s.value);
|
|
1264
|
+
}), n = this._ctx, r = e, n.isMatch = ge(n.isMatch, r), this;
|
|
1265
|
+
}
|
|
1266
|
+
and(e) {
|
|
1267
|
+
return this.filter(e);
|
|
1268
|
+
}
|
|
1269
|
+
or(e) {
|
|
1270
|
+
return new this.db.WhereClause(this._ctx.table, e, this);
|
|
1271
|
+
}
|
|
1272
|
+
reverse() {
|
|
1273
|
+
return this._ctx.dir = this._ctx.dir === "prev" ? "next" : "prev", this._ondirectionchange && this._ondirectionchange(this._ctx.dir), this;
|
|
1274
|
+
}
|
|
1275
|
+
desc() {
|
|
1276
|
+
return this.reverse();
|
|
1277
|
+
}
|
|
1278
|
+
eachKey(e) {
|
|
1279
|
+
var n = this._ctx;
|
|
1280
|
+
return n.keysOnly = !n.isMatch, this.each(function(r, s) {
|
|
1281
|
+
e(s.key, s);
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
eachUniqueKey(e) {
|
|
1285
|
+
return this._ctx.unique = "unique", this.eachKey(e);
|
|
1286
|
+
}
|
|
1287
|
+
eachPrimaryKey(e) {
|
|
1288
|
+
var n = this._ctx;
|
|
1289
|
+
return n.keysOnly = !n.isMatch, this.each(function(r, s) {
|
|
1290
|
+
e(s.primaryKey, s);
|
|
1291
|
+
});
|
|
1292
|
+
}
|
|
1293
|
+
keys(e) {
|
|
1294
|
+
var n = this._ctx;
|
|
1295
|
+
n.keysOnly = !n.isMatch;
|
|
1296
|
+
var r = [];
|
|
1297
|
+
return this.each(function(s, i) {
|
|
1298
|
+
r.push(i.key);
|
|
1299
|
+
}).then(function() {
|
|
1300
|
+
return r;
|
|
1301
|
+
}).then(e);
|
|
1302
|
+
}
|
|
1303
|
+
primaryKeys(e) {
|
|
1304
|
+
var n = this._ctx;
|
|
1305
|
+
if (n.dir === "next" && be(n, !0) && n.limit > 0)
|
|
1306
|
+
return this._read((s) => {
|
|
1307
|
+
var i = ot(n, n.table.core.schema);
|
|
1308
|
+
return n.table.core.query({ trans: s, values: !1, limit: n.limit, query: { index: i, range: n.range } });
|
|
1309
|
+
}).then(({ result: s }) => s).then(e);
|
|
1310
|
+
n.keysOnly = !n.isMatch;
|
|
1311
|
+
var r = [];
|
|
1312
|
+
return this.each(function(s, i) {
|
|
1313
|
+
r.push(i.primaryKey);
|
|
1314
|
+
}).then(function() {
|
|
1315
|
+
return r;
|
|
1316
|
+
}).then(e);
|
|
1317
|
+
}
|
|
1318
|
+
uniqueKeys(e) {
|
|
1319
|
+
return this._ctx.unique = "unique", this.keys(e);
|
|
1320
|
+
}
|
|
1321
|
+
firstKey(e) {
|
|
1322
|
+
return this.limit(1).keys(function(n) {
|
|
1323
|
+
return n[0];
|
|
1324
|
+
}).then(e);
|
|
1325
|
+
}
|
|
1326
|
+
lastKey(e) {
|
|
1327
|
+
return this.reverse().firstKey(e);
|
|
1328
|
+
}
|
|
1329
|
+
distinct() {
|
|
1330
|
+
var e = this._ctx, n = e.index && e.table.schema.idxByName[e.index];
|
|
1331
|
+
if (!n || !n.multi)
|
|
1332
|
+
return this;
|
|
1333
|
+
var r = {};
|
|
1334
|
+
return xt(this._ctx, function(s) {
|
|
1335
|
+
var i = s.primaryKey.toString(), o = z(r, i);
|
|
1336
|
+
return r[i] = !0, !o;
|
|
1337
|
+
}), this;
|
|
1338
|
+
}
|
|
1339
|
+
modify(e) {
|
|
1340
|
+
var n = this._ctx;
|
|
1341
|
+
return this._write((r) => {
|
|
1342
|
+
var s;
|
|
1343
|
+
if (typeof e == "function")
|
|
1344
|
+
s = e;
|
|
1345
|
+
else {
|
|
1346
|
+
var i = $(e), o = i.length;
|
|
1347
|
+
s = function(f) {
|
|
1348
|
+
for (var y = !1, g = 0; g < o; ++g) {
|
|
1349
|
+
var v = i[g], b = e[v];
|
|
1350
|
+
te(f, v) !== b && (H(f, v, b), y = !0);
|
|
1351
|
+
}
|
|
1352
|
+
return y;
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
const u = n.table.core, { outbound: a, extractKey: l } = u.schema.primaryKey, h = this.db._options.modifyChunkSize || 200, c = [];
|
|
1356
|
+
let d = 0;
|
|
1357
|
+
const m = [], p = (f, y) => {
|
|
1358
|
+
const { failures: g, numFailures: v } = y;
|
|
1359
|
+
d += f - v;
|
|
1360
|
+
for (let b of $(g))
|
|
1361
|
+
c.push(g[b]);
|
|
1362
|
+
};
|
|
1363
|
+
return this.clone().primaryKeys().then((f) => {
|
|
1364
|
+
const y = (g) => {
|
|
1365
|
+
const v = Math.min(h, f.length - g);
|
|
1366
|
+
return u.getMany({ trans: r, keys: f.slice(g, g + v), cache: "immutable" }).then((b) => {
|
|
1367
|
+
const x = [], E = [], k = a ? [] : null, w = [];
|
|
1368
|
+
for (let _ = 0; _ < v; ++_) {
|
|
1369
|
+
const j = b[_], O = { value: We(j), primKey: f[g + _] };
|
|
1370
|
+
s.call(O, O.value, O) !== !1 && (O.value == null ? w.push(f[g + _]) : a || L(l(j), l(O.value)) === 0 ? (E.push(O.value), a && k.push(f[g + _])) : (w.push(f[g + _]), x.push(O.value)));
|
|
1371
|
+
}
|
|
1372
|
+
const A = be(n) && n.limit === 1 / 0 && (typeof e != "function" || e === Et) && { index: n.index, range: n.range };
|
|
1373
|
+
return Promise.resolve(x.length > 0 && u.mutate({ trans: r, type: "add", values: x }).then((_) => {
|
|
1374
|
+
for (let j in _.failures)
|
|
1375
|
+
w.splice(parseInt(j), 1);
|
|
1376
|
+
p(x.length, _);
|
|
1377
|
+
})).then(() => (E.length > 0 || A && typeof e == "object") && u.mutate({ trans: r, type: "put", keys: k, values: E, criteria: A, changeSpec: typeof e != "function" && e }).then((_) => p(E.length, _))).then(() => (w.length > 0 || A && e === Et) && u.mutate({ trans: r, type: "delete", keys: w, criteria: A }).then((_) => p(w.length, _))).then(() => f.length > g + v && y(g + h));
|
|
1378
|
+
});
|
|
1379
|
+
};
|
|
1380
|
+
return y(0).then(() => {
|
|
1381
|
+
if (c.length > 0)
|
|
1382
|
+
throw new lt("Error modifying one or more objects", c, d, m);
|
|
1383
|
+
return f.length;
|
|
1384
|
+
});
|
|
1385
|
+
});
|
|
1386
|
+
});
|
|
1387
|
+
}
|
|
1388
|
+
delete() {
|
|
1389
|
+
var e = this._ctx, n = e.range;
|
|
1390
|
+
return be(e) && (e.isPrimKey && !Rr || n.type === 3) ? this._write((r) => {
|
|
1391
|
+
const { primaryKey: s } = e.table.core.schema, i = n;
|
|
1392
|
+
return e.table.core.count({ trans: r, query: { index: s, range: i } }).then((o) => e.table.core.mutate({ trans: r, type: "deleteRange", range: i }).then(({ failures: u, lastResult: a, results: l, numFailures: h }) => {
|
|
1393
|
+
if (h)
|
|
1394
|
+
throw new lt("Could not delete some values", Object.keys(u).map((c) => u[c]), o - h);
|
|
1395
|
+
return o - h;
|
|
1396
|
+
}));
|
|
1397
|
+
}) : this.modify(Et);
|
|
1398
|
+
}
|
|
1399
|
+
}
|
|
1400
|
+
const Et = (t, e) => e.value = null;
|
|
1401
|
+
function $r(t, e) {
|
|
1402
|
+
return t < e ? -1 : t === e ? 0 : 1;
|
|
1403
|
+
}
|
|
1404
|
+
function Nr(t, e) {
|
|
1405
|
+
return t > e ? -1 : t === e ? 0 : 1;
|
|
1406
|
+
}
|
|
1407
|
+
function W(t, e, n) {
|
|
1408
|
+
var r = t instanceof Zn ? new t.Collection(t) : t;
|
|
1409
|
+
return r._ctx.error = n ? new n(e) : new TypeError(e), r;
|
|
1410
|
+
}
|
|
1411
|
+
function we(t) {
|
|
1412
|
+
return new t.Collection(t, () => Jn("")).limit(0);
|
|
1413
|
+
}
|
|
1414
|
+
function Br(t, e, n, r, s, i) {
|
|
1415
|
+
for (var o = Math.min(t.length, r.length), u = -1, a = 0; a < o; ++a) {
|
|
1416
|
+
var l = e[a];
|
|
1417
|
+
if (l !== r[a])
|
|
1418
|
+
return s(t[a], n[a]) < 0 ? t.substr(0, a) + n[a] + n.substr(a + 1) : s(t[a], r[a]) < 0 ? t.substr(0, a) + r[a] + n.substr(a + 1) : u >= 0 ? t.substr(0, u) + e[u] + n.substr(u + 1) : null;
|
|
1419
|
+
s(t[a], l) < 0 && (u = a);
|
|
1420
|
+
}
|
|
1421
|
+
return o < r.length && i === "next" ? t + n.substr(t.length) : o < t.length && i === "prev" ? t.substr(0, n.length) : u < 0 ? null : t.substr(0, u) + r[u] + n.substr(u + 1);
|
|
1422
|
+
}
|
|
1423
|
+
function Ze(t, e, n, r) {
|
|
1424
|
+
var s, i, o, u, a, l, h, c = n.length;
|
|
1425
|
+
if (!n.every((f) => typeof f == "string"))
|
|
1426
|
+
return W(t, Gn);
|
|
1427
|
+
function d(f) {
|
|
1428
|
+
s = function(g) {
|
|
1429
|
+
return g === "next" ? (v) => v.toUpperCase() : (v) => v.toLowerCase();
|
|
1430
|
+
}(f), i = function(g) {
|
|
1431
|
+
return g === "next" ? (v) => v.toLowerCase() : (v) => v.toUpperCase();
|
|
1432
|
+
}(f), o = f === "next" ? $r : Nr;
|
|
1433
|
+
var y = n.map(function(g) {
|
|
1434
|
+
return { lower: i(g), upper: s(g) };
|
|
1435
|
+
}).sort(function(g, v) {
|
|
1436
|
+
return o(g.lower, v.lower);
|
|
1437
|
+
});
|
|
1438
|
+
u = y.map(function(g) {
|
|
1439
|
+
return g.upper;
|
|
1440
|
+
}), a = y.map(function(g) {
|
|
1441
|
+
return g.lower;
|
|
1442
|
+
}), l = f, h = f === "next" ? "" : r;
|
|
1443
|
+
}
|
|
1444
|
+
d("next");
|
|
1445
|
+
var m = new t.Collection(t, () => re(u[0], a[c - 1] + r));
|
|
1446
|
+
m._ondirectionchange = function(f) {
|
|
1447
|
+
d(f);
|
|
1448
|
+
};
|
|
1449
|
+
var p = 0;
|
|
1450
|
+
return m._addAlgorithm(function(f, y, g) {
|
|
1451
|
+
var v = f.key;
|
|
1452
|
+
if (typeof v != "string")
|
|
1453
|
+
return !1;
|
|
1454
|
+
var b = i(v);
|
|
1455
|
+
if (e(b, a, p))
|
|
1456
|
+
return !0;
|
|
1457
|
+
for (var x = null, E = p; E < c; ++E) {
|
|
1458
|
+
var k = Br(v, b, u[E], a[E], o, l);
|
|
1459
|
+
k === null && x === null ? p = E + 1 : (x === null || o(x, k) > 0) && (x = k);
|
|
1460
|
+
}
|
|
1461
|
+
return y(x !== null ? function() {
|
|
1462
|
+
f.continue(x + h);
|
|
1463
|
+
} : g), !1;
|
|
1464
|
+
}), m;
|
|
1465
|
+
}
|
|
1466
|
+
function re(t, e, n, r) {
|
|
1467
|
+
return { type: 2, lower: t, upper: e, lowerOpen: n, upperOpen: r };
|
|
1468
|
+
}
|
|
1469
|
+
function Jn(t) {
|
|
1470
|
+
return { type: 1, lower: t, upper: t };
|
|
1471
|
+
}
|
|
1472
|
+
class Zn {
|
|
1473
|
+
get Collection() {
|
|
1474
|
+
return this._ctx.table.db.Collection;
|
|
1475
|
+
}
|
|
1476
|
+
between(e, n, r, s) {
|
|
1477
|
+
r = r !== !1, s = s === !0;
|
|
1478
|
+
try {
|
|
1479
|
+
return this._cmp(e, n) > 0 || this._cmp(e, n) === 0 && (r || s) && (!r || !s) ? we(this) : new this.Collection(this, () => re(e, n, !r, !s));
|
|
1480
|
+
} catch {
|
|
1481
|
+
return W(this, X);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
equals(e) {
|
|
1485
|
+
return e == null ? W(this, X) : new this.Collection(this, () => Jn(e));
|
|
1486
|
+
}
|
|
1487
|
+
above(e) {
|
|
1488
|
+
return e == null ? W(this, X) : new this.Collection(this, () => re(e, void 0, !0));
|
|
1489
|
+
}
|
|
1490
|
+
aboveOrEqual(e) {
|
|
1491
|
+
return e == null ? W(this, X) : new this.Collection(this, () => re(e, void 0, !1));
|
|
1492
|
+
}
|
|
1493
|
+
below(e) {
|
|
1494
|
+
return e == null ? W(this, X) : new this.Collection(this, () => re(void 0, e, !1, !0));
|
|
1495
|
+
}
|
|
1496
|
+
belowOrEqual(e) {
|
|
1497
|
+
return e == null ? W(this, X) : new this.Collection(this, () => re(void 0, e));
|
|
1498
|
+
}
|
|
1499
|
+
startsWith(e) {
|
|
1500
|
+
return typeof e != "string" ? W(this, Gn) : this.between(e, e + he, !0, !0);
|
|
1501
|
+
}
|
|
1502
|
+
startsWithIgnoreCase(e) {
|
|
1503
|
+
return e === "" ? this.startsWith(e) : Ze(this, (n, r) => n.indexOf(r[0]) === 0, [e], he);
|
|
1504
|
+
}
|
|
1505
|
+
equalsIgnoreCase(e) {
|
|
1506
|
+
return Ze(this, (n, r) => n === r[0], [e], "");
|
|
1507
|
+
}
|
|
1508
|
+
anyOfIgnoreCase() {
|
|
1509
|
+
var e = J.apply(_e, arguments);
|
|
1510
|
+
return e.length === 0 ? we(this) : Ze(this, (n, r) => r.indexOf(n) !== -1, e, "");
|
|
1511
|
+
}
|
|
1512
|
+
startsWithAnyOfIgnoreCase() {
|
|
1513
|
+
var e = J.apply(_e, arguments);
|
|
1514
|
+
return e.length === 0 ? we(this) : Ze(this, (n, r) => r.some((s) => n.indexOf(s) === 0), e, he);
|
|
1515
|
+
}
|
|
1516
|
+
anyOf() {
|
|
1517
|
+
const e = J.apply(_e, arguments);
|
|
1518
|
+
let n = this._cmp;
|
|
1519
|
+
try {
|
|
1520
|
+
e.sort(n);
|
|
1521
|
+
} catch {
|
|
1522
|
+
return W(this, X);
|
|
1523
|
+
}
|
|
1524
|
+
if (e.length === 0)
|
|
1525
|
+
return we(this);
|
|
1526
|
+
const r = new this.Collection(this, () => re(e[0], e[e.length - 1]));
|
|
1527
|
+
r._ondirectionchange = (i) => {
|
|
1528
|
+
n = i === "next" ? this._ascending : this._descending, e.sort(n);
|
|
1529
|
+
};
|
|
1530
|
+
let s = 0;
|
|
1531
|
+
return r._addAlgorithm((i, o, u) => {
|
|
1532
|
+
const a = i.key;
|
|
1533
|
+
for (; n(a, e[s]) > 0; )
|
|
1534
|
+
if (++s, s === e.length)
|
|
1535
|
+
return o(u), !1;
|
|
1536
|
+
return n(a, e[s]) === 0 || (o(() => {
|
|
1537
|
+
i.continue(e[s]);
|
|
1538
|
+
}), !1);
|
|
1539
|
+
}), r;
|
|
1540
|
+
}
|
|
1541
|
+
notEqual(e) {
|
|
1542
|
+
return this.inAnyRange([[qt, e], [e, this.db._maxKey]], { includeLowers: !1, includeUppers: !1 });
|
|
1543
|
+
}
|
|
1544
|
+
noneOf() {
|
|
1545
|
+
const e = J.apply(_e, arguments);
|
|
1546
|
+
if (e.length === 0)
|
|
1547
|
+
return new this.Collection(this);
|
|
1548
|
+
try {
|
|
1549
|
+
e.sort(this._ascending);
|
|
1550
|
+
} catch {
|
|
1551
|
+
return W(this, X);
|
|
1552
|
+
}
|
|
1553
|
+
const n = e.reduce((r, s) => r ? r.concat([[r[r.length - 1][1], s]]) : [[qt, s]], null);
|
|
1554
|
+
return n.push([e[e.length - 1], this.db._maxKey]), this.inAnyRange(n, { includeLowers: !1, includeUppers: !1 });
|
|
1555
|
+
}
|
|
1556
|
+
inAnyRange(e, n) {
|
|
1557
|
+
const r = this._cmp, s = this._ascending, i = this._descending, o = this._min, u = this._max;
|
|
1558
|
+
if (e.length === 0)
|
|
1559
|
+
return we(this);
|
|
1560
|
+
if (!e.every((v) => v[0] !== void 0 && v[1] !== void 0 && s(v[0], v[1]) <= 0))
|
|
1561
|
+
return W(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", C.InvalidArgument);
|
|
1562
|
+
const a = !n || n.includeLowers !== !1, l = n && n.includeUppers === !0;
|
|
1563
|
+
let h, c = s;
|
|
1564
|
+
function d(v, b) {
|
|
1565
|
+
return c(v[0], b[0]);
|
|
1566
|
+
}
|
|
1567
|
+
try {
|
|
1568
|
+
h = e.reduce(function(v, b) {
|
|
1569
|
+
let x = 0, E = v.length;
|
|
1570
|
+
for (; x < E; ++x) {
|
|
1571
|
+
const k = v[x];
|
|
1572
|
+
if (r(b[0], k[1]) < 0 && r(b[1], k[0]) > 0) {
|
|
1573
|
+
k[0] = o(k[0], b[0]), k[1] = u(k[1], b[1]);
|
|
1574
|
+
break;
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
return x === E && v.push(b), v;
|
|
1578
|
+
}, []), h.sort(d);
|
|
1579
|
+
} catch {
|
|
1580
|
+
return W(this, X);
|
|
1581
|
+
}
|
|
1582
|
+
let m = 0;
|
|
1583
|
+
const p = l ? (v) => s(v, h[m][1]) > 0 : (v) => s(v, h[m][1]) >= 0, f = a ? (v) => i(v, h[m][0]) > 0 : (v) => i(v, h[m][0]) >= 0;
|
|
1584
|
+
let y = p;
|
|
1585
|
+
const g = new this.Collection(this, () => re(h[0][0], h[h.length - 1][1], !a, !l));
|
|
1586
|
+
return g._ondirectionchange = (v) => {
|
|
1587
|
+
v === "next" ? (y = p, c = s) : (y = f, c = i), h.sort(d);
|
|
1588
|
+
}, g._addAlgorithm((v, b, x) => {
|
|
1589
|
+
for (var E = v.key; y(E); )
|
|
1590
|
+
if (++m, m === h.length)
|
|
1591
|
+
return b(x), !1;
|
|
1592
|
+
return !!function(k) {
|
|
1593
|
+
return !p(k) && !f(k);
|
|
1594
|
+
}(E) || (this._cmp(E, h[m][1]) === 0 || this._cmp(E, h[m][0]) === 0 || b(() => {
|
|
1595
|
+
c === s ? v.continue(h[m][0]) : v.continue(h[m][1]);
|
|
1596
|
+
}), !1);
|
|
1597
|
+
}), g;
|
|
1598
|
+
}
|
|
1599
|
+
startsWithAnyOf() {
|
|
1600
|
+
const e = J.apply(_e, arguments);
|
|
1601
|
+
return e.every((n) => typeof n == "string") ? e.length === 0 ? we(this) : this.inAnyRange(e.map((n) => [n, n + he])) : W(this, "startsWithAnyOf() only works with strings");
|
|
1602
|
+
}
|
|
1603
|
+
}
|
|
1604
|
+
function Y(t) {
|
|
1605
|
+
return R(function(e) {
|
|
1606
|
+
return qe(e), t(e.target.error), !1;
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
function qe(t) {
|
|
1610
|
+
t.stopPropagation && t.stopPropagation(), t.preventDefault && t.preventDefault();
|
|
1611
|
+
}
|
|
1612
|
+
const Le = "storagemutated", ie = "x-storagemutated-1", ue = $e(null, Le);
|
|
1613
|
+
class Mr {
|
|
1614
|
+
_lock() {
|
|
1615
|
+
return Ie(!P.global), ++this._reculock, this._reculock !== 1 || P.global || (P.lockOwnerFor = this), this;
|
|
1616
|
+
}
|
|
1617
|
+
_unlock() {
|
|
1618
|
+
if (Ie(!P.global), --this._reculock == 0)
|
|
1619
|
+
for (P.global || (P.lockOwnerFor = null); this._blockedFuncs.length > 0 && !this._locked(); ) {
|
|
1620
|
+
var e = this._blockedFuncs.shift();
|
|
1621
|
+
try {
|
|
1622
|
+
Te(e[1], e[0]);
|
|
1623
|
+
} catch {
|
|
1624
|
+
}
|
|
1625
|
+
}
|
|
1626
|
+
return this;
|
|
1627
|
+
}
|
|
1628
|
+
_locked() {
|
|
1629
|
+
return this._reculock && P.lockOwnerFor !== this;
|
|
1630
|
+
}
|
|
1631
|
+
create(e) {
|
|
1632
|
+
if (!this.mode)
|
|
1633
|
+
return this;
|
|
1634
|
+
const n = this.db.idbdb, r = this.db._state.dbOpenError;
|
|
1635
|
+
if (Ie(!this.idbtrans), !e && !n)
|
|
1636
|
+
switch (r && r.name) {
|
|
1637
|
+
case "DatabaseClosedError":
|
|
1638
|
+
throw new C.DatabaseClosed(r);
|
|
1639
|
+
case "MissingAPIError":
|
|
1640
|
+
throw new C.MissingAPI(r.message, r);
|
|
1641
|
+
default:
|
|
1642
|
+
throw new C.OpenFailed(r);
|
|
1643
|
+
}
|
|
1644
|
+
if (!this.active)
|
|
1645
|
+
throw new C.TransactionInactive();
|
|
1646
|
+
return Ie(this._completion._state === null), (e = this.idbtrans = e || (this.db.core ? this.db.core.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }) : n.transaction(this.storeNames, this.mode, { durability: this.chromeTransactionDurability }))).onerror = R((s) => {
|
|
1647
|
+
qe(s), this._reject(e.error);
|
|
1648
|
+
}), e.onabort = R((s) => {
|
|
1649
|
+
qe(s), this.active && this._reject(new C.Abort(e.error)), this.active = !1, this.on("abort").fire(s);
|
|
1650
|
+
}), e.oncomplete = R(() => {
|
|
1651
|
+
this.active = !1, this._resolve(), "mutatedParts" in e && ue.storagemutated.fire(e.mutatedParts);
|
|
1652
|
+
}), this;
|
|
1653
|
+
}
|
|
1654
|
+
_promise(e, n, r) {
|
|
1655
|
+
if (e === "readwrite" && this.mode !== "readwrite")
|
|
1656
|
+
return N(new C.ReadOnly("Transaction is readonly"));
|
|
1657
|
+
if (!this.active)
|
|
1658
|
+
return N(new C.TransactionInactive());
|
|
1659
|
+
if (this._locked())
|
|
1660
|
+
return new S((i, o) => {
|
|
1661
|
+
this._blockedFuncs.push([() => {
|
|
1662
|
+
this._promise(e, n, r).then(i, o);
|
|
1663
|
+
}, P]);
|
|
1664
|
+
});
|
|
1665
|
+
if (r)
|
|
1666
|
+
return oe(() => {
|
|
1667
|
+
var i = new S((o, u) => {
|
|
1668
|
+
this._lock();
|
|
1669
|
+
const a = n(o, u, this);
|
|
1670
|
+
a && a.then && a.then(o, u);
|
|
1671
|
+
});
|
|
1672
|
+
return i.finally(() => this._unlock()), i._lib = !0, i;
|
|
1673
|
+
});
|
|
1674
|
+
var s = new S((i, o) => {
|
|
1675
|
+
var u = n(i, o, this);
|
|
1676
|
+
u && u.then && u.then(i, o);
|
|
1677
|
+
});
|
|
1678
|
+
return s._lib = !0, s;
|
|
1679
|
+
}
|
|
1680
|
+
_root() {
|
|
1681
|
+
return this.parent ? this.parent._root() : this;
|
|
1682
|
+
}
|
|
1683
|
+
waitFor(e) {
|
|
1684
|
+
var n = this._root();
|
|
1685
|
+
const r = S.resolve(e);
|
|
1686
|
+
if (n._waitingFor)
|
|
1687
|
+
n._waitingFor = n._waitingFor.then(() => r);
|
|
1688
|
+
else {
|
|
1689
|
+
n._waitingFor = r, n._waitingQueue = [];
|
|
1690
|
+
var s = n.idbtrans.objectStore(n.storeNames[0]);
|
|
1691
|
+
(function o() {
|
|
1692
|
+
for (++n._spinCount; n._waitingQueue.length; )
|
|
1693
|
+
n._waitingQueue.shift()();
|
|
1694
|
+
n._waitingFor && (s.get(-1 / 0).onsuccess = o);
|
|
1695
|
+
})();
|
|
1696
|
+
}
|
|
1697
|
+
var i = n._waitingFor;
|
|
1698
|
+
return new S((o, u) => {
|
|
1699
|
+
r.then((a) => n._waitingQueue.push(R(o.bind(null, a))), (a) => n._waitingQueue.push(R(u.bind(null, a)))).finally(() => {
|
|
1700
|
+
n._waitingFor === i && (n._waitingFor = null);
|
|
1701
|
+
});
|
|
1702
|
+
});
|
|
1703
|
+
}
|
|
1704
|
+
abort() {
|
|
1705
|
+
this.active && (this.active = !1, this.idbtrans && this.idbtrans.abort(), this._reject(new C.Abort()));
|
|
1706
|
+
}
|
|
1707
|
+
table(e) {
|
|
1708
|
+
const n = this._memoizedTables || (this._memoizedTables = {});
|
|
1709
|
+
if (z(n, e))
|
|
1710
|
+
return n[e];
|
|
1711
|
+
const r = this.schema[e];
|
|
1712
|
+
if (!r)
|
|
1713
|
+
throw new C.NotFound("Table " + e + " not part of transaction");
|
|
1714
|
+
const s = new this.db.Table(e, r, this);
|
|
1715
|
+
return s.core = this.db.core.table(e), n[e] = s, s;
|
|
1716
|
+
}
|
|
1717
|
+
}
|
|
1718
|
+
function Lt(t, e, n, r, s, i, o) {
|
|
1719
|
+
return { name: t, keyPath: e, unique: n, multi: r, auto: s, compound: i, src: (n && !o ? "&" : "") + (r ? "*" : "") + (s ? "++" : "") + er(e) };
|
|
1720
|
+
}
|
|
1721
|
+
function er(t) {
|
|
1722
|
+
return typeof t == "string" ? t : t ? "[" + [].join.call(t, "+") + "]" : "";
|
|
1723
|
+
}
|
|
1724
|
+
function tr(t, e, n) {
|
|
1725
|
+
return { name: t, primKey: e, indexes: n, mappedClass: null, idxByName: Kn(n, (r) => [r.name, r]) };
|
|
1726
|
+
}
|
|
1727
|
+
let Ue = (t) => {
|
|
1728
|
+
try {
|
|
1729
|
+
return t.only([[]]), Ue = () => [[]], [[]];
|
|
1730
|
+
} catch {
|
|
1731
|
+
return Ue = () => he, he;
|
|
1732
|
+
}
|
|
1733
|
+
};
|
|
1734
|
+
function Ut(t) {
|
|
1735
|
+
return t == null ? () => {
|
|
1736
|
+
} : typeof t == "string" ? function(e) {
|
|
1737
|
+
return e.split(".").length === 1 ? (n) => n[e] : (n) => te(n, e);
|
|
1738
|
+
}(t) : (e) => te(e, t);
|
|
1739
|
+
}
|
|
1740
|
+
function En(t) {
|
|
1741
|
+
return [].slice.call(t);
|
|
1742
|
+
}
|
|
1743
|
+
let Fr = 0;
|
|
1744
|
+
function Ne(t) {
|
|
1745
|
+
return t == null ? ":id" : typeof t == "string" ? t : `[${t.join("+")}]`;
|
|
1746
|
+
}
|
|
1747
|
+
function qr(t, e, n) {
|
|
1748
|
+
function r(a) {
|
|
1749
|
+
if (a.type === 3)
|
|
1750
|
+
return null;
|
|
1751
|
+
if (a.type === 4)
|
|
1752
|
+
throw new Error("Cannot convert never type to IDBKeyRange");
|
|
1753
|
+
const { lower: l, upper: h, lowerOpen: c, upperOpen: d } = a;
|
|
1754
|
+
return l === void 0 ? h === void 0 ? null : e.upperBound(h, !!d) : h === void 0 ? e.lowerBound(l, !!c) : e.bound(l, h, !!c, !!d);
|
|
1755
|
+
}
|
|
1756
|
+
const { schema: s, hasGetAll: i } = function(a, l) {
|
|
1757
|
+
const h = En(a.objectStoreNames);
|
|
1758
|
+
return { schema: { name: a.name, tables: h.map((c) => l.objectStore(c)).map((c) => {
|
|
1759
|
+
const { keyPath: d, autoIncrement: m } = c, p = F(d), f = d == null, y = {}, g = { name: c.name, primaryKey: { name: null, isPrimaryKey: !0, outbound: f, compound: p, keyPath: d, autoIncrement: m, unique: !0, extractKey: Ut(d) }, indexes: En(c.indexNames).map((v) => c.index(v)).map((v) => {
|
|
1760
|
+
const { name: b, unique: x, multiEntry: E, keyPath: k } = v, w = { name: b, compound: F(k), keyPath: k, unique: x, multiEntry: E, extractKey: Ut(k) };
|
|
1761
|
+
return y[Ne(k)] = w, w;
|
|
1762
|
+
}), getIndexByKeyPath: (v) => y[Ne(v)] };
|
|
1763
|
+
return y[":id"] = g.primaryKey, d != null && (y[Ne(d)] = g.primaryKey), g;
|
|
1764
|
+
}) }, hasGetAll: h.length > 0 && "getAll" in l.objectStore(h[0]) && !(typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604) };
|
|
1765
|
+
}(t, n), o = s.tables.map((a) => function(l) {
|
|
1766
|
+
const h = l.name;
|
|
1767
|
+
return { name: h, schema: l, mutate: function({ trans: c, type: d, keys: m, values: p, range: f }) {
|
|
1768
|
+
return new Promise((y, g) => {
|
|
1769
|
+
y = R(y);
|
|
1770
|
+
const v = c.objectStore(h), b = v.keyPath == null, x = d === "put" || d === "add";
|
|
1771
|
+
if (!x && d !== "delete" && d !== "deleteRange")
|
|
1772
|
+
throw new Error("Invalid operation type: " + d);
|
|
1773
|
+
const { length: E } = m || p || { length: 1 };
|
|
1774
|
+
if (m && p && m.length !== p.length)
|
|
1775
|
+
throw new Error("Given keys array must have same length as given values array.");
|
|
1776
|
+
if (E === 0)
|
|
1777
|
+
return y({ numFailures: 0, failures: {}, results: [], lastResult: void 0 });
|
|
1778
|
+
let k;
|
|
1779
|
+
const w = [], A = [];
|
|
1780
|
+
let _ = 0;
|
|
1781
|
+
const j = (q) => {
|
|
1782
|
+
++_, qe(q);
|
|
1783
|
+
};
|
|
1784
|
+
if (d === "deleteRange") {
|
|
1785
|
+
if (f.type === 4)
|
|
1786
|
+
return y({ numFailures: _, failures: A, results: [], lastResult: void 0 });
|
|
1787
|
+
f.type === 3 ? w.push(k = v.clear()) : w.push(k = v.delete(r(f)));
|
|
1788
|
+
} else {
|
|
1789
|
+
const [q, B] = x ? b ? [p, m] : [p, null] : [m, null];
|
|
1790
|
+
if (x)
|
|
1791
|
+
for (let D = 0; D < E; ++D)
|
|
1792
|
+
w.push(k = B && B[D] !== void 0 ? v[d](q[D], B[D]) : v[d](q[D])), k.onerror = j;
|
|
1793
|
+
else
|
|
1794
|
+
for (let D = 0; D < E; ++D)
|
|
1795
|
+
w.push(k = v[d](q[D])), k.onerror = j;
|
|
1796
|
+
}
|
|
1797
|
+
const O = (q) => {
|
|
1798
|
+
const B = q.target.result;
|
|
1799
|
+
w.forEach((D, ye) => D.error != null && (A[ye] = D.error)), y({ numFailures: _, failures: A, results: d === "delete" ? m : w.map((D) => D.result), lastResult: B });
|
|
1800
|
+
};
|
|
1801
|
+
k.onerror = (q) => {
|
|
1802
|
+
j(q), O(q);
|
|
1803
|
+
}, k.onsuccess = O;
|
|
1804
|
+
});
|
|
1805
|
+
}, getMany: ({ trans: c, keys: d }) => new Promise((m, p) => {
|
|
1806
|
+
m = R(m);
|
|
1807
|
+
const f = c.objectStore(h), y = d.length, g = new Array(y);
|
|
1808
|
+
let v, b = 0, x = 0;
|
|
1809
|
+
const E = (w) => {
|
|
1810
|
+
const A = w.target;
|
|
1811
|
+
g[A._pos] = A.result, ++x === b && m(g);
|
|
1812
|
+
}, k = Y(p);
|
|
1813
|
+
for (let w = 0; w < y; ++w)
|
|
1814
|
+
d[w] != null && (v = f.get(d[w]), v._pos = w, v.onsuccess = E, v.onerror = k, ++b);
|
|
1815
|
+
b === 0 && m(g);
|
|
1816
|
+
}), get: ({ trans: c, key: d }) => new Promise((m, p) => {
|
|
1817
|
+
m = R(m);
|
|
1818
|
+
const f = c.objectStore(h).get(d);
|
|
1819
|
+
f.onsuccess = (y) => m(y.target.result), f.onerror = Y(p);
|
|
1820
|
+
}), query: function(c) {
|
|
1821
|
+
return (d) => new Promise((m, p) => {
|
|
1822
|
+
m = R(m);
|
|
1823
|
+
const { trans: f, values: y, limit: g, query: v } = d, b = g === 1 / 0 ? void 0 : g, { index: x, range: E } = v, k = f.objectStore(h), w = x.isPrimaryKey ? k : k.index(x.name), A = r(E);
|
|
1824
|
+
if (g === 0)
|
|
1825
|
+
return m({ result: [] });
|
|
1826
|
+
if (c) {
|
|
1827
|
+
const _ = y ? w.getAll(A, b) : w.getAllKeys(A, b);
|
|
1828
|
+
_.onsuccess = (j) => m({ result: j.target.result }), _.onerror = Y(p);
|
|
1829
|
+
} else {
|
|
1830
|
+
let _ = 0;
|
|
1831
|
+
const j = y || !("openKeyCursor" in w) ? w.openCursor(A) : w.openKeyCursor(A), O = [];
|
|
1832
|
+
j.onsuccess = (q) => {
|
|
1833
|
+
const B = j.result;
|
|
1834
|
+
return B ? (O.push(y ? B.value : B.primaryKey), ++_ === g ? m({ result: O }) : void B.continue()) : m({ result: O });
|
|
1835
|
+
}, j.onerror = Y(p);
|
|
1836
|
+
}
|
|
1837
|
+
});
|
|
1838
|
+
}(i), openCursor: function({ trans: c, values: d, query: m, reverse: p, unique: f }) {
|
|
1839
|
+
return new Promise((y, g) => {
|
|
1840
|
+
y = R(y);
|
|
1841
|
+
const { index: v, range: b } = m, x = c.objectStore(h), E = v.isPrimaryKey ? x : x.index(v.name), k = p ? f ? "prevunique" : "prev" : f ? "nextunique" : "next", w = d || !("openKeyCursor" in E) ? E.openCursor(r(b), k) : E.openKeyCursor(r(b), k);
|
|
1842
|
+
w.onerror = Y(g), w.onsuccess = R((A) => {
|
|
1843
|
+
const _ = w.result;
|
|
1844
|
+
if (!_)
|
|
1845
|
+
return void y(null);
|
|
1846
|
+
_.___id = ++Fr, _.done = !1;
|
|
1847
|
+
const j = _.continue.bind(_);
|
|
1848
|
+
let O = _.continuePrimaryKey;
|
|
1849
|
+
O && (O = O.bind(_));
|
|
1850
|
+
const q = _.advance.bind(_), B = () => {
|
|
1851
|
+
throw new Error("Cursor not stopped");
|
|
1852
|
+
};
|
|
1853
|
+
_.trans = c, _.stop = _.continue = _.continuePrimaryKey = _.advance = () => {
|
|
1854
|
+
throw new Error("Cursor not started");
|
|
1855
|
+
}, _.fail = R(g), _.next = function() {
|
|
1856
|
+
let D = 1;
|
|
1857
|
+
return this.start(() => D-- ? this.continue() : this.stop()).then(() => this);
|
|
1858
|
+
}, _.start = (D) => {
|
|
1859
|
+
const ye = new Promise((V, ce) => {
|
|
1860
|
+
V = R(V), w.onerror = Y(ce), _.fail = ce, _.stop = (Ae) => {
|
|
1861
|
+
_.stop = _.continue = _.continuePrimaryKey = _.advance = B, V(Ae);
|
|
1862
|
+
};
|
|
1863
|
+
}), ve = () => {
|
|
1864
|
+
if (w.result)
|
|
1865
|
+
try {
|
|
1866
|
+
D();
|
|
1867
|
+
} catch (V) {
|
|
1868
|
+
_.fail(V);
|
|
1869
|
+
}
|
|
1870
|
+
else
|
|
1871
|
+
_.done = !0, _.start = () => {
|
|
1872
|
+
throw new Error("Cursor behind last entry");
|
|
1873
|
+
}, _.stop();
|
|
1874
|
+
};
|
|
1875
|
+
return w.onsuccess = R((V) => {
|
|
1876
|
+
w.onsuccess = ve, ve();
|
|
1877
|
+
}), _.continue = j, _.continuePrimaryKey = O, _.advance = q, ve(), ye;
|
|
1878
|
+
}, y(_);
|
|
1879
|
+
}, g);
|
|
1880
|
+
});
|
|
1881
|
+
}, count({ query: c, trans: d }) {
|
|
1882
|
+
const { index: m, range: p } = c;
|
|
1883
|
+
return new Promise((f, y) => {
|
|
1884
|
+
const g = d.objectStore(h), v = m.isPrimaryKey ? g : g.index(m.name), b = r(p), x = b ? v.count(b) : v.count();
|
|
1885
|
+
x.onsuccess = R((E) => f(E.target.result)), x.onerror = Y(y);
|
|
1886
|
+
});
|
|
1887
|
+
} };
|
|
1888
|
+
}(a)), u = {};
|
|
1889
|
+
return o.forEach((a) => u[a.name] = a), { stack: "dbcore", transaction: t.transaction.bind(t), table(a) {
|
|
1890
|
+
if (!u[a])
|
|
1891
|
+
throw new Error(`Table '${a}' not found`);
|
|
1892
|
+
return u[a];
|
|
1893
|
+
}, MIN_KEY: -1 / 0, MAX_KEY: Ue(e), schema: s };
|
|
1894
|
+
}
|
|
1895
|
+
function Vt({ _novip: t }, e) {
|
|
1896
|
+
const n = e.db, r = function(s, i, { IDBKeyRange: o, indexedDB: u }, a) {
|
|
1897
|
+
return { dbcore: function(l, h) {
|
|
1898
|
+
return h.reduce((c, { create: d }) => ({ ...c, ...d(c) }), l);
|
|
1899
|
+
}(qr(i, o, a), s.dbcore) };
|
|
1900
|
+
}(t._middlewares, n, t._deps, e);
|
|
1901
|
+
t.core = r.dbcore, t.tables.forEach((s) => {
|
|
1902
|
+
const i = s.name;
|
|
1903
|
+
t.core.schema.tables.some((o) => o.name === i) && (s.core = t.core.table(i), t[i] instanceof t.Table && (t[i].core = s.core));
|
|
1904
|
+
});
|
|
1905
|
+
}
|
|
1906
|
+
function mt({ _novip: t }, e, n, r) {
|
|
1907
|
+
n.forEach((s) => {
|
|
1908
|
+
const i = r[s];
|
|
1909
|
+
e.forEach((o) => {
|
|
1910
|
+
const u = Zt(o, s);
|
|
1911
|
+
(!u || "value" in u && u.value === void 0) && (o === t.Transaction.prototype || o instanceof t.Transaction ? ee(o, s, { get() {
|
|
1912
|
+
return this.table(s);
|
|
1913
|
+
}, set(a) {
|
|
1914
|
+
An(this, s, { value: a, writable: !0, configurable: !0, enumerable: !0 });
|
|
1915
|
+
} }) : o[s] = new t.Table(s, i));
|
|
1916
|
+
});
|
|
1917
|
+
});
|
|
1918
|
+
}
|
|
1919
|
+
function Wt({ _novip: t }, e) {
|
|
1920
|
+
e.forEach((n) => {
|
|
1921
|
+
for (let r in n)
|
|
1922
|
+
n[r] instanceof t.Table && delete n[r];
|
|
1923
|
+
});
|
|
1924
|
+
}
|
|
1925
|
+
function Lr(t, e) {
|
|
1926
|
+
return t._cfg.version - e._cfg.version;
|
|
1927
|
+
}
|
|
1928
|
+
function Ur(t, e, n, r) {
|
|
1929
|
+
const s = t._dbSchema, i = t._createTransaction("readwrite", t._storeNames, s);
|
|
1930
|
+
i.create(n), i._completion.catch(r);
|
|
1931
|
+
const o = i._reject.bind(i), u = P.transless || P;
|
|
1932
|
+
oe(() => {
|
|
1933
|
+
P.trans = i, P.transless = u, e === 0 ? ($(s).forEach((a) => {
|
|
1934
|
+
Pt(n, a, s[a].primKey, s[a].indexes);
|
|
1935
|
+
}), Vt(t, n), S.follow(() => t.on.populate.fire(i)).catch(o)) : function({ _novip: a }, l, h, c) {
|
|
1936
|
+
const d = [], m = a._versions;
|
|
1937
|
+
let p = a._dbSchema = Ht(a, a.idbdb, c), f = !1;
|
|
1938
|
+
const y = m.filter((v) => v._cfg.version >= l);
|
|
1939
|
+
function g() {
|
|
1940
|
+
return d.length ? S.resolve(d.shift()(h.idbtrans)).then(g) : S.resolve();
|
|
1941
|
+
}
|
|
1942
|
+
return y.forEach((v) => {
|
|
1943
|
+
d.push(() => {
|
|
1944
|
+
const b = p, x = v._cfg.dbschema;
|
|
1945
|
+
Yt(a, b, c), Yt(a, x, c), p = a._dbSchema = x;
|
|
1946
|
+
const E = nr(b, x);
|
|
1947
|
+
E.add.forEach((w) => {
|
|
1948
|
+
Pt(c, w[0], w[1].primKey, w[1].indexes);
|
|
1949
|
+
}), E.change.forEach((w) => {
|
|
1950
|
+
if (w.recreate)
|
|
1951
|
+
throw new C.Upgrade("Not yet support for changing primary key");
|
|
1952
|
+
{
|
|
1953
|
+
const A = c.objectStore(w.name);
|
|
1954
|
+
w.add.forEach((_) => zt(A, _)), w.change.forEach((_) => {
|
|
1955
|
+
A.deleteIndex(_.name), zt(A, _);
|
|
1956
|
+
}), w.del.forEach((_) => A.deleteIndex(_));
|
|
1957
|
+
}
|
|
1958
|
+
});
|
|
1959
|
+
const k = v._cfg.contentUpgrade;
|
|
1960
|
+
if (k && v._cfg.version > l) {
|
|
1961
|
+
Vt(a, c), h._memoizedTables = {}, f = !0;
|
|
1962
|
+
let w = Rn(x);
|
|
1963
|
+
E.del.forEach((O) => {
|
|
1964
|
+
w[O] = b[O];
|
|
1965
|
+
}), Wt(a, [a.Transaction.prototype]), mt(a, [a.Transaction.prototype], $(w), w), h.schema = w;
|
|
1966
|
+
const A = en(k);
|
|
1967
|
+
let _;
|
|
1968
|
+
A && Ce();
|
|
1969
|
+
const j = S.follow(() => {
|
|
1970
|
+
if (_ = k(h), _ && A) {
|
|
1971
|
+
var O = ne.bind(null, null);
|
|
1972
|
+
_.then(O, O);
|
|
1973
|
+
}
|
|
1974
|
+
});
|
|
1975
|
+
return _ && typeof _.then == "function" ? S.resolve(_) : j.then(() => _);
|
|
1976
|
+
}
|
|
1977
|
+
}), d.push((b) => {
|
|
1978
|
+
(!f || !Kr) && function(x, E) {
|
|
1979
|
+
[].slice.call(E.db.objectStoreNames).forEach((k) => x[k] == null && E.db.deleteObjectStore(k));
|
|
1980
|
+
}(v._cfg.dbschema, b), Wt(a, [a.Transaction.prototype]), mt(a, [a.Transaction.prototype], a._storeNames, a._dbSchema), h.schema = a._dbSchema;
|
|
1981
|
+
});
|
|
1982
|
+
}), g().then(() => {
|
|
1983
|
+
var v, b;
|
|
1984
|
+
b = c, $(v = p).forEach((x) => {
|
|
1985
|
+
b.db.objectStoreNames.contains(x) || Pt(b, x, v[x].primKey, v[x].indexes);
|
|
1986
|
+
});
|
|
1987
|
+
});
|
|
1988
|
+
}(t, e, i, n).catch(o);
|
|
1989
|
+
});
|
|
1990
|
+
}
|
|
1991
|
+
function nr(t, e) {
|
|
1992
|
+
const n = { del: [], add: [], change: [] };
|
|
1993
|
+
let r;
|
|
1994
|
+
for (r in t)
|
|
1995
|
+
e[r] || n.del.push(r);
|
|
1996
|
+
for (r in e) {
|
|
1997
|
+
const s = t[r], i = e[r];
|
|
1998
|
+
if (s) {
|
|
1999
|
+
const o = { name: r, def: i, recreate: !1, del: [], add: [], change: [] };
|
|
2000
|
+
if ("" + (s.primKey.keyPath || "") != "" + (i.primKey.keyPath || "") || s.primKey.auto !== i.primKey.auto && !yt)
|
|
2001
|
+
o.recreate = !0, n.change.push(o);
|
|
2002
|
+
else {
|
|
2003
|
+
const u = s.idxByName, a = i.idxByName;
|
|
2004
|
+
let l;
|
|
2005
|
+
for (l in u)
|
|
2006
|
+
a[l] || o.del.push(l);
|
|
2007
|
+
for (l in a) {
|
|
2008
|
+
const h = u[l], c = a[l];
|
|
2009
|
+
h ? h.src !== c.src && o.change.push(c) : o.add.push(c);
|
|
2010
|
+
}
|
|
2011
|
+
(o.del.length > 0 || o.add.length > 0 || o.change.length > 0) && n.change.push(o);
|
|
2012
|
+
}
|
|
2013
|
+
} else
|
|
2014
|
+
n.add.push([r, i]);
|
|
2015
|
+
}
|
|
2016
|
+
return n;
|
|
2017
|
+
}
|
|
2018
|
+
function Pt(t, e, n, r) {
|
|
2019
|
+
const s = t.db.createObjectStore(e, n.keyPath ? { keyPath: n.keyPath, autoIncrement: n.auto } : { autoIncrement: n.auto });
|
|
2020
|
+
return r.forEach((i) => zt(s, i)), s;
|
|
2021
|
+
}
|
|
2022
|
+
function zt(t, e) {
|
|
2023
|
+
t.createIndex(e.name, e.keyPath, { unique: e.unique, multiEntry: e.multi });
|
|
2024
|
+
}
|
|
2025
|
+
function Ht(t, e, n) {
|
|
2026
|
+
const r = {};
|
|
2027
|
+
return ct(e.objectStoreNames, 0).forEach((s) => {
|
|
2028
|
+
const i = n.objectStore(s);
|
|
2029
|
+
let o = i.keyPath;
|
|
2030
|
+
const u = Lt(er(o), o || "", !1, !1, !!i.autoIncrement, o && typeof o != "string", !0), a = [];
|
|
2031
|
+
for (let h = 0; h < i.indexNames.length; ++h) {
|
|
2032
|
+
const c = i.index(i.indexNames[h]);
|
|
2033
|
+
o = c.keyPath;
|
|
2034
|
+
var l = Lt(c.name, o, !!c.unique, !!c.multiEntry, !1, o && typeof o != "string", !1);
|
|
2035
|
+
a.push(l);
|
|
2036
|
+
}
|
|
2037
|
+
r[s] = tr(s, u, a);
|
|
2038
|
+
}), r;
|
|
2039
|
+
}
|
|
2040
|
+
function Yt({ _novip: t }, e, n) {
|
|
2041
|
+
const r = n.db.objectStoreNames;
|
|
2042
|
+
for (let s = 0; s < r.length; ++s) {
|
|
2043
|
+
const i = r[s], o = n.objectStore(i);
|
|
2044
|
+
t._hasGetAll = "getAll" in o;
|
|
2045
|
+
for (let u = 0; u < o.indexNames.length; ++u) {
|
|
2046
|
+
const a = o.indexNames[u], l = o.index(a).keyPath, h = typeof l == "string" ? l : "[" + ct(l).join("+") + "]";
|
|
2047
|
+
if (e[i]) {
|
|
2048
|
+
const c = e[i].idxByName[h];
|
|
2049
|
+
c && (c.name = a, delete e[i].idxByName[h], e[i].idxByName[a] = c);
|
|
2050
|
+
}
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && K.WorkerGlobalScope && K instanceof K.WorkerGlobalScope && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604 && (t._hasGetAll = !1);
|
|
2054
|
+
}
|
|
2055
|
+
class Vr {
|
|
2056
|
+
_parseStoresSpec(e, n) {
|
|
2057
|
+
$(e).forEach((r) => {
|
|
2058
|
+
if (e[r] !== null) {
|
|
2059
|
+
var s = e[r].split(",").map((o, u) => {
|
|
2060
|
+
const a = (o = o.trim()).replace(/([&*]|\+\+)/g, ""), l = /^\[/.test(a) ? a.match(/^\[(.*)\]$/)[1].split("+") : a;
|
|
2061
|
+
return Lt(a, l || null, /\&/.test(o), /\*/.test(o), /\+\+/.test(o), F(l), u === 0);
|
|
2062
|
+
}), i = s.shift();
|
|
2063
|
+
if (i.multi)
|
|
2064
|
+
throw new C.Schema("Primary key cannot be multi-valued");
|
|
2065
|
+
s.forEach((o) => {
|
|
2066
|
+
if (o.auto)
|
|
2067
|
+
throw new C.Schema("Only primary key can be marked as autoIncrement (++)");
|
|
2068
|
+
if (!o.keyPath)
|
|
2069
|
+
throw new C.Schema("Index must have a name and cannot be an empty string");
|
|
2070
|
+
}), n[r] = tr(r, i, s);
|
|
2071
|
+
}
|
|
2072
|
+
});
|
|
2073
|
+
}
|
|
2074
|
+
stores(e) {
|
|
2075
|
+
const n = this.db;
|
|
2076
|
+
this._cfg.storesSource = this._cfg.storesSource ? U(this._cfg.storesSource, e) : e;
|
|
2077
|
+
const r = n._versions, s = {};
|
|
2078
|
+
let i = {};
|
|
2079
|
+
return r.forEach((o) => {
|
|
2080
|
+
U(s, o._cfg.storesSource), i = o._cfg.dbschema = {}, o._parseStoresSpec(s, i);
|
|
2081
|
+
}), n._dbSchema = i, Wt(n, [n._allTables, n, n.Transaction.prototype]), mt(n, [n._allTables, n, n.Transaction.prototype, this._cfg.tables], $(i), i), n._storeNames = $(i), this;
|
|
2082
|
+
}
|
|
2083
|
+
upgrade(e) {
|
|
2084
|
+
return this._cfg.contentUpgrade = rn(this._cfg.contentUpgrade || I, e), this;
|
|
2085
|
+
}
|
|
2086
|
+
}
|
|
2087
|
+
function un(t, e) {
|
|
2088
|
+
let n = t._dbNamesDB;
|
|
2089
|
+
return n || (n = t._dbNamesDB = new pe(vt, { addons: [], indexedDB: t, IDBKeyRange: e }), n.version(1).stores({ dbnames: "name" })), n.table("dbnames");
|
|
2090
|
+
}
|
|
2091
|
+
function cn(t) {
|
|
2092
|
+
return t && typeof t.databases == "function";
|
|
2093
|
+
}
|
|
2094
|
+
function Gt(t) {
|
|
2095
|
+
return oe(function() {
|
|
2096
|
+
return P.letThrough = !0, t();
|
|
2097
|
+
});
|
|
2098
|
+
}
|
|
2099
|
+
function Wr() {
|
|
2100
|
+
var t;
|
|
2101
|
+
return !navigator.userAgentData && /Safari\//.test(navigator.userAgent) && !/Chrom(e|ium)\//.test(navigator.userAgent) && indexedDB.databases ? new Promise(function(e) {
|
|
2102
|
+
var n = function() {
|
|
2103
|
+
return indexedDB.databases().finally(e);
|
|
2104
|
+
};
|
|
2105
|
+
t = setInterval(n, 100), n();
|
|
2106
|
+
}).finally(function() {
|
|
2107
|
+
return clearInterval(t);
|
|
2108
|
+
}) : Promise.resolve();
|
|
2109
|
+
}
|
|
2110
|
+
function zr(t) {
|
|
2111
|
+
const e = t._state, { indexedDB: n } = t._deps;
|
|
2112
|
+
if (e.isBeingOpened || t.idbdb)
|
|
2113
|
+
return e.dbReadyPromise.then(() => e.dbOpenError ? N(e.dbOpenError) : t);
|
|
2114
|
+
G && (e.openCanceller._stackHolder = Pe()), e.isBeingOpened = !0, e.dbOpenError = null, e.openComplete = !1;
|
|
2115
|
+
const r = e.openCanceller;
|
|
2116
|
+
function s() {
|
|
2117
|
+
if (e.openCanceller !== r)
|
|
2118
|
+
throw new C.DatabaseClosed("db.open() was cancelled");
|
|
2119
|
+
}
|
|
2120
|
+
let i = e.dbReadyResolve, o = null, u = !1;
|
|
2121
|
+
return S.race([r, (typeof navigator > "u" ? S.resolve() : Wr()).then(() => new S((a, l) => {
|
|
2122
|
+
if (s(), !n)
|
|
2123
|
+
throw new C.MissingAPI();
|
|
2124
|
+
const h = t.name, c = e.autoSchema ? n.open(h) : n.open(h, Math.round(10 * t.verno));
|
|
2125
|
+
if (!c)
|
|
2126
|
+
throw new C.MissingAPI();
|
|
2127
|
+
c.onerror = Y(l), c.onblocked = R(t._fireOnBlocked), c.onupgradeneeded = R((d) => {
|
|
2128
|
+
if (o = c.transaction, e.autoSchema && !t._options.allowEmptyDB) {
|
|
2129
|
+
c.onerror = qe, o.abort(), c.result.close();
|
|
2130
|
+
const p = n.deleteDatabase(h);
|
|
2131
|
+
p.onsuccess = p.onerror = R(() => {
|
|
2132
|
+
l(new C.NoSuchDatabase(`Database ${h} doesnt exist`));
|
|
2133
|
+
});
|
|
2134
|
+
} else {
|
|
2135
|
+
o.onerror = Y(l);
|
|
2136
|
+
var m = d.oldVersion > Math.pow(2, 62) ? 0 : d.oldVersion;
|
|
2137
|
+
u = m < 1, t._novip.idbdb = c.result, Ur(t, m / 10, o, l);
|
|
2138
|
+
}
|
|
2139
|
+
}, l), c.onsuccess = R(() => {
|
|
2140
|
+
o = null;
|
|
2141
|
+
const d = t._novip.idbdb = c.result, m = ct(d.objectStoreNames);
|
|
2142
|
+
if (m.length > 0)
|
|
2143
|
+
try {
|
|
2144
|
+
const f = d.transaction((p = m).length === 1 ? p[0] : p, "readonly");
|
|
2145
|
+
e.autoSchema ? function({ _novip: y }, g, v) {
|
|
2146
|
+
y.verno = g.version / 10;
|
|
2147
|
+
const b = y._dbSchema = Ht(0, g, v);
|
|
2148
|
+
y._storeNames = ct(g.objectStoreNames, 0), mt(y, [y._allTables], $(b), b);
|
|
2149
|
+
}(t, d, f) : (Yt(t, t._dbSchema, f), function(y, g) {
|
|
2150
|
+
const v = nr(Ht(0, y.idbdb, g), y._dbSchema);
|
|
2151
|
+
return !(v.add.length || v.change.some((b) => b.add.length || b.change.length));
|
|
2152
|
+
}(t, f) || console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")), Vt(t, f);
|
|
2153
|
+
} catch {
|
|
2154
|
+
}
|
|
2155
|
+
var p;
|
|
2156
|
+
De.push(t), d.onversionchange = R((f) => {
|
|
2157
|
+
e.vcFired = !0, t.on("versionchange").fire(f);
|
|
2158
|
+
}), d.onclose = R((f) => {
|
|
2159
|
+
t.on("close").fire(f);
|
|
2160
|
+
}), u && function({ indexedDB: f, IDBKeyRange: y }, g) {
|
|
2161
|
+
!cn(f) && g !== vt && un(f, y).put({ name: g }).catch(I);
|
|
2162
|
+
}(t._deps, h), a();
|
|
2163
|
+
}, l);
|
|
2164
|
+
}))]).then(() => (s(), e.onReadyBeingFired = [], S.resolve(Gt(() => t.on.ready.fire(t.vip))).then(function a() {
|
|
2165
|
+
if (e.onReadyBeingFired.length > 0) {
|
|
2166
|
+
let l = e.onReadyBeingFired.reduce(rn, I);
|
|
2167
|
+
return e.onReadyBeingFired = [], S.resolve(Gt(() => l(t.vip))).then(a);
|
|
2168
|
+
}
|
|
2169
|
+
}))).finally(() => {
|
|
2170
|
+
e.onReadyBeingFired = null, e.isBeingOpened = !1;
|
|
2171
|
+
}).then(() => t).catch((a) => {
|
|
2172
|
+
e.dbOpenError = a;
|
|
2173
|
+
try {
|
|
2174
|
+
o && o.abort();
|
|
2175
|
+
} catch {
|
|
2176
|
+
}
|
|
2177
|
+
return r === e.openCanceller && t._close(), N(a);
|
|
2178
|
+
}).finally(() => {
|
|
2179
|
+
e.openComplete = !0, i();
|
|
2180
|
+
});
|
|
2181
|
+
}
|
|
2182
|
+
function Xt(t) {
|
|
2183
|
+
var e = (i) => t.next(i), n = s(e), r = s((i) => t.throw(i));
|
|
2184
|
+
function s(i) {
|
|
2185
|
+
return (o) => {
|
|
2186
|
+
var u = i(o), a = u.value;
|
|
2187
|
+
return u.done ? a : a && typeof a.then == "function" ? a.then(n, r) : F(a) ? Promise.all(a).then(n, r) : n(a);
|
|
2188
|
+
};
|
|
2189
|
+
}
|
|
2190
|
+
return s(e)();
|
|
2191
|
+
}
|
|
2192
|
+
function Hr(t, e, n) {
|
|
2193
|
+
var r = arguments.length;
|
|
2194
|
+
if (r < 2)
|
|
2195
|
+
throw new C.InvalidArgument("Too few arguments");
|
|
2196
|
+
for (var s = new Array(r - 1); --r; )
|
|
2197
|
+
s[r - 1] = arguments[r];
|
|
2198
|
+
return n = s.pop(), [t, jn(s), n];
|
|
2199
|
+
}
|
|
2200
|
+
function rr(t, e, n, r, s) {
|
|
2201
|
+
return S.resolve().then(() => {
|
|
2202
|
+
const i = P.transless || P, o = t._createTransaction(e, n, t._dbSchema, r), u = { trans: o, transless: i };
|
|
2203
|
+
if (r)
|
|
2204
|
+
o.idbtrans = r.idbtrans;
|
|
2205
|
+
else
|
|
2206
|
+
try {
|
|
2207
|
+
o.create(), t._state.PR1398_maxLoop = 3;
|
|
2208
|
+
} catch (c) {
|
|
2209
|
+
return c.name === nn.InvalidState && t.isOpen() && --t._state.PR1398_maxLoop > 0 ? (console.warn("Dexie: Need to reopen db"), t._close(), t.open().then(() => rr(t, e, n, null, s))) : N(c);
|
|
2210
|
+
}
|
|
2211
|
+
const a = en(s);
|
|
2212
|
+
let l;
|
|
2213
|
+
a && Ce();
|
|
2214
|
+
const h = S.follow(() => {
|
|
2215
|
+
if (l = s.call(o, o), l)
|
|
2216
|
+
if (a) {
|
|
2217
|
+
var c = ne.bind(null, null);
|
|
2218
|
+
l.then(c, c);
|
|
2219
|
+
} else
|
|
2220
|
+
typeof l.next == "function" && typeof l.throw == "function" && (l = Xt(l));
|
|
2221
|
+
}, u);
|
|
2222
|
+
return (l && typeof l.then == "function" ? S.resolve(l).then((c) => o.active ? c : N(new C.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))) : h.then(() => l)).then((c) => (r && o._resolve(), o._completion.then(() => c))).catch((c) => (o._reject(c), N(c)));
|
|
2223
|
+
});
|
|
2224
|
+
}
|
|
2225
|
+
function et(t, e, n) {
|
|
2226
|
+
const r = F(t) ? t.slice() : [t];
|
|
2227
|
+
for (let s = 0; s < n; ++s)
|
|
2228
|
+
r.push(e);
|
|
2229
|
+
return r;
|
|
2230
|
+
}
|
|
2231
|
+
const Yr = { stack: "dbcore", name: "VirtualIndexMiddleware", level: 1, create: function(t) {
|
|
2232
|
+
return { ...t, table(e) {
|
|
2233
|
+
const n = t.table(e), { schema: r } = n, s = {}, i = [];
|
|
2234
|
+
function o(l, h, c) {
|
|
2235
|
+
const d = Ne(l), m = s[d] = s[d] || [], p = l == null ? 0 : typeof l == "string" ? 1 : l.length, f = h > 0, y = { ...c, isVirtual: f, keyTail: h, keyLength: p, extractKey: Ut(l), unique: !f && c.unique };
|
|
2236
|
+
return m.push(y), y.isPrimaryKey || i.push(y), p > 1 && o(p === 2 ? l[0] : l.slice(0, p - 1), h + 1, c), m.sort((g, v) => g.keyTail - v.keyTail), y;
|
|
2237
|
+
}
|
|
2238
|
+
const u = o(r.primaryKey.keyPath, 0, r.primaryKey);
|
|
2239
|
+
s[":id"] = [u];
|
|
2240
|
+
for (const l of r.indexes)
|
|
2241
|
+
o(l.keyPath, 0, l);
|
|
2242
|
+
function a(l) {
|
|
2243
|
+
const h = l.query.index;
|
|
2244
|
+
return h.isVirtual ? { ...l, query: { index: h, range: (c = l.query.range, d = h.keyTail, { type: c.type === 1 ? 2 : c.type, lower: et(c.lower, c.lowerOpen ? t.MAX_KEY : t.MIN_KEY, d), lowerOpen: !0, upper: et(c.upper, c.upperOpen ? t.MIN_KEY : t.MAX_KEY, d), upperOpen: !0 }) } } : l;
|
|
2245
|
+
var c, d;
|
|
2246
|
+
}
|
|
2247
|
+
return { ...n, schema: { ...r, primaryKey: u, indexes: i, getIndexByKeyPath: function(l) {
|
|
2248
|
+
const h = s[Ne(l)];
|
|
2249
|
+
return h && h[0];
|
|
2250
|
+
} }, count: (l) => n.count(a(l)), query: (l) => n.query(a(l)), openCursor(l) {
|
|
2251
|
+
const { keyTail: h, isVirtual: c, keyLength: d } = l.query.index;
|
|
2252
|
+
return c ? n.openCursor(a(l)).then((m) => m && function(p) {
|
|
2253
|
+
return Object.create(p, { continue: { value: function(f) {
|
|
2254
|
+
f != null ? p.continue(et(f, l.reverse ? t.MAX_KEY : t.MIN_KEY, h)) : l.unique ? p.continue(p.key.slice(0, d).concat(l.reverse ? t.MIN_KEY : t.MAX_KEY, h)) : p.continue();
|
|
2255
|
+
} }, continuePrimaryKey: { value(f, y) {
|
|
2256
|
+
p.continuePrimaryKey(et(f, t.MAX_KEY, h), y);
|
|
2257
|
+
} }, primaryKey: { get: () => p.primaryKey }, key: { get() {
|
|
2258
|
+
const f = p.key;
|
|
2259
|
+
return d === 1 ? f[0] : f.slice(0, d);
|
|
2260
|
+
} }, value: { get: () => p.value } });
|
|
2261
|
+
}(m)) : n.openCursor(l);
|
|
2262
|
+
} };
|
|
2263
|
+
} };
|
|
2264
|
+
} };
|
|
2265
|
+
function ln(t, e, n, r) {
|
|
2266
|
+
return n = n || {}, r = r || "", $(t).forEach((s) => {
|
|
2267
|
+
if (z(e, s)) {
|
|
2268
|
+
var i = t[s], o = e[s];
|
|
2269
|
+
if (typeof i == "object" && typeof o == "object" && i && o) {
|
|
2270
|
+
const u = At(i);
|
|
2271
|
+
u !== At(o) ? n[r + s] = e[s] : u === "Object" ? ln(i, o, n, r + s + ".") : i !== o && (n[r + s] = e[s]);
|
|
2272
|
+
} else
|
|
2273
|
+
i !== o && (n[r + s] = e[s]);
|
|
2274
|
+
} else
|
|
2275
|
+
n[r + s] = void 0;
|
|
2276
|
+
}), $(e).forEach((s) => {
|
|
2277
|
+
z(t, s) || (n[r + s] = e[s]);
|
|
2278
|
+
}), n;
|
|
2279
|
+
}
|
|
2280
|
+
const Gr = { stack: "dbcore", name: "HooksMiddleware", level: 2, create: (t) => ({ ...t, table(e) {
|
|
2281
|
+
const n = t.table(e), { primaryKey: r } = n.schema;
|
|
2282
|
+
return { ...n, mutate(s) {
|
|
2283
|
+
const i = P.trans, { deleting: o, creating: u, updating: a } = i.table(e).hook;
|
|
2284
|
+
switch (s.type) {
|
|
2285
|
+
case "add":
|
|
2286
|
+
if (u.fire === I)
|
|
2287
|
+
break;
|
|
2288
|
+
return i._promise("readwrite", () => l(s), !0);
|
|
2289
|
+
case "put":
|
|
2290
|
+
if (u.fire === I && a.fire === I)
|
|
2291
|
+
break;
|
|
2292
|
+
return i._promise("readwrite", () => l(s), !0);
|
|
2293
|
+
case "delete":
|
|
2294
|
+
if (o.fire === I)
|
|
2295
|
+
break;
|
|
2296
|
+
return i._promise("readwrite", () => l(s), !0);
|
|
2297
|
+
case "deleteRange":
|
|
2298
|
+
if (o.fire === I)
|
|
2299
|
+
break;
|
|
2300
|
+
return i._promise("readwrite", () => function(c) {
|
|
2301
|
+
return h(c.trans, c.range, 1e4);
|
|
2302
|
+
}(s), !0);
|
|
2303
|
+
}
|
|
2304
|
+
return n.mutate(s);
|
|
2305
|
+
function l(c) {
|
|
2306
|
+
const d = P.trans, m = c.keys || function(p, f) {
|
|
2307
|
+
return f.type === "delete" ? f.keys : f.keys || f.values.map(p.extractKey);
|
|
2308
|
+
}(r, c);
|
|
2309
|
+
if (!m)
|
|
2310
|
+
throw new Error("Keys missing");
|
|
2311
|
+
return (c = c.type === "add" || c.type === "put" ? { ...c, keys: m } : { ...c }).type !== "delete" && (c.values = [...c.values]), c.keys && (c.keys = [...c.keys]), function(p, f, y) {
|
|
2312
|
+
return f.type === "add" ? Promise.resolve([]) : p.getMany({ trans: f.trans, keys: y, cache: "immutable" });
|
|
2313
|
+
}(n, c, m).then((p) => {
|
|
2314
|
+
const f = m.map((y, g) => {
|
|
2315
|
+
const v = p[g], b = { onerror: null, onsuccess: null };
|
|
2316
|
+
if (c.type === "delete")
|
|
2317
|
+
o.fire.call(b, y, v, d);
|
|
2318
|
+
else if (c.type === "add" || v === void 0) {
|
|
2319
|
+
const x = u.fire.call(b, y, c.values[g], d);
|
|
2320
|
+
y == null && x != null && (y = x, c.keys[g] = y, r.outbound || H(c.values[g], r.keyPath, y));
|
|
2321
|
+
} else {
|
|
2322
|
+
const x = ln(v, c.values[g]), E = a.fire.call(b, x, y, v, d);
|
|
2323
|
+
if (E) {
|
|
2324
|
+
const k = c.values[g];
|
|
2325
|
+
Object.keys(E).forEach((w) => {
|
|
2326
|
+
z(k, w) ? k[w] = E[w] : H(k, w, E[w]);
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
2329
|
+
}
|
|
2330
|
+
return b;
|
|
2331
|
+
});
|
|
2332
|
+
return n.mutate(c).then(({ failures: y, results: g, numFailures: v, lastResult: b }) => {
|
|
2333
|
+
for (let x = 0; x < m.length; ++x) {
|
|
2334
|
+
const E = g ? g[x] : m[x], k = f[x];
|
|
2335
|
+
E == null ? k.onerror && k.onerror(y[x]) : k.onsuccess && k.onsuccess(c.type === "put" && p[x] ? c.values[x] : E);
|
|
2336
|
+
}
|
|
2337
|
+
return { failures: y, results: g, numFailures: v, lastResult: b };
|
|
2338
|
+
}).catch((y) => (f.forEach((g) => g.onerror && g.onerror(y)), Promise.reject(y)));
|
|
2339
|
+
});
|
|
2340
|
+
}
|
|
2341
|
+
function h(c, d, m) {
|
|
2342
|
+
return n.query({ trans: c, values: !1, query: { index: r, range: d }, limit: m }).then(({ result: p }) => l({ type: "delete", keys: p, trans: c }).then((f) => f.numFailures > 0 ? Promise.reject(f.failures[0]) : p.length < m ? { failures: [], numFailures: 0, lastResult: void 0 } : h(c, { ...d, lower: p[p.length - 1], lowerOpen: !0 }, m)));
|
|
2343
|
+
}
|
|
2344
|
+
} };
|
|
2345
|
+
} }) };
|
|
2346
|
+
function sr(t, e, n) {
|
|
2347
|
+
try {
|
|
2348
|
+
if (!e || e.keys.length < t.length)
|
|
2349
|
+
return null;
|
|
2350
|
+
const r = [];
|
|
2351
|
+
for (let s = 0, i = 0; s < e.keys.length && i < t.length; ++s)
|
|
2352
|
+
L(e.keys[s], t[i]) === 0 && (r.push(n ? We(e.values[s]) : e.values[s]), ++i);
|
|
2353
|
+
return r.length === t.length ? r : null;
|
|
2354
|
+
} catch {
|
|
2355
|
+
return null;
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2358
|
+
const Xr = { stack: "dbcore", level: -1, create: (t) => ({ table: (e) => {
|
|
2359
|
+
const n = t.table(e);
|
|
2360
|
+
return { ...n, getMany: (r) => {
|
|
2361
|
+
if (!r.cache)
|
|
2362
|
+
return n.getMany(r);
|
|
2363
|
+
const s = sr(r.keys, r.trans._cache, r.cache === "clone");
|
|
2364
|
+
return s ? S.resolve(s) : n.getMany(r).then((i) => (r.trans._cache = { keys: r.keys, values: r.cache === "clone" ? We(i) : i }, i));
|
|
2365
|
+
}, mutate: (r) => (r.type !== "add" && (r.trans._cache = null), n.mutate(r)) };
|
|
2366
|
+
} }) };
|
|
2367
|
+
function hn(t) {
|
|
2368
|
+
return !("from" in t);
|
|
2369
|
+
}
|
|
2370
|
+
const Q = function(t, e) {
|
|
2371
|
+
if (!this) {
|
|
2372
|
+
const n = new Q();
|
|
2373
|
+
return t && "d" in t && U(n, t), n;
|
|
2374
|
+
}
|
|
2375
|
+
U(this, arguments.length ? { d: 1, from: t, to: arguments.length > 1 ? e : t } : { d: 0 });
|
|
2376
|
+
};
|
|
2377
|
+
function Ve(t, e, n) {
|
|
2378
|
+
const r = L(e, n);
|
|
2379
|
+
if (isNaN(r))
|
|
2380
|
+
return;
|
|
2381
|
+
if (r > 0)
|
|
2382
|
+
throw RangeError();
|
|
2383
|
+
if (hn(t))
|
|
2384
|
+
return U(t, { from: e, to: n, d: 1 });
|
|
2385
|
+
const s = t.l, i = t.r;
|
|
2386
|
+
if (L(n, t.from) < 0)
|
|
2387
|
+
return s ? Ve(s, e, n) : t.l = { from: e, to: n, d: 1, l: null, r: null }, Pn(t);
|
|
2388
|
+
if (L(e, t.to) > 0)
|
|
2389
|
+
return i ? Ve(i, e, n) : t.r = { from: e, to: n, d: 1, l: null, r: null }, Pn(t);
|
|
2390
|
+
L(e, t.from) < 0 && (t.from = e, t.l = null, t.d = i ? i.d + 1 : 1), L(n, t.to) > 0 && (t.to = n, t.r = null, t.d = t.l ? t.l.d + 1 : 1);
|
|
2391
|
+
const o = !t.r;
|
|
2392
|
+
s && !t.l && gt(t, s), i && o && gt(t, i);
|
|
2393
|
+
}
|
|
2394
|
+
function gt(t, e) {
|
|
2395
|
+
hn(e) || function n(r, { from: s, to: i, l: o, r: u }) {
|
|
2396
|
+
Ve(r, s, i), o && n(r, o), u && n(r, u);
|
|
2397
|
+
}(t, e);
|
|
2398
|
+
}
|
|
2399
|
+
function Qr(t, e) {
|
|
2400
|
+
const n = Qt(e);
|
|
2401
|
+
let r = n.next();
|
|
2402
|
+
if (r.done)
|
|
2403
|
+
return !1;
|
|
2404
|
+
let s = r.value;
|
|
2405
|
+
const i = Qt(t);
|
|
2406
|
+
let o = i.next(s.from), u = o.value;
|
|
2407
|
+
for (; !r.done && !o.done; ) {
|
|
2408
|
+
if (L(u.from, s.to) <= 0 && L(u.to, s.from) >= 0)
|
|
2409
|
+
return !0;
|
|
2410
|
+
L(s.from, u.from) < 0 ? s = (r = n.next(u.from)).value : u = (o = i.next(s.from)).value;
|
|
2411
|
+
}
|
|
2412
|
+
return !1;
|
|
2413
|
+
}
|
|
2414
|
+
function Qt(t) {
|
|
2415
|
+
let e = hn(t) ? null : { s: 0, n: t };
|
|
2416
|
+
return { next(n) {
|
|
2417
|
+
const r = arguments.length > 0;
|
|
2418
|
+
for (; e; )
|
|
2419
|
+
switch (e.s) {
|
|
2420
|
+
case 0:
|
|
2421
|
+
if (e.s = 1, r)
|
|
2422
|
+
for (; e.n.l && L(n, e.n.from) < 0; )
|
|
2423
|
+
e = { up: e, n: e.n.l, s: 1 };
|
|
2424
|
+
else
|
|
2425
|
+
for (; e.n.l; )
|
|
2426
|
+
e = { up: e, n: e.n.l, s: 1 };
|
|
2427
|
+
case 1:
|
|
2428
|
+
if (e.s = 2, !r || L(n, e.n.to) <= 0)
|
|
2429
|
+
return { value: e.n, done: !1 };
|
|
2430
|
+
case 2:
|
|
2431
|
+
if (e.n.r) {
|
|
2432
|
+
e.s = 3, e = { up: e, n: e.n.r, s: 0 };
|
|
2433
|
+
continue;
|
|
2434
|
+
}
|
|
2435
|
+
case 3:
|
|
2436
|
+
e = e.up;
|
|
2437
|
+
}
|
|
2438
|
+
return { done: !0 };
|
|
2439
|
+
} };
|
|
2440
|
+
}
|
|
2441
|
+
function Pn(t) {
|
|
2442
|
+
var e, n;
|
|
2443
|
+
const r = (((e = t.r) === null || e === void 0 ? void 0 : e.d) || 0) - (((n = t.l) === null || n === void 0 ? void 0 : n.d) || 0), s = r > 1 ? "r" : r < -1 ? "l" : "";
|
|
2444
|
+
if (s) {
|
|
2445
|
+
const i = s === "r" ? "l" : "r", o = { ...t }, u = t[s];
|
|
2446
|
+
t.from = u.from, t.to = u.to, t[s] = u[s], o[s] = u[i], t[i] = o, o.d = Cn(o);
|
|
2447
|
+
}
|
|
2448
|
+
t.d = Cn(t);
|
|
2449
|
+
}
|
|
2450
|
+
function Cn({ r: t, l: e }) {
|
|
2451
|
+
return (t ? e ? Math.max(t.d, e.d) : t.d : e ? e.d : 0) + 1;
|
|
2452
|
+
}
|
|
2453
|
+
Ee(Q.prototype, { add(t) {
|
|
2454
|
+
return gt(this, t), this;
|
|
2455
|
+
}, addKey(t) {
|
|
2456
|
+
return Ve(this, t, t), this;
|
|
2457
|
+
}, addKeys(t) {
|
|
2458
|
+
return t.forEach((e) => Ve(this, e, e)), this;
|
|
2459
|
+
}, [Ot]() {
|
|
2460
|
+
return Qt(this);
|
|
2461
|
+
} });
|
|
2462
|
+
const Jr = { stack: "dbcore", level: 0, create: (t) => {
|
|
2463
|
+
const e = t.schema.name, n = new Q(t.MIN_KEY, t.MAX_KEY);
|
|
2464
|
+
return { ...t, table: (r) => {
|
|
2465
|
+
const s = t.table(r), { schema: i } = s, { primaryKey: o } = i, { extractKey: u, outbound: a } = o, l = { ...s, mutate: (d) => {
|
|
2466
|
+
const m = d.trans, p = m.mutatedParts || (m.mutatedParts = {}), f = (k) => {
|
|
2467
|
+
const w = `idb://${e}/${r}/${k}`;
|
|
2468
|
+
return p[w] || (p[w] = new Q());
|
|
2469
|
+
}, y = f(""), g = f(":dels"), { type: v } = d;
|
|
2470
|
+
let [b, x] = d.type === "deleteRange" ? [d.range] : d.type === "delete" ? [d.keys] : d.values.length < 50 ? [[], d.values] : [];
|
|
2471
|
+
const E = d.trans._cache;
|
|
2472
|
+
return s.mutate(d).then((k) => {
|
|
2473
|
+
if (F(b)) {
|
|
2474
|
+
v !== "delete" && (b = k.results), y.addKeys(b);
|
|
2475
|
+
const w = sr(b, E);
|
|
2476
|
+
w || v === "add" || g.addKeys(b), (w || x) && function(A, _, j, O) {
|
|
2477
|
+
function q(B) {
|
|
2478
|
+
const D = A(B.name || "");
|
|
2479
|
+
function ye(V) {
|
|
2480
|
+
return V != null ? B.extractKey(V) : null;
|
|
2481
|
+
}
|
|
2482
|
+
const ve = (V) => B.multiEntry && F(V) ? V.forEach((ce) => D.addKey(ce)) : D.addKey(V);
|
|
2483
|
+
(j || O).forEach((V, ce) => {
|
|
2484
|
+
const Ae = j && ye(j[ce]), bt = O && ye(O[ce]);
|
|
2485
|
+
L(Ae, bt) !== 0 && (Ae != null && ve(Ae), bt != null && ve(bt));
|
|
2486
|
+
});
|
|
2487
|
+
}
|
|
2488
|
+
_.indexes.forEach(q);
|
|
2489
|
+
}(f, i, w, x);
|
|
2490
|
+
} else if (b) {
|
|
2491
|
+
const w = { from: b.lower, to: b.upper };
|
|
2492
|
+
g.add(w), y.add(w);
|
|
2493
|
+
} else
|
|
2494
|
+
y.add(n), g.add(n), i.indexes.forEach((w) => f(w.name).add(n));
|
|
2495
|
+
return k;
|
|
2496
|
+
});
|
|
2497
|
+
} }, h = ({ query: { index: d, range: m } }) => {
|
|
2498
|
+
var p, f;
|
|
2499
|
+
return [d, new Q((p = m.lower) !== null && p !== void 0 ? p : t.MIN_KEY, (f = m.upper) !== null && f !== void 0 ? f : t.MAX_KEY)];
|
|
2500
|
+
}, c = { get: (d) => [o, new Q(d.key)], getMany: (d) => [o, new Q().addKeys(d.keys)], count: h, query: h, openCursor: h };
|
|
2501
|
+
return $(c).forEach((d) => {
|
|
2502
|
+
l[d] = function(m) {
|
|
2503
|
+
const { subscr: p } = P;
|
|
2504
|
+
if (p) {
|
|
2505
|
+
const f = (x) => {
|
|
2506
|
+
const E = `idb://${e}/${r}/${x}`;
|
|
2507
|
+
return p[E] || (p[E] = new Q());
|
|
2508
|
+
}, y = f(""), g = f(":dels"), [v, b] = c[d](m);
|
|
2509
|
+
if (f(v.name || "").add(b), !v.isPrimaryKey) {
|
|
2510
|
+
if (d !== "count") {
|
|
2511
|
+
const x = d === "query" && a && m.values && s.query({ ...m, values: !1 });
|
|
2512
|
+
return s[d].apply(this, arguments).then((E) => {
|
|
2513
|
+
if (d === "query") {
|
|
2514
|
+
if (a && m.values)
|
|
2515
|
+
return x.then(({ result: w }) => (y.addKeys(w), E));
|
|
2516
|
+
const k = m.values ? E.result.map(u) : E.result;
|
|
2517
|
+
m.values ? y.addKeys(k) : g.addKeys(k);
|
|
2518
|
+
} else if (d === "openCursor") {
|
|
2519
|
+
const k = E, w = m.values;
|
|
2520
|
+
return k && Object.create(k, { key: { get: () => (g.addKey(k.primaryKey), k.key) }, primaryKey: { get() {
|
|
2521
|
+
const A = k.primaryKey;
|
|
2522
|
+
return g.addKey(A), A;
|
|
2523
|
+
} }, value: { get: () => (w && y.addKey(k.primaryKey), k.value) } });
|
|
2524
|
+
}
|
|
2525
|
+
return E;
|
|
2526
|
+
});
|
|
2527
|
+
}
|
|
2528
|
+
g.add(n);
|
|
2529
|
+
}
|
|
2530
|
+
}
|
|
2531
|
+
return s[d].apply(this, arguments);
|
|
2532
|
+
};
|
|
2533
|
+
}), l;
|
|
2534
|
+
} };
|
|
2535
|
+
} };
|
|
2536
|
+
class pe {
|
|
2537
|
+
constructor(e, n) {
|
|
2538
|
+
this._middlewares = {}, this.verno = 0;
|
|
2539
|
+
const r = pe.dependencies;
|
|
2540
|
+
this._options = n = { addons: pe.addons, autoOpen: !0, indexedDB: r.indexedDB, IDBKeyRange: r.IDBKeyRange, ...n }, this._deps = { indexedDB: n.indexedDB, IDBKeyRange: n.IDBKeyRange };
|
|
2541
|
+
const { addons: s } = n;
|
|
2542
|
+
this._dbSchema = {}, this._versions = [], this._storeNames = [], this._allTables = {}, this.idbdb = null, this._novip = this;
|
|
2543
|
+
const i = { dbOpenError: null, isBeingOpened: !1, onReadyBeingFired: null, openComplete: !1, dbReadyResolve: I, dbReadyPromise: null, cancelOpen: I, openCanceller: null, autoSchema: !0, PR1398_maxLoop: 3 };
|
|
2544
|
+
var o;
|
|
2545
|
+
i.dbReadyPromise = new S((u) => {
|
|
2546
|
+
i.dbReadyResolve = u;
|
|
2547
|
+
}), i.openCanceller = new S((u, a) => {
|
|
2548
|
+
i.cancelOpen = a;
|
|
2549
|
+
}), this._state = i, this.name = e, this.on = $e(this, "populate", "blocked", "versionchange", "close", { ready: [rn, I] }), this.on.ready.subscribe = On(this.on.ready.subscribe, (u) => (a, l) => {
|
|
2550
|
+
pe.vip(() => {
|
|
2551
|
+
const h = this._state;
|
|
2552
|
+
if (h.openComplete)
|
|
2553
|
+
h.dbOpenError || S.resolve().then(a), l && u(a);
|
|
2554
|
+
else if (h.onReadyBeingFired)
|
|
2555
|
+
h.onReadyBeingFired.push(a), l && u(a);
|
|
2556
|
+
else {
|
|
2557
|
+
u(a);
|
|
2558
|
+
const c = this;
|
|
2559
|
+
l || u(function d() {
|
|
2560
|
+
c.on.ready.unsubscribe(a), c.on.ready.unsubscribe(d);
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
});
|
|
2564
|
+
}), this.Collection = (o = this, Oe(Dr.prototype, function(u, a) {
|
|
2565
|
+
this.db = o;
|
|
2566
|
+
let l = Qn, h = null;
|
|
2567
|
+
if (a)
|
|
2568
|
+
try {
|
|
2569
|
+
l = a();
|
|
2570
|
+
} catch (p) {
|
|
2571
|
+
h = p;
|
|
2572
|
+
}
|
|
2573
|
+
const c = u._ctx, d = c.table, m = d.hook.reading.fire;
|
|
2574
|
+
this._ctx = { table: d, index: c.index, isPrimKey: !c.index || d.schema.primKey.keyPath && c.index === d.schema.primKey.name, range: l, keysOnly: !1, dir: "next", unique: "", algorithm: null, filter: null, replayFilter: null, justLimit: !0, isMatch: null, offset: 0, limit: 1 / 0, error: h, or: c.or, valueMapper: m !== Me ? m : null };
|
|
2575
|
+
})), this.Table = function(u) {
|
|
2576
|
+
return Oe(jr.prototype, function(a, l, h) {
|
|
2577
|
+
this.db = u, this._tx = h, this.name = a, this.schema = l, this.hook = u._allTables[a] ? u._allTables[a].hook : $e(null, { creating: [kr, I], reading: [_r, Me], updating: [Sr, I], deleting: [xr, I] });
|
|
2578
|
+
});
|
|
2579
|
+
}(this), this.Transaction = function(u) {
|
|
2580
|
+
return Oe(Mr.prototype, function(a, l, h, c, d) {
|
|
2581
|
+
this.db = u, this.mode = a, this.storeNames = l, this.schema = h, this.chromeTransactionDurability = c, this.idbtrans = null, this.on = $e(this, "complete", "error", "abort"), this.parent = d || 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((m, p) => {
|
|
2582
|
+
this._resolve = m, this._reject = p;
|
|
2583
|
+
}), this._completion.then(() => {
|
|
2584
|
+
this.active = !1, this.on.complete.fire();
|
|
2585
|
+
}, (m) => {
|
|
2586
|
+
var p = this.active;
|
|
2587
|
+
return this.active = !1, this.on.error.fire(m), this.parent ? this.parent._reject(m) : p && this.idbtrans && this.idbtrans.abort(), N(m);
|
|
2588
|
+
});
|
|
2589
|
+
});
|
|
2590
|
+
}(this), this.Version = function(u) {
|
|
2591
|
+
return Oe(Vr.prototype, function(a) {
|
|
2592
|
+
this.db = u, this._cfg = { version: a, storesSource: null, dbschema: {}, tables: {}, contentUpgrade: null };
|
|
2593
|
+
});
|
|
2594
|
+
}(this), this.WhereClause = function(u) {
|
|
2595
|
+
return Oe(Zn.prototype, function(a, l, h) {
|
|
2596
|
+
this.db = u, this._ctx = { table: a, index: l === ":id" ? null : l, or: h };
|
|
2597
|
+
const c = u._deps.indexedDB;
|
|
2598
|
+
if (!c)
|
|
2599
|
+
throw new C.MissingAPI();
|
|
2600
|
+
this._cmp = this._ascending = c.cmp.bind(c), this._descending = (d, m) => c.cmp(m, d), this._max = (d, m) => c.cmp(d, m) > 0 ? d : m, this._min = (d, m) => c.cmp(d, m) < 0 ? d : m, this._IDBKeyRange = u._deps.IDBKeyRange;
|
|
2601
|
+
});
|
|
2602
|
+
}(this), this.on("versionchange", (u) => {
|
|
2603
|
+
u.newVersion > 0 ? console.warn(`Another connection wants to upgrade database '${this.name}'. Closing db now to resume the upgrade.`) : console.warn(`Another connection wants to delete database '${this.name}'. Closing db now to resume the delete request.`), this.close();
|
|
2604
|
+
}), this.on("blocked", (u) => {
|
|
2605
|
+
!u.newVersion || u.newVersion < u.oldVersion ? console.warn(`Dexie.delete('${this.name}') was blocked`) : console.warn(`Upgrade '${this.name}' blocked by other connection holding version ${u.oldVersion / 10}`);
|
|
2606
|
+
}), this._maxKey = Ue(n.IDBKeyRange), this._createTransaction = (u, a, l, h) => new this.Transaction(u, a, l, this._options.chromeTransactionDurability, h), this._fireOnBlocked = (u) => {
|
|
2607
|
+
this.on("blocked").fire(u), De.filter((a) => a.name === this.name && a !== this && !a._state.vcFired).map((a) => a.on("versionchange").fire(u));
|
|
2608
|
+
}, this.use(Yr), this.use(Gr), this.use(Jr), this.use(Xr), this.vip = Object.create(this, { _vip: { value: !0 } }), s.forEach((u) => u(this));
|
|
2609
|
+
}
|
|
2610
|
+
version(e) {
|
|
2611
|
+
if (isNaN(e) || e < 0.1)
|
|
2612
|
+
throw new C.Type("Given version is not a positive number");
|
|
2613
|
+
if (e = Math.round(10 * e) / 10, this.idbdb || this._state.isBeingOpened)
|
|
2614
|
+
throw new C.Schema("Cannot add version when database is open");
|
|
2615
|
+
this.verno = Math.max(this.verno, e);
|
|
2616
|
+
const n = this._versions;
|
|
2617
|
+
var r = n.filter((s) => s._cfg.version === e)[0];
|
|
2618
|
+
return r || (r = new this.Version(e), n.push(r), n.sort(Lr), r.stores({}), this._state.autoSchema = !1, r);
|
|
2619
|
+
}
|
|
2620
|
+
_whenReady(e) {
|
|
2621
|
+
return this.idbdb && (this._state.openComplete || P.letThrough || this._vip) ? e() : new S((n, r) => {
|
|
2622
|
+
if (this._state.openComplete)
|
|
2623
|
+
return r(new C.DatabaseClosed(this._state.dbOpenError));
|
|
2624
|
+
if (!this._state.isBeingOpened) {
|
|
2625
|
+
if (!this._options.autoOpen)
|
|
2626
|
+
return void r(new C.DatabaseClosed());
|
|
2627
|
+
this.open().catch(I);
|
|
2628
|
+
}
|
|
2629
|
+
this._state.dbReadyPromise.then(n, r);
|
|
2630
|
+
}).then(e);
|
|
2631
|
+
}
|
|
2632
|
+
use({ stack: e, create: n, level: r, name: s }) {
|
|
2633
|
+
s && this.unuse({ stack: e, name: s });
|
|
2634
|
+
const i = this._middlewares[e] || (this._middlewares[e] = []);
|
|
2635
|
+
return i.push({ stack: e, create: n, level: r ?? 10, name: s }), i.sort((o, u) => o.level - u.level), this;
|
|
2636
|
+
}
|
|
2637
|
+
unuse({ stack: e, name: n, create: r }) {
|
|
2638
|
+
return e && this._middlewares[e] && (this._middlewares[e] = this._middlewares[e].filter((s) => r ? s.create !== r : !!n && s.name !== n)), this;
|
|
2639
|
+
}
|
|
2640
|
+
open() {
|
|
2641
|
+
return zr(this);
|
|
2642
|
+
}
|
|
2643
|
+
_close() {
|
|
2644
|
+
const e = this._state, n = De.indexOf(this);
|
|
2645
|
+
if (n >= 0 && De.splice(n, 1), this.idbdb) {
|
|
2646
|
+
try {
|
|
2647
|
+
this.idbdb.close();
|
|
2648
|
+
} catch {
|
|
2649
|
+
}
|
|
2650
|
+
this._novip.idbdb = null;
|
|
2651
|
+
}
|
|
2652
|
+
e.dbReadyPromise = new S((r) => {
|
|
2653
|
+
e.dbReadyResolve = r;
|
|
2654
|
+
}), e.openCanceller = new S((r, s) => {
|
|
2655
|
+
e.cancelOpen = s;
|
|
2656
|
+
});
|
|
2657
|
+
}
|
|
2658
|
+
close() {
|
|
2659
|
+
this._close();
|
|
2660
|
+
const e = this._state;
|
|
2661
|
+
this._options.autoOpen = !1, e.dbOpenError = new C.DatabaseClosed(), e.isBeingOpened && e.cancelOpen(e.dbOpenError);
|
|
2662
|
+
}
|
|
2663
|
+
delete() {
|
|
2664
|
+
const e = arguments.length > 0, n = this._state;
|
|
2665
|
+
return new S((r, s) => {
|
|
2666
|
+
const i = () => {
|
|
2667
|
+
this.close();
|
|
2668
|
+
var o = this._deps.indexedDB.deleteDatabase(this.name);
|
|
2669
|
+
o.onsuccess = R(() => {
|
|
2670
|
+
(function({ indexedDB: u, IDBKeyRange: a }, l) {
|
|
2671
|
+
!cn(u) && l !== vt && un(u, a).delete(l).catch(I);
|
|
2672
|
+
})(this._deps, this.name), r();
|
|
2673
|
+
}), o.onerror = Y(s), o.onblocked = this._fireOnBlocked;
|
|
2674
|
+
};
|
|
2675
|
+
if (e)
|
|
2676
|
+
throw new C.InvalidArgument("Arguments not allowed in db.delete()");
|
|
2677
|
+
n.isBeingOpened ? n.dbReadyPromise.then(i) : i();
|
|
2678
|
+
});
|
|
2679
|
+
}
|
|
2680
|
+
backendDB() {
|
|
2681
|
+
return this.idbdb;
|
|
2682
|
+
}
|
|
2683
|
+
isOpen() {
|
|
2684
|
+
return this.idbdb !== null;
|
|
2685
|
+
}
|
|
2686
|
+
hasBeenClosed() {
|
|
2687
|
+
const e = this._state.dbOpenError;
|
|
2688
|
+
return e && e.name === "DatabaseClosed";
|
|
2689
|
+
}
|
|
2690
|
+
hasFailed() {
|
|
2691
|
+
return this._state.dbOpenError !== null;
|
|
2692
|
+
}
|
|
2693
|
+
dynamicallyOpened() {
|
|
2694
|
+
return this._state.autoSchema;
|
|
2695
|
+
}
|
|
2696
|
+
get tables() {
|
|
2697
|
+
return $(this._allTables).map((e) => this._allTables[e]);
|
|
2698
|
+
}
|
|
2699
|
+
transaction() {
|
|
2700
|
+
const e = Hr.apply(this, arguments);
|
|
2701
|
+
return this._transaction.apply(this, e);
|
|
2702
|
+
}
|
|
2703
|
+
_transaction(e, n, r) {
|
|
2704
|
+
let s = P.trans;
|
|
2705
|
+
s && s.db === this && e.indexOf("!") === -1 || (s = null);
|
|
2706
|
+
const i = e.indexOf("?") !== -1;
|
|
2707
|
+
let o, u;
|
|
2708
|
+
e = e.replace("!", "").replace("?", "");
|
|
2709
|
+
try {
|
|
2710
|
+
if (u = n.map((l) => {
|
|
2711
|
+
var h = l instanceof this.Table ? l.name : l;
|
|
2712
|
+
if (typeof h != "string")
|
|
2713
|
+
throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");
|
|
2714
|
+
return h;
|
|
2715
|
+
}), e == "r" || e === _t)
|
|
2716
|
+
o = _t;
|
|
2717
|
+
else {
|
|
2718
|
+
if (e != "rw" && e != kt)
|
|
2719
|
+
throw new C.InvalidArgument("Invalid transaction mode: " + e);
|
|
2720
|
+
o = kt;
|
|
2721
|
+
}
|
|
2722
|
+
if (s) {
|
|
2723
|
+
if (s.mode === _t && o === kt) {
|
|
2724
|
+
if (!i)
|
|
2725
|
+
throw new C.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
|
|
2726
|
+
s = null;
|
|
2727
|
+
}
|
|
2728
|
+
s && u.forEach((l) => {
|
|
2729
|
+
if (s && s.storeNames.indexOf(l) === -1) {
|
|
2730
|
+
if (!i)
|
|
2731
|
+
throw new C.SubTransaction("Table " + l + " not included in parent transaction.");
|
|
2732
|
+
s = null;
|
|
2733
|
+
}
|
|
2734
|
+
}), i && s && !s.active && (s = null);
|
|
2735
|
+
}
|
|
2736
|
+
} catch (l) {
|
|
2737
|
+
return s ? s._promise(null, (h, c) => {
|
|
2738
|
+
c(l);
|
|
2739
|
+
}) : N(l);
|
|
2740
|
+
}
|
|
2741
|
+
const a = rr.bind(null, this, o, u, s, r);
|
|
2742
|
+
return s ? s._promise(o, a, "lock") : P.trans ? Te(P.transless, () => this._whenReady(a)) : this._whenReady(a);
|
|
2743
|
+
}
|
|
2744
|
+
table(e) {
|
|
2745
|
+
if (!z(this._allTables, e))
|
|
2746
|
+
throw new C.InvalidTable(`Table ${e} does not exist`);
|
|
2747
|
+
return this._allTables[e];
|
|
2748
|
+
}
|
|
2749
|
+
}
|
|
2750
|
+
const Zr = typeof Symbol < "u" && "observable" in Symbol ? Symbol.observable : "@@observable";
|
|
2751
|
+
class es {
|
|
2752
|
+
constructor(e) {
|
|
2753
|
+
this._subscribe = e;
|
|
2754
|
+
}
|
|
2755
|
+
subscribe(e, n, r) {
|
|
2756
|
+
return this._subscribe(e && typeof e != "function" ? e : { next: e, error: n, complete: r });
|
|
2757
|
+
}
|
|
2758
|
+
[Zr]() {
|
|
2759
|
+
return this;
|
|
2760
|
+
}
|
|
2761
|
+
}
|
|
2762
|
+
function ir(t, e) {
|
|
2763
|
+
return $(e).forEach((n) => {
|
|
2764
|
+
gt(t[n] || (t[n] = new Q()), e[n]);
|
|
2765
|
+
}), t;
|
|
2766
|
+
}
|
|
2767
|
+
function ts(t) {
|
|
2768
|
+
let e, n = !1;
|
|
2769
|
+
const r = new es((s) => {
|
|
2770
|
+
const i = en(t);
|
|
2771
|
+
let o = !1, u = {}, a = {};
|
|
2772
|
+
const l = { get closed() {
|
|
2773
|
+
return o;
|
|
2774
|
+
}, unsubscribe: () => {
|
|
2775
|
+
o = !0, ue.storagemutated.unsubscribe(m);
|
|
2776
|
+
} };
|
|
2777
|
+
s.start && s.start(l);
|
|
2778
|
+
let h = !1, c = !1;
|
|
2779
|
+
function d() {
|
|
2780
|
+
return $(a).some((f) => u[f] && Qr(u[f], a[f]));
|
|
2781
|
+
}
|
|
2782
|
+
const m = (f) => {
|
|
2783
|
+
ir(u, f), d() && p();
|
|
2784
|
+
}, p = () => {
|
|
2785
|
+
if (h || o)
|
|
2786
|
+
return;
|
|
2787
|
+
u = {};
|
|
2788
|
+
const f = {}, y = function(g) {
|
|
2789
|
+
i && Ce();
|
|
2790
|
+
const v = () => oe(t, { subscr: g, trans: null }), b = P.trans ? Te(P.transless, v) : v();
|
|
2791
|
+
return i && b.then(ne, ne), b;
|
|
2792
|
+
}(f);
|
|
2793
|
+
c || (ue(Le, m), c = !0), h = !0, Promise.resolve(y).then((g) => {
|
|
2794
|
+
n = !0, e = g, h = !1, o || (d() ? p() : (u = {}, a = f, s.next && s.next(g)));
|
|
2795
|
+
}, (g) => {
|
|
2796
|
+
h = !1, n = !1, s.error && s.error(g), l.unsubscribe();
|
|
2797
|
+
});
|
|
2798
|
+
};
|
|
2799
|
+
return p(), l;
|
|
2800
|
+
});
|
|
2801
|
+
return r.hasValue = () => n, r.getValue = () => e, r;
|
|
2802
|
+
}
|
|
2803
|
+
let Jt;
|
|
2804
|
+
try {
|
|
2805
|
+
Jt = { indexedDB: K.indexedDB || K.mozIndexedDB || K.webkitIndexedDB || K.msIndexedDB, IDBKeyRange: K.IDBKeyRange || K.webkitIDBKeyRange };
|
|
2806
|
+
} catch {
|
|
2807
|
+
Jt = { indexedDB: null, IDBKeyRange: null };
|
|
2808
|
+
}
|
|
2809
|
+
const le = pe;
|
|
2810
|
+
function at(t) {
|
|
2811
|
+
let e = Z;
|
|
2812
|
+
try {
|
|
2813
|
+
Z = !0, ue.storagemutated.fire(t);
|
|
2814
|
+
} finally {
|
|
2815
|
+
Z = e;
|
|
2816
|
+
}
|
|
2817
|
+
}
|
|
2818
|
+
Ee(le, { ...tt, delete: (t) => new le(t, { addons: [] }).delete(), exists: (t) => new le(t, { addons: [] }).open().then((e) => (e.close(), !0)).catch("NoSuchDatabaseError", () => !1), getDatabaseNames(t) {
|
|
2819
|
+
try {
|
|
2820
|
+
return function({ indexedDB: e, IDBKeyRange: n }) {
|
|
2821
|
+
return cn(e) ? Promise.resolve(e.databases()).then((r) => r.map((s) => s.name).filter((s) => s !== vt)) : un(e, n).toCollection().primaryKeys();
|
|
2822
|
+
}(le.dependencies).then(t);
|
|
2823
|
+
} catch {
|
|
2824
|
+
return N(new C.MissingAPI());
|
|
2825
|
+
}
|
|
2826
|
+
}, defineClass: () => function(t) {
|
|
2827
|
+
U(this, t);
|
|
2828
|
+
}, ignoreTransaction: (t) => P.trans ? Te(P.transless, t) : t(), vip: Gt, async: function(t) {
|
|
2829
|
+
return function() {
|
|
2830
|
+
try {
|
|
2831
|
+
var e = Xt(t.apply(this, arguments));
|
|
2832
|
+
return e && typeof e.then == "function" ? e : S.resolve(e);
|
|
2833
|
+
} catch (n) {
|
|
2834
|
+
return N(n);
|
|
2835
|
+
}
|
|
2836
|
+
};
|
|
2837
|
+
}, spawn: function(t, e, n) {
|
|
2838
|
+
try {
|
|
2839
|
+
var r = Xt(t.apply(n, e || []));
|
|
2840
|
+
return r && typeof r.then == "function" ? r : S.resolve(r);
|
|
2841
|
+
} catch (s) {
|
|
2842
|
+
return N(s);
|
|
2843
|
+
}
|
|
2844
|
+
}, currentTransaction: { get: () => P.trans || null }, waitFor: function(t, e) {
|
|
2845
|
+
const n = S.resolve(typeof t == "function" ? le.ignoreTransaction(t) : t).timeout(e || 6e4);
|
|
2846
|
+
return P.trans ? P.trans.waitFor(n) : n;
|
|
2847
|
+
}, Promise: S, debug: { get: () => G, set: (t) => {
|
|
2848
|
+
$n(t, t === "dexie" ? () => !0 : Xn);
|
|
2849
|
+
} }, derive: ke, extend: U, props: Ee, override: On, Events: $e, on: ue, liveQuery: ts, extendObservabilitySet: ir, getByKeyPath: te, setByKeyPath: H, delByKeyPath: function(t, e) {
|
|
2850
|
+
typeof e == "string" ? H(t, e, void 0) : "length" in e && [].map.call(e, function(n) {
|
|
2851
|
+
H(t, n, void 0);
|
|
2852
|
+
});
|
|
2853
|
+
}, shallowClone: Rn, deepClone: We, getObjectDiff: ln, cmp: L, asap: In, minKey: qt, addons: [], connections: De, errnames: nn, dependencies: Jt, semVer: wn, version: wn.split(".").map((t) => parseInt(t)).reduce((t, e, n) => t + e / Math.pow(10, 2 * n)) }), le.maxKey = Ue(le.dependencies.IDBKeyRange), typeof dispatchEvent < "u" && typeof addEventListener < "u" && (ue(Le, (t) => {
|
|
2854
|
+
if (!Z) {
|
|
2855
|
+
let e;
|
|
2856
|
+
yt ? (e = document.createEvent("CustomEvent"), e.initCustomEvent(ie, !0, !0, t)) : e = new CustomEvent(ie, { detail: t }), Z = !0, dispatchEvent(e), Z = !1;
|
|
2857
|
+
}
|
|
2858
|
+
}), addEventListener(ie, ({ detail: t }) => {
|
|
2859
|
+
Z || at(t);
|
|
2860
|
+
}));
|
|
2861
|
+
let Z = !1;
|
|
2862
|
+
if (typeof BroadcastChannel < "u") {
|
|
2863
|
+
const t = new BroadcastChannel(ie);
|
|
2864
|
+
typeof t.unref == "function" && t.unref(), ue(Le, (e) => {
|
|
2865
|
+
Z || t.postMessage(e);
|
|
2866
|
+
}), t.onmessage = (e) => {
|
|
2867
|
+
e.data && at(e.data);
|
|
2868
|
+
};
|
|
2869
|
+
} else if (typeof self < "u" && typeof navigator < "u") {
|
|
2870
|
+
ue(Le, (e) => {
|
|
2871
|
+
try {
|
|
2872
|
+
Z || (typeof localStorage < "u" && localStorage.setItem(ie, JSON.stringify({ trig: Math.random(), changedParts: e })), typeof self.clients == "object" && [...self.clients.matchAll({ includeUncontrolled: !0 })].forEach((n) => n.postMessage({ type: ie, changedParts: e })));
|
|
2873
|
+
} catch {
|
|
2874
|
+
}
|
|
2875
|
+
}), typeof addEventListener < "u" && addEventListener("storage", (e) => {
|
|
2876
|
+
if (e.key === ie) {
|
|
2877
|
+
const n = JSON.parse(e.newValue);
|
|
2878
|
+
n && at(n.changedParts);
|
|
2879
|
+
}
|
|
2880
|
+
});
|
|
2881
|
+
const t = self.document && navigator.serviceWorker;
|
|
2882
|
+
t && t.addEventListener("message", function({ data: e }) {
|
|
2883
|
+
e && e.type === ie && at(e.changedParts);
|
|
2884
|
+
});
|
|
2885
|
+
}
|
|
2886
|
+
S.rejectionMapper = function(t, e) {
|
|
2887
|
+
if (!t || t instanceof xe || t instanceof TypeError || t instanceof SyntaxError || !t.name || !gn[t.name])
|
|
2888
|
+
return t;
|
|
2889
|
+
var n = new gn[t.name](e || t.message, t);
|
|
2890
|
+
return "stack" in t && ee(n, "stack", { get: function() {
|
|
2891
|
+
return this.inner.stack;
|
|
2892
|
+
} }), n;
|
|
2893
|
+
}, $n(G, Xn);
|
|
2894
|
+
class ns extends pe {
|
|
2895
|
+
constructor() {
|
|
2896
|
+
super("NylasAuthDatabase"), ut(this, "grant"), ut(this, "pkce"), this.version(1).stores({
|
|
2897
|
+
grant: "++id,token",
|
|
2898
|
+
pkce: "++id,codeVerifier"
|
|
2899
|
+
}), this.grant = this.table("grant"), this.pkce = this.table("pkce");
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
class rs {
|
|
2903
|
+
constructor() {
|
|
2904
|
+
ut(this, "theDB"), this.theDB = new ns();
|
|
2905
|
+
}
|
|
2906
|
+
async setCodeVerifier(e) {
|
|
2907
|
+
await this.theDB.pkce.put({ id: 1, codeVerifier: e }, 1);
|
|
2908
|
+
}
|
|
2909
|
+
async getCodeVerifier() {
|
|
2910
|
+
const [e] = await this.theDB.pkce.toArray();
|
|
2911
|
+
return e ? e.codeVerifier : null;
|
|
2912
|
+
}
|
|
2913
|
+
async getTokenInfo() {
|
|
2914
|
+
const e = await this.theDB.grant.get(1);
|
|
2915
|
+
return e ? e.token : null;
|
|
2916
|
+
}
|
|
2917
|
+
async setTokenInfo(e) {
|
|
2918
|
+
await this.theDB.grant.put({ id: 1, token: e }, 1);
|
|
2919
|
+
}
|
|
2920
|
+
async reset() {
|
|
2921
|
+
await this.theDB.grant.clear();
|
|
2922
|
+
}
|
|
2923
|
+
}
|
|
2924
|
+
function ms(t) {
|
|
2925
|
+
const e = "NylasAuth";
|
|
2926
|
+
if (!t)
|
|
2927
|
+
throw new Error("NylasAuth requires a config object");
|
|
2928
|
+
let n = null;
|
|
2929
|
+
if (t.storageType === "indexeddb" && (n = new rs()), !n)
|
|
2930
|
+
throw new Error("NylasAuth requires a storage object");
|
|
2931
|
+
const r = [
|
|
2932
|
+
{
|
|
2933
|
+
type: "read-only",
|
|
2934
|
+
value: "https://www.googleapis.com/auth/gmail.readonly"
|
|
2935
|
+
},
|
|
2936
|
+
{
|
|
2937
|
+
type: "modify",
|
|
2938
|
+
value: "https://www.googleapis.com/auth/gmail.modify"
|
|
2939
|
+
},
|
|
2940
|
+
{
|
|
2941
|
+
type: "compose",
|
|
2942
|
+
value: "https://www.googleapis.com/auth/gmail.compose"
|
|
2943
|
+
},
|
|
2944
|
+
{
|
|
2945
|
+
type: "insert",
|
|
2946
|
+
value: "https://www.googleapis.com/auth/gmail.insert"
|
|
2947
|
+
},
|
|
2948
|
+
{
|
|
2949
|
+
type: "labels",
|
|
2950
|
+
value: "https://www.googleapis.com/auth/gmail.labels"
|
|
2951
|
+
},
|
|
2952
|
+
{
|
|
2953
|
+
type: "metadata",
|
|
2954
|
+
value: "https://www.googleapis.com/auth/gmail.metadata"
|
|
2955
|
+
},
|
|
2956
|
+
{
|
|
2957
|
+
type: "settings.basic",
|
|
2958
|
+
value: "https://www.googleapis.com/auth/gmail.settings.basic"
|
|
2959
|
+
},
|
|
2960
|
+
{
|
|
2961
|
+
type: "settings.sharing",
|
|
2962
|
+
value: "https://www.googleapis.com/auth/gmail.settings.sharing"
|
|
2963
|
+
}
|
|
2964
|
+
], s = [
|
|
2965
|
+
{
|
|
2966
|
+
type: "read-only",
|
|
2967
|
+
value: "https://outlook.office.com/mail.read"
|
|
2968
|
+
},
|
|
2969
|
+
{
|
|
2970
|
+
type: "modify",
|
|
2971
|
+
value: "https://outlook.office.com/mail.readwrite"
|
|
2972
|
+
},
|
|
2973
|
+
{
|
|
2974
|
+
type: "send",
|
|
2975
|
+
value: "https://outlook.office.com/mail.send"
|
|
2976
|
+
},
|
|
2977
|
+
{
|
|
2978
|
+
type: "offline",
|
|
2979
|
+
value: "offline_access"
|
|
2980
|
+
}
|
|
2981
|
+
];
|
|
2982
|
+
async function i(o, u, a, l = !0, h, c) {
|
|
2983
|
+
const d = await (n == null ? void 0 : n.getTokenInfo()), m = new URL(o, h ?? t.apiUri), p = new Headers();
|
|
2984
|
+
p.append("Accept", "application/json"), p.append("Content-Type", "application/json"), p.append("User-Agent", e), d && p.append("Authorization", `Bearer ${d.access_token}`);
|
|
2985
|
+
const f = await fetch(m.toString(), {
|
|
2986
|
+
method: u || "GET",
|
|
2987
|
+
headers: p,
|
|
2988
|
+
mode: "cors",
|
|
2989
|
+
referrer: location.origin,
|
|
2990
|
+
body: a ? JSON.stringify(a) : void 0,
|
|
2991
|
+
...c || {}
|
|
2992
|
+
});
|
|
2993
|
+
return l ? await f.json() : f.body;
|
|
2994
|
+
}
|
|
2995
|
+
return {
|
|
2996
|
+
config: t,
|
|
2997
|
+
/**
|
|
2998
|
+
* This method will make a request to the Nylas API to exchange an authorization code for an access token.
|
|
2999
|
+
* @param scopes The scopes that were used to generate the authorization code
|
|
3000
|
+
* @param email The email that was used to generate the authorization code
|
|
3001
|
+
* @param provider The provider that was used to generate the authorization code
|
|
3002
|
+
* @returns A promise that resolves to a URL string that can be used to redirect the user to the Nylas API to complete the authorization flow
|
|
3003
|
+
*/
|
|
3004
|
+
async getHostedAuthRedirectURL(o = t.defaultScopes, u, a) {
|
|
3005
|
+
const l = await mn(Math.random().toString()), h = await mn(l);
|
|
3006
|
+
await (n == null ? void 0 : n.setCodeVerifier(l));
|
|
3007
|
+
const c = new URL(`${t.apiUri}/v3/connect/auth`);
|
|
3008
|
+
return c.searchParams.set("client_id", t.clientId), c.searchParams.set("response_type", "code"), c.searchParams.set("scope", o.join(" ")), c.searchParams.set("redirect_uri", t.redirectURI), c.searchParams.set("access_type", "offline"), c.searchParams.set("code_challenge", h), c.searchParams.set("code_challenge_method", "S256"), c.searchParams.set("options", "rotate_refresh_token"), a && c.searchParams.set("provider", a), u && c.searchParams.set("login_hint", u), c.toString();
|
|
3009
|
+
},
|
|
3010
|
+
/**
|
|
3011
|
+
* This method will make a request to the Nylas API to exchange an authorization code for an access token.
|
|
3012
|
+
* @param path A path to the Nylas API, e.g. `/v3/grants/methreads`
|
|
3013
|
+
* @param method GET, POST, PUT, DELETE, etc.
|
|
3014
|
+
* @param body A JSON object to send as the body of the request
|
|
3015
|
+
* @param domain The domain to use for the request, e.g. `api.us.nylas.com`
|
|
3016
|
+
* @param parseJSON Whether to parse the response as JSON or return the raw response (default: true)
|
|
3017
|
+
* @returns
|
|
3018
|
+
*/
|
|
3019
|
+
nylasAPIRequest: i,
|
|
3020
|
+
/**
|
|
3021
|
+
* This method will make a request to the Nylas API to exchange an authorization code for an access token.
|
|
3022
|
+
* @param code The authorization code that was returned from the Nylas API
|
|
3023
|
+
* @returns A promise that resolves to a TokenExchangeResponse object
|
|
3024
|
+
*/
|
|
3025
|
+
async exchangeAuthCodeForTokenInfo(o) {
|
|
3026
|
+
if (!o)
|
|
3027
|
+
return null;
|
|
3028
|
+
const u = await (n == null ? void 0 : n.getCodeVerifier()), a = await this.nylasAPIRequest("/v3/connect/token", "POST", {
|
|
3029
|
+
code: o,
|
|
3030
|
+
client_id: t.clientId,
|
|
3031
|
+
grant_type: "authorization_code",
|
|
3032
|
+
redirect_uri: t.redirectURI,
|
|
3033
|
+
code_verifier: u
|
|
3034
|
+
});
|
|
3035
|
+
return "error" in a || await (n == null ? void 0 : n.setTokenInfo(a)), a;
|
|
3036
|
+
},
|
|
3037
|
+
/**
|
|
3038
|
+
* This method will make a `application/octet-stream` request to the Nylas API to download a file.
|
|
3039
|
+
*/
|
|
3040
|
+
async nylasDownloadFileRequest(o, u = "GET", a) {
|
|
3041
|
+
const l = await (n == null ? void 0 : n.getTokenInfo()), h = new URL(o, t.apiUri), c = new Headers();
|
|
3042
|
+
return c.append("Accept", "application/json"), c.append("Content-Type", "application/octet-stream"), c.append("User-Agent", e), l && c.append("Authorization", `Bearer ${l.access_token}`), (await fetch(h.toString(), {
|
|
3043
|
+
method: u,
|
|
3044
|
+
headers: c,
|
|
3045
|
+
mode: "cors",
|
|
3046
|
+
referrer: location.origin,
|
|
3047
|
+
body: a ? JSON.stringify(a) : void 0
|
|
3048
|
+
})).blob();
|
|
3049
|
+
},
|
|
3050
|
+
/**
|
|
3051
|
+
* This methid will clear the access token from the storage object
|
|
3052
|
+
*/
|
|
3053
|
+
async logout() {
|
|
3054
|
+
const o = await (n == null ? void 0 : n.getTokenInfo());
|
|
3055
|
+
o && await this.nylasAPIRequest(`/v3/connect/revoke?token=${o.access_token}`, "POST"), await (n == null ? void 0 : n.reset());
|
|
3056
|
+
},
|
|
3057
|
+
/**
|
|
3058
|
+
* This method will make a request to the Nylas API to exchange an authorization code for an access token.
|
|
3059
|
+
* @returns A promise that resolves to a boolean indicating whether the user is authenticated
|
|
3060
|
+
*/
|
|
3061
|
+
async isAuthenticated() {
|
|
3062
|
+
return !!await (n == null ? void 0 : n.getTokenInfo());
|
|
3063
|
+
},
|
|
3064
|
+
/**
|
|
3065
|
+
* This method will return information about the current access token.
|
|
3066
|
+
* @returns A promise with the token info
|
|
3067
|
+
*/
|
|
3068
|
+
async getTokenInfo() {
|
|
3069
|
+
const o = await (n == null ? void 0 : n.getTokenInfo());
|
|
3070
|
+
if (!o)
|
|
3071
|
+
return null;
|
|
3072
|
+
const { access_token: u, ...a } = o;
|
|
3073
|
+
return a;
|
|
3074
|
+
},
|
|
3075
|
+
/**
|
|
3076
|
+
* This method will make a request to the Nylas API to validate if the current access token is valid.
|
|
3077
|
+
* @returns A promise that resolves to a boolean indicating whether the current access token is valid
|
|
3078
|
+
*/
|
|
3079
|
+
async isAccessTokenValid() {
|
|
3080
|
+
const o = await (n == null ? void 0 : n.getTokenInfo());
|
|
3081
|
+
return o ? "data" in await this.nylasAPIRequest(
|
|
3082
|
+
`/v3/connect/tokeninfo?id_token=${o.id_token}`,
|
|
3083
|
+
"GET"
|
|
3084
|
+
) : !1;
|
|
3085
|
+
},
|
|
3086
|
+
/**
|
|
3087
|
+
* This method will make a request to the Nylas API to refresh the current access token.
|
|
3088
|
+
* @returns A promise that resolves to a TokenExchangeResponse object
|
|
3089
|
+
*/
|
|
3090
|
+
async refreshAccessToken() {
|
|
3091
|
+
const o = await (n == null ? void 0 : n.getTokenInfo());
|
|
3092
|
+
if (!o)
|
|
3093
|
+
return null;
|
|
3094
|
+
const u = await this.nylasAPIRequest("/v3/connect/token", "POST", {
|
|
3095
|
+
client_id: t.clientId,
|
|
3096
|
+
grant_type: "refresh_token",
|
|
3097
|
+
refresh_token: o.refresh_token
|
|
3098
|
+
});
|
|
3099
|
+
return "error" in u || await (n == null ? void 0 : n.setTokenInfo(u)), u;
|
|
3100
|
+
},
|
|
3101
|
+
/**
|
|
3102
|
+
* This method will return true if the current access token has the given scope
|
|
3103
|
+
* based on the type of scope (e.g. 'read-only', 'modify', 'compose', 'insert', 'labels', 'metadata', 'settings.basic', or 'settings.sharing')
|
|
3104
|
+
* @param type Either 'read-only', 'modify', 'compose', 'insert', 'labels', 'metadata', 'settings.basic', or 'settings.sharing'
|
|
3105
|
+
*/
|
|
3106
|
+
async hasScopeByType(o = "email", u) {
|
|
3107
|
+
const a = await (n == null ? void 0 : n.getTokenInfo());
|
|
3108
|
+
if (!a)
|
|
3109
|
+
return !1;
|
|
3110
|
+
const l = a.scope.toLowerCase().split(" ");
|
|
3111
|
+
let h = [];
|
|
3112
|
+
const c = Array.isArray(u) ? u : [u];
|
|
3113
|
+
return o === "email" && (h = [...s, ...r].filter(
|
|
3114
|
+
(d) => c.includes(d.type)
|
|
3115
|
+
)), h.every((d) => l.includes(d.value));
|
|
3116
|
+
},
|
|
3117
|
+
/**
|
|
3118
|
+
* A helper method to check if the current access token has a given scope.
|
|
3119
|
+
* @param scope The scope(s) to check for in the current access token (e.g. https://www.googleapis.com/auth/gmail.modify)
|
|
3120
|
+
* @returns boolean indicating whether the current access token has the given scope
|
|
3121
|
+
*/
|
|
3122
|
+
async hasScope(o) {
|
|
3123
|
+
const u = await (n == null ? void 0 : n.getTokenInfo());
|
|
3124
|
+
if (!u)
|
|
3125
|
+
return !1;
|
|
3126
|
+
const a = u.scope.toLowerCase().split(" ");
|
|
3127
|
+
return (Array.isArray(o) ? o : [o]).some((l) => a.includes(l.toLowerCase()));
|
|
3128
|
+
}
|
|
3129
|
+
};
|
|
3130
|
+
}
|
|
3131
|
+
const ss = (t, e, n) => {
|
|
3132
|
+
const r = t.get(e);
|
|
3133
|
+
r ? r.includes(n) || r.push(n) : t.set(e, [n]);
|
|
3134
|
+
}, is = (t, e) => {
|
|
3135
|
+
let n;
|
|
3136
|
+
return (...r) => {
|
|
3137
|
+
n && clearTimeout(n), n = setTimeout(() => {
|
|
3138
|
+
n = 0, t(...r);
|
|
3139
|
+
}, e);
|
|
3140
|
+
};
|
|
3141
|
+
}, os = (t) => !("isConnected" in t) || t.isConnected, Tn = is((t) => {
|
|
3142
|
+
for (let e of t.keys())
|
|
3143
|
+
t.set(e, t.get(e).filter(os));
|
|
3144
|
+
}, 2e3), as = () => {
|
|
3145
|
+
if (typeof fn != "function")
|
|
3146
|
+
return {};
|
|
3147
|
+
const t = /* @__PURE__ */ new Map();
|
|
3148
|
+
return {
|
|
3149
|
+
dispose: () => t.clear(),
|
|
3150
|
+
get: (e) => {
|
|
3151
|
+
const n = fn();
|
|
3152
|
+
n && ss(t, e, n);
|
|
3153
|
+
},
|
|
3154
|
+
set: (e) => {
|
|
3155
|
+
const n = t.get(e);
|
|
3156
|
+
n && t.set(e, n.filter(pn)), Tn(t);
|
|
3157
|
+
},
|
|
3158
|
+
reset: () => {
|
|
3159
|
+
t.forEach((e) => e.forEach(pn)), Tn(t);
|
|
3160
|
+
}
|
|
3161
|
+
};
|
|
3162
|
+
}, Ct = (t) => typeof t == "function" ? t() : t, us = (t, e = (n, r) => n !== r) => {
|
|
3163
|
+
const n = Ct(t);
|
|
3164
|
+
let r = new Map(Object.entries(n ?? {}));
|
|
3165
|
+
const s = {
|
|
3166
|
+
dispose: [],
|
|
3167
|
+
get: [],
|
|
3168
|
+
set: [],
|
|
3169
|
+
reset: []
|
|
3170
|
+
}, i = () => {
|
|
3171
|
+
var p;
|
|
3172
|
+
r = new Map(Object.entries((p = Ct(t)) !== null && p !== void 0 ? p : {})), s.reset.forEach((f) => f());
|
|
3173
|
+
}, o = () => {
|
|
3174
|
+
s.dispose.forEach((p) => p()), i();
|
|
3175
|
+
}, u = (p) => (s.get.forEach((f) => f(p)), r.get(p)), a = (p, f) => {
|
|
3176
|
+
const y = r.get(p);
|
|
3177
|
+
e(f, y, p) && (r.set(p, f), s.set.forEach((g) => g(p, f, y)));
|
|
3178
|
+
}, l = typeof Proxy > "u" ? {} : new Proxy(n, {
|
|
3179
|
+
get(p, f) {
|
|
3180
|
+
return u(f);
|
|
3181
|
+
},
|
|
3182
|
+
ownKeys(p) {
|
|
3183
|
+
return Array.from(r.keys());
|
|
3184
|
+
},
|
|
3185
|
+
getOwnPropertyDescriptor() {
|
|
3186
|
+
return {
|
|
3187
|
+
enumerable: !0,
|
|
3188
|
+
configurable: !0
|
|
3189
|
+
};
|
|
3190
|
+
},
|
|
3191
|
+
has(p, f) {
|
|
3192
|
+
return r.has(f);
|
|
3193
|
+
},
|
|
3194
|
+
set(p, f, y) {
|
|
3195
|
+
return a(f, y), !0;
|
|
3196
|
+
}
|
|
3197
|
+
}), h = (p, f) => (s[p].push(f), () => {
|
|
3198
|
+
cs(s[p], f);
|
|
3199
|
+
});
|
|
3200
|
+
return {
|
|
3201
|
+
state: l,
|
|
3202
|
+
get: u,
|
|
3203
|
+
set: a,
|
|
3204
|
+
on: h,
|
|
3205
|
+
onChange: (p, f) => {
|
|
3206
|
+
const y = h("set", (v, b) => {
|
|
3207
|
+
v === p && f(b);
|
|
3208
|
+
}), g = h("reset", () => f(Ct(t)[p]));
|
|
3209
|
+
return () => {
|
|
3210
|
+
y(), g();
|
|
3211
|
+
};
|
|
3212
|
+
},
|
|
3213
|
+
use: (...p) => {
|
|
3214
|
+
const f = p.reduce((y, g) => (g.set && y.push(h("set", g.set)), g.get && y.push(h("get", g.get)), g.reset && y.push(h("reset", g.reset)), g.dispose && y.push(h("dispose", g.dispose)), y), []);
|
|
3215
|
+
return () => f.forEach((y) => y());
|
|
3216
|
+
},
|
|
3217
|
+
dispose: o,
|
|
3218
|
+
reset: i,
|
|
3219
|
+
forceUpdate: (p) => {
|
|
3220
|
+
const f = r.get(p);
|
|
3221
|
+
s.set.forEach((y) => y(p, f, f));
|
|
3222
|
+
}
|
|
3223
|
+
};
|
|
3224
|
+
}, cs = (t, e) => {
|
|
3225
|
+
const n = t.indexOf(e);
|
|
3226
|
+
n >= 0 && (t[n] = t[t.length - 1], t.length--);
|
|
3227
|
+
}, gs = (t, e) => {
|
|
3228
|
+
const n = us(t, e);
|
|
3229
|
+
return n.use(as()), n;
|
|
3230
|
+
};
|
|
3231
|
+
export {
|
|
3232
|
+
ds as N,
|
|
3233
|
+
fs as X,
|
|
3234
|
+
ps as Z,
|
|
3235
|
+
gs as c,
|
|
3236
|
+
ms as e,
|
|
3237
|
+
lr as n
|
|
3238
|
+
};
|