/* @oracle/oraclejet-preact: undefined */
import { jsx, Fragment, jsxs } from 'preact/jsx-runtime';
import { styles } from './PRIVATE_Axis/themes/AxisStyles.css.js';
import { c as classNames } from './classNames-4e12b00d.js';
import { g as getClientHints } from './clientHints-f850225e.js';
import { M as MultilineText, S as SinglelineText } from './MultilineText-03e1e46c.js';
import './datatipUtils-13ab34b7.js';
import { c as getEnclosingRectDims } from './labelUtils-ec7f939f.js';
import { AxisRedwoodTheme } from './PRIVATE_Axis/themes/redwood/AxisTheme.js';
import { u as useComponentTheme } from './useComponentTheme-d2f9e47f.js';
import { u as updateVisTextStyleProperties } from './textUtils-3ed25dd1.js';
import { styles as styles$1 } from './hooks/PRIVATE_useVisDnd/themes/VisDndStyles.css.js';

/**
 * Renders the svg text with given style and svg attributes.
 */
function ChartAxisText({ style, textProps, isTitle, isInteractive, id, isRotated, isRtl, dataProps }) {
    const browser = getClientHints().browser;
    const className = classNames([
        isInteractive ? styles.isInteractive : '',
        isTitle ? styles.axisTitle : styles.axisLabel,
        !isTitle && browser === 'safari' ? styles.middleBaseline : ''
    ]);
    const isMultiline = textProps.lines.length > 1;
    return isMultiline ? (jsx(MultilineText, { class: className, text: textProps.text, dataProps: dataProps, isRtl: isRtl, isRotated: isRotated, lines: textProps.lines, lineProps: textProps.lineProps, textStyle: style, isTruncated: textProps.isTruncated, id: id })) : (jsx(SinglelineText, { style: style, isRtl: isRtl, isRotated: isRotated, dataProps: dataProps, text: textProps.lines[0], props: textProps.lineProps[0], isTruncated: textProps.isTruncated, id: id, class: className }));
}

/**
 * Renders the chart axis.
 */
function Axis({ title, titleStyle, titleProps, tickLabels, tickLabelStyle, focusedGroupIndex, axisPosition, isRtl, activeId, isTextInteractive, cursor, availSpace, dragOverStyle }) {
    const { classes } = useComponentTheme(AxisRedwoodTheme);
    const axisClass = [classes];
    switch (dragOverStyle) {
        case 'accept':
            axisClass.push(styles$1.dndDragOverSvgStyle);
            break;
        case 'reject':
            axisClass.push(styles$1.dndRejectedStyle);
            axisClass.push(styles.axisBackground);
            break;
        case 'none':
            axisClass.push(styles.axisBackground);
    }
    return (jsx(Fragment, { children: jsxs("g", { class: classNames(axisClass), style: { cursor }, children: [jsx("rect", { ...availSpace }), title && titleProps && (jsx(ChartAxisText, { textProps: titleProps, isRtl: isRtl, isRotated: titleProps.isRotated, style: updateVisTextStyleProperties(titleStyle), isTitle: true, isInteractive: false })), tickLabels.length > 0 && (jsx("g", { style: tickLabelStyle, children: tickLabels.map(({ index, ...textProps }, renderedIndex) => {
                        const isFocused = focusedGroupIndex === renderedIndex;
                        return (jsxs(Fragment, { children: [isFocused
                                    ? textProps.text &&
                                        textProps.dims && (jsx("rect", { ...getEnclosingRectDims(textProps.dims, axisPosition), class: styles.outlineRing }))
                                    : '', textProps.text && (jsx(ChartAxisText, { textProps: textProps, isTitle: false, isRotated: textProps.isRotated, isRtl: isRtl, dataProps: textProps.dataProps, isInteractive: !!isTextInteractive?.(index), id: isFocused ? activeId : '' }))] }));
                    }) }))] }) }));
}

export { Axis as A };
//# sourceMappingURL=Axis-9e78ee61.js.map
