var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/PisellProcedure/utils/layoutRatio.ts
var layoutRatio_exports = {};
__export(layoutRatio_exports, {
  LAYOUT_RATIO_PRESETS: () => LAYOUT_RATIO_PRESETS,
  calculateRatioPercent: () => calculateRatioPercent,
  generateRatioStyles: () => generateRatioStyles,
  parseLayoutRatio: () => parseLayoutRatio
});
module.exports = __toCommonJS(layoutRatio_exports);
var parseLayoutRatio = (ratio) => {
  if (!ratio || typeof ratio !== "string") {
    return [7, 3];
  }
  const parts = ratio.split(":");
  if (parts.length !== 2) {
    return [7, 3];
  }
  const content = Number(parts[0]);
  const sidebar = Number(parts[1]);
  if (isNaN(content) || isNaN(sidebar) || content <= 0 || sidebar <= 0) {
    return [7, 3];
  }
  return [content, sidebar];
};
var calculateRatioPercent = (ratio) => {
  const [content, sidebar] = parseLayoutRatio(ratio);
  const total = content + sidebar;
  return {
    contentPercent: content / total * 100,
    sidebarPercent: sidebar / total * 100
  };
};
var generateRatioStyles = (ratio, gap = 16) => {
  const { contentPercent, sidebarPercent } = calculateRatioPercent(ratio);
  const sidebarWidth = `calc(${sidebarPercent}% - ${gap / 2}px)`;
  const sidebarFlex = `0 0 ${sidebarWidth}`;
  return {
    contentStyle: {
      flex: `0 0 calc(${contentPercent}% - ${gap / 2}px)`,
      maxWidth: `calc(${contentPercent}% - ${gap / 2}px)`
    },
    sidebarStyle: {
      // 使用 CSS 变量，让 CSS 中的 !important 可以引用这些值
      "--sidebar-ratio-width": sidebarWidth,
      "--sidebar-ratio-max-width": sidebarWidth,
      "--sidebar-ratio-flex": sidebarFlex
    }
  };
};
var LAYOUT_RATIO_PRESETS = [
  { label: "7:3", value: "7:3" },
  { label: "6:4", value: "6:4" }
];
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  LAYOUT_RATIO_PRESETS,
  calculateRatioPercent,
  generateRatioStyles,
  parseLayoutRatio
});
