function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
export function debounce(func, wait) {
  var timeout = null;
  return function () {
    for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
      args[_key] = arguments[_key];
    }
    if (timeout) {
      clearTimeout(timeout);
    }
    timeout = setTimeout(function () {
      func.apply(void 0, args);
    }, wait);
  };
}
export function mergeRefs() {
  for (var _len2 = arguments.length, refs = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
    refs[_key2] = arguments[_key2];
  }
  return function (value) {
    refs.forEach(function (ref) {
      if (typeof ref === 'function') {
        ref(value);
      } else if (ref && _typeof(ref) === 'object') {
        ref.current = value;
      }
    });
  };
}

/**
 * 安全的滚动函数，包含错误处理和边界检查
 * @param element - 要滚动的元素
 * @param options - 滚动选项
 */
export function safeScrollTo(element, options) {
  try {
    if (!element || !element.scrollTo) {
      return false;
    }
    var _options$left = options.left,
      left = _options$left === void 0 ? 0 : _options$left,
      _options$behavior = options.behavior,
      behavior = _options$behavior === void 0 ? 'smooth' : _options$behavior;
    var maxScrollLeft = Math.max(0, element.scrollWidth - element.clientWidth);
    var safeLeft = Math.max(0, Math.min(left, maxScrollLeft));
    element.scrollTo({
      left: safeLeft,
      behavior: behavior
    });
    return true;
  } catch (error) {
    console.warn('Failed to scroll element:', error);
    return false;
  }
}