kaabalah 4.6.0 → 4.8.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.
@@ -7,11 +7,13 @@ var chunkFM7WUVZV_js = require('./chunk-FM7WUVZV.js');
7
7
  var data_exports = {};
8
8
  chunkFM7WUVZV_js.__export(data_exports, {
9
9
  DIGRAPHS: () => DIGRAPHS,
10
+ EXTENDED_MASTER_NUMBERS: () => EXTENDED_MASTER_NUMBERS,
10
11
  GematriaNumbersWithMeaning: () => GematriaNumbersWithMeaning,
11
12
  INDIVIDUALITY_NUMBER_MEANINGS: () => INDIVIDUALITY_NUMBER_MEANINGS,
12
13
  PERSONALITY_NUMBER_MEANINGS: () => PERSONALITY_NUMBER_MEANINGS,
13
14
  SYNTHESIS_NUMBER_MEANINGS: () => SYNTHESIS_NUMBER_MEANINGS
14
15
  });
16
+ var EXTENDED_MASTER_NUMBERS = [11, 22, 33, 44, 55, 66, 77, 88, 99];
15
17
  var DIGRAPHS = /* @__PURE__ */ new Set([
16
18
  chunk5AIYNAGI_js.LATIN_LETTERS.PH,
17
19
  chunk5AIYNAGI_js.LATIN_LETTERS.TS,
@@ -96,6 +98,32 @@ var reduceToSingleDigitWithSteps = (num) => {
96
98
  finalValue: currentNum
97
99
  };
98
100
  };
101
+ var reduceWithMasterNumbers = (num, masterNumbers = EXTENDED_MASTER_NUMBERS) => {
102
+ const steps = [num];
103
+ let current = num;
104
+ let masterNumber;
105
+ while (current > 9) {
106
+ if (masterNumbers.includes(current)) {
107
+ masterNumber = current;
108
+ break;
109
+ }
110
+ current = String(current).split("").reduce((acc, digit) => acc + parseInt(digit), 0);
111
+ steps.push(current);
112
+ }
113
+ let finalValue = current;
114
+ if (masterNumber && finalValue > 9) {
115
+ while (finalValue > 9) {
116
+ finalValue = String(finalValue).split("").reduce((acc, d) => acc + parseInt(d), 0);
117
+ steps.push(finalValue);
118
+ }
119
+ }
120
+ return {
121
+ originalSum: num,
122
+ reductionSteps: steps,
123
+ finalValue: masterNumber ?? steps[steps.length - 1],
124
+ masterNumber
125
+ };
126
+ };
99
127
  var getLastArkAnnuStep = (steps) => {
100
128
  if (steps.length === 0) return 0;
101
129
  const step = steps.sort((a, b) => b - a).find((step2) => step2 <= 22);
@@ -288,6 +316,32 @@ function getAvailableLetters(tree, includeDigraphs) {
288
316
  const digraphs = includeDigraphs ? Array.from(DIGRAPHS) : [];
289
317
  return [...singleLetters, ...digraphs];
290
318
  }
319
+ function parseSuggestionToLetterUnits(text) {
320
+ const upper = text.toUpperCase();
321
+ const units = [];
322
+ let i = 0;
323
+ while (i < upper.length) {
324
+ const char = upper[i];
325
+ if (i + 1 < upper.length) {
326
+ const twoChar = char + upper[i + 1].toLowerCase();
327
+ if (DIGRAPHS.has(twoChar)) {
328
+ units.push(twoChar);
329
+ i += 2;
330
+ continue;
331
+ }
332
+ }
333
+ units.push(char);
334
+ i += 1;
335
+ }
336
+ return units;
337
+ }
338
+ function countLetterUnits(units) {
339
+ const counts = /* @__PURE__ */ new Map();
340
+ for (const unit of units) {
341
+ counts.set(unit, (counts.get(unit) || 0) + 1);
342
+ }
343
+ return counts;
344
+ }
291
345
  var reverseGematria = (options, tree) => {
292
346
  const {
293
347
  targetVowels,
@@ -296,7 +350,12 @@ var reverseGematria = (options, tree) => {
296
350
  minLength = 1,
297
351
  maxLength = 8,
298
352
  maxResults = 100,
299
- includeDigraphs = true
353
+ includeDigraphs = true,
354
+ maxLetterRepeat,
355
+ suggestionText,
356
+ suggestionMode = "subsequence",
357
+ matchReductionStep = true,
358
+ masterNumbers = EXTENDED_MASTER_NUMBERS
300
359
  } = options;
301
360
  if (targetVowels === void 0 && targetConsonants === void 0 && targetSynthesis === void 0) {
302
361
  return { results: [], hasMore: false, totalFound: 0 };
@@ -304,6 +363,13 @@ var reverseGematria = (options, tree) => {
304
363
  if (!tree) {
305
364
  tree = chunk5AIYNAGI_js.createTree({ system: chunk5AIYNAGI_js.SYSTEM, parts: [] });
306
365
  }
366
+ if (suggestionText !== void 0) {
367
+ if (suggestionMode === "subsequence") {
368
+ return reverseGematriaFromSubsequence(options, tree);
369
+ } else {
370
+ return reverseGematriaAnagram(options, tree);
371
+ }
372
+ }
307
373
  const results = [];
308
374
  let totalFound = 0;
309
375
  let hasMore = false;
@@ -316,7 +382,7 @@ var reverseGematria = (options, tree) => {
316
382
  }
317
383
  return letterInfoCache.get(cacheKey);
318
384
  };
319
- const backtrack = (currentLetters, currentInfos, runningVowelsSum, runningConsonantsSum) => {
385
+ const backtrack = (currentLetters, currentInfos, runningVowelsSum, runningConsonantsSum, letterCounts) => {
320
386
  if (results.length >= maxResults) {
321
387
  hasMore = true;
322
388
  return;
@@ -337,9 +403,12 @@ var reverseGematria = (options, tree) => {
337
403
  }
338
404
  }
339
405
  const actualSynthesisSum = actualVowelsSum + actualConsonantsSum;
340
- const matchesVowels = targetVowels === void 0 || actualVowelsSum === targetVowels;
341
- const matchesConsonants = targetConsonants === void 0 || actualConsonantsSum === targetConsonants;
342
- const matchesSynthesis = targetSynthesis === void 0 || actualSynthesisSum === targetSynthesis;
406
+ const vowelsReduction = reduceWithMasterNumbers(actualVowelsSum, masterNumbers);
407
+ const consonantsReduction = reduceWithMasterNumbers(actualConsonantsSum, masterNumbers);
408
+ const synthesisReduction = reduceWithMasterNumbers(actualSynthesisSum, masterNumbers);
409
+ const matchesVowels = targetVowels === void 0 || (matchReductionStep ? vowelsReduction.reductionSteps.includes(targetVowels) : actualVowelsSum === targetVowels);
410
+ const matchesConsonants = targetConsonants === void 0 || (matchReductionStep ? consonantsReduction.reductionSteps.includes(targetConsonants) : actualConsonantsSum === targetConsonants);
411
+ const matchesSynthesis = targetSynthesis === void 0 || (matchReductionStep ? synthesisReduction.reductionSteps.includes(targetSynthesis) : actualSynthesisSum === targetSynthesis);
343
412
  if (matchesVowels && matchesConsonants && matchesSynthesis) {
344
413
  totalFound++;
345
414
  if (results.length < maxResults) {
@@ -359,7 +428,10 @@ var reverseGematria = (options, tree) => {
359
428
  letterDetails,
360
429
  vowelsSum: actualVowelsSum,
361
430
  consonantsSum: actualConsonantsSum,
362
- synthesisSum: actualSynthesisSum
431
+ synthesisSum: actualSynthesisSum,
432
+ vowels: vowelsReduction,
433
+ consonants: consonantsReduction,
434
+ synthesis: synthesisReduction
363
435
  });
364
436
  } else {
365
437
  hasMore = true;
@@ -369,49 +441,434 @@ var reverseGematria = (options, tree) => {
369
441
  if (currentLength >= maxLength) {
370
442
  return;
371
443
  }
372
- if (targetVowels !== void 0 && runningVowelsSum > targetVowels) {
373
- return;
444
+ if (!matchReductionStep) {
445
+ if (targetVowels !== void 0 && runningVowelsSum > targetVowels) {
446
+ return;
447
+ }
448
+ if (targetConsonants !== void 0 && runningConsonantsSum > targetConsonants) {
449
+ return;
450
+ }
451
+ if (targetSynthesis !== void 0 && runningVowelsSum + runningConsonantsSum > targetSynthesis) {
452
+ return;
453
+ }
374
454
  }
375
- if (targetConsonants !== void 0 && runningConsonantsSum > targetConsonants) {
455
+ for (const letter of availableLetters) {
456
+ const isStarting = currentLength === 0;
457
+ const letterInfo = getLetterInfoCached(letter, isStarting);
458
+ if (!letterInfo) continue;
459
+ if (maxLetterRepeat !== void 0) {
460
+ const currentCount = letterCounts.get(letter) || 0;
461
+ if (currentCount >= maxLetterRepeat) {
462
+ continue;
463
+ }
464
+ }
465
+ const value = letterInfo.normalValue;
466
+ const newVowelsSum = runningVowelsSum + (letterInfo.isVowel ? value : 0);
467
+ const newConsonantsSum = runningConsonantsSum + (letterInfo.isVowel ? 0 : value);
468
+ if (!matchReductionStep) {
469
+ if (targetVowels !== void 0 && newVowelsSum > targetVowels) {
470
+ continue;
471
+ }
472
+ if (targetConsonants !== void 0 && newConsonantsSum > targetConsonants) {
473
+ continue;
474
+ }
475
+ if (targetSynthesis !== void 0 && newVowelsSum + newConsonantsSum > targetSynthesis) {
476
+ continue;
477
+ }
478
+ }
479
+ currentLetters.push(letter);
480
+ currentInfos.push(letterInfo);
481
+ letterCounts.set(letter, (letterCounts.get(letter) || 0) + 1);
482
+ backtrack(currentLetters, currentInfos, newVowelsSum, newConsonantsSum, letterCounts);
483
+ currentLetters.pop();
484
+ currentInfos.pop();
485
+ letterCounts.set(letter, letterCounts.get(letter) - 1);
486
+ if (results.length >= maxResults) {
487
+ hasMore = true;
488
+ return;
489
+ }
490
+ }
491
+ };
492
+ backtrack([], [], 0, 0, /* @__PURE__ */ new Map());
493
+ return {
494
+ results,
495
+ hasMore,
496
+ totalFound
497
+ };
498
+ };
499
+ function reverseGematriaAnagram(options, tree) {
500
+ const {
501
+ targetVowels,
502
+ targetConsonants,
503
+ targetSynthesis,
504
+ minLength = 1,
505
+ maxLength = 8,
506
+ maxResults = 100,
507
+ maxLetterRepeat,
508
+ suggestionText = "",
509
+ matchReductionStep = true,
510
+ masterNumbers = EXTENDED_MASTER_NUMBERS
511
+ } = options;
512
+ const results = [];
513
+ let totalFound = 0;
514
+ let hasMore = false;
515
+ const suggestionUnits = parseSuggestionToLetterUnits(suggestionText);
516
+ const letterUnits = suggestionUnits.filter((u) => u !== " ");
517
+ const maxSpaces = suggestionUnits.filter((u) => u === " ").length;
518
+ const availablePool = countLetterUnits(letterUnits);
519
+ const availableLetters = Array.from(availablePool.keys());
520
+ const letterInfoCache = /* @__PURE__ */ new Map();
521
+ const getLetterInfoCached = (letter, isStarting) => {
522
+ const cacheKey = `${letter}-${isStarting}`;
523
+ if (!letterInfoCache.has(cacheKey)) {
524
+ letterInfoCache.set(cacheKey, buildLetterInfo(tree, letter, isStarting));
525
+ }
526
+ return letterInfoCache.get(cacheKey);
527
+ };
528
+ const seenResults = /* @__PURE__ */ new Set();
529
+ const backtrack = (currentLetters, currentInfos, runningVowelsSum, runningConsonantsSum, letterCounts, usedFromPool, spacesUsed) => {
530
+ if (results.length >= maxResults) {
531
+ hasMore = true;
376
532
  return;
377
533
  }
378
- if (targetSynthesis !== void 0 && runningVowelsSum + runningConsonantsSum > targetSynthesis) {
534
+ const letterOnlyLength = currentLetters.filter((l) => l !== " ").length;
535
+ if (letterOnlyLength >= minLength && letterOnlyLength <= maxLength) {
536
+ let actualVowelsSum = runningVowelsSum;
537
+ let actualConsonantsSum = runningConsonantsSum;
538
+ if (currentInfos.length > 1) {
539
+ const lastInfo = currentInfos[currentInfos.length - 1];
540
+ if (lastInfo.endingValue !== void 0) {
541
+ const diff = lastInfo.endingValue - lastInfo.normalValue;
542
+ if (lastInfo.isVowel) {
543
+ actualVowelsSum += diff;
544
+ } else {
545
+ actualConsonantsSum += diff;
546
+ }
547
+ }
548
+ }
549
+ const actualSynthesisSum = actualVowelsSum + actualConsonantsSum;
550
+ const vowelsReduction = reduceWithMasterNumbers(actualVowelsSum, masterNumbers);
551
+ const consonantsReduction = reduceWithMasterNumbers(actualConsonantsSum, masterNumbers);
552
+ const synthesisReduction = reduceWithMasterNumbers(actualSynthesisSum, masterNumbers);
553
+ const matchesVowels = targetVowels === void 0 || (matchReductionStep ? vowelsReduction.reductionSteps.includes(targetVowels) : actualVowelsSum === targetVowels);
554
+ const matchesConsonants = targetConsonants === void 0 || (matchReductionStep ? consonantsReduction.reductionSteps.includes(targetConsonants) : actualConsonantsSum === targetConsonants);
555
+ const matchesSynthesis = targetSynthesis === void 0 || (matchReductionStep ? synthesisReduction.reductionSteps.includes(targetSynthesis) : actualSynthesisSum === targetSynthesis);
556
+ if (matchesVowels && matchesConsonants && matchesSynthesis) {
557
+ const lettersStr = currentLetters.join("").toUpperCase();
558
+ if (!seenResults.has(lettersStr)) {
559
+ seenResults.add(lettersStr);
560
+ totalFound++;
561
+ if (results.length < maxResults) {
562
+ const letterDetails = currentInfos.map((info, idx) => {
563
+ const isEnding = idx === currentInfos.length - 1 && currentInfos.length > 1;
564
+ const useEndingValue = isEnding && info.endingValue !== void 0;
565
+ return {
566
+ latinLetterId: chunk5AIYNAGI_js.id("latinLetter" /* LATIN_LETTER */, info.letter),
567
+ value: useEndingValue ? info.endingValue : info.normalValue,
568
+ hebrewLetterId: info.hebrewLetterId,
569
+ hebrewCharacter: useEndingValue && info.hebrewCharacterWhenEnding ? info.hebrewCharacterWhenEnding : info.hebrewCharacter,
570
+ isVowel: info.isVowel
571
+ };
572
+ });
573
+ results.push({
574
+ letters: lettersStr,
575
+ letterDetails,
576
+ vowelsSum: actualVowelsSum,
577
+ consonantsSum: actualConsonantsSum,
578
+ synthesisSum: actualSynthesisSum,
579
+ vowels: vowelsReduction,
580
+ consonants: consonantsReduction,
581
+ synthesis: synthesisReduction
582
+ });
583
+ } else {
584
+ hasMore = true;
585
+ }
586
+ }
587
+ }
588
+ }
589
+ if (letterOnlyLength >= maxLength) {
379
590
  return;
380
591
  }
592
+ if (!matchReductionStep) {
593
+ if (targetVowels !== void 0 && runningVowelsSum > targetVowels) {
594
+ return;
595
+ }
596
+ if (targetConsonants !== void 0 && runningConsonantsSum > targetConsonants) {
597
+ return;
598
+ }
599
+ if (targetSynthesis !== void 0 && runningVowelsSum + runningConsonantsSum > targetSynthesis) {
600
+ return;
601
+ }
602
+ }
603
+ if (spacesUsed < maxSpaces && currentLetters.length > 0 && currentLetters[currentLetters.length - 1] !== " ") {
604
+ currentLetters.push(" ");
605
+ backtrack(
606
+ currentLetters,
607
+ currentInfos,
608
+ runningVowelsSum,
609
+ runningConsonantsSum,
610
+ letterCounts,
611
+ usedFromPool,
612
+ spacesUsed + 1
613
+ );
614
+ currentLetters.pop();
615
+ if (results.length >= maxResults) {
616
+ hasMore = true;
617
+ return;
618
+ }
619
+ }
381
620
  for (const letter of availableLetters) {
382
- const isStarting = currentLength === 0;
621
+ const poolLimit = availablePool.get(letter) || 0;
622
+ const usedCount = usedFromPool.get(letter) || 0;
623
+ if (usedCount >= poolLimit) {
624
+ continue;
625
+ }
626
+ if (maxLetterRepeat !== void 0) {
627
+ const currentCount = letterCounts.get(letter) || 0;
628
+ if (currentCount >= maxLetterRepeat) {
629
+ continue;
630
+ }
631
+ }
632
+ const isStarting = currentInfos.length === 0;
383
633
  const letterInfo = getLetterInfoCached(letter, isStarting);
384
634
  if (!letterInfo) continue;
385
635
  const value = letterInfo.normalValue;
386
636
  const newVowelsSum = runningVowelsSum + (letterInfo.isVowel ? value : 0);
387
637
  const newConsonantsSum = runningConsonantsSum + (letterInfo.isVowel ? 0 : value);
638
+ if (!matchReductionStep) {
639
+ if (targetVowels !== void 0 && newVowelsSum > targetVowels) {
640
+ continue;
641
+ }
642
+ if (targetConsonants !== void 0 && newConsonantsSum > targetConsonants) {
643
+ continue;
644
+ }
645
+ if (targetSynthesis !== void 0 && newVowelsSum + newConsonantsSum > targetSynthesis) {
646
+ continue;
647
+ }
648
+ }
649
+ currentLetters.push(letter);
650
+ currentInfos.push(letterInfo);
651
+ letterCounts.set(letter, (letterCounts.get(letter) || 0) + 1);
652
+ usedFromPool.set(letter, usedCount + 1);
653
+ backtrack(
654
+ currentLetters,
655
+ currentInfos,
656
+ newVowelsSum,
657
+ newConsonantsSum,
658
+ letterCounts,
659
+ usedFromPool,
660
+ spacesUsed
661
+ );
662
+ currentLetters.pop();
663
+ currentInfos.pop();
664
+ letterCounts.set(letter, letterCounts.get(letter) - 1);
665
+ usedFromPool.set(letter, usedCount);
666
+ if (results.length >= maxResults) {
667
+ hasMore = true;
668
+ return;
669
+ }
670
+ }
671
+ };
672
+ backtrack([], [], 0, 0, /* @__PURE__ */ new Map(), /* @__PURE__ */ new Map(), 0);
673
+ return {
674
+ results,
675
+ hasMore,
676
+ totalFound
677
+ };
678
+ }
679
+ function reverseGematriaFromSubsequence(options, tree) {
680
+ const {
681
+ targetVowels,
682
+ targetConsonants,
683
+ targetSynthesis,
684
+ minLength = 1,
685
+ maxLength = 8,
686
+ maxResults = 100,
687
+ maxLetterRepeat,
688
+ suggestionText = "",
689
+ matchReductionStep = true,
690
+ masterNumbers = EXTENDED_MASTER_NUMBERS
691
+ } = options;
692
+ const results = [];
693
+ let totalFound = 0;
694
+ let hasMore = false;
695
+ const suggestionUnits = parseSuggestionToLetterUnits(suggestionText);
696
+ const letterUnitsWithPositions = [];
697
+ for (let i = 0; i < suggestionUnits.length; i++) {
698
+ letterUnitsWithPositions.push({
699
+ unit: suggestionUnits[i],
700
+ isSpace: suggestionUnits[i] === " ",
701
+ originalIndex: i
702
+ });
703
+ }
704
+ const letterOnlyUnits = letterUnitsWithPositions.filter((u) => !u.isSpace);
705
+ const maxSpaces = letterUnitsWithPositions.filter((u) => u.isSpace).length;
706
+ const letterInfoCache = /* @__PURE__ */ new Map();
707
+ const getLetterInfoCached = (letter, isStarting) => {
708
+ const cacheKey = `${letter}-${isStarting}`;
709
+ if (!letterInfoCache.has(cacheKey)) {
710
+ letterInfoCache.set(cacheKey, buildLetterInfo(tree, letter, isStarting));
711
+ }
712
+ return letterInfoCache.get(cacheKey);
713
+ };
714
+ const seenResults = /* @__PURE__ */ new Set();
715
+ const generateSubsequences = (index, currentLetters, currentInfos, runningVowelsSum, runningConsonantsSum, letterCounts, spacesUsed) => {
716
+ if (results.length >= maxResults) {
717
+ hasMore = true;
718
+ return;
719
+ }
720
+ const letterOnlyLength = currentLetters.filter((l) => l !== " ").length;
721
+ if (letterOnlyLength >= minLength && letterOnlyLength <= maxLength) {
722
+ let actualVowelsSum = runningVowelsSum;
723
+ let actualConsonantsSum = runningConsonantsSum;
724
+ if (currentInfos.length > 1) {
725
+ const lastInfo = currentInfos[currentInfos.length - 1];
726
+ if (lastInfo.endingValue !== void 0) {
727
+ const diff = lastInfo.endingValue - lastInfo.normalValue;
728
+ if (lastInfo.isVowel) {
729
+ actualVowelsSum += diff;
730
+ } else {
731
+ actualConsonantsSum += diff;
732
+ }
733
+ }
734
+ }
735
+ const actualSynthesisSum = actualVowelsSum + actualConsonantsSum;
736
+ const vowelsReduction = reduceWithMasterNumbers(actualVowelsSum, masterNumbers);
737
+ const consonantsReduction = reduceWithMasterNumbers(actualConsonantsSum, masterNumbers);
738
+ const synthesisReduction = reduceWithMasterNumbers(actualSynthesisSum, masterNumbers);
739
+ const matchesVowels = targetVowels === void 0 || (matchReductionStep ? vowelsReduction.reductionSteps.includes(targetVowels) : actualVowelsSum === targetVowels);
740
+ const matchesConsonants = targetConsonants === void 0 || (matchReductionStep ? consonantsReduction.reductionSteps.includes(targetConsonants) : actualConsonantsSum === targetConsonants);
741
+ const matchesSynthesis = targetSynthesis === void 0 || (matchReductionStep ? synthesisReduction.reductionSteps.includes(targetSynthesis) : actualSynthesisSum === targetSynthesis);
742
+ if (matchesVowels && matchesConsonants && matchesSynthesis) {
743
+ const lettersStr = currentLetters.join("").toUpperCase();
744
+ if (!seenResults.has(lettersStr)) {
745
+ seenResults.add(lettersStr);
746
+ totalFound++;
747
+ if (results.length < maxResults) {
748
+ const letterDetails = currentInfos.map((info, idx) => {
749
+ const isEnding = idx === currentInfos.length - 1 && currentInfos.length > 1;
750
+ const useEndingValue = isEnding && info.endingValue !== void 0;
751
+ return {
752
+ latinLetterId: chunk5AIYNAGI_js.id("latinLetter" /* LATIN_LETTER */, info.letter),
753
+ value: useEndingValue ? info.endingValue : info.normalValue,
754
+ hebrewLetterId: info.hebrewLetterId,
755
+ hebrewCharacter: useEndingValue && info.hebrewCharacterWhenEnding ? info.hebrewCharacterWhenEnding : info.hebrewCharacter,
756
+ isVowel: info.isVowel
757
+ };
758
+ });
759
+ results.push({
760
+ letters: lettersStr,
761
+ letterDetails,
762
+ vowelsSum: actualVowelsSum,
763
+ consonantsSum: actualConsonantsSum,
764
+ synthesisSum: actualSynthesisSum,
765
+ vowels: vowelsReduction,
766
+ consonants: consonantsReduction,
767
+ synthesis: synthesisReduction
768
+ });
769
+ } else {
770
+ hasMore = true;
771
+ }
772
+ }
773
+ }
774
+ }
775
+ if (index >= letterOnlyUnits.length || letterOnlyLength >= maxLength) {
776
+ return;
777
+ }
778
+ if (!matchReductionStep) {
779
+ if (targetVowels !== void 0 && runningVowelsSum > targetVowels) {
780
+ return;
781
+ }
782
+ if (targetConsonants !== void 0 && runningConsonantsSum > targetConsonants) {
783
+ return;
784
+ }
785
+ if (targetSynthesis !== void 0 && runningVowelsSum + runningConsonantsSum > targetSynthesis) {
786
+ return;
787
+ }
788
+ }
789
+ generateSubsequences(
790
+ index + 1,
791
+ currentLetters,
792
+ currentInfos,
793
+ runningVowelsSum,
794
+ runningConsonantsSum,
795
+ letterCounts,
796
+ spacesUsed
797
+ );
798
+ if (results.length >= maxResults) {
799
+ hasMore = true;
800
+ return;
801
+ }
802
+ const letter = letterOnlyUnits[index].unit;
803
+ if (maxLetterRepeat !== void 0) {
804
+ const currentCount = letterCounts.get(letter) || 0;
805
+ if (currentCount >= maxLetterRepeat) {
806
+ return;
807
+ }
808
+ }
809
+ const isStarting = currentInfos.length === 0;
810
+ const letterInfo = getLetterInfoCached(letter, isStarting);
811
+ if (!letterInfo) return;
812
+ const value = letterInfo.normalValue;
813
+ const newVowelsSum = runningVowelsSum + (letterInfo.isVowel ? value : 0);
814
+ const newConsonantsSum = runningConsonantsSum + (letterInfo.isVowel ? 0 : value);
815
+ if (!matchReductionStep) {
388
816
  if (targetVowels !== void 0 && newVowelsSum > targetVowels) {
389
- continue;
817
+ return;
390
818
  }
391
819
  if (targetConsonants !== void 0 && newConsonantsSum > targetConsonants) {
392
- continue;
820
+ return;
393
821
  }
394
822
  if (targetSynthesis !== void 0 && newVowelsSum + newConsonantsSum > targetSynthesis) {
395
- continue;
823
+ return;
396
824
  }
825
+ }
826
+ currentLetters.push(letter);
827
+ currentInfos.push(letterInfo);
828
+ letterCounts.set(letter, (letterCounts.get(letter) || 0) + 1);
829
+ generateSubsequences(
830
+ index + 1,
831
+ currentLetters,
832
+ currentInfos,
833
+ newVowelsSum,
834
+ newConsonantsSum,
835
+ letterCounts,
836
+ spacesUsed
837
+ );
838
+ currentLetters.pop();
839
+ currentInfos.pop();
840
+ letterCounts.set(letter, letterCounts.get(letter) - 1);
841
+ if (results.length >= maxResults) {
842
+ hasMore = true;
843
+ return;
844
+ }
845
+ if (spacesUsed < maxSpaces && currentLetters.length > 0 && currentLetters[currentLetters.length - 1] !== " ") {
846
+ currentLetters.push(" ");
397
847
  currentLetters.push(letter);
398
848
  currentInfos.push(letterInfo);
399
- backtrack(currentLetters, currentInfos, newVowelsSum, newConsonantsSum);
849
+ letterCounts.set(letter, (letterCounts.get(letter) || 0) + 1);
850
+ generateSubsequences(
851
+ index + 1,
852
+ currentLetters,
853
+ currentInfos,
854
+ newVowelsSum,
855
+ newConsonantsSum,
856
+ letterCounts,
857
+ spacesUsed + 1
858
+ );
859
+ currentLetters.pop();
400
860
  currentLetters.pop();
401
861
  currentInfos.pop();
402
- if (results.length >= maxResults) {
403
- hasMore = true;
404
- return;
405
- }
862
+ letterCounts.set(letter, letterCounts.get(letter) - 1);
406
863
  }
407
864
  };
408
- backtrack([], [], 0, 0);
865
+ generateSubsequences(0, [], [], 0, 0, /* @__PURE__ */ new Map(), 0);
409
866
  return {
410
867
  results,
411
868
  hasMore,
412
869
  totalFound
413
870
  };
414
- };
871
+ }
415
872
  var calculateGematria = (phrase, options = {
416
873
  missing: false,
417
874
  percentages: false
@@ -481,5 +938,5 @@ var calculateGematria = (phrase, options = {
481
938
  exports.calculateGematria = calculateGematria;
482
939
  exports.data_exports = data_exports;
483
940
  exports.reverseGematria = reverseGematria;
484
- //# sourceMappingURL=chunk-Y2LGJEWP.js.map
485
- //# sourceMappingURL=chunk-Y2LGJEWP.js.map
941
+ //# sourceMappingURL=chunk-BIW4BUAA.js.map
942
+ //# sourceMappingURL=chunk-BIW4BUAA.js.map