coh-content-db 2.0.0-rc.3 → 2.0.0-rc.5

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.
@@ -64,13 +64,105 @@ const PLAQUE_TYPE = [
64
64
 
65
65
  const SEX = ["M", "F"];
66
66
 
67
+ var __defProp$8 = Object.defineProperty;
68
+ var __defNormalProp$8 = (obj, key, value) => key in obj ? __defProp$8(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
69
+ var __publicField$8 = (obj, key, value) => __defNormalProp$8(obj, typeof key !== "symbol" ? key + "" : key, value);
70
+ class Alignments {
71
+ constructor(raw) {
72
+ __publicField$8(this, "items");
73
+ __publicField$8(this, "hero");
74
+ __publicField$8(this, "villain");
75
+ __publicField$8(this, "praetorian");
76
+ __publicField$8(this, "primal");
77
+ this.items = raw;
78
+ this.hero = raw.includes("H");
79
+ this.villain = raw.includes("V");
80
+ this.praetorian = raw.includes("P");
81
+ this.primal = !this.praetorian && (this.hero || this.villain);
82
+ }
83
+ }
84
+
85
+ var __typeError$4 = (msg) => {
86
+ throw TypeError(msg);
87
+ };
88
+ var __accessCheck$4 = (obj, member, msg) => member.has(obj) || __typeError$4("Cannot " + msg);
89
+ var __privateGet$4 = (obj, member, getter) => (__accessCheck$4(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
90
+ var __privateAdd$4 = (obj, member, value) => member.has(obj) ? __typeError$4("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
91
+ var __privateSet$3 = (obj, member, value, setter) => (__accessCheck$4(obj, member, "write to private field"), member.set(obj, value), value);
92
+ var __privateMethod$2 = (obj, member, method) => (__accessCheck$4(obj, member, "access private method"), method);
93
+ var _sortedValues, _Alternates_instances, compareAlternates_fn, compareAlignment_fn, compareSex_fn;
94
+ const ALIGNMENT_SORT = { H: 2, V: 1, P: 0 };
95
+ const SEX_SORT = { M: 1, F: 0 };
96
+ class Alternates {
97
+ constructor(values) {
98
+ __privateAdd$4(this, _Alternates_instances);
99
+ __privateAdd$4(this, _sortedValues, []);
100
+ __privateSet$3(this, _sortedValues, values.sort());
101
+ __privateGet$4(this, _sortedValues).sort((a, b) => __privateMethod$2(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
102
+ }
103
+ getValue(alignment, sex) {
104
+ for (let index = __privateGet$4(this, _sortedValues).length; index--; ) {
105
+ const entry = __privateGet$4(this, _sortedValues)[index];
106
+ if ((entry.alignment === void 0 || entry.alignment === alignment) && (entry.sex === void 0 || entry.sex === sex)) return entry.value;
107
+ }
108
+ return this.default?.value;
109
+ }
110
+ /**
111
+ * Get the default value for this list of alternates, the value with the highest priority and lowest specificity.
112
+ */
113
+ get default() {
114
+ return __privateGet$4(this, _sortedValues)[0];
115
+ }
116
+ /**
117
+ * Get the list of alternates sorted in canonical order (alignment then sex, low to high specificity).
118
+ */
119
+ get canonical() {
120
+ return __privateGet$4(this, _sortedValues);
121
+ }
122
+ /**
123
+ * Create a joined string from the alternate values in canonical order.
124
+ * @param separator Separator to use. Default is ' / '
125
+ */
126
+ toString(separator) {
127
+ return this.canonical.map((x) => x.value).join(separator);
128
+ }
129
+ }
130
+ _sortedValues = new WeakMap();
131
+ _Alternates_instances = new WeakSet();
132
+ compareAlternates_fn = function(a, b) {
133
+ const aSpecificity = (a.alignment ? 2 : 0) + (a.sex ? 1 : 0);
134
+ const bSpecificity = (b.alignment ? 2 : 0) + (b.sex ? 1 : 0);
135
+ if (aSpecificity !== bSpecificity) return aSpecificity - bSpecificity;
136
+ const alignmentComparison = __privateMethod$2(this, _Alternates_instances, compareAlignment_fn).call(this, a.alignment, b.alignment);
137
+ if (alignmentComparison !== 0) return alignmentComparison;
138
+ const sexComparison = __privateMethod$2(this, _Alternates_instances, compareSex_fn).call(this, a.sex, b.sex);
139
+ if (sexComparison !== 0) return sexComparison;
140
+ return String(a.value).localeCompare(String(b.value));
141
+ };
142
+ compareAlignment_fn = function(a, b) {
143
+ if (a === b) return 0;
144
+ if (a === void 0 && b !== void 0) return -1;
145
+ if (b === void 0 && a !== void 0) return 1;
146
+ const aSort = a === void 0 ? -1 : ALIGNMENT_SORT[a] ?? -1;
147
+ const bSort = b === void 0 ? -1 : ALIGNMENT_SORT[b] ?? -1;
148
+ return bSort - aSort;
149
+ };
150
+ compareSex_fn = function(a, b) {
151
+ if (a === b) return 0;
152
+ if (a === void 0 && b !== void 0) return -1;
153
+ if (b === void 0 && a !== void 0) return 1;
154
+ const aSort = SEX_SORT[a ?? -1] ?? -1;
155
+ const bSort = SEX_SORT[b ?? -1] ?? -1;
156
+ return bSort - aSort;
157
+ };
158
+
67
159
  var __typeError$3 = (msg) => {
68
160
  throw TypeError(msg);
69
161
  };
70
162
  var __accessCheck$3 = (obj, member, msg) => member.has(obj) || __typeError$3("Cannot " + msg);
71
163
  var __privateGet$3 = (obj, member, getter) => (__accessCheck$3(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
72
164
  var __privateAdd$3 = (obj, member, value) => member.has(obj) ? __typeError$3("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
73
- var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
165
+ var __privateSet$2 = (obj, member, value, setter) => (__accessCheck$3(obj, member, "write to private field"), member.set(obj, value), value);
74
166
  var __privateMethod$1 = (obj, member, method) => (__accessCheck$3(obj, member, "access private method"), method);
75
167
  var _value, _Key_instances, validateKey_fn;
76
168
  const INVALID_KEY_PATTERN = /[^a-z0-9-]/;
@@ -79,7 +171,7 @@ class Key {
79
171
  __privateAdd$3(this, _Key_instances);
80
172
  __privateAdd$3(this, _value);
81
173
  __privateMethod$1(this, _Key_instances, validateKey_fn).call(this, value);
82
- __privateSet$1(this, _value, value);
174
+ __privateSet$2(this, _value, value);
83
175
  }
84
176
  get value() {
85
177
  return __privateGet$3(this, _value);
@@ -110,24 +202,60 @@ var __defNormalProp$6 = (obj, key, value) => key in obj ? __defProp$6(obj, key,
110
202
  var __publicField$6 = (obj, key, value) => __defNormalProp$6(obj, typeof key !== "symbol" ? key + "" : key, value);
111
203
  class BadgePartial {
112
204
  constructor(data) {
205
+ /**
206
+ * Key.
207
+ */
113
208
  __publicField$6(this, "key");
209
+ /**
210
+ * Type of partial.
211
+ */
114
212
  __publicField$6(this, "type");
213
+ /**
214
+ * Map the partial is located on.
215
+ */
115
216
  __publicField$6(this, "mapKey");
217
+ /**
218
+ * /loc coordinates.
219
+ */
116
220
  __publicField$6(this, "loc");
221
+ /**
222
+ * Is it a wall plaque or a physical monument?
223
+ */
117
224
  __publicField$6(this, "plaqueType");
118
- __publicField$6(this, "inscription");
225
+ /**
226
+ * Plaque inscription.
227
+ */
228
+ __publicField$6(this, "plaqueInscription");
229
+ /**
230
+ * The number or letter the partial appears as on Vidiot Maps.
231
+ */
119
232
  __publicField$6(this, "vidiotMapKey");
233
+ /**
234
+ * The badge required for this partial.
235
+ */
120
236
  __publicField$6(this, "badgeKey");
237
+ /**
238
+ * Level of the invention required.
239
+ */
121
240
  __publicField$6(this, "inventionLevel");
241
+ /**
242
+ * The types of enhancements required to be crafted.
243
+ */
122
244
  __publicField$6(this, "inventionTypes");
245
+ /**
246
+ * Number of invention crafts required.
247
+ */
123
248
  __publicField$6(this, "inventionCount");
249
+ /**
250
+ * Any additional notes.
251
+ */
124
252
  __publicField$6(this, "notes");
125
253
  this.key = new Key(data.key).value;
126
254
  this.type = data.type;
127
255
  this.mapKey = data.mapKey;
128
256
  this.loc = data.loc;
129
257
  this.plaqueType = data.plaqueType;
130
- this.inscription = data.inscription;
258
+ this.plaqueInscription = data.plaqueInscription;
131
259
  this.vidiotMapKey = data.vidiotMapKey;
132
260
  this.badgeKey = data.badgeKey;
133
261
  this.inventionLevel = data.inventionLevel;
@@ -137,95 +265,19 @@ class BadgePartial {
137
265
  }
138
266
  }
139
267
 
268
+ var __defProp$5 = Object.defineProperty;
140
269
  var __typeError$2 = (msg) => {
141
270
  throw TypeError(msg);
142
271
  };
272
+ var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
273
+ var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
143
274
  var __accessCheck$2 = (obj, member, msg) => member.has(obj) || __typeError$2("Cannot " + msg);
144
275
  var __privateGet$2 = (obj, member, getter) => (__accessCheck$2(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
145
276
  var __privateAdd$2 = (obj, member, value) => member.has(obj) ? __typeError$2("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
146
- var __privateSet = (obj, member, value, setter) => (__accessCheck$2(obj, member, "write to private field"), member.set(obj, value), value);
147
- var __privateMethod = (obj, member, method) => (__accessCheck$2(obj, member, "access private method"), method);
148
- var _sortedValues, _Alternates_instances, compareAlternates_fn, compareAlignment_fn, compareSex_fn;
149
- const ALIGNMENT_SORT = { H: 2, V: 1, P: 0 };
150
- const SEX_SORT = { M: 1, F: 0 };
151
- class Alternates {
152
- constructor(values) {
153
- __privateAdd$2(this, _Alternates_instances);
154
- __privateAdd$2(this, _sortedValues, []);
155
- __privateSet(this, _sortedValues, values.sort());
156
- __privateGet$2(this, _sortedValues).sort((a, b) => __privateMethod(this, _Alternates_instances, compareAlternates_fn).call(this, a, b));
157
- }
158
- getValue(alignment, sex) {
159
- for (let index = __privateGet$2(this, _sortedValues).length; index--; ) {
160
- const entry = __privateGet$2(this, _sortedValues)[index];
161
- if ((entry.alignment === void 0 || entry.alignment === alignment) && (entry.sex === void 0 || entry.sex === sex)) return entry.value;
162
- }
163
- return this.default;
164
- }
165
- /**
166
- * Get the default value for this list of alternates, the value with the highest priority and lowest specificity.
167
- */
168
- get default() {
169
- return __privateGet$2(this, _sortedValues)[0]?.value;
170
- }
171
- /**
172
- * Get the list of alternates sorted in canonical order (alignment then sex, low to high specificity).
173
- */
174
- get canonical() {
175
- return __privateGet$2(this, _sortedValues);
176
- }
177
- /**
178
- * Create a joined string from the alternate values in canonical order.
179
- * @param separator Separator to use. Default is ' / '
180
- */
181
- toString(separator) {
182
- return this.canonical.map((x) => x.value).join(separator);
183
- }
184
- }
185
- _sortedValues = new WeakMap();
186
- _Alternates_instances = new WeakSet();
187
- compareAlternates_fn = function(a, b) {
188
- const aSpecificity = (a.alignment ? 2 : 0) + (a.sex ? 1 : 0);
189
- const bSpecificity = (b.alignment ? 2 : 0) + (b.sex ? 1 : 0);
190
- if (aSpecificity !== bSpecificity) return aSpecificity - bSpecificity;
191
- const alignmentComparison = __privateMethod(this, _Alternates_instances, compareAlignment_fn).call(this, a.alignment, b.alignment);
192
- if (alignmentComparison !== 0) return alignmentComparison;
193
- const sexComparison = __privateMethod(this, _Alternates_instances, compareSex_fn).call(this, a.sex, b.sex);
194
- if (sexComparison !== 0) return sexComparison;
195
- return String(a.value).localeCompare(String(b.value));
196
- };
197
- compareAlignment_fn = function(a, b) {
198
- if (a === b) return 0;
199
- if (a === void 0 && b !== void 0) return -1;
200
- if (b === void 0 && a !== void 0) return 1;
201
- const aSort = a === void 0 ? -1 : ALIGNMENT_SORT[a] ?? -1;
202
- const bSort = b === void 0 ? -1 : ALIGNMENT_SORT[b] ?? -1;
203
- if (aSort !== bSort) return bSort - aSort;
204
- return a?.localeCompare(b ?? "") ?? 0;
205
- };
206
- compareSex_fn = function(a, b) {
207
- if (a === b) return 0;
208
- if (a === void 0 && b !== void 0) return -1;
209
- if (b === void 0 && a !== void 0) return 1;
210
- const aSort = SEX_SORT[a ?? -1] ?? -1;
211
- const bSort = SEX_SORT[b ?? -1] ?? -1;
212
- if (aSort !== bSort) return bSort - aSort;
213
- return a?.localeCompare(b ?? "") ?? 0;
214
- };
215
-
216
- var __defProp$5 = Object.defineProperty;
217
- var __typeError$1 = (msg) => {
218
- throw TypeError(msg);
219
- };
220
- var __defNormalProp$5 = (obj, key, value) => key in obj ? __defProp$5(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
221
- var __publicField$5 = (obj, key, value) => __defNormalProp$5(obj, typeof key !== "symbol" ? key + "" : key, value);
222
- var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
223
- var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
224
- var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
225
277
  var _partialsIndex;
226
278
  class Badge {
227
279
  constructor(data) {
228
- __privateAdd$1(this, _partialsIndex, {});
280
+ __privateAdd$2(this, _partialsIndex, {});
229
281
  /**
230
282
  * The database key for this badge.
231
283
  */
@@ -250,8 +302,6 @@ class Badge {
250
302
  __publicField$5(this, "badgeText");
251
303
  /**
252
304
  * Description of how to acquire the badge.
253
- *
254
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
255
305
  */
256
306
  __publicField$5(this, "acquisition");
257
307
  /**
@@ -262,8 +312,6 @@ class Badge {
262
312
  __publicField$5(this, "icon");
263
313
  /**
264
314
  * Freeform notes or tips about the badge.
265
- *
266
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
267
315
  */
268
316
  __publicField$5(this, "notes");
269
317
  /**
@@ -288,8 +336,6 @@ class Badge {
288
336
  __publicField$5(this, "setTitle");
289
337
  /**
290
338
  * A description of the effect the badge will have, such as a buff or granting a temporary power.
291
- *
292
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
293
339
  */
294
340
  __publicField$5(this, "effect");
295
341
  /**
@@ -303,7 +349,7 @@ class Badge {
303
349
  this.key = new Key(data.key).value;
304
350
  this.type = data.type;
305
351
  this.name = new Alternates(data.name);
306
- this.alignment = data.alignment;
352
+ this.alignment = new Alignments(data.alignment);
307
353
  this.badgeText = new Alternates(data.badgeText ?? []);
308
354
  this.acquisition = data.acquisition;
309
355
  this.icon = new Alternates(data.icon ?? []);
@@ -316,23 +362,124 @@ class Badge {
316
362
  this.setTitle = data.setTitle;
317
363
  this.ignoreInTotals = data.ignoreInTotals ?? false;
318
364
  this.partials = data.partials?.map((data2) => {
319
- if (__privateGet$1(this, _partialsIndex)[data2.key] !== void 0) throw new Error(`Duplicate badge partial key [${data2.key}]`);
365
+ if (__privateGet$2(this, _partialsIndex)[data2.key] !== void 0) throw new Error(`Duplicate badge partial key [${data2.key}]`);
320
366
  const badge = new BadgePartial(data2);
321
- __privateGet$1(this, _partialsIndex)[badge.key] = badge;
367
+ __privateGet$2(this, _partialsIndex)[badge.key] = badge;
322
368
  return badge;
323
369
  });
324
370
  }
325
371
  getPartial(key) {
326
- const result = __privateGet$1(this, _partialsIndex)[key];
372
+ const result = __privateGet$2(this, _partialsIndex)[key];
327
373
  if (result === void 0) throw new Error(`Unknown badge partial key [${key}]`);
328
374
  return result;
329
375
  }
330
376
  }
331
377
  _partialsIndex = new WeakMap();
332
378
 
379
+ var __typeError$1 = (msg) => {
380
+ throw TypeError(msg);
381
+ };
382
+ var __accessCheck$1 = (obj, member, msg) => member.has(obj) || __typeError$1("Cannot " + msg);
383
+ var __privateGet$1 = (obj, member, getter) => (__accessCheck$1(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
384
+ var __privateAdd$1 = (obj, member, value) => member.has(obj) ? __typeError$1("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
385
+ var __privateSet$1 = (obj, member, value, setter) => (__accessCheck$1(obj, member, "write to private field"), member.set(obj, value), value);
386
+ var __privateMethod = (obj, member, method) => (__accessCheck$1(obj, member, "access private method"), method);
387
+ var _badges, _badgeIndex$1, _mapOrder, _BadgeIndex_instances, satisfiesQueryPredicate_fn, satisfiesFilterPredicate_fn, sort_fn;
388
+ class BadgeIndex {
389
+ constructor(badges, maps) {
390
+ __privateAdd$1(this, _BadgeIndex_instances);
391
+ __privateAdd$1(this, _badges, []);
392
+ __privateAdd$1(this, _badgeIndex$1, {});
393
+ __privateAdd$1(this, _mapOrder, {});
394
+ __privateSet$1(this, _mapOrder, Object.fromEntries(
395
+ maps?.sort((a, b) => a.name.localeCompare(b.name))?.map((x, index) => [x.key, index]) ?? []
396
+ ));
397
+ __privateSet$1(this, _badges, badges);
398
+ for (const badge of badges) {
399
+ if (__privateGet$1(this, _badgeIndex$1)[badge.key] !== void 0) throw new Error(`Duplicate badge key [${badge.key}]`);
400
+ __privateGet$1(this, _badgeIndex$1)[badge.key] = badge;
401
+ }
402
+ }
403
+ getBadge(key) {
404
+ const result = __privateGet$1(this, _badgeIndex$1)[key];
405
+ if (result === void 0) throw new Error(`Unknown badge key [${key}]`);
406
+ return result;
407
+ }
408
+ searchBadges(options) {
409
+ const filtered = options?.query || options?.filter ? __privateGet$1(this, _badges).filter((badge) => __privateMethod(this, _BadgeIndex_instances, satisfiesQueryPredicate_fn).call(this, badge, options?.query) && __privateMethod(this, _BadgeIndex_instances, satisfiesFilterPredicate_fn).call(this, badge, options?.filter)) : __privateGet$1(this, _badges);
410
+ const paged = options?.pageSize ? filtered.slice(((options?.page ?? 1) - 1) * options.pageSize, (options?.page ?? 1) * options?.pageSize) : filtered;
411
+ const sorted = __privateMethod(this, _BadgeIndex_instances, sort_fn).call(this, paged, options?.sort);
412
+ return {
413
+ items: sorted,
414
+ page: options?.page ?? 1,
415
+ pageSize: options?.pageSize,
416
+ totalItems: filtered.length,
417
+ totalPages: options?.pageSize ? Math.ceil(filtered.length / options?.pageSize) : 1
418
+ };
419
+ }
420
+ }
421
+ _badges = new WeakMap();
422
+ _badgeIndex$1 = new WeakMap();
423
+ _mapOrder = new WeakMap();
424
+ _BadgeIndex_instances = new WeakSet();
425
+ satisfiesQueryPredicate_fn = function(badge, query) {
426
+ const queryString = query?.str?.toLowerCase() ?? "";
427
+ return !!((query?.on?.name ?? true) && badge.name.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || query?.on?.badgeText && badge.badgeText.canonical.some((x) => x.value.toLowerCase().includes(queryString)) || query?.on?.acquisition && badge.acquisition?.toLowerCase().includes(queryString) || query?.on?.effect && badge.effect?.toLowerCase().includes(queryString) || query?.on?.notes && badge.notes?.toLowerCase().includes(queryString) || query?.on?.setTitle && (badge.setTitle?.id?.toString().includes(queryString) || badge.setTitle?.praetorianId?.toString().includes(queryString)));
428
+ };
429
+ satisfiesFilterPredicate_fn = function(badge, filter) {
430
+ return (!filter?.type || badge.type === filter.type) && (!filter?.mapKey || badge.mapKey === filter.mapKey) && (!filter?.alignment || badge.alignment.items.includes(filter.alignment));
431
+ };
432
+ sort_fn = function(badges, sort) {
433
+ if (!sort) return badges;
434
+ const ascending = sort.dir !== "DESC";
435
+ if (!sort.by || sort.by === "CANONICAL") return sort.dir === "DESC" ? badges.reverse() : badges;
436
+ if (sort.by === "BADGE_NAME") return ascending ? badges.sort((a, b) => a.name.default?.value.localeCompare(b.name.default?.value ?? "") ?? 0) : badges.sort((a, b) => b.name.default?.value.localeCompare(a.name.default?.value ?? "") ?? 0);
437
+ return badges.sort((a, b) => {
438
+ const aIndex = __privateGet$1(this, _mapOrder)[a.mapKey ?? ""];
439
+ const bIndex = __privateGet$1(this, _mapOrder)[b.mapKey ?? ""];
440
+ if (aIndex === bIndex) return 0;
441
+ if (aIndex === void 0) return ascending ? 1 : -1;
442
+ if (bIndex === void 0) return ascending ? -1 : 1;
443
+ return ascending ? aIndex - bIndex : bIndex - aIndex;
444
+ });
445
+ };
446
+
333
447
  var __defProp$4 = Object.defineProperty;
334
448
  var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
335
449
  var __publicField$4 = (obj, key, value) => __defNormalProp$4(obj, typeof key !== "symbol" ? key + "" : key, value);
450
+ class BundleMetadata {
451
+ constructor(bundle) {
452
+ /**
453
+ * Name of the server group.
454
+ */
455
+ __publicField$4(this, "name");
456
+ /**
457
+ * Description of the server group.
458
+ */
459
+ __publicField$4(this, "description");
460
+ /**
461
+ * Repository where the db content package is maintained.
462
+ */
463
+ __publicField$4(this, "repository");
464
+ /**
465
+ * List of external links for this Server Group. Wiki, forums, etc.
466
+ */
467
+ __publicField$4(this, "links");
468
+ /**
469
+ * Change log for this data package.
470
+ */
471
+ __publicField$4(this, "changelog");
472
+ this.name = bundle.name;
473
+ this.description = bundle.description;
474
+ this.repository = bundle.repository;
475
+ this.links = bundle.links ?? [];
476
+ this.changelog = bundle.changelog ?? [];
477
+ }
478
+ }
479
+
480
+ var __defProp$3 = Object.defineProperty;
481
+ var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
482
+ var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
336
483
  class VidiotMapPointOfInterest {
337
484
  constructor(data) {
338
485
  /**
@@ -340,25 +487,23 @@ class VidiotMapPointOfInterest {
340
487
  *
341
488
  * Screen-space, pixels from top-left `[0, 0]`.
342
489
  */
343
- __publicField$4(this, "pos");
490
+ __publicField$3(this, "pos");
344
491
  /**
345
492
  * Freeform notes about the PoI.
346
- *
347
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
348
493
  */
349
- __publicField$4(this, "notes");
494
+ __publicField$3(this, "notes");
350
495
  /**
351
496
  * If the POI is a zone transfer, the map it transfers to.
352
497
  */
353
- __publicField$4(this, "mapKey");
498
+ __publicField$3(this, "mapKey");
354
499
  /**
355
500
  * If the POI is a badge, the badge.
356
501
  */
357
- __publicField$4(this, "badgeKey");
502
+ __publicField$3(this, "badgeKey");
358
503
  /**
359
504
  * If the POI is a partial for a badge, the partial key.
360
505
  */
361
- __publicField$4(this, "badgePartialKey");
506
+ __publicField$3(this, "badgePartialKey");
362
507
  this.pos = data.pos;
363
508
  this.notes = data.notes;
364
509
  this.mapKey = data.mapKey;
@@ -367,50 +512,50 @@ class VidiotMapPointOfInterest {
367
512
  }
368
513
  }
369
514
 
370
- var __defProp$3 = Object.defineProperty;
371
- var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
372
- var __publicField$3 = (obj, key, value) => __defNormalProp$3(obj, typeof key !== "symbol" ? key + "" : key, value);
515
+ var __defProp$2 = Object.defineProperty;
516
+ var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
517
+ var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
373
518
  class VidiotMap {
374
519
  constructor(data) {
375
520
  /**
376
521
  * URL of the map image.
377
522
  */
378
- __publicField$3(this, "imageUrl");
523
+ __publicField$2(this, "imageUrl");
379
524
  /**
380
525
  * Name to display for the Vidiot map.
381
526
  */
382
- __publicField$3(this, "name");
527
+ __publicField$2(this, "name");
383
528
  /**
384
529
  * List of Points of Interest labelled on the image.
385
530
  */
386
- __publicField$3(this, "pointsOfInterest");
531
+ __publicField$2(this, "pointsOfInterest");
387
532
  this.imageUrl = data.imageUrl;
388
533
  this.name = data.name;
389
534
  this.pointsOfInterest = data.pointsOfInterest?.map((data2) => new VidiotMapPointOfInterest(data2));
390
535
  }
391
536
  }
392
537
 
393
- var __defProp$2 = Object.defineProperty;
394
- var __defNormalProp$2 = (obj, key, value) => key in obj ? __defProp$2(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
395
- var __publicField$2 = (obj, key, value) => __defNormalProp$2(obj, typeof key !== "symbol" ? key + "" : key, value);
538
+ var __defProp$1 = Object.defineProperty;
539
+ var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
540
+ var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
396
541
  class GameMap {
397
542
  constructor(data) {
398
543
  /**
399
544
  * The database key for this map.
400
545
  */
401
- __publicField$2(this, "key");
546
+ __publicField$1(this, "key");
402
547
  /**
403
548
  * The name of the map as it appears in-game.
404
549
  */
405
- __publicField$2(this, "name");
550
+ __publicField$1(this, "name");
406
551
  /**
407
552
  * List of external links for this Map. Wiki, forums, etc.
408
553
  */
409
- __publicField$2(this, "links");
554
+ __publicField$1(this, "links");
410
555
  /**
411
556
  * List of Vidiot Map assets for this map.
412
557
  */
413
- __publicField$2(this, "vidiotMaps");
558
+ __publicField$1(this, "vidiotMaps");
414
559
  this.key = new Key(data.key).value;
415
560
  this.name = data.name;
416
561
  this.links = data.links;
@@ -418,41 +563,6 @@ class GameMap {
418
563
  }
419
564
  }
420
565
 
421
- var __defProp$1 = Object.defineProperty;
422
- var __defNormalProp$1 = (obj, key, value) => key in obj ? __defProp$1(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
423
- var __publicField$1 = (obj, key, value) => __defNormalProp$1(obj, typeof key !== "symbol" ? key + "" : key, value);
424
- class BundleMetadata {
425
- constructor(bundle) {
426
- /**
427
- * Name of the server group.
428
- */
429
- __publicField$1(this, "name");
430
- /**
431
- * Description of the server group.
432
- *
433
- * Supports {@link https://www.markdownguide.org/|Markdown} format.
434
- */
435
- __publicField$1(this, "description");
436
- /**
437
- * Repository where the db content package is maintained.
438
- */
439
- __publicField$1(this, "repository");
440
- /**
441
- * List of external links for this Server Group. Wiki, forums, etc.
442
- */
443
- __publicField$1(this, "links");
444
- /**
445
- * Change log for this data package.
446
- */
447
- __publicField$1(this, "changelog");
448
- this.name = bundle.name;
449
- this.description = bundle.description;
450
- this.repository = bundle.repository;
451
- this.links = bundle.links ?? [];
452
- this.changelog = bundle.changelog ?? [];
453
- }
454
- }
455
-
456
566
  var __defProp = Object.defineProperty;
457
567
  var __typeError = (msg) => {
458
568
  throw TypeError(msg);
@@ -462,6 +572,7 @@ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "sy
462
572
  var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
463
573
  var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
464
574
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
575
+ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), member.set(obj, value), value);
465
576
  var _archetypeIndex, _mapIndex, _badgeIndex;
466
577
  class CohContentDatabase {
467
578
  /**
@@ -471,7 +582,7 @@ class CohContentDatabase {
471
582
  constructor(bundle) {
472
583
  __privateAdd(this, _archetypeIndex, {});
473
584
  __privateAdd(this, _mapIndex, {});
474
- __privateAdd(this, _badgeIndex, {});
585
+ __privateAdd(this, _badgeIndex);
475
586
  /**
476
587
  * Metadata about the content bundle.
477
588
  */
@@ -507,12 +618,8 @@ class CohContentDatabase {
507
618
  __privateGet(this, _mapIndex)[map.key] = map;
508
619
  return map;
509
620
  }) ?? [];
510
- this.badges = bundle.badges?.map((data) => {
511
- if (__privateGet(this, _badgeIndex)[data.key] !== void 0) throw new Error(`Duplicate badge key [${data.key}]`);
512
- const badge = new Badge(data);
513
- __privateGet(this, _badgeIndex)[badge.key] = badge;
514
- return badge;
515
- }) ?? [];
621
+ this.badges = bundle.badges?.map((data) => new Badge(data)) ?? [];
622
+ __privateSet(this, _badgeIndex, new BadgeIndex(this.badges, this.maps));
516
623
  }
517
624
  getArchetype(key) {
518
625
  const result = __privateGet(this, _archetypeIndex)[key];
@@ -525,9 +632,16 @@ class CohContentDatabase {
525
632
  return result;
526
633
  }
527
634
  getBadge(key) {
528
- const result = __privateGet(this, _badgeIndex)[key];
529
- if (result === void 0) throw new Error(`Unknown badge key [${key}]`);
530
- return result;
635
+ return __privateGet(this, _badgeIndex).getBadge(key);
636
+ }
637
+ /**
638
+ * Search, sort and filter the badge list.
639
+ * This is a fairly brute-forced approach and will not be as performant as loading the badge data into a traditional
640
+ * database engine, but is sufficient for most operations.
641
+ * @param options {@link BadgeSearchOptions}
642
+ */
643
+ searchBadges(options) {
644
+ return __privateGet(this, _badgeIndex).searchBadges(options);
531
645
  }
532
646
  }
533
647
  _archetypeIndex = new WeakMap();
@@ -540,13 +654,15 @@ const CHANGELOG = [
540
654
  date: /* @__PURE__ */ new Date("2025-03-12"),
541
655
  description: `* Replaced redundant interfaces with their concrete equivalents.
542
656
  * Server groups are now referred to as 'forks'.
543
- * Replaced enums with extensible union types; Forks with new badge types, enhancement types, etc. can now extend them locally.
657
+ * Replaced enums with union types.
544
658
  * \`IServerGroupData\` is now \`ContentBundle\` and each database instance is now designed to accept only a single server group.
545
659
  * Removed the \`serverGroup\` property from entities to simplify the object tree given that only a single context can exist per db now.
660
+ * Added a simple indexing and search function for badge names, text and acquisition info.
661
+ * Map and badge references now follow a standard Markdown link format with a \`badge://\` or \`map://\` protocol.
546
662
  * Standardized pluralization of some field names (name, icon).
547
663
  * Combined \`settitle\` ids into a single tuple field.
548
664
  * Change from GNU to The Unlicense.
549
- * Removed dependency on lodash. There are now no third-party runtime dependencies.
665
+ * Removed all third-party dependencies.
550
666
  * Moved from webpack to rollup for packaging.
551
667
  * Add eslint for linting.
552
668
  * Add jest for unit tests.
@@ -555,20 +671,31 @@ const CHANGELOG = [
555
671
  }
556
672
  ];
557
673
 
558
- function createBadgeReference(target) {
674
+ function badgeUri(target) {
675
+ const key = typeof target === "string" ? target : target.key;
676
+ return `badge://${key}`;
677
+ }
678
+ function badgeLink(target) {
679
+ const key = typeof target === "string" ? target : target.key;
680
+ return `[${key}](${badgeUri(target)})`;
681
+ }
682
+ function mapUri(target) {
559
683
  const key = typeof target === "string" ? target : target.key;
560
- return `[badge:${key}]`;
684
+ return `map://${key}`;
561
685
  }
562
- function createMapReference(target) {
686
+ function mapLink(target) {
563
687
  const key = typeof target === "string" ? target : target.key;
564
- return `[map:${key}]`;
688
+ return `[${key}](${mapUri(target)})`;
565
689
  }
566
690
 
567
691
  exports.ALIGNMENT = ALIGNMENT;
692
+ exports.Alignments = Alignments;
693
+ exports.Alternates = Alternates;
568
694
  exports.Archetype = Archetype;
569
695
  exports.BADGE_PARTIAL_TYPE = BADGE_PARTIAL_TYPE;
570
696
  exports.BADGE_TYPE = BADGE_TYPE;
571
697
  exports.Badge = Badge;
698
+ exports.BadgeIndex = BadgeIndex;
572
699
  exports.BadgePartial = BadgePartial;
573
700
  exports.BundleMetadata = BundleMetadata;
574
701
  exports.CHANGELOG = CHANGELOG;
@@ -580,6 +707,8 @@ exports.PLAQUE_TYPE = PLAQUE_TYPE;
580
707
  exports.SEX = SEX;
581
708
  exports.VidiotMap = VidiotMap;
582
709
  exports.VidiotMapPointOfInterest = VidiotMapPointOfInterest;
583
- exports.createBadgeReference = createBadgeReference;
584
- exports.createMapReference = createMapReference;
710
+ exports.badgeLink = badgeLink;
711
+ exports.badgeUri = badgeUri;
712
+ exports.mapLink = mapLink;
713
+ exports.mapUri = mapUri;
585
714
  //# sourceMappingURL=coh-content-db.js.map