/** Context shared by the default and Tip payment catalogs. */
import type {
  GiftCategory,
  GiftProduct,
  PayChannel,
  PaymentOrderStatus,
  PaymentPlan,
  CommercialOfferSummary,
  TipMessageResponse,
} from "@/data/schemas/payment";

export type PaymentPlanCatalog = "default" | "tip";

export interface PaymentState {
  planCatalog: PaymentPlanCatalog;
  plans: readonly PaymentPlan[];
  giftCategories: readonly GiftCategory[];
  giftProducts: readonly GiftProduct[];
  giftCharacterId: string | null;
  supportCharacterId: string | null;
  selectedGiftCategory: string | null;
  requestedGiftCategory: string | null;
  requestedGiftPlanId: string | null;
  isFirstRecharge: boolean;
  commercialOfferId: string | null;
  chatActionId: string | null;
  commercialOffer: CommercialOfferSummary | null;
  selectedPlanId: string;
  payChannel: PayChannel;
  autoRenew: boolean;
  agreed: boolean;
  currentOrderId: string | null;
  currentOrderPlanId: string | null;
  payParams: Record<string, unknown> | null;
  orderStatus: PaymentOrderStatus | null;
  tipMessage: TipMessageResponse | null;
  tipMessageError: string | null;
  orderPollingStartedAt: number | null;
  errorMessage: string | null;
  launchNonce: number;
}

export const initialState: PaymentState = {
  planCatalog: "default",
  plans: [],
  giftCategories: [],
  giftProducts: [],
  giftCharacterId: null,
  supportCharacterId: null,
  selectedGiftCategory: null,
  requestedGiftCategory: null,
  requestedGiftPlanId: null,
  isFirstRecharge: false,
  commercialOfferId: null,
  chatActionId: null,
  commercialOffer: null,
  selectedPlanId: "",
  payChannel: "stripe",
  autoRenew: true,
  agreed: true,
  currentOrderId: null,
  currentOrderPlanId: null,
  payParams: null,
  orderStatus: null,
  tipMessage: null,
  tipMessageError: null,
  orderPollingStartedAt: null,
  errorMessage: null,
  launchNonce: 0,
};
