/*! js-cookie v3.0.1 | mit */ ; (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, (function () { var current = global.cookies; var exports = global.cookies = factory(); exports.noconflict = function () { global.cookies = current; return exports; }; }())); }(this, (function () { 'use strict'; /* eslint-disable no-var */ function assign (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { target[key] = source[key]; } } return target } /* eslint-enable no-var */ /* eslint-disable no-var */ var defaultconverter = { read: function (value) { if (value[0] === '"') { value = value.slice(1, -1); } return value.replace(/(%[\da-f]{2})+/gi, decodeuricomponent) }, write: function (value) { return encodeuricomponent(value).replace( /%(2[346bf]|3[ac-f]|40|5[bde]|60|7[bcd])/g, decodeuricomponent ) } }; /* eslint-enable no-var */ /* eslint-disable no-var */ function init (converter, defaultattributes) { function set (key, value, attributes) { if (typeof document === 'undefined') { return } attributes = assign({}, defaultattributes, attributes); if (typeof attributes.expires === 'number') { attributes.expires = new date(date.now() + attributes.expires * 864e5); } if (attributes.expires) { attributes.expires = attributes.expires.toutcstring(); } key = encodeuricomponent(key) .replace(/%(2[346b]|5e|60|7c)/g, decodeuricomponent) .replace(/[()]/g, escape); var stringifiedattributes = ''; for (var attributename in attributes) { if (!attributes[attributename]) { continue } stringifiedattributes += '; ' + attributename; if (attributes[attributename] === true) { continue } // considers rfc 6265 section 5.2: // ... // 3. if the remaining unparsed-attributes contains a %x3b (";") // character: // consume the characters of the unparsed-attributes up to, // not including, the first %x3b (";") character. // ... stringifiedattributes += '=' + attributes[attributename].split(';')[0]; } return (document.cookie = key + '=' + converter.write(value, key) + stringifiedattributes) } function get (key) { if (typeof document === 'undefined' || (arguments.length && !key)) { return } // to prevent the for loop in the first place assign an empty array // in case there are no cookies at all. var cookies = document.cookie ? document.cookie.split('; ') : []; var jar = {}; for (var i = 0; i < cookies.length; i++) { var parts = cookies[i].split('='); var value = parts.slice(1).join('='); try { var foundkey = decodeuricomponent(parts[0]); jar[foundkey] = converter.read(value, foundkey); if (key === foundkey) { break } } catch (e) {} } return key ? jar[key] : jar } return object.create( { set: set, get: get, remove: function (key, attributes) { set( key, '', assign({}, attributes, { expires: -1 }) ); }, withattributes: function (attributes) { return init(this.converter, assign({}, this.attributes, attributes)) }, withconverter: function (converter) { return init(assign({}, this.converter, converter), this.attributes) } }, { attributes: { value: object.freeze(defaultattributes) }, converter: { value: object.freeze(converter) } } ) } var api = init(defaultconverter, { path: '/' }); /* eslint-enable no-var */ return api; })));