@vestcards/shared 1.2.0 → 1.4.0

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.
@@ -1,1195 +1,1336 @@
1
- var Oe = Object.defineProperty;
2
- var Fe = (t, e, i) => e in t ? Oe(t, e, { enumerable: !0, configurable: !0, writable: !0, value: i }) : t[e] = i;
3
- var _ = (t, e, i) => Fe(t, typeof e != "symbol" ? e + "" : e, i);
4
- import { r as V, a as Ne, b as fe } from "./fsrs-sJJWxUiC.js";
5
- import "date-fns/locale";
6
- import { isSameDay as Ie } from "date-fns";
7
- import "date-fns-tz";
8
- const Pe = 0.9, Ft = 50, Nt = 200, It = 10, Pt = 10;
9
- var h = ((t) => (t[t.New = 0] = "New", t[t.Learning = 1] = "Learning", t[t.Review = 2] = "Review", t[t.Relearning = 3] = "Relearning", t))(h || {}), l = ((t) => (t[t.Manual = 0] = "Manual", t[t.Again = 1] = "Again", t[t.Hard = 2] = "Hard", t[t.Good = 3] = "Good", t[t.Easy = 4] = "Easy", t))(l || {});
10
- class d {
11
- static card(e) {
12
- return { ...e, state: d.state(e.state), due: d.time(e.due), last_review: e.last_review ? d.time(e.last_review) : void 0 };
13
- }
14
- static rating(e) {
15
- if (typeof e == "string") {
16
- const i = e.charAt(0).toUpperCase(), r = e.slice(1).toLowerCase(), s = l[`${i}${r}`];
17
- if (s === void 0) throw new Error(`Invalid rating:[${e}]`);
18
- return s;
19
- } else if (typeof e == "number") return e;
20
- throw new Error(`Invalid rating:[${e}]`);
21
- }
22
- static state(e) {
23
- if (typeof e == "string") {
24
- const i = e.charAt(0).toUpperCase(), r = e.slice(1).toLowerCase(), s = h[`${i}${r}`];
25
- if (s === void 0) throw new Error(`Invalid state:[${e}]`);
26
- return s;
27
- } else if (typeof e == "number") return e;
28
- throw new Error(`Invalid state:[${e}]`);
29
- }
30
- static time(e) {
31
- if (typeof e == "object" && e instanceof Date) return e;
32
- if (typeof e == "string") {
33
- const i = Date.parse(e);
34
- if (isNaN(i)) throw new Error(`Invalid date:[${e}]`);
35
- return new Date(i);
36
- } else if (typeof e == "number") return new Date(e);
37
- throw new Error(`Invalid date:[${e}]`);
38
- }
39
- static review_log(e) {
40
- return { ...e, due: d.time(e.due), rating: d.rating(e.rating), state: d.state(e.state), review: d.time(e.review) };
41
- }
42
- }
43
- Date.prototype.scheduler = function(t, e) {
44
- return Ae(this, t, e);
45
- }, Date.prototype.diff = function(t, e) {
46
- return Te(this, t, e);
1
+ import { t as e } from "./date-D5P-dKAx.js";
2
+ import { i as t, n, r } from "./fsrs-D2XsH28s.js";
3
+ //#region src/spaced-repetition/config.ts
4
+ var i = .9, a = .1542, o = i ** (-1 / a) - 1, s = 50, c = {
5
+ learnDailyLimit: {
6
+ recommended: 200,
7
+ min: 100,
8
+ max: 500,
9
+ step: 50
10
+ },
11
+ newCardsPerDeckDailyLimit: {
12
+ recommended: 10,
13
+ min: 1,
14
+ max: 50,
15
+ step: 5
16
+ }
17
+ }, l = 10, u = (e, t) => e === c.learnDailyLimit.recommended && t === c.newCardsPerDeckDailyLimit.recommended, d = ((e) => (e[e.New = 0] = "New", e[e.Learning = 1] = "Learning", e[e.Review = 2] = "Review", e[e.Relearning = 3] = "Relearning", e))(d || {}), f = ((e) => (e[e.Manual = 0] = "Manual", e[e.Again = 1] = "Again", e[e.Hard = 2] = "Hard", e[e.Good = 3] = "Good", e[e.Easy = 4] = "Easy", e))(f || {}), p = class e {
18
+ static card(t) {
19
+ return {
20
+ ...t,
21
+ state: e.state(t.state),
22
+ due: e.time(t.due),
23
+ last_review: t.last_review ? e.time(t.last_review) : void 0
24
+ };
25
+ }
26
+ static rating(e) {
27
+ if (typeof e == "string") {
28
+ let t = f[`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()}`];
29
+ if (t === void 0) throw Error(`Invalid rating:[${e}]`);
30
+ return t;
31
+ } else if (typeof e == "number") return e;
32
+ throw Error(`Invalid rating:[${e}]`);
33
+ }
34
+ static state(e) {
35
+ if (typeof e == "string") {
36
+ let t = d[`${e.charAt(0).toUpperCase()}${e.slice(1).toLowerCase()}`];
37
+ if (t === void 0) throw Error(`Invalid state:[${e}]`);
38
+ return t;
39
+ } else if (typeof e == "number") return e;
40
+ throw Error(`Invalid state:[${e}]`);
41
+ }
42
+ static time(e) {
43
+ if (typeof e == "object" && e instanceof Date) return e;
44
+ if (typeof e == "string") {
45
+ let t = Date.parse(e);
46
+ if (isNaN(t)) throw Error(`Invalid date:[${e}]`);
47
+ return new Date(t);
48
+ } else if (typeof e == "number") return new Date(e);
49
+ throw Error(`Invalid date:[${e}]`);
50
+ }
51
+ static review_log(t) {
52
+ return {
53
+ ...t,
54
+ due: e.time(t.due),
55
+ rating: e.rating(t.rating),
56
+ state: e.state(t.state),
57
+ review: e.time(t.review)
58
+ };
59
+ }
60
+ }, m = "4.7.1";
61
+ Date.prototype.scheduler = function(e, t) {
62
+ return ee(this, e, t);
63
+ }, Date.prototype.diff = function(e, t) {
64
+ return te(this, e, t);
47
65
  }, Date.prototype.format = function() {
48
- return ke(this);
49
- }, Date.prototype.dueFormat = function(t, e, i) {
50
- return je(this, t, e, i);
66
+ return ne(this);
67
+ }, Date.prototype.dueFormat = function(e, t, n) {
68
+ return re(this, e, t, n);
51
69
  };
52
- function Ae(t, e, i) {
53
- return new Date(i ? d.time(t).getTime() + e * 24 * 60 * 60 * 1e3 : d.time(t).getTime() + e * 60 * 1e3);
54
- }
55
- function Te(t, e, i) {
56
- if (!t || !e) throw new Error("Invalid date");
57
- const r = d.time(t).getTime() - d.time(e).getTime();
58
- let s = 0;
59
- switch (i) {
60
- case "days":
61
- s = Math.floor(r / (1440 * 60 * 1e3));
62
- break;
63
- case "minutes":
64
- s = Math.floor(r / (60 * 1e3));
65
- break;
66
- }
67
- return s;
68
- }
69
- function ke(t) {
70
- const e = d.time(t), i = e.getFullYear(), r = e.getMonth() + 1, s = e.getDate(), n = e.getHours(), a = e.getMinutes(), o = e.getSeconds();
71
- return `${i}-${D(r)}-${D(s)} ${D(n)}:${D(a)}:${D(o)}`;
72
- }
73
- function D(t) {
74
- return t < 10 ? `0${t}` : `${t}`;
75
- }
76
- const L = [60, 60, 24, 31, 12], G = ["second", "min", "hour", "day", "month", "year"];
77
- function je(t, e, i, r = G) {
78
- t = d.time(t), e = d.time(e), r.length !== G.length && (r = G);
79
- let s = t.getTime() - e.getTime(), n;
80
- for (s /= 1e3, n = 0; n < L.length && !(s < L[n]); n++) s /= L[n];
81
- return `${Math.floor(s)}${i ? r[n] : ""}`;
82
- }
83
- const he = Object.freeze([l.Again, l.Hard, l.Good, l.Easy]), He = [{ start: 2.5, end: 7, factor: 0.15 }, { start: 7, end: 20, factor: 0.1 }, { start: 20, end: 1 / 0, factor: 0.05 }];
84
- function $e(t, e, i) {
85
- let r = 1;
86
- for (const a of He) r += a.factor * Math.max(Math.min(t, a.end) - a.start, 0);
87
- t = Math.min(t, i);
88
- let s = Math.max(2, Math.round(t - r));
89
- const n = Math.min(Math.round(t + r), i);
90
- return t > e && (s = Math.max(s, e + 1)), s = Math.min(s, n), { min_ivl: s, max_ivl: n };
91
- }
92
- function b(t, e, i) {
93
- return Math.min(Math.max(t, e), i);
94
- }
95
- function Le(t, e) {
96
- const i = Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate()), r = Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate());
97
- return Math.floor((r - i) / 864e5);
98
- }
99
- const Ge = 0.9, Ue = 36500, qe = Object.freeze([0.40255, 1.18385, 3.173, 15.69105, 7.1949, 0.5345, 1.4604, 46e-4, 1.54575, 0.1192, 1.01925, 1.9395, 0.11, 0.29605, 2.2698, 0.2315, 2.9898, 0.51655, 0.6621]), We = !1, Ye = !0, p = 0.01, N = 100, ie = Object.freeze([Object.freeze([p, N]), Object.freeze([p, N]), Object.freeze([p, N]), Object.freeze([p, N]), Object.freeze([1, 10]), Object.freeze([1e-3, 4]), Object.freeze([1e-3, 4]), Object.freeze([1e-3, 0.75]), Object.freeze([0, 4.5]), Object.freeze([0, 0.8]), Object.freeze([1e-3, 3.5]), Object.freeze([1e-3, 5]), Object.freeze([1e-3, 0.25]), Object.freeze([1e-3, 0.9]), Object.freeze([0, 4]), Object.freeze([0, 1]), Object.freeze([1, 6]), Object.freeze([0, 2]), Object.freeze([0, 2])]), W = (t) => {
100
- let e = [...qe];
101
- return t != null && t.w && (t.w.length === 19 ? e = [...t.w] : t.w.length === 17 && (e = t == null ? void 0 : t.w.concat([0, 0]), e[4] = +(e[5] * 2 + e[4]).toFixed(8), e[5] = +(Math.log(e[5] * 3 + 1) / 3).toFixed(8), e[6] = +(e[6] + 0.5).toFixed(8), console.debug("[FSRS V5]auto fill w to 19 length"))), e = e.map((i, r) => b(i, ie[r][0], ie[r][1])), { request_retention: (t == null ? void 0 : t.request_retention) || Ge, maximum_interval: (t == null ? void 0 : t.maximum_interval) || Ue, w: e, enable_fuzz: (t == null ? void 0 : t.enable_fuzz) ?? We, enable_short_term: (t == null ? void 0 : t.enable_short_term) ?? Ye };
70
+ function ee(e, t, n) {
71
+ return new Date(n ? p.time(e).getTime() + t * 24 * 60 * 60 * 1e3 : p.time(e).getTime() + t * 60 * 1e3);
72
+ }
73
+ function te(e, t, n) {
74
+ if (!e || !t) throw Error("Invalid date");
75
+ let r = p.time(e).getTime() - p.time(t).getTime(), i = 0;
76
+ switch (n) {
77
+ case "days":
78
+ i = Math.floor(r / (1440 * 60 * 1e3));
79
+ break;
80
+ case "minutes":
81
+ i = Math.floor(r / (60 * 1e3));
82
+ break;
83
+ }
84
+ return i;
85
+ }
86
+ function ne(e) {
87
+ let t = p.time(e), n = t.getFullYear(), r = t.getMonth() + 1, i = t.getDate(), a = t.getHours(), o = t.getMinutes(), s = t.getSeconds();
88
+ return `${n}-${h(r)}-${h(i)} ${h(a)}:${h(o)}:${h(s)}`;
89
+ }
90
+ function h(e) {
91
+ return e < 10 ? `0${e}` : `${e}`;
92
+ }
93
+ var g = [
94
+ 60,
95
+ 60,
96
+ 24,
97
+ 31,
98
+ 12
99
+ ], _ = [
100
+ "second",
101
+ "min",
102
+ "hour",
103
+ "day",
104
+ "month",
105
+ "year"
106
+ ];
107
+ function re(e, t, n, r = _) {
108
+ e = p.time(e), t = p.time(t), r.length !== _.length && (r = _);
109
+ let i = e.getTime() - t.getTime(), a;
110
+ for (i /= 1e3, a = 0; a < g.length && !(i < g[a]); a++) i /= g[a];
111
+ return `${Math.floor(i)}${n ? r[a] : ""}`;
112
+ }
113
+ var ie = Object.freeze([
114
+ f.Again,
115
+ f.Hard,
116
+ f.Good,
117
+ f.Easy
118
+ ]), ae = [
119
+ {
120
+ start: 2.5,
121
+ end: 7,
122
+ factor: .15
123
+ },
124
+ {
125
+ start: 7,
126
+ end: 20,
127
+ factor: .1
128
+ },
129
+ {
130
+ start: 20,
131
+ end: Infinity,
132
+ factor: .05
133
+ }
134
+ ];
135
+ function oe(e, t, n) {
136
+ let r = 1;
137
+ for (let t of ae) r += t.factor * Math.max(Math.min(e, t.end) - t.start, 0);
138
+ e = Math.min(e, n);
139
+ let i = Math.max(2, Math.round(e - r)), a = Math.min(Math.round(e + r), n);
140
+ return e > t && (i = Math.max(i, t + 1)), i = Math.min(i, a), {
141
+ min_ivl: i,
142
+ max_ivl: a
143
+ };
144
+ }
145
+ function v(e, t, n) {
146
+ return Math.min(Math.max(e, t), n);
147
+ }
148
+ function se(e, t) {
149
+ let n = Date.UTC(e.getUTCFullYear(), e.getUTCMonth(), e.getUTCDate()), r = Date.UTC(t.getUTCFullYear(), t.getUTCMonth(), t.getUTCDate());
150
+ return Math.floor((r - n) / 864e5);
151
+ }
152
+ var ce = Object.freeze([
153
+ .40255,
154
+ 1.18385,
155
+ 3.173,
156
+ 15.69105,
157
+ 7.1949,
158
+ .5345,
159
+ 1.4604,
160
+ .0046,
161
+ 1.54575,
162
+ .1192,
163
+ 1.01925,
164
+ 1.9395,
165
+ .11,
166
+ .29605,
167
+ 2.2698,
168
+ .2315,
169
+ 2.9898,
170
+ .51655,
171
+ .6621
172
+ ]);
173
+ `${m}`;
174
+ var y = .01, le = Object.freeze([
175
+ Object.freeze([y, 100]),
176
+ Object.freeze([y, 100]),
177
+ Object.freeze([y, 100]),
178
+ Object.freeze([y, 100]),
179
+ Object.freeze([1, 10]),
180
+ Object.freeze([.001, 4]),
181
+ Object.freeze([.001, 4]),
182
+ Object.freeze([.001, .75]),
183
+ Object.freeze([0, 4.5]),
184
+ Object.freeze([0, .8]),
185
+ Object.freeze([.001, 3.5]),
186
+ Object.freeze([.001, 5]),
187
+ Object.freeze([.001, .25]),
188
+ Object.freeze([.001, .9]),
189
+ Object.freeze([0, 4]),
190
+ Object.freeze([0, 1]),
191
+ Object.freeze([1, 6]),
192
+ Object.freeze([0, 2]),
193
+ Object.freeze([0, 2])
194
+ ]), b = (e) => {
195
+ let t = [...ce];
196
+ return e?.w && (e.w.length === 19 ? t = [...e.w] : e.w.length === 17 && (t = e?.w.concat([0, 0]), t[4] = +(t[5] * 2 + t[4]).toFixed(8), t[5] = +(Math.log(t[5] * 3 + 1) / 3).toFixed(8), t[6] = +(t[6] + .5).toFixed(8), console.debug("[FSRS V5]auto fill w to 19 length"))), t = t.map((e, t) => v(e, le[t][0], le[t][1])), {
197
+ request_retention: e?.request_retention || .9,
198
+ maximum_interval: e?.maximum_interval || 36500,
199
+ w: t,
200
+ enable_fuzz: e?.enable_fuzz ?? !1,
201
+ enable_short_term: e?.enable_short_term ?? !0
202
+ };
102
203
  };
103
- function P(t, e) {
104
- const i = { due: t ? d.time(t) : /* @__PURE__ */ new Date(), stability: 0, difficulty: 0, elapsed_days: 0, scheduled_days: 0, reps: 0, lapses: 0, state: h.New, last_review: void 0 };
105
- return e && typeof e == "function" ? e(i) : i;
106
- }
107
- class Ke {
108
- constructor(e) {
109
- _(this, "c");
110
- _(this, "s0");
111
- _(this, "s1");
112
- _(this, "s2");
113
- const i = Be();
114
- this.c = 1, this.s0 = i(" "), this.s1 = i(" "), this.s2 = i(" "), e == null && (e = +/* @__PURE__ */ new Date()), this.s0 -= i(e), this.s0 < 0 && (this.s0 += 1), this.s1 -= i(e), this.s1 < 0 && (this.s1 += 1), this.s2 -= i(e), this.s2 < 0 && (this.s2 += 1);
115
- }
116
- next() {
117
- const e = 2091639 * this.s0 + this.c * 23283064365386963e-26;
118
- return this.s0 = this.s1, this.s1 = this.s2, this.s2 = e - (this.c = e | 0), this.s2;
119
- }
120
- set state(e) {
121
- this.c = e.c, this.s0 = e.s0, this.s1 = e.s1, this.s2 = e.s2;
122
- }
123
- get state() {
124
- return { c: this.c, s0: this.s0, s1: this.s1, s2: this.s2 };
125
- }
126
- }
127
- function Be() {
128
- let t = 4022871197;
129
- return function(e) {
130
- e = String(e);
131
- for (let i = 0; i < e.length; i++) {
132
- t += e.charCodeAt(i);
133
- let r = 0.02519603282416938 * t;
134
- t = r >>> 0, r -= t, r *= t, t = r >>> 0, r -= t, t += r * 4294967296;
135
- }
136
- return (t >>> 0) * 23283064365386963e-26;
137
- };
138
- }
139
- function Xe(t) {
140
- const e = new Ke(t), i = () => e.next();
141
- return i.int32 = () => e.next() * 4294967296 | 0, i.double = () => i() + (i() * 2097152 | 0) * 11102230246251565e-32, i.state = () => e.state, i.importState = (r) => (e.state = r, i), i;
142
- }
143
- const _e = -0.5, ye = 19 / 81;
144
- function Ze(t, e) {
145
- return +Math.pow(1 + ye * t / e, _e).toFixed(8);
146
- }
147
- class Je {
148
- constructor(e) {
149
- _(this, "param");
150
- _(this, "intervalModifier");
151
- _(this, "_seed");
152
- _(this, "forgetting_curve", Ze);
153
- this.param = new Proxy(W(e), this.params_handler_proxy()), this.intervalModifier = this.calculate_interval_modifier(this.param.request_retention);
154
- }
155
- get interval_modifier() {
156
- return this.intervalModifier;
157
- }
158
- set seed(e) {
159
- this._seed = e;
160
- }
161
- calculate_interval_modifier(e) {
162
- if (e <= 0 || e > 1) throw new Error("Requested retention rate should be in the range (0,1]");
163
- return +((Math.pow(e, 1 / _e) - 1) / ye).toFixed(8);
164
- }
165
- get parameters() {
166
- return this.param;
167
- }
168
- set parameters(e) {
169
- this.update_parameters(e);
170
- }
171
- params_handler_proxy() {
172
- const e = this;
173
- return { set: function(i, r, s) {
174
- return r === "request_retention" && Number.isFinite(s) && (e.intervalModifier = e.calculate_interval_modifier(Number(s))), Reflect.set(i, r, s), !0;
175
- } };
176
- }
177
- update_parameters(e) {
178
- const i = W(e);
179
- for (const r in i) if (r in this.param) {
180
- const s = r;
181
- this.param[s] = i[s];
182
- }
183
- }
184
- init_stability(e) {
185
- return Math.max(this.param.w[e - 1], 0.1);
186
- }
187
- init_difficulty(e) {
188
- return this.constrain_difficulty(this.param.w[4] - Math.exp((e - 1) * this.param.w[5]) + 1);
189
- }
190
- apply_fuzz(e, i) {
191
- if (!this.param.enable_fuzz || e < 2.5) return Math.round(e);
192
- const r = Xe(this._seed)(), { min_ivl: s, max_ivl: n } = $e(e, i, this.param.maximum_interval);
193
- return Math.floor(r * (n - s + 1) + s);
194
- }
195
- next_interval(e, i) {
196
- const r = Math.min(Math.max(1, Math.round(e * this.intervalModifier)), this.param.maximum_interval);
197
- return this.apply_fuzz(r, i);
198
- }
199
- linear_damping(e, i) {
200
- return +(e * (10 - i) / 9).toFixed(8);
201
- }
202
- next_difficulty(e, i) {
203
- const r = -this.param.w[6] * (i - 3), s = e + this.linear_damping(r, e);
204
- return this.constrain_difficulty(this.mean_reversion(this.init_difficulty(l.Easy), s));
205
- }
206
- constrain_difficulty(e) {
207
- return Math.min(Math.max(+e.toFixed(8), 1), 10);
208
- }
209
- mean_reversion(e, i) {
210
- return +(this.param.w[7] * e + (1 - this.param.w[7]) * i).toFixed(8);
211
- }
212
- next_recall_stability(e, i, r, s) {
213
- const n = l.Hard === s ? this.param.w[15] : 1, a = l.Easy === s ? this.param.w[16] : 1;
214
- return +b(i * (1 + Math.exp(this.param.w[8]) * (11 - e) * Math.pow(i, -this.param.w[9]) * (Math.exp((1 - r) * this.param.w[10]) - 1) * n * a), p, 36500).toFixed(8);
215
- }
216
- next_forget_stability(e, i, r) {
217
- return +b(this.param.w[11] * Math.pow(e, -this.param.w[12]) * (Math.pow(i + 1, this.param.w[13]) - 1) * Math.exp((1 - r) * this.param.w[14]), p, 36500).toFixed(8);
218
- }
219
- next_short_term_stability(e, i) {
220
- return +b(e * Math.exp(this.param.w[17] * (i - 3 + this.param.w[18])), p, 36500).toFixed(8);
221
- }
222
- next_state(e, i, r) {
223
- const { difficulty: s, stability: n } = e ?? { difficulty: 0, stability: 0 };
224
- if (i < 0) throw new Error(`Invalid delta_t "${i}"`);
225
- if (r < 0 || r > 4) throw new Error(`Invalid grade "${r}"`);
226
- if (s === 0 && n === 0) return { difficulty: this.init_difficulty(r), stability: this.init_stability(r) };
227
- if (r === 0) return { difficulty: s, stability: n };
228
- if (s < 1 || n < p) throw new Error(`Invalid memory state { difficulty: ${s}, stability: ${n} }`);
229
- const a = this.forgetting_curve(i, n), o = this.next_recall_stability(s, n, a, r), c = this.next_forget_stability(s, n, a), u = this.next_short_term_stability(n, r);
230
- let f = o;
231
- if (r === 1) {
232
- let [y, g] = [0, 0];
233
- this.param.enable_short_term && (y = this.param.w[17], g = this.param.w[18]);
234
- const E = n / Math.exp(y * g);
235
- f = b(+E.toFixed(8), p, c);
236
- }
237
- return i === 0 && this.param.enable_short_term && (f = u), { difficulty: this.next_difficulty(s, r), stability: f };
238
- }
239
- }
240
- function me() {
241
- const t = this.review_time.getTime(), e = this.current.reps, i = this.current.difficulty * this.current.stability;
242
- return `${t}_${e}_${i}`;
243
- }
244
- var Y = ((t) => (t.SCHEDULER = "Scheduler", t.SEED = "Seed", t))(Y || {});
245
- class we {
246
- constructor(e, i, r, s = { seed: me }) {
247
- _(this, "last");
248
- _(this, "current");
249
- _(this, "review_time");
250
- _(this, "next", /* @__PURE__ */ new Map());
251
- _(this, "algorithm");
252
- _(this, "initSeedStrategy");
253
- this.algorithm = r, this.initSeedStrategy = s.seed.bind(this), this.last = d.card(e), this.current = d.card(e), this.review_time = d.time(i), this.init();
254
- }
255
- init() {
256
- const { state: e, last_review: i } = this.current;
257
- let r = 0;
258
- e !== h.New && i && (r = Le(i, this.review_time)), this.current.last_review = this.review_time, this.current.elapsed_days = r, this.current.reps += 1, this.algorithm.seed = this.initSeedStrategy();
259
- }
260
- preview() {
261
- return { [l.Again]: this.review(l.Again), [l.Hard]: this.review(l.Hard), [l.Good]: this.review(l.Good), [l.Easy]: this.review(l.Easy), [Symbol.iterator]: this.previewIterator.bind(this) };
262
- }
263
- *previewIterator() {
264
- for (const e of he) yield this.review(e);
265
- }
266
- review(e) {
267
- const { state: i } = this.last;
268
- let r;
269
- switch (i) {
270
- case h.New:
271
- r = this.newState(e);
272
- break;
273
- case h.Learning:
274
- case h.Relearning:
275
- r = this.learningState(e);
276
- break;
277
- case h.Review:
278
- r = this.reviewState(e);
279
- break;
280
- }
281
- if (r) return r;
282
- throw new Error("Invalid grade");
283
- }
284
- buildLog(e) {
285
- const { last_review: i, due: r, elapsed_days: s } = this.last;
286
- return { rating: e, state: this.current.state, due: i || r, stability: this.current.stability, difficulty: this.current.difficulty, elapsed_days: this.current.elapsed_days, last_elapsed_days: s, scheduled_days: this.current.scheduled_days, review: this.review_time };
287
- }
288
- }
289
- class re extends we {
290
- newState(e) {
291
- const i = this.next.get(e);
292
- if (i) return i;
293
- const r = d.card(this.current);
294
- switch (r.difficulty = this.algorithm.init_difficulty(e), r.stability = this.algorithm.init_stability(e), e) {
295
- case l.Again:
296
- r.scheduled_days = 0, r.due = this.review_time.scheduler(1), r.state = h.Learning;
297
- break;
298
- case l.Hard:
299
- r.scheduled_days = 0, r.due = this.review_time.scheduler(5), r.state = h.Learning;
300
- break;
301
- case l.Good:
302
- r.scheduled_days = 0, r.due = this.review_time.scheduler(10), r.state = h.Learning;
303
- break;
304
- case l.Easy: {
305
- const n = this.algorithm.next_interval(r.stability, this.current.elapsed_days);
306
- r.scheduled_days = n, r.due = this.review_time.scheduler(n, !0), r.state = h.Review;
307
- break;
308
- }
309
- default:
310
- throw new Error("Invalid grade");
311
- }
312
- const s = { card: r, log: this.buildLog(e) };
313
- return this.next.set(e, s), s;
314
- }
315
- learningState(e) {
316
- const i = this.next.get(e);
317
- if (i) return i;
318
- const { state: r, difficulty: s, stability: n } = this.last, a = d.card(this.current), o = this.current.elapsed_days;
319
- switch (a.difficulty = this.algorithm.next_difficulty(s, e), a.stability = this.algorithm.next_short_term_stability(n, e), e) {
320
- case l.Again: {
321
- a.scheduled_days = 0, a.due = this.review_time.scheduler(5, !1), a.state = r;
322
- break;
323
- }
324
- case l.Hard: {
325
- a.scheduled_days = 0, a.due = this.review_time.scheduler(10), a.state = r;
326
- break;
327
- }
328
- case l.Good: {
329
- const u = this.algorithm.next_interval(a.stability, o);
330
- a.scheduled_days = u, a.due = this.review_time.scheduler(u, !0), a.state = h.Review;
331
- break;
332
- }
333
- case l.Easy: {
334
- const u = this.algorithm.next_short_term_stability(n, l.Good), f = this.algorithm.next_interval(u, o), y = Math.max(this.algorithm.next_interval(a.stability, o), f + 1);
335
- a.scheduled_days = y, a.due = this.review_time.scheduler(y, !0), a.state = h.Review;
336
- break;
337
- }
338
- default:
339
- throw new Error("Invalid grade");
340
- }
341
- const c = { card: a, log: this.buildLog(e) };
342
- return this.next.set(e, c), c;
343
- }
344
- reviewState(e) {
345
- const i = this.next.get(e);
346
- if (i) return i;
347
- const r = this.current.elapsed_days, { difficulty: s, stability: n } = this.last, a = this.algorithm.forgetting_curve(r, n), o = d.card(this.current), c = d.card(this.current), u = d.card(this.current), f = d.card(this.current);
348
- this.next_ds(o, c, u, f, s, n, a), this.next_interval(o, c, u, f, r), this.next_state(o, c, u, f), o.lapses += 1;
349
- const y = { card: o, log: this.buildLog(l.Again) }, g = { card: c, log: super.buildLog(l.Hard) }, E = { card: u, log: super.buildLog(l.Good) }, R = { card: f, log: super.buildLog(l.Easy) };
350
- return this.next.set(l.Again, y), this.next.set(l.Hard, g), this.next.set(l.Good, E), this.next.set(l.Easy, R), this.next.get(e);
351
- }
352
- next_ds(e, i, r, s, n, a, o) {
353
- e.difficulty = this.algorithm.next_difficulty(n, l.Again);
354
- const c = a / Math.exp(this.algorithm.parameters.w[17] * this.algorithm.parameters.w[18]), u = this.algorithm.next_forget_stability(n, a, o);
355
- e.stability = b(+c.toFixed(8), p, u), i.difficulty = this.algorithm.next_difficulty(n, l.Hard), i.stability = this.algorithm.next_recall_stability(n, a, o, l.Hard), r.difficulty = this.algorithm.next_difficulty(n, l.Good), r.stability = this.algorithm.next_recall_stability(n, a, o, l.Good), s.difficulty = this.algorithm.next_difficulty(n, l.Easy), s.stability = this.algorithm.next_recall_stability(n, a, o, l.Easy);
356
- }
357
- next_interval(e, i, r, s, n) {
358
- let a, o;
359
- a = this.algorithm.next_interval(i.stability, n), o = this.algorithm.next_interval(r.stability, n), a = Math.min(a, o), o = Math.max(o, a + 1);
360
- const c = Math.max(this.algorithm.next_interval(s.stability, n), o + 1);
361
- e.scheduled_days = 0, e.due = this.review_time.scheduler(5), i.scheduled_days = a, i.due = this.review_time.scheduler(a, !0), r.scheduled_days = o, r.due = this.review_time.scheduler(o, !0), s.scheduled_days = c, s.due = this.review_time.scheduler(c, !0);
362
- }
363
- next_state(e, i, r, s) {
364
- e.state = h.Relearning, i.state = h.Review, r.state = h.Review, s.state = h.Review;
365
- }
366
- }
367
- class se extends we {
368
- newState(e) {
369
- const i = this.next.get(e);
370
- if (i) return i;
371
- this.current.scheduled_days = 0, this.current.elapsed_days = 0;
372
- const r = d.card(this.current), s = d.card(this.current), n = d.card(this.current), a = d.card(this.current);
373
- return this.init_ds(r, s, n, a), this.next_interval(r, s, n, a, 0), this.next_state(r, s, n, a), this.update_next(r, s, n, a), this.next.get(e);
374
- }
375
- init_ds(e, i, r, s) {
376
- e.difficulty = this.algorithm.init_difficulty(l.Again), e.stability = this.algorithm.init_stability(l.Again), i.difficulty = this.algorithm.init_difficulty(l.Hard), i.stability = this.algorithm.init_stability(l.Hard), r.difficulty = this.algorithm.init_difficulty(l.Good), r.stability = this.algorithm.init_stability(l.Good), s.difficulty = this.algorithm.init_difficulty(l.Easy), s.stability = this.algorithm.init_stability(l.Easy);
377
- }
378
- learningState(e) {
379
- return this.reviewState(e);
380
- }
381
- reviewState(e) {
382
- const i = this.next.get(e);
383
- if (i) return i;
384
- const r = this.current.elapsed_days, { difficulty: s, stability: n } = this.last, a = this.algorithm.forgetting_curve(r, n), o = d.card(this.current), c = d.card(this.current), u = d.card(this.current), f = d.card(this.current);
385
- return this.next_ds(o, c, u, f, s, n, a), this.next_interval(o, c, u, f, r), this.next_state(o, c, u, f), o.lapses += 1, this.update_next(o, c, u, f), this.next.get(e);
386
- }
387
- next_ds(e, i, r, s, n, a, o) {
388
- e.difficulty = this.algorithm.next_difficulty(n, l.Again);
389
- const c = this.algorithm.next_forget_stability(n, a, o);
390
- e.stability = b(a, p, c), i.difficulty = this.algorithm.next_difficulty(n, l.Hard), i.stability = this.algorithm.next_recall_stability(n, a, o, l.Hard), r.difficulty = this.algorithm.next_difficulty(n, l.Good), r.stability = this.algorithm.next_recall_stability(n, a, o, l.Good), s.difficulty = this.algorithm.next_difficulty(n, l.Easy), s.stability = this.algorithm.next_recall_stability(n, a, o, l.Easy);
391
- }
392
- next_interval(e, i, r, s, n) {
393
- let a, o, c, u;
394
- a = this.algorithm.next_interval(e.stability, n), o = this.algorithm.next_interval(i.stability, n), c = this.algorithm.next_interval(r.stability, n), u = this.algorithm.next_interval(s.stability, n), a = Math.min(a, o), o = Math.max(o, a + 1), c = Math.max(c, o + 1), u = Math.max(u, c + 1), e.scheduled_days = a, e.due = this.review_time.scheduler(a, !0), i.scheduled_days = o, i.due = this.review_time.scheduler(o, !0), r.scheduled_days = c, r.due = this.review_time.scheduler(c, !0), s.scheduled_days = u, s.due = this.review_time.scheduler(u, !0);
395
- }
396
- next_state(e, i, r, s) {
397
- e.state = h.Review, i.state = h.Review, r.state = h.Review, s.state = h.Review;
398
- }
399
- update_next(e, i, r, s) {
400
- const n = { card: e, log: this.buildLog(l.Again) }, a = { card: i, log: super.buildLog(l.Hard) }, o = { card: r, log: super.buildLog(l.Good) }, c = { card: s, log: super.buildLog(l.Easy) };
401
- this.next.set(l.Again, n), this.next.set(l.Hard, a), this.next.set(l.Good, o), this.next.set(l.Easy, c);
402
- }
403
- }
404
- class Qe {
405
- constructor(e) {
406
- _(this, "fsrs");
407
- this.fsrs = e;
408
- }
409
- replay(e, i, r) {
410
- return this.fsrs.next(e, i, r);
411
- }
412
- handleManualRating(e, i, r, s, n, a, o) {
413
- if (typeof i > "u") throw new Error("reschedule: state is required for manual rating");
414
- let c, u;
415
- if (i === h.New) c = { rating: l.Manual, state: i, due: o ?? r, stability: e.stability, difficulty: e.difficulty, elapsed_days: s, last_elapsed_days: e.elapsed_days, scheduled_days: e.scheduled_days, review: r }, u = P(r), u.last_review = r;
416
- else {
417
- if (typeof o > "u") throw new Error("reschedule: due is required for manual rating");
418
- const f = o.diff(r, "days");
419
- c = { rating: l.Manual, state: e.state, due: e.last_review || e.due, stability: e.stability, difficulty: e.difficulty, elapsed_days: s, last_elapsed_days: e.elapsed_days, scheduled_days: e.scheduled_days, review: r }, u = { ...e, state: i, due: o, last_review: r, stability: n || e.stability, difficulty: a || e.difficulty, elapsed_days: s, scheduled_days: f, reps: e.reps + 1 };
420
- }
421
- return { card: u, log: c };
422
- }
423
- reschedule(e, i) {
424
- const r = [];
425
- let s = P(e.due);
426
- for (const n of i) {
427
- let a;
428
- if (n.review = d.time(n.review), n.rating === l.Manual) {
429
- let o = 0;
430
- s.state !== h.New && s.last_review && (o = n.review.diff(s.last_review, "days")), a = this.handleManualRating(s, n.state, n.review, o, n.stability, n.difficulty, n.due ? d.time(n.due) : void 0);
431
- } else a = this.replay(s, n.review, n.rating);
432
- r.push(a), s = a.card;
433
- }
434
- return r;
435
- }
436
- calculateManualRecord(e, i, r, s) {
437
- if (!r) return null;
438
- const { card: n, log: a } = r, o = d.card(e);
439
- return o.due.getTime() === n.due.getTime() ? null : (o.scheduled_days = n.due.diff(o.due, "days"), this.handleManualRating(o, n.state, d.time(i), a.elapsed_days, s ? n.stability : void 0, s ? n.difficulty : void 0, n.due));
440
- }
441
- }
442
- class Ve extends Je {
443
- constructor(i) {
444
- super(i);
445
- _(this, "strategyHandler", /* @__PURE__ */ new Map());
446
- _(this, "Scheduler");
447
- const { enable_short_term: r } = this.parameters;
448
- this.Scheduler = r ? re : se;
449
- }
450
- params_handler_proxy() {
451
- const i = this;
452
- return { set: function(r, s, n) {
453
- return s === "request_retention" && Number.isFinite(n) ? i.intervalModifier = i.calculate_interval_modifier(Number(n)) : s === "enable_short_term" && (i.Scheduler = n === !0 ? re : se), Reflect.set(r, s, n), !0;
454
- } };
455
- }
456
- useStrategy(i, r) {
457
- return this.strategyHandler.set(i, r), this;
458
- }
459
- clearStrategy(i) {
460
- return i ? this.strategyHandler.delete(i) : this.strategyHandler.clear(), this;
461
- }
462
- getScheduler(i, r) {
463
- const s = this.strategyHandler.get(Y.SEED), n = this.strategyHandler.get(Y.SCHEDULER) || this.Scheduler, a = s || me;
464
- return new n(i, r, this, { seed: a });
465
- }
466
- repeat(i, r, s) {
467
- const n = this.getScheduler(i, r).preview();
468
- return s && typeof s == "function" ? s(n) : n;
469
- }
470
- next(i, r, s, n) {
471
- const a = this.getScheduler(i, r), o = d.rating(s);
472
- if (o === l.Manual) throw new Error("Cannot review a manual rating");
473
- const c = a.review(o);
474
- return n && typeof n == "function" ? n(c) : c;
475
- }
476
- get_retrievability(i, r, s = !0) {
477
- const n = d.card(i);
478
- r = r ? d.time(r) : /* @__PURE__ */ new Date();
479
- const a = n.state !== h.New ? Math.max(r.diff(n.last_review, "days"), 0) : 0, o = n.state !== h.New ? this.forgetting_curve(a, +n.stability.toFixed(8)) : 0;
480
- return s ? `${(o * 100).toFixed(2)}%` : o;
481
- }
482
- rollback(i, r, s) {
483
- const n = d.card(i), a = d.review_log(r);
484
- if (a.rating === l.Manual) throw new Error("Cannot rollback a manual rating");
485
- let o, c, u;
486
- switch (a.state) {
487
- case h.New:
488
- o = a.due, c = void 0, u = 0;
489
- break;
490
- case h.Learning:
491
- case h.Relearning:
492
- case h.Review:
493
- o = a.review, c = a.due, u = n.lapses - (a.rating === l.Again && a.state === h.Review ? 1 : 0);
494
- break;
495
- }
496
- const f = { ...n, due: o, stability: a.stability, difficulty: a.difficulty, elapsed_days: a.last_elapsed_days, scheduled_days: a.scheduled_days, reps: Math.max(0, n.reps - 1), lapses: Math.max(0, u), state: a.state, last_review: c };
497
- return s && typeof s == "function" ? s(f) : f;
498
- }
499
- forget(i, r, s = !1, n) {
500
- const a = d.card(i);
501
- r = d.time(r);
502
- const o = a.state === h.New ? 0 : r.diff(a.last_review, "days"), c = { rating: l.Manual, state: a.state, due: a.due, stability: a.stability, difficulty: a.difficulty, elapsed_days: 0, last_elapsed_days: a.elapsed_days, scheduled_days: o, review: r }, u = { card: { ...a, due: r, stability: 0, difficulty: 0, elapsed_days: 0, scheduled_days: 0, reps: s ? 0 : a.reps, lapses: s ? 0 : a.lapses, state: h.New, last_review: a.last_review }, log: c };
503
- return n && typeof n == "function" ? n(u) : u;
504
- }
505
- reschedule(i, r = [], s = {}) {
506
- const { recordLogHandler: n, reviewsOrderBy: a, skipManual: o = !0, now: c = /* @__PURE__ */ new Date(), update_memory_state: u = !1 } = s;
507
- a && typeof a == "function" && r.sort(a), o && (r = r.filter((ze) => ze.rating !== l.Manual));
508
- const f = new Qe(this), y = f.reschedule(s.first_card || P(), r), g = y.length, E = d.card(i), R = f.calculateManualRecord(E, c, g ? y[g - 1] : void 0, u);
509
- return n && typeof n == "function" ? { collections: y.map(n), reschedule_item: R ? n(R) : null } : { collections: y, reschedule_item: R };
510
- }
511
- }
512
- const et = (t) => new Ve(t || {}), tt = W({
513
- request_retention: Pe,
514
- enable_fuzz: !0,
515
- maximum_interval: 100
516
- }), pe = et(tt), ge = (t) => t.due ? t : { ...t, due: /* @__PURE__ */ new Date() }, it = (t) => fe.indexOf(t), ve = (t) => ({
517
- due: t.due,
518
- stability: t.stability,
519
- difficulty: t.difficulty,
520
- elapsed_days: t.elapsedDays,
521
- scheduled_days: t.scheduledDays,
522
- reps: t.reps,
523
- lapses: t.lapses,
524
- state: it(t.state),
525
- last_review: t.lastReview
526
- }), rt = (t, e, i) => {
527
- const r = /* @__PURE__ */ new Date(), s = ve(ge(t));
528
- return pe.repeat(s, r, (a) => {
529
- const o = at(e), c = a[o], u = nt(c.card, t), f = c.log, y = {
530
- id: 0,
531
- // will be set by the database
532
- cardReviewId: t.id,
533
- grade: e,
534
- state: be(f.state),
535
- due: f.due,
536
- stability: f.stability,
537
- difficulty: f.difficulty,
538
- elapsedDays: f.elapsed_days,
539
- lastElapsedDays: f.last_elapsed_days,
540
- scheduledDays: f.scheduled_days,
541
- review: f.review,
542
- duration: i
543
- };
544
- return { nextCard: u, reviewLog: y };
545
- });
204
+ function x(e, t) {
205
+ let n = {
206
+ due: e ? p.time(e) : /* @__PURE__ */ new Date(),
207
+ stability: 0,
208
+ difficulty: 0,
209
+ elapsed_days: 0,
210
+ scheduled_days: 0,
211
+ reps: 0,
212
+ lapses: 0,
213
+ state: d.New,
214
+ last_review: void 0
215
+ };
216
+ return t && typeof t == "function" ? t(n) : n;
217
+ }
218
+ var ue = class {
219
+ c;
220
+ s0;
221
+ s1;
222
+ s2;
223
+ constructor(e) {
224
+ let t = de();
225
+ this.c = 1, this.s0 = t(" "), this.s1 = t(" "), this.s2 = t(" "), e ??= +/* @__PURE__ */ new Date(), this.s0 -= t(e), this.s0 < 0 && (this.s0 += 1), this.s1 -= t(e), this.s1 < 0 && (this.s1 += 1), this.s2 -= t(e), this.s2 < 0 && (this.s2 += 1);
226
+ }
227
+ next() {
228
+ let e = 2091639 * this.s0 + this.c * 23283064365386963e-26;
229
+ return this.s0 = this.s1, this.s1 = this.s2, this.s2 = e - (this.c = e | 0), this.s2;
230
+ }
231
+ set state(e) {
232
+ this.c = e.c, this.s0 = e.s0, this.s1 = e.s1, this.s2 = e.s2;
233
+ }
234
+ get state() {
235
+ return {
236
+ c: this.c,
237
+ s0: this.s0,
238
+ s1: this.s1,
239
+ s2: this.s2
240
+ };
241
+ }
546
242
  };
547
- function At(t) {
548
- const e = /* @__PURE__ */ new Date(), i = ve(ge(t)), r = pe.repeat(i, e), s = Object.fromEntries(V.map((n) => [n, /* @__PURE__ */ new Date()]));
549
- for (const n of he) {
550
- const a = r[n].card.due, o = st(n);
551
- s[o] = a;
552
- }
553
- return s;
554
- }
555
- function st(t) {
556
- return V[t];
557
- }
558
- function be(t) {
559
- return fe[t];
560
- }
561
- function nt(t, e) {
562
- return {
563
- ...e,
564
- due: t.due,
565
- stability: t.stability,
566
- difficulty: t.difficulty,
567
- elapsedDays: t.elapsed_days,
568
- scheduledDays: t.scheduled_days,
569
- reps: t.reps,
570
- lapses: t.lapses,
571
- state: be(t.state),
572
- lastReview: t.last_review ?? null
573
- };
574
- }
575
- function at(t) {
576
- const e = V.indexOf(t);
577
- if (e === -1)
578
- throw new Error(`Invalid rating: ${t}`);
579
- return e;
580
- }
581
- function Tt(t, e) {
582
- const i = P();
583
- return {
584
- id: "",
585
- due: null,
586
- stability: i.stability,
587
- difficulty: i.difficulty,
588
- elapsedDays: i.elapsed_days,
589
- scheduledDays: i.scheduled_days,
590
- reps: i.reps,
591
- lapses: i.lapses,
592
- state: Ne.New,
593
- lastReview: i.last_review ?? null,
594
- userDeckStudyId: t,
595
- cardId: e
596
- };
597
- }
598
- var xe = Symbol.for("immer-nothing"), ne = Symbol.for("immer-draftable"), w = Symbol.for("immer-state"), ot = process.env.NODE_ENV !== "production" ? [
599
- // All error codes, starting by 0:
600
- function(t) {
601
- return `The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`;
602
- },
603
- function(t) {
604
- return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${t}'`;
605
- },
606
- "This object has been frozen and should not be mutated",
607
- function(t) {
608
- return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + t;
609
- },
610
- "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
611
- "Immer forbids circular references",
612
- "The first or second argument to `produce` must be a function",
613
- "The third argument to `produce` must be a function or undefined",
614
- "First argument to `createDraft` must be a plain object, an array, or an immerable object",
615
- "First argument to `finishDraft` must be a draft returned by `createDraft`",
616
- function(t) {
617
- return `'current' expects a draft, got: ${t}`;
618
- },
619
- "Object.defineProperty() cannot be used on an Immer draft",
620
- "Object.setPrototypeOf() cannot be used on an Immer draft",
621
- "Immer only supports deleting array indices",
622
- "Immer only supports setting array indices and the 'length' property",
623
- function(t) {
624
- return `'original' expects a draft, got: ${t}`;
625
- }
626
- // Note: if more errors are added, the errorOffset in Patches.ts should be increased
627
- // See Patches.ts for additional errors
628
- ] : [];
629
- function m(t, ...e) {
630
- if (process.env.NODE_ENV !== "production") {
631
- const i = ot[t], r = typeof i == "function" ? i.apply(null, e) : i;
632
- throw new Error(`[Immer] ${r}`);
633
- }
634
- throw new Error(
635
- `[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`
636
- );
637
- }
638
- var C = Object.getPrototypeOf;
639
- function S(t) {
640
- return !!t && !!t[w];
641
- }
642
- function x(t) {
643
- var e;
644
- return t ? Me(t) || Array.isArray(t) || !!t[ne] || !!((e = t.constructor) != null && e[ne]) || F(t) || H(t) : !1;
645
- }
646
- var lt = Object.prototype.constructor.toString(), ae = /* @__PURE__ */ new WeakMap();
647
- function Me(t) {
648
- if (!t || typeof t != "object")
649
- return !1;
650
- const e = Object.getPrototypeOf(t);
651
- if (e === null || e === Object.prototype)
652
- return !0;
653
- const i = Object.hasOwnProperty.call(e, "constructor") && e.constructor;
654
- if (i === Object)
655
- return !0;
656
- if (typeof i != "function")
657
- return !1;
658
- let r = ae.get(i);
659
- return r === void 0 && (r = Function.toString.call(i), ae.set(i, r)), r === lt;
660
- }
661
- function A(t, e, i = !0) {
662
- j(t) === 0 ? (i ? Reflect.ownKeys(t) : Object.keys(t)).forEach((s) => {
663
- e(s, t[s], t);
664
- }) : t.forEach((r, s) => e(s, r, t));
665
- }
666
- function j(t) {
667
- const e = t[w];
668
- return e ? e.type_ : Array.isArray(t) ? 1 : F(t) ? 2 : H(t) ? 3 : 0;
669
- }
670
- function K(t, e) {
671
- return j(t) === 2 ? t.has(e) : Object.prototype.hasOwnProperty.call(t, e);
672
- }
673
- function Se(t, e, i) {
674
- const r = j(t);
675
- r === 2 ? t.set(e, i) : r === 3 ? t.add(i) : t[e] = i;
676
- }
677
- function ct(t, e) {
678
- return t === e ? t !== 0 || 1 / t === 1 / e : t !== t && e !== e;
679
- }
680
- function F(t) {
681
- return t instanceof Map;
682
- }
683
- function H(t) {
684
- return t instanceof Set;
685
- }
686
- function v(t) {
687
- return t.copy_ || t.base_;
688
- }
689
- function B(t, e) {
690
- if (F(t))
691
- return new Map(t);
692
- if (H(t))
693
- return new Set(t);
694
- if (Array.isArray(t))
695
- return Array.prototype.slice.call(t);
696
- const i = Me(t);
697
- if (e === !0 || e === "class_only" && !i) {
698
- const r = Object.getOwnPropertyDescriptors(t);
699
- delete r[w];
700
- let s = Reflect.ownKeys(r);
701
- for (let n = 0; n < s.length; n++) {
702
- const a = s[n], o = r[a];
703
- o.writable === !1 && (o.writable = !0, o.configurable = !0), (o.get || o.set) && (r[a] = {
704
- configurable: !0,
705
- writable: !0,
706
- // could live with !!desc.set as well here...
707
- enumerable: o.enumerable,
708
- value: t[a]
709
- });
710
- }
711
- return Object.create(C(t), r);
712
- } else {
713
- const r = C(t);
714
- if (r !== null && i)
715
- return { ...t };
716
- const s = Object.create(r);
717
- return Object.assign(s, t);
718
- }
719
- }
720
- function ee(t, e = !1) {
721
- return $(t) || S(t) || !x(t) || (j(t) > 1 && Object.defineProperties(t, {
722
- set: I,
723
- add: I,
724
- clear: I,
725
- delete: I
726
- }), Object.freeze(t), e && Object.values(t).forEach((i) => ee(i, !0))), t;
727
- }
728
- function ut() {
729
- m(2);
730
- }
731
- var I = {
732
- value: ut
243
+ function de() {
244
+ let e = 4022871197;
245
+ return function(t) {
246
+ t = String(t);
247
+ for (let n = 0; n < t.length; n++) {
248
+ e += t.charCodeAt(n);
249
+ let r = .02519603282416938 * e;
250
+ e = r >>> 0, r -= e, r *= e, e = r >>> 0, r -= e, e += r * 4294967296;
251
+ }
252
+ return (e >>> 0) * 23283064365386963e-26;
253
+ };
254
+ }
255
+ function fe(e) {
256
+ let t = new ue(e), n = () => t.next();
257
+ return n.int32 = () => t.next() * 4294967296 | 0, n.double = () => n() + (n() * 2097152 | 0) * 11102230246251565e-32, n.state = () => t.state, n.importState = (e) => (t.state = e, n), n;
258
+ }
259
+ var pe = -.5, me = 19 / 81;
260
+ function he(e, t) {
261
+ return +((1 + me * e / t) ** +pe).toFixed(8);
262
+ }
263
+ var ge = class {
264
+ param;
265
+ intervalModifier;
266
+ _seed;
267
+ constructor(e) {
268
+ this.param = new Proxy(b(e), this.params_handler_proxy()), this.intervalModifier = this.calculate_interval_modifier(this.param.request_retention);
269
+ }
270
+ get interval_modifier() {
271
+ return this.intervalModifier;
272
+ }
273
+ set seed(e) {
274
+ this._seed = e;
275
+ }
276
+ calculate_interval_modifier(e) {
277
+ if (e <= 0 || e > 1) throw Error("Requested retention rate should be in the range (0,1]");
278
+ return +((e ** (1 / pe) - 1) / me).toFixed(8);
279
+ }
280
+ get parameters() {
281
+ return this.param;
282
+ }
283
+ set parameters(e) {
284
+ this.update_parameters(e);
285
+ }
286
+ params_handler_proxy() {
287
+ let e = this;
288
+ return { set: function(t, n, r) {
289
+ return n === "request_retention" && Number.isFinite(r) && (e.intervalModifier = e.calculate_interval_modifier(Number(r))), Reflect.set(t, n, r), !0;
290
+ } };
291
+ }
292
+ update_parameters(e) {
293
+ let t = b(e);
294
+ for (let e in t) if (e in this.param) {
295
+ let n = e;
296
+ this.param[n] = t[n];
297
+ }
298
+ }
299
+ init_stability(e) {
300
+ return Math.max(this.param.w[e - 1], .1);
301
+ }
302
+ init_difficulty(e) {
303
+ return this.constrain_difficulty(this.param.w[4] - Math.exp((e - 1) * this.param.w[5]) + 1);
304
+ }
305
+ apply_fuzz(e, t) {
306
+ if (!this.param.enable_fuzz || e < 2.5) return Math.round(e);
307
+ let n = fe(this._seed)(), { min_ivl: r, max_ivl: i } = oe(e, t, this.param.maximum_interval);
308
+ return Math.floor(n * (i - r + 1) + r);
309
+ }
310
+ next_interval(e, t) {
311
+ let n = Math.min(Math.max(1, Math.round(e * this.intervalModifier)), this.param.maximum_interval);
312
+ return this.apply_fuzz(n, t);
313
+ }
314
+ linear_damping(e, t) {
315
+ return +(e * (10 - t) / 9).toFixed(8);
316
+ }
317
+ next_difficulty(e, t) {
318
+ let n = -this.param.w[6] * (t - 3), r = e + this.linear_damping(n, e);
319
+ return this.constrain_difficulty(this.mean_reversion(this.init_difficulty(f.Easy), r));
320
+ }
321
+ constrain_difficulty(e) {
322
+ return Math.min(Math.max(+e.toFixed(8), 1), 10);
323
+ }
324
+ mean_reversion(e, t) {
325
+ return +(this.param.w[7] * e + (1 - this.param.w[7]) * t).toFixed(8);
326
+ }
327
+ next_recall_stability(e, t, n, r) {
328
+ let i = f.Hard === r ? this.param.w[15] : 1, a = f.Easy === r ? this.param.w[16] : 1;
329
+ return +v(t * (1 + Math.exp(this.param.w[8]) * (11 - e) * t ** +-this.param.w[9] * (Math.exp((1 - n) * this.param.w[10]) - 1) * i * a), y, 36500).toFixed(8);
330
+ }
331
+ next_forget_stability(e, t, n) {
332
+ return +v(this.param.w[11] * e ** +-this.param.w[12] * ((t + 1) ** +this.param.w[13] - 1) * Math.exp((1 - n) * this.param.w[14]), y, 36500).toFixed(8);
333
+ }
334
+ next_short_term_stability(e, t) {
335
+ return +v(e * Math.exp(this.param.w[17] * (t - 3 + this.param.w[18])), y, 36500).toFixed(8);
336
+ }
337
+ forgetting_curve = he;
338
+ next_state(e, t, n) {
339
+ let { difficulty: r, stability: i } = e ?? {
340
+ difficulty: 0,
341
+ stability: 0
342
+ };
343
+ if (t < 0) throw Error(`Invalid delta_t "${t}"`);
344
+ if (n < 0 || n > 4) throw Error(`Invalid grade "${n}"`);
345
+ if (r === 0 && i === 0) return {
346
+ difficulty: this.init_difficulty(n),
347
+ stability: this.init_stability(n)
348
+ };
349
+ if (n === 0) return {
350
+ difficulty: r,
351
+ stability: i
352
+ };
353
+ if (r < 1 || i < .01) throw Error(`Invalid memory state { difficulty: ${r}, stability: ${i} }`);
354
+ let a = this.forgetting_curve(t, i), o = this.next_recall_stability(r, i, a, n), s = this.next_forget_stability(r, i, a), c = this.next_short_term_stability(i, n), l = o;
355
+ if (n === 1) {
356
+ let [e, t] = [0, 0];
357
+ this.param.enable_short_term && (e = this.param.w[17], t = this.param.w[18]), l = v(+(i / Math.exp(e * t)).toFixed(8), y, s);
358
+ }
359
+ return t === 0 && this.param.enable_short_term && (l = c), {
360
+ difficulty: this.next_difficulty(r, n),
361
+ stability: l
362
+ };
363
+ }
733
364
  };
734
- function $(t) {
735
- return t === null || typeof t != "object" ? !0 : Object.isFrozen(t);
736
- }
737
- var dt = {};
738
- function M(t) {
739
- const e = dt[t];
740
- return e || m(0, t), e;
741
- }
742
- var z;
743
- function Ee() {
744
- return z;
745
- }
746
- function ft(t, e) {
747
- return {
748
- drafts_: [],
749
- parent_: t,
750
- immer_: e,
751
- // Whenever the modified draft contains a draft from another scope, we
752
- // need to prevent auto-freezing so the unowned draft can be finalized.
753
- canAutoFreeze_: !0,
754
- unfinalizedDrafts_: 0
755
- };
756
- }
757
- function oe(t, e) {
758
- e && (M("Patches"), t.patches_ = [], t.inversePatches_ = [], t.patchListener_ = e);
759
- }
760
- function X(t) {
761
- Z(t), t.drafts_.forEach(ht), t.drafts_ = null;
762
- }
763
- function Z(t) {
764
- t === z && (z = t.parent_);
765
- }
766
- function le(t) {
767
- return z = ft(z, t);
768
- }
769
- function ht(t) {
770
- const e = t[w];
771
- e.type_ === 0 || e.type_ === 1 ? e.revoke_() : e.revoked_ = !0;
772
- }
773
- function ce(t, e) {
774
- e.unfinalizedDrafts_ = e.drafts_.length;
775
- const i = e.drafts_[0];
776
- return t !== void 0 && t !== i ? (i[w].modified_ && (X(e), m(4)), x(t) && (t = T(e, t), e.parent_ || k(e, t)), e.patches_ && M("Patches").generateReplacementPatches_(
777
- i[w].base_,
778
- t,
779
- e.patches_,
780
- e.inversePatches_
781
- )) : t = T(e, i, []), X(e), e.patches_ && e.patchListener_(e.patches_, e.inversePatches_), t !== xe ? t : void 0;
782
- }
783
- function T(t, e, i) {
784
- if ($(e))
785
- return e;
786
- const r = t.immer_.shouldUseStrictIteration(), s = e[w];
787
- if (!s)
788
- return A(
789
- e,
790
- (n, a) => ue(t, s, e, n, a, i),
791
- r
792
- ), e;
793
- if (s.scope_ !== t)
794
- return e;
795
- if (!s.modified_)
796
- return k(t, s.base_, !0), s.base_;
797
- if (!s.finalized_) {
798
- s.finalized_ = !0, s.scope_.unfinalizedDrafts_--;
799
- const n = s.copy_;
800
- let a = n, o = !1;
801
- s.type_ === 3 && (a = new Set(n), n.clear(), o = !0), A(
802
- a,
803
- (c, u) => ue(
804
- t,
805
- s,
806
- n,
807
- c,
808
- u,
809
- i,
810
- o
811
- ),
812
- r
813
- ), k(t, n, !1), i && t.patches_ && M("Patches").generatePatches_(
814
- s,
815
- i,
816
- t.patches_,
817
- t.inversePatches_
818
- );
819
- }
820
- return s.copy_;
821
- }
822
- function ue(t, e, i, r, s, n, a) {
823
- if (s == null || typeof s != "object" && !a)
824
- return;
825
- const o = $(s);
826
- if (!(o && !a)) {
827
- if (process.env.NODE_ENV !== "production" && s === i && m(5), S(s)) {
828
- const c = n && e && e.type_ !== 3 && // Set objects are atomic since they have no keys.
829
- !K(e.assigned_, r) ? n.concat(r) : void 0, u = T(t, s, c);
830
- if (Se(i, r, u), S(u))
831
- t.canAutoFreeze_ = !1;
832
- else
833
- return;
834
- } else a && i.add(s);
835
- if (x(s) && !o) {
836
- if (!t.immer_.autoFreeze_ && t.unfinalizedDrafts_ < 1 || e && e.base_ && e.base_[r] === s && o)
837
- return;
838
- T(t, s), (!e || !e.scope_.parent_) && typeof r != "symbol" && (F(i) ? i.has(r) : Object.prototype.propertyIsEnumerable.call(i, r)) && k(t, s);
839
- }
840
- }
841
- }
842
- function k(t, e, i = !1) {
843
- !t.parent_ && t.immer_.autoFreeze_ && t.canAutoFreeze_ && ee(e, i);
844
- }
845
- function _t(t, e) {
846
- const i = Array.isArray(t), r = {
847
- type_: i ? 1 : 0,
848
- // Track which produce call this is associated with.
849
- scope_: e ? e.scope_ : Ee(),
850
- // True for both shallow and deep changes.
851
- modified_: !1,
852
- // Used during finalization.
853
- finalized_: !1,
854
- // Track which properties have been assigned (true) or deleted (false).
855
- assigned_: {},
856
- // The parent draft state.
857
- parent_: e,
858
- // The base state.
859
- base_: t,
860
- // The base proxy.
861
- draft_: null,
862
- // set below
863
- // The base copy with any updated values.
864
- copy_: null,
865
- // Called by the `produce` function.
866
- revoke_: null,
867
- isManual_: !1
868
- };
869
- let s = r, n = te;
870
- i && (s = [r], n = O);
871
- const { revoke: a, proxy: o } = Proxy.revocable(s, n);
872
- return r.draft_ = o, r.revoke_ = a, o;
873
- }
874
- var te = {
875
- get(t, e) {
876
- if (e === w)
877
- return t;
878
- const i = v(t);
879
- if (!K(i, e))
880
- return yt(t, i, e);
881
- const r = i[e];
882
- return t.finalized_ || !x(r) ? r : r === U(t.base_, e) ? (q(t), t.copy_[e] = Q(r, t)) : r;
883
- },
884
- has(t, e) {
885
- return e in v(t);
886
- },
887
- ownKeys(t) {
888
- return Reflect.ownKeys(v(t));
889
- },
890
- set(t, e, i) {
891
- const r = Re(v(t), e);
892
- if (r != null && r.set)
893
- return r.set.call(t.draft_, i), !0;
894
- if (!t.modified_) {
895
- const s = U(v(t), e), n = s == null ? void 0 : s[w];
896
- if (n && n.base_ === i)
897
- return t.copy_[e] = i, t.assigned_[e] = !1, !0;
898
- if (ct(i, s) && (i !== void 0 || K(t.base_, e)))
899
- return !0;
900
- q(t), J(t);
901
- }
902
- return t.copy_[e] === i && // special case: handle new props with value 'undefined'
903
- (i !== void 0 || e in t.copy_) || // special case: NaN
904
- Number.isNaN(i) && Number.isNaN(t.copy_[e]) || (t.copy_[e] = i, t.assigned_[e] = !0), !0;
905
- },
906
- deleteProperty(t, e) {
907
- return U(t.base_, e) !== void 0 || e in t.base_ ? (t.assigned_[e] = !1, q(t), J(t)) : delete t.assigned_[e], t.copy_ && delete t.copy_[e], !0;
908
- },
909
- // Note: We never coerce `desc.value` into an Immer draft, because we can't make
910
- // the same guarantee in ES5 mode.
911
- getOwnPropertyDescriptor(t, e) {
912
- const i = v(t), r = Reflect.getOwnPropertyDescriptor(i, e);
913
- return r && {
914
- writable: !0,
915
- configurable: t.type_ !== 1 || e !== "length",
916
- enumerable: r.enumerable,
917
- value: i[e]
918
- };
919
- },
920
- defineProperty() {
921
- m(11);
922
- },
923
- getPrototypeOf(t) {
924
- return C(t.base_);
925
- },
926
- setPrototypeOf() {
927
- m(12);
928
- }
929
- }, O = {};
930
- A(te, (t, e) => {
931
- O[t] = function() {
932
- return arguments[0] = arguments[0][0], e.apply(this, arguments);
933
- };
934
- });
935
- O.deleteProperty = function(t, e) {
936
- return process.env.NODE_ENV !== "production" && isNaN(parseInt(e)) && m(13), O.set.call(this, t, e, void 0);
365
+ function _e() {
366
+ return `${this.review_time.getTime()}_${this.current.reps}_${this.current.difficulty * this.current.stability}`;
367
+ }
368
+ var S = ((e) => (e.SCHEDULER = "Scheduler", e.SEED = "Seed", e))(S || {}), ve = class {
369
+ last;
370
+ current;
371
+ review_time;
372
+ next = /* @__PURE__ */ new Map();
373
+ algorithm;
374
+ initSeedStrategy;
375
+ constructor(e, t, n, r = { seed: _e }) {
376
+ this.algorithm = n, this.initSeedStrategy = r.seed.bind(this), this.last = p.card(e), this.current = p.card(e), this.review_time = p.time(t), this.init();
377
+ }
378
+ init() {
379
+ let { state: e, last_review: t } = this.current, n = 0;
380
+ e !== d.New && t && (n = se(t, this.review_time)), this.current.last_review = this.review_time, this.current.elapsed_days = n, this.current.reps += 1, this.algorithm.seed = this.initSeedStrategy();
381
+ }
382
+ preview() {
383
+ return {
384
+ [f.Again]: this.review(f.Again),
385
+ [f.Hard]: this.review(f.Hard),
386
+ [f.Good]: this.review(f.Good),
387
+ [f.Easy]: this.review(f.Easy),
388
+ [Symbol.iterator]: this.previewIterator.bind(this)
389
+ };
390
+ }
391
+ *previewIterator() {
392
+ for (let e of ie) yield this.review(e);
393
+ }
394
+ review(e) {
395
+ let { state: t } = this.last, n;
396
+ switch (t) {
397
+ case d.New:
398
+ n = this.newState(e);
399
+ break;
400
+ case d.Learning:
401
+ case d.Relearning:
402
+ n = this.learningState(e);
403
+ break;
404
+ case d.Review:
405
+ n = this.reviewState(e);
406
+ break;
407
+ }
408
+ if (n) return n;
409
+ throw Error("Invalid grade");
410
+ }
411
+ buildLog(e) {
412
+ let { last_review: t, due: n, elapsed_days: r } = this.last;
413
+ return {
414
+ rating: e,
415
+ state: this.current.state,
416
+ due: t || n,
417
+ stability: this.current.stability,
418
+ difficulty: this.current.difficulty,
419
+ elapsed_days: this.current.elapsed_days,
420
+ last_elapsed_days: r,
421
+ scheduled_days: this.current.scheduled_days,
422
+ review: this.review_time
423
+ };
424
+ }
425
+ }, ye = class extends ve {
426
+ newState(e) {
427
+ let t = this.next.get(e);
428
+ if (t) return t;
429
+ let n = p.card(this.current);
430
+ switch (n.difficulty = this.algorithm.init_difficulty(e), n.stability = this.algorithm.init_stability(e), e) {
431
+ case f.Again:
432
+ n.scheduled_days = 0, n.due = this.review_time.scheduler(1), n.state = d.Learning;
433
+ break;
434
+ case f.Hard:
435
+ n.scheduled_days = 0, n.due = this.review_time.scheduler(5), n.state = d.Learning;
436
+ break;
437
+ case f.Good:
438
+ n.scheduled_days = 0, n.due = this.review_time.scheduler(10), n.state = d.Learning;
439
+ break;
440
+ case f.Easy: {
441
+ let e = this.algorithm.next_interval(n.stability, this.current.elapsed_days);
442
+ n.scheduled_days = e, n.due = this.review_time.scheduler(e, !0), n.state = d.Review;
443
+ break;
444
+ }
445
+ default: throw Error("Invalid grade");
446
+ }
447
+ let r = {
448
+ card: n,
449
+ log: this.buildLog(e)
450
+ };
451
+ return this.next.set(e, r), r;
452
+ }
453
+ learningState(e) {
454
+ let t = this.next.get(e);
455
+ if (t) return t;
456
+ let { state: n, difficulty: r, stability: i } = this.last, a = p.card(this.current), o = this.current.elapsed_days;
457
+ switch (a.difficulty = this.algorithm.next_difficulty(r, e), a.stability = this.algorithm.next_short_term_stability(i, e), e) {
458
+ case f.Again:
459
+ a.scheduled_days = 0, a.due = this.review_time.scheduler(5, !1), a.state = n;
460
+ break;
461
+ case f.Hard:
462
+ a.scheduled_days = 0, a.due = this.review_time.scheduler(10), a.state = n;
463
+ break;
464
+ case f.Good: {
465
+ let e = this.algorithm.next_interval(a.stability, o);
466
+ a.scheduled_days = e, a.due = this.review_time.scheduler(e, !0), a.state = d.Review;
467
+ break;
468
+ }
469
+ case f.Easy: {
470
+ let e = this.algorithm.next_short_term_stability(i, f.Good), t = this.algorithm.next_interval(e, o), n = Math.max(this.algorithm.next_interval(a.stability, o), t + 1);
471
+ a.scheduled_days = n, a.due = this.review_time.scheduler(n, !0), a.state = d.Review;
472
+ break;
473
+ }
474
+ default: throw Error("Invalid grade");
475
+ }
476
+ let s = {
477
+ card: a,
478
+ log: this.buildLog(e)
479
+ };
480
+ return this.next.set(e, s), s;
481
+ }
482
+ reviewState(e) {
483
+ let t = this.next.get(e);
484
+ if (t) return t;
485
+ let n = this.current.elapsed_days, { difficulty: r, stability: i } = this.last, a = this.algorithm.forgetting_curve(n, i), o = p.card(this.current), s = p.card(this.current), c = p.card(this.current), l = p.card(this.current);
486
+ this.next_ds(o, s, c, l, r, i, a), this.next_interval(o, s, c, l, n), this.next_state(o, s, c, l), o.lapses += 1;
487
+ let u = {
488
+ card: o,
489
+ log: this.buildLog(f.Again)
490
+ }, d = {
491
+ card: s,
492
+ log: super.buildLog(f.Hard)
493
+ }, m = {
494
+ card: c,
495
+ log: super.buildLog(f.Good)
496
+ }, ee = {
497
+ card: l,
498
+ log: super.buildLog(f.Easy)
499
+ };
500
+ return this.next.set(f.Again, u), this.next.set(f.Hard, d), this.next.set(f.Good, m), this.next.set(f.Easy, ee), this.next.get(e);
501
+ }
502
+ next_ds(e, t, n, r, i, a, o) {
503
+ e.difficulty = this.algorithm.next_difficulty(i, f.Again);
504
+ let s = a / Math.exp(this.algorithm.parameters.w[17] * this.algorithm.parameters.w[18]), c = this.algorithm.next_forget_stability(i, a, o);
505
+ e.stability = v(+s.toFixed(8), y, c), t.difficulty = this.algorithm.next_difficulty(i, f.Hard), t.stability = this.algorithm.next_recall_stability(i, a, o, f.Hard), n.difficulty = this.algorithm.next_difficulty(i, f.Good), n.stability = this.algorithm.next_recall_stability(i, a, o, f.Good), r.difficulty = this.algorithm.next_difficulty(i, f.Easy), r.stability = this.algorithm.next_recall_stability(i, a, o, f.Easy);
506
+ }
507
+ next_interval(e, t, n, r, i) {
508
+ let a, o;
509
+ a = this.algorithm.next_interval(t.stability, i), o = this.algorithm.next_interval(n.stability, i), a = Math.min(a, o), o = Math.max(o, a + 1);
510
+ let s = Math.max(this.algorithm.next_interval(r.stability, i), o + 1);
511
+ e.scheduled_days = 0, e.due = this.review_time.scheduler(5), t.scheduled_days = a, t.due = this.review_time.scheduler(a, !0), n.scheduled_days = o, n.due = this.review_time.scheduler(o, !0), r.scheduled_days = s, r.due = this.review_time.scheduler(s, !0);
512
+ }
513
+ next_state(e, t, n, r) {
514
+ e.state = d.Relearning, t.state = d.Review, n.state = d.Review, r.state = d.Review;
515
+ }
516
+ }, be = class extends ve {
517
+ newState(e) {
518
+ let t = this.next.get(e);
519
+ if (t) return t;
520
+ this.current.scheduled_days = 0, this.current.elapsed_days = 0;
521
+ let n = p.card(this.current), r = p.card(this.current), i = p.card(this.current), a = p.card(this.current);
522
+ return this.init_ds(n, r, i, a), this.next_interval(n, r, i, a, 0), this.next_state(n, r, i, a), this.update_next(n, r, i, a), this.next.get(e);
523
+ }
524
+ init_ds(e, t, n, r) {
525
+ e.difficulty = this.algorithm.init_difficulty(f.Again), e.stability = this.algorithm.init_stability(f.Again), t.difficulty = this.algorithm.init_difficulty(f.Hard), t.stability = this.algorithm.init_stability(f.Hard), n.difficulty = this.algorithm.init_difficulty(f.Good), n.stability = this.algorithm.init_stability(f.Good), r.difficulty = this.algorithm.init_difficulty(f.Easy), r.stability = this.algorithm.init_stability(f.Easy);
526
+ }
527
+ learningState(e) {
528
+ return this.reviewState(e);
529
+ }
530
+ reviewState(e) {
531
+ let t = this.next.get(e);
532
+ if (t) return t;
533
+ let n = this.current.elapsed_days, { difficulty: r, stability: i } = this.last, a = this.algorithm.forgetting_curve(n, i), o = p.card(this.current), s = p.card(this.current), c = p.card(this.current), l = p.card(this.current);
534
+ return this.next_ds(o, s, c, l, r, i, a), this.next_interval(o, s, c, l, n), this.next_state(o, s, c, l), o.lapses += 1, this.update_next(o, s, c, l), this.next.get(e);
535
+ }
536
+ next_ds(e, t, n, r, i, a, o) {
537
+ e.difficulty = this.algorithm.next_difficulty(i, f.Again), e.stability = v(a, y, this.algorithm.next_forget_stability(i, a, o)), t.difficulty = this.algorithm.next_difficulty(i, f.Hard), t.stability = this.algorithm.next_recall_stability(i, a, o, f.Hard), n.difficulty = this.algorithm.next_difficulty(i, f.Good), n.stability = this.algorithm.next_recall_stability(i, a, o, f.Good), r.difficulty = this.algorithm.next_difficulty(i, f.Easy), r.stability = this.algorithm.next_recall_stability(i, a, o, f.Easy);
538
+ }
539
+ next_interval(e, t, n, r, i) {
540
+ let a, o, s, c;
541
+ a = this.algorithm.next_interval(e.stability, i), o = this.algorithm.next_interval(t.stability, i), s = this.algorithm.next_interval(n.stability, i), c = this.algorithm.next_interval(r.stability, i), a = Math.min(a, o), o = Math.max(o, a + 1), s = Math.max(s, o + 1), c = Math.max(c, s + 1), e.scheduled_days = a, e.due = this.review_time.scheduler(a, !0), t.scheduled_days = o, t.due = this.review_time.scheduler(o, !0), n.scheduled_days = s, n.due = this.review_time.scheduler(s, !0), r.scheduled_days = c, r.due = this.review_time.scheduler(c, !0);
542
+ }
543
+ next_state(e, t, n, r) {
544
+ e.state = d.Review, t.state = d.Review, n.state = d.Review, r.state = d.Review;
545
+ }
546
+ update_next(e, t, n, r) {
547
+ let i = {
548
+ card: e,
549
+ log: this.buildLog(f.Again)
550
+ }, a = {
551
+ card: t,
552
+ log: super.buildLog(f.Hard)
553
+ }, o = {
554
+ card: n,
555
+ log: super.buildLog(f.Good)
556
+ }, s = {
557
+ card: r,
558
+ log: super.buildLog(f.Easy)
559
+ };
560
+ this.next.set(f.Again, i), this.next.set(f.Hard, a), this.next.set(f.Good, o), this.next.set(f.Easy, s);
561
+ }
562
+ }, xe = class {
563
+ fsrs;
564
+ constructor(e) {
565
+ this.fsrs = e;
566
+ }
567
+ replay(e, t, n) {
568
+ return this.fsrs.next(e, t, n);
569
+ }
570
+ handleManualRating(e, t, n, r, i, a, o) {
571
+ if (typeof t > "u") throw Error("reschedule: state is required for manual rating");
572
+ let s, c;
573
+ if (t === d.New) s = {
574
+ rating: f.Manual,
575
+ state: t,
576
+ due: o ?? n,
577
+ stability: e.stability,
578
+ difficulty: e.difficulty,
579
+ elapsed_days: r,
580
+ last_elapsed_days: e.elapsed_days,
581
+ scheduled_days: e.scheduled_days,
582
+ review: n
583
+ }, c = x(n), c.last_review = n;
584
+ else {
585
+ if (typeof o > "u") throw Error("reschedule: due is required for manual rating");
586
+ let l = o.diff(n, "days");
587
+ s = {
588
+ rating: f.Manual,
589
+ state: e.state,
590
+ due: e.last_review || e.due,
591
+ stability: e.stability,
592
+ difficulty: e.difficulty,
593
+ elapsed_days: r,
594
+ last_elapsed_days: e.elapsed_days,
595
+ scheduled_days: e.scheduled_days,
596
+ review: n
597
+ }, c = {
598
+ ...e,
599
+ state: t,
600
+ due: o,
601
+ last_review: n,
602
+ stability: i || e.stability,
603
+ difficulty: a || e.difficulty,
604
+ elapsed_days: r,
605
+ scheduled_days: l,
606
+ reps: e.reps + 1
607
+ };
608
+ }
609
+ return {
610
+ card: c,
611
+ log: s
612
+ };
613
+ }
614
+ reschedule(e, t) {
615
+ let n = [], r = x(e.due);
616
+ for (let e of t) {
617
+ let t;
618
+ if (e.review = p.time(e.review), e.rating === f.Manual) {
619
+ let n = 0;
620
+ r.state !== d.New && r.last_review && (n = e.review.diff(r.last_review, "days")), t = this.handleManualRating(r, e.state, e.review, n, e.stability, e.difficulty, e.due ? p.time(e.due) : void 0);
621
+ } else t = this.replay(r, e.review, e.rating);
622
+ n.push(t), r = t.card;
623
+ }
624
+ return n;
625
+ }
626
+ calculateManualRecord(e, t, n, r) {
627
+ if (!n) return null;
628
+ let { card: i, log: a } = n, o = p.card(e);
629
+ return o.due.getTime() === i.due.getTime() ? null : (o.scheduled_days = i.due.diff(o.due, "days"), this.handleManualRating(o, i.state, p.time(t), a.elapsed_days, r ? i.stability : void 0, r ? i.difficulty : void 0, i.due));
630
+ }
631
+ }, Se = class extends ge {
632
+ strategyHandler = /* @__PURE__ */ new Map();
633
+ Scheduler;
634
+ constructor(e) {
635
+ super(e);
636
+ let { enable_short_term: t } = this.parameters;
637
+ this.Scheduler = t ? ye : be;
638
+ }
639
+ params_handler_proxy() {
640
+ let e = this;
641
+ return { set: function(t, n, r) {
642
+ return n === "request_retention" && Number.isFinite(r) ? e.intervalModifier = e.calculate_interval_modifier(Number(r)) : n === "enable_short_term" && (e.Scheduler = r === !0 ? ye : be), Reflect.set(t, n, r), !0;
643
+ } };
644
+ }
645
+ useStrategy(e, t) {
646
+ return this.strategyHandler.set(e, t), this;
647
+ }
648
+ clearStrategy(e) {
649
+ return e ? this.strategyHandler.delete(e) : this.strategyHandler.clear(), this;
650
+ }
651
+ getScheduler(e, t) {
652
+ let n = this.strategyHandler.get(S.SEED);
653
+ return new ((this.strategyHandler.get(S.SCHEDULER)) || this.Scheduler)(e, t, this, { seed: n || _e });
654
+ }
655
+ repeat(e, t, n) {
656
+ let r = this.getScheduler(e, t).preview();
657
+ return n && typeof n == "function" ? n(r) : r;
658
+ }
659
+ next(e, t, n, r) {
660
+ let i = this.getScheduler(e, t), a = p.rating(n);
661
+ if (a === f.Manual) throw Error("Cannot review a manual rating");
662
+ let o = i.review(a);
663
+ return r && typeof r == "function" ? r(o) : o;
664
+ }
665
+ get_retrievability(e, t, n = !0) {
666
+ let r = p.card(e);
667
+ t = t ? p.time(t) : /* @__PURE__ */ new Date();
668
+ let i = r.state === d.New ? 0 : Math.max(t.diff(r.last_review, "days"), 0), a = r.state === d.New ? 0 : this.forgetting_curve(i, +r.stability.toFixed(8));
669
+ return n ? `${(a * 100).toFixed(2)}%` : a;
670
+ }
671
+ rollback(e, t, n) {
672
+ let r = p.card(e), i = p.review_log(t);
673
+ if (i.rating === f.Manual) throw Error("Cannot rollback a manual rating");
674
+ let a, o, s;
675
+ switch (i.state) {
676
+ case d.New:
677
+ a = i.due, o = void 0, s = 0;
678
+ break;
679
+ case d.Learning:
680
+ case d.Relearning:
681
+ case d.Review:
682
+ a = i.review, o = i.due, s = r.lapses - +(i.rating === f.Again && i.state === d.Review);
683
+ break;
684
+ }
685
+ let c = {
686
+ ...r,
687
+ due: a,
688
+ stability: i.stability,
689
+ difficulty: i.difficulty,
690
+ elapsed_days: i.last_elapsed_days,
691
+ scheduled_days: i.scheduled_days,
692
+ reps: Math.max(0, r.reps - 1),
693
+ lapses: Math.max(0, s),
694
+ state: i.state,
695
+ last_review: o
696
+ };
697
+ return n && typeof n == "function" ? n(c) : c;
698
+ }
699
+ forget(e, t, n = !1, r) {
700
+ let i = p.card(e);
701
+ t = p.time(t);
702
+ let a = i.state === d.New ? 0 : t.diff(i.last_review, "days"), o = {
703
+ rating: f.Manual,
704
+ state: i.state,
705
+ due: i.due,
706
+ stability: i.stability,
707
+ difficulty: i.difficulty,
708
+ elapsed_days: 0,
709
+ last_elapsed_days: i.elapsed_days,
710
+ scheduled_days: a,
711
+ review: t
712
+ }, s = {
713
+ card: {
714
+ ...i,
715
+ due: t,
716
+ stability: 0,
717
+ difficulty: 0,
718
+ elapsed_days: 0,
719
+ scheduled_days: 0,
720
+ reps: n ? 0 : i.reps,
721
+ lapses: n ? 0 : i.lapses,
722
+ state: d.New,
723
+ last_review: i.last_review
724
+ },
725
+ log: o
726
+ };
727
+ return r && typeof r == "function" ? r(s) : s;
728
+ }
729
+ reschedule(e, t = [], n = {}) {
730
+ let { recordLogHandler: r, reviewsOrderBy: i, skipManual: a = !0, now: o = /* @__PURE__ */ new Date(), update_memory_state: s = !1 } = n;
731
+ i && typeof i == "function" && t.sort(i), a && (t = t.filter((e) => e.rating !== f.Manual));
732
+ let c = new xe(this), l = c.reschedule(n.first_card || x(), t), u = l.length, d = p.card(e), m = c.calculateManualRecord(d, o, u ? l[u - 1] : void 0, s);
733
+ return r && typeof r == "function" ? {
734
+ collections: l.map(r),
735
+ reschedule_item: m ? r(m) : null
736
+ } : {
737
+ collections: l,
738
+ reschedule_item: m
739
+ };
740
+ }
741
+ }, Ce = ((e) => new Se(e || {}))(b({
742
+ request_retention: i,
743
+ enable_fuzz: !0,
744
+ maximum_interval: 100
745
+ })), we = (e) => e.due ? e : {
746
+ ...e,
747
+ due: /* @__PURE__ */ new Date()
748
+ }, Te = (e) => t.indexOf(e), Ee = (e) => ({
749
+ due: e.due,
750
+ stability: e.stability,
751
+ difficulty: e.difficulty,
752
+ elapsed_days: e.elapsedDays,
753
+ scheduled_days: e.scheduledDays,
754
+ reps: e.reps,
755
+ lapses: e.lapses,
756
+ state: Te(e.state),
757
+ last_review: e.lastReview
758
+ }), De = (e, t, n) => {
759
+ let r = /* @__PURE__ */ new Date(), i = Ee(we(e));
760
+ return Ce.repeat(i, r, (r) => {
761
+ let i = r[je(t)], a = C(i.card, e), o = i.log;
762
+ return {
763
+ nextCard: a,
764
+ reviewLog: {
765
+ id: 0,
766
+ cardReviewId: e.id,
767
+ grade: t,
768
+ state: Ae(o.state),
769
+ due: o.due,
770
+ stability: o.stability,
771
+ difficulty: o.difficulty,
772
+ elapsedDays: o.elapsed_days,
773
+ lastElapsedDays: o.last_elapsed_days,
774
+ scheduledDays: o.scheduled_days,
775
+ review: o.review,
776
+ duration: n
777
+ }
778
+ };
779
+ });
937
780
  };
938
- O.set = function(t, e, i) {
939
- return process.env.NODE_ENV !== "production" && e !== "length" && isNaN(parseInt(e)) && m(14), te.set.call(this, t[0], e, i, t[0]);
781
+ function Oe(e) {
782
+ let t = /* @__PURE__ */ new Date(), n = Ee(we(e)), i = Ce.repeat(n, t), a = Object.fromEntries(r.map((e) => [e, /* @__PURE__ */ new Date()]));
783
+ for (let e of ie) {
784
+ let t = i[e].card.due, n = ke(e);
785
+ a[n] = t;
786
+ }
787
+ return a;
788
+ }
789
+ function ke(e) {
790
+ return r[e];
791
+ }
792
+ function Ae(e) {
793
+ return t[e];
794
+ }
795
+ function C(e, t) {
796
+ return {
797
+ ...t,
798
+ due: e.due,
799
+ stability: e.stability,
800
+ difficulty: e.difficulty,
801
+ elapsedDays: e.elapsed_days,
802
+ scheduledDays: e.scheduled_days,
803
+ reps: e.reps,
804
+ lapses: e.lapses,
805
+ state: Ae(e.state),
806
+ lastReview: e.last_review ?? null
807
+ };
808
+ }
809
+ function je(e) {
810
+ let t = r.indexOf(e);
811
+ if (t === -1) throw Error(`Invalid rating: ${e}`);
812
+ return t;
813
+ }
814
+ function Me(e, t) {
815
+ let r = x();
816
+ return {
817
+ id: "",
818
+ due: null,
819
+ stability: r.stability,
820
+ difficulty: r.difficulty,
821
+ elapsedDays: r.elapsed_days,
822
+ scheduledDays: r.scheduled_days,
823
+ reps: r.reps,
824
+ lapses: r.lapses,
825
+ state: n.New,
826
+ lastReview: r.last_review ?? null,
827
+ userDeckStudyId: e,
828
+ cardId: t
829
+ };
830
+ }
831
+ //#endregion
832
+ //#region src/spaced-repetition/retention.ts
833
+ function Ne(e, t) {
834
+ return t <= 0 ? 0 : (1 + o * e / t) ** -a;
835
+ }
836
+ function Pe(e, t) {
837
+ return Ne(e, t) * 100;
838
+ }
839
+ //#endregion
840
+ //#region ../../node_modules/immer/dist/immer.mjs
841
+ var Fe = Symbol.for("immer-nothing"), Ie = Symbol.for("immer-draftable"), w = Symbol.for("immer-state"), Le = process.env.NODE_ENV === "production" ? [] : [
842
+ function(e) {
843
+ return `The plugin for '${e}' has not been loaded into Immer. To enable the plugin, import and call \`enable${e}()\` when initializing your application.`;
844
+ },
845
+ function(e) {
846
+ return `produce can only be called on things that are draftable: plain objects, arrays, Map, Set or classes that are marked with '[immerable]: true'. Got '${e}'`;
847
+ },
848
+ "This object has been frozen and should not be mutated",
849
+ function(e) {
850
+ return "Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? " + e;
851
+ },
852
+ "An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.",
853
+ "Immer forbids circular references",
854
+ "The first or second argument to `produce` must be a function",
855
+ "The third argument to `produce` must be a function or undefined",
856
+ "First argument to `createDraft` must be a plain object, an array, or an immerable object",
857
+ "First argument to `finishDraft` must be a draft returned by `createDraft`",
858
+ function(e) {
859
+ return `'current' expects a draft, got: ${e}`;
860
+ },
861
+ "Object.defineProperty() cannot be used on an Immer draft",
862
+ "Object.setPrototypeOf() cannot be used on an Immer draft",
863
+ "Immer only supports deleting array indices",
864
+ "Immer only supports setting array indices and the 'length' property",
865
+ function(e) {
866
+ return `'original' expects a draft, got: ${e}`;
867
+ }
868
+ ];
869
+ function T(e, ...t) {
870
+ if (process.env.NODE_ENV !== "production") {
871
+ let n = Le[e], r = typeof n == "function" ? n.apply(null, t) : n;
872
+ throw Error(`[Immer] ${r}`);
873
+ }
874
+ throw Error(`[Immer] minified error nr: ${e}. Full error at: https://bit.ly/3cXEKWf`);
875
+ }
876
+ var E = Object.getPrototypeOf;
877
+ function D(e) {
878
+ return !!e && !!e[w];
879
+ }
880
+ function O(e) {
881
+ return e ? Be(e) || Array.isArray(e) || !!e[Ie] || !!e.constructor?.[Ie] || M(e) || N(e) : !1;
882
+ }
883
+ var Re = Object.prototype.constructor.toString(), ze = /* @__PURE__ */ new WeakMap();
884
+ function Be(e) {
885
+ if (!e || typeof e != "object") return !1;
886
+ let t = Object.getPrototypeOf(e);
887
+ if (t === null || t === Object.prototype) return !0;
888
+ let n = Object.hasOwnProperty.call(t, "constructor") && t.constructor;
889
+ if (n === Object) return !0;
890
+ if (typeof n != "function") return !1;
891
+ let r = ze.get(n);
892
+ return r === void 0 && (r = Function.toString.call(n), ze.set(n, r)), r === Re;
893
+ }
894
+ function k(e, t, n = !0) {
895
+ A(e) === 0 ? (n ? Reflect.ownKeys(e) : Object.keys(e)).forEach((n) => {
896
+ t(n, e[n], e);
897
+ }) : e.forEach((n, r) => t(r, n, e));
898
+ }
899
+ function A(e) {
900
+ let t = e[w];
901
+ return t ? t.type_ : Array.isArray(e) ? 1 : M(e) ? 2 : N(e) ? 3 : 0;
902
+ }
903
+ function j(e, t) {
904
+ return A(e) === 2 ? e.has(t) : Object.prototype.hasOwnProperty.call(e, t);
905
+ }
906
+ function Ve(e, t, n) {
907
+ let r = A(e);
908
+ r === 2 ? e.set(t, n) : r === 3 ? e.add(n) : e[t] = n;
909
+ }
910
+ function He(e, t) {
911
+ return e === t ? e !== 0 || 1 / e == 1 / t : e !== e && t !== t;
912
+ }
913
+ function M(e) {
914
+ return e instanceof Map;
915
+ }
916
+ function N(e) {
917
+ return e instanceof Set;
918
+ }
919
+ function P(e) {
920
+ return e.copy_ || e.base_;
921
+ }
922
+ function F(e, t) {
923
+ if (M(e)) return new Map(e);
924
+ if (N(e)) return new Set(e);
925
+ if (Array.isArray(e)) return Array.prototype.slice.call(e);
926
+ let n = Be(e);
927
+ if (t === !0 || t === "class_only" && !n) {
928
+ let t = Object.getOwnPropertyDescriptors(e);
929
+ delete t[w];
930
+ let n = Reflect.ownKeys(t);
931
+ for (let r = 0; r < n.length; r++) {
932
+ let i = n[r], a = t[i];
933
+ a.writable === !1 && (a.writable = !0, a.configurable = !0), (a.get || a.set) && (t[i] = {
934
+ configurable: !0,
935
+ writable: !0,
936
+ enumerable: a.enumerable,
937
+ value: e[i]
938
+ });
939
+ }
940
+ return Object.create(E(e), t);
941
+ } else {
942
+ let t = E(e);
943
+ return t !== null && n ? { ...e } : Object.assign(Object.create(t), e);
944
+ }
945
+ }
946
+ function I(e, t = !1) {
947
+ return R(e) || D(e) || !O(e) ? e : (A(e) > 1 && Object.defineProperties(e, {
948
+ set: L,
949
+ add: L,
950
+ clear: L,
951
+ delete: L
952
+ }), Object.freeze(e), t && Object.values(e).forEach((e) => I(e, !0)), e);
953
+ }
954
+ function Ue() {
955
+ T(2);
956
+ }
957
+ var L = { value: Ue };
958
+ function R(e) {
959
+ return typeof e != "object" || !e ? !0 : Object.isFrozen(e);
960
+ }
961
+ var We = {};
962
+ function z(e) {
963
+ let t = We[e];
964
+ return t || T(0, e), t;
965
+ }
966
+ var B;
967
+ function Ge() {
968
+ return B;
969
+ }
970
+ function Ke(e, t) {
971
+ return {
972
+ drafts_: [],
973
+ parent_: e,
974
+ immer_: t,
975
+ canAutoFreeze_: !0,
976
+ unfinalizedDrafts_: 0
977
+ };
978
+ }
979
+ function qe(e, t) {
980
+ t && (z("Patches"), e.patches_ = [], e.inversePatches_ = [], e.patchListener_ = t);
981
+ }
982
+ function V(e) {
983
+ H(e), e.drafts_.forEach(Ye), e.drafts_ = null;
984
+ }
985
+ function H(e) {
986
+ e === B && (B = e.parent_);
987
+ }
988
+ function Je(e) {
989
+ return B = Ke(B, e);
990
+ }
991
+ function Ye(e) {
992
+ let t = e[w];
993
+ t.type_ === 0 || t.type_ === 1 ? t.revoke_() : t.revoked_ = !0;
994
+ }
995
+ function Xe(e, t) {
996
+ t.unfinalizedDrafts_ = t.drafts_.length;
997
+ let n = t.drafts_[0];
998
+ return e !== void 0 && e !== n ? (n[w].modified_ && (V(t), T(4)), O(e) && (e = U(t, e), t.parent_ || W(t, e)), t.patches_ && z("Patches").generateReplacementPatches_(n[w].base_, e, t.patches_, t.inversePatches_)) : e = U(t, n, []), V(t), t.patches_ && t.patchListener_(t.patches_, t.inversePatches_), e === Fe ? void 0 : e;
999
+ }
1000
+ function U(e, t, n) {
1001
+ if (R(t)) return t;
1002
+ let r = e.immer_.shouldUseStrictIteration(), i = t[w];
1003
+ if (!i) return k(t, (r, a) => Ze(e, i, t, r, a, n), r), t;
1004
+ if (i.scope_ !== e) return t;
1005
+ if (!i.modified_) return W(e, i.base_, !0), i.base_;
1006
+ if (!i.finalized_) {
1007
+ i.finalized_ = !0, i.scope_.unfinalizedDrafts_--;
1008
+ let t = i.copy_, a = t, o = !1;
1009
+ i.type_ === 3 && (a = new Set(t), t.clear(), o = !0), k(a, (r, a) => Ze(e, i, t, r, a, n, o), r), W(e, t, !1), n && e.patches_ && z("Patches").generatePatches_(i, n, e.patches_, e.inversePatches_);
1010
+ }
1011
+ return i.copy_;
1012
+ }
1013
+ function Ze(e, t, n, r, i, a, o) {
1014
+ if (i == null || typeof i != "object" && !o) return;
1015
+ let s = R(i);
1016
+ if (!(s && !o)) {
1017
+ if (process.env.NODE_ENV !== "production" && i === n && T(5), D(i)) {
1018
+ let o = U(e, i, a && t && t.type_ !== 3 && !j(t.assigned_, r) ? a.concat(r) : void 0);
1019
+ if (Ve(n, r, o), D(o)) e.canAutoFreeze_ = !1;
1020
+ else return;
1021
+ } else o && n.add(i);
1022
+ if (O(i) && !s) {
1023
+ if (!e.immer_.autoFreeze_ && e.unfinalizedDrafts_ < 1 || t && t.base_ && t.base_[r] === i && s) return;
1024
+ U(e, i), (!t || !t.scope_.parent_) && typeof r != "symbol" && (M(n) ? n.has(r) : Object.prototype.propertyIsEnumerable.call(n, r)) && W(e, i);
1025
+ }
1026
+ }
1027
+ }
1028
+ function W(e, t, n = !1) {
1029
+ !e.parent_ && e.immer_.autoFreeze_ && e.canAutoFreeze_ && I(t, n);
1030
+ }
1031
+ function Qe(e, t) {
1032
+ let n = Array.isArray(e), r = {
1033
+ type_: +!!n,
1034
+ scope_: t ? t.scope_ : Ge(),
1035
+ modified_: !1,
1036
+ finalized_: !1,
1037
+ assigned_: {},
1038
+ parent_: t,
1039
+ base_: e,
1040
+ draft_: null,
1041
+ copy_: null,
1042
+ revoke_: null,
1043
+ isManual_: !1
1044
+ }, i = r, a = G;
1045
+ n && (i = [r], a = K);
1046
+ let { revoke: o, proxy: s } = Proxy.revocable(i, a);
1047
+ return r.draft_ = s, r.revoke_ = o, s;
1048
+ }
1049
+ var G = {
1050
+ get(e, t) {
1051
+ if (t === w) return e;
1052
+ let n = P(e);
1053
+ if (!j(n, t)) return $e(e, n, t);
1054
+ let r = n[t];
1055
+ return e.finalized_ || !O(r) ? r : r === q(e.base_, t) ? (Y(e), e.copy_[t] = X(r, e)) : r;
1056
+ },
1057
+ has(e, t) {
1058
+ return t in P(e);
1059
+ },
1060
+ ownKeys(e) {
1061
+ return Reflect.ownKeys(P(e));
1062
+ },
1063
+ set(e, t, n) {
1064
+ let r = et(P(e), t);
1065
+ if (r?.set) return r.set.call(e.draft_, n), !0;
1066
+ if (!e.modified_) {
1067
+ let r = q(P(e), t), i = r?.[w];
1068
+ if (i && i.base_ === n) return e.copy_[t] = n, e.assigned_[t] = !1, !0;
1069
+ if (He(n, r) && (n !== void 0 || j(e.base_, t))) return !0;
1070
+ Y(e), J(e);
1071
+ }
1072
+ return e.copy_[t] === n && (n !== void 0 || t in e.copy_) || Number.isNaN(n) && Number.isNaN(e.copy_[t]) ? !0 : (e.copy_[t] = n, e.assigned_[t] = !0, !0);
1073
+ },
1074
+ deleteProperty(e, t) {
1075
+ return q(e.base_, t) !== void 0 || t in e.base_ ? (e.assigned_[t] = !1, Y(e), J(e)) : delete e.assigned_[t], e.copy_ && delete e.copy_[t], !0;
1076
+ },
1077
+ getOwnPropertyDescriptor(e, t) {
1078
+ let n = P(e), r = Reflect.getOwnPropertyDescriptor(n, t);
1079
+ return r && {
1080
+ writable: !0,
1081
+ configurable: e.type_ !== 1 || t !== "length",
1082
+ enumerable: r.enumerable,
1083
+ value: n[t]
1084
+ };
1085
+ },
1086
+ defineProperty() {
1087
+ T(11);
1088
+ },
1089
+ getPrototypeOf(e) {
1090
+ return E(e.base_);
1091
+ },
1092
+ setPrototypeOf() {
1093
+ T(12);
1094
+ }
1095
+ }, K = {};
1096
+ k(G, (e, t) => {
1097
+ K[e] = function() {
1098
+ return arguments[0] = arguments[0][0], t.apply(this, arguments);
1099
+ };
1100
+ }), K.deleteProperty = function(e, t) {
1101
+ return process.env.NODE_ENV !== "production" && isNaN(parseInt(t)) && T(13), K.set.call(this, e, t, void 0);
1102
+ }, K.set = function(e, t, n) {
1103
+ return process.env.NODE_ENV !== "production" && t !== "length" && isNaN(parseInt(t)) && T(14), G.set.call(this, e[0], t, n, e[0]);
940
1104
  };
941
- function U(t, e) {
942
- const i = t[w];
943
- return (i ? v(i) : t)[e];
944
- }
945
- function yt(t, e, i) {
946
- var s;
947
- const r = Re(e, i);
948
- return r ? "value" in r ? r.value : (
949
- // This is a very special case, if the prop is a getter defined by the
950
- // prototype, we should invoke it with the draft as context!
951
- (s = r.get) == null ? void 0 : s.call(t.draft_)
952
- ) : void 0;
953
- }
954
- function Re(t, e) {
955
- if (!(e in t))
956
- return;
957
- let i = C(t);
958
- for (; i; ) {
959
- const r = Object.getOwnPropertyDescriptor(i, e);
960
- if (r)
961
- return r;
962
- i = C(i);
963
- }
964
- }
965
- function J(t) {
966
- t.modified_ || (t.modified_ = !0, t.parent_ && J(t.parent_));
967
- }
968
- function q(t) {
969
- t.copy_ || (t.copy_ = B(
970
- t.base_,
971
- t.scope_.immer_.useStrictShallowCopy_
972
- ));
973
- }
974
- var mt = class {
975
- constructor(t) {
976
- this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !0, this.produce = (e, i, r) => {
977
- if (typeof e == "function" && typeof i != "function") {
978
- const n = i;
979
- i = e;
980
- const a = this;
981
- return function(c = n, ...u) {
982
- return a.produce(c, (f) => i.call(this, f, ...u));
983
- };
984
- }
985
- typeof i != "function" && m(6), r !== void 0 && typeof r != "function" && m(7);
986
- let s;
987
- if (x(e)) {
988
- const n = le(this), a = Q(e, void 0);
989
- let o = !0;
990
- try {
991
- s = i(a), o = !1;
992
- } finally {
993
- o ? X(n) : Z(n);
994
- }
995
- return oe(n, r), ce(s, n);
996
- } else if (!e || typeof e != "object") {
997
- if (s = i(e), s === void 0 && (s = e), s === xe && (s = void 0), this.autoFreeze_ && ee(s, !0), r) {
998
- const n = [], a = [];
999
- M("Patches").generateReplacementPatches_(e, s, n, a), r(n, a);
1000
- }
1001
- return s;
1002
- } else
1003
- m(1, e);
1004
- }, this.produceWithPatches = (e, i) => {
1005
- if (typeof e == "function")
1006
- return (a, ...o) => this.produceWithPatches(a, (c) => e(c, ...o));
1007
- let r, s;
1008
- return [this.produce(e, i, (a, o) => {
1009
- r = a, s = o;
1010
- }), r, s];
1011
- }, typeof (t == null ? void 0 : t.autoFreeze) == "boolean" && this.setAutoFreeze(t.autoFreeze), typeof (t == null ? void 0 : t.useStrictShallowCopy) == "boolean" && this.setUseStrictShallowCopy(t.useStrictShallowCopy), typeof (t == null ? void 0 : t.useStrictIteration) == "boolean" && this.setUseStrictIteration(t.useStrictIteration);
1012
- }
1013
- createDraft(t) {
1014
- x(t) || m(8), S(t) && (t = wt(t));
1015
- const e = le(this), i = Q(t, void 0);
1016
- return i[w].isManual_ = !0, Z(e), i;
1017
- }
1018
- finishDraft(t, e) {
1019
- const i = t && t[w];
1020
- (!i || !i.isManual_) && m(9);
1021
- const { scope_: r } = i;
1022
- return oe(r, e), ce(void 0, r);
1023
- }
1024
- /**
1025
- * Pass true to automatically freeze all copies created by Immer.
1026
- *
1027
- * By default, auto-freezing is enabled.
1028
- */
1029
- setAutoFreeze(t) {
1030
- this.autoFreeze_ = t;
1031
- }
1032
- /**
1033
- * Pass true to enable strict shallow copy.
1034
- *
1035
- * By default, immer does not copy the object descriptors such as getter, setter and non-enumrable properties.
1036
- */
1037
- setUseStrictShallowCopy(t) {
1038
- this.useStrictShallowCopy_ = t;
1039
- }
1040
- /**
1041
- * Pass false to use faster iteration that skips non-enumerable properties
1042
- * but still handles symbols for compatibility.
1043
- *
1044
- * By default, strict iteration is enabled (includes all own properties).
1045
- */
1046
- setUseStrictIteration(t) {
1047
- this.useStrictIteration_ = t;
1048
- }
1049
- shouldUseStrictIteration() {
1050
- return this.useStrictIteration_;
1051
- }
1052
- applyPatches(t, e) {
1053
- let i;
1054
- for (i = e.length - 1; i >= 0; i--) {
1055
- const s = e[i];
1056
- if (s.path.length === 0 && s.op === "replace") {
1057
- t = s.value;
1058
- break;
1059
- }
1060
- }
1061
- i > -1 && (e = e.slice(i + 1));
1062
- const r = M("Patches").applyPatches_;
1063
- return S(t) ? r(t, e) : this.produce(
1064
- t,
1065
- (s) => r(s, e)
1066
- );
1067
- }
1105
+ function q(e, t) {
1106
+ let n = e[w];
1107
+ return (n ? P(n) : e)[t];
1108
+ }
1109
+ function $e(e, t, n) {
1110
+ let r = et(t, n);
1111
+ return r ? "value" in r ? r.value : r.get?.call(e.draft_) : void 0;
1112
+ }
1113
+ function et(e, t) {
1114
+ if (!(t in e)) return;
1115
+ let n = E(e);
1116
+ for (; n;) {
1117
+ let e = Object.getOwnPropertyDescriptor(n, t);
1118
+ if (e) return e;
1119
+ n = E(n);
1120
+ }
1121
+ }
1122
+ function J(e) {
1123
+ e.modified_ || (e.modified_ = !0, e.parent_ && J(e.parent_));
1124
+ }
1125
+ function Y(e) {
1126
+ e.copy_ ||= F(e.base_, e.scope_.immer_.useStrictShallowCopy_);
1127
+ }
1128
+ var tt = class {
1129
+ constructor(e) {
1130
+ this.autoFreeze_ = !0, this.useStrictShallowCopy_ = !1, this.useStrictIteration_ = !0, this.produce = (e, t, n) => {
1131
+ if (typeof e == "function" && typeof t != "function") {
1132
+ let n = t;
1133
+ t = e;
1134
+ let r = this;
1135
+ return function(e = n, ...i) {
1136
+ return r.produce(e, (e) => t.call(this, e, ...i));
1137
+ };
1138
+ }
1139
+ typeof t != "function" && T(6), n !== void 0 && typeof n != "function" && T(7);
1140
+ let r;
1141
+ if (O(e)) {
1142
+ let i = Je(this), a = X(e, void 0), o = !0;
1143
+ try {
1144
+ r = t(a), o = !1;
1145
+ } finally {
1146
+ o ? V(i) : H(i);
1147
+ }
1148
+ return qe(i, n), Xe(r, i);
1149
+ } else if (!e || typeof e != "object") {
1150
+ if (r = t(e), r === void 0 && (r = e), r === Fe && (r = void 0), this.autoFreeze_ && I(r, !0), n) {
1151
+ let t = [], i = [];
1152
+ z("Patches").generateReplacementPatches_(e, r, t, i), n(t, i);
1153
+ }
1154
+ return r;
1155
+ } else T(1, e);
1156
+ }, this.produceWithPatches = (e, t) => {
1157
+ if (typeof e == "function") return (t, ...n) => this.produceWithPatches(t, (t) => e(t, ...n));
1158
+ let n, r;
1159
+ return [
1160
+ this.produce(e, t, (e, t) => {
1161
+ n = e, r = t;
1162
+ }),
1163
+ n,
1164
+ r
1165
+ ];
1166
+ }, typeof e?.autoFreeze == "boolean" && this.setAutoFreeze(e.autoFreeze), typeof e?.useStrictShallowCopy == "boolean" && this.setUseStrictShallowCopy(e.useStrictShallowCopy), typeof e?.useStrictIteration == "boolean" && this.setUseStrictIteration(e.useStrictIteration);
1167
+ }
1168
+ createDraft(e) {
1169
+ O(e) || T(8), D(e) && (e = nt(e));
1170
+ let t = Je(this), n = X(e, void 0);
1171
+ return n[w].isManual_ = !0, H(t), n;
1172
+ }
1173
+ finishDraft(e, t) {
1174
+ let n = e && e[w];
1175
+ (!n || !n.isManual_) && T(9);
1176
+ let { scope_: r } = n;
1177
+ return qe(r, t), Xe(void 0, r);
1178
+ }
1179
+ setAutoFreeze(e) {
1180
+ this.autoFreeze_ = e;
1181
+ }
1182
+ setUseStrictShallowCopy(e) {
1183
+ this.useStrictShallowCopy_ = e;
1184
+ }
1185
+ setUseStrictIteration(e) {
1186
+ this.useStrictIteration_ = e;
1187
+ }
1188
+ shouldUseStrictIteration() {
1189
+ return this.useStrictIteration_;
1190
+ }
1191
+ applyPatches(e, t) {
1192
+ let n;
1193
+ for (n = t.length - 1; n >= 0; n--) {
1194
+ let r = t[n];
1195
+ if (r.path.length === 0 && r.op === "replace") {
1196
+ e = r.value;
1197
+ break;
1198
+ }
1199
+ }
1200
+ n > -1 && (t = t.slice(n + 1));
1201
+ let r = z("Patches").applyPatches_;
1202
+ return D(e) ? r(e, t) : this.produce(e, (e) => r(e, t));
1203
+ }
1068
1204
  };
1069
- function Q(t, e) {
1070
- const i = F(t) ? M("MapSet").proxyMap_(t, e) : H(t) ? M("MapSet").proxySet_(t, e) : _t(t, e);
1071
- return (e ? e.scope_ : Ee()).drafts_.push(i), i;
1072
- }
1073
- function wt(t) {
1074
- return S(t) || m(10, t), De(t);
1075
- }
1076
- function De(t) {
1077
- if (!x(t) || $(t))
1078
- return t;
1079
- const e = t[w];
1080
- let i, r = !0;
1081
- if (e) {
1082
- if (!e.modified_)
1083
- return e.base_;
1084
- e.finalized_ = !0, i = B(t, e.scope_.immer_.useStrictShallowCopy_), r = e.scope_.immer_.shouldUseStrictIteration();
1085
- } else
1086
- i = B(t, !0);
1087
- return A(
1088
- i,
1089
- (s, n) => {
1090
- Se(i, s, De(n));
1091
- },
1092
- r
1093
- ), e && (e.finalized_ = !1), i;
1094
- }
1095
- var pt = new mt(), gt = pt.produce;
1096
- function vt(t, e) {
1097
- const i = t + e;
1098
- let r = 0;
1099
- for (let s = 0; s < i.length; s++) {
1100
- const n = i.charCodeAt(s);
1101
- r = (r << 5) - r + n, r |= 0;
1102
- }
1103
- return r;
1104
- }
1105
- function bt(t, e) {
1106
- return (vt(t, e) >>> 0) / 4294967295;
1107
- }
1108
- function kt(t, e = /* @__PURE__ */ new Set()) {
1109
- if (t.reviewCards.length === 0 && t.newCards.length === 0)
1110
- return;
1111
- if (t.reviewCards.length === 0)
1112
- return t.newCards[0];
1113
- if (t.newCards.length === 0)
1114
- return t.reviewCards[0];
1115
- const i = de(t.newCards, e), r = de(t.reviewCards, e);
1116
- if (!i) return r ?? t.newCards[0];
1117
- if (!r) return i ?? t.reviewCards[0];
1118
- const s = t.newCards.length, n = t.reviewCards.length, a = s + n, o = 0.33, c = s / a, u = (o + c) / 2;
1119
- return bt(i.card.id, r.card.id) < u ? i : r;
1120
- }
1121
- function de(t, e) {
1122
- return t.find((i) => !e.has(i.card.id));
1123
- }
1124
- function jt(t, e, i) {
1125
- const r = St(e, i);
1126
- if (!r)
1127
- return e;
1128
- const { nextCard: s } = rt(r.cardReview, t, 30), n = s.due && Ie(s.due, /* @__PURE__ */ new Date());
1129
- return gt(e, (a) => {
1130
- if (xt(a, r), n) {
1131
- const o = {
1132
- ...r,
1133
- cardReview: s
1134
- };
1135
- Mt(a, o);
1136
- }
1137
- });
1138
- }
1139
- function xt(t, e) {
1140
- e.cardReview.state === "New" ? t.newCards = t.newCards.filter((i) => i.card.id !== e.card.id) : t.reviewCards = t.reviewCards.filter((i) => i.card.id !== e.card.id), Ce(t, e.cardReview.state, "decrease");
1141
- }
1142
- function Mt(t, e) {
1143
- if (e.cardReview.state === "New") {
1144
- const i = t.newCards.findIndex(
1145
- (r) => r.cardReview.due && e.cardReview.due && r.cardReview.due >= e.cardReview.due || r.cardReview.difficulty >= e.cardReview.difficulty
1146
- );
1147
- i === -1 ? t.newCards.push(e) : t.newCards.splice(i, 0, e);
1148
- } else {
1149
- const i = Et(t, t.reviewCards);
1150
- t.reviewCards.splice(i, 0, e);
1151
- }
1152
- Ce(t, e.cardReview.state, "increase");
1153
- }
1154
- function Ce(t, e, i) {
1155
- const r = i === "increase" ? 1 : -1;
1156
- switch (e) {
1157
- case "New":
1158
- t.stats.new += r;
1159
- break;
1160
- case "Learning":
1161
- case "Relearning":
1162
- t.stats.learning += r;
1163
- break;
1164
- case "Review":
1165
- t.stats.review += r;
1166
- break;
1167
- default:
1168
- t.stats.new += r;
1169
- break;
1170
- }
1171
- t.stats.total += r;
1172
- }
1173
- function St(t, e) {
1174
- return t.newCards.find((i) => i.card.id === e) ?? t.reviewCards.find((i) => i.card.id === e);
1175
- }
1176
- function Et(t, e) {
1177
- if (e.length === 0)
1178
- return 0;
1179
- const i = Math.max(4, Math.floor(e.length / 3));
1180
- return Math.min(i, e.length);
1181
- }
1182
- export {
1183
- Pe as FSRS_RETENTION,
1184
- Ft as MAX_CARDS_TO_FETCH,
1185
- Nt as MAX_LEARN_PER_DAY,
1186
- It as MAX_NEW_PER_DECK_DAY,
1187
- Pt as THRESHOLD_CARDS_FOR_REFETCH,
1188
- kt as getNextCardFromSession,
1189
- At as getReviewDateForEachRating,
1190
- St as getSessionCard,
1191
- rt as gradeCard,
1192
- nt as mergeFsrsCard,
1193
- Tt as newCardReview,
1194
- jt as removeCardFromSessionData
1205
+ function X(e, t) {
1206
+ let n = M(e) ? z("MapSet").proxyMap_(e, t) : N(e) ? z("MapSet").proxySet_(e, t) : Qe(e, t);
1207
+ return (t ? t.scope_ : Ge()).drafts_.push(n), n;
1208
+ }
1209
+ function nt(e) {
1210
+ return D(e) || T(10, e), rt(e);
1211
+ }
1212
+ function rt(e) {
1213
+ if (!O(e) || R(e)) return e;
1214
+ let t = e[w], n, r = !0;
1215
+ if (t) {
1216
+ if (!t.modified_) return t.base_;
1217
+ t.finalized_ = !0, n = F(e, t.scope_.immer_.useStrictShallowCopy_), r = t.scope_.immer_.shouldUseStrictIteration();
1218
+ } else n = F(e, !0);
1219
+ return k(n, (e, t) => {
1220
+ Ve(n, e, rt(t));
1221
+ }, r), t && (t.finalized_ = !1), n;
1222
+ }
1223
+ var Z = new tt().produce;
1224
+ //#endregion
1225
+ //#region src/spaced-repetition/utils.ts
1226
+ function it(e, t) {
1227
+ let n = e + t, r = 0;
1228
+ for (let e = 0; e < n.length; e++) {
1229
+ let t = n.charCodeAt(e);
1230
+ r = (r << 5) - r + t, r |= 0;
1231
+ }
1232
+ return r;
1233
+ }
1234
+ function at(e, t) {
1235
+ return (it(e, t) >>> 0) / 4294967295;
1236
+ }
1237
+ function ot(e, t = /* @__PURE__ */ new Set()) {
1238
+ if (e.reviewCards.length === 0 && e.newCards.length === 0) return;
1239
+ if (e.reviewCards.length === 0) return Q(e.newCards, t) ?? e.newCards[0];
1240
+ if (e.newCards.length === 0) return Q(e.reviewCards, t) ?? e.reviewCards[0];
1241
+ let n = Q(e.newCards, t), r = Q(e.reviewCards, t);
1242
+ if (!n) return r ?? e.newCards[0];
1243
+ if (!r) return n ?? e.reviewCards[0];
1244
+ let i = e.newCards.length, a = (.33 + i / (i + e.reviewCards.length)) / 2;
1245
+ return at(n.card.id, r.card.id) < a ? n : r;
1246
+ }
1247
+ function Q(e, t) {
1248
+ return e.find((e) => !t.has(e.card.id));
1249
+ }
1250
+ function st(e, t) {
1251
+ let n = $(e, t);
1252
+ return n ? Z(e, (e) => {
1253
+ lt(e, n);
1254
+ }) : e;
1255
+ }
1256
+ function ct(t, n, r) {
1257
+ let i = $(n, r);
1258
+ if (!i) return n;
1259
+ let { nextCard: a } = De(i.cardReview, t, 30), o = a.due && (0, e.isSameDay)(a.due, /* @__PURE__ */ new Date());
1260
+ return Z(n, (e) => {
1261
+ lt(e, i), o && ut(e, {
1262
+ ...i,
1263
+ cardReview: a
1264
+ });
1265
+ });
1266
+ }
1267
+ function lt(e, t) {
1268
+ t.cardReview.state === "New" ? e.newCards = e.newCards.filter((e) => e.card.id !== t.card.id) : e.reviewCards = e.reviewCards.filter((e) => e.card.id !== t.card.id), dt(e, t.cardReview.state, "decrease");
1269
+ }
1270
+ function ut(e, t) {
1271
+ if (t.cardReview.state === "New") {
1272
+ let n = e.newCards.findIndex((e) => e.cardReview.due && t.cardReview.due && e.cardReview.due >= t.cardReview.due || e.cardReview.difficulty >= t.cardReview.difficulty);
1273
+ n === -1 ? e.newCards.push(t) : e.newCards.splice(n, 0, t);
1274
+ } else {
1275
+ let n = ft(e, e.reviewCards);
1276
+ e.reviewCards.splice(n, 0, t);
1277
+ }
1278
+ dt(e, t.cardReview.state, "increase");
1279
+ }
1280
+ function dt(e, t, n) {
1281
+ let r = n === "increase" ? 1 : -1;
1282
+ switch (t) {
1283
+ case "New":
1284
+ e.stats.new += r;
1285
+ break;
1286
+ case "Learning":
1287
+ case "Relearning":
1288
+ e.stats.learning += r;
1289
+ break;
1290
+ case "Review":
1291
+ e.stats.review += r;
1292
+ break;
1293
+ default:
1294
+ e.stats.new += r;
1295
+ break;
1296
+ }
1297
+ e.stats.total += r;
1298
+ }
1299
+ function $(e, t) {
1300
+ return e.newCards.find((e) => e.card.id === t) ?? e.reviewCards.find((e) => e.card.id === t);
1301
+ }
1302
+ function ft(e, t) {
1303
+ if (t.length === 0) return 0;
1304
+ let n = Math.max(4, Math.floor(t.length / 3));
1305
+ return Math.min(n, t.length);
1306
+ }
1307
+ //#endregion
1308
+ //#region src/spaced-repetition/session-manager.ts
1309
+ var pt = 5, mt = {
1310
+ newCards: [],
1311
+ reviewCards: [],
1312
+ stats: {
1313
+ new: 0,
1314
+ learning: 0,
1315
+ review: 0,
1316
+ total: 0
1317
+ }
1318
+ }, ht = class {
1319
+ recentlyReviewed = /* @__PURE__ */ new Set();
1320
+ _reviewsCompleted = 0;
1321
+ _correctGrades = 0;
1322
+ getProgress() {
1323
+ return {
1324
+ reviewsCompleted: this._reviewsCompleted,
1325
+ correctGrades: this._correctGrades
1326
+ };
1327
+ }
1328
+ nextCard(e) {
1329
+ return ot(e, this.recentlyReviewed);
1330
+ }
1331
+ onRate(e, t) {
1332
+ return this.recentlyReviewed.add(e), this.recentlyReviewed.size > 5 && this.recentlyReviewed.delete(this.recentlyReviewed.values().next().value), this._reviewsCompleted++, (t === "Good" || t === "Easy") && this._correctGrades++, this.getProgress();
1333
+ }
1195
1334
  };
1335
+ //#endregion
1336
+ export { i as FSRS_RETENTION, o as FSRS_RETENTION_FACTOR, a as FSRS_RETRIEVABILITY_DECAY, ht as FlashcardSessionManager, c as LEARNING_SETTINGS_LIMITS, s as MAX_CARDS_TO_FETCH, pt as RECENTLY_REVIEWED_SET_SIZE, l as THRESHOLD_CARDS_FOR_REFETCH, Pe as calculateRetentionPercentage, Ne as calculateRetrievability, mt as defaultSessionData, ot as getNextCardFromSession, Oe as getReviewDateForEachRating, $ as getSessionCard, De as gradeCard, u as isRecommendedLearningSettings, C as mergeFsrsCard, Me as newCardReview, ct as removeCardFromSessionData, st as skipCardFromSessionData };