import { type Breakpoint } from '@divi/types'; /** * Group Carousel Settings Interface. */ interface GroupCarouselSettings { slidesToShow: number; slidesToScroll: number; auto: boolean; speed: number; transitionSpeed: number; pauseOnHover: boolean; centerMode: boolean; showArrows: boolean; showDots: boolean; arrowPosition: 'inside' | 'center' | 'outside'; dotAlignment: 'left' | 'center' | 'right'; dotPosition: 'above' | 'below' | 'overlay'; } /** * Group Carousel Instance Interface. */ interface GroupCarouselInstance { element: HTMLElement; slides: HTMLElement[]; currentSlide: number; totalSlides: number; settings: GroupCarouselSettings; autoplayTimer?: number; classObserver?: MutationObserver; goToSlide(index: number): void; nextSlide(): void; prevSlide(): void; startAutoplay(): void; stopAutoplay(): void; updateDots(): void; updateArrows(): void; destroy(): void; getRealSlideIndex(): number; getSettings(): GroupCarouselSettings; } /** * Extended HTMLElement with carousel instance property. */ interface HTMLElementWithCarousel extends HTMLElement { __groupCarouselInstance?: GroupCarouselInstance; scheduleNextSlideCallback?: () => void; } /** * Row of carousel settings as localized from PHP (desktop or per-breakpoint). * Speeds may be numbers (ms) or strings with units. */ type CarouselScriptDataRow = Partial> & { speed?: string | number; transitionSpeed?: string | number; }; interface CarouselScriptData { selector: string; data: CarouselScriptDataRow; responsive?: Partial>; } /** * MultiView data item structure for carousel-specific responsive/hover/sticky states. * Used by the orchestrator for handling dynamic setting changes. */ interface CarouselMultiViewItem { action: string; selector: string; data: Record>; } /** * Local type for carousel multiview access to avoid global type conflicts. * Uses intersection to avoid extending Window with incompatible property types. */ type CarouselWindow = Window & { diviElementMultiViewData?: CarouselMultiViewItem[]; }; /** * Global extensions for window and DOM. */ declare global { interface Window { ET_Builder?: object; diviModuleGroupCarouselData?: CarouselScriptData[]; diviModuleGroupCarouselInit?: ( element: HTMLElement, settings?: Partial, ) => GroupCarouselInstance | null; diviModuleGroupCarouselUpdate?: ( element: HTMLElement, settings: GroupCarouselSettings, ) => GroupCarouselInstance | null; diviModuleGroupCarouselReinit?: () => void; diviModuleGroupCarouselReinitElement?: (element: HTMLElement, settings?: Partial) => void; } } /** * Slide indexes for the visible window — kept in sync with ACTIVE_SLIDE / LAST_VISIBLE_SLIDE in updateSlides(). */ type VisibleSlideIndexes = { start: number; endExclusive: number; active: number; lastVisible: number; }; export type { GroupCarouselSettings, GroupCarouselInstance, HTMLElementWithCarousel, CarouselScriptData, CarouselScriptDataRow, CarouselMultiViewItem, CarouselWindow, VisibleSlideIndexes, };