"use client";

import type { ChatUnlockDialogModel } from "../hooks/use-chat-unlock-coordinator";

import { HistoryUnlockDialog } from "./history-unlock-dialog";
import { InsufficientCreditsDialog } from "./insufficient-credits-dialog";

export interface ChatUnlockDialogsProps {
  model: ChatUnlockDialogModel;
}

export function ChatUnlockDialogs({
  model,
}: ChatUnlockDialogsProps) {
  return (
    <>
      <HistoryUnlockDialog
        open={model.historyUnlock.open}
        lockedCount={model.historyUnlock.lockedCount}
        isLoading={model.historyUnlock.isLoading}
        errorMessage={model.historyUnlock.errorMessage}
        guidance={model.historyUnlock.guidance}
        onClose={model.closeHistoryUnlock}
        onConfirm={model.confirmHistoryUnlock}
      />
      <InsufficientCreditsDialog
        open={model.unlockPaywallRequest !== null}
        creditBalance={model.unlockPaywallRequest?.creditBalance ?? 0}
        requiredCredits={model.unlockPaywallRequest?.requiredCredits ?? 0}
        shortfallCredits={model.unlockPaywallRequest?.shortfallCredits ?? 0}
        guidance={model.unlockPaywallRequest?.paymentGuidance ?? null}
        onClose={model.closePaywall}
        onConfirm={model.confirmPaywall}
      />
    </>
  );
}
