"use client"; import "photoswipe/style.css"; import { zodResolver } from "@hookform/resolvers/zod"; import clsx from "clsx"; import type { LucideIcon } from "lucide-react"; import { Tag, Truck } from "lucide-react"; import PhotoSwipeLightbox from "photoswipe/lightbox"; import { useEffect, useId, useRef, useState } from "react"; import type { ControllerRenderProps } from "react-hook-form"; import { Controller, useForm } from "react-hook-form"; import z from "zod"; import type { PriceType } from "@/components/shadcnblocks/price"; import { Price } from "@/components/shadcnblocks/price"; import QuantityInput from "@/components/shadcnblocks/quantity-input"; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, } from "@/components/ui/accordion"; import { AspectRatio } from "@/components/ui/aspect-ratio"; import { Badge, badgeVariants } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { buttonVariants } from "@/components/ui/button"; import type { CarouselApi } from "@/components/ui/carousel"; import { Carousel, CarouselContent, CarouselItem, CarouselNext, CarouselPrevious, } from "@/components/ui/carousel"; import { Dialog, DialogContent, DialogTitle } from "@/components/ui/dialog"; import { FieldLegend, FieldSet } from "@/components/ui/field"; import { RadioGroup, RadioGroupItem } from "@/components/ui/radio-group"; import { cn } from "@/lib/utils"; const STOCK_STATUS = { IN_STOCK: { code: "IN_STOCK", message: (qt?: number) => qt ? `پیش‌سفارش امروز ${qt.toLocaleString("fa-IR")} عدد باقی مانده` : "موجود، آماده ارسال", color: "oklch(64.8% 0.2 131.684)", }, LOW_STOCK: { code: "LOW_STOCK", message: "دارد سریع فروش می‌رود!", color: "oklch(76.9% 0.188 70.08)", }, OUT_OF_STOCK: { code: "OUT_OF_STOCK", message: "ناموجود", color: "oklch(58.6% 0.253 17.585)", }, } as const; type StockStatusCode = keyof typeof STOCK_STATUS; type Image = { src: string; alt: string; thumbnail: string; width: number; height: number; }; type SocialIcon = { title: string; light: string; dark: string; }; type SocialLink = { link: string; icon: SocialIcon; }; type StockStatus = { code: StockStatusCode; quantity?: number; }; interface ProductImagesProps { images: Image[]; galleryID?: string; badges?: string[]; } interface StockStatusProps { status?: StockStatus; } type ServiceListType = { icon: LucideIcon; text: string; }[]; interface ServicesListProps { list?: ServiceListType; } type FormType = z.infer; type FieldName = keyof FormType; type Option = { id: string; value: string; label: string; thumbnail?: string; color?: string; stockStatusCode?: StockStatusCode; }; interface Hinges { label: string; id: string; min?: number; max?: number; name: FieldName; options?: Option[]; } interface FormProps { hinges: Record; selected?: FormType; } interface RadioGroupProps { options?: Array