{"version":3,"file":"dom-DVb-f0ZG.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\nexport const getModalZIndex = (element?: Readonly<HTMLElement | null>): number => {\n  if (typeof window === 'undefined') return 1055\n  const target = element ?? document.body\n  const raw = window.getComputedStyle(target).getPropertyValue('--bs-modal-zindex').trim()\n  const parsed = Number.parseInt(raw, 10)\n  return Number.isFinite(parsed) ? parsed : 1055\n}\n"],"names":["el"],"mappings":"AAGO,MAAM,mBAAmB,CAAC,WAAmC,OAAuB;AACzF,QAAM,EAAC,kBAAiB;AACxB,SAAO,iBAAiB,CAAC,UAAU,KAAK,CAAC,OAAO,OAAO,aAAa,IAAI,gBAAgB;AAC1F;AAKO,MAAM,eAAe,CAC1B,IACA,UAAkC,OACtB;AACZ,QAAM,kBAAkB,CAACA,QAAuCA,QAAO,iBAAA;AAEvE,MAAI;AACF,OAAG,MAAM,OAAO;AAAA,EAClB,SAAS,GAAG;AAEV,YAAQ,MAAM,CAAC;AAAA,EACjB;AACA,SAAO,gBAAgB,EAAE;AAC3B;AAEO,MAAM,cAAc,CAAC,QAAmC,UAAU,CAAA,GAAI,WAAW;AAKjF,MAAM,YAAY,CAAC,OAAmC;AAM3D,MAAI,GAAG,aAAa,SAAS,MAAM,QAAQ;AAEzC,WAAO;AAAA,EACT;AAIA,QAAM,MAAM,GAAG,sBAAA;AACf,SAAO,CAAC,EAAE,OAAO,IAAI,SAAS,KAAK,IAAI,QAAQ;AACjD;AAYO,MAAM,6BAA6B,CACxC,GACA,MACW;AACX,MAAI,OAAO,SAAS,eAAe,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAG,QAAO;AAC7D,QAAM,WAAW,EAAE,wBAAwB,CAAC;AAC5C,MAAI,WAAW,KAAK,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