"use client";
'use strict';

var react = require('react');
var jsxRuntime = require('react/jsx-runtime');

// src/lib/router-context.tsx
var RouterContext = react.createContext(null);
function RouterProvider({ children, value }) {
  return /* @__PURE__ */ jsxRuntime.jsx(RouterContext.Provider, { value, children });
}
function useRouter() {
  const context = react.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 = react.useContext(RouterContext);
  return context?.pathname ?? (typeof window !== "undefined" ? window.location.pathname : "/");
}
function useLink() {
  const context = react.useContext(RouterContext);
  if (!context) {
    return react.forwardRef(function FallbackLink({ href, children, ...props }, ref) {
      return /* @__PURE__ */ jsxRuntime.jsx("a", { href, ref, ...props, children });
    });
  }
  return context.Link;
}

exports.RouterProvider = RouterProvider;
exports.useLink = useLink;
exports.usePathname = usePathname;
exports.useRouter = useRouter;
//# sourceMappingURL=chunk-S7KHTUHA.js.map
//# sourceMappingURL=chunk-S7KHTUHA.js.map