2026-11-03 12:24:43 +05:30
|
|
|
'use client';
|
|
|
|
|
|
2026-11-03 12:59:38 +05:30
|
|
|
import React, { useState, useRef } from 'react';
|
2026-11-03 12:24:43 +05:30
|
|
|
import Link from 'next/link';
|
2026-11-03 12:59:38 +05:30
|
|
|
import {
|
|
|
|
|
UploadCloud,
|
|
|
|
|
AlertCircle,
|
|
|
|
|
RefreshCw,
|
|
|
|
|
Download,
|
|
|
|
|
Smartphone,
|
|
|
|
|
Sparkles,
|
|
|
|
|
Loader2,
|
|
|
|
|
Image as ImageIcon,
|
|
|
|
|
Zap,
|
|
|
|
|
ChevronRight,
|
|
|
|
|
} from 'lucide-react';
|
2026-11-03 12:24:43 +05:30
|
|
|
import { ToolItem, AppItem, VariantSpec, resolveLocalised } from '@/types';
|
|
|
|
|
import { BeforeAfterSlider } from '../ui/BeforeAfterSlider';
|
2026-11-04 11:43:31 +05:30
|
|
|
import { CardBeforeAfterSlider } from '../ui/CardBeforeAfterSlider';
|
2026-11-03 12:24:43 +05:30
|
|
|
|
|
|
|
|
interface TryItWidgetProps {
|
|
|
|
|
tool: ToolItem;
|
|
|
|
|
homeApp?: AppItem | null;
|
|
|
|
|
variants?: VariantSpec[];
|
|
|
|
|
locale?: string;
|
|
|
|
|
className?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function TryItWidget({
|
|
|
|
|
tool,
|
|
|
|
|
homeApp,
|
|
|
|
|
variants = [],
|
|
|
|
|
locale = 'en',
|
|
|
|
|
className = '',
|
|
|
|
|
}: TryItWidgetProps) {
|
|
|
|
|
const [selectedFile, setSelectedFile] = useState<File | null>(null);
|
|
|
|
|
const [previewUrl, setPreviewUrl] = useState<string | null>(null);
|
|
|
|
|
const [resultUrl, setResultUrl] = useState<string | null>(null);
|
|
|
|
|
const [activeVariant, setActiveVariant] = useState<string>(
|
|
|
|
|
tool.tryIt?.endpointRef?.defaultVariant || (variants.length > 0 ? variants[0].id : '')
|
|
|
|
|
);
|
|
|
|
|
const [status, setStatus] = useState<'idle' | 'selected' | 'processing' | 'success' | 'limit' | 'error' | 'unavailable'>('idle');
|
|
|
|
|
const [errorMessage, setErrorMessage] = useState<string>('');
|
|
|
|
|
const [remainingTries, setRemainingTries] = useState<number>(tool.tryIt?.limits?.perDay || 5);
|
2026-11-03 12:31:06 +05:30
|
|
|
const [isDragOver, setIsDragOver] = useState<boolean>(false);
|
2026-11-03 12:24:43 +05:30
|
|
|
const fileInputRef = useRef<HTMLInputElement>(null);
|
|
|
|
|
|
|
|
|
|
const samplePresets = [
|
|
|
|
|
{
|
2026-11-03 12:59:38 +05:30
|
|
|
label: 'Portrait Retouch',
|
2026-11-03 12:24:43 +05:30
|
|
|
url: 'https://images.unsplash.com/photo-1534528741775-53994a69daeb?w=600&auto=format&fit=crop&q=80',
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-11-03 12:59:38 +05:30
|
|
|
label: 'Natural Studio Model',
|
2026-11-03 12:24:43 +05:30
|
|
|
url: 'https://images.unsplash.com/photo-1544005313-94ddf0286df2?w=600&auto=format&fit=crop&q=80',
|
|
|
|
|
},
|
2026-11-03 12:59:38 +05:30
|
|
|
{
|
|
|
|
|
label: 'Vintage Archival Shot',
|
|
|
|
|
url: 'https://images.unsplash.com/photo-1507003211169-0a1dd7228f2d?w=600&auto=format&fit=crop&q=80',
|
|
|
|
|
},
|
2026-11-03 12:24:43 +05:30
|
|
|
];
|
|
|
|
|
|
|
|
|
|
const handleFileChange = (file: File) => {
|
|
|
|
|
const maxMB = tool.tryIt?.limits?.maxMB || 12;
|
2026-11-03 18:30:13 +05:30
|
|
|
const acceptedTypes = ['image/jpeg', 'image/png', 'image/webp'];
|
|
|
|
|
if (!acceptedTypes.includes(file.type)) {
|
|
|
|
|
setStatus('error');
|
|
|
|
|
setErrorMessage('Choose a JPG, PNG, or WebP image.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
2026-11-03 12:24:43 +05:30
|
|
|
if (file.size > maxMB * 1024 * 1024) {
|
|
|
|
|
setStatus('error');
|
|
|
|
|
setErrorMessage(`File exceeds ${maxMB}MB limit.`);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const objectUrl = URL.createObjectURL(file);
|
|
|
|
|
setSelectedFile(file);
|
|
|
|
|
setPreviewUrl(objectUrl);
|
|
|
|
|
setResultUrl(null);
|
|
|
|
|
setStatus('selected');
|
|
|
|
|
setErrorMessage('');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const loadSamplePreset = async (url: string) => {
|
|
|
|
|
try {
|
|
|
|
|
setStatus('processing');
|
|
|
|
|
const res = await fetch(url);
|
|
|
|
|
const blob = await res.blob();
|
|
|
|
|
const file = new File([blob], 'sample.jpg', { type: 'image/jpeg' });
|
|
|
|
|
handleFileChange(file);
|
|
|
|
|
} catch {
|
|
|
|
|
setStatus('idle');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const handleDrop = (e: React.DragEvent) => {
|
|
|
|
|
e.preventDefault();
|
2026-11-03 12:31:06 +05:30
|
|
|
setIsDragOver(false);
|
2026-11-03 12:24:43 +05:30
|
|
|
if (e.dataTransfer.files && e.dataTransfer.files[0]) {
|
|
|
|
|
handleFileChange(e.dataTransfer.files[0]);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const runTryIt = async () => {
|
|
|
|
|
if (!selectedFile) return;
|
|
|
|
|
|
|
|
|
|
setStatus('processing');
|
|
|
|
|
setErrorMessage('');
|
|
|
|
|
|
|
|
|
|
const formData = new FormData();
|
|
|
|
|
formData.append('image', selectedFile);
|
|
|
|
|
if (activeVariant) {
|
|
|
|
|
formData.append('variant', activeVariant);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
const response = await fetch(`/api/try/${tool.id}`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: formData,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const remainingHeader = response.headers.get('X-Remaining-Tries');
|
|
|
|
|
if (remainingHeader) {
|
|
|
|
|
setRemainingTries(parseInt(remainingHeader, 10));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (response.status === 429) {
|
|
|
|
|
const data = await response.json();
|
|
|
|
|
setStatus('limit');
|
|
|
|
|
setErrorMessage(data.messageKey === 'dailyBudgetExceeded'
|
|
|
|
|
? "Today's free try budget has been reached. Open in mobile app for unlimited instant access."
|
|
|
|
|
: "You have reached your daily free try limit on web. Open the app for 50 bonus credits!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (response.status === 503) {
|
|
|
|
|
setStatus('unavailable');
|
|
|
|
|
setErrorMessage('This AI tool is temporarily undergoing server maintenance. Please try in the mobile app.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
|
|
|
|
const errorJson = await response.json().catch(() => null);
|
|
|
|
|
setStatus('error');
|
|
|
|
|
setErrorMessage(errorJson?.error?.message || 'Processing failed. Please try again.');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const blob = await response.blob();
|
|
|
|
|
const resBlobUrl = URL.createObjectURL(blob);
|
|
|
|
|
setResultUrl(resBlobUrl);
|
|
|
|
|
setStatus('success');
|
|
|
|
|
} catch (err: any) {
|
|
|
|
|
setStatus('error');
|
|
|
|
|
setErrorMessage(err.message || 'Network connection failed. Please retry.');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const reset = () => {
|
|
|
|
|
setSelectedFile(null);
|
|
|
|
|
if (previewUrl) URL.revokeObjectURL(previewUrl);
|
|
|
|
|
if (resultUrl) URL.revokeObjectURL(resultUrl);
|
|
|
|
|
setPreviewUrl(null);
|
|
|
|
|
setResultUrl(null);
|
|
|
|
|
setStatus('idle');
|
|
|
|
|
setErrorMessage('');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2026-11-03 14:56:58 +05:30
|
|
|
<div className={`relative bg-white rounded-3xl p-5 sm:p-8 lg:p-10 border border-slate-900/[0.08] shadow-cream-md overflow-hidden ${className}`}>
|
2026-11-03 12:24:43 +05:30
|
|
|
{/* Top Header & Tries Counter */}
|
2026-11-03 14:56:58 +05:30
|
|
|
<div className="flex flex-col sm:flex-row sm:items-center justify-between gap-4 pb-5 sm:pb-6 border-b border-slate-100">
|
|
|
|
|
<div className="flex items-center gap-3 sm:gap-4 min-w-0">
|
|
|
|
|
<div className="w-10 h-10 sm:w-11 sm:h-11 rounded-2xl bg-gradient-to-tr from-blue-600 via-indigo-600 to-blue-700 flex items-center justify-center text-white shadow-md shadow-blue-500/20 shrink-0">
|
2026-11-03 13:16:16 +05:30
|
|
|
<Zap className="w-5 h-5" />
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
2026-11-03 14:56:58 +05:30
|
|
|
<div className="min-w-0">
|
|
|
|
|
<div className="flex flex-wrap items-center gap-2 sm:gap-2.5">
|
|
|
|
|
<h3 className="font-display font-bold text-slate-900 text-base sm:text-lg tracking-tight">
|
|
|
|
|
{resolveLocalised(tool.name, locale)}
|
|
|
|
|
</h3>
|
|
|
|
|
<div className="inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-[11px] font-mono font-semibold text-blue-700 bg-gradient-to-r from-blue-50 via-indigo-50/60 to-blue-50 border border-blue-200/80 shadow-2xs whitespace-nowrap">
|
|
|
|
|
<span className="relative flex h-2 w-2">
|
|
|
|
|
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"></span>
|
|
|
|
|
<span className="relative inline-flex rounded-full h-2 w-2 bg-blue-600"></span>
|
|
|
|
|
</span>
|
|
|
|
|
<span>Free Browser Trial</span>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-xs text-slate-500 mt-1 font-normal flex items-center gap-1.5 flex-wrap">
|
|
|
|
|
<span>Studio-Grade AI Enhancement</span>
|
|
|
|
|
<span className="text-slate-300 hidden sm:inline">•</span>
|
|
|
|
|
<span className="hidden sm:inline">Instant Visual Quality</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-03 14:56:58 +05:30
|
|
|
<div className="flex items-center justify-between sm:justify-end gap-2 shrink-0 pt-2.5 sm:pt-0 border-t sm:border-t-0 border-slate-100">
|
|
|
|
|
<div className="inline-flex items-center gap-2 bg-emerald-50 border border-emerald-200/90 px-3.5 py-1.5 rounded-full text-xs font-mono text-emerald-800 font-semibold shadow-2xs">
|
|
|
|
|
<span className="w-2 h-2 rounded-full bg-emerald-500 animate-pulse"></span>
|
|
|
|
|
<span>{remainingTries} free tries today</span>
|
|
|
|
|
</div>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Main Body per Status */}
|
2026-11-03 13:16:16 +05:30
|
|
|
<div className="mt-7">
|
2026-11-03 12:24:43 +05:30
|
|
|
{status === 'idle' && (
|
2026-11-04 11:43:31 +05:30
|
|
|
<div className="grid grid-cols-1 lg:grid-cols-[1.1fr_.9fr] gap-8 items-center">
|
|
|
|
|
{/* Left Column: Interactive Before/After Transformation Preview */}
|
|
|
|
|
<div className="space-y-3">
|
|
|
|
|
<div className="flex items-center justify-between">
|
|
|
|
|
<span className="text-xs font-mono uppercase tracking-wider text-slate-500 font-bold flex items-center gap-1.5">
|
|
|
|
|
<Sparkles className="w-3.5 h-3.5 text-blue-600" /> Real AI Transformation Output
|
|
|
|
|
</span>
|
|
|
|
|
<span className="text-[10px] font-mono font-semibold text-blue-700 bg-blue-50 px-2 py-0.5 rounded-full border border-blue-200">
|
|
|
|
|
Auto-sliding & scrubber
|
|
|
|
|
</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
2026-11-04 11:43:31 +05:30
|
|
|
|
|
|
|
|
{tool.content?.examples?.[0]?.before && tool.content?.examples?.[0]?.after ? (
|
|
|
|
|
<div className="rounded-2xl overflow-hidden border border-slate-900/10 shadow-cream-sm">
|
|
|
|
|
<CardBeforeAfterSlider
|
|
|
|
|
beforeUrl={tool.content.examples[0].before}
|
|
|
|
|
afterUrl={tool.content.examples[0].after}
|
|
|
|
|
beforeLabel="ORIGINAL"
|
|
|
|
|
afterLabel="AI RESULT"
|
|
|
|
|
aspectRatio="aspect-[4/3] sm:aspect-[16/10]"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
) : (
|
|
|
|
|
<div className="aspect-[16/10] bg-slate-100 rounded-2xl grid place-items-center text-slate-400 text-sm">
|
|
|
|
|
Transformation preview
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{tool.content?.examples?.[0]?.caption && (
|
|
|
|
|
<p className="text-center text-xs font-medium text-slate-500 px-1">
|
|
|
|
|
{tool.content.examples[0].caption}
|
|
|
|
|
</p>
|
|
|
|
|
)}
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
|
2026-11-04 11:43:31 +05:30
|
|
|
{/* Right Column: Upload Zone & Instant Samples */}
|
|
|
|
|
<div className="space-y-5">
|
|
|
|
|
<div>
|
|
|
|
|
<h4 className="font-display font-bold text-slate-900 text-lg sm:text-xl">
|
|
|
|
|
Try with your photo
|
|
|
|
|
</h4>
|
|
|
|
|
<p className="text-xs text-slate-500 mt-1">
|
|
|
|
|
Test {resolveLocalised(tool.name, locale)} in your browser with zero setup or sign-in.
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Drag & Drop Upload Zone */}
|
|
|
|
|
<div
|
|
|
|
|
onDrop={handleDrop}
|
|
|
|
|
onDragOver={(e) => {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
setIsDragOver(true);
|
|
|
|
|
}}
|
|
|
|
|
onDragLeave={() => setIsDragOver(false)}
|
|
|
|
|
onClick={() => fileInputRef.current?.click()}
|
|
|
|
|
onKeyDown={(e) => {
|
|
|
|
|
if (e.key === 'Enter' || e.key === ' ') {
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
fileInputRef.current?.click();
|
|
|
|
|
}
|
|
|
|
|
}}
|
|
|
|
|
role="button"
|
|
|
|
|
tabIndex={0}
|
|
|
|
|
aria-label="Choose a JPG, PNG, or WebP photo to edit"
|
|
|
|
|
className={`border-2 border-dashed rounded-2xl p-6 sm:p-8 text-center cursor-pointer transition-all duration-300 group ${
|
|
|
|
|
isDragOver
|
|
|
|
|
? 'border-blue-500 bg-blue-50/50 scale-[1.01]'
|
|
|
|
|
: 'border-slate-300 hover:border-blue-500 bg-slate-50/60 hover:bg-blue-50/30'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
<input
|
|
|
|
|
ref={fileInputRef}
|
|
|
|
|
type="file"
|
|
|
|
|
accept="image/jpeg,image/png,image/webp"
|
|
|
|
|
className="hidden"
|
|
|
|
|
onChange={(e) => e.target.files?.[0] && handleFileChange(e.target.files[0])}
|
|
|
|
|
/>
|
|
|
|
|
<div className="w-12 h-12 mx-auto mb-3 rounded-2xl bg-blue-50 border border-blue-100 flex items-center justify-center text-blue-600 group-hover:scale-110 transition-all duration-300 shadow-sm">
|
|
|
|
|
<UploadCloud className="w-6 h-6" />
|
|
|
|
|
</div>
|
|
|
|
|
<p className="text-sm sm:text-base font-display font-bold text-slate-900">
|
|
|
|
|
Drop your photo here, or <span className="text-blue-600 underline decoration-blue-300 underline-offset-4 group-hover:text-blue-700">browse</span>
|
|
|
|
|
</p>
|
|
|
|
|
<p className="mt-1 text-[11px] font-mono text-slate-500">
|
|
|
|
|
JPG, PNG, WebP up to {tool.tryIt?.limits?.maxMB || 12}MB
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
{/* Quick Sample Presets */}
|
|
|
|
|
<div>
|
|
|
|
|
<p className="text-xs font-mono uppercase tracking-wider text-slate-500 font-semibold mb-2.5">
|
|
|
|
|
Or test instantly with a sample photo:
|
|
|
|
|
</p>
|
|
|
|
|
<div className="flex flex-wrap gap-2">
|
|
|
|
|
{samplePresets.map((preset, idx) => (
|
|
|
|
|
<button
|
|
|
|
|
key={idx}
|
|
|
|
|
onClick={() => loadSamplePreset(preset.url)}
|
|
|
|
|
className="inline-flex items-center gap-1.5 px-3 py-2 rounded-xl text-xs font-semibold bg-white border border-slate-200 text-slate-700 hover:bg-blue-50 hover:border-blue-300 hover:text-blue-700 transition-all active:scale-95 shadow-2xs"
|
|
|
|
|
>
|
|
|
|
|
<ImageIcon className="w-3.5 h-3.5 text-slate-400" />
|
|
|
|
|
<span>{preset.label}</span>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{status === 'selected' && previewUrl && (
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6 items-center">
|
2026-11-03 12:31:06 +05:30
|
|
|
{/* Image Preview Card */}
|
2026-11-03 13:16:16 +05:30
|
|
|
<div className="relative aspect-[4/3] rounded-3xl overflow-hidden border border-slate-200 bg-slate-100 shadow-sm">
|
2026-11-03 12:24:43 +05:30
|
|
|
{/* eslint-disable-next-line @next/next/no-img-element */}
|
|
|
|
|
<img src={previewUrl} alt="Selected photo" className="w-full h-full object-cover" />
|
|
|
|
|
<button
|
|
|
|
|
onClick={reset}
|
2026-11-03 13:16:16 +05:30
|
|
|
className="absolute top-3 right-3 bg-slate-900/80 hover:bg-slate-900 text-white text-xs font-mono px-3 py-1.5 rounded-xl backdrop-blur-md transition-colors"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
|
|
|
|
Change Photo
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-03 12:31:06 +05:30
|
|
|
{/* Mode Selection & Run Action */}
|
2026-11-03 12:59:38 +05:30
|
|
|
<div className="space-y-5">
|
2026-11-03 12:24:43 +05:30
|
|
|
{variants.length > 0 && (
|
|
|
|
|
<div>
|
2026-11-03 13:16:16 +05:30
|
|
|
<label className="block text-xs font-mono uppercase tracking-wider text-slate-600 font-semibold mb-2.5">
|
2026-11-03 12:31:06 +05:30
|
|
|
{resolveLocalised(tool.tryIt?.variantControl?.label, locale, 'Select Retouch Mode')}
|
2026-11-03 12:24:43 +05:30
|
|
|
</label>
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
{variants.map((v) => (
|
|
|
|
|
<label
|
|
|
|
|
key={v.id}
|
2026-11-03 12:31:06 +05:30
|
|
|
className={`flex items-center justify-between p-3.5 rounded-2xl border cursor-pointer transition-all duration-200 ${
|
2026-11-03 12:24:43 +05:30
|
|
|
activeVariant === v.id
|
2026-11-03 13:16:16 +05:30
|
|
|
? 'border-blue-600 bg-blue-50/70 text-blue-900 shadow-sm'
|
|
|
|
|
: 'border-slate-200 hover:border-slate-300 bg-white'
|
2026-11-03 12:24:43 +05:30
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
<div className="flex items-center space-x-3">
|
|
|
|
|
<input
|
|
|
|
|
type="radio"
|
|
|
|
|
name="variant"
|
|
|
|
|
value={v.id}
|
|
|
|
|
checked={activeVariant === v.id}
|
|
|
|
|
onChange={() => setActiveVariant(v.id)}
|
2026-11-03 13:16:16 +05:30
|
|
|
className="text-blue-600 focus:ring-blue-500 h-4 w-4"
|
2026-11-03 12:24:43 +05:30
|
|
|
/>
|
|
|
|
|
<div>
|
2026-11-03 13:16:16 +05:30
|
|
|
<p className="text-xs sm:text-sm font-bold text-slate-900">
|
2026-11-03 12:24:43 +05:30
|
|
|
{resolveLocalised(v.label, locale, v.description || v.id)}
|
|
|
|
|
</p>
|
|
|
|
|
{v.description && (
|
2026-11-03 13:16:16 +05:30
|
|
|
<p className="text-[11px] text-slate-500">{v.description}</p>
|
2026-11-03 12:24:43 +05:30
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Run Button */}
|
|
|
|
|
<button
|
|
|
|
|
onClick={runTryIt}
|
2026-11-03 13:16:16 +05:30
|
|
|
className="w-full py-4 px-6 rounded-2xl font-bold text-xs sm:text-sm text-white bg-gradient-to-r from-blue-600 to-indigo-600 hover:from-blue-700 hover:to-indigo-700 shadow-md shadow-blue-500/25 transition-all flex items-center justify-center gap-2 active:scale-98"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-03 13:16:16 +05:30
|
|
|
<Sparkles className="w-4 h-4 text-white" />
|
2026-11-03 12:24:43 +05:30
|
|
|
<span>Run {resolveLocalised(tool.name, locale)}</span>
|
|
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{status === 'processing' && (
|
2026-11-03 12:59:38 +05:30
|
|
|
<div className="py-16 sm:py-20 text-center space-y-5">
|
2026-11-03 13:16:16 +05:30
|
|
|
<div className="relative inline-flex p-5 rounded-3xl bg-blue-50 border border-blue-200 text-blue-600 shadow-sm">
|
|
|
|
|
<Loader2 className="w-10 h-10 animate-spin text-blue-600" />
|
2026-11-03 12:31:06 +05:30
|
|
|
<span className="absolute -top-1 -right-1 flex h-3 w-3">
|
2026-11-03 13:16:16 +05:30
|
|
|
<span className="animate-ping absolute inline-flex h-full w-full rounded-full bg-blue-400 opacity-75"></span>
|
|
|
|
|
<span className="relative inline-flex rounded-full h-3 w-3 bg-blue-500"></span>
|
2026-11-03 12:31:06 +05:30
|
|
|
</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
<div>
|
2026-11-03 13:16:16 +05:30
|
|
|
<h4 className="text-lg font-display font-bold text-slate-900">
|
2026-11-03 12:31:06 +05:30
|
|
|
CRE Neural Vision Engine Processing...
|
2026-11-03 12:24:43 +05:30
|
|
|
</h4>
|
2026-11-03 13:16:16 +05:30
|
|
|
<p className="text-xs sm:text-sm text-slate-500 max-w-sm mx-auto mt-1 font-mono">
|
2026-11-03 14:56:58 +05:30
|
|
|
Synthesizing deep neural layers while preserving natural textures and micro-details.
|
2026-11-03 12:24:43 +05:30
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{status === 'success' && previewUrl && resultUrl && (
|
|
|
|
|
<div className="space-y-6">
|
|
|
|
|
<BeforeAfterSlider
|
|
|
|
|
beforeUrl={previewUrl}
|
|
|
|
|
afterUrl={resultUrl}
|
|
|
|
|
beforeLabel="Original"
|
2026-11-03 12:31:06 +05:30
|
|
|
afterLabel="CRE AI Result"
|
|
|
|
|
caption="Drag slider horizontally to inspect precision AI results and natural textures."
|
2026-11-03 12:24:43 +05:30
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
{/* Actions: Download & Reset */}
|
2026-11-03 12:31:06 +05:30
|
|
|
<div className="flex flex-wrap items-center justify-between gap-3 pt-2">
|
2026-11-03 12:24:43 +05:30
|
|
|
<button
|
|
|
|
|
onClick={reset}
|
2026-11-03 13:16:16 +05:30
|
|
|
className="inline-flex items-center gap-2 px-4 py-2.5 rounded-xl text-xs sm:text-sm font-semibold border border-slate-300 bg-slate-50 hover:bg-slate-100 text-slate-700 transition-colors"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-03 13:16:16 +05:30
|
|
|
<RefreshCw className="w-4 h-4 text-slate-500" />
|
2026-11-03 12:24:43 +05:30
|
|
|
<span>Process Another Photo</span>
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<a
|
|
|
|
|
href={resultUrl}
|
|
|
|
|
download={`${tool.slug}-result.png`}
|
2026-11-03 13:16:16 +05:30
|
|
|
className="inline-flex items-center gap-2 px-6 py-2.5 rounded-xl text-xs sm:text-sm font-bold text-white bg-emerald-600 hover:bg-emerald-700 shadow-md shadow-emerald-500/20 transition-all hover:scale-105 active:scale-95"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-03 13:16:16 +05:30
|
|
|
<Download className="w-4 h-4" />
|
2026-11-03 12:31:06 +05:30
|
|
|
<span>Download Result (HD)</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-03 12:31:06 +05:30
|
|
|
{/* Result App Handoff Card */}
|
2026-11-03 12:24:43 +05:30
|
|
|
{homeApp && (
|
2026-11-03 13:16:16 +05:30
|
|
|
<div className="mt-6 p-6 rounded-3xl bg-slate-50 border border-slate-200 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-5">
|
2026-11-03 12:24:43 +05:30
|
|
|
<div className="space-y-1">
|
2026-11-03 12:59:38 +05:30
|
|
|
<div className="flex items-center gap-2">
|
2026-11-03 13:16:16 +05:30
|
|
|
<Smartphone className="w-4 h-4 text-indigo-600" />
|
|
|
|
|
<span className="text-[11px] font-mono uppercase tracking-widest text-indigo-700 font-bold">
|
2026-11-03 12:31:06 +05:30
|
|
|
Need 4K Lossless & Batch Processing?
|
2026-11-03 12:24:43 +05:30
|
|
|
</span>
|
|
|
|
|
</div>
|
2026-11-03 13:16:16 +05:30
|
|
|
<h5 className="font-display font-bold text-slate-900 text-base">
|
2026-11-03 12:59:38 +05:30
|
|
|
Open in {resolveLocalised(homeApp.name, locale)}
|
2026-11-03 12:24:43 +05:30
|
|
|
</h5>
|
2026-11-03 13:16:16 +05:30
|
|
|
<p className="text-xs text-slate-600">
|
2026-11-03 12:31:06 +05:30
|
|
|
Get 50 free HD export credits on first launch with promo code{' '}
|
2026-11-03 13:16:16 +05:30
|
|
|
<span className="font-mono font-bold text-blue-600 bg-blue-50 px-1 py-0.5 rounded border border-blue-200">{homeApp.welcomeBonus?.code || 'TRYWEB50'}</span>.
|
2026-11-03 12:24:43 +05:30
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<Link
|
|
|
|
|
href={`/go/${tool.slug}/${homeApp.slug}`}
|
2026-11-03 13:16:16 +05:30
|
|
|
className="w-full sm:w-auto shrink-0 px-6 py-3 rounded-full text-xs font-bold text-white bg-blue-600 hover:bg-blue-700 shadow-sm transition-all text-center flex items-center justify-center gap-2 hover:scale-105"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-03 12:31:06 +05:30
|
|
|
<span>Open in Mobile App</span>
|
|
|
|
|
<ChevronRight className="w-4 h-4" />
|
2026-11-03 12:24:43 +05:30
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{(status === 'limit' || status === 'error' || status === 'unavailable') && (
|
2026-11-03 13:16:16 +05:30
|
|
|
<div className="p-7 sm:p-9 rounded-3xl bg-amber-50 border border-amber-200 text-center space-y-4">
|
|
|
|
|
<div className="w-12 h-12 mx-auto rounded-2xl bg-amber-100 border border-amber-300 flex items-center justify-center text-amber-700">
|
2026-11-03 12:24:43 +05:30
|
|
|
<AlertCircle className="w-6 h-6" />
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
2026-11-03 13:16:16 +05:30
|
|
|
<h4 className="text-base font-display font-bold text-slate-900">
|
2026-11-03 12:24:43 +05:30
|
|
|
{status === 'limit'
|
|
|
|
|
? 'Daily Free Web Limit Reached'
|
|
|
|
|
: status === 'unavailable'
|
|
|
|
|
? 'Service Temporarily Offline'
|
|
|
|
|
: 'Processing Issue'}
|
|
|
|
|
</h4>
|
2026-11-03 13:16:16 +05:30
|
|
|
<p className="text-xs sm:text-sm text-slate-600 max-w-md mx-auto mt-1 font-mono">
|
2026-11-03 12:24:43 +05:30
|
|
|
{errorMessage}
|
|
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="flex flex-wrap items-center justify-center gap-3 pt-2">
|
|
|
|
|
<button
|
|
|
|
|
onClick={reset}
|
2026-11-03 13:16:16 +05:30
|
|
|
className="px-4 py-2 rounded-xl text-xs font-semibold border border-slate-300 bg-white hover:bg-slate-100 text-slate-700"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
|
|
|
|
Try Again
|
|
|
|
|
</button>
|
|
|
|
|
{homeApp && (
|
|
|
|
|
<Link
|
|
|
|
|
href={`/go/${tool.slug}/${homeApp.slug}`}
|
2026-11-03 13:16:16 +05:30
|
|
|
className="px-5 py-2 rounded-xl text-xs font-bold text-white bg-blue-600 hover:bg-blue-700 shadow-sm"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
|
|
|
|
Open in {resolveLocalised(homeApp.name, locale)}
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|