(function () {
"use strict";
function computeDigitalRoot(value) {
let current = Math.abs(Math.trunc(Number(value)));
if (!Number.isFinite(current)) {
return null;
}
while (current >= 10) {
current = String(current)
.split("")
.reduce((sum, digit) => sum + Number(digit), 0);
}
return current;
}
function describeDigitalRootReduction(value, digitalRoot) {
const normalized = Math.abs(Math.trunc(Number(value)));
if (!Number.isFinite(normalized) || !Number.isFinite(digitalRoot)) {
return "";
}
if (normalized < 10) {
return String(normalized);
}
return `${String(normalized).split("").join(" + ")} = ${digitalRoot}`;
}
function renderPositionDigitalRootCard(letter, alphabet, context, orderLabel) {
const index = Number(letter?.index);
if (!Number.isFinite(index)) {
return "";
}
const position = Math.trunc(index);
if (position <= 0) {
return "";
}
const digitalRoot = computeDigitalRoot(position);
if (!Number.isFinite(digitalRoot)) {
return "";
}
const entries = Array.isArray(context.alphabets?.[alphabet]) ? context.alphabets[alphabet] : [];
const countText = entries.length ? ` of ${entries.length}` : "";
const orderText = orderLabel ? ` (${orderLabel})` : "";
const reductionText = describeDigitalRootReduction(position, digitalRoot);
const openNumberBtn = context.navBtn(`View Number ${digitalRoot}`, "nav:number", { value: digitalRoot });
return context.card("Position Digital Root", `
- Position
- #${position}${countText}${orderText}
- Digital Root
- ${digitalRoot}${reductionText ? ` (${reductionText})` : ""}
${openNumberBtn}
`);
}
function monthRefsForLetter(letter, context) {
const hebrewLetterId = context.normalizeId(letter?.hebrewLetterId);
if (!hebrewLetterId) {
return [];
}
return context.monthRefsByHebrewId.get(hebrewLetterId) || [];
}
function calendarMonthsCard(monthRefs, titleLabel, context) {
if (!monthRefs.length) {
return "";
}
const monthButtons = monthRefs
.map((month) => context.navBtn(month.label || month.name, "nav:calendar-month", { "month-id": month.id }))
.join("");
return context.card("Calendar Months", `
${titleLabel}
${monthButtons}
`);
}
function renderAstrologyCard(astrology, context) {
if (!astrology) return "";
const { type, name } = astrology;
const id = (name || "").toLowerCase();
if (type === "planet") {
const sym = context.PLANET_SYMBOLS[id] || "";
const cubePlacement = context.getCubePlacementForPlanet(id);
const cubeBtn = context.cubePlacementBtn(cubePlacement, { "planet-id": id });
return context.card("Astrology", `
- Type
- Planet
- Ruler
- ${sym} ${context.cap(id)}
${cubeBtn}
`);
}
if (type === "zodiac") {
const sym = context.ZODIAC_SYMBOLS[id] || "";
const cubePlacement = context.getCubePlacementForSign(id);
const cubeBtn = context.cubePlacementBtn(cubePlacement, { "sign-id": id });
return context.card("Astrology", `
- Type
- Zodiac Sign
- Sign
- ${sym} ${context.cap(id)}
${cubeBtn}
`);
}
if (type === "element") {
const elemEmoji = { air: "๐จ", water: "๐ง", fire: "๐ฅ", earth: "๐" };
return context.card("Astrology", `
- Type
- Element
- Element
- ${elemEmoji[id] || ""} ${context.cap(id)}
`);
}
return context.card("Astrology", `
- Type
- ${context.cap(type)}
- Name
- ${context.cap(name)}
`);
}
function renderHebrewDualityCard(letter, context) {
const duality = context.HEBREW_DOUBLE_DUALITY[context.normalizeId(letter?.hebrewLetterId)];
if (!duality) {
return "";
}
return context.card("Duality", `
- Polarity
- ${duality.left} / ${duality.right}
`);
}
function renderHebrewFourWorldsCard(letter, context) {
const letterId = context.normalizeLetterId(letter?.hebrewLetterId || letter?.transliteration || letter?.char);
if (!letterId) {
return "";
}
const rows = (Array.isArray(context.fourWorldLayers) ? context.fourWorldLayers : [])
.filter((entry) => entry?.hebrewLetterId === letterId);
if (!rows.length) {
return "";
}
const body = rows.map((entry) => {
const pathBtn = Number.isFinite(Number(entry?.pathNumber))
? context.navBtn(`View Path ${entry.pathNumber}`, "nav:kabbalah-path", { "path-no": Number(entry.pathNumber) })
: "";
return `
${entry.slot}: ${entry.letterChar} โ ${entry.world}
${entry.soulLayer}
${entry.worldLayer}${entry.worldDescription ? ` ยท ${entry.worldDescription}` : ""}
${entry.soulLayer}${entry.soulTitle ? ` โ ${entry.soulTitle}` : ""}${entry.soulDescription ? `: ${entry.soulDescription}` : ""}
${pathBtn}
`;
}).join("");
return context.card("Qabalistic Worlds & Soul Layers", `${body}
`);
}
function normalizeLatinLetter(value) {
return String(value || "")
.trim()
.toUpperCase()
.replace(/[^A-Z]/g, "");
}
function extractEnglishLetterRefs(value) {
if (Array.isArray(value)) {
return [...new Set(value.map((entry) => normalizeLatinLetter(entry)).filter(Boolean))];
}
return [...new Set(
String(value || "")
.split(/[\s,;|\/]+/)
.map((entry) => normalizeLatinLetter(entry))
.filter(Boolean)
)];
}
function renderAlphabetEquivalentCard(activeAlphabet, letter, context) {
const hebrewLetters = Array.isArray(context.alphabets?.hebrew) ? context.alphabets.hebrew : [];
const greekLetters = Array.isArray(context.alphabets?.greek) ? context.alphabets.greek : [];
const englishLetters = Array.isArray(context.alphabets?.english) ? context.alphabets.english : [];
const arabicLetters = Array.isArray(context.alphabets?.arabic) ? context.alphabets.arabic : [];
const enochianLetters = Array.isArray(context.alphabets?.enochian) ? context.alphabets.enochian : [];
const linkedHebrewIds = new Set();
const linkedEnglishLetters = new Set();
const buttons = [];
function addHebrewId(value) {
const id = context.normalizeId(value);
if (id) {
linkedHebrewIds.add(id);
}
}
function addEnglishLetter(value) {
const code = normalizeLatinLetter(value);
if (!code) {
return;
}
linkedEnglishLetters.add(code);
englishLetters
.filter((entry) => normalizeLatinLetter(entry?.letter) === code)
.forEach((entry) => addHebrewId(entry?.hebrewLetterId));
}
if (activeAlphabet === "hebrew") {
addHebrewId(letter?.hebrewLetterId);
} else if (activeAlphabet === "greek") {
addHebrewId(letter?.hebrewLetterId);
englishLetters
.filter((entry) => context.normalizeId(entry?.greekEquivalent) === context.normalizeId(letter?.name))
.forEach((entry) => addEnglishLetter(entry?.letter));
} else if (activeAlphabet === "english") {
addEnglishLetter(letter?.letter);
addHebrewId(letter?.hebrewLetterId);
} else if (activeAlphabet === "arabic") {
addHebrewId(letter?.hebrewLetterId);
} else if (activeAlphabet === "enochian") {
extractEnglishLetterRefs(letter?.englishLetters).forEach((code) => addEnglishLetter(code));
addHebrewId(letter?.hebrewLetterId);
}
if (!linkedHebrewIds.size && !linkedEnglishLetters.size) {
return "";
}
const activeHebrewKey = context.normalizeId(letter?.hebrewLetterId);
const activeGreekKey = context.normalizeId(letter?.name);
const activeEnglishKey = normalizeLatinLetter(letter?.letter);
const activeArabicKey = context.normalizeId(letter?.name);
const activeEnochianKey = context.normalizeId(letter?.id || letter?.char || letter?.title);
hebrewLetters.forEach((heb) => {
const key = context.normalizeId(heb?.hebrewLetterId);
if (!key || !linkedHebrewIds.has(key)) {
return;
}
if (activeAlphabet === "hebrew" && key === activeHebrewKey) {
return;
}
buttons.push(``);
});
greekLetters.forEach((grk) => {
const key = context.normalizeId(grk?.name);
const viaHebrew = linkedHebrewIds.has(context.normalizeId(grk?.hebrewLetterId));
const viaEnglish = englishLetters.some((eng) => (
linkedEnglishLetters.has(normalizeLatinLetter(eng?.letter))
&& context.normalizeId(eng?.greekEquivalent) === key
));
if (!(viaHebrew || viaEnglish)) {
return;
}
if (activeAlphabet === "greek" && key === activeGreekKey) {
return;
}
buttons.push(``);
});
englishLetters.forEach((eng) => {
const key = normalizeLatinLetter(eng?.letter);
const viaLetter = linkedEnglishLetters.has(key);
const viaHebrew = linkedHebrewIds.has(context.normalizeId(eng?.hebrewLetterId));
if (!(viaLetter || viaHebrew)) {
return;
}
if (activeAlphabet === "english" && key === activeEnglishKey) {
return;
}
buttons.push(``);
});
arabicLetters.forEach((arb) => {
const key = context.normalizeId(arb?.name);
if (!linkedHebrewIds.has(context.normalizeId(arb?.hebrewLetterId))) {
return;
}
if (activeAlphabet === "arabic" && key === activeArabicKey) {
return;
}
buttons.push(``);
});
enochianLetters.forEach((eno) => {
const key = context.normalizeId(eno?.id || eno?.char || eno?.title);
const englishRefs = extractEnglishLetterRefs(eno?.englishLetters);
const viaHebrew = linkedHebrewIds.has(context.normalizeId(eno?.hebrewLetterId));
const viaEnglish = englishRefs.some((code) => linkedEnglishLetters.has(code));
if (!(viaHebrew || viaEnglish)) {
return;
}
if (activeAlphabet === "enochian" && key === activeEnochianKey) {
return;
}
buttons.push(``);
});
if (!buttons.length) {
return "";
}
return context.card("ALPHABET EQUIVALENT", `${buttons.join("")}
`);
}
function renderHebrewDetail(context) {
const { letter, detailSubEl, detailBodyEl } = context;
detailSubEl.textContent = `${letter.name} โ ${letter.transliteration}`;
detailBodyEl.innerHTML = "";
const sections = [];
sections.push(context.card("Letter Details", `
- Character
- ${letter.char}
- Name
- ${letter.name}
- Transliteration
- ${letter.transliteration}
- Meaning
- ${letter.meaning}
- Gematria Value
- ${letter.numerology}
- Letter Type
- ${letter.letterType}
- Position
- #${letter.index} of 22
`));
const positionRootCard = renderPositionDigitalRootCard(letter, "hebrew", context);
if (positionRootCard) {
sections.push(positionRootCard);
}
if (letter.letterType === "double") {
const dualityCard = renderHebrewDualityCard(letter, context);
if (dualityCard) {
sections.push(dualityCard);
}
}
const fourWorldsCard = renderHebrewFourWorldsCard(letter, context);
if (fourWorldsCard) {
sections.push(fourWorldsCard);
}
if (letter.astrology) {
sections.push(renderAstrologyCard(letter.astrology, context));
}
if (letter.kabbalahPathNumber) {
const tarotPart = letter.tarot
? `Tarot Card${letter.tarot.card} (Trump ${letter.tarot.trumpNumber})`
: "";
const kabBtn = context.navBtn("View Kabbalah Path", "tarot:view-kab-path", { "path-number": letter.kabbalahPathNumber });
const tarotBtn = letter.tarot
? context.navBtn("View Tarot Card", "kab:view-trump", { "trump-number": letter.tarot.trumpNumber })
: "";
const cubePlacement = context.getCubePlacementForHebrewLetter(letter.hebrewLetterId, letter.kabbalahPathNumber);
const cubeBtn = context.cubePlacementBtn(cubePlacement, {
"hebrew-letter-id": letter.hebrewLetterId,
"path-no": letter.kabbalahPathNumber
});
sections.push(context.card("Kabbalah & Tarot", `
- Path Number
- ${letter.kabbalahPathNumber}
${tarotPart}
${kabBtn}${tarotBtn}${cubeBtn}
`));
}
const monthRefs = monthRefsForLetter(letter, context);
const monthCard = calendarMonthsCard(monthRefs, `Calendar correspondences linked to ${letter.name}.`, context);
if (monthCard) {
sections.push(monthCard);
}
const equivalentsCard = renderAlphabetEquivalentCard("hebrew", letter, context);
if (equivalentsCard) {
sections.push(equivalentsCard);
}
detailBodyEl.innerHTML = sections.join("");
context.attachDetailListeners();
}
function renderGreekDetail(context) {
const { letter, detailSubEl, detailBodyEl } = context;
const archaicBadge = letter.archaic ? ' archaic' : "";
detailSubEl.textContent = `${letter.displayName}${letter.archaic ? " (archaic)" : ""} โ ${letter.transliteration}`;
detailBodyEl.innerHTML = "";
const sections = [];
const charRow = letter.charFinal
? `Form (final)${letter.charFinal}`
: "";
sections.push(context.card("Letter Details", `
- Uppercase
- ${letter.char}
- Lowercase
- ${letter.charLower || "โ"}
${charRow}
- Name
- ${letter.displayName}${archaicBadge}
- Transliteration
- ${letter.transliteration}
- IPA
- ${letter.ipa || "โ"}
- Isopsephy Value
- ${letter.numerology}
- Meaning / Origin
- ${letter.meaning || "โ"}
`));
const positionRootCard = renderPositionDigitalRootCard(letter, "greek", context);
if (positionRootCard) {
sections.push(positionRootCard);
}
const equivalentsCard = renderAlphabetEquivalentCard("greek", letter, context);
if (equivalentsCard) {
sections.push(equivalentsCard);
}
const monthRefs = monthRefsForLetter(letter, context);
const monthCard = calendarMonthsCard(monthRefs, `Calendar correspondences inherited via ${letter.displayName}'s Hebrew origin.`, context);
if (monthCard) {
sections.push(monthCard);
}
detailBodyEl.innerHTML = sections.join("");
context.attachDetailListeners();
}
function renderEnglishDetail(context) {
const { letter, detailSubEl, detailBodyEl } = context;
detailSubEl.textContent = `Letter ${letter.letter} ยท position #${letter.index}`;
detailBodyEl.innerHTML = "";
const sections = [];
sections.push(context.card("Letter Details", `
- Letter
- ${letter.letter}
- Position
- #${letter.index} of 26
- IPA
- ${letter.ipa || "โ"}
- Pythagorean Value
- ${letter.pythagorean}
`));
const positionRootCard = renderPositionDigitalRootCard(letter, "english", context);
if (positionRootCard) {
sections.push(positionRootCard);
}
const equivalentsCard = renderAlphabetEquivalentCard("english", letter, context);
if (equivalentsCard) {
sections.push(equivalentsCard);
}
const monthRefs = monthRefsForLetter(letter, context);
const monthCard = calendarMonthsCard(monthRefs, "Calendar correspondences linked through this letter's Hebrew correspondence.", context);
if (monthCard) {
sections.push(monthCard);
}
detailBodyEl.innerHTML = sections.join("");
context.attachDetailListeners();
}
function renderArabicDetail(context) {
const { letter, detailSubEl, detailBodyEl } = context;
detailSubEl.textContent = `${context.arabicDisplayName(letter)} โ ${letter.transliteration}`;
detailBodyEl.innerHTML = "";
const sections = [];
const forms = letter.forms || {};
const formParts = [
forms.isolated ? `${forms.isolated}
isolated` : "",
forms.final ? `${forms.final}
final` : "",
forms.medial ? `${forms.medial}
medial` : "",
forms.initial ? `${forms.initial}
initial` : ""
].filter(Boolean);
sections.push(context.card("Letter Details", `
- Arabic Name
- ${letter.nameArabic}
- Transliteration
- ${letter.transliteration}
- IPA
- ${letter.ipa || "โ"}
- Abjad Value
- ${letter.abjad}
- Meaning
- ${letter.meaning || "โ"}
- Category
- ${letter.category}
- Position
- #${letter.index} of 28 (Abjad order)
`));
const positionRootCard = renderPositionDigitalRootCard(letter, "arabic", context, "Abjad order");
if (positionRootCard) {
sections.push(positionRootCard);
}
if (formParts.length) {
sections.push(context.card("Letter Forms", `${formParts.join("")}
`));
}
const equivalentsCard = renderAlphabetEquivalentCard("arabic", letter, context);
if (equivalentsCard) {
sections.push(equivalentsCard);
}
detailBodyEl.innerHTML = sections.join("");
context.attachDetailListeners();
}
function renderEnochianDetail(context) {
const { letter, detailSubEl, detailBodyEl } = context;
const englishRefs = extractEnglishLetterRefs(letter?.englishLetters);
detailSubEl.textContent = `${letter.title} โ ${letter.transliteration}`;
detailBodyEl.innerHTML = "";
const sections = [];
sections.push(context.card("Letter Details", `
- Character
- ${context.enochianGlyphImageHtml(letter, "alpha-enochian-glyph-img alpha-enochian-glyph-img--detail-row")}
- Name
- ${letter.title}
- English Letters
- ${englishRefs.join(" / ") || "โ"}
- Transliteration
- ${letter.transliteration || "โ"}
- Element / Planet
- ${letter.elementOrPlanet || "โ"}
- Tarot
- ${letter.tarot || "โ"}
- Numerology
- ${letter.numerology || "โ"}
- Glyph Source
- Local cache: asset/img/enochian (sourced from dCode set)
- Position
- #${letter.index} of 21
`));
const positionRootCard = renderPositionDigitalRootCard(letter, "enochian", context);
if (positionRootCard) {
sections.push(positionRootCard);
}
const equivalentsCard = renderAlphabetEquivalentCard("enochian", letter, context);
if (equivalentsCard) {
sections.push(equivalentsCard);
}
const monthRefs = monthRefsForLetter(letter, context);
const monthCard = calendarMonthsCard(monthRefs, "Calendar correspondences linked through this letter's Hebrew correspondence.", context);
if (monthCard) {
sections.push(monthCard);
}
detailBodyEl.innerHTML = sections.join("");
context.attachDetailListeners();
}
function renderDetail(context) {
const alphabet = context.alphabet;
if (alphabet === "hebrew") {
renderHebrewDetail(context);
} else if (alphabet === "greek") {
renderGreekDetail(context);
} else if (alphabet === "english") {
renderEnglishDetail(context);
} else if (alphabet === "arabic") {
renderArabicDetail(context);
} else if (alphabet === "enochian") {
renderEnochianDetail(context);
}
}
window.AlphabetDetailUi = { renderDetail };
})();