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/ecocup/cupList/hooks/useColumns.tsx
var useColumns_exports = {};
__export(useColumns_exports, {
  useColumns: () => useColumns
});
module.exports = __toCommonJS(useColumns_exports);
var import_react = __toESM(require("react"));
var import_dayjs = __toESM(require("dayjs"));
var import_materials = require("@pisell/materials");
var import_const = require("../const");
var import_MoreDropdown = __toESM(require("../../components/MoreDropdown"));
var import_hooks = require("../../hooks");
var import__ = require("../index.less");
var prefixCls = "ecocup-cup-list";
var useColumns = (props) => {
  const { onClickAction, locales, isEcoShare } = props;
  const isApp = (0, import_hooks.useIsApp)();
  const getRelativeTime = (text) => {
    if (!text) return "";
    const diff = (0, import_dayjs.default)().diff((0, import_dayjs.default)(text), "day");
    if (diff === 0) return locales.getText("pisell2.text.ecocup.table.time-of-return.today");
    return locales.getText("pisell2.text.ecocup.table.time-of-rent.relative")(diff);
  };
  return [
    {
      title: locales.getText("pisell2.text.ecocup.table.cup-code"),
      dataIndex: "eco_cup_code",
      key: "eco_cup_code",
      align: "center",
      width: 170,
      render: (text, record) => {
        return text || (record == null ? void 0 : record.code) || "";
      }
    },
    {
      title: locales.getText("pisell2.text.ecocup.table.customer"),
      dataIndex: "customer",
      key: "customer",
      align: "center",
      hidden: isApp,
      with: 220,
      render: (text, record) => {
        var _a;
        return ((_a = record == null ? void 0 : record.customer) == null ? void 0 : _a.display_name) || "";
      }
    },
    {
      title: locales.getText("pisell2.text.ecocup.table.status"),
      dataIndex: "status",
      key: "status",
      align: "center",
      width: 120,
      render: (text) => {
        const status = import_const.STATUS_TEXT_MAP[text];
        const color = import_const.STATUS_COLOR_MAP[text];
        return /* @__PURE__ */ import_react.default.createElement(
          "div",
          {
            className: `${prefixCls}-table-status`,
            style: {
              backgroundColor: color == null ? void 0 : color.backgroundColor,
              color: color == null ? void 0 : color.color,
              border: `1px solid ${color == null ? void 0 : color.border}`
            }
          },
          locales.getText(status)
        );
      }
    },
    {
      title: locales.getText("pisell2.text.ecocup.table.shop-of-rent"),
      dataIndex: "rent_shop",
      key: "rent_shop",
      align: "center",
      hidden: isApp,
      width: 200,
      render: (text, record) => {
        var _a;
        return ((_a = record == null ? void 0 : record.rent_shop) == null ? void 0 : _a.name) || "";
      }
    },
    {
      title: locales.getText("pisell2.text.ecocup.table.time-of-rent"),
      dataIndex: "rent_time",
      key: "rent_time",
      align: "center",
      hidden: isApp,
      width: 160,
      render: (text) => {
        if (!text) return "";
        return /* @__PURE__ */ import_react.default.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" } }, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_dayjs.default)(text).format("DD/MM/YYYY")), /* @__PURE__ */ import_react.default.createElement("span", null, getRelativeTime(text)));
      }
    },
    {
      title: locales.getText("pisell2.text.ecocup.table.shop-of-return"),
      dataIndex: "return_shop",
      key: "return_shop",
      align: "center",
      hidden: isApp,
      width: 200,
      render: (text, record) => {
        var _a;
        return ((_a = record == null ? void 0 : record.return_shop) == null ? void 0 : _a.name) || "";
      }
    },
    {
      title: locales.getText("pisell2.text.ecocup.table.time-of-return"),
      dataIndex: "return_time",
      key: "return_time",
      align: "center",
      hidden: isApp,
      width: 160,
      render: (text) => {
        return text ? (0, import_dayjs.default)(text).format("DD/MM/YYYY") : "";
      }
    },
    {
      title: locales.getText("pisell2.text.ecocup.rent"),
      dataIndex: "rent_shop",
      key: "rent_shop",
      align: "center",
      hidden: !isApp,
      width: 160,
      render: (text, record) => {
        var _a, _b;
        return /* @__PURE__ */ import_react.default.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" } }, ((_a = record == null ? void 0 : record.rent_shop) == null ? void 0 : _a.name) ? /* @__PURE__ */ import_react.default.createElement("span", null, (_b = record == null ? void 0 : record.rent_shop) == null ? void 0 : _b.name) : null, (record == null ? void 0 : record.rent_time) ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_dayjs.default)(record == null ? void 0 : record.rent_time).format("DD/MM/YYYY")), /* @__PURE__ */ import_react.default.createElement("span", null, getRelativeTime(record == null ? void 0 : record.rent_time))) : null);
      }
    },
    {
      title: locales.getText("pisell2.text.ecocup.action.return"),
      dataIndex: "return_shop",
      key: "return_shop",
      align: "center",
      hidden: !isApp,
      width: 160,
      render: (text, record) => {
        var _a, _b;
        return /* @__PURE__ */ import_react.default.createElement("div", { style: { display: "flex", flexDirection: "column", alignItems: "center" } }, ((_a = record == null ? void 0 : record.return_shop) == null ? void 0 : _a.name) ? /* @__PURE__ */ import_react.default.createElement("span", null, (_b = record == null ? void 0 : record.return_shop) == null ? void 0 : _b.name) : null, (record == null ? void 0 : record.return_time) ? /* @__PURE__ */ import_react.default.createElement(import_react.default.Fragment, null, /* @__PURE__ */ import_react.default.createElement("span", null, (0, import_dayjs.default)(record == null ? void 0 : record.return_time).format("DD/MM/YYYY")), /* @__PURE__ */ import_react.default.createElement("span", null, getRelativeTime(record == null ? void 0 : record.return_time))) : null);
      }
    },
    {
      title: locales.getText("pisell2.text.ecocup.table.actions"),
      dataIndex: "actions",
      key: "actions",
      hidden: isApp || isEcoShare,
      width: 180,
      render: (text, record) => {
        const _status = (record == null ? void 0 : record.status) || "";
        const showMoreTypes = ["in_stock", "rent"];
        if ((record == null ? void 0 : record.shop_id) !== (record == null ? void 0 : record.current_shop_id) && !(record == null ? void 0 : record.eco_cup_id)) return null;
        return /* @__PURE__ */ import_react.default.createElement("div", { className: `${prefixCls}-table-actions` }, _status === "rent" ? /* @__PURE__ */ import_react.default.createElement(
          import_materials.Button,
          {
            type: "primary",
            onClick: () => onClickAction("return", record)
          },
          locales.getText("pisell2.text.ecocup.action.return")
        ) : null, showMoreTypes.includes(_status) ? /* @__PURE__ */ import_react.default.createElement(
          import_MoreDropdown.default,
          {
            locales,
            onClick: (key) => onClickAction(key, record)
          }
        ) : null);
      }
    }
  ];
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useColumns
});
