{"version":3,"sources":["../src/tarot/index.ts"],"names":["id"],"mappings":";;;;;;;;;AAsBO,IAAM,wBAAqC;AAE3C,IAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF;AAuCO,IAAM,cAA6B;AAAA,EACxC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAIA,IAAM,eAA4B;AAAA;AAAA,EAEhC;AAAA,IACE,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,SAAS;AAAA,IACT,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,SACE;AAAA,IACF,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,SAAS;AAAA,IACT,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,SAAS;AAAA,IACT,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,SACE;AAAA,IACF,cAAc;AAAA,IACd,MAAM;AAAA,IACN,MAAM;AAAA,EACR;AAAA,EACA;AAAA,IACE,QAAQ;AAAA,IACR,WAAW;AAAA,IACX,mBAAmB;AAAA,IACnB,SACE;A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;AAClB,UAAM,IAAI;AAAA,MACR,mDAAmD,OAAO,KAAK,KAAK,WAAW,OAC5E,IAAI,CAAC,UAAU,MAAM,OAAO,EAC5B,KAAK,GAAG,CAAC;AAAA,IACd;AAAA,EACF;AAEA,SAAO;AAAA,IACL,QAAQ,sBAAsB,MAAM;AAAA,IACpC,QAAQ,QAAQ,UAAU;AAAA,IAC1B,SAAS,QAAQ;AAAA,IACjB,OAAO,6BAA6B,UAAU;AAAA,EAChD;AACF","sourcesContent":["/**\n * Tarot interpretation functions\n */\n\nimport {\n  getCanonicalTree,\n  id,\n  KaabalahTypes,\n  LetterTypes,\n  NumerologyTypes,\n  parseId,\n  type SystemKey,\n  TarotTypes,\n  type NodeId,\n  type Node,\n  WesternAstrologyTypes\n} from \"../core\";\n\nexport type Deck = \"papus_pt\" | \"papus\" | \"mythic\" | \"egyptian\" | \"rider-waite\"\nexport type TarotDeckId = Deck;\nexport type TarotTreeId = SystemKey;\n\nexport const DEFAULT_TAROT_TREE_ID: TarotTreeId = \"kaabalah\";\n\nexport const TAROT_TREE_IDS = [\n  \"kaabalah\",\n  \"hermetic-qabalah\",\n  \"lurianic-kabbalah\"\n] as const satisfies readonly TarotTreeId[];\n\nexport type MajorArcana =\n  | \"01_the_magician\"\n  | \"02_the_high_priestess\"\n  | \"03_the_empress\"\n  | \"04_the_emperor\"\n  | \"05_the_hierophant\"\n  | \"06_the_lover\"\n  | \"07_the_chariot\"\n  | \"08_justice\"\n  | \"09_the_hermit\"\n  | \"10_the_wheel_of_fortune\"\n  | \"11_strength\"\n  | \"12_the_hanged_man\"\n  | \"13_death\"\n  | \"14_temperance\"\n  | \"15_the_devil\"\n  | \"16_the_house_of_god\"\n  | \"17_the_star\"\n  | \"18_the_moon\"\n  | \"19_the_sun\"\n  | \"20_judgement\"\n  | \"21_the_fool\"\n  | \"22_the_world\"\n\nexport type TarotCard = {\n  number: number\n  tarotCard: string\n  tarotCardFilename: string\n  egyptianCardName?: string\n  meaning: string\n  papusMeaning?: string\n  type: \"major\" | \"minor\" | \"daat+royalship\"\n  deck: Deck\n  suit?: string\n  isInverted?: boolean\n}\n\nexport const majorArcana: MajorArcana[] = [\n  \"01_the_magician\",\n  \"02_the_high_priestess\",\n  \"03_the_empress\",\n  \"04_the_emperor\",\n  \"05_the_hierophant\",\n  \"06_the_lover\",\n  \"07_the_chariot\",\n  \"08_justice\",\n  \"09_the_hermit\",\n  \"10_the_wheel_of_fortune\",\n  \"11_strength\",\n  \"12_the_hanged_man\",\n  \"13_death\",\n  \"14_temperance\",\n  \"15_the_devil\",\n  \"16_the_house_of_god\",\n  \"17_the_star\",\n  \"18_the_moon\",\n  \"19_the_sun\",\n  \"20_judgement\",\n  \"21_the_fool\",\n  \"22_the_world\"\n]\n\n// Base card catalog. The exported ARKANNUS list is normalized below so its\n// numbers always reflect the canonical kaabalah tree correspondences.\nconst RAW_ARKANNUS: TarotCard[] = [\n  // Major Arcana (1-22)\n  {\n    number: 1,\n    tarotCard: \"The Magician\",\n    tarotCardFilename: \"01_the_magician\",\n    meaning: \"Abracadabra, the power to create reality through voice\",\n    papusMeaning: \"Male inquirer.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 2,\n    tarotCard: \"The High Priestess\",\n    tarotCardFilename: \"02_the_high_priestess\",\n    meaning:\n      \"Intuition, the power to rewrite your book of life improving your life every instant\",\n    papusMeaning: \"Female inquirer.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 3,\n    tarotCard: \"The Empress\",\n    tarotCardFilename: \"03_the_empress\",\n    meaning: \"Adaptation, the power to geometrize through emotions\",\n    papusMeaning: \"Action. Initiative.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 4,\n    tarotCard: \"The Emperor\",\n    tarotCardFilename: \"04_the_emperor\",\n    meaning: \"Authority, the power to mark your territory with the sacred fire\",\n    papusMeaning: \"Will.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 5,\n    tarotCard: \"The Hierophant\",\n    tarotCardFilename: \"05_the_hierophant\",\n    meaning:\n      \"Magnetism, the power to ritualize life and circulate the quintessence\",\n    papusMeaning: \"Inspiration.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 6,\n    tarotCard: \"The Lover\",\n    tarotCardFilename: \"06_the_lover\",\n    meaning:\n      \"Dichotomy, stay on the middle path by being neither a victim nor a villain\",\n    papusMeaning: \"Love.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 7,\n    tarotCard: \"The Chariot\",\n    tarotCardFilename: \"07_the_chariot\",\n    meaning: \"Merkaabah, take control and build your merkaabah (mind vehicle)\",\n    papusMeaning: \"Triumph. Providential protection.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 8,\n    tarotCard: \"Justice\",\n    tarotCardFilename: \"08_justice\",\n    meaning: \"Justice, be just with yourself to be just with others\",\n    papusMeaning: \"Justice.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 9,\n    tarotCard: \"The Hermit\",\n    tarotCardFilename: \"09_the_hermit\",\n    meaning: \"Introspection, seek within, retreat\",\n    papusMeaning: \"Prudence.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 10,\n    tarotCard: \"The Wheel of Fortune\",\n    tarotCardFilename: \"10_the_wheel_of_fortune\",\n    meaning:\n      \"Loops, extroversion, break the great wheel and ascend, seek externally\",\n    papusMeaning: \"Fortune. Destiny.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 11,\n    tarotCard: \"Strength\",\n    tarotCardFilename: \"11_strength\",\n    meaning: \"The strength of your subconscious, unity brings strength\",\n    papusMeaning: \"Strength. Fortitude.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 12,\n    tarotCard: \"The Hanged Man\",\n    tarotCardFilename: \"12_the_hanged_man\",\n    meaning: \"Make valid sacrifices, adopt a new perspective\",\n    papusMeaning: \"Trials. Sacrifice.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 13,\n    tarotCard: \"Death\",\n    tarotCardFilename: \"13_death\",\n    meaning: \"Death, renovation, kill that which kills your soul\",\n    papusMeaning: \"Death.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 14,\n    tarotCard: \"Temperance\",\n    tarotCardFilename: \"14_temperance\",\n    meaning: \"Balance, harmonize differences\",\n    papusMeaning: \"Temperance. Economy.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 15,\n    tarotCard: \"The Devil\",\n    tarotCardFilename: \"15_the_devil\",\n    meaning:\n      \"Indecision between vice and virtue, transmute weakness and passions into strengths\",\n    papusMeaning: \"Immense force. Illness.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 16,\n    tarotCard: \"The Tower\",\n    tarotCardFilename: \"16_the_house_of_god\",\n    meaning:\n      \"Separation, destruction, separate from what's harmful and connect with what's helpful, make room for the new\",\n    papusMeaning: \"Ruin. Deception.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 17,\n    tarotCard: \"The Star\",\n    tarotCardFilename: \"17_the_star\",\n    meaning:\n      \"Fecundation, ecology, ecstasy, hope, renew yourself to maintain health, act according to your spiritual purpose\",\n    papusMeaning: \"Hope.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 18,\n    tarotCard: \"The Moon\",\n    tarotCardFilename: \"18_the_moon\",\n    meaning:\n      \"Hidden enemies, be vigilant, recognize where you're self sabotaging\",\n    papusMeaning: \"Hidden enemies. Danger.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 19,\n    tarotCard: \"The Sun\",\n    tarotCardFilename: \"19_the_sun\",\n    meaning:\n      \"Be conscious of your alchemical band, transmute money into knowledge and vice versa\",\n    papusMeaning: \"Material happiness. Lucky marriage.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 20,\n    tarotCard: \"Judgment\",\n    tarotCardFilename: \"20_judgement\",\n    meaning: \"Make retrospectives and learn from mistakes and successes\",\n    papusMeaning: \"Change of position.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 21,\n    tarotCard: \"The Fool\",\n    tarotCardFilename: \"21_the_fool\",\n    meaning: \"Stop walking in circles, create connections of knowledge\",\n    papusMeaning: \"Inconsiderate actions. Madness.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n  {\n    number: 22,\n    tarotCard: \"The World\",\n    tarotCardFilename: \"22_the_world\",\n    meaning: \"Win the world, start acting on the world of causes\",\n    papusMeaning: \"Assured success.\",\n    type: \"major\",\n    deck: \"mythic\"\n  },\n\n  // Da'at Royalship - Wands (23-26)\n  {\n    number: 23,\n    tarotCard: \"King of Wands\",\n    tarotCardFilename: \"king_wands\",\n    egyptianCardName: \"The Laborer\",\n    meaning: \"Get's the best out of every one, Idealism, Magnanimity\",\n    papusMeaning:\n      \"A dark man, a friend. He generally represents a married man, the father of a family.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 24,\n    tarotCard: \"Queen of Wands\",\n    tarotCardFilename: \"queen_wands\",\n    egyptianCardName: \"The Weaver\",\n    meaning:\n      \"Hold the line while the king goes to work, Preserve what was conquered\",\n    papusMeaning:\n      \"A dark woman, a friend. Represents a serious woman, a very good counsellor, often the mother of a family.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 25,\n    tarotCard: \"Knight of Wands\",\n    tarotCardFilename: \"knight_wands\",\n    egyptianCardName: \"The Argonaut\",\n    meaning: \"Dreams that become reality\",\n    papusMeaning: \"A dark young man, a friend.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 26,\n    tarotCard: \"Page of Wands\",\n    tarotCardFilename: \"page_wands\",\n    egyptianCardName: \"The Prodigy\",\n    meaning: \"Don't rush, the precipitations are the doors to failure\",\n    papusMeaning:\n      \"A dark child, a friend. Also represents a message from a near relation.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n\n  // Minor Arcana - Wands (27-36)\n  {\n    number: 27,\n    tarotCard: \"Ace of Wands\",\n    tarotCardFilename: \"ace_wands\",\n    egyptianCardName: \"Initiation\",\n    meaning: \"Ignite the flames of ideals, Trust in your inner divinity\",\n    papusMeaning: \"Commencement of an enterprise.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 28,\n    tarotCard: \"Two of Wands\",\n    tarotCardFilename: \"2_wands\",\n    egyptianCardName: \"Desolation\",\n    meaning: \"Formulate a strategy to use your own talents\",\n    papusMeaning:\n      \"Opposition to the commencement of the enterprise. The enterprise is commenced when an unexpected obstacle suddenly prevents its execution.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 29,\n    tarotCard: \"Three of Wands\",\n    tarotCardFilename: \"3_wands\",\n    egyptianCardName: \"Innovation\",\n    meaning: \"Keep going despite losing something apparently important\",\n    papusMeaning:\n      \"Realization of the commencement of the enterprise. The basis of the work is now definitely established, and the undertaking can be fearlessly continued.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 30,\n    tarotCard: \"Four of Wands\",\n    tarotCardFilename: \"4_wands\",\n    egyptianCardName: \"Alliance\",\n    meaning: \"Work in teams\",\n    papusMeaning:\n      \"Obstacles to the enterprise.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 31,\n    tarotCard: \"Five of Wands\",\n    tarotCardFilename: \"5_wands\",\n    egyptianCardName: \"Magnificence\",\n    meaning: \"Strengthen the root chakra, overcome internal fears\",\n    papusMeaning: \"Opposition to the obstacles. Victory after surmounting them.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 32,\n    tarotCard: \"Six of Wands\",\n    tarotCardFilename: \"6_wands\",\n    egyptianCardName: \"Impediment\",\n    meaning: \"External victory, internal lack of internal self realization\",\n    papusMeaning:\n      \"Realization of the opposition. At last the obstacles succeed. Failure of the enterprise in the midst of its execution.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 33,\n    tarotCard: \"Seven of Wands\",\n    tarotCardFilename: \"7_wands\",\n    egyptianCardName: \"Exchange\",\n    meaning: \"Face competitors in an ethical and loyal way\",\n    papusMeaning: \"Certain success to the enterprise.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 34,\n    tarotCard: \"Eight of Wands\",\n    tarotCardFilename: \"8_wands\",\n    egyptianCardName: \"Domesticity\",\n    meaning: \"Travel to the center of peace and intelligence\",\n    papusMeaning:\n      \"Opposition to its success. The enterprise will only partially succeed.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 35,\n    tarotCard: \"Nine of Wands\",\n    tarotCardFilename: \"9_wands\",\n    egyptianCardName: \"Uncertainty\",\n    meaning: \"Obstacle that precedes total victory, gather hidden forces\",\n    papusMeaning: \"Realization of success. Success is continued.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n  {\n    number: 36,\n    tarotCard: \"Ten of Wands\",\n    tarotCardFilename: \"10_wands\",\n    egyptianCardName: \"The Unexpected\",\n    meaning:\n      \"Get out of apathy, create a new tree of life using the Lightning Path\",\n    papusMeaning: \"Uncertainty in the management of the enterprise.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"wands\"\n  },\n\n  // Da'at Royalship - Cups (37-40)\n  {\n    number: 37,\n    tarotCard: \"King of Cups\",\n    tarotCardFilename: \"king_cups\",\n    egyptianCardName: \"Art and Science\",\n    meaning:\n      \"Stop hurting yourself (related to The Lover), heals everyone and forgets about yourself, balm for your own wound\",\n    papusMeaning:\n      \"A fair man, a friend. This card also represents a barrister, judge, or ecclesiastic. It symbolizes a bachelor.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 38,\n    tarotCard: \"Queen of Cups\",\n    tarotCardFilename: \"queen_cups\",\n    egyptianCardName: \"Duplicity\",\n    meaning: \"Work with subtlety, positive challenges\",\n    papusMeaning:\n      \"A fair woman, a friend. The woman loved. The mistress.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 39,\n    tarotCard: \"Knight of Cups\",\n    tarotCardFilename: \"knight_cups\",\n    egyptianCardName: \"Testimony\",\n    meaning: \"Alternative healing\",\n    papusMeaning:\n      \"A young fair man, a friend. The young man loved. The lover.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 40,\n    tarotCard: \"Page of Cups\",\n    tarotCardFilename: \"page_cups\",\n    egyptianCardName: \"Premonition\",\n    meaning: \"Increase of self-esteem, emotional courage\",\n    papusMeaning: \"A fair child. A messenger. Birth.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n\n  // Minor Arcana - Cups (41-50)\n  {\n    number: 41,\n    tarotCard: \"Ace of Cups\",\n    tarotCardFilename: \"ace_cups\",\n    egyptianCardName: \"Attraction\",\n    meaning: \"Renewal or new affection, alternative treatment for health\",\n    papusMeaning: \"Commencement of a love affair.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 42,\n    tarotCard: \"Two of Cups\",\n    tarotCardFilename: \"2_cups\",\n    egyptianCardName: \"Versatility\",\n    meaning: \"Do not poison yourself or the other person\",\n    papusMeaning:\n      \"Opposition to this commencement. Unimportant obstacles raised by one of the lovers.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 43,\n    tarotCard: \"Three of Cups\",\n    tarotCardFilename: \"3_cups\",\n    egyptianCardName: \"Consummation\",\n    meaning: \"Harmony between instinct and emotion, Be discreet\",\n    papusMeaning:\n      \"Realization of this commencement. The love is mutual.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 44,\n    tarotCard: \"Four of Cups\",\n    tarotCardFilename: \"4_cups\",\n    egyptianCardName: \"Conjecture\",\n    meaning: \"Abundance in emotional life, do not listen to slander\",\n    papusMeaning:\n      \"Serious obstacles to the love. They arise from other persons, not from the lovers.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 45,\n    tarotCard: \"Five of Cups\",\n    tarotCardFilename: \"5_cups\",\n    egyptianCardName: \"Patrimony\",\n    meaning: \"Do not break your spiritual commitment (your purpose)\",\n    papusMeaning:\n      \"Opposition to the obstacles. Victory over the obstacles after a struggle.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 46,\n    tarotCard: \"Six of Cups\",\n    tarotCardFilename: \"6_cups\",\n    egyptianCardName: \"Regeneration\",\n    meaning: \"Do not have self-pity\",\n    papusMeaning:\n      \"The obstacles triumph. Love destroyed in the midst of happiness. Widowhood.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 47,\n    tarotCard: \"Seven of Cups\",\n    tarotCardFilename: \"7_cups\",\n    egyptianCardName: \"Expressiveness\",\n    meaning: \"Gestations, related to The Star\",\n    papusMeaning: \"Success assured to the lovers.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 48,\n    tarotCard: \"Eight of Cups\",\n    tarotCardFilename: \"8_cups\",\n    egyptianCardName: \"Delusion\",\n    meaning: \"Reflect on your emotional life after 18 hours\",\n    papusMeaning:\n      \"Partial failure of love. Love only partially succeeds.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 49,\n    tarotCard: \"Nine of Cups\",\n    tarotCardFilename: \"9_cups\",\n    egyptianCardName: \"Preeminence\",\n    meaning: \"Reconciliations and forgiveness\",\n    papusMeaning: \"Motherhood.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n  {\n    number: 50,\n    tarotCard: \"Ten of Cups\",\n    tarotCardFilename: \"10_cups\",\n    egyptianCardName: \"Dissension\",\n    meaning: \"Marriage of the spirit with the soul, Alchemical Weddings\",\n    papusMeaning:\n      \"Uncertainty in the management of the love affair.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"cups\"\n  },\n\n  // Da'at Royalship - Swords (51-54)\n  {\n    number: 51,\n    tarotCard: \"King of Swords\",\n    tarotCardFilename: \"king_swords\",\n    egyptianCardName: \"Advice\",\n    meaning: \"Actions of victorious strategies\",\n    papusMeaning:\n      \"A dark, bad man. He is a soldier, a powerful enemy, who must be distrusted.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 52,\n    tarotCard: \"Queen of Swords\",\n    tarotCardFilename: \"queen_swords\",\n    egyptianCardName: \"Premeditation\",\n    meaning: \"Supremacy of the feminine, related to Justice\",\n    papusMeaning:\n      \"A dark wicked woman. The card also indicates her actions, gossip and calumnies.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 53,\n    tarotCard: \"Knight of Swords\",\n    tarotCardFilename: \"knight_swords\",\n    egyptianCardName: \"Hostility\",\n    meaning: \"Joint victorious actions\",\n    papusMeaning:\n      \"A young, dark man, an enemy. He is also a spy.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 54,\n    tarotCard: \"Page of Swords\",\n    tarotCardFilename: \"page_swords\",\n    egyptianCardName: \"Examination\",\n    meaning: \"Follow your intuition\",\n    papusMeaning: \"A child, an enemy. Bad news. Delay.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n\n  // Minor Arcana - Swords (55-64)\n  {\n    number: 55,\n    tarotCard: \"Ace of Swords\",\n    tarotCardFilename: \"ace_swords\",\n    egyptianCardName: \"Vehemence\",\n    meaning: \"Conflicts before victory\",\n    papusMeaning: \"Commencement of enmity.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 56,\n    tarotCard: \"Two of Swords\",\n    tarotCardFilename: \"2_swords\",\n    egyptianCardName: \"Communion\",\n    meaning: \"Traumas and conflicts to be overcome\",\n    papusMeaning:\n      \"Opposition to this commencement. The enmity does not last.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 57,\n    tarotCard: \"Three of Swords\",\n    tarotCardFilename: \"3_swords\",\n    egyptianCardName: \"Proscription\",\n    meaning: \"Death of yang, Fire, tendencies to depression\",\n    papusMeaning: \"Realization of the enmity. Hatred.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 58,\n    tarotCard: \"Four of Swords\",\n    tarotCardFilename: \"4_swords\",\n    egyptianCardName: \"Solitude\",\n    meaning: \"Reflection, related to The Hermit\",\n    papusMeaning: \"Opposition to the hatred. Success against the enemy.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 59,\n    tarotCard: \"Five of Swords\",\n    tarotCardFilename: \"5_swords\",\n    egyptianCardName: \"Evolution\",\n    meaning: \"Healthy self-challenge, Self-demands\",\n    papusMeaning:\n      \"Opposition to this opposition. The enemy triumphs at the moment one fancies the victory is secured.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 60,\n    tarotCard: \"Six of Swords\",\n    tarotCardFilename: \"6_swords\",\n    egyptianCardName: \"Revelation\",\n    meaning: \"External daily strategies, Future perspectives\",\n    papusMeaning:\n      \"Equilibrium of the opposition. The enemy is rendered powerless at last.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 61,\n    tarotCard: \"Seven of Swords\",\n    tarotCardFilename: \"7_swords\",\n    egyptianCardName: \"Meditation\",\n    meaning: \"Internal nocturnal strategies, related to The Hermit\",\n    papusMeaning: \"Success assured to the enemy.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 62,\n    tarotCard: \"Eight of Swords\",\n    tarotCardFilename: \"8_swords\",\n    egyptianCardName: \"Rivalry\",\n    meaning: \"Appeal to superior forces, Internal and external conflicts\",\n    papusMeaning:\n      \"Partial opposition to this success. The enemy only partially triumphs.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 63,\n    tarotCard: \"Nine of Swords\",\n    tarotCardFilename: \"9_swords\",\n    egyptianCardName: \"Pilgrimage\",\n    meaning: \"The problems being imagined will never happen\",\n    papusMeaning: \"Certain duration of the hatred.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n  {\n    number: 64,\n    tarotCard: \"Ten of Swords\",\n    tarotCardFilename: \"10_swords\",\n    egyptianCardName: \"Contrition\",\n    meaning: \"Death and rebirth, related to Death and The Tower\",\n    papusMeaning: \"Uncertainty in the enmity.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"swords\"\n  },\n\n  // Da'at Royalship - Pentacles (65-68)\n  {\n    number: 65,\n    tarotCard: \"King of Pentacles\",\n    tarotCardFilename: \"king_pentacles\",\n    egyptianCardName: \"Apprenticeship\",\n    meaning: \"Turns everything into gold\",\n    papusMeaning: \"A fair man, inimical or indifferent.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 66,\n    tarotCard: \"Queen of Pentacles\",\n    tarotCardFilename: \"queen_pentacles\",\n    egyptianCardName: \"Perplexity\",\n    meaning: \"Act with diplomacy\",\n    papusMeaning: \"A fair woman, indifferent, or inimical.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 67,\n    tarotCard: \"Knight of Pentacles\",\n    tarotCardFilename: \"knight_pentacles\",\n    egyptianCardName: \"Veneration\",\n    meaning: \"Invest into new things\",\n    papusMeaning: \"A young, fair man. A stranger. An arrival.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 68,\n    tarotCard: \"Page of Pentacles\",\n    tarotCardFilename: \"page_pentacles\",\n    egyptianCardName: \"Speculation\",\n    meaning: \"Prudence in the material life\",\n    papusMeaning: \"A fair child. A messenger. A letter.\",\n    type: \"daat+royalship\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n\n  // Minor Arcana - Pentacles (69-78)\n  {\n    number: 69,\n    tarotCard: \"Ace of Pentacles\",\n    tarotCardFilename: \"ace_pentacles\",\n    egyptianCardName: \"Rebirth\",\n    meaning:\n      \"Rebirth through a single material goal, Form clear material goals\",\n    papusMeaning: \"Commencement of fortune. Inheritance. Gifts. Economy.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 70,\n    tarotCard: \"Two of Pentacles\",\n    tarotCardFilename: \"2_pentacles\",\n    egyptianCardName: \"Confusion\",\n    meaning:\n      \"Light forming shadows, Duality asking for synthesis in the trinity, Don't put all the eggs in the same basket\",\n    papusMeaning:\n      \"Opposition to this commencement. Difficulty in well establishing the first landmarks of good fortune.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 71,\n    tarotCard: \"Three of Pentacles\",\n    tarotCardFilename: \"3_pentacles\",\n    egyptianCardName: \"The Provider\",\n    meaning:\n      \"Light forming sound, Establish balance through the trinity becoming a great dispenser, Verbalize what should be done, Do not settle for the first results\",\n    papusMeaning:\n      \"Realization of this commencement of fortune. A small sum.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 72,\n    tarotCard: \"Four of Pentacles\",\n    tarotCardFilename: \"4_pentacles\",\n    egyptianCardName: \"Generosity\",\n    meaning: \"Avoid avarice / greed\",\n    papusMeaning: \"Opposition of fortune. Loss of money.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 73,\n    tarotCard: \"Five of Pentacles\",\n    tarotCardFilename: \"5_pentacles\",\n    egyptianCardName: \"Offering\",\n    meaning:\n      \"Only order will bring progress, Do not kick the barn without having something concrete in front of you\",\n    papusMeaning:\n      \"Opposition to this opposition. A success coming which will balance the low.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 74,\n    tarotCard: \"Six of Pentacles\",\n    tarotCardFilename: \"6_pentacles\",\n    egyptianCardName: \"Love and Desire\",\n    meaning: \"Act with prudence\",\n    papusMeaning: \"Realization of the opposition. Ruin.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 75,\n    tarotCard: \"Seven of Pentacles\",\n    tarotCardFilename: \"7_pentacles\",\n    egyptianCardName: \"Purification\",\n    meaning: \"Don't boast about your proposal or project\",\n    papusMeaning: \"Success assured. A large fortune.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 76,\n    tarotCard: \"Eight of Pentacles\",\n    tarotCardFilename: \"8_pentacles\",\n    egyptianCardName: \"Avarice\",\n    meaning: \"Keep doing what you always did\",\n    papusMeaning:\n      \"Partial success. Great loss of money at the moment apparently of definitely securing the fortune.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 77,\n    tarotCard: \"Nine of Pentacles\",\n    tarotCardFilename: \"9_pentacles\",\n    egyptianCardName: \"Cooperation\",\n    meaning: \"Work with what you like and earn something with it\",\n    papusMeaning: \"Equilibrium of equilibrium. A durable fortune.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  },\n  {\n    number: 78,\n    tarotCard: \"Ten of Pentacles\",\n    tarotCardFilename: \"10_pentacles\",\n    egyptianCardName: \"The Unforeseen\",\n    meaning: \"Prosperity, Prosperous inheritance\",\n    papusMeaning:\n      \"Uncertainty in the fortune. Great success and great reverses.\",\n    type: \"minor\",\n    deck: \"egyptian\",\n    suit: \"pentacles\"\n  }\n]\n\n\nconst sleep = (ms: number) => new Promise(resolve => setTimeout(resolve, ms))\n\nconst shuffleArray = <T,>(array: T[]): T[] => {\n  const newArray = [...array]\n  for (let i = newArray.length - 1; i > 0; i--) {\n    const j = Math.floor(Math.random() * (i + 1));\n\n    [newArray[i], newArray[j]] = [newArray[j], newArray[i]];\n  }\n  return newArray\n}\n\n/**\n * Shuffles a deck of tarot cards and optionally includes inverted cards\n * @param cards - Array of tarot cards to shuffle\n * @param includeInvertedCards - Whether to include inverted cards in the shuffle\n * @param shuffleCount - Number of times to shuffle the deck (default: 6)\n * @param shuffleDelay - Delay between shuffles in milliseconds (default: 300)\n * @returns Promise that resolves to the shuffled deck\n */\nexport async function shuffleTarotDeck(\n  cards: TarotCard[],\n  includeInvertedCards: boolean = false,\n  shuffleCount: number = 6,\n  shuffleDelay: number = 300\n): Promise<TarotCard[]> {\n  let shuffledCards = shuffleArray([...cards]);\n\n  if (includeInvertedCards) {\n    const halfIndex = Math.floor(shuffledCards.length / 2);\n    shuffledCards = [\n      ...shuffledCards\n        .slice(0, halfIndex)\n        .map(card => ({ ...card, isInverted: true })),\n      ...shuffledCards.slice(halfIndex)\n    ];\n  }\n\n  for (let i = 0; i < shuffleCount; i++) {\n    shuffledCards = shuffleArray(shuffledCards);\n    await sleep(shuffleDelay);\n  }\n\n  return shuffledCards;\n}\n\ntype TarotDescriptiveDeckKey =\n  | \"PAPUS_KAABALISTIC\"\n  | \"PAPUS_DIVINATORY\"\n  | \"KIER_EGYPTIAN\";\n\nexport interface TarotDeckMetadata {\n  id: TarotDeckId;\n  label: string;\n}\n\nexport interface TarotDeckDescription {\n  name?: string;\n  meaning?: string;\n  reversedMeaning?: string;\n  keywords?: string[];\n}\n\nexport type TarotAstrologyCorrespondenceType =\n  | WesternAstrologyTypes.PLANET\n  | WesternAstrologyTypes.WESTERN_ZODIAC_SIGN\n  | WesternAstrologyTypes.WESTERN_ELEMENT;\n\nexport interface TarotAstrologyCorrespondence {\n  type: TarotAstrologyCorrespondenceType;\n  id: NodeId<TarotAstrologyCorrespondenceType>;\n  label: string;\n}\n\nexport interface TarotArchetype {\n  canonicalId: NodeId<KaabalahTypes.PATH>;\n  kind: \"major\";\n  pathId: NodeId<KaabalahTypes.PATH>;\n  pathNumber: number;\n  pathSlug: string;\n  hebrewLetterId: NodeId<LetterTypes.HEBREW_LETTER>;\n  hebrewLetter: string;\n  pathMeaning?: string;\n  tarotArkAnnuId: NodeId<TarotTypes.TAROT_ARK_ANNU>;\n  tarotCardNumber: number;\n  tarotCardName: string;\n  tarotCardFilename: MajorArcana;\n  tarotMeaning?: string;\n  astrology: TarotAstrologyCorrespondence[];\n  availableDeckIds: TarotDeckId[];\n  descriptionsByDeck: Partial<Record<TarotDeckId, TarotDeckDescription>>;\n}\n\nexport type TarotArchetypeLookup =\n  | { pathSlug: string }\n  | { pathId: NodeId<KaabalahTypes.PATH> }\n  | { tarotCardFilename: MajorArcana | string }\n  | { tarotCardNumber: number };\n\nexport type TarotCardKind = \"major\" | \"court\" | \"minor\";\nexport type TarotCourtRank = \"king\" | \"queen\" | \"knight\" | \"page\";\n\nexport type TarotAssetPathType = \"major\" | \"minor\" | \"daat+royalship\";\n\nexport interface TarotCardProfile {\n  tarotArkAnnuId: NodeId<TarotTypes.TAROT_ARK_ANNU>;\n  tarotCardNumber: number;\n  tarotCardName: string;\n  tarotCardFilename: string;\n  tarotMeaning?: string;\n  kind: TarotCardKind;\n  assetPathType: TarotAssetPathType;\n  suit?: string;\n  courtRank?: TarotCourtRank;\n  availableDeckIds: TarotDeckId[];\n  descriptionsByDeck: Partial<Record<TarotDeckId, TarotDeckDescription>>;\n}\n\nexport type TarotImageLookup =\n  | TarotArchetypeLookup\n  | { tarotArkAnnuId: NodeId<TarotTypes.TAROT_ARK_ANNU> }\n  | { tarotCardName: string };\n\nexport type TarotCorrespondenceNodeType =\n  | KaabalahTypes.SPHERE\n  | LetterTypes.HEBREW_LETTER\n  | WesternAstrologyTypes.PLANET\n  | WesternAstrologyTypes.WESTERN_ZODIAC_SIGN\n  | WesternAstrologyTypes.WESTERN_ELEMENT;\n\nexport interface TarotCorrespondenceNode<T extends TarotCorrespondenceNodeType> {\n  id: NodeId<T>;\n  label: string;\n}\n\nexport interface TarotPathCorrespondence {\n  pathId: NodeId<KaabalahTypes.PATH>;\n  pathNumber: number;\n  pathSlug: string;\n  meaning?: string;\n  hebrewLetter: TarotCorrespondenceNode<LetterTypes.HEBREW_LETTER>;\n  fromSphere: TarotCorrespondenceNode<KaabalahTypes.SPHERE>;\n  toSphere: TarotCorrespondenceNode<KaabalahTypes.SPHERE>;\n}\n\nexport interface TarotCorrespondenceProfileBase {\n  tarotArkAnnuId: NodeId<TarotTypes.TAROT_ARK_ANNU>;\n  tarotCardNumber: number;\n  tarotCardName: string;\n  tarotCardFilename: string;\n  tarotMeaning?: string;\n  suit?: string;\n}\n\nexport interface TarotMajorCorrespondenceProfile\n  extends TarotCorrespondenceProfileBase {\n  kind: \"major\";\n  correspondences: {\n    astrology: TarotAstrologyCorrespondence[];\n    path: TarotPathCorrespondence;\n  };\n}\n\nexport interface TarotPageCorrespondenceProfile\n  extends TarotCorrespondenceProfileBase {\n  kind: \"court\";\n  courtRank: \"page\";\n  correspondences: {\n    element: TarotCorrespondenceNode<WesternAstrologyTypes.WESTERN_ELEMENT>;\n  };\n}\n\nexport interface TarotCourtAstrologyCorrespondenceProfile\n  extends TarotCorrespondenceProfileBase {\n  kind: \"court\";\n  courtRank: Exclude<TarotCourtRank, \"page\">;\n  correspondences: {\n    sign: TarotCorrespondenceNode<WesternAstrologyTypes.WESTERN_ZODIAC_SIGN>;\n    planets: TarotCorrespondenceNode<WesternAstrologyTypes.PLANET>[];\n  };\n}\n\nexport interface TarotMinorCorrespondenceProfile\n  extends TarotCorrespondenceProfileBase {\n  kind: \"minor\";\n  correspondences: {\n    sphere: TarotCorrespondenceNode<KaabalahTypes.SPHERE>;\n    planets: TarotCorrespondenceNode<WesternAstrologyTypes.PLANET>[];\n  };\n}\n\nexport type TarotCorrespondenceProfile =\n  | TarotMajorCorrespondenceProfile\n  | TarotPageCorrespondenceProfile\n  | TarotCourtAstrologyCorrespondenceProfile\n  | TarotMinorCorrespondenceProfile;\n\nexport interface TarotRepresentation {\n  card: TarotCardProfile;\n  archetype?: TarotArchetype;\n  deck: TarotDeckMetadata;\n  assetPath: string;\n  imageUrl: string;\n  label: string;\n  altText: string;\n  cardLabel: string;\n  description?: TarotDeckDescription;\n}\n\nexport const TAROT_IMAGE_BASE_URL =\n  \"https://kaabalah-app.s3.us-east-1.amazonaws.com/tarot\";\n\ntype TarotDeckConfig = TarotDeckMetadata & {\n  descriptiveDataKey?: TarotDescriptiveDeckKey;\n};\n\nconst TAROT_DECK_METADATA: readonly TarotDeckConfig[] = [\n  {\n    id: \"papus_pt\",\n    label: \"Papus Kaabalistic\",\n    descriptiveDataKey: \"PAPUS_KAABALISTIC\"\n  },\n  {\n    id: \"papus\",\n    label: \"Papus Divinatory\",\n    descriptiveDataKey: \"PAPUS_DIVINATORY\"\n  },\n  {\n    id: \"mythic\",\n    label: \"Mythic\"\n  },\n  {\n    id: \"egyptian\",\n    label: \"Egyptian\",\n    descriptiveDataKey: \"KIER_EGYPTIAN\"\n  },\n  {\n    id: \"rider-waite\",\n    label: \"Rider Waite\"\n  }\n] as const;\n\ntype TarotMajorCard = TarotCard & {\n  type: \"major\";\n  tarotCardFilename: MajorArcana;\n};\n\ntype TarotArchetypeCache = {\n  archetypes: TarotArchetype[];\n  byPathId: Map<string, TarotArchetype>;\n  byPathSlug: Map<string, TarotArchetype>;\n  byTarotCardFilename: Map<string, TarotArchetype>;\n  byTarotCardNumber: Map<number, TarotArchetype>;\n};\n\ntype TarotCardProfileCache = {\n  profiles: TarotCardProfile[];\n  byTarotArkAnnuId: Map<string, TarotCardProfile>;\n  byTarotCardName: Map<string, TarotCardProfile>;\n  byTarotCardFilename: Map<string, TarotCardProfile>;\n  byTarotCardNumber: Map<number, TarotCardProfile>;\n};\n\nlet tarotArchetypeCache: TarotArchetypeCache | undefined;\nlet tarotCardProfileCache: TarotCardProfileCache | undefined;\n\nfunction normalizePathSlug(pathSlug: string): string {\n  return pathSlug\n    .trim()\n    .replace(/^\\/?path\\//i, \"\")\n    .toLowerCase();\n}\n\nfunction normalizeTarotLookupKey(value: string): string {\n  return value.trim().toLowerCase();\n}\n\nconst TAROT_TREE_PARTS: Partial<Record<TarotTreeId, readonly [\"tarot\"]>> = {\n  kaabalah: [\"tarot\"]\n};\n\nconst TAROT_ARK_ANNU_ID_BY_NAME = new Map(\n  RAW_ARKANNUS.map((card) => [\n    normalizeTarotLookupKey(card.tarotCard),\n    id(TarotTypes.TAROT_ARK_ANNU, card.tarotCard)\n  ] as const)\n);\n\nconst TAROT_ARK_ANNU_ID_BY_FILENAME = new Map(\n  RAW_ARKANNUS.map((card) => [\n    normalizeTarotLookupKey(card.tarotCardFilename),\n    id(TarotTypes.TAROT_ARK_ANNU, card.tarotCard)\n  ] as const)\n);\n\nfunction getTarotTreeWorkspace(treeId: TarotTreeId = DEFAULT_TAROT_TREE_ID) {\n  const parts = TAROT_TREE_PARTS[treeId];\n\n  if (!parts) {\n    return undefined;\n  }\n\n  return getCanonicalTree({\n    system: treeId,\n    parts: [...parts]\n  });\n}\n\nfunction getDirectTarotCardNumber(\n  tarotArkAnnuId: NodeId<TarotTypes.TAROT_ARK_ANNU>,\n  treeId: TarotTreeId = DEFAULT_TAROT_TREE_ID\n): number | undefined {\n  const tree = getTarotTreeWorkspace(treeId);\n\n  if (!tree) {\n    return undefined;\n  }\n\n  const match = tree.getCorrespondences(tarotArkAnnuId, {\n    type: NumerologyTypes.NUMBER,\n    depth: 1,\n    limit: 1\n  })[0];\n\n  if (!match) {\n    return undefined;\n  }\n\n  return Number.parseInt(parseId(match.node.id), 10);\n}\n\nfunction buildDefaultArkannus(cards: TarotCard[]): TarotCard[] {\n  const tree = getTarotTreeWorkspace(DEFAULT_TAROT_TREE_ID);\n  const resolveNumber = (tarotCardName: string) => {\n    if (!tree) {\n      return undefined;\n    }\n\n    const match = tree.getCorrespondences(\n      id(TarotTypes.TAROT_ARK_ANNU, tarotCardName),\n      {\n        type: NumerologyTypes.NUMBER,\n        depth: 1,\n        limit: 1\n      }\n    )[0];\n\n    if (!match) {\n      return undefined;\n    }\n\n    return Number.parseInt(parseId(match.node.id), 10);\n  };\n\n  return [...cards]\n    .map((card) => ({\n      ...card,\n      number: resolveNumber(card.tarotCard) ?? card.number\n    }))\n    .sort((left, right) => {\n      if (left.number !== right.number) {\n        return left.number - right.number;\n      }\n\n      return left.tarotCard.localeCompare(right.tarotCard);\n    });\n}\n\nexport const ARKANNUS: TarotCard[] = buildDefaultArkannus(RAW_ARKANNUS);\n\nconst TAROT_COURT_RANKS = [\n  \"king\",\n  \"queen\",\n  \"knight\",\n  \"page\"\n] as const satisfies readonly TarotCourtRank[];\n\nconst MAJOR_ARCANA_CARDS = ARKANNUS.filter(\n  (card): card is TarotMajorCard =>\n    card.type === \"major\" &&\n    majorArcana.includes(card.tarotCardFilename as MajorArcana)\n);\n\nfunction toTarotCardKind(card: TarotCard): TarotCardKind {\n  if (card.type === \"major\") {\n    return \"major\";\n  }\n\n  return card.type === \"minor\" ? \"minor\" : \"court\";\n}\n\nfunction toTarotCourtRank(card: TarotCard): TarotCourtRank | undefined {\n  if (card.type !== \"daat+royalship\") {\n    return undefined;\n  }\n\n  const [rank] = card.tarotCardFilename.split(\"_\");\n  return TAROT_COURT_RANKS.includes(rank as TarotCourtRank)\n    ? (rank as TarotCourtRank)\n    : undefined;\n}\n\nfunction toTarotAssetPathType(card: TarotCard): TarotAssetPathType {\n  return card.type;\n}\n\nfunction buildTarotAssetPath(card: TarotCardProfile): string {\n  if (card.assetPathType === \"major\") {\n    return `major/${card.tarotCardFilename}`;\n  }\n\n  if (!card.suit) {\n    throw new Error(\n      `Missing suit metadata required to resolve tarot image path for ${card.tarotCardName}.`\n    );\n  }\n\n  return `${card.assetPathType}/${card.suit}/${card.tarotCardFilename}`;\n}\n\nfunction toAstrologyCorrespondence<T extends TarotAstrologyCorrespondenceType>(\n  node: Node<T>\n): TarotAstrologyCorrespondence {\n  return {\n    type: node.type,\n    id: node.id,\n    label: parseId(node.id)\n  };\n}\n\nfunction getTarotCorrespondenceTree(\n  treeId: TarotTreeId = DEFAULT_TAROT_TREE_ID\n) {\n  return getCanonicalTree({\n    system: treeId,\n    parts: [\"westernAstrology\", \"tarot\"]\n  });\n}\n\ntype TarotCorrespondenceResolvedNodeType =\n  | TarotCorrespondenceNodeType\n  | KaabalahTypes.PATH\n  | NumerologyTypes.NUMBER\n  | TarotTypes.TAROT_SUIT;\n\ntype TarotCorrespondenceSourceId = NodeId<\n  | TarotTypes.TAROT_ARK_ANNU\n  | KaabalahTypes.PATH\n  | KaabalahTypes.SPHERE\n  | TarotTypes.TAROT_SUIT\n  | WesternAstrologyTypes.WESTERN_ZODIAC_SIGN\n>;\n\nfunction getCorrespondenceNodes<T extends TarotCorrespondenceResolvedNodeType>(\n  tree: ReturnType<typeof getCanonicalTree>,\n  sourceId: TarotCorrespondenceSourceId,\n  type: T | readonly T[],\n  depth: number = 1,\n  limit?: number\n): Node<T>[] {\n  return tree.getCorrespondences(sourceId, {\n    type,\n    depth,\n    limit\n  }).map(({ node }) => node as Node<T>);\n}\n\nfunction getFirstCorrespondenceNode<\n  T extends TarotCorrespondenceResolvedNodeType\n>(\n  tree: ReturnType<typeof getCanonicalTree>,\n  sourceId: TarotCorrespondenceSourceId,\n  type: T,\n  depth: number = 1\n): Node<T> | undefined {\n  return getCorrespondenceNodes(tree, sourceId, type, depth, 1)[0];\n}\n\nfunction toCorrespondenceNode<T extends TarotCorrespondenceNodeType>(\n  node: Node<T> | undefined\n): TarotCorrespondenceNode<T> | undefined {\n  if (!node) {\n    return undefined;\n  }\n\n  return {\n    id: node.id,\n    label: parseId(node.id)\n  };\n}\n\nfunction toUniqueCorrespondenceNodes<T extends TarotCorrespondenceNodeType>(\n  nodes: Node<T>[]\n): TarotCorrespondenceNode<T>[] {\n  const seen = new Set<string>();\n\n  return nodes.flatMap((node) => {\n    const key = String(node.id);\n\n    if (seen.has(key)) {\n      return [];\n    }\n\n    seen.add(key);\n    return [toCorrespondenceNode(node)!];\n  });\n}\n\nfunction toTarotCorrespondenceProfileBase(\n  card: TarotCardProfile\n): TarotCorrespondenceProfileBase {\n  return {\n    tarotArkAnnuId: card.tarotArkAnnuId,\n    tarotCardNumber: card.tarotCardNumber,\n    tarotCardName: card.tarotCardName,\n    tarotCardFilename: card.tarotCardFilename,\n    tarotMeaning: card.tarotMeaning,\n    suit: card.suit\n  };\n}\n\nfunction resolveTarotCardProfileForTree(\n  lookup: TarotImageLookup,\n  treeId: TarotTreeId = DEFAULT_TAROT_TREE_ID\n): TarotCardProfile | undefined {\n  if (\"tarotCardNumber\" in lookup) {\n    return getTarotCardByNumber(lookup.tarotCardNumber, treeId);\n  }\n\n  return getTarotCardProfile(lookup);\n}\n\nfunction buildMajorCorrespondenceProfile(\n  card: TarotCardProfile,\n  tree: ReturnType<typeof getCanonicalTree>\n): TarotMajorCorrespondenceProfile | undefined {\n  const pathNode = getFirstCorrespondenceNode(\n    tree,\n    card.tarotArkAnnuId,\n    KaabalahTypes.PATH\n  );\n  const hebrewLetterNode = pathNode\n    ? getFirstCorrespondenceNode(\n        tree,\n        pathNode.id,\n        LetterTypes.HEBREW_LETTER\n      )\n    : undefined;\n  const pathNumberNode = pathNode\n    ? getFirstCorrespondenceNode(tree, pathNode.id, NumerologyTypes.NUMBER)\n    : undefined;\n  const pathNumber = pathNumberNode\n    ? Number.parseInt(parseId(pathNumberNode.id), 10)\n    : Number.NaN;\n  const fromSphereNode = pathNode?.data?.from\n    ? tree.getNode(pathNode.data.from)\n    : undefined;\n  const toSphereNode = pathNode?.data?.to\n    ? tree.getNode(pathNode.data.to)\n    : undefined;\n\n  if (\n    !pathNode ||\n    !hebrewLetterNode ||\n    !fromSphereNode ||\n    !toSphereNode ||\n    !Number.isFinite(pathNumber)\n  ) {\n    return undefined;\n  }\n\n  return {\n    ...toTarotCorrespondenceProfileBase(card),\n    kind: \"major\",\n    correspondences: {\n      astrology: getCorrespondenceNodes(\n        tree,\n        pathNode.id,\n        [\n          WesternAstrologyTypes.WESTERN_ELEMENT,\n          WesternAstrologyTypes.PLANET,\n          WesternAstrologyTypes.WESTERN_ZODIAC_SIGN\n        ]\n      ).map((node) =>\n        toAstrologyCorrespondence(\n          node as Node<TarotAstrologyCorrespondenceType>\n        )\n      ),\n      path: {\n        pathId: pathNode.id,\n        pathNumber,\n        pathSlug: parseId(hebrewLetterNode.id).toLowerCase(),\n        meaning: pathNode.data?.meaning,\n        hebrewLetter: toCorrespondenceNode(hebrewLetterNode)!,\n        fromSphere: toCorrespondenceNode(\n          fromSphereNode as Node<KaabalahTypes.SPHERE>\n        )!,\n        toSphere: toCorrespondenceNode(\n          toSphereNode as Node<KaabalahTypes.SPHERE>\n        )!\n      }\n    }\n  };\n}\n\nfunction buildCourtCorrespondenceProfile(\n  card: TarotCardProfile,\n  tree: ReturnType<typeof getCanonicalTree>\n):\n  | TarotPageCorrespondenceProfile\n  | TarotCourtAstrologyCorrespondenceProfile\n  | undefined {\n  const suitNode = getFirstCorrespondenceNode(\n    tree,\n    card.tarotArkAnnuId,\n    TarotTypes.TAROT_SUIT\n  );\n\n  if (!card.courtRank) {\n    return undefined;\n  }\n\n  if (card.courtRank === \"page\") {\n    const elementNode = suitNode\n      ? getFirstCorrespondenceNode(\n          tree,\n          suitNode.id,\n          WesternAstrologyTypes.WESTERN_ELEMENT\n        )\n      : undefined;\n\n    if (!elementNode) {\n      return undefined;\n    }\n\n    return {\n      ...toTarotCorrespondenceProfileBase(card),\n      kind: \"court\",\n      courtRank: \"page\",\n      correspondences: {\n        element: toCorrespondenceNode(elementNode)!\n      }\n    };\n  }\n\n  const signNode = getFirstCorrespondenceNode(\n    tree,\n    card.tarotArkAnnuId,\n    WesternAstrologyTypes.WESTERN_ZODIAC_SIGN\n  );\n\n  if (!signNode) {\n    return undefined;\n  }\n\n  return {\n    ...toTarotCorrespondenceProfileBase(card),\n    kind: \"court\",\n    courtRank: card.courtRank,\n    correspondences: {\n      sign: toCorrespondenceNode(signNode)!,\n      planets: toUniqueCorrespondenceNodes(\n        getCorrespondenceNodes(\n          tree,\n          signNode.id,\n          WesternAstrologyTypes.PLANET\n        )\n      )\n    }\n  };\n}\n\nfunction buildMinorCorrespondenceProfile(\n  card: TarotCardProfile,\n  tree: ReturnType<typeof getCanonicalTree>\n): TarotMinorCorrespondenceProfile | undefined {\n  const sphereNode = getFirstCorrespondenceNode(\n    tree,\n    card.tarotArkAnnuId,\n    KaabalahTypes.SPHERE\n  );\n\n  if (!sphereNode) {\n    return undefined;\n  }\n\n  return {\n    ...toTarotCorrespondenceProfileBase(card),\n    kind: \"minor\",\n    correspondences: {\n      sphere: toCorrespondenceNode(sphereNode)!,\n      planets: toUniqueCorrespondenceNodes(\n        getCorrespondenceNodes(tree, sphereNode.id, WesternAstrologyTypes.PLANET)\n      )\n    }\n  };\n}\n\nfunction buildDescriptionsByDeck(\n  tarotArkAnnu: Node<TarotTypes.TAROT_ARK_ANNU>\n): Partial<Record<TarotDeckId, TarotDeckDescription>> {\n  const descriptions: Partial<Record<TarotDeckId, TarotDeckDescription>> = {};\n\n  for (const deck of TAROT_DECK_METADATA) {\n    if (!deck.descriptiveDataKey) {\n      continue;\n    }\n\n    const description =\n      tarotArkAnnu.data?.descriptiveData?.[deck.descriptiveDataKey];\n\n    if (!description) {\n      continue;\n    }\n\n    descriptions[deck.id] = { ...description };\n  }\n\n  return descriptions;\n}\n\nfunction getTarotArchetypeCache(): TarotArchetypeCache {\n  if (tarotArchetypeCache) {\n    return tarotArchetypeCache;\n  }\n\n  const tree = getCanonicalTree({\n    system: \"kaabalah\",\n    parts: [\"westernAstrology\", \"tarot\"]\n  });\n\n  const archetypes = MAJOR_ARCANA_CARDS.map((card) => {\n    const pathId = id(KaabalahTypes.PATH, card.number);\n    const path = tree.getNode(pathId);\n    const hebrewLetter = tree.getCorrespondences(pathId, {\n      type: LetterTypes.HEBREW_LETTER,\n      limit: 1\n    })[0]?.node;\n    const tarotArkAnnu = tree.getCorrespondences(pathId, {\n      type: TarotTypes.TAROT_ARK_ANNU,\n      limit: 1\n    })[0]?.node;\n\n    if (!path || !hebrewLetter || !tarotArkAnnu) {\n      throw new Error(\n        `Missing canonical tarot archetype metadata for ${pathId}.`\n      );\n    }\n\n    const astrology = tree.getCorrespondences(pathId, {\n      type: [\n        WesternAstrologyTypes.WESTERN_ELEMENT,\n        WesternAstrologyTypes.PLANET,\n        WesternAstrologyTypes.WESTERN_ZODIAC_SIGN\n      ]\n    }).map(({ node }) =>\n      toAstrologyCorrespondence(\n        node as Node<TarotAstrologyCorrespondenceType>\n      )\n    );\n\n    const descriptionsByDeck = buildDescriptionsByDeck(tarotArkAnnu);\n\n    return {\n      canonicalId: pathId,\n      kind: \"major\" as const,\n      pathId,\n      pathNumber: card.number,\n      pathSlug: parseId(hebrewLetter.id).toLowerCase(),\n      hebrewLetterId: hebrewLetter.id,\n      hebrewLetter: parseId(hebrewLetter.id),\n      pathMeaning: path.data?.meaning,\n      tarotArkAnnuId: tarotArkAnnu.id,\n      tarotCardNumber: card.number,\n      tarotCardName: parseId(tarotArkAnnu.id),\n      tarotCardFilename: card.tarotCardFilename,\n      tarotMeaning:\n        descriptionsByDeck.papus_pt?.meaning ??\n        card.meaning,\n      astrology,\n      availableDeckIds: TAROT_DECK_METADATA.map((deck) => deck.id),\n      descriptionsByDeck\n    };\n  });\n\n  tarotArchetypeCache = {\n    archetypes,\n    byPathId: new Map(archetypes.map((archetype) => [archetype.pathId, archetype])),\n    byPathSlug: new Map(\n      archetypes.map((archetype) => [archetype.pathSlug, archetype])\n    ),\n    byTarotCardFilename: new Map(\n      archetypes.map((archetype) => [archetype.tarotCardFilename, archetype])\n    ),\n    byTarotCardNumber: new Map(\n      archetypes.map((archetype) => [archetype.tarotCardNumber, archetype])\n    )\n  };\n\n  return tarotArchetypeCache;\n}\n\nfunction getTarotCardProfileCache(): TarotCardProfileCache {\n  if (tarotCardProfileCache) {\n    return tarotCardProfileCache;\n  }\n\n  const tree = getCanonicalTree({\n    system: \"kaabalah\",\n    parts: [\"westernAstrology\", \"tarot\"]\n  });\n  const availableDeckIds = TAROT_DECK_METADATA.map((deck) => deck.id);\n\n  const profiles = ARKANNUS.map((card) => {\n    const tarotArkAnnuId = id(TarotTypes.TAROT_ARK_ANNU, card.tarotCard);\n    const tarotArkAnnu = tree.getNode(tarotArkAnnuId);\n\n    if (!tarotArkAnnu) {\n      throw new Error(`Missing canonical tarot metadata for ${tarotArkAnnuId}.`);\n    }\n\n    const descriptionsByDeck = buildDescriptionsByDeck(tarotArkAnnu);\n\n    return {\n      tarotArkAnnuId,\n      tarotCardNumber: card.number,\n      tarotCardName: card.tarotCard,\n      tarotCardFilename: card.tarotCardFilename,\n      tarotMeaning:\n        descriptionsByDeck.papus_pt?.meaning ??\n        card.meaning,\n      kind: toTarotCardKind(card),\n      assetPathType: toTarotAssetPathType(card),\n      suit: card.suit,\n      courtRank: toTarotCourtRank(card),\n      availableDeckIds,\n      descriptionsByDeck\n    };\n  });\n\n  tarotCardProfileCache = {\n    profiles,\n    byTarotArkAnnuId: new Map(\n      profiles.map((profile) => [String(profile.tarotArkAnnuId), profile])\n    ),\n    byTarotCardName: new Map(\n      profiles.map((profile) => [\n        normalizeTarotLookupKey(profile.tarotCardName),\n        profile\n      ])\n    ),\n    byTarotCardFilename: new Map(\n      profiles.map((profile) => [\n        normalizeTarotLookupKey(profile.tarotCardFilename),\n        profile\n      ])\n    ),\n    byTarotCardNumber: new Map(\n      profiles.map((profile) => [profile.tarotCardNumber, profile])\n    )\n  };\n\n  return tarotCardProfileCache;\n}\n\nfunction buildTarotRepresentation(\n  card: TarotCardProfile,\n  deck: TarotDeckConfig\n): TarotRepresentation {\n  const description = card.descriptionsByDeck[deck.id];\n  const assetPath = buildTarotAssetPath(card);\n  const imageUrl = `${TAROT_IMAGE_BASE_URL}/${deck.id}/${assetPath}.jpg`;\n\n  return {\n    card,\n    archetype: card.kind === \"major\"\n      ? getTarotArchetype({ tarotCardNumber: card.tarotCardNumber })\n      : undefined,\n    deck: { id: deck.id, label: deck.label },\n    assetPath,\n    imageUrl,\n    label: `${card.tarotCardName} - ${deck.label}`,\n    altText: `${card.tarotCardName} - ${deck.label}`,\n    cardLabel: description?.name ?? card.tarotCardName,\n    description\n  };\n}\n\nfunction resolveTarotArkAnnuId(\n  lookup: TarotImageLookup\n): NodeId<TarotTypes.TAROT_ARK_ANNU> | undefined {\n  if (\"pathSlug\" in lookup || \"pathId\" in lookup) {\n    return getTarotArchetype(lookup)?.tarotArkAnnuId;\n  }\n\n  if (\"tarotArkAnnuId\" in lookup) {\n    return lookup.tarotArkAnnuId;\n  }\n\n  if (\"tarotCardName\" in lookup) {\n    return TAROT_ARK_ANNU_ID_BY_NAME.get(\n      normalizeTarotLookupKey(lookup.tarotCardName)\n    );\n  }\n\n  if (\"tarotCardFilename\" in lookup) {\n    return TAROT_ARK_ANNU_ID_BY_FILENAME.get(\n      normalizeTarotLookupKey(lookup.tarotCardFilename)\n    );\n  }\n\n  return undefined;\n}\n\nexport function getTarotCardProfile(\n  lookup: TarotImageLookup\n): TarotCardProfile | undefined {\n  const cache = getTarotCardProfileCache();\n\n  if (\"pathSlug\" in lookup || \"pathId\" in lookup) {\n    const archetype = getTarotArchetype(lookup);\n    return archetype\n      ? cache.byTarotCardNumber.get(archetype.tarotCardNumber)\n      : undefined;\n  }\n\n  if (\"tarotArkAnnuId\" in lookup) {\n    return cache.byTarotArkAnnuId.get(String(lookup.tarotArkAnnuId));\n  }\n\n  if (\"tarotCardName\" in lookup) {\n    return cache.byTarotCardName.get(\n      normalizeTarotLookupKey(lookup.tarotCardName)\n    );\n  }\n\n  if (\"tarotCardFilename\" in lookup) {\n    return cache.byTarotCardFilename.get(\n      normalizeTarotLookupKey(lookup.tarotCardFilename)\n    );\n  }\n\n  return getTarotCardByNumber(lookup.tarotCardNumber);\n}\n\nexport function listTarotDecks(): TarotDeckMetadata[] {\n  return TAROT_DECK_METADATA.map(({ id, label }) => ({ id, label }));\n}\n\nexport function listTarotTrees(): TarotTreeId[] {\n  return [...TAROT_TREE_IDS];\n}\n\nexport function getTarotCardNumber(\n  lookup: TarotImageLookup,\n  treeId: TarotTreeId = DEFAULT_TAROT_TREE_ID\n): number | undefined {\n  if (\"tarotCardNumber\" in lookup) {\n    return getTarotCardByNumber(lookup.tarotCardNumber, treeId)\n      ?.tarotCardNumber;\n  }\n\n  const tarotArkAnnuId = resolveTarotArkAnnuId(lookup);\n\n  if (!tarotArkAnnuId) {\n    return undefined;\n  }\n\n  return getDirectTarotCardNumber(tarotArkAnnuId, treeId);\n}\n\nexport function getTarotCardByNumber(\n  cardNumber: number,\n  treeId: TarotTreeId = DEFAULT_TAROT_TREE_ID\n): TarotCardProfile | undefined {\n  const tree = getTarotTreeWorkspace(treeId);\n\n  if (!tree) {\n    return undefined;\n  }\n\n  const match = tree.getCorrespondences(id(NumerologyTypes.NUMBER, cardNumber), {\n    type: TarotTypes.TAROT_ARK_ANNU,\n    depth: 1,\n    limit: 1\n  })[0];\n\n  if (!match) {\n    return undefined;\n  }\n\n  const profile = getTarotCardProfile({\n    tarotArkAnnuId: match.node.id as NodeId<TarotTypes.TAROT_ARK_ANNU>\n  });\n\n  if (!profile || profile.tarotCardNumber === cardNumber) {\n    return profile;\n  }\n\n  return {\n    ...profile,\n    tarotCardNumber: cardNumber\n  };\n}\n\nexport function getTarotArchetype(\n  lookup: TarotArchetypeLookup\n): TarotArchetype | undefined {\n  const cache = getTarotArchetypeCache();\n\n  if (\"pathSlug\" in lookup) {\n    return cache.byPathSlug.get(normalizePathSlug(lookup.pathSlug));\n  }\n\n  if (\"pathId\" in lookup) {\n    return cache.byPathId.get(String(lookup.pathId));\n  }\n\n  if (\"tarotCardFilename\" in lookup) {\n    return cache.byTarotCardFilename.get(\n      lookup.tarotCardFilename.toLowerCase()\n    );\n  }\n\n  return cache.byTarotCardNumber.get(lookup.tarotCardNumber);\n}\n\nexport function getTarotCorrespondenceProfile(\n  lookup: TarotImageLookup,\n  treeId: TarotTreeId = DEFAULT_TAROT_TREE_ID\n): TarotCorrespondenceProfile | undefined {\n  const card = resolveTarotCardProfileForTree(lookup, treeId);\n\n  if (!card) {\n    return undefined;\n  }\n\n  const tree = getTarotCorrespondenceTree(treeId);\n\n  switch (card.kind) {\n    case \"major\":\n      return buildMajorCorrespondenceProfile(card, tree);\n    case \"court\":\n      return buildCourtCorrespondenceProfile(card, tree);\n    case \"minor\":\n      return buildMinorCorrespondenceProfile(card, tree);\n  }\n}\n\nexport function getTarotRepresentations(\n  lookup: TarotImageLookup\n): TarotRepresentation[] {\n  const card = getTarotCardProfile(lookup);\n\n  if (!card) {\n    return [];\n  }\n\n  return TAROT_DECK_METADATA.map((deck) =>\n    buildTarotRepresentation(card, deck)\n  );\n}\n\nexport function getTarotRepresentation(\n  lookup: TarotImageLookup,\n  deckId: TarotDeckId\n): TarotRepresentation | undefined {\n  const card = getTarotCardProfile(lookup);\n  const deck = TAROT_DECK_METADATA.find((candidate) => candidate.id === deckId);\n\n  if (!card || !deck) {\n    return undefined;\n  }\n\n  return buildTarotRepresentation(card, deck);\n}\n\nexport function resolveTarotImageUrl(\n  lookup: TarotImageLookup,\n  deckId: TarotDeckId\n): string | undefined {\n  return getTarotRepresentation(lookup, deckId)?.imageUrl;\n}\n\nexport type TarotSpreadId =\n  | \"quick-insight\"\n  | \"conscious-reading\"\n  | \"time-reading\"\n  | \"dialectic-reading\"\n  | \"tree-of-life-reading\"\n  | \"celtic-cross\"\n  | \"event-reading\";\n\nexport type TarotSpreadContextKey = \"inquirerGender\";\nexport type TarotInquirerGender = \"man\" | \"woman\";\nexport type TarotSpreadCardType = TarotCard[\"type\"];\nexport type TarotSpreadMinorRank =\n  | \"ace\"\n  | \"2\"\n  | \"3\"\n  | \"4\"\n  | \"5\"\n  | \"6\"\n  | \"7\"\n  | \"8\"\n  | \"9\"\n  | \"10\";\n\nexport interface TarotSpreadCardConstraint {\n  allowedTypes?: TarotSpreadCardType[];\n  requiredRank?: TarotSpreadMinorRank;\n  allowedCardFilenames?: string[];\n  excludedCardFilenames?: string[];\n}\n\nexport interface TarotSpreadSlotMetadata {\n  displayLabel?: string;\n  groupKey?: string;\n  note?: string;\n  orientation?: \"upright\" | \"sideways\";\n  temporalPhase?: \"past\" | \"present\" | \"future\";\n}\n\nexport interface TarotSpreadSlotDefinition {\n  slotKey: string;\n  label: string;\n  order: number;\n  minCards: number;\n  maxCards: number;\n  validationRules?: TarotSpreadCardConstraint;\n  manualSelectionRules?: TarotSpreadCardConstraint;\n  drawRules?: TarotSpreadCardConstraint;\n  metadata?: TarotSpreadSlotMetadata;\n}\n\nexport interface TarotSpreadInquirerRule {\n  slotKey: string;\n  sourceSlotKeys: string[];\n  cardNumbersByGender: Record<TarotInquirerGender, number>;\n}\n\nexport interface TarotSpreadDefinition {\n  spreadId: TarotSpreadId;\n  label: string;\n  description?: string;\n  contextRequirements?: TarotSpreadContextKey[];\n  slots: TarotSpreadSlotDefinition[];\n  specialRules?: {\n    inquirerCard?: TarotSpreadInquirerRule;\n  };\n}\n\nexport interface TarotSpreadSelectionContext {\n  inquirerGender?: TarotInquirerGender;\n}\n\nexport interface TarotSpreadSelectionCard {\n  slotKey: string;\n  cardNumber: number;\n  isInverted?: boolean;\n}\n\nexport interface TarotSpreadResolvedSelectionCard\n  extends TarotSpreadSelectionCard {\n  card: TarotCard;\n  slot: TarotSpreadSlotDefinition;\n}\n\nexport type TarotSpreadValidationErrorCode =\n  | \"UNKNOWN_SPREAD\"\n  | \"UNKNOWN_SLOT\"\n  | \"CARD_NOT_FOUND\"\n  | \"DUPLICATE_CARD\"\n  | \"MISSING_REQUIRED_CARDS\"\n  | \"TOO_MANY_CARDS\"\n  | \"INVALID_CARD_TYPE\"\n  | \"INVALID_CARD_RANK\"\n  | \"DISALLOWED_CARD\"\n  | \"MISSING_CONTEXT\"\n  | \"INVALID_INQUIRER_CARD\";\n\nexport interface TarotSpreadValidationIssue {\n  code: TarotSpreadValidationErrorCode;\n  message: string;\n  slotKey?: string;\n  cardNumber?: number;\n}\n\nexport interface TarotSpreadValidationResult {\n  ok: boolean;\n  isComplete: boolean;\n  spread?: TarotSpreadDefinition;\n  resolvedCards: TarotSpreadResolvedSelectionCard[];\n  errors: TarotSpreadValidationIssue[];\n}\n\nexport interface TarotSpreadValidationInput {\n  spreadId: TarotSpreadId;\n  cards: TarotSpreadSelectionCard[];\n  context?: TarotSpreadSelectionContext;\n  allowPartial?: boolean;\n}\n\nexport interface DrawTarotSpreadOptions {\n  spreadId: TarotSpreadId;\n  deckId?: TarotDeckId;\n  includeInverted?: boolean;\n  rng?: () => number;\n  context?: TarotSpreadSelectionContext;\n}\n\nexport interface TarotSpreadDrawResult {\n  spread: TarotSpreadDefinition;\n  deckId: TarotDeckId;\n  context?: TarotSpreadSelectionContext;\n  cards: TarotSpreadResolvedSelectionCard[];\n}\n\nconst TAROT_SPREAD_MINOR_RANKS: readonly TarotSpreadMinorRank[] = [\n  \"ace\",\n  \"2\",\n  \"3\",\n  \"4\",\n  \"5\",\n  \"6\",\n  \"7\",\n  \"8\",\n  \"9\",\n  \"10\"\n];\n\nconst EVENT_INNER_SLOT_KEYS = [\n  \"inner-1\",\n  \"inner-2\",\n  \"inner-3\",\n  \"inner-4\",\n  \"inner-5\",\n  \"inner-6\",\n  \"inner-7\"\n] as const;\n\nconst TAROT_CARD_BY_NUMBER = new Map(\n  ARKANNUS.map((card) => [card.number, card] as const)\n);\n\nfunction createEventOuterSlot(\n  index: number,\n  temporalPhase: TarotSpreadSlotMetadata[\"temporalPhase\"]\n): TarotSpreadSlotDefinition {\n  return {\n    slotKey: `outer-${index}`,\n    label: String(index),\n    order: index,\n    minCards: 1,\n    maxCards: 1,\n    validationRules: {\n      allowedTypes: [\"minor\", \"daat+royalship\"]\n    },\n    manualSelectionRules: {\n      allowedTypes: [\"minor\", \"daat+royalship\"]\n    },\n    drawRules: {\n      allowedTypes: [\"minor\", \"daat+royalship\"]\n    },\n    metadata: {\n      displayLabel: String(index),\n      groupKey: \"outer\",\n      temporalPhase\n    }\n  };\n}\n\nfunction createEventInnerSlot(\n  index: number,\n  label: string,\n  note: string\n): TarotSpreadSlotDefinition {\n  return {\n    slotKey: `inner-${index}`,\n    label,\n    order: 100 + index,\n    minCards: 1,\n    maxCards: 1,\n    validationRules: {\n      allowedTypes: [\"major\"]\n    },\n    manualSelectionRules: {\n      allowedTypes: [\"major\"],\n      excludedCardFilenames: [\n        \"01_the_magician\",\n        \"02_the_high_priestess\"\n      ]\n    },\n    drawRules: {\n      allowedTypes: [\"major\"]\n    },\n    metadata: {\n      displayLabel: `${index}.`,\n      groupKey: \"inner\",\n      note\n    }\n  };\n}\n\nconst TAROT_SPREADS: readonly TarotSpreadDefinition[] = [\n  {\n    spreadId: \"quick-insight\",\n    label: \"Quick Insight\",\n    description: \"A single-card reading for immediate insight.\",\n    slots: [\n      {\n        slotKey: \"quick-insight\",\n        label: \"Quick Insight\",\n        order: 1,\n        minCards: 1,\n        maxCards: 1\n      }\n    ]\n  },\n  {\n    spreadId: \"conscious-reading\",\n    label: \"Conscious Reading\",\n    description:\n      \"Three-card spread for conscious, unconscious, and subconscious layers.\",\n    slots: [\n      {\n        slotKey: \"conscious\",\n        label: \"Conscious\",\n        order: 1,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"major\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"major\"]\n        },\n        drawRules: {\n          allowedTypes: [\"major\"]\n        }\n      },\n      {\n        slotKey: \"unconscious\",\n        label: \"Unconscious\",\n        order: 2,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"daat+royalship\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"daat+royalship\"]\n        },\n        drawRules: {\n          allowedTypes: [\"daat+royalship\"]\n        }\n      },\n      {\n        slotKey: \"subconscious\",\n        label: \"Subconscious\",\n        order: 3,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"]\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"]\n        }\n      }\n    ]\n  },\n  {\n    spreadId: \"time-reading\",\n    label: \"Time Reading\",\n    description: \"Three major arcana cards for past, present, and future.\",\n    slots: [\n      {\n        slotKey: \"past\",\n        label: \"Past\",\n        order: 1,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"major\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"major\"]\n        },\n        drawRules: {\n          allowedTypes: [\"major\"]\n        }\n      },\n      {\n        slotKey: \"present\",\n        label: \"Present\",\n        order: 2,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"major\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"major\"]\n        },\n        drawRules: {\n          allowedTypes: [\"major\"]\n        }\n      },\n      {\n        slotKey: \"future\",\n        label: \"Future\",\n        order: 3,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"major\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"major\"]\n        },\n        drawRules: {\n          allowedTypes: [\"major\"]\n        }\n      }\n    ]\n  },\n  {\n    spreadId: \"dialectic-reading\",\n    label: \"Dialectic Reading\",\n    description: \"Three major arcana cards for thesis, antithesis, and synthesis.\",\n    slots: [\n      {\n        slotKey: \"thesis\",\n        label: \"Thesis\",\n        order: 1,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"major\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"major\"]\n        },\n        drawRules: {\n          allowedTypes: [\"major\"]\n        }\n      },\n      {\n        slotKey: \"antithesis\",\n        label: \"Antithesis\",\n        order: 2,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"major\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"major\"]\n        },\n        drawRules: {\n          allowedTypes: [\"major\"]\n        }\n      },\n      {\n        slotKey: \"synthesis\",\n        label: \"Synthesis\",\n        order: 3,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"major\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"major\"]\n        },\n        drawRules: {\n          allowedTypes: [\"major\"]\n        }\n      }\n    ]\n  },\n  {\n    spreadId: \"tree-of-life-reading\",\n    label: \"Tree of Life Reading\",\n    description:\n      \"Ten numbered minor arcana slots mapped to the spheres plus four Daath court cards.\",\n    slots: [\n      {\n        slotKey: \"kether\",\n        label: \"Kether\",\n        order: 1,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"ace\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"ace\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"ace\"\n        }\n      },\n      {\n        slotKey: \"chokhmah\",\n        label: \"Chokhmah\",\n        order: 2,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"2\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"2\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"2\"\n        }\n      },\n      {\n        slotKey: \"binah\",\n        label: \"Binah\",\n        order: 3,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"3\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"3\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"3\"\n        }\n      },\n      {\n        slotKey: \"chesed\",\n        label: \"Chesed\",\n        order: 4,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"4\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"4\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"4\"\n        }\n      },\n      {\n        slotKey: \"geburah\",\n        label: \"Geburah\",\n        order: 5,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"5\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"5\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"5\"\n        }\n      },\n      {\n        slotKey: \"tiphareth\",\n        label: \"Tiphareth\",\n        order: 6,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"6\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"6\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"6\"\n        }\n      },\n      {\n        slotKey: \"netzach\",\n        label: \"Netzach\",\n        order: 7,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"7\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"7\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"7\"\n        }\n      },\n      {\n        slotKey: \"hod\",\n        label: \"Hod\",\n        order: 8,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"8\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"8\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"8\"\n        }\n      },\n      {\n        slotKey: \"yesod\",\n        label: \"Yesod\",\n        order: 9,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"9\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"9\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"9\"\n        }\n      },\n      {\n        slotKey: \"malkuth\",\n        label: \"Malkuth\",\n        order: 10,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"10\"\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"10\"\n        },\n        drawRules: {\n          allowedTypes: [\"minor\"],\n          requiredRank: \"10\"\n        }\n      },\n      {\n        slotKey: \"daath\",\n        label: \"Daath\",\n        order: 11,\n        minCards: 4,\n        maxCards: 4,\n        validationRules: {\n          allowedTypes: [\"daat+royalship\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"daat+royalship\"]\n        },\n        drawRules: {\n          allowedTypes: [\"daat+royalship\"]\n        }\n      }\n    ]\n  },\n  {\n    spreadId: \"celtic-cross\",\n    label: \"Celtic Cross\",\n    description: \"Classic ten-card Celtic Cross spread.\",\n    slots: [\n      {\n        slotKey: \"present\",\n        label: \"The Present\",\n        order: 1,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"1.\"\n        }\n      },\n      {\n        slotKey: \"challenge\",\n        label: \"The Challenge\",\n        order: 2,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"2.\",\n          orientation: \"sideways\"\n        }\n      },\n      {\n        slotKey: \"above\",\n        label: \"Above\",\n        order: 3,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"3.\"\n        }\n      },\n      {\n        slotKey: \"below\",\n        label: \"Below\",\n        order: 4,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"4.\"\n        }\n      },\n      {\n        slotKey: \"behind\",\n        label: \"Behind\",\n        order: 5,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"5.\"\n        }\n      },\n      {\n        slotKey: \"before\",\n        label: \"Before\",\n        order: 6,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"6.\"\n        }\n      },\n      {\n        slotKey: \"self\",\n        label: \"Self\",\n        order: 7,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"7.\"\n        }\n      },\n      {\n        slotKey: \"environment\",\n        label: \"Environment\",\n        order: 8,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"8.\"\n        }\n      },\n      {\n        slotKey: \"hopes-fears\",\n        label: \"Hopes/Fears\",\n        order: 9,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"9.\"\n        }\n      },\n      {\n        slotKey: \"outcome\",\n        label: \"Outcome\",\n        order: 10,\n        minCards: 1,\n        maxCards: 1,\n        metadata: {\n          displayLabel: \"10.\"\n        }\n      }\n    ]\n  },\n  {\n    spreadId: \"event-reading\",\n    label: \"Event Reading\",\n    description:\n      \"Papus-style event spread with outer minor/court cards, seven major cards, and an inquirer card.\",\n    contextRequirements: [\"inquirerGender\"],\n    slots: [\n      createEventOuterSlot(1, \"past\"),\n      createEventOuterSlot(2, \"past\"),\n      createEventOuterSlot(3, \"past\"),\n      createEventOuterSlot(4, \"past\"),\n      createEventOuterSlot(5, \"present\"),\n      createEventOuterSlot(6, \"present\"),\n      createEventOuterSlot(7, \"present\"),\n      createEventOuterSlot(8, \"present\"),\n      createEventOuterSlot(9, \"future\"),\n      createEventOuterSlot(10, \"future\"),\n      createEventOuterSlot(11, \"future\"),\n      createEventOuterSlot(12, \"future\"),\n      createEventInnerSlot(\n        1,\n        \"Commencement\",\n        \"Character of the beginning phase.\"\n      ),\n      createEventInnerSlot(2, \"Apogee\", \"Peak or zenith of the event.\"),\n      createEventInnerSlot(\n        3,\n        \"Decline/Obstacle\",\n        \"Challenges, obstacles, or decline.\"\n      ),\n      createEventInnerSlot(4, \"Fall\", \"Conclusion or end phase.\"),\n      createEventInnerSlot(\n        5,\n        \"The Past\",\n        \"Special character or influence in the past.\"\n      ),\n      createEventInnerSlot(\n        6,\n        \"The Present\",\n        \"Special character or influence in the present.\"\n      ),\n      createEventInnerSlot(\n        7,\n        \"The Future\",\n        \"Special character or influence to come.\"\n      ),\n      {\n        slotKey: \"inquirer\",\n        label: \"Inquirer\",\n        order: 200,\n        minCards: 1,\n        maxCards: 1,\n        validationRules: {\n          allowedTypes: [\"major\"]\n        },\n        manualSelectionRules: {\n          allowedTypes: [\"major\"],\n          allowedCardFilenames: [\n            \"01_the_magician\",\n            \"02_the_high_priestess\"\n          ]\n        },\n        drawRules: {\n          allowedTypes: [\"major\"]\n        },\n        metadata: {\n          displayLabel: \"Inquirer\",\n          groupKey: \"center\",\n          note: \"The querent's energy in this reading.\"\n        }\n      }\n    ],\n    specialRules: {\n      inquirerCard: {\n        slotKey: \"inquirer\",\n        sourceSlotKeys: [...EVENT_INNER_SLOT_KEYS],\n        cardNumbersByGender: {\n          man: 1,\n          woman: 2\n        }\n      }\n    }\n  }\n] as const;\n\nconst TAROT_SPREAD_BY_ID = new Map(\n  TAROT_SPREADS.map((spread) => [spread.spreadId, spread] as const)\n);\n\nfunction cloneCardConstraint(\n  constraint?: TarotSpreadCardConstraint\n): TarotSpreadCardConstraint | undefined {\n  if (!constraint) {\n    return undefined;\n  }\n\n  return {\n    allowedTypes: constraint.allowedTypes\n      ? [...constraint.allowedTypes]\n      : undefined,\n    requiredRank: constraint.requiredRank,\n    allowedCardFilenames: constraint.allowedCardFilenames\n      ? [...constraint.allowedCardFilenames]\n      : undefined,\n    excludedCardFilenames: constraint.excludedCardFilenames\n      ? [...constraint.excludedCardFilenames]\n      : undefined\n  };\n}\n\nfunction cloneSlotDefinition(\n  slot: TarotSpreadSlotDefinition\n): TarotSpreadSlotDefinition {\n  return {\n    ...slot,\n    validationRules: cloneCardConstraint(slot.validationRules),\n    manualSelectionRules: cloneCardConstraint(slot.manualSelectionRules),\n    drawRules: cloneCardConstraint(slot.drawRules),\n    metadata: slot.metadata ? { ...slot.metadata } : undefined\n  };\n}\n\nfunction cloneSpreadDefinition(\n  spread: TarotSpreadDefinition\n): TarotSpreadDefinition {\n  return {\n    ...spread,\n    contextRequirements: spread.contextRequirements\n      ? [...spread.contextRequirements]\n      : undefined,\n    slots: spread.slots.map(cloneSlotDefinition),\n    specialRules: spread.specialRules?.inquirerCard\n      ? {\n          inquirerCard: {\n            slotKey: spread.specialRules.inquirerCard.slotKey,\n            sourceSlotKeys: [...spread.specialRules.inquirerCard.sourceSlotKeys],\n            cardNumbersByGender: {\n              ...spread.specialRules.inquirerCard.cardNumbersByGender\n            }\n          }\n        }\n      : undefined\n  };\n}\n\nfunction getTarotDeckCardByNumber(cardNumber: number): TarotCard | undefined {\n  return TAROT_CARD_BY_NUMBER.get(cardNumber);\n}\n\nfunction getTarotSpreadRuleForValidation(\n  slot: TarotSpreadSlotDefinition\n): TarotSpreadCardConstraint | undefined {\n  return slot.validationRules ?? slot.drawRules ?? slot.manualSelectionRules;\n}\n\nfunction getTarotSpreadRuleForDraw(\n  slot: TarotSpreadSlotDefinition\n): TarotSpreadCardConstraint | undefined {\n  return slot.drawRules ?? slot.validationRules ?? slot.manualSelectionRules;\n}\n\nfunction getTarotMinorRank(\n  card: TarotCard\n): TarotSpreadMinorRank | undefined {\n  if (card.type !== \"minor\") {\n    return undefined;\n  }\n\n  const rank = card.tarotCardFilename.split(\"_\")[0] as TarotSpreadMinorRank;\n  return TAROT_SPREAD_MINOR_RANKS.includes(rank) ? rank : undefined;\n}\n\nfunction matchesTarotSpreadConstraint(\n  card: TarotCard,\n  constraint?: TarotSpreadCardConstraint\n): boolean {\n  if (!constraint) {\n    return true;\n  }\n\n  if (\n    constraint.allowedTypes &&\n    !constraint.allowedTypes.includes(card.type)\n  ) {\n    return false;\n  }\n\n  if (\n    constraint.allowedCardFilenames &&\n    !constraint.allowedCardFilenames.includes(card.tarotCardFilename)\n  ) {\n    return false;\n  }\n\n  if (\n    constraint.excludedCardFilenames &&\n    constraint.excludedCardFilenames.includes(card.tarotCardFilename)\n  ) {\n    return false;\n  }\n\n  if (constraint.requiredRank) {\n    return getTarotMinorRank(card) === constraint.requiredRank;\n  }\n\n  return true;\n}\n\nfunction randomIndex(length: number, rng: () => number): number {\n  if (length <= 0) {\n    throw new Error(\"Cannot draw from an empty pool.\");\n  }\n\n  const raw = rng();\n  if (!Number.isFinite(raw)) {\n    throw new Error(\"Tarot spread RNG must return a finite number.\");\n  }\n\n  const normalized = Math.min(Math.max(raw, 0), 1 - Number.EPSILON);\n  return Math.floor(normalized * length);\n}\n\nfunction withSpreadCardOrientation(\n  card: TarotCard,\n  includeInverted: boolean,\n  rng: () => number\n): TarotCard {\n  return {\n    ...card,\n    isInverted: includeInverted ? rng() < 0.5 : false\n  };\n}\n\nfunction resolveTarotSpreadSelectionCard(\n  card: TarotSpreadSelectionCard,\n  slot: TarotSpreadSlotDefinition,\n  tarotCard: TarotCard\n): TarotSpreadResolvedSelectionCard {\n  return {\n    ...card,\n    slot,\n    card: {\n      ...tarotCard,\n      isInverted: card.isInverted ?? false\n    }\n  };\n}\n\nfunction sortResolvedTarotSpreadCards(\n  resolvedCards: TarotSpreadResolvedSelectionCard[]\n): TarotSpreadResolvedSelectionCard[] {\n  return [...resolvedCards].sort((left, right) => {\n    if (left.slot.order !== right.slot.order) {\n      return left.slot.order - right.slot.order;\n    }\n\n    return left.card.number - right.card.number;\n  });\n}\n\nfunction validateEventInquirerCard(\n  spread: TarotSpreadDefinition,\n  resolvedCards: TarotSpreadResolvedSelectionCard[],\n  context: TarotSpreadSelectionContext | undefined,\n  errors: TarotSpreadValidationIssue[]\n): void {\n  const inquirerRule = spread.specialRules?.inquirerCard;\n\n  if (!inquirerRule) {\n    return;\n  }\n\n  if (!context?.inquirerGender) {\n    return;\n  }\n\n  const inquirerCardNumber =\n    inquirerRule.cardNumbersByGender[context.inquirerGender];\n  const sourceCards = resolvedCards.filter((card) =>\n    inquirerRule.sourceSlotKeys.includes(card.slotKey)\n  );\n  const inquirerCards = resolvedCards.filter(\n    (card) => card.slotKey === inquirerRule.slotKey\n  );\n\n  if (inquirerCards.length !== 1) {\n    return;\n  }\n\n  const sourceContainsGenderCard = sourceCards.some(\n    (card) => card.card.number === inquirerCardNumber\n  );\n  const totalGenderCardCount = [...sourceCards, ...inquirerCards].filter(\n    (card) => card.card.number === inquirerCardNumber\n  ).length;\n\n  if (totalGenderCardCount !== 1) {\n    errors.push({\n      code: \"INVALID_INQUIRER_CARD\",\n      slotKey: inquirerRule.slotKey,\n      cardNumber: inquirerCardNumber,\n      message:\n        \"Event Reading must contain the gendered inquirer card exactly once across the major arcana band and inquirer slot.\"\n    });\n    return;\n  }\n\n  if (\n    !sourceContainsGenderCard &&\n    inquirerCards[0].card.number !== inquirerCardNumber\n  ) {\n    errors.push({\n      code: \"INVALID_INQUIRER_CARD\",\n      slotKey: inquirerRule.slotKey,\n      cardNumber: inquirerCards[0].card.number,\n      message:\n        \"When the inquirer card was not drawn in the seven major slots, it must occupy the Inquirer slot.\"\n    });\n  }\n}\n\nfunction pickTarotCardFromPool(\n  pool: TarotCard[],\n  constraint: TarotSpreadCardConstraint | undefined,\n  rng: () => number\n): TarotCard {\n  const candidateIndexes = pool.reduce<number[]>((indexes, card, index) => {\n    if (matchesTarotSpreadConstraint(card, constraint)) {\n      indexes.push(index);\n    }\n\n    return indexes;\n  }, []);\n\n  if (candidateIndexes.length === 0) {\n    throw new Error(\"Unable to draw a tarot card that satisfies the spread rule.\");\n  }\n\n  const pickedIndex = candidateIndexes[randomIndex(candidateIndexes.length, rng)];\n  const [pickedCard] = pool.splice(pickedIndex, 1);\n\n  return pickedCard;\n}\n\nfunction buildResolvedDrawnCard(\n  slot: TarotSpreadSlotDefinition,\n  card: TarotCard,\n  includeInverted: boolean,\n  rng: () => number\n): TarotSpreadResolvedSelectionCard {\n  const drawnCard = withSpreadCardOrientation(card, includeInverted, rng);\n\n  return {\n    slotKey: slot.slotKey,\n    cardNumber: drawnCard.number,\n    isInverted: drawnCard.isInverted ?? false,\n    slot,\n    card: drawnCard\n  };\n}\n\nfunction drawDefaultTarotSpread(\n  spread: TarotSpreadDefinition,\n  includeInverted: boolean,\n  rng: () => number\n): TarotSpreadResolvedSelectionCard[] {\n  const deckPool = [...ARKANNUS];\n  const drawnCards: TarotSpreadResolvedSelectionCard[] = [];\n\n  for (const slot of spread.slots.slice().sort((left, right) => left.order - right.order)) {\n    const drawRule = getTarotSpreadRuleForDraw(slot);\n\n    for (let index = 0; index < slot.maxCards; index += 1) {\n      const card = pickTarotCardFromPool(deckPool, drawRule, rng);\n      drawnCards.push(\n        buildResolvedDrawnCard(slot, card, includeInverted, rng)\n      );\n    }\n  }\n\n  return drawnCards;\n}\n\nfunction drawEventReadingSpread(\n  spread: TarotSpreadDefinition,\n  includeInverted: boolean,\n  rng: () => number,\n  context: TarotSpreadSelectionContext | undefined\n): TarotSpreadResolvedSelectionCard[] {\n  const inquirerRule = spread.specialRules?.inquirerCard;\n\n  if (!inquirerRule || !context?.inquirerGender) {\n    throw new Error(\n      \"Event Reading draw requires `context.inquirerGender`.\"\n    );\n  }\n\n  const slotsByKey = new Map(\n    spread.slots.map((slot) => [slot.slotKey, slot] as const)\n  );\n  const outerPool = ARKANNUS.filter(\n    (card) => card.type === \"minor\" || card.type === \"daat+royalship\"\n  );\n  const majorPool = ARKANNUS.filter((card) => card.type === \"major\");\n  const drawnCards: TarotSpreadResolvedSelectionCard[] = [];\n\n  for (const slot of spread.slots\n    .filter((candidate) => candidate.metadata?.groupKey === \"outer\")\n    .sort((left, right) => left.order - right.order)) {\n    const card = pickTarotCardFromPool(outerPool, getTarotSpreadRuleForDraw(slot), rng);\n    drawnCards.push(buildResolvedDrawnCard(slot, card, includeInverted, rng));\n  }\n\n  for (const slotKey of inquirerRule.sourceSlotKeys) {\n    const slot = slotsByKey.get(slotKey);\n\n    if (!slot) {\n      throw new Error(`Missing Event Reading slot definition for ${slotKey}.`);\n    }\n\n    const card = pickTarotCardFromPool(majorPool, getTarotSpreadRuleForDraw(slot), rng);\n    drawnCards.push(buildResolvedDrawnCard(slot, card, includeInverted, rng));\n  }\n\n  const genderedInquirerCardNumber =\n    inquirerRule.cardNumbersByGender[context.inquirerGender];\n  const sourceContainsGenderedCard = drawnCards.some(\n    (card) =>\n      inquirerRule.sourceSlotKeys.includes(card.slotKey) &&\n      card.card.number === genderedInquirerCardNumber\n  );\n  const inquirerSlot = slotsByKey.get(inquirerRule.slotKey);\n\n  if (!inquirerSlot) {\n    throw new Error(\n      `Missing Event Reading slot definition for ${inquirerRule.slotKey}.`\n    );\n  }\n\n  if (!sourceContainsGenderedCard) {\n    const genderedCardIndex = majorPool.findIndex(\n      (card) => card.number === genderedInquirerCardNumber\n    );\n\n    if (genderedCardIndex < 0) {\n      throw new Error(\n        \"Unable to assign the Event Reading inquirer card from the remaining major arcana.\"\n      );\n    }\n\n    const [genderedCard] = majorPool.splice(genderedCardIndex, 1);\n    drawnCards.push(\n      buildResolvedDrawnCard(inquirerSlot, genderedCard, includeInverted, rng)\n    );\n  } else {\n    const replacement = pickTarotCardFromPool(\n      majorPool,\n      getTarotSpreadRuleForDraw(inquirerSlot),\n      rng\n    );\n    drawnCards.push(\n      buildResolvedDrawnCard(inquirerSlot, replacement, includeInverted, rng)\n    );\n  }\n\n  return drawnCards;\n}\n\nexport function listTarotSpreads(): TarotSpreadDefinition[] {\n  return TAROT_SPREADS.map(cloneSpreadDefinition);\n}\n\nexport function getTarotSpread(\n  spreadId: TarotSpreadId\n): TarotSpreadDefinition | undefined {\n  const spread = TAROT_SPREAD_BY_ID.get(spreadId);\n  return spread ? cloneSpreadDefinition(spread) : undefined;\n}\n\nexport function validateTarotSpreadSelection(\n  input: TarotSpreadValidationInput\n): TarotSpreadValidationResult {\n  const spread = TAROT_SPREAD_BY_ID.get(input.spreadId);\n  const errors: TarotSpreadValidationIssue[] = [];\n\n  if (!spread) {\n    return {\n      ok: false,\n      isComplete: false,\n      errors: [\n        {\n          code: \"UNKNOWN_SPREAD\",\n          message: `Unknown tarot spread: ${input.spreadId}.`\n        }\n      ],\n      resolvedCards: []\n    };\n  }\n\n  const slotsByKey = new Map(\n    spread.slots.map((slot) => [slot.slotKey, slot] as const)\n  );\n  const seenCardNumbers = new Set<number>();\n  const resolvedCards: TarotSpreadResolvedSelectionCard[] = [];\n\n  for (const selectedCard of input.cards) {\n    const slot = slotsByKey.get(selectedCard.slotKey);\n\n    if (!slot) {\n      errors.push({\n        code: \"UNKNOWN_SLOT\",\n        slotKey: selectedCard.slotKey,\n        message: `Unknown slot for ${spread.label}: ${selectedCard.slotKey}.`\n      });\n      continue;\n    }\n\n    const tarotCard = getTarotDeckCardByNumber(selectedCard.cardNumber);\n\n    if (!tarotCard) {\n      errors.push({\n        code: \"CARD_NOT_FOUND\",\n        slotKey: selectedCard.slotKey,\n        cardNumber: selectedCard.cardNumber,\n        message: `Unknown tarot card number: ${selectedCard.cardNumber}.`\n      });\n      continue;\n    }\n\n    if (seenCardNumbers.has(tarotCard.number)) {\n      errors.push({\n        code: \"DUPLICATE_CARD\",\n        slotKey: selectedCard.slotKey,\n        cardNumber: tarotCard.number,\n        message: `Tarot card ${tarotCard.number} is duplicated across the spread.`\n      });\n      continue;\n    }\n\n    seenCardNumbers.add(tarotCard.number);\n    resolvedCards.push(\n      resolveTarotSpreadSelectionCard(selectedCard, slot, tarotCard)\n    );\n  }\n\n  let isComplete = true;\n\n  for (const slot of spread.slots) {\n    const slotCards = resolvedCards.filter(\n      (selectedCard) => selectedCard.slotKey === slot.slotKey\n    );\n\n    if (slotCards.length < slot.minCards) {\n      isComplete = false;\n      if (!input.allowPartial) {\n        errors.push({\n          code: \"MISSING_REQUIRED_CARDS\",\n          slotKey: slot.slotKey,\n          message: `${spread.label} requires ${slot.minCards} card(s) for ${slot.label}.`\n        });\n      }\n    }\n\n    if (slotCards.length > slot.maxCards) {\n      isComplete = false;\n      errors.push({\n        code: \"TOO_MANY_CARDS\",\n        slotKey: slot.slotKey,\n        message: `${spread.label} allows at most ${slot.maxCards} card(s) for ${slot.label}.`\n      });\n    }\n\n    const validationRule = getTarotSpreadRuleForValidation(slot);\n\n    for (const slotCard of slotCards) {\n      if (validationRule?.allowedTypes && !validationRule.allowedTypes.includes(slotCard.card.type)) {\n        errors.push({\n          code: \"INVALID_CARD_TYPE\",\n          slotKey: slot.slotKey,\n          cardNumber: slotCard.card.number,\n          message: `${slot.label} does not accept ${slotCard.card.type} cards.`\n        });\n      }\n\n      if (\n        validationRule?.requiredRank &&\n        getTarotMinorRank(slotCard.card) !== validationRule.requiredRank\n      ) {\n        errors.push({\n          code: \"INVALID_CARD_RANK\",\n          slotKey: slot.slotKey,\n          cardNumber: slotCard.card.number,\n          message: `${slot.label} requires a ${validationRule.requiredRank} minor arcana card.`\n        });\n      }\n\n      if (\n        validationRule?.allowedCardFilenames &&\n        !validationRule.allowedCardFilenames.includes(slotCard.card.tarotCardFilename)\n      ) {\n        errors.push({\n          code: \"DISALLOWED_CARD\",\n          slotKey: slot.slotKey,\n          cardNumber: slotCard.card.number,\n          message: `${slotCard.card.tarotCard} is not allowed in ${slot.label}.`\n        });\n      }\n\n      if (\n        validationRule?.excludedCardFilenames &&\n        validationRule.excludedCardFilenames.includes(slotCard.card.tarotCardFilename)\n      ) {\n        errors.push({\n          code: \"DISALLOWED_CARD\",\n          slotKey: slot.slotKey,\n          cardNumber: slotCard.card.number,\n          message: `${slotCard.card.tarotCard} is excluded from ${slot.label}.`\n        });\n      }\n    }\n  }\n\n  if (\n    spread.contextRequirements?.includes(\"inquirerGender\") &&\n    !input.context?.inquirerGender\n  ) {\n    isComplete = false;\n    errors.push({\n      code: \"MISSING_CONTEXT\",\n      message: `${spread.label} requires \\`context.inquirerGender\\`.`\n    });\n  }\n\n  validateEventInquirerCard(spread, resolvedCards, input.context, errors);\n\n  const sortedResolvedCards = sortResolvedTarotSpreadCards(resolvedCards);\n\n  return {\n    ok: errors.length === 0,\n    isComplete,\n    spread: cloneSpreadDefinition(spread),\n    resolvedCards: sortedResolvedCards,\n    errors\n  };\n}\n\nexport function drawTarotSpread(\n  options: DrawTarotSpreadOptions\n): TarotSpreadDrawResult {\n  const spread = TAROT_SPREAD_BY_ID.get(options.spreadId);\n\n  if (!spread) {\n    throw new Error(`Unknown tarot spread: ${options.spreadId}.`);\n  }\n\n  const rng = options.rng ?? Math.random;\n  const includeInverted = options.includeInverted ?? false;\n  const drawnCards =\n    spread.spreadId === \"event-reading\"\n      ? drawEventReadingSpread(spread, includeInverted, rng, options.context)\n      : drawDefaultTarotSpread(spread, includeInverted, rng);\n  const validation = validateTarotSpreadSelection({\n    spreadId: spread.spreadId,\n    cards: drawnCards.map((card) => ({\n      slotKey: card.slotKey,\n      cardNumber: card.cardNumber,\n      isInverted: card.isInverted\n    })),\n    context: options.context\n  });\n\n  if (!validation.ok) {\n    throw new Error(\n      `Generated an invalid tarot spread selection for ${spread.label}: ${validation.errors\n        .map((error) => error.message)\n        .join(\" \")}`\n    );\n  }\n\n  return {\n    spread: cloneSpreadDefinition(spread),\n    deckId: options.deckId ?? \"rider-waite\",\n    context: options.context,\n    cards: sortResolvedTarotSpreadCards(drawnCards)\n  };\n}\n"]}