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ockspot/./app/javascript/init_consent_from_cookie.js","webpack://dockspot/./app/javascript/sparkles/dom.js","webpack://dockspot/./node_modules/js-cookie/dist/js.cookie.mjs","webpack://dockspot/./app/javascript/common/utils/cookie.js"],"sourcesContent":["import { dom } from \"./dom\";\nimport { getCookie, setCookie } from \"../common/utils/cookie\";\n\nexport const updateConsentFromCookie = function() {\n switch (readCookiesConsentCookie()) {\n case \"accepted\":\n acceptTracking();\n break;\n case \"refused\":\n refuseTracking();\n break;\n default:\n refuseTracking();\n break;\n }\n}\n\nexport const handleCookieConsentHandlers = function() {\n updateConsentFromCookie();\n showCookiesConsentStatus();\n attachAccept();\n attachRefuse();\n};\n\nvar attachAccept = () => dom.findAll(\"a[data-cookie-consent='accept']\").on(\"click\", function(event) {\n writeCookiesConsentCookie(\"accepted\");\n updateConsentFromCookie();\n showCookiesConsentStatus();\n event.preventDefault();\n});\n\nvar attachRefuse = () => dom.findAll(\"a[data-cookie-consent='refuse']\").on(\"click\", function(event) {\n writeCookiesConsentCookie(\"refused\");\n window.location.reload(true);\n event.preventDefault();\n});\n\nconst consentCookieName = \"cookieAcceptStatusV2\"\n\nvar writeCookiesConsentCookie = value => // NOTE: Experation is set to 10 years. Safari caps expiration to 7 days. See https://www.cookiestatus.com/\n setCookie(consentCookieName, value, {expires: 365 * 10});\n\nconst readCookiesConsentCookie = () => getCookie(consentCookieName);\n\nconst refuseTracking = function() {\n if (typeof gtag === \"function\") {\n gtag(\"consent\", \"update\", {\n ad_storage: 'denied',\n ad_user_data: 'denied',\n ad_personalization: 'denied',\n analytics_storage: 'denied',\n });\n }\n if (typeof fbq === \"function\") {\n fbq(\"consent\", \"revoke\");\n }\n};\n\nconst acceptTracking = function() {\n if (typeof gtag === \"function\") {\n const consent = {\n ad_storage: 'granted',\n ad_user_data: 'granted',\n ad_personalization: 'granted',\n analytics_storage: 'granted',\n };\n gtag(\"consent\", \"update\", consent);\n gtag(\"event\", \"consent_updated\", consent);\n }\n if (typeof fbq === \"function\") {\n fbq(\"consent\", \"grant\");\n }\n};\n\nvar showCookiesConsentStatus = function() {\n dom.find(\"#cookies-accepted\").hide();\n dom.find(\"#cookies-refused\").hide();\n dom.find(\"#cookies-unknown\").hide();\n\n switch (readCookiesConsentCookie()) {\n case \"accepted\":\n dom.find(\"#cookies-accepted\").show();\n break;\n case \"refused\":\n dom.find(\"#cookies-refused\").show();\n break;\n default:\n dom.find(\"#cookies-unknown\").show();\n break;\n }\n};\n","import { updateConsentFromCookie } from \"./sparkles/cookies\";\n\nupdateConsentFromCookie();\n\nconsole.debug(\"init_consent_from_cookie.js initialized\");\n","const domNodeAliases = {\n findAll: \"querySelectorAll\",\n find: \"querySelector\",\n set: \"setAttribute\",\n get: \"getAttribute\",\n on: \"addEventListener\"\n};\n\nexport var dom = {\n find() {\n return document.querySelector.apply(document, arguments);\n },\n\n findAll() {\n return document.querySelectorAll.apply(document, arguments);\n },\n\n createElement(tagName, attributes) {\n if (attributes == null) { attributes = {}; }\n const element = document.createElement(tagName);\n for (let key in attributes) { const value = attributes[key]; element.setAttribute(key, value); }\n return element;\n },\n\n install(window) {\n for (let alias of Object.keys(domNodeAliases)) {\n const original = domNodeAliases[alias];\n window.Element.prototype[alias] = window.Element.prototype[original];\n window.Document.prototype[alias] = window.Document.prototype[original];\n window.DocumentFragment.prototype[alias] = window.DocumentFragment.prototype[original];\n }\n\n window.NodeList.prototype.on = function() { Array.from(this).map((node) => node.on(...arguments)); };\n\n window.Element.prototype.hide = function() { this.style.display = \"none\"; };\n window.NodeList.prototype.hide = function() { Array.from(this).map((element) => element.hide()); };\n\n window.Element.prototype.show = function() { this.style.display = \"block\"; };\n window.NodeList.prototype.show = function() { Array.from(this).map((element) => element.show()); };\n }\n};\n","/*! js-cookie v3.0.5 | MIT */\n/* eslint-disable no-var */\nfunction assign (target) {\n for (var i = 1; i < arguments.length; i++) {\n var source = arguments[i];\n for (var key in source) {\n target[key] = source[key];\n }\n }\n return target\n}\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\nvar defaultConverter = {\n read: function (value) {\n if (value[0] === '\"') {\n value = value.slice(1, -1);\n }\n return value.replace(/(%[\\dA-F]{2})+/gi, decodeURIComponent)\n },\n write: function (value) {\n return encodeURIComponent(value).replace(\n /%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,\n decodeURIComponent\n )\n }\n};\n/* eslint-enable no-var */\n\n/* eslint-disable no-var */\n\nfunction init (converter, defaultAttributes) {\n function set (name, value, attributes) {\n if (typeof document === 'undefined') {\n return\n }\n\n attributes = assign({}, defaultAttributes, attributes);\n\n if (typeof attributes.expires === 'number') {\n attributes.expires = new Date(Date.now() + attributes.expires * 864e5);\n }\n if (attributes.expires) {\n attributes.expires = attributes.expires.toUTCString();\n }\n\n name = encodeURIComponent(name)\n .replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent)\n .replace(/[()]/g, escape);\n\n var stringifiedAttributes = '';\n for (var attributeName in attributes) {\n if (!attributes[attributeName]) {\n continue\n }\n\n stringifiedAttributes += '; ' + attributeName;\n\n if (attributes[attributeName] === true) {\n continue\n }\n\n // Considers RFC 6265 section 5.2:\n // ...\n // 3. If the remaining unparsed-attributes contains a %x3B (\";\")\n // character:\n // Consume the characters of the unparsed-attributes up to,\n // not including, the first %x3B (\";\") character.\n // ...\n stringifiedAttributes += '=' + attributes[attributeName].split(';')[0];\n }\n\n return (document.cookie =\n name + '=' + converter.write(value, name) + stringifiedAttributes)\n }\n\n function get (name) {\n if (typeof document === 'undefined' || (arguments.length && !name)) {\n return\n }\n\n // To prevent the for loop in the first place assign an empty array\n // in case there are no cookies at all.\n var cookies = document.cookie ? document.cookie.split('; ') : [];\n var jar = {};\n for (var i = 0; i < cookies.length; i++) {\n var parts = cookies[i].split('=');\n var value = parts.slice(1).join('=');\n\n try {\n var found = decodeURIComponent(parts[0]);\n jar[found] = converter.read(value, found);\n\n if (name === found) {\n break\n }\n } catch (e) {}\n }\n\n return name ? jar[name] : jar\n }\n\n return Object.create(\n {\n set,\n get,\n remove: function (name, attributes) {\n set(\n name,\n '',\n assign({}, attributes, {\n expires: -1\n })\n );\n },\n withAttributes: function (attributes) {\n return init(this.converter, assign({}, this.attributes, attributes))\n },\n withConverter: function (converter) {\n return init(assign({}, this.converter, converter), this.attributes)\n }\n },\n {\n attributes: { value: Object.freeze(defaultAttributes) },\n converter: { value: Object.freeze(converter) }\n }\n )\n}\n\nvar api = init(defaultConverter, { path: '/' });\n/* eslint-enable no-var */\n\nexport { api as default };\n","/*\n * decaffeinate suggestions:\n * DS102: Remove unnecessary code created because of implicit returns\n * Full docs: https://github.com/decaffeinate/decaffeinate/blob/main/docs/suggestions.md\n */\nimport Cookies from \"js-cookie\";\n\n// Read more at https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies\n// * httpOnly & secure: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Restrict_access_to_cookies\n// * domain: https://github.com/js-cookie/js-cookie#domain\n// * sameSite: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#SameSite_attribute\n// * path: https://developer.mozilla.org/en-US/docs/Web/HTTP/Cookies#Path_attribute\n\nexport var setCookie = (name, value, { expires }) => Cookies.set(\n name,\n value, {\n expires,\n sameSite: \"Lax\",\n secure: false,\n path: \"/\"\n}\n);\n\nexport var getCookie = name => Cookies.get()[name];\n"],"names":["updateConsentFromCookie","readCookiesConsentCookie","acceptTracking","refuseTracking","handleCookieConsentHandlers","showCookiesConsentStatus","attachAccept","attachRefuse","dom","findAll","on","event","writeCookiesConsentCookie","preventDefault","window","location","reload","consentCookieName","value","setCookie","expires","getCookie","gtag","ad_storage","ad_user_data","ad_personalization","analytics_storage","fbq","consent","find","hide","show","console","debug","domNodeAliases","set","get","document","querySelector","apply","arguments","querySelectorAll","createElement","tagName","attributes","element","key","setAttribute","install","_i","_Object$keys","Object","keys","length","alias","original","Element","prototype","Document","DocumentFragment","NodeList","_arguments","Array","from","this","map","node","style","display","target","i","source","api","init","converter","defaultAttributes","name","Date","now","toUTCString","encodeURIComponent","replace","decodeURIComponent","escape","stringifiedAttributes","attributeName","split","cookie","write","create","cookies","jar","parts","slice","join","found","read","e","remove","withAttributes","withConverter","freeze","path","_ref","Cookies","sameSite","secure"],"sourceRoot":""}