@luxonis/visualizer-protobuf 2.16.2 → 2.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/FoxgloveServer-C39Uooyk.js +1172 -0
  2. package/dist/{WorkerImageDecoder.worker-DCoSYoLL.js → WorkerImageDecoder.worker-tkX9-IYo.js} +3 -2
  3. package/dist/_commonjsHelpers-E-ZsRS8r.js +32 -0
  4. package/dist/{comlink-D0blLC4P.js → comlink-DHMAu6X7.js} +1 -1
  5. package/dist/{communicator-CkB-oBVq.js → communicator-D49kmBTQ.js} +1 -1
  6. package/dist/{decodeImage-NYPkamnK.js → decodeImage-C8kB6T3V.js} +1 -1
  7. package/dist/deserialization.worker-DsG76nP8.js +1326 -0
  8. package/dist/{foxglove-protocol-RZlF5fna.js → foxglove-protocol-CYoMweAY.js} +1 -1
  9. package/dist/{i18next-C5Qe4-E1.js → i18next-IYI3-Nuv.js} +1624 -3124
  10. package/dist/{i420ToRgbaToPoitcloud.worker-CQFm7P7B.js → i420ToRgbaToPoitcloud.worker-CzFC0VI1.js} +1 -1
  11. package/dist/{index-_CotNV5x.js → index-4PQpGzhb.js} +10 -8
  12. package/dist/{index-C8kEVNt8.js → index-BFMXTxLw.js} +10 -8
  13. package/dist/{index-D7BaFI3k.js → index-BQecGu9I.js} +10 -8
  14. package/dist/{index-BFmZhB_k.js → index-BT9CBn7l.js} +2663 -2658
  15. package/dist/{index-CGZy-t2h.js → index-BWittpbR.js} +10 -8
  16. package/dist/{index-BRyhvg1u.js → index-BeQ1w8aW.js} +10 -8
  17. package/dist/{index-B-NuHgKz.js → index-BomoqOv5.js} +10 -8
  18. package/dist/{index-qRQvVkdj.js → index-ByIsztCr.js} +10 -8
  19. package/dist/{index-C7bn4vhH.js → index-CJRhjhJ0.js} +10 -8
  20. package/dist/{index-De_-85Dx.js → index-CR6XGTJc.js} +26206 -31958
  21. package/dist/{index-BflsEH7y.js → index-CXIVXFcJ.js} +13 -10
  22. package/dist/{index-DeqZpaJF.js → index-CXThSQcL.js} +10 -8
  23. package/dist/{index-BA7oWwVg.js → index-CcIi7pJR.js} +10 -8
  24. package/dist/{index-BDNOxLbq.js → index-CcP1Qppv.js} +10 -8
  25. package/dist/{index-BsSLQ0Qh.js → index-Ci0X5xT3.js} +10 -8
  26. package/dist/{index-D_n427cy.js → index-CrtBH66u.js} +10 -8
  27. package/dist/{index--q0v8_7h.js → index-DUUnuN10.js} +10 -8
  28. package/dist/{index-C3EAt3Mi.js → index-DchGURxJ.js} +10 -8
  29. package/dist/{index-Cls5O6Ds.js → index-DdKOhCXT.js} +10 -8
  30. package/dist/index.js +10 -8
  31. package/dist/isArrayLikeObject-Bytw9p-q.js +1503 -0
  32. package/dist/lib/src/components/Panel.d.ts +1 -0
  33. package/dist/lib/src/components/Panel.d.ts.map +1 -1
  34. package/dist/lib/src/components/Panel.js +2 -2
  35. package/dist/lib/src/components/Panel.js.map +1 -1
  36. package/dist/lib/src/components/PanelToolbar.d.ts +1 -0
  37. package/dist/lib/src/components/PanelToolbar.d.ts.map +1 -1
  38. package/dist/lib/src/components/PanelToolbar.js +6 -3
  39. package/dist/lib/src/components/PanelToolbar.js.map +1 -1
  40. package/dist/lib/src/components/measure-render-delay.d.ts.map +1 -1
  41. package/dist/lib/src/components/measure-render-delay.js +5 -0
  42. package/dist/lib/src/components/measure-render-delay.js.map +1 -1
  43. package/dist/lib/src/messaging/{deserialization.d.ts → deserialization.worker.d.ts} +6 -2
  44. package/dist/lib/src/messaging/deserialization.worker.d.ts.map +1 -0
  45. package/dist/lib/src/messaging/{deserialization.js → deserialization.worker.js} +28 -3
  46. package/dist/lib/src/messaging/deserialization.worker.js.map +1 -0
  47. package/dist/lib/src/messaging/message-handler.d.ts.map +1 -1
  48. package/dist/lib/src/messaging/message-handler.js +14 -20
  49. package/dist/lib/src/messaging/message-handler.js.map +1 -1
  50. package/dist/lib/src/panels/ImagePanel.d.ts +3 -5
  51. package/dist/lib/src/panels/ImagePanel.d.ts.map +1 -1
  52. package/dist/lib/src/panels/ImagePanel.js +1 -0
  53. package/dist/lib/src/panels/ImagePanel.js.map +1 -1
  54. package/dist/lib/src/panels/PointCloudPanel.d.ts +2 -0
  55. package/dist/lib/src/panels/PointCloudPanel.d.ts.map +1 -1
  56. package/dist/lib/src/panels/PointCloudPanel.js +29 -4
  57. package/dist/lib/src/panels/PointCloudPanel.js.map +1 -1
  58. package/dist/lib/src/utils/poitcloud-sync.d.ts.map +1 -1
  59. package/dist/lib/src/utils/poitcloud-sync.js +5 -2
  60. package/dist/lib/src/utils/poitcloud-sync.js.map +1 -1
  61. package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.d.ts.map +1 -1
  62. package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.js +3 -0
  63. package/dist/packages/studio-base/src/panels/ThreeDeeRender/ThreeDeeRender.js.map +1 -1
  64. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/CameraStateSettings.js +2 -2
  65. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/CameraStateSettings.js.map +1 -1
  66. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/ImageMode.d.ts.map +1 -1
  67. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/ImageMode.js +0 -1
  68. package/dist/packages/studio-base/src/panels/ThreeDeeRender/renderables/ImageMode/ImageMode.js.map +1 -1
  69. package/dist/{FoxgloveServer-DiLI7KZU.js → protobuf-Cr0sn6Ua.js} +996 -2196
  70. package/dist/tslib.es6-D98N6tjc.js +4116 -0
  71. package/dist/useMessageReducer-Cg30zaG9.js +422 -0
  72. package/dist/{worker-CtuCYYTr.js → worker-B5OJw-Fq.js} +5 -3
  73. package/dist/{worker-Bd7K1fGT.js → worker-aVL4LGa3.js} +5 -3
  74. package/package.json +1 -1
  75. package/dist/lib/src/messaging/deserialization.d.ts.map +0 -1
  76. package/dist/lib/src/messaging/deserialization.js.map +0 -1
@@ -1,3281 +1,1781 @@
1
- /** Detect free variable `global` from Node.js. */
2
- var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
1
+ import { h as isObject, z as defineProperty, u as eq, c as isArrayLike, j as isIndex, b as baseRest, g as isPrototype, p as arrayLikeKeys, n as overArg, k as isObjectLike, l as baseGetTag, r as root, U as Uint8Array, d as isBuffer, e as isTypedArray, i as isArray, a as isArrayLikeObject, f as isArguments, A as isFunction, y as baseFor, v as Stack } from './isArrayLikeObject-Bytw9p-q.js';
3
2
 
4
- /** Detect free variable `self`. */
5
- var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
6
-
7
- /** Used as a reference to the global object. */
8
- var root = freeGlobal || freeSelf || Function('return this')();
9
-
10
- /** Built-in value references. */
11
- var Symbol$1 = root.Symbol;
12
-
13
- /** Used for built-in method references. */
14
- var objectProto$a = Object.prototype;
15
-
16
- /** Used to check objects for own properties. */
17
- var hasOwnProperty$8 = objectProto$a.hasOwnProperty;
18
-
19
- /**
20
- * Used to resolve the
21
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
22
- * of values.
23
- */
24
- var nativeObjectToString$1 = objectProto$a.toString;
25
-
26
- /** Built-in value references. */
27
- var symToStringTag$1 = Symbol$1 ? Symbol$1.toStringTag : undefined;
28
-
29
- /**
30
- * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
31
- *
32
- * @private
33
- * @param {*} value The value to query.
34
- * @returns {string} Returns the raw `toStringTag`.
35
- */
36
- function getRawTag(value) {
37
- var isOwn = hasOwnProperty$8.call(value, symToStringTag$1),
38
- tag = value[symToStringTag$1];
39
-
40
- try {
41
- value[symToStringTag$1] = undefined;
42
- var unmasked = true;
43
- } catch (e) {}
44
-
45
- var result = nativeObjectToString$1.call(value);
46
- if (unmasked) {
47
- if (isOwn) {
48
- value[symToStringTag$1] = tag;
49
- } else {
50
- delete value[symToStringTag$1];
51
- }
52
- }
53
- return result;
54
- }
55
-
56
- /** Used for built-in method references. */
57
- var objectProto$9 = Object.prototype;
58
-
59
- /**
60
- * Used to resolve the
61
- * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
62
- * of values.
63
- */
64
- var nativeObjectToString = objectProto$9.toString;
65
-
66
- /**
67
- * Converts `value` to a string using `Object.prototype.toString`.
68
- *
69
- * @private
70
- * @param {*} value The value to convert.
71
- * @returns {string} Returns the converted string.
72
- */
73
- function objectToString(value) {
74
- return nativeObjectToString.call(value);
75
- }
76
-
77
- /** `Object#toString` result references. */
78
- var nullTag = '[object Null]',
79
- undefinedTag = '[object Undefined]';
80
-
81
- /** Built-in value references. */
82
- var symToStringTag = Symbol$1 ? Symbol$1.toStringTag : undefined;
83
-
84
- /**
85
- * The base implementation of `getTag` without fallbacks for buggy environments.
86
- *
87
- * @private
88
- * @param {*} value The value to query.
89
- * @returns {string} Returns the `toStringTag`.
90
- */
91
- function baseGetTag(value) {
92
- if (value == null) {
93
- return value === undefined ? undefinedTag : nullTag;
94
- }
95
- return (symToStringTag && symToStringTag in Object(value))
96
- ? getRawTag(value)
97
- : objectToString(value);
98
- }
99
-
100
- /**
101
- * Checks if `value` is object-like. A value is object-like if it's not `null`
102
- * and has a `typeof` result of "object".
103
- *
104
- * @static
105
- * @memberOf _
106
- * @since 4.0.0
107
- * @category Lang
108
- * @param {*} value The value to check.
109
- * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
110
- * @example
111
- *
112
- * _.isObjectLike({});
113
- * // => true
114
- *
115
- * _.isObjectLike([1, 2, 3]);
116
- * // => true
117
- *
118
- * _.isObjectLike(_.noop);
119
- * // => false
120
- *
121
- * _.isObjectLike(null);
122
- * // => false
123
- */
124
- function isObjectLike(value) {
125
- return value != null && typeof value == 'object';
126
- }
127
-
128
- /**
129
- * Checks if `value` is classified as an `Array` object.
130
- *
131
- * @static
132
- * @memberOf _
133
- * @since 0.1.0
134
- * @category Lang
135
- * @param {*} value The value to check.
136
- * @returns {boolean} Returns `true` if `value` is an array, else `false`.
137
- * @example
138
- *
139
- * _.isArray([1, 2, 3]);
140
- * // => true
141
- *
142
- * _.isArray(document.body.children);
143
- * // => false
144
- *
145
- * _.isArray('abc');
146
- * // => false
147
- *
148
- * _.isArray(_.noop);
149
- * // => false
150
- */
151
- var isArray = Array.isArray;
3
+ // This file is autogenerated. It's used to publish ESM to npm.
4
+ function _typeof(obj) {
5
+ "@babel/helpers - typeof";
152
6
 
153
- /**
154
- * Checks if `value` is the
155
- * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
156
- * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
157
- *
158
- * @static
159
- * @memberOf _
160
- * @since 0.1.0
161
- * @category Lang
162
- * @param {*} value The value to check.
163
- * @returns {boolean} Returns `true` if `value` is an object, else `false`.
164
- * @example
165
- *
166
- * _.isObject({});
167
- * // => true
168
- *
169
- * _.isObject([1, 2, 3]);
170
- * // => true
171
- *
172
- * _.isObject(_.noop);
173
- * // => true
174
- *
175
- * _.isObject(null);
176
- * // => false
177
- */
178
- function isObject(value) {
179
- var type = typeof value;
180
- return value != null && (type == 'object' || type == 'function');
7
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
8
+ return typeof obj;
9
+ } : function (obj) {
10
+ return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
11
+ }, _typeof(obj);
181
12
  }
182
13
 
183
- /**
184
- * This method returns the first argument it receives.
185
- *
186
- * @static
187
- * @since 0.1.0
188
- * @memberOf _
189
- * @category Util
190
- * @param {*} value Any value.
191
- * @returns {*} Returns `value`.
192
- * @example
193
- *
194
- * var object = { 'a': 1 };
195
- *
196
- * console.log(_.identity(object) === object);
197
- * // => true
198
- */
199
- function identity(value) {
200
- return value;
201
- }
14
+ // https://github.com/bgrins/TinyColor
15
+ // Brian Grinstead, MIT License
202
16
 
203
- /** `Object#toString` result references. */
204
- var asyncTag = '[object AsyncFunction]',
205
- funcTag$1 = '[object Function]',
206
- genTag = '[object GeneratorFunction]',
207
- proxyTag = '[object Proxy]';
17
+ var trimLeft = /^\s+/;
18
+ var trimRight = /\s+$/;
19
+ function tinycolor(color, opts) {
20
+ color = color ? color : "";
21
+ opts = opts || {};
208
22
 
209
- /**
210
- * Checks if `value` is classified as a `Function` object.
211
- *
212
- * @static
213
- * @memberOf _
214
- * @since 0.1.0
215
- * @category Lang
216
- * @param {*} value The value to check.
217
- * @returns {boolean} Returns `true` if `value` is a function, else `false`.
218
- * @example
219
- *
220
- * _.isFunction(_);
221
- * // => true
222
- *
223
- * _.isFunction(/abc/);
224
- * // => false
225
- */
226
- function isFunction(value) {
227
- if (!isObject(value)) {
228
- return false;
23
+ // If input is already a tinycolor, return itself
24
+ if (color instanceof tinycolor) {
25
+ return color;
229
26
  }
230
- // The use of `Object#toString` avoids issues with the `typeof` operator
231
- // in Safari 9 which returns 'object' for typed arrays and other constructors.
232
- var tag = baseGetTag(value);
233
- return tag == funcTag$1 || tag == genTag || tag == asyncTag || tag == proxyTag;
234
- }
235
-
236
- /** Used to detect overreaching core-js shims. */
237
- var coreJsData = root['__core-js_shared__'];
238
-
239
- /** Used to detect methods masquerading as native. */
240
- var maskSrcKey = (function() {
241
- var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
242
- return uid ? ('Symbol(src)_1.' + uid) : '';
243
- }());
244
-
245
- /**
246
- * Checks if `func` has its source masked.
247
- *
248
- * @private
249
- * @param {Function} func The function to check.
250
- * @returns {boolean} Returns `true` if `func` is masked, else `false`.
251
- */
252
- function isMasked(func) {
253
- return !!maskSrcKey && (maskSrcKey in func);
254
- }
255
-
256
- /** Used for built-in method references. */
257
- var funcProto$2 = Function.prototype;
258
-
259
- /** Used to resolve the decompiled source of functions. */
260
- var funcToString$2 = funcProto$2.toString;
261
-
262
- /**
263
- * Converts `func` to its source code.
264
- *
265
- * @private
266
- * @param {Function} func The function to convert.
267
- * @returns {string} Returns the source code.
268
- */
269
- function toSource(func) {
270
- if (func != null) {
271
- try {
272
- return funcToString$2.call(func);
273
- } catch (e) {}
274
- try {
275
- return (func + '');
276
- } catch (e) {}
277
- }
278
- return '';
279
- }
280
-
281
- /**
282
- * Used to match `RegExp`
283
- * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
284
- */
285
- var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
286
-
287
- /** Used to detect host constructors (Safari). */
288
- var reIsHostCtor = /^\[object .+?Constructor\]$/;
289
-
290
- /** Used for built-in method references. */
291
- var funcProto$1 = Function.prototype,
292
- objectProto$8 = Object.prototype;
293
-
294
- /** Used to resolve the decompiled source of functions. */
295
- var funcToString$1 = funcProto$1.toString;
296
-
297
- /** Used to check objects for own properties. */
298
- var hasOwnProperty$7 = objectProto$8.hasOwnProperty;
299
-
300
- /** Used to detect if a method is native. */
301
- var reIsNative = RegExp('^' +
302
- funcToString$1.call(hasOwnProperty$7).replace(reRegExpChar, '\\$&')
303
- .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
304
- );
305
-
306
- /**
307
- * The base implementation of `_.isNative` without bad shim checks.
308
- *
309
- * @private
310
- * @param {*} value The value to check.
311
- * @returns {boolean} Returns `true` if `value` is a native function,
312
- * else `false`.
313
- */
314
- function baseIsNative(value) {
315
- if (!isObject(value) || isMasked(value)) {
316
- return false;
27
+ // If we are called as a function, call using new instead
28
+ if (!(this instanceof tinycolor)) {
29
+ return new tinycolor(color, opts);
317
30
  }
318
- var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
319
- return pattern.test(toSource(value));
320
- }
321
-
322
- /**
323
- * Gets the value at `key` of `object`.
324
- *
325
- * @private
326
- * @param {Object} [object] The object to query.
327
- * @param {string} key The key of the property to get.
328
- * @returns {*} Returns the property value.
329
- */
330
- function getValue(object, key) {
331
- return object == null ? undefined : object[key];
332
- }
333
-
334
- /**
335
- * Gets the native function at `key` of `object`.
336
- *
337
- * @private
338
- * @param {Object} object The object to query.
339
- * @param {string} key The key of the method to get.
340
- * @returns {*} Returns the function if it's native, else `undefined`.
341
- */
342
- function getNative(object, key) {
343
- var value = getValue(object, key);
344
- return baseIsNative(value) ? value : undefined;
345
- }
346
-
347
- /** Built-in value references. */
348
- var objectCreate = Object.create;
349
-
350
- /**
351
- * The base implementation of `_.create` without support for assigning
352
- * properties to the created object.
353
- *
354
- * @private
355
- * @param {Object} proto The object to inherit from.
356
- * @returns {Object} Returns the new object.
357
- */
358
- var baseCreate = (function() {
359
- function object() {}
360
- return function(proto) {
361
- if (!isObject(proto)) {
362
- return {};
363
- }
364
- if (objectCreate) {
365
- return objectCreate(proto);
366
- }
367
- object.prototype = proto;
368
- var result = new object;
369
- object.prototype = undefined;
370
- return result;
371
- };
372
- }());
31
+ var rgb = inputToRGB(color);
32
+ this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format;
33
+ this._gradientType = opts.gradientType;
373
34
 
374
- /**
375
- * A faster alternative to `Function#apply`, this function invokes `func`
376
- * with the `this` binding of `thisArg` and the arguments of `args`.
377
- *
378
- * @private
379
- * @param {Function} func The function to invoke.
380
- * @param {*} thisArg The `this` binding of `func`.
381
- * @param {Array} args The arguments to invoke `func` with.
382
- * @returns {*} Returns the result of `func`.
383
- */
384
- function apply(func, thisArg, args) {
385
- switch (args.length) {
386
- case 0: return func.call(thisArg);
387
- case 1: return func.call(thisArg, args[0]);
388
- case 2: return func.call(thisArg, args[0], args[1]);
389
- case 3: return func.call(thisArg, args[0], args[1], args[2]);
390
- }
391
- return func.apply(thisArg, args);
35
+ // Don't let the range of [0,255] come back in [0,1].
36
+ // Potentially lose a little bit of precision here, but will fix issues where
37
+ // .5 gets interpreted as half of the total, instead of half of 1
38
+ // If it was supposed to be 128, this was already taken care of by `inputToRgb`
39
+ if (this._r < 1) this._r = Math.round(this._r);
40
+ if (this._g < 1) this._g = Math.round(this._g);
41
+ if (this._b < 1) this._b = Math.round(this._b);
42
+ this._ok = rgb.ok;
392
43
  }
393
-
394
- /**
395
- * Copies the values of `source` to `array`.
396
- *
397
- * @private
398
- * @param {Array} source The array to copy values from.
399
- * @param {Array} [array=[]] The array to copy values to.
400
- * @returns {Array} Returns `array`.
401
- */
402
- function copyArray(source, array) {
403
- var index = -1,
404
- length = source.length;
405
-
406
- array || (array = Array(length));
407
- while (++index < length) {
408
- array[index] = source[index];
44
+ tinycolor.prototype = {
45
+ isDark: function isDark() {
46
+ return this.getBrightness() < 128;
47
+ },
48
+ isLight: function isLight() {
49
+ return !this.isDark();
50
+ },
51
+ isValid: function isValid() {
52
+ return this._ok;
53
+ },
54
+ getOriginalInput: function getOriginalInput() {
55
+ return this._originalInput;
56
+ },
57
+ getFormat: function getFormat() {
58
+ return this._format;
59
+ },
60
+ getAlpha: function getAlpha() {
61
+ return this._a;
62
+ },
63
+ getBrightness: function getBrightness() {
64
+ //http://www.w3.org/TR/AERT#color-contrast
65
+ var rgb = this.toRgb();
66
+ return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
67
+ },
68
+ getLuminance: function getLuminance() {
69
+ //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
70
+ var rgb = this.toRgb();
71
+ var RsRGB, GsRGB, BsRGB, R, G, B;
72
+ RsRGB = rgb.r / 255;
73
+ GsRGB = rgb.g / 255;
74
+ BsRGB = rgb.b / 255;
75
+ if (RsRGB <= 0.03928) R = RsRGB / 12.92;else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
76
+ if (GsRGB <= 0.03928) G = GsRGB / 12.92;else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
77
+ if (BsRGB <= 0.03928) B = BsRGB / 12.92;else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
78
+ return 0.2126 * R + 0.7152 * G + 0.0722 * B;
79
+ },
80
+ setAlpha: function setAlpha(value) {
81
+ this._a = boundAlpha(value);
82
+ this._roundA = Math.round(100 * this._a) / 100;
83
+ return this;
84
+ },
85
+ toHsv: function toHsv() {
86
+ var hsv = rgbToHsv(this._r, this._g, this._b);
87
+ return {
88
+ h: hsv.h * 360,
89
+ s: hsv.s,
90
+ v: hsv.v,
91
+ a: this._a
92
+ };
93
+ },
94
+ toHsvString: function toHsvString() {
95
+ var hsv = rgbToHsv(this._r, this._g, this._b);
96
+ var h = Math.round(hsv.h * 360),
97
+ s = Math.round(hsv.s * 100),
98
+ v = Math.round(hsv.v * 100);
99
+ return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
100
+ },
101
+ toHsl: function toHsl() {
102
+ var hsl = rgbToHsl(this._r, this._g, this._b);
103
+ return {
104
+ h: hsl.h * 360,
105
+ s: hsl.s,
106
+ l: hsl.l,
107
+ a: this._a
108
+ };
109
+ },
110
+ toHslString: function toHslString() {
111
+ var hsl = rgbToHsl(this._r, this._g, this._b);
112
+ var h = Math.round(hsl.h * 360),
113
+ s = Math.round(hsl.s * 100),
114
+ l = Math.round(hsl.l * 100);
115
+ return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
116
+ },
117
+ toHex: function toHex(allow3Char) {
118
+ return rgbToHex(this._r, this._g, this._b, allow3Char);
119
+ },
120
+ toHexString: function toHexString(allow3Char) {
121
+ return "#" + this.toHex(allow3Char);
122
+ },
123
+ toHex8: function toHex8(allow4Char) {
124
+ return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
125
+ },
126
+ toHex8String: function toHex8String(allow4Char) {
127
+ return "#" + this.toHex8(allow4Char);
128
+ },
129
+ toRgb: function toRgb() {
130
+ return {
131
+ r: Math.round(this._r),
132
+ g: Math.round(this._g),
133
+ b: Math.round(this._b),
134
+ a: this._a
135
+ };
136
+ },
137
+ toRgbString: function toRgbString() {
138
+ return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
139
+ },
140
+ toPercentageRgb: function toPercentageRgb() {
141
+ return {
142
+ r: Math.round(bound01(this._r, 255) * 100) + "%",
143
+ g: Math.round(bound01(this._g, 255) * 100) + "%",
144
+ b: Math.round(bound01(this._b, 255) * 100) + "%",
145
+ a: this._a
146
+ };
147
+ },
148
+ toPercentageRgbString: function toPercentageRgbString() {
149
+ return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
150
+ },
151
+ toName: function toName() {
152
+ if (this._a === 0) {
153
+ return "transparent";
154
+ }
155
+ if (this._a < 1) {
156
+ return false;
157
+ }
158
+ return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
159
+ },
160
+ toFilter: function toFilter(secondColor) {
161
+ var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
162
+ var secondHex8String = hex8String;
163
+ var gradientType = this._gradientType ? "GradientType = 1, " : "";
164
+ if (secondColor) {
165
+ var s = tinycolor(secondColor);
166
+ secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
167
+ }
168
+ return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
169
+ },
170
+ toString: function toString(format) {
171
+ var formatSet = !!format;
172
+ format = format || this._format;
173
+ var formattedString = false;
174
+ var hasAlpha = this._a < 1 && this._a >= 0;
175
+ var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
176
+ if (needsAlphaFormat) {
177
+ // Special case for "transparent", all other non-alpha formats
178
+ // will return rgba when there is transparency.
179
+ if (format === "name" && this._a === 0) {
180
+ return this.toName();
181
+ }
182
+ return this.toRgbString();
183
+ }
184
+ if (format === "rgb") {
185
+ formattedString = this.toRgbString();
186
+ }
187
+ if (format === "prgb") {
188
+ formattedString = this.toPercentageRgbString();
189
+ }
190
+ if (format === "hex" || format === "hex6") {
191
+ formattedString = this.toHexString();
192
+ }
193
+ if (format === "hex3") {
194
+ formattedString = this.toHexString(true);
195
+ }
196
+ if (format === "hex4") {
197
+ formattedString = this.toHex8String(true);
198
+ }
199
+ if (format === "hex8") {
200
+ formattedString = this.toHex8String();
201
+ }
202
+ if (format === "name") {
203
+ formattedString = this.toName();
204
+ }
205
+ if (format === "hsl") {
206
+ formattedString = this.toHslString();
207
+ }
208
+ if (format === "hsv") {
209
+ formattedString = this.toHsvString();
210
+ }
211
+ return formattedString || this.toHexString();
212
+ },
213
+ clone: function clone() {
214
+ return tinycolor(this.toString());
215
+ },
216
+ _applyModification: function _applyModification(fn, args) {
217
+ var color = fn.apply(null, [this].concat([].slice.call(args)));
218
+ this._r = color._r;
219
+ this._g = color._g;
220
+ this._b = color._b;
221
+ this.setAlpha(color._a);
222
+ return this;
223
+ },
224
+ lighten: function lighten() {
225
+ return this._applyModification(_lighten, arguments);
226
+ },
227
+ brighten: function brighten() {
228
+ return this._applyModification(_brighten, arguments);
229
+ },
230
+ darken: function darken() {
231
+ return this._applyModification(_darken, arguments);
232
+ },
233
+ desaturate: function desaturate() {
234
+ return this._applyModification(_desaturate, arguments);
235
+ },
236
+ saturate: function saturate() {
237
+ return this._applyModification(_saturate, arguments);
238
+ },
239
+ greyscale: function greyscale() {
240
+ return this._applyModification(_greyscale, arguments);
241
+ },
242
+ spin: function spin() {
243
+ return this._applyModification(_spin, arguments);
244
+ },
245
+ _applyCombination: function _applyCombination(fn, args) {
246
+ return fn.apply(null, [this].concat([].slice.call(args)));
247
+ },
248
+ analogous: function analogous() {
249
+ return this._applyCombination(_analogous, arguments);
250
+ },
251
+ complement: function complement() {
252
+ return this._applyCombination(_complement, arguments);
253
+ },
254
+ monochromatic: function monochromatic() {
255
+ return this._applyCombination(_monochromatic, arguments);
256
+ },
257
+ splitcomplement: function splitcomplement() {
258
+ return this._applyCombination(_splitcomplement, arguments);
259
+ },
260
+ // Disabled until https://github.com/bgrins/TinyColor/issues/254
261
+ // polyad: function (number) {
262
+ // return this._applyCombination(polyad, [number]);
263
+ // },
264
+ triad: function triad() {
265
+ return this._applyCombination(polyad, [3]);
266
+ },
267
+ tetrad: function tetrad() {
268
+ return this._applyCombination(polyad, [4]);
409
269
  }
410
- return array;
411
- }
412
-
413
- /** Used to detect hot functions by number of calls within a span of milliseconds. */
414
- var HOT_COUNT = 800,
415
- HOT_SPAN = 16;
416
-
417
- /* Built-in method references for those with the same name as other `lodash` methods. */
418
- var nativeNow = Date.now;
419
-
420
- /**
421
- * Creates a function that'll short out and invoke `identity` instead
422
- * of `func` when it's called `HOT_COUNT` or more times in `HOT_SPAN`
423
- * milliseconds.
424
- *
425
- * @private
426
- * @param {Function} func The function to restrict.
427
- * @returns {Function} Returns the new shortable function.
428
- */
429
- function shortOut(func) {
430
- var count = 0,
431
- lastCalled = 0;
432
-
433
- return function() {
434
- var stamp = nativeNow(),
435
- remaining = HOT_SPAN - (stamp - lastCalled);
270
+ };
436
271
 
437
- lastCalled = stamp;
438
- if (remaining > 0) {
439
- if (++count >= HOT_COUNT) {
440
- return arguments[0];
272
+ // If input is an object, force 1 into "1.0" to handle ratios properly
273
+ // String input requires "1.0" as input, so 1 will be treated as 1
274
+ tinycolor.fromRatio = function (color, opts) {
275
+ if (_typeof(color) == "object") {
276
+ var newColor = {};
277
+ for (var i in color) {
278
+ if (color.hasOwnProperty(i)) {
279
+ if (i === "a") {
280
+ newColor[i] = color[i];
281
+ } else {
282
+ newColor[i] = convertToPercentage(color[i]);
283
+ }
441
284
  }
442
- } else {
443
- count = 0;
444
285
  }
445
- return func.apply(undefined, arguments);
446
- };
447
- }
286
+ color = newColor;
287
+ }
288
+ return tinycolor(color, opts);
289
+ };
448
290
 
449
- /**
450
- * Creates a function that returns `value`.
451
- *
452
- * @static
453
- * @memberOf _
454
- * @since 2.4.0
455
- * @category Util
456
- * @param {*} value The value to return from the new function.
457
- * @returns {Function} Returns the new constant function.
458
- * @example
459
- *
460
- * var objects = _.times(2, _.constant({ 'a': 1 }));
461
- *
462
- * console.log(objects);
463
- * // => [{ 'a': 1 }, { 'a': 1 }]
464
- *
465
- * console.log(objects[0] === objects[1]);
466
- * // => true
467
- */
468
- function constant(value) {
469
- return function() {
470
- return value;
291
+ // Given a string or object, convert that input to RGB
292
+ // Possible string inputs:
293
+ //
294
+ // "red"
295
+ // "#f00" or "f00"
296
+ // "#ff0000" or "ff0000"
297
+ // "#ff000000" or "ff000000"
298
+ // "rgb 255 0 0" or "rgb (255, 0, 0)"
299
+ // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
300
+ // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
301
+ // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
302
+ // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
303
+ // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
304
+ // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
305
+ //
306
+ function inputToRGB(color) {
307
+ var rgb = {
308
+ r: 0,
309
+ g: 0,
310
+ b: 0
471
311
  };
472
- }
473
-
474
- var defineProperty = (function() {
475
- try {
476
- var func = getNative(Object, 'defineProperty');
477
- func({}, '', {});
478
- return func;
479
- } catch (e) {}
480
- }());
481
-
482
- /**
483
- * The base implementation of `setToString` without support for hot loop shorting.
484
- *
485
- * @private
486
- * @param {Function} func The function to modify.
487
- * @param {Function} string The `toString` result.
488
- * @returns {Function} Returns `func`.
489
- */
490
- var baseSetToString = !defineProperty ? identity : function(func, string) {
491
- return defineProperty(func, 'toString', {
492
- 'configurable': true,
493
- 'enumerable': false,
494
- 'value': constant(string),
495
- 'writable': true
496
- });
497
- };
498
-
499
- /**
500
- * Sets the `toString` method of `func` to return `string`.
501
- *
502
- * @private
503
- * @param {Function} func The function to modify.
504
- * @param {Function} string The `toString` result.
505
- * @returns {Function} Returns `func`.
506
- */
507
- var setToString = shortOut(baseSetToString);
508
-
509
- /** Used as references for various `Number` constants. */
510
- var MAX_SAFE_INTEGER$1 = 9007199254740991;
511
-
512
- /** Used to detect unsigned integer values. */
513
- var reIsUint = /^(?:0|[1-9]\d*)$/;
514
-
515
- /**
516
- * Checks if `value` is a valid array-like index.
517
- *
518
- * @private
519
- * @param {*} value The value to check.
520
- * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
521
- * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
522
- */
523
- function isIndex(value, length) {
524
- var type = typeof value;
525
- length = length == null ? MAX_SAFE_INTEGER$1 : length;
526
-
527
- return !!length &&
528
- (type == 'number' ||
529
- (type != 'symbol' && reIsUint.test(value))) &&
530
- (value > -1 && value % 1 == 0 && value < length);
531
- }
532
-
533
- /**
534
- * The base implementation of `assignValue` and `assignMergeValue` without
535
- * value checks.
536
- *
537
- * @private
538
- * @param {Object} object The object to modify.
539
- * @param {string} key The key of the property to assign.
540
- * @param {*} value The value to assign.
541
- */
542
- function baseAssignValue(object, key, value) {
543
- if (key == '__proto__' && defineProperty) {
544
- defineProperty(object, key, {
545
- 'configurable': true,
546
- 'enumerable': true,
547
- 'value': value,
548
- 'writable': true
549
- });
550
- } else {
551
- object[key] = value;
552
- }
553
- }
554
-
555
- /**
556
- * Performs a
557
- * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
558
- * comparison between two values to determine if they are equivalent.
559
- *
560
- * @static
561
- * @memberOf _
562
- * @since 4.0.0
563
- * @category Lang
564
- * @param {*} value The value to compare.
565
- * @param {*} other The other value to compare.
566
- * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
567
- * @example
568
- *
569
- * var object = { 'a': 1 };
570
- * var other = { 'a': 1 };
571
- *
572
- * _.eq(object, object);
573
- * // => true
574
- *
575
- * _.eq(object, other);
576
- * // => false
577
- *
578
- * _.eq('a', 'a');
579
- * // => true
580
- *
581
- * _.eq('a', Object('a'));
582
- * // => false
583
- *
584
- * _.eq(NaN, NaN);
585
- * // => true
586
- */
587
- function eq(value, other) {
588
- return value === other || (value !== value && other !== other);
589
- }
590
-
591
- /** Used for built-in method references. */
592
- var objectProto$7 = Object.prototype;
593
-
594
- /** Used to check objects for own properties. */
595
- var hasOwnProperty$6 = objectProto$7.hasOwnProperty;
596
-
597
- /**
598
- * Assigns `value` to `key` of `object` if the existing value is not equivalent
599
- * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
600
- * for equality comparisons.
601
- *
602
- * @private
603
- * @param {Object} object The object to modify.
604
- * @param {string} key The key of the property to assign.
605
- * @param {*} value The value to assign.
606
- */
607
- function assignValue(object, key, value) {
608
- var objValue = object[key];
609
- if (!(hasOwnProperty$6.call(object, key) && eq(objValue, value)) ||
610
- (value === undefined && !(key in object))) {
611
- baseAssignValue(object, key, value);
312
+ var a = 1;
313
+ var s = null;
314
+ var v = null;
315
+ var l = null;
316
+ var ok = false;
317
+ var format = false;
318
+ if (typeof color == "string") {
319
+ color = stringInputToObject(color);
612
320
  }
613
- }
614
-
615
- /**
616
- * Copies properties of `source` to `object`.
617
- *
618
- * @private
619
- * @param {Object} source The object to copy properties from.
620
- * @param {Array} props The property identifiers to copy.
621
- * @param {Object} [object={}] The object to copy properties to.
622
- * @param {Function} [customizer] The function to customize copied values.
623
- * @returns {Object} Returns `object`.
624
- */
625
- function copyObject(source, props, object, customizer) {
626
- var isNew = !object;
627
- object || (object = {});
628
-
629
- var index = -1,
630
- length = props.length;
631
-
632
- while (++index < length) {
633
- var key = props[index];
634
-
635
- var newValue = undefined;
636
-
637
- if (newValue === undefined) {
638
- newValue = source[key];
321
+ if (_typeof(color) == "object") {
322
+ if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
323
+ rgb = rgbToRgb(color.r, color.g, color.b);
324
+ ok = true;
325
+ format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
326
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
327
+ s = convertToPercentage(color.s);
328
+ v = convertToPercentage(color.v);
329
+ rgb = hsvToRgb(color.h, s, v);
330
+ ok = true;
331
+ format = "hsv";
332
+ } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
333
+ s = convertToPercentage(color.s);
334
+ l = convertToPercentage(color.l);
335
+ rgb = hslToRgb(color.h, s, l);
336
+ ok = true;
337
+ format = "hsl";
639
338
  }
640
- if (isNew) {
641
- baseAssignValue(object, key, newValue);
642
- } else {
643
- assignValue(object, key, newValue);
339
+ if (color.hasOwnProperty("a")) {
340
+ a = color.a;
644
341
  }
645
342
  }
646
- return object;
343
+ a = boundAlpha(a);
344
+ return {
345
+ ok: ok,
346
+ format: color.format || format,
347
+ r: Math.min(255, Math.max(rgb.r, 0)),
348
+ g: Math.min(255, Math.max(rgb.g, 0)),
349
+ b: Math.min(255, Math.max(rgb.b, 0)),
350
+ a: a
351
+ };
647
352
  }
648
353
 
649
- /* Built-in method references for those with the same name as other `lodash` methods. */
650
- var nativeMax = Math.max;
354
+ // Conversion Functions
355
+ // --------------------
651
356
 
652
- /**
653
- * A specialized version of `baseRest` which transforms the rest array.
654
- *
655
- * @private
656
- * @param {Function} func The function to apply a rest parameter to.
657
- * @param {number} [start=func.length-1] The start position of the rest parameter.
658
- * @param {Function} transform The rest array transform.
659
- * @returns {Function} Returns the new function.
660
- */
661
- function overRest(func, start, transform) {
662
- start = nativeMax(start === undefined ? (func.length - 1) : start, 0);
663
- return function() {
664
- var args = arguments,
665
- index = -1,
666
- length = nativeMax(args.length - start, 0),
667
- array = Array(length);
357
+ // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
358
+ // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
668
359
 
669
- while (++index < length) {
670
- array[index] = args[start + index];
671
- }
672
- index = -1;
673
- var otherArgs = Array(start + 1);
674
- while (++index < start) {
675
- otherArgs[index] = args[index];
676
- }
677
- otherArgs[start] = transform(array);
678
- return apply(func, this, otherArgs);
360
+ // `rgbToRgb`
361
+ // Handle bounds / percentage checking to conform to CSS color spec
362
+ // <http://www.w3.org/TR/css3-color/>
363
+ // *Assumes:* r, g, b in [0, 255] or [0, 1]
364
+ // *Returns:* { r, g, b } in [0, 255]
365
+ function rgbToRgb(r, g, b) {
366
+ return {
367
+ r: bound01(r, 255) * 255,
368
+ g: bound01(g, 255) * 255,
369
+ b: bound01(b, 255) * 255
679
370
  };
680
371
  }
681
372
 
682
- /**
683
- * The base implementation of `_.rest` which doesn't validate or coerce arguments.
684
- *
685
- * @private
686
- * @param {Function} func The function to apply a rest parameter to.
687
- * @param {number} [start=func.length-1] The start position of the rest parameter.
688
- * @returns {Function} Returns the new function.
689
- */
690
- function baseRest(func, start) {
691
- return setToString(overRest(func, start, identity), func + '');
373
+ // `rgbToHsl`
374
+ // Converts an RGB color value to HSL.
375
+ // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
376
+ // *Returns:* { h, s, l } in [0,1]
377
+ function rgbToHsl(r, g, b) {
378
+ r = bound01(r, 255);
379
+ g = bound01(g, 255);
380
+ b = bound01(b, 255);
381
+ var max = Math.max(r, g, b),
382
+ min = Math.min(r, g, b);
383
+ var h,
384
+ s,
385
+ l = (max + min) / 2;
386
+ if (max == min) {
387
+ h = s = 0; // achromatic
388
+ } else {
389
+ var d = max - min;
390
+ s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
391
+ switch (max) {
392
+ case r:
393
+ h = (g - b) / d + (g < b ? 6 : 0);
394
+ break;
395
+ case g:
396
+ h = (b - r) / d + 2;
397
+ break;
398
+ case b:
399
+ h = (r - g) / d + 4;
400
+ break;
401
+ }
402
+ h /= 6;
403
+ }
404
+ return {
405
+ h: h,
406
+ s: s,
407
+ l: l
408
+ };
692
409
  }
693
410
 
694
- /** Used as references for various `Number` constants. */
695
- var MAX_SAFE_INTEGER = 9007199254740991;
696
-
697
- /**
698
- * Checks if `value` is a valid array-like length.
699
- *
700
- * **Note:** This method is loosely based on
701
- * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
702
- *
703
- * @static
704
- * @memberOf _
705
- * @since 4.0.0
706
- * @category Lang
707
- * @param {*} value The value to check.
708
- * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
709
- * @example
710
- *
711
- * _.isLength(3);
712
- * // => true
713
- *
714
- * _.isLength(Number.MIN_VALUE);
715
- * // => false
716
- *
717
- * _.isLength(Infinity);
718
- * // => false
719
- *
720
- * _.isLength('3');
721
- * // => false
722
- */
723
- function isLength(value) {
724
- return typeof value == 'number' &&
725
- value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
726
- }
727
-
728
- /**
729
- * Checks if `value` is array-like. A value is considered array-like if it's
730
- * not a function and has a `value.length` that's an integer greater than or
731
- * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
732
- *
733
- * @static
734
- * @memberOf _
735
- * @since 4.0.0
736
- * @category Lang
737
- * @param {*} value The value to check.
738
- * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
739
- * @example
740
- *
741
- * _.isArrayLike([1, 2, 3]);
742
- * // => true
743
- *
744
- * _.isArrayLike(document.body.children);
745
- * // => true
746
- *
747
- * _.isArrayLike('abc');
748
- * // => true
749
- *
750
- * _.isArrayLike(_.noop);
751
- * // => false
752
- */
753
- function isArrayLike(value) {
754
- return value != null && isLength(value.length) && !isFunction(value);
755
- }
756
-
757
- /**
758
- * Checks if the given arguments are from an iteratee call.
759
- *
760
- * @private
761
- * @param {*} value The potential iteratee value argument.
762
- * @param {*} index The potential iteratee index or key argument.
763
- * @param {*} object The potential iteratee object argument.
764
- * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
765
- * else `false`.
766
- */
767
- function isIterateeCall(value, index, object) {
768
- if (!isObject(object)) {
769
- return false;
411
+ // `hslToRgb`
412
+ // Converts an HSL color value to RGB.
413
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
414
+ // *Returns:* { r, g, b } in the set [0, 255]
415
+ function hslToRgb(h, s, l) {
416
+ var r, g, b;
417
+ h = bound01(h, 360);
418
+ s = bound01(s, 100);
419
+ l = bound01(l, 100);
420
+ function hue2rgb(p, q, t) {
421
+ if (t < 0) t += 1;
422
+ if (t > 1) t -= 1;
423
+ if (t < 1 / 6) return p + (q - p) * 6 * t;
424
+ if (t < 1 / 2) return q;
425
+ if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
426
+ return p;
770
427
  }
771
- var type = typeof index;
772
- if (type == 'number'
773
- ? (isArrayLike(object) && isIndex(index, object.length))
774
- : (type == 'string' && index in object)
775
- ) {
776
- return eq(object[index], value);
428
+ if (s === 0) {
429
+ r = g = b = l; // achromatic
430
+ } else {
431
+ var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
432
+ var p = 2 * l - q;
433
+ r = hue2rgb(p, q, h + 1 / 3);
434
+ g = hue2rgb(p, q, h);
435
+ b = hue2rgb(p, q, h - 1 / 3);
777
436
  }
778
- return false;
437
+ return {
438
+ r: r * 255,
439
+ g: g * 255,
440
+ b: b * 255
441
+ };
779
442
  }
780
443
 
781
- /**
782
- * Creates a function like `_.assign`.
783
- *
784
- * @private
785
- * @param {Function} assigner The function to assign values.
786
- * @returns {Function} Returns the new assigner function.
787
- */
788
- function createAssigner(assigner) {
789
- return baseRest(function(object, sources) {
790
- var index = -1,
791
- length = sources.length,
792
- customizer = length > 1 ? sources[length - 1] : undefined,
793
- guard = length > 2 ? sources[2] : undefined;
794
-
795
- customizer = (assigner.length > 3 && typeof customizer == 'function')
796
- ? (length--, customizer)
797
- : undefined;
798
-
799
- if (guard && isIterateeCall(sources[0], sources[1], guard)) {
800
- customizer = length < 3 ? undefined : customizer;
801
- length = 1;
802
- }
803
- object = Object(object);
804
- while (++index < length) {
805
- var source = sources[index];
806
- if (source) {
807
- assigner(object, source, index, customizer);
808
- }
444
+ // `rgbToHsv`
445
+ // Converts an RGB color value to HSV
446
+ // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
447
+ // *Returns:* { h, s, v } in [0,1]
448
+ function rgbToHsv(r, g, b) {
449
+ r = bound01(r, 255);
450
+ g = bound01(g, 255);
451
+ b = bound01(b, 255);
452
+ var max = Math.max(r, g, b),
453
+ min = Math.min(r, g, b);
454
+ var h,
455
+ s,
456
+ v = max;
457
+ var d = max - min;
458
+ s = max === 0 ? 0 : d / max;
459
+ if (max == min) {
460
+ h = 0; // achromatic
461
+ } else {
462
+ switch (max) {
463
+ case r:
464
+ h = (g - b) / d + (g < b ? 6 : 0);
465
+ break;
466
+ case g:
467
+ h = (b - r) / d + 2;
468
+ break;
469
+ case b:
470
+ h = (r - g) / d + 4;
471
+ break;
809
472
  }
810
- return object;
811
- });
473
+ h /= 6;
474
+ }
475
+ return {
476
+ h: h,
477
+ s: s,
478
+ v: v
479
+ };
812
480
  }
813
481
 
814
- /** Used for built-in method references. */
815
- var objectProto$6 = Object.prototype;
816
-
817
- /**
818
- * Checks if `value` is likely a prototype object.
819
- *
820
- * @private
821
- * @param {*} value The value to check.
822
- * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
823
- */
824
- function isPrototype(value) {
825
- var Ctor = value && value.constructor,
826
- proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto$6;
827
-
828
- return value === proto;
482
+ // `hsvToRgb`
483
+ // Converts an HSV color value to RGB.
484
+ // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
485
+ // *Returns:* { r, g, b } in the set [0, 255]
486
+ function hsvToRgb(h, s, v) {
487
+ h = bound01(h, 360) * 6;
488
+ s = bound01(s, 100);
489
+ v = bound01(v, 100);
490
+ var i = Math.floor(h),
491
+ f = h - i,
492
+ p = v * (1 - s),
493
+ q = v * (1 - f * s),
494
+ t = v * (1 - (1 - f) * s),
495
+ mod = i % 6,
496
+ r = [v, q, p, p, t, v][mod],
497
+ g = [t, v, v, q, p, p][mod],
498
+ b = [p, p, t, v, v, q][mod];
499
+ return {
500
+ r: r * 255,
501
+ g: g * 255,
502
+ b: b * 255
503
+ };
829
504
  }
830
505
 
831
- /**
832
- * The base implementation of `_.times` without support for iteratee shorthands
833
- * or max array length checks.
834
- *
835
- * @private
836
- * @param {number} n The number of times to invoke `iteratee`.
837
- * @param {Function} iteratee The function invoked per iteration.
838
- * @returns {Array} Returns the array of results.
839
- */
840
- function baseTimes(n, iteratee) {
841
- var index = -1,
842
- result = Array(n);
506
+ // `rgbToHex`
507
+ // Converts an RGB color to hex
508
+ // Assumes r, g, and b are contained in the set [0, 255]
509
+ // Returns a 3 or 6 character hex
510
+ function rgbToHex(r, g, b, allow3Char) {
511
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
843
512
 
844
- while (++index < n) {
845
- result[index] = iteratee(index);
513
+ // Return a 3 character hex if possible
514
+ if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
515
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
846
516
  }
847
- return result;
517
+ return hex.join("");
848
518
  }
849
519
 
850
- /** `Object#toString` result references. */
851
- var argsTag$1 = '[object Arguments]';
520
+ // `rgbaToHex`
521
+ // Converts an RGBA color plus alpha transparency to hex
522
+ // Assumes r, g, b are contained in the set [0, 255] and
523
+ // a in [0, 1]. Returns a 4 or 8 character rgba hex
524
+ function rgbaToHex(r, g, b, a, allow4Char) {
525
+ var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
852
526
 
853
- /**
854
- * The base implementation of `_.isArguments`.
855
- *
856
- * @private
857
- * @param {*} value The value to check.
858
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
859
- */
860
- function baseIsArguments(value) {
861
- return isObjectLike(value) && baseGetTag(value) == argsTag$1;
527
+ // Return a 4 character hex if possible
528
+ if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
529
+ return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
530
+ }
531
+ return hex.join("");
862
532
  }
863
533
 
864
- /** Used for built-in method references. */
865
- var objectProto$5 = Object.prototype;
866
-
867
- /** Used to check objects for own properties. */
868
- var hasOwnProperty$5 = objectProto$5.hasOwnProperty;
869
-
870
- /** Built-in value references. */
871
- var propertyIsEnumerable = objectProto$5.propertyIsEnumerable;
534
+ // `rgbaToArgbHex`
535
+ // Converts an RGBA color to an ARGB Hex8 string
536
+ // Rarely used, but required for "toFilter()"
537
+ function rgbaToArgbHex(r, g, b, a) {
538
+ var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
539
+ return hex.join("");
540
+ }
872
541
 
873
- /**
874
- * Checks if `value` is likely an `arguments` object.
875
- *
876
- * @static
877
- * @memberOf _
878
- * @since 0.1.0
879
- * @category Lang
880
- * @param {*} value The value to check.
881
- * @returns {boolean} Returns `true` if `value` is an `arguments` object,
882
- * else `false`.
883
- * @example
884
- *
885
- * _.isArguments(function() { return arguments; }());
886
- * // => true
887
- *
888
- * _.isArguments([1, 2, 3]);
889
- * // => false
890
- */
891
- var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
892
- return isObjectLike(value) && hasOwnProperty$5.call(value, 'callee') &&
893
- !propertyIsEnumerable.call(value, 'callee');
542
+ // `equals`
543
+ // Can be called with any tinycolor input
544
+ tinycolor.equals = function (color1, color2) {
545
+ if (!color1 || !color2) return false;
546
+ return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
547
+ };
548
+ tinycolor.random = function () {
549
+ return tinycolor.fromRatio({
550
+ r: Math.random(),
551
+ g: Math.random(),
552
+ b: Math.random()
553
+ });
894
554
  };
895
555
 
896
- /**
897
- * This method returns `false`.
898
- *
899
- * @static
900
- * @memberOf _
901
- * @since 4.13.0
902
- * @category Util
903
- * @returns {boolean} Returns `false`.
904
- * @example
905
- *
906
- * _.times(2, _.stubFalse);
907
- * // => [false, false]
908
- */
909
- function stubFalse() {
910
- return false;
911
- }
912
-
913
- /** Detect free variable `exports`. */
914
- var freeExports$2 = typeof exports == 'object' && exports && !exports.nodeType && exports;
556
+ // Modification Functions
557
+ // ----------------------
558
+ // Thanks to less.js for some of the basics here
559
+ // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
915
560
 
916
- /** Detect free variable `module`. */
917
- var freeModule$2 = freeExports$2 && typeof module == 'object' && module && !module.nodeType && module;
918
-
919
- /** Detect the popular CommonJS extension `module.exports`. */
920
- var moduleExports$2 = freeModule$2 && freeModule$2.exports === freeExports$2;
921
-
922
- /** Built-in value references. */
923
- var Buffer$1 = moduleExports$2 ? root.Buffer : undefined;
924
-
925
- /* Built-in method references for those with the same name as other `lodash` methods. */
926
- var nativeIsBuffer = Buffer$1 ? Buffer$1.isBuffer : undefined;
927
-
928
- /**
929
- * Checks if `value` is a buffer.
930
- *
931
- * @static
932
- * @memberOf _
933
- * @since 4.3.0
934
- * @category Lang
935
- * @param {*} value The value to check.
936
- * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
937
- * @example
938
- *
939
- * _.isBuffer(new Buffer(2));
940
- * // => true
941
- *
942
- * _.isBuffer(new Uint8Array(2));
943
- * // => false
944
- */
945
- var isBuffer = nativeIsBuffer || stubFalse;
946
-
947
- /** `Object#toString` result references. */
948
- var argsTag = '[object Arguments]',
949
- arrayTag = '[object Array]',
950
- boolTag = '[object Boolean]',
951
- dateTag = '[object Date]',
952
- errorTag = '[object Error]',
953
- funcTag = '[object Function]',
954
- mapTag = '[object Map]',
955
- numberTag = '[object Number]',
956
- objectTag$1 = '[object Object]',
957
- regexpTag = '[object RegExp]',
958
- setTag = '[object Set]',
959
- stringTag = '[object String]',
960
- weakMapTag = '[object WeakMap]';
961
-
962
- var arrayBufferTag = '[object ArrayBuffer]',
963
- dataViewTag = '[object DataView]',
964
- float32Tag = '[object Float32Array]',
965
- float64Tag = '[object Float64Array]',
966
- int8Tag = '[object Int8Array]',
967
- int16Tag = '[object Int16Array]',
968
- int32Tag = '[object Int32Array]',
969
- uint8Tag = '[object Uint8Array]',
970
- uint8ClampedTag = '[object Uint8ClampedArray]',
971
- uint16Tag = '[object Uint16Array]',
972
- uint32Tag = '[object Uint32Array]';
973
-
974
- /** Used to identify `toStringTag` values of typed arrays. */
975
- var typedArrayTags = {};
976
- typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
977
- typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
978
- typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
979
- typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
980
- typedArrayTags[uint32Tag] = true;
981
- typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
982
- typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
983
- typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
984
- typedArrayTags[errorTag] = typedArrayTags[funcTag] =
985
- typedArrayTags[mapTag] = typedArrayTags[numberTag] =
986
- typedArrayTags[objectTag$1] = typedArrayTags[regexpTag] =
987
- typedArrayTags[setTag] = typedArrayTags[stringTag] =
988
- typedArrayTags[weakMapTag] = false;
989
-
990
- /**
991
- * The base implementation of `_.isTypedArray` without Node.js optimizations.
992
- *
993
- * @private
994
- * @param {*} value The value to check.
995
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
996
- */
997
- function baseIsTypedArray(value) {
998
- return isObjectLike(value) &&
999
- isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
561
+ function _desaturate(color, amount) {
562
+ amount = amount === 0 ? 0 : amount || 10;
563
+ var hsl = tinycolor(color).toHsl();
564
+ hsl.s -= amount / 100;
565
+ hsl.s = clamp01(hsl.s);
566
+ return tinycolor(hsl);
1000
567
  }
1001
-
1002
- /**
1003
- * The base implementation of `_.unary` without support for storing metadata.
1004
- *
1005
- * @private
1006
- * @param {Function} func The function to cap arguments for.
1007
- * @returns {Function} Returns the new capped function.
1008
- */
1009
- function baseUnary(func) {
1010
- return function(value) {
1011
- return func(value);
1012
- };
568
+ function _saturate(color, amount) {
569
+ amount = amount === 0 ? 0 : amount || 10;
570
+ var hsl = tinycolor(color).toHsl();
571
+ hsl.s += amount / 100;
572
+ hsl.s = clamp01(hsl.s);
573
+ return tinycolor(hsl);
574
+ }
575
+ function _greyscale(color) {
576
+ return tinycolor(color).desaturate(100);
577
+ }
578
+ function _lighten(color, amount) {
579
+ amount = amount === 0 ? 0 : amount || 10;
580
+ var hsl = tinycolor(color).toHsl();
581
+ hsl.l += amount / 100;
582
+ hsl.l = clamp01(hsl.l);
583
+ return tinycolor(hsl);
584
+ }
585
+ function _brighten(color, amount) {
586
+ amount = amount === 0 ? 0 : amount || 10;
587
+ var rgb = tinycolor(color).toRgb();
588
+ rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
589
+ rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
590
+ rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
591
+ return tinycolor(rgb);
592
+ }
593
+ function _darken(color, amount) {
594
+ amount = amount === 0 ? 0 : amount || 10;
595
+ var hsl = tinycolor(color).toHsl();
596
+ hsl.l -= amount / 100;
597
+ hsl.l = clamp01(hsl.l);
598
+ return tinycolor(hsl);
1013
599
  }
1014
600
 
1015
- /** Detect free variable `exports`. */
1016
- var freeExports$1 = typeof exports == 'object' && exports && !exports.nodeType && exports;
1017
-
1018
- /** Detect free variable `module`. */
1019
- var freeModule$1 = freeExports$1 && typeof module == 'object' && module && !module.nodeType && module;
1020
-
1021
- /** Detect the popular CommonJS extension `module.exports`. */
1022
- var moduleExports$1 = freeModule$1 && freeModule$1.exports === freeExports$1;
1023
-
1024
- /** Detect free variable `process` from Node.js. */
1025
- var freeProcess = moduleExports$1 && freeGlobal.process;
1026
-
1027
- /** Used to access faster Node.js helpers. */
1028
- var nodeUtil = (function() {
1029
- try {
1030
- // Use `util.types` for Node.js 10+.
1031
- var types = freeModule$1 && freeModule$1.require && freeModule$1.require('util').types;
1032
-
1033
- if (types) {
1034
- return types;
1035
- }
1036
-
1037
- // Legacy `process.binding('util')` for Node.js < 10.
1038
- return freeProcess && freeProcess.binding && freeProcess.binding('util');
1039
- } catch (e) {}
1040
- }());
1041
-
1042
- /* Node.js helper references. */
1043
- var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
1044
-
1045
- /**
1046
- * Checks if `value` is classified as a typed array.
1047
- *
1048
- * @static
1049
- * @memberOf _
1050
- * @since 3.0.0
1051
- * @category Lang
1052
- * @param {*} value The value to check.
1053
- * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1054
- * @example
1055
- *
1056
- * _.isTypedArray(new Uint8Array);
1057
- * // => true
1058
- *
1059
- * _.isTypedArray([]);
1060
- * // => false
1061
- */
1062
- var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1063
-
1064
- /** Used for built-in method references. */
1065
- var objectProto$4 = Object.prototype;
1066
-
1067
- /** Used to check objects for own properties. */
1068
- var hasOwnProperty$4 = objectProto$4.hasOwnProperty;
601
+ // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
602
+ // Values outside of this range will be wrapped into this range.
603
+ function _spin(color, amount) {
604
+ var hsl = tinycolor(color).toHsl();
605
+ var hue = (hsl.h + amount) % 360;
606
+ hsl.h = hue < 0 ? 360 + hue : hue;
607
+ return tinycolor(hsl);
608
+ }
1069
609
 
1070
- /**
1071
- * Creates an array of the enumerable property names of the array-like `value`.
1072
- *
1073
- * @private
1074
- * @param {*} value The value to query.
1075
- * @param {boolean} inherited Specify returning inherited property names.
1076
- * @returns {Array} Returns the array of property names.
1077
- */
1078
- function arrayLikeKeys(value, inherited) {
1079
- var isArr = isArray(value),
1080
- isArg = !isArr && isArguments(value),
1081
- isBuff = !isArr && !isArg && isBuffer(value),
1082
- isType = !isArr && !isArg && !isBuff && isTypedArray(value),
1083
- skipIndexes = isArr || isArg || isBuff || isType,
1084
- result = skipIndexes ? baseTimes(value.length, String) : [],
1085
- length = result.length;
610
+ // Combination Functions
611
+ // ---------------------
612
+ // Thanks to jQuery xColor for some of the ideas behind these
613
+ // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
1086
614
 
1087
- for (var key in value) {
1088
- if ((inherited || hasOwnProperty$4.call(value, key)) &&
1089
- !(skipIndexes && (
1090
- // Safari 9 has enumerable `arguments.length` in strict mode.
1091
- key == 'length' ||
1092
- // Node.js 0.10 has enumerable non-index properties on buffers.
1093
- (isBuff && (key == 'offset' || key == 'parent')) ||
1094
- // PhantomJS 2 has enumerable non-index properties on typed arrays.
1095
- (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
1096
- // Skip index properties.
1097
- isIndex(key, length)
1098
- ))) {
1099
- result.push(key);
1100
- }
615
+ function _complement(color) {
616
+ var hsl = tinycolor(color).toHsl();
617
+ hsl.h = (hsl.h + 180) % 360;
618
+ return tinycolor(hsl);
619
+ }
620
+ function polyad(color, number) {
621
+ if (isNaN(number) || number <= 0) {
622
+ throw new Error("Argument to polyad must be a positive number");
623
+ }
624
+ var hsl = tinycolor(color).toHsl();
625
+ var result = [tinycolor(color)];
626
+ var step = 360 / number;
627
+ for (var i = 1; i < number; i++) {
628
+ result.push(tinycolor({
629
+ h: (hsl.h + i * step) % 360,
630
+ s: hsl.s,
631
+ l: hsl.l
632
+ }));
1101
633
  }
1102
634
  return result;
1103
635
  }
1104
-
1105
- /**
1106
- * Creates a unary function that invokes `func` with its argument transformed.
1107
- *
1108
- * @private
1109
- * @param {Function} func The function to wrap.
1110
- * @param {Function} transform The argument transform.
1111
- * @returns {Function} Returns the new function.
1112
- */
1113
- function overArg(func, transform) {
1114
- return function(arg) {
1115
- return func(transform(arg));
1116
- };
636
+ function _splitcomplement(color) {
637
+ var hsl = tinycolor(color).toHsl();
638
+ var h = hsl.h;
639
+ return [tinycolor(color), tinycolor({
640
+ h: (h + 72) % 360,
641
+ s: hsl.s,
642
+ l: hsl.l
643
+ }), tinycolor({
644
+ h: (h + 216) % 360,
645
+ s: hsl.s,
646
+ l: hsl.l
647
+ })];
1117
648
  }
1118
-
1119
- /**
1120
- * This function is like
1121
- * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1122
- * except that it includes inherited enumerable properties.
1123
- *
1124
- * @private
1125
- * @param {Object} object The object to query.
1126
- * @returns {Array} Returns the array of property names.
1127
- */
1128
- function nativeKeysIn(object) {
1129
- var result = [];
1130
- if (object != null) {
1131
- for (var key in Object(object)) {
1132
- result.push(key);
1133
- }
649
+ function _analogous(color, results, slices) {
650
+ results = results || 6;
651
+ slices = slices || 30;
652
+ var hsl = tinycolor(color).toHsl();
653
+ var part = 360 / slices;
654
+ var ret = [tinycolor(color)];
655
+ for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) {
656
+ hsl.h = (hsl.h + part) % 360;
657
+ ret.push(tinycolor(hsl));
1134
658
  }
1135
- return result;
659
+ return ret;
660
+ }
661
+ function _monochromatic(color, results) {
662
+ results = results || 6;
663
+ var hsv = tinycolor(color).toHsv();
664
+ var h = hsv.h,
665
+ s = hsv.s,
666
+ v = hsv.v;
667
+ var ret = [];
668
+ var modification = 1 / results;
669
+ while (results--) {
670
+ ret.push(tinycolor({
671
+ h: h,
672
+ s: s,
673
+ v: v
674
+ }));
675
+ v = (v + modification) % 1;
676
+ }
677
+ return ret;
1136
678
  }
1137
679
 
1138
- /** Used for built-in method references. */
1139
- var objectProto$3 = Object.prototype;
680
+ // Utility Functions
681
+ // ---------------------
1140
682
 
1141
- /** Used to check objects for own properties. */
1142
- var hasOwnProperty$3 = objectProto$3.hasOwnProperty;
683
+ tinycolor.mix = function (color1, color2, amount) {
684
+ amount = amount === 0 ? 0 : amount || 50;
685
+ var rgb1 = tinycolor(color1).toRgb();
686
+ var rgb2 = tinycolor(color2).toRgb();
687
+ var p = amount / 100;
688
+ var rgba = {
689
+ r: (rgb2.r - rgb1.r) * p + rgb1.r,
690
+ g: (rgb2.g - rgb1.g) * p + rgb1.g,
691
+ b: (rgb2.b - rgb1.b) * p + rgb1.b,
692
+ a: (rgb2.a - rgb1.a) * p + rgb1.a
693
+ };
694
+ return tinycolor(rgba);
695
+ };
1143
696
 
1144
- /**
1145
- * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
1146
- *
1147
- * @private
1148
- * @param {Object} object The object to query.
1149
- * @returns {Array} Returns the array of property names.
1150
- */
1151
- function baseKeysIn(object) {
1152
- if (!isObject(object)) {
1153
- return nativeKeysIn(object);
1154
- }
1155
- var isProto = isPrototype(object),
1156
- result = [];
697
+ // Readability Functions
698
+ // ---------------------
699
+ // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
1157
700
 
1158
- for (var key in object) {
1159
- if (!(key == 'constructor' && (isProto || !hasOwnProperty$3.call(object, key)))) {
1160
- result.push(key);
1161
- }
1162
- }
1163
- return result;
1164
- }
701
+ // `contrast`
702
+ // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
703
+ tinycolor.readability = function (color1, color2) {
704
+ var c1 = tinycolor(color1);
705
+ var c2 = tinycolor(color2);
706
+ return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
707
+ };
1165
708
 
1166
- /**
1167
- * Creates an array of the own and inherited enumerable property names of `object`.
1168
- *
1169
- * **Note:** Non-object values are coerced to objects.
1170
- *
1171
- * @static
1172
- * @memberOf _
1173
- * @since 3.0.0
1174
- * @category Object
1175
- * @param {Object} object The object to query.
1176
- * @returns {Array} Returns the array of property names.
1177
- * @example
1178
- *
1179
- * function Foo() {
1180
- * this.a = 1;
1181
- * this.b = 2;
1182
- * }
1183
- *
1184
- * Foo.prototype.c = 3;
1185
- *
1186
- * _.keysIn(new Foo);
1187
- * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
1188
- */
1189
- function keysIn(object) {
1190
- return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
1191
- }
1192
-
1193
- /* Built-in method references that are verified to be native. */
1194
- var nativeCreate = getNative(Object, 'create');
1195
-
1196
- /**
1197
- * Removes all key-value entries from the hash.
1198
- *
1199
- * @private
1200
- * @name clear
1201
- * @memberOf Hash
1202
- */
1203
- function hashClear() {
1204
- this.__data__ = nativeCreate ? nativeCreate(null) : {};
1205
- this.size = 0;
1206
- }
1207
-
1208
- /**
1209
- * Removes `key` and its value from the hash.
1210
- *
1211
- * @private
1212
- * @name delete
1213
- * @memberOf Hash
1214
- * @param {Object} hash The hash to modify.
1215
- * @param {string} key The key of the value to remove.
1216
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1217
- */
1218
- function hashDelete(key) {
1219
- var result = this.has(key) && delete this.__data__[key];
1220
- this.size -= result ? 1 : 0;
1221
- return result;
1222
- }
1223
-
1224
- /** Used to stand-in for `undefined` hash values. */
1225
- var HASH_UNDEFINED$1 = '__lodash_hash_undefined__';
1226
-
1227
- /** Used for built-in method references. */
1228
- var objectProto$2 = Object.prototype;
1229
-
1230
- /** Used to check objects for own properties. */
1231
- var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
1232
-
1233
- /**
1234
- * Gets the hash value for `key`.
1235
- *
1236
- * @private
1237
- * @name get
1238
- * @memberOf Hash
1239
- * @param {string} key The key of the value to get.
1240
- * @returns {*} Returns the entry value.
1241
- */
1242
- function hashGet(key) {
1243
- var data = this.__data__;
1244
- if (nativeCreate) {
1245
- var result = data[key];
1246
- return result === HASH_UNDEFINED$1 ? undefined : result;
1247
- }
1248
- return hasOwnProperty$2.call(data, key) ? data[key] : undefined;
1249
- }
1250
-
1251
- /** Used for built-in method references. */
1252
- var objectProto$1 = Object.prototype;
1253
-
1254
- /** Used to check objects for own properties. */
1255
- var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
1256
-
1257
- /**
1258
- * Checks if a hash value for `key` exists.
1259
- *
1260
- * @private
1261
- * @name has
1262
- * @memberOf Hash
1263
- * @param {string} key The key of the entry to check.
1264
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1265
- */
1266
- function hashHas(key) {
1267
- var data = this.__data__;
1268
- return nativeCreate ? (data[key] !== undefined) : hasOwnProperty$1.call(data, key);
1269
- }
1270
-
1271
- /** Used to stand-in for `undefined` hash values. */
1272
- var HASH_UNDEFINED = '__lodash_hash_undefined__';
1273
-
1274
- /**
1275
- * Sets the hash `key` to `value`.
1276
- *
1277
- * @private
1278
- * @name set
1279
- * @memberOf Hash
1280
- * @param {string} key The key of the value to set.
1281
- * @param {*} value The value to set.
1282
- * @returns {Object} Returns the hash instance.
1283
- */
1284
- function hashSet(key, value) {
1285
- var data = this.__data__;
1286
- this.size += this.has(key) ? 0 : 1;
1287
- data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
1288
- return this;
1289
- }
1290
-
1291
- /**
1292
- * Creates a hash object.
1293
- *
1294
- * @private
1295
- * @constructor
1296
- * @param {Array} [entries] The key-value pairs to cache.
1297
- */
1298
- function Hash(entries) {
1299
- var index = -1,
1300
- length = entries == null ? 0 : entries.length;
1301
-
1302
- this.clear();
1303
- while (++index < length) {
1304
- var entry = entries[index];
1305
- this.set(entry[0], entry[1]);
1306
- }
1307
- }
1308
-
1309
- // Add methods to `Hash`.
1310
- Hash.prototype.clear = hashClear;
1311
- Hash.prototype['delete'] = hashDelete;
1312
- Hash.prototype.get = hashGet;
1313
- Hash.prototype.has = hashHas;
1314
- Hash.prototype.set = hashSet;
1315
-
1316
- /**
1317
- * Removes all key-value entries from the list cache.
1318
- *
1319
- * @private
1320
- * @name clear
1321
- * @memberOf ListCache
1322
- */
1323
- function listCacheClear() {
1324
- this.__data__ = [];
1325
- this.size = 0;
1326
- }
1327
-
1328
- /**
1329
- * Gets the index at which the `key` is found in `array` of key-value pairs.
1330
- *
1331
- * @private
1332
- * @param {Array} array The array to inspect.
1333
- * @param {*} key The key to search for.
1334
- * @returns {number} Returns the index of the matched value, else `-1`.
1335
- */
1336
- function assocIndexOf(array, key) {
1337
- var length = array.length;
1338
- while (length--) {
1339
- if (eq(array[length][0], key)) {
1340
- return length;
1341
- }
1342
- }
1343
- return -1;
1344
- }
1345
-
1346
- /** Used for built-in method references. */
1347
- var arrayProto = Array.prototype;
1348
-
1349
- /** Built-in value references. */
1350
- var splice = arrayProto.splice;
1351
-
1352
- /**
1353
- * Removes `key` and its value from the list cache.
1354
- *
1355
- * @private
1356
- * @name delete
1357
- * @memberOf ListCache
1358
- * @param {string} key The key of the value to remove.
1359
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1360
- */
1361
- function listCacheDelete(key) {
1362
- var data = this.__data__,
1363
- index = assocIndexOf(data, key);
1364
-
1365
- if (index < 0) {
1366
- return false;
1367
- }
1368
- var lastIndex = data.length - 1;
1369
- if (index == lastIndex) {
1370
- data.pop();
1371
- } else {
1372
- splice.call(data, index, 1);
1373
- }
1374
- --this.size;
1375
- return true;
1376
- }
1377
-
1378
- /**
1379
- * Gets the list cache value for `key`.
1380
- *
1381
- * @private
1382
- * @name get
1383
- * @memberOf ListCache
1384
- * @param {string} key The key of the value to get.
1385
- * @returns {*} Returns the entry value.
1386
- */
1387
- function listCacheGet(key) {
1388
- var data = this.__data__,
1389
- index = assocIndexOf(data, key);
1390
-
1391
- return index < 0 ? undefined : data[index][1];
1392
- }
1393
-
1394
- /**
1395
- * Checks if a list cache value for `key` exists.
1396
- *
1397
- * @private
1398
- * @name has
1399
- * @memberOf ListCache
1400
- * @param {string} key The key of the entry to check.
1401
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1402
- */
1403
- function listCacheHas(key) {
1404
- return assocIndexOf(this.__data__, key) > -1;
1405
- }
1406
-
1407
- /**
1408
- * Sets the list cache `key` to `value`.
1409
- *
1410
- * @private
1411
- * @name set
1412
- * @memberOf ListCache
1413
- * @param {string} key The key of the value to set.
1414
- * @param {*} value The value to set.
1415
- * @returns {Object} Returns the list cache instance.
1416
- */
1417
- function listCacheSet(key, value) {
1418
- var data = this.__data__,
1419
- index = assocIndexOf(data, key);
1420
-
1421
- if (index < 0) {
1422
- ++this.size;
1423
- data.push([key, value]);
1424
- } else {
1425
- data[index][1] = value;
1426
- }
1427
- return this;
1428
- }
1429
-
1430
- /**
1431
- * Creates an list cache object.
1432
- *
1433
- * @private
1434
- * @constructor
1435
- * @param {Array} [entries] The key-value pairs to cache.
1436
- */
1437
- function ListCache(entries) {
1438
- var index = -1,
1439
- length = entries == null ? 0 : entries.length;
1440
-
1441
- this.clear();
1442
- while (++index < length) {
1443
- var entry = entries[index];
1444
- this.set(entry[0], entry[1]);
1445
- }
1446
- }
1447
-
1448
- // Add methods to `ListCache`.
1449
- ListCache.prototype.clear = listCacheClear;
1450
- ListCache.prototype['delete'] = listCacheDelete;
1451
- ListCache.prototype.get = listCacheGet;
1452
- ListCache.prototype.has = listCacheHas;
1453
- ListCache.prototype.set = listCacheSet;
1454
-
1455
- /* Built-in method references that are verified to be native. */
1456
- var Map$1 = getNative(root, 'Map');
1457
-
1458
- /**
1459
- * Removes all key-value entries from the map.
1460
- *
1461
- * @private
1462
- * @name clear
1463
- * @memberOf MapCache
1464
- */
1465
- function mapCacheClear() {
1466
- this.size = 0;
1467
- this.__data__ = {
1468
- 'hash': new Hash,
1469
- 'map': new (Map$1 || ListCache),
1470
- 'string': new Hash
1471
- };
1472
- }
1473
-
1474
- /**
1475
- * Checks if `value` is suitable for use as unique object key.
1476
- *
1477
- * @private
1478
- * @param {*} value The value to check.
1479
- * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1480
- */
1481
- function isKeyable(value) {
1482
- var type = typeof value;
1483
- return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1484
- ? (value !== '__proto__')
1485
- : (value === null);
1486
- }
1487
-
1488
- /**
1489
- * Gets the data for `map`.
1490
- *
1491
- * @private
1492
- * @param {Object} map The map to query.
1493
- * @param {string} key The reference key.
1494
- * @returns {*} Returns the map data.
1495
- */
1496
- function getMapData(map, key) {
1497
- var data = map.__data__;
1498
- return isKeyable(key)
1499
- ? data[typeof key == 'string' ? 'string' : 'hash']
1500
- : data.map;
1501
- }
1502
-
1503
- /**
1504
- * Removes `key` and its value from the map.
1505
- *
1506
- * @private
1507
- * @name delete
1508
- * @memberOf MapCache
1509
- * @param {string} key The key of the value to remove.
1510
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1511
- */
1512
- function mapCacheDelete(key) {
1513
- var result = getMapData(this, key)['delete'](key);
1514
- this.size -= result ? 1 : 0;
1515
- return result;
1516
- }
1517
-
1518
- /**
1519
- * Gets the map value for `key`.
1520
- *
1521
- * @private
1522
- * @name get
1523
- * @memberOf MapCache
1524
- * @param {string} key The key of the value to get.
1525
- * @returns {*} Returns the entry value.
1526
- */
1527
- function mapCacheGet(key) {
1528
- return getMapData(this, key).get(key);
1529
- }
1530
-
1531
- /**
1532
- * Checks if a map value for `key` exists.
1533
- *
1534
- * @private
1535
- * @name has
1536
- * @memberOf MapCache
1537
- * @param {string} key The key of the entry to check.
1538
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1539
- */
1540
- function mapCacheHas(key) {
1541
- return getMapData(this, key).has(key);
1542
- }
1543
-
1544
- /**
1545
- * Sets the map `key` to `value`.
1546
- *
1547
- * @private
1548
- * @name set
1549
- * @memberOf MapCache
1550
- * @param {string} key The key of the value to set.
1551
- * @param {*} value The value to set.
1552
- * @returns {Object} Returns the map cache instance.
1553
- */
1554
- function mapCacheSet(key, value) {
1555
- var data = getMapData(this, key),
1556
- size = data.size;
1557
-
1558
- data.set(key, value);
1559
- this.size += data.size == size ? 0 : 1;
1560
- return this;
1561
- }
1562
-
1563
- /**
1564
- * Creates a map cache object to store key-value pairs.
1565
- *
1566
- * @private
1567
- * @constructor
1568
- * @param {Array} [entries] The key-value pairs to cache.
1569
- */
1570
- function MapCache(entries) {
1571
- var index = -1,
1572
- length = entries == null ? 0 : entries.length;
1573
-
1574
- this.clear();
1575
- while (++index < length) {
1576
- var entry = entries[index];
1577
- this.set(entry[0], entry[1]);
1578
- }
1579
- }
1580
-
1581
- // Add methods to `MapCache`.
1582
- MapCache.prototype.clear = mapCacheClear;
1583
- MapCache.prototype['delete'] = mapCacheDelete;
1584
- MapCache.prototype.get = mapCacheGet;
1585
- MapCache.prototype.has = mapCacheHas;
1586
- MapCache.prototype.set = mapCacheSet;
1587
-
1588
- /** Built-in value references. */
1589
- var getPrototype = overArg(Object.getPrototypeOf, Object);
1590
-
1591
- /** `Object#toString` result references. */
1592
- var objectTag = '[object Object]';
1593
-
1594
- /** Used for built-in method references. */
1595
- var funcProto = Function.prototype,
1596
- objectProto = Object.prototype;
1597
-
1598
- /** Used to resolve the decompiled source of functions. */
1599
- var funcToString = funcProto.toString;
1600
-
1601
- /** Used to check objects for own properties. */
1602
- var hasOwnProperty = objectProto.hasOwnProperty;
1603
-
1604
- /** Used to infer the `Object` constructor. */
1605
- var objectCtorString = funcToString.call(Object);
1606
-
1607
- /**
1608
- * Checks if `value` is a plain object, that is, an object created by the
1609
- * `Object` constructor or one with a `[[Prototype]]` of `null`.
1610
- *
1611
- * @static
1612
- * @memberOf _
1613
- * @since 0.8.0
1614
- * @category Lang
1615
- * @param {*} value The value to check.
1616
- * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
1617
- * @example
1618
- *
1619
- * function Foo() {
1620
- * this.a = 1;
1621
- * }
1622
- *
1623
- * _.isPlainObject(new Foo);
1624
- * // => false
1625
- *
1626
- * _.isPlainObject([1, 2, 3]);
1627
- * // => false
1628
- *
1629
- * _.isPlainObject({ 'x': 0, 'y': 0 });
1630
- * // => true
1631
- *
1632
- * _.isPlainObject(Object.create(null));
1633
- * // => true
1634
- */
1635
- function isPlainObject(value) {
1636
- if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
1637
- return false;
1638
- }
1639
- var proto = getPrototype(value);
1640
- if (proto === null) {
1641
- return true;
1642
- }
1643
- var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
1644
- return typeof Ctor == 'function' && Ctor instanceof Ctor &&
1645
- funcToString.call(Ctor) == objectCtorString;
1646
- }
1647
-
1648
- /**
1649
- * Removes all key-value entries from the stack.
1650
- *
1651
- * @private
1652
- * @name clear
1653
- * @memberOf Stack
1654
- */
1655
- function stackClear() {
1656
- this.__data__ = new ListCache;
1657
- this.size = 0;
1658
- }
1659
-
1660
- /**
1661
- * Removes `key` and its value from the stack.
1662
- *
1663
- * @private
1664
- * @name delete
1665
- * @memberOf Stack
1666
- * @param {string} key The key of the value to remove.
1667
- * @returns {boolean} Returns `true` if the entry was removed, else `false`.
1668
- */
1669
- function stackDelete(key) {
1670
- var data = this.__data__,
1671
- result = data['delete'](key);
1672
-
1673
- this.size = data.size;
1674
- return result;
1675
- }
1676
-
1677
- /**
1678
- * Gets the stack value for `key`.
1679
- *
1680
- * @private
1681
- * @name get
1682
- * @memberOf Stack
1683
- * @param {string} key The key of the value to get.
1684
- * @returns {*} Returns the entry value.
1685
- */
1686
- function stackGet(key) {
1687
- return this.__data__.get(key);
1688
- }
1689
-
1690
- /**
1691
- * Checks if a stack value for `key` exists.
1692
- *
1693
- * @private
1694
- * @name has
1695
- * @memberOf Stack
1696
- * @param {string} key The key of the entry to check.
1697
- * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
1698
- */
1699
- function stackHas(key) {
1700
- return this.__data__.has(key);
1701
- }
1702
-
1703
- /** Used as the size to enable large array optimizations. */
1704
- var LARGE_ARRAY_SIZE = 200;
1705
-
1706
- /**
1707
- * Sets the stack `key` to `value`.
1708
- *
1709
- * @private
1710
- * @name set
1711
- * @memberOf Stack
1712
- * @param {string} key The key of the value to set.
1713
- * @param {*} value The value to set.
1714
- * @returns {Object} Returns the stack cache instance.
1715
- */
1716
- function stackSet(key, value) {
1717
- var data = this.__data__;
1718
- if (data instanceof ListCache) {
1719
- var pairs = data.__data__;
1720
- if (!Map$1 || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
1721
- pairs.push([key, value]);
1722
- this.size = ++data.size;
1723
- return this;
1724
- }
1725
- data = this.__data__ = new MapCache(pairs);
1726
- }
1727
- data.set(key, value);
1728
- this.size = data.size;
1729
- return this;
1730
- }
1731
-
1732
- /**
1733
- * Creates a stack cache object to store key-value pairs.
1734
- *
1735
- * @private
1736
- * @constructor
1737
- * @param {Array} [entries] The key-value pairs to cache.
1738
- */
1739
- function Stack(entries) {
1740
- var data = this.__data__ = new ListCache(entries);
1741
- this.size = data.size;
1742
- }
1743
-
1744
- // Add methods to `Stack`.
1745
- Stack.prototype.clear = stackClear;
1746
- Stack.prototype['delete'] = stackDelete;
1747
- Stack.prototype.get = stackGet;
1748
- Stack.prototype.has = stackHas;
1749
- Stack.prototype.set = stackSet;
1750
-
1751
- /** Detect free variable `exports`. */
1752
- var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
1753
-
1754
- /** Detect free variable `module`. */
1755
- var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
1756
-
1757
- /** Detect the popular CommonJS extension `module.exports`. */
1758
- var moduleExports = freeModule && freeModule.exports === freeExports;
1759
-
1760
- /** Built-in value references. */
1761
- var Buffer = moduleExports ? root.Buffer : undefined,
1762
- allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
1763
-
1764
- /**
1765
- * Creates a clone of `buffer`.
1766
- *
1767
- * @private
1768
- * @param {Buffer} buffer The buffer to clone.
1769
- * @param {boolean} [isDeep] Specify a deep clone.
1770
- * @returns {Buffer} Returns the cloned buffer.
1771
- */
1772
- function cloneBuffer(buffer, isDeep) {
1773
- if (isDeep) {
1774
- return buffer.slice();
1775
- }
1776
- var length = buffer.length,
1777
- result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
1778
-
1779
- buffer.copy(result);
1780
- return result;
1781
- }
1782
-
1783
- /** Built-in value references. */
1784
- var Uint8Array = root.Uint8Array;
1785
-
1786
- /**
1787
- * Creates a clone of `arrayBuffer`.
1788
- *
1789
- * @private
1790
- * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
1791
- * @returns {ArrayBuffer} Returns the cloned array buffer.
1792
- */
1793
- function cloneArrayBuffer(arrayBuffer) {
1794
- var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1795
- new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1796
- return result;
1797
- }
1798
-
1799
- /**
1800
- * Creates a clone of `typedArray`.
1801
- *
1802
- * @private
1803
- * @param {Object} typedArray The typed array to clone.
1804
- * @param {boolean} [isDeep] Specify a deep clone.
1805
- * @returns {Object} Returns the cloned typed array.
1806
- */
1807
- function cloneTypedArray(typedArray, isDeep) {
1808
- var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1809
- return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
1810
- }
1811
-
1812
- /**
1813
- * Initializes an object clone.
1814
- *
1815
- * @private
1816
- * @param {Object} object The object to clone.
1817
- * @returns {Object} Returns the initialized clone.
1818
- */
1819
- function initCloneObject(object) {
1820
- return (typeof object.constructor == 'function' && !isPrototype(object))
1821
- ? baseCreate(getPrototype(object))
1822
- : {};
1823
- }
1824
-
1825
- /**
1826
- * Creates a base function for methods like `_.forIn` and `_.forOwn`.
1827
- *
1828
- * @private
1829
- * @param {boolean} [fromRight] Specify iterating from right to left.
1830
- * @returns {Function} Returns the new base function.
1831
- */
1832
- function createBaseFor(fromRight) {
1833
- return function(object, iteratee, keysFunc) {
1834
- var index = -1,
1835
- iterable = Object(object),
1836
- props = keysFunc(object),
1837
- length = props.length;
1838
-
1839
- while (length--) {
1840
- var key = props[++index];
1841
- if (iteratee(iterable[key], key, iterable) === false) {
1842
- break;
1843
- }
1844
- }
1845
- return object;
1846
- };
1847
- }
1848
-
1849
- /**
1850
- * The base implementation of `baseForOwn` which iterates over `object`
1851
- * properties returned by `keysFunc` and invokes `iteratee` for each property.
1852
- * Iteratee functions may exit iteration early by explicitly returning `false`.
1853
- *
1854
- * @private
1855
- * @param {Object} object The object to iterate over.
1856
- * @param {Function} iteratee The function invoked per iteration.
1857
- * @param {Function} keysFunc The function to get the keys of `object`.
1858
- * @returns {Object} Returns `object`.
1859
- */
1860
- var baseFor = createBaseFor();
1861
-
1862
- /**
1863
- * This function is like `assignValue` except that it doesn't assign
1864
- * `undefined` values.
1865
- *
1866
- * @private
1867
- * @param {Object} object The object to modify.
1868
- * @param {string} key The key of the property to assign.
1869
- * @param {*} value The value to assign.
1870
- */
1871
- function assignMergeValue(object, key, value) {
1872
- if ((value !== undefined && !eq(object[key], value)) ||
1873
- (value === undefined && !(key in object))) {
1874
- baseAssignValue(object, key, value);
1875
- }
1876
- }
1877
-
1878
- /**
1879
- * This method is like `_.isArrayLike` except that it also checks if `value`
1880
- * is an object.
1881
- *
1882
- * @static
1883
- * @memberOf _
1884
- * @since 4.0.0
1885
- * @category Lang
1886
- * @param {*} value The value to check.
1887
- * @returns {boolean} Returns `true` if `value` is an array-like object,
1888
- * else `false`.
1889
- * @example
1890
- *
1891
- * _.isArrayLikeObject([1, 2, 3]);
1892
- * // => true
1893
- *
1894
- * _.isArrayLikeObject(document.body.children);
1895
- * // => true
1896
- *
1897
- * _.isArrayLikeObject('abc');
1898
- * // => false
1899
- *
1900
- * _.isArrayLikeObject(_.noop);
1901
- * // => false
1902
- */
1903
- function isArrayLikeObject(value) {
1904
- return isObjectLike(value) && isArrayLike(value);
1905
- }
1906
-
1907
- /**
1908
- * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
1909
- *
1910
- * @private
1911
- * @param {Object} object The object to query.
1912
- * @param {string} key The key of the property to get.
1913
- * @returns {*} Returns the property value.
1914
- */
1915
- function safeGet(object, key) {
1916
- if (key === 'constructor' && typeof object[key] === 'function') {
1917
- return;
1918
- }
1919
-
1920
- if (key == '__proto__') {
1921
- return;
1922
- }
1923
-
1924
- return object[key];
1925
- }
1926
-
1927
- /**
1928
- * Converts `value` to a plain object flattening inherited enumerable string
1929
- * keyed properties of `value` to own properties of the plain object.
1930
- *
1931
- * @static
1932
- * @memberOf _
1933
- * @since 3.0.0
1934
- * @category Lang
1935
- * @param {*} value The value to convert.
1936
- * @returns {Object} Returns the converted plain object.
1937
- * @example
1938
- *
1939
- * function Foo() {
1940
- * this.b = 2;
1941
- * }
1942
- *
1943
- * Foo.prototype.c = 3;
1944
- *
1945
- * _.assign({ 'a': 1 }, new Foo);
1946
- * // => { 'a': 1, 'b': 2 }
1947
- *
1948
- * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
1949
- * // => { 'a': 1, 'b': 2, 'c': 3 }
1950
- */
1951
- function toPlainObject(value) {
1952
- return copyObject(value, keysIn(value));
1953
- }
1954
-
1955
- /**
1956
- * A specialized version of `baseMerge` for arrays and objects which performs
1957
- * deep merges and tracks traversed objects enabling objects with circular
1958
- * references to be merged.
1959
- *
1960
- * @private
1961
- * @param {Object} object The destination object.
1962
- * @param {Object} source The source object.
1963
- * @param {string} key The key of the value to merge.
1964
- * @param {number} srcIndex The index of `source`.
1965
- * @param {Function} mergeFunc The function to merge values.
1966
- * @param {Function} [customizer] The function to customize assigned values.
1967
- * @param {Object} [stack] Tracks traversed source values and their merged
1968
- * counterparts.
1969
- */
1970
- function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
1971
- var objValue = safeGet(object, key),
1972
- srcValue = safeGet(source, key),
1973
- stacked = stack.get(srcValue);
1974
-
1975
- if (stacked) {
1976
- assignMergeValue(object, key, stacked);
1977
- return;
1978
- }
1979
- var newValue = customizer
1980
- ? customizer(objValue, srcValue, (key + ''), object, source, stack)
1981
- : undefined;
1982
-
1983
- var isCommon = newValue === undefined;
1984
-
1985
- if (isCommon) {
1986
- var isArr = isArray(srcValue),
1987
- isBuff = !isArr && isBuffer(srcValue),
1988
- isTyped = !isArr && !isBuff && isTypedArray(srcValue);
1989
-
1990
- newValue = srcValue;
1991
- if (isArr || isBuff || isTyped) {
1992
- if (isArray(objValue)) {
1993
- newValue = objValue;
1994
- }
1995
- else if (isArrayLikeObject(objValue)) {
1996
- newValue = copyArray(objValue);
1997
- }
1998
- else if (isBuff) {
1999
- isCommon = false;
2000
- newValue = cloneBuffer(srcValue, true);
2001
- }
2002
- else if (isTyped) {
2003
- isCommon = false;
2004
- newValue = cloneTypedArray(srcValue, true);
2005
- }
2006
- else {
2007
- newValue = [];
2008
- }
2009
- }
2010
- else if (isPlainObject(srcValue) || isArguments(srcValue)) {
2011
- newValue = objValue;
2012
- if (isArguments(objValue)) {
2013
- newValue = toPlainObject(objValue);
2014
- }
2015
- else if (!isObject(objValue) || isFunction(objValue)) {
2016
- newValue = initCloneObject(srcValue);
2017
- }
2018
- }
2019
- else {
2020
- isCommon = false;
2021
- }
2022
- }
2023
- if (isCommon) {
2024
- // Recursively merge objects and arrays (susceptible to call stack limits).
2025
- stack.set(srcValue, newValue);
2026
- mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
2027
- stack['delete'](srcValue);
2028
- }
2029
- assignMergeValue(object, key, newValue);
2030
- }
2031
-
2032
- /**
2033
- * The base implementation of `_.merge` without support for multiple sources.
2034
- *
2035
- * @private
2036
- * @param {Object} object The destination object.
2037
- * @param {Object} source The source object.
2038
- * @param {number} srcIndex The index of `source`.
2039
- * @param {Function} [customizer] The function to customize merged values.
2040
- * @param {Object} [stack] Tracks traversed source values and their merged
2041
- * counterparts.
2042
- */
2043
- function baseMerge(object, source, srcIndex, customizer, stack) {
2044
- if (object === source) {
2045
- return;
2046
- }
2047
- baseFor(source, function(srcValue, key) {
2048
- stack || (stack = new Stack);
2049
- if (isObject(srcValue)) {
2050
- baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
2051
- }
2052
- else {
2053
- var newValue = customizer
2054
- ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
2055
- : undefined;
2056
-
2057
- if (newValue === undefined) {
2058
- newValue = srcValue;
2059
- }
2060
- assignMergeValue(object, key, newValue);
2061
- }
2062
- }, keysIn);
2063
- }
2064
-
2065
- /**
2066
- * This method is like `_.assign` except that it recursively merges own and
2067
- * inherited enumerable string keyed properties of source objects into the
2068
- * destination object. Source properties that resolve to `undefined` are
2069
- * skipped if a destination value exists. Array and plain object properties
2070
- * are merged recursively. Other objects and value types are overridden by
2071
- * assignment. Source objects are applied from left to right. Subsequent
2072
- * sources overwrite property assignments of previous sources.
2073
- *
2074
- * **Note:** This method mutates `object`.
2075
- *
2076
- * @static
2077
- * @memberOf _
2078
- * @since 0.5.0
2079
- * @category Object
2080
- * @param {Object} object The destination object.
2081
- * @param {...Object} [sources] The source objects.
2082
- * @returns {Object} Returns `object`.
2083
- * @example
2084
- *
2085
- * var object = {
2086
- * 'a': [{ 'b': 2 }, { 'd': 4 }]
2087
- * };
2088
- *
2089
- * var other = {
2090
- * 'a': [{ 'c': 3 }, { 'e': 5 }]
2091
- * };
2092
- *
2093
- * _.merge(object, other);
2094
- * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
2095
- */
2096
- var merge = createAssigner(function(object, source, srcIndex) {
2097
- baseMerge(object, source, srcIndex);
2098
- });
2099
-
2100
- // This file is autogenerated. It's used to publish ESM to npm.
2101
- function _typeof(obj) {
2102
- "@babel/helpers - typeof";
2103
-
2104
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) {
2105
- return typeof obj;
2106
- } : function (obj) {
2107
- return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
2108
- }, _typeof(obj);
2109
- }
2110
-
2111
- // https://github.com/bgrins/TinyColor
2112
- // Brian Grinstead, MIT License
2113
-
2114
- var trimLeft = /^\s+/;
2115
- var trimRight = /\s+$/;
2116
- function tinycolor(color, opts) {
2117
- color = color ? color : "";
2118
- opts = opts || {};
2119
-
2120
- // If input is already a tinycolor, return itself
2121
- if (color instanceof tinycolor) {
2122
- return color;
2123
- }
2124
- // If we are called as a function, call using new instead
2125
- if (!(this instanceof tinycolor)) {
2126
- return new tinycolor(color, opts);
2127
- }
2128
- var rgb = inputToRGB(color);
2129
- this._originalInput = color, this._r = rgb.r, this._g = rgb.g, this._b = rgb.b, this._a = rgb.a, this._roundA = Math.round(100 * this._a) / 100, this._format = opts.format || rgb.format;
2130
- this._gradientType = opts.gradientType;
709
+ // `isReadable`
710
+ // Ensure that foreground and background color combinations meet WCAG2 guidelines.
711
+ // The third argument is an optional Object.
712
+ // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
713
+ // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
714
+ // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
2131
715
 
2132
- // Don't let the range of [0,255] come back in [0,1].
2133
- // Potentially lose a little bit of precision here, but will fix issues where
2134
- // .5 gets interpreted as half of the total, instead of half of 1
2135
- // If it was supposed to be 128, this was already taken care of by `inputToRgb`
2136
- if (this._r < 1) this._r = Math.round(this._r);
2137
- if (this._g < 1) this._g = Math.round(this._g);
2138
- if (this._b < 1) this._b = Math.round(this._b);
2139
- this._ok = rgb.ok;
2140
- }
2141
- tinycolor.prototype = {
2142
- isDark: function isDark() {
2143
- return this.getBrightness() < 128;
2144
- },
2145
- isLight: function isLight() {
2146
- return !this.isDark();
2147
- },
2148
- isValid: function isValid() {
2149
- return this._ok;
2150
- },
2151
- getOriginalInput: function getOriginalInput() {
2152
- return this._originalInput;
2153
- },
2154
- getFormat: function getFormat() {
2155
- return this._format;
2156
- },
2157
- getAlpha: function getAlpha() {
2158
- return this._a;
2159
- },
2160
- getBrightness: function getBrightness() {
2161
- //http://www.w3.org/TR/AERT#color-contrast
2162
- var rgb = this.toRgb();
2163
- return (rgb.r * 299 + rgb.g * 587 + rgb.b * 114) / 1000;
2164
- },
2165
- getLuminance: function getLuminance() {
2166
- //http://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef
2167
- var rgb = this.toRgb();
2168
- var RsRGB, GsRGB, BsRGB, R, G, B;
2169
- RsRGB = rgb.r / 255;
2170
- GsRGB = rgb.g / 255;
2171
- BsRGB = rgb.b / 255;
2172
- if (RsRGB <= 0.03928) R = RsRGB / 12.92;else R = Math.pow((RsRGB + 0.055) / 1.055, 2.4);
2173
- if (GsRGB <= 0.03928) G = GsRGB / 12.92;else G = Math.pow((GsRGB + 0.055) / 1.055, 2.4);
2174
- if (BsRGB <= 0.03928) B = BsRGB / 12.92;else B = Math.pow((BsRGB + 0.055) / 1.055, 2.4);
2175
- return 0.2126 * R + 0.7152 * G + 0.0722 * B;
2176
- },
2177
- setAlpha: function setAlpha(value) {
2178
- this._a = boundAlpha(value);
2179
- this._roundA = Math.round(100 * this._a) / 100;
2180
- return this;
2181
- },
2182
- toHsv: function toHsv() {
2183
- var hsv = rgbToHsv(this._r, this._g, this._b);
2184
- return {
2185
- h: hsv.h * 360,
2186
- s: hsv.s,
2187
- v: hsv.v,
2188
- a: this._a
2189
- };
2190
- },
2191
- toHsvString: function toHsvString() {
2192
- var hsv = rgbToHsv(this._r, this._g, this._b);
2193
- var h = Math.round(hsv.h * 360),
2194
- s = Math.round(hsv.s * 100),
2195
- v = Math.round(hsv.v * 100);
2196
- return this._a == 1 ? "hsv(" + h + ", " + s + "%, " + v + "%)" : "hsva(" + h + ", " + s + "%, " + v + "%, " + this._roundA + ")";
2197
- },
2198
- toHsl: function toHsl() {
2199
- var hsl = rgbToHsl(this._r, this._g, this._b);
2200
- return {
2201
- h: hsl.h * 360,
2202
- s: hsl.s,
2203
- l: hsl.l,
2204
- a: this._a
2205
- };
2206
- },
2207
- toHslString: function toHslString() {
2208
- var hsl = rgbToHsl(this._r, this._g, this._b);
2209
- var h = Math.round(hsl.h * 360),
2210
- s = Math.round(hsl.s * 100),
2211
- l = Math.round(hsl.l * 100);
2212
- return this._a == 1 ? "hsl(" + h + ", " + s + "%, " + l + "%)" : "hsla(" + h + ", " + s + "%, " + l + "%, " + this._roundA + ")";
2213
- },
2214
- toHex: function toHex(allow3Char) {
2215
- return rgbToHex(this._r, this._g, this._b, allow3Char);
2216
- },
2217
- toHexString: function toHexString(allow3Char) {
2218
- return "#" + this.toHex(allow3Char);
2219
- },
2220
- toHex8: function toHex8(allow4Char) {
2221
- return rgbaToHex(this._r, this._g, this._b, this._a, allow4Char);
2222
- },
2223
- toHex8String: function toHex8String(allow4Char) {
2224
- return "#" + this.toHex8(allow4Char);
2225
- },
2226
- toRgb: function toRgb() {
2227
- return {
2228
- r: Math.round(this._r),
2229
- g: Math.round(this._g),
2230
- b: Math.round(this._b),
2231
- a: this._a
2232
- };
2233
- },
2234
- toRgbString: function toRgbString() {
2235
- return this._a == 1 ? "rgb(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ")" : "rgba(" + Math.round(this._r) + ", " + Math.round(this._g) + ", " + Math.round(this._b) + ", " + this._roundA + ")";
2236
- },
2237
- toPercentageRgb: function toPercentageRgb() {
2238
- return {
2239
- r: Math.round(bound01(this._r, 255) * 100) + "%",
2240
- g: Math.round(bound01(this._g, 255) * 100) + "%",
2241
- b: Math.round(bound01(this._b, 255) * 100) + "%",
2242
- a: this._a
2243
- };
2244
- },
2245
- toPercentageRgbString: function toPercentageRgbString() {
2246
- return this._a == 1 ? "rgb(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%)" : "rgba(" + Math.round(bound01(this._r, 255) * 100) + "%, " + Math.round(bound01(this._g, 255) * 100) + "%, " + Math.round(bound01(this._b, 255) * 100) + "%, " + this._roundA + ")";
2247
- },
2248
- toName: function toName() {
2249
- if (this._a === 0) {
2250
- return "transparent";
2251
- }
2252
- if (this._a < 1) {
2253
- return false;
2254
- }
2255
- return hexNames[rgbToHex(this._r, this._g, this._b, true)] || false;
2256
- },
2257
- toFilter: function toFilter(secondColor) {
2258
- var hex8String = "#" + rgbaToArgbHex(this._r, this._g, this._b, this._a);
2259
- var secondHex8String = hex8String;
2260
- var gradientType = this._gradientType ? "GradientType = 1, " : "";
2261
- if (secondColor) {
2262
- var s = tinycolor(secondColor);
2263
- secondHex8String = "#" + rgbaToArgbHex(s._r, s._g, s._b, s._a);
2264
- }
2265
- return "progid:DXImageTransform.Microsoft.gradient(" + gradientType + "startColorstr=" + hex8String + ",endColorstr=" + secondHex8String + ")";
2266
- },
2267
- toString: function toString(format) {
2268
- var formatSet = !!format;
2269
- format = format || this._format;
2270
- var formattedString = false;
2271
- var hasAlpha = this._a < 1 && this._a >= 0;
2272
- var needsAlphaFormat = !formatSet && hasAlpha && (format === "hex" || format === "hex6" || format === "hex3" || format === "hex4" || format === "hex8" || format === "name");
2273
- if (needsAlphaFormat) {
2274
- // Special case for "transparent", all other non-alpha formats
2275
- // will return rgba when there is transparency.
2276
- if (format === "name" && this._a === 0) {
2277
- return this.toName();
2278
- }
2279
- return this.toRgbString();
2280
- }
2281
- if (format === "rgb") {
2282
- formattedString = this.toRgbString();
2283
- }
2284
- if (format === "prgb") {
2285
- formattedString = this.toPercentageRgbString();
2286
- }
2287
- if (format === "hex" || format === "hex6") {
2288
- formattedString = this.toHexString();
2289
- }
2290
- if (format === "hex3") {
2291
- formattedString = this.toHexString(true);
2292
- }
2293
- if (format === "hex4") {
2294
- formattedString = this.toHex8String(true);
2295
- }
2296
- if (format === "hex8") {
2297
- formattedString = this.toHex8String();
2298
- }
2299
- if (format === "name") {
2300
- formattedString = this.toName();
2301
- }
2302
- if (format === "hsl") {
2303
- formattedString = this.toHslString();
2304
- }
2305
- if (format === "hsv") {
2306
- formattedString = this.toHsvString();
2307
- }
2308
- return formattedString || this.toHexString();
2309
- },
2310
- clone: function clone() {
2311
- return tinycolor(this.toString());
2312
- },
2313
- _applyModification: function _applyModification(fn, args) {
2314
- var color = fn.apply(null, [this].concat([].slice.call(args)));
2315
- this._r = color._r;
2316
- this._g = color._g;
2317
- this._b = color._b;
2318
- this.setAlpha(color._a);
2319
- return this;
2320
- },
2321
- lighten: function lighten() {
2322
- return this._applyModification(_lighten, arguments);
2323
- },
2324
- brighten: function brighten() {
2325
- return this._applyModification(_brighten, arguments);
2326
- },
2327
- darken: function darken() {
2328
- return this._applyModification(_darken, arguments);
2329
- },
2330
- desaturate: function desaturate() {
2331
- return this._applyModification(_desaturate, arguments);
2332
- },
2333
- saturate: function saturate() {
2334
- return this._applyModification(_saturate, arguments);
2335
- },
2336
- greyscale: function greyscale() {
2337
- return this._applyModification(_greyscale, arguments);
2338
- },
2339
- spin: function spin() {
2340
- return this._applyModification(_spin, arguments);
2341
- },
2342
- _applyCombination: function _applyCombination(fn, args) {
2343
- return fn.apply(null, [this].concat([].slice.call(args)));
2344
- },
2345
- analogous: function analogous() {
2346
- return this._applyCombination(_analogous, arguments);
2347
- },
2348
- complement: function complement() {
2349
- return this._applyCombination(_complement, arguments);
2350
- },
2351
- monochromatic: function monochromatic() {
2352
- return this._applyCombination(_monochromatic, arguments);
2353
- },
2354
- splitcomplement: function splitcomplement() {
2355
- return this._applyCombination(_splitcomplement, arguments);
2356
- },
2357
- // Disabled until https://github.com/bgrins/TinyColor/issues/254
2358
- // polyad: function (number) {
2359
- // return this._applyCombination(polyad, [number]);
2360
- // },
2361
- triad: function triad() {
2362
- return this._applyCombination(polyad, [3]);
2363
- },
2364
- tetrad: function tetrad() {
2365
- return this._applyCombination(polyad, [4]);
716
+ // *Example*
717
+ // tinycolor.isReadable("#000", "#111") => false
718
+ // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
719
+ tinycolor.isReadable = function (color1, color2, wcag2) {
720
+ var readability = tinycolor.readability(color1, color2);
721
+ var wcag2Parms, out;
722
+ out = false;
723
+ wcag2Parms = validateWCAG2Parms(wcag2);
724
+ switch (wcag2Parms.level + wcag2Parms.size) {
725
+ case "AAsmall":
726
+ case "AAAlarge":
727
+ out = readability >= 4.5;
728
+ break;
729
+ case "AAlarge":
730
+ out = readability >= 3;
731
+ break;
732
+ case "AAAsmall":
733
+ out = readability >= 7;
734
+ break;
2366
735
  }
736
+ return out;
2367
737
  };
2368
738
 
2369
- // If input is an object, force 1 into "1.0" to handle ratios properly
2370
- // String input requires "1.0" as input, so 1 will be treated as 1
2371
- tinycolor.fromRatio = function (color, opts) {
2372
- if (_typeof(color) == "object") {
2373
- var newColor = {};
2374
- for (var i in color) {
2375
- if (color.hasOwnProperty(i)) {
2376
- if (i === "a") {
2377
- newColor[i] = color[i];
2378
- } else {
2379
- newColor[i] = convertToPercentage(color[i]);
2380
- }
2381
- }
739
+ // `mostReadable`
740
+ // Given a base color and a list of possible foreground or background
741
+ // colors for that base, returns the most readable color.
742
+ // Optionally returns Black or White if the most readable color is unreadable.
743
+ // *Example*
744
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
745
+ // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
746
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
747
+ // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
748
+ tinycolor.mostReadable = function (baseColor, colorList, args) {
749
+ var bestColor = null;
750
+ var bestScore = 0;
751
+ var readability;
752
+ var includeFallbackColors, level, size;
753
+ args = args || {};
754
+ includeFallbackColors = args.includeFallbackColors;
755
+ level = args.level;
756
+ size = args.size;
757
+ for (var i = 0; i < colorList.length; i++) {
758
+ readability = tinycolor.readability(baseColor, colorList[i]);
759
+ if (readability > bestScore) {
760
+ bestScore = readability;
761
+ bestColor = tinycolor(colorList[i]);
2382
762
  }
2383
- color = newColor;
2384
763
  }
2385
- return tinycolor(color, opts);
764
+ if (tinycolor.isReadable(baseColor, bestColor, {
765
+ level: level,
766
+ size: size
767
+ }) || !includeFallbackColors) {
768
+ return bestColor;
769
+ } else {
770
+ args.includeFallbackColors = false;
771
+ return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
772
+ }
2386
773
  };
2387
774
 
2388
- // Given a string or object, convert that input to RGB
2389
- // Possible string inputs:
2390
- //
2391
- // "red"
2392
- // "#f00" or "f00"
2393
- // "#ff0000" or "ff0000"
2394
- // "#ff000000" or "ff000000"
2395
- // "rgb 255 0 0" or "rgb (255, 0, 0)"
2396
- // "rgb 1.0 0 0" or "rgb (1, 0, 0)"
2397
- // "rgba (255, 0, 0, 1)" or "rgba 255, 0, 0, 1"
2398
- // "rgba (1.0, 0, 0, 1)" or "rgba 1.0, 0, 0, 1"
2399
- // "hsl(0, 100%, 50%)" or "hsl 0 100% 50%"
2400
- // "hsla(0, 100%, 50%, 1)" or "hsla 0 100% 50%, 1"
2401
- // "hsv(0, 100%, 100%)" or "hsv 0 100% 100%"
2402
- //
2403
- function inputToRGB(color) {
2404
- var rgb = {
2405
- r: 0,
2406
- g: 0,
2407
- b: 0
2408
- };
2409
- var a = 1;
2410
- var s = null;
2411
- var v = null;
2412
- var l = null;
2413
- var ok = false;
2414
- var format = false;
2415
- if (typeof color == "string") {
2416
- color = stringInputToObject(color);
2417
- }
2418
- if (_typeof(color) == "object") {
2419
- if (isValidCSSUnit(color.r) && isValidCSSUnit(color.g) && isValidCSSUnit(color.b)) {
2420
- rgb = rgbToRgb(color.r, color.g, color.b);
2421
- ok = true;
2422
- format = String(color.r).substr(-1) === "%" ? "prgb" : "rgb";
2423
- } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.v)) {
2424
- s = convertToPercentage(color.s);
2425
- v = convertToPercentage(color.v);
2426
- rgb = hsvToRgb(color.h, s, v);
2427
- ok = true;
2428
- format = "hsv";
2429
- } else if (isValidCSSUnit(color.h) && isValidCSSUnit(color.s) && isValidCSSUnit(color.l)) {
2430
- s = convertToPercentage(color.s);
2431
- l = convertToPercentage(color.l);
2432
- rgb = hslToRgb(color.h, s, l);
2433
- ok = true;
2434
- format = "hsl";
2435
- }
2436
- if (color.hasOwnProperty("a")) {
2437
- a = color.a;
2438
- }
2439
- }
2440
- a = boundAlpha(a);
2441
- return {
2442
- ok: ok,
2443
- format: color.format || format,
2444
- r: Math.min(255, Math.max(rgb.r, 0)),
2445
- g: Math.min(255, Math.max(rgb.g, 0)),
2446
- b: Math.min(255, Math.max(rgb.b, 0)),
2447
- a: a
2448
- };
2449
- }
775
+ // Big List of Colors
776
+ // ------------------
777
+ // <https://www.w3.org/TR/css-color-4/#named-colors>
778
+ var names = tinycolor.names = {
779
+ aliceblue: "f0f8ff",
780
+ antiquewhite: "faebd7",
781
+ aqua: "0ff",
782
+ aquamarine: "7fffd4",
783
+ azure: "f0ffff",
784
+ beige: "f5f5dc",
785
+ bisque: "ffe4c4",
786
+ black: "000",
787
+ blanchedalmond: "ffebcd",
788
+ blue: "00f",
789
+ blueviolet: "8a2be2",
790
+ brown: "a52a2a",
791
+ burlywood: "deb887",
792
+ burntsienna: "ea7e5d",
793
+ cadetblue: "5f9ea0",
794
+ chartreuse: "7fff00",
795
+ chocolate: "d2691e",
796
+ coral: "ff7f50",
797
+ cornflowerblue: "6495ed",
798
+ cornsilk: "fff8dc",
799
+ crimson: "dc143c",
800
+ cyan: "0ff",
801
+ darkblue: "00008b",
802
+ darkcyan: "008b8b",
803
+ darkgoldenrod: "b8860b",
804
+ darkgray: "a9a9a9",
805
+ darkgreen: "006400",
806
+ darkgrey: "a9a9a9",
807
+ darkkhaki: "bdb76b",
808
+ darkmagenta: "8b008b",
809
+ darkolivegreen: "556b2f",
810
+ darkorange: "ff8c00",
811
+ darkorchid: "9932cc",
812
+ darkred: "8b0000",
813
+ darksalmon: "e9967a",
814
+ darkseagreen: "8fbc8f",
815
+ darkslateblue: "483d8b",
816
+ darkslategray: "2f4f4f",
817
+ darkslategrey: "2f4f4f",
818
+ darkturquoise: "00ced1",
819
+ darkviolet: "9400d3",
820
+ deeppink: "ff1493",
821
+ deepskyblue: "00bfff",
822
+ dimgray: "696969",
823
+ dimgrey: "696969",
824
+ dodgerblue: "1e90ff",
825
+ firebrick: "b22222",
826
+ floralwhite: "fffaf0",
827
+ forestgreen: "228b22",
828
+ fuchsia: "f0f",
829
+ gainsboro: "dcdcdc",
830
+ ghostwhite: "f8f8ff",
831
+ gold: "ffd700",
832
+ goldenrod: "daa520",
833
+ gray: "808080",
834
+ green: "008000",
835
+ greenyellow: "adff2f",
836
+ grey: "808080",
837
+ honeydew: "f0fff0",
838
+ hotpink: "ff69b4",
839
+ indianred: "cd5c5c",
840
+ indigo: "4b0082",
841
+ ivory: "fffff0",
842
+ khaki: "f0e68c",
843
+ lavender: "e6e6fa",
844
+ lavenderblush: "fff0f5",
845
+ lawngreen: "7cfc00",
846
+ lemonchiffon: "fffacd",
847
+ lightblue: "add8e6",
848
+ lightcoral: "f08080",
849
+ lightcyan: "e0ffff",
850
+ lightgoldenrodyellow: "fafad2",
851
+ lightgray: "d3d3d3",
852
+ lightgreen: "90ee90",
853
+ lightgrey: "d3d3d3",
854
+ lightpink: "ffb6c1",
855
+ lightsalmon: "ffa07a",
856
+ lightseagreen: "20b2aa",
857
+ lightskyblue: "87cefa",
858
+ lightslategray: "789",
859
+ lightslategrey: "789",
860
+ lightsteelblue: "b0c4de",
861
+ lightyellow: "ffffe0",
862
+ lime: "0f0",
863
+ limegreen: "32cd32",
864
+ linen: "faf0e6",
865
+ magenta: "f0f",
866
+ maroon: "800000",
867
+ mediumaquamarine: "66cdaa",
868
+ mediumblue: "0000cd",
869
+ mediumorchid: "ba55d3",
870
+ mediumpurple: "9370db",
871
+ mediumseagreen: "3cb371",
872
+ mediumslateblue: "7b68ee",
873
+ mediumspringgreen: "00fa9a",
874
+ mediumturquoise: "48d1cc",
875
+ mediumvioletred: "c71585",
876
+ midnightblue: "191970",
877
+ mintcream: "f5fffa",
878
+ mistyrose: "ffe4e1",
879
+ moccasin: "ffe4b5",
880
+ navajowhite: "ffdead",
881
+ navy: "000080",
882
+ oldlace: "fdf5e6",
883
+ olive: "808000",
884
+ olivedrab: "6b8e23",
885
+ orange: "ffa500",
886
+ orangered: "ff4500",
887
+ orchid: "da70d6",
888
+ palegoldenrod: "eee8aa",
889
+ palegreen: "98fb98",
890
+ paleturquoise: "afeeee",
891
+ palevioletred: "db7093",
892
+ papayawhip: "ffefd5",
893
+ peachpuff: "ffdab9",
894
+ peru: "cd853f",
895
+ pink: "ffc0cb",
896
+ plum: "dda0dd",
897
+ powderblue: "b0e0e6",
898
+ purple: "800080",
899
+ rebeccapurple: "663399",
900
+ red: "f00",
901
+ rosybrown: "bc8f8f",
902
+ royalblue: "4169e1",
903
+ saddlebrown: "8b4513",
904
+ salmon: "fa8072",
905
+ sandybrown: "f4a460",
906
+ seagreen: "2e8b57",
907
+ seashell: "fff5ee",
908
+ sienna: "a0522d",
909
+ silver: "c0c0c0",
910
+ skyblue: "87ceeb",
911
+ slateblue: "6a5acd",
912
+ slategray: "708090",
913
+ slategrey: "708090",
914
+ snow: "fffafa",
915
+ springgreen: "00ff7f",
916
+ steelblue: "4682b4",
917
+ tan: "d2b48c",
918
+ teal: "008080",
919
+ thistle: "d8bfd8",
920
+ tomato: "ff6347",
921
+ turquoise: "40e0d0",
922
+ violet: "ee82ee",
923
+ wheat: "f5deb3",
924
+ white: "fff",
925
+ whitesmoke: "f5f5f5",
926
+ yellow: "ff0",
927
+ yellowgreen: "9acd32"
928
+ };
2450
929
 
2451
- // Conversion Functions
2452
- // --------------------
930
+ // Make it easy to access colors via `hexNames[hex]`
931
+ var hexNames = tinycolor.hexNames = flip(names);
2453
932
 
2454
- // `rgbToHsl`, `rgbToHsv`, `hslToRgb`, `hsvToRgb` modified from:
2455
- // <http://mjijackson.com/2008/02/rgb-to-hsl-and-rgb-to-hsv-color-model-conversion-algorithms-in-javascript>
933
+ // Utilities
934
+ // ---------
2456
935
 
2457
- // `rgbToRgb`
2458
- // Handle bounds / percentage checking to conform to CSS color spec
2459
- // <http://www.w3.org/TR/css3-color/>
2460
- // *Assumes:* r, g, b in [0, 255] or [0, 1]
2461
- // *Returns:* { r, g, b } in [0, 255]
2462
- function rgbToRgb(r, g, b) {
2463
- return {
2464
- r: bound01(r, 255) * 255,
2465
- g: bound01(g, 255) * 255,
2466
- b: bound01(b, 255) * 255
2467
- };
936
+ // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
937
+ function flip(o) {
938
+ var flipped = {};
939
+ for (var i in o) {
940
+ if (o.hasOwnProperty(i)) {
941
+ flipped[o[i]] = i;
942
+ }
943
+ }
944
+ return flipped;
2468
945
  }
2469
946
 
2470
- // `rgbToHsl`
2471
- // Converts an RGB color value to HSL.
2472
- // *Assumes:* r, g, and b are contained in [0, 255] or [0, 1]
2473
- // *Returns:* { h, s, l } in [0,1]
2474
- function rgbToHsl(r, g, b) {
2475
- r = bound01(r, 255);
2476
- g = bound01(g, 255);
2477
- b = bound01(b, 255);
2478
- var max = Math.max(r, g, b),
2479
- min = Math.min(r, g, b);
2480
- var h,
2481
- s,
2482
- l = (max + min) / 2;
2483
- if (max == min) {
2484
- h = s = 0; // achromatic
2485
- } else {
2486
- var d = max - min;
2487
- s = l > 0.5 ? d / (2 - max - min) : d / (max + min);
2488
- switch (max) {
2489
- case r:
2490
- h = (g - b) / d + (g < b ? 6 : 0);
2491
- break;
2492
- case g:
2493
- h = (b - r) / d + 2;
2494
- break;
2495
- case b:
2496
- h = (r - g) / d + 4;
2497
- break;
2498
- }
2499
- h /= 6;
947
+ // Return a valid alpha value [0,1] with all invalid values being set to 1
948
+ function boundAlpha(a) {
949
+ a = parseFloat(a);
950
+ if (isNaN(a) || a < 0 || a > 1) {
951
+ a = 1;
2500
952
  }
2501
- return {
2502
- h: h,
2503
- s: s,
2504
- l: l
2505
- };
953
+ return a;
2506
954
  }
2507
955
 
2508
- // `hslToRgb`
2509
- // Converts an HSL color value to RGB.
2510
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and l are contained [0, 1] or [0, 100]
2511
- // *Returns:* { r, g, b } in the set [0, 255]
2512
- function hslToRgb(h, s, l) {
2513
- var r, g, b;
2514
- h = bound01(h, 360);
2515
- s = bound01(s, 100);
2516
- l = bound01(l, 100);
2517
- function hue2rgb(p, q, t) {
2518
- if (t < 0) t += 1;
2519
- if (t > 1) t -= 1;
2520
- if (t < 1 / 6) return p + (q - p) * 6 * t;
2521
- if (t < 1 / 2) return q;
2522
- if (t < 2 / 3) return p + (q - p) * (2 / 3 - t) * 6;
2523
- return p;
956
+ // Take input from [0, n] and return it as [0, 1]
957
+ function bound01(n, max) {
958
+ if (isOnePointZero(n)) n = "100%";
959
+ var processPercent = isPercentage(n);
960
+ n = Math.min(max, Math.max(0, parseFloat(n)));
961
+
962
+ // Automatically convert percentage into number
963
+ if (processPercent) {
964
+ n = parseInt(n * max, 10) / 100;
2524
965
  }
2525
- if (s === 0) {
2526
- r = g = b = l; // achromatic
2527
- } else {
2528
- var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
2529
- var p = 2 * l - q;
2530
- r = hue2rgb(p, q, h + 1 / 3);
2531
- g = hue2rgb(p, q, h);
2532
- b = hue2rgb(p, q, h - 1 / 3);
966
+
967
+ // Handle floating point rounding errors
968
+ if (Math.abs(n - max) < 0.000001) {
969
+ return 1;
2533
970
  }
2534
- return {
2535
- r: r * 255,
2536
- g: g * 255,
2537
- b: b * 255
2538
- };
971
+
972
+ // Convert into [0, 1] range if it isn't already
973
+ return n % max / parseFloat(max);
2539
974
  }
2540
975
 
2541
- // `rgbToHsv`
2542
- // Converts an RGB color value to HSV
2543
- // *Assumes:* r, g, and b are contained in the set [0, 255] or [0, 1]
2544
- // *Returns:* { h, s, v } in [0,1]
2545
- function rgbToHsv(r, g, b) {
2546
- r = bound01(r, 255);
2547
- g = bound01(g, 255);
2548
- b = bound01(b, 255);
2549
- var max = Math.max(r, g, b),
2550
- min = Math.min(r, g, b);
2551
- var h,
2552
- s,
2553
- v = max;
2554
- var d = max - min;
2555
- s = max === 0 ? 0 : d / max;
2556
- if (max == min) {
2557
- h = 0; // achromatic
2558
- } else {
2559
- switch (max) {
2560
- case r:
2561
- h = (g - b) / d + (g < b ? 6 : 0);
2562
- break;
2563
- case g:
2564
- h = (b - r) / d + 2;
2565
- break;
2566
- case b:
2567
- h = (r - g) / d + 4;
2568
- break;
2569
- }
2570
- h /= 6;
976
+ // Force a number between 0 and 1
977
+ function clamp01(val) {
978
+ return Math.min(1, Math.max(0, val));
979
+ }
980
+
981
+ // Parse a base-16 hex value into a base-10 integer
982
+ function parseIntFromHex(val) {
983
+ return parseInt(val, 16);
984
+ }
985
+
986
+ // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
987
+ // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
988
+ function isOnePointZero(n) {
989
+ return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
990
+ }
991
+
992
+ // Check to see if string passed in is a percentage
993
+ function isPercentage(n) {
994
+ return typeof n === "string" && n.indexOf("%") != -1;
995
+ }
996
+
997
+ // Force a hex value to have 2 characters
998
+ function pad2(c) {
999
+ return c.length == 1 ? "0" + c : "" + c;
1000
+ }
1001
+
1002
+ // Replace a decimal with it's percentage value
1003
+ function convertToPercentage(n) {
1004
+ if (n <= 1) {
1005
+ n = n * 100 + "%";
2571
1006
  }
2572
- return {
2573
- h: h,
2574
- s: s,
2575
- v: v
2576
- };
1007
+ return n;
2577
1008
  }
2578
1009
 
2579
- // `hsvToRgb`
2580
- // Converts an HSV color value to RGB.
2581
- // *Assumes:* h is contained in [0, 1] or [0, 360] and s and v are contained in [0, 1] or [0, 100]
2582
- // *Returns:* { r, g, b } in the set [0, 255]
2583
- function hsvToRgb(h, s, v) {
2584
- h = bound01(h, 360) * 6;
2585
- s = bound01(s, 100);
2586
- v = bound01(v, 100);
2587
- var i = Math.floor(h),
2588
- f = h - i,
2589
- p = v * (1 - s),
2590
- q = v * (1 - f * s),
2591
- t = v * (1 - (1 - f) * s),
2592
- mod = i % 6,
2593
- r = [v, q, p, p, t, v][mod],
2594
- g = [t, v, v, q, p, p][mod],
2595
- b = [p, p, t, v, v, q][mod];
1010
+ // Converts a decimal to a hex value
1011
+ function convertDecimalToHex(d) {
1012
+ return Math.round(parseFloat(d) * 255).toString(16);
1013
+ }
1014
+ // Converts a hex value to a decimal
1015
+ function convertHexToDecimal(h) {
1016
+ return parseIntFromHex(h) / 255;
1017
+ }
1018
+ var matchers = function () {
1019
+ // <http://www.w3.org/TR/css3-values/#integers>
1020
+ var CSS_INTEGER = "[-\\+]?\\d+%?";
1021
+
1022
+ // <http://www.w3.org/TR/css3-values/#number-value>
1023
+ var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
1024
+
1025
+ // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
1026
+ var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
1027
+
1028
+ // Actual matching.
1029
+ // Parentheses and commas are optional, but not required.
1030
+ // Whitespace can take the place of commas or opening paren
1031
+ var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
1032
+ var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
2596
1033
  return {
2597
- r: r * 255,
2598
- g: g * 255,
2599
- b: b * 255
1034
+ CSS_UNIT: new RegExp(CSS_UNIT),
1035
+ rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
1036
+ rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
1037
+ hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
1038
+ hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
1039
+ hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
1040
+ hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
1041
+ hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1042
+ hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
1043
+ hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
1044
+ hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
2600
1045
  };
2601
- }
2602
-
2603
- // `rgbToHex`
2604
- // Converts an RGB color to hex
2605
- // Assumes r, g, and b are contained in the set [0, 255]
2606
- // Returns a 3 or 6 character hex
2607
- function rgbToHex(r, g, b, allow3Char) {
2608
- var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
1046
+ }();
2609
1047
 
2610
- // Return a 3 character hex if possible
2611
- if (allow3Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1)) {
2612
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0);
2613
- }
2614
- return hex.join("");
1048
+ // `isValidCSSUnit`
1049
+ // Take in a single string / number and check to see if it looks like a CSS unit
1050
+ // (see `matchers` above for definition).
1051
+ function isValidCSSUnit(color) {
1052
+ return !!matchers.CSS_UNIT.exec(color);
2615
1053
  }
2616
1054
 
2617
- // `rgbaToHex`
2618
- // Converts an RGBA color plus alpha transparency to hex
2619
- // Assumes r, g, b are contained in the set [0, 255] and
2620
- // a in [0, 1]. Returns a 4 or 8 character rgba hex
2621
- function rgbaToHex(r, g, b, a, allow4Char) {
2622
- var hex = [pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16)), pad2(convertDecimalToHex(a))];
1055
+ // `stringInputToObject`
1056
+ // Permissive string parsing. Take in a number of formats, and output an object
1057
+ // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
1058
+ function stringInputToObject(color) {
1059
+ color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
1060
+ var named = false;
1061
+ if (names[color]) {
1062
+ color = names[color];
1063
+ named = true;
1064
+ } else if (color == "transparent") {
1065
+ return {
1066
+ r: 0,
1067
+ g: 0,
1068
+ b: 0,
1069
+ a: 0,
1070
+ format: "name"
1071
+ };
1072
+ }
2623
1073
 
2624
- // Return a 4 character hex if possible
2625
- if (allow4Char && hex[0].charAt(0) == hex[0].charAt(1) && hex[1].charAt(0) == hex[1].charAt(1) && hex[2].charAt(0) == hex[2].charAt(1) && hex[3].charAt(0) == hex[3].charAt(1)) {
2626
- return hex[0].charAt(0) + hex[1].charAt(0) + hex[2].charAt(0) + hex[3].charAt(0);
1074
+ // Try to match string input using regular expressions.
1075
+ // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
1076
+ // Just return an object and let the conversion functions handle that.
1077
+ // This way the result will be the same whether the tinycolor is initialized with string or object.
1078
+ var match;
1079
+ if (match = matchers.rgb.exec(color)) {
1080
+ return {
1081
+ r: match[1],
1082
+ g: match[2],
1083
+ b: match[3]
1084
+ };
2627
1085
  }
2628
- return hex.join("");
1086
+ if (match = matchers.rgba.exec(color)) {
1087
+ return {
1088
+ r: match[1],
1089
+ g: match[2],
1090
+ b: match[3],
1091
+ a: match[4]
1092
+ };
1093
+ }
1094
+ if (match = matchers.hsl.exec(color)) {
1095
+ return {
1096
+ h: match[1],
1097
+ s: match[2],
1098
+ l: match[3]
1099
+ };
1100
+ }
1101
+ if (match = matchers.hsla.exec(color)) {
1102
+ return {
1103
+ h: match[1],
1104
+ s: match[2],
1105
+ l: match[3],
1106
+ a: match[4]
1107
+ };
1108
+ }
1109
+ if (match = matchers.hsv.exec(color)) {
1110
+ return {
1111
+ h: match[1],
1112
+ s: match[2],
1113
+ v: match[3]
1114
+ };
1115
+ }
1116
+ if (match = matchers.hsva.exec(color)) {
1117
+ return {
1118
+ h: match[1],
1119
+ s: match[2],
1120
+ v: match[3],
1121
+ a: match[4]
1122
+ };
1123
+ }
1124
+ if (match = matchers.hex8.exec(color)) {
1125
+ return {
1126
+ r: parseIntFromHex(match[1]),
1127
+ g: parseIntFromHex(match[2]),
1128
+ b: parseIntFromHex(match[3]),
1129
+ a: convertHexToDecimal(match[4]),
1130
+ format: named ? "name" : "hex8"
1131
+ };
1132
+ }
1133
+ if (match = matchers.hex6.exec(color)) {
1134
+ return {
1135
+ r: parseIntFromHex(match[1]),
1136
+ g: parseIntFromHex(match[2]),
1137
+ b: parseIntFromHex(match[3]),
1138
+ format: named ? "name" : "hex"
1139
+ };
1140
+ }
1141
+ if (match = matchers.hex4.exec(color)) {
1142
+ return {
1143
+ r: parseIntFromHex(match[1] + "" + match[1]),
1144
+ g: parseIntFromHex(match[2] + "" + match[2]),
1145
+ b: parseIntFromHex(match[3] + "" + match[3]),
1146
+ a: convertHexToDecimal(match[4] + "" + match[4]),
1147
+ format: named ? "name" : "hex8"
1148
+ };
1149
+ }
1150
+ if (match = matchers.hex3.exec(color)) {
1151
+ return {
1152
+ r: parseIntFromHex(match[1] + "" + match[1]),
1153
+ g: parseIntFromHex(match[2] + "" + match[2]),
1154
+ b: parseIntFromHex(match[3] + "" + match[3]),
1155
+ format: named ? "name" : "hex"
1156
+ };
1157
+ }
1158
+ return false;
2629
1159
  }
2630
-
2631
- // `rgbaToArgbHex`
2632
- // Converts an RGBA color to an ARGB Hex8 string
2633
- // Rarely used, but required for "toFilter()"
2634
- function rgbaToArgbHex(r, g, b, a) {
2635
- var hex = [pad2(convertDecimalToHex(a)), pad2(Math.round(r).toString(16)), pad2(Math.round(g).toString(16)), pad2(Math.round(b).toString(16))];
2636
- return hex.join("");
1160
+ function validateWCAG2Parms(parms) {
1161
+ // return valid WCAG2 parms for isReadable.
1162
+ // If input parms are invalid, return {"level":"AA", "size":"small"}
1163
+ var level, size;
1164
+ parms = parms || {
1165
+ level: "AA",
1166
+ size: "small"
1167
+ };
1168
+ level = (parms.level || "AA").toUpperCase();
1169
+ size = (parms.size || "small").toLowerCase();
1170
+ if (level !== "AA" && level !== "AAA") {
1171
+ level = "AA";
1172
+ }
1173
+ if (size !== "small" && size !== "large") {
1174
+ size = "small";
1175
+ }
1176
+ return {
1177
+ level: level,
1178
+ size: size
1179
+ };
2637
1180
  }
2638
1181
 
2639
- // `equals`
2640
- // Can be called with any tinycolor input
2641
- tinycolor.equals = function (color1, color2) {
2642
- if (!color1 || !color2) return false;
2643
- return tinycolor(color1).toRgbString() == tinycolor(color2).toRgbString();
2644
- };
2645
- tinycolor.random = function () {
2646
- return tinycolor.fromRatio({
2647
- r: Math.random(),
2648
- g: Math.random(),
2649
- b: Math.random()
2650
- });
2651
- };
2652
-
2653
- // Modification Functions
2654
- // ----------------------
2655
- // Thanks to less.js for some of the basics here
2656
- // <https://github.com/cloudhead/less.js/blob/master/lib/less/functions.js>
2657
-
2658
- function _desaturate(color, amount) {
2659
- amount = amount === 0 ? 0 : amount || 10;
2660
- var hsl = tinycolor(color).toHsl();
2661
- hsl.s -= amount / 100;
2662
- hsl.s = clamp01(hsl.s);
2663
- return tinycolor(hsl);
2664
- }
2665
- function _saturate(color, amount) {
2666
- amount = amount === 0 ? 0 : amount || 10;
2667
- var hsl = tinycolor(color).toHsl();
2668
- hsl.s += amount / 100;
2669
- hsl.s = clamp01(hsl.s);
2670
- return tinycolor(hsl);
2671
- }
2672
- function _greyscale(color) {
2673
- return tinycolor(color).desaturate(100);
2674
- }
2675
- function _lighten(color, amount) {
2676
- amount = amount === 0 ? 0 : amount || 10;
2677
- var hsl = tinycolor(color).toHsl();
2678
- hsl.l += amount / 100;
2679
- hsl.l = clamp01(hsl.l);
2680
- return tinycolor(hsl);
2681
- }
2682
- function _brighten(color, amount) {
2683
- amount = amount === 0 ? 0 : amount || 10;
2684
- var rgb = tinycolor(color).toRgb();
2685
- rgb.r = Math.max(0, Math.min(255, rgb.r - Math.round(255 * -(amount / 100))));
2686
- rgb.g = Math.max(0, Math.min(255, rgb.g - Math.round(255 * -(amount / 100))));
2687
- rgb.b = Math.max(0, Math.min(255, rgb.b - Math.round(255 * -(amount / 100))));
2688
- return tinycolor(rgb);
2689
- }
2690
- function _darken(color, amount) {
2691
- amount = amount === 0 ? 0 : amount || 10;
2692
- var hsl = tinycolor(color).toHsl();
2693
- hsl.l -= amount / 100;
2694
- hsl.l = clamp01(hsl.l);
2695
- return tinycolor(hsl);
2696
- }
1182
+ /** Built-in value references. */
1183
+ var objectCreate = Object.create;
2697
1184
 
2698
- // Spin takes a positive or negative amount within [-360, 360] indicating the change of hue.
2699
- // Values outside of this range will be wrapped into this range.
2700
- function _spin(color, amount) {
2701
- var hsl = tinycolor(color).toHsl();
2702
- var hue = (hsl.h + amount) % 360;
2703
- hsl.h = hue < 0 ? 360 + hue : hue;
2704
- return tinycolor(hsl);
2705
- }
1185
+ /**
1186
+ * The base implementation of `_.create` without support for assigning
1187
+ * properties to the created object.
1188
+ *
1189
+ * @private
1190
+ * @param {Object} proto The object to inherit from.
1191
+ * @returns {Object} Returns the new object.
1192
+ */
1193
+ var baseCreate = (function() {
1194
+ function object() {}
1195
+ return function(proto) {
1196
+ if (!isObject(proto)) {
1197
+ return {};
1198
+ }
1199
+ if (objectCreate) {
1200
+ return objectCreate(proto);
1201
+ }
1202
+ object.prototype = proto;
1203
+ var result = new object;
1204
+ object.prototype = undefined;
1205
+ return result;
1206
+ };
1207
+ }());
2706
1208
 
2707
- // Combination Functions
2708
- // ---------------------
2709
- // Thanks to jQuery xColor for some of the ideas behind these
2710
- // <https://github.com/infusion/jQuery-xcolor/blob/master/jquery.xcolor.js>
1209
+ /**
1210
+ * Copies the values of `source` to `array`.
1211
+ *
1212
+ * @private
1213
+ * @param {Array} source The array to copy values from.
1214
+ * @param {Array} [array=[]] The array to copy values to.
1215
+ * @returns {Array} Returns `array`.
1216
+ */
1217
+ function copyArray(source, array) {
1218
+ var index = -1,
1219
+ length = source.length;
2711
1220
 
2712
- function _complement(color) {
2713
- var hsl = tinycolor(color).toHsl();
2714
- hsl.h = (hsl.h + 180) % 360;
2715
- return tinycolor(hsl);
2716
- }
2717
- function polyad(color, number) {
2718
- if (isNaN(number) || number <= 0) {
2719
- throw new Error("Argument to polyad must be a positive number");
2720
- }
2721
- var hsl = tinycolor(color).toHsl();
2722
- var result = [tinycolor(color)];
2723
- var step = 360 / number;
2724
- for (var i = 1; i < number; i++) {
2725
- result.push(tinycolor({
2726
- h: (hsl.h + i * step) % 360,
2727
- s: hsl.s,
2728
- l: hsl.l
2729
- }));
1221
+ array || (array = Array(length));
1222
+ while (++index < length) {
1223
+ array[index] = source[index];
2730
1224
  }
2731
- return result;
2732
- }
2733
- function _splitcomplement(color) {
2734
- var hsl = tinycolor(color).toHsl();
2735
- var h = hsl.h;
2736
- return [tinycolor(color), tinycolor({
2737
- h: (h + 72) % 360,
2738
- s: hsl.s,
2739
- l: hsl.l
2740
- }), tinycolor({
2741
- h: (h + 216) % 360,
2742
- s: hsl.s,
2743
- l: hsl.l
2744
- })];
1225
+ return array;
2745
1226
  }
2746
- function _analogous(color, results, slices) {
2747
- results = results || 6;
2748
- slices = slices || 30;
2749
- var hsl = tinycolor(color).toHsl();
2750
- var part = 360 / slices;
2751
- var ret = [tinycolor(color)];
2752
- for (hsl.h = (hsl.h - (part * results >> 1) + 720) % 360; --results;) {
2753
- hsl.h = (hsl.h + part) % 360;
2754
- ret.push(tinycolor(hsl));
1227
+
1228
+ /**
1229
+ * The base implementation of `assignValue` and `assignMergeValue` without
1230
+ * value checks.
1231
+ *
1232
+ * @private
1233
+ * @param {Object} object The object to modify.
1234
+ * @param {string} key The key of the property to assign.
1235
+ * @param {*} value The value to assign.
1236
+ */
1237
+ function baseAssignValue(object, key, value) {
1238
+ if (key == '__proto__' && defineProperty) {
1239
+ defineProperty(object, key, {
1240
+ 'configurable': true,
1241
+ 'enumerable': true,
1242
+ 'value': value,
1243
+ 'writable': true
1244
+ });
1245
+ } else {
1246
+ object[key] = value;
2755
1247
  }
2756
- return ret;
2757
1248
  }
2758
- function _monochromatic(color, results) {
2759
- results = results || 6;
2760
- var hsv = tinycolor(color).toHsv();
2761
- var h = hsv.h,
2762
- s = hsv.s,
2763
- v = hsv.v;
2764
- var ret = [];
2765
- var modification = 1 / results;
2766
- while (results--) {
2767
- ret.push(tinycolor({
2768
- h: h,
2769
- s: s,
2770
- v: v
2771
- }));
2772
- v = (v + modification) % 1;
1249
+
1250
+ /** Used for built-in method references. */
1251
+ var objectProto$2 = Object.prototype;
1252
+
1253
+ /** Used to check objects for own properties. */
1254
+ var hasOwnProperty$2 = objectProto$2.hasOwnProperty;
1255
+
1256
+ /**
1257
+ * Assigns `value` to `key` of `object` if the existing value is not equivalent
1258
+ * using [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1259
+ * for equality comparisons.
1260
+ *
1261
+ * @private
1262
+ * @param {Object} object The object to modify.
1263
+ * @param {string} key The key of the property to assign.
1264
+ * @param {*} value The value to assign.
1265
+ */
1266
+ function assignValue(object, key, value) {
1267
+ var objValue = object[key];
1268
+ if (!(hasOwnProperty$2.call(object, key) && eq(objValue, value)) ||
1269
+ (value === undefined && !(key in object))) {
1270
+ baseAssignValue(object, key, value);
2773
1271
  }
2774
- return ret;
2775
1272
  }
2776
1273
 
2777
- // Utility Functions
2778
- // ---------------------
1274
+ /**
1275
+ * Copies properties of `source` to `object`.
1276
+ *
1277
+ * @private
1278
+ * @param {Object} source The object to copy properties from.
1279
+ * @param {Array} props The property identifiers to copy.
1280
+ * @param {Object} [object={}] The object to copy properties to.
1281
+ * @param {Function} [customizer] The function to customize copied values.
1282
+ * @returns {Object} Returns `object`.
1283
+ */
1284
+ function copyObject(source, props, object, customizer) {
1285
+ var isNew = !object;
1286
+ object || (object = {});
2779
1287
 
2780
- tinycolor.mix = function (color1, color2, amount) {
2781
- amount = amount === 0 ? 0 : amount || 50;
2782
- var rgb1 = tinycolor(color1).toRgb();
2783
- var rgb2 = tinycolor(color2).toRgb();
2784
- var p = amount / 100;
2785
- var rgba = {
2786
- r: (rgb2.r - rgb1.r) * p + rgb1.r,
2787
- g: (rgb2.g - rgb1.g) * p + rgb1.g,
2788
- b: (rgb2.b - rgb1.b) * p + rgb1.b,
2789
- a: (rgb2.a - rgb1.a) * p + rgb1.a
2790
- };
2791
- return tinycolor(rgba);
2792
- };
1288
+ var index = -1,
1289
+ length = props.length;
2793
1290
 
2794
- // Readability Functions
2795
- // ---------------------
2796
- // <http://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef (WCAG Version 2)
1291
+ while (++index < length) {
1292
+ var key = props[index];
2797
1293
 
2798
- // `contrast`
2799
- // Analyze the 2 colors and returns the color contrast defined by (WCAG Version 2)
2800
- tinycolor.readability = function (color1, color2) {
2801
- var c1 = tinycolor(color1);
2802
- var c2 = tinycolor(color2);
2803
- return (Math.max(c1.getLuminance(), c2.getLuminance()) + 0.05) / (Math.min(c1.getLuminance(), c2.getLuminance()) + 0.05);
2804
- };
1294
+ var newValue = undefined;
2805
1295
 
2806
- // `isReadable`
2807
- // Ensure that foreground and background color combinations meet WCAG2 guidelines.
2808
- // The third argument is an optional Object.
2809
- // the 'level' property states 'AA' or 'AAA' - if missing or invalid, it defaults to 'AA';
2810
- // the 'size' property states 'large' or 'small' - if missing or invalid, it defaults to 'small'.
2811
- // If the entire object is absent, isReadable defaults to {level:"AA",size:"small"}.
1296
+ if (newValue === undefined) {
1297
+ newValue = source[key];
1298
+ }
1299
+ if (isNew) {
1300
+ baseAssignValue(object, key, newValue);
1301
+ } else {
1302
+ assignValue(object, key, newValue);
1303
+ }
1304
+ }
1305
+ return object;
1306
+ }
2812
1307
 
2813
- // *Example*
2814
- // tinycolor.isReadable("#000", "#111") => false
2815
- // tinycolor.isReadable("#000", "#111",{level:"AA",size:"large"}) => false
2816
- tinycolor.isReadable = function (color1, color2, wcag2) {
2817
- var readability = tinycolor.readability(color1, color2);
2818
- var wcag2Parms, out;
2819
- out = false;
2820
- wcag2Parms = validateWCAG2Parms(wcag2);
2821
- switch (wcag2Parms.level + wcag2Parms.size) {
2822
- case "AAsmall":
2823
- case "AAAlarge":
2824
- out = readability >= 4.5;
2825
- break;
2826
- case "AAlarge":
2827
- out = readability >= 3;
2828
- break;
2829
- case "AAAsmall":
2830
- out = readability >= 7;
2831
- break;
1308
+ /**
1309
+ * Checks if the given arguments are from an iteratee call.
1310
+ *
1311
+ * @private
1312
+ * @param {*} value The potential iteratee value argument.
1313
+ * @param {*} index The potential iteratee index or key argument.
1314
+ * @param {*} object The potential iteratee object argument.
1315
+ * @returns {boolean} Returns `true` if the arguments are from an iteratee call,
1316
+ * else `false`.
1317
+ */
1318
+ function isIterateeCall(value, index, object) {
1319
+ if (!isObject(object)) {
1320
+ return false;
2832
1321
  }
2833
- return out;
2834
- };
1322
+ var type = typeof index;
1323
+ if (type == 'number'
1324
+ ? (isArrayLike(object) && isIndex(index, object.length))
1325
+ : (type == 'string' && index in object)
1326
+ ) {
1327
+ return eq(object[index], value);
1328
+ }
1329
+ return false;
1330
+ }
2835
1331
 
2836
- // `mostReadable`
2837
- // Given a base color and a list of possible foreground or background
2838
- // colors for that base, returns the most readable color.
2839
- // Optionally returns Black or White if the most readable color is unreadable.
2840
- // *Example*
2841
- // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:false}).toHexString(); // "#112255"
2842
- // tinycolor.mostReadable(tinycolor.mostReadable("#123", ["#124", "#125"],{includeFallbackColors:true}).toHexString(); // "#ffffff"
2843
- // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"large"}).toHexString(); // "#faf3f3"
2844
- // tinycolor.mostReadable("#a8015a", ["#faf3f3"],{includeFallbackColors:true,level:"AAA",size:"small"}).toHexString(); // "#ffffff"
2845
- tinycolor.mostReadable = function (baseColor, colorList, args) {
2846
- var bestColor = null;
2847
- var bestScore = 0;
2848
- var readability;
2849
- var includeFallbackColors, level, size;
2850
- args = args || {};
2851
- includeFallbackColors = args.includeFallbackColors;
2852
- level = args.level;
2853
- size = args.size;
2854
- for (var i = 0; i < colorList.length; i++) {
2855
- readability = tinycolor.readability(baseColor, colorList[i]);
2856
- if (readability > bestScore) {
2857
- bestScore = readability;
2858
- bestColor = tinycolor(colorList[i]);
1332
+ /**
1333
+ * Creates a function like `_.assign`.
1334
+ *
1335
+ * @private
1336
+ * @param {Function} assigner The function to assign values.
1337
+ * @returns {Function} Returns the new assigner function.
1338
+ */
1339
+ function createAssigner(assigner) {
1340
+ return baseRest(function(object, sources) {
1341
+ var index = -1,
1342
+ length = sources.length,
1343
+ customizer = length > 1 ? sources[length - 1] : undefined,
1344
+ guard = length > 2 ? sources[2] : undefined;
1345
+
1346
+ customizer = (assigner.length > 3 && typeof customizer == 'function')
1347
+ ? (length--, customizer)
1348
+ : undefined;
1349
+
1350
+ if (guard && isIterateeCall(sources[0], sources[1], guard)) {
1351
+ customizer = length < 3 ? undefined : customizer;
1352
+ length = 1;
1353
+ }
1354
+ object = Object(object);
1355
+ while (++index < length) {
1356
+ var source = sources[index];
1357
+ if (source) {
1358
+ assigner(object, source, index, customizer);
1359
+ }
1360
+ }
1361
+ return object;
1362
+ });
1363
+ }
1364
+
1365
+ /**
1366
+ * This function is like
1367
+ * [`Object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1368
+ * except that it includes inherited enumerable properties.
1369
+ *
1370
+ * @private
1371
+ * @param {Object} object The object to query.
1372
+ * @returns {Array} Returns the array of property names.
1373
+ */
1374
+ function nativeKeysIn(object) {
1375
+ var result = [];
1376
+ if (object != null) {
1377
+ for (var key in Object(object)) {
1378
+ result.push(key);
2859
1379
  }
2860
1380
  }
2861
- if (tinycolor.isReadable(baseColor, bestColor, {
2862
- level: level,
2863
- size: size
2864
- }) || !includeFallbackColors) {
2865
- return bestColor;
2866
- } else {
2867
- args.includeFallbackColors = false;
2868
- return tinycolor.mostReadable(baseColor, ["#fff", "#000"], args);
2869
- }
2870
- };
1381
+ return result;
1382
+ }
2871
1383
 
2872
- // Big List of Colors
2873
- // ------------------
2874
- // <https://www.w3.org/TR/css-color-4/#named-colors>
2875
- var names = tinycolor.names = {
2876
- aliceblue: "f0f8ff",
2877
- antiquewhite: "faebd7",
2878
- aqua: "0ff",
2879
- aquamarine: "7fffd4",
2880
- azure: "f0ffff",
2881
- beige: "f5f5dc",
2882
- bisque: "ffe4c4",
2883
- black: "000",
2884
- blanchedalmond: "ffebcd",
2885
- blue: "00f",
2886
- blueviolet: "8a2be2",
2887
- brown: "a52a2a",
2888
- burlywood: "deb887",
2889
- burntsienna: "ea7e5d",
2890
- cadetblue: "5f9ea0",
2891
- chartreuse: "7fff00",
2892
- chocolate: "d2691e",
2893
- coral: "ff7f50",
2894
- cornflowerblue: "6495ed",
2895
- cornsilk: "fff8dc",
2896
- crimson: "dc143c",
2897
- cyan: "0ff",
2898
- darkblue: "00008b",
2899
- darkcyan: "008b8b",
2900
- darkgoldenrod: "b8860b",
2901
- darkgray: "a9a9a9",
2902
- darkgreen: "006400",
2903
- darkgrey: "a9a9a9",
2904
- darkkhaki: "bdb76b",
2905
- darkmagenta: "8b008b",
2906
- darkolivegreen: "556b2f",
2907
- darkorange: "ff8c00",
2908
- darkorchid: "9932cc",
2909
- darkred: "8b0000",
2910
- darksalmon: "e9967a",
2911
- darkseagreen: "8fbc8f",
2912
- darkslateblue: "483d8b",
2913
- darkslategray: "2f4f4f",
2914
- darkslategrey: "2f4f4f",
2915
- darkturquoise: "00ced1",
2916
- darkviolet: "9400d3",
2917
- deeppink: "ff1493",
2918
- deepskyblue: "00bfff",
2919
- dimgray: "696969",
2920
- dimgrey: "696969",
2921
- dodgerblue: "1e90ff",
2922
- firebrick: "b22222",
2923
- floralwhite: "fffaf0",
2924
- forestgreen: "228b22",
2925
- fuchsia: "f0f",
2926
- gainsboro: "dcdcdc",
2927
- ghostwhite: "f8f8ff",
2928
- gold: "ffd700",
2929
- goldenrod: "daa520",
2930
- gray: "808080",
2931
- green: "008000",
2932
- greenyellow: "adff2f",
2933
- grey: "808080",
2934
- honeydew: "f0fff0",
2935
- hotpink: "ff69b4",
2936
- indianred: "cd5c5c",
2937
- indigo: "4b0082",
2938
- ivory: "fffff0",
2939
- khaki: "f0e68c",
2940
- lavender: "e6e6fa",
2941
- lavenderblush: "fff0f5",
2942
- lawngreen: "7cfc00",
2943
- lemonchiffon: "fffacd",
2944
- lightblue: "add8e6",
2945
- lightcoral: "f08080",
2946
- lightcyan: "e0ffff",
2947
- lightgoldenrodyellow: "fafad2",
2948
- lightgray: "d3d3d3",
2949
- lightgreen: "90ee90",
2950
- lightgrey: "d3d3d3",
2951
- lightpink: "ffb6c1",
2952
- lightsalmon: "ffa07a",
2953
- lightseagreen: "20b2aa",
2954
- lightskyblue: "87cefa",
2955
- lightslategray: "789",
2956
- lightslategrey: "789",
2957
- lightsteelblue: "b0c4de",
2958
- lightyellow: "ffffe0",
2959
- lime: "0f0",
2960
- limegreen: "32cd32",
2961
- linen: "faf0e6",
2962
- magenta: "f0f",
2963
- maroon: "800000",
2964
- mediumaquamarine: "66cdaa",
2965
- mediumblue: "0000cd",
2966
- mediumorchid: "ba55d3",
2967
- mediumpurple: "9370db",
2968
- mediumseagreen: "3cb371",
2969
- mediumslateblue: "7b68ee",
2970
- mediumspringgreen: "00fa9a",
2971
- mediumturquoise: "48d1cc",
2972
- mediumvioletred: "c71585",
2973
- midnightblue: "191970",
2974
- mintcream: "f5fffa",
2975
- mistyrose: "ffe4e1",
2976
- moccasin: "ffe4b5",
2977
- navajowhite: "ffdead",
2978
- navy: "000080",
2979
- oldlace: "fdf5e6",
2980
- olive: "808000",
2981
- olivedrab: "6b8e23",
2982
- orange: "ffa500",
2983
- orangered: "ff4500",
2984
- orchid: "da70d6",
2985
- palegoldenrod: "eee8aa",
2986
- palegreen: "98fb98",
2987
- paleturquoise: "afeeee",
2988
- palevioletred: "db7093",
2989
- papayawhip: "ffefd5",
2990
- peachpuff: "ffdab9",
2991
- peru: "cd853f",
2992
- pink: "ffc0cb",
2993
- plum: "dda0dd",
2994
- powderblue: "b0e0e6",
2995
- purple: "800080",
2996
- rebeccapurple: "663399",
2997
- red: "f00",
2998
- rosybrown: "bc8f8f",
2999
- royalblue: "4169e1",
3000
- saddlebrown: "8b4513",
3001
- salmon: "fa8072",
3002
- sandybrown: "f4a460",
3003
- seagreen: "2e8b57",
3004
- seashell: "fff5ee",
3005
- sienna: "a0522d",
3006
- silver: "c0c0c0",
3007
- skyblue: "87ceeb",
3008
- slateblue: "6a5acd",
3009
- slategray: "708090",
3010
- slategrey: "708090",
3011
- snow: "fffafa",
3012
- springgreen: "00ff7f",
3013
- steelblue: "4682b4",
3014
- tan: "d2b48c",
3015
- teal: "008080",
3016
- thistle: "d8bfd8",
3017
- tomato: "ff6347",
3018
- turquoise: "40e0d0",
3019
- violet: "ee82ee",
3020
- wheat: "f5deb3",
3021
- white: "fff",
3022
- whitesmoke: "f5f5f5",
3023
- yellow: "ff0",
3024
- yellowgreen: "9acd32"
3025
- };
1384
+ /** Used for built-in method references. */
1385
+ var objectProto$1 = Object.prototype;
3026
1386
 
3027
- // Make it easy to access colors via `hexNames[hex]`
3028
- var hexNames = tinycolor.hexNames = flip(names);
1387
+ /** Used to check objects for own properties. */
1388
+ var hasOwnProperty$1 = objectProto$1.hasOwnProperty;
3029
1389
 
3030
- // Utilities
3031
- // ---------
1390
+ /**
1391
+ * The base implementation of `_.keysIn` which doesn't treat sparse arrays as dense.
1392
+ *
1393
+ * @private
1394
+ * @param {Object} object The object to query.
1395
+ * @returns {Array} Returns the array of property names.
1396
+ */
1397
+ function baseKeysIn(object) {
1398
+ if (!isObject(object)) {
1399
+ return nativeKeysIn(object);
1400
+ }
1401
+ var isProto = isPrototype(object),
1402
+ result = [];
3032
1403
 
3033
- // `{ 'name1': 'val1' }` becomes `{ 'val1': 'name1' }`
3034
- function flip(o) {
3035
- var flipped = {};
3036
- for (var i in o) {
3037
- if (o.hasOwnProperty(i)) {
3038
- flipped[o[i]] = i;
1404
+ for (var key in object) {
1405
+ if (!(key == 'constructor' && (isProto || !hasOwnProperty$1.call(object, key)))) {
1406
+ result.push(key);
3039
1407
  }
3040
1408
  }
3041
- return flipped;
1409
+ return result;
3042
1410
  }
3043
1411
 
3044
- // Return a valid alpha value [0,1] with all invalid values being set to 1
3045
- function boundAlpha(a) {
3046
- a = parseFloat(a);
3047
- if (isNaN(a) || a < 0 || a > 1) {
3048
- a = 1;
3049
- }
3050
- return a;
1412
+ /**
1413
+ * Creates an array of the own and inherited enumerable property names of `object`.
1414
+ *
1415
+ * **Note:** Non-object values are coerced to objects.
1416
+ *
1417
+ * @static
1418
+ * @memberOf _
1419
+ * @since 3.0.0
1420
+ * @category Object
1421
+ * @param {Object} object The object to query.
1422
+ * @returns {Array} Returns the array of property names.
1423
+ * @example
1424
+ *
1425
+ * function Foo() {
1426
+ * this.a = 1;
1427
+ * this.b = 2;
1428
+ * }
1429
+ *
1430
+ * Foo.prototype.c = 3;
1431
+ *
1432
+ * _.keysIn(new Foo);
1433
+ * // => ['a', 'b', 'c'] (iteration order is not guaranteed)
1434
+ */
1435
+ function keysIn(object) {
1436
+ return isArrayLike(object) ? arrayLikeKeys(object, true) : baseKeysIn(object);
3051
1437
  }
3052
1438
 
3053
- // Take input from [0, n] and return it as [0, 1]
3054
- function bound01(n, max) {
3055
- if (isOnePointZero(n)) n = "100%";
3056
- var processPercent = isPercentage(n);
3057
- n = Math.min(max, Math.max(0, parseFloat(n)));
1439
+ /** Built-in value references. */
1440
+ var getPrototype = overArg(Object.getPrototypeOf, Object);
3058
1441
 
3059
- // Automatically convert percentage into number
3060
- if (processPercent) {
3061
- n = parseInt(n * max, 10) / 100;
3062
- }
1442
+ /** `Object#toString` result references. */
1443
+ var objectTag = '[object Object]';
3063
1444
 
3064
- // Handle floating point rounding errors
3065
- if (Math.abs(n - max) < 0.000001) {
3066
- return 1;
3067
- }
1445
+ /** Used for built-in method references. */
1446
+ var funcProto = Function.prototype,
1447
+ objectProto = Object.prototype;
3068
1448
 
3069
- // Convert into [0, 1] range if it isn't already
3070
- return n % max / parseFloat(max);
3071
- }
1449
+ /** Used to resolve the decompiled source of functions. */
1450
+ var funcToString = funcProto.toString;
3072
1451
 
3073
- // Force a number between 0 and 1
3074
- function clamp01(val) {
3075
- return Math.min(1, Math.max(0, val));
3076
- }
1452
+ /** Used to check objects for own properties. */
1453
+ var hasOwnProperty = objectProto.hasOwnProperty;
3077
1454
 
3078
- // Parse a base-16 hex value into a base-10 integer
3079
- function parseIntFromHex(val) {
3080
- return parseInt(val, 16);
3081
- }
1455
+ /** Used to infer the `Object` constructor. */
1456
+ var objectCtorString = funcToString.call(Object);
3082
1457
 
3083
- // Need to handle 1.0 as 100%, since once it is a number, there is no difference between it and 1
3084
- // <http://stackoverflow.com/questions/7422072/javascript-how-to-detect-number-as-a-decimal-including-1-0>
3085
- function isOnePointZero(n) {
3086
- return typeof n == "string" && n.indexOf(".") != -1 && parseFloat(n) === 1;
1458
+ /**
1459
+ * Checks if `value` is a plain object, that is, an object created by the
1460
+ * `Object` constructor or one with a `[[Prototype]]` of `null`.
1461
+ *
1462
+ * @static
1463
+ * @memberOf _
1464
+ * @since 0.8.0
1465
+ * @category Lang
1466
+ * @param {*} value The value to check.
1467
+ * @returns {boolean} Returns `true` if `value` is a plain object, else `false`.
1468
+ * @example
1469
+ *
1470
+ * function Foo() {
1471
+ * this.a = 1;
1472
+ * }
1473
+ *
1474
+ * _.isPlainObject(new Foo);
1475
+ * // => false
1476
+ *
1477
+ * _.isPlainObject([1, 2, 3]);
1478
+ * // => false
1479
+ *
1480
+ * _.isPlainObject({ 'x': 0, 'y': 0 });
1481
+ * // => true
1482
+ *
1483
+ * _.isPlainObject(Object.create(null));
1484
+ * // => true
1485
+ */
1486
+ function isPlainObject(value) {
1487
+ if (!isObjectLike(value) || baseGetTag(value) != objectTag) {
1488
+ return false;
1489
+ }
1490
+ var proto = getPrototype(value);
1491
+ if (proto === null) {
1492
+ return true;
1493
+ }
1494
+ var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
1495
+ return typeof Ctor == 'function' && Ctor instanceof Ctor &&
1496
+ funcToString.call(Ctor) == objectCtorString;
3087
1497
  }
3088
1498
 
3089
- // Check to see if string passed in is a percentage
3090
- function isPercentage(n) {
3091
- return typeof n === "string" && n.indexOf("%") != -1;
3092
- }
1499
+ /** Detect free variable `exports`. */
1500
+ var freeExports = typeof exports == 'object' && exports && !exports.nodeType && exports;
3093
1501
 
3094
- // Force a hex value to have 2 characters
3095
- function pad2(c) {
3096
- return c.length == 1 ? "0" + c : "" + c;
3097
- }
1502
+ /** Detect free variable `module`. */
1503
+ var freeModule = freeExports && typeof module == 'object' && module && !module.nodeType && module;
3098
1504
 
3099
- // Replace a decimal with it's percentage value
3100
- function convertToPercentage(n) {
3101
- if (n <= 1) {
3102
- n = n * 100 + "%";
3103
- }
3104
- return n;
3105
- }
1505
+ /** Detect the popular CommonJS extension `module.exports`. */
1506
+ var moduleExports = freeModule && freeModule.exports === freeExports;
3106
1507
 
3107
- // Converts a decimal to a hex value
3108
- function convertDecimalToHex(d) {
3109
- return Math.round(parseFloat(d) * 255).toString(16);
3110
- }
3111
- // Converts a hex value to a decimal
3112
- function convertHexToDecimal(h) {
3113
- return parseIntFromHex(h) / 255;
3114
- }
3115
- var matchers = function () {
3116
- // <http://www.w3.org/TR/css3-values/#integers>
3117
- var CSS_INTEGER = "[-\\+]?\\d+%?";
1508
+ /** Built-in value references. */
1509
+ var Buffer = moduleExports ? root.Buffer : undefined,
1510
+ allocUnsafe = Buffer ? Buffer.allocUnsafe : undefined;
3118
1511
 
3119
- // <http://www.w3.org/TR/css3-values/#number-value>
3120
- var CSS_NUMBER = "[-\\+]?\\d*\\.\\d+%?";
1512
+ /**
1513
+ * Creates a clone of `buffer`.
1514
+ *
1515
+ * @private
1516
+ * @param {Buffer} buffer The buffer to clone.
1517
+ * @param {boolean} [isDeep] Specify a deep clone.
1518
+ * @returns {Buffer} Returns the cloned buffer.
1519
+ */
1520
+ function cloneBuffer(buffer, isDeep) {
1521
+ if (isDeep) {
1522
+ return buffer.slice();
1523
+ }
1524
+ var length = buffer.length,
1525
+ result = allocUnsafe ? allocUnsafe(length) : new buffer.constructor(length);
3121
1526
 
3122
- // Allow positive/negative integer/number. Don't capture the either/or, just the entire outcome.
3123
- var CSS_UNIT = "(?:" + CSS_NUMBER + ")|(?:" + CSS_INTEGER + ")";
1527
+ buffer.copy(result);
1528
+ return result;
1529
+ }
3124
1530
 
3125
- // Actual matching.
3126
- // Parentheses and commas are optional, but not required.
3127
- // Whitespace can take the place of commas or opening paren
3128
- var PERMISSIVE_MATCH3 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
3129
- var PERMISSIVE_MATCH4 = "[\\s|\\(]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")[,|\\s]+(" + CSS_UNIT + ")\\s*\\)?";
3130
- return {
3131
- CSS_UNIT: new RegExp(CSS_UNIT),
3132
- rgb: new RegExp("rgb" + PERMISSIVE_MATCH3),
3133
- rgba: new RegExp("rgba" + PERMISSIVE_MATCH4),
3134
- hsl: new RegExp("hsl" + PERMISSIVE_MATCH3),
3135
- hsla: new RegExp("hsla" + PERMISSIVE_MATCH4),
3136
- hsv: new RegExp("hsv" + PERMISSIVE_MATCH3),
3137
- hsva: new RegExp("hsva" + PERMISSIVE_MATCH4),
3138
- hex3: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
3139
- hex6: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/,
3140
- hex4: /^#?([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})([0-9a-fA-F]{1})$/,
3141
- hex8: /^#?([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})([0-9a-fA-F]{2})$/
3142
- };
3143
- }();
1531
+ /**
1532
+ * Creates a clone of `arrayBuffer`.
1533
+ *
1534
+ * @private
1535
+ * @param {ArrayBuffer} arrayBuffer The array buffer to clone.
1536
+ * @returns {ArrayBuffer} Returns the cloned array buffer.
1537
+ */
1538
+ function cloneArrayBuffer(arrayBuffer) {
1539
+ var result = new arrayBuffer.constructor(arrayBuffer.byteLength);
1540
+ new Uint8Array(result).set(new Uint8Array(arrayBuffer));
1541
+ return result;
1542
+ }
3144
1543
 
3145
- // `isValidCSSUnit`
3146
- // Take in a single string / number and check to see if it looks like a CSS unit
3147
- // (see `matchers` above for definition).
3148
- function isValidCSSUnit(color) {
3149
- return !!matchers.CSS_UNIT.exec(color);
1544
+ /**
1545
+ * Creates a clone of `typedArray`.
1546
+ *
1547
+ * @private
1548
+ * @param {Object} typedArray The typed array to clone.
1549
+ * @param {boolean} [isDeep] Specify a deep clone.
1550
+ * @returns {Object} Returns the cloned typed array.
1551
+ */
1552
+ function cloneTypedArray(typedArray, isDeep) {
1553
+ var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
1554
+ return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
3150
1555
  }
3151
1556
 
3152
- // `stringInputToObject`
3153
- // Permissive string parsing. Take in a number of formats, and output an object
3154
- // based on detected format. Returns `{ r, g, b }` or `{ h, s, l }` or `{ h, s, v}`
3155
- function stringInputToObject(color) {
3156
- color = color.replace(trimLeft, "").replace(trimRight, "").toLowerCase();
3157
- var named = false;
3158
- if (names[color]) {
3159
- color = names[color];
3160
- named = true;
3161
- } else if (color == "transparent") {
3162
- return {
3163
- r: 0,
3164
- g: 0,
3165
- b: 0,
3166
- a: 0,
3167
- format: "name"
3168
- };
3169
- }
1557
+ /**
1558
+ * Initializes an object clone.
1559
+ *
1560
+ * @private
1561
+ * @param {Object} object The object to clone.
1562
+ * @returns {Object} Returns the initialized clone.
1563
+ */
1564
+ function initCloneObject(object) {
1565
+ return (typeof object.constructor == 'function' && !isPrototype(object))
1566
+ ? baseCreate(getPrototype(object))
1567
+ : {};
1568
+ }
3170
1569
 
3171
- // Try to match string input using regular expressions.
3172
- // Keep most of the number bounding out of this function - don't worry about [0,1] or [0,100] or [0,360]
3173
- // Just return an object and let the conversion functions handle that.
3174
- // This way the result will be the same whether the tinycolor is initialized with string or object.
3175
- var match;
3176
- if (match = matchers.rgb.exec(color)) {
3177
- return {
3178
- r: match[1],
3179
- g: match[2],
3180
- b: match[3]
3181
- };
3182
- }
3183
- if (match = matchers.rgba.exec(color)) {
3184
- return {
3185
- r: match[1],
3186
- g: match[2],
3187
- b: match[3],
3188
- a: match[4]
3189
- };
3190
- }
3191
- if (match = matchers.hsl.exec(color)) {
3192
- return {
3193
- h: match[1],
3194
- s: match[2],
3195
- l: match[3]
3196
- };
3197
- }
3198
- if (match = matchers.hsla.exec(color)) {
3199
- return {
3200
- h: match[1],
3201
- s: match[2],
3202
- l: match[3],
3203
- a: match[4]
3204
- };
3205
- }
3206
- if (match = matchers.hsv.exec(color)) {
3207
- return {
3208
- h: match[1],
3209
- s: match[2],
3210
- v: match[3]
3211
- };
1570
+ /**
1571
+ * This function is like `assignValue` except that it doesn't assign
1572
+ * `undefined` values.
1573
+ *
1574
+ * @private
1575
+ * @param {Object} object The object to modify.
1576
+ * @param {string} key The key of the property to assign.
1577
+ * @param {*} value The value to assign.
1578
+ */
1579
+ function assignMergeValue(object, key, value) {
1580
+ if ((value !== undefined && !eq(object[key], value)) ||
1581
+ (value === undefined && !(key in object))) {
1582
+ baseAssignValue(object, key, value);
3212
1583
  }
3213
- if (match = matchers.hsva.exec(color)) {
3214
- return {
3215
- h: match[1],
3216
- s: match[2],
3217
- v: match[3],
3218
- a: match[4]
3219
- };
1584
+ }
1585
+
1586
+ /**
1587
+ * Gets the value at `key`, unless `key` is "__proto__" or "constructor".
1588
+ *
1589
+ * @private
1590
+ * @param {Object} object The object to query.
1591
+ * @param {string} key The key of the property to get.
1592
+ * @returns {*} Returns the property value.
1593
+ */
1594
+ function safeGet(object, key) {
1595
+ if (key === 'constructor' && typeof object[key] === 'function') {
1596
+ return;
3220
1597
  }
3221
- if (match = matchers.hex8.exec(color)) {
3222
- return {
3223
- r: parseIntFromHex(match[1]),
3224
- g: parseIntFromHex(match[2]),
3225
- b: parseIntFromHex(match[3]),
3226
- a: convertHexToDecimal(match[4]),
3227
- format: named ? "name" : "hex8"
3228
- };
1598
+
1599
+ if (key == '__proto__') {
1600
+ return;
3229
1601
  }
3230
- if (match = matchers.hex6.exec(color)) {
3231
- return {
3232
- r: parseIntFromHex(match[1]),
3233
- g: parseIntFromHex(match[2]),
3234
- b: parseIntFromHex(match[3]),
3235
- format: named ? "name" : "hex"
3236
- };
1602
+
1603
+ return object[key];
1604
+ }
1605
+
1606
+ /**
1607
+ * Converts `value` to a plain object flattening inherited enumerable string
1608
+ * keyed properties of `value` to own properties of the plain object.
1609
+ *
1610
+ * @static
1611
+ * @memberOf _
1612
+ * @since 3.0.0
1613
+ * @category Lang
1614
+ * @param {*} value The value to convert.
1615
+ * @returns {Object} Returns the converted plain object.
1616
+ * @example
1617
+ *
1618
+ * function Foo() {
1619
+ * this.b = 2;
1620
+ * }
1621
+ *
1622
+ * Foo.prototype.c = 3;
1623
+ *
1624
+ * _.assign({ 'a': 1 }, new Foo);
1625
+ * // => { 'a': 1, 'b': 2 }
1626
+ *
1627
+ * _.assign({ 'a': 1 }, _.toPlainObject(new Foo));
1628
+ * // => { 'a': 1, 'b': 2, 'c': 3 }
1629
+ */
1630
+ function toPlainObject(value) {
1631
+ return copyObject(value, keysIn(value));
1632
+ }
1633
+
1634
+ /**
1635
+ * A specialized version of `baseMerge` for arrays and objects which performs
1636
+ * deep merges and tracks traversed objects enabling objects with circular
1637
+ * references to be merged.
1638
+ *
1639
+ * @private
1640
+ * @param {Object} object The destination object.
1641
+ * @param {Object} source The source object.
1642
+ * @param {string} key The key of the value to merge.
1643
+ * @param {number} srcIndex The index of `source`.
1644
+ * @param {Function} mergeFunc The function to merge values.
1645
+ * @param {Function} [customizer] The function to customize assigned values.
1646
+ * @param {Object} [stack] Tracks traversed source values and their merged
1647
+ * counterparts.
1648
+ */
1649
+ function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
1650
+ var objValue = safeGet(object, key),
1651
+ srcValue = safeGet(source, key),
1652
+ stacked = stack.get(srcValue);
1653
+
1654
+ if (stacked) {
1655
+ assignMergeValue(object, key, stacked);
1656
+ return;
3237
1657
  }
3238
- if (match = matchers.hex4.exec(color)) {
3239
- return {
3240
- r: parseIntFromHex(match[1] + "" + match[1]),
3241
- g: parseIntFromHex(match[2] + "" + match[2]),
3242
- b: parseIntFromHex(match[3] + "" + match[3]),
3243
- a: convertHexToDecimal(match[4] + "" + match[4]),
3244
- format: named ? "name" : "hex8"
3245
- };
1658
+ var newValue = customizer
1659
+ ? customizer(objValue, srcValue, (key + ''), object, source, stack)
1660
+ : undefined;
1661
+
1662
+ var isCommon = newValue === undefined;
1663
+
1664
+ if (isCommon) {
1665
+ var isArr = isArray(srcValue),
1666
+ isBuff = !isArr && isBuffer(srcValue),
1667
+ isTyped = !isArr && !isBuff && isTypedArray(srcValue);
1668
+
1669
+ newValue = srcValue;
1670
+ if (isArr || isBuff || isTyped) {
1671
+ if (isArray(objValue)) {
1672
+ newValue = objValue;
1673
+ }
1674
+ else if (isArrayLikeObject(objValue)) {
1675
+ newValue = copyArray(objValue);
1676
+ }
1677
+ else if (isBuff) {
1678
+ isCommon = false;
1679
+ newValue = cloneBuffer(srcValue, true);
1680
+ }
1681
+ else if (isTyped) {
1682
+ isCommon = false;
1683
+ newValue = cloneTypedArray(srcValue, true);
1684
+ }
1685
+ else {
1686
+ newValue = [];
1687
+ }
1688
+ }
1689
+ else if (isPlainObject(srcValue) || isArguments(srcValue)) {
1690
+ newValue = objValue;
1691
+ if (isArguments(objValue)) {
1692
+ newValue = toPlainObject(objValue);
1693
+ }
1694
+ else if (!isObject(objValue) || isFunction(objValue)) {
1695
+ newValue = initCloneObject(srcValue);
1696
+ }
1697
+ }
1698
+ else {
1699
+ isCommon = false;
1700
+ }
3246
1701
  }
3247
- if (match = matchers.hex3.exec(color)) {
3248
- return {
3249
- r: parseIntFromHex(match[1] + "" + match[1]),
3250
- g: parseIntFromHex(match[2] + "" + match[2]),
3251
- b: parseIntFromHex(match[3] + "" + match[3]),
3252
- format: named ? "name" : "hex"
3253
- };
1702
+ if (isCommon) {
1703
+ // Recursively merge objects and arrays (susceptible to call stack limits).
1704
+ stack.set(srcValue, newValue);
1705
+ mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
1706
+ stack['delete'](srcValue);
3254
1707
  }
3255
- return false;
1708
+ assignMergeValue(object, key, newValue);
3256
1709
  }
3257
- function validateWCAG2Parms(parms) {
3258
- // return valid WCAG2 parms for isReadable.
3259
- // If input parms are invalid, return {"level":"AA", "size":"small"}
3260
- var level, size;
3261
- parms = parms || {
3262
- level: "AA",
3263
- size: "small"
3264
- };
3265
- level = (parms.level || "AA").toUpperCase();
3266
- size = (parms.size || "small").toLowerCase();
3267
- if (level !== "AA" && level !== "AAA") {
3268
- level = "AA";
3269
- }
3270
- if (size !== "small" && size !== "large") {
3271
- size = "small";
1710
+
1711
+ /**
1712
+ * The base implementation of `_.merge` without support for multiple sources.
1713
+ *
1714
+ * @private
1715
+ * @param {Object} object The destination object.
1716
+ * @param {Object} source The source object.
1717
+ * @param {number} srcIndex The index of `source`.
1718
+ * @param {Function} [customizer] The function to customize merged values.
1719
+ * @param {Object} [stack] Tracks traversed source values and their merged
1720
+ * counterparts.
1721
+ */
1722
+ function baseMerge(object, source, srcIndex, customizer, stack) {
1723
+ if (object === source) {
1724
+ return;
3272
1725
  }
3273
- return {
3274
- level: level,
3275
- size: size
3276
- };
1726
+ baseFor(source, function(srcValue, key) {
1727
+ stack || (stack = new Stack);
1728
+ if (isObject(srcValue)) {
1729
+ baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
1730
+ }
1731
+ else {
1732
+ var newValue = customizer
1733
+ ? customizer(safeGet(object, key), srcValue, (key + ''), object, source, stack)
1734
+ : undefined;
1735
+
1736
+ if (newValue === undefined) {
1737
+ newValue = srcValue;
1738
+ }
1739
+ assignMergeValue(object, key, newValue);
1740
+ }
1741
+ }, keysIn);
3277
1742
  }
3278
1743
 
1744
+ /**
1745
+ * This method is like `_.assign` except that it recursively merges own and
1746
+ * inherited enumerable string keyed properties of source objects into the
1747
+ * destination object. Source properties that resolve to `undefined` are
1748
+ * skipped if a destination value exists. Array and plain object properties
1749
+ * are merged recursively. Other objects and value types are overridden by
1750
+ * assignment. Source objects are applied from left to right. Subsequent
1751
+ * sources overwrite property assignments of previous sources.
1752
+ *
1753
+ * **Note:** This method mutates `object`.
1754
+ *
1755
+ * @static
1756
+ * @memberOf _
1757
+ * @since 0.5.0
1758
+ * @category Object
1759
+ * @param {Object} object The destination object.
1760
+ * @param {...Object} [sources] The source objects.
1761
+ * @returns {Object} Returns `object`.
1762
+ * @example
1763
+ *
1764
+ * var object = {
1765
+ * 'a': [{ 'b': 2 }, { 'd': 4 }]
1766
+ * };
1767
+ *
1768
+ * var other = {
1769
+ * 'a': [{ 'c': 3 }, { 'e': 5 }]
1770
+ * };
1771
+ *
1772
+ * _.merge(object, other);
1773
+ * // => { 'a': [{ 'b': 2, 'c': 3 }, { 'd': 4, 'e': 5 }] }
1774
+ */
1775
+ var merge = createAssigner(function(object, source, srcIndex) {
1776
+ baseMerge(object, source, srcIndex);
1777
+ });
1778
+
3279
1779
  const consoleLogger = {
3280
1780
  type: 'logger',
3281
1781
  log(args) {
@@ -5643,4 +4143,4 @@ instance.hasLoadedNamespace;
5643
4143
  instance.loadNamespaces;
5644
4144
  instance.loadLanguages;
5645
4145
 
5646
- export { assignValue as A, tinycolor as B, merge as C, instance as D, copyObject as E, keysIn as F, getPrototype as G, cloneArrayBuffer as H, cloneTypedArray as I, nodeUtil as J, baseUnary as K, copyArray as L, MapCache as M, cloneBuffer as N, initCloneObject as O, isPlainObject as P, t as Q, Symbol$1 as S, Uint8Array as U, isArray as a, baseGetTag as b, isPrototype as c, isArrayLike as d, arrayLikeKeys as e, isArguments as f, getNative as g, overRest as h, isObjectLike as i, Map$1 as j, eq as k, isBuffer as l, Stack as m, isTypedArray as n, overArg as o, isObject as p, isLength as q, root as r, setToString as s, toSource as t, isIndex as u, identity as v, baseFor as w, baseRest as x, isArrayLikeObject as y, baseAssignValue as z };
4146
+ export { assignValue as a, baseAssignValue as b, copyObject as c, cloneArrayBuffer as d, cloneTypedArray as e, copyArray as f, getPrototype as g, cloneBuffer as h, instance as i, initCloneObject as j, keysIn as k, isPlainObject as l, merge as m, t as n, tinycolor as t };