{"version":3,"file":"geolocationModal-9fa5fd10.js","sources":["../../../../../../src/scripts/modules/geolocationModal.ts"],"sourcesContent":["import { Component } from '@verndale/core';\n\nclass GeolocationModal extends Component {\n loading = false;\n isHomePage: string | undefined = '';\n cookieName: string | undefined = '';\n showModal: string | undefined = '';\n currentLang: string | undefined = '';\n cookieVisitedName: string | null = '';\n cookieValue: string | null = '';\n cookieVisitedValue = 0;\n\n\n constructor(el: HTMLElement) {\n super(el);\n this.loading = true;\n this.isHomePage = this.el.dataset.isHomePage;\n this.cookieName = this.el.dataset.cookieName;\n this.showModal = this.el.dataset.showModal;\n this.currentLang = this.el.dataset.currentLang;\n\n this.cookieVisitedName = localStorage.getItem(`${this.cookieName}-visited`);\n\n this.cookieValue = localStorage.getItem(this.cookieName ? this.cookieName : '');\n this.cookieVisitedValue =\n parseInt(this.cookieVisitedName ? this.cookieVisitedName : '0') || 0;\n\n localStorage.setItem(`${this.cookieName}-visited`, this.cookieVisitedValue.toString());\n\n if (this.isHomePage === 'false' && this.showModal) {\n localStorage.setItem(`${this.cookieName}-visited`, (this.cookieVisitedValue + 1).toString());\n\n this.open();\n }\n\n this.setCurrentLang();\n }\n\n setupDefaults() {\n this.dom = {\n close: this.el.querySelector('.modal-close a'),\n container: this.el.querySelector('.modal-container'),\n overlay: this.el.querySelector('.modal-overlay'),\n selectWrapper: this.el.querySelector('.custom-select-wrapper'),\n selectOptions: this.el.querySelector('.custom-options'),\n selectedValue: this.el.querySelector('.selected-value'),\n select: this.el.querySelector('.custom-select'),\n loader: this.el.querySelector('.modal-loading'),\n geolocation: this.el.querySelector('.geolocation-modal__inner')\n };\n }\n\n addListeners() {\n (this.dom.close as HTMLButtonElement).addEventListener('click', this.close.bind(this));\n (this.dom.selectWrapper as HTMLElement).addEventListener('click', this.toggleOptions.bind(this));\n (this.dom.selectOptions as HTMLElement).addEventListener('click', this.selectOptions.bind(this));\n (this.dom.container as HTMLElement).addEventListener('load', this.setLoading.bind(this));\n }\n\n setLoading() {\n if (this.loading) {\n (this.dom.loader as HTMLElement).style.display = 'flex';\n (this.dom.geolocation as HTMLElement).style.display = 'none';\n } else {\n (this.dom.geolocation as HTMLElement).style.display = 'block';\n (this.dom.loader as HTMLElement).style.display = 'none';\n }\n }\n\n toggleOptions() {\n (this.dom.selectOptions as HTMLElement).classList.toggle('hidden');\n }\n\n selectOptions(e: Event) {\n const target = e.target as HTMLElement;\n (this.dom.selectedValue as HTMLElement).innerHTML = target.innerText;\n const hiddenOptions = this.el.querySelectorAll('.select-options');\n const link = this.el.querySelector('.redirect-anchor');\n\n hiddenOptions.forEach(option => {\n if ((option as HTMLInputElement).value === target.dataset.value) {\n option.setAttribute('selected', 'true');\n (this.dom.selectedValue as HTMLElement).dataset.value = target.dataset.value;\n (link as HTMLAnchorElement).href = (option as HTMLInputElement).dataset.link as string;\n } else {\n option.setAttribute('selected', 'false');\n }\n });\n }\n\n open() {\n if (this.cookieVisitedValue < 1) {\n (this.dom.geolocation as HTMLElement).classList.remove('hidden');\n (this.dom.container as HTMLElement).classList.remove('hidden');\n (this.dom.overlay as HTMLElement).classList.remove('hidden');\n }\n }\n\n close() {\n (this.dom.container as HTMLElement).classList.add('hidden');\n (this.dom.overlay as HTMLElement).classList.add('hidden');\n const script = document.createElement('script');\n script.setAttribute('id', 'Cookiebot');\n script.setAttribute('src', 'https://consent.cookiebot.com/uc.js');\n script.setAttribute('data-cbid', 'bfd87e60-53dc-4c50-a640-d82ff5c22b0c');\n script.setAttribute('data-blockingmode', 'auto');\n script.setAttribute('type', 'text/javascript');\n const gbCookie = document.cookie.match(/_gb=([^;]*)/);\n if (gbCookie && gbCookie.length > 1 && gbCookie[1]) {\n // eslint-disable-next-line no-undef\n const decodedValue = atob(gbCookie[1]);\n script.setAttribute('nonce', decodedValue);\n }\n document.head.appendChild(script);\n this.el.classList.add('hidden');\n }\n\n setCurrentLang() {\n // if (this.cookieBanner) {\n // this.cookieBanner.style.display = 'none';\n // }\n\n const hiddenOptions = document.querySelectorAll('.select-options');\n hiddenOptions.forEach(option => {\n if (this.currentLang === (option as HTMLInputElement).value) {\n option.setAttribute('selected', 'true');\n\n const customOptions = (this.dom.selectOptions as HTMLElement).querySelectorAll('span');\n customOptions.forEach(custOption => {\n if ((custOption as HTMLElement).dataset.value === this.currentLang) {\n (this.dom.selectedValue as HTMLElement).innerHTML = (custOption as HTMLElement).innerText;\n (this.dom.selectedValue as HTMLElement).dataset.value = (custOption as HTMLElement).dataset.value;\n }\n });\n }\n });\n this.loading = false;\n }\n}\n\nexport default GeolocationModal;\n"],"names":["GeolocationModal","Component","el","__publicField","target","hiddenOptions","link","option","script","gbCookie","decodedValue","custOption"],"mappings":"iNAEA,MAAMA,UAAyBC,CAAU,CAWvC,YAAYC,EAAiB,CAC3B,MAAMA,CAAE,EAXVC,EAAA,eAAU,IACVA,EAAA,kBAAiC,IACjCA,EAAA,kBAAiC,IACjCA,EAAA,iBAAgC,IAChCA,EAAA,mBAAkC,IAClCA,EAAA,yBAAmC,IACnCA,EAAA,mBAA6B,IAC7BA,EAAA,0BAAqB,GAKnB,KAAK,QAAU,GACV,KAAA,WAAa,KAAK,GAAG,QAAQ,WAC7B,KAAA,WAAa,KAAK,GAAG,QAAQ,WAC7B,KAAA,UAAY,KAAK,GAAG,QAAQ,UAC5B,KAAA,YAAc,KAAK,GAAG,QAAQ,YAEnC,KAAK,kBAAoB,aAAa,QAAQ,GAAG,KAAK,UAAU,UAAU,EAE1E,KAAK,YAAc,aAAa,QAAQ,KAAK,WAAa,KAAK,WAAa,EAAE,EAC9E,KAAK,mBACH,SAAS,KAAK,kBAAoB,KAAK,kBAAoB,GAAG,GAAK,EAExD,aAAA,QAAQ,GAAG,KAAK,UAAU,WAAY,KAAK,mBAAmB,UAAU,EAEjF,KAAK,aAAe,SAAW,KAAK,YACzB,aAAA,QAAQ,GAAG,KAAK,UAAU,YAAa,KAAK,mBAAqB,GAAG,SAAU,CAAA,EAE3F,KAAK,KAAK,GAGZ,KAAK,eAAe,CACtB,C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