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/pisellReservation/mobileTable/buildReservationMobileTableConfig.ts
var buildReservationMobileTableConfig_exports = {};
__export(buildReservationMobileTableConfig_exports, {
  MOBILE_TOOLBAR_RANGE_FILTER_ITEM_CLASS: () => MOBILE_TOOLBAR_RANGE_FILTER_ITEM_CLASS,
  adaptFilterConfigForMobile: () => adaptFilterConfigForMobile,
  adaptFilterListForMobile: () => adaptFilterListForMobile,
  adaptQuickFiltersForMobileToolbar: () => adaptQuickFiltersForMobileToolbar,
  buildReservationHudDrawerToolbarConfig: () => buildReservationHudDrawerToolbarConfig,
  buildReservationMobileTableGridConfig: () => buildReservationMobileTableGridConfig,
  buildReservationMobileTableToolbarConfig: () => buildReservationMobileTableToolbarConfig,
  buildReservationPhoneNarrowStackToolbarConfig: () => buildReservationPhoneNarrowStackToolbarConfig
});
module.exports = __toCommonJS(buildReservationMobileTableConfig_exports);
var import_classnames = __toESM(require("classnames"));
var import_materials = require("@pisell/materials");
var MOBILE_BOOKING_BRIEF_CELL_CLASS = "pisell-reservation-mobile-table-col--booking-brief";
var MOBILE_ORDER_INFO_CELL_CLASS = "pisell-reservation-mobile-table-col--order-info";
var MOBILE_CUSTOMER_CELL_CLASS = "pisell-reservation-mobile-table-col--customer";
var MOBILE_CONTACT_CELL_CLASS = "pisell-reservation-mobile-table-col--contact";
var MOBILE_HOLDER_DATA_CELL_CLASS = "pisell-reservation-mobile-table-col--holder-data";
var MOBILE_PERSON_COLUMN_CLASS_BY_KEY = {
  customer: MOBILE_CUSTOMER_CELL_CLASS,
  contact: MOBILE_CONTACT_CELL_CLASS,
  holder_data: MOBILE_HOLDER_DATA_CELL_CLASS
};
var MOBILE_RESERVATION_COLUMN_WIDTH_CAPS = {
  booking_brief: 124,
  relation_form_name: 88,
  service_time: 128,
  order_info: 100,
  customer: 96,
  contact: 100,
  holder_data: 88,
  services: 88,
  number: 72,
  appointment_form: 92,
  booking_id: 72,
  order_origin: 96,
  updated: 88,
  actions: 72
};
var MOBILE_RESERVATION_WIDTH_RATIO = 0.78;
function narrowBookingBriefColumn(column) {
  const key = String(column.key ?? column.dataIndex ?? "");
  if (key !== "booking_brief") return column;
  return {
    ...column,
    /** 自定义 render 含多行内容，关闭 antd 单元格单行省略 */
    ellipsis: false,
    className: (0, import_classnames.default)(
      typeof column.className === "string" ? column.className : void 0,
      MOBILE_BOOKING_BRIEF_CELL_CLASS
    ),
    onCell: () => ({
      className: MOBILE_BOOKING_BRIEF_CELL_CLASS
    })
  };
}
function narrowOrderInfoColumn(column) {
  const key = String(column.key ?? column.dataIndex ?? "");
  if (key !== "order_info") return column;
  return {
    ...column,
    /** 纵向多行 render；关闭 antd 整格单行省略，由列 class CSS 对每行子元素单独省略 */
    ellipsis: false,
    className: (0, import_classnames.default)(
      typeof column.className === "string" ? column.className : void 0,
      MOBILE_ORDER_INFO_CELL_CLASS
    ),
    onCell: () => ({
      className: MOBILE_ORDER_INFO_CELL_CLASS
    })
  };
}
function narrowServiceTimeColumn(column) {
  const key = String(column.key ?? column.dataIndex ?? "");
  if (key !== "service_time") return column;
  return {
    ...column,
    className: (0, import_classnames.default)(
      typeof column.className === "string" ? column.className : void 0,
      "pisell-reservation-mobile-table-col--service-time"
    )
  };
}
function narrowPersonInfoColumn(column) {
  const key = String(column.key ?? column.dataIndex ?? "");
  const cellClass = MOBILE_PERSON_COLUMN_CLASS_BY_KEY[key];
  if (!cellClass) return column;
  return {
    ...column,
    ellipsis: false,
    className: (0, import_classnames.default)(
      typeof column.className === "string" ? column.className : void 0,
      cellClass
    ),
    onCell: () => ({
      className: cellClass
    })
  };
}
var MOBILE_TOOLBAR_RANGE_FILTER_ITEM_CLASS = "pisell-reservation-mobile-toolbar-range-filter-item";
function adaptFilterListForMobile(filterList, options) {
  return filterList.map((item) => {
    if (String(item.type) !== "rangePicker") return item;
    const props = typeof item.props === "object" && item.props !== null ? { ...item.props } : {};
    const other = typeof item.other === "object" && item.other !== null ? { ...item.other } : {};
    const priorFormItemProps = typeof other.formItemProps === "object" && other.formItemProps !== null ? other.formItemProps : {};
    const placeholder = typeof props.placeholder === "string" ? props.placeholder : typeof other.placeholder === "string" ? other.placeholder : void 0;
    delete props.placeholder;
    delete other.placeholder;
    delete props.showTime;
    delete other.showTime;
    const priorStyle = typeof priorFormItemProps.style === "object" && priorFormItemProps.style !== null ? priorFormItemProps.style : {};
    return {
      ...item,
      type: "custom",
      other: {
        ...other,
        component: import_materials.PisellMobileDateRangePicker,
        formItemProps: {
          ...priorFormItemProps,
          ...(options == null ? void 0 : options.rangeFormItemClassName) ? {
            className: (0, import_classnames.default)(
              options.rangeFormItemClassName,
              typeof priorFormItemProps.className === "string" ? priorFormItemProps.className : void 0
            )
          } : {},
          ...(options == null ? void 0 : options.compactFormItem) ? { style: { marginBottom: 0, ...priorStyle } } : {}
        }
      },
      props: {
        ...props,
        format: "DD/MM/YYYY",
        ...placeholder ? { placeholder } : {},
        ...(options == null ? void 0 : options.rangePickerVariant) ? { variant: options.rangePickerVariant } : {},
        style: {
          width: "100%",
          minWidth: 0,
          maxWidth: "100%",
          ...typeof props.style === "object" && props.style !== null ? props.style : {}
        }
      }
    };
  });
}
function adaptQuickFiltersForMobileToolbar(filterList) {
  return adaptFilterListForMobile(filterList, {
    rangeFormItemClassName: MOBILE_TOOLBAR_RANGE_FILTER_ITEM_CLASS,
    compactFormItem: true
  });
}
function adaptFilterConfigForMobile(filterConfig) {
  const defaultFilterValue = filterConfig.defaultFilterValue;
  if (typeof defaultFilterValue !== "object" || defaultFilterValue === null) {
    return filterConfig;
  }
  const rawOther = defaultFilterValue.otherFilter;
  if (!Array.isArray(rawOther)) return filterConfig;
  return {
    ...filterConfig,
    defaultFilterValue: {
      ...defaultFilterValue,
      otherFilter: adaptFilterListForMobile(rawOther, {
        rangePickerVariant: "filter"
      })
    }
  };
}
function buildReservationPhoneNarrowStackToolbarConfig(baseToolBar) {
  const base = baseToolBar ?? {};
  const baseClassName = typeof base.className === "string" ? base.className : void 0;
  return {
    ...base,
    className: (0, import_classnames.default)(
      baseClassName,
      "pisell-record-board-toolbar--narrow-stack"
    )
  };
}
function buildReservationMobileTableToolbarConfig(params) {
  const base = params.baseToolBar ?? {};
  const baseClassName = typeof base.className === "string" ? base.className : void 0;
  const baseSearch = typeof base.search === "object" && base.search !== null ? base.search : {};
  return {
    ...base,
    toolbarDensity: "compact-narrow",
    filter: typeof base.filter === "object" && base.filter !== null ? { ...base.filter, phoneLayout: true } : { phoneLayout: true },
    quickFilter: params.quickFilterFilterList && params.quickFilterFilterList.length > 0 ? { filterList: params.quickFilterFilterList } : false,
    search: params.searchGetContainer ? {
      ...baseSearch,
      getContainer: params.searchGetContainer,
      /** 相对全宽略收窄并设上限，避免 Find Modal 在手机预约里占满一整屏显得过大 */
      modalWidth: "min(calc(100% - 24px), 360px)",
      modalStyle: {
        ...typeof baseSearch.modalStyle === "object" && baseSearch.modalStyle !== null && !Array.isArray(baseSearch.modalStyle) ? baseSearch.modalStyle : {},
        marginLeft: "auto",
        marginRight: "auto"
      }
    } : baseSearch,
    className: (0, import_classnames.default)(
      baseClassName,
      "pisell-record-board-toolbar--narrow-stack",
      "pisell-reservation-mobile-table-toolbar"
    )
  };
}
function buildReservationMobileTableGridConfig(grid) {
  const base = grid ?? {};
  const rawColumns = Array.isArray(base.columns) ? base.columns : [];
  const columns = (0, import_materials.adaptColumnsForPhoneLayout)(
    rawColumns.map(
      (column) => narrowOrderInfoColumn(
        narrowServiceTimeColumn(
          narrowPersonInfoColumn(narrowBookingBriefColumn(column))
        )
      )
    ),
    {
      widthCapsByKey: MOBILE_RESERVATION_COLUMN_WIDTH_CAPS,
      defaultWidthRatio: MOBILE_RESERVATION_WIDTH_RATIO
    }
  );
  const scrollBase = typeof base.scroll === "object" && base.scroll !== null ? base.scroll : {};
  const { x: _dropHorizontalScroll, ...scrollWithoutX } = scrollBase;
  return {
    ...base,
    columns,
    infiniteScroll: true,
    size: "small",
    className: (0, import_classnames.default)(
      typeof base.className === "string" ? base.className : void 0,
      "pisell-reservation-mobile-table-grid"
    ),
    scroll: {
      ...scrollWithoutX,
      autoCalc: true
    }
  };
}
function buildReservationHudDrawerToolbarConfig(params) {
  const built = buildReservationMobileTableToolbarConfig({
    baseToolBar: params.baseToolBar,
    searchGetContainer: params.searchGetContainer,
    quickFilterFilterList: [
      {
        type: "custom",
        key: "hudQuickFiltersRow",
        other: {
          component: params.quickFilterComponent,
          compositeFilterFieldNames: [
            "appointment_status",
            "order_payment_status"
          ],
          formItemProps: { style: { marginBottom: 0 } }
        }
      }
    ]
  });
  const builtClass = typeof built.className === "string" ? built.className : void 0;
  const builtSearch = typeof built.search === "object" && built.search !== null ? built.search : void 0;
  const priorModalStyle = builtSearch && typeof builtSearch.modalStyle === "object" && builtSearch.modalStyle !== null && !Array.isArray(builtSearch.modalStyle) ? builtSearch.modalStyle : {};
  return {
    ...built,
    mergeCompactNarrowTrailingWithQuickFilterRow: true,
    /** HUD 内嵌表：Find Modal 铺满抽屉内容区；手机 Table 仍保留 360px 上限 */
    search: params.searchGetContainer && builtSearch ? {
      ...builtSearch,
      modalWidth: "100%",
      modalStyle: {
        ...priorModalStyle,
        marginLeft: 0,
        marginRight: 0,
        width: "100%",
        maxWidth: "100%"
      }
    } : built.search,
    className: (0, import_classnames.default)(
      builtClass,
      "pisell-reservation-hud-table-toolbar"
    )
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  MOBILE_TOOLBAR_RANGE_FILTER_ITEM_CLASS,
  adaptFilterConfigForMobile,
  adaptFilterListForMobile,
  adaptQuickFiltersForMobileToolbar,
  buildReservationHudDrawerToolbarConfig,
  buildReservationMobileTableGridConfig,
  buildReservationMobileTableToolbarConfig,
  buildReservationPhoneNarrowStackToolbarConfig
});
