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/salesSdk/selectors.ts
var selectors_exports = {};
__export(selectors_exports, {
  deriveDisabledEdit: () => deriveDisabledEdit,
  deriveSummary: () => deriveSummary,
  isWalkInCustomer: () => isWalkInCustomer
});
module.exports = __toCommonJS(selectors_exports);
var PAYMENT_STATUS_EDITABLE_WHITELIST = /* @__PURE__ */ new Set([
  "unfulfilled",
  "paid",
  "unpaid",
  "payment_processing"
]);
function deriveDisabledEdit(rootBooking, header) {
  var _a;
  const appointmentStatus = String((rootBooking == null ? void 0 : rootBooking.appointment_status) ?? "");
  const rawPaymentStatus = String((header == null ? void 0 : header.payment_status) ?? "");
  const paymentStatus = rawPaymentStatus === "partially_paid" ? "unpaid" : rawPaymentStatus;
  const channelDisabledEdit = Boolean((_a = header == null ? void 0 : header.metadata) == null ? void 0 : _a.is_other_entrance_edited);
  const cancelled = appointmentStatus === "cancelled";
  const inWhitelist = paymentStatus === "" || PAYMENT_STATUS_EDITABLE_WHITELIST.has(paymentStatus);
  const disabledEdit = cancelled || !inWhitelist || channelDisabledEdit;
  return {
    disabledEdit,
    channelDisabledEdit,
    appointmentStatus,
    paymentStatus: rawPaymentStatus
  };
}
var ZERO_AMOUNT = "0.00";
function deriveSummary(summary) {
  const get = (key) => {
    const v = summary == null ? void 0 : summary[key];
    if (v == null) return ZERO_AMOUNT;
    return String(v);
  };
  return {
    productAmount: get("product_amount"),
    productOriginalAmount: get("product_original_amount"),
    productExpectAmount: get("product_expect_amount"),
    productTaxFee: get("product_tax_fee"),
    taxFee: get("tax_fee"),
    surchargeFee: get("surcharge_fee"),
    discountAmount: get("discount_amount"),
    depositAmount: get("deposit_amount"),
    expectAmount: get("expect_amount"),
    totalAmount: get("total_amount"),
    amountGap: get("amount_gap"),
    roundingAmount: get("rounding_amount")
  };
}
function isWalkInCustomer(customer) {
  if (!customer) return true;
  const id = customer.id;
  if (id === void 0 || id === null) return true;
  if (typeof id === "string") {
    return ["", "0", "1"].includes(id);
  }
  return [0, 1].includes(id);
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  deriveDisabledEdit,
  deriveSummary,
  isWalkInCustomer
});
