{"version":3,"file":"consent.js","mappings":"+2CAAqBA,EAAO,WAavB,O,EAXD,SAAAA,IACA,IAAAC,EAAA,M,4FAAAC,CAAA,KAAAF,GACoBG,SAASC,iBAAiB,gBAElCC,QAAQ,SAACC,GACAA,EAAGC,QAAQ,QAEnBC,iBAAiB,SAAU,SAACC,GAC7BR,EAAKS,SAASJ,EAClB,EACJ,EACJ,G,EAAC,EAAAK,IAAA,WAAAC,MAED,SAASN,GAML,GAAIO,OAAOC,UAAW,CAClB,IAEMC,EAFiBC,OAAOC,OAAOH,WAAWI,OAAO,SAAAC,GAAC,MAAgB,WAAbC,EAAOD,IAA2B,YAATA,EAAE,EAAgB,GAE7DE,IAAI,SAAAF,GAAC,OAAEA,aAAC,EAADA,EAAI,KAAI,CAAC,CAAC,GAN7CG,OAAO,SAACC,EAAKC,GAAG,OAAAC,EAAAA,EAAA,GAAWF,GAAQC,EAAG,EAAK,CAAC,GAQzDlB,EAAGM,MAAQc,KAAKC,UAAUZ,EAC9B,CACJ,M,6EAAC,CA5BuB,GCE5BF,OAAOe,IAAMf,OAAOe,KAAO,CAAC,EAC5Bf,OAAOe,IAAI5B,QAAU,IAAIA,C","sources":["webpack://d3r-core/./resources/javascript/v2/src/Consent/Consent.js","webpack://d3r-core/./resources/javascript/v2/consent.js"],"sourcesContent":["export default class Consent\n{\n    constructor()\n    {\n        const consent = document.querySelectorAll('.d3r-consent');\n\n        consent.forEach((el) => {\n            const form = el.closest('form');\n\n            form.addEventListener('submit', (e) => {\n                this.populate(el);\n            });\n        });\n    }\n\n    populate(el)\n    {\n        const mergeObjects = function(array) {\n            return array.reduce((acc, obj) => ({ ...acc, ...obj }), {});\n        };\n\n        if (window.dataLayer) {\n            const consentHistory = Object.values(dataLayer).filter(a=> typeof a === 'object' && a[0] === 'consent');\n\n            const data = mergeObjects(consentHistory.map(a=>a?.[2]||{}));\n\n            el.value = JSON.stringify(data);\n        }\n    }\n}\n","import Consent from \"./src/Consent/Consent\";\n\nwindow.D3R = window.D3R || {};\nwindow.D3R.Consent = new Consent();\n"],"names":["Consent","_this","_classCallCheck","document","querySelectorAll","forEach","el","closest","addEventListener","e","populate","key","value","window","dataLayer","data","Object","values","filter","a","_typeof","map","reduce","acc","obj","_objectSpread","JSON","stringify","D3R"],"sourceRoot":""}