/**
 * tdesign v0.41.7
 * (c) 2022 tdesign
 * @license MIT
 */

'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var VueCompositionAPI = require('@vue/composition-api');

function useDefaultValue(value, defaultValue, onChange, propsName, eventName) {
  var _getCurrentInstance = VueCompositionAPI.getCurrentInstance(),
      emit = _getCurrentInstance.emit;

  var internalValue = VueCompositionAPI.ref();
  internalValue.value = defaultValue;

  if (typeof value.value !== "undefined") {
    return [value, function (newValue) {
      for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
        args[_key - 1] = arguments[_key];
      }

      emit.apply(void 0, ["update:".concat(propsName), newValue].concat(args));
      onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, [newValue].concat(args));
      emit.apply(void 0, [eventName, newValue].concat(args));
    }];
  }

  return [internalValue, function (newValue) {
    internalValue.value = newValue;

    for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
      args[_key2 - 1] = arguments[_key2];
    }

    emit.apply(void 0, [eventName, newValue].concat(args));
    onChange === null || onChange === void 0 ? void 0 : onChange.apply(void 0, [newValue].concat(args));
  }];
}

exports["default"] = useDefaultValue;
//# sourceMappingURL=useDefaultValue.js.map
