import { ASPECTS, POINTS, SIGNS, dms, orbText, pointName, signName } from "@/lib/astro";
import { sideTimeKnown } from "@/lib/synastry";
import type { HouseOverlay, InterAspect, Synastry, SynastryResult } from "@/lib/types";
import { GRID_POINTS, Pos } from "./ChartTables";
const NATURES: { key: keyof SynastryResult["summary"]["by_nature"]; label: string; hint: string }[] = [
{ key: "harmonious", label: "Harmonikus", hint: "trigon, szextil: ami könnyen megy köztetek" },
{ key: "challenging", label: "Feszültebb", hint: "kvadrát, szembenállás: súrlódás, de mozgatóerő is" },
{ key: "neutral", label: "Együttállás", hint: "összeolvadás: erős, a bolygóktól függő hatás" },
];
/** The inter-chart aspects by character, as a bar and counts. */
export function NatureBar({ summary }: { summary: SynastryResult["summary"] }) {
const total = summary.aspect_count || 1;
return (
{NATURES.map((n) => (
))}
{NATURES.map((n) => (
-
{n.label}
-
{summary.by_nature[n.key]} {n.hint}
))}
);
}
const GRID_ANGLES: [string, string][] = [
["ascendant", "AC"],
["midheaven", "MC"],
];
function gridPoints(s: Synastry["chart1"]): [string, string][] {
const present = new Set(s.chart.points.map((p) => p.id));
const rows: [string, string][] = GRID_POINTS.filter((id) => present.has(id)).map((id) => [id, POINTS[id]?.glyph ?? id]);
if (sideTimeKnown(s)) {
for (const [key, label] of GRID_ANGLES) if (s.chart.angles?.[key]) rows.push([key, label]);
}
return rows;
}
/** The aspects between the two charts: the first person in the rows, the second in the columns. */
export function CrossGrid({ synastry, name1, name2 }: { synastry: Synastry; name1: string; name2: string }) {
const rows = gridPoints(synastry.chart1);
const cols = gridPoints(synastry.chart2);
const byPair = new Map();
for (const a of synastry.synastry.aspects) byPair.set(`${a.person1}|${a.person2}`, a);
const label = ([id, text]: [string, string], who: string) => (
2 ? "sym" : "grid-angle"} aria-label={`${who}: ${pointName(id)}`} role="img">
{text}
);
return (
|
{name2} →
↓ {name1}
|
{cols.map((c) => (
{label(c, name2)}
|
))}
{rows.map((row) => {
const [id] = row;
return (
|
{label(row, name1)}
|
{cols.map(([other]) => {
const a = byPair.get(`${id}|${other}`);
const info = a ? ASPECTS[a.aspect] : undefined;
const text = a
? `${name1} ${pointName(id)} ${info?.hu ?? a.aspect} ${name2} ${pointName(other)}, orbis ${orbText(a.orb)}`
: undefined;
return (
{a && (
{info?.glyph ?? "?"}
)}
|
);
})}
);
})}
);
}
function OverlayTable({ title, overlays, missing }: { title: string; overlays: HouseOverlay[] | null; missing: string }) {
return (
{title}
{overlays ? (
| Pont |
Jegy |
Ház |
{overlays.map((o) => (
|
{POINTS[o.point]?.glyph}
{" "}
{pointName(o.point)}
|
{SIGNS[o.sign]?.glyph}
{" "}
{signName(o.sign)}
|
{o.house}. |
))}
) : (
{missing}
)}
);
}
/** Each person's points in the other's houses (needs the other's birth time). */
export function HouseOverlays({ synastry, name1, name2 }: { synastry: Synastry; name1: string; name2: string }) {
const o = synastry.synastry.house_overlays;
return (
Melyik életterületét érinti a másik: az egyik fél bolygói a másik házaiban. Ehhez a ház „gazdájának” pontos
születési ideje kell.
);
}
/** The composite chart (midpoints of the two charts). */
export function CompositeTables({ synastry }: { synastry: Synastry }) {
const c = synastry.synastry.composite;
const hasHouses = Boolean(c.houses);
const angles = (
[
["ascendant", "ASC"],
["midheaven", "MC"],
] as const
).filter(([key]) => c.angles?.[key]);
const aspects = [...c.aspects].filter((a) => a.orb <= 3).sort((a, b) => a.orb - b.orb);
return (
A kompozit képlet a két képlet felezőpontjaiból áll: a kapcsolatot mint önálló harmadik „személyt” írja le.
{!c.angles && " Tengelyek és házak nélkül, mert legalább az egyik születési idő ismeretlen."}
Pontok
| Pont |
Pozíció |
{hasHouses && Ház | }
{c.points.map((p) => (
|
{POINTS[p.id]?.glyph}
{" "}
{pointName(p.id)}
|
|
{hasHouses && {p.house ? `${p.house}.` : "–"} | }
))}
{angles.map(([key, label]) => (
| {label} |
{dms(c.angles![key].degree_in_sign_dms)} {SIGNS[c.angles![key].sign]?.glyph}{" "}
{signName(c.angles![key].sign)}
|
{hasHouses && | }
))}
Szoros fényszögek
{aspects.length === 0 ? (
Nincs 3°-nál szorosabb fényszög.
) : (
{aspects.map((a) => (
|
{pointName(a.point1)} {pointName(a.point2)}
|
{orbText(a.orb)} |
))}
)}
);
}
function AspectTag({ aspect }: { aspect: string }) {
const info = ASPECTS[aspect];
return (
{info?.glyph}
{" "}
{info?.hu ?? aspect}
);
}
/** Every aspect between the two charts, closest first. */
export function InterAspectList({ synastry, name1, name2 }: { synastry: Synastry; name1: string; name2: string }) {
const aspects = [...synastry.synastry.aspects].sort((a, b) => a.orb - b.orb);
if (aspects.length === 0) return Nincs fényszög a két képlet között.
;
return (
| {name1} |
Fényszög |
{name2} |
Orbisz |
{aspects.map((a) => (
|
{POINTS[a.person1]?.glyph}
{" "}
{pointName(a.person1)}
|
|
{POINTS[a.person2]?.glyph}
{" "}
{pointName(a.person2)}
|
{orbText(a.orb)} |
))}
);
}