{"version":3,"file":"dom-BK2w00Ec.mjs","sources":["../src/utils/dom.ts"],"sourcesContent":["import type {Slot} from 'vue'\n\n// Get the currently active HTML element\nexport const getActiveElement = (excludes: readonly HTMLElement[] = []): Element | null => {\n  const {activeElement} = document\n  return activeElement && !excludes?.some((el) => el === activeElement) ? activeElement : null\n}\n\n/**\n * @deprecated only used in BFormGroup, which is not an SFC... Function could probably be replaced with pure Vue\n */\nexport const attemptFocus = (\n  el: Readonly<HTMLElement>,\n  options: Readonly<FocusOptions> = {}\n): boolean => {\n  const isActiveElement = (el: Readonly<HTMLElement>): boolean => el === getActiveElement()\n\n  try {\n    el.focus(options)\n  } catch (e) {\n    // eslint-disable-next-line no-console\n    console.error(e)\n  }\n  return isActiveElement(el)\n}\n\nexport const isEmptySlot = (el: Slot | undefined): boolean => (el?.() ?? []).length === 0\n\n/**\n * @deprecated only used in BFormGroup, which is not an SFC... Function could probably be replaced with pure Vue\n */\nexport const isVisible = (el: Readonly<Element>): boolean => {\n  //if (!isElement(el) || !el.parentNode || !contains(DOCUMENT.body, el)) {\n  // Note this can fail for shadow dom elements since they\n  // are not a direct descendant of document.body\n  //return false\n  //}\n  if (el.getAttribute('display') === 'none') {\n    // We do this check to help with vue-test-utils when using v-show\n    return false\n  }\n  // All browsers support getBoundingClientRect(), except JSDOM as it returns all 0's for values :(\n  // So any tests that need isVisible will fail in JSDOM\n  // Except when we override the getBCR prototype in some tests\n  const bcr = el.getBoundingClientRect()\n  return !!(bcr && bcr.height > 0 && bcr.width > 0)\n}\n\nexport const getTransitionDelay = (element: Readonly<HTMLElement>) => {\n  const style = window.getComputedStyle(element)\n  // if multiple durations are defined, we take the first\n  const transitionDelay = style.transitionDelay.split(',')[0] || ''\n  const transitionDuration = style.transitionDuration.split(',')[0] || ''\n  const transitionDelayMs = Number(transitionDelay.slice(0, -1)) * 1000\n  const transitionDurationMs = Number(transitionDuration.slice(0, -1)) * 1000\n  return transitionDelayMs + transitionDurationMs\n}\n\nexport const sortSlotElementsByPosition = (\n  a: Readonly<HTMLElement> | null,\n  b: Readonly<HTMLElement> | null\n): number => {\n  if (typeof Node === 'undefined' || !Node || !a || !b) return 0\n  const position = a.compareDocumentPosition(b)\n  if (position & Node.DOCUMENT_POSITION_FOLLOWING) return -1\n  if (position & Node.DOCUMENT_POSITION_PRECEDING) return 1\n  return 0\n}\n"],"names":["el"],"mappings":"AAGO,MAAM,mBAAmB,CAAC,WAAmC,OAAuB;AACnF,QAAA,EAAC,kBAAiB;AACjB,SAAA,iBAAiB,EAAC,qCAAU,KAAK,CAAC,OAAO,OAAO,kBAAiB,gBAAgB;AAC1F;AAKO,MAAM,eAAe,CAC1B,IACA,UAAkC,OACtB;AACZ,QAAM,kBAAkB,CAACA,QAAuCA,QAAO,iBAAiB;AAEpF,MAAA;AACF,OAAG,MAAM,OAAO;AAAA,WACT,GAAG;AAEV,YAAQ,MAAM,CAAC;AAAA,EAAA;AAEjB,SAAO,gBAAgB,EAAE;AAC3B;AAEO,MAAM,cAAc,CAAC,SAAmC,+BAAU,CAAA,GAAI,WAAW;AAK3E,MAAA,YAAY,CAAC,OAAmC;AAM3D,MAAI,GAAG,aAAa,SAAS,MAAM,QAAQ;AAElC,WAAA;AAAA,EAAA;AAKH,QAAA,MAAM,GAAG,sBAAsB;AACrC,SAAO,CAAC,EAAE,OAAO,IAAI,SAAS,KAAK,IAAI,QAAQ;AACjD;AAYa,MAAA,6BAA6B,CACxC,GACA,MACW;AACP,MAAA,OAAO,SAAS,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAU,QAAA;AACvD,QAAA,WAAW,EAAE,wBAAwB,CAAC;AACxC,MAAA,WAAW,KAAK,4BAAoC,QAAA;AACpD,MAAA,WAAW,KAAK,4BAAoC,QAAA;AACjD,SAAA;AACT;"}