{
  "version": 3,
  "sources": ["../../../utilities/dom/src/attrs.ts", "../../../utilities/core/src/array.ts", "../../../utilities/core/src/functions.ts", "../../../utilities/core/src/guard.ts", "../../../utilities/core/src/warning.ts", "../../../utilities/dom/src/next-tick.ts", "../../../utilities/dom/src/body-pointer-event.ts", "../../../../node_modules/compute-scroll-into-view/src/index.ts", "../../../../node_modules/scroll-into-view-if-needed/es/index.js", "../../../utilities/dom/src/listener.ts", "../../../utilities/dom/src/computed-style.ts", "../../../utilities/dom/src/query.ts", "../../../utilities/dom/src/scrollable.ts", "../../../utilities/dom/src/body-scroll-lock.ts", "../../../utilities/dom/src/dispatch-event.ts", "../../../utilities/dom/src/focus-event.ts", "../../../utilities/dom/src/focusable.ts", "../../../utilities/dom/src/keyboard-event.ts", "../../../utilities/dom/src/visually-hidden.ts", "../../../utilities/dom/src/live-region.ts", "../../../utilities/dom/src/mutation-observer.ts", "../../../utilities/dom/src/nodelist.ts", "../../../utilities/dom/src/text-selection.ts", "../../../utilities/dom/src/pointer-event.ts", "../../../utilities/dom/src/pointerlock.ts", "../../../../node_modules/@floating-ui/core/dist/floating-ui.core.esm.js", "../../../../node_modules/@floating-ui/dom/dist/floating-ui.dom.esm.js", "../../../utilities/dom/src/popper.middleware.ts", "../../../utilities/dom/src/rect-observer.ts", "../../../utilities/dom/src/popper.ts", "../../../types/src/prop-types.ts", "../../../utilities/core/src/array.ts", "../../../utilities/core/src/functions.ts", "../../../utilities/core/src/guard.ts", "../../../utilities/core/src/warning.ts", "../src/pin-input.dom.ts", "../src/pin-input.connect.ts", "../src/pin-input.machine.ts"],
  "sourcesContent": ["type Booleanish = boolean | \"true\" | \"false\"\n\nexport const dataAttr = (guard: boolean | undefined) => {\n  return (guard ? \"\" : undefined) as Booleanish\n}\n\nexport const ariaAttr = (guard: boolean | undefined) => {\n  return guard ? true : undefined\n}\n", "export function toArray<T>(v: T | T[] | undefined | null): T[] {\n  if (!v) return []\n  return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n  if (i > -1) v.splice(i, 1)\n  return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n  while (v.length > 0) v.pop()\n  return v\n}\n\nexport type IndexOptions = {\n  step?: number\n  loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n  const { step = 1, loop = true } = opts\n  const next = idx + step\n  const len = v.length\n  const last = len - 1\n  if (idx === -1) return step > 0 ? 0 : last\n  if (next < 0) return loop ? last : 0\n  if (next >= len) return loop ? 0 : idx > len ? len : idx\n  return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n  return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n  const { step = 1, loop = true } = opts\n  return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n  return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n  const res: T[][] = []\n  return v.reduce((rows, value, index) => {\n    if (index % size === 0) rows.push([value])\n    else last(rows)?.push(value)\n    return rows\n  }, res)\n}\n", "export const runIfFn = <T>(\n  v: T,\n  ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? ReturnType<T> : T => {\n  return typeof v === \"function\" ? v(...a) : v\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n  <T>(...fns: Array<(a: T) => T>) =>\n  (v: T) =>\n    fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n  <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n  (...a: Parameters<T>) => {\n    fns.forEach(function (fn) {\n      fn?.(...a)\n    })\n  }\n\nexport const uuid = (() => {\n  let id = 0\n  return () => {\n    id++\n    return id.toString(36)\n  }\n})()\n", "const platform = (v: RegExp) => isDom() && v.test(navigator.platform)\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\n\nexport const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => !!(typeof window !== \"undefined\")\nexport const isMac = () => platform(/^Mac/)\nexport const isIPhone = () => platform(/^iPhone/)\nexport const isIPad = () => platform(/^iPad/) || (isMac() && navigator.maxTouchPoints > 1)\nexport const isIos = () => isIPhone() || isIPad()\nexport const isSafari = () => ua(/^((?!chrome|android).)*safari/i)\nexport const isFirefox = () => ua(/^Firefox/)\nexport const isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/)\nexport const isApple = () => isMac() || isIos()\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && \"button\" in v\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && \"touches\" in v\nexport const isLeftClick = (v: MouseEvent | PointerEvent) => v.button === 0\nexport const isRightClick = (v: MouseEvent | PointerEvent) => v.button === 2\nexport const isModifiedEvent = (v: MouseEvent | PointerEvent | KeyboardEvent) =>\n  v.ctrlKey || v.altKey || v.metaKey || v.shiftKey\nexport const isCtrlKey = (v: KeyboardEvent) => (isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey)\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n  const m = a.length === 1 ? a[0] : a[1]\n  const c = a.length === 2 ? a[0] : true\n  if (c && process.env.NODE_ENV !== \"production\") {\n    console.warn(m)\n  }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n  const m = a.length === 1 ? a[0] : a[1]\n  const c = a.length === 2 ? a[0] : true\n  if (c && process.env.NODE_ENV !== \"production\") {\n    throw new Error(m)\n  }\n}\n", "export function nextTick(fn: VoidFunction) {\n  const set = new Set<VoidFunction>()\n  function raf(fn: VoidFunction) {\n    const id = globalThis.requestAnimationFrame(fn)\n    set.add(() => globalThis.cancelAnimationFrame(id))\n  }\n  raf(() => raf(fn))\n  return function cleanup() {\n    set.forEach(function (fn) {\n      fn()\n    })\n  }\n}\n\nexport function raf(fn: VoidFunction) {\n  const id = globalThis.requestAnimationFrame(fn)\n  return function cleanup() {\n    globalThis.cancelAnimationFrame(id)\n  }\n}\n\nexport function forceReflow() {\n  return document.body.offsetHeight\n}\n", "import { isLeftClick } from \"@ui-machines/utils\"\nimport { nextTick } from \"./next-tick\"\n\nlet changeCount = 0\nlet originalBodyPointerEvents: string\n\ntype PointerEventOptions = {\n  disabled: boolean\n  document?: Document\n}\n\nexport function preventBodyPointerEvents(el: HTMLElement | null, opts: Partial<PointerEventOptions> = {}) {\n  const { disabled = false, document: docProp } = opts\n  const doc: Document = docProp || document\n\n  let isTouchOrPenPressed = false\n  let isLeftClickPressed = false\n\n  function listen() {\n    const onPointerDown = (event: PointerEvent) => {\n      const isMouse = event.pointerType === \"mouse\"\n      isTouchOrPenPressed = !isMouse\n      isLeftClickPressed = isMouse && isLeftClick(event)\n    }\n\n    const onPointerUp = () => {\n      isTouchOrPenPressed = false\n      isLeftClickPressed = false\n    }\n\n    doc.addEventListener(\"pointerdown\", onPointerDown)\n    doc.addEventListener(\"pointerup\", onPointerUp)\n\n    return function () {\n      doc.removeEventListener(\"pointerdown\", onPointerDown)\n      doc.removeEventListener(\"pointerup\", onPointerUp)\n    }\n  }\n\n  function reset() {\n    changeCount--\n    if (changeCount === 0) {\n      doc.body.style.pointerEvents = originalBodyPointerEvents\n    }\n    if (el) {\n      el.style.pointerEvents = \"\"\n    }\n  }\n\n  function apply() {\n    if (disabled) return\n\n    if (changeCount === 0) {\n      originalBodyPointerEvents = doc.body.style.pointerEvents\n    }\n\n    doc.body.style.pointerEvents = \"none\"\n    if (el) {\n      el.style.pointerEvents = \"auto\"\n    }\n\n    changeCount++\n\n    return function () {\n      if (isTouchOrPenPressed) {\n        doc.addEventListener(\"click\", reset, { once: true })\n      } else if (isLeftClickPressed) {\n        doc.addEventListener(\"pointerup\", reset, { once: true })\n      } else {\n        reset()\n      }\n    }\n  }\n\n  const cleanups: Array<VoidFunction | undefined> = []\n  cleanups.push(apply())\n  nextTick(() => {\n    cleanups.push(listen())\n  })\n\n  return function () {\n    cleanups.forEach((cleanup) => cleanup?.())\n  }\n}\n", "// Compute what scrolling needs to be done on required scrolling boxes for target to be in view\n\n// The type names here are named after the spec to make it easier to find more information around what they mean:\n// To reduce churn and reduce things that need be maintained things from the official TS DOM library is used here\n// https://drafts.csswg.org/cssom-view/\n\n// For a definition on what is \"block flow direction\" exactly, check this: https://drafts.csswg.org/css-writing-modes-4/#block-flow-direction\n\n// add support for visualViewport object currently implemented in chrome\ninterface visualViewport {\n  height: number\n  width: number\n}\n\ntype ScrollLogicalPosition = 'start' | 'center' | 'end' | 'nearest'\n// This new option is tracked in this PR, which is the most likely candidate at the time: https://github.com/w3c/csswg-drafts/pull/1805\ntype ScrollMode = 'always' | 'if-needed'\n// New option that skips auto-scrolling all nodes with overflow: hidden set\n// See FF implementation: https://hg.mozilla.org/integration/fx-team/rev/c48c3ec05012#l7.18\ntype SkipOverflowHiddenElements = boolean\n\ninterface Options {\n  block?: ScrollLogicalPosition\n  inline?: ScrollLogicalPosition\n  scrollMode?: ScrollMode\n  boundary?: CustomScrollBoundary\n  skipOverflowHiddenElements?: SkipOverflowHiddenElements\n}\n\n// Custom behavior, not in any spec\ntype CustomScrollBoundaryCallback = (parent: Element) => boolean\ntype CustomScrollBoundary = Element | CustomScrollBoundaryCallback | null\ninterface CustomScrollAction {\n  el: Element\n  top: number\n  left: number\n}\n\n// @TODO better shadowdom test, 11 = document fragment\nfunction isElement(el: any): el is Element {\n  return typeof el === 'object' && el != null && el.nodeType === 1\n}\n\nfunction canOverflow(\n  overflow: string | null,\n  skipOverflowHiddenElements?: boolean\n) {\n  if (skipOverflowHiddenElements && overflow === 'hidden') {\n    return false\n  }\n\n  return overflow !== 'visible' && overflow !== 'clip'\n}\n\nfunction getFrameElement(el: Element) {\n  if (!el.ownerDocument || !el.ownerDocument.defaultView) {\n    return null\n  }\n\n  try {\n    return el.ownerDocument.defaultView.frameElement\n  } catch (e) {\n    return null\n  }\n}\n\nfunction isHiddenByFrame(el: Element): boolean {\n  const frame = getFrameElement(el)\n  if (!frame) {\n    return false\n  }\n\n  return (\n    frame.clientHeight < el.scrollHeight || frame.clientWidth < el.scrollWidth\n  )\n}\n\nfunction isScrollable(el: Element, skipOverflowHiddenElements?: boolean) {\n  if (el.clientHeight < el.scrollHeight || el.clientWidth < el.scrollWidth) {\n    const style = getComputedStyle(el, null)\n    return (\n      canOverflow(style.overflowY, skipOverflowHiddenElements) ||\n      canOverflow(style.overflowX, skipOverflowHiddenElements) ||\n      isHiddenByFrame(el)\n    )\n  }\n\n  return false\n}\n/**\n * Find out which edge to align against when logical scroll position is \"nearest\"\n * Interesting fact: \"nearest\" works similarily to \"if-needed\", if the element is fully visible it will not scroll it\n *\n * Legends:\n * \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510 \u250F \u2501 \u2501 \u2501 \u2513\n * \u2502 target \u2502   frame\n * \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518 \u2517 \u2501 \u2501 \u2501 \u251B\n */\nfunction alignNearest(\n  scrollingEdgeStart: number,\n  scrollingEdgeEnd: number,\n  scrollingSize: number,\n  scrollingBorderStart: number,\n  scrollingBorderEnd: number,\n  elementEdgeStart: number,\n  elementEdgeEnd: number,\n  elementSize: number\n) {\n  /**\n   * If element edge A and element edge B are both outside scrolling box edge A and scrolling box edge B\n   *\n   *          \u250C\u2500\u2500\u2510\n   *        \u250F\u2501\u2502\u2501\u2501\u2502\u2501\u2513\n   *          \u2502  \u2502\n   *        \u2503 \u2502  \u2502 \u2503        do nothing\n   *          \u2502  \u2502\n   *        \u2517\u2501\u2502\u2501\u2501\u2502\u2501\u251B\n   *          \u2514\u2500\u2500\u2518\n   *\n   *  If element edge C and element edge D are both outside scrolling box edge C and scrolling box edge D\n   *\n   *    \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n   *   \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n   *   \u2502\u2503         \u2503\u2502        do nothing\n   *   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n   *    \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n   */\n  if (\n    (elementEdgeStart < scrollingEdgeStart &&\n      elementEdgeEnd > scrollingEdgeEnd) ||\n    (elementEdgeStart > scrollingEdgeStart && elementEdgeEnd < scrollingEdgeEnd)\n  ) {\n    return 0\n  }\n\n  /**\n   * If element edge A is outside scrolling box edge A and element height is less than scrolling box height\n   *\n   *          \u250C\u2500\u2500\u2510\n   *        \u250F\u2501\u2502\u2501\u2501\u2502\u2501\u2513         \u250F\u2501\u250C\u2501\u2501\u2510\u2501\u2513\n   *          \u2514\u2500\u2500\u2518             \u2502  \u2502\n   *  from  \u2503      \u2503     to  \u2503 \u2514\u2500\u2500\u2518 \u2503\n   *\n   *        \u2517\u2501 \u2501\u2501 \u2501\u251B         \u2517\u2501 \u2501\u2501 \u2501\u251B\n   *\n   * If element edge B is outside scrolling box edge B and element height is greater than scrolling box height\n   *\n   *        \u250F\u2501 \u2501\u2501 \u2501\u2513         \u250F\u2501\u250C\u2501\u2501\u2510\u2501\u2513\n   *                           \u2502  \u2502\n   *  from  \u2503 \u250C\u2500\u2500\u2510 \u2503     to  \u2503 \u2502  \u2502 \u2503\n   *          \u2502  \u2502             \u2502  \u2502\n   *        \u2517\u2501\u2502\u2501\u2501\u2502\u2501\u251B         \u2517\u2501\u2502\u2501\u2501\u2502\u2501\u251B\n   *          \u2502  \u2502             \u2514\u2500\u2500\u2518\n   *          \u2502  \u2502\n   *          \u2514\u2500\u2500\u2518\n   *\n   * If element edge C is outside scrolling box edge C and element width is less than scrolling box width\n   *\n   *       from                 to\n   *    \u250F \u2501 \u2501 \u2501 \u2501 \u2513         \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n   *  \u250C\u2500\u2500\u2500\u2510                 \u250C\u2500\u2500\u2500\u2510\n   *  \u2502 \u2503 \u2502       \u2503         \u2503   \u2502     \u2503\n   *  \u2514\u2500\u2500\u2500\u2518                 \u2514\u2500\u2500\u2500\u2518\n   *    \u2517 \u2501 \u2501 \u2501 \u2501 \u251B         \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n   *\n   * If element edge D is outside scrolling box edge D and element width is greater than scrolling box width\n   *\n   *       from                 to\n   *    \u250F \u2501 \u2501 \u2501 \u2501 \u2513         \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n   *        \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510   \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n   *    \u2503   \u2502     \u2503     \u2502   \u2503         \u2503 \u2502\n   *        \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518   \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n   *    \u2517 \u2501 \u2501 \u2501 \u2501 \u251B         \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n   */\n  if (\n    (elementEdgeStart <= scrollingEdgeStart && elementSize <= scrollingSize) ||\n    (elementEdgeEnd >= scrollingEdgeEnd && elementSize >= scrollingSize)\n  ) {\n    return elementEdgeStart - scrollingEdgeStart - scrollingBorderStart\n  }\n\n  /**\n   * If element edge B is outside scrolling box edge B and element height is less than scrolling box height\n   *\n   *        \u250F\u2501 \u2501\u2501 \u2501\u2513         \u250F\u2501 \u2501\u2501 \u2501\u2513\n   *\n   *  from  \u2503      \u2503     to  \u2503 \u250C\u2500\u2500\u2510 \u2503\n   *          \u250C\u2500\u2500\u2510             \u2502  \u2502\n   *        \u2517\u2501\u2502\u2501\u2501\u2502\u2501\u251B         \u2517\u2501\u2514\u2501\u2501\u2518\u2501\u251B\n   *          \u2514\u2500\u2500\u2518\n   *\n   * If element edge A is outside scrolling box edge A and element height is greater than scrolling box height\n   *\n   *          \u250C\u2500\u2500\u2510\n   *          \u2502  \u2502\n   *          \u2502  \u2502             \u250C\u2500\u2500\u2510\n   *        \u250F\u2501\u2502\u2501\u2501\u2502\u2501\u2513         \u250F\u2501\u2502\u2501\u2501\u2502\u2501\u2513\n   *          \u2502  \u2502             \u2502  \u2502\n   *  from  \u2503 \u2514\u2500\u2500\u2518 \u2503     to  \u2503 \u2502  \u2502 \u2503\n   *                           \u2502  \u2502\n   *        \u2517\u2501 \u2501\u2501 \u2501\u251B         \u2517\u2501\u2514\u2501\u2501\u2518\u2501\u251B\n   *\n   * If element edge C is outside scrolling box edge C and element width is greater than scrolling box width\n   *\n   *           from                 to\n   *        \u250F \u2501 \u2501 \u2501 \u2501 \u2513         \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n   *  \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510           \u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n   *  \u2502     \u2503     \u2502   \u2503       \u2502 \u2503         \u2503\n   *  \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518           \u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\n   *        \u2517 \u2501 \u2501 \u2501 \u2501 \u251B         \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n   *\n   * If element edge D is outside scrolling box edge D and element width is less than scrolling box width\n   *\n   *           from                 to\n   *        \u250F \u2501 \u2501 \u2501 \u2501 \u2513         \u250F \u2501 \u2501 \u2501 \u2501 \u2513\n   *                \u250C\u2500\u2500\u2500\u2510             \u250C\u2500\u2500\u2500\u2510\n   *        \u2503       \u2502 \u2503 \u2502       \u2503     \u2502   \u2503\n   *                \u2514\u2500\u2500\u2500\u2518             \u2514\u2500\u2500\u2500\u2518\n   *        \u2517 \u2501 \u2501 \u2501 \u2501 \u251B         \u2517 \u2501 \u2501 \u2501 \u2501 \u251B\n   *\n   */\n  if (\n    (elementEdgeEnd > scrollingEdgeEnd && elementSize < scrollingSize) ||\n    (elementEdgeStart < scrollingEdgeStart && elementSize > scrollingSize)\n  ) {\n    return elementEdgeEnd - scrollingEdgeEnd + scrollingBorderEnd\n  }\n\n  return 0\n}\n\nexport default (target: Element, options: Options): CustomScrollAction[] => {\n  //TODO: remove this hack when microbundle will support typescript >= 4.0\n  const windowWithViewport = (window as unknown) as Window & {\n    visualViewport: visualViewport\n  }\n\n  const {\n    scrollMode,\n    block,\n    inline,\n    boundary,\n    skipOverflowHiddenElements,\n  } = options\n  // Allow using a callback to check the boundary\n  // The default behavior is to check if the current target matches the boundary element or not\n  // If undefined it'll check that target is never undefined (can happen as we recurse up the tree)\n  const checkBoundary =\n    typeof boundary === 'function' ? boundary : (node: any) => node !== boundary\n\n  if (!isElement(target)) {\n    throw new TypeError('Invalid target')\n  }\n\n  // Used to handle the top most element that can be scrolled\n  const scrollingElement = document.scrollingElement || document.documentElement\n\n  // Collect all the scrolling boxes, as defined in the spec: https://drafts.csswg.org/cssom-view/#scrolling-box\n  const frames: Element[] = []\n  let cursor: Element | null = target\n  while (isElement(cursor) && checkBoundary(cursor)) {\n    // Move cursor to parent\n    cursor = cursor.parentElement\n\n    // Stop when we reach the viewport\n    if (cursor === scrollingElement) {\n      frames.push(cursor)\n      break\n    }\n\n    // Skip document.body if it's not the scrollingElement and documentElement isn't independently scrollable\n    if (\n      cursor != null &&\n      cursor === document.body &&\n      isScrollable(cursor) &&\n      !isScrollable(document.documentElement)\n    ) {\n      continue\n    }\n\n    // Now we check if the element is scrollable, this code only runs if the loop haven't already hit the viewport or a custom boundary\n    if (cursor != null && isScrollable(cursor, skipOverflowHiddenElements)) {\n      frames.push(cursor)\n    }\n  }\n\n  // Support pinch-zooming properly, making sure elements scroll into the visual viewport\n  // Browsers that don't support visualViewport will report the layout viewport dimensions on document.documentElement.clientWidth/Height\n  // and viewport dimensions on window.innerWidth/Height\n  // https://www.quirksmode.org/mobile/viewports2.html\n  // https://bokand.github.io/viewport/index.html\n  const viewportWidth = windowWithViewport.visualViewport\n    ? windowWithViewport.visualViewport.width\n    : innerWidth\n  const viewportHeight = windowWithViewport.visualViewport\n    ? windowWithViewport.visualViewport.height\n    : innerHeight\n\n  // Newer browsers supports scroll[X|Y], page[X|Y]Offset is\n  const viewportX = window.scrollX || pageXOffset\n  const viewportY = window.scrollY || pageYOffset\n\n  const {\n    height: targetHeight,\n    width: targetWidth,\n    top: targetTop,\n    right: targetRight,\n    bottom: targetBottom,\n    left: targetLeft,\n  } = target.getBoundingClientRect()\n\n  // These values mutate as we loop through and generate scroll coordinates\n  let targetBlock: number =\n    block === 'start' || block === 'nearest'\n      ? targetTop\n      : block === 'end'\n      ? targetBottom\n      : targetTop + targetHeight / 2 // block === 'center\n  let targetInline: number =\n    inline === 'center'\n      ? targetLeft + targetWidth / 2\n      : inline === 'end'\n      ? targetRight\n      : targetLeft // inline === 'start || inline === 'nearest\n\n  // Collect new scroll positions\n  const computations: CustomScrollAction[] = []\n  // In chrome there's no longer a difference between caching the `frames.length` to a var or not, so we don't in this case (size > speed anyways)\n  for (let index = 0; index < frames.length; index++) {\n    const frame = frames[index]\n\n    // @TODO add a shouldScroll hook here that allows userland code to take control\n\n    const {\n      height,\n      width,\n      top,\n      right,\n      bottom,\n      left,\n    } = frame.getBoundingClientRect()\n\n    // If the element is already visible we can end it here\n    // @TODO targetBlock and targetInline should be taken into account to be compliant with https://github.com/w3c/csswg-drafts/pull/1805/files#diff-3c17f0e43c20f8ecf89419d49e7ef5e0R1333\n    if (\n      scrollMode === 'if-needed' &&\n      targetTop >= 0 &&\n      targetLeft >= 0 &&\n      targetBottom <= viewportHeight &&\n      targetRight <= viewportWidth &&\n      targetTop >= top &&\n      targetBottom <= bottom &&\n      targetLeft >= left &&\n      targetRight <= right\n    ) {\n      // Break the loop and return the computations for things that are not fully visible\n      return computations\n    }\n\n    const frameStyle = getComputedStyle(frame)\n    const borderLeft = parseInt(frameStyle.borderLeftWidth as string, 10)\n    const borderTop = parseInt(frameStyle.borderTopWidth as string, 10)\n    const borderRight = parseInt(frameStyle.borderRightWidth as string, 10)\n    const borderBottom = parseInt(frameStyle.borderBottomWidth as string, 10)\n\n    let blockScroll: number = 0\n    let inlineScroll: number = 0\n\n    // The property existance checks for offfset[Width|Height] is because only HTMLElement objects have them, but any Element might pass by here\n    // @TODO find out if the \"as HTMLElement\" overrides can be dropped\n    const scrollbarWidth =\n      'offsetWidth' in frame\n        ? (frame as HTMLElement).offsetWidth -\n          (frame as HTMLElement).clientWidth -\n          borderLeft -\n          borderRight\n        : 0\n    const scrollbarHeight =\n      'offsetHeight' in frame\n        ? (frame as HTMLElement).offsetHeight -\n          (frame as HTMLElement).clientHeight -\n          borderTop -\n          borderBottom\n        : 0\n\n    if (scrollingElement === frame) {\n      // Handle viewport logic (document.documentElement or document.body)\n\n      if (block === 'start') {\n        blockScroll = targetBlock\n      } else if (block === 'end') {\n        blockScroll = targetBlock - viewportHeight\n      } else if (block === 'nearest') {\n        blockScroll = alignNearest(\n          viewportY,\n          viewportY + viewportHeight,\n          viewportHeight,\n          borderTop,\n          borderBottom,\n          viewportY + targetBlock,\n          viewportY + targetBlock + targetHeight,\n          targetHeight\n        )\n      } else {\n        // block === 'center' is the default\n        blockScroll = targetBlock - viewportHeight / 2\n      }\n\n      if (inline === 'start') {\n        inlineScroll = targetInline\n      } else if (inline === 'center') {\n        inlineScroll = targetInline - viewportWidth / 2\n      } else if (inline === 'end') {\n        inlineScroll = targetInline - viewportWidth\n      } else {\n        // inline === 'nearest' is the default\n        inlineScroll = alignNearest(\n          viewportX,\n          viewportX + viewportWidth,\n          viewportWidth,\n          borderLeft,\n          borderRight,\n          viewportX + targetInline,\n          viewportX + targetInline + targetWidth,\n          targetWidth\n        )\n      }\n\n      // Apply scroll position offsets and ensure they are within bounds\n      // @TODO add more test cases to cover this 100%\n      blockScroll = Math.max(0, blockScroll + viewportY)\n      inlineScroll = Math.max(0, inlineScroll + viewportX)\n    } else {\n      // Handle each scrolling frame that might exist between the target and the viewport\n\n      if (block === 'start') {\n        blockScroll = targetBlock - top - borderTop\n      } else if (block === 'end') {\n        blockScroll = targetBlock - bottom + borderBottom + scrollbarHeight\n      } else if (block === 'nearest') {\n        blockScroll = alignNearest(\n          top,\n          bottom,\n          height,\n          borderTop,\n          borderBottom + scrollbarHeight,\n          targetBlock,\n          targetBlock + targetHeight,\n          targetHeight\n        )\n      } else {\n        // block === 'center' is the default\n        blockScroll = targetBlock - (top + height / 2) + scrollbarHeight / 2\n      }\n\n      if (inline === 'start') {\n        inlineScroll = targetInline - left - borderLeft\n      } else if (inline === 'center') {\n        inlineScroll = targetInline - (left + width / 2) + scrollbarWidth / 2\n      } else if (inline === 'end') {\n        inlineScroll = targetInline - right + borderRight + scrollbarWidth\n      } else {\n        // inline === 'nearest' is the default\n        inlineScroll = alignNearest(\n          left,\n          right,\n          width,\n          borderLeft,\n          borderRight + scrollbarWidth,\n          targetInline,\n          targetInline + targetWidth,\n          targetWidth\n        )\n      }\n\n      const { scrollLeft, scrollTop } = frame\n      // Ensure scroll coordinates are not out of bounds while applying scroll offsets\n      blockScroll = Math.max(\n        0,\n        Math.min(\n          scrollTop + blockScroll,\n          frame.scrollHeight - height + scrollbarHeight\n        )\n      )\n      inlineScroll = Math.max(\n        0,\n        Math.min(\n          scrollLeft + inlineScroll,\n          frame.scrollWidth - width + scrollbarWidth\n        )\n      )\n\n      // Cache the offset so that parent frames can scroll this into view correctly\n      targetBlock += scrollTop - blockScroll\n      targetInline += scrollLeft - inlineScroll\n    }\n\n    computations.push({ el: frame, top: blockScroll, left: inlineScroll })\n  }\n\n  return computations\n}\n", "import compute from 'compute-scroll-into-view';\n\nfunction isOptionsObject(options) {\n  return options === Object(options) && Object.keys(options).length !== 0;\n}\n\nfunction defaultBehavior(actions, behavior) {\n  if (behavior === void 0) {\n    behavior = 'auto';\n  }\n\n  var canSmoothScroll = ('scrollBehavior' in document.body.style);\n  actions.forEach(function (_ref) {\n    var el = _ref.el,\n        top = _ref.top,\n        left = _ref.left;\n\n    if (el.scroll && canSmoothScroll) {\n      el.scroll({\n        top: top,\n        left: left,\n        behavior: behavior\n      });\n    } else {\n      el.scrollTop = top;\n      el.scrollLeft = left;\n    }\n  });\n}\n\nfunction getOptions(options) {\n  if (options === false) {\n    return {\n      block: 'end',\n      inline: 'nearest'\n    };\n  }\n\n  if (isOptionsObject(options)) {\n    return options;\n  }\n\n  return {\n    block: 'start',\n    inline: 'nearest'\n  };\n}\n\nfunction scrollIntoView(target, options) {\n  var targetIsDetached = !target.ownerDocument.documentElement.contains(target);\n\n  if (isOptionsObject(options) && typeof options.behavior === 'function') {\n    return options.behavior(targetIsDetached ? [] : compute(target, options));\n  }\n\n  if (targetIsDetached) {\n    return;\n  }\n\n  var computeOptions = getOptions(options);\n  return defaultBehavior(compute(target, computeOptions), computeOptions.behavior);\n}\n\nexport default scrollIntoView;", "export const t = (v: any) => Object.prototype.toString.call(v).slice(8, -1)\n\nexport const isRef = (v: any): v is RefTarget => {\n  return t(v) === \"Object\" && \"current\" in v\n}\n\nexport const runIfFn = (fn: any): HTMLElement | null => {\n  return t(fn) === \"Function\" ? fn() : fn\n}\n\nconst isTouchEvent = (v: Event): v is TouchEvent => {\n  return t(v) === \"Object\" && !!(v as TouchEvent).touches\n}\n\nconst fallback = { pageX: 0, pageY: 0, clientX: 0, clientY: 0 }\n\nexport function extractInfo<T extends AnyPointerEvent = AnyPointerEvent>(event: T, type: \"page\" | \"client\" = \"page\") {\n  const point = isTouchEvent(event) ? event.touches[0] || event.changedTouches[0] || fallback : event\n  return {\n    point: {\n      x: point[`${type}X`],\n      y: point[`${type}Y`],\n    },\n  }\n}\n\nexport function addDomEvent<K extends keyof EventMap>(\n  target: DOMEventTarget,\n  event: K,\n  listener: (event: EventMap[K]) => void,\n  options?: boolean | AddEventListenerOptions,\n) {\n  const node = isRef(target) ? target.current : runIfFn(target)\n  node?.addEventListener(event, listener as any, options)\n  return () => node?.removeEventListener(event, listener as any, options)\n}\n\nexport function addPointerEvent<K extends keyof EventMap>(\n  target: DOMEventTarget,\n  event: K,\n  listener: (event: EventMap[K], info: PointerEventInfo) => void,\n  options?: boolean | AddEventListenerOptions,\n) {\n  return addDomEvent(target, getEventName(event), wrapHandler(listener, event === \"pointerdown\"), options)\n}\n\nfunction wrapHandler<E extends EventMap[keyof EventMap]>(\n  fn: (event: E, info: PointerEventInfo) => void,\n  filter = false,\n) {\n  const listener: EventListener = (event: any) => {\n    fn(event, extractInfo(event))\n  }\n  return filter ? filterPrimaryPointer(listener) : listener\n}\n\nfunction filterPrimaryPointer(fn: EventListener): EventListener {\n  return (event: Event) => {\n    const win = ((event as UIEvent).view ?? window) as typeof window\n    const isMouseEvent = event instanceof win.MouseEvent\n    const isPrimary = !isMouseEvent || (isMouseEvent && (event as MouseEvent).button === 0)\n    if (isPrimary) {\n      fn(event)\n    }\n  }\n}\n\nexport function extractClientInfo(event: AnyPointerEvent) {\n  return extractInfo(event, \"client\")\n}\n\nconst supportsPointerEvent = () => typeof window !== \"undefined\" && window.onpointerdown === null\nconst supportsTouchEvent = () => typeof window !== \"undefined\" && window.ontouchstart === null\nconst supportsMouseEvent = () => typeof window !== \"undefined\" && window.onmousedown === null\n\nexport function getEventName(evt: keyof EventMap): keyof EventMap {\n  if (supportsPointerEvent()) return evt\n  if (supportsTouchEvent()) return touchEventNames[evt]\n  if (supportsMouseEvent()) return mouseEventNames[evt]\n  return evt\n}\n\nexport interface EventMap extends DocumentEventMap, WindowEventMap, HTMLElementEventMap {}\n\nexport type DOMTarget = Document | HTMLElement | EventTarget | null\nexport type AnyPointerEvent = MouseEvent | TouchEvent | PointerEvent\nexport type RefTarget = { current: HTMLElement | null }\nexport type DOMEventTarget = (() => DOMTarget) | DOMTarget | RefTarget\nexport type EventListenerOptions = boolean | AddEventListenerOptions\nexport interface PointerEventInfo {\n  point: { x: number; y: number }\n}\nexport type EventListenerWithPointInfo<T extends AnyPointerEvent = AnyPointerEvent> = (\n  event: T,\n  info: PointerEventInfo,\n) => void\n\ninterface PointerNameMap {\n  pointerdown: string\n  pointermove: string\n  pointerup: string\n  pointercancel: string\n  pointerover?: string\n  pointerout?: string\n  pointerenter?: string\n  pointerleave?: string\n}\n\nconst mouseEventNames: PointerNameMap = {\n  pointerdown: \"mousedown\",\n  pointermove: \"mousemove\",\n  pointerup: \"mouseup\",\n  pointercancel: \"mousecancel\",\n  pointerover: \"mouseover\",\n  pointerout: \"mouseout\",\n  pointerenter: \"mouseenter\",\n  pointerleave: \"mouseleave\",\n}\n\nconst touchEventNames: PointerNameMap = {\n  pointerdown: \"touchstart\",\n  pointermove: \"touchmove\",\n  pointerup: \"touchend\",\n  pointercancel: \"touchcancel\",\n}\n", "type Key = keyof CSSStyleDeclaration | (string & {})\ntype Styles = Record<Key, any>\ntype El = HTMLElement | null | undefined\n\nconst styleCache: WeakMap<HTMLElement, Styles> = new WeakMap()\n\nexport function getComputedStyle(el: El): Styles {\n  if (!el) return {} as Styles\n  let style: Styles | undefined = styleCache.get(el)\n  if (!style) {\n    const win = el?.ownerDocument.defaultView ?? window\n    style = win.getComputedStyle(el) as Styles\n    styleCache.set(el, style)\n  }\n  return style\n}\n\nexport function setElementStyle(el: El, styles: Styles) {\n  if (!el) return\n  for (const key in styles) el.style.setProperty(key, styles[key])\n}\n\nexport function checkElementStyle(el: El, k: Key, v: string | string[]) {\n  if (!el) return false\n  const style = getComputedStyle(el)\n  const val = Array.isArray(v) ? v : [v]\n  const vv = style?.getPropertyValue(k)\n  return vv !== null ? val.includes(vv) : false\n}\n", "export function getOwnerDocument(el: HTMLElement | Window) {\n  if (isWindow(el)) return el.document\n  return el?.ownerDocument ?? document\n}\n\nexport function getOwnerWindow(el: HTMLElement) {\n  return el?.ownerDocument.defaultView ?? window\n}\n\nexport function getDocumentElement(el: HTMLElement | Window): HTMLElement {\n  return getOwnerDocument(el).documentElement\n}\n\nexport function getNodeName(node: HTMLElement | Window): string {\n  return isWindow(node) ? \"\" : node ? node.localName || \"\" : \"\"\n}\n\nexport function getEventWindow(event: UIEvent) {\n  if (event.view) return event.view\n  let target = event.currentTarget\n  if (target != null) return getOwnerWindow(target as HTMLElement)\n  return window\n}\n\nexport function getParent(el: HTMLElement): HTMLElement {\n  const doc = getOwnerDocument(el)\n  if (getNodeName(el) === \"html\") return el\n  return el.assignedSlot || el.parentElement || doc.documentElement\n}\n\ntype Node = HTMLElement | EventTarget | null\n\nexport function contains(parent: Node | undefined, child: Node) {\n  if (!parent) return false\n  return parent === child || (isHTMLElement(parent) && isHTMLElement(child) && parent.contains(child))\n}\n\nexport function isHTMLElement(v: any): v is HTMLElement {\n  return typeof v === \"object\" && v?.nodeType === Node.ELEMENT_NODE && typeof v?.nodeName === \"string\"\n}\n\nexport function isWindow(value: any): value is Window {\n  return value?.toString() === \"[object Window]\"\n}\n\nexport const isDisabled = (el: HTMLElement | null): boolean => {\n  return el?.getAttribute(\"disabled\") != null || !!el?.getAttribute(\"aria-disabled\") === true\n}\n\nexport function getNativeEvent<E>(\n  event: E,\n): React.ChangeEvent<any> extends E ? InputEvent : E extends React.SyntheticEvent<any, infer T> ? T : never {\n  return (event as any).nativeEvent ?? event\n}\n", "import { getComputedStyle } from \"./computed-style\"\nimport { getNodeName, getOwnerDocument, getOwnerWindow, getParent, isHTMLElement, isWindow } from \"./query\"\n\nexport function isScrollParent(el: HTMLElement): boolean {\n  const { overflow, overflowX, overflowY } = getComputedStyle(el)\n  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX)\n}\n\nexport function getScrollParent(el: HTMLElement): HTMLElement {\n  if ([\"html\", \"body\", \"#document\"].includes(getNodeName(el))) {\n    return getOwnerDocument(el).body\n  }\n\n  if (isHTMLElement(el) && isScrollParent(el)) {\n    return el\n  }\n\n  return getScrollParent(getParent(el))\n}\n\ntype Target = Array<VisualViewport | Window | HTMLElement>\n\nexport function getScrollParents(el: HTMLElement, list: Target = []): Target {\n  const scrollParent = getScrollParent(el)\n  const isBody = scrollParent === getOwnerDocument(el).body\n  const win = getOwnerWindow(scrollParent)\n\n  const target = isBody\n    ? ([win] as Target).concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : [])\n    : scrollParent\n\n  const parents = list.concat(target)\n  if (isBody) return parents\n\n  return parents.concat(getScrollParents(getParent(<HTMLElement>target)))\n}\n\nexport function getScrollOffset(el: HTMLElement) {\n  if (isWindow(el)) {\n    return { scrollLeft: el.scrollX, scrollTop: el.scrollY }\n  }\n\n  return { scrollLeft: el.scrollLeft, scrollTop: el.scrollTop }\n}\n", "import { isDom, isIos, noop, pipe } from \"@ui-machines/utils\"\nimport scrollIntoView from \"scroll-into-view-if-needed\"\nimport { addDomEvent } from \"./listener\"\nimport { getScrollParent } from \"./scrollable\"\n\ninterface PreventScrollOptions {\n  disabled?: boolean\n  allowPinchZoom?: boolean\n  document?: Document\n}\n\n// HTML input types that do not cause the software keyboard to appear.\nconst nonTextInputTypes = new Set([\"checkbox\", \"radio\", \"range\", \"color\", \"file\", \"image\", \"button\", \"submit\", \"reset\"])\n\nexport function preventBodyScroll(opts?: PreventScrollOptions) {\n  const { document: docProp, disabled = false, allowPinchZoom } = opts ?? {}\n\n  const doc = docProp ?? document\n  const win = doc?.defaultView ?? window\n\n  const viewport = isDom() ? win.visualViewport : null\n  const docEl = doc.documentElement\n\n  function preventScrollStandard() {\n    const fn = pipe(\n      setStyle(docEl, \"paddingRight\", `${win.innerWidth - docEl.clientWidth}px`),\n      setStyle(docEl, \"overflow\", \"hidden\"),\n    )\n    return () => fn?.()\n  }\n\n  function preventScrollMobileSafari() {\n    let scrollable: HTMLElement | undefined\n    let lastY = 0\n\n    let onTouchStart = (e: TouchEvent) => {\n      scrollable = getScrollParent(e.target as HTMLElement)\n\n      if (scrollable === docEl && scrollable === doc.body) {\n        return\n      }\n      lastY = e.changedTouches[0].pageY\n    }\n\n    let onTouchMove = (e: TouchEvent) => {\n      if (e.touches.length === 2 && allowPinchZoom) return\n\n      if (!scrollable || scrollable === docEl || scrollable === doc.body) {\n        e.preventDefault()\n        return\n      }\n\n      let y = e.changedTouches[0].pageY\n      let scrollTop = scrollable.scrollTop\n      let bottom = scrollable.scrollHeight - scrollable.clientHeight\n\n      if ((scrollTop <= 0 && y > lastY) || (scrollTop >= bottom && y < lastY)) {\n        e.preventDefault()\n      }\n\n      lastY = y\n    }\n\n    let onTouchEnd = (e: TouchEvent) => {\n      let target = e.target as HTMLElement\n      if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) {\n        e.preventDefault()\n        target.style.transform = \"translateY(-2000px)\"\n        target.focus()\n        win.requestAnimationFrame(() => {\n          target.style.transform = \"\"\n        })\n      }\n    }\n\n    let onFocus = (e: FocusEvent) => {\n      let target = e.target as HTMLElement\n      if (target instanceof win.HTMLInputElement && !nonTextInputTypes.has(target.type)) {\n        target.style.transform = \"translateY(-2000px)\"\n        win.requestAnimationFrame(() => {\n          target.style.transform = \"\"\n          if (!viewport) return\n\n          if (viewport.height < win.innerHeight) {\n            win.requestAnimationFrame(function () {\n              scrollIntoView(target, { scrollMode: \"if-needed\" })\n            })\n          } else {\n            viewport.addEventListener(\n              \"resize\",\n              function () {\n                scrollIntoView(target, { scrollMode: \"if-needed\" })\n              },\n              { once: true },\n            )\n          }\n        })\n      }\n    }\n\n    let onWindowScroll = () => {\n      win.scrollTo(0, 0)\n    }\n\n    let scrollX = win.scrollX\n    let scrollY = win.scrollY\n    let restoreStyles = pipe(\n      setStyle(docEl, \"paddingRight\", `${win.innerWidth - docEl.clientWidth}px`),\n      setStyle(docEl, \"overflow\", \"hidden\"),\n      setStyle(doc.body, \"marginTop\", `-${scrollY}px`),\n    )\n\n    win.scrollTo(0, 0)\n\n    let removeEvents = pipe(\n      addDomEvent(doc, \"touchstart\", onTouchStart, { passive: false, capture: true }),\n      addDomEvent(doc, \"touchmove\", onTouchMove, { passive: false, capture: true }),\n      addDomEvent(doc, \"touchend\", onTouchEnd, { passive: false, capture: true }),\n      addDomEvent(doc, \"focus\", onFocus, true),\n      addDomEvent(win, \"scroll\", onWindowScroll),\n    )\n\n    return () => {\n      restoreStyles()\n      removeEvents()\n      win.scrollTo(scrollX, scrollY)\n    }\n  }\n\n  if (disabled) return noop\n  return isIos() ? preventScrollMobileSafari() : preventScrollStandard()\n}\n\nfunction setStyle(el: HTMLElement, key: string, value: string) {\n  let cur = el.style[key]\n  el.style[key] = value\n  return () => {\n    el.style[key] = cur\n  }\n}\n\n// Backup lib: https://github.com/hanai/html-body-scroll-lock\n", "import { getOwnerWindow } from \"./query\"\n\ntype DispatchEventOptions = {\n  type?: \"input\" | \"checked\"\n  key?: string\n  value: string | number | boolean\n  hidden?: boolean\n}\n\nexport function dispatchInputEvent(el: HTMLElement, opts: DispatchEventOptions) {\n  const { key = \"value\", value, type = \"input\", hidden = true } = opts\n  const win = getOwnerWindow(el)\n  if (!(el instanceof win.HTMLInputElement)) return\n\n  if (hidden) {\n    el.type = \"text\"\n    el.hidden = true\n  }\n\n  const proto = win.HTMLInputElement.prototype\n  const set = Object.getOwnPropertyDescriptor(proto, key)?.set\n\n  set?.call(el, value)\n\n  const evt = new win.Event(type, { bubbles: true })\n  el.dispatchEvent(evt)\n\n  if (hidden) {\n    el.type = \"hidden\"\n    el.hidden = false\n  }\n}\n", "/**\n * Determine if the blur event within an element is valid\n */\nexport function validateBlur(event: Event, opts: Options) {\n  const exclude = Array.isArray(opts.exclude) ? opts.exclude : [opts.exclude]\n  const relatedTarget = (event.relatedTarget ?? opts.fallback) as HTMLElement\n  return exclude.every((el) => !el?.contains(relatedTarget))\n}\n\ntype MaybeArray<T> = T | T[]\n\ntype Options = {\n  exclude: MaybeArray<HTMLElement | null>\n  fallback?: HTMLElement | null\n}\n\ntype Event = Pick<FocusEvent, \"relatedTarget\">\n", "import { getComputedStyle } from \"./computed-style\"\nimport { isDisabled, isHTMLElement } from \"./query\"\n\nexport const focusableSelector = [\n  \"input:not([disabled]):not([type=hidden])\",\n  \"select:not([disabled])\",\n  \"textarea:not([disabled])\",\n  \"button:not([disabled])\",\n  \"embed\",\n  \"iframe\",\n  \"object\",\n  \"a[href]\",\n  \"area[href]\",\n  \"[tabindex]\",\n  \"audio[controls]\",\n  \"video[controls]\",\n  \"*[tabindex]:not([aria-disabled])\",\n  \"[contenteditable]:not([contenteditable=false])\",\n  \"details > summary:first-of-type\",\n].join(\",\")\n\nexport function isHidden(el: HTMLElement | null, until?: HTMLElement) {\n  const style = getComputedStyle(el)\n  if (!el || style.getPropertyValue(\"visibility\") === \"hidden\") return true\n  while (el) {\n    if (until != null && el === until) return false\n    if (style.getPropertyValue(\"display\") === \"none\") return true\n    el = el.parentElement\n  }\n  return false\n}\n\n/**\n * Returns the focusable elements within the element\n */\nexport const getFocusables = (el: HTMLElement | Document | null, includeContainer = false) => {\n  if (!el) return []\n  let els = Array.from(el.querySelectorAll<HTMLElement>(focusableSelector))\n  if (includeContainer && isHTMLElement(el)) {\n    els.unshift(el)\n  }\n  return els.filter((el) => isFocusable(el) && !isHidden(el))\n}\n\n/**\n * Whether this element is focusable\n */\nexport const isFocusable = (el: HTMLElement | null) => {\n  if (!isHTMLElement(el) || isHidden(el) || isDisabled(el)) return false\n  return el?.matches(focusableSelector)\n}\n\n/**\n * Returns the tabbable elements within the element\n */\nexport const getTabbables = (el: HTMLElement | Document, includeContainer = false) => {\n  return getFocusables(el, includeContainer).filter(isTabbable)\n}\n\n/**\n * Whether this element is tabbable\n */\nexport const isTabbable = (el: HTMLElement | null) => {\n  return isFocusable(el) && !isDisabled(el) && !isHidden(el)\n}\n", "import type { KeyboardEvent } from \"react\"\n\ntype EventKey =\n  | \"ArrowDown\"\n  | \"ArrowUp\"\n  | \"ArrowLeft\"\n  | \"ArrowRight\"\n  | \"Space\"\n  | \"Enter\"\n  | \"Comma\"\n  | \"Escape\"\n  | \"Backspace\"\n  | \"Delete\"\n  | \"Home\"\n  | \"End\"\n  | \"Tab\"\n  | \"PageUp\"\n  | \"PageDown\"\n  | (string & {})\n\nexport type EventKeyMap = Partial<Record<EventKey, (event: React.KeyboardEvent) => void>>\n\nconst rtlKeyMap = {\n  ArrowLeft: \"ArrowRight\",\n  ArrowRight: \"ArrowLeft\",\n  Home: \"End\",\n  End: \"Home\",\n}\n\nconst sameKeyMap = {\n  Up: \"ArrowUp\",\n  Down: \"ArrowDown\",\n  Esc: \"Escape\",\n  \" \": \"Space\",\n  \",\": \"Comma\",\n  Left: \"ArrowLeft\",\n  Right: \"ArrowRight\",\n}\n\ntype EventKeyOptions = {\n  dir?: \"ltr\" | \"rtl\"\n  orientation?: \"horizontal\" | \"vertical\"\n}\n\n/**\n * Determine the event key based on text direction.\n */\nexport function getEventKey(event: KeyboardEvent, options: EventKeyOptions = {}) {\n  const { dir = \"ltr\", orientation = \"horizontal\" } = options\n\n  let { key } = event\n  key = sameKeyMap[key] ?? key // normalize key\n\n  const isRtl = dir === \"rtl\" && orientation === \"horizontal\"\n\n  if (isRtl && key in rtlKeyMap) {\n    key = rtlKeyMap[key]\n  }\n\n  return key\n}\n\nconst PAGE_KEYS = new Set([\"PageUp\", \"PageDown\"])\nconst ARROW_KEYS = new Set([\"ArrowUp\", \"ArrowDown\", \"ArrowLeft\", \"ArrowRight\"])\n\n/**\n * Determine the step factor for keyboard events\n */\nexport function getEventStep(event: KeyboardEvent) {\n  if (event.ctrlKey || event.metaKey) {\n    return 0.1\n  } else {\n    const isPageKey = PAGE_KEYS.has(event.key)\n    const isSkipKey = isPageKey || (event.shiftKey && ARROW_KEYS.has(event.key))\n    return isSkipKey ? 10 : 1\n  }\n}\n", "export const visuallyHiddenStyle = {\n  border: \"0\",\n  clip: \"rect(0 0 0 0)\",\n  height: \"1px\",\n  margin: \"-1px\",\n  overflow: \"hidden\",\n  padding: \"0\",\n  position: \"absolute\",\n  width: \"1px\",\n  whiteSpace: \"nowrap\",\n  wordWrap: \"normal\",\n} as const\n\nexport function setVisuallyHidden(el: HTMLElement) {\n  Object.assign(el.style, visuallyHiddenStyle)\n}\n", "import { setVisuallyHidden } from \"./visually-hidden\"\n\nexport type LiveRegionOptions = {\n  /**\n   * The element's local or tag name\n   */\n  name?: string\n  /**\n   * The aria-live attribute of the reion\n   */\n  ariaLive: \"polite\" | \"assertive\"\n  /**\n   * The role property of the region\n   */\n  role: \"status\" | \"alert\" | \"log\"\n  /**\n   * The aria-relevant attribute of the region\n   */\n  ariaRelevant: \"additions\" | \"removals\" | \"text\" | \"all\"\n  /**\n   * The aria-atomic attribute of the region\n   */\n  ariaAtomic: \"true\" | \"false\"\n  /**\n   * The owner document of the region\n   */\n  doc?: Document\n  /**\n   * The root element to attach the region to.\n   * Defaults to the document's body.\n   */\n  root?: HTMLElement | null\n}\n\nexport type LiveRegion = ReturnType<typeof createLiveRegion>\n\nexport function createLiveRegion(opts: Partial<LiveRegionOptions> = {}) {\n  const {\n    ariaLive = \"polite\",\n    role = \"log\",\n    ariaRelevant = \"additions\",\n    doc: ownerDocument,\n    root,\n    name = \"machine-announcer\",\n  } = opts\n\n  let region: HTMLElement | null = null\n  const doc = ownerDocument || document\n  const win = doc.defaultView || window\n\n  const exists = doc.getElementById(\"__live-region__\")\n  if (exists) return null\n\n  region = doc.createElement(name)\n  region.id = \"__live-region__\"\n  region.setAttribute(\"aria-live\", ariaLive)\n  region.setAttribute(\"role\", role)\n  region.setAttribute(\"aria-relevant\", ariaRelevant)\n  setVisuallyHidden(region)\n\n  const body = root ?? doc.body\n  body.appendChild(region)\n\n  function announce(msg: string, expire = 7e3) {\n    if (!region) return\n\n    const div = doc.createElement(\"p\")\n    div.innerHTML = msg\n    region.appendChild(div)\n\n    win.setTimeout(() => {\n      region?.removeChild(div)\n    }, expire)\n  }\n\n  function destroy() {\n    if (!region) return\n    region.parentNode?.removeChild(region)\n  }\n\n  return { announce, destroy }\n}\n", "import { noop } from \"@ui-machines/utils\"\n\nexport function observeAttributes(\n  node: HTMLElement | null,\n  attributes: string | string[],\n  fn: (v: MutationRecord) => void,\n) {\n  if (!node) return noop\n  const attrs = Array.isArray(attributes) ? attributes : [attributes]\n  const win = node.ownerDocument.defaultView || window\n  const obs = new win.MutationObserver((changes) => {\n    for (const change of changes) {\n      if (change.type === \"attributes\" && change.attributeName && attrs.includes(change.attributeName)) {\n        fn(change)\n      }\n    }\n  })\n\n  obs.observe(node, { attributes: true, attributeFilter: attrs })\n\n  return () => obs.disconnect()\n}\n", "type Root = Document | Element | null\n\nexport function queryElements<T extends HTMLElement>(root: Root, selector: string) {\n  return Array.from(root?.querySelectorAll<T>(selector) ?? [])\n}\n\nexport function itemById<T extends HTMLElement>(v: T[], id: string) {\n  return v.find((node) => node.id === id)\n}\n\nexport function indexOfId<T extends HTMLElement>(v: T[], id: string) {\n  const item = itemById(v, id)\n  return item ? v.indexOf(item) : -1\n}\n\nexport function nextById<T extends HTMLElement>(v: T[], id: string, loop = true) {\n  let idx = indexOfId(v, id)\n  idx = loop ? (idx + 1) % v.length : Math.min(idx + 1, v.length - 1)\n  return v[idx]\n}\n\nexport function prevById<T extends HTMLElement>(v: T[], id: string, loop = true) {\n  let idx = indexOfId(v, id)\n  if (idx === -1) return loop ? v[v.length - 1] : null\n  idx = loop ? (idx - 1 + v.length) % v.length : Math.max(0, idx - 1)\n  return v[idx]\n}\n\nexport function findByText<T extends HTMLElement>(v: T[], text: string, currentId?: string | null) {\n  const filtered = v.filter((item) => {\n    const str = item.dataset.valuetext ?? item.textContent\n    return !!str?.toLowerCase().startsWith(text.toLowerCase())\n  })\n  return currentId ? nextById(filtered, currentId) : null\n}\n\nexport function sortByTreeOrder<T extends HTMLElement>(v: T[]) {\n  return v.sort((a, b) => (a.compareDocumentPosition(b) & 2 ? 1 : -1))\n}\n", "import { nextTick } from \"./next-tick\"\n\ntype State = \"default\" | \"disabled\" | \"restoring\"\n\nlet state: State = \"default\"\nlet cache = \"\"\n\nexport function disableTextSelection(ownerDocument: Document) {\n  const doc = ownerDocument || document\n  const root = doc.documentElement\n\n  if (state === \"default\") {\n    cache = root.style.userSelect\n    root.style.userSelect = \"none\"\n  }\n  state = \"disabled\"\n\n  return function restoreTextSelection() {\n    if (state !== \"disabled\") return\n    state = \"restoring\"\n    nextTick(() => {\n      if (state === \"restoring\") {\n        if (root.style.userSelect === \"none\") {\n          root.style.userSelect = cache || \"\"\n        }\n        cache = \"\"\n        state = \"default\"\n      }\n    })\n  }\n}\n", "import { pipe, isLeftClick, isMouseEvent } from \"@ui-machines/utils\"\nimport { disableTextSelection } from \"./text-selection\"\nimport { addPointerEvent, AnyPointerEvent, EventListenerWithPointInfo as Listener, PointerEventInfo } from \"./listener\"\n\nexport function trackPointerDown(doc: Document, onPointerDown: (el: HTMLElement) => void) {\n  const win = doc.defaultView ?? window\n  const fn = (event: PointerEvent) => {\n    if (event.target instanceof win.HTMLElement) {\n      onPointerDown(event.target)\n    }\n  }\n  doc.addEventListener(\"pointerdown\", fn)\n  return () => {\n    doc.removeEventListener(\"pointerdown\", fn)\n  }\n}\n\ntype TrackPointerMoveOptions = {\n  ctx: { doc?: Document; threshold?: number }\n  onPointerUp: VoidFunction\n  onPointerMove: (info: PointerEventInfo, event: AnyPointerEvent) => void\n}\n\nexport function trackPointerMove(opts: TrackPointerMoveOptions) {\n  const { onPointerMove, onPointerUp, ctx } = opts\n  const { doc = document, threshold = 5 } = ctx\n\n  const handlePointerMove: Listener = (event, info) => {\n    const { point: p } = info\n    const distance = Math.sqrt(p.x ** 2 + p.y ** 2)\n    if (distance < threshold) return\n\n    // Because Safari doesn't trigger mouseup events when it's above a `<select>`\n    if (isMouseEvent(event) && isLeftClick(event)) {\n      onPointerUp()\n      return\n    }\n\n    onPointerMove(info, event)\n  }\n\n  return pipe(\n    addPointerEvent(doc, \"pointermove\", handlePointerMove, false),\n    addPointerEvent(doc, \"pointerup\", onPointerUp, false),\n    addPointerEvent(doc, \"pointercancel\", onPointerUp, false),\n    addPointerEvent(doc, \"contextmenu\", onPointerUp, false),\n    disableTextSelection(doc),\n  )\n}\n", "type PointerLockHandlers = {\n  onPointerLock?: VoidFunction\n  onPointerUnlock?: VoidFunction\n}\n\nexport function addPointerlockChangeListener(doc: Document, fn: VoidFunction) {\n  doc.addEventListener(\"webkitpointerlockchange\", fn, false)\n  doc.addEventListener(\"mozpointerlockchange\", fn, false)\n  doc.addEventListener(\"pointerlockchange\", fn, false)\n  return function cleaup() {\n    doc.removeEventListener(\"mozpointerlockchange\", fn, false)\n    doc.removeEventListener(\"pointerlockchange\", fn, false)\n  }\n}\n\nexport function addPointerlockErrorListener(doc: Document, fn: (e: Event) => void) {\n  doc.addEventListener(\"webkitpointerlockerror\", fn, false)\n  doc.addEventListener(\"mozpointerlockerror\", fn, false)\n  doc.addEventListener(\"pointerlockerror\", fn, false)\n  return function cleanup() {\n    doc.removeEventListener(\"webkitpointerlockerror\", fn, false)\n    doc.removeEventListener(\"mozpointerlockerror\", fn, false)\n    doc.removeEventListener(\"pointerlockerror\", fn, false)\n  }\n}\n\nfunction getPointerlockFunc(el: HTMLElement) {\n  return el.requestPointerLock || (el as any).mozRequestPointerLock || (el as any).webkitRequestPointerLock\n}\n\nfunction getRemovePointerlockFunc(doc: Document) {\n  return doc.exitPointerLock || (doc as any).mozExitPointerLock || (doc as any).webkitExitPointerLock\n}\n\nexport function getPointerlockElement(doc: Document) {\n  return doc.pointerLockElement || (doc as any).mozPointerLockElement || (doc as any).webkitPointerLockElement\n}\n\nexport function requestPointerLock(doc: Document, handlers: PointerLockHandlers = {}) {\n  const { onPointerLock, onPointerUnlock } = handlers\n  const body = doc.body\n\n  function isSupported() {\n    return \"pointerLockElement\" in doc || \"mozPointerLockElement\" in doc || \"webkitPointerLockElement\" in doc\n  }\n\n  function hasLockElement() {\n    return !!doc.pointerLockElement\n  }\n\n  function onPointerChange() {\n    if (hasLockElement()) onPointerLock?.()\n    else onPointerUnlock?.()\n  }\n\n  function onPointerError(event: Event) {\n    const isLocked = hasLockElement()\n    if (isLocked) onPointerUnlock?.()\n    console.error(\"PointerLock error occured:\", event)\n    exit()\n  }\n\n  function exit() {\n    doc.exitPointerLock = getRemovePointerlockFunc(doc)\n    doc.exitPointerLock()\n  }\n\n  const cleanups: Set<Function> = new Set()\n\n  function addEventListeners() {\n    cleanups.add(addPointerlockChangeListener(doc, onPointerChange))\n    cleanups.add(addPointerlockErrorListener(doc, onPointerError))\n  }\n\n  function dispose() {\n    if (!isSupported()) return\n    cleanups.forEach((fn) => fn())\n    cleanups.clear()\n    exit()\n  }\n\n  function setup() {\n    if (!isSupported()) return\n    body.requestPointerLock = getPointerlockFunc(body)\n    body.requestPointerLock()\n    addEventListeners()\n  }\n\n  setup()\n  return dispose\n}\n", "function getBasePlacement(placement) {\n  return placement.split('-')[0];\n}\n\nfunction getAlignment(placement) {\n  return placement.split('-')[1];\n}\n\nfunction getMainAxisFromPlacement(placement) {\n  return ['top', 'bottom'].includes(getBasePlacement(placement)) ? 'x' : 'y';\n}\n\nfunction getLengthFromAxis(axis) {\n  return axis === 'y' ? 'height' : 'width';\n}\n\nfunction computeCoordsFromPlacement(_ref) {\n  let {\n    reference,\n    floating,\n    placement\n  } = _ref;\n  const commonX = reference.x + reference.width / 2 - floating.width / 2;\n  const commonY = reference.y + reference.height / 2 - floating.height / 2;\n  let coords;\n\n  switch (getBasePlacement(placement)) {\n    case 'top':\n      coords = {\n        x: commonX,\n        y: reference.y - floating.height\n      };\n      break;\n\n    case 'bottom':\n      coords = {\n        x: commonX,\n        y: reference.y + reference.height\n      };\n      break;\n\n    case 'right':\n      coords = {\n        x: reference.x + reference.width,\n        y: commonY\n      };\n      break;\n\n    case 'left':\n      coords = {\n        x: reference.x - floating.width,\n        y: commonY\n      };\n      break;\n\n    default:\n      coords = {\n        x: reference.x,\n        y: reference.y\n      };\n  }\n\n  const mainAxis = getMainAxisFromPlacement(placement);\n  const length = getLengthFromAxis(mainAxis);\n\n  switch (getAlignment(placement)) {\n    case 'start':\n      coords[mainAxis] = coords[mainAxis] - (reference[length] / 2 - floating[length] / 2);\n      break;\n\n    case 'end':\n      coords[mainAxis] = coords[mainAxis] + (reference[length] / 2 - floating[length] / 2);\n      break;\n  }\n\n  return coords;\n}\n\nconst computePosition = async (reference, floating, config) => {\n  const {\n    placement = 'bottom',\n    strategy = 'absolute',\n    middleware = [],\n    platform\n  } = config;\n\n  if (process.env.NODE_ENV !== \"production\") {\n    if (platform == null) {\n      console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));\n    }\n\n    if (middleware.filter(_ref => {\n      let {\n        name\n      } = _ref;\n      return name === 'autoPlacement' || name === 'flip';\n    }).length > 1) {\n      throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement`', 'middleware detected. This will lead to an infinite loop. Ensure only', 'one of either has been passed to the `middleware` array.'].join(' '));\n    }\n  }\n\n  let rects = await platform.getElementRects({\n    reference,\n    floating,\n    strategy\n  });\n  let {\n    x,\n    y\n  } = computeCoordsFromPlacement({ ...rects,\n    placement\n  });\n  let statefulPlacement = placement;\n  let middlewareData = {};\n  let _debug_loop_count_ = 0;\n\n  for (let i = 0; i < middleware.length; i++) {\n    if (process.env.NODE_ENV !== \"production\") {\n      _debug_loop_count_++;\n\n      if (_debug_loop_count_ > 100) {\n        throw new Error(['Floating UI: The middleware lifecycle appears to be', 'running in an infinite loop. This is usually caused by a `reset`', 'continually being returned without a break condition.'].join(' '));\n      }\n    }\n\n    const {\n      name,\n      fn\n    } = middleware[i];\n    const {\n      x: nextX,\n      y: nextY,\n      data,\n      reset\n    } = await fn({\n      x,\n      y,\n      initialPlacement: placement,\n      placement: statefulPlacement,\n      strategy,\n      middlewareData,\n      rects,\n      platform,\n      elements: {\n        reference,\n        floating\n      }\n    });\n    x = nextX != null ? nextX : x;\n    y = nextY != null ? nextY : y;\n    middlewareData = { ...middlewareData,\n      [name]: data != null ? data : {}\n    };\n\n    if (reset) {\n      if (typeof reset === 'object') {\n        if (reset.placement) {\n          statefulPlacement = reset.placement;\n        }\n\n        if (reset.rects) {\n          rects = reset.rects === true ? await platform.getElementRects({\n            reference,\n            floating,\n            strategy\n          }) : reset.rects;\n        }\n\n        ({\n          x,\n          y\n        } = computeCoordsFromPlacement({ ...rects,\n          placement: statefulPlacement\n        }));\n      }\n\n      i = -1;\n      continue;\n    }\n  }\n\n  return {\n    x,\n    y,\n    placement: statefulPlacement,\n    strategy,\n    middlewareData\n  };\n};\n\nfunction expandPaddingObject(padding) {\n  return {\n    top: 0,\n    right: 0,\n    bottom: 0,\n    left: 0,\n    ...padding\n  };\n}\n\nfunction getSideObjectFromPadding(padding) {\n  return typeof padding !== 'number' ? expandPaddingObject(padding) : {\n    top: padding,\n    right: padding,\n    bottom: padding,\n    left: padding\n  };\n}\n\nfunction rectToClientRect(rect) {\n  return { ...rect,\n    top: rect.y,\n    left: rect.x,\n    right: rect.x + rect.width,\n    bottom: rect.y + rect.height\n  };\n}\n\nasync function detectOverflow(middlewareArguments, options) {\n  if (options === void 0) {\n    options = {};\n  }\n\n  const {\n    x,\n    y,\n    platform,\n    rects,\n    elements,\n    strategy\n  } = middlewareArguments;\n  const {\n    boundary = 'clippingParents',\n    rootBoundary = 'viewport',\n    elementContext = 'floating',\n    altBoundary = false,\n    padding = 0\n  } = options;\n  const paddingObject = getSideObjectFromPadding(padding);\n  const altContext = elementContext === 'floating' ? 'reference' : 'floating';\n  const element = elements[altBoundary ? altContext : elementContext];\n  const clippingClientRect = await platform.getClippingClientRect({\n    element: (await platform.isElement(element)) ? element : element.contextElement || (await platform.getDocumentElement({\n      element: elements.floating\n    })),\n    boundary,\n    rootBoundary\n  });\n  const elementClientRect = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({\n    rect: elementContext === 'floating' ? { ...rects.floating,\n      x,\n      y\n    } : rects.reference,\n    offsetParent: await platform.getOffsetParent({\n      element: elements.floating\n    }),\n    strategy\n  })); // positive = overflowing the clipping rect\n  // 0 or negative = within the clipping rect\n\n  return {\n    top: clippingClientRect.top - elementClientRect.top + paddingObject.top,\n    bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,\n    left: clippingClientRect.left - elementClientRect.left + paddingObject.left,\n    right: elementClientRect.right - clippingClientRect.right + paddingObject.right\n  };\n}\n\nconst min = Math.min;\nconst max = Math.max;\n\nfunction within(min$1, value, max$1) {\n  return max(min$1, min(value, max$1));\n}\n\nconst arrow = options => ({\n  name: 'arrow',\n  options,\n\n  async fn(middlewareArguments) {\n    // Since `element` is required, we don't Partial<> the type\n    const {\n      element,\n      padding = 0\n    } = options != null ? options : {};\n    const {\n      x,\n      y,\n      placement,\n      rects,\n      platform\n    } = middlewareArguments;\n\n    if (element == null) {\n      if (process.env.NODE_ENV !== \"production\") {\n        console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');\n      }\n\n      return {};\n    }\n\n    const paddingObject = getSideObjectFromPadding(padding);\n    const coords = {\n      x,\n      y\n    };\n    const basePlacement = getBasePlacement(placement);\n    const axis = getMainAxisFromPlacement(basePlacement);\n    const length = getLengthFromAxis(axis);\n    const arrowDimensions = await platform.getDimensions({\n      element\n    });\n    const minProp = axis === 'y' ? 'top' : 'left';\n    const maxProp = axis === 'y' ? 'bottom' : 'right';\n    const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];\n    const startDiff = coords[axis] - rects.reference[axis];\n    const arrowOffsetParent = await platform.getOffsetParent({\n      element\n    });\n    const clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;\n    const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center\n    // point is outside of the floating element's bounds\n\n    const min = paddingObject[minProp];\n    const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];\n    const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;\n    const offset = within(min, center, max);\n    return {\n      data: {\n        [axis]: offset,\n        centerOffset: center - offset\n      }\n    };\n  }\n\n});\n\nconst hash$1 = {\n  left: 'right',\n  right: 'left',\n  bottom: 'top',\n  top: 'bottom'\n};\nfunction getOppositePlacement(placement) {\n  return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);\n}\n\nfunction getAlignmentSides(placement, rects) {\n  const isStart = getAlignment(placement) === 'start';\n  const mainAxis = getMainAxisFromPlacement(placement);\n  const length = getLengthFromAxis(mainAxis);\n  let mainAlignmentSide = mainAxis === 'x' ? isStart ? 'right' : 'left' : isStart ? 'bottom' : 'top';\n\n  if (rects.reference[length] > rects.floating[length]) {\n    mainAlignmentSide = getOppositePlacement(mainAlignmentSide);\n  }\n\n  return {\n    main: mainAlignmentSide,\n    cross: getOppositePlacement(mainAlignmentSide)\n  };\n}\n\nconst hash = {\n  start: 'end',\n  end: 'start'\n};\nfunction getOppositeAlignmentPlacement(placement) {\n  return placement.replace(/start|end/g, matched => hash[matched]);\n}\n\nconst basePlacements = ['top', 'right', 'bottom', 'left'];\nconst allPlacements = /*#__PURE__*/basePlacements.reduce((acc, basePlacement) => acc.concat(basePlacement, basePlacement + \"-start\", basePlacement + \"-end\"), []);\n\nfunction getPlacementList(alignment, autoAlignment, allowedPlacements) {\n  const allowedPlacementsSortedByAlignment = alignment ? [...allowedPlacements.filter(placement => getAlignment(placement) === alignment), ...allowedPlacements.filter(placement => getAlignment(placement) !== alignment)] : allowedPlacements.filter(placement => getBasePlacement(placement) === placement);\n  return allowedPlacementsSortedByAlignment.filter(placement => {\n    if (alignment) {\n      return getAlignment(placement) === alignment || (autoAlignment ? getOppositeAlignmentPlacement(placement) !== placement : false);\n    }\n\n    return true;\n  });\n}\nconst autoPlacement = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n\n  return {\n    name: 'autoPlacement',\n    options,\n\n    async fn(middlewareArguments) {\n      var _middlewareData$autoP, _middlewareData$autoP2, _middlewareData$autoP3, _middlewareData$autoP4, _middlewareData$autoP5, _placementsSortedByLe;\n\n      const {\n        x,\n        y,\n        rects,\n        middlewareData,\n        placement\n      } = middlewareArguments;\n      const {\n        alignment = null,\n        allowedPlacements = allPlacements,\n        autoAlignment = true,\n        ...detectOverflowOptions\n      } = options;\n\n      if ((_middlewareData$autoP = middlewareData.autoPlacement) != null && _middlewareData$autoP.skip) {\n        return {};\n      }\n\n      const placements = getPlacementList(alignment, autoAlignment, allowedPlacements);\n      const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);\n      const currentIndex = (_middlewareData$autoP2 = (_middlewareData$autoP3 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP3.index) != null ? _middlewareData$autoP2 : 0;\n      const currentPlacement = placements[currentIndex];\n      const {\n        main,\n        cross\n      } = getAlignmentSides(currentPlacement, rects); // Make `computeCoords` start from the right place\n\n      if (placement !== currentPlacement) {\n        return {\n          x,\n          y,\n          reset: {\n            placement: placements[0]\n          }\n        };\n      }\n\n      const currentOverflows = [overflow[getBasePlacement(currentPlacement)], overflow[main], overflow[cross]];\n      const allOverflows = [...((_middlewareData$autoP4 = (_middlewareData$autoP5 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP5.overflows) != null ? _middlewareData$autoP4 : []), {\n        placement: currentPlacement,\n        overflows: currentOverflows\n      }];\n      const nextPlacement = placements[currentIndex + 1]; // There are more placements to check\n\n      if (nextPlacement) {\n        return {\n          data: {\n            index: currentIndex + 1,\n            overflows: allOverflows\n          },\n          reset: {\n            placement: nextPlacement\n          }\n        };\n      }\n\n      const placementsSortedByLeastOverflow = allOverflows.slice().sort((a, b) => a.overflows[0] - b.overflows[0]);\n      const placementThatFitsOnAllSides = (_placementsSortedByLe = placementsSortedByLeastOverflow.find(_ref => {\n        let {\n          overflows\n        } = _ref;\n        return overflows.every(overflow => overflow <= 0);\n      })) == null ? void 0 : _placementsSortedByLe.placement;\n      return {\n        data: {\n          skip: true\n        },\n        reset: {\n          placement: placementThatFitsOnAllSides != null ? placementThatFitsOnAllSides : placementsSortedByLeastOverflow[0].placement\n        }\n      };\n    }\n\n  };\n};\n\nfunction getExpandedPlacements(placement) {\n  const oppositePlacement = getOppositePlacement(placement);\n  return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];\n}\n\nconst flip = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n\n  return {\n    name: 'flip',\n    options,\n\n    async fn(middlewareArguments) {\n      var _middlewareData$flip, _middlewareData$flip2;\n\n      const {\n        placement,\n        middlewareData,\n        rects,\n        initialPlacement\n      } = middlewareArguments;\n\n      if ((_middlewareData$flip = middlewareData.flip) != null && _middlewareData$flip.skip) {\n        return {};\n      }\n\n      const {\n        mainAxis: checkMainAxis = true,\n        crossAxis: checkCrossAxis = true,\n        fallbackPlacements: specifiedFallbackPlacements,\n        fallbackStrategy = 'bestFit',\n        flipAlignment = true,\n        ...detectOverflowOptions\n      } = options;\n      const basePlacement = getBasePlacement(placement);\n      const isBasePlacement = basePlacement === initialPlacement;\n      const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));\n      const placements = [initialPlacement, ...fallbackPlacements];\n      const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);\n      const overflows = [];\n      let overflowsData = ((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.overflows) || [];\n\n      if (checkMainAxis) {\n        overflows.push(overflow[basePlacement]);\n      }\n\n      if (checkCrossAxis) {\n        const {\n          main,\n          cross\n        } = getAlignmentSides(placement, rects);\n        overflows.push(overflow[main], overflow[cross]);\n      }\n\n      overflowsData = [...overflowsData, {\n        placement,\n        overflows\n      }]; // One or more sides is overflowing\n\n      if (!overflows.every(side => side <= 0)) {\n        var _middlewareData$flip$, _middlewareData$flip3;\n\n        const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip3 = middlewareData.flip) == null ? void 0 : _middlewareData$flip3.index) != null ? _middlewareData$flip$ : 0) + 1;\n        const nextPlacement = placements[nextIndex];\n\n        if (nextPlacement) {\n          // Try next placement and re-run the lifecycle\n          return {\n            data: {\n              index: nextIndex,\n              overflows: overflowsData\n            },\n            reset: {\n              placement: nextPlacement\n            }\n          };\n        }\n\n        let resetPlacement = 'bottom';\n\n        switch (fallbackStrategy) {\n          case 'bestFit':\n            {\n              var _overflowsData$slice$;\n\n              const placement = (_overflowsData$slice$ = overflowsData.slice().sort((a, b) => a.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0) - b.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0))[0]) == null ? void 0 : _overflowsData$slice$.placement;\n\n              if (placement) {\n                resetPlacement = placement;\n              }\n\n              break;\n            }\n\n          case 'initialPlacement':\n            resetPlacement = initialPlacement;\n            break;\n        }\n\n        return {\n          data: {\n            skip: true\n          },\n          reset: {\n            placement: resetPlacement\n          }\n        };\n      }\n\n      return {};\n    }\n\n  };\n};\n\nfunction getSideOffsets(overflow, rect) {\n  return {\n    top: overflow.top - rect.height,\n    right: overflow.right - rect.width,\n    bottom: overflow.bottom - rect.height,\n    left: overflow.left - rect.width\n  };\n}\n\nfunction isAnySideFullyClipped(overflow) {\n  return basePlacements.some(side => overflow[side] >= 0);\n}\n\nconst hide = () => ({\n  name: 'hide',\n\n  async fn(modifierArguments) {\n    const referenceOverflow = await detectOverflow(modifierArguments, {\n      elementContext: 'reference'\n    });\n    const floatingAltOverflow = await detectOverflow(modifierArguments, {\n      altBoundary: true\n    });\n    const referenceHiddenOffsets = getSideOffsets(referenceOverflow, modifierArguments.rects.reference);\n    const escapedOffsets = getSideOffsets(floatingAltOverflow, modifierArguments.rects.floating);\n    const referenceHidden = isAnySideFullyClipped(referenceHiddenOffsets);\n    const escaped = isAnySideFullyClipped(escapedOffsets);\n    return {\n      data: {\n        referenceHidden,\n        referenceHiddenOffsets,\n        escaped,\n        escapedOffsets\n      }\n    };\n  }\n\n});\n\nfunction convertValueToCoords(_ref) {\n  let {\n    placement,\n    rects,\n    value\n  } = _ref;\n  const basePlacement = getBasePlacement(placement);\n  const multiplier = ['left', 'top'].includes(basePlacement) ? -1 : 1;\n  const rawValue = typeof value === 'function' ? value({ ...rects,\n    placement\n  }) : value;\n  const {\n    mainAxis,\n    crossAxis\n  } = typeof rawValue === 'number' ? {\n    mainAxis: rawValue,\n    crossAxis: 0\n  } : {\n    mainAxis: 0,\n    crossAxis: 0,\n    ...rawValue\n  };\n  return getMainAxisFromPlacement(basePlacement) === 'x' ? {\n    x: crossAxis,\n    y: mainAxis * multiplier\n  } : {\n    x: mainAxis * multiplier,\n    y: crossAxis\n  };\n}\nconst offset = function (value) {\n  if (value === void 0) {\n    value = 0;\n  }\n\n  return {\n    name: 'offset',\n    options: value,\n\n    fn(middlewareArguments) {\n      const {\n        x,\n        y,\n        placement,\n        rects\n      } = middlewareArguments;\n      const diffCoords = convertValueToCoords({\n        placement,\n        rects,\n        value\n      });\n      return {\n        x: x + diffCoords.x,\n        y: y + diffCoords.y,\n        data: diffCoords\n      };\n    }\n\n  };\n};\n\nfunction getCrossAxis(axis) {\n  return axis === 'x' ? 'y' : 'x';\n}\n\nconst shift = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n\n  return {\n    name: 'shift',\n    options,\n\n    async fn(middlewareArguments) {\n      const {\n        x,\n        y,\n        placement\n      } = middlewareArguments;\n      const {\n        mainAxis: checkMainAxis = true,\n        crossAxis: checkCrossAxis = false,\n        limiter = {\n          fn: _ref => {\n            let {\n              x,\n              y\n            } = _ref;\n            return {\n              x,\n              y\n            };\n          }\n        },\n        ...detectOverflowOptions\n      } = options;\n      const coords = {\n        x,\n        y\n      };\n      const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);\n      const mainAxis = getMainAxisFromPlacement(getBasePlacement(placement));\n      const crossAxis = getCrossAxis(mainAxis);\n      let mainAxisCoord = coords[mainAxis];\n      let crossAxisCoord = coords[crossAxis];\n\n      if (checkMainAxis) {\n        const minSide = mainAxis === 'y' ? 'top' : 'left';\n        const maxSide = mainAxis === 'y' ? 'bottom' : 'right';\n        const min = mainAxisCoord + overflow[minSide];\n        const max = mainAxisCoord - overflow[maxSide];\n        mainAxisCoord = within(min, mainAxisCoord, max);\n      }\n\n      if (checkCrossAxis) {\n        const minSide = crossAxis === 'y' ? 'top' : 'left';\n        const maxSide = crossAxis === 'y' ? 'bottom' : 'right';\n        const min = crossAxisCoord + overflow[minSide];\n        const max = crossAxisCoord - overflow[maxSide];\n        crossAxisCoord = within(min, crossAxisCoord, max);\n      }\n\n      const limitedCoords = limiter.fn({ ...middlewareArguments,\n        [mainAxis]: mainAxisCoord,\n        [crossAxis]: crossAxisCoord\n      });\n      return { ...limitedCoords,\n        data: {\n          x: limitedCoords.x - x,\n          y: limitedCoords.y - y\n        }\n      };\n    }\n\n  };\n};\nconst limitShift = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n\n  return {\n    options,\n\n    fn(middlewareArguments) {\n      const {\n        x,\n        y,\n        placement,\n        rects,\n        middlewareData\n      } = middlewareArguments;\n      const {\n        offset = 0,\n        mainAxis: checkMainAxis = true,\n        crossAxis: checkCrossAxis = true\n      } = options;\n      const coords = {\n        x,\n        y\n      };\n      const mainAxis = getMainAxisFromPlacement(placement);\n      const crossAxis = getCrossAxis(mainAxis);\n      let mainAxisCoord = coords[mainAxis];\n      let crossAxisCoord = coords[crossAxis];\n      const rawOffset = typeof offset === 'function' ? offset({ ...rects,\n        placement\n      }) : offset;\n      const computedOffset = typeof rawOffset === 'number' ? {\n        mainAxis: rawOffset,\n        crossAxis: 0\n      } : {\n        mainAxis: 0,\n        crossAxis: 0,\n        ...rawOffset\n      };\n\n      if (checkMainAxis) {\n        const len = mainAxis === 'y' ? 'height' : 'width';\n        const limitMin = rects.reference[mainAxis] - rects.floating[len] + computedOffset.mainAxis;\n        const limitMax = rects.reference[mainAxis] + rects.reference[len] - computedOffset.mainAxis;\n\n        if (mainAxisCoord < limitMin) {\n          mainAxisCoord = limitMin;\n        } else if (mainAxisCoord > limitMax) {\n          mainAxisCoord = limitMax;\n        }\n      }\n\n      if (checkCrossAxis) {\n        var _middlewareData$offse, _middlewareData$offse2, _middlewareData$offse3, _middlewareData$offse4;\n\n        const len = mainAxis === 'y' ? 'width' : 'height';\n        const isOriginSide = ['top', 'left'].includes(getBasePlacement(placement));\n        const limitMin = rects.reference[crossAxis] - rects.floating[len] + (isOriginSide ? (_middlewareData$offse = (_middlewareData$offse2 = middlewareData.offset) == null ? void 0 : _middlewareData$offse2[crossAxis]) != null ? _middlewareData$offse : 0 : 0) + (isOriginSide ? 0 : computedOffset.crossAxis);\n        const limitMax = rects.reference[crossAxis] + rects.reference[len] + (isOriginSide ? 0 : (_middlewareData$offse3 = (_middlewareData$offse4 = middlewareData.offset) == null ? void 0 : _middlewareData$offse4[crossAxis]) != null ? _middlewareData$offse3 : 0) - (isOriginSide ? computedOffset.crossAxis : 0);\n\n        if (crossAxisCoord < limitMin) {\n          crossAxisCoord = limitMin;\n        } else if (crossAxisCoord > limitMax) {\n          crossAxisCoord = limitMax;\n        }\n      }\n\n      return {\n        [mainAxis]: mainAxisCoord,\n        [crossAxis]: crossAxisCoord\n      };\n    }\n\n  };\n};\n\nconst size = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n\n  return {\n    name: 'size',\n    options,\n\n    async fn(middlewareArguments) {\n      var _middlewareData$size;\n\n      const {\n        placement,\n        rects,\n        middlewareData\n      } = middlewareArguments;\n      const {\n        apply,\n        ...detectOverflowOptions\n      } = options;\n\n      if ((_middlewareData$size = middlewareData.size) != null && _middlewareData$size.skip) {\n        return {};\n      }\n\n      const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);\n      const basePlacement = getBasePlacement(placement);\n      const isEnd = getAlignment(placement) === 'end';\n      let heightSide;\n      let widthSide;\n\n      if (basePlacement === 'top' || basePlacement === 'bottom') {\n        heightSide = basePlacement;\n        widthSide = isEnd ? 'left' : 'right';\n      } else {\n        widthSide = basePlacement;\n        heightSide = isEnd ? 'top' : 'bottom';\n      }\n\n      const xMin = max(overflow.left, 0);\n      const xMax = max(overflow.right, 0);\n      const yMin = max(overflow.top, 0);\n      const yMax = max(overflow.bottom, 0);\n      const dimensions = {\n        height: rects.floating.height - (['left', 'right'].includes(placement) ? 2 * (yMin !== 0 || yMax !== 0 ? yMin + yMax : max(overflow.top, overflow.bottom)) : overflow[heightSide]),\n        width: rects.floating.width - (['top', 'bottom'].includes(placement) ? 2 * (xMin !== 0 || xMax !== 0 ? xMin + xMax : max(overflow.left, overflow.right)) : overflow[widthSide])\n      };\n      apply == null ? void 0 : apply({ ...dimensions,\n        ...rects\n      });\n      return {\n        data: {\n          skip: true\n        },\n        reset: {\n          rects: true\n        }\n      };\n    }\n\n  };\n};\n\nconst inline = function (options) {\n  if (options === void 0) {\n    options = {};\n  }\n\n  return {\n    name: 'inline',\n    options,\n\n    async fn(middlewareArguments) {\n      var _middlewareData$inlin, _await$platform$getCl;\n\n      const {\n        placement,\n        elements,\n        rects,\n        platform,\n        strategy,\n        middlewareData\n      } = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a\n      // ClientRect's bounds, despite the event listener being triggered. A\n      // padding of 2 seems to handle this issue.\n\n      const {\n        padding = 2,\n        x,\n        y\n      } = options;\n\n      if ((_middlewareData$inlin = middlewareData.inline) != null && _middlewareData$inlin.skip) {\n        return {};\n      }\n\n      const fallback = rectToClientRect(await platform.convertOffsetParentRelativeRectToViewportRelativeRect({\n        rect: rects.reference,\n        offsetParent: await platform.getOffsetParent({\n          element: elements.floating\n        }),\n        strategy\n      }));\n      const clientRects = Array.from((_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects({\n        element: elements.reference\n      }))) != null ? _await$platform$getCl : []);\n      const paddingObject = getSideObjectFromPadding(padding);\n\n      function getBoundingClientRect() {\n        // There are two rects and they are disjoined\n        if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {\n          var _clientRects$find;\n\n          // Find the first rect in which the point is fully inside\n          return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;\n        } // There are 2 or more connected rects\n\n\n        if (clientRects.length >= 2) {\n          if (getMainAxisFromPlacement(placement) === 'x') {\n            const firstRect = clientRects[0];\n            const lastRect = clientRects[clientRects.length - 1];\n            const isTop = getBasePlacement(placement) === 'top';\n            const top = firstRect.top;\n            const bottom = lastRect.bottom;\n            const left = isTop ? firstRect.left : lastRect.left;\n            const right = isTop ? firstRect.right : lastRect.right;\n            const width = right - left;\n            const height = bottom - top;\n            return {\n              top,\n              bottom,\n              left,\n              right,\n              width,\n              height,\n              x: left,\n              y: top\n            };\n          }\n\n          const isLeftPlacement = getBasePlacement(placement) === 'left';\n          const maxRight = max(...clientRects.map(rect => rect.right));\n          const minLeft = min(...clientRects.map(rect => rect.left));\n          const measureRects = clientRects.filter(rect => isLeftPlacement ? rect.left === minLeft : rect.right === maxRight);\n          const top = measureRects[0].top;\n          const bottom = measureRects[measureRects.length - 1].bottom;\n          const left = minLeft;\n          const right = maxRight;\n          const width = right - left;\n          const height = bottom - top;\n          return {\n            top,\n            bottom,\n            left,\n            right,\n            width,\n            height,\n            x: left,\n            y: top\n          };\n        }\n\n        return fallback;\n      }\n\n      return {\n        data: {\n          skip: true\n        },\n        reset: {\n          rects: await platform.getElementRects({\n            reference: {\n              getBoundingClientRect\n            },\n            floating: elements.floating,\n            strategy\n          })\n        }\n      };\n    }\n\n  };\n};\n\nexport { arrow, autoPlacement, computePosition, detectOverflow, flip, hide, inline, limitShift, offset, rectToClientRect, shift, size };\n", "import { rectToClientRect, computePosition as computePosition$1 } from '@floating-ui/core';\nexport { arrow, autoPlacement, detectOverflow, flip, hide, inline, limitShift, offset, shift, size } from '@floating-ui/core';\n\nfunction isWindow(value) {\n  return (value == null ? void 0 : value.toString()) === '[object Window]';\n}\nfunction getWindow(node) {\n  if (node == null) {\n    return window;\n  }\n\n  if (!isWindow(node)) {\n    const ownerDocument = node.ownerDocument;\n    return ownerDocument ? ownerDocument.defaultView || window : window;\n  }\n\n  return node;\n}\n\nfunction getComputedStyle$1(element) {\n  return getWindow(element).getComputedStyle(element);\n}\n\nfunction getNodeName(node) {\n  return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';\n}\n\nfunction isHTMLElement(value) {\n  return value instanceof getWindow(value).HTMLElement;\n}\nfunction isElement(value) {\n  return value instanceof getWindow(value).Element;\n}\nfunction isNode(value) {\n  return value instanceof getWindow(value).Node;\n}\nfunction isShadowRoot(node) {\n  const OwnElement = getWindow(node).ShadowRoot;\n  return node instanceof OwnElement || node instanceof ShadowRoot;\n}\nfunction isScrollParent(element) {\n  // Firefox wants us to check `-x` and `-y` variations as well\n  const {\n    overflow,\n    overflowX,\n    overflowY\n  } = getComputedStyle$1(element);\n  return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);\n}\nfunction isTableElement(element) {\n  return ['table', 'td', 'th'].includes(getNodeName(element));\n}\nfunction isContainingBlock(element) {\n  // TODO: Try and use feature detection here instead\n  const isFirefox = navigator.userAgent.toLowerCase().includes('firefox');\n  const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that\n  // create a containing block.\n  // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block\n\n  return css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);\n}\n\nconst min = Math.min;\nconst max = Math.max;\nconst round = Math.round;\n\nfunction getBoundingClientRect(element, includeScale) {\n  if (includeScale === void 0) {\n    includeScale = false;\n  }\n\n  const clientRect = element.getBoundingClientRect();\n  let scaleX = 1;\n  let scaleY = 1;\n\n  if (includeScale && isHTMLElement(element)) {\n    scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;\n    scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;\n  }\n\n  return {\n    width: clientRect.width / scaleX,\n    height: clientRect.height / scaleY,\n    top: clientRect.top / scaleY,\n    right: clientRect.right / scaleX,\n    bottom: clientRect.bottom / scaleY,\n    left: clientRect.left / scaleX,\n    x: clientRect.left / scaleX,\n    y: clientRect.top / scaleY\n  };\n}\n\nfunction getDocumentElement(node) {\n  return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;\n}\n\nfunction getNodeScroll(element) {\n  if (isWindow(element)) {\n    return {\n      scrollLeft: element.pageXOffset,\n      scrollTop: element.pageYOffset\n    };\n  }\n\n  return {\n    scrollLeft: element.scrollLeft,\n    scrollTop: element.scrollTop\n  };\n}\n\nfunction getWindowScrollBarX(element) {\n  // If <html> has a CSS width greater than the viewport, then this will be\n  // incorrect for RTL.\n  return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;\n}\n\nfunction isScaled(element) {\n  const rect = getBoundingClientRect(element);\n  return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;\n}\n\nfunction getRectRelativeToOffsetParent(element, offsetParent, strategy) {\n  const isOffsetParentAnElement = isHTMLElement(offsetParent);\n  const documentElement = getDocumentElement(offsetParent);\n  const rect = getBoundingClientRect(element, isOffsetParentAnElement && isScaled(offsetParent));\n  let scroll = {\n    scrollLeft: 0,\n    scrollTop: 0\n  };\n  const offsets = {\n    x: 0,\n    y: 0\n  };\n\n  if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {\n    if (getNodeName(offsetParent) !== 'body' || isScrollParent(documentElement)) {\n      scroll = getNodeScroll(offsetParent);\n    }\n\n    if (isHTMLElement(offsetParent)) {\n      const offsetRect = getBoundingClientRect(offsetParent, true);\n      offsets.x = offsetRect.x + offsetParent.clientLeft;\n      offsets.y = offsetRect.y + offsetParent.clientTop;\n    } else if (documentElement) {\n      offsets.x = getWindowScrollBarX(documentElement);\n    }\n  }\n\n  return {\n    x: rect.left + scroll.scrollLeft - offsets.x,\n    y: rect.top + scroll.scrollTop - offsets.y,\n    width: rect.width,\n    height: rect.height\n  };\n}\n\nfunction getParentNode(node) {\n  if (getNodeName(node) === 'html') {\n    return node;\n  }\n\n  return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle\n    // @ts-ignore\n    node.assignedSlot || // step into the shadow DOM of the parent of a slotted node\n    node.parentNode || ( // DOM Element detected\n    isShadowRoot(node) ? node.host : null) || // ShadowRoot detected\n    getDocumentElement(node) // fallback\n\n  );\n}\n\nfunction getTrueOffsetParent(element) {\n  if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {\n    return null;\n  }\n\n  return element.offsetParent;\n}\n\nfunction getContainingBlock(element) {\n  let currentNode = getParentNode(element);\n\n  while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {\n    if (isContainingBlock(currentNode)) {\n      return currentNode;\n    } else {\n      currentNode = currentNode.parentNode;\n    }\n  }\n\n  return null;\n} // Gets the closest ancestor positioned element. Handles some edge cases,\n// such as table ancestors and cross browser bugs.\n\n\nfunction getOffsetParent(element) {\n  const window = getWindow(element);\n  let offsetParent = getTrueOffsetParent(element);\n\n  while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {\n    offsetParent = getTrueOffsetParent(offsetParent);\n  }\n\n  if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {\n    return window;\n  }\n\n  return offsetParent || getContainingBlock(element) || window;\n}\n\nfunction getDimensions(element) {\n  return {\n    width: element.offsetWidth,\n    height: element.offsetHeight\n  };\n}\n\nfunction convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {\n  let {\n    rect,\n    offsetParent,\n    strategy\n  } = _ref;\n  const isOffsetParentAnElement = isHTMLElement(offsetParent);\n  const documentElement = getDocumentElement(offsetParent);\n\n  if (offsetParent === documentElement) {\n    return rect;\n  }\n\n  let scroll = {\n    scrollLeft: 0,\n    scrollTop: 0\n  };\n  const offsets = {\n    x: 0,\n    y: 0\n  };\n\n  if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {\n    if (getNodeName(offsetParent) !== 'body' || isScrollParent(documentElement)) {\n      scroll = getNodeScroll(offsetParent);\n    }\n\n    if (isHTMLElement(offsetParent)) {\n      const offsetRect = getBoundingClientRect(offsetParent, true);\n      offsets.x = offsetRect.x + offsetParent.clientLeft;\n      offsets.y = offsetRect.y + offsetParent.clientTop;\n    } // This doesn't appear to be need to be negated.\n    // else if (documentElement) {\n    //   offsets.x = getWindowScrollBarX(documentElement);\n    // }\n\n  }\n\n  return { ...rect,\n    x: rect.x - scroll.scrollLeft + offsets.x,\n    y: rect.y - scroll.scrollTop + offsets.y\n  };\n}\n\nfunction getViewportRect(element) {\n  const win = getWindow(element);\n  const html = getDocumentElement(element);\n  const visualViewport = win.visualViewport;\n  let width = html.clientWidth;\n  let height = html.clientHeight;\n  let x = 0;\n  let y = 0;\n\n  if (visualViewport) {\n    width = visualViewport.width;\n    height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)\n    // In Chrome, it returns a value very close to 0 (+/-) but contains rounding\n    // errors due to floating point numbers, so we need to check precision.\n    // Safari returns a number <= 0, usually < -1 when pinch-zoomed\n\n    if (Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) < 0.01) {\n      x = visualViewport.offsetLeft;\n      y = visualViewport.offsetTop;\n    }\n  }\n\n  return {\n    width,\n    height,\n    x,\n    y\n  };\n}\n\n// of the `<html>` and `<body>` rect bounds if horizontally scrollable\n\nfunction getDocumentRect(element) {\n  var _element$ownerDocumen;\n\n  const html = getDocumentElement(element);\n  const scroll = getNodeScroll(element);\n  const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;\n  const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);\n  const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);\n  let x = -scroll.scrollLeft + getWindowScrollBarX(element);\n  const y = -scroll.scrollTop;\n\n  if (getComputedStyle$1(body || html).direction === 'rtl') {\n    x += max(html.clientWidth, body ? body.clientWidth : 0) - width;\n  }\n\n  return {\n    width,\n    height,\n    x,\n    y\n  };\n}\n\nfunction getScrollParent(node) {\n  if (['html', 'body', '#document'].includes(getNodeName(node))) {\n    // @ts-ignore assume body is always available\n    return node.ownerDocument.body;\n  }\n\n  if (isHTMLElement(node) && isScrollParent(node)) {\n    return node;\n  }\n\n  return getScrollParent(getParentNode(node));\n}\n\nfunction getScrollParents(node, list) {\n  var _node$ownerDocument;\n\n  if (list === void 0) {\n    list = [];\n  }\n\n  const scrollParent = getScrollParent(node);\n  const isBody = scrollParent === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);\n  const win = getWindow(scrollParent);\n  const target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;\n  const updatedList = list.concat(target);\n  return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here\n  updatedList.concat(getScrollParents(getParentNode(target)));\n}\n\nfunction contains(parent, child) {\n  const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method\n\n  if (parent.contains(child)) {\n    return true;\n  } // then fallback to custom implementation with Shadow DOM support\n  else if (rootNode && isShadowRoot(rootNode)) {\n    let next = child;\n\n    do {\n      // use `===` replace node.isSameNode()\n      if (next && parent === next) {\n        return true;\n      } // @ts-ignore: need a better way to handle this...\n\n\n      next = next.parentNode || next.host;\n    } while (next);\n  }\n\n  return false;\n}\n\nfunction getInnerBoundingClientRect(element) {\n  const clientRect = getBoundingClientRect(element);\n  const top = clientRect.top + element.clientTop;\n  const left = clientRect.left + element.clientLeft;\n  return {\n    top,\n    left,\n    x: left,\n    y: top,\n    right: left + element.clientWidth,\n    bottom: top + element.clientHeight,\n    width: element.clientWidth,\n    height: element.clientHeight\n  };\n}\n\nfunction getClientRectFromClippingParent(element, clippingParent) {\n  if (clippingParent === 'viewport') {\n    return rectToClientRect(getViewportRect(element));\n  }\n\n  if (isElement(clippingParent)) {\n    return getInnerBoundingClientRect(clippingParent);\n  }\n\n  return rectToClientRect(getDocumentRect(getDocumentElement(element)));\n} // A \"clipping parent\" is an overflowable container with the characteristic of\n// clipping (or hiding) overflowing elements with a position different from\n// `initial`\n\n\nfunction getClippingParents(element) {\n  const clippingParents = getScrollParents(getParentNode(element));\n  const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);\n  const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;\n\n  if (!isElement(clipperElement)) {\n    return [];\n  } // @ts-ignore isElement check ensures we return Array<Element>\n\n\n  return clippingParents.filter(clippingParent => isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body');\n} // Gets the maximum area that the element is visible in due to any number of\n// clipping parents\n\n\nfunction getClippingClientRect(_ref) {\n  let {\n    element,\n    boundary,\n    rootBoundary\n  } = _ref;\n  const mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);\n  const clippingParents = [...mainClippingParents, rootBoundary];\n  const firstClippingParent = clippingParents[0];\n  const clippingRect = clippingParents.reduce((accRect, clippingParent) => {\n    const rect = getClientRectFromClippingParent(element, clippingParent);\n    accRect.top = max(rect.top, accRect.top);\n    accRect.right = min(rect.right, accRect.right);\n    accRect.bottom = min(rect.bottom, accRect.bottom);\n    accRect.left = max(rect.left, accRect.left);\n    return accRect;\n  }, getClientRectFromClippingParent(element, firstClippingParent));\n  clippingRect.width = clippingRect.right - clippingRect.left;\n  clippingRect.height = clippingRect.bottom - clippingRect.top;\n  clippingRect.x = clippingRect.left;\n  clippingRect.y = clippingRect.top;\n  return clippingRect;\n}\n\nconst platform = {\n  getElementRects: _ref => {\n    let {\n      reference,\n      floating,\n      strategy\n    } = _ref;\n    return {\n      reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),\n      floating: { ...getDimensions(floating),\n        x: 0,\n        y: 0\n      }\n    };\n  },\n  convertOffsetParentRelativeRectToViewportRelativeRect: args => convertOffsetParentRelativeRectToViewportRelativeRect(args),\n  getOffsetParent: _ref2 => {\n    let {\n      element\n    } = _ref2;\n    return getOffsetParent(element);\n  },\n  isElement: value => isElement(value),\n  getDocumentElement: _ref3 => {\n    let {\n      element\n    } = _ref3;\n    return getDocumentElement(element);\n  },\n  getClippingClientRect: args => getClippingClientRect(args),\n  getDimensions: _ref4 => {\n    let {\n      element\n    } = _ref4;\n    return getDimensions(element);\n  },\n  getClientRects: _ref5 => {\n    let {\n      element\n    } = _ref5;\n    return element.getClientRects();\n  }\n};\n\nconst computePosition = (reference, floating, options) => computePosition$1(reference, floating, {\n  platform,\n  ...options\n});\n\nexport { computePosition, getScrollParents };\n", "import { Middleware, Placement } from \"@floating-ui/dom\"\n\n/* -----------------------------------------------------------------------------\n * Shared middleware utils\n * -----------------------------------------------------------------------------*/\n\nconst toVar = (value: string, fallback?: string | number) => ({\n  variable: value,\n  reference: fallback ? `var(${value}, ${fallback})` : `var(${value})`,\n})\n\nexport const cssVars = {\n  arrowShadowColor: toVar(\"--arrow-shadow-color\"),\n  arrowSize: toVar(\"--arrow-size\"),\n  arrowSizeHalf: toVar(\"--arrow-size-half\"),\n  arrowBg: toVar(\"--arrow-background\"),\n  transformOrigin: toVar(\"--transform-origin\"),\n  arrowOffset: toVar(\"--arrow-offset\"),\n  boxShadow: toVar(\"--arrow-box-shadow\"),\n}\n\n/* -----------------------------------------------------------------------------\n * Transform Origin Middleware\n * -----------------------------------------------------------------------------*/\n\nconst transforms = {\n  top: \"bottom center\",\n  \"top-start\": \"bottom left\",\n  \"top-end\": \"bottom right\",\n  bottom: \"top center\",\n  \"bottom-start\": \"top left\",\n  \"bottom-end\": \"top right\",\n  left: \"right center\",\n  \"left-start\": \"right top\",\n  \"left-end\": \"right bottom\",\n  right: \"left center\",\n  \"right-start\": \"left top\",\n  \"right-end\": \"left bottom\",\n}\n\nexport const transformOrigin: Middleware = {\n  name: \"transformOrigin\",\n  fn({ placement, elements }) {\n    const { floating } = elements\n    floating.style.setProperty(cssVars.transformOrigin.variable, transforms[placement])\n    return {\n      data: { transformOrigin: transforms[placement] },\n    }\n  },\n}\n\n/* -----------------------------------------------------------------------------\n * Arrow Middleware\n * -----------------------------------------------------------------------------*/\n\ntype ArrowOptions = { element: HTMLElement }\n\nexport const positionArrow = (opts: ArrowOptions): Middleware => ({\n  name: \"positionArrow\",\n  fn({ placement, middlewareData }) {\n    const { element: arrow } = opts\n    const { x, y } = middlewareData.arrow ?? { x: 0, y: 0 }\n\n    const staticSide = {\n      top: \"bottom\",\n      right: \"left\",\n      bottom: \"top\",\n      left: \"right\",\n    }[placement.split(\"-\")[0]]\n\n    Object.assign(arrow.style, {\n      left: x != null ? `${x}px` : \"\",\n      top: y != null ? `${y}px` : \"\",\n      right: \"\",\n      bottom: \"\",\n      [<string>staticSide]: cssVars.arrowOffset.reference,\n      [cssVars.boxShadow.variable]: getBoxShadow(placement)!,\n    })\n\n    return {}\n  },\n})\n\nexport function getBoxShadow(placement: Placement) {\n  if (placement.includes(\"top\")) return `1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`\n  if (placement.includes(\"bottom\")) return `-1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`\n  if (placement.includes(\"right\")) return `-1px 1px 1px 0 ${cssVars.arrowShadowColor.reference}`\n  if (placement.includes(\"left\")) return `1px -1px 1px 0 ${cssVars.arrowShadowColor.reference}`\n}\n", "// Credit goes to the radix-ui team for this utility:\n// https://github.com/radix-ui/primitives/blob/main/packages/core/rect/src/observeElementRect.ts\n\nexport type Measurable = { getBoundingClientRect(): DOMRect }\n\nexport function observeElementRect(el: Measurable, fn: CallbackFn) {\n  const data = observedElements.get(el)\n\n  if (!data) {\n    observedElements.set(el, { rect: {} as DOMRect, callbacks: [fn] })\n\n    if (observedElements.size === 1) {\n      rafId = requestAnimationFrame(runLoop)\n    }\n  } else {\n    data.callbacks.push(fn)\n    fn(el.getBoundingClientRect())\n  }\n\n  return () => {\n    const data = observedElements.get(el)\n    if (!data) return\n\n    const index = data.callbacks.indexOf(fn)\n    if (index > -1) {\n      data.callbacks.splice(index, 1)\n    }\n\n    if (data.callbacks.length === 0) {\n      observedElements.delete(el)\n\n      if (observedElements.size === 0) {\n        cancelAnimationFrame(rafId)\n      }\n    }\n  }\n}\n\ntype CallbackFn = (rect: DOMRect) => void\n\ntype ObservedData = {\n  rect: DOMRect\n  callbacks: Array<CallbackFn>\n}\n\nlet rafId: number\nconst observedElements: Map<Measurable, ObservedData> = new Map()\n\nfunction runLoop() {\n  const changedRectsData: Array<ObservedData> = []\n\n  observedElements.forEach((data, element) => {\n    const newRect = element.getBoundingClientRect()\n\n    if (!isEqual(data.rect, newRect)) {\n      data.rect = newRect\n      changedRectsData.push(data)\n    }\n  })\n\n  changedRectsData.forEach((data) => {\n    data.callbacks.forEach((callback) => callback(data.rect))\n  })\n\n  rafId = requestAnimationFrame(runLoop)\n}\n\nfunction isEqual(rect1: DOMRect, rect2: DOMRect) {\n  return (\n    rect1.width === rect2.width &&\n    rect1.height === rect2.height &&\n    rect1.top === rect2.top &&\n    rect1.right === rect2.right &&\n    rect1.bottom === rect2.bottom &&\n    rect1.left === rect2.left\n  )\n}\n", "import {\n  arrow,\n  computePosition,\n  flip,\n  getScrollParents,\n  Middleware,\n  offset,\n  Placement,\n  shift,\n  size,\n} from \"@floating-ui/dom\"\nimport { noop } from \"@ui-machines/utils\"\nimport { cssVars, positionArrow, transformOrigin } from \"./popper.middleware\"\nimport { observeElementRect } from \"./rect-observer\"\n\nexport type PlacementOptions = {\n  arrow?: { padding?: number; element?: HTMLElement }\n  strategy?: \"absolute\" | \"fixed\"\n  placement?: Placement\n  offset?: { mainAxis?: number; crossAxis?: number }\n  gutter?: number\n  flip?: boolean\n  matchWidth?: boolean\n  boundary?: \"clippingParents\" | Element | Element[]\n  eventListeners?: boolean | { scroll?: boolean; resize?: boolean }\n}\n\nconst defaultOpts: PlacementOptions = {\n  strategy: \"absolute\",\n  placement: \"bottom\",\n  eventListeners: true,\n  gutter: 8,\n  flip: true,\n  boundary: \"clippingParents\",\n  matchWidth: false,\n}\n\nexport function getPlacement(reference: HTMLElement | null, floating: HTMLElement | null, opts: PlacementOptions = {}) {\n  if (reference == null || floating == null) {\n    return { addListeners: () => noop, compute: () => noop }\n  }\n\n  opts = Object.assign({}, defaultOpts, opts)\n  const win = reference.ownerDocument.defaultView || window\n\n  const middleware: Middleware[] = [transformOrigin]\n\n  if (opts.flip) {\n    middleware.push(flip({ boundary: opts.boundary, padding: 8 }))\n  }\n\n  if (opts.gutter || opts.offset) {\n    const data = opts.gutter ? { mainAxis: opts.gutter } : opts.offset\n    middleware.push(offset(data))\n  }\n\n  middleware.push(shift({ boundary: opts.boundary }))\n\n  if (opts.arrow?.element) {\n    middleware.push(\n      arrow({\n        element: opts.arrow.element,\n        padding: opts.arrow.padding ?? 8,\n      }),\n      positionArrow({ element: opts.arrow?.element }),\n    )\n  }\n\n  if (opts.matchWidth) {\n    middleware.push(\n      size({\n        apply({ reference }) {\n          Object.assign(floating.style, {\n            width: reference.width + \"px\",\n            minWidth: \"unset\",\n          })\n        },\n      }),\n    )\n  }\n\n  function compute() {\n    if (reference == null || floating == null) return\n    computePosition(reference, floating, {\n      placement: opts.placement,\n      middleware,\n      strategy: opts.strategy,\n    }).then(({ x, y }) => {\n      Object.assign(floating.style, { left: `${x}px`, top: `${y}px` })\n    })\n  }\n\n  function addResizeListeners() {\n    const enabled = typeof opts.eventListeners === \"boolean\" ? opts.eventListeners : opts.eventListeners?.resize\n    if (!enabled) return\n\n    const unobserve = observeElementRect(reference!, compute)\n    win.addEventListener(\"resize\", compute)\n\n    return () => {\n      win.removeEventListener(\"resize\", compute)\n      unobserve()\n    }\n  }\n\n  function addScrollListeners() {\n    const enabled = typeof opts.eventListeners === \"boolean\" ? opts.eventListeners : opts.eventListeners?.scroll\n    if (!enabled || reference == null) return\n    const fns = getScrollParents(reference).map((el) => {\n      el.addEventListener(\"scroll\", compute)\n      return () => {\n        el.removeEventListener(\"scroll\", compute)\n      }\n    })\n    return () => {\n      fns.forEach((fn) => fn())\n    }\n  }\n\n  return {\n    addListeners() {\n      const cleanups = [addResizeListeners(), addScrollListeners()]\n      return () => cleanups.forEach((fn) => fn?.())\n    },\n    compute,\n  }\n}\n\n/* -----------------------------------------------------------------------------\n * Recommended Style (Floating, Arrow, Inner Arrow)\n * -----------------------------------------------------------------------------*/\n\ntype ArrowStyleOptions = {\n  size?: number\n  background?: string\n  shadowColor?: string\n}\n\nfunction getArrowStyle(opts: ArrowStyleOptions = {}) {\n  const { size = 8, background, shadowColor } = opts\n  return {\n    position: \"absolute\",\n    [cssVars.arrowSize.variable]: `${size}px`,\n    width: cssVars.arrowSize.reference,\n    height: cssVars.arrowSize.reference,\n    [cssVars.arrowSizeHalf.variable]: `calc(${cssVars.arrowSize.reference} / 2)`,\n    [cssVars.arrowOffset.variable]: `calc(${cssVars.arrowSizeHalf.reference} * -1)`,\n    [cssVars.arrowBg.variable]: background,\n    [cssVars.arrowShadowColor.variable]: shadowColor,\n  } as const\n}\n\nfunction getInnerArrowStyle() {\n  return {\n    transform: \"rotate(45deg)\",\n    background: cssVars.arrowBg.reference,\n    top: 0,\n    left: 0,\n    width: \"100%\",\n    height: \"100%\",\n    position: \"absolute\",\n    zIndex: \"inherit\",\n  } as const\n}\n\nfunction getFloatingStyle() {\n  return {\n    position: \"absolute\",\n    minWidth: \"max-content\",\n    inset: \"0 auto auto 0\",\n  } as const\n}\n\nexport const PLACEMENT_STYLE = {\n  arrow: getArrowStyle,\n  innerArrow: getInnerArrowStyle,\n  floating: getFloatingStyle,\n}\n", "import type * as React from \"react\"\n\ntype Dict<T = any> = Record<string, T>\n\ntype Booleanish = boolean | \"true\" | \"false\"\n\ntype Omit<T, K extends keyof T> = { [P in Exclude<keyof T, K>]?: T[P] }\n\ntype WithStyle<T extends { style?: any }> = Omit<T, \"style\"> & {\n  style?: T[\"style\"] & {\n    [prop: string]: string | number | undefined\n  }\n}\n\ntype DataAttr = {\n  \"data-uid\"?: string\n  \"data-ownedby\"?: string\n  \"data-selected\"?: Booleanish\n  \"data-expanded\"?: Booleanish\n  \"data-highlighted\"?: Booleanish\n  \"data-readonly\"?: Booleanish\n  \"data-invalid\"?: Booleanish\n  \"data-hover\"?: Booleanish\n  \"data-active\"?: Booleanish\n  \"data-focus\"?: Booleanish\n  \"data-disabled\"?: Booleanish\n  \"data-type\"?: string\n  \"data-value\"?: string | number\n  \"data-valuetext\"?: string\n  \"data-open\"?: Booleanish\n  \"data-placement\"?: string\n  \"data-orientation\"?: \"horizontal\" | \"vertical\"\n  \"data-label\"?: string\n  \"data-checked\"?: Booleanish\n  \"data-pressed\"?: Booleanish\n  \"data-state\"?: string | null\n  \"data-half\"?: Booleanish\n  \"data-count\"?: number\n  \"data-controls\"?: string\n  \"data-part\"?: string\n  \"data-index\"?: number\n  \"data-complete\"?: Booleanish\n}\n\ntype JSXElementAttributes = DataAttr & React.HTMLAttributes<HTMLElement>\ntype JSXButtonAttributes = DataAttr & React.ButtonHTMLAttributes<HTMLButtonElement>\ntype JSXInputAttributes = DataAttr & React.InputHTMLAttributes<HTMLInputElement>\ntype JSXLabelAttributes = DataAttr & React.LabelHTMLAttributes<HTMLLabelElement>\ntype JSXOutputAttributes = DataAttr & React.OutputHTMLAttributes<HTMLOutputElement>\n\nexport type PropTypes = Record<\"button\" | \"label\" | \"input\" | \"output\" | \"element\", Dict>\n\nexport type ReactPropTypes = {\n  button: JSXButtonAttributes\n  label: JSXLabelAttributes\n  input: JSXInputAttributes\n  output: JSXOutputAttributes\n  element: JSXElementAttributes\n}\n\nexport type NormalizeProps = {\n  button<T extends PropTypes>(props: WithStyle<JSXButtonAttributes>): T[\"button\"]\n  label<T extends PropTypes>(props: WithStyle<JSXLabelAttributes>): T[\"label\"]\n  input<T extends PropTypes>(props: WithStyle<JSXInputAttributes>): T[\"input\"]\n  output<T extends PropTypes>(props: WithStyle<JSXOutputAttributes>): T[\"output\"]\n  element<T extends PropTypes>(props: WithStyle<JSXElementAttributes>): T[\"element\"]\n}\n\nexport function createNormalizer(fn: (props: Dict) => Dict): NormalizeProps {\n  return { button: fn, label: fn, input: fn, output: fn, element: fn }\n}\n\nexport const normalizeProp = createNormalizer((v) => v)\n", "export function toArray<T>(v: T | T[] | undefined | null): T[] {\n  if (!v) return []\n  return Array.isArray(v) ? v : [v]\n}\n\nexport const fromLength = (length: number) => Array.from(Array(length).keys())\n\nexport const first = <T>(v: T[]): T | undefined => v[0]\n\nexport const last = <T>(v: T[]): T | undefined => v[v.length - 1]\n\nexport const isEmpty = <T>(v: T[]): boolean => v.length === 0\n\nexport const has = <T>(v: T[], t: any): boolean => v.indexOf(t) !== -1\n\nexport const add = <T>(v: T[], ...items: T[]): T[] => v.concat(items)\n\nexport const remove = <T>(v: T[], item: T): T[] => removeAt(v, v.indexOf(item))\n\nexport const removeAt = <T>(v: T[], i: number): T[] => {\n  if (i > -1) v.splice(i, 1)\n  return v\n}\n\nexport function clear<T>(v: T[]): T[] {\n  while (v.length > 0) v.pop()\n  return v\n}\n\nexport type IndexOptions = {\n  step?: number\n  loop?: boolean\n}\n\nexport function nextIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n  const { step = 1, loop = true } = opts\n  const next = idx + step\n  const len = v.length\n  const last = len - 1\n  if (idx === -1) return step > 0 ? 0 : last\n  if (next < 0) return loop ? last : 0\n  if (next >= len) return loop ? 0 : idx > len ? len : idx\n  return next\n}\n\nexport function next<T>(v: T[], idx: number, opts: IndexOptions = {}): T | undefined {\n  return v[nextIndex(v, idx, opts)]\n}\n\nexport function prevIndex<T>(v: T[], idx: number, opts: IndexOptions = {}): number {\n  const { step = 1, loop = true } = opts\n  return nextIndex(v, idx, { step: -step, loop })\n}\n\nexport function prev<T>(v: T[], index: number, opts: IndexOptions = {}): T | undefined {\n  return v[prevIndex(v, index, opts)]\n}\n\nexport const chunk = <T>(v: T[], size: number): T[][] => {\n  const res: T[][] = []\n  return v.reduce((rows, value, index) => {\n    if (index % size === 0) rows.push([value])\n    else last(rows)?.push(value)\n    return rows\n  }, res)\n}\n", "export const runIfFn = <T>(\n  v: T,\n  ...a: T extends (...a: any[]) => void ? Parameters<T> : never\n): T extends (...a: any[]) => void ? ReturnType<T> : T => {\n  return typeof v === \"function\" ? v(...a) : v\n}\n\nexport const cast = <T>(v: unknown): T => v as T\n\nexport const noop = () => {}\n\nexport const pipe =\n  <T>(...fns: Array<(a: T) => T>) =>\n  (v: T) =>\n    fns.reduce((a, b) => b(a), v)\n\nexport const callAll =\n  <T extends (...a: any[]) => void>(...fns: (T | undefined)[]) =>\n  (...a: Parameters<T>) => {\n    fns.forEach(function (fn) {\n      fn?.(...a)\n    })\n  }\n\nexport const uuid = (() => {\n  let id = 0\n  return () => {\n    id++\n    return id.toString(36)\n  }\n})()\n", "const platform = (v: RegExp) => isDom() && v.test(navigator.platform)\nconst ua = (v: RegExp) => isDom() && v.test(navigator.userAgent)\n\nexport const isDev = () => process.env.NODE_ENV !== \"production\"\nexport const isDom = () => !!(typeof window !== \"undefined\")\nexport const isMac = () => platform(/^Mac/)\nexport const isIPhone = () => platform(/^iPhone/)\nexport const isIPad = () => platform(/^iPad/) || (isMac() && navigator.maxTouchPoints > 1)\nexport const isIos = () => isIPhone() || isIPad()\nexport const isSafari = () => ua(/^((?!chrome|android).)*safari/i)\nexport const isFirefox = () => ua(/^Firefox/)\nexport const isWebkit = () => ua(/^WebKit/) && !ua(/Chrome/)\nexport const isApple = () => isMac() || isIos()\n\nexport const isArray = (v: any): v is any[] => Array.isArray(v)\nexport const isBoolean = (v: any): v is boolean => v === true || v === false\nexport const isObject = (v: any): v is Record<string, any> => !(v == null || typeof v !== \"object\" || isArray(v))\nexport const isNumber = (v: any): v is number => typeof v === \"number\" && !Number.isNaN(v)\nexport const isString = (v: any): v is string => typeof v === \"string\"\nexport const isFunction = (v: any): v is Function => typeof v === \"function\"\n\nexport const supportsPointerEvent = () => isDom() && window.onpointerdown === null\nexport const supportsTouchEvent = () => isDom() && window.ontouchstart === null\nexport const supportsMouseEvent = () => isDom() && window.onmousedown === null\n\nexport const isMouseEvent = (v: any): v is MouseEvent => isObject(v) && \"button\" in v\nexport const isTouchEvent = (v: any): v is TouchEvent => isObject(v) && \"touches\" in v\nexport const isLeftClick = (v: MouseEvent | PointerEvent) => v.button === 0\nexport const isRightClick = (v: MouseEvent | PointerEvent) => v.button === 2\nexport const isModifiedEvent = (v: MouseEvent | PointerEvent | KeyboardEvent) =>\n  v.ctrlKey || v.altKey || v.metaKey || v.shiftKey\nexport const isCtrlKey = (v: KeyboardEvent) => (isMac() ? v.metaKey && !v.ctrlKey : v.ctrlKey && !v.metaKey)\n", "export function warn(m: string): void\nexport function warn(c: boolean, m: string): void\nexport function warn(...a: any[]): void {\n  const m = a.length === 1 ? a[0] : a[1]\n  const c = a.length === 2 ? a[0] : true\n  if (c && process.env.NODE_ENV !== \"production\") {\n    console.warn(m)\n  }\n}\n\nexport function invariant(m: string): void\nexport function invariant(c: boolean, m: string): void\nexport function invariant(...a: any[]): void {\n  const m = a.length === 1 ? a[0] : a[1]\n  const c = a.length === 2 ? a[0] : true\n  if (c && process.env.NODE_ENV !== \"production\") {\n    throw new Error(m)\n  }\n}\n", "import { queryElements } from \"@ui-machines/dom-utils\"\nimport { MachineContext as Ctx } from \"./pin-input.types\"\n\nexport const dom = {\n  getDoc: (ctx: Ctx) => ctx.doc ?? document,\n\n  getRootId: (ctx: Ctx) => `pin-input-${ctx.uid}`,\n  getInputId: (ctx: Ctx, id: string | number) => `pin-input-${ctx.uid}-${id}`,\n\n  getRootEl: (ctx: Ctx) => dom.getDoc(ctx).getElementById(dom.getRootId(ctx)),\n  getElements: (ctx: Ctx) =>\n    queryElements<HTMLInputElement>(dom.getRootEl(ctx), `input[data-ownedby=${dom.getRootId(ctx)}]`),\n  getFocusedEl: (ctx: Ctx) => dom.getElements(ctx)[ctx.focusedIndex],\n\n  getFirstInputEl: (ctx: Ctx) => dom.getElements(ctx)[0],\n}\n", "import { StateMachine as S } from \"@ui-machines/core\"\nimport { ariaAttr, dataAttr, EventKeyMap, getEventKey, getNativeEvent } from \"@ui-machines/dom-utils\"\nimport { normalizeProp, PropTypes, ReactPropTypes } from \"@ui-machines/types\"\nimport { isModifiedEvent } from \"@ui-machines/utils\"\nimport { dom } from \"./pin-input.dom\"\nimport { MachineContext, MachineState } from \"./pin-input.types\"\n\nexport function connect<T extends PropTypes = ReactPropTypes>(\n  state: S.State<MachineContext, MachineState>,\n  send: (event: S.Event<S.AnyEventObject>) => void,\n  normalize = normalizeProp,\n) {\n  const { context: ctx } = state\n\n  return {\n    value: ctx.value,\n    focusedIndex: ctx.focusedIndex,\n\n    setValue(value: number[]) {\n      send({ type: \"SET_VALUE\", value })\n    },\n    clearValue() {\n      send({ type: \"CLEAR_VALUE\" })\n    },\n    setValueAtIndex(value: string, index: number) {\n      send({ type: \"SET_VALUE\", value, index })\n    },\n    focus() {\n      dom.getFirstInputEl(ctx)?.focus()\n    },\n    blur() {\n      if (ctx.focusedIndex === -1) return\n      dom.getFirstInputEl(ctx)?.blur()\n    },\n\n    containerProps: normalize.element<T>({\n      \"data-part\": \"container\",\n      id: dom.getRootId(ctx),\n      \"data-invalid\": dataAttr(ctx.invalid),\n      \"data-disabled\": dataAttr(ctx.disabled),\n      \"data-complete\": dataAttr(ctx.isValueComplete),\n    }),\n\n    getInputProps({ index }: { index: number }) {\n      const inputType = ctx.type === \"numeric\" ? \"tel\" : \"text\"\n      return normalize.input<T>({\n        \"data-part\": \"input\",\n        disabled: ctx.disabled,\n        \"data-disabled\": dataAttr(ctx.disabled),\n        \"data-complete\": dataAttr(ctx.isValueComplete),\n        id: dom.getInputId(ctx, index),\n        \"data-ownedby\": dom.getRootId(ctx),\n        \"aria-label\": \"Please enter your pin code\",\n        inputMode: ctx.otp || ctx.type === \"numeric\" ? \"numeric\" : \"text\",\n        \"aria-invalid\": ariaAttr(ctx.invalid),\n        \"data-invalid\": dataAttr(ctx.invalid),\n        type: ctx.mask ? \"password\" : inputType,\n        value: ctx.value[index] || \"\",\n        autoCapitalize: \"off\",\n        autoComplete: ctx.otp ? \"one-time-code\" : \"off\",\n        placeholder: ctx.focusedIndex === index ? \"\" : ctx.placeholder,\n        onChange(event) {\n          const evt = getNativeEvent(event)\n          if (evt.isComposing) return\n\n          const value = event.target.value\n\n          if (evt.inputType === \"insertFromPaste\" || value.length > 2) {\n            send({ type: \"PASTE\", value })\n            event.preventDefault()\n            return\n          }\n\n          if (evt.inputType === \"insertText\") {\n            send({ type: \"INPUT\", value })\n          }\n        },\n        onKeyDown(event) {\n          const evt = getNativeEvent(event)\n          if (evt.isComposing || isModifiedEvent(evt)) return\n\n          const keyMap: EventKeyMap = {\n            Backspace() {\n              send(\"BACKSPACE\")\n            },\n            Delete() {\n              send(\"DELETE\")\n            },\n            ArrowLeft() {\n              send(\"ARROW_LEFT\")\n            },\n            ArrowRight() {\n              send(\"ARROW_RIGHT\")\n            },\n          }\n\n          const key = getEventKey(event, { dir: ctx.dir })\n          const exec = keyMap[key]\n\n          if (exec) {\n            exec?.(event)\n            event.preventDefault()\n          }\n        },\n        onFocus() {\n          send({ type: \"FOCUS\", index })\n        },\n        onBlur() {\n          send({ type: \"BLUR\", index })\n        },\n      })\n    },\n  }\n}\n", "import { createMachine, guards, ref } from \"@ui-machines/core\"\nimport { nextTick } from \"@ui-machines/dom-utils\"\nimport { fromLength } from \"@ui-machines/utils\"\nimport { dom } from \"./pin-input.dom\"\nimport { MachineContext, MachineState } from \"./pin-input.types\"\n\nconst { and } = guards\n\nexport const machine = createMachine<MachineContext, MachineState>(\n  {\n    id: \"pin-input\",\n    initial: \"unknown\",\n    context: {\n      uid: \"pin-input\",\n      value: [],\n      focusedIndex: -1,\n      placeholder: \"\u25CB\",\n      otp: false,\n      type: \"numeric\",\n    },\n\n    on: {\n      SET_VALUE: [\n        {\n          guard: \"hasIndex\",\n          actions: \"setValueAtIndex\",\n        },\n        { actions: \"setValue\" },\n      ],\n      CLEAR_VALUE: {\n        actions: [\"clearValue\", \"setFocusIndexToFirst\"],\n      },\n    },\n\n    computed: {\n      valueLength: (ctx) => ctx.value.length,\n      filledValueLength: (ctx) => ctx.value.filter((v) => v?.trim() !== \"\").length,\n      isValueComplete: (ctx) => ctx.valueLength === ctx.filledValueLength,\n      valueAsString: (ctx) => ctx.value.join(\"\"),\n    },\n\n    watch: {\n      focusedIndex: \"focusInput\",\n      value: \"invokeOnChange\",\n      isValueComplete: \"invokeComplete\",\n    },\n\n    states: {\n      unknown: {\n        on: {\n          SETUP: [\n            {\n              guard: \"autoFocus\",\n              target: \"focused\",\n              actions: [\"setupDocument\", \"setupValue\", \"setFocusIndexToFirst\"],\n            },\n            {\n              target: \"idle\",\n              actions: [\"setupDocument\", \"setupValue\"],\n            },\n          ],\n        },\n      },\n      idle: {\n        on: {\n          FOCUS: {\n            target: \"focused\",\n            actions: \"setFocusedIndex\",\n          },\n        },\n      },\n      focused: {\n        on: {\n          INPUT: [\n            {\n              guard: and(\"isFinalValue\", \"isValidValue\"),\n              actions: \"setFocusedValue\",\n            },\n            {\n              guard: and(\"hasValue\", \"isValidValue\"),\n              actions: [\"replaceFocusedValue\", \"setNextFocusedIndex\"],\n            },\n            {\n              guard: \"isValidValue\",\n              actions: [\"setFocusedValue\", \"setNextFocusedIndex\"],\n            },\n          ],\n          PASTE: {\n            guard: \"isValidValue\",\n            actions: [\"setPastedValue\", \"setLastValueFocusIndex\"],\n          },\n          BLUR: {\n            target: \"idle\",\n            actions: \"clearFocusedIndex\",\n          },\n          DELETE: {\n            guard: \"hasValue\",\n            actions: \"clearFocusedValue\",\n          },\n          ARROW_LEFT: {\n            actions: \"setPrevFocusedIndex\",\n          },\n          ARROW_RIGHT: {\n            actions: \"setNextFocusedIndex\",\n          },\n          BACKSPACE: [\n            {\n              guard: \"hasValue\",\n              actions: \"clearFocusedValue\",\n            },\n            {\n              actions: [\"setPrevFocusedIndex\", \"clearFocusedValue\"],\n            },\n          ],\n        },\n      },\n    },\n  },\n  {\n    guards: {\n      autoFocus: (ctx) => !!ctx.autoFocus,\n      isValueEmpty: (_ctx, evt) => evt.value === \"\",\n      hasValue: (ctx) => ctx.value[ctx.focusedIndex] !== \"\",\n      isValueComplete: (ctx) => ctx.isValueComplete,\n      isValidValue: (ctx, evt) => isValidType(evt.value, ctx.type),\n      isFinalValue: (ctx) => {\n        return (\n          ctx.filledValueLength + 1 === ctx.valueLength &&\n          ctx.value.findIndex((v) => v.trim() === \"\") === ctx.focusedIndex\n        )\n      },\n      isLastInputFocused: (ctx) => ctx.focusedIndex === ctx.valueLength - 1,\n      hasIndex: (_ctx, evt) => evt.index !== undefined,\n    },\n    actions: {\n      setupDocument: (ctx, evt) => {\n        ctx.doc = ref(evt.doc)\n        ctx.uid = evt.id\n      },\n      setupValue: (ctx) => {\n        nextTick(() => {\n          const inputs = dom.getElements(ctx)\n          const empty = fromLength(inputs.length).map(() => \"\")\n          ctx.value = Object.assign(empty, ctx.value)\n        })\n      },\n      focusInput: (ctx) => {\n        nextTick(() => {\n          if (ctx.focusedIndex === -1) return\n          dom.getFocusedEl(ctx)?.focus()\n        })\n      },\n      invokeComplete: (ctx) => {\n        if (ctx.isValueComplete) {\n          ctx.onComplete?.(Array.from(ctx.value), ctx.valueAsString)\n        }\n      },\n      invokeOnChange: (ctx, evt) => {\n        if (evt.type !== \"SETUP\") {\n          ctx.onChange?.(Array.from(ctx.value))\n        }\n      },\n      clearFocusedIndex: (ctx) => {\n        ctx.focusedIndex = -1\n      },\n      setValue: (ctx, event) => {\n        assign(ctx, event.value)\n      },\n      setFocusedIndex: (ctx, event) => {\n        ctx.focusedIndex = event.index\n      },\n      setFocusedValue: (ctx, event) => {\n        ctx.value[ctx.focusedIndex] = event.value\n      },\n      replaceFocusedValue: (ctx, evt) => {\n        const val = ctx.value[ctx.focusedIndex]\n        ctx.value[ctx.focusedIndex] = evt.value.replace(val, \"\").charAt(0)\n      },\n      setPastedValue(ctx, evt) {\n        nextTick(() => {\n          const value = (evt.value as string).substr(0, ctx.valueLength)\n          assign(ctx, value.split(\"\").filter(Boolean))\n        })\n      },\n      setValueAtIndex: (ctx, evt) => {\n        ctx.value[evt.index] = evt.value\n      },\n      clearValue: (ctx) => {\n        assign(ctx, \"\")\n      },\n      clearFocusedValue: (ctx) => {\n        ctx.value[ctx.focusedIndex] = \"\"\n      },\n      setFocusIndexToFirst: (ctx) => {\n        ctx.focusedIndex = 0\n      },\n      setNextFocusedIndex: (ctx) => {\n        ctx.focusedIndex = Math.min(ctx.focusedIndex + 1, ctx.valueLength - 1)\n      },\n      setPrevFocusedIndex: (ctx) => {\n        ctx.focusedIndex = Math.max(ctx.focusedIndex - 1, 0)\n      },\n      setLastValueFocusIndex: (ctx) => {\n        nextTick(() => {\n          ctx.focusedIndex = Math.min(ctx.filledValueLength, ctx.valueLength - 1)\n        })\n      },\n    },\n  },\n)\n\nconst REGEX = {\n  numeric: /^[0-9]+$/,\n  alphabetic: /^[A-Za-z]+$/,\n  alphanumeric: /^[a-zA-Z0-9]+$/i,\n}\n\nfunction isValidType(value: string, type: MachineContext[\"type\"]) {\n  if (!type) return true\n  return !!REGEX[type]?.test(value)\n}\n\nfunction assign(ctx: MachineContext, value: string | string[]) {\n  for (let i = 0; i < ctx.value.length; i++) {\n    if (Array.isArray(value)) {\n      if (!value[i]) continue\n      ctx.value[i] = value[i]\n    } else {\n      ctx.value[i] = value\n    }\n  }\n}\n"],
  "mappings": "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",
  "names": []
}
