var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
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 __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/components/pisellFloorMapLayout/components/MapLayer.tsx
var MapLayer_exports = {};
__export(MapLayer_exports, {
  MapLayer: () => MapLayer,
  default: () => MapLayer_default
});
module.exports = __toCommonJS(MapLayer_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_MapLayer = require("./MapLayer.less");
var PREFIX = "pisell-floor-map-layout";
function toCssSize(v) {
  if (v === void 0) return void 0;
  return typeof v === "number" ? `${v}px` : v;
}
function MapLayer(props) {
  const {
    config = {},
    contentWidth = 0,
    contentHeight = 0,
    cellSize = 64,
    preferCanvasGrid = false,
    pointerEventsNone = false,
    children,
    className
  } = props;
  const {
    backgroundType = "none",
    backgroundColor,
    backgroundImage,
    backgroundSvg,
    showGrid = false,
    padding,
    gap
  } = config;
  const paddingCss = toCssSize(padding);
  const gapCss = toCssSize(gap);
  const backgroundStyle = {};
  if (preferCanvasGrid) {
    backgroundStyle.backgroundColor = "transparent";
  } else if (backgroundType === "color" && backgroundColor) {
    backgroundStyle.backgroundColor = backgroundColor;
  }
  if (backgroundType === "image" && backgroundImage) {
    backgroundStyle.backgroundImage = `url(${backgroundImage})`;
    backgroundStyle.backgroundSize = "cover";
    backgroundStyle.backgroundPosition = "center";
  }
  if (backgroundType === "svg" && backgroundSvg) {
    const isUrl = backgroundSvg.startsWith("http") || backgroundSvg.startsWith("/");
    backgroundStyle.backgroundImage = isUrl ? `url(${backgroundSvg})` : `url("data:image/svg+xml,${encodeURIComponent(backgroundSvg)}")`;
    backgroundStyle.backgroundSize = "cover";
    backgroundStyle.backgroundPosition = "center";
  }
  const containerStyle = {
    padding: paddingCss,
    gap: gapCss,
    ...pointerEventsNone ? { pointerEvents: "none" } : {}
  };
  const snapStep = Math.max(1, Number(config.snapStep ?? 1) || 1);
  const gridSize = Math.max(50, Math.round(cellSize * snapStep));
  const gridStyle = showGrid ? {
    backgroundImage: `
          linear-gradient(to right, rgba(0,0,0,0.08) 1px, transparent 1px),
          linear-gradient(to bottom, rgba(0,0,0,0.08) 1px, transparent 1px)
        `,
    backgroundSize: `${gridSize}px ${gridSize}px`
  } : {};
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(`${PREFIX}-map-layer`, className),
      style: { ...backgroundStyle, ...containerStyle, ...gridStyle }
    },
    children
  );
}
var MapLayer_default = MapLayer;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  MapLayer
});
