@vestcards/shared 0.5.1 → 1.0.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.
- package/dist/fsrs-C8QUsZ5l.js +10 -0
- package/dist/fsrs-HJutnIWm.cjs +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +88 -32
- package/dist/index.js +10 -5
- package/dist/spaced-repetition.cjs +1 -0
- package/dist/spaced-repetition.d.ts +133 -0
- package/dist/spaced-repetition.js +1195 -0
- package/package.json +4 -2
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
var n = /* @__PURE__ */ ((a) => (a.New = "New", a.Learning = "Learning", a.Review = "Review", a.Relearning = "Relearning", a))(n || {});
|
|
2
|
+
const s = ["New", "Learning", "Review", "Relearning"];
|
|
3
|
+
var r = /* @__PURE__ */ ((a) => (a.Manual = "Manual", a.Again = "Again", a.Hard = "Hard", a.Good = "Good", a.Easy = "Easy", a))(r || {});
|
|
4
|
+
const e = ["Manual", "Again", "Hard", "Good", "Easy"];
|
|
5
|
+
export {
|
|
6
|
+
r as R,
|
|
7
|
+
n as a,
|
|
8
|
+
s as b,
|
|
9
|
+
e as r
|
|
10
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var n=(a=>(a.New="New",a.Learning="Learning",a.Review="Review",a.Relearning="Relearning",a))(n||{});const e=["New","Learning","Review","Relearning"];var r=(a=>(a.Manual="Manual",a.Again="Again",a.Hard="Hard",a.Good="Good",a.Easy="Easy",a))(r||{});const i=["Manual","Again","Hard","Good","Easy"];exports.ReviewRating=r;exports.ReviewState=n;exports.reviewRatings=i;exports.reviewStates=e;
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("./fsrs-HJutnIWm.cjs"),s=["not-reviewed","card-updated","demand-rejected","card-removed"];var i=(e=>(e.Draft="draft",e.Review="to_review",e.Published="published",e.Archived="archived",e))(i||{});const u=["matemática","geografia","física","biologia","história","literatura","gramática","sociologia","química","filosofia","redação","artes","inglês"],r={história:"quaternary",geografia:"tertiary",matemática:"secondary",biologia:"primary",física:"quinary",gramática:"tertiary",literatura:"secondary",química:"primary",filosofia:"quaternary",sociologia:"quinary",redação:"secondary",artes:"tertiary",inglês:"quinary",default:"default"},t={matemática:"radical",gramática:"spell-check",literatura:"book-open",biologia:"dna",química:"test-tube-diagonal",física:"atom",história:"scroll",geografia:"earth",filosofia:"brain",sociologia:"users-round",redação:"notebook-pen",artes:"palette",inglês:"languages",default:"graduation-cap"},l=e=>t[e]||t.default,g=e=>r[e]||r.default;var o=(e=>(e.Admin="admin",e.Moderator="moderator",e.User="user",e))(o||{}),n=(e=>(e.Owner="owner",e.Admin="admin",e.Member="member",e))(n||{}),c=(e=>(e.Premium="premium",e))(c||{}),d=(e=>(e.Active="active",e.Canceled="canceled",e.Pending="pending",e.Expired="expired",e))(d||{});exports.ReviewRating=a.ReviewRating;exports.ReviewState=a.ReviewState;exports.reviewRatings=a.reviewRatings;exports.reviewStates=a.reviewStates;exports.DeckStatus=i;exports.Entitlement=c;exports.MembershipStatus=d;exports.OrganizationRole=n;exports.SUBJECTS=u;exports.SUBJECT_COLORS=r;exports.SUBJECT_ICONS=t;exports.UserRole=o;exports.cardDemandStatus=s;exports.getSubjectColor=g;exports.getSubjectIcon=l;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,19 +1,9 @@
|
|
|
1
|
-
export declare interface ArchivedLibraryItem {
|
|
2
|
-
deckId: string;
|
|
3
|
-
subject: string;
|
|
4
|
-
topic: string;
|
|
5
|
-
title: string;
|
|
6
|
-
ownerId?: string;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
1
|
export declare type BillingType = 'PIX' | 'CREDIT_CARD' | 'BOLETO';
|
|
10
2
|
|
|
11
3
|
export declare type CardDemandStatus = (typeof cardDemandStatus)[number];
|
|
12
4
|
|
|
13
5
|
export declare const cardDemandStatus: readonly ["not-reviewed", "card-updated", "demand-rejected", "card-removed"];
|
|
14
6
|
|
|
15
|
-
export declare type CardState = 'New' | 'Learning' | 'Review' | 'Relearning';
|
|
16
|
-
|
|
17
7
|
export declare enum DeckStatus {
|
|
18
8
|
Draft = "draft",
|
|
19
9
|
Review = "to_review",
|
|
@@ -31,22 +21,12 @@ export declare const getSubjectColor: (subject: string) => SemanticColor;
|
|
|
31
21
|
|
|
32
22
|
export declare const getSubjectIcon: (subject: string) => string;
|
|
33
23
|
|
|
34
|
-
export declare interface
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export declare type GroupedLibraryData = GroupedLibraryItem[];
|
|
42
|
-
|
|
43
|
-
export declare interface GroupedLibraryItem {
|
|
44
|
-
name: string;
|
|
45
|
-
id: string;
|
|
24
|
+
export declare interface IArchivedLibraryItem {
|
|
25
|
+
deckId: string;
|
|
26
|
+
subject: string;
|
|
27
|
+
topic: string;
|
|
28
|
+
title: string;
|
|
46
29
|
ownerId?: string;
|
|
47
|
-
type: StudyType;
|
|
48
|
-
stats: SessionStats;
|
|
49
|
-
subRows?: GroupedLibraryItem[];
|
|
50
30
|
}
|
|
51
31
|
|
|
52
32
|
export declare interface ICard {
|
|
@@ -63,6 +43,21 @@ export declare interface ICard {
|
|
|
63
43
|
};
|
|
64
44
|
}
|
|
65
45
|
|
|
46
|
+
export declare interface ICardReview {
|
|
47
|
+
id: string;
|
|
48
|
+
due: Date | null;
|
|
49
|
+
stability: number;
|
|
50
|
+
difficulty: number;
|
|
51
|
+
elapsedDays: number;
|
|
52
|
+
scheduledDays: number;
|
|
53
|
+
reps: number;
|
|
54
|
+
lapses: number;
|
|
55
|
+
state: ReviewState;
|
|
56
|
+
lastReview: Date | null;
|
|
57
|
+
userDeckStudyId: string;
|
|
58
|
+
cardId: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
66
61
|
export declare interface IDeck {
|
|
67
62
|
id: string;
|
|
68
63
|
title: string;
|
|
@@ -86,6 +81,17 @@ export declare interface IDeckDetail extends IDeck {
|
|
|
86
81
|
cards: ICard[];
|
|
87
82
|
}
|
|
88
83
|
|
|
84
|
+
export declare type IGroupedLibraryData = IGroupedLibraryItem[];
|
|
85
|
+
|
|
86
|
+
export declare interface IGroupedLibraryItem {
|
|
87
|
+
name: string;
|
|
88
|
+
id: string;
|
|
89
|
+
ownerId?: string;
|
|
90
|
+
type: StudyType;
|
|
91
|
+
stats: IStudyStats;
|
|
92
|
+
subRows?: IGroupedLibraryItem[];
|
|
93
|
+
}
|
|
94
|
+
|
|
89
95
|
export declare interface IOwnerInfo {
|
|
90
96
|
type: EntityType;
|
|
91
97
|
id: string;
|
|
@@ -93,6 +99,42 @@ export declare interface IOwnerInfo {
|
|
|
93
99
|
image: string | null;
|
|
94
100
|
}
|
|
95
101
|
|
|
102
|
+
export declare interface IReviewLog {
|
|
103
|
+
id: number;
|
|
104
|
+
cardReviewId: string;
|
|
105
|
+
grade: ReviewRating;
|
|
106
|
+
state: ReviewState;
|
|
107
|
+
due: Date;
|
|
108
|
+
stability: number;
|
|
109
|
+
difficulty: number;
|
|
110
|
+
elapsedDays: number;
|
|
111
|
+
lastElapsedDays: number;
|
|
112
|
+
scheduledDays: number;
|
|
113
|
+
review: Date;
|
|
114
|
+
duration: number;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export declare interface ISessionCard {
|
|
118
|
+
card: ICard;
|
|
119
|
+
cardReview: ICardReview;
|
|
120
|
+
subject: Subject;
|
|
121
|
+
topicName: string;
|
|
122
|
+
userDeckStudyId: string;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export declare interface ISessionData {
|
|
126
|
+
reviewCards: ISessionCard[];
|
|
127
|
+
newCards: ISessionCard[];
|
|
128
|
+
stats: IStudyStats;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export declare interface IStudyStats {
|
|
132
|
+
review: number;
|
|
133
|
+
learning: number;
|
|
134
|
+
new: number;
|
|
135
|
+
total: number;
|
|
136
|
+
}
|
|
137
|
+
|
|
96
138
|
export declare enum MembershipStatus {
|
|
97
139
|
Active = "active",
|
|
98
140
|
Canceled = "canceled",
|
|
@@ -108,17 +150,31 @@ export declare enum OrganizationRole {
|
|
|
108
150
|
|
|
109
151
|
export declare type OrganizationScopeRole = (typeof OrganizationRole)[keyof typeof OrganizationRole];
|
|
110
152
|
|
|
111
|
-
export declare
|
|
153
|
+
export declare enum ReviewRating {
|
|
154
|
+
Manual = "Manual",
|
|
155
|
+
Again = "Again",
|
|
156
|
+
Hard = "Hard",
|
|
157
|
+
Good = "Good",
|
|
158
|
+
Easy = "Easy"
|
|
159
|
+
}
|
|
112
160
|
|
|
113
|
-
export declare
|
|
161
|
+
export declare const reviewRatings: readonly ["Manual", "Again", "Hard", "Good", "Easy"];
|
|
114
162
|
|
|
115
|
-
export declare
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
163
|
+
export declare type ReviewRatingType = keyof typeof ReviewRating;
|
|
164
|
+
|
|
165
|
+
export declare enum ReviewState {
|
|
166
|
+
New = "New",
|
|
167
|
+
Learning = "Learning",
|
|
168
|
+
Review = "Review",
|
|
169
|
+
Relearning = "Relearning"
|
|
120
170
|
}
|
|
121
171
|
|
|
172
|
+
export declare const reviewStates: readonly ["New", "Learning", "Review", "Relearning"];
|
|
173
|
+
|
|
174
|
+
export declare type ReviewStateType = keyof typeof ReviewState;
|
|
175
|
+
|
|
176
|
+
export declare type SemanticColor = 'primary' | 'secondary' | 'tertiary' | 'quaternary' | 'quinary' | 'default';
|
|
177
|
+
|
|
122
178
|
export declare type StudyStatus = 'not-started' | 'suspended' | 'has-cards' | 'no-cards';
|
|
123
179
|
|
|
124
180
|
export declare type StudyType = 'ALL' | 'DECK' | 'TOPIC' | 'SUBJECT';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { R as f, a as v, r as y, b as p } from "./fsrs-C8QUsZ5l.js";
|
|
1
2
|
const c = ["not-reviewed", "card-updated", "demand-rejected", "card-removed"];
|
|
2
3
|
var i = /* @__PURE__ */ ((a) => (a.Draft = "draft", a.Review = "to_review", a.Published = "published", a.Archived = "archived", a))(i || {});
|
|
3
|
-
const
|
|
4
|
+
const s = [
|
|
4
5
|
"matemática",
|
|
5
6
|
// azul
|
|
6
7
|
"geografia",
|
|
@@ -57,18 +58,22 @@ const u = [
|
|
|
57
58
|
artes: "palette",
|
|
58
59
|
inglês: "languages",
|
|
59
60
|
default: "graduation-cap"
|
|
60
|
-
},
|
|
61
|
+
}, u = (a) => e[a] || e.default, l = (a) => r[a] || r.default;
|
|
61
62
|
var t = /* @__PURE__ */ ((a) => (a.Admin = "admin", a.Moderator = "moderator", a.User = "user", a))(t || {}), o = /* @__PURE__ */ ((a) => (a.Owner = "owner", a.Admin = "admin", a.Member = "member", a))(o || {}), n = /* @__PURE__ */ ((a) => (a.Premium = "premium", a))(n || {}), d = /* @__PURE__ */ ((a) => (a.Active = "active", a.Canceled = "canceled", a.Pending = "pending", a.Expired = "expired", a))(d || {});
|
|
62
63
|
export {
|
|
63
64
|
i as DeckStatus,
|
|
64
65
|
n as Entitlement,
|
|
65
66
|
d as MembershipStatus,
|
|
66
67
|
o as OrganizationRole,
|
|
67
|
-
|
|
68
|
+
f as ReviewRating,
|
|
69
|
+
v as ReviewState,
|
|
70
|
+
s as SUBJECTS,
|
|
68
71
|
r as SUBJECT_COLORS,
|
|
69
72
|
e as SUBJECT_ICONS,
|
|
70
73
|
t as UserRole,
|
|
71
74
|
c as cardDemandStatus,
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
l as getSubjectColor,
|
|
76
|
+
u as getSubjectIcon,
|
|
77
|
+
y as reviewRatings,
|
|
78
|
+
p as reviewStates
|
|
74
79
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var Ae=Object.defineProperty;var Ie=(t,e,i)=>e in t?Ae(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i;var _=(t,e,i)=>Ie(t,typeof e!="symbol"?e+"":e,i);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const R=require("./fsrs-HJutnIWm.cjs");require("date-fns/locale");const Pe=require("date-fns");require("date-fns-tz");const fe=.9,Te=50,He=200,ke=10,je=10;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||{});class d{static card(e){return{...e,state:d.state(e.state),due:d.time(e.due),last_review:e.last_review?d.time(e.last_review):void 0}}static rating(e){if(typeof e=="string"){const i=e.charAt(0).toUpperCase(),r=e.slice(1).toLowerCase(),s=l[`${i}${r}`];if(s===void 0)throw new Error(`Invalid rating:[${e}]`);return s}else if(typeof e=="number")return e;throw new Error(`Invalid rating:[${e}]`)}static state(e){if(typeof e=="string"){const i=e.charAt(0).toUpperCase(),r=e.slice(1).toLowerCase(),s=h[`${i}${r}`];if(s===void 0)throw new Error(`Invalid state:[${e}]`);return s}else if(typeof e=="number")return e;throw new Error(`Invalid state:[${e}]`)}static time(e){if(typeof e=="object"&&e instanceof Date)return e;if(typeof e=="string"){const i=Date.parse(e);if(isNaN(i))throw new Error(`Invalid date:[${e}]`);return new Date(i)}else if(typeof e=="number")return new Date(e);throw new Error(`Invalid date:[${e}]`)}static review_log(e){return{...e,due:d.time(e.due),rating:d.rating(e.rating),state:d.state(e.state),review:d.time(e.review)}}}Date.prototype.scheduler=function(t,e){return $e(this,t,e)},Date.prototype.diff=function(t,e){return Le(this,t,e)},Date.prototype.format=function(){return Ge(this)},Date.prototype.dueFormat=function(t,e,i){return Ue(this,t,e,i)};function $e(t,e,i){return new Date(i?d.time(t).getTime()+e*24*60*60*1e3:d.time(t).getTime()+e*60*1e3)}function Le(t,e,i){if(!t||!e)throw new Error("Invalid date");const r=d.time(t).getTime()-d.time(e).getTime();let s=0;switch(i){case"days":s=Math.floor(r/(1440*60*1e3));break;case"minutes":s=Math.floor(r/(60*1e3));break}return s}function Ge(t){const e=d.time(t),i=e.getFullYear(),r=e.getMonth()+1,s=e.getDate(),n=e.getHours(),a=e.getMinutes(),o=e.getSeconds();return`${i}-${D(r)}-${D(s)} ${D(n)}:${D(a)}:${D(o)}`}function D(t){return t<10?`0${t}`:`${t}`}const G=[60,60,24,31,12],U=["second","min","hour","day","month","year"];function Ue(t,e,i,r=U){t=d.time(t),e=d.time(e),r.length!==U.length&&(r=U);let s=t.getTime()-e.getTime(),n;for(s/=1e3,n=0;n<G.length&&!(s<G[n]);n++)s/=G[n];return`${Math.floor(s)}${i?r[n]:""}`}const he=Object.freeze([l.Again,l.Hard,l.Good,l.Easy]),qe=[{start:2.5,end:7,factor:.15},{start:7,end:20,factor:.1},{start:20,end:1/0,factor:.05}];function We(t,e,i){let r=1;for(const a of qe)r+=a.factor*Math.max(Math.min(t,a.end)-a.start,0);t=Math.min(t,i);let s=Math.max(2,Math.round(t-r));const n=Math.min(Math.round(t+r),i);return t>e&&(s=Math.max(s,e+1)),s=Math.min(s,n),{min_ivl:s,max_ivl:n}}function b(t,e,i){return Math.min(Math.max(t,e),i)}function Ye(t,e){const i=Date.UTC(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate()),r=Date.UTC(e.getUTCFullYear(),e.getUTCMonth(),e.getUTCDate());return Math.floor((r-i)/864e5)}const Xe=.9,Ke=36500,Be=Object.freeze([.40255,1.18385,3.173,15.69105,7.1949,.5345,1.4604,.0046,1.54575,.1192,1.01925,1.9395,.11,.29605,2.2698,.2315,2.9898,.51655,.6621]),Ze=!1,Je=!0,g=.01,A=100,ie=Object.freeze([Object.freeze([g,A]),Object.freeze([g,A]),Object.freeze([g,A]),Object.freeze([g,A]),Object.freeze([1,10]),Object.freeze([.001,4]),Object.freeze([.001,4]),Object.freeze([.001,.75]),Object.freeze([0,4.5]),Object.freeze([0,.8]),Object.freeze([.001,3.5]),Object.freeze([.001,5]),Object.freeze([.001,.25]),Object.freeze([.001,.9]),Object.freeze([0,4]),Object.freeze([0,1]),Object.freeze([1,6]),Object.freeze([0,2]),Object.freeze([0,2])]),Y=t=>{let e=[...Be];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]+.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)||Xe,maximum_interval:(t==null?void 0:t.maximum_interval)||Ke,w:e,enable_fuzz:(t==null?void 0:t.enable_fuzz)??Ze,enable_short_term:(t==null?void 0:t.enable_short_term)??Je}};function P(t,e){const i={due:t?d.time(t):new Date,stability:0,difficulty:0,elapsed_days:0,scheduled_days:0,reps:0,lapses:0,state:h.New,last_review:void 0};return e&&typeof e=="function"?e(i):i}class Qe{constructor(e){_(this,"c");_(this,"s0");_(this,"s1");_(this,"s2");const i=Ve();this.c=1,this.s0=i(" "),this.s1=i(" "),this.s2=i(" "),e==null&&(e=+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)}next(){const e=2091639*this.s0+this.c*23283064365386963e-26;return this.s0=this.s1,this.s1=this.s2,this.s2=e-(this.c=e|0),this.s2}set state(e){this.c=e.c,this.s0=e.s0,this.s1=e.s1,this.s2=e.s2}get state(){return{c:this.c,s0:this.s0,s1:this.s1,s2:this.s2}}}function Ve(){let t=4022871197;return function(e){e=String(e);for(let i=0;i<e.length;i++){t+=e.charCodeAt(i);let r=.02519603282416938*t;t=r>>>0,r-=t,r*=t,t=r>>>0,r-=t,t+=r*4294967296}return(t>>>0)*23283064365386963e-26}}function et(t){const e=new Qe(t),i=()=>e.next();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}const _e=-.5,ye=19/81;function tt(t,e){return+Math.pow(1+ye*t/e,_e).toFixed(8)}class it{constructor(e){_(this,"param");_(this,"intervalModifier");_(this,"_seed");_(this,"forgetting_curve",tt);this.param=new Proxy(Y(e),this.params_handler_proxy()),this.intervalModifier=this.calculate_interval_modifier(this.param.request_retention)}get interval_modifier(){return this.intervalModifier}set seed(e){this._seed=e}calculate_interval_modifier(e){if(e<=0||e>1)throw new Error("Requested retention rate should be in the range (0,1]");return+((Math.pow(e,1/_e)-1)/ye).toFixed(8)}get parameters(){return this.param}set parameters(e){this.update_parameters(e)}params_handler_proxy(){const e=this;return{set:function(i,r,s){return r==="request_retention"&&Number.isFinite(s)&&(e.intervalModifier=e.calculate_interval_modifier(Number(s))),Reflect.set(i,r,s),!0}}}update_parameters(e){const i=Y(e);for(const r in i)if(r in this.param){const s=r;this.param[s]=i[s]}}init_stability(e){return Math.max(this.param.w[e-1],.1)}init_difficulty(e){return this.constrain_difficulty(this.param.w[4]-Math.exp((e-1)*this.param.w[5])+1)}apply_fuzz(e,i){if(!this.param.enable_fuzz||e<2.5)return Math.round(e);const r=et(this._seed)(),{min_ivl:s,max_ivl:n}=We(e,i,this.param.maximum_interval);return Math.floor(r*(n-s+1)+s)}next_interval(e,i){const r=Math.min(Math.max(1,Math.round(e*this.intervalModifier)),this.param.maximum_interval);return this.apply_fuzz(r,i)}linear_damping(e,i){return+(e*(10-i)/9).toFixed(8)}next_difficulty(e,i){const r=-this.param.w[6]*(i-3),s=e+this.linear_damping(r,e);return this.constrain_difficulty(this.mean_reversion(this.init_difficulty(l.Easy),s))}constrain_difficulty(e){return Math.min(Math.max(+e.toFixed(8),1),10)}mean_reversion(e,i){return+(this.param.w[7]*e+(1-this.param.w[7])*i).toFixed(8)}next_recall_stability(e,i,r,s){const n=l.Hard===s?this.param.w[15]:1,a=l.Easy===s?this.param.w[16]:1;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),g,36500).toFixed(8)}next_forget_stability(e,i,r){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]),g,36500).toFixed(8)}next_short_term_stability(e,i){return+b(e*Math.exp(this.param.w[17]*(i-3+this.param.w[18])),g,36500).toFixed(8)}next_state(e,i,r){const{difficulty:s,stability:n}=e??{difficulty:0,stability:0};if(i<0)throw new Error(`Invalid delta_t "${i}"`);if(r<0||r>4)throw new Error(`Invalid grade "${r}"`);if(s===0&&n===0)return{difficulty:this.init_difficulty(r),stability:this.init_stability(r)};if(r===0)return{difficulty:s,stability:n};if(s<1||n<g)throw new Error(`Invalid memory state { difficulty: ${s}, stability: ${n} }`);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);let f=o;if(r===1){let[y,p]=[0,0];this.param.enable_short_term&&(y=this.param.w[17],p=this.param.w[18]);const E=n/Math.exp(y*p);f=b(+E.toFixed(8),g,c)}return i===0&&this.param.enable_short_term&&(f=u),{difficulty:this.next_difficulty(s,r),stability:f}}}function me(){const t=this.review_time.getTime(),e=this.current.reps,i=this.current.difficulty*this.current.stability;return`${t}_${e}_${i}`}var X=(t=>(t.SCHEDULER="Scheduler",t.SEED="Seed",t))(X||{});class we{constructor(e,i,r,s={seed:me}){_(this,"last");_(this,"current");_(this,"review_time");_(this,"next",new Map);_(this,"algorithm");_(this,"initSeedStrategy");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()}init(){const{state:e,last_review:i}=this.current;let r=0;e!==h.New&&i&&(r=Ye(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()}preview(){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)}}*previewIterator(){for(const e of he)yield this.review(e)}review(e){const{state:i}=this.last;let r;switch(i){case h.New:r=this.newState(e);break;case h.Learning:case h.Relearning:r=this.learningState(e);break;case h.Review:r=this.reviewState(e);break}if(r)return r;throw new Error("Invalid grade")}buildLog(e){const{last_review:i,due:r,elapsed_days:s}=this.last;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}}}class re extends we{newState(e){const i=this.next.get(e);if(i)return i;const r=d.card(this.current);switch(r.difficulty=this.algorithm.init_difficulty(e),r.stability=this.algorithm.init_stability(e),e){case l.Again:r.scheduled_days=0,r.due=this.review_time.scheduler(1),r.state=h.Learning;break;case l.Hard:r.scheduled_days=0,r.due=this.review_time.scheduler(5),r.state=h.Learning;break;case l.Good:r.scheduled_days=0,r.due=this.review_time.scheduler(10),r.state=h.Learning;break;case l.Easy:{const n=this.algorithm.next_interval(r.stability,this.current.elapsed_days);r.scheduled_days=n,r.due=this.review_time.scheduler(n,!0),r.state=h.Review;break}default:throw new Error("Invalid grade")}const s={card:r,log:this.buildLog(e)};return this.next.set(e,s),s}learningState(e){const i=this.next.get(e);if(i)return i;const{state:r,difficulty:s,stability:n}=this.last,a=d.card(this.current),o=this.current.elapsed_days;switch(a.difficulty=this.algorithm.next_difficulty(s,e),a.stability=this.algorithm.next_short_term_stability(n,e),e){case l.Again:{a.scheduled_days=0,a.due=this.review_time.scheduler(5,!1),a.state=r;break}case l.Hard:{a.scheduled_days=0,a.due=this.review_time.scheduler(10),a.state=r;break}case l.Good:{const u=this.algorithm.next_interval(a.stability,o);a.scheduled_days=u,a.due=this.review_time.scheduler(u,!0),a.state=h.Review;break}case l.Easy:{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);a.scheduled_days=y,a.due=this.review_time.scheduler(y,!0),a.state=h.Review;break}default:throw new Error("Invalid grade")}const c={card:a,log:this.buildLog(e)};return this.next.set(e,c),c}reviewState(e){const i=this.next.get(e);if(i)return i;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);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;const y={card:o,log:this.buildLog(l.Again)},p={card:c,log:super.buildLog(l.Hard)},E={card:u,log:super.buildLog(l.Good)},C={card:f,log:super.buildLog(l.Easy)};return this.next.set(l.Again,y),this.next.set(l.Hard,p),this.next.set(l.Good,E),this.next.set(l.Easy,C),this.next.get(e)}next_ds(e,i,r,s,n,a,o){e.difficulty=this.algorithm.next_difficulty(n,l.Again);const c=a/Math.exp(this.algorithm.parameters.w[17]*this.algorithm.parameters.w[18]),u=this.algorithm.next_forget_stability(n,a,o);e.stability=b(+c.toFixed(8),g,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)}next_interval(e,i,r,s,n){let a,o;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);const c=Math.max(this.algorithm.next_interval(s.stability,n),o+1);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)}next_state(e,i,r,s){e.state=h.Relearning,i.state=h.Review,r.state=h.Review,s.state=h.Review}}class se extends we{newState(e){const i=this.next.get(e);if(i)return i;this.current.scheduled_days=0,this.current.elapsed_days=0;const r=d.card(this.current),s=d.card(this.current),n=d.card(this.current),a=d.card(this.current);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)}init_ds(e,i,r,s){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)}learningState(e){return this.reviewState(e)}reviewState(e){const i=this.next.get(e);if(i)return i;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);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)}next_ds(e,i,r,s,n,a,o){e.difficulty=this.algorithm.next_difficulty(n,l.Again);const c=this.algorithm.next_forget_stability(n,a,o);e.stability=b(a,g,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)}next_interval(e,i,r,s,n){let a,o,c,u;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)}next_state(e,i,r,s){e.state=h.Review,i.state=h.Review,r.state=h.Review,s.state=h.Review}update_next(e,i,r,s){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)};this.next.set(l.Again,n),this.next.set(l.Hard,a),this.next.set(l.Good,o),this.next.set(l.Easy,c)}}class rt{constructor(e){_(this,"fsrs");this.fsrs=e}replay(e,i,r){return this.fsrs.next(e,i,r)}handleManualRating(e,i,r,s,n,a,o){if(typeof i>"u")throw new Error("reschedule: state is required for manual rating");let c,u;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;else{if(typeof o>"u")throw new Error("reschedule: due is required for manual rating");const f=o.diff(r,"days");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}}return{card:u,log:c}}reschedule(e,i){const r=[];let s=P(e.due);for(const n of i){let a;if(n.review=d.time(n.review),n.rating===l.Manual){let o=0;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)}else a=this.replay(s,n.review,n.rating);r.push(a),s=a.card}return r}calculateManualRecord(e,i,r,s){if(!r)return null;const{card:n,log:a}=r,o=d.card(e);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))}}class st extends it{constructor(i){super(i);_(this,"strategyHandler",new Map);_(this,"Scheduler");const{enable_short_term:r}=this.parameters;this.Scheduler=r?re:se}params_handler_proxy(){const i=this;return{set:function(r,s,n){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}}}useStrategy(i,r){return this.strategyHandler.set(i,r),this}clearStrategy(i){return i?this.strategyHandler.delete(i):this.strategyHandler.clear(),this}getScheduler(i,r){const s=this.strategyHandler.get(X.SEED),n=this.strategyHandler.get(X.SCHEDULER)||this.Scheduler,a=s||me;return new n(i,r,this,{seed:a})}repeat(i,r,s){const n=this.getScheduler(i,r).preview();return s&&typeof s=="function"?s(n):n}next(i,r,s,n){const a=this.getScheduler(i,r),o=d.rating(s);if(o===l.Manual)throw new Error("Cannot review a manual rating");const c=a.review(o);return n&&typeof n=="function"?n(c):c}get_retrievability(i,r,s=!0){const n=d.card(i);r=r?d.time(r):new Date;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;return s?`${(o*100).toFixed(2)}%`:o}rollback(i,r,s){const n=d.card(i),a=d.review_log(r);if(a.rating===l.Manual)throw new Error("Cannot rollback a manual rating");let o,c,u;switch(a.state){case h.New:o=a.due,c=void 0,u=0;break;case h.Learning:case h.Relearning:case h.Review:o=a.review,c=a.due,u=n.lapses-(a.rating===l.Again&&a.state===h.Review?1:0);break}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};return s&&typeof s=="function"?s(f):f}forget(i,r,s=!1,n){const a=d.card(i);r=d.time(r);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};return n&&typeof n=="function"?n(u):u}reschedule(i,r=[],s={}){const{recordLogHandler:n,reviewsOrderBy:a,skipManual:o=!0,now:c=new Date,update_memory_state:u=!1}=s;a&&typeof a=="function"&&r.sort(a),o&&(r=r.filter(Ne=>Ne.rating!==l.Manual));const f=new rt(this),y=f.reschedule(s.first_card||P(),r),p=y.length,E=d.card(i),C=f.calculateManualRecord(E,c,p?y[p-1]:void 0,u);return n&&typeof n=="function"?{collections:y.map(n),reschedule_item:C?n(C):null}:{collections:y,reschedule_item:C}}}const nt=t=>new st(t||{}),at=Y({request_retention:fe,enable_fuzz:!0,maximum_interval:100}),ge=nt(at),pe=t=>t.due?t:{...t,due:new Date},ot=t=>R.reviewStates.indexOf(t),ve=t=>({due:t.due,stability:t.stability,difficulty:t.difficulty,elapsed_days:t.elapsedDays,scheduled_days:t.scheduledDays,reps:t.reps,lapses:t.lapses,state:ot(t.state),last_review:t.lastReview}),be=(t,e,i)=>{const r=new Date,s=ve(pe(t));return ge.repeat(s,r,a=>{const o=ut(e),c=a[o],u=Se(c.card,t),f=c.log,y={id:0,cardReviewId:t.id,grade:e,state:xe(f.state),due:f.due,stability:f.stability,difficulty:f.difficulty,elapsedDays:f.elapsed_days,lastElapsedDays:f.last_elapsed_days,scheduledDays:f.scheduled_days,review:f.review,duration:i};return{nextCard:u,reviewLog:y}})};function lt(t){const e=new Date,i=ve(pe(t)),r=ge.repeat(i,e),s=Object.fromEntries(R.reviewRatings.map(n=>[n,new Date]));for(const n of he){const a=r[n].card.due,o=ct(n);s[o]=a}return s}function ct(t){return R.reviewRatings[t]}function xe(t){return R.reviewStates[t]}function Se(t,e){return{...e,due:t.due,stability:t.stability,difficulty:t.difficulty,elapsedDays:t.elapsed_days,scheduledDays:t.scheduled_days,reps:t.reps,lapses:t.lapses,state:xe(t.state),lastReview:t.last_review??null}}function ut(t){const e=R.reviewRatings.indexOf(t);if(e===-1)throw new Error(`Invalid rating: ${t}`);return e}function dt(t,e){const i=P();return{id:"",due:null,stability:i.stability,difficulty:i.difficulty,elapsedDays:i.elapsed_days,scheduledDays:i.scheduled_days,reps:i.reps,lapses:i.lapses,state:R.ReviewState.New,lastReview:i.last_review??null,userDeckStudyId:t,cardId:e}}var Me=Symbol.for("immer-nothing"),ne=Symbol.for("immer-draftable"),w=Symbol.for("immer-state"),ft=process.env.NODE_ENV!=="production"?[function(t){return`The plugin for '${t}' has not been loaded into Immer. To enable the plugin, import and call \`enable${t}()\` when initializing your application.`},function(t){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}'`},"This object has been frozen and should not be mutated",function(t){return"Cannot use a proxy that has been revoked. Did you pass an object from inside an immer function to an async process? "+t},"An immer producer returned a new value *and* modified its draft. Either return a new value *or* modify the draft.","Immer forbids circular references","The first or second argument to `produce` must be a function","The third argument to `produce` must be a function or undefined","First argument to `createDraft` must be a plain object, an array, or an immerable object","First argument to `finishDraft` must be a draft returned by `createDraft`",function(t){return`'current' expects a draft, got: ${t}`},"Object.defineProperty() cannot be used on an Immer draft","Object.setPrototypeOf() cannot be used on an Immer draft","Immer only supports deleting array indices","Immer only supports setting array indices and the 'length' property",function(t){return`'original' expects a draft, got: ${t}`}]:[];function m(t,...e){if(process.env.NODE_ENV!=="production"){const i=ft[t],r=typeof i=="function"?i.apply(null,e):i;throw new Error(`[Immer] ${r}`)}throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var F=Object.getPrototypeOf;function M(t){return!!t&&!!t[w]}function x(t){var e;return t?Re(t)||Array.isArray(t)||!!t[ne]||!!((e=t.constructor)!=null&&e[ne])||N(t)||$(t):!1}var ht=Object.prototype.constructor.toString(),ae=new WeakMap;function Re(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);if(e===null||e===Object.prototype)return!0;const i=Object.hasOwnProperty.call(e,"constructor")&&e.constructor;if(i===Object)return!0;if(typeof i!="function")return!1;let r=ae.get(i);return r===void 0&&(r=Function.toString.call(i),ae.set(i,r)),r===ht}function T(t,e,i=!0){j(t)===0?(i?Reflect.ownKeys(t):Object.keys(t)).forEach(s=>{e(s,t[s],t)}):t.forEach((r,s)=>e(s,r,t))}function j(t){const e=t[w];return e?e.type_:Array.isArray(t)?1:N(t)?2:$(t)?3:0}function K(t,e){return j(t)===2?t.has(e):Object.prototype.hasOwnProperty.call(t,e)}function Ee(t,e,i){const r=j(t);r===2?t.set(e,i):r===3?t.add(i):t[e]=i}function _t(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}function N(t){return t instanceof Map}function $(t){return t instanceof Set}function v(t){return t.copy_||t.base_}function B(t,e){if(N(t))return new Map(t);if($(t))return new Set(t);if(Array.isArray(t))return Array.prototype.slice.call(t);const i=Re(t);if(e===!0||e==="class_only"&&!i){const r=Object.getOwnPropertyDescriptors(t);delete r[w];let s=Reflect.ownKeys(r);for(let n=0;n<s.length;n++){const a=s[n],o=r[a];o.writable===!1&&(o.writable=!0,o.configurable=!0),(o.get||o.set)&&(r[a]={configurable:!0,writable:!0,enumerable:o.enumerable,value:t[a]})}return Object.create(F(t),r)}else{const r=F(t);if(r!==null&&i)return{...t};const s=Object.create(r);return Object.assign(s,t)}}function ee(t,e=!1){return L(t)||M(t)||!x(t)||(j(t)>1&&Object.defineProperties(t,{set:I,add:I,clear:I,delete:I}),Object.freeze(t),e&&Object.values(t).forEach(i=>ee(i,!0))),t}function yt(){m(2)}var I={value:yt};function L(t){return t===null||typeof t!="object"?!0:Object.isFrozen(t)}var mt={};function S(t){const e=mt[t];return e||m(0,t),e}var z;function Ce(){return z}function wt(t,e){return{drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0}}function oe(t,e){e&&(S("Patches"),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Z(t){J(t),t.drafts_.forEach(gt),t.drafts_=null}function J(t){t===z&&(z=t.parent_)}function le(t){return z=wt(z,t)}function gt(t){const e=t[w];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function ce(t,e){e.unfinalizedDrafts_=e.drafts_.length;const i=e.drafts_[0];return t!==void 0&&t!==i?(i[w].modified_&&(Z(e),m(4)),x(t)&&(t=H(e,t),e.parent_||k(e,t)),e.patches_&&S("Patches").generateReplacementPatches_(i[w].base_,t,e.patches_,e.inversePatches_)):t=H(e,i,[]),Z(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==Me?t:void 0}function H(t,e,i){if(L(e))return e;const r=t.immer_.shouldUseStrictIteration(),s=e[w];if(!s)return T(e,(n,a)=>ue(t,s,e,n,a,i),r),e;if(s.scope_!==t)return e;if(!s.modified_)return k(t,s.base_,!0),s.base_;if(!s.finalized_){s.finalized_=!0,s.scope_.unfinalizedDrafts_--;const n=s.copy_;let a=n,o=!1;s.type_===3&&(a=new Set(n),n.clear(),o=!0),T(a,(c,u)=>ue(t,s,n,c,u,i,o),r),k(t,n,!1),i&&t.patches_&&S("Patches").generatePatches_(s,i,t.patches_,t.inversePatches_)}return s.copy_}function ue(t,e,i,r,s,n,a){if(s==null||typeof s!="object"&&!a)return;const o=L(s);if(!(o&&!a)){if(process.env.NODE_ENV!=="production"&&s===i&&m(5),M(s)){const c=n&&e&&e.type_!==3&&!K(e.assigned_,r)?n.concat(r):void 0,u=H(t,s,c);if(Ee(i,r,u),M(u))t.canAutoFreeze_=!1;else return}else a&&i.add(s);if(x(s)&&!o){if(!t.immer_.autoFreeze_&&t.unfinalizedDrafts_<1||e&&e.base_&&e.base_[r]===s&&o)return;H(t,s),(!e||!e.scope_.parent_)&&typeof r!="symbol"&&(N(i)?i.has(r):Object.prototype.propertyIsEnumerable.call(i,r))&&k(t,s)}}}function k(t,e,i=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&ee(e,i)}function pt(t,e){const i=Array.isArray(t),r={type_:i?1:0,scope_:e?e.scope_:Ce(),modified_:!1,finalized_:!1,assigned_:{},parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1};let s=r,n=te;i&&(s=[r],n=O);const{revoke:a,proxy:o}=Proxy.revocable(s,n);return r.draft_=o,r.revoke_=a,o}var te={get(t,e){if(e===w)return t;const i=v(t);if(!K(i,e))return vt(t,i,e);const r=i[e];return t.finalized_||!x(r)?r:r===q(t.base_,e)?(W(t),t.copy_[e]=V(r,t)):r},has(t,e){return e in v(t)},ownKeys(t){return Reflect.ownKeys(v(t))},set(t,e,i){const r=De(v(t),e);if(r!=null&&r.set)return r.set.call(t.draft_,i),!0;if(!t.modified_){const s=q(v(t),e),n=s==null?void 0:s[w];if(n&&n.base_===i)return t.copy_[e]=i,t.assigned_[e]=!1,!0;if(_t(i,s)&&(i!==void 0||K(t.base_,e)))return!0;W(t),Q(t)}return t.copy_[e]===i&&(i!==void 0||e in t.copy_)||Number.isNaN(i)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=i,t.assigned_[e]=!0),!0},deleteProperty(t,e){return q(t.base_,e)!==void 0||e in t.base_?(t.assigned_[e]=!1,W(t),Q(t)):delete t.assigned_[e],t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const i=v(t),r=Reflect.getOwnPropertyDescriptor(i,e);return r&&{writable:!0,configurable:t.type_!==1||e!=="length",enumerable:r.enumerable,value:i[e]}},defineProperty(){m(11)},getPrototypeOf(t){return F(t.base_)},setPrototypeOf(){m(12)}},O={};T(te,(t,e)=>{O[t]=function(){return arguments[0]=arguments[0][0],e.apply(this,arguments)}});O.deleteProperty=function(t,e){return process.env.NODE_ENV!=="production"&&isNaN(parseInt(e))&&m(13),O.set.call(this,t,e,void 0)};O.set=function(t,e,i){return process.env.NODE_ENV!=="production"&&e!=="length"&&isNaN(parseInt(e))&&m(14),te.set.call(this,t[0],e,i,t[0])};function q(t,e){const i=t[w];return(i?v(i):t)[e]}function vt(t,e,i){var s;const r=De(e,i);return r?"value"in r?r.value:(s=r.get)==null?void 0:s.call(t.draft_):void 0}function De(t,e){if(!(e in t))return;let i=F(t);for(;i;){const r=Object.getOwnPropertyDescriptor(i,e);if(r)return r;i=F(i)}}function Q(t){t.modified_||(t.modified_=!0,t.parent_&&Q(t.parent_))}function W(t){t.copy_||(t.copy_=B(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var bt=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!0,this.produce=(e,i,r)=>{if(typeof e=="function"&&typeof i!="function"){const n=i;i=e;const a=this;return function(c=n,...u){return a.produce(c,f=>i.call(this,f,...u))}}typeof i!="function"&&m(6),r!==void 0&&typeof r!="function"&&m(7);let s;if(x(e)){const n=le(this),a=V(e,void 0);let o=!0;try{s=i(a),o=!1}finally{o?Z(n):J(n)}return oe(n,r),ce(s,n)}else if(!e||typeof e!="object"){if(s=i(e),s===void 0&&(s=e),s===Me&&(s=void 0),this.autoFreeze_&&ee(s,!0),r){const n=[],a=[];S("Patches").generateReplacementPatches_(e,s,n,a),r(n,a)}return s}else m(1,e)},this.produceWithPatches=(e,i)=>{if(typeof e=="function")return(a,...o)=>this.produceWithPatches(a,c=>e(c,...o));let r,s;return[this.produce(e,i,(a,o)=>{r=a,s=o}),r,s]},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)}createDraft(t){x(t)||m(8),M(t)&&(t=xt(t));const e=le(this),i=V(t,void 0);return i[w].isManual_=!0,J(e),i}finishDraft(t,e){const i=t&&t[w];(!i||!i.isManual_)&&m(9);const{scope_:r}=i;return oe(r,e),ce(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let i;for(i=e.length-1;i>=0;i--){const s=e[i];if(s.path.length===0&&s.op==="replace"){t=s.value;break}}i>-1&&(e=e.slice(i+1));const r=S("Patches").applyPatches_;return M(t)?r(t,e):this.produce(t,s=>r(s,e))}};function V(t,e){const i=N(t)?S("MapSet").proxyMap_(t,e):$(t)?S("MapSet").proxySet_(t,e):pt(t,e);return(e?e.scope_:Ce()).drafts_.push(i),i}function xt(t){return M(t)||m(10,t),Fe(t)}function Fe(t){if(!x(t)||L(t))return t;const e=t[w];let i,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,i=B(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else i=B(t,!0);return T(i,(s,n)=>{Ee(i,s,Fe(n))},r),e&&(e.finalized_=!1),i}var St=new bt,Mt=St.produce;function Rt(t,e){const i=t+e;let r=0;for(let s=0;s<i.length;s++){const n=i.charCodeAt(s);r=(r<<5)-r+n,r|=0}return r}function Et(t,e){return(Rt(t,e)>>>0)/4294967295}function Ct(t,e=new Set){if(t.reviewCards.length===0&&t.newCards.length===0)return;if(t.reviewCards.length===0)return t.newCards[0];if(t.newCards.length===0)return t.reviewCards[0];const i=de(t.newCards,e),r=de(t.reviewCards,e);if(!i)return r??t.newCards[0];if(!r)return i??t.reviewCards[0];const s=t.newCards.length,n=t.reviewCards.length,a=s+n,o=.33,c=s/a,u=(o+c)/2;return Et(i.card.id,r.card.id)<u?i:r}function de(t,e){return t.find(i=>!e.has(i.card.id))}function Dt(t,e,i){const r=Oe(e,i);if(!r)return e;const{nextCard:s}=be(r.cardReview,t,30),n=s.due&&Pe.isSameDay(s.due,new Date);return Mt(e,a=>{if(Ft(a,r),n){const o={...r,cardReview:s};zt(a,o)}})}function Ft(t,e){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),ze(t,e.cardReview.state,"decrease")}function zt(t,e){if(e.cardReview.state==="New"){const i=t.newCards.findIndex(r=>r.cardReview.due&&e.cardReview.due&&r.cardReview.due>=e.cardReview.due||r.cardReview.difficulty>=e.cardReview.difficulty);i===-1?t.newCards.push(e):t.newCards.splice(i,0,e)}else{const i=Ot(t,t.reviewCards);t.reviewCards.splice(i,0,e)}ze(t,e.cardReview.state,"increase")}function ze(t,e,i){const r=i==="increase"?1:-1;switch(e){case"New":t.stats.new+=r;break;case"Learning":case"Relearning":t.stats.learning+=r;break;case"Review":t.stats.review+=r;break;default:t.stats.new+=r;break}t.stats.total+=r}function Oe(t,e){return t.newCards.find(i=>i.card.id===e)??t.reviewCards.find(i=>i.card.id===e)}function Ot(t,e){if(e.length===0)return 0;const i=Math.max(4,Math.floor(e.length/3));return Math.min(i,e.length)}exports.FSRS_RETENTION=fe;exports.MAX_CARDS_TO_FETCH=Te;exports.MAX_LEARN_PER_DAY=He;exports.MAX_NEW_PER_DECK_DAY=ke;exports.THRESHOLD_CARDS_FOR_REFETCH=je;exports.getNextCardFromSession=Ct;exports.getReviewDateForEachRating=lt;exports.getSessionCard=Oe;exports.gradeCard=be;exports.mergeFsrsCard=Se;exports.newCardReview=dt;exports.removeCardFromSessionData=Dt;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { Card } from 'ts-fsrs';
|
|
2
|
+
|
|
3
|
+
export declare const FSRS_RETENTION = 0.9;
|
|
4
|
+
|
|
5
|
+
export declare function getNextCardFromSession(data: ISessionData, recentlyReviewed?: Set<string>): ISessionCard | undefined;
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Give a {@link ICardReview}, returns the review {@link Date} for each {@link ReviewRating}.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getReviewDateForEachRating(card: ICardReview): Record<ReviewRating, Date>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Gets the card from the session data.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getSessionCard(sessionData: ISessionData, cardId: string): ISessionCard | undefined;
|
|
16
|
+
|
|
17
|
+
export declare const gradeCard: (card: ICardReview, rating: ReviewRating, durationInSeconds: number) => {
|
|
18
|
+
nextCard: ICardReview;
|
|
19
|
+
reviewLog: IReviewLog;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
declare interface ICard {
|
|
23
|
+
id: string;
|
|
24
|
+
question: string;
|
|
25
|
+
answer: string | null;
|
|
26
|
+
frontImage?: {
|
|
27
|
+
id: string;
|
|
28
|
+
url: string;
|
|
29
|
+
};
|
|
30
|
+
backImage?: {
|
|
31
|
+
id: string;
|
|
32
|
+
url: string;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare interface ICardReview {
|
|
37
|
+
id: string;
|
|
38
|
+
due: Date | null;
|
|
39
|
+
stability: number;
|
|
40
|
+
difficulty: number;
|
|
41
|
+
elapsedDays: number;
|
|
42
|
+
scheduledDays: number;
|
|
43
|
+
reps: number;
|
|
44
|
+
lapses: number;
|
|
45
|
+
state: ReviewState;
|
|
46
|
+
lastReview: Date | null;
|
|
47
|
+
userDeckStudyId: string;
|
|
48
|
+
cardId: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
declare interface IReviewLog {
|
|
52
|
+
id: number;
|
|
53
|
+
cardReviewId: string;
|
|
54
|
+
grade: ReviewRating;
|
|
55
|
+
state: ReviewState;
|
|
56
|
+
due: Date;
|
|
57
|
+
stability: number;
|
|
58
|
+
difficulty: number;
|
|
59
|
+
elapsedDays: number;
|
|
60
|
+
lastElapsedDays: number;
|
|
61
|
+
scheduledDays: number;
|
|
62
|
+
review: Date;
|
|
63
|
+
duration: number;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare interface ISessionCard {
|
|
67
|
+
card: ICard;
|
|
68
|
+
cardReview: ICardReview;
|
|
69
|
+
subject: Subject;
|
|
70
|
+
topicName: string;
|
|
71
|
+
userDeckStudyId: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
declare interface ISessionData {
|
|
75
|
+
reviewCards: ISessionCard[];
|
|
76
|
+
newCards: ISessionCard[];
|
|
77
|
+
stats: IStudyStats;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare interface IStudyStats {
|
|
81
|
+
review: number;
|
|
82
|
+
learning: number;
|
|
83
|
+
new: number;
|
|
84
|
+
total: number;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export declare const MAX_CARDS_TO_FETCH = 50;
|
|
88
|
+
|
|
89
|
+
export declare const MAX_LEARN_PER_DAY = 200;
|
|
90
|
+
|
|
91
|
+
export declare const MAX_NEW_PER_DECK_DAY = 10;
|
|
92
|
+
|
|
93
|
+
export declare function mergeFsrsCard(fsrsCard: Card, card: ICardReview): ICardReview;
|
|
94
|
+
|
|
95
|
+
export declare function newCardReview(userDeckStudyId: string, cardId: string): ICardReview;
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Computes the next session data after grading a card.
|
|
99
|
+
*
|
|
100
|
+
* Simulates the card grading and if the next review is within ~10 minutes,
|
|
101
|
+
* keeps the card in the session and updates the respective counter.
|
|
102
|
+
*
|
|
103
|
+
* If the card's state is `New`, then the card exists in `newCards`.
|
|
104
|
+
* If the card is any other state, then the card exists in `reviewCards`.
|
|
105
|
+
*
|
|
106
|
+
* @param grade The grade given to the card
|
|
107
|
+
* @param data The current session data
|
|
108
|
+
* @param cardId The id of the card that was graded
|
|
109
|
+
*/
|
|
110
|
+
export declare function removeCardFromSessionData(grade: ReviewRating, data: ISessionData, cardId: string): ISessionData;
|
|
111
|
+
|
|
112
|
+
declare enum ReviewRating {
|
|
113
|
+
Manual = "Manual",
|
|
114
|
+
Again = "Again",
|
|
115
|
+
Hard = "Hard",
|
|
116
|
+
Good = "Good",
|
|
117
|
+
Easy = "Easy"
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
declare enum ReviewState {
|
|
121
|
+
New = "New",
|
|
122
|
+
Learning = "Learning",
|
|
123
|
+
Review = "Review",
|
|
124
|
+
Relearning = "Relearning"
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
declare type Subject = (typeof SUBJECTS)[number];
|
|
128
|
+
|
|
129
|
+
declare const SUBJECTS: readonly ["matemática", "geografia", "física", "biologia", "história", "literatura", "gramática", "sociologia", "química", "filosofia", "redação", "artes", "inglês"];
|
|
130
|
+
|
|
131
|
+
export declare const THRESHOLD_CARDS_FOR_REFETCH = 10;
|
|
132
|
+
|
|
133
|
+
export { }
|