{"version":3,"file":"dom.mjs","sources":["../../../src/utils/dom.ts"],"sourcesContent":["// Node.closest() polyfill\nif (typeof window !== 'undefined' && 'Element' in window && !Element.prototype.closest) {\n  Element.prototype.closest = function (this: any, s: string) {\n    const matches = (this.document || this.ownerDocument).querySelectorAll(s);\n    let el = this;\n    let i;\n    // eslint-disable-next-line\n    do {\n      i = matches.length;\n      // eslint-disable-next-line\n      while (--i >= 0 && matches.item(i) !== el) {}\n      el = el.parentElement;\n    } while (i < 0 && el);\n    return el;\n  };\n}\n\nexport function getPreviousCousin(node: HTMLElement, selector: string) {\n  let sibling = node.parentElement?.previousSibling;\n  let el;\n  while (sibling) {\n    if (sibling instanceof HTMLElement) {\n      el = sibling.querySelector(selector);\n    }\n    if (el) {\n      return el;\n    }\n    sibling = sibling.previousSibling;\n  }\n  return undefined;\n}\n\nexport function getNextCharacter(global?: typeof globalThis) {\n  const selection = (global || window).getSelection();\n  if (!selection || !selection.anchorNode) {\n    return null;\n  }\n\n  const range = selection.getRangeAt(0);\n  const text = selection.anchorNode.textContent;\n  const offset = range.startOffset;\n  return text!.slice(offset, offset + 1);\n}\n"],"names":[],"mappings":"AACA,IAAI,OAAO,WAAW,WAAe,IAAA,SAAA,IAAa,UAAU,CAAC,OAAA,CAAQ,UAAU,OAAS,EAAA;AACtF,EAAQ,OAAA,CAAA,SAAA,CAAU,OAAU,GAAA,SAAqB,CAAW,EAAA;AAC1D,IAAA,MAAM,WAAW,IAAK,CAAA,QAAA,IAAY,IAAK,CAAA,aAAA,EAAe,iBAAiB,CAAC,CAAA;AACxE,IAAA,IAAI,EAAK,GAAA,IAAA;AACT,IAAI,IAAA,CAAA;AAEJ,IAAG,GAAA;AACD,MAAA,CAAA,GAAI,OAAQ,CAAA,MAAA;AAEZ,MAAA,OAAO,EAAE,CAAK,IAAA,CAAA,IAAK,QAAQ,IAAK,CAAA,CAAC,MAAM,EAAI,EAAA;AAAA;AAC3C,MAAA,EAAA,GAAK,EAAG,CAAA,aAAA;AAAA,KACV,QAAS,IAAI,CAAK,IAAA,EAAA;AAClB,IAAO,OAAA,EAAA;AAAA,GACT;AACF"}