import textDriverFactory from '../Text/Text.driver';
import { tooltipLegacyDriverFactory } from '../Tooltip/Tooltip.driver';
import { dataHooks } from './constants';
import deprecationTestkitLog from '../utils/deprecationTestkitLog';
const addItemDriverFactory = ({ element, eventTrigger, }) => {
    deprecationTestkitLog('addItemTestkitFactory legacy testkit is deprecated and will be removed in next major release. Please use the AddItemTestkit unidriver testkit instead.');
    const byHook = (hook) => element?.querySelector(`[data-hook="${hook}"]`);
    const tooltipTestkit = tooltipLegacyDriverFactory({
        // @ts-expect-error
        element: byHook(dataHooks.itemTooltip),
        eventTrigger,
    });
    const textDriver = () => 
    // @ts-ignore
    textDriverFactory({ element: byHook(dataHooks.itemText) });
    const subtitleTextDriver = () => 
    // @ts-ignore
    textDriverFactory({ element: byHook(dataHooks.itemSubtitle) });
    const baseElement = byHook(dataHooks.addItem);
    return {
        /** returns true if element in the DOM */
        exists: () => !!baseElement,
        /** returns the driver element */
        element: () => baseElement,
        /** returns value of action text */
        getText: () => textDriver().getText(),
        /** true if passed children in string exists */
        textExists: () => textDriver().exists(),
        /** returns value of tooltip content */
        getTooltipContent: () => tooltipTestkit.getTooltipText(),
        /** clicks on element */
        click: () => baseElement && eventTrigger.click(baseElement),
        /** returns value of subtitle */
        getSubtitle: () => subtitleTextDriver().getText(),
        /** returns true if element is focused */
        isFocused: () => document.activeElement === baseElement,
        /** sets focus on the element */
        focus: () => {
            if (baseElement) {
                // @ts-expect-error
                baseElement.focus();
                eventTrigger.focus(baseElement);
            }
        },
        /** removes focus on the element */
        blur: () => {
            if (baseElement) {
                // @ts-expect-error
                baseElement.blur();
                eventTrigger.blur(baseElement);
            }
        },
    };
};
export default addItemDriverFactory;
//# sourceMappingURL=AddItem.driver.js.map