/**
 * 支付套餐列表响应
 */
import { z } from "zod";

import {
  arrayOrEmpty,
  booleanOrFalse,
  numberOrZero,
  schemaOrNull,
  stringOrEmpty,
} from "../../nullable-defaults";
import { PaymentPlanSchema } from "../payment_plan";

export const FirstRechargeOfferSchema = z
  .object({
    enabled: booleanOrFalse,
    type: stringOrEmpty,
    discountPercent: numberOrZero,
  })
  .readonly();

export const CommercialOfferSummarySchema = z
  .object({
    enabled: booleanOrFalse,
    commercialOfferId: z.string().min(1),
    characterId: stringOrEmpty,
    planId: z.string().min(1),
    discountPercent: numberOrZero,
    pricePercent: numberOrZero,
    expiresAt: z.string().min(1),
    triggerReason: stringOrEmpty,
    message: stringOrEmpty,
  })
  .readonly();

export const PaymentPlansResponseSchema = z
  .object({
    isFirstRecharge: booleanOrFalse,
    supportCharacterId: stringOrEmpty,
    firstRechargeOffer: schemaOrNull(FirstRechargeOfferSchema),
    commercialOffer: schemaOrNull(CommercialOfferSummarySchema),
    plans: arrayOrEmpty(PaymentPlanSchema),
  })
  .readonly();

export type PaymentPlansResponseInput = z.input<
  typeof PaymentPlansResponseSchema
>;
export type PaymentPlansResponseData = z.output<
  typeof PaymentPlansResponseSchema
>;
export type FirstRechargeOfferData = z.output<typeof FirstRechargeOfferSchema>;
export type CommercialOfferSummaryData = z.output<typeof CommercialOfferSummarySchema>;

export type FirstRechargeOffer = FirstRechargeOfferData;
export type CommercialOfferSummary = CommercialOfferSummaryData;

export type PaymentPlansResponse = PaymentPlansResponseData;
