/* eslint-disable @next/next/no-img-element */ "use client"; import { useState, useMemo, useEffect } from "react"; import { motion, AnimatePresence } from "motion/react"; import { ArrowRight, ChevronLeft, ShieldCheck, CheckCircle2, Clock, FlaskConical, Stethoscope, Info, CalendarDays, X, Plus, Minus, Bell, Sparkles, ChevronDown, ChevronUp, Activity, Heart, Zap, Star, ShoppingBag, Thermometer, AlertTriangle, AlertCircle, Dog, Cat, Share2, Phone, Download, Play, Film, Headphones, Volume2 } from "lucide-react"; const ICON_MAP: Record> = { Sparkles, Activity, ShieldCheck, Heart, Zap, Star }; import { toPersian } from "../lib/utils"; import { Product } from "../lib/data/products"; import { productService } from "../lib/services/productService"; import { SCIENTIFIC_TERMS } from "../lib/data/scientificTerms"; import { useSettingsStore } from "../lib/store/settingsStore"; import { create } from "zustand"; import { useCartStore } from "../lib/store/cartStore"; import { usePetStore } from "../lib/store/usePetStore"; import { toast } from "sonner"; import api from "../lib/services/api"; import { DosageConfig } from "../lib/types"; interface CalculatorState { petType: "young" | "adult"; weight: number; setPetType: (type: "young" | "adult") => void; setWeight: (weight: number) => void; } const useCalculatorStore = create((set) => ({ petType: "young", weight: 10, setPetType: (petType) => set({ petType }), setWeight: (weight) => set({ weight }), })); import dynamic from 'next/dynamic'; import Tooltip from "./Tooltip"; import SafeImage from "./SafeImage"; import PodcastInlinePlayer from "./PodcastInlinePlayer"; const VideoModalPlayer = dynamic(() => import("./VideoModalPlayer"), { ssr: false }); const ProductReviews = dynamic(() => import("./ProductReviews"), { ssr: false }); const ProductImageZoomModal = dynamic(() => import("./ProductImageZoomModal"), { ssr: false }); import { useRouter } from 'next/navigation'; interface GalleryMediaItem { id: string; type: 'image' | 'video' | 'podcast'; url: string; thumbnail: string; title: string; badge?: string; videoData?: { title?: string; doctor?: string; description?: string; videoUrl?: string; thumbnail?: string; }; podcastData?: { audioUrl?: string; title?: string; description?: string; cover?: string; }; } function isVideoUrl(url?: string): boolean { if (!url) return false; const clean = url.toLowerCase().trim(); return ( clean.endsWith('.mp4') || clean.endsWith('.webm') || clean.endsWith('.mov') || clean.endsWith('.mkv') || clean.endsWith('.m4v') || clean.includes('aparat.com') || clean.includes('youtube.com') || clean.includes('youtu.be') || clean.includes('vimeo.com') || clean.includes('/video/') || clean.startsWith('data:video') ); } export default function ProductPage({ productSlug }: { productSlug: string }) { const router = useRouter(); const [product, setProduct] = useState(null); const [allProducts, setAllProducts] = useState([]); const [isLoading, setIsLoading] = useState(true); const [itemQuantity, setItemQuantity] = useState(1); const [showRefillModal, setShowRefillModal] = useState(false); const [isMounted, setIsMounted] = useState(false); const [dosageConfig, setDosageConfig] = useState(null); const [isFullDescriptionOpen, setIsFullDescriptionOpen] = useState(false); const [activeMediaIndex, setActiveMediaIndex] = useState(0); const [activeImage, setActiveImage] = useState(null); const [isImageZoomOpen, setIsImageZoomOpen] = useState(false); const [isVideoModalOpen, setIsVideoModalOpen] = useState(false); const [isFullVideoDescOpen, setIsFullVideoDescOpen] = useState(false); const [activeMediaForVideoModal, setActiveMediaForVideoModal] = useState<{ title?: string; doctor?: string; videoUrl?: string; thumbnail?: string; description?: string; } | null>(null); useEffect(() => { Promise.resolve().then(() => setIsMounted(true)); }, []); useEffect(() => { productService.getProductBySlug(productSlug) .then(p => { setProduct(p); if (p?.image) setActiveImage(p.image); return productService.getProducts({ limit: 50 }); }) .then(res => { if (res && res.data) setAllProducts(res.data); }) .catch(err => console.error("Error fetching products in ProductPage:", err)) .finally(() => setIsLoading(false)); }, [productSlug]); useEffect(() => { if (product && product.id) { api.get(`/products/${product.id}/dosage-config`) .then(res => { if (res.data) { setDosageConfig(res.data); } }) .catch(err => console.error('[ProductPage] Dosage config fetch error:', err)); } }, [product]); const { pets, getActivePet } = usePetStore(); const activePet = getActivePet(); const { petType, weight, setPetType, setWeight } = useCalculatorStore(); const { addItem } = useCartStore(); const getText = useSettingsStore((state) => state.getText); const isCatalogMode = getText('catalog_mode', 'false') === 'true'; const isCatalogHidePrices = getText('catalog_hide_prices', 'false') === 'true'; const isCatalogDisableCart = getText('catalog_disable_cart', 'false') === 'true'; const isCartDisabled = isCatalogMode || isCatalogDisableCart; const scientificTerms = useSettingsStore(state => state.scientificTerms); const termKeys = useMemo(() => { return Array.from(new Set([ ...Object.keys(scientificTerms), ...Object.keys(SCIENTIFIC_TERMS) ])); }, [scientificTerms]); // Re-hydrate product const fullProduct = useMemo(() => { if (!product) return null; const apiProduct = allProducts.find(p => p.id === product.id) || product; if (!apiProduct) return null; return { ...apiProduct, packageSize: apiProduct.packageSize !== undefined && apiProduct.packageSize !== null ? Number(apiProduct.packageSize) : 100, }; }, [product, allProducts]); useEffect(() => { if (activePet && activePet.weight > 0) { setWeight(activePet.weight); setPetType(activePet.age <= 1 ? "young" : "adult"); } }, [activePet, setPetType, setWeight]); // Pet compatibility calculation matching ArchivePage logic const compatibility = useMemo(() => { if (!activePet || !fullProduct) return null; const sameSpecies = fullProduct.suitableFor === activePet.type || fullProduct.suitableFor === "هر دو"; const matchedSymptom = (activePet.medicalConditions || []).find(mc => (fullProduct.symptoms || []).some(s => mc.includes(s) || s.includes(mc)) ); if (!sameSpecies) return { type: 'alert', text: `مخصوص ${fullProduct.suitableFor}` }; if (matchedSymptom) return { type: 'success', text: `توصیه شده برای ${matchedSymptom} ${activePet.name}` }; if (sameSpecies) return { type: 'neutral', text: `مناسب برای ${activePet.name}` }; return null; }, [fullProduct, activePet]); const calculation = useMemo(() => { if (!fullProduct) return null; let dailyDose = 1; let unit = fullProduct.unit?.includes('ml') ? "میلی‌لیتر" : fullProduct.unit?.includes('g') ? "گرم" : "قرص"; let description = petType === "young" ? "دوز رشد روزانه" : "دوز نگهداری روزانه"; if (dosageConfig) { const baseW = dosageConfig.baseWeightKg || 10; const baseD = dosageConfig.baseDose || 1; const ageMultiplier = petType === "young" ? (dosageConfig.youngMultiplier || 1.25) : 1; const calculated = Math.round((weight / baseW) * baseD * ageMultiplier); dailyDose = Math.max(1, calculated); if (dosageConfig.maxDailyDose && dosageConfig.maxDailyDose > 0) { dailyDose = Math.min(dailyDose, dosageConfig.maxDailyDose); } if (dosageConfig.unit) { unit = dosageConfig.unit; } if (dosageConfig.instructions) { description = dosageConfig.instructions; } } else if (typeof fullProduct.calculateDosage === 'function') { const result = fullProduct.calculateDosage(weight, petType === "young"); dailyDose = result.quantity; unit = result.unit; description = result.description; } else { const factor = petType === "young" ? 0.2 : 0.1; dailyDose = Math.max(1, Math.round(weight * factor)); } const packageSize = fullProduct.packageSize !== undefined && fullProduct.packageSize !== null ? Number(fullProduct.packageSize) : 100; const duration = Math.max(1, Math.floor((packageSize || 100) / (dailyDose || 1))); return { dailyDose, duration: duration || 0, unit, description }; }, [fullProduct, dosageConfig, petType, weight]); // Suggest quantity inside useEffect to avoid render-phase state update useEffect(() => { const duration = calculation?.duration ?? 0; const suggestedQty = (duration < 30 && duration > 0) ? 2 : 1; Promise.resolve().then(() => setItemQuantity(suggestedQty)); }, [calculation?.duration]); // Omnichannel Product Media Gallery (Featured Image + Gallery Images/Videos + Dedicated Video + Podcast) const galleryMedia = useMemo(() => { if (!product) return []; const items: GalleryMediaItem[] = []; // 1. Featured Image (Always first) if (product.image) { items.push({ id: 'featured-image', type: 'image', url: product.image, thumbnail: product.image, title: product.nameFa || product.name || 'تصویر شاخص محصول', badge: 'تصویر اصلی' }); } // 2. Additional Gallery Media from product.images in custom configured order if (product.images && Array.isArray(product.images)) { product.images.forEach((mUrl, idx) => { if (!mUrl || mUrl === product.image) return; const isVid = isVideoUrl(mUrl); if (isVid) { items.push({ id: `gallery-vid-${idx}`, type: 'video', url: mUrl, thumbnail: product.videoCover || product.image, title: `ویدیو معرفی ${idx + 1}`, badge: 'ویدیو', videoData: { title: `ویدیو محصول ${product.nameFa || product.name}`, doctor: 'کادر علمی و تخصصی کنینا', videoUrl: mUrl, thumbnail: product.videoCover || product.image, description: product.videoDescription || product.description, } }); } else { items.push({ id: `gallery-img-${idx}`, type: 'image', url: mUrl, thumbnail: mUrl, title: `تصویر گالری ${idx + 1}`, badge: 'تصویر' }); } }); } // 3. Dedicated Video (product.videoUrl) if present and not duplicated if (product.videoUrl && !items.some(it => it.url === product.videoUrl)) { items.push({ id: 'dedicated-video', type: 'video', url: product.videoUrl, thumbnail: product.videoCover || product.image, title: product.videoTitle || 'ویدیو راهنمای مصرف و معرفی', badge: 'ویدیوکست', videoData: { title: product.videoTitle || `ویدیو راهنمای ${product.nameFa || product.name}`, doctor: 'کادر علمی و تخصصی کنینا', videoUrl: product.videoUrl, thumbnail: product.videoCover || product.image, description: product.videoDescription || product.description, } }); } // 4. Dedicated Podcast (product.podcastUrl) if present and not duplicated if (product.podcastUrl && !items.some(it => it.url === product.podcastUrl)) { items.push({ id: 'dedicated-podcast', type: 'podcast', url: product.podcastUrl, thumbnail: product.podcastCover || product.image, title: product.podcastTitle || 'پادکست و بررسی صوتی بالینی', badge: 'پادکست', podcastData: { audioUrl: product.podcastUrl, title: product.podcastTitle || 'پادکست و بررسی صوتی بالینی مکمل', description: product.podcastDescription || product.description, cover: product.podcastCover || product.image, } }); } return items; }, [product]); const activeMedia = galleryMedia[activeMediaIndex] || galleryMedia[0]; if (isLoading) return (
); if (!product || !fullProduct || !calculation) return
محصول یافت نشد
; const isOutOfStock = (product.packageSize !== undefined && product.packageSize !== null ? Number(product.packageSize) : 100) <= 0; return (
{/* Standard Breadcrumb Navigation & Integrated Back Button */}
router.push('/')}>خانه router.push('/shop')}>فروشگاه {product.nameFa || product.name}
{/* Global Single Grid Layout - Aligns Sticky Buy Box at the Top */}
{/* Right/Main Content Column (lg:col-span-8) */}
{/* Above the Fold Grid */}
{/* Right Column: Omnichannel Product Media Hub & Gallery (md:col-span-5) */}
{/* Top Floating Badges */}
{product.specialBadge && (
{product.specialBadge}
)} {isOutOfStock ? (
ناموجود در انبار
) : (
موجود در انبار
)}
گرید دارویی اختصاصی
{/* Species Suitable Badges (Dog / Cat) */}
{(product.suitableFor === "سگ" || product.suitableFor === "هر دو") && (
)} {(product.suitableFor === "گربه" || product.suitableFor === "هر دو") && (
)}
{/* 1. Image Viewer */} {(!activeMedia || activeMedia.type === 'image') && (
setIsImageZoomOpen(true)} className="w-full h-full flex items-center justify-center cursor-zoom-in relative" title="کلیک برای مشاهده تصویر بزرگتر" >
بزرگ‌نمایی
)} {/* 2. Video Player Frame */} {activeMedia?.type === 'video' && (
{ setActiveMediaForVideoModal(activeMedia.videoData || { title: activeMedia.title || product.name, videoUrl: activeMedia.url, thumbnail: activeMedia.thumbnail, description: product.description, }); setIsVideoModalOpen(true); }} className="w-full h-full relative cursor-pointer overflow-hidden rounded-2xl bg-neutral-950 flex items-center justify-center group/vid" title="برای پخش ویدیو کلیک کنید" >
پخش ویدیو معرفی محصول

{activeMedia.title || product.nameFa || product.name}

)} {/* 3. Podcast Player Frame */} {activeMedia?.type === 'podcast' && (
{ const el = document.getElementById('podcast-player-section'); if (el) { el.scrollIntoView({ behavior: 'smooth' }); } }} className="w-full h-full relative cursor-pointer overflow-hidden rounded-2xl bg-gradient-to-br from-purple-950 via-slate-900 to-indigo-950 flex flex-col items-center justify-center p-6 text-white text-center group/pod" title="مشاهده و پخش پادکست بالینی" >
{/* Animated Audio Bars */}
پادکست و بررسی صوتی بالینی

{activeMedia.title || "بررسی تخصصی اثر مکمل توسط تیم علمی"}

)}
{/* Multiple Gallery Media Thumbnails Strip */} {galleryMedia.length > 1 && (
{galleryMedia.map((item, idx) => { const isSelected = activeMediaIndex === idx; return ( ); })}
)}
{/* Left Column: Product Title & Description (md:col-span-7) */}
استاندارد صنعتی آلمان
کاتالوگ رسمی Canina
{product.specialBadge && (
{product.specialBadge}
)} {compatibility && (
{compatibility.type === 'alert' ? : compatibility.type === 'success' ? : } {compatibility.text}
)}

{product.nameFa || product.name}

{product.nameEn && (

{product.nameEn}

)}

{isMounted && pets.length > 0 ? ( product.optimisticTemplate?.replace("[PetName]", activePet?.name || "").replace("[OnSet]", product.onSetOfAction || "به زودی") ) : ( product.scientificTagline )}

{fullProduct.shortDescription && (

{fullProduct.shortDescription}

)}
{/* ─── Symptoms / Therapeutic Indications Section ─── */} {fullProduct.symptoms && fullProduct.symptoms.length > 0 && (

علائم و موارد درمانی مرتبط

این محصول برای رفع علائم زیر توسط دامپزشکان توصیه می‌شود:

{fullProduct.symptoms.map((symptom: string, idx: number) => ( {symptom} ))}
)} {/* Key Benefits Section */} {fullProduct.keyBenefits && fullProduct.keyBenefits.length > 0 && (

چرا {fullProduct.name}؟

{fullProduct.keyBenefits.map((benefit, i) => { const Icon = ICON_MAP[benefit.icon] || CheckCircle2; return (

{benefit.title}

{benefit.description}

); })}
)} {/* Comprehensive Product Description Section (Below the fold) */} {fullProduct.description && (

توضیحات و معرفی محصول

{(() => { const descText = fullProduct.description.trim(); const isHtml = /<[a-z][\s\S]*>/i.test(descText); const formattedHtml = isHtml ? descText : descText.split('\n').filter(Boolean).map(p => `

${p.trim()}

`).join(''); const isLongText = descText.length > 400; return ( <>
{/* Gradient fade overlay when collapsed */} {isLongText && !isFullDescriptionOpen && (
)}
{isLongText && (
)} ); })()}
)} {/* Smart Dosage Calculator Utility Section (Only for oral/dosed products, not topical products) */} {!(fullProduct.categorySlug === 'special-care' || fullProduct.name.toLowerCase().includes('pfotenpflege') || fullProduct.name.toLowerCase().includes('augenpflege') || fullProduct.unit?.includes('ml Lotion') || fullProduct.unit?.includes('Balsam') || fullProduct.nameFa?.includes('کرم') || fullProduct.nameFa?.includes('قطره تمیزکننده') || fullProduct.nameFa?.includes('اسپری')) && (

{activePet ? `ماشین حساب هوشمند مصرف برای ${activePet.name}` : 'ماشین حساب هوشمند مصرف'}

{activePet ? `تخمین دقیق دوز روزانه و ماندگاری هر بسته بر اساس وزن و سن ${activePet.name}` : 'تخمین دقیق دوز روزانه و ماندگاری هر بسته بر اساس مشخصات پت شما'}

{/* Manual Slider Inputs */}
{activePet ? `وزن ${activePet.name} (کیلوگرم)` : 'وزن پت (کیلوگرم)'} {toPersian(weight)} ک‌گ
setWeight(parseInt(e.target.value))} className="w-full h-2 bg-medical-gray-200 rounded-lg appearance-none cursor-pointer accent-canina-blue [&::-webkit-slider-thumb]:w-6 [&::-webkit-slider-thumb]:h-6 [&::-webkit-slider-thumb]:rounded-full [&::-webkit-slider-thumb]:bg-canina-blue [&::-webkit-slider-thumb]:appearance-none" />
{activePet ? `سن ${activePet.name}` : 'سن حیوان'}
{/* Calculation Results Output */}
{activePet ? `محاسبه‌گر دوره درمانی ${activePet.name}` : 'محاسبه‌گر دوره درمانی'}
AI Calculator
پیشنهاد: {toPersian(itemQuantity)} بسته
{toPersian(calculation.duration)} روز
مدت تامین یک بسته
{toPersian(calculation.dailyDose)}
دوز روزانه ({calculation.unit === 'g' ? 'گرم' : calculation.unit})
تخمین هزینه دوره ۳۰ روزه: {toPersian((Math.ceil(30 / (calculation.duration || 30)) * (product.priceValue || 0)).toLocaleString())} تومان

{activePet ? `* دوز دقیق بر اساس وزن ${activePet.name} (${toPersian(weight)} ک‌گ) محاسبه شده است.` : '* دوز دقیق بر اساس وزن پت محاسبه شده است.'}

)} {/* Ingredients & Scientific Analysis Section (Compact & Sleek Design) */} {((product.main_ingredients && product.main_ingredients.length > 0) || (product.analysis && Object.keys(product.analysis).length > 0)) && (

ترکیبات و آنالیز علمی

آنالیز دقیق مواد مؤثره و فرمولاسیون دارویی

{/* Ingredients Pills */} {product.main_ingredients && product.main_ingredients.length > 0 && (

مواد تشکیل‌دهنده برتر

{product.main_ingredients.map((ing, idx) => { const termKey = termKeys.find(key => { const termObj = scientificTerms[key] || SCIENTIFIC_TERMS[key]; const termName = termObj?.term || key; const ingClean = ing.toLowerCase(); const keyClean = key.toLowerCase(); const termNameClean = termName.toLowerCase(); return ingClean.includes(keyClean) || keyClean.includes(ingClean) || ingClean.includes(termNameClean) || termNameClean.includes(ingClean); }); return (
{termKey ? ( router.push(`/wiki?term=${id}`)}> {ing} ) : ing}
); })}
)} {/* Quantitative Analysis Cards (Responsive layout fitting 1 or multiple items naturally) */} {(() => { const filteredAnalysis = Object.entries(product.analysis || {}).filter(([key, val]) => { const cleanKey = key.toLowerCase(); // Don't show duplicate ingredients here if already listed above if (cleanKey.includes('مواد') || cleanKey.includes('ترکیبات') || cleanKey.includes('ingredient')) return false; return Boolean(val); }); if (filteredAnalysis.length === 0) return null; return (
جدول آنالیز و آنالیتیکال ترکیبات
{filteredAnalysis.map(([key, value]) => (
{key} {toPersian(value)}
))}
); })()}
)} {/* Feeding / Usage Instructions Section (Merged and enriched) */}

{fullProduct.categorySlug === 'special-care' || fullProduct.name.toLowerCase().includes('pfotenpflege') || fullProduct.name.toLowerCase().includes('augenpflege') ? 'دستورالعمل و نحوه استفاده موضعی' : 'توصیه غذایی و نحوه مصرف'}

{fullProduct.categorySlug === 'special-care' || fullProduct.name.toLowerCase().includes('pfotenpflege') || fullProduct.name.toLowerCase().includes('augenpflege') ? 'فرآورده بهداشتی / موضعی (اعمال روی موضع بدون وابستگی به وزن بدن)' : 'راهنمای استاندارد تغذیه بر اساس کاتالوگ دارویی آلمان'}

{fullProduct.categorySlug === 'special-care' || fullProduct.name.toLowerCase().includes('pfotenpflege') || fullProduct.name.toLowerCase().includes('augenpflege') || fullProduct.unit?.includes('ml Lotion') || fullProduct.unit?.includes('Balsam') || fullProduct.nameFa?.includes('کرم') || fullProduct.nameFa?.includes('قطره تمیزکننده') || fullProduct.nameFa?.includes('اسپری') ? (

{product.feedingAdvice || "چندین بار در روز روی نواحی آسیب‌دیده مالیده و به آرامی ماساژ داده شود."}

ℹ️ این محصول یک فرآورده موضعی/بهداشتی است و مقدار مصرف آن به صورت موضعی (روی پوست، چشم یا پنجه) اعمال می‌شود و وابسته به وزن بدن حیوان نمی‌باشد. ماندگاری بسته بسته به میزان و تکرار مصرف روزانه شما متفاوت خواهد بود.

) : (

{product.feedingAdvice}

)} {/* Storage & Precautions Bar */}
شرایط نگهداری کاتالوگ آلمان

{product.storage || "در جای خشک، خنک (زیر ۲۵ درجه سانتی‌گراد) و دور از تابش مستقیم نور خورشید نگهداری شود."}

احتیاط و منع مصرف (Contraindications)

{product.contraindications?.join(" • ") || "دور از دسترس کودکان نگهداری شود. پس از هربار مصرف درب قوطی را محکم ببندید."}

{/* Multimedia & Scientific Documentation (Video, Podcast & PDF Catalog) */} {(product.videoUrl || product.podcastUrl || product.pdfUrl) && (

رسانه و مستندات تخصصی محصول

تحلیل هوشمند (AI-Powered)

ویدیو آموزشی، پادکست تحلیل علمی تولیدشده با هوش مصنوعی و دفترچه کاتالوگ کارخانه Canina

{/* Video Player Row */} {product.videoUrl && (
{/* Thumbnail / Cover Box */}
setIsVideoModalOpen(true)} className="relative w-full md:w-80 aspect-video rounded-2xl overflow-hidden cursor-pointer bg-neutral-800 border border-white/10 group-hover:border-canina-blue/50 transition-all flex items-center justify-center shrink-0" >
ویدیو راهنما و معرفی

{product.videoTitle || "ویدیو راهنمای مصرف و معرفی مکمل"}

{(() => { const vDesc = product.videoDescription || "مشاهده ویدیوی آموزشی، دوزبندی دقیق و نحوه مصرف مکمل توسط کادر علمی کنینا"; const isLong = vDesc.length > 120; return (

{isLong && !isFullVideoDescOpen ? `${vDesc.slice(0, 120)}...` : vDesc}

{isLong && ( )}
); })()}
)} {/* Podcast Player Row (Inline Direct Player with Soundcloud Waveform) */} {product.podcastUrl && (
)} {/* PDF Catalog Download Row */} {product.pdfUrl && (
PDF

{product.pdfTitle || "بروشور و کاتالوگ علمی Canina آلمان"}

{product.pdfDescription || "شامل مقالات رفرنس، جدول ترکیبات دقیق و سرتیفیکیت رسمی"}

دانلود مستقیم فایل PDF
)}
)} {/* FAQ Section */} {product.faqs && product.faqs.length > 0 && (

پاسخ به ابهامات شما

{product.faqs.map((faq, i) => (
{faq.question}
{faq.answer}
))}
)} {/* Customer Reviews & Ratings Section */} {product && (
)}
{/* Sticky Sidebar (Clean Buy Box) - Hidden on mobile as mobile floating buy bar is active */}
قیمت نهایی محصول
{isCatalogHidePrices ? "استعلام قیمت" : toPersian(product.price)}
{isCartDisabled ? (
مشاوره و استعلام خرید ({getText('contact_phone', '۰۲۱-۸۸۸۸۴۴۴۴')})

خرید آنلاین در حالت کاتالوگ موقتاً غیرفعال است

) : (
{/* Quantity Selector - 40% Width */}
{toPersian(itemQuantity)}
{/* Add to Cart / Preorder / Stock Notify Button - 60% Width */} {(product as unknown as { isPreorder?: boolean; preorderDeposit?: number }).isPreorder ? ( ) : (product.packageSize || 0) <= 0 ? ( ) : ( )}
)}
ضمانت اصالت محصول (Made in Germany)
آماده ارسال (تحویل حداکثر ۴۸ ساعت)
{/* expected results box */} {product.expectedResults && product.expectedResults.length > 0 && (

تغییرات قابل انتظار

{product.expectedResults.map((res, i) => { const Icon = ICON_MAP[res.icon] || Sparkles; return (
{res.text}
); })}
)}
{/* Smart Cross-sell: Recommended Combinations */} {product.relatedProducts && product.relatedProducts.length > 0 && (
فرمولاسیون ترکیبی هم‌افزا (Synergy Blend)

اثربخشی دوبرابر با ترکیب هوشمند

{product.relatedProducts.map(relId => { const relProduct = allProducts.find(p => p.id === relId); if (!relProduct) return null; return ( router.push(`/shop/${relProduct.id}`)} >

{relProduct.name}

{relProduct.shortDescription || (relProduct.description ? relProduct.description.replace(/<[^>]*>/g, '') : '')}

{relProduct.price}
مشاهده محصول مکمل
); })}
)}
{/* Refill Automation Popup */} {showRefillModal && (
setShowRefillModal(false)} className="absolute inset-0 bg-medical-gray-900/60 backdrop-blur-md" />

سیستم یادآوری هوشمند

بر اساس وزن {toPersian(weight)} کیلوگرمی {activePet ? `برای ${activePet.name}` : 'سگ شما'}، این بسته {toPersian(product.packageSize)} تایی دقیقاً {toPersian(calculation.duration)} روز دیگر تمام می‌شود.

آیا مایلید سیستم ۵ روز قبل از اتمام، به شما پیامک یادآوری ارسال کند؟
)} {/* Mobile Floating Sticky Bottom Buy Bar */}
قیمت نهایی {isCatalogHidePrices ? "استعلام قیمت" : toPersian(product.price)}
{isCartDisabled ? ( استعلام و مشاوره ) : isOutOfStock ? ( ) : ( <>
{toPersian(itemQuantity)}
)}
{/* Fullscreen High-Resolution Image Zoom & Inspection Lightbox Modal */} setIsImageZoomOpen(false)} images={galleryMedia.filter(m => m.type === 'image').map(m => m.url)} activeImage={activeMedia?.type === 'image' ? activeMedia.url : (galleryMedia.find(m => m.type === 'image')?.url || product.image || "")} onSelectImage={(img) => { const foundIdx = galleryMedia.findIndex(m => m.url === img); if (foundIdx !== -1) setActiveMediaIndex(foundIdx); }} productName={product.nameFa || product.name} /> {/* Dedicated Video Modal Player */} { setIsVideoModalOpen(false); setActiveMediaForVideoModal(null); }} video={activeMediaForVideoModal || (product.videoUrl ? { title: product.videoTitle || product.name, doctor: "کادر علمی و تخصصی کنینا", videoUrl: product.videoUrl, thumbnail: product.videoCover || product.image, description: product.videoDescription || product.description, } : null)} />
); }