import type { Spectrum1D } from '@zakodium/nmrium-core';
import { useScale } from '../../context/ScaleContext.js';
import { useActiveSpectrum } from '../../hooks/useActiveSpectrum.js';
import { useActiveSpectrumPeaksViewState } from '../../hooks/useActiveSpectrumPeaksViewState.js';
import useSpectrum from '../../hooks/useSpectrum.js';
import { usePeakShapesPath } from './usePeakShapesPath.js';
const emptyData = { peaks: {}, display: {} };
function PeaksShapes() {
const { shiftY } = useScale();
const { showPeaksShapes, showPeaksSum } = useActiveSpectrumPeaksViewState();
const activeSpectrum = useActiveSpectrum();
const spectrum = useSpectrum(emptyData) as Spectrum1D;
if (!spectrum?.peaks?.values || !spectrum.display.isVisible) {
return null;
}
const shift = (activeSpectrum?.index || 0) * shiftY;
return (
{showPeaksShapes && }
{showPeaksSum && }
);
}
function PeaksShapesItems(props: { vAlign: number }) {
const spectrum = useSpectrum(emptyData) as Spectrum1D;
const getPath = usePeakShapesPath(spectrum);
return (
{' '}
{spectrum.peaks.values.map((peak) => {
const { fill, path } = getPath({ target: 'peakShape', peak });
return (
);
})}
);
}
function PeaksShapesSum(props: { vAlign: number }) {
const spectrum = useSpectrum(emptyData) as Spectrum1D;
const getPath = usePeakShapesPath(spectrum);
const { fill, path } = getPath({
target: 'peaksSum',
peaks: spectrum.peaks.values,
});
return (
);
}
export default PeaksShapes;