{"version":3,"names":["closestAcrossShadow","el","selector","result","closest","root","getRootNode","ShadowRoot","host","blurAcrossShadow","_a","matches","document","activeElement","shadowRoot","HTMLElement","blur","addMutationObserver","callback","window","MutationObserver","mutationObserver","observe","body","childList","subtree","supportsIntersectionObserver","IntersectionObserverEntry","prototype","IntersectionHandler","constructor","this","elements","Set","isPrinting","observer","IntersectionObserver","entries","intersecting","filter","entry","isIntersecting","map","target","length","triggerCallback","rootMargin","addEventListener","has","forEach","add","unobserve","delete","updateContainerPosition","reference","container","xPos","yPos","rect","getBoundingClientRect","left","scrollX","x","width","top","scrollY","y","height","style","executeOnTreeSiblings","item","previousElementSibling","nextElementSibling","parentElement","disableAriaAccess","dataset","ariaHiddenInitial","ariaHidden","resetAriaAccess","removeAttribute"],"sources":["node_modules/@oebb-web-team/oebb-web-components/dist/collection/utils/dom.js"],"sourcesContent":["export function closestAcrossShadow(el, selector) {\n while (true) {\n const result = el.closest(selector);\n if (result) {\n return result;\n }\n const root = el.getRootNode();\n if (!(root instanceof ShadowRoot)) {\n return null;\n }\n el = root.host;\n }\n}\nexport function blurAcrossShadow(root) {\n var _a;\n if (!root.matches(':focus-within')) {\n return;\n }\n let el = document.activeElement;\n if (!el) {\n return;\n }\n while ((_a = el.shadowRoot) === null || _a === void 0 ? void 0 : _a.activeElement) {\n el = el.shadowRoot.activeElement;\n }\n if (el instanceof HTMLElement) {\n el.blur();\n }\n}\nexport function addMutationObserver(callback) {\n if (!window.MutationObserver) {\n // Simply ignore if the browser does not support MutationObserver\n return null;\n }\n const mutationObserver = new MutationObserver(callback);\n mutationObserver.observe(document.body, { childList: true, subtree: true });\n return mutationObserver;\n}\nexport function supportsIntersectionObserver() {\n return 'IntersectionObserver' in window\n && 'IntersectionObserverEntry' in window\n && 'intersectionRatio' in window.IntersectionObserverEntry.prototype\n && 'isIntersecting' in window.IntersectionObserverEntry.prototype;\n}\nexport class IntersectionHandler {\n constructor(callback) {\n this.callback = callback;\n this.elements = new Set();\n this.isPrinting = false;\n if (supportsIntersectionObserver()) {\n // Browser supports IntersectionObserver, let's create it\n this.observer = new IntersectionObserver(entries => {\n const intersecting = entries.filter(entry => entry.isIntersecting).map(entry => entry.target);\n if (intersecting.length) {\n this.triggerCallback(...intersecting);\n }\n }, { rootMargin: '10%' });\n // Add a listener for print view - we need to trigger the callbacks immediately then\n window.addEventListener('beforeprint', () => {\n this.isPrinting = true;\n this.triggerCallback(...this.elements);\n });\n window.addEventListener('afterprint', () => {\n this.isPrinting = false;\n });\n }\n else {\n this.observer = null;\n }\n }\n observe(...elements) {\n if (this.observer && !this.isPrinting) {\n elements.filter(el => !this.elements.has(el)).forEach(el => {\n this.elements.add(el);\n this.observer.observe(el);\n });\n }\n else {\n // Observer not supported or in print preview mode, trigger callback immediately\n elements.forEach(this.callback);\n }\n }\n unobserve(...elements) {\n if (this.observer) {\n elements.forEach(el => {\n this.elements.delete(el);\n this.observer.unobserve(el);\n });\n }\n }\n triggerCallback(...elements) {\n this.unobserve(...elements);\n elements.forEach(this.callback);\n }\n}\nexport function updateContainerPosition(reference, container, xPos = 0, yPos = 1) {\n if (!reference || !container) {\n return;\n }\n const rect = reference.getBoundingClientRect();\n const left = window.scrollX + rect.x + xPos * rect.width;\n const top = window.scrollY + rect.y + yPos * rect.height;\n container.style.left = `${left}px`;\n container.style.top = `${top}px`;\n}\nexport function executeOnTreeSiblings(el, callback) {\n if (!el || el === document.body) {\n return;\n }\n // Run on previous siblings\n for (let item = el.previousElementSibling; item; item = item.previousElementSibling) {\n callback(item);\n }\n // Run on later siblings\n for (let item = el.nextElementSibling; item; item = item.nextElementSibling) {\n callback(item);\n }\n // Run on siblings of parent\n executeOnTreeSiblings(el.parentElement, callback);\n}\nexport function disableAriaAccess(el) {\n if (el instanceof HTMLElement && !el.dataset.ariaHiddenInitial) {\n el.dataset.ariaHiddenInitial = el.ariaHidden || 'undefined';\n }\n el.ariaHidden = 'true';\n}\nexport function resetAriaAccess(el) {\n if (el instanceof HTMLElement && el.dataset.ariaHiddenInitial) {\n if (el.dataset.ariaHiddenInitial === 'undefined') {\n el.removeAttribute('aria-hidden');\n }\n else {\n el.ariaHidden = el.dataset.ariaHiddenInitial;\n }\n delete el.dataset.ariaHiddenInitial;\n }\n}\n//# sourceMappingURL=dom.js.map\n"],"mappings":"AAAO,SAASA,EAAoBC,EAAIC,GACtC,MAAO,KAAM,CACX,MAAMC,EAASF,EAAGG,QAAQF,GAC1B,GAAIC,EAAQ,CACV,OAAOA,CACb,CACI,MAAME,EAAOJ,EAAGK,cAChB,KAAMD,aAAgBE,YAAa,CACjC,OAAO,IACb,CACIN,EAAKI,EAAKG,IACd,CACA,CACO,SAASC,EAAiBJ,GAC/B,IAAIK,EACJ,IAAKL,EAAKM,QAAQ,iBAAkB,CAClC,MACJ,CACE,IAAIV,EAAKW,SAASC,cAClB,IAAKZ,EAAI,CACP,MACJ,CACE,OAAQS,EAAKT,EAAGa,cAAgB,MAAQJ,SAAY,OAAS,EAAIA,EAAGG,cAAe,CACjFZ,EAAKA,EAAGa,WAAWD,aACvB,CACE,GAAIZ,aAAcc,YAAa,CAC7Bd,EAAGe,MACP,CACA,CACO,SAASC,EAAoBC,GAClC,IAAKC,OAAOC,iBAAkB,CAE5B,OAAO,IACX,CACE,MAAMC,EAAmB,IAAID,iBAAiBF,GAC9CG,EAAiBC,QAAQV,SAASW,KAAM,CAAEC,UAAW,KAAMC,QAAS,OACpE,OAAOJ,CACT,CACO,SAASK,IACd,MAAO,yBAA0BP,QAC5B,8BAA+BA,QAC/B,sBAAuBA,OAAOQ,0BAA0BC,WACxD,mBAAoBT,OAAOQ,0BAA0BC,SAC5D,CACO,MAAMC,EACX,WAAAC,CAAYZ,GACVa,KAAKb,SAAWA,EAChBa,KAAKC,SAAW,IAAIC,IACpBF,KAAKG,WAAa,MAClB,GAAIR,IAAgC,CAElCK,KAAKI,SAAW,IAAIC,sBAAqBC,IACvC,MAAMC,EAAeD,EAAQE,QAAOC,GAASA,EAAMC,iBAAgBC,KAAIF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