'use strict';

var index = require('../../../hooks/base/useGlobalConfig/index.js');
var vue = require('vue');
var vueRouter = require('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 = index.useGlobalConfig("router");
  const currentRoute = vue.unref(router.value?.currentRoute);
  const { route = currentRoute || vueRouter.useRoute(), transform, defaultValue } = options || {};
  const queryValue = route.query[name];
  return transformRouteValue(queryValue, defaultValue, transform);
}
function getRouteParams(name, options) {
  const router = index.useGlobalConfig("router");
  const currentRoute = vue.unref(router.value?.currentRoute);
  const { route = currentRoute || vueRouter.useRoute(), transform, defaultValue } = options || {};
  const paramsValue = route.params[name];
  return transformRouteValue(paramsValue, defaultValue, transform);
}

exports.getRouteParams = getRouteParams;
exports.getRouteQuery = getRouteQuery;
//# sourceMappingURL=router.js.map
