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js","webpack://dockspot/./app/javascript/init_consent_from_cookie.js","webpack://dockspot/./app/javascript/sparkles/cookies.js","webpack://dockspot/./app/javascript/sparkles/dom.js"],"sourcesContent":["/*! 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","import { updateConsentFromCookie } from \"./sparkles/cookies\";\n\nupdateConsentFromCookie();\n\nconsole.debug(\"init_consent_from_cookie.js initialized\");\n","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","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"],"names":["target","i","arguments","length","source","key","api","init","converter","defaultAttributes","set","name","value","attributes","document","expires","Date","now","toUTCString","encodeURIComponent","replace","decodeURIComponent","escape","stringifiedAttributes","attributeName","split","cookie","write","Object","create","get","cookies","jar","parts","slice","join","found","read","e","remove","withAttributes","this","withConverter","freeze","path","setCookie","_ref","Cookies","sameSite","secure","getCookie","updateConsentFromCookie","console","debug","readCookiesConsentCookie","acceptTracking","refuseTracking","handleCookieConsentHandlers","showCookiesConsentStatus","attachAccept","attachRefuse","dom","findAll","on","event","writeCookiesConsentCookie","preventDefault","window","location","reload","consentCookieName","gtag","ad_storage","ad_user_data","ad_personalization","analytics_storage","fbq","consent","find","hide","show","domNodeAliases","querySelector","apply","querySelectorAll","createElement","tagName","element","setAttribute","install","_i","_Object$keys","keys","alias","original","Element","prototype","Document","DocumentFragment","NodeList","_arguments","Array","from","map","node","style","display"],"sourceRoot":""}