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/PisellBasicGrid/hooks/useGridStyle.ts
var useGridStyle_exports = {};
__export(useGridStyle_exports, {
  default: () => useGridStyle_default,
  useGridStyle: () => useGridStyle
});
module.exports = __toCommonJS(useGridStyle_exports);
var import_react = require("react");
var import_utils = require("../utils");
var useGridStyle = (params) => {
  const {
    direction = "horizontal",
    wrap = "nowrap",
    columns,
    equalWidth = false,
    gap,
    rowGap,
    columnGap,
    justify = "start",
    align = "stretch",
    alignContent = "stretch"
  } = params;
  const containerStyle = (0, import_react.useMemo)(() => {
    const style = {
      display: "flex",
      flexDirection: import_utils.DIRECTION_MAP[direction],
      flexWrap: import_utils.WRAP_MAP[wrap],
      justifyContent: import_utils.JUSTIFY_MAP[justify],
      alignItems: import_utils.ALIGN_MAP[align]
    };
    if (wrap !== "nowrap") {
      style.alignContent = import_utils.ALIGN_CONTENT_MAP[alignContent];
    }
    const normalizedGap = (0, import_utils.normalizeGap)(gap);
    const normalizedRowGap = (0, import_utils.normalizeGap)(rowGap);
    const normalizedColumnGap = (0, import_utils.normalizeGap)(columnGap);
    if (normalizedRowGap || normalizedColumnGap) {
      if (normalizedRowGap) {
        style.rowGap = normalizedRowGap;
      }
      if (normalizedColumnGap) {
        style.columnGap = normalizedColumnGap;
      }
      if (normalizedGap) {
        if (!normalizedRowGap) {
          style.rowGap = normalizedGap;
        }
        if (!normalizedColumnGap) {
          style.columnGap = normalizedGap;
        }
      }
    } else if (normalizedGap) {
      style.gap = normalizedGap;
    }
    return style;
  }, [direction, wrap, justify, align, alignContent, gap, rowGap, columnGap]);
  const itemStyle = (0, import_react.useMemo)(() => {
    const style = {
      alignItems: "stretch"
    };
    if (columns !== void 0 && columns > 0) {
      const effectiveGap = columnGap ?? gap;
      style.flexBasis = (0, import_utils.calculateFlexBasis)(columns, effectiveGap);
      style.flexGrow = 0;
      style.flexShrink = 0;
    } else if (equalWidth) {
      style.flexGrow = 1;
      style.flexShrink = 1;
      style.flexBasis = 0;
    } else {
      style.flexGrow = 0;
      style.flexShrink = 0;
      style.flexBasis = "auto";
    }
    return style;
  }, [columns, equalWidth, gap, columnGap]);
  return {
    containerStyle,
    itemStyle
  };
};
var useGridStyle_default = useGridStyle;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useGridStyle
});
