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/pisellRecordBoard/shellFrame/ResourceWall/PisellRecordBoardResourceWallView.tsx
var PisellRecordBoardResourceWallView_exports = {};
__export(PisellRecordBoardResourceWallView_exports, {
  DEFAULT_RESOURCE_WALL_FILTER_FIELD_KEY: () => DEFAULT_RESOURCE_WALL_FILTER_FIELD_KEY,
  PisellRecordBoardResourceWallView: () => PisellRecordBoardResourceWallView
});
module.exports = __toCommonJS(PisellRecordBoardResourceWallView_exports);
var import_react = __toESM(require("react"));
var import_antd = require("antd");
var import_useRecordBoardContext = require("../../hooks/useRecordBoardContext");
var import_VenueWallCard = require("./VenueWallCard");
var DEFAULT_RESOURCE_WALL_FILTER_FIELD_KEY = "resource_wall_resource_ids";
var LAYOUT_PRESETS = [
  { key: "1x1", cols: 1, rows: 1 },
  { key: "1x2", cols: 2, rows: 1 },
  { key: "2x3", cols: 3, rows: 2 },
  { key: "3x2", cols: 2, rows: 3 },
  { key: "3x3", cols: 3, rows: 3 }
];
var PisellRecordBoardResourceWallView = (props) => {
  var _a, _b, _c;
  const { className, style, loading, cards: cardsProp } = props;
  const ctx = (0, import_useRecordBoardContext.useRecordBoardContext)();
  const filterKey = props.filterFieldKey ?? DEFAULT_RESOURCE_WALL_FILTER_FIELD_KEY;
  const selectedRaw = (_c = (_b = (_a = ctx.searchParams) == null ? void 0 : _a.filter) == null ? void 0 : _b.values) == null ? void 0 : _c[filterKey];
  const selectedIds = (0, import_react.useMemo)(() => {
    if (!Array.isArray(selectedRaw)) return null;
    return selectedRaw.map((x) => String(x));
  }, [selectedRaw]);
  const cards = cardsProp ?? [];
  const visibleCards = (0, import_react.useMemo)(() => {
    if (selectedIds == null || selectedIds.length === 0) {
      return cards;
    }
    const set = new Set(selectedIds);
    return cards.filter((c) => set.has(String(c.resourceId)));
  }, [cards, selectedIds]);
  const [now, setNow] = (0, import_react.useState)(() => /* @__PURE__ */ new Date());
  (0, import_react.useEffect)(() => {
    const id = window.setInterval(() => setNow(/* @__PURE__ */ new Date()), 1e3);
    return () => window.clearInterval(id);
  }, []);
  const selectedLayout = LAYOUT_PRESETS[2];
  const shell = /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className,
      style: {
        flex: 1,
        minHeight: 0,
        display: "flex",
        flexDirection: "column",
        overflow: "hidden",
        background: "#f5f7fb",
        color: "#0f172a",
        ...style
      }
    },
    /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        style: {
          flexShrink: 0,
          borderBottom: "1px solid #e2e8f0",
          padding: "16px 24px",
          display: "flex",
          alignItems: "center",
          justifyContent: "space-between",
          gap: 16,
          background: "#fff"
        }
      },
      /* @__PURE__ */ import_react.default.createElement(
        "div",
        {
          style: {
            fontSize: 22,
            fontWeight: 600,
            letterSpacing: "-0.02em"
          }
        },
        now.toLocaleTimeString([], {
          hour: "2-digit",
          minute: "2-digit",
          hour12: false
        }),
        " ",
        "·",
        " ",
        now.toLocaleDateString("en-GB", {
          day: "2-digit",
          month: "short",
          year: "numeric"
        })
      )
    ),
    /* @__PURE__ */ import_react.default.createElement("div", { style: { flex: 1, minHeight: 0, padding: 12 } }, /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        style: {
          height: "100%",
          display: "grid",
          gap: 16,
          gridTemplateColumns: `repeat(${selectedLayout.cols}, minmax(0, 1fr))`,
          gridTemplateRows: `repeat(${selectedLayout.rows}, minmax(0, 1fr))`
        }
      },
      visibleCards.slice(0, selectedLayout.cols * selectedLayout.rows).map((card, index) => /* @__PURE__ */ import_react.default.createElement(import_VenueWallCard.VenueWallCard, { key: `${card.resourceId}-${index}`, card }))
    ))
  );
  if (loading) {
    return /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className,
        style: {
          flex: 1,
          minHeight: 0,
          display: "flex",
          alignItems: "center",
          justifyContent: "center",
          background: "#f5f7fb",
          ...style
        }
      },
      /* @__PURE__ */ import_react.default.createElement(import_antd.Spin, null)
    );
  }
  return shell;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  DEFAULT_RESOURCE_WALL_FILTER_FIELD_KEY,
  PisellRecordBoardResourceWallView
});
