import { selectorListUniDriverFactory } from './SelectorList.uni.driver';
import { loaderUniDriverFactory } from '../Loader/Loader.uni.driver';
import { searchUniDriverFactory } from '../Search/Search.uni.driver';
import { selectorUniDriverFactory } from '../Selector/Selector.uni.driver';
import { dataHooks } from './SelectorList.helpers';
export const SelectorListPrivateUniDriverFactory = (base, body) => {
    const mainLoaderDriver = loaderUniDriverFactory(base.$(`[data-hook="${dataHooks.mainLoader}"]`), body);
    const nextPageLoaderDriver = loaderUniDriverFactory(base.$(`[data-hook="${dataHooks.nextPageLoader}"]`), body);
    const searchDriver = searchUniDriverFactory(base.$(`[data-hook="${dataHooks.search}"]`), body);
    const findInListByDataHook = dataHook => base.$(`[data-hook="${dataHook}"]`);
    const getList = () => findInListByDataHook(dataHooks.list);
    const getContent = () => findInListByDataHook(dataHooks.content);
    const getSelectors = () => getList().$$(`[data-hook="${dataHooks.selector}"]`);
    const selectorDriverAt = i => selectorUniDriverFactory(getSelectors().get(i));
    const pressKey = async (key) => {
        const el = await getContent().getNative();
        el.dispatchEvent(new KeyboardEvent('keydown', { key, bubbles: true }));
    };
    return {
        ...selectorListUniDriverFactory(base, body),
        isMainLoaderMedium: mainLoaderDriver.isMedium,
        isNextPageLoaderSmall: nextPageLoaderDriver.isSmall,
        getSearchPlaceholder: searchDriver.inputDriver.getPlaceholder,
        getSearchMaxLength: () => searchDriver.inputDriver.getMaxLength(),
        getSelectorToggleTypeAt: i => selectorDriverAt(i).toggleType(),
        isSelectorImageTinyAt: i => selectorDriverAt(i).isImageTiny(),
        isSelectorImageSmallAt: i => selectorDriverAt(i).isImageSmall(),
        isSelectorImagePortraitAt: i => selectorDriverAt(i).isImagePortrait(),
        isSelectorImageLargeAt: i => selectorDriverAt(i).isImageLarge(),
        isSelectorImageCinemaAt: i => selectorDriverAt(i).isImageCinema(),
        isSelectorImageCircleAt: i => selectorDriverAt(i).isImageCircle(),
        isSelectorImageRectangularAt: i => selectorDriverAt(i).isImageRectangular(),
        focusContent: async () => {
            const el = await getContent().getNative();
            el.focus();
        },
        clickContent: async () => {
            const el = await getContent().getNative();
            el.dispatchEvent(new MouseEvent('mousedown', { bubbles: true }));
        },
        focusSearch: () => searchDriver.inputDriver.focus(),
        pressArrowDown: () => pressKey('ArrowDown'),
        pressArrowUp: () => pressKey('ArrowUp'),
        pressEnter: () => pressKey('Enter'),
        pressSpace: () => pressKey(' '),
        isItemActiveAt: async (i) => {
            const selectorElement = await getSelectors().get(i).getNative();
            const classList = Array.from(selectorElement.classList);
            return classList.some(className => className.includes('isActive'));
        },
    };
};
//# sourceMappingURL=SelectorList.private.uni.driver.js.map