import type { ReactNode } from 'react';
import { CategoryIcon } from '@/site/components/art/category-icon';
import {
    LongevityScene,
    PlasticSurgeryScene,
} from '@/site/components/art/category-scenes';
import { ContourArt } from '@/site/components/art/contour-art';
import {
    DentalScene,
    FaceScene,
    HairScene,
    MensHealthScene,
} from '@/site/components/sections/home/area-scenes';
import type {
    SceneBeat,
    SceneProps,
} from '@/site/components/sections/home/area-scenes';

/**
 * Picks the drawing of a home page panel by its group (config/site.php →
 * departments). The six groups each have one (docs/DECISIONS.md K46):
 * hair, dental, the face of medical aesthetics and men's health were drawn
 * for these panels; personalised medicine takes the orbits and plastic
 * surgery the planning sheet that their category pages play
 * (components/art/category-scenes.tsx).
 */
const scenes: Partial<Record<string, (props: SceneProps) => ReactNode>> = {
    personalized: LongevityScene,
    dental: DentalScene,
    hair: HairScene,
    aesthetics: FaceScene,
    'mens-health': MensHealthScene,
    'plastic-surgery': PlasticSurgeryScene,
};

/**
 * The scene of a group that has no drawing of its own yet (a new one): its
 * icon draws itself inside contour rings that turn with the scroll.
 */
function MarkScene({ seed, icon }: { seed: string; icon: string }) {
    return (
        <div className="area-lens">
            <ContourArt seed={seed} rings={11} className="area-rings" />
            <CategoryIcon name={icon} className="area-icon" />
        </div>
    );
}

type AreaSceneProps = {
    /** Group key: picks the scene. */
    area: string;
    icon: string;
    beats: SceneBeat[];
};

/** The drawing of one group; decorative (its panel carries the text). */
export function AreaScene({ area, icon, beats }: AreaSceneProps) {
    const Scene = scenes[area];

    // A scene needs at least two beats to tell anything.
    return Scene && beats.length > 1 ? (
        <Scene beats={beats} />
    ) : (
        <MarkScene seed={area} icon={icon} />
    );
}
