@opfr/services 1.5.2 → 1.7.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.
Files changed (141) hide show
  1. package/dist/index.es.js +1173 -1439
  2. package/dist/index.umd.js +1 -1
  3. package/dist/services/entities/definition/model.d.ts +12 -2
  4. package/dist/services/entities/definition/model.d.ts.map +1 -1
  5. package/dist/services/entities/definition/schema.d.ts +20 -2
  6. package/dist/services/entities/definition/schema.d.ts.map +1 -1
  7. package/dist/services/entities/helper.d.ts +5 -20
  8. package/dist/services/entities/helper.d.ts.map +1 -1
  9. package/dist/services/entities/process/findMany.d.ts +2 -1
  10. package/dist/services/entities/process/findMany.d.ts.map +1 -1
  11. package/dist/services/entities/process/findOne.d.ts +3 -1
  12. package/dist/services/entities/process/findOne.d.ts.map +1 -1
  13. package/dist/services/entities/types.d.ts +5 -1
  14. package/dist/services/entities/types.d.ts.map +1 -1
  15. package/dist/services/index.d.ts +2 -2
  16. package/dist/services/index.d.ts.map +1 -1
  17. package/dist/services/reminder/types.d.ts +1 -2
  18. package/dist/services/reminder/types.d.ts.map +1 -1
  19. package/dist/services/story/definition/model.d.ts +4 -0
  20. package/dist/services/story/definition/model.d.ts.map +1 -0
  21. package/dist/services/story/definition/schema.d.ts +13 -0
  22. package/dist/services/story/definition/schema.d.ts.map +1 -0
  23. package/dist/services/story/helper.d.ts +10 -0
  24. package/dist/services/story/helper.d.ts.map +1 -0
  25. package/dist/services/story/index.d.ts.map +1 -0
  26. package/dist/services/story/process/create.d.ts +3 -0
  27. package/dist/services/story/process/create.d.ts.map +1 -0
  28. package/dist/services/story/process/findMany.d.ts +5 -0
  29. package/dist/services/story/process/findMany.d.ts.map +1 -0
  30. package/dist/services/story/process/findOne.d.ts +4 -0
  31. package/dist/services/story/process/findOne.d.ts.map +1 -0
  32. package/dist/services/story/process/updateOne.d.ts +4 -0
  33. package/dist/services/story/process/updateOne.d.ts.map +1 -0
  34. package/dist/services/story/service.d.ts +15 -0
  35. package/dist/services/story/service.d.ts.map +1 -0
  36. package/dist/services/story/types.d.ts +11 -0
  37. package/dist/services/story/types.d.ts.map +1 -0
  38. package/dist/services/user/definition/schema.d.ts.map +1 -1
  39. package/dist/services/user-cooldown/definition/schema.d.ts.map +1 -1
  40. package/dist/services/user-cooldown/helper.d.ts +3 -3
  41. package/dist/services/user-cooldown/helper.d.ts.map +1 -1
  42. package/dist/services/user-cooldown/index.d.ts +0 -1
  43. package/dist/services/user-cooldown/index.d.ts.map +1 -1
  44. package/dist/services/user-cooldown/types.d.ts +1 -8
  45. package/dist/services/user-cooldown/types.d.ts.map +1 -1
  46. package/dist/services/user-inventory/helper.d.ts +1 -3
  47. package/dist/services/user-inventory/helper.d.ts.map +1 -1
  48. package/dist/services/user-meta/definition/schema.d.ts.map +1 -1
  49. package/dist/services/user-meta/helper.d.ts +1 -1
  50. package/dist/services/user-meta/helper.d.ts.map +1 -1
  51. package/dist/services/user-meta/types.d.ts +2 -4
  52. package/dist/services/user-meta/types.d.ts.map +1 -1
  53. package/dist/services/user-settings/definition/schema.d.ts.map +1 -1
  54. package/dist/services/user-settings/types.d.ts +1 -6
  55. package/dist/services/user-settings/types.d.ts.map +1 -1
  56. package/dist/services/user-stats/inventory/helper.d.ts.map +1 -1
  57. package/dist/services/user-story/definition/model.d.ts +4 -0
  58. package/dist/services/user-story/definition/model.d.ts.map +1 -0
  59. package/dist/services/user-story/definition/schema.d.ts +13 -0
  60. package/dist/services/user-story/definition/schema.d.ts.map +1 -0
  61. package/dist/services/user-story/helper.d.ts +31 -0
  62. package/dist/services/user-story/helper.d.ts.map +1 -0
  63. package/dist/services/user-story/index.d.ts +3 -0
  64. package/dist/services/user-story/index.d.ts.map +1 -0
  65. package/dist/services/user-story/process/create.d.ts +4 -0
  66. package/dist/services/user-story/process/create.d.ts.map +1 -0
  67. package/dist/services/user-story/process/deleteOne.d.ts +3 -0
  68. package/dist/services/user-story/process/deleteOne.d.ts.map +1 -0
  69. package/dist/services/user-story/process/findMany.d.ts +5 -0
  70. package/dist/services/user-story/process/findMany.d.ts.map +1 -0
  71. package/dist/services/user-story/process/findOne.d.ts +5 -0
  72. package/dist/services/user-story/process/findOne.d.ts.map +1 -0
  73. package/dist/services/user-story/process/updateOne.d.ts +5 -0
  74. package/dist/services/user-story/process/updateOne.d.ts.map +1 -0
  75. package/dist/services/user-story/service.d.ts +15 -0
  76. package/dist/services/user-story/service.d.ts.map +1 -0
  77. package/dist/services/user-story/types.d.ts +43 -0
  78. package/dist/services/user-story/types.d.ts.map +1 -0
  79. package/dist/services/user-story/utils.d.ts +8 -0
  80. package/dist/services/user-story/utils.d.ts.map +1 -0
  81. package/package.json +3 -3
  82. package/dist/services/shop/definition/model.d.ts +0 -4
  83. package/dist/services/shop/definition/model.d.ts.map +0 -1
  84. package/dist/services/shop/definition/schema.d.ts +0 -13
  85. package/dist/services/shop/definition/schema.d.ts.map +0 -1
  86. package/dist/services/shop/helper.d.ts +0 -14
  87. package/dist/services/shop/helper.d.ts.map +0 -1
  88. package/dist/services/shop/index.d.ts +0 -4
  89. package/dist/services/shop/index.d.ts.map +0 -1
  90. package/dist/services/shop/items/background.d.ts +0 -18
  91. package/dist/services/shop/items/background.d.ts.map +0 -1
  92. package/dist/services/shop/items/boostXp.d.ts +0 -18
  93. package/dist/services/shop/items/boostXp.d.ts.map +0 -1
  94. package/dist/services/shop/items/bottle.d.ts +0 -18
  95. package/dist/services/shop/items/bottle.d.ts.map +0 -1
  96. package/dist/services/shop/items/chest.d.ts +0 -18
  97. package/dist/services/shop/items/chest.d.ts.map +0 -1
  98. package/dist/services/shop/items/default.d.ts +0 -21
  99. package/dist/services/shop/items/default.d.ts.map +0 -1
  100. package/dist/services/shop/items/equipments.d.ts +0 -18
  101. package/dist/services/shop/items/equipments.d.ts.map +0 -1
  102. package/dist/services/shop/items/index.d.ts +0 -10
  103. package/dist/services/shop/items/index.d.ts.map +0 -1
  104. package/dist/services/shop/items/object.d.ts +0 -18
  105. package/dist/services/shop/items/object.d.ts.map +0 -1
  106. package/dist/services/shop/items/repair.d.ts +0 -18
  107. package/dist/services/shop/items/repair.d.ts.map +0 -1
  108. package/dist/services/shop/items/store.d.ts +0 -18
  109. package/dist/services/shop/items/store.d.ts.map +0 -1
  110. package/dist/services/shop/items/title.d.ts +0 -18
  111. package/dist/services/shop/items/title.d.ts.map +0 -1
  112. package/dist/services/shop/process/create.d.ts +0 -4
  113. package/dist/services/shop/process/create.d.ts.map +0 -1
  114. package/dist/services/shop/process/findOne.d.ts +0 -5
  115. package/dist/services/shop/process/findOne.d.ts.map +0 -1
  116. package/dist/services/shop/process/updateOne.d.ts +0 -5
  117. package/dist/services/shop/process/updateOne.d.ts.map +0 -1
  118. package/dist/services/shop/service.d.ts +0 -19
  119. package/dist/services/shop/service.d.ts.map +0 -1
  120. package/dist/services/shop/types.d.ts +0 -5
  121. package/dist/services/shop/types.d.ts.map +0 -1
  122. package/dist/services/user-cooldown/constants.d.ts +0 -2
  123. package/dist/services/user-cooldown/constants.d.ts.map +0 -1
  124. package/dist/services/user-shop/definition/model.d.ts +0 -4
  125. package/dist/services/user-shop/definition/model.d.ts.map +0 -1
  126. package/dist/services/user-shop/definition/schema.d.ts +0 -13
  127. package/dist/services/user-shop/definition/schema.d.ts.map +0 -1
  128. package/dist/services/user-shop/helper.d.ts +0 -9
  129. package/dist/services/user-shop/helper.d.ts.map +0 -1
  130. package/dist/services/user-shop/index.d.ts.map +0 -1
  131. package/dist/services/user-shop/process/create.d.ts +0 -4
  132. package/dist/services/user-shop/process/create.d.ts.map +0 -1
  133. package/dist/services/user-shop/process/findOne.d.ts +0 -5
  134. package/dist/services/user-shop/process/findOne.d.ts.map +0 -1
  135. package/dist/services/user-shop/process/updateOne.d.ts +0 -5
  136. package/dist/services/user-shop/process/updateOne.d.ts.map +0 -1
  137. package/dist/services/user-shop/service.d.ts +0 -14
  138. package/dist/services/user-shop/service.d.ts.map +0 -1
  139. package/dist/services/user-shop/types.d.ts +0 -9
  140. package/dist/services/user-shop/types.d.ts.map +0 -1
  141. /package/dist/services/{user-shop → story}/index.d.ts +0 -0
package/dist/index.es.js CHANGED
@@ -1,65 +1,65 @@
1
- import { Schema as o, models as d, model as p, connect as He, Types as Ke } from "mongoose";
2
- import { QuestStatus as M, DEFAULT_FACTION as Pe, GAME_TYPES as Le, EQUIPMENT_SLOT as be, EFFECT_KEYS as Qe, CHARACTERISTICS as We, getComputedCharacteristicValue as Ge, getCurrentLevel as Ye, HP_PER_VITALITY as Ve, DEFAULT_MAX_HP as Xe, transformToDBBuff as Je, RANK_IDS_WITHOUT_BASIC as he, SHOP_DEFAULT_AVAILABLE_ENTITY_AMOUNT as Ze } from "@opfr/definitions";
3
- import et from "node-cache";
4
- import * as $e from "events";
5
- import { filterNullAndUndefined as _, sortBy as H, pickNthByOdds as le, shuffle as ge, recordToArray as x, arrayToRecord as Ie, mergeObjects as C, seededRandom as tt, randomBetween as Ee, hasExpire as oe, isString as nt, capitalizeAllWords as at, pickFrom as rt, sameDay as Ue, yesterday as K, exclude as j, range as st } from "@opfr/utils-lang";
6
- const P = "___ALL_ENTITIES___";
7
- class f {
1
+ import { Schema as c, models as d, model as l, connect as Qe, Types as Ye } from "mongoose";
2
+ import { QuestStatus as q, 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";
3
+ import ut from "node-cache";
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 {
8
8
  cache;
9
9
  constructor(e) {
10
- this.cache = new et({
10
+ this.cache = new ut({
11
11
  stdTTL: e,
12
12
  checkperiod: e * 0.2,
13
13
  useClones: !1
14
14
  });
15
15
  }
16
16
  async get(e, t) {
17
- const a = this.normalizeKey(e), r = this.cache.get(a);
18
- if (r)
19
- return r;
17
+ const r = this.normalizeKey(e), a = this.cache.get(r);
18
+ if (a)
19
+ return a;
20
20
  const s = await this.fetchFromDb(e, t ?? {});
21
- return s && this.cache.set(a, s), s;
21
+ return s && this.cache.set(r, s), s;
22
22
  }
23
- async update(e, t, a) {
24
- const r = await this.updateInDb(e, t, a);
25
- if (r) {
26
- const s = this.getKey(r);
27
- this.cache.del(P), this.cache.set(this.normalizeKey(s), r);
23
+ async update(e, t, r) {
24
+ const a = await this.updateInDb(e, t, r);
25
+ if (a) {
26
+ const s = this.getKey(a);
27
+ this.cache.del(G), this.cache.set(this.normalizeKey(s), a);
28
28
  }
29
- return r;
29
+ return a;
30
30
  }
31
31
  invalidate(e) {
32
- this.cache.del(P), e && this.cache.del(this.normalizeKey(e));
32
+ this.cache.del(G), e && this.cache.del(this.normalizeKey(e));
33
33
  }
34
34
  clearAll() {
35
35
  this.cache.flushAll();
36
36
  }
37
37
  }
38
- class w extends f {
38
+ class f extends y {
39
39
  async getAll() {
40
- const e = this.cache.get(P);
40
+ const e = this.cache.get(G);
41
41
  if (e)
42
42
  return e;
43
43
  const t = await this.fetchManyFromDb({}, {});
44
- return this.cache.set(P, t), t.forEach((a) => {
45
- this.cache.set(this.normalizeKey(this.getKey(a)), a);
44
+ return this.cache.set(G, t), t.forEach((r) => {
45
+ this.cache.set(this.normalizeKey(this.getKey(r)), r);
46
46
  }), t;
47
47
  }
48
48
  async getMany(e, t = {}) {
49
- const a = await this.fetchManyFromDb(e, t);
50
- return a.forEach((r) => {
51
- this.cache.set(this.normalizeKey(this.getKey(r)), r);
52
- }), a;
49
+ const r = await this.fetchManyFromDb(e, t);
50
+ return r.forEach((a) => {
51
+ this.cache.set(this.normalizeKey(this.getKey(a)), a);
52
+ }), r;
53
53
  }
54
54
  }
55
- const De = new $e.EventEmitter(), S = (n, e, t) => {
55
+ const De = new Ue.EventEmitter(), S = (n, e, t) => {
56
56
  De.emit(n, e, t);
57
- }, _r = (n) => {
57
+ }, La = (n) => {
58
58
  for (const [e, t] of Object.entries(n))
59
- De.on(e, (a, r) => {
60
- t(a, r);
59
+ De.on(e, (r, a) => {
60
+ t(r, a);
61
61
  });
62
- }, b = {
62
+ }, w = {
63
63
  USER: "middleware/quest/USER",
64
64
  USER_INVENTORY: "middleware/quest/USER_INVENTORY",
65
65
  USER_META: "middleware/quest/USER_META",
@@ -71,10 +71,10 @@ const De = new $e.EventEmitter(), S = (n, e, t) => {
71
71
  USER_STATS_FLAGS: "middleware/quest/USER_STATS_FLAGS",
72
72
  USER_STATS_FREQUENCY: "middleware/quest/USER_STATS_FREQUENCY",
73
73
  USER_STATS_INVENTORY: "middleware/quest/USER_STATS_INVENTORY"
74
- }, Te = new o(
74
+ }, ve = new c(
75
75
  {
76
76
  user: {
77
- type: o.Types.ObjectId,
77
+ type: c.Types.ObjectId,
78
78
  required: !0,
79
79
  ref: "User",
80
80
  index: !0
@@ -84,42 +84,34 @@ const De = new $e.EventEmitter(), S = (n, e, t) => {
84
84
  required: !0,
85
85
  index: !0
86
86
  },
87
- status: { type: String, default: M.IN_PROGRESS, index: 1 },
87
+ status: { type: String, default: q.IN_PROGRESS, index: 1 },
88
88
  lastCompletionDate: Date,
89
89
  streak: Number
90
90
  },
91
91
  { minimize: !1 }
92
92
  );
93
- Te.post("findOneAndUpdate", function(n) {
93
+ ve.post("findOneAndUpdate", function(n) {
94
94
  n && S(
95
- b.USER_QUEST,
95
+ w.USER_QUEST,
96
96
  n.user._id,
97
97
  n
98
98
  );
99
99
  });
100
- const q = d?.UserQuest || p("UserQuest", Te), it = new o({
100
+ const C = d?.UserQuest || l("UserQuest", ve), pt = new c({
101
101
  user: {
102
- type: o.Types.ObjectId,
102
+ type: c.Types.ObjectId,
103
103
  required: !0,
104
104
  unique: !0,
105
105
  ref: "User"
106
106
  },
107
- raid: {
108
- classic: { type: Date, default: /* @__PURE__ */ new Date(0) },
109
- special: { type: Date, default: /* @__PURE__ */ new Date(0) }
110
- },
111
- lockUserCommand: { type: Date, default: /* @__PURE__ */ new Date(0) },
112
107
  commands: {
113
- work: { type: Date, default: /* @__PURE__ */ new Date(0) },
114
- dice: { type: Date, default: /* @__PURE__ */ new Date(0) },
115
- doubleOrQuit: { type: Date, default: /* @__PURE__ */ new Date(0) },
116
- priceIsRight: { type: Date, default: /* @__PURE__ */ new Date(0) },
117
- blackJack: { type: Date, default: /* @__PURE__ */ new Date(0) },
118
- rps: { type: Date, default: /* @__PURE__ */ new Date(0) }
119
- }
120
- }), Q = d?.UserCooldown || p("UserCooldown", it), ut = new o({
108
+ type: Map,
109
+ of: Date,
110
+ default: /* @__PURE__ */ new Map()
111
+ }
112
+ }), W = d?.UserCooldown || l("UserCooldown", pt), yt = new c({
121
113
  user: {
122
- type: o.Types.ObjectId,
114
+ type: c.Types.ObjectId,
123
115
  required: !0,
124
116
  unique: !0,
125
117
  ref: "User"
@@ -133,17 +125,17 @@ const q = d?.UserQuest || p("UserQuest", Te), it = new o({
133
125
  },
134
126
  previousCompletedQuest: { type: [String], default: [] },
135
127
  previousMessageSent: { type: Number, default: 0 }
136
- }), W = d?.UserDailyReport || p("UserDailyReport", ut), ot = new o({
128
+ }), V = d?.UserDailyReport || l("UserDailyReport", yt), ft = new c({
137
129
  user: {
138
- type: o.Types.ObjectId,
130
+ type: c.Types.ObjectId,
139
131
  required: !0,
140
132
  unique: !0,
141
133
  ref: "User"
142
134
  },
143
135
  encyclopedia: { type: [String], default: [] }
144
- }), G = d?.UserEncyclopedia || p("UserEncyclopedia", ot), ct = new o({
136
+ }), X = d?.UserEncyclopedia || l("UserEncyclopedia", ft), mt = new c({
145
137
  user: {
146
- type: o.Types.ObjectId,
138
+ type: c.Types.ObjectId,
147
139
  required: !0,
148
140
  unique: !0,
149
141
  ref: "User",
@@ -158,10 +150,10 @@ const q = d?.UserQuest || p("UserQuest", Te), it = new o({
158
150
  },
159
151
  default: null
160
152
  }
161
- }), Y = d?.UserGames || p("UserGames", ct), Oe = new o(
153
+ }), J = d?.UserGames || l("UserGames", mt), Me = new c(
162
154
  {
163
155
  user: {
164
- type: o.Types.ObjectId,
156
+ type: c.Types.ObjectId,
165
157
  required: !0,
166
158
  unique: !0,
167
159
  ref: "User"
@@ -180,23 +172,23 @@ const q = d?.UserQuest || p("UserQuest", Te), it = new o({
180
172
  },
181
173
  { minimize: !1 }
182
174
  );
183
- Oe.post("findOneAndUpdate", function(n) {
175
+ Me.post("findOneAndUpdate", function(n) {
184
176
  n && S(
185
- b.USER_INVENTORY,
177
+ w.USER_INVENTORY,
186
178
  n.user._id,
187
179
  n
188
180
  );
189
181
  });
190
- const V = d?.UserInventory || p("UserInventory", Oe), lt = new $e.EventEmitter(), dt = (n, e) => {
191
- lt.emit(n, e);
192
- }, v = {
182
+ const Z = d?.UserInventory || l("UserInventory", Me), ht = new Ue.EventEmitter(), gt = (n, e) => {
183
+ ht.emit(n, e);
184
+ }, M = {
193
185
  multiplier: { type: Number, default: 0 },
194
186
  origin: String,
195
187
  expireAt: { type: Date, default: null },
196
188
  startAt: { type: Date, default: null }
197
- }, ve = new o({
189
+ }, xe = new c({
198
190
  user: {
199
- type: o.Types.ObjectId,
191
+ type: c.Types.ObjectId,
200
192
  required: !0,
201
193
  unique: !0,
202
194
  ref: "User"
@@ -216,38 +208,40 @@ const V = d?.UserInventory || p("UserInventory", Oe), lt = new $e.EventEmitter()
216
208
  buffs: {
217
209
  cooldown: {
218
210
  casino: {
219
- type: [v],
211
+ type: [M],
220
212
  default: []
221
213
  },
222
214
  work: {
223
- type: [v],
215
+ type: [M],
224
216
  default: []
225
217
  }
226
218
  },
227
219
  berry: {
228
220
  work: {
229
- type: [v],
221
+ type: [M],
230
222
  default: []
231
223
  },
232
224
  global: {
233
- type: [v],
225
+ type: [M],
234
226
  default: []
235
227
  }
236
228
  },
237
229
  drop: {
238
230
  work: {
239
- type: [v],
231
+ type: [M],
240
232
  default: []
241
233
  }
242
234
  },
243
235
  xp: {
244
236
  global: {
245
- type: [v],
237
+ type: [M],
246
238
  default: []
247
239
  }
248
240
  }
249
241
  },
250
242
  hp: { type: Number, default: 100 },
243
+ energyMax: { type: Number, default: 10 },
244
+ energy: { type: Number, default: 10 },
251
245
  workUnluckyStreak: { type: Number, default: 0 },
252
246
  characteristics: {
253
247
  vitality: { type: Number, default: 0 },
@@ -257,10 +251,6 @@ const V = d?.UserInventory || p("UserInventory", Oe), lt = new $e.EventEmitter()
257
251
  intelligence: { type: Number, default: 0 },
258
252
  wisdom: { type: Number, default: 0 }
259
253
  },
260
- resetCharacteristics: {
261
- free: { type: Boolean, default: !0 },
262
- nextAvailable: { type: Date, default: null }
263
- },
264
254
  scrolls: {
265
255
  vitality: { type: Number, default: 0 },
266
256
  strength: { type: Number, default: 0 },
@@ -270,16 +260,16 @@ const V = d?.UserInventory || p("UserInventory", Oe), lt = new $e.EventEmitter()
270
260
  wisdom: { type: Number, default: 0 }
271
261
  }
272
262
  });
273
- ve.post("findOneAndUpdate", async function(n) {
263
+ xe.post("findOneAndUpdate", async function(n) {
274
264
  n && (S(
275
- b.USER_META,
265
+ w.USER_META,
276
266
  n.user._id,
277
267
  n
278
- ), n.hp <= 0 && dt("death", n.user._id));
268
+ ), n.hp <= 0 && gt("death", n.user._id));
279
269
  });
280
- const O = d?.UserMeta || p("UserMeta", ve), Be = new o({
270
+ const v = d?.UserMeta || l("UserMeta", xe), qe = new c({
281
271
  user: {
282
- type: o.Types.ObjectId,
272
+ type: c.Types.ObjectId,
283
273
  required: !0,
284
274
  unique: !0,
285
275
  ref: "User"
@@ -294,16 +284,16 @@ const O = d?.UserMeta || p("UserMeta", ve), Be = new o({
294
284
  unlockedBags: { type: [String], default: ["default"] },
295
285
  selectedBag: { type: String, default: "default" }
296
286
  });
297
- Be.post("findOneAndUpdate", function(n) {
287
+ qe.post("findOneAndUpdate", function(n) {
298
288
  n && S(
299
- b.USER_ORNAMENT,
289
+ w.USER_ORNAMENT,
300
290
  n.user._id,
301
291
  n
302
292
  );
303
293
  });
304
- const X = d?.UserOrnament || p("UserOrnament", Be), pt = new o({
294
+ const ee = d?.UserOrnament || l("UserOrnament", qe), St = new c({
305
295
  user: {
306
- type: o.Types.ObjectId,
296
+ type: c.Types.ObjectId,
307
297
  required: !0,
308
298
  unique: !0,
309
299
  ref: "User"
@@ -314,34 +304,15 @@ const X = d?.UserOrnament || p("UserOrnament", Be), pt = new o({
314
304
  sendDailyReport: { type: Boolean, default: !1, index: !0 },
315
305
  sendDailyQuest: { type: Boolean, default: !1 },
316
306
  reminder: {
317
- raid: {
318
- classic: { type: Boolean, default: !1 },
319
- special: { type: Boolean, default: !1 }
320
- },
321
307
  commands: {
322
- work: { type: Boolean, default: !1 },
323
- dice: { type: Boolean, default: !1 },
324
- qod: { type: Boolean, default: !1 },
325
- blackjack: { type: Boolean, default: !1 },
326
- guess: { type: Boolean, default: !1 },
327
- rps: { type: Boolean, default: !1 }
308
+ type: Map,
309
+ of: Boolean,
310
+ default: /* @__PURE__ */ new Map()
328
311
  }
329
312
  }
330
- }), N = d?.UserSettings || p("UserSettings", pt), yt = new o(
331
- {
332
- user: {
333
- type: o.Types.ObjectId,
334
- required: !0,
335
- unique: !0,
336
- ref: "User"
337
- },
338
- lastShopId: o.Types.ObjectId,
339
- limit: { type: o.Types.Mixed, default: {} }
340
- },
341
- { minimize: !1 }
342
- ), J = d?.UserShop || p("UserShop", yt), Me = new o({
313
+ }), F = d?.UserSettings || l("UserSettings", St), Ae = new c({
343
314
  user: {
344
- type: o.Types.ObjectId,
315
+ type: c.Types.ObjectId,
345
316
  required: !0,
346
317
  unique: !0,
347
318
  ref: "User"
@@ -374,16 +345,16 @@ const X = d?.UserOrnament || p("UserOrnament", Be), pt = new o({
374
345
  guessInOneTryCount: { type: Number, default: 0 }
375
346
  }
376
347
  });
377
- Me.post("findOneAndUpdate", function(n) {
348
+ Ae.post("findOneAndUpdate", function(n) {
378
349
  n && S(
379
- b.USER_STATS_CASINO,
350
+ w.USER_STATS_CASINO,
380
351
  n.user._id,
381
352
  n
382
353
  );
383
354
  });
384
- const k = d?.UserStatsCasino || p("UserStatsCasino", Me), ke = new o({
355
+ const A = d?.UserStatsCasino || l("UserStatsCasino", Ae), ke = new c({
385
356
  user: {
386
- type: o.Types.ObjectId,
357
+ type: c.Types.ObjectId,
387
358
  required: !0,
388
359
  unique: !0,
389
360
  ref: "User"
@@ -393,14 +364,14 @@ const k = d?.UserStatsCasino || p("UserStatsCasino", Me), ke = new o({
393
364
  });
394
365
  ke.post("findOneAndUpdate", function(n) {
395
366
  n && S(
396
- b.USER_STATS_ECONOMY,
367
+ w.USER_STATS_ECONOMY,
397
368
  n.user._id,
398
369
  n
399
370
  );
400
371
  });
401
- const Z = d?.UserStatsEconomy || p("UserStatsEconomy", ke), Ae = new o({
372
+ const te = d?.UserStatsEconomy || l("UserStatsEconomy", ke), Re = new c({
402
373
  user: {
403
- type: o.Types.ObjectId,
374
+ type: c.Types.ObjectId,
404
375
  required: !0,
405
376
  unique: !0,
406
377
  ref: "User"
@@ -410,19 +381,19 @@ const Z = d?.UserStatsEconomy || p("UserStatsEconomy", ke), Ae = new o({
410
381
  randomMessageClaimed: { type: Number, default: 0 },
411
382
  writeDifferentChatIds: { type: [String], default: [] }
412
383
  });
413
- Ae.post("findOneAndUpdate", function(n) {
384
+ Re.post("findOneAndUpdate", function(n) {
414
385
  n && S(
415
- b.USER_STATS_ENGAGEMENT,
386
+ w.USER_STATS_ENGAGEMENT,
416
387
  n.user._id,
417
388
  n
418
389
  );
419
390
  });
420
- const ee = d?.UserStatsEngagement || p(
391
+ const ne = d?.UserStatsEngagement || l(
421
392
  "UserStatsEngagement",
422
- Ae
423
- ), qe = new o({
393
+ Re
394
+ ), Ce = new c({
424
395
  user: {
425
- type: o.Types.ObjectId,
396
+ type: c.Types.ObjectId,
426
397
  required: !0,
427
398
  unique: !0,
428
399
  ref: "User"
@@ -439,16 +410,16 @@ const ee = d?.UserStatsEngagement || p(
439
410
  loseEverything: { type: Boolean, default: !1 }
440
411
  }
441
412
  });
442
- qe.post("findOneAndUpdate", function(n) {
413
+ Ce.post("findOneAndUpdate", function(n) {
443
414
  n && S(
444
- b.USER_STATS_FLAGS,
415
+ w.USER_STATS_FLAGS,
445
416
  n.user._id,
446
417
  n
447
418
  );
448
419
  });
449
- const te = d?.UserStatsFlags || p("UserStatsFlags", qe), Re = new o({
420
+ const re = d?.UserStatsFlags || l("UserStatsFlags", Ce), _e = new c({
450
421
  user: {
451
- type: o.Types.ObjectId,
422
+ type: c.Types.ObjectId,
452
423
  required: !0,
453
424
  unique: !0,
454
425
  ref: "User"
@@ -458,19 +429,19 @@ const te = d?.UserStatsFlags || p("UserStatsFlags", qe), Re = new o({
458
429
  lastTimeRead: { type: Date, default: /* @__PURE__ */ new Date(), index: !0 }
459
430
  }
460
431
  });
461
- Re.post("findOneAndUpdate", function(n) {
432
+ _e.post("findOneAndUpdate", function(n) {
462
433
  n && S(
463
- b.USER_STATS_FREQUENCY,
434
+ w.USER_STATS_FREQUENCY,
464
435
  n.user._id,
465
436
  n
466
437
  );
467
438
  });
468
- const T = d?.UserStatsFrequency || p(
439
+ const D = d?.UserStatsFrequency || l(
469
440
  "UserStatsFrequency",
470
- Re
471
- ), xe = new o({
441
+ _e
442
+ ), Be = new c({
472
443
  user: {
473
- type: o.Types.ObjectId,
444
+ type: c.Types.ObjectId,
474
445
  required: !0,
475
446
  unique: !0,
476
447
  ref: "User"
@@ -495,39 +466,39 @@ const T = d?.UserStatsFrequency || p(
495
466
  totalCrafted: { type: Number, default: 0 }
496
467
  }
497
468
  });
498
- xe.post("findOneAndUpdate", function(n) {
469
+ Be.post("findOneAndUpdate", function(n) {
499
470
  n && S(
500
- b.USER_STATS_INVENTORY,
471
+ w.USER_STATS_INVENTORY,
501
472
  n.user._id,
502
473
  n
503
474
  );
504
475
  });
505
- const A = d?.UserStatsInventory || p(
476
+ const k = d?.UserStatsInventory || l(
506
477
  "UserStatsInventory",
507
- xe
508
- ), de = new o({
478
+ Be
479
+ ), ye = new c({
509
480
  discordId: { type: String, required: !0, unique: !0 },
510
481
  scam: { type: Boolean, default: !1 },
511
482
  birthday: { type: Date, default: null, index: 1 },
512
- faction: { type: String, default: Pe, index: 1 },
483
+ faction: { type: String, default: Ge, index: 1 },
513
484
  canChangeFaction: { type: Boolean, default: !1 },
514
485
  canChooseFaction: { type: Boolean, default: !1 }
515
486
  });
516
- de.post("findOneAndUpdate", function(n) {
517
- n && S(b.USER, n._id, n);
487
+ ye.post("findOneAndUpdate", function(n) {
488
+ n && S(w.USER, n._id, n);
518
489
  });
519
- de.post("deleteOne", async function() {
490
+ ye.post("deleteOne", async function() {
520
491
  const n = this.getQuery()._id;
521
- await Q.deleteOne({ user: n }), await W.deleteOne({ user: n }), await G.deleteOne({ user: n }), await Y.deleteOne({ user: n }), await V.deleteOne({ user: n }), await O.deleteOne({ user: n }), await X.deleteOne({ user: n }), await q.deleteMany({ user: n }), await N.deleteOne({ user: n }), await J.deleteOne({ user: n }), await k.deleteOne({ user: n }), await Z.deleteOne({ user: n }), await ee.deleteOne({ user: n }), await te.deleteOne({ user: n }), await T.deleteOne({ user: n }), await A.deleteOne({ user: n });
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 v.deleteOne({ user: n }), await ee.deleteOne({ user: n }), await C.deleteMany({ user: n }), await F.deleteOne({ user: n }), await A.deleteOne({ user: n }), await te.deleteOne({ user: n }), await ne.deleteOne({ user: n }), await re.deleteOne({ user: n }), await D.deleteOne({ user: n }), await k.deleteOne({ user: n });
522
493
  });
523
- const $ = d?.User || p("User", de);
524
- class ft extends w {
494
+ const b = d?.User || l("User", ye);
495
+ class wt extends f {
525
496
  getByObjectId(e) {
526
497
  return this.update({ _id: e }, {});
527
498
  }
528
499
  getNextBirthdays() {
529
500
  const e = /* @__PURE__ */ new Date(), t = e.getFullYear();
530
- return $.aggregate([
501
+ return b.aggregate([
531
502
  {
532
503
  $match: {
533
504
  birthday: { $ne: null }
@@ -578,7 +549,7 @@ class ft extends w {
578
549
  ]);
579
550
  }
580
551
  getFactionRanking(e) {
581
- return $.aggregate([
552
+ return b.aggregate([
582
553
  { $match: { faction: e } },
583
554
  {
584
555
  $lookup: {
@@ -601,7 +572,7 @@ class ft extends w {
601
572
  ]);
602
573
  }
603
574
  getGlobalRanking() {
604
- return $.aggregate([
575
+ return b.aggregate([
605
576
  {
606
577
  $lookup: {
607
578
  from: "usermetas",
@@ -623,7 +594,7 @@ class ft extends w {
623
594
  ]);
624
595
  }
625
596
  getBerryRanking() {
626
- return $.aggregate([
597
+ return b.aggregate([
627
598
  {
628
599
  $lookup: {
629
600
  from: "usermetas",
@@ -645,10 +616,10 @@ class ft extends w {
645
616
  ]);
646
617
  }
647
618
  getQuestRanking() {
648
- return q.aggregate([
619
+ return C.aggregate([
649
620
  {
650
621
  $match: {
651
- status: M.COMPLETED
622
+ status: q.COMPLETED
652
623
  }
653
624
  },
654
625
  {
@@ -692,7 +663,7 @@ class ft extends w {
692
663
  }
693
664
  getTodayAllBirthday() {
694
665
  const e = /* @__PURE__ */ new Date();
695
- return $.aggregate([
666
+ return b.aggregate([
696
667
  { $match: { birthday: { $ne: null } } },
697
668
  {
698
669
  $addFields: {
@@ -739,18 +710,18 @@ class ft extends w {
739
710
  );
740
711
  }
741
712
  }
742
- const mt = (n, e) => $.find(n, {}, e).lean(), y = (n) => n.toObject({ flattenMaps: !0, flattenObjectIds: !1 }), ht = (n) => $.create({
713
+ const bt = (n, e) => b.find(n, {}, e).lean(), p = (n) => n.toObject({ flattenMaps: !0, flattenObjectIds: !1 }), $t = (n) => b.create({
743
714
  discordId: n
744
715
  });
745
- async function gt(n, { upsert: e = !0, ...t }) {
746
- const a = await $.findOne({ discordId: n }, {}, t).lean();
747
- return !a && e ? y(await ht(n)) : a;
716
+ async function It(n, { upsert: e = !0, ...t }) {
717
+ const r = await b.findOne({ discordId: n }, {}, t).lean();
718
+ return !r && e ? p(await $t(n)) : r;
748
719
  }
749
- const wt = (n, e) => $.findOneAndUpdate(n, e, {
720
+ const Ut = (n, e) => b.findOneAndUpdate(n, e, {
750
721
  upsert: !0,
751
722
  returnDocument: "after"
752
723
  }).lean();
753
- class St extends ft {
724
+ class Tt extends wt {
754
725
  constructor() {
755
726
  super(3600);
756
727
  }
@@ -761,19 +732,19 @@ class St extends ft {
761
732
  return e;
762
733
  }
763
734
  fetchFromDb(e, t) {
764
- return gt(e, t);
735
+ return It(e, t);
765
736
  }
766
737
  fetchManyFromDb(e, t) {
767
- return mt(e, t);
738
+ return bt(e, t);
768
739
  }
769
740
  updateInDb(e, t) {
770
- return wt(e, t);
741
+ return Ut(e, t);
771
742
  }
772
743
  }
773
- const bt = new St(), Cr = ["work", ...Le], $t = new o(
744
+ const Et = new Tt(), Ot = new c(
774
745
  {
775
746
  user: {
776
- type: o.Types.ObjectId,
747
+ type: c.Types.ObjectId,
777
748
  ref: "User",
778
749
  required: !0,
779
750
  index: !0
@@ -782,53 +753,53 @@ const bt = new St(), Cr = ["work", ...Le], $t = new o(
782
753
  type: { type: String, required: !0 }
783
754
  },
784
755
  { minimize: !1 }
785
- ), F = d?.Reminder || p("Reminder", $t), It = async (n) => {
786
- await F.deleteMany(n);
787
- }, Et = async (n, e) => {
788
- await F.deleteOne({ user: n, type: e });
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 });
789
760
  };
790
- class Ut extends w {
761
+ class Mt extends f {
791
762
  getAllPassedReminder() {
792
763
  return this.getMany({ date: { $lte: /* @__PURE__ */ new Date() } });
793
764
  }
794
- async addReminder(e, t, a) {
795
- await this.update({ user: e, type: t }, { $set: { date: a } }, { upsert: !0 });
765
+ async addReminder(e, t, r) {
766
+ await this.update({ user: e, type: t }, { $set: { date: r } }, { upsert: !0 });
796
767
  }
797
- async updateReminderDate(e, t, a) {
768
+ async updateReminderDate(e, t, r) {
798
769
  await this.update({ user: e, type: t }, [
799
770
  {
800
771
  $set: {
801
772
  date: {
802
- $add: ["$date", a]
773
+ $add: ["$date", r]
803
774
  }
804
775
  }
805
776
  }
806
777
  ]);
807
778
  }
808
779
  async removeReminder(e, t) {
809
- await Et(e, t), this.invalidate({ user: e, type: t });
780
+ await vt(e, t), this.invalidate({ user: e, type: t });
810
781
  }
811
782
  async deleteSelectedReminders(e) {
812
- const t = e.map((a) => a._id);
813
- await It({ _id: { $in: t } }), e.forEach((a) => {
814
- this.invalidate({ user: a.user, type: a.type });
783
+ const t = e.map((r) => r._id);
784
+ await Dt({ _id: { $in: t } }), e.forEach((r) => {
785
+ this.invalidate({ user: r.user, type: r.type });
815
786
  });
816
787
  }
817
788
  }
818
- function Dt(n, e) {
819
- return F.find(n, {}, e).lean();
789
+ function xt(n, e) {
790
+ return N.find(n, {}, e).lean();
820
791
  }
821
- async function Tt(n) {
822
- const e = await F.findOne(n).lean();
792
+ async function qt(n) {
793
+ const e = await N.findOne(n).lean();
823
794
  return e || null;
824
795
  }
825
- async function Ot(n, e, t) {
826
- return F.findOneAndUpdate(n, e, {
796
+ async function At(n, e, t) {
797
+ return N.findOneAndUpdate(n, e, {
827
798
  ...t,
828
799
  returnDocument: "after"
829
800
  }).lean();
830
801
  }
831
- class vt extends Ut {
802
+ class kt extends Mt {
832
803
  constructor() {
833
804
  super(300);
834
805
  }
@@ -842,66 +813,66 @@ class vt extends Ut {
842
813
  return `${e.toString()}/${t}`;
843
814
  }
844
815
  fetchFromDb(e) {
845
- return Tt(e);
816
+ return qt(e);
846
817
  }
847
818
  fetchManyFromDb(e, t) {
848
- return Dt(e, t);
819
+ return xt(e, t);
849
820
  }
850
- updateInDb(e, t, a = { upsert: !1 }) {
851
- return Ot(e, t, a);
821
+ updateInDb(e, t, r = { upsert: !1 }) {
822
+ return At(e, t, r);
852
823
  }
853
824
  }
854
- const Bt = new vt(), Mt = new o(
825
+ const Rt = new kt(), Ct = new c(
855
826
  {
856
827
  panoplyId: { unique: !0, index: 1, required: !0, type: String },
857
828
  name: { required: !0, type: String },
858
829
  equipments: {
859
830
  required: !0,
860
- type: [{ type: o.Types.ObjectId, ref: "Entities" }]
831
+ type: [{ type: c.Types.ObjectId, ref: "Entities" }]
861
832
  },
862
833
  fullBonusStr: { type: String },
863
834
  halfBonusStr: { type: String },
864
- fullBonus: o.Types.Mixed,
865
- halfBonus: o.Types.Mixed
835
+ fullBonus: c.Types.Mixed,
836
+ halfBonus: c.Types.Mixed
866
837
  },
867
838
  { minimize: !1 }
868
- ), z = d?.Panoplies || p("Panoplies", Mt), kt = (n, e) => z.find(n, {}, e).lean(), At = async (n, e) => z.find(n, {}, e).populate("equipments");
869
- async function qt(n) {
870
- const e = await z.findOne({ panoplyId: n }).lean();
839
+ ), K = d?.Panoplies || l("Panoplies", Ct), _t = (n, e) => K.find(n, {}, e).lean(), Bt = async (n, e) => K.find(n, {}, e).populate("equipments");
840
+ async function Ft(n) {
841
+ const e = await K.findOne({ panoplyId: n }).lean();
871
842
  return e || null;
872
843
  }
873
- const Rt = async (n) => z.findOne(n).populate("equipments");
874
- class xt extends w {
844
+ const Nt = async (n) => K.findOne(n).populate("equipments");
845
+ class Kt extends f {
875
846
  getAllPopulated() {
876
- return At({}, {});
847
+ return Bt({}, {});
877
848
  }
878
849
  getPopulated(e) {
879
- return Rt({ panoplyId: e });
850
+ return Nt({ panoplyId: e });
880
851
  }
881
852
  hasPanoply(e, t) {
882
- const a = _(Object.values(e)), r = t.equipments.filter(
883
- (s) => a.find((i) => i.entityId === s.entityId)
853
+ const r = L(Object.values(e)), a = t.equipments.filter(
854
+ (s) => r.find((i) => i.entityId === s.entityId)
884
855
  ).length;
885
- if (r === t.equipments.length)
856
+ if (a === t.equipments.length)
886
857
  return t.fullBonus;
887
- if (r >= t.equipments.length / 2)
858
+ if (a >= t.equipments.length / 2)
888
859
  return t.halfBonus;
889
860
  }
890
861
  async getPanoplyBonus(e) {
891
- const t = [], a = await this.getAllPopulated();
892
- for (const r of a) {
893
- const s = _(Object.values(e)), i = r.equipments.filter(
894
- (c) => s.find(({ entityId: u }) => u === c.entityId)
862
+ const t = [], r = await this.getAllPopulated();
863
+ 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)
895
866
  );
896
- i.length === r.equipments.length ? t.push([r, "full"]) : i.length >= r.equipments.length / 2 ? t.push([r, "half"]) : i.length >= 1 && t.push([r, null]);
867
+ 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]);
897
868
  }
898
869
  return t;
899
870
  }
900
871
  }
901
- const _t = async (n, e) => z.findOneAndUpdate(n, e, {
872
+ const Ht = async (n, e) => K.findOneAndUpdate(n, e, {
902
873
  returnDocument: "after"
903
874
  }).lean();
904
- class Ct extends xt {
875
+ class Pt extends Kt {
905
876
  constructor() {
906
877
  super(3600);
907
878
  }
@@ -912,51 +883,68 @@ class Ct extends xt {
912
883
  return e;
913
884
  }
914
885
  updateInDb(e, t) {
915
- return _t(e, t);
886
+ return Ht(e, t);
916
887
  }
917
888
  fetchFromDb(e) {
918
- return qt(e);
889
+ return Ft(e);
919
890
  }
920
891
  fetchManyFromDb(e, t) {
921
- return kt(e, t);
892
+ return _t(e, t);
922
893
  }
923
894
  }
924
- const E = new Ct();
925
- class Nt extends w {
895
+ const R = new Pt(), jt = new c(
896
+ {
897
+ type: {
898
+ type: String,
899
+ enum: We,
900
+ required: !0
901
+ },
902
+ params: { type: c.Types.Mixed }
903
+ },
904
+ { _id: !1 }
905
+ ), zt = new c(
906
+ {
907
+ entityId: { unique: !0, required: !0, type: String }
908
+ },
909
+ {
910
+ minimize: !1,
911
+ discriminatorKey: "type"
912
+ }
913
+ ), Lt = new c({
914
+ category: { required: !0, type: String },
915
+ subtype: { type: String },
916
+ rankId: String,
917
+ effects: { type: [jt], default: [] },
918
+ usage: {
919
+ _id: !1,
920
+ type: {
921
+ mode: String,
922
+ craft: Boolean
923
+ },
924
+ default: void 0
925
+ }
926
+ }), Qt = new c({
927
+ category: { required: !0, type: String },
928
+ characteristics: {
929
+ _id: !1,
930
+ type: Object
931
+ },
932
+ panoply: String
933
+ }), _ = d?.Entities || l("Entities", zt), Yt = _.discriminator("item", Lt);
934
+ _.discriminator("equipment", Qt);
935
+ const Gt = async (n, e) => _.find(n, {}, e).lean(), Wt = async (n, e) => Yt.find(n, {}, e).lean();
936
+ class Vt extends f {
926
937
  isEntity(e) {
927
938
  return !!e && "entityId" in e;
928
939
  }
929
940
  isItem(e) {
930
- return e.category !== "equipment";
941
+ return e.type === "item";
931
942
  }
932
943
  isEquipment(e) {
933
- return e.category === "equipment";
944
+ return e.type === "equipment";
934
945
  }
935
946
  async isEntityId(e, t = () => !0) {
936
- return (await this.getAll()).filter(t).map(({ entityId: r }) => r).includes(e);
937
- }
938
- async getSomeStoreItems(e) {
939
- const t = (await this.getAll()).filter((a) => this.isStoreItem(a));
940
- return H(
941
- le(
942
- e,
943
- t,
944
- (a) => a.entityId,
945
- (a) => a.shop.odd ?? 0
946
- ),
947
- (a) => a.shop.price
948
- );
949
- }
950
- async getSomeRepairItems(e) {
951
- const t = (await this.getAll()).filter((a) => this.isRepairItem(a));
952
- return ge(t).slice(0, e);
953
- }
954
- async getSomeObjectItems(e) {
955
- const t = (await this.getAll()).filter((a) => this.isObjectItem(a));
956
- return ge(t.filter((a) => !!a.shop?.price)).slice(
957
- 0,
958
- e
959
- );
947
+ return (await this.getAll()).filter(t).map(({ entityId: a }) => a).includes(e);
960
948
  }
961
949
  async idArrayToEntities(e) {
962
950
  return (await this.getAll()).filter(
@@ -968,29 +956,32 @@ class Nt extends w {
968
956
  }
969
957
  async recordToEntityTuple(e) {
970
958
  const t = await this.getAll();
971
- return x(e).reduce((a, [r, s]) => {
972
- const i = t.find(({ entityId: c }) => c === r);
973
- return i && a.push([i, s]), a;
959
+ return B(e).reduce((r, [a, s]) => {
960
+ const i = t.find(({ entityId: u }) => u === a);
961
+ return i && r.push([i, s]), r;
974
962
  }, []);
975
963
  }
976
964
  async getAllEntitiesLimit() {
977
965
  const e = await this.getAll();
978
- return Ie(
966
+ return Te(
979
967
  e.map((t) => [t.entityId, t.shop?.limit ?? 0])
980
968
  );
981
969
  }
982
970
  async getAllEntitiesBy(e) {
983
971
  return (await this.getAll()).filter(e);
984
972
  }
973
+ async getAllItemsBy(e) {
974
+ return (await Wt({}, {})).filter(e);
975
+ }
985
976
  async fromDBToEquipableEquipment(e) {
986
- const a = (await this.getAll()).filter(
987
- (r) => this.isEquipment(r)
977
+ const r = (await this.getAll()).filter(
978
+ (a) => this.isEquipment(a)
988
979
  ).find(
989
- ({ entityId: r }) => r === e.entityId
980
+ ({ entityId: a }) => a === e.entityId
990
981
  );
991
- if (!a)
982
+ if (!r)
992
983
  throw new Error(`cannot find any equipment: ${e.entityId}`);
993
- return this.seedEquipment(a, e.seed);
984
+ return this.seedEquipment(r, e.seed);
994
985
  }
995
986
  async getUserEquipmentsCharacteristics(e) {
996
987
  let t = {
@@ -1001,222 +992,94 @@ class Nt extends w {
1001
992
  intelligence: 0,
1002
993
  wisdom: 0
1003
994
  };
1004
- const a = await E.getAllPopulated();
1005
- for (const r of be) {
1006
- const s = e[r];
1007
- s && (t = C(
995
+ const r = await R.getAllPopulated();
996
+ for (const a of Ie) {
997
+ const s = e[a];
998
+ s && (t = Q(
1008
999
  t,
1009
1000
  (await this.fromDBToEquipableEquipment(s)).characteristics,
1010
- (i, c) => i + c
1001
+ (i, u) => i + u
1011
1002
  ));
1012
1003
  }
1013
- for (const r of a) {
1014
- const s = E.hasPanoply(e, r);
1015
- s && !("target" in s) && (t = C(
1004
+ for (const a of r) {
1005
+ const s = R.hasPanoply(e, a);
1006
+ s && !("target" in s) && (t = Q(
1016
1007
  t,
1017
1008
  s,
1018
- (i, c) => i + c
1009
+ (i, u) => i + u
1019
1010
  ));
1020
1011
  }
1021
1012
  return t;
1022
1013
  }
1023
- filterCraftEntities(e) {
1024
- return e.filter((t) => t.usage?.craft);
1025
- }
1026
- filterDismantleEntities(e) {
1027
- return e.filter((t) => t.usage?.dismantle);
1028
- }
1029
1014
  filterUsableEntities(e) {
1030
- return e.filter((t) => t.usage?.mode);
1031
- }
1032
- filterEnchantableEntities(e) {
1033
- return e.filter((t) => t.usage?.enchant);
1034
- }
1035
- hasCraftEntities(e) {
1036
- return !!e.find((t) => t.usage?.craft);
1037
- }
1038
- hasDismantleEntities(e) {
1039
- return !!e.find((t) => t.usage?.dismantle);
1040
- }
1041
- hasEnchantableEntities(e) {
1042
- return !!e.find((t) => t.usage?.enchant);
1015
+ return e.filter(
1016
+ (t) => this.isConsumableItem(t) && t.usage?.mode
1017
+ );
1043
1018
  }
1044
1019
  hasUsableEntities(e) {
1045
- return !!e.find((t) => t.usage?.mode);
1020
+ return !!e.find(
1021
+ (t) => this.isConsumableItem(t) && t.usage?.mode
1022
+ );
1046
1023
  }
1047
1024
  isChestItem(e) {
1048
- return e.type === "chest";
1049
- }
1050
- isBottleItem(e) {
1051
- return e.type === "bottle";
1052
- }
1053
- isBoostItem(e) {
1054
- return e.type === "boost";
1025
+ return this.isItem(e) && e.category === "chest";
1055
1026
  }
1056
- isRepairItem(e) {
1057
- return e.type === "repair";
1027
+ isConsumableItem(e) {
1028
+ return this.isItem(e) && e.category === "consumable";
1058
1029
  }
1059
- isStoreItem(e) {
1060
- return e.type === "store";
1061
- }
1062
- isObjectItem(e) {
1063
- return e.type === "object";
1064
- }
1065
- isScrollItem(e) {
1066
- return e.type === "scroll";
1067
- }
1068
- isCookedMeal(e) {
1069
- return e.type === "cookedMeal";
1070
- }
1071
- isAlcoholItem(e) {
1072
- return e.type === "alcohol";
1030
+ isResourceItem(e) {
1031
+ return this.isItem(e) && e.category === "resource";
1073
1032
  }
1074
1033
  isSameEquipment(e, t) {
1075
1034
  return e.entityId === t.entityId && e.seed === t.seed;
1076
1035
  }
1077
1036
  seedEquipment(e, t) {
1078
- const a = tt(t), r = H(
1079
- x(e.characteristics),
1037
+ const r = ct(t), a = pe(
1038
+ B(e.characteristics),
1080
1039
  ([s]) => s
1081
1040
  );
1082
1041
  return {
1083
1042
  ...e,
1084
1043
  seed: t,
1085
1044
  characteristics: Object.fromEntries(
1086
- r.map(([s, i]) => [
1045
+ a.map(([s, i]) => [
1087
1046
  s,
1088
- Array.isArray(i) ? Ee(i[0], i[1] + 1, a) : i
1047
+ Array.isArray(i) ? Ee(i[0], i[1] + 1, r) : i
1089
1048
  ])
1090
1049
  )
1091
1050
  };
1092
1051
  }
1093
1052
  isEquipped(e, t) {
1094
1053
  return !!Object.values(e).find(
1095
- (a) => a && this.isSameEquipment(a, t)
1054
+ (r) => r && this.isSameEquipment(r, t)
1096
1055
  );
1097
1056
  }
1098
- calcILvl(e) {
1099
- return Object.values(e.characteristics).reduce((a, r) => a + r, 0) + e.level;
1100
- }
1101
1057
  }
1102
- const Ft = new o(
1103
- {
1104
- type: {
1105
- type: String,
1106
- enum: Qe,
1107
- required: !0
1108
- },
1109
- params: { type: o.Types.Mixed }
1110
- },
1111
- { _id: !1 }
1112
- ), zt = new o(
1113
- {
1114
- entityId: { unique: !0, required: !0, type: String },
1115
- type: { required: !0, type: String },
1116
- name: {
1117
- required: !0,
1118
- _id: !1,
1119
- type: {
1120
- key: { required: !0, type: String },
1121
- context: String
1122
- }
1123
- },
1124
- description: {
1125
- _id: !1,
1126
- type: {
1127
- key: { required: !0, type: String },
1128
- context: String
1129
- }
1130
- },
1131
- image: { required: !0, type: String },
1132
- emojis: { required: !0, type: String },
1133
- category: { required: !0, type: String },
1134
- effects: { type: [Ft], default: [] },
1135
- rankId: String,
1136
- usage: {
1137
- _id: !1,
1138
- type: {
1139
- mode: String,
1140
- craft: Boolean,
1141
- enchant: String,
1142
- dismantle: {
1143
- type: [{ type: { entityId: String, quantity: Number }, _id: !1 }],
1144
- default: void 0
1145
- }
1146
- },
1147
- default: void 0
1148
- },
1149
- shop: {
1150
- default: void 0,
1151
- _id: !1,
1152
- type: {
1153
- price: { required: !0, type: Number },
1154
- limit: Number,
1155
- size: Number,
1156
- odd: Number
1157
- }
1158
- },
1159
- bottle: {
1160
- default: void 0,
1161
- _id: !1,
1162
- type: {
1163
- xp: {
1164
- type: o.Types.Union,
1165
- of: [Number, [Number]],
1166
- required: !0
1167
- },
1168
- buffs: {
1169
- required: !0,
1170
- default: [],
1171
- type: [
1172
- {
1173
- target: { type: String, required: !0 },
1174
- multiplier: { type: Number, required: !0 },
1175
- origin: { type: String, required: !0 },
1176
- startIn: { type: Number, default: null },
1177
- endIn: { type: Number, default: null },
1178
- _id: !1
1179
- }
1180
- ]
1181
- },
1182
- hp: Number,
1183
- tier: Number
1184
- }
1185
- },
1186
- ms: Number,
1187
- characteristics: {
1188
- _id: !1,
1189
- type: Object
1190
- },
1191
- level: Number,
1192
- panoply: String
1193
- },
1194
- { minimize: !1 }
1195
- ), ne = d?.Entities || p("Entities", zt), jt = async (n) => await ne.create({
1058
+ const Xt = async (n) => await _.create({
1196
1059
  ...n
1197
- }), Ht = async (n, e) => ne.find(n, {}, e).lean();
1198
- async function Kt(n) {
1199
- const e = await ne.findOne({ entityId: n }).lean();
1060
+ });
1061
+ async function Jt(n) {
1062
+ const e = await _.findOne({ entityId: n }).lean();
1200
1063
  return e || null;
1201
1064
  }
1202
- const Pt = (n, e) => ne.findOneAndUpdate(n, e, {
1065
+ const Zt = (n, e) => _.findOneAndUpdate(n, e, {
1203
1066
  returnDocument: "after"
1204
1067
  }).lean();
1205
- class Lt extends Nt {
1068
+ class en extends Vt {
1206
1069
  constructor() {
1207
1070
  super(3600);
1208
1071
  }
1209
1072
  createInDb(e) {
1210
- return jt(e);
1073
+ return Xt(e);
1211
1074
  }
1212
1075
  updateInDb(e, t) {
1213
- return Pt(e, t);
1076
+ return Zt(e, t);
1214
1077
  }
1215
1078
  fetchFromDb(e) {
1216
- return Kt(e);
1079
+ return Jt(e);
1217
1080
  }
1218
1081
  fetchManyFromDb(e, t) {
1219
- return Ht(e, t);
1082
+ return Gt(e, t);
1220
1083
  }
1221
1084
  normalizeKey(e) {
1222
1085
  return e;
@@ -1225,8 +1088,8 @@ class Lt extends Nt {
1225
1088
  return e.entityId;
1226
1089
  }
1227
1090
  }
1228
- const l = new Lt();
1229
- class Qt extends f {
1091
+ const m = new en();
1092
+ class tn extends y {
1230
1093
  hasAlreadyFoundEntity(e, t) {
1231
1094
  return e.encyclopedia.includes(t);
1232
1095
  }
@@ -1236,23 +1099,23 @@ class Qt extends f {
1236
1099
  });
1237
1100
  }
1238
1101
  }
1239
- const Wt = async (n) => await G.create({
1102
+ const nn = async (n) => await X.create({
1240
1103
  user: n
1241
1104
  });
1242
- async function Gt(n) {
1243
- const e = await G.findOne({ user: n }).lean();
1244
- return e || y(await Wt(n));
1105
+ async function rn(n) {
1106
+ const e = await X.findOne({ user: n }).lean();
1107
+ return e || p(await nn(n));
1245
1108
  }
1246
- const Yt = (n, e) => G.findOneAndUpdate({ user: n }, e, {
1109
+ const an = (n, e) => X.findOneAndUpdate({ user: n }, e, {
1247
1110
  upsert: !0,
1248
1111
  returnDocument: "after"
1249
1112
  }).lean();
1250
- class Vt extends Qt {
1113
+ class sn extends tn {
1251
1114
  constructor() {
1252
1115
  super(300);
1253
1116
  }
1254
1117
  fetchFromDb(e) {
1255
- return Gt(e);
1118
+ return rn(e);
1256
1119
  }
1257
1120
  getKey({ user: e }) {
1258
1121
  return e;
@@ -1261,22 +1124,11 @@ class Vt extends Qt {
1261
1124
  return e.toString();
1262
1125
  }
1263
1126
  updateInDb(e, t) {
1264
- return Yt(e, t);
1127
+ return an(e, t);
1265
1128
  }
1266
1129
  }
1267
- const ce = new Vt();
1268
- class Xt extends f {
1269
- getPanoplyEffectiveBonus(e, t) {
1270
- const a = _(
1271
- Object.values(e.equippedItems)
1272
- ), r = t.equipments.filter(
1273
- (s) => a.find((i) => i.entityId === s.entityId)
1274
- ).length;
1275
- if (r === t.equipments.length)
1276
- return t.fullBonus;
1277
- if (r >= t.equipments.length / 2)
1278
- return t.halfBonus;
1279
- }
1130
+ const le = new sn();
1131
+ class un extends y {
1280
1132
  async getUserEquipmentsCharacteristics(e) {
1281
1133
  let t = {
1282
1134
  vitality: 0,
@@ -1286,102 +1138,79 @@ class Xt extends f {
1286
1138
  intelligence: 0,
1287
1139
  wisdom: 0
1288
1140
  };
1289
- const a = await E.getAllPopulated();
1290
- for (const r of be) {
1291
- const s = e.equippedItems?.[r];
1292
- if (!s)
1141
+ for (const r of Ie) {
1142
+ const a = e.equippedItems?.[r];
1143
+ if (!a)
1293
1144
  continue;
1294
- const i = await l.fromDBToEquipableEquipment(s);
1295
- t = C(
1145
+ const s = await m.fromDBToEquipableEquipment(a);
1146
+ t = Q(
1296
1147
  t,
1297
- i.characteristics,
1298
- (c, u) => c + u
1148
+ s.characteristics,
1149
+ (i, u) => i + u
1299
1150
  );
1300
1151
  }
1301
- for (const r of a) {
1302
- const s = this.getPanoplyEffectiveBonus(e, r);
1303
- s && !("target" in s) && (t = C(
1304
- t,
1305
- s,
1306
- (i, c) => i + c
1307
- ));
1308
- }
1309
1152
  return t;
1310
1153
  }
1311
1154
  async hasInventoryRequirements(e, t) {
1312
- const a = await this.get(e);
1313
- return x(t).reduce(
1314
- (r, [s, i]) => r && (a.itemList[s] ?? 0) >= (i ?? 0),
1155
+ const r = await this.get(e);
1156
+ return B(t).reduce(
1157
+ (a, [s, i]) => a && (r.itemList[s] ?? 0) >= (i ?? 0),
1315
1158
  !0
1316
1159
  );
1317
1160
  }
1318
- async hasEnoughEntity(e, t, a) {
1319
- return ((await this.get(e)).itemList[a] ?? 0) >= t;
1161
+ async hasEnoughEntity(e, t, r) {
1162
+ return ((await this.get(e)).itemList[r] ?? 0) >= t;
1320
1163
  }
1321
1164
  async getItemList(e) {
1322
1165
  return (await this.get(e)).itemList;
1323
1166
  }
1324
- async calcBottleMultiplier(e, { bottle: { buffs: t } }) {
1325
- const a = await this.get(e), s = (await E.getPanoplyBonus(
1326
- a.equippedItems
1327
- )).find(
1328
- ([i, c]) => i.panoplyId === "herbalist" && c !== null
1329
- );
1330
- return s && s[1] === "full" ? t.map((i) => ({
1331
- ...i,
1332
- multiplier: i.multiplier * 1.25
1333
- })) : s && s[1] === "half" ? t.map((i) => ({
1334
- ...i,
1335
- multiplier: i.multiplier * 1.1
1336
- })) : t;
1337
- }
1338
1167
  async calcMinStreakForWorkLoot(e) {
1339
- const t = await this.get(e), a = (await E.getPanoplyBonus(t.equippedItems)).find(
1340
- ([r, s]) => r.panoplyId === "marine" && s !== null
1168
+ const t = await this.get(e), r = (await R.getPanoplyBonus(t.equippedItems)).find(
1169
+ ([a, s]) => a.panoplyId === "marine" && s !== null
1341
1170
  );
1342
- return a && a[1] === "full" ? 10 : a && a[1] === "half" ? 20 : 1 / 0;
1171
+ return r && r[1] === "full" ? 10 : r && r[1] === "half" ? 20 : 1 / 0;
1343
1172
  }
1344
1173
  async hasRevolutionaryBuff(e) {
1345
1174
  const t = await this.get(e);
1346
- return (await E.getPanoplyBonus(t.equippedItems)).find(
1347
- ([r, s]) => r.panoplyId === "revolutionary" && s !== null
1175
+ return (await R.getPanoplyBonus(t.equippedItems)).find(
1176
+ ([a, s]) => a.panoplyId === "revolutionary" && s !== null
1348
1177
  )?.[1] ?? null;
1349
1178
  }
1350
1179
  /*
1351
1180
  ** UPDATES
1352
1181
  */
1353
- async addItem(e, t, a) {
1182
+ async addItem(e, t, r) {
1354
1183
  await this.update(e, {
1355
- $inc: { [`itemList.${t}`]: a }
1356
- }), await ce.addEntities(e, [t]);
1184
+ $inc: { [`itemList.${t}`]: r }
1185
+ }), await le.addEntities(e, [t]);
1357
1186
  }
1358
1187
  async addItems(e, t) {
1359
1188
  await this.update(e, {
1360
1189
  $inc: Object.fromEntries(
1361
- Object.entries(t).filter(([, a]) => (a ?? 0) > 0).map(([a, r]) => [`itemList.${a}`, r])
1190
+ Object.entries(t).filter(([, r]) => (r ?? 0) > 0).map(([r, a]) => [`itemList.${r}`, a])
1362
1191
  )
1363
- }), await ce.addEntities(
1192
+ }), await le.addEntities(
1364
1193
  e,
1365
- x(t).filter(([, a]) => a > 0).map(([a]) => a)
1194
+ B(t).filter(([, r]) => r > 0).map(([r]) => r)
1366
1195
  );
1367
1196
  }
1368
- async removeItem(e, t, a) {
1369
- a !== 0 && await this.update(e, [
1197
+ async removeItem(e, t, r) {
1198
+ r !== 0 && await this.update(e, [
1370
1199
  {
1371
1200
  $set: {
1372
1201
  [`itemList.${t}`]: {
1373
- $max: [{ $add: [`$itemList.${t}`, -a] }, 0]
1202
+ $max: [{ $add: [`$itemList.${t}`, -r] }, 0]
1374
1203
  }
1375
1204
  }
1376
1205
  }
1377
1206
  ]);
1378
1207
  }
1379
- async removeEquipment(e, t, a) {
1208
+ async removeEquipment(e, t, r) {
1380
1209
  await this.update(e, {
1381
1210
  $pull: {
1382
1211
  equipmentList: {
1383
1212
  entityId: t,
1384
- seed: a
1213
+ seed: r
1385
1214
  }
1386
1215
  }
1387
1216
  });
@@ -1392,9 +1221,9 @@ class Xt extends f {
1392
1221
  async addEquipments(e, t) {
1393
1222
  await this.update(e, {
1394
1223
  $push: { equipmentList: { $each: t } }
1395
- }), await ce.addEntities(
1224
+ }), await le.addEntities(
1396
1225
  e,
1397
- t.map((a) => a.entityId)
1226
+ t.map((r) => r.entityId)
1398
1227
  );
1399
1228
  }
1400
1229
  async saveEquipments(e) {
@@ -1407,64 +1236,64 @@ class Xt extends f {
1407
1236
  ]);
1408
1237
  }
1409
1238
  async changeEquippedEquipment(e, t) {
1410
- const a = await this.get(e);
1411
- a?.equipmentSave[t] && await this.equip(e, a.equipmentSave[t]);
1239
+ const r = await this.get(e);
1240
+ r?.equipmentSave[t] && await this.equip(e, r.equipmentSave[t]);
1412
1241
  }
1413
1242
  async equip(e, t) {
1414
- const a = await U.getMaxHp(e), r = Object.fromEntries(
1415
- x(t).map(([s, i]) => [
1243
+ const r = await O.getMaxHp(e), a = Object.fromEntries(
1244
+ B(t).map(([s, i]) => [
1416
1245
  `equippedItems.${s}`,
1417
1246
  i
1418
1247
  ])
1419
1248
  );
1420
1249
  await this.update(e, {
1421
- $set: r
1422
- }), await U.updateHp(e, a);
1250
+ $set: a
1251
+ }), await O.updateHp(e, r);
1423
1252
  }
1424
1253
  async unequip(e, t) {
1425
- const a = await U.getMaxHp(e);
1254
+ const r = await O.getMaxHp(e);
1426
1255
  await this.update(e, {
1427
1256
  $set: {
1428
1257
  [`equippedItems.${t}`]: null
1429
1258
  }
1430
- }), await U.updateHp(e, a);
1259
+ }), await O.updateHp(e, r);
1431
1260
  }
1432
- async craftItem(e, t, a, r) {
1433
- for (const { entityId: c, size: u } of t.entities)
1434
- await this.removeItem(e, c, u * a);
1261
+ async craftItem(e, t, r, a) {
1262
+ for (const { entityId: u, size: o } of t.entities)
1263
+ await this.removeItem(e, u, o * r);
1435
1264
  const { entityId: s, size: i } = t.result;
1436
- await l.isEntityId(s, l.isEquipment) ? await this.addEquipments(e, [{ entityId: s, seed: r }]) : await l.isEntityId(s, l.isItem) && await this.addItem(e, s, i * a);
1265
+ await m.isEntityId(s, m.isEquipment) ? await this.addEquipments(e, [{ entityId: s, seed: a }]) : await m.isEntityId(s, m.isItem) && await this.addItem(e, s, i * r);
1437
1266
  }
1438
- async dismantleEntity(e, t, a, r, s) {
1439
- l.isEquipment(t) ? await this.removeEquipment(e, t.entityId, s) : l.isItem(t) && await this.removeItem(e, t.entityId, r);
1440
- for (const { entityId: i, quantity: c } of a)
1441
- await l.isEntityId(i, l.isItem) && await this.addItem(e, i, r * c);
1267
+ async dismantleEntity(e, t, r, a, s) {
1268
+ m.isEquipment(t) ? await this.removeEquipment(e, t.entityId, s) : m.isItem(t) && await this.removeItem(e, t.entityId, a);
1269
+ for (const { entityId: i, quantity: u } of r)
1270
+ await m.isEntityId(i, m.isItem) && await this.addItem(e, i, a * u);
1442
1271
  await this.removeItem(e, "tools", 1);
1443
1272
  }
1444
- async enchantItem(e, t, a, r, s) {
1445
- await this.removeItem(e, t, s * 4), await this.removeItem(e, r, s), await this.addItem(e, a, s);
1273
+ async enchantItem(e, t, r, a, s) {
1274
+ await this.removeItem(e, t, s * 4), await this.removeItem(e, a, s), await this.addItem(e, r, s);
1446
1275
  }
1447
1276
  async unlockRecipe(e, t) {
1448
1277
  await this.update(e, { $addToSet: { recipes: t } });
1449
1278
  }
1450
1279
  }
1451
- const Jt = (n) => V.create({
1280
+ const cn = (n) => Z.create({
1452
1281
  user: n
1453
1282
  });
1454
- async function Zt(n) {
1455
- const e = await V.findOne({ user: n }).lean();
1456
- return e || y(await Jt(n));
1283
+ async function on(n) {
1284
+ const e = await Z.findOne({ user: n }).lean();
1285
+ return e || p(await cn(n));
1457
1286
  }
1458
- const en = (n, e) => V.findOneAndUpdate({ user: n }, e, {
1287
+ const dn = (n, e) => Z.findOneAndUpdate({ user: n }, e, {
1459
1288
  upsert: !0,
1460
1289
  returnDocument: "after"
1461
1290
  }).lean();
1462
- class tn extends Xt {
1291
+ class ln extends un {
1463
1292
  constructor() {
1464
1293
  super(300);
1465
1294
  }
1466
1295
  fetchFromDb(e) {
1467
- return Zt(e);
1296
+ return on(e);
1468
1297
  }
1469
1298
  normalizeKey(e) {
1470
1299
  return e.toString();
@@ -1473,17 +1302,17 @@ class tn extends Xt {
1473
1302
  return e;
1474
1303
  }
1475
1304
  updateInDb(e, t) {
1476
- return en(e, t);
1305
+ return dn(e, t);
1477
1306
  }
1478
1307
  }
1479
- const m = new tn();
1480
- class nn extends w {
1308
+ const E = new ln();
1309
+ class pn extends f {
1481
1310
  async getTotalCharacteristics(e) {
1482
- const { characteristics: t, scrolls: a } = await this.get(e);
1483
- return Ie(
1484
- We.map((r) => [
1485
- r,
1486
- Ge(t[r]) + a[r]
1311
+ const { characteristics: t, scrolls: r } = await this.get(e);
1312
+ return Te(
1313
+ Ve.map((a) => [
1314
+ a,
1315
+ Xe(t[a]) + r[a]
1487
1316
  ])
1488
1317
  );
1489
1318
  }
@@ -1530,59 +1359,59 @@ class nn extends w {
1530
1359
  });
1531
1360
  }
1532
1361
  async calcXpBoost(e) {
1533
- const t = await this.get(e), { boost: a } = t.xp, r = a !== null && Date.now() < a.getTime() ? 0.2 : 0, s = Math.max(
1362
+ const t = await this.get(e), { boost: r } = t.xp, a = r !== null && Date.now() < r.getTime() ? 0.2 : 0, s = Math.max(
1534
1363
  t.premium ? 0.5 : 0,
1535
1364
  t.booster ? 0.25 : 0
1536
1365
  );
1537
- return r + s + t.buffs.xp.global.reduce(
1538
- (i, { expireAt: c, startAt: u, multiplier: h }) => u && u > /* @__PURE__ */ new Date() || c && oe(c) ? i : i + h,
1366
+ return a + s + t.buffs.xp.global.reduce(
1367
+ (i, { expireAt: u, startAt: o, multiplier: h }) => o && o > /* @__PURE__ */ new Date() || u && de(u) ? i : i + h,
1539
1368
  0
1540
1369
  );
1541
1370
  }
1542
1371
  calcMessageXp(e) {
1543
- const t = e.trim().length, a = 2;
1544
- return t < 10 ? 10 * a : t > 300 ? 300 * a : t * a;
1372
+ const t = e.trim().length, r = 2;
1373
+ return t < 10 ? 10 * r : t > 300 ? 300 * r : t * r;
1545
1374
  }
1546
1375
  async getXpDeathPenalties(e) {
1547
- const t = await this.get(e), a = Ye(t.xp.amount);
1548
- return a <= 10 ? 5e3 : a <= 20 ? 1e4 : a <= 30 ? 2e4 : a <= 40 ? 3e4 : a <= 50 ? 5e4 : a <= 60 ? 75e3 : a <= 70 ? 15e4 : a <= 80 ? 25e4 : a <= 90 ? 4e5 : a <= 100 ? 75e4 : 14e6;
1376
+ const t = await this.get(e), r = Je(t.xp.amount);
1377
+ return r <= 10 ? 5e3 : r <= 20 ? 1e4 : r <= 30 ? 2e4 : r <= 40 ? 3e4 : r <= 50 ? 5e4 : r <= 60 ? 75e3 : r <= 70 ? 15e4 : r <= 80 ? 25e4 : r <= 90 ? 4e5 : r <= 100 ? 75e4 : 14e6;
1549
1378
  }
1550
- async calcXp(e, t, a) {
1551
- return t *= 1 + await this.calcXpBoost(e), Math.ceil(t * a);
1379
+ async calcXp(e, t, r) {
1380
+ return t *= 1 + await this.calcXpBoost(e), Math.ceil(t * r);
1552
1381
  }
1553
- async calcBerry(e, t, a) {
1382
+ async calcBerry(e, t, r) {
1554
1383
  if (t <= 0) return t;
1555
- const r = a ? 1 : await this.calcBuffMultiplier(e, "berry", "global");
1556
- return Math.ceil(t * (r || 1));
1384
+ const a = r ? 1 : await this.calcBuffMultiplier(e, "berry", "global");
1385
+ return Math.ceil(t * (a || 1));
1557
1386
  }
1558
- async calcBuffMultiplier(e, t, a) {
1559
- return (await this.get(e)).buffs[t][a].reduce(
1560
- (i, { expireAt: c, startAt: u, multiplier: h }) => i + (/* @__PURE__ */ new Date() >= (u ?? /* @__PURE__ */ new Date()) && (!c || !oe(c)) ? h : 0),
1387
+ async calcBuffMultiplier(e, t, r) {
1388
+ return (await this.get(e)).buffs[t][r].reduce(
1389
+ (i, { expireAt: u, startAt: o, multiplier: h }) => i + (/* @__PURE__ */ new Date() >= (o ?? /* @__PURE__ */ new Date()) && (!u || !de(u)) ? h : 0),
1561
1390
  1
1562
1391
  );
1563
1392
  }
1564
1393
  async getMaxHp(e) {
1565
- const t = await m.get(e), { vitality: a } = await this.getTotalCharacteristics(e), r = await m.getUserEquipmentsCharacteristics(
1394
+ const t = await E.get(e), { vitality: r } = await this.getTotalCharacteristics(e), a = await E.getUserEquipmentsCharacteristics(
1566
1395
  t
1567
1396
  );
1568
- return (a + r.vitality) * Ve + Xe;
1397
+ return (r + a.vitality) * Ze + et;
1569
1398
  }
1570
1399
  async getHpRatio(e) {
1571
- const t = await this.get(e), a = await this.getMaxHp(e);
1572
- return Math.min(t.hp / a, 1);
1400
+ const t = await this.get(e), r = await this.getMaxHp(e);
1401
+ return Math.min(t.hp / r, 1);
1573
1402
  }
1574
1403
  async hasCharacteristicRequirement(e, t) {
1575
- const a = await m.get(e), r = await m.getUserEquipmentsCharacteristics(
1576
- a
1577
- ), s = C(
1404
+ const r = await E.get(e), a = await E.getUserEquipmentsCharacteristics(
1405
+ r
1406
+ ), s = Q(
1578
1407
  await this.getTotalCharacteristics(e),
1579
- r,
1580
- (i, c) => i + c
1408
+ a,
1409
+ (i, u) => i + u
1581
1410
  );
1582
1411
  if ("sum" in t) {
1583
1412
  let i = 0;
1584
- for (const c of t.characteristics)
1585
- i += s[c] ?? 0;
1413
+ for (const u of t.characteristics)
1414
+ i += s[u] ?? 0;
1586
1415
  return i >= t.sum;
1587
1416
  } else {
1588
1417
  for (const i of Object.keys(
@@ -1595,10 +1424,10 @@ class nn extends w {
1595
1424
  }
1596
1425
  async hasMalusBuff(e) {
1597
1426
  const t = await this.get(e);
1598
- for (const a of Object.values(t.buffs))
1599
- for (const r of Object.values(a))
1600
- for (const { multiplier: s, startAt: i, expireAt: c } of r)
1601
- if (s < 0 && (!c || !oe(c)) && (i ?? /* @__PURE__ */ new Date()) <= /* @__PURE__ */ new Date())
1427
+ for (const r of Object.values(t.buffs))
1428
+ for (const a of Object.values(r))
1429
+ for (const { multiplier: s, startAt: i, expireAt: u } of a)
1430
+ if (s < 0 && (!u || !de(u)) && (i ?? /* @__PURE__ */ new Date()) <= /* @__PURE__ */ new Date())
1602
1431
  return !0;
1603
1432
  return !1;
1604
1433
  }
@@ -1627,7 +1456,7 @@ class nn extends w {
1627
1456
  }
1628
1457
  async updateBoost(e, t) {
1629
1458
  const {
1630
- xp: { boost: a }
1459
+ xp: { boost: r }
1631
1460
  } = await this.update(e, [
1632
1461
  {
1633
1462
  $set: {
@@ -1646,15 +1475,15 @@ class nn extends w {
1646
1475
  }
1647
1476
  }
1648
1477
  ]);
1649
- return a;
1478
+ return r;
1650
1479
  }
1651
1480
  async updateBuff(e, t) {
1652
1481
  if (Array.isArray(t)) {
1653
- for (const r of t)
1654
- await this.updateBuff(e, r);
1482
+ for (const a of t)
1483
+ await this.updateBuff(e, a);
1655
1484
  return;
1656
1485
  }
1657
- const a = Je(t);
1486
+ const r = tt(t);
1658
1487
  await this.update(e, [
1659
1488
  {
1660
1489
  $set: {
@@ -1679,10 +1508,10 @@ class nn extends w {
1679
1508
  then: {
1680
1509
  multiplier: t.multiplier,
1681
1510
  origin: t.origin,
1682
- expireAt: a.expireAt ? {
1511
+ expireAt: r.expireAt ? {
1683
1512
  $cond: {
1684
1513
  if: { $lt: ["$$buff.expireAt", /* @__PURE__ */ new Date()] },
1685
- then: a.expireAt,
1514
+ then: r.expireAt,
1686
1515
  else: {
1687
1516
  $add: [
1688
1517
  "$$buff.expireAt",
@@ -1735,7 +1564,7 @@ class nn extends w {
1735
1564
  },
1736
1565
  then: `$buffs.${t.target}`,
1737
1566
  else: {
1738
- $concatArrays: [`$buffs.${t.target}`, [{ ...a }]]
1567
+ $concatArrays: [`$buffs.${t.target}`, [{ ...r }]]
1739
1568
  }
1740
1569
  }
1741
1570
  }
@@ -1748,21 +1577,21 @@ class nn extends w {
1748
1577
  $pull: { [`buffs.${t.target}`]: { origin: t.origin } }
1749
1578
  });
1750
1579
  }
1751
- async updatePanoplyBuff(e, t, a, r) {
1752
- const s = await l.fromDBToEquipableEquipment(t), i = _(Object.values(a)), u = (await E.getAllPopulated()).find(
1753
- (D) => D.panoplyId === s.panoply
1580
+ async updatePanoplyBuff(e, t, r, a) {
1581
+ const s = await m.fromDBToEquipableEquipment(t), i = L(Object.values(r)), o = (await R.getAllPopulated()).find(
1582
+ (g) => g.panoplyId === s.panoply
1754
1583
  );
1755
- if (!u)
1584
+ if (!o)
1756
1585
  return;
1757
- const h = u.equipments.filter(
1758
- (D) => (i.find((ue) => D.entityId === ue.entityId) || !r && s.entityId === D.entityId) && (r ? s.entityId !== D.entityId : !0)
1759
- ).length, R = h === u.equipments.length ? u.fullBonus : h >= u.equipments.length / 2 ? u.halfBonus : void 0;
1760
- u.halfBonus && "target" in u.halfBonus && await this.removeBuff(e, u.halfBonus), u.fullBonus && "target" in u.fullBonus && await this.removeBuff(e, u.fullBonus), R && "target" in R && await this.updateBuff(e, R);
1586
+ const h = o.equipments.filter(
1587
+ (g) => (i.find(($) => g.entityId === $.entityId) || !a && s.entityId === g.entityId) && (a ? s.entityId !== g.entityId : !0)
1588
+ ).length, I = h === o.equipments.length ? o.fullBonus : h >= o.equipments.length / 2 ? o.halfBonus : void 0;
1589
+ o.halfBonus && "target" in o.halfBonus && await this.removeBuff(e, o.halfBonus), o.fullBonus && "target" in o.fullBonus && await this.removeBuff(e, o.fullBonus), I && "target" in I && await this.updateBuff(e, I);
1761
1590
  }
1762
1591
  async gainHp(e, t) {
1763
- const a = await this.get(e), s = await this.getMaxHp(e) - a.hp;
1592
+ const r = await this.get(e), s = await this.getMaxHp(e) - r.hp;
1764
1593
  await this.update(e, {
1765
- $set: { hp: a.hp + Math.floor(Math.min(t, s)) }
1594
+ $set: { hp: r.hp + Math.floor(Math.min(t, s)) }
1766
1595
  });
1767
1596
  }
1768
1597
  async loseHp(e, t) {
@@ -1773,14 +1602,14 @@ class nn extends w {
1773
1602
  ]);
1774
1603
  }
1775
1604
  async updateHp(e, t) {
1776
- const a = await this.getMaxHp(e);
1605
+ const r = await this.getMaxHp(e);
1777
1606
  await this.update(e, [
1778
1607
  {
1779
1608
  $set: {
1780
1609
  hp: {
1781
1610
  $round: [
1782
1611
  {
1783
- $multiply: [{ $divide: ["$hp", t] }, a]
1612
+ $multiply: [{ $divide: ["$hp", t] }, r]
1784
1613
  },
1785
1614
  0
1786
1615
  ]
@@ -1790,23 +1619,23 @@ class nn extends w {
1790
1619
  ]);
1791
1620
  }
1792
1621
  async addCharacteristics(e, t) {
1793
- const a = await this.getMaxHp(e), r = Object.fromEntries(
1622
+ const r = await this.getMaxHp(e), a = Object.fromEntries(
1794
1623
  Object.entries(t).filter(([, s]) => s !== 0).map(([s, i]) => [`characteristics.${s}`, i])
1795
1624
  );
1796
1625
  await this.update(e, {
1797
- $inc: r
1798
- }), await this.updateHp(e, a);
1626
+ $inc: a
1627
+ }), await this.updateHp(e, r);
1799
1628
  }
1800
1629
  async addScrollCharacteristic(e, t) {
1801
- const a = await this.getMaxHp(e), r = Object.fromEntries(
1630
+ const r = await this.getMaxHp(e), a = Object.fromEntries(
1802
1631
  Object.entries(t).filter(([, s]) => s !== 0).map(([s, i]) => [`scrolls.${s}`, i])
1803
1632
  );
1804
1633
  await this.update(e, {
1805
- $inc: r
1806
- }), await this.updateHp(e, a);
1634
+ $inc: a
1635
+ }), await this.updateHp(e, r);
1807
1636
  }
1808
- async resetCharacteristics(e, t) {
1809
- const a = await this.getMaxHp(e), r = {
1637
+ async resetCharacteristics(e) {
1638
+ const t = await this.getMaxHp(e), r = {
1810
1639
  vitality: 0,
1811
1640
  strength: 0,
1812
1641
  agility: 0,
@@ -1814,22 +1643,14 @@ class nn extends w {
1814
1643
  intelligence: 0,
1815
1644
  wisdom: 0
1816
1645
  };
1817
- t ? await this.update(e, {
1818
- $set: {
1819
- characteristics: r,
1820
- "resetCharacteristics.free": !1
1821
- }
1822
- }) : await this.update(e, {
1646
+ await this.update(e, {
1823
1647
  $set: {
1824
- characteristics: r,
1825
- "resetCharacteristics.nextAvailable": new Date(
1826
- Date.now() + 720 * 60 * 60 * 1e3
1827
- )
1648
+ characteristics: r
1828
1649
  },
1829
1650
  $inc: {
1830
1651
  berry: -1e8
1831
1652
  }
1832
- }), await this.updateHp(e, a);
1653
+ }), await this.updateHp(e, t);
1833
1654
  }
1834
1655
  async updateLastMessageWithXpDate(e) {
1835
1656
  await this.update(e, { $set: { "xp.lastMessageWithXp": /* @__PURE__ */ new Date() } });
@@ -1858,30 +1679,30 @@ class nn extends w {
1858
1679
  });
1859
1680
  }
1860
1681
  async updateUserXp(e, t) {
1861
- const a = await this.calcXp(
1682
+ const r = await this.calcXp(
1862
1683
  e,
1863
1684
  t,
1864
1685
  await this.getHpRatio(e)
1865
1686
  );
1866
- return await this.addXp(e, a), a;
1687
+ return await this.addXp(e, r), r;
1867
1688
  }
1868
- async updateUserBerry(e, t, a) {
1869
- const r = await this.calcBerry(e, t, a);
1870
- return await this.addBerry(e, r), r;
1689
+ async updateUserBerry(e, t, r) {
1690
+ const a = await this.calcBerry(e, t, r);
1691
+ return await this.addBerry(e, a), a;
1871
1692
  }
1872
1693
  }
1873
- const an = (n) => O.find(n).lean(), rn = async (n) => await O.create({
1694
+ const yn = (n) => v.find(n).lean(), fn = async (n) => await v.create({
1874
1695
  user: n
1875
1696
  });
1876
- async function sn(n) {
1877
- const e = await O.findOne({ user: n }).lean();
1878
- return e || y(await rn(n));
1697
+ async function mn(n) {
1698
+ const e = await v.findOne({ user: n }).lean();
1699
+ return e || p(await fn(n));
1879
1700
  }
1880
- const un = (n, e) => O.findOneAndUpdate({ user: n }, e, {
1701
+ const hn = (n, e) => v.findOneAndUpdate({ user: n }, e, {
1881
1702
  returnDocument: "after",
1882
1703
  upsert: !0
1883
1704
  }).lean();
1884
- class on extends nn {
1705
+ class gn extends pn {
1885
1706
  constructor() {
1886
1707
  super(300);
1887
1708
  }
@@ -1892,17 +1713,17 @@ class on extends nn {
1892
1713
  return e;
1893
1714
  }
1894
1715
  fetchFromDb(e) {
1895
- return sn(e);
1716
+ return mn(e);
1896
1717
  }
1897
1718
  fetchManyFromDb(e) {
1898
- return an(e);
1719
+ return yn(e);
1899
1720
  }
1900
1721
  updateInDb(e, t) {
1901
- return un(e, t);
1722
+ return hn(e, t);
1902
1723
  }
1903
1724
  }
1904
- const U = new on();
1905
- class cn extends w {
1725
+ const O = new gn();
1726
+ class Sn extends f {
1906
1727
  async updateSendDailyQuest(e, t) {
1907
1728
  await this.update(e, { $set: { sendDailyQuest: t } });
1908
1729
  }
@@ -1912,8 +1733,8 @@ class cn extends w {
1912
1733
  async updateInventorySort(e, t) {
1913
1734
  await this.update(e, { $set: { "sort.inventory": t } });
1914
1735
  }
1915
- async updateReminderSettings(e, t, a) {
1916
- await this.update(e, { $set: { [`reminder.${t}`]: a } });
1736
+ async updateReminderSettings(e, t, r) {
1737
+ await this.update(e, { $set: { [`reminder.${t}`]: r } });
1917
1738
  }
1918
1739
  getUsersWithDailyReportEnable() {
1919
1740
  return this.getMany({
@@ -1921,18 +1742,18 @@ class cn extends w {
1921
1742
  });
1922
1743
  }
1923
1744
  }
1924
- const ln = (n) => N.find(n).lean(), dn = async (n) => await N.create({
1745
+ const wn = (n) => F.find(n).lean(), bn = async (n) => await F.create({
1925
1746
  user: n
1926
1747
  });
1927
- async function pn(n) {
1928
- const e = await N.findOne({ user: n }).lean();
1929
- return e || y(await dn(n));
1748
+ async function $n(n) {
1749
+ const e = await F.findOne({ user: n }).lean();
1750
+ return e || p(await bn(n));
1930
1751
  }
1931
- const yn = (n, e) => N.findOneAndUpdate({ user: n }, e, {
1752
+ const In = (n, e) => F.findOneAndUpdate({ user: n }, e, {
1932
1753
  returnDocument: "after",
1933
1754
  upsert: !0
1934
1755
  }).lean();
1935
- class fn extends cn {
1756
+ class Un extends Sn {
1936
1757
  constructor() {
1937
1758
  super(3600);
1938
1759
  }
@@ -1943,17 +1764,17 @@ class fn extends cn {
1943
1764
  return e.user;
1944
1765
  }
1945
1766
  fetchFromDb(e) {
1946
- return pn(e);
1767
+ return $n(e);
1947
1768
  }
1948
1769
  fetchManyFromDb(e) {
1949
- return ln(e);
1770
+ return wn(e);
1950
1771
  }
1951
1772
  updateInDb(e, t) {
1952
- return yn(e, t);
1773
+ return In(e, t);
1953
1774
  }
1954
1775
  }
1955
- const _e = new fn();
1956
- class mn extends f {
1776
+ const Fe = new Un();
1777
+ class Tn extends y {
1957
1778
  async getCommandCooldown(e, t) {
1958
1779
  return (await this.get(e)).commands[t];
1959
1780
  }
@@ -1962,33 +1783,33 @@ class mn extends f {
1962
1783
  $set: {
1963
1784
  lockUserCommand: new Date(Date.now() + 2 * 3600 * 1e3)
1964
1785
  }
1965
- }), await U.gainHp(e, 1);
1786
+ }), await O.gainHp(e, 1);
1966
1787
  }
1967
- async useCommand(e, t, a) {
1968
- const { reminder: r } = await _e.get(e);
1788
+ async useCommand(e, t, r) {
1789
+ const { reminder: a } = await Fe.get(e);
1969
1790
  await this.update(e, {
1970
1791
  $set: {
1971
- [`commands.${t}`]: new Date(Date.now() + a)
1792
+ [`commands.${t}`]: new Date(Date.now() + r)
1972
1793
  }
1973
- }), r.commands[t] && await Bt.addReminder(
1794
+ }), a.commands[t] && await Rt.addReminder(
1974
1795
  e,
1975
1796
  `commands/${t}`,
1976
- new Date(Date.now() + a)
1797
+ new Date(Date.now() + r)
1977
1798
  );
1978
1799
  }
1979
1800
  }
1980
- const hn = async (n) => await Q.create({
1801
+ const En = async (n) => await W.create({
1981
1802
  user: n
1982
1803
  });
1983
- async function gn(n) {
1984
- const e = await Q.findOne({ user: n }).lean();
1985
- return e || y(await hn(n));
1804
+ async function On(n) {
1805
+ const e = await W.findOne({ user: n }).lean();
1806
+ return e || p(await En(n));
1986
1807
  }
1987
- const wn = (n, e) => Q.findOneAndUpdate({ user: n }, e, {
1808
+ const Dn = (n, e) => W.findOneAndUpdate({ user: n }, e, {
1988
1809
  returnDocument: "after",
1989
1810
  upsert: !0
1990
1811
  }).lean();
1991
- class Sn extends mn {
1812
+ class vn extends Tn {
1992
1813
  constructor() {
1993
1814
  super(300);
1994
1815
  }
@@ -1999,17 +1820,17 @@ class Sn extends mn {
1999
1820
  return e.user;
2000
1821
  }
2001
1822
  fetchFromDb(e) {
2002
- return gn(e);
1823
+ return On(e);
2003
1824
  }
2004
1825
  updateInDb(e, t) {
2005
- return wn(e, t);
1826
+ return Dn(e, t);
2006
1827
  }
2007
1828
  }
2008
- const Nr = new Sn();
2009
- class bn extends w {
1829
+ const Qa = new vn();
1830
+ class Mn extends f {
2010
1831
  async isOrnamentIds(e, t = () => !0) {
2011
- const r = (await this.getAll()).filter(t).map(({ ornamentId: s }) => s);
2012
- return e.every((s) => r.includes(s));
1832
+ const a = (await this.getAll()).filter(t).map(({ ornamentId: s }) => s);
1833
+ return e.every((s) => a.includes(s));
2013
1834
  }
2014
1835
  isOrnament(e) {
2015
1836
  return !!e && "ornamentId" in e;
@@ -2045,47 +1866,47 @@ class bn extends w {
2045
1866
  return (await this.getAll()).filter((e) => this.isShopTitle(e));
2046
1867
  }
2047
1868
  formatBackgroundId(e) {
2048
- const t = nt(e) ? e : e.ornamentId;
2049
- return t === "background_default" ? "par défaut" : `"${at(t.split("_").join(" "))}"`;
1869
+ const t = ot(e) ? e : e.ornamentId;
1870
+ return t === "background_default" ? "par défaut" : `"${dt(t.split("_").join(" "))}"`;
2050
1871
  }
2051
1872
  async getSomeShopTitles(e) {
2052
1873
  const t = await this.getAllShopTitles();
2053
- return H(
2054
- le(
1874
+ return pe(
1875
+ Se(
2055
1876
  e,
2056
1877
  t,
2057
- (a) => a.ornamentId,
2058
- (a) => a.odd ?? 0
1878
+ (r) => r.ornamentId,
1879
+ (r) => r.odd ?? 0
2059
1880
  ),
2060
- (a) => a.price
1881
+ (r) => r.price
2061
1882
  );
2062
1883
  }
2063
1884
  async getSomeBackgrounds(e) {
2064
1885
  const t = await this.getAllBackgrounds();
2065
- return H(
2066
- le(
1886
+ return pe(
1887
+ Se(
2067
1888
  e,
2068
1889
  t,
2069
- (a) => a.ornamentId,
2070
- (a) => a.odd ?? 0
1890
+ (r) => r.ornamentId,
1891
+ (r) => r.odd ?? 0
2071
1892
  ),
2072
- (a) => a.price ?? 0
1893
+ (r) => r.price ?? 0
2073
1894
  );
2074
1895
  }
2075
1896
  pickEachRarityOrnament(e, t) {
2076
- if (t.length !== he.length)
1897
+ if (t.length !== ge.length)
2077
1898
  throw new RangeError(
2078
1899
  "pickEachRarityOrnament - must give same number of odds than ranks"
2079
1900
  );
2080
- return _(
2081
- t.map((a, r) => {
2082
- const s = he[r], i = e[s];
2083
- return Math.random() > a || !i || !i.length ? null : rt(i);
1901
+ return L(
1902
+ t.map((r, a) => {
1903
+ const s = ge[a], i = e[s];
1904
+ return Math.random() > r || !i || !i.length ? null : lt(i);
2084
1905
  })
2085
1906
  );
2086
1907
  }
2087
1908
  }
2088
- const $n = new o(
1909
+ const xn = new c(
2089
1910
  {
2090
1911
  ornamentId: { unique: !0, index: 1, required: !0, type: String },
2091
1912
  type: { required: !0, type: String },
@@ -2099,26 +1920,26 @@ const $n = new o(
2099
1920
  strength: Number
2100
1921
  },
2101
1922
  { minimize: !1 }
2102
- ), pe = d?.Ornaments || p("Ornaments", $n), In = async (n, e) => pe.find(n, {}, e).lean();
2103
- async function En(n) {
2104
- const e = await pe.findOne({ ornamentId: n }).lean();
1923
+ ), fe = d?.Ornaments || l("Ornaments", xn), qn = async (n, e) => fe.find(n, {}, e).lean();
1924
+ async function An(n) {
1925
+ const e = await fe.findOne({ ornamentId: n }).lean();
2105
1926
  return e || null;
2106
1927
  }
2107
- const Un = (n, e) => pe.findOneAndUpdate(n, e, {
1928
+ const kn = (n, e) => fe.findOneAndUpdate(n, e, {
2108
1929
  returnDocument: "after"
2109
1930
  }).lean();
2110
- class Dn extends bn {
1931
+ class Rn extends Mn {
2111
1932
  constructor() {
2112
1933
  super(3600);
2113
1934
  }
2114
1935
  updateInDb(e, t) {
2115
- return Un(e, t);
1936
+ return kn(e, t);
2116
1937
  }
2117
1938
  fetchFromDb(e) {
2118
- return En(e);
1939
+ return An(e);
2119
1940
  }
2120
1941
  fetchManyFromDb(e, t) {
2121
- return In(e, t);
1942
+ return qn(e, t);
2122
1943
  }
2123
1944
  getKey(e) {
2124
1945
  return e.ornamentId;
@@ -2127,13 +1948,13 @@ class Dn extends bn {
2127
1948
  return e;
2128
1949
  }
2129
1950
  }
2130
- const g = new Dn();
2131
- class Tn extends f {
1951
+ const U = new Rn();
1952
+ class Cn extends y {
2132
1953
  async unlockTitle(e, t) {
2133
- await g.isOrnamentIds([t], g.isTitle) && await this.update(e, { $addToSet: { unlockedTitles: t } });
1954
+ await U.isOrnamentIds([t], U.isTitle) && await this.update(e, { $addToSet: { unlockedTitles: t } });
2134
1955
  }
2135
1956
  async unlockTitles(e, t) {
2136
- await g.isOrnamentIds(t, g.isTitle) && await this.update(e, {
1957
+ await U.isOrnamentIds(t, U.isTitle) && await this.update(e, {
2137
1958
  $addToSet: { unlockedTitles: { $each: t } }
2138
1959
  });
2139
1960
  }
@@ -2141,17 +1962,17 @@ class Tn extends f {
2141
1962
  await this.update(e, { $set: { selectedTitle: t } });
2142
1963
  }
2143
1964
  async unlockBackground(e, t) {
2144
- await g.isOrnamentIds(
1965
+ await U.isOrnamentIds(
2145
1966
  [t],
2146
- g.isBackground
1967
+ U.isBackground
2147
1968
  ) && await this.update(e, {
2148
1969
  $addToSet: { unlockedBackgrounds: t }
2149
1970
  });
2150
1971
  }
2151
1972
  async unlockBackgrounds(e, t) {
2152
- await g.isOrnamentIds(
1973
+ await U.isOrnamentIds(
2153
1974
  t,
2154
- g.isBackground
1975
+ U.isBackground
2155
1976
  ) && await this.update(e, {
2156
1977
  $addToSet: { unlockedBackgrounds: { $each: t } }
2157
1978
  });
@@ -2161,9 +1982,9 @@ class Tn extends f {
2161
1982
  $set: { selectedBackground: t }
2162
1983
  });
2163
1984
  }
2164
- async unlockBadge(e, t, a) {
1985
+ async unlockBadge(e, t, r) {
2165
1986
  t.isProgressive ? await this.update(e, {
2166
- $addToSet: { unlockedBadges: `${t.id}_${a}` }
1987
+ $addToSet: { unlockedBadges: `${t.id}_${r}` }
2167
1988
  }) : await this.update(e, {
2168
1989
  $addToSet: { unlockedBadges: t.id }
2169
1990
  });
@@ -2197,18 +2018,18 @@ class Tn extends f {
2197
2018
  });
2198
2019
  }
2199
2020
  }
2200
- const On = async (n) => await X.create({
2021
+ const _n = async (n) => await ee.create({
2201
2022
  user: n
2202
2023
  });
2203
- async function vn(n) {
2204
- const e = await X.findOne({ user: n }).lean();
2205
- return e || y(await On(n));
2024
+ async function Bn(n) {
2025
+ const e = await ee.findOne({ user: n }).lean();
2026
+ return e || p(await _n(n));
2206
2027
  }
2207
- const Bn = async (n, e) => X.findOneAndUpdate({ user: n }, e, {
2028
+ const Fn = async (n, e) => ee.findOneAndUpdate({ user: n }, e, {
2208
2029
  upsert: !0,
2209
2030
  returnDocument: "after"
2210
2031
  }).lean();
2211
- class Mn extends Tn {
2032
+ class Nn extends Cn {
2212
2033
  constructor() {
2213
2034
  super(300);
2214
2035
  }
@@ -2219,14 +2040,14 @@ class Mn extends Tn {
2219
2040
  return e;
2220
2041
  }
2221
2042
  fetchFromDb(e) {
2222
- return vn(e);
2043
+ return Bn(e);
2223
2044
  }
2224
2045
  updateInDb(e, t) {
2225
- return Bn(e, t);
2046
+ return Fn(e, t);
2226
2047
  }
2227
2048
  }
2228
- const L = new Mn();
2229
- class kn extends w {
2049
+ const we = new Nn();
2050
+ class Kn extends f {
2230
2051
  async getStatus(e, t) {
2231
2052
  return (await this.get({ user: e, questId: t })).status;
2232
2053
  }
@@ -2234,21 +2055,21 @@ class kn extends w {
2234
2055
  return await this.getStatus(e, t) === "COMPLETED";
2235
2056
  }
2236
2057
  async isStreaking(e, t) {
2237
- const { lastCompletionDate: a } = await this.get({ user: e, questId: t });
2238
- return !!a && Ue(K(), a);
2058
+ const { lastCompletionDate: r } = await this.get({ user: e, questId: t });
2059
+ return !!r && Oe(Y(), r);
2239
2060
  }
2240
2061
  async getStreakMultiplier(e, t) {
2241
- const a = await this.get({ user: e, questId: t });
2242
- return await this.isStreaking(e, t) ? 1 + Math.min(2, (a.streak ?? 0) / 10) : 1;
2062
+ const r = await this.get({ user: e, questId: t });
2063
+ return await this.isStreaking(e, t) ? 1 + Math.min(2, (r.streak ?? 0) / 10) : 1;
2243
2064
  }
2244
2065
  async getCompletedCount(e) {
2245
- return (await this.getMany({ user: e, status: M.COMPLETED })).length;
2066
+ return (await this.getMany({ user: e, status: q.COMPLETED })).length;
2246
2067
  }
2247
2068
  async completeQuest(e, t = !1) {
2248
- const a = K();
2249
- a.setHours(0, 0, 0, 0);
2250
- const r = /* @__PURE__ */ new Date();
2251
- return r.setHours(0, 0, 0, 0), this.update(
2069
+ const r = Y();
2070
+ r.setHours(0, 0, 0, 0);
2071
+ const a = /* @__PURE__ */ new Date();
2072
+ return a.setHours(0, 0, 0, 0), this.update(
2252
2073
  e,
2253
2074
  [
2254
2075
  {
@@ -2258,8 +2079,8 @@ class kn extends w {
2258
2079
  $cond: {
2259
2080
  if: {
2260
2081
  $and: [
2261
- { $gte: ["$lastCompletionDate", a] },
2262
- { $lt: ["$lastCompletionDate", r] }
2082
+ { $gte: ["$lastCompletionDate", r] },
2083
+ { $lt: ["$lastCompletionDate", a] }
2263
2084
  ]
2264
2085
  },
2265
2086
  then: { $add: [{ $ifNull: ["$streak", 0] }, 1] },
@@ -2268,7 +2089,7 @@ class kn extends w {
2268
2089
  }
2269
2090
  } : {},
2270
2091
  lastCompletionDate: /* @__PURE__ */ new Date(),
2271
- status: M.COMPLETED
2092
+ status: q.COMPLETED
2272
2093
  }
2273
2094
  }
2274
2095
  ],
@@ -2276,24 +2097,24 @@ class kn extends w {
2276
2097
  );
2277
2098
  }
2278
2099
  }
2279
- function An(n) {
2280
- return q.find(n).lean();
2100
+ function Hn(n) {
2101
+ return C.find(n).lean();
2281
2102
  }
2282
- const qn = async (n) => await q.create({
2103
+ const Pn = async (n) => await C.create({
2283
2104
  ...n
2284
2105
  });
2285
- async function Rn(n) {
2286
- const e = await q.findOne(n).lean();
2287
- return e || y(await qn(n));
2106
+ async function jn(n) {
2107
+ const e = await C.findOne(n).lean();
2108
+ return e || p(await Pn(n));
2288
2109
  }
2289
- function xn(n, e, t) {
2290
- return q.findOneAndUpdate(n, e, {
2110
+ function zn(n, e, t) {
2111
+ return C.findOneAndUpdate(n, e, {
2291
2112
  upsert: !0,
2292
2113
  ...t,
2293
2114
  returnDocument: "after"
2294
2115
  }).lean();
2295
2116
  }
2296
- class _n extends kn {
2117
+ class Ln extends Kn {
2297
2118
  constructor() {
2298
2119
  super(3600);
2299
2120
  }
@@ -2307,17 +2128,17 @@ class _n extends kn {
2307
2128
  return { user: e, questId: t };
2308
2129
  }
2309
2130
  fetchFromDb(e) {
2310
- return Rn(e);
2131
+ return jn(e);
2311
2132
  }
2312
2133
  fetchManyFromDb(e) {
2313
- return An(e);
2134
+ return Hn(e);
2314
2135
  }
2315
- updateInDb(e, t, a) {
2316
- return xn(e, t, a);
2136
+ updateInDb(e, t, r) {
2137
+ return zn(e, t, r);
2317
2138
  }
2318
2139
  }
2319
- const we = new _n();
2320
- class Cn extends f {
2140
+ const be = new Ln();
2141
+ class Qn extends y {
2321
2142
  async randomMessageIncrement(e) {
2322
2143
  await this.update(e, { $inc: { randomMessageClaimed: 1 } });
2323
2144
  }
@@ -2335,18 +2156,18 @@ class Cn extends f {
2335
2156
  await this.update(e, { $inc: { totalMinutesInVoice: t } });
2336
2157
  }
2337
2158
  }
2338
- const Nn = async (n) => await ee.create({
2159
+ const Yn = async (n) => await ne.create({
2339
2160
  user: n
2340
2161
  });
2341
- async function Fn(n) {
2342
- const e = await ee.findOne({ user: n }).lean();
2343
- return e || y(await Nn(n));
2162
+ async function Gn(n) {
2163
+ const e = await ne.findOne({ user: n }).lean();
2164
+ return e || p(await Yn(n));
2344
2165
  }
2345
- const zn = (n, e) => ee.findOneAndUpdate({ user: n }, e, {
2166
+ const Wn = (n, e) => ne.findOneAndUpdate({ user: n }, e, {
2346
2167
  upsert: !0,
2347
2168
  returnDocument: "after"
2348
2169
  }).lean();
2349
- class jn extends Cn {
2170
+ class Vn extends Qn {
2350
2171
  constructor() {
2351
2172
  super(300);
2352
2173
  }
@@ -2359,29 +2180,29 @@ class jn extends Cn {
2359
2180
  return e;
2360
2181
  }
2361
2182
  fetchFromDb(e) {
2362
- return Fn(e);
2183
+ return Gn(e);
2363
2184
  }
2364
2185
  updateInDb(e, t) {
2365
- return zn(e, t);
2186
+ return Wn(e, t);
2366
2187
  }
2367
2188
  }
2368
- const Se = new jn();
2369
- class Hn extends f {
2189
+ const $e = new Vn();
2190
+ class Xn extends y {
2370
2191
  async updateDailyReport(e) {
2371
- const t = await U.get(e), a = await L.get(e), r = await we.getMany({
2192
+ const t = await O.get(e), r = await we.get(e), a = await be.getMany({
2372
2193
  user: e,
2373
- status: M.COMPLETED
2374
- }), s = await Se.get(e);
2194
+ status: q.COMPLETED
2195
+ }), s = await $e.get(e);
2375
2196
  await this.update(e, {
2376
2197
  $set: {
2377
2198
  xpYesterday: t.xp.amount,
2378
2199
  berryYesterday: t.berry,
2379
- previousCompletedQuest: r.map(
2200
+ previousCompletedQuest: a.map(
2380
2201
  ({ questId: i }) => i
2381
2202
  ),
2382
- "previousOrnament.unlockedBadges": a.unlockedBadges,
2383
- "previousOrnament.unlockedTitles": a.unlockedTitles,
2384
- "previousOrnament.unlockedBackgrounds": a.unlockedBackgrounds,
2203
+ "previousOrnament.unlockedBadges": r.unlockedBadges,
2204
+ "previousOrnament.unlockedTitles": r.unlockedTitles,
2205
+ "previousOrnament.unlockedBackgrounds": r.unlockedBackgrounds,
2385
2206
  previousMessageSent: s.messageSent
2386
2207
  }
2387
2208
  });
@@ -2389,57 +2210,57 @@ class Hn extends f {
2389
2210
  async getDailyReport(e) {
2390
2211
  const {
2391
2212
  previousOrnament: t,
2392
- previousCompletedQuest: a,
2393
- xpYesterday: r,
2213
+ previousCompletedQuest: r,
2214
+ xpYesterday: a,
2394
2215
  berryYesterday: s,
2395
2216
  previousMessageSent: i
2396
- } = await this.get(e), c = await U.get(e), u = await we.getMany({
2217
+ } = await this.get(e), u = await O.get(e), o = await be.getMany({
2397
2218
  user: e,
2398
- status: M.COMPLETED
2399
- }), h = await L.get(e), R = await Se.get(e), { berry: D, xp: ue } = c, { voice: me, amount: Ce } = ue, { unlockedBadges: Ne, unlockedBackgrounds: Fe, unlockedTitles: ze } = h;
2219
+ status: q.COMPLETED
2220
+ }), h = await we.get(e), I = await $e.get(e), { berry: g, xp: $ } = u, { voice: he, amount: He } = $, { unlockedBadges: Pe, unlockedBackgrounds: je, unlockedTitles: ze } = h;
2400
2221
  return {
2401
- berry: D - s,
2402
- xp: Ce - r,
2403
- message: R.messageSent - i,
2404
- voice: Ue(me.lastConnection, K()) ? me.minutesInVoiceToday : 0,
2405
- quest: j(
2406
- u.map(({ questId: je }) => je),
2407
- a
2222
+ berry: g - s,
2223
+ xp: He - a,
2224
+ message: I.messageSent - i,
2225
+ voice: Oe(he.lastConnection, Y()) ? he.minutesInVoiceToday : 0,
2226
+ quest: P(
2227
+ o.map(({ questId: Le }) => Le),
2228
+ r
2408
2229
  ),
2409
- badge: j(Ne, t.unlockedBadges),
2410
- title: j(ze, t.unlockedTitles),
2411
- background: j(
2412
- Fe,
2230
+ badge: P(Pe, t.unlockedBadges),
2231
+ title: P(ze, t.unlockedTitles),
2232
+ background: P(
2233
+ je,
2413
2234
  t.unlockedBackgrounds
2414
2235
  )
2415
2236
  };
2416
2237
  }
2417
2238
  async getAllDailyReportsToSend() {
2418
- const e = await _e.getUsersWithDailyReportEnable(), t = await bt.getMany({
2419
- _id: { $in: e.map(({ user: a }) => a) },
2239
+ const e = await Fe.getUsersWithDailyReportEnable(), t = await Et.getMany({
2240
+ _id: { $in: e.map(({ user: r }) => r) },
2420
2241
  faction: { $ne: "citizen" }
2421
2242
  });
2422
2243
  return await Promise.all(
2423
- t.map(async ({ _id: a, discordId: r }) => ({
2424
- report: await this.getDailyReport(a),
2425
- user: a,
2426
- discordId: r
2244
+ t.map(async ({ _id: r, discordId: a }) => ({
2245
+ report: await this.getDailyReport(r),
2246
+ user: r,
2247
+ discordId: a
2427
2248
  }))
2428
2249
  );
2429
2250
  }
2430
2251
  }
2431
- const Kn = (n) => W.create({
2252
+ const Jn = (n) => V.create({
2432
2253
  user: n
2433
2254
  });
2434
- async function Pn(n) {
2435
- const e = await W.findOne({ user: n }).lean();
2436
- return e || y(await Kn(n));
2255
+ async function Zn(n) {
2256
+ const e = await V.findOne({ user: n }).lean();
2257
+ return e || p(await Jn(n));
2437
2258
  }
2438
- const Ln = (n, e) => W.findOneAndUpdate({ user: n }, e, {
2259
+ const er = (n, e) => V.findOneAndUpdate({ user: n }, e, {
2439
2260
  upsert: !0,
2440
2261
  returnDocument: "after"
2441
2262
  }).lean();
2442
- class Qn extends Hn {
2263
+ class tr extends Xn {
2443
2264
  constructor() {
2444
2265
  super(60);
2445
2266
  }
@@ -2450,21 +2271,21 @@ class Qn extends Hn {
2450
2271
  return e.user;
2451
2272
  }
2452
2273
  fetchFromDb(e) {
2453
- return Pn(e);
2274
+ return Zn(e);
2454
2275
  }
2455
2276
  updateInDb(e, t) {
2456
- return Ln(e, t);
2277
+ return er(e, t);
2457
2278
  }
2458
2279
  }
2459
- const Fr = new Qn();
2460
- class Wn extends f {
2461
- async setGuessGame(e, t, a, r) {
2280
+ const Ya = new tr();
2281
+ class nr extends y {
2282
+ async setGuessGame(e, t, r, a) {
2462
2283
  await this.update(e, {
2463
2284
  $set: {
2464
2285
  guess: {
2465
2286
  amount: t,
2466
- tries: a,
2467
- numberToGuess: r,
2287
+ tries: r,
2288
+ numberToGuess: a,
2468
2289
  lastGuess: 0
2469
2290
  }
2470
2291
  }
@@ -2488,18 +2309,18 @@ class Wn extends f {
2488
2309
  });
2489
2310
  }
2490
2311
  }
2491
- const Gn = async (n) => await Y.create({
2312
+ const rr = async (n) => await J.create({
2492
2313
  user: n
2493
2314
  });
2494
- async function Yn(n) {
2495
- const e = await Y.findOne({ user: n }).lean();
2496
- return e || y(await Gn(n));
2315
+ async function ar(n) {
2316
+ const e = await J.findOne({ user: n }).lean();
2317
+ return e || p(await rr(n));
2497
2318
  }
2498
- const Vn = (n, e) => Y.findOneAndUpdate({ user: n }, e, {
2319
+ const sr = (n, e) => J.findOneAndUpdate({ user: n }, e, {
2499
2320
  upsert: !0,
2500
2321
  returnDocument: "after"
2501
2322
  }).lean();
2502
- class Xn extends Wn {
2323
+ class ir extends nr {
2503
2324
  constructor() {
2504
2325
  super(300);
2505
2326
  }
@@ -2510,15 +2331,15 @@ class Xn extends Wn {
2510
2331
  return e;
2511
2332
  }
2512
2333
  fetchFromDb(e) {
2513
- return Yn(e);
2334
+ return ar(e);
2514
2335
  }
2515
2336
  updateInDb(e, t) {
2516
- return Vn(e, t);
2337
+ return sr(e, t);
2517
2338
  }
2518
2339
  }
2519
- const zr = new Xn(), Jn = new o({
2340
+ const Ga = new ir(), ur = new c({
2520
2341
  user: {
2521
- type: o.Types.ObjectId,
2342
+ type: c.Types.ObjectId,
2522
2343
  required: !0,
2523
2344
  unique: !0,
2524
2345
  ref: "User"
@@ -2526,10 +2347,10 @@ const zr = new Xn(), Jn = new o({
2526
2347
  xp: { type: Number, default: 0 },
2527
2348
  berry: { type: Number, default: 0 },
2528
2349
  faction: { type: Number, default: 0 }
2529
- }), B = d?.UserRank || p("UserRank", Jn);
2530
- class Zn extends f {
2350
+ }), x = d?.UserRank || l("UserRank", ur);
2351
+ class cr extends y {
2531
2352
  async computeAllXpRanks() {
2532
- const t = (await O.aggregate([
2353
+ const t = (await v.aggregate([
2533
2354
  {
2534
2355
  $setWindowFields: {
2535
2356
  sortBy: { "xp.amount": -1 },
@@ -2537,17 +2358,17 @@ class Zn extends f {
2537
2358
  }
2538
2359
  },
2539
2360
  { $project: { user: 1, xpRank: 1 } }
2540
- ])).map(({ user: a, xpRank: r }) => ({
2361
+ ])).map(({ user: r, xpRank: a }) => ({
2541
2362
  updateOne: {
2542
- filter: { user: a },
2543
- update: { $set: { xp: r } },
2363
+ filter: { user: r },
2364
+ update: { $set: { xp: a } },
2544
2365
  upsert: !0
2545
2366
  }
2546
2367
  }));
2547
- t.length > 0 && await B.bulkWrite(t), this.clearAll();
2368
+ t.length > 0 && await x.bulkWrite(t), this.clearAll();
2548
2369
  }
2549
2370
  async computeAllBerryRanks() {
2550
- const t = (await O.aggregate([
2371
+ const t = (await v.aggregate([
2551
2372
  {
2552
2373
  $setWindowFields: {
2553
2374
  sortBy: { berry: -1 },
@@ -2555,17 +2376,17 @@ class Zn extends f {
2555
2376
  }
2556
2377
  },
2557
2378
  { $project: { user: 1, berryRank: 1 } }
2558
- ])).map(({ user: a, berryRank: r }) => ({
2379
+ ])).map(({ user: r, berryRank: a }) => ({
2559
2380
  updateOne: {
2560
- filter: { user: a },
2561
- update: { $set: { berry: r } },
2381
+ filter: { user: r },
2382
+ update: { $set: { berry: a } },
2562
2383
  upsert: !0
2563
2384
  }
2564
2385
  }));
2565
- t.length > 0 && await B.bulkWrite(t), this.clearAll();
2386
+ t.length > 0 && await x.bulkWrite(t), this.clearAll();
2566
2387
  }
2567
2388
  async computeAllFactionRanks() {
2568
- const t = (await $.aggregate([
2389
+ const t = (await b.aggregate([
2569
2390
  {
2570
2391
  $lookup: {
2571
2392
  from: "usermetas",
@@ -2583,14 +2404,14 @@ class Zn extends f {
2583
2404
  }
2584
2405
  },
2585
2406
  { $project: { factionRank: 1 } }
2586
- ])).map(({ _id: a, factionRank: r }) => ({
2407
+ ])).map(({ _id: r, factionRank: a }) => ({
2587
2408
  updateOne: {
2588
- filter: { user: a },
2589
- update: { $set: { faction: r } },
2409
+ filter: { user: r },
2410
+ update: { $set: { faction: a } },
2590
2411
  upsert: !0
2591
2412
  }
2592
2413
  }));
2593
- t.length > 0 && await B.bulkWrite(t), this.clearAll();
2414
+ t.length > 0 && await x.bulkWrite(t), this.clearAll();
2594
2415
  }
2595
2416
  async computeAllRanks() {
2596
2417
  await Promise.all([
@@ -2600,18 +2421,18 @@ class Zn extends f {
2600
2421
  ]);
2601
2422
  }
2602
2423
  }
2603
- const ea = async (n) => await B.create({
2424
+ const or = async (n) => await x.create({
2604
2425
  user: n
2605
2426
  });
2606
- async function ta(n) {
2607
- const e = await B.findOne({ user: n }).lean();
2608
- return e || y(await ea(n));
2427
+ async function dr(n) {
2428
+ const e = await x.findOne({ user: n }).lean();
2429
+ return e || p(await or(n));
2609
2430
  }
2610
- const na = (n, e) => B.findOneAndUpdate({ user: n }, e, {
2431
+ const lr = (n, e) => x.findOneAndUpdate({ user: n }, e, {
2611
2432
  returnDocument: "after",
2612
2433
  upsert: !0
2613
2434
  }).lean();
2614
- class aa extends Zn {
2435
+ class pr extends cr {
2615
2436
  constructor() {
2616
2437
  super(300);
2617
2438
  }
@@ -2622,86 +2443,388 @@ class aa extends Zn {
2622
2443
  return e.user;
2623
2444
  }
2624
2445
  fetchFromDb(e) {
2625
- return ta(e);
2446
+ return dr(e);
2626
2447
  }
2627
2448
  updateInDb(e, t) {
2628
- return na(e, t);
2629
- }
2630
- }
2631
- const jr = new aa();
2632
- class ra extends f {
2633
- async isBuyLimitReached(e, t, a) {
2634
- const r = await l.getAllEntitiesLimit();
2635
- if (await l.isEntityId(t, l.isEquipment))
2636
- return !1;
2637
- const s = await this.get(e), i = s.limit?.[t];
2638
- let c = r[t];
2639
- const u = await m.hasRevolutionaryBuff(e);
2640
- return s.lastShopId !== a ? !1 : (u === "half" && t === "chest_2" && (c += 2), u === "full" && t === "chest_3" && (c += 1), !!(c && i && i >= c));
2641
- }
2642
- async getShopItemRest(e, t, a, r = Ze) {
2643
- const s = await l.getAllEntitiesLimit();
2644
- if (await l.isEntityId(t, l.isEquipment))
2645
- return r;
2646
- let i = s[t];
2647
- const c = await this.get(e), u = c.limit?.[t], h = await m.hasRevolutionaryBuff(e);
2648
- return h === "half" && t === "chest_2" && (i += 2), h === "full" && t === "chest_3" && (i += 1), i ? c.lastShopId !== a ? i : u ? i - u : Math.min(i, r) : r;
2649
- }
2650
- async increaseBuyLimit(e, t, a, r) {
2651
- await this.update(e, [
2449
+ return lr(e, t);
2450
+ }
2451
+ }
2452
+ const Wa = new pr(), yr = new c(
2453
+ {
2454
+ speakerId: { type: String, required: !0 },
2455
+ order: { type: Number },
2456
+ args: { type: [String], enum: nt, default: void 0 }
2457
+ },
2458
+ { _id: !1 }
2459
+ ), fr = new c(
2460
+ {
2461
+ stepId: { type: String, required: !0 },
2462
+ type: {
2463
+ type: String,
2464
+ required: !0,
2465
+ enum: at
2466
+ },
2467
+ actionType: { type: String, enum: rt },
2468
+ messages: { type: [yr], default: void 0 },
2469
+ payload: { type: c.Types.Mixed, default: void 0 },
2470
+ next: { type: String }
2471
+ },
2472
+ { _id: !1 }
2473
+ ), mr = new c(
2474
+ {
2475
+ sceneId: { type: String, required: !0 },
2476
+ steps: { type: Map, of: fr, required: !0 },
2477
+ entryStepId: { type: String, required: !0 },
2478
+ next: { type: String }
2479
+ },
2480
+ { _id: !1 }
2481
+ ), hr = new c(
2482
+ {
2483
+ chapterId: { type: String, required: !0 },
2484
+ scenes: { type: Map, of: mr, required: !0 },
2485
+ entrySceneId: { type: String, required: !0 },
2486
+ next: { type: String }
2487
+ },
2488
+ { _id: !1 }
2489
+ ), gr = new c(
2490
+ {
2491
+ type: {
2492
+ type: String,
2493
+ required: !0,
2494
+ enum: st
2495
+ },
2496
+ speakerId: { type: String, required: !0 }
2497
+ },
2498
+ { _id: !1 }
2499
+ ), Ne = new c({
2500
+ storyId: {
2501
+ type: String,
2502
+ required: !0,
2503
+ unique: !0
2504
+ },
2505
+ speakers: { type: [gr], required: !0 },
2506
+ chapters: { type: Map, of: hr, required: !0 },
2507
+ entryChapterId: { type: String, required: !0 }
2508
+ });
2509
+ Ne.pre("findOneAndUpdate", function() {
2510
+ this.setOptions({ runValidators: !0 });
2511
+ });
2512
+ const ae = d?.Story || l("Story", Ne), Sr = async (n) => await ae.create(n), j = {
2513
+ storyId: "main",
2514
+ speakers: it,
2515
+ chapters: {
2516
+ [oe.chapterId]: oe
2517
+ },
2518
+ entryChapterId: oe.chapterId
2519
+ };
2520
+ class wr extends f {
2521
+ async seed() {
2522
+ return await this.get(j.storyId) ? this.update({ storyId: j.storyId }, { $set: j }) : Sr(j);
2523
+ }
2524
+ }
2525
+ 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, {
2526
+ returnDocument: "after"
2527
+ }).lean();
2528
+ class Ur extends wr {
2529
+ constructor() {
2530
+ super(86400);
2531
+ }
2532
+ normalizeKey(e) {
2533
+ return e;
2534
+ }
2535
+ getKey(e) {
2536
+ return e.storyId;
2537
+ }
2538
+ fetchFromDb(e) {
2539
+ return $r(e);
2540
+ }
2541
+ fetchManyFromDb(e, t) {
2542
+ return br(e, t);
2543
+ }
2544
+ updateInDb(e, t) {
2545
+ const r = typeof e == "string" ? e : e.storyId;
2546
+ return Ir(r, t);
2547
+ }
2548
+ }
2549
+ const T = new Ur(), Tr = new c(
2550
+ {
2551
+ chapterId: { type: String, required: !0 },
2552
+ sceneId: { type: String, required: !0 },
2553
+ stepId: { type: String, required: !0 },
2554
+ value: { type: String, required: !0 }
2555
+ },
2556
+ { _id: !1 }
2557
+ ), Ke = new c({
2558
+ user: {
2559
+ type: c.Types.ObjectId,
2560
+ required: !0,
2561
+ ref: "User",
2562
+ index: !0
2563
+ },
2564
+ storyId: {
2565
+ type: String,
2566
+ required: !0
2567
+ },
2568
+ currentChapterId: { type: String, required: !0 },
2569
+ currentSceneId: { type: String, required: !0 },
2570
+ currentStepId: { type: String, required: !0 },
2571
+ status: {
2572
+ type: String,
2573
+ required: !0,
2574
+ enum: ["in_progress", "completed"],
2575
+ default: "in_progress"
2576
+ },
2577
+ choices: { type: [Tr], default: [] }
2578
+ });
2579
+ Ke.index({ user: 1, storyId: 1 }, { unique: !0 });
2580
+ const H = d?.UserStory || l("UserStory", Ke), Er = async (n, e, t, r, a) => await H.create({
2581
+ user: n,
2582
+ storyId: e,
2583
+ currentChapterId: t,
2584
+ currentSceneId: r,
2585
+ currentStepId: a,
2586
+ status: "in_progress"
2587
+ }), Or = (n, e) => H.deleteOne({ user: n, storyId: e }).then(() => {
2588
+ }), Dr = (n, e, t, r) => {
2589
+ const a = n.chapters[e];
2590
+ if (!a) return null;
2591
+ const s = a.scenes[t];
2592
+ if (!s) return null;
2593
+ if (s.steps[r])
2594
+ return { chapterId: e, sceneId: t, stepId: r };
2595
+ if (s.next) {
2596
+ const i = a.scenes[s.next];
2597
+ if (i)
2598
+ return {
2599
+ chapterId: e,
2600
+ sceneId: s.next,
2601
+ stepId: i.entryStepId
2602
+ };
2603
+ }
2604
+ if (a.next) {
2605
+ const i = n.chapters[a.next];
2606
+ if (i) {
2607
+ const u = i.scenes[i.entrySceneId];
2608
+ if (u)
2609
+ return {
2610
+ chapterId: a.next,
2611
+ sceneId: i.entrySceneId,
2612
+ stepId: u.entryStepId
2613
+ };
2614
+ }
2615
+ }
2616
+ return null;
2617
+ }, z = (n, e) => {
2618
+ const t = n.chapters[e.currentChapterId];
2619
+ if (!t) return null;
2620
+ const r = t.scenes[e.currentSceneId];
2621
+ return r ? r.steps[e.currentStepId] ?? null : null;
2622
+ }, vr = (n, e, t, r, a) => {
2623
+ const s = [], i = /* @__PURE__ */ new Set();
2624
+ let u = n.entryStepId;
2625
+ for (; u && !i.has(u); ) {
2626
+ i.add(u);
2627
+ const o = n.steps[u];
2628
+ if (!o) break;
2629
+ if (o.type !== "action") {
2630
+ if (s.push({ step: o }), u === a) break;
2631
+ u = o.next;
2632
+ continue;
2633
+ }
2634
+ if (o.actionType === "button") {
2635
+ const I = e.find(
2636
+ ($) => $.chapterId === t && $.sceneId === r && $.stepId === u
2637
+ );
2638
+ if (!I) {
2639
+ s.push({ step: o });
2640
+ break;
2641
+ }
2642
+ const g = o.payload.find(
2643
+ ($) => $.actionId === I.value
2644
+ );
2645
+ if (!g || (s.push({ step: o, selectedAction: g }), u === a)) break;
2646
+ u = g.next;
2647
+ continue;
2648
+ }
2649
+ if (s.push({ step: o }), u === a) break;
2650
+ u = o.payload[0]?.next;
2651
+ }
2652
+ return s;
2653
+ };
2654
+ class Mr extends f {
2655
+ async getCurrentStep(e, t) {
2656
+ const r = await this.get({ user: e, storyId: t });
2657
+ if (!r) return null;
2658
+ const a = await T.get(t);
2659
+ return a ? z(a, r) : null;
2660
+ }
2661
+ async getSceneSteps(e, t, r, a) {
2662
+ const s = await this.get({ user: e, storyId: t });
2663
+ if (!s) return null;
2664
+ const i = await T.get(t);
2665
+ if (!i) return null;
2666
+ const u = i.chapters[r];
2667
+ if (!u) return null;
2668
+ const o = u.scenes[a];
2669
+ if (!o) return null;
2670
+ const h = s.status === "in_progress" && s.currentChapterId === r && s.currentSceneId === a;
2671
+ return vr(
2672
+ o,
2673
+ s.choices,
2674
+ r,
2675
+ a,
2676
+ h ? s.currentStepId : void 0
2677
+ );
2678
+ }
2679
+ async start(e, t) {
2680
+ const r = await T.get(t);
2681
+ if (!r) return null;
2682
+ const a = r.chapters[r.entryChapterId];
2683
+ if (!a) return null;
2684
+ const s = a.scenes[a.entrySceneId];
2685
+ if (!s) return null;
2686
+ await Or(e, t), this.invalidate({ user: e, storyId: t });
2687
+ const i = await Er(
2688
+ e,
2689
+ t,
2690
+ r.entryChapterId,
2691
+ a.entrySceneId,
2692
+ s.entryStepId
2693
+ ), u = p(i);
2694
+ return this.cache.set(this.normalizeKey({ user: e, storyId: t }), u), u;
2695
+ }
2696
+ async advanceToNext(e, t) {
2697
+ const r = await this.get({ user: e, storyId: t });
2698
+ if (!r) return { status: "error" };
2699
+ if (r.status === "completed") return { status: "completed" };
2700
+ const a = await T.get(t);
2701
+ if (!a) return { status: "error" };
2702
+ const s = z(a, r);
2703
+ if (!s) return { status: "error" };
2704
+ if (s.type === "action") return { status: "action_required" };
2705
+ if (!s.next) return { status: "scene_ended" };
2706
+ const i = a.chapters[r.currentChapterId];
2707
+ if (!i) return { status: "error" };
2708
+ const u = i.scenes[r.currentSceneId];
2709
+ if (!u) return { status: "error" };
2710
+ if (!u.steps[s.next]) return { status: "scene_ended" };
2711
+ const o = await this.advanceTo(
2712
+ e,
2713
+ t,
2714
+ a,
2715
+ r.currentChapterId,
2716
+ r.currentSceneId,
2717
+ s.next
2718
+ );
2719
+ return o ? { status: "advanced", data: o } : { status: "error" };
2720
+ }
2721
+ async advanceToNextScene(e, t) {
2722
+ const r = await this.get({ user: e, storyId: t });
2723
+ if (!r || r.status === "completed") return null;
2724
+ const a = await T.get(t);
2725
+ if (!a) return null;
2726
+ const s = a.chapters[r.currentChapterId];
2727
+ if (!s) return null;
2728
+ const i = s.scenes[r.currentSceneId];
2729
+ if (!i || !i.next) return null;
2730
+ const u = s.scenes[i.next];
2731
+ return u ? this.update(
2732
+ { user: e, storyId: t },
2652
2733
  {
2653
2734
  $set: {
2654
- limit: {
2655
- $cond: {
2656
- if: { $eq: ["$lastShopId", t] },
2657
- then: {
2658
- $setField: {
2659
- field: a,
2660
- input: { $ifNull: ["$limit", {}] },
2661
- value: {
2662
- $add: [{ $ifNull: [`$limit.${a}`, 0] }, r]
2663
- }
2664
- }
2665
- },
2666
- else: {
2667
- [a]: r
2668
- }
2669
- }
2670
- },
2671
- lastShopId: t
2735
+ currentSceneId: i.next,
2736
+ currentStepId: u.entryStepId
2672
2737
  }
2673
2738
  }
2674
- ]);
2739
+ ) : null;
2740
+ }
2741
+ async validateCommandAndAdvance(e, t, r) {
2742
+ const a = await this.get({ user: e, storyId: t });
2743
+ if (!a || a.status === "completed") return null;
2744
+ const s = await T.get(t);
2745
+ if (!s) return null;
2746
+ const i = z(s, a);
2747
+ if (!i || i.type !== "action" || i.actionType !== "command")
2748
+ return null;
2749
+ const u = i.payload.find((o) => o.commandId === r);
2750
+ return u ? this.advanceTo(
2751
+ e,
2752
+ t,
2753
+ s,
2754
+ a.currentChapterId,
2755
+ a.currentSceneId,
2756
+ u.next
2757
+ ) : null;
2758
+ }
2759
+ async validateActionAndAdvance(e, t, r) {
2760
+ const a = await this.get({ user: e, storyId: t });
2761
+ if (!a || a.status === "completed") return null;
2762
+ const s = await T.get(t);
2763
+ if (!s) return null;
2764
+ const i = z(s, a);
2765
+ if (!i || i.type !== "action") return null;
2766
+ const u = i.payload.find((o) => o.actionId === r);
2767
+ return u ? this.advanceTo(
2768
+ e,
2769
+ t,
2770
+ s,
2771
+ a.currentChapterId,
2772
+ a.currentSceneId,
2773
+ u.next,
2774
+ {
2775
+ chapterId: a.currentChapterId,
2776
+ sceneId: a.currentSceneId,
2777
+ stepId: a.currentStepId,
2778
+ value: r
2779
+ }
2780
+ ) : null;
2781
+ }
2782
+ async advanceTo(e, t, r, a, s, i, u) {
2783
+ const o = Dr(r, a, s, i);
2784
+ return o ? this.update(
2785
+ { user: e, storyId: t },
2786
+ {
2787
+ $set: {
2788
+ currentChapterId: o.chapterId,
2789
+ currentSceneId: o.sceneId,
2790
+ currentStepId: o.stepId
2791
+ },
2792
+ ...u && { $push: { choices: u } }
2793
+ }
2794
+ ) : this.update(
2795
+ { user: e, storyId: t },
2796
+ {
2797
+ $set: { status: "completed" },
2798
+ ...u && { $push: { choices: u } }
2799
+ }
2800
+ );
2675
2801
  }
2676
2802
  }
2677
- const sa = async (n) => await J.create({
2678
- user: n
2679
- }), ia = async (n) => {
2680
- const e = await J.findOne({ user: n }).lean();
2681
- return e || y(await sa(n));
2682
- }, ua = (n, e) => J.findOneAndUpdate({ user: n }, e, {
2683
- upsert: !0,
2803
+ const xr = (n, e = {}) => H.find(n, null, e).lean(), qr = (n, e) => H.findOne({ user: n, storyId: e }).lean(), Ar = (n, e) => H.findOneAndUpdate(n, e, {
2684
2804
  returnDocument: "after"
2685
2805
  }).lean();
2686
- class oa extends ra {
2806
+ class kr extends Mr {
2687
2807
  constructor() {
2688
- super(300);
2808
+ super(120);
2689
2809
  }
2690
2810
  normalizeKey(e) {
2691
- return e.toString();
2811
+ return `${e.user.toString()}:${e.storyId}`;
2692
2812
  }
2693
- getKey({ user: e }) {
2694
- return e;
2813
+ getKey(e) {
2814
+ return { user: e.user, storyId: e.storyId };
2695
2815
  }
2696
2816
  fetchFromDb(e) {
2697
- return ia(e);
2817
+ return qr(e.user, e.storyId);
2818
+ }
2819
+ fetchManyFromDb(e, t) {
2820
+ return xr(e, t);
2698
2821
  }
2699
2822
  updateInDb(e, t) {
2700
- return ua(e, t);
2823
+ return Ar(e, t);
2701
2824
  }
2702
2825
  }
2703
- const Hr = new oa();
2704
- class ca extends f {
2826
+ const Va = new kr();
2827
+ class Rr extends y {
2705
2828
  async didSevenDoubleAtDoQ(e) {
2706
2829
  await this.update(e, {
2707
2830
  $inc: { "doubleOrQuit.sevenDoubleInARowCount": 1 }
@@ -2710,11 +2833,11 @@ class ca extends f {
2710
2833
  async winWithBlackjack(e) {
2711
2834
  await this.update(e, { $inc: { "blackJack.blackJackCount": 1 } });
2712
2835
  }
2713
- async updateLastGames(e, t, a) {
2836
+ async updateLastGames(e, t, r) {
2714
2837
  await this.update(e, {
2715
2838
  $push: {
2716
2839
  lastGames: {
2717
- $each: [{ gameType: t, endState: a }],
2840
+ $each: [{ gameType: t, endState: r }],
2718
2841
  $position: 0,
2719
2842
  $slice: 20
2720
2843
  }
@@ -2725,19 +2848,19 @@ class ca extends f {
2725
2848
  await this.update(e, { $inc: { drawCount: 1 } });
2726
2849
  }
2727
2850
  async bet666(e) {
2728
- const t = K();
2851
+ const t = Y();
2729
2852
  t.setHours(0, 0, 0, 0);
2730
- const a = /* @__PURE__ */ new Date();
2731
- a.setHours(0, 0, 0, 0), await k.updateOne(
2853
+ const r = /* @__PURE__ */ new Date();
2854
+ r.setHours(0, 0, 0, 0), await A.updateOne(
2732
2855
  {
2733
2856
  user: e,
2734
2857
  "bet666.last": {
2735
2858
  $gte: t,
2736
- $lt: a
2859
+ $lt: r
2737
2860
  }
2738
2861
  },
2739
2862
  { $inc: { "bet666.count": 1 }, $set: { "bet666.last": /* @__PURE__ */ new Date() } }
2740
- ), await k.updateOne(
2863
+ ), await A.updateOne(
2741
2864
  {
2742
2865
  user: e,
2743
2866
  "bet666.last": {
@@ -2780,18 +2903,18 @@ class ca extends f {
2780
2903
  await this.update(e, { $inc: { "dice.drawWithDoubleSixCount": 1 } });
2781
2904
  }
2782
2905
  }
2783
- const la = async (n) => await k.create({
2906
+ const Cr = async (n) => await A.create({
2784
2907
  user: n
2785
2908
  });
2786
- async function da(n) {
2787
- const e = await k.findOne({ user: n }).lean();
2788
- return e || y(await la(n));
2909
+ async function _r(n) {
2910
+ const e = await A.findOne({ user: n }).lean();
2911
+ return e || p(await Cr(n));
2789
2912
  }
2790
- const pa = (n, e) => k.findOneAndUpdate({ user: n }, e, {
2913
+ const Br = (n, e) => A.findOneAndUpdate({ user: n }, e, {
2791
2914
  upsert: !0,
2792
2915
  returnDocument: "after"
2793
2916
  }).lean();
2794
- class ya extends ca {
2917
+ class Fr extends Rr {
2795
2918
  constructor() {
2796
2919
  super(300);
2797
2920
  }
@@ -2802,14 +2925,14 @@ class ya extends ca {
2802
2925
  return e;
2803
2926
  }
2804
2927
  fetchFromDb(e) {
2805
- return da(e);
2928
+ return _r(e);
2806
2929
  }
2807
2930
  updateInDb(e, t) {
2808
- return pa(e, t);
2931
+ return Br(e, t);
2809
2932
  }
2810
2933
  }
2811
- const Kr = new ya();
2812
- class fa extends f {
2934
+ const Xa = new Fr();
2935
+ class Nr extends y {
2813
2936
  async workIncrement(e) {
2814
2937
  await this.update(e, { $inc: { workCount: 1 } });
2815
2938
  }
@@ -2821,18 +2944,18 @@ class fa extends f {
2821
2944
  });
2822
2945
  }
2823
2946
  }
2824
- const ma = (n) => Z.create({
2947
+ const Kr = (n) => te.create({
2825
2948
  user: n
2826
2949
  });
2827
- async function ha(n) {
2828
- const e = await Z.findOne({ user: n }).lean();
2829
- return e || y(await ma(n));
2950
+ async function Hr(n) {
2951
+ const e = await te.findOne({ user: n }).lean();
2952
+ return e || p(await Kr(n));
2830
2953
  }
2831
- const ga = (n, e) => Z.findOneAndUpdate({ user: n }, e, {
2954
+ const Pr = (n, e) => te.findOneAndUpdate({ user: n }, e, {
2832
2955
  upsert: !0,
2833
2956
  returnDocument: "after"
2834
2957
  }).lean();
2835
- class wa extends fa {
2958
+ class jr extends Nr {
2836
2959
  constructor() {
2837
2960
  super(300);
2838
2961
  }
@@ -2843,14 +2966,14 @@ class wa extends fa {
2843
2966
  return e;
2844
2967
  }
2845
2968
  fetchFromDb(e) {
2846
- return ha(e);
2969
+ return Hr(e);
2847
2970
  }
2848
2971
  updateInDb(e, t) {
2849
- return ga(e, t);
2972
+ return Pr(e, t);
2850
2973
  }
2851
2974
  }
2852
- const Sa = new wa();
2853
- class ba extends f {
2975
+ const Ja = new jr();
2976
+ class zr extends y {
2854
2977
  async hasReportedSomeone(e) {
2855
2978
  await this.update(e, { $set: { reportedSomeone: !0 } });
2856
2979
  }
@@ -2881,18 +3004,18 @@ class ba extends f {
2881
3004
  await this.update(e, { $set: { "gamblingFlags.lose10M": !0 } });
2882
3005
  }
2883
3006
  }
2884
- const $a = async (n) => await te.create({
3007
+ const Lr = async (n) => await re.create({
2885
3008
  user: n
2886
3009
  });
2887
- async function Ia(n) {
2888
- const e = await te.findOne({ user: n }).lean();
2889
- return e || y(await $a(n));
3010
+ async function Qr(n) {
3011
+ const e = await re.findOne({ user: n }).lean();
3012
+ return e || p(await Lr(n));
2890
3013
  }
2891
- const Ea = (n, e) => te.findOneAndUpdate({ user: n }, e, {
3014
+ const Yr = (n, e) => re.findOneAndUpdate({ user: n }, e, {
2892
3015
  upsert: !0,
2893
3016
  returnDocument: "after"
2894
3017
  }).lean();
2895
- class Ua extends ba {
3018
+ class Gr extends zr {
2896
3019
  constructor() {
2897
3020
  super(300);
2898
3021
  }
@@ -2903,17 +3026,17 @@ class Ua extends ba {
2903
3026
  return e;
2904
3027
  }
2905
3028
  fetchFromDb(e) {
2906
- return Ia(e);
3029
+ return Qr(e);
2907
3030
  }
2908
3031
  updateInDb(e, t) {
2909
- return Ea(e, t);
3032
+ return Yr(e, t);
2910
3033
  }
2911
3034
  }
2912
- const Pr = new Ua();
2913
- class Da extends f {
3035
+ const Za = new Gr();
3036
+ class Wr extends y {
2914
3037
  async readEdito(e) {
2915
3038
  const t = /* @__PURE__ */ new Date();
2916
- t.setHours(0, 0, 0, 0), await T.updateOne(
3039
+ t.setHours(0, 0, 0, 0), await D.updateOne(
2917
3040
  {
2918
3041
  user: e,
2919
3042
  "edito.lastTimeRead": {
@@ -2924,7 +3047,7 @@ class Da extends f {
2924
3047
  $inc: { "edito.readToday": 1 },
2925
3048
  $set: { "edito.lastTimeRead": /* @__PURE__ */ new Date() }
2926
3049
  }
2927
- ), await T.updateOne(
3050
+ ), await D.updateOne(
2928
3051
  {
2929
3052
  user: e,
2930
3053
  "edito.lastTimeRead": {
@@ -2938,7 +3061,7 @@ class Da extends f {
2938
3061
  }
2939
3062
  async getTotalEditoReadToday() {
2940
3063
  const e = /* @__PURE__ */ new Date();
2941
- return e.setHours(0, 0, 0, 0), (await T.aggregate([
3064
+ return e.setHours(0, 0, 0, 0), (await D.aggregate([
2942
3065
  {
2943
3066
  $match: {
2944
3067
  "edito.lastTimeRead": { $gte: e },
@@ -2949,18 +3072,18 @@ class Da extends f {
2949
3072
  ]))[0]?.total ?? 0;
2950
3073
  }
2951
3074
  }
2952
- const Ta = async (n) => await T.create({
3075
+ const Vr = async (n) => await D.create({
2953
3076
  user: n
2954
3077
  });
2955
- async function Oa(n) {
2956
- const e = await T.findOne({ user: n }).lean();
2957
- return e || y(await Ta(n));
3078
+ async function Xr(n) {
3079
+ const e = await D.findOne({ user: n }).lean();
3080
+ return e || p(await Vr(n));
2958
3081
  }
2959
- const va = (n, e) => T.findOneAndUpdate({ user: n }, e, {
3082
+ const Jr = (n, e) => D.findOneAndUpdate({ user: n }, e, {
2960
3083
  upsert: !0,
2961
3084
  returnDocument: "after"
2962
3085
  }).lean();
2963
- class Ba extends Da {
3086
+ class Zr extends Wr {
2964
3087
  constructor() {
2965
3088
  super(300);
2966
3089
  }
@@ -2971,52 +3094,50 @@ class Ba extends Da {
2971
3094
  return e;
2972
3095
  }
2973
3096
  fetchFromDb(e) {
2974
- return Oa(e);
3097
+ return Xr(e);
2975
3098
  }
2976
3099
  updateInDb(e, t) {
2977
- return va(e, t);
3100
+ return Jr(e, t);
2978
3101
  }
2979
3102
  }
2980
- const Lr = new Ba();
2981
- class Ma extends f {
2982
- async updateCraftStats(e, t, a) {
2983
- const r = await l.get(a);
2984
- !r || !l.isItem(r) || await this.update(e, {
3103
+ const es = new Zr();
3104
+ class ea extends y {
3105
+ async updateCraftStats(e, t, r) {
3106
+ const a = await m.get(r);
3107
+ !a || !m.isItem(a) || await this.update(e, {
2985
3108
  $inc: {
2986
- "crafts.cookedMeal": l.isCookedMeal(r) ? t : 0,
2987
- "crafts.scrolls": l.isScrollItem(r) ? t : 0,
2988
3109
  "crafts.totalCrafted": t
2989
3110
  }
2990
3111
  });
2991
3112
  }
2992
- async incrementAlcoholDrink(e, t, a) {
3113
+ async incrementAlcoholDrink(e, t, r) {
2993
3114
  ["wine", "beer", "rhum"].includes(t) && await this.update(e, {
2994
3115
  $inc: {
2995
- "alcohols.wines": t === "wine" ? a : 0,
2996
- "alcohols.beers": t === "beer" ? a : 0,
2997
- "alcohols.rhums": t === "rhum" ? a : 0,
2998
- "alcohols.totalConsumed": a
3116
+ "alcohols.wines": t === "wine" ? r : 0,
3117
+ "alcohols.beers": t === "beer" ? r : 0,
3118
+ "alcohols.rhums": t === "rhum" ? r : 0,
3119
+ "alcohols.totalConsumed": r
2999
3120
  }
3000
3121
  });
3001
3122
  }
3002
3123
  async incrementBottleUsedToday(e, t) {
3003
- const a = /* @__PURE__ */ new Date();
3004
- a.setHours(0, 0, 0, 0), await A.updateOne(
3124
+ const r = /* @__PURE__ */ new Date();
3125
+ r.setHours(0, 0, 0, 0), await k.updateOne(
3005
3126
  {
3006
3127
  user: e,
3007
3128
  "bottle.lastUsed": {
3008
- $gte: a
3129
+ $gte: r
3009
3130
  }
3010
3131
  },
3011
3132
  {
3012
3133
  $inc: { "bottle.usedToday": t },
3013
3134
  $set: { "bottle.lastUsed": /* @__PURE__ */ new Date() }
3014
3135
  }
3015
- ), await A.updateOne(
3136
+ ), await k.updateOne(
3016
3137
  {
3017
3138
  user: e,
3018
3139
  "bottle.lastUsed": {
3019
- $lt: a
3140
+ $lt: r
3020
3141
  }
3021
3142
  },
3022
3143
  {
@@ -3038,18 +3159,18 @@ class Ma extends f {
3038
3159
  });
3039
3160
  }
3040
3161
  }
3041
- const ka = async (n) => await A.create({
3162
+ const ta = async (n) => await k.create({
3042
3163
  user: n
3043
3164
  });
3044
- async function Aa(n) {
3045
- const e = await A.findOne({ user: n }).lean();
3046
- return e || y(await ka(n));
3165
+ async function na(n) {
3166
+ const e = await k.findOne({ user: n }).lean();
3167
+ return e || p(await ta(n));
3047
3168
  }
3048
- const qa = (n, e) => A.findOneAndUpdate({ user: n }, e, {
3169
+ const ra = (n, e) => k.findOneAndUpdate({ user: n }, e, {
3049
3170
  upsert: !0,
3050
3171
  returnDocument: "after"
3051
3172
  }).lean();
3052
- class Ra extends Ma {
3173
+ class aa extends ea {
3053
3174
  constructor() {
3054
3175
  super(300);
3055
3176
  }
@@ -3060,97 +3181,97 @@ class Ra extends Ma {
3060
3181
  return e;
3061
3182
  }
3062
3183
  fetchFromDb(e) {
3063
- return Aa(e);
3184
+ return na(e);
3064
3185
  }
3065
3186
  updateInDb(e, t) {
3066
- return qa(e, t);
3187
+ return ra(e, t);
3067
3188
  }
3068
3189
  }
3069
- const Qr = new Ra();
3070
- class xa extends w {
3190
+ const ts = new aa();
3191
+ class sa extends f {
3071
3192
  async maxCraftQuantity(e, t) {
3072
- const a = await m.get(e);
3073
- let r = 1 / 0;
3193
+ const r = await E.get(e);
3194
+ let a = 1 / 0;
3074
3195
  for (const s of t)
3075
- r = Math.min(
3076
- r,
3196
+ a = Math.min(
3197
+ a,
3077
3198
  Math.floor(
3078
- (a.itemList[s.entityId] ?? 0) / s.size
3199
+ (r.itemList[s.entityId] ?? 0) / s.size
3079
3200
  )
3080
3201
  );
3081
- return r;
3202
+ return a;
3082
3203
  }
3083
- async hasEnoughItemsForRecipe(e, t, a) {
3084
- const r = await m.get(e);
3204
+ async hasEnoughItemsForRecipe(e, t, r) {
3205
+ const a = await E.get(e);
3085
3206
  for (const s of t.entities)
3086
- if ((r.itemList[s.entityId] ?? 0) < s.size * a)
3207
+ if ((a.itemList[s.entityId] ?? 0) < s.size * r)
3087
3208
  return !1;
3088
3209
  return !0;
3089
3210
  }
3090
3211
  decodeCraftId(e) {
3091
- return e.split(";").map((t, a) => ({
3212
+ return e.split(";").map((t, r) => ({
3092
3213
  entityId: t === "null" ? null : t,
3093
- index: a
3214
+ index: r
3094
3215
  }));
3095
3216
  }
3096
3217
  encodeCraftId(e) {
3097
3218
  return e.map(({ entityId: t }) => `${t}`).join(";");
3098
3219
  }
3099
3220
  async isValidRecipe(e) {
3100
- return !!(await this.getAll()).find((a) => a.craftId === e);
3221
+ return !!(await this.getAll()).find((r) => r.craftId === e);
3101
3222
  }
3102
3223
  async getRecipeResult(e, t) {
3103
- const a = await m.get(e), r = (await E.getPanoplyBonus(a.equippedItems)).find(
3224
+ const r = await E.get(e), a = (await R.getPanoplyBonus(r.equippedItems)).find(
3104
3225
  ([s, i]) => s.panoplyId === "little_blacksmith" && i !== null
3105
3226
  );
3106
- return r?.[1] === "full" && t === "chest_3" ? "chest_blacksmith_3" : r?.[1] === "half" && t === "chest_2" ? "chest_blacksmith_2" : r?.[1] === "half" && t === "chest_1" ? "chest_blacksmith_1" : t;
3227
+ return a?.[1] === "full" && t === "chest_3" ? "chest_blacksmith_3" : a?.[1] === "half" && t === "chest_2" ? "chest_blacksmith_2" : a?.[1] === "half" && t === "chest_1" ? "chest_blacksmith_1" : t;
3107
3228
  }
3108
3229
  }
3109
- const _a = new o(
3230
+ const ia = new c(
3110
3231
  {
3111
3232
  entityId: { type: String, required: !0 },
3112
3233
  size: { type: Number, required: !0 }
3113
3234
  },
3114
3235
  { _id: !1 }
3115
- ), Ca = new o(
3236
+ ), ua = new c(
3116
3237
  {
3117
3238
  entityId: { type: String, required: !0 },
3118
3239
  size: { type: Number, required: !0 }
3119
3240
  },
3120
3241
  { _id: !1 }
3121
- ), Na = new o(
3242
+ ), ca = new c(
3122
3243
  {
3123
3244
  craftId: { type: String, unique: !0, required: !0 },
3124
3245
  name: { type: String, required: !0 },
3125
- entities: { type: [_a], required: !0 },
3126
- result: { type: Ca, required: !0 }
3246
+ entities: { type: [ia], required: !0 },
3247
+ result: { type: ua, required: !0 }
3127
3248
  },
3128
3249
  { minimize: !1 }
3129
- ), ae = d?.Recipes || p("Recipes", Na), Fa = async (n) => await ae.create({
3250
+ ), se = d?.Recipes || l("Recipes", ca), oa = async (n) => await se.create({
3130
3251
  ...n
3131
- }), za = async (n, e) => ae.find(n, {}, e).lean();
3132
- async function ja(n) {
3133
- const e = await ae.findOne({ craftId: n }).lean();
3252
+ }), da = async (n, e) => se.find(n, {}, e).lean();
3253
+ async function la(n) {
3254
+ const e = await se.findOne({ craftId: n }).lean();
3134
3255
  return e || null;
3135
3256
  }
3136
- const Ha = (n, e) => ae.findOneAndUpdate(n, e, {
3257
+ const pa = (n, e) => se.findOneAndUpdate(n, e, {
3137
3258
  returnDocument: "after"
3138
3259
  }).lean();
3139
- class Ka extends xa {
3260
+ class ya extends sa {
3140
3261
  constructor() {
3141
3262
  super(3600);
3142
3263
  }
3143
3264
  createInDb(e) {
3144
- return Fa(e);
3265
+ return oa(e);
3145
3266
  }
3146
3267
  updateInDb(e, t) {
3147
- return Ha(e, t);
3268
+ return pa(e, t);
3148
3269
  }
3149
3270
  fetchFromDb(e) {
3150
- return ja(e);
3271
+ return la(e);
3151
3272
  }
3152
3273
  fetchManyFromDb(e, t) {
3153
- return za(e, t);
3274
+ return da(e, t);
3154
3275
  }
3155
3276
  normalizeKey(e) {
3156
3277
  return e;
@@ -3159,35 +3280,35 @@ class Ka extends xa {
3159
3280
  return e.craftId;
3160
3281
  }
3161
3282
  }
3162
- const Wr = new Ka(), Pa = new o({
3283
+ const ns = new ya(), fa = new c({
3163
3284
  bannedUserId: { type: String, index: !0, required: !0 },
3164
3285
  authorId: { type: String, required: !0 },
3165
3286
  unbannedTimestamp: { type: Date, index: 1 },
3166
3287
  reason: { type: String, required: !0 },
3167
3288
  guildId: { type: String, required: !0 }
3168
- }), re = d?.Bans || p("Bans", Pa), La = (n, e) => re.deleteOne({ bannedUserId: n, guildId: e });
3169
- class Qa extends w {
3289
+ }), ie = d?.Bans || l("Bans", fa), ma = (n, e) => ie.deleteOne({ bannedUserId: n, guildId: e });
3290
+ class ha extends f {
3170
3291
  async getUnbanUsers() {
3171
3292
  return this.getMany({
3172
3293
  unbannedTimestamp: { $lte: /* @__PURE__ */ new Date(), $ne: null }
3173
3294
  });
3174
3295
  }
3175
- async banUserFromGuild({ bannedUserId: e, guildId: t, ...a }) {
3176
- await this.update({ bannedUserId: e, guildId: t }, { ...a });
3296
+ async banUserFromGuild({ bannedUserId: e, guildId: t, ...r }) {
3297
+ await this.update({ bannedUserId: e, guildId: t }, { ...r });
3177
3298
  }
3178
3299
  async isBannedFromGuild(e, t) {
3179
- const a = await this.get({ bannedUserId: e, guildId: t });
3180
- return !!(a && (!a.unbannedTimestamp || a.unbannedTimestamp > /* @__PURE__ */ new Date()));
3300
+ const r = await this.get({ bannedUserId: e, guildId: t });
3301
+ return !!(r && (!r.unbannedTimestamp || r.unbannedTimestamp > /* @__PURE__ */ new Date()));
3181
3302
  }
3182
3303
  async deleteBan(e, t) {
3183
- await La(e, t), this.invalidate({ bannedUserId: e, guildId: t });
3304
+ await ma(e, t), this.invalidate({ bannedUserId: e, guildId: t });
3184
3305
  }
3185
3306
  }
3186
- const Wa = (n) => re.find(n).lean(), Ga = (n) => re.findOne(n).lean(), Ya = (n, e) => re.findOneAndUpdate(n, e, {
3307
+ const ga = (n) => ie.find(n).lean(), Sa = (n) => ie.findOne(n).lean(), wa = (n, e) => ie.findOneAndUpdate(n, e, {
3187
3308
  returnDocument: "after",
3188
3309
  upsert: !0
3189
3310
  }).lean();
3190
- class Va extends Qa {
3311
+ class ba extends ha {
3191
3312
  constructor() {
3192
3313
  super(3600 * 36);
3193
3314
  }
@@ -3198,23 +3319,23 @@ class Va extends Qa {
3198
3319
  return { bannedUserId: e, guildId: t };
3199
3320
  }
3200
3321
  fetchFromDb(e) {
3201
- return Ga(e);
3322
+ return Sa(e);
3202
3323
  }
3203
3324
  fetchManyFromDb(e) {
3204
- return Wa(e);
3325
+ return ga(e);
3205
3326
  }
3206
3327
  updateInDb(e, t) {
3207
- return Ya(e, t);
3328
+ return wa(e, t);
3208
3329
  }
3209
3330
  }
3210
- const Gr = new Va(), Xa = new o({
3331
+ const rs = new ba(), $a = new c({
3211
3332
  senderId: {
3212
- type: o.Types.ObjectId,
3333
+ type: c.Types.ObjectId,
3213
3334
  required: !0,
3214
3335
  ref: "User"
3215
3336
  },
3216
3337
  receiverId: {
3217
- type: o.Types.ObjectId,
3338
+ type: c.Types.ObjectId,
3218
3339
  required: !0,
3219
3340
  index: !0,
3220
3341
  ref: "User"
@@ -3224,36 +3345,36 @@ const Gr = new Va(), Xa = new o({
3224
3345
  meta: {
3225
3346
  rps: { type: String, default: void 0 }
3226
3347
  }
3227
- }), se = d?.Invitation || p("Invitation", Xa), Ja = (n) => se.create({
3348
+ }), ue = d?.Invitation || l("Invitation", $a), Ia = (n) => ue.create({
3228
3349
  ...n
3229
- }), Za = async (n) => {
3230
- await se.deleteMany({
3350
+ }), Ua = async (n) => {
3351
+ await ue.deleteMany({
3231
3352
  ...n
3232
3353
  });
3233
3354
  };
3234
- class er extends f {
3355
+ class Ta extends y {
3235
3356
  async sendInvitation({
3236
3357
  senderId: e,
3237
3358
  receiverId: t,
3238
- gameMode: a,
3239
- ...r
3359
+ gameMode: r,
3360
+ ...a
3240
3361
  }) {
3241
- return await this.get({ senderId: e, gameMode: a, receiverId: t }) ? null : await Ja({ ...r, senderId: e, gameMode: a, receiverId: t });
3362
+ return await this.get({ senderId: e, gameMode: r, receiverId: t }) ? null : await Ia({ ...a, senderId: e, gameMode: r, receiverId: t });
3242
3363
  }
3243
3364
  async deleteInvitation({
3244
3365
  senderId: e,
3245
3366
  receiverId: t,
3246
- gameMode: a
3367
+ gameMode: r
3247
3368
  }) {
3248
- await Za({ senderId: e, gameMode: a, receiverId: t }), this.invalidate({ senderId: e, gameMode: a, receiverId: t });
3369
+ await Ua({ senderId: e, gameMode: r, receiverId: t }), this.invalidate({ senderId: e, gameMode: r, receiverId: t });
3249
3370
  }
3250
3371
  }
3251
- const tr = (n) => se.findOne({
3372
+ const Ea = (n) => ue.findOne({
3252
3373
  ...n
3253
- }).lean(), nr = (n, e) => se.findOneAndUpdate(n, e, {
3374
+ }).lean(), Oa = (n, e) => ue.findOneAndUpdate(n, e, {
3254
3375
  returnDocument: "after"
3255
3376
  }).lean();
3256
- class ar extends er {
3377
+ class Da extends Ta {
3257
3378
  constructor() {
3258
3379
  super(3600);
3259
3380
  }
@@ -3263,19 +3384,19 @@ class ar extends er {
3263
3384
  getKey({
3264
3385
  receiverId: e,
3265
3386
  gameMode: t,
3266
- senderId: a
3387
+ senderId: r
3267
3388
  }) {
3268
- return { gameMode: t, receiverId: e, senderId: a };
3389
+ return { gameMode: t, receiverId: e, senderId: r };
3269
3390
  }
3270
3391
  fetchFromDb(e) {
3271
- return tr(e);
3392
+ return Ea(e);
3272
3393
  }
3273
3394
  updateInDb(e, t) {
3274
- return nr(e, t);
3395
+ return Oa(e, t);
3275
3396
  }
3276
3397
  }
3277
- const Yr = new ar();
3278
- class rr extends f {
3398
+ const as = new Da();
3399
+ class va extends y {
3279
3400
  async randomizeEditoPrice(e) {
3280
3401
  const t = Ee(100, 1001);
3281
3402
  return await this.update({ guildId: e }, { $set: { "edito.price": t } }), t;
@@ -3289,11 +3410,11 @@ class rr extends f {
3289
3410
  { $set: { "ranking.messageId": t } }
3290
3411
  );
3291
3412
  }
3292
- async addCrewChannelId(e, t, a) {
3413
+ async addCrewChannelId(e, t, r) {
3293
3414
  await this.update(
3294
3415
  { guildId: e },
3295
3416
  {
3296
- $push: { "crew.crewChannelIds": { channelId: a, crewId: t } }
3417
+ $push: { "crew.crewChannelIds": { channelId: r, crewId: t } }
3297
3418
  }
3298
3419
  );
3299
3420
  }
@@ -3302,7 +3423,7 @@ class rr extends f {
3302
3423
  { guildId: e },
3303
3424
  {
3304
3425
  $set: Object.fromEntries(
3305
- Object.entries(t).map(([a, r]) => [`roles.${a}`, r])
3426
+ Object.entries(t).map(([r, a]) => [`roles.${r}`, a])
3306
3427
  )
3307
3428
  }
3308
3429
  );
@@ -3312,16 +3433,16 @@ class rr extends f {
3312
3433
  { guildId: e },
3313
3434
  {
3314
3435
  $set: Object.fromEntries(
3315
- Object.entries(t).map(([a, r]) => [
3316
- `channels.${a}`,
3317
- r
3436
+ Object.entries(t).map(([r, a]) => [
3437
+ `channels.${r}`,
3438
+ a
3318
3439
  ])
3319
3440
  )
3320
3441
  }
3321
3442
  );
3322
3443
  }
3323
3444
  }
3324
- const sr = new o({
3445
+ const Ma = new c({
3325
3446
  guildId: { type: String, required: !0, unique: !0 },
3326
3447
  ranking: {
3327
3448
  messageId: { type: String, default: null }
@@ -3369,16 +3490,16 @@ const sr = new o({
3369
3490
  default: []
3370
3491
  }
3371
3492
  }
3372
- }), ye = d?.Settings || p("Settings", sr), ir = (n) => ye.create({
3493
+ }), me = d?.Settings || l("Settings", Ma), xa = (n) => me.create({
3373
3494
  guildId: n
3374
- }), ur = async (n) => {
3375
- const e = await ye.findOne({ guildId: n }).lean();
3376
- return e || y(await ir(n));
3377
- }, or = (n, e) => ye.findOneAndUpdate(n, e, {
3495
+ }), qa = async (n) => {
3496
+ const e = await me.findOne({ guildId: n }).lean();
3497
+ return e || p(await xa(n));
3498
+ }, Aa = (n, e) => me.findOneAndUpdate(n, e, {
3378
3499
  upsert: !0,
3379
3500
  returnDocument: "after"
3380
3501
  }).lean();
3381
- class cr extends rr {
3502
+ class ka extends va {
3382
3503
  constructor() {
3383
3504
  super(3600 * 24 * 30);
3384
3505
  }
@@ -3389,414 +3510,37 @@ class cr extends rr {
3389
3510
  return e;
3390
3511
  }
3391
3512
  fetchFromDb(e) {
3392
- return ur(e);
3393
- }
3394
- updateInDb(e, t) {
3395
- return or(e, t);
3396
- }
3397
- }
3398
- const Vr = new cr();
3399
- class I {
3400
- toDBShopItem() {
3401
- return {
3402
- price: this.price,
3403
- size: this.size,
3404
- id: "entityId" in this.data ? this.data.entityId : this.data.ornamentId,
3405
- currency: this.currency
3406
- };
3407
- }
3408
- async onBuy(e, t) {
3409
- this.currency === "berry" ? (await U.updateUserBerry(
3410
- e,
3411
- -1 * this.price * t,
3412
- !1
3413
- ), await Sa.updateTotalSpentInShop(
3414
- e,
3415
- this.price * t
3416
- )) : await m.removeItem(
3417
- e,
3418
- this.currency,
3419
- this.price * t
3420
- );
3421
- }
3422
- isBackground() {
3423
- return !1;
3424
- }
3425
- isChest() {
3426
- return !1;
3427
- }
3428
- isTitle() {
3429
- return !1;
3430
- }
3431
- isBoostXp() {
3432
- return !1;
3433
- }
3434
- isRepair() {
3435
- return !1;
3436
- }
3437
- isStore() {
3438
- return !1;
3439
- }
3440
- isObject() {
3441
- return !1;
3442
- }
3443
- isBottle() {
3444
- return !1;
3445
- }
3446
- isEquipment() {
3447
- return !1;
3448
- }
3449
- }
3450
- class lr extends I {
3451
- price;
3452
- size;
3453
- currency;
3454
- data;
3455
- constructor({
3456
- price: e,
3457
- item: t,
3458
- size: a,
3459
- currency: r
3460
- }) {
3461
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
3462
- }
3463
- async onBuy(e, t) {
3464
- await super.onBuy(e, t), await L.unlockBackground(e, this.data.ornamentId);
3465
- }
3466
- isBackground() {
3467
- return !0;
3468
- }
3469
- }
3470
- class dr extends I {
3471
- price;
3472
- size;
3473
- currency;
3474
- data;
3475
- constructor({
3476
- price: e,
3477
- item: t,
3478
- size: a,
3479
- currency: r
3480
- }) {
3481
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
3482
- }
3483
- async onBuy(e, t) {
3484
- await super.onBuy(e, t), await m.addItem(e, this.data.entityId, t);
3485
- }
3486
- isBoostXp() {
3487
- return !0;
3488
- }
3489
- }
3490
- class pr extends I {
3491
- price;
3492
- size;
3493
- currency;
3494
- data;
3495
- constructor({
3496
- price: e,
3497
- item: t,
3498
- size: a,
3499
- currency: r
3500
- }) {
3501
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
3502
- }
3503
- async onBuy(e, t) {
3504
- await super.onBuy(e, t), await m.addItem(e, this.data.entityId, t);
3505
- }
3506
- isChest() {
3507
- return !0;
3508
- }
3509
- }
3510
- class yr extends I {
3511
- price;
3512
- size;
3513
- currency;
3514
- data;
3515
- constructor({
3516
- price: e,
3517
- item: t,
3518
- size: a,
3519
- currency: r
3520
- }) {
3521
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
3522
- }
3523
- async onBuy(e, t) {
3524
- await super.onBuy(e, t), await m.addItem(e, this.data.entityId, t);
3525
- }
3526
- isObject() {
3527
- return !0;
3528
- }
3529
- }
3530
- class fr extends I {
3531
- price;
3532
- size;
3533
- currency;
3534
- data;
3535
- constructor({
3536
- price: e,
3537
- item: t,
3538
- size: a,
3539
- currency: r
3540
- }) {
3541
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
3542
- }
3543
- async onBuy(e, t) {
3544
- await super.onBuy(e, t), await m.addEquipments(
3545
- e,
3546
- st({ stop: t }).map(
3547
- () => l.seedEquipment(
3548
- { ...this.data },
3549
- Date.now() - Math.round(Math.random() * 1e3)
3550
- )
3551
- ).map((a) => ({
3552
- entityId: a.entityId,
3553
- seed: a.seed
3554
- }))
3555
- );
3556
- }
3557
- isEquipment() {
3558
- return !0;
3559
- }
3560
- }
3561
- class mr extends I {
3562
- price;
3563
- size;
3564
- currency;
3565
- data;
3566
- constructor({
3567
- price: e,
3568
- item: t,
3569
- size: a,
3570
- currency: r
3571
- }) {
3572
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
3573
- }
3574
- async onBuy(e, t) {
3575
- await super.onBuy(e, t), await m.addItem(e, this.data.entityId, t);
3576
- }
3577
- isBottle() {
3578
- return !0;
3579
- }
3580
- }
3581
- class hr extends I {
3582
- price;
3583
- size;
3584
- currency;
3585
- data;
3586
- constructor({
3587
- price: e,
3588
- item: t,
3589
- size: a,
3590
- currency: r
3591
- }) {
3592
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
3593
- }
3594
- async onBuy(e, t) {
3595
- await super.onBuy(e, t), await m.addItem(e, this.data.entityId, t);
3596
- }
3597
- isRepair() {
3598
- return !0;
3599
- }
3600
- }
3601
- class gr extends I {
3602
- price;
3603
- size;
3604
- currency;
3605
- data;
3606
- constructor({
3607
- price: e,
3608
- item: t,
3609
- size: a,
3610
- currency: r
3611
- }) {
3612
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
3613
- }
3614
- async onBuy(e, t) {
3615
- await super.onBuy(e, t), await m.addItem(e, this.data.entityId, t);
3616
- }
3617
- isStore() {
3618
- return !0;
3619
- }
3620
- }
3621
- class wr extends I {
3622
- price;
3623
- size;
3624
- currency;
3625
- data;
3626
- constructor({
3627
- price: e,
3628
- item: t,
3629
- size: a,
3630
- currency: r
3631
- }) {
3632
- super(), this.data = t, this.price = e, this.size = a, this.currency = r;
3633
- }
3634
- async onBuy(e, t) {
3635
- await super.onBuy(e, t), await L.unlockTitle(e, this.data.ornamentId);
3636
- }
3637
- isTitle() {
3638
- return !0;
3639
- }
3640
- }
3641
- class Sr extends f {
3642
- async getShopItem(e, t) {
3643
- const r = (await this.get(e)).items.find((h) => h.id === t);
3644
- if (!r)
3645
- return;
3646
- const { price: s, size: i, currency: c } = r, u = await l.get(r.id) ?? await g.get(r.id);
3647
- if (g.isOrnament(u) && g.isBackground(u))
3648
- return new lr({ price: s, item: u, size: i, currency: c });
3649
- if (g.isOrnament(u) && g.isShopTitle(u))
3650
- return new wr({ price: s, item: u, size: i, currency: c });
3651
- if (l.isEntity(u) && l.isChestItem(u))
3652
- return new pr({ price: s, item: u, size: i, currency: c });
3653
- if (l.isEntity(u) && l.isBoostItem(u))
3654
- return new dr({ price: s, item: u, size: i, currency: c });
3655
- if (l.isEntity(u) && l.isRepairItem(u))
3656
- return new hr({ price: s, item: u, size: i, currency: c });
3657
- if (l.isEntity(u) && l.isStoreItem(u))
3658
- return new gr({ price: s, item: u, size: i, currency: c });
3659
- if (l.isEntity(u) && l.isObjectItem(u))
3660
- return new yr({ price: s, item: u, size: i, currency: c });
3661
- if (l.isEntity(u) && l.isEquipment(u))
3662
- return new fr({ price: s, item: u, size: i, currency: c });
3663
- if (l.isEntity(u) && l.isBottleItem(u))
3664
- return new mr({ price: s, size: i, item: u, currency: c });
3665
- }
3666
- async getShopItemList(e) {
3667
- const t = await this.get(e), a = [];
3668
- for (const { id: r } of t.items) {
3669
- const s = await this.getShopItem(e, r);
3670
- s && a.push(s);
3671
- }
3672
- return a;
3673
- }
3674
- getShopItemId(e) {
3675
- return l.isEntity(e.data) ? e.data.entityId : e.data.ornamentId;
3676
- }
3677
- async updateShopStats(e, t, a) {
3678
- await this.update(
3679
- { shopType: e },
3680
- {
3681
- $inc: {
3682
- "stats.berrySpent": t.price * a,
3683
- "stats.itemBought": a,
3684
- "stats.chestBought": t.isChest() ? a : 0,
3685
- "stats.percentBought": t.data.type === "repair" ? (t.data.effects.find((r) => r.type === "CREW_REPAIR")?.params.amount ?? 0) * a : 0,
3686
- "stats.boostTimeBought": t.data.type === "boost" && t.data.ms ? t.data.ms / (1440 * 60 * 1e3) : 0
3687
- }
3688
- }
3689
- );
3690
- }
3691
- async buyShopItem(e, t, a, r) {
3692
- const s = t.map((i) => (i.id === this.getShopItemId(a) && i.size && (i.size -= r), i));
3693
- await this.update(
3694
- { shopType: e },
3695
- {
3696
- $set: {
3697
- items: s
3698
- }
3699
- }
3700
- );
3701
- }
3702
- async publish(e) {
3703
- await this.update(
3704
- { shopType: e },
3705
- {
3706
- $set: {
3707
- publishedAt: /* @__PURE__ */ new Date()
3708
- }
3709
- }
3710
- );
3711
- }
3712
- async setShopItems(e, t) {
3713
- await this.update(
3714
- { shopType: e },
3715
- {
3716
- $set: {
3717
- items: [...t]
3718
- }
3719
- }
3720
- );
3721
- }
3722
- }
3723
- const br = new o(
3724
- {
3725
- shopType: { type: String, required: !0, unique: !0 },
3726
- publishedAt: { type: Date, default: /* @__PURE__ */ new Date() },
3727
- duration: { type: Number, default: null },
3728
- closeAt: { type: Date, default: null },
3729
- items: {
3730
- type: [
3731
- {
3732
- _id: !1,
3733
- type: {
3734
- price: Number,
3735
- size: { type: Number, default: null },
3736
- id: String,
3737
- currency: String
3738
- }
3739
- }
3740
- ],
3741
- default: []
3742
- },
3743
- stats: {
3744
- berrySpent: { type: Number, default: 0 },
3745
- itemBought: { type: Number, default: 0 },
3746
- chestBought: { type: Number, default: 0 },
3747
- boostTimeBought: { type: Number, default: 0 },
3748
- percentBought: { type: Number, default: 0 }
3749
- }
3750
- },
3751
- { minimize: !1 }
3752
- ), fe = d?.Shop || p("Shop", br), $r = (n) => fe.create({
3753
- shopType: n
3754
- }), Ir = async (n) => {
3755
- const e = await fe.findOne({ shopType: n }).lean();
3756
- return e || y(await $r(n));
3757
- }, Er = (n, e) => fe.findOneAndUpdate(n, e, { upsert: !0, returnDocument: "after" }).lean();
3758
- class Ur extends Sr {
3759
- constructor() {
3760
- super(3600);
3761
- }
3762
- normalizeKey(e) {
3763
- return e;
3764
- }
3765
- getKey({ shopType: e }) {
3766
- return e;
3767
- }
3768
- fetchFromDb(e) {
3769
- return Ir(e);
3513
+ return qa(e);
3770
3514
  }
3771
3515
  updateInDb(e, t) {
3772
- return Er(e, t);
3516
+ return Aa(e, t);
3773
3517
  }
3774
3518
  }
3775
- const Xr = new Ur(), Dr = new o({
3519
+ const ss = new ka(), Ra = new c({
3776
3520
  warnedUserId: { type: String, required: !0, index: !0 },
3777
3521
  authorId: String,
3778
3522
  date: { type: Date, default: Date.now() },
3779
3523
  reason: { type: String, default: null }
3780
- }), ie = d?.Warn || p("Warn", Dr), Tr = (n) => ie.countDocuments(n), Or = (n) => ie.create({
3524
+ }), ce = d?.Warn || l("Warn", Ra), Ca = (n) => ce.countDocuments(n), _a = (n) => ce.create({
3781
3525
  ...n
3782
- }), vr = (n) => ie.findByIdAndDelete(n).lean();
3783
- class Br extends w {
3526
+ }), Ba = (n) => ce.findByIdAndDelete(n).lean();
3527
+ class Fa extends f {
3784
3528
  getUserWarns(e) {
3785
3529
  return this.getMany({ warnedUserId: e });
3786
3530
  }
3787
3531
  getUserWarnCount(e) {
3788
- return Tr({ warnedUserId: e });
3532
+ return Ca({ warnedUserId: e });
3789
3533
  }
3790
3534
  async createWarn(e) {
3791
- await Or(e);
3535
+ await _a(e);
3792
3536
  }
3793
3537
  async deleteWarn(e) {
3794
- const t = await vr(e);
3538
+ const t = await Ba(e);
3795
3539
  return t && this.invalidate(this.getKey(t)), t;
3796
3540
  }
3797
3541
  }
3798
- const Mr = (n) => ie.find(n).lean();
3799
- class kr extends Br {
3542
+ const Na = (n) => ce.find(n).lean();
3543
+ class Ka extends Fa {
3800
3544
  constructor() {
3801
3545
  super(300);
3802
3546
  }
@@ -3810,59 +3554,49 @@ class kr extends Br {
3810
3554
  throw new Error("Method not implemented.");
3811
3555
  }
3812
3556
  fetchManyFromDb(e) {
3813
- return Mr(e);
3557
+ return Na(e);
3814
3558
  }
3815
3559
  updateInDb() {
3816
3560
  throw new Error("Method not implemented.");
3817
3561
  }
3818
3562
  }
3819
- const Jr = new kr(), Zr = (n) => {
3820
- He(n);
3563
+ const is = new Ka(), us = (n) => {
3564
+ Qe(n);
3821
3565
  };
3822
- class es extends Ke.ObjectId {
3566
+ class cs extends Ye.ObjectId {
3823
3567
  }
3824
3568
  export {
3825
- lr as BackgroundShopItem,
3826
- dr as BoostXpShopItem,
3827
- mr as BottleShopItem,
3828
- Cr as COOLDOWN_COMMANDS,
3829
- pr as ChestShopItem,
3830
- fr as EquipmentShopItem,
3831
- es as ObjectId,
3832
- yr as ObjectShopItem,
3833
- b as QUEST_MIDDLEWARE_EVENT_NAME,
3834
- hr as RepairShopItem,
3835
- gr as StoreShopItem,
3836
- wr as TitleShopItem,
3837
- Gr as banService,
3838
- Zr as connectToServices,
3569
+ cs as ObjectId,
3570
+ w as QUEST_MIDDLEWARE_EVENT_NAME,
3571
+ rs as banService,
3572
+ us as connectToServices,
3839
3573
  S as emitQuestMiddlewareEvent,
3840
- l as entityService,
3841
- Yr as invitationService,
3842
- g as ornamentService,
3843
- E as panoplyService,
3844
- Wr as recipeService,
3845
- _r as registerQuestMiddlewareEvents,
3846
- Bt as reminderService,
3847
- Vr as settingsService,
3848
- Xr as shopService,
3849
- Nr as userCooldownService,
3850
- Fr as userDailyReportService,
3851
- ce as userEncyclopediaService,
3852
- zr as userGamesService,
3853
- m as userInventoryService,
3854
- U as userMetaService,
3855
- L as userOrnamentService,
3856
- we as userQuestService,
3857
- jr as userRankService,
3858
- bt as userService,
3859
- _e as userSettingsService,
3860
- Hr as userShopService,
3861
- Kr as userStatsCasinoService,
3862
- Sa as userStatsEconomyService,
3863
- Se as userStatsEngagementService,
3864
- Pr as userStatsFlagsService,
3865
- Lr as userStatsFrequencyService,
3866
- Qr as userStatsInventoryService,
3867
- Jr as warnService
3574
+ m as entityService,
3575
+ as as invitationService,
3576
+ U as ornamentService,
3577
+ R as panoplyService,
3578
+ ns as recipeService,
3579
+ La as registerQuestMiddlewareEvents,
3580
+ Rt as reminderService,
3581
+ ss as settingsService,
3582
+ T as storyService,
3583
+ Qa as userCooldownService,
3584
+ Ya as userDailyReportService,
3585
+ le as userEncyclopediaService,
3586
+ Ga as userGamesService,
3587
+ E as userInventoryService,
3588
+ O as userMetaService,
3589
+ we as userOrnamentService,
3590
+ be as userQuestService,
3591
+ Wa as userRankService,
3592
+ Et as userService,
3593
+ Fe as userSettingsService,
3594
+ Xa as userStatsCasinoService,
3595
+ Ja as userStatsEconomyService,
3596
+ $e as userStatsEngagementService,
3597
+ Za as userStatsFlagsService,
3598
+ es as userStatsFrequencyService,
3599
+ ts as userStatsInventoryService,
3600
+ Va as userStoryService,
3601
+ is as warnService
3868
3602
  };