var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/saleDetail/utils/adjustTimeOrderAmounts.ts
var adjustTimeOrderAmounts_exports = {};
__export(adjustTimeOrderAmounts_exports, {
  resolveAdjustTimeOrderAmounts: () => resolveAdjustTimeOrderAmounts
});
module.exports = __toCommonJS(adjustTimeOrderAmounts_exports);
var toAmountNumber = (value) => {
  const amount = Number(value || 0);
  return Number.isFinite(amount) ? amount : 0;
};
var firstDefined = (...values) => {
  for (const value of values) {
    if (value !== void 0 && value !== null && value !== "") return value;
  }
  return void 0;
};
function resolveAdjustTimeOrderAmounts(input) {
  var _a, _b, _c, _d, _e, _f;
  const tempSummary = (_a = input.tempOrder) == null ? void 0 : _a.summary;
  const contextSummary = input.summary;
  const detailSummary = (_b = input.salesDetail) == null ? void 0 : _b.summary;
  const rawSummary = (_d = (_c = input.salesDetail) == null ? void 0 : _c.raw) == null ? void 0 : _d.summary;
  return {
    orderTotalAmount: toAmountNumber(
      firstDefined(
        tempSummary == null ? void 0 : tempSummary.expect_amount,
        tempSummary == null ? void 0 : tempSummary.total_amount,
        contextSummary == null ? void 0 : contextSummary.expect_amount,
        contextSummary == null ? void 0 : contextSummary.total_amount,
        detailSummary == null ? void 0 : detailSummary.expect_amount,
        detailSummary == null ? void 0 : detailSummary.total_amount,
        rawSummary == null ? void 0 : rawSummary.expect_amount,
        rawSummary == null ? void 0 : rawSummary.total_amount,
        (_f = (_e = input.salesDetail) == null ? void 0 : _e.header) == null ? void 0 : _f.total_amount
      )
    ),
    orderPaidAmount: toAmountNumber(
      firstDefined(
        tempSummary == null ? void 0 : tempSummary.order_paid_amount,
        contextSummary == null ? void 0 : contextSummary.order_paid_amount,
        detailSummary == null ? void 0 : detailSummary.order_paid_amount,
        rawSummary == null ? void 0 : rawSummary.order_paid_amount
      )
    )
  };
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  resolveAdjustTimeOrderAmounts
});
