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/pisellSalesGrid/mobileTable/applySalesPhoneGridColumns.ts
var applySalesPhoneGridColumns_exports = {};
__export(applySalesPhoneGridColumns_exports, {
  MOBILE_SALES_TABLE_GRID_CLASS: () => MOBILE_SALES_TABLE_GRID_CLASS,
  MOBILE_SALE_BRIEF_CELL_CLASS: () => MOBILE_SALE_BRIEF_CELL_CLASS,
  MOBILE_SALE_BRIEF_COLUMN_WIDTH: () => MOBILE_SALE_BRIEF_COLUMN_WIDTH,
  MOBILE_STACK_CELL_CLASS: () => MOBILE_STACK_CELL_CLASS,
  MOBILE_TAG_CELL_CLASS: () => MOBILE_TAG_CELL_CLASS,
  applySalesPhoneGridColumns: () => applySalesPhoneGridColumns,
  buildSalesPhoneGridScroll: () => buildSalesPhoneGridScroll,
  buildSalesPhoneRowSelection: () => buildSalesPhoneRowSelection,
  mergeSalesPhoneGridClassName: () => mergeSalesPhoneGridClassName,
  withDefaultSalesGridInfiniteScroll: () => withDefaultSalesGridInfiniteScroll
});
module.exports = __toCommonJS(applySalesPhoneGridColumns_exports);
var import_classnames = __toESM(require("classnames"));
var MOBILE_SALES_TABLE_GRID_CLASS = "pisell-sales-grid-mobile-table-grid";
var MOBILE_SALE_BRIEF_CELL_CLASS = "pisell-sales-grid-mobile-table-col--sale-brief";
var MOBILE_STACK_CELL_CLASS = "pisell-sales-grid-mobile-table-col--stack";
var MOBILE_TAG_CELL_CLASS = "pisell-sales-grid-mobile-table-col--tag";
var MOBILE_SALE_BRIEF_COLUMN_WIDTH = 156;
var MOBILE_ORDER_COLUMN_WIDTHS = {
  sale_brief: MOBILE_SALE_BRIEF_COLUMN_WIDTH,
  customer: 108,
  contacts_info: 108,
  payment_info: 108,
  product_quantity: 80,
  order_origin: 132,
  payment_status: 108,
  delivery_type: 108,
  status: 104,
  shipping_status: 108,
  last_edit_account: 128,
  order_id: 72
};
var MOBILE_BOOKING_COLUMN_WIDTHS = {
  booking_brief: 136,
  relation_form_name: 72,
  service_time: 120,
  customer: 88,
  contact: 108,
  holder_data: 88,
  services: 88,
  number: 80,
  appointment_form: 96,
  order_info: 92,
  booking_id: 72,
  order_origin: 100,
  updated: 96
};
var MOBILE_STACK_COLUMN_KEYS = /* @__PURE__ */ new Set([
  "sale_brief",
  "booking_brief",
  "customer",
  "contacts_info",
  "contact",
  "holder_data",
  "services",
  "payment_info",
  "order_info",
  "order_origin",
  "last_edit_account",
  "updated"
]);
var MOBILE_TAG_COLUMN_KEYS = /* @__PURE__ */ new Set([
  "payment_status",
  "delivery_type",
  "status",
  "shipping_status"
]);
var MOBILE_WIDTH_SCALE_FALLBACK = 0.72;
var MOBILE_MIN_COLUMN_WIDTH = 64;
function withDefaultSalesGridInfiniteScroll(grid) {
  return {
    ...grid,
    infiniteScroll: grid.infiniteScroll !== false
  };
}
function getColumnKey(column) {
  return String(column.key ?? column.dataIndex ?? "");
}
function toCellClassName(key) {
  return `pisell-sales-grid-mobile-table-col--${key.replace(/_/g, "-")}`;
}
function resolvePhoneWidth(key, desktopWidth) {
  if (MOBILE_ORDER_COLUMN_WIDTHS[key] != null) {
    return MOBILE_ORDER_COLUMN_WIDTHS[key];
  }
  if (MOBILE_BOOKING_COLUMN_WIDTHS[key] != null) {
    return MOBILE_BOOKING_COLUMN_WIDTHS[key];
  }
  if (typeof desktopWidth === "number" && desktopWidth > 0) {
    return Math.max(
      MOBILE_MIN_COLUMN_WIDTH,
      Math.round(desktopWidth * MOBILE_WIDTH_SCALE_FALLBACK)
    );
  }
  return void 0;
}
function withCellClass(column, cellClassNames) {
  const merged = (0, import_classnames.default)(
    typeof column.className === "string" ? column.className : void 0,
    ...cellClassNames
  );
  return {
    ...column,
    className: merged,
    onCell: () => ({
      className: merged
    })
  };
}
function adaptPhoneColumn(column) {
  const key = getColumnKey(column);
  if (!key) {
    return column;
  }
  const phoneWidth = resolvePhoneWidth(key, column.width);
  if (phoneWidth == null) {
    return column;
  }
  const cellClass = toCellClassName(key);
  const cellClassNames = [cellClass];
  if (MOBILE_STACK_COLUMN_KEYS.has(key)) {
    cellClassNames.push(MOBILE_STACK_CELL_CLASS);
  }
  if (MOBILE_TAG_COLUMN_KEYS.has(key)) {
    cellClassNames.push(MOBILE_TAG_CELL_CLASS);
  }
  const useAntdEllipsis = !MOBILE_STACK_COLUMN_KEYS.has(key) && !MOBILE_TAG_COLUMN_KEYS.has(key);
  return withCellClass(
    {
      ...column,
      width: phoneWidth,
      ellipsis: useAntdEllipsis
    },
    cellClassNames
  );
}
function applySalesPhoneGridColumns(columns) {
  if (!Array.isArray(columns)) {
    return columns;
  }
  return columns.map((column) => adaptPhoneColumn(column));
}
function mergeSalesPhoneGridClassName(className) {
  return (0, import_classnames.default)(className, MOBILE_SALES_TABLE_GRID_CLASS);
}
function buildSalesPhoneGridScroll(scroll) {
  const base = scroll && typeof scroll === "object" ? { ...scroll } : {};
  const { x: _dropHorizontalScroll, ...scrollWithoutX } = base;
  return {
    ...scrollWithoutX,
    autoCalc: base.autoCalc ?? true
  };
}
function buildSalesPhoneRowSelection(rowSelection) {
  if (!rowSelection || typeof rowSelection !== "object") {
    return rowSelection;
  }
  return {
    ...rowSelection,
    fixed: false
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  MOBILE_SALES_TABLE_GRID_CLASS,
  MOBILE_SALE_BRIEF_CELL_CLASS,
  MOBILE_SALE_BRIEF_COLUMN_WIDTH,
  MOBILE_STACK_CELL_CLASS,
  MOBILE_TAG_CELL_CLASS,
  applySalesPhoneGridColumns,
  buildSalesPhoneGridScroll,
  buildSalesPhoneRowSelection,
  mergeSalesPhoneGridClassName,
  withDefaultSalesGridInfiniteScroll
});
