import { createCinematicBloomPass } from "./BloomPass.js";
import { createCinematicDepthHazePass } from "./DepthHazePass.js";
import { createCinematicFilmGrainPass } from "./FilmGrainPass.js";
import { createCinematicVignettePass } from "./VignettePass.js";
import { createRendererOwnedEvidenceFlag } from "./CinematicEvidence.js";
export function createCinematicPostProcessStack(options = {}) {
    const colorGradePreset = options.colorGradePreset ?? "neon-noir";
    const bloom = createCinematicBloomPass({ intensity: options.glow === false ? 0.08 : 0.28 });
    const vignette = createCinematicVignettePass();
    const filmGrain = createCinematicFilmGrainPass();
    const depthHaze = createCinematicDepthHazePass({ density: options.fogOrHaze === false ? 0.06 : 0.22 });
    return {
        id: options.id ?? "cinematic-postprocess",
        colorGradePreset,
        bloom,
        vignette,
        filmGrain,
        depthHaze,
        rendererOptions: {
            targetFormat: "rgba16f",
            bloom: { threshold: bloom.threshold, intensity: bloom.intensity, radius: bloom.radius },
            toneMapping: { operator: "filmic", exposure: exposureFor(colorGradePreset), whitePoint: 1.18, inputColorSpace: "linear", outputColorSpace: "srgb" },
            colorGrade: colorGradeFor(colorGradePreset, vignette.intensity),
            filmGrain: { intensity: filmGrain.intensity, seed: filmGrain.animated ? 17 : 1, monochrome: true },
            fxaa: true
        },
        rendererOwnedEvidence: [
            bloom.rendererOwnedEvidence,
            vignette.rendererOwnedEvidence,
            filmGrain.rendererOwnedEvidence,
            depthHaze.rendererOwnedEvidence,
            createRendererOwnedEvidenceFlag({
                id: `postprocess:color-grade:${colorGradePreset}`,
                feature: "postprocess",
                label: `Color grade ${colorGradePreset}`,
                source: "renderer-postprocess",
                sceneContent: false
            })
        ],
        diagnostics: ["Cinematic postprocess stack is renderer-owned; route DOM overlays cannot satisfy effect evidence."]
    };
}
function exposureFor(preset) {
    if (preset === "warm-sunrise")
        return 1.12;
    if (preset === "cool-moonlit")
        return 1.3;
    if (preset === "studio-neutral")
        return 1.02;
    return 1.22;
}
function colorGradeFor(preset, vignette) {
    switch (preset) {
        case "warm-sunrise":
            return { contrast: 1.08, saturation: 1.08, vibrance: 0.14, vignette, sharpening: 0.16 };
        case "cool-moonlit":
            return { contrast: 1.16, saturation: 0.9, vibrance: 0.08, vignette: vignette + 0.04, sharpening: 0.18 };
        case "studio-neutral":
            return { contrast: 1.04, saturation: 1, vibrance: 0.06, vignette: 0.06, sharpening: 0.18 };
        case "neon-noir":
            return { contrast: 1.18, saturation: 1.12, vibrance: 0.2, vignette: vignette + 0.06, sharpening: 0.16 };
    }
}
//# sourceMappingURL=CinematicPostProcess.js.map