"use client"; import Link from "next/link"; import { ArrowRight, BellRing, CheckCircle2, Coins, Crown, Loader2, Lock, MessageSquare, Radar, Send, Sparkles, TrendingUp, Wallet, X, Zap, } from "lucide-react"; export type UnlockProBilling = { pointsEnabled: boolean; isEligible: boolean; pointsUsed: number; discountAmount: number; finalPrice: number; maxDiscountUsd: number; pointsPerUsd: number; }; type UnlockProOverlayProps = { points: number; planPriceUsd: number; usePoints: boolean; billing: UnlockProBilling; onToggleUsePoints: () => void; onPay: () => void; onClose?: () => void; payBusy?: boolean; payLabel?: string; locale?: "zh-CN" | "en-US"; errorText?: string; infoText?: string; faqHref?: string; telegramGroupUrl?: string; }; const features = { "zh-CN": [ { icon: TrendingUp, label: "15天高精度趋势预报" }, { icon: Radar, label: "实时多源雷达图" }, { icon: Send, label: "全平台智能气象推送" }, ], "en-US": [ { icon: TrendingUp, label: "15-day precision forecast" }, { icon: Radar, label: "Real-time radar panel" }, { icon: Send, label: "Cross-platform alert push" }, ], }; export function UnlockProOverlay({ points, planPriceUsd, usePoints, billing, onToggleUsePoints, onPay, onClose, payBusy = false, payLabel, locale = "zh-CN", errorText, infoText, faqHref = "/account", telegramGroupUrl, }: UnlockProOverlayProps) { const isEn = locale === "en-US"; const title = isEn ? "Unlock PolyWeather Pro" : "解锁 PolyWeather Pro"; const subtitle = isEn ? "High-precision weather intelligence, delivered everywhere." : "全球最精准的高精度气象推送,全平台覆盖"; const finalPayLabel = payLabel || (isEn ? "Subscribe & Activate" : "立即订阅并激活服务"); const featureList = features[locale] ?? features["zh-CN"]; const canUsePoints = billing.pointsEnabled && billing.isEligible; return (
{/* Ambient background */}
{/* Close button */} {onClose && ( )}
{/* Header */}
{/* Badge */}
Pro

{title}

{subtitle}

{/* Main content grid */}
{/* Left: Plan card */}
{/* Inner glow */}
Standard Pro / {isEn ? "mo" : "月"}
${planPriceUsd.toFixed(2)}
{featureList.map(({ icon: Icon, label }, i) => (
{label}
))}
{/* Right: Points card */} {canUsePoints ? (
{/* Header row */}
{isEn ? "Points Credit" : "积分抵扣"}
{/* Toggle */}
{/* Discount display */}
-${billing.discountAmount.toFixed(2)} off

{usePoints ? isEn ? `Using ${billing.pointsUsed} pts · saves $${billing.discountAmount.toFixed(2)}` : `已消耗 ${billing.pointsUsed} 积分 · 省 $${billing.discountAmount.toFixed(2)}` : isEn ? `Toggle to save up to $${billing.maxDiscountUsd.toFixed(2)}` : `开启可最多抵扣 $${billing.maxDiscountUsd.toFixed(2)}`}

{/* Points balance */}
{isEn ? "Your balance:" : "当前积分:"}{" "} {points}
) : ( /* Not eligible / points disabled */
{/* Top */}
{!billing.pointsEnabled ? isEn ? "Points Disabled" : "积分未开启" : isEn ? "Insufficient Points" : "积分不足"}

{isEn ? "Earn Points & Save" : "赚取积分,抵扣订阅"}

{!billing.pointsEnabled ? isEn ? "Points redemption is unavailable for this plan." : "当前套餐暂不支持积分抵扣。" : isEn ? `Need ${billing.pointsPerUsd} pts minimum. You have: ${points}` : `至少需要 ${billing.pointsPerUsd} 积分,当前仅有 ${points}`}

{/* Progress bar */} {billing.pointsEnabled && (
{points} / {billing.pointsPerUsd} {Math.min( 100, Math.round((points / billing.pointsPerUsd) * 100), )} %
)} {/* Bottom CTA */}
{telegramGroupUrl ? ( {isEn ? "Join Telegram to earn" : "加入电报群赚取积分"} ) : ( {isEn ? "Join community to earn points" : "加入社群即可赚取积分"} )}
)}
{/* Payment summary */}
{/* Summary row */}

{isEn ? "Total Due Today" : "今日应付"}

{billing.discountAmount > 0 && usePoints && (

${planPriceUsd.toFixed(2)} USD

)}
${billing.finalPrice.toFixed(2)} USD
{/* CTA Button */}
{/* Footer links */}
{isEn ? "Secure Payment" : "安全付款"} · {isEn ? "Subscription FAQ" : "订阅说明"}
{/* Error / Info messages */} {errorText && (

{errorText}

)} {infoText && (

{infoText}

)}
); }