kaabalah 6.8.1 → 6.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/dist/astrology/index.d.mts +8 -2
  2. package/dist/astrology/index.d.ts +8 -2
  3. package/dist/astrology/index.js +56 -52
  4. package/dist/astrology/index.mjs +1 -1
  5. package/dist/{chunk-LQX6PW35.js → chunk-47BAJUYW.js} +70 -103
  6. package/dist/chunk-47BAJUYW.js.map +1 -0
  7. package/dist/{chunk-SHKAAZHT.mjs → chunk-7LIIEUJB.mjs} +67 -43
  8. package/dist/chunk-7LIIEUJB.mjs.map +1 -0
  9. package/dist/{chunk-SYLFUBAB.js → chunk-CW6QDSMF.js} +41 -34
  10. package/dist/chunk-CW6QDSMF.js.map +1 -0
  11. package/dist/{chunk-K33NFXSD.js → chunk-FCAIGKB5.js} +163 -139
  12. package/dist/chunk-FCAIGKB5.js.map +1 -0
  13. package/dist/{chunk-WLML6SVX.js → chunk-GHHOLWAG.js} +493 -286
  14. package/dist/chunk-GHHOLWAG.js.map +1 -0
  15. package/dist/{chunk-36XZ5WR2.js → chunk-M2FTEWY2.js} +991 -985
  16. package/dist/chunk-M2FTEWY2.js.map +1 -0
  17. package/dist/{chunk-5K4OQ4UB.mjs → chunk-NOZKIUGP.mjs} +60 -43
  18. package/dist/chunk-NOZKIUGP.mjs.map +1 -0
  19. package/dist/{chunk-QS5XAAAG.mjs → chunk-OSMB2MJR.mjs} +23 -16
  20. package/dist/chunk-OSMB2MJR.mjs.map +1 -0
  21. package/dist/{chunk-7YU7TRCG.mjs → chunk-PEHDLSUH.mjs} +11 -7
  22. package/dist/chunk-PEHDLSUH.mjs.map +1 -0
  23. package/dist/{chunk-5HXSHALQ.mjs → chunk-PPIKM3QA.mjs} +486 -280
  24. package/dist/chunk-PPIKM3QA.mjs.map +1 -0
  25. package/dist/{chunk-VJ6RW5H4.js → chunk-Q7YAKPBH.js} +63 -42
  26. package/dist/chunk-Q7YAKPBH.js.map +1 -0
  27. package/dist/{chunk-3UJPBUY4.mjs → chunk-RAQDVWNK.mjs} +9 -12
  28. package/dist/chunk-RAQDVWNK.mjs.map +1 -0
  29. package/dist/{chunk-BEFGGHIJ.js → chunk-SWWLTDR6.js} +11 -6
  30. package/dist/chunk-SWWLTDR6.js.map +1 -0
  31. package/dist/{chunk-UZ42PN5T.js → chunk-UNXDDLZS.js} +10 -13
  32. package/dist/chunk-UNXDDLZS.js.map +1 -0
  33. package/dist/{chunk-6N5YC2WD.mjs → chunk-X5HGLMEF.mjs} +20 -53
  34. package/dist/chunk-X5HGLMEF.mjs.map +1 -0
  35. package/dist/{chunk-ITESL6GR.mjs → chunk-Y3TLBFPD.mjs} +982 -976
  36. package/dist/chunk-Y3TLBFPD.mjs.map +1 -0
  37. package/dist/cli.js +9349 -6829
  38. package/dist/cli.js.map +1 -1
  39. package/dist/core/index.d.mts +3 -3
  40. package/dist/core/index.d.ts +3 -3
  41. package/dist/core/index.js +65 -49
  42. package/dist/core/index.mjs +2 -2
  43. package/dist/{correspondence-model-DWXbAjC-.d.mts → correspondence-model-JSyDWwmn.d.mts} +19 -1
  44. package/dist/{correspondence-model-DWXbAjC-.d.ts → correspondence-model-JSyDWwmn.d.ts} +19 -1
  45. package/dist/data-CdjlIcAo.d.mts +33 -0
  46. package/dist/data-_b06lgY6.d.ts +33 -0
  47. package/dist/gematria/index.d.mts +1 -1
  48. package/dist/gematria/index.d.ts +1 -1
  49. package/dist/gematria/index.js +5 -5
  50. package/dist/gematria/index.mjs +2 -2
  51. package/dist/index.d.mts +6 -5
  52. package/dist/index.d.ts +6 -5
  53. package/dist/index.js +228 -204
  54. package/dist/index.mjs +8 -8
  55. package/dist/numerology/index.d.mts +21 -0
  56. package/dist/numerology/index.d.ts +21 -0
  57. package/dist/numerology/index.js +18 -18
  58. package/dist/numerology/index.mjs +3 -3
  59. package/dist/semantic/index.d.mts +2 -2
  60. package/dist/semantic/index.d.ts +2 -2
  61. package/dist/semantic/index.js +26 -26
  62. package/dist/semantic/index.mjs +7 -7
  63. package/dist/{swisseph.node-2PWBQLWG.mjs → swisseph.node-53QCJWTI.mjs} +4 -3
  64. package/dist/swisseph.node-53QCJWTI.mjs.map +1 -0
  65. package/dist/{swisseph.node-NWM75JF3.js → swisseph.node-CGBZTQ5N.js} +4 -3
  66. package/dist/swisseph.node-CGBZTQ5N.js.map +1 -0
  67. package/dist/swisseph.node-GPVFDOB6.wasm +0 -0
  68. package/dist/swisseph.node.js +1 -1
  69. package/dist/swisseph.node.wasm +0 -0
  70. package/dist/swisseph.web-GPVFDOB6.wasm +0 -0
  71. package/dist/{wasm/build/swisseph.web-CK57WSU3.mjs → swisseph.web-SRINFOJC.mjs} +4 -3
  72. package/dist/swisseph.web-SRINFOJC.mjs.map +1 -0
  73. package/dist/{wasm/build/swisseph.web-GPTWPXKT.js → swisseph.web-XCF4GL2M.js} +4 -3
  74. package/dist/swisseph.web-XCF4GL2M.js.map +1 -0
  75. package/dist/swisseph.web.js +1 -1
  76. package/dist/swisseph.web.wasm +0 -0
  77. package/dist/tarot/index.d.mts +102 -126
  78. package/dist/tarot/index.d.ts +102 -126
  79. package/dist/tarot/index.js +23 -23
  80. package/dist/tarot/index.mjs +3 -3
  81. package/dist/{topology-CSSfYL2c.d.mts → topology-CH3hsIqO.d.mts} +2 -1
  82. package/dist/{topology-Bbgniegh.d.ts → topology-DXYTpDvj.d.ts} +2 -1
  83. package/dist/visual/index.d.mts +135 -10
  84. package/dist/visual/index.d.ts +135 -10
  85. package/dist/visual/index.js +48 -44
  86. package/dist/visual/index.mjs +3 -3
  87. package/dist/wasm/build/{swisseph.node-2PWBQLWG.mjs → swisseph.node-53QCJWTI.mjs} +4 -3
  88. package/dist/wasm/build/swisseph.node-53QCJWTI.mjs.map +1 -0
  89. package/dist/wasm/build/{swisseph.node-NWM75JF3.js → swisseph.node-CGBZTQ5N.js} +4 -3
  90. package/dist/wasm/build/swisseph.node-CGBZTQ5N.js.map +1 -0
  91. package/dist/wasm/build/swisseph.node-GPVFDOB6.wasm +0 -0
  92. package/dist/wasm/build/swisseph.node.js +1 -1
  93. package/dist/wasm/build/swisseph.node.wasm +0 -0
  94. package/dist/wasm/build/swisseph.web-GPVFDOB6.wasm +0 -0
  95. package/dist/{swisseph.web-CK57WSU3.mjs → wasm/build/swisseph.web-SRINFOJC.mjs} +4 -3
  96. package/dist/wasm/build/swisseph.web-SRINFOJC.mjs.map +1 -0
  97. package/dist/{swisseph.web-GPTWPXKT.js → wasm/build/swisseph.web-XCF4GL2M.js} +4 -3
  98. package/dist/wasm/build/swisseph.web-XCF4GL2M.js.map +1 -0
  99. package/dist/wasm/build/swisseph.web.js +1 -1
  100. package/dist/wasm/build/swisseph.web.wasm +0 -0
  101. package/package.json +2 -1
  102. package/wasm/build/swisseph.node.js +1 -1
  103. package/wasm/build/swisseph.node.wasm +0 -0
  104. package/wasm/build/swisseph.web.js +1 -1
  105. package/wasm/build/swisseph.web.wasm +0 -0
  106. package/dist/chunk-36XZ5WR2.js.map +0 -1
  107. package/dist/chunk-3UJPBUY4.mjs.map +0 -1
  108. package/dist/chunk-5HXSHALQ.mjs.map +0 -1
  109. package/dist/chunk-5K4OQ4UB.mjs.map +0 -1
  110. package/dist/chunk-6N5YC2WD.mjs.map +0 -1
  111. package/dist/chunk-7YU7TRCG.mjs.map +0 -1
  112. package/dist/chunk-BEFGGHIJ.js.map +0 -1
  113. package/dist/chunk-ITESL6GR.mjs.map +0 -1
  114. package/dist/chunk-K33NFXSD.js.map +0 -1
  115. package/dist/chunk-LQX6PW35.js.map +0 -1
  116. package/dist/chunk-QS5XAAAG.mjs.map +0 -1
  117. package/dist/chunk-SHKAAZHT.mjs.map +0 -1
  118. package/dist/chunk-SYLFUBAB.js.map +0 -1
  119. package/dist/chunk-UZ42PN5T.js.map +0 -1
  120. package/dist/chunk-VJ6RW5H4.js.map +0 -1
  121. package/dist/chunk-WLML6SVX.js.map +0 -1
  122. package/dist/swisseph-YPVN5VCI.wasm +0 -0
  123. package/dist/swisseph.js +0 -30
  124. package/dist/swisseph.node-2K5IHMKE.wasm +0 -0
  125. package/dist/swisseph.node-2PWBQLWG.mjs.map +0 -1
  126. package/dist/swisseph.node-NWM75JF3.js.map +0 -1
  127. package/dist/swisseph.wasm +0 -0
  128. package/dist/swisseph.web-2K5IHMKE.wasm +0 -0
  129. package/dist/swisseph.web-CK57WSU3.mjs.map +0 -1
  130. package/dist/swisseph.web-GPTWPXKT.js.map +0 -1
  131. package/dist/wasm/build/swisseph-YPVN5VCI.wasm +0 -0
  132. package/dist/wasm/build/swisseph.js +0 -30
  133. package/dist/wasm/build/swisseph.node-2K5IHMKE.wasm +0 -0
  134. package/dist/wasm/build/swisseph.node-2PWBQLWG.mjs.map +0 -1
  135. package/dist/wasm/build/swisseph.node-NWM75JF3.js.map +0 -1
  136. package/dist/wasm/build/swisseph.wasm +0 -0
  137. package/dist/wasm/build/swisseph.web-2K5IHMKE.wasm +0 -0
  138. package/dist/wasm/build/swisseph.web-CK57WSU3.mjs.map +0 -1
  139. package/dist/wasm/build/swisseph.web-GPTWPXKT.js.map +0 -1
  140. package/dist/webassembly.md +0 -127
  141. package/wasm/build/swisseph-YPVN5VCI.wasm +0 -0
  142. package/wasm/build/swisseph.d.ts +0 -12
  143. package/wasm/build/swisseph.js +0 -30
  144. package/wasm/build/swisseph.wasm +0 -0
  145. package/wasm/build/webassembly.md +0 -127
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkLQX6PW35_js = require('./chunk-LQX6PW35.js');
4
- var chunkVJ6RW5H4_js = require('./chunk-VJ6RW5H4.js');
3
+ var chunk47BAJUYW_js = require('./chunk-47BAJUYW.js');
4
+ var chunkQ7YAKPBH_js = require('./chunk-Q7YAKPBH.js');
5
5
 
6
- // src/tarot/index.ts
6
+ // src/tarot/data.ts
7
7
  var DEFAULT_TAROT_TREE_ID = "kaabalah";
8
8
  var TAROT_TREE_IDS = [
9
9
  "kaabalah",
@@ -859,31 +859,6 @@ var RAW_ARKANNUS = [
859
859
  suit: "pentacles"
860
860
  }
861
861
  ];
862
- var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
863
- var shuffleArray = (array) => {
864
- const newArray = [...array];
865
- for (let i = newArray.length - 1; i > 0; i--) {
866
- const j = Math.floor(Math.random() * (i + 1));
867
- [newArray[i], newArray[j]] = [newArray[j], newArray[i]];
868
- }
869
- return newArray;
870
- };
871
- async function shuffleTarotDeck(cards, includeInvertedCards = false, shuffleCount = 6, shuffleDelay = 300) {
872
- let shuffledCards = shuffleArray([...cards]);
873
- if (includeInvertedCards) {
874
- const halfIndex = Math.floor(shuffledCards.length / 2);
875
- shuffledCards = [
876
- ...shuffledCards.slice(0, halfIndex).map((card) => ({ ...card, isInverted: true })),
877
- ...shuffledCards.slice(halfIndex)
878
- ];
879
- }
880
- for (let i = 0; i < shuffleCount; i++) {
881
- shuffledCards = shuffleArray(shuffledCards);
882
- await sleep(shuffleDelay);
883
- }
884
- return shuffledCards;
885
- }
886
- var TAROT_IMAGE_BASE_URL = "https://kaabalah-app.s3.us-east-1.amazonaws.com/tarot";
887
862
  var TAROT_DECK_METADATA = [
888
863
  {
889
864
  id: "papus_pt",
@@ -909,35 +884,17 @@ var TAROT_DECK_METADATA = [
909
884
  label: "Rider Waite"
910
885
  }
911
886
  ];
912
- var tarotArchetypeCache;
913
- var tarotCardProfileCache;
914
- function normalizePathSlug(pathSlug) {
915
- return pathSlug.trim().replace(/^\/?path\//i, "").toLowerCase();
916
- }
917
- function normalizeTarotLookupKey(value) {
918
- return value.trim().toLowerCase();
919
- }
887
+
888
+ // src/tarot/arkannus.ts
920
889
  var TAROT_TREE_PARTS = {
921
890
  kaabalah: ["tarot"]
922
891
  };
923
- var TAROT_ARK_ANNU_ID_BY_NAME = new Map(
924
- RAW_ARKANNUS.map((card) => [
925
- normalizeTarotLookupKey(card.tarotCard),
926
- chunkVJ6RW5H4_js.id("tarotArkAnnu" /* TAROT_ARK_ANNU */, card.tarotCard)
927
- ])
928
- );
929
- var TAROT_ARK_ANNU_ID_BY_FILENAME = new Map(
930
- RAW_ARKANNUS.map((card) => [
931
- normalizeTarotLookupKey(card.tarotCardFilename),
932
- chunkVJ6RW5H4_js.id("tarotArkAnnu" /* TAROT_ARK_ANNU */, card.tarotCard)
933
- ])
934
- );
935
892
  function getTarotTreeWorkspace(treeId = DEFAULT_TAROT_TREE_ID) {
936
893
  const parts = TAROT_TREE_PARTS[treeId];
937
894
  if (!parts) {
938
895
  return void 0;
939
896
  }
940
- return chunkLQX6PW35_js.getCanonicalTree({
897
+ return chunk47BAJUYW_js.getCanonicalTree({
941
898
  system: treeId,
942
899
  parts: [...parts]
943
900
  });
@@ -955,7 +912,7 @@ function getDirectTarotCardNumber(tarotArkAnnuId, treeId = DEFAULT_TAROT_TREE_ID
955
912
  if (!match) {
956
913
  return void 0;
957
914
  }
958
- return Number.parseInt(chunkVJ6RW5H4_js.parseId(match.node.id), 10);
915
+ return Number.parseInt(chunkQ7YAKPBH_js.parseId(match.node.id), 10);
959
916
  }
960
917
  function buildDefaultArkannus(cards) {
961
918
  const tree = getTarotTreeWorkspace(DEFAULT_TAROT_TREE_ID);
@@ -964,7 +921,7 @@ function buildDefaultArkannus(cards) {
964
921
  return void 0;
965
922
  }
966
923
  const match = tree.getCorrespondences(
967
- chunkVJ6RW5H4_js.id("tarotArkAnnu" /* TAROT_ARK_ANNU */, tarotCardName),
924
+ chunkQ7YAKPBH_js.id("tarotArkAnnu" /* TAROT_ARK_ANNU */, tarotCardName),
968
925
  {
969
926
  type: "number" /* NUMBER */,
970
927
  depth: 1,
@@ -974,7 +931,7 @@ function buildDefaultArkannus(cards) {
974
931
  if (!match) {
975
932
  return void 0;
976
933
  }
977
- return Number.parseInt(chunkVJ6RW5H4_js.parseId(match.node.id), 10);
934
+ return Number.parseInt(chunkQ7YAKPBH_js.parseId(match.node.id), 10);
978
935
  };
979
936
  return [...cards].map((card) => ({
980
937
  ...card,
@@ -987,577 +944,79 @@ function buildDefaultArkannus(cards) {
987
944
  });
988
945
  }
989
946
  var ARKANNUS = buildDefaultArkannus(RAW_ARKANNUS);
990
- var TAROT_COURT_RANKS = [
991
- "king",
992
- "queen",
993
- "knight",
994
- "page"
947
+
948
+ // src/tarot/spreads.ts
949
+ var TAROT_SPREAD_MINOR_RANKS = [
950
+ "ace",
951
+ "2",
952
+ "3",
953
+ "4",
954
+ "5",
955
+ "6",
956
+ "7",
957
+ "8",
958
+ "9",
959
+ "10"
995
960
  ];
996
- var MAJOR_ARCANA_CARDS = ARKANNUS.filter(
997
- (card) => card.type === "major" && majorArcana.includes(card.tarotCardFilename)
961
+ var EVENT_INNER_SLOT_KEYS = [
962
+ "inner-1",
963
+ "inner-2",
964
+ "inner-3",
965
+ "inner-4",
966
+ "inner-5",
967
+ "inner-6",
968
+ "inner-7"
969
+ ];
970
+ var TAROT_CARD_BY_NUMBER = new Map(
971
+ ARKANNUS.map((card) => [card.number, card])
998
972
  );
999
- function toTarotCardKind(card) {
1000
- if (card.type === "major") {
1001
- return "major";
1002
- }
1003
- return card.type === "minor" ? "minor" : "court";
1004
- }
1005
- function toTarotCourtRank(card) {
1006
- if (card.type !== "daat+royalship") {
1007
- return void 0;
1008
- }
1009
- const [rank] = card.tarotCardFilename.split("_");
1010
- return TAROT_COURT_RANKS.includes(rank) ? rank : void 0;
1011
- }
1012
- function toTarotAssetPathType(card) {
1013
- return card.type;
1014
- }
1015
- function buildTarotAssetPath(card) {
1016
- if (card.assetPathType === "major") {
1017
- return `major/${card.tarotCardFilename}`;
1018
- }
1019
- if (!card.suit) {
1020
- throw new Error(
1021
- `Missing suit metadata required to resolve tarot image path for ${card.tarotCardName}.`
1022
- );
1023
- }
1024
- return `${card.assetPathType}/${card.suit}/${card.tarotCardFilename}`;
1025
- }
1026
- function toAstrologyCorrespondence(node) {
1027
- return {
1028
- type: node.type,
1029
- id: node.id,
1030
- label: chunkVJ6RW5H4_js.parseId(node.id)
1031
- };
1032
- }
1033
- function getTarotCorrespondenceTree(treeId = DEFAULT_TAROT_TREE_ID) {
1034
- return chunkLQX6PW35_js.getCanonicalTree({
1035
- system: treeId,
1036
- parts: ["westernAstrology", "tarot"]
1037
- });
1038
- }
1039
- function getCorrespondenceNodes(tree, sourceId, type, depth = 1, limit) {
1040
- return tree.getCorrespondences(sourceId, {
1041
- type,
1042
- depth,
1043
- limit
1044
- }).map(({ node }) => node);
1045
- }
1046
- function getFirstCorrespondenceNode(tree, sourceId, type, depth = 1) {
1047
- return getCorrespondenceNodes(tree, sourceId, type, depth, 1)[0];
1048
- }
1049
- function toCorrespondenceNode(node) {
1050
- if (!node) {
1051
- return void 0;
1052
- }
973
+ function createEventOuterSlot(index, temporalPhase) {
1053
974
  return {
1054
- id: node.id,
1055
- label: chunkVJ6RW5H4_js.parseId(node.id)
1056
- };
1057
- }
1058
- function toUniqueCorrespondenceNodes(nodes) {
1059
- const seen = /* @__PURE__ */ new Set();
1060
- return nodes.flatMap((node) => {
1061
- const key = String(node.id);
1062
- if (seen.has(key)) {
1063
- return [];
975
+ slotKey: `outer-${index}`,
976
+ label: String(index),
977
+ order: index,
978
+ minCards: 1,
979
+ maxCards: 1,
980
+ validationRules: {
981
+ allowedTypes: ["minor", "daat+royalship"]
982
+ },
983
+ manualSelectionRules: {
984
+ allowedTypes: ["minor", "daat+royalship"]
985
+ },
986
+ drawRules: {
987
+ allowedTypes: ["minor", "daat+royalship"]
988
+ },
989
+ metadata: {
990
+ displayLabel: String(index),
991
+ groupKey: "outer",
992
+ temporalPhase
1064
993
  }
1065
- seen.add(key);
1066
- return [toCorrespondenceNode(node)];
1067
- });
1068
- }
1069
- function toTarotCorrespondenceProfileBase(card) {
1070
- return {
1071
- tarotArkAnnuId: card.tarotArkAnnuId,
1072
- tarotCardNumber: card.tarotCardNumber,
1073
- tarotCardName: card.tarotCardName,
1074
- tarotCardFilename: card.tarotCardFilename,
1075
- tarotMeaning: card.tarotMeaning,
1076
- suit: card.suit
1077
994
  };
1078
995
  }
1079
- function resolveTarotCardProfileForTree(lookup, treeId = DEFAULT_TAROT_TREE_ID) {
1080
- if ("tarotCardNumber" in lookup) {
1081
- return getTarotCardByNumber(lookup.tarotCardNumber, treeId);
1082
- }
1083
- return getTarotCardProfile(lookup);
1084
- }
1085
- function buildMajorCorrespondenceProfile(card, tree) {
1086
- const pathNode = getFirstCorrespondenceNode(
1087
- tree,
1088
- card.tarotArkAnnuId,
1089
- "path" /* PATH */
1090
- );
1091
- const hebrewLetterNode = pathNode ? getFirstCorrespondenceNode(
1092
- tree,
1093
- pathNode.id,
1094
- "hebrewLetter" /* HEBREW_LETTER */
1095
- ) : void 0;
1096
- const pathNumberNode = pathNode ? getFirstCorrespondenceNode(tree, pathNode.id, "number" /* NUMBER */) : void 0;
1097
- const pathNumber = pathNumberNode ? Number.parseInt(chunkVJ6RW5H4_js.parseId(pathNumberNode.id), 10) : Number.NaN;
1098
- const fromSphereNode = pathNode?.data?.from ? tree.getNode(pathNode.data.from) : void 0;
1099
- const toSphereNode = pathNode?.data?.to ? tree.getNode(pathNode.data.to) : void 0;
1100
- if (!pathNode || !hebrewLetterNode || !fromSphereNode || !toSphereNode || !Number.isFinite(pathNumber)) {
1101
- return void 0;
1102
- }
996
+ function createEventInnerSlot(index, label, note) {
1103
997
  return {
1104
- ...toTarotCorrespondenceProfileBase(card),
1105
- kind: "major",
1106
- correspondences: {
1107
- astrology: getCorrespondenceNodes(
1108
- tree,
1109
- pathNode.id,
1110
- [
1111
- "westernElement" /* WESTERN_ELEMENT */,
1112
- "planet" /* PLANET */,
1113
- "westernZodiacSign" /* WESTERN_ZODIAC_SIGN */
1114
- ]
1115
- ).map(
1116
- (node) => toAstrologyCorrespondence(
1117
- node
1118
- )
1119
- ),
1120
- path: {
1121
- pathId: pathNode.id,
1122
- pathNumber,
1123
- pathSlug: chunkVJ6RW5H4_js.parseId(hebrewLetterNode.id).toLowerCase(),
1124
- meaning: pathNode.data?.meaning,
1125
- hebrewLetter: toCorrespondenceNode(hebrewLetterNode),
1126
- fromSphere: toCorrespondenceNode(
1127
- fromSphereNode
1128
- ),
1129
- toSphere: toCorrespondenceNode(
1130
- toSphereNode
1131
- )
1132
- }
1133
- }
1134
- };
1135
- }
1136
- function buildCourtCorrespondenceProfile(card, tree) {
1137
- const suitNode = getFirstCorrespondenceNode(
1138
- tree,
1139
- card.tarotArkAnnuId,
1140
- "tarotSuit" /* TAROT_SUIT */
1141
- );
1142
- if (!card.courtRank) {
1143
- return void 0;
1144
- }
1145
- if (card.courtRank === "page") {
1146
- const elementNode = suitNode ? getFirstCorrespondenceNode(
1147
- tree,
1148
- suitNode.id,
1149
- "westernElement" /* WESTERN_ELEMENT */
1150
- ) : void 0;
1151
- if (!elementNode) {
1152
- return void 0;
1153
- }
1154
- return {
1155
- ...toTarotCorrespondenceProfileBase(card),
1156
- kind: "court",
1157
- courtRank: "page",
1158
- correspondences: {
1159
- element: toCorrespondenceNode(elementNode)
1160
- }
1161
- };
1162
- }
1163
- const signNode = getFirstCorrespondenceNode(
1164
- tree,
1165
- card.tarotArkAnnuId,
1166
- "westernZodiacSign" /* WESTERN_ZODIAC_SIGN */
1167
- );
1168
- if (!signNode) {
1169
- return void 0;
1170
- }
1171
- return {
1172
- ...toTarotCorrespondenceProfileBase(card),
1173
- kind: "court",
1174
- courtRank: card.courtRank,
1175
- correspondences: {
1176
- sign: toCorrespondenceNode(signNode),
1177
- planets: toUniqueCorrespondenceNodes(
1178
- getCorrespondenceNodes(
1179
- tree,
1180
- signNode.id,
1181
- "planet" /* PLANET */
1182
- )
1183
- )
1184
- }
1185
- };
1186
- }
1187
- function buildMinorCorrespondenceProfile(card, tree) {
1188
- const sphereNode = getFirstCorrespondenceNode(
1189
- tree,
1190
- card.tarotArkAnnuId,
1191
- "sphere" /* SPHERE */
1192
- );
1193
- if (!sphereNode) {
1194
- return void 0;
1195
- }
1196
- return {
1197
- ...toTarotCorrespondenceProfileBase(card),
1198
- kind: "minor",
1199
- correspondences: {
1200
- sphere: toCorrespondenceNode(sphereNode),
1201
- planets: toUniqueCorrespondenceNodes(
1202
- getCorrespondenceNodes(tree, sphereNode.id, "planet" /* PLANET */)
1203
- )
1204
- }
1205
- };
1206
- }
1207
- function buildDescriptionsByDeck(tarotArkAnnu) {
1208
- const descriptions = {};
1209
- for (const deck of TAROT_DECK_METADATA) {
1210
- if (!deck.descriptiveDataKey) {
1211
- continue;
1212
- }
1213
- const description = tarotArkAnnu.data?.descriptiveData?.[deck.descriptiveDataKey];
1214
- if (!description) {
1215
- continue;
1216
- }
1217
- descriptions[deck.id] = { ...description };
1218
- }
1219
- return descriptions;
1220
- }
1221
- function getTarotArchetypeCache() {
1222
- if (tarotArchetypeCache) {
1223
- return tarotArchetypeCache;
1224
- }
1225
- const tree = chunkLQX6PW35_js.getCanonicalTree({
1226
- system: "kaabalah",
1227
- parts: ["westernAstrology", "tarot"]
1228
- });
1229
- const archetypes = MAJOR_ARCANA_CARDS.map((card) => {
1230
- const pathId = chunkVJ6RW5H4_js.id("path" /* PATH */, card.number);
1231
- const path = tree.getNode(pathId);
1232
- const hebrewLetter = tree.getCorrespondences(pathId, {
1233
- type: "hebrewLetter" /* HEBREW_LETTER */,
1234
- limit: 1
1235
- })[0]?.node;
1236
- const tarotArkAnnu = tree.getCorrespondences(pathId, {
1237
- type: "tarotArkAnnu" /* TAROT_ARK_ANNU */,
1238
- limit: 1
1239
- })[0]?.node;
1240
- if (!path || !hebrewLetter || !tarotArkAnnu) {
1241
- throw new Error(
1242
- `Missing canonical tarot archetype metadata for ${pathId}.`
1243
- );
1244
- }
1245
- const astrology = tree.getCorrespondences(pathId, {
1246
- type: [
1247
- "westernElement" /* WESTERN_ELEMENT */,
1248
- "planet" /* PLANET */,
1249
- "westernZodiacSign" /* WESTERN_ZODIAC_SIGN */
1250
- ]
1251
- }).map(
1252
- ({ node }) => toAstrologyCorrespondence(
1253
- node
1254
- )
1255
- );
1256
- const descriptionsByDeck = buildDescriptionsByDeck(tarotArkAnnu);
1257
- return {
1258
- canonicalId: pathId,
1259
- kind: "major",
1260
- pathId,
1261
- pathNumber: card.number,
1262
- pathSlug: chunkVJ6RW5H4_js.parseId(hebrewLetter.id).toLowerCase(),
1263
- hebrewLetterId: hebrewLetter.id,
1264
- hebrewLetter: chunkVJ6RW5H4_js.parseId(hebrewLetter.id),
1265
- pathMeaning: path.data?.meaning,
1266
- tarotArkAnnuId: tarotArkAnnu.id,
1267
- tarotCardNumber: card.number,
1268
- tarotCardName: chunkVJ6RW5H4_js.parseId(tarotArkAnnu.id),
1269
- tarotCardFilename: card.tarotCardFilename,
1270
- tarotMeaning: descriptionsByDeck.papus_pt?.meaning ?? card.meaning,
1271
- astrology,
1272
- availableDeckIds: TAROT_DECK_METADATA.map((deck) => deck.id),
1273
- descriptionsByDeck
1274
- };
1275
- });
1276
- tarotArchetypeCache = {
1277
- archetypes,
1278
- byPathId: new Map(archetypes.map((archetype) => [archetype.pathId, archetype])),
1279
- byPathSlug: new Map(
1280
- archetypes.map((archetype) => [archetype.pathSlug, archetype])
1281
- ),
1282
- byTarotCardFilename: new Map(
1283
- archetypes.map((archetype) => [archetype.tarotCardFilename, archetype])
1284
- ),
1285
- byTarotCardNumber: new Map(
1286
- archetypes.map((archetype) => [archetype.tarotCardNumber, archetype])
1287
- )
1288
- };
1289
- return tarotArchetypeCache;
1290
- }
1291
- function getTarotCardProfileCache() {
1292
- if (tarotCardProfileCache) {
1293
- return tarotCardProfileCache;
1294
- }
1295
- const tree = chunkLQX6PW35_js.getCanonicalTree({
1296
- system: "kaabalah",
1297
- parts: ["westernAstrology", "tarot"]
1298
- });
1299
- const availableDeckIds = TAROT_DECK_METADATA.map((deck) => deck.id);
1300
- const profiles = ARKANNUS.map((card) => {
1301
- const tarotArkAnnuId = chunkVJ6RW5H4_js.id("tarotArkAnnu" /* TAROT_ARK_ANNU */, card.tarotCard);
1302
- const tarotArkAnnu = tree.getNode(tarotArkAnnuId);
1303
- if (!tarotArkAnnu) {
1304
- throw new Error(`Missing canonical tarot metadata for ${tarotArkAnnuId}.`);
1305
- }
1306
- const descriptionsByDeck = buildDescriptionsByDeck(tarotArkAnnu);
1307
- return {
1308
- tarotArkAnnuId,
1309
- tarotCardNumber: card.number,
1310
- tarotCardName: card.tarotCard,
1311
- tarotCardFilename: card.tarotCardFilename,
1312
- tarotMeaning: descriptionsByDeck.papus_pt?.meaning ?? card.meaning,
1313
- kind: toTarotCardKind(card),
1314
- assetPathType: toTarotAssetPathType(card),
1315
- suit: card.suit,
1316
- courtRank: toTarotCourtRank(card),
1317
- availableDeckIds,
1318
- descriptionsByDeck
1319
- };
1320
- });
1321
- tarotCardProfileCache = {
1322
- profiles,
1323
- byTarotArkAnnuId: new Map(
1324
- profiles.map((profile) => [String(profile.tarotArkAnnuId), profile])
1325
- ),
1326
- byTarotCardName: new Map(
1327
- profiles.map((profile) => [
1328
- normalizeTarotLookupKey(profile.tarotCardName),
1329
- profile
1330
- ])
1331
- ),
1332
- byTarotCardFilename: new Map(
1333
- profiles.map((profile) => [
1334
- normalizeTarotLookupKey(profile.tarotCardFilename),
1335
- profile
1336
- ])
1337
- ),
1338
- byTarotCardNumber: new Map(
1339
- profiles.map((profile) => [profile.tarotCardNumber, profile])
1340
- )
1341
- };
1342
- return tarotCardProfileCache;
1343
- }
1344
- function buildTarotRepresentation(card, deck) {
1345
- const description = card.descriptionsByDeck[deck.id];
1346
- const assetPath = buildTarotAssetPath(card);
1347
- const imageUrl = `${TAROT_IMAGE_BASE_URL}/${deck.id}/${assetPath}.jpg`;
1348
- return {
1349
- card,
1350
- archetype: card.kind === "major" ? getTarotArchetype({ tarotCardNumber: card.tarotCardNumber }) : void 0,
1351
- deck: { id: deck.id, label: deck.label },
1352
- assetPath,
1353
- imageUrl,
1354
- label: `${card.tarotCardName} - ${deck.label}`,
1355
- altText: `${card.tarotCardName} - ${deck.label}`,
1356
- cardLabel: description?.name ?? card.tarotCardName,
1357
- description
1358
- };
1359
- }
1360
- function resolveTarotArkAnnuId(lookup) {
1361
- if ("pathSlug" in lookup || "pathId" in lookup) {
1362
- return getTarotArchetype(lookup)?.tarotArkAnnuId;
1363
- }
1364
- if ("tarotArkAnnuId" in lookup) {
1365
- return lookup.tarotArkAnnuId;
1366
- }
1367
- if ("tarotCardName" in lookup) {
1368
- return TAROT_ARK_ANNU_ID_BY_NAME.get(
1369
- normalizeTarotLookupKey(lookup.tarotCardName)
1370
- );
1371
- }
1372
- if ("tarotCardFilename" in lookup) {
1373
- return TAROT_ARK_ANNU_ID_BY_FILENAME.get(
1374
- normalizeTarotLookupKey(lookup.tarotCardFilename)
1375
- );
1376
- }
1377
- return void 0;
1378
- }
1379
- function getTarotCardProfile(lookup) {
1380
- const cache = getTarotCardProfileCache();
1381
- if ("pathSlug" in lookup || "pathId" in lookup) {
1382
- const archetype = getTarotArchetype(lookup);
1383
- return archetype ? cache.byTarotCardNumber.get(archetype.tarotCardNumber) : void 0;
1384
- }
1385
- if ("tarotArkAnnuId" in lookup) {
1386
- return cache.byTarotArkAnnuId.get(String(lookup.tarotArkAnnuId));
1387
- }
1388
- if ("tarotCardName" in lookup) {
1389
- return cache.byTarotCardName.get(
1390
- normalizeTarotLookupKey(lookup.tarotCardName)
1391
- );
1392
- }
1393
- if ("tarotCardFilename" in lookup) {
1394
- return cache.byTarotCardFilename.get(
1395
- normalizeTarotLookupKey(lookup.tarotCardFilename)
1396
- );
1397
- }
1398
- return getTarotCardByNumber(lookup.tarotCardNumber);
1399
- }
1400
- function listTarotDecks() {
1401
- return TAROT_DECK_METADATA.map(({ id: id2, label }) => ({ id: id2, label }));
1402
- }
1403
- function listTarotTrees() {
1404
- return [...TAROT_TREE_IDS];
1405
- }
1406
- function getTarotCardNumber(lookup, treeId = DEFAULT_TAROT_TREE_ID) {
1407
- if ("tarotCardNumber" in lookup) {
1408
- return getTarotCardByNumber(lookup.tarotCardNumber, treeId)?.tarotCardNumber;
1409
- }
1410
- const tarotArkAnnuId = resolveTarotArkAnnuId(lookup);
1411
- if (!tarotArkAnnuId) {
1412
- return void 0;
1413
- }
1414
- return getDirectTarotCardNumber(tarotArkAnnuId, treeId);
1415
- }
1416
- function getTarotCardByNumber(cardNumber, treeId = DEFAULT_TAROT_TREE_ID) {
1417
- const tree = getTarotTreeWorkspace(treeId);
1418
- if (!tree) {
1419
- return void 0;
1420
- }
1421
- const match = tree.getCorrespondences(chunkVJ6RW5H4_js.id("number" /* NUMBER */, cardNumber), {
1422
- type: "tarotArkAnnu" /* TAROT_ARK_ANNU */,
1423
- depth: 1,
1424
- limit: 1
1425
- })[0];
1426
- if (!match) {
1427
- return void 0;
1428
- }
1429
- const profile = getTarotCardProfile({
1430
- tarotArkAnnuId: match.node.id
1431
- });
1432
- if (!profile || profile.tarotCardNumber === cardNumber) {
1433
- return profile;
1434
- }
1435
- return {
1436
- ...profile,
1437
- tarotCardNumber: cardNumber
1438
- };
1439
- }
1440
- function getTarotArchetype(lookup) {
1441
- const cache = getTarotArchetypeCache();
1442
- if ("pathSlug" in lookup) {
1443
- return cache.byPathSlug.get(normalizePathSlug(lookup.pathSlug));
1444
- }
1445
- if ("pathId" in lookup) {
1446
- return cache.byPathId.get(String(lookup.pathId));
1447
- }
1448
- if ("tarotCardFilename" in lookup) {
1449
- return cache.byTarotCardFilename.get(
1450
- lookup.tarotCardFilename.toLowerCase()
1451
- );
1452
- }
1453
- return cache.byTarotCardNumber.get(lookup.tarotCardNumber);
1454
- }
1455
- function getTarotCorrespondenceProfile(lookup, treeId = DEFAULT_TAROT_TREE_ID) {
1456
- const card = resolveTarotCardProfileForTree(lookup, treeId);
1457
- if (!card) {
1458
- return void 0;
1459
- }
1460
- const tree = getTarotCorrespondenceTree(treeId);
1461
- switch (card.kind) {
1462
- case "major":
1463
- return buildMajorCorrespondenceProfile(card, tree);
1464
- case "court":
1465
- return buildCourtCorrespondenceProfile(card, tree);
1466
- case "minor":
1467
- return buildMinorCorrespondenceProfile(card, tree);
1468
- }
1469
- }
1470
- function getTarotRepresentations(lookup) {
1471
- const card = getTarotCardProfile(lookup);
1472
- if (!card) {
1473
- return [];
1474
- }
1475
- return TAROT_DECK_METADATA.map(
1476
- (deck) => buildTarotRepresentation(card, deck)
1477
- );
1478
- }
1479
- function getTarotRepresentation(lookup, deckId) {
1480
- const card = getTarotCardProfile(lookup);
1481
- const deck = TAROT_DECK_METADATA.find((candidate) => candidate.id === deckId);
1482
- if (!card || !deck) {
1483
- return void 0;
1484
- }
1485
- return buildTarotRepresentation(card, deck);
1486
- }
1487
- function resolveTarotImageUrl(lookup, deckId) {
1488
- return getTarotRepresentation(lookup, deckId)?.imageUrl;
1489
- }
1490
- var TAROT_SPREAD_MINOR_RANKS = [
1491
- "ace",
1492
- "2",
1493
- "3",
1494
- "4",
1495
- "5",
1496
- "6",
1497
- "7",
1498
- "8",
1499
- "9",
1500
- "10"
1501
- ];
1502
- var EVENT_INNER_SLOT_KEYS = [
1503
- "inner-1",
1504
- "inner-2",
1505
- "inner-3",
1506
- "inner-4",
1507
- "inner-5",
1508
- "inner-6",
1509
- "inner-7"
1510
- ];
1511
- var TAROT_CARD_BY_NUMBER = new Map(
1512
- ARKANNUS.map((card) => [card.number, card])
1513
- );
1514
- function createEventOuterSlot(index, temporalPhase) {
1515
- return {
1516
- slotKey: `outer-${index}`,
1517
- label: String(index),
1518
- order: index,
1519
- minCards: 1,
1520
- maxCards: 1,
1521
- validationRules: {
1522
- allowedTypes: ["minor", "daat+royalship"]
1523
- },
1524
- manualSelectionRules: {
1525
- allowedTypes: ["minor", "daat+royalship"]
1526
- },
1527
- drawRules: {
1528
- allowedTypes: ["minor", "daat+royalship"]
1529
- },
1530
- metadata: {
1531
- displayLabel: String(index),
1532
- groupKey: "outer",
1533
- temporalPhase
1534
- }
1535
- };
1536
- }
1537
- function createEventInnerSlot(index, label, note) {
1538
- return {
1539
- slotKey: `inner-${index}`,
1540
- label,
1541
- order: 100 + index,
1542
- minCards: 1,
1543
- maxCards: 1,
1544
- validationRules: {
1545
- allowedTypes: ["major"]
1546
- },
1547
- manualSelectionRules: {
1548
- allowedTypes: ["major"],
1549
- excludedCardFilenames: [
1550
- "01_the_magician",
1551
- "02_the_high_priestess"
1552
- ]
1553
- },
1554
- drawRules: {
1555
- allowedTypes: ["major"]
1556
- },
1557
- metadata: {
1558
- displayLabel: `${index}.`,
1559
- groupKey: "inner",
1560
- note
998
+ slotKey: `inner-${index}`,
999
+ label,
1000
+ order: 100 + index,
1001
+ minCards: 1,
1002
+ maxCards: 1,
1003
+ validationRules: {
1004
+ allowedTypes: ["major"]
1005
+ },
1006
+ manualSelectionRules: {
1007
+ allowedTypes: ["major"],
1008
+ excludedCardFilenames: [
1009
+ "01_the_magician",
1010
+ "02_the_high_priestess"
1011
+ ]
1012
+ },
1013
+ drawRules: {
1014
+ allowedTypes: ["major"]
1015
+ },
1016
+ metadata: {
1017
+ displayLabel: `${index}.`,
1018
+ groupKey: "inner",
1019
+ note
1561
1020
  }
1562
1021
  };
1563
1022
  }
@@ -2132,435 +1591,982 @@ var TAROT_SPREADS = [
2132
1591
  note: "The querent's energy in this reading."
2133
1592
  }
2134
1593
  }
2135
- ],
2136
- specialRules: {
2137
- inquirerCard: {
2138
- slotKey: "inquirer",
2139
- sourceSlotKeys: [...EVENT_INNER_SLOT_KEYS],
2140
- cardNumbersByGender: {
2141
- man: 1,
2142
- woman: 2
2143
- }
1594
+ ],
1595
+ specialRules: {
1596
+ inquirerCard: {
1597
+ slotKey: "inquirer",
1598
+ sourceSlotKeys: [...EVENT_INNER_SLOT_KEYS],
1599
+ cardNumbersByGender: {
1600
+ man: 1,
1601
+ woman: 2
1602
+ }
1603
+ }
1604
+ }
1605
+ }
1606
+ ];
1607
+ var TAROT_SPREAD_BY_ID = new Map(
1608
+ TAROT_SPREADS.map((spread) => [spread.spreadId, spread])
1609
+ );
1610
+ function cloneCardConstraint(constraint) {
1611
+ if (!constraint) {
1612
+ return void 0;
1613
+ }
1614
+ return {
1615
+ allowedTypes: constraint.allowedTypes ? [...constraint.allowedTypes] : void 0,
1616
+ requiredRank: constraint.requiredRank,
1617
+ allowedCardFilenames: constraint.allowedCardFilenames ? [...constraint.allowedCardFilenames] : void 0,
1618
+ excludedCardFilenames: constraint.excludedCardFilenames ? [...constraint.excludedCardFilenames] : void 0
1619
+ };
1620
+ }
1621
+ function cloneSlotDefinition(slot) {
1622
+ return {
1623
+ ...slot,
1624
+ validationRules: cloneCardConstraint(slot.validationRules),
1625
+ manualSelectionRules: cloneCardConstraint(slot.manualSelectionRules),
1626
+ drawRules: cloneCardConstraint(slot.drawRules),
1627
+ metadata: slot.metadata ? { ...slot.metadata } : void 0
1628
+ };
1629
+ }
1630
+ function cloneSpreadDefinition(spread) {
1631
+ return {
1632
+ ...spread,
1633
+ contextRequirements: spread.contextRequirements ? [...spread.contextRequirements] : void 0,
1634
+ slots: spread.slots.map(cloneSlotDefinition),
1635
+ specialRules: spread.specialRules?.inquirerCard ? {
1636
+ inquirerCard: {
1637
+ slotKey: spread.specialRules.inquirerCard.slotKey,
1638
+ sourceSlotKeys: [...spread.specialRules.inquirerCard.sourceSlotKeys],
1639
+ cardNumbersByGender: {
1640
+ ...spread.specialRules.inquirerCard.cardNumbersByGender
1641
+ }
1642
+ }
1643
+ } : void 0
1644
+ };
1645
+ }
1646
+ function getTarotDeckCardByNumber(cardNumber) {
1647
+ return TAROT_CARD_BY_NUMBER.get(cardNumber);
1648
+ }
1649
+ function getTarotSpreadRuleForValidation(slot) {
1650
+ return slot.validationRules ?? slot.drawRules ?? slot.manualSelectionRules;
1651
+ }
1652
+ function getTarotSpreadRuleForDraw(slot) {
1653
+ return slot.drawRules ?? slot.validationRules ?? slot.manualSelectionRules;
1654
+ }
1655
+ function getTarotMinorRank(card) {
1656
+ if (card.type !== "minor") {
1657
+ return void 0;
1658
+ }
1659
+ const rank = card.tarotCardFilename.split("_")[0];
1660
+ return TAROT_SPREAD_MINOR_RANKS.includes(rank) ? rank : void 0;
1661
+ }
1662
+ function matchesTarotSpreadConstraint(card, constraint) {
1663
+ if (!constraint) {
1664
+ return true;
1665
+ }
1666
+ if (constraint.allowedTypes && !constraint.allowedTypes.includes(card.type)) {
1667
+ return false;
1668
+ }
1669
+ if (constraint.allowedCardFilenames && !constraint.allowedCardFilenames.includes(card.tarotCardFilename)) {
1670
+ return false;
1671
+ }
1672
+ if (constraint.excludedCardFilenames && constraint.excludedCardFilenames.includes(card.tarotCardFilename)) {
1673
+ return false;
1674
+ }
1675
+ if (constraint.requiredRank) {
1676
+ return getTarotMinorRank(card) === constraint.requiredRank;
1677
+ }
1678
+ return true;
1679
+ }
1680
+ function randomIndex(length, rng) {
1681
+ if (length <= 0) {
1682
+ throw new Error("Cannot draw from an empty pool.");
1683
+ }
1684
+ const raw = rng();
1685
+ if (!Number.isFinite(raw)) {
1686
+ throw new Error("Tarot spread RNG must return a finite number.");
1687
+ }
1688
+ const normalized = Math.min(Math.max(raw, 0), 1 - Number.EPSILON);
1689
+ return Math.floor(normalized * length);
1690
+ }
1691
+ function withSpreadCardOrientation(card, includeInverted, rng) {
1692
+ return {
1693
+ ...card,
1694
+ isInverted: includeInverted ? rng() < 0.5 : false
1695
+ };
1696
+ }
1697
+ function resolveTarotSpreadSelectionCard(card, slot, tarotCard) {
1698
+ return {
1699
+ ...card,
1700
+ slot,
1701
+ card: {
1702
+ ...tarotCard,
1703
+ isInverted: card.isInverted ?? false
1704
+ }
1705
+ };
1706
+ }
1707
+ function sortResolvedTarotSpreadCards(resolvedCards) {
1708
+ return [...resolvedCards].sort((left, right) => {
1709
+ if (left.slot.order !== right.slot.order) {
1710
+ return left.slot.order - right.slot.order;
1711
+ }
1712
+ return left.card.number - right.card.number;
1713
+ });
1714
+ }
1715
+ function validateEventInquirerCard(spread, resolvedCards, context, errors) {
1716
+ const inquirerRule = spread.specialRules?.inquirerCard;
1717
+ if (!inquirerRule) {
1718
+ return;
1719
+ }
1720
+ if (!context?.inquirerGender) {
1721
+ return;
1722
+ }
1723
+ const inquirerCardNumber = inquirerRule.cardNumbersByGender[context.inquirerGender];
1724
+ const sourceCards = resolvedCards.filter(
1725
+ (card) => inquirerRule.sourceSlotKeys.includes(card.slotKey)
1726
+ );
1727
+ const inquirerCards = resolvedCards.filter(
1728
+ (card) => card.slotKey === inquirerRule.slotKey
1729
+ );
1730
+ if (inquirerCards.length !== 1) {
1731
+ return;
1732
+ }
1733
+ const sourceContainsGenderCard = sourceCards.some(
1734
+ (card) => card.card.number === inquirerCardNumber
1735
+ );
1736
+ const totalGenderCardCount = [...sourceCards, ...inquirerCards].filter(
1737
+ (card) => card.card.number === inquirerCardNumber
1738
+ ).length;
1739
+ if (totalGenderCardCount !== 1) {
1740
+ errors.push({
1741
+ code: "INVALID_INQUIRER_CARD",
1742
+ slotKey: inquirerRule.slotKey,
1743
+ cardNumber: inquirerCardNumber,
1744
+ message: "Event Reading must contain the gendered inquirer card exactly once across the major arcana band and inquirer slot."
1745
+ });
1746
+ return;
1747
+ }
1748
+ if (!sourceContainsGenderCard && inquirerCards[0].card.number !== inquirerCardNumber) {
1749
+ errors.push({
1750
+ code: "INVALID_INQUIRER_CARD",
1751
+ slotKey: inquirerRule.slotKey,
1752
+ cardNumber: inquirerCards[0].card.number,
1753
+ message: "When the inquirer card was not drawn in the seven major slots, it must occupy the Inquirer slot."
1754
+ });
1755
+ }
1756
+ }
1757
+ function pickTarotCardFromPool(pool, constraint, rng) {
1758
+ const candidateIndexes = pool.reduce((indexes, card, index) => {
1759
+ if (matchesTarotSpreadConstraint(card, constraint)) {
1760
+ indexes.push(index);
1761
+ }
1762
+ return indexes;
1763
+ }, []);
1764
+ if (candidateIndexes.length === 0) {
1765
+ throw new Error("Unable to draw a tarot card that satisfies the spread rule.");
1766
+ }
1767
+ const pickedIndex = candidateIndexes[randomIndex(candidateIndexes.length, rng)];
1768
+ const [pickedCard] = pool.splice(pickedIndex, 1);
1769
+ return pickedCard;
1770
+ }
1771
+ function buildResolvedDrawnCard(slot, card, includeInverted, rng) {
1772
+ const drawnCard = withSpreadCardOrientation(card, includeInverted, rng);
1773
+ return {
1774
+ slotKey: slot.slotKey,
1775
+ cardNumber: drawnCard.number,
1776
+ isInverted: drawnCard.isInverted ?? false,
1777
+ slot,
1778
+ card: drawnCard
1779
+ };
1780
+ }
1781
+ function drawDefaultTarotSpread(spread, includeInverted, rng) {
1782
+ const deckPool = [...ARKANNUS];
1783
+ const drawnCards = [];
1784
+ for (const slot of spread.slots.slice().sort((left, right) => left.order - right.order)) {
1785
+ const drawRule = getTarotSpreadRuleForDraw(slot);
1786
+ for (let index = 0; index < slot.maxCards; index += 1) {
1787
+ const card = pickTarotCardFromPool(deckPool, drawRule, rng);
1788
+ drawnCards.push(
1789
+ buildResolvedDrawnCard(slot, card, includeInverted, rng)
1790
+ );
1791
+ }
1792
+ }
1793
+ return drawnCards;
1794
+ }
1795
+ function drawEventReadingSpread(spread, includeInverted, rng, context) {
1796
+ const inquirerRule = spread.specialRules?.inquirerCard;
1797
+ if (!inquirerRule || !context?.inquirerGender) {
1798
+ throw new Error(
1799
+ "Event Reading draw requires `context.inquirerGender`."
1800
+ );
1801
+ }
1802
+ const slotsByKey = new Map(
1803
+ spread.slots.map((slot) => [slot.slotKey, slot])
1804
+ );
1805
+ const outerPool = ARKANNUS.filter(
1806
+ (card) => card.type === "minor" || card.type === "daat+royalship"
1807
+ );
1808
+ const majorPool = ARKANNUS.filter((card) => card.type === "major");
1809
+ const drawnCards = [];
1810
+ for (const slot of spread.slots.filter((candidate) => candidate.metadata?.groupKey === "outer").sort((left, right) => left.order - right.order)) {
1811
+ const card = pickTarotCardFromPool(outerPool, getTarotSpreadRuleForDraw(slot), rng);
1812
+ drawnCards.push(buildResolvedDrawnCard(slot, card, includeInverted, rng));
1813
+ }
1814
+ for (const slotKey of inquirerRule.sourceSlotKeys) {
1815
+ const slot = slotsByKey.get(slotKey);
1816
+ if (!slot) {
1817
+ throw new Error(`Missing Event Reading slot definition for ${slotKey}.`);
1818
+ }
1819
+ const card = pickTarotCardFromPool(majorPool, getTarotSpreadRuleForDraw(slot), rng);
1820
+ drawnCards.push(buildResolvedDrawnCard(slot, card, includeInverted, rng));
1821
+ }
1822
+ const genderedInquirerCardNumber = inquirerRule.cardNumbersByGender[context.inquirerGender];
1823
+ const sourceContainsGenderedCard = drawnCards.some(
1824
+ (card) => inquirerRule.sourceSlotKeys.includes(card.slotKey) && card.card.number === genderedInquirerCardNumber
1825
+ );
1826
+ const inquirerSlot = slotsByKey.get(inquirerRule.slotKey);
1827
+ if (!inquirerSlot) {
1828
+ throw new Error(
1829
+ `Missing Event Reading slot definition for ${inquirerRule.slotKey}.`
1830
+ );
1831
+ }
1832
+ if (!sourceContainsGenderedCard) {
1833
+ const genderedCardIndex = majorPool.findIndex(
1834
+ (card) => card.number === genderedInquirerCardNumber
1835
+ );
1836
+ if (genderedCardIndex < 0) {
1837
+ throw new Error(
1838
+ "Unable to assign the Event Reading inquirer card from the remaining major arcana."
1839
+ );
1840
+ }
1841
+ const [genderedCard] = majorPool.splice(genderedCardIndex, 1);
1842
+ drawnCards.push(
1843
+ buildResolvedDrawnCard(inquirerSlot, genderedCard, includeInverted, rng)
1844
+ );
1845
+ } else {
1846
+ const replacement = pickTarotCardFromPool(
1847
+ majorPool,
1848
+ getTarotSpreadRuleForDraw(inquirerSlot),
1849
+ rng
1850
+ );
1851
+ drawnCards.push(
1852
+ buildResolvedDrawnCard(inquirerSlot, replacement, includeInverted, rng)
1853
+ );
1854
+ }
1855
+ return drawnCards;
1856
+ }
1857
+ function listTarotSpreads() {
1858
+ return TAROT_SPREADS.map(cloneSpreadDefinition);
1859
+ }
1860
+ function getTarotSpread(spreadId) {
1861
+ const spread = TAROT_SPREAD_BY_ID.get(spreadId);
1862
+ return spread ? cloneSpreadDefinition(spread) : void 0;
1863
+ }
1864
+ function validateTarotSpreadSelection(input) {
1865
+ const spread = TAROT_SPREAD_BY_ID.get(input.spreadId);
1866
+ const errors = [];
1867
+ if (!spread) {
1868
+ return {
1869
+ ok: false,
1870
+ isComplete: false,
1871
+ errors: [
1872
+ {
1873
+ code: "UNKNOWN_SPREAD",
1874
+ message: `Unknown tarot spread: ${input.spreadId}.`
1875
+ }
1876
+ ],
1877
+ resolvedCards: []
1878
+ };
1879
+ }
1880
+ const slotsByKey = new Map(
1881
+ spread.slots.map((slot) => [slot.slotKey, slot])
1882
+ );
1883
+ const seenCardNumbers = /* @__PURE__ */ new Set();
1884
+ const resolvedCards = [];
1885
+ for (const selectedCard of input.cards) {
1886
+ const slot = slotsByKey.get(selectedCard.slotKey);
1887
+ if (!slot) {
1888
+ errors.push({
1889
+ code: "UNKNOWN_SLOT",
1890
+ slotKey: selectedCard.slotKey,
1891
+ message: `Unknown slot for ${spread.label}: ${selectedCard.slotKey}.`
1892
+ });
1893
+ continue;
1894
+ }
1895
+ const tarotCard = getTarotDeckCardByNumber(selectedCard.cardNumber);
1896
+ if (!tarotCard) {
1897
+ errors.push({
1898
+ code: "CARD_NOT_FOUND",
1899
+ slotKey: selectedCard.slotKey,
1900
+ cardNumber: selectedCard.cardNumber,
1901
+ message: `Unknown tarot card number: ${selectedCard.cardNumber}.`
1902
+ });
1903
+ continue;
1904
+ }
1905
+ if (seenCardNumbers.has(tarotCard.number)) {
1906
+ errors.push({
1907
+ code: "DUPLICATE_CARD",
1908
+ slotKey: selectedCard.slotKey,
1909
+ cardNumber: tarotCard.number,
1910
+ message: `Tarot card ${tarotCard.number} is duplicated across the spread.`
1911
+ });
1912
+ continue;
1913
+ }
1914
+ seenCardNumbers.add(tarotCard.number);
1915
+ resolvedCards.push(
1916
+ resolveTarotSpreadSelectionCard(selectedCard, slot, tarotCard)
1917
+ );
1918
+ }
1919
+ let isComplete = true;
1920
+ for (const slot of spread.slots) {
1921
+ const slotCards = resolvedCards.filter(
1922
+ (selectedCard) => selectedCard.slotKey === slot.slotKey
1923
+ );
1924
+ if (slotCards.length < slot.minCards) {
1925
+ isComplete = false;
1926
+ if (!input.allowPartial) {
1927
+ errors.push({
1928
+ code: "MISSING_REQUIRED_CARDS",
1929
+ slotKey: slot.slotKey,
1930
+ message: `${spread.label} requires ${slot.minCards} card(s) for ${slot.label}.`
1931
+ });
1932
+ }
1933
+ }
1934
+ if (slotCards.length > slot.maxCards) {
1935
+ isComplete = false;
1936
+ errors.push({
1937
+ code: "TOO_MANY_CARDS",
1938
+ slotKey: slot.slotKey,
1939
+ message: `${spread.label} allows at most ${slot.maxCards} card(s) for ${slot.label}.`
1940
+ });
1941
+ }
1942
+ const validationRule = getTarotSpreadRuleForValidation(slot);
1943
+ for (const slotCard of slotCards) {
1944
+ if (validationRule?.allowedTypes && !validationRule.allowedTypes.includes(slotCard.card.type)) {
1945
+ errors.push({
1946
+ code: "INVALID_CARD_TYPE",
1947
+ slotKey: slot.slotKey,
1948
+ cardNumber: slotCard.card.number,
1949
+ message: `${slot.label} does not accept ${slotCard.card.type} cards.`
1950
+ });
1951
+ }
1952
+ if (validationRule?.requiredRank && getTarotMinorRank(slotCard.card) !== validationRule.requiredRank) {
1953
+ errors.push({
1954
+ code: "INVALID_CARD_RANK",
1955
+ slotKey: slot.slotKey,
1956
+ cardNumber: slotCard.card.number,
1957
+ message: `${slot.label} requires a ${validationRule.requiredRank} minor arcana card.`
1958
+ });
1959
+ }
1960
+ if (validationRule?.allowedCardFilenames && !validationRule.allowedCardFilenames.includes(slotCard.card.tarotCardFilename)) {
1961
+ errors.push({
1962
+ code: "DISALLOWED_CARD",
1963
+ slotKey: slot.slotKey,
1964
+ cardNumber: slotCard.card.number,
1965
+ message: `${slotCard.card.tarotCard} is not allowed in ${slot.label}.`
1966
+ });
1967
+ }
1968
+ if (validationRule?.excludedCardFilenames && validationRule.excludedCardFilenames.includes(slotCard.card.tarotCardFilename)) {
1969
+ errors.push({
1970
+ code: "DISALLOWED_CARD",
1971
+ slotKey: slot.slotKey,
1972
+ cardNumber: slotCard.card.number,
1973
+ message: `${slotCard.card.tarotCard} is excluded from ${slot.label}.`
1974
+ });
2144
1975
  }
2145
1976
  }
2146
1977
  }
1978
+ if (spread.contextRequirements?.includes("inquirerGender") && !input.context?.inquirerGender) {
1979
+ isComplete = false;
1980
+ errors.push({
1981
+ code: "MISSING_CONTEXT",
1982
+ message: `${spread.label} requires \`context.inquirerGender\`.`
1983
+ });
1984
+ }
1985
+ validateEventInquirerCard(spread, resolvedCards, input.context, errors);
1986
+ const sortedResolvedCards = sortResolvedTarotSpreadCards(resolvedCards);
1987
+ return {
1988
+ ok: errors.length === 0,
1989
+ isComplete,
1990
+ spread: cloneSpreadDefinition(spread),
1991
+ resolvedCards: sortedResolvedCards,
1992
+ errors
1993
+ };
1994
+ }
1995
+ function drawTarotSpread(options) {
1996
+ const spread = TAROT_SPREAD_BY_ID.get(options.spreadId);
1997
+ if (!spread) {
1998
+ throw new Error(`Unknown tarot spread: ${options.spreadId}.`);
1999
+ }
2000
+ const rng = options.rng ?? Math.random;
2001
+ const includeInverted = options.includeInverted ?? false;
2002
+ const drawnCards = spread.spreadId === "event-reading" ? drawEventReadingSpread(spread, includeInverted, rng, options.context) : drawDefaultTarotSpread(spread, includeInverted, rng);
2003
+ const validation = validateTarotSpreadSelection({
2004
+ spreadId: spread.spreadId,
2005
+ cards: drawnCards.map((card) => ({
2006
+ slotKey: card.slotKey,
2007
+ cardNumber: card.cardNumber,
2008
+ isInverted: card.isInverted
2009
+ })),
2010
+ context: options.context
2011
+ });
2012
+ if (!validation.ok) {
2013
+ throw new Error(
2014
+ `Generated an invalid tarot spread selection for ${spread.label}: ${validation.errors.map((error) => error.message).join(" ")}`
2015
+ );
2016
+ }
2017
+ return {
2018
+ spread: cloneSpreadDefinition(spread),
2019
+ deckId: options.deckId ?? "rider-waite",
2020
+ context: options.context,
2021
+ cards: sortResolvedTarotSpreadCards(drawnCards)
2022
+ };
2023
+ }
2024
+
2025
+ // src/tarot/index.ts
2026
+ var sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
2027
+ var shuffleArray = (array, rng = Math.random) => {
2028
+ const newArray = [...array];
2029
+ for (let i = newArray.length - 1; i > 0; i--) {
2030
+ const j = Math.floor(rng() * (i + 1));
2031
+ [newArray[i], newArray[j]] = [newArray[j], newArray[i]];
2032
+ }
2033
+ return newArray;
2034
+ };
2035
+ async function shuffleTarotDeck(cards, includeInvertedCards = false, shuffleCount = 6, shuffleDelay = 300, rng = Math.random) {
2036
+ let shuffledCards = shuffleArray([...cards], rng);
2037
+ if (includeInvertedCards) {
2038
+ const halfIndex = Math.floor(shuffledCards.length / 2);
2039
+ shuffledCards = [
2040
+ ...shuffledCards.slice(0, halfIndex).map((card) => ({ ...card, isInverted: true })),
2041
+ ...shuffledCards.slice(halfIndex)
2042
+ ];
2043
+ }
2044
+ for (let i = 0; i < shuffleCount; i++) {
2045
+ shuffledCards = shuffleArray(shuffledCards, rng);
2046
+ await sleep(shuffleDelay);
2047
+ }
2048
+ return shuffledCards;
2049
+ }
2050
+ var TAROT_IMAGE_BASE_URL = "https://kaabalah-app.s3.us-east-1.amazonaws.com/tarot";
2051
+ var tarotArchetypeCache;
2052
+ var tarotCardProfileCache;
2053
+ function normalizePathSlug(pathSlug) {
2054
+ return pathSlug.trim().replace(/^\/?path\//i, "").toLowerCase();
2055
+ }
2056
+ function normalizeTarotLookupKey(value) {
2057
+ return value.trim().toLowerCase();
2058
+ }
2059
+ var TAROT_ARK_ANNU_ID_BY_NAME = new Map(
2060
+ ARKANNUS.map((card) => [
2061
+ normalizeTarotLookupKey(card.tarotCard),
2062
+ chunkQ7YAKPBH_js.id("tarotArkAnnu" /* TAROT_ARK_ANNU */, card.tarotCard)
2063
+ ])
2064
+ );
2065
+ var TAROT_ARK_ANNU_ID_BY_FILENAME = new Map(
2066
+ ARKANNUS.map((card) => [
2067
+ normalizeTarotLookupKey(card.tarotCardFilename),
2068
+ chunkQ7YAKPBH_js.id("tarotArkAnnu" /* TAROT_ARK_ANNU */, card.tarotCard)
2069
+ ])
2070
+ );
2071
+ var TAROT_COURT_RANKS = [
2072
+ "king",
2073
+ "queen",
2074
+ "knight",
2075
+ "page"
2147
2076
  ];
2148
- var TAROT_SPREAD_BY_ID = new Map(
2149
- TAROT_SPREADS.map((spread) => [spread.spreadId, spread])
2077
+ var MAJOR_ARCANA_CARDS = ARKANNUS.filter(
2078
+ (card) => card.type === "major" && majorArcana.includes(card.tarotCardFilename)
2150
2079
  );
2151
- function cloneCardConstraint(constraint) {
2152
- if (!constraint) {
2080
+ function toTarotCardKind(card) {
2081
+ if (card.type === "major") {
2082
+ return "major";
2083
+ }
2084
+ return card.type === "minor" ? "minor" : "court";
2085
+ }
2086
+ function toTarotCourtRank(card) {
2087
+ if (card.type !== "daat+royalship") {
2153
2088
  return void 0;
2154
2089
  }
2155
- return {
2156
- allowedTypes: constraint.allowedTypes ? [...constraint.allowedTypes] : void 0,
2157
- requiredRank: constraint.requiredRank,
2158
- allowedCardFilenames: constraint.allowedCardFilenames ? [...constraint.allowedCardFilenames] : void 0,
2159
- excludedCardFilenames: constraint.excludedCardFilenames ? [...constraint.excludedCardFilenames] : void 0
2160
- };
2090
+ const [rank] = card.tarotCardFilename.split("_");
2091
+ return TAROT_COURT_RANKS.includes(rank) ? rank : void 0;
2161
2092
  }
2162
- function cloneSlotDefinition(slot) {
2163
- return {
2164
- ...slot,
2165
- validationRules: cloneCardConstraint(slot.validationRules),
2166
- manualSelectionRules: cloneCardConstraint(slot.manualSelectionRules),
2167
- drawRules: cloneCardConstraint(slot.drawRules),
2168
- metadata: slot.metadata ? { ...slot.metadata } : void 0
2169
- };
2093
+ function toTarotAssetPathType(card) {
2094
+ return card.type;
2170
2095
  }
2171
- function cloneSpreadDefinition(spread) {
2096
+ function buildTarotAssetPath(card) {
2097
+ if (card.assetPathType === "major") {
2098
+ return `major/${card.tarotCardFilename}`;
2099
+ }
2100
+ if (!card.suit) {
2101
+ throw new Error(
2102
+ `Missing suit metadata required to resolve tarot image path for ${card.tarotCardName}.`
2103
+ );
2104
+ }
2105
+ return `${card.assetPathType}/${card.suit}/${card.tarotCardFilename}`;
2106
+ }
2107
+ function toAstrologyCorrespondence(node) {
2172
2108
  return {
2173
- ...spread,
2174
- contextRequirements: spread.contextRequirements ? [...spread.contextRequirements] : void 0,
2175
- slots: spread.slots.map(cloneSlotDefinition),
2176
- specialRules: spread.specialRules?.inquirerCard ? {
2177
- inquirerCard: {
2178
- slotKey: spread.specialRules.inquirerCard.slotKey,
2179
- sourceSlotKeys: [...spread.specialRules.inquirerCard.sourceSlotKeys],
2180
- cardNumbersByGender: {
2181
- ...spread.specialRules.inquirerCard.cardNumbersByGender
2182
- }
2183
- }
2184
- } : void 0
2109
+ type: node.type,
2110
+ id: node.id,
2111
+ label: chunkQ7YAKPBH_js.parseId(node.id)
2185
2112
  };
2186
2113
  }
2187
- function getTarotDeckCardByNumber(cardNumber) {
2188
- return TAROT_CARD_BY_NUMBER.get(cardNumber);
2114
+ function getTarotCorrespondenceTree(treeId = DEFAULT_TAROT_TREE_ID) {
2115
+ return chunk47BAJUYW_js.getCanonicalTree({
2116
+ system: treeId,
2117
+ parts: ["westernAstrology", "tarot"]
2118
+ });
2189
2119
  }
2190
- function getTarotSpreadRuleForValidation(slot) {
2191
- return slot.validationRules ?? slot.drawRules ?? slot.manualSelectionRules;
2120
+ function getCorrespondenceNodes(tree, sourceId, type, depth = 1, limit) {
2121
+ return tree.getCorrespondences(sourceId, {
2122
+ type,
2123
+ depth,
2124
+ limit
2125
+ }).map(({ node }) => node);
2192
2126
  }
2193
- function getTarotSpreadRuleForDraw(slot) {
2194
- return slot.drawRules ?? slot.validationRules ?? slot.manualSelectionRules;
2127
+ function getFirstCorrespondenceNode(tree, sourceId, type, depth = 1) {
2128
+ return getCorrespondenceNodes(tree, sourceId, type, depth, 1)[0];
2195
2129
  }
2196
- function getTarotMinorRank(card) {
2197
- if (card.type !== "minor") {
2130
+ function toCorrespondenceNode(node) {
2131
+ if (!node) {
2198
2132
  return void 0;
2199
2133
  }
2200
- const rank = card.tarotCardFilename.split("_")[0];
2201
- return TAROT_SPREAD_MINOR_RANKS.includes(rank) ? rank : void 0;
2202
- }
2203
- function matchesTarotSpreadConstraint(card, constraint) {
2204
- if (!constraint) {
2205
- return true;
2206
- }
2207
- if (constraint.allowedTypes && !constraint.allowedTypes.includes(card.type)) {
2208
- return false;
2209
- }
2210
- if (constraint.allowedCardFilenames && !constraint.allowedCardFilenames.includes(card.tarotCardFilename)) {
2211
- return false;
2212
- }
2213
- if (constraint.excludedCardFilenames && constraint.excludedCardFilenames.includes(card.tarotCardFilename)) {
2214
- return false;
2215
- }
2216
- if (constraint.requiredRank) {
2217
- return getTarotMinorRank(card) === constraint.requiredRank;
2218
- }
2219
- return true;
2134
+ return {
2135
+ id: node.id,
2136
+ label: chunkQ7YAKPBH_js.parseId(node.id)
2137
+ };
2220
2138
  }
2221
- function randomIndex(length, rng) {
2222
- if (length <= 0) {
2223
- throw new Error("Cannot draw from an empty pool.");
2224
- }
2225
- const raw = rng();
2226
- if (!Number.isFinite(raw)) {
2227
- throw new Error("Tarot spread RNG must return a finite number.");
2228
- }
2229
- const normalized = Math.min(Math.max(raw, 0), 1 - Number.EPSILON);
2230
- return Math.floor(normalized * length);
2139
+ function toUniqueCorrespondenceNodes(nodes) {
2140
+ const seen = /* @__PURE__ */ new Set();
2141
+ return nodes.flatMap((node) => {
2142
+ const key = String(node.id);
2143
+ if (seen.has(key)) {
2144
+ return [];
2145
+ }
2146
+ seen.add(key);
2147
+ return [toCorrespondenceNode(node)];
2148
+ });
2231
2149
  }
2232
- function withSpreadCardOrientation(card, includeInverted, rng) {
2150
+ function toTarotCorrespondenceProfileBase(card) {
2233
2151
  return {
2234
- ...card,
2235
- isInverted: includeInverted ? rng() < 0.5 : false
2152
+ tarotArkAnnuId: card.tarotArkAnnuId,
2153
+ tarotCardNumber: card.tarotCardNumber,
2154
+ tarotCardName: card.tarotCardName,
2155
+ tarotCardFilename: card.tarotCardFilename,
2156
+ tarotMeaning: card.tarotMeaning,
2157
+ suit: card.suit
2236
2158
  };
2237
2159
  }
2238
- function resolveTarotSpreadSelectionCard(card, slot, tarotCard) {
2160
+ function resolveTarotCardProfileForTree(lookup, treeId = DEFAULT_TAROT_TREE_ID) {
2161
+ if ("tarotCardNumber" in lookup) {
2162
+ return getTarotCardByNumber(lookup.tarotCardNumber, treeId);
2163
+ }
2164
+ return getTarotCardProfile(lookup);
2165
+ }
2166
+ function buildMajorCorrespondenceProfile(card, tree) {
2167
+ const pathNode = getFirstCorrespondenceNode(
2168
+ tree,
2169
+ card.tarotArkAnnuId,
2170
+ "path" /* PATH */
2171
+ );
2172
+ const hebrewLetterNode = pathNode ? getFirstCorrespondenceNode(
2173
+ tree,
2174
+ pathNode.id,
2175
+ "hebrewLetter" /* HEBREW_LETTER */
2176
+ ) : void 0;
2177
+ const pathNumberNode = pathNode ? getFirstCorrespondenceNode(tree, pathNode.id, "number" /* NUMBER */) : void 0;
2178
+ const pathNumber = pathNumberNode ? Number.parseInt(chunkQ7YAKPBH_js.parseId(pathNumberNode.id), 10) : Number.NaN;
2179
+ const fromSphereNode = pathNode?.data?.from ? tree.getNode(pathNode.data.from) : void 0;
2180
+ const toSphereNode = pathNode?.data?.to ? tree.getNode(pathNode.data.to) : void 0;
2181
+ if (!pathNode || !hebrewLetterNode || !fromSphereNode || !toSphereNode || !Number.isFinite(pathNumber)) {
2182
+ return void 0;
2183
+ }
2239
2184
  return {
2240
- ...card,
2241
- slot,
2242
- card: {
2243
- ...tarotCard,
2244
- isInverted: card.isInverted ?? false
2185
+ ...toTarotCorrespondenceProfileBase(card),
2186
+ kind: "major",
2187
+ correspondences: {
2188
+ astrology: getCorrespondenceNodes(
2189
+ tree,
2190
+ pathNode.id,
2191
+ [
2192
+ "westernElement" /* WESTERN_ELEMENT */,
2193
+ "planet" /* PLANET */,
2194
+ "westernZodiacSign" /* WESTERN_ZODIAC_SIGN */
2195
+ ]
2196
+ ).map(
2197
+ (node) => toAstrologyCorrespondence(
2198
+ node
2199
+ )
2200
+ ),
2201
+ path: {
2202
+ pathId: pathNode.id,
2203
+ pathNumber,
2204
+ pathSlug: chunkQ7YAKPBH_js.parseId(hebrewLetterNode.id).toLowerCase(),
2205
+ meaning: pathNode.data?.meaning,
2206
+ hebrewLetter: toCorrespondenceNode(hebrewLetterNode),
2207
+ fromSphere: toCorrespondenceNode(
2208
+ fromSphereNode
2209
+ ),
2210
+ toSphere: toCorrespondenceNode(
2211
+ toSphereNode
2212
+ )
2213
+ }
2245
2214
  }
2246
2215
  };
2247
2216
  }
2248
- function sortResolvedTarotSpreadCards(resolvedCards) {
2249
- return [...resolvedCards].sort((left, right) => {
2250
- if (left.slot.order !== right.slot.order) {
2251
- return left.slot.order - right.slot.order;
2252
- }
2253
- return left.card.number - right.card.number;
2254
- });
2255
- }
2256
- function validateEventInquirerCard(spread, resolvedCards, context, errors) {
2257
- const inquirerRule = spread.specialRules?.inquirerCard;
2258
- if (!inquirerRule) {
2259
- return;
2217
+ function buildCourtCorrespondenceProfile(card, tree) {
2218
+ const suitNode = getFirstCorrespondenceNode(
2219
+ tree,
2220
+ card.tarotArkAnnuId,
2221
+ "tarotSuit" /* TAROT_SUIT */
2222
+ );
2223
+ if (!card.courtRank) {
2224
+ return void 0;
2260
2225
  }
2261
- if (!context?.inquirerGender) {
2262
- return;
2226
+ if (card.courtRank === "page") {
2227
+ const elementNode = suitNode ? getFirstCorrespondenceNode(
2228
+ tree,
2229
+ suitNode.id,
2230
+ "westernElement" /* WESTERN_ELEMENT */
2231
+ ) : void 0;
2232
+ if (!elementNode) {
2233
+ return void 0;
2234
+ }
2235
+ return {
2236
+ ...toTarotCorrespondenceProfileBase(card),
2237
+ kind: "court",
2238
+ courtRank: "page",
2239
+ correspondences: {
2240
+ element: toCorrespondenceNode(elementNode)
2241
+ }
2242
+ };
2263
2243
  }
2264
- const inquirerCardNumber = inquirerRule.cardNumbersByGender[context.inquirerGender];
2265
- const sourceCards = resolvedCards.filter(
2266
- (card) => inquirerRule.sourceSlotKeys.includes(card.slotKey)
2267
- );
2268
- const inquirerCards = resolvedCards.filter(
2269
- (card) => card.slotKey === inquirerRule.slotKey
2244
+ const signNode = getFirstCorrespondenceNode(
2245
+ tree,
2246
+ card.tarotArkAnnuId,
2247
+ "westernZodiacSign" /* WESTERN_ZODIAC_SIGN */
2270
2248
  );
2271
- if (inquirerCards.length !== 1) {
2272
- return;
2249
+ if (!signNode) {
2250
+ return void 0;
2273
2251
  }
2274
- const sourceContainsGenderCard = sourceCards.some(
2275
- (card) => card.card.number === inquirerCardNumber
2276
- );
2277
- const totalGenderCardCount = [...sourceCards, ...inquirerCards].filter(
2278
- (card) => card.card.number === inquirerCardNumber
2279
- ).length;
2280
- if (totalGenderCardCount !== 1) {
2281
- errors.push({
2282
- code: "INVALID_INQUIRER_CARD",
2283
- slotKey: inquirerRule.slotKey,
2284
- cardNumber: inquirerCardNumber,
2285
- message: "Event Reading must contain the gendered inquirer card exactly once across the major arcana band and inquirer slot."
2286
- });
2287
- return;
2252
+ return {
2253
+ ...toTarotCorrespondenceProfileBase(card),
2254
+ kind: "court",
2255
+ courtRank: card.courtRank,
2256
+ correspondences: {
2257
+ sign: toCorrespondenceNode(signNode),
2258
+ planets: toUniqueCorrespondenceNodes(
2259
+ getCorrespondenceNodes(
2260
+ tree,
2261
+ signNode.id,
2262
+ "planet" /* PLANET */
2263
+ )
2264
+ )
2265
+ }
2266
+ };
2267
+ }
2268
+ function buildMinorCorrespondenceProfile(card, tree) {
2269
+ const sphereNode = getFirstCorrespondenceNode(
2270
+ tree,
2271
+ card.tarotArkAnnuId,
2272
+ "sphere" /* SPHERE */
2273
+ );
2274
+ if (!sphereNode) {
2275
+ return void 0;
2288
2276
  }
2289
- if (!sourceContainsGenderCard && inquirerCards[0].card.number !== inquirerCardNumber) {
2290
- errors.push({
2291
- code: "INVALID_INQUIRER_CARD",
2292
- slotKey: inquirerRule.slotKey,
2293
- cardNumber: inquirerCards[0].card.number,
2294
- message: "When the inquirer card was not drawn in the seven major slots, it must occupy the Inquirer slot."
2295
- });
2277
+ return {
2278
+ ...toTarotCorrespondenceProfileBase(card),
2279
+ kind: "minor",
2280
+ correspondences: {
2281
+ sphere: toCorrespondenceNode(sphereNode),
2282
+ planets: toUniqueCorrespondenceNodes(
2283
+ getCorrespondenceNodes(tree, sphereNode.id, "planet" /* PLANET */)
2284
+ )
2285
+ }
2286
+ };
2287
+ }
2288
+ function buildDescriptionsByDeck(tarotArkAnnu) {
2289
+ const descriptions = {};
2290
+ for (const deck of TAROT_DECK_METADATA) {
2291
+ if (!deck.descriptiveDataKey) {
2292
+ continue;
2293
+ }
2294
+ const description = tarotArkAnnu.data?.descriptiveData?.[deck.descriptiveDataKey];
2295
+ if (!description) {
2296
+ continue;
2297
+ }
2298
+ descriptions[deck.id] = { ...description };
2296
2299
  }
2300
+ return descriptions;
2297
2301
  }
2298
- function pickTarotCardFromPool(pool, constraint, rng) {
2299
- const candidateIndexes = pool.reduce((indexes, card, index) => {
2300
- if (matchesTarotSpreadConstraint(card, constraint)) {
2301
- indexes.push(index);
2302
+ function getTarotArchetypeCache() {
2303
+ if (tarotArchetypeCache) {
2304
+ return tarotArchetypeCache;
2305
+ }
2306
+ const tree = chunk47BAJUYW_js.getCanonicalTree({
2307
+ system: "kaabalah",
2308
+ parts: ["westernAstrology", "tarot"]
2309
+ });
2310
+ const archetypes = MAJOR_ARCANA_CARDS.map((card) => {
2311
+ const pathId = chunkQ7YAKPBH_js.id("path" /* PATH */, card.number);
2312
+ const path = tree.getNode(pathId);
2313
+ const hebrewLetter = tree.getCorrespondences(pathId, {
2314
+ type: "hebrewLetter" /* HEBREW_LETTER */,
2315
+ limit: 1
2316
+ })[0]?.node;
2317
+ const tarotArkAnnu = tree.getCorrespondences(pathId, {
2318
+ type: "tarotArkAnnu" /* TAROT_ARK_ANNU */,
2319
+ limit: 1
2320
+ })[0]?.node;
2321
+ if (!path || !hebrewLetter || !tarotArkAnnu) {
2322
+ throw new Error(
2323
+ `Missing canonical tarot archetype metadata for ${pathId}.`
2324
+ );
2302
2325
  }
2303
- return indexes;
2304
- }, []);
2305
- if (candidateIndexes.length === 0) {
2306
- throw new Error("Unable to draw a tarot card that satisfies the spread rule.");
2326
+ const astrology = tree.getCorrespondences(pathId, {
2327
+ type: [
2328
+ "westernElement" /* WESTERN_ELEMENT */,
2329
+ "planet" /* PLANET */,
2330
+ "westernZodiacSign" /* WESTERN_ZODIAC_SIGN */
2331
+ ]
2332
+ }).map(
2333
+ ({ node }) => toAstrologyCorrespondence(
2334
+ node
2335
+ )
2336
+ );
2337
+ const descriptionsByDeck = buildDescriptionsByDeck(tarotArkAnnu);
2338
+ return {
2339
+ canonicalId: pathId,
2340
+ kind: "major",
2341
+ pathId,
2342
+ pathNumber: card.number,
2343
+ pathSlug: chunkQ7YAKPBH_js.parseId(hebrewLetter.id).toLowerCase(),
2344
+ hebrewLetterId: hebrewLetter.id,
2345
+ hebrewLetter: chunkQ7YAKPBH_js.parseId(hebrewLetter.id),
2346
+ pathMeaning: path.data?.meaning,
2347
+ tarotArkAnnuId: tarotArkAnnu.id,
2348
+ tarotCardNumber: card.number,
2349
+ tarotCardName: chunkQ7YAKPBH_js.parseId(tarotArkAnnu.id),
2350
+ tarotCardFilename: card.tarotCardFilename,
2351
+ tarotMeaning: descriptionsByDeck.papus_pt?.meaning ?? card.meaning,
2352
+ astrology,
2353
+ availableDeckIds: TAROT_DECK_METADATA.map((deck) => deck.id),
2354
+ descriptionsByDeck
2355
+ };
2356
+ });
2357
+ tarotArchetypeCache = {
2358
+ archetypes,
2359
+ byPathId: new Map(archetypes.map((archetype) => [archetype.pathId, archetype])),
2360
+ byPathSlug: new Map(
2361
+ archetypes.map((archetype) => [archetype.pathSlug, archetype])
2362
+ ),
2363
+ byTarotCardFilename: new Map(
2364
+ archetypes.map((archetype) => [archetype.tarotCardFilename, archetype])
2365
+ ),
2366
+ byTarotCardNumber: new Map(
2367
+ archetypes.map((archetype) => [archetype.tarotCardNumber, archetype])
2368
+ )
2369
+ };
2370
+ return tarotArchetypeCache;
2371
+ }
2372
+ function getTarotCardProfileCache() {
2373
+ if (tarotCardProfileCache) {
2374
+ return tarotCardProfileCache;
2307
2375
  }
2308
- const pickedIndex = candidateIndexes[randomIndex(candidateIndexes.length, rng)];
2309
- const [pickedCard] = pool.splice(pickedIndex, 1);
2310
- return pickedCard;
2376
+ const tree = chunk47BAJUYW_js.getCanonicalTree({
2377
+ system: "kaabalah",
2378
+ parts: ["westernAstrology", "tarot"]
2379
+ });
2380
+ const availableDeckIds = TAROT_DECK_METADATA.map((deck) => deck.id);
2381
+ const profiles = ARKANNUS.map((card) => {
2382
+ const tarotArkAnnuId = chunkQ7YAKPBH_js.id("tarotArkAnnu" /* TAROT_ARK_ANNU */, card.tarotCard);
2383
+ const tarotArkAnnu = tree.getNode(tarotArkAnnuId);
2384
+ if (!tarotArkAnnu) {
2385
+ throw new Error(`Missing canonical tarot metadata for ${tarotArkAnnuId}.`);
2386
+ }
2387
+ const descriptionsByDeck = buildDescriptionsByDeck(tarotArkAnnu);
2388
+ return {
2389
+ tarotArkAnnuId,
2390
+ tarotCardNumber: card.number,
2391
+ tarotCardName: card.tarotCard,
2392
+ tarotCardFilename: card.tarotCardFilename,
2393
+ tarotMeaning: descriptionsByDeck.papus_pt?.meaning ?? card.meaning,
2394
+ kind: toTarotCardKind(card),
2395
+ assetPathType: toTarotAssetPathType(card),
2396
+ suit: card.suit,
2397
+ courtRank: toTarotCourtRank(card),
2398
+ availableDeckIds,
2399
+ descriptionsByDeck
2400
+ };
2401
+ });
2402
+ tarotCardProfileCache = {
2403
+ profiles,
2404
+ byTarotArkAnnuId: new Map(
2405
+ profiles.map((profile) => [String(profile.tarotArkAnnuId), profile])
2406
+ ),
2407
+ byTarotCardName: new Map(
2408
+ profiles.map((profile) => [
2409
+ normalizeTarotLookupKey(profile.tarotCardName),
2410
+ profile
2411
+ ])
2412
+ ),
2413
+ byTarotCardFilename: new Map(
2414
+ profiles.map((profile) => [
2415
+ normalizeTarotLookupKey(profile.tarotCardFilename),
2416
+ profile
2417
+ ])
2418
+ ),
2419
+ byTarotCardNumber: new Map(
2420
+ profiles.map((profile) => [profile.tarotCardNumber, profile])
2421
+ )
2422
+ };
2423
+ return tarotCardProfileCache;
2311
2424
  }
2312
- function buildResolvedDrawnCard(slot, card, includeInverted, rng) {
2313
- const drawnCard = withSpreadCardOrientation(card, includeInverted, rng);
2425
+ function buildTarotRepresentation(card, deck) {
2426
+ const description = card.descriptionsByDeck[deck.id];
2427
+ const assetPath = buildTarotAssetPath(card);
2428
+ const imageUrl = `${TAROT_IMAGE_BASE_URL}/${deck.id}/${assetPath}.jpg`;
2314
2429
  return {
2315
- slotKey: slot.slotKey,
2316
- cardNumber: drawnCard.number,
2317
- isInverted: drawnCard.isInverted ?? false,
2318
- slot,
2319
- card: drawnCard
2430
+ card,
2431
+ archetype: card.kind === "major" ? getTarotArchetype({ tarotCardNumber: card.tarotCardNumber }) : void 0,
2432
+ deck: { id: deck.id, label: deck.label },
2433
+ assetPath,
2434
+ imageUrl,
2435
+ label: `${card.tarotCardName} - ${deck.label}`,
2436
+ altText: `${card.tarotCardName} - ${deck.label}`,
2437
+ cardLabel: description?.name ?? card.tarotCardName,
2438
+ description
2320
2439
  };
2321
2440
  }
2322
- function drawDefaultTarotSpread(spread, includeInverted, rng) {
2323
- const deckPool = [...ARKANNUS];
2324
- const drawnCards = [];
2325
- for (const slot of spread.slots.slice().sort((left, right) => left.order - right.order)) {
2326
- const drawRule = getTarotSpreadRuleForDraw(slot);
2327
- for (let index = 0; index < slot.maxCards; index += 1) {
2328
- const card = pickTarotCardFromPool(deckPool, drawRule, rng);
2329
- drawnCards.push(
2330
- buildResolvedDrawnCard(slot, card, includeInverted, rng)
2331
- );
2332
- }
2441
+ function resolveTarotArkAnnuId(lookup) {
2442
+ if ("pathSlug" in lookup || "pathId" in lookup) {
2443
+ return getTarotArchetype(lookup)?.tarotArkAnnuId;
2333
2444
  }
2334
- return drawnCards;
2335
- }
2336
- function drawEventReadingSpread(spread, includeInverted, rng, context) {
2337
- const inquirerRule = spread.specialRules?.inquirerCard;
2338
- if (!inquirerRule || !context?.inquirerGender) {
2339
- throw new Error(
2340
- "Event Reading draw requires `context.inquirerGender`."
2445
+ if ("tarotArkAnnuId" in lookup) {
2446
+ return lookup.tarotArkAnnuId;
2447
+ }
2448
+ if ("tarotCardName" in lookup) {
2449
+ return TAROT_ARK_ANNU_ID_BY_NAME.get(
2450
+ normalizeTarotLookupKey(lookup.tarotCardName)
2341
2451
  );
2342
2452
  }
2343
- const slotsByKey = new Map(
2344
- spread.slots.map((slot) => [slot.slotKey, slot])
2345
- );
2346
- const outerPool = ARKANNUS.filter(
2347
- (card) => card.type === "minor" || card.type === "daat+royalship"
2348
- );
2349
- const majorPool = ARKANNUS.filter((card) => card.type === "major");
2350
- const drawnCards = [];
2351
- for (const slot of spread.slots.filter((candidate) => candidate.metadata?.groupKey === "outer").sort((left, right) => left.order - right.order)) {
2352
- const card = pickTarotCardFromPool(outerPool, getTarotSpreadRuleForDraw(slot), rng);
2353
- drawnCards.push(buildResolvedDrawnCard(slot, card, includeInverted, rng));
2453
+ if ("tarotCardFilename" in lookup) {
2454
+ return TAROT_ARK_ANNU_ID_BY_FILENAME.get(
2455
+ normalizeTarotLookupKey(lookup.tarotCardFilename)
2456
+ );
2354
2457
  }
2355
- for (const slotKey of inquirerRule.sourceSlotKeys) {
2356
- const slot = slotsByKey.get(slotKey);
2357
- if (!slot) {
2358
- throw new Error(`Missing Event Reading slot definition for ${slotKey}.`);
2359
- }
2360
- const card = pickTarotCardFromPool(majorPool, getTarotSpreadRuleForDraw(slot), rng);
2361
- drawnCards.push(buildResolvedDrawnCard(slot, card, includeInverted, rng));
2458
+ return void 0;
2459
+ }
2460
+ function getTarotCardProfile(lookup) {
2461
+ const cache = getTarotCardProfileCache();
2462
+ if ("pathSlug" in lookup || "pathId" in lookup) {
2463
+ const archetype = getTarotArchetype(lookup);
2464
+ return archetype ? cache.byTarotCardNumber.get(archetype.tarotCardNumber) : void 0;
2362
2465
  }
2363
- const genderedInquirerCardNumber = inquirerRule.cardNumbersByGender[context.inquirerGender];
2364
- const sourceContainsGenderedCard = drawnCards.some(
2365
- (card) => inquirerRule.sourceSlotKeys.includes(card.slotKey) && card.card.number === genderedInquirerCardNumber
2366
- );
2367
- const inquirerSlot = slotsByKey.get(inquirerRule.slotKey);
2368
- if (!inquirerSlot) {
2369
- throw new Error(
2370
- `Missing Event Reading slot definition for ${inquirerRule.slotKey}.`
2466
+ if ("tarotArkAnnuId" in lookup) {
2467
+ return cache.byTarotArkAnnuId.get(String(lookup.tarotArkAnnuId));
2468
+ }
2469
+ if ("tarotCardName" in lookup) {
2470
+ return cache.byTarotCardName.get(
2471
+ normalizeTarotLookupKey(lookup.tarotCardName)
2371
2472
  );
2372
2473
  }
2373
- if (!sourceContainsGenderedCard) {
2374
- const genderedCardIndex = majorPool.findIndex(
2375
- (card) => card.number === genderedInquirerCardNumber
2376
- );
2377
- if (genderedCardIndex < 0) {
2378
- throw new Error(
2379
- "Unable to assign the Event Reading inquirer card from the remaining major arcana."
2380
- );
2381
- }
2382
- const [genderedCard] = majorPool.splice(genderedCardIndex, 1);
2383
- drawnCards.push(
2384
- buildResolvedDrawnCard(inquirerSlot, genderedCard, includeInverted, rng)
2385
- );
2386
- } else {
2387
- const replacement = pickTarotCardFromPool(
2388
- majorPool,
2389
- getTarotSpreadRuleForDraw(inquirerSlot),
2390
- rng
2391
- );
2392
- drawnCards.push(
2393
- buildResolvedDrawnCard(inquirerSlot, replacement, includeInverted, rng)
2474
+ if ("tarotCardFilename" in lookup) {
2475
+ return cache.byTarotCardFilename.get(
2476
+ normalizeTarotLookupKey(lookup.tarotCardFilename)
2394
2477
  );
2395
2478
  }
2396
- return drawnCards;
2479
+ return getTarotCardByNumber(lookup.tarotCardNumber);
2397
2480
  }
2398
- function listTarotSpreads() {
2399
- return TAROT_SPREADS.map(cloneSpreadDefinition);
2481
+ function listTarotDecks() {
2482
+ return TAROT_DECK_METADATA.map(({ id: id2, label }) => ({ id: id2, label }));
2400
2483
  }
2401
- function getTarotSpread(spreadId) {
2402
- const spread = TAROT_SPREAD_BY_ID.get(spreadId);
2403
- return spread ? cloneSpreadDefinition(spread) : void 0;
2484
+ function listTarotTrees() {
2485
+ return [...TAROT_TREE_IDS];
2404
2486
  }
2405
- function validateTarotSpreadSelection(input) {
2406
- const spread = TAROT_SPREAD_BY_ID.get(input.spreadId);
2407
- const errors = [];
2408
- if (!spread) {
2409
- return {
2410
- ok: false,
2411
- isComplete: false,
2412
- errors: [
2413
- {
2414
- code: "UNKNOWN_SPREAD",
2415
- message: `Unknown tarot spread: ${input.spreadId}.`
2416
- }
2417
- ],
2418
- resolvedCards: []
2419
- };
2487
+ function getTarotCardNumber(lookup, treeId = DEFAULT_TAROT_TREE_ID) {
2488
+ if ("tarotCardNumber" in lookup) {
2489
+ return getTarotCardByNumber(lookup.tarotCardNumber, treeId)?.tarotCardNumber;
2420
2490
  }
2421
- const slotsByKey = new Map(
2422
- spread.slots.map((slot) => [slot.slotKey, slot])
2423
- );
2424
- const seenCardNumbers = /* @__PURE__ */ new Set();
2425
- const resolvedCards = [];
2426
- for (const selectedCard of input.cards) {
2427
- const slot = slotsByKey.get(selectedCard.slotKey);
2428
- if (!slot) {
2429
- errors.push({
2430
- code: "UNKNOWN_SLOT",
2431
- slotKey: selectedCard.slotKey,
2432
- message: `Unknown slot for ${spread.label}: ${selectedCard.slotKey}.`
2433
- });
2434
- continue;
2435
- }
2436
- const tarotCard = getTarotDeckCardByNumber(selectedCard.cardNumber);
2437
- if (!tarotCard) {
2438
- errors.push({
2439
- code: "CARD_NOT_FOUND",
2440
- slotKey: selectedCard.slotKey,
2441
- cardNumber: selectedCard.cardNumber,
2442
- message: `Unknown tarot card number: ${selectedCard.cardNumber}.`
2443
- });
2444
- continue;
2445
- }
2446
- if (seenCardNumbers.has(tarotCard.number)) {
2447
- errors.push({
2448
- code: "DUPLICATE_CARD",
2449
- slotKey: selectedCard.slotKey,
2450
- cardNumber: tarotCard.number,
2451
- message: `Tarot card ${tarotCard.number} is duplicated across the spread.`
2452
- });
2453
- continue;
2454
- }
2455
- seenCardNumbers.add(tarotCard.number);
2456
- resolvedCards.push(
2457
- resolveTarotSpreadSelectionCard(selectedCard, slot, tarotCard)
2458
- );
2491
+ const tarotArkAnnuId = resolveTarotArkAnnuId(lookup);
2492
+ if (!tarotArkAnnuId) {
2493
+ return void 0;
2459
2494
  }
2460
- let isComplete = true;
2461
- for (const slot of spread.slots) {
2462
- const slotCards = resolvedCards.filter(
2463
- (selectedCard) => selectedCard.slotKey === slot.slotKey
2464
- );
2465
- if (slotCards.length < slot.minCards) {
2466
- isComplete = false;
2467
- if (!input.allowPartial) {
2468
- errors.push({
2469
- code: "MISSING_REQUIRED_CARDS",
2470
- slotKey: slot.slotKey,
2471
- message: `${spread.label} requires ${slot.minCards} card(s) for ${slot.label}.`
2472
- });
2473
- }
2474
- }
2475
- if (slotCards.length > slot.maxCards) {
2476
- isComplete = false;
2477
- errors.push({
2478
- code: "TOO_MANY_CARDS",
2479
- slotKey: slot.slotKey,
2480
- message: `${spread.label} allows at most ${slot.maxCards} card(s) for ${slot.label}.`
2481
- });
2482
- }
2483
- const validationRule = getTarotSpreadRuleForValidation(slot);
2484
- for (const slotCard of slotCards) {
2485
- if (validationRule?.allowedTypes && !validationRule.allowedTypes.includes(slotCard.card.type)) {
2486
- errors.push({
2487
- code: "INVALID_CARD_TYPE",
2488
- slotKey: slot.slotKey,
2489
- cardNumber: slotCard.card.number,
2490
- message: `${slot.label} does not accept ${slotCard.card.type} cards.`
2491
- });
2492
- }
2493
- if (validationRule?.requiredRank && getTarotMinorRank(slotCard.card) !== validationRule.requiredRank) {
2494
- errors.push({
2495
- code: "INVALID_CARD_RANK",
2496
- slotKey: slot.slotKey,
2497
- cardNumber: slotCard.card.number,
2498
- message: `${slot.label} requires a ${validationRule.requiredRank} minor arcana card.`
2499
- });
2500
- }
2501
- if (validationRule?.allowedCardFilenames && !validationRule.allowedCardFilenames.includes(slotCard.card.tarotCardFilename)) {
2502
- errors.push({
2503
- code: "DISALLOWED_CARD",
2504
- slotKey: slot.slotKey,
2505
- cardNumber: slotCard.card.number,
2506
- message: `${slotCard.card.tarotCard} is not allowed in ${slot.label}.`
2507
- });
2508
- }
2509
- if (validationRule?.excludedCardFilenames && validationRule.excludedCardFilenames.includes(slotCard.card.tarotCardFilename)) {
2510
- errors.push({
2511
- code: "DISALLOWED_CARD",
2512
- slotKey: slot.slotKey,
2513
- cardNumber: slotCard.card.number,
2514
- message: `${slotCard.card.tarotCard} is excluded from ${slot.label}.`
2515
- });
2516
- }
2517
- }
2495
+ return getDirectTarotCardNumber(tarotArkAnnuId, treeId);
2496
+ }
2497
+ function getTarotCardByNumber(cardNumber, treeId = DEFAULT_TAROT_TREE_ID) {
2498
+ const tree = getTarotTreeWorkspace(treeId);
2499
+ if (!tree) {
2500
+ return void 0;
2518
2501
  }
2519
- if (spread.contextRequirements?.includes("inquirerGender") && !input.context?.inquirerGender) {
2520
- isComplete = false;
2521
- errors.push({
2522
- code: "MISSING_CONTEXT",
2523
- message: `${spread.label} requires \`context.inquirerGender\`.`
2524
- });
2502
+ const match = tree.getCorrespondences(chunkQ7YAKPBH_js.id("number" /* NUMBER */, cardNumber), {
2503
+ type: "tarotArkAnnu" /* TAROT_ARK_ANNU */,
2504
+ depth: 1,
2505
+ limit: 1
2506
+ })[0];
2507
+ if (!match) {
2508
+ return void 0;
2509
+ }
2510
+ const profile = getTarotCardProfile({
2511
+ tarotArkAnnuId: match.node.id
2512
+ });
2513
+ if (!profile || profile.tarotCardNumber === cardNumber) {
2514
+ return profile;
2525
2515
  }
2526
- validateEventInquirerCard(spread, resolvedCards, input.context, errors);
2527
- const sortedResolvedCards = sortResolvedTarotSpreadCards(resolvedCards);
2528
2516
  return {
2529
- ok: errors.length === 0,
2530
- isComplete,
2531
- spread: cloneSpreadDefinition(spread),
2532
- resolvedCards: sortedResolvedCards,
2533
- errors
2517
+ ...profile,
2518
+ tarotCardNumber: cardNumber
2534
2519
  };
2535
2520
  }
2536
- function drawTarotSpread(options) {
2537
- const spread = TAROT_SPREAD_BY_ID.get(options.spreadId);
2538
- if (!spread) {
2539
- throw new Error(`Unknown tarot spread: ${options.spreadId}.`);
2521
+ function getTarotArchetype(lookup) {
2522
+ const cache = getTarotArchetypeCache();
2523
+ if ("pathSlug" in lookup) {
2524
+ return cache.byPathSlug.get(normalizePathSlug(lookup.pathSlug));
2540
2525
  }
2541
- const rng = options.rng ?? Math.random;
2542
- const includeInverted = options.includeInverted ?? false;
2543
- const drawnCards = spread.spreadId === "event-reading" ? drawEventReadingSpread(spread, includeInverted, rng, options.context) : drawDefaultTarotSpread(spread, includeInverted, rng);
2544
- const validation = validateTarotSpreadSelection({
2545
- spreadId: spread.spreadId,
2546
- cards: drawnCards.map((card) => ({
2547
- slotKey: card.slotKey,
2548
- cardNumber: card.cardNumber,
2549
- isInverted: card.isInverted
2550
- })),
2551
- context: options.context
2552
- });
2553
- if (!validation.ok) {
2554
- throw new Error(
2555
- `Generated an invalid tarot spread selection for ${spread.label}: ${validation.errors.map((error) => error.message).join(" ")}`
2526
+ if ("pathId" in lookup) {
2527
+ return cache.byPathId.get(String(lookup.pathId));
2528
+ }
2529
+ if ("tarotCardFilename" in lookup) {
2530
+ return cache.byTarotCardFilename.get(
2531
+ lookup.tarotCardFilename.toLowerCase()
2556
2532
  );
2557
2533
  }
2558
- return {
2559
- spread: cloneSpreadDefinition(spread),
2560
- deckId: options.deckId ?? "rider-waite",
2561
- context: options.context,
2562
- cards: sortResolvedTarotSpreadCards(drawnCards)
2563
- };
2534
+ return cache.byTarotCardNumber.get(lookup.tarotCardNumber);
2535
+ }
2536
+ function getTarotCorrespondenceProfile(lookup, treeId = DEFAULT_TAROT_TREE_ID) {
2537
+ const card = resolveTarotCardProfileForTree(lookup, treeId);
2538
+ if (!card) {
2539
+ return void 0;
2540
+ }
2541
+ const tree = getTarotCorrespondenceTree(treeId);
2542
+ switch (card.kind) {
2543
+ case "major":
2544
+ return buildMajorCorrespondenceProfile(card, tree);
2545
+ case "court":
2546
+ return buildCourtCorrespondenceProfile(card, tree);
2547
+ case "minor":
2548
+ return buildMinorCorrespondenceProfile(card, tree);
2549
+ }
2550
+ }
2551
+ function getTarotRepresentations(lookup) {
2552
+ const card = getTarotCardProfile(lookup);
2553
+ if (!card) {
2554
+ return [];
2555
+ }
2556
+ return TAROT_DECK_METADATA.map(
2557
+ (deck) => buildTarotRepresentation(card, deck)
2558
+ );
2559
+ }
2560
+ function getTarotRepresentation(lookup, deckId) {
2561
+ const card = getTarotCardProfile(lookup);
2562
+ const deck = TAROT_DECK_METADATA.find((candidate) => candidate.id === deckId);
2563
+ if (!card || !deck) {
2564
+ return void 0;
2565
+ }
2566
+ return buildTarotRepresentation(card, deck);
2567
+ }
2568
+ function resolveTarotImageUrl(lookup, deckId) {
2569
+ return getTarotRepresentation(lookup, deckId)?.imageUrl;
2564
2570
  }
2565
2571
 
2566
2572
  exports.ARKANNUS = ARKANNUS;
@@ -2584,4 +2590,4 @@ exports.resolveTarotImageUrl = resolveTarotImageUrl;
2584
2590
  exports.shuffleTarotDeck = shuffleTarotDeck;
2585
2591
  exports.validateTarotSpreadSelection = validateTarotSpreadSelection;
2586
2592
  //# sourceMappingURL=out.js.map
2587
- //# sourceMappingURL=chunk-36XZ5WR2.js.map
2593
+ //# sourceMappingURL=chunk-M2FTEWY2.js.map