import { helper } from '@ember/component/helper';
import { assert } from '@ember/debug';

/**
 * Helper that returns a default value if the passed argument is undefined
 *
 * @param {array} param
 * @property {V} 0 - value to be returned if it's defined
 * @property {DV} 1 - default value to be returned if value is undefined
 */
function argOrDefault([value, defaultValue]) {
  assert('`defaultValue` must be provided', defaultValue !== undefined);
  if (value !== undefined) {
    return value;
  }
  return defaultValue;
}

//eslint-disable-next-line
function argOrDefaultDecorator(defaultValue, configKey) {
  return function (_target, key) {
    return {
      get() {
        return argOrDefault([this.args[key], defaultValue]);
      }
    };
  };
}
var argOrDefault$1 = helper(argOrDefault);

export { argOrDefault, argOrDefaultDecorator, argOrDefault$1 as default };
//# sourceMappingURL=arg-or-default.js.map
