function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/*
 * @Author: han.wang
 * @Date: 2025-12-11 12:30:12
 * @LastEditors: han.wang
 * @LastEditTime: 2025-12-11 16:33:54
 * @Description: 
 */

/**
 * 布局比例工具函数
 * @description 用于解析和计算内容区与信息区的布局比例
 */

/**
 * 解析比例字符串
 * @param ratio 比例字符串，如 '7:3'
 * @returns [内容区比例, 信息区比例]
 * @example
 * parseLayoutRatio('7:3') // => [7, 3]
 * parseLayoutRatio('6:4') // => [6, 4]
 */
export var parseLayoutRatio = function parseLayoutRatio(ratio) {
  if (!ratio || typeof ratio !== 'string') {
    return [7, 3]; // 默认比例
  }
  var parts = ratio.split(':');
  if (parts.length !== 2) {
    return [7, 3]; // 默认比例
  }
  var content = Number(parts[0]);
  var sidebar = Number(parts[1]);
  // 确保解析出的数字是有效的
  if (isNaN(content) || isNaN(sidebar) || content <= 0 || sidebar <= 0) {
    return [7, 3]; // 默认比例
  }
  return [content, sidebar];
};

/**
 * 计算百分比
 * @param ratio 比例字符串，如 '7:3'
 * @returns { contentPercent, sidebarPercent }
 * @example
 * calculateRatioPercent('7:3') // => { contentPercent: 70, sidebarPercent: 30 }
 */
export var calculateRatioPercent = function calculateRatioPercent(ratio) {
  var _parseLayoutRatio = parseLayoutRatio(ratio),
    _parseLayoutRatio2 = _slicedToArray(_parseLayoutRatio, 2),
    content = _parseLayoutRatio2[0],
    sidebar = _parseLayoutRatio2[1];
  var total = content + sidebar;
  return {
    contentPercent: content / total * 100,
    sidebarPercent: sidebar / total * 100
  };
};

/**
 * 生成 flex 比例样式
 * @param ratio 比例字符串，如 '7:3'
 * @param gap 间距（px）
 * @returns { contentStyle, sidebarStyle }
 */
export var generateRatioStyles = function generateRatioStyles(ratio) {
  var gap = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 16;
  var _calculateRatioPercen = calculateRatioPercent(ratio),
    contentPercent = _calculateRatioPercen.contentPercent,
    sidebarPercent = _calculateRatioPercen.sidebarPercent;
  var sidebarWidth = "calc(".concat(sidebarPercent, "% - ").concat(gap / 2, "px)");
  var sidebarFlex = "0 0 ".concat(sidebarWidth);
  return {
    contentStyle: {
      flex: "0 0 calc(".concat(contentPercent, "% - ").concat(gap / 2, "px)"),
      maxWidth: "calc(".concat(contentPercent, "% - ").concat(gap / 2, "px)")
    },
    sidebarStyle: {
      // 使用 CSS 变量，让 CSS 中的 !important 可以引用这些值
      '--sidebar-ratio-width': sidebarWidth,
      '--sidebar-ratio-max-width': sidebarWidth,
      '--sidebar-ratio-flex': sidebarFlex
    }
  };
};

/**
 * 预设比例选项
 */
export var LAYOUT_RATIO_PRESETS = [{
  label: '7:3',
  value: '7:3'
}, {
  label: '6:4',
  value: '6:4'
}];