import { useGlobalConfig } from '../../../hooks/base/useGlobalConfig/index.mjs';
import { unref } from 'vue';
import { useRoute } from 'vue-router';

function transformRouteValue(value, defaultValue, transform) {
  const finalValue = value !== void 0 ? value : defaultValue;
  if (!transform) {
    return finalValue;
  }
  if (typeof transform === "function") {
    return transform(finalValue);
  }
  if (transform.get) {
    return transform.get(finalValue);
  }
  return finalValue;
}
function getRouteQuery(name, options) {
  const router = useGlobalConfig("router");
  const currentRoute = unref(router.value?.currentRoute);
  const { route = currentRoute || useRoute(), transform, defaultValue } = options || {};
  const queryValue = route.query[name];
  return transformRouteValue(queryValue, defaultValue, transform);
}
function getRouteParams(name, options) {
  const router = useGlobalConfig("router");
  const currentRoute = unref(router.value?.currentRoute);
  const { route = currentRoute || useRoute(), transform, defaultValue } = options || {};
  const paramsValue = route.params[name];
  return transformRouteValue(paramsValue, defaultValue, transform);
}

export { getRouteParams, getRouteQuery };
//# sourceMappingURL=router.mjs.map
