import { type Dispatch, type SetStateAction, useCallback, useEffect, useRef, useState, } from 'react'; import { type FetcherWithComponents, Link, useFetcher, useNavigate, useRevalidator, } from 'react-router'; import {Image} from '@shopify/hydrogen'; import {CartForm, type OptimisticCartLineInput} from '@shopify/hydrogen'; import {type MappedProductOptions} from '@shopify/hydrogen'; import {AnimatePresence, motion} from 'motion/react'; import { ArrowLeft, Check, ChevronDown, ChevronUp, Heart, Minus, Plus, Share2, ShoppingBag, Sparkles, Star, } from 'lucide-react'; import {useAside} from '~/components/Aside'; import {AbiirProductListItem} from '~/components/AbiirProductListItem'; import {useAbiirProductWishlist} from '~/hooks/useAbiirProductWishlist'; import {PDP_DEFAULT_SHIPPING_RETURNS, type AbiirPdpCms} from '~/lib/abiirProductDetail'; import {MOCK_ABIIR_PRODUCT_DETAIL_CMS} from '~/lib/abiirPdpDefaults'; import pdpImageFallback from '~/assets/spring-glow-bundle.png'; import {ABIIR_PRODUCT_LIST_GRID_CLASS} from '~/lib/abiirProductListGrid'; import {useSwipeNavigate} from '~/lib/useSwipeNavigate'; import type {AbiirProductListItemData} from '~/lib/featuredProducts'; import type {Image as StorefrontImageType} from '@shopify/hydrogen/storefront-api-types'; import type {ProductFragment} from 'storefrontapi.generated'; import type { PdpProductReview, PdpProductReviewStats, } from '~/lib/productReviewTypes'; type PdpMediaImage = { __typename?: 'MediaImage'; id?: string | null; image?: Pick | null; }; type PdpVideo = { __typename?: 'Video'; id?: string | null; previewImage?: Pick | null; sources?: Array<{ url?: string | null; mimeType?: string | null; format?: string | null; height?: number | null; width?: number | null; } | null> | null; }; type PdpMediaNode = PdpMediaImage | PdpVideo | {__typename?: string; id?: string | null}; type PdpGalleryItem = | { kind: 'image'; id: string; image: Pick; } | { kind: 'video'; id: string; previewImage: Pick | null; sources: Array<{url: string; mimeType?: string | null}>; }; /** * Storefront `Video.sources` often lists HLS (.m3u8) first. A plain `