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/dataSourceComponents/fields/DatePicker/ReadPretty.tsx
var ReadPretty_exports = {};
__export(ReadPretty_exports, {
  default: () => ReadPretty_default
});
module.exports = __toCommonJS(ReadPretty_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_dayjs = __toESM(require("dayjs"));
var import_usePisellConfig = __toESM(require("../../../pisell-config-provider/hooks/usePisellConfig"));
var import_ReadPretty = require("./ReadPretty.less");
var DEFAULT_FORMAT = "YYYY-MM-DD HH:mm:ss";
var DATE_FORMATS = {
  "zh-CN": {
    withTime: "YYYY-MM-DD HH:mm:ss",
    withoutTime: "YYYY-MM-DD"
  },
  "en-US": {
    withTime: "HH:mm:ss YYYY-MM-DD",
    withoutTime: "YYYY-MM-DD"
  }
};
var DatePickerReadPretty = ({ value, renderMode, showTime }) => {
  const { locale = "zh-CN" } = (0, import_usePisellConfig.default)();
  const dateFormat = (0, import_react.useMemo)(() => {
    if (locale in DATE_FORMATS) {
      const formats = DATE_FORMATS[locale];
      return showTime ? formats.withTime : formats.withoutTime;
    }
    if (process.env.NODE_ENV !== "production") {
      console.warn(`Unsupported locale: ${locale}, falling back to default format`);
    }
    return DEFAULT_FORMAT;
  }, [locale, showTime]);
  const formattedDate = (0, import_react.useMemo)(() => {
    if (!value)
      return "";
    try {
      return (0, import_dayjs.default)(value).format(dateFormat);
    } catch (error) {
      if (process.env.NODE_ENV !== "production") {
        console.error("Error formatting date:", error);
      }
      return "";
    }
  }, [value, dateFormat]);
  return /* @__PURE__ */ import_react.default.createElement(
    "span",
    {
      className: (0, import_classnames.default)("pisell-date-picker-read-pretty", {
        "pisell-date-picker-read-pretty-table-view": renderMode === "tableView"
      })
    },
    formattedDate
  );
};
var ReadPretty_default = DatePickerReadPretty;
