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mjs","webpack://ucn/./src/common/cookie/cookie.ts","webpack://ucn/./src/common/try-parse-json.js","webpack://ucn/./src/services/favorites/favorite-cookie-service.ts","webpack://ucn/./src/components/header/header-favorite.js"],"sourcesContent":["/*! js-cookie v3.0.1 | 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 (key, 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 key = encodeURIComponent(key)\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 key + '=' + converter.write(value, key) + stringifiedAttributes)\n }\n\n function get (key) {\n if (typeof document === 'undefined' || (arguments.length && !key)) {\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 foundKey = decodeURIComponent(parts[0]);\n jar[foundKey] = converter.read(value, foundKey);\n\n if (key === foundKey) {\n break\n }\n } catch (e) {}\n }\n\n return key ? jar[key] : jar\n }\n\n return Object.create(\n {\n set: set,\n get: get,\n remove: function (key, attributes) {\n set(\n key,\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 default api;\n","import Cookies from \"js-cookie\";\nimport { tryParseJson } from \"@common/try-parse-json.js\";\nvar setCookie = function (name, value, options) {\n Cookies.set(name, value, options);\n};\nvar removeCookie = function (name) { return Cookies.remove(name); };\nvar getCookie = function (name) {\n var data = Cookies.get(name);\n return tryParseJson(data);\n};\nexport { setCookie, removeCookie, getCookie };\n","export const tryParseJson = (value) => {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch (e) {\n\t\treturn undefined;\n\t}\n};\n","var __read = (this && this.__read) || function (o, n) {\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\n if (!m) return o;\n var i = m.call(o), r, ar = [], e;\n try {\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\n }\n catch (error) { e = { error: error }; }\n finally {\n try {\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\n }\n finally { if (e) throw e.error; }\n }\n return ar;\n};\nvar __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {\n if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {\n if (ar || !(i in from)) {\n if (!ar) ar = Array.prototype.slice.call(from, 0, i);\n ar[i] = from[i];\n }\n }\n return to.concat(ar || Array.prototype.slice.call(from));\n};\nimport { getCookie, setCookie } from \"@common/cookie/cookie\";\nexport var FAVORITES_COOKIE_NAME = \"ucn-favorites\";\nvar COOKIE_OPTIONS = {\n path: \"/\",\n sameSite: \"strict\",\n secure: true,\n expires: 500,\n};\nvar get = function () {\n var favorites = getCookie(FAVORITES_COOKIE_NAME);\n if (!favorites)\n return { collection: [] };\n return favorites;\n};\nvar has = function (id, favorites) { var _a; return (_a = favorites === null || favorites === void 0 ? void 0 : favorites.collection) === null || _a === void 0 ? void 0 : _a.includes(id); };\nvar set = function (id, favorites) {\n var collection = __spreadArray(__spreadArray([], __read(((favorites === null || favorites === void 0 ? void 0 : favorites.collection) ? favorites.collection : [])), false), [\n id,\n ], false);\n setCookie(FAVORITES_COOKIE_NAME, JSON.stringify({ collection: collection }), COOKIE_OPTIONS);\n return { collection: collection };\n};\nvar remove = function (id, favorites) {\n var collection = favorites.collection.filter(function (value) { return value !== id; });\n setCookie(FAVORITES_COOKIE_NAME, JSON.stringify({ collection: collection }), COOKIE_OPTIONS);\n return { collection: collection };\n};\nexport var favoriteCookieService = { get: get, set: set, remove: remove, has: has };\n","import { favoriteCookieService } from \"@services/favorites/favorite-cookie-service\";\n\nexport default class HeaderFavorite {\n\tconstructor(config) {\n\t\tthis.el = config.el;\n\t\tthis.hasFavorites = null;\n\t\tthis.init();\n\t}\n\n\tinit() {\n\t\tthis.setHasFavorites();\n\t}\n\n\tsetHasFavorites() {\n\t\tthis.hasFavorites = favoriteCookieService.get().collection.length > 0;\n\n\t\tthis.toggleNotificationDot(this.hasFavorites);\n\t}\n\n\ttoggleNotificationDot(show) {\n\t\tif (show) {\n\t\t\tthis.el.classList.add(\"header-favorite__link--active\");\n\t\t} else {\n\t\t\tthis.el.classList.remove(\"header-favorite__link--active\");\n\t\t}\n\t}\n}\n"],"names":["target","i","arguments","length","source","key","api","init","converter","defaultAttributes","set","value","attributes","document","expires","Date","now","toUTCString","encodeURIComponent","replace","decodeURIComponent","escape","stringifiedAttributes","attributeName","split","cookie","write","Object","create","get","cookies","jar","parts","slice","join","foundKey","read","e","remove","withAttributes","this","withConverter","freeze","path","getCookie","name","JSON","parse","tryParseJson","FAVORITES_COOKIE_NAME","favoriteCookieService","favorites","collection","HeaderFavorite","config","el","hasFavorites","setHasFavorites","toggleNotificationDot","show","classList","add"],"sourceRoot":""}