{"version":3,"file":"Optanon.js","names":["Optanon","a","setters","Component","default","deepMerge","ajax","Event","execute","constructor","element","options","arguments","length","changeSessionTrackingUrl","cookies","optanon","dw","buttons","confirmMyChoices","allowAll","id","saveButton","saveContainer","acceptContainer","acceptRecommended","acceptRecommendedContainer","bindEvents","window","OptanonWrapper","optanonWrapperEvent","bind","addEventListener","optanonDisplayPopup","url","concat","then","emit","catch","optanonDomainScriptID","optanonCookieToggleInfoDisplayEnable","IsAlertBoxClosed","ToggleInfoDisplay","document","getElementById","optanonAddBtns","classes","styles","acceptButton","buttonTheme","top","footer","getElementsByClassName","savePreference","divSave","createElement","divAccept","innerHTML","appendChild"],"sources":["components/global/Optanon.js"],"sourcesContent":["import Component from 'core/Component';\nimport { deepMerge } from 'toolbox/deepMerge';\nimport { ajax } from 'toolbox/ajax';\nimport { Event } from 'services/EventEmitter';\n\n/**\n * This is a description of the Optanon constructor function.\n * @class\n * @classdesc This is a description of the Optanon class. (must be edited)\n * @extends Component\n */\nexport default class Optanon extends Component {\n    /**\n     * Constructor of the class that mainly merge the options of the components\n     * @param {HTMLElement} element HTMLElement of the component\n     * @param {Object} options options that belongs to the component\n     */\n    constructor(element, options = {}) {\n        super(element, deepMerge({\n            changeSessionTrackingUrl: '',\n            cookies: {\n                optanon: 'OptanonConsent',\n                dw: 'dw_dnt',\n            },\n            buttons: {\n                confirmMyChoices: 'Confirm My Choices',\n                allowAll: 'Allow All',\n            },\n            id: {\n                saveButton: 'save-btn',\n                saveContainer: 'save-container',\n                acceptContainer: 'accept-container',\n                acceptRecommended: 'accept-recommended-btn-handler',\n                acceptRecommendedContainer: 'accept-recommended-container',\n            },\n        }, options));\n    }\n\n    /**\n     * Should contain only event listeners and nothing else\n     * All the event handlers should be into a separated function. No usage of anonyous function\n     */\n    bindEvents() {\n        window.OptanonWrapper = this.optanonWrapperEvent.bind(this);\n        window.addEventListener('load', this.optanonDisplayPopup.bind(this));\n    }\n\n    /**\n     * Optanon Wrapper window Event.\n     * https://community.cookiepro.com/s/article/UUID-730ad441-6c4d-7877-7f85-36f1e801e8ca\n     * As can be seen in the linked documentation, this code, which is assigned to window.OptanonWrapper, is executed:\n     * - on every page load\n     * - each time preferences are saved, if a change from active to inactive has been made\n     * What the code does here is sending an ajax request to a dedicated endpoint (not cached) that will then act\n     * depending on the state of the different consents.\n     * It's necessary to do that on each page load because, as the doc says, there isn't any event\n     * to handle the removal of a given consent.\n     * This means that if we want to stay compliant by properly removing custom 1st party cookies upon consent removal,\n     * we need to check the consent state on each request.\n     * @return {*} ajax response\n     */\n    optanonWrapperEvent() {\n        const url = `${this.options.changeSessionTrackingUrl}`;\n        return ajax(url)\n            .then(() => {\n                Event.emit('Onetrust.activegroups.updated');\n            })\n            .catch(() => {});\n    }\n\n    /**\n     * Optanon cookie policy popup - onetrust v2\n     */\n    optanonDisplayPopup() {\n        if ((typeof window.Optanon === 'undefined') || !this.options.optanonDomainScriptID) {\n            return;\n        }\n\n        if (this.options.optanonCookieToggleInfoDisplayEnable && ('IsAlertBoxClosed' in window.Optanon) && (window.Optanon.IsAlertBoxClosed() === false)) {\n            window.Optanon.ToggleInfoDisplay();\n        }\n\n        if (document.getElementById(this.options.id.saveContainer) === null) {\n            this.optanonAddBtns();\n        }\n    }\n\n    /**\n     * Add buttons to Optanon cookie policy popup - onetrust v2\n     */\n    optanonAddBtns() {\n        const { confirmMyChoices, allowAll } = this.options.buttons;\n        const saveButton = `<button id=\"${this.options.id.saveButton}\" class=\"${this.options.classes.saveContainer}\" style=\"${this.options.styles.confirmMyChoices}\" aria-label=\"${confirmMyChoices}\" role=\"button\" tabindex=\"0\">${confirmMyChoices}</button>`;\n        const acceptButton = `<button id=\"${this.options.id.acceptRecommended}\" class=\"${this.options.classes.buttonTheme}\" style=\"${this.options.styles.allowAll}\" aria-label=\"${allowAll}\" role=\"button\" tabindex=\"0\">${allowAll}</button>`;\n\n        const top = document.getElementById(this.options.id.acceptRecommendedContainer);\n        const footer = document.getElementsByClassName(this.options.classes.savePreference)[0];\n\n        const divSave = document.createElement('div');\n        divSave.id = this.options.id.saveContainer;\n\n        const divAccept = document.createElement('div');\n        divAccept.id = this.options.id.acceptContainer;\n\n        divSave.innerHTML = saveButton;\n        divAccept.innerHTML = acceptButton;\n\n        if (top) {\n            top.appendChild(divSave);\n        }\n\n        if (footer) {\n            footer.appendChild(divAccept);\n        }\n    }\n}\n"],"mappings":"gJAWqBA,CAAO,QAAAC,CAAA,oBAAAC,OAAA,WAAAD,CAAA,EAXrBE,CAAS,CAAAF,CAAA,CAAAG,OAAA,WAAAH,CAAA,EACPI,CAAS,CAAAJ,CAAA,CAATI,SAAS,WAAAJ,CAAA,EACTK,CAAI,CAAAL,CAAA,CAAJK,IAAI,WAAAL,CAAA,EACJM,CAAK,CAAAN,CAAA,CAALM,KAAK,GAAAC,OAAA,SAAAA,CAAA,EAAAP,CAAA,WAQOD,CAAO,CAAb,aAAsB,CAAAG,CAAU,CAM3CM,WAAWA,CAACC,CAAO,CAAgB,IAAd,CAAAC,CAAO,GAAAC,SAAA,CAAAC,MAAA,WAAAD,SAAA,IAAAA,SAAA,IAAG,CAAC,CAAC,CAC7B,KAAK,CAACF,CAAO,CAAEL,CAAS,CAAC,CACrBS,wBAAwB,CAAE,EAAE,CAC5BC,OAAO,CAAE,CACLC,OAAO,CAAE,gBAAgB,CACzBC,EAAE,CAAE,QACR,CAAC,CACDC,OAAO,CAAE,CACLC,gBAAgB,CAAE,oBAAoB,CACtCC,QAAQ,CAAE,WACd,CAAC,CACDC,EAAE,CAAE,CACAC,UAAU,CAAE,UAAU,CACtBC,aAAa,CAAE,gBAAgB,CAC/BC,eAAe,CAAE,kBAAkB,CACnCC,iBAAiB,CAAE,gCAAgC,CACnDC,0BAA0B,CAAE,8BAChC,CACJ,CAAC,CAAEf,CAAO,CAAC,CACf,CAMAgB,UAAUA,CAAA,CAAG,CACTC,MAAM,CAACC,cAAc,CAAG,IAAI,CAACC,mBAAmB,CAACC,IAAI,CAAC,IAAI,CAAC,C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