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