{"version":3,"sources":["jsdelivr-header.js","/npm/vue-scroll-picker@2.0.1/src/components/VueScrollPicker.vue","/npm/vue-scroll-picker@2.0.1/src/index.ts"],"names":[],"mappings":"AAAA;AACA;AACA;AACA;AACA;AACA;AACA,01BCqBM,MAAA,EAAyC,CAAE,SAAS,GAEpD,EAAO,EAUP,EAAQ,EAuBR,EAAkB,IAAc,IAC7B,EAAM,QAAQ,KAAK,IACxB,GAAe,OAAX,EACF,MAAO,CAAE,MAAO,KAAM,KAAM,IAE9B,cAAe,GACb,IAAK,SACH,MAAO,CAAE,MAAO,EAAQ,KAAM,GAEhC,IAAK,SACL,IAAK,UACH,MAAO,CAAE,MAAO,EAAQ,KAAM,GAAG,KAG9B,OAAA,OAIL,EAAoB,EAA0C,MAE9D,EAAgB,EACpB,KAAK,IACH,EAAgB,MAAM,WACnB,GAAW,EAAO,OAAS,EAAM,aAEpC,IAIJ,IAAI,EAAwB,GAExB,EAAe,EACf,EAAU,EACV,EAAa,EAEb,EAAoC,KAExC,MAAM,EAAK,IAEL,EAAa,IACb,EAAc,IACd,EAAoB,IACpB,EAAiB,IAEvB,IAAI,EAAmD,KA4DvD,SAAS,I,MACP,MAAM,EAAY,EAAW,MACvB,EAAmB,EAAkB,MACvC,IAAC,IAAc,EACjB,OAIF,CACE,MAAQ,MAAK,UAAW,EAAiB,wBACnC,GAAQ,OAAA,EAAA,EAAG,YAAH,EAAA,EAAU,wBAAwB,MAAO,EACvC,GAAA,EAAM,GAAU,EAAI,CACtC,CAGA,IAAI,EAAkB,EACR,EAAA,MAAM,KAAK,EAAU,UAAU,KAAI,CAAC,EAAS,KACzD,MAAQ,MAAK,UAAW,EAAQ,wBAC1B,GAAc,EAAM,GAAU,EACpC,OAAc,IAAV,IACF,GAAgB,EAAa,EACX,EAAA,GAEb,EAAa,KAGT,EAAA,KAAK,OAAO,GACf,EAAA,EAAkB,EAAc,OAC5C,CAES,SAAA,EAAoB,EAAgB,G,MAC3C,IAAI,EAAU,IACV,EAAk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,MAMzB,SAAa,EAAW,GAC/B,IAAK,EAAY,QAAU,EAAe,MACxC,OAEI,MAAA,EAAU,EAAY,MAAM,wBAC5B,EAAa,EAAe,MAAM,wBACxC,IAAI,EAAY,EAAc,MAE5B,GAAA,EAAQ,MAAQ,GAChB,GAAK,EAAQ,OACb,EAAQ,KAAO,GACf,GAAK,EAAQ,OACb,CACI,GAAwB,IAAxB,EAAc,MAChB,OAIA,IAFF,IAEE,EAAgB,MAAM,IACtB,EAAgB,MAAM,GAAW,UAEjC,GAGF,SAAA,EAAW,MAAQ,GACnB,GAAK,EAAW,OAChB,EAAW,KAAO,GAClB,GAAK,EAAW,OAChB,CACA,GAAI,EAAc,QAAU,EAAgB,MAAM,OAAS,EACzD,OAIA,IAFF,IAEE,EAAgB,MAAM,IACtB,EAAgB,MAAM,GAAW,UAEjC,GAEJ,CACA,GAAI,EAAc,QAAU,GAAa,EAAgB,MAAM,GAAY,CACzE,EAAc,MAAQ,EACtB,MAAM,EAAY,EAAgB,MAAM,GAAW,MACnD,EAAK,MAAO,GACZ,EAAK,QAAS,GACd,EAAqB,GACZ,EAAA,EAAkB,GAC7B,CACF,CApDI,CAAa,EAAG,EAEpB,CAoDA,SAAS,EAAqB,GACxB,EAAM,aAAe,GACvB,EAAK,oBAAqB,EAE9B,CAGA,SAAS,EAAe,GACE,OAApB,EAAE,eACU,GAElB,CAEA,SAAS,IACO,GAChB,CAEA,SAAS,IACE,EAAA,EAAkB,EAAc,QAC1B,EAAA,KACf,EAAK,SACP,C,k3BCpeO,SAAS,GAAQ,GAClB,EAAA,UAAU,kBAAmB,GACnC,QAEW,OAAW,KAAe,QAAS,QAC5C,GAAQ,OAAO,KAGjB,MAAM,GAAiB,CACrB,mB","file":"/npm/vue-scroll-picker@2.0.1/dist/index.mjs","sourceRoot":"","sourcesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/vue-scroll-picker@2.0.1/dist/index.mjs\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","<script\n  setup\n  lang=\"ts\"\n  generic=\"T extends ScrollPickerOption = ScrollPickerOption\"\n>\nimport {\n  computed,\n  nextTick,\n  onBeforeUnmount,\n  onMounted,\n  ref,\n  shallowRef,\n  VNode,\n  watch,\n} from 'vue'\n\nexport type ScrollPickerValue = string | number | boolean | null\nexport interface ScrollPickerOption {\n  name: string\n  value: ScrollPickerValue\n  disabled?: boolean\n}\n\nexport type ScrollPickerOptionable<T> = ScrollPickerValue | T\n\ntype GestureState = [scrollY: number, clientY: number, isDragging: boolean]\n\nconst EVENT_OPTIONS: AddEventListenerOptions = { passive: false }\n\nconst emit = defineEmits<{\n  (event: 'update:modelValue', value: ScrollPickerValue | undefined): void\n  (event: 'start'): void\n  (event: 'move', value: ScrollPickerValue | undefined): void\n  (event: 'end', value: ScrollPickerValue | undefined): void\n  (event: 'cancel'): void\n  (event: 'wheel', value: ScrollPickerValue | undefined): void\n  (event: 'click', value: ScrollPickerValue | undefined): void\n}>()\n\nconst props = withDefaults(\n  defineProps<{\n    modelValue: ScrollPickerValue | undefined\n    options?: ScrollPickerOptionable<T>[]\n    dragSensitivity?: number\n    touchSensitivity?: number\n    wheelSensitivity?: number\n    emptyText?: string\n  }>(),\n  {\n    options: () => [],\n    dragSensitivity: 1.7,\n    touchSensitivity: 1.7,\n    wheelSensitivity: 1,\n    emptyText: 'No Options Available',\n  },\n)\n\ndefineSlots<{\n  default: (props: { option: T }) => VNode\n  empty: (props: { text: string }) => VNode\n}>()\n\nconst internalOptions = computed<T[]>(() => {\n  return props.options.map((option) => {\n    if (option === null) {\n      return { value: null, name: '' } as T\n    }\n    switch (typeof option) {\n      case 'string': {\n        return { value: option, name: option } as T\n      }\n      case 'number':\n      case 'boolean': {\n        return { value: option, name: `${option}` } as T\n      }\n    }\n    return option\n  })\n})\n\nconst transitionTimeout = ref<ReturnType<typeof setTimeout> | null>(null)\n\nconst internalIndex = ref(\n  Math.max(\n    internalOptions.value.findIndex(\n      (option) => option.value == props.modelValue,\n    ),\n    0,\n  ),\n)\n\nlet itemOffsets: number[] = []\n\nlet scrollOffset = 0\nlet scrollY = 0\nlet scrollYMax = 0\n\nlet gestureState: GestureState | null = null\n\nconst el = shallowRef<HTMLDivElement>()\n\nconst rotatorRef = shallowRef<HTMLDivElement>()\nconst layerTopRef = shallowRef<HTMLDivElement>()\nconst layerSelectionRef = shallowRef<HTMLDivElement>()\nconst layerBottomRef = shallowRef<HTMLDivElement>()\n\nlet resizeObserver: globalThis.ResizeObserver | null = null\n\nwatch(\n  () => props.modelValue,\n  (value) => {\n    const nextIndex = internalOptions.value.findIndex(\n      (option) => option.value == value,\n    )\n    if (internalIndex.value !== nextIndex) {\n      internalIndex.value = Math.max(nextIndex, 0)\n      scrollTo(findScrollByIndex(nextIndex))\n    }\n  },\n)\n\nwatch(internalOptions, (options) => {\n  internalIndex.value = Math.max(\n    options.findIndex((option) => option.value == props.modelValue),\n    0,\n  )\n  nextTick(() => {\n    updateItemOffsets()\n    setScroll(findScrollByIndex(internalIndex.value))\n  })\n})\n\nonMounted(() => {\n  if (!el.value) {\n    return\n  }\n\n  el.value.addEventListener('wheel', handleWheel, EVENT_OPTIONS)\n  el.value.addEventListener('touchstart', handleTouchStart, EVENT_OPTIONS)\n  el.value.addEventListener('mousedown', handleMouseDown, EVENT_OPTIONS)\n\n  if (typeof window.ResizeObserver !== 'undefined') {\n    let raf = null as ReturnType<typeof requestAnimationFrame> | null\n    resizeObserver = new window.ResizeObserver(() => {\n      if (raf) {\n        cancelAnimationFrame(raf)\n      }\n      raf = requestAnimationFrame(() => {\n        updateItemOffsets()\n        raf = null\n      })\n    })\n    resizeObserver.observe(el.value)\n  } else {\n    updateItemOffsets()\n  }\n})\n\nonBeforeUnmount(() => {\n  el.value?.removeEventListener('wheel', handleWheel)\n  el.value?.removeEventListener('touchstart', handleTouchStart)\n  el.value?.removeEventListener('mousedown', handleMouseDown)\n\n  resizeObserver?.disconnect()\n})\n\nfunction updateItemOffsets() {\n  const rotatorEl = rotatorRef.value\n  const layerSelectionEl = layerSelectionRef.value\n  if (!rotatorEl || !layerSelectionEl) {\n    return\n  }\n\n  // set scrollOffset\n  {\n    const { top, bottom } = layerSelectionEl.getBoundingClientRect()\n    const elTop = el.value?.getBoundingClientRect().top ?? 0\n    scrollOffset = (top + bottom) / 2 - elTop\n  }\n\n  // set itemOffsets\n  let firstItemOffset = 0\n  itemOffsets = Array.from(rotatorEl.children).map((itemRef, index) => {\n    const { top, bottom } = itemRef.getBoundingClientRect()\n    const itemOffset = (top + bottom) / 2\n    if (index === 0) {\n      scrollOffset -= itemOffset - top\n      firstItemOffset = itemOffset\n    }\n    return itemOffset - firstItemOffset\n  })\n\n  scrollYMax = Math.max(...itemOffsets)\n  setScroll(findScrollByIndex(internalIndex.value))\n}\n\nfunction findIndexFromScroll(scroll: number, ignoreDisabled: boolean): number {\n  let minDiff = Infinity\n  let foundBoundIndex = 0\n  for (const [boundIndex, bound] of itemOffsets.entries()) {\n    if (!ignoreDisabled && internalOptions.value[boundIndex]?.disabled) {\n      continue\n    }\n    if (Math.abs(bound - scroll) < minDiff) {\n      minDiff = Math.abs(bound - scroll)\n      foundBoundIndex = boundIndex\n    }\n  }\n  return foundBoundIndex\n}\n\nfunction findScrollByIndex(index: number): number {\n  return itemOffsets[Math.min(Math.max(index, 0), itemOffsets.length - 1)]\n}\n\nfunction scrollTo(scroll: number) {\n  setScroll(scroll)\n  if (transitionTimeout.value) {\n    clearTimeout(transitionTimeout.value)\n  }\n  transitionTimeout.value = setTimeout(() => {\n    transitionTimeout.value = null\n  }, 150)\n}\n\nlet scrollRaf = null as ReturnType<typeof requestAnimationFrame> | null\nfunction setScroll(scroll: number) {\n  scrollY = scroll\n  if (scrollRaf) {\n    cancelAnimationFrame(scrollRaf)\n  }\n  scrollRaf = requestAnimationFrame(() => {\n    if (rotatorRef.value) {\n      rotatorRef.value.style.top = `${scrollOffset - scroll}px`\n    }\n    scrollRaf = null\n  })\n  return scroll\n}\n\nfunction bounceEffect(value: number, min: number, max: number, tension = 0.2) {\n  if (value < min) {\n    return min + (value - min) * tension\n  }\n  if (value > max) {\n    return max + (value - max) * tension\n  }\n  return value\n}\n\nlet wheelTimeout: ReturnType<typeof setTimeout> | null = null\nfunction handleWheel(e: WheelEvent) {\n  if (!wheelTimeout && scrollY <= 0 && e.deltaY < 0) {\n    return\n  }\n  if (!wheelTimeout && scrollY >= scrollYMax && e.deltaY > 0) {\n    return\n  }\n\n  if (itemOffsets.length === 1) {\n    return\n  }\n  e.preventDefault()\n  const scrollYValue = setScroll(\n    bounceEffect(scrollY + e.deltaY * props.wheelSensitivity, 0, scrollYMax),\n  )\n\n  const nextIndex = findIndexFromScroll(scrollYValue, true)\n  const nextOption: ScrollPickerOption | undefined =\n    internalOptions.value[nextIndex]\n  const nextValue = nextOption?.value\n  emit('wheel', nextValue)\n  if (nextOption && !nextOption.disabled) {\n    internalIndex.value = nextIndex\n    emitUpdateModelValue(nextValue)\n  }\n\n  if (wheelTimeout) {\n    clearTimeout(wheelTimeout)\n  }\n  wheelTimeout = setTimeout(() => {\n    scrollTo(findScrollByIndex(findIndexFromScroll(scrollYValue, false)))\n    wheelTimeout = null\n  }, 100)\n}\n\nfunction handleTouchStart(e: TouchEvent) {\n  if (gestureState) {\n    return\n  }\n  if (e.cancelable) {\n    e.preventDefault()\n  }\n\n  // TODO multitouch\n  gestureState = [scrollY, e.touches[0].clientY, false]\n  emit('start')\n\n  document.addEventListener('touchmove', handleTouchMove, EVENT_OPTIONS)\n  document.addEventListener('touchend', handleTouchEnd, EVENT_OPTIONS)\n  document.addEventListener('touchcancel', handleTouchCancel)\n}\n\nfunction handleMouseDown(e: MouseEvent) {\n  if (gestureState) {\n    return\n  }\n  if (e.cancelable) {\n    e.preventDefault()\n  }\n\n  gestureState = [scrollY, e.clientY, false]\n  emit('start')\n\n  document.addEventListener('mousemove', handleMouseMove, EVENT_OPTIONS)\n  document.addEventListener('mouseup', handleMouseUp, EVENT_OPTIONS)\n  document.addEventListener('mouseout', handleMouseOut)\n}\n\nfunction handleTouchMove(e: TouchEvent) {\n  if (!gestureState) {\n    return\n  }\n  if (e.cancelable) {\n    e.preventDefault()\n  }\n  const diff = gestureState[1] - e.touches[0].clientY // TODO multitouch\n  if (Math.abs(diff) > 1.5) {\n    const nextGestureState = gestureState.slice() as GestureState\n    nextGestureState[2] = true\n    gestureState = nextGestureState\n  }\n  emitMove(\n    setScroll(\n      bounceEffect(\n        gestureState[0] + diff * props.touchSensitivity,\n        0,\n        scrollYMax,\n      ),\n    ),\n  )\n}\n\nfunction handleMouseMove(e: MouseEvent) {\n  if (!gestureState) {\n    return\n  }\n  if (e.cancelable) {\n    e.preventDefault()\n  }\n  const diff = gestureState[1] - e.clientY\n  if (Math.abs(diff) > 1.5) {\n    const nextGestureState = gestureState.slice() as GestureState\n    nextGestureState[2] = true\n    gestureState = nextGestureState\n  }\n  emitMove(\n    setScroll(\n      bounceEffect(\n        gestureState[0] + diff * props.dragSensitivity,\n        0,\n        scrollYMax,\n      ),\n    ),\n  )\n}\n\nfunction emitMove(scrollY: number) {\n  emit(\n    'move',\n    internalOptions.value[findIndexFromScroll(scrollY, true)]?.value ??\n      undefined,\n  )\n}\n\nfunction handleMouseUp(e: MouseEvent) {\n  if (!gestureState) {\n    return\n  }\n  if (e.cancelable) {\n    e.preventDefault()\n  }\n\n  endGesture(gestureState[2], e.clientX, e.clientY)\n  gestureState = null\n\n  document.removeEventListener('mousemove', handleMouseMove)\n  document.removeEventListener('mouseup', handleMouseUp)\n  document.removeEventListener('mouseout', handleMouseOut)\n}\n\nfunction handleTouchEnd(e: TouchEvent) {\n  if (!gestureState) {\n    return\n  }\n  if (e.cancelable) {\n    e.preventDefault()\n  }\n  endGesture(\n    gestureState[2],\n    e.changedTouches[0].clientX,\n    e.changedTouches[0].clientY,\n  )\n  gestureState = null\n\n  document.removeEventListener('touchmove', handleTouchMove)\n  document.removeEventListener('touchend', handleTouchEnd)\n  document.removeEventListener('touchcancel', handleTouchCancel)\n}\n\nfunction endGesture(isDragging: boolean, x: number, y: number) {\n  if (isDragging) {\n    const nextIndex = findIndexFromScroll(scrollY, false)\n    const nextValue = internalOptions.value[nextIndex]?.value ?? null\n    scrollTo(findScrollByIndex(nextIndex))\n    internalIndex.value = nextIndex\n    emit('end', nextValue)\n    emitUpdateModelValue(nextValue)\n  } else {\n    triggerClick(x, y)\n  }\n}\n\nfunction triggerClick(x: number, y: number) {\n  if (!layerTopRef.value || !layerBottomRef.value) {\n    return\n  }\n  const topRect = layerTopRef.value.getBoundingClientRect()\n  const bottomRect = layerBottomRef.value.getBoundingClientRect()\n  let nextIndex = internalIndex.value\n  if (\n    topRect.left <= x &&\n    x <= topRect.right &&\n    topRect.top <= y &&\n    y <= topRect.bottom\n  ) {\n    if (internalIndex.value === 0) {\n      return // top\n    }\n    nextIndex--\n    while (\n      internalOptions.value[nextIndex] &&\n      internalOptions.value[nextIndex].disabled\n    ) {\n      nextIndex--\n    }\n  } else if (\n    bottomRect.left <= x &&\n    x <= bottomRect.right &&\n    bottomRect.top <= y &&\n    y <= bottomRect.bottom\n  ) {\n    if (internalIndex.value === internalOptions.value.length - 1) {\n      return // bottom\n    }\n    nextIndex++\n    while (\n      internalOptions.value[nextIndex] &&\n      internalOptions.value[nextIndex].disabled\n    ) {\n      nextIndex++\n    }\n  }\n  if (internalIndex.value !== nextIndex && internalOptions.value[nextIndex]) {\n    internalIndex.value = nextIndex\n    const nextValue = internalOptions.value[nextIndex].value\n    emit('end', nextValue)\n    emit('click', nextValue)\n    emitUpdateModelValue(nextValue)\n    scrollTo(findScrollByIndex(nextIndex))\n  }\n}\n\nfunction emitUpdateModelValue(value: ScrollPickerValue) {\n  if (props.modelValue !== value) {\n    emit('update:modelValue', value)\n  }\n}\n\n// <Cancel>\nfunction handleMouseOut(e: MouseEvent) {\n  if (e.relatedTarget === null) {\n    cancelGesture()\n  }\n}\n\nfunction handleTouchCancel() {\n  cancelGesture()\n}\n\nfunction cancelGesture() {\n  scrollTo(findScrollByIndex(internalIndex.value))\n  gestureState = null\n  emit('cancel')\n}\n// </Cancel>\n</script>\n<template>\n  <div ref=\"el\" class=\"vue-scroll-picker\">\n    <div\n      ref=\"rotatorRef\"\n      role=\"listbox\"\n      :class=\"[\n        'vue-scroll-picker-rotator',\n        {\n          'vue-scroll-picker-rotator-transition': transitionTimeout,\n        },\n      ]\"\n    >\n      <template v-if=\"internalOptions.length === 0\">\n        <div\n          key=\"empty\"\n          role=\"option\"\n          class=\"vue-scroll-picker-item\"\n          aria-disabled=\"true\"\n          aria-selected=\"false\"\n        >\n          <slot name=\"empty\" :text=\"emptyText\">\n            {{ emptyText }}\n          </slot>\n        </div>\n      </template>\n      <template v-else>\n        <template\n          v-for=\"(option, optionIndex) in internalOptions\"\n          :key=\"optionIndex\"\n        >\n          <div\n            role=\"option\"\n            class=\"vue-scroll-picker-item\"\n            :aria-disabled=\"option.disabled\"\n            :aria-selected=\"internalIndex === optionIndex\"\n            :data-value=\"option.value ?? ''\"\n          >\n            <slot :option=\"option\">{{ option.name }}</slot>\n          </div>\n        </template>\n      </template>\n    </div>\n    <div class=\"vue-scroll-picker-layer\">\n      <div ref=\"layerTopRef\" class=\"vue-scroll-picker-layer-top\"></div>\n      <div\n        ref=\"layerSelectionRef\"\n        class=\"vue-scroll-picker-layer-selection\"\n      ></div>\n      <div ref=\"layerBottomRef\" class=\"vue-scroll-picker-layer-bottom\"></div>\n    </div>\n  </div>\n</template>\n","import { App, Component, Plugin } from 'vue'\n\nimport VueScrollPicker, {\n  type ScrollPickerValue,\n  type ScrollPickerOption,\n  type ScrollPickerOptionable,\n} from './components/VueScrollPicker.vue'\n\nimport './style.css'\n\nexport function install(app: App) {\n  app.component('VueScrollPicker', VueScrollPicker as unknown as Component)\n}\n\nif (typeof window !== 'undefined' && 'Vue' in window) {\n  install(window.Vue as App)\n}\n\nconst plugin: Plugin = {\n  install,\n}\n\nexport default plugin\n\nexport { VueScrollPicker }\n\nexport type VueScrollPickerValue = ScrollPickerValue\nexport type VueScrollPickerOption = ScrollPickerOption\nexport type VueScrollPickerOptionable<T> = ScrollPickerOptionable<T>\n"]}