tileserver-gl-light 5.2.0 → 5.2.2-pre.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 (42) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/package.json +12 -1
  3. package/public/resources/fonts/OpenSans-Bold.ttf +0 -0
  4. package/public/resources/fonts/OpenSans-Italic.ttf +0 -0
  5. package/public/resources/fonts/OpenSans-Regular.ttf +0 -0
  6. package/public/resources/leaflet-hash.js +162 -0
  7. package/public/resources/leaflet.css +661 -0
  8. package/public/resources/leaflet.js +6 -0
  9. package/public/resources/leaflet.js.map +1 -0
  10. package/public/resources/mapbox-gl-rtl-text.js +1 -0
  11. package/public/resources/maplibre-gl-inspect.css +40 -0
  12. package/public/resources/maplibre-gl-inspect.js +2858 -0
  13. package/public/resources/maplibre-gl-inspect.js.map +1 -0
  14. package/public/resources/maplibre-gl.css +1 -0
  15. package/public/resources/maplibre-gl.js +59 -0
  16. package/public/resources/maplibre-gl.js.map +1 -0
  17. package/.dockerignore +0 -8
  18. package/.eslintignore +0 -1
  19. package/.eslintrc.cjs +0 -36
  20. package/.gitattributes +0 -11
  21. package/.github/dependabot.yml +0 -19
  22. package/.github/workflows/automerger.yml +0 -17
  23. package/.github/workflows/ci.yml +0 -56
  24. package/.github/workflows/codeql.yml +0 -37
  25. package/.github/workflows/ct.yml +0 -86
  26. package/.github/workflows/pipeline.yml +0 -43
  27. package/.github/workflows/release.yml +0 -175
  28. package/.hadolint.yml +0 -3
  29. package/.nvmrc +0 -1
  30. package/.prettierignore +0 -1
  31. package/.readthedocs.yaml +0 -18
  32. package/Dockerfile +0 -84
  33. package/Dockerfile_build +0 -38
  34. package/Dockerfile_test +0 -62
  35. package/ISSUE_TEMPLATE.md +0 -21
  36. package/PUBLISHING.md +0 -112
  37. package/changelog_for_version.md +0 -9
  38. package/commitlint.config.cjs +0 -3
  39. package/docker-entrypoint.sh +0 -7
  40. package/lint-staged.config.cjs +0 -4
  41. package/prettier.config.cjs +0 -13
  42. package/publish.js +0 -68
@@ -0,0 +1,2858 @@
1
+ (function (global, factory) {
2
+ typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
3
+ typeof define === 'function' && define.amd ? define(factory) :
4
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.MaplibreInspect = factory());
5
+ })(this, (function () { 'use strict';
6
+
7
+ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
8
+
9
+ function getDefaultExportFromCjs (x) {
10
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
11
+ }
12
+
13
+ var lodash_isequal = {exports: {}};
14
+
15
+ /**
16
+ * Lodash (Custom Build) <https://lodash.com/>
17
+ * Build: `lodash modularize exports="npm" -o ./`
18
+ * Copyright JS Foundation and other contributors <https://js.foundation/>
19
+ * Released under MIT license <https://lodash.com/license>
20
+ * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
21
+ * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
22
+ */
23
+ lodash_isequal.exports;
24
+
25
+ (function (module, exports) {
26
+ /** Used as the size to enable large array optimizations. */
27
+ var LARGE_ARRAY_SIZE = 200;
28
+
29
+ /** Used to stand-in for `undefined` hash values. */
30
+ var HASH_UNDEFINED = '__lodash_hash_undefined__';
31
+
32
+ /** Used to compose bitmasks for value comparisons. */
33
+ var COMPARE_PARTIAL_FLAG = 1,
34
+ COMPARE_UNORDERED_FLAG = 2;
35
+
36
+ /** Used as references for various `Number` constants. */
37
+ var MAX_SAFE_INTEGER = 9007199254740991;
38
+
39
+ /** `Object#toString` result references. */
40
+ var argsTag = '[object Arguments]',
41
+ arrayTag = '[object Array]',
42
+ asyncTag = '[object AsyncFunction]',
43
+ boolTag = '[object Boolean]',
44
+ dateTag = '[object Date]',
45
+ errorTag = '[object Error]',
46
+ funcTag = '[object Function]',
47
+ genTag = '[object GeneratorFunction]',
48
+ mapTag = '[object Map]',
49
+ numberTag = '[object Number]',
50
+ nullTag = '[object Null]',
51
+ objectTag = '[object Object]',
52
+ promiseTag = '[object Promise]',
53
+ proxyTag = '[object Proxy]',
54
+ regexpTag = '[object RegExp]',
55
+ setTag = '[object Set]',
56
+ stringTag = '[object String]',
57
+ symbolTag = '[object Symbol]',
58
+ undefinedTag = '[object Undefined]',
59
+ weakMapTag = '[object WeakMap]';
60
+
61
+ var arrayBufferTag = '[object ArrayBuffer]',
62
+ dataViewTag = '[object DataView]',
63
+ float32Tag = '[object Float32Array]',
64
+ float64Tag = '[object Float64Array]',
65
+ int8Tag = '[object Int8Array]',
66
+ int16Tag = '[object Int16Array]',
67
+ int32Tag = '[object Int32Array]',
68
+ uint8Tag = '[object Uint8Array]',
69
+ uint8ClampedTag = '[object Uint8ClampedArray]',
70
+ uint16Tag = '[object Uint16Array]',
71
+ uint32Tag = '[object Uint32Array]';
72
+
73
+ /**
74
+ * Used to match `RegExp`
75
+ * [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
76
+ */
77
+ var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
78
+
79
+ /** Used to detect host constructors (Safari). */
80
+ var reIsHostCtor = /^\[object .+?Constructor\]$/;
81
+
82
+ /** Used to detect unsigned integer values. */
83
+ var reIsUint = /^(?:0|[1-9]\d*)$/;
84
+
85
+ /** Used to identify `toStringTag` values of typed arrays. */
86
+ var typedArrayTags = {};
87
+ typedArrayTags[float32Tag] = typedArrayTags[float64Tag] =
88
+ typedArrayTags[int8Tag] = typedArrayTags[int16Tag] =
89
+ typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] =
90
+ typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] =
91
+ typedArrayTags[uint32Tag] = true;
92
+ typedArrayTags[argsTag] = typedArrayTags[arrayTag] =
93
+ typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] =
94
+ typedArrayTags[dataViewTag] = typedArrayTags[dateTag] =
95
+ typedArrayTags[errorTag] = typedArrayTags[funcTag] =
96
+ typedArrayTags[mapTag] = typedArrayTags[numberTag] =
97
+ typedArrayTags[objectTag] = typedArrayTags[regexpTag] =
98
+ typedArrayTags[setTag] = typedArrayTags[stringTag] =
99
+ typedArrayTags[weakMapTag] = false;
100
+
101
+ /** Detect free variable `global` from Node.js. */
102
+ var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
103
+
104
+ /** Detect free variable `self`. */
105
+ var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
106
+
107
+ /** Used as a reference to the global object. */
108
+ var root = freeGlobal || freeSelf || Function('return this')();
109
+
110
+ /** Detect free variable `exports`. */
111
+ var freeExports = exports && !exports.nodeType && exports;
112
+
113
+ /** Detect free variable `module`. */
114
+ var freeModule = freeExports && 'object' == 'object' && module && !module.nodeType && module;
115
+
116
+ /** Detect the popular CommonJS extension `module.exports`. */
117
+ var moduleExports = freeModule && freeModule.exports === freeExports;
118
+
119
+ /** Detect free variable `process` from Node.js. */
120
+ var freeProcess = moduleExports && freeGlobal.process;
121
+
122
+ /** Used to access faster Node.js helpers. */
123
+ var nodeUtil = (function() {
124
+ try {
125
+ return freeProcess && freeProcess.binding && freeProcess.binding('util');
126
+ } catch (e) {}
127
+ }());
128
+
129
+ /* Node.js helper references. */
130
+ var nodeIsTypedArray = nodeUtil && nodeUtil.isTypedArray;
131
+
132
+ /**
133
+ * A specialized version of `_.filter` for arrays without support for
134
+ * iteratee shorthands.
135
+ *
136
+ * @private
137
+ * @param {Array} [array] The array to iterate over.
138
+ * @param {Function} predicate The function invoked per iteration.
139
+ * @returns {Array} Returns the new filtered array.
140
+ */
141
+ function arrayFilter(array, predicate) {
142
+ var index = -1,
143
+ length = array == null ? 0 : array.length,
144
+ resIndex = 0,
145
+ result = [];
146
+
147
+ while (++index < length) {
148
+ var value = array[index];
149
+ if (predicate(value, index, array)) {
150
+ result[resIndex++] = value;
151
+ }
152
+ }
153
+ return result;
154
+ }
155
+
156
+ /**
157
+ * Appends the elements of `values` to `array`.
158
+ *
159
+ * @private
160
+ * @param {Array} array The array to modify.
161
+ * @param {Array} values The values to append.
162
+ * @returns {Array} Returns `array`.
163
+ */
164
+ function arrayPush(array, values) {
165
+ var index = -1,
166
+ length = values.length,
167
+ offset = array.length;
168
+
169
+ while (++index < length) {
170
+ array[offset + index] = values[index];
171
+ }
172
+ return array;
173
+ }
174
+
175
+ /**
176
+ * A specialized version of `_.some` for arrays without support for iteratee
177
+ * shorthands.
178
+ *
179
+ * @private
180
+ * @param {Array} [array] The array to iterate over.
181
+ * @param {Function} predicate The function invoked per iteration.
182
+ * @returns {boolean} Returns `true` if any element passes the predicate check,
183
+ * else `false`.
184
+ */
185
+ function arraySome(array, predicate) {
186
+ var index = -1,
187
+ length = array == null ? 0 : array.length;
188
+
189
+ while (++index < length) {
190
+ if (predicate(array[index], index, array)) {
191
+ return true;
192
+ }
193
+ }
194
+ return false;
195
+ }
196
+
197
+ /**
198
+ * The base implementation of `_.times` without support for iteratee shorthands
199
+ * or max array length checks.
200
+ *
201
+ * @private
202
+ * @param {number} n The number of times to invoke `iteratee`.
203
+ * @param {Function} iteratee The function invoked per iteration.
204
+ * @returns {Array} Returns the array of results.
205
+ */
206
+ function baseTimes(n, iteratee) {
207
+ var index = -1,
208
+ result = Array(n);
209
+
210
+ while (++index < n) {
211
+ result[index] = iteratee(index);
212
+ }
213
+ return result;
214
+ }
215
+
216
+ /**
217
+ * The base implementation of `_.unary` without support for storing metadata.
218
+ *
219
+ * @private
220
+ * @param {Function} func The function to cap arguments for.
221
+ * @returns {Function} Returns the new capped function.
222
+ */
223
+ function baseUnary(func) {
224
+ return function(value) {
225
+ return func(value);
226
+ };
227
+ }
228
+
229
+ /**
230
+ * Checks if a `cache` value for `key` exists.
231
+ *
232
+ * @private
233
+ * @param {Object} cache The cache to query.
234
+ * @param {string} key The key of the entry to check.
235
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
236
+ */
237
+ function cacheHas(cache, key) {
238
+ return cache.has(key);
239
+ }
240
+
241
+ /**
242
+ * Gets the value at `key` of `object`.
243
+ *
244
+ * @private
245
+ * @param {Object} [object] The object to query.
246
+ * @param {string} key The key of the property to get.
247
+ * @returns {*} Returns the property value.
248
+ */
249
+ function getValue(object, key) {
250
+ return object == null ? undefined : object[key];
251
+ }
252
+
253
+ /**
254
+ * Converts `map` to its key-value pairs.
255
+ *
256
+ * @private
257
+ * @param {Object} map The map to convert.
258
+ * @returns {Array} Returns the key-value pairs.
259
+ */
260
+ function mapToArray(map) {
261
+ var index = -1,
262
+ result = Array(map.size);
263
+
264
+ map.forEach(function(value, key) {
265
+ result[++index] = [key, value];
266
+ });
267
+ return result;
268
+ }
269
+
270
+ /**
271
+ * Creates a unary function that invokes `func` with its argument transformed.
272
+ *
273
+ * @private
274
+ * @param {Function} func The function to wrap.
275
+ * @param {Function} transform The argument transform.
276
+ * @returns {Function} Returns the new function.
277
+ */
278
+ function overArg(func, transform) {
279
+ return function(arg) {
280
+ return func(transform(arg));
281
+ };
282
+ }
283
+
284
+ /**
285
+ * Converts `set` to an array of its values.
286
+ *
287
+ * @private
288
+ * @param {Object} set The set to convert.
289
+ * @returns {Array} Returns the values.
290
+ */
291
+ function setToArray(set) {
292
+ var index = -1,
293
+ result = Array(set.size);
294
+
295
+ set.forEach(function(value) {
296
+ result[++index] = value;
297
+ });
298
+ return result;
299
+ }
300
+
301
+ /** Used for built-in method references. */
302
+ var arrayProto = Array.prototype,
303
+ funcProto = Function.prototype,
304
+ objectProto = Object.prototype;
305
+
306
+ /** Used to detect overreaching core-js shims. */
307
+ var coreJsData = root['__core-js_shared__'];
308
+
309
+ /** Used to resolve the decompiled source of functions. */
310
+ var funcToString = funcProto.toString;
311
+
312
+ /** Used to check objects for own properties. */
313
+ var hasOwnProperty = objectProto.hasOwnProperty;
314
+
315
+ /** Used to detect methods masquerading as native. */
316
+ var maskSrcKey = (function() {
317
+ var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
318
+ return uid ? ('Symbol(src)_1.' + uid) : '';
319
+ }());
320
+
321
+ /**
322
+ * Used to resolve the
323
+ * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
324
+ * of values.
325
+ */
326
+ var nativeObjectToString = objectProto.toString;
327
+
328
+ /** Used to detect if a method is native. */
329
+ var reIsNative = RegExp('^' +
330
+ funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
331
+ .replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
332
+ );
333
+
334
+ /** Built-in value references. */
335
+ var Buffer = moduleExports ? root.Buffer : undefined,
336
+ Symbol = root.Symbol,
337
+ Uint8Array = root.Uint8Array,
338
+ propertyIsEnumerable = objectProto.propertyIsEnumerable,
339
+ splice = arrayProto.splice,
340
+ symToStringTag = Symbol ? Symbol.toStringTag : undefined;
341
+
342
+ /* Built-in method references for those with the same name as other `lodash` methods. */
343
+ var nativeGetSymbols = Object.getOwnPropertySymbols,
344
+ nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined,
345
+ nativeKeys = overArg(Object.keys, Object);
346
+
347
+ /* Built-in method references that are verified to be native. */
348
+ var DataView = getNative(root, 'DataView'),
349
+ Map = getNative(root, 'Map'),
350
+ Promise = getNative(root, 'Promise'),
351
+ Set = getNative(root, 'Set'),
352
+ WeakMap = getNative(root, 'WeakMap'),
353
+ nativeCreate = getNative(Object, 'create');
354
+
355
+ /** Used to detect maps, sets, and weakmaps. */
356
+ var dataViewCtorString = toSource(DataView),
357
+ mapCtorString = toSource(Map),
358
+ promiseCtorString = toSource(Promise),
359
+ setCtorString = toSource(Set),
360
+ weakMapCtorString = toSource(WeakMap);
361
+
362
+ /** Used to convert symbols to primitives and strings. */
363
+ var symbolProto = Symbol ? Symbol.prototype : undefined,
364
+ symbolValueOf = symbolProto ? symbolProto.valueOf : undefined;
365
+
366
+ /**
367
+ * Creates a hash object.
368
+ *
369
+ * @private
370
+ * @constructor
371
+ * @param {Array} [entries] The key-value pairs to cache.
372
+ */
373
+ function Hash(entries) {
374
+ var index = -1,
375
+ length = entries == null ? 0 : entries.length;
376
+
377
+ this.clear();
378
+ while (++index < length) {
379
+ var entry = entries[index];
380
+ this.set(entry[0], entry[1]);
381
+ }
382
+ }
383
+
384
+ /**
385
+ * Removes all key-value entries from the hash.
386
+ *
387
+ * @private
388
+ * @name clear
389
+ * @memberOf Hash
390
+ */
391
+ function hashClear() {
392
+ this.__data__ = nativeCreate ? nativeCreate(null) : {};
393
+ this.size = 0;
394
+ }
395
+
396
+ /**
397
+ * Removes `key` and its value from the hash.
398
+ *
399
+ * @private
400
+ * @name delete
401
+ * @memberOf Hash
402
+ * @param {Object} hash The hash to modify.
403
+ * @param {string} key The key of the value to remove.
404
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
405
+ */
406
+ function hashDelete(key) {
407
+ var result = this.has(key) && delete this.__data__[key];
408
+ this.size -= result ? 1 : 0;
409
+ return result;
410
+ }
411
+
412
+ /**
413
+ * Gets the hash value for `key`.
414
+ *
415
+ * @private
416
+ * @name get
417
+ * @memberOf Hash
418
+ * @param {string} key The key of the value to get.
419
+ * @returns {*} Returns the entry value.
420
+ */
421
+ function hashGet(key) {
422
+ var data = this.__data__;
423
+ if (nativeCreate) {
424
+ var result = data[key];
425
+ return result === HASH_UNDEFINED ? undefined : result;
426
+ }
427
+ return hasOwnProperty.call(data, key) ? data[key] : undefined;
428
+ }
429
+
430
+ /**
431
+ * Checks if a hash value for `key` exists.
432
+ *
433
+ * @private
434
+ * @name has
435
+ * @memberOf Hash
436
+ * @param {string} key The key of the entry to check.
437
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
438
+ */
439
+ function hashHas(key) {
440
+ var data = this.__data__;
441
+ return nativeCreate ? (data[key] !== undefined) : hasOwnProperty.call(data, key);
442
+ }
443
+
444
+ /**
445
+ * Sets the hash `key` to `value`.
446
+ *
447
+ * @private
448
+ * @name set
449
+ * @memberOf Hash
450
+ * @param {string} key The key of the value to set.
451
+ * @param {*} value The value to set.
452
+ * @returns {Object} Returns the hash instance.
453
+ */
454
+ function hashSet(key, value) {
455
+ var data = this.__data__;
456
+ this.size += this.has(key) ? 0 : 1;
457
+ data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
458
+ return this;
459
+ }
460
+
461
+ // Add methods to `Hash`.
462
+ Hash.prototype.clear = hashClear;
463
+ Hash.prototype['delete'] = hashDelete;
464
+ Hash.prototype.get = hashGet;
465
+ Hash.prototype.has = hashHas;
466
+ Hash.prototype.set = hashSet;
467
+
468
+ /**
469
+ * Creates an list cache object.
470
+ *
471
+ * @private
472
+ * @constructor
473
+ * @param {Array} [entries] The key-value pairs to cache.
474
+ */
475
+ function ListCache(entries) {
476
+ var index = -1,
477
+ length = entries == null ? 0 : entries.length;
478
+
479
+ this.clear();
480
+ while (++index < length) {
481
+ var entry = entries[index];
482
+ this.set(entry[0], entry[1]);
483
+ }
484
+ }
485
+
486
+ /**
487
+ * Removes all key-value entries from the list cache.
488
+ *
489
+ * @private
490
+ * @name clear
491
+ * @memberOf ListCache
492
+ */
493
+ function listCacheClear() {
494
+ this.__data__ = [];
495
+ this.size = 0;
496
+ }
497
+
498
+ /**
499
+ * Removes `key` and its value from the list cache.
500
+ *
501
+ * @private
502
+ * @name delete
503
+ * @memberOf ListCache
504
+ * @param {string} key The key of the value to remove.
505
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
506
+ */
507
+ function listCacheDelete(key) {
508
+ var data = this.__data__,
509
+ index = assocIndexOf(data, key);
510
+
511
+ if (index < 0) {
512
+ return false;
513
+ }
514
+ var lastIndex = data.length - 1;
515
+ if (index == lastIndex) {
516
+ data.pop();
517
+ } else {
518
+ splice.call(data, index, 1);
519
+ }
520
+ --this.size;
521
+ return true;
522
+ }
523
+
524
+ /**
525
+ * Gets the list cache value for `key`.
526
+ *
527
+ * @private
528
+ * @name get
529
+ * @memberOf ListCache
530
+ * @param {string} key The key of the value to get.
531
+ * @returns {*} Returns the entry value.
532
+ */
533
+ function listCacheGet(key) {
534
+ var data = this.__data__,
535
+ index = assocIndexOf(data, key);
536
+
537
+ return index < 0 ? undefined : data[index][1];
538
+ }
539
+
540
+ /**
541
+ * Checks if a list cache value for `key` exists.
542
+ *
543
+ * @private
544
+ * @name has
545
+ * @memberOf ListCache
546
+ * @param {string} key The key of the entry to check.
547
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
548
+ */
549
+ function listCacheHas(key) {
550
+ return assocIndexOf(this.__data__, key) > -1;
551
+ }
552
+
553
+ /**
554
+ * Sets the list cache `key` to `value`.
555
+ *
556
+ * @private
557
+ * @name set
558
+ * @memberOf ListCache
559
+ * @param {string} key The key of the value to set.
560
+ * @param {*} value The value to set.
561
+ * @returns {Object} Returns the list cache instance.
562
+ */
563
+ function listCacheSet(key, value) {
564
+ var data = this.__data__,
565
+ index = assocIndexOf(data, key);
566
+
567
+ if (index < 0) {
568
+ ++this.size;
569
+ data.push([key, value]);
570
+ } else {
571
+ data[index][1] = value;
572
+ }
573
+ return this;
574
+ }
575
+
576
+ // Add methods to `ListCache`.
577
+ ListCache.prototype.clear = listCacheClear;
578
+ ListCache.prototype['delete'] = listCacheDelete;
579
+ ListCache.prototype.get = listCacheGet;
580
+ ListCache.prototype.has = listCacheHas;
581
+ ListCache.prototype.set = listCacheSet;
582
+
583
+ /**
584
+ * Creates a map cache object to store key-value pairs.
585
+ *
586
+ * @private
587
+ * @constructor
588
+ * @param {Array} [entries] The key-value pairs to cache.
589
+ */
590
+ function MapCache(entries) {
591
+ var index = -1,
592
+ length = entries == null ? 0 : entries.length;
593
+
594
+ this.clear();
595
+ while (++index < length) {
596
+ var entry = entries[index];
597
+ this.set(entry[0], entry[1]);
598
+ }
599
+ }
600
+
601
+ /**
602
+ * Removes all key-value entries from the map.
603
+ *
604
+ * @private
605
+ * @name clear
606
+ * @memberOf MapCache
607
+ */
608
+ function mapCacheClear() {
609
+ this.size = 0;
610
+ this.__data__ = {
611
+ 'hash': new Hash,
612
+ 'map': new (Map || ListCache),
613
+ 'string': new Hash
614
+ };
615
+ }
616
+
617
+ /**
618
+ * Removes `key` and its value from the map.
619
+ *
620
+ * @private
621
+ * @name delete
622
+ * @memberOf MapCache
623
+ * @param {string} key The key of the value to remove.
624
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
625
+ */
626
+ function mapCacheDelete(key) {
627
+ var result = getMapData(this, key)['delete'](key);
628
+ this.size -= result ? 1 : 0;
629
+ return result;
630
+ }
631
+
632
+ /**
633
+ * Gets the map value for `key`.
634
+ *
635
+ * @private
636
+ * @name get
637
+ * @memberOf MapCache
638
+ * @param {string} key The key of the value to get.
639
+ * @returns {*} Returns the entry value.
640
+ */
641
+ function mapCacheGet(key) {
642
+ return getMapData(this, key).get(key);
643
+ }
644
+
645
+ /**
646
+ * Checks if a map value for `key` exists.
647
+ *
648
+ * @private
649
+ * @name has
650
+ * @memberOf MapCache
651
+ * @param {string} key The key of the entry to check.
652
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
653
+ */
654
+ function mapCacheHas(key) {
655
+ return getMapData(this, key).has(key);
656
+ }
657
+
658
+ /**
659
+ * Sets the map `key` to `value`.
660
+ *
661
+ * @private
662
+ * @name set
663
+ * @memberOf MapCache
664
+ * @param {string} key The key of the value to set.
665
+ * @param {*} value The value to set.
666
+ * @returns {Object} Returns the map cache instance.
667
+ */
668
+ function mapCacheSet(key, value) {
669
+ var data = getMapData(this, key),
670
+ size = data.size;
671
+
672
+ data.set(key, value);
673
+ this.size += data.size == size ? 0 : 1;
674
+ return this;
675
+ }
676
+
677
+ // Add methods to `MapCache`.
678
+ MapCache.prototype.clear = mapCacheClear;
679
+ MapCache.prototype['delete'] = mapCacheDelete;
680
+ MapCache.prototype.get = mapCacheGet;
681
+ MapCache.prototype.has = mapCacheHas;
682
+ MapCache.prototype.set = mapCacheSet;
683
+
684
+ /**
685
+ *
686
+ * Creates an array cache object to store unique values.
687
+ *
688
+ * @private
689
+ * @constructor
690
+ * @param {Array} [values] The values to cache.
691
+ */
692
+ function SetCache(values) {
693
+ var index = -1,
694
+ length = values == null ? 0 : values.length;
695
+
696
+ this.__data__ = new MapCache;
697
+ while (++index < length) {
698
+ this.add(values[index]);
699
+ }
700
+ }
701
+
702
+ /**
703
+ * Adds `value` to the array cache.
704
+ *
705
+ * @private
706
+ * @name add
707
+ * @memberOf SetCache
708
+ * @alias push
709
+ * @param {*} value The value to cache.
710
+ * @returns {Object} Returns the cache instance.
711
+ */
712
+ function setCacheAdd(value) {
713
+ this.__data__.set(value, HASH_UNDEFINED);
714
+ return this;
715
+ }
716
+
717
+ /**
718
+ * Checks if `value` is in the array cache.
719
+ *
720
+ * @private
721
+ * @name has
722
+ * @memberOf SetCache
723
+ * @param {*} value The value to search for.
724
+ * @returns {number} Returns `true` if `value` is found, else `false`.
725
+ */
726
+ function setCacheHas(value) {
727
+ return this.__data__.has(value);
728
+ }
729
+
730
+ // Add methods to `SetCache`.
731
+ SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
732
+ SetCache.prototype.has = setCacheHas;
733
+
734
+ /**
735
+ * Creates a stack cache object to store key-value pairs.
736
+ *
737
+ * @private
738
+ * @constructor
739
+ * @param {Array} [entries] The key-value pairs to cache.
740
+ */
741
+ function Stack(entries) {
742
+ var data = this.__data__ = new ListCache(entries);
743
+ this.size = data.size;
744
+ }
745
+
746
+ /**
747
+ * Removes all key-value entries from the stack.
748
+ *
749
+ * @private
750
+ * @name clear
751
+ * @memberOf Stack
752
+ */
753
+ function stackClear() {
754
+ this.__data__ = new ListCache;
755
+ this.size = 0;
756
+ }
757
+
758
+ /**
759
+ * Removes `key` and its value from the stack.
760
+ *
761
+ * @private
762
+ * @name delete
763
+ * @memberOf Stack
764
+ * @param {string} key The key of the value to remove.
765
+ * @returns {boolean} Returns `true` if the entry was removed, else `false`.
766
+ */
767
+ function stackDelete(key) {
768
+ var data = this.__data__,
769
+ result = data['delete'](key);
770
+
771
+ this.size = data.size;
772
+ return result;
773
+ }
774
+
775
+ /**
776
+ * Gets the stack value for `key`.
777
+ *
778
+ * @private
779
+ * @name get
780
+ * @memberOf Stack
781
+ * @param {string} key The key of the value to get.
782
+ * @returns {*} Returns the entry value.
783
+ */
784
+ function stackGet(key) {
785
+ return this.__data__.get(key);
786
+ }
787
+
788
+ /**
789
+ * Checks if a stack value for `key` exists.
790
+ *
791
+ * @private
792
+ * @name has
793
+ * @memberOf Stack
794
+ * @param {string} key The key of the entry to check.
795
+ * @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
796
+ */
797
+ function stackHas(key) {
798
+ return this.__data__.has(key);
799
+ }
800
+
801
+ /**
802
+ * Sets the stack `key` to `value`.
803
+ *
804
+ * @private
805
+ * @name set
806
+ * @memberOf Stack
807
+ * @param {string} key The key of the value to set.
808
+ * @param {*} value The value to set.
809
+ * @returns {Object} Returns the stack cache instance.
810
+ */
811
+ function stackSet(key, value) {
812
+ var data = this.__data__;
813
+ if (data instanceof ListCache) {
814
+ var pairs = data.__data__;
815
+ if (!Map || (pairs.length < LARGE_ARRAY_SIZE - 1)) {
816
+ pairs.push([key, value]);
817
+ this.size = ++data.size;
818
+ return this;
819
+ }
820
+ data = this.__data__ = new MapCache(pairs);
821
+ }
822
+ data.set(key, value);
823
+ this.size = data.size;
824
+ return this;
825
+ }
826
+
827
+ // Add methods to `Stack`.
828
+ Stack.prototype.clear = stackClear;
829
+ Stack.prototype['delete'] = stackDelete;
830
+ Stack.prototype.get = stackGet;
831
+ Stack.prototype.has = stackHas;
832
+ Stack.prototype.set = stackSet;
833
+
834
+ /**
835
+ * Creates an array of the enumerable property names of the array-like `value`.
836
+ *
837
+ * @private
838
+ * @param {*} value The value to query.
839
+ * @param {boolean} inherited Specify returning inherited property names.
840
+ * @returns {Array} Returns the array of property names.
841
+ */
842
+ function arrayLikeKeys(value, inherited) {
843
+ var isArr = isArray(value),
844
+ isArg = !isArr && isArguments(value),
845
+ isBuff = !isArr && !isArg && isBuffer(value),
846
+ isType = !isArr && !isArg && !isBuff && isTypedArray(value),
847
+ skipIndexes = isArr || isArg || isBuff || isType,
848
+ result = skipIndexes ? baseTimes(value.length, String) : [],
849
+ length = result.length;
850
+
851
+ for (var key in value) {
852
+ if ((hasOwnProperty.call(value, key)) &&
853
+ !(skipIndexes && (
854
+ // Safari 9 has enumerable `arguments.length` in strict mode.
855
+ key == 'length' ||
856
+ // Node.js 0.10 has enumerable non-index properties on buffers.
857
+ (isBuff && (key == 'offset' || key == 'parent')) ||
858
+ // PhantomJS 2 has enumerable non-index properties on typed arrays.
859
+ (isType && (key == 'buffer' || key == 'byteLength' || key == 'byteOffset')) ||
860
+ // Skip index properties.
861
+ isIndex(key, length)
862
+ ))) {
863
+ result.push(key);
864
+ }
865
+ }
866
+ return result;
867
+ }
868
+
869
+ /**
870
+ * Gets the index at which the `key` is found in `array` of key-value pairs.
871
+ *
872
+ * @private
873
+ * @param {Array} array The array to inspect.
874
+ * @param {*} key The key to search for.
875
+ * @returns {number} Returns the index of the matched value, else `-1`.
876
+ */
877
+ function assocIndexOf(array, key) {
878
+ var length = array.length;
879
+ while (length--) {
880
+ if (eq(array[length][0], key)) {
881
+ return length;
882
+ }
883
+ }
884
+ return -1;
885
+ }
886
+
887
+ /**
888
+ * The base implementation of `getAllKeys` and `getAllKeysIn` which uses
889
+ * `keysFunc` and `symbolsFunc` to get the enumerable property names and
890
+ * symbols of `object`.
891
+ *
892
+ * @private
893
+ * @param {Object} object The object to query.
894
+ * @param {Function} keysFunc The function to get the keys of `object`.
895
+ * @param {Function} symbolsFunc The function to get the symbols of `object`.
896
+ * @returns {Array} Returns the array of property names and symbols.
897
+ */
898
+ function baseGetAllKeys(object, keysFunc, symbolsFunc) {
899
+ var result = keysFunc(object);
900
+ return isArray(object) ? result : arrayPush(result, symbolsFunc(object));
901
+ }
902
+
903
+ /**
904
+ * The base implementation of `getTag` without fallbacks for buggy environments.
905
+ *
906
+ * @private
907
+ * @param {*} value The value to query.
908
+ * @returns {string} Returns the `toStringTag`.
909
+ */
910
+ function baseGetTag(value) {
911
+ if (value == null) {
912
+ return value === undefined ? undefinedTag : nullTag;
913
+ }
914
+ return (symToStringTag && symToStringTag in Object(value))
915
+ ? getRawTag(value)
916
+ : objectToString(value);
917
+ }
918
+
919
+ /**
920
+ * The base implementation of `_.isArguments`.
921
+ *
922
+ * @private
923
+ * @param {*} value The value to check.
924
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
925
+ */
926
+ function baseIsArguments(value) {
927
+ return isObjectLike(value) && baseGetTag(value) == argsTag;
928
+ }
929
+
930
+ /**
931
+ * The base implementation of `_.isEqual` which supports partial comparisons
932
+ * and tracks traversed objects.
933
+ *
934
+ * @private
935
+ * @param {*} value The value to compare.
936
+ * @param {*} other The other value to compare.
937
+ * @param {boolean} bitmask The bitmask flags.
938
+ * 1 - Unordered comparison
939
+ * 2 - Partial comparison
940
+ * @param {Function} [customizer] The function to customize comparisons.
941
+ * @param {Object} [stack] Tracks traversed `value` and `other` objects.
942
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
943
+ */
944
+ function baseIsEqual(value, other, bitmask, customizer, stack) {
945
+ if (value === other) {
946
+ return true;
947
+ }
948
+ if (value == null || other == null || (!isObjectLike(value) && !isObjectLike(other))) {
949
+ return value !== value && other !== other;
950
+ }
951
+ return baseIsEqualDeep(value, other, bitmask, customizer, baseIsEqual, stack);
952
+ }
953
+
954
+ /**
955
+ * A specialized version of `baseIsEqual` for arrays and objects which performs
956
+ * deep comparisons and tracks traversed objects enabling objects with circular
957
+ * references to be compared.
958
+ *
959
+ * @private
960
+ * @param {Object} object The object to compare.
961
+ * @param {Object} other The other object to compare.
962
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
963
+ * @param {Function} customizer The function to customize comparisons.
964
+ * @param {Function} equalFunc The function to determine equivalents of values.
965
+ * @param {Object} [stack] Tracks traversed `object` and `other` objects.
966
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
967
+ */
968
+ function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
969
+ var objIsArr = isArray(object),
970
+ othIsArr = isArray(other),
971
+ objTag = objIsArr ? arrayTag : getTag(object),
972
+ othTag = othIsArr ? arrayTag : getTag(other);
973
+
974
+ objTag = objTag == argsTag ? objectTag : objTag;
975
+ othTag = othTag == argsTag ? objectTag : othTag;
976
+
977
+ var objIsObj = objTag == objectTag,
978
+ othIsObj = othTag == objectTag,
979
+ isSameTag = objTag == othTag;
980
+
981
+ if (isSameTag && isBuffer(object)) {
982
+ if (!isBuffer(other)) {
983
+ return false;
984
+ }
985
+ objIsArr = true;
986
+ objIsObj = false;
987
+ }
988
+ if (isSameTag && !objIsObj) {
989
+ stack || (stack = new Stack);
990
+ return (objIsArr || isTypedArray(object))
991
+ ? equalArrays(object, other, bitmask, customizer, equalFunc, stack)
992
+ : equalByTag(object, other, objTag, bitmask, customizer, equalFunc, stack);
993
+ }
994
+ if (!(bitmask & COMPARE_PARTIAL_FLAG)) {
995
+ var objIsWrapped = objIsObj && hasOwnProperty.call(object, '__wrapped__'),
996
+ othIsWrapped = othIsObj && hasOwnProperty.call(other, '__wrapped__');
997
+
998
+ if (objIsWrapped || othIsWrapped) {
999
+ var objUnwrapped = objIsWrapped ? object.value() : object,
1000
+ othUnwrapped = othIsWrapped ? other.value() : other;
1001
+
1002
+ stack || (stack = new Stack);
1003
+ return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
1004
+ }
1005
+ }
1006
+ if (!isSameTag) {
1007
+ return false;
1008
+ }
1009
+ stack || (stack = new Stack);
1010
+ return equalObjects(object, other, bitmask, customizer, equalFunc, stack);
1011
+ }
1012
+
1013
+ /**
1014
+ * The base implementation of `_.isNative` without bad shim checks.
1015
+ *
1016
+ * @private
1017
+ * @param {*} value The value to check.
1018
+ * @returns {boolean} Returns `true` if `value` is a native function,
1019
+ * else `false`.
1020
+ */
1021
+ function baseIsNative(value) {
1022
+ if (!isObject(value) || isMasked(value)) {
1023
+ return false;
1024
+ }
1025
+ var pattern = isFunction(value) ? reIsNative : reIsHostCtor;
1026
+ return pattern.test(toSource(value));
1027
+ }
1028
+
1029
+ /**
1030
+ * The base implementation of `_.isTypedArray` without Node.js optimizations.
1031
+ *
1032
+ * @private
1033
+ * @param {*} value The value to check.
1034
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1035
+ */
1036
+ function baseIsTypedArray(value) {
1037
+ return isObjectLike(value) &&
1038
+ isLength(value.length) && !!typedArrayTags[baseGetTag(value)];
1039
+ }
1040
+
1041
+ /**
1042
+ * The base implementation of `_.keys` which doesn't treat sparse arrays as dense.
1043
+ *
1044
+ * @private
1045
+ * @param {Object} object The object to query.
1046
+ * @returns {Array} Returns the array of property names.
1047
+ */
1048
+ function baseKeys(object) {
1049
+ if (!isPrototype(object)) {
1050
+ return nativeKeys(object);
1051
+ }
1052
+ var result = [];
1053
+ for (var key in Object(object)) {
1054
+ if (hasOwnProperty.call(object, key) && key != 'constructor') {
1055
+ result.push(key);
1056
+ }
1057
+ }
1058
+ return result;
1059
+ }
1060
+
1061
+ /**
1062
+ * A specialized version of `baseIsEqualDeep` for arrays with support for
1063
+ * partial deep comparisons.
1064
+ *
1065
+ * @private
1066
+ * @param {Array} array The array to compare.
1067
+ * @param {Array} other The other array to compare.
1068
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1069
+ * @param {Function} customizer The function to customize comparisons.
1070
+ * @param {Function} equalFunc The function to determine equivalents of values.
1071
+ * @param {Object} stack Tracks traversed `array` and `other` objects.
1072
+ * @returns {boolean} Returns `true` if the arrays are equivalent, else `false`.
1073
+ */
1074
+ function equalArrays(array, other, bitmask, customizer, equalFunc, stack) {
1075
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1076
+ arrLength = array.length,
1077
+ othLength = other.length;
1078
+
1079
+ if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
1080
+ return false;
1081
+ }
1082
+ // Assume cyclic values are equal.
1083
+ var stacked = stack.get(array);
1084
+ if (stacked && stack.get(other)) {
1085
+ return stacked == other;
1086
+ }
1087
+ var index = -1,
1088
+ result = true,
1089
+ seen = (bitmask & COMPARE_UNORDERED_FLAG) ? new SetCache : undefined;
1090
+
1091
+ stack.set(array, other);
1092
+ stack.set(other, array);
1093
+
1094
+ // Ignore non-index properties.
1095
+ while (++index < arrLength) {
1096
+ var arrValue = array[index],
1097
+ othValue = other[index];
1098
+
1099
+ if (customizer) {
1100
+ var compared = isPartial
1101
+ ? customizer(othValue, arrValue, index, other, array, stack)
1102
+ : customizer(arrValue, othValue, index, array, other, stack);
1103
+ }
1104
+ if (compared !== undefined) {
1105
+ if (compared) {
1106
+ continue;
1107
+ }
1108
+ result = false;
1109
+ break;
1110
+ }
1111
+ // Recursively compare arrays (susceptible to call stack limits).
1112
+ if (seen) {
1113
+ if (!arraySome(other, function(othValue, othIndex) {
1114
+ if (!cacheHas(seen, othIndex) &&
1115
+ (arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
1116
+ return seen.push(othIndex);
1117
+ }
1118
+ })) {
1119
+ result = false;
1120
+ break;
1121
+ }
1122
+ } else if (!(
1123
+ arrValue === othValue ||
1124
+ equalFunc(arrValue, othValue, bitmask, customizer, stack)
1125
+ )) {
1126
+ result = false;
1127
+ break;
1128
+ }
1129
+ }
1130
+ stack['delete'](array);
1131
+ stack['delete'](other);
1132
+ return result;
1133
+ }
1134
+
1135
+ /**
1136
+ * A specialized version of `baseIsEqualDeep` for comparing objects of
1137
+ * the same `toStringTag`.
1138
+ *
1139
+ * **Note:** This function only supports comparing values with tags of
1140
+ * `Boolean`, `Date`, `Error`, `Number`, `RegExp`, or `String`.
1141
+ *
1142
+ * @private
1143
+ * @param {Object} object The object to compare.
1144
+ * @param {Object} other The other object to compare.
1145
+ * @param {string} tag The `toStringTag` of the objects to compare.
1146
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1147
+ * @param {Function} customizer The function to customize comparisons.
1148
+ * @param {Function} equalFunc The function to determine equivalents of values.
1149
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
1150
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1151
+ */
1152
+ function equalByTag(object, other, tag, bitmask, customizer, equalFunc, stack) {
1153
+ switch (tag) {
1154
+ case dataViewTag:
1155
+ if ((object.byteLength != other.byteLength) ||
1156
+ (object.byteOffset != other.byteOffset)) {
1157
+ return false;
1158
+ }
1159
+ object = object.buffer;
1160
+ other = other.buffer;
1161
+
1162
+ case arrayBufferTag:
1163
+ if ((object.byteLength != other.byteLength) ||
1164
+ !equalFunc(new Uint8Array(object), new Uint8Array(other))) {
1165
+ return false;
1166
+ }
1167
+ return true;
1168
+
1169
+ case boolTag:
1170
+ case dateTag:
1171
+ case numberTag:
1172
+ // Coerce booleans to `1` or `0` and dates to milliseconds.
1173
+ // Invalid dates are coerced to `NaN`.
1174
+ return eq(+object, +other);
1175
+
1176
+ case errorTag:
1177
+ return object.name == other.name && object.message == other.message;
1178
+
1179
+ case regexpTag:
1180
+ case stringTag:
1181
+ // Coerce regexes to strings and treat strings, primitives and objects,
1182
+ // as equal. See http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
1183
+ // for more details.
1184
+ return object == (other + '');
1185
+
1186
+ case mapTag:
1187
+ var convert = mapToArray;
1188
+
1189
+ case setTag:
1190
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG;
1191
+ convert || (convert = setToArray);
1192
+
1193
+ if (object.size != other.size && !isPartial) {
1194
+ return false;
1195
+ }
1196
+ // Assume cyclic values are equal.
1197
+ var stacked = stack.get(object);
1198
+ if (stacked) {
1199
+ return stacked == other;
1200
+ }
1201
+ bitmask |= COMPARE_UNORDERED_FLAG;
1202
+
1203
+ // Recursively compare objects (susceptible to call stack limits).
1204
+ stack.set(object, other);
1205
+ var result = equalArrays(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
1206
+ stack['delete'](object);
1207
+ return result;
1208
+
1209
+ case symbolTag:
1210
+ if (symbolValueOf) {
1211
+ return symbolValueOf.call(object) == symbolValueOf.call(other);
1212
+ }
1213
+ }
1214
+ return false;
1215
+ }
1216
+
1217
+ /**
1218
+ * A specialized version of `baseIsEqualDeep` for objects with support for
1219
+ * partial deep comparisons.
1220
+ *
1221
+ * @private
1222
+ * @param {Object} object The object to compare.
1223
+ * @param {Object} other The other object to compare.
1224
+ * @param {number} bitmask The bitmask flags. See `baseIsEqual` for more details.
1225
+ * @param {Function} customizer The function to customize comparisons.
1226
+ * @param {Function} equalFunc The function to determine equivalents of values.
1227
+ * @param {Object} stack Tracks traversed `object` and `other` objects.
1228
+ * @returns {boolean} Returns `true` if the objects are equivalent, else `false`.
1229
+ */
1230
+ function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
1231
+ var isPartial = bitmask & COMPARE_PARTIAL_FLAG,
1232
+ objProps = getAllKeys(object),
1233
+ objLength = objProps.length,
1234
+ othProps = getAllKeys(other),
1235
+ othLength = othProps.length;
1236
+
1237
+ if (objLength != othLength && !isPartial) {
1238
+ return false;
1239
+ }
1240
+ var index = objLength;
1241
+ while (index--) {
1242
+ var key = objProps[index];
1243
+ if (!(isPartial ? key in other : hasOwnProperty.call(other, key))) {
1244
+ return false;
1245
+ }
1246
+ }
1247
+ // Assume cyclic values are equal.
1248
+ var stacked = stack.get(object);
1249
+ if (stacked && stack.get(other)) {
1250
+ return stacked == other;
1251
+ }
1252
+ var result = true;
1253
+ stack.set(object, other);
1254
+ stack.set(other, object);
1255
+
1256
+ var skipCtor = isPartial;
1257
+ while (++index < objLength) {
1258
+ key = objProps[index];
1259
+ var objValue = object[key],
1260
+ othValue = other[key];
1261
+
1262
+ if (customizer) {
1263
+ var compared = isPartial
1264
+ ? customizer(othValue, objValue, key, other, object, stack)
1265
+ : customizer(objValue, othValue, key, object, other, stack);
1266
+ }
1267
+ // Recursively compare objects (susceptible to call stack limits).
1268
+ if (!(compared === undefined
1269
+ ? (objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack))
1270
+ : compared
1271
+ )) {
1272
+ result = false;
1273
+ break;
1274
+ }
1275
+ skipCtor || (skipCtor = key == 'constructor');
1276
+ }
1277
+ if (result && !skipCtor) {
1278
+ var objCtor = object.constructor,
1279
+ othCtor = other.constructor;
1280
+
1281
+ // Non `Object` object instances with different constructors are not equal.
1282
+ if (objCtor != othCtor &&
1283
+ ('constructor' in object && 'constructor' in other) &&
1284
+ !(typeof objCtor == 'function' && objCtor instanceof objCtor &&
1285
+ typeof othCtor == 'function' && othCtor instanceof othCtor)) {
1286
+ result = false;
1287
+ }
1288
+ }
1289
+ stack['delete'](object);
1290
+ stack['delete'](other);
1291
+ return result;
1292
+ }
1293
+
1294
+ /**
1295
+ * Creates an array of own enumerable property names and symbols of `object`.
1296
+ *
1297
+ * @private
1298
+ * @param {Object} object The object to query.
1299
+ * @returns {Array} Returns the array of property names and symbols.
1300
+ */
1301
+ function getAllKeys(object) {
1302
+ return baseGetAllKeys(object, keys, getSymbols);
1303
+ }
1304
+
1305
+ /**
1306
+ * Gets the data for `map`.
1307
+ *
1308
+ * @private
1309
+ * @param {Object} map The map to query.
1310
+ * @param {string} key The reference key.
1311
+ * @returns {*} Returns the map data.
1312
+ */
1313
+ function getMapData(map, key) {
1314
+ var data = map.__data__;
1315
+ return isKeyable(key)
1316
+ ? data[typeof key == 'string' ? 'string' : 'hash']
1317
+ : data.map;
1318
+ }
1319
+
1320
+ /**
1321
+ * Gets the native function at `key` of `object`.
1322
+ *
1323
+ * @private
1324
+ * @param {Object} object The object to query.
1325
+ * @param {string} key The key of the method to get.
1326
+ * @returns {*} Returns the function if it's native, else `undefined`.
1327
+ */
1328
+ function getNative(object, key) {
1329
+ var value = getValue(object, key);
1330
+ return baseIsNative(value) ? value : undefined;
1331
+ }
1332
+
1333
+ /**
1334
+ * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
1335
+ *
1336
+ * @private
1337
+ * @param {*} value The value to query.
1338
+ * @returns {string} Returns the raw `toStringTag`.
1339
+ */
1340
+ function getRawTag(value) {
1341
+ var isOwn = hasOwnProperty.call(value, symToStringTag),
1342
+ tag = value[symToStringTag];
1343
+
1344
+ try {
1345
+ value[symToStringTag] = undefined;
1346
+ var unmasked = true;
1347
+ } catch (e) {}
1348
+
1349
+ var result = nativeObjectToString.call(value);
1350
+ if (unmasked) {
1351
+ if (isOwn) {
1352
+ value[symToStringTag] = tag;
1353
+ } else {
1354
+ delete value[symToStringTag];
1355
+ }
1356
+ }
1357
+ return result;
1358
+ }
1359
+
1360
+ /**
1361
+ * Creates an array of the own enumerable symbols of `object`.
1362
+ *
1363
+ * @private
1364
+ * @param {Object} object The object to query.
1365
+ * @returns {Array} Returns the array of symbols.
1366
+ */
1367
+ var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
1368
+ if (object == null) {
1369
+ return [];
1370
+ }
1371
+ object = Object(object);
1372
+ return arrayFilter(nativeGetSymbols(object), function(symbol) {
1373
+ return propertyIsEnumerable.call(object, symbol);
1374
+ });
1375
+ };
1376
+
1377
+ /**
1378
+ * Gets the `toStringTag` of `value`.
1379
+ *
1380
+ * @private
1381
+ * @param {*} value The value to query.
1382
+ * @returns {string} Returns the `toStringTag`.
1383
+ */
1384
+ var getTag = baseGetTag;
1385
+
1386
+ // Fallback for data views, maps, sets, and weak maps in IE 11 and promises in Node.js < 6.
1387
+ if ((DataView && getTag(new DataView(new ArrayBuffer(1))) != dataViewTag) ||
1388
+ (Map && getTag(new Map) != mapTag) ||
1389
+ (Promise && getTag(Promise.resolve()) != promiseTag) ||
1390
+ (Set && getTag(new Set) != setTag) ||
1391
+ (WeakMap && getTag(new WeakMap) != weakMapTag)) {
1392
+ getTag = function(value) {
1393
+ var result = baseGetTag(value),
1394
+ Ctor = result == objectTag ? value.constructor : undefined,
1395
+ ctorString = Ctor ? toSource(Ctor) : '';
1396
+
1397
+ if (ctorString) {
1398
+ switch (ctorString) {
1399
+ case dataViewCtorString: return dataViewTag;
1400
+ case mapCtorString: return mapTag;
1401
+ case promiseCtorString: return promiseTag;
1402
+ case setCtorString: return setTag;
1403
+ case weakMapCtorString: return weakMapTag;
1404
+ }
1405
+ }
1406
+ return result;
1407
+ };
1408
+ }
1409
+
1410
+ /**
1411
+ * Checks if `value` is a valid array-like index.
1412
+ *
1413
+ * @private
1414
+ * @param {*} value The value to check.
1415
+ * @param {number} [length=MAX_SAFE_INTEGER] The upper bounds of a valid index.
1416
+ * @returns {boolean} Returns `true` if `value` is a valid index, else `false`.
1417
+ */
1418
+ function isIndex(value, length) {
1419
+ length = length == null ? MAX_SAFE_INTEGER : length;
1420
+ return !!length &&
1421
+ (typeof value == 'number' || reIsUint.test(value)) &&
1422
+ (value > -1 && value % 1 == 0 && value < length);
1423
+ }
1424
+
1425
+ /**
1426
+ * Checks if `value` is suitable for use as unique object key.
1427
+ *
1428
+ * @private
1429
+ * @param {*} value The value to check.
1430
+ * @returns {boolean} Returns `true` if `value` is suitable, else `false`.
1431
+ */
1432
+ function isKeyable(value) {
1433
+ var type = typeof value;
1434
+ return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
1435
+ ? (value !== '__proto__')
1436
+ : (value === null);
1437
+ }
1438
+
1439
+ /**
1440
+ * Checks if `func` has its source masked.
1441
+ *
1442
+ * @private
1443
+ * @param {Function} func The function to check.
1444
+ * @returns {boolean} Returns `true` if `func` is masked, else `false`.
1445
+ */
1446
+ function isMasked(func) {
1447
+ return !!maskSrcKey && (maskSrcKey in func);
1448
+ }
1449
+
1450
+ /**
1451
+ * Checks if `value` is likely a prototype object.
1452
+ *
1453
+ * @private
1454
+ * @param {*} value The value to check.
1455
+ * @returns {boolean} Returns `true` if `value` is a prototype, else `false`.
1456
+ */
1457
+ function isPrototype(value) {
1458
+ var Ctor = value && value.constructor,
1459
+ proto = (typeof Ctor == 'function' && Ctor.prototype) || objectProto;
1460
+
1461
+ return value === proto;
1462
+ }
1463
+
1464
+ /**
1465
+ * Converts `value` to a string using `Object.prototype.toString`.
1466
+ *
1467
+ * @private
1468
+ * @param {*} value The value to convert.
1469
+ * @returns {string} Returns the converted string.
1470
+ */
1471
+ function objectToString(value) {
1472
+ return nativeObjectToString.call(value);
1473
+ }
1474
+
1475
+ /**
1476
+ * Converts `func` to its source code.
1477
+ *
1478
+ * @private
1479
+ * @param {Function} func The function to convert.
1480
+ * @returns {string} Returns the source code.
1481
+ */
1482
+ function toSource(func) {
1483
+ if (func != null) {
1484
+ try {
1485
+ return funcToString.call(func);
1486
+ } catch (e) {}
1487
+ try {
1488
+ return (func + '');
1489
+ } catch (e) {}
1490
+ }
1491
+ return '';
1492
+ }
1493
+
1494
+ /**
1495
+ * Performs a
1496
+ * [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
1497
+ * comparison between two values to determine if they are equivalent.
1498
+ *
1499
+ * @static
1500
+ * @memberOf _
1501
+ * @since 4.0.0
1502
+ * @category Lang
1503
+ * @param {*} value The value to compare.
1504
+ * @param {*} other The other value to compare.
1505
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1506
+ * @example
1507
+ *
1508
+ * var object = { 'a': 1 };
1509
+ * var other = { 'a': 1 };
1510
+ *
1511
+ * _.eq(object, object);
1512
+ * // => true
1513
+ *
1514
+ * _.eq(object, other);
1515
+ * // => false
1516
+ *
1517
+ * _.eq('a', 'a');
1518
+ * // => true
1519
+ *
1520
+ * _.eq('a', Object('a'));
1521
+ * // => false
1522
+ *
1523
+ * _.eq(NaN, NaN);
1524
+ * // => true
1525
+ */
1526
+ function eq(value, other) {
1527
+ return value === other || (value !== value && other !== other);
1528
+ }
1529
+
1530
+ /**
1531
+ * Checks if `value` is likely an `arguments` object.
1532
+ *
1533
+ * @static
1534
+ * @memberOf _
1535
+ * @since 0.1.0
1536
+ * @category Lang
1537
+ * @param {*} value The value to check.
1538
+ * @returns {boolean} Returns `true` if `value` is an `arguments` object,
1539
+ * else `false`.
1540
+ * @example
1541
+ *
1542
+ * _.isArguments(function() { return arguments; }());
1543
+ * // => true
1544
+ *
1545
+ * _.isArguments([1, 2, 3]);
1546
+ * // => false
1547
+ */
1548
+ var isArguments = baseIsArguments(function() { return arguments; }()) ? baseIsArguments : function(value) {
1549
+ return isObjectLike(value) && hasOwnProperty.call(value, 'callee') &&
1550
+ !propertyIsEnumerable.call(value, 'callee');
1551
+ };
1552
+
1553
+ /**
1554
+ * Checks if `value` is classified as an `Array` object.
1555
+ *
1556
+ * @static
1557
+ * @memberOf _
1558
+ * @since 0.1.0
1559
+ * @category Lang
1560
+ * @param {*} value The value to check.
1561
+ * @returns {boolean} Returns `true` if `value` is an array, else `false`.
1562
+ * @example
1563
+ *
1564
+ * _.isArray([1, 2, 3]);
1565
+ * // => true
1566
+ *
1567
+ * _.isArray(document.body.children);
1568
+ * // => false
1569
+ *
1570
+ * _.isArray('abc');
1571
+ * // => false
1572
+ *
1573
+ * _.isArray(_.noop);
1574
+ * // => false
1575
+ */
1576
+ var isArray = Array.isArray;
1577
+
1578
+ /**
1579
+ * Checks if `value` is array-like. A value is considered array-like if it's
1580
+ * not a function and has a `value.length` that's an integer greater than or
1581
+ * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
1582
+ *
1583
+ * @static
1584
+ * @memberOf _
1585
+ * @since 4.0.0
1586
+ * @category Lang
1587
+ * @param {*} value The value to check.
1588
+ * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
1589
+ * @example
1590
+ *
1591
+ * _.isArrayLike([1, 2, 3]);
1592
+ * // => true
1593
+ *
1594
+ * _.isArrayLike(document.body.children);
1595
+ * // => true
1596
+ *
1597
+ * _.isArrayLike('abc');
1598
+ * // => true
1599
+ *
1600
+ * _.isArrayLike(_.noop);
1601
+ * // => false
1602
+ */
1603
+ function isArrayLike(value) {
1604
+ return value != null && isLength(value.length) && !isFunction(value);
1605
+ }
1606
+
1607
+ /**
1608
+ * Checks if `value` is a buffer.
1609
+ *
1610
+ * @static
1611
+ * @memberOf _
1612
+ * @since 4.3.0
1613
+ * @category Lang
1614
+ * @param {*} value The value to check.
1615
+ * @returns {boolean} Returns `true` if `value` is a buffer, else `false`.
1616
+ * @example
1617
+ *
1618
+ * _.isBuffer(new Buffer(2));
1619
+ * // => true
1620
+ *
1621
+ * _.isBuffer(new Uint8Array(2));
1622
+ * // => false
1623
+ */
1624
+ var isBuffer = nativeIsBuffer || stubFalse;
1625
+
1626
+ /**
1627
+ * Performs a deep comparison between two values to determine if they are
1628
+ * equivalent.
1629
+ *
1630
+ * **Note:** This method supports comparing arrays, array buffers, booleans,
1631
+ * date objects, error objects, maps, numbers, `Object` objects, regexes,
1632
+ * sets, strings, symbols, and typed arrays. `Object` objects are compared
1633
+ * by their own, not inherited, enumerable properties. Functions and DOM
1634
+ * nodes are compared by strict equality, i.e. `===`.
1635
+ *
1636
+ * @static
1637
+ * @memberOf _
1638
+ * @since 0.1.0
1639
+ * @category Lang
1640
+ * @param {*} value The value to compare.
1641
+ * @param {*} other The other value to compare.
1642
+ * @returns {boolean} Returns `true` if the values are equivalent, else `false`.
1643
+ * @example
1644
+ *
1645
+ * var object = { 'a': 1 };
1646
+ * var other = { 'a': 1 };
1647
+ *
1648
+ * _.isEqual(object, other);
1649
+ * // => true
1650
+ *
1651
+ * object === other;
1652
+ * // => false
1653
+ */
1654
+ function isEqual(value, other) {
1655
+ return baseIsEqual(value, other);
1656
+ }
1657
+
1658
+ /**
1659
+ * Checks if `value` is classified as a `Function` object.
1660
+ *
1661
+ * @static
1662
+ * @memberOf _
1663
+ * @since 0.1.0
1664
+ * @category Lang
1665
+ * @param {*} value The value to check.
1666
+ * @returns {boolean} Returns `true` if `value` is a function, else `false`.
1667
+ * @example
1668
+ *
1669
+ * _.isFunction(_);
1670
+ * // => true
1671
+ *
1672
+ * _.isFunction(/abc/);
1673
+ * // => false
1674
+ */
1675
+ function isFunction(value) {
1676
+ if (!isObject(value)) {
1677
+ return false;
1678
+ }
1679
+ // The use of `Object#toString` avoids issues with the `typeof` operator
1680
+ // in Safari 9 which returns 'object' for typed arrays and other constructors.
1681
+ var tag = baseGetTag(value);
1682
+ return tag == funcTag || tag == genTag || tag == asyncTag || tag == proxyTag;
1683
+ }
1684
+
1685
+ /**
1686
+ * Checks if `value` is a valid array-like length.
1687
+ *
1688
+ * **Note:** This method is loosely based on
1689
+ * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
1690
+ *
1691
+ * @static
1692
+ * @memberOf _
1693
+ * @since 4.0.0
1694
+ * @category Lang
1695
+ * @param {*} value The value to check.
1696
+ * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
1697
+ * @example
1698
+ *
1699
+ * _.isLength(3);
1700
+ * // => true
1701
+ *
1702
+ * _.isLength(Number.MIN_VALUE);
1703
+ * // => false
1704
+ *
1705
+ * _.isLength(Infinity);
1706
+ * // => false
1707
+ *
1708
+ * _.isLength('3');
1709
+ * // => false
1710
+ */
1711
+ function isLength(value) {
1712
+ return typeof value == 'number' &&
1713
+ value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
1714
+ }
1715
+
1716
+ /**
1717
+ * Checks if `value` is the
1718
+ * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
1719
+ * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
1720
+ *
1721
+ * @static
1722
+ * @memberOf _
1723
+ * @since 0.1.0
1724
+ * @category Lang
1725
+ * @param {*} value The value to check.
1726
+ * @returns {boolean} Returns `true` if `value` is an object, else `false`.
1727
+ * @example
1728
+ *
1729
+ * _.isObject({});
1730
+ * // => true
1731
+ *
1732
+ * _.isObject([1, 2, 3]);
1733
+ * // => true
1734
+ *
1735
+ * _.isObject(_.noop);
1736
+ * // => true
1737
+ *
1738
+ * _.isObject(null);
1739
+ * // => false
1740
+ */
1741
+ function isObject(value) {
1742
+ var type = typeof value;
1743
+ return value != null && (type == 'object' || type == 'function');
1744
+ }
1745
+
1746
+ /**
1747
+ * Checks if `value` is object-like. A value is object-like if it's not `null`
1748
+ * and has a `typeof` result of "object".
1749
+ *
1750
+ * @static
1751
+ * @memberOf _
1752
+ * @since 4.0.0
1753
+ * @category Lang
1754
+ * @param {*} value The value to check.
1755
+ * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
1756
+ * @example
1757
+ *
1758
+ * _.isObjectLike({});
1759
+ * // => true
1760
+ *
1761
+ * _.isObjectLike([1, 2, 3]);
1762
+ * // => true
1763
+ *
1764
+ * _.isObjectLike(_.noop);
1765
+ * // => false
1766
+ *
1767
+ * _.isObjectLike(null);
1768
+ * // => false
1769
+ */
1770
+ function isObjectLike(value) {
1771
+ return value != null && typeof value == 'object';
1772
+ }
1773
+
1774
+ /**
1775
+ * Checks if `value` is classified as a typed array.
1776
+ *
1777
+ * @static
1778
+ * @memberOf _
1779
+ * @since 3.0.0
1780
+ * @category Lang
1781
+ * @param {*} value The value to check.
1782
+ * @returns {boolean} Returns `true` if `value` is a typed array, else `false`.
1783
+ * @example
1784
+ *
1785
+ * _.isTypedArray(new Uint8Array);
1786
+ * // => true
1787
+ *
1788
+ * _.isTypedArray([]);
1789
+ * // => false
1790
+ */
1791
+ var isTypedArray = nodeIsTypedArray ? baseUnary(nodeIsTypedArray) : baseIsTypedArray;
1792
+
1793
+ /**
1794
+ * Creates an array of the own enumerable property names of `object`.
1795
+ *
1796
+ * **Note:** Non-object values are coerced to objects. See the
1797
+ * [ES spec](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
1798
+ * for more details.
1799
+ *
1800
+ * @static
1801
+ * @since 0.1.0
1802
+ * @memberOf _
1803
+ * @category Object
1804
+ * @param {Object} object The object to query.
1805
+ * @returns {Array} Returns the array of property names.
1806
+ * @example
1807
+ *
1808
+ * function Foo() {
1809
+ * this.a = 1;
1810
+ * this.b = 2;
1811
+ * }
1812
+ *
1813
+ * Foo.prototype.c = 3;
1814
+ *
1815
+ * _.keys(new Foo);
1816
+ * // => ['a', 'b'] (iteration order is not guaranteed)
1817
+ *
1818
+ * _.keys('hi');
1819
+ * // => ['0', '1']
1820
+ */
1821
+ function keys(object) {
1822
+ return isArrayLike(object) ? arrayLikeKeys(object) : baseKeys(object);
1823
+ }
1824
+
1825
+ /**
1826
+ * This method returns a new empty array.
1827
+ *
1828
+ * @static
1829
+ * @memberOf _
1830
+ * @since 4.13.0
1831
+ * @category Util
1832
+ * @returns {Array} Returns the new empty array.
1833
+ * @example
1834
+ *
1835
+ * var arrays = _.times(2, _.stubArray);
1836
+ *
1837
+ * console.log(arrays);
1838
+ * // => [[], []]
1839
+ *
1840
+ * console.log(arrays[0] === arrays[1]);
1841
+ * // => false
1842
+ */
1843
+ function stubArray() {
1844
+ return [];
1845
+ }
1846
+
1847
+ /**
1848
+ * This method returns `false`.
1849
+ *
1850
+ * @static
1851
+ * @memberOf _
1852
+ * @since 4.13.0
1853
+ * @category Util
1854
+ * @returns {boolean} Returns `false`.
1855
+ * @example
1856
+ *
1857
+ * _.times(2, _.stubFalse);
1858
+ * // => [false, false]
1859
+ */
1860
+ function stubFalse() {
1861
+ return false;
1862
+ }
1863
+
1864
+ module.exports = isEqual;
1865
+ } (lodash_isequal, lodash_isequal.exports));
1866
+
1867
+ var lodash_isequalExports = lodash_isequal.exports;
1868
+ var isEqual = /*@__PURE__*/getDefaultExportFromCjs(lodash_isequalExports);
1869
+
1870
+ function circleLayer(color, source, vectorLayer) {
1871
+ const layer = {
1872
+ id: [source, vectorLayer, 'circle'].join('_'),
1873
+ source,
1874
+ type: 'circle',
1875
+ paint: {
1876
+ 'circle-color': color,
1877
+ 'circle-radius': 2
1878
+ },
1879
+ filter: ['==', '$type', 'Point']
1880
+ };
1881
+ if (vectorLayer) {
1882
+ layer['source-layer'] = vectorLayer;
1883
+ }
1884
+ return layer;
1885
+ }
1886
+ function polygonLayer(color, _outlineColor, source, vectorLayer) {
1887
+ const layer = {
1888
+ id: [source, vectorLayer, 'polygon'].join('_'),
1889
+ source,
1890
+ type: 'fill',
1891
+ paint: {
1892
+ 'fill-color': color,
1893
+ 'fill-antialias': true,
1894
+ 'fill-outline-color': color
1895
+ },
1896
+ filter: ['==', '$type', 'Polygon']
1897
+ };
1898
+ if (vectorLayer) {
1899
+ layer['source-layer'] = vectorLayer;
1900
+ }
1901
+ return layer;
1902
+ }
1903
+ function lineLayer(color, source, vectorLayer) {
1904
+ const layer = {
1905
+ id: [source, vectorLayer, 'line'].join('_'),
1906
+ source,
1907
+ layout: {
1908
+ 'line-join': 'round',
1909
+ 'line-cap': 'round'
1910
+ },
1911
+ type: 'line',
1912
+ paint: {
1913
+ 'line-color': color
1914
+ },
1915
+ filter: ['==', '$type', 'LineString']
1916
+ };
1917
+ if (vectorLayer) {
1918
+ layer['source-layer'] = vectorLayer;
1919
+ }
1920
+ return layer;
1921
+ }
1922
+ /**
1923
+ * Generate colored layer styles for the given sources
1924
+ * @param sources dictionary containing the vector layer IDs
1925
+ * @param Function to generate a color for a layer
1926
+ * @return Array of Maplibre GL layers
1927
+ */
1928
+ function generateColoredLayers(sources, assignLayerColor) {
1929
+ const polyLayers = [];
1930
+ const circleLayers = [];
1931
+ const lineLayers = [];
1932
+ function alphaColors(layerId) {
1933
+ const obj = {
1934
+ circle: assignLayerColor(layerId, 0.8),
1935
+ line: assignLayerColor(layerId, 0.6),
1936
+ polygon: assignLayerColor(layerId, 0.3),
1937
+ polygonOutline: assignLayerColor(layerId, 0.6),
1938
+ default: assignLayerColor(layerId, 1)
1939
+ };
1940
+ return obj;
1941
+ }
1942
+ Object.keys(sources).forEach((sourceId) => {
1943
+ const layers = sources[sourceId];
1944
+ if (!layers || layers.length === 0) {
1945
+ const colors = alphaColors(sourceId);
1946
+ circleLayers.push(circleLayer(colors.circle, sourceId));
1947
+ lineLayers.push(lineLayer(colors.line, sourceId));
1948
+ polyLayers.push(polygonLayer(colors.polygon, colors.polygonOutline, sourceId));
1949
+ }
1950
+ else {
1951
+ layers.forEach((layerId) => {
1952
+ const colors = alphaColors(layerId);
1953
+ circleLayers.push(circleLayer(colors.circle, sourceId, layerId));
1954
+ lineLayers.push(lineLayer(colors.line, sourceId, layerId));
1955
+ polyLayers.push(polygonLayer(colors.polygon, colors.polygonOutline, sourceId, layerId));
1956
+ });
1957
+ }
1958
+ });
1959
+ return polyLayers.concat(lineLayers).concat(circleLayers);
1960
+ }
1961
+ /**
1962
+ * Create inspection style out of the original style and the new colored layers
1963
+ * @param originalMapStyle - map style
1964
+ * @param coloredLayers - array of colored Maplibre GL layers
1965
+ * @param opts - options
1966
+ * @return {Object} Colored inspect style
1967
+ */
1968
+ function generateInspectStyle(originalMapStyle, coloredLayers, opts) {
1969
+ opts = Object.assign({
1970
+ backgroundColor: '#fff'
1971
+ }, opts);
1972
+ const backgroundLayer = {
1973
+ 'id': 'background',
1974
+ 'type': 'background',
1975
+ 'paint': {
1976
+ 'background-color': opts.backgroundColor
1977
+ }
1978
+ };
1979
+ const sources = {};
1980
+ Object.keys(originalMapStyle.sources).forEach((sourceId) => {
1981
+ const source = originalMapStyle.sources[sourceId];
1982
+ if (source.type === 'vector' || source.type === 'geojson') {
1983
+ sources[sourceId] = source;
1984
+ }
1985
+ });
1986
+ return Object.assign(originalMapStyle, {
1987
+ layers: [backgroundLayer].concat(coloredLayers),
1988
+ sources
1989
+ });
1990
+ }
1991
+ var stylegen = {
1992
+ polygonLayer,
1993
+ lineLayer,
1994
+ circleLayer,
1995
+ generateInspectStyle,
1996
+ generateColoredLayers
1997
+ };
1998
+
1999
+ /**
2000
+ * A button to toggle the inspect mode
2001
+ */
2002
+ class InspectButton {
2003
+ constructor(options) {
2004
+ options = Object.assign({
2005
+ show: true,
2006
+ onToggle() { }
2007
+ }, options);
2008
+ this._btn = this.createButton();
2009
+ this._btn.onclick = options.onToggle;
2010
+ this.elem = this.createContainer(this._btn, options.show);
2011
+ }
2012
+ createButton() {
2013
+ const btn = document.createElement('button');
2014
+ btn.className = 'maplibregl-ctrl-icon maplibregl-ctrl-inspect';
2015
+ btn.type = 'button';
2016
+ btn.setAttribute('aria-label', 'Inspect');
2017
+ return btn;
2018
+ }
2019
+ createContainer(child, show) {
2020
+ const container = document.createElement('div');
2021
+ container.className = 'maplibregl-ctrl maplibregl-ctrl-group';
2022
+ container.appendChild(child);
2023
+ if (!show) {
2024
+ container.style.display = 'none';
2025
+ }
2026
+ return container;
2027
+ }
2028
+ setInspectIcon() {
2029
+ this._btn.className = 'maplibregl-ctrl-icon maplibregl-ctrl-inspect';
2030
+ }
2031
+ setMapIcon() {
2032
+ this._btn.className = 'maplibregl-ctrl-icon maplibregl-ctrl-map';
2033
+ }
2034
+ }
2035
+
2036
+ function displayValue(value) {
2037
+ if (typeof value === 'undefined' || value === null)
2038
+ return value;
2039
+ if (value instanceof Date)
2040
+ return value.toLocaleString();
2041
+ if (typeof value === 'object' ||
2042
+ typeof value === 'number' ||
2043
+ typeof value === 'string')
2044
+ return value.toString();
2045
+ return value;
2046
+ }
2047
+ function renderProperty(propertyName, property) {
2048
+ return `${'<div class="maplibregl-inspect_property">' +
2049
+ '<div class="maplibregl-inspect_property-name">'}${propertyName}</div>` +
2050
+ `<div class="maplibregl-inspect_property-value">${displayValue(property)}</div>` +
2051
+ '</div>';
2052
+ }
2053
+ function renderLayer(layerId) {
2054
+ return `<div class="maplibregl-inspect_layer">${layerId}</div>`;
2055
+ }
2056
+ function renderProperties(feature) {
2057
+ const sourceProperty = renderLayer(feature.layer['source-layer'] || feature.layer.source);
2058
+ const idProperty = renderProperty('$id', feature.id);
2059
+ const typeProperty = renderProperty('$type', feature.geometry.type);
2060
+ const properties = Object.keys(feature.properties).map(propertyName => renderProperty(propertyName, feature.properties[propertyName]));
2061
+ return [sourceProperty, idProperty, typeProperty].concat(properties).join('');
2062
+ }
2063
+ function renderFeatures(features) {
2064
+ return features.map(ft => `<div class="maplibregl-inspect_feature">${renderProperties(ft)}</div>`).join('');
2065
+ }
2066
+ function renderPopup(features) {
2067
+ return `<div class="maplibregl-inspect_popup">${renderFeatures(features)}</div>`;
2068
+ }
2069
+
2070
+ var randomColor$1 = {exports: {}};
2071
+
2072
+ (function (module, exports) {
2073
+ (function(root, factory) {
2074
+
2075
+ // Support CommonJS
2076
+ {
2077
+ var randomColor = factory();
2078
+
2079
+ // Support NodeJS & Component, which allow module.exports to be a function
2080
+ if (module && module.exports) {
2081
+ exports = module.exports = randomColor;
2082
+ }
2083
+
2084
+ // Support CommonJS 1.1.1 spec
2085
+ exports.randomColor = randomColor;
2086
+
2087
+ // Support AMD
2088
+ }
2089
+
2090
+ }(commonjsGlobal, function() {
2091
+
2092
+ // Seed to get repeatable colors
2093
+ var seed = null;
2094
+
2095
+ // Shared color dictionary
2096
+ var colorDictionary = {};
2097
+
2098
+ // Populate the color dictionary
2099
+ loadColorBounds();
2100
+
2101
+ // check if a range is taken
2102
+ var colorRanges = [];
2103
+
2104
+ var randomColor = function (options) {
2105
+
2106
+ options = options || {};
2107
+
2108
+ // Check if there is a seed and ensure it's an
2109
+ // integer. Otherwise, reset the seed value.
2110
+ if (options.seed !== undefined && options.seed !== null && options.seed === parseInt(options.seed, 10)) {
2111
+ seed = options.seed;
2112
+
2113
+ // A string was passed as a seed
2114
+ } else if (typeof options.seed === 'string') {
2115
+ seed = stringToInteger(options.seed);
2116
+
2117
+ // Something was passed as a seed but it wasn't an integer or string
2118
+ } else if (options.seed !== undefined && options.seed !== null) {
2119
+ throw new TypeError('The seed value must be an integer or string');
2120
+
2121
+ // No seed, reset the value outside.
2122
+ } else {
2123
+ seed = null;
2124
+ }
2125
+
2126
+ var H,S,B;
2127
+
2128
+ // Check if we need to generate multiple colors
2129
+ if (options.count !== null && options.count !== undefined) {
2130
+
2131
+ var totalColors = options.count,
2132
+ colors = [];
2133
+ // Value false at index i means the range i is not taken yet.
2134
+ for (var i = 0; i < options.count; i++) {
2135
+ colorRanges.push(false);
2136
+ }
2137
+ options.count = null;
2138
+
2139
+ while (totalColors > colors.length) {
2140
+
2141
+ var color = randomColor(options);
2142
+
2143
+ if (seed !== null) {
2144
+ options.seed = seed;
2145
+ }
2146
+
2147
+ colors.push(color);
2148
+ }
2149
+
2150
+ options.count = totalColors;
2151
+
2152
+ return colors;
2153
+ }
2154
+
2155
+ // First we pick a hue (H)
2156
+ H = pickHue(options);
2157
+
2158
+ // Then use H to determine saturation (S)
2159
+ S = pickSaturation(H, options);
2160
+
2161
+ // Then use S and H to determine brightness (B).
2162
+ B = pickBrightness(H, S, options);
2163
+
2164
+ // Then we return the HSB color in the desired format
2165
+ return setFormat([H,S,B], options);
2166
+ };
2167
+
2168
+ function pickHue(options) {
2169
+ if (colorRanges.length > 0) {
2170
+ var hueRange = getRealHueRange(options.hue);
2171
+
2172
+ var hue = randomWithin(hueRange);
2173
+
2174
+ //Each of colorRanges.length ranges has a length equal approximatelly one step
2175
+ var step = (hueRange[1] - hueRange[0]) / colorRanges.length;
2176
+
2177
+ var j = parseInt((hue - hueRange[0]) / step);
2178
+
2179
+ //Check if the range j is taken
2180
+ if (colorRanges[j] === true) {
2181
+ j = (j + 2) % colorRanges.length;
2182
+ }
2183
+ else {
2184
+ colorRanges[j] = true;
2185
+ }
2186
+
2187
+ var min = (hueRange[0] + j * step) % 359,
2188
+ max = (hueRange[0] + (j + 1) * step) % 359;
2189
+
2190
+ hueRange = [min, max];
2191
+
2192
+ hue = randomWithin(hueRange);
2193
+
2194
+ if (hue < 0) {hue = 360 + hue;}
2195
+ return hue
2196
+ }
2197
+ else {
2198
+ var hueRange = getHueRange(options.hue);
2199
+
2200
+ hue = randomWithin(hueRange);
2201
+ // Instead of storing red as two seperate ranges,
2202
+ // we group them, using negative numbers
2203
+ if (hue < 0) {
2204
+ hue = 360 + hue;
2205
+ }
2206
+
2207
+ return hue;
2208
+ }
2209
+ }
2210
+
2211
+ function pickSaturation (hue, options) {
2212
+
2213
+ if (options.hue === 'monochrome') {
2214
+ return 0;
2215
+ }
2216
+
2217
+ if (options.luminosity === 'random') {
2218
+ return randomWithin([0,100]);
2219
+ }
2220
+
2221
+ var saturationRange = getSaturationRange(hue);
2222
+
2223
+ var sMin = saturationRange[0],
2224
+ sMax = saturationRange[1];
2225
+
2226
+ switch (options.luminosity) {
2227
+
2228
+ case 'bright':
2229
+ sMin = 55;
2230
+ break;
2231
+
2232
+ case 'dark':
2233
+ sMin = sMax - 10;
2234
+ break;
2235
+
2236
+ case 'light':
2237
+ sMax = 55;
2238
+ break;
2239
+ }
2240
+
2241
+ return randomWithin([sMin, sMax]);
2242
+
2243
+ }
2244
+
2245
+ function pickBrightness (H, S, options) {
2246
+
2247
+ var bMin = getMinimumBrightness(H, S),
2248
+ bMax = 100;
2249
+
2250
+ switch (options.luminosity) {
2251
+
2252
+ case 'dark':
2253
+ bMax = bMin + 20;
2254
+ break;
2255
+
2256
+ case 'light':
2257
+ bMin = (bMax + bMin)/2;
2258
+ break;
2259
+
2260
+ case 'random':
2261
+ bMin = 0;
2262
+ bMax = 100;
2263
+ break;
2264
+ }
2265
+
2266
+ return randomWithin([bMin, bMax]);
2267
+ }
2268
+
2269
+ function setFormat (hsv, options) {
2270
+
2271
+ switch (options.format) {
2272
+
2273
+ case 'hsvArray':
2274
+ return hsv;
2275
+
2276
+ case 'hslArray':
2277
+ return HSVtoHSL(hsv);
2278
+
2279
+ case 'hsl':
2280
+ var hsl = HSVtoHSL(hsv);
2281
+ return 'hsl('+hsl[0]+', '+hsl[1]+'%, '+hsl[2]+'%)';
2282
+
2283
+ case 'hsla':
2284
+ var hslColor = HSVtoHSL(hsv);
2285
+ var alpha = options.alpha || Math.random();
2286
+ return 'hsla('+hslColor[0]+', '+hslColor[1]+'%, '+hslColor[2]+'%, ' + alpha + ')';
2287
+
2288
+ case 'rgbArray':
2289
+ return HSVtoRGB(hsv);
2290
+
2291
+ case 'rgb':
2292
+ var rgb = HSVtoRGB(hsv);
2293
+ return 'rgb(' + rgb.join(', ') + ')';
2294
+
2295
+ case 'rgba':
2296
+ var rgbColor = HSVtoRGB(hsv);
2297
+ var alpha = options.alpha || Math.random();
2298
+ return 'rgba(' + rgbColor.join(', ') + ', ' + alpha + ')';
2299
+
2300
+ default:
2301
+ return HSVtoHex(hsv);
2302
+ }
2303
+
2304
+ }
2305
+
2306
+ function getMinimumBrightness(H, S) {
2307
+
2308
+ var lowerBounds = getColorInfo(H).lowerBounds;
2309
+
2310
+ for (var i = 0; i < lowerBounds.length - 1; i++) {
2311
+
2312
+ var s1 = lowerBounds[i][0],
2313
+ v1 = lowerBounds[i][1];
2314
+
2315
+ var s2 = lowerBounds[i+1][0],
2316
+ v2 = lowerBounds[i+1][1];
2317
+
2318
+ if (S >= s1 && S <= s2) {
2319
+
2320
+ var m = (v2 - v1)/(s2 - s1),
2321
+ b = v1 - m*s1;
2322
+
2323
+ return m*S + b;
2324
+ }
2325
+
2326
+ }
2327
+
2328
+ return 0;
2329
+ }
2330
+
2331
+ function getHueRange (colorInput) {
2332
+
2333
+ if (typeof parseInt(colorInput) === 'number') {
2334
+
2335
+ var number = parseInt(colorInput);
2336
+
2337
+ if (number < 360 && number > 0) {
2338
+ return [number, number];
2339
+ }
2340
+
2341
+ }
2342
+
2343
+ if (typeof colorInput === 'string') {
2344
+
2345
+ if (colorDictionary[colorInput]) {
2346
+ var color = colorDictionary[colorInput];
2347
+ if (color.hueRange) {return color.hueRange;}
2348
+ } else if (colorInput.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) {
2349
+ var hue = HexToHSB(colorInput)[0];
2350
+ return [ hue, hue ];
2351
+ }
2352
+ }
2353
+
2354
+ return [0,360];
2355
+
2356
+ }
2357
+
2358
+ function getSaturationRange (hue) {
2359
+ return getColorInfo(hue).saturationRange;
2360
+ }
2361
+
2362
+ function getColorInfo (hue) {
2363
+
2364
+ // Maps red colors to make picking hue easier
2365
+ if (hue >= 334 && hue <= 360) {
2366
+ hue-= 360;
2367
+ }
2368
+
2369
+ for (var colorName in colorDictionary) {
2370
+ var color = colorDictionary[colorName];
2371
+ if (color.hueRange &&
2372
+ hue >= color.hueRange[0] &&
2373
+ hue <= color.hueRange[1]) {
2374
+ return colorDictionary[colorName];
2375
+ }
2376
+ } return 'Color not found';
2377
+ }
2378
+
2379
+ function randomWithin (range) {
2380
+ if (seed === null) {
2381
+ //generate random evenly destinct number from : https://martin.ankerl.com/2009/12/09/how-to-create-random-colors-programmatically/
2382
+ var golden_ratio = 0.618033988749895;
2383
+ var r=Math.random();
2384
+ r += golden_ratio;
2385
+ r %= 1;
2386
+ return Math.floor(range[0] + r*(range[1] + 1 - range[0]));
2387
+ } else {
2388
+ //Seeded random algorithm from http://indiegamr.com/generate-repeatable-random-numbers-in-js/
2389
+ var max = range[1] || 1;
2390
+ var min = range[0] || 0;
2391
+ seed = (seed * 9301 + 49297) % 233280;
2392
+ var rnd = seed / 233280.0;
2393
+ return Math.floor(min + rnd * (max - min));
2394
+ }
2395
+ }
2396
+
2397
+ function HSVtoHex (hsv){
2398
+
2399
+ var rgb = HSVtoRGB(hsv);
2400
+
2401
+ function componentToHex(c) {
2402
+ var hex = c.toString(16);
2403
+ return hex.length == 1 ? '0' + hex : hex;
2404
+ }
2405
+
2406
+ var hex = '#' + componentToHex(rgb[0]) + componentToHex(rgb[1]) + componentToHex(rgb[2]);
2407
+
2408
+ return hex;
2409
+
2410
+ }
2411
+
2412
+ function defineColor (name, hueRange, lowerBounds) {
2413
+
2414
+ var sMin = lowerBounds[0][0],
2415
+ sMax = lowerBounds[lowerBounds.length - 1][0],
2416
+
2417
+ bMin = lowerBounds[lowerBounds.length - 1][1],
2418
+ bMax = lowerBounds[0][1];
2419
+
2420
+ colorDictionary[name] = {
2421
+ hueRange: hueRange,
2422
+ lowerBounds: lowerBounds,
2423
+ saturationRange: [sMin, sMax],
2424
+ brightnessRange: [bMin, bMax]
2425
+ };
2426
+
2427
+ }
2428
+
2429
+ function loadColorBounds () {
2430
+
2431
+ defineColor(
2432
+ 'monochrome',
2433
+ null,
2434
+ [[0,0],[100,0]]
2435
+ );
2436
+
2437
+ defineColor(
2438
+ 'red',
2439
+ [-26,18],
2440
+ [[20,100],[30,92],[40,89],[50,85],[60,78],[70,70],[80,60],[90,55],[100,50]]
2441
+ );
2442
+
2443
+ defineColor(
2444
+ 'orange',
2445
+ [18,46],
2446
+ [[20,100],[30,93],[40,88],[50,86],[60,85],[70,70],[100,70]]
2447
+ );
2448
+
2449
+ defineColor(
2450
+ 'yellow',
2451
+ [46,62],
2452
+ [[25,100],[40,94],[50,89],[60,86],[70,84],[80,82],[90,80],[100,75]]
2453
+ );
2454
+
2455
+ defineColor(
2456
+ 'green',
2457
+ [62,178],
2458
+ [[30,100],[40,90],[50,85],[60,81],[70,74],[80,64],[90,50],[100,40]]
2459
+ );
2460
+
2461
+ defineColor(
2462
+ 'blue',
2463
+ [178, 257],
2464
+ [[20,100],[30,86],[40,80],[50,74],[60,60],[70,52],[80,44],[90,39],[100,35]]
2465
+ );
2466
+
2467
+ defineColor(
2468
+ 'purple',
2469
+ [257, 282],
2470
+ [[20,100],[30,87],[40,79],[50,70],[60,65],[70,59],[80,52],[90,45],[100,42]]
2471
+ );
2472
+
2473
+ defineColor(
2474
+ 'pink',
2475
+ [282, 334],
2476
+ [[20,100],[30,90],[40,86],[60,84],[80,80],[90,75],[100,73]]
2477
+ );
2478
+
2479
+ }
2480
+
2481
+ function HSVtoRGB (hsv) {
2482
+
2483
+ // this doesn't work for the values of 0 and 360
2484
+ // here's the hacky fix
2485
+ var h = hsv[0];
2486
+ if (h === 0) {h = 1;}
2487
+ if (h === 360) {h = 359;}
2488
+
2489
+ // Rebase the h,s,v values
2490
+ h = h/360;
2491
+ var s = hsv[1]/100,
2492
+ v = hsv[2]/100;
2493
+
2494
+ var h_i = Math.floor(h*6),
2495
+ f = h * 6 - h_i,
2496
+ p = v * (1 - s),
2497
+ q = v * (1 - f*s),
2498
+ t = v * (1 - (1 - f)*s),
2499
+ r = 256,
2500
+ g = 256,
2501
+ b = 256;
2502
+
2503
+ switch(h_i) {
2504
+ case 0: r = v; g = t; b = p; break;
2505
+ case 1: r = q; g = v; b = p; break;
2506
+ case 2: r = p; g = v; b = t; break;
2507
+ case 3: r = p; g = q; b = v; break;
2508
+ case 4: r = t; g = p; b = v; break;
2509
+ case 5: r = v; g = p; b = q; break;
2510
+ }
2511
+
2512
+ var result = [Math.floor(r*255), Math.floor(g*255), Math.floor(b*255)];
2513
+ return result;
2514
+ }
2515
+
2516
+ function HexToHSB (hex) {
2517
+ hex = hex.replace(/^#/, '');
2518
+ hex = hex.length === 3 ? hex.replace(/(.)/g, '$1$1') : hex;
2519
+
2520
+ var red = parseInt(hex.substr(0, 2), 16) / 255,
2521
+ green = parseInt(hex.substr(2, 2), 16) / 255,
2522
+ blue = parseInt(hex.substr(4, 2), 16) / 255;
2523
+
2524
+ var cMax = Math.max(red, green, blue),
2525
+ delta = cMax - Math.min(red, green, blue),
2526
+ saturation = cMax ? (delta / cMax) : 0;
2527
+
2528
+ switch (cMax) {
2529
+ case red: return [ 60 * (((green - blue) / delta) % 6) || 0, saturation, cMax ];
2530
+ case green: return [ 60 * (((blue - red) / delta) + 2) || 0, saturation, cMax ];
2531
+ case blue: return [ 60 * (((red - green) / delta) + 4) || 0, saturation, cMax ];
2532
+ }
2533
+ }
2534
+
2535
+ function HSVtoHSL (hsv) {
2536
+ var h = hsv[0],
2537
+ s = hsv[1]/100,
2538
+ v = hsv[2]/100,
2539
+ k = (2-s)*v;
2540
+
2541
+ return [
2542
+ h,
2543
+ Math.round(s*v / (k<1 ? k : 2-k) * 10000) / 100,
2544
+ k/2 * 100
2545
+ ];
2546
+ }
2547
+
2548
+ function stringToInteger (string) {
2549
+ var total = 0;
2550
+ for (var i = 0; i !== string.length; i++) {
2551
+ if (total >= Number.MAX_SAFE_INTEGER) break;
2552
+ total += string.charCodeAt(i);
2553
+ }
2554
+ return total
2555
+ }
2556
+
2557
+ // get The range of given hue when options.count!=0
2558
+ function getRealHueRange(colorHue)
2559
+ { if (!isNaN(colorHue)) {
2560
+ var number = parseInt(colorHue);
2561
+
2562
+ if (number < 360 && number > 0) {
2563
+ return getColorInfo(colorHue).hueRange
2564
+ }
2565
+ }
2566
+ else if (typeof colorHue === 'string') {
2567
+
2568
+ if (colorDictionary[colorHue]) {
2569
+ var color = colorDictionary[colorHue];
2570
+
2571
+ if (color.hueRange) {
2572
+ return color.hueRange
2573
+ }
2574
+ } else if (colorHue.match(/^#?([0-9A-F]{3}|[0-9A-F]{6})$/i)) {
2575
+ var hue = HexToHSB(colorHue)[0];
2576
+ return getColorInfo(hue).hueRange
2577
+ }
2578
+ }
2579
+
2580
+ return [0,360]
2581
+ }
2582
+ return randomColor;
2583
+ }));
2584
+ } (randomColor$1, randomColor$1.exports));
2585
+
2586
+ var randomColorExports = randomColor$1.exports;
2587
+ var randomColor = /*@__PURE__*/getDefaultExportFromCjs(randomColorExports);
2588
+
2589
+ /**
2590
+ * Assign a color to a unique layer ID and also considering
2591
+ * common layer names such as water or wood.
2592
+ * @param layerId - a layer ID
2593
+ * @param alpha - alpha value for the color, default is 1
2594
+ * @return a color in rgba string format
2595
+ */
2596
+ function brightColor(layerId, alpha) {
2597
+ let luminosity = 'bright';
2598
+ let hue = undefined;
2599
+ if (/water|ocean|lake|sea|river/.test(layerId)) {
2600
+ hue = 'blue';
2601
+ }
2602
+ if (/state|country|place/.test(layerId)) {
2603
+ hue = 'pink';
2604
+ }
2605
+ if (/road|highway|transport|streets/.test(layerId)) {
2606
+ hue = 'orange';
2607
+ }
2608
+ if (/contour|building|earth/.test(layerId)) {
2609
+ hue = 'monochrome';
2610
+ }
2611
+ if (/building/.test(layerId)) {
2612
+ luminosity = 'dark';
2613
+ }
2614
+ if (/earth/.test(layerId)) {
2615
+ luminosity = 'light';
2616
+ }
2617
+ if (/contour|landuse/.test(layerId)) {
2618
+ hue = 'yellow';
2619
+ }
2620
+ if (/wood|forest|park|landcover|land|natural/.test(layerId)) {
2621
+ hue = 'green';
2622
+ }
2623
+ const rgb = randomColor({
2624
+ luminosity,
2625
+ hue,
2626
+ seed: layerId,
2627
+ format: 'rgbArray'
2628
+ });
2629
+ return `rgba(${rgb.join(', ')}, ${alpha || "1"})`;
2630
+ }
2631
+ var colors = { brightColor };
2632
+
2633
+ function isInspectStyle(style) {
2634
+ return style.metadata && style.metadata['maplibregl-inspect:inspect'];
2635
+ }
2636
+ function markInspectStyle(style) {
2637
+ return Object.assign(style, {
2638
+ metadata: Object.assign({}, style.metadata, {
2639
+ 'maplibregl-inspect:inspect': true
2640
+ })
2641
+ });
2642
+ }
2643
+ /**
2644
+ * Maplibre Inspect Control
2645
+ */
2646
+ class MaplibreInspect {
2647
+ constructor(options) {
2648
+ this._onSourceChange = (e) => {
2649
+ if (e.sourceDataType === 'visibility' || !e.isSourceLoaded) {
2650
+ return;
2651
+ }
2652
+ const previousSources = Object.assign({}, this.sources);
2653
+ this._setSourcesFromMap();
2654
+ if (!isEqual(previousSources, this.sources) && Object.keys(this.sources).length > 0) {
2655
+ // If the sources have changed, we need to re-render the inspect style but not too fast
2656
+ setTimeout(() => this.render(), 1000);
2657
+ }
2658
+ };
2659
+ this._onStyleChange = () => {
2660
+ const style = this._map.getStyle();
2661
+ if (!isInspectStyle(style)) {
2662
+ this._originalStyle = style;
2663
+ }
2664
+ };
2665
+ this._onRightClick = () => {
2666
+ if (!this.options.showMapPopupOnHover && !this.options.showInspectMapPopupOnHover && !this.options.blockHoverPopupOnClick) {
2667
+ if (this._popup)
2668
+ this._popup.remove();
2669
+ }
2670
+ };
2671
+ this._onMousemove = (e) => {
2672
+ if (this._showInspectMap) {
2673
+ if (!this.options.showInspectMapPopup)
2674
+ return;
2675
+ if (e.type === 'mousemove' && !this.options.showInspectMapPopupOnHover)
2676
+ return;
2677
+ if (e.type === 'click' && this.options.showInspectMapPopupOnHover && this.options.blockHoverPopupOnClick) {
2678
+ this._popupBlocked = !this._popupBlocked;
2679
+ }
2680
+ }
2681
+ else {
2682
+ if (!this.options.showMapPopup)
2683
+ return;
2684
+ if (e.type === 'mousemove' && !this.options.showMapPopupOnHover)
2685
+ return;
2686
+ if (e.type === 'click' && this.options.showMapPopupOnHover && this.options.blockHoverPopupOnClick) {
2687
+ this._popupBlocked = !this._popupBlocked;
2688
+ }
2689
+ }
2690
+ if (!this._popupBlocked && this._popup) {
2691
+ let queryBox;
2692
+ if (this.options.selectThreshold === 0) {
2693
+ queryBox = e.point;
2694
+ }
2695
+ else {
2696
+ // set a bbox around the pointer
2697
+ queryBox = [
2698
+ [
2699
+ e.point.x - this.options.selectThreshold,
2700
+ e.point.y + this.options.selectThreshold
2701
+ ], // bottom left (SW)
2702
+ [
2703
+ e.point.x + this.options.selectThreshold,
2704
+ e.point.y - this.options.selectThreshold
2705
+ ] // top right (NE)
2706
+ ];
2707
+ }
2708
+ const features = this._map.queryRenderedFeatures(queryBox, this.options.queryParameters) || [];
2709
+ this._map.getCanvas().style.cursor = (features.length) ? 'pointer' : '';
2710
+ if (!features.length) {
2711
+ this._popup.remove();
2712
+ }
2713
+ else {
2714
+ this._popup.setLngLat(e.lngLat);
2715
+ const renderedPopup = this.options.renderPopup(features);
2716
+ if (typeof renderedPopup === 'string') {
2717
+ this._popup.setHTML(renderedPopup);
2718
+ }
2719
+ else {
2720
+ this._popup.setDOMContent(renderedPopup);
2721
+ }
2722
+ this._popup.addTo(this._map);
2723
+ }
2724
+ }
2725
+ };
2726
+ if (!(this instanceof MaplibreInspect)) {
2727
+ throw new Error('MaplibreInspect needs to be called with the new keyword');
2728
+ }
2729
+ let popup = null;
2730
+ if (window.maplibregl) {
2731
+ popup = new window.maplibregl.Popup({
2732
+ closeButton: false,
2733
+ closeOnClick: false
2734
+ });
2735
+ }
2736
+ else if (!options.popup) {
2737
+ console.error('Maplibre GL JS can not be found. Make sure to include it or pass an initialized MaplibreGL Popup to MaplibreInspect if you are using moduleis.');
2738
+ }
2739
+ this.options = Object.assign({
2740
+ showInspectMap: false,
2741
+ showInspectButton: true,
2742
+ showInspectMapPopup: true,
2743
+ showMapPopup: false,
2744
+ showMapPopupOnHover: true,
2745
+ showInspectMapPopupOnHover: true,
2746
+ blockHoverPopupOnClick: false,
2747
+ backgroundColor: '#fff',
2748
+ assignLayerColor: colors.brightColor,
2749
+ buildInspectStyle: stylegen.generateInspectStyle,
2750
+ renderPopup,
2751
+ popup,
2752
+ selectThreshold: 5,
2753
+ useInspectStyle: true,
2754
+ queryParameters: {},
2755
+ sources: {},
2756
+ toggleCallback() { },
2757
+ manageStyleOutside: false
2758
+ }, options);
2759
+ this.sources = this.options.sources;
2760
+ this.assignLayerColor = this.options.assignLayerColor;
2761
+ this._popup = this.options.popup;
2762
+ this._popupBlocked = false;
2763
+ this._showInspectMap = this.options.showInspectMap;
2764
+ this._toggle = new InspectButton({
2765
+ show: this.options.showInspectButton,
2766
+ onToggle: () => this.toggleInspector()
2767
+ });
2768
+ }
2769
+ toggleInspector() {
2770
+ this._showInspectMap = !this._showInspectMap;
2771
+ this._popupBlocked = false;
2772
+ this.options.toggleCallback(this._showInspectMap);
2773
+ this.render();
2774
+ }
2775
+ _inspectStyle() {
2776
+ const coloredLayers = stylegen.generateColoredLayers(this.sources, this.assignLayerColor);
2777
+ return this.options.buildInspectStyle(this._map.getStyle(), coloredLayers, {
2778
+ backgroundColor: this.options.backgroundColor
2779
+ });
2780
+ }
2781
+ render() {
2782
+ if (this._showInspectMap) {
2783
+ if (this.options.useInspectStyle) {
2784
+ this._map.setStyle(markInspectStyle(this._inspectStyle()));
2785
+ }
2786
+ this._toggle.setMapIcon();
2787
+ }
2788
+ else if (this._originalStyle) {
2789
+ if (this._popup)
2790
+ this._popup.remove();
2791
+ if (this.options.useInspectStyle) {
2792
+ this._map.setStyle(this._originalStyle);
2793
+ }
2794
+ this._toggle.setInspectIcon();
2795
+ }
2796
+ }
2797
+ _setSourcesFromMap() {
2798
+ //NOTE: This heavily depends on the internal API of Maplibre GL
2799
+ //so this breaks between Maplibre GL JS releases
2800
+ const mapStyleSourcesNames = Object.keys(this._map.getStyle().sources);
2801
+ Object.keys(this._map.style.sourceCaches).forEach((sourceId) => {
2802
+ const sourceCache = this._map.style.sourceCaches[sourceId] || { _source: {} };
2803
+ const layerIds = sourceCache._source.vectorLayerIds;
2804
+ if (layerIds) {
2805
+ this.sources[sourceId] = layerIds;
2806
+ }
2807
+ else if (sourceCache._source.type === 'geojson') {
2808
+ this.sources[sourceId] = [];
2809
+ }
2810
+ });
2811
+ Object.keys(this.sources).forEach((sourceId) => {
2812
+ if (mapStyleSourcesNames.indexOf(sourceId) === -1) {
2813
+ delete this.sources[sourceId];
2814
+ }
2815
+ });
2816
+ }
2817
+ /**
2818
+ * This will set the original style of the map
2819
+ * It will also update the sources assuming the map has already been loaded
2820
+ * @param style - The original style
2821
+ */
2822
+ setOriginalStyle(style) {
2823
+ this._originalStyle = style;
2824
+ this._setSourcesFromMap();
2825
+ }
2826
+ onAdd(map) {
2827
+ this._map = map;
2828
+ // if sources have already been passed as options
2829
+ // we do not need to figure out the sources ourselves
2830
+ if (Object.keys(this.sources).length === 0) {
2831
+ map.on('tiledata', this._onSourceChange);
2832
+ map.on('sourcedata', this._onSourceChange);
2833
+ }
2834
+ map.on('styledata', this._onStyleChange);
2835
+ map.on('load', this._onStyleChange);
2836
+ map.on('mousemove', this._onMousemove);
2837
+ map.on('click', this._onMousemove);
2838
+ map.on('contextmenu', this._onRightClick);
2839
+ return this._toggle.elem;
2840
+ }
2841
+ onRemove() {
2842
+ this._map.off('styledata', this._onStyleChange);
2843
+ this._map.off('load', this._onStyleChange);
2844
+ this._map.off('tiledata', this._onSourceChange);
2845
+ this._map.off('sourcedata', this._onSourceChange);
2846
+ this._map.off('mousemove', this._onMousemove);
2847
+ this._map.off('click', this._onMousemove);
2848
+ this._map.off('contextmenu', this._onRightClick);
2849
+ const elem = this._toggle.elem;
2850
+ elem.parentNode.removeChild(elem);
2851
+ this._map = undefined;
2852
+ }
2853
+ }
2854
+
2855
+ return MaplibreInspect;
2856
+
2857
+ }));
2858
+ //# sourceMappingURL=maplibre-gl-inspect.js.map