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