{"version":3,"names":["BsWebcomponent","constructor","elem","parentElem","this","initEventCollapse","initModals","reinitCollapse","options","hasOwnProperty","_a","window","dpl","bs","bsCollapse","Collapse","getInstance","triggerEl","querySelector","getAttribute","addEventListener","toggle","querySelectorAll","forEach","collapse","classList","contains","flyoutEl","closest","parent","that","e","target","button","setAttribute","remove","add","modalElemts","modalElem","modal","parentElement","append","hasAttribute","getFirstFocusable","focus","preventFocusOutOfModal","event","shiftKey","key","focusables","getFocusableElements","length","preventDefault","element","arrFocusables","push","filter","el","cookieUtil","CookieUtil","I18nUtil","isValidLangIdent","s","SUPPORTED_LANGUAGE_IDENTS","includes","getCurrentLang","readFromCookies","cookieLang","getCookieValue","toLowerCase","htmlLangValue","document","documentElement","lang","DEFAULT_LANG_IDENT","getTranslation","currentLang","globalStore","state","language","value","I18N","en","en_texts","es","es_texts","de","de_texts"],"sources":["src/components/bahf-header/bsWebcomponent.ts","src/utils/I18nUtil.ts"],"sourcesContent":["/* istanbul ignore file */\n/*! @design/bapf-pattern-library v3.5.3 | 27.02.2024 | bsWebcomponent.tsx */\n/**\n * Polyfill zur Wiederherstellung von Bootstrap-Funktionalitäten in WebComponents\n * Verwendung mit Stencil siehe https://confluence.webapp.sdst.sbaintern.de/display/REDD/Webcomponents\n */\n\n/* istanbul ignore next */\n\ninterface ICollapseOptions {\n toggle: boolean,\n parent?: HTMLElement\n}\n\ninterface IWindow {\n dpl?: {\n global: {\n init: () => Object;\n };\n tabbar: { init: (selector?) => Object };\n header: { init: (selector?) => Object };\n collapse: { init: (selector?) => Object };\n bs: {\n Alert,\n Collapse,\n Dropdown,\n Modal,\n Popover,\n Tab\n };\n };\n}\n\n/**\n * Erweitert die Funktionalität der DPL3 in WebComponents\n * mit Bootstrap-Eigenschaften (z.b aria-expanded)\n * @param {HTMLElement} elem, beliebiges Parent-Element\n */\nexport class BsWebcomponent {\n private elem: HTMLElement;\n private readonly parentElem?: HTMLElement;\n\n constructor(elem, parentElem = null) {\n this.elem = elem;\n this.parentElem = parentElem;\n this.initEventCollapse();\n this.initModals();\n }\n\n // initialisiert Bootstrap-Collapse, wenn es noch keine Instanz gibt\n reinitCollapse(elem, options) {\n if (!elem.hasOwnProperty('bsCollapse') && (window as Window).dpl?.bs) {\n elem.bsCollapse = (window as unknown as IWindow).dpl.bs.Collapse.getInstance(elem) || new (window as unknown as IWindow).dpl.bs.Collapse(elem, options);\n const triggerEl = this.elem.querySelector(`[data-bs-target=\"#${elem.getAttribute('id')}\"]`);\n triggerEl.addEventListener('click', () => {\n elem.bsCollapse.toggle();\n });\n }\n }\n\n // Fügt Eventlistener für Collapse um Bootstrap-Collapse nachzubilden\n // Steuert CSS-Klasse collapsed\n // Steuert aria-expnaded Attribute\n initEventCollapse() {\n if (!this.elem.querySelector('.collapse')) {\n return;\n }\n\n // wenn keinte Instanz vorhanden dann instanzieren\n this.elem.querySelectorAll('.collapse').forEach((collapse: HTMLElement) => {\n if ((window as unknown as IWindow).dpl.bs.Collapse.getInstance(collapse)) {\n return;\n }\n\n let options: ICollapseOptions = {\n toggle: false\n };\n\n // init Flyout\n if (!collapse.classList.contains('ba-flyout-collapse')) {\n // init flyout collapsibles\n const flyoutEl: HTMLElement = collapse.closest('.ba-flyout-collapse.collapse');\n if (flyoutEl) options.parent = flyoutEl\n if (this.parentElem) options.parent = this.parentElem;\n }\n\n this.reinitCollapse(collapse, options);\n })\n\n const that = this;\n\n // Eventlistener\n this.elem.addEventListener('show.bs.collapse', function (e) {\n if (!(e.target as HTMLElement).classList.contains('collapse')) {\n return;\n }\n\n const button = that.elem.querySelector(`[data-bs-target=\"#${(e.target as HTMLElement).getAttribute('id')}\"]`);\n button.setAttribute('aria-expanded', 'true');\n button.classList.remove('collapsed');\n });\n that.elem.addEventListener('hide.bs.collapse', function (e) {\n if (!(e.target as HTMLElement).classList.contains('collapse')) {\n return;\n }\n\n const button = that.elem.querySelector(`[data-bs-target=\"#${(e.target as HTMLElement).getAttribute('id')}\"]`);\n button.setAttribute('aria-expanded', 'false');\n button.classList.add('collapsed');\n });\n }\n\n initModals() {\n const modalElemts = this.elem.querySelectorAll('.modal');\n\n modalElemts.forEach(modalElem => {\n let parent, modal;\n\n // Vor öffnen eines BS-Modals: modal und parent merken\n modalElem.addEventListener('show.bs.modal', (e) => {\n parent = (e.target as HTMLElement).parentElement;\n modal = e.target;\n });\n\n // Nach öffnen: modal wieder an sein parent anhängen (=zurück in's Shadow-DOM holen)\n modalElem.addEventListener('shown.bs.modal', () => {\n parent.append(modal);\n });\n\n // Nach öffnen eines BS-Modals: erstes fokussierbares Element im Modal fokussieren\n if (!modalElem.hasAttribute('data-prevent-autofocus')) {\n modalElem.addEventListener('shown.bs.modal', (e) => {\n this.getFirstFocusable(e.target as HTMLElement).focus();\n });\n }\n\n const that = this;\n modalElem.addEventListener('keydown', (e: KeyboardEvent) => {\n that.preventFocusOutOfModal(e, modalElem);\n });\n });\n }\n\n // Modal kann per Tab-Taste nicht mehr verlassen werden (Focus-Falle)\n preventFocusOutOfModal(event, modal) {\n if (!event.shiftKey && event.key === 'Tab') {\n const focusables = this.getFocusableElements(modal);\n if (focusables[focusables.length - 1] === event.target) {\n event.preventDefault();\n focusables[0].focus();\n }\n }\n }\n\n getFirstFocusable(element) {\n const focusables = this.getFocusableElements(element);\n return focusables.length ? focusables[0] : element;\n }\n\n getFocusableElements(element) {\n const arrFocusables = [];\n element.querySelectorAll('a[href], button, input:not([type=hidden]), textarea, select, details, [tabindex]:not([tabindex=\"-1\"])').forEach((elem) => arrFocusables.push(elem));\n return arrFocusables.filter(el => !el.hasAttribute('disabled') && !el.getAttribute('aria-hidden'));\n }\n}\n","import { CookieUtil } from './CookieUtil';\nimport * as en_texts from './i18n/i18n.en.json';\nimport * as es_texts from './i18n/i18n.es.json';\nimport * as de_texts from './i18n/i18n.de.json';\nimport globalStore from '../stores/globalStore';\n\nconst cookieUtil = CookieUtil;\n\nexport class I18nUtil {\n private static readonly SUPPORTED_LANGUAGE_IDENTS: string[] = ['de', 'en', 'es'];\n private static readonly DEFAULT_LANG_IDENT: string = 'de';\n\n private static readonly I18N = {\n en: en_texts,\n es: es_texts,\n de: de_texts,\n };\n\n private static isValidLangIdent(s: string) {\n return I18nUtil.SUPPORTED_LANGUAGE_IDENTS.includes(s);\n }\n\n /**\n * Ermittelt die derzeitig genutzte Sprache der Seite/Session.\n * Dazu werden folgende Kriterien ausgewertet:\n * 1. Wert des \"LANG\"-Cookies (gesetzt durch den User im Header)\n * 2. Sprache der Seite (\"lang\"-Attribut des -Dokuments)\n * 3. Fallback zur Standardsprache\n * Die Kriterien werden der Reihe nach evaluiert.\n * Sobald ein Kriterium erfüllt ist wird einer der unterstützten Sprach-Idents zurückgegeben.\n */\n public static getCurrentLang(readFromCookies = true) {\n if(readFromCookies) {\n const cookieLang = cookieUtil.getCookieValue('LANG').toLowerCase();\n if (cookieLang && I18nUtil.isValidLangIdent(cookieLang)) {\n return cookieLang;\n }\n }\n\n const htmlLangValue = document.documentElement.lang;\n if (I18nUtil.isValidLangIdent(htmlLangValue)) {\n return htmlLangValue;\n }\n\n return I18nUtil.DEFAULT_LANG_IDENT;\n }\n\n public static getTranslation(key: string) {\n const currentLang = globalStore.state.language.toLowerCase();\n const value = this.I18N[currentLang][key];\n if (!value) {\n return '';\n }\n return value;\n }\n}\n"],"mappings":";kFAsCaA,EAIX,WAAAC,CAAYC,EAAMC,EAAa,MAC7BC,KAAKF,KAAOA,EACZE,KAAKD,WAAaA,EAClBC,KAAKC,oBACLD,KAAKE,Y,CAIP,cAAAC,CAAeL,EAAMM,G,MACnB,IAAKN,EAAKO,eAAe,iBAAiBC,EAACC,OAAkBC,OAAG,MAAAF,SAAA,SAAAA,EAAEG,IAAI,CACpEX,EAAKY,WAAcH,OAA8BC,IAAIC,GAAGE,SAASC,YAAYd,IAAS,IAAKS,OAA8BC,IAAIC,GAAGE,SAASb,EAAMM,GAC/I,MAAMS,EAAYb,KAAKF,KAAKgB,cAAc,qBAAqBhB,EAAKiB,aAAa,WACjFF,EAAU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