praiadeseselle/site/modules/PrivacyWire/js/PrivacyWire_legacy.js

1 line
14 KiB
JavaScript
Raw Permalink Normal View History

2024-04-04 15:12:59 +02:00
!function(){"use strict";function _toPropertyKey(e){var t=function _toPrimitive(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:String(t)}function _typeof(e){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},_typeof(e)}function _defineProperties(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,_toPropertyKey(o.key),o)}}function _arrayLikeToArray(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function _createForOfIteratorHelper(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function _unsupportedIterableToArray(e,t){if(e){if("string"==typeof e)return _arrayLikeToArray(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?_arrayLikeToArray(e,t):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,F=function(){};return{s:F,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:F}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,r=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return r=e.done,e},e:function(e){a=!0,s=e},f:function(){try{r||null==n.return||n.return()}finally{if(a)throw s}}}}String.prototype.formatUnicorn=String.prototype.formatUnicorn||function(){var e=this.toString();if(arguments.length){var t,n=_typeof(arguments[0]),o="string"===n||"number"===n?Array.prototype.slice.call(arguments):arguments[0];for(t in o)e=e.replace(new RegExp("\\{"+t+"\\}","gi"),o[t])}return e};var e=function(){function PrivacyWire(e){!function _classCallCheck(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,PrivacyWire),this.name="privacywire",this.toggleToStatus=!0,this.cookieGroups=Object.freeze(["necessary","functional","statistics","marketing","external_media"]),this.settings=this.sanitizeSettings(e),this.userConsent=this.sanitizeStoredConsent(),this.elements=this.initiateElements(),this.syncConsentToCheckboxes(),this.checkForValidConsent()||this.showBanner(),this.checkElementsWithRequiredConsent(),this.handleButtons()}return function _createClass(e,t,n){return t&&_defineProperties(e.prototype,t),n&&_defineProperties(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}(PrivacyWire,[{key:"sanitizeSettings",value:function sanitizeSettings(e){var t={};t.version=parseInt(e.version),t.dnt=Boolean(parseInt(e.dnt)),t.bots=Boolean(parseInt(e.bots)),t.customFunction="".concat(e.customFunction),t.messageTimeout=parseInt(e.messageTimeout),t.consentByClass=Boolean(parseInt(e.consentByClass)),t.cookieGroups={};var n,o=_createForOfIteratorHelper(this.cookieGroups);try{for(o.s();!(n=o.n()).done;){var s=n.value;t.cookieGroups[s]="".concat(e.cookieGroups[s])}}catch(e){o.e(e)}finally{o.f()}return t}},{key:"sanitizeStoredConsent",value:function sanitizeStoredConsent(){if(!window.localStorage.getItem(this.name))return this.getDefaultConsent();var e=JSON.parse(window.localStorage.getItem(this.name));if(parseInt(e.version)!==this.settings.version)return this.getDefaultConsent();if(void 0===e.cookieGroups)return this.removeStoredConsent(),this.getDefaultConsent();var t={};t.version=parseInt(e.version),t.cookieGroups={};var n,o=_createForOfIteratorHelper(this.cookieGroups);try{for(o.s();!(n=o.n()).done;){var s=n.value;t.cookieGroups[s]=Boolean(e.cookieGroups[s])}}catch(e){o