{"version":3,"sources":["../../src/utils/getFloatingUIOffset.ts"],"sourcesContent":["import type { Offset } from '../types';\nimport type { MiddlewareState } from '@floating-ui/dom';\nimport { fromFloatingUIPlacement } from './fromFloatingUIPlacement';\n/**\n * Type taken from Floating UI since they are not exported\n */\nexport type FloatingUIOffsetValue =\n  | number\n  | {\n      /**\n       * The axis that runs along the side of the floating element.\n       * @default 0\n       */\n      mainAxis?: number;\n      /**\n       * The axis that runs along the alignment of the floating element.\n       * @default 0\n       */\n      crossAxis?: number;\n      /**\n       * When set to a number, overrides the `crossAxis` value for aligned\n       * (non-centered/base) placements and works logically. A positive number\n       * will move the floating element in the direction of the opposite edge\n       * to the one that is aligned, while a negative number the reverse.\n       * @default null\n       */\n      alignmentAxis?: number | null;\n    };\n\n/**\n * Type taken from Floating UI since they are not exported\n */\nexport type FloatingUIOffsetFunction = (args: MiddlewareState) => FloatingUIOffsetValue;\n\n/**\n * Shim to transform offset values from this library to Floating UI\n * @param rawOffset Offset from this library\n * @returns An offset value compatible with Floating UI\n */\nexport function getFloatingUIOffset(\n  rawOffset: Offset | undefined,\n): FloatingUIOffsetValue | FloatingUIOffsetFunction | undefined {\n  if (!rawOffset) {\n    return rawOffset;\n  }\n\n  if (typeof rawOffset === 'number' || typeof rawOffset === 'object') {\n    return rawOffset;\n  }\n\n  return ({ rects: { floating, reference }, placement }) => {\n    const { position, alignment } = fromFloatingUIPlacement(placement);\n    return rawOffset({ positionedRect: floating, targetRect: reference, position, alignment });\n  };\n}\n"],"names":["fromFloatingUIPlacement","getFloatingUIOffset","rawOffset","rects","floating","reference","placement","position","alignment","positionedRect","targetRect"],"mappings":";;;;+BAuCgBC;;;;;;yCArCwB,+BAA4B;AAqC7D,6BACLC,SAA6B;IAE7B,IAAI,CAACA,WAAW;QACd,OAAOA;IACT;IAEA,IAAI,OAAOA,cAAc,YAAY,OAAOA,cAAc,UAAU;QAClE,OAAOA;IACT;IAEA,OAAO,CAAC,EAAEC,OAAO,EAAEC,QAAQ,EAAEC,SAAS,EAAE,EAAEC,SAAS,EAAE;QACnD,MAAM,EAAEC,QAAQ,EAAEC,SAAS,EAAE,OAAGR,gDAAAA,EAAwBM;QACxD,OAAOJ,UAAU;YAAEO,gBAAgBL;YAAUM,YAAYL;YAAWE;YAAUC;QAAU;IAC1F;AACF"}