// eslint-disable-next-line import-x/no-unresolved
import Flicker, { Options, EventBindings } from 'flickity';

interface PointerDragEvent extends PointerEvent {
  x: number;
  y: number;
}
interface TouchDragEvent extends Touch {
  x: number;
  y: number;
}

export interface Flickity
  extends Omit<Flicker, 'next' | 'previous' | 'slides'> {
  options: FlickityOptions;
  next(isWrapped?: boolean, isInstant?: boolean): void;
  previous(isWrapped?: boolean, isInstant?: boolean): void;
  updateDraggable(): void;
  viewFullscreen: () => void;
  exitFullscreen: () => void;
  slides: FlickitySlide[];
  x?: number;
  y?: number;
  slideableWidth: number;
  cursorPosition: number;
}

export type FlickityOptions = Options & {
  fullscreen?: boolean;
  fade?: boolean;
};

export type DragEvent = TouchDragEvent | PointerDragEvent;

export type SlideAnimation = 'fade' | 'scroll' | 'parallax' | (() => void);

export interface FlickityEvents
  extends Omit<
    EventBindings,
    'dragMove' | 'dragEnd' | 'dragStart' | 'staticClick'
  > {
  dragMove?: (pointer?: DragEvent) => void;
  dragStart?: (pointer?: DragEvent) => void;
  dragEnd?: (pointer?: DragEvent) => void;
  staticClick?: (pointer?: DragEvent) => void;
}

export interface FlickitySlide {
  cells: FlickityCell[];
  firstMargin: number;
  height: number;
  isOriginLeft: boolean;
  outerWidth: number;
  parent: Flickity;
  target: number;
  x: number;
}

export interface FlickityCell {
  element: HTMLElement;
  parent: Flickity;
  shift: number;
  size: { [prop: string]: number };
  target: number;
  x: number;
}
