import React, { useEffect, useState } from 'react';
import { useWixPatternsInitialProps } from '../WixPatternsInitialPropsProvider';
import { WixPatternsContainerProvider } from '../WixPatternsContainerProvider';
import { useWixPatternsContainerOverrides } from '../WixPatternsContainerOverridesContext';
import { buildWixPatternsContainer } from '../../state';
export function CairoProvider({ value, children, localCache = true, contextType = 'SITE', layoutType, ...rest }) {
    const containerOverrides = useWixPatternsContainerOverrides();
    const initialProps = useWixPatternsInitialProps();
    const [container] = useState(() => buildWixPatternsContainer(value, {
        containerOverrides,
        initialProps,
        localCache,
        contextType,
        layoutType,
        ...rest,
    }));
    useState(() => {
        container.initialFetch();
    });
    useEffect(() => {
        return container.init();
    }, []);
    return (React.createElement(WixPatternsContainerProvider, { value: container }, children));
}
//# sourceMappingURL=CairoProvider.js.map