import { jsx as _jsx } from "@emotion/react/jsx-runtime";
import React from "react";
import { useLocation } from "react-router-dom";
import { withSuspense } from "./components/PageSuspense";
import { useFetchPage } from "./hooks/useFetchPage";
import { usePageSource } from "./hooks/useSource";
import { RuntimeContext } from "./RuntimeContext";
import { ModalPageSourceContext } from "./SourceContext";
import * as queryString from "./utils/query-string";
const ModalPageProvider = ({ children }) => {
    const location = useLocation();
    const query = React.useMemo(() => queryString.parse(location.search), [location.search]);
    useFetchPage(query.modalPage);
    const modalPage = RuntimeContext.useSelectState((runtime) => runtime.maps.page[query.modalPage || ""]);
    const { source: modalPageSource } = usePageSource({ page: modalPage }, query.modalRowId);
    return (_jsx(ModalPageSourceContext.Provider, Object.assign({ value: modalPageSource }, { children: children })));
};
export default withSuspense(ModalPageProvider);
//# sourceMappingURL=ModalPageProvider.js.map