import React from 'react'; import { __, sprintf } from '@wordpress/i18n'; import { ArrowRight, FlaskConical, TrendingUp } from 'lucide-react'; import type { CompressionCheckResult } from '../../api'; import { formatBytes, numberFormat, percentFormat, dateFormat } from '../../lib/i18n'; import { COMPRESSION_CHECK_PRO_LINK, compressionCheckCtaLabel, loadTimeSaved } from './compression-check'; import { MISSED_SAVINGS_FLOOR } from './model'; function EstimateChip( { title }: { title: string } ) { return ( ); } /** * The page's one upsell: what Pro would save on this library, measured on copies of its own images. * * Nothing here is invented. With no measurement it offers the check instead of a number. */ export default function ProBand( { result, running, runLabel, onRun, canSeeSamples, onSeeSamples, missedBytes, missedSince, offer }: { result: CompressionCheckResult | null; running: boolean; runLabel: string; onRun: () => void; canSeeSamples: boolean; onSeeSamples: () => void; missedBytes: number | null; missedSince: number; /** A real, running discount from the checkup; null when there is none. */ offer?: { code: string; percent: number; expires: number } | null; } ) { const showMissed = missedBytes !== null && missedBytes >= MISSED_SAVINGS_FLOOR; return (
{ __( 'Pro would save you', 'image-sizes' ) } { result ? ( <>
{ result.saved_bytes > 0 ? sprintf( /* translators: %s: size saved, e.g. "2.1 GB". */ __( '~%s smaller', 'image-sizes' ), formatBytes( result.saved_bytes, true ), ) : sprintf( /* translators: %s: how much smaller, e.g. "35%". */ __( '%s smaller', 'image-sizes' ), percentFormat( result.saved_pct ), ) } { sprintf( /* translators: %s: number of images the estimate covers. */ __( 'across your %s images', 'image-sizes' ), numberFormat( result.image_count ), ) } { loadTimeSaved( result.saved_pct ) !== null && ( <> { ' ' } { sprintf( /* translators: %s: seconds saved, e.g. "1.4". */ __( 'and ~%s s faster image load', 'image-sizes' ), numberFormat( loadTimeSaved( result.saved_pct ) as number ), ) } ) }
{ sprintf( /* translators: 1: number of images tested, 2: percentage saved on average. */ __( 'We tested %1$s of your images at Pro’s default quality: %2$s smaller on average.', 'image-sizes' ), numberFormat( result.samples_tested ), percentFormat( result.saved_pct ), ) }
{ sprintf( /* translators: %s: date the check ran. */ __( 'Checked %s.', 'image-sizes' ), dateFormat( result.measured_at ), ) } ) : (

{ running ? __( 'Testing copies of your images. Your library is not changed.', 'image-sizes' ) : __( 'Find out how much smaller your images could be. We test copies of a few of them, so nothing in your library changes.', 'image-sizes' ) }

) } { showMissed && (
) }
{ offer && ( { sprintf( /* translators: 1: discount percent, 2: coupon code, 3: date and time the offer ends. */ __( 'Checkup offer: %1$s%% off with code %2$s · ends %3$s', 'image-sizes' ), numberFormat( offer.percent ), offer.code, new Date( offer.expires * 1000 ).toLocaleString( window.THUMBPRESS?.locale || undefined, { month: 'short', day: 'numeric', hour: 'numeric', minute: '2-digit' } ), ) } ) } { result ? ( { compressionCheckCtaLabel() } ) : ( ) } { __( 'Try Pro risk-free for 30 days', 'image-sizes' ) } { result && ( canSeeSamples ? ( ) : ( ) ) }
); }