import { QueryLanguage } from "@contember/binding";
import { RoutingParameter } from "../RoutingParameter.js";
const parseLinkTarget = (to, env) => {
  if (typeof to !== "string") {
    return to;
  }
  const parsedTarget = QueryLanguage.desugarTaggedMap(to, env);
  return {
    pageName: parsedTarget.name,
    parameters: Object.fromEntries(parsedTarget.entries.map((it) => {
      switch (it.value.type) {
        case "literal":
          return [it.key, typeof it.value.value === "number" ? String(it.value.value) : it.value.value ?? void 0];
        case "variable":
          return [it.key, new RoutingParameter(it.value.value)];
      }
    }))
  };
};
export { parseLinkTarget };
//# sourceMappingURL=LinkLanguage.js.map
