import { tooltipLegacyDriverFactory } from '../Tooltip/Tooltip.driver';
const getTextElement = element => element.querySelector(`[data-hook="loader-text"]`);
const getStatusIndicatorElement = element => element.querySelector(`[data-hook="loader-status-indicator"]`);
const loaderDriverFactory = ({ element, eventTrigger }) => {
    const tooltipTestkit = () => tooltipLegacyDriverFactory({
        element: element.querySelector(`[data-hook="loader-tooltip"]`),
        eventTrigger,
    });
    return {
        component: () => element,
        exists: () => !!element,
        /** returns the loader color ('blue' or 'white') */
        getColor: () => element.getAttribute('data-color'),
        /** returns the element text */
        getText: () => getTextElement(element).textContent,
        /** true if the element has text */
        hasText: () => !!getTextElement(element),
        /** true if the status indicator is rendered */
        statusIndicatorExists: () => !!getStatusIndicatorElement(element),
        /** true when using the large loader */
        isLarge: () => element.getAttribute('data-size') === 'large',
        /** true when using the medium loader */
        isMedium: () => element.getAttribute('data-size') === 'medium',
        /** true when using the small loader */
        isSmall: () => element.getAttribute('data-size') === 'small',
        /** true when using the tiny loader */
        isTiny: () => element.getAttribute('data-size') === 'tiny',
        /** true when loader is in loading status */
        isLoading: () => element.getAttribute('data-status') === 'loading',
        /** true when loader is in loading-with-errors status */
        isLoadingWithErrors: () => element.getAttribute('data-status') === 'loadingWithErrors',
        /** true when loader is in error status */
        isError: () => element.getAttribute('data-status') === 'error',
        /** true when loader is in success status */
        isSuccess: () => element.getAttribute('data-status') === 'success',
        /** trigger the tooltip and returns the value of the tooltip message (async function) */
        getStatusMessage: () => {
            tooltipTestkit().mouseEnter();
            return tooltipTestkit().getTooltipText();
        },
    };
};
export default loaderDriverFactory;
//# sourceMappingURL=Loader.driver.js.map