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/booking/info/dateRange/index.tsx
var dateRange_exports = {};
__export(dateRange_exports, {
  default: () => dateRange_default,
  disabledDate: () => disabledDate
});
module.exports = __toCommonJS(dateRange_exports);
var import_react = __toESM(require("react"));
var import_icons = require("@ant-design/icons");
var import_classnames = __toESM(require("classnames"));
var import_dayjs = __toESM(require("dayjs"));
var import_materials = require("@pisell/materials");
var import_index = require("./index.less");
var disabledDate = (current, position, currentDate) => {
  if (position === "start") {
    return false;
  }
  if (position === "end" && current.endOf("day") && (currentDate == null ? void 0 : currentDate[0])) {
    const endDisabled = currentDate == null ? void 0 : currentDate[0].add(8, "months").format("YYYY-MM-DD");
    return (0, import_dayjs.default)(endDisabled) < current.startOf("day") || current.startOf("day") <= (currentDate == null ? void 0 : currentDate[0]);
  }
  return current && current <= (currentDate == null ? void 0 : currentDate[0]);
};
var DateRange = ({ state, dispatch, key }) => {
  const [value, setValue] = (0, import_react.useState)([]);
  (0, import_react.useEffect)(() => {
    var _a, _b;
    const lists = [(_a = state.date) == null ? void 0 : _a.value, (_b = state.date) == null ? void 0 : _b.end_date];
    setValue(lists);
    console.log("lists", lists);
  }, [state.date]);
  const dateChange = (e) => {
    dispatch({
      type: "setDate",
      payload: {
        value: e[0],
        end_date: e[1],
        edit: true
      }
    });
  };
  const formatLocale = (0, import_react.useMemo)(() => {
    const locale = state == null ? void 0 : state.locale;
    const isEn = locale === "en" || locale === "en-US";
    const _format = isEn ? "DD/MM/YYYY" : "YYYY-MM-DD";
    return _format;
  }, [state == null ? void 0 : state.locale, state.date]);
  return (0, import_react.useMemo)(() => {
    return /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement(
      "div",
      {
        className: (0, import_classnames.default)(
          "pisell-lowcode__booking-service-header-date-range",
          {
            "pisell-lowcode__booking-service-header-date-range-terminal": state.isTerminalDayBookingPage
          }
        )
      },
      /* @__PURE__ */ import_react.default.createElement(import_materials.Page, null, /* @__PURE__ */ import_react.default.createElement(
        import_materials.DatePicker.RangePicker,
        {
          key,
          inputReadOnly: true,
          allowClear: false,
          size: "large",
          style: { width: "100%", padding: 0 },
          suffixIcon: !state.disabledEdit ? /* @__PURE__ */ import_react.default.createElement(import_icons.CalendarOutlined, null) : null,
          disabledDate,
          value: [value[0], value[1]],
          onChange: dateChange,
          format: formatLocale,
          isHideCustomSelect: true,
          endDateDays: 1
        }
      ))
    ));
  }, [value, state.disabledEdit, state == null ? void 0 : state.locale]);
};
var dateRange_default = DateRange;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  disabledDate
});
