@trishchuk/coolors-mcp 1.0.0 → 1.0.1

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 (66) hide show
  1. package/.claude/settings.local.json +2 -6
  2. package/.github/ISSUE_TEMPLATE/bug_report.md +20 -8
  3. package/.github/ISSUE_TEMPLATE/feature_request.md +22 -8
  4. package/.github/pull_request_template.md +33 -8
  5. package/.github/workflows/ci.yml +97 -97
  6. package/.github/workflows/deploy-docs.yml +9 -9
  7. package/.github/workflows/release.yml +15 -15
  8. package/README.md +26 -1
  9. package/TOOLS_UK.md +233 -0
  10. package/docs/.vitepress/cache/deps/@braintree_sanitize-url.js +30 -12
  11. package/docs/.vitepress/cache/deps/_metadata.json +1 -1
  12. package/docs/.vitepress/cache/deps/chunk-BUSYA2B4.js +9 -6
  13. package/docs/.vitepress/cache/deps/chunk-JD3CXNQ6.js +2543 -1612
  14. package/docs/.vitepress/cache/deps/chunk-SYPOPCWC.js +3508 -2529
  15. package/docs/.vitepress/cache/deps/cytoscape-cose-bilkent.js +1902 -1003
  16. package/docs/.vitepress/cache/deps/cytoscape.js +13303 -7347
  17. package/docs/.vitepress/cache/deps/dayjs.js +494 -272
  18. package/docs/.vitepress/cache/deps/debug.js +82 -38
  19. package/docs/.vitepress/cache/deps/prismjs.js +444 -272
  20. package/docs/.vitepress/cache/deps/prismjs_components_prism-bash.js +80 -73
  21. package/docs/.vitepress/cache/deps/prismjs_components_prism-javascript.js +93 -62
  22. package/docs/.vitepress/cache/deps/prismjs_components_prism-json.js +13 -13
  23. package/docs/.vitepress/cache/deps/prismjs_components_prism-python.js +34 -27
  24. package/docs/.vitepress/cache/deps/prismjs_components_prism-typescript.js +20 -17
  25. package/docs/.vitepress/cache/deps/prismjs_components_prism-yaml.js +75 -41
  26. package/docs/.vitepress/cache/deps/vitepress___@vue_devtools-api.js +2005 -1438
  27. package/docs/.vitepress/cache/deps/vitepress___@vueuse_core.js +2 -2
  28. package/docs/.vitepress/cache/deps/vitepress___@vueuse_integrations_useFocusTrap.js +566 -229
  29. package/docs/.vitepress/cache/deps/vitepress___mark__js_src_vanilla__js.js +382 -270
  30. package/docs/.vitepress/cache/deps/vitepress___minisearch.js +334 -125
  31. package/docs/.vitepress/cache/deps/vue.js +2 -2
  32. package/docs/.vitepress/components/ClientGrid.vue +9 -3
  33. package/docs/.vitepress/components/CodeBlock.vue +51 -44
  34. package/docs/.vitepress/components/ConfigModal.vue +151 -67
  35. package/docs/.vitepress/components/DiagramModal.vue +186 -154
  36. package/docs/.vitepress/components/TroubleshootingModal.vue +101 -96
  37. package/docs/.vitepress/config.js +171 -141
  38. package/docs/.vitepress/theme/FundingLayout.vue +65 -54
  39. package/docs/.vitepress/theme/Layout.vue +21 -21
  40. package/docs/.vitepress/theme/components/AdBanner.vue +73 -52
  41. package/docs/.vitepress/theme/components/AdPlaceholder.vue +3 -3
  42. package/docs/.vitepress/theme/components/FundingEffects.vue +77 -53
  43. package/docs/.vitepress/theme/components/FundingHero.vue +78 -63
  44. package/docs/.vitepress/theme/components/SupportSection.vue +106 -89
  45. package/docs/.vitepress/theme/custom-app.css +19 -12
  46. package/docs/.vitepress/theme/custom.css +33 -25
  47. package/docs/.vitepress/theme/index.js +19 -16
  48. package/docs/concepts/accessibility.md +59 -47
  49. package/docs/concepts/color-spaces.md +28 -6
  50. package/docs/concepts/distance-metrics.md +45 -30
  51. package/docs/concepts/hct.md +30 -27
  52. package/docs/concepts/image-analysis.md +52 -21
  53. package/docs/concepts/material-design.md +43 -17
  54. package/docs/concepts/theme-matching.md +64 -40
  55. package/docs/examples/basic-colors.md +92 -108
  56. package/docs/examples/creating-themes.md +104 -108
  57. package/docs/examples/css-refactoring.md +33 -29
  58. package/docs/examples/image-extraction.md +145 -138
  59. package/docs/getting-started.md +45 -34
  60. package/docs/index.md +5 -1
  61. package/docs/installation.md +15 -1
  62. package/docs/tools/accessibility.md +74 -68
  63. package/docs/tools/image-extraction.md +62 -54
  64. package/docs/tools/theme-matching.md +45 -42
  65. package/note.md +1 -2
  66. package/package.json +2 -2
@@ -43,7 +43,13 @@ var TreeIterator = class {
43
43
  this.backtrack();
44
44
  }
45
45
  key() {
46
- return this.set._prefix + this._path.map(({ keys }) => last$1(keys)).filter((key) => key !== LEAF).join("");
46
+ return (
47
+ this.set._prefix +
48
+ this._path
49
+ .map(({ keys }) => last$1(keys))
50
+ .filter((key) => key !== LEAF)
51
+ .join("")
52
+ );
47
53
  }
48
54
  value() {
49
55
  return last$1(this._path).node.get(LEAF);
@@ -67,15 +73,12 @@ var last$1 = (array) => {
67
73
  };
68
74
  var fuzzySearch = (node, query, maxDistance) => {
69
75
  const results = /* @__PURE__ */ new Map();
70
- if (query === void 0)
71
- return results;
76
+ if (query === void 0) return results;
72
77
  const n = query.length + 1;
73
78
  const m = n + maxDistance;
74
79
  const matrix = new Uint8Array(m * n).fill(maxDistance + 1);
75
- for (let j = 0; j < n; ++j)
76
- matrix[j] = j;
77
- for (let i = 1; i < m; ++i)
78
- matrix[i * n] = i;
80
+ for (let j = 0; j < n; ++j) matrix[j] = j;
81
+ for (let i = 1; i < m; ++i) matrix[i * n] = i;
79
82
  recurse(node, query, maxDistance, results, matrix, 1, n, "");
80
83
  return results;
81
84
  };
@@ -101,15 +104,27 @@ var recurse = (node, query, maxDistance, results, matrix, m, n, prefix) => {
101
104
  const rpl = matrix[prevRowOffset + j] + +different;
102
105
  const del = matrix[prevRowOffset + j + 1] + 1;
103
106
  const ins = matrix[thisRowOffset + j] + 1;
104
- const dist = matrix[thisRowOffset + j + 1] = Math.min(rpl, del, ins);
105
- if (dist < minDistance)
106
- minDistance = dist;
107
+ const dist = (matrix[thisRowOffset + j + 1] = Math.min(
108
+ rpl,
109
+ del,
110
+ ins,
111
+ ));
112
+ if (dist < minDistance) minDistance = dist;
107
113
  }
108
114
  if (minDistance > maxDistance) {
109
115
  continue key;
110
116
  }
111
117
  }
112
- recurse(node.get(key), query, maxDistance, results, matrix, i, n, prefix + key);
118
+ recurse(
119
+ node.get(key),
120
+ query,
121
+ maxDistance,
122
+ results,
123
+ matrix,
124
+ i,
125
+ n,
126
+ prefix + key,
127
+ );
113
128
  }
114
129
  }
115
130
  };
@@ -161,7 +176,10 @@ var SearchableMap = class _SearchableMap {
161
176
  if (!prefix.startsWith(this._prefix)) {
162
177
  throw new Error("Mismatched prefix");
163
178
  }
164
- const [node, path] = trackDown(this._tree, prefix.slice(this._prefix.length));
179
+ const [node, path] = trackDown(
180
+ this._tree,
181
+ prefix.slice(this._prefix.length),
182
+ );
165
183
  if (node === void 0) {
166
184
  const [parentNode, key] = last(path);
167
185
  for (const k of parentNode.keys()) {
@@ -286,8 +304,7 @@ var SearchableMap = class _SearchableMap {
286
304
  }
287
305
  this._size = 0;
288
306
  const iter = this.entries();
289
- while (!iter.next().done)
290
- this._size += 1;
307
+ while (!iter.next().done) this._size += 1;
291
308
  return this._size;
292
309
  }
293
310
  /**
@@ -343,7 +360,7 @@ var SearchableMap = class _SearchableMap {
343
360
  const node = createPath(this._tree, key);
344
361
  let value = node.get(LEAF);
345
362
  if (value === void 0) {
346
- node.set(LEAF, value = initial());
363
+ node.set(LEAF, (value = initial()));
347
364
  }
348
365
  return value;
349
366
  }
@@ -413,8 +430,7 @@ var createPath = (node, key) => {
413
430
  if (k !== LEAF && key[pos] === k[0]) {
414
431
  const len = Math.min(keyLength - pos, k.length);
415
432
  let offset = 1;
416
- while (offset < len && key[pos + offset] === k[offset])
417
- ++offset;
433
+ while (offset < len && key[pos + offset] === k[offset]) ++offset;
418
434
  const child2 = node.get(k);
419
435
  if (offset === k.length) {
420
436
  node = child2;
@@ -540,16 +556,27 @@ var MiniSearch = class _MiniSearch {
540
556
  * ```
541
557
  */
542
558
  constructor(options) {
543
- if ((options === null || options === void 0 ? void 0 : options.fields) == null) {
559
+ if (
560
+ (options === null || options === void 0 ? void 0 : options.fields) == null
561
+ ) {
544
562
  throw new Error('MiniSearch: option "fields" must be provided');
545
563
  }
546
- const autoVacuum = options.autoVacuum == null || options.autoVacuum === true ? defaultAutoVacuumOptions : options.autoVacuum;
564
+ const autoVacuum =
565
+ options.autoVacuum == null || options.autoVacuum === true
566
+ ? defaultAutoVacuumOptions
567
+ : options.autoVacuum;
547
568
  this._options = {
548
569
  ...defaultOptions,
549
570
  ...options,
550
571
  autoVacuum,
551
- searchOptions: { ...defaultSearchOptions, ...options.searchOptions || {} },
552
- autoSuggestOptions: { ...defaultAutoSuggestOptions, ...options.autoSuggestOptions || {} }
572
+ searchOptions: {
573
+ ...defaultSearchOptions,
574
+ ...(options.searchOptions || {}),
575
+ },
576
+ autoSuggestOptions: {
577
+ ...defaultAutoSuggestOptions,
578
+ ...(options.autoSuggestOptions || {}),
579
+ },
553
580
  };
554
581
  this._index = new SearchableMap();
555
582
  this._documentCount = 0;
@@ -572,10 +599,13 @@ var MiniSearch = class _MiniSearch {
572
599
  * @param document The document to be indexed
573
600
  */
574
601
  add(document) {
575
- const { extractField, tokenize, processTerm, fields, idField } = this._options;
602
+ const { extractField, tokenize, processTerm, fields, idField } =
603
+ this._options;
576
604
  const id = extractField(document, idField);
577
605
  if (id == null) {
578
- throw new Error(`MiniSearch: document does not have ID field "${idField}"`);
606
+ throw new Error(
607
+ `MiniSearch: document does not have ID field "${idField}"`,
608
+ );
579
609
  }
580
610
  if (this._idToShortId.has(id)) {
581
611
  throw new Error(`MiniSearch: duplicate ID ${id}`);
@@ -584,12 +614,16 @@ var MiniSearch = class _MiniSearch {
584
614
  this.saveStoredFields(shortDocumentId, document);
585
615
  for (const field of fields) {
586
616
  const fieldValue = extractField(document, field);
587
- if (fieldValue == null)
588
- continue;
617
+ if (fieldValue == null) continue;
589
618
  const tokens = tokenize(fieldValue.toString(), field);
590
619
  const fieldId = this._fieldIds[field];
591
620
  const uniqueTerms = new Set(tokens).size;
592
- this.addFieldLength(shortDocumentId, fieldId, this._documentCount - 1, uniqueTerms);
621
+ this.addFieldLength(
622
+ shortDocumentId,
623
+ fieldId,
624
+ this._documentCount - 1,
625
+ uniqueTerms,
626
+ );
593
627
  for (const term of tokens) {
594
628
  const processedTerm = processTerm(term, field);
595
629
  if (Array.isArray(processedTerm)) {
@@ -608,8 +642,7 @@ var MiniSearch = class _MiniSearch {
608
642
  * @param documents An array of documents to be indexed
609
643
  */
610
644
  addAll(documents) {
611
- for (const document of documents)
612
- this.add(document);
645
+ for (const document of documents) this.add(document);
613
646
  }
614
647
  /**
615
648
  * Adds all the given documents to the index asynchronously.
@@ -625,17 +658,22 @@ var MiniSearch = class _MiniSearch {
625
658
  addAllAsync(documents, options = {}) {
626
659
  const { chunkSize = 10 } = options;
627
660
  const acc = { chunk: [], promise: Promise.resolve() };
628
- const { chunk, promise } = documents.reduce(({ chunk: chunk2, promise: promise2 }, document, i) => {
629
- chunk2.push(document);
630
- if ((i + 1) % chunkSize === 0) {
631
- return {
632
- chunk: [],
633
- promise: promise2.then(() => new Promise((resolve) => setTimeout(resolve, 0))).then(() => this.addAll(chunk2))
634
- };
635
- } else {
636
- return { chunk: chunk2, promise: promise2 };
637
- }
638
- }, acc);
661
+ const { chunk, promise } = documents.reduce(
662
+ ({ chunk: chunk2, promise: promise2 }, document, i) => {
663
+ chunk2.push(document);
664
+ if ((i + 1) % chunkSize === 0) {
665
+ return {
666
+ chunk: [],
667
+ promise: promise2
668
+ .then(() => new Promise((resolve) => setTimeout(resolve, 0)))
669
+ .then(() => this.addAll(chunk2)),
670
+ };
671
+ } else {
672
+ return { chunk: chunk2, promise: promise2 };
673
+ }
674
+ },
675
+ acc,
676
+ );
639
677
  return promise.then(() => this.addAll(chunk));
640
678
  }
641
679
  /**
@@ -653,23 +691,32 @@ var MiniSearch = class _MiniSearch {
653
691
  * @param document The document to be removed
654
692
  */
655
693
  remove(document) {
656
- const { tokenize, processTerm, extractField, fields, idField } = this._options;
694
+ const { tokenize, processTerm, extractField, fields, idField } =
695
+ this._options;
657
696
  const id = extractField(document, idField);
658
697
  if (id == null) {
659
- throw new Error(`MiniSearch: document does not have ID field "${idField}"`);
698
+ throw new Error(
699
+ `MiniSearch: document does not have ID field "${idField}"`,
700
+ );
660
701
  }
661
702
  const shortId = this._idToShortId.get(id);
662
703
  if (shortId == null) {
663
- throw new Error(`MiniSearch: cannot remove document with ID ${id}: it is not in the index`);
704
+ throw new Error(
705
+ `MiniSearch: cannot remove document with ID ${id}: it is not in the index`,
706
+ );
664
707
  }
665
708
  for (const field of fields) {
666
709
  const fieldValue = extractField(document, field);
667
- if (fieldValue == null)
668
- continue;
710
+ if (fieldValue == null) continue;
669
711
  const tokens = tokenize(fieldValue.toString(), field);
670
712
  const fieldId = this._fieldIds[field];
671
713
  const uniqueTerms = new Set(tokens).size;
672
- this.removeFieldLength(shortId, fieldId, this._documentCount, uniqueTerms);
714
+ this.removeFieldLength(
715
+ shortId,
716
+ fieldId,
717
+ this._documentCount,
718
+ uniqueTerms,
719
+ );
673
720
  for (const term of tokens) {
674
721
  const processedTerm = processTerm(term, field);
675
722
  if (Array.isArray(processedTerm)) {
@@ -698,10 +745,11 @@ var MiniSearch = class _MiniSearch {
698
745
  */
699
746
  removeAll(documents) {
700
747
  if (documents) {
701
- for (const document of documents)
702
- this.remove(document);
748
+ for (const document of documents) this.remove(document);
703
749
  } else if (arguments.length > 0) {
704
- throw new Error("Expected documents to be present. Omit the argument to remove all documents.");
750
+ throw new Error(
751
+ "Expected documents to be present. Omit the argument to remove all documents.",
752
+ );
705
753
  } else {
706
754
  this._index = new SearchableMap();
707
755
  this._documentCount = 0;
@@ -760,13 +808,20 @@ var MiniSearch = class _MiniSearch {
760
808
  discard(id) {
761
809
  const shortId = this._idToShortId.get(id);
762
810
  if (shortId == null) {
763
- throw new Error(`MiniSearch: cannot discard document with ID ${id}: it is not in the index`);
811
+ throw new Error(
812
+ `MiniSearch: cannot discard document with ID ${id}: it is not in the index`,
813
+ );
764
814
  }
765
815
  this._idToShortId.delete(id);
766
816
  this._documentIds.delete(shortId);
767
817
  this._storedFields.delete(shortId);
768
818
  (this._fieldLength.get(shortId) || []).forEach((fieldLength, fieldId) => {
769
- this.removeFieldLength(shortId, fieldId, this._documentCount, fieldLength);
819
+ this.removeFieldLength(
820
+ shortId,
821
+ fieldId,
822
+ this._documentCount,
823
+ fieldLength,
824
+ );
770
825
  });
771
826
  this._fieldLength.delete(shortId);
772
827
  this._documentCount -= 1;
@@ -777,8 +832,12 @@ var MiniSearch = class _MiniSearch {
777
832
  if (this._options.autoVacuum === false) {
778
833
  return;
779
834
  }
780
- const { minDirtFactor, minDirtCount, batchSize, batchWait } = this._options.autoVacuum;
781
- this.conditionalVacuum({ batchSize, batchWait }, { minDirtCount, minDirtFactor });
835
+ const { minDirtFactor, minDirtCount, batchSize, batchWait } =
836
+ this._options.autoVacuum;
837
+ this.conditionalVacuum(
838
+ { batchSize, batchWait },
839
+ { minDirtCount, minDirtFactor },
840
+ );
782
841
  }
783
842
  /**
784
843
  * Discards the documents with the given IDs, so they won't appear in search
@@ -869,7 +928,8 @@ var MiniSearch = class _MiniSearch {
869
928
  }
870
929
  conditionalVacuum(options, conditions) {
871
930
  if (this._currentVacuum) {
872
- this._enqueuedVacuumConditions = this._enqueuedVacuumConditions && conditions;
931
+ this._enqueuedVacuumConditions =
932
+ this._enqueuedVacuumConditions && conditions;
873
933
  if (this._enqueuedVacuum != null) {
874
934
  return this._enqueuedVacuum;
875
935
  }
@@ -1135,7 +1195,10 @@ var MiniSearch = class _MiniSearch {
1135
1195
  */
1136
1196
  search(query, searchOptions = {}) {
1137
1197
  const { searchOptions: globalSearchOptions } = this._options;
1138
- const searchOptionsWithDefaults = { ...globalSearchOptions, ...searchOptions };
1198
+ const searchOptionsWithDefaults = {
1199
+ ...globalSearchOptions,
1200
+ ...searchOptions,
1201
+ };
1139
1202
  const rawResults = this.executeQuery(query, searchOptions);
1140
1203
  const results = [];
1141
1204
  for (const [docId, { score, terms, match }] of rawResults) {
@@ -1145,14 +1208,20 @@ var MiniSearch = class _MiniSearch {
1145
1208
  score: score * quality,
1146
1209
  terms: Object.keys(match),
1147
1210
  queryTerms: terms,
1148
- match
1211
+ match,
1149
1212
  };
1150
1213
  Object.assign(result, this._storedFields.get(docId));
1151
- if (searchOptionsWithDefaults.filter == null || searchOptionsWithDefaults.filter(result)) {
1214
+ if (
1215
+ searchOptionsWithDefaults.filter == null ||
1216
+ searchOptionsWithDefaults.filter(result)
1217
+ ) {
1152
1218
  results.push(result);
1153
1219
  }
1154
1220
  }
1155
- if (query === _MiniSearch.wildcard && searchOptionsWithDefaults.boostDocument == null) {
1221
+ if (
1222
+ query === _MiniSearch.wildcard &&
1223
+ searchOptionsWithDefaults.boostDocument == null
1224
+ ) {
1156
1225
  return results;
1157
1226
  }
1158
1227
  results.sort(byScore);
@@ -1274,7 +1343,9 @@ var MiniSearch = class _MiniSearch {
1274
1343
  */
1275
1344
  static loadJSON(json, options) {
1276
1345
  if (options == null) {
1277
- throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
1346
+ throw new Error(
1347
+ "MiniSearch: loadJSON should be given the same options used when serializing the index",
1348
+ );
1278
1349
  }
1279
1350
  return this.loadJS(JSON.parse(json), options);
1280
1351
  }
@@ -1293,7 +1364,9 @@ var MiniSearch = class _MiniSearch {
1293
1364
  */
1294
1365
  static async loadJSONAsync(json, options) {
1295
1366
  if (options == null) {
1296
- throw new Error("MiniSearch: loadJSON should be given the same options used when serializing the index");
1367
+ throw new Error(
1368
+ "MiniSearch: loadJSON should be given the same options used when serializing the index",
1369
+ );
1297
1370
  }
1298
1371
  return this.loadJSAsync(JSON.parse(json), options);
1299
1372
  }
@@ -1329,7 +1402,13 @@ var MiniSearch = class _MiniSearch {
1329
1402
  * @ignore
1330
1403
  */
1331
1404
  static loadJS(js, options) {
1332
- const { index, documentIds, fieldLength, storedFields, serializationVersion } = js;
1405
+ const {
1406
+ index,
1407
+ documentIds,
1408
+ fieldLength,
1409
+ storedFields,
1410
+ serializationVersion,
1411
+ } = js;
1333
1412
  const miniSearch = this.instantiateMiniSearch(js, options);
1334
1413
  miniSearch._documentIds = objectToNumericMap(documentIds);
1335
1414
  miniSearch._fieldLength = objectToNumericMap(fieldLength);
@@ -1354,7 +1433,13 @@ var MiniSearch = class _MiniSearch {
1354
1433
  * @ignore
1355
1434
  */
1356
1435
  static async loadJSAsync(js, options) {
1357
- const { index, documentIds, fieldLength, storedFields, serializationVersion } = js;
1436
+ const {
1437
+ index,
1438
+ documentIds,
1439
+ fieldLength,
1440
+ storedFields,
1441
+ serializationVersion,
1442
+ } = js;
1358
1443
  const miniSearch = this.instantiateMiniSearch(js, options);
1359
1444
  miniSearch._documentIds = await objectToNumericMapAsync(documentIds);
1360
1445
  miniSearch._fieldLength = await objectToNumericMapAsync(fieldLength);
@@ -1370,10 +1455,12 @@ var MiniSearch = class _MiniSearch {
1370
1455
  if (serializationVersion === 1) {
1371
1456
  indexEntry = indexEntry.ds;
1372
1457
  }
1373
- dataMap.set(parseInt(fieldId, 10), await objectToNumericMapAsync(indexEntry));
1458
+ dataMap.set(
1459
+ parseInt(fieldId, 10),
1460
+ await objectToNumericMapAsync(indexEntry),
1461
+ );
1374
1462
  }
1375
- if (++count % 1e3 === 0)
1376
- await wait(0);
1463
+ if (++count % 1e3 === 0) await wait(0);
1377
1464
  miniSearch._index.set(term, dataMap);
1378
1465
  }
1379
1466
  return miniSearch;
@@ -1382,9 +1469,18 @@ var MiniSearch = class _MiniSearch {
1382
1469
  * @ignore
1383
1470
  */
1384
1471
  static instantiateMiniSearch(js, options) {
1385
- const { documentCount, nextId, fieldIds, averageFieldLength, dirtCount, serializationVersion } = js;
1472
+ const {
1473
+ documentCount,
1474
+ nextId,
1475
+ fieldIds,
1476
+ averageFieldLength,
1477
+ dirtCount,
1478
+ serializationVersion,
1479
+ } = js;
1386
1480
  if (serializationVersion !== 1 && serializationVersion !== 2) {
1387
- throw new Error("MiniSearch: cannot deserialize an index created with an incompatible version");
1481
+ throw new Error(
1482
+ "MiniSearch: cannot deserialize an index created with an incompatible version",
1483
+ );
1388
1484
  }
1389
1485
  const miniSearch = new _MiniSearch(options);
1390
1486
  miniSearch._documentCount = documentCount;
@@ -1405,15 +1501,31 @@ var MiniSearch = class _MiniSearch {
1405
1501
  }
1406
1502
  if (typeof query !== "string") {
1407
1503
  const options2 = { ...searchOptions, ...query, queries: void 0 };
1408
- const results2 = query.queries.map((subquery) => this.executeQuery(subquery, options2));
1504
+ const results2 = query.queries.map((subquery) =>
1505
+ this.executeQuery(subquery, options2),
1506
+ );
1409
1507
  return this.combineResults(results2, options2.combineWith);
1410
1508
  }
1411
- const { tokenize, processTerm, searchOptions: globalSearchOptions } = this._options;
1412
- const options = { tokenize, processTerm, ...globalSearchOptions, ...searchOptions };
1413
- const { tokenize: searchTokenize, processTerm: searchProcessTerm } = options;
1414
- const terms = searchTokenize(query).flatMap((term) => searchProcessTerm(term)).filter((term) => !!term);
1509
+ const {
1510
+ tokenize,
1511
+ processTerm,
1512
+ searchOptions: globalSearchOptions,
1513
+ } = this._options;
1514
+ const options = {
1515
+ tokenize,
1516
+ processTerm,
1517
+ ...globalSearchOptions,
1518
+ ...searchOptions,
1519
+ };
1520
+ const { tokenize: searchTokenize, processTerm: searchProcessTerm } =
1521
+ options;
1522
+ const terms = searchTokenize(query)
1523
+ .flatMap((term) => searchProcessTerm(term))
1524
+ .filter((term) => !!term);
1415
1525
  const queries = terms.map(termToQuerySpec(options));
1416
- const results = queries.map((query2) => this.executeQuerySpec(query2, options));
1526
+ const results = queries.map((query2) =>
1527
+ this.executeQuerySpec(query2, options),
1528
+ );
1417
1529
  return this.combineResults(results, options.combineWith);
1418
1530
  }
1419
1531
  /**
@@ -1421,11 +1533,29 @@ var MiniSearch = class _MiniSearch {
1421
1533
  */
1422
1534
  executeQuerySpec(query, searchOptions) {
1423
1535
  const options = { ...this._options.searchOptions, ...searchOptions };
1424
- const boosts = (options.fields || this._options.fields).reduce((boosts2, field) => ({ ...boosts2, [field]: getOwnProperty(options.boost, field) || 1 }), {});
1536
+ const boosts = (options.fields || this._options.fields).reduce(
1537
+ (boosts2, field) => ({
1538
+ ...boosts2,
1539
+ [field]: getOwnProperty(options.boost, field) || 1,
1540
+ }),
1541
+ {},
1542
+ );
1425
1543
  const { boostDocument, weights, maxFuzzy, bm25: bm25params } = options;
1426
- const { fuzzy: fuzzyWeight, prefix: prefixWeight } = { ...defaultSearchOptions.weights, ...weights };
1544
+ const { fuzzy: fuzzyWeight, prefix: prefixWeight } = {
1545
+ ...defaultSearchOptions.weights,
1546
+ ...weights,
1547
+ };
1427
1548
  const data = this._index.get(query.term);
1428
- const results = this.termResults(query.term, query.term, 1, query.termBoost, data, boosts, boostDocument, bm25params);
1549
+ const results = this.termResults(
1550
+ query.term,
1551
+ query.term,
1552
+ 1,
1553
+ query.termBoost,
1554
+ data,
1555
+ boosts,
1556
+ boostDocument,
1557
+ bm25params,
1558
+ );
1429
1559
  let prefixMatches;
1430
1560
  let fuzzyMatches;
1431
1561
  if (query.prefix) {
@@ -1433,7 +1563,10 @@ var MiniSearch = class _MiniSearch {
1433
1563
  }
1434
1564
  if (query.fuzzy) {
1435
1565
  const fuzzy = query.fuzzy === true ? 0.2 : query.fuzzy;
1436
- const maxDistance = fuzzy < 1 ? Math.min(maxFuzzy, Math.round(query.term.length * fuzzy)) : fuzzy;
1566
+ const maxDistance =
1567
+ fuzzy < 1
1568
+ ? Math.min(maxFuzzy, Math.round(query.term.length * fuzzy))
1569
+ : fuzzy;
1437
1570
  if (maxDistance)
1438
1571
  fuzzyMatches = this._index.fuzzyGet(query.term, maxDistance);
1439
1572
  }
@@ -1443,9 +1576,22 @@ var MiniSearch = class _MiniSearch {
1443
1576
  if (!distance) {
1444
1577
  continue;
1445
1578
  }
1446
- fuzzyMatches === null || fuzzyMatches === void 0 ? void 0 : fuzzyMatches.delete(term);
1447
- const weight = prefixWeight * term.length / (term.length + 0.3 * distance);
1448
- this.termResults(query.term, term, weight, query.termBoost, data2, boosts, boostDocument, bm25params, results);
1579
+ fuzzyMatches === null || fuzzyMatches === void 0
1580
+ ? void 0
1581
+ : fuzzyMatches.delete(term);
1582
+ const weight =
1583
+ (prefixWeight * term.length) / (term.length + 0.3 * distance);
1584
+ this.termResults(
1585
+ query.term,
1586
+ term,
1587
+ weight,
1588
+ query.termBoost,
1589
+ data2,
1590
+ boosts,
1591
+ boostDocument,
1592
+ bm25params,
1593
+ results,
1594
+ );
1449
1595
  }
1450
1596
  }
1451
1597
  if (fuzzyMatches) {
@@ -1454,8 +1600,18 @@ var MiniSearch = class _MiniSearch {
1454
1600
  if (!distance) {
1455
1601
  continue;
1456
1602
  }
1457
- const weight = fuzzyWeight * term.length / (term.length + distance);
1458
- this.termResults(query.term, term, weight, query.termBoost, data2, boosts, boostDocument, bm25params, results);
1603
+ const weight = (fuzzyWeight * term.length) / (term.length + distance);
1604
+ this.termResults(
1605
+ query.term,
1606
+ term,
1607
+ weight,
1608
+ query.termBoost,
1609
+ data2,
1610
+ boosts,
1611
+ boostDocument,
1612
+ bm25params,
1613
+ results,
1614
+ );
1459
1615
  }
1460
1616
  }
1461
1617
  return results;
@@ -1467,11 +1623,13 @@ var MiniSearch = class _MiniSearch {
1467
1623
  const results = /* @__PURE__ */ new Map();
1468
1624
  const options = { ...this._options.searchOptions, ...searchOptions };
1469
1625
  for (const [shortId, id] of this._documentIds) {
1470
- const score = options.boostDocument ? options.boostDocument(id, "", this._storedFields.get(shortId)) : 1;
1626
+ const score = options.boostDocument
1627
+ ? options.boostDocument(id, "", this._storedFields.get(shortId))
1628
+ : 1;
1471
1629
  results.set(shortId, {
1472
1630
  score,
1473
1631
  terms: [],
1474
- match: {}
1632
+ match: {},
1475
1633
  });
1476
1634
  }
1477
1635
  return results;
@@ -1533,21 +1691,29 @@ var MiniSearch = class _MiniSearch {
1533
1691
  storedFields: Object.fromEntries(this._storedFields),
1534
1692
  dirtCount: this._dirtCount,
1535
1693
  index,
1536
- serializationVersion: 2
1694
+ serializationVersion: 2,
1537
1695
  };
1538
1696
  }
1539
1697
  /**
1540
1698
  * @ignore
1541
1699
  */
1542
- termResults(sourceTerm, derivedTerm, termWeight, termBoost, fieldTermData, fieldBoosts, boostDocumentFn, bm25params, results = /* @__PURE__ */ new Map()) {
1543
- if (fieldTermData == null)
1544
- return results;
1700
+ termResults(
1701
+ sourceTerm,
1702
+ derivedTerm,
1703
+ termWeight,
1704
+ termBoost,
1705
+ fieldTermData,
1706
+ fieldBoosts,
1707
+ boostDocumentFn,
1708
+ bm25params,
1709
+ results = /* @__PURE__ */ new Map(),
1710
+ ) {
1711
+ if (fieldTermData == null) return results;
1545
1712
  for (const field of Object.keys(fieldBoosts)) {
1546
1713
  const fieldBoost = fieldBoosts[field];
1547
1714
  const fieldId = this._fieldIds[field];
1548
1715
  const fieldTermFreqs = fieldTermData.get(fieldId);
1549
- if (fieldTermFreqs == null)
1550
- continue;
1716
+ if (fieldTermFreqs == null) continue;
1551
1717
  let matchingFields = fieldTermFreqs.size;
1552
1718
  const avgFieldLength = this._avgFieldLength[fieldId];
1553
1719
  for (const docId of fieldTermFreqs.keys()) {
@@ -1556,13 +1722,26 @@ var MiniSearch = class _MiniSearch {
1556
1722
  matchingFields -= 1;
1557
1723
  continue;
1558
1724
  }
1559
- const docBoost = boostDocumentFn ? boostDocumentFn(this._documentIds.get(docId), derivedTerm, this._storedFields.get(docId)) : 1;
1560
- if (!docBoost)
1561
- continue;
1725
+ const docBoost = boostDocumentFn
1726
+ ? boostDocumentFn(
1727
+ this._documentIds.get(docId),
1728
+ derivedTerm,
1729
+ this._storedFields.get(docId),
1730
+ )
1731
+ : 1;
1732
+ if (!docBoost) continue;
1562
1733
  const termFreq = fieldTermFreqs.get(docId);
1563
1734
  const fieldLength = this._fieldLength.get(docId)[fieldId];
1564
- const rawScore = calcBM25Score(termFreq, matchingFields, this._documentCount, fieldLength, avgFieldLength, bm25params);
1565
- const weightedScore = termWeight * termBoost * fieldBoost * docBoost * rawScore;
1735
+ const rawScore = calcBM25Score(
1736
+ termFreq,
1737
+ matchingFields,
1738
+ this._documentCount,
1739
+ fieldLength,
1740
+ avgFieldLength,
1741
+ bm25params,
1742
+ );
1743
+ const weightedScore =
1744
+ termWeight * termBoost * fieldBoost * docBoost * rawScore;
1566
1745
  const result = results.get(docId);
1567
1746
  if (result) {
1568
1747
  result.score += weightedScore;
@@ -1577,7 +1756,7 @@ var MiniSearch = class _MiniSearch {
1577
1756
  results.set(docId, {
1578
1757
  score: weightedScore,
1579
1758
  terms: [sourceTerm],
1580
- match: { [derivedTerm]: [field] }
1759
+ match: { [derivedTerm]: [field] },
1581
1760
  });
1582
1761
  }
1583
1762
  }
@@ -1630,7 +1809,11 @@ var MiniSearch = class _MiniSearch {
1630
1809
  warnDocumentChanged(shortDocumentId, fieldId, term) {
1631
1810
  for (const fieldName of Object.keys(this._fieldIds)) {
1632
1811
  if (this._fieldIds[fieldName] === fieldId) {
1633
- this._options.logger("warn", `MiniSearch: document with ID ${this._documentIds.get(shortDocumentId)} has changed before removal: term "${term}" was not present in field "${fieldName}". Removing a document after it has changed can corrupt the index!`, "version_conflict");
1812
+ this._options.logger(
1813
+ "warn",
1814
+ `MiniSearch: document with ID ${this._documentIds.get(shortDocumentId)} has changed before removal: term "${term}" was not present in field "${fieldName}". Removing a document after it has changed can corrupt the index!`,
1815
+ "version_conflict",
1816
+ );
1634
1817
  return;
1635
1818
  }
1636
1819
  }
@@ -1660,7 +1843,7 @@ var MiniSearch = class _MiniSearch {
1660
1843
  addFieldLength(documentId, fieldId, count, length) {
1661
1844
  let fieldLengths = this._fieldLength.get(documentId);
1662
1845
  if (fieldLengths == null)
1663
- this._fieldLength.set(documentId, fieldLengths = []);
1846
+ this._fieldLength.set(documentId, (fieldLengths = []));
1664
1847
  fieldLengths[fieldId] = length;
1665
1848
  const averageFieldLength = this._avgFieldLength[fieldId] || 0;
1666
1849
  const totalFieldLength = averageFieldLength * count + length;
@@ -1687,16 +1870,18 @@ var MiniSearch = class _MiniSearch {
1687
1870
  }
1688
1871
  let documentFields = this._storedFields.get(documentId);
1689
1872
  if (documentFields == null)
1690
- this._storedFields.set(documentId, documentFields = {});
1873
+ this._storedFields.set(documentId, (documentFields = {}));
1691
1874
  for (const fieldName of storeFields) {
1692
1875
  const fieldValue = extractField(doc, fieldName);
1693
- if (fieldValue !== void 0)
1694
- documentFields[fieldName] = fieldValue;
1876
+ if (fieldValue !== void 0) documentFields[fieldName] = fieldValue;
1695
1877
  }
1696
1878
  }
1697
1879
  };
1698
1880
  MiniSearch.wildcard = Symbol("*");
1699
- var getOwnProperty = (object, property) => Object.prototype.hasOwnProperty.call(object, property) ? object[property] : void 0;
1881
+ var getOwnProperty = (object, property) =>
1882
+ Object.prototype.hasOwnProperty.call(object, property)
1883
+ ? object[property]
1884
+ : void 0;
1700
1885
  var combinators = {
1701
1886
  [OR]: (a, b) => {
1702
1887
  for (const docId of b.keys()) {
@@ -1716,34 +1901,55 @@ var combinators = {
1716
1901
  const combined = /* @__PURE__ */ new Map();
1717
1902
  for (const docId of b.keys()) {
1718
1903
  const existing = a.get(docId);
1719
- if (existing == null)
1720
- continue;
1904
+ if (existing == null) continue;
1721
1905
  const { score, terms, match } = b.get(docId);
1722
1906
  assignUniqueTerms(existing.terms, terms);
1723
1907
  combined.set(docId, {
1724
1908
  score: existing.score + score,
1725
1909
  terms: existing.terms,
1726
- match: Object.assign(existing.match, match)
1910
+ match: Object.assign(existing.match, match),
1727
1911
  });
1728
1912
  }
1729
1913
  return combined;
1730
1914
  },
1731
1915
  [AND_NOT]: (a, b) => {
1732
- for (const docId of b.keys())
1733
- a.delete(docId);
1916
+ for (const docId of b.keys()) a.delete(docId);
1734
1917
  return a;
1735
- }
1918
+ },
1736
1919
  };
1737
1920
  var defaultBM25params = { k: 1.2, b: 0.7, d: 0.5 };
1738
- var calcBM25Score = (termFreq, matchingCount, totalCount, fieldLength, avgFieldLength, bm25params) => {
1921
+ var calcBM25Score = (
1922
+ termFreq,
1923
+ matchingCount,
1924
+ totalCount,
1925
+ fieldLength,
1926
+ avgFieldLength,
1927
+ bm25params,
1928
+ ) => {
1739
1929
  const { k, b, d } = bm25params;
1740
- const invDocFreq = Math.log(1 + (totalCount - matchingCount + 0.5) / (matchingCount + 0.5));
1741
- return invDocFreq * (d + termFreq * (k + 1) / (termFreq + k * (1 - b + b * fieldLength / avgFieldLength)));
1930
+ const invDocFreq = Math.log(
1931
+ 1 + (totalCount - matchingCount + 0.5) / (matchingCount + 0.5),
1932
+ );
1933
+ return (
1934
+ invDocFreq *
1935
+ (d +
1936
+ (termFreq * (k + 1)) /
1937
+ (termFreq + k * (1 - b + (b * fieldLength) / avgFieldLength)))
1938
+ );
1742
1939
  };
1743
1940
  var termToQuerySpec = (options) => (term, i, terms) => {
1744
- const fuzzy = typeof options.fuzzy === "function" ? options.fuzzy(term, i, terms) : options.fuzzy || false;
1745
- const prefix = typeof options.prefix === "function" ? options.prefix(term, i, terms) : options.prefix === true;
1746
- const termBoost = typeof options.boostTerm === "function" ? options.boostTerm(term, i, terms) : 1;
1941
+ const fuzzy =
1942
+ typeof options.fuzzy === "function"
1943
+ ? options.fuzzy(term, i, terms)
1944
+ : options.fuzzy || false;
1945
+ const prefix =
1946
+ typeof options.prefix === "function"
1947
+ ? options.prefix(term, i, terms)
1948
+ : options.prefix === true;
1949
+ const termBoost =
1950
+ typeof options.boostTerm === "function"
1951
+ ? options.boostTerm(term, i, terms)
1952
+ : 1;
1747
1953
  return { term, fuzzy, prefix, termBoost };
1748
1954
  };
1749
1955
  var defaultOptions = {
@@ -1755,10 +1961,14 @@ var defaultOptions = {
1755
1961
  searchOptions: void 0,
1756
1962
  storeFields: [],
1757
1963
  logger: (level, message) => {
1758
- if (typeof (console === null || console === void 0 ? void 0 : console[level]) === "function")
1964
+ if (
1965
+ typeof (console === null || console === void 0
1966
+ ? void 0
1967
+ : console[level]) === "function"
1968
+ )
1759
1969
  console[level](message);
1760
1970
  },
1761
- autoVacuum: true
1971
+ autoVacuum: true,
1762
1972
  };
1763
1973
  var defaultSearchOptions = {
1764
1974
  combineWith: OR,
@@ -1767,23 +1977,24 @@ var defaultSearchOptions = {
1767
1977
  maxFuzzy: 6,
1768
1978
  boost: {},
1769
1979
  weights: { fuzzy: 0.45, prefix: 0.375 },
1770
- bm25: defaultBM25params
1980
+ bm25: defaultBM25params,
1771
1981
  };
1772
1982
  var defaultAutoSuggestOptions = {
1773
1983
  combineWith: AND,
1774
- prefix: (term, i, terms) => i === terms.length - 1
1984
+ prefix: (term, i, terms) => i === terms.length - 1,
1775
1985
  };
1776
1986
  var defaultVacuumOptions = { batchSize: 1e3, batchWait: 10 };
1777
1987
  var defaultVacuumConditions = { minDirtFactor: 0.1, minDirtCount: 20 };
1778
- var defaultAutoVacuumOptions = { ...defaultVacuumOptions, ...defaultVacuumConditions };
1988
+ var defaultAutoVacuumOptions = {
1989
+ ...defaultVacuumOptions,
1990
+ ...defaultVacuumConditions,
1991
+ };
1779
1992
  var assignUniqueTerm = (target, term) => {
1780
- if (!target.includes(term))
1781
- target.push(term);
1993
+ if (!target.includes(term)) target.push(term);
1782
1994
  };
1783
1995
  var assignUniqueTerms = (target, source) => {
1784
1996
  for (const term of source) {
1785
- if (!target.includes(term))
1786
- target.push(term);
1997
+ if (!target.includes(term)) target.push(term);
1787
1998
  }
1788
1999
  };
1789
2000
  var byScore = ({ score: a }, { score: b }) => b - a;
@@ -1808,7 +2019,5 @@ var objectToNumericMapAsync = async (object) => {
1808
2019
  };
1809
2020
  var wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1810
2021
  var SPACE_OR_PUNCTUATION = /[\n\r\p{Z}\p{P}]+/u;
1811
- export {
1812
- MiniSearch as default
1813
- };
2022
+ export { MiniSearch as default };
1814
2023
  //# sourceMappingURL=vitepress___minisearch.js.map