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/plus/pisellSalesManagement/hooks/useBookingPerspective.tsx
var useBookingPerspective_exports = {};
__export(useBookingPerspective_exports, {
  useBookingPerspective: () => useBookingPerspective
});
module.exports = __toCommonJS(useBookingPerspective_exports);
var import_react = __toESM(require("react"));
var import_materials = require("@pisell/materials");
var import_utils = require("@pisell/utils");
var import_clientName = __toESM(require("../../clientName"));
var import_booking = require("../config/booking");
var import_order = require("../config/order");
var import_config = require("../config");
var import_perspectiveUtils = require("./perspectiveUtils");
var import_useEngineContext = __toESM(require("../../../hooks/useEngineContext"));
var import_BookingNotesPreview = __toESM(require("../components/BookingNotesPreview"));
var import_BookingFormsPreview = __toESM(require("../components/BookingFormsPreview"));
var import_serve = require("../serve");
var import_usePaymentMethodNameMap = require("./usePaymentMethodNameMap");
function getBookingType(record) {
  var _a, _b;
  if (((_a = record == null ? void 0 : record.order.metadata) == null ? void 0 : _a.appointment_structure_version) === "2.0") {
    return "pisell2";
  }
  if ((_b = record == null ? void 0 : record.metadata) == null ? void 0 : _b.multiple_resource_flag) {
    return "pisell2";
  }
  if (record.parent_id > 0 && record.item_type !== "recurring_booking") {
    return "pisell2";
  }
  return "pisell1";
}
var useBookingPerspective = (params, options) => {
  var _a, _b, _c;
  const context = (0, import_useEngineContext.default)();
  const utils = (_a = context == null ? void 0 : context.appHelper) == null ? void 0 : _a.utils;
  const onOpenDetail = options == null ? void 0 : options.onOpenDetail;
  const translationOriginal = utils == null ? void 0 : utils.translationOriginal;
  const locale = (_c = (_b = context == null ? void 0 : context.engine) == null ? void 0 : _b.props) == null ? void 0 : _c.locale;
  const paymentMethodNameMap = (0, import_usePaymentMethodNameMap.usePaymentMethodNameMap)();
  const businessCode = params == null ? void 0 : params.businessCode;
  const staticData = (0, import_react.useMemo)(() => {
    const BOOKING_STATUS_LABEL_MAP = (0, import_booking.getBookingStatusMap)();
    const BOOKING_PLATFORM_LABEL_MAP = (0, import_booking.getBookingPlatformMap)();
    const PAYMENT_STATUS_LABEL_MAP = (0, import_order.getPaymentStatusMap)();
    const BUSINESS_LABEL_MAP = (0, import_config.getBusinessLabelMap)();
    const bookingLabels = (0, import_booking.getBookingHeaderLabels)();
    const { relationTables } = params || {};
    const relationTablesList = Array.isArray(relationTables) ? relationTables : [];
    const _relationTables = relationTablesList.filter(
      (item) => [
        "appointment_booking",
        "ticket",
        "party_room",
        "therapist",
        "table-order",
        "voucher_ticket",
        "mobile_order"
      ].includes(item.relation_type)
    );
    const uniqueTables = _relationTables.reduce((pre, cur) => {
      let exists = pre.some((obj) => obj.form_id === cur.form_id);
      if (!exists) {
        pre.push(cur);
      }
      return pre;
    }, []);
    return {
      BOOKING_STATUS_LABEL_MAP,
      BOOKING_PLATFORM_LABEL_MAP,
      PAYMENT_STATUS_LABEL_MAP,
      BUSINESS_LABEL_MAP,
      bookingLabels,
      uniqueTables
    };
  }, [params == null ? void 0 : params.relationTables, locale]);
  const buildColumns = (0, import_react.useCallback)(
    (ctx) => {
      const {
        BOOKING_STATUS_LABEL_MAP,
        BOOKING_PLATFORM_LABEL_MAP,
        PAYMENT_STATUS_LABEL_MAP,
        BUSINESS_LABEL_MAP,
        bookingLabels,
        uniqueTables
      } = staticData;
      return [
        {
          title: bookingLabels.bookingBrief,
          key: "booking_brief",
          width: 188,
          render: (_, record) => {
            var _a2, _b2, _c2;
            const startAt = (0, import_perspectiveUtils.buildDateTime)(record == null ? void 0 : record.start_date, record == null ? void 0 : record.start_time) || (record == null ? void 0 : record.start_at);
            const status = record == null ? void 0 : record.appointment_status;
            const statusLabel = BOOKING_STATUS_LABEL_MAP[status] || status || "-";
            const statusColor = import_booking.BOOKING_STATUS_COLOR_MAP[status] || "";
            const orderNote = (_a2 = record == null ? void 0 : record.order) == null ? void 0 : _a2.note;
            const internalNotes = record == null ? void 0 : record.notes;
            const noteApis = (0, import_serve.createNoteApis)((_b2 = record == null ? void 0 : record.order) == null ? void 0 : _b2.id);
            return /* @__PURE__ */ import_react.default.createElement("div", { className: "pisell-sales-grid-booking-brief" }, /* @__PURE__ */ import_react.default.createElement(import_clientName.default, { dataSource: (_c2 = record == null ? void 0 : record.order) == null ? void 0 : _c2.customer }), startAt ? /* @__PURE__ */ import_react.default.createElement(
              import_materials.PisellDateTimeDisplay,
              {
                value: startAt,
                layout: "inline",
                textAlign: "left",
                timeFormat: { padHour: true },
                dateFormat: {
                  order: "DMY",
                  showYear: false,
                  shortMonth: true,
                  showRelativeDay: true,
                  useCommaBeforeYear: false
                },
                fields: {
                  fieldOrder: ["time", "weekday", "date"]
                  // inlineSeparators: [' ', ', '],
                }
              }
            ) : null, /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
              import_perspectiveUtils.Tag,
              {
                style: {
                  backgroundColor: statusColor,
                  whiteSpace: "nowrap",
                  border: "none",
                  fontWeight: 500
                }
              },
              statusLabel
            )), /* @__PURE__ */ import_react.default.createElement(
              import_BookingNotesPreview.default,
              {
                dataSource: {
                  note: orderNote,
                  internalNotes,
                  apis: noteApis,
                  bookingId: record == null ? void 0 : record.id,
                  onChange: (value, type, noteType) => {
                    ctx.refresh();
                  }
                },
                labels: {
                  orderNote: bookingLabels.orderNote,
                  internalNote: bookingLabels.internalNote,
                  more: bookingLabels.more
                },
                style: {
                  maxWidth: "100%"
                }
              }
            ));
          }
        },
        {
          title: bookingLabels.resource,
          dataIndex: "relation_form_name",
          key: "relation_form_name",
          align: "center",
          width: 100,
          render: (value) => {
            if (!value) return "-";
            return /* @__PURE__ */ import_react.default.createElement("div", { style: import_perspectiveUtils.textStyles.text }, value);
          }
        },
        {
          title: bookingLabels.serviceTime,
          key: "service_time",
          align: "center",
          width: 165,
          render: (_, record) => {
            const startAt = (0, import_perspectiveUtils.buildDateTime)(record == null ? void 0 : record.start_date, record == null ? void 0 : record.start_time) || (record == null ? void 0 : record.start_at);
            const endAt = (0, import_perspectiveUtils.buildDateTime)(record == null ? void 0 : record.end_date, record == null ? void 0 : record.end_time) || (record == null ? void 0 : record.end_at);
            if (!startAt || !endAt) {
              return null;
            }
            return /* @__PURE__ */ import_react.default.createElement("div", { style: { textAlign: "center" } }, /* @__PURE__ */ import_react.default.createElement(import_materials.PisellTimeRangeDisplay, { startAt, endAt }));
          },
          uniformCompare: (_, record) => {
            const {
              start_date = "",
              start_time = "",
              end_date = "",
              end_time = ""
            } = record;
            return `${start_date}${start_time}${end_date}${end_time}`;
          }
        },
        {
          title: bookingLabels.customer,
          key: "customer",
          align: "center",
          width: 118,
          uniformCompare: (_, record) => {
            const value = record.order;
            const customer = value == null ? void 0 : value.customer;
            if (!customer) return "-";
            const guestCode = customer == null ? void 0 : customer.guest_code;
            if (guestCode) return `${guestCode}`;
            if (customer.user_id === 1) return "walk-in";
            return customer;
          },
          render: (_, record) => {
            const value = record.order;
            const customer = value == null ? void 0 : value.customer;
            const guestCode = customer == null ? void 0 : customer.guest_code;
            if (guestCode) {
              return /* @__PURE__ */ import_react.default.createElement(
                "div",
                {
                  style: {
                    display: "flex",
                    flexDirection: "column",
                    alignItems: "center",
                    textAlign: "center"
                  }
                },
                /* @__PURE__ */ import_react.default.createElement("div", { style: { fontWeight: "bold" } }, bookingLabels.guest)
              );
            }
            const phone = (0, import_perspectiveUtils.formatPhone)(
              (customer == null ? void 0 : customer.phone) || (record == null ? void 0 : record.phone),
              (customer == null ? void 0 : customer.country_calling_code) || (record == null ? void 0 : record.country_calling_code)
            );
            const email = customer == null ? void 0 : customer.email;
            const lines = (0, import_perspectiveUtils.getDisplayLines)([phone, email]);
            return /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                style: {
                  display: "flex",
                  flexDirection: "column",
                  alignItems: "center",
                  textAlign: "center"
                }
              },
              /* @__PURE__ */ import_react.default.createElement(import_clientName.default, { dataSource: customer, style: { fontSize: 14 } }),
              lines.map((line, index) => /* @__PURE__ */ import_react.default.createElement("div", { key: `${line}-${index}`, style: import_perspectiveUtils.textStyles.text }, line))
            );
          }
        },
        {
          title: bookingLabels.contact,
          key: "contact",
          align: "center",
          width: 150,
          uniformCompare: (_, record) => {
            const value = record.order;
            const contactValue = value == null ? void 0 : value.contacts_info;
            if (!contactValue) return "-";
            return contactValue;
          },
          render: (_, record) => {
            const value = record.order;
            const contactValue = value == null ? void 0 : value.contacts_info;
            if (!contactValue) return "-";
            const phone = (0, import_perspectiveUtils.formatPhone)(contactValue == null ? void 0 : contactValue.phone);
            const lines = (0, import_perspectiveUtils.getDisplayLines)([phone, contactValue == null ? void 0 : contactValue.email]);
            return /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                style: {
                  display: "flex",
                  flexDirection: "column",
                  alignItems: "center",
                  textAlign: "center"
                }
              },
              /* @__PURE__ */ import_react.default.createElement(
                import_clientName.default,
                {
                  dataSource: contactValue,
                  style: { fontSize: 14 }
                }
              ),
              lines.map((line, index) => /* @__PURE__ */ import_react.default.createElement("div", { key: `${line}-${index}`, style: import_perspectiveUtils.textStyles.text }, line))
            );
          }
        },
        {
          title: bookingLabels.holder,
          dataIndex: "holder_data",
          key: "holder_data",
          align: "center",
          width: 110,
          uniformCompare: (value, record) => {
            if (!value) return "-";
            return value;
          },
          render: (value, record) => {
            var _a2;
            if (!value) return "-";
            const holderValue = Array.isArray(value) ? value[0] : value;
            if (!holderValue) return "-";
            let holderPhone;
            const customerPhone = ((_a2 = holderValue.data) == null ? void 0 : _a2.customer_phone) || holderValue.customer_phone;
            if (customerPhone) {
              holderPhone = (0, import_perspectiveUtils.formatPhone)(customerPhone);
            }
            const lines = (0, import_perspectiveUtils.getDisplayLines)([holderPhone]);
            return /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                style: {
                  display: "flex",
                  flexDirection: "column",
                  alignItems: "center",
                  textAlign: "center"
                }
              },
              /* @__PURE__ */ import_react.default.createElement(
                import_clientName.default,
                {
                  dataSource: { display_name: holderValue.main_field || record.holder_name || "" },
                  style: { fontSize: 14 }
                }
              ),
              lines.map((line, index) => /* @__PURE__ */ import_react.default.createElement("div", { key: `${line}-${index}`, style: { ...import_perspectiveUtils.textStyles.text, whiteSpace: "nowrap" } }, line))
            );
          }
        },
        {
          title: bookingLabels.services,
          key: "services",
          align: "center",
          width: 120,
          render: (_, record) => {
            const detail = (0, import_perspectiveUtils.parseJson)(record == null ? void 0 : record.order_detail);
            const items = (0, import_perspectiveUtils.normalizeList)(detail);
            const displayItems = items.slice(0, 3);
            const moreCount = items.length - displayItems.length;
            const lines = displayItems.map((item) => {
              const title = utils.translation(item.product_title);
              const qty = item == null ? void 0 : item.product_quantity;
              if (!title) return null;
              return qty ? `${title} x${qty}` : String(title);
            }).filter((item) => item);
            if (moreCount > 0) {
              lines.push(`+${moreCount} ${bookingLabels.more}`);
            }
            if (lines.length === 0) return null;
            return /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                style: {
                  display: "flex",
                  flexDirection: "column",
                  alignItems: "center",
                  textAlign: "center"
                }
              },
              lines.map((line, index) => /* @__PURE__ */ import_react.default.createElement("div", { key: `${line}-${index}`, style: import_perspectiveUtils.textStyles.text }, line))
            );
          },
          uniformCompare: (_value, record) => {
            return (record == null ? void 0 : record.order_detail) || "";
          }
        },
        {
          title: bookingLabels.pax,
          dataIndex: "number",
          key: "number",
          align: "center",
          width: 110,
          render: (_, record) => {
            const count = record == null ? void 0 : record.number;
            return /* @__PURE__ */ import_react.default.createElement("span", { style: { ...import_perspectiveUtils.textStyles.text, textAlign: "center" } }, count ?? "-");
          }
        },
        {
          /** 预约关联表单摘要 */
          title: bookingLabels.forms,
          key: "appointment_form",
          width: 132,
          align: "center",
          render: (_, record) => {
            var _a2;
            return /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                style: {
                  width: "100%",
                  maxWidth: 132,
                  margin: "0 auto",
                  minWidth: 0
                }
              },
              /* @__PURE__ */ import_react.default.createElement(
                import_BookingFormsPreview.default,
                {
                  value: record == null ? void 0 : record.appointment_form,
                  uniqueTables,
                  bookingLabels,
                  textStyles: import_perspectiveUtils.textStyles,
                  relationId: record.parent_id || record.id,
                  relationType: record.item_type,
                  customer: (_a2 = record.order) == null ? void 0 : _a2.customer
                }
              )
            );
          }
        },
        {
          title: bookingLabels.paymentMethod,
          key: "payment_method",
          dataIndex: ["order", "payments"],
          width: 180,
          align: "center",
          render: (_, record) => {
            const order = (record == null ? void 0 : record.order) || {};
            const payments = Array.isArray(order == null ? void 0 : order.payments) ? order.payments : [];
            const currencySymbol = order == null ? void 0 : order.currency_symbol;
            if (payments.length === 0) {
              return "-";
            }
            return /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                style: {
                  display: "flex",
                  flexDirection: "column",
                  gap: 8,
                  alignItems: "flex-start"
                }
              },
              payments.map((payment, index) => {
                var _a2, _b2, _c2;
                const walletPassName = (payment == null ? void 0 : payment.voucher_id) ? (translationOriginal == null ? void 0 : translationOriginal(
                  (_a2 = payment == null ? void 0 : payment.fund_record) == null ? void 0 : _a2.wallet_pass_name
                )) || ((_c2 = (_b2 = payment == null ? void 0 : payment.fund_record) == null ? void 0 : _b2.wallet_pass_name) == null ? void 0 : _c2.default) : "";
                const methodName = walletPassName || (0, import_usePaymentMethodNameMap.resolvePaymentMethodName)(payment, paymentMethodNameMap);
                const amount = Number(payment == null ? void 0 : payment.amount);
                const paymentTime = payment == null ? void 0 : payment.payment_time;
                return /* @__PURE__ */ import_react.default.createElement(
                  "div",
                  {
                    key: (payment == null ? void 0 : payment.order_payment_id) || index,
                    style: {
                      display: "flex",
                      flexDirection: "column",
                      alignItems: "flex-start"
                    }
                  },
                  /* @__PURE__ */ import_react.default.createElement(
                    "div",
                    {
                      style: {
                        fontSize: 14,
                        lineHeight: "20px",
                        color: "#101828",
                        fontWeight: 500,
                        whiteSpace: "nowrap"
                      }
                    },
                    /* @__PURE__ */ import_react.default.createElement("span", null, methodName),
                    Number.isFinite(amount) ? /* @__PURE__ */ import_react.default.createElement("span", null, ": ", (0, import_perspectiveUtils.formatAmount)(amount, currencySymbol)) : null
                  ),
                  paymentTime ? /* @__PURE__ */ import_react.default.createElement(
                    import_materials.PisellDateTimeDisplay,
                    {
                      value: paymentTime,
                      layout: "inline",
                      textAlign: "left",
                      timeFormat: { padHour: true },
                      dateFormat: {
                        showYear: false,
                        shortMonth: true,
                        showRelativeDay: true,
                        useCommaBeforeYear: false
                      },
                      fields: {
                        fieldOrder: ["time", "weekday", "date"]
                      },
                      style: {
                        ...import_perspectiveUtils.textStyles.text,
                        whiteSpace: "nowrap"
                      }
                    }
                  ) : null
                );
              })
            );
          }
        },
        {
          title: bookingLabels.orderInfo,
          key: "order_info",
          width: 124,
          align: "center",
          render: (_, record) => {
            const order = (record == null ? void 0 : record.order) || {};
            const orderCode = order == null ? void 0 : order.shop_full_order_number;
            const totalAmount = order == null ? void 0 : order.total_amount;
            const currencySymbol = order == null ? void 0 : order.currency_symbol;
            const paymentStatus = order == null ? void 0 : order.payment_status;
            const paymentLabel = PAYMENT_STATUS_LABEL_MAP[paymentStatus] || "-";
            const paymentColor = import_order.PAYMENT_STATUS_COLOR_MAP[paymentStatus] || "";
            return /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                className: "pisell-sales-grid-order-info",
                style: {
                  display: "flex",
                  flexDirection: "column",
                  alignItems: "flex-start"
                }
              },
              /* @__PURE__ */ import_react.default.createElement(
                "div",
                {
                  style: {
                    fontWeight: 600,
                    textDecoration: "underline",
                    color: "var(--theme-color, #7f56d9)"
                  }
                },
                orderCode || "-"
              ),
              totalAmount != null ? /* @__PURE__ */ import_react.default.createElement("div", { style: import_perspectiveUtils.textStyles.text }, (0, import_perspectiveUtils.formatAmount)(totalAmount, currencySymbol)) : null,
              paymentLabel ? /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
                import_perspectiveUtils.Tag,
                {
                  style: {
                    backgroundColor: paymentColor,
                    whiteSpace: "nowrap",
                    border: "none",
                    fontWeight: 500
                  }
                },
                paymentLabel
              )) : null
            );
          }
        },
        {
          title: bookingLabels.bookingId,
          dataIndex: "booking_id",
          key: "booking_id",
          align: "center",
          width: 120,
          render: (value) => /* @__PURE__ */ import_react.default.createElement(
            "span",
            {
              style: {
                ...import_perspectiveUtils.textStyles.text,
                textAlign: "center",
                fontSize: 14,
                fontWeight: 400
              }
            },
            value
          )
        },
        {
          title: bookingLabels.orderOrigin,
          key: "order_origin",
          width: 160,
          align: "center",
          render: (_, record) => {
            var _a2, _b2, _c2, _d, _e;
            const businessKey = ((_a2 = record == null ? void 0 : record.order) == null ? void 0 : _a2.business_code) || (record == null ? void 0 : record.business_code);
            const businessLabel = BUSINESS_LABEL_MAP[businessKey];
            const platform = ((_b2 = record == null ? void 0 : record.order) == null ? void 0 : _b2.platform) || ((_c2 = record == null ? void 0 : record.order) == null ? void 0 : _c2.order_sales_channel);
            const channel = BOOKING_PLATFORM_LABEL_MAP[platform] || platform;
            const device = (record == null ? void 0 : record.device_name) || (record == null ? void 0 : record.device) || (record == null ? void 0 : record.terminal);
            const time = (record == null ? void 0 : record.created_at) || ((_d = record == null ? void 0 : record.order) == null ? void 0 : _d.created_at);
            const actor = ((_e = record == null ? void 0 : record.order) == null ? void 0 : _e.create_account) || (record == null ? void 0 : record.create_account) || (record == null ? void 0 : record.operator_name);
            const lines = (0, import_perspectiveUtils.getDisplayLines)([channel, device]);
            return /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                style: {
                  display: "flex",
                  flexDirection: "column",
                  alignItems: "flex-start"
                }
              },
              businessLabel ? /* @__PURE__ */ import_react.default.createElement("div", null, /* @__PURE__ */ import_react.default.createElement(
                import_perspectiveUtils.Tag,
                {
                  color: import_config.BUSINESS_COLOR_MAP[businessKey],
                  style: {
                    color: "black",
                    fontWeight: 500
                  }
                },
                businessLabel
              )) : null,
              lines.map((line, index) => /* @__PURE__ */ import_react.default.createElement("div", { key: `${line}-${index}`, style: import_perspectiveUtils.textStyles.text }, line)),
              actor ? /* @__PURE__ */ import_react.default.createElement(
                "div",
                {
                  style: {
                    display: "flex",
                    alignItems: "center",
                    ...import_perspectiveUtils.textStyles.text
                  }
                },
                /* @__PURE__ */ import_react.default.createElement("span", null, bookingLabels.createdBy, ":"),
                /* @__PURE__ */ import_react.default.createElement(import_clientName.default, { dataSource: actor, style: { fontSize: 12 } })
              ) : null,
              /* @__PURE__ */ import_react.default.createElement(
                import_materials.PisellDateTimeDisplay,
                {
                  value: time,
                  layout: "inline",
                  textAlign: "left",
                  timeFormat: { padHour: true },
                  dateFormat: {
                    order: "DMY",
                    showYear: false,
                    shortMonth: true,
                    showRelativeDay: true,
                    useCommaBeforeYear: false
                  },
                  fields: {
                    fieldOrder: ["time", "weekday", "date"]
                    // inlineSeparators: [' ', ', '],
                  },
                  style: {
                    whiteSpace: "nowrap"
                  }
                }
              )
            );
          }
        },
        {
          title: bookingLabels.updated,
          key: "updated",
          width: 132,
          align: "center",
          render: (_, record) => {
            var _a2, _b2;
            const time = (record == null ? void 0 : record.updated_at) || ((_a2 = record == null ? void 0 : record.order) == null ? void 0 : _a2.updated_at);
            const platform = ((_b2 = record == null ? void 0 : record.order) == null ? void 0 : _b2.platform) || (record == null ? void 0 : record.order_platform);
            const channel = BOOKING_PLATFORM_LABEL_MAP[platform] || platform;
            const lines = (0, import_perspectiveUtils.getDisplayLines)([channel]);
            return /* @__PURE__ */ import_react.default.createElement(
              "div",
              {
                style: {
                  display: "flex",
                  flexDirection: "column",
                  alignItems: "flex-start"
                }
              },
              /* @__PURE__ */ import_react.default.createElement(
                import_materials.PisellDateTimeDisplay,
                {
                  value: time,
                  layout: "inline",
                  textAlign: "left",
                  timeFormat: { padHour: true },
                  dateFormat: {
                    order: "DMY",
                    showYear: false,
                    shortMonth: true,
                    showRelativeDay: true,
                    useCommaBeforeYear: false
                  },
                  fields: {
                    fieldOrder: ["time", "weekday", "date"]
                    // inlineSeparators: [' ', ', '],
                  },
                  style: {
                    whiteSpace: "nowrap"
                  }
                }
              ),
              lines.map((line, index) => /* @__PURE__ */ import_react.default.createElement("div", { key: `${line}-${index}`, style: import_perspectiveUtils.textStyles.text }, line))
            );
          }
        }
      ];
    },
    [staticData, translationOriginal, paymentMethodNameMap]
  );
  const _perspective = (0, import_react.useMemo)(
    () => ({
      key: "monitor",
      label: "Monitor",
      getChildComponentProps: (ctx) => ({
        grid: {
          bordered: true,
          collapseUniformColumns: true,
          columns: buildColumns(ctx),
          defaultHiddenColumnKeys: ["order_origin", "updated"],
          scroll: {
            // x: '1800px',
            x: "max-content",
            autoCalc: true,
            scrollToFirstRowOnChange: true
          },
          rowSelection: false,
          onRow: (record) => ({
            onClick: () => {
              var _a2, _b2, _c2;
              if (!record.id) return;
              if (onOpenDetail) {
                onOpenDetail({ orderId: (_a2 = record.order) == null ? void 0 : _a2.id, record });
                return;
              }
              utils == null ? void 0 : utils.action({
                type: "pisell1.handleOpenSaleDetail",
                data: {
                  osProps: {
                    orderId: record.order.id,
                    osKey: "sales-management-item-detail",
                    businessCode
                  }
                }
              });
              return;
              const time = /* @__PURE__ */ new Date();
              utils == null ? void 0 : utils.action({
                type: "pisell1.bookingDetail",
                data: {
                  component_type: getBookingType(record),
                  booking_id: record.order.id,
                  type: record.parent_id === 0 ? "list" : "detail",
                  id: record.id,
                  isParallelResourcesBooking: record.relation_id === 0 && record.relation_type === "",
                  preliminaryBookingDetail: {
                    customer: (_b2 = record == null ? void 0 : record.order) == null ? void 0 : _b2.customer,
                    id: record.order.id,
                    order_sales_channel: (_c2 = record == null ? void 0 : record.order) == null ? void 0 : _c2.order_sales_channel,
                    bookings: {
                      booking_id: record == null ? void 0 : record.booking_id,
                      appointment_status: record == null ? void 0 : record.appointment_status,
                      list: [
                        {
                          start_date: record == null ? void 0 : record.start_date,
                          start_time: record == null ? void 0 : record.start_time
                        }
                      ]
                    }
                  }
                },
                callback: (cbParams) => {
                  const { type } = cbParams || {};
                  if (Date.now() - time.getTime() < 500) {
                    return;
                  }
                  if (type === "close") {
                    return;
                  }
                  ctx.refresh();
                }
              });
            }
          })
        },
        toolBar: {
          search: { showConfirmButton: false },
          sort: { list: (0, import_booking.getSortList)() },
          filter: {
            hiddenQuickFilter: true,
            defaultFilterValue: {
              quickFilter: [],
              otherFilter: (0, import_booking.getFilterButtonList)(),
              values: {}
            }
          },
          quickFilter: {
            /** RecordBoard 平面图视图时用顶栏日程；网格视图保留快筛日期 */
            hideFilterNamesOnFloorMap: ["booking_time_start_between"],
            filterList: [
              {
                type: "rangePicker",
                name: "booking_time_start_between",
                key: "bookingTimeStartBetween",
                props: {
                  placeholder: import_utils.locales.getText(
                    "pisell2.salesManagement.booking.filter.bookingDate.label"
                  ),
                  showTime: true
                }
              }
            ]
          }
        },
        batchActionBar: {
          overflowThreshold: 2
        }
      })
    }),
    [buildColumns, utils, locale, onOpenDetail, businessCode]
  );
  return _perspective;
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  useBookingPerspective
});
