export {
  normalizeBillingCycle,
  deriveOrderStatusDescriptor,
  getOrderServiceCategory,
  getOrderServiceCategory as getServiceCategory,
  calculateOrderTotals,
  formatScheduledDate,
} from "@customer-portal/domain/orders";

export type {
  OrderStatusDescriptor,
  OrderStatusState,
  OrderStatusTone,
  OrderServiceCategory,
} from "@customer-portal/domain/orders";

export function summarizePrimaryItem(
  items: Array<{ name?: string; quantity?: number }> | undefined,
  fallback: string
): string {
  if (!items || items.length === 0) {
    return fallback;
  }

  const [primary, ...rest] = items;
  let summary = primary?.name || fallback;
  const additionalCount = rest.filter(Boolean).length;
  if (additionalCount > 0) {
    summary += ` +${additionalCount} more`;
  }
  return summary;
}
