import { useRouter as usePagesRouter } from "next/router";
import { P, match } from "ts-pattern";
import { useEffect } from "react";
import { setLocale } from "../../state/shared-api";
import { useDispatch } from "../../runtimes/react/hooks/use-dispatch";
function useRouter() {
  try {
    const router = usePagesRouter();
    return router;
  } catch (e) {
    return;
  }
}
const useRouterLocaleSync = () => {
  const router = useRouter();
  const dispatch = useDispatch();
  useEffect(() => {
    match(router).with({ locale: P.string }, ({ locale }) => dispatch(setLocale(new Intl.Locale(locale)))).otherwise(() => {
    });
  }, [router]);
};
export {
  useRouterLocaleSync
};
//# sourceMappingURL=use-router-locale-sync.js.map