import { NavigationContext } from "@contember/ui";
import { useEnvironment } from "@contember/binding";
import { jsx } from "react/jsx-runtime";
import { useRoutingLinkFactory, isRoutingLinkTarget } from "../../routing/useRoutingLink.js";
import { PageNotFound } from "../../routing/urlMapper.js";
import { parseLinkTarget } from "../../routing/binding/LinkLanguage.js";
const NavigationProvider = (props) => {
  const env = useEnvironment();
  const linkFactory = useRoutingLinkFactory();
  return /* @__PURE__ */ jsx(NavigationContext.Provider, {
    value: (val) => {
      if (!isRoutingLinkTarget(val)) {
        throw new PageNotFound("Invalid request");
      }
      return linkFactory(parseLinkTarget(val, env));
    },
    children: props.children
  });
};
export {
  NavigationProvider
};
//# sourceMappingURL=NavigationProvider.js.map
