import { createElement } from "react";
import { NavigationContext } from "@contember/ui";
import { useEnvironment } from "@contember/binding";
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__ */ createElement(NavigationContext.Provider, {
    value: (val) => {
      if (!isRoutingLinkTarget(val)) {
        throw new PageNotFound("Invalid request");
      }
      return linkFactory(parseLinkTarget(val, env));
    }
  }, props.children);
};
export { NavigationProvider };
//# sourceMappingURL=NavigationProvider.js.map
