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,
|
|
|
|
|
Loader2,
|
2026-11-06 10:53:55 +05:30
|
|
|
Image as ImageIcon,
|
2026-11-03 12:59:38 +05:30
|
|
|
} from 'lucide-react';
|
2026-11-03 12:24:43 +05:30
|
|
|
import { ToolItem, AppItem, VariantSpec, resolveLocalised } from '@/types';
|
2026-11-04 11:43:31 +05:30
|
|
|
import { CardBeforeAfterSlider } from '../ui/CardBeforeAfterSlider';
|
2026-11-13 17:48:49 +05:30
|
|
|
import { TurnstileWidget } from '@/components/turnstile/TurnstileWidget';
|
2026-11-03 12:24:43 +05:30
|
|
|
|
|
|
|
|
interface TryItWidgetProps {
|
|
|
|
|
tool: ToolItem;
|
|
|
|
|
homeApp?: AppItem | null;
|
|
|
|
|
variants?: VariantSpec[];
|
|
|
|
|
locale?: string;
|
|
|
|
|
className?: string;
|
2026-11-04 15:36:30 +05:30
|
|
|
samplePresets?: Array<{ label: string; url: string; resultUrl?: string }>;
|
|
|
|
|
ctaText?: string;
|
2026-11-05 10:26:19 +05:30
|
|
|
onSwitchToCompare?: () => void;
|
2026-11-03 12:24:43 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export function TryItWidget({
|
|
|
|
|
tool,
|
|
|
|
|
homeApp,
|
|
|
|
|
variants = [],
|
|
|
|
|
locale = 'en',
|
|
|
|
|
className = '',
|
2026-11-04 15:36:30 +05:30
|
|
|
samplePresets,
|
|
|
|
|
ctaText,
|
2026-11-03 12:24:43 +05:30
|
|
|
}: 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-13 17:48:49 +05:30
|
|
|
const [turnstileToken, setTurnstileToken] = useState<string>('');
|
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);
|
|
|
|
|
|
2026-11-04 15:36:30 +05:30
|
|
|
const activePresets = samplePresets && samplePresets.length > 0
|
|
|
|
|
? samplePresets
|
|
|
|
|
: [
|
|
|
|
|
{
|
2026-11-06 10:53:55 +05:30
|
|
|
label: 'Sample portrait',
|
|
|
|
|
url: (tool as any).media?.before || '/management/pages/home/sections/our-tools/blemish-remover/before.jpg',
|
|
|
|
|
resultUrl: (tool as any).media?.after || '/management/pages/home/sections/our-tools/blemish-remover/after.jpg',
|
2026-11-04 15:36:30 +05:30
|
|
|
},
|
|
|
|
|
];
|
2026-11-03 12:24:43 +05:30
|
|
|
|
|
|
|
|
const handleFileChange = (file: File) => {
|
2026-11-06 10:53:55 +05:30
|
|
|
const validTypes = ['image/jpeg', 'image/png', 'image/webp'];
|
|
|
|
|
if (!validTypes.includes(file.type)) {
|
2026-11-03 18:30:13 +05:30
|
|
|
setStatus('error');
|
2026-11-06 10:53:55 +05:30
|
|
|
setErrorMessage('Please upload a valid JPG, PNG, or WebP photo.');
|
2026-11-03 18:30:13 +05:30
|
|
|
return;
|
|
|
|
|
}
|
2026-11-06 10:53:55 +05:30
|
|
|
|
|
|
|
|
const maxBytes = (tool.tryIt?.limits?.maxMB || 12) * 1024 * 1024;
|
|
|
|
|
if (file.size > maxBytes) {
|
2026-11-03 12:24:43 +05:30
|
|
|
setStatus('error');
|
2026-11-06 10:53:55 +05:30
|
|
|
setErrorMessage(`Image exceeds max size of ${tool.tryIt?.limits?.maxMB || 12}MB.`);
|
2026-11-03 12:24:43 +05:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
setSelectedFile(file);
|
2026-11-06 10:53:55 +05:30
|
|
|
const objectUrl = URL.createObjectURL(file);
|
2026-11-03 12:24:43 +05:30
|
|
|
setPreviewUrl(objectUrl);
|
|
|
|
|
setResultUrl(null);
|
|
|
|
|
setStatus('selected');
|
|
|
|
|
setErrorMessage('');
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
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]);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
const loadSamplePreset = async (presetUrl: string, sampleResult?: string) => {
|
|
|
|
|
try {
|
|
|
|
|
setStatus('selected');
|
|
|
|
|
setPreviewUrl(presetUrl);
|
|
|
|
|
if (sampleResult) {
|
|
|
|
|
setResultUrl(sampleResult);
|
|
|
|
|
}
|
|
|
|
|
const res = await fetch(presetUrl);
|
|
|
|
|
const blob = await res.blob();
|
|
|
|
|
const file = new File([blob], 'sample_photo.jpg', { type: 'image/jpeg' });
|
|
|
|
|
setSelectedFile(file);
|
|
|
|
|
setErrorMessage('');
|
|
|
|
|
} catch {
|
|
|
|
|
setStatus('error');
|
|
|
|
|
setErrorMessage('Failed to load sample image.');
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2026-11-03 12:24:43 +05:30
|
|
|
const runTryIt = async () => {
|
2026-11-06 10:53:55 +05:30
|
|
|
if (!selectedFile && !previewUrl) return;
|
2026-11-03 12:24:43 +05:30
|
|
|
|
|
|
|
|
setStatus('processing');
|
|
|
|
|
setErrorMessage('');
|
|
|
|
|
|
|
|
|
|
try {
|
2026-11-06 10:53:55 +05:30
|
|
|
const formData = new FormData();
|
|
|
|
|
if (selectedFile) {
|
|
|
|
|
formData.append('image', selectedFile);
|
|
|
|
|
} else if (previewUrl) {
|
|
|
|
|
const res = await fetch(previewUrl);
|
|
|
|
|
const blob = await res.blob();
|
|
|
|
|
formData.append('image', blob, 'preset.jpg');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (activeVariant) {
|
|
|
|
|
formData.append('variant', activeVariant);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-13 17:48:49 +05:30
|
|
|
if (turnstileToken) {
|
|
|
|
|
formData.append('cf-turnstile-response', turnstileToken);
|
|
|
|
|
}
|
|
|
|
|
|
2026-11-03 12:24:43 +05:30
|
|
|
const response = await fetch(`/api/try/${tool.id}`, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: formData,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (response.status === 429) {
|
|
|
|
|
setStatus('limit');
|
2026-11-06 10:53:55 +05:30
|
|
|
setRemainingTries(0);
|
2026-11-03 12:24:43 +05:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (response.status === 503) {
|
|
|
|
|
setStatus('unavailable');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!response.ok) {
|
2026-11-06 10:53:55 +05:30
|
|
|
const errData = await response.json().catch(() => ({}));
|
2026-11-03 12:24:43 +05:30
|
|
|
setStatus('error');
|
2026-11-06 10:53:55 +05:30
|
|
|
setErrorMessage(errData?.error?.message || 'Inference call failed. Please try another image.');
|
2026-11-03 12:24:43 +05:30
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const blob = await response.blob();
|
2026-11-06 10:53:55 +05:30
|
|
|
const url = URL.createObjectURL(blob);
|
|
|
|
|
setResultUrl(url);
|
2026-11-03 12:24:43 +05:30
|
|
|
setStatus('success');
|
2026-11-06 10:53:55 +05:30
|
|
|
setRemainingTries((prev) => Math.max(0, prev - 1));
|
|
|
|
|
} catch {
|
2026-11-03 12:24:43 +05:30
|
|
|
setStatus('error');
|
2026-11-06 10:53:55 +05:30
|
|
|
setErrorMessage('Network error connecting to inference API.');
|
2026-11-03 12:24:43 +05:30
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const reset = () => {
|
|
|
|
|
setSelectedFile(null);
|
|
|
|
|
setPreviewUrl(null);
|
|
|
|
|
setResultUrl(null);
|
|
|
|
|
setStatus('idle');
|
|
|
|
|
setErrorMessage('');
|
2026-11-06 10:53:55 +05:30
|
|
|
if (fileInputRef.current) fileInputRef.current.value = '';
|
2026-11-03 12:24:43 +05:30
|
|
|
};
|
|
|
|
|
|
|
|
|
|
return (
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className={`w-full ${className}`}>
|
|
|
|
|
{/* Top Header Row */}
|
|
|
|
|
<div className="flex items-center justify-between pb-3 border-b border-rule text-xs font-body">
|
|
|
|
|
<div className="flex items-center gap-2">
|
|
|
|
|
<span className="font-medium text-ink">{resolveLocalised(tool.name, locale)}</span>
|
|
|
|
|
<span className="text-muted">· Web trial</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="text-muted">
|
|
|
|
|
<span>{remainingTries} free tries remaining today</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
{/* Error Message */}
|
|
|
|
|
{errorMessage && (
|
|
|
|
|
<div className="mt-4 p-3 bg-paper-2 border border-rule rounded-card flex items-center gap-2 text-xs text-ink font-body">
|
|
|
|
|
<AlertCircle className="w-4 h-4 text-accent shrink-0" aria-hidden="true" />
|
|
|
|
|
<span>{errorMessage}</span>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{/* Main Body */}
|
|
|
|
|
<div className="mt-5">
|
2026-11-03 12:24:43 +05:30
|
|
|
{status === 'idle' && (
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="space-y-4">
|
|
|
|
|
{/* Drag & Drop Upload Zone */}
|
2026-11-04 11:47:43 +05:30
|
|
|
<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="Upload photo to edit"
|
2026-11-06 10:53:55 +05:30
|
|
|
className={`border border-dashed rounded-card p-8 sm:p-12 text-center cursor-pointer transition-colors duration-150 min-h-[300px] flex flex-col items-center justify-center ${
|
2026-11-04 11:47:43 +05:30
|
|
|
isDragOver
|
2026-11-06 10:53:55 +05:30
|
|
|
? 'border-accent bg-paper-2'
|
|
|
|
|
: 'border-rule hover:border-ink bg-paper-2/60'
|
2026-11-04 11:47:43 +05: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])}
|
|
|
|
|
/>
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="mb-3 text-accent">
|
|
|
|
|
<UploadCloud className="w-8 h-8" aria-hidden="true" />
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
2026-11-04 11:43:31 +05:30
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="mb-2">
|
|
|
|
|
<span className="btn-primary text-xs">
|
|
|
|
|
Choose photo to upload
|
|
|
|
|
</span>
|
2026-11-04 11:47:43 +05:30
|
|
|
</div>
|
2026-11-04 11:43:31 +05:30
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
<p className="text-sm font-body text-ink-2 mt-2">
|
|
|
|
|
or drag and drop your photo into this workspace
|
2026-11-04 11:47:43 +05:30
|
|
|
</p>
|
2026-11-06 10:53:55 +05:30
|
|
|
<p className="mt-1 text-xs text-muted font-body">
|
|
|
|
|
Supports JPG, PNG, WebP up to {tool.tryIt?.limits?.maxMB || 12}MB
|
2026-11-04 11:47:43 +05:30
|
|
|
</p>
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
{/* Quick Sample Preset */}
|
|
|
|
|
<div className="pt-1 flex items-center gap-2 text-xs font-body text-muted">
|
|
|
|
|
<span>Or test preset:</span>
|
|
|
|
|
{activePresets.map((preset, idx) => (
|
|
|
|
|
<button
|
|
|
|
|
key={idx}
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={() => loadSamplePreset(preset.url, preset.resultUrl)}
|
|
|
|
|
className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded bg-paper-2 hover:bg-paper-3 border border-rule text-ink transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<ImageIcon className="w-3.5 h-3.5 text-muted" aria-hidden="true" />
|
|
|
|
|
<span>{preset.label}</span>
|
|
|
|
|
</button>
|
|
|
|
|
))}
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{status === 'selected' && previewUrl && (
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="space-y-5">
|
|
|
|
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-5 items-start">
|
|
|
|
|
{/* Preview */}
|
|
|
|
|
<div className="relative aspect-[4/3] rounded-card overflow-hidden border border-rule bg-paper-2">
|
2026-11-03 12:24:43 +05:30
|
|
|
<img src={previewUrl} alt="Selected photo" className="w-full h-full object-cover" />
|
|
|
|
|
<button
|
2026-11-06 10:53:55 +05:30
|
|
|
type="button"
|
2026-11-03 12:24:43 +05:30
|
|
|
onClick={reset}
|
2026-11-06 10:53:55 +05:30
|
|
|
className="absolute top-2.5 right-2.5 bg-paper-hi text-ink text-xs px-2.5 py-1 rounded border border-rule hover:border-ink transition-colors font-body shadow-sm"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-06 10:53:55 +05:30
|
|
|
Change photo
|
2026-11-03 12:24:43 +05:30
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-03 12:31:06 +05:30
|
|
|
{/* Mode Selection & Run Action */}
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="space-y-4">
|
2026-11-03 12:24:43 +05:30
|
|
|
{variants.length > 0 && (
|
|
|
|
|
<div>
|
2026-11-06 10:53:55 +05:30
|
|
|
<label className="block text-xs font-body text-muted mb-2">
|
|
|
|
|
{resolveLocalised(tool.tryIt?.variantControl?.label, locale, 'Retouch mode')}
|
2026-11-03 12:24:43 +05:30
|
|
|
</label>
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="space-y-1.5">
|
2026-11-03 12:24:43 +05:30
|
|
|
{variants.map((v) => (
|
|
|
|
|
<label
|
|
|
|
|
key={v.id}
|
2026-11-06 10:53:55 +05:30
|
|
|
className={`flex items-center justify-between p-2.5 rounded-card border cursor-pointer transition-colors duration-100 ${
|
2026-11-03 12:24:43 +05:30
|
|
|
activeVariant === v.id
|
2026-11-06 10:53:55 +05:30
|
|
|
? 'border-accent bg-paper-hi text-ink'
|
|
|
|
|
: 'border-rule hover:border-ink bg-paper-2 text-ink-2'
|
2026-11-03 12:24:43 +05:30
|
|
|
}`}
|
|
|
|
|
>
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="flex items-center space-x-2.5">
|
2026-11-03 12:24:43 +05:30
|
|
|
<input
|
|
|
|
|
type="radio"
|
|
|
|
|
name="variant"
|
|
|
|
|
value={v.id}
|
|
|
|
|
checked={activeVariant === v.id}
|
|
|
|
|
onChange={() => setActiveVariant(v.id)}
|
2026-11-06 10:53:55 +05:30
|
|
|
className="accent-[var(--color-accent)] h-3.5 w-3.5"
|
2026-11-03 12:24:43 +05:30
|
|
|
/>
|
|
|
|
|
<div>
|
2026-11-06 10:53:55 +05:30
|
|
|
<p className="text-xs font-body font-medium text-ink">
|
2026-11-03 12:24:43 +05:30
|
|
|
{resolveLocalised(v.label, locale, v.description || v.id)}
|
|
|
|
|
</p>
|
|
|
|
|
{v.description && (
|
2026-11-06 10:53:55 +05:30
|
|
|
<p className="text-[11px] text-muted font-body">{v.description}</p>
|
2026-11-03 12:24:43 +05:30
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</label>
|
|
|
|
|
))}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-11-13 17:48:49 +05:30
|
|
|
<div className="py-2 flex justify-center">
|
|
|
|
|
<TurnstileWidget
|
|
|
|
|
onVerify={(tok) => setTurnstileToken(tok)}
|
|
|
|
|
onExpire={() => setTurnstileToken('')}
|
|
|
|
|
theme="auto"
|
|
|
|
|
size="flexible"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-03 12:24:43 +05:30
|
|
|
<button
|
2026-11-06 10:53:55 +05:30
|
|
|
type="button"
|
2026-11-03 12:24:43 +05:30
|
|
|
onClick={runTryIt}
|
2026-11-06 10:53:55 +05:30
|
|
|
className="btn-primary w-full text-center"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-06 10:53:55 +05:30
|
|
|
<span>{ctaText || `Process ${resolveLocalised(tool.name, locale)}`}</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{status === 'processing' && (
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="py-14 text-center space-y-4">
|
|
|
|
|
<div className="inline-flex p-4 rounded-card bg-paper-2 border border-rule text-accent">
|
|
|
|
|
<Loader2 className="w-8 h-8 animate-spin text-accent" aria-hidden="true" />
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
<div>
|
2026-11-06 10:53:55 +05:30
|
|
|
<h4 className="text-base font-body font-semibold text-ink">
|
|
|
|
|
Processing neural layers…
|
2026-11-03 12:24:43 +05:30
|
|
|
</h4>
|
2026-11-06 10:53:55 +05:30
|
|
|
<p className="text-xs text-muted max-w-sm mx-auto mt-1 font-body">
|
|
|
|
|
Synthesizing sub-pixel output in volatile GPU memory while preserving skin pores and edges.
|
2026-11-03 12:24:43 +05:30
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
|
|
{status === 'success' && previewUrl && resultUrl && (
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="space-y-5">
|
|
|
|
|
<div className="aspect-[4/3] rounded-card overflow-hidden bg-paper-2 border border-rule">
|
|
|
|
|
<CardBeforeAfterSlider
|
|
|
|
|
beforeUrl={previewUrl}
|
|
|
|
|
afterUrl={resultUrl}
|
|
|
|
|
beforeLabel="Original"
|
|
|
|
|
afterLabel="Enhanced"
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
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
|
2026-11-06 10:53:55 +05:30
|
|
|
type="button"
|
2026-11-03 12:24:43 +05:30
|
|
|
onClick={reset}
|
2026-11-06 10:53:55 +05:30
|
|
|
className="btn-secondary"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-06 10:53:55 +05:30
|
|
|
<RefreshCw className="w-3.5 h-3.5" aria-hidden="true" />
|
|
|
|
|
<span>Process another photo</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
<a
|
|
|
|
|
href={resultUrl}
|
|
|
|
|
download={`${tool.slug}-result.png`}
|
2026-11-06 10:53:55 +05:30
|
|
|
className="btn-primary"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-06 10:53:55 +05:30
|
|
|
<Download className="w-3.5 h-3.5" aria-hidden="true" />
|
|
|
|
|
<span>Download output</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
{/* Mobile App Handoff */}
|
2026-11-03 12:24:43 +05:30
|
|
|
{homeApp && (
|
2026-11-06 10:53:55 +05:30
|
|
|
<div className="mt-4 p-4 rounded-card bg-paper-2 border border-rule flex flex-col sm:flex-row items-start sm:items-center justify-between gap-3">
|
|
|
|
|
<div className="space-y-0.5">
|
|
|
|
|
<span className="text-xs font-body font-semibold text-ink">
|
|
|
|
|
Need batch processing or 4K lossless export?
|
|
|
|
|
</span>
|
|
|
|
|
<p className="text-xs text-muted font-body">
|
|
|
|
|
Download {resolveLocalised(homeApp.name, locale)} on your phone for unlimited processing.
|
2026-11-03 12:24:43 +05:30
|
|
|
</p>
|
|
|
|
|
</div>
|
|
|
|
|
<Link
|
2026-11-06 10:53:55 +05:30
|
|
|
href={`/apps/${homeApp.slug}`}
|
|
|
|
|
className="btn-secondary shrink-0 text-xs"
|
2026-11-03 12:24:43 +05:30
|
|
|
>
|
2026-11-06 10:53:55 +05:30
|
|
|
<Smartphone className="w-3.5 h-3.5 text-accent" aria-hidden="true" />
|
|
|
|
|
<span>Get mobile app</span>
|
2026-11-03 12:24:43 +05:30
|
|
|
</Link>
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-11-06 10:53:55 +05:30
|
|
|
{status === 'limit' && (
|
|
|
|
|
<div className="p-8 text-center space-y-4 bg-paper-2 border border-rule rounded-card">
|
|
|
|
|
<h4 className="text-base font-body font-semibold text-ink">
|
|
|
|
|
Daily browser limit reached
|
|
|
|
|
</h4>
|
|
|
|
|
<p className="text-xs text-muted max-w-sm mx-auto font-body">
|
|
|
|
|
You have completed all free browser sessions for today. Download our mobile app for unlimited inferences.
|
|
|
|
|
</p>
|
|
|
|
|
{homeApp && (
|
|
|
|
|
<Link href={`/apps/${homeApp.slug}`} className="btn-primary inline-flex">
|
|
|
|
|
<span>Open {resolveLocalised(homeApp.name, locale)}</span>
|
|
|
|
|
</Link>
|
|
|
|
|
)}
|
2026-11-03 12:24:43 +05:30
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|