import { Page } from '@wix/design-system';
import React, { Children } from 'react';
import { CollectionPageContextProvider } from '../../providers';
import { usePageHeader } from '../../hooks/usePageHeader';
import { useCollectionPageState } from '@wix/bex-core/react';
import { PageWrapperBase } from './PageWrapperBase';
export function InfiniteScrollPage({ children, ...props }) {
    // WSR <Page /> expects a flattened children array
    const childrenArr = Children.toArray(children);
    const { title: pageTitle, header } = usePageHeader(childrenArr);
    const collectionPageState = useCollectionPageState({ pageTitle, hasHeader: header != null }, props.state);
    const { pageState } = collectionPageState;
    return (React.createElement(CollectionPageContextProvider, { value: collectionPageState },
        React.createElement(PageWrapperBase, { pageState: pageState },
            React.createElement(Page, { ...props }, childrenArr))));
}
//# sourceMappingURL=InfiniteScrollPage.js.map