@nylas/react 2.1.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/dist/cjs/connect.js +1 -0
  2. package/dist/cjs/elements.js +1 -0
  3. package/dist/cjs/index.js +1 -0
  4. package/dist/cjs/notetaker.js +62 -0
  5. package/dist/cjs/utils.js +11 -0
  6. package/dist/connect.d.ts +1 -0
  7. package/dist/elements.d.ts +1 -0
  8. package/dist/es/connect.js +279 -0
  9. package/dist/es/elements.js +1319 -0
  10. package/dist/es/index.js +281 -0
  11. package/dist/es/notetaker.js +5784 -0
  12. package/dist/es/utils.js +12396 -0
  13. package/dist/lib/connect/types.d.ts +1 -1
  14. package/dist/lib/connect/useNylasConnect.d.ts +2 -2
  15. package/dist/lib/connect.d.ts +1 -0
  16. package/dist/lib/elements/components.d.ts +975 -0
  17. package/dist/lib/elements.d.ts +1 -0
  18. package/dist/lib/index.d.ts +3 -6
  19. package/dist/lib/notetaker.d.ts +1 -0
  20. package/dist/lib/utils.d.ts +2 -0
  21. package/dist/notetaker.d.ts +1 -0
  22. package/dist/utils.d.ts +1 -0
  23. package/package.json +36 -16
  24. package/dist/add-circle-icon_2.entry-8c3bb0bb.cjs +0 -1
  25. package/dist/add-circle-icon_2.entry-a3daf6c4.js +0 -28
  26. package/dist/archive-icon.entry-46ad0ff3.cjs +0 -1
  27. package/dist/archive-icon.entry-d5141486.js +0 -18
  28. package/dist/arrow-icon.entry-1b89ce78.js +0 -18
  29. package/dist/arrow-icon.entry-f696de4f.cjs +0 -1
  30. package/dist/bold-icon.entry-7827cd4e.cjs +0 -1
  31. package/dist/bold-icon.entry-c117b4cf.js +0 -18
  32. package/dist/button-component_2.entry-8cd4c5f3.cjs +0 -1
  33. package/dist/button-component_2.entry-e68caa9b.js +0 -29
  34. package/dist/calendar-agenda-fill-icon_37.entry-52bdc8b3.js +0 -5234
  35. package/dist/calendar-agenda-fill-icon_37.entry-8c592cfa.cjs +0 -6
  36. package/dist/calendar-cancel-icon.entry-7facfa05.cjs +0 -1
  37. package/dist/calendar-cancel-icon.entry-f5f1d499.js +0 -18
  38. package/dist/calendar-check-icon.entry-55320137.js +0 -18
  39. package/dist/calendar-check-icon.entry-72108702.cjs +0 -1
  40. package/dist/calendar-icon.entry-afea361e.js +0 -18
  41. package/dist/calendar-icon.entry-f5c6730f.cjs +0 -1
  42. package/dist/checkbox-component.entry-5722d263.cjs +0 -1
  43. package/dist/checkbox-component.entry-89fa6edd.js +0 -54
  44. package/dist/checkbox-group_4.entry-30e8af17.cjs +0 -28
  45. package/dist/checkbox-group_4.entry-51f03009.js +0 -10014
  46. package/dist/checkmark-circle-icon.entry-ae11049d.cjs +0 -1
  47. package/dist/checkmark-circle-icon.entry-dfe67e22.js +0 -18
  48. package/dist/checkmark-icon_15.entry-4c3979db.js +0 -1415
  49. package/dist/checkmark-icon_15.entry-e59c0f53.cjs +0 -5
  50. package/dist/chevron-icon_3.entry-1f3c3ca6.js +0 -159
  51. package/dist/chevron-icon_3.entry-ea791750.cjs +0 -1
  52. package/dist/clock-icon_4.entry-172fed74.cjs +0 -1
  53. package/dist/clock-icon_4.entry-78878cb8.js +0 -48
  54. package/dist/constants-f51538ef-cd2a67c4.cjs +0 -1
  55. package/dist/constants-f51538ef-e0a5f026.js +0 -876
  56. package/dist/customParseFormat-b5d95b34-a6b6fcba.cjs +0 -1
  57. package/dist/customParseFormat-b5d95b34-ce80820c.js +0 -135
  58. package/dist/delete-icon.entry-a8c0bf03.cjs +0 -1
  59. package/dist/delete-icon.entry-cebdc90f.js +0 -18
  60. package/dist/document-refresh-icon.entry-2d9a529d.cjs +0 -1
  61. package/dist/document-refresh-icon.entry-8780a2b8.js +0 -18
  62. package/dist/feedbackSync-92220b42-fbebe1f9.cjs +0 -448
  63. package/dist/feedbackSync-92220b42-fd5f5610.js +0 -6048
  64. package/dist/folder-icon.entry-3e61ccca.cjs +0 -1
  65. package/dist/folder-icon.entry-6ffd5191.js +0 -18
  66. package/dist/forward-icon.entry-c7d88db8.cjs +0 -1
  67. package/dist/forward-icon.entry-c9c4bf5b.js +0 -18
  68. package/dist/globe-icon.entry-0b93cab8.cjs +0 -1
  69. package/dist/globe-icon.entry-7c0dca7b.js +0 -18
  70. package/dist/google-logo-icon_6.entry-deef91ee.js +0 -1765
  71. package/dist/google-logo-icon_6.entry-e25ce3e7.cjs +0 -2
  72. package/dist/google-meet-icon_5.entry-214347f0.cjs +0 -1
  73. package/dist/google-meet-icon_5.entry-f8b5a92a.js +0 -58
  74. package/dist/inbox-icon.entry-873062c3.js +0 -18
  75. package/dist/inbox-icon.entry-f08f2fd5.cjs +0 -1
  76. package/dist/index-025be398.js +0 -7187
  77. package/dist/index-c510313d-1318f67a.js +0 -289
  78. package/dist/index-c510313d-b0508eee.cjs +0 -1
  79. package/dist/index-f42fe591.cjs +0 -65
  80. package/dist/index.es-488bc919-d02dd50a.cjs +0 -7
  81. package/dist/index.es-488bc919-ea63a7e9.js +0 -2724
  82. package/dist/info-icon_2.entry-442b9097.cjs +0 -1
  83. package/dist/info-icon_2.entry-60fb8648.js +0 -37
  84. package/dist/input-component.entry-5898a52e.js +0 -96
  85. package/dist/input-component.entry-7274fd28.cjs +0 -1
  86. package/dist/input-dropdown_2.entry-4534436c.js +0 -255
  87. package/dist/input-dropdown_2.entry-9b72f637.cjs +0 -1
  88. package/dist/italic-icon.entry-62052cd8.js +0 -18
  89. package/dist/italic-icon.entry-9bdbbd37.cjs +0 -1
  90. package/dist/lib/elements/index.d.ts +0 -133
  91. package/dist/lib/elements/react-component-lib/createComponent.d.ts +0 -10
  92. package/dist/lib/elements/react-component-lib/createOverlayComponent.d.ts +0 -21
  93. package/dist/lib/elements/react-component-lib/index.d.ts +0 -2
  94. package/dist/lib/elements/react-component-lib/interfaces.d.ts +0 -29
  95. package/dist/lib/elements/react-component-lib/utils/attachProps.d.ts +0 -9
  96. package/dist/lib/elements/react-component-lib/utils/case.d.ts +0 -2
  97. package/dist/lib/elements/react-component-lib/utils/dev.d.ts +0 -2
  98. package/dist/lib/elements/react-component-lib/utils/index.d.ts +0 -10
  99. package/dist/multi-select-dropdown.entry-77752d46.cjs +0 -1
  100. package/dist/multi-select-dropdown.entry-9c9d05c1.js +0 -133
  101. package/dist/nylas-booked-event-card_11.entry-32b2e9f1.js +0 -1410
  102. package/dist/nylas-booked-event-card_11.entry-4aba5146.cjs +0 -1
  103. package/dist/nylas-date-component_2.entry-6b058796.cjs +0 -1
  104. package/dist/nylas-date-component_2.entry-a869519f.js +0 -310
  105. package/dist/nylas-form-card.entry-5390459f.js +0 -75
  106. package/dist/nylas-form-card.entry-c2f34d73.cjs +0 -1
  107. package/dist/nylas-notification_2.entry-054392cf.cjs +0 -1
  108. package/dist/nylas-notification_2.entry-f46e88e5.js +0 -88
  109. package/dist/nylas-scheduler-editor.entry-40a48f47.js +0 -1854
  110. package/dist/nylas-scheduler-editor.entry-e29fdf07.cjs +0 -2
  111. package/dist/nylas-scheduling.entry-115b1752.js +0 -1002
  112. package/dist/nylas-scheduling.entry-79cb1d9c.cjs +0 -1
  113. package/dist/person-icon.entry-2cae306c.cjs +0 -1
  114. package/dist/person-icon.entry-fd668b89.js +0 -18
  115. package/dist/play-icon.entry-7fc3c0fd.js +0 -18
  116. package/dist/play-icon.entry-9989a520.cjs +0 -1
  117. package/dist/radio-button-group.entry-03385b5f.cjs +0 -1
  118. package/dist/radio-button-group.entry-9df82cd0.js +0 -58
  119. package/dist/react.cjs +0 -1
  120. package/dist/react.js +0 -164
  121. package/dist/refresh-icon.entry-310954ba.cjs +0 -1
  122. package/dist/refresh-icon.entry-c56e5623.js +0 -18
  123. package/dist/register-component-3acd57e7-5a79a90a.cjs +0 -1
  124. package/dist/register-component-3acd57e7-cb09c05e.js +0 -110
  125. package/dist/reply-all-icon.entry-32e0e000.js +0 -18
  126. package/dist/reply-all-icon.entry-68388f97.cjs +0 -1
  127. package/dist/reply-icon.entry-3ac2e736.js +0 -18
  128. package/dist/reply-icon.entry-e616a9a4.cjs +0 -1
  129. package/dist/sent-icon.entry-0622ed04.js +0 -18
  130. package/dist/sent-icon.entry-543eb3c4.cjs +0 -1
  131. package/dist/spam-icon.entry-74bcfd4f.js +0 -18
  132. package/dist/spam-icon.entry-e341ee3e.cjs +0 -1
  133. package/dist/star-icon.entry-864d2bf9.js +0 -18
  134. package/dist/star-icon.entry-c90d40f6.cjs +0 -1
  135. package/dist/stop-icon.entry-835908c5.js +0 -18
  136. package/dist/stop-icon.entry-ffc46b42.cjs +0 -1
  137. package/dist/textarea-component.entry-6adcf6a6.js +0 -58
  138. package/dist/textarea-component.entry-dae8eb5c.cjs +0 -1
  139. package/dist/toggle-switch.entry-5ee29867.cjs +0 -1
  140. package/dist/toggle-switch.entry-ff2ccb75.js +0 -51
  141. package/dist/translate-icon.entry-372dd808.js +0 -18
  142. package/dist/translate-icon.entry-5606067d.cjs +0 -1
  143. package/dist/trash-fill-icon.entry-01b4379e.js +0 -18
  144. package/dist/trash-fill-icon.entry-daed6c0a.cjs +0 -1
  145. package/dist/underline-icon.entry-2020ee64.cjs +0 -1
  146. package/dist/underline-icon.entry-464b900d.js +0 -18
  147. package/dist/utils-31933f5d-15041585.js +0 -17878
  148. package/dist/utils-31933f5d-1d4c81ab.cjs +0 -54
@@ -1,2724 +0,0 @@
1
- import { n as Jn } from "./utils-31933f5d-15041585.js";
2
- var Zn = /* @__PURE__ */ ((t) => (t.Error = "error", t.Warning = "warning", t.Info = "info", t.Success = "success", t))(Zn || {});
3
- const zr = (t) => t !== null && typeof t == "object" && "error" in t, j = typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : typeof window < "u" ? window : Jn, B = Object.keys, N = Array.isArray;
4
- function U(t, e) {
5
- return typeof e != "object" || B(e).forEach(function(n) {
6
- t[n] = e[n];
7
- }), t;
8
- }
9
- typeof Promise > "u" || j.Promise || (j.Promise = Promise);
10
- const Fe = Object.getPrototypeOf, er = {}.hasOwnProperty;
11
- function W(t, e) {
12
- return er.call(t, e);
13
- }
14
- function Ee(t, e) {
15
- typeof e == "function" && (e = e(Fe(t))), (typeof Reflect > "u" ? B : Reflect.ownKeys)(e).forEach((n) => {
16
- Z(t, n, e[n]);
17
- });
18
- }
19
- const wn = Object.defineProperty;
20
- function Z(t, e, n, r) {
21
- wn(t, e, U(n && W(n, "get") && typeof n.get == "function" ? { get: n.get, set: n.set, configurable: !0 } : { value: n, configurable: !0, writable: !0 }, r));
22
- }
23
- function _e(t) {
24
- return { from: function(e) {
25
- return t.prototype = Object.create(e.prototype), Z(t.prototype, "constructor", t), { extend: Ee.bind(null, t.prototype) };
26
- } };
27
- }
28
- const tr = Object.getOwnPropertyDescriptor;
29
- function Xt(t, e) {
30
- let n;
31
- return tr(t, e) || (n = Fe(t)) && Xt(n, e);
32
- }
33
- const nr = [].slice;
34
- function at(t, e, n) {
35
- return nr.call(t, e, n);
36
- }
37
- function xn(t, e) {
38
- return e(t);
39
- }
40
- function Ce(t) {
41
- if (!t)
42
- throw new Error("Assertion Failed");
43
- }
44
- function kn(t) {
45
- j.setImmediate ? setImmediate(t) : setTimeout(t, 0);
46
- }
47
- function En(t, e) {
48
- return t.reduce((n, r, s) => {
49
- var i = e(r, s);
50
- return i && (n[i[0]] = i[1]), n;
51
- }, {});
52
- }
53
- function ee(t, e) {
54
- if (W(t, e))
55
- return t[e];
56
- if (!e)
57
- return t;
58
- if (typeof e != "string") {
59
- for (var n = [], r = 0, s = e.length; r < s; ++r) {
60
- var i = ee(t, e[r]);
61
- n.push(i);
62
- }
63
- return n;
64
- }
65
- var o = e.indexOf(".");
66
- if (o !== -1) {
67
- var u = t[e.substr(0, o)];
68
- return u === void 0 ? void 0 : ee(u, e.substr(o + 1));
69
- }
70
- }
71
- function z(t, e, n) {
72
- if (t && e !== void 0 && (!("isFrozen" in Object) || !Object.isFrozen(t)))
73
- if (typeof e != "string" && "length" in e) {
74
- Ce(typeof n != "string" && "length" in n);
75
- for (var r = 0, s = e.length; r < s; ++r)
76
- z(t, e[r], n[r]);
77
- } else {
78
- var i = e.indexOf(".");
79
- if (i !== -1) {
80
- var o = e.substr(0, i), u = e.substr(i + 1);
81
- if (u === "")
82
- n === void 0 ? N(t) && !isNaN(parseInt(o)) ? t.splice(o, 1) : delete t[o] : t[o] = n;
83
- else {
84
- var a = t[o];
85
- a && W(t, o) || (a = t[o] = {}), z(a, u, n);
86
- }
87
- } else
88
- n === void 0 ? N(t) && !isNaN(parseInt(e)) ? t.splice(e, 1) : delete t[e] : t[e] = n;
89
- }
90
- }
91
- function Pn(t) {
92
- var e = {};
93
- for (var n in t)
94
- W(t, n) && (e[n] = t[n]);
95
- return e;
96
- }
97
- const rr = [].concat;
98
- function Kn(t) {
99
- return rr.apply([], t);
100
- }
101
- const On = "Boolean,String,Date,RegExp,Blob,File,FileList,FileSystemFileHandle,ArrayBuffer,DataView,Uint8ClampedArray,ImageBitmap,ImageData,Map,Set,CryptoKey".split(",").concat(Kn([8, 16, 32, 64].map((t) => ["Int", "Uint", "Float"].map((e) => e + t + "Array")))).filter((t) => j[t]), sr = On.map((t) => j[t]);
102
- En(On, (t) => [t, !0]);
103
- let re = null;
104
- function Ve(t) {
105
- re = typeof WeakMap < "u" && /* @__PURE__ */ new WeakMap();
106
- const e = Pt(t);
107
- return re = null, e;
108
- }
109
- function Pt(t) {
110
- if (!t || typeof t != "object")
111
- return t;
112
- let e = re && re.get(t);
113
- if (e)
114
- return e;
115
- if (N(t)) {
116
- e = [], re && re.set(t, e);
117
- for (var n = 0, r = t.length; n < r; ++n)
118
- e.push(Pt(t[n]));
119
- } else if (sr.indexOf(t.constructor) >= 0)
120
- e = t;
121
- else {
122
- const i = Fe(t);
123
- for (var s in e = i === Object.prototype ? {} : Object.create(i), re && re.set(t, e), t)
124
- W(t, s) && (e[s] = Pt(t[s]));
125
- }
126
- return e;
127
- }
128
- const { toString: ir } = {};
129
- function Kt(t) {
130
- return ir.call(t).slice(8, -1);
131
- }
132
- const Ot = typeof Symbol < "u" ? Symbol.iterator : "@@iterator", or = typeof Ot == "symbol" ? function(t) {
133
- var e;
134
- return t != null && (e = t[Ot]) && e.apply(t);
135
- } : function() {
136
- return null;
137
- }, be = {};
138
- function Q(t) {
139
- var e, n, r, s;
140
- if (arguments.length === 1) {
141
- if (N(t))
142
- return t.slice();
143
- if (this === be && typeof t == "string")
144
- return [t];
145
- if (s = or(t)) {
146
- for (n = []; !(r = s.next()).done; )
147
- n.push(r.value);
148
- return n;
149
- }
150
- if (t == null)
151
- return [t];
152
- if (typeof (e = t.length) == "number") {
153
- for (n = new Array(e); e--; )
154
- n[e] = t[e];
155
- return n;
156
- }
157
- return [t];
158
- }
159
- for (e = arguments.length, n = new Array(e); e--; )
160
- n[e] = arguments[e];
161
- return n;
162
- }
163
- const Qt = typeof Symbol < "u" ? (t) => t[Symbol.toStringTag] === "AsyncFunction" : () => !1;
164
- var G = typeof location < "u" && /^(http|https):\/\/(localhost|127\.0\.0\.1)/.test(location.href);
165
- function Sn(t, e) {
166
- G = t, An = e;
167
- }
168
- var An = () => !0;
169
- const ar = !new Error("").stack;
170
- function Pe() {
171
- if (ar)
172
- try {
173
- throw new Error();
174
- } catch (t) {
175
- return t;
176
- }
177
- return new Error();
178
- }
179
- function St(t, e) {
180
- var n = t.stack;
181
- return n ? (e = e || 0, n.indexOf(t.name) === 0 && (e += (t.name + t.message).split(`
182
- `).length), n.split(`
183
- `).slice(e).filter(An).map((r) => `
184
- ` + r).join("")) : "";
185
- }
186
- var Cn = ["Unknown", "Constraint", "Data", "TransactionInactive", "ReadOnly", "Version", "NotFound", "InvalidState", "InvalidAccess", "Abort", "Timeout", "QuotaExceeded", "Syntax", "DataClone"], Jt = ["Modify", "Bulk", "OpenFailed", "VersionChange", "Schema", "Upgrade", "InvalidTable", "MissingAPI", "NoSuchDatabase", "InvalidArgument", "SubTransaction", "Unsupported", "Internal", "DatabaseClosed", "PrematureCommit", "ForeignAwait"].concat(Cn), ur = { 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" };
187
- function we(t, e) {
188
- this._e = Pe(), this.name = t, this.message = e;
189
- }
190
- function jn(t, e) {
191
- return t + ". Errors: " + Object.keys(e).map((n) => e[n].toString()).filter((n, r, s) => s.indexOf(n) === r).join(`
192
- `);
193
- }
194
- function ut(t, e, n, r) {
195
- this._e = Pe(), this.failures = e, this.failedKeys = r, this.successCount = n, this.message = jn(t, e);
196
- }
197
- function De(t, e) {
198
- this._e = Pe(), this.name = "BulkError", this.failures = Object.keys(e).map((n) => e[n]), this.failuresByPos = e, this.message = jn(t, e);
199
- }
200
- _e(we).from(Error).extend({ stack: { get: function() {
201
- return this._stack || (this._stack = this.name + ": " + this.message + St(this._e, 2));
202
- } }, toString: function() {
203
- return this.name + ": " + this.message;
204
- } }), _e(ut).from(we), _e(De).from(we);
205
- var Zt = Jt.reduce((t, e) => (t[e] = e + "Error", t), {});
206
- const lr = we;
207
- var O = Jt.reduce((t, e) => {
208
- var n = e + "Error";
209
- function r(s, i) {
210
- this._e = Pe(), this.name = n, s ? typeof s == "string" ? (this.message = `${s}${i ? `
211
- ` + i : ""}`, this.inner = i || null) : typeof s == "object" && (this.message = `${s.name} ${s.message}`, this.inner = s) : (this.message = ur[e] || n, this.inner = null);
212
- }
213
- return _e(r).from(lr), t[e] = r, t;
214
- }, {});
215
- O.Syntax = SyntaxError, O.Type = TypeError, O.Range = RangeError;
216
- var ln = Cn.reduce((t, e) => (t[e + "Error"] = O[e], t), {}), et = Jt.reduce((t, e) => (["Syntax", "Type", "Range"].indexOf(e) === -1 && (t[e + "Error"] = O[e]), t), {});
217
- function C() {
218
- }
219
- function Me(t) {
220
- return t;
221
- }
222
- function cr(t, e) {
223
- return t == null || t === Me ? e : function(n) {
224
- return e(t(n));
225
- };
226
- }
227
- function fe(t, e) {
228
- return function() {
229
- t.apply(this, arguments), e.apply(this, arguments);
230
- };
231
- }
232
- function hr(t, e) {
233
- return t === C ? e : function() {
234
- var n = t.apply(this, arguments);
235
- n !== void 0 && (arguments[0] = n);
236
- var r = this.onsuccess, s = this.onerror;
237
- this.onsuccess = null, this.onerror = null;
238
- var i = e.apply(this, arguments);
239
- return r && (this.onsuccess = this.onsuccess ? fe(r, this.onsuccess) : r), s && (this.onerror = this.onerror ? fe(s, this.onerror) : s), i !== void 0 ? i : n;
240
- };
241
- }
242
- function dr(t, e) {
243
- return t === C ? e : function() {
244
- t.apply(this, arguments);
245
- var n = this.onsuccess, r = this.onerror;
246
- this.onsuccess = this.onerror = null, e.apply(this, arguments), n && (this.onsuccess = this.onsuccess ? fe(n, this.onsuccess) : n), r && (this.onerror = this.onerror ? fe(r, this.onerror) : r);
247
- };
248
- }
249
- function fr(t, e) {
250
- return t === C ? e : function(n) {
251
- var r = t.apply(this, arguments);
252
- U(n, r);
253
- var s = this.onsuccess, i = this.onerror;
254
- this.onsuccess = null, this.onerror = null;
255
- var o = e.apply(this, arguments);
256
- return s && (this.onsuccess = this.onsuccess ? fe(s, this.onsuccess) : s), i && (this.onerror = this.onerror ? fe(i, this.onerror) : i), r === void 0 ? o === void 0 ? void 0 : o : U(r, o);
257
- };
258
- }
259
- function pr(t, e) {
260
- return t === C ? e : function() {
261
- return e.apply(this, arguments) !== !1 && t.apply(this, arguments);
262
- };
263
- }
264
- function en(t, e) {
265
- return t === C ? e : function() {
266
- var n = t.apply(this, arguments);
267
- if (n && typeof n.then == "function") {
268
- for (var r = this, s = arguments.length, i = new Array(s); s--; )
269
- i[s] = arguments[s];
270
- return n.then(function() {
271
- return e.apply(r, i);
272
- });
273
- }
274
- return e.apply(this, arguments);
275
- };
276
- }
277
- et.ModifyError = ut, et.DexieError = we, et.BulkError = De;
278
- var Ne = {};
279
- const Dn = 100, [At, lt, Ct] = typeof Promise > "u" ? [] : (() => {
280
- let t = Promise.resolve();
281
- if (typeof crypto > "u" || !crypto.subtle)
282
- return [t, Fe(t), t];
283
- const e = crypto.subtle.digest("SHA-512", new Uint8Array([0]));
284
- return [e, Fe(e), t];
285
- })(), In = lt && lt.then, tt = At && At.constructor, tn = !!Ct;
286
- var jt = !1, yr = Ct ? () => {
287
- Ct.then(Ye);
288
- } : j.setImmediate ? setImmediate.bind(null, Ye) : j.MutationObserver ? () => {
289
- var t = document.createElement("div");
290
- new MutationObserver(() => {
291
- Ye(), t = null;
292
- }).observe(t, { attributes: !0 }), t.setAttribute("i", "1");
293
- } : () => {
294
- setTimeout(Ye, 0);
295
- }, Ie = function(t, e) {
296
- je.push([t, e]), ct && (yr(), ct = !1);
297
- }, Dt = !0, ct = !0, he = [], nt = [], It = null, Tt = Me, xe = { id: "global", global: !0, ref: 0, unhandleds: [], onunhandled: dn, pgp: !1, env: {}, finalize: function() {
298
- this.unhandleds.forEach((t) => {
299
- try {
300
- dn(t[0], t[1]);
301
- } catch {
302
- }
303
- });
304
- } }, K = xe, je = [], de = 0, rt = [];
305
- function E(t) {
306
- if (typeof this != "object")
307
- throw new TypeError("Promises must be constructed via new");
308
- this._listeners = [], this.onuncatched = C, this._lib = !1;
309
- var e = this._PSD = K;
310
- if (G && (this._stackHolder = Pe(), this._prev = null, this._numPrev = 0), typeof t != "function") {
311
- if (t !== Ne)
312
- throw new TypeError("Not a function");
313
- return this._state = arguments[1], this._value = arguments[2], void (this._state === !1 && Rt(this, this._value));
314
- }
315
- this._state = null, this._value = null, ++e.ref, Bn(this, t);
316
- }
317
- const Bt = { get: function() {
318
- var t = K, e = ht;
319
- function n(r, s) {
320
- var i = !t.global && (t !== K || e !== ht);
321
- const o = i && !te();
322
- var u = new E((a, c) => {
323
- nn(this, new Tn(dt(r, t, i, o), dt(s, t, i, o), a, c, t));
324
- });
325
- return G && Mn(u, this), u;
326
- }
327
- return n.prototype = Ne, n;
328
- }, set: function(t) {
329
- Z(this, "then", t && t.prototype === Ne ? Bt : { get: function() {
330
- return t;
331
- }, set: Bt.set });
332
- } };
333
- function Tn(t, e, n, r, s) {
334
- this.onFulfilled = typeof t == "function" ? t : null, this.onRejected = typeof e == "function" ? e : null, this.resolve = n, this.reject = r, this.psd = s;
335
- }
336
- function Bn(t, e) {
337
- try {
338
- e((n) => {
339
- if (t._state === null) {
340
- if (n === t)
341
- throw new TypeError("A promise cannot be resolved with itself.");
342
- var r = t._lib && We();
343
- n && typeof n.then == "function" ? Bn(t, (s, i) => {
344
- n instanceof E ? n._then(s, i) : n.then(s, i);
345
- }) : (t._state = !0, t._value = n, Rn(t)), r && ze();
346
- }
347
- }, Rt.bind(null, t));
348
- } catch (n) {
349
- Rt(t, n);
350
- }
351
- }
352
- function Rt(t, e) {
353
- if (nt.push(e), t._state === null) {
354
- var n = t._lib && We();
355
- e = Tt(e), t._state = !1, t._value = e, G && e !== null && typeof e == "object" && !e._promise && function(r, s, i) {
356
- try {
357
- r.apply(null, i);
358
- } catch (o) {
359
- s && s(o);
360
- }
361
- }(() => {
362
- var r = Xt(e, "stack");
363
- e._promise = t, Z(e, "stack", { get: () => jt ? r && (r.get ? r.get.apply(e) : r.value) : t.stack });
364
- }), function(r) {
365
- he.some((s) => s._value === r._value) || he.push(r);
366
- }(t), Rn(t), n && ze();
367
- }
368
- }
369
- function Rn(t) {
370
- var e = t._listeners;
371
- t._listeners = [];
372
- for (var n = 0, r = e.length; n < r; ++n)
373
- nn(t, e[n]);
374
- var s = t._PSD;
375
- --s.ref || s.finalize(), de === 0 && (++de, Ie(() => {
376
- --de == 0 && rn();
377
- }, []));
378
- }
379
- function nn(t, e) {
380
- if (t._state !== null) {
381
- var n = t._state ? e.onFulfilled : e.onRejected;
382
- if (n === null)
383
- return (t._state ? e.resolve : e.reject)(t._value);
384
- ++e.psd.ref, ++de, Ie(mr, [n, t, e]);
385
- } else
386
- t._listeners.push(e);
387
- }
388
- function mr(t, e, n) {
389
- try {
390
- It = e;
391
- var r, s = e._value;
392
- e._state ? r = t(s) : (nt.length && (nt = []), r = t(s), nt.indexOf(s) === -1 && function(i) {
393
- for (var o = he.length; o; )
394
- if (he[--o]._value === i._value)
395
- return void he.splice(o, 1);
396
- }(e)), n.resolve(r);
397
- } catch (i) {
398
- n.reject(i);
399
- } finally {
400
- It = null, --de == 0 && rn(), --n.psd.ref || n.psd.finalize();
401
- }
402
- }
403
- function Fn(t, e, n) {
404
- if (e.length === n)
405
- return e;
406
- var r = "";
407
- if (t._state === !1) {
408
- var s, i, o = t._value;
409
- o != null ? (s = o.name || "Error", i = o.message || o, r = St(o, 0)) : (s = o, i = ""), e.push(s + (i ? ": " + i : "") + r);
410
- }
411
- return G && ((r = St(t._stackHolder, 2)) && e.indexOf(r) === -1 && e.push(r), t._prev && Fn(t._prev, e, n)), e;
412
- }
413
- function Mn(t, e) {
414
- var n = e ? e._numPrev + 1 : 0;
415
- n < 100 && (t._prev = e, t._numPrev = n);
416
- }
417
- function Ye() {
418
- We() && ze();
419
- }
420
- function We() {
421
- var t = Dt;
422
- return Dt = !1, ct = !1, t;
423
- }
424
- function ze() {
425
- var t, e, n;
426
- do
427
- for (; je.length > 0; )
428
- for (t = je, je = [], n = t.length, e = 0; e < n; ++e) {
429
- var r = t[e];
430
- r[0].apply(null, r[1]);
431
- }
432
- while (je.length > 0);
433
- Dt = !0, ct = !0;
434
- }
435
- function rn() {
436
- var t = he;
437
- he = [], t.forEach((r) => {
438
- r._PSD.onunhandled.call(null, r._value, r);
439
- });
440
- for (var e = rt.slice(0), n = e.length; n; )
441
- e[--n]();
442
- }
443
- function Ge(t) {
444
- return new E(Ne, !1, t);
445
- }
446
- function D(t, e) {
447
- var n = K;
448
- return function() {
449
- var r = We(), s = K;
450
- try {
451
- return oe(n, !0), t.apply(this, arguments);
452
- } catch (i) {
453
- e && e(i);
454
- } finally {
455
- oe(s, !1), r && ze();
456
- }
457
- };
458
- }
459
- Ee(E.prototype, { then: Bt, _then: function(t, e) {
460
- nn(this, new Tn(null, null, t, e, K));
461
- }, catch: function(t) {
462
- if (arguments.length === 1)
463
- return this.then(null, t);
464
- var e = arguments[0], n = arguments[1];
465
- 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));
466
- }, finally: function(t) {
467
- return this.then((e) => (t(), e), (e) => (t(), Ge(e)));
468
- }, stack: { get: function() {
469
- if (this._stack)
470
- return this._stack;
471
- try {
472
- jt = !0;
473
- var t = Fn(this, [], 20).join(`
474
- From previous: `);
475
- return this._state !== null && (this._stack = t), t;
476
- } finally {
477
- jt = !1;
478
- }
479
- } }, timeout: function(t, e) {
480
- return t < 1 / 0 ? new E((n, r) => {
481
- var s = setTimeout(() => r(new O.Timeout(e)), t);
482
- this.then(n, r).finally(clearTimeout.bind(null, s));
483
- }) : this;
484
- } }), typeof Symbol < "u" && Symbol.toStringTag && Z(E.prototype, Symbol.toStringTag, "Dexie.Promise"), xe.env = Nn(), Ee(E, { all: function() {
485
- var t = Q.apply(null, arguments).map(He);
486
- return new E(function(e, n) {
487
- t.length === 0 && e([]);
488
- var r = t.length;
489
- t.forEach((s, i) => E.resolve(s).then((o) => {
490
- t[i] = o, --r || e(t);
491
- }, n));
492
- });
493
- }, resolve: (t) => {
494
- if (t instanceof E)
495
- return t;
496
- if (t && typeof t.then == "function")
497
- return new E((n, r) => {
498
- t.then(n, r);
499
- });
500
- var e = new E(Ne, !0, t);
501
- return Mn(e, It), e;
502
- }, reject: Ge, race: function() {
503
- var t = Q.apply(null, arguments).map(He);
504
- return new E((e, n) => {
505
- t.map((r) => E.resolve(r).then(e, n));
506
- });
507
- }, PSD: { get: () => K, set: (t) => K = t }, totalEchoes: { get: () => ht }, newPSD: ie, usePSD: Oe, scheduler: { get: () => Ie, set: (t) => {
508
- Ie = t;
509
- } }, rejectionMapper: { get: () => Tt, set: (t) => {
510
- Tt = t;
511
- } }, follow: (t, e) => new E((n, r) => ie((s, i) => {
512
- var o = K;
513
- o.unhandleds = [], o.onunhandled = i, o.finalize = fe(function() {
514
- (function(u) {
515
- function a() {
516
- u(), rt.splice(rt.indexOf(a), 1);
517
- }
518
- rt.push(a), ++de, Ie(() => {
519
- --de == 0 && rn();
520
- }, []);
521
- })(() => {
522
- this.unhandleds.length === 0 ? s() : i(this.unhandleds[0]);
523
- });
524
- }, o.finalize), t();
525
- }, e, n, r)) }), tt && (tt.allSettled && Z(E, "allSettled", function() {
526
- const t = Q.apply(null, arguments).map(He);
527
- return new E((e) => {
528
- t.length === 0 && e([]);
529
- let n = t.length;
530
- const r = new Array(n);
531
- t.forEach((s, i) => E.resolve(s).then((o) => r[i] = { status: "fulfilled", value: o }, (o) => r[i] = { status: "rejected", reason: o }).then(() => --n || e(r)));
532
- });
533
- }), tt.any && typeof AggregateError < "u" && Z(E, "any", function() {
534
- const t = Q.apply(null, arguments).map(He);
535
- return new E((e, n) => {
536
- t.length === 0 && n(new AggregateError([]));
537
- let r = t.length;
538
- const s = new Array(r);
539
- t.forEach((i, o) => E.resolve(i).then((u) => e(u), (u) => {
540
- s[o] = u, --r || n(new AggregateError(s));
541
- }));
542
- });
543
- }));
544
- const M = { awaits: 0, echoes: 0, id: 0 };
545
- var gr = 0, st = [], vt = 0, ht = 0, vr = 0;
546
- function ie(t, e, n, r) {
547
- var s = K, i = Object.create(s);
548
- i.parent = s, i.ref = 0, i.global = !1, i.id = ++vr;
549
- var o = xe.env;
550
- i.env = tn ? { Promise: E, PromiseProp: { value: E, configurable: !0, writable: !0 }, all: E.all, race: E.race, allSettled: E.allSettled, any: E.any, resolve: E.resolve, reject: E.reject, nthen: cn(o.nthen, i), gthen: cn(o.gthen, i) } : {}, e && U(i, e), ++s.ref, i.finalize = function() {
551
- --this.parent.ref || this.parent.finalize();
552
- };
553
- var u = Oe(i, t, n, r);
554
- return i.ref === 0 && i.finalize(), u;
555
- }
556
- function Ke() {
557
- return M.id || (M.id = ++gr), ++M.awaits, M.echoes += Dn, M.id;
558
- }
559
- function te() {
560
- return !!M.awaits && (--M.awaits == 0 && (M.id = 0), M.echoes = M.awaits * Dn, !0);
561
- }
562
- function He(t) {
563
- return M.echoes && t && t.constructor === tt ? (Ke(), t.then((e) => (te(), e), (e) => (te(), R(e)))) : t;
564
- }
565
- function br(t) {
566
- ++ht, M.echoes && --M.echoes != 0 || (M.echoes = M.id = 0), st.push(K), oe(t, !0);
567
- }
568
- function _r() {
569
- var t = st[st.length - 1];
570
- st.pop(), oe(t, !1);
571
- }
572
- function oe(t, e) {
573
- var n = K;
574
- if ((e ? !M.echoes || vt++ && t === K : !vt || --vt && t === K) || qn(e ? br.bind(null, t) : _r), t !== K && (K = t, n === xe && (xe.env = Nn()), tn)) {
575
- var r = xe.env.Promise, s = t.env;
576
- lt.then = s.nthen, r.prototype.then = s.gthen, (n.global || t.global) && (Object.defineProperty(j, "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));
577
- }
578
- }
579
- function Nn() {
580
- var t = j.Promise;
581
- return tn ? { Promise: t, PromiseProp: Object.getOwnPropertyDescriptor(j, "Promise"), all: t.all, race: t.race, allSettled: t.allSettled, any: t.any, resolve: t.resolve, reject: t.reject, nthen: lt.then, gthen: t.prototype.then } : {};
582
- }
583
- function Oe(t, e, n, r, s) {
584
- var i = K;
585
- try {
586
- return oe(t, !0), e(n, r, s);
587
- } finally {
588
- oe(i, !1);
589
- }
590
- }
591
- function qn(t) {
592
- In.call(At, t);
593
- }
594
- function dt(t, e, n, r) {
595
- return typeof t != "function" ? t : function() {
596
- var s = K;
597
- n && Ke(), oe(e, !0);
598
- try {
599
- return t.apply(this, arguments);
600
- } finally {
601
- oe(s, !1), r && qn(te);
602
- }
603
- };
604
- }
605
- function cn(t, e) {
606
- return function(n, r) {
607
- return t.call(this, dt(n, e), dt(r, e));
608
- };
609
- }
610
- ("" + In).indexOf("[native code]") === -1 && (Ke = te = C);
611
- const hn = "unhandledrejection";
612
- function dn(t, e) {
613
- var n;
614
- try {
615
- n = e.onuncatched(t);
616
- } catch {
617
- }
618
- if (n !== !1)
619
- try {
620
- var r, s = { promise: e, reason: t };
621
- if (j.document && document.createEvent ? ((r = document.createEvent("Event")).initEvent(hn, !0, !0), U(r, s)) : j.CustomEvent && U(r = new CustomEvent(hn, { detail: s }), s), r && j.dispatchEvent && (dispatchEvent(r), !j.PromiseRejectionEvent && j.onunhandledrejection))
622
- try {
623
- j.onunhandledrejection(r);
624
- } catch {
625
- }
626
- G && r && !r.defaultPrevented && console.warn(`Unhandled rejection: ${t.stack || t}`);
627
- } catch {
628
- }
629
- }
630
- var R = E.reject;
631
- function Ft(t, e, n, r) {
632
- if (t.idbdb && (t._state.openComplete || K.letThrough || t._vip)) {
633
- var s = t._createTransaction(e, n, t._dbSchema);
634
- try {
635
- s.create(), t._state.PR1398_maxLoop = 3;
636
- } catch (i) {
637
- return i.name === Zt.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))) : R(i);
638
- }
639
- return s._promise(e, (i, o) => ie(() => (K.trans = s, r(i, o, s)))).then((i) => s._completion.then(() => i));
640
- }
641
- if (t._state.openComplete)
642
- return R(new O.DatabaseClosed(t._state.dbOpenError));
643
- if (!t._state.isBeingOpened) {
644
- if (!t._options.autoOpen)
645
- return R(new O.DatabaseClosed());
646
- t.open().catch(C);
647
- }
648
- return t._state.dbReadyPromise.then(() => Ft(t, e, n, r));
649
- }
650
- const fn = "3.2.4", ce = String.fromCharCode(65535), Mt = -1 / 0, H = "Invalid key provided. Keys must be of type string, number, Date or Array<string | number | Date>.", $n = "String expected.", Te = [], yt = typeof navigator < "u" && /(MSIE|Trident|Edge)/.test(navigator.userAgent), wr = yt, xr = yt, Un = (t) => !/(dexie\.js|dexie\.min\.js)/.test(t), mt = "__dbnames", bt = "readonly", _t = "readwrite";
651
- function pe(t, e) {
652
- return t ? e ? function() {
653
- return t.apply(this, arguments) && e.apply(this, arguments);
654
- } : t : e;
655
- }
656
- const Ln = { type: 3, lower: -1 / 0, lowerOpen: !1, upper: [[]], upperOpen: !1 };
657
- function Xe(t) {
658
- return typeof t != "string" || /\./.test(t) ? (e) => e : (e) => (e[t] === void 0 && t in e && delete (e = Ve(e))[t], e);
659
- }
660
- class kr {
661
- _trans(e, n, r) {
662
- const s = this._tx || K.trans, i = this.name;
663
- function o(a, c, h) {
664
- if (!h.schema[i])
665
- throw new O.NotFound("Table " + i + " not part of transaction");
666
- return n(h.idbtrans, h);
667
- }
668
- const u = We();
669
- try {
670
- return s && s.db === this.db ? s === K.trans ? s._promise(e, o, r) : ie(() => s._promise(e, o, r), { trans: s, transless: K.transless || K }) : Ft(this.db, e, [this.name], o);
671
- } finally {
672
- u && ze();
673
- }
674
- }
675
- get(e, n) {
676
- 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);
677
- }
678
- where(e) {
679
- if (typeof e == "string")
680
- return new this.db.WhereClause(this, e);
681
- if (N(e))
682
- return new this.db.WhereClause(this, `[${e.join("+")}]`);
683
- const n = B(e);
684
- if (n.length === 1)
685
- return this.where(n[0]).equals(e[n[0]]);
686
- const r = this.schema.indexes.concat(this.schema.primKey).filter((c) => c.compound && n.every((h) => c.keyPath.indexOf(h) >= 0) && c.keyPath.every((h) => n.indexOf(h) >= 0))[0];
687
- if (r && this.db._maxKey !== ce)
688
- return this.where(r.name).equals(r.keyPath.map((c) => e[c]));
689
- !r && G && console.warn(`The query ${JSON.stringify(e)} on ${this.name} would benefit of a compound index [${n.join("+")}]`);
690
- const { idxByName: s } = this.schema, i = this.db._deps.indexedDB;
691
- function o(c, h) {
692
- try {
693
- return i.cmp(c, h) === 0;
694
- } catch {
695
- return !1;
696
- }
697
- }
698
- const [u, a] = n.reduce(([c, h], l) => {
699
- const d = s[l], p = e[l];
700
- return [c || d, c || !d ? pe(h, d && d.multi ? (m) => {
701
- const f = ee(m, l);
702
- return N(f) && f.some((v) => o(p, v));
703
- } : (m) => o(p, ee(m, l))) : h];
704
- }, [null, null]);
705
- return u ? this.where(u.name).equals(e[u.keyPath]).filter(a) : r ? this.filter(a) : this.where(n).equals("");
706
- }
707
- filter(e) {
708
- return this.toCollection().and(e);
709
- }
710
- count(e) {
711
- return this.toCollection().count(e);
712
- }
713
- offset(e) {
714
- return this.toCollection().offset(e);
715
- }
716
- limit(e) {
717
- return this.toCollection().limit(e);
718
- }
719
- each(e) {
720
- return this.toCollection().each(e);
721
- }
722
- toArray(e) {
723
- return this.toCollection().toArray(e);
724
- }
725
- toCollection() {
726
- return new this.db.Collection(new this.db.WhereClause(this));
727
- }
728
- orderBy(e) {
729
- return new this.db.Collection(new this.db.WhereClause(this, N(e) ? `[${e.join("+")}]` : e));
730
- }
731
- reverse() {
732
- return this.toCollection().reverse();
733
- }
734
- mapToClass(e) {
735
- this.schema.mappedClass = e;
736
- const n = (r) => {
737
- if (!r)
738
- return r;
739
- const s = Object.create(e.prototype);
740
- for (var i in r)
741
- if (W(r, i))
742
- try {
743
- s[i] = r[i];
744
- } catch {
745
- }
746
- return s;
747
- };
748
- return this.schema.readHook && this.hook.reading.unsubscribe(this.schema.readHook), this.schema.readHook = n, this.hook("reading", n), e;
749
- }
750
- defineClass() {
751
- return this.mapToClass(function(e) {
752
- U(this, e);
753
- });
754
- }
755
- add(e, n) {
756
- const { auto: r, keyPath: s } = this.schema.primKey;
757
- let i = e;
758
- return s && r && (i = Xe(s)(e)), this._trans("readwrite", (o) => this.core.mutate({ trans: o, type: "add", keys: n != null ? [n] : null, values: [i] })).then((o) => o.numFailures ? E.reject(o.failures[0]) : o.lastResult).then((o) => {
759
- if (s)
760
- try {
761
- z(e, s, o);
762
- } catch {
763
- }
764
- return o;
765
- });
766
- }
767
- update(e, n) {
768
- if (typeof e != "object" || N(e))
769
- return this.where(":id").equals(e).modify(n);
770
- {
771
- const r = ee(e, this.schema.primKey.keyPath);
772
- if (r === void 0)
773
- return R(new O.InvalidArgument("Given object does not contain its primary key"));
774
- try {
775
- typeof n != "function" ? B(n).forEach((s) => {
776
- z(e, s, n[s]);
777
- }) : n(e, { value: e, primKey: r });
778
- } catch {
779
- }
780
- return this.where(":id").equals(r).modify(n);
781
- }
782
- }
783
- put(e, n) {
784
- const { auto: r, keyPath: s } = this.schema.primKey;
785
- let i = e;
786
- return s && r && (i = Xe(s)(e)), this._trans("readwrite", (o) => this.core.mutate({ trans: o, type: "put", values: [i], keys: n != null ? [n] : null })).then((o) => o.numFailures ? E.reject(o.failures[0]) : o.lastResult).then((o) => {
787
- if (s)
788
- try {
789
- z(e, s, o);
790
- } catch {
791
- }
792
- return o;
793
- });
794
- }
795
- delete(e) {
796
- return this._trans("readwrite", (n) => this.core.mutate({ trans: n, type: "delete", keys: [e] })).then((n) => n.numFailures ? E.reject(n.failures[0]) : void 0);
797
- }
798
- clear() {
799
- return this._trans("readwrite", (e) => this.core.mutate({ trans: e, type: "deleteRange", range: Ln })).then((e) => e.numFailures ? E.reject(e.failures[0]) : void 0);
800
- }
801
- bulkGet(e) {
802
- return this._trans("readonly", (n) => this.core.getMany({ keys: e, trans: n }).then((r) => r.map((s) => this.hook.reading.fire(s))));
803
- }
804
- bulkAdd(e, n, r) {
805
- const s = Array.isArray(n) ? n : void 0, i = (r = r || (s ? void 0 : n)) ? r.allKeys : void 0;
806
- return this._trans("readwrite", (o) => {
807
- const { auto: u, keyPath: a } = this.schema.primKey;
808
- if (a && s)
809
- throw new O.InvalidArgument("bulkAdd(): keys argument invalid on tables with inbound keys");
810
- if (s && s.length !== e.length)
811
- throw new O.InvalidArgument("Arguments objects and keys must have the same length");
812
- const c = e.length;
813
- let h = a && u ? e.map(Xe(a)) : e;
814
- return this.core.mutate({ trans: o, type: "add", keys: s, values: h, wantResults: i }).then(({ numFailures: l, results: d, lastResult: p, failures: m }) => {
815
- if (l === 0)
816
- return i ? d : p;
817
- throw new De(`${this.name}.bulkAdd(): ${l} of ${c} operations failed`, m);
818
- });
819
- });
820
- }
821
- bulkPut(e, n, r) {
822
- const s = Array.isArray(n) ? n : void 0, i = (r = r || (s ? void 0 : n)) ? r.allKeys : void 0;
823
- return this._trans("readwrite", (o) => {
824
- const { auto: u, keyPath: a } = this.schema.primKey;
825
- if (a && s)
826
- throw new O.InvalidArgument("bulkPut(): keys argument invalid on tables with inbound keys");
827
- if (s && s.length !== e.length)
828
- throw new O.InvalidArgument("Arguments objects and keys must have the same length");
829
- const c = e.length;
830
- let h = a && u ? e.map(Xe(a)) : e;
831
- return this.core.mutate({ trans: o, type: "put", keys: s, values: h, wantResults: i }).then(({ numFailures: l, results: d, lastResult: p, failures: m }) => {
832
- if (l === 0)
833
- return i ? d : p;
834
- throw new De(`${this.name}.bulkPut(): ${l} of ${c} operations failed`, m);
835
- });
836
- });
837
- }
838
- bulkDelete(e) {
839
- const n = e.length;
840
- return this._trans("readwrite", (r) => this.core.mutate({ trans: r, type: "delete", keys: e })).then(({ numFailures: r, lastResult: s, failures: i }) => {
841
- if (r === 0)
842
- return s;
843
- throw new De(`${this.name}.bulkDelete(): ${r} of ${n} operations failed`, i);
844
- });
845
- }
846
- }
847
- function Be(t) {
848
- var e = {}, n = function(o, u) {
849
- if (u) {
850
- for (var a = arguments.length, c = new Array(a - 1); --a; )
851
- c[a - 1] = arguments[a];
852
- return e[o].subscribe.apply(null, c), t;
853
- }
854
- if (typeof o == "string")
855
- return e[o];
856
- };
857
- n.addEventType = i;
858
- for (var r = 1, s = arguments.length; r < s; ++r)
859
- i(arguments[r]);
860
- return n;
861
- function i(o, u, a) {
862
- if (typeof o != "object") {
863
- var c;
864
- u || (u = pr), a || (a = C);
865
- var h = { subscribers: [], fire: a, subscribe: function(l) {
866
- h.subscribers.indexOf(l) === -1 && (h.subscribers.push(l), h.fire = u(h.fire, l));
867
- }, unsubscribe: function(l) {
868
- h.subscribers = h.subscribers.filter(function(d) {
869
- return d !== l;
870
- }), h.fire = h.subscribers.reduce(u, a);
871
- } };
872
- return e[o] = n[o] = h, h;
873
- }
874
- B(c = o).forEach(function(l) {
875
- var d = c[l];
876
- if (N(d))
877
- i(l, c[l][0], c[l][1]);
878
- else {
879
- if (d !== "asap")
880
- throw new O.InvalidArgument("Invalid event config");
881
- var p = i(l, Me, function() {
882
- for (var m = arguments.length, f = new Array(m); m--; )
883
- f[m] = arguments[m];
884
- p.subscribers.forEach(function(v) {
885
- kn(function() {
886
- v.apply(null, f);
887
- });
888
- });
889
- });
890
- }
891
- });
892
- }
893
- }
894
- function Ae(t, e) {
895
- return _e(e).from({ prototype: t }), e;
896
- }
897
- function ge(t, e) {
898
- return !(t.filter || t.algorithm || t.or) && (e ? t.justLimit : !t.replayFilter);
899
- }
900
- function wt(t, e) {
901
- t.filter = pe(t.filter, e);
902
- }
903
- function xt(t, e, n) {
904
- var r = t.replayFilter;
905
- t.replayFilter = r ? () => pe(r(), e()) : e, t.justLimit = n && !r;
906
- }
907
- function it(t, e) {
908
- if (t.isPrimKey)
909
- return e.primaryKey;
910
- const n = e.getIndexByKeyPath(t.index);
911
- if (!n)
912
- throw new O.Schema("KeyPath " + t.index + " on object store " + e.name + " is not indexed");
913
- return n;
914
- }
915
- function pn(t, e, n) {
916
- const r = it(t, e.schema);
917
- return e.openCursor({ trans: n, values: !t.keysOnly, reverse: t.dir === "prev", unique: !!t.unique, query: { index: r, range: t.range } });
918
- }
919
- function Qe(t, e, n, r) {
920
- const s = t.replayFilter ? pe(t.filter, t.replayFilter()) : t.filter;
921
- if (t.or) {
922
- const i = {}, o = (u, a, c) => {
923
- if (!s || s(a, c, (d) => a.stop(d), (d) => a.fail(d))) {
924
- var h = a.primaryKey, l = "" + h;
925
- l === "[object ArrayBuffer]" && (l = "" + new Uint8Array(h)), W(i, l) || (i[l] = !0, e(u, a, c));
926
- }
927
- };
928
- return Promise.all([t.or._iterate(o, n), yn(pn(t, r, n), t.algorithm, o, !t.keysOnly && t.valueMapper)]);
929
- }
930
- return yn(pn(t, r, n), pe(t.algorithm, s), e, !t.keysOnly && t.valueMapper);
931
- }
932
- function yn(t, e, n, r) {
933
- var s = D(r ? (i, o, u) => n(r(i), o, u) : n);
934
- return t.then((i) => {
935
- if (i)
936
- return i.start(() => {
937
- var o = () => i.continue();
938
- e && !e(i, (u) => o = u, (u) => {
939
- i.stop(u), o = C;
940
- }, (u) => {
941
- i.fail(u), o = C;
942
- }) || s(i.value, i, (u) => o = u), o();
943
- });
944
- });
945
- }
946
- function $(t, e) {
947
- try {
948
- const n = mn(t), r = mn(e);
949
- if (n !== r)
950
- 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;
951
- switch (n) {
952
- case "number":
953
- case "Date":
954
- case "string":
955
- return t > e ? 1 : t < e ? -1 : 0;
956
- case "binary":
957
- return function(s, i) {
958
- const o = s.length, u = i.length, a = o < u ? o : u;
959
- for (let c = 0; c < a; ++c)
960
- if (s[c] !== i[c])
961
- return s[c] < i[c] ? -1 : 1;
962
- return o === u ? 0 : o < u ? -1 : 1;
963
- }(gn(t), gn(e));
964
- case "Array":
965
- return function(s, i) {
966
- const o = s.length, u = i.length, a = o < u ? o : u;
967
- for (let c = 0; c < a; ++c) {
968
- const h = $(s[c], i[c]);
969
- if (h !== 0)
970
- return h;
971
- }
972
- return o === u ? 0 : o < u ? -1 : 1;
973
- }(t, e);
974
- }
975
- } catch {
976
- }
977
- return NaN;
978
- }
979
- function mn(t) {
980
- const e = typeof t;
981
- if (e !== "object")
982
- return e;
983
- if (ArrayBuffer.isView(t))
984
- return "binary";
985
- const n = Kt(t);
986
- return n === "ArrayBuffer" ? "binary" : n;
987
- }
988
- function gn(t) {
989
- return t instanceof Uint8Array ? t : ArrayBuffer.isView(t) ? new Uint8Array(t.buffer, t.byteOffset, t.byteLength) : new Uint8Array(t);
990
- }
991
- class Er {
992
- _read(e, n) {
993
- var r = this._ctx;
994
- return r.error ? r.table._trans(null, R.bind(null, r.error)) : r.table._trans("readonly", e).then(n);
995
- }
996
- _write(e) {
997
- var n = this._ctx;
998
- return n.error ? n.table._trans(null, R.bind(null, n.error)) : n.table._trans("readwrite", e, "locked");
999
- }
1000
- _addAlgorithm(e) {
1001
- var n = this._ctx;
1002
- n.algorithm = pe(n.algorithm, e);
1003
- }
1004
- _iterate(e, n) {
1005
- return Qe(this._ctx, e, n, this._ctx.table.core);
1006
- }
1007
- clone(e) {
1008
- var n = Object.create(this.constructor.prototype), r = Object.create(this._ctx);
1009
- return e && U(r, e), n._ctx = r, n;
1010
- }
1011
- raw() {
1012
- return this._ctx.valueMapper = null, this;
1013
- }
1014
- each(e) {
1015
- var n = this._ctx;
1016
- return this._read((r) => Qe(n, e, r, n.table.core));
1017
- }
1018
- count(e) {
1019
- return this._read((n) => {
1020
- const r = this._ctx, s = r.table.core;
1021
- if (ge(r, !0))
1022
- return s.count({ trans: n, query: { index: it(r, s.schema), range: r.range } }).then((o) => Math.min(o, r.limit));
1023
- var i = 0;
1024
- return Qe(r, () => (++i, !1), n, s).then(() => i);
1025
- }).then(e);
1026
- }
1027
- sortBy(e, n) {
1028
- const r = e.split(".").reverse(), s = r[0], i = r.length - 1;
1029
- function o(c, h) {
1030
- return h ? o(c[r[h]], h - 1) : c[s];
1031
- }
1032
- var u = this._ctx.dir === "next" ? 1 : -1;
1033
- function a(c, h) {
1034
- var l = o(c, i), d = o(h, i);
1035
- return l < d ? -u : l > d ? u : 0;
1036
- }
1037
- return this.toArray(function(c) {
1038
- return c.sort(a);
1039
- }).then(n);
1040
- }
1041
- toArray(e) {
1042
- return this._read((n) => {
1043
- var r = this._ctx;
1044
- if (r.dir === "next" && ge(r, !0) && r.limit > 0) {
1045
- const { valueMapper: s } = r, i = it(r, r.table.core.schema);
1046
- 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);
1047
- }
1048
- {
1049
- const s = [];
1050
- return Qe(r, (i) => s.push(i), n, r.table.core).then(() => s);
1051
- }
1052
- }, e);
1053
- }
1054
- offset(e) {
1055
- var n = this._ctx;
1056
- return e <= 0 || (n.offset += e, ge(n) ? xt(n, () => {
1057
- var r = e;
1058
- return (s, i) => r === 0 || (r === 1 ? (--r, !1) : (i(() => {
1059
- s.advance(r), r = 0;
1060
- }), !1));
1061
- }) : xt(n, () => {
1062
- var r = e;
1063
- return () => --r < 0;
1064
- })), this;
1065
- }
1066
- limit(e) {
1067
- return this._ctx.limit = Math.min(this._ctx.limit, e), xt(this._ctx, () => {
1068
- var n = e;
1069
- return function(r, s, i) {
1070
- return --n <= 0 && s(i), n >= 0;
1071
- };
1072
- }, !0), this;
1073
- }
1074
- until(e, n) {
1075
- return wt(this._ctx, function(r, s, i) {
1076
- return !e(r.value) || (s(i), n);
1077
- }), this;
1078
- }
1079
- first(e) {
1080
- return this.limit(1).toArray(function(n) {
1081
- return n[0];
1082
- }).then(e);
1083
- }
1084
- last(e) {
1085
- return this.reverse().first(e);
1086
- }
1087
- filter(e) {
1088
- var n, r;
1089
- return wt(this._ctx, function(s) {
1090
- return e(s.value);
1091
- }), n = this._ctx, r = e, n.isMatch = pe(n.isMatch, r), this;
1092
- }
1093
- and(e) {
1094
- return this.filter(e);
1095
- }
1096
- or(e) {
1097
- return new this.db.WhereClause(this._ctx.table, e, this);
1098
- }
1099
- reverse() {
1100
- return this._ctx.dir = this._ctx.dir === "prev" ? "next" : "prev", this._ondirectionchange && this._ondirectionchange(this._ctx.dir), this;
1101
- }
1102
- desc() {
1103
- return this.reverse();
1104
- }
1105
- eachKey(e) {
1106
- var n = this._ctx;
1107
- return n.keysOnly = !n.isMatch, this.each(function(r, s) {
1108
- e(s.key, s);
1109
- });
1110
- }
1111
- eachUniqueKey(e) {
1112
- return this._ctx.unique = "unique", this.eachKey(e);
1113
- }
1114
- eachPrimaryKey(e) {
1115
- var n = this._ctx;
1116
- return n.keysOnly = !n.isMatch, this.each(function(r, s) {
1117
- e(s.primaryKey, s);
1118
- });
1119
- }
1120
- keys(e) {
1121
- var n = this._ctx;
1122
- n.keysOnly = !n.isMatch;
1123
- var r = [];
1124
- return this.each(function(s, i) {
1125
- r.push(i.key);
1126
- }).then(function() {
1127
- return r;
1128
- }).then(e);
1129
- }
1130
- primaryKeys(e) {
1131
- var n = this._ctx;
1132
- if (n.dir === "next" && ge(n, !0) && n.limit > 0)
1133
- return this._read((s) => {
1134
- var i = it(n, n.table.core.schema);
1135
- return n.table.core.query({ trans: s, values: !1, limit: n.limit, query: { index: i, range: n.range } });
1136
- }).then(({ result: s }) => s).then(e);
1137
- n.keysOnly = !n.isMatch;
1138
- var r = [];
1139
- return this.each(function(s, i) {
1140
- r.push(i.primaryKey);
1141
- }).then(function() {
1142
- return r;
1143
- }).then(e);
1144
- }
1145
- uniqueKeys(e) {
1146
- return this._ctx.unique = "unique", this.keys(e);
1147
- }
1148
- firstKey(e) {
1149
- return this.limit(1).keys(function(n) {
1150
- return n[0];
1151
- }).then(e);
1152
- }
1153
- lastKey(e) {
1154
- return this.reverse().firstKey(e);
1155
- }
1156
- distinct() {
1157
- var e = this._ctx, n = e.index && e.table.schema.idxByName[e.index];
1158
- if (!n || !n.multi)
1159
- return this;
1160
- var r = {};
1161
- return wt(this._ctx, function(s) {
1162
- var i = s.primaryKey.toString(), o = W(r, i);
1163
- return r[i] = !0, !o;
1164
- }), this;
1165
- }
1166
- modify(e) {
1167
- var n = this._ctx;
1168
- return this._write((r) => {
1169
- var s;
1170
- if (typeof e == "function")
1171
- s = e;
1172
- else {
1173
- var i = B(e), o = i.length;
1174
- s = function(f) {
1175
- for (var v = !1, g = 0; g < o; ++g) {
1176
- var y = i[g], _ = e[y];
1177
- ee(f, y) !== _ && (z(f, y, _), v = !0);
1178
- }
1179
- return v;
1180
- };
1181
- }
1182
- const u = n.table.core, { outbound: a, extractKey: c } = u.schema.primaryKey, h = this.db._options.modifyChunkSize || 200, l = [];
1183
- let d = 0;
1184
- const p = [], m = (f, v) => {
1185
- const { failures: g, numFailures: y } = v;
1186
- d += f - y;
1187
- for (let _ of B(g))
1188
- l.push(g[_]);
1189
- };
1190
- return this.clone().primaryKeys().then((f) => {
1191
- const v = (g) => {
1192
- const y = Math.min(h, f.length - g);
1193
- return u.getMany({ trans: r, keys: f.slice(g, g + y), cache: "immutable" }).then((_) => {
1194
- const k = [], P = [], x = a ? [] : null, b = [];
1195
- for (let w = 0; w < y; ++w) {
1196
- const I = _[w], A = { value: Ve(I), primKey: f[g + w] };
1197
- s.call(A, A.value, A) !== !1 && (A.value == null ? b.push(f[g + w]) : a || $(c(I), c(A.value)) === 0 ? (P.push(A.value), a && x.push(f[g + w])) : (b.push(f[g + w]), k.push(A.value)));
1198
- }
1199
- const S = ge(n) && n.limit === 1 / 0 && (typeof e != "function" || e === kt) && { index: n.index, range: n.range };
1200
- return Promise.resolve(k.length > 0 && u.mutate({ trans: r, type: "add", values: k }).then((w) => {
1201
- for (let I in w.failures)
1202
- b.splice(parseInt(I), 1);
1203
- m(k.length, w);
1204
- })).then(() => (P.length > 0 || S && typeof e == "object") && u.mutate({ trans: r, type: "put", keys: x, values: P, criteria: S, changeSpec: typeof e != "function" && e }).then((w) => m(P.length, w))).then(() => (b.length > 0 || S && e === kt) && u.mutate({ trans: r, type: "delete", keys: b, criteria: S }).then((w) => m(b.length, w))).then(() => f.length > g + y && v(g + h));
1205
- });
1206
- };
1207
- return v(0).then(() => {
1208
- if (l.length > 0)
1209
- throw new ut("Error modifying one or more objects", l, d, p);
1210
- return f.length;
1211
- });
1212
- });
1213
- });
1214
- }
1215
- delete() {
1216
- var e = this._ctx, n = e.range;
1217
- return ge(e) && (e.isPrimKey && !xr || n.type === 3) ? this._write((r) => {
1218
- const { primaryKey: s } = e.table.core.schema, i = n;
1219
- 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: c, numFailures: h }) => {
1220
- if (h)
1221
- throw new ut("Could not delete some values", Object.keys(u).map((l) => u[l]), o - h);
1222
- return o - h;
1223
- }));
1224
- }) : this.modify(kt);
1225
- }
1226
- }
1227
- const kt = (t, e) => e.value = null;
1228
- function Pr(t, e) {
1229
- return t < e ? -1 : t === e ? 0 : 1;
1230
- }
1231
- function Kr(t, e) {
1232
- return t > e ? -1 : t === e ? 0 : 1;
1233
- }
1234
- function V(t, e, n) {
1235
- var r = t instanceof Wn ? new t.Collection(t) : t;
1236
- return r._ctx.error = n ? new n(e) : new TypeError(e), r;
1237
- }
1238
- function ve(t) {
1239
- return new t.Collection(t, () => Vn("")).limit(0);
1240
- }
1241
- function Or(t, e, n, r, s, i) {
1242
- for (var o = Math.min(t.length, r.length), u = -1, a = 0; a < o; ++a) {
1243
- var c = e[a];
1244
- if (c !== r[a])
1245
- 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;
1246
- s(t[a], c) < 0 && (u = a);
1247
- }
1248
- 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);
1249
- }
1250
- function Je(t, e, n, r) {
1251
- var s, i, o, u, a, c, h, l = n.length;
1252
- if (!n.every((f) => typeof f == "string"))
1253
- return V(t, $n);
1254
- function d(f) {
1255
- s = function(g) {
1256
- return g === "next" ? (y) => y.toUpperCase() : (y) => y.toLowerCase();
1257
- }(f), i = function(g) {
1258
- return g === "next" ? (y) => y.toLowerCase() : (y) => y.toUpperCase();
1259
- }(f), o = f === "next" ? Pr : Kr;
1260
- var v = n.map(function(g) {
1261
- return { lower: i(g), upper: s(g) };
1262
- }).sort(function(g, y) {
1263
- return o(g.lower, y.lower);
1264
- });
1265
- u = v.map(function(g) {
1266
- return g.upper;
1267
- }), a = v.map(function(g) {
1268
- return g.lower;
1269
- }), c = f, h = f === "next" ? "" : r;
1270
- }
1271
- d("next");
1272
- var p = new t.Collection(t, () => ne(u[0], a[l - 1] + r));
1273
- p._ondirectionchange = function(f) {
1274
- d(f);
1275
- };
1276
- var m = 0;
1277
- return p._addAlgorithm(function(f, v, g) {
1278
- var y = f.key;
1279
- if (typeof y != "string")
1280
- return !1;
1281
- var _ = i(y);
1282
- if (e(_, a, m))
1283
- return !0;
1284
- for (var k = null, P = m; P < l; ++P) {
1285
- var x = Or(y, _, u[P], a[P], o, c);
1286
- x === null && k === null ? m = P + 1 : (k === null || o(k, x) > 0) && (k = x);
1287
- }
1288
- return v(k !== null ? function() {
1289
- f.continue(k + h);
1290
- } : g), !1;
1291
- }), p;
1292
- }
1293
- function ne(t, e, n, r) {
1294
- return { type: 2, lower: t, upper: e, lowerOpen: n, upperOpen: r };
1295
- }
1296
- function Vn(t) {
1297
- return { type: 1, lower: t, upper: t };
1298
- }
1299
- class Wn {
1300
- get Collection() {
1301
- return this._ctx.table.db.Collection;
1302
- }
1303
- between(e, n, r, s) {
1304
- r = r !== !1, s = s === !0;
1305
- try {
1306
- return this._cmp(e, n) > 0 || this._cmp(e, n) === 0 && (r || s) && (!r || !s) ? ve(this) : new this.Collection(this, () => ne(e, n, !r, !s));
1307
- } catch {
1308
- return V(this, H);
1309
- }
1310
- }
1311
- equals(e) {
1312
- return e == null ? V(this, H) : new this.Collection(this, () => Vn(e));
1313
- }
1314
- above(e) {
1315
- return e == null ? V(this, H) : new this.Collection(this, () => ne(e, void 0, !0));
1316
- }
1317
- aboveOrEqual(e) {
1318
- return e == null ? V(this, H) : new this.Collection(this, () => ne(e, void 0, !1));
1319
- }
1320
- below(e) {
1321
- return e == null ? V(this, H) : new this.Collection(this, () => ne(void 0, e, !1, !0));
1322
- }
1323
- belowOrEqual(e) {
1324
- return e == null ? V(this, H) : new this.Collection(this, () => ne(void 0, e));
1325
- }
1326
- startsWith(e) {
1327
- return typeof e != "string" ? V(this, $n) : this.between(e, e + ce, !0, !0);
1328
- }
1329
- startsWithIgnoreCase(e) {
1330
- return e === "" ? this.startsWith(e) : Je(this, (n, r) => n.indexOf(r[0]) === 0, [e], ce);
1331
- }
1332
- equalsIgnoreCase(e) {
1333
- return Je(this, (n, r) => n === r[0], [e], "");
1334
- }
1335
- anyOfIgnoreCase() {
1336
- var e = Q.apply(be, arguments);
1337
- return e.length === 0 ? ve(this) : Je(this, (n, r) => r.indexOf(n) !== -1, e, "");
1338
- }
1339
- startsWithAnyOfIgnoreCase() {
1340
- var e = Q.apply(be, arguments);
1341
- return e.length === 0 ? ve(this) : Je(this, (n, r) => r.some((s) => n.indexOf(s) === 0), e, ce);
1342
- }
1343
- anyOf() {
1344
- const e = Q.apply(be, arguments);
1345
- let n = this._cmp;
1346
- try {
1347
- e.sort(n);
1348
- } catch {
1349
- return V(this, H);
1350
- }
1351
- if (e.length === 0)
1352
- return ve(this);
1353
- const r = new this.Collection(this, () => ne(e[0], e[e.length - 1]));
1354
- r._ondirectionchange = (i) => {
1355
- n = i === "next" ? this._ascending : this._descending, e.sort(n);
1356
- };
1357
- let s = 0;
1358
- return r._addAlgorithm((i, o, u) => {
1359
- const a = i.key;
1360
- for (; n(a, e[s]) > 0; )
1361
- if (++s, s === e.length)
1362
- return o(u), !1;
1363
- return n(a, e[s]) === 0 || (o(() => {
1364
- i.continue(e[s]);
1365
- }), !1);
1366
- }), r;
1367
- }
1368
- notEqual(e) {
1369
- return this.inAnyRange([[Mt, e], [e, this.db._maxKey]], { includeLowers: !1, includeUppers: !1 });
1370
- }
1371
- noneOf() {
1372
- const e = Q.apply(be, arguments);
1373
- if (e.length === 0)
1374
- return new this.Collection(this);
1375
- try {
1376
- e.sort(this._ascending);
1377
- } catch {
1378
- return V(this, H);
1379
- }
1380
- const n = e.reduce((r, s) => r ? r.concat([[r[r.length - 1][1], s]]) : [[Mt, s]], null);
1381
- return n.push([e[e.length - 1], this.db._maxKey]), this.inAnyRange(n, { includeLowers: !1, includeUppers: !1 });
1382
- }
1383
- inAnyRange(e, n) {
1384
- const r = this._cmp, s = this._ascending, i = this._descending, o = this._min, u = this._max;
1385
- if (e.length === 0)
1386
- return ve(this);
1387
- if (!e.every((y) => y[0] !== void 0 && y[1] !== void 0 && s(y[0], y[1]) <= 0))
1388
- return V(this, "First argument to inAnyRange() must be an Array of two-value Arrays [lower,upper] where upper must not be lower than lower", O.InvalidArgument);
1389
- const a = !n || n.includeLowers !== !1, c = n && n.includeUppers === !0;
1390
- let h, l = s;
1391
- function d(y, _) {
1392
- return l(y[0], _[0]);
1393
- }
1394
- try {
1395
- h = e.reduce(function(y, _) {
1396
- let k = 0, P = y.length;
1397
- for (; k < P; ++k) {
1398
- const x = y[k];
1399
- if (r(_[0], x[1]) < 0 && r(_[1], x[0]) > 0) {
1400
- x[0] = o(x[0], _[0]), x[1] = u(x[1], _[1]);
1401
- break;
1402
- }
1403
- }
1404
- return k === P && y.push(_), y;
1405
- }, []), h.sort(d);
1406
- } catch {
1407
- return V(this, H);
1408
- }
1409
- let p = 0;
1410
- const m = c ? (y) => s(y, h[p][1]) > 0 : (y) => s(y, h[p][1]) >= 0, f = a ? (y) => i(y, h[p][0]) > 0 : (y) => i(y, h[p][0]) >= 0;
1411
- let v = m;
1412
- const g = new this.Collection(this, () => ne(h[0][0], h[h.length - 1][1], !a, !c));
1413
- return g._ondirectionchange = (y) => {
1414
- y === "next" ? (v = m, l = s) : (v = f, l = i), h.sort(d);
1415
- }, g._addAlgorithm((y, _, k) => {
1416
- for (var P = y.key; v(P); )
1417
- if (++p, p === h.length)
1418
- return _(k), !1;
1419
- return !!function(x) {
1420
- return !m(x) && !f(x);
1421
- }(P) || (this._cmp(P, h[p][1]) === 0 || this._cmp(P, h[p][0]) === 0 || _(() => {
1422
- l === s ? y.continue(h[p][0]) : y.continue(h[p][1]);
1423
- }), !1);
1424
- }), g;
1425
- }
1426
- startsWithAnyOf() {
1427
- const e = Q.apply(be, arguments);
1428
- return e.every((n) => typeof n == "string") ? e.length === 0 ? ve(this) : this.inAnyRange(e.map((n) => [n, n + ce])) : V(this, "startsWithAnyOf() only works with strings");
1429
- }
1430
- }
1431
- function Y(t) {
1432
- return D(function(e) {
1433
- return qe(e), t(e.target.error), !1;
1434
- });
1435
- }
1436
- function qe(t) {
1437
- t.stopPropagation && t.stopPropagation(), t.preventDefault && t.preventDefault();
1438
- }
1439
- const $e = "storagemutated", se = "x-storagemutated-1", ae = Be(null, $e);
1440
- class Sr {
1441
- _lock() {
1442
- return Ce(!K.global), ++this._reculock, this._reculock !== 1 || K.global || (K.lockOwnerFor = this), this;
1443
- }
1444
- _unlock() {
1445
- if (Ce(!K.global), --this._reculock == 0)
1446
- for (K.global || (K.lockOwnerFor = null); this._blockedFuncs.length > 0 && !this._locked(); ) {
1447
- var e = this._blockedFuncs.shift();
1448
- try {
1449
- Oe(e[1], e[0]);
1450
- } catch {
1451
- }
1452
- }
1453
- return this;
1454
- }
1455
- _locked() {
1456
- return this._reculock && K.lockOwnerFor !== this;
1457
- }
1458
- create(e) {
1459
- if (!this.mode)
1460
- return this;
1461
- const n = this.db.idbdb, r = this.db._state.dbOpenError;
1462
- if (Ce(!this.idbtrans), !e && !n)
1463
- switch (r && r.name) {
1464
- case "DatabaseClosedError":
1465
- throw new O.DatabaseClosed(r);
1466
- case "MissingAPIError":
1467
- throw new O.MissingAPI(r.message, r);
1468
- default:
1469
- throw new O.OpenFailed(r);
1470
- }
1471
- if (!this.active)
1472
- throw new O.TransactionInactive();
1473
- return Ce(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 = D((s) => {
1474
- qe(s), this._reject(e.error);
1475
- }), e.onabort = D((s) => {
1476
- qe(s), this.active && this._reject(new O.Abort(e.error)), this.active = !1, this.on("abort").fire(s);
1477
- }), e.oncomplete = D(() => {
1478
- this.active = !1, this._resolve(), "mutatedParts" in e && ae.storagemutated.fire(e.mutatedParts);
1479
- }), this;
1480
- }
1481
- _promise(e, n, r) {
1482
- if (e === "readwrite" && this.mode !== "readwrite")
1483
- return R(new O.ReadOnly("Transaction is readonly"));
1484
- if (!this.active)
1485
- return R(new O.TransactionInactive());
1486
- if (this._locked())
1487
- return new E((i, o) => {
1488
- this._blockedFuncs.push([() => {
1489
- this._promise(e, n, r).then(i, o);
1490
- }, K]);
1491
- });
1492
- if (r)
1493
- return ie(() => {
1494
- var i = new E((o, u) => {
1495
- this._lock();
1496
- const a = n(o, u, this);
1497
- a && a.then && a.then(o, u);
1498
- });
1499
- return i.finally(() => this._unlock()), i._lib = !0, i;
1500
- });
1501
- var s = new E((i, o) => {
1502
- var u = n(i, o, this);
1503
- u && u.then && u.then(i, o);
1504
- });
1505
- return s._lib = !0, s;
1506
- }
1507
- _root() {
1508
- return this.parent ? this.parent._root() : this;
1509
- }
1510
- waitFor(e) {
1511
- var n = this._root();
1512
- const r = E.resolve(e);
1513
- if (n._waitingFor)
1514
- n._waitingFor = n._waitingFor.then(() => r);
1515
- else {
1516
- n._waitingFor = r, n._waitingQueue = [];
1517
- var s = n.idbtrans.objectStore(n.storeNames[0]);
1518
- (function o() {
1519
- for (++n._spinCount; n._waitingQueue.length; )
1520
- n._waitingQueue.shift()();
1521
- n._waitingFor && (s.get(-1 / 0).onsuccess = o);
1522
- })();
1523
- }
1524
- var i = n._waitingFor;
1525
- return new E((o, u) => {
1526
- r.then((a) => n._waitingQueue.push(D(o.bind(null, a))), (a) => n._waitingQueue.push(D(u.bind(null, a)))).finally(() => {
1527
- n._waitingFor === i && (n._waitingFor = null);
1528
- });
1529
- });
1530
- }
1531
- abort() {
1532
- this.active && (this.active = !1, this.idbtrans && this.idbtrans.abort(), this._reject(new O.Abort()));
1533
- }
1534
- table(e) {
1535
- const n = this._memoizedTables || (this._memoizedTables = {});
1536
- if (W(n, e))
1537
- return n[e];
1538
- const r = this.schema[e];
1539
- if (!r)
1540
- throw new O.NotFound("Table " + e + " not part of transaction");
1541
- const s = new this.db.Table(e, r, this);
1542
- return s.core = this.db.core.table(e), n[e] = s, s;
1543
- }
1544
- }
1545
- function Nt(t, e, n, r, s, i, o) {
1546
- return { name: t, keyPath: e, unique: n, multi: r, auto: s, compound: i, src: (n && !o ? "&" : "") + (r ? "*" : "") + (s ? "++" : "") + zn(e) };
1547
- }
1548
- function zn(t) {
1549
- return typeof t == "string" ? t : t ? "[" + [].join.call(t, "+") + "]" : "";
1550
- }
1551
- function Yn(t, e, n) {
1552
- return { name: t, primKey: e, indexes: n, mappedClass: null, idxByName: En(n, (r) => [r.name, r]) };
1553
- }
1554
- let Ue = (t) => {
1555
- try {
1556
- return t.only([[]]), Ue = () => [[]], [[]];
1557
- } catch {
1558
- return Ue = () => ce, ce;
1559
- }
1560
- };
1561
- function qt(t) {
1562
- return t == null ? () => {
1563
- } : typeof t == "string" ? function(e) {
1564
- return e.split(".").length === 1 ? (n) => n[e] : (n) => ee(n, e);
1565
- }(t) : (e) => ee(e, t);
1566
- }
1567
- function vn(t) {
1568
- return [].slice.call(t);
1569
- }
1570
- let Ar = 0;
1571
- function Re(t) {
1572
- return t == null ? ":id" : typeof t == "string" ? t : `[${t.join("+")}]`;
1573
- }
1574
- function Cr(t, e, n) {
1575
- function r(a) {
1576
- if (a.type === 3)
1577
- return null;
1578
- if (a.type === 4)
1579
- throw new Error("Cannot convert never type to IDBKeyRange");
1580
- const { lower: c, upper: h, lowerOpen: l, upperOpen: d } = a;
1581
- return c === void 0 ? h === void 0 ? null : e.upperBound(h, !!d) : h === void 0 ? e.lowerBound(c, !!l) : e.bound(c, h, !!l, !!d);
1582
- }
1583
- const { schema: s, hasGetAll: i } = function(a, c) {
1584
- const h = vn(a.objectStoreNames);
1585
- return { schema: { name: a.name, tables: h.map((l) => c.objectStore(l)).map((l) => {
1586
- const { keyPath: d, autoIncrement: p } = l, m = N(d), f = d == null, v = {}, g = { name: l.name, primaryKey: { name: null, isPrimaryKey: !0, outbound: f, compound: m, keyPath: d, autoIncrement: p, unique: !0, extractKey: qt(d) }, indexes: vn(l.indexNames).map((y) => l.index(y)).map((y) => {
1587
- const { name: _, unique: k, multiEntry: P, keyPath: x } = y, b = { name: _, compound: N(x), keyPath: x, unique: k, multiEntry: P, extractKey: qt(x) };
1588
- return v[Re(x)] = b, b;
1589
- }), getIndexByKeyPath: (y) => v[Re(y)] };
1590
- return v[":id"] = g.primaryKey, d != null && (v[Re(d)] = g.primaryKey), g;
1591
- }) }, hasGetAll: h.length > 0 && "getAll" in c.objectStore(h[0]) && !(typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604) };
1592
- }(t, n), o = s.tables.map((a) => function(c) {
1593
- const h = c.name;
1594
- return { name: h, schema: c, mutate: function({ trans: l, type: d, keys: p, values: m, range: f }) {
1595
- return new Promise((v, g) => {
1596
- v = D(v);
1597
- const y = l.objectStore(h), _ = y.keyPath == null, k = d === "put" || d === "add";
1598
- if (!k && d !== "delete" && d !== "deleteRange")
1599
- throw new Error("Invalid operation type: " + d);
1600
- const { length: P } = p || m || { length: 1 };
1601
- if (p && m && p.length !== m.length)
1602
- throw new Error("Given keys array must have same length as given values array.");
1603
- if (P === 0)
1604
- return v({ numFailures: 0, failures: {}, results: [], lastResult: void 0 });
1605
- let x;
1606
- const b = [], S = [];
1607
- let w = 0;
1608
- const I = (q) => {
1609
- ++w, qe(q);
1610
- };
1611
- if (d === "deleteRange") {
1612
- if (f.type === 4)
1613
- return v({ numFailures: w, failures: S, results: [], lastResult: void 0 });
1614
- f.type === 3 ? b.push(x = y.clear()) : b.push(x = y.delete(r(f)));
1615
- } else {
1616
- const [q, F] = k ? _ ? [m, p] : [m, null] : [p, null];
1617
- if (k)
1618
- for (let T = 0; T < P; ++T)
1619
- b.push(x = F && F[T] !== void 0 ? y[d](q[T], F[T]) : y[d](q[T])), x.onerror = I;
1620
- else
1621
- for (let T = 0; T < P; ++T)
1622
- b.push(x = y[d](q[T])), x.onerror = I;
1623
- }
1624
- const A = (q) => {
1625
- const F = q.target.result;
1626
- b.forEach((T, ye) => T.error != null && (S[ye] = T.error)), v({ numFailures: w, failures: S, results: d === "delete" ? p : b.map((T) => T.result), lastResult: F });
1627
- };
1628
- x.onerror = (q) => {
1629
- I(q), A(q);
1630
- }, x.onsuccess = A;
1631
- });
1632
- }, getMany: ({ trans: l, keys: d }) => new Promise((p, m) => {
1633
- p = D(p);
1634
- const f = l.objectStore(h), v = d.length, g = new Array(v);
1635
- let y, _ = 0, k = 0;
1636
- const P = (b) => {
1637
- const S = b.target;
1638
- g[S._pos] = S.result, ++k === _ && p(g);
1639
- }, x = Y(m);
1640
- for (let b = 0; b < v; ++b)
1641
- d[b] != null && (y = f.get(d[b]), y._pos = b, y.onsuccess = P, y.onerror = x, ++_);
1642
- _ === 0 && p(g);
1643
- }), get: ({ trans: l, key: d }) => new Promise((p, m) => {
1644
- p = D(p);
1645
- const f = l.objectStore(h).get(d);
1646
- f.onsuccess = (v) => p(v.target.result), f.onerror = Y(m);
1647
- }), query: function(l) {
1648
- return (d) => new Promise((p, m) => {
1649
- p = D(p);
1650
- const { trans: f, values: v, limit: g, query: y } = d, _ = g === 1 / 0 ? void 0 : g, { index: k, range: P } = y, x = f.objectStore(h), b = k.isPrimaryKey ? x : x.index(k.name), S = r(P);
1651
- if (g === 0)
1652
- return p({ result: [] });
1653
- if (l) {
1654
- const w = v ? b.getAll(S, _) : b.getAllKeys(S, _);
1655
- w.onsuccess = (I) => p({ result: I.target.result }), w.onerror = Y(m);
1656
- } else {
1657
- let w = 0;
1658
- const I = v || !("openKeyCursor" in b) ? b.openCursor(S) : b.openKeyCursor(S), A = [];
1659
- I.onsuccess = (q) => {
1660
- const F = I.result;
1661
- return F ? (A.push(v ? F.value : F.primaryKey), ++w === g ? p({ result: A }) : void F.continue()) : p({ result: A });
1662
- }, I.onerror = Y(m);
1663
- }
1664
- });
1665
- }(i), openCursor: function({ trans: l, values: d, query: p, reverse: m, unique: f }) {
1666
- return new Promise((v, g) => {
1667
- v = D(v);
1668
- const { index: y, range: _ } = p, k = l.objectStore(h), P = y.isPrimaryKey ? k : k.index(y.name), x = m ? f ? "prevunique" : "prev" : f ? "nextunique" : "next", b = d || !("openKeyCursor" in P) ? P.openCursor(r(_), x) : P.openKeyCursor(r(_), x);
1669
- b.onerror = Y(g), b.onsuccess = D((S) => {
1670
- const w = b.result;
1671
- if (!w)
1672
- return void v(null);
1673
- w.___id = ++Ar, w.done = !1;
1674
- const I = w.continue.bind(w);
1675
- let A = w.continuePrimaryKey;
1676
- A && (A = A.bind(w));
1677
- const q = w.advance.bind(w), F = () => {
1678
- throw new Error("Cursor not stopped");
1679
- };
1680
- w.trans = l, w.stop = w.continue = w.continuePrimaryKey = w.advance = () => {
1681
- throw new Error("Cursor not started");
1682
- }, w.fail = D(g), w.next = function() {
1683
- let T = 1;
1684
- return this.start(() => T-- ? this.continue() : this.stop()).then(() => this);
1685
- }, w.start = (T) => {
1686
- const ye = new Promise((L, ue) => {
1687
- L = D(L), b.onerror = Y(ue), w.fail = ue, w.stop = (Se) => {
1688
- w.stop = w.continue = w.continuePrimaryKey = w.advance = F, L(Se);
1689
- };
1690
- }), me = () => {
1691
- if (b.result)
1692
- try {
1693
- T();
1694
- } catch (L) {
1695
- w.fail(L);
1696
- }
1697
- else
1698
- w.done = !0, w.start = () => {
1699
- throw new Error("Cursor behind last entry");
1700
- }, w.stop();
1701
- };
1702
- return b.onsuccess = D((L) => {
1703
- b.onsuccess = me, me();
1704
- }), w.continue = I, w.continuePrimaryKey = A, w.advance = q, me(), ye;
1705
- }, v(w);
1706
- }, g);
1707
- });
1708
- }, count({ query: l, trans: d }) {
1709
- const { index: p, range: m } = l;
1710
- return new Promise((f, v) => {
1711
- const g = d.objectStore(h), y = p.isPrimaryKey ? g : g.index(p.name), _ = r(m), k = _ ? y.count(_) : y.count();
1712
- k.onsuccess = D((P) => f(P.target.result)), k.onerror = Y(v);
1713
- });
1714
- } };
1715
- }(a)), u = {};
1716
- return o.forEach((a) => u[a.name] = a), { stack: "dbcore", transaction: t.transaction.bind(t), table(a) {
1717
- if (!u[a])
1718
- throw new Error(`Table '${a}' not found`);
1719
- return u[a];
1720
- }, MIN_KEY: -1 / 0, MAX_KEY: Ue(e), schema: s };
1721
- }
1722
- function $t({ _novip: t }, e) {
1723
- const n = e.db, r = function(s, i, { IDBKeyRange: o, indexedDB: u }, a) {
1724
- return { dbcore: function(c, h) {
1725
- return h.reduce((l, { create: d }) => ({ ...l, ...d(l) }), c);
1726
- }(Cr(i, o, a), s.dbcore) };
1727
- }(t._middlewares, n, t._deps, e);
1728
- t.core = r.dbcore, t.tables.forEach((s) => {
1729
- const i = s.name;
1730
- 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));
1731
- });
1732
- }
1733
- function ft({ _novip: t }, e, n, r) {
1734
- n.forEach((s) => {
1735
- const i = r[s];
1736
- e.forEach((o) => {
1737
- const u = Xt(o, s);
1738
- (!u || "value" in u && u.value === void 0) && (o === t.Transaction.prototype || o instanceof t.Transaction ? Z(o, s, { get() {
1739
- return this.table(s);
1740
- }, set(a) {
1741
- wn(this, s, { value: a, writable: !0, configurable: !0, enumerable: !0 });
1742
- } }) : o[s] = new t.Table(s, i));
1743
- });
1744
- });
1745
- }
1746
- function Ut({ _novip: t }, e) {
1747
- e.forEach((n) => {
1748
- for (let r in n)
1749
- n[r] instanceof t.Table && delete n[r];
1750
- });
1751
- }
1752
- function jr(t, e) {
1753
- return t._cfg.version - e._cfg.version;
1754
- }
1755
- function Dr(t, e, n, r) {
1756
- const s = t._dbSchema, i = t._createTransaction("readwrite", t._storeNames, s);
1757
- i.create(n), i._completion.catch(r);
1758
- const o = i._reject.bind(i), u = K.transless || K;
1759
- ie(() => {
1760
- K.trans = i, K.transless = u, e === 0 ? (B(s).forEach((a) => {
1761
- Et(n, a, s[a].primKey, s[a].indexes);
1762
- }), $t(t, n), E.follow(() => t.on.populate.fire(i)).catch(o)) : function({ _novip: a }, c, h, l) {
1763
- const d = [], p = a._versions;
1764
- let m = a._dbSchema = Vt(a, a.idbdb, l), f = !1;
1765
- const v = p.filter((y) => y._cfg.version >= c);
1766
- function g() {
1767
- return d.length ? E.resolve(d.shift()(h.idbtrans)).then(g) : E.resolve();
1768
- }
1769
- return v.forEach((y) => {
1770
- d.push(() => {
1771
- const _ = m, k = y._cfg.dbschema;
1772
- Wt(a, _, l), Wt(a, k, l), m = a._dbSchema = k;
1773
- const P = Gn(_, k);
1774
- P.add.forEach((b) => {
1775
- Et(l, b[0], b[1].primKey, b[1].indexes);
1776
- }), P.change.forEach((b) => {
1777
- if (b.recreate)
1778
- throw new O.Upgrade("Not yet support for changing primary key");
1779
- {
1780
- const S = l.objectStore(b.name);
1781
- b.add.forEach((w) => Lt(S, w)), b.change.forEach((w) => {
1782
- S.deleteIndex(w.name), Lt(S, w);
1783
- }), b.del.forEach((w) => S.deleteIndex(w));
1784
- }
1785
- });
1786
- const x = y._cfg.contentUpgrade;
1787
- if (x && y._cfg.version > c) {
1788
- $t(a, l), h._memoizedTables = {}, f = !0;
1789
- let b = Pn(k);
1790
- P.del.forEach((A) => {
1791
- b[A] = _[A];
1792
- }), Ut(a, [a.Transaction.prototype]), ft(a, [a.Transaction.prototype], B(b), b), h.schema = b;
1793
- const S = Qt(x);
1794
- let w;
1795
- S && Ke();
1796
- const I = E.follow(() => {
1797
- if (w = x(h), w && S) {
1798
- var A = te.bind(null, null);
1799
- w.then(A, A);
1800
- }
1801
- });
1802
- return w && typeof w.then == "function" ? E.resolve(w) : I.then(() => w);
1803
- }
1804
- }), d.push((_) => {
1805
- (!f || !wr) && function(k, P) {
1806
- [].slice.call(P.db.objectStoreNames).forEach((x) => k[x] == null && P.db.deleteObjectStore(x));
1807
- }(y._cfg.dbschema, _), Ut(a, [a.Transaction.prototype]), ft(a, [a.Transaction.prototype], a._storeNames, a._dbSchema), h.schema = a._dbSchema;
1808
- });
1809
- }), g().then(() => {
1810
- var y, _;
1811
- _ = l, B(y = m).forEach((k) => {
1812
- _.db.objectStoreNames.contains(k) || Et(_, k, y[k].primKey, y[k].indexes);
1813
- });
1814
- });
1815
- }(t, e, i, n).catch(o);
1816
- });
1817
- }
1818
- function Gn(t, e) {
1819
- const n = { del: [], add: [], change: [] };
1820
- let r;
1821
- for (r in t)
1822
- e[r] || n.del.push(r);
1823
- for (r in e) {
1824
- const s = t[r], i = e[r];
1825
- if (s) {
1826
- const o = { name: r, def: i, recreate: !1, del: [], add: [], change: [] };
1827
- if ("" + (s.primKey.keyPath || "") != "" + (i.primKey.keyPath || "") || s.primKey.auto !== i.primKey.auto && !yt)
1828
- o.recreate = !0, n.change.push(o);
1829
- else {
1830
- const u = s.idxByName, a = i.idxByName;
1831
- let c;
1832
- for (c in u)
1833
- a[c] || o.del.push(c);
1834
- for (c in a) {
1835
- const h = u[c], l = a[c];
1836
- h ? h.src !== l.src && o.change.push(l) : o.add.push(l);
1837
- }
1838
- (o.del.length > 0 || o.add.length > 0 || o.change.length > 0) && n.change.push(o);
1839
- }
1840
- } else
1841
- n.add.push([r, i]);
1842
- }
1843
- return n;
1844
- }
1845
- function Et(t, e, n, r) {
1846
- const s = t.db.createObjectStore(e, n.keyPath ? { keyPath: n.keyPath, autoIncrement: n.auto } : { autoIncrement: n.auto });
1847
- return r.forEach((i) => Lt(s, i)), s;
1848
- }
1849
- function Lt(t, e) {
1850
- t.createIndex(e.name, e.keyPath, { unique: e.unique, multiEntry: e.multi });
1851
- }
1852
- function Vt(t, e, n) {
1853
- const r = {};
1854
- return at(e.objectStoreNames, 0).forEach((s) => {
1855
- const i = n.objectStore(s);
1856
- let o = i.keyPath;
1857
- const u = Nt(zn(o), o || "", !1, !1, !!i.autoIncrement, o && typeof o != "string", !0), a = [];
1858
- for (let h = 0; h < i.indexNames.length; ++h) {
1859
- const l = i.index(i.indexNames[h]);
1860
- o = l.keyPath;
1861
- var c = Nt(l.name, o, !!l.unique, !!l.multiEntry, !1, o && typeof o != "string", !1);
1862
- a.push(c);
1863
- }
1864
- r[s] = Yn(s, u, a);
1865
- }), r;
1866
- }
1867
- function Wt({ _novip: t }, e, n) {
1868
- const r = n.db.objectStoreNames;
1869
- for (let s = 0; s < r.length; ++s) {
1870
- const i = r[s], o = n.objectStore(i);
1871
- t._hasGetAll = "getAll" in o;
1872
- for (let u = 0; u < o.indexNames.length; ++u) {
1873
- const a = o.indexNames[u], c = o.index(a).keyPath, h = typeof c == "string" ? c : "[" + at(c).join("+") + "]";
1874
- if (e[i]) {
1875
- const l = e[i].idxByName[h];
1876
- l && (l.name = a, delete e[i].idxByName[h], e[i].idxByName[a] = l);
1877
- }
1878
- }
1879
- }
1880
- typeof navigator < "u" && /Safari/.test(navigator.userAgent) && !/(Chrome\/|Edge\/)/.test(navigator.userAgent) && j.WorkerGlobalScope && j instanceof j.WorkerGlobalScope && [].concat(navigator.userAgent.match(/Safari\/(\d*)/))[1] < 604 && (t._hasGetAll = !1);
1881
- }
1882
- class Ir {
1883
- _parseStoresSpec(e, n) {
1884
- B(e).forEach((r) => {
1885
- if (e[r] !== null) {
1886
- var s = e[r].split(",").map((o, u) => {
1887
- const a = (o = o.trim()).replace(/([&*]|\+\+)/g, ""), c = /^\[/.test(a) ? a.match(/^\[(.*)\]$/)[1].split("+") : a;
1888
- return Nt(a, c || null, /\&/.test(o), /\*/.test(o), /\+\+/.test(o), N(c), u === 0);
1889
- }), i = s.shift();
1890
- if (i.multi)
1891
- throw new O.Schema("Primary key cannot be multi-valued");
1892
- s.forEach((o) => {
1893
- if (o.auto)
1894
- throw new O.Schema("Only primary key can be marked as autoIncrement (++)");
1895
- if (!o.keyPath)
1896
- throw new O.Schema("Index must have a name and cannot be an empty string");
1897
- }), n[r] = Yn(r, i, s);
1898
- }
1899
- });
1900
- }
1901
- stores(e) {
1902
- const n = this.db;
1903
- this._cfg.storesSource = this._cfg.storesSource ? U(this._cfg.storesSource, e) : e;
1904
- const r = n._versions, s = {};
1905
- let i = {};
1906
- return r.forEach((o) => {
1907
- U(s, o._cfg.storesSource), i = o._cfg.dbschema = {}, o._parseStoresSpec(s, i);
1908
- }), n._dbSchema = i, Ut(n, [n._allTables, n, n.Transaction.prototype]), ft(n, [n._allTables, n, n.Transaction.prototype, this._cfg.tables], B(i), i), n._storeNames = B(i), this;
1909
- }
1910
- upgrade(e) {
1911
- return this._cfg.contentUpgrade = en(this._cfg.contentUpgrade || C, e), this;
1912
- }
1913
- }
1914
- function sn(t, e) {
1915
- let n = t._dbNamesDB;
1916
- return n || (n = t._dbNamesDB = new ke(mt, { addons: [], indexedDB: t, IDBKeyRange: e }), n.version(1).stores({ dbnames: "name" })), n.table("dbnames");
1917
- }
1918
- function on(t) {
1919
- return t && typeof t.databases == "function";
1920
- }
1921
- function zt(t) {
1922
- return ie(function() {
1923
- return K.letThrough = !0, t();
1924
- });
1925
- }
1926
- function Tr() {
1927
- var t;
1928
- return !navigator.userAgentData && /Safari\//.test(navigator.userAgent) && !/Chrom(e|ium)\//.test(navigator.userAgent) && indexedDB.databases ? new Promise(function(e) {
1929
- var n = function() {
1930
- return indexedDB.databases().finally(e);
1931
- };
1932
- t = setInterval(n, 100), n();
1933
- }).finally(function() {
1934
- return clearInterval(t);
1935
- }) : Promise.resolve();
1936
- }
1937
- function Br(t) {
1938
- const e = t._state, { indexedDB: n } = t._deps;
1939
- if (e.isBeingOpened || t.idbdb)
1940
- return e.dbReadyPromise.then(() => e.dbOpenError ? R(e.dbOpenError) : t);
1941
- G && (e.openCanceller._stackHolder = Pe()), e.isBeingOpened = !0, e.dbOpenError = null, e.openComplete = !1;
1942
- const r = e.openCanceller;
1943
- function s() {
1944
- if (e.openCanceller !== r)
1945
- throw new O.DatabaseClosed("db.open() was cancelled");
1946
- }
1947
- let i = e.dbReadyResolve, o = null, u = !1;
1948
- return E.race([r, (typeof navigator > "u" ? E.resolve() : Tr()).then(() => new E((a, c) => {
1949
- if (s(), !n)
1950
- throw new O.MissingAPI();
1951
- const h = t.name, l = e.autoSchema ? n.open(h) : n.open(h, Math.round(10 * t.verno));
1952
- if (!l)
1953
- throw new O.MissingAPI();
1954
- l.onerror = Y(c), l.onblocked = D(t._fireOnBlocked), l.onupgradeneeded = D((d) => {
1955
- if (o = l.transaction, e.autoSchema && !t._options.allowEmptyDB) {
1956
- l.onerror = qe, o.abort(), l.result.close();
1957
- const m = n.deleteDatabase(h);
1958
- m.onsuccess = m.onerror = D(() => {
1959
- c(new O.NoSuchDatabase(`Database ${h} doesnt exist`));
1960
- });
1961
- } else {
1962
- o.onerror = Y(c);
1963
- var p = d.oldVersion > Math.pow(2, 62) ? 0 : d.oldVersion;
1964
- u = p < 1, t._novip.idbdb = l.result, Dr(t, p / 10, o, c);
1965
- }
1966
- }, c), l.onsuccess = D(() => {
1967
- o = null;
1968
- const d = t._novip.idbdb = l.result, p = at(d.objectStoreNames);
1969
- if (p.length > 0)
1970
- try {
1971
- const f = d.transaction((m = p).length === 1 ? m[0] : m, "readonly");
1972
- e.autoSchema ? function({ _novip: v }, g, y) {
1973
- v.verno = g.version / 10;
1974
- const _ = v._dbSchema = Vt(0, g, y);
1975
- v._storeNames = at(g.objectStoreNames, 0), ft(v, [v._allTables], B(_), _);
1976
- }(t, d, f) : (Wt(t, t._dbSchema, f), function(v, g) {
1977
- const y = Gn(Vt(0, v.idbdb, g), v._dbSchema);
1978
- return !(y.add.length || y.change.some((_) => _.add.length || _.change.length));
1979
- }(t, f) || console.warn("Dexie SchemaDiff: Schema was extended without increasing the number passed to db.version(). Some queries may fail.")), $t(t, f);
1980
- } catch {
1981
- }
1982
- var m;
1983
- Te.push(t), d.onversionchange = D((f) => {
1984
- e.vcFired = !0, t.on("versionchange").fire(f);
1985
- }), d.onclose = D((f) => {
1986
- t.on("close").fire(f);
1987
- }), u && function({ indexedDB: f, IDBKeyRange: v }, g) {
1988
- !on(f) && g !== mt && sn(f, v).put({ name: g }).catch(C);
1989
- }(t._deps, h), a();
1990
- }, c);
1991
- }))]).then(() => (s(), e.onReadyBeingFired = [], E.resolve(zt(() => t.on.ready.fire(t.vip))).then(function a() {
1992
- if (e.onReadyBeingFired.length > 0) {
1993
- let c = e.onReadyBeingFired.reduce(en, C);
1994
- return e.onReadyBeingFired = [], E.resolve(zt(() => c(t.vip))).then(a);
1995
- }
1996
- }))).finally(() => {
1997
- e.onReadyBeingFired = null, e.isBeingOpened = !1;
1998
- }).then(() => t).catch((a) => {
1999
- e.dbOpenError = a;
2000
- try {
2001
- o && o.abort();
2002
- } catch {
2003
- }
2004
- return r === e.openCanceller && t._close(), R(a);
2005
- }).finally(() => {
2006
- e.openComplete = !0, i();
2007
- });
2008
- }
2009
- function Yt(t) {
2010
- var e = (i) => t.next(i), n = s(e), r = s((i) => t.throw(i));
2011
- function s(i) {
2012
- return (o) => {
2013
- var u = i(o), a = u.value;
2014
- return u.done ? a : a && typeof a.then == "function" ? a.then(n, r) : N(a) ? Promise.all(a).then(n, r) : n(a);
2015
- };
2016
- }
2017
- return s(e)();
2018
- }
2019
- function Rr(t, e, n) {
2020
- var r = arguments.length;
2021
- if (r < 2)
2022
- throw new O.InvalidArgument("Too few arguments");
2023
- for (var s = new Array(r - 1); --r; )
2024
- s[r - 1] = arguments[r];
2025
- return n = s.pop(), [t, Kn(s), n];
2026
- }
2027
- function Hn(t, e, n, r, s) {
2028
- return E.resolve().then(() => {
2029
- const i = K.transless || K, o = t._createTransaction(e, n, t._dbSchema, r), u = { trans: o, transless: i };
2030
- if (r)
2031
- o.idbtrans = r.idbtrans;
2032
- else
2033
- try {
2034
- o.create(), t._state.PR1398_maxLoop = 3;
2035
- } catch (l) {
2036
- return l.name === Zt.InvalidState && t.isOpen() && --t._state.PR1398_maxLoop > 0 ? (console.warn("Dexie: Need to reopen db"), t._close(), t.open().then(() => Hn(t, e, n, null, s))) : R(l);
2037
- }
2038
- const a = Qt(s);
2039
- let c;
2040
- a && Ke();
2041
- const h = E.follow(() => {
2042
- if (c = s.call(o, o), c)
2043
- if (a) {
2044
- var l = te.bind(null, null);
2045
- c.then(l, l);
2046
- } else
2047
- typeof c.next == "function" && typeof c.throw == "function" && (c = Yt(c));
2048
- }, u);
2049
- return (c && typeof c.then == "function" ? E.resolve(c).then((l) => o.active ? l : R(new O.PrematureCommit("Transaction committed too early. See http://bit.ly/2kdckMn"))) : h.then(() => c)).then((l) => (r && o._resolve(), o._completion.then(() => l))).catch((l) => (o._reject(l), R(l)));
2050
- });
2051
- }
2052
- function Ze(t, e, n) {
2053
- const r = N(t) ? t.slice() : [t];
2054
- for (let s = 0; s < n; ++s)
2055
- r.push(e);
2056
- return r;
2057
- }
2058
- const Fr = { stack: "dbcore", name: "VirtualIndexMiddleware", level: 1, create: function(t) {
2059
- return { ...t, table(e) {
2060
- const n = t.table(e), { schema: r } = n, s = {}, i = [];
2061
- function o(c, h, l) {
2062
- const d = Re(c), p = s[d] = s[d] || [], m = c == null ? 0 : typeof c == "string" ? 1 : c.length, f = h > 0, v = { ...l, isVirtual: f, keyTail: h, keyLength: m, extractKey: qt(c), unique: !f && l.unique };
2063
- return p.push(v), v.isPrimaryKey || i.push(v), m > 1 && o(m === 2 ? c[0] : c.slice(0, m - 1), h + 1, l), p.sort((g, y) => g.keyTail - y.keyTail), v;
2064
- }
2065
- const u = o(r.primaryKey.keyPath, 0, r.primaryKey);
2066
- s[":id"] = [u];
2067
- for (const c of r.indexes)
2068
- o(c.keyPath, 0, c);
2069
- function a(c) {
2070
- const h = c.query.index;
2071
- return h.isVirtual ? { ...c, query: { index: h, range: (l = c.query.range, d = h.keyTail, { type: l.type === 1 ? 2 : l.type, lower: Ze(l.lower, l.lowerOpen ? t.MAX_KEY : t.MIN_KEY, d), lowerOpen: !0, upper: Ze(l.upper, l.upperOpen ? t.MIN_KEY : t.MAX_KEY, d), upperOpen: !0 }) } } : c;
2072
- var l, d;
2073
- }
2074
- return { ...n, schema: { ...r, primaryKey: u, indexes: i, getIndexByKeyPath: function(c) {
2075
- const h = s[Re(c)];
2076
- return h && h[0];
2077
- } }, count: (c) => n.count(a(c)), query: (c) => n.query(a(c)), openCursor(c) {
2078
- const { keyTail: h, isVirtual: l, keyLength: d } = c.query.index;
2079
- return l ? n.openCursor(a(c)).then((p) => p && function(m) {
2080
- return Object.create(m, { continue: { value: function(f) {
2081
- f != null ? m.continue(Ze(f, c.reverse ? t.MAX_KEY : t.MIN_KEY, h)) : c.unique ? m.continue(m.key.slice(0, d).concat(c.reverse ? t.MIN_KEY : t.MAX_KEY, h)) : m.continue();
2082
- } }, continuePrimaryKey: { value(f, v) {
2083
- m.continuePrimaryKey(Ze(f, t.MAX_KEY, h), v);
2084
- } }, primaryKey: { get: () => m.primaryKey }, key: { get() {
2085
- const f = m.key;
2086
- return d === 1 ? f[0] : f.slice(0, d);
2087
- } }, value: { get: () => m.value } });
2088
- }(p)) : n.openCursor(c);
2089
- } };
2090
- } };
2091
- } };
2092
- function an(t, e, n, r) {
2093
- return n = n || {}, r = r || "", B(t).forEach((s) => {
2094
- if (W(e, s)) {
2095
- var i = t[s], o = e[s];
2096
- if (typeof i == "object" && typeof o == "object" && i && o) {
2097
- const u = Kt(i);
2098
- u !== Kt(o) ? n[r + s] = e[s] : u === "Object" ? an(i, o, n, r + s + ".") : i !== o && (n[r + s] = e[s]);
2099
- } else
2100
- i !== o && (n[r + s] = e[s]);
2101
- } else
2102
- n[r + s] = void 0;
2103
- }), B(e).forEach((s) => {
2104
- W(t, s) || (n[r + s] = e[s]);
2105
- }), n;
2106
- }
2107
- const Mr = { stack: "dbcore", name: "HooksMiddleware", level: 2, create: (t) => ({ ...t, table(e) {
2108
- const n = t.table(e), { primaryKey: r } = n.schema;
2109
- return { ...n, mutate(s) {
2110
- const i = K.trans, { deleting: o, creating: u, updating: a } = i.table(e).hook;
2111
- switch (s.type) {
2112
- case "add":
2113
- if (u.fire === C)
2114
- break;
2115
- return i._promise("readwrite", () => c(s), !0);
2116
- case "put":
2117
- if (u.fire === C && a.fire === C)
2118
- break;
2119
- return i._promise("readwrite", () => c(s), !0);
2120
- case "delete":
2121
- if (o.fire === C)
2122
- break;
2123
- return i._promise("readwrite", () => c(s), !0);
2124
- case "deleteRange":
2125
- if (o.fire === C)
2126
- break;
2127
- return i._promise("readwrite", () => function(l) {
2128
- return h(l.trans, l.range, 1e4);
2129
- }(s), !0);
2130
- }
2131
- return n.mutate(s);
2132
- function c(l) {
2133
- const d = K.trans, p = l.keys || function(m, f) {
2134
- return f.type === "delete" ? f.keys : f.keys || f.values.map(m.extractKey);
2135
- }(r, l);
2136
- if (!p)
2137
- throw new Error("Keys missing");
2138
- return (l = l.type === "add" || l.type === "put" ? { ...l, keys: p } : { ...l }).type !== "delete" && (l.values = [...l.values]), l.keys && (l.keys = [...l.keys]), function(m, f, v) {
2139
- return f.type === "add" ? Promise.resolve([]) : m.getMany({ trans: f.trans, keys: v, cache: "immutable" });
2140
- }(n, l, p).then((m) => {
2141
- const f = p.map((v, g) => {
2142
- const y = m[g], _ = { onerror: null, onsuccess: null };
2143
- if (l.type === "delete")
2144
- o.fire.call(_, v, y, d);
2145
- else if (l.type === "add" || y === void 0) {
2146
- const k = u.fire.call(_, v, l.values[g], d);
2147
- v == null && k != null && (v = k, l.keys[g] = v, r.outbound || z(l.values[g], r.keyPath, v));
2148
- } else {
2149
- const k = an(y, l.values[g]), P = a.fire.call(_, k, v, y, d);
2150
- if (P) {
2151
- const x = l.values[g];
2152
- Object.keys(P).forEach((b) => {
2153
- W(x, b) ? x[b] = P[b] : z(x, b, P[b]);
2154
- });
2155
- }
2156
- }
2157
- return _;
2158
- });
2159
- return n.mutate(l).then(({ failures: v, results: g, numFailures: y, lastResult: _ }) => {
2160
- for (let k = 0; k < p.length; ++k) {
2161
- const P = g ? g[k] : p[k], x = f[k];
2162
- P == null ? x.onerror && x.onerror(v[k]) : x.onsuccess && x.onsuccess(l.type === "put" && m[k] ? l.values[k] : P);
2163
- }
2164
- return { failures: v, results: g, numFailures: y, lastResult: _ };
2165
- }).catch((v) => (f.forEach((g) => g.onerror && g.onerror(v)), Promise.reject(v)));
2166
- });
2167
- }
2168
- function h(l, d, p) {
2169
- return n.query({ trans: l, values: !1, query: { index: r, range: d }, limit: p }).then(({ result: m }) => c({ type: "delete", keys: m, trans: l }).then((f) => f.numFailures > 0 ? Promise.reject(f.failures[0]) : m.length < p ? { failures: [], numFailures: 0, lastResult: void 0 } : h(l, { ...d, lower: m[m.length - 1], lowerOpen: !0 }, p)));
2170
- }
2171
- } };
2172
- } }) };
2173
- function Xn(t, e, n) {
2174
- try {
2175
- if (!e || e.keys.length < t.length)
2176
- return null;
2177
- const r = [];
2178
- for (let s = 0, i = 0; s < e.keys.length && i < t.length; ++s)
2179
- $(e.keys[s], t[i]) === 0 && (r.push(n ? Ve(e.values[s]) : e.values[s]), ++i);
2180
- return r.length === t.length ? r : null;
2181
- } catch {
2182
- return null;
2183
- }
2184
- }
2185
- const Nr = { stack: "dbcore", level: -1, create: (t) => ({ table: (e) => {
2186
- const n = t.table(e);
2187
- return { ...n, getMany: (r) => {
2188
- if (!r.cache)
2189
- return n.getMany(r);
2190
- const s = Xn(r.keys, r.trans._cache, r.cache === "clone");
2191
- return s ? E.resolve(s) : n.getMany(r).then((i) => (r.trans._cache = { keys: r.keys, values: r.cache === "clone" ? Ve(i) : i }, i));
2192
- }, mutate: (r) => (r.type !== "add" && (r.trans._cache = null), n.mutate(r)) };
2193
- } }) };
2194
- function un(t) {
2195
- return !("from" in t);
2196
- }
2197
- const X = function(t, e) {
2198
- if (!this) {
2199
- const n = new X();
2200
- return t && "d" in t && U(n, t), n;
2201
- }
2202
- U(this, arguments.length ? { d: 1, from: t, to: arguments.length > 1 ? e : t } : { d: 0 });
2203
- };
2204
- function Le(t, e, n) {
2205
- const r = $(e, n);
2206
- if (isNaN(r))
2207
- return;
2208
- if (r > 0)
2209
- throw RangeError();
2210
- if (un(t))
2211
- return U(t, { from: e, to: n, d: 1 });
2212
- const s = t.l, i = t.r;
2213
- if ($(n, t.from) < 0)
2214
- return s ? Le(s, e, n) : t.l = { from: e, to: n, d: 1, l: null, r: null }, bn(t);
2215
- if ($(e, t.to) > 0)
2216
- return i ? Le(i, e, n) : t.r = { from: e, to: n, d: 1, l: null, r: null }, bn(t);
2217
- $(e, t.from) < 0 && (t.from = e, t.l = null, t.d = i ? i.d + 1 : 1), $(n, t.to) > 0 && (t.to = n, t.r = null, t.d = t.l ? t.l.d + 1 : 1);
2218
- const o = !t.r;
2219
- s && !t.l && pt(t, s), i && o && pt(t, i);
2220
- }
2221
- function pt(t, e) {
2222
- un(e) || function n(r, { from: s, to: i, l: o, r: u }) {
2223
- Le(r, s, i), o && n(r, o), u && n(r, u);
2224
- }(t, e);
2225
- }
2226
- function qr(t, e) {
2227
- const n = Gt(e);
2228
- let r = n.next();
2229
- if (r.done)
2230
- return !1;
2231
- let s = r.value;
2232
- const i = Gt(t);
2233
- let o = i.next(s.from), u = o.value;
2234
- for (; !r.done && !o.done; ) {
2235
- if ($(u.from, s.to) <= 0 && $(u.to, s.from) >= 0)
2236
- return !0;
2237
- $(s.from, u.from) < 0 ? s = (r = n.next(u.from)).value : u = (o = i.next(s.from)).value;
2238
- }
2239
- return !1;
2240
- }
2241
- function Gt(t) {
2242
- let e = un(t) ? null : { s: 0, n: t };
2243
- return { next(n) {
2244
- const r = arguments.length > 0;
2245
- for (; e; )
2246
- switch (e.s) {
2247
- case 0:
2248
- if (e.s = 1, r)
2249
- for (; e.n.l && $(n, e.n.from) < 0; )
2250
- e = { up: e, n: e.n.l, s: 1 };
2251
- else
2252
- for (; e.n.l; )
2253
- e = { up: e, n: e.n.l, s: 1 };
2254
- case 1:
2255
- if (e.s = 2, !r || $(n, e.n.to) <= 0)
2256
- return { value: e.n, done: !1 };
2257
- case 2:
2258
- if (e.n.r) {
2259
- e.s = 3, e = { up: e, n: e.n.r, s: 0 };
2260
- continue;
2261
- }
2262
- case 3:
2263
- e = e.up;
2264
- }
2265
- return { done: !0 };
2266
- } };
2267
- }
2268
- function bn(t) {
2269
- var e, n;
2270
- 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" : "";
2271
- if (s) {
2272
- const i = s === "r" ? "l" : "r", o = { ...t }, u = t[s];
2273
- t.from = u.from, t.to = u.to, t[s] = u[s], o[s] = u[i], t[i] = o, o.d = _n(o);
2274
- }
2275
- t.d = _n(t);
2276
- }
2277
- function _n({ r: t, l: e }) {
2278
- return (t ? e ? Math.max(t.d, e.d) : t.d : e ? e.d : 0) + 1;
2279
- }
2280
- Ee(X.prototype, { add(t) {
2281
- return pt(this, t), this;
2282
- }, addKey(t) {
2283
- return Le(this, t, t), this;
2284
- }, addKeys(t) {
2285
- return t.forEach((e) => Le(this, e, e)), this;
2286
- }, [Ot]() {
2287
- return Gt(this);
2288
- } });
2289
- const $r = { stack: "dbcore", level: 0, create: (t) => {
2290
- const e = t.schema.name, n = new X(t.MIN_KEY, t.MAX_KEY);
2291
- return { ...t, table: (r) => {
2292
- const s = t.table(r), { schema: i } = s, { primaryKey: o } = i, { extractKey: u, outbound: a } = o, c = { ...s, mutate: (d) => {
2293
- const p = d.trans, m = p.mutatedParts || (p.mutatedParts = {}), f = (x) => {
2294
- const b = `idb://${e}/${r}/${x}`;
2295
- return m[b] || (m[b] = new X());
2296
- }, v = f(""), g = f(":dels"), { type: y } = d;
2297
- let [_, k] = d.type === "deleteRange" ? [d.range] : d.type === "delete" ? [d.keys] : d.values.length < 50 ? [[], d.values] : [];
2298
- const P = d.trans._cache;
2299
- return s.mutate(d).then((x) => {
2300
- if (N(_)) {
2301
- y !== "delete" && (_ = x.results), v.addKeys(_);
2302
- const b = Xn(_, P);
2303
- b || y === "add" || g.addKeys(_), (b || k) && function(S, w, I, A) {
2304
- function q(F) {
2305
- const T = S(F.name || "");
2306
- function ye(L) {
2307
- return L != null ? F.extractKey(L) : null;
2308
- }
2309
- const me = (L) => F.multiEntry && N(L) ? L.forEach((ue) => T.addKey(ue)) : T.addKey(L);
2310
- (I || A).forEach((L, ue) => {
2311
- const Se = I && ye(I[ue]), gt = A && ye(A[ue]);
2312
- $(Se, gt) !== 0 && (Se != null && me(Se), gt != null && me(gt));
2313
- });
2314
- }
2315
- w.indexes.forEach(q);
2316
- }(f, i, b, k);
2317
- } else if (_) {
2318
- const b = { from: _.lower, to: _.upper };
2319
- g.add(b), v.add(b);
2320
- } else
2321
- v.add(n), g.add(n), i.indexes.forEach((b) => f(b.name).add(n));
2322
- return x;
2323
- });
2324
- } }, h = ({ query: { index: d, range: p } }) => {
2325
- var m, f;
2326
- return [d, new X((m = p.lower) !== null && m !== void 0 ? m : t.MIN_KEY, (f = p.upper) !== null && f !== void 0 ? f : t.MAX_KEY)];
2327
- }, l = { get: (d) => [o, new X(d.key)], getMany: (d) => [o, new X().addKeys(d.keys)], count: h, query: h, openCursor: h };
2328
- return B(l).forEach((d) => {
2329
- c[d] = function(p) {
2330
- const { subscr: m } = K;
2331
- if (m) {
2332
- const f = (k) => {
2333
- const P = `idb://${e}/${r}/${k}`;
2334
- return m[P] || (m[P] = new X());
2335
- }, v = f(""), g = f(":dels"), [y, _] = l[d](p);
2336
- if (f(y.name || "").add(_), !y.isPrimaryKey) {
2337
- if (d !== "count") {
2338
- const k = d === "query" && a && p.values && s.query({ ...p, values: !1 });
2339
- return s[d].apply(this, arguments).then((P) => {
2340
- if (d === "query") {
2341
- if (a && p.values)
2342
- return k.then(({ result: b }) => (v.addKeys(b), P));
2343
- const x = p.values ? P.result.map(u) : P.result;
2344
- p.values ? v.addKeys(x) : g.addKeys(x);
2345
- } else if (d === "openCursor") {
2346
- const x = P, b = p.values;
2347
- return x && Object.create(x, { key: { get: () => (g.addKey(x.primaryKey), x.key) }, primaryKey: { get() {
2348
- const S = x.primaryKey;
2349
- return g.addKey(S), S;
2350
- } }, value: { get: () => (b && v.addKey(x.primaryKey), x.value) } });
2351
- }
2352
- return P;
2353
- });
2354
- }
2355
- g.add(n);
2356
- }
2357
- }
2358
- return s[d].apply(this, arguments);
2359
- };
2360
- }), c;
2361
- } };
2362
- } };
2363
- class ke {
2364
- constructor(e, n) {
2365
- this._middlewares = {}, this.verno = 0;
2366
- const r = ke.dependencies;
2367
- this._options = n = { addons: ke.addons, autoOpen: !0, indexedDB: r.indexedDB, IDBKeyRange: r.IDBKeyRange, ...n }, this._deps = { indexedDB: n.indexedDB, IDBKeyRange: n.IDBKeyRange };
2368
- const { addons: s } = n;
2369
- this._dbSchema = {}, this._versions = [], this._storeNames = [], this._allTables = {}, this.idbdb = null, this._novip = this;
2370
- const i = { dbOpenError: null, isBeingOpened: !1, onReadyBeingFired: null, openComplete: !1, dbReadyResolve: C, dbReadyPromise: null, cancelOpen: C, openCanceller: null, autoSchema: !0, PR1398_maxLoop: 3 };
2371
- var o;
2372
- i.dbReadyPromise = new E((u) => {
2373
- i.dbReadyResolve = u;
2374
- }), i.openCanceller = new E((u, a) => {
2375
- i.cancelOpen = a;
2376
- }), this._state = i, this.name = e, this.on = Be(this, "populate", "blocked", "versionchange", "close", { ready: [en, C] }), this.on.ready.subscribe = xn(this.on.ready.subscribe, (u) => (a, c) => {
2377
- ke.vip(() => {
2378
- const h = this._state;
2379
- if (h.openComplete)
2380
- h.dbOpenError || E.resolve().then(a), c && u(a);
2381
- else if (h.onReadyBeingFired)
2382
- h.onReadyBeingFired.push(a), c && u(a);
2383
- else {
2384
- u(a);
2385
- const l = this;
2386
- c || u(function d() {
2387
- l.on.ready.unsubscribe(a), l.on.ready.unsubscribe(d);
2388
- });
2389
- }
2390
- });
2391
- }), this.Collection = (o = this, Ae(Er.prototype, function(u, a) {
2392
- this.db = o;
2393
- let c = Ln, h = null;
2394
- if (a)
2395
- try {
2396
- c = a();
2397
- } catch (m) {
2398
- h = m;
2399
- }
2400
- const l = u._ctx, d = l.table, p = d.hook.reading.fire;
2401
- this._ctx = { table: d, index: l.index, isPrimKey: !l.index || d.schema.primKey.keyPath && l.index === d.schema.primKey.name, range: c, keysOnly: !1, dir: "next", unique: "", algorithm: null, filter: null, replayFilter: null, justLimit: !0, isMatch: null, offset: 0, limit: 1 / 0, error: h, or: l.or, valueMapper: p !== Me ? p : null };
2402
- })), this.Table = function(u) {
2403
- return Ae(kr.prototype, function(a, c, h) {
2404
- this.db = u, this._tx = h, this.name = a, this.schema = c, this.hook = u._allTables[a] ? u._allTables[a].hook : Be(null, { creating: [hr, C], reading: [cr, Me], updating: [fr, C], deleting: [dr, C] });
2405
- });
2406
- }(this), this.Transaction = function(u) {
2407
- return Ae(Sr.prototype, function(a, c, h, l, d) {
2408
- this.db = u, this.mode = a, this.storeNames = c, this.schema = h, this.chromeTransactionDurability = l, this.idbtrans = null, this.on = Be(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 E((p, m) => {
2409
- this._resolve = p, this._reject = m;
2410
- }), this._completion.then(() => {
2411
- this.active = !1, this.on.complete.fire();
2412
- }, (p) => {
2413
- var m = this.active;
2414
- return this.active = !1, this.on.error.fire(p), this.parent ? this.parent._reject(p) : m && this.idbtrans && this.idbtrans.abort(), R(p);
2415
- });
2416
- });
2417
- }(this), this.Version = function(u) {
2418
- return Ae(Ir.prototype, function(a) {
2419
- this.db = u, this._cfg = { version: a, storesSource: null, dbschema: {}, tables: {}, contentUpgrade: null };
2420
- });
2421
- }(this), this.WhereClause = function(u) {
2422
- return Ae(Wn.prototype, function(a, c, h) {
2423
- this.db = u, this._ctx = { table: a, index: c === ":id" ? null : c, or: h };
2424
- const l = u._deps.indexedDB;
2425
- if (!l)
2426
- throw new O.MissingAPI();
2427
- this._cmp = this._ascending = l.cmp.bind(l), this._descending = (d, p) => l.cmp(p, d), this._max = (d, p) => l.cmp(d, p) > 0 ? d : p, this._min = (d, p) => l.cmp(d, p) < 0 ? d : p, this._IDBKeyRange = u._deps.IDBKeyRange;
2428
- });
2429
- }(this), this.on("versionchange", (u) => {
2430
- 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();
2431
- }), this.on("blocked", (u) => {
2432
- !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}`);
2433
- }), this._maxKey = Ue(n.IDBKeyRange), this._createTransaction = (u, a, c, h) => new this.Transaction(u, a, c, this._options.chromeTransactionDurability, h), this._fireOnBlocked = (u) => {
2434
- this.on("blocked").fire(u), Te.filter((a) => a.name === this.name && a !== this && !a._state.vcFired).map((a) => a.on("versionchange").fire(u));
2435
- }, this.use(Fr), this.use(Mr), this.use($r), this.use(Nr), this.vip = Object.create(this, { _vip: { value: !0 } }), s.forEach((u) => u(this));
2436
- }
2437
- version(e) {
2438
- if (isNaN(e) || e < 0.1)
2439
- throw new O.Type("Given version is not a positive number");
2440
- if (e = Math.round(10 * e) / 10, this.idbdb || this._state.isBeingOpened)
2441
- throw new O.Schema("Cannot add version when database is open");
2442
- this.verno = Math.max(this.verno, e);
2443
- const n = this._versions;
2444
- var r = n.filter((s) => s._cfg.version === e)[0];
2445
- return r || (r = new this.Version(e), n.push(r), n.sort(jr), r.stores({}), this._state.autoSchema = !1, r);
2446
- }
2447
- _whenReady(e) {
2448
- return this.idbdb && (this._state.openComplete || K.letThrough || this._vip) ? e() : new E((n, r) => {
2449
- if (this._state.openComplete)
2450
- return r(new O.DatabaseClosed(this._state.dbOpenError));
2451
- if (!this._state.isBeingOpened) {
2452
- if (!this._options.autoOpen)
2453
- return void r(new O.DatabaseClosed());
2454
- this.open().catch(C);
2455
- }
2456
- this._state.dbReadyPromise.then(n, r);
2457
- }).then(e);
2458
- }
2459
- use({ stack: e, create: n, level: r, name: s }) {
2460
- s && this.unuse({ stack: e, name: s });
2461
- const i = this._middlewares[e] || (this._middlewares[e] = []);
2462
- return i.push({ stack: e, create: n, level: r ?? 10, name: s }), i.sort((o, u) => o.level - u.level), this;
2463
- }
2464
- unuse({ stack: e, name: n, create: r }) {
2465
- return e && this._middlewares[e] && (this._middlewares[e] = this._middlewares[e].filter((s) => r ? s.create !== r : !!n && s.name !== n)), this;
2466
- }
2467
- open() {
2468
- return Br(this);
2469
- }
2470
- _close() {
2471
- const e = this._state, n = Te.indexOf(this);
2472
- if (n >= 0 && Te.splice(n, 1), this.idbdb) {
2473
- try {
2474
- this.idbdb.close();
2475
- } catch {
2476
- }
2477
- this._novip.idbdb = null;
2478
- }
2479
- e.dbReadyPromise = new E((r) => {
2480
- e.dbReadyResolve = r;
2481
- }), e.openCanceller = new E((r, s) => {
2482
- e.cancelOpen = s;
2483
- });
2484
- }
2485
- close() {
2486
- this._close();
2487
- const e = this._state;
2488
- this._options.autoOpen = !1, e.dbOpenError = new O.DatabaseClosed(), e.isBeingOpened && e.cancelOpen(e.dbOpenError);
2489
- }
2490
- delete() {
2491
- const e = arguments.length > 0, n = this._state;
2492
- return new E((r, s) => {
2493
- const i = () => {
2494
- this.close();
2495
- var o = this._deps.indexedDB.deleteDatabase(this.name);
2496
- o.onsuccess = D(() => {
2497
- (function({ indexedDB: u, IDBKeyRange: a }, c) {
2498
- !on(u) && c !== mt && sn(u, a).delete(c).catch(C);
2499
- })(this._deps, this.name), r();
2500
- }), o.onerror = Y(s), o.onblocked = this._fireOnBlocked;
2501
- };
2502
- if (e)
2503
- throw new O.InvalidArgument("Arguments not allowed in db.delete()");
2504
- n.isBeingOpened ? n.dbReadyPromise.then(i) : i();
2505
- });
2506
- }
2507
- backendDB() {
2508
- return this.idbdb;
2509
- }
2510
- isOpen() {
2511
- return this.idbdb !== null;
2512
- }
2513
- hasBeenClosed() {
2514
- const e = this._state.dbOpenError;
2515
- return e && e.name === "DatabaseClosed";
2516
- }
2517
- hasFailed() {
2518
- return this._state.dbOpenError !== null;
2519
- }
2520
- dynamicallyOpened() {
2521
- return this._state.autoSchema;
2522
- }
2523
- get tables() {
2524
- return B(this._allTables).map((e) => this._allTables[e]);
2525
- }
2526
- transaction() {
2527
- const e = Rr.apply(this, arguments);
2528
- return this._transaction.apply(this, e);
2529
- }
2530
- _transaction(e, n, r) {
2531
- let s = K.trans;
2532
- s && s.db === this && e.indexOf("!") === -1 || (s = null);
2533
- const i = e.indexOf("?") !== -1;
2534
- let o, u;
2535
- e = e.replace("!", "").replace("?", "");
2536
- try {
2537
- if (u = n.map((c) => {
2538
- var h = c instanceof this.Table ? c.name : c;
2539
- if (typeof h != "string")
2540
- throw new TypeError("Invalid table argument to Dexie.transaction(). Only Table or String are allowed");
2541
- return h;
2542
- }), e == "r" || e === bt)
2543
- o = bt;
2544
- else {
2545
- if (e != "rw" && e != _t)
2546
- throw new O.InvalidArgument("Invalid transaction mode: " + e);
2547
- o = _t;
2548
- }
2549
- if (s) {
2550
- if (s.mode === bt && o === _t) {
2551
- if (!i)
2552
- throw new O.SubTransaction("Cannot enter a sub-transaction with READWRITE mode when parent transaction is READONLY");
2553
- s = null;
2554
- }
2555
- s && u.forEach((c) => {
2556
- if (s && s.storeNames.indexOf(c) === -1) {
2557
- if (!i)
2558
- throw new O.SubTransaction("Table " + c + " not included in parent transaction.");
2559
- s = null;
2560
- }
2561
- }), i && s && !s.active && (s = null);
2562
- }
2563
- } catch (c) {
2564
- return s ? s._promise(null, (h, l) => {
2565
- l(c);
2566
- }) : R(c);
2567
- }
2568
- const a = Hn.bind(null, this, o, u, s, r);
2569
- return s ? s._promise(o, a, "lock") : K.trans ? Oe(K.transless, () => this._whenReady(a)) : this._whenReady(a);
2570
- }
2571
- table(e) {
2572
- if (!W(this._allTables, e))
2573
- throw new O.InvalidTable(`Table ${e} does not exist`);
2574
- return this._allTables[e];
2575
- }
2576
- }
2577
- const Ur = typeof Symbol < "u" && "observable" in Symbol ? Symbol.observable : "@@observable";
2578
- class Lr {
2579
- constructor(e) {
2580
- this._subscribe = e;
2581
- }
2582
- subscribe(e, n, r) {
2583
- return this._subscribe(e && typeof e != "function" ? e : { next: e, error: n, complete: r });
2584
- }
2585
- [Ur]() {
2586
- return this;
2587
- }
2588
- }
2589
- function Qn(t, e) {
2590
- return B(e).forEach((n) => {
2591
- pt(t[n] || (t[n] = new X()), e[n]);
2592
- }), t;
2593
- }
2594
- function Vr(t) {
2595
- let e, n = !1;
2596
- const r = new Lr((s) => {
2597
- const i = Qt(t);
2598
- let o = !1, u = {}, a = {};
2599
- const c = { get closed() {
2600
- return o;
2601
- }, unsubscribe: () => {
2602
- o = !0, ae.storagemutated.unsubscribe(p);
2603
- } };
2604
- s.start && s.start(c);
2605
- let h = !1, l = !1;
2606
- function d() {
2607
- return B(a).some((f) => u[f] && qr(u[f], a[f]));
2608
- }
2609
- const p = (f) => {
2610
- Qn(u, f), d() && m();
2611
- }, m = () => {
2612
- if (h || o)
2613
- return;
2614
- u = {};
2615
- const f = {}, v = function(g) {
2616
- i && Ke();
2617
- const y = () => ie(t, { subscr: g, trans: null }), _ = K.trans ? Oe(K.transless, y) : y();
2618
- return i && _.then(te, te), _;
2619
- }(f);
2620
- l || (ae($e, p), l = !0), h = !0, Promise.resolve(v).then((g) => {
2621
- n = !0, e = g, h = !1, o || (d() ? m() : (u = {}, a = f, s.next && s.next(g)));
2622
- }, (g) => {
2623
- h = !1, n = !1, s.error && s.error(g), c.unsubscribe();
2624
- });
2625
- };
2626
- return m(), c;
2627
- });
2628
- return r.hasValue = () => n, r.getValue = () => e, r;
2629
- }
2630
- let Ht;
2631
- try {
2632
- Ht = { indexedDB: j.indexedDB || j.mozIndexedDB || j.webkitIndexedDB || j.msIndexedDB, IDBKeyRange: j.IDBKeyRange || j.webkitIDBKeyRange };
2633
- } catch {
2634
- Ht = { indexedDB: null, IDBKeyRange: null };
2635
- }
2636
- const le = ke;
2637
- function ot(t) {
2638
- let e = J;
2639
- try {
2640
- J = !0, ae.storagemutated.fire(t);
2641
- } finally {
2642
- J = e;
2643
- }
2644
- }
2645
- Ee(le, { ...et, delete: (t) => new le(t, { addons: [] }).delete(), exists: (t) => new le(t, { addons: [] }).open().then((e) => (e.close(), !0)).catch("NoSuchDatabaseError", () => !1), getDatabaseNames(t) {
2646
- try {
2647
- return function({ indexedDB: e, IDBKeyRange: n }) {
2648
- return on(e) ? Promise.resolve(e.databases()).then((r) => r.map((s) => s.name).filter((s) => s !== mt)) : sn(e, n).toCollection().primaryKeys();
2649
- }(le.dependencies).then(t);
2650
- } catch {
2651
- return R(new O.MissingAPI());
2652
- }
2653
- }, defineClass: () => function(t) {
2654
- U(this, t);
2655
- }, ignoreTransaction: (t) => K.trans ? Oe(K.transless, t) : t(), vip: zt, async: function(t) {
2656
- return function() {
2657
- try {
2658
- var e = Yt(t.apply(this, arguments));
2659
- return e && typeof e.then == "function" ? e : E.resolve(e);
2660
- } catch (n) {
2661
- return R(n);
2662
- }
2663
- };
2664
- }, spawn: function(t, e, n) {
2665
- try {
2666
- var r = Yt(t.apply(n, e || []));
2667
- return r && typeof r.then == "function" ? r : E.resolve(r);
2668
- } catch (s) {
2669
- return R(s);
2670
- }
2671
- }, currentTransaction: { get: () => K.trans || null }, waitFor: function(t, e) {
2672
- const n = E.resolve(typeof t == "function" ? le.ignoreTransaction(t) : t).timeout(e || 6e4);
2673
- return K.trans ? K.trans.waitFor(n) : n;
2674
- }, Promise: E, debug: { get: () => G, set: (t) => {
2675
- Sn(t, t === "dexie" ? () => !0 : Un);
2676
- } }, derive: _e, extend: U, props: Ee, override: xn, Events: Be, on: ae, liveQuery: Vr, extendObservabilitySet: Qn, getByKeyPath: ee, setByKeyPath: z, delByKeyPath: function(t, e) {
2677
- typeof e == "string" ? z(t, e, void 0) : "length" in e && [].map.call(e, function(n) {
2678
- z(t, n, void 0);
2679
- });
2680
- }, shallowClone: Pn, deepClone: Ve, getObjectDiff: an, cmp: $, asap: kn, minKey: Mt, addons: [], connections: Te, errnames: Zt, dependencies: Ht, semVer: fn, version: fn.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" && (ae($e, (t) => {
2681
- if (!J) {
2682
- let e;
2683
- yt ? (e = document.createEvent("CustomEvent"), e.initCustomEvent(se, !0, !0, t)) : e = new CustomEvent(se, { detail: t }), J = !0, dispatchEvent(e), J = !1;
2684
- }
2685
- }), addEventListener(se, ({ detail: t }) => {
2686
- J || ot(t);
2687
- }));
2688
- let J = !1;
2689
- if (typeof BroadcastChannel < "u") {
2690
- const t = new BroadcastChannel(se);
2691
- typeof t.unref == "function" && t.unref(), ae($e, (e) => {
2692
- J || t.postMessage(e);
2693
- }), t.onmessage = (e) => {
2694
- e.data && ot(e.data);
2695
- };
2696
- } else if (typeof self < "u" && typeof navigator < "u") {
2697
- ae($e, (e) => {
2698
- try {
2699
- J || (typeof localStorage < "u" && localStorage.setItem(se, JSON.stringify({ trig: Math.random(), changedParts: e })), typeof self.clients == "object" && [...self.clients.matchAll({ includeUncontrolled: !0 })].forEach((n) => n.postMessage({ type: se, changedParts: e })));
2700
- } catch {
2701
- }
2702
- }), typeof addEventListener < "u" && addEventListener("storage", (e) => {
2703
- if (e.key === se) {
2704
- const n = JSON.parse(e.newValue);
2705
- n && ot(n.changedParts);
2706
- }
2707
- });
2708
- const t = self.document && navigator.serviceWorker;
2709
- t && t.addEventListener("message", function({ data: e }) {
2710
- e && e.type === se && ot(e.changedParts);
2711
- });
2712
- }
2713
- E.rejectionMapper = function(t, e) {
2714
- if (!t || t instanceof we || t instanceof TypeError || t instanceof SyntaxError || !t.name || !ln[t.name])
2715
- return t;
2716
- var n = new ln[t.name](e || t.message, t);
2717
- return "stack" in t && Z(n, "stack", { get: function() {
2718
- return this.inner.stack;
2719
- } }), n;
2720
- }, Sn(G, Un);
2721
- export {
2722
- zr as X,
2723
- Zn as n
2724
- };