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/FloorMapOverview.tsx
var FloorMapOverview_exports = {};
__export(FloorMapOverview_exports, {
  FloorMapOverview: () => FloorMapOverview,
  default: () => FloorMapOverview_default
});
module.exports = __toCommonJS(FloorMapOverview_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_utils = require("@pisell/utils");
var import_ItemLayer = __toESM(require("./ItemLayer"));
var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
var import_floorMapCanvasDisplay = require("../utils/floorMapCanvasDisplay");
var import_mergeCanvasesForTabs = require("../utils/mergeCanvasesForTabs");
var import_floorMapLayoutConstants = require("../floorMapLayoutConstants");
var import_FloorMapOverview = require("./FloorMapOverview.less");
var I18N_OVERVIEW_AREA_BADGE = "pisell-floor-map-layout.overview.area-title-badge";
var I18N_EMPTY = "pisell-floor-map-layout.overview.empty";
function FloorMapOverview(props) {
  var _a, _b;
  const {
    overviewLayout,
    config,
    itemUnit = "pixel",
    renderItem,
    viewportScale,
    enableHover = true,
    onItemClick,
    onItemHover,
    onItemLeave,
    getMergedItemWrapperStyle,
    readModeSelectedItemId,
    className
  } = props;
  const engineCtx = (0, import_useEngineContext.default)();
  const engineLocale = ((_b = (_a = engineCtx == null ? void 0 : engineCtx.engine) == null ? void 0 : _a.props) == null ? void 0 : _b.locale) || "zh-CN";
  if (overviewLayout.areas.length === 0) {
    return /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(
          `${import_floorMapLayoutConstants.FLOOR_MAP_LAYOUT_CLASS_PREFIX}-overview`,
          `${import_floorMapLayoutConstants.FLOOR_MAP_LAYOUT_CLASS_PREFIX}-overview--empty`,
          className
        ),
        style: {
          width: "100%",
          height: "100%"
        }
      },
      import_utils.locales.getText(I18N_EMPTY)
    );
  }
  const displayNameById = /* @__PURE__ */ new Map();
  for (const canvas of (0, import_mergeCanvasesForTabs.mergeCanvasesForTabs)(config)) {
    displayNameById.set(
      canvas.id,
      (0, import_floorMapCanvasDisplay.getFloorMapCanvasDisplayName)(canvas, engineLocale)
    );
  }
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: (0, import_classnames.default)(`${import_floorMapLayoutConstants.FLOOR_MAP_LAYOUT_CLASS_PREFIX}-overview`, className),
      style: {
        position: "relative",
        width: overviewLayout.totalWidth,
        height: overviewLayout.totalHeight
      }
    },
    overviewLayout.areas.map((area) => {
      const displayName = displayNameById.get(area.canvasId) ?? area.canvasId;
      const safeScale = viewportScale != null && Number.isFinite(viewportScale) && viewportScale > 0 ? viewportScale : 1;
      const inverseScale = 1 / safeScale;
      return /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          key: area.canvasId,
          className: `${import_floorMapLayoutConstants.FLOOR_MAP_LAYOUT_CLASS_PREFIX}-overview-area-block`,
          style: {
            position: "absolute",
            left: area.x,
            top: area.y,
            width: area.contentWidth
          }
        },
        /* @__PURE__ */ import_react.default.createElement(
          "div",
          {
            className: `${import_floorMapLayoutConstants.FLOOR_MAP_LAYOUT_CLASS_PREFIX}-overview-area-title`,
            title: displayName,
            style: {
              height: area.titleBandHeight,
              transform: `scale(${inverseScale})`,
              transformOrigin: "top left",
              width: `${100 * safeScale}%`,
              maxWidth: `${area.contentWidth * safeScale}px`
            }
          },
          /* @__PURE__ */ import_react.default.createElement("span", { className: `${import_floorMapLayoutConstants.FLOOR_MAP_LAYOUT_CLASS_PREFIX}-overview-area-title-inner` }, /* @__PURE__ */ import_react.default.createElement("span", { className: `${import_floorMapLayoutConstants.FLOOR_MAP_LAYOUT_CLASS_PREFIX}-overview-area-title-badge` }, import_utils.locales.getText(I18N_OVERVIEW_AREA_BADGE)), /* @__PURE__ */ import_react.default.createElement("span", { className: `${import_floorMapLayoutConstants.FLOOR_MAP_LAYOUT_CLASS_PREFIX}-overview-area-title-text` }, displayName))
        ),
        /* @__PURE__ */ import_react.default.createElement(
          "div",
          {
            className: `${import_floorMapLayoutConstants.FLOOR_MAP_LAYOUT_CLASS_PREFIX}-overview-area`,
            style: {
              width: area.contentWidth,
              height: area.contentHeight
            }
          },
          /* @__PURE__ */ import_react.default.createElement(
            import_ItemLayer.default,
            {
              items: area.items,
              renderItem,
              viewportScale,
              cellSize: area.cellSize,
              itemUnit,
              contentWidth: area.contentWidth,
              contentHeight: area.contentHeight,
              contentOffsetX: area.contentOffsetX,
              contentOffsetY: area.contentOffsetY,
              enableHover,
              itemHoverOutline: enableHover,
              onItemClick,
              onItemHover,
              onItemLeave,
              getMergedItemWrapperStyle,
              readModeSelectedItemId
            }
          )
        )
      );
    })
  );
}
var FloorMapOverview_default = FloorMapOverview;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  FloorMapOverview
});
