import React, { isValidElement, Children } from 'react';
import { CollectionPageHeader, } from '../../components/CollectionPageHeaderNew';
import { CollectionPageContent, } from '../../components/CollectionPageContent';
import { CollectionPageFooter, } from '../../components/CollectionPageFooter';
export function useCollectionPageChild(children) {
    // Mapping to raw WDS components since original Page filtering none expected components: https://github.com/wix-private/wix-design-systems/blob/master/packages/wix-style-react/src/Page/Page.js#L626
    return Children.toArray(children)
        .map((child, index) => {
        let newChild = null;
        if (isValidElement(child)) {
            switch (child.type) {
                case CollectionPageHeader:
                    const header = child;
                    newChild = header.type.useCollectionPageHeader(header);
                    break;
                case CollectionPageContent:
                    const content = child;
                    newChild = content.type.useCollectionPageContent(content);
                    break;
                case CollectionPageFooter:
                    const footer = child;
                    newChild = footer.type.useCollectionPageFooter(footer);
                    break;
                default:
                    // WIP: Eventually once we will support all child types this will return null
                    newChild = child;
            }
        }
        if (newChild === null) {
            return null;
        }
        return React.cloneElement(newChild, { key: index });
    })
        .filter((c) => c);
}
//# sourceMappingURL=useCollectionPageChild.js.map