{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./app/javascript/packs/consenter.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","window","MY_CONSENT_PREFERENCES","purposes","MY_CONSENT_CALLBACK","CustomEvent","event","params","bubbles","cancelable","detail","undefined","evt","document","createEvent","initCustomEvent","Event","consenter","js_srcs","js_lib","reg_functions","additionalCallbacks","runScript","id","script","checkIfCMPPrefsAreMet","cmpPref","checkIfDepsAreMet","deps","logger","next","ensureArray","Array","isArray","addEventListenerOnce","target","type","listener","addOptions","removeOptions","addEventListener","fn","removeEventListener","apply","this","arguments","length","some","pref","checkConsent","every","handle","go_on","dep","loaded","getDepEvtName","getPrevEvtName","loadAll","js","preference","jsLoader","src","async","splice","createElement","defer","onload","onreadystatechange","libIsLoaded","head","appendChild","message","console","log","start","websitePreferences","tagManagerPreferences","fullConsent","_sp_","config","targetingParams","acps","purposeId","dispatchEvent","firePreferencesEvents","getElementsByTagName","classList","add","writePreferencesToDOM","preferences","dataLayer","push","tcfApiConsentAdapter","UTOPIA_PURPOSES","WRITE_COOKIES","ANALYTICS","FULL_CONSENT","initDataLayer","addAfterLoadCallback","callback","libname","scriptLoaded","loadJS","afterLoadCb","indexOf","waitForDependency","waitFor","waitForCmpPref","dependencies","Date","now","Math","floor","random","toString","myPref","myDep"],"mappings":"aACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QAKfF,EAAoBQ,EAAIF,E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B,EAAe6D,IAClD9F,EAAWC,QAGR,OAwQbtB,EAAOgB,UAAYA,EACnBhB,EAAOG,oBAAsBH,EAAOgB,UAAUyD,MAxYlD,CA0YGzE","file":"js/consenter-791a192fd535d944f5bf.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/packs/\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 20);\n","/*eslint-disable */\nwindow.MY_CONSENT_PREFERENCES = {purposes: {1: true}};\nwindow.MY_CONSENT_CALLBACK = () => {\n};\n/* eslint-enable */\n/*eslint-disable */\n(function () {\n if ( typeof window.CustomEvent === \"function\" ) return false; //If not IE\n\n function CustomEvent ( event, params ) {\n params = params || { bubbles: false, cancelable: false, detail: undefined };\n var evt = document.createEvent( 'CustomEvent' );\n evt.initCustomEvent( event, params.bubbles, params.cancelable, params.detail );\n return evt;\n }\n\n CustomEvent.prototype = window.Event.prototype;\n\n window.CustomEvent = CustomEvent;\n})();\n/* eslint-enable */\n(\n function( window ) {\n let consenter = {};\n let js_srcs = [];\n let js_lib = {};\n let reg_functions = {};\n\n let additionalCallbacks = [];\n\n /**\n * Startpoint for this script - executed by CMP callback\n * @param updated_preferences\n * @param full_consent\n */\n consenter.start = function( websitePreferences, tagManagerPreferences, fullConsent ) {\n logger( 'consenter started' );\n // contentpass handling\n if (typeof window._sp_ !== 'undefined' && window._sp_.config.targetingParams.acps === \"true\" ) {\n websitePreferences = { 1: true };\n tagManagerPreferences = { 2: false, 3: false, 6: false };\n } \n /*eslint-disable */\n window.MY_CONSENT_PREFERENCES.purposes = websitePreferences;\n /* eslint-enable */\n firePreferencesEvents( websitePreferences );\n writePreferencesToDOM( websitePreferences );\n loadAll();\n initDataLayer( tagManagerPreferences, fullConsent );\n };\n\n /**\n * Add callback to be executed after given script is loaded.\n * @param name\n * @param callback\n */\n consenter.addAfterLoadCallback = function( name, callback ) {\n if ( !scriptLoaded( name ) ) {\n additionalCallbacks.push( {name: name, callback: callback} );\n return;\n }\n\n callback();\n };\n\n /**\n * Register Scripts to load after consent is given\n * @param name of the script has to be a valid js Object key\n * @param src of the script\n * @param preference consent preference (between 1..5)\n * @param async ether async or defer\n * @param dep array of dependencies\n */\n consenter.loadJS = function( name, src, preference = 1, async = 'async', dep = [] ) {\n js_srcs.push( {name: name, src: src, preference: preference, async: async, deps: dep} );\n js_lib[name] = {name: name, loaded: false};\n loadAll();\n };\n\n /**\n * manually register scripts as loaded (for blocking loaded scripts)\n * @param name of the script has to be a valid js Object key\n */\n consenter.libIsLoaded = function( name ) {\n js_lib[name] = {name: name, loaded: true};\n\n for ( let afterLoadCb of additionalCallbacks ) {\n if ( name === afterLoadCb.name ) {\n afterLoadCb.callback();\n additionalCallbacks.splice( additionalCallbacks.indexOf( afterLoadCb ), 1 );\n }\n }\n\n const evt = new CustomEvent( getDepEvtName( name ) );\n window.dispatchEvent( evt );\n };\n\n /**\n * wait with execution of callback until all dependencies are resolved\n * @param deps\n * @param next callback\n */\n consenter.waitForDependency = function( deps, next ) {\n consenter.waitFor( [], deps, next, false );\n };\n\n /**\n * wait with execution of callback until one of the CMP Preferences is given\n * @param cmpPref\n * @param next callback\n */\n consenter.waitForCmpPref = function( cmpPref, next ) {\n consenter.waitFor( cmpPref, [], next, false );\n };\n\n /**\n * wait with execution of cb function until all dependencies are resolved\n * @param cmpPref array with CMP preferences\n * @param deps array with dependencies\n * @param next Callback function\n */\n consenter.waitFor = function( cmpPref, deps, next ) {\n const preferences = ensureArray( cmpPref );\n const dependencies = ensureArray( deps );\n const id = getUniquID();\n reg_functions[id] = {cmpPref: preferences, deps: dependencies, next: next};\n\n if ( checkIfCMPPrefsAreMet( preferences ) === true && checkIfDepsAreMet( dependencies ) === true && reg_functions[id] ) {\n runScript( id );\n } else {\n preferences.every( ( myPref ) => {\n if ( !checkConsent( myPref ) ) {\n logger( 'create listener for: ' + getPrevEvtName( myPref ) );\n addEventListenerOnce( window, getPrevEvtName( myPref ), () => {\n logger( 'execute listener for: ' + getPrevEvtName( myPref ) );\n runScript( id );\n } );\n }\n return true;\n } );\n dependencies.every( ( myDep ) => {\n if ( js_lib[myDep] && js_lib[myDep].loaded === false ) {\n logger( 'create listener for: ' + getDepEvtName( myDep ) );\n addEventListenerOnce( window, getDepEvtName( myDep ), () => {\n logger( 'execute listener for: ' + getDepEvtName( myDep ) );\n runScript( id );\n } );\n }\n return true;\n } );\n }\n };\n\n /**\n * Run an inline script which is registered by waitFor functions\n * @param id of the Script\n */\n function runScript( id ) {\n if ( reg_functions[id] ) {\n const script = reg_functions[id];\n if ( checkIfCMPPrefsAreMet( script.cmpPref ) === true && checkIfDepsAreMet( script.deps ) === true ) {\n logger( 'all dependencies met, now run script with pref: ' + script.cmpPref + ' and dep: ' + script.deps + ' and ID: ' + id );\n script.next();\n reg_functions[id] = false;\n }\n }\n }\n\n /**\n * Ensure the value is an Array\n * @param value\n * @return {*[]|*}\n */\n function ensureArray( value ) {\n if ( !Array.isArray( value ) ) {\n return [value];\n }\n return value;\n }\n\n /**\n * Helper function to create a Event Listener which deletes itself on first execution\n * @param target Element\n * @param type Event Name\n * @param listener Callback function\n * @param addOptions\n * @param removeOptions\n */\n function addEventListenerOnce( target, type, listener, addOptions, removeOptions ) {\n target.addEventListener( type, function fn( event ) {\n target.removeEventListener( type, fn, removeOptions );\n listener.apply( this, arguments );\n }, addOptions );\n }\n\n /**\n * returns a unique Number based on Microtime and a random number\n */\n function getUniquID() {\n return (\n Date.now() + Math.floor( Math.random() * 100 )\n ).toString( 16 );\n }\n\n /**\n * Checks if the needed consent is given\n * @param cmpPref\n * @return {boolean}\n */\n function checkIfCMPPrefsAreMet( cmpPref ) {\n if ( cmpPref.length === 0 ) {\n return true;\n }\n return cmpPref.some( ( pref ) => checkConsent( pref ) );\n }\n\n /**\n * Checks the given Consent\n * @param pref Level\n * @return {boolean}\n */\n function checkConsent( pref ) {\n return !!(\n typeof window.MY_CONSENT_PREFERENCES.purposes !== 'undefined' && window.MY_CONSENT_PREFERENCES.purposes[pref]\n );\n }\n\n /**\n * Checks if all dependencies are met\n * @param {Array} deps List of dependencies.\n * @return {boolean}\n */\n function checkIfDepsAreMet( deps ) {\n if ( deps.every( ( handle ) => (\n handle === ''\n ) ) ) {\n return true;\n }\n let go_on = false;\n deps.every( ( dep ) => {\n go_on = !!(\n js_lib[dep] && js_lib[dep].loaded\n );\n return true;\n } );\n\n return go_on;\n }\n\n /**\n * Generate the event name for dependencies\n * @param name\n * @return {string}\n */\n function getDepEvtName( name ) {\n return 'scriptIsLoaded_' + name;\n }\n\n /**\n * Generate the event name for CMP preferences\n * @param pref\n * @return {string}\n */\n function getPrevEvtName( pref ) {\n return 'cmpPreferenceIsGiven_' + pref;\n }\n\n function scriptLoaded( name ) {\n for ( let libname in js_lib ) {\n if ( js_lib[libname].name === name && js_lib[libname].loaded ) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * load all registered Scripts if the consent is given\n */\n function loadAll() {\n if (\n js_srcs.length > 0 &&\n typeof window.MY_CONSENT_PREFERENCES.purposes !== 'undefined'\n ) {\n for ( let i = 0; i < js_srcs.length; i++ ) {\n let js = js_srcs[i];\n if (\n js.preference !== undefined &&\n window.MY_CONSENT_PREFERENCES.purposes[js.preference] === true\n ) {\n let go_on = false;\n if ( js.deps.length > 0 ) {\n js.deps.every( ( dep ) => {\n if ( js_lib[dep] && js_lib[dep].loaded ) {\n go_on = true;\n } else {\n go_on = false;\n addEventListenerOnce( window, getDepEvtName( dep ), () => loadAll() );\n }\n return true;\n } );\n } else {\n go_on = true;\n }\n if ( go_on ) {\n jsLoader( js.src, js.name, js.async );\n js_srcs.splice( i, 1 );\n i--;\n }\n }\n }\n }\n }\n\n /**\n * load a JS file asynchronously\n *\n * @see https://github.com/filamentgroup/loadJS/\n * @param src\n * @param name\n * @param async\n * @return {HTMLScriptElement}\n */\n function jsLoader( src, name, async = 'async' ) {\n // let ref = window.document.getElementsByTagName( 'script' )[0];\n let script = window.document.createElement( 'script' );\n script.src = src;\n if ( async === 'async' ) {\n script.async = true;\n } else {\n script.defer = true;\n }\n script.id = name;\n script.onload = script.onreadystatechange = function() {\n script.onreadystatechange = script.onload = null;\n consenter.libIsLoaded( name );\n };\n document.head.appendChild( script );\n // ref.parentNode.insertBefore( script, ref );\n return script;\n }\n\n /**\n * If the consent is given we fire Events for every consent preference.\n * @param preference the given Preferences\n */\n function firePreferencesEvents( preference ) {\n if ( preference ) {\n for ( let purposeId in preference ) {\n if ( preference[purposeId] ) {\n const evt = new Event( getPrevEvtName( purposeId ) );\n window.dispatchEvent( evt );\n }\n }\n }\n }\n\n /**\n * If the consent is given we write consent information to the DOM for CSS handling.\n * @param preference the given Preferences\n */\n function writePreferencesToDOM( preference ) {\n for ( let purposeId in preference ) {\n if ( preference[purposeId] ) {\n let html = document.getElementsByTagName( 'html' )[0];\n html.classList.add( 'cmp-consent-level-' + purposeId );\n }\n }\n }\n\n /**\n * Init the Google Tagmanager Datalayer with the CMP preferences\n */\n function initDataLayer( preferences, fullConsent ) {\n /*eslint-disable */\n window.dataLayer.push( {\n 'cmp_data': fullConsent,\n 'event': 'cmp_consent_test'\n } );\n\n if ( preferences[window.tcfApiConsentAdapter.UTOPIA_PURPOSES.WRITE_COOKIES] )\n window.dataLayer.push( {\n 'cmp_cookies': true,\n 'event': 'cmp_cookies_on'\n } );\n\n if ( !preferences[window.tcfApiConsentAdapter.UTOPIA_PURPOSES.ANALYTICS] )\n window.dataLayer.push( {\n 'cmp_analytics': false,\n 'event': 'cmp_analytics_off'\n } );\n else\n window.dataLayer.push( {\n 'cmp_analytics': true,\n 'event': 'cmp_analytics_on'\n } );\n \n if ( preferences[window.tcfApiConsentAdapter.UTOPIA_PURPOSES.FULL_CONSENT] )\n window.dataLayer.push( {\n 'cmp_full_consent': true,\n 'event': 'cmp_full_consent'\n } );\n \n /*eslint-enable */\n }\n\n function logger( message ) {\n console.log( message ); // eslint-disable-line no-console\n }\n\n // expose the 'consenter' object globally. Use it to expose anything in here that's useful to other parts of your application.\n window.consenter = consenter;\n window.MY_CONSENT_CALLBACK = window.consenter.start;\n }\n)( window );\n"],"sourceRoot":""}