/**
 * Outbox handler registry.
 *
 * Explicit array — NOT a Vite glob. Outbox handlers are a closed set dispatched
 * in a CF Worker; explicit imports are tree-shaker-safe and make the contract visible.
 *
 * To add a new handler:
 *  1. Create apps/web/src/server/workflows/outbox/handlers/<event-type>.ts
 *  2. Import and add it to OUTBOX_HANDLERS below.
 *  3. Add a fixture to regression/outbox-replay/fixtures/<event-type>.json
 */

import type { OutboxHandler } from './types.js';

import { purchaseEmailReceipt } from './handlers/purchase.email_receipt.js';
import { purchaseEmailDetailsQr } from './handlers/purchase.email_details_qr.js';
import { purchaseGuestEmailReceipt } from './handlers/purchase.guest_email_receipt.js';
import { purchaseGuestEmailDetailsQr } from './handlers/purchase.guest_email_details_qr.js';
import { clubMembershipCreate } from './handlers/club_membership.create.js';
import { purchaseExpiredSplit } from './handlers/purchase.expired_split.js';
import { adminVendorMessage } from './handlers/admin.vendor_message.js';
import { supportAiDispatch } from './handlers/support.ai.dispatch.js';
import { supportNotifEmail } from './handlers/support.notif.email.js';
import { supportNotifPush } from './handlers/support.notif.push.js';
import { supportCaseRefundRequested } from './handlers/support-case.refund.requested.js';
import { supportRefundRetry } from './handlers/support.refund.retry.js';
import { vendorHeroReview } from './handlers/vendor.hero.review.js';
import { contactSupportEmail } from './handlers/contact.support_email.js';
import { refundExecutedEmail } from './handlers/refund.executed_email.js';
import { paymentsRefundPartialFailure } from './handlers/payments.refund.partial_failure.js';
import { vendorStripeOnboardingInvite } from './handlers/vendor.stripe.onboarding_invite.js';
import { vendorStripeChargesEnabled } from './handlers/vendor.stripe.charges_enabled.js';
import { translationJobEnqueued } from './handlers/translation.job_enqueued.js';
import { notificationDeliver } from './handlers/notification.deliver.js';
import { returnsOpened } from './handlers/returns.opened.js';
import { returnsApproved } from './handlers/returns.approved.js';
import { returnsTrackingEntered } from './handlers/returns.tracking_entered.js';
import { returnsReceived } from './handlers/returns.received.js';
import { returnsRefunded } from './handlers/returns.refunded.js';
import { returnsAutoRefundedSla } from './handlers/returns.auto_refunded_sla.js';
import { returnsDenied } from './handlers/returns.denied.js';
import { returnsSlaExpiredBuyerShip } from './handlers/returns.sla_expired_buyer_ship.js';
import { returnsCancelled } from './handlers/returns.cancelled.js';
import { referralClawback } from './handlers/referral.clawback.js';
import { referralEarn } from './handlers/referral.earn.js';
import { referralQualified } from './handlers/referral.qualified.js';
import { buyerWelcomeDay0 } from './handlers/handle-buyer-welcome-day0.js';
import { buyerWelcomeDay3 } from './handlers/handle-buyer-welcome-day3.js';
import { buyerDigestWeekly } from './handlers/handle-buyer-digest-weekly.js';
import { buyerVoucherExpiry } from './handlers/handle-buyer-voucher-expiry.js';
import {
  buyerReengagement30d,
  buyerReengagement60d,
  buyerReengagement90d,
} from './handlers/handle-buyer-reengagement.js';
import { buyerPostpurchaseDay7 } from './handlers/handle-buyer-postpurchase-day7.js';
import { buyerUnsubscribed } from './handlers/handle-buyer-unsubscribed.js';
import { vendorWelcomeDay0 } from './handlers/handle-vendor-welcome-day0.js';
import { vendorDealExpiry } from './handlers/handle-vendor-deal-expiry.js';
import { vendorLowRedemption } from './handlers/handle-vendor-low-redemption.js';
import { imageRejected } from './handlers/image.rejected.js';
import { dealLlmValidate } from './handlers/deal.llm-validate.js';
import {
  cartCheckoutCompensation,
  cartCheckoutCompensationCleanup,
  cartCheckoutFulfillment,
} from './handlers/cart.checkout.compensation.js';

export const OUTBOX_HANDLERS: readonly OutboxHandler<unknown>[] = [
  purchaseEmailReceipt,
  purchaseEmailDetailsQr,
  purchaseGuestEmailReceipt,
  purchaseGuestEmailDetailsQr,
  clubMembershipCreate,
  purchaseExpiredSplit,
  adminVendorMessage,
  supportAiDispatch,
  supportNotifEmail,
  supportNotifPush,
  supportCaseRefundRequested,
  supportRefundRetry,
  vendorHeroReview,
  contactSupportEmail,
  refundExecutedEmail,
  paymentsRefundPartialFailure,
  vendorStripeOnboardingInvite,
  vendorStripeChargesEnabled,
  translationJobEnqueued,
  notificationDeliver,
  returnsOpened,
  returnsApproved,
  returnsTrackingEntered,
  returnsReceived,
  returnsRefunded,
  returnsAutoRefundedSla,
  returnsDenied,
  returnsSlaExpiredBuyerShip,
  returnsCancelled,
  referralClawback,
  referralEarn,
  referralQualified,
  buyerWelcomeDay0,
  buyerWelcomeDay3,
  buyerDigestWeekly,
  buyerVoucherExpiry,
  buyerReengagement30d,
  buyerReengagement60d,
  buyerReengagement90d,
  buyerPostpurchaseDay7,
  buyerUnsubscribed,
  vendorWelcomeDay0,
  vendorDealExpiry,
  vendorLowRedemption,
  imageRejected,
  dealLlmValidate,
  cartCheckoutCompensation,
  cartCheckoutCompensationCleanup,
  cartCheckoutFulfillment,
];

export const HANDLER_BY_TYPE = new Map(OUTBOX_HANDLERS.map((h) => [h.type, h] as const));
