import { Children } from 'react';
/**
 * Main component to conditionally render content based on child components' conditions.
 *
 * @component
 * @example
 * // Example usage of Show component
 * <Show>
 *   <Show.When isTrue={true}>This will be shown</Show.When>
 *   <Show.Else>This will be shown if no conditions are true</Show.Else>
 * </Show>
 *
 * @param {Object} props - The properties of the Show component.
 * @param {ReactNode} props.children - The child components to evaluate.
 *
 * @returns {ReactNode} The rendered content based on the conditions.
 */
export function Show({ children }) {
    let when = undefined;
    let otherwise = undefined;
    Children.forEach(children, (child) => {
        const element = child;
        if (!element.props.isTrue) {
            otherwise = element;
        }
        else if (!when && element.props.isTrue === true) {
            when = element;
        }
    });
    return when || otherwise;
}
/**
 * Component to render content when a specific condition is true.
 *
 * @component
 * @example
 * // Example usage of Show.When component
 * <Show.When isTrue={true}>This will be shown</Show.When>
 *
 * @param {Object} props - The properties of the Show.When component.
 * @param {boolean} props.isTrue - The condition to check.
 * @param {ReactNode} props.children - The content to render if the condition is true.
 *
 * @returns {ReactNode} The rendered content if the condition is true, otherwise null.
 */
Show.When = ({ isTrue, children }) => {
    return isTrue ? children : undefined;
};
/**
 * Component to render alternative content when none of the conditions are true.
 *
 * @component
 * @example
 * // Example usage of Show.Else component
 * <Show.Else>This will be shown if no conditions are true</Show.Else>
 *
 * @param {Object} props - The properties of the Show.Else component.
 * @param {ReactNode} [props.children] - The alternative content to render (used if render is not provided).
 *
 * @returns {ReactNode} The rendered alternative content.
 */
Show.Else = ({ children }) => {
    return children || undefined;
};
//# sourceMappingURL=Show.jsx.map