@amaui/cookie
Advanced tools
Comparing version
@@ -0,9 +1,24 @@ | ||
export interface IOptions { | ||
namespace?: string; | ||
namespace_separator?: string; | ||
} | ||
declare class AmauiCookie { | ||
options: IOptions; | ||
removeNotAllowed: string[]; | ||
constructor(options?: IOptions); | ||
get namespace(): string; | ||
static get cookie(): string; | ||
static get cookies(): Record<string, any>; | ||
static has(name: string): any; | ||
static get(name: string): any; | ||
static add(name_: string, value_: any, days?: number, path?: string): void; | ||
static remove(name: string, path?: string): void; | ||
static get clear(): void; | ||
get properties(): Array<string>; | ||
get values(): Array<any>; | ||
get items(): Record<string, any>; | ||
get clear(): void; | ||
get(name: string): any; | ||
has(name: string): any; | ||
add(name_: string, value_: any, days?: number, path?: string): void; | ||
update(...args: [string, any, number, string]): void; | ||
remove(name: string, path?: string): void; | ||
private property; | ||
private propertyOriginal; | ||
} | ||
export default AmauiCookie; |
@@ -12,3 +12,18 @@ "use strict"; | ||
const optionsDefault = { | ||
namespace: 'AMAUI', | ||
namespace_separator: '_' | ||
}; | ||
class AmauiCookie { | ||
constructor(options = optionsDefault) { | ||
this.options = void 0; | ||
this.removeNotAllowed = []; | ||
this.options = (0, _utils.merge)(options, optionsDefault); | ||
} | ||
get namespace() { | ||
return `${this.options.namespace}${this.options.namespace_separator}`; | ||
} | ||
static get cookie() { | ||
@@ -18,34 +33,51 @@ return (0, _utils.isEnvironment)('browser') && window.document.cookie || ''; | ||
static get cookies() { | ||
static get clear() { | ||
const cookieProperties = AmauiCookie.cookie.split('; ').map(item => item.split('=')[0]); | ||
return cookieProperties.forEach(value => document.cookie = `${value}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`); | ||
} | ||
get properties() { | ||
return Object.keys(this.items); | ||
} | ||
get values() { | ||
const cookies = this.items; | ||
return Object.keys(cookies).map(property => cookies[property]); | ||
} | ||
get items() { | ||
if ((0, _utils.isEnvironment)('browser')) { | ||
const cookies = {}; | ||
const cookie = AmauiCookie.cookie; | ||
const items = cookie.split('; '); | ||
const items = {}; | ||
const cookies = AmauiCookie.cookie.split('; ').filter(item => item.indexOf(this.namespace) === 0); | ||
for (const item of items) { | ||
const parts = item.split('='); | ||
cookies[parts[0]] = (0, _utils.castParam)(parts.slice(1).join('=')); | ||
for (const cookie of cookies) { | ||
const parts = cookie.split('='); | ||
items[this.propertyOriginal(parts[0])] = (0, _utils.castParam)(parts.slice(1).join('=')); | ||
} | ||
return cookies; | ||
return items; | ||
} | ||
} | ||
static has(name) { | ||
get clear() { | ||
return this.properties.filter(value => this.removeNotAllowed.indexOf(value) === -1 || this.removeNotAllowed.indexOf(this.propertyOriginal(value)) === -1).forEach(value => this.remove(value)); | ||
} | ||
get(name) { | ||
if ((0, _utils.isEnvironment)('browser')) { | ||
const cookies = AmauiCookie.cookies; | ||
return cookies.hasOwnProperty(name); | ||
const items = this.items; | ||
return items[name]; | ||
} | ||
} | ||
static get(name) { | ||
has(name) { | ||
if ((0, _utils.isEnvironment)('browser')) { | ||
const cookies = AmauiCookie.cookies; | ||
return cookies[name]; | ||
const items = this.items; | ||
return items.hasOwnProperty(name); | ||
} | ||
} | ||
static add(name_, value_, days = 364, path = '/') { | ||
add(name_, value_, days = 364, path = '/') { | ||
if ((0, _utils.isEnvironment)('browser')) { | ||
const name = name_; | ||
const name = this.property(name_); | ||
const value = !(0, _utils.is)('string', value_) ? (0, _utils.serialize)(value_) : value_; | ||
@@ -55,11 +87,24 @@ const expires = (0, _date.add)(days, 'day').utc; | ||
} | ||
} // An alias for add method | ||
update(...args) { | ||
return this.add(...args); | ||
} | ||
static remove(name, path = '/') { | ||
remove(name, path = '/') { | ||
if ((0, _utils.isEnvironment)('browser')) { | ||
const cookies = AmauiCookie.cookies; | ||
if (cookies.hasOwnProperty(name)) document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path}`; | ||
const items = this.items; | ||
if (items.hasOwnProperty(name)) document.cookie = `${this.property(name)}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path}`; | ||
} | ||
} | ||
property(value) { | ||
return `${this.namespace}${value}`; | ||
} | ||
propertyOriginal(value) { | ||
return value.indexOf(this.namespace) === 0 ? value.slice(this.namespace.length) : value; | ||
} | ||
} | ||
@@ -66,0 +111,0 @@ |
@@ -10,24 +10,50 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import { is, serialize, castParam, isEnvironment } from '@amaui/utils'; | ||
import { is, merge, serialize, castParam, isEnvironment } from '@amaui/utils'; | ||
import { add as _add } from '@amaui/date'; | ||
var optionsDefault = { | ||
namespace: 'AMAUI', | ||
namespace_separator: '_' | ||
}; | ||
var AmauiCookie = /*#__PURE__*/function () { | ||
function AmauiCookie() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : optionsDefault; | ||
_classCallCheck(this, AmauiCookie); | ||
this.options = void 0; | ||
this.removeNotAllowed = []; | ||
this.options = merge(options, optionsDefault); | ||
} | ||
_createClass(AmauiCookie, null, [{ | ||
key: "cookie", | ||
_createClass(AmauiCookie, [{ | ||
key: "namespace", | ||
get: function get() { | ||
return isEnvironment('browser') && window.document.cookie || ''; | ||
return "".concat(this.options.namespace).concat(this.options.namespace_separator); | ||
} | ||
}, { | ||
key: "cookies", | ||
key: "properties", | ||
get: function get() { | ||
return Object.keys(this.items); | ||
} | ||
}, { | ||
key: "values", | ||
get: function get() { | ||
var cookies = this.items; | ||
return Object.keys(cookies).map(function (property) { | ||
return cookies[property]; | ||
}); | ||
} | ||
}, { | ||
key: "items", | ||
get: function get() { | ||
var _this = this; | ||
if (isEnvironment('browser')) { | ||
var cookies = {}; | ||
var cookie = AmauiCookie.cookie; | ||
var items = cookie.split('; '); | ||
var items = {}; | ||
var cookies = AmauiCookie.cookie.split('; ').filter(function (item) { | ||
return item.indexOf(_this.namespace) === 0; | ||
}); | ||
var _iterator = _createForOfIteratorHelper(items), | ||
var _iterator = _createForOfIteratorHelper(cookies), | ||
_step; | ||
@@ -37,5 +63,5 @@ | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var item = _step.value; | ||
var parts = item.split('='); | ||
cookies[parts[0]] = castParam(parts.slice(1).join('=')); | ||
var cookie = _step.value; | ||
var parts = cookie.split('='); | ||
items[this.propertyOriginal(parts[0])] = castParam(parts.slice(1).join('=')); | ||
} | ||
@@ -48,12 +74,15 @@ } catch (err) { | ||
return cookies; | ||
return items; | ||
} | ||
} | ||
}, { | ||
key: "has", | ||
value: function has(name) { | ||
if (isEnvironment('browser')) { | ||
var cookies = AmauiCookie.cookies; | ||
return cookies.hasOwnProperty(name); | ||
} | ||
key: "clear", | ||
get: function get() { | ||
var _this2 = this; | ||
return this.properties.filter(function (value) { | ||
return _this2.removeNotAllowed.indexOf(value) === -1 || _this2.removeNotAllowed.indexOf(_this2.propertyOriginal(value)) === -1; | ||
}).forEach(function (value) { | ||
return _this2.remove(value); | ||
}); | ||
} | ||
@@ -64,7 +93,15 @@ }, { | ||
if (isEnvironment('browser')) { | ||
var cookies = AmauiCookie.cookies; | ||
return cookies[name]; | ||
var items = this.items; | ||
return items[name]; | ||
} | ||
} | ||
}, { | ||
key: "has", | ||
value: function has(name) { | ||
if (isEnvironment('browser')) { | ||
var items = this.items; | ||
return items.hasOwnProperty(name); | ||
} | ||
} | ||
}, { | ||
key: "add", | ||
@@ -76,3 +113,3 @@ value: function add(name_, value_) { | ||
if (isEnvironment('browser')) { | ||
var name = name_; | ||
var name = this.property(name_); | ||
var value = !is('string', value_) ? serialize(value_) : value_; | ||
@@ -84,2 +121,8 @@ | ||
} | ||
} // An alias for add method | ||
}, { | ||
key: "update", | ||
value: function update() { | ||
return this.add.apply(this, arguments); | ||
} | ||
@@ -92,6 +135,31 @@ }, { | ||
if (isEnvironment('browser')) { | ||
var cookies = AmauiCookie.cookies; | ||
if (cookies.hasOwnProperty(name)) document.cookie = "".concat(name, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(path); | ||
var items = this.items; | ||
if (items.hasOwnProperty(name)) document.cookie = "".concat(this.property(name), "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(path); | ||
} | ||
} | ||
}, { | ||
key: "property", | ||
value: function property(value) { | ||
return "".concat(this.namespace).concat(value); | ||
} | ||
}, { | ||
key: "propertyOriginal", | ||
value: function propertyOriginal(value) { | ||
return value.indexOf(this.namespace) === 0 ? value.slice(this.namespace.length) : value; | ||
} | ||
}], [{ | ||
key: "cookie", | ||
get: function get() { | ||
return isEnvironment('browser') && window.document.cookie || ''; | ||
} | ||
}, { | ||
key: "clear", | ||
get: function get() { | ||
var cookieProperties = AmauiCookie.cookie.split('; ').map(function (item) { | ||
return item.split('=')[0]; | ||
}); | ||
return cookieProperties.forEach(function (value) { | ||
return document.cookie = "".concat(value, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"); | ||
}); | ||
} | ||
}]); | ||
@@ -98,0 +166,0 @@ |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.111 | ||
/** @license AmauiCookie v1.0.112 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.111 | ||
/** @license AmauiCookie v1.0.112 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -10,24 +10,50 @@ import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
import { is, serialize, castParam, isEnvironment } from '@amaui/utils'; | ||
import { is, merge, serialize, castParam, isEnvironment } from '@amaui/utils'; | ||
import { add as _add } from '@amaui/date'; | ||
var optionsDefault = { | ||
namespace: 'AMAUI', | ||
namespace_separator: '_' | ||
}; | ||
var AmauiCookie = /*#__PURE__*/function () { | ||
function AmauiCookie() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : optionsDefault; | ||
_classCallCheck(this, AmauiCookie); | ||
this.options = void 0; | ||
this.removeNotAllowed = []; | ||
this.options = merge(options, optionsDefault); | ||
} | ||
_createClass(AmauiCookie, null, [{ | ||
key: "cookie", | ||
_createClass(AmauiCookie, [{ | ||
key: "namespace", | ||
get: function get() { | ||
return isEnvironment('browser') && window.document.cookie || ''; | ||
return "".concat(this.options.namespace).concat(this.options.namespace_separator); | ||
} | ||
}, { | ||
key: "cookies", | ||
key: "properties", | ||
get: function get() { | ||
return Object.keys(this.items); | ||
} | ||
}, { | ||
key: "values", | ||
get: function get() { | ||
var cookies = this.items; | ||
return Object.keys(cookies).map(function (property) { | ||
return cookies[property]; | ||
}); | ||
} | ||
}, { | ||
key: "items", | ||
get: function get() { | ||
var _this = this; | ||
if (isEnvironment('browser')) { | ||
var cookies = {}; | ||
var cookie = AmauiCookie.cookie; | ||
var items = cookie.split('; '); | ||
var items = {}; | ||
var cookies = AmauiCookie.cookie.split('; ').filter(function (item) { | ||
return item.indexOf(_this.namespace) === 0; | ||
}); | ||
var _iterator = _createForOfIteratorHelper(items), | ||
var _iterator = _createForOfIteratorHelper(cookies), | ||
_step; | ||
@@ -37,5 +63,5 @@ | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var item = _step.value; | ||
var parts = item.split('='); | ||
cookies[parts[0]] = castParam(parts.slice(1).join('=')); | ||
var cookie = _step.value; | ||
var parts = cookie.split('='); | ||
items[this.propertyOriginal(parts[0])] = castParam(parts.slice(1).join('=')); | ||
} | ||
@@ -48,12 +74,15 @@ } catch (err) { | ||
return cookies; | ||
return items; | ||
} | ||
} | ||
}, { | ||
key: "has", | ||
value: function has(name) { | ||
if (isEnvironment('browser')) { | ||
var cookies = AmauiCookie.cookies; | ||
return cookies.hasOwnProperty(name); | ||
} | ||
key: "clear", | ||
get: function get() { | ||
var _this2 = this; | ||
return this.properties.filter(function (value) { | ||
return _this2.removeNotAllowed.indexOf(value) === -1 || _this2.removeNotAllowed.indexOf(_this2.propertyOriginal(value)) === -1; | ||
}).forEach(function (value) { | ||
return _this2.remove(value); | ||
}); | ||
} | ||
@@ -64,7 +93,15 @@ }, { | ||
if (isEnvironment('browser')) { | ||
var cookies = AmauiCookie.cookies; | ||
return cookies[name]; | ||
var items = this.items; | ||
return items[name]; | ||
} | ||
} | ||
}, { | ||
key: "has", | ||
value: function has(name) { | ||
if (isEnvironment('browser')) { | ||
var items = this.items; | ||
return items.hasOwnProperty(name); | ||
} | ||
} | ||
}, { | ||
key: "add", | ||
@@ -76,3 +113,3 @@ value: function add(name_, value_) { | ||
if (isEnvironment('browser')) { | ||
var name = name_; | ||
var name = this.property(name_); | ||
var value = !is('string', value_) ? serialize(value_) : value_; | ||
@@ -84,2 +121,8 @@ | ||
} | ||
} // An alias for add method | ||
}, { | ||
key: "update", | ||
value: function update() { | ||
return this.add.apply(this, arguments); | ||
} | ||
@@ -92,6 +135,31 @@ }, { | ||
if (isEnvironment('browser')) { | ||
var cookies = AmauiCookie.cookies; | ||
if (cookies.hasOwnProperty(name)) document.cookie = "".concat(name, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(path); | ||
var items = this.items; | ||
if (items.hasOwnProperty(name)) document.cookie = "".concat(this.property(name), "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(path); | ||
} | ||
} | ||
}, { | ||
key: "property", | ||
value: function property(value) { | ||
return "".concat(this.namespace).concat(value); | ||
} | ||
}, { | ||
key: "propertyOriginal", | ||
value: function propertyOriginal(value) { | ||
return value.indexOf(this.namespace) === 0 ? value.slice(this.namespace.length) : value; | ||
} | ||
}], [{ | ||
key: "cookie", | ||
get: function get() { | ||
return isEnvironment('browser') && window.document.cookie || ''; | ||
} | ||
}, { | ||
key: "clear", | ||
get: function get() { | ||
var cookieProperties = AmauiCookie.cookie.split('; ').map(function (item) { | ||
return item.split('=')[0]; | ||
}); | ||
return cookieProperties.forEach(function (value) { | ||
return document.cookie = "".concat(value, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"); | ||
}); | ||
} | ||
}]); | ||
@@ -98,0 +166,0 @@ |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.111 | ||
/** @license AmauiCookie v1.0.112 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
@@ -1,5 +0,19 @@ | ||
import { is, serialize, castParam, isEnvironment } from '@amaui/utils'; | ||
import { is, merge, serialize, castParam, isEnvironment } from '@amaui/utils'; | ||
import { add } from '@amaui/date'; | ||
const optionsDefault = { | ||
namespace: 'AMAUI', | ||
namespace_separator: '_' | ||
}; | ||
class AmauiCookie { | ||
constructor(options = optionsDefault) { | ||
this.options = void 0; | ||
this.removeNotAllowed = []; | ||
this.options = merge(options, optionsDefault); | ||
} | ||
get namespace() { | ||
return `${this.options.namespace}${this.options.namespace_separator}`; | ||
} | ||
static get cookie() { | ||
@@ -9,34 +23,51 @@ return isEnvironment('browser') && window.document.cookie || ''; | ||
static get cookies() { | ||
static get clear() { | ||
const cookieProperties = AmauiCookie.cookie.split('; ').map(item => item.split('=')[0]); | ||
return cookieProperties.forEach(value => document.cookie = `${value}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/`); | ||
} | ||
get properties() { | ||
return Object.keys(this.items); | ||
} | ||
get values() { | ||
const cookies = this.items; | ||
return Object.keys(cookies).map(property => cookies[property]); | ||
} | ||
get items() { | ||
if (isEnvironment('browser')) { | ||
const cookies = {}; | ||
const cookie = AmauiCookie.cookie; | ||
const items = cookie.split('; '); | ||
const items = {}; | ||
const cookies = AmauiCookie.cookie.split('; ').filter(item => item.indexOf(this.namespace) === 0); | ||
for (const item of items) { | ||
const parts = item.split('='); | ||
cookies[parts[0]] = castParam(parts.slice(1).join('=')); | ||
for (const cookie of cookies) { | ||
const parts = cookie.split('='); | ||
items[this.propertyOriginal(parts[0])] = castParam(parts.slice(1).join('=')); | ||
} | ||
return cookies; | ||
return items; | ||
} | ||
} | ||
static has(name) { | ||
get clear() { | ||
return this.properties.filter(value => this.removeNotAllowed.indexOf(value) === -1 || this.removeNotAllowed.indexOf(this.propertyOriginal(value)) === -1).forEach(value => this.remove(value)); | ||
} | ||
get(name) { | ||
if (isEnvironment('browser')) { | ||
const cookies = AmauiCookie.cookies; | ||
return cookies.hasOwnProperty(name); | ||
const items = this.items; | ||
return items[name]; | ||
} | ||
} | ||
static get(name) { | ||
has(name) { | ||
if (isEnvironment('browser')) { | ||
const cookies = AmauiCookie.cookies; | ||
return cookies[name]; | ||
const items = this.items; | ||
return items.hasOwnProperty(name); | ||
} | ||
} | ||
static add(name_, value_, days = 364, path = '/') { | ||
add(name_, value_, days = 364, path = '/') { | ||
if (isEnvironment('browser')) { | ||
const name = name_; | ||
const name = this.property(name_); | ||
const value = !is('string', value_) ? serialize(value_) : value_; | ||
@@ -46,13 +77,26 @@ const expires = add(days, 'day').utc; | ||
} | ||
} // An alias for add method | ||
update(...args) { | ||
return this.add(...args); | ||
} | ||
static remove(name, path = '/') { | ||
remove(name, path = '/') { | ||
if (isEnvironment('browser')) { | ||
const cookies = AmauiCookie.cookies; | ||
if (cookies.hasOwnProperty(name)) document.cookie = `${name}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path}`; | ||
const items = this.items; | ||
if (items.hasOwnProperty(name)) document.cookie = `${this.property(name)}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=${path}`; | ||
} | ||
} | ||
property(value) { | ||
return `${this.namespace}${value}`; | ||
} | ||
propertyOriginal(value) { | ||
return value.indexOf(this.namespace) === 0 ? value.slice(this.namespace.length) : value; | ||
} | ||
} | ||
export default AmauiCookie; |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.111 | ||
/** @license AmauiCookie v1.0.112 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
{ | ||
"name": "@amaui/cookie", | ||
"version": "1.0.111", | ||
"version": "1.0.112", | ||
"description": "Cookie", | ||
@@ -5,0 +5,0 @@ "repository": "https://github.com/amaui-org/amaui-cookie.git", |
@@ -15,3 +15,3 @@ | ||
<sub>Production ready </sub> | ||
<sub>3.5kb gzipped </sub> | ||
<sub>3.8kb gzipped </sub> | ||
<sub>100% test cov </sub> | ||
@@ -48,19 +48,21 @@ <sub>Browser</sub> | ||
// Add a cookie | ||
AmauiCookie.add('a', 4); | ||
const amauiCookie = new AmauiCookie(); | ||
// Has a cookie | ||
AmauiCookie.get('a'); | ||
// Add | ||
amauiCookie.add('a', 4); | ||
// Has | ||
amauiCookie.has('a'); | ||
// true | ||
// Get a cookie | ||
AmauiCookie.get('a'); | ||
// Get | ||
amauiCookie.get('a'); | ||
// 4 | ||
// Remove a cookie | ||
AmauiCookie.remove('a'); | ||
// Remove | ||
amauiCookie.remove('a'); | ||
AmauiCookie.get('a'); | ||
amauiCookie.get('a'); | ||
@@ -67,0 +69,0 @@ // undefined |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.111 | ||
/** @license AmauiCookie v1.0.112 | ||
* | ||
@@ -69,3 +69,3 @@ * This source code is licensed under the MIT license found in the | ||
var optionsDefault$3 = { | ||
var optionsDefault$4 = { | ||
elementIsObject: false | ||
@@ -77,5 +77,5 @@ }; // Multiple is methods instead of one, | ||
var value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; | ||
var options_ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : optionsDefault$3; | ||
var options_ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : optionsDefault$4; | ||
var options = _extends({}, optionsDefault$3, options_); | ||
var options = _extends({}, optionsDefault$4, options_); | ||
@@ -192,3 +192,3 @@ switch (type) { | ||
var optionsDefault$2 = { | ||
var optionsDefault$3 = { | ||
copy: false, | ||
@@ -201,5 +201,5 @@ merge: { | ||
var merge = function merge(target, source) { | ||
var options_ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : optionsDefault$2; | ||
var options_ = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : optionsDefault$3; | ||
var options = _extends({}, optionsDefault$2, options_); | ||
var options = _extends({}, optionsDefault$3, options_); | ||
@@ -230,3 +230,3 @@ if (options.merge.array && is('array', target) && is('array', source)) { | ||
var optionsDefault$1 = { | ||
var optionsDefault$2 = { | ||
decode: true, | ||
@@ -237,4 +237,4 @@ decodeMethod: decodeURIComponent | ||
var castParam = function castParam(value) { | ||
var options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : optionsDefault$1; | ||
var options = merge$1(options_, optionsDefault$1); | ||
var options_ = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : optionsDefault$2; | ||
var options = merge$1(options_, optionsDefault$2); | ||
var newValue = value; | ||
@@ -282,3 +282,3 @@ if (is('string', value) && options.decode && is('function', options.decodeMethod)) newValue = options.decodeMethod(value); | ||
var optionsDefault = {}; | ||
var optionsDefault$1 = {}; | ||
var months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December']; | ||
@@ -327,3 +327,3 @@ var monthsAbr = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']; | ||
var value_ = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date(); | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : optionsDefault; | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : optionsDefault$1; | ||
@@ -353,3 +353,3 @@ _classCallCheck(this, AmauiDate); | ||
// Merge options with option defaults | ||
this.options = merge$1(this.options, optionsDefault); // Convert seconds to milliseconds | ||
this.options = merge$1(this.options, optionsDefault$1); // Convert seconds to milliseconds | ||
// so it's valid in new Date as argument | ||
@@ -516,22 +516,48 @@ | ||
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } | ||
var optionsDefault = { | ||
namespace: 'AMAUI', | ||
namespace_separator: '_' | ||
}; | ||
var AmauiCookie = /*#__PURE__*/function () { | ||
function AmauiCookie() { | ||
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : optionsDefault; | ||
_classCallCheck(this, AmauiCookie); | ||
this.options = void 0; | ||
this.removeNotAllowed = []; | ||
this.options = merge$1(options, optionsDefault); | ||
} | ||
_createClass(AmauiCookie, null, [{ | ||
key: "cookie", | ||
_createClass(AmauiCookie, [{ | ||
key: "namespace", | ||
get: function get() { | ||
return isEnvironment('browser') && window.document.cookie || ''; | ||
return "".concat(this.options.namespace).concat(this.options.namespace_separator); | ||
} | ||
}, { | ||
key: "cookies", | ||
key: "properties", | ||
get: function get() { | ||
return Object.keys(this.items); | ||
} | ||
}, { | ||
key: "values", | ||
get: function get() { | ||
var cookies = this.items; | ||
return Object.keys(cookies).map(function (property) { | ||
return cookies[property]; | ||
}); | ||
} | ||
}, { | ||
key: "items", | ||
get: function get() { | ||
var _this = this; | ||
if (isEnvironment('browser')) { | ||
var cookies = {}; | ||
var cookie = AmauiCookie.cookie; | ||
var items = cookie.split('; '); | ||
var items = {}; | ||
var cookies = AmauiCookie.cookie.split('; ').filter(function (item) { | ||
return item.indexOf(_this.namespace) === 0; | ||
}); | ||
var _iterator = _createForOfIteratorHelper(items), | ||
var _iterator = _createForOfIteratorHelper(cookies), | ||
_step; | ||
@@ -541,5 +567,5 @@ | ||
for (_iterator.s(); !(_step = _iterator.n()).done;) { | ||
var item = _step.value; | ||
var parts = item.split('='); | ||
cookies[parts[0]] = castParam$1(parts.slice(1).join('=')); | ||
var cookie = _step.value; | ||
var parts = cookie.split('='); | ||
items[this.propertyOriginal(parts[0])] = castParam$1(parts.slice(1).join('=')); | ||
} | ||
@@ -552,12 +578,15 @@ } catch (err) { | ||
return cookies; | ||
return items; | ||
} | ||
} | ||
}, { | ||
key: "has", | ||
value: function has(name) { | ||
if (isEnvironment('browser')) { | ||
var cookies = AmauiCookie.cookies; | ||
return cookies.hasOwnProperty(name); | ||
} | ||
key: "clear", | ||
get: function get() { | ||
var _this2 = this; | ||
return this.properties.filter(function (value) { | ||
return _this2.removeNotAllowed.indexOf(value) === -1 || _this2.removeNotAllowed.indexOf(_this2.propertyOriginal(value)) === -1; | ||
}).forEach(function (value) { | ||
return _this2.remove(value); | ||
}); | ||
} | ||
@@ -568,7 +597,15 @@ }, { | ||
if (isEnvironment('browser')) { | ||
var cookies = AmauiCookie.cookies; | ||
return cookies[name]; | ||
var items = this.items; | ||
return items[name]; | ||
} | ||
} | ||
}, { | ||
key: "has", | ||
value: function has(name) { | ||
if (isEnvironment('browser')) { | ||
var items = this.items; | ||
return items.hasOwnProperty(name); | ||
} | ||
} | ||
}, { | ||
key: "add", | ||
@@ -580,3 +617,3 @@ value: function add$1(name_, value_) { | ||
if (isEnvironment('browser')) { | ||
var name = name_; | ||
var name = this.property(name_); | ||
var value = !is('string', value_) ? serialize$1(value_) : value_; | ||
@@ -588,2 +625,8 @@ | ||
} | ||
} // An alias for add method | ||
}, { | ||
key: "update", | ||
value: function update() { | ||
return this.add.apply(this, arguments); | ||
} | ||
@@ -596,6 +639,31 @@ }, { | ||
if (isEnvironment('browser')) { | ||
var cookies = AmauiCookie.cookies; | ||
if (cookies.hasOwnProperty(name)) document.cookie = "".concat(name, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(path); | ||
var items = this.items; | ||
if (items.hasOwnProperty(name)) document.cookie = "".concat(this.property(name), "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(path); | ||
} | ||
} | ||
}, { | ||
key: "property", | ||
value: function property(value) { | ||
return "".concat(this.namespace).concat(value); | ||
} | ||
}, { | ||
key: "propertyOriginal", | ||
value: function propertyOriginal(value) { | ||
return value.indexOf(this.namespace) === 0 ? value.slice(this.namespace.length) : value; | ||
} | ||
}], [{ | ||
key: "cookie", | ||
get: function get() { | ||
return isEnvironment('browser') && window.document.cookie || ''; | ||
} | ||
}, { | ||
key: "clear", | ||
get: function get() { | ||
var cookieProperties = AmauiCookie.cookie.split('; ').map(function (item) { | ||
return item.split('=')[0]; | ||
}); | ||
return cookieProperties.forEach(function (value) { | ||
return document.cookie = "".concat(value, "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/"); | ||
}); | ||
} | ||
}]); | ||
@@ -602,0 +670,0 @@ |
@@ -1,2 +0,2 @@ | ||
/** @license AmauiCookie v1.0.111 | ||
/** @license AmauiCookie v1.0.112 | ||
* | ||
@@ -6,2 +6,2 @@ * This source code is licensed under the MIT license found in the | ||
*/ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).AmauiCookie=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var r="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function o(e){return o="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},o(e)}function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}var a={elementIsObject:!1},u=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,u=i({},a,r);switch(t){case"string":return"string"==typeof n;case"number":return"number"==typeof n&&!Number.isNaN(n);case"boolean":return"boolean"==typeof n;case"array":return Array.isArray(n);case"object":var c="object"===o(n)&&!!n&&n.constructor===Object,l=e("element",n,u);return c&&(!l||u.elementIsObject);case"object-like":return"object"===o(n)&&(null===n||n.constructor!==Object);case"class":return("object"===o(n)||"function"==typeof n)&&(/class/gi.test(String(n))||/class/gi.test(String(null==n?void 0:n.constructor)));case"function":return!!(n&&n instanceof Function);case"async":return!(!e("function",n)||!(s("browser")?"AsyncFunction"===n.constructor.name:n()instanceof Promise));case"date":return!!(n&&n instanceof Date);case"element":return!(!n||!n.elementType&&!n.hasOwnProperty("$$typeof"));case"simple":return e("string",n,u)||e("number",n,u)||e("boolean",n,u)||e("element",n,u)&&!u.elementIsObject||[void 0,null].indexOf(n)>-1;case"not-array-object":return!e("array",n,u)&&!e("object",n,u);case"array-buffer":return"[object ArrayBuffer]"===String(n);case"blob":return s("browser")&&n instanceof Blob;case"buffer":return!!(s("nodejs")&&n&&null!==n.constructor&&"function"==typeof n.constructor.isBuffer&&n.constructor.isBuffer(n));default:return!1}},s=function e(t){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;switch(t){case"browser":return"undefined"!=typeof window&&void 0!==window.document;case"worker":return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;case"nodejs":return!(void 0===r||"undefined"==typeof module||!module.exports);case"localhost":return n=void 0!==o?o:e("browser")&&window.location.hostname,u("string",n)&&["localhost","127.0.0.1"].some((function(e){return n.indexOf(e)>-1}));default:return!1}},c=function e(t){if(u("array",t))return t.map((function(t){return e(t)}));if(u("object",t)){var n={};return Object.keys(t).forEach((function(r){return n[r]=e(t[r])})),n}return t},l={copy:!1,merge:{array:!1}},f=function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l,o=i({},l,r);if(o.merge.array&&u("array",t)&&u("array",n))for(var a=Math.max(t.length,n.length),s=0;s<a;s++)void 0===t[s]&&(t[s]=n[s]),(u("object",t[s])&&u("object",n[s])||u("array",t[s])&&u("array",n[s]))&&(t[s]=e(t[s],n[s],o));return u("object",t)&&u("object",n)&&Object.keys(n).forEach((function(r){t.hasOwnProperty(r)?u("object",t[r])&&u("object",n[r])&&(t[r]=e(t[r],n[r],o)):t[r]=o.copy?c(n[r]):n[r]})),t},d={decode:!0,decodeMethod:decodeURIComponent},h=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d,n=f(t,d),r=e;u("string",e)&&n.decode&&u("function",n.decodeMethod)&&(r=n.decodeMethod(e));try{if(u("string",r)){if("undefined"===r)return;return"NaN"===r?NaN:JSON.parse(r)}return r}catch(e){}return r},y=function e(t){return u("object",t)?"{".concat(Object.keys(t).sort().map((function(n){return'"'.concat(n,'":').concat(e(t[n]))})).join(","),"}"):u("array",t)?"[".concat(t.map((function(t){return e(t)})).join(","),"]"):u("string",t)?'"'.concat(t,'"'):function(e){return u("string",e)?e.replace(/(\s|\r|\n)+/," "):e}(JSON.stringify(function(e){return void 0===e?"undefined":e instanceof Function||e instanceof Object?e.toString():e}(t)))},v={},g=["January","February","March","April","May","June","July","August","September","October","November","December"],b=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],p=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function w(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.amauidate;if(n&&n.valid)switch(t){case"millisecond":return new k(n.value.setMilliseconds(n.millisecond+e));case"second":return new k(n.value.setSeconds(n.second+e));case"minute":return new k(n.value.setMinutes(n.minute+e));case"hour":return new k(n.value.setHours(n.hour+e));case"day":return new k(n.value.setDate(n.day+e));case"week":return new k(n.value.setDate(n.day+7*e));case"month":return new k(n.value.setMonth(n.month-1+e));case"year":return new k(n.value.setFullYear(n.year+e))}}var k=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v;e(this,t),this.value_=n,this.options=r,this.value=void 0,this.millisecond=void 0,this.milliseconds=void 0,this.second=void 0,this.minute=void 0,this.hour=void 0,this.day=void 0,this.dayWeek=void 0,this.dayYear=void 0,this.week=void 0,this.month=void 0,this.year=void 0,this.init()}return n(t,[{key:"init",value:function(){this.options=f(this.options,v),u("number",this.value_)&&10===String(this.value_).length&&(this.value_*=1e3),this.value=new Date(this.value_ instanceof t?this.value_.value:this.value_),this.valid&&(this.millisecond=this.value[this.options.utc?"getUTCMilliseconds":"getMilliseconds"](),this.milliseconds=this.value.getTime(),this.second=this.value[this.options.utc?"getUTCSeconds":"getSeconds"](),this.minute=this.value[this.options.utc?"getUTCMinutes":"getMinutes"](),this.hour=this.value[this.options.utc?"getUTCHours":"getHours"](),this.day=this.value[this.options.utc?"getUTCDate":"getDate"](),this.dayWeek=this.value[this.options.utc?"getUTCDay":"getDay"](),this.month=this.value[this.options.utc?"getUTCMonth":"getMonth"]()+1,this.year=this.value[this.options.utc?"getUTCFullYear":"getFullYear"](),this.dayYear=Math.floor((this.milliseconds-Number(new Date(this.year,0,0)))/1e3/60/60/24),this.weekValue())}},{key:"weekValue",value:function(){var e=new Date(this.year,0,1);return e.setDate(e.getDate()+(1-e.getDay()%7)),this.week=Math.round((Number(this.value)-Number(e))/6048e5)+1,this.week}},{key:"months",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.months)||g}},{key:"monthsAbr",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.monthsAbr)||b}},{key:"daysWeek",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.daysWeek)||m}},{key:"daysWeekAbr",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.daysWeekAbr)||p}},{key:"valid",get:function(){return void 0===this.value_||this.value_ instanceof Date||this.value_ instanceof t||(e=new Date(this.value_).getTime(),Number.isInteger(e)&&String(e).length>=10&&(new Date(e).getTime()>0||new Date(1e3*e).getTime()>0));var e}},{key:"local",get:function(){if(this.valid)return new t(new Date(this.value.toLocaleString("en-us")))}},{key:"utc",get:function(){return new t(this.value,{utc:!0})}},{key:"iso",get:function(){if(this.valid)return this.value.toISOString()}},{key:"daysInMonth",get:function(){return new Date(this.year,this.month,0).getDate()}},{key:"weeksInYear",get:function(){var e=new Date(this.year,0,1),t=1===new Date(this.year,1,29).getMonth();return 4===e.getDay()||t&&3===e.getDay()?53:52}},{key:"valueOf",get:function(){return this.milliseconds}},{key:"unix",get:function(){if(this.valid)return Math.floor(this.value.getTime()/1e3)}},{key:"timezone",value:function(e){if(this.valid&&e)return new t(this.value.toLocaleString("en-us",{timeZone:e}))}}],[{key:"utc",get:function(){return new t(new Date,{utc:!0})}},{key:"daysInMonth",get:function(){return(new t).daysInMonth}},{key:"valueOf",get:function(){return(new t).valueOf}},{key:"unix",get:function(){return(new t).unix}},{key:"milliseconds",get:function(){return(new t).milliseconds}},{key:"iso",get:function(){return(new t).iso}},{key:"amauidate",get:function(){return new t}},{key:"local",get:function(){return(new t).local}}]),t}();function j(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return S(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return S(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}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 i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function S(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var O=function(){function t(){e(this,t)}return n(t,null,[{key:"cookie",get:function(){return s("browser")&&window.document.cookie||""}},{key:"cookies",get:function(){if(s("browser")){var e,n={},r=j(t.cookie.split("; "));try{for(r.s();!(e=r.n()).done;){var o=e.value.split("=");n[o[0]]=h(o.slice(1).join("="))}}catch(e){r.e(e)}finally{r.f()}return n}}},{key:"has",value:function(e){if(s("browser"))return t.cookies.hasOwnProperty(e)}},{key:"get",value:function(e){if(s("browser"))return t.cookies[e]}},{key:"add",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:364,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"/";if(s("browser")){var o=e,i=u("string",t)?t:y(t),a=w(n,"day").utc;document.cookie="".concat(o,"=").concat(i,"; expires=").concat(a,"; path=").concat(r)}}},{key:"remove",value:function(e){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";if(s("browser")){var r=t.cookies;r.hasOwnProperty(e)&&(document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(n))}}}]),t}();return O})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).AmauiCookie=t()}(this,(function(){"use strict";function e(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function t(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function n(e,n,r){return n&&t(e.prototype,n),r&&t(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var r="undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{};function o(e){return o="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},o(e)}function i(){return i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},i.apply(this,arguments)}var a={elementIsObject:!1},u=function e(t){var n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:a,u=i({},a,r);switch(t){case"string":return"string"==typeof n;case"number":return"number"==typeof n&&!Number.isNaN(n);case"boolean":return"boolean"==typeof n;case"array":return Array.isArray(n);case"object":var c="object"===o(n)&&!!n&&n.constructor===Object,l=e("element",n,u);return c&&(!l||u.elementIsObject);case"object-like":return"object"===o(n)&&(null===n||n.constructor!==Object);case"class":return("object"===o(n)||"function"==typeof n)&&(/class/gi.test(String(n))||/class/gi.test(String(null==n?void 0:n.constructor)));case"function":return!!(n&&n instanceof Function);case"async":return!(!e("function",n)||!(s("browser")?"AsyncFunction"===n.constructor.name:n()instanceof Promise));case"date":return!!(n&&n instanceof Date);case"element":return!(!n||!n.elementType&&!n.hasOwnProperty("$$typeof"));case"simple":return e("string",n,u)||e("number",n,u)||e("boolean",n,u)||e("element",n,u)&&!u.elementIsObject||[void 0,null].indexOf(n)>-1;case"not-array-object":return!e("array",n,u)&&!e("object",n,u);case"array-buffer":return"[object ArrayBuffer]"===String(n);case"blob":return s("browser")&&n instanceof Blob;case"buffer":return!!(s("nodejs")&&n&&null!==n.constructor&&"function"==typeof n.constructor.isBuffer&&n.constructor.isBuffer(n));default:return!1}},s=function e(t){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0;switch(t){case"browser":return"undefined"!=typeof window&&void 0!==window.document;case"worker":return"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope;case"nodejs":return!(void 0===r||"undefined"==typeof module||!module.exports);case"localhost":return n=void 0!==o?o:e("browser")&&window.location.hostname,u("string",n)&&["localhost","127.0.0.1"].some((function(e){return n.indexOf(e)>-1}));default:return!1}},c=function e(t){if(u("array",t))return t.map((function(t){return e(t)}));if(u("object",t)){var n={};return Object.keys(t).forEach((function(r){return n[r]=e(t[r])})),n}return t},l={copy:!1,merge:{array:!1}},f=function e(t,n){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:l,o=i({},l,r);if(o.merge.array&&u("array",t)&&u("array",n))for(var a=Math.max(t.length,n.length),s=0;s<a;s++)void 0===t[s]&&(t[s]=n[s]),(u("object",t[s])&&u("object",n[s])||u("array",t[s])&&u("array",n[s]))&&(t[s]=e(t[s],n[s],o));return u("object",t)&&u("object",n)&&Object.keys(n).forEach((function(r){t.hasOwnProperty(r)?u("object",t[r])&&u("object",n[r])&&(t[r]=e(t[r],n[r],o)):t[r]=o.copy?c(n[r]):n[r]})),t},h={decode:!0,decodeMethod:decodeURIComponent},d=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h,n=f(t,h),r=e;u("string",e)&&n.decode&&u("function",n.decodeMethod)&&(r=n.decodeMethod(e));try{if(u("string",r)){if("undefined"===r)return;return"NaN"===r?NaN:JSON.parse(r)}return r}catch(e){}return r},y=function e(t){return u("object",t)?"{".concat(Object.keys(t).sort().map((function(n){return'"'.concat(n,'":').concat(e(t[n]))})).join(","),"}"):u("array",t)?"[".concat(t.map((function(t){return e(t)})).join(","),"]"):u("string",t)?'"'.concat(t,'"'):function(e){return u("string",e)?e.replace(/(\s|\r|\n)+/," "):e}(JSON.stringify(function(e){return void 0===e?"undefined":e instanceof Function||e instanceof Object?e.toString():e}(t)))},v={},p=["January","February","March","April","May","June","July","August","September","October","November","December"],g=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],m=["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],b=["Mon","Tue","Wed","Thu","Fri","Sat","Sun"];function w(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:k.amauidate;if(n&&n.valid)switch(t){case"millisecond":return new k(n.value.setMilliseconds(n.millisecond+e));case"second":return new k(n.value.setSeconds(n.second+e));case"minute":return new k(n.value.setMinutes(n.minute+e));case"hour":return new k(n.value.setHours(n.hour+e));case"day":return new k(n.value.setDate(n.day+e));case"week":return new k(n.value.setDate(n.day+7*e));case"month":return new k(n.value.setMonth(n.month-1+e));case"year":return new k(n.value.setFullYear(n.year+e))}}var k=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Date,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:v;e(this,t),this.value_=n,this.options=r,this.value=void 0,this.millisecond=void 0,this.milliseconds=void 0,this.second=void 0,this.minute=void 0,this.hour=void 0,this.day=void 0,this.dayWeek=void 0,this.dayYear=void 0,this.week=void 0,this.month=void 0,this.year=void 0,this.init()}return n(t,[{key:"init",value:function(){this.options=f(this.options,v),u("number",this.value_)&&10===String(this.value_).length&&(this.value_*=1e3),this.value=new Date(this.value_ instanceof t?this.value_.value:this.value_),this.valid&&(this.millisecond=this.value[this.options.utc?"getUTCMilliseconds":"getMilliseconds"](),this.milliseconds=this.value.getTime(),this.second=this.value[this.options.utc?"getUTCSeconds":"getSeconds"](),this.minute=this.value[this.options.utc?"getUTCMinutes":"getMinutes"](),this.hour=this.value[this.options.utc?"getUTCHours":"getHours"](),this.day=this.value[this.options.utc?"getUTCDate":"getDate"](),this.dayWeek=this.value[this.options.utc?"getUTCDay":"getDay"](),this.month=this.value[this.options.utc?"getUTCMonth":"getMonth"]()+1,this.year=this.value[this.options.utc?"getUTCFullYear":"getFullYear"](),this.dayYear=Math.floor((this.milliseconds-Number(new Date(this.year,0,0)))/1e3/60/60/24),this.weekValue())}},{key:"weekValue",value:function(){var e=new Date(this.year,0,1);return e.setDate(e.getDate()+(1-e.getDay()%7)),this.week=Math.round((Number(this.value)-Number(e))/6048e5)+1,this.week}},{key:"months",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.months)||p}},{key:"monthsAbr",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.monthsAbr)||g}},{key:"daysWeek",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.daysWeek)||m}},{key:"daysWeekAbr",get:function(){var e;return(null===(e=this.options.overrides)||void 0===e?void 0:e.daysWeekAbr)||b}},{key:"valid",get:function(){return void 0===this.value_||this.value_ instanceof Date||this.value_ instanceof t||(e=new Date(this.value_).getTime(),Number.isInteger(e)&&String(e).length>=10&&(new Date(e).getTime()>0||new Date(1e3*e).getTime()>0));var e}},{key:"local",get:function(){if(this.valid)return new t(new Date(this.value.toLocaleString("en-us")))}},{key:"utc",get:function(){return new t(this.value,{utc:!0})}},{key:"iso",get:function(){if(this.valid)return this.value.toISOString()}},{key:"daysInMonth",get:function(){return new Date(this.year,this.month,0).getDate()}},{key:"weeksInYear",get:function(){var e=new Date(this.year,0,1),t=1===new Date(this.year,1,29).getMonth();return 4===e.getDay()||t&&3===e.getDay()?53:52}},{key:"valueOf",get:function(){return this.milliseconds}},{key:"unix",get:function(){if(this.valid)return Math.floor(this.value.getTime()/1e3)}},{key:"timezone",value:function(e){if(this.valid&&e)return new t(this.value.toLocaleString("en-us",{timeZone:e}))}}],[{key:"utc",get:function(){return new t(new Date,{utc:!0})}},{key:"daysInMonth",get:function(){return(new t).daysInMonth}},{key:"valueOf",get:function(){return(new t).valueOf}},{key:"unix",get:function(){return(new t).unix}},{key:"milliseconds",get:function(){return(new t).milliseconds}},{key:"iso",get:function(){return(new t).iso}},{key:"amauidate",get:function(){return new t}},{key:"local",get:function(){return(new t).local}}]),t}();function j(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=function(e,t){if(!e)return;if("string"==typeof e)return O(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return O(e,t)}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0,o=function(){};return{s:o,n:function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}},e:function(e){throw e},f:o}}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 i,a=!0,u=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function O(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var S={namespace:"AMAUI",namespace_separator:"_"},D=function(){function t(){var n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:S;e(this,t),this.options=void 0,this.removeNotAllowed=[],this.options=f(n,S)}return n(t,[{key:"namespace",get:function(){return"".concat(this.options.namespace).concat(this.options.namespace_separator)}},{key:"properties",get:function(){return Object.keys(this.items)}},{key:"values",get:function(){var e=this.items;return Object.keys(e).map((function(t){return e[t]}))}},{key:"items",get:function(){var e=this;if(s("browser")){var n,r={},o=j(t.cookie.split("; ").filter((function(t){return 0===t.indexOf(e.namespace)})));try{for(o.s();!(n=o.n()).done;){var i=n.value.split("=");r[this.propertyOriginal(i[0])]=d(i.slice(1).join("="))}}catch(e){o.e(e)}finally{o.f()}return r}}},{key:"clear",get:function(){var e=this;return this.properties.filter((function(t){return-1===e.removeNotAllowed.indexOf(t)||-1===e.removeNotAllowed.indexOf(e.propertyOriginal(t))})).forEach((function(t){return e.remove(t)}))}},{key:"get",value:function(e){if(s("browser"))return this.items[e]}},{key:"has",value:function(e){if(s("browser"))return this.items.hasOwnProperty(e)}},{key:"add",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:364,r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"/";if(s("browser")){var o=this.property(e),i=u("string",t)?t:y(t),a=w(n,"day").utc;document.cookie="".concat(o,"=").concat(i,"; expires=").concat(a,"; path=").concat(r)}}},{key:"update",value:function(){return this.add.apply(this,arguments)}},{key:"remove",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"/";if(s("browser")){var n=this.items;n.hasOwnProperty(e)&&(document.cookie="".concat(this.property(e),"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=").concat(t))}}},{key:"property",value:function(e){return"".concat(this.namespace).concat(e)}},{key:"propertyOriginal",value:function(e){return 0===e.indexOf(this.namespace)?e.slice(this.namespace.length):e}}],[{key:"cookie",get:function(){return s("browser")&&window.document.cookie||""}},{key:"clear",get:function(){return t.cookie.split("; ").map((function(e){return e.split("=")[0]})).forEach((function(e){return document.cookie="".concat(e,"=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/")}))}}]),t}();return D})); |
59261
21.09%1130
32.32%95
2.15%