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/pisellTimeRangeDisplay/components/TimeRangeBlock.tsx
var TimeRangeBlock_exports = {};
__export(TimeRangeBlock_exports, {
  TimeRangeBlock: () => TimeRangeBlock,
  default: () => TimeRangeBlock_default
});
module.exports = __toCommonJS(TimeRangeBlock_exports);
var import_react = __toESM(require("react"));
var import_dayjs = __toESM(require("dayjs"));
var import_utils = require("../utils");
var TimeRangeBlock = ({
  start,
  end,
  isSameDay,
  timeFormat,
  dateFormat,
  weekdayFormat,
  showWeekdayInCrossDay = true,
  referenceDate = (0, import_dayjs.default)(),
  style,
  startStyle,
  endStyle,
  className
}) => {
  const inlineStyle = {
    fontSize: style == null ? void 0 : style.fontSize,
    fontWeight: style == null ? void 0 : style.fontWeight,
    color: style == null ? void 0 : style.color,
    lineHeight: style == null ? void 0 : style.lineHeight
  };
  const startInlineStyle = {
    ...inlineStyle,
    fontSize: (startStyle == null ? void 0 : startStyle.fontSize) ?? inlineStyle.fontSize,
    fontWeight: (startStyle == null ? void 0 : startStyle.fontWeight) ?? inlineStyle.fontWeight,
    color: (startStyle == null ? void 0 : startStyle.color) ?? inlineStyle.color,
    lineHeight: (startStyle == null ? void 0 : startStyle.lineHeight) ?? inlineStyle.lineHeight
  };
  const endInlineStyle = {
    ...inlineStyle,
    fontSize: (endStyle == null ? void 0 : endStyle.fontSize) ?? inlineStyle.fontSize,
    fontWeight: (endStyle == null ? void 0 : endStyle.fontWeight) ?? inlineStyle.fontWeight,
    color: (endStyle == null ? void 0 : endStyle.color) ?? inlineStyle.color,
    lineHeight: (endStyle == null ? void 0 : endStyle.lineHeight) ?? inlineStyle.lineHeight
  };
  if (isSameDay) {
    const startStr = (0, import_utils.formatTime)(start, timeFormat);
    const endStr = (0, import_utils.formatTime)(end, timeFormat);
    return /* @__PURE__ */ import_react.default.createElement(
      "span",
      {
        className: `pisell-time-range-display-time ${className || ""}`.trim(),
        style: inlineStyle
      },
      /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-time-range-display-time-start", style: startInlineStyle }, startStr),
      /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-time-range-display-time-end-wrap" }, /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-time-range-display-time-sep", style: inlineStyle, "aria-hidden": true }, " - "), /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-time-range-display-time-end", style: endInlineStyle }, endStr))
    );
  }
  const isCrossYear = start.year() !== end.year();
  const dateFormatOverride = {
    order: "DMY",
    shortMonth: true,
    showYear: (dateFormat == null ? void 0 : dateFormat.showYear) ?? isCrossYear,
    showMonth: true,
    showDay: true,
    useCommaBeforeYear: false
  };
  const startTimeStr = (0, import_utils.formatTime)(start, timeFormat);
  const endTimeStr = (0, import_utils.formatTime)(end, timeFormat);
  const getCrossDayDatePart = (date) => {
    if (!showWeekdayInCrossDay) {
      return (0, import_utils.formatDate)(date, { ...dateFormat, ...dateFormatOverride });
    }
    return (0, import_utils.getDatePartDisplay)({
      date,
      dateFormat,
      weekdayFormat,
      referenceDate,
      dateFormatOverride
    });
  };
  const startDatePart = getCrossDayDatePart(start);
  const endDatePart = getCrossDayDatePart(end);
  const startPart = `${startTimeStr} ${startDatePart}`;
  const endPart = `${endTimeStr} ${endDatePart}`;
  const timeClass = "pisell-time-range-display-time pisell-time-range-display-time-cross";
  return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
    "span",
    {
      key: "time-start",
      className: `${timeClass} ${className || ""}`.trim(),
      style: startInlineStyle
    },
    startPart
  ), /* @__PURE__ */ import_react.default.createElement(
    "span",
    {
      key: "time-end",
      className: `${timeClass} ${className || ""}`.trim(),
      style: inlineStyle
    },
    /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-time-range-display-time-cross-sep", style: inlineStyle, "aria-hidden": true }, " - "),
    /* @__PURE__ */ import_react.default.createElement("span", { className: "pisell-time-range-display-time-cross-end", style: endInlineStyle }, endPart)
  ));
};
var TimeRangeBlock_default = TimeRangeBlock;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  TimeRangeBlock
});
