import { inject, watch } from 'vue';
import { queryParamsKey } from '../constants.mjs';

const useWatchModelChange = (modelValue, options) => {
  const queryParams = inject(queryParamsKey);
  if (queryParams && !options.noDefaultSync) {
    modelValue.value = queryParams.value[options.prop];
  }
  watch(modelValue, (newValue) => {
    if (queryParams) {
      queryParams.value[options.prop] = newValue;
    }
  });
  watch(
    () => queryParams?.value?.[options.prop],
    (newValue) => {
      modelValue.value = newValue;
    }
  );
};

export { useWatchModelChange };
//# sourceMappingURL=useWatchModelChange.mjs.map
