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/plus/pisellReservation/components/ReservationCalendarBookingNode.tsx
var ReservationCalendarBookingNode_exports = {};
__export(ReservationCalendarBookingNode_exports, {
  ReservationCalendarBookingNode: () => ReservationCalendarBookingNode
});
module.exports = __toCommonJS(ReservationCalendarBookingNode_exports);
var import_react = __toESM(require("react"));
var import_calendarAdapter = require("../data/calendarAdapter");
var import_ReservationCalendarDayBookingRoomCard = require("./ReservationCalendarDayBookingRoomCard");
function ReservationCalendarBookingNode(props) {
  const { args, tables, calendarDragSuppressDetailRef } = props;
  const item = args.booking.item;
  const armSuppressDetailAfterDrag = () => {
    const r = calendarDragSuppressDetailRef.current;
    if (r.timer != null) {
      clearTimeout(r.timer);
      r.timer = null;
    }
    r.bookingId = item.id;
    r.timer = setTimeout(() => {
      r.bookingId = null;
      r.timer = null;
    }, 650);
  };
  const onOverlayBookingClick = (e) => {
    const r = calendarDragSuppressDetailRef.current;
    if (r.bookingId === item.id) {
      r.bookingId = null;
      if (r.timer != null) {
        clearTimeout(r.timer);
        r.timer = null;
      }
      e.preventDefault();
      e.stopPropagation();
      return;
    }
    e.stopPropagation();
    args.onOpenDetail(item);
  };
  if (item.kind === "block") {
    return /* @__PURE__ */ import_react.default.createElement(
      "button",
      {
        type: "button",
        className: "absolute inset-0 rounded-2xl px-2 py-2 text-left",
        onClick: (e) => {
          e.stopPropagation();
          args.onOpenDetail(item);
        }
      },
      /* @__PURE__ */ import_react.default.createElement("div", { className: "truncate text-sm font-medium" }, item.name)
    );
  }
  const raw = item.raw;
  if (!raw) {
    return /* @__PURE__ */ import_react.default.createElement(
      "button",
      {
        type: "button",
        draggable: true,
        onDragStart: (e) => {
          e.stopPropagation();
          args.onDragStart(item);
        },
        onDragEnd: (e) => {
          e.stopPropagation();
          armSuppressDetailAfterDrag();
        },
        onClick: onOverlayBookingClick,
        className: "absolute inset-0 rounded-2xl px-2 py-2 text-left"
      },
      /* @__PURE__ */ import_react.default.createElement("div", { className: "truncate text-sm" }, item.name)
    );
  }
  const row = (0, import_calendarAdapter.findMergedTableRowForBookingRaw)(
    raw,
    tables
  );
  return /* @__PURE__ */ import_react.default.createElement(
    "div",
    {
      className: "absolute inset-0 min-h-0 cursor-grab overflow-hidden rounded-2xl active:cursor-grabbing",
      draggable: true,
      onDragStart: (e) => {
        e.stopPropagation();
        args.onDragStart(item);
      },
      onDragEnd: (e) => {
        e.stopPropagation();
        armSuppressDetailAfterDrag();
      },
      onClick: onOverlayBookingClick,
      onKeyDown: (e) => {
        if (e.key === "Enter" || e.key === " ") {
          e.preventDefault();
          e.stopPropagation();
          args.onOpenDetail(item);
        }
      },
      role: "button",
      tabIndex: 0
    },
    /* @__PURE__ */ import_react.default.createElement(
      import_ReservationCalendarDayBookingRoomCard.ReservationCalendarDayBookingRoomCard,
      {
        raw,
        tableRow: row ?? null,
        overlayWidthPx: args.overlayWidthPx
      }
    )
  );
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  ReservationCalendarBookingNode
});
