@opfr/services 1.8.0 → 1.9.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/index.es.js CHANGED
@@ -1,16 +1,17 @@
1
- import { Schema as c, models as d, model as l, connect as Qe, Types as Ye } from "mongoose";
2
- import { QuestStatus as A, DEFAULT_FACTION as Ge, EFFECT_KEYS as We, EQUIPMENT_SLOT as Ie, CHARACTERISTICS as Ve, getComputedCharacteristicValue as Xe, getCurrentLevel as Je, HP_PER_VITALITY as Ze, DEFAULT_MAX_HP as et, transformToDBBuff as tt, RANK_IDS_WITHOUT_BASIC as ge, STORY_MESSAGE_ARGS as nt, STORY_ACTION_TYPES as rt, STORY_STEP_TYPES as at, STORY_SPEAKER_TYPES as st, chapterOne as oe, speakers as it } from "@opfr/definitions";
1
+ import { Schema as o, models as d, model as l, connect as Qe, Types as Ye } from "mongoose";
2
+ import { QuestStatus as k, DEFAULT_FACTION as Ge, EFFECT_KEYS as We, EQUIPMENT_SLOT as Ie, CHARACTERISTICS as Ve, getComputedCharacteristicValue as Xe, getCurrentLevel as Je, HP_PER_VITALITY as Ze, DEFAULT_MAX_HP as et, transformToDBBuff as tt, RANK_IDS_WITHOUT_BASIC as ge, STORY_MESSAGE_ARGS as nt, STORY_ACTION_TYPES as rt, STORY_STEP_TYPES as at, STORY_SPEAKER_TYPES as st, chapterOne as de, speakers as it } from "@opfr/definitions";
3
3
  import ut from "node-cache";
4
4
  import * as Ue from "events";
5
- import { filterNullAndUndefined as L, recordToArray as B, arrayToRecord as Te, mergeObjects as Q, seededRandom as ct, sortBy as pe, randomBetween as Ee, hasExpire as de, isString as ot, capitalizeAllWords as dt, pickNthByOdds as Se, pickFrom as lt, sameDay as Oe, yesterday as Y, exclude as P } from "@opfr/utils-lang";
6
- const G = "___ALL_ENTITIES___";
7
- class y {
5
+ import { filterNullAndUndefined as Q, recordToArray as F, arrayToRecord as Te, mergeObjects as Y, seededRandom as ot, sortBy as ye, randomBetween as Ee, hasExpire as le, isString as ct, capitalizeAllWords as dt, pickNthByOdds as Se, pickFrom as lt, sameDay as ve, yesterday as G, exclude as z } from "@opfr/utils-lang";
6
+ const W = "___ALL_ENTITIES___";
7
+ class m {
8
8
  cache;
9
- constructor(e) {
9
+ constructor(e, t) {
10
10
  this.cache = new ut({
11
11
  stdTTL: e,
12
12
  checkperiod: e * 0.2,
13
- useClones: !1
13
+ useClones: !1,
14
+ maxKeys: t?.maxKeys ?? -1
14
15
  });
15
16
  }
16
17
  async get(e, t) {
@@ -24,24 +25,24 @@ class y {
24
25
  const a = await this.updateInDb(e, t, r);
25
26
  if (a) {
26
27
  const s = this.getKey(a);
27
- this.cache.del(G), this.cache.set(this.normalizeKey(s), a);
28
+ this.cache.del(W), this.cache.set(this.normalizeKey(s), a);
28
29
  }
29
30
  return a;
30
31
  }
31
32
  invalidate(e) {
32
- this.cache.del(G), e && this.cache.del(this.normalizeKey(e));
33
+ this.cache.del(W), e && this.cache.del(this.normalizeKey(e));
33
34
  }
34
35
  clearAll() {
35
36
  this.cache.flushAll();
36
37
  }
37
38
  }
38
- class f extends y {
39
+ class w extends m {
39
40
  async getAll() {
40
- const e = this.cache.get(G);
41
+ const e = this.cache.get(W);
41
42
  if (e)
42
43
  return e;
43
44
  const t = await this.fetchManyFromDb({}, {});
44
- return this.cache.set(G, t), t.forEach((r) => {
45
+ return this.cache.set(W, t), t.forEach((r) => {
45
46
  this.cache.set(this.normalizeKey(this.getKey(r)), r);
46
47
  }), t;
47
48
  }
@@ -52,14 +53,14 @@ class f extends y {
52
53
  }), r;
53
54
  }
54
55
  }
55
- const De = new Ue.EventEmitter(), g = (n, e, t) => {
56
- De.emit(n, e, t);
56
+ const Oe = new Ue.EventEmitter(), b = (n, e, t) => {
57
+ Oe.emit(n, e, t);
57
58
  }, La = (n) => {
58
59
  for (const [e, t] of Object.entries(n))
59
- De.on(e, (r, a) => {
60
+ Oe.on(e, (r, a) => {
60
61
  t(r, a);
61
62
  });
62
- }, S = {
63
+ }, $ = {
63
64
  USER: "middleware/quest/USER",
64
65
  USER_INVENTORY: "middleware/quest/USER_INVENTORY",
65
66
  USER_META: "middleware/quest/USER_META",
@@ -71,10 +72,10 @@ const De = new Ue.EventEmitter(), g = (n, e, t) => {
71
72
  USER_STATS_FLAGS: "middleware/quest/USER_STATS_FLAGS",
72
73
  USER_STATS_FREQUENCY: "middleware/quest/USER_STATS_FREQUENCY",
73
74
  USER_STATS_INVENTORY: "middleware/quest/USER_STATS_INVENTORY"
74
- }, ve = new c(
75
+ }, De = new o(
75
76
  {
76
77
  user: {
77
- type: c.Types.ObjectId,
78
+ type: o.Types.ObjectId,
78
79
  required: !0,
79
80
  ref: "User",
80
81
  index: !0
@@ -84,22 +85,22 @@ const De = new Ue.EventEmitter(), g = (n, e, t) => {
84
85
  required: !0,
85
86
  index: !0
86
87
  },
87
- status: { type: String, default: A.IN_PROGRESS, index: 1 },
88
+ status: { type: String, default: k.IN_PROGRESS, index: 1 },
88
89
  lastCompletionDate: Date,
89
90
  streak: Number
90
91
  },
91
92
  { minimize: !1 }
92
93
  );
93
- ve.post("findOneAndUpdate", function(n) {
94
- n && g(
95
- S.USER_QUEST,
94
+ De.post("findOneAndUpdate", function(n) {
95
+ n && b(
96
+ $.USER_QUEST,
96
97
  n.user._id,
97
98
  n
98
99
  );
99
100
  });
100
- const R = d?.UserQuest || l("UserQuest", ve), pt = new c({
101
+ const C = d?.UserQuest || l("UserQuest", De), pt = new o({
101
102
  user: {
102
- type: c.Types.ObjectId,
103
+ type: o.Types.ObjectId,
103
104
  required: !0,
104
105
  unique: !0,
105
106
  ref: "User"
@@ -109,9 +110,9 @@ const R = d?.UserQuest || l("UserQuest", ve), pt = new c({
109
110
  of: Date,
110
111
  default: /* @__PURE__ */ new Map()
111
112
  }
112
- }), W = d?.UserCooldown || l("UserCooldown", pt), yt = new c({
113
+ }), V = d?.UserCooldown || l("UserCooldown", pt), yt = new o({
113
114
  user: {
114
- type: c.Types.ObjectId,
115
+ type: o.Types.ObjectId,
115
116
  required: !0,
116
117
  unique: !0,
117
118
  ref: "User"
@@ -125,17 +126,17 @@ const R = d?.UserQuest || l("UserQuest", ve), pt = new c({
125
126
  },
126
127
  previousCompletedQuest: { type: [String], default: [] },
127
128
  previousMessageSent: { type: Number, default: 0 }
128
- }), V = d?.UserDailyReport || l("UserDailyReport", yt), ft = new c({
129
+ }), X = d?.UserDailyReport || l("UserDailyReport", yt), ft = new o({
129
130
  user: {
130
- type: c.Types.ObjectId,
131
+ type: o.Types.ObjectId,
131
132
  required: !0,
132
133
  unique: !0,
133
134
  ref: "User"
134
135
  },
135
136
  encyclopedia: { type: [String], default: [] }
136
- }), X = d?.UserEncyclopedia || l("UserEncyclopedia", ft), mt = new c({
137
+ }), J = d?.UserEncyclopedia || l("UserEncyclopedia", ft), mt = new o({
137
138
  user: {
138
- type: c.Types.ObjectId,
139
+ type: o.Types.ObjectId,
139
140
  required: !0,
140
141
  unique: !0,
141
142
  ref: "User",
@@ -150,10 +151,10 @@ const R = d?.UserQuest || l("UserQuest", ve), pt = new c({
150
151
  },
151
152
  default: null
152
153
  }
153
- }), J = d?.UserGames || l("UserGames", mt), Me = new c(
154
+ }), Z = d?.UserGames || l("UserGames", mt), xe = new o(
154
155
  {
155
156
  user: {
156
- type: c.Types.ObjectId,
157
+ type: o.Types.ObjectId,
157
158
  required: !0,
158
159
  unique: !0,
159
160
  ref: "User"
@@ -172,23 +173,23 @@ const R = d?.UserQuest || l("UserQuest", ve), pt = new c({
172
173
  },
173
174
  { minimize: !1 }
174
175
  );
175
- Me.post("findOneAndUpdate", function(n) {
176
- n && g(
177
- S.USER_INVENTORY,
176
+ xe.post("findOneAndUpdate", function(n) {
177
+ n && b(
178
+ $.USER_INVENTORY,
178
179
  n.user._id,
179
180
  n
180
181
  );
181
182
  });
182
- const Z = d?.UserInventory || l("UserInventory", Me), ht = new Ue.EventEmitter(), gt = (n, e) => {
183
+ const ee = d?.UserInventory || l("UserInventory", xe), ht = new Ue.EventEmitter(), gt = (n, e) => {
183
184
  ht.emit(n, e);
184
- }, v = {
185
+ }, x = {
185
186
  multiplier: { type: Number, default: 0 },
186
187
  origin: String,
187
188
  expireAt: { type: Date, default: null },
188
189
  startAt: { type: Date, default: null }
189
- }, xe = new c({
190
+ }, Me = new o({
190
191
  user: {
191
- type: c.Types.ObjectId,
192
+ type: o.Types.ObjectId,
192
193
  required: !0,
193
194
  unique: !0,
194
195
  ref: "User"
@@ -208,33 +209,33 @@ const Z = d?.UserInventory || l("UserInventory", Me), ht = new Ue.EventEmitter()
208
209
  buffs: {
209
210
  cooldown: {
210
211
  casino: {
211
- type: [v],
212
+ type: [x],
212
213
  default: []
213
214
  },
214
215
  work: {
215
- type: [v],
216
+ type: [x],
216
217
  default: []
217
218
  }
218
219
  },
219
220
  berry: {
220
221
  work: {
221
- type: [v],
222
+ type: [x],
222
223
  default: []
223
224
  },
224
225
  global: {
225
- type: [v],
226
+ type: [x],
226
227
  default: []
227
228
  }
228
229
  },
229
230
  drop: {
230
231
  work: {
231
- type: [v],
232
+ type: [x],
232
233
  default: []
233
234
  }
234
235
  },
235
236
  xp: {
236
237
  global: {
237
- type: [v],
238
+ type: [x],
238
239
  default: []
239
240
  }
240
241
  }
@@ -260,16 +261,16 @@ const Z = d?.UserInventory || l("UserInventory", Me), ht = new Ue.EventEmitter()
260
261
  wisdom: { type: Number, default: 0 }
261
262
  }
262
263
  });
263
- xe.post("findOneAndUpdate", async function(n) {
264
- n && (g(
265
- S.USER_META,
264
+ Me.post("findOneAndUpdate", async function(n) {
265
+ n && (b(
266
+ $.USER_META,
266
267
  n.user._id,
267
268
  n
268
269
  ), n.hp <= 0 && gt("death", n.user._id));
269
270
  });
270
- const D = d?.UserMeta || l("UserMeta", xe), Ae = new c({
271
+ const D = d?.UserMeta || l("UserMeta", Me), Ae = new o({
271
272
  user: {
272
- type: c.Types.ObjectId,
273
+ type: o.Types.ObjectId,
273
274
  required: !0,
274
275
  unique: !0,
275
276
  ref: "User"
@@ -285,15 +286,15 @@ const D = d?.UserMeta || l("UserMeta", xe), Ae = new c({
285
286
  selectedBag: { type: String, default: "default" }
286
287
  });
287
288
  Ae.post("findOneAndUpdate", function(n) {
288
- n && g(
289
- S.USER_ORNAMENT,
289
+ n && b(
290
+ $.USER_ORNAMENT,
290
291
  n.user._id,
291
292
  n
292
293
  );
293
294
  });
294
- const ee = d?.UserOrnament || l("UserOrnament", Ae), St = new c({
295
+ const te = d?.UserOrnament || l("UserOrnament", Ae), St = new o({
295
296
  user: {
296
- type: c.Types.ObjectId,
297
+ type: o.Types.ObjectId,
297
298
  required: !0,
298
299
  unique: !0,
299
300
  ref: "User"
@@ -310,9 +311,9 @@ const ee = d?.UserOrnament || l("UserOrnament", Ae), St = new c({
310
311
  default: /* @__PURE__ */ new Map()
311
312
  }
312
313
  }
313
- }), F = d?.UserSettings || l("UserSettings", St), qe = new c({
314
+ }), K = d?.UserSettings || l("UserSettings", St), ke = new o({
314
315
  user: {
315
- type: c.Types.ObjectId,
316
+ type: o.Types.ObjectId,
316
317
  required: !0,
317
318
  unique: !0,
318
319
  ref: "User"
@@ -345,16 +346,16 @@ const ee = d?.UserOrnament || l("UserOrnament", Ae), St = new c({
345
346
  guessInOneTryCount: { type: Number, default: 0 }
346
347
  }
347
348
  });
348
- qe.post("findOneAndUpdate", function(n) {
349
- n && g(
350
- S.USER_STATS_CASINO,
349
+ ke.post("findOneAndUpdate", function(n) {
350
+ n && b(
351
+ $.USER_STATS_CASINO,
351
352
  n.user._id,
352
353
  n
353
354
  );
354
355
  });
355
- const q = d?.UserStatsCasino || l("UserStatsCasino", qe), ke = new c({
356
+ const q = d?.UserStatsCasino || l("UserStatsCasino", ke), qe = new o({
356
357
  user: {
357
- type: c.Types.ObjectId,
358
+ type: o.Types.ObjectId,
358
359
  required: !0,
359
360
  unique: !0,
360
361
  ref: "User"
@@ -362,16 +363,16 @@ const q = d?.UserStatsCasino || l("UserStatsCasino", qe), ke = new c({
362
363
  workCount: { type: Number, default: 0 },
363
364
  totalSpentInShop: { type: Number, default: 0 }
364
365
  });
365
- ke.post("findOneAndUpdate", function(n) {
366
- n && g(
367
- S.USER_STATS_ECONOMY,
366
+ qe.post("findOneAndUpdate", function(n) {
367
+ n && b(
368
+ $.USER_STATS_ECONOMY,
368
369
  n.user._id,
369
370
  n
370
371
  );
371
372
  });
372
- const te = d?.UserStatsEconomy || l("UserStatsEconomy", ke), Re = new c({
373
+ const ne = d?.UserStatsEconomy || l("UserStatsEconomy", qe), Re = new o({
373
374
  user: {
374
- type: c.Types.ObjectId,
375
+ type: o.Types.ObjectId,
375
376
  required: !0,
376
377
  unique: !0,
377
378
  ref: "User"
@@ -382,18 +383,18 @@ const te = d?.UserStatsEconomy || l("UserStatsEconomy", ke), Re = new c({
382
383
  writeDifferentChatIds: { type: [String], default: [] }
383
384
  });
384
385
  Re.post("findOneAndUpdate", function(n) {
385
- n && g(
386
- S.USER_STATS_ENGAGEMENT,
386
+ n && b(
387
+ $.USER_STATS_ENGAGEMENT,
387
388
  n.user._id,
388
389
  n
389
390
  );
390
391
  });
391
- const ne = d?.UserStatsEngagement || l(
392
+ const re = d?.UserStatsEngagement || l(
392
393
  "UserStatsEngagement",
393
394
  Re
394
- ), Ce = new c({
395
+ ), Ce = new o({
395
396
  user: {
396
- type: c.Types.ObjectId,
397
+ type: o.Types.ObjectId,
397
398
  required: !0,
398
399
  unique: !0,
399
400
  ref: "User"
@@ -411,15 +412,15 @@ const ne = d?.UserStatsEngagement || l(
411
412
  }
412
413
  });
413
414
  Ce.post("findOneAndUpdate", function(n) {
414
- n && g(
415
- S.USER_STATS_FLAGS,
415
+ n && b(
416
+ $.USER_STATS_FLAGS,
416
417
  n.user._id,
417
418
  n
418
419
  );
419
420
  });
420
- const re = d?.UserStatsFlags || l("UserStatsFlags", Ce), Be = new c({
421
+ const ae = d?.UserStatsFlags || l("UserStatsFlags", Ce), Be = new o({
421
422
  user: {
422
- type: c.Types.ObjectId,
423
+ type: o.Types.ObjectId,
423
424
  required: !0,
424
425
  unique: !0,
425
426
  ref: "User"
@@ -430,8 +431,8 @@ const re = d?.UserStatsFlags || l("UserStatsFlags", Ce), Be = new c({
430
431
  }
431
432
  });
432
433
  Be.post("findOneAndUpdate", function(n) {
433
- n && g(
434
- S.USER_STATS_FREQUENCY,
434
+ n && b(
435
+ $.USER_STATS_FREQUENCY,
435
436
  n.user._id,
436
437
  n
437
438
  );
@@ -439,9 +440,9 @@ Be.post("findOneAndUpdate", function(n) {
439
440
  const O = d?.UserStatsFrequency || l(
440
441
  "UserStatsFrequency",
441
442
  Be
442
- ), _e = new c({
443
+ ), _e = new o({
443
444
  user: {
444
- type: c.Types.ObjectId,
445
+ type: o.Types.ObjectId,
445
446
  required: !0,
446
447
  unique: !0,
447
448
  ref: "User"
@@ -467,16 +468,16 @@ const O = d?.UserStatsFrequency || l(
467
468
  }
468
469
  });
469
470
  _e.post("findOneAndUpdate", function(n) {
470
- n && g(
471
- S.USER_STATS_INVENTORY,
471
+ n && b(
472
+ $.USER_STATS_INVENTORY,
472
473
  n.user._id,
473
474
  n
474
475
  );
475
476
  });
476
- const k = d?.UserStatsInventory || l(
477
+ const R = d?.UserStatsInventory || l(
477
478
  "UserStatsInventory",
478
479
  _e
479
- ), ye = new c({
480
+ ), fe = new o({
480
481
  discordId: { type: String, required: !0, unique: !0 },
481
482
  scam: { type: Boolean, default: !1 },
482
483
  birthday: { type: Date, default: null, index: 1 },
@@ -484,21 +485,21 @@ const k = d?.UserStatsInventory || l(
484
485
  canChangeFaction: { type: Boolean, default: !1 },
485
486
  canChooseFaction: { type: Boolean, default: !1 }
486
487
  });
487
- ye.post("findOneAndUpdate", function(n) {
488
- n && g(S.USER, n._id, n);
488
+ fe.post("findOneAndUpdate", function(n) {
489
+ n && b($.USER, n._id, n);
489
490
  });
490
- ye.post("deleteOne", async function() {
491
+ fe.post("deleteOne", async function() {
491
492
  const n = this.getQuery()._id;
492
- await W.deleteOne({ user: n }), await V.deleteOne({ user: n }), await X.deleteOne({ user: n }), await J.deleteOne({ user: n }), await Z.deleteOne({ user: n }), await D.deleteOne({ user: n }), await ee.deleteOne({ user: n }), await R.deleteMany({ user: n }), await F.deleteOne({ user: n }), await q.deleteOne({ user: n }), await te.deleteOne({ user: n }), await ne.deleteOne({ user: n }), await re.deleteOne({ user: n }), await O.deleteOne({ user: n }), await k.deleteOne({ user: n });
493
+ await V.deleteOne({ user: n }), await X.deleteOne({ user: n }), await J.deleteOne({ user: n }), await Z.deleteOne({ user: n }), await ee.deleteOne({ user: n }), await D.deleteOne({ user: n }), await te.deleteOne({ user: n }), await C.deleteMany({ user: n }), await K.deleteOne({ user: n }), await q.deleteOne({ user: n }), await ne.deleteOne({ user: n }), await re.deleteOne({ user: n }), await ae.deleteOne({ user: n }), await O.deleteOne({ user: n }), await R.deleteOne({ user: n });
493
494
  });
494
- const w = d?.User || l("User", ye);
495
- class wt extends f {
495
+ const I = d?.User || l("User", fe);
496
+ class wt extends w {
496
497
  getByObjectId(e) {
497
498
  return this.update({ _id: e }, {});
498
499
  }
499
500
  getNextBirthdays() {
500
501
  const e = /* @__PURE__ */ new Date(), t = e.getFullYear();
501
- return w.aggregate([
502
+ return I.aggregate([
502
503
  {
503
504
  $match: {
504
505
  birthday: { $ne: null }
@@ -549,7 +550,7 @@ class wt extends f {
549
550
  ]);
550
551
  }
551
552
  getFactionRanking(e) {
552
- return w.aggregate([
553
+ return I.aggregate([
553
554
  { $match: { faction: e } },
554
555
  {
555
556
  $lookup: {
@@ -572,7 +573,7 @@ class wt extends f {
572
573
  ]);
573
574
  }
574
575
  getGlobalRanking() {
575
- return w.aggregate([
576
+ return I.aggregate([
576
577
  {
577
578
  $lookup: {
578
579
  from: "usermetas",
@@ -594,7 +595,7 @@ class wt extends f {
594
595
  ]);
595
596
  }
596
597
  getBerryRanking() {
597
- return w.aggregate([
598
+ return I.aggregate([
598
599
  {
599
600
  $lookup: {
600
601
  from: "usermetas",
@@ -616,10 +617,10 @@ class wt extends f {
616
617
  ]);
617
618
  }
618
619
  getQuestRanking() {
619
- return R.aggregate([
620
+ return C.aggregate([
620
621
  {
621
622
  $match: {
622
- status: A.COMPLETED
623
+ status: k.COMPLETED
623
624
  }
624
625
  },
625
626
  {
@@ -663,7 +664,7 @@ class wt extends f {
663
664
  }
664
665
  getTodayAllBirthday() {
665
666
  const e = /* @__PURE__ */ new Date();
666
- return w.aggregate([
667
+ return I.aggregate([
667
668
  { $match: { birthday: { $ne: null } } },
668
669
  {
669
670
  $addFields: {
@@ -710,14 +711,14 @@ class wt extends f {
710
711
  );
711
712
  }
712
713
  }
713
- const bt = (n, e) => w.find(n, {}, e).lean(), p = (n) => n.toObject({ flattenMaps: !0, flattenObjectIds: !1 }), $t = (n) => w.create({
714
+ const bt = (n, e) => I.find(n, {}, e).lean(), y = (n) => n.toObject({ flattenMaps: !0, flattenObjectIds: !1 }), $t = (n) => I.create({
714
715
  discordId: n
715
716
  });
716
717
  async function It(n, { upsert: e = !0, ...t }) {
717
- const r = await w.findOne({ discordId: n }, {}, t).lean();
718
- return !r && e ? p(await $t(n)) : r;
718
+ const r = await I.findOne({ discordId: n }, {}, t).lean();
719
+ return !r && e ? y(await $t(n)) : r;
719
720
  }
720
- const Ut = (n, e) => w.findOneAndUpdate(n, e, {
721
+ const Ut = (n, e) => I.findOneAndUpdate(n, e, {
721
722
  upsert: !0,
722
723
  returnDocument: "after"
723
724
  }).lean();
@@ -741,10 +742,10 @@ class Tt extends wt {
741
742
  return Ut(e, t);
742
743
  }
743
744
  }
744
- const Et = new Tt(), Ot = new c(
745
+ const Et = new Tt(), vt = new o(
745
746
  {
746
747
  user: {
747
- type: c.Types.ObjectId,
748
+ type: o.Types.ObjectId,
748
749
  ref: "User",
749
750
  required: !0,
750
751
  index: !0
@@ -753,12 +754,12 @@ const Et = new Tt(), Ot = new c(
753
754
  type: { type: String, required: !0 }
754
755
  },
755
756
  { minimize: !1 }
756
- ), N = d?.Reminder || l("Reminder", Ot), Dt = async (n) => {
757
- await N.deleteMany(n);
758
- }, vt = async (n, e) => {
759
- await N.deleteOne({ user: n, type: e });
757
+ ), H = d?.Reminder || l("Reminder", vt), Ot = async (n) => {
758
+ await H.deleteMany(n);
759
+ }, Dt = async (n, e) => {
760
+ await H.deleteOne({ user: n, type: e });
760
761
  };
761
- class Mt extends f {
762
+ class xt extends w {
762
763
  getAllPassedReminder() {
763
764
  return this.getMany({ date: { $lte: /* @__PURE__ */ new Date() } });
764
765
  }
@@ -777,29 +778,29 @@ class Mt extends f {
777
778
  ]);
778
779
  }
779
780
  async removeReminder(e, t) {
780
- await vt(e, t), this.invalidate({ user: e, type: t });
781
+ await Dt(e, t), this.invalidate({ user: e, type: t });
781
782
  }
782
783
  async deleteSelectedReminders(e) {
783
784
  const t = e.map((r) => r._id);
784
- await Dt({ _id: { $in: t } }), e.forEach((r) => {
785
+ await Ot({ _id: { $in: t } }), e.forEach((r) => {
785
786
  this.invalidate({ user: r.user, type: r.type });
786
787
  });
787
788
  }
788
789
  }
789
- function xt(n, e) {
790
- return N.find(n, {}, e).lean();
790
+ function Mt(n, e) {
791
+ return H.find(n, {}, e).lean();
791
792
  }
792
793
  async function At(n) {
793
- const e = await N.findOne(n).lean();
794
+ const e = await H.findOne(n).lean();
794
795
  return e || null;
795
796
  }
796
- async function qt(n, e, t) {
797
- return N.findOneAndUpdate(n, e, {
797
+ async function kt(n, e, t) {
798
+ return H.findOneAndUpdate(n, e, {
798
799
  ...t,
799
800
  returnDocument: "after"
800
801
  }).lean();
801
802
  }
802
- class kt extends Mt {
803
+ class qt extends xt {
803
804
  constructor() {
804
805
  super(300);
805
806
  }
@@ -816,33 +817,33 @@ class kt extends Mt {
816
817
  return At(e);
817
818
  }
818
819
  fetchManyFromDb(e, t) {
819
- return xt(e, t);
820
+ return Mt(e, t);
820
821
  }
821
822
  updateInDb(e, t, r = { upsert: !1 }) {
822
- return qt(e, t, r);
823
+ return kt(e, t, r);
823
824
  }
824
825
  }
825
- const Rt = new kt(), Ct = new c(
826
+ const Rt = new qt(), Ct = new o(
826
827
  {
827
828
  panoplyId: { unique: !0, index: 1, required: !0, type: String },
828
829
  name: { required: !0, type: String },
829
830
  equipments: {
830
831
  required: !0,
831
- type: [{ type: c.Types.ObjectId, ref: "Entities" }]
832
+ type: [{ type: o.Types.ObjectId, ref: "Entities" }]
832
833
  },
833
834
  fullBonusStr: { type: String },
834
835
  halfBonusStr: { type: String },
835
- fullBonus: c.Types.Mixed,
836
- halfBonus: c.Types.Mixed
836
+ fullBonus: o.Types.Mixed,
837
+ halfBonus: o.Types.Mixed
837
838
  },
838
839
  { minimize: !1 }
839
- ), K = d?.Panoplies || l("Panoplies", Ct), Bt = (n, e) => K.find(n, {}, e).lean(), _t = async (n, e) => K.find(n, {}, e).populate("equipments");
840
+ ), P = d?.Panoplies || l("Panoplies", Ct), Bt = (n, e) => P.find(n, {}, e).lean(), _t = async (n, e) => P.find(n, {}, e).populate("equipments");
840
841
  async function Ft(n) {
841
- const e = await K.findOne({ panoplyId: n }).lean();
842
+ const e = await P.findOne({ panoplyId: n }).lean();
842
843
  return e || null;
843
844
  }
844
- const Nt = async (n) => K.findOne(n).populate("equipments");
845
- class Kt extends f {
845
+ const Nt = async (n) => P.findOne(n).populate("equipments");
846
+ class Kt extends w {
846
847
  getAllPopulated() {
847
848
  return _t({}, {});
848
849
  }
@@ -850,7 +851,7 @@ class Kt extends f {
850
851
  return Nt({ panoplyId: e });
851
852
  }
852
853
  hasPanoply(e, t) {
853
- const r = L(Object.values(e)), a = t.equipments.filter(
854
+ const r = Q(Object.values(e)), a = t.equipments.filter(
854
855
  (s) => r.find((i) => i.entityId === s.entityId)
855
856
  ).length;
856
857
  if (a === t.equipments.length)
@@ -861,15 +862,15 @@ class Kt extends f {
861
862
  async getPanoplyBonus(e) {
862
863
  const t = [], r = await this.getAllPopulated();
863
864
  for (const a of r) {
864
- const s = L(Object.values(e)), i = a.equipments.filter(
865
- (u) => s.find(({ entityId: o }) => o === u.entityId)
865
+ const s = Q(Object.values(e)), i = a.equipments.filter(
866
+ (u) => s.find(({ entityId: c }) => c === u.entityId)
866
867
  );
867
868
  i.length === a.equipments.length ? t.push([a, "full"]) : i.length >= a.equipments.length / 2 ? t.push([a, "half"]) : i.length >= 1 && t.push([a, null]);
868
869
  }
869
870
  return t;
870
871
  }
871
872
  }
872
- const Ht = async (n, e) => K.findOneAndUpdate(n, e, {
873
+ const Ht = async (n, e) => P.findOneAndUpdate(n, e, {
873
874
  returnDocument: "after"
874
875
  }).lean();
875
876
  class Pt extends Kt {
@@ -892,17 +893,17 @@ class Pt extends Kt {
892
893
  return Bt(e, t);
893
894
  }
894
895
  }
895
- const _ = new Pt(), jt = new c(
896
+ const N = new Pt(), jt = new o(
896
897
  {
897
898
  type: {
898
899
  type: String,
899
900
  enum: We,
900
901
  required: !0
901
902
  },
902
- params: { type: c.Types.Mixed }
903
+ params: { type: o.Types.Mixed }
903
904
  },
904
905
  { _id: !1 }
905
- ), zt = new c(
906
+ ), zt = new o(
906
907
  {
907
908
  entityId: { unique: !0, required: !0, type: String }
908
909
  },
@@ -910,7 +911,7 @@ const _ = new Pt(), jt = new c(
910
911
  minimize: !1,
911
912
  discriminatorKey: "type"
912
913
  }
913
- ), Lt = new c({
914
+ ), Lt = new o({
914
915
  category: { required: !0, type: String },
915
916
  subtype: { type: String },
916
917
  rankId: String,
@@ -923,17 +924,17 @@ const _ = new Pt(), jt = new c(
923
924
  },
924
925
  default: void 0
925
926
  }
926
- }), Qt = new c({
927
+ }), Qt = new o({
927
928
  category: { required: !0, type: String },
928
929
  characteristics: {
929
930
  _id: !1,
930
931
  type: Object
931
932
  },
932
933
  panoply: String
933
- }), C = d?.Entities || l("Entities", zt), Yt = C.discriminator("item", Lt);
934
- C.discriminator("equipment", Qt);
935
- const Gt = async (n, e) => C.find(n, {}, e).lean(), Wt = async (n, e) => Yt.find(n, {}, e).lean();
936
- class Vt extends f {
934
+ }), B = d?.Entities || l("Entities", zt), Yt = B.discriminator("item", Lt);
935
+ B.discriminator("equipment", Qt);
936
+ const Gt = async (n, e) => B.find(n, {}, e).lean(), Wt = async (n, e) => Yt.find(n, {}, e).lean();
937
+ class Vt extends w {
937
938
  isEntity(e) {
938
939
  return !!e && "entityId" in e;
939
940
  }
@@ -956,7 +957,7 @@ class Vt extends f {
956
957
  }
957
958
  async recordToEntityTuple(e) {
958
959
  const t = await this.getAll();
959
- return B(e).reduce((r, [a, s]) => {
960
+ return F(e).reduce((r, [a, s]) => {
960
961
  const i = t.find(({ entityId: u }) => u === a);
961
962
  return i && r.push([i, s]), r;
962
963
  }, []);
@@ -992,18 +993,18 @@ class Vt extends f {
992
993
  intelligence: 0,
993
994
  wisdom: 0
994
995
  };
995
- const r = await _.getAllPopulated();
996
+ const r = await N.getAllPopulated();
996
997
  for (const a of Ie) {
997
998
  const s = e[a];
998
- s && (t = Q(
999
+ s && (t = Y(
999
1000
  t,
1000
1001
  (await this.fromDBToEquipableEquipment(s)).characteristics,
1001
1002
  (i, u) => i + u
1002
1003
  ));
1003
1004
  }
1004
1005
  for (const a of r) {
1005
- const s = _.hasPanoply(e, a);
1006
- s && !("target" in s) && (t = Q(
1006
+ const s = N.hasPanoply(e, a);
1007
+ s && !("target" in s) && (t = Y(
1007
1008
  t,
1008
1009
  s,
1009
1010
  (i, u) => i + u
@@ -1034,8 +1035,8 @@ class Vt extends f {
1034
1035
  return e.entityId === t.entityId && e.seed === t.seed;
1035
1036
  }
1036
1037
  seedEquipment(e, t) {
1037
- const r = ct(t), a = pe(
1038
- B(e.characteristics),
1038
+ const r = ot(t), a = ye(
1039
+ F(e.characteristics),
1039
1040
  ([s]) => s
1040
1041
  );
1041
1042
  return {
@@ -1055,14 +1056,14 @@ class Vt extends f {
1055
1056
  );
1056
1057
  }
1057
1058
  }
1058
- const Xt = async (n) => await C.create({
1059
+ const Xt = async (n) => await B.create({
1059
1060
  ...n
1060
1061
  });
1061
1062
  async function Jt(n) {
1062
- const e = await C.findOne({ entityId: n }).lean();
1063
+ const e = await B.findOne({ entityId: n }).lean();
1063
1064
  return e || null;
1064
1065
  }
1065
- const Zt = (n, e) => C.findOneAndUpdate(n, e, {
1066
+ const Zt = (n, e) => B.findOneAndUpdate(n, e, {
1066
1067
  returnDocument: "after"
1067
1068
  }).lean();
1068
1069
  class en extends Vt {
@@ -1088,8 +1089,8 @@ class en extends Vt {
1088
1089
  return e.entityId;
1089
1090
  }
1090
1091
  }
1091
- const U = new en();
1092
- class tn extends y {
1092
+ const T = new en();
1093
+ class tn extends m {
1093
1094
  hasAlreadyFoundEntity(e, t) {
1094
1095
  return e.encyclopedia.includes(t);
1095
1096
  }
@@ -1099,14 +1100,14 @@ class tn extends y {
1099
1100
  });
1100
1101
  }
1101
1102
  }
1102
- const nn = async (n) => await X.create({
1103
+ const nn = async (n) => await J.create({
1103
1104
  user: n
1104
1105
  });
1105
1106
  async function rn(n) {
1106
- const e = await X.findOne({ user: n }).lean();
1107
- return e || p(await nn(n));
1107
+ const e = await J.findOne({ user: n }).lean();
1108
+ return e || y(await nn(n));
1108
1109
  }
1109
- const an = (n, e) => X.findOneAndUpdate({ user: n }, e, {
1110
+ const an = (n, e) => J.findOneAndUpdate({ user: n }, e, {
1110
1111
  upsert: !0,
1111
1112
  returnDocument: "after"
1112
1113
  }).lean();
@@ -1127,8 +1128,8 @@ class sn extends tn {
1127
1128
  return an(e, t);
1128
1129
  }
1129
1130
  }
1130
- const le = new sn();
1131
- class un extends y {
1131
+ const pe = new sn();
1132
+ class un extends m {
1132
1133
  async getUserEquipmentsCharacteristics(e) {
1133
1134
  let t = {
1134
1135
  vitality: 0,
@@ -1142,8 +1143,8 @@ class un extends y {
1142
1143
  const a = e.equippedItems?.[r];
1143
1144
  if (!a)
1144
1145
  continue;
1145
- const s = await U.fromDBToEquipableEquipment(a);
1146
- t = Q(
1146
+ const s = await T.fromDBToEquipableEquipment(a);
1147
+ t = Y(
1147
1148
  t,
1148
1149
  s.characteristics,
1149
1150
  (i, u) => i + u
@@ -1153,7 +1154,7 @@ class un extends y {
1153
1154
  }
1154
1155
  async hasInventoryRequirements(e, t) {
1155
1156
  const r = await this.get(e);
1156
- return B(t).reduce(
1157
+ return F(t).reduce(
1157
1158
  (a, [s, i]) => a && (r.itemList[s] ?? 0) >= (i ?? 0),
1158
1159
  !0
1159
1160
  );
@@ -1165,14 +1166,14 @@ class un extends y {
1165
1166
  return (await this.get(e)).itemList;
1166
1167
  }
1167
1168
  async calcMinStreakForWorkLoot(e) {
1168
- const t = await this.get(e), r = (await _.getPanoplyBonus(t.equippedItems)).find(
1169
+ const t = await this.get(e), r = (await N.getPanoplyBonus(t.equippedItems)).find(
1169
1170
  ([a, s]) => a.panoplyId === "marine" && s !== null
1170
1171
  );
1171
1172
  return r && r[1] === "full" ? 10 : r && r[1] === "half" ? 20 : 1 / 0;
1172
1173
  }
1173
1174
  async hasRevolutionaryBuff(e) {
1174
1175
  const t = await this.get(e);
1175
- return (await _.getPanoplyBonus(t.equippedItems)).find(
1176
+ return (await N.getPanoplyBonus(t.equippedItems)).find(
1176
1177
  ([a, s]) => a.panoplyId === "revolutionary" && s !== null
1177
1178
  )?.[1] ?? null;
1178
1179
  }
@@ -1188,16 +1189,16 @@ class un extends y {
1188
1189
  async addItem(e, t, r) {
1189
1190
  await this.update(e, {
1190
1191
  $inc: { [`itemList.${t}`]: r }
1191
- }), await le.addEntities(e, [t]);
1192
+ }), await pe.addEntities(e, [t]);
1192
1193
  }
1193
1194
  async addItems(e, t) {
1194
1195
  await this.update(e, {
1195
1196
  $inc: Object.fromEntries(
1196
1197
  Object.entries(t).filter(([, r]) => (r ?? 0) > 0).map(([r, a]) => [`itemList.${r}`, a])
1197
1198
  )
1198
- }), await le.addEntities(
1199
+ }), await pe.addEntities(
1199
1200
  e,
1200
- B(t).filter(([, r]) => r > 0).map(([r]) => r)
1201
+ F(t).filter(([, r]) => r > 0).map(([r]) => r)
1201
1202
  );
1202
1203
  }
1203
1204
  async removeItem(e, t, r) {
@@ -1227,7 +1228,7 @@ class un extends y {
1227
1228
  async addEquipments(e, t) {
1228
1229
  await this.update(e, {
1229
1230
  $push: { equipmentList: { $each: t } }
1230
- }), await le.addEntities(
1231
+ }), await pe.addEntities(
1231
1232
  e,
1232
1233
  t.map((r) => r.entityId)
1233
1234
  );
@@ -1246,29 +1247,29 @@ class un extends y {
1246
1247
  r?.equipmentSave[t] && await this.equip(e, r.equipmentSave[t]);
1247
1248
  }
1248
1249
  async equip(e, t) {
1249
- const r = await E.getMaxHp(e), a = Object.fromEntries(
1250
- B(t).map(([s, i]) => [
1250
+ const r = await v.getMaxHp(e), a = Object.fromEntries(
1251
+ F(t).map(([s, i]) => [
1251
1252
  `equippedItems.${s}`,
1252
1253
  i
1253
1254
  ])
1254
1255
  );
1255
1256
  await this.update(e, {
1256
1257
  $set: a
1257
- }), await E.updateHp(e, r);
1258
+ }), await v.updateHp(e, r);
1258
1259
  }
1259
1260
  async unequip(e, t) {
1260
- const r = await E.getMaxHp(e);
1261
+ const r = await v.getMaxHp(e);
1261
1262
  await this.update(e, {
1262
1263
  $set: {
1263
1264
  [`equippedItems.${t}`]: null
1264
1265
  }
1265
- }), await E.updateHp(e, r);
1266
+ }), await v.updateHp(e, r);
1266
1267
  }
1267
1268
  async craftItem(e, t, r, a) {
1268
- for (const { entityId: u, size: o } of t.entities)
1269
- await this.removeItem(e, u, (o ?? 1) * r);
1269
+ for (const { entityId: u, size: c } of t.entities)
1270
+ await this.removeItem(e, u, (c ?? 1) * r);
1270
1271
  const { entityId: s, size: i } = t.result;
1271
- await U.isEntityId(s, U.isEquipment) ? await this.addEquipments(e, [{ entityId: s, seed: a }]) : await U.isEntityId(s, U.isItem) && await this.addItem(e, s, (i ?? 1) * r);
1272
+ await T.isEntityId(s, T.isEquipment) ? await this.addEquipments(e, [{ entityId: s, seed: a }]) : await T.isEntityId(s, T.isItem) && await this.addItem(e, s, (i ?? 1) * r);
1272
1273
  }
1273
1274
  async unlockRecipe(e, t) {
1274
1275
  await this.hasRecipe(e, t) || await this.update(e, {
@@ -1276,14 +1277,14 @@ class un extends y {
1276
1277
  });
1277
1278
  }
1278
1279
  }
1279
- const cn = (n) => Z.create({
1280
+ const on = (n) => ee.create({
1280
1281
  user: n
1281
1282
  });
1282
- async function on(n) {
1283
- const e = await Z.findOne({ user: n }).lean();
1284
- return e || p(await cn(n));
1283
+ async function cn(n) {
1284
+ const e = await ee.findOne({ user: n }).lean();
1285
+ return e || y(await on(n));
1285
1286
  }
1286
- const dn = (n, e) => Z.findOneAndUpdate({ user: n }, e, {
1287
+ const dn = (n, e) => ee.findOneAndUpdate({ user: n }, e, {
1287
1288
  upsert: !0,
1288
1289
  returnDocument: "after"
1289
1290
  }).lean();
@@ -1292,7 +1293,7 @@ class ln extends un {
1292
1293
  super(300);
1293
1294
  }
1294
1295
  fetchFromDb(e) {
1295
- return on(e);
1296
+ return cn(e);
1296
1297
  }
1297
1298
  normalizeKey(e) {
1298
1299
  return e.toString();
@@ -1305,7 +1306,7 @@ class ln extends un {
1305
1306
  }
1306
1307
  }
1307
1308
  const M = new ln();
1308
- class pn extends f {
1309
+ class pn extends w {
1309
1310
  async getTotalCharacteristics(e) {
1310
1311
  const { characteristics: t, scrolls: r } = await this.get(e);
1311
1312
  return Te(
@@ -1363,7 +1364,7 @@ class pn extends f {
1363
1364
  t.booster ? 0.25 : 0
1364
1365
  );
1365
1366
  return a + s + t.buffs.xp.global.reduce(
1366
- (i, { expireAt: u, startAt: o, multiplier: m }) => o && o > /* @__PURE__ */ new Date() || u && de(u) ? i : i + m,
1367
+ (i, { expireAt: u, startAt: c, multiplier: f }) => c && c > /* @__PURE__ */ new Date() || u && le(u) ? i : i + f,
1367
1368
  0
1368
1369
  );
1369
1370
  }
@@ -1385,7 +1386,7 @@ class pn extends f {
1385
1386
  }
1386
1387
  async calcBuffMultiplier(e, t, r) {
1387
1388
  return (await this.get(e)).buffs[t][r].reduce(
1388
- (i, { expireAt: u, startAt: o, multiplier: m }) => i + (/* @__PURE__ */ new Date() >= (o ?? /* @__PURE__ */ new Date()) && (!u || !de(u)) ? m : 0),
1389
+ (i, { expireAt: u, startAt: c, multiplier: f }) => i + (/* @__PURE__ */ new Date() >= (c ?? /* @__PURE__ */ new Date()) && (!u || !le(u)) ? f : 0),
1389
1390
  1
1390
1391
  );
1391
1392
  }
@@ -1402,7 +1403,7 @@ class pn extends f {
1402
1403
  async hasCharacteristicRequirement(e, t) {
1403
1404
  const r = await M.get(e), a = await M.getUserEquipmentsCharacteristics(
1404
1405
  r
1405
- ), s = Q(
1406
+ ), s = Y(
1406
1407
  await this.getTotalCharacteristics(e),
1407
1408
  a,
1408
1409
  (i, u) => i + u
@@ -1426,7 +1427,7 @@ class pn extends f {
1426
1427
  for (const r of Object.values(t.buffs))
1427
1428
  for (const a of Object.values(r))
1428
1429
  for (const { multiplier: s, startAt: i, expireAt: u } of a)
1429
- if (s < 0 && (!u || !de(u)) && (i ?? /* @__PURE__ */ new Date()) <= /* @__PURE__ */ new Date())
1430
+ if (s < 0 && (!u || !le(u)) && (i ?? /* @__PURE__ */ new Date()) <= /* @__PURE__ */ new Date())
1430
1431
  return !0;
1431
1432
  return !1;
1432
1433
  }
@@ -1577,15 +1578,15 @@ class pn extends f {
1577
1578
  });
1578
1579
  }
1579
1580
  async updatePanoplyBuff(e, t, r, a) {
1580
- const s = await U.fromDBToEquipableEquipment(t), i = L(Object.values(r)), o = (await _.getAllPopulated()).find(
1581
- (h) => h.panoplyId === s.panoply
1581
+ const s = await T.fromDBToEquipableEquipment(t), i = Q(Object.values(r)), c = (await N.getAllPopulated()).find(
1582
+ (g) => g.panoplyId === s.panoply
1582
1583
  );
1583
- if (!o)
1584
+ if (!c)
1584
1585
  return;
1585
- const m = o.equipments.filter(
1586
- (h) => (i.find((b) => h.entityId === b.entityId) || !a && s.entityId === h.entityId) && (a ? s.entityId !== h.entityId : !0)
1587
- ).length, $ = m === o.equipments.length ? o.fullBonus : m >= o.equipments.length / 2 ? o.halfBonus : void 0;
1588
- o.halfBonus && "target" in o.halfBonus && await this.removeBuff(e, o.halfBonus), o.fullBonus && "target" in o.fullBonus && await this.removeBuff(e, o.fullBonus), $ && "target" in $ && await this.updateBuff(e, $);
1586
+ const f = c.equipments.filter(
1587
+ (g) => (i.find((S) => g.entityId === S.entityId) || !a && s.entityId === g.entityId) && (a ? s.entityId !== g.entityId : !0)
1588
+ ).length, h = f === c.equipments.length ? c.fullBonus : f >= c.equipments.length / 2 ? c.halfBonus : void 0;
1589
+ c.halfBonus && "target" in c.halfBonus && await this.removeBuff(e, c.halfBonus), c.fullBonus && "target" in c.fullBonus && await this.removeBuff(e, c.fullBonus), h && "target" in h && await this.updateBuff(e, h);
1589
1590
  }
1590
1591
  async gainHp(e, t) {
1591
1592
  const r = await this.get(e), s = await this.getMaxHp(e) - r.hp;
@@ -1695,7 +1696,7 @@ const yn = (n) => D.find(n).lean(), fn = async (n) => await D.create({
1695
1696
  });
1696
1697
  async function mn(n) {
1697
1698
  const e = await D.findOne({ user: n }).lean();
1698
- return e || p(await fn(n));
1699
+ return e || y(await fn(n));
1699
1700
  }
1700
1701
  const hn = (n, e) => D.findOneAndUpdate({ user: n }, e, {
1701
1702
  returnDocument: "after",
@@ -1721,8 +1722,8 @@ class gn extends pn {
1721
1722
  return hn(e, t);
1722
1723
  }
1723
1724
  }
1724
- const E = new gn();
1725
- class Sn extends f {
1725
+ const v = new gn();
1726
+ class Sn extends w {
1726
1727
  async updateSendDailyQuest(e, t) {
1727
1728
  await this.update(e, { $set: { sendDailyQuest: t } });
1728
1729
  }
@@ -1741,14 +1742,14 @@ class Sn extends f {
1741
1742
  });
1742
1743
  }
1743
1744
  }
1744
- const wn = (n) => F.find(n).lean(), bn = async (n) => await F.create({
1745
+ const wn = (n) => K.find(n).lean(), bn = async (n) => await K.create({
1745
1746
  user: n
1746
1747
  });
1747
1748
  async function $n(n) {
1748
- const e = await F.findOne({ user: n }).lean();
1749
- return e || p(await bn(n));
1749
+ const e = await K.findOne({ user: n }).lean();
1750
+ return e || y(await bn(n));
1750
1751
  }
1751
- const In = (n, e) => F.findOneAndUpdate({ user: n }, e, {
1752
+ const In = (n, e) => K.findOneAndUpdate({ user: n }, e, {
1752
1753
  returnDocument: "after",
1753
1754
  upsert: !0
1754
1755
  }).lean();
@@ -1773,7 +1774,7 @@ class Un extends Sn {
1773
1774
  }
1774
1775
  }
1775
1776
  const Fe = new Un();
1776
- class Tn extends y {
1777
+ class Tn extends m {
1777
1778
  async getCommandCooldown(e, t) {
1778
1779
  return (await this.get(e)).commands[t];
1779
1780
  }
@@ -1782,7 +1783,7 @@ class Tn extends y {
1782
1783
  $set: {
1783
1784
  lockUserCommand: new Date(Date.now() + 2 * 3600 * 1e3)
1784
1785
  }
1785
- }), await E.gainHp(e, 1);
1786
+ }), await v.gainHp(e, 1);
1786
1787
  }
1787
1788
  async useCommand(e, t, r) {
1788
1789
  const { reminder: a } = await Fe.get(e);
@@ -1797,18 +1798,18 @@ class Tn extends y {
1797
1798
  );
1798
1799
  }
1799
1800
  }
1800
- const En = async (n) => await W.create({
1801
+ const En = async (n) => await V.create({
1801
1802
  user: n
1802
1803
  });
1803
- async function On(n) {
1804
- const e = await W.findOne({ user: n }).lean();
1805
- return e || p(await En(n));
1804
+ async function vn(n) {
1805
+ const e = await V.findOne({ user: n }).lean();
1806
+ return e || y(await En(n));
1806
1807
  }
1807
- const Dn = (n, e) => W.findOneAndUpdate({ user: n }, e, {
1808
+ const On = (n, e) => V.findOneAndUpdate({ user: n }, e, {
1808
1809
  returnDocument: "after",
1809
1810
  upsert: !0
1810
1811
  }).lean();
1811
- class vn extends Tn {
1812
+ class Dn extends Tn {
1812
1813
  constructor() {
1813
1814
  super(300);
1814
1815
  }
@@ -1819,14 +1820,14 @@ class vn extends Tn {
1819
1820
  return e.user;
1820
1821
  }
1821
1822
  fetchFromDb(e) {
1822
- return On(e);
1823
+ return vn(e);
1823
1824
  }
1824
1825
  updateInDb(e, t) {
1825
- return Dn(e, t);
1826
+ return On(e, t);
1826
1827
  }
1827
1828
  }
1828
- const Qa = new vn();
1829
- class Mn extends f {
1829
+ const Qa = new Dn();
1830
+ class xn extends w {
1830
1831
  async isOrnamentIds(e, t = () => !0) {
1831
1832
  const a = (await this.getAll()).filter(t).map(({ ornamentId: s }) => s);
1832
1833
  return e.every((s) => a.includes(s));
@@ -1865,12 +1866,12 @@ class Mn extends f {
1865
1866
  return (await this.getAll()).filter((e) => this.isShopTitle(e));
1866
1867
  }
1867
1868
  formatBackgroundId(e) {
1868
- const t = ot(e) ? e : e.ornamentId;
1869
+ const t = ct(e) ? e : e.ornamentId;
1869
1870
  return t === "background_default" ? "par défaut" : `"${dt(t.split("_").join(" "))}"`;
1870
1871
  }
1871
1872
  async getSomeShopTitles(e) {
1872
1873
  const t = await this.getAllShopTitles();
1873
- return pe(
1874
+ return ye(
1874
1875
  Se(
1875
1876
  e,
1876
1877
  t,
@@ -1882,7 +1883,7 @@ class Mn extends f {
1882
1883
  }
1883
1884
  async getSomeBackgrounds(e) {
1884
1885
  const t = await this.getAllBackgrounds();
1885
- return pe(
1886
+ return ye(
1886
1887
  Se(
1887
1888
  e,
1888
1889
  t,
@@ -1897,7 +1898,7 @@ class Mn extends f {
1897
1898
  throw new RangeError(
1898
1899
  "pickEachRarityOrnament - must give same number of odds than ranks"
1899
1900
  );
1900
- return L(
1901
+ return Q(
1901
1902
  t.map((r, a) => {
1902
1903
  const s = ge[a], i = e[s];
1903
1904
  return Math.random() > r || !i || !i.length ? null : lt(i);
@@ -1905,7 +1906,7 @@ class Mn extends f {
1905
1906
  );
1906
1907
  }
1907
1908
  }
1908
- const xn = new c(
1909
+ const Mn = new o(
1909
1910
  {
1910
1911
  ornamentId: { unique: !0, index: 1, required: !0, type: String },
1911
1912
  type: { required: !0, type: String },
@@ -1919,23 +1920,23 @@ const xn = new c(
1919
1920
  strength: Number
1920
1921
  },
1921
1922
  { minimize: !1 }
1922
- ), fe = d?.Ornaments || l("Ornaments", xn), An = async (n, e) => fe.find(n, {}, e).lean();
1923
- async function qn(n) {
1924
- const e = await fe.findOne({ ornamentId: n }).lean();
1923
+ ), me = d?.Ornaments || l("Ornaments", Mn), An = async (n, e) => me.find(n, {}, e).lean();
1924
+ async function kn(n) {
1925
+ const e = await me.findOne({ ornamentId: n }).lean();
1925
1926
  return e || null;
1926
1927
  }
1927
- const kn = (n, e) => fe.findOneAndUpdate(n, e, {
1928
+ const qn = (n, e) => me.findOneAndUpdate(n, e, {
1928
1929
  returnDocument: "after"
1929
1930
  }).lean();
1930
- class Rn extends Mn {
1931
+ class Rn extends xn {
1931
1932
  constructor() {
1932
1933
  super(3600);
1933
1934
  }
1934
1935
  updateInDb(e, t) {
1935
- return kn(e, t);
1936
+ return qn(e, t);
1936
1937
  }
1937
1938
  fetchFromDb(e) {
1938
- return qn(e);
1939
+ return kn(e);
1939
1940
  }
1940
1941
  fetchManyFromDb(e, t) {
1941
1942
  return An(e, t);
@@ -1947,13 +1948,13 @@ class Rn extends Mn {
1947
1948
  return e;
1948
1949
  }
1949
1950
  }
1950
- const I = new Rn();
1951
- class Cn extends y {
1951
+ const U = new Rn();
1952
+ class Cn extends m {
1952
1953
  async unlockTitle(e, t) {
1953
- await I.isOrnamentIds([t], I.isTitle) && await this.update(e, { $addToSet: { unlockedTitles: t } });
1954
+ await U.isOrnamentIds([t], U.isTitle) && await this.update(e, { $addToSet: { unlockedTitles: t } });
1954
1955
  }
1955
1956
  async unlockTitles(e, t) {
1956
- await I.isOrnamentIds(t, I.isTitle) && await this.update(e, {
1957
+ await U.isOrnamentIds(t, U.isTitle) && await this.update(e, {
1957
1958
  $addToSet: { unlockedTitles: { $each: t } }
1958
1959
  });
1959
1960
  }
@@ -1961,17 +1962,17 @@ class Cn extends y {
1961
1962
  await this.update(e, { $set: { selectedTitle: t } });
1962
1963
  }
1963
1964
  async unlockBackground(e, t) {
1964
- await I.isOrnamentIds(
1965
+ await U.isOrnamentIds(
1965
1966
  [t],
1966
- I.isBackground
1967
+ U.isBackground
1967
1968
  ) && await this.update(e, {
1968
1969
  $addToSet: { unlockedBackgrounds: t }
1969
1970
  });
1970
1971
  }
1971
1972
  async unlockBackgrounds(e, t) {
1972
- await I.isOrnamentIds(
1973
+ await U.isOrnamentIds(
1973
1974
  t,
1974
- I.isBackground
1975
+ U.isBackground
1975
1976
  ) && await this.update(e, {
1976
1977
  $addToSet: { unlockedBackgrounds: { $each: t } }
1977
1978
  });
@@ -2017,14 +2018,14 @@ class Cn extends y {
2017
2018
  });
2018
2019
  }
2019
2020
  }
2020
- const Bn = async (n) => await ee.create({
2021
+ const Bn = async (n) => await te.create({
2021
2022
  user: n
2022
2023
  });
2023
2024
  async function _n(n) {
2024
- const e = await ee.findOne({ user: n }).lean();
2025
- return e || p(await Bn(n));
2025
+ const e = await te.findOne({ user: n }).lean();
2026
+ return e || y(await Bn(n));
2026
2027
  }
2027
- const Fn = async (n, e) => ee.findOneAndUpdate({ user: n }, e, {
2028
+ const Fn = async (n, e) => te.findOneAndUpdate({ user: n }, e, {
2028
2029
  upsert: !0,
2029
2030
  returnDocument: "after"
2030
2031
  }).lean();
@@ -2046,7 +2047,7 @@ class Nn extends Cn {
2046
2047
  }
2047
2048
  }
2048
2049
  const we = new Nn();
2049
- class Kn extends f {
2050
+ class Kn extends w {
2050
2051
  async getStatus(e, t) {
2051
2052
  return (await this.get({ user: e, questId: t })).status;
2052
2053
  }
@@ -2055,17 +2056,17 @@ class Kn extends f {
2055
2056
  }
2056
2057
  async isStreaking(e, t) {
2057
2058
  const { lastCompletionDate: r } = await this.get({ user: e, questId: t });
2058
- return !!r && Oe(Y(), r);
2059
+ return !!r && ve(G(), r);
2059
2060
  }
2060
2061
  async getStreakMultiplier(e, t) {
2061
2062
  const r = await this.get({ user: e, questId: t });
2062
2063
  return await this.isStreaking(e, t) ? 1 + Math.min(2, (r.streak ?? 0) / 10) : 1;
2063
2064
  }
2064
2065
  async getCompletedCount(e) {
2065
- return (await this.getMany({ user: e, status: A.COMPLETED })).length;
2066
+ return (await this.getMany({ user: e, status: k.COMPLETED })).length;
2066
2067
  }
2067
2068
  async completeQuest(e, t = !1) {
2068
- const r = Y();
2069
+ const r = G();
2069
2070
  r.setHours(0, 0, 0, 0);
2070
2071
  const a = /* @__PURE__ */ new Date();
2071
2072
  return a.setHours(0, 0, 0, 0), this.update(
@@ -2088,7 +2089,7 @@ class Kn extends f {
2088
2089
  }
2089
2090
  } : {},
2090
2091
  lastCompletionDate: /* @__PURE__ */ new Date(),
2091
- status: A.COMPLETED
2092
+ status: k.COMPLETED
2092
2093
  }
2093
2094
  }
2094
2095
  ],
@@ -2097,17 +2098,17 @@ class Kn extends f {
2097
2098
  }
2098
2099
  }
2099
2100
  function Hn(n) {
2100
- return R.find(n).lean();
2101
+ return C.find(n).lean();
2101
2102
  }
2102
- const Pn = async (n) => await R.create({
2103
+ const Pn = async (n) => await C.create({
2103
2104
  ...n
2104
2105
  });
2105
2106
  async function jn(n) {
2106
- const e = await R.findOne(n).lean();
2107
- return e || p(await Pn(n));
2107
+ const e = await C.findOne(n).lean();
2108
+ return e || y(await Pn(n));
2108
2109
  }
2109
2110
  function zn(n, e, t) {
2110
- return R.findOneAndUpdate(n, e, {
2111
+ return C.findOneAndUpdate(n, e, {
2111
2112
  upsert: !0,
2112
2113
  ...t,
2113
2114
  returnDocument: "after"
@@ -2137,7 +2138,7 @@ class Ln extends Kn {
2137
2138
  }
2138
2139
  }
2139
2140
  const be = new Ln();
2140
- class Qn extends y {
2141
+ class Qn extends m {
2141
2142
  async randomMessageIncrement(e) {
2142
2143
  await this.update(e, { $inc: { randomMessageClaimed: 1 } });
2143
2144
  }
@@ -2155,14 +2156,14 @@ class Qn extends y {
2155
2156
  await this.update(e, { $inc: { totalMinutesInVoice: t } });
2156
2157
  }
2157
2158
  }
2158
- const Yn = async (n) => await ne.create({
2159
+ const Yn = async (n) => await re.create({
2159
2160
  user: n
2160
2161
  });
2161
2162
  async function Gn(n) {
2162
- const e = await ne.findOne({ user: n }).lean();
2163
- return e || p(await Yn(n));
2163
+ const e = await re.findOne({ user: n }).lean();
2164
+ return e || y(await Yn(n));
2164
2165
  }
2165
- const Wn = (n, e) => ne.findOneAndUpdate({ user: n }, e, {
2166
+ const Wn = (n, e) => re.findOneAndUpdate({ user: n }, e, {
2166
2167
  upsert: !0,
2167
2168
  returnDocument: "after"
2168
2169
  }).lean();
@@ -2186,11 +2187,11 @@ class Vn extends Qn {
2186
2187
  }
2187
2188
  }
2188
2189
  const $e = new Vn();
2189
- class Xn extends y {
2190
+ class Xn extends m {
2190
2191
  async updateDailyReport(e) {
2191
- const t = await E.get(e), r = await we.get(e), a = await be.getMany({
2192
+ const t = await v.get(e), r = await we.get(e), a = await be.getMany({
2192
2193
  user: e,
2193
- status: A.COMPLETED
2194
+ status: k.COMPLETED
2194
2195
  }), s = await $e.get(e);
2195
2196
  await this.update(e, {
2196
2197
  $set: {
@@ -2213,22 +2214,22 @@ class Xn extends y {
2213
2214
  xpYesterday: a,
2214
2215
  berryYesterday: s,
2215
2216
  previousMessageSent: i
2216
- } = await this.get(e), u = await E.get(e), o = await be.getMany({
2217
+ } = await this.get(e), u = await v.get(e), c = await be.getMany({
2217
2218
  user: e,
2218
- status: A.COMPLETED
2219
- }), m = await we.get(e), $ = await $e.get(e), { berry: h, xp: b } = u, { voice: he, amount: He } = b, { unlockedBadges: Pe, unlockedBackgrounds: je, unlockedTitles: ze } = m;
2219
+ status: k.COMPLETED
2220
+ }), f = await we.get(e), h = await $e.get(e), { berry: g, xp: S } = u, { voice: p, amount: He } = S, { unlockedBadges: Pe, unlockedBackgrounds: je, unlockedTitles: ze } = f;
2220
2221
  return {
2221
- berry: h - s,
2222
+ berry: g - s,
2222
2223
  xp: He - a,
2223
- message: $.messageSent - i,
2224
- voice: Oe(he.lastConnection, Y()) ? he.minutesInVoiceToday : 0,
2225
- quest: P(
2226
- o.map(({ questId: Le }) => Le),
2224
+ message: h.messageSent - i,
2225
+ voice: ve(p.lastConnection, G()) ? p.minutesInVoiceToday : 0,
2226
+ quest: z(
2227
+ c.map(({ questId: Le }) => Le),
2227
2228
  r
2228
2229
  ),
2229
- badge: P(Pe, t.unlockedBadges),
2230
- title: P(ze, t.unlockedTitles),
2231
- background: P(
2230
+ badge: z(Pe, t.unlockedBadges),
2231
+ title: z(ze, t.unlockedTitles),
2232
+ background: z(
2232
2233
  je,
2233
2234
  t.unlockedBackgrounds
2234
2235
  )
@@ -2248,14 +2249,14 @@ class Xn extends y {
2248
2249
  );
2249
2250
  }
2250
2251
  }
2251
- const Jn = (n) => V.create({
2252
+ const Jn = (n) => X.create({
2252
2253
  user: n
2253
2254
  });
2254
2255
  async function Zn(n) {
2255
- const e = await V.findOne({ user: n }).lean();
2256
- return e || p(await Jn(n));
2256
+ const e = await X.findOne({ user: n }).lean();
2257
+ return e || y(await Jn(n));
2257
2258
  }
2258
- const er = (n, e) => V.findOneAndUpdate({ user: n }, e, {
2259
+ const er = (n, e) => X.findOneAndUpdate({ user: n }, e, {
2259
2260
  upsert: !0,
2260
2261
  returnDocument: "after"
2261
2262
  }).lean();
@@ -2277,7 +2278,7 @@ class tr extends Xn {
2277
2278
  }
2278
2279
  }
2279
2280
  const Ya = new tr();
2280
- class nr extends y {
2281
+ class nr extends m {
2281
2282
  async setGuessGame(e, t, r, a) {
2282
2283
  await this.update(e, {
2283
2284
  $set: {
@@ -2308,14 +2309,14 @@ class nr extends y {
2308
2309
  });
2309
2310
  }
2310
2311
  }
2311
- const rr = async (n) => await J.create({
2312
+ const rr = async (n) => await Z.create({
2312
2313
  user: n
2313
2314
  });
2314
2315
  async function ar(n) {
2315
- const e = await J.findOne({ user: n }).lean();
2316
- return e || p(await rr(n));
2316
+ const e = await Z.findOne({ user: n }).lean();
2317
+ return e || y(await rr(n));
2317
2318
  }
2318
- const sr = (n, e) => J.findOneAndUpdate({ user: n }, e, {
2319
+ const sr = (n, e) => Z.findOneAndUpdate({ user: n }, e, {
2319
2320
  upsert: !0,
2320
2321
  returnDocument: "after"
2321
2322
  }).lean();
@@ -2336,9 +2337,9 @@ class ir extends nr {
2336
2337
  return sr(e, t);
2337
2338
  }
2338
2339
  }
2339
- const Ga = new ir(), ur = new c({
2340
+ const Ga = new ir(), ur = new o({
2340
2341
  user: {
2341
- type: c.Types.ObjectId,
2342
+ type: o.Types.ObjectId,
2342
2343
  required: !0,
2343
2344
  unique: !0,
2344
2345
  ref: "User"
@@ -2346,8 +2347,8 @@ const Ga = new ir(), ur = new c({
2346
2347
  xp: { type: Number, default: 0 },
2347
2348
  berry: { type: Number, default: 0 },
2348
2349
  faction: { type: Number, default: 0 }
2349
- }), x = d?.UserRank || l("UserRank", ur);
2350
- class cr extends y {
2350
+ }), A = d?.UserRank || l("UserRank", ur);
2351
+ class or extends m {
2351
2352
  async computeAllXpRanks() {
2352
2353
  const t = (await D.aggregate([
2353
2354
  {
@@ -2364,7 +2365,7 @@ class cr extends y {
2364
2365
  upsert: !0
2365
2366
  }
2366
2367
  }));
2367
- t.length > 0 && await x.bulkWrite(t), this.clearAll();
2368
+ t.length > 0 && await A.bulkWrite(t), this.clearAll();
2368
2369
  }
2369
2370
  async computeAllBerryRanks() {
2370
2371
  const t = (await D.aggregate([
@@ -2382,10 +2383,10 @@ class cr extends y {
2382
2383
  upsert: !0
2383
2384
  }
2384
2385
  }));
2385
- t.length > 0 && await x.bulkWrite(t), this.clearAll();
2386
+ t.length > 0 && await A.bulkWrite(t), this.clearAll();
2386
2387
  }
2387
2388
  async computeAllFactionRanks() {
2388
- const t = (await w.aggregate([
2389
+ const t = (await I.aggregate([
2389
2390
  {
2390
2391
  $lookup: {
2391
2392
  from: "usermetas",
@@ -2410,7 +2411,7 @@ class cr extends y {
2410
2411
  upsert: !0
2411
2412
  }
2412
2413
  }));
2413
- t.length > 0 && await x.bulkWrite(t), this.clearAll();
2414
+ t.length > 0 && await A.bulkWrite(t), this.clearAll();
2414
2415
  }
2415
2416
  async computeAllRanks() {
2416
2417
  await Promise.all([
@@ -2420,18 +2421,18 @@ class cr extends y {
2420
2421
  ]);
2421
2422
  }
2422
2423
  }
2423
- const or = async (n) => await x.create({
2424
+ const cr = async (n) => await A.create({
2424
2425
  user: n
2425
2426
  });
2426
2427
  async function dr(n) {
2427
- const e = await x.findOne({ user: n }).lean();
2428
- return e || p(await or(n));
2428
+ const e = await A.findOne({ user: n }).lean();
2429
+ return e || y(await cr(n));
2429
2430
  }
2430
- const lr = (n, e) => x.findOneAndUpdate({ user: n }, e, {
2431
+ const lr = (n, e) => A.findOneAndUpdate({ user: n }, e, {
2431
2432
  returnDocument: "after",
2432
2433
  upsert: !0
2433
2434
  }).lean();
2434
- class pr extends cr {
2435
+ class pr extends or {
2435
2436
  constructor() {
2436
2437
  super(300);
2437
2438
  }
@@ -2448,14 +2449,15 @@ class pr extends cr {
2448
2449
  return lr(e, t);
2449
2450
  }
2450
2451
  }
2451
- const Wa = new pr(), yr = new c(
2452
+ const Wa = new pr(), yr = new o(
2452
2453
  {
2453
2454
  speakerId: { type: String, required: !0 },
2454
2455
  order: { type: Number },
2456
+ index: { type: Number },
2455
2457
  args: { type: [String], enum: nt, default: void 0 }
2456
2458
  },
2457
2459
  { _id: !1 }
2458
- ), fr = new c(
2460
+ ), fr = new o(
2459
2461
  {
2460
2462
  stepId: { type: String, required: !0 },
2461
2463
  type: {
@@ -2465,11 +2467,11 @@ const Wa = new pr(), yr = new c(
2465
2467
  },
2466
2468
  actionType: { type: String, enum: rt },
2467
2469
  messages: { type: [yr], default: void 0 },
2468
- payload: { type: c.Types.Mixed, default: void 0 },
2470
+ payload: { type: o.Types.Mixed, default: void 0 },
2469
2471
  next: { type: String }
2470
2472
  },
2471
2473
  { _id: !1 }
2472
- ), mr = new c(
2474
+ ), mr = new o(
2473
2475
  {
2474
2476
  sceneId: { type: String, required: !0 },
2475
2477
  steps: { type: Map, of: fr, required: !0 },
@@ -2477,7 +2479,7 @@ const Wa = new pr(), yr = new c(
2477
2479
  next: { type: String }
2478
2480
  },
2479
2481
  { _id: !1 }
2480
- ), hr = new c(
2482
+ ), hr = new o(
2481
2483
  {
2482
2484
  chapterId: { type: String, required: !0 },
2483
2485
  scenes: { type: Map, of: mr, required: !0 },
@@ -2485,7 +2487,7 @@ const Wa = new pr(), yr = new c(
2485
2487
  next: { type: String }
2486
2488
  },
2487
2489
  { _id: !1 }
2488
- ), gr = new c(
2490
+ ), gr = new o(
2489
2491
  {
2490
2492
  type: {
2491
2493
  type: String,
@@ -2495,7 +2497,7 @@ const Wa = new pr(), yr = new c(
2495
2497
  speakerId: { type: String, required: !0 }
2496
2498
  },
2497
2499
  { _id: !1 }
2498
- ), Ne = new c({
2500
+ ), Ne = new o({
2499
2501
  storyId: {
2500
2502
  type: String,
2501
2503
  required: !0,
@@ -2508,20 +2510,24 @@ const Wa = new pr(), yr = new c(
2508
2510
  Ne.pre("findOneAndUpdate", function() {
2509
2511
  this.setOptions({ runValidators: !0 });
2510
2512
  });
2511
- const ae = d?.Story || l("Story", Ne), Sr = async (n) => await ae.create(n), j = {
2513
+ const se = d?.Story || l("Story", Ne), Sr = async (n) => await se.create(n), _ = {
2512
2514
  storyId: "main",
2513
2515
  speakers: it,
2514
2516
  chapters: {
2515
- [oe.chapterId]: oe
2517
+ [de.chapterId]: de
2516
2518
  },
2517
- entryChapterId: oe.chapterId
2519
+ entryChapterId: de.chapterId
2518
2520
  };
2519
- class wr extends f {
2521
+ class wr extends w {
2520
2522
  async seed() {
2521
- return await this.get(j.storyId) ? this.update({ storyId: j.storyId }, { $set: j }) : Sr(j);
2523
+ return await this.get(_.storyId) ? this.update({ storyId: _.storyId }, { $set: _ }) : Sr(_);
2524
+ }
2525
+ async getStep(e, t, r) {
2526
+ const a = await this.get(_.storyId);
2527
+ return a ? a.chapters?.[e]?.scenes?.[t]?.steps?.[r] : null;
2522
2528
  }
2523
2529
  }
2524
- const br = (n, e = {}) => ae.find(n, null, e).lean(), $r = (n) => ae.findOne({ storyId: n }).lean(), Ir = (n, e) => ae.findOneAndUpdate({ storyId: n }, e, {
2530
+ const br = (n, e = {}) => se.find(n, null, e).lean(), $r = (n) => se.findOne({ storyId: n }).lean(), Ir = (n, e) => se.findOneAndUpdate({ storyId: n }, e, {
2525
2531
  returnDocument: "after"
2526
2532
  }).lean();
2527
2533
  class Ur extends wr {
@@ -2545,7 +2551,7 @@ class Ur extends wr {
2545
2551
  return Ir(r, t);
2546
2552
  }
2547
2553
  }
2548
- const T = new Ur(), Tr = new c(
2554
+ const E = new Ur(), Tr = new o(
2549
2555
  {
2550
2556
  chapterId: { type: String, required: !0 },
2551
2557
  sceneId: { type: String, required: !0 },
@@ -2553,9 +2559,9 @@ const T = new Ur(), Tr = new c(
2553
2559
  value: { type: String, required: !0 }
2554
2560
  },
2555
2561
  { _id: !1 }
2556
- ), Ke = new c({
2562
+ ), Ke = new o({
2557
2563
  user: {
2558
- type: c.Types.ObjectId,
2564
+ type: o.Types.ObjectId,
2559
2565
  required: !0,
2560
2566
  ref: "User",
2561
2567
  index: !0
@@ -2576,20 +2582,20 @@ const T = new Ur(), Tr = new c(
2576
2582
  choices: { type: [Tr], default: [] }
2577
2583
  });
2578
2584
  Ke.index({ user: 1, storyId: 1 }, { unique: !0 });
2579
- const H = d?.UserStory || l("UserStory", Ke), Er = async (n, e, t, r, a) => await H.create({
2585
+ const j = d?.UserStory || l("UserStory", Ke), Er = async (n, e, t, r, a) => await j.create({
2580
2586
  user: n,
2581
2587
  storyId: e,
2582
2588
  currentChapterId: t,
2583
2589
  currentSceneId: r,
2584
2590
  currentStepId: a,
2585
2591
  status: "in_progress"
2586
- }), Or = (n, e) => H.deleteOne({ user: n, storyId: e }).then(() => {
2587
- }), Dr = (n, e, t, r) => {
2592
+ }), vr = (n, e) => j.deleteOne({ user: n, storyId: e }).then(() => {
2593
+ }), Or = (n, e, t, r) => {
2588
2594
  const a = n.chapters[e];
2589
2595
  if (!a) return null;
2590
2596
  const s = a.scenes[t];
2591
2597
  if (!s) return null;
2592
- if (s.steps[r])
2598
+ if (r && s.steps[r])
2593
2599
  return { chapterId: e, sceneId: t, stepId: r };
2594
2600
  if (s.next) {
2595
2601
  const i = a.scenes[s.next];
@@ -2613,101 +2619,113 @@ const H = d?.UserStory || l("UserStory", Ke), Er = async (n, e, t, r, a) => awai
2613
2619
  }
2614
2620
  }
2615
2621
  return null;
2616
- }, z = (n, e) => {
2622
+ }, L = (n, e) => {
2617
2623
  const t = n.chapters[e.currentChapterId];
2618
2624
  if (!t) return null;
2619
2625
  const r = t.scenes[e.currentSceneId];
2620
2626
  return r ? r.steps[e.currentStepId] ?? null : null;
2621
- }, vr = (n, e, t, r, a) => {
2627
+ }, Dr = (n, e, t, r, a) => {
2622
2628
  const s = [], i = /* @__PURE__ */ new Set();
2623
2629
  let u = n.entryStepId;
2624
2630
  for (; u && !i.has(u); ) {
2625
2631
  i.add(u);
2626
- const o = n.steps[u];
2627
- if (!o) break;
2628
- if (o.type !== "action") {
2629
- if (s.push({ step: o }), u === a) break;
2630
- u = o.next;
2632
+ const c = n.steps[u];
2633
+ if (!c) break;
2634
+ if (c.type !== "action") {
2635
+ if (s.push({ step: c }), u === a) break;
2636
+ u = c.next;
2631
2637
  continue;
2632
2638
  }
2633
- if (o.actionType === "button") {
2634
- const $ = e.find(
2635
- (b) => b.chapterId === t && b.sceneId === r && b.stepId === u
2639
+ if (c.actionType === "button") {
2640
+ const f = e.find(
2641
+ (g) => g.chapterId === t && g.sceneId === r && g.stepId === u
2636
2642
  );
2637
- if (!$) {
2638
- s.push({ step: o });
2643
+ if (!f) {
2644
+ s.push({ step: c });
2639
2645
  break;
2640
2646
  }
2641
- const h = o.payload.find(
2642
- (b) => b.actionId === $.value
2647
+ const h = c.payload.find(
2648
+ (g) => g.actionId === f.value
2643
2649
  );
2644
- if (!h || (s.push({ step: o, selectedAction: h }), u === a)) break;
2650
+ if (!h || (s.push({ step: c, selectedAction: h }), u === a)) break;
2645
2651
  u = h.next;
2646
2652
  continue;
2647
2653
  }
2648
- if (s.push({ step: o }), u === a) break;
2649
- u = o.payload[0]?.next;
2654
+ if (c.actionType === "command") {
2655
+ const f = u, h = Array.from(
2656
+ new Set(
2657
+ e.filter(
2658
+ (S) => S.chapterId === t && S.sceneId === r && S.stepId === f
2659
+ ).map((S) => S.value)
2660
+ )
2661
+ );
2662
+ if (s.push({ step: c, validatedActionIds: h }), !c.payload.every(
2663
+ (S) => h.includes(S.actionId)
2664
+ ) || u === a) break;
2665
+ u = c.next;
2666
+ }
2650
2667
  }
2651
2668
  return s;
2652
2669
  };
2653
- class Mr extends f {
2670
+ class xr extends w {
2654
2671
  async getCurrentStep(e, t) {
2655
2672
  const r = await this.get({ user: e, storyId: t });
2656
2673
  if (!r) return null;
2657
- const a = await T.get(t);
2658
- return a ? z(a, r) : null;
2674
+ const a = await E.get(t);
2675
+ return a ? L(a, r) : null;
2659
2676
  }
2660
2677
  async getSceneSteps(e, t, r, a) {
2661
2678
  const s = await this.get({ user: e, storyId: t });
2662
2679
  if (!s) return null;
2663
- const i = await T.get(t);
2680
+ const i = await E.get(t);
2664
2681
  if (!i) return null;
2665
2682
  const u = i.chapters[r];
2666
2683
  if (!u) return null;
2667
- const o = u.scenes[a];
2668
- if (!o) return null;
2669
- const m = s.status === "in_progress" && s.currentChapterId === r && s.currentSceneId === a;
2670
- return vr(
2671
- o,
2684
+ const c = u.scenes[a];
2685
+ if (!c) return null;
2686
+ const f = s.status === "in_progress" && s.currentChapterId === r && s.currentSceneId === a;
2687
+ return Dr(
2688
+ c,
2672
2689
  s.choices,
2673
2690
  r,
2674
2691
  a,
2675
- m ? s.currentStepId : void 0
2692
+ f ? s.currentStepId : void 0
2676
2693
  );
2677
2694
  }
2678
2695
  async start(e, t) {
2679
- const r = await T.get(t);
2696
+ const r = await E.get(t);
2680
2697
  if (!r) return null;
2681
2698
  const a = r.chapters[r.entryChapterId];
2682
2699
  if (!a) return null;
2683
2700
  const s = a.scenes[a.entrySceneId];
2684
2701
  if (!s) return null;
2685
- await Or(e, t), this.invalidate({ user: e, storyId: t });
2702
+ await vr(e, t), this.invalidate({ user: e, storyId: t });
2686
2703
  const i = await Er(
2687
2704
  e,
2688
2705
  t,
2689
2706
  r.entryChapterId,
2690
2707
  a.entrySceneId,
2691
2708
  s.entryStepId
2692
- ), u = p(i);
2709
+ ), u = y(i);
2693
2710
  return this.cache.set(this.normalizeKey({ user: e, storyId: t }), u), u;
2694
2711
  }
2695
2712
  async advanceToNext(e, t) {
2696
2713
  const r = await this.get({ user: e, storyId: t });
2697
- if (!r) return { status: "error" };
2714
+ if (!r) return { status: "error", message: "user story not found" };
2698
2715
  if (r.status === "completed") return { status: "completed" };
2699
- const a = await T.get(t);
2700
- if (!a) return { status: "error" };
2701
- const s = z(a, r);
2702
- if (!s) return { status: "error" };
2716
+ const a = await E.get(t);
2717
+ if (!a) return { status: "error", message: "story not found" };
2718
+ const s = L(a, r);
2719
+ if (!s) return { status: "error", message: "current step not found" };
2703
2720
  if (s.type === "action") return { status: "action_required" };
2704
2721
  if (!s.next) return { status: "scene_ended" };
2705
2722
  const i = a.chapters[r.currentChapterId];
2706
- if (!i) return { status: "error" };
2723
+ if (!i)
2724
+ return { status: "error", message: "current chapter not found" };
2707
2725
  const u = i.scenes[r.currentSceneId];
2708
- if (!u) return { status: "error" };
2726
+ if (!u) return { status: "error", message: "current scene not found" };
2709
2727
  if (!u.steps[s.next]) return { status: "scene_ended" };
2710
- const o = await this.advanceTo(
2728
+ const c = await this.advanceTo(
2711
2729
  e,
2712
2730
  t,
2713
2731
  a,
@@ -2715,12 +2733,12 @@ class Mr extends f {
2715
2733
  r.currentSceneId,
2716
2734
  s.next
2717
2735
  );
2718
- return o ? { status: "advanced", data: o } : { status: "error" };
2736
+ return c ? { status: "advanced", data: c } : { status: "error", message: "failed to advance step" };
2719
2737
  }
2720
2738
  async advanceToNextScene(e, t) {
2721
2739
  const r = await this.get({ user: e, storyId: t });
2722
2740
  if (!r || r.status === "completed") return null;
2723
- const a = await T.get(t);
2741
+ const a = await E.get(t);
2724
2742
  if (!a) return null;
2725
2743
  const s = a.chapters[r.currentChapterId];
2726
2744
  if (!s) return null;
@@ -2739,30 +2757,74 @@ class Mr extends f {
2739
2757
  }
2740
2758
  async validateCommandAndAdvance(e, t, r) {
2741
2759
  const a = await this.get({ user: e, storyId: t });
2742
- if (!a || a.status === "completed") return null;
2743
- const s = await T.get(t);
2744
- if (!s) return null;
2745
- const i = z(s, a);
2760
+ if (!a || a.status === "completed")
2761
+ return {
2762
+ status: "error",
2763
+ message: "user story not found or already completed"
2764
+ };
2765
+ const s = await E.get(t);
2766
+ if (!s) return { status: "error", message: "story not found" };
2767
+ const i = L(s, a);
2746
2768
  if (!i || i.type !== "action" || i.actionType !== "command")
2747
- return null;
2748
- const u = i.payload.find((o) => o.commandId === r);
2749
- return u ? this.advanceTo(
2769
+ return {
2770
+ status: "error",
2771
+ message: "current step is not a command action"
2772
+ };
2773
+ const u = i.payload.find((p) => p.commandId === r);
2774
+ if (!u)
2775
+ return {
2776
+ status: "error",
2777
+ message: `command "${r}" not in step payload`
2778
+ };
2779
+ const c = {
2780
+ chapterId: a.currentChapterId,
2781
+ sceneId: a.currentSceneId,
2782
+ stepId: a.currentStepId,
2783
+ value: u.actionId
2784
+ }, f = a.choices.some(
2785
+ (p) => p.chapterId === c.chapterId && p.sceneId === c.sceneId && p.stepId === c.stepId && p.value === u.actionId
2786
+ ), h = new Set(
2787
+ a.choices.filter(
2788
+ (p) => p.chapterId === c.chapterId && p.sceneId === c.sceneId && p.stepId === c.stepId
2789
+ ).map((p) => p.value)
2790
+ );
2791
+ if (h.add(u.actionId), !i.payload.every(
2792
+ (p) => h.has(p.actionId)
2793
+ )) {
2794
+ if (f)
2795
+ return {
2796
+ status: "partial",
2797
+ data: a
2798
+ };
2799
+ const p = await this.update(
2800
+ { user: e, storyId: t },
2801
+ { $push: { choices: c } }
2802
+ );
2803
+ return p ? {
2804
+ status: "partial",
2805
+ data: p,
2806
+ feedbackStepId: u.next
2807
+ } : { status: "error", message: "failed to record command" };
2808
+ }
2809
+ const S = await this.advanceTo(
2750
2810
  e,
2751
2811
  t,
2752
2812
  s,
2753
2813
  a.currentChapterId,
2754
2814
  a.currentSceneId,
2755
- u.next
2756
- ) : null;
2815
+ i.next,
2816
+ f ? void 0 : c
2817
+ );
2818
+ return S ? { status: "advanced", data: S, feedbackStepId: u.next } : { status: "error", message: "failed to advance step" };
2757
2819
  }
2758
2820
  async validateActionAndAdvance(e, t, r) {
2759
2821
  const a = await this.get({ user: e, storyId: t });
2760
2822
  if (!a || a.status === "completed") return null;
2761
- const s = await T.get(t);
2823
+ const s = await E.get(t);
2762
2824
  if (!s) return null;
2763
- const i = z(s, a);
2825
+ const i = L(s, a);
2764
2826
  if (!i || i.type !== "action") return null;
2765
- const u = i.payload.find((o) => o.actionId === r);
2827
+ const u = i.payload.find((c) => c.actionId === r);
2766
2828
  return u ? this.advanceTo(
2767
2829
  e,
2768
2830
  t,
@@ -2779,14 +2841,14 @@ class Mr extends f {
2779
2841
  ) : null;
2780
2842
  }
2781
2843
  async advanceTo(e, t, r, a, s, i, u) {
2782
- const o = Dr(r, a, s, i);
2783
- return o ? this.update(
2844
+ const c = Or(r, a, s, i);
2845
+ return c ? this.update(
2784
2846
  { user: e, storyId: t },
2785
2847
  {
2786
2848
  $set: {
2787
- currentChapterId: o.chapterId,
2788
- currentSceneId: o.sceneId,
2789
- currentStepId: o.stepId
2849
+ currentChapterId: c.chapterId,
2850
+ currentSceneId: c.sceneId,
2851
+ currentStepId: c.stepId
2790
2852
  },
2791
2853
  ...u && { $push: { choices: u } }
2792
2854
  }
@@ -2799,12 +2861,12 @@ class Mr extends f {
2799
2861
  );
2800
2862
  }
2801
2863
  }
2802
- const xr = (n, e = {}) => H.find(n, null, e).lean(), Ar = (n, e) => H.findOne({ user: n, storyId: e }).lean(), qr = (n, e) => H.findOneAndUpdate(n, e, {
2864
+ const Mr = (n, e = {}) => j.find(n, null, e).lean(), Ar = (n, e) => j.findOne({ user: n, storyId: e }).lean(), kr = (n, e) => j.findOneAndUpdate(n, e, {
2803
2865
  returnDocument: "after"
2804
2866
  }).lean();
2805
- class kr extends Mr {
2867
+ class qr extends xr {
2806
2868
  constructor() {
2807
- super(120);
2869
+ super(1800, { maxKeys: 5e4 });
2808
2870
  }
2809
2871
  normalizeKey(e) {
2810
2872
  return `${e.user.toString()}:${e.storyId}`;
@@ -2816,14 +2878,14 @@ class kr extends Mr {
2816
2878
  return Ar(e.user, e.storyId);
2817
2879
  }
2818
2880
  fetchManyFromDb(e, t) {
2819
- return xr(e, t);
2881
+ return Mr(e, t);
2820
2882
  }
2821
2883
  updateInDb(e, t) {
2822
- return qr(e, t);
2884
+ return kr(e, t);
2823
2885
  }
2824
2886
  }
2825
- const Va = new kr();
2826
- class Rr extends y {
2887
+ const Va = new qr();
2888
+ class Rr extends m {
2827
2889
  async didSevenDoubleAtDoQ(e) {
2828
2890
  await this.update(e, {
2829
2891
  $inc: { "doubleOrQuit.sevenDoubleInARowCount": 1 }
@@ -2847,7 +2909,7 @@ class Rr extends y {
2847
2909
  await this.update(e, { $inc: { drawCount: 1 } });
2848
2910
  }
2849
2911
  async bet666(e) {
2850
- const t = Y();
2912
+ const t = G();
2851
2913
  t.setHours(0, 0, 0, 0);
2852
2914
  const r = /* @__PURE__ */ new Date();
2853
2915
  r.setHours(0, 0, 0, 0), await q.updateOne(
@@ -2907,7 +2969,7 @@ const Cr = async (n) => await q.create({
2907
2969
  });
2908
2970
  async function Br(n) {
2909
2971
  const e = await q.findOne({ user: n }).lean();
2910
- return e || p(await Cr(n));
2972
+ return e || y(await Cr(n));
2911
2973
  }
2912
2974
  const _r = (n, e) => q.findOneAndUpdate({ user: n }, e, {
2913
2975
  upsert: !0,
@@ -2931,7 +2993,7 @@ class Fr extends Rr {
2931
2993
  }
2932
2994
  }
2933
2995
  const Xa = new Fr();
2934
- class Nr extends y {
2996
+ class Nr extends m {
2935
2997
  async workIncrement(e) {
2936
2998
  await this.update(e, { $inc: { workCount: 1 } });
2937
2999
  }
@@ -2943,14 +3005,14 @@ class Nr extends y {
2943
3005
  });
2944
3006
  }
2945
3007
  }
2946
- const Kr = (n) => te.create({
3008
+ const Kr = (n) => ne.create({
2947
3009
  user: n
2948
3010
  });
2949
3011
  async function Hr(n) {
2950
- const e = await te.findOne({ user: n }).lean();
2951
- return e || p(await Kr(n));
3012
+ const e = await ne.findOne({ user: n }).lean();
3013
+ return e || y(await Kr(n));
2952
3014
  }
2953
- const Pr = (n, e) => te.findOneAndUpdate({ user: n }, e, {
3015
+ const Pr = (n, e) => ne.findOneAndUpdate({ user: n }, e, {
2954
3016
  upsert: !0,
2955
3017
  returnDocument: "after"
2956
3018
  }).lean();
@@ -2972,7 +3034,7 @@ class jr extends Nr {
2972
3034
  }
2973
3035
  }
2974
3036
  const Ja = new jr();
2975
- class zr extends y {
3037
+ class zr extends m {
2976
3038
  async hasReportedSomeone(e) {
2977
3039
  await this.update(e, { $set: { reportedSomeone: !0 } });
2978
3040
  }
@@ -3003,14 +3065,14 @@ class zr extends y {
3003
3065
  await this.update(e, { $set: { "gamblingFlags.lose10M": !0 } });
3004
3066
  }
3005
3067
  }
3006
- const Lr = async (n) => await re.create({
3068
+ const Lr = async (n) => await ae.create({
3007
3069
  user: n
3008
3070
  });
3009
3071
  async function Qr(n) {
3010
- const e = await re.findOne({ user: n }).lean();
3011
- return e || p(await Lr(n));
3072
+ const e = await ae.findOne({ user: n }).lean();
3073
+ return e || y(await Lr(n));
3012
3074
  }
3013
- const Yr = (n, e) => re.findOneAndUpdate({ user: n }, e, {
3075
+ const Yr = (n, e) => ae.findOneAndUpdate({ user: n }, e, {
3014
3076
  upsert: !0,
3015
3077
  returnDocument: "after"
3016
3078
  }).lean();
@@ -3032,7 +3094,7 @@ class Gr extends zr {
3032
3094
  }
3033
3095
  }
3034
3096
  const Za = new Gr();
3035
- class Wr extends y {
3097
+ class Wr extends m {
3036
3098
  async readEdito(e) {
3037
3099
  const t = /* @__PURE__ */ new Date();
3038
3100
  t.setHours(0, 0, 0, 0), await O.updateOne(
@@ -3076,7 +3138,7 @@ const Vr = async (n) => await O.create({
3076
3138
  });
3077
3139
  async function Xr(n) {
3078
3140
  const e = await O.findOne({ user: n }).lean();
3079
- return e || p(await Vr(n));
3141
+ return e || y(await Vr(n));
3080
3142
  }
3081
3143
  const Jr = (n, e) => O.findOneAndUpdate({ user: n }, e, {
3082
3144
  upsert: !0,
@@ -3100,10 +3162,10 @@ class Zr extends Wr {
3100
3162
  }
3101
3163
  }
3102
3164
  const es = new Zr();
3103
- class ea extends y {
3165
+ class ea extends m {
3104
3166
  async updateCraftStats(e, t, r) {
3105
- const a = await U.get(r);
3106
- !a || !U.isItem(a) || await this.update(e, {
3167
+ const a = await T.get(r);
3168
+ !a || !T.isItem(a) || await this.update(e, {
3107
3169
  $inc: {
3108
3170
  "crafts.totalCrafted": t
3109
3171
  }
@@ -3121,7 +3183,7 @@ class ea extends y {
3121
3183
  }
3122
3184
  async incrementBottleUsedToday(e, t) {
3123
3185
  const r = /* @__PURE__ */ new Date();
3124
- r.setHours(0, 0, 0, 0), await k.updateOne(
3186
+ r.setHours(0, 0, 0, 0), await R.updateOne(
3125
3187
  {
3126
3188
  user: e,
3127
3189
  "bottle.lastUsed": {
@@ -3132,7 +3194,7 @@ class ea extends y {
3132
3194
  $inc: { "bottle.usedToday": t },
3133
3195
  $set: { "bottle.lastUsed": /* @__PURE__ */ new Date() }
3134
3196
  }
3135
- ), await k.updateOne(
3197
+ ), await R.updateOne(
3136
3198
  {
3137
3199
  user: e,
3138
3200
  "bottle.lastUsed": {
@@ -3158,14 +3220,14 @@ class ea extends y {
3158
3220
  });
3159
3221
  }
3160
3222
  }
3161
- const ta = async (n) => await k.create({
3223
+ const ta = async (n) => await R.create({
3162
3224
  user: n
3163
3225
  });
3164
3226
  async function na(n) {
3165
- const e = await k.findOne({ user: n }).lean();
3166
- return e || p(await ta(n));
3227
+ const e = await R.findOne({ user: n }).lean();
3228
+ return e || y(await ta(n));
3167
3229
  }
3168
- const ra = (n, e) => k.findOneAndUpdate({ user: n }, e, {
3230
+ const ra = (n, e) => R.findOneAndUpdate({ user: n }, e, {
3169
3231
  upsert: !0,
3170
3232
  returnDocument: "after"
3171
3233
  }).lean();
@@ -3187,7 +3249,7 @@ class aa extends ea {
3187
3249
  }
3188
3250
  }
3189
3251
  const ts = new aa();
3190
- class sa extends f {
3252
+ class sa extends w {
3191
3253
  async maxCraftQuantity(e, t) {
3192
3254
  const r = await M.get(e);
3193
3255
  let a = 1 / 0;
@@ -3214,19 +3276,19 @@ class sa extends f {
3214
3276
  return t;
3215
3277
  }
3216
3278
  }
3217
- const ia = new c(
3279
+ const ia = new o(
3218
3280
  {
3219
3281
  entityId: { type: String, required: !0 },
3220
3282
  size: { type: Number, default: 1 }
3221
3283
  },
3222
3284
  { _id: !1 }
3223
- ), ua = new c(
3285
+ ), ua = new o(
3224
3286
  {
3225
3287
  entityId: { type: String, required: !0 },
3226
3288
  size: { type: Number }
3227
3289
  },
3228
3290
  { _id: !1 }
3229
- ), ca = new c(
3291
+ ), oa = new o(
3230
3292
  {
3231
3293
  recipeId: { type: String, unique: !0, required: !0 },
3232
3294
  rankId: String,
@@ -3235,14 +3297,14 @@ const ia = new c(
3235
3297
  result: { type: ua, required: !0 }
3236
3298
  },
3237
3299
  { minimize: !1 }
3238
- ), se = d?.Recipes || l("Recipes", ca), oa = async (n) => await se.create({
3300
+ ), ie = d?.Recipes || l("Recipes", oa), ca = async (n) => await ie.create({
3239
3301
  ...n
3240
- }), da = async (n, e) => se.find(n, {}, e).lean();
3302
+ }), da = async (n, e) => ie.find(n, {}, e).lean();
3241
3303
  async function la(n) {
3242
- const e = await se.findOne({ recipeId: n }).lean();
3304
+ const e = await ie.findOne({ recipeId: n }).lean();
3243
3305
  return e || null;
3244
3306
  }
3245
- const pa = (n, e) => se.findOneAndUpdate(n, e, {
3307
+ const pa = (n, e) => ie.findOneAndUpdate(n, e, {
3246
3308
  returnDocument: "after"
3247
3309
  }).lean();
3248
3310
  class ya extends sa {
@@ -3250,7 +3312,7 @@ class ya extends sa {
3250
3312
  super(3600);
3251
3313
  }
3252
3314
  createInDb(e) {
3253
- return oa(e);
3315
+ return ca(e);
3254
3316
  }
3255
3317
  updateInDb(e, t) {
3256
3318
  return pa(e, t);
@@ -3268,14 +3330,14 @@ class ya extends sa {
3268
3330
  return e.recipeId;
3269
3331
  }
3270
3332
  }
3271
- const ns = new ya(), fa = new c({
3333
+ const ns = new ya(), fa = new o({
3272
3334
  bannedUserId: { type: String, index: !0, required: !0 },
3273
3335
  authorId: { type: String, required: !0 },
3274
3336
  unbannedTimestamp: { type: Date, index: 1 },
3275
3337
  reason: { type: String, required: !0 },
3276
3338
  guildId: { type: String, required: !0 }
3277
- }), ie = d?.Bans || l("Bans", fa), ma = (n, e) => ie.deleteOne({ bannedUserId: n, guildId: e });
3278
- class ha extends f {
3339
+ }), ue = d?.Bans || l("Bans", fa), ma = (n, e) => ue.deleteOne({ bannedUserId: n, guildId: e });
3340
+ class ha extends w {
3279
3341
  async getUnbanUsers() {
3280
3342
  return this.getMany({
3281
3343
  unbannedTimestamp: { $lte: /* @__PURE__ */ new Date(), $ne: null }
@@ -3292,7 +3354,7 @@ class ha extends f {
3292
3354
  await ma(e, t), this.invalidate({ bannedUserId: e, guildId: t });
3293
3355
  }
3294
3356
  }
3295
- const ga = (n) => ie.find(n).lean(), Sa = (n) => ie.findOne(n).lean(), wa = (n, e) => ie.findOneAndUpdate(n, e, {
3357
+ const ga = (n) => ue.find(n).lean(), Sa = (n) => ue.findOne(n).lean(), wa = (n, e) => ue.findOneAndUpdate(n, e, {
3296
3358
  returnDocument: "after",
3297
3359
  upsert: !0
3298
3360
  }).lean();
@@ -3316,14 +3378,14 @@ class ba extends ha {
3316
3378
  return wa(e, t);
3317
3379
  }
3318
3380
  }
3319
- const rs = new ba(), $a = new c({
3381
+ const rs = new ba(), $a = new o({
3320
3382
  senderId: {
3321
- type: c.Types.ObjectId,
3383
+ type: o.Types.ObjectId,
3322
3384
  required: !0,
3323
3385
  ref: "User"
3324
3386
  },
3325
3387
  receiverId: {
3326
- type: c.Types.ObjectId,
3388
+ type: o.Types.ObjectId,
3327
3389
  required: !0,
3328
3390
  index: !0,
3329
3391
  ref: "User"
@@ -3333,14 +3395,14 @@ const rs = new ba(), $a = new c({
3333
3395
  meta: {
3334
3396
  rps: { type: String, default: void 0 }
3335
3397
  }
3336
- }), ue = d?.Invitation || l("Invitation", $a), Ia = (n) => ue.create({
3398
+ }), oe = d?.Invitation || l("Invitation", $a), Ia = (n) => oe.create({
3337
3399
  ...n
3338
3400
  }), Ua = async (n) => {
3339
- await ue.deleteMany({
3401
+ await oe.deleteMany({
3340
3402
  ...n
3341
3403
  });
3342
3404
  };
3343
- class Ta extends y {
3405
+ class Ta extends m {
3344
3406
  async sendInvitation({
3345
3407
  senderId: e,
3346
3408
  receiverId: t,
@@ -3357,12 +3419,12 @@ class Ta extends y {
3357
3419
  await Ua({ senderId: e, gameMode: r, receiverId: t }), this.invalidate({ senderId: e, gameMode: r, receiverId: t });
3358
3420
  }
3359
3421
  }
3360
- const Ea = (n) => ue.findOne({
3422
+ const Ea = (n) => oe.findOne({
3361
3423
  ...n
3362
- }).lean(), Oa = (n, e) => ue.findOneAndUpdate(n, e, {
3424
+ }).lean(), va = (n, e) => oe.findOneAndUpdate(n, e, {
3363
3425
  returnDocument: "after"
3364
3426
  }).lean();
3365
- class Da extends Ta {
3427
+ class Oa extends Ta {
3366
3428
  constructor() {
3367
3429
  super(3600);
3368
3430
  }
@@ -3380,11 +3442,11 @@ class Da extends Ta {
3380
3442
  return Ea(e);
3381
3443
  }
3382
3444
  updateInDb(e, t) {
3383
- return Oa(e, t);
3445
+ return va(e, t);
3384
3446
  }
3385
3447
  }
3386
- const as = new Da();
3387
- class va extends y {
3448
+ const as = new Oa();
3449
+ class Da extends m {
3388
3450
  async randomizeEditoPrice(e) {
3389
3451
  const t = Ee(100, 1001);
3390
3452
  return await this.update({ guildId: e }, { $set: { "edito.price": t } }), t;
@@ -3430,7 +3492,7 @@ class va extends y {
3430
3492
  );
3431
3493
  }
3432
3494
  }
3433
- const Ma = new c({
3495
+ const xa = new o({
3434
3496
  guildId: { type: String, required: !0, unique: !0 },
3435
3497
  ranking: {
3436
3498
  messageId: { type: String, default: null }
@@ -3478,16 +3540,16 @@ const Ma = new c({
3478
3540
  default: []
3479
3541
  }
3480
3542
  }
3481
- }), me = d?.Settings || l("Settings", Ma), xa = (n) => me.create({
3543
+ }), he = d?.Settings || l("Settings", xa), Ma = (n) => he.create({
3482
3544
  guildId: n
3483
3545
  }), Aa = async (n) => {
3484
- const e = await me.findOne({ guildId: n }).lean();
3485
- return e || p(await xa(n));
3486
- }, qa = (n, e) => me.findOneAndUpdate(n, e, {
3546
+ const e = await he.findOne({ guildId: n }).lean();
3547
+ return e || y(await Ma(n));
3548
+ }, ka = (n, e) => he.findOneAndUpdate(n, e, {
3487
3549
  upsert: !0,
3488
3550
  returnDocument: "after"
3489
3551
  }).lean();
3490
- class ka extends va {
3552
+ class qa extends Da {
3491
3553
  constructor() {
3492
3554
  super(3600 * 24 * 30);
3493
3555
  }
@@ -3501,10 +3563,10 @@ class ka extends va {
3501
3563
  return Aa(e);
3502
3564
  }
3503
3565
  updateInDb(e, t) {
3504
- return qa(e, t);
3566
+ return ka(e, t);
3505
3567
  }
3506
3568
  }
3507
- const ss = new ka(), Ra = new c({
3569
+ const ss = new qa(), Ra = new o({
3508
3570
  warnedUserId: { type: String, required: !0, index: !0 },
3509
3571
  authorId: String,
3510
3572
  date: { type: Date, default: Date.now() },
@@ -3512,7 +3574,7 @@ const ss = new ka(), Ra = new c({
3512
3574
  }), ce = d?.Warn || l("Warn", Ra), Ca = (n) => ce.countDocuments(n), Ba = (n) => ce.create({
3513
3575
  ...n
3514
3576
  }), _a = (n) => ce.findByIdAndDelete(n).lean();
3515
- class Fa extends f {
3577
+ class Fa extends w {
3516
3578
  getUserWarns(e) {
3517
3579
  return this.getMany({ warnedUserId: e });
3518
3580
  }
@@ -3551,29 +3613,29 @@ class Ka extends Fa {
3551
3613
  const is = new Ka(), us = (n) => {
3552
3614
  Qe(n);
3553
3615
  };
3554
- class cs extends Ye.ObjectId {
3616
+ class os extends Ye.ObjectId {
3555
3617
  }
3556
3618
  export {
3557
- cs as ObjectId,
3558
- S as QUEST_MIDDLEWARE_EVENT_NAME,
3619
+ os as ObjectId,
3620
+ $ as QUEST_MIDDLEWARE_EVENT_NAME,
3559
3621
  rs as banService,
3560
3622
  us as connectToServices,
3561
- g as emitQuestMiddlewareEvent,
3562
- U as entityService,
3623
+ b as emitQuestMiddlewareEvent,
3624
+ T as entityService,
3563
3625
  as as invitationService,
3564
- I as ornamentService,
3565
- _ as panoplyService,
3626
+ U as ornamentService,
3627
+ N as panoplyService,
3566
3628
  ns as recipeService,
3567
3629
  La as registerQuestMiddlewareEvents,
3568
3630
  Rt as reminderService,
3569
3631
  ss as settingsService,
3570
- T as storyService,
3632
+ E as storyService,
3571
3633
  Qa as userCooldownService,
3572
3634
  Ya as userDailyReportService,
3573
- le as userEncyclopediaService,
3635
+ pe as userEncyclopediaService,
3574
3636
  Ga as userGamesService,
3575
3637
  M as userInventoryService,
3576
- E as userMetaService,
3638
+ v as userMetaService,
3577
3639
  we as userOrnamentService,
3578
3640
  be as userQuestService,
3579
3641
  Wa as userRankService,