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/pisellRecordBoard/shellFrame/ResourceWall/venueWallCardPresentation.ts
var venueWallCardPresentation_exports = {};
__export(venueWallCardPresentation_exports, {
  buildVenueWallCardPresentation: () => buildVenueWallCardPresentation
});
module.exports = __toCommonJS(venueWallCardPresentation_exports);
var import_locales = require("../../../../locales");
var import_venueWallUtils = require("./venueWallUtils");
function resolveFloorLikeStatus(statusKey) {
  if (statusKey === "available") return "empty";
  if (statusKey === "boardingSoon" || statusKey === "late") return "reserved";
  return "occupied";
}
function resolveHeaderStatusKey(statusKey) {
  if (statusKey === "available") return "empty";
  if (statusKey === "boardingSoon") return "reserved";
  if (statusKey === "late") return "late";
  if (statusKey === "expired") return "expired";
  return "occupied";
}
function headerLabelForKey(key) {
  switch (key) {
    case "empty":
      return (0, import_locales.getText)("pisell-resource-wall-card-current-not-in-use");
    case "reserved":
      return (0, import_locales.getText)("pisell-resource-wall-floor-status-reserved");
    case "late":
      return (0, import_locales.getText)("pisell-resource-wall-floor-status-late");
    case "expired":
      return (0, import_locales.getText)("pisell-resource-wall-floor-status-expired");
    default:
      return (0, import_locales.getText)("pisell-resource-wall-floor-status-occupied");
  }
}
function sanitizeContact(booking) {
  const c = (booking == null ? void 0 : booking.trim()) ?? "";
  if (c === "Available to Book") return "";
  return c;
}
function resolveInUseProgressPercent(args) {
  const { card, wallNowMs, liveRemainingPreciseMin } = args;
  const end = card.sessionEndMs;
  const start = card.sessionStartMs;
  if (end != null && start != null && Number.isFinite(end) && Number.isFinite(start) && end > start) {
    const durationMs = end - start;
    const elapsedMs = Math.min(
      Math.max(0, wallNowMs - start),
      durationMs
    );
    return (0, import_venueWallUtils.clamp)(elapsedMs / durationMs * 100, 0, 100);
  }
  const denomMin = 60;
  const elapsedPreciseMin = denomMin - liveRemainingPreciseMin;
  return (0, import_venueWallUtils.clamp)(elapsedPreciseMin / denomMin * 100, 0, 100);
}
function buildVenueWallCardPresentation(args) {
  const {
    card,
    toneMap,
    wallNowMs,
    liveRemainingMin,
    liveRemainingPreciseMin,
    liveStartsInMin,
    liveLateMin,
    boardingSoonBeforeMin,
    idleMain,
    idleSub,
    availableCardColor
  } = args;
  const statusKey = (0, import_venueWallUtils.deriveVenueWallStatus)({
    ...card,
    remainingMin: liveRemainingMin
  });
  const floorLikeStatus = resolveFloorLikeStatus(statusKey);
  const headerStatusKey = resolveHeaderStatusKey(statusKey);
  const headerStatusLabel = headerLabelForKey(headerStatusKey);
  const tone = toneMap[statusKey] ?? toneMap.inUse;
  const endingSoonTone = toneMap.endingSoon;
  const boardingTone = toneMap.boardingSoon;
  const lateTone = toneMap.late ?? boardingTone;
  const expiredTone = toneMap.expired ?? endingSoonTone;
  const cardVariant = floorLikeStatus === "occupied" ? "occupied" : "accent";
  const mainOnOccupied = "#ffffff";
  const subOnOccupied = "rgba(255,255,255,0.88)";
  const mainColor = cardVariant === "occupied" ? mainOnOccupied : idleMain;
  const subColor = cardVariant === "occupied" ? subOnOccupied : idleSub;
  let surfaceAccentColor = availableCardColor;
  if (floorLikeStatus === "reserved") {
    surfaceAccentColor = boardingTone.color;
  }
  const timeRangeLine = (card.currentTime ?? "").trim();
  const contactLine = sanitizeContact(card.currentBooking);
  let primaryEmphasisLine = "";
  let primaryEmphasisColor = mainColor;
  let progress = 0;
  let progressColor = mainOnOccupied;
  let showProgress = false;
  const rmDisplay = Math.max(0, liveRemainingMin);
  const endingWindowMin = Math.max(1, boardingSoonBeforeMin);
  const inEndingSoonWindow = floorLikeStatus === "occupied" && liveRemainingMin >= 0 && liveRemainingMin <= endingWindowMin;
  const showEndingSoonMarquee = floorLikeStatus === "occupied" && inEndingSoonWindow && statusKey !== "expired";
  if (statusKey === "available") {
    primaryEmphasisLine = "";
    primaryEmphasisColor = mainColor;
  } else if (statusKey === "boardingSoon") {
    primaryEmphasisLine = (0, import_locales.getText)("pisell-resource-wall-card-starts-in").replace(
      "{n}",
      (0, import_venueWallUtils.formatDurationHM)(liveStartsInMin)
    );
    primaryEmphasisColor = boardingTone.color;
  } else if (statusKey === "late") {
    primaryEmphasisLine = (0, import_locales.getText)("pisell-resource-wall-card-late").replace(
      "{n}",
      (0, import_venueWallUtils.formatDurationHM)(Math.max(0, Math.floor(liveLateMin)))
    );
    primaryEmphasisColor = lateTone.color;
  } else if (statusKey === "inUse" || statusKey === "endingSoon" || statusKey === "expired") {
    showProgress = true;
    const sessionEndedNoOvertimeCopy = statusKey === "expired" || liveRemainingMin < 0;
    if (sessionEndedNoOvertimeCopy) {
      progress = 100;
      progressColor = expiredTone.color;
      if (liveRemainingMin < 0) {
        primaryEmphasisLine = (0, import_venueWallUtils.formatVenueWallCountdown)(liveRemainingMin);
      } else {
        primaryEmphasisLine = (0, import_locales.getText)("pisell-resource-wall-countdown-zero-overtime");
      }
      primaryEmphasisColor = expiredTone.color;
    } else {
      progress = resolveInUseProgressPercent({
        card,
        wallNowMs,
        liveRemainingPreciseMin
      });
      progressColor = statusKey === "endingSoon" || inEndingSoonWindow ? endingSoonTone.color : mainOnOccupied;
      primaryEmphasisLine = (0, import_venueWallUtils.formatVenueWallCountdown)(rmDisplay);
      primaryEmphasisColor = statusKey === "endingSoon" || inEndingSoonWindow ? endingSoonTone.color : mainOnOccupied;
    }
  }
  const marqueeText = showEndingSoonMarquee ? (0, import_locales.getText)("pisell-resource-wall-marquee-ending-soon") : "";
  const marqueeColor = showEndingSoonMarquee ? "#ffffff" : cardVariant === "occupied" ? "rgba(255,255,255,0.92)" : endingSoonTone.color;
  const marqueeShellBackground = showEndingSoonMarquee ? primaryEmphasisColor : "transparent";
  let headerStatusColor;
  if (headerStatusKey === "empty") headerStatusColor = availableCardColor;
  else if (headerStatusKey === "reserved") headerStatusColor = boardingTone.color;
  else if (headerStatusKey === "late") headerStatusColor = lateTone.color;
  else if (headerStatusKey === "expired") headerStatusColor = expiredTone.color;
  else headerStatusColor = "#ffffff";
  return {
    statusKey,
    floorLikeStatus,
    headerStatusKey,
    headerStatusLabel,
    headerStatusColor,
    cardVariant,
    mainColor,
    subColor,
    surfaceAccentColor,
    primaryEmphasisLine,
    primaryEmphasisColor,
    timeRangeLine,
    contactLine,
    showProgress,
    progress,
    progressColor,
    showEndingSoonMarquee,
    marqueeText,
    marqueeColor,
    marqueeShellBackground
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  buildVenueWallCardPresentation
});
