{"version":3,"sources":["../../../src/components/layout/Carousel.tsx","../../../src/util/array.ts","../../../src/util/math.ts","../../../src/util/easeFunctions.ts","../../../src/util/loopingArray.ts"],"sourcesContent":["import type { ReactNode } from 'react'\nimport React from 'react'\nimport clsx from 'clsx'\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { ChevronLeft, ChevronRight } from 'lucide-react'\nimport { createLoopingListWithIndex, range } from '../../util/array'\nimport { clamp } from '../../util/math'\nimport { EaseFunctions } from '../../util/easeFunctions'\nimport type { Direction } from '../../util/loopingArray'\nimport { LoopingArrayCalculator } from '../../util/loopingArray'\n\n\ntype CarouselProps = {\n  children: ReactNode[],\n  animationTime?: number,\n  isLooping?: boolean,\n  isAutoLooping?: boolean,\n  autoLoopingTimeOut?: number,\n  autoLoopAnimationTime?: number,\n  hintNext?: boolean,\n  arrows?: boolean,\n  dots?: boolean,\n  /**\n   * Percentage that is allowed to be scrolled further\n   */\n  overScrollThreshold?: number,\n  blurColor?: string,\n  className?: string,\n  heightClassName?: string,\n  widthClassName?: string,\n}\n\ntype ItemType = {\n  item: ReactNode,\n  index: number,\n}\n\ntype CarouselAnimationState = {\n  targetPosition: number,\n  /**\n   * Value of either 1 or -1, 1 is forwards -1 is backwards\n   */\n  direction: Direction,\n  startPosition: number,\n  startTime?: number,\n  lastUpdateTime?: number,\n  isAutoLooping: boolean,\n}\n\ntype DragState = {\n  startX: number,\n  startTime: number,\n  lastX: number,\n  startIndex: number,\n}\n\ntype CarouselInformation = {\n  currentPosition: number,\n  dragState?: DragState,\n  animationState?: CarouselAnimationState,\n}\n\nexport const Carousel = ({\n  children,\n  animationTime = 200,\n  isLooping = false,\n  isAutoLooping = false,\n  autoLoopingTimeOut = 5000,\n  autoLoopAnimationTime = 500,\n  hintNext = false,\n  arrows = false,\n  dots = true,\n  overScrollThreshold = 0.1,\n  blurColor = 'from-white',\n  className = '',\n  heightClassName = 'h-[24rem]',\n  widthClassName = 'w-[70%] desktop:w-1/2',\n}: CarouselProps) => {\n  if (isAutoLooping && !isLooping) {\n    console.error('When isAutoLooping is true, isLooping should also be true')\n    isLooping = true\n  }\n\n  const [{\n    currentPosition,\n    dragState,\n    animationState,\n  }, setCarouselInformation] = useState<CarouselInformation>({\n    currentPosition: 0,\n  })\n  const animationId = useRef<number | undefined>(undefined)\n  const timeOut = useRef<NodeJS.Timeout | undefined>(undefined)\n  autoLoopingTimeOut = Math.max(0, autoLoopingTimeOut)\n\n  const length = children.length\n  const paddingItemCount = 3 // The number of items to append left and right of the list to allow for clean transition when looping\n\n  const util = useMemo(() => new LoopingArrayCalculator(length, isLooping, overScrollThreshold), [length, isLooping, overScrollThreshold])\n  const currentIndex = util.getCorrectedPosition(LoopingArrayCalculator.withoutOffset(currentPosition))\n  animationTime = Math.max(200, animationTime) // in ms, must be > 0\n  autoLoopAnimationTime = Math.max(200, autoLoopAnimationTime)\n\n  const getStyleOffset = (index: number) => {\n    const baseOffset = -50 + (index - currentPosition) * 100\n    return `${baseOffset}%`\n  }\n\n  const animation = useCallback((time: number) => {\n    let keepAnimating: boolean = true\n\n    // Other calculation in the setState call to avoid updating the useCallback to often\n    setCarouselInformation((state) => {\n      const {\n        animationState,\n        dragState\n      } = state\n      if (animationState === undefined || dragState !== undefined) {\n        keepAnimating = false\n        return state\n      }\n      if (!animationState.startTime || !animationState.lastUpdateTime) {\n        return {\n          ...state,\n          animationState: {\n            ...animationState,\n            startTime: time,\n            lastUpdateTime: time\n          }\n        }\n      }\n      const useAnimationTime = animationState.isAutoLooping ? autoLoopAnimationTime : animationTime\n      const progress = clamp((time - animationState.startTime) / useAnimationTime) // progress\n      const easedProgress = EaseFunctions.easeInEaseOut(progress)\n      const distance = util.getDistanceDirectional(animationState.startPosition, animationState.targetPosition, animationState.direction)\n      const newPosition = util.getCorrectedPosition(easedProgress * distance * animationState.direction + animationState.startPosition)\n\n      if (animationState.targetPosition === newPosition || progress === 1) {\n        keepAnimating = false\n        return ({\n          currentPosition: LoopingArrayCalculator.withoutOffset(newPosition),\n          animationState: undefined\n        })\n      }\n      return ({\n        currentPosition: newPosition,\n        animationState: {\n          ...animationState!,\n          lastUpdateTime: time\n        }\n      })\n    })\n    if (keepAnimating) {\n      animationId.current = requestAnimationFrame(time1 => animation(time1))\n    }\n  }, [animationTime, autoLoopAnimationTime, util])\n\n  useEffect(() => {\n    if (animationState) {\n      animationId.current = requestAnimationFrame(animation)\n    }\n    return () => {\n      if (animationId.current) {\n        cancelAnimationFrame(animationId.current)\n        animationId.current = 0\n      }\n    }\n  }, [animationState]) // eslint-disable-line react-hooks/exhaustive-deps\n\n  const startAutoLoop = () => setCarouselInformation(prevState => ({\n    ...prevState,\n    dragState: prevState.dragState,\n    animationState: prevState.animationState || prevState.dragState ? prevState.animationState : {\n      startPosition: currentPosition,\n      targetPosition: (currentPosition + 1) % length,\n      direction: 1, // always move forward\n      isAutoLooping: true\n    }\n  }))\n\n  useEffect(() => {\n    if (!animationId.current && !animationState && !dragState && !timeOut.current) {\n      if (autoLoopingTimeOut > 0) {\n        timeOut.current = setTimeout(() => {\n          startAutoLoop()\n          timeOut.current = undefined\n        }, autoLoopingTimeOut)\n      } else {\n        startAutoLoop()\n      }\n    }\n  }, [animationState, dragState, animationId.current, timeOut.current]) // eslint-disable-line react-hooks/exhaustive-deps\n\n  const startAnimation = (targetPosition?: number) => {\n    if (targetPosition === undefined) {\n      targetPosition = LoopingArrayCalculator.withoutOffset(currentPosition)\n    }\n    if (targetPosition === currentPosition) {\n      return // we are exactly where we want to be\n    }\n\n    // find target index and fastest path to it\n    const direction = util.getBestDirection(currentPosition, targetPosition)\n    clearTimeout(timeOut.current)\n    timeOut.current = undefined\n    if (animationId.current) {\n      cancelAnimationFrame(animationId.current)\n      animationId.current = undefined\n    }\n\n    setCarouselInformation(prevState => ({\n      ...prevState,\n      dragState: undefined,\n      animationState: {\n        targetPosition: targetPosition!,\n        direction,\n        startPosition: currentPosition,\n        isAutoLooping: false\n      },\n      timeOut: undefined\n    }))\n  }\n\n  const canGoLeft = () => {\n    return isLooping || currentPosition !== 0\n  }\n\n  const canGoRight = () => {\n    return isLooping || currentPosition !== length - 1\n  }\n\n  const left = () => {\n    if (canGoLeft()) {\n      startAnimation(currentPosition === 0 ? length - 1 : LoopingArrayCalculator.withoutOffset(currentPosition - 1))\n    }\n  }\n\n  const right = () => {\n    if (canGoRight()) {\n      startAnimation(LoopingArrayCalculator.withoutOffset((currentPosition + 1) % length))\n    }\n  }\n\n  let items: ItemType[] = children.map((item, index) => ({\n    index,\n    item\n  }))\n\n  if (isLooping) {\n    const before = createLoopingListWithIndex(children, length - 1, paddingItemCount, false).reverse().map(([index, item]) => ({\n      index,\n      item\n    }))\n    const after = createLoopingListWithIndex(children, 0, paddingItemCount).map(([index, item]) => ({\n      index,\n      item\n    }))\n    items = [\n      ...before,\n      ...items,\n      ...after\n    ]\n  }\n\n  const onDragStart = (x: number) => setCarouselInformation(prevState => ({\n    ...prevState,\n    dragState: {\n      lastX: x,\n      startX: x,\n      startTime: Date.now(),\n      startIndex: currentPosition,\n    },\n    animationState: undefined // cancel animation\n  }))\n\n  const onDrag = (x: number, width: number) => {\n    // For some weird reason the clientX is 0 on the last dragUpdate before drag end causing issues\n    if (!dragState || x === 0) {\n      return\n    }\n    const offsetUpdate = (dragState.lastX - x) / width\n    const newPosition = util.getCorrectedPosition(currentPosition + offsetUpdate)\n\n    setCarouselInformation(prevState => ({\n      ...prevState,\n      currentPosition: newPosition,\n      dragState: {\n        ...dragState,\n        lastX: x\n      },\n    }))\n  }\n\n  const onDragEnd = (x: number, width: number) => {\n    if (!dragState) {\n      return\n    }\n    const distance = dragState.startX - x\n    const relativeDistance = distance / width\n    const duration = (Date.now() - dragState.startTime) // in milliseconds\n    const velocity = distance / (Date.now() - dragState.startTime)\n\n    const isSlide = Math.abs(velocity) > 2 || (duration < 200 && (Math.abs(relativeDistance) > 0.2 || Math.abs(distance) > 50))\n    if (isSlide) {\n      if (distance > 0 && canGoRight()) {\n        right()\n        return\n      } else if (distance < 0 && canGoLeft()) {\n        left()\n        return\n      }\n    }\n    startAnimation()\n  }\n\n  const dragHandlers = {\n    draggable: true,\n    onDragStart: (event: React.DragEvent<HTMLDivElement>) => {\n      onDragStart(event.clientX)\n      event.dataTransfer.setDragImage(document.createElement('div'), 0, 0)\n    },\n    onDrag: (event: React.DragEvent<HTMLDivElement>) => onDrag(event.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n    onDragEnd: (event: React.DragEvent<HTMLDivElement>) => onDragEnd(event.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n    onTouchStart: (event: React.TouchEvent<HTMLDivElement>) => onDragStart(event.touches[0]!.clientX),\n    onTouchMove: (event: React.TouchEvent<HTMLDivElement>) => onDrag(event.touches[0]!.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n    onTouchEnd: (event: React.TouchEvent<HTMLDivElement>) => onDragEnd(event.changedTouches[0]!.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n    onTouchCancel: (event: React.TouchEvent<HTMLDivElement>) => onDragEnd(event.changedTouches[0]!.clientX, (event.target as HTMLDivElement).getBoundingClientRect().width),\n  }\n\n  return (\n    <div className=\"col items-center w-full gap-y-2\">\n      <div className={clsx(`relative w-full overflow-hidden`, heightClassName, className)}>\n        {arrows && (\n          <>\n            <div\n              className={clsx('absolute z-10 left-0 top-1/2 -translate-y-1/2 bg-gray-200 hover:bg-gray-300 rounded-lg cursor-pointer border-black border-2', { hidden: !canGoLeft() })}\n              onClick={() => left()}\n            >\n              <ChevronLeft size={32}/>\n            </div>\n            <div\n              className={clsx('absolute z-10 right-0 top-1/2 -translate-y-1/2 bg-gray-200 hover:bg-gray-300 rounded-lg cursor-pointer border-black border-2', { hidden: !canGoRight() })}\n              onClick={() => right()}\n            >\n              <ChevronRight size={32}/>\n            </div>\n          </>\n        )}\n        {hintNext ? (\n          <div className={clsx(`relative row h-full`, heightClassName)}>\n            <div className=\"relative row h-full w-full px-2 overflow-hidden\">\n              {items.map(({\n                            item,\n                            index\n                          }, listIndex) => (\n                <div\n                  key={listIndex}\n                  className={clsx(`absolute left-[50%] h-full overflow-hidden`, widthClassName, { '!cursor-grabbing': !!dragState })}\n                  style={{ translate: getStyleOffset(listIndex - (isLooping ? paddingItemCount : 0)) }}\n                  {...dragHandlers}\n                  onClick={() => startAnimation(index)}\n                >\n                  {item}\n                </div>\n              ))}\n            </div>\n            <div\n              className={clsx(`hidden pointer-events-none desktop:block absolute left-0 h-full w-[20%] bg-gradient-to-r to-transparent`, blurColor)}\n            />\n            <div\n              className={clsx(`hidden pointer-events-none desktop:block absolute right-0 h-full w-[20%] bg-gradient-to-l to-transparent`, blurColor)}\n            />\n          </div>\n        ) : (\n          <div className={clsx('px-16 h-full', { '!cursor-grabbing': !!dragState })} {...dragHandlers}>\n            {children[currentIndex]}\n          </div>\n        )}\n      </div>\n      {dots && (\n        <div\n          className=\"row items-center justify-center w-full my-2\">\n          {range(0, length - 1).map(index => (\n            <button\n              key={index}\n              className={clsx('w-[2rem] min-w-[2rem] h-[0.75rem] min-h-[0.75rem] hover:bg-primary hover:brightness-90 first:rounded-l-md last:rounded-r-md', {\n                'bg-gray-200': currentIndex !== index,\n                'bg-primary': currentIndex === index\n              })}\n              onClick={() => startAnimation(index)}\n            />\n          ))}\n        </div>\n      )}\n    </div>\n  )\n}\n","export const equalSizeGroups = <T >(array: T[], groupSize: number): T[][] => {\n  if (groupSize <= 0) {\n    console.warn(`group size should be greater than 0: groupSize = ${groupSize}`)\n    return [[...array]]\n  }\n\n  const groups = []\n  for (let i = 0; i < array.length; i += groupSize) {\n    groups.push(array.slice(i, Math.min(i + groupSize, array.length)))\n  }\n  return groups\n}\n\n/**\n * @param start\n * @param end inclusive\n * @param allowEmptyRange Whether the range can be defined empty via end < start\n */\nexport const range = (start: number, end: number, allowEmptyRange: boolean = false): number[] => {\n  if (end < start) {\n    if (!allowEmptyRange) {\n      console.warn(`range: end (${end}) < start (${start}) should be allowed explicitly, set allowEmptyRange to true`)\n    }\n    return []\n  }\n  return Array.from({ length: end - start + 1 }, (_, index) => index + start)\n}\n\n/** Finds the closest match\n * @param list The list of all possible matches\n * @param firstCloser Return whether item1 is closer than item2\n */\nexport const closestMatch = <T >(list: T[], firstCloser: (item1: T, item2: T) => boolean) => {\n  return list.reduce((item1, item2) => {\n    return firstCloser(item1, item2) ? item1 : item2\n  })\n}\n\n/**\n * returns the item in middle of a list and its neighbours before and after\n * e.g. [1,2,3,4,5,6] for item = 1 would return [5,6,1,2,3]\n */\nexport const getNeighbours = <T >(list: T[], item: T, neighbourDistance: number = 2) => {\n  const index = list.indexOf(item)\n  const totalItems = neighbourDistance * 2 + 1\n  if (list.length < totalItems) {\n    console.warn('List is to short')\n    return list\n  }\n\n  if (index === -1) {\n    console.error('item not found in list')\n    return list.splice(0, totalItems)\n  }\n\n  let start = index - neighbourDistance\n  if (start < 0) {\n    start += list.length\n  }\n  const end = (index + neighbourDistance + 1) % list.length\n\n  const result: T[] = []\n  let ignoreOnce = list.length === totalItems\n  for (let i = start; i !== end || ignoreOnce; i = (i + 1) % list.length) {\n    result.push(list[i]!)\n    if (end === i && ignoreOnce) {\n      ignoreOnce = false\n    }\n  }\n  return result\n}\n\nexport const createLoopingListWithIndex = <T >(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {\n  if (length < 0) {\n    console.warn(`createLoopingList: length must be >= 0, given ${length}`)\n  } else if (length === 0) {\n    length = list.length\n  }\n\n  const returnList: [number, T][] = []\n\n  if (forwards) {\n    for (let i = startIndex; returnList.length < length; i = (i + 1) % list.length) {\n      returnList.push([i, list[i]!])\n    }\n  } else {\n    for (let i = startIndex; returnList.length < length; i = i === 0 ? i = list.length - 1 : i - 1) {\n      returnList.push([i, list[i]!])\n    }\n  }\n\n  return returnList\n}\n\nexport const createLoopingList = <T >(list: T[], startIndex: number = 0, length: number = 0, forwards: boolean = true) => {\n  return createLoopingListWithIndex(list, startIndex, length, forwards).map(([_, item]) => item)\n}\n\nexport const ArrayUtil = {\n  unique: <T>(list: T[]): T[] => {\n    const seen = new Set<T>()\n    return list.filter((item) => {\n      if (seen.has(item)) {\n        return false\n      }\n      seen.add(item)\n      return true\n    })\n  },\n\n  difference: <T>(list: T[], removeList: T[]): T[] => {\n    const remove = new Set<T>(removeList)\n    return list.filter((item) => !remove.has(item))\n  }\n}\n","export const clamp = (value: number, min: number = 0, max: number = 1): number => {\n  return Math.min(Math.max(value, min), max)\n}\n","import { clamp } from './math'\n\nexport type EaseFunction = (t: number) => number\n\nexport class EaseFunctions {\n  static cubicBezierGeneric(x1: number, y1: number, x2: number, y2: number): { x: EaseFunction, y: EaseFunction } {\n    // Calculate the x and y coordinates using the cubic Bézier formula\n    const cx = 3 * x1\n    const bx = 3 * (x2 - x1) - cx\n    const ax = 1 - cx - bx\n\n    const cy = 3 * y1\n    const by = 3 * (y2 - y1) - cy\n    const ay = 1 - cy - by\n\n    // Compute x and y values at parameter t\n    const x = (t: number) => ((ax * t + bx) * t + cx) * t\n    const y = (t: number) => ((ay * t + by) * t + cy) * t\n\n    return {\n      x,\n      y\n    }\n  }\n\n  static cubicBezier(x1: number, y1: number, x2: number, y2: number): EaseFunction {\n    const { y } = EaseFunctions.cubicBezierGeneric(x1, y1, x2, y2)\n    return (t: number) => {\n      t = clamp(t)\n      return y(t) // <= equal to x(t) * 0 + y(t) * 1\n    }\n  }\n\n  static easeInEaseOut(t: number): number {\n    return EaseFunctions.cubicBezier(0.65, 0, 0.35, 1)(t)\n  };\n}\n","/**\n *  1 is forwards\n *\n * -1 is backwards\n */\nexport type Direction = 1 | -1\n\nexport class LoopingArrayCalculator {\n  length: number\n  isLooping: boolean\n  allowedOverScroll: number\n\n  constructor(length: number, isLooping: boolean = true, allowedOverScroll: number = 0.1) {\n    if (allowedOverScroll < 0 || length < 1) {\n      throw new Error('Invalid parameters: allowedOverScroll >= 0 and length >= 1 must be true')\n    }\n\n    this.length = length\n    this.isLooping = isLooping\n    this.allowedOverScroll = allowedOverScroll\n  }\n\n  getCorrectedPosition(position: number): number {\n    if (!this.isLooping) {\n      return Math.max(-this.allowedOverScroll, Math.min(this.allowedOverScroll + this.length - 1, position))\n    }\n    if (position >= this.length) {\n      return position % this.length\n    }\n    if (position < 0) {\n      return this.length - (Math.abs(position) % this.length)\n    }\n    return position\n  }\n\n  static withoutOffset(position: number): number {\n    return position + LoopingArrayCalculator.getOffset(position)\n  }\n\n  static getOffset(position: number): number {\n    return Math.round(position) - position // For example: 45.5 => 46 - 45.5 = 0.5\n  }\n\n  /**\n   * @return absolute distance forwards or Infinity when the target cannot be reached (only possible when not isLooping)\n   */\n  getDistanceDirectional(position: number, target: number, direction: Direction): number {\n    if (!this.isLooping && (position < -this.allowedOverScroll || position > this.allowedOverScroll + this.length - 1)) {\n      throw new Error('Invalid parameters: position is out of bounds.')\n    }\n\n    const isForwardInvalid = (direction === 1 && position > target)\n    const isBackwardInvalid = (direction === -1 && target < position)\n\n    if (!this.isLooping && (isForwardInvalid || isBackwardInvalid)) {\n      return Infinity\n    }\n\n    if (direction === -1) {\n      return this.getDistanceDirectional(target, position, 1)\n    }\n\n    position = this.getCorrectedPosition(position)\n    target = this.getCorrectedPosition(target)\n\n    let distance = (target - position) * direction\n    if (distance < 0) {\n      distance = this.length - (Math.abs(position) % this.length) + target\n    }\n\n    return distance\n  }\n\n  getDistanceForward(position: number, target: number): number {\n    return this.getDistanceDirectional(position, target, 1)\n  }\n\n  getDistanceBackward(position: number, target: number): number {\n    return this.getDistanceDirectional(position, target, -1)\n  }\n\n  getDistance(position: number, target: number): number {\n    const forwardDistance = this.getDistanceForward(position, target)\n    const backwardDistance = this.getDistanceBackward(position, target)\n\n    return Math.min(forwardDistance, backwardDistance)\n  }\n\n  getBestDirection(position: number, target: number): Direction {\n    const forwardDistance = this.getDistanceForward(position, target)\n    const backwardDistance = this.getDistanceBackward(position, target)\n    return forwardDistance < backwardDistance ? 1 : -1\n  }\n}\n"],"mappings":";AAEA,OAAO,UAAU;AACjB,SAAS,aAAa,WAAW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