"use client";
import { createContext, useContext, forwardRef } from 'react';
import { jsx } from 'react/jsx-runtime';

// src/lib/router-context.tsx
var RouterContext = createContext(null);
function RouterProvider({ children, value }) {
  return /* @__PURE__ */ jsx(RouterContext.Provider, { value, children });
}
function useRouter() {
  const context = useContext(RouterContext);
  if (!context) {
    return {
      push: (href) => {
        window.location.href = href;
      },
      replace: (href) => {
        window.location.replace(href);
      },
      back: () => {
        window.history.back();
      },
      forward: () => {
        window.history.forward();
      },
      refresh: () => {
        window.location.reload();
      },
      prefetch: () => {
      }
    };
  }
  return {
    push: context.navigate,
    replace: context.replace,
    back: context.back,
    forward: context.forward,
    refresh: () => {
      window.location.reload();
    },
    prefetch: context.prefetch
  };
}
function usePathname() {
  const context = useContext(RouterContext);
  return context?.pathname ?? (typeof window !== "undefined" ? window.location.pathname : "/");
}
function useLink() {
  const context = useContext(RouterContext);
  if (!context) {
    return forwardRef(function FallbackLink({ href, children, ...props }, ref) {
      return /* @__PURE__ */ jsx("a", { href, ref, ...props, children });
    });
  }
  return context.Link;
}

export { RouterProvider, useLink, usePathname, useRouter };
//# sourceMappingURL=chunk-QWG2FMUN.mjs.map
//# sourceMappingURL=chunk-QWG2FMUN.mjs.map