"use strict";

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports.detectScenario = detectScenario;
function detectScenario(session, items) {
  if (!session) return "composite";
  const isSingleItem = items.length === 1;
  const isPaymentMode = session.mode === "payment";
  const isSubscriptionMode = ["subscription", "setup"].includes(session.mode || "");
  if (isSingleItem && isPaymentMode) {
    const item = items[0];
    const product = item.price?.product;
    if (product?.type === "credit" && item.price?.metadata?.credit_config) {
      return "credit-topup";
    }
  }
  if (isSingleItem && isSubscriptionMode && !items.some(i => i.cross_sell)) {
    return "subscription";
  }
  return "composite";
}