import { jsx } from "react/jsx-runtime";
import { useState, useLayoutEffect } from "react";
import { Router } from "react-router-dom";
const AppRouter = ({ history, basename, ...props }) => {
  const [state, setState] = useState({
    action: history.action,
    location: history.location
  });
  useLayoutEffect(() => {
    const unlisten = history.listen((...args) => {
      if (args.length === 2) {
        setState({
          location: args[0],
          action: args[1]
        });
      } else {
        setState(args[0]);
      }
    });
    return () => {
      unlisten();
    };
  }, [history]);
  return /* @__PURE__ */ jsx(
    Router,
    {
      ...props,
      basename,
      location: state.location,
      navigationType: state.action,
      navigator: history
    }
  );
};
export {
  AppRouter
};
