]> git.openstreetmap.org Git - rails.git/blob - vendor/assets/iD/iD.js
Set search input z-index with Bootstrap utility class
[rails.git] / vendor / assets / iD / iD.js
1 (() => {
2   var __create = Object.create;
3   var __defProp = Object.defineProperty;
4   var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5   var __getOwnPropNames = Object.getOwnPropertyNames;
6   var __getProtoOf = Object.getPrototypeOf;
7   var __hasOwnProp = Object.prototype.hasOwnProperty;
8   var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
9   var __require = /* @__PURE__ */ ((x2) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x2, {
10     get: (a2, b2) => (typeof require !== "undefined" ? require : a2)[b2]
11   }) : x2)(function(x2) {
12     if (typeof require !== "undefined")
13       return require.apply(this, arguments);
14     throw Error('Dynamic require of "' + x2 + '" is not supported');
15   });
16   var __commonJS = (cb, mod) => function __require2() {
17     return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
18   };
19   var __export = (target, all) => {
20     for (var name in all)
21       __defProp(target, name, { get: all[name], enumerable: true });
22   };
23   var __copyProps = (to, from, except, desc) => {
24     if (from && typeof from === "object" || typeof from === "function") {
25       for (let key of __getOwnPropNames(from))
26         if (!__hasOwnProp.call(to, key) && key !== except)
27           __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
28     }
29     return to;
30   };
31   var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
32     // If the importer is in node compatibility mode or this is not an ESM
33     // file that has been converted to a CommonJS file using a Babel-
34     // compatible transform (i.e. "__esModule" has not been set), then set
35     // "default" to the CommonJS "module.exports" for node compatibility.
36     isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
37     mod
38   ));
39   var __publicField = (obj, key, value) => {
40     __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
41     return value;
42   };
43   var __accessCheck = (obj, member, msg) => {
44     if (!member.has(obj))
45       throw TypeError("Cannot " + msg);
46   };
47   var __privateAdd = (obj, member, value) => {
48     if (member.has(obj))
49       throw TypeError("Cannot add the same private member more than once");
50     member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
51   };
52   var __privateMethod = (obj, member, method) => {
53     __accessCheck(obj, member, "access private method");
54     return method;
55   };
56
57   // node_modules/diacritics/index.js
58   var require_diacritics = __commonJS({
59     "node_modules/diacritics/index.js"(exports2) {
60       exports2.remove = removeDiacritics2;
61       var replacementList = [
62         {
63           base: " ",
64           chars: "\xA0"
65         },
66         {
67           base: "0",
68           chars: "\u07C0"
69         },
70         {
71           base: "A",
72           chars: "\u24B6\uFF21\xC0\xC1\xC2\u1EA6\u1EA4\u1EAA\u1EA8\xC3\u0100\u0102\u1EB0\u1EAE\u1EB4\u1EB2\u0226\u01E0\xC4\u01DE\u1EA2\xC5\u01FA\u01CD\u0200\u0202\u1EA0\u1EAC\u1EB6\u1E00\u0104\u023A\u2C6F"
73         },
74         {
75           base: "AA",
76           chars: "\uA732"
77         },
78         {
79           base: "AE",
80           chars: "\xC6\u01FC\u01E2"
81         },
82         {
83           base: "AO",
84           chars: "\uA734"
85         },
86         {
87           base: "AU",
88           chars: "\uA736"
89         },
90         {
91           base: "AV",
92           chars: "\uA738\uA73A"
93         },
94         {
95           base: "AY",
96           chars: "\uA73C"
97         },
98         {
99           base: "B",
100           chars: "\u24B7\uFF22\u1E02\u1E04\u1E06\u0243\u0181"
101         },
102         {
103           base: "C",
104           chars: "\u24B8\uFF23\uA73E\u1E08\u0106C\u0108\u010A\u010C\xC7\u0187\u023B"
105         },
106         {
107           base: "D",
108           chars: "\u24B9\uFF24\u1E0A\u010E\u1E0C\u1E10\u1E12\u1E0E\u0110\u018A\u0189\u1D05\uA779"
109         },
110         {
111           base: "Dh",
112           chars: "\xD0"
113         },
114         {
115           base: "DZ",
116           chars: "\u01F1\u01C4"
117         },
118         {
119           base: "Dz",
120           chars: "\u01F2\u01C5"
121         },
122         {
123           base: "E",
124           chars: "\u025B\u24BA\uFF25\xC8\xC9\xCA\u1EC0\u1EBE\u1EC4\u1EC2\u1EBC\u0112\u1E14\u1E16\u0114\u0116\xCB\u1EBA\u011A\u0204\u0206\u1EB8\u1EC6\u0228\u1E1C\u0118\u1E18\u1E1A\u0190\u018E\u1D07"
125         },
126         {
127           base: "F",
128           chars: "\uA77C\u24BB\uFF26\u1E1E\u0191\uA77B"
129         },
130         {
131           base: "G",
132           chars: "\u24BC\uFF27\u01F4\u011C\u1E20\u011E\u0120\u01E6\u0122\u01E4\u0193\uA7A0\uA77D\uA77E\u0262"
133         },
134         {
135           base: "H",
136           chars: "\u24BD\uFF28\u0124\u1E22\u1E26\u021E\u1E24\u1E28\u1E2A\u0126\u2C67\u2C75\uA78D"
137         },
138         {
139           base: "I",
140           chars: "\u24BE\uFF29\xCC\xCD\xCE\u0128\u012A\u012C\u0130\xCF\u1E2E\u1EC8\u01CF\u0208\u020A\u1ECA\u012E\u1E2C\u0197"
141         },
142         {
143           base: "J",
144           chars: "\u24BF\uFF2A\u0134\u0248\u0237"
145         },
146         {
147           base: "K",
148           chars: "\u24C0\uFF2B\u1E30\u01E8\u1E32\u0136\u1E34\u0198\u2C69\uA740\uA742\uA744\uA7A2"
149         },
150         {
151           base: "L",
152           chars: "\u24C1\uFF2C\u013F\u0139\u013D\u1E36\u1E38\u013B\u1E3C\u1E3A\u0141\u023D\u2C62\u2C60\uA748\uA746\uA780"
153         },
154         {
155           base: "LJ",
156           chars: "\u01C7"
157         },
158         {
159           base: "Lj",
160           chars: "\u01C8"
161         },
162         {
163           base: "M",
164           chars: "\u24C2\uFF2D\u1E3E\u1E40\u1E42\u2C6E\u019C\u03FB"
165         },
166         {
167           base: "N",
168           chars: "\uA7A4\u0220\u24C3\uFF2E\u01F8\u0143\xD1\u1E44\u0147\u1E46\u0145\u1E4A\u1E48\u019D\uA790\u1D0E"
169         },
170         {
171           base: "NJ",
172           chars: "\u01CA"
173         },
174         {
175           base: "Nj",
176           chars: "\u01CB"
177         },
178         {
179           base: "O",
180           chars: "\u24C4\uFF2F\xD2\xD3\xD4\u1ED2\u1ED0\u1ED6\u1ED4\xD5\u1E4C\u022C\u1E4E\u014C\u1E50\u1E52\u014E\u022E\u0230\xD6\u022A\u1ECE\u0150\u01D1\u020C\u020E\u01A0\u1EDC\u1EDA\u1EE0\u1EDE\u1EE2\u1ECC\u1ED8\u01EA\u01EC\xD8\u01FE\u0186\u019F\uA74A\uA74C"
181         },
182         {
183           base: "OE",
184           chars: "\u0152"
185         },
186         {
187           base: "OI",
188           chars: "\u01A2"
189         },
190         {
191           base: "OO",
192           chars: "\uA74E"
193         },
194         {
195           base: "OU",
196           chars: "\u0222"
197         },
198         {
199           base: "P",
200           chars: "\u24C5\uFF30\u1E54\u1E56\u01A4\u2C63\uA750\uA752\uA754"
201         },
202         {
203           base: "Q",
204           chars: "\u24C6\uFF31\uA756\uA758\u024A"
205         },
206         {
207           base: "R",
208           chars: "\u24C7\uFF32\u0154\u1E58\u0158\u0210\u0212\u1E5A\u1E5C\u0156\u1E5E\u024C\u2C64\uA75A\uA7A6\uA782"
209         },
210         {
211           base: "S",
212           chars: "\u24C8\uFF33\u1E9E\u015A\u1E64\u015C\u1E60\u0160\u1E66\u1E62\u1E68\u0218\u015E\u2C7E\uA7A8\uA784"
213         },
214         {
215           base: "T",
216           chars: "\u24C9\uFF34\u1E6A\u0164\u1E6C\u021A\u0162\u1E70\u1E6E\u0166\u01AC\u01AE\u023E\uA786"
217         },
218         {
219           base: "Th",
220           chars: "\xDE"
221         },
222         {
223           base: "TZ",
224           chars: "\uA728"
225         },
226         {
227           base: "U",
228           chars: "\u24CA\uFF35\xD9\xDA\xDB\u0168\u1E78\u016A\u1E7A\u016C\xDC\u01DB\u01D7\u01D5\u01D9\u1EE6\u016E\u0170\u01D3\u0214\u0216\u01AF\u1EEA\u1EE8\u1EEE\u1EEC\u1EF0\u1EE4\u1E72\u0172\u1E76\u1E74\u0244"
229         },
230         {
231           base: "V",
232           chars: "\u24CB\uFF36\u1E7C\u1E7E\u01B2\uA75E\u0245"
233         },
234         {
235           base: "VY",
236           chars: "\uA760"
237         },
238         {
239           base: "W",
240           chars: "\u24CC\uFF37\u1E80\u1E82\u0174\u1E86\u1E84\u1E88\u2C72"
241         },
242         {
243           base: "X",
244           chars: "\u24CD\uFF38\u1E8A\u1E8C"
245         },
246         {
247           base: "Y",
248           chars: "\u24CE\uFF39\u1EF2\xDD\u0176\u1EF8\u0232\u1E8E\u0178\u1EF6\u1EF4\u01B3\u024E\u1EFE"
249         },
250         {
251           base: "Z",
252           chars: "\u24CF\uFF3A\u0179\u1E90\u017B\u017D\u1E92\u1E94\u01B5\u0224\u2C7F\u2C6B\uA762"
253         },
254         {
255           base: "a",
256           chars: "\u24D0\uFF41\u1E9A\xE0\xE1\xE2\u1EA7\u1EA5\u1EAB\u1EA9\xE3\u0101\u0103\u1EB1\u1EAF\u1EB5\u1EB3\u0227\u01E1\xE4\u01DF\u1EA3\xE5\u01FB\u01CE\u0201\u0203\u1EA1\u1EAD\u1EB7\u1E01\u0105\u2C65\u0250\u0251"
257         },
258         {
259           base: "aa",
260           chars: "\uA733"
261         },
262         {
263           base: "ae",
264           chars: "\xE6\u01FD\u01E3"
265         },
266         {
267           base: "ao",
268           chars: "\uA735"
269         },
270         {
271           base: "au",
272           chars: "\uA737"
273         },
274         {
275           base: "av",
276           chars: "\uA739\uA73B"
277         },
278         {
279           base: "ay",
280           chars: "\uA73D"
281         },
282         {
283           base: "b",
284           chars: "\u24D1\uFF42\u1E03\u1E05\u1E07\u0180\u0183\u0253\u0182"
285         },
286         {
287           base: "c",
288           chars: "\uFF43\u24D2\u0107\u0109\u010B\u010D\xE7\u1E09\u0188\u023C\uA73F\u2184"
289         },
290         {
291           base: "d",
292           chars: "\u24D3\uFF44\u1E0B\u010F\u1E0D\u1E11\u1E13\u1E0F\u0111\u018C\u0256\u0257\u018B\u13E7\u0501\uA7AA"
293         },
294         {
295           base: "dh",
296           chars: "\xF0"
297         },
298         {
299           base: "dz",
300           chars: "\u01F3\u01C6"
301         },
302         {
303           base: "e",
304           chars: "\u24D4\uFF45\xE8\xE9\xEA\u1EC1\u1EBF\u1EC5\u1EC3\u1EBD\u0113\u1E15\u1E17\u0115\u0117\xEB\u1EBB\u011B\u0205\u0207\u1EB9\u1EC7\u0229\u1E1D\u0119\u1E19\u1E1B\u0247\u01DD"
305         },
306         {
307           base: "f",
308           chars: "\u24D5\uFF46\u1E1F\u0192"
309         },
310         {
311           base: "ff",
312           chars: "\uFB00"
313         },
314         {
315           base: "fi",
316           chars: "\uFB01"
317         },
318         {
319           base: "fl",
320           chars: "\uFB02"
321         },
322         {
323           base: "ffi",
324           chars: "\uFB03"
325         },
326         {
327           base: "ffl",
328           chars: "\uFB04"
329         },
330         {
331           base: "g",
332           chars: "\u24D6\uFF47\u01F5\u011D\u1E21\u011F\u0121\u01E7\u0123\u01E5\u0260\uA7A1\uA77F\u1D79"
333         },
334         {
335           base: "h",
336           chars: "\u24D7\uFF48\u0125\u1E23\u1E27\u021F\u1E25\u1E29\u1E2B\u1E96\u0127\u2C68\u2C76\u0265"
337         },
338         {
339           base: "hv",
340           chars: "\u0195"
341         },
342         {
343           base: "i",
344           chars: "\u24D8\uFF49\xEC\xED\xEE\u0129\u012B\u012D\xEF\u1E2F\u1EC9\u01D0\u0209\u020B\u1ECB\u012F\u1E2D\u0268\u0131"
345         },
346         {
347           base: "j",
348           chars: "\u24D9\uFF4A\u0135\u01F0\u0249"
349         },
350         {
351           base: "k",
352           chars: "\u24DA\uFF4B\u1E31\u01E9\u1E33\u0137\u1E35\u0199\u2C6A\uA741\uA743\uA745\uA7A3"
353         },
354         {
355           base: "l",
356           chars: "\u24DB\uFF4C\u0140\u013A\u013E\u1E37\u1E39\u013C\u1E3D\u1E3B\u017F\u0142\u019A\u026B\u2C61\uA749\uA781\uA747\u026D"
357         },
358         {
359           base: "lj",
360           chars: "\u01C9"
361         },
362         {
363           base: "m",
364           chars: "\u24DC\uFF4D\u1E3F\u1E41\u1E43\u0271\u026F"
365         },
366         {
367           base: "n",
368           chars: "\u24DD\uFF4E\u01F9\u0144\xF1\u1E45\u0148\u1E47\u0146\u1E4B\u1E49\u019E\u0272\u0149\uA791\uA7A5\u043B\u0509"
369         },
370         {
371           base: "nj",
372           chars: "\u01CC"
373         },
374         {
375           base: "o",
376           chars: "\u24DE\uFF4F\xF2\xF3\xF4\u1ED3\u1ED1\u1ED7\u1ED5\xF5\u1E4D\u022D\u1E4F\u014D\u1E51\u1E53\u014F\u022F\u0231\xF6\u022B\u1ECF\u0151\u01D2\u020D\u020F\u01A1\u1EDD\u1EDB\u1EE1\u1EDF\u1EE3\u1ECD\u1ED9\u01EB\u01ED\xF8\u01FF\uA74B\uA74D\u0275\u0254\u1D11"
377         },
378         {
379           base: "oe",
380           chars: "\u0153"
381         },
382         {
383           base: "oi",
384           chars: "\u01A3"
385         },
386         {
387           base: "oo",
388           chars: "\uA74F"
389         },
390         {
391           base: "ou",
392           chars: "\u0223"
393         },
394         {
395           base: "p",
396           chars: "\u24DF\uFF50\u1E55\u1E57\u01A5\u1D7D\uA751\uA753\uA755\u03C1"
397         },
398         {
399           base: "q",
400           chars: "\u24E0\uFF51\u024B\uA757\uA759"
401         },
402         {
403           base: "r",
404           chars: "\u24E1\uFF52\u0155\u1E59\u0159\u0211\u0213\u1E5B\u1E5D\u0157\u1E5F\u024D\u027D\uA75B\uA7A7\uA783"
405         },
406         {
407           base: "s",
408           chars: "\u24E2\uFF53\u015B\u1E65\u015D\u1E61\u0161\u1E67\u1E63\u1E69\u0219\u015F\u023F\uA7A9\uA785\u1E9B\u0282"
409         },
410         {
411           base: "ss",
412           chars: "\xDF"
413         },
414         {
415           base: "t",
416           chars: "\u24E3\uFF54\u1E6B\u1E97\u0165\u1E6D\u021B\u0163\u1E71\u1E6F\u0167\u01AD\u0288\u2C66\uA787"
417         },
418         {
419           base: "th",
420           chars: "\xFE"
421         },
422         {
423           base: "tz",
424           chars: "\uA729"
425         },
426         {
427           base: "u",
428           chars: "\u24E4\uFF55\xF9\xFA\xFB\u0169\u1E79\u016B\u1E7B\u016D\xFC\u01DC\u01D8\u01D6\u01DA\u1EE7\u016F\u0171\u01D4\u0215\u0217\u01B0\u1EEB\u1EE9\u1EEF\u1EED\u1EF1\u1EE5\u1E73\u0173\u1E77\u1E75\u0289"
429         },
430         {
431           base: "v",
432           chars: "\u24E5\uFF56\u1E7D\u1E7F\u028B\uA75F\u028C"
433         },
434         {
435           base: "vy",
436           chars: "\uA761"
437         },
438         {
439           base: "w",
440           chars: "\u24E6\uFF57\u1E81\u1E83\u0175\u1E87\u1E85\u1E98\u1E89\u2C73"
441         },
442         {
443           base: "x",
444           chars: "\u24E7\uFF58\u1E8B\u1E8D"
445         },
446         {
447           base: "y",
448           chars: "\u24E8\uFF59\u1EF3\xFD\u0177\u1EF9\u0233\u1E8F\xFF\u1EF7\u1E99\u1EF5\u01B4\u024F\u1EFF"
449         },
450         {
451           base: "z",
452           chars: "\u24E9\uFF5A\u017A\u1E91\u017C\u017E\u1E93\u1E95\u01B6\u0225\u0240\u2C6C\uA763"
453         }
454       ];
455       var diacriticsMap = {};
456       for (i3 = 0; i3 < replacementList.length; i3 += 1) {
457         chars = replacementList[i3].chars;
458         for (j2 = 0; j2 < chars.length; j2 += 1) {
459           diacriticsMap[chars[j2]] = replacementList[i3].base;
460         }
461       }
462       var chars;
463       var j2;
464       var i3;
465       function removeDiacritics2(str) {
466         return str.replace(/[^\u0000-\u007e]/g, function(c2) {
467           return diacriticsMap[c2] || c2;
468         });
469       }
470       exports2.replacementList = replacementList;
471       exports2.diacriticsMap = diacriticsMap;
472     }
473   });
474
475   // node_modules/alif-toolkit/lib/isArabic.js
476   var require_isArabic = __commonJS({
477     "node_modules/alif-toolkit/lib/isArabic.js"(exports2) {
478       "use strict";
479       Object.defineProperty(exports2, "__esModule", { value: true });
480       var arabicBlocks = [
481         [1536, 1791],
482         [1872, 1919],
483         [2208, 2303],
484         [64336, 65023],
485         [65136, 65279],
486         [69216, 69247],
487         [126064, 126143],
488         [126464, 126719]
489         // Mathematical Alphabetic symbols https://www.unicode.org/charts/PDF/U1EE00.pdf
490       ];
491       function isArabic(char) {
492         if (char.length > 1) {
493           throw new Error("isArabic works on only one-character strings");
494         }
495         let code = char.charCodeAt(0);
496         for (let i3 = 0; i3 < arabicBlocks.length; i3++) {
497           let block2 = arabicBlocks[i3];
498           if (code >= block2[0] && code <= block2[1]) {
499             return true;
500           }
501         }
502         return false;
503       }
504       exports2.isArabic = isArabic;
505       function isMath(char) {
506         if (char.length > 2) {
507           throw new Error("isMath works on only one-character strings");
508         }
509         let code = char.charCodeAt(0);
510         return code >= 1632 && code <= 1644 || code >= 1776 && code <= 1785;
511       }
512       exports2.isMath = isMath;
513     }
514   });
515
516   // node_modules/alif-toolkit/lib/unicode-arabic.js
517   var require_unicode_arabic = __commonJS({
518     "node_modules/alif-toolkit/lib/unicode-arabic.js"(exports2) {
519       "use strict";
520       Object.defineProperty(exports2, "__esModule", { value: true });
521       var arabicReference = {
522         "alef": {
523           "normal": [
524             "\u0627"
525           ],
526           "madda_above": {
527             "normal": [
528               "\u0627\u0653",
529               "\u0622"
530             ],
531             "isolated": "\uFE81",
532             "final": "\uFE82"
533           },
534           "hamza_above": {
535             "normal": [
536               "\u0627\u0654",
537               "\u0623"
538             ],
539             "isolated": "\uFE83",
540             "final": "\uFE84"
541           },
542           "hamza_below": {
543             "normal": [
544               "\u0627\u0655",
545               "\u0625"
546             ],
547             "isolated": "\uFE87",
548             "final": "\uFE88"
549           },
550           "wasla": {
551             "normal": "\u0671",
552             "isolated": "\uFB50",
553             "final": "\uFB51"
554           },
555           "wavy_hamza_above": [
556             "\u0672"
557           ],
558           "wavy_hamza_below": [
559             "\u0627\u065F",
560             "\u0673"
561           ],
562           "high_hamza": [
563             "\u0675",
564             "\u0627\u0674"
565           ],
566           "indic_two_above": [
567             "\u0773"
568           ],
569           "indic_three_above": [
570             "\u0774"
571           ],
572           "fathatan": {
573             "normal": [
574               "\u0627\u064B"
575             ],
576             "final": "\uFD3C",
577             "isolated": "\uFD3D"
578           },
579           "isolated": "\uFE8D",
580           "final": "\uFE8E"
581         },
582         "beh": {
583           "normal": [
584             "\u0628"
585           ],
586           "dotless": [
587             "\u066E"
588           ],
589           "three_dots_horizontally_below": [
590             "\u0750"
591           ],
592           "dot_below_three_dots_above": [
593             "\u0751"
594           ],
595           "three_dots_pointing_upwards_below": [
596             "\u0752"
597           ],
598           "three_dots_pointing_upwards_below_two_dots_above": [
599             "\u0753"
600           ],
601           "two_dots_below_dot_above": [
602             "\u0754"
603           ],
604           "inverted_small_v_below": [
605             "\u0755"
606           ],
607           "small_v": [
608             "\u0756"
609           ],
610           "small_v_below": [
611             "\u08A0"
612           ],
613           "hamza_above": [
614             "\u08A1"
615           ],
616           "small_meem_above": [
617             "\u08B6"
618           ],
619           "isolated": "\uFE8F",
620           "final": "\uFE90",
621           "initial": "\uFE91",
622           "medial": "\uFE92"
623         },
624         "teh marbuta": {
625           "normal": [
626             "\u0629"
627           ],
628           "isolated": "\uFE93",
629           "final": "\uFE94"
630         },
631         "teh": {
632           "normal": [
633             "\u062A"
634           ],
635           "ring": [
636             "\u067C"
637           ],
638           "three_dots_above_downwards": [
639             "\u067D"
640           ],
641           "small_teh_above": [
642             "\u08B8"
643           ],
644           "isolated": "\uFE95",
645           "final": "\uFE96",
646           "initial": "\uFE97",
647           "medial": "\uFE98"
648         },
649         "theh": {
650           "normal": [
651             "\u062B"
652           ],
653           "isolated": "\uFE99",
654           "final": "\uFE9A",
655           "initial": "\uFE9B",
656           "medial": "\uFE9C"
657         },
658         "jeem": {
659           "normal": [
660             "\u062C"
661           ],
662           "two_dots_above": [
663             "\u08A2"
664           ],
665           "isolated": "\uFE9D",
666           "final": "\uFE9E",
667           "initial": "\uFE9F",
668           "medial": "\uFEA0"
669         },
670         "hah": {
671           "normal": [
672             "\u062D"
673           ],
674           "hamza_above": [
675             "\u0681"
676           ],
677           "two_dots_vertical_above": [
678             "\u0682"
679           ],
680           "three_dots_above": [
681             "\u0685"
682           ],
683           "two_dots_above": [
684             "\u0757"
685           ],
686           "three_dots_pointing_upwards_below": [
687             "\u0758"
688           ],
689           "small_tah_below": [
690             "\u076E"
691           ],
692           "small_tah_two_dots": [
693             "\u076F"
694           ],
695           "small_tah_above": [
696             "\u0772"
697           ],
698           "indic_four_below": [
699             "\u077C"
700           ],
701           "isolated": "\uFEA1",
702           "final": "\uFEA2",
703           "initial": "\uFEA3",
704           "medial": "\uFEA4"
705         },
706         "khah": {
707           "normal": [
708             "\u062E"
709           ],
710           "isolated": "\uFEA5",
711           "final": "\uFEA6",
712           "initial": "\uFEA7",
713           "medial": "\uFEA8"
714         },
715         "dal": {
716           "normal": [
717             "\u062F"
718           ],
719           "ring": [
720             "\u0689"
721           ],
722           "dot_below": [
723             "\u068A"
724           ],
725           "dot_below_small_tah": [
726             "\u068B"
727           ],
728           "three_dots_above_downwards": [
729             "\u068F"
730           ],
731           "four_dots_above": [
732             "\u0690"
733           ],
734           "inverted_v": [
735             "\u06EE"
736           ],
737           "two_dots_vertically_below_small_tah": [
738             "\u0759"
739           ],
740           "inverted_small_v_below": [
741             "\u075A"
742           ],
743           "three_dots_below": [
744             "\u08AE"
745           ],
746           "isolated": "\uFEA9",
747           "final": "\uFEAA"
748         },
749         "thal": {
750           "normal": [
751             "\u0630"
752           ],
753           "isolated": "\uFEAB",
754           "final": "\uFEAC"
755         },
756         "reh": {
757           "normal": [
758             "\u0631"
759           ],
760           "small_v": [
761             "\u0692"
762           ],
763           "ring": [
764             "\u0693"
765           ],
766           "dot_below": [
767             "\u0694"
768           ],
769           "small_v_below": [
770             "\u0695"
771           ],
772           "dot_below_dot_above": [
773             "\u0696"
774           ],
775           "two_dots_above": [
776             "\u0697"
777           ],
778           "four_dots_above": [
779             "\u0699"
780           ],
781           "inverted_v": [
782             "\u06EF"
783           ],
784           "stroke": [
785             "\u075B"
786           ],
787           "two_dots_vertically_above": [
788             "\u076B"
789           ],
790           "hamza_above": [
791             "\u076C"
792           ],
793           "small_tah_two_dots": [
794             "\u0771"
795           ],
796           "loop": [
797             "\u08AA"
798           ],
799           "small_noon_above": [
800             "\u08B9"
801           ],
802           "isolated": "\uFEAD",
803           "final": "\uFEAE"
804         },
805         "zain": {
806           "normal": [
807             "\u0632"
808           ],
809           "inverted_v_above": [
810             "\u08B2"
811           ],
812           "isolated": "\uFEAF",
813           "final": "\uFEB0"
814         },
815         "seen": {
816           "normal": [
817             "\u0633"
818           ],
819           "dot_below_dot_above": [
820             "\u069A"
821           ],
822           "three_dots_below": [
823             "\u069B"
824           ],
825           "three_dots_below_three_dots_above": [
826             "\u069C"
827           ],
828           "four_dots_above": [
829             "\u075C"
830           ],
831           "two_dots_vertically_above": [
832             "\u076D"
833           ],
834           "small_tah_two_dots": [
835             "\u0770"
836           ],
837           "indic_four_above": [
838             "\u077D"
839           ],
840           "inverted_v": [
841             "\u077E"
842           ],
843           "isolated": "\uFEB1",
844           "final": "\uFEB2",
845           "initial": "\uFEB3",
846           "medial": "\uFEB4"
847         },
848         "sheen": {
849           "normal": [
850             "\u0634"
851           ],
852           "dot_below": [
853             "\u06FA"
854           ],
855           "isolated": "\uFEB5",
856           "final": "\uFEB6",
857           "initial": "\uFEB7",
858           "medial": "\uFEB8"
859         },
860         "sad": {
861           "normal": [
862             "\u0635"
863           ],
864           "two_dots_below": [
865             "\u069D"
866           ],
867           "three_dots_above": [
868             "\u069E"
869           ],
870           "three_dots_below": [
871             "\u08AF"
872           ],
873           "isolated": "\uFEB9",
874           "final": "\uFEBA",
875           "initial": "\uFEBB",
876           "medial": "\uFEBC"
877         },
878         "dad": {
879           "normal": [
880             "\u0636"
881           ],
882           "dot_below": [
883             "\u06FB"
884           ],
885           "isolated": "\uFEBD",
886           "final": "\uFEBE",
887           "initial": "\uFEBF",
888           "medial": "\uFEC0"
889         },
890         "tah": {
891           "normal": [
892             "\u0637"
893           ],
894           "three_dots_above": [
895             "\u069F"
896           ],
897           "two_dots_above": [
898             "\u08A3"
899           ],
900           "isolated": "\uFEC1",
901           "final": "\uFEC2",
902           "initial": "\uFEC3",
903           "medial": "\uFEC4"
904         },
905         "zah": {
906           "normal": [
907             "\u0638"
908           ],
909           "isolated": "\uFEC5",
910           "final": "\uFEC6",
911           "initial": "\uFEC7",
912           "medial": "\uFEC8"
913         },
914         "ain": {
915           "normal": [
916             "\u0639"
917           ],
918           "three_dots_above": [
919             "\u06A0"
920           ],
921           "two_dots_above": [
922             "\u075D"
923           ],
924           "three_dots_pointing_downwards_above": [
925             "\u075E"
926           ],
927           "two_dots_vertically_above": [
928             "\u075F"
929           ],
930           "three_dots_below": [
931             "\u08B3"
932           ],
933           "isolated": "\uFEC9",
934           "final": "\uFECA",
935           "initial": "\uFECB",
936           "medial": "\uFECC"
937         },
938         "ghain": {
939           "normal": [
940             "\u063A"
941           ],
942           "dot_below": [
943             "\u06FC"
944           ],
945           "isolated": "\uFECD",
946           "final": "\uFECE",
947           "initial": "\uFECF",
948           "medial": "\uFED0"
949         },
950         "feh": {
951           "normal": [
952             "\u0641"
953           ],
954           "dotless": [
955             "\u06A1"
956           ],
957           "dot_moved_below": [
958             "\u06A2"
959           ],
960           "dot_below": [
961             "\u06A3"
962           ],
963           "three_dots_below": [
964             "\u06A5"
965           ],
966           "two_dots_below": [
967             "\u0760"
968           ],
969           "three_dots_pointing_upwards_below": [
970             "\u0761"
971           ],
972           "dot_below_three_dots_above": [
973             "\u08A4"
974           ],
975           "isolated": "\uFED1",
976           "final": "\uFED2",
977           "initial": "\uFED3",
978           "medial": "\uFED4"
979         },
980         "qaf": {
981           "normal": [
982             "\u0642"
983           ],
984           "dotless": [
985             "\u066F"
986           ],
987           "dot_above": [
988             "\u06A7"
989           ],
990           "three_dots_above": [
991             "\u06A8"
992           ],
993           "dot_below": [
994             "\u08A5"
995           ],
996           "isolated": "\uFED5",
997           "final": "\uFED6",
998           "initial": "\uFED7",
999           "medial": "\uFED8"
1000         },
1001         "kaf": {
1002           "normal": [
1003             "\u0643"
1004           ],
1005           "swash": [
1006             "\u06AA"
1007           ],
1008           "ring": [
1009             "\u06AB"
1010           ],
1011           "dot_above": [
1012             "\u06AC"
1013           ],
1014           "three_dots_below": [
1015             "\u06AE"
1016           ],
1017           "two_dots_above": [
1018             "\u077F"
1019           ],
1020           "dot_below": [
1021             "\u08B4"
1022           ],
1023           "isolated": "\uFED9",
1024           "final": "\uFEDA",
1025           "initial": "\uFEDB",
1026           "medial": "\uFEDC"
1027         },
1028         "lam": {
1029           "normal": [
1030             "\u0644"
1031           ],
1032           "small_v": [
1033             "\u06B5"
1034           ],
1035           "dot_above": [
1036             "\u06B6"
1037           ],
1038           "three_dots_above": [
1039             "\u06B7"
1040           ],
1041           "three_dots_below": [
1042             "\u06B8"
1043           ],
1044           "bar": [
1045             "\u076A"
1046           ],
1047           "double_bar": [
1048             "\u08A6"
1049           ],
1050           "isolated": "\uFEDD",
1051           "final": "\uFEDE",
1052           "initial": "\uFEDF",
1053           "medial": "\uFEE0"
1054         },
1055         "meem": {
1056           "normal": [
1057             "\u0645"
1058           ],
1059           "dot_above": [
1060             "\u0765"
1061           ],
1062           "dot_below": [
1063             "\u0766"
1064           ],
1065           "three_dots_above": [
1066             "\u08A7"
1067           ],
1068           "isolated": "\uFEE1",
1069           "final": "\uFEE2",
1070           "initial": "\uFEE3",
1071           "medial": "\uFEE4"
1072         },
1073         "noon": {
1074           "normal": [
1075             "\u0646"
1076           ],
1077           "dot_below": [
1078             "\u06B9"
1079           ],
1080           "ring": [
1081             "\u06BC"
1082           ],
1083           "three_dots_above": [
1084             "\u06BD"
1085           ],
1086           "two_dots_below": [
1087             "\u0767"
1088           ],
1089           "small_tah": [
1090             "\u0768"
1091           ],
1092           "small_v": [
1093             "\u0769"
1094           ],
1095           "isolated": "\uFEE5",
1096           "final": "\uFEE6",
1097           "initial": "\uFEE7",
1098           "medial": "\uFEE8"
1099         },
1100         "heh": {
1101           "normal": [
1102             "\u0647"
1103           ],
1104           "isolated": "\uFEE9",
1105           "final": "\uFEEA",
1106           "initial": "\uFEEB",
1107           "medial": "\uFEEC"
1108         },
1109         "waw": {
1110           "normal": [
1111             "\u0648"
1112           ],
1113           "hamza_above": {
1114             "normal": [
1115               "\u0624",
1116               "\u0648\u0654"
1117             ],
1118             "isolated": "\uFE85",
1119             "final": "\uFE86"
1120           },
1121           "high_hamza": [
1122             "\u0676",
1123             "\u0648\u0674"
1124           ],
1125           "ring": [
1126             "\u06C4"
1127           ],
1128           "two_dots_above": [
1129             "\u06CA"
1130           ],
1131           "dot_above": [
1132             "\u06CF"
1133           ],
1134           "indic_two_above": [
1135             "\u0778"
1136           ],
1137           "indic_three_above": [
1138             "\u0779"
1139           ],
1140           "dot_within": [
1141             "\u08AB"
1142           ],
1143           "isolated": "\uFEED",
1144           "final": "\uFEEE"
1145         },
1146         "alef_maksura": {
1147           "normal": [
1148             "\u0649"
1149           ],
1150           "hamza_above": [
1151             "\u0626",
1152             "\u064A\u0654"
1153           ],
1154           "initial": "\uFBE8",
1155           "medial": "\uFBE9",
1156           "isolated": "\uFEEF",
1157           "final": "\uFEF0"
1158         },
1159         "yeh": {
1160           "normal": [
1161             "\u064A"
1162           ],
1163           "hamza_above": {
1164             "normal": [
1165               "\u0626",
1166               "\u0649\u0654"
1167             ],
1168             "isolated": "\uFE89",
1169             "final": "\uFE8A",
1170             "initial": "\uFE8B",
1171             "medial": "\uFE8C"
1172           },
1173           "two_dots_below_hamza_above": [
1174             "\u08A8"
1175           ],
1176           "high_hamza": [
1177             "\u0678",
1178             "\u064A\u0674"
1179           ],
1180           "tail": [
1181             "\u06CD"
1182           ],
1183           "small_v": [
1184             "\u06CE"
1185           ],
1186           "three_dots_below": [
1187             "\u06D1"
1188           ],
1189           "two_dots_below_dot_above": [
1190             "\u08A9"
1191           ],
1192           "two_dots_below_small_noon_above": [
1193             "\u08BA"
1194           ],
1195           "isolated": "\uFEF1",
1196           "final": "\uFEF2",
1197           "initial": "\uFEF3",
1198           "medial": "\uFEF4"
1199         },
1200         "tteh": {
1201           "normal": [
1202             "\u0679"
1203           ],
1204           "isolated": "\uFB66",
1205           "final": "\uFB67",
1206           "initial": "\uFB68",
1207           "medial": "\uFB69"
1208         },
1209         "tteheh": {
1210           "normal": [
1211             "\u067A"
1212           ],
1213           "isolated": "\uFB5E",
1214           "final": "\uFB5F",
1215           "initial": "\uFB60",
1216           "medial": "\uFB61"
1217         },
1218         "beeh": {
1219           "normal": [
1220             "\u067B"
1221           ],
1222           "isolated": "\uFB52",
1223           "final": "\uFB53",
1224           "initial": "\uFB54",
1225           "medial": "\uFB55"
1226         },
1227         "peh": {
1228           "normal": [
1229             "\u067E"
1230           ],
1231           "small_meem_above": [
1232             "\u08B7"
1233           ],
1234           "isolated": "\uFB56",
1235           "final": "\uFB57",
1236           "initial": "\uFB58",
1237           "medial": "\uFB59"
1238         },
1239         "teheh": {
1240           "normal": [
1241             "\u067F"
1242           ],
1243           "isolated": "\uFB62",
1244           "final": "\uFB63",
1245           "initial": "\uFB64",
1246           "medial": "\uFB65"
1247         },
1248         "beheh": {
1249           "normal": [
1250             "\u0680"
1251           ],
1252           "isolated": "\uFB5A",
1253           "final": "\uFB5B",
1254           "initial": "\uFB5C",
1255           "medial": "\uFB5D"
1256         },
1257         "nyeh": {
1258           "normal": [
1259             "\u0683"
1260           ],
1261           "isolated": "\uFB76",
1262           "final": "\uFB77",
1263           "initial": "\uFB78",
1264           "medial": "\uFB79"
1265         },
1266         "dyeh": {
1267           "normal": [
1268             "\u0684"
1269           ],
1270           "isolated": "\uFB72",
1271           "final": "\uFB73",
1272           "initial": "\uFB74",
1273           "medial": "\uFB75"
1274         },
1275         "tcheh": {
1276           "normal": [
1277             "\u0686"
1278           ],
1279           "dot_above": [
1280             "\u06BF"
1281           ],
1282           "isolated": "\uFB7A",
1283           "final": "\uFB7B",
1284           "initial": "\uFB7C",
1285           "medial": "\uFB7D"
1286         },
1287         "tcheheh": {
1288           "normal": [
1289             "\u0687"
1290           ],
1291           "isolated": "\uFB7E",
1292           "final": "\uFB7F",
1293           "initial": "\uFB80",
1294           "medial": "\uFB81"
1295         },
1296         "ddal": {
1297           "normal": [
1298             "\u0688"
1299           ],
1300           "isolated": "\uFB88",
1301           "final": "\uFB89"
1302         },
1303         "dahal": {
1304           "normal": [
1305             "\u068C"
1306           ],
1307           "isolated": "\uFB84",
1308           "final": "\uFB85"
1309         },
1310         "ddahal": {
1311           "normal": [
1312             "\u068D"
1313           ],
1314           "isolated": "\uFB82",
1315           "final": "\uFB83"
1316         },
1317         "dul": {
1318           "normal": [
1319             "\u068F",
1320             "\u068E"
1321           ],
1322           "isolated": "\uFB86",
1323           "final": "\uFB87"
1324         },
1325         "rreh": {
1326           "normal": [
1327             "\u0691"
1328           ],
1329           "isolated": "\uFB8C",
1330           "final": "\uFB8D"
1331         },
1332         "jeh": {
1333           "normal": [
1334             "\u0698"
1335           ],
1336           "isolated": "\uFB8A",
1337           "final": "\uFB8B"
1338         },
1339         "veh": {
1340           "normal": [
1341             "\u06A4"
1342           ],
1343           "isolated": "\uFB6A",
1344           "final": "\uFB6B",
1345           "initial": "\uFB6C",
1346           "medial": "\uFB6D"
1347         },
1348         "peheh": {
1349           "normal": [
1350             "\u06A6"
1351           ],
1352           "isolated": "\uFB6E",
1353           "final": "\uFB6F",
1354           "initial": "\uFB70",
1355           "medial": "\uFB71"
1356         },
1357         "keheh": {
1358           "normal": [
1359             "\u06A9"
1360           ],
1361           "dot_above": [
1362             "\u0762"
1363           ],
1364           "three_dots_above": [
1365             "\u0763"
1366           ],
1367           "three_dots_pointing_upwards_below": [
1368             "\u0764"
1369           ],
1370           "isolated": "\uFB8E",
1371           "final": "\uFB8F",
1372           "initial": "\uFB90",
1373           "medial": "\uFB91"
1374         },
1375         "ng": {
1376           "normal": [
1377             "\u06AD"
1378           ],
1379           "isolated": "\uFBD3",
1380           "final": "\uFBD4",
1381           "initial": "\uFBD5",
1382           "medial": "\uFBD6"
1383         },
1384         "gaf": {
1385           "normal": [
1386             "\u06AF"
1387           ],
1388           "ring": [
1389             "\u06B0"
1390           ],
1391           "two_dots_below": [
1392             "\u06B2"
1393           ],
1394           "three_dots_above": [
1395             "\u06B4"
1396           ],
1397           "inverted_stroke": [
1398             "\u08B0"
1399           ],
1400           "isolated": "\uFB92",
1401           "final": "\uFB93",
1402           "initial": "\uFB94",
1403           "medial": "\uFB95"
1404         },
1405         "ngoeh": {
1406           "normal": [
1407             "\u06B1"
1408           ],
1409           "isolated": "\uFB9A",
1410           "final": "\uFB9B",
1411           "initial": "\uFB9C",
1412           "medial": "\uFB9D"
1413         },
1414         "gueh": {
1415           "normal": [
1416             "\u06B3"
1417           ],
1418           "isolated": "\uFB96",
1419           "final": "\uFB97",
1420           "initial": "\uFB98",
1421           "medial": "\uFB99"
1422         },
1423         "noon ghunna": {
1424           "normal": [
1425             "\u06BA"
1426           ],
1427           "isolated": "\uFB9E",
1428           "final": "\uFB9F"
1429         },
1430         "rnoon": {
1431           "normal": [
1432             "\u06BB"
1433           ],
1434           "isolated": "\uFBA0",
1435           "final": "\uFBA1",
1436           "initial": "\uFBA2",
1437           "medial": "\uFBA3"
1438         },
1439         "heh doachashmee": {
1440           "normal": [
1441             "\u06BE"
1442           ],
1443           "isolated": "\uFBAA",
1444           "final": "\uFBAB",
1445           "initial": "\uFBAC",
1446           "medial": "\uFBAD"
1447         },
1448         "heh goal": {
1449           "normal": [
1450             "\u06C1"
1451           ],
1452           "hamza_above": [
1453             "\u06C1\u0654",
1454             "\u06C2"
1455           ],
1456           "isolated": "\uFBA6",
1457           "final": "\uFBA7",
1458           "initial": "\uFBA8",
1459           "medial": "\uFBA9"
1460         },
1461         "teh marbuta goal": {
1462           "normal": [
1463             "\u06C3"
1464           ]
1465         },
1466         "kirghiz oe": {
1467           "normal": [
1468             "\u06C5"
1469           ],
1470           "isolated": "\uFBE0",
1471           "final": "\uFBE1"
1472         },
1473         "oe": {
1474           "normal": [
1475             "\u06C6"
1476           ],
1477           "isolated": "\uFBD9",
1478           "final": "\uFBDA"
1479         },
1480         "u": {
1481           "normal": [
1482             "\u06C7"
1483           ],
1484           "hamza_above": {
1485             "normal": [
1486               "\u0677",
1487               "\u06C7\u0674"
1488             ],
1489             "isolated": "\uFBDD"
1490           },
1491           "isolated": "\uFBD7",
1492           "final": "\uFBD8"
1493         },
1494         "yu": {
1495           "normal": [
1496             "\u06C8"
1497           ],
1498           "isolated": "\uFBDB",
1499           "final": "\uFBDC"
1500         },
1501         "kirghiz yu": {
1502           "normal": [
1503             "\u06C9"
1504           ],
1505           "isolated": "\uFBE2",
1506           "final": "\uFBE3"
1507         },
1508         "ve": {
1509           "normal": [
1510             "\u06CB"
1511           ],
1512           "isolated": "\uFBDE",
1513           "final": "\uFBDF"
1514         },
1515         "farsi yeh": {
1516           "normal": [
1517             "\u06CC"
1518           ],
1519           "indic_two_above": [
1520             "\u0775"
1521           ],
1522           "indic_three_above": [
1523             "\u0776"
1524           ],
1525           "indic_four_above": [
1526             "\u0777"
1527           ],
1528           "isolated": "\uFBFC",
1529           "final": "\uFBFD",
1530           "initial": "\uFBFE",
1531           "medial": "\uFBFF"
1532         },
1533         "e": {
1534           "normal": [
1535             "\u06D0"
1536           ],
1537           "isolated": "\uFBE4",
1538           "final": "\uFBE5",
1539           "initial": "\uFBE6",
1540           "medial": "\uFBE7"
1541         },
1542         "yeh barree": {
1543           "normal": [
1544             "\u06D2"
1545           ],
1546           "hamza_above": {
1547             "normal": [
1548               "\u06D2\u0654",
1549               "\u06D3"
1550             ],
1551             "isolated": "\uFBB0",
1552             "final": "\uFBB1"
1553           },
1554           "indic_two_above": [
1555             "\u077A"
1556           ],
1557           "indic_three_above": [
1558             "\u077B"
1559           ],
1560           "isolated": "\uFBAE",
1561           "final": "\uFBAF"
1562         },
1563         "ae": {
1564           "normal": [
1565             "\u06D5"
1566           ],
1567           "isolated": "\u06D5",
1568           "final": "\uFEEA",
1569           "yeh_above": {
1570             "normal": [
1571               "\u06C0",
1572               "\u06D5\u0654"
1573             ],
1574             "isolated": "\uFBA4",
1575             "final": "\uFBA5"
1576           }
1577         },
1578         "rohingya yeh": {
1579           "normal": [
1580             "\u08AC"
1581           ]
1582         },
1583         "low alef": {
1584           "normal": [
1585             "\u08AD"
1586           ]
1587         },
1588         "straight waw": {
1589           "normal": [
1590             "\u08B1"
1591           ]
1592         },
1593         "african feh": {
1594           "normal": [
1595             "\u08BB"
1596           ]
1597         },
1598         "african qaf": {
1599           "normal": [
1600             "\u08BC"
1601           ]
1602         },
1603         "african noon": {
1604           "normal": [
1605             "\u08BD"
1606           ]
1607         }
1608       };
1609       exports2.default = arabicReference;
1610     }
1611   });
1612
1613   // node_modules/alif-toolkit/lib/unicode-ligatures.js
1614   var require_unicode_ligatures = __commonJS({
1615     "node_modules/alif-toolkit/lib/unicode-ligatures.js"(exports2) {
1616       "use strict";
1617       Object.defineProperty(exports2, "__esModule", { value: true });
1618       var ligatureReference = {
1619         "\u0626\u0627": {
1620           "isolated": "\uFBEA",
1621           "final": "\uFBEB"
1622         },
1623         "\u0626\u06D5": {
1624           "isolated": "\uFBEC",
1625           "final": "\uFBED"
1626         },
1627         "\u0626\u0648": {
1628           "isolated": "\uFBEE",
1629           "final": "\uFBEF"
1630         },
1631         "\u0626\u06C7": {
1632           "isolated": "\uFBF0",
1633           "final": "\uFBF1"
1634         },
1635         "\u0626\u06C6": {
1636           "isolated": "\uFBF2",
1637           "final": "\uFBF3"
1638         },
1639         "\u0626\u06C8": {
1640           "isolated": "\uFBF4",
1641           "final": "\uFBF5"
1642         },
1643         "\u0626\u06D0": {
1644           "isolated": "\uFBF6",
1645           "final": "\uFBF7",
1646           "initial": "\uFBF8"
1647         },
1648         "\u0626\u0649": {
1649           "uighur_kirghiz": {
1650             "isolated": "\uFBF9",
1651             "final": "\uFBFA",
1652             "initial": "\uFBFB"
1653           },
1654           "isolated": "\uFC03",
1655           "final": "\uFC68"
1656         },
1657         "\u0626\u062C": {
1658           "isolated": "\uFC00",
1659           "initial": "\uFC97"
1660         },
1661         "\u0626\u062D": {
1662           "isolated": "\uFC01",
1663           "initial": "\uFC98"
1664         },
1665         "\u0626\u0645": {
1666           "isolated": "\uFC02",
1667           "final": "\uFC66",
1668           "initial": "\uFC9A",
1669           "medial": "\uFCDF"
1670         },
1671         "\u0626\u064A": {
1672           "isolated": "\uFC04",
1673           "final": "\uFC69"
1674         },
1675         "\u0628\u062C": {
1676           "isolated": "\uFC05",
1677           "initial": "\uFC9C"
1678         },
1679         "\u0628\u062D": {
1680           "isolated": "\uFC06",
1681           "initial": "\uFC9D"
1682         },
1683         "\u0628\u062E": {
1684           "isolated": "\uFC07",
1685           "initial": "\uFC9E"
1686         },
1687         "\u0628\u0645": {
1688           "isolated": "\uFC08",
1689           "final": "\uFC6C",
1690           "initial": "\uFC9F",
1691           "medial": "\uFCE1"
1692         },
1693         "\u0628\u0649": {
1694           "isolated": "\uFC09",
1695           "final": "\uFC6E"
1696         },
1697         "\u0628\u064A": {
1698           "isolated": "\uFC0A",
1699           "final": "\uFC6F"
1700         },
1701         "\u062A\u062C": {
1702           "isolated": "\uFC0B",
1703           "initial": "\uFCA1"
1704         },
1705         "\u062A\u062D": {
1706           "isolated": "\uFC0C",
1707           "initial": "\uFCA2"
1708         },
1709         "\u062A\u062E": {
1710           "isolated": "\uFC0D",
1711           "initial": "\uFCA3"
1712         },
1713         "\u062A\u0645": {
1714           "isolated": "\uFC0E",
1715           "final": "\uFC72",
1716           "initial": "\uFCA4",
1717           "medial": "\uFCE3"
1718         },
1719         "\u062A\u0649": {
1720           "isolated": "\uFC0F",
1721           "final": "\uFC74"
1722         },
1723         "\u062A\u064A": {
1724           "isolated": "\uFC10",
1725           "final": "\uFC75"
1726         },
1727         "\u062B\u062C": {
1728           "isolated": "\uFC11"
1729         },
1730         "\u062B\u0645": {
1731           "isolated": "\uFC12",
1732           "final": "\uFC78",
1733           "initial": "\uFCA6",
1734           "medial": "\uFCE5"
1735         },
1736         "\u062B\u0649": {
1737           "isolated": "\uFC13",
1738           "final": "\uFC7A"
1739         },
1740         "\u062B\u0648": {
1741           "isolated": "\uFC14"
1742         },
1743         "\u062C\u062D": {
1744           "isolated": "\uFC15",
1745           "initial": "\uFCA7"
1746         },
1747         "\u062C\u0645": {
1748           "isolated": "\uFC16",
1749           "initial": "\uFCA8"
1750         },
1751         "\u062D\u062C": {
1752           "isolated": "\uFC17",
1753           "initial": "\uFCA9"
1754         },
1755         "\u062D\u0645": {
1756           "isolated": "\uFC18",
1757           "initial": "\uFCAA"
1758         },
1759         "\u062E\u062C": {
1760           "isolated": "\uFC19",
1761           "initial": "\uFCAB"
1762         },
1763         "\u062E\u062D": {
1764           "isolated": "\uFC1A"
1765         },
1766         "\u062E\u0645": {
1767           "isolated": "\uFC1B",
1768           "initial": "\uFCAC"
1769         },
1770         "\u0633\u062C": {
1771           "isolated": "\uFC1C",
1772           "initial": "\uFCAD",
1773           "medial": "\uFD34"
1774         },
1775         "\u0633\u062D": {
1776           "isolated": "\uFC1D",
1777           "initial": "\uFCAE",
1778           "medial": "\uFD35"
1779         },
1780         "\u0633\u062E": {
1781           "isolated": "\uFC1E",
1782           "initial": "\uFCAF",
1783           "medial": "\uFD36"
1784         },
1785         "\u0633\u0645": {
1786           "isolated": "\uFC1F",
1787           "initial": "\uFCB0",
1788           "medial": "\uFCE7"
1789         },
1790         "\u0635\u062D": {
1791           "isolated": "\uFC20",
1792           "initial": "\uFCB1"
1793         },
1794         "\u0635\u0645": {
1795           "isolated": "\uFC21",
1796           "initial": "\uFCB3"
1797         },
1798         "\u0636\u062C": {
1799           "isolated": "\uFC22",
1800           "initial": "\uFCB4"
1801         },
1802         "\u0636\u062D": {
1803           "isolated": "\uFC23",
1804           "initial": "\uFCB5"
1805         },
1806         "\u0636\u062E": {
1807           "isolated": "\uFC24",
1808           "initial": "\uFCB6"
1809         },
1810         "\u0636\u0645": {
1811           "isolated": "\uFC25",
1812           "initial": "\uFCB7"
1813         },
1814         "\u0637\u062D": {
1815           "isolated": "\uFC26",
1816           "initial": "\uFCB8"
1817         },
1818         "\u0637\u0645": {
1819           "isolated": "\uFC27",
1820           "initial": "\uFD33",
1821           "medial": "\uFD3A"
1822         },
1823         "\u0638\u0645": {
1824           "isolated": "\uFC28",
1825           "initial": "\uFCB9",
1826           "medial": "\uFD3B"
1827         },
1828         "\u0639\u062C": {
1829           "isolated": "\uFC29",
1830           "initial": "\uFCBA"
1831         },
1832         "\u0639\u0645": {
1833           "isolated": "\uFC2A",
1834           "initial": "\uFCBB"
1835         },
1836         "\u063A\u062C": {
1837           "isolated": "\uFC2B",
1838           "initial": "\uFCBC"
1839         },
1840         "\u063A\u0645": {
1841           "isolated": "\uFC2C",
1842           "initial": "\uFCBD"
1843         },
1844         "\u0641\u062C": {
1845           "isolated": "\uFC2D",
1846           "initial": "\uFCBE"
1847         },
1848         "\u0641\u062D": {
1849           "isolated": "\uFC2E",
1850           "initial": "\uFCBF"
1851         },
1852         "\u0641\u062E": {
1853           "isolated": "\uFC2F",
1854           "initial": "\uFCC0"
1855         },
1856         "\u0641\u0645": {
1857           "isolated": "\uFC30",
1858           "initial": "\uFCC1"
1859         },
1860         "\u0641\u0649": {
1861           "isolated": "\uFC31",
1862           "final": "\uFC7C"
1863         },
1864         "\u0641\u064A": {
1865           "isolated": "\uFC32",
1866           "final": "\uFC7D"
1867         },
1868         "\u0642\u062D": {
1869           "isolated": "\uFC33",
1870           "initial": "\uFCC2"
1871         },
1872         "\u0642\u0645": {
1873           "isolated": "\uFC34",
1874           "initial": "\uFCC3"
1875         },
1876         "\u0642\u0649": {
1877           "isolated": "\uFC35",
1878           "final": "\uFC7E"
1879         },
1880         "\u0642\u064A": {
1881           "isolated": "\uFC36",
1882           "final": "\uFC7F"
1883         },
1884         "\u0643\u0627": {
1885           "isolated": "\uFC37",
1886           "final": "\uFC80"
1887         },
1888         "\u0643\u062C": {
1889           "isolated": "\uFC38",
1890           "initial": "\uFCC4"
1891         },
1892         "\u0643\u062D": {
1893           "isolated": "\uFC39",
1894           "initial": "\uFCC5"
1895         },
1896         "\u0643\u062E": {
1897           "isolated": "\uFC3A",
1898           "initial": "\uFCC6"
1899         },
1900         "\u0643\u0644": {
1901           "isolated": "\uFC3B",
1902           "final": "\uFC81",
1903           "initial": "\uFCC7",
1904           "medial": "\uFCEB"
1905         },
1906         "\u0643\u0645": {
1907           "isolated": "\uFC3C",
1908           "final": "\uFC82",
1909           "initial": "\uFCC8",
1910           "medial": "\uFCEC"
1911         },
1912         "\u0643\u0649": {
1913           "isolated": "\uFC3D",
1914           "final": "\uFC83"
1915         },
1916         "\u0643\u064A": {
1917           "isolated": "\uFC3E",
1918           "final": "\uFC84"
1919         },
1920         "\u0644\u062C": {
1921           "isolated": "\uFC3F",
1922           "initial": "\uFCC9"
1923         },
1924         "\u0644\u062D": {
1925           "isolated": "\uFC40",
1926           "initial": "\uFCCA"
1927         },
1928         "\u0644\u062E": {
1929           "isolated": "\uFC41",
1930           "initial": "\uFCCB"
1931         },
1932         "\u0644\u0645": {
1933           "isolated": "\uFC42",
1934           "final": "\uFC85",
1935           "initial": "\uFCCC",
1936           "medial": "\uFCED"
1937         },
1938         "\u0644\u0649": {
1939           "isolated": "\uFC43",
1940           "final": "\uFC86"
1941         },
1942         "\u0644\u064A": {
1943           "isolated": "\uFC44",
1944           "final": "\uFC87"
1945         },
1946         "\u0645\u062C": {
1947           "isolated": "\uFC45",
1948           "initial": "\uFCCE"
1949         },
1950         "\u0645\u062D": {
1951           "isolated": "\uFC46",
1952           "initial": "\uFCCF"
1953         },
1954         "\u0645\u062E": {
1955           "isolated": "\uFC47",
1956           "initial": "\uFCD0"
1957         },
1958         "\u0645\u0645": {
1959           "isolated": "\uFC48",
1960           "final": "\uFC89",
1961           "initial": "\uFCD1"
1962         },
1963         "\u0645\u0649": {
1964           "isolated": "\uFC49"
1965         },
1966         "\u0645\u064A": {
1967           "isolated": "\uFC4A"
1968         },
1969         "\u0646\u062C": {
1970           "isolated": "\uFC4B",
1971           "initial": "\uFCD2"
1972         },
1973         "\u0646\u062D": {
1974           "isolated": "\uFC4C",
1975           "initial": "\uFCD3"
1976         },
1977         "\u0646\u062E": {
1978           "isolated": "\uFC4D",
1979           "initial": "\uFCD4"
1980         },
1981         "\u0646\u0645": {
1982           "isolated": "\uFC4E",
1983           "final": "\uFC8C",
1984           "initial": "\uFCD5",
1985           "medial": "\uFCEE"
1986         },
1987         "\u0646\u0649": {
1988           "isolated": "\uFC4F",
1989           "final": "\uFC8E"
1990         },
1991         "\u0646\u064A": {
1992           "isolated": "\uFC50",
1993           "final": "\uFC8F"
1994         },
1995         "\u0647\u062C": {
1996           "isolated": "\uFC51",
1997           "initial": "\uFCD7"
1998         },
1999         "\u0647\u0645": {
2000           "isolated": "\uFC52",
2001           "initial": "\uFCD8"
2002         },
2003         "\u0647\u0649": {
2004           "isolated": "\uFC53"
2005         },
2006         "\u0647\u064A": {
2007           "isolated": "\uFC54"
2008         },
2009         "\u064A\u062C": {
2010           "isolated": "\uFC55",
2011           "initial": "\uFCDA"
2012         },
2013         "\u064A\u062D": {
2014           "isolated": "\uFC56",
2015           "initial": "\uFCDB"
2016         },
2017         "\u064A\u062E": {
2018           "isolated": "\uFC57",
2019           "initial": "\uFCDC"
2020         },
2021         "\u064A\u0645": {
2022           "isolated": "\uFC58",
2023           "final": "\uFC93",
2024           "initial": "\uFCDD",
2025           "medial": "\uFCF0"
2026         },
2027         "\u064A\u0649": {
2028           "isolated": "\uFC59",
2029           "final": "\uFC95"
2030         },
2031         "\u064A\u064A": {
2032           "isolated": "\uFC5A",
2033           "final": "\uFC96"
2034         },
2035         "\u0630\u0670": {
2036           "isolated": "\uFC5B"
2037         },
2038         "\u0631\u0670": {
2039           "isolated": "\uFC5C"
2040         },
2041         "\u0649\u0670": {
2042           "isolated": "\uFC5D",
2043           "final": "\uFC90"
2044         },
2045         "\u064C\u0651": {
2046           "isolated": "\uFC5E"
2047         },
2048         "\u064D\u0651": {
2049           "isolated": "\uFC5F"
2050         },
2051         "\u064E\u0651": {
2052           "isolated": "\uFC60"
2053         },
2054         "\u064F\u0651": {
2055           "isolated": "\uFC61"
2056         },
2057         "\u0650\u0651": {
2058           "isolated": "\uFC62"
2059         },
2060         "\u0651\u0670": {
2061           "isolated": "\uFC63"
2062         },
2063         "\u0626\u0631": {
2064           "final": "\uFC64"
2065         },
2066         "\u0626\u0632": {
2067           "final": "\uFC65"
2068         },
2069         "\u0626\u0646": {
2070           "final": "\uFC67"
2071         },
2072         "\u0628\u0631": {
2073           "final": "\uFC6A"
2074         },
2075         "\u0628\u0632": {
2076           "final": "\uFC6B"
2077         },
2078         "\u0628\u0646": {
2079           "final": "\uFC6D"
2080         },
2081         "\u062A\u0631": {
2082           "final": "\uFC70"
2083         },
2084         "\u062A\u0632": {
2085           "final": "\uFC71"
2086         },
2087         "\u062A\u0646": {
2088           "final": "\uFC73"
2089         },
2090         "\u062B\u0631": {
2091           "final": "\uFC76"
2092         },
2093         "\u062B\u0632": {
2094           "final": "\uFC77"
2095         },
2096         "\u062B\u0646": {
2097           "final": "\uFC79"
2098         },
2099         "\u062B\u064A": {
2100           "final": "\uFC7B"
2101         },
2102         "\u0645\u0627": {
2103           "final": "\uFC88"
2104         },
2105         "\u0646\u0631": {
2106           "final": "\uFC8A"
2107         },
2108         "\u0646\u0632": {
2109           "final": "\uFC8B"
2110         },
2111         "\u0646\u0646": {
2112           "final": "\uFC8D"
2113         },
2114         "\u064A\u0631": {
2115           "final": "\uFC91"
2116         },
2117         "\u064A\u0632": {
2118           "final": "\uFC92"
2119         },
2120         "\u064A\u0646": {
2121           "final": "\uFC94"
2122         },
2123         "\u0626\u062E": {
2124           "initial": "\uFC99"
2125         },
2126         "\u0626\u0647": {
2127           "initial": "\uFC9B",
2128           "medial": "\uFCE0"
2129         },
2130         "\u0628\u0647": {
2131           "initial": "\uFCA0",
2132           "medial": "\uFCE2"
2133         },
2134         "\u062A\u0647": {
2135           "initial": "\uFCA5",
2136           "medial": "\uFCE4"
2137         },
2138         "\u0635\u062E": {
2139           "initial": "\uFCB2"
2140         },
2141         "\u0644\u0647": {
2142           "initial": "\uFCCD"
2143         },
2144         "\u0646\u0647": {
2145           "initial": "\uFCD6",
2146           "medial": "\uFCEF"
2147         },
2148         "\u0647\u0670": {
2149           "initial": "\uFCD9"
2150         },
2151         "\u064A\u0647": {
2152           "initial": "\uFCDE",
2153           "medial": "\uFCF1"
2154         },
2155         "\u062B\u0647": {
2156           "medial": "\uFCE6"
2157         },
2158         "\u0633\u0647": {
2159           "medial": "\uFCE8",
2160           "initial": "\uFD31"
2161         },
2162         "\u0634\u0645": {
2163           "medial": "\uFCE9",
2164           "isolated": "\uFD0C",
2165           "final": "\uFD28",
2166           "initial": "\uFD30"
2167         },
2168         "\u0634\u0647": {
2169           "medial": "\uFCEA",
2170           "initial": "\uFD32"
2171         },
2172         "\u0640\u064E\u0651": {
2173           "medial": "\uFCF2"
2174         },
2175         "\u0640\u064F\u0651": {
2176           "medial": "\uFCF3"
2177         },
2178         "\u0640\u0650\u0651": {
2179           "medial": "\uFCF4"
2180         },
2181         "\u0637\u0649": {
2182           "isolated": "\uFCF5",
2183           "final": "\uFD11"
2184         },
2185         "\u0637\u064A": {
2186           "isolated": "\uFCF6",
2187           "final": "\uFD12"
2188         },
2189         "\u0639\u0649": {
2190           "isolated": "\uFCF7",
2191           "final": "\uFD13"
2192         },
2193         "\u0639\u064A": {
2194           "isolated": "\uFCF8",
2195           "final": "\uFD14"
2196         },
2197         "\u063A\u0649": {
2198           "isolated": "\uFCF9",
2199           "final": "\uFD15"
2200         },
2201         "\u063A\u064A": {
2202           "isolated": "\uFCFA",
2203           "final": "\uFD16"
2204         },
2205         "\u0633\u0649": {
2206           "isolated": "\uFCFB"
2207         },
2208         "\u0633\u064A": {
2209           "isolated": "\uFCFC",
2210           "final": "\uFD18"
2211         },
2212         "\u0634\u0649": {
2213           "isolated": "\uFCFD",
2214           "final": "\uFD19"
2215         },
2216         "\u0634\u064A": {
2217           "isolated": "\uFCFE",
2218           "final": "\uFD1A"
2219         },
2220         "\u062D\u0649": {
2221           "isolated": "\uFCFF",
2222           "final": "\uFD1B"
2223         },
2224         "\u062D\u064A": {
2225           "isolated": "\uFD00",
2226           "final": "\uFD1C"
2227         },
2228         "\u062C\u0649": {
2229           "isolated": "\uFD01",
2230           "final": "\uFD1D"
2231         },
2232         "\u062C\u064A": {
2233           "isolated": "\uFD02",
2234           "final": "\uFD1E"
2235         },
2236         "\u062E\u0649": {
2237           "isolated": "\uFD03",
2238           "final": "\uFD1F"
2239         },
2240         "\u062E\u064A": {
2241           "isolated": "\uFD04",
2242           "final": "\uFD20"
2243         },
2244         "\u0635\u0649": {
2245           "isolated": "\uFD05",
2246           "final": "\uFD21"
2247         },
2248         "\u0635\u064A": {
2249           "isolated": "\uFD06",
2250           "final": "\uFD22"
2251         },
2252         "\u0636\u0649": {
2253           "isolated": "\uFD07",
2254           "final": "\uFD23"
2255         },
2256         "\u0636\u064A": {
2257           "isolated": "\uFD08",
2258           "final": "\uFD24"
2259         },
2260         "\u0634\u062C": {
2261           "isolated": "\uFD09",
2262           "final": "\uFD25",
2263           "initial": "\uFD2D",
2264           "medial": "\uFD37"
2265         },
2266         "\u0634\u062D": {
2267           "isolated": "\uFD0A",
2268           "final": "\uFD26",
2269           "initial": "\uFD2E",
2270           "medial": "\uFD38"
2271         },
2272         "\u0634\u062E": {
2273           "isolated": "\uFD0B",
2274           "final": "\uFD27",
2275           "initial": "\uFD2F",
2276           "medial": "\uFD39"
2277         },
2278         "\u0634\u0631": {
2279           "isolated": "\uFD0D",
2280           "final": "\uFD29"
2281         },
2282         "\u0633\u0631": {
2283           "isolated": "\uFD0E",
2284           "final": "\uFD2A"
2285         },
2286         "\u0635\u0631": {
2287           "isolated": "\uFD0F",
2288           "final": "\uFD2B"
2289         },
2290         "\u0636\u0631": {
2291           "isolated": "\uFD10",
2292           "final": "\uFD2C"
2293         },
2294         "\u0633\u0639": {
2295           "final": "\uFD17"
2296         },
2297         "\u062A\u062C\u0645": {
2298           "initial": "\uFD50"
2299         },
2300         "\u062A\u062D\u062C": {
2301           "final": "\uFD51",
2302           "initial": "\uFD52"
2303         },
2304         "\u062A\u062D\u0645": {
2305           "initial": "\uFD53"
2306         },
2307         "\u062A\u062E\u0645": {
2308           "initial": "\uFD54"
2309         },
2310         "\u062A\u0645\u062C": {
2311           "initial": "\uFD55"
2312         },
2313         "\u062A\u0645\u062D": {
2314           "initial": "\uFD56"
2315         },
2316         "\u062A\u0645\u062E": {
2317           "initial": "\uFD57"
2318         },
2319         "\u062C\u0645\u062D": {
2320           "final": "\uFD58",
2321           "initial": "\uFD59"
2322         },
2323         "\u062D\u0645\u064A": {
2324           "final": "\uFD5A"
2325         },
2326         "\u062D\u0645\u0649": {
2327           "final": "\uFD5B"
2328         },
2329         "\u0633\u062D\u062C": {
2330           "initial": "\uFD5C"
2331         },
2332         "\u0633\u062C\u062D": {
2333           "initial": "\uFD5D"
2334         },
2335         "\u0633\u062C\u0649": {
2336           "final": "\uFD5E"
2337         },
2338         "\u0633\u0645\u062D": {
2339           "final": "\uFD5F",
2340           "initial": "\uFD60"
2341         },
2342         "\u0633\u0645\u062C": {
2343           "initial": "\uFD61"
2344         },
2345         "\u0633\u0645\u0645": {
2346           "final": "\uFD62",
2347           "initial": "\uFD63"
2348         },
2349         "\u0635\u062D\u062D": {
2350           "final": "\uFD64",
2351           "initial": "\uFD65"
2352         },
2353         "\u0635\u0645\u0645": {
2354           "final": "\uFD66",
2355           "initial": "\uFDC5"
2356         },
2357         "\u0634\u062D\u0645": {
2358           "final": "\uFD67",
2359           "initial": "\uFD68"
2360         },
2361         "\u0634\u062C\u064A": {
2362           "final": "\uFD69"
2363         },
2364         "\u0634\u0645\u062E": {
2365           "final": "\uFD6A",
2366           "initial": "\uFD6B"
2367         },
2368         "\u0634\u0645\u0645": {
2369           "final": "\uFD6C",
2370           "initial": "\uFD6D"
2371         },
2372         "\u0636\u062D\u0649": {
2373           "final": "\uFD6E"
2374         },
2375         "\u0636\u062E\u0645": {
2376           "final": "\uFD6F",
2377           "initial": "\uFD70"
2378         },
2379         "\u0636\u0645\u062D": {
2380           "final": "\uFD71"
2381         },
2382         "\u0637\u0645\u062D": {
2383           "initial": "\uFD72"
2384         },
2385         "\u0637\u0645\u0645": {
2386           "initial": "\uFD73"
2387         },
2388         "\u0637\u0645\u064A": {
2389           "final": "\uFD74"
2390         },
2391         "\u0639\u062C\u0645": {
2392           "final": "\uFD75",
2393           "initial": "\uFDC4"
2394         },
2395         "\u0639\u0645\u0645": {
2396           "final": "\uFD76",
2397           "initial": "\uFD77"
2398         },
2399         "\u0639\u0645\u0649": {
2400           "final": "\uFD78"
2401         },
2402         "\u063A\u0645\u0645": {
2403           "final": "\uFD79"
2404         },
2405         "\u063A\u0645\u064A": {
2406           "final": "\uFD7A"
2407         },
2408         "\u063A\u0645\u0649": {
2409           "final": "\uFD7B"
2410         },
2411         "\u0641\u062E\u0645": {
2412           "final": "\uFD7C",
2413           "initial": "\uFD7D"
2414         },
2415         "\u0642\u0645\u062D": {
2416           "final": "\uFD7E",
2417           "initial": "\uFDB4"
2418         },
2419         "\u0642\u0645\u0645": {
2420           "final": "\uFD7F"
2421         },
2422         "\u0644\u062D\u0645": {
2423           "final": "\uFD80",
2424           "initial": "\uFDB5"
2425         },
2426         "\u0644\u062D\u064A": {
2427           "final": "\uFD81"
2428         },
2429         "\u0644\u062D\u0649": {
2430           "final": "\uFD82"
2431         },
2432         "\u0644\u062C\u062C": {
2433           "initial": "\uFD83",
2434           "final": "\uFD84"
2435         },
2436         "\u0644\u062E\u0645": {
2437           "final": "\uFD85",
2438           "initial": "\uFD86"
2439         },
2440         "\u0644\u0645\u062D": {
2441           "final": "\uFD87",
2442           "initial": "\uFD88"
2443         },
2444         "\u0645\u062D\u062C": {
2445           "initial": "\uFD89"
2446         },
2447         "\u0645\u062D\u0645": {
2448           "initial": "\uFD8A"
2449         },
2450         "\u0645\u062D\u064A": {
2451           "final": "\uFD8B"
2452         },
2453         "\u0645\u062C\u062D": {
2454           "initial": "\uFD8C"
2455         },
2456         "\u0645\u062C\u0645": {
2457           "initial": "\uFD8D"
2458         },
2459         "\u0645\u062E\u062C": {
2460           "initial": "\uFD8E"
2461         },
2462         "\u0645\u062E\u0645": {
2463           "initial": "\uFD8F"
2464         },
2465         "\u0645\u062C\u062E": {
2466           "initial": "\uFD92"
2467         },
2468         "\u0647\u0645\u062C": {
2469           "initial": "\uFD93"
2470         },
2471         "\u0647\u0645\u0645": {
2472           "initial": "\uFD94"
2473         },
2474         "\u0646\u062D\u0645": {
2475           "initial": "\uFD95"
2476         },
2477         "\u0646\u062D\u0649": {
2478           "final": "\uFD96"
2479         },
2480         "\u0646\u062C\u0645": {
2481           "final": "\uFD97",
2482           "initial": "\uFD98"
2483         },
2484         "\u0646\u062C\u0649": {
2485           "final": "\uFD99"
2486         },
2487         "\u0646\u0645\u064A": {
2488           "final": "\uFD9A"
2489         },
2490         "\u0646\u0645\u0649": {
2491           "final": "\uFD9B"
2492         },
2493         "\u064A\u0645\u0645": {
2494           "final": "\uFD9C",
2495           "initial": "\uFD9D"
2496         },
2497         "\u0628\u062E\u064A": {
2498           "final": "\uFD9E"
2499         },
2500         "\u062A\u062C\u064A": {
2501           "final": "\uFD9F"
2502         },
2503         "\u062A\u062C\u0649": {
2504           "final": "\uFDA0"
2505         },
2506         "\u062A\u062E\u064A": {
2507           "final": "\uFDA1"
2508         },
2509         "\u062A\u062E\u0649": {
2510           "final": "\uFDA2"
2511         },
2512         "\u062A\u0645\u064A": {
2513           "final": "\uFDA3"
2514         },
2515         "\u062A\u0645\u0649": {
2516           "final": "\uFDA4"
2517         },
2518         "\u062C\u0645\u064A": {
2519           "final": "\uFDA5"
2520         },
2521         "\u062C\u062D\u0649": {
2522           "final": "\uFDA6"
2523         },
2524         "\u062C\u0645\u0649": {
2525           "final": "\uFDA7"
2526         },
2527         "\u0633\u062E\u0649": {
2528           "final": "\uFDA8"
2529         },
2530         "\u0635\u062D\u064A": {
2531           "final": "\uFDA9"
2532         },
2533         "\u0634\u062D\u064A": {
2534           "final": "\uFDAA"
2535         },
2536         "\u0636\u062D\u064A": {
2537           "final": "\uFDAB"
2538         },
2539         "\u0644\u062C\u064A": {
2540           "final": "\uFDAC"
2541         },
2542         "\u0644\u0645\u064A": {
2543           "final": "\uFDAD"
2544         },
2545         "\u064A\u062D\u064A": {
2546           "final": "\uFDAE"
2547         },
2548         "\u064A\u062C\u064A": {
2549           "final": "\uFDAF"
2550         },
2551         "\u064A\u0645\u064A": {
2552           "final": "\uFDB0"
2553         },
2554         "\u0645\u0645\u064A": {
2555           "final": "\uFDB1"
2556         },
2557         "\u0642\u0645\u064A": {
2558           "final": "\uFDB2"
2559         },
2560         "\u0646\u062D\u064A": {
2561           "final": "\uFDB3"
2562         },
2563         "\u0639\u0645\u064A": {
2564           "final": "\uFDB6"
2565         },
2566         "\u0643\u0645\u064A": {
2567           "final": "\uFDB7"
2568         },
2569         "\u0646\u062C\u062D": {
2570           "initial": "\uFDB8",
2571           "final": "\uFDBD"
2572         },
2573         "\u0645\u062E\u064A": {
2574           "final": "\uFDB9"
2575         },
2576         "\u0644\u062C\u0645": {
2577           "initial": "\uFDBA",
2578           "final": "\uFDBC"
2579         },
2580         "\u0643\u0645\u0645": {
2581           "final": "\uFDBB",
2582           "initial": "\uFDC3"
2583         },
2584         "\u062C\u062D\u064A": {
2585           "final": "\uFDBE"
2586         },
2587         "\u062D\u062C\u064A": {
2588           "final": "\uFDBF"
2589         },
2590         "\u0645\u062C\u064A": {
2591           "final": "\uFDC0"
2592         },
2593         "\u0641\u0645\u064A": {
2594           "final": "\uFDC1"
2595         },
2596         "\u0628\u062D\u064A": {
2597           "final": "\uFDC2"
2598         },
2599         "\u0633\u062E\u064A": {
2600           "final": "\uFDC6"
2601         },
2602         "\u0646\u062C\u064A": {
2603           "final": "\uFDC7"
2604         },
2605         "\u0644\u0622": {
2606           "isolated": "\uFEF5",
2607           "final": "\uFEF6"
2608         },
2609         "\u0644\u0623": {
2610           "isolated": "\uFEF7",
2611           "final": "\uFEF8"
2612         },
2613         "\u0644\u0625": {
2614           "isolated": "\uFEF9",
2615           "final": "\uFEFA"
2616         },
2617         "\u0644\u0627": {
2618           "isolated": "\uFEFB",
2619           "final": "\uFEFC"
2620         },
2621         "words": {
2622           "\u0635\u0644\u06D2": "\uFDF0",
2623           "\u0642\u0644\u06D2": "\uFDF1",
2624           "\u0627\u0644\u0644\u0647": "\uFDF2",
2625           "\u0627\u0643\u0628\u0631": "\uFDF3",
2626           "\u0645\u062D\u0645\u062F": "\uFDF4",
2627           "\u0635\u0644\u0639\u0645": "\uFDF5",
2628           "\u0631\u0633\u0648\u0644": "\uFDF6",
2629           "\u0639\u0644\u064A\u0647": "\uFDF7",
2630           "\u0648\u0633\u0644\u0645": "\uFDF8",
2631           "\u0635\u0644\u0649": "\uFDF9",
2632           "\u0635\u0644\u0649\u0627\u0644\u0644\u0647\u0639\u0644\u064A\u0647\u0648\u0633\u0644\u0645": "\uFDFA",
2633           "\u062C\u0644\u062C\u0644\u0627\u0644\u0647": "\uFDFB",
2634           "\u0631\u06CC\u0627\u0644": "\uFDFC"
2635         }
2636       };
2637       exports2.default = ligatureReference;
2638     }
2639   });
2640
2641   // node_modules/alif-toolkit/lib/reference.js
2642   var require_reference = __commonJS({
2643     "node_modules/alif-toolkit/lib/reference.js"(exports2) {
2644       "use strict";
2645       Object.defineProperty(exports2, "__esModule", { value: true });
2646       var unicode_arabic_1 = require_unicode_arabic();
2647       var unicode_ligatures_1 = require_unicode_ligatures();
2648       var letterList = Object.keys(unicode_arabic_1.default);
2649       exports2.letterList = letterList;
2650       var ligatureList = Object.keys(unicode_ligatures_1.default);
2651       exports2.ligatureList = ligatureList;
2652       var ligatureWordList = Object.keys(unicode_ligatures_1.default.words);
2653       exports2.ligatureWordList = ligatureWordList;
2654       var lams = "\u0644\u06B5\u06B6\u06B7\u06B8";
2655       exports2.lams = lams;
2656       var alefs = "\u0627\u0622\u0623\u0625\u0671\u0672\u0673\u0675\u0773\u0774";
2657       exports2.alefs = alefs;
2658       var tashkeel = "\u0605\u0640\u0670\u0674\u06DF\u06E7\u06E8";
2659       exports2.tashkeel = tashkeel;
2660       function addToTashkeel(start2, finish) {
2661         for (var i3 = start2; i3 <= finish; i3++) {
2662           exports2.tashkeel = tashkeel += String.fromCharCode(i3);
2663         }
2664       }
2665       addToTashkeel(1552, 1562);
2666       addToTashkeel(1611, 1631);
2667       addToTashkeel(1750, 1756);
2668       addToTashkeel(1760, 1764);
2669       addToTashkeel(1770, 1773);
2670       addToTashkeel(2259, 2273);
2671       addToTashkeel(2275, 2303);
2672       addToTashkeel(65136, 65151);
2673       var lineBreakers = "\u0627\u0629\u0648\u06C0\u06CF\u06FD\u06FE\u076B\u076C\u0771\u0773\u0774\u0778\u0779\u08E2\u08B1\u08B2\u08B9";
2674       exports2.lineBreakers = lineBreakers;
2675       function addToLineBreakers(start2, finish) {
2676         for (var i3 = start2; i3 <= finish; i3++) {
2677           exports2.lineBreakers = lineBreakers += String.fromCharCode(i3);
2678         }
2679       }
2680       addToLineBreakers(1536, 1567);
2681       addToLineBreakers(1569, 1573);
2682       addToLineBreakers(1583, 1586);
2683       addToLineBreakers(1632, 1645);
2684       addToLineBreakers(1649, 1655);
2685       addToLineBreakers(1672, 1689);
2686       addToLineBreakers(1731, 1739);
2687       addToLineBreakers(1746, 1785);
2688       addToLineBreakers(1881, 1883);
2689       addToLineBreakers(2218, 2222);
2690       addToLineBreakers(64336, 65021);
2691       addToLineBreakers(65152, 65276);
2692       addToLineBreakers(69216, 69247);
2693       addToLineBreakers(126064, 126143);
2694       addToLineBreakers(126464, 126719);
2695     }
2696   });
2697
2698   // node_modules/alif-toolkit/lib/GlyphSplitter.js
2699   var require_GlyphSplitter = __commonJS({
2700     "node_modules/alif-toolkit/lib/GlyphSplitter.js"(exports2) {
2701       "use strict";
2702       Object.defineProperty(exports2, "__esModule", { value: true });
2703       var isArabic_1 = require_isArabic();
2704       var reference_1 = require_reference();
2705       function GlyphSplitter(word) {
2706         let letters = [];
2707         let lastLetter = "";
2708         word.split("").forEach((letter) => {
2709           if (isArabic_1.isArabic(letter)) {
2710             if (reference_1.tashkeel.indexOf(letter) > -1) {
2711               letters[letters.length - 1] += letter;
2712             } else if (lastLetter.length && (reference_1.lams.indexOf(lastLetter) === 0 && reference_1.alefs.indexOf(letter) > -1 || reference_1.lams.indexOf(lastLetter) > 0 && reference_1.alefs.indexOf(letter) === 0)) {
2713               letters[letters.length - 1] += letter;
2714             } else {
2715               letters.push(letter);
2716             }
2717           } else {
2718             letters.push(letter);
2719           }
2720           if (reference_1.tashkeel.indexOf(letter) === -1) {
2721             lastLetter = letter;
2722           }
2723         });
2724         return letters;
2725       }
2726       exports2.GlyphSplitter = GlyphSplitter;
2727     }
2728   });
2729
2730   // node_modules/alif-toolkit/lib/BaselineSplitter.js
2731   var require_BaselineSplitter = __commonJS({
2732     "node_modules/alif-toolkit/lib/BaselineSplitter.js"(exports2) {
2733       "use strict";
2734       Object.defineProperty(exports2, "__esModule", { value: true });
2735       var isArabic_1 = require_isArabic();
2736       var reference_1 = require_reference();
2737       function BaselineSplitter(word) {
2738         let letters = [];
2739         let lastLetter = "";
2740         word.split("").forEach((letter) => {
2741           if (isArabic_1.isArabic(letter) && isArabic_1.isArabic(lastLetter)) {
2742             if (lastLetter.length && reference_1.tashkeel.indexOf(letter) > -1) {
2743               letters[letters.length - 1] += letter;
2744             } else if (reference_1.lineBreakers.indexOf(lastLetter) > -1) {
2745               letters.push(letter);
2746             } else {
2747               letters[letters.length - 1] += letter;
2748             }
2749           } else {
2750             letters.push(letter);
2751           }
2752           if (reference_1.tashkeel.indexOf(letter) === -1) {
2753             lastLetter = letter;
2754           }
2755         });
2756         return letters;
2757       }
2758       exports2.BaselineSplitter = BaselineSplitter;
2759     }
2760   });
2761
2762   // node_modules/alif-toolkit/lib/Normalization.js
2763   var require_Normalization = __commonJS({
2764     "node_modules/alif-toolkit/lib/Normalization.js"(exports2) {
2765       "use strict";
2766       Object.defineProperty(exports2, "__esModule", { value: true });
2767       var unicode_arabic_1 = require_unicode_arabic();
2768       var unicode_ligatures_1 = require_unicode_ligatures();
2769       var isArabic_1 = require_isArabic();
2770       var reference_1 = require_reference();
2771       function Normal(word, breakPresentationForm) {
2772         if (typeof breakPresentationForm === "undefined") {
2773           breakPresentationForm = true;
2774         }
2775         let returnable = "";
2776         word.split("").forEach((letter) => {
2777           if (!isArabic_1.isArabic(letter)) {
2778             returnable += letter;
2779             return;
2780           }
2781           for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2782             let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2783             let versions = Object.keys(letterForms);
2784             for (let v2 = 0; v2 < versions.length; v2++) {
2785               let localVersion = letterForms[versions[v2]];
2786               if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2787                 let embeddedForms = Object.keys(localVersion);
2788                 for (let ef = 0; ef < embeddedForms.length; ef++) {
2789                   let form = localVersion[embeddedForms[ef]];
2790                   if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2791                     if (form === letter) {
2792                       if (breakPresentationForm && localVersion["normal"] && ["isolated", "initial", "medial", "final"].indexOf(embeddedForms[ef]) > -1) {
2793                         if (typeof localVersion["normal"] === "object") {
2794                           returnable += localVersion["normal"][0];
2795                         } else {
2796                           returnable += localVersion["normal"];
2797                         }
2798                         return;
2799                       }
2800                       returnable += letter;
2801                       return;
2802                     } else if (typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2803                       returnable += form[0];
2804                       return;
2805                     }
2806                   }
2807                 }
2808               } else if (localVersion === letter) {
2809                 if (breakPresentationForm && letterForms["normal"] && ["isolated", "initial", "medial", "final"].indexOf(versions[v2]) > -1) {
2810                   if (typeof letterForms["normal"] === "object") {
2811                     returnable += letterForms["normal"][0];
2812                   } else {
2813                     returnable += letterForms["normal"];
2814                   }
2815                   return;
2816                 }
2817                 returnable += letter;
2818                 return;
2819               } else if (typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2820                 returnable += localVersion[0];
2821                 return;
2822               }
2823             }
2824           }
2825           for (let v2 = 0; v2 < reference_1.ligatureList.length; v2++) {
2826             let normalForm = reference_1.ligatureList[v2];
2827             if (normalForm !== "words") {
2828               let ligForms = Object.keys(unicode_ligatures_1.default[normalForm]);
2829               for (let f2 = 0; f2 < ligForms.length; f2++) {
2830                 if (unicode_ligatures_1.default[normalForm][ligForms[f2]] === letter) {
2831                   returnable += normalForm;
2832                   return;
2833                 }
2834               }
2835             }
2836           }
2837           for (let v3 = 0; v3 < reference_1.ligatureWordList.length; v3++) {
2838             let normalForm = reference_1.ligatureWordList[v3];
2839             if (unicode_ligatures_1.default.words[normalForm] === letter) {
2840               returnable += normalForm;
2841               return;
2842             }
2843           }
2844           returnable += letter;
2845         });
2846         return returnable;
2847       }
2848       exports2.Normal = Normal;
2849     }
2850   });
2851
2852   // node_modules/alif-toolkit/lib/CharShaper.js
2853   var require_CharShaper = __commonJS({
2854     "node_modules/alif-toolkit/lib/CharShaper.js"(exports2) {
2855       "use strict";
2856       Object.defineProperty(exports2, "__esModule", { value: true });
2857       var unicode_arabic_1 = require_unicode_arabic();
2858       var isArabic_1 = require_isArabic();
2859       var reference_1 = require_reference();
2860       function CharShaper(letter, form) {
2861         if (!isArabic_1.isArabic(letter)) {
2862           throw new Error("Not Arabic");
2863         }
2864         if (letter === "\u0621") {
2865           return "\u0621";
2866         }
2867         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2868           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2869           let versions = Object.keys(letterForms);
2870           for (let v2 = 0; v2 < versions.length; v2++) {
2871             let localVersion = letterForms[versions[v2]];
2872             if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2873               if (versions.indexOf(form) > -1) {
2874                 return letterForms[form];
2875               }
2876             } else if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2877               let embeddedVersions = Object.keys(localVersion);
2878               for (let ev = 0; ev < embeddedVersions.length; ev++) {
2879                 if (localVersion[embeddedVersions[ev]] === letter || typeof localVersion[embeddedVersions[ev]] === "object" && localVersion[embeddedVersions[ev]].indexOf && localVersion[embeddedVersions[ev]].indexOf(letter) > -1) {
2880                   if (embeddedVersions.indexOf(form) > -1) {
2881                     return localVersion[form];
2882                   }
2883                 }
2884               }
2885             }
2886           }
2887         }
2888       }
2889       exports2.CharShaper = CharShaper;
2890     }
2891   });
2892
2893   // node_modules/alif-toolkit/lib/WordShaper.js
2894   var require_WordShaper = __commonJS({
2895     "node_modules/alif-toolkit/lib/WordShaper.js"(exports2) {
2896       "use strict";
2897       Object.defineProperty(exports2, "__esModule", { value: true });
2898       var isArabic_1 = require_isArabic();
2899       var reference_1 = require_reference();
2900       var CharShaper_1 = require_CharShaper();
2901       var unicode_ligatures_1 = require_unicode_ligatures();
2902       function WordShaper2(word) {
2903         let state = "initial";
2904         let output = "";
2905         for (let w2 = 0; w2 < word.length; w2++) {
2906           let nextLetter = " ";
2907           for (let nxw = w2 + 1; nxw < word.length; nxw++) {
2908             if (!isArabic_1.isArabic(word[nxw])) {
2909               break;
2910             }
2911             if (reference_1.tashkeel.indexOf(word[nxw]) === -1) {
2912               nextLetter = word[nxw];
2913               break;
2914             }
2915           }
2916           if (!isArabic_1.isArabic(word[w2]) || isArabic_1.isMath(word[w2])) {
2917             output += word[w2];
2918             state = "initial";
2919           } else if (reference_1.tashkeel.indexOf(word[w2]) > -1) {
2920             output += word[w2];
2921           } else if (nextLetter === " " || reference_1.lineBreakers.indexOf(word[w2]) > -1) {
2922             output += CharShaper_1.CharShaper(word[w2], state === "initial" ? "isolated" : "final");
2923             state = "initial";
2924           } else if (reference_1.lams.indexOf(word[w2]) > -1 && reference_1.alefs.indexOf(nextLetter) > -1) {
2925             output += unicode_ligatures_1.default[word[w2] + nextLetter][state === "initial" ? "isolated" : "final"];
2926             while (word[w2] !== nextLetter) {
2927               w2++;
2928             }
2929             state = "initial";
2930           } else {
2931             output += CharShaper_1.CharShaper(word[w2], state);
2932             state = "medial";
2933           }
2934         }
2935         return output;
2936       }
2937       exports2.WordShaper = WordShaper2;
2938     }
2939   });
2940
2941   // node_modules/alif-toolkit/lib/ParentLetter.js
2942   var require_ParentLetter = __commonJS({
2943     "node_modules/alif-toolkit/lib/ParentLetter.js"(exports2) {
2944       "use strict";
2945       Object.defineProperty(exports2, "__esModule", { value: true });
2946       var unicode_arabic_1 = require_unicode_arabic();
2947       var isArabic_1 = require_isArabic();
2948       var reference_1 = require_reference();
2949       function ParentLetter(letter) {
2950         if (!isArabic_1.isArabic(letter)) {
2951           throw new Error("Not an Arabic letter");
2952         }
2953         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2954           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2955           let versions = Object.keys(letterForms);
2956           for (let v2 = 0; v2 < versions.length; v2++) {
2957             let localVersion = letterForms[versions[v2]];
2958             if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2959               let embeddedForms = Object.keys(localVersion);
2960               for (let ef = 0; ef < embeddedForms.length; ef++) {
2961                 let form = localVersion[embeddedForms[ef]];
2962                 if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2963                   return localVersion;
2964                 }
2965               }
2966             } else if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2967               return letterForms;
2968             }
2969           }
2970           return null;
2971         }
2972       }
2973       exports2.ParentLetter = ParentLetter;
2974       function GrandparentLetter(letter) {
2975         if (!isArabic_1.isArabic(letter)) {
2976           throw new Error("Not an Arabic letter");
2977         }
2978         for (let w2 = 0; w2 < reference_1.letterList.length; w2++) {
2979           let letterForms = unicode_arabic_1.default[reference_1.letterList[w2]];
2980           let versions = Object.keys(letterForms);
2981           for (let v2 = 0; v2 < versions.length; v2++) {
2982             let localVersion = letterForms[versions[v2]];
2983             if (typeof localVersion === "object" && typeof localVersion.indexOf === "undefined") {
2984               let embeddedForms = Object.keys(localVersion);
2985               for (let ef = 0; ef < embeddedForms.length; ef++) {
2986                 let form = localVersion[embeddedForms[ef]];
2987                 if (form === letter || typeof form === "object" && form.indexOf && form.indexOf(letter) > -1) {
2988                   return letterForms;
2989                 }
2990               }
2991             } else if (localVersion === letter || typeof localVersion === "object" && localVersion.indexOf && localVersion.indexOf(letter) > -1) {
2992               return letterForms;
2993             }
2994           }
2995           return null;
2996         }
2997       }
2998       exports2.GrandparentLetter = GrandparentLetter;
2999     }
3000   });
3001
3002   // node_modules/alif-toolkit/lib/index.js
3003   var require_lib = __commonJS({
3004     "node_modules/alif-toolkit/lib/index.js"(exports2) {
3005       "use strict";
3006       Object.defineProperty(exports2, "__esModule", { value: true });
3007       var isArabic_1 = require_isArabic();
3008       exports2.isArabic = isArabic_1.isArabic;
3009       var GlyphSplitter_1 = require_GlyphSplitter();
3010       exports2.GlyphSplitter = GlyphSplitter_1.GlyphSplitter;
3011       var BaselineSplitter_1 = require_BaselineSplitter();
3012       exports2.BaselineSplitter = BaselineSplitter_1.BaselineSplitter;
3013       var Normalization_1 = require_Normalization();
3014       exports2.Normal = Normalization_1.Normal;
3015       var CharShaper_1 = require_CharShaper();
3016       exports2.CharShaper = CharShaper_1.CharShaper;
3017       var WordShaper_1 = require_WordShaper();
3018       exports2.WordShaper = WordShaper_1.WordShaper;
3019       var ParentLetter_1 = require_ParentLetter();
3020       exports2.ParentLetter = ParentLetter_1.ParentLetter;
3021       exports2.GrandparentLetter = ParentLetter_1.GrandparentLetter;
3022     }
3023   });
3024
3025   // node_modules/vparse/index.js
3026   var require_vparse = __commonJS({
3027     "node_modules/vparse/index.js"(exports2, module2) {
3028       (function(window2) {
3029         "use strict";
3030         function parseVersion3(v2) {
3031           var m2 = v2.replace(/[^0-9.]/g, "").match(/[0-9]*\.|[0-9]+/g) || [];
3032           v2 = {
3033             major: +m2[0] || 0,
3034             minor: +m2[1] || 0,
3035             patch: +m2[2] || 0,
3036             build: +m2[3] || 0
3037           };
3038           v2.isEmpty = !v2.major && !v2.minor && !v2.patch && !v2.build;
3039           v2.parsed = [v2.major, v2.minor, v2.patch, v2.build];
3040           v2.text = v2.parsed.join(".");
3041           v2.compare = compare2;
3042           return v2;
3043         }
3044         function compare2(v2) {
3045           if (typeof v2 === "string") {
3046             v2 = parseVersion3(v2);
3047           }
3048           for (var i3 = 0; i3 < 4; i3++) {
3049             if (this.parsed[i3] !== v2.parsed[i3]) {
3050               return this.parsed[i3] > v2.parsed[i3] ? 1 : -1;
3051             }
3052           }
3053           return 0;
3054         }
3055         if (typeof module2 === "object" && module2 && typeof module2.exports === "object") {
3056           module2.exports = parseVersion3;
3057         } else {
3058           window2.parseVersion = parseVersion3;
3059         }
3060       })(exports2);
3061     }
3062   });
3063
3064   // node_modules/which-polygon/node_modules/quickselect/quickselect.js
3065   var require_quickselect = __commonJS({
3066     "node_modules/which-polygon/node_modules/quickselect/quickselect.js"(exports2, module2) {
3067       (function(global2, factory) {
3068         typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.quickselect = factory();
3069       })(exports2, function() {
3070         "use strict";
3071         function quickselect2(arr, k2, left, right, compare2) {
3072           quickselectStep(arr, k2, left || 0, right || arr.length - 1, compare2 || defaultCompare);
3073         }
3074         function quickselectStep(arr, k2, left, right, compare2) {
3075           while (right > left) {
3076             if (right - left > 600) {
3077               var n3 = right - left + 1;
3078               var m2 = k2 - left + 1;
3079               var z2 = Math.log(n3);
3080               var s2 = 0.5 * Math.exp(2 * z2 / 3);
3081               var sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
3082               var newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
3083               var newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
3084               quickselectStep(arr, k2, newLeft, newRight, compare2);
3085             }
3086             var t2 = arr[k2];
3087             var i3 = left;
3088             var j2 = right;
3089             swap2(arr, left, k2);
3090             if (compare2(arr[right], t2) > 0)
3091               swap2(arr, left, right);
3092             while (i3 < j2) {
3093               swap2(arr, i3, j2);
3094               i3++;
3095               j2--;
3096               while (compare2(arr[i3], t2) < 0)
3097                 i3++;
3098               while (compare2(arr[j2], t2) > 0)
3099                 j2--;
3100             }
3101             if (compare2(arr[left], t2) === 0)
3102               swap2(arr, left, j2);
3103             else {
3104               j2++;
3105               swap2(arr, j2, right);
3106             }
3107             if (j2 <= k2)
3108               left = j2 + 1;
3109             if (k2 <= j2)
3110               right = j2 - 1;
3111           }
3112         }
3113         function swap2(arr, i3, j2) {
3114           var tmp = arr[i3];
3115           arr[i3] = arr[j2];
3116           arr[j2] = tmp;
3117         }
3118         function defaultCompare(a2, b2) {
3119           return a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
3120         }
3121         return quickselect2;
3122       });
3123     }
3124   });
3125
3126   // node_modules/which-polygon/node_modules/rbush/index.js
3127   var require_rbush = __commonJS({
3128     "node_modules/which-polygon/node_modules/rbush/index.js"(exports2, module2) {
3129       "use strict";
3130       module2.exports = rbush;
3131       module2.exports.default = rbush;
3132       var quickselect2 = require_quickselect();
3133       function rbush(maxEntries, format2) {
3134         if (!(this instanceof rbush))
3135           return new rbush(maxEntries, format2);
3136         this._maxEntries = Math.max(4, maxEntries || 9);
3137         this._minEntries = Math.max(2, Math.ceil(this._maxEntries * 0.4));
3138         if (format2) {
3139           this._initFormat(format2);
3140         }
3141         this.clear();
3142       }
3143       rbush.prototype = {
3144         all: function() {
3145           return this._all(this.data, []);
3146         },
3147         search: function(bbox2) {
3148           var node = this.data, result = [], toBBox = this.toBBox;
3149           if (!intersects(bbox2, node))
3150             return result;
3151           var nodesToSearch = [], i3, len, child, childBBox;
3152           while (node) {
3153             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
3154               child = node.children[i3];
3155               childBBox = node.leaf ? toBBox(child) : child;
3156               if (intersects(bbox2, childBBox)) {
3157                 if (node.leaf)
3158                   result.push(child);
3159                 else if (contains(bbox2, childBBox))
3160                   this._all(child, result);
3161                 else
3162                   nodesToSearch.push(child);
3163               }
3164             }
3165             node = nodesToSearch.pop();
3166           }
3167           return result;
3168         },
3169         collides: function(bbox2) {
3170           var node = this.data, toBBox = this.toBBox;
3171           if (!intersects(bbox2, node))
3172             return false;
3173           var nodesToSearch = [], i3, len, child, childBBox;
3174           while (node) {
3175             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
3176               child = node.children[i3];
3177               childBBox = node.leaf ? toBBox(child) : child;
3178               if (intersects(bbox2, childBBox)) {
3179                 if (node.leaf || contains(bbox2, childBBox))
3180                   return true;
3181                 nodesToSearch.push(child);
3182               }
3183             }
3184             node = nodesToSearch.pop();
3185           }
3186           return false;
3187         },
3188         load: function(data) {
3189           if (!(data && data.length))
3190             return this;
3191           if (data.length < this._minEntries) {
3192             for (var i3 = 0, len = data.length; i3 < len; i3++) {
3193               this.insert(data[i3]);
3194             }
3195             return this;
3196           }
3197           var node = this._build(data.slice(), 0, data.length - 1, 0);
3198           if (!this.data.children.length) {
3199             this.data = node;
3200           } else if (this.data.height === node.height) {
3201             this._splitRoot(this.data, node);
3202           } else {
3203             if (this.data.height < node.height) {
3204               var tmpNode = this.data;
3205               this.data = node;
3206               node = tmpNode;
3207             }
3208             this._insert(node, this.data.height - node.height - 1, true);
3209           }
3210           return this;
3211         },
3212         insert: function(item) {
3213           if (item)
3214             this._insert(item, this.data.height - 1);
3215           return this;
3216         },
3217         clear: function() {
3218           this.data = createNode([]);
3219           return this;
3220         },
3221         remove: function(item, equalsFn) {
3222           if (!item)
3223             return this;
3224           var node = this.data, bbox2 = this.toBBox(item), path = [], indexes = [], i3, parent, index, goingUp;
3225           while (node || path.length) {
3226             if (!node) {
3227               node = path.pop();
3228               parent = path[path.length - 1];
3229               i3 = indexes.pop();
3230               goingUp = true;
3231             }
3232             if (node.leaf) {
3233               index = findItem(item, node.children, equalsFn);
3234               if (index !== -1) {
3235                 node.children.splice(index, 1);
3236                 path.push(node);
3237                 this._condense(path);
3238                 return this;
3239               }
3240             }
3241             if (!goingUp && !node.leaf && contains(node, bbox2)) {
3242               path.push(node);
3243               indexes.push(i3);
3244               i3 = 0;
3245               parent = node;
3246               node = node.children[0];
3247             } else if (parent) {
3248               i3++;
3249               node = parent.children[i3];
3250               goingUp = false;
3251             } else
3252               node = null;
3253           }
3254           return this;
3255         },
3256         toBBox: function(item) {
3257           return item;
3258         },
3259         compareMinX: compareNodeMinX,
3260         compareMinY: compareNodeMinY,
3261         toJSON: function() {
3262           return this.data;
3263         },
3264         fromJSON: function(data) {
3265           this.data = data;
3266           return this;
3267         },
3268         _all: function(node, result) {
3269           var nodesToSearch = [];
3270           while (node) {
3271             if (node.leaf)
3272               result.push.apply(result, node.children);
3273             else
3274               nodesToSearch.push.apply(nodesToSearch, node.children);
3275             node = nodesToSearch.pop();
3276           }
3277           return result;
3278         },
3279         _build: function(items, left, right, height) {
3280           var N2 = right - left + 1, M2 = this._maxEntries, node;
3281           if (N2 <= M2) {
3282             node = createNode(items.slice(left, right + 1));
3283             calcBBox(node, this.toBBox);
3284             return node;
3285           }
3286           if (!height) {
3287             height = Math.ceil(Math.log(N2) / Math.log(M2));
3288             M2 = Math.ceil(N2 / Math.pow(M2, height - 1));
3289           }
3290           node = createNode([]);
3291           node.leaf = false;
3292           node.height = height;
3293           var N22 = Math.ceil(N2 / M2), N1 = N22 * Math.ceil(Math.sqrt(M2)), i3, j2, right2, right3;
3294           multiSelect(items, left, right, N1, this.compareMinX);
3295           for (i3 = left; i3 <= right; i3 += N1) {
3296             right2 = Math.min(i3 + N1 - 1, right);
3297             multiSelect(items, i3, right2, N22, this.compareMinY);
3298             for (j2 = i3; j2 <= right2; j2 += N22) {
3299               right3 = Math.min(j2 + N22 - 1, right2);
3300               node.children.push(this._build(items, j2, right3, height - 1));
3301             }
3302           }
3303           calcBBox(node, this.toBBox);
3304           return node;
3305         },
3306         _chooseSubtree: function(bbox2, node, level, path) {
3307           var i3, len, child, targetNode, area, enlargement, minArea, minEnlargement;
3308           while (true) {
3309             path.push(node);
3310             if (node.leaf || path.length - 1 === level)
3311               break;
3312             minArea = minEnlargement = Infinity;
3313             for (i3 = 0, len = node.children.length; i3 < len; i3++) {
3314               child = node.children[i3];
3315               area = bboxArea(child);
3316               enlargement = enlargedArea(bbox2, child) - area;
3317               if (enlargement < minEnlargement) {
3318                 minEnlargement = enlargement;
3319                 minArea = area < minArea ? area : minArea;
3320                 targetNode = child;
3321               } else if (enlargement === minEnlargement) {
3322                 if (area < minArea) {
3323                   minArea = area;
3324                   targetNode = child;
3325                 }
3326               }
3327             }
3328             node = targetNode || node.children[0];
3329           }
3330           return node;
3331         },
3332         _insert: function(item, level, isNode) {
3333           var toBBox = this.toBBox, bbox2 = isNode ? item : toBBox(item), insertPath = [];
3334           var node = this._chooseSubtree(bbox2, this.data, level, insertPath);
3335           node.children.push(item);
3336           extend2(node, bbox2);
3337           while (level >= 0) {
3338             if (insertPath[level].children.length > this._maxEntries) {
3339               this._split(insertPath, level);
3340               level--;
3341             } else
3342               break;
3343           }
3344           this._adjustParentBBoxes(bbox2, insertPath, level);
3345         },
3346         // split overflowed node into two
3347         _split: function(insertPath, level) {
3348           var node = insertPath[level], M2 = node.children.length, m2 = this._minEntries;
3349           this._chooseSplitAxis(node, m2, M2);
3350           var splitIndex = this._chooseSplitIndex(node, m2, M2);
3351           var newNode = createNode(node.children.splice(splitIndex, node.children.length - splitIndex));
3352           newNode.height = node.height;
3353           newNode.leaf = node.leaf;
3354           calcBBox(node, this.toBBox);
3355           calcBBox(newNode, this.toBBox);
3356           if (level)
3357             insertPath[level - 1].children.push(newNode);
3358           else
3359             this._splitRoot(node, newNode);
3360         },
3361         _splitRoot: function(node, newNode) {
3362           this.data = createNode([node, newNode]);
3363           this.data.height = node.height + 1;
3364           this.data.leaf = false;
3365           calcBBox(this.data, this.toBBox);
3366         },
3367         _chooseSplitIndex: function(node, m2, M2) {
3368           var i3, bbox1, bbox2, overlap, area, minOverlap, minArea, index;
3369           minOverlap = minArea = Infinity;
3370           for (i3 = m2; i3 <= M2 - m2; i3++) {
3371             bbox1 = distBBox(node, 0, i3, this.toBBox);
3372             bbox2 = distBBox(node, i3, M2, this.toBBox);
3373             overlap = intersectionArea(bbox1, bbox2);
3374             area = bboxArea(bbox1) + bboxArea(bbox2);
3375             if (overlap < minOverlap) {
3376               minOverlap = overlap;
3377               index = i3;
3378               minArea = area < minArea ? area : minArea;
3379             } else if (overlap === minOverlap) {
3380               if (area < minArea) {
3381                 minArea = area;
3382                 index = i3;
3383               }
3384             }
3385           }
3386           return index;
3387         },
3388         // sorts node children by the best axis for split
3389         _chooseSplitAxis: function(node, m2, M2) {
3390           var compareMinX = node.leaf ? this.compareMinX : compareNodeMinX, compareMinY = node.leaf ? this.compareMinY : compareNodeMinY, xMargin = this._allDistMargin(node, m2, M2, compareMinX), yMargin = this._allDistMargin(node, m2, M2, compareMinY);
3391           if (xMargin < yMargin)
3392             node.children.sort(compareMinX);
3393         },
3394         // total margin of all possible split distributions where each node is at least m full
3395         _allDistMargin: function(node, m2, M2, compare2) {
3396           node.children.sort(compare2);
3397           var toBBox = this.toBBox, leftBBox = distBBox(node, 0, m2, toBBox), rightBBox = distBBox(node, M2 - m2, M2, toBBox), margin = bboxMargin(leftBBox) + bboxMargin(rightBBox), i3, child;
3398           for (i3 = m2; i3 < M2 - m2; i3++) {
3399             child = node.children[i3];
3400             extend2(leftBBox, node.leaf ? toBBox(child) : child);
3401             margin += bboxMargin(leftBBox);
3402           }
3403           for (i3 = M2 - m2 - 1; i3 >= m2; i3--) {
3404             child = node.children[i3];
3405             extend2(rightBBox, node.leaf ? toBBox(child) : child);
3406             margin += bboxMargin(rightBBox);
3407           }
3408           return margin;
3409         },
3410         _adjustParentBBoxes: function(bbox2, path, level) {
3411           for (var i3 = level; i3 >= 0; i3--) {
3412             extend2(path[i3], bbox2);
3413           }
3414         },
3415         _condense: function(path) {
3416           for (var i3 = path.length - 1, siblings; i3 >= 0; i3--) {
3417             if (path[i3].children.length === 0) {
3418               if (i3 > 0) {
3419                 siblings = path[i3 - 1].children;
3420                 siblings.splice(siblings.indexOf(path[i3]), 1);
3421               } else
3422                 this.clear();
3423             } else
3424               calcBBox(path[i3], this.toBBox);
3425           }
3426         },
3427         _initFormat: function(format2) {
3428           var compareArr = ["return a", " - b", ";"];
3429           this.compareMinX = new Function("a", "b", compareArr.join(format2[0]));
3430           this.compareMinY = new Function("a", "b", compareArr.join(format2[1]));
3431           this.toBBox = new Function(
3432             "a",
3433             "return {minX: a" + format2[0] + ", minY: a" + format2[1] + ", maxX: a" + format2[2] + ", maxY: a" + format2[3] + "};"
3434           );
3435         }
3436       };
3437       function findItem(item, items, equalsFn) {
3438         if (!equalsFn)
3439           return items.indexOf(item);
3440         for (var i3 = 0; i3 < items.length; i3++) {
3441           if (equalsFn(item, items[i3]))
3442             return i3;
3443         }
3444         return -1;
3445       }
3446       function calcBBox(node, toBBox) {
3447         distBBox(node, 0, node.children.length, toBBox, node);
3448       }
3449       function distBBox(node, k2, p2, toBBox, destNode) {
3450         if (!destNode)
3451           destNode = createNode(null);
3452         destNode.minX = Infinity;
3453         destNode.minY = Infinity;
3454         destNode.maxX = -Infinity;
3455         destNode.maxY = -Infinity;
3456         for (var i3 = k2, child; i3 < p2; i3++) {
3457           child = node.children[i3];
3458           extend2(destNode, node.leaf ? toBBox(child) : child);
3459         }
3460         return destNode;
3461       }
3462       function extend2(a2, b2) {
3463         a2.minX = Math.min(a2.minX, b2.minX);
3464         a2.minY = Math.min(a2.minY, b2.minY);
3465         a2.maxX = Math.max(a2.maxX, b2.maxX);
3466         a2.maxY = Math.max(a2.maxY, b2.maxY);
3467         return a2;
3468       }
3469       function compareNodeMinX(a2, b2) {
3470         return a2.minX - b2.minX;
3471       }
3472       function compareNodeMinY(a2, b2) {
3473         return a2.minY - b2.minY;
3474       }
3475       function bboxArea(a2) {
3476         return (a2.maxX - a2.minX) * (a2.maxY - a2.minY);
3477       }
3478       function bboxMargin(a2) {
3479         return a2.maxX - a2.minX + (a2.maxY - a2.minY);
3480       }
3481       function enlargedArea(a2, b2) {
3482         return (Math.max(b2.maxX, a2.maxX) - Math.min(b2.minX, a2.minX)) * (Math.max(b2.maxY, a2.maxY) - Math.min(b2.minY, a2.minY));
3483       }
3484       function intersectionArea(a2, b2) {
3485         var minX = Math.max(a2.minX, b2.minX), minY = Math.max(a2.minY, b2.minY), maxX = Math.min(a2.maxX, b2.maxX), maxY = Math.min(a2.maxY, b2.maxY);
3486         return Math.max(0, maxX - minX) * Math.max(0, maxY - minY);
3487       }
3488       function contains(a2, b2) {
3489         return a2.minX <= b2.minX && a2.minY <= b2.minY && b2.maxX <= a2.maxX && b2.maxY <= a2.maxY;
3490       }
3491       function intersects(a2, b2) {
3492         return b2.minX <= a2.maxX && b2.minY <= a2.maxY && b2.maxX >= a2.minX && b2.maxY >= a2.minY;
3493       }
3494       function createNode(children2) {
3495         return {
3496           children: children2,
3497           height: 1,
3498           leaf: true,
3499           minX: Infinity,
3500           minY: Infinity,
3501           maxX: -Infinity,
3502           maxY: -Infinity
3503         };
3504       }
3505       function multiSelect(arr, left, right, n3, compare2) {
3506         var stack = [left, right], mid;
3507         while (stack.length) {
3508           right = stack.pop();
3509           left = stack.pop();
3510           if (right - left <= n3)
3511             continue;
3512           mid = left + Math.ceil((right - left) / n3 / 2) * n3;
3513           quickselect2(arr, mid, left, right, compare2);
3514           stack.push(left, mid, mid, right);
3515         }
3516       }
3517     }
3518   });
3519
3520   // node_modules/lineclip/index.js
3521   var require_lineclip = __commonJS({
3522     "node_modules/lineclip/index.js"(exports2, module2) {
3523       "use strict";
3524       module2.exports = lineclip2;
3525       lineclip2.polyline = lineclip2;
3526       lineclip2.polygon = polygonclip2;
3527       function lineclip2(points, bbox2, result) {
3528         var len = points.length, codeA = bitCode2(points[0], bbox2), part = [], i3, a2, b2, codeB, lastCode;
3529         if (!result)
3530           result = [];
3531         for (i3 = 1; i3 < len; i3++) {
3532           a2 = points[i3 - 1];
3533           b2 = points[i3];
3534           codeB = lastCode = bitCode2(b2, bbox2);
3535           while (true) {
3536             if (!(codeA | codeB)) {
3537               part.push(a2);
3538               if (codeB !== lastCode) {
3539                 part.push(b2);
3540                 if (i3 < len - 1) {
3541                   result.push(part);
3542                   part = [];
3543                 }
3544               } else if (i3 === len - 1) {
3545                 part.push(b2);
3546               }
3547               break;
3548             } else if (codeA & codeB) {
3549               break;
3550             } else if (codeA) {
3551               a2 = intersect2(a2, b2, codeA, bbox2);
3552               codeA = bitCode2(a2, bbox2);
3553             } else {
3554               b2 = intersect2(a2, b2, codeB, bbox2);
3555               codeB = bitCode2(b2, bbox2);
3556             }
3557           }
3558           codeA = lastCode;
3559         }
3560         if (part.length)
3561           result.push(part);
3562         return result;
3563       }
3564       function polygonclip2(points, bbox2) {
3565         var result, edge, prev, prevInside, i3, p2, inside;
3566         for (edge = 1; edge <= 8; edge *= 2) {
3567           result = [];
3568           prev = points[points.length - 1];
3569           prevInside = !(bitCode2(prev, bbox2) & edge);
3570           for (i3 = 0; i3 < points.length; i3++) {
3571             p2 = points[i3];
3572             inside = !(bitCode2(p2, bbox2) & edge);
3573             if (inside !== prevInside)
3574               result.push(intersect2(prev, p2, edge, bbox2));
3575             if (inside)
3576               result.push(p2);
3577             prev = p2;
3578             prevInside = inside;
3579           }
3580           points = result;
3581           if (!points.length)
3582             break;
3583         }
3584         return result;
3585       }
3586       function intersect2(a2, b2, edge, bbox2) {
3587         return edge & 8 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[3] - a2[1]) / (b2[1] - a2[1]), bbox2[3]] : (
3588           // top
3589           edge & 4 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[1] - a2[1]) / (b2[1] - a2[1]), bbox2[1]] : (
3590             // bottom
3591             edge & 2 ? [bbox2[2], a2[1] + (b2[1] - a2[1]) * (bbox2[2] - a2[0]) / (b2[0] - a2[0])] : (
3592               // right
3593               edge & 1 ? [bbox2[0], a2[1] + (b2[1] - a2[1]) * (bbox2[0] - a2[0]) / (b2[0] - a2[0])] : (
3594                 // left
3595                 null
3596               )
3597             )
3598           )
3599         );
3600       }
3601       function bitCode2(p2, bbox2) {
3602         var code = 0;
3603         if (p2[0] < bbox2[0])
3604           code |= 1;
3605         else if (p2[0] > bbox2[2])
3606           code |= 2;
3607         if (p2[1] < bbox2[1])
3608           code |= 4;
3609         else if (p2[1] > bbox2[3])
3610           code |= 8;
3611         return code;
3612       }
3613     }
3614   });
3615
3616   // node_modules/which-polygon/index.js
3617   var require_which_polygon = __commonJS({
3618     "node_modules/which-polygon/index.js"(exports2, module2) {
3619       "use strict";
3620       var rbush = require_rbush();
3621       var lineclip2 = require_lineclip();
3622       module2.exports = whichPolygon5;
3623       function whichPolygon5(data) {
3624         var bboxes = [];
3625         for (var i3 = 0; i3 < data.features.length; i3++) {
3626           var feature3 = data.features[i3];
3627           if (!feature3.geometry)
3628             continue;
3629           var coords = feature3.geometry.coordinates;
3630           if (feature3.geometry.type === "Polygon") {
3631             bboxes.push(treeItem(coords, feature3.properties));
3632           } else if (feature3.geometry.type === "MultiPolygon") {
3633             for (var j2 = 0; j2 < coords.length; j2++) {
3634               bboxes.push(treeItem(coords[j2], feature3.properties));
3635             }
3636           }
3637         }
3638         var tree = rbush().load(bboxes);
3639         function query(p2, multi) {
3640           var output = [], result = tree.search({
3641             minX: p2[0],
3642             minY: p2[1],
3643             maxX: p2[0],
3644             maxY: p2[1]
3645           });
3646           for (var i4 = 0; i4 < result.length; i4++) {
3647             if (insidePolygon(result[i4].coords, p2)) {
3648               if (multi)
3649                 output.push(result[i4].props);
3650               else
3651                 return result[i4].props;
3652             }
3653           }
3654           return multi && output.length ? output : null;
3655         }
3656         query.tree = tree;
3657         query.bbox = function queryBBox(bbox2) {
3658           var output = [];
3659           var result = tree.search({
3660             minX: bbox2[0],
3661             minY: bbox2[1],
3662             maxX: bbox2[2],
3663             maxY: bbox2[3]
3664           });
3665           for (var i4 = 0; i4 < result.length; i4++) {
3666             if (polygonIntersectsBBox(result[i4].coords, bbox2)) {
3667               output.push(result[i4].props);
3668             }
3669           }
3670           return output;
3671         };
3672         return query;
3673       }
3674       function polygonIntersectsBBox(polygon2, bbox2) {
3675         var bboxCenter = [
3676           (bbox2[0] + bbox2[2]) / 2,
3677           (bbox2[1] + bbox2[3]) / 2
3678         ];
3679         if (insidePolygon(polygon2, bboxCenter))
3680           return true;
3681         for (var i3 = 0; i3 < polygon2.length; i3++) {
3682           if (lineclip2(polygon2[i3], bbox2).length > 0)
3683             return true;
3684         }
3685         return false;
3686       }
3687       function insidePolygon(rings, p2) {
3688         var inside = false;
3689         for (var i3 = 0, len = rings.length; i3 < len; i3++) {
3690           var ring = rings[i3];
3691           for (var j2 = 0, len2 = ring.length, k2 = len2 - 1; j2 < len2; k2 = j2++) {
3692             if (rayIntersect(p2, ring[j2], ring[k2]))
3693               inside = !inside;
3694           }
3695         }
3696         return inside;
3697       }
3698       function rayIntersect(p2, p1, p22) {
3699         return p1[1] > p2[1] !== p22[1] > p2[1] && p2[0] < (p22[0] - p1[0]) * (p2[1] - p1[1]) / (p22[1] - p1[1]) + p1[0];
3700       }
3701       function treeItem(coords, props) {
3702         var item = {
3703           minX: Infinity,
3704           minY: Infinity,
3705           maxX: -Infinity,
3706           maxY: -Infinity,
3707           coords,
3708           props
3709         };
3710         for (var i3 = 0; i3 < coords[0].length; i3++) {
3711           var p2 = coords[0][i3];
3712           item.minX = Math.min(item.minX, p2[0]);
3713           item.minY = Math.min(item.minY, p2[1]);
3714           item.maxX = Math.max(item.maxX, p2[0]);
3715           item.maxY = Math.max(item.maxY, p2[1]);
3716         }
3717         return item;
3718       }
3719     }
3720   });
3721
3722   // node_modules/wgs84/index.js
3723   var require_wgs84 = __commonJS({
3724     "node_modules/wgs84/index.js"(exports2, module2) {
3725       module2.exports.RADIUS = 6378137;
3726       module2.exports.FLATTENING = 1 / 298.257223563;
3727       module2.exports.POLAR_RADIUS = 63567523142e-4;
3728     }
3729   });
3730
3731   // node_modules/@mapbox/geojson-area/index.js
3732   var require_geojson_area = __commonJS({
3733     "node_modules/@mapbox/geojson-area/index.js"(exports2, module2) {
3734       var wgs84 = require_wgs84();
3735       module2.exports.geometry = geometry;
3736       module2.exports.ring = ringArea;
3737       function geometry(_2) {
3738         var area = 0, i3;
3739         switch (_2.type) {
3740           case "Polygon":
3741             return polygonArea(_2.coordinates);
3742           case "MultiPolygon":
3743             for (i3 = 0; i3 < _2.coordinates.length; i3++) {
3744               area += polygonArea(_2.coordinates[i3]);
3745             }
3746             return area;
3747           case "Point":
3748           case "MultiPoint":
3749           case "LineString":
3750           case "MultiLineString":
3751             return 0;
3752           case "GeometryCollection":
3753             for (i3 = 0; i3 < _2.geometries.length; i3++) {
3754               area += geometry(_2.geometries[i3]);
3755             }
3756             return area;
3757         }
3758       }
3759       function polygonArea(coords) {
3760         var area = 0;
3761         if (coords && coords.length > 0) {
3762           area += Math.abs(ringArea(coords[0]));
3763           for (var i3 = 1; i3 < coords.length; i3++) {
3764             area -= Math.abs(ringArea(coords[i3]));
3765           }
3766         }
3767         return area;
3768       }
3769       function ringArea(coords) {
3770         var p1, p2, p3, lowerIndex, middleIndex, upperIndex, i3, area = 0, coordsLength = coords.length;
3771         if (coordsLength > 2) {
3772           for (i3 = 0; i3 < coordsLength; i3++) {
3773             if (i3 === coordsLength - 2) {
3774               lowerIndex = coordsLength - 2;
3775               middleIndex = coordsLength - 1;
3776               upperIndex = 0;
3777             } else if (i3 === coordsLength - 1) {
3778               lowerIndex = coordsLength - 1;
3779               middleIndex = 0;
3780               upperIndex = 1;
3781             } else {
3782               lowerIndex = i3;
3783               middleIndex = i3 + 1;
3784               upperIndex = i3 + 2;
3785             }
3786             p1 = coords[lowerIndex];
3787             p2 = coords[middleIndex];
3788             p3 = coords[upperIndex];
3789             area += (rad(p3[0]) - rad(p1[0])) * Math.sin(rad(p2[1]));
3790           }
3791           area = area * wgs84.RADIUS * wgs84.RADIUS / 2;
3792         }
3793         return area;
3794       }
3795       function rad(_2) {
3796         return _2 * Math.PI / 180;
3797       }
3798     }
3799   });
3800
3801   // node_modules/circle-to-polygon/input-validation/validateCenter.js
3802   var require_validateCenter = __commonJS({
3803     "node_modules/circle-to-polygon/input-validation/validateCenter.js"(exports2) {
3804       exports2.validateCenter = function validateCenter(center) {
3805         var validCenterLengths = [2, 3];
3806         if (!Array.isArray(center) || !validCenterLengths.includes(center.length)) {
3807           throw new Error("ERROR! Center has to be an array of length two or three");
3808         }
3809         var [lng, lat] = center;
3810         if (typeof lng !== "number" || typeof lat !== "number") {
3811           throw new Error(
3812             "ERROR! Longitude and Latitude has to be numbers but where ".concat(typeof lng, " and ").concat(typeof lat)
3813           );
3814         }
3815         if (lng > 180 || lng < -180) {
3816           throw new Error("ERROR! Longitude has to be between -180 and 180 but was ".concat(lng));
3817         }
3818         if (lat > 90 || lat < -90) {
3819           throw new Error("ERROR! Latitude has to be between -90 and 90 but was ".concat(lat));
3820         }
3821       };
3822     }
3823   });
3824
3825   // node_modules/circle-to-polygon/input-validation/validateRadius.js
3826   var require_validateRadius = __commonJS({
3827     "node_modules/circle-to-polygon/input-validation/validateRadius.js"(exports2) {
3828       exports2.validateRadius = function validateRadius(radius) {
3829         if (typeof radius !== "number") {
3830           throw new Error("ERROR! Radius has to be a positive number but was: ".concat(typeof radius));
3831         }
3832         if (radius <= 0) {
3833           throw new Error("ERROR! Radius has to be a positive number but was: ".concat(radius));
3834         }
3835       };
3836     }
3837   });
3838
3839   // node_modules/circle-to-polygon/input-validation/validateNumberOfEdges.js
3840   var require_validateNumberOfEdges = __commonJS({
3841     "node_modules/circle-to-polygon/input-validation/validateNumberOfEdges.js"(exports2) {
3842       exports2.validateNumberOfEdges = function validateNumberOfEdges(numberOfEdges) {
3843         if (typeof numberOfEdges !== "number") {
3844           const ARGUMENT_TYPE = Array.isArray(numberOfEdges) ? "array" : typeof numberOfEdges;
3845           throw new Error("ERROR! Number of edges has to be a number but was: ".concat(ARGUMENT_TYPE));
3846         }
3847         if (numberOfEdges < 3) {
3848           throw new Error("ERROR! Number of edges has to be at least 3 but was: ".concat(numberOfEdges));
3849         }
3850       };
3851     }
3852   });
3853
3854   // node_modules/circle-to-polygon/input-validation/validateEarthRadius.js
3855   var require_validateEarthRadius = __commonJS({
3856     "node_modules/circle-to-polygon/input-validation/validateEarthRadius.js"(exports2) {
3857       exports2.validateEarthRadius = function validateEarthRadius(earthRadius2) {
3858         if (typeof earthRadius2 !== "number") {
3859           const ARGUMENT_TYPE = Array.isArray(earthRadius2) ? "array" : typeof earthRadius2;
3860           throw new Error("ERROR! Earth radius has to be a number but was: ".concat(ARGUMENT_TYPE));
3861         }
3862         if (earthRadius2 <= 0) {
3863           throw new Error("ERROR! Earth radius has to be a positive number but was: ".concat(earthRadius2));
3864         }
3865       };
3866     }
3867   });
3868
3869   // node_modules/circle-to-polygon/input-validation/validateBearing.js
3870   var require_validateBearing = __commonJS({
3871     "node_modules/circle-to-polygon/input-validation/validateBearing.js"(exports2) {
3872       exports2.validateBearing = function validateBearing(bearing) {
3873         if (typeof bearing !== "number") {
3874           const ARGUMENT_TYPE = Array.isArray(bearing) ? "array" : typeof bearing;
3875           throw new Error("ERROR! Bearing has to be a number but was: ".concat(ARGUMENT_TYPE));
3876         }
3877       };
3878     }
3879   });
3880
3881   // node_modules/circle-to-polygon/input-validation/index.js
3882   var require_input_validation = __commonJS({
3883     "node_modules/circle-to-polygon/input-validation/index.js"(exports2) {
3884       var validateCenter = require_validateCenter().validateCenter;
3885       var validateRadius = require_validateRadius().validateRadius;
3886       var validateNumberOfEdges = require_validateNumberOfEdges().validateNumberOfEdges;
3887       var validateEarthRadius = require_validateEarthRadius().validateEarthRadius;
3888       var validateBearing = require_validateBearing().validateBearing;
3889       function validateInput({ center, radius, numberOfEdges, earthRadius: earthRadius2, bearing }) {
3890         validateCenter(center);
3891         validateRadius(radius);
3892         validateNumberOfEdges(numberOfEdges);
3893         validateEarthRadius(earthRadius2);
3894         validateBearing(bearing);
3895       }
3896       exports2.validateCenter = validateCenter;
3897       exports2.validateRadius = validateRadius;
3898       exports2.validateNumberOfEdges = validateNumberOfEdges;
3899       exports2.validateEarthRadius = validateEarthRadius;
3900       exports2.validateBearing = validateBearing;
3901       exports2.validateInput = validateInput;
3902     }
3903   });
3904
3905   // node_modules/circle-to-polygon/index.js
3906   var require_circle_to_polygon = __commonJS({
3907     "node_modules/circle-to-polygon/index.js"(exports2, module2) {
3908       "use strict";
3909       var { validateInput } = require_input_validation();
3910       var defaultEarthRadius = 6378137;
3911       function toRadians(angleInDegrees) {
3912         return angleInDegrees * Math.PI / 180;
3913       }
3914       function toDegrees(angleInRadians) {
3915         return angleInRadians * 180 / Math.PI;
3916       }
3917       function offset(c1, distance, earthRadius2, bearing) {
3918         var lat1 = toRadians(c1[1]);
3919         var lon1 = toRadians(c1[0]);
3920         var dByR = distance / earthRadius2;
3921         var lat = Math.asin(
3922           Math.sin(lat1) * Math.cos(dByR) + Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing)
3923         );
3924         var lon = lon1 + Math.atan2(
3925           Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),
3926           Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat)
3927         );
3928         return [toDegrees(lon), toDegrees(lat)];
3929       }
3930       module2.exports = function circleToPolygon2(center, radius, options2) {
3931         var n3 = getNumberOfEdges(options2);
3932         var earthRadius2 = getEarthRadius(options2);
3933         var bearing = getBearing(options2);
3934         var direction = getDirection(options2);
3935         validateInput({ center, radius, numberOfEdges: n3, earthRadius: earthRadius2, bearing });
3936         var start2 = toRadians(bearing);
3937         var coordinates = [];
3938         for (var i3 = 0; i3 < n3; ++i3) {
3939           coordinates.push(
3940             offset(
3941               center,
3942               radius,
3943               earthRadius2,
3944               start2 + direction * 2 * Math.PI * -i3 / n3
3945             )
3946           );
3947         }
3948         coordinates.push(coordinates[0]);
3949         return {
3950           type: "Polygon",
3951           coordinates: [coordinates]
3952         };
3953       };
3954       function getNumberOfEdges(options2) {
3955         if (isUndefinedOrNull(options2)) {
3956           return 32;
3957         } else if (isObjectNotArray(options2)) {
3958           var numberOfEdges = options2.numberOfEdges;
3959           return numberOfEdges === void 0 ? 32 : numberOfEdges;
3960         }
3961         return options2;
3962       }
3963       function getEarthRadius(options2) {
3964         if (isUndefinedOrNull(options2)) {
3965           return defaultEarthRadius;
3966         } else if (isObjectNotArray(options2)) {
3967           var earthRadius2 = options2.earthRadius;
3968           return earthRadius2 === void 0 ? defaultEarthRadius : earthRadius2;
3969         }
3970         return defaultEarthRadius;
3971       }
3972       function getDirection(options2) {
3973         if (isObjectNotArray(options2) && options2.rightHandRule) {
3974           return -1;
3975         }
3976         return 1;
3977       }
3978       function getBearing(options2) {
3979         if (isUndefinedOrNull(options2)) {
3980           return 0;
3981         } else if (isObjectNotArray(options2)) {
3982           var bearing = options2.bearing;
3983           return bearing === void 0 ? 0 : bearing;
3984         }
3985         return 0;
3986       }
3987       function isObjectNotArray(argument) {
3988         return argument !== null && typeof argument === "object" && !Array.isArray(argument);
3989       }
3990       function isUndefinedOrNull(argument) {
3991         return argument === null || argument === void 0;
3992       }
3993     }
3994   });
3995
3996   // node_modules/geojson-precision/index.js
3997   var require_geojson_precision = __commonJS({
3998     "node_modules/geojson-precision/index.js"(exports2, module2) {
3999       (function() {
4000         function parse(t2, coordinatePrecision, extrasPrecision) {
4001           function point2(p2) {
4002             return p2.map(function(e3, index) {
4003               if (index < 2) {
4004                 return 1 * e3.toFixed(coordinatePrecision);
4005               } else {
4006                 return 1 * e3.toFixed(extrasPrecision);
4007               }
4008             });
4009           }
4010           function multi(l2) {
4011             return l2.map(point2);
4012           }
4013           function poly(p2) {
4014             return p2.map(multi);
4015           }
4016           function multiPoly(m2) {
4017             return m2.map(poly);
4018           }
4019           function geometry(obj) {
4020             if (!obj) {
4021               return {};
4022             }
4023             switch (obj.type) {
4024               case "Point":
4025                 obj.coordinates = point2(obj.coordinates);
4026                 return obj;
4027               case "LineString":
4028               case "MultiPoint":
4029                 obj.coordinates = multi(obj.coordinates);
4030                 return obj;
4031               case "Polygon":
4032               case "MultiLineString":
4033                 obj.coordinates = poly(obj.coordinates);
4034                 return obj;
4035               case "MultiPolygon":
4036                 obj.coordinates = multiPoly(obj.coordinates);
4037                 return obj;
4038               case "GeometryCollection":
4039                 obj.geometries = obj.geometries.map(geometry);
4040                 return obj;
4041               default:
4042                 return {};
4043             }
4044           }
4045           function feature3(obj) {
4046             obj.geometry = geometry(obj.geometry);
4047             return obj;
4048           }
4049           function featureCollection(f2) {
4050             f2.features = f2.features.map(feature3);
4051             return f2;
4052           }
4053           function geometryCollection(g3) {
4054             g3.geometries = g3.geometries.map(geometry);
4055             return g3;
4056           }
4057           if (!t2) {
4058             return t2;
4059           }
4060           switch (t2.type) {
4061             case "Feature":
4062               return feature3(t2);
4063             case "GeometryCollection":
4064               return geometryCollection(t2);
4065             case "FeatureCollection":
4066               return featureCollection(t2);
4067             case "Point":
4068             case "LineString":
4069             case "Polygon":
4070             case "MultiPoint":
4071             case "MultiPolygon":
4072             case "MultiLineString":
4073               return geometry(t2);
4074             default:
4075               return t2;
4076           }
4077         }
4078         module2.exports = parse;
4079         module2.exports.parse = parse;
4080       })();
4081     }
4082   });
4083
4084   // node_modules/@aitodotai/json-stringify-pretty-compact/index.js
4085   var require_json_stringify_pretty_compact = __commonJS({
4086     "node_modules/@aitodotai/json-stringify-pretty-compact/index.js"(exports2, module2) {
4087       function isObject3(obj) {
4088         return typeof obj === "object" && obj !== null;
4089       }
4090       function forEach(obj, cb) {
4091         if (Array.isArray(obj)) {
4092           obj.forEach(cb);
4093         } else if (isObject3(obj)) {
4094           Object.keys(obj).forEach(function(key) {
4095             var val = obj[key];
4096             cb(val, key);
4097           });
4098         }
4099       }
4100       function getTreeDepth(obj) {
4101         var depth = 0;
4102         if (Array.isArray(obj) || isObject3(obj)) {
4103           forEach(obj, function(val) {
4104             if (Array.isArray(val) || isObject3(val)) {
4105               var tmpDepth = getTreeDepth(val);
4106               if (tmpDepth > depth) {
4107                 depth = tmpDepth;
4108               }
4109             }
4110           });
4111           return depth + 1;
4112         }
4113         return depth;
4114       }
4115       function stringify3(obj, options2) {
4116         options2 = options2 || {};
4117         var indent = JSON.stringify([1], null, get4(options2, "indent", 2)).slice(2, -3);
4118         var addMargin = get4(options2, "margins", false);
4119         var addArrayMargin = get4(options2, "arrayMargins", false);
4120         var addObjectMargin = get4(options2, "objectMargins", false);
4121         var maxLength = indent === "" ? Infinity : get4(options2, "maxLength", 80);
4122         var maxNesting = get4(options2, "maxNesting", Infinity);
4123         return function _stringify(obj2, currentIndent, reserved) {
4124           if (obj2 && typeof obj2.toJSON === "function") {
4125             obj2 = obj2.toJSON();
4126           }
4127           var string = JSON.stringify(obj2);
4128           if (string === void 0) {
4129             return string;
4130           }
4131           var length2 = maxLength - currentIndent.length - reserved;
4132           var treeDepth = getTreeDepth(obj2);
4133           if (treeDepth <= maxNesting && string.length <= length2) {
4134             var prettified = prettify(string, {
4135               addMargin,
4136               addArrayMargin,
4137               addObjectMargin
4138             });
4139             if (prettified.length <= length2) {
4140               return prettified;
4141             }
4142           }
4143           if (isObject3(obj2)) {
4144             var nextIndent = currentIndent + indent;
4145             var items = [];
4146             var delimiters;
4147             var comma = function(array2, index2) {
4148               return index2 === array2.length - 1 ? 0 : 1;
4149             };
4150             if (Array.isArray(obj2)) {
4151               for (var index = 0; index < obj2.length; index++) {
4152                 items.push(
4153                   _stringify(obj2[index], nextIndent, comma(obj2, index)) || "null"
4154                 );
4155               }
4156               delimiters = "[]";
4157             } else {
4158               Object.keys(obj2).forEach(function(key, index2, array2) {
4159                 var keyPart = JSON.stringify(key) + ": ";
4160                 var value = _stringify(
4161                   obj2[key],
4162                   nextIndent,
4163                   keyPart.length + comma(array2, index2)
4164                 );
4165                 if (value !== void 0) {
4166                   items.push(keyPart + value);
4167                 }
4168               });
4169               delimiters = "{}";
4170             }
4171             if (items.length > 0) {
4172               return [
4173                 delimiters[0],
4174                 indent + items.join(",\n" + nextIndent),
4175                 delimiters[1]
4176               ].join("\n" + currentIndent);
4177             }
4178           }
4179           return string;
4180         }(obj, "", 0);
4181       }
4182       var stringOrChar = /("(?:[^\\"]|\\.)*")|[:,\][}{]/g;
4183       function prettify(string, options2) {
4184         options2 = options2 || {};
4185         var tokens = {
4186           "{": "{",
4187           "}": "}",
4188           "[": "[",
4189           "]": "]",
4190           ",": ", ",
4191           ":": ": "
4192         };
4193         if (options2.addMargin || options2.addObjectMargin) {
4194           tokens["{"] = "{ ";
4195           tokens["}"] = " }";
4196         }
4197         if (options2.addMargin || options2.addArrayMargin) {
4198           tokens["["] = "[ ";
4199           tokens["]"] = " ]";
4200         }
4201         return string.replace(stringOrChar, function(match, string2) {
4202           return string2 ? match : tokens[match];
4203         });
4204       }
4205       function get4(options2, name, defaultValue) {
4206         return name in options2 ? options2[name] : defaultValue;
4207       }
4208       module2.exports = stringify3;
4209     }
4210   });
4211
4212   // node_modules/aes-js/index.js
4213   var require_aes_js = __commonJS({
4214     "node_modules/aes-js/index.js"(exports2, module2) {
4215       (function(root3) {
4216         "use strict";
4217         function checkInt(value) {
4218           return parseInt(value) === value;
4219         }
4220         function checkInts(arrayish) {
4221           if (!checkInt(arrayish.length)) {
4222             return false;
4223           }
4224           for (var i3 = 0; i3 < arrayish.length; i3++) {
4225             if (!checkInt(arrayish[i3]) || arrayish[i3] < 0 || arrayish[i3] > 255) {
4226               return false;
4227             }
4228           }
4229           return true;
4230         }
4231         function coerceArray(arg, copy2) {
4232           if (arg.buffer && arg.name === "Uint8Array") {
4233             if (copy2) {
4234               if (arg.slice) {
4235                 arg = arg.slice();
4236               } else {
4237                 arg = Array.prototype.slice.call(arg);
4238               }
4239             }
4240             return arg;
4241           }
4242           if (Array.isArray(arg)) {
4243             if (!checkInts(arg)) {
4244               throw new Error("Array contains invalid value: " + arg);
4245             }
4246             return new Uint8Array(arg);
4247           }
4248           if (checkInt(arg.length) && checkInts(arg)) {
4249             return new Uint8Array(arg);
4250           }
4251           throw new Error("unsupported array-like object");
4252         }
4253         function createArray(length2) {
4254           return new Uint8Array(length2);
4255         }
4256         function copyArray(sourceArray, targetArray, targetStart, sourceStart, sourceEnd) {
4257           if (sourceStart != null || sourceEnd != null) {
4258             if (sourceArray.slice) {
4259               sourceArray = sourceArray.slice(sourceStart, sourceEnd);
4260             } else {
4261               sourceArray = Array.prototype.slice.call(sourceArray, sourceStart, sourceEnd);
4262             }
4263           }
4264           targetArray.set(sourceArray, targetStart);
4265         }
4266         var convertUtf8 = /* @__PURE__ */ function() {
4267           function toBytes(text) {
4268             var result = [], i3 = 0;
4269             text = encodeURI(text);
4270             while (i3 < text.length) {
4271               var c2 = text.charCodeAt(i3++);
4272               if (c2 === 37) {
4273                 result.push(parseInt(text.substr(i3, 2), 16));
4274                 i3 += 2;
4275               } else {
4276                 result.push(c2);
4277               }
4278             }
4279             return coerceArray(result);
4280           }
4281           function fromBytes(bytes) {
4282             var result = [], i3 = 0;
4283             while (i3 < bytes.length) {
4284               var c2 = bytes[i3];
4285               if (c2 < 128) {
4286                 result.push(String.fromCharCode(c2));
4287                 i3++;
4288               } else if (c2 > 191 && c2 < 224) {
4289                 result.push(String.fromCharCode((c2 & 31) << 6 | bytes[i3 + 1] & 63));
4290                 i3 += 2;
4291               } else {
4292                 result.push(String.fromCharCode((c2 & 15) << 12 | (bytes[i3 + 1] & 63) << 6 | bytes[i3 + 2] & 63));
4293                 i3 += 3;
4294               }
4295             }
4296             return result.join("");
4297           }
4298           return {
4299             toBytes,
4300             fromBytes
4301           };
4302         }();
4303         var convertHex = /* @__PURE__ */ function() {
4304           function toBytes(text) {
4305             var result = [];
4306             for (var i3 = 0; i3 < text.length; i3 += 2) {
4307               result.push(parseInt(text.substr(i3, 2), 16));
4308             }
4309             return result;
4310           }
4311           var Hex = "0123456789abcdef";
4312           function fromBytes(bytes) {
4313             var result = [];
4314             for (var i3 = 0; i3 < bytes.length; i3++) {
4315               var v2 = bytes[i3];
4316               result.push(Hex[(v2 & 240) >> 4] + Hex[v2 & 15]);
4317             }
4318             return result.join("");
4319           }
4320           return {
4321             toBytes,
4322             fromBytes
4323           };
4324         }();
4325         var numberOfRounds = { 16: 10, 24: 12, 32: 14 };
4326         var rcon = [1, 2, 4, 8, 16, 32, 64, 128, 27, 54, 108, 216, 171, 77, 154, 47, 94, 188, 99, 198, 151, 53, 106, 212, 179, 125, 250, 239, 197, 145];
4327         var S2 = [99, 124, 119, 123, 242, 107, 111, 197, 48, 1, 103, 43, 254, 215, 171, 118, 202, 130, 201, 125, 250, 89, 71, 240, 173, 212, 162, 175, 156, 164, 114, 192, 183, 253, 147, 38, 54, 63, 247, 204, 52, 165, 229, 241, 113, 216, 49, 21, 4, 199, 35, 195, 24, 150, 5, 154, 7, 18, 128, 226, 235, 39, 178, 117, 9, 131, 44, 26, 27, 110, 90, 160, 82, 59, 214, 179, 41, 227, 47, 132, 83, 209, 0, 237, 32, 252, 177, 91, 106, 203, 190, 57, 74, 76, 88, 207, 208, 239, 170, 251, 67, 77, 51, 133, 69, 249, 2, 127, 80, 60, 159, 168, 81, 163, 64, 143, 146, 157, 56, 245, 188, 182, 218, 33, 16, 255, 243, 210, 205, 12, 19, 236, 95, 151, 68, 23, 196, 167, 126, 61, 100, 93, 25, 115, 96, 129, 79, 220, 34, 42, 144, 136, 70, 238, 184, 20, 222, 94, 11, 219, 224, 50, 58, 10, 73, 6, 36, 92, 194, 211, 172, 98, 145, 149, 228, 121, 231, 200, 55, 109, 141, 213, 78, 169, 108, 86, 244, 234, 101, 122, 174, 8, 186, 120, 37, 46, 28, 166, 180, 198, 232, 221, 116, 31, 75, 189, 139, 138, 112, 62, 181, 102, 72, 3, 246, 14, 97, 53, 87, 185, 134, 193, 29, 158, 225, 248, 152, 17, 105, 217, 142, 148, 155, 30, 135, 233, 206, 85, 40, 223, 140, 161, 137, 13, 191, 230, 66, 104, 65, 153, 45, 15, 176, 84, 187, 22];
4328         var Si = [82, 9, 106, 213, 48, 54, 165, 56, 191, 64, 163, 158, 129, 243, 215, 251, 124, 227, 57, 130, 155, 47, 255, 135, 52, 142, 67, 68, 196, 222, 233, 203, 84, 123, 148, 50, 166, 194, 35, 61, 238, 76, 149, 11, 66, 250, 195, 78, 8, 46, 161, 102, 40, 217, 36, 178, 118, 91, 162, 73, 109, 139, 209, 37, 114, 248, 246, 100, 134, 104, 152, 22, 212, 164, 92, 204, 93, 101, 182, 146, 108, 112, 72, 80, 253, 237, 185, 218, 94, 21, 70, 87, 167, 141, 157, 132, 144, 216, 171, 0, 140, 188, 211, 10, 247, 228, 88, 5, 184, 179, 69, 6, 208, 44, 30, 143, 202, 63, 15, 2, 193, 175, 189, 3, 1, 19, 138, 107, 58, 145, 17, 65, 79, 103, 220, 234, 151, 242, 207, 206, 240, 180, 230, 115, 150, 172, 116, 34, 231, 173, 53, 133, 226, 249, 55, 232, 28, 117, 223, 110, 71, 241, 26, 113, 29, 41, 197, 137, 111, 183, 98, 14, 170, 24, 190, 27, 252, 86, 62, 75, 198, 210, 121, 32, 154, 219, 192, 254, 120, 205, 90, 244, 31, 221, 168, 51, 136, 7, 199, 49, 177, 18, 16, 89, 39, 128, 236, 95, 96, 81, 127, 169, 25, 181, 74, 13, 45, 229, 122, 159, 147, 201, 156, 239, 160, 224, 59, 77, 174, 42, 245, 176, 200, 235, 187, 60, 131, 83, 153, 97, 23, 43, 4, 126, 186, 119, 214, 38, 225, 105, 20, 99, 85, 33, 12, 125];
4329         var T1 = [3328402341, 4168907908, 4000806809, 4135287693, 4294111757, 3597364157, 3731845041, 2445657428, 1613770832, 33620227, 3462883241, 1445669757, 3892248089, 3050821474, 1303096294, 3967186586, 2412431941, 528646813, 2311702848, 4202528135, 4026202645, 2992200171, 2387036105, 4226871307, 1101901292, 3017069671, 1604494077, 1169141738, 597466303, 1403299063, 3832705686, 2613100635, 1974974402, 3791519004, 1033081774, 1277568618, 1815492186, 2118074177, 4126668546, 2211236943, 1748251740, 1369810420, 3521504564, 4193382664, 3799085459, 2883115123, 1647391059, 706024767, 134480908, 2512897874, 1176707941, 2646852446, 806885416, 932615841, 168101135, 798661301, 235341577, 605164086, 461406363, 3756188221, 3454790438, 1311188841, 2142417613, 3933566367, 302582043, 495158174, 1479289972, 874125870, 907746093, 3698224818, 3025820398, 1537253627, 2756858614, 1983593293, 3084310113, 2108928974, 1378429307, 3722699582, 1580150641, 327451799, 2790478837, 3117535592, 0, 3253595436, 1075847264, 3825007647, 2041688520, 3059440621, 3563743934, 2378943302, 1740553945, 1916352843, 2487896798, 2555137236, 2958579944, 2244988746, 3151024235, 3320835882, 1336584933, 3992714006, 2252555205, 2588757463, 1714631509, 293963156, 2319795663, 3925473552, 67240454, 4269768577, 2689618160, 2017213508, 631218106, 1269344483, 2723238387, 1571005438, 2151694528, 93294474, 1066570413, 563977660, 1882732616, 4059428100, 1673313503, 2008463041, 2950355573, 1109467491, 537923632, 3858759450, 4260623118, 3218264685, 2177748300, 403442708, 638784309, 3287084079, 3193921505, 899127202, 2286175436, 773265209, 2479146071, 1437050866, 4236148354, 2050833735, 3362022572, 3126681063, 840505643, 3866325909, 3227541664, 427917720, 2655997905, 2749160575, 1143087718, 1412049534, 999329963, 193497219, 2353415882, 3354324521, 1807268051, 672404540, 2816401017, 3160301282, 369822493, 2916866934, 3688947771, 1681011286, 1949973070, 336202270, 2454276571, 201721354, 1210328172, 3093060836, 2680341085, 3184776046, 1135389935, 3294782118, 965841320, 831886756, 3554993207, 4068047243, 3588745010, 2345191491, 1849112409, 3664604599, 26054028, 2983581028, 2622377682, 1235855840, 3630984372, 2891339514, 4092916743, 3488279077, 3395642799, 4101667470, 1202630377, 268961816, 1874508501, 4034427016, 1243948399, 1546530418, 941366308, 1470539505, 1941222599, 2546386513, 3421038627, 2715671932, 3899946140, 1042226977, 2521517021, 1639824860, 227249030, 260737669, 3765465232, 2084453954, 1907733956, 3429263018, 2420656344, 100860677, 4160157185, 470683154, 3261161891, 1781871967, 2924959737, 1773779408, 394692241, 2579611992, 974986535, 664706745, 3655459128, 3958962195, 731420851, 571543859, 3530123707, 2849626480, 126783113, 865375399, 765172662, 1008606754, 361203602, 3387549984, 2278477385, 2857719295, 1344809080, 2782912378, 59542671, 1503764984, 160008576, 437062935, 1707065306, 3622233649, 2218934982, 3496503480, 2185314755, 697932208, 1512910199, 504303377, 2075177163, 2824099068, 1841019862, 739644986];
4330         var T2 = [2781242211, 2230877308, 2582542199, 2381740923, 234877682, 3184946027, 2984144751, 1418839493, 1348481072, 50462977, 2848876391, 2102799147, 434634494, 1656084439, 3863849899, 2599188086, 1167051466, 2636087938, 1082771913, 2281340285, 368048890, 3954334041, 3381544775, 201060592, 3963727277, 1739838676, 4250903202, 3930435503, 3206782108, 4149453988, 2531553906, 1536934080, 3262494647, 484572669, 2923271059, 1783375398, 1517041206, 1098792767, 49674231, 1334037708, 1550332980, 4098991525, 886171109, 150598129, 2481090929, 1940642008, 1398944049, 1059722517, 201851908, 1385547719, 1699095331, 1587397571, 674240536, 2704774806, 252314885, 3039795866, 151914247, 908333586, 2602270848, 1038082786, 651029483, 1766729511, 3447698098, 2682942837, 454166793, 2652734339, 1951935532, 775166490, 758520603, 3000790638, 4004797018, 4217086112, 4137964114, 1299594043, 1639438038, 3464344499, 2068982057, 1054729187, 1901997871, 2534638724, 4121318227, 1757008337, 0, 750906861, 1614815264, 535035132, 3363418545, 3988151131, 3201591914, 1183697867, 3647454910, 1265776953, 3734260298, 3566750796, 3903871064, 1250283471, 1807470800, 717615087, 3847203498, 384695291, 3313910595, 3617213773, 1432761139, 2484176261, 3481945413, 283769337, 100925954, 2180939647, 4037038160, 1148730428, 3123027871, 3813386408, 4087501137, 4267549603, 3229630528, 2315620239, 2906624658, 3156319645, 1215313976, 82966005, 3747855548, 3245848246, 1974459098, 1665278241, 807407632, 451280895, 251524083, 1841287890, 1283575245, 337120268, 891687699, 801369324, 3787349855, 2721421207, 3431482436, 959321879, 1469301956, 4065699751, 2197585534, 1199193405, 2898814052, 3887750493, 724703513, 2514908019, 2696962144, 2551808385, 3516813135, 2141445340, 1715741218, 2119445034, 2872807568, 2198571144, 3398190662, 700968686, 3547052216, 1009259540, 2041044702, 3803995742, 487983883, 1991105499, 1004265696, 1449407026, 1316239930, 504629770, 3683797321, 168560134, 1816667172, 3837287516, 1570751170, 1857934291, 4014189740, 2797888098, 2822345105, 2754712981, 936633572, 2347923833, 852879335, 1133234376, 1500395319, 3084545389, 2348912013, 1689376213, 3533459022, 3762923945, 3034082412, 4205598294, 133428468, 634383082, 2949277029, 2398386810, 3913789102, 403703816, 3580869306, 2297460856, 1867130149, 1918643758, 607656988, 4049053350, 3346248884, 1368901318, 600565992, 2090982877, 2632479860, 557719327, 3717614411, 3697393085, 2249034635, 2232388234, 2430627952, 1115438654, 3295786421, 2865522278, 3633334344, 84280067, 33027830, 303828494, 2747425121, 1600795957, 4188952407, 3496589753, 2434238086, 1486471617, 658119965, 3106381470, 953803233, 334231800, 3005978776, 857870609, 3151128937, 1890179545, 2298973838, 2805175444, 3056442267, 574365214, 2450884487, 550103529, 1233637070, 4289353045, 2018519080, 2057691103, 2399374476, 4166623649, 2148108681, 387583245, 3664101311, 836232934, 3330556482, 3100665960, 3280093505, 2955516313, 2002398509, 287182607, 3413881008, 4238890068, 3597515707, 975967766];
4331         var T3 = [1671808611, 2089089148, 2006576759, 2072901243, 4061003762, 1807603307, 1873927791, 3310653893, 810573872, 16974337, 1739181671, 729634347, 4263110654, 3613570519, 2883997099, 1989864566, 3393556426, 2191335298, 3376449993, 2106063485, 4195741690, 1508618841, 1204391495, 4027317232, 2917941677, 3563566036, 2734514082, 2951366063, 2629772188, 2767672228, 1922491506, 3227229120, 3082974647, 4246528509, 2477669779, 644500518, 911895606, 1061256767, 4144166391, 3427763148, 878471220, 2784252325, 3845444069, 4043897329, 1905517169, 3631459288, 827548209, 356461077, 67897348, 3344078279, 593839651, 3277757891, 405286936, 2527147926, 84871685, 2595565466, 118033927, 305538066, 2157648768, 3795705826, 3945188843, 661212711, 2999812018, 1973414517, 152769033, 2208177539, 745822252, 439235610, 455947803, 1857215598, 1525593178, 2700827552, 1391895634, 994932283, 3596728278, 3016654259, 695947817, 3812548067, 795958831, 2224493444, 1408607827, 3513301457, 0, 3979133421, 543178784, 4229948412, 2982705585, 1542305371, 1790891114, 3410398667, 3201918910, 961245753, 1256100938, 1289001036, 1491644504, 3477767631, 3496721360, 4012557807, 2867154858, 4212583931, 1137018435, 1305975373, 861234739, 2241073541, 1171229253, 4178635257, 33948674, 2139225727, 1357946960, 1011120188, 2679776671, 2833468328, 1374921297, 2751356323, 1086357568, 2408187279, 2460827538, 2646352285, 944271416, 4110742005, 3168756668, 3066132406, 3665145818, 560153121, 271589392, 4279952895, 4077846003, 3530407890, 3444343245, 202643468, 322250259, 3962553324, 1608629855, 2543990167, 1154254916, 389623319, 3294073796, 2817676711, 2122513534, 1028094525, 1689045092, 1575467613, 422261273, 1939203699, 1621147744, 2174228865, 1339137615, 3699352540, 577127458, 712922154, 2427141008, 2290289544, 1187679302, 3995715566, 3100863416, 339486740, 3732514782, 1591917662, 186455563, 3681988059, 3762019296, 844522546, 978220090, 169743370, 1239126601, 101321734, 611076132, 1558493276, 3260915650, 3547250131, 2901361580, 1655096418, 2443721105, 2510565781, 3828863972, 2039214713, 3878868455, 3359869896, 928607799, 1840765549, 2374762893, 3580146133, 1322425422, 2850048425, 1823791212, 1459268694, 4094161908, 3928346602, 1706019429, 2056189050, 2934523822, 135794696, 3134549946, 2022240376, 628050469, 779246638, 472135708, 2800834470, 3032970164, 3327236038, 3894660072, 3715932637, 1956440180, 522272287, 1272813131, 3185336765, 2340818315, 2323976074, 1888542832, 1044544574, 3049550261, 1722469478, 1222152264, 50660867, 4127324150, 236067854, 1638122081, 895445557, 1475980887, 3117443513, 2257655686, 3243809217, 489110045, 2662934430, 3778599393, 4162055160, 2561878936, 288563729, 1773916777, 3648039385, 2391345038, 2493985684, 2612407707, 505560094, 2274497927, 3911240169, 3460925390, 1442818645, 678973480, 3749357023, 2358182796, 2717407649, 2306869641, 219617805, 3218761151, 3862026214, 1120306242, 1756942440, 1103331905, 2578459033, 762796589, 252780047, 2966125488, 1425844308, 3151392187, 372911126];
4332         var T4 = [1667474886, 2088535288, 2004326894, 2071694838, 4075949567, 1802223062, 1869591006, 3318043793, 808472672, 16843522, 1734846926, 724270422, 4278065639, 3621216949, 2880169549, 1987484396, 3402253711, 2189597983, 3385409673, 2105378810, 4210693615, 1499065266, 1195886990, 4042263547, 2913856577, 3570689971, 2728590687, 2947541573, 2627518243, 2762274643, 1920112356, 3233831835, 3082273397, 4261223649, 2475929149, 640051788, 909531756, 1061110142, 4160160501, 3435941763, 875846760, 2779116625, 3857003729, 4059105529, 1903268834, 3638064043, 825316194, 353713962, 67374088, 3351728789, 589522246, 3284360861, 404236336, 2526454071, 84217610, 2593830191, 117901582, 303183396, 2155911963, 3806477791, 3958056653, 656894286, 2998062463, 1970642922, 151591698, 2206440989, 741110872, 437923380, 454765878, 1852748508, 1515908788, 2694904667, 1381168804, 993742198, 3604373943, 3014905469, 690584402, 3823320797, 791638366, 2223281939, 1398011302, 3520161977, 0, 3991743681, 538992704, 4244381667, 2981218425, 1532751286, 1785380564, 3419096717, 3200178535, 960056178, 1246420628, 1280103576, 1482221744, 3486468741, 3503319995, 4025428677, 2863326543, 4227536621, 1128514950, 1296947098, 859002214, 2240123921, 1162203018, 4193849577, 33687044, 2139062782, 1347481760, 1010582648, 2678045221, 2829640523, 1364325282, 2745433693, 1077985408, 2408548869, 2459086143, 2644360225, 943212656, 4126475505, 3166494563, 3065430391, 3671750063, 555836226, 269496352, 4294908645, 4092792573, 3537006015, 3452783745, 202118168, 320025894, 3974901699, 1600119230, 2543297077, 1145359496, 387397934, 3301201811, 2812801621, 2122220284, 1027426170, 1684319432, 1566435258, 421079858, 1936954854, 1616945344, 2172753945, 1330631070, 3705438115, 572679748, 707427924, 2425400123, 2290647819, 1179044492, 4008585671, 3099120491, 336870440, 3739122087, 1583276732, 185277718, 3688593069, 3772791771, 842159716, 976899700, 168435220, 1229577106, 101059084, 606366792, 1549591736, 3267517855, 3553849021, 2897014595, 1650632388, 2442242105, 2509612081, 3840161747, 2038008818, 3890688725, 3368567691, 926374254, 1835907034, 2374863873, 3587531953, 1313788572, 2846482505, 1819063512, 1448540844, 4109633523, 3941213647, 1701162954, 2054852340, 2930698567, 134748176, 3132806511, 2021165296, 623210314, 774795868, 471606328, 2795958615, 3031746419, 3334885783, 3907527627, 3722280097, 1953799400, 522133822, 1263263126, 3183336545, 2341176845, 2324333839, 1886425312, 1044267644, 3048588401, 1718004428, 1212733584, 50529542, 4143317495, 235803164, 1633788866, 892690282, 1465383342, 3115962473, 2256965911, 3250673817, 488449850, 2661202215, 3789633753, 4177007595, 2560144171, 286339874, 1768537042, 3654906025, 2391705863, 2492770099, 2610673197, 505291324, 2273808917, 3924369609, 3469625735, 1431699370, 673740880, 3755965093, 2358021891, 2711746649, 2307489801, 218961690, 3217021541, 3873845719, 1111672452, 1751693520, 1094828930, 2576986153, 757954394, 252645662, 2964376443, 1414855848, 3149649517, 370555436];
4333         var T5 = [1374988112, 2118214995, 437757123, 975658646, 1001089995, 530400753, 2902087851, 1273168787, 540080725, 2910219766, 2295101073, 4110568485, 1340463100, 3307916247, 641025152, 3043140495, 3736164937, 632953703, 1172967064, 1576976609, 3274667266, 2169303058, 2370213795, 1809054150, 59727847, 361929877, 3211623147, 2505202138, 3569255213, 1484005843, 1239443753, 2395588676, 1975683434, 4102977912, 2572697195, 666464733, 3202437046, 4035489047, 3374361702, 2110667444, 1675577880, 3843699074, 2538681184, 1649639237, 2976151520, 3144396420, 4269907996, 4178062228, 1883793496, 2403728665, 2497604743, 1383856311, 2876494627, 1917518562, 3810496343, 1716890410, 3001755655, 800440835, 2261089178, 3543599269, 807962610, 599762354, 33778362, 3977675356, 2328828971, 2809771154, 4077384432, 1315562145, 1708848333, 101039829, 3509871135, 3299278474, 875451293, 2733856160, 92987698, 2767645557, 193195065, 1080094634, 1584504582, 3178106961, 1042385657, 2531067453, 3711829422, 1306967366, 2438237621, 1908694277, 67556463, 1615861247, 429456164, 3602770327, 2302690252, 1742315127, 2968011453, 126454664, 3877198648, 2043211483, 2709260871, 2084704233, 4169408201, 0, 159417987, 841739592, 504459436, 1817866830, 4245618683, 260388950, 1034867998, 908933415, 168810852, 1750902305, 2606453969, 607530554, 202008497, 2472011535, 3035535058, 463180190, 2160117071, 1641816226, 1517767529, 470948374, 3801332234, 3231722213, 1008918595, 303765277, 235474187, 4069246893, 766945465, 337553864, 1475418501, 2943682380, 4003061179, 2743034109, 4144047775, 1551037884, 1147550661, 1543208500, 2336434550, 3408119516, 3069049960, 3102011747, 3610369226, 1113818384, 328671808, 2227573024, 2236228733, 3535486456, 2935566865, 3341394285, 496906059, 3702665459, 226906860, 2009195472, 733156972, 2842737049, 294930682, 1206477858, 2835123396, 2700099354, 1451044056, 573804783, 2269728455, 3644379585, 2362090238, 2564033334, 2801107407, 2776292904, 3669462566, 1068351396, 742039012, 1350078989, 1784663195, 1417561698, 4136440770, 2430122216, 775550814, 2193862645, 2673705150, 1775276924, 1876241833, 3475313331, 3366754619, 270040487, 3902563182, 3678124923, 3441850377, 1851332852, 3969562369, 2203032232, 3868552805, 2868897406, 566021896, 4011190502, 3135740889, 1248802510, 3936291284, 699432150, 832877231, 708780849, 3332740144, 899835584, 1951317047, 4236429990, 3767586992, 866637845, 4043610186, 1106041591, 2144161806, 395441711, 1984812685, 1139781709, 3433712980, 3835036895, 2664543715, 1282050075, 3240894392, 1181045119, 2640243204, 25965917, 4203181171, 4211818798, 3009879386, 2463879762, 3910161971, 1842759443, 2597806476, 933301370, 1509430414, 3943906441, 3467192302, 3076639029, 3776767469, 2051518780, 2631065433, 1441952575, 404016761, 1942435775, 1408749034, 1610459739, 3745345300, 2017778566, 3400528769, 3110650942, 941896748, 3265478751, 371049330, 3168937228, 675039627, 4279080257, 967311729, 135050206, 3635733660, 1683407248, 2076935265, 3576870512, 1215061108, 3501741890];
4334         var T6 = [1347548327, 1400783205, 3273267108, 2520393566, 3409685355, 4045380933, 2880240216, 2471224067, 1428173050, 4138563181, 2441661558, 636813900, 4233094615, 3620022987, 2149987652, 2411029155, 1239331162, 1730525723, 2554718734, 3781033664, 46346101, 310463728, 2743944855, 3328955385, 3875770207, 2501218972, 3955191162, 3667219033, 768917123, 3545789473, 692707433, 1150208456, 1786102409, 2029293177, 1805211710, 3710368113, 3065962831, 401639597, 1724457132, 3028143674, 409198410, 2196052529, 1620529459, 1164071807, 3769721975, 2226875310, 486441376, 2499348523, 1483753576, 428819965, 2274680428, 3075636216, 598438867, 3799141122, 1474502543, 711349675, 129166120, 53458370, 2592523643, 2782082824, 4063242375, 2988687269, 3120694122, 1559041666, 730517276, 2460449204, 4042459122, 2706270690, 3446004468, 3573941694, 533804130, 2328143614, 2637442643, 2695033685, 839224033, 1973745387, 957055980, 2856345839, 106852767, 1371368976, 4181598602, 1033297158, 2933734917, 1179510461, 3046200461, 91341917, 1862534868, 4284502037, 605657339, 2547432937, 3431546947, 2003294622, 3182487618, 2282195339, 954669403, 3682191598, 1201765386, 3917234703, 3388507166, 0, 2198438022, 1211247597, 2887651696, 1315723890, 4227665663, 1443857720, 507358933, 657861945, 1678381017, 560487590, 3516619604, 975451694, 2970356327, 261314535, 3535072918, 2652609425, 1333838021, 2724322336, 1767536459, 370938394, 182621114, 3854606378, 1128014560, 487725847, 185469197, 2918353863, 3106780840, 3356761769, 2237133081, 1286567175, 3152976349, 4255350624, 2683765030, 3160175349, 3309594171, 878443390, 1988838185, 3704300486, 1756818940, 1673061617, 3403100636, 272786309, 1075025698, 545572369, 2105887268, 4174560061, 296679730, 1841768865, 1260232239, 4091327024, 3960309330, 3497509347, 1814803222, 2578018489, 4195456072, 575138148, 3299409036, 446754879, 3629546796, 4011996048, 3347532110, 3252238545, 4270639778, 915985419, 3483825537, 681933534, 651868046, 2755636671, 3828103837, 223377554, 2607439820, 1649704518, 3270937875, 3901806776, 1580087799, 4118987695, 3198115200, 2087309459, 2842678573, 3016697106, 1003007129, 2802849917, 1860738147, 2077965243, 164439672, 4100872472, 32283319, 2827177882, 1709610350, 2125135846, 136428751, 3874428392, 3652904859, 3460984630, 3572145929, 3593056380, 2939266226, 824852259, 818324884, 3224740454, 930369212, 2801566410, 2967507152, 355706840, 1257309336, 4148292826, 243256656, 790073846, 2373340630, 1296297904, 1422699085, 3756299780, 3818836405, 457992840, 3099667487, 2135319889, 77422314, 1560382517, 1945798516, 788204353, 1521706781, 1385356242, 870912086, 325965383, 2358957921, 2050466060, 2388260884, 2313884476, 4006521127, 901210569, 3990953189, 1014646705, 1503449823, 1062597235, 2031621326, 3212035895, 3931371469, 1533017514, 350174575, 2256028891, 2177544179, 1052338372, 741876788, 1606591296, 1914052035, 213705253, 2334669897, 1107234197, 1899603969, 3725069491, 2631447780, 2422494913, 1635502980, 1893020342, 1950903388, 1120974935];
4335         var T7 = [2807058932, 1699970625, 2764249623, 1586903591, 1808481195, 1173430173, 1487645946, 59984867, 4199882800, 1844882806, 1989249228, 1277555970, 3623636965, 3419915562, 1149249077, 2744104290, 1514790577, 459744698, 244860394, 3235995134, 1963115311, 4027744588, 2544078150, 4190530515, 1608975247, 2627016082, 2062270317, 1507497298, 2200818878, 567498868, 1764313568, 3359936201, 2305455554, 2037970062, 1047239e3, 1910319033, 1337376481, 2904027272, 2892417312, 984907214, 1243112415, 830661914, 861968209, 2135253587, 2011214180, 2927934315, 2686254721, 731183368, 1750626376, 4246310725, 1820824798, 4172763771, 3542330227, 48394827, 2404901663, 2871682645, 671593195, 3254988725, 2073724613, 145085239, 2280796200, 2779915199, 1790575107, 2187128086, 472615631, 3029510009, 4075877127, 3802222185, 4107101658, 3201631749, 1646252340, 4270507174, 1402811438, 1436590835, 3778151818, 3950355702, 3963161475, 4020912224, 2667994737, 273792366, 2331590177, 104699613, 95345982, 3175501286, 2377486676, 1560637892, 3564045318, 369057872, 4213447064, 3919042237, 1137477952, 2658625497, 1119727848, 2340947849, 1530455833, 4007360968, 172466556, 266959938, 516552836, 0, 2256734592, 3980931627, 1890328081, 1917742170, 4294704398, 945164165, 3575528878, 958871085, 3647212047, 2787207260, 1423022939, 775562294, 1739656202, 3876557655, 2530391278, 2443058075, 3310321856, 547512796, 1265195639, 437656594, 3121275539, 719700128, 3762502690, 387781147, 218828297, 3350065803, 2830708150, 2848461854, 428169201, 122466165, 3720081049, 1627235199, 648017665, 4122762354, 1002783846, 2117360635, 695634755, 3336358691, 4234721005, 4049844452, 3704280881, 2232435299, 574624663, 287343814, 612205898, 1039717051, 840019705, 2708326185, 793451934, 821288114, 1391201670, 3822090177, 376187827, 3113855344, 1224348052, 1679968233, 2361698556, 1058709744, 752375421, 2431590963, 1321699145, 3519142200, 2734591178, 188127444, 2177869557, 3727205754, 2384911031, 3215212461, 2648976442, 2450346104, 3432737375, 1180849278, 331544205, 3102249176, 4150144569, 2952102595, 2159976285, 2474404304, 766078933, 313773861, 2570832044, 2108100632, 1668212892, 3145456443, 2013908262, 418672217, 3070356634, 2594734927, 1852171925, 3867060991, 3473416636, 3907448597, 2614737639, 919489135, 164948639, 2094410160, 2997825956, 590424639, 2486224549, 1723872674, 3157750862, 3399941250, 3501252752, 3625268135, 2555048196, 3673637356, 1343127501, 4130281361, 3599595085, 2957853679, 1297403050, 81781910, 3051593425, 2283490410, 532201772, 1367295589, 3926170974, 895287692, 1953757831, 1093597963, 492483431, 3528626907, 1446242576, 1192455638, 1636604631, 209336225, 344873464, 1015671571, 669961897, 3375740769, 3857572124, 2973530695, 3747192018, 1933530610, 3464042516, 935293895, 3454686199, 2858115069, 1863638845, 3683022916, 4085369519, 3292445032, 875313188, 1080017571, 3279033885, 621591778, 1233856572, 2504130317, 24197544, 3017672716, 3835484340, 3247465558, 2220981195, 3060847922, 1551124588, 1463996600];
4336         var T8 = [4104605777, 1097159550, 396673818, 660510266, 2875968315, 2638606623, 4200115116, 3808662347, 821712160, 1986918061, 3430322568, 38544885, 3856137295, 718002117, 893681702, 1654886325, 2975484382, 3122358053, 3926825029, 4274053469, 796197571, 1290801793, 1184342925, 3556361835, 2405426947, 2459735317, 1836772287, 1381620373, 3196267988, 1948373848, 3764988233, 3385345166, 3263785589, 2390325492, 1480485785, 3111247143, 3780097726, 2293045232, 548169417, 3459953789, 3746175075, 439452389, 1362321559, 1400849762, 1685577905, 1806599355, 2174754046, 137073913, 1214797936, 1174215055, 3731654548, 2079897426, 1943217067, 1258480242, 529487843, 1437280870, 3945269170, 3049390895, 3313212038, 923313619, 679998e3, 3215307299, 57326082, 377642221, 3474729866, 2041877159, 133361907, 1776460110, 3673476453, 96392454, 878845905, 2801699524, 777231668, 4082475170, 2330014213, 4142626212, 2213296395, 1626319424, 1906247262, 1846563261, 562755902, 3708173718, 1040559837, 3871163981, 1418573201, 3294430577, 114585348, 1343618912, 2566595609, 3186202582, 1078185097, 3651041127, 3896688048, 2307622919, 425408743, 3371096953, 2081048481, 1108339068, 2216610296, 0, 2156299017, 736970802, 292596766, 1517440620, 251657213, 2235061775, 2933202493, 758720310, 265905162, 1554391400, 1532285339, 908999204, 174567692, 1474760595, 4002861748, 2610011675, 3234156416, 3693126241, 2001430874, 303699484, 2478443234, 2687165888, 585122620, 454499602, 151849742, 2345119218, 3064510765, 514443284, 4044981591, 1963412655, 2581445614, 2137062819, 19308535, 1928707164, 1715193156, 4219352155, 1126790795, 600235211, 3992742070, 3841024952, 836553431, 1669664834, 2535604243, 3323011204, 1243905413, 3141400786, 4180808110, 698445255, 2653899549, 2989552604, 2253581325, 3252932727, 3004591147, 1891211689, 2487810577, 3915653703, 4237083816, 4030667424, 2100090966, 865136418, 1229899655, 953270745, 3399679628, 3557504664, 4118925222, 2061379749, 3079546586, 2915017791, 983426092, 2022837584, 1607244650, 2118541908, 2366882550, 3635996816, 972512814, 3283088770, 1568718495, 3499326569, 3576539503, 621982671, 2895723464, 410887952, 2623762152, 1002142683, 645401037, 1494807662, 2595684844, 1335535747, 2507040230, 4293295786, 3167684641, 367585007, 3885750714, 1865862730, 2668221674, 2960971305, 2763173681, 1059270954, 2777952454, 2724642869, 1320957812, 2194319100, 2429595872, 2815956275, 77089521, 3973773121, 3444575871, 2448830231, 1305906550, 4021308739, 2857194700, 2516901860, 3518358430, 1787304780, 740276417, 1699839814, 1592394909, 2352307457, 2272556026, 188821243, 1729977011, 3687994002, 274084841, 3594982253, 3613494426, 2701949495, 4162096729, 322734571, 2837966542, 1640576439, 484830689, 1202797690, 3537852828, 4067639125, 349075736, 3342319475, 4157467219, 4255800159, 1030690015, 1155237496, 2951971274, 1757691577, 607398968, 2738905026, 499347990, 3794078908, 1011452712, 227885567, 2818666809, 213114376, 3034881240, 1455525988, 3414450555, 850817237, 1817998408, 3092726480];
4337         var U1 = [0, 235474187, 470948374, 303765277, 941896748, 908933415, 607530554, 708780849, 1883793496, 2118214995, 1817866830, 1649639237, 1215061108, 1181045119, 1417561698, 1517767529, 3767586992, 4003061179, 4236429990, 4069246893, 3635733660, 3602770327, 3299278474, 3400528769, 2430122216, 2664543715, 2362090238, 2193862645, 2835123396, 2801107407, 3035535058, 3135740889, 3678124923, 3576870512, 3341394285, 3374361702, 3810496343, 3977675356, 4279080257, 4043610186, 2876494627, 2776292904, 3076639029, 3110650942, 2472011535, 2640243204, 2403728665, 2169303058, 1001089995, 899835584, 666464733, 699432150, 59727847, 226906860, 530400753, 294930682, 1273168787, 1172967064, 1475418501, 1509430414, 1942435775, 2110667444, 1876241833, 1641816226, 2910219766, 2743034109, 2976151520, 3211623147, 2505202138, 2606453969, 2302690252, 2269728455, 3711829422, 3543599269, 3240894392, 3475313331, 3843699074, 3943906441, 4178062228, 4144047775, 1306967366, 1139781709, 1374988112, 1610459739, 1975683434, 2076935265, 1775276924, 1742315127, 1034867998, 866637845, 566021896, 800440835, 92987698, 193195065, 429456164, 395441711, 1984812685, 2017778566, 1784663195, 1683407248, 1315562145, 1080094634, 1383856311, 1551037884, 101039829, 135050206, 437757123, 337553864, 1042385657, 807962610, 573804783, 742039012, 2531067453, 2564033334, 2328828971, 2227573024, 2935566865, 2700099354, 3001755655, 3168937228, 3868552805, 3902563182, 4203181171, 4102977912, 3736164937, 3501741890, 3265478751, 3433712980, 1106041591, 1340463100, 1576976609, 1408749034, 2043211483, 2009195472, 1708848333, 1809054150, 832877231, 1068351396, 766945465, 599762354, 159417987, 126454664, 361929877, 463180190, 2709260871, 2943682380, 3178106961, 3009879386, 2572697195, 2538681184, 2236228733, 2336434550, 3509871135, 3745345300, 3441850377, 3274667266, 3910161971, 3877198648, 4110568485, 4211818798, 2597806476, 2497604743, 2261089178, 2295101073, 2733856160, 2902087851, 3202437046, 2968011453, 3936291284, 3835036895, 4136440770, 4169408201, 3535486456, 3702665459, 3467192302, 3231722213, 2051518780, 1951317047, 1716890410, 1750902305, 1113818384, 1282050075, 1584504582, 1350078989, 168810852, 67556463, 371049330, 404016761, 841739592, 1008918595, 775550814, 540080725, 3969562369, 3801332234, 4035489047, 4269907996, 3569255213, 3669462566, 3366754619, 3332740144, 2631065433, 2463879762, 2160117071, 2395588676, 2767645557, 2868897406, 3102011747, 3069049960, 202008497, 33778362, 270040487, 504459436, 875451293, 975658646, 675039627, 641025152, 2084704233, 1917518562, 1615861247, 1851332852, 1147550661, 1248802510, 1484005843, 1451044056, 933301370, 967311729, 733156972, 632953703, 260388950, 25965917, 328671808, 496906059, 1206477858, 1239443753, 1543208500, 1441952575, 2144161806, 1908694277, 1675577880, 1842759443, 3610369226, 3644379585, 3408119516, 3307916247, 4011190502, 3776767469, 4077384432, 4245618683, 2809771154, 2842737049, 3144396420, 3043140495, 2673705150, 2438237621, 2203032232, 2370213795];
4338         var U2 = [0, 185469197, 370938394, 487725847, 741876788, 657861945, 975451694, 824852259, 1483753576, 1400783205, 1315723890, 1164071807, 1950903388, 2135319889, 1649704518, 1767536459, 2967507152, 3152976349, 2801566410, 2918353863, 2631447780, 2547432937, 2328143614, 2177544179, 3901806776, 3818836405, 4270639778, 4118987695, 3299409036, 3483825537, 3535072918, 3652904859, 2077965243, 1893020342, 1841768865, 1724457132, 1474502543, 1559041666, 1107234197, 1257309336, 598438867, 681933534, 901210569, 1052338372, 261314535, 77422314, 428819965, 310463728, 3409685355, 3224740454, 3710368113, 3593056380, 3875770207, 3960309330, 4045380933, 4195456072, 2471224067, 2554718734, 2237133081, 2388260884, 3212035895, 3028143674, 2842678573, 2724322336, 4138563181, 4255350624, 3769721975, 3955191162, 3667219033, 3516619604, 3431546947, 3347532110, 2933734917, 2782082824, 3099667487, 3016697106, 2196052529, 2313884476, 2499348523, 2683765030, 1179510461, 1296297904, 1347548327, 1533017514, 1786102409, 1635502980, 2087309459, 2003294622, 507358933, 355706840, 136428751, 53458370, 839224033, 957055980, 605657339, 790073846, 2373340630, 2256028891, 2607439820, 2422494913, 2706270690, 2856345839, 3075636216, 3160175349, 3573941694, 3725069491, 3273267108, 3356761769, 4181598602, 4063242375, 4011996048, 3828103837, 1033297158, 915985419, 730517276, 545572369, 296679730, 446754879, 129166120, 213705253, 1709610350, 1860738147, 1945798516, 2029293177, 1239331162, 1120974935, 1606591296, 1422699085, 4148292826, 4233094615, 3781033664, 3931371469, 3682191598, 3497509347, 3446004468, 3328955385, 2939266226, 2755636671, 3106780840, 2988687269, 2198438022, 2282195339, 2501218972, 2652609425, 1201765386, 1286567175, 1371368976, 1521706781, 1805211710, 1620529459, 2105887268, 1988838185, 533804130, 350174575, 164439672, 46346101, 870912086, 954669403, 636813900, 788204353, 2358957921, 2274680428, 2592523643, 2441661558, 2695033685, 2880240216, 3065962831, 3182487618, 3572145929, 3756299780, 3270937875, 3388507166, 4174560061, 4091327024, 4006521127, 3854606378, 1014646705, 930369212, 711349675, 560487590, 272786309, 457992840, 106852767, 223377554, 1678381017, 1862534868, 1914052035, 2031621326, 1211247597, 1128014560, 1580087799, 1428173050, 32283319, 182621114, 401639597, 486441376, 768917123, 651868046, 1003007129, 818324884, 1503449823, 1385356242, 1333838021, 1150208456, 1973745387, 2125135846, 1673061617, 1756818940, 2970356327, 3120694122, 2802849917, 2887651696, 2637442643, 2520393566, 2334669897, 2149987652, 3917234703, 3799141122, 4284502037, 4100872472, 3309594171, 3460984630, 3545789473, 3629546796, 2050466060, 1899603969, 1814803222, 1730525723, 1443857720, 1560382517, 1075025698, 1260232239, 575138148, 692707433, 878443390, 1062597235, 243256656, 91341917, 409198410, 325965383, 3403100636, 3252238545, 3704300486, 3620022987, 3874428392, 3990953189, 4042459122, 4227665663, 2460449204, 2578018489, 2226875310, 2411029155, 3198115200, 3046200461, 2827177882, 2743944855];
4339         var U3 = [0, 218828297, 437656594, 387781147, 875313188, 958871085, 775562294, 590424639, 1750626376, 1699970625, 1917742170, 2135253587, 1551124588, 1367295589, 1180849278, 1265195639, 3501252752, 3720081049, 3399941250, 3350065803, 3835484340, 3919042237, 4270507174, 4085369519, 3102249176, 3051593425, 2734591178, 2952102595, 2361698556, 2177869557, 2530391278, 2614737639, 3145456443, 3060847922, 2708326185, 2892417312, 2404901663, 2187128086, 2504130317, 2555048196, 3542330227, 3727205754, 3375740769, 3292445032, 3876557655, 3926170974, 4246310725, 4027744588, 1808481195, 1723872674, 1910319033, 2094410160, 1608975247, 1391201670, 1173430173, 1224348052, 59984867, 244860394, 428169201, 344873464, 935293895, 984907214, 766078933, 547512796, 1844882806, 1627235199, 2011214180, 2062270317, 1507497298, 1423022939, 1137477952, 1321699145, 95345982, 145085239, 532201772, 313773861, 830661914, 1015671571, 731183368, 648017665, 3175501286, 2957853679, 2807058932, 2858115069, 2305455554, 2220981195, 2474404304, 2658625497, 3575528878, 3625268135, 3473416636, 3254988725, 3778151818, 3963161475, 4213447064, 4130281361, 3599595085, 3683022916, 3432737375, 3247465558, 3802222185, 4020912224, 4172763771, 4122762354, 3201631749, 3017672716, 2764249623, 2848461854, 2331590177, 2280796200, 2431590963, 2648976442, 104699613, 188127444, 472615631, 287343814, 840019705, 1058709744, 671593195, 621591778, 1852171925, 1668212892, 1953757831, 2037970062, 1514790577, 1463996600, 1080017571, 1297403050, 3673637356, 3623636965, 3235995134, 3454686199, 4007360968, 3822090177, 4107101658, 4190530515, 2997825956, 3215212461, 2830708150, 2779915199, 2256734592, 2340947849, 2627016082, 2443058075, 172466556, 122466165, 273792366, 492483431, 1047239e3, 861968209, 612205898, 695634755, 1646252340, 1863638845, 2013908262, 1963115311, 1446242576, 1530455833, 1277555970, 1093597963, 1636604631, 1820824798, 2073724613, 1989249228, 1436590835, 1487645946, 1337376481, 1119727848, 164948639, 81781910, 331544205, 516552836, 1039717051, 821288114, 669961897, 719700128, 2973530695, 3157750862, 2871682645, 2787207260, 2232435299, 2283490410, 2667994737, 2450346104, 3647212047, 3564045318, 3279033885, 3464042516, 3980931627, 3762502690, 4150144569, 4199882800, 3070356634, 3121275539, 2904027272, 2686254721, 2200818878, 2384911031, 2570832044, 2486224549, 3747192018, 3528626907, 3310321856, 3359936201, 3950355702, 3867060991, 4049844452, 4234721005, 1739656202, 1790575107, 2108100632, 1890328081, 1402811438, 1586903591, 1233856572, 1149249077, 266959938, 48394827, 369057872, 418672217, 1002783846, 919489135, 567498868, 752375421, 209336225, 24197544, 376187827, 459744698, 945164165, 895287692, 574624663, 793451934, 1679968233, 1764313568, 2117360635, 1933530610, 1343127501, 1560637892, 1243112415, 1192455638, 3704280881, 3519142200, 3336358691, 3419915562, 3907448597, 3857572124, 4075877127, 4294704398, 3029510009, 3113855344, 2927934315, 2744104290, 2159976285, 2377486676, 2594734927, 2544078150];
4340         var U4 = [0, 151849742, 303699484, 454499602, 607398968, 758720310, 908999204, 1059270954, 1214797936, 1097159550, 1517440620, 1400849762, 1817998408, 1699839814, 2118541908, 2001430874, 2429595872, 2581445614, 2194319100, 2345119218, 3034881240, 3186202582, 2801699524, 2951971274, 3635996816, 3518358430, 3399679628, 3283088770, 4237083816, 4118925222, 4002861748, 3885750714, 1002142683, 850817237, 698445255, 548169417, 529487843, 377642221, 227885567, 77089521, 1943217067, 2061379749, 1640576439, 1757691577, 1474760595, 1592394909, 1174215055, 1290801793, 2875968315, 2724642869, 3111247143, 2960971305, 2405426947, 2253581325, 2638606623, 2487810577, 3808662347, 3926825029, 4044981591, 4162096729, 3342319475, 3459953789, 3576539503, 3693126241, 1986918061, 2137062819, 1685577905, 1836772287, 1381620373, 1532285339, 1078185097, 1229899655, 1040559837, 923313619, 740276417, 621982671, 439452389, 322734571, 137073913, 19308535, 3871163981, 4021308739, 4104605777, 4255800159, 3263785589, 3414450555, 3499326569, 3651041127, 2933202493, 2815956275, 3167684641, 3049390895, 2330014213, 2213296395, 2566595609, 2448830231, 1305906550, 1155237496, 1607244650, 1455525988, 1776460110, 1626319424, 2079897426, 1928707164, 96392454, 213114376, 396673818, 514443284, 562755902, 679998e3, 865136418, 983426092, 3708173718, 3557504664, 3474729866, 3323011204, 4180808110, 4030667424, 3945269170, 3794078908, 2507040230, 2623762152, 2272556026, 2390325492, 2975484382, 3092726480, 2738905026, 2857194700, 3973773121, 3856137295, 4274053469, 4157467219, 3371096953, 3252932727, 3673476453, 3556361835, 2763173681, 2915017791, 3064510765, 3215307299, 2156299017, 2307622919, 2459735317, 2610011675, 2081048481, 1963412655, 1846563261, 1729977011, 1480485785, 1362321559, 1243905413, 1126790795, 878845905, 1030690015, 645401037, 796197571, 274084841, 425408743, 38544885, 188821243, 3613494426, 3731654548, 3313212038, 3430322568, 4082475170, 4200115116, 3780097726, 3896688048, 2668221674, 2516901860, 2366882550, 2216610296, 3141400786, 2989552604, 2837966542, 2687165888, 1202797690, 1320957812, 1437280870, 1554391400, 1669664834, 1787304780, 1906247262, 2022837584, 265905162, 114585348, 499347990, 349075736, 736970802, 585122620, 972512814, 821712160, 2595684844, 2478443234, 2293045232, 2174754046, 3196267988, 3079546586, 2895723464, 2777952454, 3537852828, 3687994002, 3234156416, 3385345166, 4142626212, 4293295786, 3841024952, 3992742070, 174567692, 57326082, 410887952, 292596766, 777231668, 660510266, 1011452712, 893681702, 1108339068, 1258480242, 1343618912, 1494807662, 1715193156, 1865862730, 1948373848, 2100090966, 2701949495, 2818666809, 3004591147, 3122358053, 2235061775, 2352307457, 2535604243, 2653899549, 3915653703, 3764988233, 4219352155, 4067639125, 3444575871, 3294430577, 3746175075, 3594982253, 836553431, 953270745, 600235211, 718002117, 367585007, 484830689, 133361907, 251657213, 2041877159, 1891211689, 1806599355, 1654886325, 1568718495, 1418573201, 1335535747, 1184342925];
4341         function convertToInt32(bytes) {
4342           var result = [];
4343           for (var i3 = 0; i3 < bytes.length; i3 += 4) {
4344             result.push(
4345               bytes[i3] << 24 | bytes[i3 + 1] << 16 | bytes[i3 + 2] << 8 | bytes[i3 + 3]
4346             );
4347           }
4348           return result;
4349         }
4350         var AES = function(key) {
4351           if (!(this instanceof AES)) {
4352             throw Error("AES must be instanitated with `new`");
4353           }
4354           Object.defineProperty(this, "key", {
4355             value: coerceArray(key, true)
4356           });
4357           this._prepare();
4358         };
4359         AES.prototype._prepare = function() {
4360           var rounds = numberOfRounds[this.key.length];
4361           if (rounds == null) {
4362             throw new Error("invalid key size (must be 16, 24 or 32 bytes)");
4363           }
4364           this._Ke = [];
4365           this._Kd = [];
4366           for (var i3 = 0; i3 <= rounds; i3++) {
4367             this._Ke.push([0, 0, 0, 0]);
4368             this._Kd.push([0, 0, 0, 0]);
4369           }
4370           var roundKeyCount = (rounds + 1) * 4;
4371           var KC = this.key.length / 4;
4372           var tk = convertToInt32(this.key);
4373           var index;
4374           for (var i3 = 0; i3 < KC; i3++) {
4375             index = i3 >> 2;
4376             this._Ke[index][i3 % 4] = tk[i3];
4377             this._Kd[rounds - index][i3 % 4] = tk[i3];
4378           }
4379           var rconpointer = 0;
4380           var t2 = KC, tt2;
4381           while (t2 < roundKeyCount) {
4382             tt2 = tk[KC - 1];
4383             tk[0] ^= S2[tt2 >> 16 & 255] << 24 ^ S2[tt2 >> 8 & 255] << 16 ^ S2[tt2 & 255] << 8 ^ S2[tt2 >> 24 & 255] ^ rcon[rconpointer] << 24;
4384             rconpointer += 1;
4385             if (KC != 8) {
4386               for (var i3 = 1; i3 < KC; i3++) {
4387                 tk[i3] ^= tk[i3 - 1];
4388               }
4389             } else {
4390               for (var i3 = 1; i3 < KC / 2; i3++) {
4391                 tk[i3] ^= tk[i3 - 1];
4392               }
4393               tt2 = tk[KC / 2 - 1];
4394               tk[KC / 2] ^= S2[tt2 & 255] ^ S2[tt2 >> 8 & 255] << 8 ^ S2[tt2 >> 16 & 255] << 16 ^ S2[tt2 >> 24 & 255] << 24;
4395               for (var i3 = KC / 2 + 1; i3 < KC; i3++) {
4396                 tk[i3] ^= tk[i3 - 1];
4397               }
4398             }
4399             var i3 = 0, r2, c2;
4400             while (i3 < KC && t2 < roundKeyCount) {
4401               r2 = t2 >> 2;
4402               c2 = t2 % 4;
4403               this._Ke[r2][c2] = tk[i3];
4404               this._Kd[rounds - r2][c2] = tk[i3++];
4405               t2++;
4406             }
4407           }
4408           for (var r2 = 1; r2 < rounds; r2++) {
4409             for (var c2 = 0; c2 < 4; c2++) {
4410               tt2 = this._Kd[r2][c2];
4411               this._Kd[r2][c2] = U1[tt2 >> 24 & 255] ^ U2[tt2 >> 16 & 255] ^ U3[tt2 >> 8 & 255] ^ U4[tt2 & 255];
4412             }
4413           }
4414         };
4415         AES.prototype.encrypt = function(plaintext) {
4416           if (plaintext.length != 16) {
4417             throw new Error("invalid plaintext size (must be 16 bytes)");
4418           }
4419           var rounds = this._Ke.length - 1;
4420           var a2 = [0, 0, 0, 0];
4421           var t2 = convertToInt32(plaintext);
4422           for (var i3 = 0; i3 < 4; i3++) {
4423             t2[i3] ^= this._Ke[0][i3];
4424           }
4425           for (var r2 = 1; r2 < rounds; r2++) {
4426             for (var i3 = 0; i3 < 4; i3++) {
4427               a2[i3] = T1[t2[i3] >> 24 & 255] ^ T2[t2[(i3 + 1) % 4] >> 16 & 255] ^ T3[t2[(i3 + 2) % 4] >> 8 & 255] ^ T4[t2[(i3 + 3) % 4] & 255] ^ this._Ke[r2][i3];
4428             }
4429             t2 = a2.slice();
4430           }
4431           var result = createArray(16), tt2;
4432           for (var i3 = 0; i3 < 4; i3++) {
4433             tt2 = this._Ke[rounds][i3];
4434             result[4 * i3] = (S2[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255;
4435             result[4 * i3 + 1] = (S2[t2[(i3 + 1) % 4] >> 16 & 255] ^ tt2 >> 16) & 255;
4436             result[4 * i3 + 2] = (S2[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255;
4437             result[4 * i3 + 3] = (S2[t2[(i3 + 3) % 4] & 255] ^ tt2) & 255;
4438           }
4439           return result;
4440         };
4441         AES.prototype.decrypt = function(ciphertext) {
4442           if (ciphertext.length != 16) {
4443             throw new Error("invalid ciphertext size (must be 16 bytes)");
4444           }
4445           var rounds = this._Kd.length - 1;
4446           var a2 = [0, 0, 0, 0];
4447           var t2 = convertToInt32(ciphertext);
4448           for (var i3 = 0; i3 < 4; i3++) {
4449             t2[i3] ^= this._Kd[0][i3];
4450           }
4451           for (var r2 = 1; r2 < rounds; r2++) {
4452             for (var i3 = 0; i3 < 4; i3++) {
4453               a2[i3] = T5[t2[i3] >> 24 & 255] ^ T6[t2[(i3 + 3) % 4] >> 16 & 255] ^ T7[t2[(i3 + 2) % 4] >> 8 & 255] ^ T8[t2[(i3 + 1) % 4] & 255] ^ this._Kd[r2][i3];
4454             }
4455             t2 = a2.slice();
4456           }
4457           var result = createArray(16), tt2;
4458           for (var i3 = 0; i3 < 4; i3++) {
4459             tt2 = this._Kd[rounds][i3];
4460             result[4 * i3] = (Si[t2[i3] >> 24 & 255] ^ tt2 >> 24) & 255;
4461             result[4 * i3 + 1] = (Si[t2[(i3 + 3) % 4] >> 16 & 255] ^ tt2 >> 16) & 255;
4462             result[4 * i3 + 2] = (Si[t2[(i3 + 2) % 4] >> 8 & 255] ^ tt2 >> 8) & 255;
4463             result[4 * i3 + 3] = (Si[t2[(i3 + 1) % 4] & 255] ^ tt2) & 255;
4464           }
4465           return result;
4466         };
4467         var ModeOfOperationECB = function(key) {
4468           if (!(this instanceof ModeOfOperationECB)) {
4469             throw Error("AES must be instanitated with `new`");
4470           }
4471           this.description = "Electronic Code Block";
4472           this.name = "ecb";
4473           this._aes = new AES(key);
4474         };
4475         ModeOfOperationECB.prototype.encrypt = function(plaintext) {
4476           plaintext = coerceArray(plaintext);
4477           if (plaintext.length % 16 !== 0) {
4478             throw new Error("invalid plaintext size (must be multiple of 16 bytes)");
4479           }
4480           var ciphertext = createArray(plaintext.length);
4481           var block2 = createArray(16);
4482           for (var i3 = 0; i3 < plaintext.length; i3 += 16) {
4483             copyArray(plaintext, block2, 0, i3, i3 + 16);
4484             block2 = this._aes.encrypt(block2);
4485             copyArray(block2, ciphertext, i3);
4486           }
4487           return ciphertext;
4488         };
4489         ModeOfOperationECB.prototype.decrypt = function(ciphertext) {
4490           ciphertext = coerceArray(ciphertext);
4491           if (ciphertext.length % 16 !== 0) {
4492             throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");
4493           }
4494           var plaintext = createArray(ciphertext.length);
4495           var block2 = createArray(16);
4496           for (var i3 = 0; i3 < ciphertext.length; i3 += 16) {
4497             copyArray(ciphertext, block2, 0, i3, i3 + 16);
4498             block2 = this._aes.decrypt(block2);
4499             copyArray(block2, plaintext, i3);
4500           }
4501           return plaintext;
4502         };
4503         var ModeOfOperationCBC = function(key, iv) {
4504           if (!(this instanceof ModeOfOperationCBC)) {
4505             throw Error("AES must be instanitated with `new`");
4506           }
4507           this.description = "Cipher Block Chaining";
4508           this.name = "cbc";
4509           if (!iv) {
4510             iv = createArray(16);
4511           } else if (iv.length != 16) {
4512             throw new Error("invalid initialation vector size (must be 16 bytes)");
4513           }
4514           this._lastCipherblock = coerceArray(iv, true);
4515           this._aes = new AES(key);
4516         };
4517         ModeOfOperationCBC.prototype.encrypt = function(plaintext) {
4518           plaintext = coerceArray(plaintext);
4519           if (plaintext.length % 16 !== 0) {
4520             throw new Error("invalid plaintext size (must be multiple of 16 bytes)");
4521           }
4522           var ciphertext = createArray(plaintext.length);
4523           var block2 = createArray(16);
4524           for (var i3 = 0; i3 < plaintext.length; i3 += 16) {
4525             copyArray(plaintext, block2, 0, i3, i3 + 16);
4526             for (var j2 = 0; j2 < 16; j2++) {
4527               block2[j2] ^= this._lastCipherblock[j2];
4528             }
4529             this._lastCipherblock = this._aes.encrypt(block2);
4530             copyArray(this._lastCipherblock, ciphertext, i3);
4531           }
4532           return ciphertext;
4533         };
4534         ModeOfOperationCBC.prototype.decrypt = function(ciphertext) {
4535           ciphertext = coerceArray(ciphertext);
4536           if (ciphertext.length % 16 !== 0) {
4537             throw new Error("invalid ciphertext size (must be multiple of 16 bytes)");
4538           }
4539           var plaintext = createArray(ciphertext.length);
4540           var block2 = createArray(16);
4541           for (var i3 = 0; i3 < ciphertext.length; i3 += 16) {
4542             copyArray(ciphertext, block2, 0, i3, i3 + 16);
4543             block2 = this._aes.decrypt(block2);
4544             for (var j2 = 0; j2 < 16; j2++) {
4545               plaintext[i3 + j2] = block2[j2] ^ this._lastCipherblock[j2];
4546             }
4547             copyArray(ciphertext, this._lastCipherblock, 0, i3, i3 + 16);
4548           }
4549           return plaintext;
4550         };
4551         var ModeOfOperationCFB = function(key, iv, segmentSize) {
4552           if (!(this instanceof ModeOfOperationCFB)) {
4553             throw Error("AES must be instanitated with `new`");
4554           }
4555           this.description = "Cipher Feedback";
4556           this.name = "cfb";
4557           if (!iv) {
4558             iv = createArray(16);
4559           } else if (iv.length != 16) {
4560             throw new Error("invalid initialation vector size (must be 16 size)");
4561           }
4562           if (!segmentSize) {
4563             segmentSize = 1;
4564           }
4565           this.segmentSize = segmentSize;
4566           this._shiftRegister = coerceArray(iv, true);
4567           this._aes = new AES(key);
4568         };
4569         ModeOfOperationCFB.prototype.encrypt = function(plaintext) {
4570           if (plaintext.length % this.segmentSize != 0) {
4571             throw new Error("invalid plaintext size (must be segmentSize bytes)");
4572           }
4573           var encrypted = coerceArray(plaintext, true);
4574           var xorSegment;
4575           for (var i3 = 0; i3 < encrypted.length; i3 += this.segmentSize) {
4576             xorSegment = this._aes.encrypt(this._shiftRegister);
4577             for (var j2 = 0; j2 < this.segmentSize; j2++) {
4578               encrypted[i3 + j2] ^= xorSegment[j2];
4579             }
4580             copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
4581             copyArray(encrypted, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize);
4582           }
4583           return encrypted;
4584         };
4585         ModeOfOperationCFB.prototype.decrypt = function(ciphertext) {
4586           if (ciphertext.length % this.segmentSize != 0) {
4587             throw new Error("invalid ciphertext size (must be segmentSize bytes)");
4588           }
4589           var plaintext = coerceArray(ciphertext, true);
4590           var xorSegment;
4591           for (var i3 = 0; i3 < plaintext.length; i3 += this.segmentSize) {
4592             xorSegment = this._aes.encrypt(this._shiftRegister);
4593             for (var j2 = 0; j2 < this.segmentSize; j2++) {
4594               plaintext[i3 + j2] ^= xorSegment[j2];
4595             }
4596             copyArray(this._shiftRegister, this._shiftRegister, 0, this.segmentSize);
4597             copyArray(ciphertext, this._shiftRegister, 16 - this.segmentSize, i3, i3 + this.segmentSize);
4598           }
4599           return plaintext;
4600         };
4601         var ModeOfOperationOFB = function(key, iv) {
4602           if (!(this instanceof ModeOfOperationOFB)) {
4603             throw Error("AES must be instanitated with `new`");
4604           }
4605           this.description = "Output Feedback";
4606           this.name = "ofb";
4607           if (!iv) {
4608             iv = createArray(16);
4609           } else if (iv.length != 16) {
4610             throw new Error("invalid initialation vector size (must be 16 bytes)");
4611           }
4612           this._lastPrecipher = coerceArray(iv, true);
4613           this._lastPrecipherIndex = 16;
4614           this._aes = new AES(key);
4615         };
4616         ModeOfOperationOFB.prototype.encrypt = function(plaintext) {
4617           var encrypted = coerceArray(plaintext, true);
4618           for (var i3 = 0; i3 < encrypted.length; i3++) {
4619             if (this._lastPrecipherIndex === 16) {
4620               this._lastPrecipher = this._aes.encrypt(this._lastPrecipher);
4621               this._lastPrecipherIndex = 0;
4622             }
4623             encrypted[i3] ^= this._lastPrecipher[this._lastPrecipherIndex++];
4624           }
4625           return encrypted;
4626         };
4627         ModeOfOperationOFB.prototype.decrypt = ModeOfOperationOFB.prototype.encrypt;
4628         var Counter = function(initialValue) {
4629           if (!(this instanceof Counter)) {
4630             throw Error("Counter must be instanitated with `new`");
4631           }
4632           if (initialValue !== 0 && !initialValue) {
4633             initialValue = 1;
4634           }
4635           if (typeof initialValue === "number") {
4636             this._counter = createArray(16);
4637             this.setValue(initialValue);
4638           } else {
4639             this.setBytes(initialValue);
4640           }
4641         };
4642         Counter.prototype.setValue = function(value) {
4643           if (typeof value !== "number" || parseInt(value) != value) {
4644             throw new Error("invalid counter value (must be an integer)");
4645           }
4646           if (value > Number.MAX_SAFE_INTEGER) {
4647             throw new Error("integer value out of safe range");
4648           }
4649           for (var index = 15; index >= 0; --index) {
4650             this._counter[index] = value % 256;
4651             value = parseInt(value / 256);
4652           }
4653         };
4654         Counter.prototype.setBytes = function(bytes) {
4655           bytes = coerceArray(bytes, true);
4656           if (bytes.length != 16) {
4657             throw new Error("invalid counter bytes size (must be 16 bytes)");
4658           }
4659           this._counter = bytes;
4660         };
4661         Counter.prototype.increment = function() {
4662           for (var i3 = 15; i3 >= 0; i3--) {
4663             if (this._counter[i3] === 255) {
4664               this._counter[i3] = 0;
4665             } else {
4666               this._counter[i3]++;
4667               break;
4668             }
4669           }
4670         };
4671         var ModeOfOperationCTR = function(key, counter) {
4672           if (!(this instanceof ModeOfOperationCTR)) {
4673             throw Error("AES must be instanitated with `new`");
4674           }
4675           this.description = "Counter";
4676           this.name = "ctr";
4677           if (!(counter instanceof Counter)) {
4678             counter = new Counter(counter);
4679           }
4680           this._counter = counter;
4681           this._remainingCounter = null;
4682           this._remainingCounterIndex = 16;
4683           this._aes = new AES(key);
4684         };
4685         ModeOfOperationCTR.prototype.encrypt = function(plaintext) {
4686           var encrypted = coerceArray(plaintext, true);
4687           for (var i3 = 0; i3 < encrypted.length; i3++) {
4688             if (this._remainingCounterIndex === 16) {
4689               this._remainingCounter = this._aes.encrypt(this._counter._counter);
4690               this._remainingCounterIndex = 0;
4691               this._counter.increment();
4692             }
4693             encrypted[i3] ^= this._remainingCounter[this._remainingCounterIndex++];
4694           }
4695           return encrypted;
4696         };
4697         ModeOfOperationCTR.prototype.decrypt = ModeOfOperationCTR.prototype.encrypt;
4698         function pkcs7pad(data) {
4699           data = coerceArray(data, true);
4700           var padder = 16 - data.length % 16;
4701           var result = createArray(data.length + padder);
4702           copyArray(data, result);
4703           for (var i3 = data.length; i3 < result.length; i3++) {
4704             result[i3] = padder;
4705           }
4706           return result;
4707         }
4708         function pkcs7strip(data) {
4709           data = coerceArray(data, true);
4710           if (data.length < 16) {
4711             throw new Error("PKCS#7 invalid length");
4712           }
4713           var padder = data[data.length - 1];
4714           if (padder > 16) {
4715             throw new Error("PKCS#7 padding byte out of range");
4716           }
4717           var length2 = data.length - padder;
4718           for (var i3 = 0; i3 < padder; i3++) {
4719             if (data[length2 + i3] !== padder) {
4720               throw new Error("PKCS#7 invalid padding byte");
4721             }
4722           }
4723           var result = createArray(length2);
4724           copyArray(data, result, 0, 0, length2);
4725           return result;
4726         }
4727         var aesjs2 = {
4728           AES,
4729           Counter,
4730           ModeOfOperation: {
4731             ecb: ModeOfOperationECB,
4732             cbc: ModeOfOperationCBC,
4733             cfb: ModeOfOperationCFB,
4734             ofb: ModeOfOperationOFB,
4735             ctr: ModeOfOperationCTR
4736           },
4737           utils: {
4738             hex: convertHex,
4739             utf8: convertUtf8
4740           },
4741           padding: {
4742             pkcs7: {
4743               pad: pkcs7pad,
4744               strip: pkcs7strip
4745             }
4746           },
4747           _arrayTest: {
4748             coerceArray,
4749             createArray,
4750             copyArray
4751           }
4752         };
4753         if (typeof exports2 !== "undefined") {
4754           module2.exports = aesjs2;
4755         } else if (typeof define === "function" && define.amd) {
4756           define([], function() {
4757             return aesjs2;
4758           });
4759         } else {
4760           if (root3.aesjs) {
4761             aesjs2._aesjs = root3.aesjs;
4762           }
4763           root3.aesjs = aesjs2;
4764         }
4765       })(exports2);
4766     }
4767   });
4768
4769   // node_modules/lodash/lodash.js
4770   var require_lodash = __commonJS({
4771     "node_modules/lodash/lodash.js"(exports2, module2) {
4772       (function() {
4773         var undefined2;
4774         var VERSION = "4.17.21";
4775         var LARGE_ARRAY_SIZE2 = 200;
4776         var CORE_ERROR_TEXT = "Unsupported core-js use. Try https://npms.io/search?q=ponyfill.", FUNC_ERROR_TEXT3 = "Expected a function", INVALID_TEMPL_VAR_ERROR_TEXT = "Invalid `variable` option passed into `_.template`";
4777         var HASH_UNDEFINED4 = "__lodash_hash_undefined__";
4778         var MAX_MEMOIZE_SIZE = 500;
4779         var PLACEHOLDER = "__lodash_placeholder__";
4780         var CLONE_DEEP_FLAG = 1, CLONE_FLAT_FLAG = 2, CLONE_SYMBOLS_FLAG = 4;
4781         var COMPARE_PARTIAL_FLAG5 = 1, COMPARE_UNORDERED_FLAG3 = 2;
4782         var WRAP_BIND_FLAG = 1, WRAP_BIND_KEY_FLAG = 2, WRAP_CURRY_BOUND_FLAG = 4, WRAP_CURRY_FLAG = 8, WRAP_CURRY_RIGHT_FLAG = 16, WRAP_PARTIAL_FLAG = 32, WRAP_PARTIAL_RIGHT_FLAG = 64, WRAP_ARY_FLAG = 128, WRAP_REARG_FLAG = 256, WRAP_FLIP_FLAG = 512;
4783         var DEFAULT_TRUNC_LENGTH = 30, DEFAULT_TRUNC_OMISSION = "...";
4784         var HOT_COUNT = 800, HOT_SPAN = 16;
4785         var LAZY_FILTER_FLAG = 1, LAZY_MAP_FLAG = 2, LAZY_WHILE_FLAG = 3;
4786         var INFINITY2 = 1 / 0, MAX_SAFE_INTEGER4 = 9007199254740991, MAX_INTEGER = 17976931348623157e292, NAN2 = 0 / 0;
4787         var MAX_ARRAY_LENGTH = 4294967295, MAX_ARRAY_INDEX = MAX_ARRAY_LENGTH - 1, HALF_MAX_ARRAY_LENGTH = MAX_ARRAY_LENGTH >>> 1;
4788         var wrapFlags = [
4789           ["ary", WRAP_ARY_FLAG],
4790           ["bind", WRAP_BIND_FLAG],
4791           ["bindKey", WRAP_BIND_KEY_FLAG],
4792           ["curry", WRAP_CURRY_FLAG],
4793           ["curryRight", WRAP_CURRY_RIGHT_FLAG],
4794           ["flip", WRAP_FLIP_FLAG],
4795           ["partial", WRAP_PARTIAL_FLAG],
4796           ["partialRight", WRAP_PARTIAL_RIGHT_FLAG],
4797           ["rearg", WRAP_REARG_FLAG]
4798         ];
4799         var argsTag4 = "[object Arguments]", arrayTag3 = "[object Array]", asyncTag2 = "[object AsyncFunction]", boolTag3 = "[object Boolean]", dateTag3 = "[object Date]", domExcTag = "[object DOMException]", errorTag3 = "[object Error]", funcTag3 = "[object Function]", genTag2 = "[object GeneratorFunction]", mapTag4 = "[object Map]", numberTag4 = "[object Number]", nullTag2 = "[object Null]", objectTag4 = "[object Object]", promiseTag2 = "[object Promise]", proxyTag2 = "[object Proxy]", regexpTag3 = "[object RegExp]", setTag4 = "[object Set]", stringTag3 = "[object String]", symbolTag3 = "[object Symbol]", undefinedTag2 = "[object Undefined]", weakMapTag3 = "[object WeakMap]", weakSetTag = "[object WeakSet]";
4800         var arrayBufferTag3 = "[object ArrayBuffer]", dataViewTag4 = "[object DataView]", float32Tag2 = "[object Float32Array]", float64Tag2 = "[object Float64Array]", int8Tag2 = "[object Int8Array]", int16Tag2 = "[object Int16Array]", int32Tag2 = "[object Int32Array]", uint8Tag2 = "[object Uint8Array]", uint8ClampedTag2 = "[object Uint8ClampedArray]", uint16Tag2 = "[object Uint16Array]", uint32Tag2 = "[object Uint32Array]";
4801         var reEmptyStringLeading = /\b__p \+= '';/g, reEmptyStringMiddle = /\b(__p \+=) '' \+/g, reEmptyStringTrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
4802         var reEscapedHtml2 = /&(?:amp|lt|gt|quot|#39);/g, reUnescapedHtml2 = /[&<>"']/g, reHasEscapedHtml2 = RegExp(reEscapedHtml2.source), reHasUnescapedHtml2 = RegExp(reUnescapedHtml2.source);
4803         var reEscape = /<%-([\s\S]+?)%>/g, reEvaluate = /<%([\s\S]+?)%>/g, reInterpolate = /<%=([\s\S]+?)%>/g;
4804         var reIsDeepProp = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/, reIsPlainProp = /^\w*$/, rePropName = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
4805         var reRegExpChar2 = /[\\^$.*+?()[\]{}|]/g, reHasRegExpChar = RegExp(reRegExpChar2.source);
4806         var reTrimStart2 = /^\s+/;
4807         var reWhitespace2 = /\s/;
4808         var reWrapComment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/, reWrapDetails = /\{\n\/\* \[wrapped with (.+)\] \*/, reSplitDetails = /,? & /;
4809         var reAsciiWord = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
4810         var reForbiddenIdentifierChars = /[()=,{}\[\]\/\s]/;
4811         var reEscapeChar = /\\(\\)?/g;
4812         var reEsTemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
4813         var reFlags = /\w*$/;
4814         var reIsBadHex2 = /^[-+]0x[0-9a-f]+$/i;
4815         var reIsBinary2 = /^0b[01]+$/i;
4816         var reIsHostCtor2 = /^\[object .+?Constructor\]$/;
4817         var reIsOctal2 = /^0o[0-7]+$/i;
4818         var reIsUint2 = /^(?:0|[1-9]\d*)$/;
4819         var reLatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
4820         var reNoMatch = /($^)/;
4821         var reUnescapedString = /['\n\r\u2028\u2029\\]/g;
4822         var rsAstralRange = "\\ud800-\\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsDingbatRange = "\\u2700-\\u27bf", rsLowerRange = "a-z\\xdf-\\xf6\\xf8-\\xff", rsMathOpRange = "\\xac\\xb1\\xd7\\xf7", rsNonCharRange = "\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf", rsPunctuationRange = "\\u2000-\\u206f", rsSpaceRange = " \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000", rsUpperRange = "A-Z\\xc0-\\xd6\\xd8-\\xde", rsVarRange = "\\ufe0e\\ufe0f", rsBreakRange = rsMathOpRange + rsNonCharRange + rsPunctuationRange + rsSpaceRange;
4823         var rsApos = "['\u2019]", rsAstral = "[" + rsAstralRange + "]", rsBreak = "[" + rsBreakRange + "]", rsCombo = "[" + rsComboRange + "]", rsDigits = "\\d+", rsDingbat = "[" + rsDingbatRange + "]", rsLower = "[" + rsLowerRange + "]", rsMisc = "[^" + rsAstralRange + rsBreakRange + rsDigits + rsDingbatRange + rsLowerRange + rsUpperRange + "]", rsFitz = "\\ud83c[\\udffb-\\udfff]", rsModifier = "(?:" + rsCombo + "|" + rsFitz + ")", rsNonAstral = "[^" + rsAstralRange + "]", rsRegional = "(?:\\ud83c[\\udde6-\\uddff]){2}", rsSurrPair = "[\\ud800-\\udbff][\\udc00-\\udfff]", rsUpper = "[" + rsUpperRange + "]", rsZWJ = "\\u200d";
4824         var rsMiscLower = "(?:" + rsLower + "|" + rsMisc + ")", rsMiscUpper = "(?:" + rsUpper + "|" + rsMisc + ")", rsOptContrLower = "(?:" + rsApos + "(?:d|ll|m|re|s|t|ve))?", rsOptContrUpper = "(?:" + rsApos + "(?:D|LL|M|RE|S|T|VE))?", reOptMod = rsModifier + "?", rsOptVar = "[" + rsVarRange + "]?", rsOptJoin = "(?:" + rsZWJ + "(?:" + [rsNonAstral, rsRegional, rsSurrPair].join("|") + ")" + rsOptVar + reOptMod + ")*", rsOrdLower = "\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])", rsOrdUpper = "\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])", rsSeq = rsOptVar + reOptMod + rsOptJoin, rsEmoji = "(?:" + [rsDingbat, rsRegional, rsSurrPair].join("|") + ")" + rsSeq, rsSymbol = "(?:" + [rsNonAstral + rsCombo + "?", rsCombo, rsRegional, rsSurrPair, rsAstral].join("|") + ")";
4825         var reApos = RegExp(rsApos, "g");
4826         var reComboMark = RegExp(rsCombo, "g");
4827         var reUnicode = RegExp(rsFitz + "(?=" + rsFitz + ")|" + rsSymbol + rsSeq, "g");
4828         var reUnicodeWord = RegExp([
4829           rsUpper + "?" + rsLower + "+" + rsOptContrLower + "(?=" + [rsBreak, rsUpper, "$"].join("|") + ")",
4830           rsMiscUpper + "+" + rsOptContrUpper + "(?=" + [rsBreak, rsUpper + rsMiscLower, "$"].join("|") + ")",
4831           rsUpper + "?" + rsMiscLower + "+" + rsOptContrLower,
4832           rsUpper + "+" + rsOptContrUpper,
4833           rsOrdUpper,
4834           rsOrdLower,
4835           rsDigits,
4836           rsEmoji
4837         ].join("|"), "g");
4838         var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + "]");
4839         var reHasUnicodeWord = /[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;
4840         var contextProps = [
4841           "Array",
4842           "Buffer",
4843           "DataView",
4844           "Date",
4845           "Error",
4846           "Float32Array",
4847           "Float64Array",
4848           "Function",
4849           "Int8Array",
4850           "Int16Array",
4851           "Int32Array",
4852           "Map",
4853           "Math",
4854           "Object",
4855           "Promise",
4856           "RegExp",
4857           "Set",
4858           "String",
4859           "Symbol",
4860           "TypeError",
4861           "Uint8Array",
4862           "Uint8ClampedArray",
4863           "Uint16Array",
4864           "Uint32Array",
4865           "WeakMap",
4866           "_",
4867           "clearTimeout",
4868           "isFinite",
4869           "parseInt",
4870           "setTimeout"
4871         ];
4872         var templateCounter = -1;
4873         var typedArrayTags2 = {};
4874         typedArrayTags2[float32Tag2] = typedArrayTags2[float64Tag2] = typedArrayTags2[int8Tag2] = typedArrayTags2[int16Tag2] = typedArrayTags2[int32Tag2] = typedArrayTags2[uint8Tag2] = typedArrayTags2[uint8ClampedTag2] = typedArrayTags2[uint16Tag2] = typedArrayTags2[uint32Tag2] = true;
4875         typedArrayTags2[argsTag4] = typedArrayTags2[arrayTag3] = typedArrayTags2[arrayBufferTag3] = typedArrayTags2[boolTag3] = typedArrayTags2[dataViewTag4] = typedArrayTags2[dateTag3] = typedArrayTags2[errorTag3] = typedArrayTags2[funcTag3] = typedArrayTags2[mapTag4] = typedArrayTags2[numberTag4] = typedArrayTags2[objectTag4] = typedArrayTags2[regexpTag3] = typedArrayTags2[setTag4] = typedArrayTags2[stringTag3] = typedArrayTags2[weakMapTag3] = false;
4876         var cloneableTags = {};
4877         cloneableTags[argsTag4] = cloneableTags[arrayTag3] = cloneableTags[arrayBufferTag3] = cloneableTags[dataViewTag4] = cloneableTags[boolTag3] = cloneableTags[dateTag3] = cloneableTags[float32Tag2] = cloneableTags[float64Tag2] = cloneableTags[int8Tag2] = cloneableTags[int16Tag2] = cloneableTags[int32Tag2] = cloneableTags[mapTag4] = cloneableTags[numberTag4] = cloneableTags[objectTag4] = cloneableTags[regexpTag3] = cloneableTags[setTag4] = cloneableTags[stringTag3] = cloneableTags[symbolTag3] = cloneableTags[uint8Tag2] = cloneableTags[uint8ClampedTag2] = cloneableTags[uint16Tag2] = cloneableTags[uint32Tag2] = true;
4878         cloneableTags[errorTag3] = cloneableTags[funcTag3] = cloneableTags[weakMapTag3] = false;
4879         var deburredLetters = {
4880           // Latin-1 Supplement block.
4881           "\xC0": "A",
4882           "\xC1": "A",
4883           "\xC2": "A",
4884           "\xC3": "A",
4885           "\xC4": "A",
4886           "\xC5": "A",
4887           "\xE0": "a",
4888           "\xE1": "a",
4889           "\xE2": "a",
4890           "\xE3": "a",
4891           "\xE4": "a",
4892           "\xE5": "a",
4893           "\xC7": "C",
4894           "\xE7": "c",
4895           "\xD0": "D",
4896           "\xF0": "d",
4897           "\xC8": "E",
4898           "\xC9": "E",
4899           "\xCA": "E",
4900           "\xCB": "E",
4901           "\xE8": "e",
4902           "\xE9": "e",
4903           "\xEA": "e",
4904           "\xEB": "e",
4905           "\xCC": "I",
4906           "\xCD": "I",
4907           "\xCE": "I",
4908           "\xCF": "I",
4909           "\xEC": "i",
4910           "\xED": "i",
4911           "\xEE": "i",
4912           "\xEF": "i",
4913           "\xD1": "N",
4914           "\xF1": "n",
4915           "\xD2": "O",
4916           "\xD3": "O",
4917           "\xD4": "O",
4918           "\xD5": "O",
4919           "\xD6": "O",
4920           "\xD8": "O",
4921           "\xF2": "o",
4922           "\xF3": "o",
4923           "\xF4": "o",
4924           "\xF5": "o",
4925           "\xF6": "o",
4926           "\xF8": "o",
4927           "\xD9": "U",
4928           "\xDA": "U",
4929           "\xDB": "U",
4930           "\xDC": "U",
4931           "\xF9": "u",
4932           "\xFA": "u",
4933           "\xFB": "u",
4934           "\xFC": "u",
4935           "\xDD": "Y",
4936           "\xFD": "y",
4937           "\xFF": "y",
4938           "\xC6": "Ae",
4939           "\xE6": "ae",
4940           "\xDE": "Th",
4941           "\xFE": "th",
4942           "\xDF": "ss",
4943           // Latin Extended-A block.
4944           "\u0100": "A",
4945           "\u0102": "A",
4946           "\u0104": "A",
4947           "\u0101": "a",
4948           "\u0103": "a",
4949           "\u0105": "a",
4950           "\u0106": "C",
4951           "\u0108": "C",
4952           "\u010A": "C",
4953           "\u010C": "C",
4954           "\u0107": "c",
4955           "\u0109": "c",
4956           "\u010B": "c",
4957           "\u010D": "c",
4958           "\u010E": "D",
4959           "\u0110": "D",
4960           "\u010F": "d",
4961           "\u0111": "d",
4962           "\u0112": "E",
4963           "\u0114": "E",
4964           "\u0116": "E",
4965           "\u0118": "E",
4966           "\u011A": "E",
4967           "\u0113": "e",
4968           "\u0115": "e",
4969           "\u0117": "e",
4970           "\u0119": "e",
4971           "\u011B": "e",
4972           "\u011C": "G",
4973           "\u011E": "G",
4974           "\u0120": "G",
4975           "\u0122": "G",
4976           "\u011D": "g",
4977           "\u011F": "g",
4978           "\u0121": "g",
4979           "\u0123": "g",
4980           "\u0124": "H",
4981           "\u0126": "H",
4982           "\u0125": "h",
4983           "\u0127": "h",
4984           "\u0128": "I",
4985           "\u012A": "I",
4986           "\u012C": "I",
4987           "\u012E": "I",
4988           "\u0130": "I",
4989           "\u0129": "i",
4990           "\u012B": "i",
4991           "\u012D": "i",
4992           "\u012F": "i",
4993           "\u0131": "i",
4994           "\u0134": "J",
4995           "\u0135": "j",
4996           "\u0136": "K",
4997           "\u0137": "k",
4998           "\u0138": "k",
4999           "\u0139": "L",
5000           "\u013B": "L",
5001           "\u013D": "L",
5002           "\u013F": "L",
5003           "\u0141": "L",
5004           "\u013A": "l",
5005           "\u013C": "l",
5006           "\u013E": "l",
5007           "\u0140": "l",
5008           "\u0142": "l",
5009           "\u0143": "N",
5010           "\u0145": "N",
5011           "\u0147": "N",
5012           "\u014A": "N",
5013           "\u0144": "n",
5014           "\u0146": "n",
5015           "\u0148": "n",
5016           "\u014B": "n",
5017           "\u014C": "O",
5018           "\u014E": "O",
5019           "\u0150": "O",
5020           "\u014D": "o",
5021           "\u014F": "o",
5022           "\u0151": "o",
5023           "\u0154": "R",
5024           "\u0156": "R",
5025           "\u0158": "R",
5026           "\u0155": "r",
5027           "\u0157": "r",
5028           "\u0159": "r",
5029           "\u015A": "S",
5030           "\u015C": "S",
5031           "\u015E": "S",
5032           "\u0160": "S",
5033           "\u015B": "s",
5034           "\u015D": "s",
5035           "\u015F": "s",
5036           "\u0161": "s",
5037           "\u0162": "T",
5038           "\u0164": "T",
5039           "\u0166": "T",
5040           "\u0163": "t",
5041           "\u0165": "t",
5042           "\u0167": "t",
5043           "\u0168": "U",
5044           "\u016A": "U",
5045           "\u016C": "U",
5046           "\u016E": "U",
5047           "\u0170": "U",
5048           "\u0172": "U",
5049           "\u0169": "u",
5050           "\u016B": "u",
5051           "\u016D": "u",
5052           "\u016F": "u",
5053           "\u0171": "u",
5054           "\u0173": "u",
5055           "\u0174": "W",
5056           "\u0175": "w",
5057           "\u0176": "Y",
5058           "\u0177": "y",
5059           "\u0178": "Y",
5060           "\u0179": "Z",
5061           "\u017B": "Z",
5062           "\u017D": "Z",
5063           "\u017A": "z",
5064           "\u017C": "z",
5065           "\u017E": "z",
5066           "\u0132": "IJ",
5067           "\u0133": "ij",
5068           "\u0152": "Oe",
5069           "\u0153": "oe",
5070           "\u0149": "'n",
5071           "\u017F": "s"
5072         };
5073         var htmlEscapes2 = {
5074           "&": "&amp;",
5075           "<": "&lt;",
5076           ">": "&gt;",
5077           '"': "&quot;",
5078           "'": "&#39;"
5079         };
5080         var htmlUnescapes2 = {
5081           "&amp;": "&",
5082           "&lt;": "<",
5083           "&gt;": ">",
5084           "&quot;": '"',
5085           "&#39;": "'"
5086         };
5087         var stringEscapes = {
5088           "\\": "\\",
5089           "'": "'",
5090           "\n": "n",
5091           "\r": "r",
5092           "\u2028": "u2028",
5093           "\u2029": "u2029"
5094         };
5095         var freeParseFloat = parseFloat, freeParseInt2 = parseInt;
5096         var freeGlobal2 = typeof global == "object" && global && global.Object === Object && global;
5097         var freeSelf2 = typeof self == "object" && self && self.Object === Object && self;
5098         var root3 = freeGlobal2 || freeSelf2 || Function("return this")();
5099         var freeExports3 = typeof exports2 == "object" && exports2 && !exports2.nodeType && exports2;
5100         var freeModule3 = freeExports3 && typeof module2 == "object" && module2 && !module2.nodeType && module2;
5101         var moduleExports3 = freeModule3 && freeModule3.exports === freeExports3;
5102         var freeProcess2 = moduleExports3 && freeGlobal2.process;
5103         var nodeUtil2 = function() {
5104           try {
5105             var types = freeModule3 && freeModule3.require && freeModule3.require("util").types;
5106             if (types) {
5107               return types;
5108             }
5109             return freeProcess2 && freeProcess2.binding && freeProcess2.binding("util");
5110           } catch (e3) {
5111           }
5112         }();
5113         var nodeIsArrayBuffer = nodeUtil2 && nodeUtil2.isArrayBuffer, nodeIsDate = nodeUtil2 && nodeUtil2.isDate, nodeIsMap = nodeUtil2 && nodeUtil2.isMap, nodeIsRegExp = nodeUtil2 && nodeUtil2.isRegExp, nodeIsSet = nodeUtil2 && nodeUtil2.isSet, nodeIsTypedArray2 = nodeUtil2 && nodeUtil2.isTypedArray;
5114         function apply(func, thisArg, args) {
5115           switch (args.length) {
5116             case 0:
5117               return func.call(thisArg);
5118             case 1:
5119               return func.call(thisArg, args[0]);
5120             case 2:
5121               return func.call(thisArg, args[0], args[1]);
5122             case 3:
5123               return func.call(thisArg, args[0], args[1], args[2]);
5124           }
5125           return func.apply(thisArg, args);
5126         }
5127         function arrayAggregator(array2, setter, iteratee, accumulator) {
5128           var index = -1, length2 = array2 == null ? 0 : array2.length;
5129           while (++index < length2) {
5130             var value = array2[index];
5131             setter(accumulator, value, iteratee(value), array2);
5132           }
5133           return accumulator;
5134         }
5135         function arrayEach(array2, iteratee) {
5136           var index = -1, length2 = array2 == null ? 0 : array2.length;
5137           while (++index < length2) {
5138             if (iteratee(array2[index], index, array2) === false) {
5139               break;
5140             }
5141           }
5142           return array2;
5143         }
5144         function arrayEachRight(array2, iteratee) {
5145           var length2 = array2 == null ? 0 : array2.length;
5146           while (length2--) {
5147             if (iteratee(array2[length2], length2, array2) === false) {
5148               break;
5149             }
5150           }
5151           return array2;
5152         }
5153         function arrayEvery(array2, predicate) {
5154           var index = -1, length2 = array2 == null ? 0 : array2.length;
5155           while (++index < length2) {
5156             if (!predicate(array2[index], index, array2)) {
5157               return false;
5158             }
5159           }
5160           return true;
5161         }
5162         function arrayFilter2(array2, predicate) {
5163           var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
5164           while (++index < length2) {
5165             var value = array2[index];
5166             if (predicate(value, index, array2)) {
5167               result[resIndex++] = value;
5168             }
5169           }
5170           return result;
5171         }
5172         function arrayIncludes(array2, value) {
5173           var length2 = array2 == null ? 0 : array2.length;
5174           return !!length2 && baseIndexOf(array2, value, 0) > -1;
5175         }
5176         function arrayIncludesWith(array2, value, comparator) {
5177           var index = -1, length2 = array2 == null ? 0 : array2.length;
5178           while (++index < length2) {
5179             if (comparator(value, array2[index])) {
5180               return true;
5181             }
5182           }
5183           return false;
5184         }
5185         function arrayMap2(array2, iteratee) {
5186           var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2);
5187           while (++index < length2) {
5188             result[index] = iteratee(array2[index], index, array2);
5189           }
5190           return result;
5191         }
5192         function arrayPush2(array2, values) {
5193           var index = -1, length2 = values.length, offset = array2.length;
5194           while (++index < length2) {
5195             array2[offset + index] = values[index];
5196           }
5197           return array2;
5198         }
5199         function arrayReduce(array2, iteratee, accumulator, initAccum) {
5200           var index = -1, length2 = array2 == null ? 0 : array2.length;
5201           if (initAccum && length2) {
5202             accumulator = array2[++index];
5203           }
5204           while (++index < length2) {
5205             accumulator = iteratee(accumulator, array2[index], index, array2);
5206           }
5207           return accumulator;
5208         }
5209         function arrayReduceRight(array2, iteratee, accumulator, initAccum) {
5210           var length2 = array2 == null ? 0 : array2.length;
5211           if (initAccum && length2) {
5212             accumulator = array2[--length2];
5213           }
5214           while (length2--) {
5215             accumulator = iteratee(accumulator, array2[length2], length2, array2);
5216           }
5217           return accumulator;
5218         }
5219         function arraySome2(array2, predicate) {
5220           var index = -1, length2 = array2 == null ? 0 : array2.length;
5221           while (++index < length2) {
5222             if (predicate(array2[index], index, array2)) {
5223               return true;
5224             }
5225           }
5226           return false;
5227         }
5228         var asciiSize = baseProperty("length");
5229         function asciiToArray(string) {
5230           return string.split("");
5231         }
5232         function asciiWords(string) {
5233           return string.match(reAsciiWord) || [];
5234         }
5235         function baseFindKey(collection, predicate, eachFunc) {
5236           var result;
5237           eachFunc(collection, function(value, key, collection2) {
5238             if (predicate(value, key, collection2)) {
5239               result = key;
5240               return false;
5241             }
5242           });
5243           return result;
5244         }
5245         function baseFindIndex(array2, predicate, fromIndex, fromRight) {
5246           var length2 = array2.length, index = fromIndex + (fromRight ? 1 : -1);
5247           while (fromRight ? index-- : ++index < length2) {
5248             if (predicate(array2[index], index, array2)) {
5249               return index;
5250             }
5251           }
5252           return -1;
5253         }
5254         function baseIndexOf(array2, value, fromIndex) {
5255           return value === value ? strictIndexOf(array2, value, fromIndex) : baseFindIndex(array2, baseIsNaN, fromIndex);
5256         }
5257         function baseIndexOfWith(array2, value, fromIndex, comparator) {
5258           var index = fromIndex - 1, length2 = array2.length;
5259           while (++index < length2) {
5260             if (comparator(array2[index], value)) {
5261               return index;
5262             }
5263           }
5264           return -1;
5265         }
5266         function baseIsNaN(value) {
5267           return value !== value;
5268         }
5269         function baseMean(array2, iteratee) {
5270           var length2 = array2 == null ? 0 : array2.length;
5271           return length2 ? baseSum(array2, iteratee) / length2 : NAN2;
5272         }
5273         function baseProperty(key) {
5274           return function(object) {
5275             return object == null ? undefined2 : object[key];
5276           };
5277         }
5278         function basePropertyOf2(object) {
5279           return function(key) {
5280             return object == null ? undefined2 : object[key];
5281           };
5282         }
5283         function baseReduce(collection, iteratee, accumulator, initAccum, eachFunc) {
5284           eachFunc(collection, function(value, index, collection2) {
5285             accumulator = initAccum ? (initAccum = false, value) : iteratee(accumulator, value, index, collection2);
5286           });
5287           return accumulator;
5288         }
5289         function baseSortBy(array2, comparer) {
5290           var length2 = array2.length;
5291           array2.sort(comparer);
5292           while (length2--) {
5293             array2[length2] = array2[length2].value;
5294           }
5295           return array2;
5296         }
5297         function baseSum(array2, iteratee) {
5298           var result, index = -1, length2 = array2.length;
5299           while (++index < length2) {
5300             var current = iteratee(array2[index]);
5301             if (current !== undefined2) {
5302               result = result === undefined2 ? current : result + current;
5303             }
5304           }
5305           return result;
5306         }
5307         function baseTimes2(n3, iteratee) {
5308           var index = -1, result = Array(n3);
5309           while (++index < n3) {
5310             result[index] = iteratee(index);
5311           }
5312           return result;
5313         }
5314         function baseToPairs(object, props) {
5315           return arrayMap2(props, function(key) {
5316             return [key, object[key]];
5317           });
5318         }
5319         function baseTrim2(string) {
5320           return string ? string.slice(0, trimmedEndIndex2(string) + 1).replace(reTrimStart2, "") : string;
5321         }
5322         function baseUnary2(func) {
5323           return function(value) {
5324             return func(value);
5325           };
5326         }
5327         function baseValues(object, props) {
5328           return arrayMap2(props, function(key) {
5329             return object[key];
5330           });
5331         }
5332         function cacheHas2(cache, key) {
5333           return cache.has(key);
5334         }
5335         function charsStartIndex(strSymbols, chrSymbols) {
5336           var index = -1, length2 = strSymbols.length;
5337           while (++index < length2 && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {
5338           }
5339           return index;
5340         }
5341         function charsEndIndex(strSymbols, chrSymbols) {
5342           var index = strSymbols.length;
5343           while (index-- && baseIndexOf(chrSymbols, strSymbols[index], 0) > -1) {
5344           }
5345           return index;
5346         }
5347         function countHolders(array2, placeholder) {
5348           var length2 = array2.length, result = 0;
5349           while (length2--) {
5350             if (array2[length2] === placeholder) {
5351               ++result;
5352             }
5353           }
5354           return result;
5355         }
5356         var deburrLetter = basePropertyOf2(deburredLetters);
5357         var escapeHtmlChar2 = basePropertyOf2(htmlEscapes2);
5358         function escapeStringChar(chr) {
5359           return "\\" + stringEscapes[chr];
5360         }
5361         function getValue2(object, key) {
5362           return object == null ? undefined2 : object[key];
5363         }
5364         function hasUnicode(string) {
5365           return reHasUnicode.test(string);
5366         }
5367         function hasUnicodeWord(string) {
5368           return reHasUnicodeWord.test(string);
5369         }
5370         function iteratorToArray(iterator) {
5371           var data, result = [];
5372           while (!(data = iterator.next()).done) {
5373             result.push(data.value);
5374           }
5375           return result;
5376         }
5377         function mapToArray2(map2) {
5378           var index = -1, result = Array(map2.size);
5379           map2.forEach(function(value, key) {
5380             result[++index] = [key, value];
5381           });
5382           return result;
5383         }
5384         function overArg2(func, transform2) {
5385           return function(arg) {
5386             return func(transform2(arg));
5387           };
5388         }
5389         function replaceHolders(array2, placeholder) {
5390           var index = -1, length2 = array2.length, resIndex = 0, result = [];
5391           while (++index < length2) {
5392             var value = array2[index];
5393             if (value === placeholder || value === PLACEHOLDER) {
5394               array2[index] = PLACEHOLDER;
5395               result[resIndex++] = index;
5396             }
5397           }
5398           return result;
5399         }
5400         function setToArray2(set4) {
5401           var index = -1, result = Array(set4.size);
5402           set4.forEach(function(value) {
5403             result[++index] = value;
5404           });
5405           return result;
5406         }
5407         function setToPairs(set4) {
5408           var index = -1, result = Array(set4.size);
5409           set4.forEach(function(value) {
5410             result[++index] = [value, value];
5411           });
5412           return result;
5413         }
5414         function strictIndexOf(array2, value, fromIndex) {
5415           var index = fromIndex - 1, length2 = array2.length;
5416           while (++index < length2) {
5417             if (array2[index] === value) {
5418               return index;
5419             }
5420           }
5421           return -1;
5422         }
5423         function strictLastIndexOf(array2, value, fromIndex) {
5424           var index = fromIndex + 1;
5425           while (index--) {
5426             if (array2[index] === value) {
5427               return index;
5428             }
5429           }
5430           return index;
5431         }
5432         function stringSize(string) {
5433           return hasUnicode(string) ? unicodeSize(string) : asciiSize(string);
5434         }
5435         function stringToArray(string) {
5436           return hasUnicode(string) ? unicodeToArray(string) : asciiToArray(string);
5437         }
5438         function trimmedEndIndex2(string) {
5439           var index = string.length;
5440           while (index-- && reWhitespace2.test(string.charAt(index))) {
5441           }
5442           return index;
5443         }
5444         var unescapeHtmlChar2 = basePropertyOf2(htmlUnescapes2);
5445         function unicodeSize(string) {
5446           var result = reUnicode.lastIndex = 0;
5447           while (reUnicode.test(string)) {
5448             ++result;
5449           }
5450           return result;
5451         }
5452         function unicodeToArray(string) {
5453           return string.match(reUnicode) || [];
5454         }
5455         function unicodeWords(string) {
5456           return string.match(reUnicodeWord) || [];
5457         }
5458         var runInContext = function runInContext2(context) {
5459           context = context == null ? root3 : _2.defaults(root3.Object(), context, _2.pick(root3, contextProps));
5460           var Array2 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String2 = context.String, TypeError2 = context.TypeError;
5461           var arrayProto2 = Array2.prototype, funcProto3 = Function2.prototype, objectProto13 = Object2.prototype;
5462           var coreJsData2 = context["__core-js_shared__"];
5463           var funcToString3 = funcProto3.toString;
5464           var hasOwnProperty10 = objectProto13.hasOwnProperty;
5465           var idCounter = 0;
5466           var maskSrcKey2 = function() {
5467             var uid = /[^.]+$/.exec(coreJsData2 && coreJsData2.keys && coreJsData2.keys.IE_PROTO || "");
5468             return uid ? "Symbol(src)_1." + uid : "";
5469           }();
5470           var nativeObjectToString3 = objectProto13.toString;
5471           var objectCtorString = funcToString3.call(Object2);
5472           var oldDash = root3._;
5473           var reIsNative2 = RegExp2(
5474             "^" + funcToString3.call(hasOwnProperty10).replace(reRegExpChar2, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
5475           );
5476           var Buffer3 = moduleExports3 ? context.Buffer : undefined2, Symbol3 = context.Symbol, Uint8Array3 = context.Uint8Array, allocUnsafe = Buffer3 ? Buffer3.allocUnsafe : undefined2, getPrototype = overArg2(Object2.getPrototypeOf, Object2), objectCreate = Object2.create, propertyIsEnumerable3 = objectProto13.propertyIsEnumerable, splice2 = arrayProto2.splice, spreadableSymbol = Symbol3 ? Symbol3.isConcatSpreadable : undefined2, symIterator = Symbol3 ? Symbol3.iterator : undefined2, symToStringTag3 = Symbol3 ? Symbol3.toStringTag : undefined2;
5477           var defineProperty = function() {
5478             try {
5479               var func = getNative2(Object2, "defineProperty");
5480               func({}, "", {});
5481               return func;
5482             } catch (e3) {
5483             }
5484           }();
5485           var ctxClearTimeout = context.clearTimeout !== root3.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root3.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root3.setTimeout && context.setTimeout;
5486           var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols2 = Object2.getOwnPropertySymbols, nativeIsBuffer2 = Buffer3 ? Buffer3.isBuffer : undefined2, nativeIsFinite = context.isFinite, nativeJoin = arrayProto2.join, nativeKeys2 = overArg2(Object2.keys, Object2), nativeMax2 = Math2.max, nativeMin2 = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto2.reverse;
5487           var DataView3 = getNative2(context, "DataView"), Map3 = getNative2(context, "Map"), Promise3 = getNative2(context, "Promise"), Set3 = getNative2(context, "Set"), WeakMap2 = getNative2(context, "WeakMap"), nativeCreate2 = getNative2(Object2, "create");
5488           var metaMap = WeakMap2 && new WeakMap2();
5489           var realNames = {};
5490           var dataViewCtorString2 = toSource2(DataView3), mapCtorString2 = toSource2(Map3), promiseCtorString2 = toSource2(Promise3), setCtorString2 = toSource2(Set3), weakMapCtorString2 = toSource2(WeakMap2);
5491           var symbolProto3 = Symbol3 ? Symbol3.prototype : undefined2, symbolValueOf2 = symbolProto3 ? symbolProto3.valueOf : undefined2, symbolToString2 = symbolProto3 ? symbolProto3.toString : undefined2;
5492           function lodash(value) {
5493             if (isObjectLike2(value) && !isArray2(value) && !(value instanceof LazyWrapper)) {
5494               if (value instanceof LodashWrapper) {
5495                 return value;
5496               }
5497               if (hasOwnProperty10.call(value, "__wrapped__")) {
5498                 return wrapperClone(value);
5499               }
5500             }
5501             return new LodashWrapper(value);
5502           }
5503           var baseCreate = /* @__PURE__ */ function() {
5504             function object() {
5505             }
5506             return function(proto) {
5507               if (!isObject3(proto)) {
5508                 return {};
5509               }
5510               if (objectCreate) {
5511                 return objectCreate(proto);
5512               }
5513               object.prototype = proto;
5514               var result2 = new object();
5515               object.prototype = undefined2;
5516               return result2;
5517             };
5518           }();
5519           function baseLodash() {
5520           }
5521           function LodashWrapper(value, chainAll) {
5522             this.__wrapped__ = value;
5523             this.__actions__ = [];
5524             this.__chain__ = !!chainAll;
5525             this.__index__ = 0;
5526             this.__values__ = undefined2;
5527           }
5528           lodash.templateSettings = {
5529             /**
5530              * Used to detect `data` property values to be HTML-escaped.
5531              *
5532              * @memberOf _.templateSettings
5533              * @type {RegExp}
5534              */
5535             "escape": reEscape,
5536             /**
5537              * Used to detect code to be evaluated.
5538              *
5539              * @memberOf _.templateSettings
5540              * @type {RegExp}
5541              */
5542             "evaluate": reEvaluate,
5543             /**
5544              * Used to detect `data` property values to inject.
5545              *
5546              * @memberOf _.templateSettings
5547              * @type {RegExp}
5548              */
5549             "interpolate": reInterpolate,
5550             /**
5551              * Used to reference the data object in the template text.
5552              *
5553              * @memberOf _.templateSettings
5554              * @type {string}
5555              */
5556             "variable": "",
5557             /**
5558              * Used to import variables into the compiled template.
5559              *
5560              * @memberOf _.templateSettings
5561              * @type {Object}
5562              */
5563             "imports": {
5564               /**
5565                * A reference to the `lodash` function.
5566                *
5567                * @memberOf _.templateSettings.imports
5568                * @type {Function}
5569                */
5570               "_": lodash
5571             }
5572           };
5573           lodash.prototype = baseLodash.prototype;
5574           lodash.prototype.constructor = lodash;
5575           LodashWrapper.prototype = baseCreate(baseLodash.prototype);
5576           LodashWrapper.prototype.constructor = LodashWrapper;
5577           function LazyWrapper(value) {
5578             this.__wrapped__ = value;
5579             this.__actions__ = [];
5580             this.__dir__ = 1;
5581             this.__filtered__ = false;
5582             this.__iteratees__ = [];
5583             this.__takeCount__ = MAX_ARRAY_LENGTH;
5584             this.__views__ = [];
5585           }
5586           function lazyClone() {
5587             var result2 = new LazyWrapper(this.__wrapped__);
5588             result2.__actions__ = copyArray(this.__actions__);
5589             result2.__dir__ = this.__dir__;
5590             result2.__filtered__ = this.__filtered__;
5591             result2.__iteratees__ = copyArray(this.__iteratees__);
5592             result2.__takeCount__ = this.__takeCount__;
5593             result2.__views__ = copyArray(this.__views__);
5594             return result2;
5595           }
5596           function lazyReverse() {
5597             if (this.__filtered__) {
5598               var result2 = new LazyWrapper(this);
5599               result2.__dir__ = -1;
5600               result2.__filtered__ = true;
5601             } else {
5602               result2 = this.clone();
5603               result2.__dir__ *= -1;
5604             }
5605             return result2;
5606           }
5607           function lazyValue() {
5608             var array2 = this.__wrapped__.value(), dir = this.__dir__, isArr = isArray2(array2), isRight = dir < 0, arrLength = isArr ? array2.length : 0, view = getView(0, arrLength, this.__views__), start2 = view.start, end = view.end, length2 = end - start2, index = isRight ? end : start2 - 1, iteratees = this.__iteratees__, iterLength = iteratees.length, resIndex = 0, takeCount = nativeMin2(length2, this.__takeCount__);
5609             if (!isArr || !isRight && arrLength == length2 && takeCount == length2) {
5610               return baseWrapperValue(array2, this.__actions__);
5611             }
5612             var result2 = [];
5613             outer:
5614               while (length2-- && resIndex < takeCount) {
5615                 index += dir;
5616                 var iterIndex = -1, value = array2[index];
5617                 while (++iterIndex < iterLength) {
5618                   var data = iteratees[iterIndex], iteratee2 = data.iteratee, type2 = data.type, computed = iteratee2(value);
5619                   if (type2 == LAZY_MAP_FLAG) {
5620                     value = computed;
5621                   } else if (!computed) {
5622                     if (type2 == LAZY_FILTER_FLAG) {
5623                       continue outer;
5624                     } else {
5625                       break outer;
5626                     }
5627                   }
5628                 }
5629                 result2[resIndex++] = value;
5630               }
5631             return result2;
5632           }
5633           LazyWrapper.prototype = baseCreate(baseLodash.prototype);
5634           LazyWrapper.prototype.constructor = LazyWrapper;
5635           function Hash2(entries) {
5636             var index = -1, length2 = entries == null ? 0 : entries.length;
5637             this.clear();
5638             while (++index < length2) {
5639               var entry = entries[index];
5640               this.set(entry[0], entry[1]);
5641             }
5642           }
5643           function hashClear2() {
5644             this.__data__ = nativeCreate2 ? nativeCreate2(null) : {};
5645             this.size = 0;
5646           }
5647           function hashDelete2(key) {
5648             var result2 = this.has(key) && delete this.__data__[key];
5649             this.size -= result2 ? 1 : 0;
5650             return result2;
5651           }
5652           function hashGet2(key) {
5653             var data = this.__data__;
5654             if (nativeCreate2) {
5655               var result2 = data[key];
5656               return result2 === HASH_UNDEFINED4 ? undefined2 : result2;
5657             }
5658             return hasOwnProperty10.call(data, key) ? data[key] : undefined2;
5659           }
5660           function hashHas2(key) {
5661             var data = this.__data__;
5662             return nativeCreate2 ? data[key] !== undefined2 : hasOwnProperty10.call(data, key);
5663           }
5664           function hashSet2(key, value) {
5665             var data = this.__data__;
5666             this.size += this.has(key) ? 0 : 1;
5667             data[key] = nativeCreate2 && value === undefined2 ? HASH_UNDEFINED4 : value;
5668             return this;
5669           }
5670           Hash2.prototype.clear = hashClear2;
5671           Hash2.prototype["delete"] = hashDelete2;
5672           Hash2.prototype.get = hashGet2;
5673           Hash2.prototype.has = hashHas2;
5674           Hash2.prototype.set = hashSet2;
5675           function ListCache2(entries) {
5676             var index = -1, length2 = entries == null ? 0 : entries.length;
5677             this.clear();
5678             while (++index < length2) {
5679               var entry = entries[index];
5680               this.set(entry[0], entry[1]);
5681             }
5682           }
5683           function listCacheClear2() {
5684             this.__data__ = [];
5685             this.size = 0;
5686           }
5687           function listCacheDelete2(key) {
5688             var data = this.__data__, index = assocIndexOf2(data, key);
5689             if (index < 0) {
5690               return false;
5691             }
5692             var lastIndex = data.length - 1;
5693             if (index == lastIndex) {
5694               data.pop();
5695             } else {
5696               splice2.call(data, index, 1);
5697             }
5698             --this.size;
5699             return true;
5700           }
5701           function listCacheGet2(key) {
5702             var data = this.__data__, index = assocIndexOf2(data, key);
5703             return index < 0 ? undefined2 : data[index][1];
5704           }
5705           function listCacheHas2(key) {
5706             return assocIndexOf2(this.__data__, key) > -1;
5707           }
5708           function listCacheSet2(key, value) {
5709             var data = this.__data__, index = assocIndexOf2(data, key);
5710             if (index < 0) {
5711               ++this.size;
5712               data.push([key, value]);
5713             } else {
5714               data[index][1] = value;
5715             }
5716             return this;
5717           }
5718           ListCache2.prototype.clear = listCacheClear2;
5719           ListCache2.prototype["delete"] = listCacheDelete2;
5720           ListCache2.prototype.get = listCacheGet2;
5721           ListCache2.prototype.has = listCacheHas2;
5722           ListCache2.prototype.set = listCacheSet2;
5723           function MapCache2(entries) {
5724             var index = -1, length2 = entries == null ? 0 : entries.length;
5725             this.clear();
5726             while (++index < length2) {
5727               var entry = entries[index];
5728               this.set(entry[0], entry[1]);
5729             }
5730           }
5731           function mapCacheClear2() {
5732             this.size = 0;
5733             this.__data__ = {
5734               "hash": new Hash2(),
5735               "map": new (Map3 || ListCache2)(),
5736               "string": new Hash2()
5737             };
5738           }
5739           function mapCacheDelete2(key) {
5740             var result2 = getMapData2(this, key)["delete"](key);
5741             this.size -= result2 ? 1 : 0;
5742             return result2;
5743           }
5744           function mapCacheGet2(key) {
5745             return getMapData2(this, key).get(key);
5746           }
5747           function mapCacheHas2(key) {
5748             return getMapData2(this, key).has(key);
5749           }
5750           function mapCacheSet2(key, value) {
5751             var data = getMapData2(this, key), size2 = data.size;
5752             data.set(key, value);
5753             this.size += data.size == size2 ? 0 : 1;
5754             return this;
5755           }
5756           MapCache2.prototype.clear = mapCacheClear2;
5757           MapCache2.prototype["delete"] = mapCacheDelete2;
5758           MapCache2.prototype.get = mapCacheGet2;
5759           MapCache2.prototype.has = mapCacheHas2;
5760           MapCache2.prototype.set = mapCacheSet2;
5761           function SetCache2(values2) {
5762             var index = -1, length2 = values2 == null ? 0 : values2.length;
5763             this.__data__ = new MapCache2();
5764             while (++index < length2) {
5765               this.add(values2[index]);
5766             }
5767           }
5768           function setCacheAdd2(value) {
5769             this.__data__.set(value, HASH_UNDEFINED4);
5770             return this;
5771           }
5772           function setCacheHas2(value) {
5773             return this.__data__.has(value);
5774           }
5775           SetCache2.prototype.add = SetCache2.prototype.push = setCacheAdd2;
5776           SetCache2.prototype.has = setCacheHas2;
5777           function Stack2(entries) {
5778             var data = this.__data__ = new ListCache2(entries);
5779             this.size = data.size;
5780           }
5781           function stackClear2() {
5782             this.__data__ = new ListCache2();
5783             this.size = 0;
5784           }
5785           function stackDelete2(key) {
5786             var data = this.__data__, result2 = data["delete"](key);
5787             this.size = data.size;
5788             return result2;
5789           }
5790           function stackGet2(key) {
5791             return this.__data__.get(key);
5792           }
5793           function stackHas2(key) {
5794             return this.__data__.has(key);
5795           }
5796           function stackSet2(key, value) {
5797             var data = this.__data__;
5798             if (data instanceof ListCache2) {
5799               var pairs2 = data.__data__;
5800               if (!Map3 || pairs2.length < LARGE_ARRAY_SIZE2 - 1) {
5801                 pairs2.push([key, value]);
5802                 this.size = ++data.size;
5803                 return this;
5804               }
5805               data = this.__data__ = new MapCache2(pairs2);
5806             }
5807             data.set(key, value);
5808             this.size = data.size;
5809             return this;
5810           }
5811           Stack2.prototype.clear = stackClear2;
5812           Stack2.prototype["delete"] = stackDelete2;
5813           Stack2.prototype.get = stackGet2;
5814           Stack2.prototype.has = stackHas2;
5815           Stack2.prototype.set = stackSet2;
5816           function arrayLikeKeys2(value, inherited) {
5817             var isArr = isArray2(value), isArg = !isArr && isArguments2(value), isBuff = !isArr && !isArg && isBuffer2(value), isType = !isArr && !isArg && !isBuff && isTypedArray2(value), skipIndexes = isArr || isArg || isBuff || isType, result2 = skipIndexes ? baseTimes2(value.length, String2) : [], length2 = result2.length;
5818             for (var key in value) {
5819               if ((inherited || hasOwnProperty10.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
5820               (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
5821               isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
5822               isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
5823               isIndex2(key, length2)))) {
5824                 result2.push(key);
5825               }
5826             }
5827             return result2;
5828           }
5829           function arraySample(array2) {
5830             var length2 = array2.length;
5831             return length2 ? array2[baseRandom(0, length2 - 1)] : undefined2;
5832           }
5833           function arraySampleSize(array2, n3) {
5834             return shuffleSelf(copyArray(array2), baseClamp(n3, 0, array2.length));
5835           }
5836           function arrayShuffle(array2) {
5837             return shuffleSelf(copyArray(array2));
5838           }
5839           function assignMergeValue(object, key, value) {
5840             if (value !== undefined2 && !eq2(object[key], value) || value === undefined2 && !(key in object)) {
5841               baseAssignValue(object, key, value);
5842             }
5843           }
5844           function assignValue(object, key, value) {
5845             var objValue = object[key];
5846             if (!(hasOwnProperty10.call(object, key) && eq2(objValue, value)) || value === undefined2 && !(key in object)) {
5847               baseAssignValue(object, key, value);
5848             }
5849           }
5850           function assocIndexOf2(array2, key) {
5851             var length2 = array2.length;
5852             while (length2--) {
5853               if (eq2(array2[length2][0], key)) {
5854                 return length2;
5855               }
5856             }
5857             return -1;
5858           }
5859           function baseAggregator(collection, setter, iteratee2, accumulator) {
5860             baseEach(collection, function(value, key, collection2) {
5861               setter(accumulator, value, iteratee2(value), collection2);
5862             });
5863             return accumulator;
5864           }
5865           function baseAssign(object, source) {
5866             return object && copyObject(source, keys2(source), object);
5867           }
5868           function baseAssignIn(object, source) {
5869             return object && copyObject(source, keysIn(source), object);
5870           }
5871           function baseAssignValue(object, key, value) {
5872             if (key == "__proto__" && defineProperty) {
5873               defineProperty(object, key, {
5874                 "configurable": true,
5875                 "enumerable": true,
5876                 "value": value,
5877                 "writable": true
5878               });
5879             } else {
5880               object[key] = value;
5881             }
5882           }
5883           function baseAt(object, paths) {
5884             var index = -1, length2 = paths.length, result2 = Array2(length2), skip = object == null;
5885             while (++index < length2) {
5886               result2[index] = skip ? undefined2 : get4(object, paths[index]);
5887             }
5888             return result2;
5889           }
5890           function baseClamp(number3, lower2, upper) {
5891             if (number3 === number3) {
5892               if (upper !== undefined2) {
5893                 number3 = number3 <= upper ? number3 : upper;
5894               }
5895               if (lower2 !== undefined2) {
5896                 number3 = number3 >= lower2 ? number3 : lower2;
5897               }
5898             }
5899             return number3;
5900           }
5901           function baseClone(value, bitmask, customizer, key, object, stack) {
5902             var result2, isDeep = bitmask & CLONE_DEEP_FLAG, isFlat = bitmask & CLONE_FLAT_FLAG, isFull = bitmask & CLONE_SYMBOLS_FLAG;
5903             if (customizer) {
5904               result2 = object ? customizer(value, key, object, stack) : customizer(value);
5905             }
5906             if (result2 !== undefined2) {
5907               return result2;
5908             }
5909             if (!isObject3(value)) {
5910               return value;
5911             }
5912             var isArr = isArray2(value);
5913             if (isArr) {
5914               result2 = initCloneArray(value);
5915               if (!isDeep) {
5916                 return copyArray(value, result2);
5917               }
5918             } else {
5919               var tag2 = getTag2(value), isFunc = tag2 == funcTag3 || tag2 == genTag2;
5920               if (isBuffer2(value)) {
5921                 return cloneBuffer(value, isDeep);
5922               }
5923               if (tag2 == objectTag4 || tag2 == argsTag4 || isFunc && !object) {
5924                 result2 = isFlat || isFunc ? {} : initCloneObject(value);
5925                 if (!isDeep) {
5926                   return isFlat ? copySymbolsIn(value, baseAssignIn(result2, value)) : copySymbols(value, baseAssign(result2, value));
5927                 }
5928               } else {
5929                 if (!cloneableTags[tag2]) {
5930                   return object ? value : {};
5931                 }
5932                 result2 = initCloneByTag(value, tag2, isDeep);
5933               }
5934             }
5935             stack || (stack = new Stack2());
5936             var stacked = stack.get(value);
5937             if (stacked) {
5938               return stacked;
5939             }
5940             stack.set(value, result2);
5941             if (isSet(value)) {
5942               value.forEach(function(subValue) {
5943                 result2.add(baseClone(subValue, bitmask, customizer, subValue, value, stack));
5944               });
5945             } else if (isMap(value)) {
5946               value.forEach(function(subValue, key2) {
5947                 result2.set(key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
5948               });
5949             }
5950             var keysFunc = isFull ? isFlat ? getAllKeysIn : getAllKeys2 : isFlat ? keysIn : keys2;
5951             var props = isArr ? undefined2 : keysFunc(value);
5952             arrayEach(props || value, function(subValue, key2) {
5953               if (props) {
5954                 key2 = subValue;
5955                 subValue = value[key2];
5956               }
5957               assignValue(result2, key2, baseClone(subValue, bitmask, customizer, key2, value, stack));
5958             });
5959             return result2;
5960           }
5961           function baseConforms(source) {
5962             var props = keys2(source);
5963             return function(object) {
5964               return baseConformsTo(object, source, props);
5965             };
5966           }
5967           function baseConformsTo(object, source, props) {
5968             var length2 = props.length;
5969             if (object == null) {
5970               return !length2;
5971             }
5972             object = Object2(object);
5973             while (length2--) {
5974               var key = props[length2], predicate = source[key], value = object[key];
5975               if (value === undefined2 && !(key in object) || !predicate(value)) {
5976                 return false;
5977               }
5978             }
5979             return true;
5980           }
5981           function baseDelay(func, wait, args) {
5982             if (typeof func != "function") {
5983               throw new TypeError2(FUNC_ERROR_TEXT3);
5984             }
5985             return setTimeout2(function() {
5986               func.apply(undefined2, args);
5987             }, wait);
5988           }
5989           function baseDifference(array2, values2, iteratee2, comparator) {
5990             var index = -1, includes2 = arrayIncludes, isCommon = true, length2 = array2.length, result2 = [], valuesLength = values2.length;
5991             if (!length2) {
5992               return result2;
5993             }
5994             if (iteratee2) {
5995               values2 = arrayMap2(values2, baseUnary2(iteratee2));
5996             }
5997             if (comparator) {
5998               includes2 = arrayIncludesWith;
5999               isCommon = false;
6000             } else if (values2.length >= LARGE_ARRAY_SIZE2) {
6001               includes2 = cacheHas2;
6002               isCommon = false;
6003               values2 = new SetCache2(values2);
6004             }
6005             outer:
6006               while (++index < length2) {
6007                 var value = array2[index], computed = iteratee2 == null ? value : iteratee2(value);
6008                 value = comparator || value !== 0 ? value : 0;
6009                 if (isCommon && computed === computed) {
6010                   var valuesIndex = valuesLength;
6011                   while (valuesIndex--) {
6012                     if (values2[valuesIndex] === computed) {
6013                       continue outer;
6014                     }
6015                   }
6016                   result2.push(value);
6017                 } else if (!includes2(values2, computed, comparator)) {
6018                   result2.push(value);
6019                 }
6020               }
6021             return result2;
6022           }
6023           var baseEach = createBaseEach(baseForOwn);
6024           var baseEachRight = createBaseEach(baseForOwnRight, true);
6025           function baseEvery(collection, predicate) {
6026             var result2 = true;
6027             baseEach(collection, function(value, index, collection2) {
6028               result2 = !!predicate(value, index, collection2);
6029               return result2;
6030             });
6031             return result2;
6032           }
6033           function baseExtremum(array2, iteratee2, comparator) {
6034             var index = -1, length2 = array2.length;
6035             while (++index < length2) {
6036               var value = array2[index], current = iteratee2(value);
6037               if (current != null && (computed === undefined2 ? current === current && !isSymbol2(current) : comparator(current, computed))) {
6038                 var computed = current, result2 = value;
6039               }
6040             }
6041             return result2;
6042           }
6043           function baseFill(array2, value, start2, end) {
6044             var length2 = array2.length;
6045             start2 = toInteger(start2);
6046             if (start2 < 0) {
6047               start2 = -start2 > length2 ? 0 : length2 + start2;
6048             }
6049             end = end === undefined2 || end > length2 ? length2 : toInteger(end);
6050             if (end < 0) {
6051               end += length2;
6052             }
6053             end = start2 > end ? 0 : toLength(end);
6054             while (start2 < end) {
6055               array2[start2++] = value;
6056             }
6057             return array2;
6058           }
6059           function baseFilter(collection, predicate) {
6060             var result2 = [];
6061             baseEach(collection, function(value, index, collection2) {
6062               if (predicate(value, index, collection2)) {
6063                 result2.push(value);
6064               }
6065             });
6066             return result2;
6067           }
6068           function baseFlatten(array2, depth, predicate, isStrict, result2) {
6069             var index = -1, length2 = array2.length;
6070             predicate || (predicate = isFlattenable);
6071             result2 || (result2 = []);
6072             while (++index < length2) {
6073               var value = array2[index];
6074               if (depth > 0 && predicate(value)) {
6075                 if (depth > 1) {
6076                   baseFlatten(value, depth - 1, predicate, isStrict, result2);
6077                 } else {
6078                   arrayPush2(result2, value);
6079                 }
6080               } else if (!isStrict) {
6081                 result2[result2.length] = value;
6082               }
6083             }
6084             return result2;
6085           }
6086           var baseFor = createBaseFor();
6087           var baseForRight = createBaseFor(true);
6088           function baseForOwn(object, iteratee2) {
6089             return object && baseFor(object, iteratee2, keys2);
6090           }
6091           function baseForOwnRight(object, iteratee2) {
6092             return object && baseForRight(object, iteratee2, keys2);
6093           }
6094           function baseFunctions(object, props) {
6095             return arrayFilter2(props, function(key) {
6096               return isFunction2(object[key]);
6097             });
6098           }
6099           function baseGet(object, path) {
6100             path = castPath(path, object);
6101             var index = 0, length2 = path.length;
6102             while (object != null && index < length2) {
6103               object = object[toKey(path[index++])];
6104             }
6105             return index && index == length2 ? object : undefined2;
6106           }
6107           function baseGetAllKeys2(object, keysFunc, symbolsFunc) {
6108             var result2 = keysFunc(object);
6109             return isArray2(object) ? result2 : arrayPush2(result2, symbolsFunc(object));
6110           }
6111           function baseGetTag2(value) {
6112             if (value == null) {
6113               return value === undefined2 ? undefinedTag2 : nullTag2;
6114             }
6115             return symToStringTag3 && symToStringTag3 in Object2(value) ? getRawTag2(value) : objectToString2(value);
6116           }
6117           function baseGt(value, other) {
6118             return value > other;
6119           }
6120           function baseHas(object, key) {
6121             return object != null && hasOwnProperty10.call(object, key);
6122           }
6123           function baseHasIn(object, key) {
6124             return object != null && key in Object2(object);
6125           }
6126           function baseInRange(number3, start2, end) {
6127             return number3 >= nativeMin2(start2, end) && number3 < nativeMax2(start2, end);
6128           }
6129           function baseIntersection(arrays, iteratee2, comparator) {
6130             var includes2 = comparator ? arrayIncludesWith : arrayIncludes, length2 = arrays[0].length, othLength = arrays.length, othIndex = othLength, caches = Array2(othLength), maxLength = Infinity, result2 = [];
6131             while (othIndex--) {
6132               var array2 = arrays[othIndex];
6133               if (othIndex && iteratee2) {
6134                 array2 = arrayMap2(array2, baseUnary2(iteratee2));
6135               }
6136               maxLength = nativeMin2(array2.length, maxLength);
6137               caches[othIndex] = !comparator && (iteratee2 || length2 >= 120 && array2.length >= 120) ? new SetCache2(othIndex && array2) : undefined2;
6138             }
6139             array2 = arrays[0];
6140             var index = -1, seen = caches[0];
6141             outer:
6142               while (++index < length2 && result2.length < maxLength) {
6143                 var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
6144                 value = comparator || value !== 0 ? value : 0;
6145                 if (!(seen ? cacheHas2(seen, computed) : includes2(result2, computed, comparator))) {
6146                   othIndex = othLength;
6147                   while (--othIndex) {
6148                     var cache = caches[othIndex];
6149                     if (!(cache ? cacheHas2(cache, computed) : includes2(arrays[othIndex], computed, comparator))) {
6150                       continue outer;
6151                     }
6152                   }
6153                   if (seen) {
6154                     seen.push(computed);
6155                   }
6156                   result2.push(value);
6157                 }
6158               }
6159             return result2;
6160           }
6161           function baseInverter(object, setter, iteratee2, accumulator) {
6162             baseForOwn(object, function(value, key, object2) {
6163               setter(accumulator, iteratee2(value), key, object2);
6164             });
6165             return accumulator;
6166           }
6167           function baseInvoke(object, path, args) {
6168             path = castPath(path, object);
6169             object = parent(object, path);
6170             var func = object == null ? object : object[toKey(last(path))];
6171             return func == null ? undefined2 : apply(func, object, args);
6172           }
6173           function baseIsArguments2(value) {
6174             return isObjectLike2(value) && baseGetTag2(value) == argsTag4;
6175           }
6176           function baseIsArrayBuffer(value) {
6177             return isObjectLike2(value) && baseGetTag2(value) == arrayBufferTag3;
6178           }
6179           function baseIsDate(value) {
6180             return isObjectLike2(value) && baseGetTag2(value) == dateTag3;
6181           }
6182           function baseIsEqual2(value, other, bitmask, customizer, stack) {
6183             if (value === other) {
6184               return true;
6185             }
6186             if (value == null || other == null || !isObjectLike2(value) && !isObjectLike2(other)) {
6187               return value !== value && other !== other;
6188             }
6189             return baseIsEqualDeep2(value, other, bitmask, customizer, baseIsEqual2, stack);
6190           }
6191           function baseIsEqualDeep2(object, other, bitmask, customizer, equalFunc, stack) {
6192             var objIsArr = isArray2(object), othIsArr = isArray2(other), objTag = objIsArr ? arrayTag3 : getTag2(object), othTag = othIsArr ? arrayTag3 : getTag2(other);
6193             objTag = objTag == argsTag4 ? objectTag4 : objTag;
6194             othTag = othTag == argsTag4 ? objectTag4 : othTag;
6195             var objIsObj = objTag == objectTag4, othIsObj = othTag == objectTag4, isSameTag = objTag == othTag;
6196             if (isSameTag && isBuffer2(object)) {
6197               if (!isBuffer2(other)) {
6198                 return false;
6199               }
6200               objIsArr = true;
6201               objIsObj = false;
6202             }
6203             if (isSameTag && !objIsObj) {
6204               stack || (stack = new Stack2());
6205               return objIsArr || isTypedArray2(object) ? equalArrays2(object, other, bitmask, customizer, equalFunc, stack) : equalByTag2(object, other, objTag, bitmask, customizer, equalFunc, stack);
6206             }
6207             if (!(bitmask & COMPARE_PARTIAL_FLAG5)) {
6208               var objIsWrapped = objIsObj && hasOwnProperty10.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty10.call(other, "__wrapped__");
6209               if (objIsWrapped || othIsWrapped) {
6210                 var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
6211                 stack || (stack = new Stack2());
6212                 return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
6213               }
6214             }
6215             if (!isSameTag) {
6216               return false;
6217             }
6218             stack || (stack = new Stack2());
6219             return equalObjects2(object, other, bitmask, customizer, equalFunc, stack);
6220           }
6221           function baseIsMap(value) {
6222             return isObjectLike2(value) && getTag2(value) == mapTag4;
6223           }
6224           function baseIsMatch(object, source, matchData, customizer) {
6225             var index = matchData.length, length2 = index, noCustomizer = !customizer;
6226             if (object == null) {
6227               return !length2;
6228             }
6229             object = Object2(object);
6230             while (index--) {
6231               var data = matchData[index];
6232               if (noCustomizer && data[2] ? data[1] !== object[data[0]] : !(data[0] in object)) {
6233                 return false;
6234               }
6235             }
6236             while (++index < length2) {
6237               data = matchData[index];
6238               var key = data[0], objValue = object[key], srcValue = data[1];
6239               if (noCustomizer && data[2]) {
6240                 if (objValue === undefined2 && !(key in object)) {
6241                   return false;
6242                 }
6243               } else {
6244                 var stack = new Stack2();
6245                 if (customizer) {
6246                   var result2 = customizer(objValue, srcValue, key, object, source, stack);
6247                 }
6248                 if (!(result2 === undefined2 ? baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG5 | COMPARE_UNORDERED_FLAG3, customizer, stack) : result2)) {
6249                   return false;
6250                 }
6251               }
6252             }
6253             return true;
6254           }
6255           function baseIsNative2(value) {
6256             if (!isObject3(value) || isMasked2(value)) {
6257               return false;
6258             }
6259             var pattern = isFunction2(value) ? reIsNative2 : reIsHostCtor2;
6260             return pattern.test(toSource2(value));
6261           }
6262           function baseIsRegExp(value) {
6263             return isObjectLike2(value) && baseGetTag2(value) == regexpTag3;
6264           }
6265           function baseIsSet(value) {
6266             return isObjectLike2(value) && getTag2(value) == setTag4;
6267           }
6268           function baseIsTypedArray2(value) {
6269             return isObjectLike2(value) && isLength2(value.length) && !!typedArrayTags2[baseGetTag2(value)];
6270           }
6271           function baseIteratee(value) {
6272             if (typeof value == "function") {
6273               return value;
6274             }
6275             if (value == null) {
6276               return identity4;
6277             }
6278             if (typeof value == "object") {
6279               return isArray2(value) ? baseMatchesProperty(value[0], value[1]) : baseMatches(value);
6280             }
6281             return property(value);
6282           }
6283           function baseKeys2(object) {
6284             if (!isPrototype2(object)) {
6285               return nativeKeys2(object);
6286             }
6287             var result2 = [];
6288             for (var key in Object2(object)) {
6289               if (hasOwnProperty10.call(object, key) && key != "constructor") {
6290                 result2.push(key);
6291               }
6292             }
6293             return result2;
6294           }
6295           function baseKeysIn(object) {
6296             if (!isObject3(object)) {
6297               return nativeKeysIn(object);
6298             }
6299             var isProto = isPrototype2(object), result2 = [];
6300             for (var key in object) {
6301               if (!(key == "constructor" && (isProto || !hasOwnProperty10.call(object, key)))) {
6302                 result2.push(key);
6303               }
6304             }
6305             return result2;
6306           }
6307           function baseLt(value, other) {
6308             return value < other;
6309           }
6310           function baseMap(collection, iteratee2) {
6311             var index = -1, result2 = isArrayLike2(collection) ? Array2(collection.length) : [];
6312             baseEach(collection, function(value, key, collection2) {
6313               result2[++index] = iteratee2(value, key, collection2);
6314             });
6315             return result2;
6316           }
6317           function baseMatches(source) {
6318             var matchData = getMatchData(source);
6319             if (matchData.length == 1 && matchData[0][2]) {
6320               return matchesStrictComparable(matchData[0][0], matchData[0][1]);
6321             }
6322             return function(object) {
6323               return object === source || baseIsMatch(object, source, matchData);
6324             };
6325           }
6326           function baseMatchesProperty(path, srcValue) {
6327             if (isKey(path) && isStrictComparable(srcValue)) {
6328               return matchesStrictComparable(toKey(path), srcValue);
6329             }
6330             return function(object) {
6331               var objValue = get4(object, path);
6332               return objValue === undefined2 && objValue === srcValue ? hasIn(object, path) : baseIsEqual2(srcValue, objValue, COMPARE_PARTIAL_FLAG5 | COMPARE_UNORDERED_FLAG3);
6333             };
6334           }
6335           function baseMerge(object, source, srcIndex, customizer, stack) {
6336             if (object === source) {
6337               return;
6338             }
6339             baseFor(source, function(srcValue, key) {
6340               stack || (stack = new Stack2());
6341               if (isObject3(srcValue)) {
6342                 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack);
6343               } else {
6344                 var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : undefined2;
6345                 if (newValue === undefined2) {
6346                   newValue = srcValue;
6347                 }
6348                 assignMergeValue(object, key, newValue);
6349               }
6350             }, keysIn);
6351           }
6352           function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) {
6353             var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack.get(srcValue);
6354             if (stacked) {
6355               assignMergeValue(object, key, stacked);
6356               return;
6357             }
6358             var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : undefined2;
6359             var isCommon = newValue === undefined2;
6360             if (isCommon) {
6361               var isArr = isArray2(srcValue), isBuff = !isArr && isBuffer2(srcValue), isTyped = !isArr && !isBuff && isTypedArray2(srcValue);
6362               newValue = srcValue;
6363               if (isArr || isBuff || isTyped) {
6364                 if (isArray2(objValue)) {
6365                   newValue = objValue;
6366                 } else if (isArrayLikeObject(objValue)) {
6367                   newValue = copyArray(objValue);
6368                 } else if (isBuff) {
6369                   isCommon = false;
6370                   newValue = cloneBuffer(srcValue, true);
6371                 } else if (isTyped) {
6372                   isCommon = false;
6373                   newValue = cloneTypedArray(srcValue, true);
6374                 } else {
6375                   newValue = [];
6376                 }
6377               } else if (isPlainObject(srcValue) || isArguments2(srcValue)) {
6378                 newValue = objValue;
6379                 if (isArguments2(objValue)) {
6380                   newValue = toPlainObject(objValue);
6381                 } else if (!isObject3(objValue) || isFunction2(objValue)) {
6382                   newValue = initCloneObject(srcValue);
6383                 }
6384               } else {
6385                 isCommon = false;
6386               }
6387             }
6388             if (isCommon) {
6389               stack.set(srcValue, newValue);
6390               mergeFunc(newValue, srcValue, srcIndex, customizer, stack);
6391               stack["delete"](srcValue);
6392             }
6393             assignMergeValue(object, key, newValue);
6394           }
6395           function baseNth(array2, n3) {
6396             var length2 = array2.length;
6397             if (!length2) {
6398               return;
6399             }
6400             n3 += n3 < 0 ? length2 : 0;
6401             return isIndex2(n3, length2) ? array2[n3] : undefined2;
6402           }
6403           function baseOrderBy(collection, iteratees, orders) {
6404             if (iteratees.length) {
6405               iteratees = arrayMap2(iteratees, function(iteratee2) {
6406                 if (isArray2(iteratee2)) {
6407                   return function(value) {
6408                     return baseGet(value, iteratee2.length === 1 ? iteratee2[0] : iteratee2);
6409                   };
6410                 }
6411                 return iteratee2;
6412               });
6413             } else {
6414               iteratees = [identity4];
6415             }
6416             var index = -1;
6417             iteratees = arrayMap2(iteratees, baseUnary2(getIteratee()));
6418             var result2 = baseMap(collection, function(value, key, collection2) {
6419               var criteria = arrayMap2(iteratees, function(iteratee2) {
6420                 return iteratee2(value);
6421               });
6422               return { "criteria": criteria, "index": ++index, "value": value };
6423             });
6424             return baseSortBy(result2, function(object, other) {
6425               return compareMultiple(object, other, orders);
6426             });
6427           }
6428           function basePick(object, paths) {
6429             return basePickBy(object, paths, function(value, path) {
6430               return hasIn(object, path);
6431             });
6432           }
6433           function basePickBy(object, paths, predicate) {
6434             var index = -1, length2 = paths.length, result2 = {};
6435             while (++index < length2) {
6436               var path = paths[index], value = baseGet(object, path);
6437               if (predicate(value, path)) {
6438                 baseSet(result2, castPath(path, object), value);
6439               }
6440             }
6441             return result2;
6442           }
6443           function basePropertyDeep(path) {
6444             return function(object) {
6445               return baseGet(object, path);
6446             };
6447           }
6448           function basePullAll(array2, values2, iteratee2, comparator) {
6449             var indexOf2 = comparator ? baseIndexOfWith : baseIndexOf, index = -1, length2 = values2.length, seen = array2;
6450             if (array2 === values2) {
6451               values2 = copyArray(values2);
6452             }
6453             if (iteratee2) {
6454               seen = arrayMap2(array2, baseUnary2(iteratee2));
6455             }
6456             while (++index < length2) {
6457               var fromIndex = 0, value = values2[index], computed = iteratee2 ? iteratee2(value) : value;
6458               while ((fromIndex = indexOf2(seen, computed, fromIndex, comparator)) > -1) {
6459                 if (seen !== array2) {
6460                   splice2.call(seen, fromIndex, 1);
6461                 }
6462                 splice2.call(array2, fromIndex, 1);
6463               }
6464             }
6465             return array2;
6466           }
6467           function basePullAt(array2, indexes) {
6468             var length2 = array2 ? indexes.length : 0, lastIndex = length2 - 1;
6469             while (length2--) {
6470               var index = indexes[length2];
6471               if (length2 == lastIndex || index !== previous) {
6472                 var previous = index;
6473                 if (isIndex2(index)) {
6474                   splice2.call(array2, index, 1);
6475                 } else {
6476                   baseUnset(array2, index);
6477                 }
6478               }
6479             }
6480             return array2;
6481           }
6482           function baseRandom(lower2, upper) {
6483             return lower2 + nativeFloor(nativeRandom() * (upper - lower2 + 1));
6484           }
6485           function baseRange(start2, end, step, fromRight) {
6486             var index = -1, length2 = nativeMax2(nativeCeil((end - start2) / (step || 1)), 0), result2 = Array2(length2);
6487             while (length2--) {
6488               result2[fromRight ? length2 : ++index] = start2;
6489               start2 += step;
6490             }
6491             return result2;
6492           }
6493           function baseRepeat(string, n3) {
6494             var result2 = "";
6495             if (!string || n3 < 1 || n3 > MAX_SAFE_INTEGER4) {
6496               return result2;
6497             }
6498             do {
6499               if (n3 % 2) {
6500                 result2 += string;
6501               }
6502               n3 = nativeFloor(n3 / 2);
6503               if (n3) {
6504                 string += string;
6505               }
6506             } while (n3);
6507             return result2;
6508           }
6509           function baseRest(func, start2) {
6510             return setToString(overRest(func, start2, identity4), func + "");
6511           }
6512           function baseSample(collection) {
6513             return arraySample(values(collection));
6514           }
6515           function baseSampleSize(collection, n3) {
6516             var array2 = values(collection);
6517             return shuffleSelf(array2, baseClamp(n3, 0, array2.length));
6518           }
6519           function baseSet(object, path, value, customizer) {
6520             if (!isObject3(object)) {
6521               return object;
6522             }
6523             path = castPath(path, object);
6524             var index = -1, length2 = path.length, lastIndex = length2 - 1, nested = object;
6525             while (nested != null && ++index < length2) {
6526               var key = toKey(path[index]), newValue = value;
6527               if (key === "__proto__" || key === "constructor" || key === "prototype") {
6528                 return object;
6529               }
6530               if (index != lastIndex) {
6531                 var objValue = nested[key];
6532                 newValue = customizer ? customizer(objValue, key, nested) : undefined2;
6533                 if (newValue === undefined2) {
6534                   newValue = isObject3(objValue) ? objValue : isIndex2(path[index + 1]) ? [] : {};
6535                 }
6536               }
6537               assignValue(nested, key, newValue);
6538               nested = nested[key];
6539             }
6540             return object;
6541           }
6542           var baseSetData = !metaMap ? identity4 : function(func, data) {
6543             metaMap.set(func, data);
6544             return func;
6545           };
6546           var baseSetToString = !defineProperty ? identity4 : function(func, string) {
6547             return defineProperty(func, "toString", {
6548               "configurable": true,
6549               "enumerable": false,
6550               "value": constant(string),
6551               "writable": true
6552             });
6553           };
6554           function baseShuffle(collection) {
6555             return shuffleSelf(values(collection));
6556           }
6557           function baseSlice(array2, start2, end) {
6558             var index = -1, length2 = array2.length;
6559             if (start2 < 0) {
6560               start2 = -start2 > length2 ? 0 : length2 + start2;
6561             }
6562             end = end > length2 ? length2 : end;
6563             if (end < 0) {
6564               end += length2;
6565             }
6566             length2 = start2 > end ? 0 : end - start2 >>> 0;
6567             start2 >>>= 0;
6568             var result2 = Array2(length2);
6569             while (++index < length2) {
6570               result2[index] = array2[index + start2];
6571             }
6572             return result2;
6573           }
6574           function baseSome(collection, predicate) {
6575             var result2;
6576             baseEach(collection, function(value, index, collection2) {
6577               result2 = predicate(value, index, collection2);
6578               return !result2;
6579             });
6580             return !!result2;
6581           }
6582           function baseSortedIndex(array2, value, retHighest) {
6583             var low = 0, high = array2 == null ? low : array2.length;
6584             if (typeof value == "number" && value === value && high <= HALF_MAX_ARRAY_LENGTH) {
6585               while (low < high) {
6586                 var mid = low + high >>> 1, computed = array2[mid];
6587                 if (computed !== null && !isSymbol2(computed) && (retHighest ? computed <= value : computed < value)) {
6588                   low = mid + 1;
6589                 } else {
6590                   high = mid;
6591                 }
6592               }
6593               return high;
6594             }
6595             return baseSortedIndexBy(array2, value, identity4, retHighest);
6596           }
6597           function baseSortedIndexBy(array2, value, iteratee2, retHighest) {
6598             var low = 0, high = array2 == null ? 0 : array2.length;
6599             if (high === 0) {
6600               return 0;
6601             }
6602             value = iteratee2(value);
6603             var valIsNaN = value !== value, valIsNull = value === null, valIsSymbol = isSymbol2(value), valIsUndefined = value === undefined2;
6604             while (low < high) {
6605               var mid = nativeFloor((low + high) / 2), computed = iteratee2(array2[mid]), othIsDefined = computed !== undefined2, othIsNull = computed === null, othIsReflexive = computed === computed, othIsSymbol = isSymbol2(computed);
6606               if (valIsNaN) {
6607                 var setLow = retHighest || othIsReflexive;
6608               } else if (valIsUndefined) {
6609                 setLow = othIsReflexive && (retHighest || othIsDefined);
6610               } else if (valIsNull) {
6611                 setLow = othIsReflexive && othIsDefined && (retHighest || !othIsNull);
6612               } else if (valIsSymbol) {
6613                 setLow = othIsReflexive && othIsDefined && !othIsNull && (retHighest || !othIsSymbol);
6614               } else if (othIsNull || othIsSymbol) {
6615                 setLow = false;
6616               } else {
6617                 setLow = retHighest ? computed <= value : computed < value;
6618               }
6619               if (setLow) {
6620                 low = mid + 1;
6621               } else {
6622                 high = mid;
6623               }
6624             }
6625             return nativeMin2(high, MAX_ARRAY_INDEX);
6626           }
6627           function baseSortedUniq(array2, iteratee2) {
6628             var index = -1, length2 = array2.length, resIndex = 0, result2 = [];
6629             while (++index < length2) {
6630               var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
6631               if (!index || !eq2(computed, seen)) {
6632                 var seen = computed;
6633                 result2[resIndex++] = value === 0 ? 0 : value;
6634               }
6635             }
6636             return result2;
6637           }
6638           function baseToNumber(value) {
6639             if (typeof value == "number") {
6640               return value;
6641             }
6642             if (isSymbol2(value)) {
6643               return NAN2;
6644             }
6645             return +value;
6646           }
6647           function baseToString2(value) {
6648             if (typeof value == "string") {
6649               return value;
6650             }
6651             if (isArray2(value)) {
6652               return arrayMap2(value, baseToString2) + "";
6653             }
6654             if (isSymbol2(value)) {
6655               return symbolToString2 ? symbolToString2.call(value) : "";
6656             }
6657             var result2 = value + "";
6658             return result2 == "0" && 1 / value == -INFINITY2 ? "-0" : result2;
6659           }
6660           function baseUniq(array2, iteratee2, comparator) {
6661             var index = -1, includes2 = arrayIncludes, length2 = array2.length, isCommon = true, result2 = [], seen = result2;
6662             if (comparator) {
6663               isCommon = false;
6664               includes2 = arrayIncludesWith;
6665             } else if (length2 >= LARGE_ARRAY_SIZE2) {
6666               var set5 = iteratee2 ? null : createSet(array2);
6667               if (set5) {
6668                 return setToArray2(set5);
6669               }
6670               isCommon = false;
6671               includes2 = cacheHas2;
6672               seen = new SetCache2();
6673             } else {
6674               seen = iteratee2 ? [] : result2;
6675             }
6676             outer:
6677               while (++index < length2) {
6678                 var value = array2[index], computed = iteratee2 ? iteratee2(value) : value;
6679                 value = comparator || value !== 0 ? value : 0;
6680                 if (isCommon && computed === computed) {
6681                   var seenIndex = seen.length;
6682                   while (seenIndex--) {
6683                     if (seen[seenIndex] === computed) {
6684                       continue outer;
6685                     }
6686                   }
6687                   if (iteratee2) {
6688                     seen.push(computed);
6689                   }
6690                   result2.push(value);
6691                 } else if (!includes2(seen, computed, comparator)) {
6692                   if (seen !== result2) {
6693                     seen.push(computed);
6694                   }
6695                   result2.push(value);
6696                 }
6697               }
6698             return result2;
6699           }
6700           function baseUnset(object, path) {
6701             path = castPath(path, object);
6702             object = parent(object, path);
6703             return object == null || delete object[toKey(last(path))];
6704           }
6705           function baseUpdate(object, path, updater, customizer) {
6706             return baseSet(object, path, updater(baseGet(object, path)), customizer);
6707           }
6708           function baseWhile(array2, predicate, isDrop, fromRight) {
6709             var length2 = array2.length, index = fromRight ? length2 : -1;
6710             while ((fromRight ? index-- : ++index < length2) && predicate(array2[index], index, array2)) {
6711             }
6712             return isDrop ? baseSlice(array2, fromRight ? 0 : index, fromRight ? index + 1 : length2) : baseSlice(array2, fromRight ? index + 1 : 0, fromRight ? length2 : index);
6713           }
6714           function baseWrapperValue(value, actions) {
6715             var result2 = value;
6716             if (result2 instanceof LazyWrapper) {
6717               result2 = result2.value();
6718             }
6719             return arrayReduce(actions, function(result3, action) {
6720               return action.func.apply(action.thisArg, arrayPush2([result3], action.args));
6721             }, result2);
6722           }
6723           function baseXor(arrays, iteratee2, comparator) {
6724             var length2 = arrays.length;
6725             if (length2 < 2) {
6726               return length2 ? baseUniq(arrays[0]) : [];
6727             }
6728             var index = -1, result2 = Array2(length2);
6729             while (++index < length2) {
6730               var array2 = arrays[index], othIndex = -1;
6731               while (++othIndex < length2) {
6732                 if (othIndex != index) {
6733                   result2[index] = baseDifference(result2[index] || array2, arrays[othIndex], iteratee2, comparator);
6734                 }
6735               }
6736             }
6737             return baseUniq(baseFlatten(result2, 1), iteratee2, comparator);
6738           }
6739           function baseZipObject(props, values2, assignFunc) {
6740             var index = -1, length2 = props.length, valsLength = values2.length, result2 = {};
6741             while (++index < length2) {
6742               var value = index < valsLength ? values2[index] : undefined2;
6743               assignFunc(result2, props[index], value);
6744             }
6745             return result2;
6746           }
6747           function castArrayLikeObject(value) {
6748             return isArrayLikeObject(value) ? value : [];
6749           }
6750           function castFunction(value) {
6751             return typeof value == "function" ? value : identity4;
6752           }
6753           function castPath(value, object) {
6754             if (isArray2(value)) {
6755               return value;
6756             }
6757             return isKey(value, object) ? [value] : stringToPath(toString2(value));
6758           }
6759           var castRest = baseRest;
6760           function castSlice(array2, start2, end) {
6761             var length2 = array2.length;
6762             end = end === undefined2 ? length2 : end;
6763             return !start2 && end >= length2 ? array2 : baseSlice(array2, start2, end);
6764           }
6765           var clearTimeout2 = ctxClearTimeout || function(id2) {
6766             return root3.clearTimeout(id2);
6767           };
6768           function cloneBuffer(buffer, isDeep) {
6769             if (isDeep) {
6770               return buffer.slice();
6771             }
6772             var length2 = buffer.length, result2 = allocUnsafe ? allocUnsafe(length2) : new buffer.constructor(length2);
6773             buffer.copy(result2);
6774             return result2;
6775           }
6776           function cloneArrayBuffer(arrayBuffer) {
6777             var result2 = new arrayBuffer.constructor(arrayBuffer.byteLength);
6778             new Uint8Array3(result2).set(new Uint8Array3(arrayBuffer));
6779             return result2;
6780           }
6781           function cloneDataView(dataView, isDeep) {
6782             var buffer = isDeep ? cloneArrayBuffer(dataView.buffer) : dataView.buffer;
6783             return new dataView.constructor(buffer, dataView.byteOffset, dataView.byteLength);
6784           }
6785           function cloneRegExp(regexp) {
6786             var result2 = new regexp.constructor(regexp.source, reFlags.exec(regexp));
6787             result2.lastIndex = regexp.lastIndex;
6788             return result2;
6789           }
6790           function cloneSymbol(symbol) {
6791             return symbolValueOf2 ? Object2(symbolValueOf2.call(symbol)) : {};
6792           }
6793           function cloneTypedArray(typedArray, isDeep) {
6794             var buffer = isDeep ? cloneArrayBuffer(typedArray.buffer) : typedArray.buffer;
6795             return new typedArray.constructor(buffer, typedArray.byteOffset, typedArray.length);
6796           }
6797           function compareAscending(value, other) {
6798             if (value !== other) {
6799               var valIsDefined = value !== undefined2, valIsNull = value === null, valIsReflexive = value === value, valIsSymbol = isSymbol2(value);
6800               var othIsDefined = other !== undefined2, othIsNull = other === null, othIsReflexive = other === other, othIsSymbol = isSymbol2(other);
6801               if (!othIsNull && !othIsSymbol && !valIsSymbol && value > other || valIsSymbol && othIsDefined && othIsReflexive && !othIsNull && !othIsSymbol || valIsNull && othIsDefined && othIsReflexive || !valIsDefined && othIsReflexive || !valIsReflexive) {
6802                 return 1;
6803               }
6804               if (!valIsNull && !valIsSymbol && !othIsSymbol && value < other || othIsSymbol && valIsDefined && valIsReflexive && !valIsNull && !valIsSymbol || othIsNull && valIsDefined && valIsReflexive || !othIsDefined && valIsReflexive || !othIsReflexive) {
6805                 return -1;
6806               }
6807             }
6808             return 0;
6809           }
6810           function compareMultiple(object, other, orders) {
6811             var index = -1, objCriteria = object.criteria, othCriteria = other.criteria, length2 = objCriteria.length, ordersLength = orders.length;
6812             while (++index < length2) {
6813               var result2 = compareAscending(objCriteria[index], othCriteria[index]);
6814               if (result2) {
6815                 if (index >= ordersLength) {
6816                   return result2;
6817                 }
6818                 var order = orders[index];
6819                 return result2 * (order == "desc" ? -1 : 1);
6820               }
6821             }
6822             return object.index - other.index;
6823           }
6824           function composeArgs(args, partials, holders, isCurried) {
6825             var argsIndex = -1, argsLength = args.length, holdersLength = holders.length, leftIndex = -1, leftLength = partials.length, rangeLength = nativeMax2(argsLength - holdersLength, 0), result2 = Array2(leftLength + rangeLength), isUncurried = !isCurried;
6826             while (++leftIndex < leftLength) {
6827               result2[leftIndex] = partials[leftIndex];
6828             }
6829             while (++argsIndex < holdersLength) {
6830               if (isUncurried || argsIndex < argsLength) {
6831                 result2[holders[argsIndex]] = args[argsIndex];
6832               }
6833             }
6834             while (rangeLength--) {
6835               result2[leftIndex++] = args[argsIndex++];
6836             }
6837             return result2;
6838           }
6839           function composeArgsRight(args, partials, holders, isCurried) {
6840             var argsIndex = -1, argsLength = args.length, holdersIndex = -1, holdersLength = holders.length, rightIndex = -1, rightLength = partials.length, rangeLength = nativeMax2(argsLength - holdersLength, 0), result2 = Array2(rangeLength + rightLength), isUncurried = !isCurried;
6841             while (++argsIndex < rangeLength) {
6842               result2[argsIndex] = args[argsIndex];
6843             }
6844             var offset = argsIndex;
6845             while (++rightIndex < rightLength) {
6846               result2[offset + rightIndex] = partials[rightIndex];
6847             }
6848             while (++holdersIndex < holdersLength) {
6849               if (isUncurried || argsIndex < argsLength) {
6850                 result2[offset + holders[holdersIndex]] = args[argsIndex++];
6851               }
6852             }
6853             return result2;
6854           }
6855           function copyArray(source, array2) {
6856             var index = -1, length2 = source.length;
6857             array2 || (array2 = Array2(length2));
6858             while (++index < length2) {
6859               array2[index] = source[index];
6860             }
6861             return array2;
6862           }
6863           function copyObject(source, props, object, customizer) {
6864             var isNew = !object;
6865             object || (object = {});
6866             var index = -1, length2 = props.length;
6867             while (++index < length2) {
6868               var key = props[index];
6869               var newValue = customizer ? customizer(object[key], source[key], key, object, source) : undefined2;
6870               if (newValue === undefined2) {
6871                 newValue = source[key];
6872               }
6873               if (isNew) {
6874                 baseAssignValue(object, key, newValue);
6875               } else {
6876                 assignValue(object, key, newValue);
6877               }
6878             }
6879             return object;
6880           }
6881           function copySymbols(source, object) {
6882             return copyObject(source, getSymbols2(source), object);
6883           }
6884           function copySymbolsIn(source, object) {
6885             return copyObject(source, getSymbolsIn(source), object);
6886           }
6887           function createAggregator(setter, initializer) {
6888             return function(collection, iteratee2) {
6889               var func = isArray2(collection) ? arrayAggregator : baseAggregator, accumulator = initializer ? initializer() : {};
6890               return func(collection, setter, getIteratee(iteratee2, 2), accumulator);
6891             };
6892           }
6893           function createAssigner(assigner) {
6894             return baseRest(function(object, sources) {
6895               var index = -1, length2 = sources.length, customizer = length2 > 1 ? sources[length2 - 1] : undefined2, guard = length2 > 2 ? sources[2] : undefined2;
6896               customizer = assigner.length > 3 && typeof customizer == "function" ? (length2--, customizer) : undefined2;
6897               if (guard && isIterateeCall(sources[0], sources[1], guard)) {
6898                 customizer = length2 < 3 ? undefined2 : customizer;
6899                 length2 = 1;
6900               }
6901               object = Object2(object);
6902               while (++index < length2) {
6903                 var source = sources[index];
6904                 if (source) {
6905                   assigner(object, source, index, customizer);
6906                 }
6907               }
6908               return object;
6909             });
6910           }
6911           function createBaseEach(eachFunc, fromRight) {
6912             return function(collection, iteratee2) {
6913               if (collection == null) {
6914                 return collection;
6915               }
6916               if (!isArrayLike2(collection)) {
6917                 return eachFunc(collection, iteratee2);
6918               }
6919               var length2 = collection.length, index = fromRight ? length2 : -1, iterable = Object2(collection);
6920               while (fromRight ? index-- : ++index < length2) {
6921                 if (iteratee2(iterable[index], index, iterable) === false) {
6922                   break;
6923                 }
6924               }
6925               return collection;
6926             };
6927           }
6928           function createBaseFor(fromRight) {
6929             return function(object, iteratee2, keysFunc) {
6930               var index = -1, iterable = Object2(object), props = keysFunc(object), length2 = props.length;
6931               while (length2--) {
6932                 var key = props[fromRight ? length2 : ++index];
6933                 if (iteratee2(iterable[key], key, iterable) === false) {
6934                   break;
6935                 }
6936               }
6937               return object;
6938             };
6939           }
6940           function createBind(func, bitmask, thisArg) {
6941             var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
6942             function wrapper() {
6943               var fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
6944               return fn.apply(isBind ? thisArg : this, arguments);
6945             }
6946             return wrapper;
6947           }
6948           function createCaseFirst(methodName) {
6949             return function(string) {
6950               string = toString2(string);
6951               var strSymbols = hasUnicode(string) ? stringToArray(string) : undefined2;
6952               var chr = strSymbols ? strSymbols[0] : string.charAt(0);
6953               var trailing = strSymbols ? castSlice(strSymbols, 1).join("") : string.slice(1);
6954               return chr[methodName]() + trailing;
6955             };
6956           }
6957           function createCompounder(callback) {
6958             return function(string) {
6959               return arrayReduce(words(deburr(string).replace(reApos, "")), callback, "");
6960             };
6961           }
6962           function createCtor(Ctor) {
6963             return function() {
6964               var args = arguments;
6965               switch (args.length) {
6966                 case 0:
6967                   return new Ctor();
6968                 case 1:
6969                   return new Ctor(args[0]);
6970                 case 2:
6971                   return new Ctor(args[0], args[1]);
6972                 case 3:
6973                   return new Ctor(args[0], args[1], args[2]);
6974                 case 4:
6975                   return new Ctor(args[0], args[1], args[2], args[3]);
6976                 case 5:
6977                   return new Ctor(args[0], args[1], args[2], args[3], args[4]);
6978                 case 6:
6979                   return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
6980                 case 7:
6981                   return new Ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
6982               }
6983               var thisBinding = baseCreate(Ctor.prototype), result2 = Ctor.apply(thisBinding, args);
6984               return isObject3(result2) ? result2 : thisBinding;
6985             };
6986           }
6987           function createCurry(func, bitmask, arity) {
6988             var Ctor = createCtor(func);
6989             function wrapper() {
6990               var length2 = arguments.length, args = Array2(length2), index = length2, placeholder = getHolder(wrapper);
6991               while (index--) {
6992                 args[index] = arguments[index];
6993               }
6994               var holders = length2 < 3 && args[0] !== placeholder && args[length2 - 1] !== placeholder ? [] : replaceHolders(args, placeholder);
6995               length2 -= holders.length;
6996               if (length2 < arity) {
6997                 return createRecurry(
6998                   func,
6999                   bitmask,
7000                   createHybrid,
7001                   wrapper.placeholder,
7002                   undefined2,
7003                   args,
7004                   holders,
7005                   undefined2,
7006                   undefined2,
7007                   arity - length2
7008                 );
7009               }
7010               var fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
7011               return apply(fn, this, args);
7012             }
7013             return wrapper;
7014           }
7015           function createFind(findIndexFunc) {
7016             return function(collection, predicate, fromIndex) {
7017               var iterable = Object2(collection);
7018               if (!isArrayLike2(collection)) {
7019                 var iteratee2 = getIteratee(predicate, 3);
7020                 collection = keys2(collection);
7021                 predicate = function(key) {
7022                   return iteratee2(iterable[key], key, iterable);
7023                 };
7024               }
7025               var index = findIndexFunc(collection, predicate, fromIndex);
7026               return index > -1 ? iterable[iteratee2 ? collection[index] : index] : undefined2;
7027             };
7028           }
7029           function createFlow(fromRight) {
7030             return flatRest(function(funcs) {
7031               var length2 = funcs.length, index = length2, prereq = LodashWrapper.prototype.thru;
7032               if (fromRight) {
7033                 funcs.reverse();
7034               }
7035               while (index--) {
7036                 var func = funcs[index];
7037                 if (typeof func != "function") {
7038                   throw new TypeError2(FUNC_ERROR_TEXT3);
7039                 }
7040                 if (prereq && !wrapper && getFuncName(func) == "wrapper") {
7041                   var wrapper = new LodashWrapper([], true);
7042                 }
7043               }
7044               index = wrapper ? index : length2;
7045               while (++index < length2) {
7046                 func = funcs[index];
7047                 var funcName = getFuncName(func), data = funcName == "wrapper" ? getData(func) : undefined2;
7048                 if (data && isLaziable(data[0]) && data[1] == (WRAP_ARY_FLAG | WRAP_CURRY_FLAG | WRAP_PARTIAL_FLAG | WRAP_REARG_FLAG) && !data[4].length && data[9] == 1) {
7049                   wrapper = wrapper[getFuncName(data[0])].apply(wrapper, data[3]);
7050                 } else {
7051                   wrapper = func.length == 1 && isLaziable(func) ? wrapper[funcName]() : wrapper.thru(func);
7052                 }
7053               }
7054               return function() {
7055                 var args = arguments, value = args[0];
7056                 if (wrapper && args.length == 1 && isArray2(value)) {
7057                   return wrapper.plant(value).value();
7058                 }
7059                 var index2 = 0, result2 = length2 ? funcs[index2].apply(this, args) : value;
7060                 while (++index2 < length2) {
7061                   result2 = funcs[index2].call(this, result2);
7062                 }
7063                 return result2;
7064               };
7065             });
7066           }
7067           function createHybrid(func, bitmask, thisArg, partials, holders, partialsRight, holdersRight, argPos, ary2, arity) {
7068             var isAry = bitmask & WRAP_ARY_FLAG, isBind = bitmask & WRAP_BIND_FLAG, isBindKey = bitmask & WRAP_BIND_KEY_FLAG, isCurried = bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG), isFlip = bitmask & WRAP_FLIP_FLAG, Ctor = isBindKey ? undefined2 : createCtor(func);
7069             function wrapper() {
7070               var length2 = arguments.length, args = Array2(length2), index = length2;
7071               while (index--) {
7072                 args[index] = arguments[index];
7073               }
7074               if (isCurried) {
7075                 var placeholder = getHolder(wrapper), holdersCount = countHolders(args, placeholder);
7076               }
7077               if (partials) {
7078                 args = composeArgs(args, partials, holders, isCurried);
7079               }
7080               if (partialsRight) {
7081                 args = composeArgsRight(args, partialsRight, holdersRight, isCurried);
7082               }
7083               length2 -= holdersCount;
7084               if (isCurried && length2 < arity) {
7085                 var newHolders = replaceHolders(args, placeholder);
7086                 return createRecurry(
7087                   func,
7088                   bitmask,
7089                   createHybrid,
7090                   wrapper.placeholder,
7091                   thisArg,
7092                   args,
7093                   newHolders,
7094                   argPos,
7095                   ary2,
7096                   arity - length2
7097                 );
7098               }
7099               var thisBinding = isBind ? thisArg : this, fn = isBindKey ? thisBinding[func] : func;
7100               length2 = args.length;
7101               if (argPos) {
7102                 args = reorder(args, argPos);
7103               } else if (isFlip && length2 > 1) {
7104                 args.reverse();
7105               }
7106               if (isAry && ary2 < length2) {
7107                 args.length = ary2;
7108               }
7109               if (this && this !== root3 && this instanceof wrapper) {
7110                 fn = Ctor || createCtor(fn);
7111               }
7112               return fn.apply(thisBinding, args);
7113             }
7114             return wrapper;
7115           }
7116           function createInverter(setter, toIteratee) {
7117             return function(object, iteratee2) {
7118               return baseInverter(object, setter, toIteratee(iteratee2), {});
7119             };
7120           }
7121           function createMathOperation(operator, defaultValue) {
7122             return function(value, other) {
7123               var result2;
7124               if (value === undefined2 && other === undefined2) {
7125                 return defaultValue;
7126               }
7127               if (value !== undefined2) {
7128                 result2 = value;
7129               }
7130               if (other !== undefined2) {
7131                 if (result2 === undefined2) {
7132                   return other;
7133                 }
7134                 if (typeof value == "string" || typeof other == "string") {
7135                   value = baseToString2(value);
7136                   other = baseToString2(other);
7137                 } else {
7138                   value = baseToNumber(value);
7139                   other = baseToNumber(other);
7140                 }
7141                 result2 = operator(value, other);
7142               }
7143               return result2;
7144             };
7145           }
7146           function createOver(arrayFunc) {
7147             return flatRest(function(iteratees) {
7148               iteratees = arrayMap2(iteratees, baseUnary2(getIteratee()));
7149               return baseRest(function(args) {
7150                 var thisArg = this;
7151                 return arrayFunc(iteratees, function(iteratee2) {
7152                   return apply(iteratee2, thisArg, args);
7153                 });
7154               });
7155             });
7156           }
7157           function createPadding(length2, chars) {
7158             chars = chars === undefined2 ? " " : baseToString2(chars);
7159             var charsLength = chars.length;
7160             if (charsLength < 2) {
7161               return charsLength ? baseRepeat(chars, length2) : chars;
7162             }
7163             var result2 = baseRepeat(chars, nativeCeil(length2 / stringSize(chars)));
7164             return hasUnicode(chars) ? castSlice(stringToArray(result2), 0, length2).join("") : result2.slice(0, length2);
7165           }
7166           function createPartial(func, bitmask, thisArg, partials) {
7167             var isBind = bitmask & WRAP_BIND_FLAG, Ctor = createCtor(func);
7168             function wrapper() {
7169               var argsIndex = -1, argsLength = arguments.length, leftIndex = -1, leftLength = partials.length, args = Array2(leftLength + argsLength), fn = this && this !== root3 && this instanceof wrapper ? Ctor : func;
7170               while (++leftIndex < leftLength) {
7171                 args[leftIndex] = partials[leftIndex];
7172               }
7173               while (argsLength--) {
7174                 args[leftIndex++] = arguments[++argsIndex];
7175               }
7176               return apply(fn, isBind ? thisArg : this, args);
7177             }
7178             return wrapper;
7179           }
7180           function createRange(fromRight) {
7181             return function(start2, end, step) {
7182               if (step && typeof step != "number" && isIterateeCall(start2, end, step)) {
7183                 end = step = undefined2;
7184               }
7185               start2 = toFinite(start2);
7186               if (end === undefined2) {
7187                 end = start2;
7188                 start2 = 0;
7189               } else {
7190                 end = toFinite(end);
7191               }
7192               step = step === undefined2 ? start2 < end ? 1 : -1 : toFinite(step);
7193               return baseRange(start2, end, step, fromRight);
7194             };
7195           }
7196           function createRelationalOperation(operator) {
7197             return function(value, other) {
7198               if (!(typeof value == "string" && typeof other == "string")) {
7199                 value = toNumber3(value);
7200                 other = toNumber3(other);
7201               }
7202               return operator(value, other);
7203             };
7204           }
7205           function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary2, arity) {
7206             var isCurry = bitmask & WRAP_CURRY_FLAG, newHolders = isCurry ? holders : undefined2, newHoldersRight = isCurry ? undefined2 : holders, newPartials = isCurry ? partials : undefined2, newPartialsRight = isCurry ? undefined2 : partials;
7207             bitmask |= isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG;
7208             bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
7209             if (!(bitmask & WRAP_CURRY_BOUND_FLAG)) {
7210               bitmask &= ~(WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG);
7211             }
7212             var newData = [
7213               func,
7214               bitmask,
7215               thisArg,
7216               newPartials,
7217               newHolders,
7218               newPartialsRight,
7219               newHoldersRight,
7220               argPos,
7221               ary2,
7222               arity
7223             ];
7224             var result2 = wrapFunc.apply(undefined2, newData);
7225             if (isLaziable(func)) {
7226               setData(result2, newData);
7227             }
7228             result2.placeholder = placeholder;
7229             return setWrapToString(result2, func, bitmask);
7230           }
7231           function createRound(methodName) {
7232             var func = Math2[methodName];
7233             return function(number3, precision3) {
7234               number3 = toNumber3(number3);
7235               precision3 = precision3 == null ? 0 : nativeMin2(toInteger(precision3), 292);
7236               if (precision3 && nativeIsFinite(number3)) {
7237                 var pair3 = (toString2(number3) + "e").split("e"), value = func(pair3[0] + "e" + (+pair3[1] + precision3));
7238                 pair3 = (toString2(value) + "e").split("e");
7239                 return +(pair3[0] + "e" + (+pair3[1] - precision3));
7240               }
7241               return func(number3);
7242             };
7243           }
7244           var createSet = !(Set3 && 1 / setToArray2(new Set3([, -0]))[1] == INFINITY2) ? noop3 : function(values2) {
7245             return new Set3(values2);
7246           };
7247           function createToPairs(keysFunc) {
7248             return function(object) {
7249               var tag2 = getTag2(object);
7250               if (tag2 == mapTag4) {
7251                 return mapToArray2(object);
7252               }
7253               if (tag2 == setTag4) {
7254                 return setToPairs(object);
7255               }
7256               return baseToPairs(object, keysFunc(object));
7257             };
7258           }
7259           function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary2, arity) {
7260             var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
7261             if (!isBindKey && typeof func != "function") {
7262               throw new TypeError2(FUNC_ERROR_TEXT3);
7263             }
7264             var length2 = partials ? partials.length : 0;
7265             if (!length2) {
7266               bitmask &= ~(WRAP_PARTIAL_FLAG | WRAP_PARTIAL_RIGHT_FLAG);
7267               partials = holders = undefined2;
7268             }
7269             ary2 = ary2 === undefined2 ? ary2 : nativeMax2(toInteger(ary2), 0);
7270             arity = arity === undefined2 ? arity : toInteger(arity);
7271             length2 -= holders ? holders.length : 0;
7272             if (bitmask & WRAP_PARTIAL_RIGHT_FLAG) {
7273               var partialsRight = partials, holdersRight = holders;
7274               partials = holders = undefined2;
7275             }
7276             var data = isBindKey ? undefined2 : getData(func);
7277             var newData = [
7278               func,
7279               bitmask,
7280               thisArg,
7281               partials,
7282               holders,
7283               partialsRight,
7284               holdersRight,
7285               argPos,
7286               ary2,
7287               arity
7288             ];
7289             if (data) {
7290               mergeData(newData, data);
7291             }
7292             func = newData[0];
7293             bitmask = newData[1];
7294             thisArg = newData[2];
7295             partials = newData[3];
7296             holders = newData[4];
7297             arity = newData[9] = newData[9] === undefined2 ? isBindKey ? 0 : func.length : nativeMax2(newData[9] - length2, 0);
7298             if (!arity && bitmask & (WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG)) {
7299               bitmask &= ~(WRAP_CURRY_FLAG | WRAP_CURRY_RIGHT_FLAG);
7300             }
7301             if (!bitmask || bitmask == WRAP_BIND_FLAG) {
7302               var result2 = createBind(func, bitmask, thisArg);
7303             } else if (bitmask == WRAP_CURRY_FLAG || bitmask == WRAP_CURRY_RIGHT_FLAG) {
7304               result2 = createCurry(func, bitmask, arity);
7305             } else if ((bitmask == WRAP_PARTIAL_FLAG || bitmask == (WRAP_BIND_FLAG | WRAP_PARTIAL_FLAG)) && !holders.length) {
7306               result2 = createPartial(func, bitmask, thisArg, partials);
7307             } else {
7308               result2 = createHybrid.apply(undefined2, newData);
7309             }
7310             var setter = data ? baseSetData : setData;
7311             return setWrapToString(setter(result2, newData), func, bitmask);
7312           }
7313           function customDefaultsAssignIn(objValue, srcValue, key, object) {
7314             if (objValue === undefined2 || eq2(objValue, objectProto13[key]) && !hasOwnProperty10.call(object, key)) {
7315               return srcValue;
7316             }
7317             return objValue;
7318           }
7319           function customDefaultsMerge(objValue, srcValue, key, object, source, stack) {
7320             if (isObject3(objValue) && isObject3(srcValue)) {
7321               stack.set(srcValue, objValue);
7322               baseMerge(objValue, srcValue, undefined2, customDefaultsMerge, stack);
7323               stack["delete"](srcValue);
7324             }
7325             return objValue;
7326           }
7327           function customOmitClone(value) {
7328             return isPlainObject(value) ? undefined2 : value;
7329           }
7330           function equalArrays2(array2, other, bitmask, customizer, equalFunc, stack) {
7331             var isPartial = bitmask & COMPARE_PARTIAL_FLAG5, arrLength = array2.length, othLength = other.length;
7332             if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
7333               return false;
7334             }
7335             var arrStacked = stack.get(array2);
7336             var othStacked = stack.get(other);
7337             if (arrStacked && othStacked) {
7338               return arrStacked == other && othStacked == array2;
7339             }
7340             var index = -1, result2 = true, seen = bitmask & COMPARE_UNORDERED_FLAG3 ? new SetCache2() : undefined2;
7341             stack.set(array2, other);
7342             stack.set(other, array2);
7343             while (++index < arrLength) {
7344               var arrValue = array2[index], othValue = other[index];
7345               if (customizer) {
7346                 var compared = isPartial ? customizer(othValue, arrValue, index, other, array2, stack) : customizer(arrValue, othValue, index, array2, other, stack);
7347               }
7348               if (compared !== undefined2) {
7349                 if (compared) {
7350                   continue;
7351                 }
7352                 result2 = false;
7353                 break;
7354               }
7355               if (seen) {
7356                 if (!arraySome2(other, function(othValue2, othIndex) {
7357                   if (!cacheHas2(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
7358                     return seen.push(othIndex);
7359                   }
7360                 })) {
7361                   result2 = false;
7362                   break;
7363                 }
7364               } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
7365                 result2 = false;
7366                 break;
7367               }
7368             }
7369             stack["delete"](array2);
7370             stack["delete"](other);
7371             return result2;
7372           }
7373           function equalByTag2(object, other, tag2, bitmask, customizer, equalFunc, stack) {
7374             switch (tag2) {
7375               case dataViewTag4:
7376                 if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
7377                   return false;
7378                 }
7379                 object = object.buffer;
7380                 other = other.buffer;
7381               case arrayBufferTag3:
7382                 if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array3(object), new Uint8Array3(other))) {
7383                   return false;
7384                 }
7385                 return true;
7386               case boolTag3:
7387               case dateTag3:
7388               case numberTag4:
7389                 return eq2(+object, +other);
7390               case errorTag3:
7391                 return object.name == other.name && object.message == other.message;
7392               case regexpTag3:
7393               case stringTag3:
7394                 return object == other + "";
7395               case mapTag4:
7396                 var convert = mapToArray2;
7397               case setTag4:
7398                 var isPartial = bitmask & COMPARE_PARTIAL_FLAG5;
7399                 convert || (convert = setToArray2);
7400                 if (object.size != other.size && !isPartial) {
7401                   return false;
7402                 }
7403                 var stacked = stack.get(object);
7404                 if (stacked) {
7405                   return stacked == other;
7406                 }
7407                 bitmask |= COMPARE_UNORDERED_FLAG3;
7408                 stack.set(object, other);
7409                 var result2 = equalArrays2(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
7410                 stack["delete"](object);
7411                 return result2;
7412               case symbolTag3:
7413                 if (symbolValueOf2) {
7414                   return symbolValueOf2.call(object) == symbolValueOf2.call(other);
7415                 }
7416             }
7417             return false;
7418           }
7419           function equalObjects2(object, other, bitmask, customizer, equalFunc, stack) {
7420             var isPartial = bitmask & COMPARE_PARTIAL_FLAG5, objProps = getAllKeys2(object), objLength = objProps.length, othProps = getAllKeys2(other), othLength = othProps.length;
7421             if (objLength != othLength && !isPartial) {
7422               return false;
7423             }
7424             var index = objLength;
7425             while (index--) {
7426               var key = objProps[index];
7427               if (!(isPartial ? key in other : hasOwnProperty10.call(other, key))) {
7428                 return false;
7429               }
7430             }
7431             var objStacked = stack.get(object);
7432             var othStacked = stack.get(other);
7433             if (objStacked && othStacked) {
7434               return objStacked == other && othStacked == object;
7435             }
7436             var result2 = true;
7437             stack.set(object, other);
7438             stack.set(other, object);
7439             var skipCtor = isPartial;
7440             while (++index < objLength) {
7441               key = objProps[index];
7442               var objValue = object[key], othValue = other[key];
7443               if (customizer) {
7444                 var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
7445               }
7446               if (!(compared === undefined2 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
7447                 result2 = false;
7448                 break;
7449               }
7450               skipCtor || (skipCtor = key == "constructor");
7451             }
7452             if (result2 && !skipCtor) {
7453               var objCtor = object.constructor, othCtor = other.constructor;
7454               if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
7455                 result2 = false;
7456               }
7457             }
7458             stack["delete"](object);
7459             stack["delete"](other);
7460             return result2;
7461           }
7462           function flatRest(func) {
7463             return setToString(overRest(func, undefined2, flatten2), func + "");
7464           }
7465           function getAllKeys2(object) {
7466             return baseGetAllKeys2(object, keys2, getSymbols2);
7467           }
7468           function getAllKeysIn(object) {
7469             return baseGetAllKeys2(object, keysIn, getSymbolsIn);
7470           }
7471           var getData = !metaMap ? noop3 : function(func) {
7472             return metaMap.get(func);
7473           };
7474           function getFuncName(func) {
7475             var result2 = func.name + "", array2 = realNames[result2], length2 = hasOwnProperty10.call(realNames, result2) ? array2.length : 0;
7476             while (length2--) {
7477               var data = array2[length2], otherFunc = data.func;
7478               if (otherFunc == null || otherFunc == func) {
7479                 return data.name;
7480               }
7481             }
7482             return result2;
7483           }
7484           function getHolder(func) {
7485             var object = hasOwnProperty10.call(lodash, "placeholder") ? lodash : func;
7486             return object.placeholder;
7487           }
7488           function getIteratee() {
7489             var result2 = lodash.iteratee || iteratee;
7490             result2 = result2 === iteratee ? baseIteratee : result2;
7491             return arguments.length ? result2(arguments[0], arguments[1]) : result2;
7492           }
7493           function getMapData2(map3, key) {
7494             var data = map3.__data__;
7495             return isKeyable2(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
7496           }
7497           function getMatchData(object) {
7498             var result2 = keys2(object), length2 = result2.length;
7499             while (length2--) {
7500               var key = result2[length2], value = object[key];
7501               result2[length2] = [key, value, isStrictComparable(value)];
7502             }
7503             return result2;
7504           }
7505           function getNative2(object, key) {
7506             var value = getValue2(object, key);
7507             return baseIsNative2(value) ? value : undefined2;
7508           }
7509           function getRawTag2(value) {
7510             var isOwn = hasOwnProperty10.call(value, symToStringTag3), tag2 = value[symToStringTag3];
7511             try {
7512               value[symToStringTag3] = undefined2;
7513               var unmasked = true;
7514             } catch (e3) {
7515             }
7516             var result2 = nativeObjectToString3.call(value);
7517             if (unmasked) {
7518               if (isOwn) {
7519                 value[symToStringTag3] = tag2;
7520               } else {
7521                 delete value[symToStringTag3];
7522               }
7523             }
7524             return result2;
7525           }
7526           var getSymbols2 = !nativeGetSymbols2 ? stubArray2 : function(object) {
7527             if (object == null) {
7528               return [];
7529             }
7530             object = Object2(object);
7531             return arrayFilter2(nativeGetSymbols2(object), function(symbol) {
7532               return propertyIsEnumerable3.call(object, symbol);
7533             });
7534           };
7535           var getSymbolsIn = !nativeGetSymbols2 ? stubArray2 : function(object) {
7536             var result2 = [];
7537             while (object) {
7538               arrayPush2(result2, getSymbols2(object));
7539               object = getPrototype(object);
7540             }
7541             return result2;
7542           };
7543           var getTag2 = baseGetTag2;
7544           if (DataView3 && getTag2(new DataView3(new ArrayBuffer(1))) != dataViewTag4 || Map3 && getTag2(new Map3()) != mapTag4 || Promise3 && getTag2(Promise3.resolve()) != promiseTag2 || Set3 && getTag2(new Set3()) != setTag4 || WeakMap2 && getTag2(new WeakMap2()) != weakMapTag3) {
7545             getTag2 = function(value) {
7546               var result2 = baseGetTag2(value), Ctor = result2 == objectTag4 ? value.constructor : undefined2, ctorString = Ctor ? toSource2(Ctor) : "";
7547               if (ctorString) {
7548                 switch (ctorString) {
7549                   case dataViewCtorString2:
7550                     return dataViewTag4;
7551                   case mapCtorString2:
7552                     return mapTag4;
7553                   case promiseCtorString2:
7554                     return promiseTag2;
7555                   case setCtorString2:
7556                     return setTag4;
7557                   case weakMapCtorString2:
7558                     return weakMapTag3;
7559                 }
7560               }
7561               return result2;
7562             };
7563           }
7564           function getView(start2, end, transforms) {
7565             var index = -1, length2 = transforms.length;
7566             while (++index < length2) {
7567               var data = transforms[index], size2 = data.size;
7568               switch (data.type) {
7569                 case "drop":
7570                   start2 += size2;
7571                   break;
7572                 case "dropRight":
7573                   end -= size2;
7574                   break;
7575                 case "take":
7576                   end = nativeMin2(end, start2 + size2);
7577                   break;
7578                 case "takeRight":
7579                   start2 = nativeMax2(start2, end - size2);
7580                   break;
7581               }
7582             }
7583             return { "start": start2, "end": end };
7584           }
7585           function getWrapDetails(source) {
7586             var match = source.match(reWrapDetails);
7587             return match ? match[1].split(reSplitDetails) : [];
7588           }
7589           function hasPath(object, path, hasFunc) {
7590             path = castPath(path, object);
7591             var index = -1, length2 = path.length, result2 = false;
7592             while (++index < length2) {
7593               var key = toKey(path[index]);
7594               if (!(result2 = object != null && hasFunc(object, key))) {
7595                 break;
7596               }
7597               object = object[key];
7598             }
7599             if (result2 || ++index != length2) {
7600               return result2;
7601             }
7602             length2 = object == null ? 0 : object.length;
7603             return !!length2 && isLength2(length2) && isIndex2(key, length2) && (isArray2(object) || isArguments2(object));
7604           }
7605           function initCloneArray(array2) {
7606             var length2 = array2.length, result2 = new array2.constructor(length2);
7607             if (length2 && typeof array2[0] == "string" && hasOwnProperty10.call(array2, "index")) {
7608               result2.index = array2.index;
7609               result2.input = array2.input;
7610             }
7611             return result2;
7612           }
7613           function initCloneObject(object) {
7614             return typeof object.constructor == "function" && !isPrototype2(object) ? baseCreate(getPrototype(object)) : {};
7615           }
7616           function initCloneByTag(object, tag2, isDeep) {
7617             var Ctor = object.constructor;
7618             switch (tag2) {
7619               case arrayBufferTag3:
7620                 return cloneArrayBuffer(object);
7621               case boolTag3:
7622               case dateTag3:
7623                 return new Ctor(+object);
7624               case dataViewTag4:
7625                 return cloneDataView(object, isDeep);
7626               case float32Tag2:
7627               case float64Tag2:
7628               case int8Tag2:
7629               case int16Tag2:
7630               case int32Tag2:
7631               case uint8Tag2:
7632               case uint8ClampedTag2:
7633               case uint16Tag2:
7634               case uint32Tag2:
7635                 return cloneTypedArray(object, isDeep);
7636               case mapTag4:
7637                 return new Ctor();
7638               case numberTag4:
7639               case stringTag3:
7640                 return new Ctor(object);
7641               case regexpTag3:
7642                 return cloneRegExp(object);
7643               case setTag4:
7644                 return new Ctor();
7645               case symbolTag3:
7646                 return cloneSymbol(object);
7647             }
7648           }
7649           function insertWrapDetails(source, details) {
7650             var length2 = details.length;
7651             if (!length2) {
7652               return source;
7653             }
7654             var lastIndex = length2 - 1;
7655             details[lastIndex] = (length2 > 1 ? "& " : "") + details[lastIndex];
7656             details = details.join(length2 > 2 ? ", " : " ");
7657             return source.replace(reWrapComment, "{\n/* [wrapped with " + details + "] */\n");
7658           }
7659           function isFlattenable(value) {
7660             return isArray2(value) || isArguments2(value) || !!(spreadableSymbol && value && value[spreadableSymbol]);
7661           }
7662           function isIndex2(value, length2) {
7663             var type2 = typeof value;
7664             length2 = length2 == null ? MAX_SAFE_INTEGER4 : length2;
7665             return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint2.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
7666           }
7667           function isIterateeCall(value, index, object) {
7668             if (!isObject3(object)) {
7669               return false;
7670             }
7671             var type2 = typeof index;
7672             if (type2 == "number" ? isArrayLike2(object) && isIndex2(index, object.length) : type2 == "string" && index in object) {
7673               return eq2(object[index], value);
7674             }
7675             return false;
7676           }
7677           function isKey(value, object) {
7678             if (isArray2(value)) {
7679               return false;
7680             }
7681             var type2 = typeof value;
7682             if (type2 == "number" || type2 == "symbol" || type2 == "boolean" || value == null || isSymbol2(value)) {
7683               return true;
7684             }
7685             return reIsPlainProp.test(value) || !reIsDeepProp.test(value) || object != null && value in Object2(object);
7686           }
7687           function isKeyable2(value) {
7688             var type2 = typeof value;
7689             return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
7690           }
7691           function isLaziable(func) {
7692             var funcName = getFuncName(func), other = lodash[funcName];
7693             if (typeof other != "function" || !(funcName in LazyWrapper.prototype)) {
7694               return false;
7695             }
7696             if (func === other) {
7697               return true;
7698             }
7699             var data = getData(other);
7700             return !!data && func === data[0];
7701           }
7702           function isMasked2(func) {
7703             return !!maskSrcKey2 && maskSrcKey2 in func;
7704           }
7705           var isMaskable = coreJsData2 ? isFunction2 : stubFalse2;
7706           function isPrototype2(value) {
7707             var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto13;
7708             return value === proto;
7709           }
7710           function isStrictComparable(value) {
7711             return value === value && !isObject3(value);
7712           }
7713           function matchesStrictComparable(key, srcValue) {
7714             return function(object) {
7715               if (object == null) {
7716                 return false;
7717               }
7718               return object[key] === srcValue && (srcValue !== undefined2 || key in Object2(object));
7719             };
7720           }
7721           function memoizeCapped(func) {
7722             var result2 = memoize(func, function(key) {
7723               if (cache.size === MAX_MEMOIZE_SIZE) {
7724                 cache.clear();
7725               }
7726               return key;
7727             });
7728             var cache = result2.cache;
7729             return result2;
7730           }
7731           function mergeData(data, source) {
7732             var bitmask = data[1], srcBitmask = source[1], newBitmask = bitmask | srcBitmask, isCommon = newBitmask < (WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG | WRAP_ARY_FLAG);
7733             var isCombo = srcBitmask == WRAP_ARY_FLAG && bitmask == WRAP_CURRY_FLAG || srcBitmask == WRAP_ARY_FLAG && bitmask == WRAP_REARG_FLAG && data[7].length <= source[8] || srcBitmask == (WRAP_ARY_FLAG | WRAP_REARG_FLAG) && source[7].length <= source[8] && bitmask == WRAP_CURRY_FLAG;
7734             if (!(isCommon || isCombo)) {
7735               return data;
7736             }
7737             if (srcBitmask & WRAP_BIND_FLAG) {
7738               data[2] = source[2];
7739               newBitmask |= bitmask & WRAP_BIND_FLAG ? 0 : WRAP_CURRY_BOUND_FLAG;
7740             }
7741             var value = source[3];
7742             if (value) {
7743               var partials = data[3];
7744               data[3] = partials ? composeArgs(partials, value, source[4]) : value;
7745               data[4] = partials ? replaceHolders(data[3], PLACEHOLDER) : source[4];
7746             }
7747             value = source[5];
7748             if (value) {
7749               partials = data[5];
7750               data[5] = partials ? composeArgsRight(partials, value, source[6]) : value;
7751               data[6] = partials ? replaceHolders(data[5], PLACEHOLDER) : source[6];
7752             }
7753             value = source[7];
7754             if (value) {
7755               data[7] = value;
7756             }
7757             if (srcBitmask & WRAP_ARY_FLAG) {
7758               data[8] = data[8] == null ? source[8] : nativeMin2(data[8], source[8]);
7759             }
7760             if (data[9] == null) {
7761               data[9] = source[9];
7762             }
7763             data[0] = source[0];
7764             data[1] = newBitmask;
7765             return data;
7766           }
7767           function nativeKeysIn(object) {
7768             var result2 = [];
7769             if (object != null) {
7770               for (var key in Object2(object)) {
7771                 result2.push(key);
7772               }
7773             }
7774             return result2;
7775           }
7776           function objectToString2(value) {
7777             return nativeObjectToString3.call(value);
7778           }
7779           function overRest(func, start2, transform3) {
7780             start2 = nativeMax2(start2 === undefined2 ? func.length - 1 : start2, 0);
7781             return function() {
7782               var args = arguments, index = -1, length2 = nativeMax2(args.length - start2, 0), array2 = Array2(length2);
7783               while (++index < length2) {
7784                 array2[index] = args[start2 + index];
7785               }
7786               index = -1;
7787               var otherArgs = Array2(start2 + 1);
7788               while (++index < start2) {
7789                 otherArgs[index] = args[index];
7790               }
7791               otherArgs[start2] = transform3(array2);
7792               return apply(func, this, otherArgs);
7793             };
7794           }
7795           function parent(object, path) {
7796             return path.length < 2 ? object : baseGet(object, baseSlice(path, 0, -1));
7797           }
7798           function reorder(array2, indexes) {
7799             var arrLength = array2.length, length2 = nativeMin2(indexes.length, arrLength), oldArray = copyArray(array2);
7800             while (length2--) {
7801               var index = indexes[length2];
7802               array2[length2] = isIndex2(index, arrLength) ? oldArray[index] : undefined2;
7803             }
7804             return array2;
7805           }
7806           function safeGet(object, key) {
7807             if (key === "constructor" && typeof object[key] === "function") {
7808               return;
7809             }
7810             if (key == "__proto__") {
7811               return;
7812             }
7813             return object[key];
7814           }
7815           var setData = shortOut(baseSetData);
7816           var setTimeout2 = ctxSetTimeout || function(func, wait) {
7817             return root3.setTimeout(func, wait);
7818           };
7819           var setToString = shortOut(baseSetToString);
7820           function setWrapToString(wrapper, reference, bitmask) {
7821             var source = reference + "";
7822             return setToString(wrapper, insertWrapDetails(source, updateWrapDetails(getWrapDetails(source), bitmask)));
7823           }
7824           function shortOut(func) {
7825             var count = 0, lastCalled = 0;
7826             return function() {
7827               var stamp = nativeNow(), remaining = HOT_SPAN - (stamp - lastCalled);
7828               lastCalled = stamp;
7829               if (remaining > 0) {
7830                 if (++count >= HOT_COUNT) {
7831                   return arguments[0];
7832                 }
7833               } else {
7834                 count = 0;
7835               }
7836               return func.apply(undefined2, arguments);
7837             };
7838           }
7839           function shuffleSelf(array2, size2) {
7840             var index = -1, length2 = array2.length, lastIndex = length2 - 1;
7841             size2 = size2 === undefined2 ? length2 : size2;
7842             while (++index < size2) {
7843               var rand = baseRandom(index, lastIndex), value = array2[rand];
7844               array2[rand] = array2[index];
7845               array2[index] = value;
7846             }
7847             array2.length = size2;
7848             return array2;
7849           }
7850           var stringToPath = memoizeCapped(function(string) {
7851             var result2 = [];
7852             if (string.charCodeAt(0) === 46) {
7853               result2.push("");
7854             }
7855             string.replace(rePropName, function(match, number3, quote, subString) {
7856               result2.push(quote ? subString.replace(reEscapeChar, "$1") : number3 || match);
7857             });
7858             return result2;
7859           });
7860           function toKey(value) {
7861             if (typeof value == "string" || isSymbol2(value)) {
7862               return value;
7863             }
7864             var result2 = value + "";
7865             return result2 == "0" && 1 / value == -INFINITY2 ? "-0" : result2;
7866           }
7867           function toSource2(func) {
7868             if (func != null) {
7869               try {
7870                 return funcToString3.call(func);
7871               } catch (e3) {
7872               }
7873               try {
7874                 return func + "";
7875               } catch (e3) {
7876               }
7877             }
7878             return "";
7879           }
7880           function updateWrapDetails(details, bitmask) {
7881             arrayEach(wrapFlags, function(pair3) {
7882               var value = "_." + pair3[0];
7883               if (bitmask & pair3[1] && !arrayIncludes(details, value)) {
7884                 details.push(value);
7885               }
7886             });
7887             return details.sort();
7888           }
7889           function wrapperClone(wrapper) {
7890             if (wrapper instanceof LazyWrapper) {
7891               return wrapper.clone();
7892             }
7893             var result2 = new LodashWrapper(wrapper.__wrapped__, wrapper.__chain__);
7894             result2.__actions__ = copyArray(wrapper.__actions__);
7895             result2.__index__ = wrapper.__index__;
7896             result2.__values__ = wrapper.__values__;
7897             return result2;
7898           }
7899           function chunk(array2, size2, guard) {
7900             if (guard ? isIterateeCall(array2, size2, guard) : size2 === undefined2) {
7901               size2 = 1;
7902             } else {
7903               size2 = nativeMax2(toInteger(size2), 0);
7904             }
7905             var length2 = array2 == null ? 0 : array2.length;
7906             if (!length2 || size2 < 1) {
7907               return [];
7908             }
7909             var index = 0, resIndex = 0, result2 = Array2(nativeCeil(length2 / size2));
7910             while (index < length2) {
7911               result2[resIndex++] = baseSlice(array2, index, index += size2);
7912             }
7913             return result2;
7914           }
7915           function compact(array2) {
7916             var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result2 = [];
7917             while (++index < length2) {
7918               var value = array2[index];
7919               if (value) {
7920                 result2[resIndex++] = value;
7921               }
7922             }
7923             return result2;
7924           }
7925           function concat() {
7926             var length2 = arguments.length;
7927             if (!length2) {
7928               return [];
7929             }
7930             var args = Array2(length2 - 1), array2 = arguments[0], index = length2;
7931             while (index--) {
7932               args[index - 1] = arguments[index];
7933             }
7934             return arrayPush2(isArray2(array2) ? copyArray(array2) : [array2], baseFlatten(args, 1));
7935           }
7936           var difference2 = baseRest(function(array2, values2) {
7937             return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true)) : [];
7938           });
7939           var differenceBy = baseRest(function(array2, values2) {
7940             var iteratee2 = last(values2);
7941             if (isArrayLikeObject(iteratee2)) {
7942               iteratee2 = undefined2;
7943             }
7944             return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true), getIteratee(iteratee2, 2)) : [];
7945           });
7946           var differenceWith = baseRest(function(array2, values2) {
7947             var comparator = last(values2);
7948             if (isArrayLikeObject(comparator)) {
7949               comparator = undefined2;
7950             }
7951             return isArrayLikeObject(array2) ? baseDifference(array2, baseFlatten(values2, 1, isArrayLikeObject, true), undefined2, comparator) : [];
7952           });
7953           function drop(array2, n3, guard) {
7954             var length2 = array2 == null ? 0 : array2.length;
7955             if (!length2) {
7956               return [];
7957             }
7958             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
7959             return baseSlice(array2, n3 < 0 ? 0 : n3, length2);
7960           }
7961           function dropRight(array2, n3, guard) {
7962             var length2 = array2 == null ? 0 : array2.length;
7963             if (!length2) {
7964               return [];
7965             }
7966             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
7967             n3 = length2 - n3;
7968             return baseSlice(array2, 0, n3 < 0 ? 0 : n3);
7969           }
7970           function dropRightWhile(array2, predicate) {
7971             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), true, true) : [];
7972           }
7973           function dropWhile(array2, predicate) {
7974             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), true) : [];
7975           }
7976           function fill(array2, value, start2, end) {
7977             var length2 = array2 == null ? 0 : array2.length;
7978             if (!length2) {
7979               return [];
7980             }
7981             if (start2 && typeof start2 != "number" && isIterateeCall(array2, value, start2)) {
7982               start2 = 0;
7983               end = length2;
7984             }
7985             return baseFill(array2, value, start2, end);
7986           }
7987           function findIndex(array2, predicate, fromIndex) {
7988             var length2 = array2 == null ? 0 : array2.length;
7989             if (!length2) {
7990               return -1;
7991             }
7992             var index = fromIndex == null ? 0 : toInteger(fromIndex);
7993             if (index < 0) {
7994               index = nativeMax2(length2 + index, 0);
7995             }
7996             return baseFindIndex(array2, getIteratee(predicate, 3), index);
7997           }
7998           function findLastIndex(array2, predicate, fromIndex) {
7999             var length2 = array2 == null ? 0 : array2.length;
8000             if (!length2) {
8001               return -1;
8002             }
8003             var index = length2 - 1;
8004             if (fromIndex !== undefined2) {
8005               index = toInteger(fromIndex);
8006               index = fromIndex < 0 ? nativeMax2(length2 + index, 0) : nativeMin2(index, length2 - 1);
8007             }
8008             return baseFindIndex(array2, getIteratee(predicate, 3), index, true);
8009           }
8010           function flatten2(array2) {
8011             var length2 = array2 == null ? 0 : array2.length;
8012             return length2 ? baseFlatten(array2, 1) : [];
8013           }
8014           function flattenDeep(array2) {
8015             var length2 = array2 == null ? 0 : array2.length;
8016             return length2 ? baseFlatten(array2, INFINITY2) : [];
8017           }
8018           function flattenDepth(array2, depth) {
8019             var length2 = array2 == null ? 0 : array2.length;
8020             if (!length2) {
8021               return [];
8022             }
8023             depth = depth === undefined2 ? 1 : toInteger(depth);
8024             return baseFlatten(array2, depth);
8025           }
8026           function fromPairs(pairs2) {
8027             var index = -1, length2 = pairs2 == null ? 0 : pairs2.length, result2 = {};
8028             while (++index < length2) {
8029               var pair3 = pairs2[index];
8030               result2[pair3[0]] = pair3[1];
8031             }
8032             return result2;
8033           }
8034           function head(array2) {
8035             return array2 && array2.length ? array2[0] : undefined2;
8036           }
8037           function indexOf(array2, value, fromIndex) {
8038             var length2 = array2 == null ? 0 : array2.length;
8039             if (!length2) {
8040               return -1;
8041             }
8042             var index = fromIndex == null ? 0 : toInteger(fromIndex);
8043             if (index < 0) {
8044               index = nativeMax2(length2 + index, 0);
8045             }
8046             return baseIndexOf(array2, value, index);
8047           }
8048           function initial(array2) {
8049             var length2 = array2 == null ? 0 : array2.length;
8050             return length2 ? baseSlice(array2, 0, -1) : [];
8051           }
8052           var intersection2 = baseRest(function(arrays) {
8053             var mapped = arrayMap2(arrays, castArrayLikeObject);
8054             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped) : [];
8055           });
8056           var intersectionBy = baseRest(function(arrays) {
8057             var iteratee2 = last(arrays), mapped = arrayMap2(arrays, castArrayLikeObject);
8058             if (iteratee2 === last(mapped)) {
8059               iteratee2 = undefined2;
8060             } else {
8061               mapped.pop();
8062             }
8063             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, getIteratee(iteratee2, 2)) : [];
8064           });
8065           var intersectionWith = baseRest(function(arrays) {
8066             var comparator = last(arrays), mapped = arrayMap2(arrays, castArrayLikeObject);
8067             comparator = typeof comparator == "function" ? comparator : undefined2;
8068             if (comparator) {
8069               mapped.pop();
8070             }
8071             return mapped.length && mapped[0] === arrays[0] ? baseIntersection(mapped, undefined2, comparator) : [];
8072           });
8073           function join(array2, separator) {
8074             return array2 == null ? "" : nativeJoin.call(array2, separator);
8075           }
8076           function last(array2) {
8077             var length2 = array2 == null ? 0 : array2.length;
8078             return length2 ? array2[length2 - 1] : undefined2;
8079           }
8080           function lastIndexOf(array2, value, fromIndex) {
8081             var length2 = array2 == null ? 0 : array2.length;
8082             if (!length2) {
8083               return -1;
8084             }
8085             var index = length2;
8086             if (fromIndex !== undefined2) {
8087               index = toInteger(fromIndex);
8088               index = index < 0 ? nativeMax2(length2 + index, 0) : nativeMin2(index, length2 - 1);
8089             }
8090             return value === value ? strictLastIndexOf(array2, value, index) : baseFindIndex(array2, baseIsNaN, index, true);
8091           }
8092           function nth(array2, n3) {
8093             return array2 && array2.length ? baseNth(array2, toInteger(n3)) : undefined2;
8094           }
8095           var pull = baseRest(pullAll);
8096           function pullAll(array2, values2) {
8097             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2) : array2;
8098           }
8099           function pullAllBy(array2, values2, iteratee2) {
8100             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2, getIteratee(iteratee2, 2)) : array2;
8101           }
8102           function pullAllWith(array2, values2, comparator) {
8103             return array2 && array2.length && values2 && values2.length ? basePullAll(array2, values2, undefined2, comparator) : array2;
8104           }
8105           var pullAt = flatRest(function(array2, indexes) {
8106             var length2 = array2 == null ? 0 : array2.length, result2 = baseAt(array2, indexes);
8107             basePullAt(array2, arrayMap2(indexes, function(index) {
8108               return isIndex2(index, length2) ? +index : index;
8109             }).sort(compareAscending));
8110             return result2;
8111           });
8112           function remove2(array2, predicate) {
8113             var result2 = [];
8114             if (!(array2 && array2.length)) {
8115               return result2;
8116             }
8117             var index = -1, indexes = [], length2 = array2.length;
8118             predicate = getIteratee(predicate, 3);
8119             while (++index < length2) {
8120               var value = array2[index];
8121               if (predicate(value, index, array2)) {
8122                 result2.push(value);
8123                 indexes.push(index);
8124               }
8125             }
8126             basePullAt(array2, indexes);
8127             return result2;
8128           }
8129           function reverse(array2) {
8130             return array2 == null ? array2 : nativeReverse.call(array2);
8131           }
8132           function slice(array2, start2, end) {
8133             var length2 = array2 == null ? 0 : array2.length;
8134             if (!length2) {
8135               return [];
8136             }
8137             if (end && typeof end != "number" && isIterateeCall(array2, start2, end)) {
8138               start2 = 0;
8139               end = length2;
8140             } else {
8141               start2 = start2 == null ? 0 : toInteger(start2);
8142               end = end === undefined2 ? length2 : toInteger(end);
8143             }
8144             return baseSlice(array2, start2, end);
8145           }
8146           function sortedIndex(array2, value) {
8147             return baseSortedIndex(array2, value);
8148           }
8149           function sortedIndexBy(array2, value, iteratee2) {
8150             return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2));
8151           }
8152           function sortedIndexOf(array2, value) {
8153             var length2 = array2 == null ? 0 : array2.length;
8154             if (length2) {
8155               var index = baseSortedIndex(array2, value);
8156               if (index < length2 && eq2(array2[index], value)) {
8157                 return index;
8158               }
8159             }
8160             return -1;
8161           }
8162           function sortedLastIndex(array2, value) {
8163             return baseSortedIndex(array2, value, true);
8164           }
8165           function sortedLastIndexBy(array2, value, iteratee2) {
8166             return baseSortedIndexBy(array2, value, getIteratee(iteratee2, 2), true);
8167           }
8168           function sortedLastIndexOf(array2, value) {
8169             var length2 = array2 == null ? 0 : array2.length;
8170             if (length2) {
8171               var index = baseSortedIndex(array2, value, true) - 1;
8172               if (eq2(array2[index], value)) {
8173                 return index;
8174               }
8175             }
8176             return -1;
8177           }
8178           function sortedUniq(array2) {
8179             return array2 && array2.length ? baseSortedUniq(array2) : [];
8180           }
8181           function sortedUniqBy(array2, iteratee2) {
8182             return array2 && array2.length ? baseSortedUniq(array2, getIteratee(iteratee2, 2)) : [];
8183           }
8184           function tail(array2) {
8185             var length2 = array2 == null ? 0 : array2.length;
8186             return length2 ? baseSlice(array2, 1, length2) : [];
8187           }
8188           function take(array2, n3, guard) {
8189             if (!(array2 && array2.length)) {
8190               return [];
8191             }
8192             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
8193             return baseSlice(array2, 0, n3 < 0 ? 0 : n3);
8194           }
8195           function takeRight(array2, n3, guard) {
8196             var length2 = array2 == null ? 0 : array2.length;
8197             if (!length2) {
8198               return [];
8199             }
8200             n3 = guard || n3 === undefined2 ? 1 : toInteger(n3);
8201             n3 = length2 - n3;
8202             return baseSlice(array2, n3 < 0 ? 0 : n3, length2);
8203           }
8204           function takeRightWhile(array2, predicate) {
8205             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3), false, true) : [];
8206           }
8207           function takeWhile(array2, predicate) {
8208             return array2 && array2.length ? baseWhile(array2, getIteratee(predicate, 3)) : [];
8209           }
8210           var union2 = baseRest(function(arrays) {
8211             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true));
8212           });
8213           var unionBy = baseRest(function(arrays) {
8214             var iteratee2 = last(arrays);
8215             if (isArrayLikeObject(iteratee2)) {
8216               iteratee2 = undefined2;
8217             }
8218             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), getIteratee(iteratee2, 2));
8219           });
8220           var unionWith = baseRest(function(arrays) {
8221             var comparator = last(arrays);
8222             comparator = typeof comparator == "function" ? comparator : undefined2;
8223             return baseUniq(baseFlatten(arrays, 1, isArrayLikeObject, true), undefined2, comparator);
8224           });
8225           function uniq(array2) {
8226             return array2 && array2.length ? baseUniq(array2) : [];
8227           }
8228           function uniqBy(array2, iteratee2) {
8229             return array2 && array2.length ? baseUniq(array2, getIteratee(iteratee2, 2)) : [];
8230           }
8231           function uniqWith(array2, comparator) {
8232             comparator = typeof comparator == "function" ? comparator : undefined2;
8233             return array2 && array2.length ? baseUniq(array2, undefined2, comparator) : [];
8234           }
8235           function unzip(array2) {
8236             if (!(array2 && array2.length)) {
8237               return [];
8238             }
8239             var length2 = 0;
8240             array2 = arrayFilter2(array2, function(group) {
8241               if (isArrayLikeObject(group)) {
8242                 length2 = nativeMax2(group.length, length2);
8243                 return true;
8244               }
8245             });
8246             return baseTimes2(length2, function(index) {
8247               return arrayMap2(array2, baseProperty(index));
8248             });
8249           }
8250           function unzipWith(array2, iteratee2) {
8251             if (!(array2 && array2.length)) {
8252               return [];
8253             }
8254             var result2 = unzip(array2);
8255             if (iteratee2 == null) {
8256               return result2;
8257             }
8258             return arrayMap2(result2, function(group) {
8259               return apply(iteratee2, undefined2, group);
8260             });
8261           }
8262           var without = baseRest(function(array2, values2) {
8263             return isArrayLikeObject(array2) ? baseDifference(array2, values2) : [];
8264           });
8265           var xor = baseRest(function(arrays) {
8266             return baseXor(arrayFilter2(arrays, isArrayLikeObject));
8267           });
8268           var xorBy = baseRest(function(arrays) {
8269             var iteratee2 = last(arrays);
8270             if (isArrayLikeObject(iteratee2)) {
8271               iteratee2 = undefined2;
8272             }
8273             return baseXor(arrayFilter2(arrays, isArrayLikeObject), getIteratee(iteratee2, 2));
8274           });
8275           var xorWith = baseRest(function(arrays) {
8276             var comparator = last(arrays);
8277             comparator = typeof comparator == "function" ? comparator : undefined2;
8278             return baseXor(arrayFilter2(arrays, isArrayLikeObject), undefined2, comparator);
8279           });
8280           var zip = baseRest(unzip);
8281           function zipObject(props, values2) {
8282             return baseZipObject(props || [], values2 || [], assignValue);
8283           }
8284           function zipObjectDeep(props, values2) {
8285             return baseZipObject(props || [], values2 || [], baseSet);
8286           }
8287           var zipWith = baseRest(function(arrays) {
8288             var length2 = arrays.length, iteratee2 = length2 > 1 ? arrays[length2 - 1] : undefined2;
8289             iteratee2 = typeof iteratee2 == "function" ? (arrays.pop(), iteratee2) : undefined2;
8290             return unzipWith(arrays, iteratee2);
8291           });
8292           function chain(value) {
8293             var result2 = lodash(value);
8294             result2.__chain__ = true;
8295             return result2;
8296           }
8297           function tap(value, interceptor) {
8298             interceptor(value);
8299             return value;
8300           }
8301           function thru(value, interceptor) {
8302             return interceptor(value);
8303           }
8304           var wrapperAt = flatRest(function(paths) {
8305             var length2 = paths.length, start2 = length2 ? paths[0] : 0, value = this.__wrapped__, interceptor = function(object) {
8306               return baseAt(object, paths);
8307             };
8308             if (length2 > 1 || this.__actions__.length || !(value instanceof LazyWrapper) || !isIndex2(start2)) {
8309               return this.thru(interceptor);
8310             }
8311             value = value.slice(start2, +start2 + (length2 ? 1 : 0));
8312             value.__actions__.push({
8313               "func": thru,
8314               "args": [interceptor],
8315               "thisArg": undefined2
8316             });
8317             return new LodashWrapper(value, this.__chain__).thru(function(array2) {
8318               if (length2 && !array2.length) {
8319                 array2.push(undefined2);
8320               }
8321               return array2;
8322             });
8323           });
8324           function wrapperChain() {
8325             return chain(this);
8326           }
8327           function wrapperCommit() {
8328             return new LodashWrapper(this.value(), this.__chain__);
8329           }
8330           function wrapperNext() {
8331             if (this.__values__ === undefined2) {
8332               this.__values__ = toArray(this.value());
8333             }
8334             var done = this.__index__ >= this.__values__.length, value = done ? undefined2 : this.__values__[this.__index__++];
8335             return { "done": done, "value": value };
8336           }
8337           function wrapperToIterator() {
8338             return this;
8339           }
8340           function wrapperPlant(value) {
8341             var result2, parent2 = this;
8342             while (parent2 instanceof baseLodash) {
8343               var clone3 = wrapperClone(parent2);
8344               clone3.__index__ = 0;
8345               clone3.__values__ = undefined2;
8346               if (result2) {
8347                 previous.__wrapped__ = clone3;
8348               } else {
8349                 result2 = clone3;
8350               }
8351               var previous = clone3;
8352               parent2 = parent2.__wrapped__;
8353             }
8354             previous.__wrapped__ = value;
8355             return result2;
8356           }
8357           function wrapperReverse() {
8358             var value = this.__wrapped__;
8359             if (value instanceof LazyWrapper) {
8360               var wrapped = value;
8361               if (this.__actions__.length) {
8362                 wrapped = new LazyWrapper(this);
8363               }
8364               wrapped = wrapped.reverse();
8365               wrapped.__actions__.push({
8366                 "func": thru,
8367                 "args": [reverse],
8368                 "thisArg": undefined2
8369               });
8370               return new LodashWrapper(wrapped, this.__chain__);
8371             }
8372             return this.thru(reverse);
8373           }
8374           function wrapperValue() {
8375             return baseWrapperValue(this.__wrapped__, this.__actions__);
8376           }
8377           var countBy = createAggregator(function(result2, value, key) {
8378             if (hasOwnProperty10.call(result2, key)) {
8379               ++result2[key];
8380             } else {
8381               baseAssignValue(result2, key, 1);
8382             }
8383           });
8384           function every(collection, predicate, guard) {
8385             var func = isArray2(collection) ? arrayEvery : baseEvery;
8386             if (guard && isIterateeCall(collection, predicate, guard)) {
8387               predicate = undefined2;
8388             }
8389             return func(collection, getIteratee(predicate, 3));
8390           }
8391           function filter2(collection, predicate) {
8392             var func = isArray2(collection) ? arrayFilter2 : baseFilter;
8393             return func(collection, getIteratee(predicate, 3));
8394           }
8395           var find2 = createFind(findIndex);
8396           var findLast = createFind(findLastIndex);
8397           function flatMap(collection, iteratee2) {
8398             return baseFlatten(map2(collection, iteratee2), 1);
8399           }
8400           function flatMapDeep(collection, iteratee2) {
8401             return baseFlatten(map2(collection, iteratee2), INFINITY2);
8402           }
8403           function flatMapDepth(collection, iteratee2, depth) {
8404             depth = depth === undefined2 ? 1 : toInteger(depth);
8405             return baseFlatten(map2(collection, iteratee2), depth);
8406           }
8407           function forEach(collection, iteratee2) {
8408             var func = isArray2(collection) ? arrayEach : baseEach;
8409             return func(collection, getIteratee(iteratee2, 3));
8410           }
8411           function forEachRight(collection, iteratee2) {
8412             var func = isArray2(collection) ? arrayEachRight : baseEachRight;
8413             return func(collection, getIteratee(iteratee2, 3));
8414           }
8415           var groupBy = createAggregator(function(result2, value, key) {
8416             if (hasOwnProperty10.call(result2, key)) {
8417               result2[key].push(value);
8418             } else {
8419               baseAssignValue(result2, key, [value]);
8420             }
8421           });
8422           function includes(collection, value, fromIndex, guard) {
8423             collection = isArrayLike2(collection) ? collection : values(collection);
8424             fromIndex = fromIndex && !guard ? toInteger(fromIndex) : 0;
8425             var length2 = collection.length;
8426             if (fromIndex < 0) {
8427               fromIndex = nativeMax2(length2 + fromIndex, 0);
8428             }
8429             return isString(collection) ? fromIndex <= length2 && collection.indexOf(value, fromIndex) > -1 : !!length2 && baseIndexOf(collection, value, fromIndex) > -1;
8430           }
8431           var invokeMap = baseRest(function(collection, path, args) {
8432             var index = -1, isFunc = typeof path == "function", result2 = isArrayLike2(collection) ? Array2(collection.length) : [];
8433             baseEach(collection, function(value) {
8434               result2[++index] = isFunc ? apply(path, value, args) : baseInvoke(value, path, args);
8435             });
8436             return result2;
8437           });
8438           var keyBy = createAggregator(function(result2, value, key) {
8439             baseAssignValue(result2, key, value);
8440           });
8441           function map2(collection, iteratee2) {
8442             var func = isArray2(collection) ? arrayMap2 : baseMap;
8443             return func(collection, getIteratee(iteratee2, 3));
8444           }
8445           function orderBy(collection, iteratees, orders, guard) {
8446             if (collection == null) {
8447               return [];
8448             }
8449             if (!isArray2(iteratees)) {
8450               iteratees = iteratees == null ? [] : [iteratees];
8451             }
8452             orders = guard ? undefined2 : orders;
8453             if (!isArray2(orders)) {
8454               orders = orders == null ? [] : [orders];
8455             }
8456             return baseOrderBy(collection, iteratees, orders);
8457           }
8458           var partition = createAggregator(function(result2, value, key) {
8459             result2[key ? 0 : 1].push(value);
8460           }, function() {
8461             return [[], []];
8462           });
8463           function reduce(collection, iteratee2, accumulator) {
8464             var func = isArray2(collection) ? arrayReduce : baseReduce, initAccum = arguments.length < 3;
8465             return func(collection, getIteratee(iteratee2, 4), accumulator, initAccum, baseEach);
8466           }
8467           function reduceRight(collection, iteratee2, accumulator) {
8468             var func = isArray2(collection) ? arrayReduceRight : baseReduce, initAccum = arguments.length < 3;
8469             return func(collection, getIteratee(iteratee2, 4), accumulator, initAccum, baseEachRight);
8470           }
8471           function reject(collection, predicate) {
8472             var func = isArray2(collection) ? arrayFilter2 : baseFilter;
8473             return func(collection, negate(getIteratee(predicate, 3)));
8474           }
8475           function sample(collection) {
8476             var func = isArray2(collection) ? arraySample : baseSample;
8477             return func(collection);
8478           }
8479           function sampleSize(collection, n3, guard) {
8480             if (guard ? isIterateeCall(collection, n3, guard) : n3 === undefined2) {
8481               n3 = 1;
8482             } else {
8483               n3 = toInteger(n3);
8484             }
8485             var func = isArray2(collection) ? arraySampleSize : baseSampleSize;
8486             return func(collection, n3);
8487           }
8488           function shuffle(collection) {
8489             var func = isArray2(collection) ? arrayShuffle : baseShuffle;
8490             return func(collection);
8491           }
8492           function size(collection) {
8493             if (collection == null) {
8494               return 0;
8495             }
8496             if (isArrayLike2(collection)) {
8497               return isString(collection) ? stringSize(collection) : collection.length;
8498             }
8499             var tag2 = getTag2(collection);
8500             if (tag2 == mapTag4 || tag2 == setTag4) {
8501               return collection.size;
8502             }
8503             return baseKeys2(collection).length;
8504           }
8505           function some(collection, predicate, guard) {
8506             var func = isArray2(collection) ? arraySome2 : baseSome;
8507             if (guard && isIterateeCall(collection, predicate, guard)) {
8508               predicate = undefined2;
8509             }
8510             return func(collection, getIteratee(predicate, 3));
8511           }
8512           var sortBy = baseRest(function(collection, iteratees) {
8513             if (collection == null) {
8514               return [];
8515             }
8516             var length2 = iteratees.length;
8517             if (length2 > 1 && isIterateeCall(collection, iteratees[0], iteratees[1])) {
8518               iteratees = [];
8519             } else if (length2 > 2 && isIterateeCall(iteratees[0], iteratees[1], iteratees[2])) {
8520               iteratees = [iteratees[0]];
8521             }
8522             return baseOrderBy(collection, baseFlatten(iteratees, 1), []);
8523           });
8524           var now3 = ctxNow || function() {
8525             return root3.Date.now();
8526           };
8527           function after(n3, func) {
8528             if (typeof func != "function") {
8529               throw new TypeError2(FUNC_ERROR_TEXT3);
8530             }
8531             n3 = toInteger(n3);
8532             return function() {
8533               if (--n3 < 1) {
8534                 return func.apply(this, arguments);
8535               }
8536             };
8537           }
8538           function ary(func, n3, guard) {
8539             n3 = guard ? undefined2 : n3;
8540             n3 = func && n3 == null ? func.length : n3;
8541             return createWrap(func, WRAP_ARY_FLAG, undefined2, undefined2, undefined2, undefined2, n3);
8542           }
8543           function before(n3, func) {
8544             var result2;
8545             if (typeof func != "function") {
8546               throw new TypeError2(FUNC_ERROR_TEXT3);
8547             }
8548             n3 = toInteger(n3);
8549             return function() {
8550               if (--n3 > 0) {
8551                 result2 = func.apply(this, arguments);
8552               }
8553               if (n3 <= 1) {
8554                 func = undefined2;
8555               }
8556               return result2;
8557             };
8558           }
8559           var bind = baseRest(function(func, thisArg, partials) {
8560             var bitmask = WRAP_BIND_FLAG;
8561             if (partials.length) {
8562               var holders = replaceHolders(partials, getHolder(bind));
8563               bitmask |= WRAP_PARTIAL_FLAG;
8564             }
8565             return createWrap(func, bitmask, thisArg, partials, holders);
8566           });
8567           var bindKey2 = baseRest(function(object, key, partials) {
8568             var bitmask = WRAP_BIND_FLAG | WRAP_BIND_KEY_FLAG;
8569             if (partials.length) {
8570               var holders = replaceHolders(partials, getHolder(bindKey2));
8571               bitmask |= WRAP_PARTIAL_FLAG;
8572             }
8573             return createWrap(key, bitmask, object, partials, holders);
8574           });
8575           function curry(func, arity, guard) {
8576             arity = guard ? undefined2 : arity;
8577             var result2 = createWrap(func, WRAP_CURRY_FLAG, undefined2, undefined2, undefined2, undefined2, undefined2, arity);
8578             result2.placeholder = curry.placeholder;
8579             return result2;
8580           }
8581           function curryRight(func, arity, guard) {
8582             arity = guard ? undefined2 : arity;
8583             var result2 = createWrap(func, WRAP_CURRY_RIGHT_FLAG, undefined2, undefined2, undefined2, undefined2, undefined2, arity);
8584             result2.placeholder = curryRight.placeholder;
8585             return result2;
8586           }
8587           function debounce2(func, wait, options2) {
8588             var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
8589             if (typeof func != "function") {
8590               throw new TypeError2(FUNC_ERROR_TEXT3);
8591             }
8592             wait = toNumber3(wait) || 0;
8593             if (isObject3(options2)) {
8594               leading = !!options2.leading;
8595               maxing = "maxWait" in options2;
8596               maxWait = maxing ? nativeMax2(toNumber3(options2.maxWait) || 0, wait) : maxWait;
8597               trailing = "trailing" in options2 ? !!options2.trailing : trailing;
8598             }
8599             function invokeFunc(time) {
8600               var args = lastArgs, thisArg = lastThis;
8601               lastArgs = lastThis = undefined2;
8602               lastInvokeTime = time;
8603               result2 = func.apply(thisArg, args);
8604               return result2;
8605             }
8606             function leadingEdge(time) {
8607               lastInvokeTime = time;
8608               timerId = setTimeout2(timerExpired, wait);
8609               return leading ? invokeFunc(time) : result2;
8610             }
8611             function remainingWait(time) {
8612               var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
8613               return maxing ? nativeMin2(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
8614             }
8615             function shouldInvoke(time) {
8616               var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
8617               return lastCallTime === undefined2 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
8618             }
8619             function timerExpired() {
8620               var time = now3();
8621               if (shouldInvoke(time)) {
8622                 return trailingEdge(time);
8623               }
8624               timerId = setTimeout2(timerExpired, remainingWait(time));
8625             }
8626             function trailingEdge(time) {
8627               timerId = undefined2;
8628               if (trailing && lastArgs) {
8629                 return invokeFunc(time);
8630               }
8631               lastArgs = lastThis = undefined2;
8632               return result2;
8633             }
8634             function cancel() {
8635               if (timerId !== undefined2) {
8636                 clearTimeout2(timerId);
8637               }
8638               lastInvokeTime = 0;
8639               lastArgs = lastCallTime = lastThis = timerId = undefined2;
8640             }
8641             function flush() {
8642               return timerId === undefined2 ? result2 : trailingEdge(now3());
8643             }
8644             function debounced() {
8645               var time = now3(), isInvoking = shouldInvoke(time);
8646               lastArgs = arguments;
8647               lastThis = this;
8648               lastCallTime = time;
8649               if (isInvoking) {
8650                 if (timerId === undefined2) {
8651                   return leadingEdge(lastCallTime);
8652                 }
8653                 if (maxing) {
8654                   clearTimeout2(timerId);
8655                   timerId = setTimeout2(timerExpired, wait);
8656                   return invokeFunc(lastCallTime);
8657                 }
8658               }
8659               if (timerId === undefined2) {
8660                 timerId = setTimeout2(timerExpired, wait);
8661               }
8662               return result2;
8663             }
8664             debounced.cancel = cancel;
8665             debounced.flush = flush;
8666             return debounced;
8667           }
8668           var defer = baseRest(function(func, args) {
8669             return baseDelay(func, 1, args);
8670           });
8671           var delay = baseRest(function(func, wait, args) {
8672             return baseDelay(func, toNumber3(wait) || 0, args);
8673           });
8674           function flip(func) {
8675             return createWrap(func, WRAP_FLIP_FLAG);
8676           }
8677           function memoize(func, resolver) {
8678             if (typeof func != "function" || resolver != null && typeof resolver != "function") {
8679               throw new TypeError2(FUNC_ERROR_TEXT3);
8680             }
8681             var memoized = function() {
8682               var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
8683               if (cache.has(key)) {
8684                 return cache.get(key);
8685               }
8686               var result2 = func.apply(this, args);
8687               memoized.cache = cache.set(key, result2) || cache;
8688               return result2;
8689             };
8690             memoized.cache = new (memoize.Cache || MapCache2)();
8691             return memoized;
8692           }
8693           memoize.Cache = MapCache2;
8694           function negate(predicate) {
8695             if (typeof predicate != "function") {
8696               throw new TypeError2(FUNC_ERROR_TEXT3);
8697             }
8698             return function() {
8699               var args = arguments;
8700               switch (args.length) {
8701                 case 0:
8702                   return !predicate.call(this);
8703                 case 1:
8704                   return !predicate.call(this, args[0]);
8705                 case 2:
8706                   return !predicate.call(this, args[0], args[1]);
8707                 case 3:
8708                   return !predicate.call(this, args[0], args[1], args[2]);
8709               }
8710               return !predicate.apply(this, args);
8711             };
8712           }
8713           function once(func) {
8714             return before(2, func);
8715           }
8716           var overArgs = castRest(function(func, transforms) {
8717             transforms = transforms.length == 1 && isArray2(transforms[0]) ? arrayMap2(transforms[0], baseUnary2(getIteratee())) : arrayMap2(baseFlatten(transforms, 1), baseUnary2(getIteratee()));
8718             var funcsLength = transforms.length;
8719             return baseRest(function(args) {
8720               var index = -1, length2 = nativeMin2(args.length, funcsLength);
8721               while (++index < length2) {
8722                 args[index] = transforms[index].call(this, args[index]);
8723               }
8724               return apply(func, this, args);
8725             });
8726           });
8727           var partial = baseRest(function(func, partials) {
8728             var holders = replaceHolders(partials, getHolder(partial));
8729             return createWrap(func, WRAP_PARTIAL_FLAG, undefined2, partials, holders);
8730           });
8731           var partialRight = baseRest(function(func, partials) {
8732             var holders = replaceHolders(partials, getHolder(partialRight));
8733             return createWrap(func, WRAP_PARTIAL_RIGHT_FLAG, undefined2, partials, holders);
8734           });
8735           var rearg = flatRest(function(func, indexes) {
8736             return createWrap(func, WRAP_REARG_FLAG, undefined2, undefined2, undefined2, indexes);
8737           });
8738           function rest(func, start2) {
8739             if (typeof func != "function") {
8740               throw new TypeError2(FUNC_ERROR_TEXT3);
8741             }
8742             start2 = start2 === undefined2 ? start2 : toInteger(start2);
8743             return baseRest(func, start2);
8744           }
8745           function spread(func, start2) {
8746             if (typeof func != "function") {
8747               throw new TypeError2(FUNC_ERROR_TEXT3);
8748             }
8749             start2 = start2 == null ? 0 : nativeMax2(toInteger(start2), 0);
8750             return baseRest(function(args) {
8751               var array2 = args[start2], otherArgs = castSlice(args, 0, start2);
8752               if (array2) {
8753                 arrayPush2(otherArgs, array2);
8754               }
8755               return apply(func, this, otherArgs);
8756             });
8757           }
8758           function throttle2(func, wait, options2) {
8759             var leading = true, trailing = true;
8760             if (typeof func != "function") {
8761               throw new TypeError2(FUNC_ERROR_TEXT3);
8762             }
8763             if (isObject3(options2)) {
8764               leading = "leading" in options2 ? !!options2.leading : leading;
8765               trailing = "trailing" in options2 ? !!options2.trailing : trailing;
8766             }
8767             return debounce2(func, wait, {
8768               "leading": leading,
8769               "maxWait": wait,
8770               "trailing": trailing
8771             });
8772           }
8773           function unary(func) {
8774             return ary(func, 1);
8775           }
8776           function wrap2(value, wrapper) {
8777             return partial(castFunction(wrapper), value);
8778           }
8779           function castArray() {
8780             if (!arguments.length) {
8781               return [];
8782             }
8783             var value = arguments[0];
8784             return isArray2(value) ? value : [value];
8785           }
8786           function clone2(value) {
8787             return baseClone(value, CLONE_SYMBOLS_FLAG);
8788           }
8789           function cloneWith(value, customizer) {
8790             customizer = typeof customizer == "function" ? customizer : undefined2;
8791             return baseClone(value, CLONE_SYMBOLS_FLAG, customizer);
8792           }
8793           function cloneDeep(value) {
8794             return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG);
8795           }
8796           function cloneDeepWith(value, customizer) {
8797             customizer = typeof customizer == "function" ? customizer : undefined2;
8798             return baseClone(value, CLONE_DEEP_FLAG | CLONE_SYMBOLS_FLAG, customizer);
8799           }
8800           function conformsTo(object, source) {
8801             return source == null || baseConformsTo(object, source, keys2(source));
8802           }
8803           function eq2(value, other) {
8804             return value === other || value !== value && other !== other;
8805           }
8806           var gt2 = createRelationalOperation(baseGt);
8807           var gte = createRelationalOperation(function(value, other) {
8808             return value >= other;
8809           });
8810           var isArguments2 = baseIsArguments2(/* @__PURE__ */ function() {
8811             return arguments;
8812           }()) ? baseIsArguments2 : function(value) {
8813             return isObjectLike2(value) && hasOwnProperty10.call(value, "callee") && !propertyIsEnumerable3.call(value, "callee");
8814           };
8815           var isArray2 = Array2.isArray;
8816           var isArrayBuffer = nodeIsArrayBuffer ? baseUnary2(nodeIsArrayBuffer) : baseIsArrayBuffer;
8817           function isArrayLike2(value) {
8818             return value != null && isLength2(value.length) && !isFunction2(value);
8819           }
8820           function isArrayLikeObject(value) {
8821             return isObjectLike2(value) && isArrayLike2(value);
8822           }
8823           function isBoolean(value) {
8824             return value === true || value === false || isObjectLike2(value) && baseGetTag2(value) == boolTag3;
8825           }
8826           var isBuffer2 = nativeIsBuffer2 || stubFalse2;
8827           var isDate = nodeIsDate ? baseUnary2(nodeIsDate) : baseIsDate;
8828           function isElement2(value) {
8829             return isObjectLike2(value) && value.nodeType === 1 && !isPlainObject(value);
8830           }
8831           function isEmpty(value) {
8832             if (value == null) {
8833               return true;
8834             }
8835             if (isArrayLike2(value) && (isArray2(value) || typeof value == "string" || typeof value.splice == "function" || isBuffer2(value) || isTypedArray2(value) || isArguments2(value))) {
8836               return !value.length;
8837             }
8838             var tag2 = getTag2(value);
8839             if (tag2 == mapTag4 || tag2 == setTag4) {
8840               return !value.size;
8841             }
8842             if (isPrototype2(value)) {
8843               return !baseKeys2(value).length;
8844             }
8845             for (var key in value) {
8846               if (hasOwnProperty10.call(value, key)) {
8847                 return false;
8848               }
8849             }
8850             return true;
8851           }
8852           function isEqual4(value, other) {
8853             return baseIsEqual2(value, other);
8854           }
8855           function isEqualWith(value, other, customizer) {
8856             customizer = typeof customizer == "function" ? customizer : undefined2;
8857             var result2 = customizer ? customizer(value, other) : undefined2;
8858             return result2 === undefined2 ? baseIsEqual2(value, other, undefined2, customizer) : !!result2;
8859           }
8860           function isError(value) {
8861             if (!isObjectLike2(value)) {
8862               return false;
8863             }
8864             var tag2 = baseGetTag2(value);
8865             return tag2 == errorTag3 || tag2 == domExcTag || typeof value.message == "string" && typeof value.name == "string" && !isPlainObject(value);
8866           }
8867           function isFinite2(value) {
8868             return typeof value == "number" && nativeIsFinite(value);
8869           }
8870           function isFunction2(value) {
8871             if (!isObject3(value)) {
8872               return false;
8873             }
8874             var tag2 = baseGetTag2(value);
8875             return tag2 == funcTag3 || tag2 == genTag2 || tag2 == asyncTag2 || tag2 == proxyTag2;
8876           }
8877           function isInteger(value) {
8878             return typeof value == "number" && value == toInteger(value);
8879           }
8880           function isLength2(value) {
8881             return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER4;
8882           }
8883           function isObject3(value) {
8884             var type2 = typeof value;
8885             return value != null && (type2 == "object" || type2 == "function");
8886           }
8887           function isObjectLike2(value) {
8888             return value != null && typeof value == "object";
8889           }
8890           var isMap = nodeIsMap ? baseUnary2(nodeIsMap) : baseIsMap;
8891           function isMatch(object, source) {
8892             return object === source || baseIsMatch(object, source, getMatchData(source));
8893           }
8894           function isMatchWith(object, source, customizer) {
8895             customizer = typeof customizer == "function" ? customizer : undefined2;
8896             return baseIsMatch(object, source, getMatchData(source), customizer);
8897           }
8898           function isNaN2(value) {
8899             return isNumber3(value) && value != +value;
8900           }
8901           function isNative(value) {
8902             if (isMaskable(value)) {
8903               throw new Error2(CORE_ERROR_TEXT);
8904             }
8905             return baseIsNative2(value);
8906           }
8907           function isNull(value) {
8908             return value === null;
8909           }
8910           function isNil(value) {
8911             return value == null;
8912           }
8913           function isNumber3(value) {
8914             return typeof value == "number" || isObjectLike2(value) && baseGetTag2(value) == numberTag4;
8915           }
8916           function isPlainObject(value) {
8917             if (!isObjectLike2(value) || baseGetTag2(value) != objectTag4) {
8918               return false;
8919             }
8920             var proto = getPrototype(value);
8921             if (proto === null) {
8922               return true;
8923             }
8924             var Ctor = hasOwnProperty10.call(proto, "constructor") && proto.constructor;
8925             return typeof Ctor == "function" && Ctor instanceof Ctor && funcToString3.call(Ctor) == objectCtorString;
8926           }
8927           var isRegExp = nodeIsRegExp ? baseUnary2(nodeIsRegExp) : baseIsRegExp;
8928           function isSafeInteger(value) {
8929             return isInteger(value) && value >= -MAX_SAFE_INTEGER4 && value <= MAX_SAFE_INTEGER4;
8930           }
8931           var isSet = nodeIsSet ? baseUnary2(nodeIsSet) : baseIsSet;
8932           function isString(value) {
8933             return typeof value == "string" || !isArray2(value) && isObjectLike2(value) && baseGetTag2(value) == stringTag3;
8934           }
8935           function isSymbol2(value) {
8936             return typeof value == "symbol" || isObjectLike2(value) && baseGetTag2(value) == symbolTag3;
8937           }
8938           var isTypedArray2 = nodeIsTypedArray2 ? baseUnary2(nodeIsTypedArray2) : baseIsTypedArray2;
8939           function isUndefined(value) {
8940             return value === undefined2;
8941           }
8942           function isWeakMap(value) {
8943             return isObjectLike2(value) && getTag2(value) == weakMapTag3;
8944           }
8945           function isWeakSet(value) {
8946             return isObjectLike2(value) && baseGetTag2(value) == weakSetTag;
8947           }
8948           var lt2 = createRelationalOperation(baseLt);
8949           var lte = createRelationalOperation(function(value, other) {
8950             return value <= other;
8951           });
8952           function toArray(value) {
8953             if (!value) {
8954               return [];
8955             }
8956             if (isArrayLike2(value)) {
8957               return isString(value) ? stringToArray(value) : copyArray(value);
8958             }
8959             if (symIterator && value[symIterator]) {
8960               return iteratorToArray(value[symIterator]());
8961             }
8962             var tag2 = getTag2(value), func = tag2 == mapTag4 ? mapToArray2 : tag2 == setTag4 ? setToArray2 : values;
8963             return func(value);
8964           }
8965           function toFinite(value) {
8966             if (!value) {
8967               return value === 0 ? value : 0;
8968             }
8969             value = toNumber3(value);
8970             if (value === INFINITY2 || value === -INFINITY2) {
8971               var sign2 = value < 0 ? -1 : 1;
8972               return sign2 * MAX_INTEGER;
8973             }
8974             return value === value ? value : 0;
8975           }
8976           function toInteger(value) {
8977             var result2 = toFinite(value), remainder = result2 % 1;
8978             return result2 === result2 ? remainder ? result2 - remainder : result2 : 0;
8979           }
8980           function toLength(value) {
8981             return value ? baseClamp(toInteger(value), 0, MAX_ARRAY_LENGTH) : 0;
8982           }
8983           function toNumber3(value) {
8984             if (typeof value == "number") {
8985               return value;
8986             }
8987             if (isSymbol2(value)) {
8988               return NAN2;
8989             }
8990             if (isObject3(value)) {
8991               var other = typeof value.valueOf == "function" ? value.valueOf() : value;
8992               value = isObject3(other) ? other + "" : other;
8993             }
8994             if (typeof value != "string") {
8995               return value === 0 ? value : +value;
8996             }
8997             value = baseTrim2(value);
8998             var isBinary = reIsBinary2.test(value);
8999             return isBinary || reIsOctal2.test(value) ? freeParseInt2(value.slice(2), isBinary ? 2 : 8) : reIsBadHex2.test(value) ? NAN2 : +value;
9000           }
9001           function toPlainObject(value) {
9002             return copyObject(value, keysIn(value));
9003           }
9004           function toSafeInteger(value) {
9005             return value ? baseClamp(toInteger(value), -MAX_SAFE_INTEGER4, MAX_SAFE_INTEGER4) : value === 0 ? value : 0;
9006           }
9007           function toString2(value) {
9008             return value == null ? "" : baseToString2(value);
9009           }
9010           var assign = createAssigner(function(object, source) {
9011             if (isPrototype2(source) || isArrayLike2(source)) {
9012               copyObject(source, keys2(source), object);
9013               return;
9014             }
9015             for (var key in source) {
9016               if (hasOwnProperty10.call(source, key)) {
9017                 assignValue(object, key, source[key]);
9018               }
9019             }
9020           });
9021           var assignIn = createAssigner(function(object, source) {
9022             copyObject(source, keysIn(source), object);
9023           });
9024           var assignInWith = createAssigner(function(object, source, srcIndex, customizer) {
9025             copyObject(source, keysIn(source), object, customizer);
9026           });
9027           var assignWith = createAssigner(function(object, source, srcIndex, customizer) {
9028             copyObject(source, keys2(source), object, customizer);
9029           });
9030           var at2 = flatRest(baseAt);
9031           function create2(prototype, properties) {
9032             var result2 = baseCreate(prototype);
9033             return properties == null ? result2 : baseAssign(result2, properties);
9034           }
9035           var defaults = baseRest(function(object, sources) {
9036             object = Object2(object);
9037             var index = -1;
9038             var length2 = sources.length;
9039             var guard = length2 > 2 ? sources[2] : undefined2;
9040             if (guard && isIterateeCall(sources[0], sources[1], guard)) {
9041               length2 = 1;
9042             }
9043             while (++index < length2) {
9044               var source = sources[index];
9045               var props = keysIn(source);
9046               var propsIndex = -1;
9047               var propsLength = props.length;
9048               while (++propsIndex < propsLength) {
9049                 var key = props[propsIndex];
9050                 var value = object[key];
9051                 if (value === undefined2 || eq2(value, objectProto13[key]) && !hasOwnProperty10.call(object, key)) {
9052                   object[key] = source[key];
9053                 }
9054               }
9055             }
9056             return object;
9057           });
9058           var defaultsDeep = baseRest(function(args) {
9059             args.push(undefined2, customDefaultsMerge);
9060             return apply(mergeWith, undefined2, args);
9061           });
9062           function findKey(object, predicate) {
9063             return baseFindKey(object, getIteratee(predicate, 3), baseForOwn);
9064           }
9065           function findLastKey(object, predicate) {
9066             return baseFindKey(object, getIteratee(predicate, 3), baseForOwnRight);
9067           }
9068           function forIn(object, iteratee2) {
9069             return object == null ? object : baseFor(object, getIteratee(iteratee2, 3), keysIn);
9070           }
9071           function forInRight(object, iteratee2) {
9072             return object == null ? object : baseForRight(object, getIteratee(iteratee2, 3), keysIn);
9073           }
9074           function forOwn(object, iteratee2) {
9075             return object && baseForOwn(object, getIteratee(iteratee2, 3));
9076           }
9077           function forOwnRight(object, iteratee2) {
9078             return object && baseForOwnRight(object, getIteratee(iteratee2, 3));
9079           }
9080           function functions(object) {
9081             return object == null ? [] : baseFunctions(object, keys2(object));
9082           }
9083           function functionsIn(object) {
9084             return object == null ? [] : baseFunctions(object, keysIn(object));
9085           }
9086           function get4(object, path, defaultValue) {
9087             var result2 = object == null ? undefined2 : baseGet(object, path);
9088             return result2 === undefined2 ? defaultValue : result2;
9089           }
9090           function has(object, path) {
9091             return object != null && hasPath(object, path, baseHas);
9092           }
9093           function hasIn(object, path) {
9094             return object != null && hasPath(object, path, baseHasIn);
9095           }
9096           var invert = createInverter(function(result2, value, key) {
9097             if (value != null && typeof value.toString != "function") {
9098               value = nativeObjectToString3.call(value);
9099             }
9100             result2[value] = key;
9101           }, constant(identity4));
9102           var invertBy = createInverter(function(result2, value, key) {
9103             if (value != null && typeof value.toString != "function") {
9104               value = nativeObjectToString3.call(value);
9105             }
9106             if (hasOwnProperty10.call(result2, value)) {
9107               result2[value].push(key);
9108             } else {
9109               result2[value] = [key];
9110             }
9111           }, getIteratee);
9112           var invoke = baseRest(baseInvoke);
9113           function keys2(object) {
9114             return isArrayLike2(object) ? arrayLikeKeys2(object) : baseKeys2(object);
9115           }
9116           function keysIn(object) {
9117             return isArrayLike2(object) ? arrayLikeKeys2(object, true) : baseKeysIn(object);
9118           }
9119           function mapKeys(object, iteratee2) {
9120             var result2 = {};
9121             iteratee2 = getIteratee(iteratee2, 3);
9122             baseForOwn(object, function(value, key, object2) {
9123               baseAssignValue(result2, iteratee2(value, key, object2), value);
9124             });
9125             return result2;
9126           }
9127           function mapValues(object, iteratee2) {
9128             var result2 = {};
9129             iteratee2 = getIteratee(iteratee2, 3);
9130             baseForOwn(object, function(value, key, object2) {
9131               baseAssignValue(result2, key, iteratee2(value, key, object2));
9132             });
9133             return result2;
9134           }
9135           var merge2 = createAssigner(function(object, source, srcIndex) {
9136             baseMerge(object, source, srcIndex);
9137           });
9138           var mergeWith = createAssigner(function(object, source, srcIndex, customizer) {
9139             baseMerge(object, source, srcIndex, customizer);
9140           });
9141           var omit = flatRest(function(object, paths) {
9142             var result2 = {};
9143             if (object == null) {
9144               return result2;
9145             }
9146             var isDeep = false;
9147             paths = arrayMap2(paths, function(path) {
9148               path = castPath(path, object);
9149               isDeep || (isDeep = path.length > 1);
9150               return path;
9151             });
9152             copyObject(object, getAllKeysIn(object), result2);
9153             if (isDeep) {
9154               result2 = baseClone(result2, CLONE_DEEP_FLAG | CLONE_FLAT_FLAG | CLONE_SYMBOLS_FLAG, customOmitClone);
9155             }
9156             var length2 = paths.length;
9157             while (length2--) {
9158               baseUnset(result2, paths[length2]);
9159             }
9160             return result2;
9161           });
9162           function omitBy(object, predicate) {
9163             return pickBy(object, negate(getIteratee(predicate)));
9164           }
9165           var pick = flatRest(function(object, paths) {
9166             return object == null ? {} : basePick(object, paths);
9167           });
9168           function pickBy(object, predicate) {
9169             if (object == null) {
9170               return {};
9171             }
9172             var props = arrayMap2(getAllKeysIn(object), function(prop) {
9173               return [prop];
9174             });
9175             predicate = getIteratee(predicate);
9176             return basePickBy(object, props, function(value, path) {
9177               return predicate(value, path[0]);
9178             });
9179           }
9180           function result(object, path, defaultValue) {
9181             path = castPath(path, object);
9182             var index = -1, length2 = path.length;
9183             if (!length2) {
9184               length2 = 1;
9185               object = undefined2;
9186             }
9187             while (++index < length2) {
9188               var value = object == null ? undefined2 : object[toKey(path[index])];
9189               if (value === undefined2) {
9190                 index = length2;
9191                 value = defaultValue;
9192               }
9193               object = isFunction2(value) ? value.call(object) : value;
9194             }
9195             return object;
9196           }
9197           function set4(object, path, value) {
9198             return object == null ? object : baseSet(object, path, value);
9199           }
9200           function setWith(object, path, value, customizer) {
9201             customizer = typeof customizer == "function" ? customizer : undefined2;
9202             return object == null ? object : baseSet(object, path, value, customizer);
9203           }
9204           var toPairs = createToPairs(keys2);
9205           var toPairsIn = createToPairs(keysIn);
9206           function transform2(object, iteratee2, accumulator) {
9207             var isArr = isArray2(object), isArrLike = isArr || isBuffer2(object) || isTypedArray2(object);
9208             iteratee2 = getIteratee(iteratee2, 4);
9209             if (accumulator == null) {
9210               var Ctor = object && object.constructor;
9211               if (isArrLike) {
9212                 accumulator = isArr ? new Ctor() : [];
9213               } else if (isObject3(object)) {
9214                 accumulator = isFunction2(Ctor) ? baseCreate(getPrototype(object)) : {};
9215               } else {
9216                 accumulator = {};
9217               }
9218             }
9219             (isArrLike ? arrayEach : baseForOwn)(object, function(value, index, object2) {
9220               return iteratee2(accumulator, value, index, object2);
9221             });
9222             return accumulator;
9223           }
9224           function unset(object, path) {
9225             return object == null ? true : baseUnset(object, path);
9226           }
9227           function update(object, path, updater) {
9228             return object == null ? object : baseUpdate(object, path, castFunction(updater));
9229           }
9230           function updateWith(object, path, updater, customizer) {
9231             customizer = typeof customizer == "function" ? customizer : undefined2;
9232             return object == null ? object : baseUpdate(object, path, castFunction(updater), customizer);
9233           }
9234           function values(object) {
9235             return object == null ? [] : baseValues(object, keys2(object));
9236           }
9237           function valuesIn(object) {
9238             return object == null ? [] : baseValues(object, keysIn(object));
9239           }
9240           function clamp3(number3, lower2, upper) {
9241             if (upper === undefined2) {
9242               upper = lower2;
9243               lower2 = undefined2;
9244             }
9245             if (upper !== undefined2) {
9246               upper = toNumber3(upper);
9247               upper = upper === upper ? upper : 0;
9248             }
9249             if (lower2 !== undefined2) {
9250               lower2 = toNumber3(lower2);
9251               lower2 = lower2 === lower2 ? lower2 : 0;
9252             }
9253             return baseClamp(toNumber3(number3), lower2, upper);
9254           }
9255           function inRange(number3, start2, end) {
9256             start2 = toFinite(start2);
9257             if (end === undefined2) {
9258               end = start2;
9259               start2 = 0;
9260             } else {
9261               end = toFinite(end);
9262             }
9263             number3 = toNumber3(number3);
9264             return baseInRange(number3, start2, end);
9265           }
9266           function random(lower2, upper, floating) {
9267             if (floating && typeof floating != "boolean" && isIterateeCall(lower2, upper, floating)) {
9268               upper = floating = undefined2;
9269             }
9270             if (floating === undefined2) {
9271               if (typeof upper == "boolean") {
9272                 floating = upper;
9273                 upper = undefined2;
9274               } else if (typeof lower2 == "boolean") {
9275                 floating = lower2;
9276                 lower2 = undefined2;
9277               }
9278             }
9279             if (lower2 === undefined2 && upper === undefined2) {
9280               lower2 = 0;
9281               upper = 1;
9282             } else {
9283               lower2 = toFinite(lower2);
9284               if (upper === undefined2) {
9285                 upper = lower2;
9286                 lower2 = 0;
9287               } else {
9288                 upper = toFinite(upper);
9289               }
9290             }
9291             if (lower2 > upper) {
9292               var temp = lower2;
9293               lower2 = upper;
9294               upper = temp;
9295             }
9296             if (floating || lower2 % 1 || upper % 1) {
9297               var rand = nativeRandom();
9298               return nativeMin2(lower2 + rand * (upper - lower2 + freeParseFloat("1e-" + ((rand + "").length - 1))), upper);
9299             }
9300             return baseRandom(lower2, upper);
9301           }
9302           var camelCase = createCompounder(function(result2, word, index) {
9303             word = word.toLowerCase();
9304             return result2 + (index ? capitalize(word) : word);
9305           });
9306           function capitalize(string) {
9307             return upperFirst(toString2(string).toLowerCase());
9308           }
9309           function deburr(string) {
9310             string = toString2(string);
9311             return string && string.replace(reLatin, deburrLetter).replace(reComboMark, "");
9312           }
9313           function endsWith(string, target, position) {
9314             string = toString2(string);
9315             target = baseToString2(target);
9316             var length2 = string.length;
9317             position = position === undefined2 ? length2 : baseClamp(toInteger(position), 0, length2);
9318             var end = position;
9319             position -= target.length;
9320             return position >= 0 && string.slice(position, end) == target;
9321           }
9322           function escape6(string) {
9323             string = toString2(string);
9324             return string && reHasUnescapedHtml2.test(string) ? string.replace(reUnescapedHtml2, escapeHtmlChar2) : string;
9325           }
9326           function escapeRegExp(string) {
9327             string = toString2(string);
9328             return string && reHasRegExpChar.test(string) ? string.replace(reRegExpChar2, "\\$&") : string;
9329           }
9330           var kebabCase = createCompounder(function(result2, word, index) {
9331             return result2 + (index ? "-" : "") + word.toLowerCase();
9332           });
9333           var lowerCase = createCompounder(function(result2, word, index) {
9334             return result2 + (index ? " " : "") + word.toLowerCase();
9335           });
9336           var lowerFirst = createCaseFirst("toLowerCase");
9337           function pad2(string, length2, chars) {
9338             string = toString2(string);
9339             length2 = toInteger(length2);
9340             var strLength = length2 ? stringSize(string) : 0;
9341             if (!length2 || strLength >= length2) {
9342               return string;
9343             }
9344             var mid = (length2 - strLength) / 2;
9345             return createPadding(nativeFloor(mid), chars) + string + createPadding(nativeCeil(mid), chars);
9346           }
9347           function padEnd(string, length2, chars) {
9348             string = toString2(string);
9349             length2 = toInteger(length2);
9350             var strLength = length2 ? stringSize(string) : 0;
9351             return length2 && strLength < length2 ? string + createPadding(length2 - strLength, chars) : string;
9352           }
9353           function padStart(string, length2, chars) {
9354             string = toString2(string);
9355             length2 = toInteger(length2);
9356             var strLength = length2 ? stringSize(string) : 0;
9357             return length2 && strLength < length2 ? createPadding(length2 - strLength, chars) + string : string;
9358           }
9359           function parseInt2(string, radix, guard) {
9360             if (guard || radix == null) {
9361               radix = 0;
9362             } else if (radix) {
9363               radix = +radix;
9364             }
9365             return nativeParseInt(toString2(string).replace(reTrimStart2, ""), radix || 0);
9366           }
9367           function repeat(string, n3, guard) {
9368             if (guard ? isIterateeCall(string, n3, guard) : n3 === undefined2) {
9369               n3 = 1;
9370             } else {
9371               n3 = toInteger(n3);
9372             }
9373             return baseRepeat(toString2(string), n3);
9374           }
9375           function replace() {
9376             var args = arguments, string = toString2(args[0]);
9377             return args.length < 3 ? string : string.replace(args[1], args[2]);
9378           }
9379           var snakeCase = createCompounder(function(result2, word, index) {
9380             return result2 + (index ? "_" : "") + word.toLowerCase();
9381           });
9382           function split(string, separator, limit) {
9383             if (limit && typeof limit != "number" && isIterateeCall(string, separator, limit)) {
9384               separator = limit = undefined2;
9385             }
9386             limit = limit === undefined2 ? MAX_ARRAY_LENGTH : limit >>> 0;
9387             if (!limit) {
9388               return [];
9389             }
9390             string = toString2(string);
9391             if (string && (typeof separator == "string" || separator != null && !isRegExp(separator))) {
9392               separator = baseToString2(separator);
9393               if (!separator && hasUnicode(string)) {
9394                 return castSlice(stringToArray(string), 0, limit);
9395               }
9396             }
9397             return string.split(separator, limit);
9398           }
9399           var startCase = createCompounder(function(result2, word, index) {
9400             return result2 + (index ? " " : "") + upperFirst(word);
9401           });
9402           function startsWith(string, target, position) {
9403             string = toString2(string);
9404             position = position == null ? 0 : baseClamp(toInteger(position), 0, string.length);
9405             target = baseToString2(target);
9406             return string.slice(position, position + target.length) == target;
9407           }
9408           function template(string, options2, guard) {
9409             var settings = lodash.templateSettings;
9410             if (guard && isIterateeCall(string, options2, guard)) {
9411               options2 = undefined2;
9412             }
9413             string = toString2(string);
9414             options2 = assignInWith({}, options2, settings, customDefaultsAssignIn);
9415             var imports = assignInWith({}, options2.imports, settings.imports, customDefaultsAssignIn), importsKeys = keys2(imports), importsValues = baseValues(imports, importsKeys);
9416             var isEscaping, isEvaluating, index = 0, interpolate = options2.interpolate || reNoMatch, source = "__p += '";
9417             var reDelimiters = RegExp2(
9418               (options2.escape || reNoMatch).source + "|" + interpolate.source + "|" + (interpolate === reInterpolate ? reEsTemplate : reNoMatch).source + "|" + (options2.evaluate || reNoMatch).source + "|$",
9419               "g"
9420             );
9421             var sourceURL = "//# sourceURL=" + (hasOwnProperty10.call(options2, "sourceURL") ? (options2.sourceURL + "").replace(/\s/g, " ") : "lodash.templateSources[" + ++templateCounter + "]") + "\n";
9422             string.replace(reDelimiters, function(match, escapeValue, interpolateValue, esTemplateValue, evaluateValue, offset) {
9423               interpolateValue || (interpolateValue = esTemplateValue);
9424               source += string.slice(index, offset).replace(reUnescapedString, escapeStringChar);
9425               if (escapeValue) {
9426                 isEscaping = true;
9427                 source += "' +\n__e(" + escapeValue + ") +\n'";
9428               }
9429               if (evaluateValue) {
9430                 isEvaluating = true;
9431                 source += "';\n" + evaluateValue + ";\n__p += '";
9432               }
9433               if (interpolateValue) {
9434                 source += "' +\n((__t = (" + interpolateValue + ")) == null ? '' : __t) +\n'";
9435               }
9436               index = offset + match.length;
9437               return match;
9438             });
9439             source += "';\n";
9440             var variable = hasOwnProperty10.call(options2, "variable") && options2.variable;
9441             if (!variable) {
9442               source = "with (obj) {\n" + source + "\n}\n";
9443             } else if (reForbiddenIdentifierChars.test(variable)) {
9444               throw new Error2(INVALID_TEMPL_VAR_ERROR_TEXT);
9445             }
9446             source = (isEvaluating ? source.replace(reEmptyStringLeading, "") : source).replace(reEmptyStringMiddle, "$1").replace(reEmptyStringTrailing, "$1;");
9447             source = "function(" + (variable || "obj") + ") {\n" + (variable ? "" : "obj || (obj = {});\n") + "var __t, __p = ''" + (isEscaping ? ", __e = _.escape" : "") + (isEvaluating ? ", __j = Array.prototype.join;\nfunction print() { __p += __j.call(arguments, '') }\n" : ";\n") + source + "return __p\n}";
9448             var result2 = attempt(function() {
9449               return Function2(importsKeys, sourceURL + "return " + source).apply(undefined2, importsValues);
9450             });
9451             result2.source = source;
9452             if (isError(result2)) {
9453               throw result2;
9454             }
9455             return result2;
9456           }
9457           function toLower(value) {
9458             return toString2(value).toLowerCase();
9459           }
9460           function toUpper(value) {
9461             return toString2(value).toUpperCase();
9462           }
9463           function trim(string, chars, guard) {
9464             string = toString2(string);
9465             if (string && (guard || chars === undefined2)) {
9466               return baseTrim2(string);
9467             }
9468             if (!string || !(chars = baseToString2(chars))) {
9469               return string;
9470             }
9471             var strSymbols = stringToArray(string), chrSymbols = stringToArray(chars), start2 = charsStartIndex(strSymbols, chrSymbols), end = charsEndIndex(strSymbols, chrSymbols) + 1;
9472             return castSlice(strSymbols, start2, end).join("");
9473           }
9474           function trimEnd(string, chars, guard) {
9475             string = toString2(string);
9476             if (string && (guard || chars === undefined2)) {
9477               return string.slice(0, trimmedEndIndex2(string) + 1);
9478             }
9479             if (!string || !(chars = baseToString2(chars))) {
9480               return string;
9481             }
9482             var strSymbols = stringToArray(string), end = charsEndIndex(strSymbols, stringToArray(chars)) + 1;
9483             return castSlice(strSymbols, 0, end).join("");
9484           }
9485           function trimStart(string, chars, guard) {
9486             string = toString2(string);
9487             if (string && (guard || chars === undefined2)) {
9488               return string.replace(reTrimStart2, "");
9489             }
9490             if (!string || !(chars = baseToString2(chars))) {
9491               return string;
9492             }
9493             var strSymbols = stringToArray(string), start2 = charsStartIndex(strSymbols, stringToArray(chars));
9494             return castSlice(strSymbols, start2).join("");
9495           }
9496           function truncate(string, options2) {
9497             var length2 = DEFAULT_TRUNC_LENGTH, omission = DEFAULT_TRUNC_OMISSION;
9498             if (isObject3(options2)) {
9499               var separator = "separator" in options2 ? options2.separator : separator;
9500               length2 = "length" in options2 ? toInteger(options2.length) : length2;
9501               omission = "omission" in options2 ? baseToString2(options2.omission) : omission;
9502             }
9503             string = toString2(string);
9504             var strLength = string.length;
9505             if (hasUnicode(string)) {
9506               var strSymbols = stringToArray(string);
9507               strLength = strSymbols.length;
9508             }
9509             if (length2 >= strLength) {
9510               return string;
9511             }
9512             var end = length2 - stringSize(omission);
9513             if (end < 1) {
9514               return omission;
9515             }
9516             var result2 = strSymbols ? castSlice(strSymbols, 0, end).join("") : string.slice(0, end);
9517             if (separator === undefined2) {
9518               return result2 + omission;
9519             }
9520             if (strSymbols) {
9521               end += result2.length - end;
9522             }
9523             if (isRegExp(separator)) {
9524               if (string.slice(end).search(separator)) {
9525                 var match, substring = result2;
9526                 if (!separator.global) {
9527                   separator = RegExp2(separator.source, toString2(reFlags.exec(separator)) + "g");
9528                 }
9529                 separator.lastIndex = 0;
9530                 while (match = separator.exec(substring)) {
9531                   var newEnd = match.index;
9532                 }
9533                 result2 = result2.slice(0, newEnd === undefined2 ? end : newEnd);
9534               }
9535             } else if (string.indexOf(baseToString2(separator), end) != end) {
9536               var index = result2.lastIndexOf(separator);
9537               if (index > -1) {
9538                 result2 = result2.slice(0, index);
9539               }
9540             }
9541             return result2 + omission;
9542           }
9543           function unescape3(string) {
9544             string = toString2(string);
9545             return string && reHasEscapedHtml2.test(string) ? string.replace(reEscapedHtml2, unescapeHtmlChar2) : string;
9546           }
9547           var upperCase = createCompounder(function(result2, word, index) {
9548             return result2 + (index ? " " : "") + word.toUpperCase();
9549           });
9550           var upperFirst = createCaseFirst("toUpperCase");
9551           function words(string, pattern, guard) {
9552             string = toString2(string);
9553             pattern = guard ? undefined2 : pattern;
9554             if (pattern === undefined2) {
9555               return hasUnicodeWord(string) ? unicodeWords(string) : asciiWords(string);
9556             }
9557             return string.match(pattern) || [];
9558           }
9559           var attempt = baseRest(function(func, args) {
9560             try {
9561               return apply(func, undefined2, args);
9562             } catch (e3) {
9563               return isError(e3) ? e3 : new Error2(e3);
9564             }
9565           });
9566           var bindAll = flatRest(function(object, methodNames) {
9567             arrayEach(methodNames, function(key) {
9568               key = toKey(key);
9569               baseAssignValue(object, key, bind(object[key], object));
9570             });
9571             return object;
9572           });
9573           function cond(pairs2) {
9574             var length2 = pairs2 == null ? 0 : pairs2.length, toIteratee = getIteratee();
9575             pairs2 = !length2 ? [] : arrayMap2(pairs2, function(pair3) {
9576               if (typeof pair3[1] != "function") {
9577                 throw new TypeError2(FUNC_ERROR_TEXT3);
9578               }
9579               return [toIteratee(pair3[0]), pair3[1]];
9580             });
9581             return baseRest(function(args) {
9582               var index = -1;
9583               while (++index < length2) {
9584                 var pair3 = pairs2[index];
9585                 if (apply(pair3[0], this, args)) {
9586                   return apply(pair3[1], this, args);
9587                 }
9588               }
9589             });
9590           }
9591           function conforms(source) {
9592             return baseConforms(baseClone(source, CLONE_DEEP_FLAG));
9593           }
9594           function constant(value) {
9595             return function() {
9596               return value;
9597             };
9598           }
9599           function defaultTo(value, defaultValue) {
9600             return value == null || value !== value ? defaultValue : value;
9601           }
9602           var flow = createFlow();
9603           var flowRight = createFlow(true);
9604           function identity4(value) {
9605             return value;
9606           }
9607           function iteratee(func) {
9608             return baseIteratee(typeof func == "function" ? func : baseClone(func, CLONE_DEEP_FLAG));
9609           }
9610           function matches(source) {
9611             return baseMatches(baseClone(source, CLONE_DEEP_FLAG));
9612           }
9613           function matchesProperty(path, srcValue) {
9614             return baseMatchesProperty(path, baseClone(srcValue, CLONE_DEEP_FLAG));
9615           }
9616           var method = baseRest(function(path, args) {
9617             return function(object) {
9618               return baseInvoke(object, path, args);
9619             };
9620           });
9621           var methodOf = baseRest(function(object, args) {
9622             return function(path) {
9623               return baseInvoke(object, path, args);
9624             };
9625           });
9626           function mixin(object, source, options2) {
9627             var props = keys2(source), methodNames = baseFunctions(source, props);
9628             if (options2 == null && !(isObject3(source) && (methodNames.length || !props.length))) {
9629               options2 = source;
9630               source = object;
9631               object = this;
9632               methodNames = baseFunctions(source, keys2(source));
9633             }
9634             var chain2 = !(isObject3(options2) && "chain" in options2) || !!options2.chain, isFunc = isFunction2(object);
9635             arrayEach(methodNames, function(methodName) {
9636               var func = source[methodName];
9637               object[methodName] = func;
9638               if (isFunc) {
9639                 object.prototype[methodName] = function() {
9640                   var chainAll = this.__chain__;
9641                   if (chain2 || chainAll) {
9642                     var result2 = object(this.__wrapped__), actions = result2.__actions__ = copyArray(this.__actions__);
9643                     actions.push({ "func": func, "args": arguments, "thisArg": object });
9644                     result2.__chain__ = chainAll;
9645                     return result2;
9646                   }
9647                   return func.apply(object, arrayPush2([this.value()], arguments));
9648                 };
9649               }
9650             });
9651             return object;
9652           }
9653           function noConflict() {
9654             if (root3._ === this) {
9655               root3._ = oldDash;
9656             }
9657             return this;
9658           }
9659           function noop3() {
9660           }
9661           function nthArg(n3) {
9662             n3 = toInteger(n3);
9663             return baseRest(function(args) {
9664               return baseNth(args, n3);
9665             });
9666           }
9667           var over = createOver(arrayMap2);
9668           var overEvery = createOver(arrayEvery);
9669           var overSome = createOver(arraySome2);
9670           function property(path) {
9671             return isKey(path) ? baseProperty(toKey(path)) : basePropertyDeep(path);
9672           }
9673           function propertyOf(object) {
9674             return function(path) {
9675               return object == null ? undefined2 : baseGet(object, path);
9676             };
9677           }
9678           var range3 = createRange();
9679           var rangeRight = createRange(true);
9680           function stubArray2() {
9681             return [];
9682           }
9683           function stubFalse2() {
9684             return false;
9685           }
9686           function stubObject() {
9687             return {};
9688           }
9689           function stubString() {
9690             return "";
9691           }
9692           function stubTrue() {
9693             return true;
9694           }
9695           function times(n3, iteratee2) {
9696             n3 = toInteger(n3);
9697             if (n3 < 1 || n3 > MAX_SAFE_INTEGER4) {
9698               return [];
9699             }
9700             var index = MAX_ARRAY_LENGTH, length2 = nativeMin2(n3, MAX_ARRAY_LENGTH);
9701             iteratee2 = getIteratee(iteratee2);
9702             n3 -= MAX_ARRAY_LENGTH;
9703             var result2 = baseTimes2(length2, iteratee2);
9704             while (++index < n3) {
9705               iteratee2(index);
9706             }
9707             return result2;
9708           }
9709           function toPath(value) {
9710             if (isArray2(value)) {
9711               return arrayMap2(value, toKey);
9712             }
9713             return isSymbol2(value) ? [value] : copyArray(stringToPath(toString2(value)));
9714           }
9715           function uniqueId(prefix) {
9716             var id2 = ++idCounter;
9717             return toString2(prefix) + id2;
9718           }
9719           var add = createMathOperation(function(augend, addend) {
9720             return augend + addend;
9721           }, 0);
9722           var ceil = createRound("ceil");
9723           var divide = createMathOperation(function(dividend, divisor) {
9724             return dividend / divisor;
9725           }, 1);
9726           var floor = createRound("floor");
9727           function max3(array2) {
9728             return array2 && array2.length ? baseExtremum(array2, identity4, baseGt) : undefined2;
9729           }
9730           function maxBy(array2, iteratee2) {
9731             return array2 && array2.length ? baseExtremum(array2, getIteratee(iteratee2, 2), baseGt) : undefined2;
9732           }
9733           function mean(array2) {
9734             return baseMean(array2, identity4);
9735           }
9736           function meanBy(array2, iteratee2) {
9737             return baseMean(array2, getIteratee(iteratee2, 2));
9738           }
9739           function min3(array2) {
9740             return array2 && array2.length ? baseExtremum(array2, identity4, baseLt) : undefined2;
9741           }
9742           function minBy(array2, iteratee2) {
9743             return array2 && array2.length ? baseExtremum(array2, getIteratee(iteratee2, 2), baseLt) : undefined2;
9744           }
9745           var multiply = createMathOperation(function(multiplier, multiplicand) {
9746             return multiplier * multiplicand;
9747           }, 1);
9748           var round = createRound("round");
9749           var subtract = createMathOperation(function(minuend, subtrahend) {
9750             return minuend - subtrahend;
9751           }, 0);
9752           function sum(array2) {
9753             return array2 && array2.length ? baseSum(array2, identity4) : 0;
9754           }
9755           function sumBy(array2, iteratee2) {
9756             return array2 && array2.length ? baseSum(array2, getIteratee(iteratee2, 2)) : 0;
9757           }
9758           lodash.after = after;
9759           lodash.ary = ary;
9760           lodash.assign = assign;
9761           lodash.assignIn = assignIn;
9762           lodash.assignInWith = assignInWith;
9763           lodash.assignWith = assignWith;
9764           lodash.at = at2;
9765           lodash.before = before;
9766           lodash.bind = bind;
9767           lodash.bindAll = bindAll;
9768           lodash.bindKey = bindKey2;
9769           lodash.castArray = castArray;
9770           lodash.chain = chain;
9771           lodash.chunk = chunk;
9772           lodash.compact = compact;
9773           lodash.concat = concat;
9774           lodash.cond = cond;
9775           lodash.conforms = conforms;
9776           lodash.constant = constant;
9777           lodash.countBy = countBy;
9778           lodash.create = create2;
9779           lodash.curry = curry;
9780           lodash.curryRight = curryRight;
9781           lodash.debounce = debounce2;
9782           lodash.defaults = defaults;
9783           lodash.defaultsDeep = defaultsDeep;
9784           lodash.defer = defer;
9785           lodash.delay = delay;
9786           lodash.difference = difference2;
9787           lodash.differenceBy = differenceBy;
9788           lodash.differenceWith = differenceWith;
9789           lodash.drop = drop;
9790           lodash.dropRight = dropRight;
9791           lodash.dropRightWhile = dropRightWhile;
9792           lodash.dropWhile = dropWhile;
9793           lodash.fill = fill;
9794           lodash.filter = filter2;
9795           lodash.flatMap = flatMap;
9796           lodash.flatMapDeep = flatMapDeep;
9797           lodash.flatMapDepth = flatMapDepth;
9798           lodash.flatten = flatten2;
9799           lodash.flattenDeep = flattenDeep;
9800           lodash.flattenDepth = flattenDepth;
9801           lodash.flip = flip;
9802           lodash.flow = flow;
9803           lodash.flowRight = flowRight;
9804           lodash.fromPairs = fromPairs;
9805           lodash.functions = functions;
9806           lodash.functionsIn = functionsIn;
9807           lodash.groupBy = groupBy;
9808           lodash.initial = initial;
9809           lodash.intersection = intersection2;
9810           lodash.intersectionBy = intersectionBy;
9811           lodash.intersectionWith = intersectionWith;
9812           lodash.invert = invert;
9813           lodash.invertBy = invertBy;
9814           lodash.invokeMap = invokeMap;
9815           lodash.iteratee = iteratee;
9816           lodash.keyBy = keyBy;
9817           lodash.keys = keys2;
9818           lodash.keysIn = keysIn;
9819           lodash.map = map2;
9820           lodash.mapKeys = mapKeys;
9821           lodash.mapValues = mapValues;
9822           lodash.matches = matches;
9823           lodash.matchesProperty = matchesProperty;
9824           lodash.memoize = memoize;
9825           lodash.merge = merge2;
9826           lodash.mergeWith = mergeWith;
9827           lodash.method = method;
9828           lodash.methodOf = methodOf;
9829           lodash.mixin = mixin;
9830           lodash.negate = negate;
9831           lodash.nthArg = nthArg;
9832           lodash.omit = omit;
9833           lodash.omitBy = omitBy;
9834           lodash.once = once;
9835           lodash.orderBy = orderBy;
9836           lodash.over = over;
9837           lodash.overArgs = overArgs;
9838           lodash.overEvery = overEvery;
9839           lodash.overSome = overSome;
9840           lodash.partial = partial;
9841           lodash.partialRight = partialRight;
9842           lodash.partition = partition;
9843           lodash.pick = pick;
9844           lodash.pickBy = pickBy;
9845           lodash.property = property;
9846           lodash.propertyOf = propertyOf;
9847           lodash.pull = pull;
9848           lodash.pullAll = pullAll;
9849           lodash.pullAllBy = pullAllBy;
9850           lodash.pullAllWith = pullAllWith;
9851           lodash.pullAt = pullAt;
9852           lodash.range = range3;
9853           lodash.rangeRight = rangeRight;
9854           lodash.rearg = rearg;
9855           lodash.reject = reject;
9856           lodash.remove = remove2;
9857           lodash.rest = rest;
9858           lodash.reverse = reverse;
9859           lodash.sampleSize = sampleSize;
9860           lodash.set = set4;
9861           lodash.setWith = setWith;
9862           lodash.shuffle = shuffle;
9863           lodash.slice = slice;
9864           lodash.sortBy = sortBy;
9865           lodash.sortedUniq = sortedUniq;
9866           lodash.sortedUniqBy = sortedUniqBy;
9867           lodash.split = split;
9868           lodash.spread = spread;
9869           lodash.tail = tail;
9870           lodash.take = take;
9871           lodash.takeRight = takeRight;
9872           lodash.takeRightWhile = takeRightWhile;
9873           lodash.takeWhile = takeWhile;
9874           lodash.tap = tap;
9875           lodash.throttle = throttle2;
9876           lodash.thru = thru;
9877           lodash.toArray = toArray;
9878           lodash.toPairs = toPairs;
9879           lodash.toPairsIn = toPairsIn;
9880           lodash.toPath = toPath;
9881           lodash.toPlainObject = toPlainObject;
9882           lodash.transform = transform2;
9883           lodash.unary = unary;
9884           lodash.union = union2;
9885           lodash.unionBy = unionBy;
9886           lodash.unionWith = unionWith;
9887           lodash.uniq = uniq;
9888           lodash.uniqBy = uniqBy;
9889           lodash.uniqWith = uniqWith;
9890           lodash.unset = unset;
9891           lodash.unzip = unzip;
9892           lodash.unzipWith = unzipWith;
9893           lodash.update = update;
9894           lodash.updateWith = updateWith;
9895           lodash.values = values;
9896           lodash.valuesIn = valuesIn;
9897           lodash.without = without;
9898           lodash.words = words;
9899           lodash.wrap = wrap2;
9900           lodash.xor = xor;
9901           lodash.xorBy = xorBy;
9902           lodash.xorWith = xorWith;
9903           lodash.zip = zip;
9904           lodash.zipObject = zipObject;
9905           lodash.zipObjectDeep = zipObjectDeep;
9906           lodash.zipWith = zipWith;
9907           lodash.entries = toPairs;
9908           lodash.entriesIn = toPairsIn;
9909           lodash.extend = assignIn;
9910           lodash.extendWith = assignInWith;
9911           mixin(lodash, lodash);
9912           lodash.add = add;
9913           lodash.attempt = attempt;
9914           lodash.camelCase = camelCase;
9915           lodash.capitalize = capitalize;
9916           lodash.ceil = ceil;
9917           lodash.clamp = clamp3;
9918           lodash.clone = clone2;
9919           lodash.cloneDeep = cloneDeep;
9920           lodash.cloneDeepWith = cloneDeepWith;
9921           lodash.cloneWith = cloneWith;
9922           lodash.conformsTo = conformsTo;
9923           lodash.deburr = deburr;
9924           lodash.defaultTo = defaultTo;
9925           lodash.divide = divide;
9926           lodash.endsWith = endsWith;
9927           lodash.eq = eq2;
9928           lodash.escape = escape6;
9929           lodash.escapeRegExp = escapeRegExp;
9930           lodash.every = every;
9931           lodash.find = find2;
9932           lodash.findIndex = findIndex;
9933           lodash.findKey = findKey;
9934           lodash.findLast = findLast;
9935           lodash.findLastIndex = findLastIndex;
9936           lodash.findLastKey = findLastKey;
9937           lodash.floor = floor;
9938           lodash.forEach = forEach;
9939           lodash.forEachRight = forEachRight;
9940           lodash.forIn = forIn;
9941           lodash.forInRight = forInRight;
9942           lodash.forOwn = forOwn;
9943           lodash.forOwnRight = forOwnRight;
9944           lodash.get = get4;
9945           lodash.gt = gt2;
9946           lodash.gte = gte;
9947           lodash.has = has;
9948           lodash.hasIn = hasIn;
9949           lodash.head = head;
9950           lodash.identity = identity4;
9951           lodash.includes = includes;
9952           lodash.indexOf = indexOf;
9953           lodash.inRange = inRange;
9954           lodash.invoke = invoke;
9955           lodash.isArguments = isArguments2;
9956           lodash.isArray = isArray2;
9957           lodash.isArrayBuffer = isArrayBuffer;
9958           lodash.isArrayLike = isArrayLike2;
9959           lodash.isArrayLikeObject = isArrayLikeObject;
9960           lodash.isBoolean = isBoolean;
9961           lodash.isBuffer = isBuffer2;
9962           lodash.isDate = isDate;
9963           lodash.isElement = isElement2;
9964           lodash.isEmpty = isEmpty;
9965           lodash.isEqual = isEqual4;
9966           lodash.isEqualWith = isEqualWith;
9967           lodash.isError = isError;
9968           lodash.isFinite = isFinite2;
9969           lodash.isFunction = isFunction2;
9970           lodash.isInteger = isInteger;
9971           lodash.isLength = isLength2;
9972           lodash.isMap = isMap;
9973           lodash.isMatch = isMatch;
9974           lodash.isMatchWith = isMatchWith;
9975           lodash.isNaN = isNaN2;
9976           lodash.isNative = isNative;
9977           lodash.isNil = isNil;
9978           lodash.isNull = isNull;
9979           lodash.isNumber = isNumber3;
9980           lodash.isObject = isObject3;
9981           lodash.isObjectLike = isObjectLike2;
9982           lodash.isPlainObject = isPlainObject;
9983           lodash.isRegExp = isRegExp;
9984           lodash.isSafeInteger = isSafeInteger;
9985           lodash.isSet = isSet;
9986           lodash.isString = isString;
9987           lodash.isSymbol = isSymbol2;
9988           lodash.isTypedArray = isTypedArray2;
9989           lodash.isUndefined = isUndefined;
9990           lodash.isWeakMap = isWeakMap;
9991           lodash.isWeakSet = isWeakSet;
9992           lodash.join = join;
9993           lodash.kebabCase = kebabCase;
9994           lodash.last = last;
9995           lodash.lastIndexOf = lastIndexOf;
9996           lodash.lowerCase = lowerCase;
9997           lodash.lowerFirst = lowerFirst;
9998           lodash.lt = lt2;
9999           lodash.lte = lte;
10000           lodash.max = max3;
10001           lodash.maxBy = maxBy;
10002           lodash.mean = mean;
10003           lodash.meanBy = meanBy;
10004           lodash.min = min3;
10005           lodash.minBy = minBy;
10006           lodash.stubArray = stubArray2;
10007           lodash.stubFalse = stubFalse2;
10008           lodash.stubObject = stubObject;
10009           lodash.stubString = stubString;
10010           lodash.stubTrue = stubTrue;
10011           lodash.multiply = multiply;
10012           lodash.nth = nth;
10013           lodash.noConflict = noConflict;
10014           lodash.noop = noop3;
10015           lodash.now = now3;
10016           lodash.pad = pad2;
10017           lodash.padEnd = padEnd;
10018           lodash.padStart = padStart;
10019           lodash.parseInt = parseInt2;
10020           lodash.random = random;
10021           lodash.reduce = reduce;
10022           lodash.reduceRight = reduceRight;
10023           lodash.repeat = repeat;
10024           lodash.replace = replace;
10025           lodash.result = result;
10026           lodash.round = round;
10027           lodash.runInContext = runInContext2;
10028           lodash.sample = sample;
10029           lodash.size = size;
10030           lodash.snakeCase = snakeCase;
10031           lodash.some = some;
10032           lodash.sortedIndex = sortedIndex;
10033           lodash.sortedIndexBy = sortedIndexBy;
10034           lodash.sortedIndexOf = sortedIndexOf;
10035           lodash.sortedLastIndex = sortedLastIndex;
10036           lodash.sortedLastIndexBy = sortedLastIndexBy;
10037           lodash.sortedLastIndexOf = sortedLastIndexOf;
10038           lodash.startCase = startCase;
10039           lodash.startsWith = startsWith;
10040           lodash.subtract = subtract;
10041           lodash.sum = sum;
10042           lodash.sumBy = sumBy;
10043           lodash.template = template;
10044           lodash.times = times;
10045           lodash.toFinite = toFinite;
10046           lodash.toInteger = toInteger;
10047           lodash.toLength = toLength;
10048           lodash.toLower = toLower;
10049           lodash.toNumber = toNumber3;
10050           lodash.toSafeInteger = toSafeInteger;
10051           lodash.toString = toString2;
10052           lodash.toUpper = toUpper;
10053           lodash.trim = trim;
10054           lodash.trimEnd = trimEnd;
10055           lodash.trimStart = trimStart;
10056           lodash.truncate = truncate;
10057           lodash.unescape = unescape3;
10058           lodash.uniqueId = uniqueId;
10059           lodash.upperCase = upperCase;
10060           lodash.upperFirst = upperFirst;
10061           lodash.each = forEach;
10062           lodash.eachRight = forEachRight;
10063           lodash.first = head;
10064           mixin(lodash, function() {
10065             var source = {};
10066             baseForOwn(lodash, function(func, methodName) {
10067               if (!hasOwnProperty10.call(lodash.prototype, methodName)) {
10068                 source[methodName] = func;
10069               }
10070             });
10071             return source;
10072           }(), { "chain": false });
10073           lodash.VERSION = VERSION;
10074           arrayEach(["bind", "bindKey", "curry", "curryRight", "partial", "partialRight"], function(methodName) {
10075             lodash[methodName].placeholder = lodash;
10076           });
10077           arrayEach(["drop", "take"], function(methodName, index) {
10078             LazyWrapper.prototype[methodName] = function(n3) {
10079               n3 = n3 === undefined2 ? 1 : nativeMax2(toInteger(n3), 0);
10080               var result2 = this.__filtered__ && !index ? new LazyWrapper(this) : this.clone();
10081               if (result2.__filtered__) {
10082                 result2.__takeCount__ = nativeMin2(n3, result2.__takeCount__);
10083               } else {
10084                 result2.__views__.push({
10085                   "size": nativeMin2(n3, MAX_ARRAY_LENGTH),
10086                   "type": methodName + (result2.__dir__ < 0 ? "Right" : "")
10087                 });
10088               }
10089               return result2;
10090             };
10091             LazyWrapper.prototype[methodName + "Right"] = function(n3) {
10092               return this.reverse()[methodName](n3).reverse();
10093             };
10094           });
10095           arrayEach(["filter", "map", "takeWhile"], function(methodName, index) {
10096             var type2 = index + 1, isFilter = type2 == LAZY_FILTER_FLAG || type2 == LAZY_WHILE_FLAG;
10097             LazyWrapper.prototype[methodName] = function(iteratee2) {
10098               var result2 = this.clone();
10099               result2.__iteratees__.push({
10100                 "iteratee": getIteratee(iteratee2, 3),
10101                 "type": type2
10102               });
10103               result2.__filtered__ = result2.__filtered__ || isFilter;
10104               return result2;
10105             };
10106           });
10107           arrayEach(["head", "last"], function(methodName, index) {
10108             var takeName = "take" + (index ? "Right" : "");
10109             LazyWrapper.prototype[methodName] = function() {
10110               return this[takeName](1).value()[0];
10111             };
10112           });
10113           arrayEach(["initial", "tail"], function(methodName, index) {
10114             var dropName = "drop" + (index ? "" : "Right");
10115             LazyWrapper.prototype[methodName] = function() {
10116               return this.__filtered__ ? new LazyWrapper(this) : this[dropName](1);
10117             };
10118           });
10119           LazyWrapper.prototype.compact = function() {
10120             return this.filter(identity4);
10121           };
10122           LazyWrapper.prototype.find = function(predicate) {
10123             return this.filter(predicate).head();
10124           };
10125           LazyWrapper.prototype.findLast = function(predicate) {
10126             return this.reverse().find(predicate);
10127           };
10128           LazyWrapper.prototype.invokeMap = baseRest(function(path, args) {
10129             if (typeof path == "function") {
10130               return new LazyWrapper(this);
10131             }
10132             return this.map(function(value) {
10133               return baseInvoke(value, path, args);
10134             });
10135           });
10136           LazyWrapper.prototype.reject = function(predicate) {
10137             return this.filter(negate(getIteratee(predicate)));
10138           };
10139           LazyWrapper.prototype.slice = function(start2, end) {
10140             start2 = toInteger(start2);
10141             var result2 = this;
10142             if (result2.__filtered__ && (start2 > 0 || end < 0)) {
10143               return new LazyWrapper(result2);
10144             }
10145             if (start2 < 0) {
10146               result2 = result2.takeRight(-start2);
10147             } else if (start2) {
10148               result2 = result2.drop(start2);
10149             }
10150             if (end !== undefined2) {
10151               end = toInteger(end);
10152               result2 = end < 0 ? result2.dropRight(-end) : result2.take(end - start2);
10153             }
10154             return result2;
10155           };
10156           LazyWrapper.prototype.takeRightWhile = function(predicate) {
10157             return this.reverse().takeWhile(predicate).reverse();
10158           };
10159           LazyWrapper.prototype.toArray = function() {
10160             return this.take(MAX_ARRAY_LENGTH);
10161           };
10162           baseForOwn(LazyWrapper.prototype, function(func, methodName) {
10163             var checkIteratee = /^(?:filter|find|map|reject)|While$/.test(methodName), isTaker = /^(?:head|last)$/.test(methodName), lodashFunc = lodash[isTaker ? "take" + (methodName == "last" ? "Right" : "") : methodName], retUnwrapped = isTaker || /^find/.test(methodName);
10164             if (!lodashFunc) {
10165               return;
10166             }
10167             lodash.prototype[methodName] = function() {
10168               var value = this.__wrapped__, args = isTaker ? [1] : arguments, isLazy = value instanceof LazyWrapper, iteratee2 = args[0], useLazy = isLazy || isArray2(value);
10169               var interceptor = function(value2) {
10170                 var result3 = lodashFunc.apply(lodash, arrayPush2([value2], args));
10171                 return isTaker && chainAll ? result3[0] : result3;
10172               };
10173               if (useLazy && checkIteratee && typeof iteratee2 == "function" && iteratee2.length != 1) {
10174                 isLazy = useLazy = false;
10175               }
10176               var chainAll = this.__chain__, isHybrid = !!this.__actions__.length, isUnwrapped = retUnwrapped && !chainAll, onlyLazy = isLazy && !isHybrid;
10177               if (!retUnwrapped && useLazy) {
10178                 value = onlyLazy ? value : new LazyWrapper(this);
10179                 var result2 = func.apply(value, args);
10180                 result2.__actions__.push({ "func": thru, "args": [interceptor], "thisArg": undefined2 });
10181                 return new LodashWrapper(result2, chainAll);
10182               }
10183               if (isUnwrapped && onlyLazy) {
10184                 return func.apply(this, args);
10185               }
10186               result2 = this.thru(interceptor);
10187               return isUnwrapped ? isTaker ? result2.value()[0] : result2.value() : result2;
10188             };
10189           });
10190           arrayEach(["pop", "push", "shift", "sort", "splice", "unshift"], function(methodName) {
10191             var func = arrayProto2[methodName], chainName = /^(?:push|sort|unshift)$/.test(methodName) ? "tap" : "thru", retUnwrapped = /^(?:pop|shift)$/.test(methodName);
10192             lodash.prototype[methodName] = function() {
10193               var args = arguments;
10194               if (retUnwrapped && !this.__chain__) {
10195                 var value = this.value();
10196                 return func.apply(isArray2(value) ? value : [], args);
10197               }
10198               return this[chainName](function(value2) {
10199                 return func.apply(isArray2(value2) ? value2 : [], args);
10200               });
10201             };
10202           });
10203           baseForOwn(LazyWrapper.prototype, function(func, methodName) {
10204             var lodashFunc = lodash[methodName];
10205             if (lodashFunc) {
10206               var key = lodashFunc.name + "";
10207               if (!hasOwnProperty10.call(realNames, key)) {
10208                 realNames[key] = [];
10209               }
10210               realNames[key].push({ "name": methodName, "func": lodashFunc });
10211             }
10212           });
10213           realNames[createHybrid(undefined2, WRAP_BIND_KEY_FLAG).name] = [{
10214             "name": "wrapper",
10215             "func": undefined2
10216           }];
10217           LazyWrapper.prototype.clone = lazyClone;
10218           LazyWrapper.prototype.reverse = lazyReverse;
10219           LazyWrapper.prototype.value = lazyValue;
10220           lodash.prototype.at = wrapperAt;
10221           lodash.prototype.chain = wrapperChain;
10222           lodash.prototype.commit = wrapperCommit;
10223           lodash.prototype.next = wrapperNext;
10224           lodash.prototype.plant = wrapperPlant;
10225           lodash.prototype.reverse = wrapperReverse;
10226           lodash.prototype.toJSON = lodash.prototype.valueOf = lodash.prototype.value = wrapperValue;
10227           lodash.prototype.first = lodash.prototype.head;
10228           if (symIterator) {
10229             lodash.prototype[symIterator] = wrapperToIterator;
10230           }
10231           return lodash;
10232         };
10233         var _2 = runInContext();
10234         if (typeof define == "function" && typeof define.amd == "object" && define.amd) {
10235           root3._ = _2;
10236           define(function() {
10237             return _2;
10238           });
10239         } else if (freeModule3) {
10240           (freeModule3.exports = _2)._ = _2;
10241           freeExports3._ = _2;
10242         } else {
10243           root3._ = _2;
10244         }
10245       }).call(exports2);
10246     }
10247   });
10248
10249   // node_modules/fast-deep-equal/index.js
10250   var require_fast_deep_equal = __commonJS({
10251     "node_modules/fast-deep-equal/index.js"(exports2, module2) {
10252       "use strict";
10253       module2.exports = function equal(a2, b2) {
10254         if (a2 === b2)
10255           return true;
10256         if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
10257           if (a2.constructor !== b2.constructor)
10258             return false;
10259           var length2, i3, keys2;
10260           if (Array.isArray(a2)) {
10261             length2 = a2.length;
10262             if (length2 != b2.length)
10263               return false;
10264             for (i3 = length2; i3-- !== 0; )
10265               if (!equal(a2[i3], b2[i3]))
10266                 return false;
10267             return true;
10268           }
10269           if (a2.constructor === RegExp)
10270             return a2.source === b2.source && a2.flags === b2.flags;
10271           if (a2.valueOf !== Object.prototype.valueOf)
10272             return a2.valueOf() === b2.valueOf();
10273           if (a2.toString !== Object.prototype.toString)
10274             return a2.toString() === b2.toString();
10275           keys2 = Object.keys(a2);
10276           length2 = keys2.length;
10277           if (length2 !== Object.keys(b2).length)
10278             return false;
10279           for (i3 = length2; i3-- !== 0; )
10280             if (!Object.prototype.hasOwnProperty.call(b2, keys2[i3]))
10281               return false;
10282           for (i3 = length2; i3-- !== 0; ) {
10283             var key = keys2[i3];
10284             if (!equal(a2[key], b2[key]))
10285               return false;
10286           }
10287           return true;
10288         }
10289         return a2 !== a2 && b2 !== b2;
10290       };
10291     }
10292   });
10293
10294   // node_modules/rbush/rbush.min.js
10295   var require_rbush_min = __commonJS({
10296     "node_modules/rbush/rbush.min.js"(exports2, module2) {
10297       !function(t2, i3) {
10298         "object" == typeof exports2 && "undefined" != typeof module2 ? module2.exports = i3() : "function" == typeof define && define.amd ? define(i3) : (t2 = t2 || self).RBush = i3();
10299       }(exports2, function() {
10300         "use strict";
10301         function t2(t3, r3, e4, a3, h3) {
10302           !function t4(n4, r4, e6, a4, h4) {
10303             for (; a4 > e6; ) {
10304               if (a4 - e6 > 600) {
10305                 var o3 = a4 - e6 + 1, s3 = r4 - e6 + 1, l3 = Math.log(o3), f3 = 0.5 * Math.exp(2 * l3 / 3), u3 = 0.5 * Math.sqrt(l3 * f3 * (o3 - f3) / o3) * (s3 - o3 / 2 < 0 ? -1 : 1), m3 = Math.max(e6, Math.floor(r4 - s3 * f3 / o3 + u3)), c3 = Math.min(a4, Math.floor(r4 + (o3 - s3) * f3 / o3 + u3));
10306                 t4(n4, r4, m3, c3, h4);
10307               }
10308               var p3 = n4[r4], d4 = e6, x2 = a4;
10309               for (i3(n4, e6, r4), h4(n4[a4], p3) > 0 && i3(n4, e6, a4); d4 < x2; ) {
10310                 for (i3(n4, d4, x2), d4++, x2--; h4(n4[d4], p3) < 0; )
10311                   d4++;
10312                 for (; h4(n4[x2], p3) > 0; )
10313                   x2--;
10314               }
10315               0 === h4(n4[e6], p3) ? i3(n4, e6, x2) : i3(n4, ++x2, a4), x2 <= r4 && (e6 = x2 + 1), r4 <= x2 && (a4 = x2 - 1);
10316             }
10317           }(t3, r3, e4 || 0, a3 || t3.length - 1, h3 || n3);
10318         }
10319         function i3(t3, i4, n4) {
10320           var r3 = t3[i4];
10321           t3[i4] = t3[n4], t3[n4] = r3;
10322         }
10323         function n3(t3, i4) {
10324           return t3 < i4 ? -1 : t3 > i4 ? 1 : 0;
10325         }
10326         var r2 = function(t3) {
10327           void 0 === t3 && (t3 = 9), this._maxEntries = Math.max(4, t3), this._minEntries = Math.max(2, Math.ceil(0.4 * this._maxEntries)), this.clear();
10328         };
10329         function e3(t3, i4, n4) {
10330           if (!n4)
10331             return i4.indexOf(t3);
10332           for (var r3 = 0; r3 < i4.length; r3++)
10333             if (n4(t3, i4[r3]))
10334               return r3;
10335           return -1;
10336         }
10337         function a2(t3, i4) {
10338           h2(t3, 0, t3.children.length, i4, t3);
10339         }
10340         function h2(t3, i4, n4, r3, e4) {
10341           e4 || (e4 = p2(null)), e4.minX = 1 / 0, e4.minY = 1 / 0, e4.maxX = -1 / 0, e4.maxY = -1 / 0;
10342           for (var a3 = i4; a3 < n4; a3++) {
10343             var h3 = t3.children[a3];
10344             o2(e4, t3.leaf ? r3(h3) : h3);
10345           }
10346           return e4;
10347         }
10348         function o2(t3, i4) {
10349           return t3.minX = Math.min(t3.minX, i4.minX), t3.minY = Math.min(t3.minY, i4.minY), t3.maxX = Math.max(t3.maxX, i4.maxX), t3.maxY = Math.max(t3.maxY, i4.maxY), t3;
10350         }
10351         function s2(t3, i4) {
10352           return t3.minX - i4.minX;
10353         }
10354         function l2(t3, i4) {
10355           return t3.minY - i4.minY;
10356         }
10357         function f2(t3) {
10358           return (t3.maxX - t3.minX) * (t3.maxY - t3.minY);
10359         }
10360         function u2(t3) {
10361           return t3.maxX - t3.minX + (t3.maxY - t3.minY);
10362         }
10363         function m2(t3, i4) {
10364           return t3.minX <= i4.minX && t3.minY <= i4.minY && i4.maxX <= t3.maxX && i4.maxY <= t3.maxY;
10365         }
10366         function c2(t3, i4) {
10367           return i4.minX <= t3.maxX && i4.minY <= t3.maxY && i4.maxX >= t3.minX && i4.maxY >= t3.minY;
10368         }
10369         function p2(t3) {
10370           return { children: t3, height: 1, leaf: true, minX: 1 / 0, minY: 1 / 0, maxX: -1 / 0, maxY: -1 / 0 };
10371         }
10372         function d2(i4, n4, r3, e4, a3) {
10373           for (var h3 = [n4, r3]; h3.length; )
10374             if (!((r3 = h3.pop()) - (n4 = h3.pop()) <= e4)) {
10375               var o3 = n4 + Math.ceil((r3 - n4) / e4 / 2) * e4;
10376               t2(i4, o3, n4, r3, a3), h3.push(n4, o3, o3, r3);
10377             }
10378         }
10379         return r2.prototype.all = function() {
10380           return this._all(this.data, []);
10381         }, r2.prototype.search = function(t3) {
10382           var i4 = this.data, n4 = [];
10383           if (!c2(t3, i4))
10384             return n4;
10385           for (var r3 = this.toBBox, e4 = []; i4; ) {
10386             for (var a3 = 0; a3 < i4.children.length; a3++) {
10387               var h3 = i4.children[a3], o3 = i4.leaf ? r3(h3) : h3;
10388               c2(t3, o3) && (i4.leaf ? n4.push(h3) : m2(t3, o3) ? this._all(h3, n4) : e4.push(h3));
10389             }
10390             i4 = e4.pop();
10391           }
10392           return n4;
10393         }, r2.prototype.collides = function(t3) {
10394           var i4 = this.data;
10395           if (!c2(t3, i4))
10396             return false;
10397           for (var n4 = []; i4; ) {
10398             for (var r3 = 0; r3 < i4.children.length; r3++) {
10399               var e4 = i4.children[r3], a3 = i4.leaf ? this.toBBox(e4) : e4;
10400               if (c2(t3, a3)) {
10401                 if (i4.leaf || m2(t3, a3))
10402                   return true;
10403                 n4.push(e4);
10404               }
10405             }
10406             i4 = n4.pop();
10407           }
10408           return false;
10409         }, r2.prototype.load = function(t3) {
10410           if (!t3 || !t3.length)
10411             return this;
10412           if (t3.length < this._minEntries) {
10413             for (var i4 = 0; i4 < t3.length; i4++)
10414               this.insert(t3[i4]);
10415             return this;
10416           }
10417           var n4 = this._build(t3.slice(), 0, t3.length - 1, 0);
10418           if (this.data.children.length)
10419             if (this.data.height === n4.height)
10420               this._splitRoot(this.data, n4);
10421             else {
10422               if (this.data.height < n4.height) {
10423                 var r3 = this.data;
10424                 this.data = n4, n4 = r3;
10425               }
10426               this._insert(n4, this.data.height - n4.height - 1, true);
10427             }
10428           else
10429             this.data = n4;
10430           return this;
10431         }, r2.prototype.insert = function(t3) {
10432           return t3 && this._insert(t3, this.data.height - 1), this;
10433         }, r2.prototype.clear = function() {
10434           return this.data = p2([]), this;
10435         }, r2.prototype.remove = function(t3, i4) {
10436           if (!t3)
10437             return this;
10438           for (var n4, r3, a3, h3 = this.data, o3 = this.toBBox(t3), s3 = [], l3 = []; h3 || s3.length; ) {
10439             if (h3 || (h3 = s3.pop(), r3 = s3[s3.length - 1], n4 = l3.pop(), a3 = true), h3.leaf) {
10440               var f3 = e3(t3, h3.children, i4);
10441               if (-1 !== f3)
10442                 return h3.children.splice(f3, 1), s3.push(h3), this._condense(s3), this;
10443             }
10444             a3 || h3.leaf || !m2(h3, o3) ? r3 ? (n4++, h3 = r3.children[n4], a3 = false) : h3 = null : (s3.push(h3), l3.push(n4), n4 = 0, r3 = h3, h3 = h3.children[0]);
10445           }
10446           return this;
10447         }, r2.prototype.toBBox = function(t3) {
10448           return t3;
10449         }, r2.prototype.compareMinX = function(t3, i4) {
10450           return t3.minX - i4.minX;
10451         }, r2.prototype.compareMinY = function(t3, i4) {
10452           return t3.minY - i4.minY;
10453         }, r2.prototype.toJSON = function() {
10454           return this.data;
10455         }, r2.prototype.fromJSON = function(t3) {
10456           return this.data = t3, this;
10457         }, r2.prototype._all = function(t3, i4) {
10458           for (var n4 = []; t3; )
10459             t3.leaf ? i4.push.apply(i4, t3.children) : n4.push.apply(n4, t3.children), t3 = n4.pop();
10460           return i4;
10461         }, r2.prototype._build = function(t3, i4, n4, r3) {
10462           var e4, h3 = n4 - i4 + 1, o3 = this._maxEntries;
10463           if (h3 <= o3)
10464             return a2(e4 = p2(t3.slice(i4, n4 + 1)), this.toBBox), e4;
10465           r3 || (r3 = Math.ceil(Math.log(h3) / Math.log(o3)), o3 = Math.ceil(h3 / Math.pow(o3, r3 - 1))), (e4 = p2([])).leaf = false, e4.height = r3;
10466           var s3 = Math.ceil(h3 / o3), l3 = s3 * Math.ceil(Math.sqrt(o3));
10467           d2(t3, i4, n4, l3, this.compareMinX);
10468           for (var f3 = i4; f3 <= n4; f3 += l3) {
10469             var u3 = Math.min(f3 + l3 - 1, n4);
10470             d2(t3, f3, u3, s3, this.compareMinY);
10471             for (var m3 = f3; m3 <= u3; m3 += s3) {
10472               var c3 = Math.min(m3 + s3 - 1, u3);
10473               e4.children.push(this._build(t3, m3, c3, r3 - 1));
10474             }
10475           }
10476           return a2(e4, this.toBBox), e4;
10477         }, r2.prototype._chooseSubtree = function(t3, i4, n4, r3) {
10478           for (; r3.push(i4), !i4.leaf && r3.length - 1 !== n4; ) {
10479             for (var e4 = 1 / 0, a3 = 1 / 0, h3 = void 0, o3 = 0; o3 < i4.children.length; o3++) {
10480               var s3 = i4.children[o3], l3 = f2(s3), u3 = (m3 = t3, c3 = s3, (Math.max(c3.maxX, m3.maxX) - Math.min(c3.minX, m3.minX)) * (Math.max(c3.maxY, m3.maxY) - Math.min(c3.minY, m3.minY)) - l3);
10481               u3 < a3 ? (a3 = u3, e4 = l3 < e4 ? l3 : e4, h3 = s3) : u3 === a3 && l3 < e4 && (e4 = l3, h3 = s3);
10482             }
10483             i4 = h3 || i4.children[0];
10484           }
10485           var m3, c3;
10486           return i4;
10487         }, r2.prototype._insert = function(t3, i4, n4) {
10488           var r3 = n4 ? t3 : this.toBBox(t3), e4 = [], a3 = this._chooseSubtree(r3, this.data, i4, e4);
10489           for (a3.children.push(t3), o2(a3, r3); i4 >= 0 && e4[i4].children.length > this._maxEntries; )
10490             this._split(e4, i4), i4--;
10491           this._adjustParentBBoxes(r3, e4, i4);
10492         }, r2.prototype._split = function(t3, i4) {
10493           var n4 = t3[i4], r3 = n4.children.length, e4 = this._minEntries;
10494           this._chooseSplitAxis(n4, e4, r3);
10495           var h3 = this._chooseSplitIndex(n4, e4, r3), o3 = p2(n4.children.splice(h3, n4.children.length - h3));
10496           o3.height = n4.height, o3.leaf = n4.leaf, a2(n4, this.toBBox), a2(o3, this.toBBox), i4 ? t3[i4 - 1].children.push(o3) : this._splitRoot(n4, o3);
10497         }, r2.prototype._splitRoot = function(t3, i4) {
10498           this.data = p2([t3, i4]), this.data.height = t3.height + 1, this.data.leaf = false, a2(this.data, this.toBBox);
10499         }, r2.prototype._chooseSplitIndex = function(t3, i4, n4) {
10500           for (var r3, e4, a3, o3, s3, l3, u3, m3 = 1 / 0, c3 = 1 / 0, p3 = i4; p3 <= n4 - i4; p3++) {
10501             var d4 = h2(t3, 0, p3, this.toBBox), x2 = h2(t3, p3, n4, this.toBBox), v2 = (e4 = d4, a3 = x2, o3 = void 0, s3 = void 0, l3 = void 0, u3 = void 0, o3 = Math.max(e4.minX, a3.minX), s3 = Math.max(e4.minY, a3.minY), l3 = Math.min(e4.maxX, a3.maxX), u3 = Math.min(e4.maxY, a3.maxY), Math.max(0, l3 - o3) * Math.max(0, u3 - s3)), M2 = f2(d4) + f2(x2);
10502             v2 < m3 ? (m3 = v2, r3 = p3, c3 = M2 < c3 ? M2 : c3) : v2 === m3 && M2 < c3 && (c3 = M2, r3 = p3);
10503           }
10504           return r3 || n4 - i4;
10505         }, r2.prototype._chooseSplitAxis = function(t3, i4, n4) {
10506           var r3 = t3.leaf ? this.compareMinX : s2, e4 = t3.leaf ? this.compareMinY : l2;
10507           this._allDistMargin(t3, i4, n4, r3) < this._allDistMargin(t3, i4, n4, e4) && t3.children.sort(r3);
10508         }, r2.prototype._allDistMargin = function(t3, i4, n4, r3) {
10509           t3.children.sort(r3);
10510           for (var e4 = this.toBBox, a3 = h2(t3, 0, i4, e4), s3 = h2(t3, n4 - i4, n4, e4), l3 = u2(a3) + u2(s3), f3 = i4; f3 < n4 - i4; f3++) {
10511             var m3 = t3.children[f3];
10512             o2(a3, t3.leaf ? e4(m3) : m3), l3 += u2(a3);
10513           }
10514           for (var c3 = n4 - i4 - 1; c3 >= i4; c3--) {
10515             var p3 = t3.children[c3];
10516             o2(s3, t3.leaf ? e4(p3) : p3), l3 += u2(s3);
10517           }
10518           return l3;
10519         }, r2.prototype._adjustParentBBoxes = function(t3, i4, n4) {
10520           for (var r3 = n4; r3 >= 0; r3--)
10521             o2(i4[r3], t3);
10522         }, r2.prototype._condense = function(t3) {
10523           for (var i4 = t3.length - 1, n4 = void 0; i4 >= 0; i4--)
10524             0 === t3[i4].children.length ? i4 > 0 ? (n4 = t3[i4 - 1].children).splice(n4.indexOf(t3[i4]), 1) : this.clear() : a2(t3[i4], this.toBBox);
10525         }, r2;
10526       });
10527     }
10528   });
10529
10530   // node_modules/ieee754/index.js
10531   var require_ieee754 = __commonJS({
10532     "node_modules/ieee754/index.js"(exports2) {
10533       exports2.read = function(buffer, offset, isLE, mLen, nBytes) {
10534         var e3, m2;
10535         var eLen = nBytes * 8 - mLen - 1;
10536         var eMax = (1 << eLen) - 1;
10537         var eBias = eMax >> 1;
10538         var nBits = -7;
10539         var i3 = isLE ? nBytes - 1 : 0;
10540         var d2 = isLE ? -1 : 1;
10541         var s2 = buffer[offset + i3];
10542         i3 += d2;
10543         e3 = s2 & (1 << -nBits) - 1;
10544         s2 >>= -nBits;
10545         nBits += eLen;
10546         for (; nBits > 0; e3 = e3 * 256 + buffer[offset + i3], i3 += d2, nBits -= 8) {
10547         }
10548         m2 = e3 & (1 << -nBits) - 1;
10549         e3 >>= -nBits;
10550         nBits += mLen;
10551         for (; nBits > 0; m2 = m2 * 256 + buffer[offset + i3], i3 += d2, nBits -= 8) {
10552         }
10553         if (e3 === 0) {
10554           e3 = 1 - eBias;
10555         } else if (e3 === eMax) {
10556           return m2 ? NaN : (s2 ? -1 : 1) * Infinity;
10557         } else {
10558           m2 = m2 + Math.pow(2, mLen);
10559           e3 = e3 - eBias;
10560         }
10561         return (s2 ? -1 : 1) * m2 * Math.pow(2, e3 - mLen);
10562       };
10563       exports2.write = function(buffer, value, offset, isLE, mLen, nBytes) {
10564         var e3, m2, c2;
10565         var eLen = nBytes * 8 - mLen - 1;
10566         var eMax = (1 << eLen) - 1;
10567         var eBias = eMax >> 1;
10568         var rt = mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0;
10569         var i3 = isLE ? 0 : nBytes - 1;
10570         var d2 = isLE ? 1 : -1;
10571         var s2 = value < 0 || value === 0 && 1 / value < 0 ? 1 : 0;
10572         value = Math.abs(value);
10573         if (isNaN(value) || value === Infinity) {
10574           m2 = isNaN(value) ? 1 : 0;
10575           e3 = eMax;
10576         } else {
10577           e3 = Math.floor(Math.log(value) / Math.LN2);
10578           if (value * (c2 = Math.pow(2, -e3)) < 1) {
10579             e3--;
10580             c2 *= 2;
10581           }
10582           if (e3 + eBias >= 1) {
10583             value += rt / c2;
10584           } else {
10585             value += rt * Math.pow(2, 1 - eBias);
10586           }
10587           if (value * c2 >= 2) {
10588             e3++;
10589             c2 /= 2;
10590           }
10591           if (e3 + eBias >= eMax) {
10592             m2 = 0;
10593             e3 = eMax;
10594           } else if (e3 + eBias >= 1) {
10595             m2 = (value * c2 - 1) * Math.pow(2, mLen);
10596             e3 = e3 + eBias;
10597           } else {
10598             m2 = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen);
10599             e3 = 0;
10600           }
10601         }
10602         for (; mLen >= 8; buffer[offset + i3] = m2 & 255, i3 += d2, m2 /= 256, mLen -= 8) {
10603         }
10604         e3 = e3 << mLen | m2;
10605         eLen += mLen;
10606         for (; eLen > 0; buffer[offset + i3] = e3 & 255, i3 += d2, e3 /= 256, eLen -= 8) {
10607         }
10608         buffer[offset + i3 - d2] |= s2 * 128;
10609       };
10610     }
10611   });
10612
10613   // node_modules/pbf/index.js
10614   var require_pbf = __commonJS({
10615     "node_modules/pbf/index.js"(exports2, module2) {
10616       "use strict";
10617       module2.exports = Pbf;
10618       var ieee754 = require_ieee754();
10619       function Pbf(buf) {
10620         this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);
10621         this.pos = 0;
10622         this.type = 0;
10623         this.length = this.buf.length;
10624       }
10625       Pbf.Varint = 0;
10626       Pbf.Fixed64 = 1;
10627       Pbf.Bytes = 2;
10628       Pbf.Fixed32 = 5;
10629       var SHIFT_LEFT_32 = (1 << 16) * (1 << 16);
10630       var SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;
10631       var TEXT_DECODER_MIN_LENGTH = 12;
10632       var utf8TextDecoder = typeof TextDecoder === "undefined" ? null : new TextDecoder("utf8");
10633       Pbf.prototype = {
10634         destroy: function() {
10635           this.buf = null;
10636         },
10637         // === READING =================================================================
10638         readFields: function(readField, result, end) {
10639           end = end || this.length;
10640           while (this.pos < end) {
10641             var val = this.readVarint(), tag2 = val >> 3, startPos = this.pos;
10642             this.type = val & 7;
10643             readField(tag2, result, this);
10644             if (this.pos === startPos)
10645               this.skip(val);
10646           }
10647           return result;
10648         },
10649         readMessage: function(readField, result) {
10650           return this.readFields(readField, result, this.readVarint() + this.pos);
10651         },
10652         readFixed32: function() {
10653           var val = readUInt32(this.buf, this.pos);
10654           this.pos += 4;
10655           return val;
10656         },
10657         readSFixed32: function() {
10658           var val = readInt32(this.buf, this.pos);
10659           this.pos += 4;
10660           return val;
10661         },
10662         // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)
10663         readFixed64: function() {
10664           var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
10665           this.pos += 8;
10666           return val;
10667         },
10668         readSFixed64: function() {
10669           var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;
10670           this.pos += 8;
10671           return val;
10672         },
10673         readFloat: function() {
10674           var val = ieee754.read(this.buf, this.pos, true, 23, 4);
10675           this.pos += 4;
10676           return val;
10677         },
10678         readDouble: function() {
10679           var val = ieee754.read(this.buf, this.pos, true, 52, 8);
10680           this.pos += 8;
10681           return val;
10682         },
10683         readVarint: function(isSigned) {
10684           var buf = this.buf, val, b2;
10685           b2 = buf[this.pos++];
10686           val = b2 & 127;
10687           if (b2 < 128)
10688             return val;
10689           b2 = buf[this.pos++];
10690           val |= (b2 & 127) << 7;
10691           if (b2 < 128)
10692             return val;
10693           b2 = buf[this.pos++];
10694           val |= (b2 & 127) << 14;
10695           if (b2 < 128)
10696             return val;
10697           b2 = buf[this.pos++];
10698           val |= (b2 & 127) << 21;
10699           if (b2 < 128)
10700             return val;
10701           b2 = buf[this.pos];
10702           val |= (b2 & 15) << 28;
10703           return readVarintRemainder(val, isSigned, this);
10704         },
10705         readVarint64: function() {
10706           return this.readVarint(true);
10707         },
10708         readSVarint: function() {
10709           var num = this.readVarint();
10710           return num % 2 === 1 ? (num + 1) / -2 : num / 2;
10711         },
10712         readBoolean: function() {
10713           return Boolean(this.readVarint());
10714         },
10715         readString: function() {
10716           var end = this.readVarint() + this.pos;
10717           var pos = this.pos;
10718           this.pos = end;
10719           if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {
10720             return readUtf8TextDecoder(this.buf, pos, end);
10721           }
10722           return readUtf8(this.buf, pos, end);
10723         },
10724         readBytes: function() {
10725           var end = this.readVarint() + this.pos, buffer = this.buf.subarray(this.pos, end);
10726           this.pos = end;
10727           return buffer;
10728         },
10729         // verbose for performance reasons; doesn't affect gzipped size
10730         readPackedVarint: function(arr, isSigned) {
10731           if (this.type !== Pbf.Bytes)
10732             return arr.push(this.readVarint(isSigned));
10733           var end = readPackedEnd(this);
10734           arr = arr || [];
10735           while (this.pos < end)
10736             arr.push(this.readVarint(isSigned));
10737           return arr;
10738         },
10739         readPackedSVarint: function(arr) {
10740           if (this.type !== Pbf.Bytes)
10741             return arr.push(this.readSVarint());
10742           var end = readPackedEnd(this);
10743           arr = arr || [];
10744           while (this.pos < end)
10745             arr.push(this.readSVarint());
10746           return arr;
10747         },
10748         readPackedBoolean: function(arr) {
10749           if (this.type !== Pbf.Bytes)
10750             return arr.push(this.readBoolean());
10751           var end = readPackedEnd(this);
10752           arr = arr || [];
10753           while (this.pos < end)
10754             arr.push(this.readBoolean());
10755           return arr;
10756         },
10757         readPackedFloat: function(arr) {
10758           if (this.type !== Pbf.Bytes)
10759             return arr.push(this.readFloat());
10760           var end = readPackedEnd(this);
10761           arr = arr || [];
10762           while (this.pos < end)
10763             arr.push(this.readFloat());
10764           return arr;
10765         },
10766         readPackedDouble: function(arr) {
10767           if (this.type !== Pbf.Bytes)
10768             return arr.push(this.readDouble());
10769           var end = readPackedEnd(this);
10770           arr = arr || [];
10771           while (this.pos < end)
10772             arr.push(this.readDouble());
10773           return arr;
10774         },
10775         readPackedFixed32: function(arr) {
10776           if (this.type !== Pbf.Bytes)
10777             return arr.push(this.readFixed32());
10778           var end = readPackedEnd(this);
10779           arr = arr || [];
10780           while (this.pos < end)
10781             arr.push(this.readFixed32());
10782           return arr;
10783         },
10784         readPackedSFixed32: function(arr) {
10785           if (this.type !== Pbf.Bytes)
10786             return arr.push(this.readSFixed32());
10787           var end = readPackedEnd(this);
10788           arr = arr || [];
10789           while (this.pos < end)
10790             arr.push(this.readSFixed32());
10791           return arr;
10792         },
10793         readPackedFixed64: function(arr) {
10794           if (this.type !== Pbf.Bytes)
10795             return arr.push(this.readFixed64());
10796           var end = readPackedEnd(this);
10797           arr = arr || [];
10798           while (this.pos < end)
10799             arr.push(this.readFixed64());
10800           return arr;
10801         },
10802         readPackedSFixed64: function(arr) {
10803           if (this.type !== Pbf.Bytes)
10804             return arr.push(this.readSFixed64());
10805           var end = readPackedEnd(this);
10806           arr = arr || [];
10807           while (this.pos < end)
10808             arr.push(this.readSFixed64());
10809           return arr;
10810         },
10811         skip: function(val) {
10812           var type2 = val & 7;
10813           if (type2 === Pbf.Varint)
10814             while (this.buf[this.pos++] > 127) {
10815             }
10816           else if (type2 === Pbf.Bytes)
10817             this.pos = this.readVarint() + this.pos;
10818           else if (type2 === Pbf.Fixed32)
10819             this.pos += 4;
10820           else if (type2 === Pbf.Fixed64)
10821             this.pos += 8;
10822           else
10823             throw new Error("Unimplemented type: " + type2);
10824         },
10825         // === WRITING =================================================================
10826         writeTag: function(tag2, type2) {
10827           this.writeVarint(tag2 << 3 | type2);
10828         },
10829         realloc: function(min3) {
10830           var length2 = this.length || 16;
10831           while (length2 < this.pos + min3)
10832             length2 *= 2;
10833           if (length2 !== this.length) {
10834             var buf = new Uint8Array(length2);
10835             buf.set(this.buf);
10836             this.buf = buf;
10837             this.length = length2;
10838           }
10839         },
10840         finish: function() {
10841           this.length = this.pos;
10842           this.pos = 0;
10843           return this.buf.subarray(0, this.length);
10844         },
10845         writeFixed32: function(val) {
10846           this.realloc(4);
10847           writeInt32(this.buf, val, this.pos);
10848           this.pos += 4;
10849         },
10850         writeSFixed32: function(val) {
10851           this.realloc(4);
10852           writeInt32(this.buf, val, this.pos);
10853           this.pos += 4;
10854         },
10855         writeFixed64: function(val) {
10856           this.realloc(8);
10857           writeInt32(this.buf, val & -1, this.pos);
10858           writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
10859           this.pos += 8;
10860         },
10861         writeSFixed64: function(val) {
10862           this.realloc(8);
10863           writeInt32(this.buf, val & -1, this.pos);
10864           writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);
10865           this.pos += 8;
10866         },
10867         writeVarint: function(val) {
10868           val = +val || 0;
10869           if (val > 268435455 || val < 0) {
10870             writeBigVarint(val, this);
10871             return;
10872           }
10873           this.realloc(4);
10874           this.buf[this.pos++] = val & 127 | (val > 127 ? 128 : 0);
10875           if (val <= 127)
10876             return;
10877           this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
10878           if (val <= 127)
10879             return;
10880           this.buf[this.pos++] = (val >>>= 7) & 127 | (val > 127 ? 128 : 0);
10881           if (val <= 127)
10882             return;
10883           this.buf[this.pos++] = val >>> 7 & 127;
10884         },
10885         writeSVarint: function(val) {
10886           this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);
10887         },
10888         writeBoolean: function(val) {
10889           this.writeVarint(Boolean(val));
10890         },
10891         writeString: function(str) {
10892           str = String(str);
10893           this.realloc(str.length * 4);
10894           this.pos++;
10895           var startPos = this.pos;
10896           this.pos = writeUtf8(this.buf, str, this.pos);
10897           var len = this.pos - startPos;
10898           if (len >= 128)
10899             makeRoomForExtraLength(startPos, len, this);
10900           this.pos = startPos - 1;
10901           this.writeVarint(len);
10902           this.pos += len;
10903         },
10904         writeFloat: function(val) {
10905           this.realloc(4);
10906           ieee754.write(this.buf, val, this.pos, true, 23, 4);
10907           this.pos += 4;
10908         },
10909         writeDouble: function(val) {
10910           this.realloc(8);
10911           ieee754.write(this.buf, val, this.pos, true, 52, 8);
10912           this.pos += 8;
10913         },
10914         writeBytes: function(buffer) {
10915           var len = buffer.length;
10916           this.writeVarint(len);
10917           this.realloc(len);
10918           for (var i3 = 0; i3 < len; i3++)
10919             this.buf[this.pos++] = buffer[i3];
10920         },
10921         writeRawMessage: function(fn, obj) {
10922           this.pos++;
10923           var startPos = this.pos;
10924           fn(obj, this);
10925           var len = this.pos - startPos;
10926           if (len >= 128)
10927             makeRoomForExtraLength(startPos, len, this);
10928           this.pos = startPos - 1;
10929           this.writeVarint(len);
10930           this.pos += len;
10931         },
10932         writeMessage: function(tag2, fn, obj) {
10933           this.writeTag(tag2, Pbf.Bytes);
10934           this.writeRawMessage(fn, obj);
10935         },
10936         writePackedVarint: function(tag2, arr) {
10937           if (arr.length)
10938             this.writeMessage(tag2, writePackedVarint, arr);
10939         },
10940         writePackedSVarint: function(tag2, arr) {
10941           if (arr.length)
10942             this.writeMessage(tag2, writePackedSVarint, arr);
10943         },
10944         writePackedBoolean: function(tag2, arr) {
10945           if (arr.length)
10946             this.writeMessage(tag2, writePackedBoolean, arr);
10947         },
10948         writePackedFloat: function(tag2, arr) {
10949           if (arr.length)
10950             this.writeMessage(tag2, writePackedFloat, arr);
10951         },
10952         writePackedDouble: function(tag2, arr) {
10953           if (arr.length)
10954             this.writeMessage(tag2, writePackedDouble, arr);
10955         },
10956         writePackedFixed32: function(tag2, arr) {
10957           if (arr.length)
10958             this.writeMessage(tag2, writePackedFixed32, arr);
10959         },
10960         writePackedSFixed32: function(tag2, arr) {
10961           if (arr.length)
10962             this.writeMessage(tag2, writePackedSFixed32, arr);
10963         },
10964         writePackedFixed64: function(tag2, arr) {
10965           if (arr.length)
10966             this.writeMessage(tag2, writePackedFixed64, arr);
10967         },
10968         writePackedSFixed64: function(tag2, arr) {
10969           if (arr.length)
10970             this.writeMessage(tag2, writePackedSFixed64, arr);
10971         },
10972         writeBytesField: function(tag2, buffer) {
10973           this.writeTag(tag2, Pbf.Bytes);
10974           this.writeBytes(buffer);
10975         },
10976         writeFixed32Field: function(tag2, val) {
10977           this.writeTag(tag2, Pbf.Fixed32);
10978           this.writeFixed32(val);
10979         },
10980         writeSFixed32Field: function(tag2, val) {
10981           this.writeTag(tag2, Pbf.Fixed32);
10982           this.writeSFixed32(val);
10983         },
10984         writeFixed64Field: function(tag2, val) {
10985           this.writeTag(tag2, Pbf.Fixed64);
10986           this.writeFixed64(val);
10987         },
10988         writeSFixed64Field: function(tag2, val) {
10989           this.writeTag(tag2, Pbf.Fixed64);
10990           this.writeSFixed64(val);
10991         },
10992         writeVarintField: function(tag2, val) {
10993           this.writeTag(tag2, Pbf.Varint);
10994           this.writeVarint(val);
10995         },
10996         writeSVarintField: function(tag2, val) {
10997           this.writeTag(tag2, Pbf.Varint);
10998           this.writeSVarint(val);
10999         },
11000         writeStringField: function(tag2, str) {
11001           this.writeTag(tag2, Pbf.Bytes);
11002           this.writeString(str);
11003         },
11004         writeFloatField: function(tag2, val) {
11005           this.writeTag(tag2, Pbf.Fixed32);
11006           this.writeFloat(val);
11007         },
11008         writeDoubleField: function(tag2, val) {
11009           this.writeTag(tag2, Pbf.Fixed64);
11010           this.writeDouble(val);
11011         },
11012         writeBooleanField: function(tag2, val) {
11013           this.writeVarintField(tag2, Boolean(val));
11014         }
11015       };
11016       function readVarintRemainder(l2, s2, p2) {
11017         var buf = p2.buf, h2, b2;
11018         b2 = buf[p2.pos++];
11019         h2 = (b2 & 112) >> 4;
11020         if (b2 < 128)
11021           return toNum(l2, h2, s2);
11022         b2 = buf[p2.pos++];
11023         h2 |= (b2 & 127) << 3;
11024         if (b2 < 128)
11025           return toNum(l2, h2, s2);
11026         b2 = buf[p2.pos++];
11027         h2 |= (b2 & 127) << 10;
11028         if (b2 < 128)
11029           return toNum(l2, h2, s2);
11030         b2 = buf[p2.pos++];
11031         h2 |= (b2 & 127) << 17;
11032         if (b2 < 128)
11033           return toNum(l2, h2, s2);
11034         b2 = buf[p2.pos++];
11035         h2 |= (b2 & 127) << 24;
11036         if (b2 < 128)
11037           return toNum(l2, h2, s2);
11038         b2 = buf[p2.pos++];
11039         h2 |= (b2 & 1) << 31;
11040         if (b2 < 128)
11041           return toNum(l2, h2, s2);
11042         throw new Error("Expected varint not more than 10 bytes");
11043       }
11044       function readPackedEnd(pbf) {
11045         return pbf.type === Pbf.Bytes ? pbf.readVarint() + pbf.pos : pbf.pos + 1;
11046       }
11047       function toNum(low, high, isSigned) {
11048         if (isSigned) {
11049           return high * 4294967296 + (low >>> 0);
11050         }
11051         return (high >>> 0) * 4294967296 + (low >>> 0);
11052       }
11053       function writeBigVarint(val, pbf) {
11054         var low, high;
11055         if (val >= 0) {
11056           low = val % 4294967296 | 0;
11057           high = val / 4294967296 | 0;
11058         } else {
11059           low = ~(-val % 4294967296);
11060           high = ~(-val / 4294967296);
11061           if (low ^ 4294967295) {
11062             low = low + 1 | 0;
11063           } else {
11064             low = 0;
11065             high = high + 1 | 0;
11066           }
11067         }
11068         if (val >= 18446744073709552e3 || val < -18446744073709552e3) {
11069           throw new Error("Given varint doesn't fit into 10 bytes");
11070         }
11071         pbf.realloc(10);
11072         writeBigVarintLow(low, high, pbf);
11073         writeBigVarintHigh(high, pbf);
11074       }
11075       function writeBigVarintLow(low, high, pbf) {
11076         pbf.buf[pbf.pos++] = low & 127 | 128;
11077         low >>>= 7;
11078         pbf.buf[pbf.pos++] = low & 127 | 128;
11079         low >>>= 7;
11080         pbf.buf[pbf.pos++] = low & 127 | 128;
11081         low >>>= 7;
11082         pbf.buf[pbf.pos++] = low & 127 | 128;
11083         low >>>= 7;
11084         pbf.buf[pbf.pos] = low & 127;
11085       }
11086       function writeBigVarintHigh(high, pbf) {
11087         var lsb = (high & 7) << 4;
11088         pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 128 : 0);
11089         if (!high)
11090           return;
11091         pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
11092         if (!high)
11093           return;
11094         pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
11095         if (!high)
11096           return;
11097         pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
11098         if (!high)
11099           return;
11100         pbf.buf[pbf.pos++] = high & 127 | ((high >>>= 7) ? 128 : 0);
11101         if (!high)
11102           return;
11103         pbf.buf[pbf.pos++] = high & 127;
11104       }
11105       function makeRoomForExtraLength(startPos, len, pbf) {
11106         var extraLen = len <= 16383 ? 1 : len <= 2097151 ? 2 : len <= 268435455 ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));
11107         pbf.realloc(extraLen);
11108         for (var i3 = pbf.pos - 1; i3 >= startPos; i3--)
11109           pbf.buf[i3 + extraLen] = pbf.buf[i3];
11110       }
11111       function writePackedVarint(arr, pbf) {
11112         for (var i3 = 0; i3 < arr.length; i3++)
11113           pbf.writeVarint(arr[i3]);
11114       }
11115       function writePackedSVarint(arr, pbf) {
11116         for (var i3 = 0; i3 < arr.length; i3++)
11117           pbf.writeSVarint(arr[i3]);
11118       }
11119       function writePackedFloat(arr, pbf) {
11120         for (var i3 = 0; i3 < arr.length; i3++)
11121           pbf.writeFloat(arr[i3]);
11122       }
11123       function writePackedDouble(arr, pbf) {
11124         for (var i3 = 0; i3 < arr.length; i3++)
11125           pbf.writeDouble(arr[i3]);
11126       }
11127       function writePackedBoolean(arr, pbf) {
11128         for (var i3 = 0; i3 < arr.length; i3++)
11129           pbf.writeBoolean(arr[i3]);
11130       }
11131       function writePackedFixed32(arr, pbf) {
11132         for (var i3 = 0; i3 < arr.length; i3++)
11133           pbf.writeFixed32(arr[i3]);
11134       }
11135       function writePackedSFixed32(arr, pbf) {
11136         for (var i3 = 0; i3 < arr.length; i3++)
11137           pbf.writeSFixed32(arr[i3]);
11138       }
11139       function writePackedFixed64(arr, pbf) {
11140         for (var i3 = 0; i3 < arr.length; i3++)
11141           pbf.writeFixed64(arr[i3]);
11142       }
11143       function writePackedSFixed64(arr, pbf) {
11144         for (var i3 = 0; i3 < arr.length; i3++)
11145           pbf.writeSFixed64(arr[i3]);
11146       }
11147       function readUInt32(buf, pos) {
11148         return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + buf[pos + 3] * 16777216;
11149       }
11150       function writeInt32(buf, val, pos) {
11151         buf[pos] = val;
11152         buf[pos + 1] = val >>> 8;
11153         buf[pos + 2] = val >>> 16;
11154         buf[pos + 3] = val >>> 24;
11155       }
11156       function readInt32(buf, pos) {
11157         return (buf[pos] | buf[pos + 1] << 8 | buf[pos + 2] << 16) + (buf[pos + 3] << 24);
11158       }
11159       function readUtf8(buf, pos, end) {
11160         var str = "";
11161         var i3 = pos;
11162         while (i3 < end) {
11163           var b0 = buf[i3];
11164           var c2 = null;
11165           var bytesPerSequence = b0 > 239 ? 4 : b0 > 223 ? 3 : b0 > 191 ? 2 : 1;
11166           if (i3 + bytesPerSequence > end)
11167             break;
11168           var b1, b2, b3;
11169           if (bytesPerSequence === 1) {
11170             if (b0 < 128) {
11171               c2 = b0;
11172             }
11173           } else if (bytesPerSequence === 2) {
11174             b1 = buf[i3 + 1];
11175             if ((b1 & 192) === 128) {
11176               c2 = (b0 & 31) << 6 | b1 & 63;
11177               if (c2 <= 127) {
11178                 c2 = null;
11179               }
11180             }
11181           } else if (bytesPerSequence === 3) {
11182             b1 = buf[i3 + 1];
11183             b2 = buf[i3 + 2];
11184             if ((b1 & 192) === 128 && (b2 & 192) === 128) {
11185               c2 = (b0 & 15) << 12 | (b1 & 63) << 6 | b2 & 63;
11186               if (c2 <= 2047 || c2 >= 55296 && c2 <= 57343) {
11187                 c2 = null;
11188               }
11189             }
11190           } else if (bytesPerSequence === 4) {
11191             b1 = buf[i3 + 1];
11192             b2 = buf[i3 + 2];
11193             b3 = buf[i3 + 3];
11194             if ((b1 & 192) === 128 && (b2 & 192) === 128 && (b3 & 192) === 128) {
11195               c2 = (b0 & 15) << 18 | (b1 & 63) << 12 | (b2 & 63) << 6 | b3 & 63;
11196               if (c2 <= 65535 || c2 >= 1114112) {
11197                 c2 = null;
11198               }
11199             }
11200           }
11201           if (c2 === null) {
11202             c2 = 65533;
11203             bytesPerSequence = 1;
11204           } else if (c2 > 65535) {
11205             c2 -= 65536;
11206             str += String.fromCharCode(c2 >>> 10 & 1023 | 55296);
11207             c2 = 56320 | c2 & 1023;
11208           }
11209           str += String.fromCharCode(c2);
11210           i3 += bytesPerSequence;
11211         }
11212         return str;
11213       }
11214       function readUtf8TextDecoder(buf, pos, end) {
11215         return utf8TextDecoder.decode(buf.subarray(pos, end));
11216       }
11217       function writeUtf8(buf, str, pos) {
11218         for (var i3 = 0, c2, lead; i3 < str.length; i3++) {
11219           c2 = str.charCodeAt(i3);
11220           if (c2 > 55295 && c2 < 57344) {
11221             if (lead) {
11222               if (c2 < 56320) {
11223                 buf[pos++] = 239;
11224                 buf[pos++] = 191;
11225                 buf[pos++] = 189;
11226                 lead = c2;
11227                 continue;
11228               } else {
11229                 c2 = lead - 55296 << 10 | c2 - 56320 | 65536;
11230                 lead = null;
11231               }
11232             } else {
11233               if (c2 > 56319 || i3 + 1 === str.length) {
11234                 buf[pos++] = 239;
11235                 buf[pos++] = 191;
11236                 buf[pos++] = 189;
11237               } else {
11238                 lead = c2;
11239               }
11240               continue;
11241             }
11242           } else if (lead) {
11243             buf[pos++] = 239;
11244             buf[pos++] = 191;
11245             buf[pos++] = 189;
11246             lead = null;
11247           }
11248           if (c2 < 128) {
11249             buf[pos++] = c2;
11250           } else {
11251             if (c2 < 2048) {
11252               buf[pos++] = c2 >> 6 | 192;
11253             } else {
11254               if (c2 < 65536) {
11255                 buf[pos++] = c2 >> 12 | 224;
11256               } else {
11257                 buf[pos++] = c2 >> 18 | 240;
11258                 buf[pos++] = c2 >> 12 & 63 | 128;
11259               }
11260               buf[pos++] = c2 >> 6 & 63 | 128;
11261             }
11262             buf[pos++] = c2 & 63 | 128;
11263           }
11264         }
11265         return pos;
11266       }
11267     }
11268   });
11269
11270   // node_modules/@mapbox/point-geometry/index.js
11271   var require_point_geometry = __commonJS({
11272     "node_modules/@mapbox/point-geometry/index.js"(exports2, module2) {
11273       "use strict";
11274       module2.exports = Point;
11275       function Point(x2, y2) {
11276         this.x = x2;
11277         this.y = y2;
11278       }
11279       Point.prototype = {
11280         /**
11281          * Clone this point, returning a new point that can be modified
11282          * without affecting the old one.
11283          * @return {Point} the clone
11284          */
11285         clone: function() {
11286           return new Point(this.x, this.y);
11287         },
11288         /**
11289          * Add this point's x & y coordinates to another point,
11290          * yielding a new point.
11291          * @param {Point} p the other point
11292          * @return {Point} output point
11293          */
11294         add: function(p2) {
11295           return this.clone()._add(p2);
11296         },
11297         /**
11298          * Subtract this point's x & y coordinates to from point,
11299          * yielding a new point.
11300          * @param {Point} p the other point
11301          * @return {Point} output point
11302          */
11303         sub: function(p2) {
11304           return this.clone()._sub(p2);
11305         },
11306         /**
11307          * Multiply this point's x & y coordinates by point,
11308          * yielding a new point.
11309          * @param {Point} p the other point
11310          * @return {Point} output point
11311          */
11312         multByPoint: function(p2) {
11313           return this.clone()._multByPoint(p2);
11314         },
11315         /**
11316          * Divide this point's x & y coordinates by point,
11317          * yielding a new point.
11318          * @param {Point} p the other point
11319          * @return {Point} output point
11320          */
11321         divByPoint: function(p2) {
11322           return this.clone()._divByPoint(p2);
11323         },
11324         /**
11325          * Multiply this point's x & y coordinates by a factor,
11326          * yielding a new point.
11327          * @param {Point} k factor
11328          * @return {Point} output point
11329          */
11330         mult: function(k2) {
11331           return this.clone()._mult(k2);
11332         },
11333         /**
11334          * Divide this point's x & y coordinates by a factor,
11335          * yielding a new point.
11336          * @param {Point} k factor
11337          * @return {Point} output point
11338          */
11339         div: function(k2) {
11340           return this.clone()._div(k2);
11341         },
11342         /**
11343          * Rotate this point around the 0, 0 origin by an angle a,
11344          * given in radians
11345          * @param {Number} a angle to rotate around, in radians
11346          * @return {Point} output point
11347          */
11348         rotate: function(a2) {
11349           return this.clone()._rotate(a2);
11350         },
11351         /**
11352          * Rotate this point around p point by an angle a,
11353          * given in radians
11354          * @param {Number} a angle to rotate around, in radians
11355          * @param {Point} p Point to rotate around
11356          * @return {Point} output point
11357          */
11358         rotateAround: function(a2, p2) {
11359           return this.clone()._rotateAround(a2, p2);
11360         },
11361         /**
11362          * Multiply this point by a 4x1 transformation matrix
11363          * @param {Array<Number>} m transformation matrix
11364          * @return {Point} output point
11365          */
11366         matMult: function(m2) {
11367           return this.clone()._matMult(m2);
11368         },
11369         /**
11370          * Calculate this point but as a unit vector from 0, 0, meaning
11371          * that the distance from the resulting point to the 0, 0
11372          * coordinate will be equal to 1 and the angle from the resulting
11373          * point to the 0, 0 coordinate will be the same as before.
11374          * @return {Point} unit vector point
11375          */
11376         unit: function() {
11377           return this.clone()._unit();
11378         },
11379         /**
11380          * Compute a perpendicular point, where the new y coordinate
11381          * is the old x coordinate and the new x coordinate is the old y
11382          * coordinate multiplied by -1
11383          * @return {Point} perpendicular point
11384          */
11385         perp: function() {
11386           return this.clone()._perp();
11387         },
11388         /**
11389          * Return a version of this point with the x & y coordinates
11390          * rounded to integers.
11391          * @return {Point} rounded point
11392          */
11393         round: function() {
11394           return this.clone()._round();
11395         },
11396         /**
11397          * Return the magitude of this point: this is the Euclidean
11398          * distance from the 0, 0 coordinate to this point's x and y
11399          * coordinates.
11400          * @return {Number} magnitude
11401          */
11402         mag: function() {
11403           return Math.sqrt(this.x * this.x + this.y * this.y);
11404         },
11405         /**
11406          * Judge whether this point is equal to another point, returning
11407          * true or false.
11408          * @param {Point} other the other point
11409          * @return {boolean} whether the points are equal
11410          */
11411         equals: function(other) {
11412           return this.x === other.x && this.y === other.y;
11413         },
11414         /**
11415          * Calculate the distance from this point to another point
11416          * @param {Point} p the other point
11417          * @return {Number} distance
11418          */
11419         dist: function(p2) {
11420           return Math.sqrt(this.distSqr(p2));
11421         },
11422         /**
11423          * Calculate the distance from this point to another point,
11424          * without the square root step. Useful if you're comparing
11425          * relative distances.
11426          * @param {Point} p the other point
11427          * @return {Number} distance
11428          */
11429         distSqr: function(p2) {
11430           var dx = p2.x - this.x, dy = p2.y - this.y;
11431           return dx * dx + dy * dy;
11432         },
11433         /**
11434          * Get the angle from the 0, 0 coordinate to this point, in radians
11435          * coordinates.
11436          * @return {Number} angle
11437          */
11438         angle: function() {
11439           return Math.atan2(this.y, this.x);
11440         },
11441         /**
11442          * Get the angle from this point to another point, in radians
11443          * @param {Point} b the other point
11444          * @return {Number} angle
11445          */
11446         angleTo: function(b2) {
11447           return Math.atan2(this.y - b2.y, this.x - b2.x);
11448         },
11449         /**
11450          * Get the angle between this point and another point, in radians
11451          * @param {Point} b the other point
11452          * @return {Number} angle
11453          */
11454         angleWith: function(b2) {
11455           return this.angleWithSep(b2.x, b2.y);
11456         },
11457         /*
11458          * Find the angle of the two vectors, solving the formula for
11459          * the cross product a x b = |a||b|sin(θ) for θ.
11460          * @param {Number} x the x-coordinate
11461          * @param {Number} y the y-coordinate
11462          * @return {Number} the angle in radians
11463          */
11464         angleWithSep: function(x2, y2) {
11465           return Math.atan2(
11466             this.x * y2 - this.y * x2,
11467             this.x * x2 + this.y * y2
11468           );
11469         },
11470         _matMult: function(m2) {
11471           var x2 = m2[0] * this.x + m2[1] * this.y, y2 = m2[2] * this.x + m2[3] * this.y;
11472           this.x = x2;
11473           this.y = y2;
11474           return this;
11475         },
11476         _add: function(p2) {
11477           this.x += p2.x;
11478           this.y += p2.y;
11479           return this;
11480         },
11481         _sub: function(p2) {
11482           this.x -= p2.x;
11483           this.y -= p2.y;
11484           return this;
11485         },
11486         _mult: function(k2) {
11487           this.x *= k2;
11488           this.y *= k2;
11489           return this;
11490         },
11491         _div: function(k2) {
11492           this.x /= k2;
11493           this.y /= k2;
11494           return this;
11495         },
11496         _multByPoint: function(p2) {
11497           this.x *= p2.x;
11498           this.y *= p2.y;
11499           return this;
11500         },
11501         _divByPoint: function(p2) {
11502           this.x /= p2.x;
11503           this.y /= p2.y;
11504           return this;
11505         },
11506         _unit: function() {
11507           this._div(this.mag());
11508           return this;
11509         },
11510         _perp: function() {
11511           var y2 = this.y;
11512           this.y = this.x;
11513           this.x = -y2;
11514           return this;
11515         },
11516         _rotate: function(angle2) {
11517           var cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = cos2 * this.x - sin2 * this.y, y2 = sin2 * this.x + cos2 * this.y;
11518           this.x = x2;
11519           this.y = y2;
11520           return this;
11521         },
11522         _rotateAround: function(angle2, p2) {
11523           var cos2 = Math.cos(angle2), sin2 = Math.sin(angle2), x2 = p2.x + cos2 * (this.x - p2.x) - sin2 * (this.y - p2.y), y2 = p2.y + sin2 * (this.x - p2.x) + cos2 * (this.y - p2.y);
11524           this.x = x2;
11525           this.y = y2;
11526           return this;
11527         },
11528         _round: function() {
11529           this.x = Math.round(this.x);
11530           this.y = Math.round(this.y);
11531           return this;
11532         }
11533       };
11534       Point.convert = function(a2) {
11535         if (a2 instanceof Point) {
11536           return a2;
11537         }
11538         if (Array.isArray(a2)) {
11539           return new Point(a2[0], a2[1]);
11540         }
11541         return a2;
11542       };
11543     }
11544   });
11545
11546   // node_modules/@mapbox/vector-tile/lib/vectortilefeature.js
11547   var require_vectortilefeature = __commonJS({
11548     "node_modules/@mapbox/vector-tile/lib/vectortilefeature.js"(exports2, module2) {
11549       "use strict";
11550       var Point = require_point_geometry();
11551       module2.exports = VectorTileFeature;
11552       function VectorTileFeature(pbf, end, extent, keys2, values) {
11553         this.properties = {};
11554         this.extent = extent;
11555         this.type = 0;
11556         this._pbf = pbf;
11557         this._geometry = -1;
11558         this._keys = keys2;
11559         this._values = values;
11560         pbf.readFields(readFeature, this, end);
11561       }
11562       function readFeature(tag2, feature3, pbf) {
11563         if (tag2 == 1)
11564           feature3.id = pbf.readVarint();
11565         else if (tag2 == 2)
11566           readTag(pbf, feature3);
11567         else if (tag2 == 3)
11568           feature3.type = pbf.readVarint();
11569         else if (tag2 == 4)
11570           feature3._geometry = pbf.pos;
11571       }
11572       function readTag(pbf, feature3) {
11573         var end = pbf.readVarint() + pbf.pos;
11574         while (pbf.pos < end) {
11575           var key = feature3._keys[pbf.readVarint()], value = feature3._values[pbf.readVarint()];
11576           feature3.properties[key] = value;
11577         }
11578       }
11579       VectorTileFeature.types = ["Unknown", "Point", "LineString", "Polygon"];
11580       VectorTileFeature.prototype.loadGeometry = function() {
11581         var pbf = this._pbf;
11582         pbf.pos = this._geometry;
11583         var end = pbf.readVarint() + pbf.pos, cmd = 1, length2 = 0, x2 = 0, y2 = 0, lines = [], line;
11584         while (pbf.pos < end) {
11585           if (length2 <= 0) {
11586             var cmdLen = pbf.readVarint();
11587             cmd = cmdLen & 7;
11588             length2 = cmdLen >> 3;
11589           }
11590           length2--;
11591           if (cmd === 1 || cmd === 2) {
11592             x2 += pbf.readSVarint();
11593             y2 += pbf.readSVarint();
11594             if (cmd === 1) {
11595               if (line)
11596                 lines.push(line);
11597               line = [];
11598             }
11599             line.push(new Point(x2, y2));
11600           } else if (cmd === 7) {
11601             if (line) {
11602               line.push(line[0].clone());
11603             }
11604           } else {
11605             throw new Error("unknown command " + cmd);
11606           }
11607         }
11608         if (line)
11609           lines.push(line);
11610         return lines;
11611       };
11612       VectorTileFeature.prototype.bbox = function() {
11613         var pbf = this._pbf;
11614         pbf.pos = this._geometry;
11615         var end = pbf.readVarint() + pbf.pos, cmd = 1, length2 = 0, x2 = 0, y2 = 0, x12 = Infinity, x22 = -Infinity, y12 = Infinity, y22 = -Infinity;
11616         while (pbf.pos < end) {
11617           if (length2 <= 0) {
11618             var cmdLen = pbf.readVarint();
11619             cmd = cmdLen & 7;
11620             length2 = cmdLen >> 3;
11621           }
11622           length2--;
11623           if (cmd === 1 || cmd === 2) {
11624             x2 += pbf.readSVarint();
11625             y2 += pbf.readSVarint();
11626             if (x2 < x12)
11627               x12 = x2;
11628             if (x2 > x22)
11629               x22 = x2;
11630             if (y2 < y12)
11631               y12 = y2;
11632             if (y2 > y22)
11633               y22 = y2;
11634           } else if (cmd !== 7) {
11635             throw new Error("unknown command " + cmd);
11636           }
11637         }
11638         return [x12, y12, x22, y22];
11639       };
11640       VectorTileFeature.prototype.toGeoJSON = function(x2, y2, z2) {
11641         var size = this.extent * Math.pow(2, z2), x05 = this.extent * x2, y05 = this.extent * y2, coords = this.loadGeometry(), type2 = VectorTileFeature.types[this.type], i3, j2;
11642         function project(line) {
11643           for (var j3 = 0; j3 < line.length; j3++) {
11644             var p2 = line[j3], y22 = 180 - (p2.y + y05) * 360 / size;
11645             line[j3] = [
11646               (p2.x + x05) * 360 / size - 180,
11647               360 / Math.PI * Math.atan(Math.exp(y22 * Math.PI / 180)) - 90
11648             ];
11649           }
11650         }
11651         switch (this.type) {
11652           case 1:
11653             var points = [];
11654             for (i3 = 0; i3 < coords.length; i3++) {
11655               points[i3] = coords[i3][0];
11656             }
11657             coords = points;
11658             project(coords);
11659             break;
11660           case 2:
11661             for (i3 = 0; i3 < coords.length; i3++) {
11662               project(coords[i3]);
11663             }
11664             break;
11665           case 3:
11666             coords = classifyRings(coords);
11667             for (i3 = 0; i3 < coords.length; i3++) {
11668               for (j2 = 0; j2 < coords[i3].length; j2++) {
11669                 project(coords[i3][j2]);
11670               }
11671             }
11672             break;
11673         }
11674         if (coords.length === 1) {
11675           coords = coords[0];
11676         } else {
11677           type2 = "Multi" + type2;
11678         }
11679         var result = {
11680           type: "Feature",
11681           geometry: {
11682             type: type2,
11683             coordinates: coords
11684           },
11685           properties: this.properties
11686         };
11687         if ("id" in this) {
11688           result.id = this.id;
11689         }
11690         return result;
11691       };
11692       function classifyRings(rings) {
11693         var len = rings.length;
11694         if (len <= 1)
11695           return [rings];
11696         var polygons = [], polygon2, ccw;
11697         for (var i3 = 0; i3 < len; i3++) {
11698           var area = signedArea(rings[i3]);
11699           if (area === 0)
11700             continue;
11701           if (ccw === void 0)
11702             ccw = area < 0;
11703           if (ccw === area < 0) {
11704             if (polygon2)
11705               polygons.push(polygon2);
11706             polygon2 = [rings[i3]];
11707           } else {
11708             polygon2.push(rings[i3]);
11709           }
11710         }
11711         if (polygon2)
11712           polygons.push(polygon2);
11713         return polygons;
11714       }
11715       function signedArea(ring) {
11716         var sum = 0;
11717         for (var i3 = 0, len = ring.length, j2 = len - 1, p1, p2; i3 < len; j2 = i3++) {
11718           p1 = ring[i3];
11719           p2 = ring[j2];
11720           sum += (p2.x - p1.x) * (p1.y + p2.y);
11721         }
11722         return sum;
11723       }
11724     }
11725   });
11726
11727   // node_modules/@mapbox/vector-tile/lib/vectortilelayer.js
11728   var require_vectortilelayer = __commonJS({
11729     "node_modules/@mapbox/vector-tile/lib/vectortilelayer.js"(exports2, module2) {
11730       "use strict";
11731       var VectorTileFeature = require_vectortilefeature();
11732       module2.exports = VectorTileLayer;
11733       function VectorTileLayer(pbf, end) {
11734         this.version = 1;
11735         this.name = null;
11736         this.extent = 4096;
11737         this.length = 0;
11738         this._pbf = pbf;
11739         this._keys = [];
11740         this._values = [];
11741         this._features = [];
11742         pbf.readFields(readLayer, this, end);
11743         this.length = this._features.length;
11744       }
11745       function readLayer(tag2, layer, pbf) {
11746         if (tag2 === 15)
11747           layer.version = pbf.readVarint();
11748         else if (tag2 === 1)
11749           layer.name = pbf.readString();
11750         else if (tag2 === 5)
11751           layer.extent = pbf.readVarint();
11752         else if (tag2 === 2)
11753           layer._features.push(pbf.pos);
11754         else if (tag2 === 3)
11755           layer._keys.push(pbf.readString());
11756         else if (tag2 === 4)
11757           layer._values.push(readValueMessage(pbf));
11758       }
11759       function readValueMessage(pbf) {
11760         var value = null, end = pbf.readVarint() + pbf.pos;
11761         while (pbf.pos < end) {
11762           var tag2 = pbf.readVarint() >> 3;
11763           value = tag2 === 1 ? pbf.readString() : tag2 === 2 ? pbf.readFloat() : tag2 === 3 ? pbf.readDouble() : tag2 === 4 ? pbf.readVarint64() : tag2 === 5 ? pbf.readVarint() : tag2 === 6 ? pbf.readSVarint() : tag2 === 7 ? pbf.readBoolean() : null;
11764         }
11765         return value;
11766       }
11767       VectorTileLayer.prototype.feature = function(i3) {
11768         if (i3 < 0 || i3 >= this._features.length)
11769           throw new Error("feature index out of bounds");
11770         this._pbf.pos = this._features[i3];
11771         var end = this._pbf.readVarint() + this._pbf.pos;
11772         return new VectorTileFeature(this._pbf, end, this.extent, this._keys, this._values);
11773       };
11774     }
11775   });
11776
11777   // node_modules/@mapbox/vector-tile/lib/vectortile.js
11778   var require_vectortile = __commonJS({
11779     "node_modules/@mapbox/vector-tile/lib/vectortile.js"(exports2, module2) {
11780       "use strict";
11781       var VectorTileLayer = require_vectortilelayer();
11782       module2.exports = VectorTile3;
11783       function VectorTile3(pbf, end) {
11784         this.layers = pbf.readFields(readTile, {}, end);
11785       }
11786       function readTile(tag2, layers, pbf) {
11787         if (tag2 === 3) {
11788           var layer = new VectorTileLayer(pbf, pbf.readVarint() + pbf.pos);
11789           if (layer.length)
11790             layers[layer.name] = layer;
11791         }
11792       }
11793     }
11794   });
11795
11796   // node_modules/@mapbox/vector-tile/index.js
11797   var require_vector_tile = __commonJS({
11798     "node_modules/@mapbox/vector-tile/index.js"(exports2, module2) {
11799       module2.exports.VectorTile = require_vectortile();
11800       module2.exports.VectorTileFeature = require_vectortilefeature();
11801       module2.exports.VectorTileLayer = require_vectortilelayer();
11802     }
11803   });
11804
11805   // node_modules/fast-json-stable-stringify/index.js
11806   var require_fast_json_stable_stringify = __commonJS({
11807     "node_modules/fast-json-stable-stringify/index.js"(exports2, module2) {
11808       "use strict";
11809       module2.exports = function(data, opts) {
11810         if (!opts)
11811           opts = {};
11812         if (typeof opts === "function")
11813           opts = { cmp: opts };
11814         var cycles = typeof opts.cycles === "boolean" ? opts.cycles : false;
11815         var cmp = opts.cmp && /* @__PURE__ */ function(f2) {
11816           return function(node) {
11817             return function(a2, b2) {
11818               var aobj = { key: a2, value: node[a2] };
11819               var bobj = { key: b2, value: node[b2] };
11820               return f2(aobj, bobj);
11821             };
11822           };
11823         }(opts.cmp);
11824         var seen = [];
11825         return function stringify3(node) {
11826           if (node && node.toJSON && typeof node.toJSON === "function") {
11827             node = node.toJSON();
11828           }
11829           if (node === void 0)
11830             return;
11831           if (typeof node == "number")
11832             return isFinite(node) ? "" + node : "null";
11833           if (typeof node !== "object")
11834             return JSON.stringify(node);
11835           var i3, out;
11836           if (Array.isArray(node)) {
11837             out = "[";
11838             for (i3 = 0; i3 < node.length; i3++) {
11839               if (i3)
11840                 out += ",";
11841               out += stringify3(node[i3]) || "null";
11842             }
11843             return out + "]";
11844           }
11845           if (node === null)
11846             return "null";
11847           if (seen.indexOf(node) !== -1) {
11848             if (cycles)
11849               return JSON.stringify("__cycle__");
11850             throw new TypeError("Converting circular structure to JSON");
11851           }
11852           var seenIndex = seen.push(node) - 1;
11853           var keys2 = Object.keys(node).sort(cmp && cmp(node));
11854           out = "";
11855           for (i3 = 0; i3 < keys2.length; i3++) {
11856             var key = keys2[i3];
11857             var value = stringify3(node[key]);
11858             if (!value)
11859               continue;
11860             if (out)
11861               out += ",";
11862             out += JSON.stringify(key) + ":" + value;
11863           }
11864           seen.splice(seenIndex, 1);
11865           return "{" + out + "}";
11866         }(data);
11867       };
11868     }
11869   });
11870
11871   // node_modules/@mapbox/sexagesimal/index.js
11872   var require_sexagesimal = __commonJS({
11873     "node_modules/@mapbox/sexagesimal/index.js"(exports2, module2) {
11874       module2.exports = element;
11875       module2.exports.pair = pair3;
11876       module2.exports.format = format2;
11877       module2.exports.formatPair = formatPair;
11878       module2.exports.coordToDMS = coordToDMS;
11879       function element(input, dims) {
11880         var result = search(input, dims);
11881         return result === null ? null : result.val;
11882       }
11883       function formatPair(input) {
11884         return format2(input.lat, "lat") + " " + format2(input.lon, "lon");
11885       }
11886       function format2(input, dim) {
11887         var dms = coordToDMS(input, dim);
11888         return dms.whole + "\xB0 " + (dms.minutes ? dms.minutes + "' " : "") + (dms.seconds ? dms.seconds + '" ' : "") + dms.dir;
11889       }
11890       function coordToDMS(input, dim) {
11891         var dirs = { lat: ["N", "S"], lon: ["E", "W"] }[dim] || "";
11892         var dir = dirs[input >= 0 ? 0 : 1];
11893         var abs3 = Math.abs(input);
11894         var whole = Math.floor(abs3);
11895         var fraction = abs3 - whole;
11896         var fractionMinutes = fraction * 60;
11897         var minutes = Math.floor(fractionMinutes);
11898         var seconds = Math.floor((fractionMinutes - minutes) * 60);
11899         return {
11900           whole,
11901           minutes,
11902           seconds,
11903           dir
11904         };
11905       }
11906       function search(input, dims) {
11907         if (!dims)
11908           dims = "NSEW";
11909         if (typeof input !== "string")
11910           return null;
11911         input = input.toUpperCase();
11912         var regex = /^[\s\,]*([NSEW])?\s*([\-|\—|\―]?[0-9.]+)[°º˚]?\s*(?:([0-9.]+)['’′‘]\s*)?(?:([0-9.]+)(?:''|"|”|″)\s*)?([NSEW])?/;
11913         var m2 = input.match(regex);
11914         if (!m2)
11915           return null;
11916         var matched = m2[0];
11917         var dim;
11918         if (m2[1] && m2[5]) {
11919           dim = m2[1];
11920           matched = matched.slice(0, -1);
11921         } else {
11922           dim = m2[1] || m2[5];
11923         }
11924         if (dim && dims.indexOf(dim) === -1)
11925           return null;
11926         var deg = m2[2] ? parseFloat(m2[2]) : 0;
11927         var min3 = m2[3] ? parseFloat(m2[3]) / 60 : 0;
11928         var sec = m2[4] ? parseFloat(m2[4]) / 3600 : 0;
11929         var sign2 = deg < 0 ? -1 : 1;
11930         if (dim === "S" || dim === "W")
11931           sign2 *= -1;
11932         return {
11933           val: (Math.abs(deg) + min3 + sec) * sign2,
11934           dim,
11935           matched,
11936           remain: input.slice(matched.length)
11937         };
11938       }
11939       function pair3(input, dims) {
11940         input = input.trim();
11941         var one2 = search(input, dims);
11942         if (!one2)
11943           return null;
11944         input = one2.remain.trim();
11945         var two = search(input, dims);
11946         if (!two || two.remain)
11947           return null;
11948         if (one2.dim) {
11949           return swapdim(one2.val, two.val, one2.dim);
11950         } else {
11951           return [one2.val, two.val];
11952         }
11953       }
11954       function swapdim(a2, b2, dim) {
11955         if (dim === "N" || dim === "S")
11956           return [a2, b2];
11957         if (dim === "W" || dim === "E")
11958           return [b2, a2];
11959       }
11960     }
11961   });
11962
11963   // node_modules/polygon-clipping/dist/polygon-clipping.umd.js
11964   var require_polygon_clipping_umd = __commonJS({
11965     "node_modules/polygon-clipping/dist/polygon-clipping.umd.js"(exports2, module2) {
11966       (function(global2, factory) {
11967         typeof exports2 === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : (global2 = typeof globalThis !== "undefined" ? globalThis : global2 || self, global2.polygonClipping = factory());
11968       })(exports2, function() {
11969         "use strict";
11970         function __generator(thisArg, body) {
11971           var _2 = {
11972             label: 0,
11973             sent: function() {
11974               if (t2[0] & 1)
11975                 throw t2[1];
11976               return t2[1];
11977             },
11978             trys: [],
11979             ops: []
11980           }, f2, y2, t2, g3;
11981           return g3 = {
11982             next: verb(0),
11983             "throw": verb(1),
11984             "return": verb(2)
11985           }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() {
11986             return this;
11987           }), g3;
11988           function verb(n3) {
11989             return function(v2) {
11990               return step([n3, v2]);
11991             };
11992           }
11993           function step(op) {
11994             if (f2)
11995               throw new TypeError("Generator is already executing.");
11996             while (_2)
11997               try {
11998                 if (f2 = 1, y2 && (t2 = op[0] & 2 ? y2["return"] : op[0] ? y2["throw"] || ((t2 = y2["return"]) && t2.call(y2), 0) : y2.next) && !(t2 = t2.call(y2, op[1])).done)
11999                   return t2;
12000                 if (y2 = 0, t2)
12001                   op = [op[0] & 2, t2.value];
12002                 switch (op[0]) {
12003                   case 0:
12004                   case 1:
12005                     t2 = op;
12006                     break;
12007                   case 4:
12008                     _2.label++;
12009                     return {
12010                       value: op[1],
12011                       done: false
12012                     };
12013                   case 5:
12014                     _2.label++;
12015                     y2 = op[1];
12016                     op = [0];
12017                     continue;
12018                   case 7:
12019                     op = _2.ops.pop();
12020                     _2.trys.pop();
12021                     continue;
12022                   default:
12023                     if (!(t2 = _2.trys, t2 = t2.length > 0 && t2[t2.length - 1]) && (op[0] === 6 || op[0] === 2)) {
12024                       _2 = 0;
12025                       continue;
12026                     }
12027                     if (op[0] === 3 && (!t2 || op[1] > t2[0] && op[1] < t2[3])) {
12028                       _2.label = op[1];
12029                       break;
12030                     }
12031                     if (op[0] === 6 && _2.label < t2[1]) {
12032                       _2.label = t2[1];
12033                       t2 = op;
12034                       break;
12035                     }
12036                     if (t2 && _2.label < t2[2]) {
12037                       _2.label = t2[2];
12038                       _2.ops.push(op);
12039                       break;
12040                     }
12041                     if (t2[2])
12042                       _2.ops.pop();
12043                     _2.trys.pop();
12044                     continue;
12045                 }
12046                 op = body.call(thisArg, _2);
12047               } catch (e3) {
12048                 op = [6, e3];
12049                 y2 = 0;
12050               } finally {
12051                 f2 = t2 = 0;
12052               }
12053             if (op[0] & 5)
12054               throw op[1];
12055             return {
12056               value: op[0] ? op[1] : void 0,
12057               done: true
12058             };
12059           }
12060         }
12061         var Node = (
12062           /** @class */
12063           /* @__PURE__ */ function() {
12064             function Node2(key, data) {
12065               this.next = null;
12066               this.key = key;
12067               this.data = data;
12068               this.left = null;
12069               this.right = null;
12070             }
12071             return Node2;
12072           }()
12073         );
12074         function DEFAULT_COMPARE(a2, b2) {
12075           return a2 > b2 ? 1 : a2 < b2 ? -1 : 0;
12076         }
12077         function splay(i3, t2, comparator) {
12078           var N2 = new Node(null, null);
12079           var l2 = N2;
12080           var r2 = N2;
12081           while (true) {
12082             var cmp2 = comparator(i3, t2.key);
12083             if (cmp2 < 0) {
12084               if (t2.left === null)
12085                 break;
12086               if (comparator(i3, t2.left.key) < 0) {
12087                 var y2 = t2.left;
12088                 t2.left = y2.right;
12089                 y2.right = t2;
12090                 t2 = y2;
12091                 if (t2.left === null)
12092                   break;
12093               }
12094               r2.left = t2;
12095               r2 = t2;
12096               t2 = t2.left;
12097             } else if (cmp2 > 0) {
12098               if (t2.right === null)
12099                 break;
12100               if (comparator(i3, t2.right.key) > 0) {
12101                 var y2 = t2.right;
12102                 t2.right = y2.left;
12103                 y2.left = t2;
12104                 t2 = y2;
12105                 if (t2.right === null)
12106                   break;
12107               }
12108               l2.right = t2;
12109               l2 = t2;
12110               t2 = t2.right;
12111             } else
12112               break;
12113           }
12114           l2.right = t2.left;
12115           r2.left = t2.right;
12116           t2.left = N2.right;
12117           t2.right = N2.left;
12118           return t2;
12119         }
12120         function insert(i3, data, t2, comparator) {
12121           var node = new Node(i3, data);
12122           if (t2 === null) {
12123             node.left = node.right = null;
12124             return node;
12125           }
12126           t2 = splay(i3, t2, comparator);
12127           var cmp2 = comparator(i3, t2.key);
12128           if (cmp2 < 0) {
12129             node.left = t2.left;
12130             node.right = t2;
12131             t2.left = null;
12132           } else if (cmp2 >= 0) {
12133             node.right = t2.right;
12134             node.left = t2;
12135             t2.right = null;
12136           }
12137           return node;
12138         }
12139         function split(key, v2, comparator) {
12140           var left = null;
12141           var right = null;
12142           if (v2) {
12143             v2 = splay(key, v2, comparator);
12144             var cmp2 = comparator(v2.key, key);
12145             if (cmp2 === 0) {
12146               left = v2.left;
12147               right = v2.right;
12148             } else if (cmp2 < 0) {
12149               right = v2.right;
12150               v2.right = null;
12151               left = v2;
12152             } else {
12153               left = v2.left;
12154               v2.left = null;
12155               right = v2;
12156             }
12157           }
12158           return {
12159             left,
12160             right
12161           };
12162         }
12163         function merge2(left, right, comparator) {
12164           if (right === null)
12165             return left;
12166           if (left === null)
12167             return right;
12168           right = splay(left.key, right, comparator);
12169           right.left = left;
12170           return right;
12171         }
12172         function printRow(root3, prefix, isTail, out, printNode) {
12173           if (root3) {
12174             out("" + prefix + (isTail ? "\u2514\u2500\u2500 " : "\u251C\u2500\u2500 ") + printNode(root3) + "\n");
12175             var indent = prefix + (isTail ? "    " : "\u2502   ");
12176             if (root3.left)
12177               printRow(root3.left, indent, false, out, printNode);
12178             if (root3.right)
12179               printRow(root3.right, indent, true, out, printNode);
12180           }
12181         }
12182         var Tree = (
12183           /** @class */
12184           function() {
12185             function Tree2(comparator) {
12186               if (comparator === void 0) {
12187                 comparator = DEFAULT_COMPARE;
12188               }
12189               this._root = null;
12190               this._size = 0;
12191               this._comparator = comparator;
12192             }
12193             Tree2.prototype.insert = function(key, data) {
12194               this._size++;
12195               return this._root = insert(key, data, this._root, this._comparator);
12196             };
12197             Tree2.prototype.add = function(key, data) {
12198               var node = new Node(key, data);
12199               if (this._root === null) {
12200                 node.left = node.right = null;
12201                 this._size++;
12202                 this._root = node;
12203               }
12204               var comparator = this._comparator;
12205               var t2 = splay(key, this._root, comparator);
12206               var cmp2 = comparator(key, t2.key);
12207               if (cmp2 === 0)
12208                 this._root = t2;
12209               else {
12210                 if (cmp2 < 0) {
12211                   node.left = t2.left;
12212                   node.right = t2;
12213                   t2.left = null;
12214                 } else if (cmp2 > 0) {
12215                   node.right = t2.right;
12216                   node.left = t2;
12217                   t2.right = null;
12218                 }
12219                 this._size++;
12220                 this._root = node;
12221               }
12222               return this._root;
12223             };
12224             Tree2.prototype.remove = function(key) {
12225               this._root = this._remove(key, this._root, this._comparator);
12226             };
12227             Tree2.prototype._remove = function(i3, t2, comparator) {
12228               var x2;
12229               if (t2 === null)
12230                 return null;
12231               t2 = splay(i3, t2, comparator);
12232               var cmp2 = comparator(i3, t2.key);
12233               if (cmp2 === 0) {
12234                 if (t2.left === null) {
12235                   x2 = t2.right;
12236                 } else {
12237                   x2 = splay(i3, t2.left, comparator);
12238                   x2.right = t2.right;
12239                 }
12240                 this._size--;
12241                 return x2;
12242               }
12243               return t2;
12244             };
12245             Tree2.prototype.pop = function() {
12246               var node = this._root;
12247               if (node) {
12248                 while (node.left)
12249                   node = node.left;
12250                 this._root = splay(node.key, this._root, this._comparator);
12251                 this._root = this._remove(node.key, this._root, this._comparator);
12252                 return {
12253                   key: node.key,
12254                   data: node.data
12255                 };
12256               }
12257               return null;
12258             };
12259             Tree2.prototype.findStatic = function(key) {
12260               var current = this._root;
12261               var compare2 = this._comparator;
12262               while (current) {
12263                 var cmp2 = compare2(key, current.key);
12264                 if (cmp2 === 0)
12265                   return current;
12266                 else if (cmp2 < 0)
12267                   current = current.left;
12268                 else
12269                   current = current.right;
12270               }
12271               return null;
12272             };
12273             Tree2.prototype.find = function(key) {
12274               if (this._root) {
12275                 this._root = splay(key, this._root, this._comparator);
12276                 if (this._comparator(key, this._root.key) !== 0)
12277                   return null;
12278               }
12279               return this._root;
12280             };
12281             Tree2.prototype.contains = function(key) {
12282               var current = this._root;
12283               var compare2 = this._comparator;
12284               while (current) {
12285                 var cmp2 = compare2(key, current.key);
12286                 if (cmp2 === 0)
12287                   return true;
12288                 else if (cmp2 < 0)
12289                   current = current.left;
12290                 else
12291                   current = current.right;
12292               }
12293               return false;
12294             };
12295             Tree2.prototype.forEach = function(visitor, ctx) {
12296               var current = this._root;
12297               var Q2 = [];
12298               var done = false;
12299               while (!done) {
12300                 if (current !== null) {
12301                   Q2.push(current);
12302                   current = current.left;
12303                 } else {
12304                   if (Q2.length !== 0) {
12305                     current = Q2.pop();
12306                     visitor.call(ctx, current);
12307                     current = current.right;
12308                   } else
12309                     done = true;
12310                 }
12311               }
12312               return this;
12313             };
12314             Tree2.prototype.range = function(low, high, fn, ctx) {
12315               var Q2 = [];
12316               var compare2 = this._comparator;
12317               var node = this._root;
12318               var cmp2;
12319               while (Q2.length !== 0 || node) {
12320                 if (node) {
12321                   Q2.push(node);
12322                   node = node.left;
12323                 } else {
12324                   node = Q2.pop();
12325                   cmp2 = compare2(node.key, high);
12326                   if (cmp2 > 0) {
12327                     break;
12328                   } else if (compare2(node.key, low) >= 0) {
12329                     if (fn.call(ctx, node))
12330                       return this;
12331                   }
12332                   node = node.right;
12333                 }
12334               }
12335               return this;
12336             };
12337             Tree2.prototype.keys = function() {
12338               var keys2 = [];
12339               this.forEach(function(_a2) {
12340                 var key = _a2.key;
12341                 return keys2.push(key);
12342               });
12343               return keys2;
12344             };
12345             Tree2.prototype.values = function() {
12346               var values = [];
12347               this.forEach(function(_a2) {
12348                 var data = _a2.data;
12349                 return values.push(data);
12350               });
12351               return values;
12352             };
12353             Tree2.prototype.min = function() {
12354               if (this._root)
12355                 return this.minNode(this._root).key;
12356               return null;
12357             };
12358             Tree2.prototype.max = function() {
12359               if (this._root)
12360                 return this.maxNode(this._root).key;
12361               return null;
12362             };
12363             Tree2.prototype.minNode = function(t2) {
12364               if (t2 === void 0) {
12365                 t2 = this._root;
12366               }
12367               if (t2)
12368                 while (t2.left)
12369                   t2 = t2.left;
12370               return t2;
12371             };
12372             Tree2.prototype.maxNode = function(t2) {
12373               if (t2 === void 0) {
12374                 t2 = this._root;
12375               }
12376               if (t2)
12377                 while (t2.right)
12378                   t2 = t2.right;
12379               return t2;
12380             };
12381             Tree2.prototype.at = function(index2) {
12382               var current = this._root;
12383               var done = false;
12384               var i3 = 0;
12385               var Q2 = [];
12386               while (!done) {
12387                 if (current) {
12388                   Q2.push(current);
12389                   current = current.left;
12390                 } else {
12391                   if (Q2.length > 0) {
12392                     current = Q2.pop();
12393                     if (i3 === index2)
12394                       return current;
12395                     i3++;
12396                     current = current.right;
12397                   } else
12398                     done = true;
12399                 }
12400               }
12401               return null;
12402             };
12403             Tree2.prototype.next = function(d2) {
12404               var root3 = this._root;
12405               var successor = null;
12406               if (d2.right) {
12407                 successor = d2.right;
12408                 while (successor.left)
12409                   successor = successor.left;
12410                 return successor;
12411               }
12412               var comparator = this._comparator;
12413               while (root3) {
12414                 var cmp2 = comparator(d2.key, root3.key);
12415                 if (cmp2 === 0)
12416                   break;
12417                 else if (cmp2 < 0) {
12418                   successor = root3;
12419                   root3 = root3.left;
12420                 } else
12421                   root3 = root3.right;
12422               }
12423               return successor;
12424             };
12425             Tree2.prototype.prev = function(d2) {
12426               var root3 = this._root;
12427               var predecessor = null;
12428               if (d2.left !== null) {
12429                 predecessor = d2.left;
12430                 while (predecessor.right)
12431                   predecessor = predecessor.right;
12432                 return predecessor;
12433               }
12434               var comparator = this._comparator;
12435               while (root3) {
12436                 var cmp2 = comparator(d2.key, root3.key);
12437                 if (cmp2 === 0)
12438                   break;
12439                 else if (cmp2 < 0)
12440                   root3 = root3.left;
12441                 else {
12442                   predecessor = root3;
12443                   root3 = root3.right;
12444                 }
12445               }
12446               return predecessor;
12447             };
12448             Tree2.prototype.clear = function() {
12449               this._root = null;
12450               this._size = 0;
12451               return this;
12452             };
12453             Tree2.prototype.toList = function() {
12454               return toList(this._root);
12455             };
12456             Tree2.prototype.load = function(keys2, values, presort) {
12457               if (values === void 0) {
12458                 values = [];
12459               }
12460               if (presort === void 0) {
12461                 presort = false;
12462               }
12463               var size = keys2.length;
12464               var comparator = this._comparator;
12465               if (presort)
12466                 sort(keys2, values, 0, size - 1, comparator);
12467               if (this._root === null) {
12468                 this._root = loadRecursive(keys2, values, 0, size);
12469                 this._size = size;
12470               } else {
12471                 var mergedList = mergeLists(this.toList(), createList(keys2, values), comparator);
12472                 size = this._size + size;
12473                 this._root = sortedListToBST({
12474                   head: mergedList
12475                 }, 0, size);
12476               }
12477               return this;
12478             };
12479             Tree2.prototype.isEmpty = function() {
12480               return this._root === null;
12481             };
12482             Object.defineProperty(Tree2.prototype, "size", {
12483               get: function() {
12484                 return this._size;
12485               },
12486               enumerable: true,
12487               configurable: true
12488             });
12489             Object.defineProperty(Tree2.prototype, "root", {
12490               get: function() {
12491                 return this._root;
12492               },
12493               enumerable: true,
12494               configurable: true
12495             });
12496             Tree2.prototype.toString = function(printNode) {
12497               if (printNode === void 0) {
12498                 printNode = function(n3) {
12499                   return String(n3.key);
12500                 };
12501               }
12502               var out = [];
12503               printRow(this._root, "", true, function(v2) {
12504                 return out.push(v2);
12505               }, printNode);
12506               return out.join("");
12507             };
12508             Tree2.prototype.update = function(key, newKey, newData) {
12509               var comparator = this._comparator;
12510               var _a2 = split(key, this._root, comparator), left = _a2.left, right = _a2.right;
12511               if (comparator(key, newKey) < 0) {
12512                 right = insert(newKey, newData, right, comparator);
12513               } else {
12514                 left = insert(newKey, newData, left, comparator);
12515               }
12516               this._root = merge2(left, right, comparator);
12517             };
12518             Tree2.prototype.split = function(key) {
12519               return split(key, this._root, this._comparator);
12520             };
12521             Tree2.prototype[Symbol.iterator] = function() {
12522               var current, Q2, done;
12523               return __generator(this, function(_a2) {
12524                 switch (_a2.label) {
12525                   case 0:
12526                     current = this._root;
12527                     Q2 = [];
12528                     done = false;
12529                     _a2.label = 1;
12530                   case 1:
12531                     if (!!done)
12532                       return [3, 6];
12533                     if (!(current !== null))
12534                       return [3, 2];
12535                     Q2.push(current);
12536                     current = current.left;
12537                     return [3, 5];
12538                   case 2:
12539                     if (!(Q2.length !== 0))
12540                       return [3, 4];
12541                     current = Q2.pop();
12542                     return [4, current];
12543                   case 3:
12544                     _a2.sent();
12545                     current = current.right;
12546                     return [3, 5];
12547                   case 4:
12548                     done = true;
12549                     _a2.label = 5;
12550                   case 5:
12551                     return [3, 1];
12552                   case 6:
12553                     return [
12554                       2
12555                       /*return*/
12556                     ];
12557                 }
12558               });
12559             };
12560             return Tree2;
12561           }()
12562         );
12563         function loadRecursive(keys2, values, start2, end) {
12564           var size = end - start2;
12565           if (size > 0) {
12566             var middle = start2 + Math.floor(size / 2);
12567             var key = keys2[middle];
12568             var data = values[middle];
12569             var node = new Node(key, data);
12570             node.left = loadRecursive(keys2, values, start2, middle);
12571             node.right = loadRecursive(keys2, values, middle + 1, end);
12572             return node;
12573           }
12574           return null;
12575         }
12576         function createList(keys2, values) {
12577           var head = new Node(null, null);
12578           var p2 = head;
12579           for (var i3 = 0; i3 < keys2.length; i3++) {
12580             p2 = p2.next = new Node(keys2[i3], values[i3]);
12581           }
12582           p2.next = null;
12583           return head.next;
12584         }
12585         function toList(root3) {
12586           var current = root3;
12587           var Q2 = [];
12588           var done = false;
12589           var head = new Node(null, null);
12590           var p2 = head;
12591           while (!done) {
12592             if (current) {
12593               Q2.push(current);
12594               current = current.left;
12595             } else {
12596               if (Q2.length > 0) {
12597                 current = p2 = p2.next = Q2.pop();
12598                 current = current.right;
12599               } else
12600                 done = true;
12601             }
12602           }
12603           p2.next = null;
12604           return head.next;
12605         }
12606         function sortedListToBST(list2, start2, end) {
12607           var size = end - start2;
12608           if (size > 0) {
12609             var middle = start2 + Math.floor(size / 2);
12610             var left = sortedListToBST(list2, start2, middle);
12611             var root3 = list2.head;
12612             root3.left = left;
12613             list2.head = list2.head.next;
12614             root3.right = sortedListToBST(list2, middle + 1, end);
12615             return root3;
12616           }
12617           return null;
12618         }
12619         function mergeLists(l1, l2, compare2) {
12620           var head = new Node(null, null);
12621           var p2 = head;
12622           var p1 = l1;
12623           var p22 = l2;
12624           while (p1 !== null && p22 !== null) {
12625             if (compare2(p1.key, p22.key) < 0) {
12626               p2.next = p1;
12627               p1 = p1.next;
12628             } else {
12629               p2.next = p22;
12630               p22 = p22.next;
12631             }
12632             p2 = p2.next;
12633           }
12634           if (p1 !== null) {
12635             p2.next = p1;
12636           } else if (p22 !== null) {
12637             p2.next = p22;
12638           }
12639           return head.next;
12640         }
12641         function sort(keys2, values, left, right, compare2) {
12642           if (left >= right)
12643             return;
12644           var pivot = keys2[left + right >> 1];
12645           var i3 = left - 1;
12646           var j2 = right + 1;
12647           while (true) {
12648             do
12649               i3++;
12650             while (compare2(keys2[i3], pivot) < 0);
12651             do
12652               j2--;
12653             while (compare2(keys2[j2], pivot) > 0);
12654             if (i3 >= j2)
12655               break;
12656             var tmp = keys2[i3];
12657             keys2[i3] = keys2[j2];
12658             keys2[j2] = tmp;
12659             tmp = values[i3];
12660             values[i3] = values[j2];
12661             values[j2] = tmp;
12662           }
12663           sort(keys2, values, left, j2, compare2);
12664           sort(keys2, values, j2 + 1, right, compare2);
12665         }
12666         const isInBbox2 = (bbox2, point2) => {
12667           return bbox2.ll.x <= point2.x && point2.x <= bbox2.ur.x && bbox2.ll.y <= point2.y && point2.y <= bbox2.ur.y;
12668         };
12669         const getBboxOverlap2 = (b1, b2) => {
12670           if (b2.ur.x < b1.ll.x || b1.ur.x < b2.ll.x || b2.ur.y < b1.ll.y || b1.ur.y < b2.ll.y)
12671             return null;
12672           const lowerX = b1.ll.x < b2.ll.x ? b2.ll.x : b1.ll.x;
12673           const upperX = b1.ur.x < b2.ur.x ? b1.ur.x : b2.ur.x;
12674           const lowerY = b1.ll.y < b2.ll.y ? b2.ll.y : b1.ll.y;
12675           const upperY = b1.ur.y < b2.ur.y ? b1.ur.y : b2.ur.y;
12676           return {
12677             ll: {
12678               x: lowerX,
12679               y: lowerY
12680             },
12681             ur: {
12682               x: upperX,
12683               y: upperY
12684             }
12685           };
12686         };
12687         let epsilon$1 = Number.EPSILON;
12688         if (epsilon$1 === void 0)
12689           epsilon$1 = Math.pow(2, -52);
12690         const EPSILON_SQ = epsilon$1 * epsilon$1;
12691         const cmp = (a2, b2) => {
12692           if (-epsilon$1 < a2 && a2 < epsilon$1) {
12693             if (-epsilon$1 < b2 && b2 < epsilon$1) {
12694               return 0;
12695             }
12696           }
12697           const ab = a2 - b2;
12698           if (ab * ab < EPSILON_SQ * a2 * b2) {
12699             return 0;
12700           }
12701           return a2 < b2 ? -1 : 1;
12702         };
12703         class PtRounder {
12704           constructor() {
12705             this.reset();
12706           }
12707           reset() {
12708             this.xRounder = new CoordRounder();
12709             this.yRounder = new CoordRounder();
12710           }
12711           round(x2, y2) {
12712             return {
12713               x: this.xRounder.round(x2),
12714               y: this.yRounder.round(y2)
12715             };
12716           }
12717         }
12718         class CoordRounder {
12719           constructor() {
12720             this.tree = new Tree();
12721             this.round(0);
12722           }
12723           // Note: this can rounds input values backwards or forwards.
12724           //       You might ask, why not restrict this to just rounding
12725           //       forwards? Wouldn't that allow left endpoints to always
12726           //       remain left endpoints during splitting (never change to
12727           //       right). No - it wouldn't, because we snap intersections
12728           //       to endpoints (to establish independence from the segment
12729           //       angle for t-intersections).
12730           round(coord2) {
12731             const node = this.tree.add(coord2);
12732             const prevNode = this.tree.prev(node);
12733             if (prevNode !== null && cmp(node.key, prevNode.key) === 0) {
12734               this.tree.remove(coord2);
12735               return prevNode.key;
12736             }
12737             const nextNode = this.tree.next(node);
12738             if (nextNode !== null && cmp(node.key, nextNode.key) === 0) {
12739               this.tree.remove(coord2);
12740               return nextNode.key;
12741             }
12742             return coord2;
12743           }
12744         }
12745         const rounder = new PtRounder();
12746         const epsilon3 = 11102230246251565e-32;
12747         const splitter = 134217729;
12748         const resulterrbound = (3 + 8 * epsilon3) * epsilon3;
12749         function sum(elen, e3, flen, f2, h2) {
12750           let Q2, Qnew, hh, bvirt;
12751           let enow = e3[0];
12752           let fnow = f2[0];
12753           let eindex = 0;
12754           let findex = 0;
12755           if (fnow > enow === fnow > -enow) {
12756             Q2 = enow;
12757             enow = e3[++eindex];
12758           } else {
12759             Q2 = fnow;
12760             fnow = f2[++findex];
12761           }
12762           let hindex = 0;
12763           if (eindex < elen && findex < flen) {
12764             if (fnow > enow === fnow > -enow) {
12765               Qnew = enow + Q2;
12766               hh = Q2 - (Qnew - enow);
12767               enow = e3[++eindex];
12768             } else {
12769               Qnew = fnow + Q2;
12770               hh = Q2 - (Qnew - fnow);
12771               fnow = f2[++findex];
12772             }
12773             Q2 = Qnew;
12774             if (hh !== 0) {
12775               h2[hindex++] = hh;
12776             }
12777             while (eindex < elen && findex < flen) {
12778               if (fnow > enow === fnow > -enow) {
12779                 Qnew = Q2 + enow;
12780                 bvirt = Qnew - Q2;
12781                 hh = Q2 - (Qnew - bvirt) + (enow - bvirt);
12782                 enow = e3[++eindex];
12783               } else {
12784                 Qnew = Q2 + fnow;
12785                 bvirt = Qnew - Q2;
12786                 hh = Q2 - (Qnew - bvirt) + (fnow - bvirt);
12787                 fnow = f2[++findex];
12788               }
12789               Q2 = Qnew;
12790               if (hh !== 0) {
12791                 h2[hindex++] = hh;
12792               }
12793             }
12794           }
12795           while (eindex < elen) {
12796             Qnew = Q2 + enow;
12797             bvirt = Qnew - Q2;
12798             hh = Q2 - (Qnew - bvirt) + (enow - bvirt);
12799             enow = e3[++eindex];
12800             Q2 = Qnew;
12801             if (hh !== 0) {
12802               h2[hindex++] = hh;
12803             }
12804           }
12805           while (findex < flen) {
12806             Qnew = Q2 + fnow;
12807             bvirt = Qnew - Q2;
12808             hh = Q2 - (Qnew - bvirt) + (fnow - bvirt);
12809             fnow = f2[++findex];
12810             Q2 = Qnew;
12811             if (hh !== 0) {
12812               h2[hindex++] = hh;
12813             }
12814           }
12815           if (Q2 !== 0 || hindex === 0) {
12816             h2[hindex++] = Q2;
12817           }
12818           return hindex;
12819         }
12820         function estimate(elen, e3) {
12821           let Q2 = e3[0];
12822           for (let i3 = 1; i3 < elen; i3++)
12823             Q2 += e3[i3];
12824           return Q2;
12825         }
12826         function vec(n3) {
12827           return new Float64Array(n3);
12828         }
12829         const ccwerrboundA = (3 + 16 * epsilon3) * epsilon3;
12830         const ccwerrboundB = (2 + 12 * epsilon3) * epsilon3;
12831         const ccwerrboundC = (9 + 64 * epsilon3) * epsilon3 * epsilon3;
12832         const B2 = vec(4);
12833         const C1 = vec(8);
12834         const C2 = vec(12);
12835         const D2 = vec(16);
12836         const u2 = vec(4);
12837         function orient2dadapt(ax, ay, bx, by, cx, cy, detsum) {
12838           let acxtail, acytail, bcxtail, bcytail;
12839           let bvirt, c2, ahi, alo, bhi, blo, _i, _j, _0, s1, s0, t1, t0, u3;
12840           const acx = ax - cx;
12841           const bcx = bx - cx;
12842           const acy = ay - cy;
12843           const bcy = by - cy;
12844           s1 = acx * bcy;
12845           c2 = splitter * acx;
12846           ahi = c2 - (c2 - acx);
12847           alo = acx - ahi;
12848           c2 = splitter * bcy;
12849           bhi = c2 - (c2 - bcy);
12850           blo = bcy - bhi;
12851           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
12852           t1 = acy * bcx;
12853           c2 = splitter * acy;
12854           ahi = c2 - (c2 - acy);
12855           alo = acy - ahi;
12856           c2 = splitter * bcx;
12857           bhi = c2 - (c2 - bcx);
12858           blo = bcx - bhi;
12859           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
12860           _i = s0 - t0;
12861           bvirt = s0 - _i;
12862           B2[0] = s0 - (_i + bvirt) + (bvirt - t0);
12863           _j = s1 + _i;
12864           bvirt = _j - s1;
12865           _0 = s1 - (_j - bvirt) + (_i - bvirt);
12866           _i = _0 - t1;
12867           bvirt = _0 - _i;
12868           B2[1] = _0 - (_i + bvirt) + (bvirt - t1);
12869           u3 = _j + _i;
12870           bvirt = u3 - _j;
12871           B2[2] = _j - (u3 - bvirt) + (_i - bvirt);
12872           B2[3] = u3;
12873           let det = estimate(4, B2);
12874           let errbound = ccwerrboundB * detsum;
12875           if (det >= errbound || -det >= errbound) {
12876             return det;
12877           }
12878           bvirt = ax - acx;
12879           acxtail = ax - (acx + bvirt) + (bvirt - cx);
12880           bvirt = bx - bcx;
12881           bcxtail = bx - (bcx + bvirt) + (bvirt - cx);
12882           bvirt = ay - acy;
12883           acytail = ay - (acy + bvirt) + (bvirt - cy);
12884           bvirt = by - bcy;
12885           bcytail = by - (bcy + bvirt) + (bvirt - cy);
12886           if (acxtail === 0 && acytail === 0 && bcxtail === 0 && bcytail === 0) {
12887             return det;
12888           }
12889           errbound = ccwerrboundC * detsum + resulterrbound * Math.abs(det);
12890           det += acx * bcytail + bcy * acxtail - (acy * bcxtail + bcx * acytail);
12891           if (det >= errbound || -det >= errbound)
12892             return det;
12893           s1 = acxtail * bcy;
12894           c2 = splitter * acxtail;
12895           ahi = c2 - (c2 - acxtail);
12896           alo = acxtail - ahi;
12897           c2 = splitter * bcy;
12898           bhi = c2 - (c2 - bcy);
12899           blo = bcy - bhi;
12900           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
12901           t1 = acytail * bcx;
12902           c2 = splitter * acytail;
12903           ahi = c2 - (c2 - acytail);
12904           alo = acytail - ahi;
12905           c2 = splitter * bcx;
12906           bhi = c2 - (c2 - bcx);
12907           blo = bcx - bhi;
12908           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
12909           _i = s0 - t0;
12910           bvirt = s0 - _i;
12911           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
12912           _j = s1 + _i;
12913           bvirt = _j - s1;
12914           _0 = s1 - (_j - bvirt) + (_i - bvirt);
12915           _i = _0 - t1;
12916           bvirt = _0 - _i;
12917           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
12918           u3 = _j + _i;
12919           bvirt = u3 - _j;
12920           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
12921           u2[3] = u3;
12922           const C1len = sum(4, B2, 4, u2, C1);
12923           s1 = acx * bcytail;
12924           c2 = splitter * acx;
12925           ahi = c2 - (c2 - acx);
12926           alo = acx - ahi;
12927           c2 = splitter * bcytail;
12928           bhi = c2 - (c2 - bcytail);
12929           blo = bcytail - bhi;
12930           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
12931           t1 = acy * bcxtail;
12932           c2 = splitter * acy;
12933           ahi = c2 - (c2 - acy);
12934           alo = acy - ahi;
12935           c2 = splitter * bcxtail;
12936           bhi = c2 - (c2 - bcxtail);
12937           blo = bcxtail - bhi;
12938           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
12939           _i = s0 - t0;
12940           bvirt = s0 - _i;
12941           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
12942           _j = s1 + _i;
12943           bvirt = _j - s1;
12944           _0 = s1 - (_j - bvirt) + (_i - bvirt);
12945           _i = _0 - t1;
12946           bvirt = _0 - _i;
12947           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
12948           u3 = _j + _i;
12949           bvirt = u3 - _j;
12950           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
12951           u2[3] = u3;
12952           const C2len = sum(C1len, C1, 4, u2, C2);
12953           s1 = acxtail * bcytail;
12954           c2 = splitter * acxtail;
12955           ahi = c2 - (c2 - acxtail);
12956           alo = acxtail - ahi;
12957           c2 = splitter * bcytail;
12958           bhi = c2 - (c2 - bcytail);
12959           blo = bcytail - bhi;
12960           s0 = alo * blo - (s1 - ahi * bhi - alo * bhi - ahi * blo);
12961           t1 = acytail * bcxtail;
12962           c2 = splitter * acytail;
12963           ahi = c2 - (c2 - acytail);
12964           alo = acytail - ahi;
12965           c2 = splitter * bcxtail;
12966           bhi = c2 - (c2 - bcxtail);
12967           blo = bcxtail - bhi;
12968           t0 = alo * blo - (t1 - ahi * bhi - alo * bhi - ahi * blo);
12969           _i = s0 - t0;
12970           bvirt = s0 - _i;
12971           u2[0] = s0 - (_i + bvirt) + (bvirt - t0);
12972           _j = s1 + _i;
12973           bvirt = _j - s1;
12974           _0 = s1 - (_j - bvirt) + (_i - bvirt);
12975           _i = _0 - t1;
12976           bvirt = _0 - _i;
12977           u2[1] = _0 - (_i + bvirt) + (bvirt - t1);
12978           u3 = _j + _i;
12979           bvirt = u3 - _j;
12980           u2[2] = _j - (u3 - bvirt) + (_i - bvirt);
12981           u2[3] = u3;
12982           const Dlen = sum(C2len, C2, 4, u2, D2);
12983           return D2[Dlen - 1];
12984         }
12985         function orient2d(ax, ay, bx, by, cx, cy) {
12986           const detleft = (ay - cy) * (bx - cx);
12987           const detright = (ax - cx) * (by - cy);
12988           const det = detleft - detright;
12989           const detsum = Math.abs(detleft + detright);
12990           if (Math.abs(det) >= ccwerrboundA * detsum)
12991             return det;
12992           return -orient2dadapt(ax, ay, bx, by, cx, cy, detsum);
12993         }
12994         const crossProduct2 = (a2, b2) => a2.x * b2.y - a2.y * b2.x;
12995         const dotProduct2 = (a2, b2) => a2.x * b2.x + a2.y * b2.y;
12996         const compareVectorAngles = (basePt, endPt1, endPt2) => {
12997           const res = orient2d(basePt.x, basePt.y, endPt1.x, endPt1.y, endPt2.x, endPt2.y);
12998           if (res > 0)
12999             return -1;
13000           if (res < 0)
13001             return 1;
13002           return 0;
13003         };
13004         const length2 = (v2) => Math.sqrt(dotProduct2(v2, v2));
13005         const sineOfAngle2 = (pShared, pBase, pAngle) => {
13006           const vBase = {
13007             x: pBase.x - pShared.x,
13008             y: pBase.y - pShared.y
13009           };
13010           const vAngle = {
13011             x: pAngle.x - pShared.x,
13012             y: pAngle.y - pShared.y
13013           };
13014           return crossProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase);
13015         };
13016         const cosineOfAngle2 = (pShared, pBase, pAngle) => {
13017           const vBase = {
13018             x: pBase.x - pShared.x,
13019             y: pBase.y - pShared.y
13020           };
13021           const vAngle = {
13022             x: pAngle.x - pShared.x,
13023             y: pAngle.y - pShared.y
13024           };
13025           return dotProduct2(vAngle, vBase) / length2(vAngle) / length2(vBase);
13026         };
13027         const horizontalIntersection2 = (pt2, v2, y2) => {
13028           if (v2.y === 0)
13029             return null;
13030           return {
13031             x: pt2.x + v2.x / v2.y * (y2 - pt2.y),
13032             y: y2
13033           };
13034         };
13035         const verticalIntersection2 = (pt2, v2, x2) => {
13036           if (v2.x === 0)
13037             return null;
13038           return {
13039             x: x2,
13040             y: pt2.y + v2.y / v2.x * (x2 - pt2.x)
13041           };
13042         };
13043         const intersection$1 = (pt1, v1, pt2, v2) => {
13044           if (v1.x === 0)
13045             return verticalIntersection2(pt2, v2, pt1.x);
13046           if (v2.x === 0)
13047             return verticalIntersection2(pt1, v1, pt2.x);
13048           if (v1.y === 0)
13049             return horizontalIntersection2(pt2, v2, pt1.y);
13050           if (v2.y === 0)
13051             return horizontalIntersection2(pt1, v1, pt2.y);
13052           const kross = crossProduct2(v1, v2);
13053           if (kross == 0)
13054             return null;
13055           const ve2 = {
13056             x: pt2.x - pt1.x,
13057             y: pt2.y - pt1.y
13058           };
13059           const d1 = crossProduct2(ve2, v1) / kross;
13060           const d2 = crossProduct2(ve2, v2) / kross;
13061           const x12 = pt1.x + d2 * v1.x, x2 = pt2.x + d1 * v2.x;
13062           const y12 = pt1.y + d2 * v1.y, y2 = pt2.y + d1 * v2.y;
13063           const x3 = (x12 + x2) / 2;
13064           const y3 = (y12 + y2) / 2;
13065           return {
13066             x: x3,
13067             y: y3
13068           };
13069         };
13070         class SweepEvent2 {
13071           // for ordering sweep events in the sweep event queue
13072           static compare(a2, b2) {
13073             const ptCmp = SweepEvent2.comparePoints(a2.point, b2.point);
13074             if (ptCmp !== 0)
13075               return ptCmp;
13076             if (a2.point !== b2.point)
13077               a2.link(b2);
13078             if (a2.isLeft !== b2.isLeft)
13079               return a2.isLeft ? 1 : -1;
13080             return Segment2.compare(a2.segment, b2.segment);
13081           }
13082           // for ordering points in sweep line order
13083           static comparePoints(aPt, bPt) {
13084             if (aPt.x < bPt.x)
13085               return -1;
13086             if (aPt.x > bPt.x)
13087               return 1;
13088             if (aPt.y < bPt.y)
13089               return -1;
13090             if (aPt.y > bPt.y)
13091               return 1;
13092             return 0;
13093           }
13094           // Warning: 'point' input will be modified and re-used (for performance)
13095           constructor(point2, isLeft) {
13096             if (point2.events === void 0)
13097               point2.events = [this];
13098             else
13099               point2.events.push(this);
13100             this.point = point2;
13101             this.isLeft = isLeft;
13102           }
13103           link(other) {
13104             if (other.point === this.point) {
13105               throw new Error("Tried to link already linked events");
13106             }
13107             const otherEvents = other.point.events;
13108             for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) {
13109               const evt = otherEvents[i3];
13110               this.point.events.push(evt);
13111               evt.point = this.point;
13112             }
13113             this.checkForConsuming();
13114           }
13115           /* Do a pass over our linked events and check to see if any pair
13116            * of segments match, and should be consumed. */
13117           checkForConsuming() {
13118             const numEvents = this.point.events.length;
13119             for (let i3 = 0; i3 < numEvents; i3++) {
13120               const evt1 = this.point.events[i3];
13121               if (evt1.segment.consumedBy !== void 0)
13122                 continue;
13123               for (let j2 = i3 + 1; j2 < numEvents; j2++) {
13124                 const evt2 = this.point.events[j2];
13125                 if (evt2.consumedBy !== void 0)
13126                   continue;
13127                 if (evt1.otherSE.point.events !== evt2.otherSE.point.events)
13128                   continue;
13129                 evt1.segment.consume(evt2.segment);
13130               }
13131             }
13132           }
13133           getAvailableLinkedEvents() {
13134             const events = [];
13135             for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) {
13136               const evt = this.point.events[i3];
13137               if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
13138                 events.push(evt);
13139               }
13140             }
13141             return events;
13142           }
13143           /**
13144            * Returns a comparator function for sorting linked events that will
13145            * favor the event that will give us the smallest left-side angle.
13146            * All ring construction starts as low as possible heading to the right,
13147            * so by always turning left as sharp as possible we'll get polygons
13148            * without uncessary loops & holes.
13149            *
13150            * The comparator function has a compute cache such that it avoids
13151            * re-computing already-computed values.
13152            */
13153           getLeftmostComparator(baseEvent) {
13154             const cache = /* @__PURE__ */ new Map();
13155             const fillCache = (linkedEvent) => {
13156               const nextEvent = linkedEvent.otherSE;
13157               cache.set(linkedEvent, {
13158                 sine: sineOfAngle2(this.point, baseEvent.point, nextEvent.point),
13159                 cosine: cosineOfAngle2(this.point, baseEvent.point, nextEvent.point)
13160               });
13161             };
13162             return (a2, b2) => {
13163               if (!cache.has(a2))
13164                 fillCache(a2);
13165               if (!cache.has(b2))
13166                 fillCache(b2);
13167               const {
13168                 sine: asine,
13169                 cosine: acosine
13170               } = cache.get(a2);
13171               const {
13172                 sine: bsine,
13173                 cosine: bcosine
13174               } = cache.get(b2);
13175               if (asine >= 0 && bsine >= 0) {
13176                 if (acosine < bcosine)
13177                   return 1;
13178                 if (acosine > bcosine)
13179                   return -1;
13180                 return 0;
13181               }
13182               if (asine < 0 && bsine < 0) {
13183                 if (acosine < bcosine)
13184                   return -1;
13185                 if (acosine > bcosine)
13186                   return 1;
13187                 return 0;
13188               }
13189               if (bsine < asine)
13190                 return -1;
13191               if (bsine > asine)
13192                 return 1;
13193               return 0;
13194             };
13195           }
13196         }
13197         let segmentId2 = 0;
13198         class Segment2 {
13199           /* This compare() function is for ordering segments in the sweep
13200            * line tree, and does so according to the following criteria:
13201            *
13202            * Consider the vertical line that lies an infinestimal step to the
13203            * right of the right-more of the two left endpoints of the input
13204            * segments. Imagine slowly moving a point up from negative infinity
13205            * in the increasing y direction. Which of the two segments will that
13206            * point intersect first? That segment comes 'before' the other one.
13207            *
13208            * If neither segment would be intersected by such a line, (if one
13209            * or more of the segments are vertical) then the line to be considered
13210            * is directly on the right-more of the two left inputs.
13211            */
13212           static compare(a2, b2) {
13213             const alx = a2.leftSE.point.x;
13214             const blx = b2.leftSE.point.x;
13215             const arx = a2.rightSE.point.x;
13216             const brx = b2.rightSE.point.x;
13217             if (brx < alx)
13218               return 1;
13219             if (arx < blx)
13220               return -1;
13221             const aly = a2.leftSE.point.y;
13222             const bly = b2.leftSE.point.y;
13223             const ary = a2.rightSE.point.y;
13224             const bry = b2.rightSE.point.y;
13225             if (alx < blx) {
13226               if (bly < aly && bly < ary)
13227                 return 1;
13228               if (bly > aly && bly > ary)
13229                 return -1;
13230               const aCmpBLeft = a2.comparePoint(b2.leftSE.point);
13231               if (aCmpBLeft < 0)
13232                 return 1;
13233               if (aCmpBLeft > 0)
13234                 return -1;
13235               const bCmpARight = b2.comparePoint(a2.rightSE.point);
13236               if (bCmpARight !== 0)
13237                 return bCmpARight;
13238               return -1;
13239             }
13240             if (alx > blx) {
13241               if (aly < bly && aly < bry)
13242                 return -1;
13243               if (aly > bly && aly > bry)
13244                 return 1;
13245               const bCmpALeft = b2.comparePoint(a2.leftSE.point);
13246               if (bCmpALeft !== 0)
13247                 return bCmpALeft;
13248               const aCmpBRight = a2.comparePoint(b2.rightSE.point);
13249               if (aCmpBRight < 0)
13250                 return 1;
13251               if (aCmpBRight > 0)
13252                 return -1;
13253               return 1;
13254             }
13255             if (aly < bly)
13256               return -1;
13257             if (aly > bly)
13258               return 1;
13259             if (arx < brx) {
13260               const bCmpARight = b2.comparePoint(a2.rightSE.point);
13261               if (bCmpARight !== 0)
13262                 return bCmpARight;
13263             }
13264             if (arx > brx) {
13265               const aCmpBRight = a2.comparePoint(b2.rightSE.point);
13266               if (aCmpBRight < 0)
13267                 return 1;
13268               if (aCmpBRight > 0)
13269                 return -1;
13270             }
13271             if (arx !== brx) {
13272               const ay = ary - aly;
13273               const ax = arx - alx;
13274               const by = bry - bly;
13275               const bx = brx - blx;
13276               if (ay > ax && by < bx)
13277                 return 1;
13278               if (ay < ax && by > bx)
13279                 return -1;
13280             }
13281             if (arx > brx)
13282               return 1;
13283             if (arx < brx)
13284               return -1;
13285             if (ary < bry)
13286               return -1;
13287             if (ary > bry)
13288               return 1;
13289             if (a2.id < b2.id)
13290               return -1;
13291             if (a2.id > b2.id)
13292               return 1;
13293             return 0;
13294           }
13295           /* Warning: a reference to ringWindings input will be stored,
13296            *  and possibly will be later modified */
13297           constructor(leftSE, rightSE, rings, windings) {
13298             this.id = ++segmentId2;
13299             this.leftSE = leftSE;
13300             leftSE.segment = this;
13301             leftSE.otherSE = rightSE;
13302             this.rightSE = rightSE;
13303             rightSE.segment = this;
13304             rightSE.otherSE = leftSE;
13305             this.rings = rings;
13306             this.windings = windings;
13307           }
13308           static fromRing(pt1, pt2, ring) {
13309             let leftPt, rightPt, winding;
13310             const cmpPts = SweepEvent2.comparePoints(pt1, pt2);
13311             if (cmpPts < 0) {
13312               leftPt = pt1;
13313               rightPt = pt2;
13314               winding = 1;
13315             } else if (cmpPts > 0) {
13316               leftPt = pt2;
13317               rightPt = pt1;
13318               winding = -1;
13319             } else
13320               throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]"));
13321             const leftSE = new SweepEvent2(leftPt, true);
13322             const rightSE = new SweepEvent2(rightPt, false);
13323             return new Segment2(leftSE, rightSE, [ring], [winding]);
13324           }
13325           /* When a segment is split, the rightSE is replaced with a new sweep event */
13326           replaceRightSE(newRightSE) {
13327             this.rightSE = newRightSE;
13328             this.rightSE.segment = this;
13329             this.rightSE.otherSE = this.leftSE;
13330             this.leftSE.otherSE = this.rightSE;
13331           }
13332           bbox() {
13333             const y12 = this.leftSE.point.y;
13334             const y2 = this.rightSE.point.y;
13335             return {
13336               ll: {
13337                 x: this.leftSE.point.x,
13338                 y: y12 < y2 ? y12 : y2
13339               },
13340               ur: {
13341                 x: this.rightSE.point.x,
13342                 y: y12 > y2 ? y12 : y2
13343               }
13344             };
13345           }
13346           /* A vector from the left point to the right */
13347           vector() {
13348             return {
13349               x: this.rightSE.point.x - this.leftSE.point.x,
13350               y: this.rightSE.point.y - this.leftSE.point.y
13351             };
13352           }
13353           isAnEndpoint(pt2) {
13354             return pt2.x === this.leftSE.point.x && pt2.y === this.leftSE.point.y || pt2.x === this.rightSE.point.x && pt2.y === this.rightSE.point.y;
13355           }
13356           /* Compare this segment with a point.
13357            *
13358            * A point P is considered to be colinear to a segment if there
13359            * exists a distance D such that if we travel along the segment
13360            * from one * endpoint towards the other a distance D, we find
13361            * ourselves at point P.
13362            *
13363            * Return value indicates:
13364            *
13365            *   1: point lies above the segment (to the left of vertical)
13366            *   0: point is colinear to segment
13367            *  -1: point lies below the segment (to the right of vertical)
13368            */
13369           comparePoint(point2) {
13370             if (this.isAnEndpoint(point2))
13371               return 0;
13372             const lPt = this.leftSE.point;
13373             const rPt = this.rightSE.point;
13374             const v2 = this.vector();
13375             if (lPt.x === rPt.x) {
13376               if (point2.x === lPt.x)
13377                 return 0;
13378               return point2.x < lPt.x ? 1 : -1;
13379             }
13380             const yDist = (point2.y - lPt.y) / v2.y;
13381             const xFromYDist = lPt.x + yDist * v2.x;
13382             if (point2.x === xFromYDist)
13383               return 0;
13384             const xDist = (point2.x - lPt.x) / v2.x;
13385             const yFromXDist = lPt.y + xDist * v2.y;
13386             if (point2.y === yFromXDist)
13387               return 0;
13388             return point2.y < yFromXDist ? -1 : 1;
13389           }
13390           /**
13391            * Given another segment, returns the first non-trivial intersection
13392            * between the two segments (in terms of sweep line ordering), if it exists.
13393            *
13394            * A 'non-trivial' intersection is one that will cause one or both of the
13395            * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
13396            *
13397            *   * endpoint of segA with endpoint of segB --> trivial
13398            *   * endpoint of segA with point along segB --> non-trivial
13399            *   * endpoint of segB with point along segA --> non-trivial
13400            *   * point along segA with point along segB --> non-trivial
13401            *
13402            * If no non-trivial intersection exists, return null
13403            * Else, return null.
13404            */
13405           getIntersection(other) {
13406             const tBbox = this.bbox();
13407             const oBbox = other.bbox();
13408             const bboxOverlap = getBboxOverlap2(tBbox, oBbox);
13409             if (bboxOverlap === null)
13410               return null;
13411             const tlp = this.leftSE.point;
13412             const trp = this.rightSE.point;
13413             const olp = other.leftSE.point;
13414             const orp = other.rightSE.point;
13415             const touchesOtherLSE = isInBbox2(tBbox, olp) && this.comparePoint(olp) === 0;
13416             const touchesThisLSE = isInBbox2(oBbox, tlp) && other.comparePoint(tlp) === 0;
13417             const touchesOtherRSE = isInBbox2(tBbox, orp) && this.comparePoint(orp) === 0;
13418             const touchesThisRSE = isInBbox2(oBbox, trp) && other.comparePoint(trp) === 0;
13419             if (touchesThisLSE && touchesOtherLSE) {
13420               if (touchesThisRSE && !touchesOtherRSE)
13421                 return trp;
13422               if (!touchesThisRSE && touchesOtherRSE)
13423                 return orp;
13424               return null;
13425             }
13426             if (touchesThisLSE) {
13427               if (touchesOtherRSE) {
13428                 if (tlp.x === orp.x && tlp.y === orp.y)
13429                   return null;
13430               }
13431               return tlp;
13432             }
13433             if (touchesOtherLSE) {
13434               if (touchesThisRSE) {
13435                 if (trp.x === olp.x && trp.y === olp.y)
13436                   return null;
13437               }
13438               return olp;
13439             }
13440             if (touchesThisRSE && touchesOtherRSE)
13441               return null;
13442             if (touchesThisRSE)
13443               return trp;
13444             if (touchesOtherRSE)
13445               return orp;
13446             const pt2 = intersection$1(tlp, this.vector(), olp, other.vector());
13447             if (pt2 === null)
13448               return null;
13449             if (!isInBbox2(bboxOverlap, pt2))
13450               return null;
13451             return rounder.round(pt2.x, pt2.y);
13452           }
13453           /**
13454            * Split the given segment into multiple segments on the given points.
13455            *  * Each existing segment will retain its leftSE and a new rightSE will be
13456            *    generated for it.
13457            *  * A new segment will be generated which will adopt the original segment's
13458            *    rightSE, and a new leftSE will be generated for it.
13459            *  * If there are more than two points given to split on, new segments
13460            *    in the middle will be generated with new leftSE and rightSE's.
13461            *  * An array of the newly generated SweepEvents will be returned.
13462            *
13463            * Warning: input array of points is modified
13464            */
13465           split(point2) {
13466             const newEvents = [];
13467             const alreadyLinked = point2.events !== void 0;
13468             const newLeftSE = new SweepEvent2(point2, true);
13469             const newRightSE = new SweepEvent2(point2, false);
13470             const oldRightSE = this.rightSE;
13471             this.replaceRightSE(newRightSE);
13472             newEvents.push(newRightSE);
13473             newEvents.push(newLeftSE);
13474             const newSeg = new Segment2(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
13475             if (SweepEvent2.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
13476               newSeg.swapEvents();
13477             }
13478             if (SweepEvent2.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
13479               this.swapEvents();
13480             }
13481             if (alreadyLinked) {
13482               newLeftSE.checkForConsuming();
13483               newRightSE.checkForConsuming();
13484             }
13485             return newEvents;
13486           }
13487           /* Swap which event is left and right */
13488           swapEvents() {
13489             const tmpEvt = this.rightSE;
13490             this.rightSE = this.leftSE;
13491             this.leftSE = tmpEvt;
13492             this.leftSE.isLeft = true;
13493             this.rightSE.isLeft = false;
13494             for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) {
13495               this.windings[i3] *= -1;
13496             }
13497           }
13498           /* Consume another segment. We take their rings under our wing
13499            * and mark them as consumed. Use for perfectly overlapping segments */
13500           consume(other) {
13501             let consumer = this;
13502             let consumee = other;
13503             while (consumer.consumedBy)
13504               consumer = consumer.consumedBy;
13505             while (consumee.consumedBy)
13506               consumee = consumee.consumedBy;
13507             const cmp2 = Segment2.compare(consumer, consumee);
13508             if (cmp2 === 0)
13509               return;
13510             if (cmp2 > 0) {
13511               const tmp = consumer;
13512               consumer = consumee;
13513               consumee = tmp;
13514             }
13515             if (consumer.prev === consumee) {
13516               const tmp = consumer;
13517               consumer = consumee;
13518               consumee = tmp;
13519             }
13520             for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) {
13521               const ring = consumee.rings[i3];
13522               const winding = consumee.windings[i3];
13523               const index2 = consumer.rings.indexOf(ring);
13524               if (index2 === -1) {
13525                 consumer.rings.push(ring);
13526                 consumer.windings.push(winding);
13527               } else
13528                 consumer.windings[index2] += winding;
13529             }
13530             consumee.rings = null;
13531             consumee.windings = null;
13532             consumee.consumedBy = consumer;
13533             consumee.leftSE.consumedBy = consumer.leftSE;
13534             consumee.rightSE.consumedBy = consumer.rightSE;
13535           }
13536           /* The first segment previous segment chain that is in the result */
13537           prevInResult() {
13538             if (this._prevInResult !== void 0)
13539               return this._prevInResult;
13540             if (!this.prev)
13541               this._prevInResult = null;
13542             else if (this.prev.isInResult())
13543               this._prevInResult = this.prev;
13544             else
13545               this._prevInResult = this.prev.prevInResult();
13546             return this._prevInResult;
13547           }
13548           beforeState() {
13549             if (this._beforeState !== void 0)
13550               return this._beforeState;
13551             if (!this.prev)
13552               this._beforeState = {
13553                 rings: [],
13554                 windings: [],
13555                 multiPolys: []
13556               };
13557             else {
13558               const seg = this.prev.consumedBy || this.prev;
13559               this._beforeState = seg.afterState();
13560             }
13561             return this._beforeState;
13562           }
13563           afterState() {
13564             if (this._afterState !== void 0)
13565               return this._afterState;
13566             const beforeState = this.beforeState();
13567             this._afterState = {
13568               rings: beforeState.rings.slice(0),
13569               windings: beforeState.windings.slice(0),
13570               multiPolys: []
13571             };
13572             const ringsAfter = this._afterState.rings;
13573             const windingsAfter = this._afterState.windings;
13574             const mpsAfter = this._afterState.multiPolys;
13575             for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) {
13576               const ring = this.rings[i3];
13577               const winding = this.windings[i3];
13578               const index2 = ringsAfter.indexOf(ring);
13579               if (index2 === -1) {
13580                 ringsAfter.push(ring);
13581                 windingsAfter.push(winding);
13582               } else
13583                 windingsAfter[index2] += winding;
13584             }
13585             const polysAfter = [];
13586             const polysExclude = [];
13587             for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) {
13588               if (windingsAfter[i3] === 0)
13589                 continue;
13590               const ring = ringsAfter[i3];
13591               const poly = ring.poly;
13592               if (polysExclude.indexOf(poly) !== -1)
13593                 continue;
13594               if (ring.isExterior)
13595                 polysAfter.push(poly);
13596               else {
13597                 if (polysExclude.indexOf(poly) === -1)
13598                   polysExclude.push(poly);
13599                 const index2 = polysAfter.indexOf(ring.poly);
13600                 if (index2 !== -1)
13601                   polysAfter.splice(index2, 1);
13602               }
13603             }
13604             for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) {
13605               const mp = polysAfter[i3].multiPoly;
13606               if (mpsAfter.indexOf(mp) === -1)
13607                 mpsAfter.push(mp);
13608             }
13609             return this._afterState;
13610           }
13611           /* Is this segment part of the final result? */
13612           isInResult() {
13613             if (this.consumedBy)
13614               return false;
13615             if (this._isInResult !== void 0)
13616               return this._isInResult;
13617             const mpsBefore = this.beforeState().multiPolys;
13618             const mpsAfter = this.afterState().multiPolys;
13619             switch (operation2.type) {
13620               case "union": {
13621                 const noBefores = mpsBefore.length === 0;
13622                 const noAfters = mpsAfter.length === 0;
13623                 this._isInResult = noBefores !== noAfters;
13624                 break;
13625               }
13626               case "intersection": {
13627                 let least;
13628                 let most;
13629                 if (mpsBefore.length < mpsAfter.length) {
13630                   least = mpsBefore.length;
13631                   most = mpsAfter.length;
13632                 } else {
13633                   least = mpsAfter.length;
13634                   most = mpsBefore.length;
13635                 }
13636                 this._isInResult = most === operation2.numMultiPolys && least < most;
13637                 break;
13638               }
13639               case "xor": {
13640                 const diff = Math.abs(mpsBefore.length - mpsAfter.length);
13641                 this._isInResult = diff % 2 === 1;
13642                 break;
13643               }
13644               case "difference": {
13645                 const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject;
13646                 this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
13647                 break;
13648               }
13649               default:
13650                 throw new Error("Unrecognized operation type found ".concat(operation2.type));
13651             }
13652             return this._isInResult;
13653           }
13654         }
13655         class RingIn2 {
13656           constructor(geomRing, poly, isExterior) {
13657             if (!Array.isArray(geomRing) || geomRing.length === 0) {
13658               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13659             }
13660             this.poly = poly;
13661             this.isExterior = isExterior;
13662             this.segments = [];
13663             if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
13664               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13665             }
13666             const firstPoint = rounder.round(geomRing[0][0], geomRing[0][1]);
13667             this.bbox = {
13668               ll: {
13669                 x: firstPoint.x,
13670                 y: firstPoint.y
13671               },
13672               ur: {
13673                 x: firstPoint.x,
13674                 y: firstPoint.y
13675               }
13676             };
13677             let prevPoint = firstPoint;
13678             for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) {
13679               if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") {
13680                 throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13681               }
13682               let point2 = rounder.round(geomRing[i3][0], geomRing[i3][1]);
13683               if (point2.x === prevPoint.x && point2.y === prevPoint.y)
13684                 continue;
13685               this.segments.push(Segment2.fromRing(prevPoint, point2, this));
13686               if (point2.x < this.bbox.ll.x)
13687                 this.bbox.ll.x = point2.x;
13688               if (point2.y < this.bbox.ll.y)
13689                 this.bbox.ll.y = point2.y;
13690               if (point2.x > this.bbox.ur.x)
13691                 this.bbox.ur.x = point2.x;
13692               if (point2.y > this.bbox.ur.y)
13693                 this.bbox.ur.y = point2.y;
13694               prevPoint = point2;
13695             }
13696             if (firstPoint.x !== prevPoint.x || firstPoint.y !== prevPoint.y) {
13697               this.segments.push(Segment2.fromRing(prevPoint, firstPoint, this));
13698             }
13699           }
13700           getSweepEvents() {
13701             const sweepEvents = [];
13702             for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) {
13703               const segment = this.segments[i3];
13704               sweepEvents.push(segment.leftSE);
13705               sweepEvents.push(segment.rightSE);
13706             }
13707             return sweepEvents;
13708           }
13709         }
13710         class PolyIn2 {
13711           constructor(geomPoly, multiPoly) {
13712             if (!Array.isArray(geomPoly)) {
13713               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13714             }
13715             this.exteriorRing = new RingIn2(geomPoly[0], this, true);
13716             this.bbox = {
13717               ll: {
13718                 x: this.exteriorRing.bbox.ll.x,
13719                 y: this.exteriorRing.bbox.ll.y
13720               },
13721               ur: {
13722                 x: this.exteriorRing.bbox.ur.x,
13723                 y: this.exteriorRing.bbox.ur.y
13724               }
13725             };
13726             this.interiorRings = [];
13727             for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) {
13728               const ring = new RingIn2(geomPoly[i3], this, false);
13729               if (ring.bbox.ll.x < this.bbox.ll.x)
13730                 this.bbox.ll.x = ring.bbox.ll.x;
13731               if (ring.bbox.ll.y < this.bbox.ll.y)
13732                 this.bbox.ll.y = ring.bbox.ll.y;
13733               if (ring.bbox.ur.x > this.bbox.ur.x)
13734                 this.bbox.ur.x = ring.bbox.ur.x;
13735               if (ring.bbox.ur.y > this.bbox.ur.y)
13736                 this.bbox.ur.y = ring.bbox.ur.y;
13737               this.interiorRings.push(ring);
13738             }
13739             this.multiPoly = multiPoly;
13740           }
13741           getSweepEvents() {
13742             const sweepEvents = this.exteriorRing.getSweepEvents();
13743             for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
13744               const ringSweepEvents = this.interiorRings[i3].getSweepEvents();
13745               for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) {
13746                 sweepEvents.push(ringSweepEvents[j2]);
13747               }
13748             }
13749             return sweepEvents;
13750           }
13751         }
13752         class MultiPolyIn2 {
13753           constructor(geom, isSubject) {
13754             if (!Array.isArray(geom)) {
13755               throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
13756             }
13757             try {
13758               if (typeof geom[0][0][0] === "number")
13759                 geom = [geom];
13760             } catch (ex) {
13761             }
13762             this.polys = [];
13763             this.bbox = {
13764               ll: {
13765                 x: Number.POSITIVE_INFINITY,
13766                 y: Number.POSITIVE_INFINITY
13767               },
13768               ur: {
13769                 x: Number.NEGATIVE_INFINITY,
13770                 y: Number.NEGATIVE_INFINITY
13771               }
13772             };
13773             for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) {
13774               const poly = new PolyIn2(geom[i3], this);
13775               if (poly.bbox.ll.x < this.bbox.ll.x)
13776                 this.bbox.ll.x = poly.bbox.ll.x;
13777               if (poly.bbox.ll.y < this.bbox.ll.y)
13778                 this.bbox.ll.y = poly.bbox.ll.y;
13779               if (poly.bbox.ur.x > this.bbox.ur.x)
13780                 this.bbox.ur.x = poly.bbox.ur.x;
13781               if (poly.bbox.ur.y > this.bbox.ur.y)
13782                 this.bbox.ur.y = poly.bbox.ur.y;
13783               this.polys.push(poly);
13784             }
13785             this.isSubject = isSubject;
13786           }
13787           getSweepEvents() {
13788             const sweepEvents = [];
13789             for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
13790               const polySweepEvents = this.polys[i3].getSweepEvents();
13791               for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) {
13792                 sweepEvents.push(polySweepEvents[j2]);
13793               }
13794             }
13795             return sweepEvents;
13796           }
13797         }
13798         class RingOut2 {
13799           /* Given the segments from the sweep line pass, compute & return a series
13800            * of closed rings from all the segments marked to be part of the result */
13801           static factory(allSegments) {
13802             const ringsOut = [];
13803             for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) {
13804               const segment = allSegments[i3];
13805               if (!segment.isInResult() || segment.ringOut)
13806                 continue;
13807               let prevEvent = null;
13808               let event = segment.leftSE;
13809               let nextEvent = segment.rightSE;
13810               const events = [event];
13811               const startingPoint = event.point;
13812               const intersectionLEs = [];
13813               while (true) {
13814                 prevEvent = event;
13815                 event = nextEvent;
13816                 events.push(event);
13817                 if (event.point === startingPoint)
13818                   break;
13819                 while (true) {
13820                   const availableLEs = event.getAvailableLinkedEvents();
13821                   if (availableLEs.length === 0) {
13822                     const firstPt = events[0].point;
13823                     const lastPt = events[events.length - 1].point;
13824                     throw new Error("Unable to complete output ring starting at [".concat(firstPt.x, ",") + " ".concat(firstPt.y, "]. Last matching segment found ends at") + " [".concat(lastPt.x, ", ").concat(lastPt.y, "]."));
13825                   }
13826                   if (availableLEs.length === 1) {
13827                     nextEvent = availableLEs[0].otherSE;
13828                     break;
13829                   }
13830                   let indexLE = null;
13831                   for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) {
13832                     if (intersectionLEs[j2].point === event.point) {
13833                       indexLE = j2;
13834                       break;
13835                     }
13836                   }
13837                   if (indexLE !== null) {
13838                     const intersectionLE = intersectionLEs.splice(indexLE)[0];
13839                     const ringEvents = events.splice(intersectionLE.index);
13840                     ringEvents.unshift(ringEvents[0].otherSE);
13841                     ringsOut.push(new RingOut2(ringEvents.reverse()));
13842                     continue;
13843                   }
13844                   intersectionLEs.push({
13845                     index: events.length,
13846                     point: event.point
13847                   });
13848                   const comparator = event.getLeftmostComparator(prevEvent);
13849                   nextEvent = availableLEs.sort(comparator)[0].otherSE;
13850                   break;
13851                 }
13852               }
13853               ringsOut.push(new RingOut2(events));
13854             }
13855             return ringsOut;
13856           }
13857           constructor(events) {
13858             this.events = events;
13859             for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) {
13860               events[i3].segment.ringOut = this;
13861             }
13862             this.poly = null;
13863           }
13864           getGeom() {
13865             let prevPt = this.events[0].point;
13866             const points = [prevPt];
13867             for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) {
13868               const pt3 = this.events[i3].point;
13869               const nextPt2 = this.events[i3 + 1].point;
13870               if (compareVectorAngles(pt3, prevPt, nextPt2) === 0)
13871                 continue;
13872               points.push(pt3);
13873               prevPt = pt3;
13874             }
13875             if (points.length === 1)
13876               return null;
13877             const pt2 = points[0];
13878             const nextPt = points[1];
13879             if (compareVectorAngles(pt2, prevPt, nextPt) === 0)
13880               points.shift();
13881             points.push(points[0]);
13882             const step = this.isExteriorRing() ? 1 : -1;
13883             const iStart = this.isExteriorRing() ? 0 : points.length - 1;
13884             const iEnd = this.isExteriorRing() ? points.length : -1;
13885             const orderedPoints = [];
13886             for (let i3 = iStart; i3 != iEnd; i3 += step)
13887               orderedPoints.push([points[i3].x, points[i3].y]);
13888             return orderedPoints;
13889           }
13890           isExteriorRing() {
13891             if (this._isExteriorRing === void 0) {
13892               const enclosing = this.enclosingRing();
13893               this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
13894             }
13895             return this._isExteriorRing;
13896           }
13897           enclosingRing() {
13898             if (this._enclosingRing === void 0) {
13899               this._enclosingRing = this._calcEnclosingRing();
13900             }
13901             return this._enclosingRing;
13902           }
13903           /* Returns the ring that encloses this one, if any */
13904           _calcEnclosingRing() {
13905             let leftMostEvt = this.events[0];
13906             for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) {
13907               const evt = this.events[i3];
13908               if (SweepEvent2.compare(leftMostEvt, evt) > 0)
13909                 leftMostEvt = evt;
13910             }
13911             let prevSeg = leftMostEvt.segment.prevInResult();
13912             let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
13913             while (true) {
13914               if (!prevSeg)
13915                 return null;
13916               if (!prevPrevSeg)
13917                 return prevSeg.ringOut;
13918               if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
13919                 if (prevPrevSeg.ringOut.enclosingRing() !== prevSeg.ringOut) {
13920                   return prevSeg.ringOut;
13921                 } else
13922                   return prevSeg.ringOut.enclosingRing();
13923               }
13924               prevSeg = prevPrevSeg.prevInResult();
13925               prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
13926             }
13927           }
13928         }
13929         class PolyOut2 {
13930           constructor(exteriorRing) {
13931             this.exteriorRing = exteriorRing;
13932             exteriorRing.poly = this;
13933             this.interiorRings = [];
13934           }
13935           addInterior(ring) {
13936             this.interiorRings.push(ring);
13937             ring.poly = this;
13938           }
13939           getGeom() {
13940             const geom = [this.exteriorRing.getGeom()];
13941             if (geom[0] === null)
13942               return null;
13943             for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
13944               const ringGeom = this.interiorRings[i3].getGeom();
13945               if (ringGeom === null)
13946                 continue;
13947               geom.push(ringGeom);
13948             }
13949             return geom;
13950           }
13951         }
13952         class MultiPolyOut2 {
13953           constructor(rings) {
13954             this.rings = rings;
13955             this.polys = this._composePolys(rings);
13956           }
13957           getGeom() {
13958             const geom = [];
13959             for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
13960               const polyGeom = this.polys[i3].getGeom();
13961               if (polyGeom === null)
13962                 continue;
13963               geom.push(polyGeom);
13964             }
13965             return geom;
13966           }
13967           _composePolys(rings) {
13968             const polys = [];
13969             for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) {
13970               const ring = rings[i3];
13971               if (ring.poly)
13972                 continue;
13973               if (ring.isExteriorRing())
13974                 polys.push(new PolyOut2(ring));
13975               else {
13976                 const enclosingRing = ring.enclosingRing();
13977                 if (!enclosingRing.poly)
13978                   polys.push(new PolyOut2(enclosingRing));
13979                 enclosingRing.poly.addInterior(ring);
13980               }
13981             }
13982             return polys;
13983           }
13984         }
13985         class SweepLine2 {
13986           constructor(queue) {
13987             let comparator = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : Segment2.compare;
13988             this.queue = queue;
13989             this.tree = new Tree(comparator);
13990             this.segments = [];
13991           }
13992           process(event) {
13993             const segment = event.segment;
13994             const newEvents = [];
13995             if (event.consumedBy) {
13996               if (event.isLeft)
13997                 this.queue.remove(event.otherSE);
13998               else
13999                 this.tree.remove(segment);
14000               return newEvents;
14001             }
14002             const node = event.isLeft ? this.tree.add(segment) : this.tree.find(segment);
14003             if (!node)
14004               throw new Error("Unable to find segment #".concat(segment.id, " ") + "[".concat(segment.leftSE.point.x, ", ").concat(segment.leftSE.point.y, "] -> ") + "[".concat(segment.rightSE.point.x, ", ").concat(segment.rightSE.point.y, "] ") + "in SweepLine tree.");
14005             let prevNode = node;
14006             let nextNode = node;
14007             let prevSeg = void 0;
14008             let nextSeg = void 0;
14009             while (prevSeg === void 0) {
14010               prevNode = this.tree.prev(prevNode);
14011               if (prevNode === null)
14012                 prevSeg = null;
14013               else if (prevNode.key.consumedBy === void 0)
14014                 prevSeg = prevNode.key;
14015             }
14016             while (nextSeg === void 0) {
14017               nextNode = this.tree.next(nextNode);
14018               if (nextNode === null)
14019                 nextSeg = null;
14020               else if (nextNode.key.consumedBy === void 0)
14021                 nextSeg = nextNode.key;
14022             }
14023             if (event.isLeft) {
14024               let prevMySplitter = null;
14025               if (prevSeg) {
14026                 const prevInter = prevSeg.getIntersection(segment);
14027                 if (prevInter !== null) {
14028                   if (!segment.isAnEndpoint(prevInter))
14029                     prevMySplitter = prevInter;
14030                   if (!prevSeg.isAnEndpoint(prevInter)) {
14031                     const newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
14032                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14033                       newEvents.push(newEventsFromSplit[i3]);
14034                     }
14035                   }
14036                 }
14037               }
14038               let nextMySplitter = null;
14039               if (nextSeg) {
14040                 const nextInter = nextSeg.getIntersection(segment);
14041                 if (nextInter !== null) {
14042                   if (!segment.isAnEndpoint(nextInter))
14043                     nextMySplitter = nextInter;
14044                   if (!nextSeg.isAnEndpoint(nextInter)) {
14045                     const newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
14046                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14047                       newEvents.push(newEventsFromSplit[i3]);
14048                     }
14049                   }
14050                 }
14051               }
14052               if (prevMySplitter !== null || nextMySplitter !== null) {
14053                 let mySplitter = null;
14054                 if (prevMySplitter === null)
14055                   mySplitter = nextMySplitter;
14056                 else if (nextMySplitter === null)
14057                   mySplitter = prevMySplitter;
14058                 else {
14059                   const cmpSplitters = SweepEvent2.comparePoints(prevMySplitter, nextMySplitter);
14060                   mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
14061                 }
14062                 this.queue.remove(segment.rightSE);
14063                 newEvents.push(segment.rightSE);
14064                 const newEventsFromSplit = segment.split(mySplitter);
14065                 for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14066                   newEvents.push(newEventsFromSplit[i3]);
14067                 }
14068               }
14069               if (newEvents.length > 0) {
14070                 this.tree.remove(segment);
14071                 newEvents.push(event);
14072               } else {
14073                 this.segments.push(segment);
14074                 segment.prev = prevSeg;
14075               }
14076             } else {
14077               if (prevSeg && nextSeg) {
14078                 const inter = prevSeg.getIntersection(nextSeg);
14079                 if (inter !== null) {
14080                   if (!prevSeg.isAnEndpoint(inter)) {
14081                     const newEventsFromSplit = this._splitSafely(prevSeg, inter);
14082                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14083                       newEvents.push(newEventsFromSplit[i3]);
14084                     }
14085                   }
14086                   if (!nextSeg.isAnEndpoint(inter)) {
14087                     const newEventsFromSplit = this._splitSafely(nextSeg, inter);
14088                     for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
14089                       newEvents.push(newEventsFromSplit[i3]);
14090                     }
14091                   }
14092                 }
14093               }
14094               this.tree.remove(segment);
14095             }
14096             return newEvents;
14097           }
14098           /* Safely split a segment that is currently in the datastructures
14099            * IE - a segment other than the one that is currently being processed. */
14100           _splitSafely(seg, pt2) {
14101             this.tree.remove(seg);
14102             const rightSE = seg.rightSE;
14103             this.queue.remove(rightSE);
14104             const newEvents = seg.split(pt2);
14105             newEvents.push(rightSE);
14106             if (seg.consumedBy === void 0)
14107               this.tree.add(seg);
14108             return newEvents;
14109           }
14110         }
14111         const POLYGON_CLIPPING_MAX_QUEUE_SIZE = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_QUEUE_SIZE || 1e6;
14112         const POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS = typeof process !== "undefined" && process.env.POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS || 1e6;
14113         class Operation2 {
14114           run(type2, geom, moreGeoms) {
14115             operation2.type = type2;
14116             rounder.reset();
14117             const multipolys = [new MultiPolyIn2(geom, true)];
14118             for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) {
14119               multipolys.push(new MultiPolyIn2(moreGeoms[i3], false));
14120             }
14121             operation2.numMultiPolys = multipolys.length;
14122             if (operation2.type === "difference") {
14123               const subject = multipolys[0];
14124               let i3 = 1;
14125               while (i3 < multipolys.length) {
14126                 if (getBboxOverlap2(multipolys[i3].bbox, subject.bbox) !== null)
14127                   i3++;
14128                 else
14129                   multipolys.splice(i3, 1);
14130               }
14131             }
14132             if (operation2.type === "intersection") {
14133               for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
14134                 const mpA = multipolys[i3];
14135                 for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) {
14136                   if (getBboxOverlap2(mpA.bbox, multipolys[j2].bbox) === null)
14137                     return [];
14138                 }
14139               }
14140             }
14141             const queue = new Tree(SweepEvent2.compare);
14142             for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
14143               const sweepEvents = multipolys[i3].getSweepEvents();
14144               for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) {
14145                 queue.insert(sweepEvents[j2]);
14146                 if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
14147                   throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big).");
14148                 }
14149               }
14150             }
14151             const sweepLine = new SweepLine2(queue);
14152             let prevQueueSize = queue.size;
14153             let node = queue.pop();
14154             while (node) {
14155               const evt = node.key;
14156               if (queue.size === prevQueueSize) {
14157                 const seg = evt.segment;
14158                 throw new Error("Unable to pop() ".concat(evt.isLeft ? "left" : "right", " SweepEvent ") + "[".concat(evt.point.x, ", ").concat(evt.point.y, "] from segment #").concat(seg.id, " ") + "[".concat(seg.leftSE.point.x, ", ").concat(seg.leftSE.point.y, "] -> ") + "[".concat(seg.rightSE.point.x, ", ").concat(seg.rightSE.point.y, "] from queue."));
14159               }
14160               if (queue.size > POLYGON_CLIPPING_MAX_QUEUE_SIZE) {
14161                 throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big).");
14162               }
14163               if (sweepLine.segments.length > POLYGON_CLIPPING_MAX_SWEEPLINE_SEGMENTS) {
14164                 throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments).");
14165               }
14166               const newEvents = sweepLine.process(evt);
14167               for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) {
14168                 const evt2 = newEvents[i3];
14169                 if (evt2.consumedBy === void 0)
14170                   queue.insert(evt2);
14171               }
14172               prevQueueSize = queue.size;
14173               node = queue.pop();
14174             }
14175             rounder.reset();
14176             const ringsOut = RingOut2.factory(sweepLine.segments);
14177             const result = new MultiPolyOut2(ringsOut);
14178             return result.getGeom();
14179           }
14180         }
14181         const operation2 = new Operation2();
14182         const union2 = function(geom) {
14183           for (var _len = arguments.length, moreGeoms = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
14184             moreGeoms[_key - 1] = arguments[_key];
14185           }
14186           return operation2.run("union", geom, moreGeoms);
14187         };
14188         const intersection2 = function(geom) {
14189           for (var _len2 = arguments.length, moreGeoms = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
14190             moreGeoms[_key2 - 1] = arguments[_key2];
14191           }
14192           return operation2.run("intersection", geom, moreGeoms);
14193         };
14194         const xor = function(geom) {
14195           for (var _len3 = arguments.length, moreGeoms = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
14196             moreGeoms[_key3 - 1] = arguments[_key3];
14197           }
14198           return operation2.run("xor", geom, moreGeoms);
14199         };
14200         const difference2 = function(subjectGeom) {
14201           for (var _len4 = arguments.length, clippingGeoms = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
14202             clippingGeoms[_key4 - 1] = arguments[_key4];
14203           }
14204           return operation2.run("difference", subjectGeom, clippingGeoms);
14205         };
14206         var index = {
14207           union: union2,
14208           intersection: intersection2,
14209           xor,
14210           difference: difference2
14211         };
14212         return index;
14213       });
14214     }
14215   });
14216
14217   // node_modules/whatwg-fetch/fetch.js
14218   var g = typeof globalThis !== "undefined" && globalThis || typeof self !== "undefined" && self || // eslint-disable-next-line no-undef
14219   typeof global !== "undefined" && global || {};
14220   var support = {
14221     searchParams: "URLSearchParams" in g,
14222     iterable: "Symbol" in g && "iterator" in Symbol,
14223     blob: "FileReader" in g && "Blob" in g && function() {
14224       try {
14225         new Blob();
14226         return true;
14227       } catch (e3) {
14228         return false;
14229       }
14230     }(),
14231     formData: "FormData" in g,
14232     arrayBuffer: "ArrayBuffer" in g
14233   };
14234   function isDataView(obj) {
14235     return obj && DataView.prototype.isPrototypeOf(obj);
14236   }
14237   if (support.arrayBuffer) {
14238     viewClasses = [
14239       "[object Int8Array]",
14240       "[object Uint8Array]",
14241       "[object Uint8ClampedArray]",
14242       "[object Int16Array]",
14243       "[object Uint16Array]",
14244       "[object Int32Array]",
14245       "[object Uint32Array]",
14246       "[object Float32Array]",
14247       "[object Float64Array]"
14248     ];
14249     isArrayBufferView = ArrayBuffer.isView || function(obj) {
14250       return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1;
14251     };
14252   }
14253   var viewClasses;
14254   var isArrayBufferView;
14255   function normalizeName(name) {
14256     if (typeof name !== "string") {
14257       name = String(name);
14258     }
14259     if (/[^a-z0-9\-#$%&'*+.^_`|~!]/i.test(name) || name === "") {
14260       throw new TypeError('Invalid character in header field name: "' + name + '"');
14261     }
14262     return name.toLowerCase();
14263   }
14264   function normalizeValue(value) {
14265     if (typeof value !== "string") {
14266       value = String(value);
14267     }
14268     return value;
14269   }
14270   function iteratorFor(items) {
14271     var iterator = {
14272       next: function() {
14273         var value = items.shift();
14274         return { done: value === void 0, value };
14275       }
14276     };
14277     if (support.iterable) {
14278       iterator[Symbol.iterator] = function() {
14279         return iterator;
14280       };
14281     }
14282     return iterator;
14283   }
14284   function Headers(headers) {
14285     this.map = {};
14286     if (headers instanceof Headers) {
14287       headers.forEach(function(value, name) {
14288         this.append(name, value);
14289       }, this);
14290     } else if (Array.isArray(headers)) {
14291       headers.forEach(function(header) {
14292         if (header.length != 2) {
14293           throw new TypeError("Headers constructor: expected name/value pair to be length 2, found" + header.length);
14294         }
14295         this.append(header[0], header[1]);
14296       }, this);
14297     } else if (headers) {
14298       Object.getOwnPropertyNames(headers).forEach(function(name) {
14299         this.append(name, headers[name]);
14300       }, this);
14301     }
14302   }
14303   Headers.prototype.append = function(name, value) {
14304     name = normalizeName(name);
14305     value = normalizeValue(value);
14306     var oldValue = this.map[name];
14307     this.map[name] = oldValue ? oldValue + ", " + value : value;
14308   };
14309   Headers.prototype["delete"] = function(name) {
14310     delete this.map[normalizeName(name)];
14311   };
14312   Headers.prototype.get = function(name) {
14313     name = normalizeName(name);
14314     return this.has(name) ? this.map[name] : null;
14315   };
14316   Headers.prototype.has = function(name) {
14317     return this.map.hasOwnProperty(normalizeName(name));
14318   };
14319   Headers.prototype.set = function(name, value) {
14320     this.map[normalizeName(name)] = normalizeValue(value);
14321   };
14322   Headers.prototype.forEach = function(callback, thisArg) {
14323     for (var name in this.map) {
14324       if (this.map.hasOwnProperty(name)) {
14325         callback.call(thisArg, this.map[name], name, this);
14326       }
14327     }
14328   };
14329   Headers.prototype.keys = function() {
14330     var items = [];
14331     this.forEach(function(value, name) {
14332       items.push(name);
14333     });
14334     return iteratorFor(items);
14335   };
14336   Headers.prototype.values = function() {
14337     var items = [];
14338     this.forEach(function(value) {
14339       items.push(value);
14340     });
14341     return iteratorFor(items);
14342   };
14343   Headers.prototype.entries = function() {
14344     var items = [];
14345     this.forEach(function(value, name) {
14346       items.push([name, value]);
14347     });
14348     return iteratorFor(items);
14349   };
14350   if (support.iterable) {
14351     Headers.prototype[Symbol.iterator] = Headers.prototype.entries;
14352   }
14353   function consumed(body) {
14354     if (body._noBody)
14355       return;
14356     if (body.bodyUsed) {
14357       return Promise.reject(new TypeError("Already read"));
14358     }
14359     body.bodyUsed = true;
14360   }
14361   function fileReaderReady(reader) {
14362     return new Promise(function(resolve, reject) {
14363       reader.onload = function() {
14364         resolve(reader.result);
14365       };
14366       reader.onerror = function() {
14367         reject(reader.error);
14368       };
14369     });
14370   }
14371   function readBlobAsArrayBuffer(blob) {
14372     var reader = new FileReader();
14373     var promise = fileReaderReady(reader);
14374     reader.readAsArrayBuffer(blob);
14375     return promise;
14376   }
14377   function readBlobAsText(blob) {
14378     var reader = new FileReader();
14379     var promise = fileReaderReady(reader);
14380     var match = /charset=([A-Za-z0-9_-]+)/.exec(blob.type);
14381     var encoding = match ? match[1] : "utf-8";
14382     reader.readAsText(blob, encoding);
14383     return promise;
14384   }
14385   function readArrayBufferAsText(buf) {
14386     var view = new Uint8Array(buf);
14387     var chars = new Array(view.length);
14388     for (var i3 = 0; i3 < view.length; i3++) {
14389       chars[i3] = String.fromCharCode(view[i3]);
14390     }
14391     return chars.join("");
14392   }
14393   function bufferClone(buf) {
14394     if (buf.slice) {
14395       return buf.slice(0);
14396     } else {
14397       var view = new Uint8Array(buf.byteLength);
14398       view.set(new Uint8Array(buf));
14399       return view.buffer;
14400     }
14401   }
14402   function Body() {
14403     this.bodyUsed = false;
14404     this._initBody = function(body) {
14405       this.bodyUsed = this.bodyUsed;
14406       this._bodyInit = body;
14407       if (!body) {
14408         this._noBody = true;
14409         this._bodyText = "";
14410       } else if (typeof body === "string") {
14411         this._bodyText = body;
14412       } else if (support.blob && Blob.prototype.isPrototypeOf(body)) {
14413         this._bodyBlob = body;
14414       } else if (support.formData && FormData.prototype.isPrototypeOf(body)) {
14415         this._bodyFormData = body;
14416       } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
14417         this._bodyText = body.toString();
14418       } else if (support.arrayBuffer && support.blob && isDataView(body)) {
14419         this._bodyArrayBuffer = bufferClone(body.buffer);
14420         this._bodyInit = new Blob([this._bodyArrayBuffer]);
14421       } else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) {
14422         this._bodyArrayBuffer = bufferClone(body);
14423       } else {
14424         this._bodyText = body = Object.prototype.toString.call(body);
14425       }
14426       if (!this.headers.get("content-type")) {
14427         if (typeof body === "string") {
14428           this.headers.set("content-type", "text/plain;charset=UTF-8");
14429         } else if (this._bodyBlob && this._bodyBlob.type) {
14430           this.headers.set("content-type", this._bodyBlob.type);
14431         } else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) {
14432           this.headers.set("content-type", "application/x-www-form-urlencoded;charset=UTF-8");
14433         }
14434       }
14435     };
14436     if (support.blob) {
14437       this.blob = function() {
14438         var rejected = consumed(this);
14439         if (rejected) {
14440           return rejected;
14441         }
14442         if (this._bodyBlob) {
14443           return Promise.resolve(this._bodyBlob);
14444         } else if (this._bodyArrayBuffer) {
14445           return Promise.resolve(new Blob([this._bodyArrayBuffer]));
14446         } else if (this._bodyFormData) {
14447           throw new Error("could not read FormData body as blob");
14448         } else {
14449           return Promise.resolve(new Blob([this._bodyText]));
14450         }
14451       };
14452     }
14453     this.arrayBuffer = function() {
14454       if (this._bodyArrayBuffer) {
14455         var isConsumed = consumed(this);
14456         if (isConsumed) {
14457           return isConsumed;
14458         } else if (ArrayBuffer.isView(this._bodyArrayBuffer)) {
14459           return Promise.resolve(
14460             this._bodyArrayBuffer.buffer.slice(
14461               this._bodyArrayBuffer.byteOffset,
14462               this._bodyArrayBuffer.byteOffset + this._bodyArrayBuffer.byteLength
14463             )
14464           );
14465         } else {
14466           return Promise.resolve(this._bodyArrayBuffer);
14467         }
14468       } else if (support.blob) {
14469         return this.blob().then(readBlobAsArrayBuffer);
14470       } else {
14471         throw new Error("could not read as ArrayBuffer");
14472       }
14473     };
14474     this.text = function() {
14475       var rejected = consumed(this);
14476       if (rejected) {
14477         return rejected;
14478       }
14479       if (this._bodyBlob) {
14480         return readBlobAsText(this._bodyBlob);
14481       } else if (this._bodyArrayBuffer) {
14482         return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer));
14483       } else if (this._bodyFormData) {
14484         throw new Error("could not read FormData body as text");
14485       } else {
14486         return Promise.resolve(this._bodyText);
14487       }
14488     };
14489     if (support.formData) {
14490       this.formData = function() {
14491         return this.text().then(decode);
14492       };
14493     }
14494     this.json = function() {
14495       return this.text().then(JSON.parse);
14496     };
14497     return this;
14498   }
14499   var methods = ["CONNECT", "DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT", "TRACE"];
14500   function normalizeMethod(method) {
14501     var upcased = method.toUpperCase();
14502     return methods.indexOf(upcased) > -1 ? upcased : method;
14503   }
14504   function Request(input, options2) {
14505     if (!(this instanceof Request)) {
14506       throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
14507     }
14508     options2 = options2 || {};
14509     var body = options2.body;
14510     if (input instanceof Request) {
14511       if (input.bodyUsed) {
14512         throw new TypeError("Already read");
14513       }
14514       this.url = input.url;
14515       this.credentials = input.credentials;
14516       if (!options2.headers) {
14517         this.headers = new Headers(input.headers);
14518       }
14519       this.method = input.method;
14520       this.mode = input.mode;
14521       this.signal = input.signal;
14522       if (!body && input._bodyInit != null) {
14523         body = input._bodyInit;
14524         input.bodyUsed = true;
14525       }
14526     } else {
14527       this.url = String(input);
14528     }
14529     this.credentials = options2.credentials || this.credentials || "same-origin";
14530     if (options2.headers || !this.headers) {
14531       this.headers = new Headers(options2.headers);
14532     }
14533     this.method = normalizeMethod(options2.method || this.method || "GET");
14534     this.mode = options2.mode || this.mode || null;
14535     this.signal = options2.signal || this.signal || function() {
14536       if ("AbortController" in g) {
14537         var ctrl = new AbortController();
14538         return ctrl.signal;
14539       }
14540     }();
14541     this.referrer = null;
14542     if ((this.method === "GET" || this.method === "HEAD") && body) {
14543       throw new TypeError("Body not allowed for GET or HEAD requests");
14544     }
14545     this._initBody(body);
14546     if (this.method === "GET" || this.method === "HEAD") {
14547       if (options2.cache === "no-store" || options2.cache === "no-cache") {
14548         var reParamSearch = /([?&])_=[^&]*/;
14549         if (reParamSearch.test(this.url)) {
14550           this.url = this.url.replace(reParamSearch, "$1_=" + (/* @__PURE__ */ new Date()).getTime());
14551         } else {
14552           var reQueryString = /\?/;
14553           this.url += (reQueryString.test(this.url) ? "&" : "?") + "_=" + (/* @__PURE__ */ new Date()).getTime();
14554         }
14555       }
14556     }
14557   }
14558   Request.prototype.clone = function() {
14559     return new Request(this, { body: this._bodyInit });
14560   };
14561   function decode(body) {
14562     var form = new FormData();
14563     body.trim().split("&").forEach(function(bytes) {
14564       if (bytes) {
14565         var split = bytes.split("=");
14566         var name = split.shift().replace(/\+/g, " ");
14567         var value = split.join("=").replace(/\+/g, " ");
14568         form.append(decodeURIComponent(name), decodeURIComponent(value));
14569       }
14570     });
14571     return form;
14572   }
14573   function parseHeaders(rawHeaders) {
14574     var headers = new Headers();
14575     var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, " ");
14576     preProcessedHeaders.split("\r").map(function(header) {
14577       return header.indexOf("\n") === 0 ? header.substr(1, header.length) : header;
14578     }).forEach(function(line) {
14579       var parts = line.split(":");
14580       var key = parts.shift().trim();
14581       if (key) {
14582         var value = parts.join(":").trim();
14583         try {
14584           headers.append(key, value);
14585         } catch (error) {
14586           console.warn("Response " + error.message);
14587         }
14588       }
14589     });
14590     return headers;
14591   }
14592   Body.call(Request.prototype);
14593   function Response(bodyInit, options2) {
14594     if (!(this instanceof Response)) {
14595       throw new TypeError('Please use the "new" operator, this DOM object constructor cannot be called as a function.');
14596     }
14597     if (!options2) {
14598       options2 = {};
14599     }
14600     this.type = "default";
14601     this.status = options2.status === void 0 ? 200 : options2.status;
14602     if (this.status < 200 || this.status > 599) {
14603       throw new RangeError("Failed to construct 'Response': The status provided (0) is outside the range [200, 599].");
14604     }
14605     this.ok = this.status >= 200 && this.status < 300;
14606     this.statusText = options2.statusText === void 0 ? "" : "" + options2.statusText;
14607     this.headers = new Headers(options2.headers);
14608     this.url = options2.url || "";
14609     this._initBody(bodyInit);
14610   }
14611   Body.call(Response.prototype);
14612   Response.prototype.clone = function() {
14613     return new Response(this._bodyInit, {
14614       status: this.status,
14615       statusText: this.statusText,
14616       headers: new Headers(this.headers),
14617       url: this.url
14618     });
14619   };
14620   Response.error = function() {
14621     var response = new Response(null, { status: 200, statusText: "" });
14622     response.ok = false;
14623     response.status = 0;
14624     response.type = "error";
14625     return response;
14626   };
14627   var redirectStatuses = [301, 302, 303, 307, 308];
14628   Response.redirect = function(url, status) {
14629     if (redirectStatuses.indexOf(status) === -1) {
14630       throw new RangeError("Invalid status code");
14631     }
14632     return new Response(null, { status, headers: { location: url } });
14633   };
14634   var DOMException2 = g.DOMException;
14635   try {
14636     new DOMException2();
14637   } catch (err) {
14638     DOMException2 = function(message, name) {
14639       this.message = message;
14640       this.name = name;
14641       var error = Error(message);
14642       this.stack = error.stack;
14643     };
14644     DOMException2.prototype = Object.create(Error.prototype);
14645     DOMException2.prototype.constructor = DOMException2;
14646   }
14647   function fetch2(input, init2) {
14648     return new Promise(function(resolve, reject) {
14649       var request3 = new Request(input, init2);
14650       if (request3.signal && request3.signal.aborted) {
14651         return reject(new DOMException2("Aborted", "AbortError"));
14652       }
14653       var xhr = new XMLHttpRequest();
14654       function abortXhr() {
14655         xhr.abort();
14656       }
14657       xhr.onload = function() {
14658         var options2 = {
14659           statusText: xhr.statusText,
14660           headers: parseHeaders(xhr.getAllResponseHeaders() || "")
14661         };
14662         if (request3.url.indexOf("file://") === 0 && (xhr.status < 200 || xhr.status > 599)) {
14663           options2.status = 200;
14664         } else {
14665           options2.status = xhr.status;
14666         }
14667         options2.url = "responseURL" in xhr ? xhr.responseURL : options2.headers.get("X-Request-URL");
14668         var body = "response" in xhr ? xhr.response : xhr.responseText;
14669         setTimeout(function() {
14670           resolve(new Response(body, options2));
14671         }, 0);
14672       };
14673       xhr.onerror = function() {
14674         setTimeout(function() {
14675           reject(new TypeError("Network request failed"));
14676         }, 0);
14677       };
14678       xhr.ontimeout = function() {
14679         setTimeout(function() {
14680           reject(new TypeError("Network request timed out"));
14681         }, 0);
14682       };
14683       xhr.onabort = function() {
14684         setTimeout(function() {
14685           reject(new DOMException2("Aborted", "AbortError"));
14686         }, 0);
14687       };
14688       function fixUrl(url) {
14689         try {
14690           return url === "" && g.location.href ? g.location.href : url;
14691         } catch (e3) {
14692           return url;
14693         }
14694       }
14695       xhr.open(request3.method, fixUrl(request3.url), true);
14696       if (request3.credentials === "include") {
14697         xhr.withCredentials = true;
14698       } else if (request3.credentials === "omit") {
14699         xhr.withCredentials = false;
14700       }
14701       if ("responseType" in xhr) {
14702         if (support.blob) {
14703           xhr.responseType = "blob";
14704         } else if (support.arrayBuffer) {
14705           xhr.responseType = "arraybuffer";
14706         }
14707       }
14708       if (init2 && typeof init2.headers === "object" && !(init2.headers instanceof Headers || g.Headers && init2.headers instanceof g.Headers)) {
14709         var names = [];
14710         Object.getOwnPropertyNames(init2.headers).forEach(function(name) {
14711           names.push(normalizeName(name));
14712           xhr.setRequestHeader(name, normalizeValue(init2.headers[name]));
14713         });
14714         request3.headers.forEach(function(value, name) {
14715           if (names.indexOf(name) === -1) {
14716             xhr.setRequestHeader(name, value);
14717           }
14718         });
14719       } else {
14720         request3.headers.forEach(function(value, name) {
14721           xhr.setRequestHeader(name, value);
14722         });
14723       }
14724       if (request3.signal) {
14725         request3.signal.addEventListener("abort", abortXhr);
14726         xhr.onreadystatechange = function() {
14727           if (xhr.readyState === 4) {
14728             request3.signal.removeEventListener("abort", abortXhr);
14729           }
14730         };
14731       }
14732       xhr.send(typeof request3._bodyInit === "undefined" ? null : request3._bodyInit);
14733     });
14734   }
14735   fetch2.polyfill = true;
14736   if (!g.fetch) {
14737     g.fetch = fetch2;
14738     g.Headers = Headers;
14739     g.Request = Request;
14740     g.Response = Response;
14741   }
14742
14743   // node_modules/abortcontroller-polyfill/dist/polyfill-patch-fetch.js
14744   (function(factory) {
14745     typeof define === "function" && define.amd ? define(factory) : factory();
14746   })(function() {
14747     "use strict";
14748     function _classCallCheck(instance, Constructor) {
14749       if (!(instance instanceof Constructor)) {
14750         throw new TypeError("Cannot call a class as a function");
14751       }
14752     }
14753     function _defineProperties(target, props) {
14754       for (var i3 = 0; i3 < props.length; i3++) {
14755         var descriptor = props[i3];
14756         descriptor.enumerable = descriptor.enumerable || false;
14757         descriptor.configurable = true;
14758         if ("value" in descriptor)
14759           descriptor.writable = true;
14760         Object.defineProperty(target, descriptor.key, descriptor);
14761       }
14762     }
14763     function _createClass(Constructor, protoProps, staticProps) {
14764       if (protoProps)
14765         _defineProperties(Constructor.prototype, protoProps);
14766       if (staticProps)
14767         _defineProperties(Constructor, staticProps);
14768       Object.defineProperty(Constructor, "prototype", {
14769         writable: false
14770       });
14771       return Constructor;
14772     }
14773     function _inherits(subClass, superClass) {
14774       if (typeof superClass !== "function" && superClass !== null) {
14775         throw new TypeError("Super expression must either be null or a function");
14776       }
14777       subClass.prototype = Object.create(superClass && superClass.prototype, {
14778         constructor: {
14779           value: subClass,
14780           writable: true,
14781           configurable: true
14782         }
14783       });
14784       Object.defineProperty(subClass, "prototype", {
14785         writable: false
14786       });
14787       if (superClass)
14788         _setPrototypeOf(subClass, superClass);
14789     }
14790     function _getPrototypeOf(o2) {
14791       _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf2(o3) {
14792         return o3.__proto__ || Object.getPrototypeOf(o3);
14793       };
14794       return _getPrototypeOf(o2);
14795     }
14796     function _setPrototypeOf(o2, p2) {
14797       _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf2(o3, p3) {
14798         o3.__proto__ = p3;
14799         return o3;
14800       };
14801       return _setPrototypeOf(o2, p2);
14802     }
14803     function _isNativeReflectConstruct() {
14804       if (typeof Reflect === "undefined" || !Reflect.construct)
14805         return false;
14806       if (Reflect.construct.sham)
14807         return false;
14808       if (typeof Proxy === "function")
14809         return true;
14810       try {
14811         Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
14812         }));
14813         return true;
14814       } catch (e3) {
14815         return false;
14816       }
14817     }
14818     function _assertThisInitialized(self2) {
14819       if (self2 === void 0) {
14820         throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
14821       }
14822       return self2;
14823     }
14824     function _possibleConstructorReturn(self2, call) {
14825       if (call && (typeof call === "object" || typeof call === "function")) {
14826         return call;
14827       } else if (call !== void 0) {
14828         throw new TypeError("Derived constructors may only return object or undefined");
14829       }
14830       return _assertThisInitialized(self2);
14831     }
14832     function _createSuper(Derived) {
14833       var hasNativeReflectConstruct = _isNativeReflectConstruct();
14834       return function _createSuperInternal() {
14835         var Super = _getPrototypeOf(Derived), result;
14836         if (hasNativeReflectConstruct) {
14837           var NewTarget = _getPrototypeOf(this).constructor;
14838           result = Reflect.construct(Super, arguments, NewTarget);
14839         } else {
14840           result = Super.apply(this, arguments);
14841         }
14842         return _possibleConstructorReturn(this, result);
14843       };
14844     }
14845     function _superPropBase(object, property) {
14846       while (!Object.prototype.hasOwnProperty.call(object, property)) {
14847         object = _getPrototypeOf(object);
14848         if (object === null)
14849           break;
14850       }
14851       return object;
14852     }
14853     function _get() {
14854       if (typeof Reflect !== "undefined" && Reflect.get) {
14855         _get = Reflect.get.bind();
14856       } else {
14857         _get = function _get2(target, property, receiver) {
14858           var base = _superPropBase(target, property);
14859           if (!base)
14860             return;
14861           var desc = Object.getOwnPropertyDescriptor(base, property);
14862           if (desc.get) {
14863             return desc.get.call(arguments.length < 3 ? target : receiver);
14864           }
14865           return desc.value;
14866         };
14867       }
14868       return _get.apply(this, arguments);
14869     }
14870     var Emitter = /* @__PURE__ */ function() {
14871       function Emitter2() {
14872         _classCallCheck(this, Emitter2);
14873         Object.defineProperty(this, "listeners", {
14874           value: {},
14875           writable: true,
14876           configurable: true
14877         });
14878       }
14879       _createClass(Emitter2, [{
14880         key: "addEventListener",
14881         value: function addEventListener(type2, callback, options2) {
14882           if (!(type2 in this.listeners)) {
14883             this.listeners[type2] = [];
14884           }
14885           this.listeners[type2].push({
14886             callback,
14887             options: options2
14888           });
14889         }
14890       }, {
14891         key: "removeEventListener",
14892         value: function removeEventListener(type2, callback) {
14893           if (!(type2 in this.listeners)) {
14894             return;
14895           }
14896           var stack = this.listeners[type2];
14897           for (var i3 = 0, l2 = stack.length; i3 < l2; i3++) {
14898             if (stack[i3].callback === callback) {
14899               stack.splice(i3, 1);
14900               return;
14901             }
14902           }
14903         }
14904       }, {
14905         key: "dispatchEvent",
14906         value: function dispatchEvent2(event) {
14907           if (!(event.type in this.listeners)) {
14908             return;
14909           }
14910           var stack = this.listeners[event.type];
14911           var stackToCall = stack.slice();
14912           for (var i3 = 0, l2 = stackToCall.length; i3 < l2; i3++) {
14913             var listener = stackToCall[i3];
14914             try {
14915               listener.callback.call(this, event);
14916             } catch (e3) {
14917               Promise.resolve().then(function() {
14918                 throw e3;
14919               });
14920             }
14921             if (listener.options && listener.options.once) {
14922               this.removeEventListener(event.type, listener.callback);
14923             }
14924           }
14925           return !event.defaultPrevented;
14926         }
14927       }]);
14928       return Emitter2;
14929     }();
14930     var AbortSignal = /* @__PURE__ */ function(_Emitter) {
14931       _inherits(AbortSignal2, _Emitter);
14932       var _super = _createSuper(AbortSignal2);
14933       function AbortSignal2() {
14934         var _this;
14935         _classCallCheck(this, AbortSignal2);
14936         _this = _super.call(this);
14937         if (!_this.listeners) {
14938           Emitter.call(_assertThisInitialized(_this));
14939         }
14940         Object.defineProperty(_assertThisInitialized(_this), "aborted", {
14941           value: false,
14942           writable: true,
14943           configurable: true
14944         });
14945         Object.defineProperty(_assertThisInitialized(_this), "onabort", {
14946           value: null,
14947           writable: true,
14948           configurable: true
14949         });
14950         Object.defineProperty(_assertThisInitialized(_this), "reason", {
14951           value: void 0,
14952           writable: true,
14953           configurable: true
14954         });
14955         return _this;
14956       }
14957       _createClass(AbortSignal2, [{
14958         key: "toString",
14959         value: function toString2() {
14960           return "[object AbortSignal]";
14961         }
14962       }, {
14963         key: "dispatchEvent",
14964         value: function dispatchEvent2(event) {
14965           if (event.type === "abort") {
14966             this.aborted = true;
14967             if (typeof this.onabort === "function") {
14968               this.onabort.call(this, event);
14969             }
14970           }
14971           _get(_getPrototypeOf(AbortSignal2.prototype), "dispatchEvent", this).call(this, event);
14972         }
14973       }]);
14974       return AbortSignal2;
14975     }(Emitter);
14976     var AbortController2 = /* @__PURE__ */ function() {
14977       function AbortController3() {
14978         _classCallCheck(this, AbortController3);
14979         Object.defineProperty(this, "signal", {
14980           value: new AbortSignal(),
14981           writable: true,
14982           configurable: true
14983         });
14984       }
14985       _createClass(AbortController3, [{
14986         key: "abort",
14987         value: function abort(reason) {
14988           var event;
14989           try {
14990             event = new Event("abort");
14991           } catch (e3) {
14992             if (typeof document !== "undefined") {
14993               if (!document.createEvent) {
14994                 event = document.createEventObject();
14995                 event.type = "abort";
14996               } else {
14997                 event = document.createEvent("Event");
14998                 event.initEvent("abort", false, false);
14999               }
15000             } else {
15001               event = {
15002                 type: "abort",
15003                 bubbles: false,
15004                 cancelable: false
15005               };
15006             }
15007           }
15008           var signalReason = reason;
15009           if (signalReason === void 0) {
15010             if (typeof document === "undefined") {
15011               signalReason = new Error("This operation was aborted");
15012               signalReason.name = "AbortError";
15013             } else {
15014               try {
15015                 signalReason = new DOMException("signal is aborted without reason");
15016               } catch (err) {
15017                 signalReason = new Error("This operation was aborted");
15018                 signalReason.name = "AbortError";
15019               }
15020             }
15021           }
15022           this.signal.reason = signalReason;
15023           this.signal.dispatchEvent(event);
15024         }
15025       }, {
15026         key: "toString",
15027         value: function toString2() {
15028           return "[object AbortController]";
15029         }
15030       }]);
15031       return AbortController3;
15032     }();
15033     if (typeof Symbol !== "undefined" && Symbol.toStringTag) {
15034       AbortController2.prototype[Symbol.toStringTag] = "AbortController";
15035       AbortSignal.prototype[Symbol.toStringTag] = "AbortSignal";
15036     }
15037     function polyfillNeeded(self2) {
15038       if (self2.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
15039         console.log("__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL=true is set, will force install polyfill");
15040         return true;
15041       }
15042       return typeof self2.Request === "function" && !self2.Request.prototype.hasOwnProperty("signal") || !self2.AbortController;
15043     }
15044     function abortableFetchDecorator(patchTargets) {
15045       if ("function" === typeof patchTargets) {
15046         patchTargets = {
15047           fetch: patchTargets
15048         };
15049       }
15050       var _patchTargets = patchTargets, fetch3 = _patchTargets.fetch, _patchTargets$Request = _patchTargets.Request, NativeRequest = _patchTargets$Request === void 0 ? fetch3.Request : _patchTargets$Request, NativeAbortController = _patchTargets.AbortController, _patchTargets$__FORCE = _patchTargets.__FORCE_INSTALL_ABORTCONTROLLER_POLYFILL, __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL = _patchTargets$__FORCE === void 0 ? false : _patchTargets$__FORCE;
15051       if (!polyfillNeeded({
15052         fetch: fetch3,
15053         Request: NativeRequest,
15054         AbortController: NativeAbortController,
15055         __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL
15056       })) {
15057         return {
15058           fetch: fetch3,
15059           Request: Request2
15060         };
15061       }
15062       var Request2 = NativeRequest;
15063       if (Request2 && !Request2.prototype.hasOwnProperty("signal") || __FORCE_INSTALL_ABORTCONTROLLER_POLYFILL) {
15064         Request2 = function Request3(input, init2) {
15065           var signal;
15066           if (init2 && init2.signal) {
15067             signal = init2.signal;
15068             delete init2.signal;
15069           }
15070           var request3 = new NativeRequest(input, init2);
15071           if (signal) {
15072             Object.defineProperty(request3, "signal", {
15073               writable: false,
15074               enumerable: false,
15075               configurable: true,
15076               value: signal
15077             });
15078           }
15079           return request3;
15080         };
15081         Request2.prototype = NativeRequest.prototype;
15082       }
15083       var realFetch = fetch3;
15084       var abortableFetch = function abortableFetch2(input, init2) {
15085         var signal = Request2 && Request2.prototype.isPrototypeOf(input) ? input.signal : init2 ? init2.signal : void 0;
15086         if (signal) {
15087           var abortError;
15088           try {
15089             abortError = new DOMException("Aborted", "AbortError");
15090           } catch (err) {
15091             abortError = new Error("Aborted");
15092             abortError.name = "AbortError";
15093           }
15094           if (signal.aborted) {
15095             return Promise.reject(abortError);
15096           }
15097           var cancellation = new Promise(function(_2, reject) {
15098             signal.addEventListener("abort", function() {
15099               return reject(abortError);
15100             }, {
15101               once: true
15102             });
15103           });
15104           if (init2 && init2.signal) {
15105             delete init2.signal;
15106           }
15107           return Promise.race([cancellation, realFetch(input, init2)]);
15108         }
15109         return realFetch(input, init2);
15110       };
15111       return {
15112         fetch: abortableFetch,
15113         Request: Request2
15114       };
15115     }
15116     (function(self2) {
15117       if (!polyfillNeeded(self2)) {
15118         return;
15119       }
15120       if (!self2.fetch) {
15121         console.warn("fetch() is not available, cannot install abortcontroller-polyfill");
15122         return;
15123       }
15124       var _abortableFetch = abortableFetchDecorator(self2), fetch3 = _abortableFetch.fetch, Request2 = _abortableFetch.Request;
15125       self2.fetch = fetch3;
15126       self2.Request = Request2;
15127       Object.defineProperty(self2, "AbortController", {
15128         writable: true,
15129         enumerable: false,
15130         configurable: true,
15131         value: AbortController2
15132       });
15133       Object.defineProperty(self2, "AbortSignal", {
15134         writable: true,
15135         enumerable: false,
15136         configurable: true,
15137         value: AbortSignal
15138       });
15139     })(typeof self !== "undefined" ? self : global);
15140   });
15141
15142   // modules/index.js
15143   var modules_exports = {};
15144   __export(modules_exports, {
15145     LocationManager: () => LocationManager,
15146     QAItem: () => QAItem,
15147     actionAddEntity: () => actionAddEntity,
15148     actionAddMember: () => actionAddMember,
15149     actionAddMidpoint: () => actionAddMidpoint,
15150     actionAddVertex: () => actionAddVertex,
15151     actionChangeMember: () => actionChangeMember,
15152     actionChangePreset: () => actionChangePreset,
15153     actionChangeTags: () => actionChangeTags,
15154     actionCircularize: () => actionCircularize,
15155     actionConnect: () => actionConnect,
15156     actionCopyEntities: () => actionCopyEntities,
15157     actionDeleteMember: () => actionDeleteMember,
15158     actionDeleteMultiple: () => actionDeleteMultiple,
15159     actionDeleteNode: () => actionDeleteNode,
15160     actionDeleteRelation: () => actionDeleteRelation,
15161     actionDeleteWay: () => actionDeleteWay,
15162     actionDiscardTags: () => actionDiscardTags,
15163     actionDisconnect: () => actionDisconnect,
15164     actionExtract: () => actionExtract,
15165     actionJoin: () => actionJoin,
15166     actionMerge: () => actionMerge,
15167     actionMergeNodes: () => actionMergeNodes,
15168     actionMergePolygon: () => actionMergePolygon,
15169     actionMergeRemoteChanges: () => actionMergeRemoteChanges,
15170     actionMove: () => actionMove,
15171     actionMoveMember: () => actionMoveMember,
15172     actionMoveNode: () => actionMoveNode,
15173     actionNoop: () => actionNoop,
15174     actionOrthogonalize: () => actionOrthogonalize,
15175     actionReflect: () => actionReflect,
15176     actionRestrictTurn: () => actionRestrictTurn,
15177     actionReverse: () => actionReverse,
15178     actionRevert: () => actionRevert,
15179     actionRotate: () => actionRotate,
15180     actionScale: () => actionScale,
15181     actionSplit: () => actionSplit,
15182     actionStraightenNodes: () => actionStraightenNodes,
15183     actionStraightenWay: () => actionStraightenWay,
15184     actionUnrestrictTurn: () => actionUnrestrictTurn,
15185     actionUpgradeTags: () => actionUpgradeTags,
15186     behaviorAddWay: () => behaviorAddWay,
15187     behaviorBreathe: () => behaviorBreathe,
15188     behaviorDrag: () => behaviorDrag,
15189     behaviorDraw: () => behaviorDraw,
15190     behaviorDrawWay: () => behaviorDrawWay,
15191     behaviorEdit: () => behaviorEdit,
15192     behaviorHash: () => behaviorHash,
15193     behaviorHover: () => behaviorHover,
15194     behaviorLasso: () => behaviorLasso,
15195     behaviorOperation: () => behaviorOperation,
15196     behaviorPaste: () => behaviorPaste,
15197     behaviorSelect: () => behaviorSelect,
15198     coreContext: () => coreContext,
15199     coreDifference: () => coreDifference,
15200     coreFileFetcher: () => coreFileFetcher,
15201     coreGraph: () => coreGraph,
15202     coreHistory: () => coreHistory,
15203     coreLocalizer: () => coreLocalizer,
15204     coreTree: () => coreTree,
15205     coreUploader: () => coreUploader,
15206     coreValidator: () => coreValidator,
15207     d3: () => d3,
15208     debug: () => debug,
15209     dmsCoordinatePair: () => dmsCoordinatePair,
15210     dmsMatcher: () => dmsMatcher,
15211     fileFetcher: () => _mainFileFetcher,
15212     geoAngle: () => geoAngle,
15213     geoChooseEdge: () => geoChooseEdge,
15214     geoEdgeEqual: () => geoEdgeEqual,
15215     geoExtent: () => geoExtent,
15216     geoGetSmallestSurroundingRectangle: () => geoGetSmallestSurroundingRectangle,
15217     geoHasLineIntersections: () => geoHasLineIntersections,
15218     geoHasSelfIntersections: () => geoHasSelfIntersections,
15219     geoLatToMeters: () => geoLatToMeters,
15220     geoLineIntersection: () => geoLineIntersection,
15221     geoLonToMeters: () => geoLonToMeters,
15222     geoMetersToLat: () => geoMetersToLat,
15223     geoMetersToLon: () => geoMetersToLon,
15224     geoMetersToOffset: () => geoMetersToOffset,
15225     geoOffsetToMeters: () => geoOffsetToMeters,
15226     geoOrthoCalcScore: () => geoOrthoCalcScore,
15227     geoOrthoCanOrthogonalize: () => geoOrthoCanOrthogonalize,
15228     geoOrthoMaxOffsetAngle: () => geoOrthoMaxOffsetAngle,
15229     geoOrthoNormalizedDotProduct: () => geoOrthoNormalizedDotProduct,
15230     geoPathHasIntersections: () => geoPathHasIntersections,
15231     geoPathIntersections: () => geoPathIntersections,
15232     geoPathLength: () => geoPathLength,
15233     geoPointInPolygon: () => geoPointInPolygon,
15234     geoPolygonContainsPolygon: () => geoPolygonContainsPolygon,
15235     geoPolygonIntersectsPolygon: () => geoPolygonIntersectsPolygon,
15236     geoRawMercator: () => geoRawMercator,
15237     geoRotate: () => geoRotate,
15238     geoScaleToZoom: () => geoScaleToZoom,
15239     geoSphericalClosestNode: () => geoSphericalClosestNode,
15240     geoSphericalDistance: () => geoSphericalDistance,
15241     geoVecAdd: () => geoVecAdd,
15242     geoVecAngle: () => geoVecAngle,
15243     geoVecCross: () => geoVecCross,
15244     geoVecDot: () => geoVecDot,
15245     geoVecEqual: () => geoVecEqual,
15246     geoVecFloor: () => geoVecFloor,
15247     geoVecInterp: () => geoVecInterp,
15248     geoVecLength: () => geoVecLength,
15249     geoVecLengthSquare: () => geoVecLengthSquare,
15250     geoVecNormalize: () => geoVecNormalize,
15251     geoVecNormalizedDot: () => geoVecNormalizedDot,
15252     geoVecProject: () => geoVecProject,
15253     geoVecScale: () => geoVecScale,
15254     geoVecSubtract: () => geoVecSubtract,
15255     geoViewportEdge: () => geoViewportEdge,
15256     geoZoomToScale: () => geoZoomToScale,
15257     likelyRawNumberFormat: () => likelyRawNumberFormat,
15258     localizer: () => _mainLocalizer,
15259     locationManager: () => _sharedLocationManager,
15260     modeAddArea: () => modeAddArea,
15261     modeAddLine: () => modeAddLine,
15262     modeAddNote: () => modeAddNote,
15263     modeAddPoint: () => modeAddPoint,
15264     modeBrowse: () => modeBrowse,
15265     modeDragNode: () => modeDragNode,
15266     modeDragNote: () => modeDragNote,
15267     modeDrawArea: () => modeDrawArea,
15268     modeDrawLine: () => modeDrawLine,
15269     modeMove: () => modeMove,
15270     modeRotate: () => modeRotate,
15271     modeSave: () => modeSave,
15272     modeSelect: () => modeSelect,
15273     modeSelectData: () => modeSelectData,
15274     modeSelectError: () => modeSelectError,
15275     modeSelectNote: () => modeSelectNote,
15276     operationCircularize: () => operationCircularize,
15277     operationContinue: () => operationContinue,
15278     operationCopy: () => operationCopy,
15279     operationDelete: () => operationDelete,
15280     operationDisconnect: () => operationDisconnect,
15281     operationDowngrade: () => operationDowngrade,
15282     operationExtract: () => operationExtract,
15283     operationMerge: () => operationMerge,
15284     operationMove: () => operationMove,
15285     operationOrthogonalize: () => operationOrthogonalize,
15286     operationPaste: () => operationPaste,
15287     operationReflectLong: () => operationReflectLong,
15288     operationReflectShort: () => operationReflectShort,
15289     operationReverse: () => operationReverse,
15290     operationRotate: () => operationRotate,
15291     operationSplit: () => operationSplit,
15292     operationStraighten: () => operationStraighten,
15293     osmAreaKeys: () => osmAreaKeys,
15294     osmChangeset: () => osmChangeset,
15295     osmEntity: () => osmEntity,
15296     osmFlowingWaterwayTagValues: () => osmFlowingWaterwayTagValues,
15297     osmInferRestriction: () => osmInferRestriction,
15298     osmIntersection: () => osmIntersection,
15299     osmIsInterestingTag: () => osmIsInterestingTag,
15300     osmIsOldMultipolygonOuterMember: () => osmIsOldMultipolygonOuterMember,
15301     osmJoinWays: () => osmJoinWays,
15302     osmLanes: () => osmLanes,
15303     osmLifecyclePrefixes: () => osmLifecyclePrefixes,
15304     osmNode: () => osmNode,
15305     osmNodeGeometriesForTags: () => osmNodeGeometriesForTags,
15306     osmNote: () => osmNote,
15307     osmOldMultipolygonOuterMember: () => osmOldMultipolygonOuterMember,
15308     osmOldMultipolygonOuterMemberOfRelation: () => osmOldMultipolygonOuterMemberOfRelation,
15309     osmOneWayTags: () => osmOneWayTags,
15310     osmPavedTags: () => osmPavedTags,
15311     osmPointTags: () => osmPointTags,
15312     osmRailwayTrackTagValues: () => osmRailwayTrackTagValues,
15313     osmRelation: () => osmRelation,
15314     osmRemoveLifecyclePrefix: () => osmRemoveLifecyclePrefix,
15315     osmRoutableHighwayTagValues: () => osmRoutableHighwayTagValues,
15316     osmSetAreaKeys: () => osmSetAreaKeys,
15317     osmSetPointTags: () => osmSetPointTags,
15318     osmSetVertexTags: () => osmSetVertexTags,
15319     osmTagSuggestingArea: () => osmTagSuggestingArea,
15320     osmTurn: () => osmTurn,
15321     osmVertexTags: () => osmVertexTags,
15322     osmWay: () => osmWay,
15323     prefs: () => corePreferences,
15324     presetCategory: () => presetCategory,
15325     presetCollection: () => presetCollection,
15326     presetField: () => presetField,
15327     presetIndex: () => presetIndex,
15328     presetManager: () => _mainPresetIndex,
15329     presetPreset: () => presetPreset,
15330     rendererBackground: () => rendererBackground,
15331     rendererBackgroundSource: () => rendererBackgroundSource,
15332     rendererFeatures: () => rendererFeatures,
15333     rendererMap: () => rendererMap,
15334     rendererPhotos: () => rendererPhotos,
15335     rendererTileLayer: () => rendererTileLayer,
15336     serviceImproveOSM: () => improveOSM_default,
15337     serviceKartaview: () => kartaview_default,
15338     serviceKeepRight: () => keepRight_default,
15339     serviceMapRules: () => maprules_default,
15340     serviceMapilio: () => mapilio_default,
15341     serviceMapillary: () => mapillary_default,
15342     serviceNominatim: () => nominatim_default,
15343     serviceNsi: () => nsi_default,
15344     serviceOsm: () => osm_default,
15345     serviceOsmWikibase: () => osm_wikibase_default,
15346     serviceOsmose: () => osmose_default,
15347     serviceStreetside: () => streetside_default,
15348     serviceTaginfo: () => taginfo_default,
15349     serviceVectorTile: () => vector_tile_default,
15350     serviceVegbilder: () => vegbilder_default,
15351     serviceWikidata: () => wikidata_default,
15352     serviceWikipedia: () => wikipedia_default,
15353     services: () => services,
15354     svgAreas: () => svgAreas,
15355     svgData: () => svgData,
15356     svgDebug: () => svgDebug,
15357     svgDefs: () => svgDefs,
15358     svgGeolocate: () => svgGeolocate,
15359     svgIcon: () => svgIcon,
15360     svgKartaviewImages: () => svgKartaviewImages,
15361     svgKeepRight: () => svgKeepRight,
15362     svgLabels: () => svgLabels,
15363     svgLayers: () => svgLayers,
15364     svgLines: () => svgLines,
15365     svgMapilioImages: () => svgMapilioImages,
15366     svgMapillaryImages: () => svgMapillaryImages,
15367     svgMapillarySigns: () => svgMapillarySigns,
15368     svgMarkerSegments: () => svgMarkerSegments,
15369     svgMidpoints: () => svgMidpoints,
15370     svgNotes: () => svgNotes,
15371     svgOsm: () => svgOsm,
15372     svgPassiveVertex: () => svgPassiveVertex,
15373     svgPath: () => svgPath,
15374     svgPointTransform: () => svgPointTransform,
15375     svgPoints: () => svgPoints,
15376     svgRelationMemberTags: () => svgRelationMemberTags,
15377     svgSegmentWay: () => svgSegmentWay,
15378     svgStreetside: () => svgStreetside,
15379     svgTagClasses: () => svgTagClasses,
15380     svgTagPattern: () => svgTagPattern,
15381     svgTouch: () => svgTouch,
15382     svgTurns: () => svgTurns,
15383     svgVegbilder: () => svgVegbilder,
15384     svgVertices: () => svgVertices,
15385     t: () => _t,
15386     uiAccount: () => uiAccount,
15387     uiAttribution: () => uiAttribution,
15388     uiChangesetEditor: () => uiChangesetEditor,
15389     uiCmd: () => uiCmd,
15390     uiCombobox: () => uiCombobox,
15391     uiCommit: () => uiCommit,
15392     uiCommitWarnings: () => uiCommitWarnings,
15393     uiConfirm: () => uiConfirm,
15394     uiConflicts: () => uiConflicts,
15395     uiContributors: () => uiContributors,
15396     uiCurtain: () => uiCurtain,
15397     uiDataEditor: () => uiDataEditor,
15398     uiDataHeader: () => uiDataHeader,
15399     uiDisclosure: () => uiDisclosure,
15400     uiEditMenu: () => uiEditMenu,
15401     uiEntityEditor: () => uiEntityEditor,
15402     uiFeatureInfo: () => uiFeatureInfo,
15403     uiFeatureList: () => uiFeatureList,
15404     uiField: () => uiField,
15405     uiFieldAccess: () => uiFieldAccess,
15406     uiFieldAddress: () => uiFieldAddress,
15407     uiFieldCheck: () => uiFieldCheck,
15408     uiFieldColour: () => uiFieldText,
15409     uiFieldCombo: () => uiFieldCombo,
15410     uiFieldDefaultCheck: () => uiFieldCheck,
15411     uiFieldDirectionalCombo: () => uiFieldDirectionalCombo,
15412     uiFieldEmail: () => uiFieldText,
15413     uiFieldHelp: () => uiFieldHelp,
15414     uiFieldIdentifier: () => uiFieldText,
15415     uiFieldLanes: () => uiFieldLanes,
15416     uiFieldLocalized: () => uiFieldLocalized,
15417     uiFieldManyCombo: () => uiFieldCombo,
15418     uiFieldMultiCombo: () => uiFieldCombo,
15419     uiFieldNetworkCombo: () => uiFieldCombo,
15420     uiFieldNumber: () => uiFieldText,
15421     uiFieldOnewayCheck: () => uiFieldCheck,
15422     uiFieldRadio: () => uiFieldRadio,
15423     uiFieldRestrictions: () => uiFieldRestrictions,
15424     uiFieldRoadheight: () => uiFieldRoadheight,
15425     uiFieldRoadspeed: () => uiFieldRoadspeed,
15426     uiFieldSemiCombo: () => uiFieldCombo,
15427     uiFieldStructureRadio: () => uiFieldRadio,
15428     uiFieldTel: () => uiFieldText,
15429     uiFieldText: () => uiFieldText,
15430     uiFieldTextarea: () => uiFieldTextarea,
15431     uiFieldTypeCombo: () => uiFieldCombo,
15432     uiFieldUrl: () => uiFieldText,
15433     uiFieldWikidata: () => uiFieldWikidata,
15434     uiFieldWikipedia: () => uiFieldWikipedia,
15435     uiFields: () => uiFields,
15436     uiFlash: () => uiFlash,
15437     uiFormFields: () => uiFormFields,
15438     uiFullScreen: () => uiFullScreen,
15439     uiGeolocate: () => uiGeolocate,
15440     uiImproveOsmComments: () => uiImproveOsmComments,
15441     uiImproveOsmDetails: () => uiImproveOsmDetails,
15442     uiImproveOsmEditor: () => uiImproveOsmEditor,
15443     uiImproveOsmHeader: () => uiImproveOsmHeader,
15444     uiInfo: () => uiInfo,
15445     uiInfoPanels: () => uiInfoPanels,
15446     uiInit: () => uiInit,
15447     uiInspector: () => uiInspector,
15448     uiIntro: () => uiIntro,
15449     uiIssuesInfo: () => uiIssuesInfo,
15450     uiKeepRightDetails: () => uiKeepRightDetails,
15451     uiKeepRightEditor: () => uiKeepRightEditor,
15452     uiKeepRightHeader: () => uiKeepRightHeader,
15453     uiLasso: () => uiLasso,
15454     uiLengthIndicator: () => uiLengthIndicator,
15455     uiLoading: () => uiLoading,
15456     uiMapInMap: () => uiMapInMap,
15457     uiModal: () => uiModal,
15458     uiNoteComments: () => uiNoteComments,
15459     uiNoteEditor: () => uiNoteEditor,
15460     uiNoteHeader: () => uiNoteHeader,
15461     uiNoteReport: () => uiNoteReport,
15462     uiNotice: () => uiNotice,
15463     uiPaneBackground: () => uiPaneBackground,
15464     uiPaneHelp: () => uiPaneHelp,
15465     uiPaneIssues: () => uiPaneIssues,
15466     uiPaneMapData: () => uiPaneMapData,
15467     uiPanePreferences: () => uiPanePreferences,
15468     uiPanelBackground: () => uiPanelBackground,
15469     uiPanelHistory: () => uiPanelHistory,
15470     uiPanelLocation: () => uiPanelLocation,
15471     uiPanelMeasurement: () => uiPanelMeasurement,
15472     uiPopover: () => uiPopover,
15473     uiPresetIcon: () => uiPresetIcon,
15474     uiPresetList: () => uiPresetList,
15475     uiRestore: () => uiRestore,
15476     uiScale: () => uiScale,
15477     uiSectionBackgroundDisplayOptions: () => uiSectionBackgroundDisplayOptions,
15478     uiSectionBackgroundList: () => uiSectionBackgroundList,
15479     uiSectionBackgroundOffset: () => uiSectionBackgroundOffset,
15480     uiSectionChanges: () => uiSectionChanges,
15481     uiSectionDataLayers: () => uiSectionDataLayers,
15482     uiSectionEntityIssues: () => uiSectionEntityIssues,
15483     uiSectionFeatureType: () => uiSectionFeatureType,
15484     uiSectionMapFeatures: () => uiSectionMapFeatures,
15485     uiSectionMapStyleOptions: () => uiSectionMapStyleOptions,
15486     uiSectionOverlayList: () => uiSectionOverlayList,
15487     uiSectionPhotoOverlays: () => uiSectionPhotoOverlays,
15488     uiSectionPresetFields: () => uiSectionPresetFields,
15489     uiSectionPrivacy: () => uiSectionPrivacy,
15490     uiSectionRawMemberEditor: () => uiSectionRawMemberEditor,
15491     uiSectionRawMembershipEditor: () => uiSectionRawMembershipEditor,
15492     uiSectionRawTagEditor: () => uiSectionRawTagEditor,
15493     uiSectionSelectionList: () => uiSectionSelectionList,
15494     uiSectionValidationIssues: () => uiSectionValidationIssues,
15495     uiSectionValidationOptions: () => uiSectionValidationOptions,
15496     uiSectionValidationRules: () => uiSectionValidationRules,
15497     uiSectionValidationStatus: () => uiSectionValidationStatus,
15498     uiSettingsCustomBackground: () => uiSettingsCustomBackground,
15499     uiSettingsCustomData: () => uiSettingsCustomData,
15500     uiSidebar: () => uiSidebar,
15501     uiSourceSwitch: () => uiSourceSwitch,
15502     uiSpinner: () => uiSpinner,
15503     uiSplash: () => uiSplash,
15504     uiStatus: () => uiStatus,
15505     uiSuccess: () => uiSuccess,
15506     uiTagReference: () => uiTagReference,
15507     uiToggle: () => uiToggle,
15508     uiTooltip: () => uiTooltip,
15509     uiVersion: () => uiVersion,
15510     uiViewOnKeepRight: () => uiViewOnKeepRight,
15511     uiViewOnOSM: () => uiViewOnOSM,
15512     uiZoom: () => uiZoom,
15513     utilAesDecrypt: () => utilAesDecrypt,
15514     utilAesEncrypt: () => utilAesEncrypt,
15515     utilArrayChunk: () => utilArrayChunk,
15516     utilArrayDifference: () => utilArrayDifference,
15517     utilArrayFlatten: () => utilArrayFlatten,
15518     utilArrayGroupBy: () => utilArrayGroupBy,
15519     utilArrayIdentical: () => utilArrayIdentical,
15520     utilArrayIntersection: () => utilArrayIntersection,
15521     utilArrayUnion: () => utilArrayUnion,
15522     utilArrayUniq: () => utilArrayUniq,
15523     utilArrayUniqBy: () => utilArrayUniqBy,
15524     utilAsyncMap: () => utilAsyncMap,
15525     utilCleanOsmString: () => utilCleanOsmString,
15526     utilCleanTags: () => utilCleanTags,
15527     utilCombinedTags: () => utilCombinedTags,
15528     utilCompareIDs: () => utilCompareIDs,
15529     utilDeepMemberSelector: () => utilDeepMemberSelector,
15530     utilDetect: () => utilDetect,
15531     utilDisplayLabel: () => utilDisplayLabel,
15532     utilDisplayName: () => utilDisplayName,
15533     utilDisplayNameForPath: () => utilDisplayNameForPath,
15534     utilDisplayType: () => utilDisplayType,
15535     utilEditDistance: () => utilEditDistance,
15536     utilEntityAndDeepMemberIDs: () => utilEntityAndDeepMemberIDs,
15537     utilEntityOrDeepMemberSelector: () => utilEntityOrDeepMemberSelector,
15538     utilEntityOrMemberSelector: () => utilEntityOrMemberSelector,
15539     utilEntityRoot: () => utilEntityRoot,
15540     utilEntitySelector: () => utilEntitySelector,
15541     utilFastMouse: () => utilFastMouse,
15542     utilFunctor: () => utilFunctor,
15543     utilGetAllNodes: () => utilGetAllNodes,
15544     utilGetSetValue: () => utilGetSetValue,
15545     utilHashcode: () => utilHashcode,
15546     utilHighlightEntities: () => utilHighlightEntities,
15547     utilKeybinding: () => utilKeybinding,
15548     utilNoAuto: () => utilNoAuto,
15549     utilObjectOmit: () => utilObjectOmit,
15550     utilOldestID: () => utilOldestID,
15551     utilPrefixCSSProperty: () => utilPrefixCSSProperty,
15552     utilPrefixDOMProperty: () => utilPrefixDOMProperty,
15553     utilQsString: () => utilQsString,
15554     utilRebind: () => utilRebind,
15555     utilSafeClassName: () => utilSafeClassName,
15556     utilSessionMutex: () => utilSessionMutex,
15557     utilSetTransform: () => utilSetTransform,
15558     utilStringQs: () => utilStringQs,
15559     utilTagDiff: () => utilTagDiff,
15560     utilTagText: () => utilTagText,
15561     utilTiler: () => utilTiler,
15562     utilTotalExtent: () => utilTotalExtent,
15563     utilTriggerEvent: () => utilTriggerEvent,
15564     utilUnicodeCharsCount: () => utilUnicodeCharsCount,
15565     utilUnicodeCharsTruncated: () => utilUnicodeCharsTruncated,
15566     utilUniqueDomId: () => utilUniqueDomId,
15567     utilWrap: () => utilWrap,
15568     validationAlmostJunction: () => validationAlmostJunction,
15569     validationCloseNodes: () => validationCloseNodes,
15570     validationCrossingWays: () => validationCrossingWays,
15571     validationDisconnectedWay: () => validationDisconnectedWay,
15572     validationFormatting: () => validationFormatting,
15573     validationHelpRequest: () => validationHelpRequest,
15574     validationImpossibleOneway: () => validationImpossibleOneway,
15575     validationIncompatibleSource: () => validationIncompatibleSource,
15576     validationMaprules: () => validationMaprules,
15577     validationMismatchedGeometry: () => validationMismatchedGeometry,
15578     validationMissingRole: () => validationMissingRole,
15579     validationMissingTag: () => validationMissingTag,
15580     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
15581     validationOutdatedTags: () => validationOutdatedTags,
15582     validationPrivateData: () => validationPrivateData,
15583     validationSuspiciousName: () => validationSuspiciousName,
15584     validationUnsquareWay: () => validationUnsquareWay
15585   });
15586
15587   // modules/actions/add_entity.js
15588   function actionAddEntity(way) {
15589     return function(graph) {
15590       return graph.replace(way);
15591     };
15592   }
15593
15594   // modules/actions/reverse.js
15595   function actionReverse(entityID, options2) {
15596     var ignoreKey = /^.*(_|:)?(description|name|note|website|ref|source|comment|watch|attribution)(_|:)?/;
15597     var numeric = /^([+\-]?)(?=[\d.])/;
15598     var directionKey = /direction$/;
15599     var turn_lanes = /^turn:lanes:?/;
15600     var keyReplacements = [
15601       [/:right$/, ":left"],
15602       [/:left$/, ":right"],
15603       [/:forward$/, ":backward"],
15604       [/:backward$/, ":forward"],
15605       [/:right:/, ":left:"],
15606       [/:left:/, ":right:"],
15607       [/:forward:/, ":backward:"],
15608       [/:backward:/, ":forward:"]
15609     ];
15610     var valueReplacements = {
15611       left: "right",
15612       right: "left",
15613       up: "down",
15614       down: "up",
15615       forward: "backward",
15616       backward: "forward",
15617       forwards: "backward",
15618       backwards: "forward"
15619     };
15620     const valueReplacementsExceptions = {
15621       "side": [
15622         { highway: "cyclist_waiting_aid" }
15623       ]
15624     };
15625     var roleReplacements = {
15626       forward: "backward",
15627       backward: "forward",
15628       forwards: "backward",
15629       backwards: "forward"
15630     };
15631     var onewayReplacements = {
15632       yes: "-1",
15633       "1": "-1",
15634       "-1": "yes"
15635     };
15636     var compassReplacements = {
15637       N: "S",
15638       NNE: "SSW",
15639       NE: "SW",
15640       ENE: "WSW",
15641       E: "W",
15642       ESE: "WNW",
15643       SE: "NW",
15644       SSE: "NNW",
15645       S: "N",
15646       SSW: "NNE",
15647       SW: "NE",
15648       WSW: "ENE",
15649       W: "E",
15650       WNW: "ESE",
15651       NW: "SE",
15652       NNW: "SSE"
15653     };
15654     function reverseKey(key) {
15655       for (var i3 = 0; i3 < keyReplacements.length; ++i3) {
15656         var replacement = keyReplacements[i3];
15657         if (replacement[0].test(key)) {
15658           return key.replace(replacement[0], replacement[1]);
15659         }
15660       }
15661       return key;
15662     }
15663     function reverseValue(key, value, includeAbsolute, allTags) {
15664       if (ignoreKey.test(key))
15665         return value;
15666       if (turn_lanes.test(key)) {
15667         return value;
15668       } else if (key === "incline" && numeric.test(value)) {
15669         return value.replace(numeric, function(_2, sign2) {
15670           return sign2 === "-" ? "" : "-";
15671         });
15672       } else if (options2 && options2.reverseOneway && key === "oneway") {
15673         return onewayReplacements[value] || value;
15674       } else if (includeAbsolute && directionKey.test(key)) {
15675         return value.split(";").map((value2) => {
15676           if (compassReplacements[value2])
15677             return compassReplacements[value2];
15678           var degrees3 = Number(value2);
15679           if (isFinite(degrees3)) {
15680             if (degrees3 < 180) {
15681               degrees3 += 180;
15682             } else {
15683               degrees3 -= 180;
15684             }
15685             return degrees3.toString();
15686           } else {
15687             return valueReplacements[value2] || value2;
15688           }
15689         }).join(";");
15690       }
15691       if (valueReplacementsExceptions[key] && valueReplacementsExceptions[key].some(
15692         (exceptionTags) => Object.keys(exceptionTags).every((k2) => {
15693           const v2 = exceptionTags[k2];
15694           return allTags[k2] && (v2 === "*" || allTags[k2] === v2);
15695         })
15696       )) {
15697         return value;
15698       }
15699       return valueReplacements[value] || value;
15700     }
15701     function reverseNodeTags(graph, nodeIDs) {
15702       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
15703         var node = graph.hasEntity(nodeIDs[i3]);
15704         if (!node || !Object.keys(node.tags).length)
15705           continue;
15706         var tags = {};
15707         for (var key in node.tags) {
15708           tags[reverseKey(key)] = reverseValue(key, node.tags[key], node.id === entityID, node.tags);
15709         }
15710         graph = graph.replace(node.update({ tags }));
15711       }
15712       return graph;
15713     }
15714     function reverseWay(graph, way) {
15715       var nodes = way.nodes.slice().reverse();
15716       var tags = {};
15717       var role;
15718       for (var key in way.tags) {
15719         tags[reverseKey(key)] = reverseValue(key, way.tags[key], false, way.tags);
15720       }
15721       graph.parentRelations(way).forEach(function(relation) {
15722         relation.members.forEach(function(member, index) {
15723           if (member.id === way.id && (role = roleReplacements[member.role])) {
15724             relation = relation.updateMember({ role }, index);
15725             graph = graph.replace(relation);
15726           }
15727         });
15728       });
15729       return reverseNodeTags(graph, nodes).replace(way.update({ nodes, tags }));
15730     }
15731     var action = function(graph) {
15732       var entity = graph.entity(entityID);
15733       if (entity.type === "way") {
15734         return reverseWay(graph, entity);
15735       }
15736       return reverseNodeTags(graph, [entityID]);
15737     };
15738     action.disabled = function(graph) {
15739       var entity = graph.hasEntity(entityID);
15740       if (!entity || entity.type === "way")
15741         return false;
15742       for (var key in entity.tags) {
15743         var value = entity.tags[key];
15744         if (reverseKey(key) !== key || reverseValue(key, value, true, entity.tags) !== value) {
15745           return false;
15746         }
15747       }
15748       return "nondirectional_node";
15749     };
15750     action.entityID = function() {
15751       return entityID;
15752     };
15753     return action;
15754   }
15755
15756   // modules/osm/tags.js
15757   function osmIsInterestingTag(key) {
15758     return key !== "attribution" && key !== "created_by" && key !== "source" && key !== "odbl" && key.indexOf("source:") !== 0 && key.indexOf("source_ref") !== 0 && // purposely exclude colon
15759     key.indexOf("tiger:") !== 0;
15760   }
15761   var osmLifecyclePrefixes = {
15762     // nonexistent, might be built
15763     proposed: true,
15764     planned: true,
15765     // under maintentance or between groundbreaking and opening
15766     construction: true,
15767     // existent but not functional
15768     disused: true,
15769     // dilapidated to nonexistent
15770     abandoned: true,
15771     was: true,
15772     // nonexistent, still may appear in imagery
15773     dismantled: true,
15774     razed: true,
15775     demolished: true,
15776     destroyed: true,
15777     removed: true,
15778     obliterated: true,
15779     // existent occasionally, e.g. stormwater drainage basin
15780     intermittent: true
15781   };
15782   function osmRemoveLifecyclePrefix(key) {
15783     const keySegments = key.split(":");
15784     if (keySegments.length === 1)
15785       return key;
15786     if (keySegments[0] in osmLifecyclePrefixes) {
15787       return key.slice(keySegments[0].length + 1);
15788     }
15789     return key;
15790   }
15791   var osmAreaKeys = {};
15792   function osmSetAreaKeys(value) {
15793     osmAreaKeys = value;
15794   }
15795   var osmAreaKeysExceptions = {
15796     highway: {
15797       elevator: true,
15798       rest_area: true,
15799       services: true
15800     },
15801     public_transport: {
15802       platform: true
15803     },
15804     railway: {
15805       platform: true,
15806       roundhouse: true,
15807       station: true,
15808       traverser: true,
15809       turntable: true,
15810       wash: true
15811     },
15812     waterway: {
15813       dam: true
15814     }
15815   };
15816   function osmTagSuggestingArea(tags) {
15817     if (tags.area === "yes")
15818       return { area: "yes" };
15819     if (tags.area === "no")
15820       return null;
15821     var returnTags = {};
15822     for (var realKey in tags) {
15823       const key = osmRemoveLifecyclePrefix(realKey);
15824       if (key in osmAreaKeys && !(tags[realKey] in osmAreaKeys[key])) {
15825         returnTags[realKey] = tags[realKey];
15826         return returnTags;
15827       }
15828       if (key in osmAreaKeysExceptions && tags[realKey] in osmAreaKeysExceptions[key]) {
15829         returnTags[realKey] = tags[realKey];
15830         return returnTags;
15831       }
15832     }
15833     return null;
15834   }
15835   var osmLineTags = {};
15836   function osmSetLineTags(value) {
15837     osmLineTags = value;
15838   }
15839   var osmPointTags = {};
15840   function osmSetPointTags(value) {
15841     osmPointTags = value;
15842   }
15843   var osmVertexTags = {};
15844   function osmSetVertexTags(value) {
15845     osmVertexTags = value;
15846   }
15847   function osmNodeGeometriesForTags(nodeTags) {
15848     var geometries = {};
15849     for (var key in nodeTags) {
15850       if (osmPointTags[key] && (osmPointTags[key]["*"] || osmPointTags[key][nodeTags[key]])) {
15851         geometries.point = true;
15852       }
15853       if (osmVertexTags[key] && (osmVertexTags[key]["*"] || osmVertexTags[key][nodeTags[key]])) {
15854         geometries.vertex = true;
15855       }
15856       if (geometries.point && geometries.vertex)
15857         break;
15858     }
15859     return geometries;
15860   }
15861   var osmOneWayTags = {
15862     "aerialway": {
15863       "chair_lift": true,
15864       "drag_lift": true,
15865       "j-bar": true,
15866       "magic_carpet": true,
15867       "mixed_lift": true,
15868       "platter": true,
15869       "rope_tow": true,
15870       "t-bar": true,
15871       "zip_line": true
15872     },
15873     "highway": {
15874       "motorway": true
15875     },
15876     "junction": {
15877       "circular": true,
15878       "roundabout": true
15879     },
15880     "man_made": {
15881       "goods_conveyor": true,
15882       "piste:halfpipe": true
15883     },
15884     "piste:type": {
15885       "downhill": true,
15886       "sled": true,
15887       "yes": true
15888     },
15889     "seamark:type": {
15890       "two-way_route": true,
15891       "recommended_traffic_lane": true,
15892       "separation_lane": true,
15893       "separation_roundabout": true
15894     },
15895     "waterway": {
15896       "canal": true,
15897       "ditch": true,
15898       "drain": true,
15899       "fish_pass": true,
15900       "pressurised": true,
15901       "river": true,
15902       "spillway": true,
15903       "stream": true,
15904       "tidal_channel": true
15905     }
15906   };
15907   var osmPavedTags = {
15908     "surface": {
15909       "paved": true,
15910       "asphalt": true,
15911       "concrete": true,
15912       "chipseal": true,
15913       "concrete:lanes": true,
15914       "concrete:plates": true
15915     },
15916     "tracktype": {
15917       "grade1": true
15918     }
15919   };
15920   var osmSemipavedTags = {
15921     "surface": {
15922       "cobblestone": true,
15923       "cobblestone:flattened": true,
15924       "unhewn_cobblestone": true,
15925       "sett": true,
15926       "paving_stones": true,
15927       "metal": true,
15928       "wood": true
15929     }
15930   };
15931   var osmRightSideIsInsideTags = {
15932     "natural": {
15933       "cliff": true,
15934       "coastline": "coastline"
15935     },
15936     "barrier": {
15937       "retaining_wall": true,
15938       "kerb": true,
15939       "guard_rail": true,
15940       "city_wall": true
15941     },
15942     "man_made": {
15943       "embankment": true,
15944       "quay": true
15945     },
15946     "waterway": {
15947       "weir": true
15948     }
15949   };
15950   var osmRoutableHighwayTagValues = {
15951     motorway: true,
15952     trunk: true,
15953     primary: true,
15954     secondary: true,
15955     tertiary: true,
15956     residential: true,
15957     motorway_link: true,
15958     trunk_link: true,
15959     primary_link: true,
15960     secondary_link: true,
15961     tertiary_link: true,
15962     unclassified: true,
15963     road: true,
15964     service: true,
15965     track: true,
15966     living_street: true,
15967     bus_guideway: true,
15968     busway: true,
15969     path: true,
15970     footway: true,
15971     cycleway: true,
15972     bridleway: true,
15973     pedestrian: true,
15974     corridor: true,
15975     steps: true
15976   };
15977   var osmPathHighwayTagValues = {
15978     path: true,
15979     footway: true,
15980     cycleway: true,
15981     bridleway: true,
15982     pedestrian: true,
15983     corridor: true,
15984     steps: true
15985   };
15986   var osmRailwayTrackTagValues = {
15987     rail: true,
15988     light_rail: true,
15989     tram: true,
15990     subway: true,
15991     monorail: true,
15992     funicular: true,
15993     miniature: true,
15994     narrow_gauge: true,
15995     disused: true,
15996     preserved: true
15997   };
15998   var osmFlowingWaterwayTagValues = {
15999     canal: true,
16000     ditch: true,
16001     drain: true,
16002     fish_pass: true,
16003     river: true,
16004     stream: true,
16005     tidal_channel: true
16006   };
16007   var allowUpperCaseTagValues = /network|taxon|genus|species|brand|grape_variety|royal_cypher|listed_status|booth|rating|stars|:output|_hours|_times|_ref|manufacturer|country|target|brewery|cai_scale|traffic_sign/;
16008   function isColourValid(value) {
16009     if (!value.match(/^(#([0-9a-fA-F]{3}){1,2}|\w+)$/)) {
16010       return false;
16011     }
16012     if (!CSS.supports("color", value) || ["unset", "inherit", "initial", "revert"].includes(value)) {
16013       return false;
16014     }
16015     return true;
16016   }
16017   var osmMutuallyExclusiveTagPairs = [
16018     ["noname", "name"],
16019     ["noref", "ref"],
16020     ["nohousenumber", "addr:housenumber"],
16021     ["noaddress", "addr:housenumber"],
16022     ["noaddress", "addr:housename"],
16023     ["noaddress", "addr:unit"],
16024     ["addr:nostreet", "addr:street"]
16025   ];
16026
16027   // node_modules/d3-array/src/ascending.js
16028   function ascending(a2, b2) {
16029     return a2 == null || b2 == null ? NaN : a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
16030   }
16031
16032   // node_modules/d3-array/src/descending.js
16033   function descending(a2, b2) {
16034     return a2 == null || b2 == null ? NaN : b2 < a2 ? -1 : b2 > a2 ? 1 : b2 >= a2 ? 0 : NaN;
16035   }
16036
16037   // node_modules/d3-array/src/bisector.js
16038   function bisector(f2) {
16039     let compare1, compare2, delta;
16040     if (f2.length !== 2) {
16041       compare1 = ascending;
16042       compare2 = (d2, x2) => ascending(f2(d2), x2);
16043       delta = (d2, x2) => f2(d2) - x2;
16044     } else {
16045       compare1 = f2 === ascending || f2 === descending ? f2 : zero;
16046       compare2 = f2;
16047       delta = f2;
16048     }
16049     function left(a2, x2, lo = 0, hi = a2.length) {
16050       if (lo < hi) {
16051         if (compare1(x2, x2) !== 0)
16052           return hi;
16053         do {
16054           const mid = lo + hi >>> 1;
16055           if (compare2(a2[mid], x2) < 0)
16056             lo = mid + 1;
16057           else
16058             hi = mid;
16059         } while (lo < hi);
16060       }
16061       return lo;
16062     }
16063     function right(a2, x2, lo = 0, hi = a2.length) {
16064       if (lo < hi) {
16065         if (compare1(x2, x2) !== 0)
16066           return hi;
16067         do {
16068           const mid = lo + hi >>> 1;
16069           if (compare2(a2[mid], x2) <= 0)
16070             lo = mid + 1;
16071           else
16072             hi = mid;
16073         } while (lo < hi);
16074       }
16075       return lo;
16076     }
16077     function center(a2, x2, lo = 0, hi = a2.length) {
16078       const i3 = left(a2, x2, lo, hi - 1);
16079       return i3 > lo && delta(a2[i3 - 1], x2) > -delta(a2[i3], x2) ? i3 - 1 : i3;
16080     }
16081     return { left, center, right };
16082   }
16083   function zero() {
16084     return 0;
16085   }
16086
16087   // node_modules/d3-array/src/number.js
16088   function number(x2) {
16089     return x2 === null ? NaN : +x2;
16090   }
16091   function* numbers(values, valueof) {
16092     if (valueof === void 0) {
16093       for (let value of values) {
16094         if (value != null && (value = +value) >= value) {
16095           yield value;
16096         }
16097       }
16098     } else {
16099       let index = -1;
16100       for (let value of values) {
16101         if ((value = valueof(value, ++index, values)) != null && (value = +value) >= value) {
16102           yield value;
16103         }
16104       }
16105     }
16106   }
16107
16108   // node_modules/d3-array/src/bisect.js
16109   var ascendingBisect = bisector(ascending);
16110   var bisectRight = ascendingBisect.right;
16111   var bisectLeft = ascendingBisect.left;
16112   var bisectCenter = bisector(number).center;
16113   var bisect_default = bisectRight;
16114
16115   // node_modules/d3-array/src/fsum.js
16116   var Adder = class {
16117     constructor() {
16118       this._partials = new Float64Array(32);
16119       this._n = 0;
16120     }
16121     add(x2) {
16122       const p2 = this._partials;
16123       let i3 = 0;
16124       for (let j2 = 0; j2 < this._n && j2 < 32; j2++) {
16125         const y2 = p2[j2], hi = x2 + y2, lo = Math.abs(x2) < Math.abs(y2) ? x2 - (hi - y2) : y2 - (hi - x2);
16126         if (lo)
16127           p2[i3++] = lo;
16128         x2 = hi;
16129       }
16130       p2[i3] = x2;
16131       this._n = i3 + 1;
16132       return this;
16133     }
16134     valueOf() {
16135       const p2 = this._partials;
16136       let n3 = this._n, x2, y2, lo, hi = 0;
16137       if (n3 > 0) {
16138         hi = p2[--n3];
16139         while (n3 > 0) {
16140           x2 = hi;
16141           y2 = p2[--n3];
16142           hi = x2 + y2;
16143           lo = y2 - (hi - x2);
16144           if (lo)
16145             break;
16146         }
16147         if (n3 > 0 && (lo < 0 && p2[n3 - 1] < 0 || lo > 0 && p2[n3 - 1] > 0)) {
16148           y2 = lo * 2;
16149           x2 = hi + y2;
16150           if (y2 == x2 - hi)
16151             hi = x2;
16152         }
16153       }
16154       return hi;
16155     }
16156   };
16157
16158   // node_modules/d3-array/src/sort.js
16159   function compareDefined(compare2 = ascending) {
16160     if (compare2 === ascending)
16161       return ascendingDefined;
16162     if (typeof compare2 !== "function")
16163       throw new TypeError("compare is not a function");
16164     return (a2, b2) => {
16165       const x2 = compare2(a2, b2);
16166       if (x2 || x2 === 0)
16167         return x2;
16168       return (compare2(b2, b2) === 0) - (compare2(a2, a2) === 0);
16169     };
16170   }
16171   function ascendingDefined(a2, b2) {
16172     return (a2 == null || !(a2 >= a2)) - (b2 == null || !(b2 >= b2)) || (a2 < b2 ? -1 : a2 > b2 ? 1 : 0);
16173   }
16174
16175   // node_modules/d3-array/src/ticks.js
16176   var e10 = Math.sqrt(50);
16177   var e5 = Math.sqrt(10);
16178   var e2 = Math.sqrt(2);
16179   function ticks(start2, stop, count) {
16180     var reverse, i3 = -1, n3, ticks2, step;
16181     stop = +stop, start2 = +start2, count = +count;
16182     if (start2 === stop && count > 0)
16183       return [start2];
16184     if (reverse = stop < start2)
16185       n3 = start2, start2 = stop, stop = n3;
16186     if ((step = tickIncrement(start2, stop, count)) === 0 || !isFinite(step))
16187       return [];
16188     if (step > 0) {
16189       let r0 = Math.round(start2 / step), r1 = Math.round(stop / step);
16190       if (r0 * step < start2)
16191         ++r0;
16192       if (r1 * step > stop)
16193         --r1;
16194       ticks2 = new Array(n3 = r1 - r0 + 1);
16195       while (++i3 < n3)
16196         ticks2[i3] = (r0 + i3) * step;
16197     } else {
16198       step = -step;
16199       let r0 = Math.round(start2 * step), r1 = Math.round(stop * step);
16200       if (r0 / step < start2)
16201         ++r0;
16202       if (r1 / step > stop)
16203         --r1;
16204       ticks2 = new Array(n3 = r1 - r0 + 1);
16205       while (++i3 < n3)
16206         ticks2[i3] = (r0 + i3) / step;
16207     }
16208     if (reverse)
16209       ticks2.reverse();
16210     return ticks2;
16211   }
16212   function tickIncrement(start2, stop, count) {
16213     var step = (stop - start2) / Math.max(0, count), power = Math.floor(Math.log(step) / Math.LN10), error = step / Math.pow(10, power);
16214     return power >= 0 ? (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1) * Math.pow(10, power) : -Math.pow(10, -power) / (error >= e10 ? 10 : error >= e5 ? 5 : error >= e2 ? 2 : 1);
16215   }
16216   function tickStep(start2, stop, count) {
16217     var step0 = Math.abs(stop - start2) / Math.max(0, count), step1 = Math.pow(10, Math.floor(Math.log(step0) / Math.LN10)), error = step0 / step1;
16218     if (error >= e10)
16219       step1 *= 10;
16220     else if (error >= e5)
16221       step1 *= 5;
16222     else if (error >= e2)
16223       step1 *= 2;
16224     return stop < start2 ? -step1 : step1;
16225   }
16226
16227   // node_modules/d3-array/src/max.js
16228   function max(values, valueof) {
16229     let max3;
16230     if (valueof === void 0) {
16231       for (const value of values) {
16232         if (value != null && (max3 < value || max3 === void 0 && value >= value)) {
16233           max3 = value;
16234         }
16235       }
16236     } else {
16237       let index = -1;
16238       for (let value of values) {
16239         if ((value = valueof(value, ++index, values)) != null && (max3 < value || max3 === void 0 && value >= value)) {
16240           max3 = value;
16241         }
16242       }
16243     }
16244     return max3;
16245   }
16246
16247   // node_modules/d3-array/src/min.js
16248   function min(values, valueof) {
16249     let min3;
16250     if (valueof === void 0) {
16251       for (const value of values) {
16252         if (value != null && (min3 > value || min3 === void 0 && value >= value)) {
16253           min3 = value;
16254         }
16255       }
16256     } else {
16257       let index = -1;
16258       for (let value of values) {
16259         if ((value = valueof(value, ++index, values)) != null && (min3 > value || min3 === void 0 && value >= value)) {
16260           min3 = value;
16261         }
16262       }
16263     }
16264     return min3;
16265   }
16266
16267   // node_modules/d3-array/src/quickselect.js
16268   function quickselect(array2, k2, left = 0, right = array2.length - 1, compare2) {
16269     compare2 = compare2 === void 0 ? ascendingDefined : compareDefined(compare2);
16270     while (right > left) {
16271       if (right - left > 600) {
16272         const n3 = right - left + 1;
16273         const m2 = k2 - left + 1;
16274         const z2 = Math.log(n3);
16275         const s2 = 0.5 * Math.exp(2 * z2 / 3);
16276         const sd = 0.5 * Math.sqrt(z2 * s2 * (n3 - s2) / n3) * (m2 - n3 / 2 < 0 ? -1 : 1);
16277         const newLeft = Math.max(left, Math.floor(k2 - m2 * s2 / n3 + sd));
16278         const newRight = Math.min(right, Math.floor(k2 + (n3 - m2) * s2 / n3 + sd));
16279         quickselect(array2, k2, newLeft, newRight, compare2);
16280       }
16281       const t2 = array2[k2];
16282       let i3 = left;
16283       let j2 = right;
16284       swap(array2, left, k2);
16285       if (compare2(array2[right], t2) > 0)
16286         swap(array2, left, right);
16287       while (i3 < j2) {
16288         swap(array2, i3, j2), ++i3, --j2;
16289         while (compare2(array2[i3], t2) < 0)
16290           ++i3;
16291         while (compare2(array2[j2], t2) > 0)
16292           --j2;
16293       }
16294       if (compare2(array2[left], t2) === 0)
16295         swap(array2, left, j2);
16296       else
16297         ++j2, swap(array2, j2, right);
16298       if (j2 <= k2)
16299         left = j2 + 1;
16300       if (k2 <= j2)
16301         right = j2 - 1;
16302     }
16303     return array2;
16304   }
16305   function swap(array2, i3, j2) {
16306     const t2 = array2[i3];
16307     array2[i3] = array2[j2];
16308     array2[j2] = t2;
16309   }
16310
16311   // node_modules/d3-array/src/quantile.js
16312   function quantile(values, p2, valueof) {
16313     values = Float64Array.from(numbers(values, valueof));
16314     if (!(n3 = values.length))
16315       return;
16316     if ((p2 = +p2) <= 0 || n3 < 2)
16317       return min(values);
16318     if (p2 >= 1)
16319       return max(values);
16320     var n3, i3 = (n3 - 1) * p2, i0 = Math.floor(i3), value0 = max(quickselect(values, i0).subarray(0, i0 + 1)), value1 = min(values.subarray(i0 + 1));
16321     return value0 + (value1 - value0) * (i3 - i0);
16322   }
16323
16324   // node_modules/d3-array/src/median.js
16325   function median(values, valueof) {
16326     return quantile(values, 0.5, valueof);
16327   }
16328
16329   // node_modules/d3-array/src/merge.js
16330   function* flatten(arrays) {
16331     for (const array2 of arrays) {
16332       yield* array2;
16333     }
16334   }
16335   function merge(arrays) {
16336     return Array.from(flatten(arrays));
16337   }
16338
16339   // node_modules/d3-array/src/pairs.js
16340   function pairs(values, pairof = pair) {
16341     const pairs2 = [];
16342     let previous;
16343     let first = false;
16344     for (const value of values) {
16345       if (first)
16346         pairs2.push(pairof(previous, value));
16347       previous = value;
16348       first = true;
16349     }
16350     return pairs2;
16351   }
16352   function pair(a2, b2) {
16353     return [a2, b2];
16354   }
16355
16356   // node_modules/d3-array/src/range.js
16357   function range(start2, stop, step) {
16358     start2 = +start2, stop = +stop, step = (n3 = arguments.length) < 2 ? (stop = start2, start2 = 0, 1) : n3 < 3 ? 1 : +step;
16359     var i3 = -1, n3 = Math.max(0, Math.ceil((stop - start2) / step)) | 0, range3 = new Array(n3);
16360     while (++i3 < n3) {
16361       range3[i3] = start2 + i3 * step;
16362     }
16363     return range3;
16364   }
16365
16366   // node_modules/d3-geo/src/math.js
16367   var epsilon = 1e-6;
16368   var epsilon2 = 1e-12;
16369   var pi = Math.PI;
16370   var halfPi = pi / 2;
16371   var quarterPi = pi / 4;
16372   var tau = pi * 2;
16373   var degrees = 180 / pi;
16374   var radians = pi / 180;
16375   var abs = Math.abs;
16376   var atan = Math.atan;
16377   var atan2 = Math.atan2;
16378   var cos = Math.cos;
16379   var exp = Math.exp;
16380   var log = Math.log;
16381   var sin = Math.sin;
16382   var sign = Math.sign || function(x2) {
16383     return x2 > 0 ? 1 : x2 < 0 ? -1 : 0;
16384   };
16385   var sqrt = Math.sqrt;
16386   var tan = Math.tan;
16387   function acos(x2) {
16388     return x2 > 1 ? 0 : x2 < -1 ? pi : Math.acos(x2);
16389   }
16390   function asin(x2) {
16391     return x2 > 1 ? halfPi : x2 < -1 ? -halfPi : Math.asin(x2);
16392   }
16393
16394   // node_modules/d3-geo/src/noop.js
16395   function noop() {
16396   }
16397
16398   // node_modules/d3-geo/src/stream.js
16399   function streamGeometry(geometry, stream) {
16400     if (geometry && streamGeometryType.hasOwnProperty(geometry.type)) {
16401       streamGeometryType[geometry.type](geometry, stream);
16402     }
16403   }
16404   var streamObjectType = {
16405     Feature: function(object, stream) {
16406       streamGeometry(object.geometry, stream);
16407     },
16408     FeatureCollection: function(object, stream) {
16409       var features = object.features, i3 = -1, n3 = features.length;
16410       while (++i3 < n3)
16411         streamGeometry(features[i3].geometry, stream);
16412     }
16413   };
16414   var streamGeometryType = {
16415     Sphere: function(object, stream) {
16416       stream.sphere();
16417     },
16418     Point: function(object, stream) {
16419       object = object.coordinates;
16420       stream.point(object[0], object[1], object[2]);
16421     },
16422     MultiPoint: function(object, stream) {
16423       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
16424       while (++i3 < n3)
16425         object = coordinates[i3], stream.point(object[0], object[1], object[2]);
16426     },
16427     LineString: function(object, stream) {
16428       streamLine(object.coordinates, stream, 0);
16429     },
16430     MultiLineString: function(object, stream) {
16431       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
16432       while (++i3 < n3)
16433         streamLine(coordinates[i3], stream, 0);
16434     },
16435     Polygon: function(object, stream) {
16436       streamPolygon(object.coordinates, stream);
16437     },
16438     MultiPolygon: function(object, stream) {
16439       var coordinates = object.coordinates, i3 = -1, n3 = coordinates.length;
16440       while (++i3 < n3)
16441         streamPolygon(coordinates[i3], stream);
16442     },
16443     GeometryCollection: function(object, stream) {
16444       var geometries = object.geometries, i3 = -1, n3 = geometries.length;
16445       while (++i3 < n3)
16446         streamGeometry(geometries[i3], stream);
16447     }
16448   };
16449   function streamLine(coordinates, stream, closed) {
16450     var i3 = -1, n3 = coordinates.length - closed, coordinate;
16451     stream.lineStart();
16452     while (++i3 < n3)
16453       coordinate = coordinates[i3], stream.point(coordinate[0], coordinate[1], coordinate[2]);
16454     stream.lineEnd();
16455   }
16456   function streamPolygon(coordinates, stream) {
16457     var i3 = -1, n3 = coordinates.length;
16458     stream.polygonStart();
16459     while (++i3 < n3)
16460       streamLine(coordinates[i3], stream, 1);
16461     stream.polygonEnd();
16462   }
16463   function stream_default(object, stream) {
16464     if (object && streamObjectType.hasOwnProperty(object.type)) {
16465       streamObjectType[object.type](object, stream);
16466     } else {
16467       streamGeometry(object, stream);
16468     }
16469   }
16470
16471   // node_modules/d3-geo/src/area.js
16472   var areaRingSum = new Adder();
16473   var areaSum = new Adder();
16474   var lambda00;
16475   var phi00;
16476   var lambda0;
16477   var cosPhi0;
16478   var sinPhi0;
16479   var areaStream = {
16480     point: noop,
16481     lineStart: noop,
16482     lineEnd: noop,
16483     polygonStart: function() {
16484       areaRingSum = new Adder();
16485       areaStream.lineStart = areaRingStart;
16486       areaStream.lineEnd = areaRingEnd;
16487     },
16488     polygonEnd: function() {
16489       var areaRing = +areaRingSum;
16490       areaSum.add(areaRing < 0 ? tau + areaRing : areaRing);
16491       this.lineStart = this.lineEnd = this.point = noop;
16492     },
16493     sphere: function() {
16494       areaSum.add(tau);
16495     }
16496   };
16497   function areaRingStart() {
16498     areaStream.point = areaPointFirst;
16499   }
16500   function areaRingEnd() {
16501     areaPoint(lambda00, phi00);
16502   }
16503   function areaPointFirst(lambda, phi) {
16504     areaStream.point = areaPoint;
16505     lambda00 = lambda, phi00 = phi;
16506     lambda *= radians, phi *= radians;
16507     lambda0 = lambda, cosPhi0 = cos(phi = phi / 2 + quarterPi), sinPhi0 = sin(phi);
16508   }
16509   function areaPoint(lambda, phi) {
16510     lambda *= radians, phi *= radians;
16511     phi = phi / 2 + quarterPi;
16512     var dLambda = lambda - lambda0, sdLambda = dLambda >= 0 ? 1 : -1, adLambda = sdLambda * dLambda, cosPhi = cos(phi), sinPhi = sin(phi), k2 = sinPhi0 * sinPhi, u2 = cosPhi0 * cosPhi + k2 * cos(adLambda), v2 = k2 * sdLambda * sin(adLambda);
16513     areaRingSum.add(atan2(v2, u2));
16514     lambda0 = lambda, cosPhi0 = cosPhi, sinPhi0 = sinPhi;
16515   }
16516   function area_default(object) {
16517     areaSum = new Adder();
16518     stream_default(object, areaStream);
16519     return areaSum * 2;
16520   }
16521
16522   // node_modules/d3-geo/src/cartesian.js
16523   function spherical(cartesian2) {
16524     return [atan2(cartesian2[1], cartesian2[0]), asin(cartesian2[2])];
16525   }
16526   function cartesian(spherical2) {
16527     var lambda = spherical2[0], phi = spherical2[1], cosPhi = cos(phi);
16528     return [cosPhi * cos(lambda), cosPhi * sin(lambda), sin(phi)];
16529   }
16530   function cartesianDot(a2, b2) {
16531     return a2[0] * b2[0] + a2[1] * b2[1] + a2[2] * b2[2];
16532   }
16533   function cartesianCross(a2, b2) {
16534     return [a2[1] * b2[2] - a2[2] * b2[1], a2[2] * b2[0] - a2[0] * b2[2], a2[0] * b2[1] - a2[1] * b2[0]];
16535   }
16536   function cartesianAddInPlace(a2, b2) {
16537     a2[0] += b2[0], a2[1] += b2[1], a2[2] += b2[2];
16538   }
16539   function cartesianScale(vector, k2) {
16540     return [vector[0] * k2, vector[1] * k2, vector[2] * k2];
16541   }
16542   function cartesianNormalizeInPlace(d2) {
16543     var l2 = sqrt(d2[0] * d2[0] + d2[1] * d2[1] + d2[2] * d2[2]);
16544     d2[0] /= l2, d2[1] /= l2, d2[2] /= l2;
16545   }
16546
16547   // node_modules/d3-geo/src/bounds.js
16548   var lambda02;
16549   var phi0;
16550   var lambda1;
16551   var phi1;
16552   var lambda2;
16553   var lambda002;
16554   var phi002;
16555   var p0;
16556   var deltaSum;
16557   var ranges;
16558   var range2;
16559   var boundsStream = {
16560     point: boundsPoint,
16561     lineStart: boundsLineStart,
16562     lineEnd: boundsLineEnd,
16563     polygonStart: function() {
16564       boundsStream.point = boundsRingPoint;
16565       boundsStream.lineStart = boundsRingStart;
16566       boundsStream.lineEnd = boundsRingEnd;
16567       deltaSum = new Adder();
16568       areaStream.polygonStart();
16569     },
16570     polygonEnd: function() {
16571       areaStream.polygonEnd();
16572       boundsStream.point = boundsPoint;
16573       boundsStream.lineStart = boundsLineStart;
16574       boundsStream.lineEnd = boundsLineEnd;
16575       if (areaRingSum < 0)
16576         lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
16577       else if (deltaSum > epsilon)
16578         phi1 = 90;
16579       else if (deltaSum < -epsilon)
16580         phi0 = -90;
16581       range2[0] = lambda02, range2[1] = lambda1;
16582     },
16583     sphere: function() {
16584       lambda02 = -(lambda1 = 180), phi0 = -(phi1 = 90);
16585     }
16586   };
16587   function boundsPoint(lambda, phi) {
16588     ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
16589     if (phi < phi0)
16590       phi0 = phi;
16591     if (phi > phi1)
16592       phi1 = phi;
16593   }
16594   function linePoint(lambda, phi) {
16595     var p2 = cartesian([lambda * radians, phi * radians]);
16596     if (p0) {
16597       var normal = cartesianCross(p0, p2), equatorial = [normal[1], -normal[0], 0], inflection = cartesianCross(equatorial, normal);
16598       cartesianNormalizeInPlace(inflection);
16599       inflection = spherical(inflection);
16600       var delta = lambda - lambda2, sign2 = delta > 0 ? 1 : -1, lambdai = inflection[0] * degrees * sign2, phii, antimeridian = abs(delta) > 180;
16601       if (antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
16602         phii = inflection[1] * degrees;
16603         if (phii > phi1)
16604           phi1 = phii;
16605       } else if (lambdai = (lambdai + 360) % 360 - 180, antimeridian ^ (sign2 * lambda2 < lambdai && lambdai < sign2 * lambda)) {
16606         phii = -inflection[1] * degrees;
16607         if (phii < phi0)
16608           phi0 = phii;
16609       } else {
16610         if (phi < phi0)
16611           phi0 = phi;
16612         if (phi > phi1)
16613           phi1 = phi;
16614       }
16615       if (antimeridian) {
16616         if (lambda < lambda2) {
16617           if (angle(lambda02, lambda) > angle(lambda02, lambda1))
16618             lambda1 = lambda;
16619         } else {
16620           if (angle(lambda, lambda1) > angle(lambda02, lambda1))
16621             lambda02 = lambda;
16622         }
16623       } else {
16624         if (lambda1 >= lambda02) {
16625           if (lambda < lambda02)
16626             lambda02 = lambda;
16627           if (lambda > lambda1)
16628             lambda1 = lambda;
16629         } else {
16630           if (lambda > lambda2) {
16631             if (angle(lambda02, lambda) > angle(lambda02, lambda1))
16632               lambda1 = lambda;
16633           } else {
16634             if (angle(lambda, lambda1) > angle(lambda02, lambda1))
16635               lambda02 = lambda;
16636           }
16637         }
16638       }
16639     } else {
16640       ranges.push(range2 = [lambda02 = lambda, lambda1 = lambda]);
16641     }
16642     if (phi < phi0)
16643       phi0 = phi;
16644     if (phi > phi1)
16645       phi1 = phi;
16646     p0 = p2, lambda2 = lambda;
16647   }
16648   function boundsLineStart() {
16649     boundsStream.point = linePoint;
16650   }
16651   function boundsLineEnd() {
16652     range2[0] = lambda02, range2[1] = lambda1;
16653     boundsStream.point = boundsPoint;
16654     p0 = null;
16655   }
16656   function boundsRingPoint(lambda, phi) {
16657     if (p0) {
16658       var delta = lambda - lambda2;
16659       deltaSum.add(abs(delta) > 180 ? delta + (delta > 0 ? 360 : -360) : delta);
16660     } else {
16661       lambda002 = lambda, phi002 = phi;
16662     }
16663     areaStream.point(lambda, phi);
16664     linePoint(lambda, phi);
16665   }
16666   function boundsRingStart() {
16667     areaStream.lineStart();
16668   }
16669   function boundsRingEnd() {
16670     boundsRingPoint(lambda002, phi002);
16671     areaStream.lineEnd();
16672     if (abs(deltaSum) > epsilon)
16673       lambda02 = -(lambda1 = 180);
16674     range2[0] = lambda02, range2[1] = lambda1;
16675     p0 = null;
16676   }
16677   function angle(lambda04, lambda12) {
16678     return (lambda12 -= lambda04) < 0 ? lambda12 + 360 : lambda12;
16679   }
16680   function rangeCompare(a2, b2) {
16681     return a2[0] - b2[0];
16682   }
16683   function rangeContains(range3, x2) {
16684     return range3[0] <= range3[1] ? range3[0] <= x2 && x2 <= range3[1] : x2 < range3[0] || range3[1] < x2;
16685   }
16686   function bounds_default(feature3) {
16687     var i3, n3, a2, b2, merged, deltaMax, delta;
16688     phi1 = lambda1 = -(lambda02 = phi0 = Infinity);
16689     ranges = [];
16690     stream_default(feature3, boundsStream);
16691     if (n3 = ranges.length) {
16692       ranges.sort(rangeCompare);
16693       for (i3 = 1, a2 = ranges[0], merged = [a2]; i3 < n3; ++i3) {
16694         b2 = ranges[i3];
16695         if (rangeContains(a2, b2[0]) || rangeContains(a2, b2[1])) {
16696           if (angle(a2[0], b2[1]) > angle(a2[0], a2[1]))
16697             a2[1] = b2[1];
16698           if (angle(b2[0], a2[1]) > angle(a2[0], a2[1]))
16699             a2[0] = b2[0];
16700         } else {
16701           merged.push(a2 = b2);
16702         }
16703       }
16704       for (deltaMax = -Infinity, n3 = merged.length - 1, i3 = 0, a2 = merged[n3]; i3 <= n3; a2 = b2, ++i3) {
16705         b2 = merged[i3];
16706         if ((delta = angle(a2[1], b2[0])) > deltaMax)
16707           deltaMax = delta, lambda02 = b2[0], lambda1 = a2[1];
16708       }
16709     }
16710     ranges = range2 = null;
16711     return lambda02 === Infinity || phi0 === Infinity ? [[NaN, NaN], [NaN, NaN]] : [[lambda02, phi0], [lambda1, phi1]];
16712   }
16713
16714   // node_modules/d3-geo/src/compose.js
16715   function compose_default(a2, b2) {
16716     function compose(x2, y2) {
16717       return x2 = a2(x2, y2), b2(x2[0], x2[1]);
16718     }
16719     if (a2.invert && b2.invert)
16720       compose.invert = function(x2, y2) {
16721         return x2 = b2.invert(x2, y2), x2 && a2.invert(x2[0], x2[1]);
16722       };
16723     return compose;
16724   }
16725
16726   // node_modules/d3-geo/src/rotation.js
16727   function rotationIdentity(lambda, phi) {
16728     return [abs(lambda) > pi ? lambda + Math.round(-lambda / tau) * tau : lambda, phi];
16729   }
16730   rotationIdentity.invert = rotationIdentity;
16731   function rotateRadians(deltaLambda, deltaPhi, deltaGamma) {
16732     return (deltaLambda %= tau) ? deltaPhi || deltaGamma ? compose_default(rotationLambda(deltaLambda), rotationPhiGamma(deltaPhi, deltaGamma)) : rotationLambda(deltaLambda) : deltaPhi || deltaGamma ? rotationPhiGamma(deltaPhi, deltaGamma) : rotationIdentity;
16733   }
16734   function forwardRotationLambda(deltaLambda) {
16735     return function(lambda, phi) {
16736       return lambda += deltaLambda, [lambda > pi ? lambda - tau : lambda < -pi ? lambda + tau : lambda, phi];
16737     };
16738   }
16739   function rotationLambda(deltaLambda) {
16740     var rotation = forwardRotationLambda(deltaLambda);
16741     rotation.invert = forwardRotationLambda(-deltaLambda);
16742     return rotation;
16743   }
16744   function rotationPhiGamma(deltaPhi, deltaGamma) {
16745     var cosDeltaPhi = cos(deltaPhi), sinDeltaPhi = sin(deltaPhi), cosDeltaGamma = cos(deltaGamma), sinDeltaGamma = sin(deltaGamma);
16746     function rotation(lambda, phi) {
16747       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaPhi + x2 * sinDeltaPhi;
16748       return [
16749         atan2(y2 * cosDeltaGamma - k2 * sinDeltaGamma, x2 * cosDeltaPhi - z2 * sinDeltaPhi),
16750         asin(k2 * cosDeltaGamma + y2 * sinDeltaGamma)
16751       ];
16752     }
16753     rotation.invert = function(lambda, phi) {
16754       var cosPhi = cos(phi), x2 = cos(lambda) * cosPhi, y2 = sin(lambda) * cosPhi, z2 = sin(phi), k2 = z2 * cosDeltaGamma - y2 * sinDeltaGamma;
16755       return [
16756         atan2(y2 * cosDeltaGamma + z2 * sinDeltaGamma, x2 * cosDeltaPhi + k2 * sinDeltaPhi),
16757         asin(k2 * cosDeltaPhi - x2 * sinDeltaPhi)
16758       ];
16759     };
16760     return rotation;
16761   }
16762   function rotation_default(rotate) {
16763     rotate = rotateRadians(rotate[0] * radians, rotate[1] * radians, rotate.length > 2 ? rotate[2] * radians : 0);
16764     function forward(coordinates) {
16765       coordinates = rotate(coordinates[0] * radians, coordinates[1] * radians);
16766       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
16767     }
16768     forward.invert = function(coordinates) {
16769       coordinates = rotate.invert(coordinates[0] * radians, coordinates[1] * radians);
16770       return coordinates[0] *= degrees, coordinates[1] *= degrees, coordinates;
16771     };
16772     return forward;
16773   }
16774
16775   // node_modules/d3-geo/src/circle.js
16776   function circleStream(stream, radius, delta, direction, t0, t1) {
16777     if (!delta)
16778       return;
16779     var cosRadius = cos(radius), sinRadius = sin(radius), step = direction * delta;
16780     if (t0 == null) {
16781       t0 = radius + direction * tau;
16782       t1 = radius - step / 2;
16783     } else {
16784       t0 = circleRadius(cosRadius, t0);
16785       t1 = circleRadius(cosRadius, t1);
16786       if (direction > 0 ? t0 < t1 : t0 > t1)
16787         t0 += direction * tau;
16788     }
16789     for (var point2, t2 = t0; direction > 0 ? t2 > t1 : t2 < t1; t2 -= step) {
16790       point2 = spherical([cosRadius, -sinRadius * cos(t2), -sinRadius * sin(t2)]);
16791       stream.point(point2[0], point2[1]);
16792     }
16793   }
16794   function circleRadius(cosRadius, point2) {
16795     point2 = cartesian(point2), point2[0] -= cosRadius;
16796     cartesianNormalizeInPlace(point2);
16797     var radius = acos(-point2[1]);
16798     return ((-point2[2] < 0 ? -radius : radius) + tau - epsilon) % tau;
16799   }
16800
16801   // node_modules/d3-geo/src/clip/buffer.js
16802   function buffer_default() {
16803     var lines = [], line;
16804     return {
16805       point: function(x2, y2, m2) {
16806         line.push([x2, y2, m2]);
16807       },
16808       lineStart: function() {
16809         lines.push(line = []);
16810       },
16811       lineEnd: noop,
16812       rejoin: function() {
16813         if (lines.length > 1)
16814           lines.push(lines.pop().concat(lines.shift()));
16815       },
16816       result: function() {
16817         var result = lines;
16818         lines = [];
16819         line = null;
16820         return result;
16821       }
16822     };
16823   }
16824
16825   // node_modules/d3-geo/src/pointEqual.js
16826   function pointEqual_default(a2, b2) {
16827     return abs(a2[0] - b2[0]) < epsilon && abs(a2[1] - b2[1]) < epsilon;
16828   }
16829
16830   // node_modules/d3-geo/src/clip/rejoin.js
16831   function Intersection(point2, points, other, entry) {
16832     this.x = point2;
16833     this.z = points;
16834     this.o = other;
16835     this.e = entry;
16836     this.v = false;
16837     this.n = this.p = null;
16838   }
16839   function rejoin_default(segments, compareIntersection2, startInside, interpolate, stream) {
16840     var subject = [], clip = [], i3, n3;
16841     segments.forEach(function(segment) {
16842       if ((n4 = segment.length - 1) <= 0)
16843         return;
16844       var n4, p02 = segment[0], p1 = segment[n4], x2;
16845       if (pointEqual_default(p02, p1)) {
16846         if (!p02[2] && !p1[2]) {
16847           stream.lineStart();
16848           for (i3 = 0; i3 < n4; ++i3)
16849             stream.point((p02 = segment[i3])[0], p02[1]);
16850           stream.lineEnd();
16851           return;
16852         }
16853         p1[0] += 2 * epsilon;
16854       }
16855       subject.push(x2 = new Intersection(p02, segment, null, true));
16856       clip.push(x2.o = new Intersection(p02, null, x2, false));
16857       subject.push(x2 = new Intersection(p1, segment, null, false));
16858       clip.push(x2.o = new Intersection(p1, null, x2, true));
16859     });
16860     if (!subject.length)
16861       return;
16862     clip.sort(compareIntersection2);
16863     link(subject);
16864     link(clip);
16865     for (i3 = 0, n3 = clip.length; i3 < n3; ++i3) {
16866       clip[i3].e = startInside = !startInside;
16867     }
16868     var start2 = subject[0], points, point2;
16869     while (1) {
16870       var current = start2, isSubject = true;
16871       while (current.v)
16872         if ((current = current.n) === start2)
16873           return;
16874       points = current.z;
16875       stream.lineStart();
16876       do {
16877         current.v = current.o.v = true;
16878         if (current.e) {
16879           if (isSubject) {
16880             for (i3 = 0, n3 = points.length; i3 < n3; ++i3)
16881               stream.point((point2 = points[i3])[0], point2[1]);
16882           } else {
16883             interpolate(current.x, current.n.x, 1, stream);
16884           }
16885           current = current.n;
16886         } else {
16887           if (isSubject) {
16888             points = current.p.z;
16889             for (i3 = points.length - 1; i3 >= 0; --i3)
16890               stream.point((point2 = points[i3])[0], point2[1]);
16891           } else {
16892             interpolate(current.x, current.p.x, -1, stream);
16893           }
16894           current = current.p;
16895         }
16896         current = current.o;
16897         points = current.z;
16898         isSubject = !isSubject;
16899       } while (!current.v);
16900       stream.lineEnd();
16901     }
16902   }
16903   function link(array2) {
16904     if (!(n3 = array2.length))
16905       return;
16906     var n3, i3 = 0, a2 = array2[0], b2;
16907     while (++i3 < n3) {
16908       a2.n = b2 = array2[i3];
16909       b2.p = a2;
16910       a2 = b2;
16911     }
16912     a2.n = b2 = array2[0];
16913     b2.p = a2;
16914   }
16915
16916   // node_modules/d3-geo/src/polygonContains.js
16917   function longitude(point2) {
16918     return abs(point2[0]) <= pi ? point2[0] : sign(point2[0]) * ((abs(point2[0]) + pi) % tau - pi);
16919   }
16920   function polygonContains_default(polygon2, point2) {
16921     var lambda = longitude(point2), phi = point2[1], sinPhi = sin(phi), normal = [sin(lambda), -cos(lambda), 0], angle2 = 0, winding = 0;
16922     var sum = new Adder();
16923     if (sinPhi === 1)
16924       phi = halfPi + epsilon;
16925     else if (sinPhi === -1)
16926       phi = -halfPi - epsilon;
16927     for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
16928       if (!(m2 = (ring = polygon2[i3]).length))
16929         continue;
16930       var ring, m2, point0 = ring[m2 - 1], lambda04 = longitude(point0), phi02 = point0[1] / 2 + quarterPi, sinPhi03 = sin(phi02), cosPhi03 = cos(phi02);
16931       for (var j2 = 0; j2 < m2; ++j2, lambda04 = lambda12, sinPhi03 = sinPhi1, cosPhi03 = cosPhi1, point0 = point1) {
16932         var point1 = ring[j2], lambda12 = longitude(point1), phi12 = point1[1] / 2 + quarterPi, sinPhi1 = sin(phi12), cosPhi1 = cos(phi12), delta = lambda12 - lambda04, sign2 = delta >= 0 ? 1 : -1, absDelta = sign2 * delta, antimeridian = absDelta > pi, k2 = sinPhi03 * sinPhi1;
16933         sum.add(atan2(k2 * sign2 * sin(absDelta), cosPhi03 * cosPhi1 + k2 * cos(absDelta)));
16934         angle2 += antimeridian ? delta + sign2 * tau : delta;
16935         if (antimeridian ^ lambda04 >= lambda ^ lambda12 >= lambda) {
16936           var arc = cartesianCross(cartesian(point0), cartesian(point1));
16937           cartesianNormalizeInPlace(arc);
16938           var intersection2 = cartesianCross(normal, arc);
16939           cartesianNormalizeInPlace(intersection2);
16940           var phiArc = (antimeridian ^ delta >= 0 ? -1 : 1) * asin(intersection2[2]);
16941           if (phi > phiArc || phi === phiArc && (arc[0] || arc[1])) {
16942             winding += antimeridian ^ delta >= 0 ? 1 : -1;
16943           }
16944         }
16945       }
16946     }
16947     return (angle2 < -epsilon || angle2 < epsilon && sum < -epsilon2) ^ winding & 1;
16948   }
16949
16950   // node_modules/d3-geo/src/clip/index.js
16951   function clip_default(pointVisible, clipLine, interpolate, start2) {
16952     return function(sink) {
16953       var line = clipLine(sink), ringBuffer = buffer_default(), ringSink = clipLine(ringBuffer), polygonStarted = false, polygon2, segments, ring;
16954       var clip = {
16955         point: point2,
16956         lineStart,
16957         lineEnd,
16958         polygonStart: function() {
16959           clip.point = pointRing;
16960           clip.lineStart = ringStart;
16961           clip.lineEnd = ringEnd;
16962           segments = [];
16963           polygon2 = [];
16964         },
16965         polygonEnd: function() {
16966           clip.point = point2;
16967           clip.lineStart = lineStart;
16968           clip.lineEnd = lineEnd;
16969           segments = merge(segments);
16970           var startInside = polygonContains_default(polygon2, start2);
16971           if (segments.length) {
16972             if (!polygonStarted)
16973               sink.polygonStart(), polygonStarted = true;
16974             rejoin_default(segments, compareIntersection, startInside, interpolate, sink);
16975           } else if (startInside) {
16976             if (!polygonStarted)
16977               sink.polygonStart(), polygonStarted = true;
16978             sink.lineStart();
16979             interpolate(null, null, 1, sink);
16980             sink.lineEnd();
16981           }
16982           if (polygonStarted)
16983             sink.polygonEnd(), polygonStarted = false;
16984           segments = polygon2 = null;
16985         },
16986         sphere: function() {
16987           sink.polygonStart();
16988           sink.lineStart();
16989           interpolate(null, null, 1, sink);
16990           sink.lineEnd();
16991           sink.polygonEnd();
16992         }
16993       };
16994       function point2(lambda, phi) {
16995         if (pointVisible(lambda, phi))
16996           sink.point(lambda, phi);
16997       }
16998       function pointLine(lambda, phi) {
16999         line.point(lambda, phi);
17000       }
17001       function lineStart() {
17002         clip.point = pointLine;
17003         line.lineStart();
17004       }
17005       function lineEnd() {
17006         clip.point = point2;
17007         line.lineEnd();
17008       }
17009       function pointRing(lambda, phi) {
17010         ring.push([lambda, phi]);
17011         ringSink.point(lambda, phi);
17012       }
17013       function ringStart() {
17014         ringSink.lineStart();
17015         ring = [];
17016       }
17017       function ringEnd() {
17018         pointRing(ring[0][0], ring[0][1]);
17019         ringSink.lineEnd();
17020         var clean2 = ringSink.clean(), ringSegments = ringBuffer.result(), i3, n3 = ringSegments.length, m2, segment, point3;
17021         ring.pop();
17022         polygon2.push(ring);
17023         ring = null;
17024         if (!n3)
17025           return;
17026         if (clean2 & 1) {
17027           segment = ringSegments[0];
17028           if ((m2 = segment.length - 1) > 0) {
17029             if (!polygonStarted)
17030               sink.polygonStart(), polygonStarted = true;
17031             sink.lineStart();
17032             for (i3 = 0; i3 < m2; ++i3)
17033               sink.point((point3 = segment[i3])[0], point3[1]);
17034             sink.lineEnd();
17035           }
17036           return;
17037         }
17038         if (n3 > 1 && clean2 & 2)
17039           ringSegments.push(ringSegments.pop().concat(ringSegments.shift()));
17040         segments.push(ringSegments.filter(validSegment));
17041       }
17042       return clip;
17043     };
17044   }
17045   function validSegment(segment) {
17046     return segment.length > 1;
17047   }
17048   function compareIntersection(a2, b2) {
17049     return ((a2 = a2.x)[0] < 0 ? a2[1] - halfPi - epsilon : halfPi - a2[1]) - ((b2 = b2.x)[0] < 0 ? b2[1] - halfPi - epsilon : halfPi - b2[1]);
17050   }
17051
17052   // node_modules/d3-geo/src/clip/antimeridian.js
17053   var antimeridian_default = clip_default(
17054     function() {
17055       return true;
17056     },
17057     clipAntimeridianLine,
17058     clipAntimeridianInterpolate,
17059     [-pi, -halfPi]
17060   );
17061   function clipAntimeridianLine(stream) {
17062     var lambda04 = NaN, phi02 = NaN, sign0 = NaN, clean2;
17063     return {
17064       lineStart: function() {
17065         stream.lineStart();
17066         clean2 = 1;
17067       },
17068       point: function(lambda12, phi12) {
17069         var sign1 = lambda12 > 0 ? pi : -pi, delta = abs(lambda12 - lambda04);
17070         if (abs(delta - pi) < epsilon) {
17071           stream.point(lambda04, phi02 = (phi02 + phi12) / 2 > 0 ? halfPi : -halfPi);
17072           stream.point(sign0, phi02);
17073           stream.lineEnd();
17074           stream.lineStart();
17075           stream.point(sign1, phi02);
17076           stream.point(lambda12, phi02);
17077           clean2 = 0;
17078         } else if (sign0 !== sign1 && delta >= pi) {
17079           if (abs(lambda04 - sign0) < epsilon)
17080             lambda04 -= sign0 * epsilon;
17081           if (abs(lambda12 - sign1) < epsilon)
17082             lambda12 -= sign1 * epsilon;
17083           phi02 = clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12);
17084           stream.point(sign0, phi02);
17085           stream.lineEnd();
17086           stream.lineStart();
17087           stream.point(sign1, phi02);
17088           clean2 = 0;
17089         }
17090         stream.point(lambda04 = lambda12, phi02 = phi12);
17091         sign0 = sign1;
17092       },
17093       lineEnd: function() {
17094         stream.lineEnd();
17095         lambda04 = phi02 = NaN;
17096       },
17097       clean: function() {
17098         return 2 - clean2;
17099       }
17100     };
17101   }
17102   function clipAntimeridianIntersect(lambda04, phi02, lambda12, phi12) {
17103     var cosPhi03, cosPhi1, sinLambda0Lambda1 = sin(lambda04 - lambda12);
17104     return abs(sinLambda0Lambda1) > epsilon ? atan((sin(phi02) * (cosPhi1 = cos(phi12)) * sin(lambda12) - sin(phi12) * (cosPhi03 = cos(phi02)) * sin(lambda04)) / (cosPhi03 * cosPhi1 * sinLambda0Lambda1)) : (phi02 + phi12) / 2;
17105   }
17106   function clipAntimeridianInterpolate(from, to, direction, stream) {
17107     var phi;
17108     if (from == null) {
17109       phi = direction * halfPi;
17110       stream.point(-pi, phi);
17111       stream.point(0, phi);
17112       stream.point(pi, phi);
17113       stream.point(pi, 0);
17114       stream.point(pi, -phi);
17115       stream.point(0, -phi);
17116       stream.point(-pi, -phi);
17117       stream.point(-pi, 0);
17118       stream.point(-pi, phi);
17119     } else if (abs(from[0] - to[0]) > epsilon) {
17120       var lambda = from[0] < to[0] ? pi : -pi;
17121       phi = direction * lambda / 2;
17122       stream.point(-lambda, phi);
17123       stream.point(0, phi);
17124       stream.point(lambda, phi);
17125     } else {
17126       stream.point(to[0], to[1]);
17127     }
17128   }
17129
17130   // node_modules/d3-geo/src/clip/circle.js
17131   function circle_default(radius) {
17132     var cr = cos(radius), delta = 6 * radians, smallRadius = cr > 0, notHemisphere = abs(cr) > epsilon;
17133     function interpolate(from, to, direction, stream) {
17134       circleStream(stream, radius, delta, direction, from, to);
17135     }
17136     function visible(lambda, phi) {
17137       return cos(lambda) * cos(phi) > cr;
17138     }
17139     function clipLine(stream) {
17140       var point0, c0, v0, v00, clean2;
17141       return {
17142         lineStart: function() {
17143           v00 = v0 = false;
17144           clean2 = 1;
17145         },
17146         point: function(lambda, phi) {
17147           var point1 = [lambda, phi], point2, v2 = visible(lambda, phi), c2 = smallRadius ? v2 ? 0 : code(lambda, phi) : v2 ? code(lambda + (lambda < 0 ? pi : -pi), phi) : 0;
17148           if (!point0 && (v00 = v0 = v2))
17149             stream.lineStart();
17150           if (v2 !== v0) {
17151             point2 = intersect2(point0, point1);
17152             if (!point2 || pointEqual_default(point0, point2) || pointEqual_default(point1, point2))
17153               point1[2] = 1;
17154           }
17155           if (v2 !== v0) {
17156             clean2 = 0;
17157             if (v2) {
17158               stream.lineStart();
17159               point2 = intersect2(point1, point0);
17160               stream.point(point2[0], point2[1]);
17161             } else {
17162               point2 = intersect2(point0, point1);
17163               stream.point(point2[0], point2[1], 2);
17164               stream.lineEnd();
17165             }
17166             point0 = point2;
17167           } else if (notHemisphere && point0 && smallRadius ^ v2) {
17168             var t2;
17169             if (!(c2 & c0) && (t2 = intersect2(point1, point0, true))) {
17170               clean2 = 0;
17171               if (smallRadius) {
17172                 stream.lineStart();
17173                 stream.point(t2[0][0], t2[0][1]);
17174                 stream.point(t2[1][0], t2[1][1]);
17175                 stream.lineEnd();
17176               } else {
17177                 stream.point(t2[1][0], t2[1][1]);
17178                 stream.lineEnd();
17179                 stream.lineStart();
17180                 stream.point(t2[0][0], t2[0][1], 3);
17181               }
17182             }
17183           }
17184           if (v2 && (!point0 || !pointEqual_default(point0, point1))) {
17185             stream.point(point1[0], point1[1]);
17186           }
17187           point0 = point1, v0 = v2, c0 = c2;
17188         },
17189         lineEnd: function() {
17190           if (v0)
17191             stream.lineEnd();
17192           point0 = null;
17193         },
17194         // Rejoin first and last segments if there were intersections and the first
17195         // and last points were visible.
17196         clean: function() {
17197           return clean2 | (v00 && v0) << 1;
17198         }
17199       };
17200     }
17201     function intersect2(a2, b2, two) {
17202       var pa = cartesian(a2), pb = cartesian(b2);
17203       var n1 = [1, 0, 0], n22 = cartesianCross(pa, pb), n2n2 = cartesianDot(n22, n22), n1n2 = n22[0], determinant = n2n2 - n1n2 * n1n2;
17204       if (!determinant)
17205         return !two && a2;
17206       var c1 = cr * n2n2 / determinant, c2 = -cr * n1n2 / determinant, n1xn2 = cartesianCross(n1, n22), A2 = cartesianScale(n1, c1), B2 = cartesianScale(n22, c2);
17207       cartesianAddInPlace(A2, B2);
17208       var u2 = n1xn2, w2 = cartesianDot(A2, u2), uu = cartesianDot(u2, u2), t2 = w2 * w2 - uu * (cartesianDot(A2, A2) - 1);
17209       if (t2 < 0)
17210         return;
17211       var t3 = sqrt(t2), q2 = cartesianScale(u2, (-w2 - t3) / uu);
17212       cartesianAddInPlace(q2, A2);
17213       q2 = spherical(q2);
17214       if (!two)
17215         return q2;
17216       var lambda04 = a2[0], lambda12 = b2[0], phi02 = a2[1], phi12 = b2[1], z2;
17217       if (lambda12 < lambda04)
17218         z2 = lambda04, lambda04 = lambda12, lambda12 = z2;
17219       var delta2 = lambda12 - lambda04, polar = abs(delta2 - pi) < epsilon, meridian = polar || delta2 < epsilon;
17220       if (!polar && phi12 < phi02)
17221         z2 = phi02, phi02 = phi12, phi12 = z2;
17222       if (meridian ? polar ? phi02 + phi12 > 0 ^ q2[1] < (abs(q2[0] - lambda04) < epsilon ? phi02 : phi12) : phi02 <= q2[1] && q2[1] <= phi12 : delta2 > pi ^ (lambda04 <= q2[0] && q2[0] <= lambda12)) {
17223         var q1 = cartesianScale(u2, (-w2 + t3) / uu);
17224         cartesianAddInPlace(q1, A2);
17225         return [q2, spherical(q1)];
17226       }
17227     }
17228     function code(lambda, phi) {
17229       var r2 = smallRadius ? radius : pi - radius, code2 = 0;
17230       if (lambda < -r2)
17231         code2 |= 1;
17232       else if (lambda > r2)
17233         code2 |= 2;
17234       if (phi < -r2)
17235         code2 |= 4;
17236       else if (phi > r2)
17237         code2 |= 8;
17238       return code2;
17239     }
17240     return clip_default(visible, clipLine, interpolate, smallRadius ? [0, -radius] : [-pi, radius - pi]);
17241   }
17242
17243   // node_modules/d3-geo/src/clip/line.js
17244   function line_default(a2, b2, x05, y05, x12, y12) {
17245     var ax = a2[0], ay = a2[1], bx = b2[0], by = b2[1], t0 = 0, t1 = 1, dx = bx - ax, dy = by - ay, r2;
17246     r2 = x05 - ax;
17247     if (!dx && r2 > 0)
17248       return;
17249     r2 /= dx;
17250     if (dx < 0) {
17251       if (r2 < t0)
17252         return;
17253       if (r2 < t1)
17254         t1 = r2;
17255     } else if (dx > 0) {
17256       if (r2 > t1)
17257         return;
17258       if (r2 > t0)
17259         t0 = r2;
17260     }
17261     r2 = x12 - ax;
17262     if (!dx && r2 < 0)
17263       return;
17264     r2 /= dx;
17265     if (dx < 0) {
17266       if (r2 > t1)
17267         return;
17268       if (r2 > t0)
17269         t0 = r2;
17270     } else if (dx > 0) {
17271       if (r2 < t0)
17272         return;
17273       if (r2 < t1)
17274         t1 = r2;
17275     }
17276     r2 = y05 - ay;
17277     if (!dy && r2 > 0)
17278       return;
17279     r2 /= dy;
17280     if (dy < 0) {
17281       if (r2 < t0)
17282         return;
17283       if (r2 < t1)
17284         t1 = r2;
17285     } else if (dy > 0) {
17286       if (r2 > t1)
17287         return;
17288       if (r2 > t0)
17289         t0 = r2;
17290     }
17291     r2 = y12 - ay;
17292     if (!dy && r2 < 0)
17293       return;
17294     r2 /= dy;
17295     if (dy < 0) {
17296       if (r2 > t1)
17297         return;
17298       if (r2 > t0)
17299         t0 = r2;
17300     } else if (dy > 0) {
17301       if (r2 < t0)
17302         return;
17303       if (r2 < t1)
17304         t1 = r2;
17305     }
17306     if (t0 > 0)
17307       a2[0] = ax + t0 * dx, a2[1] = ay + t0 * dy;
17308     if (t1 < 1)
17309       b2[0] = ax + t1 * dx, b2[1] = ay + t1 * dy;
17310     return true;
17311   }
17312
17313   // node_modules/d3-geo/src/clip/rectangle.js
17314   var clipMax = 1e9;
17315   var clipMin = -clipMax;
17316   function clipRectangle(x05, y05, x12, y12) {
17317     function visible(x2, y2) {
17318       return x05 <= x2 && x2 <= x12 && y05 <= y2 && y2 <= y12;
17319     }
17320     function interpolate(from, to, direction, stream) {
17321       var a2 = 0, a1 = 0;
17322       if (from == null || (a2 = corner(from, direction)) !== (a1 = corner(to, direction)) || comparePoint(from, to) < 0 ^ direction > 0) {
17323         do
17324           stream.point(a2 === 0 || a2 === 3 ? x05 : x12, a2 > 1 ? y12 : y05);
17325         while ((a2 = (a2 + direction + 4) % 4) !== a1);
17326       } else {
17327         stream.point(to[0], to[1]);
17328       }
17329     }
17330     function corner(p2, direction) {
17331       return abs(p2[0] - x05) < epsilon ? direction > 0 ? 0 : 3 : abs(p2[0] - x12) < epsilon ? direction > 0 ? 2 : 1 : abs(p2[1] - y05) < epsilon ? direction > 0 ? 1 : 0 : direction > 0 ? 3 : 2;
17332     }
17333     function compareIntersection2(a2, b2) {
17334       return comparePoint(a2.x, b2.x);
17335     }
17336     function comparePoint(a2, b2) {
17337       var ca = corner(a2, 1), cb = corner(b2, 1);
17338       return ca !== cb ? ca - cb : ca === 0 ? b2[1] - a2[1] : ca === 1 ? a2[0] - b2[0] : ca === 2 ? a2[1] - b2[1] : b2[0] - a2[0];
17339     }
17340     return function(stream) {
17341       var activeStream = stream, bufferStream = buffer_default(), segments, polygon2, ring, x__, y__, v__, x_, y_, v_, first, clean2;
17342       var clipStream = {
17343         point: point2,
17344         lineStart,
17345         lineEnd,
17346         polygonStart,
17347         polygonEnd
17348       };
17349       function point2(x2, y2) {
17350         if (visible(x2, y2))
17351           activeStream.point(x2, y2);
17352       }
17353       function polygonInside() {
17354         var winding = 0;
17355         for (var i3 = 0, n3 = polygon2.length; i3 < n3; ++i3) {
17356           for (var ring2 = polygon2[i3], j2 = 1, m2 = ring2.length, point3 = ring2[0], a0, a1, b0 = point3[0], b1 = point3[1]; j2 < m2; ++j2) {
17357             a0 = b0, a1 = b1, point3 = ring2[j2], b0 = point3[0], b1 = point3[1];
17358             if (a1 <= y12) {
17359               if (b1 > y12 && (b0 - a0) * (y12 - a1) > (b1 - a1) * (x05 - a0))
17360                 ++winding;
17361             } else {
17362               if (b1 <= y12 && (b0 - a0) * (y12 - a1) < (b1 - a1) * (x05 - a0))
17363                 --winding;
17364             }
17365           }
17366         }
17367         return winding;
17368       }
17369       function polygonStart() {
17370         activeStream = bufferStream, segments = [], polygon2 = [], clean2 = true;
17371       }
17372       function polygonEnd() {
17373         var startInside = polygonInside(), cleanInside = clean2 && startInside, visible2 = (segments = merge(segments)).length;
17374         if (cleanInside || visible2) {
17375           stream.polygonStart();
17376           if (cleanInside) {
17377             stream.lineStart();
17378             interpolate(null, null, 1, stream);
17379             stream.lineEnd();
17380           }
17381           if (visible2) {
17382             rejoin_default(segments, compareIntersection2, startInside, interpolate, stream);
17383           }
17384           stream.polygonEnd();
17385         }
17386         activeStream = stream, segments = polygon2 = ring = null;
17387       }
17388       function lineStart() {
17389         clipStream.point = linePoint2;
17390         if (polygon2)
17391           polygon2.push(ring = []);
17392         first = true;
17393         v_ = false;
17394         x_ = y_ = NaN;
17395       }
17396       function lineEnd() {
17397         if (segments) {
17398           linePoint2(x__, y__);
17399           if (v__ && v_)
17400             bufferStream.rejoin();
17401           segments.push(bufferStream.result());
17402         }
17403         clipStream.point = point2;
17404         if (v_)
17405           activeStream.lineEnd();
17406       }
17407       function linePoint2(x2, y2) {
17408         var v2 = visible(x2, y2);
17409         if (polygon2)
17410           ring.push([x2, y2]);
17411         if (first) {
17412           x__ = x2, y__ = y2, v__ = v2;
17413           first = false;
17414           if (v2) {
17415             activeStream.lineStart();
17416             activeStream.point(x2, y2);
17417           }
17418         } else {
17419           if (v2 && v_)
17420             activeStream.point(x2, y2);
17421           else {
17422             var a2 = [x_ = Math.max(clipMin, Math.min(clipMax, x_)), y_ = Math.max(clipMin, Math.min(clipMax, y_))], b2 = [x2 = Math.max(clipMin, Math.min(clipMax, x2)), y2 = Math.max(clipMin, Math.min(clipMax, y2))];
17423             if (line_default(a2, b2, x05, y05, x12, y12)) {
17424               if (!v_) {
17425                 activeStream.lineStart();
17426                 activeStream.point(a2[0], a2[1]);
17427               }
17428               activeStream.point(b2[0], b2[1]);
17429               if (!v2)
17430                 activeStream.lineEnd();
17431               clean2 = false;
17432             } else if (v2) {
17433               activeStream.lineStart();
17434               activeStream.point(x2, y2);
17435               clean2 = false;
17436             }
17437           }
17438         }
17439         x_ = x2, y_ = y2, v_ = v2;
17440       }
17441       return clipStream;
17442     };
17443   }
17444
17445   // node_modules/d3-geo/src/length.js
17446   var lengthSum;
17447   var lambda03;
17448   var sinPhi02;
17449   var cosPhi02;
17450   var lengthStream = {
17451     sphere: noop,
17452     point: noop,
17453     lineStart: lengthLineStart,
17454     lineEnd: noop,
17455     polygonStart: noop,
17456     polygonEnd: noop
17457   };
17458   function lengthLineStart() {
17459     lengthStream.point = lengthPointFirst;
17460     lengthStream.lineEnd = lengthLineEnd;
17461   }
17462   function lengthLineEnd() {
17463     lengthStream.point = lengthStream.lineEnd = noop;
17464   }
17465   function lengthPointFirst(lambda, phi) {
17466     lambda *= radians, phi *= radians;
17467     lambda03 = lambda, sinPhi02 = sin(phi), cosPhi02 = cos(phi);
17468     lengthStream.point = lengthPoint;
17469   }
17470   function lengthPoint(lambda, phi) {
17471     lambda *= radians, phi *= radians;
17472     var sinPhi = sin(phi), cosPhi = cos(phi), delta = abs(lambda - lambda03), cosDelta = cos(delta), sinDelta = sin(delta), x2 = cosPhi * sinDelta, y2 = cosPhi02 * sinPhi - sinPhi02 * cosPhi * cosDelta, z2 = sinPhi02 * sinPhi + cosPhi02 * cosPhi * cosDelta;
17473     lengthSum.add(atan2(sqrt(x2 * x2 + y2 * y2), z2));
17474     lambda03 = lambda, sinPhi02 = sinPhi, cosPhi02 = cosPhi;
17475   }
17476   function length_default(object) {
17477     lengthSum = new Adder();
17478     stream_default(object, lengthStream);
17479     return +lengthSum;
17480   }
17481
17482   // node_modules/d3-geo/src/identity.js
17483   var identity_default = (x2) => x2;
17484
17485   // node_modules/d3-geo/src/path/area.js
17486   var areaSum2 = new Adder();
17487   var areaRingSum2 = new Adder();
17488   var x00;
17489   var y00;
17490   var x0;
17491   var y0;
17492   var areaStream2 = {
17493     point: noop,
17494     lineStart: noop,
17495     lineEnd: noop,
17496     polygonStart: function() {
17497       areaStream2.lineStart = areaRingStart2;
17498       areaStream2.lineEnd = areaRingEnd2;
17499     },
17500     polygonEnd: function() {
17501       areaStream2.lineStart = areaStream2.lineEnd = areaStream2.point = noop;
17502       areaSum2.add(abs(areaRingSum2));
17503       areaRingSum2 = new Adder();
17504     },
17505     result: function() {
17506       var area = areaSum2 / 2;
17507       areaSum2 = new Adder();
17508       return area;
17509     }
17510   };
17511   function areaRingStart2() {
17512     areaStream2.point = areaPointFirst2;
17513   }
17514   function areaPointFirst2(x2, y2) {
17515     areaStream2.point = areaPoint2;
17516     x00 = x0 = x2, y00 = y0 = y2;
17517   }
17518   function areaPoint2(x2, y2) {
17519     areaRingSum2.add(y0 * x2 - x0 * y2);
17520     x0 = x2, y0 = y2;
17521   }
17522   function areaRingEnd2() {
17523     areaPoint2(x00, y00);
17524   }
17525   var area_default2 = areaStream2;
17526
17527   // node_modules/d3-geo/src/path/bounds.js
17528   var x02 = Infinity;
17529   var y02 = x02;
17530   var x1 = -x02;
17531   var y1 = x1;
17532   var boundsStream2 = {
17533     point: boundsPoint2,
17534     lineStart: noop,
17535     lineEnd: noop,
17536     polygonStart: noop,
17537     polygonEnd: noop,
17538     result: function() {
17539       var bounds = [[x02, y02], [x1, y1]];
17540       x1 = y1 = -(y02 = x02 = Infinity);
17541       return bounds;
17542     }
17543   };
17544   function boundsPoint2(x2, y2) {
17545     if (x2 < x02)
17546       x02 = x2;
17547     if (x2 > x1)
17548       x1 = x2;
17549     if (y2 < y02)
17550       y02 = y2;
17551     if (y2 > y1)
17552       y1 = y2;
17553   }
17554   var bounds_default2 = boundsStream2;
17555
17556   // node_modules/d3-geo/src/path/centroid.js
17557   var X0 = 0;
17558   var Y0 = 0;
17559   var Z0 = 0;
17560   var X1 = 0;
17561   var Y1 = 0;
17562   var Z1 = 0;
17563   var X2 = 0;
17564   var Y2 = 0;
17565   var Z2 = 0;
17566   var x002;
17567   var y002;
17568   var x03;
17569   var y03;
17570   var centroidStream = {
17571     point: centroidPoint,
17572     lineStart: centroidLineStart,
17573     lineEnd: centroidLineEnd,
17574     polygonStart: function() {
17575       centroidStream.lineStart = centroidRingStart;
17576       centroidStream.lineEnd = centroidRingEnd;
17577     },
17578     polygonEnd: function() {
17579       centroidStream.point = centroidPoint;
17580       centroidStream.lineStart = centroidLineStart;
17581       centroidStream.lineEnd = centroidLineEnd;
17582     },
17583     result: function() {
17584       var centroid = Z2 ? [X2 / Z2, Y2 / Z2] : Z1 ? [X1 / Z1, Y1 / Z1] : Z0 ? [X0 / Z0, Y0 / Z0] : [NaN, NaN];
17585       X0 = Y0 = Z0 = X1 = Y1 = Z1 = X2 = Y2 = Z2 = 0;
17586       return centroid;
17587     }
17588   };
17589   function centroidPoint(x2, y2) {
17590     X0 += x2;
17591     Y0 += y2;
17592     ++Z0;
17593   }
17594   function centroidLineStart() {
17595     centroidStream.point = centroidPointFirstLine;
17596   }
17597   function centroidPointFirstLine(x2, y2) {
17598     centroidStream.point = centroidPointLine;
17599     centroidPoint(x03 = x2, y03 = y2);
17600   }
17601   function centroidPointLine(x2, y2) {
17602     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
17603     X1 += z2 * (x03 + x2) / 2;
17604     Y1 += z2 * (y03 + y2) / 2;
17605     Z1 += z2;
17606     centroidPoint(x03 = x2, y03 = y2);
17607   }
17608   function centroidLineEnd() {
17609     centroidStream.point = centroidPoint;
17610   }
17611   function centroidRingStart() {
17612     centroidStream.point = centroidPointFirstRing;
17613   }
17614   function centroidRingEnd() {
17615     centroidPointRing(x002, y002);
17616   }
17617   function centroidPointFirstRing(x2, y2) {
17618     centroidStream.point = centroidPointRing;
17619     centroidPoint(x002 = x03 = x2, y002 = y03 = y2);
17620   }
17621   function centroidPointRing(x2, y2) {
17622     var dx = x2 - x03, dy = y2 - y03, z2 = sqrt(dx * dx + dy * dy);
17623     X1 += z2 * (x03 + x2) / 2;
17624     Y1 += z2 * (y03 + y2) / 2;
17625     Z1 += z2;
17626     z2 = y03 * x2 - x03 * y2;
17627     X2 += z2 * (x03 + x2);
17628     Y2 += z2 * (y03 + y2);
17629     Z2 += z2 * 3;
17630     centroidPoint(x03 = x2, y03 = y2);
17631   }
17632   var centroid_default = centroidStream;
17633
17634   // node_modules/d3-geo/src/path/context.js
17635   function PathContext(context) {
17636     this._context = context;
17637   }
17638   PathContext.prototype = {
17639     _radius: 4.5,
17640     pointRadius: function(_2) {
17641       return this._radius = _2, this;
17642     },
17643     polygonStart: function() {
17644       this._line = 0;
17645     },
17646     polygonEnd: function() {
17647       this._line = NaN;
17648     },
17649     lineStart: function() {
17650       this._point = 0;
17651     },
17652     lineEnd: function() {
17653       if (this._line === 0)
17654         this._context.closePath();
17655       this._point = NaN;
17656     },
17657     point: function(x2, y2) {
17658       switch (this._point) {
17659         case 0: {
17660           this._context.moveTo(x2, y2);
17661           this._point = 1;
17662           break;
17663         }
17664         case 1: {
17665           this._context.lineTo(x2, y2);
17666           break;
17667         }
17668         default: {
17669           this._context.moveTo(x2 + this._radius, y2);
17670           this._context.arc(x2, y2, this._radius, 0, tau);
17671           break;
17672         }
17673       }
17674     },
17675     result: noop
17676   };
17677
17678   // node_modules/d3-geo/src/path/measure.js
17679   var lengthSum2 = new Adder();
17680   var lengthRing;
17681   var x003;
17682   var y003;
17683   var x04;
17684   var y04;
17685   var lengthStream2 = {
17686     point: noop,
17687     lineStart: function() {
17688       lengthStream2.point = lengthPointFirst2;
17689     },
17690     lineEnd: function() {
17691       if (lengthRing)
17692         lengthPoint2(x003, y003);
17693       lengthStream2.point = noop;
17694     },
17695     polygonStart: function() {
17696       lengthRing = true;
17697     },
17698     polygonEnd: function() {
17699       lengthRing = null;
17700     },
17701     result: function() {
17702       var length2 = +lengthSum2;
17703       lengthSum2 = new Adder();
17704       return length2;
17705     }
17706   };
17707   function lengthPointFirst2(x2, y2) {
17708     lengthStream2.point = lengthPoint2;
17709     x003 = x04 = x2, y003 = y04 = y2;
17710   }
17711   function lengthPoint2(x2, y2) {
17712     x04 -= x2, y04 -= y2;
17713     lengthSum2.add(sqrt(x04 * x04 + y04 * y04));
17714     x04 = x2, y04 = y2;
17715   }
17716   var measure_default = lengthStream2;
17717
17718   // node_modules/d3-geo/src/path/string.js
17719   function PathString() {
17720     this._string = [];
17721   }
17722   PathString.prototype = {
17723     _radius: 4.5,
17724     _circle: circle(4.5),
17725     pointRadius: function(_2) {
17726       if ((_2 = +_2) !== this._radius)
17727         this._radius = _2, this._circle = null;
17728       return this;
17729     },
17730     polygonStart: function() {
17731       this._line = 0;
17732     },
17733     polygonEnd: function() {
17734       this._line = NaN;
17735     },
17736     lineStart: function() {
17737       this._point = 0;
17738     },
17739     lineEnd: function() {
17740       if (this._line === 0)
17741         this._string.push("Z");
17742       this._point = NaN;
17743     },
17744     point: function(x2, y2) {
17745       switch (this._point) {
17746         case 0: {
17747           this._string.push("M", x2, ",", y2);
17748           this._point = 1;
17749           break;
17750         }
17751         case 1: {
17752           this._string.push("L", x2, ",", y2);
17753           break;
17754         }
17755         default: {
17756           if (this._circle == null)
17757             this._circle = circle(this._radius);
17758           this._string.push("M", x2, ",", y2, this._circle);
17759           break;
17760         }
17761       }
17762     },
17763     result: function() {
17764       if (this._string.length) {
17765         var result = this._string.join("");
17766         this._string = [];
17767         return result;
17768       } else {
17769         return null;
17770       }
17771     }
17772   };
17773   function circle(radius) {
17774     return "m0," + radius + "a" + radius + "," + radius + " 0 1,1 0," + -2 * radius + "a" + radius + "," + radius + " 0 1,1 0," + 2 * radius + "z";
17775   }
17776
17777   // node_modules/d3-geo/src/path/index.js
17778   function path_default(projection2, context) {
17779     var pointRadius = 4.5, projectionStream, contextStream;
17780     function path(object) {
17781       if (object) {
17782         if (typeof pointRadius === "function")
17783           contextStream.pointRadius(+pointRadius.apply(this, arguments));
17784         stream_default(object, projectionStream(contextStream));
17785       }
17786       return contextStream.result();
17787     }
17788     path.area = function(object) {
17789       stream_default(object, projectionStream(area_default2));
17790       return area_default2.result();
17791     };
17792     path.measure = function(object) {
17793       stream_default(object, projectionStream(measure_default));
17794       return measure_default.result();
17795     };
17796     path.bounds = function(object) {
17797       stream_default(object, projectionStream(bounds_default2));
17798       return bounds_default2.result();
17799     };
17800     path.centroid = function(object) {
17801       stream_default(object, projectionStream(centroid_default));
17802       return centroid_default.result();
17803     };
17804     path.projection = function(_2) {
17805       return arguments.length ? (projectionStream = _2 == null ? (projection2 = null, identity_default) : (projection2 = _2).stream, path) : projection2;
17806     };
17807     path.context = function(_2) {
17808       if (!arguments.length)
17809         return context;
17810       contextStream = _2 == null ? (context = null, new PathString()) : new PathContext(context = _2);
17811       if (typeof pointRadius !== "function")
17812         contextStream.pointRadius(pointRadius);
17813       return path;
17814     };
17815     path.pointRadius = function(_2) {
17816       if (!arguments.length)
17817         return pointRadius;
17818       pointRadius = typeof _2 === "function" ? _2 : (contextStream.pointRadius(+_2), +_2);
17819       return path;
17820     };
17821     return path.projection(projection2).context(context);
17822   }
17823
17824   // node_modules/d3-geo/src/transform.js
17825   function transform_default(methods2) {
17826     return {
17827       stream: transformer(methods2)
17828     };
17829   }
17830   function transformer(methods2) {
17831     return function(stream) {
17832       var s2 = new TransformStream();
17833       for (var key in methods2)
17834         s2[key] = methods2[key];
17835       s2.stream = stream;
17836       return s2;
17837     };
17838   }
17839   function TransformStream() {
17840   }
17841   TransformStream.prototype = {
17842     constructor: TransformStream,
17843     point: function(x2, y2) {
17844       this.stream.point(x2, y2);
17845     },
17846     sphere: function() {
17847       this.stream.sphere();
17848     },
17849     lineStart: function() {
17850       this.stream.lineStart();
17851     },
17852     lineEnd: function() {
17853       this.stream.lineEnd();
17854     },
17855     polygonStart: function() {
17856       this.stream.polygonStart();
17857     },
17858     polygonEnd: function() {
17859       this.stream.polygonEnd();
17860     }
17861   };
17862
17863   // node_modules/d3-geo/src/projection/fit.js
17864   function fit(projection2, fitBounds, object) {
17865     var clip = projection2.clipExtent && projection2.clipExtent();
17866     projection2.scale(150).translate([0, 0]);
17867     if (clip != null)
17868       projection2.clipExtent(null);
17869     stream_default(object, projection2.stream(bounds_default2));
17870     fitBounds(bounds_default2.result());
17871     if (clip != null)
17872       projection2.clipExtent(clip);
17873     return projection2;
17874   }
17875   function fitExtent(projection2, extent, object) {
17876     return fit(projection2, function(b2) {
17877       var w2 = extent[1][0] - extent[0][0], h2 = extent[1][1] - extent[0][1], k2 = Math.min(w2 / (b2[1][0] - b2[0][0]), h2 / (b2[1][1] - b2[0][1])), x2 = +extent[0][0] + (w2 - k2 * (b2[1][0] + b2[0][0])) / 2, y2 = +extent[0][1] + (h2 - k2 * (b2[1][1] + b2[0][1])) / 2;
17878       projection2.scale(150 * k2).translate([x2, y2]);
17879     }, object);
17880   }
17881   function fitSize(projection2, size, object) {
17882     return fitExtent(projection2, [[0, 0], size], object);
17883   }
17884   function fitWidth(projection2, width, object) {
17885     return fit(projection2, function(b2) {
17886       var w2 = +width, k2 = w2 / (b2[1][0] - b2[0][0]), x2 = (w2 - k2 * (b2[1][0] + b2[0][0])) / 2, y2 = -k2 * b2[0][1];
17887       projection2.scale(150 * k2).translate([x2, y2]);
17888     }, object);
17889   }
17890   function fitHeight(projection2, height, object) {
17891     return fit(projection2, function(b2) {
17892       var h2 = +height, k2 = h2 / (b2[1][1] - b2[0][1]), x2 = -k2 * b2[0][0], y2 = (h2 - k2 * (b2[1][1] + b2[0][1])) / 2;
17893       projection2.scale(150 * k2).translate([x2, y2]);
17894     }, object);
17895   }
17896
17897   // node_modules/d3-geo/src/projection/resample.js
17898   var maxDepth = 16;
17899   var cosMinDistance = cos(30 * radians);
17900   function resample_default(project, delta2) {
17901     return +delta2 ? resample(project, delta2) : resampleNone(project);
17902   }
17903   function resampleNone(project) {
17904     return transformer({
17905       point: function(x2, y2) {
17906         x2 = project(x2, y2);
17907         this.stream.point(x2[0], x2[1]);
17908       }
17909     });
17910   }
17911   function resample(project, delta2) {
17912     function resampleLineTo(x05, y05, lambda04, a0, b0, c0, x12, y12, lambda12, a1, b1, c1, depth, stream) {
17913       var dx = x12 - x05, dy = y12 - y05, d2 = dx * dx + dy * dy;
17914       if (d2 > 4 * delta2 && depth--) {
17915         var a2 = a0 + a1, b2 = b0 + b1, c2 = c0 + c1, m2 = sqrt(a2 * a2 + b2 * b2 + c2 * c2), phi2 = asin(c2 /= m2), lambda22 = abs(abs(c2) - 1) < epsilon || abs(lambda04 - lambda12) < epsilon ? (lambda04 + lambda12) / 2 : atan2(b2, a2), p2 = project(lambda22, phi2), x2 = p2[0], y2 = p2[1], dx2 = x2 - x05, dy2 = y2 - y05, dz = dy * dx2 - dx * dy2;
17916         if (dz * dz / d2 > delta2 || abs((dx * dx2 + dy * dy2) / d2 - 0.5) > 0.3 || a0 * a1 + b0 * b1 + c0 * c1 < cosMinDistance) {
17917           resampleLineTo(x05, y05, lambda04, a0, b0, c0, x2, y2, lambda22, a2 /= m2, b2 /= m2, c2, depth, stream);
17918           stream.point(x2, y2);
17919           resampleLineTo(x2, y2, lambda22, a2, b2, c2, x12, y12, lambda12, a1, b1, c1, depth, stream);
17920         }
17921       }
17922     }
17923     return function(stream) {
17924       var lambda003, x004, y004, a00, b00, c00, lambda04, x05, y05, a0, b0, c0;
17925       var resampleStream = {
17926         point: point2,
17927         lineStart,
17928         lineEnd,
17929         polygonStart: function() {
17930           stream.polygonStart();
17931           resampleStream.lineStart = ringStart;
17932         },
17933         polygonEnd: function() {
17934           stream.polygonEnd();
17935           resampleStream.lineStart = lineStart;
17936         }
17937       };
17938       function point2(x2, y2) {
17939         x2 = project(x2, y2);
17940         stream.point(x2[0], x2[1]);
17941       }
17942       function lineStart() {
17943         x05 = NaN;
17944         resampleStream.point = linePoint2;
17945         stream.lineStart();
17946       }
17947       function linePoint2(lambda, phi) {
17948         var c2 = cartesian([lambda, phi]), p2 = project(lambda, phi);
17949         resampleLineTo(x05, y05, lambda04, a0, b0, c0, x05 = p2[0], y05 = p2[1], lambda04 = lambda, a0 = c2[0], b0 = c2[1], c0 = c2[2], maxDepth, stream);
17950         stream.point(x05, y05);
17951       }
17952       function lineEnd() {
17953         resampleStream.point = point2;
17954         stream.lineEnd();
17955       }
17956       function ringStart() {
17957         lineStart();
17958         resampleStream.point = ringPoint;
17959         resampleStream.lineEnd = ringEnd;
17960       }
17961       function ringPoint(lambda, phi) {
17962         linePoint2(lambda003 = lambda, phi), x004 = x05, y004 = y05, a00 = a0, b00 = b0, c00 = c0;
17963         resampleStream.point = linePoint2;
17964       }
17965       function ringEnd() {
17966         resampleLineTo(x05, y05, lambda04, a0, b0, c0, x004, y004, lambda003, a00, b00, c00, maxDepth, stream);
17967         resampleStream.lineEnd = lineEnd;
17968         lineEnd();
17969       }
17970       return resampleStream;
17971     };
17972   }
17973
17974   // node_modules/d3-geo/src/projection/index.js
17975   var transformRadians = transformer({
17976     point: function(x2, y2) {
17977       this.stream.point(x2 * radians, y2 * radians);
17978     }
17979   });
17980   function transformRotate(rotate) {
17981     return transformer({
17982       point: function(x2, y2) {
17983         var r2 = rotate(x2, y2);
17984         return this.stream.point(r2[0], r2[1]);
17985       }
17986     });
17987   }
17988   function scaleTranslate(k2, dx, dy, sx, sy) {
17989     function transform2(x2, y2) {
17990       x2 *= sx;
17991       y2 *= sy;
17992       return [dx + k2 * x2, dy - k2 * y2];
17993     }
17994     transform2.invert = function(x2, y2) {
17995       return [(x2 - dx) / k2 * sx, (dy - y2) / k2 * sy];
17996     };
17997     return transform2;
17998   }
17999   function scaleTranslateRotate(k2, dx, dy, sx, sy, alpha) {
18000     if (!alpha)
18001       return scaleTranslate(k2, dx, dy, sx, sy);
18002     var cosAlpha = cos(alpha), sinAlpha = sin(alpha), a2 = cosAlpha * k2, b2 = sinAlpha * k2, ai = cosAlpha / k2, bi = sinAlpha / k2, ci = (sinAlpha * dy - cosAlpha * dx) / k2, fi = (sinAlpha * dx + cosAlpha * dy) / k2;
18003     function transform2(x2, y2) {
18004       x2 *= sx;
18005       y2 *= sy;
18006       return [a2 * x2 - b2 * y2 + dx, dy - b2 * x2 - a2 * y2];
18007     }
18008     transform2.invert = function(x2, y2) {
18009       return [sx * (ai * x2 - bi * y2 + ci), sy * (fi - bi * x2 - ai * y2)];
18010     };
18011     return transform2;
18012   }
18013   function projection(project) {
18014     return projectionMutator(function() {
18015       return project;
18016     })();
18017   }
18018   function projectionMutator(projectAt) {
18019     var project, k2 = 150, x2 = 480, y2 = 250, lambda = 0, phi = 0, deltaLambda = 0, deltaPhi = 0, deltaGamma = 0, rotate, alpha = 0, sx = 1, sy = 1, theta = null, preclip = antimeridian_default, x05 = null, y05, x12, y12, postclip = identity_default, delta2 = 0.5, projectResample, projectTransform, projectRotateTransform, cache, cacheStream;
18020     function projection2(point2) {
18021       return projectRotateTransform(point2[0] * radians, point2[1] * radians);
18022     }
18023     function invert(point2) {
18024       point2 = projectRotateTransform.invert(point2[0], point2[1]);
18025       return point2 && [point2[0] * degrees, point2[1] * degrees];
18026     }
18027     projection2.stream = function(stream) {
18028       return cache && cacheStream === stream ? cache : cache = transformRadians(transformRotate(rotate)(preclip(projectResample(postclip(cacheStream = stream)))));
18029     };
18030     projection2.preclip = function(_2) {
18031       return arguments.length ? (preclip = _2, theta = void 0, reset()) : preclip;
18032     };
18033     projection2.postclip = function(_2) {
18034       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
18035     };
18036     projection2.clipAngle = function(_2) {
18037       return arguments.length ? (preclip = +_2 ? circle_default(theta = _2 * radians) : (theta = null, antimeridian_default), reset()) : theta * degrees;
18038     };
18039     projection2.clipExtent = function(_2) {
18040       return arguments.length ? (postclip = _2 == null ? (x05 = y05 = x12 = y12 = null, identity_default) : clipRectangle(x05 = +_2[0][0], y05 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1]), reset()) : x05 == null ? null : [[x05, y05], [x12, y12]];
18041     };
18042     projection2.scale = function(_2) {
18043       return arguments.length ? (k2 = +_2, recenter()) : k2;
18044     };
18045     projection2.translate = function(_2) {
18046       return arguments.length ? (x2 = +_2[0], y2 = +_2[1], recenter()) : [x2, y2];
18047     };
18048     projection2.center = function(_2) {
18049       return arguments.length ? (lambda = _2[0] % 360 * radians, phi = _2[1] % 360 * radians, recenter()) : [lambda * degrees, phi * degrees];
18050     };
18051     projection2.rotate = function(_2) {
18052       return arguments.length ? (deltaLambda = _2[0] % 360 * radians, deltaPhi = _2[1] % 360 * radians, deltaGamma = _2.length > 2 ? _2[2] % 360 * radians : 0, recenter()) : [deltaLambda * degrees, deltaPhi * degrees, deltaGamma * degrees];
18053     };
18054     projection2.angle = function(_2) {
18055       return arguments.length ? (alpha = _2 % 360 * radians, recenter()) : alpha * degrees;
18056     };
18057     projection2.reflectX = function(_2) {
18058       return arguments.length ? (sx = _2 ? -1 : 1, recenter()) : sx < 0;
18059     };
18060     projection2.reflectY = function(_2) {
18061       return arguments.length ? (sy = _2 ? -1 : 1, recenter()) : sy < 0;
18062     };
18063     projection2.precision = function(_2) {
18064       return arguments.length ? (projectResample = resample_default(projectTransform, delta2 = _2 * _2), reset()) : sqrt(delta2);
18065     };
18066     projection2.fitExtent = function(extent, object) {
18067       return fitExtent(projection2, extent, object);
18068     };
18069     projection2.fitSize = function(size, object) {
18070       return fitSize(projection2, size, object);
18071     };
18072     projection2.fitWidth = function(width, object) {
18073       return fitWidth(projection2, width, object);
18074     };
18075     projection2.fitHeight = function(height, object) {
18076       return fitHeight(projection2, height, object);
18077     };
18078     function recenter() {
18079       var center = scaleTranslateRotate(k2, 0, 0, sx, sy, alpha).apply(null, project(lambda, phi)), transform2 = scaleTranslateRotate(k2, x2 - center[0], y2 - center[1], sx, sy, alpha);
18080       rotate = rotateRadians(deltaLambda, deltaPhi, deltaGamma);
18081       projectTransform = compose_default(project, transform2);
18082       projectRotateTransform = compose_default(rotate, projectTransform);
18083       projectResample = resample_default(projectTransform, delta2);
18084       return reset();
18085     }
18086     function reset() {
18087       cache = cacheStream = null;
18088       return projection2;
18089     }
18090     return function() {
18091       project = projectAt.apply(this, arguments);
18092       projection2.invert = project.invert && invert;
18093       return recenter();
18094     };
18095   }
18096
18097   // node_modules/d3-geo/src/projection/mercator.js
18098   function mercatorRaw(lambda, phi) {
18099     return [lambda, log(tan((halfPi + phi) / 2))];
18100   }
18101   mercatorRaw.invert = function(x2, y2) {
18102     return [x2, 2 * atan(exp(y2)) - halfPi];
18103   };
18104   function mercator_default() {
18105     return mercatorProjection(mercatorRaw).scale(961 / tau);
18106   }
18107   function mercatorProjection(project) {
18108     var m2 = projection(project), center = m2.center, scale = m2.scale, translate = m2.translate, clipExtent = m2.clipExtent, x05 = null, y05, x12, y12;
18109     m2.scale = function(_2) {
18110       return arguments.length ? (scale(_2), reclip()) : scale();
18111     };
18112     m2.translate = function(_2) {
18113       return arguments.length ? (translate(_2), reclip()) : translate();
18114     };
18115     m2.center = function(_2) {
18116       return arguments.length ? (center(_2), reclip()) : center();
18117     };
18118     m2.clipExtent = function(_2) {
18119       return arguments.length ? (_2 == null ? x05 = y05 = x12 = y12 = null : (x05 = +_2[0][0], y05 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1]), reclip()) : x05 == null ? null : [[x05, y05], [x12, y12]];
18120     };
18121     function reclip() {
18122       var k2 = pi * scale(), t2 = m2(rotation_default(m2.rotate()).invert([0, 0]));
18123       return clipExtent(x05 == null ? [[t2[0] - k2, t2[1] - k2], [t2[0] + k2, t2[1] + k2]] : project === mercatorRaw ? [[Math.max(t2[0] - k2, x05), y05], [Math.min(t2[0] + k2, x12), y12]] : [[x05, Math.max(t2[1] - k2, y05)], [x12, Math.min(t2[1] + k2, y12)]]);
18124     }
18125     return reclip();
18126   }
18127
18128   // node_modules/d3-geo/src/projection/identity.js
18129   function identity_default2() {
18130     var k2 = 1, tx = 0, ty = 0, sx = 1, sy = 1, alpha = 0, ca, sa, x05 = null, y05, x12, y12, kx = 1, ky = 1, transform2 = transformer({
18131       point: function(x2, y2) {
18132         var p2 = projection2([x2, y2]);
18133         this.stream.point(p2[0], p2[1]);
18134       }
18135     }), postclip = identity_default, cache, cacheStream;
18136     function reset() {
18137       kx = k2 * sx;
18138       ky = k2 * sy;
18139       cache = cacheStream = null;
18140       return projection2;
18141     }
18142     function projection2(p2) {
18143       var x2 = p2[0] * kx, y2 = p2[1] * ky;
18144       if (alpha) {
18145         var t2 = y2 * ca - x2 * sa;
18146         x2 = x2 * ca + y2 * sa;
18147         y2 = t2;
18148       }
18149       return [x2 + tx, y2 + ty];
18150     }
18151     projection2.invert = function(p2) {
18152       var x2 = p2[0] - tx, y2 = p2[1] - ty;
18153       if (alpha) {
18154         var t2 = y2 * ca + x2 * sa;
18155         x2 = x2 * ca - y2 * sa;
18156         y2 = t2;
18157       }
18158       return [x2 / kx, y2 / ky];
18159     };
18160     projection2.stream = function(stream) {
18161       return cache && cacheStream === stream ? cache : cache = transform2(postclip(cacheStream = stream));
18162     };
18163     projection2.postclip = function(_2) {
18164       return arguments.length ? (postclip = _2, x05 = y05 = x12 = y12 = null, reset()) : postclip;
18165     };
18166     projection2.clipExtent = function(_2) {
18167       return arguments.length ? (postclip = _2 == null ? (x05 = y05 = x12 = y12 = null, identity_default) : clipRectangle(x05 = +_2[0][0], y05 = +_2[0][1], x12 = +_2[1][0], y12 = +_2[1][1]), reset()) : x05 == null ? null : [[x05, y05], [x12, y12]];
18168     };
18169     projection2.scale = function(_2) {
18170       return arguments.length ? (k2 = +_2, reset()) : k2;
18171     };
18172     projection2.translate = function(_2) {
18173       return arguments.length ? (tx = +_2[0], ty = +_2[1], reset()) : [tx, ty];
18174     };
18175     projection2.angle = function(_2) {
18176       return arguments.length ? (alpha = _2 % 360 * radians, sa = sin(alpha), ca = cos(alpha), reset()) : alpha * degrees;
18177     };
18178     projection2.reflectX = function(_2) {
18179       return arguments.length ? (sx = _2 ? -1 : 1, reset()) : sx < 0;
18180     };
18181     projection2.reflectY = function(_2) {
18182       return arguments.length ? (sy = _2 ? -1 : 1, reset()) : sy < 0;
18183     };
18184     projection2.fitExtent = function(extent, object) {
18185       return fitExtent(projection2, extent, object);
18186     };
18187     projection2.fitSize = function(size, object) {
18188       return fitSize(projection2, size, object);
18189     };
18190     projection2.fitWidth = function(width, object) {
18191       return fitWidth(projection2, width, object);
18192     };
18193     projection2.fitHeight = function(height, object) {
18194       return fitHeight(projection2, height, object);
18195     };
18196     return projection2;
18197   }
18198
18199   // modules/geo/geo.js
18200   var TAU = 2 * Math.PI;
18201   var EQUATORIAL_RADIUS = 6378137;
18202   var POLAR_RADIUS = 63567523e-1;
18203   function geoLatToMeters(dLat) {
18204     return dLat * (TAU * POLAR_RADIUS / 360);
18205   }
18206   function geoLonToMeters(dLon, atLat) {
18207     return Math.abs(atLat) >= 90 ? 0 : dLon * (TAU * EQUATORIAL_RADIUS / 360) * Math.abs(Math.cos(atLat * (Math.PI / 180)));
18208   }
18209   function geoMetersToLat(m2) {
18210     return m2 / (TAU * POLAR_RADIUS / 360);
18211   }
18212   function geoMetersToLon(m2, atLat) {
18213     return Math.abs(atLat) >= 90 ? 0 : m2 / (TAU * EQUATORIAL_RADIUS / 360) / Math.abs(Math.cos(atLat * (Math.PI / 180)));
18214   }
18215   function geoMetersToOffset(meters, tileSize) {
18216     tileSize = tileSize || 256;
18217     return [
18218       meters[0] * tileSize / (TAU * EQUATORIAL_RADIUS),
18219       -meters[1] * tileSize / (TAU * POLAR_RADIUS)
18220     ];
18221   }
18222   function geoOffsetToMeters(offset, tileSize) {
18223     tileSize = tileSize || 256;
18224     return [
18225       offset[0] * TAU * EQUATORIAL_RADIUS / tileSize,
18226       -offset[1] * TAU * POLAR_RADIUS / tileSize
18227     ];
18228   }
18229   function geoSphericalDistance(a2, b2) {
18230     var x2 = geoLonToMeters(a2[0] - b2[0], (a2[1] + b2[1]) / 2);
18231     var y2 = geoLatToMeters(a2[1] - b2[1]);
18232     return Math.sqrt(x2 * x2 + y2 * y2);
18233   }
18234   function geoScaleToZoom(k2, tileSize) {
18235     tileSize = tileSize || 256;
18236     var log2ts = Math.log(tileSize) * Math.LOG2E;
18237     return Math.log(k2 * TAU) / Math.LN2 - log2ts;
18238   }
18239   function geoZoomToScale(z2, tileSize) {
18240     tileSize = tileSize || 256;
18241     return tileSize * Math.pow(2, z2) / TAU;
18242   }
18243   function geoSphericalClosestNode(nodes, point2) {
18244     var minDistance = Infinity, distance;
18245     var indexOfMin;
18246     for (var i3 in nodes) {
18247       distance = geoSphericalDistance(nodes[i3].loc, point2);
18248       if (distance < minDistance) {
18249         minDistance = distance;
18250         indexOfMin = i3;
18251       }
18252     }
18253     if (indexOfMin !== void 0) {
18254       return { index: indexOfMin, distance: minDistance, node: nodes[indexOfMin] };
18255     } else {
18256       return null;
18257     }
18258   }
18259
18260   // modules/geo/extent.js
18261   function geoExtent(min3, max3) {
18262     if (!(this instanceof geoExtent)) {
18263       return new geoExtent(min3, max3);
18264     } else if (min3 instanceof geoExtent) {
18265       return min3;
18266     } else if (min3 && min3.length === 2 && min3[0].length === 2 && min3[1].length === 2) {
18267       this[0] = min3[0];
18268       this[1] = min3[1];
18269     } else {
18270       this[0] = min3 || [Infinity, Infinity];
18271       this[1] = max3 || min3 || [-Infinity, -Infinity];
18272     }
18273   }
18274   geoExtent.prototype = new Array(2);
18275   Object.assign(geoExtent.prototype, {
18276     equals: function(obj) {
18277       return this[0][0] === obj[0][0] && this[0][1] === obj[0][1] && this[1][0] === obj[1][0] && this[1][1] === obj[1][1];
18278     },
18279     extend: function(obj) {
18280       if (!(obj instanceof geoExtent))
18281         obj = new geoExtent(obj);
18282       return geoExtent(
18283         [Math.min(obj[0][0], this[0][0]), Math.min(obj[0][1], this[0][1])],
18284         [Math.max(obj[1][0], this[1][0]), Math.max(obj[1][1], this[1][1])]
18285       );
18286     },
18287     _extend: function(extent) {
18288       this[0][0] = Math.min(extent[0][0], this[0][0]);
18289       this[0][1] = Math.min(extent[0][1], this[0][1]);
18290       this[1][0] = Math.max(extent[1][0], this[1][0]);
18291       this[1][1] = Math.max(extent[1][1], this[1][1]);
18292     },
18293     area: function() {
18294       return Math.abs((this[1][0] - this[0][0]) * (this[1][1] - this[0][1]));
18295     },
18296     center: function() {
18297       return [(this[0][0] + this[1][0]) / 2, (this[0][1] + this[1][1]) / 2];
18298     },
18299     rectangle: function() {
18300       return [this[0][0], this[0][1], this[1][0], this[1][1]];
18301     },
18302     bbox: function() {
18303       return { minX: this[0][0], minY: this[0][1], maxX: this[1][0], maxY: this[1][1] };
18304     },
18305     polygon: function() {
18306       return [
18307         [this[0][0], this[0][1]],
18308         [this[0][0], this[1][1]],
18309         [this[1][0], this[1][1]],
18310         [this[1][0], this[0][1]],
18311         [this[0][0], this[0][1]]
18312       ];
18313     },
18314     contains: function(obj) {
18315       if (!(obj instanceof geoExtent))
18316         obj = new geoExtent(obj);
18317       return obj[0][0] >= this[0][0] && obj[0][1] >= this[0][1] && obj[1][0] <= this[1][0] && obj[1][1] <= this[1][1];
18318     },
18319     intersects: function(obj) {
18320       if (!(obj instanceof geoExtent))
18321         obj = new geoExtent(obj);
18322       return obj[0][0] <= this[1][0] && obj[0][1] <= this[1][1] && obj[1][0] >= this[0][0] && obj[1][1] >= this[0][1];
18323     },
18324     intersection: function(obj) {
18325       if (!this.intersects(obj))
18326         return new geoExtent();
18327       return new geoExtent(
18328         [Math.max(obj[0][0], this[0][0]), Math.max(obj[0][1], this[0][1])],
18329         [Math.min(obj[1][0], this[1][0]), Math.min(obj[1][1], this[1][1])]
18330       );
18331     },
18332     percentContainedIn: function(obj) {
18333       if (!(obj instanceof geoExtent))
18334         obj = new geoExtent(obj);
18335       var a1 = this.intersection(obj).area();
18336       var a2 = this.area();
18337       if (a1 === Infinity || a2 === Infinity) {
18338         return 0;
18339       } else if (a1 === 0 || a2 === 0) {
18340         if (obj.contains(this)) {
18341           return 1;
18342         }
18343         return 0;
18344       } else {
18345         return a1 / a2;
18346       }
18347     },
18348     padByMeters: function(meters) {
18349       var dLat = geoMetersToLat(meters);
18350       var dLon = geoMetersToLon(meters, this.center()[1]);
18351       return geoExtent(
18352         [this[0][0] - dLon, this[0][1] - dLat],
18353         [this[1][0] + dLon, this[1][1] + dLat]
18354       );
18355     },
18356     toParam: function() {
18357       return this.rectangle().join(",");
18358     },
18359     split: function() {
18360       const center = this.center();
18361       return [
18362         geoExtent(this[0], center),
18363         geoExtent([center[0], this[0][1]], [this[1][0], center[1]]),
18364         geoExtent(center, this[1]),
18365         geoExtent([this[0][0], center[1]], [center[0], this[1][1]])
18366       ];
18367     }
18368   });
18369
18370   // node_modules/d3-polygon/src/area.js
18371   function area_default3(polygon2) {
18372     var i3 = -1, n3 = polygon2.length, a2, b2 = polygon2[n3 - 1], area = 0;
18373     while (++i3 < n3) {
18374       a2 = b2;
18375       b2 = polygon2[i3];
18376       area += a2[1] * b2[0] - a2[0] * b2[1];
18377     }
18378     return area / 2;
18379   }
18380
18381   // node_modules/d3-polygon/src/centroid.js
18382   function centroid_default2(polygon2) {
18383     var i3 = -1, n3 = polygon2.length, x2 = 0, y2 = 0, a2, b2 = polygon2[n3 - 1], c2, k2 = 0;
18384     while (++i3 < n3) {
18385       a2 = b2;
18386       b2 = polygon2[i3];
18387       k2 += c2 = a2[0] * b2[1] - b2[0] * a2[1];
18388       x2 += (a2[0] + b2[0]) * c2;
18389       y2 += (a2[1] + b2[1]) * c2;
18390     }
18391     return k2 *= 3, [x2 / k2, y2 / k2];
18392   }
18393
18394   // node_modules/d3-polygon/src/cross.js
18395   function cross_default(a2, b2, c2) {
18396     return (b2[0] - a2[0]) * (c2[1] - a2[1]) - (b2[1] - a2[1]) * (c2[0] - a2[0]);
18397   }
18398
18399   // node_modules/d3-polygon/src/hull.js
18400   function lexicographicOrder(a2, b2) {
18401     return a2[0] - b2[0] || a2[1] - b2[1];
18402   }
18403   function computeUpperHullIndexes(points) {
18404     const n3 = points.length, indexes = [0, 1];
18405     let size = 2, i3;
18406     for (i3 = 2; i3 < n3; ++i3) {
18407       while (size > 1 && cross_default(points[indexes[size - 2]], points[indexes[size - 1]], points[i3]) <= 0)
18408         --size;
18409       indexes[size++] = i3;
18410     }
18411     return indexes.slice(0, size);
18412   }
18413   function hull_default(points) {
18414     if ((n3 = points.length) < 3)
18415       return null;
18416     var i3, n3, sortedPoints = new Array(n3), flippedPoints = new Array(n3);
18417     for (i3 = 0; i3 < n3; ++i3)
18418       sortedPoints[i3] = [+points[i3][0], +points[i3][1], i3];
18419     sortedPoints.sort(lexicographicOrder);
18420     for (i3 = 0; i3 < n3; ++i3)
18421       flippedPoints[i3] = [sortedPoints[i3][0], -sortedPoints[i3][1]];
18422     var upperIndexes = computeUpperHullIndexes(sortedPoints), lowerIndexes = computeUpperHullIndexes(flippedPoints);
18423     var skipLeft = lowerIndexes[0] === upperIndexes[0], skipRight = lowerIndexes[lowerIndexes.length - 1] === upperIndexes[upperIndexes.length - 1], hull = [];
18424     for (i3 = upperIndexes.length - 1; i3 >= 0; --i3)
18425       hull.push(points[sortedPoints[upperIndexes[i3]][2]]);
18426     for (i3 = +skipLeft; i3 < lowerIndexes.length - skipRight; ++i3)
18427       hull.push(points[sortedPoints[lowerIndexes[i3]][2]]);
18428     return hull;
18429   }
18430
18431   // modules/geo/vector.js
18432   function geoVecEqual(a2, b2, epsilon3) {
18433     if (epsilon3) {
18434       return Math.abs(a2[0] - b2[0]) <= epsilon3 && Math.abs(a2[1] - b2[1]) <= epsilon3;
18435     } else {
18436       return a2[0] === b2[0] && a2[1] === b2[1];
18437     }
18438   }
18439   function geoVecAdd(a2, b2) {
18440     return [a2[0] + b2[0], a2[1] + b2[1]];
18441   }
18442   function geoVecSubtract(a2, b2) {
18443     return [a2[0] - b2[0], a2[1] - b2[1]];
18444   }
18445   function geoVecScale(a2, mag) {
18446     return [a2[0] * mag, a2[1] * mag];
18447   }
18448   function geoVecFloor(a2) {
18449     return [Math.floor(a2[0]), Math.floor(a2[1])];
18450   }
18451   function geoVecInterp(a2, b2, t2) {
18452     return [
18453       a2[0] + (b2[0] - a2[0]) * t2,
18454       a2[1] + (b2[1] - a2[1]) * t2
18455     ];
18456   }
18457   function geoVecLength(a2, b2) {
18458     return Math.sqrt(geoVecLengthSquare(a2, b2));
18459   }
18460   function geoVecLengthSquare(a2, b2) {
18461     b2 = b2 || [0, 0];
18462     var x2 = a2[0] - b2[0];
18463     var y2 = a2[1] - b2[1];
18464     return x2 * x2 + y2 * y2;
18465   }
18466   function geoVecNormalize(a2) {
18467     var length2 = Math.sqrt(a2[0] * a2[0] + a2[1] * a2[1]);
18468     if (length2 !== 0) {
18469       return geoVecScale(a2, 1 / length2);
18470     }
18471     return [0, 0];
18472   }
18473   function geoVecAngle(a2, b2) {
18474     return Math.atan2(b2[1] - a2[1], b2[0] - a2[0]);
18475   }
18476   function geoVecDot(a2, b2, origin) {
18477     origin = origin || [0, 0];
18478     var p2 = geoVecSubtract(a2, origin);
18479     var q2 = geoVecSubtract(b2, origin);
18480     return p2[0] * q2[0] + p2[1] * q2[1];
18481   }
18482   function geoVecNormalizedDot(a2, b2, origin) {
18483     origin = origin || [0, 0];
18484     var p2 = geoVecNormalize(geoVecSubtract(a2, origin));
18485     var q2 = geoVecNormalize(geoVecSubtract(b2, origin));
18486     return geoVecDot(p2, q2);
18487   }
18488   function geoVecCross(a2, b2, origin) {
18489     origin = origin || [0, 0];
18490     var p2 = geoVecSubtract(a2, origin);
18491     var q2 = geoVecSubtract(b2, origin);
18492     return p2[0] * q2[1] - p2[1] * q2[0];
18493   }
18494   function geoVecProject(a2, points) {
18495     var min3 = Infinity;
18496     var idx;
18497     var target;
18498     for (var i3 = 0; i3 < points.length - 1; i3++) {
18499       var o2 = points[i3];
18500       var s2 = geoVecSubtract(points[i3 + 1], o2);
18501       var v2 = geoVecSubtract(a2, o2);
18502       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
18503       var p2;
18504       if (proj < 0) {
18505         p2 = o2;
18506       } else if (proj > 1) {
18507         p2 = points[i3 + 1];
18508       } else {
18509         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
18510       }
18511       var dist = geoVecLength(p2, a2);
18512       if (dist < min3) {
18513         min3 = dist;
18514         idx = i3 + 1;
18515         target = p2;
18516       }
18517     }
18518     if (idx !== void 0) {
18519       return { index: idx, distance: min3, target };
18520     } else {
18521       return null;
18522     }
18523   }
18524
18525   // modules/geo/geom.js
18526   function geoAngle(a2, b2, projection2) {
18527     return geoVecAngle(projection2(a2.loc), projection2(b2.loc));
18528   }
18529   function geoEdgeEqual(a2, b2) {
18530     return a2[0] === b2[0] && a2[1] === b2[1] || a2[0] === b2[1] && a2[1] === b2[0];
18531   }
18532   function geoRotate(points, angle2, around) {
18533     return points.map(function(point2) {
18534       var radial = geoVecSubtract(point2, around);
18535       return [
18536         radial[0] * Math.cos(angle2) - radial[1] * Math.sin(angle2) + around[0],
18537         radial[0] * Math.sin(angle2) + radial[1] * Math.cos(angle2) + around[1]
18538       ];
18539     });
18540   }
18541   function geoChooseEdge(nodes, point2, projection2, activeID) {
18542     var dist = geoVecLength;
18543     var points = nodes.map(function(n3) {
18544       return projection2(n3.loc);
18545     });
18546     var ids = nodes.map(function(n3) {
18547       return n3.id;
18548     });
18549     var min3 = Infinity;
18550     var idx;
18551     var loc;
18552     for (var i3 = 0; i3 < points.length - 1; i3++) {
18553       if (ids[i3] === activeID || ids[i3 + 1] === activeID)
18554         continue;
18555       var o2 = points[i3];
18556       var s2 = geoVecSubtract(points[i3 + 1], o2);
18557       var v2 = geoVecSubtract(point2, o2);
18558       var proj = geoVecDot(v2, s2) / geoVecDot(s2, s2);
18559       var p2;
18560       if (proj < 0) {
18561         p2 = o2;
18562       } else if (proj > 1) {
18563         p2 = points[i3 + 1];
18564       } else {
18565         p2 = [o2[0] + proj * s2[0], o2[1] + proj * s2[1]];
18566       }
18567       var d2 = dist(p2, point2);
18568       if (d2 < min3) {
18569         min3 = d2;
18570         idx = i3 + 1;
18571         loc = projection2.invert(p2);
18572       }
18573     }
18574     if (idx !== void 0) {
18575       return { index: idx, distance: min3, loc };
18576     } else {
18577       return null;
18578     }
18579   }
18580   function geoHasLineIntersections(activeNodes, inactiveNodes, activeID) {
18581     var actives = [];
18582     var inactives = [];
18583     var j2, k2, n1, n22, segment;
18584     for (j2 = 0; j2 < activeNodes.length - 1; j2++) {
18585       n1 = activeNodes[j2];
18586       n22 = activeNodes[j2 + 1];
18587       segment = [n1.loc, n22.loc];
18588       if (n1.id === activeID || n22.id === activeID) {
18589         actives.push(segment);
18590       }
18591     }
18592     for (j2 = 0; j2 < inactiveNodes.length - 1; j2++) {
18593       n1 = inactiveNodes[j2];
18594       n22 = inactiveNodes[j2 + 1];
18595       segment = [n1.loc, n22.loc];
18596       inactives.push(segment);
18597     }
18598     for (j2 = 0; j2 < actives.length; j2++) {
18599       for (k2 = 0; k2 < inactives.length; k2++) {
18600         var p2 = actives[j2];
18601         var q2 = inactives[k2];
18602         var hit = geoLineIntersection(p2, q2);
18603         if (hit) {
18604           return true;
18605         }
18606       }
18607     }
18608     return false;
18609   }
18610   function geoHasSelfIntersections(nodes, activeID) {
18611     var actives = [];
18612     var inactives = [];
18613     var j2, k2;
18614     for (j2 = 0; j2 < nodes.length - 1; j2++) {
18615       var n1 = nodes[j2];
18616       var n22 = nodes[j2 + 1];
18617       var segment = [n1.loc, n22.loc];
18618       if (n1.id === activeID || n22.id === activeID) {
18619         actives.push(segment);
18620       } else {
18621         inactives.push(segment);
18622       }
18623     }
18624     for (j2 = 0; j2 < actives.length; j2++) {
18625       for (k2 = 0; k2 < inactives.length; k2++) {
18626         var p2 = actives[j2];
18627         var q2 = inactives[k2];
18628         if (geoVecEqual(p2[1], q2[0]) || geoVecEqual(p2[0], q2[1]) || geoVecEqual(p2[0], q2[0]) || geoVecEqual(p2[1], q2[1])) {
18629           continue;
18630         }
18631         var hit = geoLineIntersection(p2, q2);
18632         if (hit) {
18633           var epsilon3 = 1e-8;
18634           if (geoVecEqual(p2[1], hit, epsilon3) || geoVecEqual(p2[0], hit, epsilon3) || geoVecEqual(q2[1], hit, epsilon3) || geoVecEqual(q2[0], hit, epsilon3)) {
18635             continue;
18636           } else {
18637             return true;
18638           }
18639         }
18640       }
18641     }
18642     return false;
18643   }
18644   function geoLineIntersection(a2, b2) {
18645     var p2 = [a2[0][0], a2[0][1]];
18646     var p22 = [a2[1][0], a2[1][1]];
18647     var q2 = [b2[0][0], b2[0][1]];
18648     var q22 = [b2[1][0], b2[1][1]];
18649     var r2 = geoVecSubtract(p22, p2);
18650     var s2 = geoVecSubtract(q22, q2);
18651     var uNumerator = geoVecCross(geoVecSubtract(q2, p2), r2);
18652     var denominator = geoVecCross(r2, s2);
18653     if (uNumerator && denominator) {
18654       var u2 = uNumerator / denominator;
18655       var t2 = geoVecCross(geoVecSubtract(q2, p2), s2) / denominator;
18656       if (t2 >= 0 && t2 <= 1 && u2 >= 0 && u2 <= 1) {
18657         return geoVecInterp(p2, p22, t2);
18658       }
18659     }
18660     return null;
18661   }
18662   function geoPathIntersections(path1, path2) {
18663     var intersections = [];
18664     for (var i3 = 0; i3 < path1.length - 1; i3++) {
18665       for (var j2 = 0; j2 < path2.length - 1; j2++) {
18666         var a2 = [path1[i3], path1[i3 + 1]];
18667         var b2 = [path2[j2], path2[j2 + 1]];
18668         var hit = geoLineIntersection(a2, b2);
18669         if (hit) {
18670           intersections.push(hit);
18671         }
18672       }
18673     }
18674     return intersections;
18675   }
18676   function geoPathHasIntersections(path1, path2) {
18677     for (var i3 = 0; i3 < path1.length - 1; i3++) {
18678       for (var j2 = 0; j2 < path2.length - 1; j2++) {
18679         var a2 = [path1[i3], path1[i3 + 1]];
18680         var b2 = [path2[j2], path2[j2 + 1]];
18681         var hit = geoLineIntersection(a2, b2);
18682         if (hit) {
18683           return true;
18684         }
18685       }
18686     }
18687     return false;
18688   }
18689   function geoPointInPolygon(point2, polygon2) {
18690     var x2 = point2[0];
18691     var y2 = point2[1];
18692     var inside = false;
18693     for (var i3 = 0, j2 = polygon2.length - 1; i3 < polygon2.length; j2 = i3++) {
18694       var xi = polygon2[i3][0];
18695       var yi = polygon2[i3][1];
18696       var xj = polygon2[j2][0];
18697       var yj = polygon2[j2][1];
18698       var intersect2 = yi > y2 !== yj > y2 && x2 < (xj - xi) * (y2 - yi) / (yj - yi) + xi;
18699       if (intersect2)
18700         inside = !inside;
18701     }
18702     return inside;
18703   }
18704   function geoPolygonContainsPolygon(outer, inner) {
18705     return inner.every(function(point2) {
18706       return geoPointInPolygon(point2, outer);
18707     });
18708   }
18709   function geoPolygonIntersectsPolygon(outer, inner, checkSegments) {
18710     function testPoints(outer2, inner2) {
18711       return inner2.some(function(point2) {
18712         return geoPointInPolygon(point2, outer2);
18713       });
18714     }
18715     return testPoints(outer, inner) || !!checkSegments && geoPathHasIntersections(outer, inner);
18716   }
18717   function geoGetSmallestSurroundingRectangle(points) {
18718     var hull = hull_default(points);
18719     var centroid = centroid_default2(hull);
18720     var minArea = Infinity;
18721     var ssrExtent = [];
18722     var ssrAngle = 0;
18723     var c1 = hull[0];
18724     for (var i3 = 0; i3 <= hull.length - 1; i3++) {
18725       var c2 = i3 === hull.length - 1 ? hull[0] : hull[i3 + 1];
18726       var angle2 = Math.atan2(c2[1] - c1[1], c2[0] - c1[0]);
18727       var poly = geoRotate(hull, -angle2, centroid);
18728       var extent = poly.reduce(function(extent2, point2) {
18729         return extent2.extend(geoExtent(point2));
18730       }, geoExtent());
18731       var area = extent.area();
18732       if (area < minArea) {
18733         minArea = area;
18734         ssrExtent = extent;
18735         ssrAngle = angle2;
18736       }
18737       c1 = c2;
18738     }
18739     return {
18740       poly: geoRotate(ssrExtent.polygon(), ssrAngle, centroid),
18741       angle: ssrAngle
18742     };
18743   }
18744   function geoPathLength(path) {
18745     var length2 = 0;
18746     for (var i3 = 0; i3 < path.length - 1; i3++) {
18747       length2 += geoVecLength(path[i3], path[i3 + 1]);
18748     }
18749     return length2;
18750   }
18751   function geoViewportEdge(point2, dimensions) {
18752     var pad2 = [80, 20, 50, 20];
18753     var x2 = 0;
18754     var y2 = 0;
18755     if (point2[0] > dimensions[0] - pad2[1]) {
18756       x2 = -10;
18757     }
18758     if (point2[0] < pad2[3]) {
18759       x2 = 10;
18760     }
18761     if (point2[1] > dimensions[1] - pad2[2]) {
18762       y2 = -10;
18763     }
18764     if (point2[1] < pad2[0]) {
18765       y2 = 10;
18766     }
18767     if (x2 || y2) {
18768       return [x2, y2];
18769     } else {
18770       return null;
18771     }
18772   }
18773
18774   // node_modules/d3-dispatch/src/dispatch.js
18775   var noop2 = { value: () => {
18776   } };
18777   function dispatch() {
18778     for (var i3 = 0, n3 = arguments.length, _2 = {}, t2; i3 < n3; ++i3) {
18779       if (!(t2 = arguments[i3] + "") || t2 in _2 || /[\s.]/.test(t2))
18780         throw new Error("illegal type: " + t2);
18781       _2[t2] = [];
18782     }
18783     return new Dispatch(_2);
18784   }
18785   function Dispatch(_2) {
18786     this._ = _2;
18787   }
18788   function parseTypenames(typenames, types) {
18789     return typenames.trim().split(/^|\s+/).map(function(t2) {
18790       var name = "", i3 = t2.indexOf(".");
18791       if (i3 >= 0)
18792         name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
18793       if (t2 && !types.hasOwnProperty(t2))
18794         throw new Error("unknown type: " + t2);
18795       return { type: t2, name };
18796     });
18797   }
18798   Dispatch.prototype = dispatch.prototype = {
18799     constructor: Dispatch,
18800     on: function(typename, callback) {
18801       var _2 = this._, T2 = parseTypenames(typename + "", _2), t2, i3 = -1, n3 = T2.length;
18802       if (arguments.length < 2) {
18803         while (++i3 < n3)
18804           if ((t2 = (typename = T2[i3]).type) && (t2 = get(_2[t2], typename.name)))
18805             return t2;
18806         return;
18807       }
18808       if (callback != null && typeof callback !== "function")
18809         throw new Error("invalid callback: " + callback);
18810       while (++i3 < n3) {
18811         if (t2 = (typename = T2[i3]).type)
18812           _2[t2] = set(_2[t2], typename.name, callback);
18813         else if (callback == null)
18814           for (t2 in _2)
18815             _2[t2] = set(_2[t2], typename.name, null);
18816       }
18817       return this;
18818     },
18819     copy: function() {
18820       var copy2 = {}, _2 = this._;
18821       for (var t2 in _2)
18822         copy2[t2] = _2[t2].slice();
18823       return new Dispatch(copy2);
18824     },
18825     call: function(type2, that) {
18826       if ((n3 = arguments.length - 2) > 0)
18827         for (var args = new Array(n3), i3 = 0, n3, t2; i3 < n3; ++i3)
18828           args[i3] = arguments[i3 + 2];
18829       if (!this._.hasOwnProperty(type2))
18830         throw new Error("unknown type: " + type2);
18831       for (t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3)
18832         t2[i3].value.apply(that, args);
18833     },
18834     apply: function(type2, that, args) {
18835       if (!this._.hasOwnProperty(type2))
18836         throw new Error("unknown type: " + type2);
18837       for (var t2 = this._[type2], i3 = 0, n3 = t2.length; i3 < n3; ++i3)
18838         t2[i3].value.apply(that, args);
18839     }
18840   };
18841   function get(type2, name) {
18842     for (var i3 = 0, n3 = type2.length, c2; i3 < n3; ++i3) {
18843       if ((c2 = type2[i3]).name === name) {
18844         return c2.value;
18845       }
18846     }
18847   }
18848   function set(type2, name, callback) {
18849     for (var i3 = 0, n3 = type2.length; i3 < n3; ++i3) {
18850       if (type2[i3].name === name) {
18851         type2[i3] = noop2, type2 = type2.slice(0, i3).concat(type2.slice(i3 + 1));
18852         break;
18853       }
18854     }
18855     if (callback != null)
18856       type2.push({ name, value: callback });
18857     return type2;
18858   }
18859   var dispatch_default = dispatch;
18860
18861   // node_modules/d3-selection/src/namespaces.js
18862   var xhtml = "http://www.w3.org/1999/xhtml";
18863   var namespaces_default = {
18864     svg: "http://www.w3.org/2000/svg",
18865     xhtml,
18866     xlink: "http://www.w3.org/1999/xlink",
18867     xml: "http://www.w3.org/XML/1998/namespace",
18868     xmlns: "http://www.w3.org/2000/xmlns/"
18869   };
18870
18871   // node_modules/d3-selection/src/namespace.js
18872   function namespace_default(name) {
18873     var prefix = name += "", i3 = prefix.indexOf(":");
18874     if (i3 >= 0 && (prefix = name.slice(0, i3)) !== "xmlns")
18875       name = name.slice(i3 + 1);
18876     return namespaces_default.hasOwnProperty(prefix) ? { space: namespaces_default[prefix], local: name } : name;
18877   }
18878
18879   // node_modules/d3-selection/src/creator.js
18880   function creatorInherit(name) {
18881     return function() {
18882       var document2 = this.ownerDocument, uri = this.namespaceURI;
18883       return uri === xhtml && document2.documentElement.namespaceURI === xhtml ? document2.createElement(name) : document2.createElementNS(uri, name);
18884     };
18885   }
18886   function creatorFixed(fullname) {
18887     return function() {
18888       return this.ownerDocument.createElementNS(fullname.space, fullname.local);
18889     };
18890   }
18891   function creator_default(name) {
18892     var fullname = namespace_default(name);
18893     return (fullname.local ? creatorFixed : creatorInherit)(fullname);
18894   }
18895
18896   // node_modules/d3-selection/src/selector.js
18897   function none() {
18898   }
18899   function selector_default(selector) {
18900     return selector == null ? none : function() {
18901       return this.querySelector(selector);
18902     };
18903   }
18904
18905   // node_modules/d3-selection/src/selection/select.js
18906   function select_default(select) {
18907     if (typeof select !== "function")
18908       select = selector_default(select);
18909     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
18910       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
18911         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
18912           if ("__data__" in node)
18913             subnode.__data__ = node.__data__;
18914           subgroup[i3] = subnode;
18915         }
18916       }
18917     }
18918     return new Selection(subgroups, this._parents);
18919   }
18920
18921   // node_modules/d3-selection/src/array.js
18922   function array(x2) {
18923     return x2 == null ? [] : Array.isArray(x2) ? x2 : Array.from(x2);
18924   }
18925
18926   // node_modules/d3-selection/src/selectorAll.js
18927   function empty() {
18928     return [];
18929   }
18930   function selectorAll_default(selector) {
18931     return selector == null ? empty : function() {
18932       return this.querySelectorAll(selector);
18933     };
18934   }
18935
18936   // node_modules/d3-selection/src/selection/selectAll.js
18937   function arrayAll(select) {
18938     return function() {
18939       return array(select.apply(this, arguments));
18940     };
18941   }
18942   function selectAll_default(select) {
18943     if (typeof select === "function")
18944       select = arrayAll(select);
18945     else
18946       select = selectorAll_default(select);
18947     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
18948       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
18949         if (node = group[i3]) {
18950           subgroups.push(select.call(node, node.__data__, i3, group));
18951           parents.push(node);
18952         }
18953       }
18954     }
18955     return new Selection(subgroups, parents);
18956   }
18957
18958   // node_modules/d3-selection/src/matcher.js
18959   function matcher_default(selector) {
18960     return function() {
18961       return this.matches(selector);
18962     };
18963   }
18964   function childMatcher(selector) {
18965     return function(node) {
18966       return node.matches(selector);
18967     };
18968   }
18969
18970   // node_modules/d3-selection/src/selection/selectChild.js
18971   var find = Array.prototype.find;
18972   function childFind(match) {
18973     return function() {
18974       return find.call(this.children, match);
18975     };
18976   }
18977   function childFirst() {
18978     return this.firstElementChild;
18979   }
18980   function selectChild_default(match) {
18981     return this.select(match == null ? childFirst : childFind(typeof match === "function" ? match : childMatcher(match)));
18982   }
18983
18984   // node_modules/d3-selection/src/selection/selectChildren.js
18985   var filter = Array.prototype.filter;
18986   function children() {
18987     return Array.from(this.children);
18988   }
18989   function childrenFilter(match) {
18990     return function() {
18991       return filter.call(this.children, match);
18992     };
18993   }
18994   function selectChildren_default(match) {
18995     return this.selectAll(match == null ? children : childrenFilter(typeof match === "function" ? match : childMatcher(match)));
18996   }
18997
18998   // node_modules/d3-selection/src/selection/filter.js
18999   function filter_default(match) {
19000     if (typeof match !== "function")
19001       match = matcher_default(match);
19002     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19003       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
19004         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
19005           subgroup.push(node);
19006         }
19007       }
19008     }
19009     return new Selection(subgroups, this._parents);
19010   }
19011
19012   // node_modules/d3-selection/src/selection/sparse.js
19013   function sparse_default(update) {
19014     return new Array(update.length);
19015   }
19016
19017   // node_modules/d3-selection/src/selection/enter.js
19018   function enter_default() {
19019     return new Selection(this._enter || this._groups.map(sparse_default), this._parents);
19020   }
19021   function EnterNode(parent, datum2) {
19022     this.ownerDocument = parent.ownerDocument;
19023     this.namespaceURI = parent.namespaceURI;
19024     this._next = null;
19025     this._parent = parent;
19026     this.__data__ = datum2;
19027   }
19028   EnterNode.prototype = {
19029     constructor: EnterNode,
19030     appendChild: function(child) {
19031       return this._parent.insertBefore(child, this._next);
19032     },
19033     insertBefore: function(child, next) {
19034       return this._parent.insertBefore(child, next);
19035     },
19036     querySelector: function(selector) {
19037       return this._parent.querySelector(selector);
19038     },
19039     querySelectorAll: function(selector) {
19040       return this._parent.querySelectorAll(selector);
19041     }
19042   };
19043
19044   // node_modules/d3-selection/src/constant.js
19045   function constant_default(x2) {
19046     return function() {
19047       return x2;
19048     };
19049   }
19050
19051   // node_modules/d3-selection/src/selection/data.js
19052   function bindIndex(parent, group, enter, update, exit, data) {
19053     var i3 = 0, node, groupLength = group.length, dataLength = data.length;
19054     for (; i3 < dataLength; ++i3) {
19055       if (node = group[i3]) {
19056         node.__data__ = data[i3];
19057         update[i3] = node;
19058       } else {
19059         enter[i3] = new EnterNode(parent, data[i3]);
19060       }
19061     }
19062     for (; i3 < groupLength; ++i3) {
19063       if (node = group[i3]) {
19064         exit[i3] = node;
19065       }
19066     }
19067   }
19068   function bindKey(parent, group, enter, update, exit, data, key) {
19069     var i3, node, nodeByKeyValue = /* @__PURE__ */ new Map(), groupLength = group.length, dataLength = data.length, keyValues = new Array(groupLength), keyValue;
19070     for (i3 = 0; i3 < groupLength; ++i3) {
19071       if (node = group[i3]) {
19072         keyValues[i3] = keyValue = key.call(node, node.__data__, i3, group) + "";
19073         if (nodeByKeyValue.has(keyValue)) {
19074           exit[i3] = node;
19075         } else {
19076           nodeByKeyValue.set(keyValue, node);
19077         }
19078       }
19079     }
19080     for (i3 = 0; i3 < dataLength; ++i3) {
19081       keyValue = key.call(parent, data[i3], i3, data) + "";
19082       if (node = nodeByKeyValue.get(keyValue)) {
19083         update[i3] = node;
19084         node.__data__ = data[i3];
19085         nodeByKeyValue.delete(keyValue);
19086       } else {
19087         enter[i3] = new EnterNode(parent, data[i3]);
19088       }
19089     }
19090     for (i3 = 0; i3 < groupLength; ++i3) {
19091       if ((node = group[i3]) && nodeByKeyValue.get(keyValues[i3]) === node) {
19092         exit[i3] = node;
19093       }
19094     }
19095   }
19096   function datum(node) {
19097     return node.__data__;
19098   }
19099   function data_default(value, key) {
19100     if (!arguments.length)
19101       return Array.from(this, datum);
19102     var bind = key ? bindKey : bindIndex, parents = this._parents, groups = this._groups;
19103     if (typeof value !== "function")
19104       value = constant_default(value);
19105     for (var m2 = groups.length, update = new Array(m2), enter = new Array(m2), exit = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19106       var parent = parents[j2], group = groups[j2], groupLength = group.length, data = arraylike(value.call(parent, parent && parent.__data__, j2, parents)), dataLength = data.length, enterGroup = enter[j2] = new Array(dataLength), updateGroup = update[j2] = new Array(dataLength), exitGroup = exit[j2] = new Array(groupLength);
19107       bind(parent, group, enterGroup, updateGroup, exitGroup, data, key);
19108       for (var i0 = 0, i1 = 0, previous, next; i0 < dataLength; ++i0) {
19109         if (previous = enterGroup[i0]) {
19110           if (i0 >= i1)
19111             i1 = i0 + 1;
19112           while (!(next = updateGroup[i1]) && ++i1 < dataLength)
19113             ;
19114           previous._next = next || null;
19115         }
19116       }
19117     }
19118     update = new Selection(update, parents);
19119     update._enter = enter;
19120     update._exit = exit;
19121     return update;
19122   }
19123   function arraylike(data) {
19124     return typeof data === "object" && "length" in data ? data : Array.from(data);
19125   }
19126
19127   // node_modules/d3-selection/src/selection/exit.js
19128   function exit_default() {
19129     return new Selection(this._exit || this._groups.map(sparse_default), this._parents);
19130   }
19131
19132   // node_modules/d3-selection/src/selection/join.js
19133   function join_default(onenter, onupdate, onexit) {
19134     var enter = this.enter(), update = this, exit = this.exit();
19135     if (typeof onenter === "function") {
19136       enter = onenter(enter);
19137       if (enter)
19138         enter = enter.selection();
19139     } else {
19140       enter = enter.append(onenter + "");
19141     }
19142     if (onupdate != null) {
19143       update = onupdate(update);
19144       if (update)
19145         update = update.selection();
19146     }
19147     if (onexit == null)
19148       exit.remove();
19149     else
19150       onexit(exit);
19151     return enter && update ? enter.merge(update).order() : update;
19152   }
19153
19154   // node_modules/d3-selection/src/selection/merge.js
19155   function merge_default(context) {
19156     var selection2 = context.selection ? context.selection() : context;
19157     for (var groups0 = this._groups, groups1 = selection2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j2 = 0; j2 < m2; ++j2) {
19158       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
19159         if (node = group0[i3] || group1[i3]) {
19160           merge2[i3] = node;
19161         }
19162       }
19163     }
19164     for (; j2 < m0; ++j2) {
19165       merges[j2] = groups0[j2];
19166     }
19167     return new Selection(merges, this._parents);
19168   }
19169
19170   // node_modules/d3-selection/src/selection/order.js
19171   function order_default() {
19172     for (var groups = this._groups, j2 = -1, m2 = groups.length; ++j2 < m2; ) {
19173       for (var group = groups[j2], i3 = group.length - 1, next = group[i3], node; --i3 >= 0; ) {
19174         if (node = group[i3]) {
19175           if (next && node.compareDocumentPosition(next) ^ 4)
19176             next.parentNode.insertBefore(node, next);
19177           next = node;
19178         }
19179       }
19180     }
19181     return this;
19182   }
19183
19184   // node_modules/d3-selection/src/selection/sort.js
19185   function sort_default(compare2) {
19186     if (!compare2)
19187       compare2 = ascending2;
19188     function compareNode(a2, b2) {
19189       return a2 && b2 ? compare2(a2.__data__, b2.__data__) : !a2 - !b2;
19190     }
19191     for (var groups = this._groups, m2 = groups.length, sortgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
19192       for (var group = groups[j2], n3 = group.length, sortgroup = sortgroups[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
19193         if (node = group[i3]) {
19194           sortgroup[i3] = node;
19195         }
19196       }
19197       sortgroup.sort(compareNode);
19198     }
19199     return new Selection(sortgroups, this._parents).order();
19200   }
19201   function ascending2(a2, b2) {
19202     return a2 < b2 ? -1 : a2 > b2 ? 1 : a2 >= b2 ? 0 : NaN;
19203   }
19204
19205   // node_modules/d3-selection/src/selection/call.js
19206   function call_default() {
19207     var callback = arguments[0];
19208     arguments[0] = this;
19209     callback.apply(null, arguments);
19210     return this;
19211   }
19212
19213   // node_modules/d3-selection/src/selection/nodes.js
19214   function nodes_default() {
19215     return Array.from(this);
19216   }
19217
19218   // node_modules/d3-selection/src/selection/node.js
19219   function node_default() {
19220     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
19221       for (var group = groups[j2], i3 = 0, n3 = group.length; i3 < n3; ++i3) {
19222         var node = group[i3];
19223         if (node)
19224           return node;
19225       }
19226     }
19227     return null;
19228   }
19229
19230   // node_modules/d3-selection/src/selection/size.js
19231   function size_default() {
19232     let size = 0;
19233     for (const node of this)
19234       ++size;
19235     return size;
19236   }
19237
19238   // node_modules/d3-selection/src/selection/empty.js
19239   function empty_default() {
19240     return !this.node();
19241   }
19242
19243   // node_modules/d3-selection/src/selection/each.js
19244   function each_default(callback) {
19245     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
19246       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
19247         if (node = group[i3])
19248           callback.call(node, node.__data__, i3, group);
19249       }
19250     }
19251     return this;
19252   }
19253
19254   // node_modules/d3-selection/src/selection/attr.js
19255   function attrRemove(name) {
19256     return function() {
19257       this.removeAttribute(name);
19258     };
19259   }
19260   function attrRemoveNS(fullname) {
19261     return function() {
19262       this.removeAttributeNS(fullname.space, fullname.local);
19263     };
19264   }
19265   function attrConstant(name, value) {
19266     return function() {
19267       this.setAttribute(name, value);
19268     };
19269   }
19270   function attrConstantNS(fullname, value) {
19271     return function() {
19272       this.setAttributeNS(fullname.space, fullname.local, value);
19273     };
19274   }
19275   function attrFunction(name, value) {
19276     return function() {
19277       var v2 = value.apply(this, arguments);
19278       if (v2 == null)
19279         this.removeAttribute(name);
19280       else
19281         this.setAttribute(name, v2);
19282     };
19283   }
19284   function attrFunctionNS(fullname, value) {
19285     return function() {
19286       var v2 = value.apply(this, arguments);
19287       if (v2 == null)
19288         this.removeAttributeNS(fullname.space, fullname.local);
19289       else
19290         this.setAttributeNS(fullname.space, fullname.local, v2);
19291     };
19292   }
19293   function attr_default(name, value) {
19294     var fullname = namespace_default(name);
19295     if (arguments.length < 2) {
19296       var node = this.node();
19297       return fullname.local ? node.getAttributeNS(fullname.space, fullname.local) : node.getAttribute(fullname);
19298     }
19299     return this.each((value == null ? fullname.local ? attrRemoveNS : attrRemove : typeof value === "function" ? fullname.local ? attrFunctionNS : attrFunction : fullname.local ? attrConstantNS : attrConstant)(fullname, value));
19300   }
19301
19302   // node_modules/d3-selection/src/window.js
19303   function window_default(node) {
19304     return node.ownerDocument && node.ownerDocument.defaultView || node.document && node || node.defaultView;
19305   }
19306
19307   // node_modules/d3-selection/src/selection/style.js
19308   function styleRemove(name) {
19309     return function() {
19310       this.style.removeProperty(name);
19311     };
19312   }
19313   function styleConstant(name, value, priority) {
19314     return function() {
19315       this.style.setProperty(name, value, priority);
19316     };
19317   }
19318   function styleFunction(name, value, priority) {
19319     return function() {
19320       var v2 = value.apply(this, arguments);
19321       if (v2 == null)
19322         this.style.removeProperty(name);
19323       else
19324         this.style.setProperty(name, v2, priority);
19325     };
19326   }
19327   function style_default(name, value, priority) {
19328     return arguments.length > 1 ? this.each((value == null ? styleRemove : typeof value === "function" ? styleFunction : styleConstant)(name, value, priority == null ? "" : priority)) : styleValue(this.node(), name);
19329   }
19330   function styleValue(node, name) {
19331     return node.style.getPropertyValue(name) || window_default(node).getComputedStyle(node, null).getPropertyValue(name);
19332   }
19333
19334   // node_modules/d3-selection/src/selection/property.js
19335   function propertyRemove(name) {
19336     return function() {
19337       delete this[name];
19338     };
19339   }
19340   function propertyConstant(name, value) {
19341     return function() {
19342       this[name] = value;
19343     };
19344   }
19345   function propertyFunction(name, value) {
19346     return function() {
19347       var v2 = value.apply(this, arguments);
19348       if (v2 == null)
19349         delete this[name];
19350       else
19351         this[name] = v2;
19352     };
19353   }
19354   function property_default(name, value) {
19355     return arguments.length > 1 ? this.each((value == null ? propertyRemove : typeof value === "function" ? propertyFunction : propertyConstant)(name, value)) : this.node()[name];
19356   }
19357
19358   // node_modules/d3-selection/src/selection/classed.js
19359   function classArray(string) {
19360     return string.trim().split(/^|\s+/);
19361   }
19362   function classList(node) {
19363     return node.classList || new ClassList(node);
19364   }
19365   function ClassList(node) {
19366     this._node = node;
19367     this._names = classArray(node.getAttribute("class") || "");
19368   }
19369   ClassList.prototype = {
19370     add: function(name) {
19371       var i3 = this._names.indexOf(name);
19372       if (i3 < 0) {
19373         this._names.push(name);
19374         this._node.setAttribute("class", this._names.join(" "));
19375       }
19376     },
19377     remove: function(name) {
19378       var i3 = this._names.indexOf(name);
19379       if (i3 >= 0) {
19380         this._names.splice(i3, 1);
19381         this._node.setAttribute("class", this._names.join(" "));
19382       }
19383     },
19384     contains: function(name) {
19385       return this._names.indexOf(name) >= 0;
19386     }
19387   };
19388   function classedAdd(node, names) {
19389     var list2 = classList(node), i3 = -1, n3 = names.length;
19390     while (++i3 < n3)
19391       list2.add(names[i3]);
19392   }
19393   function classedRemove(node, names) {
19394     var list2 = classList(node), i3 = -1, n3 = names.length;
19395     while (++i3 < n3)
19396       list2.remove(names[i3]);
19397   }
19398   function classedTrue(names) {
19399     return function() {
19400       classedAdd(this, names);
19401     };
19402   }
19403   function classedFalse(names) {
19404     return function() {
19405       classedRemove(this, names);
19406     };
19407   }
19408   function classedFunction(names, value) {
19409     return function() {
19410       (value.apply(this, arguments) ? classedAdd : classedRemove)(this, names);
19411     };
19412   }
19413   function classed_default(name, value) {
19414     var names = classArray(name + "");
19415     if (arguments.length < 2) {
19416       var list2 = classList(this.node()), i3 = -1, n3 = names.length;
19417       while (++i3 < n3)
19418         if (!list2.contains(names[i3]))
19419           return false;
19420       return true;
19421     }
19422     return this.each((typeof value === "function" ? classedFunction : value ? classedTrue : classedFalse)(names, value));
19423   }
19424
19425   // node_modules/d3-selection/src/selection/text.js
19426   function textRemove() {
19427     this.textContent = "";
19428   }
19429   function textConstant(value) {
19430     return function() {
19431       this.textContent = value;
19432     };
19433   }
19434   function textFunction(value) {
19435     return function() {
19436       var v2 = value.apply(this, arguments);
19437       this.textContent = v2 == null ? "" : v2;
19438     };
19439   }
19440   function text_default(value) {
19441     return arguments.length ? this.each(value == null ? textRemove : (typeof value === "function" ? textFunction : textConstant)(value)) : this.node().textContent;
19442   }
19443
19444   // node_modules/d3-selection/src/selection/html.js
19445   function htmlRemove() {
19446     this.innerHTML = "";
19447   }
19448   function htmlConstant(value) {
19449     return function() {
19450       this.innerHTML = value;
19451     };
19452   }
19453   function htmlFunction(value) {
19454     return function() {
19455       var v2 = value.apply(this, arguments);
19456       this.innerHTML = v2 == null ? "" : v2;
19457     };
19458   }
19459   function html_default(value) {
19460     return arguments.length ? this.each(value == null ? htmlRemove : (typeof value === "function" ? htmlFunction : htmlConstant)(value)) : this.node().innerHTML;
19461   }
19462
19463   // node_modules/d3-selection/src/selection/raise.js
19464   function raise() {
19465     if (this.nextSibling)
19466       this.parentNode.appendChild(this);
19467   }
19468   function raise_default() {
19469     return this.each(raise);
19470   }
19471
19472   // node_modules/d3-selection/src/selection/lower.js
19473   function lower() {
19474     if (this.previousSibling)
19475       this.parentNode.insertBefore(this, this.parentNode.firstChild);
19476   }
19477   function lower_default() {
19478     return this.each(lower);
19479   }
19480
19481   // node_modules/d3-selection/src/selection/append.js
19482   function append_default(name) {
19483     var create2 = typeof name === "function" ? name : creator_default(name);
19484     return this.select(function() {
19485       return this.appendChild(create2.apply(this, arguments));
19486     });
19487   }
19488
19489   // node_modules/d3-selection/src/selection/insert.js
19490   function constantNull() {
19491     return null;
19492   }
19493   function insert_default(name, before) {
19494     var create2 = typeof name === "function" ? name : creator_default(name), select = before == null ? constantNull : typeof before === "function" ? before : selector_default(before);
19495     return this.select(function() {
19496       return this.insertBefore(create2.apply(this, arguments), select.apply(this, arguments) || null);
19497     });
19498   }
19499
19500   // node_modules/d3-selection/src/selection/remove.js
19501   function remove() {
19502     var parent = this.parentNode;
19503     if (parent)
19504       parent.removeChild(this);
19505   }
19506   function remove_default() {
19507     return this.each(remove);
19508   }
19509
19510   // node_modules/d3-selection/src/selection/clone.js
19511   function selection_cloneShallow() {
19512     var clone2 = this.cloneNode(false), parent = this.parentNode;
19513     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
19514   }
19515   function selection_cloneDeep() {
19516     var clone2 = this.cloneNode(true), parent = this.parentNode;
19517     return parent ? parent.insertBefore(clone2, this.nextSibling) : clone2;
19518   }
19519   function clone_default(deep) {
19520     return this.select(deep ? selection_cloneDeep : selection_cloneShallow);
19521   }
19522
19523   // node_modules/d3-selection/src/selection/datum.js
19524   function datum_default(value) {
19525     return arguments.length ? this.property("__data__", value) : this.node().__data__;
19526   }
19527
19528   // node_modules/d3-selection/src/selection/on.js
19529   function contextListener(listener) {
19530     return function(event) {
19531       listener.call(this, event, this.__data__);
19532     };
19533   }
19534   function parseTypenames2(typenames) {
19535     return typenames.trim().split(/^|\s+/).map(function(t2) {
19536       var name = "", i3 = t2.indexOf(".");
19537       if (i3 >= 0)
19538         name = t2.slice(i3 + 1), t2 = t2.slice(0, i3);
19539       return { type: t2, name };
19540     });
19541   }
19542   function onRemove(typename) {
19543     return function() {
19544       var on = this.__on;
19545       if (!on)
19546         return;
19547       for (var j2 = 0, i3 = -1, m2 = on.length, o2; j2 < m2; ++j2) {
19548         if (o2 = on[j2], (!typename.type || o2.type === typename.type) && o2.name === typename.name) {
19549           this.removeEventListener(o2.type, o2.listener, o2.options);
19550         } else {
19551           on[++i3] = o2;
19552         }
19553       }
19554       if (++i3)
19555         on.length = i3;
19556       else
19557         delete this.__on;
19558     };
19559   }
19560   function onAdd(typename, value, options2) {
19561     return function() {
19562       var on = this.__on, o2, listener = contextListener(value);
19563       if (on)
19564         for (var j2 = 0, m2 = on.length; j2 < m2; ++j2) {
19565           if ((o2 = on[j2]).type === typename.type && o2.name === typename.name) {
19566             this.removeEventListener(o2.type, o2.listener, o2.options);
19567             this.addEventListener(o2.type, o2.listener = listener, o2.options = options2);
19568             o2.value = value;
19569             return;
19570           }
19571         }
19572       this.addEventListener(typename.type, listener, options2);
19573       o2 = { type: typename.type, name: typename.name, value, listener, options: options2 };
19574       if (!on)
19575         this.__on = [o2];
19576       else
19577         on.push(o2);
19578     };
19579   }
19580   function on_default(typename, value, options2) {
19581     var typenames = parseTypenames2(typename + ""), i3, n3 = typenames.length, t2;
19582     if (arguments.length < 2) {
19583       var on = this.node().__on;
19584       if (on)
19585         for (var j2 = 0, m2 = on.length, o2; j2 < m2; ++j2) {
19586           for (i3 = 0, o2 = on[j2]; i3 < n3; ++i3) {
19587             if ((t2 = typenames[i3]).type === o2.type && t2.name === o2.name) {
19588               return o2.value;
19589             }
19590           }
19591         }
19592       return;
19593     }
19594     on = value ? onAdd : onRemove;
19595     for (i3 = 0; i3 < n3; ++i3)
19596       this.each(on(typenames[i3], value, options2));
19597     return this;
19598   }
19599
19600   // node_modules/d3-selection/src/selection/dispatch.js
19601   function dispatchEvent(node, type2, params) {
19602     var window2 = window_default(node), event = window2.CustomEvent;
19603     if (typeof event === "function") {
19604       event = new event(type2, params);
19605     } else {
19606       event = window2.document.createEvent("Event");
19607       if (params)
19608         event.initEvent(type2, params.bubbles, params.cancelable), event.detail = params.detail;
19609       else
19610         event.initEvent(type2, false, false);
19611     }
19612     node.dispatchEvent(event);
19613   }
19614   function dispatchConstant(type2, params) {
19615     return function() {
19616       return dispatchEvent(this, type2, params);
19617     };
19618   }
19619   function dispatchFunction(type2, params) {
19620     return function() {
19621       return dispatchEvent(this, type2, params.apply(this, arguments));
19622     };
19623   }
19624   function dispatch_default2(type2, params) {
19625     return this.each((typeof params === "function" ? dispatchFunction : dispatchConstant)(type2, params));
19626   }
19627
19628   // node_modules/d3-selection/src/selection/iterator.js
19629   function* iterator_default() {
19630     for (var groups = this._groups, j2 = 0, m2 = groups.length; j2 < m2; ++j2) {
19631       for (var group = groups[j2], i3 = 0, n3 = group.length, node; i3 < n3; ++i3) {
19632         if (node = group[i3])
19633           yield node;
19634       }
19635     }
19636   }
19637
19638   // node_modules/d3-selection/src/selection/index.js
19639   var root = [null];
19640   function Selection(groups, parents) {
19641     this._groups = groups;
19642     this._parents = parents;
19643   }
19644   function selection() {
19645     return new Selection([[document.documentElement]], root);
19646   }
19647   function selection_selection() {
19648     return this;
19649   }
19650   Selection.prototype = selection.prototype = {
19651     constructor: Selection,
19652     select: select_default,
19653     selectAll: selectAll_default,
19654     selectChild: selectChild_default,
19655     selectChildren: selectChildren_default,
19656     filter: filter_default,
19657     data: data_default,
19658     enter: enter_default,
19659     exit: exit_default,
19660     join: join_default,
19661     merge: merge_default,
19662     selection: selection_selection,
19663     order: order_default,
19664     sort: sort_default,
19665     call: call_default,
19666     nodes: nodes_default,
19667     node: node_default,
19668     size: size_default,
19669     empty: empty_default,
19670     each: each_default,
19671     attr: attr_default,
19672     style: style_default,
19673     property: property_default,
19674     classed: classed_default,
19675     text: text_default,
19676     html: html_default,
19677     raise: raise_default,
19678     lower: lower_default,
19679     append: append_default,
19680     insert: insert_default,
19681     remove: remove_default,
19682     clone: clone_default,
19683     datum: datum_default,
19684     on: on_default,
19685     dispatch: dispatch_default2,
19686     [Symbol.iterator]: iterator_default
19687   };
19688   var selection_default = selection;
19689
19690   // node_modules/d3-selection/src/select.js
19691   function select_default2(selector) {
19692     return typeof selector === "string" ? new Selection([[document.querySelector(selector)]], [document.documentElement]) : new Selection([[selector]], root);
19693   }
19694
19695   // node_modules/d3-selection/src/sourceEvent.js
19696   function sourceEvent_default(event) {
19697     let sourceEvent;
19698     while (sourceEvent = event.sourceEvent)
19699       event = sourceEvent;
19700     return event;
19701   }
19702
19703   // node_modules/d3-selection/src/pointer.js
19704   function pointer_default(event, node) {
19705     event = sourceEvent_default(event);
19706     if (node === void 0)
19707       node = event.currentTarget;
19708     if (node) {
19709       var svg2 = node.ownerSVGElement || node;
19710       if (svg2.createSVGPoint) {
19711         var point2 = svg2.createSVGPoint();
19712         point2.x = event.clientX, point2.y = event.clientY;
19713         point2 = point2.matrixTransform(node.getScreenCTM().inverse());
19714         return [point2.x, point2.y];
19715       }
19716       if (node.getBoundingClientRect) {
19717         var rect = node.getBoundingClientRect();
19718         return [event.clientX - rect.left - node.clientLeft, event.clientY - rect.top - node.clientTop];
19719       }
19720     }
19721     return [event.pageX, event.pageY];
19722   }
19723
19724   // node_modules/d3-selection/src/selectAll.js
19725   function selectAll_default2(selector) {
19726     return typeof selector === "string" ? new Selection([document.querySelectorAll(selector)], [document.documentElement]) : new Selection([array(selector)], root);
19727   }
19728
19729   // node_modules/d3-drag/src/noevent.js
19730   var nonpassive = { passive: false };
19731   var nonpassivecapture = { capture: true, passive: false };
19732   function nopropagation(event) {
19733     event.stopImmediatePropagation();
19734   }
19735   function noevent_default(event) {
19736     event.preventDefault();
19737     event.stopImmediatePropagation();
19738   }
19739
19740   // node_modules/d3-drag/src/nodrag.js
19741   function nodrag_default(view) {
19742     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", noevent_default, nonpassivecapture);
19743     if ("onselectstart" in root3) {
19744       selection2.on("selectstart.drag", noevent_default, nonpassivecapture);
19745     } else {
19746       root3.__noselect = root3.style.MozUserSelect;
19747       root3.style.MozUserSelect = "none";
19748     }
19749   }
19750   function yesdrag(view, noclick) {
19751     var root3 = view.document.documentElement, selection2 = select_default2(view).on("dragstart.drag", null);
19752     if (noclick) {
19753       selection2.on("click.drag", noevent_default, nonpassivecapture);
19754       setTimeout(function() {
19755         selection2.on("click.drag", null);
19756       }, 0);
19757     }
19758     if ("onselectstart" in root3) {
19759       selection2.on("selectstart.drag", null);
19760     } else {
19761       root3.style.MozUserSelect = root3.__noselect;
19762       delete root3.__noselect;
19763     }
19764   }
19765
19766   // node_modules/d3-drag/src/constant.js
19767   var constant_default2 = (x2) => () => x2;
19768
19769   // node_modules/d3-drag/src/event.js
19770   function DragEvent(type2, {
19771     sourceEvent,
19772     subject,
19773     target,
19774     identifier,
19775     active,
19776     x: x2,
19777     y: y2,
19778     dx,
19779     dy,
19780     dispatch: dispatch14
19781   }) {
19782     Object.defineProperties(this, {
19783       type: { value: type2, enumerable: true, configurable: true },
19784       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
19785       subject: { value: subject, enumerable: true, configurable: true },
19786       target: { value: target, enumerable: true, configurable: true },
19787       identifier: { value: identifier, enumerable: true, configurable: true },
19788       active: { value: active, enumerable: true, configurable: true },
19789       x: { value: x2, enumerable: true, configurable: true },
19790       y: { value: y2, enumerable: true, configurable: true },
19791       dx: { value: dx, enumerable: true, configurable: true },
19792       dy: { value: dy, enumerable: true, configurable: true },
19793       _: { value: dispatch14 }
19794     });
19795   }
19796   DragEvent.prototype.on = function() {
19797     var value = this._.on.apply(this._, arguments);
19798     return value === this._ ? this : value;
19799   };
19800
19801   // node_modules/d3-drag/src/drag.js
19802   function defaultFilter(event) {
19803     return !event.ctrlKey && !event.button;
19804   }
19805   function defaultContainer() {
19806     return this.parentNode;
19807   }
19808   function defaultSubject(event, d2) {
19809     return d2 == null ? { x: event.x, y: event.y } : d2;
19810   }
19811   function defaultTouchable() {
19812     return navigator.maxTouchPoints || "ontouchstart" in this;
19813   }
19814   function drag_default() {
19815     var filter2 = defaultFilter, container = defaultContainer, subject = defaultSubject, touchable = defaultTouchable, gestures = {}, listeners = dispatch_default("start", "drag", "end"), active = 0, mousedownx, mousedowny, mousemoving, touchending, clickDistance2 = 0;
19816     function drag(selection2) {
19817       selection2.on("mousedown.drag", mousedowned).filter(touchable).on("touchstart.drag", touchstarted).on("touchmove.drag", touchmoved, nonpassive).on("touchend.drag touchcancel.drag", touchended).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
19818     }
19819     function mousedowned(event, d2) {
19820       if (touchending || !filter2.call(this, event, d2))
19821         return;
19822       var gesture = beforestart(this, container.call(this, event, d2), event, d2, "mouse");
19823       if (!gesture)
19824         return;
19825       select_default2(event.view).on("mousemove.drag", mousemoved, nonpassivecapture).on("mouseup.drag", mouseupped, nonpassivecapture);
19826       nodrag_default(event.view);
19827       nopropagation(event);
19828       mousemoving = false;
19829       mousedownx = event.clientX;
19830       mousedowny = event.clientY;
19831       gesture("start", event);
19832     }
19833     function mousemoved(event) {
19834       noevent_default(event);
19835       if (!mousemoving) {
19836         var dx = event.clientX - mousedownx, dy = event.clientY - mousedowny;
19837         mousemoving = dx * dx + dy * dy > clickDistance2;
19838       }
19839       gestures.mouse("drag", event);
19840     }
19841     function mouseupped(event) {
19842       select_default2(event.view).on("mousemove.drag mouseup.drag", null);
19843       yesdrag(event.view, mousemoving);
19844       noevent_default(event);
19845       gestures.mouse("end", event);
19846     }
19847     function touchstarted(event, d2) {
19848       if (!filter2.call(this, event, d2))
19849         return;
19850       var touches = event.changedTouches, c2 = container.call(this, event, d2), n3 = touches.length, i3, gesture;
19851       for (i3 = 0; i3 < n3; ++i3) {
19852         if (gesture = beforestart(this, c2, event, d2, touches[i3].identifier, touches[i3])) {
19853           nopropagation(event);
19854           gesture("start", event, touches[i3]);
19855         }
19856       }
19857     }
19858     function touchmoved(event) {
19859       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
19860       for (i3 = 0; i3 < n3; ++i3) {
19861         if (gesture = gestures[touches[i3].identifier]) {
19862           noevent_default(event);
19863           gesture("drag", event, touches[i3]);
19864         }
19865       }
19866     }
19867     function touchended(event) {
19868       var touches = event.changedTouches, n3 = touches.length, i3, gesture;
19869       if (touchending)
19870         clearTimeout(touchending);
19871       touchending = setTimeout(function() {
19872         touchending = null;
19873       }, 500);
19874       for (i3 = 0; i3 < n3; ++i3) {
19875         if (gesture = gestures[touches[i3].identifier]) {
19876           nopropagation(event);
19877           gesture("end", event, touches[i3]);
19878         }
19879       }
19880     }
19881     function beforestart(that, container2, event, d2, identifier, touch) {
19882       var dispatch14 = listeners.copy(), p2 = pointer_default(touch || event, container2), dx, dy, s2;
19883       if ((s2 = subject.call(that, new DragEvent("beforestart", {
19884         sourceEvent: event,
19885         target: drag,
19886         identifier,
19887         active,
19888         x: p2[0],
19889         y: p2[1],
19890         dx: 0,
19891         dy: 0,
19892         dispatch: dispatch14
19893       }), d2)) == null)
19894         return;
19895       dx = s2.x - p2[0] || 0;
19896       dy = s2.y - p2[1] || 0;
19897       return function gesture(type2, event2, touch2) {
19898         var p02 = p2, n3;
19899         switch (type2) {
19900           case "start":
19901             gestures[identifier] = gesture, n3 = active++;
19902             break;
19903           case "end":
19904             delete gestures[identifier], --active;
19905           case "drag":
19906             p2 = pointer_default(touch2 || event2, container2), n3 = active;
19907             break;
19908         }
19909         dispatch14.call(
19910           type2,
19911           that,
19912           new DragEvent(type2, {
19913             sourceEvent: event2,
19914             subject: s2,
19915             target: drag,
19916             identifier,
19917             active: n3,
19918             x: p2[0] + dx,
19919             y: p2[1] + dy,
19920             dx: p2[0] - p02[0],
19921             dy: p2[1] - p02[1],
19922             dispatch: dispatch14
19923           }),
19924           d2
19925         );
19926       };
19927     }
19928     drag.filter = function(_2) {
19929       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : filter2;
19930     };
19931     drag.container = function(_2) {
19932       return arguments.length ? (container = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : container;
19933     };
19934     drag.subject = function(_2) {
19935       return arguments.length ? (subject = typeof _2 === "function" ? _2 : constant_default2(_2), drag) : subject;
19936     };
19937     drag.touchable = function(_2) {
19938       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default2(!!_2), drag) : touchable;
19939     };
19940     drag.on = function() {
19941       var value = listeners.on.apply(listeners, arguments);
19942       return value === listeners ? drag : value;
19943     };
19944     drag.clickDistance = function(_2) {
19945       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, drag) : Math.sqrt(clickDistance2);
19946     };
19947     return drag;
19948   }
19949
19950   // node_modules/d3-color/src/define.js
19951   function define_default(constructor, factory, prototype) {
19952     constructor.prototype = factory.prototype = prototype;
19953     prototype.constructor = constructor;
19954   }
19955   function extend(parent, definition) {
19956     var prototype = Object.create(parent.prototype);
19957     for (var key in definition)
19958       prototype[key] = definition[key];
19959     return prototype;
19960   }
19961
19962   // node_modules/d3-color/src/color.js
19963   function Color() {
19964   }
19965   var darker = 0.7;
19966   var brighter = 1 / darker;
19967   var reI = "\\s*([+-]?\\d+)\\s*";
19968   var reN = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*";
19969   var reP = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*";
19970   var reHex = /^#([0-9a-f]{3,8})$/;
19971   var reRgbInteger = new RegExp("^rgb\\(".concat(reI, ",").concat(reI, ",").concat(reI, "\\)$"));
19972   var reRgbPercent = new RegExp("^rgb\\(".concat(reP, ",").concat(reP, ",").concat(reP, "\\)$"));
19973   var reRgbaInteger = new RegExp("^rgba\\(".concat(reI, ",").concat(reI, ",").concat(reI, ",").concat(reN, "\\)$"));
19974   var reRgbaPercent = new RegExp("^rgba\\(".concat(reP, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
19975   var reHslPercent = new RegExp("^hsl\\(".concat(reN, ",").concat(reP, ",").concat(reP, "\\)$"));
19976   var reHslaPercent = new RegExp("^hsla\\(".concat(reN, ",").concat(reP, ",").concat(reP, ",").concat(reN, "\\)$"));
19977   var named = {
19978     aliceblue: 15792383,
19979     antiquewhite: 16444375,
19980     aqua: 65535,
19981     aquamarine: 8388564,
19982     azure: 15794175,
19983     beige: 16119260,
19984     bisque: 16770244,
19985     black: 0,
19986     blanchedalmond: 16772045,
19987     blue: 255,
19988     blueviolet: 9055202,
19989     brown: 10824234,
19990     burlywood: 14596231,
19991     cadetblue: 6266528,
19992     chartreuse: 8388352,
19993     chocolate: 13789470,
19994     coral: 16744272,
19995     cornflowerblue: 6591981,
19996     cornsilk: 16775388,
19997     crimson: 14423100,
19998     cyan: 65535,
19999     darkblue: 139,
20000     darkcyan: 35723,
20001     darkgoldenrod: 12092939,
20002     darkgray: 11119017,
20003     darkgreen: 25600,
20004     darkgrey: 11119017,
20005     darkkhaki: 12433259,
20006     darkmagenta: 9109643,
20007     darkolivegreen: 5597999,
20008     darkorange: 16747520,
20009     darkorchid: 10040012,
20010     darkred: 9109504,
20011     darksalmon: 15308410,
20012     darkseagreen: 9419919,
20013     darkslateblue: 4734347,
20014     darkslategray: 3100495,
20015     darkslategrey: 3100495,
20016     darkturquoise: 52945,
20017     darkviolet: 9699539,
20018     deeppink: 16716947,
20019     deepskyblue: 49151,
20020     dimgray: 6908265,
20021     dimgrey: 6908265,
20022     dodgerblue: 2003199,
20023     firebrick: 11674146,
20024     floralwhite: 16775920,
20025     forestgreen: 2263842,
20026     fuchsia: 16711935,
20027     gainsboro: 14474460,
20028     ghostwhite: 16316671,
20029     gold: 16766720,
20030     goldenrod: 14329120,
20031     gray: 8421504,
20032     green: 32768,
20033     greenyellow: 11403055,
20034     grey: 8421504,
20035     honeydew: 15794160,
20036     hotpink: 16738740,
20037     indianred: 13458524,
20038     indigo: 4915330,
20039     ivory: 16777200,
20040     khaki: 15787660,
20041     lavender: 15132410,
20042     lavenderblush: 16773365,
20043     lawngreen: 8190976,
20044     lemonchiffon: 16775885,
20045     lightblue: 11393254,
20046     lightcoral: 15761536,
20047     lightcyan: 14745599,
20048     lightgoldenrodyellow: 16448210,
20049     lightgray: 13882323,
20050     lightgreen: 9498256,
20051     lightgrey: 13882323,
20052     lightpink: 16758465,
20053     lightsalmon: 16752762,
20054     lightseagreen: 2142890,
20055     lightskyblue: 8900346,
20056     lightslategray: 7833753,
20057     lightslategrey: 7833753,
20058     lightsteelblue: 11584734,
20059     lightyellow: 16777184,
20060     lime: 65280,
20061     limegreen: 3329330,
20062     linen: 16445670,
20063     magenta: 16711935,
20064     maroon: 8388608,
20065     mediumaquamarine: 6737322,
20066     mediumblue: 205,
20067     mediumorchid: 12211667,
20068     mediumpurple: 9662683,
20069     mediumseagreen: 3978097,
20070     mediumslateblue: 8087790,
20071     mediumspringgreen: 64154,
20072     mediumturquoise: 4772300,
20073     mediumvioletred: 13047173,
20074     midnightblue: 1644912,
20075     mintcream: 16121850,
20076     mistyrose: 16770273,
20077     moccasin: 16770229,
20078     navajowhite: 16768685,
20079     navy: 128,
20080     oldlace: 16643558,
20081     olive: 8421376,
20082     olivedrab: 7048739,
20083     orange: 16753920,
20084     orangered: 16729344,
20085     orchid: 14315734,
20086     palegoldenrod: 15657130,
20087     palegreen: 10025880,
20088     paleturquoise: 11529966,
20089     palevioletred: 14381203,
20090     papayawhip: 16773077,
20091     peachpuff: 16767673,
20092     peru: 13468991,
20093     pink: 16761035,
20094     plum: 14524637,
20095     powderblue: 11591910,
20096     purple: 8388736,
20097     rebeccapurple: 6697881,
20098     red: 16711680,
20099     rosybrown: 12357519,
20100     royalblue: 4286945,
20101     saddlebrown: 9127187,
20102     salmon: 16416882,
20103     sandybrown: 16032864,
20104     seagreen: 3050327,
20105     seashell: 16774638,
20106     sienna: 10506797,
20107     silver: 12632256,
20108     skyblue: 8900331,
20109     slateblue: 6970061,
20110     slategray: 7372944,
20111     slategrey: 7372944,
20112     snow: 16775930,
20113     springgreen: 65407,
20114     steelblue: 4620980,
20115     tan: 13808780,
20116     teal: 32896,
20117     thistle: 14204888,
20118     tomato: 16737095,
20119     turquoise: 4251856,
20120     violet: 15631086,
20121     wheat: 16113331,
20122     white: 16777215,
20123     whitesmoke: 16119285,
20124     yellow: 16776960,
20125     yellowgreen: 10145074
20126   };
20127   define_default(Color, color, {
20128     copy(channels) {
20129       return Object.assign(new this.constructor(), this, channels);
20130     },
20131     displayable() {
20132       return this.rgb().displayable();
20133     },
20134     hex: color_formatHex,
20135     // Deprecated! Use color.formatHex.
20136     formatHex: color_formatHex,
20137     formatHex8: color_formatHex8,
20138     formatHsl: color_formatHsl,
20139     formatRgb: color_formatRgb,
20140     toString: color_formatRgb
20141   });
20142   function color_formatHex() {
20143     return this.rgb().formatHex();
20144   }
20145   function color_formatHex8() {
20146     return this.rgb().formatHex8();
20147   }
20148   function color_formatHsl() {
20149     return hslConvert(this).formatHsl();
20150   }
20151   function color_formatRgb() {
20152     return this.rgb().formatRgb();
20153   }
20154   function color(format2) {
20155     var m2, l2;
20156     format2 = (format2 + "").trim().toLowerCase();
20157     return (m2 = reHex.exec(format2)) ? (l2 = m2[1].length, m2 = parseInt(m2[1], 16), l2 === 6 ? rgbn(m2) : l2 === 3 ? new Rgb(m2 >> 8 & 15 | m2 >> 4 & 240, m2 >> 4 & 15 | m2 & 240, (m2 & 15) << 4 | m2 & 15, 1) : l2 === 8 ? rgba(m2 >> 24 & 255, m2 >> 16 & 255, m2 >> 8 & 255, (m2 & 255) / 255) : l2 === 4 ? rgba(m2 >> 12 & 15 | m2 >> 8 & 240, m2 >> 8 & 15 | m2 >> 4 & 240, m2 >> 4 & 15 | m2 & 240, ((m2 & 15) << 4 | m2 & 15) / 255) : null) : (m2 = reRgbInteger.exec(format2)) ? new Rgb(m2[1], m2[2], m2[3], 1) : (m2 = reRgbPercent.exec(format2)) ? new Rgb(m2[1] * 255 / 100, m2[2] * 255 / 100, m2[3] * 255 / 100, 1) : (m2 = reRgbaInteger.exec(format2)) ? rgba(m2[1], m2[2], m2[3], m2[4]) : (m2 = reRgbaPercent.exec(format2)) ? rgba(m2[1] * 255 / 100, m2[2] * 255 / 100, m2[3] * 255 / 100, m2[4]) : (m2 = reHslPercent.exec(format2)) ? hsla(m2[1], m2[2] / 100, m2[3] / 100, 1) : (m2 = reHslaPercent.exec(format2)) ? hsla(m2[1], m2[2] / 100, m2[3] / 100, m2[4]) : named.hasOwnProperty(format2) ? rgbn(named[format2]) : format2 === "transparent" ? new Rgb(NaN, NaN, NaN, 0) : null;
20158   }
20159   function rgbn(n3) {
20160     return new Rgb(n3 >> 16 & 255, n3 >> 8 & 255, n3 & 255, 1);
20161   }
20162   function rgba(r2, g3, b2, a2) {
20163     if (a2 <= 0)
20164       r2 = g3 = b2 = NaN;
20165     return new Rgb(r2, g3, b2, a2);
20166   }
20167   function rgbConvert(o2) {
20168     if (!(o2 instanceof Color))
20169       o2 = color(o2);
20170     if (!o2)
20171       return new Rgb();
20172     o2 = o2.rgb();
20173     return new Rgb(o2.r, o2.g, o2.b, o2.opacity);
20174   }
20175   function rgb(r2, g3, b2, opacity) {
20176     return arguments.length === 1 ? rgbConvert(r2) : new Rgb(r2, g3, b2, opacity == null ? 1 : opacity);
20177   }
20178   function Rgb(r2, g3, b2, opacity) {
20179     this.r = +r2;
20180     this.g = +g3;
20181     this.b = +b2;
20182     this.opacity = +opacity;
20183   }
20184   define_default(Rgb, rgb, extend(Color, {
20185     brighter(k2) {
20186       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
20187       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
20188     },
20189     darker(k2) {
20190       k2 = k2 == null ? darker : Math.pow(darker, k2);
20191       return new Rgb(this.r * k2, this.g * k2, this.b * k2, this.opacity);
20192     },
20193     rgb() {
20194       return this;
20195     },
20196     clamp() {
20197       return new Rgb(clampi(this.r), clampi(this.g), clampi(this.b), clampa(this.opacity));
20198     },
20199     displayable() {
20200       return -0.5 <= this.r && this.r < 255.5 && (-0.5 <= this.g && this.g < 255.5) && (-0.5 <= this.b && this.b < 255.5) && (0 <= this.opacity && this.opacity <= 1);
20201     },
20202     hex: rgb_formatHex,
20203     // Deprecated! Use color.formatHex.
20204     formatHex: rgb_formatHex,
20205     formatHex8: rgb_formatHex8,
20206     formatRgb: rgb_formatRgb,
20207     toString: rgb_formatRgb
20208   }));
20209   function rgb_formatHex() {
20210     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b));
20211   }
20212   function rgb_formatHex8() {
20213     return "#".concat(hex(this.r)).concat(hex(this.g)).concat(hex(this.b)).concat(hex((isNaN(this.opacity) ? 1 : this.opacity) * 255));
20214   }
20215   function rgb_formatRgb() {
20216     const a2 = clampa(this.opacity);
20217     return "".concat(a2 === 1 ? "rgb(" : "rgba(").concat(clampi(this.r), ", ").concat(clampi(this.g), ", ").concat(clampi(this.b)).concat(a2 === 1 ? ")" : ", ".concat(a2, ")"));
20218   }
20219   function clampa(opacity) {
20220     return isNaN(opacity) ? 1 : Math.max(0, Math.min(1, opacity));
20221   }
20222   function clampi(value) {
20223     return Math.max(0, Math.min(255, Math.round(value) || 0));
20224   }
20225   function hex(value) {
20226     value = clampi(value);
20227     return (value < 16 ? "0" : "") + value.toString(16);
20228   }
20229   function hsla(h2, s2, l2, a2) {
20230     if (a2 <= 0)
20231       h2 = s2 = l2 = NaN;
20232     else if (l2 <= 0 || l2 >= 1)
20233       h2 = s2 = NaN;
20234     else if (s2 <= 0)
20235       h2 = NaN;
20236     return new Hsl(h2, s2, l2, a2);
20237   }
20238   function hslConvert(o2) {
20239     if (o2 instanceof Hsl)
20240       return new Hsl(o2.h, o2.s, o2.l, o2.opacity);
20241     if (!(o2 instanceof Color))
20242       o2 = color(o2);
20243     if (!o2)
20244       return new Hsl();
20245     if (o2 instanceof Hsl)
20246       return o2;
20247     o2 = o2.rgb();
20248     var r2 = o2.r / 255, g3 = o2.g / 255, b2 = o2.b / 255, min3 = Math.min(r2, g3, b2), max3 = Math.max(r2, g3, b2), h2 = NaN, s2 = max3 - min3, l2 = (max3 + min3) / 2;
20249     if (s2) {
20250       if (r2 === max3)
20251         h2 = (g3 - b2) / s2 + (g3 < b2) * 6;
20252       else if (g3 === max3)
20253         h2 = (b2 - r2) / s2 + 2;
20254       else
20255         h2 = (r2 - g3) / s2 + 4;
20256       s2 /= l2 < 0.5 ? max3 + min3 : 2 - max3 - min3;
20257       h2 *= 60;
20258     } else {
20259       s2 = l2 > 0 && l2 < 1 ? 0 : h2;
20260     }
20261     return new Hsl(h2, s2, l2, o2.opacity);
20262   }
20263   function hsl(h2, s2, l2, opacity) {
20264     return arguments.length === 1 ? hslConvert(h2) : new Hsl(h2, s2, l2, opacity == null ? 1 : opacity);
20265   }
20266   function Hsl(h2, s2, l2, opacity) {
20267     this.h = +h2;
20268     this.s = +s2;
20269     this.l = +l2;
20270     this.opacity = +opacity;
20271   }
20272   define_default(Hsl, hsl, extend(Color, {
20273     brighter(k2) {
20274       k2 = k2 == null ? brighter : Math.pow(brighter, k2);
20275       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
20276     },
20277     darker(k2) {
20278       k2 = k2 == null ? darker : Math.pow(darker, k2);
20279       return new Hsl(this.h, this.s, this.l * k2, this.opacity);
20280     },
20281     rgb() {
20282       var h2 = this.h % 360 + (this.h < 0) * 360, s2 = isNaN(h2) || isNaN(this.s) ? 0 : this.s, l2 = this.l, m2 = l2 + (l2 < 0.5 ? l2 : 1 - l2) * s2, m1 = 2 * l2 - m2;
20283       return new Rgb(
20284         hsl2rgb(h2 >= 240 ? h2 - 240 : h2 + 120, m1, m2),
20285         hsl2rgb(h2, m1, m2),
20286         hsl2rgb(h2 < 120 ? h2 + 240 : h2 - 120, m1, m2),
20287         this.opacity
20288       );
20289     },
20290     clamp() {
20291       return new Hsl(clamph(this.h), clampt(this.s), clampt(this.l), clampa(this.opacity));
20292     },
20293     displayable() {
20294       return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && (0 <= this.l && this.l <= 1) && (0 <= this.opacity && this.opacity <= 1);
20295     },
20296     formatHsl() {
20297       const a2 = clampa(this.opacity);
20298       return "".concat(a2 === 1 ? "hsl(" : "hsla(").concat(clamph(this.h), ", ").concat(clampt(this.s) * 100, "%, ").concat(clampt(this.l) * 100, "%").concat(a2 === 1 ? ")" : ", ".concat(a2, ")"));
20299     }
20300   }));
20301   function clamph(value) {
20302     value = (value || 0) % 360;
20303     return value < 0 ? value + 360 : value;
20304   }
20305   function clampt(value) {
20306     return Math.max(0, Math.min(1, value || 0));
20307   }
20308   function hsl2rgb(h2, m1, m2) {
20309     return (h2 < 60 ? m1 + (m2 - m1) * h2 / 60 : h2 < 180 ? m2 : h2 < 240 ? m1 + (m2 - m1) * (240 - h2) / 60 : m1) * 255;
20310   }
20311
20312   // node_modules/d3-interpolate/src/basis.js
20313   function basis(t1, v0, v1, v2, v3) {
20314     var t2 = t1 * t1, t3 = t2 * t1;
20315     return ((1 - 3 * t1 + 3 * t2 - t3) * v0 + (4 - 6 * t2 + 3 * t3) * v1 + (1 + 3 * t1 + 3 * t2 - 3 * t3) * v2 + t3 * v3) / 6;
20316   }
20317   function basis_default(values) {
20318     var n3 = values.length - 1;
20319     return function(t2) {
20320       var i3 = t2 <= 0 ? t2 = 0 : t2 >= 1 ? (t2 = 1, n3 - 1) : Math.floor(t2 * n3), v1 = values[i3], v2 = values[i3 + 1], v0 = i3 > 0 ? values[i3 - 1] : 2 * v1 - v2, v3 = i3 < n3 - 1 ? values[i3 + 2] : 2 * v2 - v1;
20321       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
20322     };
20323   }
20324
20325   // node_modules/d3-interpolate/src/basisClosed.js
20326   function basisClosed_default(values) {
20327     var n3 = values.length;
20328     return function(t2) {
20329       var i3 = Math.floor(((t2 %= 1) < 0 ? ++t2 : t2) * n3), v0 = values[(i3 + n3 - 1) % n3], v1 = values[i3 % n3], v2 = values[(i3 + 1) % n3], v3 = values[(i3 + 2) % n3];
20330       return basis((t2 - i3 / n3) * n3, v0, v1, v2, v3);
20331     };
20332   }
20333
20334   // node_modules/d3-interpolate/src/constant.js
20335   var constant_default3 = (x2) => () => x2;
20336
20337   // node_modules/d3-interpolate/src/color.js
20338   function linear(a2, d2) {
20339     return function(t2) {
20340       return a2 + t2 * d2;
20341     };
20342   }
20343   function exponential(a2, b2, y2) {
20344     return a2 = Math.pow(a2, y2), b2 = Math.pow(b2, y2) - a2, y2 = 1 / y2, function(t2) {
20345       return Math.pow(a2 + t2 * b2, y2);
20346     };
20347   }
20348   function gamma(y2) {
20349     return (y2 = +y2) === 1 ? nogamma : function(a2, b2) {
20350       return b2 - a2 ? exponential(a2, b2, y2) : constant_default3(isNaN(a2) ? b2 : a2);
20351     };
20352   }
20353   function nogamma(a2, b2) {
20354     var d2 = b2 - a2;
20355     return d2 ? linear(a2, d2) : constant_default3(isNaN(a2) ? b2 : a2);
20356   }
20357
20358   // node_modules/d3-interpolate/src/rgb.js
20359   var rgb_default = function rgbGamma(y2) {
20360     var color2 = gamma(y2);
20361     function rgb2(start2, end) {
20362       var r2 = color2((start2 = rgb(start2)).r, (end = rgb(end)).r), g3 = color2(start2.g, end.g), b2 = color2(start2.b, end.b), opacity = nogamma(start2.opacity, end.opacity);
20363       return function(t2) {
20364         start2.r = r2(t2);
20365         start2.g = g3(t2);
20366         start2.b = b2(t2);
20367         start2.opacity = opacity(t2);
20368         return start2 + "";
20369       };
20370     }
20371     rgb2.gamma = rgbGamma;
20372     return rgb2;
20373   }(1);
20374   function rgbSpline(spline) {
20375     return function(colors) {
20376       var n3 = colors.length, r2 = new Array(n3), g3 = new Array(n3), b2 = new Array(n3), i3, color2;
20377       for (i3 = 0; i3 < n3; ++i3) {
20378         color2 = rgb(colors[i3]);
20379         r2[i3] = color2.r || 0;
20380         g3[i3] = color2.g || 0;
20381         b2[i3] = color2.b || 0;
20382       }
20383       r2 = spline(r2);
20384       g3 = spline(g3);
20385       b2 = spline(b2);
20386       color2.opacity = 1;
20387       return function(t2) {
20388         color2.r = r2(t2);
20389         color2.g = g3(t2);
20390         color2.b = b2(t2);
20391         return color2 + "";
20392       };
20393     };
20394   }
20395   var rgbBasis = rgbSpline(basis_default);
20396   var rgbBasisClosed = rgbSpline(basisClosed_default);
20397
20398   // node_modules/d3-interpolate/src/numberArray.js
20399   function numberArray_default(a2, b2) {
20400     if (!b2)
20401       b2 = [];
20402     var n3 = a2 ? Math.min(b2.length, a2.length) : 0, c2 = b2.slice(), i3;
20403     return function(t2) {
20404       for (i3 = 0; i3 < n3; ++i3)
20405         c2[i3] = a2[i3] * (1 - t2) + b2[i3] * t2;
20406       return c2;
20407     };
20408   }
20409   function isNumberArray(x2) {
20410     return ArrayBuffer.isView(x2) && !(x2 instanceof DataView);
20411   }
20412
20413   // node_modules/d3-interpolate/src/array.js
20414   function genericArray(a2, b2) {
20415     var nb = b2 ? b2.length : 0, na = a2 ? Math.min(nb, a2.length) : 0, x2 = new Array(na), c2 = new Array(nb), i3;
20416     for (i3 = 0; i3 < na; ++i3)
20417       x2[i3] = value_default(a2[i3], b2[i3]);
20418     for (; i3 < nb; ++i3)
20419       c2[i3] = b2[i3];
20420     return function(t2) {
20421       for (i3 = 0; i3 < na; ++i3)
20422         c2[i3] = x2[i3](t2);
20423       return c2;
20424     };
20425   }
20426
20427   // node_modules/d3-interpolate/src/date.js
20428   function date_default(a2, b2) {
20429     var d2 = /* @__PURE__ */ new Date();
20430     return a2 = +a2, b2 = +b2, function(t2) {
20431       return d2.setTime(a2 * (1 - t2) + b2 * t2), d2;
20432     };
20433   }
20434
20435   // node_modules/d3-interpolate/src/number.js
20436   function number_default(a2, b2) {
20437     return a2 = +a2, b2 = +b2, function(t2) {
20438       return a2 * (1 - t2) + b2 * t2;
20439     };
20440   }
20441
20442   // node_modules/d3-interpolate/src/object.js
20443   function object_default(a2, b2) {
20444     var i3 = {}, c2 = {}, k2;
20445     if (a2 === null || typeof a2 !== "object")
20446       a2 = {};
20447     if (b2 === null || typeof b2 !== "object")
20448       b2 = {};
20449     for (k2 in b2) {
20450       if (k2 in a2) {
20451         i3[k2] = value_default(a2[k2], b2[k2]);
20452       } else {
20453         c2[k2] = b2[k2];
20454       }
20455     }
20456     return function(t2) {
20457       for (k2 in i3)
20458         c2[k2] = i3[k2](t2);
20459       return c2;
20460     };
20461   }
20462
20463   // node_modules/d3-interpolate/src/string.js
20464   var reA = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g;
20465   var reB = new RegExp(reA.source, "g");
20466   function zero2(b2) {
20467     return function() {
20468       return b2;
20469     };
20470   }
20471   function one(b2) {
20472     return function(t2) {
20473       return b2(t2) + "";
20474     };
20475   }
20476   function string_default(a2, b2) {
20477     var bi = reA.lastIndex = reB.lastIndex = 0, am, bm, bs, i3 = -1, s2 = [], q2 = [];
20478     a2 = a2 + "", b2 = b2 + "";
20479     while ((am = reA.exec(a2)) && (bm = reB.exec(b2))) {
20480       if ((bs = bm.index) > bi) {
20481         bs = b2.slice(bi, bs);
20482         if (s2[i3])
20483           s2[i3] += bs;
20484         else
20485           s2[++i3] = bs;
20486       }
20487       if ((am = am[0]) === (bm = bm[0])) {
20488         if (s2[i3])
20489           s2[i3] += bm;
20490         else
20491           s2[++i3] = bm;
20492       } else {
20493         s2[++i3] = null;
20494         q2.push({ i: i3, x: number_default(am, bm) });
20495       }
20496       bi = reB.lastIndex;
20497     }
20498     if (bi < b2.length) {
20499       bs = b2.slice(bi);
20500       if (s2[i3])
20501         s2[i3] += bs;
20502       else
20503         s2[++i3] = bs;
20504     }
20505     return s2.length < 2 ? q2[0] ? one(q2[0].x) : zero2(b2) : (b2 = q2.length, function(t2) {
20506       for (var i4 = 0, o2; i4 < b2; ++i4)
20507         s2[(o2 = q2[i4]).i] = o2.x(t2);
20508       return s2.join("");
20509     });
20510   }
20511
20512   // node_modules/d3-interpolate/src/value.js
20513   function value_default(a2, b2) {
20514     var t2 = typeof b2, c2;
20515     return b2 == null || t2 === "boolean" ? constant_default3(b2) : (t2 === "number" ? number_default : t2 === "string" ? (c2 = color(b2)) ? (b2 = c2, rgb_default) : string_default : b2 instanceof color ? rgb_default : b2 instanceof Date ? date_default : isNumberArray(b2) ? numberArray_default : Array.isArray(b2) ? genericArray : typeof b2.valueOf !== "function" && typeof b2.toString !== "function" || isNaN(b2) ? object_default : number_default)(a2, b2);
20516   }
20517
20518   // node_modules/d3-interpolate/src/round.js
20519   function round_default(a2, b2) {
20520     return a2 = +a2, b2 = +b2, function(t2) {
20521       return Math.round(a2 * (1 - t2) + b2 * t2);
20522     };
20523   }
20524
20525   // node_modules/d3-interpolate/src/transform/decompose.js
20526   var degrees2 = 180 / Math.PI;
20527   var identity = {
20528     translateX: 0,
20529     translateY: 0,
20530     rotate: 0,
20531     skewX: 0,
20532     scaleX: 1,
20533     scaleY: 1
20534   };
20535   function decompose_default(a2, b2, c2, d2, e3, f2) {
20536     var scaleX, scaleY, skewX;
20537     if (scaleX = Math.sqrt(a2 * a2 + b2 * b2))
20538       a2 /= scaleX, b2 /= scaleX;
20539     if (skewX = a2 * c2 + b2 * d2)
20540       c2 -= a2 * skewX, d2 -= b2 * skewX;
20541     if (scaleY = Math.sqrt(c2 * c2 + d2 * d2))
20542       c2 /= scaleY, d2 /= scaleY, skewX /= scaleY;
20543     if (a2 * d2 < b2 * c2)
20544       a2 = -a2, b2 = -b2, skewX = -skewX, scaleX = -scaleX;
20545     return {
20546       translateX: e3,
20547       translateY: f2,
20548       rotate: Math.atan2(b2, a2) * degrees2,
20549       skewX: Math.atan(skewX) * degrees2,
20550       scaleX,
20551       scaleY
20552     };
20553   }
20554
20555   // node_modules/d3-interpolate/src/transform/parse.js
20556   var svgNode;
20557   function parseCss(value) {
20558     const m2 = new (typeof DOMMatrix === "function" ? DOMMatrix : WebKitCSSMatrix)(value + "");
20559     return m2.isIdentity ? identity : decompose_default(m2.a, m2.b, m2.c, m2.d, m2.e, m2.f);
20560   }
20561   function parseSvg(value) {
20562     if (value == null)
20563       return identity;
20564     if (!svgNode)
20565       svgNode = document.createElementNS("http://www.w3.org/2000/svg", "g");
20566     svgNode.setAttribute("transform", value);
20567     if (!(value = svgNode.transform.baseVal.consolidate()))
20568       return identity;
20569     value = value.matrix;
20570     return decompose_default(value.a, value.b, value.c, value.d, value.e, value.f);
20571   }
20572
20573   // node_modules/d3-interpolate/src/transform/index.js
20574   function interpolateTransform(parse, pxComma, pxParen, degParen) {
20575     function pop(s2) {
20576       return s2.length ? s2.pop() + " " : "";
20577     }
20578     function translate(xa, ya, xb, yb, s2, q2) {
20579       if (xa !== xb || ya !== yb) {
20580         var i3 = s2.push("translate(", null, pxComma, null, pxParen);
20581         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
20582       } else if (xb || yb) {
20583         s2.push("translate(" + xb + pxComma + yb + pxParen);
20584       }
20585     }
20586     function rotate(a2, b2, s2, q2) {
20587       if (a2 !== b2) {
20588         if (a2 - b2 > 180)
20589           b2 += 360;
20590         else if (b2 - a2 > 180)
20591           a2 += 360;
20592         q2.push({ i: s2.push(pop(s2) + "rotate(", null, degParen) - 2, x: number_default(a2, b2) });
20593       } else if (b2) {
20594         s2.push(pop(s2) + "rotate(" + b2 + degParen);
20595       }
20596     }
20597     function skewX(a2, b2, s2, q2) {
20598       if (a2 !== b2) {
20599         q2.push({ i: s2.push(pop(s2) + "skewX(", null, degParen) - 2, x: number_default(a2, b2) });
20600       } else if (b2) {
20601         s2.push(pop(s2) + "skewX(" + b2 + degParen);
20602       }
20603     }
20604     function scale(xa, ya, xb, yb, s2, q2) {
20605       if (xa !== xb || ya !== yb) {
20606         var i3 = s2.push(pop(s2) + "scale(", null, ",", null, ")");
20607         q2.push({ i: i3 - 4, x: number_default(xa, xb) }, { i: i3 - 2, x: number_default(ya, yb) });
20608       } else if (xb !== 1 || yb !== 1) {
20609         s2.push(pop(s2) + "scale(" + xb + "," + yb + ")");
20610       }
20611     }
20612     return function(a2, b2) {
20613       var s2 = [], q2 = [];
20614       a2 = parse(a2), b2 = parse(b2);
20615       translate(a2.translateX, a2.translateY, b2.translateX, b2.translateY, s2, q2);
20616       rotate(a2.rotate, b2.rotate, s2, q2);
20617       skewX(a2.skewX, b2.skewX, s2, q2);
20618       scale(a2.scaleX, a2.scaleY, b2.scaleX, b2.scaleY, s2, q2);
20619       a2 = b2 = null;
20620       return function(t2) {
20621         var i3 = -1, n3 = q2.length, o2;
20622         while (++i3 < n3)
20623           s2[(o2 = q2[i3]).i] = o2.x(t2);
20624         return s2.join("");
20625       };
20626     };
20627   }
20628   var interpolateTransformCss = interpolateTransform(parseCss, "px, ", "px)", "deg)");
20629   var interpolateTransformSvg = interpolateTransform(parseSvg, ", ", ")", ")");
20630
20631   // node_modules/d3-interpolate/src/zoom.js
20632   var epsilon22 = 1e-12;
20633   function cosh(x2) {
20634     return ((x2 = Math.exp(x2)) + 1 / x2) / 2;
20635   }
20636   function sinh(x2) {
20637     return ((x2 = Math.exp(x2)) - 1 / x2) / 2;
20638   }
20639   function tanh(x2) {
20640     return ((x2 = Math.exp(2 * x2)) - 1) / (x2 + 1);
20641   }
20642   var zoom_default = function zoomRho(rho, rho2, rho4) {
20643     function zoom(p02, p1) {
20644       var ux0 = p02[0], uy0 = p02[1], w0 = p02[2], ux1 = p1[0], uy1 = p1[1], w1 = p1[2], dx = ux1 - ux0, dy = uy1 - uy0, d2 = dx * dx + dy * dy, i3, S2;
20645       if (d2 < epsilon22) {
20646         S2 = Math.log(w1 / w0) / rho;
20647         i3 = function(t2) {
20648           return [
20649             ux0 + t2 * dx,
20650             uy0 + t2 * dy,
20651             w0 * Math.exp(rho * t2 * S2)
20652           ];
20653         };
20654       } else {
20655         var d1 = Math.sqrt(d2), b0 = (w1 * w1 - w0 * w0 + rho4 * d2) / (2 * w0 * rho2 * d1), b1 = (w1 * w1 - w0 * w0 - rho4 * d2) / (2 * w1 * rho2 * d1), r0 = Math.log(Math.sqrt(b0 * b0 + 1) - b0), r1 = Math.log(Math.sqrt(b1 * b1 + 1) - b1);
20656         S2 = (r1 - r0) / rho;
20657         i3 = function(t2) {
20658           var s2 = t2 * S2, coshr0 = cosh(r0), u2 = w0 / (rho2 * d1) * (coshr0 * tanh(rho * s2 + r0) - sinh(r0));
20659           return [
20660             ux0 + u2 * dx,
20661             uy0 + u2 * dy,
20662             w0 * coshr0 / cosh(rho * s2 + r0)
20663           ];
20664         };
20665       }
20666       i3.duration = S2 * 1e3 * rho / Math.SQRT2;
20667       return i3;
20668     }
20669     zoom.rho = function(_2) {
20670       var _1 = Math.max(1e-3, +_2), _22 = _1 * _1, _4 = _22 * _22;
20671       return zoomRho(_1, _22, _4);
20672     };
20673     return zoom;
20674   }(Math.SQRT2, 2, 4);
20675
20676   // node_modules/d3-interpolate/src/quantize.js
20677   function quantize_default(interpolator, n3) {
20678     var samples = new Array(n3);
20679     for (var i3 = 0; i3 < n3; ++i3)
20680       samples[i3] = interpolator(i3 / (n3 - 1));
20681     return samples;
20682   }
20683
20684   // node_modules/d3-timer/src/timer.js
20685   var frame = 0;
20686   var timeout = 0;
20687   var interval = 0;
20688   var pokeDelay = 1e3;
20689   var taskHead;
20690   var taskTail;
20691   var clockLast = 0;
20692   var clockNow = 0;
20693   var clockSkew = 0;
20694   var clock = typeof performance === "object" && performance.now ? performance : Date;
20695   var setFrame = typeof window === "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(f2) {
20696     setTimeout(f2, 17);
20697   };
20698   function now() {
20699     return clockNow || (setFrame(clearNow), clockNow = clock.now() + clockSkew);
20700   }
20701   function clearNow() {
20702     clockNow = 0;
20703   }
20704   function Timer() {
20705     this._call = this._time = this._next = null;
20706   }
20707   Timer.prototype = timer.prototype = {
20708     constructor: Timer,
20709     restart: function(callback, delay, time) {
20710       if (typeof callback !== "function")
20711         throw new TypeError("callback is not a function");
20712       time = (time == null ? now() : +time) + (delay == null ? 0 : +delay);
20713       if (!this._next && taskTail !== this) {
20714         if (taskTail)
20715           taskTail._next = this;
20716         else
20717           taskHead = this;
20718         taskTail = this;
20719       }
20720       this._call = callback;
20721       this._time = time;
20722       sleep();
20723     },
20724     stop: function() {
20725       if (this._call) {
20726         this._call = null;
20727         this._time = Infinity;
20728         sleep();
20729       }
20730     }
20731   };
20732   function timer(callback, delay, time) {
20733     var t2 = new Timer();
20734     t2.restart(callback, delay, time);
20735     return t2;
20736   }
20737   function timerFlush() {
20738     now();
20739     ++frame;
20740     var t2 = taskHead, e3;
20741     while (t2) {
20742       if ((e3 = clockNow - t2._time) >= 0)
20743         t2._call.call(void 0, e3);
20744       t2 = t2._next;
20745     }
20746     --frame;
20747   }
20748   function wake() {
20749     clockNow = (clockLast = clock.now()) + clockSkew;
20750     frame = timeout = 0;
20751     try {
20752       timerFlush();
20753     } finally {
20754       frame = 0;
20755       nap();
20756       clockNow = 0;
20757     }
20758   }
20759   function poke() {
20760     var now3 = clock.now(), delay = now3 - clockLast;
20761     if (delay > pokeDelay)
20762       clockSkew -= delay, clockLast = now3;
20763   }
20764   function nap() {
20765     var t0, t1 = taskHead, t2, time = Infinity;
20766     while (t1) {
20767       if (t1._call) {
20768         if (time > t1._time)
20769           time = t1._time;
20770         t0 = t1, t1 = t1._next;
20771       } else {
20772         t2 = t1._next, t1._next = null;
20773         t1 = t0 ? t0._next = t2 : taskHead = t2;
20774       }
20775     }
20776     taskTail = t0;
20777     sleep(time);
20778   }
20779   function sleep(time) {
20780     if (frame)
20781       return;
20782     if (timeout)
20783       timeout = clearTimeout(timeout);
20784     var delay = time - clockNow;
20785     if (delay > 24) {
20786       if (time < Infinity)
20787         timeout = setTimeout(wake, time - clock.now() - clockSkew);
20788       if (interval)
20789         interval = clearInterval(interval);
20790     } else {
20791       if (!interval)
20792         clockLast = clock.now(), interval = setInterval(poke, pokeDelay);
20793       frame = 1, setFrame(wake);
20794     }
20795   }
20796
20797   // node_modules/d3-timer/src/timeout.js
20798   function timeout_default(callback, delay, time) {
20799     var t2 = new Timer();
20800     delay = delay == null ? 0 : +delay;
20801     t2.restart((elapsed) => {
20802       t2.stop();
20803       callback(elapsed + delay);
20804     }, delay, time);
20805     return t2;
20806   }
20807
20808   // node_modules/d3-transition/src/transition/schedule.js
20809   var emptyOn = dispatch_default("start", "end", "cancel", "interrupt");
20810   var emptyTween = [];
20811   var CREATED = 0;
20812   var SCHEDULED = 1;
20813   var STARTING = 2;
20814   var STARTED = 3;
20815   var RUNNING = 4;
20816   var ENDING = 5;
20817   var ENDED = 6;
20818   function schedule_default(node, name, id2, index, group, timing) {
20819     var schedules = node.__transition;
20820     if (!schedules)
20821       node.__transition = {};
20822     else if (id2 in schedules)
20823       return;
20824     create(node, id2, {
20825       name,
20826       index,
20827       // For context during callback.
20828       group,
20829       // For context during callback.
20830       on: emptyOn,
20831       tween: emptyTween,
20832       time: timing.time,
20833       delay: timing.delay,
20834       duration: timing.duration,
20835       ease: timing.ease,
20836       timer: null,
20837       state: CREATED
20838     });
20839   }
20840   function init(node, id2) {
20841     var schedule = get2(node, id2);
20842     if (schedule.state > CREATED)
20843       throw new Error("too late; already scheduled");
20844     return schedule;
20845   }
20846   function set2(node, id2) {
20847     var schedule = get2(node, id2);
20848     if (schedule.state > STARTED)
20849       throw new Error("too late; already running");
20850     return schedule;
20851   }
20852   function get2(node, id2) {
20853     var schedule = node.__transition;
20854     if (!schedule || !(schedule = schedule[id2]))
20855       throw new Error("transition not found");
20856     return schedule;
20857   }
20858   function create(node, id2, self2) {
20859     var schedules = node.__transition, tween;
20860     schedules[id2] = self2;
20861     self2.timer = timer(schedule, 0, self2.time);
20862     function schedule(elapsed) {
20863       self2.state = SCHEDULED;
20864       self2.timer.restart(start2, self2.delay, self2.time);
20865       if (self2.delay <= elapsed)
20866         start2(elapsed - self2.delay);
20867     }
20868     function start2(elapsed) {
20869       var i3, j2, n3, o2;
20870       if (self2.state !== SCHEDULED)
20871         return stop();
20872       for (i3 in schedules) {
20873         o2 = schedules[i3];
20874         if (o2.name !== self2.name)
20875           continue;
20876         if (o2.state === STARTED)
20877           return timeout_default(start2);
20878         if (o2.state === RUNNING) {
20879           o2.state = ENDED;
20880           o2.timer.stop();
20881           o2.on.call("interrupt", node, node.__data__, o2.index, o2.group);
20882           delete schedules[i3];
20883         } else if (+i3 < id2) {
20884           o2.state = ENDED;
20885           o2.timer.stop();
20886           o2.on.call("cancel", node, node.__data__, o2.index, o2.group);
20887           delete schedules[i3];
20888         }
20889       }
20890       timeout_default(function() {
20891         if (self2.state === STARTED) {
20892           self2.state = RUNNING;
20893           self2.timer.restart(tick, self2.delay, self2.time);
20894           tick(elapsed);
20895         }
20896       });
20897       self2.state = STARTING;
20898       self2.on.call("start", node, node.__data__, self2.index, self2.group);
20899       if (self2.state !== STARTING)
20900         return;
20901       self2.state = STARTED;
20902       tween = new Array(n3 = self2.tween.length);
20903       for (i3 = 0, j2 = -1; i3 < n3; ++i3) {
20904         if (o2 = self2.tween[i3].value.call(node, node.__data__, self2.index, self2.group)) {
20905           tween[++j2] = o2;
20906         }
20907       }
20908       tween.length = j2 + 1;
20909     }
20910     function tick(elapsed) {
20911       var t2 = elapsed < self2.duration ? self2.ease.call(null, elapsed / self2.duration) : (self2.timer.restart(stop), self2.state = ENDING, 1), i3 = -1, n3 = tween.length;
20912       while (++i3 < n3) {
20913         tween[i3].call(node, t2);
20914       }
20915       if (self2.state === ENDING) {
20916         self2.on.call("end", node, node.__data__, self2.index, self2.group);
20917         stop();
20918       }
20919     }
20920     function stop() {
20921       self2.state = ENDED;
20922       self2.timer.stop();
20923       delete schedules[id2];
20924       for (var i3 in schedules)
20925         return;
20926       delete node.__transition;
20927     }
20928   }
20929
20930   // node_modules/d3-transition/src/interrupt.js
20931   function interrupt_default(node, name) {
20932     var schedules = node.__transition, schedule, active, empty2 = true, i3;
20933     if (!schedules)
20934       return;
20935     name = name == null ? null : name + "";
20936     for (i3 in schedules) {
20937       if ((schedule = schedules[i3]).name !== name) {
20938         empty2 = false;
20939         continue;
20940       }
20941       active = schedule.state > STARTING && schedule.state < ENDING;
20942       schedule.state = ENDED;
20943       schedule.timer.stop();
20944       schedule.on.call(active ? "interrupt" : "cancel", node, node.__data__, schedule.index, schedule.group);
20945       delete schedules[i3];
20946     }
20947     if (empty2)
20948       delete node.__transition;
20949   }
20950
20951   // node_modules/d3-transition/src/selection/interrupt.js
20952   function interrupt_default2(name) {
20953     return this.each(function() {
20954       interrupt_default(this, name);
20955     });
20956   }
20957
20958   // node_modules/d3-transition/src/transition/tween.js
20959   function tweenRemove(id2, name) {
20960     var tween0, tween1;
20961     return function() {
20962       var schedule = set2(this, id2), tween = schedule.tween;
20963       if (tween !== tween0) {
20964         tween1 = tween0 = tween;
20965         for (var i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
20966           if (tween1[i3].name === name) {
20967             tween1 = tween1.slice();
20968             tween1.splice(i3, 1);
20969             break;
20970           }
20971         }
20972       }
20973       schedule.tween = tween1;
20974     };
20975   }
20976   function tweenFunction(id2, name, value) {
20977     var tween0, tween1;
20978     if (typeof value !== "function")
20979       throw new Error();
20980     return function() {
20981       var schedule = set2(this, id2), tween = schedule.tween;
20982       if (tween !== tween0) {
20983         tween1 = (tween0 = tween).slice();
20984         for (var t2 = { name, value }, i3 = 0, n3 = tween1.length; i3 < n3; ++i3) {
20985           if (tween1[i3].name === name) {
20986             tween1[i3] = t2;
20987             break;
20988           }
20989         }
20990         if (i3 === n3)
20991           tween1.push(t2);
20992       }
20993       schedule.tween = tween1;
20994     };
20995   }
20996   function tween_default(name, value) {
20997     var id2 = this._id;
20998     name += "";
20999     if (arguments.length < 2) {
21000       var tween = get2(this.node(), id2).tween;
21001       for (var i3 = 0, n3 = tween.length, t2; i3 < n3; ++i3) {
21002         if ((t2 = tween[i3]).name === name) {
21003           return t2.value;
21004         }
21005       }
21006       return null;
21007     }
21008     return this.each((value == null ? tweenRemove : tweenFunction)(id2, name, value));
21009   }
21010   function tweenValue(transition2, name, value) {
21011     var id2 = transition2._id;
21012     transition2.each(function() {
21013       var schedule = set2(this, id2);
21014       (schedule.value || (schedule.value = {}))[name] = value.apply(this, arguments);
21015     });
21016     return function(node) {
21017       return get2(node, id2).value[name];
21018     };
21019   }
21020
21021   // node_modules/d3-transition/src/transition/interpolate.js
21022   function interpolate_default(a2, b2) {
21023     var c2;
21024     return (typeof b2 === "number" ? number_default : b2 instanceof color ? rgb_default : (c2 = color(b2)) ? (b2 = c2, rgb_default) : string_default)(a2, b2);
21025   }
21026
21027   // node_modules/d3-transition/src/transition/attr.js
21028   function attrRemove2(name) {
21029     return function() {
21030       this.removeAttribute(name);
21031     };
21032   }
21033   function attrRemoveNS2(fullname) {
21034     return function() {
21035       this.removeAttributeNS(fullname.space, fullname.local);
21036     };
21037   }
21038   function attrConstant2(name, interpolate, value1) {
21039     var string00, string1 = value1 + "", interpolate0;
21040     return function() {
21041       var string0 = this.getAttribute(name);
21042       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
21043     };
21044   }
21045   function attrConstantNS2(fullname, interpolate, value1) {
21046     var string00, string1 = value1 + "", interpolate0;
21047     return function() {
21048       var string0 = this.getAttributeNS(fullname.space, fullname.local);
21049       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
21050     };
21051   }
21052   function attrFunction2(name, interpolate, value) {
21053     var string00, string10, interpolate0;
21054     return function() {
21055       var string0, value1 = value(this), string1;
21056       if (value1 == null)
21057         return void this.removeAttribute(name);
21058       string0 = this.getAttribute(name);
21059       string1 = value1 + "";
21060       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
21061     };
21062   }
21063   function attrFunctionNS2(fullname, interpolate, value) {
21064     var string00, string10, interpolate0;
21065     return function() {
21066       var string0, value1 = value(this), string1;
21067       if (value1 == null)
21068         return void this.removeAttributeNS(fullname.space, fullname.local);
21069       string0 = this.getAttributeNS(fullname.space, fullname.local);
21070       string1 = value1 + "";
21071       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
21072     };
21073   }
21074   function attr_default2(name, value) {
21075     var fullname = namespace_default(name), i3 = fullname === "transform" ? interpolateTransformSvg : interpolate_default;
21076     return this.attrTween(name, typeof value === "function" ? (fullname.local ? attrFunctionNS2 : attrFunction2)(fullname, i3, tweenValue(this, "attr." + name, value)) : value == null ? (fullname.local ? attrRemoveNS2 : attrRemove2)(fullname) : (fullname.local ? attrConstantNS2 : attrConstant2)(fullname, i3, value));
21077   }
21078
21079   // node_modules/d3-transition/src/transition/attrTween.js
21080   function attrInterpolate(name, i3) {
21081     return function(t2) {
21082       this.setAttribute(name, i3.call(this, t2));
21083     };
21084   }
21085   function attrInterpolateNS(fullname, i3) {
21086     return function(t2) {
21087       this.setAttributeNS(fullname.space, fullname.local, i3.call(this, t2));
21088     };
21089   }
21090   function attrTweenNS(fullname, value) {
21091     var t0, i0;
21092     function tween() {
21093       var i3 = value.apply(this, arguments);
21094       if (i3 !== i0)
21095         t0 = (i0 = i3) && attrInterpolateNS(fullname, i3);
21096       return t0;
21097     }
21098     tween._value = value;
21099     return tween;
21100   }
21101   function attrTween(name, value) {
21102     var t0, i0;
21103     function tween() {
21104       var i3 = value.apply(this, arguments);
21105       if (i3 !== i0)
21106         t0 = (i0 = i3) && attrInterpolate(name, i3);
21107       return t0;
21108     }
21109     tween._value = value;
21110     return tween;
21111   }
21112   function attrTween_default(name, value) {
21113     var key = "attr." + name;
21114     if (arguments.length < 2)
21115       return (key = this.tween(key)) && key._value;
21116     if (value == null)
21117       return this.tween(key, null);
21118     if (typeof value !== "function")
21119       throw new Error();
21120     var fullname = namespace_default(name);
21121     return this.tween(key, (fullname.local ? attrTweenNS : attrTween)(fullname, value));
21122   }
21123
21124   // node_modules/d3-transition/src/transition/delay.js
21125   function delayFunction(id2, value) {
21126     return function() {
21127       init(this, id2).delay = +value.apply(this, arguments);
21128     };
21129   }
21130   function delayConstant(id2, value) {
21131     return value = +value, function() {
21132       init(this, id2).delay = value;
21133     };
21134   }
21135   function delay_default(value) {
21136     var id2 = this._id;
21137     return arguments.length ? this.each((typeof value === "function" ? delayFunction : delayConstant)(id2, value)) : get2(this.node(), id2).delay;
21138   }
21139
21140   // node_modules/d3-transition/src/transition/duration.js
21141   function durationFunction(id2, value) {
21142     return function() {
21143       set2(this, id2).duration = +value.apply(this, arguments);
21144     };
21145   }
21146   function durationConstant(id2, value) {
21147     return value = +value, function() {
21148       set2(this, id2).duration = value;
21149     };
21150   }
21151   function duration_default(value) {
21152     var id2 = this._id;
21153     return arguments.length ? this.each((typeof value === "function" ? durationFunction : durationConstant)(id2, value)) : get2(this.node(), id2).duration;
21154   }
21155
21156   // node_modules/d3-transition/src/transition/ease.js
21157   function easeConstant(id2, value) {
21158     if (typeof value !== "function")
21159       throw new Error();
21160     return function() {
21161       set2(this, id2).ease = value;
21162     };
21163   }
21164   function ease_default(value) {
21165     var id2 = this._id;
21166     return arguments.length ? this.each(easeConstant(id2, value)) : get2(this.node(), id2).ease;
21167   }
21168
21169   // node_modules/d3-transition/src/transition/easeVarying.js
21170   function easeVarying(id2, value) {
21171     return function() {
21172       var v2 = value.apply(this, arguments);
21173       if (typeof v2 !== "function")
21174         throw new Error();
21175       set2(this, id2).ease = v2;
21176     };
21177   }
21178   function easeVarying_default(value) {
21179     if (typeof value !== "function")
21180       throw new Error();
21181     return this.each(easeVarying(this._id, value));
21182   }
21183
21184   // node_modules/d3-transition/src/transition/filter.js
21185   function filter_default2(match) {
21186     if (typeof match !== "function")
21187       match = matcher_default(match);
21188     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
21189       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = [], node, i3 = 0; i3 < n3; ++i3) {
21190         if ((node = group[i3]) && match.call(node, node.__data__, i3, group)) {
21191           subgroup.push(node);
21192         }
21193       }
21194     }
21195     return new Transition(subgroups, this._parents, this._name, this._id);
21196   }
21197
21198   // node_modules/d3-transition/src/transition/merge.js
21199   function merge_default2(transition2) {
21200     if (transition2._id !== this._id)
21201       throw new Error();
21202     for (var groups0 = this._groups, groups1 = transition2._groups, m0 = groups0.length, m1 = groups1.length, m2 = Math.min(m0, m1), merges = new Array(m0), j2 = 0; j2 < m2; ++j2) {
21203       for (var group0 = groups0[j2], group1 = groups1[j2], n3 = group0.length, merge2 = merges[j2] = new Array(n3), node, i3 = 0; i3 < n3; ++i3) {
21204         if (node = group0[i3] || group1[i3]) {
21205           merge2[i3] = node;
21206         }
21207       }
21208     }
21209     for (; j2 < m0; ++j2) {
21210       merges[j2] = groups0[j2];
21211     }
21212     return new Transition(merges, this._parents, this._name, this._id);
21213   }
21214
21215   // node_modules/d3-transition/src/transition/on.js
21216   function start(name) {
21217     return (name + "").trim().split(/^|\s+/).every(function(t2) {
21218       var i3 = t2.indexOf(".");
21219       if (i3 >= 0)
21220         t2 = t2.slice(0, i3);
21221       return !t2 || t2 === "start";
21222     });
21223   }
21224   function onFunction(id2, name, listener) {
21225     var on0, on1, sit = start(name) ? init : set2;
21226     return function() {
21227       var schedule = sit(this, id2), on = schedule.on;
21228       if (on !== on0)
21229         (on1 = (on0 = on).copy()).on(name, listener);
21230       schedule.on = on1;
21231     };
21232   }
21233   function on_default2(name, listener) {
21234     var id2 = this._id;
21235     return arguments.length < 2 ? get2(this.node(), id2).on.on(name) : this.each(onFunction(id2, name, listener));
21236   }
21237
21238   // node_modules/d3-transition/src/transition/remove.js
21239   function removeFunction(id2) {
21240     return function() {
21241       var parent = this.parentNode;
21242       for (var i3 in this.__transition)
21243         if (+i3 !== id2)
21244           return;
21245       if (parent)
21246         parent.removeChild(this);
21247     };
21248   }
21249   function remove_default2() {
21250     return this.on("end.remove", removeFunction(this._id));
21251   }
21252
21253   // node_modules/d3-transition/src/transition/select.js
21254   function select_default3(select) {
21255     var name = this._name, id2 = this._id;
21256     if (typeof select !== "function")
21257       select = selector_default(select);
21258     for (var groups = this._groups, m2 = groups.length, subgroups = new Array(m2), j2 = 0; j2 < m2; ++j2) {
21259       for (var group = groups[j2], n3 = group.length, subgroup = subgroups[j2] = new Array(n3), node, subnode, i3 = 0; i3 < n3; ++i3) {
21260         if ((node = group[i3]) && (subnode = select.call(node, node.__data__, i3, group))) {
21261           if ("__data__" in node)
21262             subnode.__data__ = node.__data__;
21263           subgroup[i3] = subnode;
21264           schedule_default(subgroup[i3], name, id2, i3, subgroup, get2(node, id2));
21265         }
21266       }
21267     }
21268     return new Transition(subgroups, this._parents, name, id2);
21269   }
21270
21271   // node_modules/d3-transition/src/transition/selectAll.js
21272   function selectAll_default3(select) {
21273     var name = this._name, id2 = this._id;
21274     if (typeof select !== "function")
21275       select = selectorAll_default(select);
21276     for (var groups = this._groups, m2 = groups.length, subgroups = [], parents = [], j2 = 0; j2 < m2; ++j2) {
21277       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
21278         if (node = group[i3]) {
21279           for (var children2 = select.call(node, node.__data__, i3, group), child, inherit2 = get2(node, id2), k2 = 0, l2 = children2.length; k2 < l2; ++k2) {
21280             if (child = children2[k2]) {
21281               schedule_default(child, name, id2, k2, children2, inherit2);
21282             }
21283           }
21284           subgroups.push(children2);
21285           parents.push(node);
21286         }
21287       }
21288     }
21289     return new Transition(subgroups, parents, name, id2);
21290   }
21291
21292   // node_modules/d3-transition/src/transition/selection.js
21293   var Selection2 = selection_default.prototype.constructor;
21294   function selection_default2() {
21295     return new Selection2(this._groups, this._parents);
21296   }
21297
21298   // node_modules/d3-transition/src/transition/style.js
21299   function styleNull(name, interpolate) {
21300     var string00, string10, interpolate0;
21301     return function() {
21302       var string0 = styleValue(this, name), string1 = (this.style.removeProperty(name), styleValue(this, name));
21303       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : interpolate0 = interpolate(string00 = string0, string10 = string1);
21304     };
21305   }
21306   function styleRemove2(name) {
21307     return function() {
21308       this.style.removeProperty(name);
21309     };
21310   }
21311   function styleConstant2(name, interpolate, value1) {
21312     var string00, string1 = value1 + "", interpolate0;
21313     return function() {
21314       var string0 = styleValue(this, name);
21315       return string0 === string1 ? null : string0 === string00 ? interpolate0 : interpolate0 = interpolate(string00 = string0, value1);
21316     };
21317   }
21318   function styleFunction2(name, interpolate, value) {
21319     var string00, string10, interpolate0;
21320     return function() {
21321       var string0 = styleValue(this, name), value1 = value(this), string1 = value1 + "";
21322       if (value1 == null)
21323         string1 = value1 = (this.style.removeProperty(name), styleValue(this, name));
21324       return string0 === string1 ? null : string0 === string00 && string1 === string10 ? interpolate0 : (string10 = string1, interpolate0 = interpolate(string00 = string0, value1));
21325     };
21326   }
21327   function styleMaybeRemove(id2, name) {
21328     var on0, on1, listener0, key = "style." + name, event = "end." + key, remove2;
21329     return function() {
21330       var schedule = set2(this, id2), on = schedule.on, listener = schedule.value[key] == null ? remove2 || (remove2 = styleRemove2(name)) : void 0;
21331       if (on !== on0 || listener0 !== listener)
21332         (on1 = (on0 = on).copy()).on(event, listener0 = listener);
21333       schedule.on = on1;
21334     };
21335   }
21336   function style_default2(name, value, priority) {
21337     var i3 = (name += "") === "transform" ? interpolateTransformCss : interpolate_default;
21338     return value == null ? this.styleTween(name, styleNull(name, i3)).on("end.style." + name, styleRemove2(name)) : typeof value === "function" ? this.styleTween(name, styleFunction2(name, i3, tweenValue(this, "style." + name, value))).each(styleMaybeRemove(this._id, name)) : this.styleTween(name, styleConstant2(name, i3, value), priority).on("end.style." + name, null);
21339   }
21340
21341   // node_modules/d3-transition/src/transition/styleTween.js
21342   function styleInterpolate(name, i3, priority) {
21343     return function(t2) {
21344       this.style.setProperty(name, i3.call(this, t2), priority);
21345     };
21346   }
21347   function styleTween(name, value, priority) {
21348     var t2, i0;
21349     function tween() {
21350       var i3 = value.apply(this, arguments);
21351       if (i3 !== i0)
21352         t2 = (i0 = i3) && styleInterpolate(name, i3, priority);
21353       return t2;
21354     }
21355     tween._value = value;
21356     return tween;
21357   }
21358   function styleTween_default(name, value, priority) {
21359     var key = "style." + (name += "");
21360     if (arguments.length < 2)
21361       return (key = this.tween(key)) && key._value;
21362     if (value == null)
21363       return this.tween(key, null);
21364     if (typeof value !== "function")
21365       throw new Error();
21366     return this.tween(key, styleTween(name, value, priority == null ? "" : priority));
21367   }
21368
21369   // node_modules/d3-transition/src/transition/text.js
21370   function textConstant2(value) {
21371     return function() {
21372       this.textContent = value;
21373     };
21374   }
21375   function textFunction2(value) {
21376     return function() {
21377       var value1 = value(this);
21378       this.textContent = value1 == null ? "" : value1;
21379     };
21380   }
21381   function text_default2(value) {
21382     return this.tween("text", typeof value === "function" ? textFunction2(tweenValue(this, "text", value)) : textConstant2(value == null ? "" : value + ""));
21383   }
21384
21385   // node_modules/d3-transition/src/transition/textTween.js
21386   function textInterpolate(i3) {
21387     return function(t2) {
21388       this.textContent = i3.call(this, t2);
21389     };
21390   }
21391   function textTween(value) {
21392     var t0, i0;
21393     function tween() {
21394       var i3 = value.apply(this, arguments);
21395       if (i3 !== i0)
21396         t0 = (i0 = i3) && textInterpolate(i3);
21397       return t0;
21398     }
21399     tween._value = value;
21400     return tween;
21401   }
21402   function textTween_default(value) {
21403     var key = "text";
21404     if (arguments.length < 1)
21405       return (key = this.tween(key)) && key._value;
21406     if (value == null)
21407       return this.tween(key, null);
21408     if (typeof value !== "function")
21409       throw new Error();
21410     return this.tween(key, textTween(value));
21411   }
21412
21413   // node_modules/d3-transition/src/transition/transition.js
21414   function transition_default() {
21415     var name = this._name, id0 = this._id, id1 = newId();
21416     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
21417       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
21418         if (node = group[i3]) {
21419           var inherit2 = get2(node, id0);
21420           schedule_default(node, name, id1, i3, group, {
21421             time: inherit2.time + inherit2.delay + inherit2.duration,
21422             delay: 0,
21423             duration: inherit2.duration,
21424             ease: inherit2.ease
21425           });
21426         }
21427       }
21428     }
21429     return new Transition(groups, this._parents, name, id1);
21430   }
21431
21432   // node_modules/d3-transition/src/transition/end.js
21433   function end_default() {
21434     var on0, on1, that = this, id2 = that._id, size = that.size();
21435     return new Promise(function(resolve, reject) {
21436       var cancel = { value: reject }, end = { value: function() {
21437         if (--size === 0)
21438           resolve();
21439       } };
21440       that.each(function() {
21441         var schedule = set2(this, id2), on = schedule.on;
21442         if (on !== on0) {
21443           on1 = (on0 = on).copy();
21444           on1._.cancel.push(cancel);
21445           on1._.interrupt.push(cancel);
21446           on1._.end.push(end);
21447         }
21448         schedule.on = on1;
21449       });
21450       if (size === 0)
21451         resolve();
21452     });
21453   }
21454
21455   // node_modules/d3-transition/src/transition/index.js
21456   var id = 0;
21457   function Transition(groups, parents, name, id2) {
21458     this._groups = groups;
21459     this._parents = parents;
21460     this._name = name;
21461     this._id = id2;
21462   }
21463   function transition(name) {
21464     return selection_default().transition(name);
21465   }
21466   function newId() {
21467     return ++id;
21468   }
21469   var selection_prototype = selection_default.prototype;
21470   Transition.prototype = transition.prototype = {
21471     constructor: Transition,
21472     select: select_default3,
21473     selectAll: selectAll_default3,
21474     selectChild: selection_prototype.selectChild,
21475     selectChildren: selection_prototype.selectChildren,
21476     filter: filter_default2,
21477     merge: merge_default2,
21478     selection: selection_default2,
21479     transition: transition_default,
21480     call: selection_prototype.call,
21481     nodes: selection_prototype.nodes,
21482     node: selection_prototype.node,
21483     size: selection_prototype.size,
21484     empty: selection_prototype.empty,
21485     each: selection_prototype.each,
21486     on: on_default2,
21487     attr: attr_default2,
21488     attrTween: attrTween_default,
21489     style: style_default2,
21490     styleTween: styleTween_default,
21491     text: text_default2,
21492     textTween: textTween_default,
21493     remove: remove_default2,
21494     tween: tween_default,
21495     delay: delay_default,
21496     duration: duration_default,
21497     ease: ease_default,
21498     easeVarying: easeVarying_default,
21499     end: end_default,
21500     [Symbol.iterator]: selection_prototype[Symbol.iterator]
21501   };
21502
21503   // node_modules/d3-ease/src/linear.js
21504   var linear2 = (t2) => +t2;
21505
21506   // node_modules/d3-ease/src/cubic.js
21507   function cubicInOut(t2) {
21508     return ((t2 *= 2) <= 1 ? t2 * t2 * t2 : (t2 -= 2) * t2 * t2 + 2) / 2;
21509   }
21510
21511   // node_modules/d3-transition/src/selection/transition.js
21512   var defaultTiming = {
21513     time: null,
21514     // Set on use.
21515     delay: 0,
21516     duration: 250,
21517     ease: cubicInOut
21518   };
21519   function inherit(node, id2) {
21520     var timing;
21521     while (!(timing = node.__transition) || !(timing = timing[id2])) {
21522       if (!(node = node.parentNode)) {
21523         throw new Error("transition ".concat(id2, " not found"));
21524       }
21525     }
21526     return timing;
21527   }
21528   function transition_default2(name) {
21529     var id2, timing;
21530     if (name instanceof Transition) {
21531       id2 = name._id, name = name._name;
21532     } else {
21533       id2 = newId(), (timing = defaultTiming).time = now(), name = name == null ? null : name + "";
21534     }
21535     for (var groups = this._groups, m2 = groups.length, j2 = 0; j2 < m2; ++j2) {
21536       for (var group = groups[j2], n3 = group.length, node, i3 = 0; i3 < n3; ++i3) {
21537         if (node = group[i3]) {
21538           schedule_default(node, name, id2, i3, group, timing || inherit(node, id2));
21539         }
21540       }
21541     }
21542     return new Transition(groups, this._parents, name, id2);
21543   }
21544
21545   // node_modules/d3-transition/src/selection/index.js
21546   selection_default.prototype.interrupt = interrupt_default2;
21547   selection_default.prototype.transition = transition_default2;
21548
21549   // node_modules/d3-zoom/src/constant.js
21550   var constant_default4 = (x2) => () => x2;
21551
21552   // node_modules/d3-zoom/src/event.js
21553   function ZoomEvent(type2, {
21554     sourceEvent,
21555     target,
21556     transform: transform2,
21557     dispatch: dispatch14
21558   }) {
21559     Object.defineProperties(this, {
21560       type: { value: type2, enumerable: true, configurable: true },
21561       sourceEvent: { value: sourceEvent, enumerable: true, configurable: true },
21562       target: { value: target, enumerable: true, configurable: true },
21563       transform: { value: transform2, enumerable: true, configurable: true },
21564       _: { value: dispatch14 }
21565     });
21566   }
21567
21568   // node_modules/d3-zoom/src/transform.js
21569   function Transform(k2, x2, y2) {
21570     this.k = k2;
21571     this.x = x2;
21572     this.y = y2;
21573   }
21574   Transform.prototype = {
21575     constructor: Transform,
21576     scale: function(k2) {
21577       return k2 === 1 ? this : new Transform(this.k * k2, this.x, this.y);
21578     },
21579     translate: function(x2, y2) {
21580       return x2 === 0 & y2 === 0 ? this : new Transform(this.k, this.x + this.k * x2, this.y + this.k * y2);
21581     },
21582     apply: function(point2) {
21583       return [point2[0] * this.k + this.x, point2[1] * this.k + this.y];
21584     },
21585     applyX: function(x2) {
21586       return x2 * this.k + this.x;
21587     },
21588     applyY: function(y2) {
21589       return y2 * this.k + this.y;
21590     },
21591     invert: function(location) {
21592       return [(location[0] - this.x) / this.k, (location[1] - this.y) / this.k];
21593     },
21594     invertX: function(x2) {
21595       return (x2 - this.x) / this.k;
21596     },
21597     invertY: function(y2) {
21598       return (y2 - this.y) / this.k;
21599     },
21600     rescaleX: function(x2) {
21601       return x2.copy().domain(x2.range().map(this.invertX, this).map(x2.invert, x2));
21602     },
21603     rescaleY: function(y2) {
21604       return y2.copy().domain(y2.range().map(this.invertY, this).map(y2.invert, y2));
21605     },
21606     toString: function() {
21607       return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
21608     }
21609   };
21610   var identity2 = new Transform(1, 0, 0);
21611   transform.prototype = Transform.prototype;
21612   function transform(node) {
21613     while (!node.__zoom)
21614       if (!(node = node.parentNode))
21615         return identity2;
21616     return node.__zoom;
21617   }
21618
21619   // node_modules/d3-zoom/src/noevent.js
21620   function nopropagation2(event) {
21621     event.stopImmediatePropagation();
21622   }
21623   function noevent_default2(event) {
21624     event.preventDefault();
21625     event.stopImmediatePropagation();
21626   }
21627
21628   // node_modules/d3-zoom/src/zoom.js
21629   function defaultFilter2(event) {
21630     return (!event.ctrlKey || event.type === "wheel") && !event.button;
21631   }
21632   function defaultExtent() {
21633     var e3 = this;
21634     if (e3 instanceof SVGElement) {
21635       e3 = e3.ownerSVGElement || e3;
21636       if (e3.hasAttribute("viewBox")) {
21637         e3 = e3.viewBox.baseVal;
21638         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
21639       }
21640       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
21641     }
21642     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
21643   }
21644   function defaultTransform() {
21645     return this.__zoom || identity2;
21646   }
21647   function defaultWheelDelta(event) {
21648     return -event.deltaY * (event.deltaMode === 1 ? 0.05 : event.deltaMode ? 1 : 2e-3) * (event.ctrlKey ? 10 : 1);
21649   }
21650   function defaultTouchable2() {
21651     return navigator.maxTouchPoints || "ontouchstart" in this;
21652   }
21653   function defaultConstrain(transform2, extent, translateExtent) {
21654     var dx0 = transform2.invertX(extent[0][0]) - translateExtent[0][0], dx1 = transform2.invertX(extent[1][0]) - translateExtent[1][0], dy0 = transform2.invertY(extent[0][1]) - translateExtent[0][1], dy1 = transform2.invertY(extent[1][1]) - translateExtent[1][1];
21655     return transform2.translate(
21656       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
21657       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
21658     );
21659   }
21660   function zoom_default2() {
21661     var filter2 = defaultFilter2, extent = defaultExtent, constrain = defaultConstrain, wheelDelta = defaultWheelDelta, touchable = defaultTouchable2, scaleExtent = [0, Infinity], translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]], duration = 250, interpolate = zoom_default, listeners = dispatch_default("start", "zoom", "end"), touchstarting, touchfirst, touchending, touchDelay = 500, wheelDelay = 150, clickDistance2 = 0, tapDistance = 10;
21662     function zoom(selection2) {
21663       selection2.property("__zoom", defaultTransform).on("wheel.zoom", wheeled, { passive: false }).on("mousedown.zoom", mousedowned).on("dblclick.zoom", dblclicked).filter(touchable).on("touchstart.zoom", touchstarted).on("touchmove.zoom", touchmoved).on("touchend.zoom touchcancel.zoom", touchended).style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
21664     }
21665     zoom.transform = function(collection, transform2, point2, event) {
21666       var selection2 = collection.selection ? collection.selection() : collection;
21667       selection2.property("__zoom", defaultTransform);
21668       if (collection !== selection2) {
21669         schedule(collection, transform2, point2, event);
21670       } else {
21671         selection2.interrupt().each(function() {
21672           gesture(this, arguments).event(event).start().zoom(null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end();
21673         });
21674       }
21675     };
21676     zoom.scaleBy = function(selection2, k2, p2, event) {
21677       zoom.scaleTo(selection2, function() {
21678         var k0 = this.__zoom.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
21679         return k0 * k1;
21680       }, p2, event);
21681     };
21682     zoom.scaleTo = function(selection2, k2, p2, event) {
21683       zoom.transform(selection2, function() {
21684         var e3 = extent.apply(this, arguments), t0 = this.__zoom, p02 = p2 == null ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2, p1 = t0.invert(p02), k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
21685         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
21686       }, p2, event);
21687     };
21688     zoom.translateBy = function(selection2, x2, y2, event) {
21689       zoom.transform(selection2, function() {
21690         return constrain(this.__zoom.translate(
21691           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
21692           typeof y2 === "function" ? y2.apply(this, arguments) : y2
21693         ), extent.apply(this, arguments), translateExtent);
21694       }, null, event);
21695     };
21696     zoom.translateTo = function(selection2, x2, y2, p2, event) {
21697       zoom.transform(selection2, function() {
21698         var e3 = extent.apply(this, arguments), t2 = this.__zoom, p02 = p2 == null ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
21699         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
21700           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
21701           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
21702         ), e3, translateExtent);
21703       }, p2, event);
21704     };
21705     function scale(transform2, k2) {
21706       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
21707       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
21708     }
21709     function translate(transform2, p02, p1) {
21710       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
21711       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
21712     }
21713     function centroid(extent2) {
21714       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
21715     }
21716     function schedule(transition2, transform2, point2, event) {
21717       transition2.on("start.zoom", function() {
21718         gesture(this, arguments).event(event).start();
21719       }).on("interrupt.zoom end.zoom", function() {
21720         gesture(this, arguments).event(event).end();
21721       }).tween("zoom", function() {
21722         var that = this, args = arguments, g3 = gesture(that, args).event(event), e3 = extent.apply(that, args), p2 = point2 == null ? centroid(e3) : typeof point2 === "function" ? point2.apply(that, args) : point2, w2 = Math.max(e3[1][0] - e3[0][0], e3[1][1] - e3[0][1]), a2 = that.__zoom, b2 = typeof transform2 === "function" ? transform2.apply(that, args) : transform2, i3 = interpolate(a2.invert(p2).concat(w2 / a2.k), b2.invert(p2).concat(w2 / b2.k));
21723         return function(t2) {
21724           if (t2 === 1)
21725             t2 = b2;
21726           else {
21727             var l2 = i3(t2), k2 = w2 / l2[2];
21728             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
21729           }
21730           g3.zoom(null, t2);
21731         };
21732       });
21733     }
21734     function gesture(that, args, clean2) {
21735       return !clean2 && that.__zooming || new Gesture(that, args);
21736     }
21737     function Gesture(that, args) {
21738       this.that = that;
21739       this.args = args;
21740       this.active = 0;
21741       this.sourceEvent = null;
21742       this.extent = extent.apply(that, args);
21743       this.taps = 0;
21744     }
21745     Gesture.prototype = {
21746       event: function(event) {
21747         if (event)
21748           this.sourceEvent = event;
21749         return this;
21750       },
21751       start: function() {
21752         if (++this.active === 1) {
21753           this.that.__zooming = this;
21754           this.emit("start");
21755         }
21756         return this;
21757       },
21758       zoom: function(key, transform2) {
21759         if (this.mouse && key !== "mouse")
21760           this.mouse[1] = transform2.invert(this.mouse[0]);
21761         if (this.touch0 && key !== "touch")
21762           this.touch0[1] = transform2.invert(this.touch0[0]);
21763         if (this.touch1 && key !== "touch")
21764           this.touch1[1] = transform2.invert(this.touch1[0]);
21765         this.that.__zoom = transform2;
21766         this.emit("zoom");
21767         return this;
21768       },
21769       end: function() {
21770         if (--this.active === 0) {
21771           delete this.that.__zooming;
21772           this.emit("end");
21773         }
21774         return this;
21775       },
21776       emit: function(type2) {
21777         var d2 = select_default2(this.that).datum();
21778         listeners.call(
21779           type2,
21780           this.that,
21781           new ZoomEvent(type2, {
21782             sourceEvent: this.sourceEvent,
21783             target: zoom,
21784             type: type2,
21785             transform: this.that.__zoom,
21786             dispatch: listeners
21787           }),
21788           d2
21789         );
21790       }
21791     };
21792     function wheeled(event, ...args) {
21793       if (!filter2.apply(this, arguments))
21794         return;
21795       var g3 = gesture(this, args).event(event), t2 = this.__zoom, k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t2.k * Math.pow(2, wheelDelta.apply(this, arguments)))), p2 = pointer_default(event);
21796       if (g3.wheel) {
21797         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
21798           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
21799         }
21800         clearTimeout(g3.wheel);
21801       } else if (t2.k === k2)
21802         return;
21803       else {
21804         g3.mouse = [p2, t2.invert(p2)];
21805         interrupt_default(this);
21806         g3.start();
21807       }
21808       noevent_default2(event);
21809       g3.wheel = setTimeout(wheelidled, wheelDelay);
21810       g3.zoom("mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
21811       function wheelidled() {
21812         g3.wheel = null;
21813         g3.end();
21814       }
21815     }
21816     function mousedowned(event, ...args) {
21817       if (touchending || !filter2.apply(this, arguments))
21818         return;
21819       var currentTarget = event.currentTarget, g3 = gesture(this, args, true).event(event), v2 = select_default2(event.view).on("mousemove.zoom", mousemoved, true).on("mouseup.zoom", mouseupped, true), p2 = pointer_default(event, currentTarget), x05 = event.clientX, y05 = event.clientY;
21820       nodrag_default(event.view);
21821       nopropagation2(event);
21822       g3.mouse = [p2, this.__zoom.invert(p2)];
21823       interrupt_default(this);
21824       g3.start();
21825       function mousemoved(event2) {
21826         noevent_default2(event2);
21827         if (!g3.moved) {
21828           var dx = event2.clientX - x05, dy = event2.clientY - y05;
21829           g3.moved = dx * dx + dy * dy > clickDistance2;
21830         }
21831         g3.event(event2).zoom("mouse", constrain(translate(g3.that.__zoom, g3.mouse[0] = pointer_default(event2, currentTarget), g3.mouse[1]), g3.extent, translateExtent));
21832       }
21833       function mouseupped(event2) {
21834         v2.on("mousemove.zoom mouseup.zoom", null);
21835         yesdrag(event2.view, g3.moved);
21836         noevent_default2(event2);
21837         g3.event(event2).end();
21838       }
21839     }
21840     function dblclicked(event, ...args) {
21841       if (!filter2.apply(this, arguments))
21842         return;
21843       var t0 = this.__zoom, p02 = pointer_default(event.changedTouches ? event.changedTouches[0] : event, this), p1 = t0.invert(p02), k1 = t0.k * (event.shiftKey ? 0.5 : 2), t1 = constrain(translate(scale(t0, k1), p02, p1), extent.apply(this, args), translateExtent);
21844       noevent_default2(event);
21845       if (duration > 0)
21846         select_default2(this).transition().duration(duration).call(schedule, t1, p02, event);
21847       else
21848         select_default2(this).call(zoom.transform, t1, p02, event);
21849     }
21850     function touchstarted(event, ...args) {
21851       if (!filter2.apply(this, arguments))
21852         return;
21853       var touches = event.touches, n3 = touches.length, g3 = gesture(this, args, event.changedTouches.length === n3).event(event), started, i3, t2, p2;
21854       nopropagation2(event);
21855       for (i3 = 0; i3 < n3; ++i3) {
21856         t2 = touches[i3], p2 = pointer_default(t2, this);
21857         p2 = [p2, this.__zoom.invert(p2), t2.identifier];
21858         if (!g3.touch0)
21859           g3.touch0 = p2, started = true, g3.taps = 1 + !!touchstarting;
21860         else if (!g3.touch1 && g3.touch0[2] !== p2[2])
21861           g3.touch1 = p2, g3.taps = 0;
21862       }
21863       if (touchstarting)
21864         touchstarting = clearTimeout(touchstarting);
21865       if (started) {
21866         if (g3.taps < 2)
21867           touchfirst = p2[0], touchstarting = setTimeout(function() {
21868             touchstarting = null;
21869           }, touchDelay);
21870         interrupt_default(this);
21871         g3.start();
21872       }
21873     }
21874     function touchmoved(event, ...args) {
21875       if (!this.__zooming)
21876         return;
21877       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2, p2, l2;
21878       noevent_default2(event);
21879       for (i3 = 0; i3 < n3; ++i3) {
21880         t2 = touches[i3], p2 = pointer_default(t2, this);
21881         if (g3.touch0 && g3.touch0[2] === t2.identifier)
21882           g3.touch0[0] = p2;
21883         else if (g3.touch1 && g3.touch1[2] === t2.identifier)
21884           g3.touch1[0] = p2;
21885       }
21886       t2 = g3.that.__zoom;
21887       if (g3.touch1) {
21888         var p02 = g3.touch0[0], l0 = g3.touch0[1], p1 = g3.touch1[0], l1 = g3.touch1[1], dp = (dp = p1[0] - p02[0]) * dp + (dp = p1[1] - p02[1]) * dp, dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl;
21889         t2 = scale(t2, Math.sqrt(dp / dl));
21890         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
21891         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
21892       } else if (g3.touch0)
21893         p2 = g3.touch0[0], l2 = g3.touch0[1];
21894       else
21895         return;
21896       g3.zoom("touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
21897     }
21898     function touchended(event, ...args) {
21899       if (!this.__zooming)
21900         return;
21901       var g3 = gesture(this, args).event(event), touches = event.changedTouches, n3 = touches.length, i3, t2;
21902       nopropagation2(event);
21903       if (touchending)
21904         clearTimeout(touchending);
21905       touchending = setTimeout(function() {
21906         touchending = null;
21907       }, touchDelay);
21908       for (i3 = 0; i3 < n3; ++i3) {
21909         t2 = touches[i3];
21910         if (g3.touch0 && g3.touch0[2] === t2.identifier)
21911           delete g3.touch0;
21912         else if (g3.touch1 && g3.touch1[2] === t2.identifier)
21913           delete g3.touch1;
21914       }
21915       if (g3.touch1 && !g3.touch0)
21916         g3.touch0 = g3.touch1, delete g3.touch1;
21917       if (g3.touch0)
21918         g3.touch0[1] = this.__zoom.invert(g3.touch0[0]);
21919       else {
21920         g3.end();
21921         if (g3.taps === 2) {
21922           t2 = pointer_default(t2, this);
21923           if (Math.hypot(touchfirst[0] - t2[0], touchfirst[1] - t2[1]) < tapDistance) {
21924             var p2 = select_default2(this).on("dblclick.zoom");
21925             if (p2)
21926               p2.apply(this, arguments);
21927           }
21928         }
21929       }
21930     }
21931     zoom.wheelDelta = function(_2) {
21932       return arguments.length ? (wheelDelta = typeof _2 === "function" ? _2 : constant_default4(+_2), zoom) : wheelDelta;
21933     };
21934     zoom.filter = function(_2) {
21935       return arguments.length ? (filter2 = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : filter2;
21936     };
21937     zoom.touchable = function(_2) {
21938       return arguments.length ? (touchable = typeof _2 === "function" ? _2 : constant_default4(!!_2), zoom) : touchable;
21939     };
21940     zoom.extent = function(_2) {
21941       return arguments.length ? (extent = typeof _2 === "function" ? _2 : constant_default4([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
21942     };
21943     zoom.scaleExtent = function(_2) {
21944       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
21945     };
21946     zoom.translateExtent = function(_2) {
21947       return arguments.length ? (translateExtent[0][0] = +_2[0][0], translateExtent[1][0] = +_2[1][0], translateExtent[0][1] = +_2[0][1], translateExtent[1][1] = +_2[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]];
21948     };
21949     zoom.constrain = function(_2) {
21950       return arguments.length ? (constrain = _2, zoom) : constrain;
21951     };
21952     zoom.duration = function(_2) {
21953       return arguments.length ? (duration = +_2, zoom) : duration;
21954     };
21955     zoom.interpolate = function(_2) {
21956       return arguments.length ? (interpolate = _2, zoom) : interpolate;
21957     };
21958     zoom.on = function() {
21959       var value = listeners.on.apply(listeners, arguments);
21960       return value === listeners ? zoom : value;
21961     };
21962     zoom.clickDistance = function(_2) {
21963       return arguments.length ? (clickDistance2 = (_2 = +_2) * _2, zoom) : Math.sqrt(clickDistance2);
21964     };
21965     zoom.tapDistance = function(_2) {
21966       return arguments.length ? (tapDistance = +_2, zoom) : tapDistance;
21967     };
21968     return zoom;
21969   }
21970
21971   // modules/geo/raw_mercator.js
21972   function geoRawMercator() {
21973     var project = mercatorRaw;
21974     var k2 = 512 / Math.PI;
21975     var x2 = 0;
21976     var y2 = 0;
21977     var clipExtent = [[0, 0], [0, 0]];
21978     function projection2(point2) {
21979       point2 = project(point2[0] * Math.PI / 180, point2[1] * Math.PI / 180);
21980       return [point2[0] * k2 + x2, y2 - point2[1] * k2];
21981     }
21982     projection2.invert = function(point2) {
21983       point2 = project.invert((point2[0] - x2) / k2, (y2 - point2[1]) / k2);
21984       return point2 && [point2[0] * 180 / Math.PI, point2[1] * 180 / Math.PI];
21985     };
21986     projection2.scale = function(_2) {
21987       if (!arguments.length)
21988         return k2;
21989       k2 = +_2;
21990       return projection2;
21991     };
21992     projection2.translate = function(_2) {
21993       if (!arguments.length)
21994         return [x2, y2];
21995       x2 = +_2[0];
21996       y2 = +_2[1];
21997       return projection2;
21998     };
21999     projection2.clipExtent = function(_2) {
22000       if (!arguments.length)
22001         return clipExtent;
22002       clipExtent = _2;
22003       return projection2;
22004     };
22005     projection2.transform = function(obj) {
22006       if (!arguments.length)
22007         return identity2.translate(x2, y2).scale(k2);
22008       x2 = +obj.x;
22009       y2 = +obj.y;
22010       k2 = +obj.k;
22011       return projection2;
22012     };
22013     projection2.stream = transform_default({
22014       point: function(x3, y3) {
22015         var vec = projection2([x3, y3]);
22016         this.stream.point(vec[0], vec[1]);
22017       }
22018     }).stream;
22019     return projection2;
22020   }
22021
22022   // modules/geo/ortho.js
22023   function geoOrthoNormalizedDotProduct(a2, b2, origin) {
22024     if (geoVecEqual(origin, a2) || geoVecEqual(origin, b2)) {
22025       return 1;
22026     }
22027     return geoVecNormalizedDot(a2, b2, origin);
22028   }
22029   function geoOrthoFilterDotProduct(dotp, epsilon3, lowerThreshold, upperThreshold, allowStraightAngles) {
22030     var val = Math.abs(dotp);
22031     if (val < epsilon3) {
22032       return 0;
22033     } else if (allowStraightAngles && Math.abs(val - 1) < epsilon3) {
22034       return 0;
22035     } else if (val < lowerThreshold || val > upperThreshold) {
22036       return dotp;
22037     } else {
22038       return null;
22039     }
22040   }
22041   function geoOrthoCalcScore(points, isClosed, epsilon3, threshold) {
22042     var score = 0;
22043     var first = isClosed ? 0 : 1;
22044     var last = isClosed ? points.length : points.length - 1;
22045     var coords = points.map(function(p2) {
22046       return p2.coord;
22047     });
22048     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
22049     var upperThreshold = Math.cos(threshold * Math.PI / 180);
22050     for (var i3 = first; i3 < last; i3++) {
22051       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
22052       var origin = coords[i3];
22053       var b2 = coords[(i3 + 1) % coords.length];
22054       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold);
22055       if (dotp === null)
22056         continue;
22057       score = score + 2 * Math.min(Math.abs(dotp - 1), Math.min(Math.abs(dotp), Math.abs(dotp + 1)));
22058     }
22059     return score;
22060   }
22061   function geoOrthoMaxOffsetAngle(coords, isClosed, lessThan) {
22062     var max3 = -Infinity;
22063     var first = isClosed ? 0 : 1;
22064     var last = isClosed ? coords.length : coords.length - 1;
22065     for (var i3 = first; i3 < last; i3++) {
22066       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
22067       var origin = coords[i3];
22068       var b2 = coords[(i3 + 1) % coords.length];
22069       var normalizedDotP = geoOrthoNormalizedDotProduct(a2, b2, origin);
22070       var angle2 = Math.acos(Math.abs(normalizedDotP)) * 180 / Math.PI;
22071       if (angle2 > 45)
22072         angle2 = 90 - angle2;
22073       if (angle2 >= lessThan)
22074         continue;
22075       if (angle2 > max3)
22076         max3 = angle2;
22077     }
22078     if (max3 === -Infinity)
22079       return null;
22080     return max3;
22081   }
22082   function geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles) {
22083     var score = null;
22084     var first = isClosed ? 0 : 1;
22085     var last = isClosed ? coords.length : coords.length - 1;
22086     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
22087     var upperThreshold = Math.cos(threshold * Math.PI / 180);
22088     for (var i3 = first; i3 < last; i3++) {
22089       var a2 = coords[(i3 - 1 + coords.length) % coords.length];
22090       var origin = coords[i3];
22091       var b2 = coords[(i3 + 1) % coords.length];
22092       var dotp = geoOrthoFilterDotProduct(geoOrthoNormalizedDotProduct(a2, b2, origin), epsilon3, lowerThreshold, upperThreshold, allowStraightAngles);
22093       if (dotp === null)
22094         continue;
22095       if (Math.abs(dotp) > 0)
22096         return 1;
22097       score = 0;
22098     }
22099     return score;
22100   }
22101
22102   // modules/util/array.js
22103   function utilArrayIdentical(a2, b2) {
22104     if (a2 === b2)
22105       return true;
22106     var i3 = a2.length;
22107     if (i3 !== b2.length)
22108       return false;
22109     while (i3--) {
22110       if (a2[i3] !== b2[i3])
22111         return false;
22112     }
22113     return true;
22114   }
22115   function utilArrayDifference(a2, b2) {
22116     var other = new Set(b2);
22117     return Array.from(new Set(a2)).filter(function(v2) {
22118       return !other.has(v2);
22119     });
22120   }
22121   function utilArrayIntersection(a2, b2) {
22122     var other = new Set(b2);
22123     return Array.from(new Set(a2)).filter(function(v2) {
22124       return other.has(v2);
22125     });
22126   }
22127   function utilArrayUnion(a2, b2) {
22128     var result = new Set(a2);
22129     b2.forEach(function(v2) {
22130       result.add(v2);
22131     });
22132     return Array.from(result);
22133   }
22134   function utilArrayUniq(a2) {
22135     return Array.from(new Set(a2));
22136   }
22137   function utilArrayChunk(a2, chunkSize) {
22138     if (!chunkSize || chunkSize < 0)
22139       return [a2.slice()];
22140     var result = new Array(Math.ceil(a2.length / chunkSize));
22141     return Array.from(result, function(item, i3) {
22142       return a2.slice(i3 * chunkSize, i3 * chunkSize + chunkSize);
22143     });
22144   }
22145   function utilArrayFlatten(a2) {
22146     return a2.reduce(function(acc, val) {
22147       return acc.concat(val);
22148     }, []);
22149   }
22150   function utilArrayGroupBy(a2, key) {
22151     return a2.reduce(function(acc, item) {
22152       var group = typeof key === "function" ? key(item) : item[key];
22153       (acc[group] = acc[group] || []).push(item);
22154       return acc;
22155     }, {});
22156   }
22157   function utilArrayUniqBy(a2, key) {
22158     var seen = /* @__PURE__ */ new Set();
22159     return a2.reduce(function(acc, item) {
22160       var val = typeof key === "function" ? key(item) : item[key];
22161       if (val && !seen.has(val)) {
22162         seen.add(val);
22163         acc.push(item);
22164       }
22165       return acc;
22166     }, []);
22167   }
22168
22169   // modules/util/util.js
22170   var import_diacritics = __toESM(require_diacritics());
22171
22172   // modules/util/svg_paths_rtl_fix.js
22173   var import_alif_toolkit = __toESM(require_lib());
22174   var rtlRegex = /[\u0590-\u05FF\u0600-\u06FF\u0750-\u07BF\u08A0–\u08BF]/;
22175   function fixRTLTextForSvg(inputText) {
22176     var ret = "", rtlBuffer = [];
22177     var arabicRegex = /[\u0600-\u06FF]/g;
22178     var arabicDiacritics = /[\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06ED]/g;
22179     var arabicMath = /[\u0660-\u066C\u06F0-\u06F9]+/g;
22180     var thaanaVowel = /[\u07A6-\u07B0]/;
22181     var hebrewSign = /[\u0591-\u05bd\u05bf\u05c1-\u05c5\u05c7]/;
22182     if (arabicRegex.test(inputText)) {
22183       inputText = (0, import_alif_toolkit.WordShaper)(inputText);
22184     }
22185     for (var n3 = 0; n3 < inputText.length; n3++) {
22186       var c2 = inputText[n3];
22187       if (arabicMath.test(c2)) {
22188         ret += rtlBuffer.reverse().join("");
22189         rtlBuffer = [c2];
22190       } else {
22191         if (rtlBuffer.length && arabicMath.test(rtlBuffer[rtlBuffer.length - 1])) {
22192           ret += rtlBuffer.reverse().join("");
22193           rtlBuffer = [];
22194         }
22195         if ((thaanaVowel.test(c2) || hebrewSign.test(c2) || arabicDiacritics.test(c2)) && rtlBuffer.length) {
22196           rtlBuffer[rtlBuffer.length - 1] += c2;
22197         } else if (rtlRegex.test(c2) || c2.charCodeAt(0) >= 64336 && c2.charCodeAt(0) <= 65023 || c2.charCodeAt(0) >= 65136 && c2.charCodeAt(0) <= 65279) {
22198           rtlBuffer.push(c2);
22199         } else if (c2 === " " && rtlBuffer.length) {
22200           rtlBuffer = [rtlBuffer.reverse().join("") + " "];
22201         } else {
22202           ret += rtlBuffer.reverse().join("") + c2;
22203           rtlBuffer = [];
22204         }
22205       }
22206     }
22207     ret += rtlBuffer.reverse().join("");
22208     return ret;
22209   }
22210
22211   // modules/core/preferences.js
22212   var _storage;
22213   try {
22214     _storage = localStorage;
22215   } catch (e3) {
22216   }
22217   _storage = _storage || /* @__PURE__ */ (() => {
22218     let s2 = {};
22219     return {
22220       getItem: (k2) => s2[k2],
22221       setItem: (k2, v2) => s2[k2] = v2,
22222       removeItem: (k2) => delete s2[k2]
22223     };
22224   })();
22225   var _listeners = {};
22226   function corePreferences(k2, v2) {
22227     try {
22228       if (v2 === void 0)
22229         return _storage.getItem(k2);
22230       else if (v2 === null)
22231         _storage.removeItem(k2);
22232       else
22233         _storage.setItem(k2, v2);
22234       if (_listeners[k2]) {
22235         _listeners[k2].forEach((handler) => handler(v2));
22236       }
22237       return true;
22238     } catch (e3) {
22239       if (typeof console !== "undefined") {
22240         console.error("localStorage quota exceeded");
22241       }
22242       return false;
22243     }
22244   }
22245   corePreferences.onChange = function(k2, handler) {
22246     _listeners[k2] = _listeners[k2] || [];
22247     _listeners[k2].push(handler);
22248   };
22249
22250   // modules/core/file_fetcher.js
22251   var import_vparse = __toESM(require_vparse());
22252
22253   // config/id.js
22254   var presetsCdnUrl = "https://cdn.jsdelivr.net/npm/@openstreetmap/id-tagging-schema@{presets_version}/";
22255   var ociCdnUrl = "https://cdn.jsdelivr.net/npm/osm-community-index@{version}/";
22256   var wmfSitematrixCdnUrl = "https://cdn.jsdelivr.net/npm/wmf-sitematrix@{version}/";
22257   var nsiCdnUrl = "https://cdn.jsdelivr.net/npm/name-suggestion-index@{version}/";
22258   var defaultOsmApiConnections = {
22259     live: {
22260       url: "https://www.openstreetmap.org",
22261       apiUrl: "https://api.openstreetmap.org",
22262       client_id: "0tmNTmd0Jo1dQp4AUmMBLtGiD9YpMuXzHefitcuVStc",
22263       client_secret: "BTlNrNxIPitHdL4sP2clHw5KLoee9aKkA7dQbc0Bj7Q"
22264     },
22265     dev: {
22266       url: "https://api06.dev.openstreetmap.org",
22267       client_id: "Ee1wWJ6UlpERbF6BfTNOpwn0R8k_06mvMXdDUkeHMgw",
22268       client_secret: "OnfWFC-JkZNHyYdr_viNn_h_RTZXRslKcUxllOXqf5g"
22269     }
22270   };
22271   var osmApiConnections = [];
22272   if (false) {
22273     osmApiConnections.push({
22274       url: null,
22275       apiUrl: ENV__ID_API_CONNECTION_API_URL,
22276       client_id: null,
22277       client_secret: null
22278     });
22279   } else if (false) {
22280     osmApiConnections.push(defaultOsmApiConnections[null]);
22281   } else {
22282     osmApiConnections.push(defaultOsmApiConnections.live);
22283     osmApiConnections.push(defaultOsmApiConnections.dev);
22284   }
22285   var taginfoApiUrl = "https://taginfo.openstreetmap.org/api/4/";
22286   var nominatimApiUrl = "https://nominatim.openstreetmap.org/";
22287   var showDonationMessage = true;
22288
22289   // package.json
22290   var package_default = {
22291     name: "iD",
22292     version: "2.28.1",
22293     description: "A friendly editor for OpenStreetMap",
22294     main: "dist/iD.min.js",
22295     repository: "github:openstreetmap/iD",
22296     homepage: "https://github.com/openstreetmap/iD",
22297     bugs: "https://github.com/openstreetmap/iD/issues",
22298     keywords: [
22299       "editor",
22300       "openstreetmap"
22301     ],
22302     license: "ISC",
22303     scripts: {
22304       all: "run-s clean build dist",
22305       build: "run-s build:css build:data build:js",
22306       "build:css": "node scripts/build_css.js",
22307       "build:data": "shx mkdir -p dist/data && node scripts/build_data.js",
22308       "build:stats": "node config/esbuild.config.mjs --stats && esbuild-visualizer --metadata dist/esbuild.json --exclude *.png --filename docs/statistics.html && shx rm dist/esbuild.json",
22309       "build:js": "node config/esbuild.config.mjs",
22310       "build:js:watch": "node config/esbuild.config.mjs --watch",
22311       clean: "shx rm -f dist/esbuild.json dist/*.js dist/*.map dist/*.css dist/img/*.svg",
22312       dist: "run-p dist:**",
22313       "dist:mapillary": "shx mkdir -p dist/mapillary-js && shx cp -R node_modules/mapillary-js/dist/* dist/mapillary-js/",
22314       "dist:pannellum": "shx mkdir -p dist/pannellum && shx cp -R node_modules/pannellum/build/* dist/pannellum/",
22315       "dist:min": "node config/esbuild.config.min.mjs",
22316       "dist:svg:iD": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "iD-%s" --symbol-sprite dist/img/iD-sprite.svg "svg/iD-sprite/**/*.svg"',
22317       "dist:svg:community": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "community-%s" --symbol-sprite dist/img/community-sprite.svg node_modules/osm-community-index/dist/img/*.svg',
22318       "dist:svg:fa": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/fa-sprite.svg svg/fontawesome/*.svg",
22319       "dist:svg:maki": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "maki-%s" --symbol-sprite dist/img/maki-sprite.svg node_modules/@mapbox/maki/icons/*.svg',
22320       "dist:svg:mapillary:signs": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/mapillary-sprite.svg node_modules/@rapideditor/mapillary_sprite_source/package_signs/*.svg",
22321       "dist:svg:mapillary:objects": "svg-sprite --symbol --symbol-dest . --symbol-sprite dist/img/mapillary-object-sprite.svg node_modules/@rapideditor/mapillary_sprite_source/package_objects/*.svg",
22322       "dist:svg:roentgen": 'svg-sprite --shape-id-generator "roentgen-%s" --shape-dim-width 16 --shape-dim-height 16 --symbol --symbol-dest . --symbol-sprite dist/img/roentgen-sprite.svg svg/roentgen/*.svg',
22323       "dist:svg:temaki": 'svg-sprite --symbol --symbol-dest . --shape-id-generator "temaki-%s" --symbol-sprite dist/img/temaki-sprite.svg node_modules/@rapideditor/temaki/icons/*.svg',
22324       imagery: "node scripts/update_imagery.js",
22325       lint: "eslint config scripts test/spec modules --ext js,mjs",
22326       "lint:fix": "eslint scripts test/spec modules --fix",
22327       start: "run-s start:watch",
22328       "start:single-build": "run-p build:js start:server",
22329       "start:watch": "run-p build:js:watch start:server",
22330       "start:server": "node scripts/server.js",
22331       test: "npm-run-all -s lint build test:spec",
22332       "test:spec": "karma start config/karma.conf.js",
22333       translations: "node scripts/update_locales.js"
22334     },
22335     dependencies: {
22336       "@mapbox/geojson-area": "^0.2.2",
22337       "@mapbox/sexagesimal": "1.2.0",
22338       "@mapbox/vector-tile": "^1.3.1",
22339       "@rapideditor/country-coder": "~5.2.2",
22340       "@rapideditor/location-conflation": "~1.3.0",
22341       "@tmcw/togeojson": "^5.8.1",
22342       "@turf/bbox": "^6.0.0",
22343       "@turf/bbox-clip": "^6.0.0",
22344       "abortcontroller-polyfill": "^1.7.5",
22345       "aes-js": "^3.1.2",
22346       "alif-toolkit": "^1.2.9",
22347       "core-js-bundle": "^3.36.0",
22348       diacritics: "1.3.0",
22349       exifr: "^7.1.3",
22350       "fast-deep-equal": "~3.1.1",
22351       "fast-json-stable-stringify": "2.1.0",
22352       "lodash-es": "~4.17.15",
22353       marked: "~12.0.0",
22354       "node-diff3": "~3.1.0",
22355       "osm-auth": "~2.4.0",
22356       pannellum: "2.5.6",
22357       pbf: "^3.2.1",
22358       "polygon-clipping": "~0.15.7",
22359       rbush: "3.0.1",
22360       "whatwg-fetch": "^3.6.20",
22361       "which-polygon": "2.2.1"
22362     },
22363     devDependencies: {
22364       "@fortawesome/fontawesome-svg-core": "~6.5.1",
22365       "@fortawesome/free-brands-svg-icons": "~6.5.1",
22366       "@fortawesome/free-regular-svg-icons": "~6.5.1",
22367       "@fortawesome/free-solid-svg-icons": "~6.5.1",
22368       "@mapbox/maki": "^8.0.1",
22369       "@openstreetmap/id-tagging-schema": "^6.6.0",
22370       "@rapideditor/mapillary_sprite_source": "^1.8.0",
22371       "@rapideditor/temaki": "^5.7.0",
22372       "@transifex/api": "^7.1.0",
22373       autoprefixer: "^10.4.17",
22374       browserslist: "^4.23.0",
22375       "browserslist-to-esbuild": "^2.1.1",
22376       chai: "^4.4.1",
22377       chalk: "^4.1.2",
22378       "cldr-core": "^44.0.1",
22379       "cldr-localenames-full": "^44.1.0",
22380       "concat-files": "^0.1.1",
22381       d3: "~7.8.5",
22382       dotenv: "^16.4.5",
22383       "editor-layer-index": "github:osmlab/editor-layer-index#gh-pages",
22384       esbuild: "^0.20.1",
22385       "esbuild-visualizer": "^0.6.0",
22386       eslint: "^8.57.0",
22387       "fetch-mock": "^9.11.0",
22388       gaze: "^1.1.3",
22389       glob: "^10.3.10",
22390       happen: "^0.3.2",
22391       "js-yaml": "^4.0.0",
22392       "json-stringify-pretty-compact": "^3.0.0",
22393       karma: "^6.4.3",
22394       "karma-chrome-launcher": "^3.2.0",
22395       "karma-coverage": "2.1.1",
22396       "karma-mocha": "^2.0.1",
22397       "karma-remap-istanbul": "^0.6.0",
22398       "mapillary-js": "4.1.2",
22399       minimist: "^1.2.8",
22400       mocha: "^10.3.0",
22401       "name-suggestion-index": "~6.0",
22402       "node-fetch": "^2.7.0",
22403       "npm-run-all": "^4.0.0",
22404       "osm-community-index": "~5.6.2",
22405       postcss: "^8.4.35",
22406       "postcss-selector-prepend": "^0.5.0",
22407       shelljs: "^0.8.0",
22408       shx: "^0.3.0",
22409       sinon: "^11.1.2",
22410       "sinon-chai": "^3.7.0",
22411       smash: "0.0",
22412       "static-server": "^2.2.1",
22413       "svg-sprite": "2.0.2",
22414       vparse: "~1.1.0"
22415     },
22416     engines: {
22417       node: ">=18"
22418     },
22419     browserslist: [
22420       "> 0.3%, last 6 major versions, not dead, Firefox ESR, maintained node versions"
22421     ]
22422   };
22423
22424   // modules/core/file_fetcher.js
22425   var _mainFileFetcher = coreFileFetcher();
22426   function coreFileFetcher() {
22427     const ociVersion = package_default.dependencies["osm-community-index"] || package_default.devDependencies["osm-community-index"];
22428     const v2 = (0, import_vparse.default)(ociVersion);
22429     const ociVersionMinor = "".concat(v2.major, ".").concat(v2.minor);
22430     const presetsVersion = package_default.devDependencies["@openstreetmap/id-tagging-schema"];
22431     let _this = {};
22432     let _inflight4 = {};
22433     let _fileMap = {
22434       "address_formats": "data/address_formats.min.json",
22435       "imagery": "data/imagery.min.json",
22436       "intro_graph": "data/intro_graph.min.json",
22437       "keepRight": "data/keepRight.min.json",
22438       "languages": "data/languages.min.json",
22439       "locales": "locales/index.min.json",
22440       "phone_formats": "data/phone_formats.min.json",
22441       "qa_data": "data/qa_data.min.json",
22442       "shortcuts": "data/shortcuts.min.json",
22443       "territory_languages": "data/territory_languages.min.json",
22444       "oci_defaults": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/defaults.min.json",
22445       "oci_features": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/featureCollection.min.json",
22446       "oci_resources": ociCdnUrl.replace("{version}", ociVersionMinor) + "dist/resources.min.json",
22447       "presets_package": presetsCdnUrl.replace("{presets_version}", presetsVersion) + "package.json",
22448       "deprecated": presetsCdnUrl + "dist/deprecated.min.json",
22449       "discarded": presetsCdnUrl + "dist/discarded.min.json",
22450       "preset_categories": presetsCdnUrl + "dist/preset_categories.min.json",
22451       "preset_defaults": presetsCdnUrl + "dist/preset_defaults.min.json",
22452       "preset_fields": presetsCdnUrl + "dist/fields.min.json",
22453       "preset_presets": presetsCdnUrl + "dist/presets.min.json",
22454       "wmf_sitematrix": wmfSitematrixCdnUrl.replace("{version}", "0.1") + "wikipedia.min.json"
22455     };
22456     let _cachedData = {};
22457     _this.cache = () => _cachedData;
22458     _this.get = (which) => {
22459       if (_cachedData[which]) {
22460         return Promise.resolve(_cachedData[which]);
22461       }
22462       const file = _fileMap[which];
22463       const url = file && _this.asset(file);
22464       if (!url) {
22465         return Promise.reject('Unknown data file for "'.concat(which, '"'));
22466       }
22467       if (url.includes("{presets_version}")) {
22468         return _this.get("presets_package").then((result) => {
22469           const presetsVersion2 = result.version;
22470           return getUrl(url.replace("{presets_version}", presetsVersion2), which);
22471         });
22472       } else {
22473         return getUrl(url);
22474       }
22475     };
22476     function getUrl(url, which) {
22477       let prom = _inflight4[url];
22478       if (!prom) {
22479         _inflight4[url] = prom = fetch(url).then((response) => {
22480           if (!response.ok || !response.json) {
22481             throw new Error(response.status + " " + response.statusText);
22482           }
22483           if (response.status === 204 || response.status === 205)
22484             return;
22485           return response.json();
22486         }).then((result) => {
22487           delete _inflight4[url];
22488           if (!result) {
22489             throw new Error('No data loaded for "'.concat(which, '"'));
22490           }
22491           _cachedData[which] = result;
22492           return result;
22493         }).catch((err) => {
22494           delete _inflight4[url];
22495           throw err;
22496         });
22497       }
22498       return prom;
22499     }
22500     _this.fileMap = function(val) {
22501       if (!arguments.length)
22502         return _fileMap;
22503       _fileMap = val;
22504       return _this;
22505     };
22506     let _assetPath = "";
22507     _this.assetPath = function(val) {
22508       if (!arguments.length)
22509         return _assetPath;
22510       _assetPath = val;
22511       return _this;
22512     };
22513     let _assetMap = {};
22514     _this.assetMap = function(val) {
22515       if (!arguments.length)
22516         return _assetMap;
22517       _assetMap = val;
22518       return _this;
22519     };
22520     _this.asset = (val) => {
22521       if (/^http(s)?:\/\//i.test(val))
22522         return val;
22523       const filename = _assetPath + val;
22524       return _assetMap[filename] || filename;
22525     };
22526     return _this;
22527   }
22528
22529   // node_modules/@rapideditor/country-coder/dist/country-coder.mjs
22530   var import_which_polygon = __toESM(require_which_polygon(), 1);
22531   var borders_default = { type: "FeatureCollection", features: [
22532     { type: "Feature", properties: { wikidata: "Q21", nameEn: "England", aliases: ["GB-ENG"], country: "GB", groups: ["Q23666", "Q3336843", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-6.03913, 51.13217], [-7.74976, 48.64773], [1.17405, 50.74239], [2.18458, 51.52087], [2.56575, 51.85301], [0.792, 57.56437], [-2.30613, 55.62698], [-2.17058, 55.45916], [-2.6095, 55.28488], [-2.63532, 55.19452], [-3.02906, 55.04606], [-3.09361, 54.94924], [-3.38407, 54.94278], [-4.1819, 54.57861], [-3.5082, 53.54318], [-3.08228, 53.25526], [-3.03675, 53.25092], [-2.92329, 53.19383], [-2.92022, 53.17685], [-2.98598, 53.15589], [-2.90649, 53.10964], [-2.87469, 53.12337], [-2.89131, 53.09374], [-2.83133, 52.99184], [-2.7251, 52.98389], [-2.72221, 52.92969], [-2.80549, 52.89428], [-2.85897, 52.94487], [-2.92401, 52.93836], [-2.97243, 52.9651], [-3.13576, 52.895], [-3.15744, 52.84947], [-3.16105, 52.79599], [-3.08734, 52.77504], [-3.01001, 52.76636], [-2.95581, 52.71794], [-3.01724, 52.72083], [-3.04398, 52.65435], [-3.13648, 52.58208], [-3.12926, 52.5286], [-3.09746, 52.53077], [-3.08662, 52.54811], [-3.00929, 52.57774], [-2.99701, 52.551], [-3.03603, 52.49969], [-3.13359, 52.49174], [-3.22971, 52.45344], [-3.22754, 52.42526], [-3.04687, 52.34504], [-2.95364, 52.3501], [-2.99701, 52.323], [-3.00785, 52.2753], [-3.09289, 52.20546], [-3.12638, 52.08114], [-2.97111, 51.90456], [-2.8818, 51.93196], [-2.78742, 51.88833], [-2.74277, 51.84367], [-2.66234, 51.83555], [-2.66336, 51.59504], [-3.20563, 51.31615], [-6.03913, 51.13217]]]] } },
22533     { type: "Feature", properties: { wikidata: "Q22", nameEn: "Scotland", aliases: ["GB-SCT"], country: "GB", groups: ["Q23666", "Q3336843", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44"] }, geometry: { type: "MultiPolygon", coordinates: [[[[0.792, 57.56437], [-0.3751, 61.32236], [-14.78497, 57.60709], [-6.82333, 55.83103], [-4.69044, 54.3629], [-3.38407, 54.94278], [-3.09361, 54.94924], [-3.02906, 55.04606], [-2.63532, 55.19452], [-2.6095, 55.28488], [-2.17058, 55.45916], [-2.30613, 55.62698], [0.792, 57.56437]]]] } },
22534     { type: "Feature", properties: { wikidata: "Q25", nameEn: "Wales", aliases: ["GB-WLS"], country: "GB", groups: ["Q23666", "Q3336843", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-3.5082, 53.54318], [-5.37267, 53.63269], [-6.03913, 51.13217], [-3.20563, 51.31615], [-2.66336, 51.59504], [-2.66234, 51.83555], [-2.74277, 51.84367], [-2.78742, 51.88833], [-2.8818, 51.93196], [-2.97111, 51.90456], [-3.12638, 52.08114], [-3.09289, 52.20546], [-3.00785, 52.2753], [-2.99701, 52.323], [-2.95364, 52.3501], [-3.04687, 52.34504], [-3.22754, 52.42526], [-3.22971, 52.45344], [-3.13359, 52.49174], [-3.03603, 52.49969], [-2.99701, 52.551], [-3.00929, 52.57774], [-3.08662, 52.54811], [-3.09746, 52.53077], [-3.12926, 52.5286], [-3.13648, 52.58208], [-3.04398, 52.65435], [-3.01724, 52.72083], [-2.95581, 52.71794], [-3.01001, 52.76636], [-3.08734, 52.77504], [-3.16105, 52.79599], [-3.15744, 52.84947], [-3.13576, 52.895], [-2.97243, 52.9651], [-2.92401, 52.93836], [-2.85897, 52.94487], [-2.80549, 52.89428], [-2.72221, 52.92969], [-2.7251, 52.98389], [-2.83133, 52.99184], [-2.89131, 53.09374], [-2.87469, 53.12337], [-2.90649, 53.10964], [-2.98598, 53.15589], [-2.92022, 53.17685], [-2.92329, 53.19383], [-3.03675, 53.25092], [-3.08228, 53.25526], [-3.5082, 53.54318]]]] } },
22535     { type: "Feature", properties: { wikidata: "Q26", nameEn: "Northern Ireland", aliases: ["GB-NIR"], country: "GB", groups: ["Q22890", "Q3336843", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-6.34755, 55.49206], [-7.2471, 55.06933], [-7.34464, 55.04688], [-7.4033, 55.00391], [-7.40004, 54.94498], [-7.44404, 54.9403], [-7.4473, 54.87003], [-7.47626, 54.83084], [-7.54508, 54.79401], [-7.54671, 54.74606], [-7.64449, 54.75265], [-7.75041, 54.7103], [-7.83352, 54.73854], [-7.93293, 54.66603], [-7.70315, 54.62077], [-7.8596, 54.53671], [-7.99812, 54.54427], [-8.04538, 54.48941], [-8.179, 54.46763], [-8.04555, 54.36292], [-7.87101, 54.29299], [-7.8596, 54.21779], [-7.81397, 54.20159], [-7.69501, 54.20731], [-7.55812, 54.12239], [-7.4799, 54.12239], [-7.44567, 54.1539], [-7.32834, 54.11475], [-7.30553, 54.11869], [-7.34005, 54.14698], [-7.29157, 54.17191], [-7.28017, 54.16714], [-7.29687, 54.1354], [-7.29493, 54.12013], [-7.26316, 54.13863], [-7.25012, 54.20063], [-7.14908, 54.22732], [-7.19145, 54.31296], [-7.02034, 54.4212], [-6.87775, 54.34682], [-6.85179, 54.29176], [-6.81583, 54.22791], [-6.74575, 54.18788], [-6.70175, 54.20218], [-6.6382, 54.17071], [-6.66264, 54.0666], [-6.62842, 54.03503], [-6.47849, 54.06947], [-6.36605, 54.07234], [-6.36279, 54.11248], [-6.32694, 54.09337], [-6.29003, 54.11278], [-6.26218, 54.09785], [-5.83481, 53.87749], [-4.69044, 54.3629], [-6.34755, 55.49206]]]] } },
22536     { type: "Feature", properties: { wikidata: "Q35", nameEn: "Denmark", country: "DK", groups: ["EU", "154", "150", "UN"], callingCodes: ["45"] }, geometry: { type: "MultiPolygon", coordinates: [[[[12.16597, 56.60205], [10.40861, 58.38489], [7.28637, 57.35913], [8.02459, 55.09613], [8.45719, 55.06747], [8.55769, 54.91837], [8.63979, 54.91069], [8.76387, 54.8948], [8.81178, 54.90518], [8.92795, 54.90452], [9.04629, 54.87249], [9.14275, 54.87421], [9.20571, 54.85841], [9.24631, 54.84726], [9.23445, 54.83432], [9.2474, 54.8112], [9.32771, 54.80602], [9.33849, 54.80233], [9.36496, 54.81749], [9.38532, 54.83968], [9.41213, 54.84254], [9.43155, 54.82586], [9.4659, 54.83131], [9.58937, 54.88785], [9.62734, 54.88057], [9.61187, 54.85548], [9.73563, 54.8247], [9.89314, 54.84171], [10.16755, 54.73883], [10.31111, 54.65968], [11.00303, 54.63689], [11.90309, 54.38543], [12.85844, 54.82438], [13.93395, 54.84044], [15.36991, 54.73263], [15.79951, 55.54655], [14.89259, 55.5623], [14.28399, 55.1553], [12.84405, 55.13257], [12.60345, 55.42675], [12.88472, 55.63369], [12.6372, 55.91371], [12.65312, 56.04345], [12.07466, 56.29488], [12.16597, 56.60205]]]] } },
22537     { type: "Feature", properties: { wikidata: "Q55", nameEn: "Netherlands", country: "NL", groups: ["EU", "155", "150", "UN"], callingCodes: ["31"] }, geometry: { type: "MultiPolygon", coordinates: [[[[5.45168, 54.20039], [2.56575, 51.85301], [3.36263, 51.37112], [3.38696, 51.33436], [3.35847, 51.31572], [3.38289, 51.27331], [3.41704, 51.25933], [3.43488, 51.24135], [3.52698, 51.2458], [3.51502, 51.28697], [3.58939, 51.30064], [3.78999, 51.25766], [3.78783, 51.2151], [3.90125, 51.20371], [3.97889, 51.22537], [4.01957, 51.24504], [4.05165, 51.24171], [4.16721, 51.29348], [4.24024, 51.35371], [4.21923, 51.37443], [4.33265, 51.37687], [4.34086, 51.35738], [4.39292, 51.35547], [4.43777, 51.36989], [4.38064, 51.41965], [4.39747, 51.43316], [4.38122, 51.44905], [4.47736, 51.4778], [4.5388, 51.48184], [4.54675, 51.47265], [4.52846, 51.45002], [4.53521, 51.4243], [4.57489, 51.4324], [4.65442, 51.42352], [4.72935, 51.48424], [4.74578, 51.48937], [4.77321, 51.50529], [4.78803, 51.50284], [4.84139, 51.4799], [4.82409, 51.44736], [4.82946, 51.4213], [4.78314, 51.43319], [4.76577, 51.43046], [4.77229, 51.41337], [4.78941, 51.41102], [4.84988, 51.41502], [4.90016, 51.41404], [4.92152, 51.39487], [5.00393, 51.44406], [5.0106, 51.47167], [5.03281, 51.48679], [5.04774, 51.47022], [5.07891, 51.4715], [5.10456, 51.43163], [5.07102, 51.39469], [5.13105, 51.34791], [5.13377, 51.31592], [5.16222, 51.31035], [5.2002, 51.32243], [5.24244, 51.30495], [5.22542, 51.26888], [5.23814, 51.26064], [5.26461, 51.26693], [5.29716, 51.26104], [5.33886, 51.26314], [5.347, 51.27502], [5.41672, 51.26248], [5.4407, 51.28169], [5.46519, 51.2849], [5.48476, 51.30053], [5.515, 51.29462], [5.5569, 51.26544], [5.5603, 51.22249], [5.65145, 51.19788], [5.65528, 51.18736], [5.70344, 51.1829], [5.74617, 51.18928], [5.77735, 51.17845], [5.77697, 51.1522], [5.82564, 51.16753], [5.85508, 51.14445], [5.80798, 51.11661], [5.8109, 51.10861], [5.83226, 51.10585], [5.82921, 51.09328], [5.79903, 51.09371], [5.79835, 51.05834], [5.77258, 51.06196], [5.75961, 51.03113], [5.77688, 51.02483], [5.76242, 50.99703], [5.71864, 50.96092], [5.72875, 50.95428], [5.74752, 50.96202], [5.75927, 50.95601], [5.74644, 50.94723], [5.72545, 50.92312], [5.72644, 50.91167], [5.71626, 50.90796], [5.69858, 50.91046], [5.67886, 50.88142], [5.64504, 50.87107], [5.64009, 50.84742], [5.65259, 50.82309], [5.70118, 50.80764], [5.68995, 50.79641], [5.70107, 50.7827], [5.68091, 50.75804], [5.69469, 50.75529], [5.72216, 50.76398], [5.73904, 50.75674], [5.74356, 50.7691], [5.76533, 50.78159], [5.77513, 50.78308], [5.80673, 50.7558], [5.84548, 50.76542], [5.84888, 50.75448], [5.88734, 50.77092], [5.89129, 50.75125], [5.89132, 50.75124], [5.95942, 50.7622], [5.97545, 50.75441], [6.01976, 50.75398], [6.02624, 50.77453], [5.97497, 50.79992], [5.98404, 50.80988], [6.00462, 50.80065], [6.02328, 50.81694], [6.01921, 50.84435], [6.05623, 50.8572], [6.05702, 50.85179], [6.07431, 50.84674], [6.07693, 50.86025], [6.08805, 50.87223], [6.07486, 50.89307], [6.09297, 50.92066], [6.01615, 50.93367], [6.02697, 50.98303], [5.95282, 50.98728], [5.90296, 50.97356], [5.90493, 51.00198], [5.87849, 51.01969], [5.86735, 51.05182], [5.9134, 51.06736], [5.9541, 51.03496], [5.98292, 51.07469], [6.16706, 51.15677], [6.17384, 51.19589], [6.07889, 51.17038], [6.07889, 51.24432], [6.16977, 51.33169], [6.22674, 51.36135], [6.22641, 51.39948], [6.20654, 51.40049], [6.21724, 51.48568], [6.18017, 51.54096], [6.09055, 51.60564], [6.11759, 51.65609], [6.02767, 51.6742], [6.04091, 51.71821], [5.95003, 51.7493], [5.98665, 51.76944], [5.94568, 51.82786], [5.99848, 51.83195], [6.06705, 51.86136], [6.10337, 51.84829], [6.16902, 51.84094], [6.11551, 51.89769], [6.15349, 51.90439], [6.21443, 51.86801], [6.29872, 51.86801], [6.30593, 51.84998], [6.40704, 51.82771], [6.38815, 51.87257], [6.47179, 51.85395], [6.50231, 51.86313], [6.58556, 51.89386], [6.68386, 51.91861], [6.72319, 51.89518], [6.82357, 51.96711], [6.83035, 51.9905], [6.68128, 52.05052], [6.76117, 52.11895], [6.83984, 52.11728], [6.97189, 52.20329], [6.9897, 52.2271], [7.03729, 52.22695], [7.06365, 52.23789], [7.02703, 52.27941], [7.07044, 52.37805], [7.03417, 52.40237], [6.99041, 52.47235], [6.94293, 52.43597], [6.69507, 52.488], [6.71641, 52.62905], [6.77307, 52.65375], [7.04557, 52.63318], [7.07253, 52.81083], [7.21694, 53.00742], [7.17898, 53.13817], [7.22681, 53.18165], [7.21679, 53.20058], [7.19052, 53.31866], [7.00198, 53.32672], [6.91025, 53.44221], [5.45168, 54.20039]], [[4.93295, 51.44945], [4.95244, 51.45207], [4.9524, 51.45014], [4.93909, 51.44632], [4.93295, 51.44945]], [[4.91493, 51.4353], [4.91935, 51.43634], [4.92227, 51.44252], [4.91811, 51.44621], [4.92287, 51.44741], [4.92811, 51.4437], [4.92566, 51.44273], [4.92815, 51.43856], [4.92879, 51.44161], [4.93544, 51.44634], [4.94025, 51.44193], [4.93416, 51.44185], [4.93471, 51.43861], [4.94265, 51.44003], [4.93986, 51.43064], [4.92952, 51.42984], [4.92652, 51.43329], [4.91493, 51.4353]]]] } },
22538     { type: "Feature", properties: { wikidata: "Q782", nameEn: "Hawaii", aliases: ["US-HI"], country: "US", groups: ["Q35657", "061", "009", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-177.8563, 29.18961], [-179.49839, 27.86265], [-151.6784, 9.55515], [-154.05867, 45.51124], [-177.5224, 27.7635], [-177.8563, 29.18961]]]] } },
22539     { type: "Feature", properties: { wikidata: "Q797", nameEn: "Alaska", aliases: ["US-AK"], country: "US", groups: ["Q35657", "021", "003", "019", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169.34848, 52.47228], [180, 51.0171], [179.84401, 55.10087], [169.34848, 52.47228]]], [[[-168.95635, 65.98512], [-169.03888, 65.48473], [-172.76104, 63.77445], [-179.55295, 57.62081], [-179.55295, 50.81807], [-133.92876, 54.62289], [-130.61931, 54.70835], [-130.64499, 54.76912], [-130.44184, 54.85377], [-130.27203, 54.97174], [-130.18765, 55.07744], [-130.08035, 55.21556], [-129.97513, 55.28029], [-130.15373, 55.74895], [-130.00857, 55.91344], [-130.00093, 56.00325], [-130.10173, 56.12178], [-130.33965, 56.10849], [-130.77769, 56.36185], [-131.8271, 56.62247], [-133.38523, 58.42773], [-133.84645, 58.73543], [-134.27175, 58.8634], [-134.48059, 59.13231], [-134.55699, 59.1297], [-134.7047, 59.2458], [-135.00267, 59.28745], [-135.03069, 59.56208], [-135.48007, 59.79937], [-136.31566, 59.59083], [-136.22381, 59.55526], [-136.33727, 59.44466], [-136.47323, 59.46617], [-136.52365, 59.16752], [-136.82619, 59.16198], [-137.4925, 58.89415], [-137.60623, 59.24465], [-138.62145, 59.76431], [-138.71149, 59.90728], [-139.05365, 59.99655], [-139.20603, 60.08896], [-139.05831, 60.35205], [-139.68991, 60.33693], [-139.98024, 60.18027], [-140.45648, 60.30919], [-140.5227, 60.22077], [-141.00116, 60.30648], [-140.97446, 84.39275], [-168.25765, 71.99091], [-168.95635, 65.98512]]]] } },
22540     { type: "Feature", properties: { wikidata: "Q3492", nameEn: "Sumatra", aliases: ["ID-SM"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[109.82788, 2.86812], [110.90339, 7.52694], [105.01437, 3.24936], [104.56723, 1.44271], [104.34728, 1.33529], [104.12282, 1.27714], [104.03085, 1.26954], [103.74084, 1.12902], [103.66049, 1.18825], [103.56591, 1.19719], [103.03657, 1.30383], [96.11174, 6.69841], [74.28481, -3.17525], [102.92489, -8.17146], [106.32259, -5.50116], [106.38511, -5.16715], [109.17017, -4.07401], [109.3962, -2.07276], [108.50935, -2.01066], [107.94791, 1.06924], [109.82788, 2.86812]]]] } },
22541     { type: "Feature", properties: { wikidata: "Q3757", nameEn: "Java", aliases: ["ID-JW"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[109.17017, -4.07401], [106.38511, -5.16715], [106.32259, -5.50116], [102.92489, -8.17146], [116.22542, -10.49172], [114.39575, -8.2889], [114.42235, -8.09762], [114.92859, -7.49253], [116.33992, -7.56171], [116.58433, -5.30385], [109.17017, -4.07401]]]] } },
22542     { type: "Feature", properties: { wikidata: "Q3795", nameEn: "Kalimantan", aliases: ["ID-KA"], country: "ID", groups: ["Q36117", "035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[120.02464, 2.83703], [118.06469, 4.16638], [117.67641, 4.16535], [117.47313, 4.18857], [117.25801, 4.35108], [115.90217, 4.37708], [115.58276, 3.93499], [115.53713, 3.14776], [115.11343, 2.82879], [115.1721, 2.49671], [114.80706, 2.21665], [114.80706, 1.92351], [114.57892, 1.5], [114.03788, 1.44787], [113.64677, 1.23933], [113.01448, 1.42832], [113.021, 1.57819], [112.48648, 1.56516], [112.2127, 1.44135], [112.15679, 1.17004], [111.94553, 1.12016], [111.82846, 0.99349], [111.55434, 0.97864], [111.22979, 1.08326], [110.62374, 0.873], [110.49182, 0.88088], [110.35354, 0.98869], [109.66397, 1.60425], [109.66397, 1.79972], [109.57923, 1.80624], [109.53794, 1.91771], [109.62558, 1.99182], [109.82788, 2.86812], [107.94791, 1.06924], [108.50935, -2.01066], [109.3962, -2.07276], [109.17017, -4.07401], [116.58433, -5.30385], [120.02464, 2.83703]]]] } },
22543     { type: "Feature", properties: { wikidata: "Q3803", nameEn: "Lesser Sunda Islands", aliases: ["ID-NU"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[116.96967, -8.01483], [114.92859, -7.49253], [114.42235, -8.09762], [114.39575, -8.2889], [116.22542, -10.49172], [122.14954, -11.52517], [125.68138, -9.85176], [125.09025, -9.46406], [124.97892, -9.19281], [125.04044, -9.17093], [125.09434, -9.19669], [125.18907, -9.16434], [125.18632, -9.03142], [125.11764, -8.96359], [124.97742, -9.08128], [124.94011, -8.85617], [124.46701, -9.13002], [124.45971, -9.30263], [124.38554, -9.3582], [124.35258, -9.43002], [124.3535, -9.48493], [124.28115, -9.50453], [124.28115, -9.42189], [124.21247, -9.36904], [124.14517, -9.42324], [124.10539, -9.41206], [124.04286, -9.34243], [124.04628, -9.22671], [124.33472, -9.11416], [124.92337, -8.75859], [125.87688, -7.49892], [116.96967, -8.01483]]]] } },
22544     { type: "Feature", properties: { wikidata: "Q3812", nameEn: "Sulawesi", aliases: ["ID-SL"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[128.34321, 3.90322], [126.69413, 6.02692], [119.56457, 0.90759], [116.58433, -5.30385], [116.33992, -7.56171], [116.96967, -8.01483], [125.87688, -7.49892], [123.78965, -0.86805], [128.34321, 3.90322]]]] } },
22545     { type: "Feature", properties: { wikidata: "Q3827", nameEn: "Maluku Islands", aliases: ["ID-ML"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[129.63187, 2.21409], [128.34321, 3.90322], [123.78965, -0.86805], [125.87688, -7.49892], [125.58506, -7.95311], [125.87691, -8.31789], [127.42116, -8.22471], [127.55165, -9.05052], [135.49042, -9.2276], [135.35517, -5.01442], [132.8312, -4.70282], [130.8468, -2.61103], [128.40647, -2.30349], [129.71519, -0.24692], [129.63187, 2.21409]]]] } },
22546     { type: "Feature", properties: { wikidata: "Q3845", nameEn: "Western New Guinea", aliases: ["ID-PP"], country: "ID", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["62"] }, geometry: { type: "MultiPolygon", coordinates: [[[[135.49042, -9.2276], [141.01842, -9.35091], [141.01763, -6.90181], [140.90448, -6.85033], [140.85295, -6.72996], [140.99813, -6.3233], [141.02352, 0.08993], [129.63187, 2.21409], [129.71519, -0.24692], [128.40647, -2.30349], [130.8468, -2.61103], [132.8312, -4.70282], [135.35517, -5.01442], [135.49042, -9.2276]]]] } },
22547     { type: "Feature", properties: { wikidata: "Q5765", nameEn: "Balearic Islands", aliases: ["ES-IB"], country: "ES", groups: ["EU", "039", "150", "UN"], callingCodes: ["34 971"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.27707, 35.35051], [5.10072, 39.89531], [3.75438, 42.33445], [-2.27707, 35.35051]]]] } },
22548     { type: "Feature", properties: { wikidata: "Q5823", nameEn: "Ceuta", aliases: ["ES-CE"], country: "ES", groups: ["EA", "EU", "015", "002", "UN"], level: "subterritory", callingCodes: ["34"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-5.38491, 35.92591], [-5.37338, 35.88417], [-5.35844, 35.87375], [-5.34379, 35.8711], [-5.21179, 35.90091], [-5.38491, 35.92591]]]] } },
22549     { type: "Feature", properties: { wikidata: "Q5831", nameEn: "Melilla", aliases: ["ES-ML"], country: "ES", groups: ["EA", "EU", "015", "002", "UN"], level: "subterritory", callingCodes: ["34"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.91909, 35.33927], [-2.96038, 35.31609], [-2.96648, 35.30475], [-2.96978, 35.29459], [-2.97035, 35.28852], [-2.96507, 35.28801], [-2.96826, 35.28296], [-2.96516, 35.27967], [-2.95431, 35.2728], [-2.95065, 35.26576], [-2.93893, 35.26737], [-2.92272, 35.27509], [-2.91909, 35.33927]]]] } },
22550     { type: "Feature", properties: { wikidata: "Q7835", nameEn: "Crimea", country: "RU", groups: ["151", "150", "UN"], level: "subterritory", callingCodes: ["7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.5, 44], [36.4883, 45.0488], [36.475, 45.2411], [36.5049, 45.3136], [36.6545, 45.3417], [36.6645, 45.4514], [35.0498, 45.7683], [34.9601, 45.7563], [34.7991, 45.8101], [34.8015, 45.9005], [34.7548, 45.907], [34.6668, 45.9714], [34.6086, 45.9935], [34.5589, 45.9935], [34.5201, 45.951], [34.4873, 45.9427], [34.4415, 45.9599], [34.4122, 46.0025], [34.3391, 46.0611], [34.2511, 46.0532], [34.181, 46.068], [34.1293, 46.1049], [34.0731, 46.1177], [34.0527, 46.1084], [33.9155, 46.1594], [33.8523, 46.1986], [33.7972, 46.2048], [33.7405, 46.1855], [33.646, 46.2303], [33.6152, 46.2261], [33.6385, 46.1415], [33.6147, 46.1356], [33.5732, 46.1032], [33.5909, 46.0601], [33.5597, 46.0307], [31.5, 45.5], [33.5, 44]]]] } },
22551     { type: "Feature", properties: { wikidata: "Q12837", nameEn: "Iberia", level: "sharedLandform" }, geometry: null },
22552     { type: "Feature", properties: { wikidata: "Q14056", nameEn: "Jan Mayen", aliases: ["NO-22"], country: "NO", groups: ["SJ", "154", "150", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[-9.18243, 72.23144], [-10.71459, 70.09565], [-5.93364, 70.76368], [-9.18243, 72.23144]]]] } },
22553     { type: "Feature", properties: { wikidata: "Q19188", nameEn: "Mainland China", country: "CN", groups: ["030", "142", "UN"], callingCodes: ["86"] }, geometry: { type: "MultiPolygon", coordinates: [[[[125.6131, 53.07229], [125.17522, 53.20225], [124.46078, 53.21881], [123.86158, 53.49391], [123.26989, 53.54843], [122.85966, 53.47395], [122.35063, 53.49565], [121.39213, 53.31888], [120.85633, 53.28499], [120.0451, 52.7359], [120.04049, 52.58773], [120.46454, 52.63811], [120.71673, 52.54099], [120.61346, 52.32447], [120.77337, 52.20805], [120.65907, 51.93544], [120.10963, 51.671], [119.13553, 50.37412], [119.38598, 50.35162], [119.27996, 50.13348], [119.11003, 50.00276], [118.61623, 49.93809], [117.82343, 49.52696], [117.48208, 49.62324], [117.27597, 49.62544], [116.71193, 49.83813], [116.03781, 48.87014], [116.06565, 48.81716], [115.78876, 48.51781], [115.811, 48.25699], [115.52082, 48.15367], [115.57128, 47.91988], [115.94296, 47.67741], [116.21879, 47.88505], [116.4465, 47.83662], [116.67405, 47.89039], [116.9723, 47.87285], [117.37875, 47.63627], [117.50181, 47.77216], [117.80196, 48.01661], [118.03676, 48.00982], [118.11009, 48.04], [118.22677, 48.03853], [118.29654, 48.00246], [118.55766, 47.99277], [118.7564, 47.76947], [119.12343, 47.66458], [119.13995, 47.53997], [119.35892, 47.48104], [119.31964, 47.42617], [119.54918, 47.29505], [119.56019, 47.24874], [119.62403, 47.24575], [119.71209, 47.19192], [119.85518, 46.92196], [119.91242, 46.90091], [119.89261, 46.66423], [119.80455, 46.67631], [119.77373, 46.62947], [119.68127, 46.59015], [119.65265, 46.62342], [119.42827, 46.63783], [119.32827, 46.61433], [119.24978, 46.64761], [119.10448, 46.65516], [119.00541, 46.74273], [118.92616, 46.72765], [118.89974, 46.77139], [118.8337, 46.77742], [118.78747, 46.68689], [118.30534, 46.73519], [117.69554, 46.50991], [117.60748, 46.59771], [117.41782, 46.57862], [117.36609, 46.36335], [116.83166, 46.38637], [116.75551, 46.33083], [116.58612, 46.30211], [116.26678, 45.96479], [116.24012, 45.8778], [116.27366, 45.78637], [116.16989, 45.68603], [115.60329, 45.44717], [114.94546, 45.37377], [114.74612, 45.43585], [114.54801, 45.38337], [114.5166, 45.27189], [113.70918, 44.72891], [112.74662, 44.86297], [112.4164, 45.06858], [111.98695, 45.09074], [111.76275, 44.98032], [111.40498, 44.3461], [111.96289, 43.81596], [111.93776, 43.68709], [111.79758, 43.6637], [111.59087, 43.51207], [111.0149, 43.3289], [110.4327, 42.78293], [110.08401, 42.6411], [109.89402, 42.63111], [109.452, 42.44842], [109.00679, 42.45302], [108.84489, 42.40246], [107.57258, 42.40898], [107.49681, 42.46221], [107.29755, 42.41395], [107.24774, 42.36107], [106.76517, 42.28741], [105.0123, 41.63188], [104.51667, 41.66113], [104.52258, 41.8706], [103.92804, 41.78246], [102.72403, 42.14675], [102.07645, 42.22519], [101.80515, 42.50074], [100.84979, 42.67087], [100.33297, 42.68231], [99.50671, 42.56535], [97.1777, 42.7964], [96.37926, 42.72055], [96.35658, 42.90363], [95.89543, 43.2528], [95.52594, 43.99353], [95.32891, 44.02407], [95.39772, 44.2805], [95.01191, 44.25274], [94.71959, 44.35284], [94.10003, 44.71016], [93.51161, 44.95964], [91.64048, 45.07408], [90.89169, 45.19667], [90.65114, 45.49314], [90.70907, 45.73437], [91.03026, 46.04194], [90.99672, 46.14207], [90.89639, 46.30711], [91.07696, 46.57315], [91.0147, 46.58171], [91.03649, 46.72916], [90.84035, 46.99525], [90.76108, 46.99399], [90.48542, 47.30438], [90.48854, 47.41826], [90.33598, 47.68303], [90.10871, 47.7375], [90.06512, 47.88177], [89.76624, 47.82745], [89.55453, 48.0423], [89.0711, 47.98528], [88.93186, 48.10263], [88.8011, 48.11302], [88.58316, 48.21893], [88.58939, 48.34531], [87.96361, 48.58478], [88.0788, 48.71436], [87.73822, 48.89582], [87.88171, 48.95853], [87.81333, 49.17354], [87.48983, 49.13794], [87.478, 49.07403], [87.28386, 49.11626], [86.87238, 49.12432], [86.73568, 48.99918], [86.75343, 48.70331], [86.38069, 48.46064], [85.73581, 48.3939], [85.5169, 48.05493], [85.61067, 47.49753], [85.69696, 47.2898], [85.54294, 47.06171], [85.22443, 47.04816], [84.93995, 46.87399], [84.73077, 47.01394], [83.92184, 46.98912], [83.04622, 47.19053], [82.21792, 45.56619], [82.58474, 45.40027], [82.51374, 45.1755], [81.73278, 45.3504], [80.11169, 45.03352], [79.8987, 44.89957], [80.38384, 44.63073], [80.40229, 44.23319], [80.40031, 44.10986], [80.75156, 43.44948], [80.69718, 43.32589], [80.77771, 43.30065], [80.78817, 43.14235], [80.62913, 43.141], [80.3735, 43.01557], [80.58999, 42.9011], [80.38169, 42.83142], [80.26886, 42.8366], [80.16892, 42.61137], [80.26841, 42.23797], [80.17807, 42.21166], [80.17842, 42.03211], [79.92977, 42.04113], [78.3732, 41.39603], [78.15757, 41.38565], [78.12873, 41.23091], [77.81287, 41.14307], [77.76206, 41.01574], [77.52723, 41.00227], [77.3693, 41.0375], [77.28004, 41.0033], [76.99302, 41.0696], [76.75681, 40.95354], [76.5261, 40.46114], [76.33659, 40.3482], [75.96168, 40.38064], [75.91361, 40.2948], [75.69663, 40.28642], [75.5854, 40.66874], [75.22834, 40.45382], [75.08243, 40.43945], [74.82013, 40.52197], [74.78168, 40.44886], [74.85996, 40.32857], [74.69875, 40.34668], [74.35063, 40.09742], [74.25533, 40.13191], [73.97049, 40.04378], [73.83006, 39.76136], [73.9051, 39.75073], [73.92354, 39.69565], [73.94683, 39.60733], [73.87018, 39.47879], [73.59831, 39.46425], [73.59241, 39.40843], [73.5004, 39.38402], [73.55396, 39.3543], [73.54572, 39.27567], [73.60638, 39.24534], [73.75823, 39.023], [73.81728, 39.04007], [73.82964, 38.91517], [73.7445, 38.93867], [73.7033, 38.84782], [73.80656, 38.66449], [73.79806, 38.61106], [73.97933, 38.52945], [74.17022, 38.65504], [74.51217, 38.47034], [74.69619, 38.42947], [74.69894, 38.22155], [74.80331, 38.19889], [74.82665, 38.07359], [74.9063, 38.03033], [74.92416, 37.83428], [75.00935, 37.77486], [74.8912, 37.67576], [74.94338, 37.55501], [75.06011, 37.52779], [75.15899, 37.41443], [75.09719, 37.37297], [75.12328, 37.31839], [74.88887, 37.23275], [74.80605, 37.21565], [74.49981, 37.24518], [74.56453, 37.03023], [75.13839, 37.02622], [75.40481, 36.95382], [75.45562, 36.71971], [75.72737, 36.7529], [75.92391, 36.56986], [76.0324, 36.41198], [76.00906, 36.17511], [75.93028, 36.13136], [76.15325, 35.9264], [76.14913, 35.82848], [76.33453, 35.84296], [76.50961, 35.8908], [76.77323, 35.66062], [76.84539, 35.67356], [76.96624, 35.5932], [77.44277, 35.46132], [77.70232, 35.46244], [77.80532, 35.52058], [78.11664, 35.48022], [78.03466, 35.3785], [78.00033, 35.23954], [78.22692, 34.88771], [78.18435, 34.7998], [78.27781, 34.61484], [78.54964, 34.57283], [78.56475, 34.50835], [78.74465, 34.45174], [79.05364, 34.32482], [78.99802, 34.3027], [78.91769, 34.15452], [78.66225, 34.08858], [78.65657, 34.03195], [78.73367, 34.01121], [78.77349, 33.73871], [78.67599, 33.66445], [78.73636, 33.56521], [79.15252, 33.17156], [79.14016, 33.02545], [79.46562, 32.69668], [79.26768, 32.53277], [79.13174, 32.47766], [79.0979, 32.38051], [78.99322, 32.37948], [78.96713, 32.33655], [78.7831, 32.46873], [78.73916, 32.69438], [78.38897, 32.53938], [78.4645, 32.45367], [78.49609, 32.2762], [78.68754, 32.10256], [78.74404, 32.00384], [78.78036, 31.99478], [78.69933, 31.78723], [78.84516, 31.60631], [78.71032, 31.50197], [78.77898, 31.31209], [78.89344, 31.30481], [79.01931, 31.42817], [79.14016, 31.43403], [79.30694, 31.17357], [79.59884, 30.93943], [79.93255, 30.88288], [80.20721, 30.58541], [80.54504, 30.44936], [80.83343, 30.32023], [81.03953, 30.20059], [81.12842, 30.01395], [81.24362, 30.0126], [81.29032, 30.08806], [81.2623, 30.14596], [81.33355, 30.15303], [81.39928, 30.21862], [81.41018, 30.42153], [81.5459, 30.37688], [81.62033, 30.44703], [81.99082, 30.33423], [82.10135, 30.35439], [82.10757, 30.23745], [82.19475, 30.16884], [82.16984, 30.0692], [82.38622, 30.02608], [82.5341, 29.9735], [82.73024, 29.81695], [83.07116, 29.61957], [83.28131, 29.56813], [83.44787, 29.30513], [83.63156, 29.16249], [83.82303, 29.30513], [83.97559, 29.33091], [84.18107, 29.23451], [84.24801, 29.02783], [84.2231, 28.89571], [84.47528, 28.74023], [84.62317, 28.73887], [84.85511, 28.58041], [85.06059, 28.68562], [85.19135, 28.62825], [85.18668, 28.54076], [85.10729, 28.34092], [85.38127, 28.28336], [85.4233, 28.32996], [85.59765, 28.30529], [85.60854, 28.25045], [85.69105, 28.38475], [85.71907, 28.38064], [85.74864, 28.23126], [85.84672, 28.18187], [85.90743, 28.05144], [85.97813, 27.99023], [85.94946, 27.9401], [86.06309, 27.90021], [86.12069, 27.93047], [86.08333, 28.02121], [86.088, 28.09264], [86.18607, 28.17364], [86.22966, 27.9786], [86.42736, 27.91122], [86.51609, 27.96623], [86.56265, 28.09569], [86.74181, 28.10638], [86.75582, 28.04182], [87.03757, 27.94835], [87.11696, 27.84104], [87.56996, 27.84517], [87.72718, 27.80938], [87.82681, 27.95248], [88.13378, 27.88015], [88.1278, 27.95417], [88.25332, 27.9478], [88.54858, 28.06057], [88.63235, 28.12356], [88.83559, 28.01936], [88.88091, 27.85192], [88.77517, 27.45415], [88.82981, 27.38814], [88.91901, 27.32483], [88.93678, 27.33777], [88.96947, 27.30319], [89.00216, 27.32532], [88.95355, 27.4106], [88.97213, 27.51671], [89.0582, 27.60985], [89.12825, 27.62502], [89.59525, 28.16433], [89.79762, 28.23979], [90.13387, 28.19178], [90.58842, 28.02838], [90.69894, 28.07784], [91.20019, 27.98715], [91.25779, 28.07509], [91.46327, 28.0064], [91.48973, 27.93903], [91.5629, 27.84823], [91.6469, 27.76358], [91.84722, 27.76325], [91.87057, 27.7195], [92.27432, 27.89077], [92.32101, 27.79363], [92.42538, 27.80092], [92.7275, 27.98662], [92.73025, 28.05814], [92.65472, 28.07632], [92.67486, 28.15018], [92.93075, 28.25671], [93.14635, 28.37035], [93.18069, 28.50319], [93.44621, 28.67189], [93.72797, 28.68821], [94.35897, 29.01965], [94.2752, 29.11687], [94.69318, 29.31739], [94.81353, 29.17804], [95.0978, 29.14446], [95.11291, 29.09527], [95.2214, 29.10727], [95.26122, 29.07727], [95.3038, 29.13847], [95.41091, 29.13007], [95.50842, 29.13487], [95.72086, 29.20797], [95.75149, 29.32063], [95.84899, 29.31464], [96.05361, 29.38167], [96.31316, 29.18643], [96.18682, 29.11087], [96.20467, 29.02325], [96.3626, 29.10607], [96.61391, 28.72742], [96.40929, 28.51526], [96.48895, 28.42955], [96.6455, 28.61657], [96.85561, 28.4875], [96.88445, 28.39452], [96.98882, 28.32564], [97.1289, 28.3619], [97.34547, 28.21385], [97.41729, 28.29783], [97.47085, 28.2688], [97.50518, 28.49716], [97.56835, 28.55628], [97.70705, 28.5056], [97.79632, 28.33168], [97.90069, 28.3776], [98.15337, 28.12114], [98.13964, 27.9478], [98.32641, 27.51385], [98.42529, 27.55404], [98.43353, 27.67086], [98.69582, 27.56499], [98.7333, 26.85615], [98.77547, 26.61994], [98.72741, 26.36183], [98.67797, 26.24487], [98.7329, 26.17218], [98.66884, 26.09165], [98.63128, 26.15492], [98.57085, 26.11547], [98.60763, 26.01512], [98.70818, 25.86241], [98.63128, 25.79937], [98.54064, 25.85129], [98.40606, 25.61129], [98.31268, 25.55307], [98.25774, 25.6051], [98.16848, 25.62739], [98.18084, 25.56298], [98.12591, 25.50722], [98.14925, 25.41547], [97.92541, 25.20815], [97.83614, 25.2715], [97.77023, 25.11492], [97.72216, 25.08508], [97.72903, 24.91332], [97.79949, 24.85655], [97.76481, 24.8289], [97.73127, 24.83015], [97.70181, 24.84557], [97.64354, 24.79171], [97.56648, 24.76475], [97.56383, 24.75535], [97.5542, 24.74943], [97.54675, 24.74202], [97.56525, 24.72838], [97.56286, 24.54535], [97.52757, 24.43748], [97.60029, 24.4401], [97.66998, 24.45288], [97.7098, 24.35658], [97.65624, 24.33781], [97.66723, 24.30027], [97.71941, 24.29652], [97.76799, 24.26365], [97.72998, 24.2302], [97.72799, 24.18883], [97.75305, 24.16902], [97.72903, 24.12606], [97.62363, 24.00506], [97.5247, 23.94032], [97.64667, 23.84574], [97.72302, 23.89288], [97.79456, 23.94836], [97.79416, 23.95663], [97.84328, 23.97603], [97.86545, 23.97723], [97.88811, 23.97446], [97.8955, 23.97758], [97.89676, 23.97931], [97.89683, 23.98389], [97.88814, 23.98605], [97.88414, 23.99405], [97.88616, 24.00463], [97.90998, 24.02094], [97.93951, 24.01953], [97.98691, 24.03897], [97.99583, 24.04932], [98.04709, 24.07616], [98.05302, 24.07408], [98.05671, 24.07961], [98.0607, 24.07812], [98.06703, 24.08028], [98.07806, 24.07988], [98.20666, 24.11406], [98.54476, 24.13119], [98.59256, 24.08371], [98.85319, 24.13042], [98.87998, 24.15624], [98.89632, 24.10612], [98.67797, 23.9644], [98.68209, 23.80492], [98.79607, 23.77947], [98.82933, 23.72921], [98.81775, 23.694], [98.88396, 23.59555], [98.80294, 23.5345], [98.82877, 23.47908], [98.87683, 23.48995], [98.92104, 23.36946], [98.87573, 23.33038], [98.93958, 23.31414], [98.92515, 23.29535], [98.88597, 23.18656], [99.05975, 23.16382], [99.04601, 23.12215], [99.25741, 23.09025], [99.34127, 23.13099], [99.52214, 23.08218], [99.54218, 22.90014], [99.43537, 22.94086], [99.45654, 22.85726], [99.31243, 22.73893], [99.38247, 22.57544], [99.37972, 22.50188], [99.28771, 22.4105], [99.17318, 22.18025], [99.19176, 22.16983], [99.1552, 22.15874], [99.33166, 22.09656], [99.47585, 22.13345], [99.85351, 22.04183], [99.96612, 22.05965], [99.99084, 21.97053], [99.94003, 21.82782], [99.98654, 21.71064], [100.04956, 21.66843], [100.12679, 21.70539], [100.17486, 21.65306], [100.10757, 21.59945], [100.12542, 21.50365], [100.1625, 21.48704], [100.18447, 21.51898], [100.25863, 21.47043], [100.35201, 21.53176], [100.42892, 21.54325], [100.4811, 21.46148], [100.57861, 21.45637], [100.72143, 21.51898], [100.87265, 21.67396], [101.11744, 21.77659], [101.15156, 21.56129], [101.2124, 21.56422], [101.19349, 21.41959], [101.26912, 21.36482], [101.2229, 21.23271], [101.29326, 21.17254], [101.54563, 21.25668], [101.6068, 21.23329], [101.59491, 21.18621], [101.60886, 21.17947], [101.66977, 21.20004], [101.70548, 21.14911], [101.7622, 21.14813], [101.79266, 21.19025], [101.76745, 21.21571], [101.83887, 21.20983], [101.84412, 21.25291], [101.74014, 21.30967], [101.74224, 21.48276], [101.7727, 21.51794], [101.7475, 21.5873], [101.80001, 21.57461], [101.83257, 21.61562], [101.74555, 21.72852], [101.7791, 21.83019], [101.62566, 21.96574], [101.57525, 22.13026], [101.60675, 22.13513], [101.53638, 22.24794], [101.56789, 22.28876], [101.61306, 22.27515], [101.68973, 22.46843], [101.7685, 22.50337], [101.86828, 22.38397], [101.90714, 22.38688], [101.91344, 22.44417], [101.98487, 22.42766], [102.03633, 22.46164], [102.1245, 22.43372], [102.14099, 22.40092], [102.16621, 22.43336], [102.26428, 22.41321], [102.25339, 22.4607], [102.41061, 22.64184], [102.38415, 22.67919], [102.42618, 22.69212], [102.46665, 22.77108], [102.51802, 22.77969], [102.57095, 22.7036], [102.60675, 22.73376], [102.8636, 22.60735], [102.9321, 22.48659], [103.0722, 22.44775], [103.07843, 22.50097], [103.17961, 22.55705], [103.15782, 22.59873], [103.18895, 22.64471], [103.28079, 22.68063], [103.32282, 22.8127], [103.43179, 22.75816], [103.43646, 22.70648], [103.52675, 22.59155], [103.57812, 22.65764], [103.56255, 22.69499], [103.64506, 22.79979], [103.87904, 22.56683], [103.93286, 22.52703], [103.94513, 22.52553], [103.95191, 22.5134], [103.96352, 22.50584], [103.96783, 22.51173], [103.97384, 22.50634], [103.99247, 22.51958], [104.01088, 22.51823], [104.03734, 22.72945], [104.11384, 22.80363], [104.27084, 22.8457], [104.25683, 22.76534], [104.35593, 22.69353], [104.47225, 22.75813], [104.58122, 22.85571], [104.60457, 22.81841], [104.65283, 22.83419], [104.72755, 22.81984], [104.77114, 22.90017], [104.84942, 22.93631], [104.86765, 22.95178], [104.8334, 23.01484], [104.79478, 23.12934], [104.87382, 23.12854], [104.87992, 23.17141], [104.91435, 23.18666], [104.9486, 23.17235], [104.96532, 23.20463], [104.98712, 23.19176], [105.07002, 23.26248], [105.11672, 23.25247], [105.17276, 23.28679], [105.22569, 23.27249], [105.32376, 23.39684], [105.40782, 23.28107], [105.42805, 23.30824], [105.49966, 23.20669], [105.56037, 23.16806], [105.57594, 23.075], [105.72382, 23.06641], [105.8726, 22.92756], [105.90119, 22.94168], [105.99568, 22.94178], [106.00179, 22.99049], [106.19705, 22.98475], [106.27022, 22.87722], [106.34961, 22.86718], [106.49749, 22.91164], [106.51306, 22.94891], [106.55976, 22.92311], [106.60179, 22.92884], [106.6516, 22.86862], [106.6734, 22.89587], [106.71387, 22.88296], [106.71128, 22.85982], [106.78422, 22.81532], [106.81271, 22.8226], [106.83685, 22.8098], [106.82404, 22.7881], [106.76293, 22.73491], [106.72321, 22.63606], [106.71698, 22.58432], [106.65316, 22.5757], [106.61269, 22.60301], [106.58395, 22.474], [106.55665, 22.46498], [106.57221, 22.37], [106.55976, 22.34841], [106.6516, 22.33977], [106.69986, 22.22309], [106.67495, 22.1885], [106.6983, 22.15102], [106.70142, 22.02409], [106.68274, 21.99811], [106.69276, 21.96013], [106.72551, 21.97923], [106.74345, 22.00965], [106.81038, 21.97934], [106.9178, 21.97357], [106.92714, 21.93459], [106.97228, 21.92592], [106.99252, 21.95191], [107.05634, 21.92303], [107.06101, 21.88982], [107.00964, 21.85948], [107.02615, 21.81981], [107.10771, 21.79879], [107.20734, 21.71493], [107.24625, 21.7077], [107.29296, 21.74674], [107.35834, 21.6672], [107.35989, 21.60063], [107.38636, 21.59774], [107.41593, 21.64839], [107.47197, 21.6672], [107.49532, 21.62958], [107.49065, 21.59774], [107.54047, 21.5934], [107.56537, 21.61945], [107.66967, 21.60787], [107.80355, 21.66141], [107.86114, 21.65128], [107.90006, 21.5905], [107.92652, 21.58906], [107.95232, 21.5388], [107.96774, 21.53601], [107.97074, 21.54072], [107.97383, 21.53961], [107.97932, 21.54503], [108.02926, 21.54997], [108.0569, 21.53604], [108.10003, 21.47338], [108.00365, 17.98159], [111.60491, 13.57105], [118.41371, 24.06775], [118.11703, 24.39734], [118.28244, 24.51231], [118.35291, 24.51645], [118.42453, 24.54644], [118.6333, 24.46259], [119.42295, 25.0886], [119.98511, 25.37624], [119.78816, 26.2348], [120.0693, 26.3959], [120.5128, 26.536], [121.03532, 26.8787], [123.5458, 31.01942], [122.29378, 31.76513], [122.80525, 33.30571], [123.85601, 37.49093], [123.90497, 38.79949], [124.17532, 39.8232], [124.23201, 39.9248], [124.35029, 39.95639], [124.37089, 40.03004], [124.3322, 40.05573], [124.38556, 40.11047], [124.40719, 40.13655], [124.86913, 40.45387], [125.71172, 40.85223], [125.76869, 40.87908], [126.00335, 40.92835], [126.242, 41.15454], [126.53189, 41.35206], [126.60631, 41.65565], [126.90729, 41.79955], [127.17841, 41.59714], [127.29712, 41.49473], [127.92943, 41.44291], [128.02633, 41.42103], [128.03311, 41.39232], [128.12967, 41.37931], [128.18546, 41.41279], [128.20061, 41.40895], [128.30716, 41.60322], [128.15119, 41.74568], [128.04487, 42.01769], [128.94007, 42.03537], [128.96068, 42.06657], [129.15178, 42.17224], [129.22285, 42.26491], [129.22423, 42.3553], [129.28541, 42.41574], [129.42882, 42.44702], [129.54701, 42.37254], [129.60482, 42.44461], [129.72541, 42.43739], [129.75294, 42.59409], [129.77183, 42.69435], [129.7835, 42.76521], [129.80719, 42.79218], [129.83277, 42.86746], [129.85261, 42.96494], [129.8865, 43.00395], [129.95082, 43.01051], [129.96409, 42.97306], [130.12957, 42.98361], [130.09764, 42.91425], [130.26095, 42.9027], [130.23068, 42.80125], [130.2385, 42.71127], [130.41826, 42.6011], [130.44361, 42.54849], [130.50123, 42.61636], [130.55143, 42.52158], [130.62107, 42.58413], [130.56576, 42.68925], [130.40213, 42.70788], [130.44361, 42.76205], [130.66524, 42.84753], [131.02438, 42.86518], [131.02668, 42.91246], [131.135, 42.94114], [131.10274, 43.04734], [131.20414, 43.13654], [131.19031, 43.21385], [131.30324, 43.39498], [131.29402, 43.46695], [131.19492, 43.53047], [131.21105, 43.82383], [131.26176, 43.94011], [131.23583, 43.96085], [131.25484, 44.03131], [131.30365, 44.04262], [131.1108, 44.70266], [130.95639, 44.85154], [131.48415, 44.99513], [131.68466, 45.12374], [131.66852, 45.2196], [131.76532, 45.22609], [131.86903, 45.33636], [131.99417, 45.2567], [132.83978, 45.05916], [132.96373, 45.0212], [133.12293, 45.1332], [133.09279, 45.25693], [133.19419, 45.51913], [133.41083, 45.57723], [133.48457, 45.86203], [133.60442, 45.90053], [133.67569, 45.9759], [133.72695, 46.05576], [133.68047, 46.14697], [133.88097, 46.25066], [133.91496, 46.4274], [133.84104, 46.46681], [134.03538, 46.75668], [134.20016, 47.33458], [134.50898, 47.4812], [134.7671, 47.72051], [134.55508, 47.98651], [134.67098, 48.1564], [134.75328, 48.36763], [134.49516, 48.42884], [132.66989, 47.96491], [132.57309, 47.71741], [131.90448, 47.68011], [131.2635, 47.73325], [131.09871, 47.6852], [130.95985, 47.6957], [130.90915, 47.90623], [130.65103, 48.10052], [130.84462, 48.30942], [130.52147, 48.61745], [130.66946, 48.88251], [130.43232, 48.90844], [130.2355, 48.86741], [129.85416, 49.11067], [129.67598, 49.29596], [129.50685, 49.42398], [129.40398, 49.44194], [129.35317, 49.3481], [129.23232, 49.40353], [129.11153, 49.36813], [128.72896, 49.58676], [127.83476, 49.5748], [127.53516, 49.84306], [127.49299, 50.01251], [127.60515, 50.23503], [127.37384, 50.28393], [127.36009, 50.43787], [127.28765, 50.46585], [127.36335, 50.58306], [127.28165, 50.72075], [127.14586, 50.91152], [126.93135, 51.0841], [126.90369, 51.3238], [126.68349, 51.70607], [126.44606, 51.98254], [126.558, 52.13738], [125.6131, 53.07229]], [[113.56865, 22.20973], [113.57123, 22.20416], [113.60504, 22.20464], [113.63011, 22.10782], [113.57191, 22.07696], [113.54839, 22.10909], [113.54942, 22.14519], [113.54093, 22.15497], [113.52659, 22.18271], [113.53552, 22.20607], [113.53301, 22.21235], [113.53591, 22.21369], [113.54093, 22.21314], [113.54333, 22.21688], [113.5508, 22.21672], [113.56865, 22.20973]], [[114.50148, 22.15017], [113.92195, 22.13873], [113.83338, 22.1826], [113.81621, 22.2163], [113.86771, 22.42972], [114.03113, 22.5065], [114.05438, 22.5026], [114.05729, 22.51104], [114.06272, 22.51617], [114.07267, 22.51855], [114.07817, 22.52997], [114.08606, 22.53276], [114.09048, 22.53716], [114.09692, 22.53435], [114.1034, 22.5352], [114.11181, 22.52878], [114.11656, 22.53415], [114.12665, 22.54003], [114.13823, 22.54319], [114.1482, 22.54091], [114.15123, 22.55163], [114.1597, 22.56041], [114.17247, 22.55944], [114.18338, 22.55444], [114.20655, 22.55706], [114.22185, 22.55343], [114.22888, 22.5436], [114.25154, 22.55977], [114.44998, 22.55977], [114.50148, 22.15017]]]] } },
22554     { type: "Feature", properties: { wikidata: "Q22890", nameEn: "Ireland", level: "sharedLandform" }, geometry: null },
22555     { type: "Feature", properties: { wikidata: "Q23666", nameEn: "Great Britain", country: "GB", level: "sharedLandform" }, geometry: null },
22556     { type: "Feature", properties: { wikidata: "Q23681", nameEn: "Northern Cyprus", groups: ["Q644636", "145", "142"], driveSide: "left", callingCodes: ["90 392"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.67678, 35.03866], [33.67742, 35.05963], [33.68474, 35.06602], [33.69095, 35.06237], [33.70861, 35.07644], [33.7161, 35.07279], [33.70209, 35.04882], [33.71482, 35.03722], [33.73824, 35.05321], [33.76106, 35.04253], [33.78581, 35.05104], [33.82067, 35.07826], [33.84168, 35.06823], [33.8541, 35.07201], [33.87479, 35.08881], [33.87097, 35.09389], [33.87622, 35.10457], [33.87224, 35.12293], [33.88561, 35.12449], [33.88943, 35.12007], [33.88737, 35.11408], [33.89853, 35.11377], [33.91789, 35.08688], [33.91299, 35.07579], [33.90247, 35.07686], [33.89485, 35.06873], [33.88367, 35.07877], [33.85261, 35.0574], [33.8355, 35.05777], [33.82051, 35.0667], [33.8012, 35.04786], [33.81524, 35.04192], [33.83055, 35.02865], [33.82875, 35.01685], [33.84045, 35.00616], [33.85216, 35.00579], [33.85891, 35.001], [33.85621, 34.98956], [33.83505, 34.98108], [33.84811, 34.97075], [33.86432, 34.97592], [33.90075, 34.96623], [33.98684, 34.76642], [35.48515, 34.70851], [35.51152, 36.10954], [32.82353, 35.70297], [32.46489, 35.48584], [32.60361, 35.16647], [32.64864, 35.19967], [32.70947, 35.18328], [32.70779, 35.14127], [32.85733, 35.07742], [32.86406, 35.1043], [32.94471, 35.09422], [33.01192, 35.15639], [33.08249, 35.17319], [33.11105, 35.15639], [33.15138, 35.19504], [33.27068, 35.16815], [33.3072, 35.16816], [33.31955, 35.18096], [33.35056, 35.18328], [33.34964, 35.17803], [33.35596, 35.17942], [33.35612, 35.17402], [33.36569, 35.17479], [33.3717, 35.1788], [33.37248, 35.18698], [33.38575, 35.2018], [33.4076, 35.20062], [33.41675, 35.16325], [33.46813, 35.10564], [33.48136, 35.0636], [33.47825, 35.04103], [33.45178, 35.02078], [33.45256, 35.00288], [33.47666, 35.00701], [33.48915, 35.06594], [33.53975, 35.08151], [33.57478, 35.06049], [33.567, 35.04803], [33.59658, 35.03635], [33.61215, 35.0527], [33.63765, 35.03869], [33.67678, 35.03866]]]] } },
22557     { type: "Feature", properties: { wikidata: "Q25231", nameEn: "Svalbard", aliases: ["NO-21"], country: "NO", groups: ["SJ", "154", "150", "UN"], level: "subterritory", callingCodes: ["47 79"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-7.49892, 77.24208], [32.07813, 72.01005], [36.85549, 84.09565], [-7.49892, 77.24208]]]] } },
22558     { type: "Feature", properties: { wikidata: "Q25263", nameEn: "Azores", aliases: ["PT-20"], country: "PT", groups: ["Q3320166", "Q2914565", "Q105472", "EU", "039", "150", "UN"], callingCodes: ["351"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-23.12984, 40.26428], [-36.43765, 41.39418], [-22.54767, 33.34416], [-23.12984, 40.26428]]]] } },
22559     { type: "Feature", properties: { wikidata: "Q25359", nameEn: "Navassa Island", aliases: ["UM-76"], country: "US", groups: ["UM", "Q1352230", "029", "003", "419", "019", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-74.7289, 18.71009], [-75.71816, 18.46438], [-74.76465, 18.06252], [-74.7289, 18.71009]]]] } },
22560     { type: "Feature", properties: { wikidata: "Q25396", nameEn: "Bonaire", aliases: ["BQ-BO", "NL-BQ1"], country: "NL", groups: ["Q1451600", "BQ", "029", "003", "419", "019", "UN"], level: "subterritory", callingCodes: ["599 7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-67.89186, 12.4116], [-68.90012, 12.62309], [-68.33524, 11.78151], [-68.01417, 11.77722], [-67.89186, 12.4116]]]] } },
22561     { type: "Feature", properties: { wikidata: "Q25528", nameEn: "Saba", aliases: ["BQ-SA", "NL-BQ2"], country: "NL", groups: ["Q1451600", "BQ", "029", "003", "419", "019", "UN"], level: "subterritory", callingCodes: ["599 4"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.07669, 17.79659], [-63.81314, 17.95045], [-63.22932, 17.32592], [-63.07669, 17.79659]]]] } },
22562     { type: "Feature", properties: { wikidata: "Q26180", nameEn: "Sint Eustatius", aliases: ["BQ-SE", "NL-BQ3"], country: "NL", groups: ["Q1451600", "BQ", "029", "003", "419", "019", "UN"], level: "subterritory", callingCodes: ["599 3"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.07669, 17.79659], [-63.34999, 16.94218], [-62.76692, 17.64353], [-63.07669, 17.79659]]]] } },
22563     { type: "Feature", properties: { wikidata: "Q26253", nameEn: "Madeira", aliases: ["PT-30"], country: "PT", groups: ["Q3320166", "Q2914565", "Q105472", "EU", "039", "150", "UN"], callingCodes: ["351"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-19.30302, 33.65304], [-16.04789, 29.65076], [-11.68307, 33.12333], [-19.30302, 33.65304]]]] } },
22564     { type: "Feature", properties: { wikidata: "Q26927", nameEn: "Lakshadweep", aliases: ["IN-LD"], country: "IN", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["91"] }, geometry: { type: "MultiPolygon", coordinates: [[[[67.64074, 11.57295], [76.59015, 5.591], [72.67494, 13.58102], [67.64074, 11.57295]]]] } },
22565     { type: "Feature", properties: { wikidata: "Q27329", nameEn: "Asian Russia", country: "RU", groups: ["142", "UN"], callingCodes: ["7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-179.99933, 64.74703], [-172.76104, 63.77445], [-169.03888, 65.48473], [-168.95635, 65.98512], [-168.25765, 71.99091], [-179.9843, 71.90735], [-179.99933, 64.74703]]], [[[59.99809, 51.98263], [60.19925, 51.99173], [60.48915, 52.15175], [60.72581, 52.15538], [60.78201, 52.22067], [61.05417, 52.35096], [60.98021, 52.50068], [60.84709, 52.52228], [60.84118, 52.63912], [60.71693, 52.66245], [60.71989, 52.75923], [61.05842, 52.92217], [61.23462, 53.03227], [62.0422, 52.96105], [62.12799, 52.99133], [62.14574, 53.09626], [61.19024, 53.30536], [61.14291, 53.41481], [61.29082, 53.50992], [61.37957, 53.45887], [61.57185, 53.50112], [61.55706, 53.57144], [60.90626, 53.62937], [61.22574, 53.80268], [61.14283, 53.90063], [60.99796, 53.93699], [61.26863, 53.92797], [61.3706, 54.08464], [61.47603, 54.08048], [61.56941, 53.95703], [61.65318, 54.02445], [62.03913, 53.94768], [62.00966, 54.04134], [62.38535, 54.03961], [62.45931, 53.90737], [62.56876, 53.94047], [62.58651, 54.05871], [63.80604, 54.27079], [63.91224, 54.20013], [64.02715, 54.22679], [63.97686, 54.29763], [64.97216, 54.4212], [65.11033, 54.33028], [65.24663, 54.35721], [65.20174, 54.55216], [68.21308, 54.98645], [68.26661, 55.09226], [68.19206, 55.18823], [68.90865, 55.38148], [69.34224, 55.36344], [69.74917, 55.35545], [70.19179, 55.1476], [70.76493, 55.3027], [70.96009, 55.10558], [71.08288, 54.71253], [71.24185, 54.64965], [71.08706, 54.33376], [71.10379, 54.13326], [71.96141, 54.17736], [72.17477, 54.36303], [72.43415, 53.92685], [72.71026, 54.1161], [73.37963, 53.96132], [73.74778, 54.07194], [73.68921, 53.86522], [73.25412, 53.61532], [73.39218, 53.44623], [75.07405, 53.80831], [75.43398, 53.98652], [75.3668, 54.07439], [76.91052, 54.4677], [76.82266, 54.1798], [76.44076, 54.16017], [76.54243, 53.99329], [77.90383, 53.29807], [79.11255, 52.01171], [80.08138, 50.77658], [80.4127, 50.95581], [80.44819, 51.20855], [80.80318, 51.28262], [81.16999, 51.15662], [81.06091, 50.94833], [81.41248, 50.97524], [81.46581, 50.77658], [81.94999, 50.79307], [82.55443, 50.75412], [83.14607, 51.00796], [83.8442, 50.87375], [84.29385, 50.27257], [84.99198, 50.06793], [85.24047, 49.60239], [86.18709, 49.50259], [86.63674, 49.80136], [86.79056, 49.74787], [86.61307, 49.60239], [86.82606, 49.51796], [87.03071, 49.25142], [87.31465, 49.23603], [87.28386, 49.11626], [87.478, 49.07403], [87.48983, 49.13794], [87.81333, 49.17354], [87.98977, 49.18147], [88.15543, 49.30314], [88.17223, 49.46934], [88.42449, 49.48821], [88.82499, 49.44808], [89.70687, 49.72535], [89.59711, 49.90851], [91.86048, 50.73734], [92.07173, 50.69585], [92.44714, 50.78762], [93.01109, 50.79001], [92.99595, 50.63183], [94.30823, 50.57498], [94.39258, 50.22193], [94.49477, 50.17832], [94.6121, 50.04239], [94.97166, 50.04725], [95.02465, 49.96941], [95.74757, 49.97915], [95.80056, 50.04239], [96.97388, 49.88413], [97.24639, 49.74737], [97.56811, 49.84265], [97.56432, 49.92801], [97.76871, 49.99861], [97.85197, 49.91339], [98.29481, 50.33561], [98.31373, 50.4996], [98.06393, 50.61262], [97.9693, 50.78044], [98.01472, 50.86652], [97.83305, 51.00248], [98.05257, 51.46696], [98.22053, 51.46579], [98.33222, 51.71832], [98.74142, 51.8637], [98.87768, 52.14563], [99.27888, 51.96876], [99.75578, 51.90108], [99.89203, 51.74903], [100.61116, 51.73028], [101.39085, 51.45753], [101.5044, 51.50467], [102.14032, 51.35566], [102.32194, 50.67982], [102.71178, 50.38873], [103.70343, 50.13952], [105.32528, 50.4648], [106.05562, 50.40582], [106.07865, 50.33474], [106.47156, 50.31909], [106.49628, 50.32436], [106.51122, 50.34408], [106.58373, 50.34044], [106.80326, 50.30177], [107.00007, 50.1977], [107.1174, 50.04239], [107.36407, 49.97612], [107.96116, 49.93191], [107.95387, 49.66659], [108.27937, 49.53167], [108.53969, 49.32325], [109.18017, 49.34709], [109.51325, 49.22859], [110.24373, 49.16676], [110.39891, 49.25083], [110.64493, 49.1816], [113.02647, 49.60772], [113.20216, 49.83356], [114.325, 50.28098], [114.9703, 50.19254], [115.26068, 49.97367], [115.73602, 49.87688], [116.22402, 50.04477], [116.62502, 49.92919], [116.71193, 49.83813], [117.27597, 49.62544], [117.48208, 49.62324], [117.82343, 49.52696], [118.61623, 49.93809], [119.11003, 50.00276], [119.27996, 50.13348], [119.38598, 50.35162], [119.13553, 50.37412], [120.10963, 51.671], [120.65907, 51.93544], [120.77337, 52.20805], [120.61346, 52.32447], [120.71673, 52.54099], [120.46454, 52.63811], [120.04049, 52.58773], [120.0451, 52.7359], [120.85633, 53.28499], [121.39213, 53.31888], [122.35063, 53.49565], [122.85966, 53.47395], [123.26989, 53.54843], [123.86158, 53.49391], [124.46078, 53.21881], [125.17522, 53.20225], [125.6131, 53.07229], [126.558, 52.13738], [126.44606, 51.98254], [126.68349, 51.70607], [126.90369, 51.3238], [126.93135, 51.0841], [127.14586, 50.91152], [127.28165, 50.72075], [127.36335, 50.58306], [127.28765, 50.46585], [127.36009, 50.43787], [127.37384, 50.28393], [127.60515, 50.23503], [127.49299, 50.01251], [127.53516, 49.84306], [127.83476, 49.5748], [128.72896, 49.58676], [129.11153, 49.36813], [129.23232, 49.40353], [129.35317, 49.3481], [129.40398, 49.44194], [129.50685, 49.42398], [129.67598, 49.29596], [129.85416, 49.11067], [130.2355, 48.86741], [130.43232, 48.90844], [130.66946, 48.88251], [130.52147, 48.61745], [130.84462, 48.30942], [130.65103, 48.10052], [130.90915, 47.90623], [130.95985, 47.6957], [131.09871, 47.6852], [131.2635, 47.73325], [131.90448, 47.68011], [132.57309, 47.71741], [132.66989, 47.96491], [134.49516, 48.42884], [134.75328, 48.36763], [134.67098, 48.1564], [134.55508, 47.98651], [134.7671, 47.72051], [134.50898, 47.4812], [134.20016, 47.33458], [134.03538, 46.75668], [133.84104, 46.46681], [133.91496, 46.4274], [133.88097, 46.25066], [133.68047, 46.14697], [133.72695, 46.05576], [133.67569, 45.9759], [133.60442, 45.90053], [133.48457, 45.86203], [133.41083, 45.57723], [133.19419, 45.51913], [133.09279, 45.25693], [133.12293, 45.1332], [132.96373, 45.0212], [132.83978, 45.05916], [131.99417, 45.2567], [131.86903, 45.33636], [131.76532, 45.22609], [131.66852, 45.2196], [131.68466, 45.12374], [131.48415, 44.99513], [130.95639, 44.85154], [131.1108, 44.70266], [131.30365, 44.04262], [131.25484, 44.03131], [131.23583, 43.96085], [131.26176, 43.94011], [131.21105, 43.82383], [131.19492, 43.53047], [131.29402, 43.46695], [131.30324, 43.39498], [131.19031, 43.21385], [131.20414, 43.13654], [131.10274, 43.04734], [131.135, 42.94114], [131.02668, 42.91246], [131.02438, 42.86518], [130.66524, 42.84753], [130.44361, 42.76205], [130.40213, 42.70788], [130.56576, 42.68925], [130.62107, 42.58413], [130.55143, 42.52158], [130.56835, 42.43281], [130.60805, 42.4317], [130.64181, 42.41422], [130.66367, 42.38024], [130.65022, 42.32281], [131.95041, 41.5445], [140.9182, 45.92937], [145.82343, 44.571], [145.23667, 43.76813], [153.94307, 38.42848], [180, 62.52334], [180, 71.53642], [155.31937, 81.93282], [76.13964, 83.37843], [64.18965, 69.94255], [66.1708, 67.61252], [61.98014, 65.72191], [60.74386, 64.95767], [59.63945, 64.78384], [59.80579, 64.13948], [59.24834, 63.01859], [59.61398, 62.44915], [59.36223, 61.3882], [59.50685, 60.91162], [58.3853, 59.487], [59.15636, 59.14682], [59.40376, 58.45822], [58.71104, 58.07475], [58.81412, 57.71602], [58.13789, 57.68097], [58.07604, 57.08308], [57.28024, 56.87898], [57.51527, 56.08729], [59.28419, 56.15739], [59.49035, 55.60486], [58.81825, 55.03378], [57.25137, 55.26262], [57.14829, 54.84204], [57.95234, 54.39672], [59.95217, 54.85853], [59.70487, 54.14846], [58.94336, 53.953], [58.79644, 52.43392], [59.22409, 52.28437], [59.25033, 52.46803], [60.17516, 52.39457], [60.17253, 52.25814], [59.91279, 52.06924], [59.99809, 51.98263]]]] } },
22566     { type: "Feature", properties: { wikidata: "Q34366", nameEn: "Tasmania", aliases: ["AU-TAS"], country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[123.64533, -39.13605], [159.69067, -56.28945], [159.74028, -39.1978], [123.64533, -39.13605]]]] } },
22567     { type: "Feature", properties: { wikidata: "Q34497", nameEn: "Saint Helena", aliases: ["SH-HL"], country: "GB", groups: ["SH", "BOTS", "011", "202", "002", "UN"], level: "subterritory", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["290"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-8.3824, -13.9131], [-6.17428, -19.07236], [-3.29308, -15.22647], [-8.3824, -13.9131]]]] } },
22568     { type: "Feature", properties: { wikidata: "Q35657", nameEn: "US States", country: "US", level: "subcountryGroup" }, geometry: null },
22569     { type: "Feature", properties: { wikidata: "Q36117", nameEn: "Borneo", level: "sharedLandform" }, geometry: null },
22570     { type: "Feature", properties: { wikidata: "Q36678", nameEn: "West Bank", country: "PS", groups: ["145", "142"], callingCodes: ["970"] }, geometry: { type: "MultiPolygon", coordinates: [[[[35.47672, 31.49578], [35.55941, 31.76535], [35.52758, 31.9131], [35.54375, 31.96587], [35.52012, 32.04076], [35.57111, 32.21877], [35.55807, 32.38674], [35.42078, 32.41562], [35.41048, 32.43706], [35.41598, 32.45593], [35.42034, 32.46009], [35.40224, 32.50136], [35.35212, 32.52047], [35.30685, 32.51024], [35.29306, 32.50947], [35.25049, 32.52453], [35.2244, 32.55289], [35.15937, 32.50466], [35.10882, 32.4757], [35.10024, 32.47856], [35.09236, 32.47614], [35.08564, 32.46948], [35.07059, 32.4585], [35.05423, 32.41754], [35.05311, 32.4024], [35.0421, 32.38242], [35.05142, 32.3667], [35.04243, 32.35008], [35.01772, 32.33863], [35.01119, 32.28684], [35.02939, 32.2671], [35.01841, 32.23981], [34.98885, 32.20758], [34.95703, 32.19522], [34.96009, 32.17503], [34.99039, 32.14626], [34.98507, 32.12606], [34.99437, 32.10962], [34.9863, 32.09551], [35.00261, 32.027], [34.98682, 31.96935], [35.00124, 31.93264], [35.03489, 31.92448], [35.03978, 31.89276], [35.03489, 31.85919], [34.99712, 31.85569], [34.9724, 31.83352], [35.01978, 31.82944], [35.05617, 31.85685], [35.07677, 31.85627], [35.14174, 31.81325], [35.18603, 31.80901], [35.18169, 31.82542], [35.19461, 31.82687], [35.21469, 31.81835], [35.216, 31.83894], [35.21128, 31.863], [35.20381, 31.86716], [35.20673, 31.88151], [35.20791, 31.8821], [35.20945, 31.8815], [35.21016, 31.88237], [35.21276, 31.88153], [35.2136, 31.88241], [35.22014, 31.88264], [35.22294, 31.87889], [35.22567, 31.86745], [35.22817, 31.8638], [35.2249, 31.85433], [35.2304, 31.84222], [35.24816, 31.8458], [35.25753, 31.8387], [35.251, 31.83085], [35.26404, 31.82567], [35.25573, 31.81362], [35.26058, 31.79064], [35.25225, 31.7678], [35.26319, 31.74846], [35.25182, 31.73945], [35.24981, 31.72543], [35.2438, 31.7201], [35.24315, 31.71244], [35.23972, 31.70896], [35.22392, 31.71899], [35.21937, 31.71578], [35.20538, 31.72388], [35.18023, 31.72067], [35.16478, 31.73242], [35.15474, 31.73352], [35.15119, 31.73634], [35.13931, 31.73012], [35.12933, 31.7325], [35.11895, 31.71454], [35.10782, 31.71594], [35.08226, 31.69107], [35.00879, 31.65426], [34.95249, 31.59813], [34.9415, 31.55601], [34.94356, 31.50743], [34.93258, 31.47816], [34.89756, 31.43891], [34.87833, 31.39321], [34.88932, 31.37093], [34.92571, 31.34337], [35.02459, 31.35979], [35.13033, 31.3551], [35.22921, 31.37445], [35.39675, 31.49572], [35.47672, 31.49578]]]] } },
22571     { type: "Feature", properties: { wikidata: "Q37362", nameEn: "Akrotiri and Dhekelia", aliases: ["SBA"], country: "GB" }, geometry: null },
22572     { type: "Feature", properties: { wikidata: "Q38095", nameEn: "Gal\xE1pagos Islands", aliases: ["EC-W"], country: "EC", groups: ["005", "419", "019", "UN"], callingCodes: ["593"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-93.12365, 2.64343], [-92.46744, -2.52874], [-87.07749, -0.8849], [-93.12365, 2.64343]]]] } },
22573     { type: "Feature", properties: { wikidata: "Q39760", nameEn: "Gaza Strip", country: "PS", groups: ["145", "142"], callingCodes: ["970"] }, geometry: { type: "MultiPolygon", coordinates: [[[[34.052, 31.46619], [34.21853, 31.32363], [34.23572, 31.2966], [34.24012, 31.29591], [34.26742, 31.21998], [34.29417, 31.24194], [34.36523, 31.28963], [34.37381, 31.30598], [34.36505, 31.36404], [34.40077, 31.40926], [34.48892, 31.48365], [34.56797, 31.54197], [34.48681, 31.59711], [34.29262, 31.70393], [34.052, 31.46619]]]] } },
22574     { type: "Feature", properties: { wikidata: "Q40888", nameEn: "Andaman and Nicobar Islands", aliases: ["IN-AN"], country: "IN", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["91"] }, geometry: { type: "MultiPolygon", coordinates: [[[[94.42132, 5.96581], [94.6371, 13.81803], [86.7822, 13.41052], [94.42132, 5.96581]]]] } },
22575     { type: "Feature", properties: { wikidata: "Q41684", nameEn: "Stewart Island", country: "NZ", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[166.59185, -47.61313], [169.70504, -47.56021], [167.52103, -46.41337], [166.59185, -47.61313]]]] } },
22576     { type: "Feature", properties: { wikidata: "Q43296", nameEn: "Wake Island", aliases: ["WK", "WAK", "WKUM", "872", "UM-79"], country: "US", groups: ["UM", "Q1352230", "057", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[167.34779, 18.97692], [166.67967, 20.14834], [165.82549, 18.97692], [167.34779, 18.97692]]]] } },
22577     { type: "Feature", properties: { wikidata: "Q46275", nameEn: "New Zealand Subantarctic Islands", country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left" }, geometry: { type: "MultiPolygon", coordinates: [[[[164.30551, -47.88072], [161.96603, -56.07661], [179.49541, -50.04657], [179.49541, -47.2902], [169.91032, -47.66283], [164.30551, -47.88072]]]] } },
22578     { type: "Feature", properties: { wikidata: "Q46395", nameEn: "British Overseas Territories", aliases: ["BOTS", "UKOTS"], country: "GB", level: "subcountryGroup" }, geometry: null },
22579     { type: "Feature", properties: { wikidata: "Q46772", nameEn: "Kerguelen Islands", country: "FR", groups: ["EU", "TF", "Q1451600", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[61.9216, -49.39746], [70.67507, -51.14192], [74.25129, -45.45074], [61.9216, -49.39746]]]] } },
22580     { type: "Feature", properties: { wikidata: "Q46879", nameEn: "Baker Island", aliases: ["UM-81"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-175.33482, -1.40631], [-175.31323, 0.5442], [-177.91421, 0.39582], [-175.33482, -1.40631]]]] } },
22581     { type: "Feature", properties: { wikidata: "Q47863", nameEn: "Midway Atoll", aliases: ["MI", "MID", "MIUM", "488", "UM-71"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-176.29741, 29.09786], [-177.77531, 29.29793], [-177.5224, 27.7635], [-176.29741, 29.09786]]]] } },
22582     { type: "Feature", properties: { wikidata: "Q62218", nameEn: "Jarvis Island", aliases: ["UM-86"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-160.42921, -1.4364], [-159.12443, 0.19975], [-160.38779, 0.30331], [-160.42921, -1.4364]]]] } },
22583     { type: "Feature", properties: { wikidata: "Q105472", nameEn: "Macaronesia", level: "sharedLandform" }, geometry: null },
22584     { type: "Feature", properties: { wikidata: "Q114935", nameEn: "Kermadec Islands", country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-174.40891, -29.09438], [-180, -24.21376], [-179.96512, -35.00791], [-174.40891, -29.09438]]]] } },
22585     { type: "Feature", properties: { wikidata: "Q115459", nameEn: "Chatham Islands", aliases: ["NZ-CIT"], country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-179.93224, -45.18423], [-172.47015, -45.17912], [-176.30998, -41.38382], [-179.93224, -45.18423]]]] } },
22586     { type: "Feature", properties: { wikidata: "Q118863", nameEn: "North Island", country: "NZ", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[179.49541, -47.2902], [179.49541, -36.79303], [174.17679, -32.62487], [170.27492, -36.38133], [174.58663, -40.80446], [174.46634, -41.55028], [179.49541, -47.2902]]]] } },
22587     { type: "Feature", properties: { wikidata: "Q120755", nameEn: "South Island", country: "NZ", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169.70504, -47.56021], [179.49541, -47.2902], [174.46634, -41.55028], [174.58663, -40.80446], [170.27492, -36.38133], [166.56976, -39.94841], [164.8365, -46.0205], [167.52103, -46.41337], [169.70504, -47.56021]]]] } },
22588     { type: "Feature", properties: { wikidata: "Q123076", nameEn: "Palmyra Atoll", aliases: ["UM-95"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-161.06795, 5.2462], [-161.0731, 7.1291], [-163.24478, 5.24198], [-161.06795, 5.2462]]]] } },
22589     { type: "Feature", properties: { wikidata: "Q130574", nameEn: "Chafarinas Islands", country: "ES", groups: ["EU", "Q191011", "015", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.40316, 35.16893], [-2.43262, 35.20652], [-2.45965, 35.16527], [-2.40316, 35.16893]]]] } },
22590     { type: "Feature", properties: { wikidata: "Q130895", nameEn: "Kingman Reef", aliases: ["UM-89"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-161.0731, 7.1291], [-163.16627, 7.15036], [-163.24478, 5.24198], [-161.0731, 7.1291]]]] } },
22591     { type: "Feature", properties: { wikidata: "Q131008", nameEn: "Johnston Atoll", aliases: ["JT", "JTN", "JTUM", "396", "UM-67"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-170.65691, 16.57199], [-168.87689, 16.01159], [-169.2329, 17.4933], [-170.65691, 16.57199]]]] } },
22592     { type: "Feature", properties: { wikidata: "Q131305", nameEn: "Howland Island", aliases: ["UM-84"], country: "US", groups: ["UM", "Q1352230", "061", "009", "UN"], level: "subterritory", roadSpeedUnit: "mph", roadHeightUnit: "ft" }, geometry: { type: "MultiPolygon", coordinates: [[[[-177.91421, 0.39582], [-175.31323, 0.5442], [-176.74464, 2.28109], [-177.91421, 0.39582]]]] } },
22593     { type: "Feature", properties: { wikidata: "Q133888", nameEn: "Ashmore and Cartier Islands", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[123.7463, -11.1783], [120.6877, -13.59408], [125.29076, -12.33139], [123.7463, -11.1783]]]] } },
22594     { type: "Feature", properties: { wikidata: "Q153732", nameEn: "Mariana Islands", level: "sharedLandform" }, geometry: null },
22595     { type: "Feature", properties: { wikidata: "Q172216", nameEn: "Coral Sea Islands", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[159.77159, -28.41151], [156.73836, -14.50464], [145.2855, -9.62524], [147.69992, -17.5933], [152.93188, -20.92631], [154.02855, -24.43238], [159.77159, -28.41151]]]] } },
22596     { type: "Feature", properties: { wikidata: "Q179313", nameEn: "Alderney", country: "GB", groups: ["GG", "830", "Q185086", "154", "150", "UN"], level: "subterritory", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01481"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.36485, 49.48223], [-2.09454, 49.46288], [-2.02963, 49.91866], [-2.49556, 49.79012], [-2.36485, 49.48223]]]] } },
22597     { type: "Feature", properties: { wikidata: "Q185086", nameEn: "Crown Dependencies", country: "GB", level: "subcountryGroup" }, geometry: null },
22598     { type: "Feature", properties: { wikidata: "Q190571", nameEn: "Scattered Islands", country: "FR", groups: ["EU", "TF", "Q1451600", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[53.53458, -16.36909], [54.96649, -16.28353], [54.61476, -15.02273], [53.53458, -16.36909]]], [[[38.55969, -20.75596], [40.68027, -23.38889], [43.52893, -15.62903], [38.55969, -20.75596]]], [[[47.03092, -11.05648], [47.11593, -12.08552], [47.96702, -11.46447], [47.03092, -11.05648]]]] } },
22599     { type: "Feature", properties: { wikidata: "Q191011", nameEn: "Plazas de soberan\xEDa", country: "ES" }, geometry: null },
22600     { type: "Feature", properties: { wikidata: "Q191146", nameEn: "Pe\xF1\xF3n de V\xE9lez de la Gomera", country: "ES", groups: ["EU", "Q191011", "015", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[-4.30191, 35.17419], [-4.30112, 35.17058], [-4.29436, 35.17149], [-4.30191, 35.17419]]]] } },
22601     { type: "Feature", properties: { wikidata: "Q201698", nameEn: "Crozet Islands", country: "FR", groups: ["EU", "TF", "Q1451600", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[55.03425, -43.65017], [46.31615, -46.28749], [54.5587, -47.93013], [55.03425, -43.65017]]]] } },
22602     { type: "Feature", properties: { wikidata: "Q578170", nameEn: "Contiguous United States", aliases: ["CONUS"], country: "US", groups: ["Q35657", "021", "003", "019", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-97.13927, 25.96583], [-96.92418, 25.97377], [-80.57035, 24.0565], [-78.91214, 27.76553], [-61.98255, 37.34815], [-67.16117, 44.20069], [-66.93432, 44.82597], [-66.96824, 44.83078], [-66.98249, 44.87071], [-66.96824, 44.90965], [-67.0216, 44.95333], [-67.11316, 45.11176], [-67.15965, 45.16179], [-67.19603, 45.16771], [-67.20349, 45.1722], [-67.22751, 45.16344], [-67.27039, 45.1934], [-67.29748, 45.18173], [-67.29754, 45.14865], [-67.34927, 45.122], [-67.48201, 45.27351], [-67.42394, 45.37969], [-67.50578, 45.48971], [-67.42144, 45.50584], [-67.43815, 45.59162], [-67.6049, 45.60725], [-67.80705, 45.69528], [-67.80653, 45.80022], [-67.75654, 45.82324], [-67.80961, 45.87531], [-67.75196, 45.91814], [-67.78111, 45.9392], [-67.78578, 47.06473], [-67.87993, 47.10377], [-67.94843, 47.1925], [-68.23244, 47.35712], [-68.37458, 47.35851], [-68.38332, 47.28723], [-68.57914, 47.28431], [-68.60575, 47.24659], [-68.70125, 47.24399], [-68.89222, 47.1807], [-69.05039, 47.2456], [-69.05073, 47.30076], [-69.05148, 47.42012], [-69.22119, 47.46461], [-69.99966, 46.69543], [-70.05812, 46.41768], [-70.18547, 46.35357], [-70.29078, 46.18832], [-70.23855, 46.1453], [-70.31025, 45.96424], [-70.24694, 45.95138], [-70.25976, 45.89675], [-70.41523, 45.79497], [-70.38934, 45.73215], [-70.54019, 45.67291], [-70.68516, 45.56964], [-70.72651, 45.49771], [-70.62518, 45.42286], [-70.65383, 45.37592], [-70.78372, 45.43269], [-70.82638, 45.39828], [-70.80236, 45.37444], [-70.84816, 45.22698], [-70.89864, 45.2398], [-70.91169, 45.29849], [-70.95193, 45.33895], [-71.0107, 45.34819], [-71.01866, 45.31573], [-71.08364, 45.30623], [-71.14568, 45.24128], [-71.19723, 45.25438], [-71.22338, 45.25184], [-71.29371, 45.29996], [-71.37133, 45.24624], [-71.44252, 45.2361], [-71.40364, 45.21382], [-71.42778, 45.12624], [-71.48735, 45.07784], [-71.50067, 45.01357], [-73.35025, 45.00942], [-74.32699, 44.99029], [-74.66689, 45.00646], [-74.8447, 45.00606], [-74.99101, 44.98051], [-75.01363, 44.95608], [-75.2193, 44.87821], [-75.41441, 44.76614], [-75.76813, 44.51537], [-75.8217, 44.43176], [-75.95947, 44.34463], [-76.00018, 44.34896], [-76.16285, 44.28262], [-76.1664, 44.23051], [-76.244, 44.19643], [-76.31222, 44.19894], [-76.35324, 44.13493], [-76.43859, 44.09393], [-76.79706, 43.63099], [-79.25796, 43.54052], [-79.06921, 43.26183], [-79.05512, 43.25375], [-79.05544, 43.21224], [-79.05002, 43.20133], [-79.05384, 43.17418], [-79.04652, 43.16396], [-79.0427, 43.13934], [-79.06881, 43.12029], [-79.05671, 43.10937], [-79.07486, 43.07845], [-79.01055, 43.06659], [-78.99941, 43.05612], [-79.02424, 43.01983], [-79.02074, 42.98444], [-78.98126, 42.97], [-78.96312, 42.95509], [-78.93224, 42.95229], [-78.90905, 42.93022], [-78.90712, 42.89733], [-78.93684, 42.82887], [-82.67862, 41.67615], [-83.11184, 41.95671], [-83.14962, 42.04089], [-83.12724, 42.2376], [-83.09837, 42.28877], [-83.07837, 42.30978], [-83.02253, 42.33045], [-82.82964, 42.37355], [-82.64242, 42.55594], [-82.58873, 42.54984], [-82.57583, 42.5718], [-82.51858, 42.611], [-82.51063, 42.66025], [-82.46613, 42.76615], [-82.4826, 42.8068], [-82.45331, 42.93139], [-82.4253, 42.95423], [-82.4146, 42.97626], [-82.42469, 42.992], [-82.48419, 45.30225], [-83.59589, 45.82131], [-83.43746, 45.99749], [-83.57017, 46.105], [-83.83329, 46.12169], [-83.90453, 46.05922], [-83.95399, 46.05634], [-84.1096, 46.23987], [-84.09756, 46.25512], [-84.11615, 46.2681], [-84.11254, 46.32329], [-84.13451, 46.39218], [-84.11196, 46.50248], [-84.12885, 46.53068], [-84.17723, 46.52753], [-84.1945, 46.54061], [-84.2264, 46.53337], [-84.26351, 46.49508], [-84.29893, 46.49127], [-84.34174, 46.50683], [-84.42101, 46.49853], [-84.4481, 46.48972], [-84.47607, 46.45225], [-84.55635, 46.45974], [-84.85871, 46.88881], [-88.37033, 48.30586], [-89.48837, 48.01412], [-89.57972, 48.00023], [-89.77248, 48.02607], [-89.89974, 47.98109], [-90.07418, 48.11043], [-90.56312, 48.09488], [-90.56444, 48.12184], [-90.75045, 48.09143], [-90.87588, 48.2484], [-91.08016, 48.18096], [-91.25025, 48.08522], [-91.43248, 48.04912], [-91.45829, 48.07454], [-91.58025, 48.04339], [-91.55649, 48.10611], [-91.70451, 48.11805], [-91.71231, 48.19875], [-91.86125, 48.21278], [-91.98929, 48.25409], [-92.05339, 48.35958], [-92.14732, 48.36578], [-92.202, 48.35252], [-92.26662, 48.35651], [-92.30939, 48.31251], [-92.27167, 48.25046], [-92.37185, 48.22259], [-92.48147, 48.36609], [-92.45588, 48.40624], [-92.50712, 48.44921], [-92.65606, 48.43471], [-92.71323, 48.46081], [-92.69927, 48.49573], [-92.62747, 48.50278], [-92.6342, 48.54133], [-92.7287, 48.54005], [-92.94973, 48.60866], [-93.25391, 48.64266], [-93.33946, 48.62787], [-93.3712, 48.60599], [-93.39758, 48.60364], [-93.40693, 48.60948], [-93.44472, 48.59147], [-93.47022, 48.54357], [-93.66382, 48.51845], [-93.79267, 48.51631], [-93.80939, 48.52439], [-93.80676, 48.58232], [-93.83288, 48.62745], [-93.85769, 48.63284], [-94.23215, 48.65202], [-94.25104, 48.65729], [-94.25172, 48.68404], [-94.27153, 48.70232], [-94.4174, 48.71049], [-94.44258, 48.69223], [-94.53826, 48.70216], [-94.54885, 48.71543], [-94.58903, 48.71803], [-94.69335, 48.77883], [-94.69669, 48.80918], [-94.70486, 48.82365], [-94.70087, 48.8339], [-94.687, 48.84077], [-94.75017, 49.09931], [-94.77355, 49.11998], [-94.82487, 49.29483], [-94.8159, 49.32299], [-94.85381, 49.32492], [-94.95681, 49.37035], [-94.99532, 49.36579], [-95.01419, 49.35647], [-95.05825, 49.35311], [-95.12903, 49.37056], [-95.15357, 49.384], [-95.15355, 48.9996], [-123.32163, 49.00419], [-123.0093, 48.83186], [-123.0093, 48.76586], [-123.26565, 48.6959], [-123.15614, 48.35395], [-123.50039, 48.21223], [-125.03842, 48.53282], [-133.98258, 38.06389], [-118.48109, 32.5991], [-117.1243, 32.53427], [-115.88053, 32.63624], [-114.71871, 32.71894], [-114.76736, 32.64094], [-114.80584, 32.62028], [-114.81141, 32.55543], [-114.79524, 32.55731], [-114.82011, 32.49609], [-111.07523, 31.33232], [-108.20979, 31.33316], [-108.20899, 31.78534], [-106.529, 31.784], [-106.52266, 31.77509], [-106.51251, 31.76922], [-106.50962, 31.76155], [-106.50111, 31.75714], [-106.48815, 31.74769], [-106.47298, 31.75054], [-106.46726, 31.75998], [-106.45244, 31.76523], [-106.43419, 31.75478], [-106.41773, 31.75196], [-106.38003, 31.73151], [-106.3718, 31.71165], [-106.34864, 31.69663], [-106.33419, 31.66303], [-106.30305, 31.62154], [-106.28084, 31.56173], [-106.24612, 31.54193], [-106.23711, 31.51262], [-106.20346, 31.46305], [-106.09025, 31.40569], [-106.00363, 31.39181], [-104.77674, 30.4236], [-104.5171, 29.64671], [-104.3969, 29.57105], [-104.39363, 29.55396], [-104.37752, 29.54255], [-103.15787, 28.93865], [-102.60596, 29.8192], [-101.47277, 29.7744], [-101.05686, 29.44738], [-101.01128, 29.36947], [-100.96725, 29.3477], [-100.94579, 29.34523], [-100.94056, 29.33371], [-100.87982, 29.296], [-100.79696, 29.24688], [-100.67294, 29.09744], [-100.63689, 28.90812], [-100.59809, 28.88197], [-100.52313, 28.75598], [-100.5075, 28.74066], [-100.51222, 28.70679], [-100.50029, 28.66117], [-99.55409, 27.61314], [-99.51478, 27.55836], [-99.52955, 27.49747], [-99.50208, 27.50021], [-99.48045, 27.49016], [-99.482, 27.47128], [-99.49744, 27.43746], [-99.53573, 27.30926], [-99.08477, 26.39849], [-99.03053, 26.41249], [-99.00546, 26.3925], [-98.35126, 26.15129], [-98.30491, 26.10475], [-98.27075, 26.09457], [-98.24603, 26.07191], [-97.97017, 26.05232], [-97.95155, 26.0625], [-97.66511, 26.01708], [-97.52025, 25.88518], [-97.49828, 25.89877], [-97.45669, 25.86874], [-97.42511, 25.83969], [-97.37332, 25.83854], [-97.35946, 25.92189], [-97.13927, 25.96583]]]] } },
22603     { type: "Feature", properties: { wikidata: "Q620634", nameEn: "Bir Tawil", groups: ["015", "002"], level: "territory" }, geometry: { type: "MultiPolygon", coordinates: [[[[33.17563, 22.00405], [33.57251, 21.72406], [33.99686, 21.76784], [34.0765, 22.00501], [33.17563, 22.00405]]]] } },
22604     { type: "Feature", properties: { wikidata: "Q639185", nameEn: "Peros Banhos", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[72.12587, -4.02588], [70.1848, -6.37445], [72.09518, -5.61768], [72.12587, -4.02588]]]] } },
22605     { type: "Feature", properties: { wikidata: "Q644636", nameEn: "Cyprus", level: "sharedLandform" }, geometry: null },
22606     { type: "Feature", properties: { wikidata: "Q851132", nameEn: "New Zealand Outlying Islands", country: "NZ", level: "subcountryGroup" }, geometry: null },
22607     { type: "Feature", properties: { wikidata: "Q875134", nameEn: "European Russia", country: "RU", groups: ["151", "150", "UN"], callingCodes: ["7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[18.57853, 55.25302], [19.64312, 54.45423], [19.8038, 54.44203], [20.63871, 54.3706], [21.41123, 54.32395], [22.79705, 54.36264], [22.7253, 54.41732], [22.70208, 54.45312], [22.67788, 54.532], [22.71293, 54.56454], [22.68021, 54.58486], [22.7522, 54.63525], [22.74225, 54.64339], [22.75467, 54.6483], [22.73397, 54.66604], [22.73631, 54.72952], [22.87317, 54.79492], [22.85083, 54.88711], [22.76422, 54.92521], [22.68723, 54.9811], [22.65451, 54.97037], [22.60075, 55.01863], [22.58907, 55.07085], [22.47688, 55.04408], [22.31562, 55.0655], [22.14267, 55.05345], [22.11697, 55.02131], [22.06087, 55.02935], [22.02582, 55.05078], [22.03984, 55.07888], [21.99543, 55.08691], [21.96505, 55.07353], [21.85521, 55.09493], [21.64954, 55.1791], [21.55605, 55.20311], [21.51095, 55.18507], [21.46766, 55.21115], [21.38446, 55.29348], [21.35465, 55.28427], [21.26425, 55.24456], [20.95181, 55.27994], [20.60454, 55.40986], [18.57853, 55.25302]]], [[[26.32936, 60.00121], [26.90044, 59.63819], [27.85643, 59.58538], [28.04187, 59.47017], [28.19061, 59.39962], [28.21137, 59.38058], [28.20537, 59.36491], [28.19284, 59.35791], [28.14215, 59.28934], [28.00689, 59.28351], [27.90911, 59.24353], [27.87978, 59.18097], [27.80482, 59.1116], [27.74429, 58.98351], [27.36366, 58.78381], [27.55489, 58.39525], [27.48541, 58.22615], [27.62393, 58.09462], [27.67282, 57.92627], [27.81841, 57.89244], [27.78526, 57.83963], [27.56689, 57.83356], [27.50171, 57.78842], [27.52615, 57.72843], [27.3746, 57.66834], [27.40393, 57.62125], [27.31919, 57.57672], [27.34698, 57.52242], [27.56832, 57.53728], [27.52453, 57.42826], [27.86101, 57.29402], [27.66511, 56.83921], [27.86101, 56.88204], [28.04768, 56.59004], [28.13526, 56.57989], [28.10069, 56.524], [28.19057, 56.44637], [28.16599, 56.37806], [28.23716, 56.27588], [28.15217, 56.16964], [28.30571, 56.06035], [28.36888, 56.05805], [28.37987, 56.11399], [28.43068, 56.09407], [28.5529, 56.11705], [28.68337, 56.10173], [28.63668, 56.07262], [28.73418, 55.97131], [29.08299, 56.03427], [29.21717, 55.98971], [29.44692, 55.95978], [29.3604, 55.75862], [29.51283, 55.70294], [29.61446, 55.77716], [29.80672, 55.79569], [29.97975, 55.87281], [30.12136, 55.8358], [30.27776, 55.86819], [30.30987, 55.83592], [30.48257, 55.81066], [30.51346, 55.78982], [30.51037, 55.76568], [30.63344, 55.73079], [30.67464, 55.64176], [30.72957, 55.66268], [30.7845, 55.58514], [30.86003, 55.63169], [30.93419, 55.6185], [30.95204, 55.50667], [30.90123, 55.46621], [30.93144, 55.3914], [30.8257, 55.3313], [30.81946, 55.27931], [30.87944, 55.28223], [30.97369, 55.17134], [31.02071, 55.06167], [31.00972, 55.02783], [30.94243, 55.03964], [30.9081, 55.02232], [30.95754, 54.98609], [30.93144, 54.9585], [30.81759, 54.94064], [30.8264, 54.90062], [30.75165, 54.80699], [30.95479, 54.74346], [30.97127, 54.71967], [31.0262, 54.70698], [30.98226, 54.68872], [30.99187, 54.67046], [31.19339, 54.66947], [31.21399, 54.63113], [31.08543, 54.50361], [31.22945, 54.46585], [31.3177, 54.34067], [31.30791, 54.25315], [31.57002, 54.14535], [31.89599, 54.0837], [31.88744, 54.03653], [31.85019, 53.91801], [31.77028, 53.80015], [31.89137, 53.78099], [32.12621, 53.81586], [32.36663, 53.7166], [32.45717, 53.74039], [32.50112, 53.68594], [32.40499, 53.6656], [32.47777, 53.5548], [32.74968, 53.45597], [32.73257, 53.33494], [32.51725, 53.28431], [32.40773, 53.18856], [32.15368, 53.07594], [31.82373, 53.10042], [31.787, 53.18033], [31.62496, 53.22886], [31.56316, 53.19432], [31.40523, 53.21406], [31.36403, 53.13504], [31.3915, 53.09712], [31.33519, 53.08805], [31.32283, 53.04101], [31.24147, 53.031], [31.35667, 52.97854], [31.592, 52.79011], [31.57277, 52.71613], [31.50406, 52.69707], [31.63869, 52.55361], [31.56316, 52.51518], [31.61397, 52.48843], [31.62084, 52.33849], [31.57971, 52.32146], [31.70735, 52.26711], [31.6895, 52.1973], [31.77877, 52.18636], [31.7822, 52.11406], [31.81722, 52.09955], [31.85018, 52.11305], [31.96141, 52.08015], [31.92159, 52.05144], [32.08813, 52.03319], [32.23331, 52.08085], [32.2777, 52.10266], [32.34044, 52.1434], [32.33083, 52.23685], [32.38988, 52.24946], [32.3528, 52.32842], [32.54781, 52.32423], [32.69475, 52.25535], [32.85405, 52.27888], [32.89937, 52.2461], [33.18913, 52.3754], [33.51323, 52.35779], [33.48027, 52.31499], [33.55718, 52.30324], [33.78789, 52.37204], [34.05239, 52.20132], [34.11199, 52.14087], [34.09413, 52.00835], [34.41136, 51.82793], [34.42922, 51.72852], [34.07765, 51.67065], [34.17599, 51.63253], [34.30562, 51.5205], [34.22048, 51.4187], [34.33446, 51.363], [34.23009, 51.26429], [34.31661, 51.23936], [34.38802, 51.2746], [34.6613, 51.25053], [34.6874, 51.18], [34.82472, 51.17483], [34.97304, 51.2342], [35.14058, 51.23162], [35.12685, 51.16191], [35.20375, 51.04723], [35.31774, 51.08434], [35.40837, 51.04119], [35.32598, 50.94524], [35.39307, 50.92145], [35.41367, 50.80227], [35.47704, 50.77274], [35.48116, 50.66405], [35.39464, 50.64751], [35.47463, 50.49247], [35.58003, 50.45117], [35.61711, 50.35707], [35.73659, 50.35489], [35.80388, 50.41356], [35.8926, 50.43829], [36.06893, 50.45205], [36.20763, 50.3943], [36.30101, 50.29088], [36.47817, 50.31457], [36.58371, 50.28563], [36.56655, 50.2413], [36.64571, 50.218], [36.69377, 50.26982], [36.91762, 50.34963], [37.08468, 50.34935], [37.48204, 50.46079], [37.47243, 50.36277], [37.62486, 50.29966], [37.62879, 50.24481], [37.61113, 50.21976], [37.75807, 50.07896], [37.79515, 50.08425], [37.90776, 50.04194], [38.02999, 49.94482], [38.02999, 49.90592], [38.21675, 49.98104], [38.18517, 50.08161], [38.32524, 50.08866], [38.35408, 50.00664], [38.65688, 49.97176], [38.68677, 50.00904], [38.73311, 49.90238], [38.90477, 49.86787], [38.9391, 49.79524], [39.1808, 49.88911], [39.27968, 49.75976], [39.44496, 49.76067], [39.59142, 49.73758], [39.65047, 49.61761], [39.84548, 49.56064], [40.13249, 49.61672], [40.16683, 49.56865], [40.03636, 49.52321], [40.03087, 49.45452], [40.1141, 49.38798], [40.14912, 49.37681], [40.18331, 49.34996], [40.22176, 49.25683], [40.01988, 49.1761], [39.93437, 49.05709], [39.6836, 49.05121], [39.6683, 48.99454], [39.71353, 48.98959], [39.72649, 48.9754], [39.74874, 48.98675], [39.78368, 48.91596], [39.98967, 48.86901], [40.03636, 48.91957], [40.08168, 48.87443], [39.97182, 48.79398], [39.79466, 48.83739], [39.73104, 48.7325], [39.71765, 48.68673], [39.67226, 48.59368], [39.79764, 48.58668], [39.84548, 48.57821], [39.86196, 48.46633], [39.88794, 48.44226], [39.94847, 48.35055], [39.84136, 48.33321], [39.84273, 48.30947], [39.90041, 48.3049], [39.91465, 48.26743], [39.95248, 48.29972], [39.9693, 48.29904], [39.97325, 48.31399], [39.99241, 48.31768], [40.00752, 48.22445], [39.94847, 48.22811], [39.83724, 48.06501], [39.88256, 48.04482], [39.77544, 48.04206], [39.82213, 47.96396], [39.73935, 47.82876], [38.87979, 47.87719], [38.79628, 47.81109], [38.76379, 47.69346], [38.35062, 47.61631], [38.28679, 47.53552], [38.28954, 47.39255], [38.22225, 47.30788], [38.33074, 47.30508], [38.32112, 47.2585], [38.23049, 47.2324], [38.22955, 47.12069], [38.3384, 46.98085], [38.12112, 46.86078], [37.62608, 46.82615], [35.23066, 45.79231], [35.04991, 45.76827], [36.6645, 45.4514], [36.6545, 45.3417], [36.5049, 45.3136], [36.475, 45.2411], [36.4883, 45.0488], [33.5943, 44.03313], [39.81147, 43.06294], [40.0078, 43.38551], [40.00853, 43.40578], [40.01552, 43.42025], [40.01007, 43.42411], [40.03312, 43.44262], [40.04445, 43.47776], [40.10657, 43.57344], [40.65957, 43.56212], [41.64935, 43.22331], [42.40563, 43.23226], [42.66667, 43.13917], [42.75889, 43.19651], [43.03322, 43.08883], [43.0419, 43.02413], [43.81453, 42.74297], [43.73119, 42.62043], [43.95517, 42.55396], [44.54202, 42.75699], [44.70002, 42.74679], [44.80941, 42.61277], [44.88754, 42.74934], [45.15318, 42.70598], [45.36501, 42.55268], [45.78692, 42.48358], [45.61676, 42.20768], [46.42738, 41.91323], [46.5332, 41.87389], [46.58924, 41.80547], [46.75269, 41.8623], [46.8134, 41.76252], [47.00955, 41.63583], [46.99554, 41.59743], [47.03757, 41.55434], [47.10762, 41.59044], [47.34579, 41.27884], [47.49004, 41.26366], [47.54504, 41.20275], [47.62288, 41.22969], [47.75831, 41.19455], [47.87973, 41.21798], [48.07587, 41.49957], [48.22064, 41.51472], [48.2878, 41.56221], [48.40277, 41.60441], [48.42301, 41.65444], [48.55078, 41.77917], [48.5867, 41.84306], [48.80971, 41.95365], [49.2134, 44.84989], [49.88945, 46.04554], [49.32259, 46.26944], [49.16518, 46.38542], [48.54988, 46.56267], [48.51142, 46.69268], [49.01136, 46.72716], [48.52326, 47.4102], [48.45173, 47.40818], [48.15348, 47.74545], [47.64973, 47.76559], [47.41689, 47.83687], [47.38731, 47.68176], [47.12107, 47.83687], [47.11516, 48.27188], [46.49011, 48.43019], [46.78392, 48.95352], [47.00857, 49.04921], [47.04658, 49.19834], [46.78398, 49.34026], [46.9078, 49.86707], [47.18319, 49.93721], [47.34589, 50.09308], [47.30448, 50.30894], [47.58551, 50.47867], [48.10044, 50.09242], [48.24519, 49.86099], [48.42564, 49.82283], [48.68352, 49.89546], [48.90782, 50.02281], [48.57946, 50.63278], [48.86936, 50.61589], [49.12673, 50.78639], [49.41959, 50.85927], [49.39001, 51.09396], [49.76866, 51.11067], [49.97277, 51.2405], [50.26859, 51.28677], [50.59695, 51.61859], [51.26254, 51.68466], [51.301, 51.48799], [51.77431, 51.49536], [51.8246, 51.67916], [52.36119, 51.74161], [52.54329, 51.48444], [53.46165, 51.49445], [53.69299, 51.23466], [54.12248, 51.11542], [54.46331, 50.85554], [54.41894, 50.61214], [54.55797, 50.52006], [54.71476, 50.61214], [54.56685, 51.01958], [54.72067, 51.03261], [55.67774, 50.54508], [56.11398, 50.7471], [56.17906, 50.93204], [57.17302, 51.11253], [57.44221, 50.88354], [57.74986, 50.93017], [57.75578, 51.13852], [58.3208, 51.15151], [58.87974, 50.70852], [59.48928, 50.64216], [59.51886, 50.49937], [59.81172, 50.54451], [60.01288, 50.8163], [60.17262, 50.83312], [60.31914, 50.67705], [60.81833, 50.6629], [61.4431, 50.80679], [61.56889, 51.23679], [61.6813, 51.25716], [61.55114, 51.32746], [61.50677, 51.40687], [60.95655, 51.48615], [60.92401, 51.61124], [60.5424, 51.61675], [60.36787, 51.66815], [60.50986, 51.7964], [60.09867, 51.87135], [59.99809, 51.98263], [59.91279, 52.06924], [60.17253, 52.25814], [60.17516, 52.39457], [59.25033, 52.46803], [59.22409, 52.28437], [58.79644, 52.43392], [58.94336, 53.953], [59.70487, 54.14846], [59.95217, 54.85853], [57.95234, 54.39672], [57.14829, 54.84204], [57.25137, 55.26262], [58.81825, 55.03378], [59.49035, 55.60486], [59.28419, 56.15739], [57.51527, 56.08729], [57.28024, 56.87898], [58.07604, 57.08308], [58.13789, 57.68097], [58.81412, 57.71602], [58.71104, 58.07475], [59.40376, 58.45822], [59.15636, 59.14682], [58.3853, 59.487], [59.50685, 60.91162], [59.36223, 61.3882], [59.61398, 62.44915], [59.24834, 63.01859], [59.80579, 64.13948], [59.63945, 64.78384], [60.74386, 64.95767], [61.98014, 65.72191], [66.1708, 67.61252], [64.18965, 69.94255], [76.13964, 83.37843], [36.85549, 84.09565], [32.07813, 72.01005], [31.59909, 70.16571], [30.84095, 69.80584], [30.95011, 69.54699], [30.52662, 69.54699], [30.16363, 69.65244], [29.97205, 69.41623], [29.27631, 69.2811], [29.26623, 69.13794], [29.0444, 69.0119], [28.91738, 69.04774], [28.45957, 68.91417], [28.78224, 68.86696], [28.43941, 68.53366], [28.62982, 68.19816], [29.34179, 68.06655], [29.66955, 67.79872], [30.02041, 67.67523], [29.91155, 67.51507], [28.9839, 66.94139], [29.91155, 66.13863], [30.16363, 65.66935], [29.97205, 65.70256], [29.74013, 65.64025], [29.84096, 65.56945], [29.68972, 65.31803], [29.61914, 65.23791], [29.8813, 65.22101], [29.84096, 65.1109], [29.61914, 65.05993], [29.68972, 64.80789], [30.05271, 64.79072], [30.12329, 64.64862], [30.01238, 64.57513], [30.06279, 64.35782], [30.4762, 64.25728], [30.55687, 64.09036], [30.25437, 63.83364], [29.98213, 63.75795], [30.49637, 63.46666], [31.23244, 63.22239], [31.29294, 63.09035], [31.58535, 62.91642], [31.38369, 62.66284], [31.10136, 62.43042], [29.01829, 61.17448], [28.82816, 61.1233], [28.47974, 60.93365], [27.77352, 60.52722], [27.71177, 60.3893], [27.44953, 60.22766], [26.32936, 60.00121]]]] } },
22608     { type: "Feature", properties: { wikidata: "Q1083368", nameEn: "Mainland Finland", country: "FI", groups: ["EU", "154", "150", "UN"], callingCodes: ["358"] }, geometry: { type: "MultiPolygon", coordinates: [[[[29.12697, 69.69193], [28.36883, 69.81658], [28.32849, 69.88605], [27.97558, 69.99671], [27.95542, 70.0965], [27.57226, 70.06215], [27.05802, 69.92069], [26.64461, 69.96565], [26.40261, 69.91377], [25.96904, 69.68397], [25.69679, 69.27039], [25.75729, 68.99383], [25.61613, 68.89602], [25.42455, 68.90328], [25.12206, 68.78684], [25.10189, 68.63307], [24.93048, 68.61102], [24.90023, 68.55579], [24.74898, 68.65143], [24.18432, 68.73936], [24.02299, 68.81601], [23.781, 68.84514], [23.68017, 68.70276], [23.13064, 68.64684], [22.53321, 68.74393], [22.38367, 68.71561], [22.27276, 68.89514], [21.63833, 69.27485], [21.27827, 69.31281], [21.00732, 69.22755], [20.98641, 69.18809], [21.11099, 69.10291], [21.05775, 69.0356], [20.72171, 69.11874], [20.55258, 69.06069], [20.78802, 69.03087], [20.91658, 68.96764], [20.85104, 68.93142], [20.90649, 68.89696], [21.03001, 68.88969], [22.00429, 68.50692], [22.73028, 68.40881], [23.10336, 68.26551], [23.15377, 68.14759], [23.26469, 68.15134], [23.40081, 68.05545], [23.65793, 67.9497], [23.45627, 67.85297], [23.54701, 67.59306], [23.39577, 67.46974], [23.75372, 67.43688], [23.75372, 67.29914], [23.54701, 67.25435], [23.58735, 67.20752], [23.56214, 67.17038], [23.98563, 66.84149], [23.98059, 66.79585], [23.89488, 66.772], [23.85959, 66.56434], [23.63776, 66.43568], [23.67591, 66.3862], [23.64982, 66.30603], [23.71339, 66.21299], [23.90497, 66.15802], [24.15791, 65.85385], [24.14798, 65.83466], [24.15107, 65.81427], [24.14112, 65.39731], [20.15877, 63.06556], [19.23413, 60.61414], [20.96741, 60.71528], [21.15143, 60.54555], [21.08159, 60.20167], [21.02509, 60.12142], [21.35468, 59.67511], [20.5104, 59.15546], [26.32936, 60.00121], [27.44953, 60.22766], [27.71177, 60.3893], [27.77352, 60.52722], [28.47974, 60.93365], [28.82816, 61.1233], [29.01829, 61.17448], [31.10136, 62.43042], [31.38369, 62.66284], [31.58535, 62.91642], [31.29294, 63.09035], [31.23244, 63.22239], [30.49637, 63.46666], [29.98213, 63.75795], [30.25437, 63.83364], [30.55687, 64.09036], [30.4762, 64.25728], [30.06279, 64.35782], [30.01238, 64.57513], [30.12329, 64.64862], [30.05271, 64.79072], [29.68972, 64.80789], [29.61914, 65.05993], [29.84096, 65.1109], [29.8813, 65.22101], [29.61914, 65.23791], [29.68972, 65.31803], [29.84096, 65.56945], [29.74013, 65.64025], [29.97205, 65.70256], [30.16363, 65.66935], [29.91155, 66.13863], [28.9839, 66.94139], [29.91155, 67.51507], [30.02041, 67.67523], [29.66955, 67.79872], [29.34179, 68.06655], [28.62982, 68.19816], [28.43941, 68.53366], [28.78224, 68.86696], [28.45957, 68.91417], [28.91738, 69.04774], [28.81248, 69.11997], [28.8629, 69.22395], [29.31664, 69.47994], [29.12697, 69.69193]]]] } },
22609     { type: "Feature", properties: { wikidata: "Q1184963", nameEn: "Alhucemas Islands", country: "ES", groups: ["EU", "Q191011", "015", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[-3.90602, 35.21494], [-3.88372, 35.20767], [-3.89343, 35.22728], [-3.90602, 35.21494]]]] } },
22610     { type: "Feature", properties: { wikidata: "Q1298289", nameEn: "Egmont Islands", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[70.1848, -6.37445], [70.67958, -8.2663], [72.17991, -6.68509], [70.1848, -6.37445]]]] } },
22611     { type: "Feature", properties: { wikidata: "Q1352230", nameEn: "US Territories", country: "US", level: "subcountryGroup" }, geometry: null },
22612     { type: "Feature", properties: { wikidata: "Q1451600", nameEn: "Overseas Countries and Territories of the EU", aliases: ["OCT"], level: "subunion" }, geometry: null },
22613     { type: "Feature", properties: { wikidata: "Q1544253", nameEn: "Great Chagos Bank", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[70.1848, -6.37445], [72.17991, -6.68509], [73.20573, -5.20727], [70.1848, -6.37445]]]] } },
22614     { type: "Feature", properties: { wikidata: "Q1585511", nameEn: "Salomon Atoll", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[72.09518, -5.61768], [73.20573, -5.20727], [72.12587, -4.02588], [72.09518, -5.61768]]]] } },
22615     { type: "Feature", properties: { wikidata: "Q1681727", nameEn: "Saint-Paul and Amsterdam", country: "FR", groups: ["EU", "TF", "Q1451600", "014", "202", "002", "UN"], level: "subterritory" }, geometry: { type: "MultiPolygon", coordinates: [[[[76.31747, -42.16264], [80.15867, -36.04977], [71.22311, -38.75287], [76.31747, -42.16264]]]] } },
22616     { type: "Feature", properties: { wikidata: "Q1901211", nameEn: "East Malaysia", country: "MY", groups: ["Q36117", "035", "142", "UN"], driveSide: "left", callingCodes: ["60"] }, geometry: { type: "MultiPolygon", coordinates: [[[[110.90339, 7.52694], [109.82788, 2.86812], [109.62558, 1.99182], [109.53794, 1.91771], [109.57923, 1.80624], [109.66397, 1.79972], [109.66397, 1.60425], [110.35354, 0.98869], [110.49182, 0.88088], [110.62374, 0.873], [111.22979, 1.08326], [111.55434, 0.97864], [111.82846, 0.99349], [111.94553, 1.12016], [112.15679, 1.17004], [112.2127, 1.44135], [112.48648, 1.56516], [113.021, 1.57819], [113.01448, 1.42832], [113.64677, 1.23933], [114.03788, 1.44787], [114.57892, 1.5], [114.80706, 1.92351], [114.80706, 2.21665], [115.1721, 2.49671], [115.11343, 2.82879], [115.53713, 3.14776], [115.58276, 3.93499], [115.90217, 4.37708], [117.25801, 4.35108], [117.47313, 4.18857], [117.67641, 4.16535], [118.06469, 4.16638], [118.93936, 4.09009], [119.52945, 5.35672], [117.98544, 6.27477], [117.93857, 6.89845], [117.17735, 7.52841], [116.79524, 7.43869], [115.02521, 5.35005], [115.16236, 5.01011], [115.15092, 4.87604], [115.20737, 4.8256], [115.27819, 4.63661], [115.2851, 4.42295], [115.36346, 4.33563], [115.31275, 4.30806], [115.09978, 4.39123], [115.07737, 4.53418], [115.04064, 4.63706], [115.02278, 4.74137], [115.02955, 4.82087], [115.05038, 4.90275], [114.99417, 4.88201], [114.96982, 4.81146], [114.88841, 4.81905], [114.8266, 4.75062], [114.77303, 4.72871], [114.83189, 4.42387], [114.88039, 4.4257], [114.78539, 4.12205], [114.64211, 4.00694], [114.49922, 4.13108], [114.4416, 4.27588], [114.32176, 4.2552], [114.32176, 4.34942], [114.26876, 4.49878], [114.15813, 4.57], [114.07448, 4.58441], [114.10166, 4.76112], [110.90339, 7.52694]]]] } },
22617     { type: "Feature", properties: { wikidata: "Q1973345", nameEn: "Peninsular Malaysia", country: "MY", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["60"] }, geometry: { type: "MultiPolygon", coordinates: [[[[102.46318, 7.22462], [102.09086, 6.23546], [102.08127, 6.22679], [102.07732, 6.193], [102.09182, 6.14161], [102.01835, 6.05407], [101.99209, 6.04075], [101.97114, 6.01992], [101.9714, 6.00575], [101.94712, 5.98421], [101.92819, 5.85511], [101.91776, 5.84269], [101.89188, 5.8386], [101.80144, 5.74505], [101.75074, 5.79091], [101.69773, 5.75881], [101.58019, 5.93534], [101.25524, 5.78633], [101.25755, 5.71065], [101.14062, 5.61613], [100.98815, 5.79464], [101.02708, 5.91013], [101.087, 5.9193], [101.12388, 6.11411], [101.06165, 6.14161], [101.12618, 6.19431], [101.10313, 6.25617], [100.85884, 6.24929], [100.81045, 6.45086], [100.74822, 6.46231], [100.74361, 6.50811], [100.66986, 6.45086], [100.43027, 6.52389], [100.42351, 6.51762], [100.41791, 6.5189], [100.41152, 6.52299], [100.35413, 6.54932], [100.31929, 6.65413], [100.32607, 6.65933], [100.32671, 6.66526], [100.31884, 6.66423], [100.31618, 6.66781], [100.30828, 6.66462], [100.29651, 6.68439], [100.19511, 6.72559], [100.12, 6.42105], [100.0756, 6.4045], [99.91873, 6.50233], [99.50117, 6.44501], [99.31854, 5.99868], [99.75778, 3.86466], [103.03657, 1.30383], [103.56591, 1.19719], [103.62738, 1.35255], [103.67468, 1.43166], [103.7219, 1.46108], [103.74161, 1.4502], [103.76395, 1.45183], [103.81181, 1.47953], [103.86383, 1.46288], [103.89565, 1.42841], [103.93384, 1.42926], [104.00131, 1.42405], [104.02277, 1.4438], [104.04622, 1.44691], [104.07348, 1.43322], [104.08871, 1.42015], [104.09162, 1.39694], [104.08072, 1.35998], [104.12282, 1.27714], [104.34728, 1.33529], [104.56723, 1.44271], [105.01437, 3.24936], [102.46318, 7.22462]]]] } },
22618     { type: "Feature", properties: { wikidata: "Q2093907", nameEn: "Three Kings Islands", country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left" }, geometry: { type: "MultiPolygon", coordinates: [[[[174.17679, -32.62487], [170.93268, -32.97889], [171.97383, -34.64644], [174.17679, -32.62487]]]] } },
22619     { type: "Feature", properties: { wikidata: "Q2298216", nameEn: "Solander Islands", country: "NZ", groups: ["Q851132", "053", "009", "UN"], driveSide: "left" }, geometry: { type: "MultiPolygon", coordinates: [[[[167.39068, -46.49187], [166.5534, -46.39484], [166.84561, -46.84889], [167.39068, -46.49187]]]] } },
22620     { type: "Feature", properties: { wikidata: "Q2872203", nameEn: "Mainland Australia", country: "AU", groups: ["053", "009", "UN"], level: "subcountryGroup", driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[88.16419, -23.49578], [123.64533, -39.13605], [159.74028, -39.1978], [159.76765, -29.76946], [154.02855, -24.43238], [152.93188, -20.92631], [147.69992, -17.5933], [145.2855, -9.62524], [143.87386, -9.02382], [143.29772, -9.33993], [142.48658, -9.36754], [142.19246, -9.15378], [141.88934, -9.36111], [141.01842, -9.35091], [135.49042, -9.2276], [127.55165, -9.05052], [125.29076, -12.33139], [88.16419, -23.49578]]]] } },
22621     { type: "Feature", properties: { wikidata: "Q2914565", nameEn: "Autonomous Regions of Portugal", country: "PT", level: "subcountryGroup" }, geometry: null },
22622     { type: "Feature", properties: { wikidata: "Q2915956", nameEn: "Mainland Portugal", country: "PT", groups: ["Q12837", "EU", "039", "150", "UN"], level: "subcountryGroup", callingCodes: ["351"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-10.39881, 36.12218], [-7.37282, 36.96896], [-7.39769, 37.16868], [-7.41133, 37.20314], [-7.41854, 37.23813], [-7.43227, 37.25152], [-7.43974, 37.38913], [-7.46878, 37.47127], [-7.51759, 37.56119], [-7.41981, 37.75729], [-7.33441, 37.81193], [-7.27314, 37.90145], [-7.24544, 37.98884], [-7.12648, 38.00296], [-7.10366, 38.04404], [-7.05966, 38.01966], [-7.00375, 38.01914], [-6.93418, 38.21454], [-7.09389, 38.17227], [-7.15581, 38.27597], [-7.32529, 38.44336], [-7.265, 38.61674], [-7.26174, 38.72107], [-7.03848, 38.87221], [-7.051, 38.907], [-6.95211, 39.0243], [-6.97004, 39.07619], [-7.04011, 39.11919], [-7.10692, 39.10275], [-7.14929, 39.11287], [-7.12811, 39.17101], [-7.23566, 39.20132], [-7.23403, 39.27579], [-7.3149, 39.34857], [-7.2927, 39.45847], [-7.49477, 39.58794], [-7.54121, 39.66717], [-7.33507, 39.64569], [-7.24707, 39.66576], [-7.01613, 39.66877], [-6.97492, 39.81488], [-6.91463, 39.86618], [-6.86737, 40.01986], [-6.94233, 40.10716], [-7.00589, 40.12087], [-7.02544, 40.18564], [-7.00426, 40.23169], [-6.86085, 40.26776], [-6.86085, 40.2976], [-6.80218, 40.33239], [-6.78426, 40.36468], [-6.84618, 40.42177], [-6.84944, 40.46394], [-6.7973, 40.51723], [-6.80218, 40.55067], [-6.84292, 40.56801], [-6.79567, 40.65955], [-6.82826, 40.74603], [-6.82337, 40.84472], [-6.79892, 40.84842], [-6.80707, 40.88047], [-6.84292, 40.89771], [-6.8527, 40.93958], [-6.9357, 41.02888], [-6.913, 41.03922], [-6.88843, 41.03027], [-6.84781, 41.02692], [-6.80942, 41.03629], [-6.79241, 41.05397], [-6.75655, 41.10187], [-6.77319, 41.13049], [-6.69711, 41.1858], [-6.68286, 41.21641], [-6.65046, 41.24725], [-6.55937, 41.24417], [-6.38551, 41.35274], [-6.38553, 41.38655], [-6.3306, 41.37677], [-6.26777, 41.48796], [-6.19128, 41.57638], [-6.29863, 41.66432], [-6.44204, 41.68258], [-6.49907, 41.65823], [-6.54633, 41.68623], [-6.56426, 41.74219], [-6.51374, 41.8758], [-6.56752, 41.88429], [-6.5447, 41.94371], [-6.58544, 41.96674], [-6.61967, 41.94008], [-6.75004, 41.94129], [-6.76959, 41.98734], [-6.81196, 41.99097], [-6.82174, 41.94493], [-6.94396, 41.94403], [-6.95537, 41.96553], [-6.98144, 41.9728], [-7.01078, 41.94977], [-7.07596, 41.94977], [-7.08574, 41.97401], [-7.14115, 41.98855], [-7.18549, 41.97515], [-7.18677, 41.88793], [-7.32366, 41.8406], [-7.37092, 41.85031], [-7.42864, 41.80589], [-7.42854, 41.83262], [-7.44759, 41.84451], [-7.45566, 41.86488], [-7.49803, 41.87095], [-7.52737, 41.83939], [-7.62188, 41.83089], [-7.58603, 41.87944], [-7.65774, 41.88308], [-7.69848, 41.90977], [-7.84188, 41.88065], [-7.88055, 41.84571], [-7.88751, 41.92553], [-7.90707, 41.92432], [-7.92336, 41.8758], [-7.9804, 41.87337], [-8.01136, 41.83453], [-8.0961, 41.81024], [-8.16455, 41.81753], [-8.16944, 41.87944], [-8.19551, 41.87459], [-8.2185, 41.91237], [-8.16232, 41.9828], [-8.08796, 42.01398], [-8.08847, 42.05767], [-8.11729, 42.08537], [-8.18178, 42.06436], [-8.19406, 42.12141], [-8.18947, 42.13853], [-8.1986, 42.15402], [-8.22406, 42.1328], [-8.24681, 42.13993], [-8.2732, 42.12396], [-8.29809, 42.106], [-8.32161, 42.10218], [-8.33912, 42.08358], [-8.36353, 42.09065], [-8.38323, 42.07683], [-8.40143, 42.08052], [-8.42512, 42.07199], [-8.44123, 42.08218], [-8.48185, 42.0811], [-8.52837, 42.07658], [-8.5252, 42.06264], [-8.54563, 42.0537], [-8.58086, 42.05147], [-8.59493, 42.05708], [-8.63791, 42.04691], [-8.64626, 42.03668], [-8.65832, 42.02972], [-8.6681, 41.99703], [-8.69071, 41.98862], [-8.7478, 41.96282], [-8.74606, 41.9469], [-8.75712, 41.92833], [-8.81794, 41.90375], [-8.87157, 41.86488], [-11.19304, 41.83075], [-10.39881, 36.12218]]]] } },
22623     { type: "Feature", properties: { wikidata: "Q3311985", nameEn: "Guernsey", country: "GB", groups: ["GG", "830", "Q185086", "154", "150", "UN"], level: "subterritory", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01481"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.49556, 49.79012], [-3.28154, 49.57329], [-2.65349, 49.15373], [-2.36485, 49.48223], [-2.49556, 49.79012]]]] } },
22624     { type: "Feature", properties: { wikidata: "Q3320166", nameEn: "Outermost Regions of the EU", aliases: ["OMR"], level: "subunion" }, geometry: null },
22625     { type: "Feature", properties: { wikidata: "Q3336843", nameEn: "Countries of the United Kingdom", aliases: ["GB-UKM"], country: "GB", level: "subcountryGroup" }, geometry: null },
22626     { type: "Feature", properties: { wikidata: "Q6736667", nameEn: "Mainland India", country: "IN", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["91"] }, geometry: { type: "MultiPolygon", coordinates: [[[[89.08044, 21.41871], [89.07114, 22.15335], [88.9367, 22.58527], [88.94614, 22.66941], [88.9151, 22.75228], [88.96713, 22.83346], [88.87063, 22.95235], [88.88327, 23.03885], [88.86377, 23.08759], [88.99148, 23.21134], [88.71133, 23.2492], [88.79254, 23.46028], [88.79351, 23.50535], [88.74841, 23.47361], [88.56507, 23.64044], [88.58087, 23.87105], [88.66189, 23.87607], [88.73743, 23.91751], [88.6976, 24.14703], [88.74841, 24.1959], [88.68801, 24.31464], [88.50934, 24.32474], [88.12296, 24.51301], [88.08786, 24.63232], [88.00683, 24.66477], [88.15515, 24.85806], [88.14004, 24.93529], [88.21832, 24.96642], [88.27325, 24.88796], [88.33917, 24.86803], [88.46277, 25.07468], [88.44766, 25.20149], [88.94067, 25.18534], [89.00463, 25.26583], [89.01105, 25.30303], [88.85278, 25.34679], [88.81296, 25.51546], [88.677, 25.46959], [88.4559, 25.59227], [88.45103, 25.66245], [88.242, 25.80811], [88.13138, 25.78773], [88.08804, 25.91334], [88.16581, 26.0238], [88.1844, 26.14417], [88.34757, 26.22216], [88.35153, 26.29123], [88.51649, 26.35923], [88.48749, 26.45855], [88.36938, 26.48683], [88.35153, 26.45241], [88.33093, 26.48929], [88.41196, 26.63837], [88.4298, 26.54489], [88.62144, 26.46783], [88.69485, 26.38353], [88.67837, 26.26291], [88.78961, 26.31093], [88.85004, 26.23211], [89.05328, 26.2469], [88.91321, 26.37984], [88.92357, 26.40711], [88.95612, 26.4564], [89.08899, 26.38845], [89.15869, 26.13708], [89.35953, 26.0077], [89.53515, 26.00382], [89.57101, 25.9682], [89.63968, 26.22595], [89.70201, 26.15138], [89.73581, 26.15818], [89.77865, 26.08387], [89.77728, 26.04254], [89.86592, 25.93115], [89.80585, 25.82489], [89.84388, 25.70042], [89.86129, 25.61714], [89.81208, 25.37244], [89.84086, 25.31854], [89.83371, 25.29548], [89.87629, 25.28337], [89.90478, 25.31038], [90.1155, 25.22686], [90.40034, 25.1534], [90.65042, 25.17788], [90.87427, 25.15799], [91.25517, 25.20677], [91.63648, 25.12846], [92.0316, 25.1834], [92.33957, 25.07593], [92.39147, 25.01471], [92.49887, 24.88796], [92.38626, 24.86055], [92.25854, 24.9191], [92.15796, 24.54435], [92.11662, 24.38997], [91.96603, 24.3799], [91.89258, 24.14674], [91.82596, 24.22345], [91.76004, 24.23848], [91.73257, 24.14703], [91.65292, 24.22095], [91.63782, 24.1132], [91.55542, 24.08687], [91.37414, 24.10693], [91.35741, 23.99072], [91.29587, 24.0041], [91.22308, 23.89616], [91.25192, 23.83463], [91.15579, 23.6599], [91.28293, 23.37538], [91.36453, 23.06612], [91.40848, 23.07117], [91.4035, 23.27522], [91.46615, 23.2328], [91.54993, 23.01051], [91.61571, 22.93929], [91.7324, 23.00043], [91.81634, 23.08001], [91.76417, 23.26619], [91.84789, 23.42235], [91.95642, 23.47361], [91.95093, 23.73284], [92.04706, 23.64229], [92.15417, 23.73409], [92.26541, 23.70392], [92.38214, 23.28705], [92.37665, 22.9435], [92.5181, 22.71441], [92.60029, 22.1522], [92.56616, 22.13554], [92.60949, 21.97638], [92.67532, 22.03547], [92.70416, 22.16017], [92.86208, 22.05456], [92.89504, 21.95143], [92.93899, 22.02656], [92.99804, 21.98964], [92.99255, 22.05965], [93.04885, 22.20595], [93.15734, 22.18687], [93.14224, 22.24535], [93.19991, 22.25425], [93.18206, 22.43716], [93.13537, 22.45873], [93.11477, 22.54374], [93.134, 22.59573], [93.09417, 22.69459], [93.134, 22.92498], [93.12988, 23.05772], [93.2878, 23.00464], [93.38478, 23.13698], [93.36862, 23.35426], [93.38781, 23.36139], [93.39981, 23.38828], [93.38805, 23.4728], [93.43475, 23.68299], [93.3908, 23.7622], [93.3908, 23.92925], [93.36059, 23.93176], [93.32351, 24.04468], [93.34735, 24.10151], [93.41415, 24.07854], [93.46633, 23.97067], [93.50616, 23.94432], [93.62871, 24.00922], [93.75952, 24.0003], [93.80279, 23.92549], [93.92089, 23.95812], [94.14081, 23.83333], [94.30215, 24.23752], [94.32362, 24.27692], [94.45279, 24.56656], [94.50729, 24.59281], [94.5526, 24.70764], [94.60204, 24.70889], [94.73937, 25.00545], [94.74212, 25.13606], [94.57458, 25.20318], [94.68032, 25.47003], [94.80117, 25.49359], [95.18556, 26.07338], [95.11428, 26.1019], [95.12801, 26.38397], [95.05798, 26.45408], [95.23513, 26.68499], [95.30339, 26.65372], [95.437, 26.7083], [95.81603, 27.01335], [95.93002, 27.04149], [96.04949, 27.19428], [96.15591, 27.24572], [96.40779, 27.29818], [96.55761, 27.29928], [96.73888, 27.36638], [96.88445, 27.25046], [96.85287, 27.2065], [96.89132, 27.17474], [97.14675, 27.09041], [97.17422, 27.14052], [96.91431, 27.45752], [96.90112, 27.62149], [97.29919, 27.92233], [97.35824, 27.87256], [97.38845, 28.01329], [97.35412, 28.06663], [97.31292, 28.06784], [97.34547, 28.21385], [97.1289, 28.3619], [96.98882, 28.32564], [96.88445, 28.39452], [96.85561, 28.4875], [96.6455, 28.61657], [96.48895, 28.42955], [96.40929, 28.51526], [96.61391, 28.72742], [96.3626, 29.10607], [96.20467, 29.02325], [96.18682, 29.11087], [96.31316, 29.18643], [96.05361, 29.38167], [95.84899, 29.31464], [95.75149, 29.32063], [95.72086, 29.20797], [95.50842, 29.13487], [95.41091, 29.13007], [95.3038, 29.13847], [95.26122, 29.07727], [95.2214, 29.10727], [95.11291, 29.09527], [95.0978, 29.14446], [94.81353, 29.17804], [94.69318, 29.31739], [94.2752, 29.11687], [94.35897, 29.01965], [93.72797, 28.68821], [93.44621, 28.67189], [93.18069, 28.50319], [93.14635, 28.37035], [92.93075, 28.25671], [92.67486, 28.15018], [92.65472, 28.07632], [92.73025, 28.05814], [92.7275, 27.98662], [92.42538, 27.80092], [92.32101, 27.79363], [92.27432, 27.89077], [91.87057, 27.7195], [91.84722, 27.76325], [91.6469, 27.76358], [91.55819, 27.6144], [91.65007, 27.48287], [92.01132, 27.47352], [92.12019, 27.27829], [92.04702, 27.26861], [92.03457, 27.07334], [92.11863, 26.893], [92.05523, 26.8692], [91.83181, 26.87318], [91.50067, 26.79223], [90.67715, 26.77215], [90.48504, 26.8594], [90.39271, 26.90704], [90.30402, 26.85098], [90.04535, 26.72422], [89.86124, 26.73307], [89.63369, 26.74402], [89.42349, 26.83727], [89.3901, 26.84225], [89.38319, 26.85963], [89.37913, 26.86224], [89.1926, 26.81329], [89.12825, 26.81661], [89.09554, 26.89089], [88.95807, 26.92668], [88.92301, 26.99286], [88.8714, 26.97488], [88.86984, 27.10937], [88.74219, 27.144], [88.91901, 27.32483], [88.82981, 27.38814], [88.77517, 27.45415], [88.88091, 27.85192], [88.83559, 28.01936], [88.63235, 28.12356], [88.54858, 28.06057], [88.25332, 27.9478], [88.1278, 27.95417], [88.13378, 27.88015], [88.1973, 27.85067], [88.19107, 27.79285], [88.04008, 27.49223], [88.07277, 27.43007], [88.01646, 27.21612], [88.01587, 27.21388], [87.9887, 27.11045], [88.11719, 26.98758], [88.13422, 26.98705], [88.12302, 26.95324], [88.19107, 26.75516], [88.1659, 26.68177], [88.16452, 26.64111], [88.09963, 26.54195], [88.09414, 26.43732], [88.00895, 26.36029], [87.90115, 26.44923], [87.89085, 26.48565], [87.84193, 26.43663], [87.7918, 26.46737], [87.76004, 26.40711], [87.67893, 26.43501], [87.66803, 26.40294], [87.59175, 26.38342], [87.55274, 26.40596], [87.51571, 26.43106], [87.46566, 26.44058], [87.37314, 26.40815], [87.34568, 26.34787], [87.26568, 26.37294], [87.26587, 26.40592], [87.24682, 26.4143], [87.18863, 26.40558], [87.14751, 26.40542], [87.09147, 26.45039], [87.0707, 26.58571], [87.04691, 26.58685], [87.01559, 26.53228], [86.95912, 26.52076], [86.94543, 26.52076], [86.82898, 26.43919], [86.76797, 26.45892], [86.74025, 26.42386], [86.69124, 26.45169], [86.62686, 26.46891], [86.61313, 26.48658], [86.57073, 26.49825], [86.54258, 26.53819], [86.49726, 26.54218], [86.31564, 26.61925], [86.26235, 26.61886], [86.22513, 26.58863], [86.13596, 26.60651], [86.02729, 26.66756], [85.8492, 26.56667], [85.85126, 26.60866], [85.83126, 26.61134], [85.76907, 26.63076], [85.72315, 26.67471], [85.73483, 26.79613], [85.66239, 26.84822], [85.61621, 26.86721], [85.59461, 26.85161], [85.5757, 26.85955], [85.56471, 26.84133], [85.47752, 26.79292], [85.34302, 26.74954], [85.21159, 26.75933], [85.18046, 26.80519], [85.19291, 26.86909], [85.15883, 26.86966], [85.02635, 26.85381], [85.05592, 26.88991], [85.00536, 26.89523], [84.97186, 26.9149], [84.96687, 26.95599], [84.85754, 26.98984], [84.82913, 27.01989], [84.793, 26.9968], [84.64496, 27.04669], [84.69166, 27.21294], [84.62161, 27.33885], [84.29315, 27.39], [84.25735, 27.44941], [84.21376, 27.45218], [84.10791, 27.52399], [84.02229, 27.43836], [83.93306, 27.44939], [83.86182, 27.4241], [83.85595, 27.35797], [83.61288, 27.47013], [83.39495, 27.4798], [83.38872, 27.39276], [83.35136, 27.33885], [83.29999, 27.32778], [83.2673, 27.36235], [83.27197, 27.38309], [83.19413, 27.45632], [82.94938, 27.46036], [82.93261, 27.50328], [82.74119, 27.49838], [82.70378, 27.72122], [82.46405, 27.6716], [82.06554, 27.92222], [81.97214, 27.93322], [81.91223, 27.84995], [81.47867, 28.08303], [81.48179, 28.12148], [81.38683, 28.17638], [81.32923, 28.13521], [81.19847, 28.36284], [81.03471, 28.40054], [80.55142, 28.69182], [80.50575, 28.6706], [80.52443, 28.54897], [80.44504, 28.63098], [80.37188, 28.63371], [80.12125, 28.82346], [80.06957, 28.82763], [80.05743, 28.91479], [80.18085, 29.13649], [80.23178, 29.11626], [80.26602, 29.13938], [80.24112, 29.21414], [80.28626, 29.20327], [80.31428, 29.30784], [80.24322, 29.44299], [80.37939, 29.57098], [80.41858, 29.63581], [80.38428, 29.68513], [80.36803, 29.73865], [80.41554, 29.79451], [80.43458, 29.80466], [80.48997, 29.79566], [80.56247, 29.86661], [80.57179, 29.91422], [80.60226, 29.95732], [80.67076, 29.95732], [80.8778, 30.13384], [80.86673, 30.17321], [80.91143, 30.22173], [80.92547, 30.17193], [81.03953, 30.20059], [80.83343, 30.32023], [80.54504, 30.44936], [80.20721, 30.58541], [79.93255, 30.88288], [79.59884, 30.93943], [79.30694, 31.17357], [79.14016, 31.43403], [79.01931, 31.42817], [78.89344, 31.30481], [78.77898, 31.31209], [78.71032, 31.50197], [78.84516, 31.60631], [78.69933, 31.78723], [78.78036, 31.99478], [78.74404, 32.00384], [78.68754, 32.10256], [78.49609, 32.2762], [78.4645, 32.45367], [78.38897, 32.53938], [78.73916, 32.69438], [78.7831, 32.46873], [78.96713, 32.33655], [78.99322, 32.37948], [79.0979, 32.38051], [79.13174, 32.47766], [79.26768, 32.53277], [79.46562, 32.69668], [79.14016, 33.02545], [79.15252, 33.17156], [78.73636, 33.56521], [78.67599, 33.66445], [78.77349, 33.73871], [78.73367, 34.01121], [78.65657, 34.03195], [78.66225, 34.08858], [78.91769, 34.15452], [78.99802, 34.3027], [79.05364, 34.32482], [78.74465, 34.45174], [78.56475, 34.50835], [78.54964, 34.57283], [78.27781, 34.61484], [78.18435, 34.7998], [78.22692, 34.88771], [78.00033, 35.23954], [78.03466, 35.3785], [78.11664, 35.48022], [77.80532, 35.52058], [77.70232, 35.46244], [77.44277, 35.46132], [76.96624, 35.5932], [76.84539, 35.67356], [76.77323, 35.66062], [76.75475, 35.52617], [76.85088, 35.39754], [76.93465, 35.39866], [77.11796, 35.05419], [76.99251, 34.93349], [76.87193, 34.96906], [76.74514, 34.92488], [76.74377, 34.84039], [76.67648, 34.76371], [76.47186, 34.78965], [76.15463, 34.6429], [76.04614, 34.67566], [75.75438, 34.51827], [75.38009, 34.55021], [75.01479, 34.64629], [74.6663, 34.703], [74.58083, 34.77386], [74.31239, 34.79626], [74.12897, 34.70073], [73.96423, 34.68244], [73.93401, 34.63386], [73.93951, 34.57169], [73.89419, 34.54568], [73.88732, 34.48911], [73.74999, 34.3781], [73.74862, 34.34183], [73.8475, 34.32935], [73.90517, 34.35317], [73.98208, 34.2522], [73.90677, 34.10504], [73.88732, 34.05105], [73.91341, 34.01235], [74.21554, 34.03853], [74.25262, 34.01577], [74.26086, 33.92237], [74.14001, 33.83002], [74.05898, 33.82089], [74.00891, 33.75437], [73.96423, 33.73071], [73.98968, 33.66155], [73.97367, 33.64061], [74.03576, 33.56718], [74.10115, 33.56392], [74.18121, 33.4745], [74.17983, 33.3679], [74.08782, 33.26232], [74.01366, 33.25199], [74.02144, 33.18908], [74.15374, 33.13477], [74.17571, 33.07495], [74.31854, 33.02891], [74.34875, 32.97823], [74.31227, 32.92795], [74.41467, 32.90563], [74.45312, 32.77755], [74.6289, 32.75561], [74.64675, 32.82604], [74.7113, 32.84219], [74.65345, 32.71225], [74.69542, 32.66792], [74.64424, 32.60985], [74.65251, 32.56416], [74.67431, 32.56676], [74.68362, 32.49298], [74.84725, 32.49075], [74.97634, 32.45367], [75.03265, 32.49538], [75.28259, 32.36556], [75.38046, 32.26836], [75.25649, 32.10187], [75.00793, 32.03786], [74.9269, 32.0658], [74.86236, 32.04485], [74.79919, 31.95983], [74.58907, 31.87824], [74.47771, 31.72227], [74.57498, 31.60382], [74.61517, 31.55698], [74.59319, 31.50197], [74.64713, 31.45605], [74.59773, 31.4136], [74.53223, 31.30321], [74.51629, 31.13829], [74.56023, 31.08303], [74.60281, 31.10419], [74.60006, 31.13711], [74.6852, 31.12771], [74.67971, 31.05479], [74.5616, 31.04153], [73.88993, 30.36305], [73.95736, 30.28466], [73.97225, 30.19829], [73.80299, 30.06969], [73.58665, 30.01848], [73.3962, 29.94707], [73.28094, 29.56646], [73.05886, 29.1878], [73.01337, 29.16422], [72.94272, 29.02487], [72.40402, 28.78283], [72.29495, 28.66367], [72.20329, 28.3869], [71.9244, 28.11555], [71.89921, 27.96035], [70.79054, 27.68423], [70.60927, 28.02178], [70.37307, 28.01208], [70.12502, 27.8057], [70.03136, 27.56627], [69.58519, 27.18109], [69.50904, 26.74892], [69.88555, 26.56836], [70.05584, 26.60398], [70.17532, 26.55362], [70.17532, 26.24118], [70.08193, 26.08094], [70.0985, 25.93238], [70.2687, 25.71156], [70.37444, 25.67443], [70.53649, 25.68928], [70.60378, 25.71898], [70.67382, 25.68186], [70.66695, 25.39314], [70.89148, 25.15064], [70.94002, 24.92843], [71.09405, 24.69017], [70.97594, 24.60904], [71.00341, 24.46038], [71.12838, 24.42662], [71.04461, 24.34657], [70.94985, 24.3791], [70.85784, 24.30903], [70.88393, 24.27398], [70.71502, 24.23517], [70.57906, 24.27774], [70.5667, 24.43787], [70.11712, 24.30915], [70.03428, 24.172], [69.73335, 24.17007], [69.59579, 24.29777], [69.29778, 24.28712], [69.19341, 24.25646], [69.07806, 24.29777], [68.97781, 24.26021], [68.90914, 24.33156], [68.7416, 24.31904], [68.74643, 23.97027], [68.39339, 23.96838], [68.20763, 23.85849], [68.11329, 23.53945], [76.59015, 5.591], [79.50447, 8.91876], [79.42124, 9.80115], [80.48418, 10.20786], [89.08044, 21.41871]]]] } },
22627     { type: "Feature", properties: { wikidata: "Q9143535", nameEn: "Akrotiri", country: "GB", groups: ["Q644636", "Q37362", "BOTS", "145", "142", "UN"], level: "subterritory", driveSide: "left", callingCodes: ["357"] }, geometry: { type: "MultiPolygon", coordinates: [[[[32.86014, 34.70585], [32.82717, 34.70622], [32.79433, 34.67883], [32.76136, 34.68318], [32.75515, 34.64985], [32.74412, 34.43926], [33.26744, 34.49942], [33.0138, 34.64424], [32.96968, 34.64046], [32.96718, 34.63446], [32.95891, 34.62919], [32.95323, 34.64075], [32.95471, 34.64528], [32.94976, 34.65204], [32.94796, 34.6587], [32.95325, 34.66462], [32.97079, 34.66112], [32.97736, 34.65277], [32.99014, 34.65518], [32.98668, 34.67268], [32.99135, 34.68061], [32.95539, 34.68471], [32.94683, 34.67907], [32.94379, 34.67111], [32.93693, 34.67027], [32.93449, 34.66241], [32.92807, 34.66736], [32.93043, 34.67091], [32.91398, 34.67343], [32.9068, 34.66102], [32.86167, 34.68734], [32.86014, 34.70585]]]] } },
22628     { type: "Feature", properties: { wikidata: "Q9206745", nameEn: "Dhekelia", country: "GB", groups: ["Q644636", "Q37362", "BOTS", "145", "142", "UN"], level: "subterritory", driveSide: "left", callingCodes: ["357"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.70575, 34.97947], [33.83531, 34.73974], [33.98684, 34.76642], [33.90075, 34.96623], [33.86432, 34.97592], [33.84811, 34.97075], [33.83505, 34.98108], [33.85621, 34.98956], [33.85891, 35.001], [33.85216, 35.00579], [33.84045, 35.00616], [33.82875, 35.01685], [33.83055, 35.02865], [33.81524, 35.04192], [33.8012, 35.04786], [33.82051, 35.0667], [33.8355, 35.05777], [33.85261, 35.0574], [33.88367, 35.07877], [33.89485, 35.06873], [33.90247, 35.07686], [33.91299, 35.07579], [33.91789, 35.08688], [33.89853, 35.11377], [33.88737, 35.11408], [33.88943, 35.12007], [33.88561, 35.12449], [33.87224, 35.12293], [33.87622, 35.10457], [33.87097, 35.09389], [33.87479, 35.08881], [33.8541, 35.07201], [33.84168, 35.06823], [33.82067, 35.07826], [33.78581, 35.05104], [33.76106, 35.04253], [33.73824, 35.05321], [33.71482, 35.03722], [33.70209, 35.04882], [33.7161, 35.07279], [33.70861, 35.07644], [33.69095, 35.06237], [33.68474, 35.06602], [33.67742, 35.05963], [33.67678, 35.03866], [33.69938, 35.03123], [33.69731, 35.01754], [33.71514, 35.00294], [33.70639, 34.99303], [33.70575, 34.97947]], [[33.77312, 34.9976], [33.77553, 34.99518], [33.78516, 34.99582], [33.79191, 34.98914], [33.78917, 34.98854], [33.78571, 34.98951], [33.78318, 34.98699], [33.78149, 34.98854], [33.77843, 34.988], [33.7778, 34.98981], [33.76738, 34.99188], [33.76605, 34.99543], [33.75682, 34.99916], [33.75994, 35.00113], [33.77312, 34.9976]], [[33.74144, 35.01053], [33.7343, 35.01178], [33.73781, 35.02181], [33.74265, 35.02329], [33.74983, 35.02274], [33.7492, 35.01319], [33.74144, 35.01053]]]] } },
22629     { type: "Feature", properties: { wikidata: "Q16390686", nameEn: "Peninsular Spain", country: "ES", groups: ["Q12837", "EU", "039", "150", "UN"], callingCodes: ["34"] }, geometry: { type: "MultiPolygon", coordinates: [[[[3.75438, 42.33445], [3.17156, 42.43545], [3.11379, 42.43646], [3.10027, 42.42621], [3.08167, 42.42748], [3.03734, 42.47363], [2.96518, 42.46692], [2.94283, 42.48174], [2.92107, 42.4573], [2.88413, 42.45938], [2.86983, 42.46843], [2.85675, 42.45444], [2.84335, 42.45724], [2.77464, 42.41046], [2.75497, 42.42578], [2.72056, 42.42298], [2.65311, 42.38771], [2.6747, 42.33974], [2.57934, 42.35808], [2.55516, 42.35351], [2.54382, 42.33406], [2.48457, 42.33933], [2.43508, 42.37568], [2.43299, 42.39423], [2.38504, 42.39977], [2.25551, 42.43757], [2.20578, 42.41633], [2.16599, 42.42314], [2.12789, 42.41291], [2.11621, 42.38393], [2.06241, 42.35906], [2.00488, 42.35399], [1.96482, 42.37787], [1.9574, 42.42401], [1.94084, 42.43039], [1.94061, 42.43333], [1.94292, 42.44316], [1.93663, 42.45439], [1.88853, 42.4501], [1.83037, 42.48395], [1.76335, 42.48863], [1.72515, 42.50338], [1.70571, 42.48867], [1.66826, 42.50779], [1.65674, 42.47125], [1.58933, 42.46275], [1.57953, 42.44957], [1.55937, 42.45808], [1.55073, 42.43299], [1.5127, 42.42959], [1.44529, 42.43724], [1.43838, 42.47848], [1.41648, 42.48315], [1.46661, 42.50949], [1.44759, 42.54431], [1.41245, 42.53539], [1.4234, 42.55959], [1.44529, 42.56722], [1.42512, 42.58292], [1.44197, 42.60217], [1.35562, 42.71944], [1.15928, 42.71407], [1.0804, 42.78569], [0.98292, 42.78754], [0.96166, 42.80629], [0.93089, 42.79154], [0.711, 42.86372], [0.66121, 42.84021], [0.65421, 42.75872], [0.67873, 42.69458], [0.40214, 42.69779], [0.36251, 42.72282], [0.29407, 42.67431], [0.25336, 42.7174], [0.17569, 42.73424], [-0.02468, 42.68513], [-0.10519, 42.72761], [-0.16141, 42.79535], [-0.17939, 42.78974], [-0.3122, 42.84788], [-0.38833, 42.80132], [-0.41319, 42.80776], [-0.44334, 42.79939], [-0.50863, 42.82713], [-0.55497, 42.77846], [-0.67637, 42.88303], [-0.69837, 42.87945], [-0.72608, 42.89318], [-0.73422, 42.91228], [-0.72037, 42.92541], [-0.75478, 42.96916], [-0.81652, 42.95166], [-0.97133, 42.96239], [-1.00963, 42.99279], [-1.10333, 43.0059], [-1.22881, 43.05534], [-1.25244, 43.04164], [-1.30531, 43.06859], [-1.30052, 43.09581], [-1.27118, 43.11961], [-1.32209, 43.1127], [-1.34419, 43.09665], [-1.35272, 43.02658], [-1.44067, 43.047], [-1.47555, 43.08372], [-1.41562, 43.12815], [-1.3758, 43.24511], [-1.40942, 43.27272], [-1.45289, 43.27049], [-1.50992, 43.29481], [-1.55963, 43.28828], [-1.57674, 43.25269], [-1.61341, 43.25269], [-1.63052, 43.28591], [-1.62481, 43.30726], [-1.69407, 43.31378], [-1.73074, 43.29481], [-1.7397, 43.32979], [-1.75079, 43.3317], [-1.75334, 43.34107], [-1.77068, 43.34396], [-1.78714, 43.35476], [-1.78332, 43.36399], [-1.79319, 43.37497], [-1.77289, 43.38957], [-1.81005, 43.59738], [-10.14298, 44.17365], [-11.19304, 41.83075], [-8.87157, 41.86488], [-8.81794, 41.90375], [-8.75712, 41.92833], [-8.74606, 41.9469], [-8.7478, 41.96282], [-8.69071, 41.98862], [-8.6681, 41.99703], [-8.65832, 42.02972], [-8.64626, 42.03668], [-8.63791, 42.04691], [-8.59493, 42.05708], [-8.58086, 42.05147], [-8.54563, 42.0537], [-8.5252, 42.06264], [-8.52837, 42.07658], [-8.48185, 42.0811], [-8.44123, 42.08218], [-8.42512, 42.07199], [-8.40143, 42.08052], [-8.38323, 42.07683], [-8.36353, 42.09065], [-8.33912, 42.08358], [-8.32161, 42.10218], [-8.29809, 42.106], [-8.2732, 42.12396], [-8.24681, 42.13993], [-8.22406, 42.1328], [-8.1986, 42.15402], [-8.18947, 42.13853], [-8.19406, 42.12141], [-8.18178, 42.06436], [-8.11729, 42.08537], [-8.08847, 42.05767], [-8.08796, 42.01398], [-8.16232, 41.9828], [-8.2185, 41.91237], [-8.19551, 41.87459], [-8.16944, 41.87944], [-8.16455, 41.81753], [-8.0961, 41.81024], [-8.01136, 41.83453], [-7.9804, 41.87337], [-7.92336, 41.8758], [-7.90707, 41.92432], [-7.88751, 41.92553], [-7.88055, 41.84571], [-7.84188, 41.88065], [-7.69848, 41.90977], [-7.65774, 41.88308], [-7.58603, 41.87944], [-7.62188, 41.83089], [-7.52737, 41.83939], [-7.49803, 41.87095], [-7.45566, 41.86488], [-7.44759, 41.84451], [-7.42854, 41.83262], [-7.42864, 41.80589], [-7.37092, 41.85031], [-7.32366, 41.8406], [-7.18677, 41.88793], [-7.18549, 41.97515], [-7.14115, 41.98855], [-7.08574, 41.97401], [-7.07596, 41.94977], [-7.01078, 41.94977], [-6.98144, 41.9728], [-6.95537, 41.96553], [-6.94396, 41.94403], [-6.82174, 41.94493], [-6.81196, 41.99097], [-6.76959, 41.98734], [-6.75004, 41.94129], [-6.61967, 41.94008], [-6.58544, 41.96674], [-6.5447, 41.94371], [-6.56752, 41.88429], [-6.51374, 41.8758], [-6.56426, 41.74219], [-6.54633, 41.68623], [-6.49907, 41.65823], [-6.44204, 41.68258], [-6.29863, 41.66432], [-6.19128, 41.57638], [-6.26777, 41.48796], [-6.3306, 41.37677], [-6.38553, 41.38655], [-6.38551, 41.35274], [-6.55937, 41.24417], [-6.65046, 41.24725], [-6.68286, 41.21641], [-6.69711, 41.1858], [-6.77319, 41.13049], [-6.75655, 41.10187], [-6.79241, 41.05397], [-6.80942, 41.03629], [-6.84781, 41.02692], [-6.88843, 41.03027], [-6.913, 41.03922], [-6.9357, 41.02888], [-6.8527, 40.93958], [-6.84292, 40.89771], [-6.80707, 40.88047], [-6.79892, 40.84842], [-6.82337, 40.84472], [-6.82826, 40.74603], [-6.79567, 40.65955], [-6.84292, 40.56801], [-6.80218, 40.55067], [-6.7973, 40.51723], [-6.84944, 40.46394], [-6.84618, 40.42177], [-6.78426, 40.36468], [-6.80218, 40.33239], [-6.86085, 40.2976], [-6.86085, 40.26776], [-7.00426, 40.23169], [-7.02544, 40.18564], [-7.00589, 40.12087], [-6.94233, 40.10716], [-6.86737, 40.01986], [-6.91463, 39.86618], [-6.97492, 39.81488], [-7.01613, 39.66877], [-7.24707, 39.66576], [-7.33507, 39.64569], [-7.54121, 39.66717], [-7.49477, 39.58794], [-7.2927, 39.45847], [-7.3149, 39.34857], [-7.23403, 39.27579], [-7.23566, 39.20132], [-7.12811, 39.17101], [-7.14929, 39.11287], [-7.10692, 39.10275], [-7.04011, 39.11919], [-6.97004, 39.07619], [-6.95211, 39.0243], [-7.051, 38.907], [-7.03848, 38.87221], [-7.26174, 38.72107], [-7.265, 38.61674], [-7.32529, 38.44336], [-7.15581, 38.27597], [-7.09389, 38.17227], [-6.93418, 38.21454], [-7.00375, 38.01914], [-7.05966, 38.01966], [-7.10366, 38.04404], [-7.12648, 38.00296], [-7.24544, 37.98884], [-7.27314, 37.90145], [-7.33441, 37.81193], [-7.41981, 37.75729], [-7.51759, 37.56119], [-7.46878, 37.47127], [-7.43974, 37.38913], [-7.43227, 37.25152], [-7.41854, 37.23813], [-7.41133, 37.20314], [-7.39769, 37.16868], [-7.37282, 36.96896], [-7.2725, 35.73269], [-5.10878, 36.05227], [-2.27707, 35.35051], [3.75438, 42.33445]], [[-5.27801, 36.14942], [-5.34064, 36.03744], [-5.40526, 36.15488], [-5.34536, 36.15501], [-5.33822, 36.15272], [-5.27801, 36.14942]]], [[[1.99838, 42.44682], [2.01564, 42.45171], [1.99216, 42.46208], [1.98579, 42.47486], [1.99766, 42.4858], [1.98916, 42.49351], [1.98022, 42.49569], [1.97697, 42.48568], [1.97227, 42.48487], [1.97003, 42.48081], [1.96215, 42.47854], [1.95606, 42.45785], [1.96125, 42.45364], [1.98378, 42.44697], [1.99838, 42.44682]]]] } },
22630     { type: "Feature", properties: { wikidata: "Q98059339", nameEn: "Mainland Norway", country: "NO", groups: ["154", "150", "UN"], callingCodes: ["47"] }, geometry: { type: "MultiPolygon", coordinates: [[[[10.40861, 58.38489], [10.64958, 58.89391], [11.08911, 58.98745], [11.15367, 59.07862], [11.34459, 59.11672], [11.4601, 58.99022], [11.45199, 58.89604], [11.65732, 58.90177], [11.8213, 59.24985], [11.69297, 59.59442], [11.92112, 59.69531], [11.87121, 59.86039], [12.15641, 59.8926], [12.36317, 59.99259], [12.52003, 60.13846], [12.59133, 60.50559], [12.2277, 61.02442], [12.69115, 61.06584], [12.86939, 61.35427], [12.57707, 61.56547], [12.40595, 61.57226], [12.14746, 61.7147], [12.29187, 62.25699], [12.07085, 62.6297], [12.19919, 63.00104], [11.98529, 63.27487], [12.19919, 63.47935], [12.14928, 63.59373], [12.74105, 64.02171], [13.23411, 64.09087], [13.98222, 64.00953], [14.16051, 64.18725], [14.11117, 64.46674], [13.64276, 64.58402], [14.50926, 65.31786], [14.53778, 66.12399], [15.05113, 66.15572], [15.49318, 66.28509], [15.37197, 66.48217], [16.35589, 67.06419], [16.39154, 67.21653], [16.09922, 67.4364], [16.12774, 67.52106], [16.38441, 67.52923], [16.7409, 67.91037], [17.30416, 68.11591], [17.90787, 67.96537], [18.13836, 68.20874], [18.1241, 68.53721], [18.39503, 68.58672], [18.63032, 68.50849], [18.97255, 68.52416], [19.93508, 68.35911], [20.22027, 68.48759], [19.95647, 68.55546], [20.22027, 68.67246], [20.33435, 68.80174], [20.28444, 68.93283], [20.0695, 69.04469], [20.55258, 69.06069], [20.72171, 69.11874], [21.05775, 69.0356], [21.11099, 69.10291], [20.98641, 69.18809], [21.00732, 69.22755], [21.27827, 69.31281], [21.63833, 69.27485], [22.27276, 68.89514], [22.38367, 68.71561], [22.53321, 68.74393], [23.13064, 68.64684], [23.68017, 68.70276], [23.781, 68.84514], [24.02299, 68.81601], [24.18432, 68.73936], [24.74898, 68.65143], [24.90023, 68.55579], [24.93048, 68.61102], [25.10189, 68.63307], [25.12206, 68.78684], [25.42455, 68.90328], [25.61613, 68.89602], [25.75729, 68.99383], [25.69679, 69.27039], [25.96904, 69.68397], [26.40261, 69.91377], [26.64461, 69.96565], [27.05802, 69.92069], [27.57226, 70.06215], [27.95542, 70.0965], [27.97558, 69.99671], [28.32849, 69.88605], [28.36883, 69.81658], [29.12697, 69.69193], [29.31664, 69.47994], [28.8629, 69.22395], [28.81248, 69.11997], [28.91738, 69.04774], [29.0444, 69.0119], [29.26623, 69.13794], [29.27631, 69.2811], [29.97205, 69.41623], [30.16363, 69.65244], [30.52662, 69.54699], [30.95011, 69.54699], [30.84095, 69.80584], [31.59909, 70.16571], [32.07813, 72.01005], [-11.60274, 67.73467], [7.28637, 57.35913], [10.40861, 58.38489]]]] } },
22631     { type: "Feature", properties: { wikidata: "Q98543636", nameEn: "Mainland Ecuador", country: "EC", groups: ["005", "419", "019", "UN"], callingCodes: ["593"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-84.52388, -3.36941], [-80.30602, -3.39149], [-80.20647, -3.431], [-80.24123, -3.46124], [-80.24586, -3.48677], [-80.23651, -3.48652], [-80.22629, -3.501], [-80.20535, -3.51667], [-80.21642, -3.5888], [-80.19848, -3.59249], [-80.18741, -3.63994], [-80.19926, -3.68894], [-80.13232, -3.90317], [-80.46386, -4.01342], [-80.4822, -4.05477], [-80.45023, -4.20938], [-80.32114, -4.21323], [-80.46386, -4.41516], [-80.39256, -4.48269], [-80.13945, -4.29786], [-79.79722, -4.47558], [-79.59402, -4.46848], [-79.26248, -4.95167], [-79.1162, -4.97774], [-79.01659, -5.01481], [-78.85149, -4.66795], [-78.68394, -4.60754], [-78.34362, -3.38633], [-78.24589, -3.39907], [-78.22642, -3.51113], [-78.14324, -3.47653], [-78.19369, -3.36431], [-77.94147, -3.05454], [-76.6324, -2.58397], [-76.05203, -2.12179], [-75.57429, -1.55961], [-75.3872, -0.9374], [-75.22862, -0.95588], [-75.22862, -0.60048], [-75.53615, -0.19213], [-75.60169, -0.18708], [-75.61997, -0.10012], [-75.40192, -0.17196], [-75.25764, -0.11943], [-75.82927, 0.09578], [-76.23441, 0.42294], [-76.41215, 0.38228], [-76.4094, 0.24015], [-76.89177, 0.24736], [-77.52001, 0.40782], [-77.49984, 0.64476], [-77.67815, 0.73863], [-77.66416, 0.81604], [-77.68613, 0.83029], [-77.7148, 0.85003], [-77.85677, 0.80197], [-78.42749, 1.15389], [-78.87137, 1.47457], [-82.12561, 4.00341], [-84.52388, -3.36941]]]] } },
22632     { type: "Feature", properties: { m49: "001", wikidata: "Q2", nameEn: "World", aliases: ["Earth", "Planet"], level: "world" }, geometry: null },
22633     { type: "Feature", properties: { m49: "002", wikidata: "Q15", nameEn: "Africa", level: "region" }, geometry: null },
22634     { type: "Feature", properties: { m49: "003", wikidata: "Q49", nameEn: "North America", level: "subregion" }, geometry: null },
22635     { type: "Feature", properties: { m49: "005", wikidata: "Q18", nameEn: "South America", level: "intermediateRegion" }, geometry: null },
22636     { type: "Feature", properties: { m49: "009", wikidata: "Q538", nameEn: "Oceania", level: "region" }, geometry: null },
22637     { type: "Feature", properties: { m49: "011", wikidata: "Q4412", nameEn: "Western Africa", level: "intermediateRegion" }, geometry: null },
22638     { type: "Feature", properties: { m49: "013", wikidata: "Q27611", nameEn: "Central America", level: "intermediateRegion" }, geometry: null },
22639     { type: "Feature", properties: { m49: "014", wikidata: "Q27407", nameEn: "Eastern Africa", level: "intermediateRegion" }, geometry: null },
22640     { type: "Feature", properties: { m49: "015", wikidata: "Q27381", nameEn: "Northern Africa", level: "subregion" }, geometry: null },
22641     { type: "Feature", properties: { m49: "017", wikidata: "Q27433", nameEn: "Middle Africa", level: "intermediateRegion" }, geometry: null },
22642     { type: "Feature", properties: { m49: "018", wikidata: "Q27394", nameEn: "Southern Africa", level: "intermediateRegion" }, geometry: null },
22643     { type: "Feature", properties: { m49: "019", wikidata: "Q828", nameEn: "Americas", level: "region" }, geometry: null },
22644     { type: "Feature", properties: { m49: "021", wikidata: "Q2017699", nameEn: "Northern America", level: "subregion" }, geometry: null },
22645     { type: "Feature", properties: { m49: "029", wikidata: "Q664609", nameEn: "Caribbean", level: "intermediateRegion" }, geometry: null },
22646     { type: "Feature", properties: { m49: "030", wikidata: "Q27231", nameEn: "Eastern Asia", level: "subregion" }, geometry: null },
22647     { type: "Feature", properties: { m49: "034", wikidata: "Q771405", nameEn: "Southern Asia", level: "subregion" }, geometry: null },
22648     { type: "Feature", properties: { m49: "035", wikidata: "Q11708", nameEn: "South-eastern Asia", level: "subregion" }, geometry: null },
22649     { type: "Feature", properties: { m49: "039", wikidata: "Q27449", nameEn: "Southern Europe", level: "subregion" }, geometry: null },
22650     { type: "Feature", properties: { m49: "053", wikidata: "Q45256", nameEn: "Australia and New Zealand", aliases: ["Australasia"], level: "subregion" }, geometry: null },
22651     { type: "Feature", properties: { m49: "054", wikidata: "Q37394", nameEn: "Melanesia", level: "subregion" }, geometry: null },
22652     { type: "Feature", properties: { m49: "057", wikidata: "Q3359409", nameEn: "Micronesia", level: "subregion" }, geometry: null },
22653     { type: "Feature", properties: { m49: "061", wikidata: "Q35942", nameEn: "Polynesia", level: "subregion" }, geometry: null },
22654     { type: "Feature", properties: { m49: "142", wikidata: "Q48", nameEn: "Asia", level: "region" }, geometry: null },
22655     { type: "Feature", properties: { m49: "143", wikidata: "Q27275", nameEn: "Central Asia", level: "subregion" }, geometry: null },
22656     { type: "Feature", properties: { m49: "145", wikidata: "Q27293", nameEn: "Western Asia", level: "subregion" }, geometry: null },
22657     { type: "Feature", properties: { m49: "150", wikidata: "Q46", nameEn: "Europe", level: "region" }, geometry: null },
22658     { type: "Feature", properties: { m49: "151", wikidata: "Q27468", nameEn: "Eastern Europe", level: "subregion" }, geometry: null },
22659     { type: "Feature", properties: { m49: "154", wikidata: "Q27479", nameEn: "Northern Europe", level: "subregion" }, geometry: null },
22660     { type: "Feature", properties: { m49: "155", wikidata: "Q27496", nameEn: "Western Europe", level: "subregion" }, geometry: null },
22661     { type: "Feature", properties: { m49: "202", wikidata: "Q132959", nameEn: "Sub-Saharan Africa", level: "subregion" }, geometry: null },
22662     { type: "Feature", properties: { m49: "419", wikidata: "Q72829598", nameEn: "Latin America and the Caribbean", level: "subregion" }, geometry: null },
22663     { type: "Feature", properties: { m49: "680", wikidata: "Q3405693", nameEn: "Sark", country: "GB", groups: ["GG", "830", "Q185086", "154", "150", "UN"], level: "subterritory", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01481"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.36485, 49.48223], [-2.65349, 49.15373], [-2.09454, 49.46288], [-2.36485, 49.48223]]]] } },
22664     { type: "Feature", properties: { m49: "830", wikidata: "Q42314", nameEn: "Channel Islands", level: "intermediateRegion" }, geometry: null },
22665     { type: "Feature", properties: { iso1A2: "AC", iso1A3: "ASC", wikidata: "Q46197", nameEn: "Ascension Island", aliases: ["SH-AC"], country: "GB", groups: ["SH", "BOTS", "011", "202", "002", "UN"], isoStatus: "excRes", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["247"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-14.82771, -8.70814], [-13.33271, -8.07391], [-14.91926, -6.63386], [-14.82771, -8.70814]]]] } },
22666     { type: "Feature", properties: { iso1A2: "AD", iso1A3: "AND", iso1N3: "020", wikidata: "Q228", nameEn: "Andorra", groups: ["Q12837", "039", "150", "UN"], callingCodes: ["376"] }, geometry: { type: "MultiPolygon", coordinates: [[[[1.72515, 42.50338], [1.73683, 42.55492], [1.7858, 42.57698], [1.72588, 42.59098], [1.73452, 42.61515], [1.68267, 42.62533], [1.6625, 42.61982], [1.63485, 42.62957], [1.60085, 42.62703], [1.55418, 42.65669], [1.50867, 42.64483], [1.48043, 42.65203], [1.46718, 42.63296], [1.47986, 42.61346], [1.44197, 42.60217], [1.42512, 42.58292], [1.44529, 42.56722], [1.4234, 42.55959], [1.41245, 42.53539], [1.44759, 42.54431], [1.46661, 42.50949], [1.41648, 42.48315], [1.43838, 42.47848], [1.44529, 42.43724], [1.5127, 42.42959], [1.55073, 42.43299], [1.55937, 42.45808], [1.57953, 42.44957], [1.58933, 42.46275], [1.65674, 42.47125], [1.66826, 42.50779], [1.70571, 42.48867], [1.72515, 42.50338]]]] } },
22667     { type: "Feature", properties: { iso1A2: "AE", iso1A3: "ARE", iso1N3: "784", wikidata: "Q878", nameEn: "United Arab Emirates", groups: ["145", "142", "UN"], callingCodes: ["971"] }, geometry: { type: "MultiPolygon", coordinates: [[[[56.26534, 25.62825], [56.25341, 25.61443], [56.26636, 25.60643], [56.25365, 25.60211], [56.20473, 25.61119], [56.18363, 25.65508], [56.14826, 25.66351], [56.13579, 25.73524], [56.17416, 25.77239], [56.13963, 25.82765], [56.19334, 25.9795], [56.15498, 26.06828], [56.08666, 26.05038], [55.81777, 26.18798], [55.14145, 25.62624], [53.97892, 24.64436], [52.82259, 25.51697], [52.35509, 25.00368], [52.02277, 24.75635], [51.83108, 24.71675], [51.58834, 24.66608], [51.41644, 24.39615], [51.58871, 24.27256], [51.59617, 24.12041], [52.56622, 22.94341], [55.13599, 22.63334], [55.2137, 22.71065], [55.22634, 23.10378], [55.57358, 23.669], [55.48677, 23.94946], [55.73301, 24.05994], [55.8308, 24.01633], [56.01799, 24.07426], [55.95472, 24.2172], [55.83367, 24.20193], [55.77658, 24.23476], [55.76558, 24.23227], [55.75257, 24.23466], [55.75382, 24.2466], [55.75939, 24.26114], [55.76781, 24.26209], [55.79145, 24.27914], [55.80747, 24.31069], [55.83395, 24.32776], [55.83271, 24.41521], [55.76461, 24.5287], [55.83271, 24.68567], [55.83408, 24.77858], [55.81348, 24.80102], [55.81116, 24.9116], [55.85094, 24.96858], [55.90849, 24.96771], [55.96316, 25.00857], [56.05715, 24.95727], [56.05106, 24.87461], [55.97467, 24.89639], [55.97836, 24.87673], [56.03535, 24.81161], [56.06128, 24.74457], [56.13684, 24.73699], [56.20062, 24.78565], [56.20568, 24.85063], [56.30269, 24.88334], [56.34873, 24.93205], [56.3227, 24.97284], [56.86325, 25.03856], [56.82555, 25.7713], [56.26534, 25.62825]], [[56.26062, 25.33108], [56.3005, 25.31815], [56.3111, 25.30107], [56.35172, 25.30681], [56.34438, 25.26653], [56.27628, 25.23404], [56.24341, 25.22867], [56.20872, 25.24104], [56.20838, 25.25668], [56.24465, 25.27505], [56.25008, 25.28843], [56.23362, 25.31253], [56.26062, 25.33108]]], [[[56.28423, 25.26344], [56.29379, 25.2754], [56.28102, 25.28486], [56.2716, 25.27916], [56.27086, 25.26128], [56.28423, 25.26344]]]] } },
22668     { type: "Feature", properties: { iso1A2: "AF", iso1A3: "AFG", iso1N3: "004", wikidata: "Q889", nameEn: "Afghanistan", groups: ["034", "142", "UN"], callingCodes: ["93"] }, geometry: { type: "MultiPolygon", coordinates: [[[[70.61526, 38.34774], [70.60407, 38.28046], [70.54673, 38.24541], [70.4898, 38.12546], [70.17206, 37.93276], [70.1863, 37.84296], [70.27694, 37.81258], [70.28243, 37.66706], [70.15015, 37.52519], [69.95971, 37.5659], [69.93362, 37.61378], [69.84435, 37.60616], [69.80041, 37.5746], [69.51888, 37.5844], [69.44954, 37.4869], [69.36645, 37.40462], [69.45022, 37.23315], [69.39529, 37.16752], [69.25152, 37.09426], [69.03274, 37.25174], [68.96407, 37.32603], [68.88168, 37.33368], [68.91189, 37.26704], [68.80889, 37.32494], [68.81438, 37.23862], [68.6798, 37.27906], [68.61851, 37.19815], [68.41888, 37.13906], [68.41201, 37.10402], [68.29253, 37.10621], [68.27605, 37.00977], [68.18542, 37.02074], [68.02194, 36.91923], [67.87917, 37.0591], [67.7803, 37.08978], [67.78329, 37.1834], [67.51868, 37.26102], [67.2581, 37.17216], [67.2224, 37.24545], [67.13039, 37.27168], [67.08232, 37.35469], [66.95598, 37.40162], [66.64699, 37.32958], [66.55743, 37.35409], [66.30993, 37.32409], [65.72274, 37.55438], [65.64137, 37.45061], [65.64263, 37.34388], [65.51778, 37.23881], [64.97945, 37.21913], [64.61141, 36.6351], [64.62514, 36.44311], [64.57295, 36.34362], [64.43288, 36.24401], [64.05385, 36.10433], [63.98519, 36.03773], [63.56496, 35.95106], [63.53475, 35.90881], [63.29579, 35.85985], [63.12276, 35.86208], [63.10318, 35.81782], [63.23262, 35.67487], [63.10079, 35.63024], [63.12276, 35.53196], [63.0898, 35.43131], [62.90853, 35.37086], [62.74098, 35.25432], [62.62288, 35.22067], [62.48006, 35.28796], [62.29878, 35.13312], [62.29191, 35.25964], [62.15871, 35.33278], [62.05709, 35.43803], [61.97743, 35.4604], [61.77693, 35.41341], [61.58742, 35.43803], [61.27371, 35.61482], [61.18187, 35.30249], [61.0991, 35.27845], [61.12831, 35.09938], [61.06926, 34.82139], [61.00197, 34.70631], [60.99922, 34.63064], [60.72316, 34.52857], [60.91321, 34.30411], [60.66502, 34.31539], [60.50209, 34.13992], [60.5838, 33.80793], [60.5485, 33.73422], [60.57762, 33.59772], [60.69573, 33.56054], [60.91133, 33.55596], [60.88908, 33.50219], [60.56485, 33.12944], [60.86191, 32.22565], [60.84541, 31.49561], [61.70929, 31.37391], [61.80569, 31.16167], [61.80957, 31.12576], [61.83257, 31.0452], [61.8335, 30.97669], [61.78268, 30.92724], [61.80829, 30.84224], [60.87231, 29.86514], [62.47751, 29.40782], [63.5876, 29.50456], [64.12966, 29.39157], [64.19796, 29.50407], [64.62116, 29.58903], [65.04005, 29.53957], [66.24175, 29.85181], [66.36042, 29.9583], [66.23609, 30.06321], [66.34869, 30.404], [66.28413, 30.57001], [66.39194, 30.9408], [66.42645, 30.95309], [66.58175, 30.97532], [66.68166, 31.07597], [66.72561, 31.20526], [66.83273, 31.26867], [67.04147, 31.31561], [67.03323, 31.24519], [67.29964, 31.19586], [67.78854, 31.33203], [67.7748, 31.4188], [67.62374, 31.40473], [67.58323, 31.52772], [67.72056, 31.52304], [67.86887, 31.63536], [68.00071, 31.6564], [68.1655, 31.82691], [68.25614, 31.80357], [68.27605, 31.75863], [68.44222, 31.76446], [68.57475, 31.83158], [68.6956, 31.75687], [68.79997, 31.61665], [68.91078, 31.59687], [68.95995, 31.64822], [69.00939, 31.62249], [69.11514, 31.70782], [69.20577, 31.85957], [69.3225, 31.93186], [69.27032, 32.14141], [69.27932, 32.29119], [69.23599, 32.45946], [69.2868, 32.53938], [69.38155, 32.56601], [69.44747, 32.6678], [69.43649, 32.7302], [69.38018, 32.76601], [69.47082, 32.85834], [69.5436, 32.8768], [69.49854, 32.88843], [69.49004, 33.01509], [69.57656, 33.09911], [69.71526, 33.09911], [69.79766, 33.13247], [69.85259, 33.09451], [70.02563, 33.14282], [70.07369, 33.22557], [70.13686, 33.21064], [70.32775, 33.34496], [70.17062, 33.53535], [70.20141, 33.64387], [70.14785, 33.6553], [70.14236, 33.71701], [70.00503, 33.73528], [69.85671, 33.93719], [69.87307, 33.9689], [69.90203, 34.04194], [70.54336, 33.9463], [70.88119, 33.97933], [71.07345, 34.06242], [71.06933, 34.10564], [71.09307, 34.11961], [71.09453, 34.13524], [71.13078, 34.16503], [71.12815, 34.26619], [71.17662, 34.36769], [71.02401, 34.44835], [71.0089, 34.54568], [71.11602, 34.63047], [71.08718, 34.69034], [71.28356, 34.80882], [71.29472, 34.87728], [71.50329, 34.97328], [71.49917, 35.00478], [71.55273, 35.02615], [71.52938, 35.09023], [71.67495, 35.21262], [71.5541, 35.28776], [71.54294, 35.31037], [71.65435, 35.4479], [71.49917, 35.6267], [71.55273, 35.71483], [71.37969, 35.95865], [71.19505, 36.04134], [71.60491, 36.39429], [71.80267, 36.49924], [72.18135, 36.71838], [72.6323, 36.84601], [73.82685, 36.91421], [74.04856, 36.82648], [74.43389, 37.00977], [74.53739, 36.96224], [74.56453, 37.03023], [74.49981, 37.24518], [74.80605, 37.21565], [74.88887, 37.23275], [74.8294, 37.3435], [74.68383, 37.3948], [74.56161, 37.37734], [74.41055, 37.3948], [74.23339, 37.41116], [74.20308, 37.34208], [73.8564, 37.26158], [73.82552, 37.22659], [73.64974, 37.23643], [73.61129, 37.27469], [73.76647, 37.33913], [73.77197, 37.4417], [73.29633, 37.46495], [73.06884, 37.31729], [72.79693, 37.22222], [72.66381, 37.02014], [72.54095, 37.00007], [72.31676, 36.98115], [71.83229, 36.68084], [71.67083, 36.67346], [71.57195, 36.74943], [71.51502, 36.89128], [71.48481, 36.93218], [71.46923, 36.99925], [71.45578, 37.03094], [71.43097, 37.05855], [71.44127, 37.11856], [71.4494, 37.18137], [71.4555, 37.21418], [71.47386, 37.2269], [71.48339, 37.23937], [71.4824, 37.24921], [71.48536, 37.26017], [71.50674, 37.31502], [71.49821, 37.31975], [71.4862, 37.33405], [71.47685, 37.40281], [71.49612, 37.4279], [71.5256, 37.47971], [71.50616, 37.50733], [71.49693, 37.53527], [71.5065, 37.60912], [71.51972, 37.61945], [71.54186, 37.69691], [71.55234, 37.73209], [71.53053, 37.76534], [71.54324, 37.77104], [71.55752, 37.78677], [71.59255, 37.79956], [71.58843, 37.92425], [71.51565, 37.95349], [71.32871, 37.88564], [71.296, 37.93403], [71.2809, 37.91995], [71.24969, 37.93031], [71.27278, 37.96496], [71.27622, 37.99946], [71.28922, 38.01272], [71.29878, 38.04429], [71.36444, 38.15358], [71.37803, 38.25641], [71.33869, 38.27335], [71.33114, 38.30339], [71.21291, 38.32797], [71.1451, 38.40106], [71.10957, 38.40671], [71.10592, 38.42077], [71.09542, 38.42517], [71.0556, 38.40176], [71.03545, 38.44779], [70.98693, 38.48862], [70.92728, 38.43021], [70.88719, 38.46826], [70.84376, 38.44688], [70.82538, 38.45394], [70.81697, 38.44507], [70.80521, 38.44447], [70.79766, 38.44944], [70.78702, 38.45031], [70.78581, 38.45502], [70.77132, 38.45548], [70.75455, 38.4252], [70.72485, 38.4131], [70.69807, 38.41861], [70.67438, 38.40597], [70.6761, 38.39144], [70.69189, 38.37031], [70.64966, 38.34999], [70.61526, 38.34774]]]] } },
22669     { type: "Feature", properties: { iso1A2: "AG", iso1A3: "ATG", iso1N3: "028", wikidata: "Q781", nameEn: "Antigua and Barbuda", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 268"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-61.66959, 18.6782], [-62.58307, 16.68909], [-62.1023, 16.97277], [-61.23098, 16.62484], [-61.66959, 18.6782]]]] } },
22670     { type: "Feature", properties: { iso1A2: "AI", iso1A3: "AIA", iso1N3: "660", wikidata: "Q25228", nameEn: "Anguilla", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 264"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.79029, 19.11219], [-63.35989, 18.06012], [-62.62718, 18.26185], [-63.79029, 19.11219]]]] } },
22671     { type: "Feature", properties: { iso1A2: "AL", iso1A3: "ALB", iso1N3: "008", wikidata: "Q222", nameEn: "Albania", groups: ["039", "150", "UN"], callingCodes: ["355"] }, geometry: { type: "MultiPolygon", coordinates: [[[[20.07761, 42.55582], [20.01834, 42.54622], [20.00842, 42.5109], [19.9324, 42.51699], [19.82333, 42.46581], [19.76549, 42.50237], [19.74731, 42.57422], [19.77375, 42.58517], [19.73244, 42.66299], [19.65972, 42.62774], [19.4836, 42.40831], [19.42352, 42.36546], [19.42, 42.33019], [19.28623, 42.17745], [19.40687, 42.10024], [19.37548, 42.06835], [19.36867, 42.02564], [19.37691, 41.96977], [19.34601, 41.95675], [19.33812, 41.90669], [19.37451, 41.8842], [19.37597, 41.84849], [19.26406, 41.74971], [19.0384, 40.35325], [19.95905, 39.82857], [19.97622, 39.78684], [19.92466, 39.69533], [19.98042, 39.6504], [20.00957, 39.69227], [20.05189, 39.69112], [20.12956, 39.65805], [20.15988, 39.652], [20.22376, 39.64532], [20.22707, 39.67459], [20.27412, 39.69884], [20.31961, 39.72799], [20.29152, 39.80421], [20.30804, 39.81563], [20.38572, 39.78516], [20.41475, 39.81437], [20.41546, 39.82832], [20.31135, 39.99438], [20.37911, 39.99058], [20.42373, 40.06777], [20.48487, 40.06271], [20.51297, 40.08168], [20.55593, 40.06524], [20.61081, 40.07866], [20.62566, 40.0897], [20.67162, 40.09433], [20.71789, 40.27739], [20.78234, 40.35803], [20.7906, 40.42726], [20.83688, 40.47882], [20.94925, 40.46625], [20.96908, 40.51526], [21.03932, 40.56299], [21.05833, 40.66586], [20.98134, 40.76046], [20.95752, 40.76982], [20.98396, 40.79109], [20.97887, 40.85475], [20.97693, 40.90103], [20.94305, 40.92399], [20.83671, 40.92752], [20.81567, 40.89662], [20.73504, 40.9081], [20.71634, 40.91781], [20.65558, 41.08009], [20.63454, 41.0889], [20.59832, 41.09066], [20.58546, 41.11179], [20.59715, 41.13644], [20.51068, 41.2323], [20.49432, 41.33679], [20.52119, 41.34381], [20.55976, 41.4087], [20.51301, 41.442], [20.49039, 41.49277], [20.45331, 41.51436], [20.45809, 41.5549], [20.52103, 41.56473], [20.55508, 41.58113], [20.51769, 41.65975], [20.52937, 41.69292], [20.51301, 41.72433], [20.53405, 41.78099], [20.57144, 41.7897], [20.55976, 41.87068], [20.59524, 41.8818], [20.57946, 41.91593], [20.63069, 41.94913], [20.59434, 42.03879], [20.55633, 42.08173], [20.56955, 42.12097], [20.48857, 42.25444], [20.3819, 42.3029], [20.34479, 42.32656], [20.24399, 42.32168], [20.21797, 42.41237], [20.17127, 42.50469], [20.07761, 42.55582]]]] } },
22672     { type: "Feature", properties: { iso1A2: "AM", iso1A3: "ARM", iso1N3: "051", wikidata: "Q399", nameEn: "Armenia", groups: ["145", "142", "UN"], callingCodes: ["374"] }, geometry: { type: "MultiPolygon", coordinates: [[[[45.0133, 41.29747], [44.93493, 41.25685], [44.81437, 41.30371], [44.80053, 41.25949], [44.81749, 41.23488], [44.84358, 41.23088], [44.89911, 41.21366], [44.87887, 41.20195], [44.82084, 41.21513], [44.72814, 41.20338], [44.61462, 41.24018], [44.59322, 41.1933], [44.46791, 41.18204], [44.34417, 41.2382], [44.34337, 41.20312], [44.32139, 41.2079], [44.18148, 41.24644], [44.16591, 41.19141], [43.84835, 41.16329], [43.74717, 41.1117], [43.67712, 41.13398], [43.4717, 41.12611], [43.44984, 41.0988], [43.47319, 41.02251], [43.58683, 40.98961], [43.67712, 40.93084], [43.67712, 40.84846], [43.74872, 40.7365], [43.7425, 40.66805], [43.63664, 40.54159], [43.54791, 40.47413], [43.60862, 40.43267], [43.59928, 40.34019], [43.71136, 40.16673], [43.65221, 40.14889], [43.65688, 40.11199], [43.92307, 40.01787], [44.1057, 40.03555], [44.1778, 40.02845], [44.26973, 40.04866], [44.46635, 39.97733], [44.61845, 39.8281], [44.75779, 39.7148], [44.88354, 39.74432], [44.92869, 39.72157], [45.06604, 39.79277], [45.18554, 39.67846], [45.17464, 39.58614], [45.21784, 39.58074], [45.23535, 39.61373], [45.30385, 39.61373], [45.29606, 39.57654], [45.46992, 39.49888], [45.70547, 39.60174], [45.80804, 39.56716], [45.83, 39.46487], [45.79225, 39.3695], [45.99774, 39.28931], [46.02303, 39.09978], [46.06973, 39.0744], [46.14785, 38.84206], [46.20601, 38.85262], [46.34059, 38.92076], [46.53497, 38.86548], [46.51805, 38.94982], [46.54296, 39.07078], [46.44022, 39.19636], [46.52584, 39.18912], [46.54141, 39.15895], [46.58032, 39.21204], [46.63481, 39.23013], [46.56476, 39.24942], [46.50093, 39.33736], [46.43244, 39.35181], [46.37795, 39.42039], [46.4013, 39.45405], [46.53051, 39.47809], [46.51027, 39.52373], [46.57721, 39.54414], [46.57098, 39.56694], [46.52117, 39.58734], [46.42465, 39.57534], [46.40286, 39.63651], [46.18493, 39.60533], [45.96543, 39.78859], [45.82533, 39.82925], [45.7833, 39.9475], [45.60895, 39.97733], [45.59806, 40.0131], [45.78642, 40.03218], [45.83779, 39.98925], [45.97944, 40.181], [45.95609, 40.27846], [45.65098, 40.37696], [45.42994, 40.53804], [45.45484, 40.57707], [45.35366, 40.65979], [45.4206, 40.7424], [45.55914, 40.78366], [45.60584, 40.87436], [45.40814, 40.97904], [45.44083, 41.01663], [45.39725, 41.02603], [45.35677, 40.99784], [45.28859, 41.03757], [45.26162, 41.0228], [45.25897, 41.0027], [45.1994, 41.04518], [45.16493, 41.05068], [45.1634, 41.08082], [45.1313, 41.09369], [45.12923, 41.06059], [45.06784, 41.05379], [45.08028, 41.10917], [45.19942, 41.13299], [45.1969, 41.168], [45.11811, 41.19967], [45.05201, 41.19211], [45.02932, 41.2101], [45.05497, 41.2464], [45.0133, 41.29747]], [[45.21324, 40.9817], [45.21219, 40.99001], [45.20518, 40.99348], [45.19312, 40.98998], [45.18382, 41.0066], [45.20625, 41.01484], [45.23487, 41.00226], [45.23095, 40.97828], [45.21324, 40.9817]], [[45.00864, 41.03411], [44.9903, 41.05657], [44.96031, 41.06345], [44.95383, 41.07553], [44.97169, 41.09176], [45.00864, 41.09407], [45.03406, 41.07931], [45.04517, 41.06653], [45.03792, 41.03938], [45.00864, 41.03411]]], [[[45.50279, 40.58424], [45.56071, 40.64765], [45.51825, 40.67382], [45.47927, 40.65023], [45.50279, 40.58424]]]] } },
22673     { type: "Feature", properties: { iso1A2: "AO", iso1A3: "AGO", iso1N3: "024", wikidata: "Q916", nameEn: "Angola", groups: ["017", "202", "002", "UN"], callingCodes: ["244"] }, geometry: { type: "MultiPolygon", coordinates: [[[[16.55507, -5.85631], [13.04371, -5.87078], [12.42245, -6.07585], [11.95767, -5.94705], [12.20376, -5.76338], [12.26557, -5.74031], [12.52318, -5.74353], [12.52301, -5.17481], [12.53599, -5.1618], [12.53586, -5.14658], [12.51589, -5.1332], [12.49815, -5.14058], [12.46297, -5.09408], [12.60251, -5.01715], [12.63465, -4.94632], [12.70868, -4.95505], [12.8733, -4.74346], [13.11195, -4.67745], [13.09648, -4.63739], [12.91489, -4.47907], [12.87096, -4.40315], [12.76844, -4.38709], [12.64835, -4.55937], [12.40964, -4.60609], [12.32324, -4.78415], [12.25587, -4.79437], [12.20901, -4.75642], [12.16068, -4.90089], [12.00924, -5.02627], [11.50888, -5.33417], [10.5065, -17.25284], [11.75063, -17.25013], [12.07076, -17.15165], [12.52111, -17.24495], [12.97145, -16.98567], [13.36212, -16.98048], [13.95896, -17.43141], [14.28743, -17.38814], [18.39229, -17.38927], [18.84226, -17.80375], [21.14283, -17.94318], [21.42741, -18.02787], [23.47474, -17.62877], [23.20038, -17.47563], [22.17217, -16.50269], [22.00323, -16.18028], [21.97988, -13.00148], [24.03339, -12.99091], [23.90937, -12.844], [24.06672, -12.29058], [23.98804, -12.13149], [24.02603, -11.15368], [24.00027, -10.89356], [23.86868, -11.02856], [23.45631, -10.946], [23.16602, -11.10577], [22.54205, -11.05784], [22.25951, -11.24911], [22.17954, -10.85884], [22.32604, -10.76291], [22.19039, -9.94628], [21.84856, -9.59871], [21.79824, -7.29628], [20.56263, -7.28566], [20.61689, -6.90876], [20.31846, -6.91953], [20.30218, -6.98955], [19.5469, -7.00195], [19.33698, -7.99743], [18.33635, -8.00126], [17.5828, -8.13784], [16.96282, -7.21787], [16.55507, -5.85631]]]] } },
22674     { type: "Feature", properties: { iso1A2: "AQ", iso1A3: "ATA", iso1N3: "010", wikidata: "Q51", nameEn: "Antarctica", level: "region", callingCodes: ["672"] }, geometry: { type: "MultiPolygon", coordinates: [[[[180, -60], [-180, -60], [-180, -90], [180, -90], [180, -60]]]] } },
22675     { type: "Feature", properties: { iso1A2: "AR", iso1A3: "ARG", iso1N3: "032", wikidata: "Q414", nameEn: "Argentina", aliases: ["RA"], groups: ["005", "419", "019", "UN"], callingCodes: ["54"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-72.31343, -50.58411], [-72.33873, -51.59954], [-71.99889, -51.98018], [-69.97824, -52.00845], [-68.41683, -52.33516], [-68.60702, -52.65781], [-68.60733, -54.9125], [-68.01394, -54.8753], [-67.46182, -54.92205], [-67.11046, -54.94199], [-66.07313, -55.19618], [-63.67376, -55.11859], [-54.78916, -36.21945], [-57.83001, -34.69099], [-58.34425, -34.15035], [-58.44442, -33.84033], [-58.40475, -33.11777], [-58.1224, -32.98842], [-58.22362, -32.52416], [-58.10036, -32.25338], [-58.20252, -31.86966], [-58.00076, -31.65016], [-58.0023, -31.53084], [-58.07569, -31.44916], [-57.98127, -31.3872], [-57.9908, -31.34924], [-57.86729, -31.06352], [-57.89476, -30.95994], [-57.8024, -30.77193], [-57.89115, -30.49572], [-57.64859, -30.35095], [-57.61478, -30.25165], [-57.65132, -30.19229], [-57.09386, -29.74211], [-56.81251, -29.48154], [-56.62789, -29.18073], [-56.57295, -29.11357], [-56.54171, -29.11447], [-56.05265, -28.62651], [-56.00458, -28.60421], [-56.01729, -28.51223], [-55.65418, -28.18304], [-55.6262, -28.17124], [-55.33303, -27.94661], [-55.16872, -27.86224], [-55.1349, -27.89759], [-54.90805, -27.73149], [-54.90159, -27.63132], [-54.67657, -27.57214], [-54.50416, -27.48232], [-54.41888, -27.40882], [-54.19268, -27.30751], [-54.19062, -27.27639], [-54.15978, -27.2889], [-53.80144, -27.09844], [-53.73372, -26.6131], [-53.68269, -26.33359], [-53.64505, -26.28089], [-53.64186, -26.25976], [-53.64632, -26.24798], [-53.63881, -26.25075], [-53.63739, -26.2496], [-53.65237, -26.23289], [-53.65018, -26.19501], [-53.73968, -26.10012], [-53.73391, -26.07006], [-53.7264, -26.0664], [-53.73086, -26.05842], [-53.73511, -26.04211], [-53.83691, -25.94849], [-53.90831, -25.55513], [-54.52926, -25.62846], [-54.5502, -25.58915], [-54.59398, -25.59224], [-54.62063, -25.91213], [-54.60664, -25.9691], [-54.67359, -25.98607], [-54.69333, -26.37705], [-54.70732, -26.45099], [-54.80868, -26.55669], [-55.00584, -26.78754], [-55.06351, -26.80195], [-55.16948, -26.96068], [-55.25243, -26.93808], [-55.39611, -26.97679], [-55.62322, -27.1941], [-55.59094, -27.32444], [-55.74475, -27.44485], [-55.89195, -27.3467], [-56.18313, -27.29851], [-56.85337, -27.5165], [-58.04205, -27.2387], [-58.59549, -27.29973], [-58.65321, -27.14028], [-58.3198, -26.83443], [-58.1188, -26.16704], [-57.87176, -25.93604], [-57.57431, -25.47269], [-57.80821, -25.13863], [-58.25492, -24.92528], [-58.33055, -24.97099], [-59.33886, -24.49935], [-59.45482, -24.34787], [-60.03367, -24.00701], [-60.28163, -24.04436], [-60.99754, -23.80934], [-61.0782, -23.62932], [-61.9756, -23.0507], [-62.22768, -22.55807], [-62.51761, -22.37684], [-62.64455, -22.25091], [-62.8078, -22.12534], [-62.81124, -21.9987], [-63.66482, -21.99918], [-63.68113, -22.0544], [-63.70963, -21.99934], [-63.93287, -21.99934], [-64.22918, -22.55807], [-64.31489, -22.88824], [-64.35108, -22.73282], [-64.4176, -22.67692], [-64.58888, -22.25035], [-64.67174, -22.18957], [-64.90014, -22.12136], [-64.99524, -22.08255], [-65.47435, -22.08908], [-65.57743, -22.07675], [-65.58694, -22.09794], [-65.61166, -22.09504], [-65.7467, -22.10105], [-65.9261, -21.93335], [-66.04832, -21.9187], [-66.03836, -21.84829], [-66.24077, -21.77837], [-66.29714, -22.08741], [-66.7298, -22.23644], [-67.18382, -22.81525], [-66.99632, -22.99839], [-67.33563, -24.04237], [-68.24825, -24.42596], [-68.56909, -24.69831], [-68.38372, -25.08636], [-68.57622, -25.32505], [-68.38372, -26.15353], [-68.56909, -26.28146], [-68.59048, -26.49861], [-68.27677, -26.90626], [-68.43363, -27.08414], [-68.77586, -27.16029], [-69.22504, -27.95042], [-69.66709, -28.44055], [-69.80969, -29.07185], [-69.99507, -29.28351], [-69.8596, -30.26131], [-70.14479, -30.36595], [-70.55832, -31.51559], [-69.88099, -33.34489], [-69.87386, -34.13344], [-70.49416, -35.24145], [-70.38008, -36.02375], [-70.95047, -36.4321], [-71.24279, -37.20264], [-70.89532, -38.6923], [-71.37826, -38.91474], [-71.92726, -40.72714], [-71.74901, -42.11711], [-72.15541, -42.15941], [-72.14828, -42.85321], [-71.64206, -43.64774], [-71.81318, -44.38097], [-71.16436, -44.46244], [-71.26418, -44.75684], [-72.06985, -44.81756], [-71.35687, -45.22075], [-71.75614, -45.61611], [-71.68577, -46.55385], [-71.94152, -47.13595], [-72.50478, -47.80586], [-72.27662, -48.28727], [-72.54042, -48.52392], [-72.56894, -48.81116], [-73.09655, -49.14342], [-73.45156, -49.79461], [-73.55259, -49.92488], [-73.15765, -50.78337], [-72.31343, -50.58411]]]] } },
22676     { type: "Feature", properties: { iso1A2: "AS", iso1A3: "ASM", iso1N3: "016", wikidata: "Q16641", nameEn: "American Samoa", aliases: ["US-AS"], country: "US", groups: ["Q1352230", "061", "009", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 684"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-171.39864, -10.21587], [-170.99605, -15.1275], [-166.32598, -15.26169], [-171.39864, -10.21587]]]] } },
22677     { type: "Feature", properties: { iso1A2: "AT", iso1A3: "AUT", iso1N3: "040", wikidata: "Q40", nameEn: "Austria", groups: ["EU", "155", "150", "UN"], callingCodes: ["43"] }, geometry: { type: "MultiPolygon", coordinates: [[[[15.34823, 48.98444], [15.28305, 48.98831], [15.26177, 48.95766], [15.16358, 48.94278], [15.15534, 48.99056], [14.99878, 49.01444], [14.97612, 48.96983], [14.98917, 48.90082], [14.95072, 48.79101], [14.98032, 48.77959], [14.9782, 48.7766], [14.98112, 48.77524], [14.9758, 48.76857], [14.95641, 48.75915], [14.94773, 48.76268], [14.81545, 48.7874], [14.80821, 48.77711], [14.80584, 48.73489], [14.72756, 48.69502], [14.71794, 48.59794], [14.66762, 48.58215], [14.60808, 48.62881], [14.56139, 48.60429], [14.4587, 48.64695], [14.43076, 48.58855], [14.33909, 48.55852], [14.20691, 48.5898], [14.09104, 48.5943], [14.01482, 48.63788], [14.06151, 48.66873], [13.84023, 48.76988], [13.82266, 48.75544], [13.81863, 48.73257], [13.79337, 48.71375], [13.81791, 48.69832], [13.81283, 48.68426], [13.81901, 48.6761], [13.82609, 48.62345], [13.80038, 48.59487], [13.80519, 48.58026], [13.76921, 48.55324], [13.7513, 48.5624], [13.74816, 48.53058], [13.72802, 48.51208], [13.66113, 48.53558], [13.65186, 48.55092], [13.62508, 48.55501], [13.59705, 48.57013], [13.57535, 48.55912], [13.51291, 48.59023], [13.50131, 48.58091], [13.50663, 48.57506], [13.46967, 48.55157], [13.45214, 48.56472], [13.43695, 48.55776], [13.45727, 48.51092], [13.42527, 48.45711], [13.43929, 48.43386], [13.40709, 48.37292], [13.30897, 48.31575], [13.26039, 48.29422], [13.18093, 48.29577], [13.126, 48.27867], [13.0851, 48.27711], [13.02083, 48.25689], [12.95306, 48.20629], [12.87126, 48.20318], [12.84475, 48.16556], [12.836, 48.1647], [12.8362, 48.15876], [12.82673, 48.15245], [12.80676, 48.14979], [12.78595, 48.12445], [12.7617, 48.12796], [12.74973, 48.10885], [12.76141, 48.07373], [12.8549, 48.01122], [12.87476, 47.96195], [12.91683, 47.95647], [12.9211, 47.95135], [12.91985, 47.94069], [12.92668, 47.93879], [12.93419, 47.94063], [12.93642, 47.94436], [12.93886, 47.94046], [12.94163, 47.92927], [13.00588, 47.84374], [12.98543, 47.82896], [12.96311, 47.79957], [12.93202, 47.77302], [12.94371, 47.76281], [12.9353, 47.74788], [12.91711, 47.74026], [12.90274, 47.72513], [12.91333, 47.7178], [12.92969, 47.71094], [12.98578, 47.7078], [13.01382, 47.72116], [13.07692, 47.68814], [13.09562, 47.63304], [13.06407, 47.60075], [13.06641, 47.58577], [13.04537, 47.58183], [13.05355, 47.56291], [13.03252, 47.53373], [13.04537, 47.49426], [12.9998, 47.46267], [12.98344, 47.48716], [12.9624, 47.47452], [12.85256, 47.52741], [12.84672, 47.54556], [12.80699, 47.54477], [12.77427, 47.58025], [12.82101, 47.61493], [12.76492, 47.64485], [12.77777, 47.66689], [12.7357, 47.6787], [12.6071, 47.6741], [12.57438, 47.63238], [12.53816, 47.63553], [12.50076, 47.62293], [12.44117, 47.6741], [12.43883, 47.6977], [12.37222, 47.68433], [12.336, 47.69534], [12.27991, 47.68827], [12.26004, 47.67725], [12.24017, 47.69534], [12.26238, 47.73544], [12.2542, 47.7433], [12.22571, 47.71776], [12.18303, 47.70065], [12.16217, 47.70105], [12.16769, 47.68167], [12.18347, 47.66663], [12.18507, 47.65984], [12.19895, 47.64085], [12.20801, 47.61082], [12.20398, 47.60667], [12.18568, 47.6049], [12.17737, 47.60121], [12.18145, 47.61019], [12.17824, 47.61506], [12.13734, 47.60639], [12.05788, 47.61742], [12.02282, 47.61033], [12.0088, 47.62451], [11.85572, 47.60166], [11.84052, 47.58354], [11.63934, 47.59202], [11.60681, 47.57881], [11.58811, 47.55515], [11.58578, 47.52281], [11.52618, 47.50939], [11.4362, 47.51413], [11.38128, 47.47465], [11.4175, 47.44621], [11.33804, 47.44937], [11.29597, 47.42566], [11.27844, 47.39956], [11.22002, 47.3964], [11.25157, 47.43277], [11.20482, 47.43198], [11.12536, 47.41222], [11.11835, 47.39719], [10.97111, 47.39561], [10.97111, 47.41617], [10.98513, 47.42882], [10.92437, 47.46991], [10.93839, 47.48018], [10.90918, 47.48571], [10.87061, 47.4786], [10.86945, 47.5015], [10.91268, 47.51334], [10.88814, 47.53701], [10.77596, 47.51729], [10.7596, 47.53228], [10.6965, 47.54253], [10.68832, 47.55752], [10.63456, 47.5591], [10.60337, 47.56755], [10.56912, 47.53584], [10.48849, 47.54057], [10.47329, 47.58552], [10.43473, 47.58394], [10.44992, 47.5524], [10.4324, 47.50111], [10.44291, 47.48453], [10.46278, 47.47901], [10.47446, 47.43318], [10.4359, 47.41183], [10.4324, 47.38494], [10.39851, 47.37623], [10.33424, 47.30813], [10.23257, 47.27088], [10.17531, 47.27167], [10.17648, 47.29149], [10.2147, 47.31014], [10.19998, 47.32832], [10.23757, 47.37609], [10.22774, 47.38904], [10.2127, 47.38019], [10.17648, 47.38889], [10.16362, 47.36674], [10.11805, 47.37228], [10.09819, 47.35724], [10.06897, 47.40709], [10.1052, 47.4316], [10.09001, 47.46005], [10.07131, 47.45531], [10.03859, 47.48927], [10.00003, 47.48216], [9.96029, 47.53899], [9.92407, 47.53111], [9.87733, 47.54688], [9.87499, 47.52953], [9.8189, 47.54688], [9.82591, 47.58158], [9.80254, 47.59419], [9.76748, 47.5934], [9.72736, 47.53457], [9.55125, 47.53629], [9.56312, 47.49495], [9.58208, 47.48344], [9.59482, 47.46305], [9.60205, 47.46165], [9.60484, 47.46358], [9.60841, 47.47178], [9.62158, 47.45858], [9.62475, 47.45685], [9.6423, 47.45599], [9.65728, 47.45383], [9.65863, 47.44847], [9.64483, 47.43842], [9.6446, 47.43233], [9.65043, 47.41937], [9.65136, 47.40504], [9.6629, 47.39591], [9.67334, 47.39191], [9.67445, 47.38429], [9.6711, 47.37824], [9.66243, 47.37136], [9.65427, 47.36824], [9.62476, 47.36639], [9.59978, 47.34671], [9.58513, 47.31334], [9.55857, 47.29919], [9.54773, 47.2809], [9.53116, 47.27029], [9.56766, 47.24281], [9.55176, 47.22585], [9.56981, 47.21926], [9.58264, 47.20673], [9.56539, 47.17124], [9.62623, 47.14685], [9.63395, 47.08443], [9.61216, 47.07732], [9.60717, 47.06091], [9.87935, 47.01337], [9.88266, 46.93343], [9.98058, 46.91434], [10.10715, 46.84296], [10.22675, 46.86942], [10.24128, 46.93147], [10.30031, 46.92093], [10.36933, 47.00212], [10.48376, 46.93891], [10.47197, 46.85698], [10.54783, 46.84505], [10.66405, 46.87614], [10.75753, 46.82258], [10.72974, 46.78972], [11.00764, 46.76896], [11.10618, 46.92966], [11.33355, 46.99862], [11.50739, 47.00644], [11.74789, 46.98484], [12.19254, 47.09331], [12.21781, 47.03996], [12.11675, 47.01241], [12.2006, 46.88854], [12.27591, 46.88651], [12.38708, 46.71529], [12.59992, 46.6595], [12.94445, 46.60401], [13.27627, 46.56059], [13.64088, 46.53438], [13.7148, 46.5222], [13.89837, 46.52331], [14.00422, 46.48474], [14.04002, 46.49117], [14.12097, 46.47724], [14.15989, 46.43327], [14.28326, 46.44315], [14.314, 46.43327], [14.42608, 46.44614], [14.45877, 46.41717], [14.52176, 46.42617], [14.56463, 46.37208], [14.5942, 46.43434], [14.66892, 46.44936], [14.72185, 46.49974], [14.81836, 46.51046], [14.83549, 46.56614], [14.86419, 46.59411], [14.87129, 46.61], [14.92283, 46.60848], [14.96002, 46.63459], [14.98024, 46.6009], [15.01451, 46.641], [15.14215, 46.66131], [15.23711, 46.63994], [15.41235, 46.65556], [15.45514, 46.63697], [15.46906, 46.61321], [15.54431, 46.6312], [15.55333, 46.64988], [15.54533, 46.66985], [15.59826, 46.68908], [15.62317, 46.67947], [15.63255, 46.68069], [15.6365, 46.6894], [15.6543, 46.69228], [15.6543, 46.70616], [15.67411, 46.70735], [15.69523, 46.69823], [15.72279, 46.69548], [15.73823, 46.70011], [15.76771, 46.69863], [15.78518, 46.70712], [15.8162, 46.71897], [15.87691, 46.7211], [15.94864, 46.68769], [15.98512, 46.68463], [15.99988, 46.67947], [16.04036, 46.6549], [16.04347, 46.68694], [16.02808, 46.71094], [15.99769, 46.7266], [15.98432, 46.74991], [15.99126, 46.78199], [15.99054, 46.82772], [16.05786, 46.83927], [16.10983, 46.867], [16.19904, 46.94134], [16.22403, 46.939], [16.27594, 46.9643], [16.28202, 47.00159], [16.51369, 47.00084], [16.43936, 47.03548], [16.52176, 47.05747], [16.46134, 47.09395], [16.52863, 47.13974], [16.44932, 47.14418], [16.46442, 47.16845], [16.4523, 47.18812], [16.42801, 47.18422], [16.41739, 47.20649], [16.43663, 47.21127], [16.44142, 47.25079], [16.47782, 47.25918], [16.45104, 47.41181], [16.49908, 47.39416], [16.52414, 47.41007], [16.57152, 47.40868], [16.6718, 47.46139], [16.64821, 47.50155], [16.71059, 47.52692], [16.64193, 47.63114], [16.58699, 47.61772], [16.4222, 47.66537], [16.55129, 47.72268], [16.53514, 47.73837], [16.54779, 47.75074], [16.61183, 47.76171], [16.65679, 47.74197], [16.72089, 47.73469], [16.7511, 47.67878], [16.82938, 47.68432], [16.86509, 47.72268], [16.87538, 47.68895], [17.08893, 47.70928], [17.05048, 47.79377], [17.07039, 47.81129], [17.00997, 47.86245], [17.08275, 47.87719], [17.11022, 47.92461], [17.09786, 47.97336], [17.16001, 48.00636], [17.07039, 48.0317], [17.09168, 48.09366], [17.05735, 48.14179], [17.02919, 48.13996], [16.97701, 48.17385], [16.89461, 48.31332], [16.90903, 48.32519], [16.84243, 48.35258], [16.83317, 48.38138], [16.83588, 48.3844], [16.8497, 48.38321], [16.85204, 48.44968], [16.94611, 48.53614], [16.93955, 48.60371], [16.90354, 48.71541], [16.79779, 48.70998], [16.71883, 48.73806], [16.68518, 48.7281], [16.67008, 48.77699], [16.46134, 48.80865], [16.40915, 48.74576], [16.37345, 48.729], [16.06034, 48.75436], [15.84404, 48.86921], [15.78087, 48.87644], [15.75341, 48.8516], [15.6921, 48.85973], [15.61622, 48.89541], [15.51357, 48.91549], [15.48027, 48.94481], [15.34823, 48.98444]]]] } },
22678     { type: "Feature", properties: { iso1A2: "AU", iso1A3: "AUS", iso1N3: "036", wikidata: "Q408", nameEn: "Australia" }, geometry: null },
22679     { type: "Feature", properties: { iso1A2: "AW", iso1A3: "ABW", iso1N3: "533", wikidata: "Q21203", nameEn: "Aruba", aliases: ["NL-AW"], country: "NL", groups: ["Q1451600", "029", "003", "419", "019", "UN"], callingCodes: ["297"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-70.00823, 12.98375], [-70.35625, 12.58277], [-69.60231, 12.17], [-70.00823, 12.98375]]]] } },
22680     { type: "Feature", properties: { iso1A2: "AX", iso1A3: "ALA", iso1N3: "248", wikidata: "Q5689", nameEn: "\xC5land Islands", country: "FI", groups: ["EU", "154", "150", "UN"], callingCodes: ["358 18", "358 457"] }, geometry: { type: "MultiPolygon", coordinates: [[[[19.08191, 60.19152], [20.5104, 59.15546], [21.35468, 59.67511], [21.02509, 60.12142], [21.08159, 60.20167], [21.15143, 60.54555], [20.96741, 60.71528], [19.23413, 60.61414], [19.08191, 60.19152]]]] } },
22681     { type: "Feature", properties: { iso1A2: "AZ", iso1A3: "AZE", iso1N3: "031", wikidata: "Q227", nameEn: "Azerbaijan", groups: ["145", "142", "UN"], callingCodes: ["994"] }, geometry: { type: "MultiPolygon", coordinates: [[[[46.42738, 41.91323], [46.3984, 41.84399], [46.30863, 41.79133], [46.23962, 41.75811], [46.20538, 41.77205], [46.17891, 41.72094], [46.19759, 41.62327], [46.24429, 41.59883], [46.26531, 41.63339], [46.28182, 41.60089], [46.3253, 41.60912], [46.34039, 41.5947], [46.34126, 41.57454], [46.29794, 41.5724], [46.33925, 41.4963], [46.40307, 41.48464], [46.4669, 41.43331], [46.63658, 41.37727], [46.72375, 41.28609], [46.66148, 41.20533], [46.63969, 41.09515], [46.55096, 41.1104], [46.48558, 41.0576], [46.456, 41.09984], [46.37661, 41.10805], [46.27698, 41.19011], [46.13221, 41.19479], [45.95786, 41.17956], [45.80842, 41.2229], [45.69946, 41.29545], [45.75705, 41.35157], [45.71035, 41.36208], [45.68389, 41.3539], [45.45973, 41.45898], [45.4006, 41.42402], [45.31352, 41.47168], [45.26285, 41.46433], [45.1797, 41.42231], [45.09867, 41.34065], [45.0133, 41.29747], [45.05497, 41.2464], [45.02932, 41.2101], [45.05201, 41.19211], [45.11811, 41.19967], [45.1969, 41.168], [45.19942, 41.13299], [45.08028, 41.10917], [45.06784, 41.05379], [45.12923, 41.06059], [45.1313, 41.09369], [45.1634, 41.08082], [45.16493, 41.05068], [45.1994, 41.04518], [45.25897, 41.0027], [45.26162, 41.0228], [45.28859, 41.03757], [45.35677, 40.99784], [45.39725, 41.02603], [45.44083, 41.01663], [45.40814, 40.97904], [45.60584, 40.87436], [45.55914, 40.78366], [45.4206, 40.7424], [45.35366, 40.65979], [45.45484, 40.57707], [45.42994, 40.53804], [45.65098, 40.37696], [45.95609, 40.27846], [45.97944, 40.181], [45.83779, 39.98925], [45.78642, 40.03218], [45.59806, 40.0131], [45.60895, 39.97733], [45.7833, 39.9475], [45.82533, 39.82925], [45.96543, 39.78859], [46.18493, 39.60533], [46.40286, 39.63651], [46.42465, 39.57534], [46.52117, 39.58734], [46.57098, 39.56694], [46.57721, 39.54414], [46.51027, 39.52373], [46.53051, 39.47809], [46.4013, 39.45405], [46.37795, 39.42039], [46.43244, 39.35181], [46.50093, 39.33736], [46.56476, 39.24942], [46.63481, 39.23013], [46.58032, 39.21204], [46.54141, 39.15895], [46.52584, 39.18912], [46.44022, 39.19636], [46.54296, 39.07078], [46.51805, 38.94982], [46.53497, 38.86548], [46.75752, 39.03231], [46.83822, 39.13143], [46.92539, 39.16644], [46.95341, 39.13505], [47.05771, 39.20143], [47.05927, 39.24846], [47.31301, 39.37492], [47.38978, 39.45999], [47.50099, 39.49615], [47.84774, 39.66285], [47.98977, 39.70999], [48.34264, 39.42935], [48.37385, 39.37584], [48.15984, 39.30028], [48.12404, 39.25208], [48.15361, 39.19419], [48.31239, 39.09278], [48.33884, 39.03022], [48.28437, 38.97186], [48.08627, 38.94434], [48.07734, 38.91616], [48.01409, 38.90333], [48.02581, 38.82705], [48.24773, 38.71883], [48.3146, 38.59958], [48.45084, 38.61013], [48.58793, 38.45076], [48.62217, 38.40198], [48.70001, 38.40564], [48.78979, 38.45026], [48.81072, 38.44853], [48.84969, 38.45015], [48.88288, 38.43975], [52.39847, 39.43556], [48.80971, 41.95365], [48.5867, 41.84306], [48.55078, 41.77917], [48.42301, 41.65444], [48.40277, 41.60441], [48.2878, 41.56221], [48.22064, 41.51472], [48.07587, 41.49957], [47.87973, 41.21798], [47.75831, 41.19455], [47.62288, 41.22969], [47.54504, 41.20275], [47.49004, 41.26366], [47.34579, 41.27884], [47.10762, 41.59044], [47.03757, 41.55434], [46.99554, 41.59743], [47.00955, 41.63583], [46.8134, 41.76252], [46.75269, 41.8623], [46.58924, 41.80547], [46.5332, 41.87389], [46.42738, 41.91323]], [[45.50279, 40.58424], [45.47927, 40.65023], [45.51825, 40.67382], [45.56071, 40.64765], [45.50279, 40.58424]]], [[[45.00864, 41.03411], [45.03792, 41.03938], [45.04517, 41.06653], [45.03406, 41.07931], [45.00864, 41.09407], [44.97169, 41.09176], [44.95383, 41.07553], [44.96031, 41.06345], [44.9903, 41.05657], [45.00864, 41.03411]]], [[[45.21324, 40.9817], [45.23095, 40.97828], [45.23487, 41.00226], [45.20625, 41.01484], [45.18382, 41.0066], [45.19312, 40.98998], [45.20518, 40.99348], [45.21219, 40.99001], [45.21324, 40.9817]]], [[[45.46992, 39.49888], [45.29606, 39.57654], [45.30385, 39.61373], [45.23535, 39.61373], [45.21784, 39.58074], [45.17464, 39.58614], [45.18554, 39.67846], [45.06604, 39.79277], [44.92869, 39.72157], [44.88354, 39.74432], [44.75779, 39.7148], [44.80977, 39.65768], [44.81043, 39.62677], [44.88916, 39.59653], [44.96746, 39.42998], [45.05932, 39.36435], [45.08751, 39.35052], [45.16168, 39.21952], [45.30489, 39.18333], [45.40148, 39.09007], [45.40452, 39.07224], [45.44811, 39.04927], [45.44966, 38.99243], [45.6131, 38.964], [45.6155, 38.94304], [45.65172, 38.95199], [45.83883, 38.90768], [45.90266, 38.87739], [45.94624, 38.89072], [46.00228, 38.87376], [46.06766, 38.87861], [46.14785, 38.84206], [46.06973, 39.0744], [46.02303, 39.09978], [45.99774, 39.28931], [45.79225, 39.3695], [45.83, 39.46487], [45.80804, 39.56716], [45.70547, 39.60174], [45.46992, 39.49888]]]] } },
22682     { type: "Feature", properties: { iso1A2: "BA", iso1A3: "BIH", iso1N3: "070", wikidata: "Q225", nameEn: "Bosnia and Herzegovina", groups: ["039", "150", "UN"], callingCodes: ["387"] }, geometry: { type: "MultiPolygon", coordinates: [[[[17.84826, 45.04489], [17.66571, 45.13408], [17.59104, 45.10816], [17.51469, 45.10791], [17.47589, 45.12656], [17.45615, 45.12523], [17.4498, 45.16119], [17.41229, 45.13335], [17.33573, 45.14521], [17.32092, 45.16246], [17.26815, 45.18444], [17.25131, 45.14957], [17.24325, 45.146], [17.18438, 45.14764], [17.0415, 45.20759], [16.9385, 45.22742], [16.92405, 45.27607], [16.83804, 45.18951], [16.81137, 45.18434], [16.78219, 45.19002], [16.74845, 45.20393], [16.64962, 45.20714], [16.60194, 45.23042], [16.56559, 45.22307], [16.5501, 45.2212], [16.52982, 45.22713], [16.49155, 45.21153], [16.4634, 45.14522], [16.40023, 45.1147], [16.38309, 45.05955], [16.38219, 45.05139], [16.3749, 45.05206], [16.35863, 45.03529], [16.35404, 45.00241], [16.29036, 44.99732], [16.12153, 45.09616], [15.98412, 45.23088], [15.83512, 45.22459], [15.76371, 45.16508], [15.78842, 45.11519], [15.74585, 45.0638], [15.78568, 44.97401], [15.74723, 44.96818], [15.76096, 44.87045], [15.79472, 44.8455], [15.72584, 44.82334], [15.8255, 44.71501], [15.89348, 44.74964], [16.05828, 44.61538], [16.00884, 44.58605], [16.03012, 44.55572], [16.10566, 44.52586], [16.16814, 44.40679], [16.12969, 44.38275], [16.21346, 44.35231], [16.18688, 44.27012], [16.36864, 44.08263], [16.43662, 44.07523], [16.43629, 44.02826], [16.50528, 44.0244], [16.55472, 43.95326], [16.70922, 43.84887], [16.75316, 43.77157], [16.80736, 43.76011], [17.00585, 43.58037], [17.15828, 43.49376], [17.24411, 43.49376], [17.29699, 43.44542], [17.25579, 43.40353], [17.286, 43.33065], [17.46986, 43.16559], [17.64268, 43.08595], [17.70879, 42.97223], [17.5392, 42.92787], [17.6444, 42.88641], [17.68151, 42.92725], [17.7948, 42.89556], [17.80854, 42.9182], [17.88201, 42.83668], [18.24318, 42.6112], [18.36197, 42.61423], [18.43735, 42.55921], [18.49778, 42.58409], [18.53751, 42.57376], [18.55504, 42.58409], [18.52232, 42.62279], [18.57373, 42.64429], [18.54841, 42.68328], [18.54603, 42.69171], [18.55221, 42.69045], [18.56789, 42.72074], [18.47324, 42.74992], [18.45921, 42.81682], [18.47633, 42.85829], [18.4935, 42.86433], [18.49661, 42.89306], [18.49076, 42.95553], [18.52232, 43.01451], [18.66254, 43.03928], [18.64735, 43.14766], [18.66605, 43.2056], [18.71747, 43.2286], [18.6976, 43.25243], [18.76538, 43.29838], [18.85342, 43.32426], [18.84794, 43.33735], [18.83912, 43.34795], [18.90911, 43.36383], [18.95819, 43.32899], [18.95001, 43.29327], [19.00844, 43.24988], [19.04233, 43.30008], [19.08206, 43.29668], [19.08673, 43.31453], [19.04071, 43.397], [19.01078, 43.43854], [18.96053, 43.45042], [18.95469, 43.49367], [18.91379, 43.50299], [19.01078, 43.55806], [19.04934, 43.50384], [19.13933, 43.5282], [19.15685, 43.53943], [19.22807, 43.5264], [19.24774, 43.53061], [19.2553, 43.5938], [19.33426, 43.58833], [19.36653, 43.60921], [19.41941, 43.54056], [19.42696, 43.57987], [19.50455, 43.58385], [19.5176, 43.71403], [19.3986, 43.79668], [19.23465, 43.98764], [19.24363, 44.01502], [19.38439, 43.96611], [19.52515, 43.95573], [19.56498, 43.99922], [19.61836, 44.01464], [19.61991, 44.05254], [19.57467, 44.04716], [19.55999, 44.06894], [19.51167, 44.08158], [19.47321, 44.1193], [19.48386, 44.14332], [19.47338, 44.15034], [19.43905, 44.13088], [19.40927, 44.16722], [19.3588, 44.18353], [19.34773, 44.23244], [19.32464, 44.27185], [19.26945, 44.26957], [19.23306, 44.26097], [19.20508, 44.2917], [19.18328, 44.28383], [19.16741, 44.28648], [19.13332, 44.31492], [19.13556, 44.338], [19.11547, 44.34218], [19.1083, 44.3558], [19.11865, 44.36712], [19.10298, 44.36924], [19.10365, 44.37795], [19.10704, 44.38249], [19.10749, 44.39421], [19.11785, 44.40313], [19.14681, 44.41463], [19.14837, 44.45253], [19.12278, 44.50132], [19.13369, 44.52521], [19.16699, 44.52197], [19.26388, 44.65412], [19.32543, 44.74058], [19.36722, 44.88164], [19.18183, 44.92055], [19.01994, 44.85493], [18.8704, 44.85097], [18.76347, 44.90669], [18.76369, 44.93707], [18.80661, 44.93561], [18.78357, 44.97741], [18.65723, 45.07544], [18.47939, 45.05871], [18.41896, 45.11083], [18.32077, 45.1021], [18.24387, 45.13699], [18.1624, 45.07654], [18.03121, 45.12632], [18.01594, 45.15163], [17.99479, 45.14958], [17.97834, 45.13831], [17.97336, 45.12245], [17.93706, 45.08016], [17.87148, 45.04645], [17.84826, 45.04489]]]] } },
22683     { type: "Feature", properties: { iso1A2: "BB", iso1A3: "BRB", iso1N3: "052", wikidata: "Q244", nameEn: "Barbados", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", callingCodes: ["1 246"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-58.56442, 13.24471], [-59.80731, 13.87556], [-59.82929, 12.70644], [-58.56442, 13.24471]]]] } },
22684     { type: "Feature", properties: { iso1A2: "BD", iso1A3: "BGD", iso1N3: "050", wikidata: "Q902", nameEn: "Bangladesh", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["880"] }, geometry: { type: "MultiPolygon", coordinates: [[[[89.15869, 26.13708], [89.08899, 26.38845], [88.95612, 26.4564], [88.92357, 26.40711], [88.91321, 26.37984], [89.05328, 26.2469], [88.85004, 26.23211], [88.78961, 26.31093], [88.67837, 26.26291], [88.69485, 26.38353], [88.62144, 26.46783], [88.4298, 26.54489], [88.41196, 26.63837], [88.33093, 26.48929], [88.35153, 26.45241], [88.36938, 26.48683], [88.48749, 26.45855], [88.51649, 26.35923], [88.35153, 26.29123], [88.34757, 26.22216], [88.1844, 26.14417], [88.16581, 26.0238], [88.08804, 25.91334], [88.13138, 25.78773], [88.242, 25.80811], [88.45103, 25.66245], [88.4559, 25.59227], [88.677, 25.46959], [88.81296, 25.51546], [88.85278, 25.34679], [89.01105, 25.30303], [89.00463, 25.26583], [88.94067, 25.18534], [88.44766, 25.20149], [88.46277, 25.07468], [88.33917, 24.86803], [88.27325, 24.88796], [88.21832, 24.96642], [88.14004, 24.93529], [88.15515, 24.85806], [88.00683, 24.66477], [88.08786, 24.63232], [88.12296, 24.51301], [88.50934, 24.32474], [88.68801, 24.31464], [88.74841, 24.1959], [88.6976, 24.14703], [88.73743, 23.91751], [88.66189, 23.87607], [88.58087, 23.87105], [88.56507, 23.64044], [88.74841, 23.47361], [88.79351, 23.50535], [88.79254, 23.46028], [88.71133, 23.2492], [88.99148, 23.21134], [88.86377, 23.08759], [88.88327, 23.03885], [88.87063, 22.95235], [88.96713, 22.83346], [88.9151, 22.75228], [88.94614, 22.66941], [88.9367, 22.58527], [89.07114, 22.15335], [89.08044, 21.41871], [92.47409, 20.38654], [92.26071, 21.05697], [92.17752, 21.17445], [92.20087, 21.337], [92.37939, 21.47764], [92.43158, 21.37025], [92.55105, 21.3856], [92.60187, 21.24615], [92.68152, 21.28454], [92.59775, 21.6092], [92.62187, 21.87037], [92.60949, 21.97638], [92.56616, 22.13554], [92.60029, 22.1522], [92.5181, 22.71441], [92.37665, 22.9435], [92.38214, 23.28705], [92.26541, 23.70392], [92.15417, 23.73409], [92.04706, 23.64229], [91.95093, 23.73284], [91.95642, 23.47361], [91.84789, 23.42235], [91.76417, 23.26619], [91.81634, 23.08001], [91.7324, 23.00043], [91.61571, 22.93929], [91.54993, 23.01051], [91.46615, 23.2328], [91.4035, 23.27522], [91.40848, 23.07117], [91.36453, 23.06612], [91.28293, 23.37538], [91.15579, 23.6599], [91.25192, 23.83463], [91.22308, 23.89616], [91.29587, 24.0041], [91.35741, 23.99072], [91.37414, 24.10693], [91.55542, 24.08687], [91.63782, 24.1132], [91.65292, 24.22095], [91.73257, 24.14703], [91.76004, 24.23848], [91.82596, 24.22345], [91.89258, 24.14674], [91.96603, 24.3799], [92.11662, 24.38997], [92.15796, 24.54435], [92.25854, 24.9191], [92.38626, 24.86055], [92.49887, 24.88796], [92.39147, 25.01471], [92.33957, 25.07593], [92.0316, 25.1834], [91.63648, 25.12846], [91.25517, 25.20677], [90.87427, 25.15799], [90.65042, 25.17788], [90.40034, 25.1534], [90.1155, 25.22686], [89.90478, 25.31038], [89.87629, 25.28337], [89.83371, 25.29548], [89.84086, 25.31854], [89.81208, 25.37244], [89.86129, 25.61714], [89.84388, 25.70042], [89.80585, 25.82489], [89.86592, 25.93115], [89.77728, 26.04254], [89.77865, 26.08387], [89.73581, 26.15818], [89.70201, 26.15138], [89.63968, 26.22595], [89.57101, 25.9682], [89.53515, 26.00382], [89.35953, 26.0077], [89.15869, 26.13708]]]] } },
22685     { type: "Feature", properties: { iso1A2: "BE", iso1A3: "BEL", iso1N3: "056", wikidata: "Q31", nameEn: "Belgium", groups: ["EU", "155", "150", "UN"], callingCodes: ["32"] }, geometry: { type: "MultiPolygon", coordinates: [[[[4.93295, 51.44945], [4.93909, 51.44632], [4.9524, 51.45014], [4.95244, 51.45207], [4.93295, 51.44945]]], [[[4.91493, 51.4353], [4.92652, 51.43329], [4.92952, 51.42984], [4.93986, 51.43064], [4.94265, 51.44003], [4.93471, 51.43861], [4.93416, 51.44185], [4.94025, 51.44193], [4.93544, 51.44634], [4.92879, 51.44161], [4.92815, 51.43856], [4.92566, 51.44273], [4.92811, 51.4437], [4.92287, 51.44741], [4.91811, 51.44621], [4.92227, 51.44252], [4.91935, 51.43634], [4.91493, 51.4353]]], [[[4.82946, 51.4213], [4.82409, 51.44736], [4.84139, 51.4799], [4.78803, 51.50284], [4.77321, 51.50529], [4.74578, 51.48937], [4.72935, 51.48424], [4.65442, 51.42352], [4.57489, 51.4324], [4.53521, 51.4243], [4.52846, 51.45002], [4.54675, 51.47265], [4.5388, 51.48184], [4.47736, 51.4778], [4.38122, 51.44905], [4.39747, 51.43316], [4.38064, 51.41965], [4.43777, 51.36989], [4.39292, 51.35547], [4.34086, 51.35738], [4.33265, 51.37687], [4.21923, 51.37443], [4.24024, 51.35371], [4.16721, 51.29348], [4.05165, 51.24171], [4.01957, 51.24504], [3.97889, 51.22537], [3.90125, 51.20371], [3.78783, 51.2151], [3.78999, 51.25766], [3.58939, 51.30064], [3.51502, 51.28697], [3.52698, 51.2458], [3.43488, 51.24135], [3.41704, 51.25933], [3.38289, 51.27331], [3.35847, 51.31572], [3.38696, 51.33436], [3.36263, 51.37112], [2.56575, 51.85301], [2.18458, 51.52087], [2.55904, 51.07014], [2.57551, 51.00326], [2.63074, 50.94746], [2.59093, 50.91751], [2.63331, 50.81457], [2.71165, 50.81295], [2.81056, 50.71773], [2.8483, 50.72276], [2.86985, 50.7033], [2.87937, 50.70298], [2.88504, 50.70656], [2.90069, 50.69263], [2.91036, 50.6939], [2.90873, 50.702], [2.95019, 50.75138], [2.96778, 50.75242], [3.00537, 50.76588], [3.04314, 50.77674], [3.09163, 50.77717], [3.10614, 50.78303], [3.11206, 50.79416], [3.11987, 50.79188], [3.1257, 50.78603], [3.15017, 50.79031], [3.16476, 50.76843], [3.18339, 50.74981], [3.18811, 50.74025], [3.20064, 50.73547], [3.19017, 50.72569], [3.20845, 50.71662], [3.22042, 50.71019], [3.24593, 50.71389], [3.26063, 50.70086], [3.26141, 50.69151], [3.2536, 50.68977], [3.264, 50.67668], [3.23951, 50.6585], [3.2729, 50.60718], [3.28575, 50.52724], [3.37693, 50.49538], [3.44629, 50.51009], [3.47385, 50.53397], [3.51564, 50.5256], [3.49509, 50.48885], [3.5683, 50.50192], [3.58361, 50.49049], [3.61014, 50.49568], [3.64426, 50.46275], [3.66153, 50.45165], [3.67494, 50.40239], [3.67262, 50.38663], [3.65709, 50.36873], [3.66976, 50.34563], [3.71009, 50.30305], [3.70987, 50.3191], [3.73911, 50.34809], [3.84314, 50.35219], [3.90781, 50.32814], [3.96771, 50.34989], [4.0268, 50.35793], [4.0689, 50.3254], [4.10237, 50.31247], [4.10957, 50.30234], [4.11954, 50.30425], [4.13665, 50.25609], [4.16808, 50.25786], [4.15524, 50.2833], [4.17347, 50.28838], [4.17861, 50.27443], [4.20651, 50.27333], [4.21945, 50.25539], [4.15524, 50.21103], [4.16014, 50.19239], [4.13561, 50.13078], [4.20147, 50.13535], [4.23101, 50.06945], [4.16294, 50.04719], [4.13508, 50.01976], [4.14239, 49.98034], [4.20532, 49.95803], [4.31963, 49.97043], [4.35051, 49.95315], [4.43488, 49.94122], [4.51098, 49.94659], [4.5414, 49.96911], [4.68695, 49.99685], [4.70064, 50.09384], [4.75237, 50.11314], [4.82438, 50.16878], [4.83279, 50.15331], [4.88602, 50.15182], [4.8382, 50.06738], [4.78827, 49.95609], [4.88529, 49.9236], [4.85134, 49.86457], [4.86965, 49.82271], [4.85464, 49.78995], [4.96714, 49.79872], [5.09249, 49.76193], [5.14545, 49.70287], [5.26232, 49.69456], [5.31465, 49.66846], [5.33039, 49.6555], [5.30214, 49.63055], [5.3137, 49.61225], [5.33851, 49.61599], [5.34837, 49.62889], [5.3974, 49.61596], [5.43713, 49.5707], [5.46734, 49.52648], [5.46541, 49.49825], [5.55001, 49.52729], [5.60909, 49.51228], [5.64505, 49.55146], [5.75649, 49.54321], [5.7577, 49.55915], [5.77435, 49.56298], [5.79195, 49.55228], [5.81838, 49.54777], [5.84143, 49.5533], [5.84692, 49.55663], [5.8424, 49.56082], [5.87256, 49.57539], [5.86986, 49.58756], [5.84971, 49.58674], [5.84826, 49.5969], [5.8762, 49.60898], [5.87609, 49.62047], [5.88393, 49.62802], [5.88552, 49.63507], [5.90599, 49.63853], [5.90164, 49.6511], [5.9069, 49.66377], [5.86175, 49.67862], [5.86527, 49.69291], [5.88677, 49.70951], [5.86503, 49.72739], [5.84193, 49.72161], [5.82562, 49.72395], [5.83149, 49.74729], [5.82245, 49.75048], [5.78871, 49.7962], [5.75409, 49.79239], [5.74953, 49.81428], [5.74364, 49.82058], [5.74844, 49.82435], [5.7404, 49.83452], [5.74076, 49.83823], [5.74975, 49.83933], [5.74953, 49.84709], [5.75884, 49.84811], [5.74567, 49.85368], [5.75861, 49.85631], [5.75269, 49.8711], [5.78415, 49.87922], [5.73621, 49.89796], [5.77314, 49.93646], [5.77291, 49.96056], [5.80833, 49.96451], [5.81163, 49.97142], [5.83467, 49.97823], [5.83968, 49.9892], [5.82331, 49.99662], [5.81866, 50.01286], [5.8551, 50.02683], [5.86904, 50.04614], [5.85474, 50.06342], [5.8857, 50.07824], [5.89488, 50.11476], [5.95929, 50.13295], [5.96453, 50.17259], [6.02488, 50.18283], [6.03093, 50.16362], [6.06406, 50.15344], [6.08577, 50.17246], [6.12028, 50.16374], [6.1137, 50.13668], [6.1379, 50.12964], [6.15298, 50.14126], [6.14132, 50.14971], [6.14588, 50.17106], [6.18739, 50.1822], [6.18364, 50.20815], [6.16853, 50.2234], [6.208, 50.25179], [6.28797, 50.27458], [6.29949, 50.30887], [6.32488, 50.32333], [6.35701, 50.31139], [6.40641, 50.32425], [6.40785, 50.33557], [6.3688, 50.35898], [6.34406, 50.37994], [6.36852, 50.40776], [6.37219, 50.45397], [6.34005, 50.46083], [6.3465, 50.48833], [6.30809, 50.50058], [6.26637, 50.50272], [6.22335, 50.49578], [6.20599, 50.52089], [6.19193, 50.5212], [6.18716, 50.52653], [6.19579, 50.5313], [6.19735, 50.53576], [6.17802, 50.54179], [6.17739, 50.55875], [6.20281, 50.56952], [6.22581, 50.5907], [6.24005, 50.58732], [6.24888, 50.59869], [6.2476, 50.60392], [6.26957, 50.62444], [6.17852, 50.6245], [6.11707, 50.72231], [6.04428, 50.72861], [6.0406, 50.71848], [6.0326, 50.72647], [6.03889, 50.74618], [6.01976, 50.75398], [5.97545, 50.75441], [5.95942, 50.7622], [5.89132, 50.75124], [5.89129, 50.75125], [5.88734, 50.77092], [5.84888, 50.75448], [5.84548, 50.76542], [5.80673, 50.7558], [5.77513, 50.78308], [5.76533, 50.78159], [5.74356, 50.7691], [5.73904, 50.75674], [5.72216, 50.76398], [5.69469, 50.75529], [5.68091, 50.75804], [5.70107, 50.7827], [5.68995, 50.79641], [5.70118, 50.80764], [5.65259, 50.82309], [5.64009, 50.84742], [5.64504, 50.87107], [5.67886, 50.88142], [5.69858, 50.91046], [5.71626, 50.90796], [5.72644, 50.91167], [5.72545, 50.92312], [5.74644, 50.94723], [5.75927, 50.95601], [5.74752, 50.96202], [5.72875, 50.95428], [5.71864, 50.96092], [5.76242, 50.99703], [5.77688, 51.02483], [5.75961, 51.03113], [5.77258, 51.06196], [5.79835, 51.05834], [5.79903, 51.09371], [5.82921, 51.09328], [5.83226, 51.10585], [5.8109, 51.10861], [5.80798, 51.11661], [5.85508, 51.14445], [5.82564, 51.16753], [5.77697, 51.1522], [5.77735, 51.17845], [5.74617, 51.18928], [5.70344, 51.1829], [5.65528, 51.18736], [5.65145, 51.19788], [5.5603, 51.22249], [5.5569, 51.26544], [5.515, 51.29462], [5.48476, 51.30053], [5.46519, 51.2849], [5.4407, 51.28169], [5.41672, 51.26248], [5.347, 51.27502], [5.33886, 51.26314], [5.29716, 51.26104], [5.26461, 51.26693], [5.23814, 51.26064], [5.22542, 51.26888], [5.24244, 51.30495], [5.2002, 51.32243], [5.16222, 51.31035], [5.13377, 51.31592], [5.13105, 51.34791], [5.07102, 51.39469], [5.10456, 51.43163], [5.07891, 51.4715], [5.04774, 51.47022], [5.03281, 51.48679], [5.0106, 51.47167], [5.00393, 51.44406], [4.92152, 51.39487], [4.90016, 51.41404], [4.84988, 51.41502], [4.78941, 51.41102], [4.77229, 51.41337], [4.76577, 51.43046], [4.78314, 51.43319], [4.82946, 51.4213]]]] } },
22686     { type: "Feature", properties: { iso1A2: "BF", iso1A3: "BFA", iso1N3: "854", wikidata: "Q965", nameEn: "Burkina Faso", groups: ["011", "202", "002", "UN"], callingCodes: ["226"] }, geometry: { type: "MultiPolygon", coordinates: [[[[0.23859, 15.00135], [0.06588, 14.96961], [-0.24673, 15.07805], [-0.72004, 15.08655], [-1.05875, 14.7921], [-1.32166, 14.72774], [-1.68083, 14.50023], [-1.97945, 14.47709], [-1.9992, 14.19011], [-2.10223, 14.14878], [-2.47587, 14.29671], [-2.66175, 14.14713], [-2.84667, 14.05532], [-2.90831, 13.81174], [-2.88189, 13.64921], [-3.26407, 13.70699], [-3.28396, 13.5422], [-3.23599, 13.29035], [-3.43507, 13.27272], [-3.4313, 13.1588], [-3.54454, 13.1781], [-3.7911, 13.36665], [-3.96282, 13.38164], [-3.90558, 13.44375], [-3.96501, 13.49778], [-4.34477, 13.12927], [-4.21819, 12.95722], [-4.238, 12.71467], [-4.47356, 12.71252], [-4.41412, 12.31922], [-4.57703, 12.19875], [-4.54841, 12.1385], [-4.62546, 12.13204], [-4.62987, 12.06531], [-4.70692, 12.06746], [-4.72893, 12.01579], [-5.07897, 11.97918], [-5.26389, 11.84778], [-5.40258, 11.8327], [-5.26389, 11.75728], [-5.29251, 11.61715], [-5.22867, 11.60421], [-5.20665, 11.43811], [-5.25509, 11.36905], [-5.25949, 11.24816], [-5.32553, 11.21578], [-5.32994, 11.13371], [-5.49284, 11.07538], [-5.41579, 10.84628], [-5.47083, 10.75329], [-5.46643, 10.56074], [-5.51058, 10.43177], [-5.39602, 10.2929], [-5.12465, 10.29788], [-4.96453, 9.99923], [-4.96621, 9.89132], [-4.6426, 9.70696], [-4.31392, 9.60062], [-4.25999, 9.76012], [-3.69703, 9.94279], [-3.31779, 9.91125], [-3.27228, 9.84981], [-3.19306, 9.93781], [-3.16609, 9.85147], [-3.00765, 9.74019], [-2.93012, 9.57403], [-2.76494, 9.40778], [-2.68802, 9.49343], [-2.76534, 9.56589], [-2.74174, 9.83172], [-2.83108, 10.40252], [-2.94232, 10.64281], [-2.83373, 11.0067], [-0.67143, 10.99811], [-0.61937, 10.91305], [-0.44298, 11.04292], [-0.42391, 11.11661], [-0.38219, 11.12596], [-0.35955, 11.07801], [-0.28566, 11.12713], [-0.27374, 11.17157], [-0.13493, 11.14075], [0.50388, 11.01011], [0.48852, 10.98561], [0.50521, 10.98035], [0.4958, 10.93269], [0.66104, 10.99964], [0.91245, 10.99597], [0.9813, 11.08876], [1.03409, 11.04719], [1.42823, 11.46822], [2.00988, 11.42227], [2.29983, 11.68254], [2.39723, 11.89473], [2.05785, 12.35539], [2.26349, 12.41915], [0.99167, 13.10727], [0.99253, 13.37515], [1.18873, 13.31771], [1.21217, 13.37853], [1.24516, 13.33968], [1.28509, 13.35488], [1.24429, 13.39373], [1.20088, 13.38951], [1.02813, 13.46635], [0.99514, 13.5668], [0.77637, 13.64442], [0.77377, 13.6866], [0.61924, 13.68491], [0.38051, 14.05575], [0.16936, 14.51654], [0.23859, 15.00135]]]] } },
22687     { type: "Feature", properties: { iso1A2: "BG", iso1A3: "BGR", iso1N3: "100", wikidata: "Q219", nameEn: "Bulgaria", groups: ["EU", "151", "150", "UN"], callingCodes: ["359"] }, geometry: { type: "MultiPolygon", coordinates: [[[[23.05288, 43.79494], [22.85314, 43.84452], [22.83753, 43.88055], [22.87873, 43.9844], [23.01674, 44.01946], [23.04988, 44.07694], [22.67173, 44.21564], [22.61711, 44.16938], [22.61688, 44.06534], [22.41449, 44.00514], [22.35558, 43.81281], [22.41043, 43.69566], [22.47582, 43.6558], [22.53397, 43.47225], [22.82036, 43.33665], [22.89727, 43.22417], [23.00806, 43.19279], [22.98104, 43.11199], [22.89521, 43.03625], [22.78397, 42.98253], [22.74826, 42.88701], [22.54302, 42.87774], [22.43309, 42.82057], [22.4997, 42.74144], [22.43983, 42.56851], [22.55669, 42.50144], [22.51961, 42.3991], [22.47498, 42.3915], [22.45919, 42.33822], [22.34773, 42.31725], [22.38136, 42.30339], [22.47251, 42.20393], [22.50289, 42.19527], [22.51224, 42.15457], [22.67701, 42.06614], [22.86749, 42.02275], [22.90254, 41.87587], [22.96682, 41.77137], [23.01239, 41.76527], [23.03342, 41.71034], [22.95513, 41.63265], [22.96331, 41.35782], [22.93334, 41.34104], [23.1833, 41.31755], [23.21953, 41.33773], [23.22771, 41.37106], [23.31301, 41.40525], [23.33639, 41.36317], [23.40416, 41.39999], [23.52453, 41.40262], [23.63203, 41.37632], [23.67644, 41.41139], [23.76525, 41.40175], [23.80148, 41.43943], [23.89613, 41.45257], [23.91483, 41.47971], [23.96975, 41.44118], [24.06908, 41.46132], [24.06323, 41.53222], [24.10063, 41.54796], [24.18126, 41.51735], [24.27124, 41.57682], [24.30513, 41.51297], [24.52599, 41.56808], [24.61129, 41.42278], [24.71529, 41.41928], [24.8041, 41.34913], [24.82514, 41.4035], [24.86136, 41.39298], [24.90928, 41.40876], [24.942, 41.38685], [25.11611, 41.34212], [25.28322, 41.23411], [25.48187, 41.28506], [25.52394, 41.2798], [25.55082, 41.31667], [25.61042, 41.30614], [25.66183, 41.31316], [25.70507, 41.29209], [25.8266, 41.34563], [25.87919, 41.30526], [26.12926, 41.35878], [26.16548, 41.42278], [26.20288, 41.43943], [26.14796, 41.47533], [26.176, 41.50072], [26.17951, 41.55409], [26.14328, 41.55496], [26.15146, 41.60828], [26.07083, 41.64584], [26.06148, 41.70345], [26.16841, 41.74858], [26.21325, 41.73223], [26.22888, 41.74139], [26.2654, 41.71544], [26.30255, 41.70925], [26.35957, 41.71149], [26.32952, 41.73637], [26.33589, 41.76802], [26.36952, 41.82265], [26.53968, 41.82653], [26.57961, 41.90024], [26.56051, 41.92995], [26.62996, 41.97644], [26.79143, 41.97386], [26.95638, 42.00741], [27.03277, 42.0809], [27.08486, 42.08735], [27.19251, 42.06028], [27.22376, 42.10152], [27.27411, 42.10409], [27.45478, 41.96591], [27.52379, 41.93756], [27.55191, 41.90928], [27.69949, 41.97515], [27.81235, 41.94803], [27.83492, 41.99709], [27.91479, 41.97902], [28.02971, 41.98066], [28.32297, 41.98371], [29.24336, 43.70874], [28.23293, 43.76], [27.99558, 43.84193], [27.92008, 44.00761], [27.73468, 43.95326], [27.64542, 44.04958], [27.60834, 44.01206], [27.39757, 44.0141], [27.26845, 44.12602], [26.95141, 44.13555], [26.62712, 44.05698], [26.38764, 44.04356], [26.10115, 43.96908], [26.05584, 43.90925], [25.94911, 43.85745], [25.72792, 43.69263], [25.39528, 43.61866], [25.17144, 43.70261], [25.10718, 43.6831], [24.96682, 43.72693], [24.73542, 43.68523], [24.62281, 43.74082], [24.50264, 43.76314], [24.35364, 43.70211], [24.18149, 43.68218], [23.73978, 43.80627], [23.61687, 43.79289], [23.4507, 43.84936], [23.26772, 43.84843], [23.05288, 43.79494]]]] } },
22688     { type: "Feature", properties: { iso1A2: "BH", iso1A3: "BHR", iso1N3: "048", wikidata: "Q398", nameEn: "Bahrain", groups: ["145", "142", "UN"], callingCodes: ["973"] }, geometry: { type: "MultiPolygon", coordinates: [[[[50.93865, 26.30758], [50.71771, 26.73086], [50.38162, 26.53976], [50.26923, 26.08243], [50.302, 25.87592], [50.57069, 25.57887], [50.80824, 25.54641], [50.7801, 25.595], [50.86149, 25.6965], [50.81266, 25.88946], [50.93865, 26.30758]]]] } },
22689     { type: "Feature", properties: { iso1A2: "BI", iso1A3: "BDI", iso1N3: "108", wikidata: "Q967", nameEn: "Burundi", groups: ["014", "202", "002", "UN"], callingCodes: ["257"] }, geometry: { type: "MultiPolygon", coordinates: [[[[30.54501, -2.41404], [30.42933, -2.31064], [30.14034, -2.43626], [29.95911, -2.33348], [29.88237, -2.75105], [29.36805, -2.82933], [29.32234, -2.6483], [29.0562, -2.58632], [29.04081, -2.7416], [29.00167, -2.78523], [29.00404, -2.81978], [29.0505, -2.81774], [29.09119, -2.87871], [29.09797, -2.91935], [29.16037, -2.95457], [29.17258, -2.99385], [29.25633, -3.05471], [29.21463, -3.3514], [29.23708, -3.75856], [29.43673, -4.44845], [29.63827, -4.44681], [29.75109, -4.45836], [29.77289, -4.41733], [29.82885, -4.36153], [29.88172, -4.35743], [30.03323, -4.26631], [30.22042, -4.01738], [30.45915, -3.56532], [30.84165, -3.25152], [30.83823, -2.97837], [30.6675, -2.98987], [30.57926, -2.89791], [30.4987, -2.9573], [30.40662, -2.86151], [30.52747, -2.65841], [30.41789, -2.66266], [30.54501, -2.41404]]]] } },
22690     { type: "Feature", properties: { iso1A2: "BJ", iso1A3: "BEN", iso1N3: "204", wikidata: "Q962", nameEn: "Benin", aliases: ["DY"], groups: ["011", "202", "002", "UN"], callingCodes: ["229"] }, geometry: { type: "MultiPolygon", coordinates: [[[[3.59375, 11.70269], [3.48187, 11.86092], [3.31613, 11.88495], [3.25352, 12.01467], [2.83978, 12.40585], [2.6593, 12.30631], [2.37783, 12.24804], [2.39657, 12.10952], [2.45824, 11.98672], [2.39723, 11.89473], [2.29983, 11.68254], [2.00988, 11.42227], [1.42823, 11.46822], [1.03409, 11.04719], [0.9813, 11.08876], [0.91245, 10.99597], [0.8804, 10.803], [0.80358, 10.71459], [0.77666, 10.37665], [1.35507, 9.99525], [1.36624, 9.5951], [1.33675, 9.54765], [1.41746, 9.3226], [1.5649, 9.16941], [1.61838, 9.0527], [1.64249, 6.99562], [1.55877, 6.99737], [1.61812, 6.74843], [1.58105, 6.68619], [1.76906, 6.43189], [1.79826, 6.28221], [1.62913, 6.24075], [1.67336, 6.02702], [2.74181, 6.13349], [2.70566, 6.38038], [2.70464, 6.50831], [2.74334, 6.57291], [2.7325, 6.64057], [2.78204, 6.70514], [2.78823, 6.76356], [2.73405, 6.78508], [2.74024, 6.92802], [2.71702, 6.95722], [2.76965, 7.13543], [2.74489, 7.42565], [2.79442, 7.43486], [2.78668, 7.5116], [2.73405, 7.5423], [2.73095, 7.7755], [2.67523, 7.87825], [2.77907, 9.06924], [3.08017, 9.10006], [3.14147, 9.28375], [3.13928, 9.47167], [3.25093, 9.61632], [3.34726, 9.70696], [3.32099, 9.78032], [3.35383, 9.83641], [3.54429, 9.87739], [3.66908, 10.18136], [3.57275, 10.27185], [3.6844, 10.46351], [3.78292, 10.40538], [3.84243, 10.59316], [3.71505, 11.13015], [3.49175, 11.29765], [3.59375, 11.70269]]]] } },
22691     { type: "Feature", properties: { iso1A2: "BL", iso1A3: "BLM", iso1N3: "652", wikidata: "Q25362", nameEn: "Saint-Barth\xE9lemy", country: "FR", groups: ["EU", "Q1451600", "029", "003", "419", "019", "UN"], callingCodes: ["590"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.62718, 18.26185], [-63.1055, 17.86651], [-62.34423, 17.49165], [-62.62718, 18.26185]]]] } },
22692     { type: "Feature", properties: { iso1A2: "BM", iso1A3: "BMU", iso1N3: "060", wikidata: "Q23635", nameEn: "Bermuda", country: "GB", groups: ["BOTS", "021", "003", "019", "UN"], driveSide: "left", callingCodes: ["1 441"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.20987, 32.6953], [-65.31453, 32.68437], [-65.63955, 31.43417], [-63.20987, 32.6953]]]] } },
22693     { type: "Feature", properties: { iso1A2: "BN", iso1A3: "BRN", iso1N3: "096", wikidata: "Q921", nameEn: "Brunei", groups: ["Q36117", "035", "142", "UN"], driveSide: "left", callingCodes: ["673"] }, geometry: { type: "MultiPolygon", coordinates: [[[[115.16236, 5.01011], [115.02521, 5.35005], [114.10166, 4.76112], [114.07448, 4.58441], [114.15813, 4.57], [114.26876, 4.49878], [114.32176, 4.34942], [114.32176, 4.2552], [114.4416, 4.27588], [114.49922, 4.13108], [114.64211, 4.00694], [114.78539, 4.12205], [114.88039, 4.4257], [114.83189, 4.42387], [114.77303, 4.72871], [114.8266, 4.75062], [114.88841, 4.81905], [114.96982, 4.81146], [114.99417, 4.88201], [115.05038, 4.90275], [115.02955, 4.82087], [115.02278, 4.74137], [115.04064, 4.63706], [115.07737, 4.53418], [115.09978, 4.39123], [115.31275, 4.30806], [115.36346, 4.33563], [115.2851, 4.42295], [115.27819, 4.63661], [115.20737, 4.8256], [115.15092, 4.87604], [115.16236, 5.01011]]]] } },
22694     { type: "Feature", properties: { iso1A2: "BO", iso1A3: "BOL", iso1N3: "068", wikidata: "Q750", nameEn: "Bolivia", groups: ["005", "419", "019", "UN"], callingCodes: ["591"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.90248, -12.52544], [-64.22539, -12.45267], [-64.30708, -12.46398], [-64.99778, -11.98604], [-65.30027, -11.48749], [-65.28141, -10.86289], [-65.35402, -10.78685], [-65.37923, -10.35141], [-65.29019, -9.86253], [-65.40615, -9.63894], [-65.56244, -9.84266], [-65.68343, -9.75323], [-67.17784, -10.34016], [-68.71533, -11.14749], [-68.7651, -11.0496], [-68.75179, -11.03688], [-68.75265, -11.02383], [-68.74802, -11.00891], [-69.42792, -10.93451], [-69.47839, -10.95254], [-69.57156, -10.94555], [-68.98115, -11.8979], [-68.65044, -12.50689], [-68.85615, -12.87769], [-68.8864, -13.40792], [-69.05265, -13.68546], [-68.88135, -14.18639], [-69.36254, -14.94634], [-69.14856, -15.23478], [-69.40336, -15.61358], [-69.20291, -16.16668], [-69.09986, -16.22693], [-68.96238, -16.194], [-68.79464, -16.33272], [-68.98358, -16.42165], [-69.04027, -16.57214], [-69.00853, -16.66769], [-69.16896, -16.72233], [-69.62883, -17.28142], [-69.46863, -17.37466], [-69.46897, -17.4988], [-69.46623, -17.60518], [-69.34126, -17.72753], [-69.28671, -17.94844], [-69.07496, -18.03715], [-69.14807, -18.16893], [-69.07432, -18.28259], [-68.94987, -18.93302], [-68.87082, -19.06003], [-68.80602, -19.08355], [-68.61989, -19.27584], [-68.41218, -19.40499], [-68.66761, -19.72118], [-68.54611, -19.84651], [-68.57132, -20.03134], [-68.74273, -20.08817], [-68.7276, -20.46178], [-68.44023, -20.62701], [-68.55383, -20.7355], [-68.53957, -20.91542], [-68.40403, -20.94562], [-68.18816, -21.28614], [-67.85114, -22.87076], [-67.54284, -22.89771], [-67.18382, -22.81525], [-66.7298, -22.23644], [-66.29714, -22.08741], [-66.24077, -21.77837], [-66.03836, -21.84829], [-66.04832, -21.9187], [-65.9261, -21.93335], [-65.7467, -22.10105], [-65.61166, -22.09504], [-65.58694, -22.09794], [-65.57743, -22.07675], [-65.47435, -22.08908], [-64.99524, -22.08255], [-64.90014, -22.12136], [-64.67174, -22.18957], [-64.58888, -22.25035], [-64.4176, -22.67692], [-64.35108, -22.73282], [-64.31489, -22.88824], [-64.22918, -22.55807], [-63.93287, -21.99934], [-63.70963, -21.99934], [-63.68113, -22.0544], [-63.66482, -21.99918], [-62.81124, -21.9987], [-62.8078, -22.12534], [-62.64455, -22.25091], [-62.2757, -21.06657], [-62.26883, -20.55311], [-61.93912, -20.10053], [-61.73723, -19.63958], [-60.00638, -19.2981], [-59.06965, -19.29148], [-58.23216, -19.80058], [-58.16225, -20.16193], [-57.8496, -19.98346], [-58.14215, -19.76276], [-57.78463, -19.03259], [-57.71113, -19.03161], [-57.69134, -19.00544], [-57.71995, -18.97546], [-57.71995, -18.89573], [-57.76764, -18.90087], [-57.56807, -18.25655], [-57.48237, -18.24219], [-57.69877, -17.8431], [-57.73949, -17.56095], [-57.90082, -17.44555], [-57.99661, -17.5273], [-58.32935, -17.28195], [-58.5058, -16.80958], [-58.30918, -16.3699], [-58.32431, -16.25861], [-58.41506, -16.32636], [-60.16069, -16.26479], [-60.23797, -15.50267], [-60.58224, -15.09887], [-60.23968, -15.09515], [-60.27887, -14.63021], [-60.46037, -14.22496], [-60.48053, -13.77981], [-61.05527, -13.50054], [-61.81151, -13.49564], [-63.76259, -12.42952], [-63.90248, -12.52544]]]] } },
22695     { type: "Feature", properties: { iso1A2: "BQ", iso1A3: "BES", iso1N3: "535", wikidata: "Q27561", nameEn: "Caribbean Netherlands", country: "NL" }, geometry: null },
22696     { type: "Feature", properties: { iso1A2: "BR", iso1A3: "BRA", iso1N3: "076", wikidata: "Q155", nameEn: "Brazil", groups: ["005", "419", "019", "UN"], callingCodes: ["55"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-59.69361, 4.34069], [-59.78878, 4.45637], [-60.15953, 4.53456], [-60.04189, 4.69801], [-59.98129, 5.07097], [-60.20944, 5.28754], [-60.32352, 5.21299], [-60.73204, 5.20931], [-60.5802, 4.94312], [-60.86539, 4.70512], [-60.98303, 4.54167], [-61.15703, 4.49839], [-61.31457, 4.54167], [-61.29675, 4.44216], [-61.48569, 4.43149], [-61.54629, 4.2822], [-62.13094, 4.08309], [-62.44822, 4.18621], [-62.57656, 4.04754], [-62.74411, 4.03331], [-62.7655, 3.73099], [-62.98296, 3.59935], [-63.21111, 3.96219], [-63.4464, 3.9693], [-63.42233, 3.89995], [-63.50611, 3.83592], [-63.67099, 4.01731], [-63.70218, 3.91417], [-63.86082, 3.94796], [-63.99183, 3.90172], [-64.14512, 4.12932], [-64.57648, 4.12576], [-64.72977, 4.28931], [-64.84028, 4.24665], [-64.48379, 3.7879], [-64.02908, 2.79797], [-64.0257, 2.48156], [-63.39114, 2.4317], [-63.39827, 2.16098], [-64.06135, 1.94722], [-64.08274, 1.64792], [-64.34654, 1.35569], [-64.38932, 1.5125], [-65.11657, 1.12046], [-65.57288, 0.62856], [-65.50158, 0.92086], [-65.6727, 1.01353], [-66.28507, 0.74585], [-66.85795, 1.22998], [-67.08222, 1.17441], [-67.15784, 1.80439], [-67.299, 1.87494], [-67.40488, 2.22258], [-67.9292, 1.82455], [-68.18632, 2.00091], [-68.26699, 1.83463], [-68.18128, 1.72881], [-69.38621, 1.70865], [-69.53746, 1.76408], [-69.83491, 1.69353], [-69.82987, 1.07864], [-69.26017, 1.06856], [-69.14422, 0.84172], [-69.20976, 0.57958], [-69.47696, 0.71065], [-70.04162, 0.55437], [-70.03658, -0.19681], [-69.603, -0.51947], [-69.59796, -0.75136], [-69.4215, -1.01853], [-69.43395, -1.42219], [-69.94708, -4.2431], [-70.00888, -4.37833], [-70.11305, -4.27281], [-70.19582, -4.3607], [-70.33236, -4.15214], [-70.77601, -4.15717], [-70.96814, -4.36915], [-71.87003, -4.51661], [-72.64391, -5.0391], [-72.83973, -5.14765], [-73.24579, -6.05764], [-73.12983, -6.43852], [-73.73986, -6.87919], [-73.77011, -7.28944], [-73.96938, -7.58465], [-73.65485, -7.77897], [-73.76576, -7.89884], [-72.92886, -9.04074], [-73.21498, -9.40904], [-72.72216, -9.41397], [-72.31883, -9.5184], [-72.14742, -9.98049], [-71.23394, -9.9668], [-70.53373, -9.42628], [-70.58453, -9.58303], [-70.55429, -9.76692], [-70.62487, -9.80666], [-70.64134, -11.0108], [-70.51395, -10.92249], [-70.38791, -11.07096], [-69.90896, -10.92744], [-69.57835, -10.94051], [-69.57156, -10.94555], [-69.47839, -10.95254], [-69.42792, -10.93451], [-68.74802, -11.00891], [-68.75265, -11.02383], [-68.75179, -11.03688], [-68.7651, -11.0496], [-68.71533, -11.14749], [-67.17784, -10.34016], [-65.68343, -9.75323], [-65.56244, -9.84266], [-65.40615, -9.63894], [-65.29019, -9.86253], [-65.37923, -10.35141], [-65.35402, -10.78685], [-65.28141, -10.86289], [-65.30027, -11.48749], [-64.99778, -11.98604], [-64.30708, -12.46398], [-64.22539, -12.45267], [-63.90248, -12.52544], [-63.76259, -12.42952], [-61.81151, -13.49564], [-61.05527, -13.50054], [-60.48053, -13.77981], [-60.46037, -14.22496], [-60.27887, -14.63021], [-60.23968, -15.09515], [-60.58224, -15.09887], [-60.23797, -15.50267], [-60.16069, -16.26479], [-58.41506, -16.32636], [-58.32431, -16.25861], [-58.30918, -16.3699], [-58.5058, -16.80958], [-58.32935, -17.28195], [-57.99661, -17.5273], [-57.90082, -17.44555], [-57.73949, -17.56095], [-57.69877, -17.8431], [-57.48237, -18.24219], [-57.56807, -18.25655], [-57.76764, -18.90087], [-57.71995, -18.89573], [-57.71995, -18.97546], [-57.69134, -19.00544], [-57.71113, -19.03161], [-57.78463, -19.03259], [-58.14215, -19.76276], [-57.8496, -19.98346], [-58.16225, -20.16193], [-57.84536, -20.93155], [-57.93492, -21.65505], [-57.88239, -21.6868], [-57.94642, -21.73799], [-57.98625, -22.09157], [-56.6508, -22.28387], [-56.5212, -22.11556], [-56.45893, -22.08072], [-56.23206, -22.25347], [-55.8331, -22.29008], [-55.74941, -22.46436], [-55.741, -22.52018], [-55.72366, -22.5519], [-55.6986, -22.56268], [-55.68742, -22.58407], [-55.62493, -22.62765], [-55.63849, -22.95122], [-55.5446, -23.22811], [-55.52288, -23.2595], [-55.5555, -23.28237], [-55.43585, -23.87157], [-55.44117, -23.9185], [-55.41784, -23.9657], [-55.12292, -23.99669], [-55.0518, -23.98666], [-55.02691, -23.97317], [-54.6238, -23.83078], [-54.32807, -24.01865], [-54.28207, -24.07305], [-54.4423, -25.13381], [-54.62033, -25.46026], [-54.60196, -25.48397], [-54.59509, -25.53696], [-54.59398, -25.59224], [-54.5502, -25.58915], [-54.52926, -25.62846], [-53.90831, -25.55513], [-53.83691, -25.94849], [-53.73511, -26.04211], [-53.73086, -26.05842], [-53.7264, -26.0664], [-53.73391, -26.07006], [-53.73968, -26.10012], [-53.65018, -26.19501], [-53.65237, -26.23289], [-53.63739, -26.2496], [-53.63881, -26.25075], [-53.64632, -26.24798], [-53.64186, -26.25976], [-53.64505, -26.28089], [-53.68269, -26.33359], [-53.73372, -26.6131], [-53.80144, -27.09844], [-54.15978, -27.2889], [-54.19062, -27.27639], [-54.19268, -27.30751], [-54.41888, -27.40882], [-54.50416, -27.48232], [-54.67657, -27.57214], [-54.90159, -27.63132], [-54.90805, -27.73149], [-55.1349, -27.89759], [-55.16872, -27.86224], [-55.33303, -27.94661], [-55.6262, -28.17124], [-55.65418, -28.18304], [-56.01729, -28.51223], [-56.00458, -28.60421], [-56.05265, -28.62651], [-56.54171, -29.11447], [-56.57295, -29.11357], [-56.62789, -29.18073], [-56.81251, -29.48154], [-57.09386, -29.74211], [-57.65132, -30.19229], [-57.22502, -30.26121], [-56.90236, -30.02578], [-56.49267, -30.39471], [-56.4795, -30.3899], [-56.4619, -30.38457], [-55.87388, -31.05053], [-55.58866, -30.84117], [-55.5634, -30.8686], [-55.55373, -30.8732], [-55.55218, -30.88193], [-55.54572, -30.89051], [-55.53431, -30.89714], [-55.53276, -30.90218], [-55.52712, -30.89997], [-55.51862, -30.89828], [-55.50841, -30.9027], [-55.50821, -30.91349], [-54.17384, -31.86168], [-53.76024, -32.0751], [-53.39572, -32.58596], [-53.37671, -32.57005], [-53.1111, -32.71147], [-53.53459, -33.16843], [-53.52794, -33.68908], [-53.44031, -33.69344], [-53.39593, -33.75169], [-53.37138, -33.74313], [-52.83257, -34.01481], [-28.34015, -20.99094], [-28.99601, 1.86593], [-51.35485, 4.8383], [-51.63798, 4.51394], [-51.61983, 4.14596], [-51.79599, 3.89336], [-51.82312, 3.85825], [-51.85573, 3.83427], [-52.31787, 3.17896], [-52.6906, 2.37298], [-52.96539, 2.1881], [-53.78743, 2.34412], [-54.16286, 2.10779], [-54.6084, 2.32856], [-55.01919, 2.564], [-55.71493, 2.40342], [-55.96292, 2.53188], [-56.13054, 2.27723], [-55.92159, 2.05236], [-55.89863, 1.89861], [-55.99278, 1.83137], [-56.47045, 1.95135], [-56.7659, 1.89509], [-57.07092, 1.95304], [-57.09109, 2.01854], [-57.23981, 1.95808], [-57.35073, 1.98327], [-57.55743, 1.69605], [-57.77281, 1.73344], [-57.97336, 1.64566], [-58.01873, 1.51966], [-58.33887, 1.58014], [-58.4858, 1.48399], [-58.53571, 1.29154], [-58.84229, 1.17749], [-58.92072, 1.31293], [-59.25583, 1.40559], [-59.74066, 1.87596], [-59.7264, 2.27497], [-59.91177, 2.36759], [-59.99733, 2.92312], [-59.79769, 3.37162], [-59.86899, 3.57089], [-59.51963, 3.91951], [-59.73353, 4.20399], [-59.69361, 4.34069]]]] } },
22697     { type: "Feature", properties: { iso1A2: "BS", iso1A3: "BHS", iso1N3: "044", wikidata: "Q778", nameEn: "The Bahamas", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 242"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-72.98446, 20.4801], [-71.70065, 25.7637], [-78.91214, 27.76553], [-80.65727, 23.71953], [-72.98446, 20.4801]]]] } },
22698     { type: "Feature", properties: { iso1A2: "BT", iso1A3: "BTN", iso1N3: "064", wikidata: "Q917", nameEn: "Bhutan", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["975"] }, geometry: { type: "MultiPolygon", coordinates: [[[[91.6469, 27.76358], [91.5629, 27.84823], [91.48973, 27.93903], [91.46327, 28.0064], [91.25779, 28.07509], [91.20019, 27.98715], [90.69894, 28.07784], [90.58842, 28.02838], [90.13387, 28.19178], [89.79762, 28.23979], [89.59525, 28.16433], [89.12825, 27.62502], [89.0582, 27.60985], [88.97213, 27.51671], [88.95355, 27.4106], [89.00216, 27.32532], [88.96947, 27.30319], [88.93678, 27.33777], [88.91901, 27.32483], [88.74219, 27.144], [88.86984, 27.10937], [88.8714, 26.97488], [88.92301, 26.99286], [88.95807, 26.92668], [89.09554, 26.89089], [89.12825, 26.81661], [89.1926, 26.81329], [89.37913, 26.86224], [89.38319, 26.85963], [89.3901, 26.84225], [89.42349, 26.83727], [89.63369, 26.74402], [89.86124, 26.73307], [90.04535, 26.72422], [90.30402, 26.85098], [90.39271, 26.90704], [90.48504, 26.8594], [90.67715, 26.77215], [91.50067, 26.79223], [91.83181, 26.87318], [92.05523, 26.8692], [92.11863, 26.893], [92.03457, 27.07334], [92.04702, 27.26861], [92.12019, 27.27829], [92.01132, 27.47352], [91.65007, 27.48287], [91.55819, 27.6144], [91.6469, 27.76358]]]] } },
22699     { type: "Feature", properties: { iso1A2: "BV", iso1A3: "BVT", iso1N3: "074", wikidata: "Q23408", nameEn: "Bouvet Island", country: "NO", groups: ["005", "419", "019", "UN"] }, geometry: { type: "MultiPolygon", coordinates: [[[[4.54042, -54.0949], [2.28941, -54.13089], [3.35353, -55.17558], [4.54042, -54.0949]]]] } },
22700     { type: "Feature", properties: { iso1A2: "BW", iso1A3: "BWA", iso1N3: "072", wikidata: "Q963", nameEn: "Botswana", groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["267"] }, geometry: { type: "MultiPolygon", coordinates: [[[[25.26433, -17.79571], [25.16882, -17.78253], [25.05895, -17.84452], [24.95586, -17.79674], [24.73364, -17.89338], [24.71887, -17.9218], [24.6303, -17.9863], [24.57485, -18.07151], [24.40577, -17.95726], [24.19416, -18.01919], [23.61088, -18.4881], [23.29618, -17.99855], [23.0996, -18.00075], [21.45556, -18.31795], [20.99904, -18.31743], [20.99751, -22.00026], [19.99912, -21.99991], [19.99817, -24.76768], [20.02809, -24.78725], [20.03678, -24.81004], [20.29826, -24.94869], [20.64795, -25.47827], [20.86081, -26.14892], [20.61754, -26.4692], [20.63275, -26.78181], [20.68596, -26.9039], [20.87031, -26.80047], [21.13353, -26.86661], [21.37869, -26.82083], [21.69322, -26.86152], [21.7854, -26.79199], [21.77114, -26.69015], [21.83291, -26.65959], [21.90703, -26.66808], [22.06192, -26.61882], [22.21206, -26.3773], [22.41921, -26.23078], [22.56365, -26.19668], [22.70808, -25.99186], [22.86012, -25.50572], [23.03497, -25.29971], [23.47588, -25.29971], [23.9244, -25.64286], [24.18287, -25.62916], [24.36531, -25.773], [24.44703, -25.73021], [24.67319, -25.81749], [24.8946, -25.80723], [25.01718, -25.72507], [25.12266, -25.75931], [25.33076, -25.76616], [25.58543, -25.6343], [25.6643, -25.4491], [25.69661, -25.29284], [25.72702, -25.25503], [25.88571, -24.87802], [25.84295, -24.78661], [25.8515, -24.75727], [26.39409, -24.63468], [26.46346, -24.60358], [26.51667, -24.47219], [26.84165, -24.24885], [26.99749, -23.65486], [27.33768, -23.40917], [27.52393, -23.37952], [27.6066, -23.21894], [27.74154, -23.2137], [27.93539, -23.04941], [27.93729, -22.96194], [28.04752, -22.90243], [28.04562, -22.8394], [28.34874, -22.5694], [28.63287, -22.55887], [28.91889, -22.44299], [29.0151, -22.22907], [29.10881, -22.21202], [29.15268, -22.21399], [29.18974, -22.18599], [29.21955, -22.17771], [29.37703, -22.19581], [29.3533, -22.18363], [29.24648, -22.05967], [29.1974, -22.07472], [29.14501, -22.07275], [29.08495, -22.04867], [29.04108, -22.00563], [29.02191, -21.95665], [29.02191, -21.90647], [29.04023, -21.85864], [29.07763, -21.81877], [28.58114, -21.63455], [28.49942, -21.66634], [28.29416, -21.59037], [28.01669, -21.57624], [27.91407, -21.31621], [27.69171, -21.08409], [27.72972, -20.51735], [27.69361, -20.48531], [27.28865, -20.49873], [27.29831, -20.28935], [27.21278, -20.08244], [26.72246, -19.92707], [26.17227, -19.53709], [25.96226, -19.08152], [25.99837, -19.02943], [25.94326, -18.90362], [25.82353, -18.82808], [25.79217, -18.6355], [25.68859, -18.56165], [25.53465, -18.39041], [25.39972, -18.12691], [25.31799, -18.07091], [25.23909, -17.90832], [25.26433, -17.79571]]]] } },
22701     { type: "Feature", properties: { iso1A2: "BY", iso1A3: "BLR", iso1N3: "112", wikidata: "Q184", nameEn: "Belarus", groups: ["151", "150", "UN"], callingCodes: ["375"] }, geometry: { type: "MultiPolygon", coordinates: [[[[28.15217, 56.16964], [27.97865, 56.11849], [27.63065, 55.89687], [27.61683, 55.78558], [27.3541, 55.8089], [27.27804, 55.78299], [27.1559, 55.85032], [26.97153, 55.8102], [26.87448, 55.7172], [26.76872, 55.67658], [26.71802, 55.70645], [26.64888, 55.70515], [26.63231, 55.67968], [26.63167, 55.57887], [26.55094, 55.5093], [26.5522, 55.40277], [26.44937, 55.34832], [26.5709, 55.32572], [26.6714, 55.33902], [26.80929, 55.31642], [26.83266, 55.30444], [26.835, 55.28182], [26.73017, 55.24226], [26.72983, 55.21788], [26.68075, 55.19787], [26.69243, 55.16718], [26.54753, 55.14181], [26.51481, 55.16051], [26.46249, 55.12814], [26.35121, 55.1525], [26.30628, 55.12536], [26.23202, 55.10439], [26.26941, 55.08032], [26.20397, 54.99729], [26.13386, 54.98924], [26.05907, 54.94631], [25.99129, 54.95705], [25.89462, 54.93438], [25.74122, 54.80108], [25.75977, 54.57252], [25.68045, 54.5321], [25.64813, 54.48704], [25.62203, 54.4656], [25.63371, 54.42075], [25.5376, 54.33158], [25.55425, 54.31591], [25.68513, 54.31727], [25.78553, 54.23327], [25.78563, 54.15747], [25.71084, 54.16704], [25.64875, 54.1259], [25.54724, 54.14925], [25.51452, 54.17799], [25.56823, 54.25212], [25.509, 54.30267], [25.35559, 54.26544], [25.22705, 54.26271], [25.19199, 54.219], [25.0728, 54.13419], [24.991, 54.14241], [24.96894, 54.17589], [24.77131, 54.11091], [24.85311, 54.02862], [24.74279, 53.96663], [24.69185, 53.96543], [24.69652, 54.01901], [24.62275, 54.00217], [24.44411, 53.90076], [24.34128, 53.90076], [24.19638, 53.96405], [23.98837, 53.92554], [23.95098, 53.9613], [23.81309, 53.94205], [23.80543, 53.89558], [23.71726, 53.93379], [23.61677, 53.92691], [23.51284, 53.95052], [23.62004, 53.60942], [23.81995, 53.24131], [23.85657, 53.22923], [23.91393, 53.16469], [23.87548, 53.0831], [23.92184, 53.02079], [23.94689, 52.95919], [23.91805, 52.94016], [23.93763, 52.71332], [23.73615, 52.6149], [23.58296, 52.59868], [23.45112, 52.53774], [23.34141, 52.44845], [23.18196, 52.28812], [23.20071, 52.22848], [23.47859, 52.18215], [23.54314, 52.12148], [23.61, 52.11264], [23.64066, 52.07626], [23.68733, 51.9906], [23.61523, 51.92066], [23.62691, 51.78208], [23.53198, 51.74298], [23.57053, 51.55938], [23.56236, 51.53673], [23.62751, 51.50512], [23.6736, 51.50255], [23.60906, 51.62122], [23.7766, 51.66809], [23.91118, 51.63316], [23.8741, 51.59734], [23.99907, 51.58369], [24.13075, 51.66979], [24.3163, 51.75063], [24.29021, 51.80841], [24.37123, 51.88222], [24.98784, 51.91273], [25.20228, 51.97143], [25.46163, 51.92205], [25.73673, 51.91973], [25.80574, 51.94556], [25.83217, 51.92587], [26.00408, 51.92967], [26.19084, 51.86781], [26.39367, 51.87315], [26.46962, 51.80501], [26.69759, 51.82284], [26.80043, 51.75777], [26.9489, 51.73788], [26.99422, 51.76933], [27.20602, 51.77291], [27.20948, 51.66713], [27.26613, 51.65957], [27.24828, 51.60161], [27.47212, 51.61184], [27.51058, 51.5854], [27.55727, 51.63486], [27.71932, 51.60672], [27.67125, 51.50854], [27.76052, 51.47604], [27.85253, 51.62293], [27.91844, 51.61952], [27.95827, 51.56065], [28.10658, 51.57857], [28.23452, 51.66988], [28.37592, 51.54505], [28.47051, 51.59734], [28.64429, 51.5664], [28.69161, 51.44695], [28.73143, 51.46236], [28.75615, 51.41442], [28.78224, 51.45294], [28.76027, 51.48802], [28.81795, 51.55552], [28.95528, 51.59222], [28.99098, 51.56833], [29.1187, 51.65872], [29.16402, 51.64679], [29.20659, 51.56918], [29.25603, 51.57089], [29.25191, 51.49828], [29.32881, 51.37843], [29.42357, 51.4187], [29.49773, 51.39814], [29.54372, 51.48372], [29.7408, 51.53417], [29.77376, 51.4461], [30.17888, 51.51025], [30.34642, 51.42555], [30.36153, 51.33984], [30.56203, 51.25655], [30.64992, 51.35014], [30.51946, 51.59649], [30.68804, 51.82806], [30.76443, 51.89739], [30.90897, 52.00699], [30.95589, 52.07775], [31.13332, 52.1004], [31.25142, 52.04131], [31.38326, 52.12991], [31.7822, 52.11406], [31.77877, 52.18636], [31.6895, 52.1973], [31.70735, 52.26711], [31.57971, 52.32146], [31.62084, 52.33849], [31.61397, 52.48843], [31.56316, 52.51518], [31.63869, 52.55361], [31.50406, 52.69707], [31.57277, 52.71613], [31.592, 52.79011], [31.35667, 52.97854], [31.24147, 53.031], [31.32283, 53.04101], [31.33519, 53.08805], [31.3915, 53.09712], [31.36403, 53.13504], [31.40523, 53.21406], [31.56316, 53.19432], [31.62496, 53.22886], [31.787, 53.18033], [31.82373, 53.10042], [32.15368, 53.07594], [32.40773, 53.18856], [32.51725, 53.28431], [32.73257, 53.33494], [32.74968, 53.45597], [32.47777, 53.5548], [32.40499, 53.6656], [32.50112, 53.68594], [32.45717, 53.74039], [32.36663, 53.7166], [32.12621, 53.81586], [31.89137, 53.78099], [31.77028, 53.80015], [31.85019, 53.91801], [31.88744, 54.03653], [31.89599, 54.0837], [31.57002, 54.14535], [31.30791, 54.25315], [31.3177, 54.34067], [31.22945, 54.46585], [31.08543, 54.50361], [31.21399, 54.63113], [31.19339, 54.66947], [30.99187, 54.67046], [30.98226, 54.68872], [31.0262, 54.70698], [30.97127, 54.71967], [30.95479, 54.74346], [30.75165, 54.80699], [30.8264, 54.90062], [30.81759, 54.94064], [30.93144, 54.9585], [30.95754, 54.98609], [30.9081, 55.02232], [30.94243, 55.03964], [31.00972, 55.02783], [31.02071, 55.06167], [30.97369, 55.17134], [30.87944, 55.28223], [30.81946, 55.27931], [30.8257, 55.3313], [30.93144, 55.3914], [30.90123, 55.46621], [30.95204, 55.50667], [30.93419, 55.6185], [30.86003, 55.63169], [30.7845, 55.58514], [30.72957, 55.66268], [30.67464, 55.64176], [30.63344, 55.73079], [30.51037, 55.76568], [30.51346, 55.78982], [30.48257, 55.81066], [30.30987, 55.83592], [30.27776, 55.86819], [30.12136, 55.8358], [29.97975, 55.87281], [29.80672, 55.79569], [29.61446, 55.77716], [29.51283, 55.70294], [29.3604, 55.75862], [29.44692, 55.95978], [29.21717, 55.98971], [29.08299, 56.03427], [28.73418, 55.97131], [28.63668, 56.07262], [28.68337, 56.10173], [28.5529, 56.11705], [28.43068, 56.09407], [28.37987, 56.11399], [28.36888, 56.05805], [28.30571, 56.06035], [28.15217, 56.16964]]]] } },
22702     { type: "Feature", properties: { iso1A2: "BZ", iso1A3: "BLZ", iso1N3: "084", wikidata: "Q242", nameEn: "Belize", groups: ["013", "003", "419", "019", "UN"], roadSpeedUnit: "mph", callingCodes: ["501"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-88.3268, 18.49048], [-88.48242, 18.49164], [-88.71505, 18.0707], [-88.8716, 17.89535], [-89.03839, 18.0067], [-89.15105, 17.95104], [-89.14985, 17.81563], [-89.15025, 17.04813], [-89.22683, 15.88619], [-89.17418, 15.90898], [-89.02415, 15.9063], [-88.95358, 15.88698], [-88.40779, 16.09624], [-86.92368, 17.61462], [-87.84815, 18.18511], [-87.85693, 18.18266], [-87.86657, 18.19971], [-87.87604, 18.18313], [-87.90671, 18.15213], [-88.03165, 18.16657], [-88.03238, 18.41778], [-88.26593, 18.47617], [-88.29909, 18.47591], [-88.3268, 18.49048]]]] } },
22703     { type: "Feature", properties: { iso1A2: "CA", iso1A3: "CAN", iso1N3: "124", wikidata: "Q16", nameEn: "Canada", groups: ["021", "003", "019", "UN"], callingCodes: ["1"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-67.20349, 45.1722], [-67.19603, 45.16771], [-67.15965, 45.16179], [-67.11316, 45.11176], [-67.0216, 44.95333], [-66.96824, 44.90965], [-66.98249, 44.87071], [-66.96824, 44.83078], [-66.93432, 44.82597], [-67.16117, 44.20069], [-61.98255, 37.34815], [-56.27503, 47.39728], [-53.12387, 41.40385], [-46.37635, 57.3249], [-77.52957, 77.23408], [-68.21821, 80.48551], [-49.33696, 84.57952], [-140.97446, 84.39275], [-141.00116, 60.30648], [-140.5227, 60.22077], [-140.45648, 60.30919], [-139.98024, 60.18027], [-139.68991, 60.33693], [-139.05831, 60.35205], [-139.20603, 60.08896], [-139.05365, 59.99655], [-138.71149, 59.90728], [-138.62145, 59.76431], [-137.60623, 59.24465], [-137.4925, 58.89415], [-136.82619, 59.16198], [-136.52365, 59.16752], [-136.47323, 59.46617], [-136.33727, 59.44466], [-136.22381, 59.55526], [-136.31566, 59.59083], [-135.48007, 59.79937], [-135.03069, 59.56208], [-135.00267, 59.28745], [-134.7047, 59.2458], [-134.55699, 59.1297], [-134.48059, 59.13231], [-134.27175, 58.8634], [-133.84645, 58.73543], [-133.38523, 58.42773], [-131.8271, 56.62247], [-130.77769, 56.36185], [-130.33965, 56.10849], [-130.10173, 56.12178], [-130.00093, 56.00325], [-130.00857, 55.91344], [-130.15373, 55.74895], [-129.97513, 55.28029], [-130.08035, 55.21556], [-130.18765, 55.07744], [-130.27203, 54.97174], [-130.44184, 54.85377], [-130.64499, 54.76912], [-130.61931, 54.70835], [-133.92876, 54.62289], [-133.36909, 48.51151], [-125.03842, 48.53282], [-123.50039, 48.21223], [-123.15614, 48.35395], [-123.26565, 48.6959], [-123.0093, 48.76586], [-123.0093, 48.83186], [-123.32163, 49.00419], [-95.15355, 48.9996], [-95.15357, 49.384], [-95.12903, 49.37056], [-95.05825, 49.35311], [-95.01419, 49.35647], [-94.99532, 49.36579], [-94.95681, 49.37035], [-94.85381, 49.32492], [-94.8159, 49.32299], [-94.82487, 49.29483], [-94.77355, 49.11998], [-94.75017, 49.09931], [-94.687, 48.84077], [-94.70087, 48.8339], [-94.70486, 48.82365], [-94.69669, 48.80918], [-94.69335, 48.77883], [-94.58903, 48.71803], [-94.54885, 48.71543], [-94.53826, 48.70216], [-94.44258, 48.69223], [-94.4174, 48.71049], [-94.27153, 48.70232], [-94.25172, 48.68404], [-94.25104, 48.65729], [-94.23215, 48.65202], [-93.85769, 48.63284], [-93.83288, 48.62745], [-93.80676, 48.58232], [-93.80939, 48.52439], [-93.79267, 48.51631], [-93.66382, 48.51845], [-93.47022, 48.54357], [-93.44472, 48.59147], [-93.40693, 48.60948], [-93.39758, 48.60364], [-93.3712, 48.60599], [-93.33946, 48.62787], [-93.25391, 48.64266], [-92.94973, 48.60866], [-92.7287, 48.54005], [-92.6342, 48.54133], [-92.62747, 48.50278], [-92.69927, 48.49573], [-92.71323, 48.46081], [-92.65606, 48.43471], [-92.50712, 48.44921], [-92.45588, 48.40624], [-92.48147, 48.36609], [-92.37185, 48.22259], [-92.27167, 48.25046], [-92.30939, 48.31251], [-92.26662, 48.35651], [-92.202, 48.35252], [-92.14732, 48.36578], [-92.05339, 48.35958], [-91.98929, 48.25409], [-91.86125, 48.21278], [-91.71231, 48.19875], [-91.70451, 48.11805], [-91.55649, 48.10611], [-91.58025, 48.04339], [-91.45829, 48.07454], [-91.43248, 48.04912], [-91.25025, 48.08522], [-91.08016, 48.18096], [-90.87588, 48.2484], [-90.75045, 48.09143], [-90.56444, 48.12184], [-90.56312, 48.09488], [-90.07418, 48.11043], [-89.89974, 47.98109], [-89.77248, 48.02607], [-89.57972, 48.00023], [-89.48837, 48.01412], [-88.37033, 48.30586], [-84.85871, 46.88881], [-84.55635, 46.45974], [-84.47607, 46.45225], [-84.4481, 46.48972], [-84.42101, 46.49853], [-84.34174, 46.50683], [-84.29893, 46.49127], [-84.26351, 46.49508], [-84.2264, 46.53337], [-84.1945, 46.54061], [-84.17723, 46.52753], [-84.12885, 46.53068], [-84.11196, 46.50248], [-84.13451, 46.39218], [-84.11254, 46.32329], [-84.11615, 46.2681], [-84.09756, 46.25512], [-84.1096, 46.23987], [-83.95399, 46.05634], [-83.90453, 46.05922], [-83.83329, 46.12169], [-83.57017, 46.105], [-83.43746, 45.99749], [-83.59589, 45.82131], [-82.48419, 45.30225], [-82.42469, 42.992], [-82.4146, 42.97626], [-82.4253, 42.95423], [-82.45331, 42.93139], [-82.4826, 42.8068], [-82.46613, 42.76615], [-82.51063, 42.66025], [-82.51858, 42.611], [-82.57583, 42.5718], [-82.58873, 42.54984], [-82.64242, 42.55594], [-82.82964, 42.37355], [-83.02253, 42.33045], [-83.07837, 42.30978], [-83.09837, 42.28877], [-83.12724, 42.2376], [-83.14962, 42.04089], [-83.11184, 41.95671], [-82.67862, 41.67615], [-78.93684, 42.82887], [-78.90712, 42.89733], [-78.90905, 42.93022], [-78.93224, 42.95229], [-78.96312, 42.95509], [-78.98126, 42.97], [-79.02074, 42.98444], [-79.02424, 43.01983], [-78.99941, 43.05612], [-79.01055, 43.06659], [-79.07486, 43.07845], [-79.05671, 43.10937], [-79.06881, 43.12029], [-79.0427, 43.13934], [-79.04652, 43.16396], [-79.05384, 43.17418], [-79.05002, 43.20133], [-79.05544, 43.21224], [-79.05512, 43.25375], [-79.06921, 43.26183], [-79.25796, 43.54052], [-76.79706, 43.63099], [-76.43859, 44.09393], [-76.35324, 44.13493], [-76.31222, 44.19894], [-76.244, 44.19643], [-76.1664, 44.23051], [-76.16285, 44.28262], [-76.00018, 44.34896], [-75.95947, 44.34463], [-75.8217, 44.43176], [-75.76813, 44.51537], [-75.41441, 44.76614], [-75.2193, 44.87821], [-75.01363, 44.95608], [-74.99101, 44.98051], [-74.8447, 45.00606], [-74.66689, 45.00646], [-74.32699, 44.99029], [-73.35025, 45.00942], [-71.50067, 45.01357], [-71.48735, 45.07784], [-71.42778, 45.12624], [-71.40364, 45.21382], [-71.44252, 45.2361], [-71.37133, 45.24624], [-71.29371, 45.29996], [-71.22338, 45.25184], [-71.19723, 45.25438], [-71.14568, 45.24128], [-71.08364, 45.30623], [-71.01866, 45.31573], [-71.0107, 45.34819], [-70.95193, 45.33895], [-70.91169, 45.29849], [-70.89864, 45.2398], [-70.84816, 45.22698], [-70.80236, 45.37444], [-70.82638, 45.39828], [-70.78372, 45.43269], [-70.65383, 45.37592], [-70.62518, 45.42286], [-70.72651, 45.49771], [-70.68516, 45.56964], [-70.54019, 45.67291], [-70.38934, 45.73215], [-70.41523, 45.79497], [-70.25976, 45.89675], [-70.24694, 45.95138], [-70.31025, 45.96424], [-70.23855, 46.1453], [-70.29078, 46.18832], [-70.18547, 46.35357], [-70.05812, 46.41768], [-69.99966, 46.69543], [-69.22119, 47.46461], [-69.05148, 47.42012], [-69.05073, 47.30076], [-69.05039, 47.2456], [-68.89222, 47.1807], [-68.70125, 47.24399], [-68.60575, 47.24659], [-68.57914, 47.28431], [-68.38332, 47.28723], [-68.37458, 47.35851], [-68.23244, 47.35712], [-67.94843, 47.1925], [-67.87993, 47.10377], [-67.78578, 47.06473], [-67.78111, 45.9392], [-67.75196, 45.91814], [-67.80961, 45.87531], [-67.75654, 45.82324], [-67.80653, 45.80022], [-67.80705, 45.69528], [-67.6049, 45.60725], [-67.43815, 45.59162], [-67.42144, 45.50584], [-67.50578, 45.48971], [-67.42394, 45.37969], [-67.48201, 45.27351], [-67.34927, 45.122], [-67.29754, 45.14865], [-67.29748, 45.18173], [-67.27039, 45.1934], [-67.22751, 45.16344], [-67.20349, 45.1722]]]] } },
22704     { type: "Feature", properties: { iso1A2: "CC", iso1A3: "CCK", iso1N3: "166", wikidata: "Q36004", nameEn: "Cocos (Keeling) Islands", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[96.61846, -10.82438], [96.02343, -12.68334], [97.93979, -12.33309], [96.61846, -10.82438]]]] } },
22705     { type: "Feature", properties: { iso1A2: "CD", iso1A3: "COD", iso1N3: "180", wikidata: "Q974", nameEn: "Democratic Republic of the Congo", aliases: ["ZR"], groups: ["017", "202", "002", "UN"], callingCodes: ["243"] }, geometry: { type: "MultiPolygon", coordinates: [[[[27.44012, 5.07349], [27.09575, 5.22305], [26.93064, 5.13535], [26.85579, 5.03887], [26.74572, 5.10685], [26.48595, 5.04984], [26.13371, 5.25594], [25.86073, 5.19455], [25.53271, 5.37431], [25.34558, 5.29101], [25.31256, 5.03668], [24.71816, 4.90509], [24.46719, 5.0915], [23.38847, 4.60013], [22.94817, 4.82392], [22.89094, 4.79321], [22.84691, 4.69887], [22.78526, 4.71423], [22.6928, 4.47285], [22.60915, 4.48821], [22.5431, 4.22041], [22.45504, 4.13039], [22.27682, 4.11347], [22.10721, 4.20723], [21.6405, 4.317], [21.55904, 4.25553], [21.25744, 4.33676], [21.21341, 4.29285], [21.11214, 4.33895], [21.08793, 4.39603], [20.90383, 4.44877], [20.60184, 4.42394], [18.62755, 3.47564], [18.63857, 3.19342], [18.10683, 2.26876], [18.08034, 1.58553], [17.85887, 1.04327], [17.86989, 0.58873], [17.95255, 0.48128], [17.93877, 0.32424], [17.81204, 0.23884], [17.66051, -0.26535], [17.72112, -0.52707], [17.32438, -0.99265], [16.97999, -1.12762], [16.70724, -1.45815], [16.50336, -1.8795], [16.16173, -2.16586], [16.22785, -2.59528], [16.1755, -3.25014], [16.21407, -3.2969], [15.89448, -3.9513], [15.53081, -4.042], [15.48121, -4.22062], [15.41785, -4.28381], [15.32693, -4.27282], [15.25411, -4.31121], [15.1978, -4.32388], [14.83101, -4.80838], [14.67948, -4.92093], [14.5059, -4.84956], [14.41499, -4.8825], [14.37366, -4.56125], [14.47284, -4.42941], [14.3957, -4.36623], [14.40672, -4.28381], [13.9108, -4.50906], [13.81162, -4.41842], [13.71794, -4.44864], [13.70417, -4.72601], [13.50305, -4.77818], [13.41764, -4.89897], [13.11182, -4.5942], [13.09648, -4.63739], [13.11195, -4.67745], [12.8733, -4.74346], [12.70868, -4.95505], [12.63465, -4.94632], [12.60251, -5.01715], [12.46297, -5.09408], [12.49815, -5.14058], [12.51589, -5.1332], [12.53586, -5.14658], [12.53599, -5.1618], [12.52301, -5.17481], [12.52318, -5.74353], [12.26557, -5.74031], [12.20376, -5.76338], [11.95767, -5.94705], [12.42245, -6.07585], [13.04371, -5.87078], [16.55507, -5.85631], [16.96282, -7.21787], [17.5828, -8.13784], [18.33635, -8.00126], [19.33698, -7.99743], [19.5469, -7.00195], [20.30218, -6.98955], [20.31846, -6.91953], [20.61689, -6.90876], [20.56263, -7.28566], [21.79824, -7.29628], [21.84856, -9.59871], [22.19039, -9.94628], [22.32604, -10.76291], [22.17954, -10.85884], [22.25951, -11.24911], [22.54205, -11.05784], [23.16602, -11.10577], [23.45631, -10.946], [23.86868, -11.02856], [24.00027, -10.89356], [24.34528, -11.06816], [24.42612, -11.44975], [25.34069, -11.19707], [25.33058, -11.65767], [26.01777, -11.91488], [26.88687, -12.01868], [27.04351, -11.61312], [27.22541, -11.60323], [27.21025, -11.76157], [27.59932, -12.22123], [28.33199, -12.41375], [29.01918, -13.41353], [29.60531, -13.21685], [29.65078, -13.41844], [29.81551, -13.44683], [29.8139, -12.14898], [29.48404, -12.23604], [29.4992, -12.43843], [29.18592, -12.37921], [28.48357, -11.87532], [28.37241, -11.57848], [28.65032, -10.65133], [28.62795, -9.92942], [28.68532, -9.78], [28.56208, -9.49122], [28.51627, -9.44726], [28.52636, -9.35379], [28.36562, -9.30091], [28.38526, -9.23393], [28.9711, -8.66935], [28.88917, -8.4831], [30.79243, -8.27382], [30.2567, -7.14121], [29.52552, -6.2731], [29.43673, -4.44845], [29.23708, -3.75856], [29.21463, -3.3514], [29.25633, -3.05471], [29.17258, -2.99385], [29.16037, -2.95457], [29.09797, -2.91935], [29.09119, -2.87871], [29.0505, -2.81774], [29.00404, -2.81978], [29.00167, -2.78523], [29.04081, -2.7416], [29.00357, -2.70596], [28.94346, -2.69124], [28.89793, -2.66111], [28.90226, -2.62385], [28.89288, -2.55848], [28.87943, -2.55165], [28.86193, -2.53185], [28.86209, -2.5231], [28.87497, -2.50887], [28.88846, -2.50493], [28.89342, -2.49017], [28.89132, -2.47557], [28.86846, -2.44866], [28.86826, -2.41888], [28.89601, -2.37321], [28.95642, -2.37321], [29.00051, -2.29001], [29.105, -2.27043], [29.17562, -2.12278], [29.11847, -1.90576], [29.24458, -1.69663], [29.24323, -1.66826], [29.36322, -1.50887], [29.45038, -1.5054], [29.53062, -1.40499], [29.59061, -1.39016], [29.58388, -0.89821], [29.63006, -0.8997], [29.62708, -0.71055], [29.67176, -0.55714], [29.67474, -0.47969], [29.65091, -0.46777], [29.72687, -0.08051], [29.7224, 0.07291], [29.77454, 0.16675], [29.81922, 0.16824], [29.87284, 0.39166], [29.97413, 0.52124], [29.95477, 0.64486], [29.98307, 0.84295], [30.1484, 0.89805], [30.22139, 0.99635], [30.24671, 1.14974], [30.48503, 1.21675], [31.30127, 2.11006], [31.28042, 2.17853], [31.20148, 2.2217], [31.1985, 2.29462], [31.12104, 2.27676], [31.07934, 2.30207], [31.06593, 2.35862], [30.96911, 2.41071], [30.91102, 2.33332], [30.83059, 2.42559], [30.74271, 2.43601], [30.75612, 2.5863], [30.8857, 2.83923], [30.8574, 2.9508], [30.77101, 3.04897], [30.84251, 3.26908], [30.93486, 3.40737], [30.94081, 3.50847], [30.85153, 3.48867], [30.85997, 3.5743], [30.80713, 3.60506], [30.78512, 3.67097], [30.56277, 3.62703], [30.57378, 3.74567], [30.55396, 3.84451], [30.47691, 3.83353], [30.27658, 3.95653], [30.22374, 3.93896], [30.1621, 4.10586], [30.06964, 4.13221], [29.79666, 4.37809], [29.82087, 4.56246], [29.49726, 4.7007], [29.43341, 4.50101], [29.22207, 4.34297], [29.03054, 4.48784], [28.8126, 4.48784], [28.6651, 4.42638], [28.20719, 4.35614], [27.79551, 4.59976], [27.76469, 4.79284], [27.65462, 4.89375], [27.56656, 4.89375], [27.44012, 5.07349]]]] } },
22706     { type: "Feature", properties: { iso1A2: "CF", iso1A3: "CAF", iso1N3: "140", wikidata: "Q929", nameEn: "Central African Republic", groups: ["017", "202", "002", "UN"], callingCodes: ["236"] }, geometry: { type: "MultiPolygon", coordinates: [[[[22.87758, 10.91915], [22.45889, 11.00246], [21.72139, 10.64136], [21.71479, 10.29932], [21.63553, 10.217], [21.52766, 10.2105], [21.34934, 9.95907], [21.26348, 9.97642], [20.82979, 9.44696], [20.36748, 9.11019], [19.06421, 9.00367], [18.86388, 8.87971], [19.11044, 8.68172], [18.79783, 8.25929], [18.67455, 8.22226], [18.62612, 8.14163], [18.64153, 8.08714], [18.6085, 8.05009], [18.02731, 8.01085], [17.93926, 7.95853], [17.67288, 7.98905], [16.8143, 7.53971], [16.6668, 7.67281], [16.658, 7.75353], [16.59415, 7.76444], [16.58315, 7.88657], [16.41583, 7.77971], [16.40703, 7.68809], [15.79942, 7.44149], [15.73118, 7.52006], [15.49743, 7.52179], [15.23397, 7.25135], [15.04717, 6.77085], [14.96311, 6.75693], [14.79966, 6.39043], [14.80122, 6.34866], [14.74206, 6.26356], [14.56149, 6.18928], [14.43073, 6.08867], [14.42917, 6.00508], [14.49455, 5.91683], [14.60974, 5.91838], [14.62375, 5.70466], [14.58951, 5.59777], [14.62531, 5.51411], [14.52724, 5.28319], [14.57083, 5.23979], [14.65489, 5.21343], [14.73383, 4.6135], [15.00825, 4.41458], [15.08609, 4.30282], [15.10644, 4.1362], [15.17482, 4.05131], [15.07686, 4.01805], [15.73522, 3.24348], [15.77725, 3.26835], [16.05449, 3.02306], [16.08252, 2.45708], [16.19357, 2.21537], [16.50126, 2.84739], [16.46701, 2.92512], [16.57598, 3.47999], [16.68283, 3.54257], [17.01746, 3.55136], [17.35649, 3.63045], [17.46876, 3.70515], [17.60966, 3.63705], [17.83421, 3.61068], [17.85842, 3.53378], [18.05656, 3.56893], [18.14902, 3.54476], [18.17323, 3.47665], [18.24148, 3.50302], [18.2723, 3.57992], [18.39558, 3.58212], [18.49245, 3.63924], [18.58711, 3.49423], [18.62755, 3.47564], [20.60184, 4.42394], [20.90383, 4.44877], [21.08793, 4.39603], [21.11214, 4.33895], [21.21341, 4.29285], [21.25744, 4.33676], [21.55904, 4.25553], [21.6405, 4.317], [22.10721, 4.20723], [22.27682, 4.11347], [22.45504, 4.13039], [22.5431, 4.22041], [22.60915, 4.48821], [22.6928, 4.47285], [22.78526, 4.71423], [22.84691, 4.69887], [22.89094, 4.79321], [22.94817, 4.82392], [23.38847, 4.60013], [24.46719, 5.0915], [24.71816, 4.90509], [25.31256, 5.03668], [25.34558, 5.29101], [25.53271, 5.37431], [25.86073, 5.19455], [26.13371, 5.25594], [26.48595, 5.04984], [26.74572, 5.10685], [26.85579, 5.03887], [26.93064, 5.13535], [27.09575, 5.22305], [27.44012, 5.07349], [27.26886, 5.25876], [27.23017, 5.37167], [27.28621, 5.56382], [27.22705, 5.62889], [27.22705, 5.71254], [26.51721, 6.09655], [26.58259, 6.1987], [26.32729, 6.36272], [26.38022, 6.63493], [25.90076, 7.09549], [25.37461, 7.33024], [25.35281, 7.42595], [25.20337, 7.50312], [25.20649, 7.61115], [25.29214, 7.66675], [25.25319, 7.8487], [24.98855, 7.96588], [24.85156, 8.16933], [24.35965, 8.26177], [24.13238, 8.36959], [24.25691, 8.69288], [23.51905, 8.71749], [23.59065, 8.99743], [23.44744, 8.99128], [23.4848, 9.16959], [23.56263, 9.19418], [23.64358, 9.28637], [23.64981, 9.44303], [23.62179, 9.53823], [23.69155, 9.67566], [23.67164, 9.86923], [23.3128, 10.45214], [23.02221, 10.69235], [22.87758, 10.91915]]]] } },
22707     { type: "Feature", properties: { iso1A2: "CG", iso1A3: "COG", iso1N3: "178", wikidata: "Q971", nameEn: "Republic of the Congo", groups: ["017", "202", "002", "UN"], callingCodes: ["242"] }, geometry: { type: "MultiPolygon", coordinates: [[[[18.62755, 3.47564], [18.58711, 3.49423], [18.49245, 3.63924], [18.39558, 3.58212], [18.2723, 3.57992], [18.24148, 3.50302], [18.17323, 3.47665], [18.14902, 3.54476], [18.05656, 3.56893], [17.85842, 3.53378], [17.83421, 3.61068], [17.60966, 3.63705], [17.46876, 3.70515], [17.35649, 3.63045], [17.01746, 3.55136], [16.68283, 3.54257], [16.57598, 3.47999], [16.46701, 2.92512], [16.50126, 2.84739], [16.19357, 2.21537], [16.15568, 2.18955], [16.08563, 2.19733], [16.05294, 1.9811], [16.14634, 1.70259], [16.02647, 1.65591], [16.02959, 1.76483], [15.48942, 1.98265], [15.34776, 1.91264], [15.22634, 2.03243], [15.00996, 1.98887], [14.61145, 2.17866], [13.29457, 2.16106], [13.13461, 1.57238], [13.25447, 1.32339], [13.15519, 1.23368], [13.89582, 1.4261], [14.25186, 1.39842], [14.48179, 0.9152], [14.26066, 0.57255], [14.10909, 0.58563], [13.88648, 0.26652], [13.90632, -0.2287], [14.06862, -0.20826], [14.2165, -0.38261], [14.41887, -0.44799], [14.52569, -0.57818], [14.41838, -1.89412], [14.25932, -1.97624], [14.23518, -2.15671], [14.16202, -2.23916], [14.23829, -2.33715], [14.10442, -2.49268], [13.85846, -2.46935], [13.92073, -2.35581], [13.75884, -2.09293], [13.47977, -2.43224], [13.02759, -2.33098], [12.82172, -1.91091], [12.61312, -1.8129], [12.44656, -1.92025], [12.47925, -2.32626], [12.04895, -2.41704], [11.96866, -2.33559], [11.74605, -2.39936], [11.57637, -2.33379], [11.64487, -2.61865], [11.5359, -2.85654], [11.64798, -2.81146], [11.80365, -3.00424], [11.70558, -3.0773], [11.70227, -3.17465], [11.96554, -3.30267], [11.8318, -3.5812], [11.92719, -3.62768], [11.87083, -3.71571], [11.68608, -3.68942], [11.57949, -3.52798], [11.48764, -3.51089], [11.22301, -3.69888], [11.12647, -3.94169], [10.75913, -4.39519], [11.50888, -5.33417], [12.00924, -5.02627], [12.16068, -4.90089], [12.20901, -4.75642], [12.25587, -4.79437], [12.32324, -4.78415], [12.40964, -4.60609], [12.64835, -4.55937], [12.76844, -4.38709], [12.87096, -4.40315], [12.91489, -4.47907], [13.09648, -4.63739], [13.11182, -4.5942], [13.41764, -4.89897], [13.50305, -4.77818], [13.70417, -4.72601], [13.71794, -4.44864], [13.81162, -4.41842], [13.9108, -4.50906], [14.40672, -4.28381], [14.3957, -4.36623], [14.47284, -4.42941], [14.37366, -4.56125], [14.41499, -4.8825], [14.5059, -4.84956], [14.67948, -4.92093], [14.83101, -4.80838], [15.1978, -4.32388], [15.25411, -4.31121], [15.32693, -4.27282], [15.41785, -4.28381], [15.48121, -4.22062], [15.53081, -4.042], [15.89448, -3.9513], [16.21407, -3.2969], [16.1755, -3.25014], [16.22785, -2.59528], [16.16173, -2.16586], [16.50336, -1.8795], [16.70724, -1.45815], [16.97999, -1.12762], [17.32438, -0.99265], [17.72112, -0.52707], [17.66051, -0.26535], [17.81204, 0.23884], [17.93877, 0.32424], [17.95255, 0.48128], [17.86989, 0.58873], [17.85887, 1.04327], [18.08034, 1.58553], [18.10683, 2.26876], [18.63857, 3.19342], [18.62755, 3.47564]]]] } },
22708     { type: "Feature", geometry: { type: "MultiPolygon", coordinates: [[[[8.72809, 47.69282], [8.72617, 47.69651], [8.73671, 47.7169], [8.70543, 47.73121], [8.74251, 47.75168], [8.71778, 47.76571], [8.68985, 47.75686], [8.68022, 47.78599], [8.65292, 47.80066], [8.64425, 47.76398], [8.62408, 47.7626], [8.61657, 47.79998], [8.56415, 47.80633], [8.56814, 47.78001], [8.48868, 47.77215], [8.45771, 47.7493], [8.44807, 47.72426], [8.40569, 47.69855], [8.4211, 47.68407], [8.40473, 47.67499], [8.41346, 47.66676], [8.42264, 47.66667], [8.44711, 47.65379], [8.4667, 47.65747], [8.46605, 47.64103], [8.49656, 47.64709], [8.5322, 47.64687], [8.52801, 47.66059], [8.56141, 47.67088], [8.57683, 47.66158], [8.6052, 47.67258], [8.61113, 47.66332], [8.62884, 47.65098], [8.62049, 47.63757], [8.60412, 47.63735], [8.61471, 47.64514], [8.60701, 47.65271], [8.59545, 47.64298], [8.60348, 47.61204], [8.57586, 47.59537], [8.55756, 47.62394], [8.51686, 47.63476], [8.50747, 47.61897], [8.45578, 47.60121], [8.46637, 47.58389], [8.48949, 47.588], [8.49431, 47.58107], [8.43235, 47.56617], [8.39477, 47.57826], [8.38273, 47.56608], [8.35512, 47.57014], [8.32735, 47.57133], [8.30277, 47.58607], [8.29524, 47.5919], [8.29722, 47.60603], [8.2824, 47.61225], [8.26313, 47.6103], [8.25863, 47.61571], [8.23809, 47.61204], [8.22577, 47.60385], [8.22011, 47.6181], [8.20617, 47.62141], [8.19378, 47.61636], [8.1652, 47.5945], [8.14947, 47.59558], [8.13823, 47.59147], [8.13662, 47.58432], [8.11543, 47.5841], [8.10395, 47.57918], [8.10002, 47.56504], [8.08557, 47.55768], [8.06663, 47.56374], [8.04383, 47.55443], [8.02136, 47.55096], [8.00113, 47.55616], [7.97581, 47.55493], [7.95682, 47.55789], [7.94494, 47.54511], [7.91251, 47.55031], [7.90673, 47.57674], [7.88664, 47.58854], [7.84412, 47.5841], [7.81901, 47.58798], [7.79486, 47.55691], [7.75261, 47.54599], [7.71961, 47.54219], [7.69642, 47.53297], [7.68101, 47.53232], [7.6656, 47.53752], [7.66174, 47.54554], [7.65083, 47.54662], [7.63338, 47.56256], [7.67655, 47.56435], [7.68904, 47.57133], [7.67115, 47.5871], [7.68486, 47.59601], [7.69385, 47.60099], [7.68229, 47.59905], [7.67395, 47.59212], [7.64599, 47.59695], [7.64213, 47.5944], [7.64309, 47.59151], [7.61929, 47.57683], [7.60459, 47.57869], [7.60523, 47.58519], [7.58945, 47.59017], [7.58386, 47.57536], [7.56684, 47.57785], [7.56548, 47.57617], [7.55689, 47.57232], [7.55652, 47.56779], [7.53634, 47.55553], [7.52831, 47.55347], [7.51723, 47.54578], [7.50873, 47.54546], [7.49691, 47.53821], [7.50588, 47.52856], [7.51904, 47.53515], [7.53199, 47.5284], [7.5229, 47.51644], [7.49804, 47.51798], [7.51076, 47.49651], [7.47534, 47.47932], [7.43356, 47.49712], [7.42923, 47.48628], [7.4583, 47.47216], [7.4462, 47.46264], [7.43088, 47.45846], [7.40308, 47.43638], [7.35603, 47.43432], [7.33526, 47.44186], [7.24669, 47.4205], [7.17026, 47.44312], [7.19583, 47.49455], [7.16249, 47.49025], [7.12781, 47.50371], [7.07425, 47.48863], [7.0231, 47.50522], [6.98425, 47.49432], [7.0024, 47.45264], [6.93953, 47.43388], [6.93744, 47.40714], [6.88542, 47.37262], [6.87959, 47.35335], [7.03125, 47.36996], [7.0564, 47.35134], [7.05305, 47.33304], [6.94316, 47.28747], [6.95108, 47.26428], [6.9508, 47.24338], [6.8489, 47.15933], [6.76788, 47.1208], [6.68823, 47.06616], [6.71531, 47.0494], [6.43341, 46.92703], [6.46456, 46.88865], [6.43216, 46.80336], [6.45209, 46.77502], [6.38351, 46.73171], [6.27135, 46.68251], [6.11084, 46.57649], [6.1567, 46.54402], [6.07269, 46.46244], [6.08427, 46.44305], [6.06407, 46.41676], [6.09926, 46.40768], [6.15016, 46.3778], [6.15985, 46.37721], [6.16987, 46.36759], [6.15738, 46.3491], [6.13876, 46.33844], [6.1198, 46.31157], [6.11697, 46.29547], [6.1013, 46.28512], [6.11926, 46.2634], [6.12446, 46.25059], [6.10071, 46.23772], [6.08563, 46.24651], [6.07072, 46.24085], [6.0633, 46.24583], [6.05029, 46.23518], [6.04602, 46.23127], [6.03342, 46.2383], [6.02461, 46.23313], [5.97542, 46.21525], [5.96515, 46.19638], [5.99573, 46.18587], [5.98846, 46.17046], [5.98188, 46.17392], [5.97508, 46.15863], [5.9641, 46.14412], [5.95781, 46.12925], [5.97893, 46.13303], [5.9871, 46.14499], [6.01791, 46.14228], [6.03614, 46.13712], [6.04564, 46.14031], [6.05203, 46.15191], [6.07491, 46.14879], [6.09199, 46.15191], [6.09926, 46.14373], [6.13397, 46.1406], [6.15305, 46.15194], [6.18116, 46.16187], [6.18871, 46.16644], [6.18707, 46.17999], [6.19552, 46.18401], [6.19807, 46.18369], [6.20539, 46.19163], [6.21114, 46.1927], [6.21273, 46.19409], [6.21603, 46.19507], [6.21844, 46.19837], [6.22222, 46.19888], [6.22175, 46.20045], [6.23544, 46.20714], [6.23913, 46.20511], [6.24821, 46.20531], [6.26007, 46.21165], [6.27694, 46.21566], [6.29663, 46.22688], [6.31041, 46.24417], [6.29474, 46.26221], [6.26749, 46.24745], [6.24952, 46.26255], [6.23775, 46.27822], [6.25137, 46.29014], [6.24826, 46.30175], [6.21981, 46.31304], [6.25432, 46.3632], [6.53358, 46.45431], [6.82312, 46.42661], [6.8024, 46.39171], [6.77152, 46.34784], [6.86052, 46.28512], [6.78968, 46.14058], [6.89321, 46.12548], [6.87868, 46.03855], [6.93862, 46.06502], [7.00946, 45.9944], [7.04151, 45.92435], [7.10685, 45.85653], [7.56343, 45.97421], [7.85949, 45.91485], [7.9049, 45.99945], [7.98881, 45.99867], [8.02906, 46.10331], [8.11383, 46.11577], [8.16866, 46.17817], [8.08814, 46.26692], [8.31162, 46.38044], [8.30648, 46.41587], [8.42464, 46.46367], [8.46317, 46.43712], [8.45032, 46.26869], [8.62242, 46.12112], [8.75697, 46.10395], [8.80778, 46.10085], [8.85617, 46.0748], [8.79414, 46.00913], [8.78585, 45.98973], [8.79362, 45.99207], [8.8319, 45.9879], [8.85121, 45.97239], [8.86688, 45.96135], [8.88904, 45.95465], [8.93649, 45.86775], [8.94372, 45.86587], [8.93504, 45.86245], [8.91129, 45.8388], [8.94737, 45.84285], [8.9621, 45.83707], [8.99663, 45.83466], [9.00324, 45.82055], [9.0298, 45.82127], [9.03279, 45.82865], [9.03793, 45.83548], [9.03505, 45.83976], [9.04059, 45.8464], [9.04546, 45.84968], [9.06642, 45.8761], [9.09065, 45.89906], [8.99257, 45.9698], [9.01618, 46.04928], [9.24503, 46.23616], [9.29226, 46.32717], [9.25502, 46.43743], [9.28136, 46.49685], [9.36128, 46.5081], [9.40487, 46.46621], [9.45936, 46.50873], [9.46117, 46.37481], [9.57015, 46.2958], [9.71273, 46.29266], [9.73086, 46.35071], [9.95249, 46.38045], [10.07055, 46.21668], [10.14439, 46.22992], [10.17862, 46.25626], [10.10506, 46.3372], [10.165, 46.41051], [10.03715, 46.44479], [10.10307, 46.61003], [10.23674, 46.63484], [10.25309, 46.57432], [10.46136, 46.53164], [10.49375, 46.62049], [10.44686, 46.64162], [10.40475, 46.63671], [10.38659, 46.67847], [10.47197, 46.85698], [10.48376, 46.93891], [10.36933, 47.00212], [10.30031, 46.92093], [10.24128, 46.93147], [10.22675, 46.86942], [10.10715, 46.84296], [9.98058, 46.91434], [9.88266, 46.93343], [9.87935, 47.01337], [9.60717, 47.06091], [9.55721, 47.04762], [9.54041, 47.06495], [9.47548, 47.05257], [9.47139, 47.06402], [9.51362, 47.08505], [9.52089, 47.10019], [9.51044, 47.13727], [9.48774, 47.17402], [9.4891, 47.19346], [9.50318, 47.22153], [9.52406, 47.24959], [9.53116, 47.27029], [9.54773, 47.2809], [9.55857, 47.29919], [9.58513, 47.31334], [9.59978, 47.34671], [9.62476, 47.36639], [9.65427, 47.36824], [9.66243, 47.37136], [9.6711, 47.37824], [9.67445, 47.38429], [9.67334, 47.39191], [9.6629, 47.39591], [9.65136, 47.40504], [9.65043, 47.41937], [9.6446, 47.43233], [9.64483, 47.43842], [9.65863, 47.44847], [9.65728, 47.45383], [9.6423, 47.45599], [9.62475, 47.45685], [9.62158, 47.45858], [9.60841, 47.47178], [9.60484, 47.46358], [9.60205, 47.46165], [9.59482, 47.46305], [9.58208, 47.48344], [9.56312, 47.49495], [9.55125, 47.53629], [9.25619, 47.65939], [9.18203, 47.65598], [9.17593, 47.65399], [9.1755, 47.65584], [9.1705, 47.65513], [9.15181, 47.66904], [9.13845, 47.66389], [9.09891, 47.67801], [9.02093, 47.6868], [8.94093, 47.65596], [8.89946, 47.64769], [8.87625, 47.65441], [8.87383, 47.67045], [8.85065, 47.68209], [8.86989, 47.70504], [8.82002, 47.71458], [8.80663, 47.73821], [8.77309, 47.72059], [8.76965, 47.7075], [8.79966, 47.70222], [8.79511, 47.67462], [8.75856, 47.68969], [8.72809, 47.69282]], [[8.95861, 45.96485], [8.96668, 45.98436], [8.97741, 45.98317], [8.97604, 45.96151], [8.95861, 45.96485]], [[8.70847, 47.68904], [8.68985, 47.69552], [8.66837, 47.68437], [8.65769, 47.68928], [8.67508, 47.6979], [8.66416, 47.71367], [8.70237, 47.71453], [8.71773, 47.69088], [8.70847, 47.68904]]]] }, properties: { iso1A2: "CH", iso1A3: "CHE", iso1N3: "756", wikidata: "Q39", nameEn: "Switzerland", groups: ["155", "150", "UN"], callingCodes: ["41"] } },
22709     { type: "Feature", properties: { iso1A2: "CI", iso1A3: "CIV", iso1N3: "384", wikidata: "Q1008", nameEn: "C\xF4te d'Ivoire", groups: ["011", "202", "002", "UN"], callingCodes: ["225"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-7.52774, 3.7105], [-3.34019, 4.17519], [-3.10675, 5.08515], [-3.11073, 5.12675], [-3.063, 5.13665], [-2.96554, 5.10397], [-2.95261, 5.12477], [-2.75502, 5.10657], [-2.73074, 5.1364], [-2.77625, 5.34621], [-2.72737, 5.34789], [-2.76614, 5.60963], [-2.85378, 5.65156], [-2.93132, 5.62137], [-2.96671, 5.6415], [-2.95323, 5.71865], [-3.01896, 5.71697], [-3.25999, 6.62521], [-3.21954, 6.74407], [-3.23327, 6.81744], [-2.95438, 7.23737], [-2.97822, 7.27165], [-2.92339, 7.60847], [-2.79467, 7.86002], [-2.78395, 7.94974], [-2.74819, 7.92613], [-2.67787, 8.02055], [-2.61232, 8.02645], [-2.62901, 8.11495], [-2.49037, 8.20872], [-2.58243, 8.7789], [-2.66357, 9.01771], [-2.77799, 9.04949], [-2.69814, 9.22717], [-2.68802, 9.49343], [-2.76494, 9.40778], [-2.93012, 9.57403], [-3.00765, 9.74019], [-3.16609, 9.85147], [-3.19306, 9.93781], [-3.27228, 9.84981], [-3.31779, 9.91125], [-3.69703, 9.94279], [-4.25999, 9.76012], [-4.31392, 9.60062], [-4.6426, 9.70696], [-4.96621, 9.89132], [-4.96453, 9.99923], [-5.12465, 10.29788], [-5.39602, 10.2929], [-5.51058, 10.43177], [-5.65135, 10.46767], [-5.78124, 10.43952], [-5.99478, 10.19694], [-6.18851, 10.24244], [-6.1731, 10.46983], [-6.24795, 10.74248], [-6.325, 10.68624], [-6.40646, 10.69922], [-6.42847, 10.5694], [-6.52974, 10.59104], [-6.63541, 10.66893], [-6.68164, 10.35074], [-6.93921, 10.35291], [-7.01186, 10.25111], [-6.97444, 10.21644], [-7.00966, 10.15794], [-7.0603, 10.14711], [-7.13331, 10.24877], [-7.3707, 10.24677], [-7.44555, 10.44602], [-7.52261, 10.4655], [-7.54462, 10.40921], [-7.63048, 10.46334], [-7.92107, 10.15577], [-7.97971, 10.17117], [-8.01225, 10.1021], [-8.11921, 10.04577], [-8.15652, 9.94288], [-8.09434, 9.86936], [-8.14657, 9.55062], [-8.03463, 9.39604], [-7.85056, 9.41812], [-7.90777, 9.20456], [-7.73862, 9.08422], [-7.92518, 8.99332], [-7.95503, 8.81146], [-7.69882, 8.66148], [-7.65653, 8.36873], [-7.92518, 8.50652], [-8.22991, 8.48438], [-8.2411, 8.24196], [-8.062, 8.16071], [-7.98675, 8.20134], [-7.99919, 8.11023], [-7.94695, 8.00925], [-8.06449, 8.04989], [-8.13414, 7.87991], [-8.09931, 7.78626], [-8.21374, 7.54466], [-8.4003, 7.6285], [-8.47114, 7.55676], [-8.41935, 7.51203], [-8.37458, 7.25794], [-8.29249, 7.1691], [-8.31736, 6.82837], [-8.59456, 6.50612], [-8.48652, 6.43797], [-8.45666, 6.49977], [-8.38453, 6.35887], [-8.3298, 6.36381], [-8.17557, 6.28222], [-8.00642, 6.31684], [-7.90692, 6.27728], [-7.83478, 6.20309], [-7.8497, 6.08932], [-7.79747, 6.07696], [-7.78254, 5.99037], [-7.70294, 5.90625], [-7.67309, 5.94337], [-7.48155, 5.80974], [-7.46165, 5.84934], [-7.43677, 5.84687], [-7.43926, 5.74787], [-7.37209, 5.61173], [-7.43428, 5.42355], [-7.36463, 5.32944], [-7.46165, 5.26256], [-7.48901, 5.14118], [-7.55369, 5.08667], [-7.53876, 4.94294], [-7.59349, 4.8909], [-7.53259, 4.35145], [-7.52774, 3.7105]]]] } },
22710     { type: "Feature", properties: { iso1A2: "CK", iso1A3: "COK", iso1N3: "184", wikidata: "Q26988", nameEn: "Cook Islands", country: "NZ", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["682"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-168.15106, -10.26955], [-156.45576, -31.75456], [-156.48634, -15.52824], [-156.50903, -7.4975], [-168.15106, -10.26955]]]] } },
22711     { type: "Feature", properties: { iso1A2: "CL", iso1A3: "CHL", iso1N3: "152", wikidata: "Q298", nameEn: "Chile", groups: ["005", "419", "019", "UN"], callingCodes: ["56"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-68.60702, -52.65781], [-68.41683, -52.33516], [-69.97824, -52.00845], [-71.99889, -51.98018], [-72.33873, -51.59954], [-72.31343, -50.58411], [-73.15765, -50.78337], [-73.55259, -49.92488], [-73.45156, -49.79461], [-73.09655, -49.14342], [-72.56894, -48.81116], [-72.54042, -48.52392], [-72.27662, -48.28727], [-72.50478, -47.80586], [-71.94152, -47.13595], [-71.68577, -46.55385], [-71.75614, -45.61611], [-71.35687, -45.22075], [-72.06985, -44.81756], [-71.26418, -44.75684], [-71.16436, -44.46244], [-71.81318, -44.38097], [-71.64206, -43.64774], [-72.14828, -42.85321], [-72.15541, -42.15941], [-71.74901, -42.11711], [-71.92726, -40.72714], [-71.37826, -38.91474], [-70.89532, -38.6923], [-71.24279, -37.20264], [-70.95047, -36.4321], [-70.38008, -36.02375], [-70.49416, -35.24145], [-69.87386, -34.13344], [-69.88099, -33.34489], [-70.55832, -31.51559], [-70.14479, -30.36595], [-69.8596, -30.26131], [-69.99507, -29.28351], [-69.80969, -29.07185], [-69.66709, -28.44055], [-69.22504, -27.95042], [-68.77586, -27.16029], [-68.43363, -27.08414], [-68.27677, -26.90626], [-68.59048, -26.49861], [-68.56909, -26.28146], [-68.38372, -26.15353], [-68.57622, -25.32505], [-68.38372, -25.08636], [-68.56909, -24.69831], [-68.24825, -24.42596], [-67.33563, -24.04237], [-66.99632, -22.99839], [-67.18382, -22.81525], [-67.54284, -22.89771], [-67.85114, -22.87076], [-68.18816, -21.28614], [-68.40403, -20.94562], [-68.53957, -20.91542], [-68.55383, -20.7355], [-68.44023, -20.62701], [-68.7276, -20.46178], [-68.74273, -20.08817], [-68.57132, -20.03134], [-68.54611, -19.84651], [-68.66761, -19.72118], [-68.41218, -19.40499], [-68.61989, -19.27584], [-68.80602, -19.08355], [-68.87082, -19.06003], [-68.94987, -18.93302], [-69.07432, -18.28259], [-69.14807, -18.16893], [-69.07496, -18.03715], [-69.28671, -17.94844], [-69.34126, -17.72753], [-69.46623, -17.60518], [-69.46897, -17.4988], [-69.66483, -17.65083], [-69.79087, -17.65563], [-69.82868, -17.72048], [-69.75305, -17.94605], [-69.81607, -18.12582], [-69.96732, -18.25992], [-70.16394, -18.31737], [-70.31267, -18.31258], [-70.378, -18.3495], [-70.59118, -18.35072], [-113.52687, -26.52828], [-68.11646, -58.14883], [-66.07313, -55.19618], [-67.11046, -54.94199], [-67.46182, -54.92205], [-68.01394, -54.8753], [-68.60733, -54.9125], [-68.60702, -52.65781]]]] } },
22712     { type: "Feature", properties: { iso1A2: "CM", iso1A3: "CMR", iso1N3: "120", wikidata: "Q1009", nameEn: "Cameroon", groups: ["017", "202", "002", "UN"], callingCodes: ["237"] }, geometry: { type: "MultiPolygon", coordinates: [[[[14.83314, 12.62963], [14.55058, 12.78256], [14.56101, 12.91036], [14.46881, 13.08259], [14.08251, 13.0797], [14.20204, 12.53405], [14.17523, 12.41916], [14.22215, 12.36533], [14.4843, 12.35223], [14.6474, 12.17466], [14.61612, 11.7798], [14.55207, 11.72001], [14.64591, 11.66166], [14.6124, 11.51283], [14.17821, 11.23831], [13.97489, 11.30258], [13.78945, 11.00154], [13.7403, 11.00593], [13.70753, 10.94451], [13.73434, 10.9255], [13.54964, 10.61236], [13.5705, 10.53183], [13.43644, 10.13326], [13.34111, 10.12299], [13.25025, 10.03647], [13.25323, 10.00127], [13.286, 9.9822], [13.27409, 9.93232], [13.24132, 9.91031], [13.25025, 9.86042], [13.29941, 9.8296], [13.25472, 9.76795], [13.22642, 9.57266], [13.02385, 9.49334], [12.85628, 9.36698], [12.91958, 9.33905], [12.90022, 9.11411], [12.81085, 8.91992], [12.79, 8.75361], [12.71701, 8.7595], [12.68722, 8.65938], [12.44146, 8.6152], [12.4489, 8.52536], [12.26123, 8.43696], [12.24782, 8.17904], [12.19271, 8.10826], [12.20909, 7.97553], [11.99908, 7.67302], [12.01844, 7.52981], [11.93205, 7.47812], [11.84864, 7.26098], [11.87396, 7.09398], [11.63117, 6.9905], [11.55818, 6.86186], [11.57755, 6.74059], [11.51499, 6.60892], [11.42264, 6.5882], [11.42041, 6.53789], [11.09495, 6.51717], [11.09644, 6.68437], [10.94302, 6.69325], [10.8179, 6.83377], [10.83727, 6.9358], [10.60789, 7.06885], [10.59746, 7.14719], [10.57214, 7.16345], [10.53639, 6.93432], [10.21466, 6.88996], [10.15135, 7.03781], [9.86314, 6.77756], [9.77824, 6.79088], [9.70674, 6.51717], [9.51757, 6.43874], [8.84209, 5.82562], [8.88156, 5.78857], [8.83687, 5.68483], [8.92029, 5.58403], [8.78027, 5.1243], [8.60302, 4.87353], [8.34397, 4.30689], [9.22018, 3.72052], [9.81162, 2.33797], [9.82123, 2.35097], [9.83754, 2.32428], [9.83238, 2.29079], [9.84716, 2.24676], [9.89012, 2.20457], [9.90749, 2.20049], [9.991, 2.16561], [11.3561, 2.17217], [11.37116, 2.29975], [13.28534, 2.25716], [13.29457, 2.16106], [14.61145, 2.17866], [15.00996, 1.98887], [15.22634, 2.03243], [15.34776, 1.91264], [15.48942, 1.98265], [16.02959, 1.76483], [16.02647, 1.65591], [16.14634, 1.70259], [16.05294, 1.9811], [16.08563, 2.19733], [16.15568, 2.18955], [16.19357, 2.21537], [16.08252, 2.45708], [16.05449, 3.02306], [15.77725, 3.26835], [15.73522, 3.24348], [15.07686, 4.01805], [15.17482, 4.05131], [15.10644, 4.1362], [15.08609, 4.30282], [15.00825, 4.41458], [14.73383, 4.6135], [14.65489, 5.21343], [14.57083, 5.23979], [14.52724, 5.28319], [14.62531, 5.51411], [14.58951, 5.59777], [14.62375, 5.70466], [14.60974, 5.91838], [14.49455, 5.91683], [14.42917, 6.00508], [14.43073, 6.08867], [14.56149, 6.18928], [14.74206, 6.26356], [14.80122, 6.34866], [14.79966, 6.39043], [14.96311, 6.75693], [15.04717, 6.77085], [15.23397, 7.25135], [15.49743, 7.52179], [15.56964, 7.58936], [15.59272, 7.7696], [15.50743, 7.79302], [15.20426, 8.50892], [15.09484, 8.65982], [14.83566, 8.80557], [14.35707, 9.19611], [14.37094, 9.2954], [13.97544, 9.6365], [14.01793, 9.73169], [14.1317, 9.82413], [14.20411, 10.00055], [14.4673, 10.00264], [14.80082, 9.93818], [14.95722, 9.97926], [15.05999, 9.94845], [15.14043, 9.99246], [15.24618, 9.99246], [15.41408, 9.92876], [15.68761, 9.99344], [15.50535, 10.1098], [15.30874, 10.31063], [15.23724, 10.47764], [15.14936, 10.53915], [15.15532, 10.62846], [15.06737, 10.80921], [15.09127, 10.87431], [15.04957, 11.02347], [15.10021, 11.04101], [15.0585, 11.40481], [15.13149, 11.5537], [15.06595, 11.71126], [15.11579, 11.79313], [15.04808, 11.8731], [15.05786, 12.0608], [15.0349, 12.10698], [15.00146, 12.1223], [14.96952, 12.0925], [14.89019, 12.16593], [14.90827, 12.3269], [14.83314, 12.62963]]]] } },
22713     { type: "Feature", properties: { iso1A2: "CN", iso1A3: "CHN", iso1N3: "156", wikidata: "Q148", nameEn: "People's Republic of China" }, geometry: null },
22714     { type: "Feature", properties: { iso1A2: "CO", iso1A3: "COL", iso1N3: "170", wikidata: "Q739", nameEn: "Colombia", groups: ["005", "419", "019", "UN"], callingCodes: ["57"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-71.19849, 12.65801], [-81.58685, 18.0025], [-82.06974, 14.49418], [-82.56142, 11.91792], [-78.79327, 9.93766], [-77.58292, 9.22278], [-77.32389, 8.81247], [-77.45064, 8.49991], [-77.17257, 7.97422], [-77.57185, 7.51147], [-77.72514, 7.72348], [-77.72157, 7.47612], [-77.81426, 7.48319], [-77.89178, 7.22681], [-78.06168, 7.07793], [-82.12561, 4.00341], [-78.87137, 1.47457], [-78.42749, 1.15389], [-77.85677, 0.80197], [-77.7148, 0.85003], [-77.68613, 0.83029], [-77.66416, 0.81604], [-77.67815, 0.73863], [-77.49984, 0.64476], [-77.52001, 0.40782], [-76.89177, 0.24736], [-76.4094, 0.24015], [-76.41215, 0.38228], [-76.23441, 0.42294], [-75.82927, 0.09578], [-75.25764, -0.11943], [-75.18513, -0.0308], [-74.42701, -0.50218], [-74.26675, -0.97229], [-73.65312, -1.26222], [-72.92587, -2.44514], [-71.75223, -2.15058], [-70.94377, -2.23142], [-70.04609, -2.73906], [-70.71396, -3.7921], [-70.52393, -3.87553], [-70.3374, -3.79505], [-69.94708, -4.2431], [-69.43395, -1.42219], [-69.4215, -1.01853], [-69.59796, -0.75136], [-69.603, -0.51947], [-70.03658, -0.19681], [-70.04162, 0.55437], [-69.47696, 0.71065], [-69.20976, 0.57958], [-69.14422, 0.84172], [-69.26017, 1.06856], [-69.82987, 1.07864], [-69.83491, 1.69353], [-69.53746, 1.76408], [-69.38621, 1.70865], [-68.18128, 1.72881], [-68.26699, 1.83463], [-68.18632, 2.00091], [-67.9292, 1.82455], [-67.40488, 2.22258], [-67.299, 1.87494], [-67.15784, 1.80439], [-67.08222, 1.17441], [-66.85795, 1.22998], [-67.21967, 2.35778], [-67.65696, 2.81691], [-67.85862, 2.79173], [-67.85862, 2.86727], [-67.30945, 3.38393], [-67.50067, 3.75812], [-67.62671, 3.74303], [-67.85358, 4.53249], [-67.83341, 5.31104], [-67.59141, 5.5369], [-67.63914, 5.64963], [-67.58558, 5.84537], [-67.43513, 5.98835], [-67.4625, 6.20625], [-67.60654, 6.2891], [-69.41843, 6.1072], [-70.10716, 6.96516], [-70.7596, 7.09799], [-71.03941, 6.98163], [-71.37234, 7.01588], [-71.42212, 7.03854], [-71.44118, 7.02116], [-71.82441, 7.04314], [-72.04895, 7.03837], [-72.19437, 7.37034], [-72.43132, 7.40034], [-72.47415, 7.48928], [-72.45321, 7.57232], [-72.47827, 7.65604], [-72.46763, 7.79518], [-72.44454, 7.86031], [-72.46183, 7.90682], [-72.45806, 7.91141], [-72.47042, 7.92306], [-72.48183, 7.92909], [-72.48801, 7.94329], [-72.47213, 7.96106], [-72.39137, 8.03534], [-72.35163, 8.01163], [-72.36987, 8.19976], [-72.4042, 8.36513], [-72.65474, 8.61428], [-72.77415, 9.10165], [-72.94052, 9.10663], [-73.02119, 9.27584], [-73.36905, 9.16636], [-72.98085, 9.85253], [-72.88002, 10.44309], [-72.4767, 11.1117], [-72.24983, 11.14138], [-71.9675, 11.65536], [-71.3275, 11.85], [-70.92579, 11.96275], [-71.19849, 12.65801]]]] } },
22715     { type: "Feature", properties: { iso1A2: "CP", iso1A3: "CPT", wikidata: "Q161258", nameEn: "Clipperton Island", country: "FR", groups: ["EU", "013", "003", "019", "UN"], isoStatus: "excRes" }, geometry: { type: "MultiPolygon", coordinates: [[[[-110.36279, 9.79626], [-108.755, 9.84085], [-109.04145, 11.13245], [-110.36279, 9.79626]]]] } },
22716     { type: "Feature", properties: { iso1A2: "CR", iso1A3: "CRI", iso1N3: "188", wikidata: "Q800", nameEn: "Costa Rica", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["506"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-83.68276, 11.01562], [-83.66597, 10.79916], [-83.90838, 10.71161], [-84.68197, 11.07568], [-84.92439, 10.9497], [-85.60529, 11.22607], [-85.71223, 11.06868], [-86.14524, 11.09059], [-87.41779, 5.02401], [-82.94503, 7.93865], [-82.89978, 8.04083], [-82.89137, 8.05755], [-82.88641, 8.10219], [-82.9388, 8.26634], [-83.05209, 8.33394], [-82.93056, 8.43465], [-82.8679, 8.44042], [-82.8382, 8.48117], [-82.83322, 8.52464], [-82.83975, 8.54755], [-82.82739, 8.60153], [-82.8794, 8.6981], [-82.92068, 8.74832], [-82.91377, 8.774], [-82.88253, 8.83331], [-82.72126, 8.97125], [-82.93516, 9.07687], [-82.93516, 9.46741], [-82.84871, 9.4973], [-82.87919, 9.62645], [-82.77206, 9.59573], [-82.66667, 9.49746], [-82.61345, 9.49881], [-82.56507, 9.57279], [-82.51044, 9.65379], [-83.54024, 10.96805], [-83.68276, 11.01562]]]] } },
22717     { type: "Feature", properties: { iso1A2: "CU", iso1A3: "CUB", iso1N3: "192", wikidata: "Q241", nameEn: "Cuba", groups: ["029", "003", "419", "019", "UN"], callingCodes: ["53"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-73.62304, 20.6935], [-82.02215, 24.23074], [-85.77883, 21.92705], [-74.81171, 18.82201], [-73.62304, 20.6935]]]] } },
22718     { type: "Feature", properties: { iso1A2: "CV", iso1A3: "CPV", iso1N3: "132", wikidata: "Q1011", nameEn: "Cape Verde", groups: ["Q105472", "011", "202", "002", "UN"], callingCodes: ["238"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-28.81604, 14.57305], [-20.39702, 14.12816], [-23.37101, 19.134], [-28.81604, 14.57305]]]] } },
22719     { type: "Feature", properties: { iso1A2: "CW", iso1A3: "CUW", iso1N3: "531", wikidata: "Q25279", nameEn: "Cura\xE7ao", aliases: ["NL-CW"], country: "NL", groups: ["Q1451600", "029", "003", "419", "019", "UN"], callingCodes: ["599"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-68.90012, 12.62309], [-69.59009, 12.46019], [-68.99639, 11.79035], [-68.33524, 11.78151], [-68.90012, 12.62309]]]] } },
22720     { type: "Feature", properties: { iso1A2: "CX", iso1A3: "CXR", iso1N3: "162", wikidata: "Q31063", nameEn: "Christmas Island", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["61"] }, geometry: { type: "MultiPolygon", coordinates: [[[[105.66835, -9.31927], [104.67494, -11.2566], [106.66176, -11.14349], [105.66835, -9.31927]]]] } },
22721     { type: "Feature", properties: { iso1A2: "CY", iso1A3: "CYP", iso1N3: "196", wikidata: "Q229", nameEn: "Republic of Cyprus", groups: ["Q644636", "EU", "145", "142", "UN"], driveSide: "left", callingCodes: ["357"] }, geometry: { type: "MultiPolygon", coordinates: [[[[32.46489, 35.48584], [30.15137, 34.08517], [32.74412, 34.43926], [32.75515, 34.64985], [32.76136, 34.68318], [32.79433, 34.67883], [32.82717, 34.70622], [32.86014, 34.70585], [32.86167, 34.68734], [32.9068, 34.66102], [32.91398, 34.67343], [32.93043, 34.67091], [32.92807, 34.66736], [32.93449, 34.66241], [32.93693, 34.67027], [32.94379, 34.67111], [32.94683, 34.67907], [32.95539, 34.68471], [32.99135, 34.68061], [32.98668, 34.67268], [32.99014, 34.65518], [32.97736, 34.65277], [32.97079, 34.66112], [32.95325, 34.66462], [32.94796, 34.6587], [32.94976, 34.65204], [32.95471, 34.64528], [32.95323, 34.64075], [32.95891, 34.62919], [32.96718, 34.63446], [32.96968, 34.64046], [33.0138, 34.64424], [33.26744, 34.49942], [33.83531, 34.73974], [33.70575, 34.97947], [33.70639, 34.99303], [33.71514, 35.00294], [33.69731, 35.01754], [33.69938, 35.03123], [33.67678, 35.03866], [33.63765, 35.03869], [33.61215, 35.0527], [33.59658, 35.03635], [33.567, 35.04803], [33.57478, 35.06049], [33.53975, 35.08151], [33.48915, 35.06594], [33.47666, 35.00701], [33.45256, 35.00288], [33.45178, 35.02078], [33.47825, 35.04103], [33.48136, 35.0636], [33.46813, 35.10564], [33.41675, 35.16325], [33.4076, 35.20062], [33.38575, 35.2018], [33.37248, 35.18698], [33.3717, 35.1788], [33.36569, 35.17479], [33.35612, 35.17402], [33.35596, 35.17942], [33.34964, 35.17803], [33.35056, 35.18328], [33.31955, 35.18096], [33.3072, 35.16816], [33.27068, 35.16815], [33.15138, 35.19504], [33.11105, 35.15639], [33.08249, 35.17319], [33.01192, 35.15639], [32.94471, 35.09422], [32.86406, 35.1043], [32.85733, 35.07742], [32.70779, 35.14127], [32.70947, 35.18328], [32.64864, 35.19967], [32.60361, 35.16647], [32.46489, 35.48584]]], [[[33.74144, 35.01053], [33.7492, 35.01319], [33.74983, 35.02274], [33.74265, 35.02329], [33.73781, 35.02181], [33.7343, 35.01178], [33.74144, 35.01053]]], [[[33.77312, 34.9976], [33.75994, 35.00113], [33.75682, 34.99916], [33.76605, 34.99543], [33.76738, 34.99188], [33.7778, 34.98981], [33.77843, 34.988], [33.78149, 34.98854], [33.78318, 34.98699], [33.78571, 34.98951], [33.78917, 34.98854], [33.79191, 34.98914], [33.78516, 34.99582], [33.77553, 34.99518], [33.77312, 34.9976]]]] } },
22722     { type: "Feature", properties: { iso1A2: "CZ", iso1A3: "CZE", iso1N3: "203", wikidata: "Q213", nameEn: "Czechia", groups: ["EU", "151", "150", "UN"], callingCodes: ["420"] }, geometry: { type: "MultiPolygon", coordinates: [[[[14.82803, 50.86966], [14.79139, 50.81438], [14.70661, 50.84096], [14.61993, 50.86049], [14.63434, 50.8883], [14.65259, 50.90513], [14.64802, 50.93241], [14.58024, 50.91443], [14.56374, 50.922], [14.59702, 50.96148], [14.59908, 50.98685], [14.58215, 50.99306], [14.56432, 51.01008], [14.53438, 51.00374], [14.53321, 51.01679], [14.49873, 51.02242], [14.50809, 51.0427], [14.49991, 51.04692], [14.49154, 51.04382], [14.49202, 51.02286], [14.45827, 51.03712], [14.41335, 51.02086], [14.30098, 51.05515], [14.25665, 50.98935], [14.28776, 50.97718], [14.32353, 50.98556], [14.32793, 50.97379], [14.30251, 50.96606], [14.31422, 50.95243], [14.39848, 50.93866], [14.38691, 50.89907], [14.30098, 50.88448], [14.27123, 50.89386], [14.24314, 50.88761], [14.22331, 50.86049], [14.02982, 50.80662], [13.98864, 50.8177], [13.89113, 50.78533], [13.89444, 50.74142], [13.82942, 50.7251], [13.76316, 50.73487], [13.70204, 50.71771], [13.65977, 50.73096], [13.52474, 50.70394], [13.53748, 50.67654], [13.5226, 50.64721], [13.49742, 50.63133], [13.46413, 50.60102], [13.42189, 50.61243], [13.37485, 50.64931], [13.37805, 50.627], [13.32264, 50.60317], [13.32594, 50.58009], [13.29454, 50.57904], [13.25158, 50.59268], [13.19043, 50.50237], [13.13424, 50.51709], [13.08301, 50.50132], [13.0312, 50.50944], [13.02038, 50.4734], [13.02147, 50.44763], [12.98433, 50.42016], [12.94058, 50.40944], [12.82465, 50.45738], [12.73476, 50.43237], [12.73044, 50.42268], [12.70731, 50.39948], [12.67261, 50.41949], [12.51356, 50.39694], [12.48747, 50.37278], [12.49214, 50.35228], [12.48256, 50.34784], [12.46643, 50.35527], [12.43722, 50.33774], [12.43371, 50.32506], [12.39924, 50.32302], [12.40158, 50.29521], [12.36594, 50.28289], [12.35425, 50.23993], [12.33263, 50.24367], [12.32445, 50.20442], [12.33847, 50.19432], [12.32596, 50.17146], [12.29232, 50.17524], [12.28063, 50.19544], [12.28755, 50.22429], [12.23943, 50.24594], [12.24791, 50.25525], [12.26953, 50.25189], [12.25119, 50.27079], [12.20823, 50.2729], [12.18013, 50.32146], [12.10907, 50.32041], [12.13716, 50.27396], [12.09287, 50.25032], [12.19335, 50.19997], [12.21484, 50.16399], [12.1917, 50.13434], [12.2073, 50.10315], [12.23709, 50.10213], [12.27433, 50.0771], [12.26111, 50.06331], [12.30798, 50.05719], [12.49908, 49.97305], [12.47264, 49.94222], [12.55197, 49.92094], [12.48256, 49.83575], [12.46603, 49.78882], [12.40489, 49.76321], [12.4462, 49.70233], [12.52553, 49.68415], [12.53544, 49.61888], [12.56188, 49.6146], [12.60155, 49.52887], [12.64782, 49.52565], [12.64121, 49.47628], [12.669, 49.42935], [12.71227, 49.42363], [12.75854, 49.3989], [12.78168, 49.34618], [12.88414, 49.33541], [12.88249, 49.35479], [12.94859, 49.34079], [13.03618, 49.30417], [13.02957, 49.27399], [13.05883, 49.26259], [13.17665, 49.16713], [13.17019, 49.14339], [13.20405, 49.12303], [13.23689, 49.11412], [13.28242, 49.1228], [13.39479, 49.04812], [13.40802, 48.98851], [13.50221, 48.93752], [13.50552, 48.97441], [13.58319, 48.96899], [13.61624, 48.9462], [13.67739, 48.87886], [13.73854, 48.88538], [13.76994, 48.83537], [13.78977, 48.83319], [13.8096, 48.77877], [13.84023, 48.76988], [14.06151, 48.66873], [14.01482, 48.63788], [14.09104, 48.5943], [14.20691, 48.5898], [14.33909, 48.55852], [14.43076, 48.58855], [14.4587, 48.64695], [14.56139, 48.60429], [14.60808, 48.62881], [14.66762, 48.58215], [14.71794, 48.59794], [14.72756, 48.69502], [14.80584, 48.73489], [14.80821, 48.77711], [14.81545, 48.7874], [14.94773, 48.76268], [14.95641, 48.75915], [14.9758, 48.76857], [14.98112, 48.77524], [14.9782, 48.7766], [14.98032, 48.77959], [14.95072, 48.79101], [14.98917, 48.90082], [14.97612, 48.96983], [14.99878, 49.01444], [15.15534, 48.99056], [15.16358, 48.94278], [15.26177, 48.95766], [15.28305, 48.98831], [15.34823, 48.98444], [15.48027, 48.94481], [15.51357, 48.91549], [15.61622, 48.89541], [15.6921, 48.85973], [15.75341, 48.8516], [15.78087, 48.87644], [15.84404, 48.86921], [16.06034, 48.75436], [16.37345, 48.729], [16.40915, 48.74576], [16.46134, 48.80865], [16.67008, 48.77699], [16.68518, 48.7281], [16.71883, 48.73806], [16.79779, 48.70998], [16.90354, 48.71541], [16.93955, 48.60371], [17.00215, 48.70887], [17.11202, 48.82925], [17.19355, 48.87602], [17.29054, 48.85546], [17.3853, 48.80936], [17.45671, 48.85004], [17.5295, 48.81117], [17.7094, 48.86721], [17.73126, 48.87885], [17.77944, 48.92318], [17.87831, 48.92679], [17.91814, 49.01784], [18.06885, 49.03157], [18.1104, 49.08624], [18.15022, 49.24518], [18.18456, 49.28909], [18.36446, 49.3267], [18.4139, 49.36517], [18.4084, 49.40003], [18.44686, 49.39467], [18.54848, 49.47059], [18.53063, 49.49022], [18.57183, 49.51162], [18.6144, 49.49824], [18.67757, 49.50895], [18.74761, 49.492], [18.84521, 49.51672], [18.84786, 49.5446], [18.80479, 49.6815], [18.72838, 49.68163], [18.69817, 49.70473], [18.62676, 49.71983], [18.62943, 49.74603], [18.62645, 49.75002], [18.61368, 49.75426], [18.61278, 49.7618], [18.57183, 49.83334], [18.60341, 49.86256], [18.57045, 49.87849], [18.57697, 49.91565], [18.54299, 49.92537], [18.54495, 49.9079], [18.53423, 49.89906], [18.41604, 49.93498], [18.33562, 49.94747], [18.33278, 49.92415], [18.31914, 49.91565], [18.27794, 49.93863], [18.27107, 49.96779], [18.21752, 49.97309], [18.20241, 49.99958], [18.10628, 50.00223], [18.07898, 50.04535], [18.03212, 50.06574], [18.00396, 50.04954], [18.04585, 50.03311], [18.04585, 50.01194], [18.00191, 50.01723], [17.86886, 49.97452], [17.77669, 50.02253], [17.7506, 50.07896], [17.6888, 50.12037], [17.66683, 50.10275], [17.59404, 50.16437], [17.70528, 50.18812], [17.76296, 50.23382], [17.72176, 50.25665], [17.74648, 50.29966], [17.69292, 50.32859], [17.67764, 50.28977], [17.58889, 50.27837], [17.3702, 50.28123], [17.34548, 50.2628], [17.34273, 50.32947], [17.27681, 50.32246], [17.19991, 50.3654], [17.19579, 50.38817], [17.14498, 50.38117], [17.1224, 50.39494], [16.89229, 50.45117], [16.85933, 50.41093], [16.90877, 50.38642], [16.94448, 50.31281], [16.99803, 50.30316], [17.02138, 50.27772], [16.99803, 50.25753], [17.02825, 50.23118], [17.00353, 50.21449], [16.98018, 50.24172], [16.8456, 50.20834], [16.7014, 50.09659], [16.63137, 50.1142], [16.55446, 50.16613], [16.56407, 50.21009], [16.42674, 50.32509], [16.39379, 50.3207], [16.3622, 50.34875], [16.36495, 50.37679], [16.30289, 50.38292], [16.28118, 50.36891], [16.22821, 50.41054], [16.21585, 50.40627], [16.19526, 50.43291], [16.31413, 50.50274], [16.34572, 50.49575], [16.44597, 50.58041], [16.33611, 50.66579], [16.23174, 50.67101], [16.20839, 50.63096], [16.10265, 50.66405], [16.02437, 50.60046], [15.98317, 50.61528], [16.0175, 50.63009], [15.97219, 50.69799], [15.87331, 50.67188], [15.81683, 50.75666], [15.73186, 50.73885], [15.43798, 50.80833], [15.3803, 50.77187], [15.36656, 50.83956], [15.2773, 50.8907], [15.27043, 50.97724], [15.2361, 50.99886], [15.1743, 50.9833], [15.16744, 51.01959], [15.11937, 50.99021], [15.10152, 51.01095], [15.06218, 51.02269], [15.03895, 51.0123], [15.02433, 51.0242], [14.96419, 50.99108], [15.01088, 50.97984], [14.99852, 50.86817], [14.82803, 50.86966]]]] } },
22723     { type: "Feature", properties: { iso1A2: "DE", iso1A3: "DEU", iso1N3: "276", wikidata: "Q183", nameEn: "Germany", groups: ["EU", "155", "150", "UN"], callingCodes: ["49"] }, geometry: { type: "MultiPolygon", coordinates: [[[[8.70847, 47.68904], [8.71773, 47.69088], [8.70237, 47.71453], [8.66416, 47.71367], [8.67508, 47.6979], [8.65769, 47.68928], [8.66837, 47.68437], [8.68985, 47.69552], [8.70847, 47.68904]]], [[[8.72617, 47.69651], [8.72809, 47.69282], [8.75856, 47.68969], [8.79511, 47.67462], [8.79966, 47.70222], [8.76965, 47.7075], [8.77309, 47.72059], [8.80663, 47.73821], [8.82002, 47.71458], [8.86989, 47.70504], [8.85065, 47.68209], [8.87383, 47.67045], [8.87625, 47.65441], [8.89946, 47.64769], [8.94093, 47.65596], [9.02093, 47.6868], [9.09891, 47.67801], [9.13845, 47.66389], [9.15181, 47.66904], [9.1705, 47.65513], [9.1755, 47.65584], [9.17593, 47.65399], [9.18203, 47.65598], [9.25619, 47.65939], [9.55125, 47.53629], [9.72736, 47.53457], [9.76748, 47.5934], [9.80254, 47.59419], [9.82591, 47.58158], [9.8189, 47.54688], [9.87499, 47.52953], [9.87733, 47.54688], [9.92407, 47.53111], [9.96029, 47.53899], [10.00003, 47.48216], [10.03859, 47.48927], [10.07131, 47.45531], [10.09001, 47.46005], [10.1052, 47.4316], [10.06897, 47.40709], [10.09819, 47.35724], [10.11805, 47.37228], [10.16362, 47.36674], [10.17648, 47.38889], [10.2127, 47.38019], [10.22774, 47.38904], [10.23757, 47.37609], [10.19998, 47.32832], [10.2147, 47.31014], [10.17648, 47.29149], [10.17531, 47.27167], [10.23257, 47.27088], [10.33424, 47.30813], [10.39851, 47.37623], [10.4324, 47.38494], [10.4359, 47.41183], [10.47446, 47.43318], [10.46278, 47.47901], [10.44291, 47.48453], [10.4324, 47.50111], [10.44992, 47.5524], [10.43473, 47.58394], [10.47329, 47.58552], [10.48849, 47.54057], [10.56912, 47.53584], [10.60337, 47.56755], [10.63456, 47.5591], [10.68832, 47.55752], [10.6965, 47.54253], [10.7596, 47.53228], [10.77596, 47.51729], [10.88814, 47.53701], [10.91268, 47.51334], [10.86945, 47.5015], [10.87061, 47.4786], [10.90918, 47.48571], [10.93839, 47.48018], [10.92437, 47.46991], [10.98513, 47.42882], [10.97111, 47.41617], [10.97111, 47.39561], [11.11835, 47.39719], [11.12536, 47.41222], [11.20482, 47.43198], [11.25157, 47.43277], [11.22002, 47.3964], [11.27844, 47.39956], [11.29597, 47.42566], [11.33804, 47.44937], [11.4175, 47.44621], [11.38128, 47.47465], [11.4362, 47.51413], [11.52618, 47.50939], [11.58578, 47.52281], [11.58811, 47.55515], [11.60681, 47.57881], [11.63934, 47.59202], [11.84052, 47.58354], [11.85572, 47.60166], [12.0088, 47.62451], [12.02282, 47.61033], [12.05788, 47.61742], [12.13734, 47.60639], [12.17824, 47.61506], [12.18145, 47.61019], [12.17737, 47.60121], [12.18568, 47.6049], [12.20398, 47.60667], [12.20801, 47.61082], [12.19895, 47.64085], [12.18507, 47.65984], [12.18347, 47.66663], [12.16769, 47.68167], [12.16217, 47.70105], [12.18303, 47.70065], [12.22571, 47.71776], [12.2542, 47.7433], [12.26238, 47.73544], [12.24017, 47.69534], [12.26004, 47.67725], [12.27991, 47.68827], [12.336, 47.69534], [12.37222, 47.68433], [12.43883, 47.6977], [12.44117, 47.6741], [12.50076, 47.62293], [12.53816, 47.63553], [12.57438, 47.63238], [12.6071, 47.6741], [12.7357, 47.6787], [12.77777, 47.66689], [12.76492, 47.64485], [12.82101, 47.61493], [12.77427, 47.58025], [12.80699, 47.54477], [12.84672, 47.54556], [12.85256, 47.52741], [12.9624, 47.47452], [12.98344, 47.48716], [12.9998, 47.46267], [13.04537, 47.49426], [13.03252, 47.53373], [13.05355, 47.56291], [13.04537, 47.58183], [13.06641, 47.58577], [13.06407, 47.60075], [13.09562, 47.63304], [13.07692, 47.68814], [13.01382, 47.72116], [12.98578, 47.7078], [12.92969, 47.71094], [12.91333, 47.7178], [12.90274, 47.72513], [12.91711, 47.74026], [12.9353, 47.74788], [12.94371, 47.76281], [12.93202, 47.77302], [12.96311, 47.79957], [12.98543, 47.82896], [13.00588, 47.84374], [12.94163, 47.92927], [12.93886, 47.94046], [12.93642, 47.94436], [12.93419, 47.94063], [12.92668, 47.93879], [12.91985, 47.94069], [12.9211, 47.95135], [12.91683, 47.95647], [12.87476, 47.96195], [12.8549, 48.01122], [12.76141, 48.07373], [12.74973, 48.10885], [12.7617, 48.12796], [12.78595, 48.12445], [12.80676, 48.14979], [12.82673, 48.15245], [12.8362, 48.15876], [12.836, 48.1647], [12.84475, 48.16556], [12.87126, 48.20318], [12.95306, 48.20629], [13.02083, 48.25689], [13.0851, 48.27711], [13.126, 48.27867], [13.18093, 48.29577], [13.26039, 48.29422], [13.30897, 48.31575], [13.40709, 48.37292], [13.43929, 48.43386], [13.42527, 48.45711], [13.45727, 48.51092], [13.43695, 48.55776], [13.45214, 48.56472], [13.46967, 48.55157], [13.50663, 48.57506], [13.50131, 48.58091], [13.51291, 48.59023], [13.57535, 48.55912], [13.59705, 48.57013], [13.62508, 48.55501], [13.65186, 48.55092], [13.66113, 48.53558], [13.72802, 48.51208], [13.74816, 48.53058], [13.7513, 48.5624], [13.76921, 48.55324], [13.80519, 48.58026], [13.80038, 48.59487], [13.82609, 48.62345], [13.81901, 48.6761], [13.81283, 48.68426], [13.81791, 48.69832], [13.79337, 48.71375], [13.81863, 48.73257], [13.82266, 48.75544], [13.84023, 48.76988], [13.8096, 48.77877], [13.78977, 48.83319], [13.76994, 48.83537], [13.73854, 48.88538], [13.67739, 48.87886], [13.61624, 48.9462], [13.58319, 48.96899], [13.50552, 48.97441], [13.50221, 48.93752], [13.40802, 48.98851], [13.39479, 49.04812], [13.28242, 49.1228], [13.23689, 49.11412], [13.20405, 49.12303], [13.17019, 49.14339], [13.17665, 49.16713], [13.05883, 49.26259], [13.02957, 49.27399], [13.03618, 49.30417], [12.94859, 49.34079], [12.88249, 49.35479], [12.88414, 49.33541], [12.78168, 49.34618], [12.75854, 49.3989], [12.71227, 49.42363], [12.669, 49.42935], [12.64121, 49.47628], [12.64782, 49.52565], [12.60155, 49.52887], [12.56188, 49.6146], [12.53544, 49.61888], [12.52553, 49.68415], [12.4462, 49.70233], [12.40489, 49.76321], [12.46603, 49.78882], [12.48256, 49.83575], [12.55197, 49.92094], [12.47264, 49.94222], [12.49908, 49.97305], [12.30798, 50.05719], [12.26111, 50.06331], [12.27433, 50.0771], [12.23709, 50.10213], [12.2073, 50.10315], [12.1917, 50.13434], [12.21484, 50.16399], [12.19335, 50.19997], [12.09287, 50.25032], [12.13716, 50.27396], [12.10907, 50.32041], [12.18013, 50.32146], [12.20823, 50.2729], [12.25119, 50.27079], [12.26953, 50.25189], [12.24791, 50.25525], [12.23943, 50.24594], [12.28755, 50.22429], [12.28063, 50.19544], [12.29232, 50.17524], [12.32596, 50.17146], [12.33847, 50.19432], [12.32445, 50.20442], [12.33263, 50.24367], [12.35425, 50.23993], [12.36594, 50.28289], [12.40158, 50.29521], [12.39924, 50.32302], [12.43371, 50.32506], [12.43722, 50.33774], [12.46643, 50.35527], [12.48256, 50.34784], [12.49214, 50.35228], [12.48747, 50.37278], [12.51356, 50.39694], [12.67261, 50.41949], [12.70731, 50.39948], [12.73044, 50.42268], [12.73476, 50.43237], [12.82465, 50.45738], [12.94058, 50.40944], [12.98433, 50.42016], [13.02147, 50.44763], [13.02038, 50.4734], [13.0312, 50.50944], [13.08301, 50.50132], [13.13424, 50.51709], [13.19043, 50.50237], [13.25158, 50.59268], [13.29454, 50.57904], [13.32594, 50.58009], [13.32264, 50.60317], [13.37805, 50.627], [13.37485, 50.64931], [13.42189, 50.61243], [13.46413, 50.60102], [13.49742, 50.63133], [13.5226, 50.64721], [13.53748, 50.67654], [13.52474, 50.70394], [13.65977, 50.73096], [13.70204, 50.71771], [13.76316, 50.73487], [13.82942, 50.7251], [13.89444, 50.74142], [13.89113, 50.78533], [13.98864, 50.8177], [14.02982, 50.80662], [14.22331, 50.86049], [14.24314, 50.88761], [14.27123, 50.89386], [14.30098, 50.88448], [14.38691, 50.89907], [14.39848, 50.93866], [14.31422, 50.95243], [14.30251, 50.96606], [14.32793, 50.97379], [14.32353, 50.98556], [14.28776, 50.97718], [14.25665, 50.98935], [14.30098, 51.05515], [14.41335, 51.02086], [14.45827, 51.03712], [14.49202, 51.02286], [14.49154, 51.04382], [14.49991, 51.04692], [14.50809, 51.0427], [14.49873, 51.02242], [14.53321, 51.01679], [14.53438, 51.00374], [14.56432, 51.01008], [14.58215, 50.99306], [14.59908, 50.98685], [14.59702, 50.96148], [14.56374, 50.922], [14.58024, 50.91443], [14.64802, 50.93241], [14.65259, 50.90513], [14.63434, 50.8883], [14.61993, 50.86049], [14.70661, 50.84096], [14.79139, 50.81438], [14.82803, 50.86966], [14.81664, 50.88148], [14.89681, 50.9422], [14.89252, 50.94999], [14.92942, 50.99744], [14.95529, 51.04552], [14.97938, 51.07742], [14.98229, 51.11354], [14.99689, 51.12205], [14.99079, 51.14284], [14.99646, 51.14365], [15.00083, 51.14974], [14.99414, 51.15813], [14.99311, 51.16249], [15.0047, 51.16874], [15.01242, 51.21285], [15.04288, 51.28387], [14.98008, 51.33449], [14.96899, 51.38367], [14.9652, 51.44793], [14.94749, 51.47155], [14.73219, 51.52922], [14.72652, 51.53902], [14.73047, 51.54606], [14.71125, 51.56209], [14.7727, 51.61263], [14.75759, 51.62318], [14.75392, 51.67445], [14.69065, 51.70842], [14.66386, 51.73282], [14.64625, 51.79472], [14.60493, 51.80473], [14.59089, 51.83302], [14.6588, 51.88359], [14.6933, 51.9044], [14.70601, 51.92944], [14.7177, 51.94048], [14.72163, 51.95188], [14.71836, 51.95606], [14.7139, 51.95643], [14.70488, 51.97679], [14.71339, 52.00337], [14.76026, 52.06624], [14.72971, 52.09167], [14.6917, 52.10283], [14.67683, 52.13936], [14.70616, 52.16927], [14.68344, 52.19612], [14.71319, 52.22144], [14.70139, 52.25038], [14.58149, 52.28007], [14.56378, 52.33838], [14.55228, 52.35264], [14.54423, 52.42568], [14.63056, 52.48993], [14.60081, 52.53116], [14.6289, 52.57136], [14.61073, 52.59847], [14.22071, 52.81175], [14.13806, 52.82392], [14.12256, 52.84311], [14.15873, 52.87715], [14.14056, 52.95786], [14.25954, 53.00264], [14.35044, 53.05829], [14.38679, 53.13669], [14.36696, 53.16444], [14.37853, 53.20405], [14.40662, 53.21098], [14.45125, 53.26241], [14.44133, 53.27427], [14.4215, 53.27724], [14.35209, 53.49506], [14.3273, 53.50587], [14.30416, 53.55499], [14.31904, 53.61581], [14.2853, 53.63392], [14.28477, 53.65955], [14.27133, 53.66613], [14.2836, 53.67721], [14.26782, 53.69866], [14.27249, 53.74464], [14.21323, 53.8664], [14.20823, 53.90776], [14.18544, 53.91258], [14.20647, 53.91671], [14.22634, 53.9291], [14.20811, 54.12784], [13.93395, 54.84044], [12.85844, 54.82438], [11.90309, 54.38543], [11.00303, 54.63689], [10.31111, 54.65968], [10.16755, 54.73883], [9.89314, 54.84171], [9.73563, 54.8247], [9.61187, 54.85548], [9.62734, 54.88057], [9.58937, 54.88785], [9.4659, 54.83131], [9.43155, 54.82586], [9.41213, 54.84254], [9.38532, 54.83968], [9.36496, 54.81749], [9.33849, 54.80233], [9.32771, 54.80602], [9.2474, 54.8112], [9.23445, 54.83432], [9.24631, 54.84726], [9.20571, 54.85841], [9.14275, 54.87421], [9.04629, 54.87249], [8.92795, 54.90452], [8.81178, 54.90518], [8.76387, 54.8948], [8.63979, 54.91069], [8.55769, 54.91837], [8.45719, 55.06747], [8.02459, 55.09613], [5.45168, 54.20039], [6.91025, 53.44221], [7.00198, 53.32672], [7.19052, 53.31866], [7.21679, 53.20058], [7.22681, 53.18165], [7.17898, 53.13817], [7.21694, 53.00742], [7.07253, 52.81083], [7.04557, 52.63318], [6.77307, 52.65375], [6.71641, 52.62905], [6.69507, 52.488], [6.94293, 52.43597], [6.99041, 52.47235], [7.03417, 52.40237], [7.07044, 52.37805], [7.02703, 52.27941], [7.06365, 52.23789], [7.03729, 52.22695], [6.9897, 52.2271], [6.97189, 52.20329], [6.83984, 52.11728], [6.76117, 52.11895], [6.68128, 52.05052], [6.83035, 51.9905], [6.82357, 51.96711], [6.72319, 51.89518], [6.68386, 51.91861], [6.58556, 51.89386], [6.50231, 51.86313], [6.47179, 51.85395], [6.38815, 51.87257], [6.40704, 51.82771], [6.30593, 51.84998], [6.29872, 51.86801], [6.21443, 51.86801], [6.15349, 51.90439], [6.11551, 51.89769], [6.16902, 51.84094], [6.10337, 51.84829], [6.06705, 51.86136], [5.99848, 51.83195], [5.94568, 51.82786], [5.98665, 51.76944], [5.95003, 51.7493], [6.04091, 51.71821], [6.02767, 51.6742], [6.11759, 51.65609], [6.09055, 51.60564], [6.18017, 51.54096], [6.21724, 51.48568], [6.20654, 51.40049], [6.22641, 51.39948], [6.22674, 51.36135], [6.16977, 51.33169], [6.07889, 51.24432], [6.07889, 51.17038], [6.17384, 51.19589], [6.16706, 51.15677], [5.98292, 51.07469], [5.9541, 51.03496], [5.9134, 51.06736], [5.86735, 51.05182], [5.87849, 51.01969], [5.90493, 51.00198], [5.90296, 50.97356], [5.95282, 50.98728], [6.02697, 50.98303], [6.01615, 50.93367], [6.09297, 50.92066], [6.07486, 50.89307], [6.08805, 50.87223], [6.07693, 50.86025], [6.07431, 50.84674], [6.05702, 50.85179], [6.05623, 50.8572], [6.01921, 50.84435], [6.02328, 50.81694], [6.00462, 50.80065], [5.98404, 50.80988], [5.97497, 50.79992], [6.02624, 50.77453], [6.01976, 50.75398], [6.03889, 50.74618], [6.0326, 50.72647], [6.0406, 50.71848], [6.04428, 50.72861], [6.11707, 50.72231], [6.17852, 50.6245], [6.26957, 50.62444], [6.2476, 50.60392], [6.24888, 50.59869], [6.24005, 50.58732], [6.22581, 50.5907], [6.20281, 50.56952], [6.17739, 50.55875], [6.17802, 50.54179], [6.19735, 50.53576], [6.19579, 50.5313], [6.18716, 50.52653], [6.19193, 50.5212], [6.20599, 50.52089], [6.22335, 50.49578], [6.26637, 50.50272], [6.30809, 50.50058], [6.3465, 50.48833], [6.34005, 50.46083], [6.37219, 50.45397], [6.36852, 50.40776], [6.34406, 50.37994], [6.3688, 50.35898], [6.40785, 50.33557], [6.40641, 50.32425], [6.35701, 50.31139], [6.32488, 50.32333], [6.29949, 50.30887], [6.28797, 50.27458], [6.208, 50.25179], [6.16853, 50.2234], [6.18364, 50.20815], [6.18739, 50.1822], [6.14588, 50.17106], [6.14132, 50.14971], [6.15298, 50.14126], [6.1379, 50.12964], [6.12055, 50.09171], [6.11274, 50.05916], [6.13458, 50.04141], [6.13044, 50.02929], [6.14666, 50.02207], [6.13794, 50.01466], [6.13273, 50.02019], [6.1295, 50.01849], [6.13806, 50.01056], [6.14948, 50.00908], [6.14147, 49.99563], [6.1701, 49.98518], [6.16466, 49.97086], [6.17872, 49.9537], [6.18554, 49.95622], [6.18045, 49.96611], [6.19089, 49.96991], [6.19856, 49.95053], [6.22094, 49.94955], [6.22608, 49.929], [6.21882, 49.92403], [6.22926, 49.92096], [6.23496, 49.89972], [6.26146, 49.88203], [6.28874, 49.87592], [6.29692, 49.86685], [6.30963, 49.87021], [6.32303, 49.85133], [6.32098, 49.83728], [6.33585, 49.83785], [6.34267, 49.84974], [6.36576, 49.85032], [6.40022, 49.82029], [6.42521, 49.81591], [6.42905, 49.81091], [6.44131, 49.81443], [6.45425, 49.81164], [6.47111, 49.82263], [6.48718, 49.81267], [6.50647, 49.80916], [6.51215, 49.80124], [6.52121, 49.81338], [6.53122, 49.80666], [6.52169, 49.79787], [6.50534, 49.78952], [6.51669, 49.78336], [6.51056, 49.77515], [6.51828, 49.76855], [6.51646, 49.75961], [6.50174, 49.75292], [6.50193, 49.73291], [6.51805, 49.72425], [6.51397, 49.72058], [6.50261, 49.72718], [6.49535, 49.72645], [6.49694, 49.72205], [6.5042, 49.71808], [6.50647, 49.71353], [6.49785, 49.71118], [6.48014, 49.69767], [6.46048, 49.69092], [6.44654, 49.67799], [6.42937, 49.66857], [6.42726, 49.66078], [6.43768, 49.66021], [6.4413, 49.65722], [6.41861, 49.61723], [6.39822, 49.60081], [6.385, 49.59946], [6.37464, 49.58886], [6.38342, 49.5799], [6.38024, 49.57593], [6.36676, 49.57813], [6.35825, 49.57053], [6.38228, 49.55855], [6.38072, 49.55171], [6.35666, 49.52931], [6.36788, 49.50377], [6.36907, 49.48931], [6.36778, 49.46937], [6.38352, 49.46463], [6.39168, 49.4667], [6.40274, 49.46546], [6.42432, 49.47683], [6.55404, 49.42464], [6.533, 49.40748], [6.60091, 49.36864], [6.58807, 49.35358], [6.572, 49.35027], [6.60186, 49.31055], [6.66583, 49.28065], [6.69274, 49.21661], [6.71843, 49.2208], [6.73256, 49.20486], [6.71137, 49.18808], [6.73765, 49.16375], [6.78265, 49.16793], [6.83385, 49.15162], [6.84703, 49.15734], [6.86225, 49.18185], [6.85016, 49.19354], [6.85119, 49.20038], [6.83555, 49.21249], [6.85939, 49.22376], [6.89298, 49.20863], [6.91875, 49.22261], [6.93831, 49.2223], [6.94028, 49.21641], [6.95963, 49.203], [6.97273, 49.2099], [7.01318, 49.19018], [7.03459, 49.19096], [7.0274, 49.17042], [7.03178, 49.15734], [7.04662, 49.13724], [7.04409, 49.12123], [7.04843, 49.11422], [7.05548, 49.11185], [7.06642, 49.11415], [7.07162, 49.1255], [7.09007, 49.13094], [7.07859, 49.15031], [7.10715, 49.15631], [7.10384, 49.13787], [7.12504, 49.14253], [7.1358, 49.1282], [7.1593, 49.1204], [7.23473, 49.12971], [7.29514, 49.11426], [7.3195, 49.14231], [7.35995, 49.14399], [7.3662, 49.17308], [7.44052, 49.18354], [7.44455, 49.16765], [7.49473, 49.17], [7.49172, 49.13915], [7.53012, 49.09818], [7.56416, 49.08136], [7.62575, 49.07654], [7.63618, 49.05428], [7.75948, 49.04562], [7.79557, 49.06583], [7.86386, 49.03499], [7.93641, 49.05544], [7.97783, 49.03161], [8.14189, 48.97833], [8.22604, 48.97352], [8.20031, 48.95856], [8.19989, 48.95825], [8.12813, 48.87985], [8.10253, 48.81829], [8.06802, 48.78957], [8.0326, 48.79017], [8.01534, 48.76085], [7.96994, 48.75606], [7.96812, 48.72491], [7.89002, 48.66317], [7.84098, 48.64217], [7.80057, 48.5857], [7.80167, 48.54758], [7.80647, 48.51239], [7.76833, 48.48945], [7.73109, 48.39192], [7.74562, 48.32736], [7.69022, 48.30018], [7.6648, 48.22219], [7.57137, 48.12292], [7.56966, 48.03265], [7.62302, 47.97898], [7.55673, 47.87371], [7.52921, 47.77747], [7.54761, 47.72912], [7.53722, 47.71635], [7.51266, 47.70197], [7.51915, 47.68335], [7.52067, 47.66437], [7.53384, 47.65115], [7.5591, 47.63849], [7.57423, 47.61628], [7.58851, 47.60794], [7.59301, 47.60058], [7.58945, 47.59017], [7.60523, 47.58519], [7.60459, 47.57869], [7.61929, 47.57683], [7.64309, 47.59151], [7.64213, 47.5944], [7.64599, 47.59695], [7.67395, 47.59212], [7.68229, 47.59905], [7.69385, 47.60099], [7.68486, 47.59601], [7.67115, 47.5871], [7.68904, 47.57133], [7.67655, 47.56435], [7.63338, 47.56256], [7.65083, 47.54662], [7.66174, 47.54554], [7.6656, 47.53752], [7.68101, 47.53232], [7.69642, 47.53297], [7.71961, 47.54219], [7.75261, 47.54599], [7.79486, 47.55691], [7.81901, 47.58798], [7.84412, 47.5841], [7.88664, 47.58854], [7.90673, 47.57674], [7.91251, 47.55031], [7.94494, 47.54511], [7.95682, 47.55789], [7.97581, 47.55493], [8.00113, 47.55616], [8.02136, 47.55096], [8.04383, 47.55443], [8.06663, 47.56374], [8.08557, 47.55768], [8.10002, 47.56504], [8.10395, 47.57918], [8.11543, 47.5841], [8.13662, 47.58432], [8.13823, 47.59147], [8.14947, 47.59558], [8.1652, 47.5945], [8.19378, 47.61636], [8.20617, 47.62141], [8.22011, 47.6181], [8.22577, 47.60385], [8.23809, 47.61204], [8.25863, 47.61571], [8.26313, 47.6103], [8.2824, 47.61225], [8.29722, 47.60603], [8.29524, 47.5919], [8.30277, 47.58607], [8.32735, 47.57133], [8.35512, 47.57014], [8.38273, 47.56608], [8.39477, 47.57826], [8.43235, 47.56617], [8.49431, 47.58107], [8.48949, 47.588], [8.46637, 47.58389], [8.45578, 47.60121], [8.50747, 47.61897], [8.51686, 47.63476], [8.55756, 47.62394], [8.57586, 47.59537], [8.60348, 47.61204], [8.59545, 47.64298], [8.60701, 47.65271], [8.61471, 47.64514], [8.60412, 47.63735], [8.62049, 47.63757], [8.62884, 47.65098], [8.61113, 47.66332], [8.6052, 47.67258], [8.57683, 47.66158], [8.56141, 47.67088], [8.52801, 47.66059], [8.5322, 47.64687], [8.49656, 47.64709], [8.46605, 47.64103], [8.4667, 47.65747], [8.44711, 47.65379], [8.42264, 47.66667], [8.41346, 47.66676], [8.40473, 47.67499], [8.4211, 47.68407], [8.40569, 47.69855], [8.44807, 47.72426], [8.45771, 47.7493], [8.48868, 47.77215], [8.56814, 47.78001], [8.56415, 47.80633], [8.61657, 47.79998], [8.62408, 47.7626], [8.64425, 47.76398], [8.65292, 47.80066], [8.68022, 47.78599], [8.68985, 47.75686], [8.71778, 47.76571], [8.74251, 47.75168], [8.70543, 47.73121], [8.73671, 47.7169], [8.72617, 47.69651]]]] } },
22724     { type: "Feature", properties: { iso1A2: "DG", iso1A3: "DGA", wikidata: "Q184851", nameEn: "Diego Garcia", country: "GB", groups: ["IO", "BOTS", "014", "202", "002", "UN"], isoStatus: "excRes", callingCodes: ["246"] }, geometry: { type: "MultiPolygon", coordinates: [[[[73.14823, -7.76302], [73.09982, -6.07324], [71.43792, -7.73904], [73.14823, -7.76302]]]] } },
22725     { type: "Feature", properties: { iso1A2: "DJ", iso1A3: "DJI", iso1N3: "262", wikidata: "Q977", nameEn: "Djibouti", groups: ["014", "202", "002", "UN"], callingCodes: ["253"] }, geometry: { type: "MultiPolygon", coordinates: [[[[43.90659, 12.3823], [43.90659, 12.3823], [43.32909, 12.59711], [43.29075, 12.79154], [42.86195, 12.58747], [42.7996, 12.42629], [42.6957, 12.36201], [42.46941, 12.52661], [42.4037, 12.46478], [41.95461, 11.81157], [41.82878, 11.72361], [41.77727, 11.49902], [41.8096, 11.33606], [41.80056, 10.97127], [42.06302, 10.92599], [42.13691, 10.97586], [42.42669, 10.98493], [42.62989, 11.09711], [42.75111, 11.06992], [42.79037, 10.98493], [42.95776, 10.98533], [43.90659, 12.3823]]]] } },
22726     { type: "Feature", properties: { iso1A2: "DK", iso1A3: "DNK", iso1N3: "208", wikidata: "Q756617", nameEn: "Kingdom of Denmark" }, geometry: null },
22727     { type: "Feature", properties: { iso1A2: "DM", iso1A3: "DMA", iso1N3: "212", wikidata: "Q784", nameEn: "Dominica", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 767"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-61.32485, 14.91445], [-60.86656, 15.82603], [-61.95646, 15.5094], [-61.32485, 14.91445]]]] } },
22728     { type: "Feature", properties: { iso1A2: "DO", iso1A3: "DOM", iso1N3: "214", wikidata: "Q786", nameEn: "Dominican Republic", groups: ["029", "003", "419", "019", "UN"], callingCodes: ["1 809", "1 829", "1 849"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-67.87844, 21.7938], [-72.38946, 20.27111], [-71.77419, 19.73128], [-71.75865, 19.70231], [-71.7429, 19.58445], [-71.71449, 19.55364], [-71.71268, 19.53374], [-71.6802, 19.45008], [-71.69448, 19.37866], [-71.77766, 19.33823], [-71.73229, 19.26686], [-71.62642, 19.21212], [-71.65337, 19.11759], [-71.69938, 19.10916], [-71.71088, 19.08353], [-71.74088, 19.0437], [-71.88102, 18.95007], [-71.77766, 18.95007], [-71.72624, 18.87802], [-71.71885, 18.78423], [-71.82556, 18.62551], [-71.95412, 18.64939], [-72.00201, 18.62312], [-71.88102, 18.50125], [-71.90875, 18.45821], [-71.69952, 18.34101], [-71.78271, 18.18302], [-71.75465, 18.14405], [-71.74994, 18.11115], [-71.73783, 18.07177], [-71.75671, 18.03456], [-72.29523, 17.48026], [-68.39466, 16.14167], [-67.87844, 21.7938]]]] } },
22729     { type: "Feature", properties: { iso1A2: "DZ", iso1A3: "DZA", iso1N3: "012", wikidata: "Q262", nameEn: "Algeria", groups: ["015", "002", "UN"], callingCodes: ["213"] }, geometry: { type: "MultiPolygon", coordinates: [[[[8.59123, 37.14286], [5.10072, 39.89531], [-2.27707, 35.35051], [-2.21248, 35.08532], [-2.21445, 35.04378], [-2.04734, 34.93218], [-1.97833, 34.93218], [-1.97469, 34.886], [-1.73707, 34.74226], [-1.84569, 34.61907], [-1.69788, 34.48056], [-1.78042, 34.39018], [-1.64666, 34.10405], [-1.73494, 33.71721], [-1.59508, 33.59929], [-1.67067, 33.27084], [-1.46249, 33.0499], [-1.54244, 32.95499], [-1.37794, 32.73628], [-0.9912, 32.52467], [-1.24998, 32.32993], [-1.24453, 32.1917], [-1.15735, 32.12096], [-1.22829, 32.07832], [-2.46166, 32.16603], [-2.93873, 32.06557], [-2.82784, 31.79459], [-3.66314, 31.6339], [-3.66386, 31.39202], [-3.77647, 31.31912], [-3.77103, 31.14984], [-3.54944, 31.0503], [-3.65418, 30.85566], [-3.64735, 30.67539], [-4.31774, 30.53229], [-4.6058, 30.28343], [-5.21671, 29.95253], [-5.58831, 29.48103], [-5.72121, 29.52322], [-5.75616, 29.61407], [-6.69965, 29.51623], [-6.78351, 29.44634], [-6.95824, 29.50924], [-7.61585, 29.36252], [-8.6715, 28.71194], [-8.66879, 27.6666], [-8.66674, 27.31569], [-4.83423, 24.99935], [1.15698, 21.12843], [1.20992, 20.73533], [3.24648, 19.81703], [3.12501, 19.1366], [3.36082, 18.9745], [4.26651, 19.14224], [5.8153, 19.45101], [7.38361, 20.79165], [7.48273, 20.87258], [11.96886, 23.51735], [11.62498, 24.26669], [11.41061, 24.21456], [10.85323, 24.5595], [10.33159, 24.5465], [10.02432, 24.98124], [10.03146, 25.35635], [9.38834, 26.19288], [9.51696, 26.39148], [9.89569, 26.57696], [9.78136, 29.40961], [9.3876, 30.16738], [9.55544, 30.23971], [9.07483, 32.07865], [8.35999, 32.50101], [8.31895, 32.83483], [8.1179, 33.05086], [8.11433, 33.10175], [7.83028, 33.18851], [7.73687, 33.42114], [7.54088, 33.7726], [7.52851, 34.06493], [7.66174, 34.20167], [7.74207, 34.16492], [7.81242, 34.21841], [7.86264, 34.3987], [8.20482, 34.57575], [8.29655, 34.72798], [8.25189, 34.92009], [8.30727, 34.95378], [8.3555, 35.10007], [8.47318, 35.23376], [8.30329, 35.29884], [8.36086, 35.47774], [8.35371, 35.66373], [8.26472, 35.73669], [8.2626, 35.91733], [8.40731, 36.42208], [8.18936, 36.44939], [8.16167, 36.48817], [8.47609, 36.66607], [8.46537, 36.7706], [8.57613, 36.78062], [8.67706, 36.8364], [8.62972, 36.86499], [8.64044, 36.9401], [8.59123, 37.14286]]]] } },
22730     { type: "Feature", properties: { iso1A2: "EA", wikidata: "Q28868874", nameEn: "Ceuta, Melilla", country: "ES", level: "territory", isoStatus: "excRes" }, geometry: null },
22731     { type: "Feature", properties: { iso1A2: "EC", iso1A3: "ECU", iso1N3: "218", wikidata: "Q736", nameEn: "Ecuador" }, geometry: null },
22732     { type: "Feature", properties: { iso1A2: "EE", iso1A3: "EST", iso1N3: "233", wikidata: "Q191", nameEn: "Estonia", aliases: ["EW"], groups: ["EU", "154", "150", "UN"], callingCodes: ["372"] }, geometry: { type: "MultiPolygon", coordinates: [[[[26.32936, 60.00121], [20.5104, 59.15546], [19.84909, 57.57876], [22.80496, 57.87798], [23.20055, 57.56697], [24.26221, 57.91787], [24.3579, 57.87471], [25.19484, 58.0831], [25.28237, 57.98539], [25.29581, 58.08288], [25.73499, 57.90193], [26.05949, 57.84744], [26.0324, 57.79037], [26.02456, 57.78342], [26.027, 57.78158], [26.0266, 57.77441], [26.02069, 57.77169], [26.02415, 57.76865], [26.03332, 57.7718], [26.0543, 57.76105], [26.08098, 57.76619], [26.2029, 57.7206], [26.1866, 57.6849], [26.29253, 57.59244], [26.46527, 57.56885], [26.54675, 57.51813], [26.90364, 57.62823], [27.34698, 57.52242], [27.31919, 57.57672], [27.40393, 57.62125], [27.3746, 57.66834], [27.52615, 57.72843], [27.50171, 57.78842], [27.56689, 57.83356], [27.78526, 57.83963], [27.81841, 57.89244], [27.67282, 57.92627], [27.62393, 58.09462], [27.48541, 58.22615], [27.55489, 58.39525], [27.36366, 58.78381], [27.74429, 58.98351], [27.80482, 59.1116], [27.87978, 59.18097], [27.90911, 59.24353], [28.00689, 59.28351], [28.14215, 59.28934], [28.19284, 59.35791], [28.20537, 59.36491], [28.21137, 59.38058], [28.19061, 59.39962], [28.04187, 59.47017], [27.85643, 59.58538], [26.90044, 59.63819], [26.32936, 60.00121]]]] } },
22733     { type: "Feature", properties: { iso1A2: "EG", iso1A3: "EGY", iso1N3: "818", wikidata: "Q79", nameEn: "Egypt", groups: ["015", "002", "UN"], callingCodes: ["20"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.62659, 31.82938], [26.92891, 33.39516], [24.8458, 31.39877], [25.01077, 30.73861], [24.71117, 30.17441], [24.99968, 29.24574], [24.99885, 21.99535], [33.17563, 22.00405], [34.0765, 22.00501], [37.8565, 22.00903], [34.4454, 27.91479], [34.8812, 29.36878], [34.92298, 29.45305], [34.26742, 31.21998], [34.24012, 31.29591], [34.23572, 31.2966], [34.21853, 31.32363], [34.052, 31.46619], [33.62659, 31.82938]]]] } },
22734     { type: "Feature", properties: { iso1A2: "EH", iso1A3: "ESH", iso1N3: "732", wikidata: "Q6250", nameEn: "Western Sahara", groups: ["015", "002"], callingCodes: ["212"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-8.66879, 27.6666], [-8.77527, 27.66663], [-8.71787, 26.9898], [-9.08698, 26.98639], [-9.56957, 26.90042], [-9.81998, 26.71379], [-10.68417, 26.90984], [-11.35695, 26.8505], [-11.23622, 26.72023], [-11.38635, 26.611], [-11.62052, 26.05229], [-12.06001, 26.04442], [-12.12281, 25.13682], [-12.92147, 24.39502], [-13.00628, 24.01923], [-13.75627, 23.77231], [-14.10361, 22.75501], [-14.1291, 22.41636], [-14.48112, 22.00886], [-14.47329, 21.63839], [-14.78487, 21.36587], [-16.44269, 21.39745], [-16.9978, 21.36239], [-17.02707, 21.34022], [-17.21511, 21.34226], [-17.35589, 20.80492], [-17.0471, 20.76408], [-17.0695, 20.85742], [-17.06781, 20.92697], [-17.0396, 20.9961], [-17.0357, 21.05368], [-16.99806, 21.12142], [-16.95474, 21.33997], [-13.01525, 21.33343], [-13.08438, 22.53866], [-13.15313, 22.75649], [-13.10753, 22.89493], [-13.00412, 23.02297], [-12.5741, 23.28975], [-12.36213, 23.3187], [-12.14969, 23.41935], [-12.00251, 23.4538], [-12.0002, 25.9986], [-8.66721, 25.99918], [-8.66674, 27.31569], [-8.66879, 27.6666]]]] } },
22735     { type: "Feature", properties: { iso1A2: "ER", iso1A3: "ERI", iso1N3: "232", wikidata: "Q986", nameEn: "Eritrea", groups: ["014", "202", "002", "UN"], callingCodes: ["291"] }, geometry: { type: "MultiPolygon", coordinates: [[[[40.99158, 15.81743], [39.63762, 18.37348], [38.57727, 17.98125], [38.45916, 17.87167], [38.37133, 17.66269], [38.13362, 17.53906], [37.50967, 17.32199], [37.42694, 17.04041], [36.99777, 17.07172], [36.92193, 16.23451], [36.76371, 15.80831], [36.69761, 15.75323], [36.54276, 15.23478], [36.44337, 15.14963], [36.54376, 14.25597], [36.56536, 14.26177], [36.55659, 14.28237], [36.63364, 14.31172], [36.85787, 14.32201], [37.01622, 14.2561], [37.09486, 14.27155], [37.13206, 14.40746], [37.3106, 14.44657], [37.47319, 14.2149], [37.528, 14.18413], [37.91287, 14.89447], [38.0364, 14.72745], [38.25562, 14.67287], [38.3533, 14.51323], [38.45748, 14.41445], [38.78306, 14.4754], [38.98058, 14.54895], [39.02834, 14.63717], [39.16074, 14.65187], [39.14772, 14.61827], [39.19547, 14.56996], [39.23888, 14.56365], [39.26927, 14.48801], [39.2302, 14.44598], [39.2519, 14.40393], [39.37685, 14.54402], [39.52756, 14.49011], [39.50585, 14.55735], [39.58182, 14.60987], [39.76632, 14.54264], [39.9443, 14.41024], [40.07236, 14.54264], [40.14649, 14.53969], [40.21128, 14.39342], [40.25686, 14.41445], [40.9167, 14.11152], [41.25097, 13.60787], [41.62864, 13.38626], [42.05841, 12.80912], [42.21469, 12.75832], [42.2798, 12.6355], [42.4037, 12.46478], [42.46941, 12.52661], [42.6957, 12.36201], [42.7996, 12.42629], [42.86195, 12.58747], [43.29075, 12.79154], [40.99158, 15.81743]]]] } },
22736     { type: "Feature", properties: { iso1A2: "ES", iso1A3: "ESP", iso1N3: "724", wikidata: "Q29", nameEn: "Spain" }, geometry: null },
22737     { type: "Feature", properties: { iso1A2: "ET", iso1A3: "ETH", iso1N3: "231", wikidata: "Q115", nameEn: "Ethiopia", groups: ["014", "202", "002", "UN"], callingCodes: ["251"] }, geometry: { type: "MultiPolygon", coordinates: [[[[42.4037, 12.46478], [42.2798, 12.6355], [42.21469, 12.75832], [42.05841, 12.80912], [41.62864, 13.38626], [41.25097, 13.60787], [40.9167, 14.11152], [40.25686, 14.41445], [40.21128, 14.39342], [40.14649, 14.53969], [40.07236, 14.54264], [39.9443, 14.41024], [39.76632, 14.54264], [39.58182, 14.60987], [39.50585, 14.55735], [39.52756, 14.49011], [39.37685, 14.54402], [39.2519, 14.40393], [39.2302, 14.44598], [39.26927, 14.48801], [39.23888, 14.56365], [39.19547, 14.56996], [39.14772, 14.61827], [39.16074, 14.65187], [39.02834, 14.63717], [38.98058, 14.54895], [38.78306, 14.4754], [38.45748, 14.41445], [38.3533, 14.51323], [38.25562, 14.67287], [38.0364, 14.72745], [37.91287, 14.89447], [37.528, 14.18413], [37.47319, 14.2149], [37.3106, 14.44657], [37.13206, 14.40746], [37.09486, 14.27155], [37.01622, 14.2561], [36.85787, 14.32201], [36.63364, 14.31172], [36.55659, 14.28237], [36.56536, 14.26177], [36.54376, 14.25597], [36.44653, 13.95666], [36.48824, 13.83954], [36.38993, 13.56459], [36.24545, 13.36759], [36.13374, 12.92665], [36.16651, 12.88019], [36.14268, 12.70879], [36.01458, 12.72478], [35.70476, 12.67101], [35.24302, 11.91132], [35.11492, 11.85156], [35.05832, 11.71158], [35.09556, 11.56278], [34.95704, 11.24448], [35.01215, 11.19626], [34.93172, 10.95946], [34.97789, 10.91559], [34.97491, 10.86147], [34.86916, 10.78832], [34.86618, 10.74588], [34.77532, 10.69027], [34.77383, 10.74588], [34.59062, 10.89072], [34.4372, 10.781], [34.2823, 10.53508], [34.34783, 10.23914], [34.32102, 10.11599], [34.22718, 10.02506], [34.20484, 9.9033], [34.13186, 9.7492], [34.08717, 9.55243], [34.10229, 9.50238], [34.14304, 9.04654], [34.14453, 8.60204], [34.01346, 8.50041], [33.89579, 8.4842], [33.87195, 8.41938], [33.71407, 8.3678], [33.66938, 8.44442], [33.54575, 8.47094], [33.3119, 8.45474], [33.19721, 8.40317], [33.1853, 8.29264], [33.18083, 8.13047], [33.08401, 8.05822], [33.0006, 7.90333], [33.04944, 7.78989], [33.24637, 7.77939], [33.32531, 7.71297], [33.44745, 7.7543], [33.71407, 7.65983], [33.87642, 7.5491], [34.02984, 7.36449], [34.03878, 7.27437], [34.01495, 7.25664], [34.19369, 7.12807], [34.19369, 7.04382], [34.35753, 6.91963], [34.47669, 6.91076], [34.53925, 6.82794], [34.53776, 6.74808], [34.65096, 6.72589], [34.77459, 6.5957], [34.87736, 6.60161], [35.01738, 6.46991], [34.96227, 6.26415], [35.00546, 5.89387], [35.12611, 5.68937], [35.13058, 5.62118], [35.31188, 5.50106], [35.29938, 5.34042], [35.50792, 5.42431], [35.8576, 5.33413], [35.81968, 5.10757], [35.82118, 4.77382], [35.9419, 4.61933], [35.95449, 4.53244], [36.03924, 4.44406], [36.84474, 4.44518], [37.07724, 4.33503], [38.14168, 3.62487], [38.45812, 3.60445], [38.52336, 3.62551], [38.91938, 3.51198], [39.07736, 3.5267], [39.19954, 3.47834], [39.49444, 3.45521], [39.51551, 3.40895], [39.55132, 3.39634], [39.58339, 3.47434], [39.76808, 3.67058], [39.86043, 3.86974], [40.77498, 4.27683], [41.1754, 3.94079], [41.89488, 3.97375], [42.07619, 4.17667], [42.55853, 4.20518], [42.84526, 4.28357], [42.97746, 4.44032], [43.04177, 4.57923], [43.40263, 4.79289], [44.02436, 4.9451], [44.98104, 4.91821], [47.97917, 8.00124], [47.92477, 8.00111], [46.99339, 7.9989], [44.19222, 8.93028], [43.32613, 9.59205], [43.23518, 9.84605], [43.0937, 9.90579], [42.87643, 10.18441], [42.69452, 10.62672], [42.95776, 10.98533], [42.79037, 10.98493], [42.75111, 11.06992], [42.62989, 11.09711], [42.42669, 10.98493], [42.13691, 10.97586], [42.06302, 10.92599], [41.80056, 10.97127], [41.8096, 11.33606], [41.77727, 11.49902], [41.82878, 11.72361], [41.95461, 11.81157], [42.4037, 12.46478]]]] } },
22738     { type: "Feature", properties: { iso1A2: "EU", iso1A3: "EUE", wikidata: "Q458", nameEn: "European Union", level: "union", isoStatus: "excRes" }, geometry: null },
22739     { type: "Feature", properties: { iso1A2: "FI", iso1A3: "FIN", iso1N3: "246", wikidata: "Q33", nameEn: "Finland", aliases: ["SF"] }, geometry: null },
22740     { type: "Feature", properties: { iso1A2: "FJ", iso1A3: "FJI", iso1N3: "242", wikidata: "Q712", nameEn: "Fiji", groups: ["054", "009", "UN"], driveSide: "left", callingCodes: ["679"] }, geometry: { type: "MultiPolygon", coordinates: [[[[174.245, -23.1974], [179.99999, -22.5], [179.99999, -11.5], [174, -11.5], [174.245, -23.1974]]], [[[-176.76826, -14.95183], [-180, -14.96041], [-180, -22.90585], [-176.74538, -22.89767], [-176.76826, -14.95183]]]] } },
22741     { type: "Feature", properties: { iso1A2: "FK", iso1A3: "FLK", iso1N3: "238", wikidata: "Q9648", nameEn: "Falkland Islands", country: "GB", groups: ["BOTS", "005", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["500"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.67376, -55.11859], [-54.56126, -51.26248], [-61.26735, -50.63919], [-63.67376, -55.11859]]]] } },
22742     { type: "Feature", properties: { iso1A2: "FM", iso1A3: "FSM", iso1N3: "583", wikidata: "Q702", nameEn: "Federated States of Micronesia", groups: ["057", "009", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["691"] }, geometry: { type: "MultiPolygon", coordinates: [[[[138.20583, 13.3783], [136.27107, 6.73747], [156.88247, -1.39237], [165.19726, 6.22546], [138.20583, 13.3783]]]] } },
22743     { type: "Feature", properties: { iso1A2: "FO", iso1A3: "FRO", iso1N3: "234", wikidata: "Q4628", nameEn: "Faroe Islands", country: "DK", groups: ["154", "150", "UN"], callingCodes: ["298"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-8.51774, 62.35338], [-6.51083, 60.95272], [-5.70102, 62.77194], [-8.51774, 62.35338]]]] } },
22744     { type: "Feature", properties: { iso1A2: "FR", iso1A3: "FRA", iso1N3: "250", wikidata: "Q142", nameEn: "France" }, geometry: null },
22745     { type: "Feature", properties: { iso1A2: "FX", iso1A3: "FXX", iso1N3: "249", wikidata: "Q212429", nameEn: "Metropolitan France", country: "FR", groups: ["EU", "155", "150", "UN"], isoStatus: "excRes", callingCodes: ["33"] }, geometry: { type: "MultiPolygon", coordinates: [[[[2.55904, 51.07014], [2.18458, 51.52087], [1.17405, 50.74239], [-2.02963, 49.91866], [-2.09454, 49.46288], [-1.83944, 49.23037], [-2.00491, 48.86706], [-2.65349, 49.15373], [-6.28985, 48.93406], [-1.81005, 43.59738], [-1.77289, 43.38957], [-1.79319, 43.37497], [-1.78332, 43.36399], [-1.78714, 43.35476], [-1.77068, 43.34396], [-1.75334, 43.34107], [-1.75079, 43.3317], [-1.7397, 43.32979], [-1.73074, 43.29481], [-1.69407, 43.31378], [-1.62481, 43.30726], [-1.63052, 43.28591], [-1.61341, 43.25269], [-1.57674, 43.25269], [-1.55963, 43.28828], [-1.50992, 43.29481], [-1.45289, 43.27049], [-1.40942, 43.27272], [-1.3758, 43.24511], [-1.41562, 43.12815], [-1.47555, 43.08372], [-1.44067, 43.047], [-1.35272, 43.02658], [-1.34419, 43.09665], [-1.32209, 43.1127], [-1.27118, 43.11961], [-1.30052, 43.09581], [-1.30531, 43.06859], [-1.25244, 43.04164], [-1.22881, 43.05534], [-1.10333, 43.0059], [-1.00963, 42.99279], [-0.97133, 42.96239], [-0.81652, 42.95166], [-0.75478, 42.96916], [-0.72037, 42.92541], [-0.73422, 42.91228], [-0.72608, 42.89318], [-0.69837, 42.87945], [-0.67637, 42.88303], [-0.55497, 42.77846], [-0.50863, 42.82713], [-0.44334, 42.79939], [-0.41319, 42.80776], [-0.38833, 42.80132], [-0.3122, 42.84788], [-0.17939, 42.78974], [-0.16141, 42.79535], [-0.10519, 42.72761], [-0.02468, 42.68513], [0.17569, 42.73424], [0.25336, 42.7174], [0.29407, 42.67431], [0.36251, 42.72282], [0.40214, 42.69779], [0.67873, 42.69458], [0.65421, 42.75872], [0.66121, 42.84021], [0.711, 42.86372], [0.93089, 42.79154], [0.96166, 42.80629], [0.98292, 42.78754], [1.0804, 42.78569], [1.15928, 42.71407], [1.35562, 42.71944], [1.44197, 42.60217], [1.47986, 42.61346], [1.46718, 42.63296], [1.48043, 42.65203], [1.50867, 42.64483], [1.55418, 42.65669], [1.60085, 42.62703], [1.63485, 42.62957], [1.6625, 42.61982], [1.68267, 42.62533], [1.73452, 42.61515], [1.72588, 42.59098], [1.7858, 42.57698], [1.73683, 42.55492], [1.72515, 42.50338], [1.76335, 42.48863], [1.83037, 42.48395], [1.88853, 42.4501], [1.93663, 42.45439], [1.94292, 42.44316], [1.94061, 42.43333], [1.94084, 42.43039], [1.9574, 42.42401], [1.96482, 42.37787], [2.00488, 42.35399], [2.06241, 42.35906], [2.11621, 42.38393], [2.12789, 42.41291], [2.16599, 42.42314], [2.20578, 42.41633], [2.25551, 42.43757], [2.38504, 42.39977], [2.43299, 42.39423], [2.43508, 42.37568], [2.48457, 42.33933], [2.54382, 42.33406], [2.55516, 42.35351], [2.57934, 42.35808], [2.6747, 42.33974], [2.65311, 42.38771], [2.72056, 42.42298], [2.75497, 42.42578], [2.77464, 42.41046], [2.84335, 42.45724], [2.85675, 42.45444], [2.86983, 42.46843], [2.88413, 42.45938], [2.92107, 42.4573], [2.94283, 42.48174], [2.96518, 42.46692], [3.03734, 42.47363], [3.08167, 42.42748], [3.10027, 42.42621], [3.11379, 42.43646], [3.17156, 42.43545], [3.75438, 42.33445], [7.60802, 41.05927], [10.09675, 41.44089], [9.56115, 43.20816], [7.50102, 43.51859], [7.42422, 43.72209], [7.40903, 43.7296], [7.41113, 43.73156], [7.41291, 43.73168], [7.41298, 43.73311], [7.41233, 43.73439], [7.42062, 43.73977], [7.42299, 43.74176], [7.42443, 43.74087], [7.42809, 43.74396], [7.43013, 43.74895], [7.43624, 43.75014], [7.43708, 43.75197], [7.4389, 43.75151], [7.4379, 43.74963], [7.47823, 43.73341], [7.53006, 43.78405], [7.50423, 43.84345], [7.49355, 43.86551], [7.51162, 43.88301], [7.56075, 43.89932], [7.56858, 43.94506], [7.60771, 43.95772], [7.65266, 43.9763], [7.66848, 43.99943], [7.6597, 44.03009], [7.72508, 44.07578], [7.66878, 44.12795], [7.68694, 44.17487], [7.63245, 44.17877], [7.62155, 44.14881], [7.36364, 44.11882], [7.34547, 44.14359], [7.27827, 44.1462], [7.16929, 44.20352], [7.00764, 44.23736], [6.98221, 44.28289], [6.89171, 44.36637], [6.88784, 44.42043], [6.94504, 44.43112], [6.86233, 44.49834], [6.85507, 44.53072], [6.96042, 44.62129], [6.95133, 44.66264], [7.00582, 44.69364], [7.07484, 44.68073], [7.00401, 44.78782], [7.02217, 44.82519], [6.93499, 44.8664], [6.90774, 44.84322], [6.75518, 44.89915], [6.74519, 44.93661], [6.74791, 45.01939], [6.66981, 45.02324], [6.62803, 45.11175], [6.7697, 45.16044], [6.85144, 45.13226], [6.96706, 45.20841], [7.07074, 45.21228], [7.13115, 45.25386], [7.10572, 45.32924], [7.18019, 45.40071], [7.00037, 45.509], [6.98948, 45.63869], [6.80785, 45.71864], [6.80785, 45.83265], [6.95315, 45.85163], [7.04151, 45.92435], [7.00946, 45.9944], [6.93862, 46.06502], [6.87868, 46.03855], [6.89321, 46.12548], [6.78968, 46.14058], [6.86052, 46.28512], [6.77152, 46.34784], [6.8024, 46.39171], [6.82312, 46.42661], [6.53358, 46.45431], [6.25432, 46.3632], [6.21981, 46.31304], [6.24826, 46.30175], [6.25137, 46.29014], [6.23775, 46.27822], [6.24952, 46.26255], [6.26749, 46.24745], [6.29474, 46.26221], [6.31041, 46.24417], [6.29663, 46.22688], [6.27694, 46.21566], [6.26007, 46.21165], [6.24821, 46.20531], [6.23913, 46.20511], [6.23544, 46.20714], [6.22175, 46.20045], [6.22222, 46.19888], [6.21844, 46.19837], [6.21603, 46.19507], [6.21273, 46.19409], [6.21114, 46.1927], [6.20539, 46.19163], [6.19807, 46.18369], [6.19552, 46.18401], [6.18707, 46.17999], [6.18871, 46.16644], [6.18116, 46.16187], [6.15305, 46.15194], [6.13397, 46.1406], [6.09926, 46.14373], [6.09199, 46.15191], [6.07491, 46.14879], [6.05203, 46.15191], [6.04564, 46.14031], [6.03614, 46.13712], [6.01791, 46.14228], [5.9871, 46.14499], [5.97893, 46.13303], [5.95781, 46.12925], [5.9641, 46.14412], [5.97508, 46.15863], [5.98188, 46.17392], [5.98846, 46.17046], [5.99573, 46.18587], [5.96515, 46.19638], [5.97542, 46.21525], [6.02461, 46.23313], [6.03342, 46.2383], [6.04602, 46.23127], [6.05029, 46.23518], [6.0633, 46.24583], [6.07072, 46.24085], [6.08563, 46.24651], [6.10071, 46.23772], [6.12446, 46.25059], [6.11926, 46.2634], [6.1013, 46.28512], [6.11697, 46.29547], [6.1198, 46.31157], [6.13876, 46.33844], [6.15738, 46.3491], [6.16987, 46.36759], [6.15985, 46.37721], [6.15016, 46.3778], [6.09926, 46.40768], [6.06407, 46.41676], [6.08427, 46.44305], [6.07269, 46.46244], [6.1567, 46.54402], [6.11084, 46.57649], [6.27135, 46.68251], [6.38351, 46.73171], [6.45209, 46.77502], [6.43216, 46.80336], [6.46456, 46.88865], [6.43341, 46.92703], [6.71531, 47.0494], [6.68823, 47.06616], [6.76788, 47.1208], [6.8489, 47.15933], [6.9508, 47.24338], [6.95108, 47.26428], [6.94316, 47.28747], [7.05305, 47.33304], [7.0564, 47.35134], [7.03125, 47.36996], [6.87959, 47.35335], [6.88542, 47.37262], [6.93744, 47.40714], [6.93953, 47.43388], [7.0024, 47.45264], [6.98425, 47.49432], [7.0231, 47.50522], [7.07425, 47.48863], [7.12781, 47.50371], [7.16249, 47.49025], [7.19583, 47.49455], [7.17026, 47.44312], [7.24669, 47.4205], [7.33526, 47.44186], [7.35603, 47.43432], [7.40308, 47.43638], [7.43088, 47.45846], [7.4462, 47.46264], [7.4583, 47.47216], [7.42923, 47.48628], [7.43356, 47.49712], [7.47534, 47.47932], [7.51076, 47.49651], [7.49804, 47.51798], [7.5229, 47.51644], [7.53199, 47.5284], [7.51904, 47.53515], [7.50588, 47.52856], [7.49691, 47.53821], [7.50873, 47.54546], [7.51723, 47.54578], [7.52831, 47.55347], [7.53634, 47.55553], [7.55652, 47.56779], [7.55689, 47.57232], [7.56548, 47.57617], [7.56684, 47.57785], [7.58386, 47.57536], [7.58945, 47.59017], [7.59301, 47.60058], [7.58851, 47.60794], [7.57423, 47.61628], [7.5591, 47.63849], [7.53384, 47.65115], [7.52067, 47.66437], [7.51915, 47.68335], [7.51266, 47.70197], [7.53722, 47.71635], [7.54761, 47.72912], [7.52921, 47.77747], [7.55673, 47.87371], [7.62302, 47.97898], [7.56966, 48.03265], [7.57137, 48.12292], [7.6648, 48.22219], [7.69022, 48.30018], [7.74562, 48.32736], [7.73109, 48.39192], [7.76833, 48.48945], [7.80647, 48.51239], [7.80167, 48.54758], [7.80057, 48.5857], [7.84098, 48.64217], [7.89002, 48.66317], [7.96812, 48.72491], [7.96994, 48.75606], [8.01534, 48.76085], [8.0326, 48.79017], [8.06802, 48.78957], [8.10253, 48.81829], [8.12813, 48.87985], [8.19989, 48.95825], [8.20031, 48.95856], [8.22604, 48.97352], [8.14189, 48.97833], [7.97783, 49.03161], [7.93641, 49.05544], [7.86386, 49.03499], [7.79557, 49.06583], [7.75948, 49.04562], [7.63618, 49.05428], [7.62575, 49.07654], [7.56416, 49.08136], [7.53012, 49.09818], [7.49172, 49.13915], [7.49473, 49.17], [7.44455, 49.16765], [7.44052, 49.18354], [7.3662, 49.17308], [7.35995, 49.14399], [7.3195, 49.14231], [7.29514, 49.11426], [7.23473, 49.12971], [7.1593, 49.1204], [7.1358, 49.1282], [7.12504, 49.14253], [7.10384, 49.13787], [7.10715, 49.15631], [7.07859, 49.15031], [7.09007, 49.13094], [7.07162, 49.1255], [7.06642, 49.11415], [7.05548, 49.11185], [7.04843, 49.11422], [7.04409, 49.12123], [7.04662, 49.13724], [7.03178, 49.15734], [7.0274, 49.17042], [7.03459, 49.19096], [7.01318, 49.19018], [6.97273, 49.2099], [6.95963, 49.203], [6.94028, 49.21641], [6.93831, 49.2223], [6.91875, 49.22261], [6.89298, 49.20863], [6.85939, 49.22376], [6.83555, 49.21249], [6.85119, 49.20038], [6.85016, 49.19354], [6.86225, 49.18185], [6.84703, 49.15734], [6.83385, 49.15162], [6.78265, 49.16793], [6.73765, 49.16375], [6.71137, 49.18808], [6.73256, 49.20486], [6.71843, 49.2208], [6.69274, 49.21661], [6.66583, 49.28065], [6.60186, 49.31055], [6.572, 49.35027], [6.58807, 49.35358], [6.60091, 49.36864], [6.533, 49.40748], [6.55404, 49.42464], [6.42432, 49.47683], [6.40274, 49.46546], [6.39168, 49.4667], [6.38352, 49.46463], [6.36778, 49.46937], [6.3687, 49.4593], [6.28818, 49.48465], [6.27875, 49.503], [6.25029, 49.50609], [6.2409, 49.51408], [6.19543, 49.50536], [6.17386, 49.50934], [6.15366, 49.50226], [6.16115, 49.49297], [6.14321, 49.48796], [6.12814, 49.49365], [6.12346, 49.4735], [6.10325, 49.4707], [6.09845, 49.46351], [6.10072, 49.45268], [6.08373, 49.45594], [6.07887, 49.46399], [6.05553, 49.46663], [6.04176, 49.44801], [6.02743, 49.44845], [6.02648, 49.45451], [5.97693, 49.45513], [5.96876, 49.49053], [5.94224, 49.49608], [5.94128, 49.50034], [5.86571, 49.50015], [5.83389, 49.52152], [5.83467, 49.52717], [5.84466, 49.53027], [5.83648, 49.5425], [5.81664, 49.53775], [5.80871, 49.5425], [5.81838, 49.54777], [5.79195, 49.55228], [5.77435, 49.56298], [5.7577, 49.55915], [5.75649, 49.54321], [5.64505, 49.55146], [5.60909, 49.51228], [5.55001, 49.52729], [5.46541, 49.49825], [5.46734, 49.52648], [5.43713, 49.5707], [5.3974, 49.61596], [5.34837, 49.62889], [5.33851, 49.61599], [5.3137, 49.61225], [5.30214, 49.63055], [5.33039, 49.6555], [5.31465, 49.66846], [5.26232, 49.69456], [5.14545, 49.70287], [5.09249, 49.76193], [4.96714, 49.79872], [4.85464, 49.78995], [4.86965, 49.82271], [4.85134, 49.86457], [4.88529, 49.9236], [4.78827, 49.95609], [4.8382, 50.06738], [4.88602, 50.15182], [4.83279, 50.15331], [4.82438, 50.16878], [4.75237, 50.11314], [4.70064, 50.09384], [4.68695, 49.99685], [4.5414, 49.96911], [4.51098, 49.94659], [4.43488, 49.94122], [4.35051, 49.95315], [4.31963, 49.97043], [4.20532, 49.95803], [4.14239, 49.98034], [4.13508, 50.01976], [4.16294, 50.04719], [4.23101, 50.06945], [4.20147, 50.13535], [4.13561, 50.13078], [4.16014, 50.19239], [4.15524, 50.21103], [4.21945, 50.25539], [4.20651, 50.27333], [4.17861, 50.27443], [4.17347, 50.28838], [4.15524, 50.2833], [4.16808, 50.25786], [4.13665, 50.25609], [4.11954, 50.30425], [4.10957, 50.30234], [4.10237, 50.31247], [4.0689, 50.3254], [4.0268, 50.35793], [3.96771, 50.34989], [3.90781, 50.32814], [3.84314, 50.35219], [3.73911, 50.34809], [3.70987, 50.3191], [3.71009, 50.30305], [3.66976, 50.34563], [3.65709, 50.36873], [3.67262, 50.38663], [3.67494, 50.40239], [3.66153, 50.45165], [3.64426, 50.46275], [3.61014, 50.49568], [3.58361, 50.49049], [3.5683, 50.50192], [3.49509, 50.48885], [3.51564, 50.5256], [3.47385, 50.53397], [3.44629, 50.51009], [3.37693, 50.49538], [3.28575, 50.52724], [3.2729, 50.60718], [3.23951, 50.6585], [3.264, 50.67668], [3.2536, 50.68977], [3.26141, 50.69151], [3.26063, 50.70086], [3.24593, 50.71389], [3.22042, 50.71019], [3.20845, 50.71662], [3.19017, 50.72569], [3.20064, 50.73547], [3.18811, 50.74025], [3.18339, 50.74981], [3.16476, 50.76843], [3.15017, 50.79031], [3.1257, 50.78603], [3.11987, 50.79188], [3.11206, 50.79416], [3.10614, 50.78303], [3.09163, 50.77717], [3.04314, 50.77674], [3.00537, 50.76588], [2.96778, 50.75242], [2.95019, 50.75138], [2.90873, 50.702], [2.91036, 50.6939], [2.90069, 50.69263], [2.88504, 50.70656], [2.87937, 50.70298], [2.86985, 50.7033], [2.8483, 50.72276], [2.81056, 50.71773], [2.71165, 50.81295], [2.63331, 50.81457], [2.59093, 50.91751], [2.63074, 50.94746], [2.57551, 51.00326], [2.55904, 51.07014]], [[1.99838, 42.44682], [1.98378, 42.44697], [1.96125, 42.45364], [1.95606, 42.45785], [1.96215, 42.47854], [1.97003, 42.48081], [1.97227, 42.48487], [1.97697, 42.48568], [1.98022, 42.49569], [1.98916, 42.49351], [1.99766, 42.4858], [1.98579, 42.47486], [1.99216, 42.46208], [2.01564, 42.45171], [1.99838, 42.44682]]]] } },
22746     { type: "Feature", properties: { iso1A2: "GA", iso1A3: "GAB", iso1N3: "266", wikidata: "Q1000", nameEn: "Gabon", groups: ["017", "202", "002", "UN"], callingCodes: ["241"] }, geometry: { type: "MultiPolygon", coordinates: [[[[13.29457, 2.16106], [13.28534, 2.25716], [11.37116, 2.29975], [11.3561, 2.17217], [11.35307, 1.00251], [9.79648, 1.0019], [9.75065, 1.06753], [9.66433, 1.06723], [7.24416, -0.64092], [10.75913, -4.39519], [11.12647, -3.94169], [11.22301, -3.69888], [11.48764, -3.51089], [11.57949, -3.52798], [11.68608, -3.68942], [11.87083, -3.71571], [11.92719, -3.62768], [11.8318, -3.5812], [11.96554, -3.30267], [11.70227, -3.17465], [11.70558, -3.0773], [11.80365, -3.00424], [11.64798, -2.81146], [11.5359, -2.85654], [11.64487, -2.61865], [11.57637, -2.33379], [11.74605, -2.39936], [11.96866, -2.33559], [12.04895, -2.41704], [12.47925, -2.32626], [12.44656, -1.92025], [12.61312, -1.8129], [12.82172, -1.91091], [13.02759, -2.33098], [13.47977, -2.43224], [13.75884, -2.09293], [13.92073, -2.35581], [13.85846, -2.46935], [14.10442, -2.49268], [14.23829, -2.33715], [14.16202, -2.23916], [14.23518, -2.15671], [14.25932, -1.97624], [14.41838, -1.89412], [14.52569, -0.57818], [14.41887, -0.44799], [14.2165, -0.38261], [14.06862, -0.20826], [13.90632, -0.2287], [13.88648, 0.26652], [14.10909, 0.58563], [14.26066, 0.57255], [14.48179, 0.9152], [14.25186, 1.39842], [13.89582, 1.4261], [13.15519, 1.23368], [13.25447, 1.32339], [13.13461, 1.57238], [13.29457, 2.16106]]]] } },
22747     { type: "Feature", properties: { iso1A2: "GB", iso1A3: "GBR", iso1N3: "826", wikidata: "Q145", ccTLD: ".uk", nameEn: "United Kingdom", aliases: ["UK"] }, geometry: null },
22748     { type: "Feature", properties: { iso1A2: "GD", iso1A3: "GRD", iso1N3: "308", wikidata: "Q769", nameEn: "Grenada", aliases: ["WG"], groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 473"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.64026, 12.69984], [-61.77886, 11.36496], [-59.94058, 12.34011], [-62.64026, 12.69984]]]] } },
22749     { type: "Feature", properties: { iso1A2: "GE", iso1A3: "GEO", iso1N3: "268", wikidata: "Q230", nameEn: "Georgia", groups: ["145", "142", "UN"], callingCodes: ["995"] }, geometry: { type: "MultiPolygon", coordinates: [[[[46.42738, 41.91323], [45.61676, 42.20768], [45.78692, 42.48358], [45.36501, 42.55268], [45.15318, 42.70598], [44.88754, 42.74934], [44.80941, 42.61277], [44.70002, 42.74679], [44.54202, 42.75699], [43.95517, 42.55396], [43.73119, 42.62043], [43.81453, 42.74297], [43.0419, 43.02413], [43.03322, 43.08883], [42.75889, 43.19651], [42.66667, 43.13917], [42.40563, 43.23226], [41.64935, 43.22331], [40.65957, 43.56212], [40.10657, 43.57344], [40.04445, 43.47776], [40.03312, 43.44262], [40.01007, 43.42411], [40.01552, 43.42025], [40.00853, 43.40578], [40.0078, 43.38551], [39.81147, 43.06294], [40.89217, 41.72528], [41.54366, 41.52185], [41.7148, 41.4932], [41.7124, 41.47417], [41.81939, 41.43621], [41.95134, 41.52466], [42.26387, 41.49346], [42.51772, 41.43606], [42.59202, 41.58183], [42.72794, 41.59714], [42.84471, 41.58912], [42.78995, 41.50126], [42.84899, 41.47265], [42.8785, 41.50516], [43.02956, 41.37891], [43.21707, 41.30331], [43.13373, 41.25503], [43.1945, 41.25242], [43.23096, 41.17536], [43.36118, 41.2028], [43.44973, 41.17666], [43.4717, 41.12611], [43.67712, 41.13398], [43.74717, 41.1117], [43.84835, 41.16329], [44.16591, 41.19141], [44.18148, 41.24644], [44.32139, 41.2079], [44.34337, 41.20312], [44.34417, 41.2382], [44.46791, 41.18204], [44.59322, 41.1933], [44.61462, 41.24018], [44.72814, 41.20338], [44.82084, 41.21513], [44.87887, 41.20195], [44.89911, 41.21366], [44.84358, 41.23088], [44.81749, 41.23488], [44.80053, 41.25949], [44.81437, 41.30371], [44.93493, 41.25685], [45.0133, 41.29747], [45.09867, 41.34065], [45.1797, 41.42231], [45.26285, 41.46433], [45.31352, 41.47168], [45.4006, 41.42402], [45.45973, 41.45898], [45.68389, 41.3539], [45.71035, 41.36208], [45.75705, 41.35157], [45.69946, 41.29545], [45.80842, 41.2229], [45.95786, 41.17956], [46.13221, 41.19479], [46.27698, 41.19011], [46.37661, 41.10805], [46.456, 41.09984], [46.48558, 41.0576], [46.55096, 41.1104], [46.63969, 41.09515], [46.66148, 41.20533], [46.72375, 41.28609], [46.63658, 41.37727], [46.4669, 41.43331], [46.40307, 41.48464], [46.33925, 41.4963], [46.29794, 41.5724], [46.34126, 41.57454], [46.34039, 41.5947], [46.3253, 41.60912], [46.28182, 41.60089], [46.26531, 41.63339], [46.24429, 41.59883], [46.19759, 41.62327], [46.17891, 41.72094], [46.20538, 41.77205], [46.23962, 41.75811], [46.30863, 41.79133], [46.3984, 41.84399], [46.42738, 41.91323]]]] } },
22750     { type: "Feature", properties: { iso1A2: "GF", iso1A3: "GUF", iso1N3: "254", wikidata: "Q3769", nameEn: "French Guiana", country: "FR", groups: ["Q3320166", "EU", "005", "419", "019", "UN"], callingCodes: ["594"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-51.35485, 4.8383], [-53.7094, 6.2264], [-54.01074, 5.68785], [-54.01877, 5.52789], [-54.26916, 5.26909], [-54.4717, 4.91964], [-54.38444, 4.13222], [-54.19367, 3.84387], [-54.05128, 3.63557], [-53.98914, 3.627], [-53.9849, 3.58697], [-54.28534, 2.67798], [-54.42864, 2.42442], [-54.6084, 2.32856], [-54.16286, 2.10779], [-53.78743, 2.34412], [-52.96539, 2.1881], [-52.6906, 2.37298], [-52.31787, 3.17896], [-51.85573, 3.83427], [-51.82312, 3.85825], [-51.79599, 3.89336], [-51.61983, 4.14596], [-51.63798, 4.51394], [-51.35485, 4.8383]]]] } },
22751     { type: "Feature", properties: { iso1A2: "GG", iso1A3: "GGY", iso1N3: "831", wikidata: "Q25230", nameEn: "Bailiwick of Guernsey", country: "GB" }, geometry: null },
22752     { type: "Feature", properties: { iso1A2: "GH", iso1A3: "GHA", iso1N3: "288", wikidata: "Q117", nameEn: "Ghana", groups: ["011", "202", "002", "UN"], callingCodes: ["233"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-0.13493, 11.14075], [-0.27374, 11.17157], [-0.28566, 11.12713], [-0.35955, 11.07801], [-0.38219, 11.12596], [-0.42391, 11.11661], [-0.44298, 11.04292], [-0.61937, 10.91305], [-0.67143, 10.99811], [-2.83373, 11.0067], [-2.94232, 10.64281], [-2.83108, 10.40252], [-2.74174, 9.83172], [-2.76534, 9.56589], [-2.68802, 9.49343], [-2.69814, 9.22717], [-2.77799, 9.04949], [-2.66357, 9.01771], [-2.58243, 8.7789], [-2.49037, 8.20872], [-2.62901, 8.11495], [-2.61232, 8.02645], [-2.67787, 8.02055], [-2.74819, 7.92613], [-2.78395, 7.94974], [-2.79467, 7.86002], [-2.92339, 7.60847], [-2.97822, 7.27165], [-2.95438, 7.23737], [-3.23327, 6.81744], [-3.21954, 6.74407], [-3.25999, 6.62521], [-3.01896, 5.71697], [-2.95323, 5.71865], [-2.96671, 5.6415], [-2.93132, 5.62137], [-2.85378, 5.65156], [-2.76614, 5.60963], [-2.72737, 5.34789], [-2.77625, 5.34621], [-2.73074, 5.1364], [-2.75502, 5.10657], [-2.95261, 5.12477], [-2.96554, 5.10397], [-3.063, 5.13665], [-3.11073, 5.12675], [-3.10675, 5.08515], [-3.34019, 4.17519], [1.07031, 5.15655], [1.27574, 5.93551], [1.19771, 6.11522], [1.19966, 6.17069], [1.09187, 6.17074], [1.05969, 6.22998], [1.03108, 6.24064], [0.99652, 6.33779], [0.89283, 6.33779], [0.71048, 6.53083], [0.74862, 6.56517], [0.63659, 6.63857], [0.6497, 6.73682], [0.58176, 6.76049], [0.57406, 6.80348], [0.52853, 6.82921], [0.56508, 6.92971], [0.52098, 6.94391], [0.52217, 6.9723], [0.59606, 7.01252], [0.65327, 7.31643], [0.62943, 7.41099], [0.57223, 7.39326], [0.52455, 7.45354], [0.51979, 7.58706], [0.58295, 7.62368], [0.62943, 7.85751], [0.58891, 8.12779], [0.6056, 8.13959], [0.61156, 8.18324], [0.5913, 8.19622], [0.63897, 8.25873], [0.73432, 8.29529], [0.64731, 8.48866], [0.47211, 8.59945], [0.37319, 8.75262], [0.52455, 8.87746], [0.45424, 9.04581], [0.56388, 9.40697], [0.49118, 9.48339], [0.36485, 9.49749], [0.33148, 9.44812], [0.25758, 9.42696], [0.2254, 9.47869], [0.31241, 9.50337], [0.30406, 9.521], [0.2409, 9.52335], [0.23851, 9.57389], [0.38153, 9.58682], [0.36008, 9.6256], [0.29334, 9.59387], [0.26712, 9.66437], [0.28261, 9.69022], [0.32313, 9.6491], [0.34816, 9.66907], [0.34816, 9.71607], [0.32075, 9.72781], [0.36366, 10.03309], [0.41252, 10.02018], [0.41371, 10.06361], [0.35293, 10.09412], [0.39584, 10.31112], [0.33028, 10.30408], [0.29453, 10.41546], [0.18846, 10.4096], [0.12886, 10.53149], [-0.05945, 10.63458], [-0.09141, 10.7147], [-0.07327, 10.71845], [-0.07183, 10.76794], [-0.0228, 10.81916], [-0.02685, 10.8783], [-908e-5, 10.91644], [-63e-4, 10.96417], [0.03355, 10.9807], [0.02395, 11.06229], [342e-5, 11.08317], [-514e-5, 11.10763], [-0.0275, 11.11202], [-0.05733, 11.08628], [-0.14462, 11.10811], [-0.13493, 11.14075]]]] } },
22753     { type: "Feature", properties: { iso1A2: "GI", iso1A3: "GIB", iso1N3: "292", wikidata: "Q1410", nameEn: "Gibraltar", country: "GB", groups: ["Q12837", "BOTS", "039", "150", "UN"], callingCodes: ["350"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-5.34064, 36.03744], [-5.27801, 36.14942], [-5.33822, 36.15272], [-5.34536, 36.15501], [-5.40526, 36.15488], [-5.34064, 36.03744]]]] } },
22754     { type: "Feature", properties: { iso1A2: "GL", iso1A3: "GRL", iso1N3: "304", wikidata: "Q223", nameEn: "Greenland", country: "DK", groups: ["Q1451600", "021", "003", "019", "UN"], callingCodes: ["299"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-49.33696, 84.57952], [-68.21821, 80.48551], [-77.52957, 77.23408], [-46.37635, 57.3249], [-9.68082, 72.73731], [-5.7106, 84.28058], [-49.33696, 84.57952]]]] } },
22755     { type: "Feature", properties: { iso1A2: "GM", iso1A3: "GMB", iso1N3: "270", wikidata: "Q1005", nameEn: "The Gambia", groups: ["011", "202", "002", "UN"], callingCodes: ["220"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-15.14917, 13.57989], [-14.36795, 13.23033], [-13.79409, 13.34472], [-13.8955, 13.59126], [-14.34721, 13.46578], [-14.93719, 13.80173], [-15.36504, 13.79313], [-15.47902, 13.58758], [-17.43598, 13.59273], [-17.43966, 13.04579], [-16.74676, 13.06025], [-16.69343, 13.16791], [-15.80355, 13.16729], [-15.80478, 13.34832], [-15.26908, 13.37768], [-15.14917, 13.57989]]]] } },
22756     { type: "Feature", properties: { iso1A2: "GN", iso1A3: "GIN", iso1N3: "324", wikidata: "Q1006", nameEn: "Guinea", groups: ["011", "202", "002", "UN"], callingCodes: ["224"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-11.37536, 12.40788], [-11.46267, 12.44559], [-11.91331, 12.42008], [-12.35415, 12.32758], [-12.87336, 12.51892], [-13.06603, 12.49342], [-13.05296, 12.64003], [-13.70523, 12.68013], [-13.7039, 12.60313], [-13.65089, 12.49515], [-13.64168, 12.42764], [-13.70851, 12.24978], [-13.92745, 12.24077], [-13.94589, 12.16869], [-13.7039, 12.00869], [-13.7039, 11.70195], [-14.09799, 11.63649], [-14.26623, 11.67486], [-14.31513, 11.60713], [-14.51173, 11.49708], [-14.66677, 11.51188], [-14.77786, 11.36323], [-14.95993, 10.99244], [-15.07174, 10.89557], [-15.96748, 10.162], [-14.36218, 8.64107], [-13.29911, 9.04245], [-13.18586, 9.0925], [-13.08953, 9.0409], [-12.94095, 9.26335], [-12.76788, 9.3133], [-12.47254, 9.86834], [-12.24262, 9.92386], [-12.12634, 9.87203], [-11.91023, 9.93927], [-11.89624, 9.99763], [-11.2118, 10.00098], [-10.6534, 9.29919], [-10.74484, 9.07998], [-10.5783, 9.06386], [-10.56197, 8.81225], [-10.47707, 8.67669], [-10.61422, 8.5314], [-10.70565, 8.29235], [-10.63934, 8.35326], [-10.54891, 8.31174], [-10.37257, 8.48941], [-10.27575, 8.48711], [-10.203, 8.47991], [-10.14579, 8.52665], [-10.05375, 8.50697], [-10.05873, 8.42578], [-9.77763, 8.54633], [-9.47415, 8.35195], [-9.50898, 8.18455], [-9.41445, 8.02448], [-9.44928, 7.9284], [-9.35724, 7.74111], [-9.37465, 7.62032], [-9.48161, 7.37122], [-9.41943, 7.41809], [-9.305, 7.42056], [-9.20798, 7.38109], [-9.18311, 7.30461], [-9.09107, 7.1985], [-8.93435, 7.2824], [-8.85724, 7.26019], [-8.8448, 7.35149], [-8.72789, 7.51429], [-8.67814, 7.69428], [-8.55874, 7.70167], [-8.55874, 7.62525], [-8.47114, 7.55676], [-8.4003, 7.6285], [-8.21374, 7.54466], [-8.09931, 7.78626], [-8.13414, 7.87991], [-8.06449, 8.04989], [-7.94695, 8.00925], [-7.99919, 8.11023], [-7.98675, 8.20134], [-8.062, 8.16071], [-8.2411, 8.24196], [-8.22991, 8.48438], [-7.92518, 8.50652], [-7.65653, 8.36873], [-7.69882, 8.66148], [-7.95503, 8.81146], [-7.92518, 8.99332], [-7.73862, 9.08422], [-7.90777, 9.20456], [-7.85056, 9.41812], [-8.03463, 9.39604], [-8.14657, 9.55062], [-8.09434, 9.86936], [-8.15652, 9.94288], [-8.11921, 10.04577], [-8.01225, 10.1021], [-7.97971, 10.17117], [-7.9578, 10.2703], [-8.10207, 10.44649], [-8.22711, 10.41722], [-8.32614, 10.69273], [-8.2667, 10.91762], [-8.35083, 11.06234], [-8.66923, 10.99397], [-8.40058, 11.37466], [-8.80854, 11.66715], [-8.94784, 12.34842], [-9.13689, 12.50875], [-9.38067, 12.48446], [-9.32097, 12.29009], [-9.63938, 12.18312], [-9.714, 12.0226], [-10.30604, 12.24634], [-10.71897, 11.91552], [-10.80355, 12.1053], [-10.99758, 12.24634], [-11.24136, 12.01286], [-11.50006, 12.17826], [-11.37536, 12.40788]]]] } },
22757     { type: "Feature", properties: { iso1A2: "GP", iso1A3: "GLP", iso1N3: "312", wikidata: "Q17012", nameEn: "Guadeloupe", country: "FR", groups: ["Q3320166", "EU", "029", "003", "419", "019", "UN"], callingCodes: ["590"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-60.03183, 16.1129], [-61.60296, 16.73066], [-63.00549, 15.26166], [-60.03183, 16.1129]]]] } },
22758     { type: "Feature", properties: { iso1A2: "GQ", iso1A3: "GNQ", iso1N3: "226", wikidata: "Q983", nameEn: "Equatorial Guinea", groups: ["017", "202", "002", "UN"], callingCodes: ["240"] }, geometry: { type: "MultiPolygon", coordinates: [[[[9.22018, 3.72052], [8.34397, 4.30689], [7.71762, 0.6674], [3.35016, -3.29031], [9.66433, 1.06723], [9.75065, 1.06753], [9.79648, 1.0019], [11.35307, 1.00251], [11.3561, 2.17217], [9.991, 2.16561], [9.90749, 2.20049], [9.89012, 2.20457], [9.84716, 2.24676], [9.83238, 2.29079], [9.83754, 2.32428], [9.82123, 2.35097], [9.81162, 2.33797], [9.22018, 3.72052]]]] } },
22759     { type: "Feature", properties: { iso1A2: "GR", iso1A3: "GRC", iso1N3: "300", wikidata: "Q41", nameEn: "Greece", aliases: ["EL"], groups: ["EU", "039", "150", "UN"], callingCodes: ["30"] }, geometry: { type: "MultiPolygon", coordinates: [[[[26.03489, 40.73051], [26.0754, 40.72772], [26.08638, 40.73214], [26.12495, 40.74283], [26.12854, 40.77339], [26.15685, 40.80709], [26.21351, 40.83298], [26.20856, 40.86048], [26.26169, 40.9168], [26.29441, 40.89119], [26.28623, 40.93005], [26.32259, 40.94042], [26.35894, 40.94292], [26.33297, 40.98388], [26.3606, 41.02027], [26.31928, 41.07386], [26.32259, 41.24929], [26.39861, 41.25053], [26.5209, 41.33993], [26.5837, 41.32131], [26.62997, 41.34613], [26.61767, 41.42281], [26.59742, 41.48058], [26.59196, 41.60491], [26.5209, 41.62592], [26.47958, 41.67037], [26.35957, 41.71149], [26.30255, 41.70925], [26.2654, 41.71544], [26.22888, 41.74139], [26.21325, 41.73223], [26.16841, 41.74858], [26.06148, 41.70345], [26.07083, 41.64584], [26.15146, 41.60828], [26.14328, 41.55496], [26.17951, 41.55409], [26.176, 41.50072], [26.14796, 41.47533], [26.20288, 41.43943], [26.16548, 41.42278], [26.12926, 41.35878], [25.87919, 41.30526], [25.8266, 41.34563], [25.70507, 41.29209], [25.66183, 41.31316], [25.61042, 41.30614], [25.55082, 41.31667], [25.52394, 41.2798], [25.48187, 41.28506], [25.28322, 41.23411], [25.11611, 41.34212], [24.942, 41.38685], [24.90928, 41.40876], [24.86136, 41.39298], [24.82514, 41.4035], [24.8041, 41.34913], [24.71529, 41.41928], [24.61129, 41.42278], [24.52599, 41.56808], [24.30513, 41.51297], [24.27124, 41.57682], [24.18126, 41.51735], [24.10063, 41.54796], [24.06323, 41.53222], [24.06908, 41.46132], [23.96975, 41.44118], [23.91483, 41.47971], [23.89613, 41.45257], [23.80148, 41.43943], [23.76525, 41.40175], [23.67644, 41.41139], [23.63203, 41.37632], [23.52453, 41.40262], [23.40416, 41.39999], [23.33639, 41.36317], [23.31301, 41.40525], [23.22771, 41.37106], [23.21953, 41.33773], [23.1833, 41.31755], [22.93334, 41.34104], [22.81199, 41.3398], [22.76408, 41.32225], [22.74538, 41.16321], [22.71266, 41.13945], [22.65306, 41.18168], [22.62852, 41.14385], [22.58295, 41.11568], [22.5549, 41.13065], [22.42285, 41.11921], [22.26744, 41.16409], [22.17629, 41.15969], [22.1424, 41.12449], [22.06527, 41.15617], [21.90869, 41.09191], [21.91102, 41.04786], [21.7556, 40.92525], [21.69601, 40.9429], [21.57448, 40.86076], [21.53007, 40.90759], [21.41555, 40.9173], [21.35595, 40.87578], [21.25779, 40.86165], [21.21105, 40.8855], [21.15262, 40.85546], [20.97887, 40.85475], [20.98396, 40.79109], [20.95752, 40.76982], [20.98134, 40.76046], [21.05833, 40.66586], [21.03932, 40.56299], [20.96908, 40.51526], [20.94925, 40.46625], [20.83688, 40.47882], [20.7906, 40.42726], [20.78234, 40.35803], [20.71789, 40.27739], [20.67162, 40.09433], [20.62566, 40.0897], [20.61081, 40.07866], [20.55593, 40.06524], [20.51297, 40.08168], [20.48487, 40.06271], [20.42373, 40.06777], [20.37911, 39.99058], [20.31135, 39.99438], [20.41546, 39.82832], [20.41475, 39.81437], [20.38572, 39.78516], [20.30804, 39.81563], [20.29152, 39.80421], [20.31961, 39.72799], [20.27412, 39.69884], [20.22707, 39.67459], [20.22376, 39.64532], [20.15988, 39.652], [20.12956, 39.65805], [20.05189, 39.69112], [20.00957, 39.69227], [19.98042, 39.6504], [19.92466, 39.69533], [19.97622, 39.78684], [19.95905, 39.82857], [19.0384, 40.35325], [19.20409, 39.7532], [22.5213, 33.45682], [29.73302, 35.92555], [29.69611, 36.10365], [29.61805, 36.14179], [29.61002, 36.1731], [29.48192, 36.18377], [29.30783, 36.01033], [28.23708, 36.56812], [27.95037, 36.46155], [27.89482, 36.69898], [27.46117, 36.53789], [27.24613, 36.71622], [27.45627, 36.9008], [27.20312, 36.94571], [27.14757, 37.32], [26.95583, 37.64989], [26.99377, 37.69034], [27.16428, 37.72343], [27.05537, 37.9131], [26.21136, 38.17558], [26.24183, 38.44695], [26.32173, 38.48731], [26.21136, 38.65436], [26.61814, 38.81372], [26.70773, 39.0312], [26.43357, 39.43096], [25.94257, 39.39358], [25.61285, 40.17161], [26.04292, 40.3958], [25.94795, 40.72797], [26.03489, 40.73051]]]] } },
22760     { type: "Feature", properties: { iso1A2: "GS", iso1A3: "SGS", iso1N3: "239", wikidata: "Q35086", nameEn: "South Georgia and South Sandwich Islands", country: "GB", groups: ["BOTS", "005", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["500"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-35.26394, -43.68272], [-53.39656, -59.87088], [-22.31757, -59.85974], [-35.26394, -43.68272]]]] } },
22761     { type: "Feature", properties: { iso1A2: "GT", iso1A3: "GTM", iso1N3: "320", wikidata: "Q774", nameEn: "Guatemala", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["502"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-89.14985, 17.81563], [-90.98678, 17.81655], [-90.99199, 17.25192], [-91.43809, 17.25373], [-91.04436, 16.92175], [-90.69064, 16.70697], [-90.61212, 16.49832], [-90.40499, 16.40524], [-90.44567, 16.07573], [-91.73182, 16.07371], [-92.20983, 15.26077], [-92.0621, 15.07406], [-92.1454, 14.98143], [-92.1423, 14.88647], [-92.18161, 14.84147], [-92.1454, 14.6804], [-92.2261, 14.53423], [-92.37213, 14.39277], [-90.55276, 12.8866], [-90.11344, 13.73679], [-90.10505, 13.85104], [-89.88937, 14.0396], [-89.81807, 14.07073], [-89.76103, 14.02923], [-89.73251, 14.04133], [-89.75569, 14.07073], [-89.70756, 14.1537], [-89.61844, 14.21937], [-89.52397, 14.22628], [-89.50614, 14.26084], [-89.58814, 14.33165], [-89.57441, 14.41637], [-89.39028, 14.44561], [-89.34776, 14.43013], [-89.35189, 14.47553], [-89.23719, 14.58046], [-89.15653, 14.57802], [-89.13132, 14.71582], [-89.23467, 14.85596], [-89.15149, 14.97775], [-89.18048, 14.99967], [-89.15149, 15.07392], [-88.97343, 15.14039], [-88.32467, 15.63665], [-88.31459, 15.66942], [-88.24022, 15.69247], [-88.22552, 15.72294], [-88.20359, 16.03858], [-88.40779, 16.09624], [-88.95358, 15.88698], [-89.02415, 15.9063], [-89.17418, 15.90898], [-89.22683, 15.88619], [-89.15025, 17.04813], [-89.14985, 17.81563]]]] } },
22762     { type: "Feature", properties: { iso1A2: "GU", iso1A3: "GUM", iso1N3: "316", wikidata: "Q16635", nameEn: "Guam", aliases: ["US-GU"], country: "US", groups: ["Q1352230", "Q153732", "057", "009", "UN"], roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 671"] }, geometry: { type: "MultiPolygon", coordinates: [[[[146.25931, 13.85876], [143.82485, 13.92273], [144.61642, 12.82462], [146.25931, 13.85876]]]] } },
22763     { type: "Feature", properties: { iso1A2: "GW", iso1A3: "GNB", iso1N3: "624", wikidata: "Q1007", nameEn: "Guinea-Bissau", groups: ["011", "202", "002", "UN"], callingCodes: ["245"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-14.31513, 11.60713], [-14.26623, 11.67486], [-14.09799, 11.63649], [-13.7039, 11.70195], [-13.7039, 12.00869], [-13.94589, 12.16869], [-13.92745, 12.24077], [-13.70851, 12.24978], [-13.64168, 12.42764], [-13.65089, 12.49515], [-13.7039, 12.60313], [-13.70523, 12.68013], [-15.17582, 12.6847], [-15.67302, 12.42974], [-16.20591, 12.46157], [-16.38191, 12.36449], [-16.70562, 12.34803], [-17.4623, 11.92379], [-15.96748, 10.162], [-15.07174, 10.89557], [-14.95993, 10.99244], [-14.77786, 11.36323], [-14.66677, 11.51188], [-14.51173, 11.49708], [-14.31513, 11.60713]]]] } },
22764     { type: "Feature", properties: { iso1A2: "GY", iso1A3: "GUY", iso1N3: "328", wikidata: "Q734", nameEn: "Guyana", groups: ["005", "419", "019", "UN"], driveSide: "left", callingCodes: ["592"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-56.84822, 6.73257], [-59.54058, 8.6862], [-59.98508, 8.53046], [-59.85562, 8.35213], [-59.80661, 8.28906], [-59.83156, 8.23261], [-59.97059, 8.20791], [-60.02407, 8.04557], [-60.38056, 7.8302], [-60.51959, 7.83373], [-60.64793, 7.56877], [-60.71923, 7.55817], [-60.59802, 7.33194], [-60.63367, 7.25061], [-60.54098, 7.14804], [-60.44116, 7.20817], [-60.28074, 7.1162], [-60.39419, 6.94847], [-60.54873, 6.8631], [-61.13632, 6.70922], [-61.20762, 6.58174], [-61.15058, 6.19558], [-61.4041, 5.95304], [-60.73204, 5.20931], [-60.32352, 5.21299], [-60.20944, 5.28754], [-59.98129, 5.07097], [-60.04189, 4.69801], [-60.15953, 4.53456], [-59.78878, 4.45637], [-59.69361, 4.34069], [-59.73353, 4.20399], [-59.51963, 3.91951], [-59.86899, 3.57089], [-59.79769, 3.37162], [-59.99733, 2.92312], [-59.91177, 2.36759], [-59.7264, 2.27497], [-59.74066, 1.87596], [-59.25583, 1.40559], [-58.92072, 1.31293], [-58.84229, 1.17749], [-58.53571, 1.29154], [-58.4858, 1.48399], [-58.33887, 1.58014], [-58.01873, 1.51966], [-57.97336, 1.64566], [-57.77281, 1.73344], [-57.55743, 1.69605], [-57.35073, 1.98327], [-57.23981, 1.95808], [-57.09109, 2.01854], [-57.07092, 1.95304], [-56.7659, 1.89509], [-56.47045, 1.95135], [-56.55439, 2.02003], [-56.70519, 2.02964], [-57.35891, 3.32121], [-58.0307, 3.95513], [-57.8699, 4.89394], [-57.37442, 5.0208], [-57.22536, 5.15605], [-57.31629, 5.33714], [-56.84822, 6.73257]]]] } },
22765     { type: "Feature", properties: { iso1A2: "HK", iso1A3: "HKG", iso1N3: "344", wikidata: "Q8646", nameEn: "Hong Kong", country: "CN", groups: ["030", "142", "UN"], driveSide: "left", callingCodes: ["852"] }, geometry: { type: "MultiPolygon", coordinates: [[[[113.92195, 22.13873], [114.50148, 22.15017], [114.44998, 22.55977], [114.25154, 22.55977], [114.22888, 22.5436], [114.22185, 22.55343], [114.20655, 22.55706], [114.18338, 22.55444], [114.17247, 22.55944], [114.1597, 22.56041], [114.15123, 22.55163], [114.1482, 22.54091], [114.13823, 22.54319], [114.12665, 22.54003], [114.11656, 22.53415], [114.11181, 22.52878], [114.1034, 22.5352], [114.09692, 22.53435], [114.09048, 22.53716], [114.08606, 22.53276], [114.07817, 22.52997], [114.07267, 22.51855], [114.06272, 22.51617], [114.05729, 22.51104], [114.05438, 22.5026], [114.03113, 22.5065], [113.86771, 22.42972], [113.81621, 22.2163], [113.83338, 22.1826], [113.92195, 22.13873]]]] } },
22766     { type: "Feature", properties: { iso1A2: "HM", iso1A3: "HMD", iso1N3: "334", wikidata: "Q131198", nameEn: "Heard Island and McDonald Islands", country: "AU", groups: ["053", "009", "UN"], driveSide: "left" }, geometry: { type: "MultiPolygon", coordinates: [[[[71.08716, -53.87687], [75.44182, -53.99822], [72.87012, -51.48322], [71.08716, -53.87687]]]] } },
22767     { type: "Feature", properties: { iso1A2: "HN", iso1A3: "HND", iso1N3: "340", wikidata: "Q783", nameEn: "Honduras", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["504"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-83.86109, 17.73736], [-88.20359, 16.03858], [-88.22552, 15.72294], [-88.24022, 15.69247], [-88.31459, 15.66942], [-88.32467, 15.63665], [-88.97343, 15.14039], [-89.15149, 15.07392], [-89.18048, 14.99967], [-89.15149, 14.97775], [-89.23467, 14.85596], [-89.13132, 14.71582], [-89.15653, 14.57802], [-89.23719, 14.58046], [-89.35189, 14.47553], [-89.34776, 14.43013], [-89.04187, 14.33644], [-88.94608, 14.20207], [-88.85785, 14.17763], [-88.815, 14.11652], [-88.73182, 14.10919], [-88.70661, 14.04317], [-88.49738, 13.97224], [-88.48982, 13.86458], [-88.25791, 13.91108], [-88.23018, 13.99915], [-88.07641, 13.98447], [-88.00331, 13.86948], [-87.7966, 13.91353], [-87.68821, 13.80829], [-87.73106, 13.75443], [-87.78148, 13.52906], [-87.71657, 13.50577], [-87.72115, 13.46083], [-87.73841, 13.44169], [-87.77354, 13.45767], [-87.83467, 13.44655], [-87.84675, 13.41078], [-87.80177, 13.35689], [-87.73714, 13.32715], [-87.69751, 13.25228], [-87.55124, 13.12523], [-87.37107, 12.98646], [-87.06306, 13.00892], [-87.03785, 12.98682], [-86.93197, 13.05313], [-86.93383, 13.18677], [-86.87066, 13.30641], [-86.71267, 13.30348], [-86.76812, 13.79605], [-86.35219, 13.77157], [-86.14801, 14.04317], [-86.00685, 14.08474], [-86.03458, 13.99181], [-85.75477, 13.8499], [-85.73964, 13.9698], [-85.45762, 14.11304], [-85.32149, 14.2562], [-85.18602, 14.24929], [-85.1575, 14.53934], [-84.90082, 14.80489], [-84.82596, 14.82212], [-84.70119, 14.68078], [-84.48373, 14.63249], [-84.10584, 14.76353], [-83.89551, 14.76697], [-83.62101, 14.89448], [-83.49268, 15.01158], [-83.13724, 15.00002], [-83.04763, 15.03256], [-82.06974, 14.49418], [-81.58685, 18.0025], [-83.86109, 17.73736]]]] } },
22768     { type: "Feature", properties: { iso1A2: "HR", iso1A3: "HRV", iso1N3: "191", wikidata: "Q224", nameEn: "Croatia", groups: ["EU", "039", "150", "UN"], callingCodes: ["385"] }, geometry: { type: "MultiPolygon", coordinates: [[[[17.6444, 42.88641], [17.5392, 42.92787], [17.70879, 42.97223], [17.64268, 43.08595], [17.46986, 43.16559], [17.286, 43.33065], [17.25579, 43.40353], [17.29699, 43.44542], [17.24411, 43.49376], [17.15828, 43.49376], [17.00585, 43.58037], [16.80736, 43.76011], [16.75316, 43.77157], [16.70922, 43.84887], [16.55472, 43.95326], [16.50528, 44.0244], [16.43629, 44.02826], [16.43662, 44.07523], [16.36864, 44.08263], [16.18688, 44.27012], [16.21346, 44.35231], [16.12969, 44.38275], [16.16814, 44.40679], [16.10566, 44.52586], [16.03012, 44.55572], [16.00884, 44.58605], [16.05828, 44.61538], [15.89348, 44.74964], [15.8255, 44.71501], [15.72584, 44.82334], [15.79472, 44.8455], [15.76096, 44.87045], [15.74723, 44.96818], [15.78568, 44.97401], [15.74585, 45.0638], [15.78842, 45.11519], [15.76371, 45.16508], [15.83512, 45.22459], [15.98412, 45.23088], [16.12153, 45.09616], [16.29036, 44.99732], [16.35404, 45.00241], [16.35863, 45.03529], [16.3749, 45.05206], [16.38219, 45.05139], [16.38309, 45.05955], [16.40023, 45.1147], [16.4634, 45.14522], [16.49155, 45.21153], [16.52982, 45.22713], [16.5501, 45.2212], [16.56559, 45.22307], [16.60194, 45.23042], [16.64962, 45.20714], [16.74845, 45.20393], [16.78219, 45.19002], [16.81137, 45.18434], [16.83804, 45.18951], [16.92405, 45.27607], [16.9385, 45.22742], [17.0415, 45.20759], [17.18438, 45.14764], [17.24325, 45.146], [17.25131, 45.14957], [17.26815, 45.18444], [17.32092, 45.16246], [17.33573, 45.14521], [17.41229, 45.13335], [17.4498, 45.16119], [17.45615, 45.12523], [17.47589, 45.12656], [17.51469, 45.10791], [17.59104, 45.10816], [17.66571, 45.13408], [17.84826, 45.04489], [17.87148, 45.04645], [17.93706, 45.08016], [17.97336, 45.12245], [17.97834, 45.13831], [17.99479, 45.14958], [18.01594, 45.15163], [18.03121, 45.12632], [18.1624, 45.07654], [18.24387, 45.13699], [18.32077, 45.1021], [18.41896, 45.11083], [18.47939, 45.05871], [18.65723, 45.07544], [18.78357, 44.97741], [18.80661, 44.93561], [18.76369, 44.93707], [18.76347, 44.90669], [18.8704, 44.85097], [19.01994, 44.85493], [18.98957, 44.90645], [19.02871, 44.92541], [19.06853, 44.89915], [19.15573, 44.95409], [19.05205, 44.97692], [19.1011, 45.01191], [19.07952, 45.14668], [19.14063, 45.12972], [19.19144, 45.17863], [19.43589, 45.17137], [19.41941, 45.23475], [19.28208, 45.23813], [19.10774, 45.29547], [18.97446, 45.37528], [18.99918, 45.49333], [19.08364, 45.48804], [19.07471, 45.53086], [18.94562, 45.53712], [18.88776, 45.57253], [18.96691, 45.66731], [18.90305, 45.71863], [18.85783, 45.85493], [18.81394, 45.91329], [18.80211, 45.87995], [18.6792, 45.92057], [18.57483, 45.80772], [18.44368, 45.73972], [18.12439, 45.78905], [18.08869, 45.76511], [17.99805, 45.79671], [17.87377, 45.78522], [17.66545, 45.84207], [17.56821, 45.93728], [17.35672, 45.95209], [17.14592, 46.16697], [16.8903, 46.28122], [16.8541, 46.36255], [16.7154, 46.39523], [16.6639, 46.45203], [16.59527, 46.47524], [16.52604, 46.47831], [16.5007, 46.49644], [16.44036, 46.5171], [16.38771, 46.53608], [16.37193, 46.55008], [16.29793, 46.5121], [16.26733, 46.51505], [16.26759, 46.50566], [16.23961, 46.49653], [16.25124, 46.48067], [16.27398, 46.42875], [16.27329, 46.41467], [16.30162, 46.40437], [16.30233, 46.37837], [16.18824, 46.38282], [16.14859, 46.40547], [16.05281, 46.39141], [16.05065, 46.3833], [16.07314, 46.36458], [16.07616, 46.3463], [15.97965, 46.30652], [15.79284, 46.25811], [15.78817, 46.21719], [15.75479, 46.20336], [15.75436, 46.21969], [15.67395, 46.22478], [15.6434, 46.21396], [15.64904, 46.19229], [15.59909, 46.14761], [15.6083, 46.11992], [15.62317, 46.09103], [15.72977, 46.04682], [15.71246, 46.01196], [15.70327, 46.00015], [15.70636, 45.92116], [15.67967, 45.90455], [15.68383, 45.88867], [15.68232, 45.86819], [15.70411, 45.8465], [15.66662, 45.84085], [15.64185, 45.82915], [15.57952, 45.84953], [15.52234, 45.82195], [15.47325, 45.8253], [15.47531, 45.79802], [15.40836, 45.79491], [15.25423, 45.72275], [15.30872, 45.69014], [15.34919, 45.71623], [15.4057, 45.64727], [15.38952, 45.63682], [15.34214, 45.64702], [15.34695, 45.63382], [15.31027, 45.6303], [15.27747, 45.60504], [15.29837, 45.5841], [15.30249, 45.53224], [15.38188, 45.48752], [15.33051, 45.45258], [15.27758, 45.46678], [15.16862, 45.42309], [15.05187, 45.49079], [15.02385, 45.48533], [14.92266, 45.52788], [14.90554, 45.47769], [14.81992, 45.45913], [14.80124, 45.49515], [14.71718, 45.53442], [14.68605, 45.53006], [14.69694, 45.57366], [14.59576, 45.62812], [14.60977, 45.66403], [14.57397, 45.67165], [14.53816, 45.6205], [14.5008, 45.60852], [14.49769, 45.54424], [14.36693, 45.48642], [14.32487, 45.47142], [14.27681, 45.4902], [14.26611, 45.48239], [14.24239, 45.50607], [14.22371, 45.50388], [14.20348, 45.46896], [14.07116, 45.48752], [14.00578, 45.52352], [13.96063, 45.50825], [13.99488, 45.47551], [13.97309, 45.45258], [13.90771, 45.45149], [13.88124, 45.42637], [13.81742, 45.43729], [13.7785, 45.46787], [13.67398, 45.4436], [13.62902, 45.45898], [13.56979, 45.4895], [13.45644, 45.59464], [13.05142, 45.33128], [13.12821, 44.48877], [16.15283, 42.18525], [18.45131, 42.21682], [18.54128, 42.39171], [18.52152, 42.42302], [18.43588, 42.48556], [18.44307, 42.51077], [18.43735, 42.55921], [18.36197, 42.61423], [18.24318, 42.6112], [17.88201, 42.83668], [17.80854, 42.9182], [17.7948, 42.89556], [17.68151, 42.92725], [17.6444, 42.88641]]]] } },
22769     { type: "Feature", properties: { iso1A2: "HT", iso1A3: "HTI", iso1N3: "332", wikidata: "Q790", nameEn: "Haiti", aliases: ["RH"], groups: ["029", "003", "419", "019", "UN"], callingCodes: ["509"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-71.71885, 18.78423], [-71.72624, 18.87802], [-71.77766, 18.95007], [-71.88102, 18.95007], [-71.74088, 19.0437], [-71.71088, 19.08353], [-71.69938, 19.10916], [-71.65337, 19.11759], [-71.62642, 19.21212], [-71.73229, 19.26686], [-71.77766, 19.33823], [-71.69448, 19.37866], [-71.6802, 19.45008], [-71.71268, 19.53374], [-71.71449, 19.55364], [-71.7429, 19.58445], [-71.75865, 19.70231], [-71.77419, 19.73128], [-72.38946, 20.27111], [-73.37289, 20.43199], [-74.7289, 18.71009], [-74.76465, 18.06252], [-72.29523, 17.48026], [-71.75671, 18.03456], [-71.73783, 18.07177], [-71.74994, 18.11115], [-71.75465, 18.14405], [-71.78271, 18.18302], [-71.69952, 18.34101], [-71.90875, 18.45821], [-71.88102, 18.50125], [-72.00201, 18.62312], [-71.95412, 18.64939], [-71.82556, 18.62551], [-71.71885, 18.78423]]]] } },
22770     { type: "Feature", properties: { iso1A2: "HU", iso1A3: "HUN", iso1N3: "348", wikidata: "Q28", nameEn: "Hungary", groups: ["EU", "151", "150", "UN"], callingCodes: ["36"] }, geometry: { type: "MultiPolygon", coordinates: [[[[21.72525, 48.34628], [21.67134, 48.3989], [21.6068, 48.50365], [21.44063, 48.58456], [21.11516, 48.49546], [20.83248, 48.5824], [20.5215, 48.53336], [20.29943, 48.26104], [20.24312, 48.2784], [19.92452, 48.1283], [19.63338, 48.25006], [19.52489, 48.19791], [19.47957, 48.09437], [19.28182, 48.08336], [19.23924, 48.0595], [19.01952, 48.07052], [18.82176, 48.04206], [18.76134, 47.97499], [18.76821, 47.87469], [18.8506, 47.82308], [18.74074, 47.8157], [18.66521, 47.76772], [18.56496, 47.76588], [18.29305, 47.73541], [18.02938, 47.75665], [17.71215, 47.7548], [17.23699, 48.02094], [17.16001, 48.00636], [17.09786, 47.97336], [17.11022, 47.92461], [17.08275, 47.87719], [17.00997, 47.86245], [17.07039, 47.81129], [17.05048, 47.79377], [17.08893, 47.70928], [16.87538, 47.68895], [16.86509, 47.72268], [16.82938, 47.68432], [16.7511, 47.67878], [16.72089, 47.73469], [16.65679, 47.74197], [16.61183, 47.76171], [16.54779, 47.75074], [16.53514, 47.73837], [16.55129, 47.72268], [16.4222, 47.66537], [16.58699, 47.61772], [16.64193, 47.63114], [16.71059, 47.52692], [16.64821, 47.50155], [16.6718, 47.46139], [16.57152, 47.40868], [16.52414, 47.41007], [16.49908, 47.39416], [16.45104, 47.41181], [16.47782, 47.25918], [16.44142, 47.25079], [16.43663, 47.21127], [16.41739, 47.20649], [16.42801, 47.18422], [16.4523, 47.18812], [16.46442, 47.16845], [16.44932, 47.14418], [16.52863, 47.13974], [16.46134, 47.09395], [16.52176, 47.05747], [16.43936, 47.03548], [16.51369, 47.00084], [16.28202, 47.00159], [16.27594, 46.9643], [16.22403, 46.939], [16.19904, 46.94134], [16.10983, 46.867], [16.14365, 46.8547], [16.15711, 46.85434], [16.21892, 46.86961], [16.2365, 46.87775], [16.2941, 46.87137], [16.34547, 46.83836], [16.3408, 46.80641], [16.31303, 46.79838], [16.30966, 46.7787], [16.37816, 46.69975], [16.42641, 46.69228], [16.41863, 46.66238], [16.38594, 46.6549], [16.39217, 46.63673], [16.50139, 46.56684], [16.52885, 46.53303], [16.52604, 46.5051], [16.59527, 46.47524], [16.6639, 46.45203], [16.7154, 46.39523], [16.8541, 46.36255], [16.8903, 46.28122], [17.14592, 46.16697], [17.35672, 45.95209], [17.56821, 45.93728], [17.66545, 45.84207], [17.87377, 45.78522], [17.99805, 45.79671], [18.08869, 45.76511], [18.12439, 45.78905], [18.44368, 45.73972], [18.57483, 45.80772], [18.6792, 45.92057], [18.80211, 45.87995], [18.81394, 45.91329], [18.99712, 45.93537], [19.01284, 45.96529], [19.0791, 45.96458], [19.10388, 46.04015], [19.14543, 45.9998], [19.28826, 45.99694], [19.52473, 46.1171], [19.56113, 46.16824], [19.66007, 46.19005], [19.81491, 46.1313], [19.93508, 46.17553], [20.01816, 46.17696], [20.03533, 46.14509], [20.09713, 46.17315], [20.26068, 46.12332], [20.28324, 46.1438], [20.35573, 46.16629], [20.45377, 46.14405], [20.49718, 46.18721], [20.63863, 46.12728], [20.76085, 46.21002], [20.74574, 46.25467], [20.86797, 46.28884], [21.06572, 46.24897], [21.16872, 46.30118], [21.28061, 46.44941], [21.26929, 46.4993], [21.33214, 46.63035], [21.43926, 46.65109], [21.5151, 46.72147], [21.48935, 46.7577], [21.52028, 46.84118], [21.59307, 46.86935], [21.59581, 46.91628], [21.68645, 46.99595], [21.648, 47.03902], [21.78395, 47.11104], [21.94463, 47.38046], [22.01055, 47.37767], [22.03389, 47.42508], [22.00917, 47.50492], [22.31816, 47.76126], [22.41979, 47.7391], [22.46559, 47.76583], [22.67247, 47.7871], [22.76617, 47.8417], [22.77991, 47.87211], [22.89849, 47.95851], [22.84276, 47.98602], [22.87847, 48.04665], [22.81804, 48.11363], [22.73427, 48.12005], [22.66835, 48.09162], [22.58733, 48.10813], [22.59007, 48.15121], [22.49806, 48.25189], [22.38133, 48.23726], [22.2083, 48.42534], [22.14689, 48.4005], [21.83339, 48.36242], [21.8279, 48.33321], [21.72525, 48.34628]]]] } },
22771     { type: "Feature", properties: { iso1A2: "IC", wikidata: "Q5813", nameEn: "Canary Islands", country: "ES", groups: ["Q3320166", "Q105472", "EU", "039", "150", "UN"], isoStatus: "excRes", callingCodes: ["34"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-12.00985, 30.24121], [-25.3475, 27.87574], [-14.43883, 27.02969], [-12.00985, 30.24121]]]] } },
22772     { type: "Feature", properties: { iso1A2: "ID", iso1A3: "IDN", iso1N3: "360", wikidata: "Q252", nameEn: "Indonesia", aliases: ["RI"] }, geometry: null },
22773     { type: "Feature", geometry: { type: "MultiPolygon", coordinates: [[[[-6.26218, 54.09785], [-6.29003, 54.11278], [-6.32694, 54.09337], [-6.36279, 54.11248], [-6.36605, 54.07234], [-6.47849, 54.06947], [-6.62842, 54.03503], [-6.66264, 54.0666], [-6.6382, 54.17071], [-6.70175, 54.20218], [-6.74575, 54.18788], [-6.81583, 54.22791], [-6.85179, 54.29176], [-6.87775, 54.34682], [-7.02034, 54.4212], [-7.19145, 54.31296], [-7.14908, 54.22732], [-7.25012, 54.20063], [-7.26316, 54.13863], [-7.29493, 54.12013], [-7.29687, 54.1354], [-7.28017, 54.16714], [-7.29157, 54.17191], [-7.34005, 54.14698], [-7.30553, 54.11869], [-7.32834, 54.11475], [-7.44567, 54.1539], [-7.4799, 54.12239], [-7.55812, 54.12239], [-7.69501, 54.20731], [-7.81397, 54.20159], [-7.8596, 54.21779], [-7.87101, 54.29299], [-8.04555, 54.36292], [-8.179, 54.46763], [-8.04538, 54.48941], [-7.99812, 54.54427], [-7.8596, 54.53671], [-7.70315, 54.62077], [-7.93293, 54.66603], [-7.83352, 54.73854], [-7.75041, 54.7103], [-7.64449, 54.75265], [-7.54671, 54.74606], [-7.54508, 54.79401], [-7.47626, 54.83084], [-7.4473, 54.87003], [-7.44404, 54.9403], [-7.40004, 54.94498], [-7.4033, 55.00391], [-7.34464, 55.04688], [-7.2471, 55.06933], [-6.34755, 55.49206], [-7.75229, 55.93854], [-11.75, 54], [-11, 51], [-6.03913, 51.13217], [-5.37267, 53.63269], [-6.26218, 54.09785]]]] }, properties: { iso1A2: "IE", iso1A3: "IRL", iso1N3: "372", wikidata: "Q27", nameEn: "Republic of Ireland", groups: ["EU", "Q22890", "154", "150", "UN"], driveSide: "left", callingCodes: ["353"] } },
22774     { type: "Feature", properties: { iso1A2: "IL", iso1A3: "ISR", iso1N3: "376", wikidata: "Q801", nameEn: "Israel", groups: ["145", "142", "UN"], callingCodes: ["972"] }, geometry: { type: "MultiPolygon", coordinates: [[[[34.052, 31.46619], [34.29262, 31.70393], [34.48681, 31.59711], [34.56797, 31.54197], [34.48892, 31.48365], [34.40077, 31.40926], [34.36505, 31.36404], [34.37381, 31.30598], [34.36523, 31.28963], [34.29417, 31.24194], [34.26742, 31.21998], [34.92298, 29.45305], [34.97718, 29.54294], [34.98207, 29.58147], [35.02147, 29.66343], [35.14108, 30.07374], [35.19183, 30.34636], [35.16218, 30.43535], [35.19595, 30.50297], [35.21379, 30.60401], [35.29311, 30.71365], [35.33456, 30.81224], [35.33984, 30.8802], [35.41371, 30.95565], [35.43658, 31.12444], [35.40316, 31.25535], [35.47672, 31.49578], [35.39675, 31.49572], [35.22921, 31.37445], [35.13033, 31.3551], [35.02459, 31.35979], [34.92571, 31.34337], [34.88932, 31.37093], [34.87833, 31.39321], [34.89756, 31.43891], [34.93258, 31.47816], [34.94356, 31.50743], [34.9415, 31.55601], [34.95249, 31.59813], [35.00879, 31.65426], [35.08226, 31.69107], [35.10782, 31.71594], [35.11895, 31.71454], [35.12933, 31.7325], [35.13931, 31.73012], [35.15119, 31.73634], [35.15474, 31.73352], [35.16478, 31.73242], [35.18023, 31.72067], [35.20538, 31.72388], [35.21937, 31.71578], [35.22392, 31.71899], [35.23972, 31.70896], [35.24315, 31.71244], [35.2438, 31.7201], [35.24981, 31.72543], [35.25182, 31.73945], [35.26319, 31.74846], [35.25225, 31.7678], [35.26058, 31.79064], [35.25573, 31.81362], [35.26404, 31.82567], [35.251, 31.83085], [35.25753, 31.8387], [35.24816, 31.8458], [35.2304, 31.84222], [35.2249, 31.85433], [35.22817, 31.8638], [35.22567, 31.86745], [35.22294, 31.87889], [35.22014, 31.88264], [35.2136, 31.88241], [35.21276, 31.88153], [35.21016, 31.88237], [35.20945, 31.8815], [35.20791, 31.8821], [35.20673, 31.88151], [35.20381, 31.86716], [35.21128, 31.863], [35.216, 31.83894], [35.21469, 31.81835], [35.19461, 31.82687], [35.18169, 31.82542], [35.18603, 31.80901], [35.14174, 31.81325], [35.07677, 31.85627], [35.05617, 31.85685], [35.01978, 31.82944], [34.9724, 31.83352], [34.99712, 31.85569], [35.03489, 31.85919], [35.03978, 31.89276], [35.03489, 31.92448], [35.00124, 31.93264], [34.98682, 31.96935], [35.00261, 32.027], [34.9863, 32.09551], [34.99437, 32.10962], [34.98507, 32.12606], [34.99039, 32.14626], [34.96009, 32.17503], [34.95703, 32.19522], [34.98885, 32.20758], [35.01841, 32.23981], [35.02939, 32.2671], [35.01119, 32.28684], [35.01772, 32.33863], [35.04243, 32.35008], [35.05142, 32.3667], [35.0421, 32.38242], [35.05311, 32.4024], [35.05423, 32.41754], [35.07059, 32.4585], [35.08564, 32.46948], [35.09236, 32.47614], [35.10024, 32.47856], [35.10882, 32.4757], [35.15937, 32.50466], [35.2244, 32.55289], [35.25049, 32.52453], [35.29306, 32.50947], [35.30685, 32.51024], [35.35212, 32.52047], [35.40224, 32.50136], [35.42034, 32.46009], [35.41598, 32.45593], [35.41048, 32.43706], [35.42078, 32.41562], [35.55807, 32.38674], [35.55494, 32.42687], [35.57485, 32.48669], [35.56614, 32.64393], [35.59813, 32.65159], [35.61669, 32.67999], [35.66527, 32.681], [35.68467, 32.70715], [35.75983, 32.74803], [35.78745, 32.77938], [35.83758, 32.82817], [35.84021, 32.8725], [35.87012, 32.91976], [35.89298, 32.9456], [35.87188, 32.98028], [35.84802, 33.1031], [35.81911, 33.11077], [35.81911, 33.1336], [35.84285, 33.16673], [35.83846, 33.19397], [35.81647, 33.2028], [35.81295, 33.24841], [35.77513, 33.27342], [35.813, 33.3172], [35.77477, 33.33609], [35.62019, 33.27278], [35.62283, 33.24226], [35.58502, 33.26653], [35.58326, 33.28381], [35.56523, 33.28969], [35.55555, 33.25844], [35.54544, 33.25513], [35.54808, 33.236], [35.5362, 33.23196], [35.54228, 33.19865], [35.52573, 33.11921], [35.50335, 33.114], [35.50272, 33.09056], [35.448, 33.09264], [35.43059, 33.06659], [35.35223, 33.05617], [35.31429, 33.10515], [35.1924, 33.08743], [35.10645, 33.09318], [34.78515, 33.20368], [33.62659, 31.82938], [34.052, 31.46619]]]] } },
22775     { type: "Feature", properties: { iso1A2: "IM", iso1A3: "IMN", iso1N3: "833", wikidata: "Q9676", nameEn: "Isle of Man", country: "GB", groups: ["Q185086", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01624", "44 07624", "44 07524", "44 07924"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-3.98763, 54.07351], [-4.1819, 54.57861], [-5.6384, 53.81157], [-3.98763, 54.07351]]]] } },
22776     { type: "Feature", properties: { iso1A2: "IN", iso1A3: "IND", iso1N3: "356", wikidata: "Q668", nameEn: "India" }, geometry: null },
22777     { type: "Feature", properties: { iso1A2: "IO", iso1A3: "IOT", iso1N3: "086", wikidata: "Q43448", nameEn: "British Indian Ocean Territory", country: "GB" }, geometry: null },
22778     { type: "Feature", properties: { iso1A2: "IQ", iso1A3: "IRQ", iso1N3: "368", wikidata: "Q796", nameEn: "Iraq", groups: ["145", "142", "UN"], callingCodes: ["964"] }, geometry: { type: "MultiPolygon", coordinates: [[[[42.78887, 37.38615], [42.56725, 37.14878], [42.35724, 37.10998], [42.36697, 37.0627], [41.81736, 36.58782], [41.40058, 36.52502], [41.28864, 36.35368], [41.2564, 36.06012], [41.37027, 35.84095], [41.38184, 35.62502], [41.26569, 35.42708], [41.21654, 35.1508], [41.2345, 34.80049], [41.12388, 34.65742], [40.97676, 34.39788], [40.64314, 34.31604], [38.79171, 33.37328], [39.08202, 32.50304], [38.98762, 32.47694], [39.04251, 32.30203], [39.26157, 32.35555], [39.29903, 32.23259], [40.01521, 32.05667], [42.97601, 30.72204], [42.97796, 30.48295], [44.72255, 29.19736], [46.42415, 29.05947], [46.5527, 29.10283], [46.89695, 29.50584], [47.15166, 30.01044], [47.37192, 30.10421], [47.7095, 30.10453], [48.01114, 29.98906], [48.06782, 30.02906], [48.17332, 30.02448], [48.40479, 29.85763], [48.59531, 29.66815], [48.83867, 29.78572], [48.61441, 29.93675], [48.51011, 29.96238], [48.44785, 30.00148], [48.4494, 30.04456], [48.43384, 30.08233], [48.38869, 30.11062], [48.38714, 30.13485], [48.41671, 30.17254], [48.41117, 30.19846], [48.26393, 30.3408], [48.24385, 30.33846], [48.21279, 30.31644], [48.19425, 30.32796], [48.18321, 30.39703], [48.14585, 30.44133], [48.02443, 30.4789], [48.03221, 30.9967], [47.68219, 31.00004], [47.6804, 31.39086], [47.86337, 31.78422], [47.64771, 32.07666], [47.52474, 32.15972], [47.57144, 32.20583], [47.37529, 32.47808], [47.17218, 32.45393], [46.46788, 32.91992], [46.32298, 32.9731], [46.17198, 32.95612], [46.09103, 32.98354], [46.15175, 33.07229], [46.03966, 33.09577], [46.05367, 33.13097], [46.11905, 33.11924], [46.20623, 33.20395], [45.99919, 33.5082], [45.86687, 33.49263], [45.96183, 33.55751], [45.89801, 33.63661], [45.77814, 33.60938], [45.50261, 33.94968], [45.42789, 33.9458], [45.41077, 33.97421], [45.47264, 34.03099], [45.56176, 34.15088], [45.58667, 34.30147], [45.53552, 34.35148], [45.49171, 34.3439], [45.46697, 34.38221], [45.43879, 34.45949], [45.51883, 34.47692], [45.53219, 34.60441], [45.59074, 34.55558], [45.60224, 34.55057], [45.73923, 34.54416], [45.70031, 34.69277], [45.65672, 34.7222], [45.68284, 34.76624], [45.70031, 34.82322], [45.73641, 34.83975], [45.79682, 34.85133], [45.78904, 34.91135], [45.86532, 34.89858], [45.89477, 34.95805], [45.87864, 35.03441], [45.92173, 35.0465], [45.92203, 35.09538], [45.93108, 35.08148], [45.94756, 35.09188], [46.06508, 35.03699], [46.07747, 35.0838], [46.11763, 35.07551], [46.19116, 35.11097], [46.15642, 35.1268], [46.16229, 35.16984], [46.19738, 35.18536], [46.18457, 35.22561], [46.11367, 35.23729], [46.15474, 35.2883], [46.13152, 35.32548], [46.05358, 35.38568], [45.98453, 35.49848], [46.01518, 35.52012], [45.97584, 35.58132], [46.03028, 35.57416], [46.01307, 35.59756], [46.0165, 35.61501], [45.99452, 35.63574], [46.0117, 35.65059], [46.01631, 35.69139], [46.23736, 35.71414], [46.34166, 35.78363], [46.32921, 35.82655], [46.17198, 35.8013], [46.08325, 35.8581], [45.94711, 35.82218], [45.89784, 35.83708], [45.81442, 35.82107], [45.76145, 35.79898], [45.6645, 35.92872], [45.60018, 35.96069], [45.55245, 35.99943], [45.46594, 36.00042], [45.38275, 35.97156], [45.33916, 35.99424], [45.37652, 36.06222], [45.37312, 36.09917], [45.32235, 36.17383], [45.30038, 36.27769], [45.26261, 36.3001], [45.27394, 36.35846], [45.23953, 36.43257], [45.11811, 36.40751], [45.00759, 36.5402], [45.06985, 36.62645], [45.06985, 36.6814], [45.01537, 36.75128], [44.84725, 36.77622], [44.83479, 36.81362], [44.90173, 36.86096], [44.91199, 36.91468], [44.89862, 37.01897], [44.81611, 37.04383], [44.75229, 37.11958], [44.78319, 37.1431], [44.76698, 37.16162], [44.63179, 37.19229], [44.42631, 37.05825], [44.38117, 37.05825], [44.35315, 37.04955], [44.35937, 37.02843], [44.30645, 36.97373], [44.25975, 36.98119], [44.18503, 37.09551], [44.22239, 37.15756], [44.27998, 37.16501], [44.2613, 37.25055], [44.13521, 37.32486], [44.02002, 37.33229], [43.90949, 37.22453], [43.84878, 37.22205], [43.82699, 37.19477], [43.8052, 37.22825], [43.7009, 37.23692], [43.63085, 37.21957], [43.56702, 37.25675], [43.50787, 37.24436], [43.33508, 37.33105], [43.30083, 37.30629], [43.11403, 37.37436], [42.93705, 37.32015], [42.78887, 37.38615]]]] } },
22779     { type: "Feature", properties: { iso1A2: "IR", iso1A3: "IRN", iso1N3: "364", wikidata: "Q794", nameEn: "Iran", groups: ["034", "142", "UN"], callingCodes: ["98"] }, geometry: { type: "MultiPolygon", coordinates: [[[[44.96746, 39.42998], [44.88916, 39.59653], [44.81043, 39.62677], [44.71806, 39.71124], [44.65422, 39.72163], [44.6137, 39.78393], [44.47298, 39.68788], [44.48111, 39.61579], [44.41849, 39.56659], [44.42832, 39.4131], [44.37921, 39.4131], [44.29818, 39.378], [44.22452, 39.4169], [44.03667, 39.39223], [44.1043, 39.19842], [44.20946, 39.13975], [44.18863, 38.93881], [44.30322, 38.81581], [44.26155, 38.71427], [44.28065, 38.6465], [44.32058, 38.62752], [44.3207, 38.49799], [44.3119, 38.37887], [44.38309, 38.36117], [44.44386, 38.38295], [44.50115, 38.33939], [44.42476, 38.25763], [44.22509, 37.88859], [44.3883, 37.85433], [44.45948, 37.77065], [44.55498, 37.783], [44.62096, 37.71985], [44.56887, 37.6429], [44.61401, 37.60165], [44.58449, 37.45018], [44.81021, 37.2915], [44.75986, 37.21549], [44.7868, 37.16644], [44.78319, 37.1431], [44.75229, 37.11958], [44.81611, 37.04383], [44.89862, 37.01897], [44.91199, 36.91468], [44.90173, 36.86096], [44.83479, 36.81362], [44.84725, 36.77622], [45.01537, 36.75128], [45.06985, 36.6814], [45.06985, 36.62645], [45.00759, 36.5402], [45.11811, 36.40751], [45.23953, 36.43257], [45.27394, 36.35846], [45.26261, 36.3001], [45.30038, 36.27769], [45.32235, 36.17383], [45.37312, 36.09917], [45.37652, 36.06222], [45.33916, 35.99424], [45.38275, 35.97156], [45.46594, 36.00042], [45.55245, 35.99943], [45.60018, 35.96069], [45.6645, 35.92872], [45.76145, 35.79898], [45.81442, 35.82107], [45.89784, 35.83708], [45.94711, 35.82218], [46.08325, 35.8581], [46.17198, 35.8013], [46.32921, 35.82655], [46.34166, 35.78363], [46.23736, 35.71414], [46.01631, 35.69139], [46.0117, 35.65059], [45.99452, 35.63574], [46.0165, 35.61501], [46.01307, 35.59756], [46.03028, 35.57416], [45.97584, 35.58132], [46.01518, 35.52012], [45.98453, 35.49848], [46.05358, 35.38568], [46.13152, 35.32548], [46.15474, 35.2883], [46.11367, 35.23729], [46.18457, 35.22561], [46.19738, 35.18536], [46.16229, 35.16984], [46.15642, 35.1268], [46.19116, 35.11097], [46.11763, 35.07551], [46.07747, 35.0838], [46.06508, 35.03699], [45.94756, 35.09188], [45.93108, 35.08148], [45.92203, 35.09538], [45.92173, 35.0465], [45.87864, 35.03441], [45.89477, 34.95805], [45.86532, 34.89858], [45.78904, 34.91135], [45.79682, 34.85133], [45.73641, 34.83975], [45.70031, 34.82322], [45.68284, 34.76624], [45.65672, 34.7222], [45.70031, 34.69277], [45.73923, 34.54416], [45.60224, 34.55057], [45.59074, 34.55558], [45.53219, 34.60441], [45.51883, 34.47692], [45.43879, 34.45949], [45.46697, 34.38221], [45.49171, 34.3439], [45.53552, 34.35148], [45.58667, 34.30147], [45.56176, 34.15088], [45.47264, 34.03099], [45.41077, 33.97421], [45.42789, 33.9458], [45.50261, 33.94968], [45.77814, 33.60938], [45.89801, 33.63661], [45.96183, 33.55751], [45.86687, 33.49263], [45.99919, 33.5082], [46.20623, 33.20395], [46.11905, 33.11924], [46.05367, 33.13097], [46.03966, 33.09577], [46.15175, 33.07229], [46.09103, 32.98354], [46.17198, 32.95612], [46.32298, 32.9731], [46.46788, 32.91992], [47.17218, 32.45393], [47.37529, 32.47808], [47.57144, 32.20583], [47.52474, 32.15972], [47.64771, 32.07666], [47.86337, 31.78422], [47.6804, 31.39086], [47.68219, 31.00004], [48.03221, 30.9967], [48.02443, 30.4789], [48.14585, 30.44133], [48.18321, 30.39703], [48.19425, 30.32796], [48.21279, 30.31644], [48.24385, 30.33846], [48.26393, 30.3408], [48.41117, 30.19846], [48.41671, 30.17254], [48.38714, 30.13485], [48.38869, 30.11062], [48.43384, 30.08233], [48.4494, 30.04456], [48.44785, 30.00148], [48.51011, 29.96238], [48.61441, 29.93675], [48.83867, 29.78572], [49.98877, 27.87827], [50.37726, 27.89227], [54.39838, 25.68383], [55.14145, 25.62624], [55.81777, 26.18798], [56.2644, 26.58649], [56.68954, 26.76645], [56.79239, 26.41236], [56.82555, 25.7713], [56.86325, 25.03856], [61.46682, 24.57869], [61.6433, 25.27541], [61.683, 25.66638], [61.83968, 25.7538], [61.83831, 26.07249], [61.89391, 26.26251], [62.05117, 26.31647], [62.21304, 26.26601], [62.31484, 26.528], [62.77352, 26.64099], [63.1889, 26.65072], [63.18688, 26.83844], [63.25005, 26.84212], [63.25005, 27.08692], [63.32283, 27.14437], [63.19649, 27.25674], [62.80604, 27.22412], [62.79684, 27.34381], [62.84905, 27.47627], [62.7638, 28.02992], [62.79412, 28.28108], [62.59499, 28.24842], [62.40259, 28.42703], [61.93581, 28.55284], [61.65978, 28.77937], [61.53765, 29.00507], [61.31508, 29.38903], [60.87231, 29.86514], [61.80829, 30.84224], [61.78268, 30.92724], [61.8335, 30.97669], [61.83257, 31.0452], [61.80957, 31.12576], [61.80569, 31.16167], [61.70929, 31.37391], [60.84541, 31.49561], [60.86191, 32.22565], [60.56485, 33.12944], [60.88908, 33.50219], [60.91133, 33.55596], [60.69573, 33.56054], [60.57762, 33.59772], [60.5485, 33.73422], [60.5838, 33.80793], [60.50209, 34.13992], [60.66502, 34.31539], [60.91321, 34.30411], [60.72316, 34.52857], [60.99922, 34.63064], [61.00197, 34.70631], [61.06926, 34.82139], [61.12831, 35.09938], [61.0991, 35.27845], [61.18187, 35.30249], [61.27371, 35.61482], [61.22719, 35.67038], [61.26152, 35.80749], [61.22444, 35.92879], [61.12007, 35.95992], [61.22719, 36.12759], [61.1393, 36.38782], [61.18187, 36.55348], [61.14516, 36.64644], [60.34767, 36.63214], [60.00768, 37.04102], [59.74678, 37.12499], [59.55178, 37.13594], [59.39385, 37.34257], [59.39797, 37.47892], [59.33507, 37.53146], [59.22905, 37.51161], [58.9338, 37.67374], [58.6921, 37.64548], [58.5479, 37.70526], [58.47786, 37.6433], [58.39959, 37.63134], [58.22999, 37.6856], [58.21399, 37.77281], [57.79534, 37.89299], [57.35042, 37.98546], [57.37236, 38.09321], [57.21169, 38.28965], [57.03453, 38.18717], [56.73928, 38.27887], [56.62255, 38.24005], [56.43303, 38.26054], [56.32454, 38.18502], [56.33278, 38.08132], [55.97847, 38.08024], [55.76561, 38.12238], [55.44152, 38.08564], [55.13412, 37.94705], [54.851, 37.75739], [54.77684, 37.62264], [54.81804, 37.61285], [54.77822, 37.51597], [54.67247, 37.43532], [54.58664, 37.45809], [54.36211, 37.34912], [54.24565, 37.32047], [53.89734, 37.3464], [48.88288, 38.43975], [48.84969, 38.45015], [48.81072, 38.44853], [48.78979, 38.45026], [48.70001, 38.40564], [48.62217, 38.40198], [48.58793, 38.45076], [48.45084, 38.61013], [48.3146, 38.59958], [48.24773, 38.71883], [48.02581, 38.82705], [48.01409, 38.90333], [48.07734, 38.91616], [48.08627, 38.94434], [48.28437, 38.97186], [48.33884, 39.03022], [48.31239, 39.09278], [48.15361, 39.19419], [48.12404, 39.25208], [48.15984, 39.30028], [48.37385, 39.37584], [48.34264, 39.42935], [47.98977, 39.70999], [47.84774, 39.66285], [47.50099, 39.49615], [47.38978, 39.45999], [47.31301, 39.37492], [47.05927, 39.24846], [47.05771, 39.20143], [46.95341, 39.13505], [46.92539, 39.16644], [46.83822, 39.13143], [46.75752, 39.03231], [46.53497, 38.86548], [46.34059, 38.92076], [46.20601, 38.85262], [46.14785, 38.84206], [46.06766, 38.87861], [46.00228, 38.87376], [45.94624, 38.89072], [45.90266, 38.87739], [45.83883, 38.90768], [45.65172, 38.95199], [45.6155, 38.94304], [45.6131, 38.964], [45.44966, 38.99243], [45.44811, 39.04927], [45.40452, 39.07224], [45.40148, 39.09007], [45.30489, 39.18333], [45.16168, 39.21952], [45.08751, 39.35052], [45.05932, 39.36435], [44.96746, 39.42998]]]] } },
22780     { type: "Feature", properties: { iso1A2: "IS", iso1A3: "ISL", iso1N3: "352", wikidata: "Q189", nameEn: "Iceland", groups: ["154", "150", "UN"], callingCodes: ["354"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-33.15676, 62.62995], [-8.25539, 63.0423], [-15.70914, 69.67442], [-33.15676, 62.62995]]]] } },
22781     { type: "Feature", properties: { iso1A2: "IT", iso1A3: "ITA", iso1N3: "380", wikidata: "Q38", nameEn: "Italy", groups: ["EU", "039", "150", "UN"], callingCodes: ["39"] }, geometry: { type: "MultiPolygon", coordinates: [[[[8.95861, 45.96485], [8.97604, 45.96151], [8.97741, 45.98317], [8.96668, 45.98436], [8.95861, 45.96485]]], [[[7.63035, 43.57419], [9.56115, 43.20816], [10.09675, 41.44089], [7.60802, 41.05927], [7.89009, 38.19924], [11.2718, 37.6713], [12.13667, 34.20326], [14.02721, 36.53141], [17.67657, 35.68918], [18.83516, 40.36999], [16.15283, 42.18525], [13.12821, 44.48877], [13.05142, 45.33128], [13.45644, 45.59464], [13.6076, 45.64761], [13.7198, 45.59352], [13.74587, 45.59811], [13.78445, 45.5825], [13.84106, 45.58185], [13.86771, 45.59898], [13.8695, 45.60835], [13.9191, 45.6322], [13.87933, 45.65207], [13.83422, 45.68703], [13.83332, 45.70855], [13.8235, 45.7176], [13.66986, 45.79955], [13.59784, 45.8072], [13.58858, 45.83503], [13.57563, 45.8425], [13.58644, 45.88173], [13.59565, 45.89446], [13.60857, 45.89907], [13.61931, 45.91782], [13.63815, 45.93607], [13.6329, 45.94894], [13.64307, 45.98326], [13.63458, 45.98947], [13.62074, 45.98388], [13.58903, 45.99009], [13.56759, 45.96991], [13.52963, 45.96588], [13.50104, 45.98078], [13.47474, 46.00546], [13.49702, 46.01832], [13.50998, 46.04498], [13.49568, 46.04839], [13.50104, 46.05986], [13.57072, 46.09022], [13.64053, 46.13587], [13.66472, 46.17392], [13.64451, 46.18966], [13.56682, 46.18703], [13.56114, 46.2054], [13.47587, 46.22725], [13.42218, 46.20758], [13.37671, 46.29668], [13.44808, 46.33507], [13.43418, 46.35992], [13.47019, 46.3621], [13.5763, 46.40915], [13.5763, 46.42613], [13.59777, 46.44137], [13.68684, 46.43881], [13.7148, 46.5222], [13.64088, 46.53438], [13.27627, 46.56059], [12.94445, 46.60401], [12.59992, 46.6595], [12.38708, 46.71529], [12.27591, 46.88651], [12.2006, 46.88854], [12.11675, 47.01241], [12.21781, 47.03996], [12.19254, 47.09331], [11.74789, 46.98484], [11.50739, 47.00644], [11.33355, 46.99862], [11.10618, 46.92966], [11.00764, 46.76896], [10.72974, 46.78972], [10.75753, 46.82258], [10.66405, 46.87614], [10.54783, 46.84505], [10.47197, 46.85698], [10.38659, 46.67847], [10.40475, 46.63671], [10.44686, 46.64162], [10.49375, 46.62049], [10.46136, 46.53164], [10.25309, 46.57432], [10.23674, 46.63484], [10.10307, 46.61003], [10.03715, 46.44479], [10.165, 46.41051], [10.10506, 46.3372], [10.17862, 46.25626], [10.14439, 46.22992], [10.07055, 46.21668], [9.95249, 46.38045], [9.73086, 46.35071], [9.71273, 46.29266], [9.57015, 46.2958], [9.46117, 46.37481], [9.45936, 46.50873], [9.40487, 46.46621], [9.36128, 46.5081], [9.28136, 46.49685], [9.25502, 46.43743], [9.29226, 46.32717], [9.24503, 46.23616], [9.01618, 46.04928], [8.99257, 45.9698], [9.09065, 45.89906], [9.06642, 45.8761], [9.04546, 45.84968], [9.04059, 45.8464], [9.03505, 45.83976], [9.03793, 45.83548], [9.03279, 45.82865], [9.0298, 45.82127], [9.00324, 45.82055], [8.99663, 45.83466], [8.9621, 45.83707], [8.94737, 45.84285], [8.91129, 45.8388], [8.93504, 45.86245], [8.94372, 45.86587], [8.93649, 45.86775], [8.88904, 45.95465], [8.86688, 45.96135], [8.85121, 45.97239], [8.8319, 45.9879], [8.79362, 45.99207], [8.78585, 45.98973], [8.79414, 46.00913], [8.85617, 46.0748], [8.80778, 46.10085], [8.75697, 46.10395], [8.62242, 46.12112], [8.45032, 46.26869], [8.46317, 46.43712], [8.42464, 46.46367], [8.30648, 46.41587], [8.31162, 46.38044], [8.08814, 46.26692], [8.16866, 46.17817], [8.11383, 46.11577], [8.02906, 46.10331], [7.98881, 45.99867], [7.9049, 45.99945], [7.85949, 45.91485], [7.56343, 45.97421], [7.10685, 45.85653], [7.04151, 45.92435], [6.95315, 45.85163], [6.80785, 45.83265], [6.80785, 45.71864], [6.98948, 45.63869], [7.00037, 45.509], [7.18019, 45.40071], [7.10572, 45.32924], [7.13115, 45.25386], [7.07074, 45.21228], [6.96706, 45.20841], [6.85144, 45.13226], [6.7697, 45.16044], [6.62803, 45.11175], [6.66981, 45.02324], [6.74791, 45.01939], [6.74519, 44.93661], [6.75518, 44.89915], [6.90774, 44.84322], [6.93499, 44.8664], [7.02217, 44.82519], [7.00401, 44.78782], [7.07484, 44.68073], [7.00582, 44.69364], [6.95133, 44.66264], [6.96042, 44.62129], [6.85507, 44.53072], [6.86233, 44.49834], [6.94504, 44.43112], [6.88784, 44.42043], [6.89171, 44.36637], [6.98221, 44.28289], [7.00764, 44.23736], [7.16929, 44.20352], [7.27827, 44.1462], [7.34547, 44.14359], [7.36364, 44.11882], [7.62155, 44.14881], [7.63245, 44.17877], [7.68694, 44.17487], [7.66878, 44.12795], [7.72508, 44.07578], [7.6597, 44.03009], [7.66848, 43.99943], [7.65266, 43.9763], [7.60771, 43.95772], [7.56858, 43.94506], [7.56075, 43.89932], [7.51162, 43.88301], [7.49355, 43.86551], [7.50423, 43.84345], [7.53006, 43.78405], [7.63035, 43.57419]], [[12.45181, 41.90056], [12.44834, 41.90095], [12.44582, 41.90194], [12.44815, 41.90326], [12.44984, 41.90545], [12.45091, 41.90625], [12.45543, 41.90738], [12.45561, 41.90629], [12.45762, 41.9058], [12.45755, 41.9033], [12.45826, 41.90281], [12.45834, 41.90174], [12.4577, 41.90115], [12.45691, 41.90125], [12.45626, 41.90172], [12.45435, 41.90143], [12.45446, 41.90028], [12.45181, 41.90056]], [[12.45648, 43.89369], [12.44184, 43.90498], [12.41641, 43.89991], [12.40935, 43.9024], [12.41233, 43.90956], [12.40733, 43.92379], [12.41551, 43.92984], [12.41165, 43.93769], [12.40506, 43.94325], [12.40415, 43.95485], [12.41414, 43.95273], [12.42005, 43.9578], [12.43662, 43.95698], [12.44684, 43.96597], [12.46205, 43.97463], [12.47853, 43.98052], [12.49406, 43.98492], [12.50678, 43.99113], [12.51463, 43.99122], [12.5154, 43.98508], [12.51064, 43.98165], [12.51109, 43.97201], [12.50622, 43.97131], [12.50875, 43.96198], [12.50655, 43.95796], [12.51427, 43.94897], [12.51553, 43.94096], [12.50496, 43.93017], [12.50269, 43.92363], [12.49724, 43.92248], [12.49247, 43.91774], [12.49429, 43.90973], [12.48771, 43.89706], [12.45648, 43.89369]]]] } },
22782     { type: "Feature", properties: { iso1A2: "JE", iso1A3: "JEY", iso1N3: "832", wikidata: "Q785", nameEn: "Bailiwick of Jersey", country: "GB", groups: ["830", "Q185086", "154", "150", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["44 01534"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.00491, 48.86706], [-1.83944, 49.23037], [-2.09454, 49.46288], [-2.65349, 49.15373], [-2.00491, 48.86706]]]] } },
22783     { type: "Feature", properties: { iso1A2: "JM", iso1A3: "JAM", iso1N3: "388", wikidata: "Q766", nameEn: "Jamaica", aliases: ["JA"], groups: ["029", "003", "419", "019", "UN"], driveSide: "left", callingCodes: ["1 876", "1 658"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-74.09729, 17.36817], [-78.9741, 19.59515], [-78.34606, 16.57862], [-74.09729, 17.36817]]]] } },
22784     { type: "Feature", properties: { iso1A2: "JO", iso1A3: "JOR", iso1N3: "400", wikidata: "Q810", nameEn: "Jordan", groups: ["145", "142", "UN"], callingCodes: ["962"] }, geometry: { type: "MultiPolygon", coordinates: [[[[39.04251, 32.30203], [38.98762, 32.47694], [39.08202, 32.50304], [38.79171, 33.37328], [36.83946, 32.31293], [36.40959, 32.37908], [36.23948, 32.50108], [36.20875, 32.49529], [36.20379, 32.52751], [36.08074, 32.51463], [36.02239, 32.65911], [35.96633, 32.66237], [35.93307, 32.71966], [35.88405, 32.71321], [35.75983, 32.74803], [35.68467, 32.70715], [35.66527, 32.681], [35.61669, 32.67999], [35.59813, 32.65159], [35.56614, 32.64393], [35.57485, 32.48669], [35.55494, 32.42687], [35.55807, 32.38674], [35.57111, 32.21877], [35.52012, 32.04076], [35.54375, 31.96587], [35.52758, 31.9131], [35.55941, 31.76535], [35.47672, 31.49578], [35.40316, 31.25535], [35.43658, 31.12444], [35.41371, 30.95565], [35.33984, 30.8802], [35.33456, 30.81224], [35.29311, 30.71365], [35.21379, 30.60401], [35.19595, 30.50297], [35.16218, 30.43535], [35.19183, 30.34636], [35.14108, 30.07374], [35.02147, 29.66343], [34.98207, 29.58147], [34.97718, 29.54294], [34.92298, 29.45305], [34.8812, 29.36878], [36.07081, 29.18469], [36.50005, 29.49696], [36.75083, 29.86903], [37.4971, 29.99949], [37.66395, 30.33245], [37.99354, 30.49998], [36.99791, 31.50081], [38.99233, 31.99721], [39.29903, 32.23259], [39.26157, 32.35555], [39.04251, 32.30203]]]] } },
22785     { type: "Feature", properties: { iso1A2: "JP", iso1A3: "JPN", iso1N3: "392", wikidata: "Q17", nameEn: "Japan", groups: ["030", "142", "UN"], driveSide: "left", callingCodes: ["81"] }, geometry: { type: "MultiPolygon", coordinates: [[[[145.82361, 43.38904], [145.23667, 43.76813], [145.82343, 44.571], [140.9182, 45.92937], [133.61399, 37.41], [129.2669, 34.87122], [122.26612, 25.98197], [123.92912, 17.8782], [155.16731, 23.60141], [145.82361, 43.38904]]]] } },
22786     { type: "Feature", properties: { iso1A2: "KE", iso1A3: "KEN", iso1N3: "404", wikidata: "Q114", nameEn: "Kenya", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["254"] }, geometry: { type: "MultiPolygon", coordinates: [[[[35.9419, 4.61933], [35.51424, 4.61643], [35.42366, 4.76969], [35.47843, 4.91872], [35.30992, 4.90402], [35.34151, 5.02364], [34.47601, 4.72162], [33.9873, 4.23316], [34.06046, 4.15235], [34.15429, 3.80464], [34.45815, 3.67385], [34.44922, 3.51627], [34.39112, 3.48802], [34.41794, 3.44342], [34.40006, 3.37949], [34.45815, 3.18319], [34.56242, 3.11478], [34.60114, 2.93034], [34.65774, 2.8753], [34.73967, 2.85447], [34.78137, 2.76223], [34.77244, 2.70272], [34.95267, 2.47209], [34.90947, 2.42447], [34.98692, 1.97348], [34.9899, 1.6668], [34.92734, 1.56109], [34.87819, 1.5596], [34.7918, 1.36752], [34.82606, 1.30944], [34.82606, 1.26626], [34.80223, 1.22754], [34.67562, 1.21265], [34.58029, 1.14712], [34.57427, 1.09868], [34.52369, 1.10692], [34.43349, 0.85254], [34.40041, 0.80266], [34.31516, 0.75693], [34.27345, 0.63182], [34.20196, 0.62289], [34.13493, 0.58118], [34.11408, 0.48884], [34.08727, 0.44713], [34.10067, 0.36372], [33.90936, 0.10581], [33.98449, -0.13079], [33.9264, -0.54188], [33.93107, -0.99298], [34.02286, -1.00779], [34.03084, -1.05101], [34.0824, -1.02264], [37.67199, -3.06222], [37.71745, -3.304], [37.5903, -3.42735], [37.63099, -3.50723], [37.75036, -3.54243], [37.81321, -3.69179], [39.21631, -4.67835], [39.44306, -4.93877], [39.62121, -4.68136], [41.75542, -1.85308], [41.56362, -1.66375], [41.56, -1.59812], [41.00099, -0.83068], [40.98767, 2.82959], [41.31368, 3.14314], [41.89488, 3.97375], [41.1754, 3.94079], [40.77498, 4.27683], [39.86043, 3.86974], [39.76808, 3.67058], [39.58339, 3.47434], [39.55132, 3.39634], [39.51551, 3.40895], [39.49444, 3.45521], [39.19954, 3.47834], [39.07736, 3.5267], [38.91938, 3.51198], [38.52336, 3.62551], [38.45812, 3.60445], [38.14168, 3.62487], [37.07724, 4.33503], [36.84474, 4.44518], [36.03924, 4.44406], [35.95449, 4.53244], [35.9419, 4.61933]]]] } },
22787     { type: "Feature", properties: { iso1A2: "KG", iso1A3: "KGZ", iso1N3: "417", wikidata: "Q813", nameEn: "Kyrgyzstan", groups: ["143", "142", "UN"], callingCodes: ["996"] }, geometry: { type: "MultiPolygon", coordinates: [[[[74.88756, 42.98612], [74.75, 42.99029], [74.70331, 43.02519], [74.64615, 43.05881], [74.57491, 43.13702], [74.22489, 43.24657], [73.55634, 43.03071], [73.50992, 42.82356], [73.44393, 42.43098], [71.88792, 42.83578], [71.62405, 42.76613], [71.53272, 42.8014], [71.2724, 42.77853], [71.22785, 42.69248], [71.17807, 42.67381], [71.15232, 42.60486], [70.97717, 42.50147], [70.85973, 42.30188], [70.94483, 42.26238], [71.13263, 42.28356], [71.28719, 42.18033], [70.69777, 41.92554], [70.17682, 41.5455], [70.48909, 41.40335], [70.67586, 41.47953], [70.78572, 41.36419], [70.77885, 41.24813], [70.86263, 41.23833], [70.9615, 41.16393], [71.02193, 41.19494], [71.11806, 41.15359], [71.25813, 41.18796], [71.27187, 41.11015], [71.34877, 41.16807], [71.40198, 41.09436], [71.46148, 41.13958], [71.43814, 41.19644], [71.46688, 41.31883], [71.57227, 41.29175], [71.6787, 41.42111], [71.65914, 41.49599], [71.73054, 41.54713], [71.71132, 41.43012], [71.76625, 41.4466], [71.83914, 41.3546], [71.91457, 41.2982], [71.85964, 41.19081], [72.07249, 41.11739], [72.10745, 41.15483], [72.16433, 41.16483], [72.17594, 41.15522], [72.14864, 41.13363], [72.1792, 41.10621], [72.21061, 41.05607], [72.17594, 41.02377], [72.18339, 40.99571], [72.324, 41.03381], [72.34026, 41.04539], [72.34757, 41.06104], [72.36138, 41.04384], [72.38511, 41.02785], [72.45206, 41.03018], [72.48742, 40.97136], [72.55109, 40.96046], [72.59136, 40.86947], [72.68157, 40.84942], [72.84291, 40.85512], [72.94454, 40.8094], [73.01869, 40.84681], [73.13267, 40.83512], [73.13412, 40.79122], [73.0612, 40.76678], [72.99133, 40.76457], [72.93296, 40.73089], [72.8722, 40.71111], [72.85372, 40.7116], [72.84754, 40.67229], [72.80137, 40.67856], [72.74866, 40.60873], [72.74894, 40.59592], [72.75982, 40.57273], [72.74862, 40.57131], [72.74768, 40.58051], [72.73995, 40.58409], [72.69579, 40.59778], [72.66713, 40.59076], [72.66713, 40.5219], [72.47795, 40.5532], [72.40517, 40.61917], [72.34406, 40.60144], [72.41714, 40.55736], [72.38384, 40.51535], [72.41513, 40.50856], [72.44191, 40.48222], [72.40346, 40.4007], [72.24368, 40.46091], [72.18648, 40.49893], [71.96401, 40.31907], [72.05464, 40.27586], [71.85002, 40.25647], [71.82646, 40.21872], [71.73054, 40.14818], [71.71719, 40.17886], [71.69621, 40.18492], [71.70569, 40.20391], [71.68386, 40.26984], [71.61931, 40.26775], [71.61725, 40.20615], [71.51549, 40.22986], [71.51215, 40.26943], [71.4246, 40.28619], [71.36663, 40.31593], [71.13042, 40.34106], [71.05901, 40.28765], [70.95789, 40.28761], [70.9818, 40.22392], [70.80495, 40.16813], [70.7928, 40.12797], [70.65827, 40.0981], [70.65946, 39.9878], [70.58912, 39.95211], [70.55033, 39.96619], [70.47557, 39.93216], [70.57384, 39.99394], [70.58297, 40.00891], [70.01283, 40.23288], [69.67001, 40.10639], [69.64704, 40.12165], [69.57615, 40.10524], [69.55555, 40.12296], [69.53794, 40.11833], [69.53855, 40.0887], [69.5057, 40.03277], [69.53615, 39.93991], [69.43557, 39.92877], [69.43134, 39.98431], [69.35649, 40.01994], [69.26938, 39.8127], [69.3594, 39.52516], [69.68677, 39.59281], [69.87491, 39.53882], [70.11111, 39.58223], [70.2869, 39.53141], [70.44757, 39.60128], [70.64087, 39.58792], [70.7854, 39.38933], [71.06418, 39.41586], [71.08752, 39.50704], [71.49814, 39.61397], [71.55856, 39.57588], [71.5517, 39.45722], [71.62688, 39.44056], [71.76816, 39.45456], [71.80164, 39.40631], [71.7522, 39.32031], [71.79202, 39.27355], [71.90601, 39.27674], [72.04059, 39.36704], [72.09689, 39.26823], [72.17242, 39.2661], [72.23834, 39.17248], [72.33173, 39.33093], [72.62027, 39.39696], [72.85934, 39.35116], [73.18454, 39.35536], [73.31912, 39.38615], [73.45096, 39.46677], [73.59831, 39.46425], [73.87018, 39.47879], [73.94683, 39.60733], [73.92354, 39.69565], [73.9051, 39.75073], [73.83006, 39.76136], [73.97049, 40.04378], [74.25533, 40.13191], [74.35063, 40.09742], [74.69875, 40.34668], [74.85996, 40.32857], [74.78168, 40.44886], [74.82013, 40.52197], [75.08243, 40.43945], [75.22834, 40.45382], [75.5854, 40.66874], [75.69663, 40.28642], [75.91361, 40.2948], [75.96168, 40.38064], [76.33659, 40.3482], [76.5261, 40.46114], [76.75681, 40.95354], [76.99302, 41.0696], [77.28004, 41.0033], [77.3693, 41.0375], [77.52723, 41.00227], [77.76206, 41.01574], [77.81287, 41.14307], [78.12873, 41.23091], [78.15757, 41.38565], [78.3732, 41.39603], [79.92977, 42.04113], [80.17842, 42.03211], [80.17807, 42.21166], [79.97364, 42.42816], [79.52921, 42.44778], [79.19763, 42.804], [78.91502, 42.76839], [78.48469, 42.89649], [75.82823, 42.94848], [75.72174, 42.79672], [75.29966, 42.86183], [75.22619, 42.85528], [74.88756, 42.98612]], [[70.74189, 39.86319], [70.63105, 39.77923], [70.59667, 39.83542], [70.54998, 39.85137], [70.52631, 39.86989], [70.53651, 39.89155], [70.74189, 39.86319]], [[71.86463, 39.98598], [71.84316, 39.95582], [71.7504, 39.93701], [71.71511, 39.96348], [71.78838, 40.01404], [71.86463, 39.98598]], [[71.21139, 40.03369], [71.1427, 39.95026], [71.23067, 39.93581], [71.16101, 39.88423], [71.10531, 39.91354], [71.04979, 39.89808], [71.10501, 39.95568], [71.09063, 39.99], [71.11668, 39.99291], [71.11037, 40.01984], [71.01035, 40.05481], [71.00236, 40.18154], [71.06305, 40.1771], [71.12218, 40.03052], [71.21139, 40.03369]]]] } },
22788     { type: "Feature", properties: { iso1A2: "KH", iso1A3: "KHM", iso1N3: "116", wikidata: "Q424", nameEn: "Cambodia", groups: ["035", "142", "UN"], callingCodes: ["855"] }, geometry: { type: "MultiPolygon", coordinates: [[[[105.87328, 11.55953], [105.81645, 11.56876], [105.80867, 11.60536], [105.8507, 11.66635], [105.88962, 11.67854], [105.95188, 11.63738], [106.00792, 11.7197], [106.02038, 11.77457], [106.06708, 11.77761], [106.13158, 11.73283], [106.18539, 11.75171], [106.26478, 11.72122], [106.30525, 11.67549], [106.37219, 11.69836], [106.44691, 11.66787], [106.45158, 11.68616], [106.41577, 11.76999], [106.44535, 11.8279], [106.44068, 11.86294], [106.4687, 11.86751], [106.4111, 11.97413], [106.70687, 11.96956], [106.79405, 12.0807], [106.92325, 12.06548], [106.99953, 12.08983], [107.15831, 12.27547], [107.34511, 12.33327], [107.42917, 12.24657], [107.4463, 12.29373], [107.55059, 12.36824], [107.5755, 12.52177], [107.55993, 12.7982], [107.49611, 12.88926], [107.49144, 13.01215], [107.62843, 13.3668], [107.61909, 13.52577], [107.53503, 13.73908], [107.45252, 13.78897], [107.46498, 13.91593], [107.44318, 13.99751], [107.38247, 13.99147], [107.35757, 14.02319], [107.37158, 14.07906], [107.33577, 14.11832], [107.40427, 14.24509], [107.39493, 14.32655], [107.44941, 14.41552], [107.48521, 14.40346], [107.52569, 14.54665], [107.52102, 14.59034], [107.55371, 14.628], [107.54361, 14.69092], [107.47238, 14.61523], [107.44435, 14.52785], [107.37897, 14.54443], [107.3276, 14.58812], [107.29803, 14.58963], [107.26534, 14.54292], [107.256, 14.48716], [107.21241, 14.48716], [107.17038, 14.41782], [107.09722, 14.3937], [107.03962, 14.45099], [107.04585, 14.41782], [106.98825, 14.36806], [106.9649, 14.3198], [106.90574, 14.33639], [106.8497, 14.29416], [106.80767, 14.31226], [106.73762, 14.42687], [106.63333, 14.44194], [106.59908, 14.50977], [106.57106, 14.50525], [106.54148, 14.59565], [106.50723, 14.58963], [106.45898, 14.55045], [106.47766, 14.50977], [106.43874, 14.52032], [106.40916, 14.45249], [106.32355, 14.44043], [106.25194, 14.48415], [106.21302, 14.36203], [106.00131, 14.36957], [105.99509, 14.32734], [106.02311, 14.30623], [106.04801, 14.20363], [106.10872, 14.18401], [106.11962, 14.11307], [106.18656, 14.06324], [106.16632, 14.01794], [106.10094, 13.98471], [106.10405, 13.9137], [105.90791, 13.92881], [105.78182, 14.02247], [105.78338, 14.08438], [105.5561, 14.15684], [105.44869, 14.10703], [105.36775, 14.09948], [105.2759, 14.17496], [105.20894, 14.34967], [105.17748, 14.34432], [105.14012, 14.23873], [105.08408, 14.20402], [105.02804, 14.23722], [104.97667, 14.38806], [104.69335, 14.42726], [104.55014, 14.36091], [104.27616, 14.39861], [103.93836, 14.3398], [103.70175, 14.38052], [103.71109, 14.4348], [103.53518, 14.42575], [103.39353, 14.35639], [103.16469, 14.33075], [102.93275, 14.19044], [102.91251, 14.01531], [102.77864, 13.93374], [102.72727, 13.77806], [102.56848, 13.69366], [102.5481, 13.6589], [102.58635, 13.6286], [102.62483, 13.60883], [102.57573, 13.60461], [102.5358, 13.56933], [102.44601, 13.5637], [102.36859, 13.57488], [102.33828, 13.55613], [102.361, 13.50551], [102.35563, 13.47307], [102.35692, 13.38274], [102.34611, 13.35618], [102.36001, 13.31142], [102.36146, 13.26006], [102.43422, 13.09061], [102.46011, 13.08057], [102.52275, 12.99813], [102.48694, 12.97537], [102.49335, 12.92711], [102.53053, 12.77506], [102.4994, 12.71736], [102.51963, 12.66117], [102.57567, 12.65358], [102.7796, 12.43781], [102.78116, 12.40284], [102.73134, 12.37091], [102.70176, 12.1686], [102.77026, 12.06815], [102.78427, 11.98746], [102.83957, 11.8519], [102.90973, 11.75613], [102.91449, 11.65512], [102.52395, 11.25257], [102.47649, 9.66162], [103.99198, 10.48391], [104.43778, 10.42386], [104.47963, 10.43046], [104.49869, 10.4057], [104.59018, 10.53073], [104.87933, 10.52833], [104.95094, 10.64003], [105.09571, 10.72722], [105.02722, 10.89236], [105.08326, 10.95656], [105.11449, 10.96332], [105.34011, 10.86179], [105.42884, 10.96878], [105.50045, 10.94586], [105.77751, 11.03671], [105.86376, 10.89839], [105.84603, 10.85873], [105.93403, 10.83853], [105.94535, 10.9168], [106.06708, 10.8098], [106.18539, 10.79451], [106.14301, 10.98176], [106.20095, 10.97795], [106.1757, 11.07301], [106.1527, 11.10476], [106.10444, 11.07879], [105.86782, 11.28343], [105.88962, 11.43605], [105.87328, 11.55953]]]] } },
22789     { type: "Feature", properties: { iso1A2: "KI", iso1A3: "KIR", iso1N3: "296", wikidata: "Q710", nameEn: "Kiribati", groups: ["057", "009", "UN"], driveSide: "left", callingCodes: ["686"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169, 3.9], [169, -3.5], [178, -3.5], [178, 3.9], [169, 3.9]]], [[[-161.06795, 5.2462], [-158.12991, -1.86122], [-175.33482, -1.40631], [-175.31804, -7.54825], [-156.50903, -7.4975], [-156.48634, -15.52824], [-135.59706, -4.70473], [-161.06795, 5.2462]]]] } },
22790     { type: "Feature", properties: { iso1A2: "KM", iso1A3: "COM", iso1N3: "174", wikidata: "Q970", nameEn: "Comoros", groups: ["014", "202", "002", "UN"], callingCodes: ["269"] }, geometry: { type: "MultiPolygon", coordinates: [[[[42.63904, -10.02522], [43.28731, -13.97126], [45.4971, -11.75965], [42.63904, -10.02522]]]] } },
22791     { type: "Feature", properties: { iso1A2: "KN", iso1A3: "KNA", iso1N3: "659", wikidata: "Q763", nameEn: "St. Kitts and Nevis", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 869"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.29333, 17.43155], [-62.76692, 17.64353], [-63.09677, 17.21372], [-62.63813, 16.65446], [-62.29333, 17.43155]]]] } },
22792     { type: "Feature", properties: { iso1A2: "KP", iso1A3: "PRK", iso1N3: "408", wikidata: "Q423", nameEn: "North Korea", groups: ["030", "142", "UN"], callingCodes: ["850"] }, geometry: { type: "MultiPolygon", coordinates: [[[[130.26095, 42.9027], [130.09764, 42.91425], [130.12957, 42.98361], [129.96409, 42.97306], [129.95082, 43.01051], [129.8865, 43.00395], [129.85261, 42.96494], [129.83277, 42.86746], [129.80719, 42.79218], [129.7835, 42.76521], [129.77183, 42.69435], [129.75294, 42.59409], [129.72541, 42.43739], [129.60482, 42.44461], [129.54701, 42.37254], [129.42882, 42.44702], [129.28541, 42.41574], [129.22423, 42.3553], [129.22285, 42.26491], [129.15178, 42.17224], [128.96068, 42.06657], [128.94007, 42.03537], [128.04487, 42.01769], [128.15119, 41.74568], [128.30716, 41.60322], [128.20061, 41.40895], [128.18546, 41.41279], [128.12967, 41.37931], [128.03311, 41.39232], [128.02633, 41.42103], [127.92943, 41.44291], [127.29712, 41.49473], [127.17841, 41.59714], [126.90729, 41.79955], [126.60631, 41.65565], [126.53189, 41.35206], [126.242, 41.15454], [126.00335, 40.92835], [125.76869, 40.87908], [125.71172, 40.85223], [124.86913, 40.45387], [124.40719, 40.13655], [124.38556, 40.11047], [124.3322, 40.05573], [124.37089, 40.03004], [124.35029, 39.95639], [124.23201, 39.9248], [124.17532, 39.8232], [123.90497, 38.79949], [123.85601, 37.49093], [124.67666, 38.05679], [124.84224, 37.977], [124.87921, 37.80827], [125.06408, 37.66334], [125.37112, 37.62643], [125.81159, 37.72949], [126.13074, 37.70512], [126.18776, 37.74728], [126.19097, 37.81462], [126.24402, 37.83113], [126.43239, 37.84095], [126.46818, 37.80873], [126.56709, 37.76857], [126.59918, 37.76364], [126.66067, 37.7897], [126.68793, 37.83728], [126.68793, 37.9175], [126.67023, 37.95852], [126.84961, 38.0344], [126.88106, 38.10246], [126.95887, 38.1347], [126.95338, 38.17735], [127.04479, 38.25518], [127.15749, 38.30722], [127.38727, 38.33227], [127.49672, 38.30647], [127.55013, 38.32257], [128.02917, 38.31861], [128.27652, 38.41657], [128.31105, 38.58462], [128.37487, 38.62345], [128.65655, 38.61914], [131.95041, 41.5445], [130.65022, 42.32281], [130.66367, 42.38024], [130.64181, 42.41422], [130.60805, 42.4317], [130.56835, 42.43281], [130.55143, 42.52158], [130.50123, 42.61636], [130.44361, 42.54849], [130.41826, 42.6011], [130.2385, 42.71127], [130.23068, 42.80125], [130.26095, 42.9027]]]] } },
22793     { type: "Feature", properties: { iso1A2: "KR", iso1A3: "KOR", iso1N3: "410", wikidata: "Q884", nameEn: "South Korea", groups: ["030", "142", "UN"], callingCodes: ["82"] }, geometry: { type: "MultiPolygon", coordinates: [[[[133.11729, 37.53115], [128.65655, 38.61914], [128.37487, 38.62345], [128.31105, 38.58462], [128.27652, 38.41657], [128.02917, 38.31861], [127.55013, 38.32257], [127.49672, 38.30647], [127.38727, 38.33227], [127.15749, 38.30722], [127.04479, 38.25518], [126.95338, 38.17735], [126.95887, 38.1347], [126.88106, 38.10246], [126.84961, 38.0344], [126.67023, 37.95852], [126.68793, 37.9175], [126.68793, 37.83728], [126.66067, 37.7897], [126.59918, 37.76364], [126.56709, 37.76857], [126.46818, 37.80873], [126.43239, 37.84095], [126.24402, 37.83113], [126.19097, 37.81462], [126.18776, 37.74728], [126.13074, 37.70512], [125.81159, 37.72949], [125.37112, 37.62643], [125.06408, 37.66334], [124.87921, 37.80827], [124.84224, 37.977], [124.67666, 38.05679], [123.85601, 37.49093], [122.80525, 33.30571], [125.99728, 32.63328], [129.2669, 34.87122], [133.11729, 37.53115]]]] } },
22794     { type: "Feature", properties: { iso1A2: "KW", iso1A3: "KWT", iso1N3: "414", wikidata: "Q817", nameEn: "Kuwait", groups: ["145", "142", "UN"], callingCodes: ["965"] }, geometry: { type: "MultiPolygon", coordinates: [[[[49.00421, 28.81495], [48.59531, 29.66815], [48.40479, 29.85763], [48.17332, 30.02448], [48.06782, 30.02906], [48.01114, 29.98906], [47.7095, 30.10453], [47.37192, 30.10421], [47.15166, 30.01044], [46.89695, 29.50584], [46.5527, 29.10283], [47.46202, 29.0014], [47.58376, 28.83382], [47.59863, 28.66798], [47.70561, 28.5221], [48.42991, 28.53628], [49.00421, 28.81495]]]] } },
22795     { type: "Feature", properties: { iso1A2: "KY", iso1A3: "CYM", iso1N3: "136", wikidata: "Q5785", nameEn: "Cayman Islands", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 345"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-82.11509, 19.60401], [-80.36068, 18.11751], [-79.32727, 20.06742], [-82.11509, 19.60401]]]] } },
22796     { type: "Feature", properties: { iso1A2: "KZ", iso1A3: "KAZ", iso1N3: "398", wikidata: "Q232", nameEn: "Kazakhstan", groups: ["143", "142", "UN"], callingCodes: ["7"] }, geometry: { type: "MultiPolygon", coordinates: [[[[68.90865, 55.38148], [68.19206, 55.18823], [68.26661, 55.09226], [68.21308, 54.98645], [65.20174, 54.55216], [65.24663, 54.35721], [65.11033, 54.33028], [64.97216, 54.4212], [63.97686, 54.29763], [64.02715, 54.22679], [63.91224, 54.20013], [63.80604, 54.27079], [62.58651, 54.05871], [62.56876, 53.94047], [62.45931, 53.90737], [62.38535, 54.03961], [62.00966, 54.04134], [62.03913, 53.94768], [61.65318, 54.02445], [61.56941, 53.95703], [61.47603, 54.08048], [61.3706, 54.08464], [61.26863, 53.92797], [60.99796, 53.93699], [61.14283, 53.90063], [61.22574, 53.80268], [60.90626, 53.62937], [61.55706, 53.57144], [61.57185, 53.50112], [61.37957, 53.45887], [61.29082, 53.50992], [61.14291, 53.41481], [61.19024, 53.30536], [62.14574, 53.09626], [62.12799, 52.99133], [62.0422, 52.96105], [61.23462, 53.03227], [61.05842, 52.92217], [60.71989, 52.75923], [60.71693, 52.66245], [60.84118, 52.63912], [60.84709, 52.52228], [60.98021, 52.50068], [61.05417, 52.35096], [60.78201, 52.22067], [60.72581, 52.15538], [60.48915, 52.15175], [60.19925, 51.99173], [59.99809, 51.98263], [60.09867, 51.87135], [60.50986, 51.7964], [60.36787, 51.66815], [60.5424, 51.61675], [60.92401, 51.61124], [60.95655, 51.48615], [61.50677, 51.40687], [61.55114, 51.32746], [61.6813, 51.25716], [61.56889, 51.23679], [61.4431, 50.80679], [60.81833, 50.6629], [60.31914, 50.67705], [60.17262, 50.83312], [60.01288, 50.8163], [59.81172, 50.54451], [59.51886, 50.49937], [59.48928, 50.64216], [58.87974, 50.70852], [58.3208, 51.15151], [57.75578, 51.13852], [57.74986, 50.93017], [57.44221, 50.88354], [57.17302, 51.11253], [56.17906, 50.93204], [56.11398, 50.7471], [55.67774, 50.54508], [54.72067, 51.03261], [54.56685, 51.01958], [54.71476, 50.61214], [54.55797, 50.52006], [54.41894, 50.61214], [54.46331, 50.85554], [54.12248, 51.11542], [53.69299, 51.23466], [53.46165, 51.49445], [52.54329, 51.48444], [52.36119, 51.74161], [51.8246, 51.67916], [51.77431, 51.49536], [51.301, 51.48799], [51.26254, 51.68466], [50.59695, 51.61859], [50.26859, 51.28677], [49.97277, 51.2405], [49.76866, 51.11067], [49.39001, 51.09396], [49.41959, 50.85927], [49.12673, 50.78639], [48.86936, 50.61589], [48.57946, 50.63278], [48.90782, 50.02281], [48.68352, 49.89546], [48.42564, 49.82283], [48.24519, 49.86099], [48.10044, 50.09242], [47.58551, 50.47867], [47.30448, 50.30894], [47.34589, 50.09308], [47.18319, 49.93721], [46.9078, 49.86707], [46.78398, 49.34026], [47.04658, 49.19834], [47.00857, 49.04921], [46.78392, 48.95352], [46.49011, 48.43019], [47.11516, 48.27188], [47.12107, 47.83687], [47.38731, 47.68176], [47.41689, 47.83687], [47.64973, 47.76559], [48.15348, 47.74545], [48.45173, 47.40818], [48.52326, 47.4102], [49.01136, 46.72716], [48.51142, 46.69268], [48.54988, 46.56267], [49.16518, 46.38542], [49.32259, 46.26944], [49.88945, 46.04554], [49.2134, 44.84989], [52.26048, 41.69249], [52.47884, 41.78034], [52.97575, 42.1308], [54.20635, 42.38477], [54.95182, 41.92424], [55.45471, 41.25609], [56.00314, 41.32584], [55.97584, 44.99322], [55.97584, 44.99328], [55.97584, 44.99338], [55.97584, 44.99343], [55.97584, 44.99348], [55.97584, 44.99353], [55.97584, 44.99359], [55.97584, 44.99369], [55.97584, 44.99374], [55.97584, 44.99384], [55.97584, 44.9939], [55.97584, 44.994], [55.97584, 44.99405], [55.97584, 44.99415], [55.97584, 44.99421], [55.97584, 44.99426], [55.97584, 44.99431], [55.97584, 44.99436], [55.97584, 44.99441], [55.97594, 44.99446], [55.97605, 44.99452], [55.97605, 44.99457], [55.97605, 44.99462], [55.97605, 44.99467], [55.97605, 44.99477], [55.97615, 44.99477], [55.97615, 44.99483], [55.97615, 44.99493], [55.97615, 44.99498], [55.97615, 44.99503], [55.97615, 44.99508], [55.97625, 44.99514], [55.97636, 44.99519], [55.97636, 44.99524], [55.97646, 44.99529], [55.97646, 44.99534], [55.97656, 44.99539], [55.97667, 44.99545], [55.97677, 44.9955], [55.97677, 44.99555], [55.97677, 44.9956], [55.97687, 44.9956], [55.97698, 44.99565], [55.97698, 44.9957], [55.97708, 44.99576], [55.97718, 44.99581], [55.97729, 44.99586], [55.97739, 44.99586], [55.97739, 44.99591], [55.97749, 44.99591], [55.9776, 44.99591], [55.9777, 44.99596], [55.9777, 44.99601], [55.9778, 44.99607], [55.97791, 44.99607], [55.97801, 44.99607], [55.97801, 44.99612], [55.97811, 44.99617], [55.97822, 44.99617], [55.97832, 44.99622], [55.97842, 44.99622], [58.59711, 45.58671], [61.01475, 44.41383], [62.01711, 43.51008], [63.34656, 43.64003], [64.53885, 43.56941], [64.96464, 43.74748], [65.18666, 43.48835], [65.53277, 43.31856], [65.85194, 42.85481], [66.09482, 42.93426], [66.00546, 41.94455], [66.53302, 41.87388], [66.69129, 41.1311], [67.9644, 41.14611], [67.98511, 41.02794], [68.08273, 41.08148], [68.1271, 41.0324], [67.96736, 40.83798], [68.49983, 40.56437], [68.63, 40.59358], [68.58444, 40.91447], [68.49983, 40.99669], [68.62221, 41.03019], [68.65662, 40.93861], [68.73945, 40.96989], [68.7217, 41.05025], [69.01308, 41.22804], [69.05006, 41.36183], [69.15137, 41.43078], [69.17701, 41.43769], [69.18528, 41.45175], [69.20439, 41.45391], [69.22671, 41.46298], [69.23332, 41.45847], [69.25059, 41.46693], [69.29778, 41.43673], [69.35554, 41.47211], [69.37468, 41.46555], [69.45081, 41.46246], [69.39485, 41.51518], [69.45751, 41.56863], [69.49545, 41.545], [70.94483, 42.26238], [70.85973, 42.30188], [70.97717, 42.50147], [71.15232, 42.60486], [71.17807, 42.67381], [71.22785, 42.69248], [71.2724, 42.77853], [71.53272, 42.8014], [71.62405, 42.76613], [71.88792, 42.83578], [73.44393, 42.43098], [73.50992, 42.82356], [73.55634, 43.03071], [74.22489, 43.24657], [74.57491, 43.13702], [74.64615, 43.05881], [74.70331, 43.02519], [74.75, 42.99029], [74.88756, 42.98612], [75.22619, 42.85528], [75.29966, 42.86183], [75.72174, 42.79672], [75.82823, 42.94848], [78.48469, 42.89649], [78.91502, 42.76839], [79.19763, 42.804], [79.52921, 42.44778], [79.97364, 42.42816], [80.17807, 42.21166], [80.26841, 42.23797], [80.16892, 42.61137], [80.26886, 42.8366], [80.38169, 42.83142], [80.58999, 42.9011], [80.3735, 43.01557], [80.62913, 43.141], [80.78817, 43.14235], [80.77771, 43.30065], [80.69718, 43.32589], [80.75156, 43.44948], [80.40031, 44.10986], [80.40229, 44.23319], [80.38384, 44.63073], [79.8987, 44.89957], [80.11169, 45.03352], [81.73278, 45.3504], [82.51374, 45.1755], [82.58474, 45.40027], [82.21792, 45.56619], [83.04622, 47.19053], [83.92184, 46.98912], [84.73077, 47.01394], [84.93995, 46.87399], [85.22443, 47.04816], [85.54294, 47.06171], [85.69696, 47.2898], [85.61067, 47.49753], [85.5169, 48.05493], [85.73581, 48.3939], [86.38069, 48.46064], [86.75343, 48.70331], [86.73568, 48.99918], [86.87238, 49.12432], [87.28386, 49.11626], [87.31465, 49.23603], [87.03071, 49.25142], [86.82606, 49.51796], [86.61307, 49.60239], [86.79056, 49.74787], [86.63674, 49.80136], [86.18709, 49.50259], [85.24047, 49.60239], [84.99198, 50.06793], [84.29385, 50.27257], [83.8442, 50.87375], [83.14607, 51.00796], [82.55443, 50.75412], [81.94999, 50.79307], [81.46581, 50.77658], [81.41248, 50.97524], [81.06091, 50.94833], [81.16999, 51.15662], [80.80318, 51.28262], [80.44819, 51.20855], [80.4127, 50.95581], [80.08138, 50.77658], [79.11255, 52.01171], [77.90383, 53.29807], [76.54243, 53.99329], [76.44076, 54.16017], [76.82266, 54.1798], [76.91052, 54.4677], [75.3668, 54.07439], [75.43398, 53.98652], [75.07405, 53.80831], [73.39218, 53.44623], [73.25412, 53.61532], [73.68921, 53.86522], [73.74778, 54.07194], [73.37963, 53.96132], [72.71026, 54.1161], [72.43415, 53.92685], [72.17477, 54.36303], [71.96141, 54.17736], [71.10379, 54.13326], [71.08706, 54.33376], [71.24185, 54.64965], [71.08288, 54.71253], [70.96009, 55.10558], [70.76493, 55.3027], [70.19179, 55.1476], [69.74917, 55.35545], [69.34224, 55.36344], [68.90865, 55.38148]]]] } },
22797     { type: "Feature", properties: { iso1A2: "LA", iso1A3: "LAO", iso1N3: "418", wikidata: "Q819", nameEn: "Laos", groups: ["035", "142", "UN"], callingCodes: ["856"] }, geometry: { type: "MultiPolygon", coordinates: [[[[102.1245, 22.43372], [102.03633, 22.46164], [101.98487, 22.42766], [101.91344, 22.44417], [101.90714, 22.38688], [101.86828, 22.38397], [101.7685, 22.50337], [101.68973, 22.46843], [101.61306, 22.27515], [101.56789, 22.28876], [101.53638, 22.24794], [101.60675, 22.13513], [101.57525, 22.13026], [101.62566, 21.96574], [101.7791, 21.83019], [101.74555, 21.72852], [101.83257, 21.61562], [101.80001, 21.57461], [101.7475, 21.5873], [101.7727, 21.51794], [101.74224, 21.48276], [101.74014, 21.30967], [101.84412, 21.25291], [101.83887, 21.20983], [101.76745, 21.21571], [101.79266, 21.19025], [101.7622, 21.14813], [101.70548, 21.14911], [101.66977, 21.20004], [101.60886, 21.17947], [101.59491, 21.18621], [101.6068, 21.23329], [101.54563, 21.25668], [101.29326, 21.17254], [101.2229, 21.23271], [101.26912, 21.36482], [101.19349, 21.41959], [101.2124, 21.56422], [101.15156, 21.56129], [101.16198, 21.52808], [101.00234, 21.39612], [100.80173, 21.2934], [100.72716, 21.31786], [100.63578, 21.05639], [100.55281, 21.02796], [100.50974, 20.88574], [100.64628, 20.88279], [100.60112, 20.8347], [100.51079, 20.82194], [100.36375, 20.82783], [100.1957, 20.68247], [100.08404, 20.36626], [100.09999, 20.31614], [100.09337, 20.26293], [100.11785, 20.24787], [100.1712, 20.24324], [100.16668, 20.2986], [100.22076, 20.31598], [100.25769, 20.3992], [100.33383, 20.4028], [100.37439, 20.35156], [100.41473, 20.25625], [100.44992, 20.23644], [100.4537, 20.19971], [100.47567, 20.19133], [100.51052, 20.14928], [100.55218, 20.17741], [100.58808, 20.15791], [100.5094, 19.87904], [100.398, 19.75047], [100.49604, 19.53504], [100.58219, 19.49164], [100.64606, 19.55884], [100.77231, 19.48324], [100.90302, 19.61901], [101.08928, 19.59748], [101.26545, 19.59242], [101.26991, 19.48324], [101.21347, 19.46223], [101.20604, 19.35296], [101.24911, 19.33334], [101.261, 19.12717], [101.35606, 19.04716], [101.25803, 18.89545], [101.22832, 18.73377], [101.27585, 18.68875], [101.06047, 18.43247], [101.18227, 18.34367], [101.15108, 18.25624], [101.19118, 18.2125], [101.1793, 18.0544], [101.02185, 17.87637], [100.96541, 17.57926], [101.15108, 17.47586], [101.44667, 17.7392], [101.72294, 17.92867], [101.78087, 18.07559], [101.88485, 18.02474], [102.11359, 18.21532], [102.45523, 17.97106], [102.59234, 17.96127], [102.60971, 17.95411], [102.61432, 17.92273], [102.5896, 17.84889], [102.59485, 17.83537], [102.68194, 17.80151], [102.69946, 17.81686], [102.67543, 17.84529], [102.68538, 17.86653], [102.75954, 17.89561], [102.79044, 17.93612], [102.81988, 17.94233], [102.86323, 17.97531], [102.95812, 18.0054], [102.9912, 17.9949], [103.01998, 17.97095], [103.0566, 18.00144], [103.07823, 18.03833], [103.07343, 18.12351], [103.1493, 18.17799], [103.14994, 18.23172], [103.17093, 18.2618], [103.29757, 18.30475], [103.23818, 18.34875], [103.24779, 18.37807], [103.30977, 18.4341], [103.41044, 18.4486], [103.47773, 18.42841], [103.60957, 18.40528], [103.699, 18.34125], [103.82449, 18.33979], [103.85642, 18.28666], [103.93916, 18.33914], [103.97725, 18.33631], [104.06533, 18.21656], [104.10927, 18.10826], [104.21776, 17.99335], [104.2757, 17.86139], [104.35432, 17.82871], [104.45404, 17.66788], [104.69867, 17.53038], [104.80061, 17.39367], [104.80716, 17.19025], [104.73712, 17.01404], [104.7373, 16.91125], [104.76442, 16.84752], [104.7397, 16.81005], [104.76099, 16.69302], [104.73349, 16.565], [104.88057, 16.37311], [105.00262, 16.25627], [105.06204, 16.09792], [105.42001, 16.00657], [105.38508, 15.987], [105.34115, 15.92737], [105.37959, 15.84074], [105.42285, 15.76971], [105.46573, 15.74742], [105.61756, 15.68792], [105.60446, 15.53301], [105.58191, 15.41031], [105.47635, 15.3796], [105.4692, 15.33709], [105.50662, 15.32054], [105.58043, 15.32724], [105.46661, 15.13132], [105.61162, 15.00037], [105.5121, 14.80802], [105.53864, 14.55731], [105.43783, 14.43865], [105.20894, 14.34967], [105.2759, 14.17496], [105.36775, 14.09948], [105.44869, 14.10703], [105.5561, 14.15684], [105.78338, 14.08438], [105.78182, 14.02247], [105.90791, 13.92881], [106.10405, 13.9137], [106.10094, 13.98471], [106.16632, 14.01794], [106.18656, 14.06324], [106.11962, 14.11307], [106.10872, 14.18401], [106.04801, 14.20363], [106.02311, 14.30623], [105.99509, 14.32734], [106.00131, 14.36957], [106.21302, 14.36203], [106.25194, 14.48415], [106.32355, 14.44043], [106.40916, 14.45249], [106.43874, 14.52032], [106.47766, 14.50977], [106.45898, 14.55045], [106.50723, 14.58963], [106.54148, 14.59565], [106.57106, 14.50525], [106.59908, 14.50977], [106.63333, 14.44194], [106.73762, 14.42687], [106.80767, 14.31226], [106.8497, 14.29416], [106.90574, 14.33639], [106.9649, 14.3198], [106.98825, 14.36806], [107.04585, 14.41782], [107.03962, 14.45099], [107.09722, 14.3937], [107.17038, 14.41782], [107.21241, 14.48716], [107.256, 14.48716], [107.26534, 14.54292], [107.29803, 14.58963], [107.3276, 14.58812], [107.37897, 14.54443], [107.44435, 14.52785], [107.47238, 14.61523], [107.54361, 14.69092], [107.51579, 14.79282], [107.59285, 14.87795], [107.48277, 14.93751], [107.46516, 15.00982], [107.61486, 15.0566], [107.61926, 15.13949], [107.58844, 15.20111], [107.62587, 15.2266], [107.60605, 15.37524], [107.62367, 15.42193], [107.53341, 15.40496], [107.50699, 15.48771], [107.3815, 15.49832], [107.34408, 15.62345], [107.27583, 15.62769], [107.27143, 15.71459], [107.21859, 15.74638], [107.21419, 15.83747], [107.34188, 15.89464], [107.39471, 15.88829], [107.46296, 16.01106], [107.44975, 16.08511], [107.33968, 16.05549], [107.25822, 16.13587], [107.14595, 16.17816], [107.15035, 16.26271], [107.09091, 16.3092], [107.02597, 16.31132], [106.97385, 16.30204], [106.96638, 16.34938], [106.88067, 16.43594], [106.88727, 16.52671], [106.84104, 16.55415], [106.74418, 16.41904], [106.65832, 16.47816], [106.66052, 16.56892], [106.61477, 16.60713], [106.58267, 16.6012], [106.59013, 16.62259], [106.55485, 16.68704], [106.55265, 16.86831], [106.52183, 16.87884], [106.51963, 16.92097], [106.54824, 16.92729], [106.55045, 17.0031], [106.50862, 16.9673], [106.43597, 17.01362], [106.31929, 17.20509], [106.29287, 17.3018], [106.24444, 17.24714], [106.18991, 17.28227], [106.09019, 17.36399], [105.85744, 17.63221], [105.76612, 17.67147], [105.60381, 17.89356], [105.64784, 17.96687], [105.46292, 18.22008], [105.38366, 18.15315], [105.15942, 18.38691], [105.10408, 18.43533], [105.1327, 18.58355], [105.19654, 18.64196], [105.12829, 18.70453], [104.64617, 18.85668], [104.5361, 18.97747], [103.87125, 19.31854], [104.06058, 19.43484], [104.10832, 19.51575], [104.05617, 19.61743], [104.06498, 19.66926], [104.23229, 19.70242], [104.41281, 19.70035], [104.53169, 19.61743], [104.64837, 19.62365], [104.68359, 19.72729], [104.8355, 19.80395], [104.8465, 19.91783], [104.9874, 20.09573], [104.91695, 20.15567], [104.86852, 20.14121], [104.61315, 20.24452], [104.62195, 20.36633], [104.72102, 20.40554], [104.66158, 20.47774], [104.47886, 20.37459], [104.40621, 20.3849], [104.38199, 20.47155], [104.63957, 20.6653], [104.27412, 20.91433], [104.11121, 20.96779], [103.98024, 20.91531], [103.82282, 20.8732], [103.73478, 20.6669], [103.68633, 20.66324], [103.45737, 20.82382], [103.38032, 20.79501], [103.21497, 20.89832], [103.12055, 20.89994], [103.03469, 21.05821], [102.97745, 21.05821], [102.89825, 21.24707], [102.80794, 21.25736], [102.88939, 21.3107], [102.94223, 21.46034], [102.86297, 21.4255], [102.98846, 21.58936], [102.97965, 21.74076], [102.86077, 21.71213], [102.85637, 21.84501], [102.81894, 21.83888], [102.82115, 21.73667], [102.74189, 21.66713], [102.67145, 21.65894], [102.62301, 21.91447], [102.49092, 21.99002], [102.51734, 22.02676], [102.18712, 22.30403], [102.14099, 22.40092], [102.1245, 22.43372]]]] } },
22798     { type: "Feature", properties: { iso1A2: "LB", iso1A3: "LBN", iso1N3: "422", wikidata: "Q822", nameEn: "Lebanon", aliases: ["RL"], groups: ["145", "142", "UN"], callingCodes: ["961"] }, geometry: { type: "MultiPolygon", coordinates: [[[[35.94816, 33.47886], [35.94465, 33.52774], [36.05723, 33.57904], [35.9341, 33.6596], [36.06778, 33.82927], [36.14517, 33.85118], [36.3967, 33.83365], [36.38263, 33.86579], [36.28589, 33.91981], [36.41078, 34.05253], [36.50576, 34.05982], [36.5128, 34.09916], [36.62537, 34.20251], [36.59195, 34.2316], [36.58667, 34.27667], [36.60778, 34.31009], [36.56556, 34.31881], [36.53039, 34.3798], [36.55853, 34.41609], [36.46179, 34.46541], [36.4442, 34.50165], [36.34745, 34.5002], [36.3369, 34.52629], [36.39846, 34.55672], [36.41429, 34.61175], [36.45299, 34.59438], [36.46003, 34.6378], [36.42941, 34.62505], [36.35384, 34.65447], [36.35135, 34.68516], [36.32399, 34.69334], [36.29165, 34.62991], [35.98718, 34.64977], [35.97386, 34.63322], [35.48515, 34.70851], [34.78515, 33.20368], [35.10645, 33.09318], [35.1924, 33.08743], [35.31429, 33.10515], [35.35223, 33.05617], [35.43059, 33.06659], [35.448, 33.09264], [35.50272, 33.09056], [35.50335, 33.114], [35.52573, 33.11921], [35.54228, 33.19865], [35.5362, 33.23196], [35.54808, 33.236], [35.54544, 33.25513], [35.55555, 33.25844], [35.56523, 33.28969], [35.58326, 33.28381], [35.58502, 33.26653], [35.62283, 33.24226], [35.62019, 33.27278], [35.77477, 33.33609], [35.81324, 33.36354], [35.82577, 33.40479], [35.88668, 33.43183], [35.94816, 33.47886]]]] } },
22799     { type: "Feature", properties: { iso1A2: "LC", iso1A3: "LCA", iso1N3: "662", wikidata: "Q760", nameEn: "St. Lucia", aliases: ["WL"], groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 758"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-59.95997, 14.20285], [-61.69315, 14.26451], [-59.94058, 12.34011], [-59.95997, 14.20285]]]] } },
22800     { type: "Feature", properties: { iso1A2: "LI", iso1A3: "LIE", iso1N3: "438", wikidata: "Q347", nameEn: "Liechtenstein", aliases: ["FL"], groups: ["155", "150", "UN"], callingCodes: ["423"] }, geometry: { type: "MultiPolygon", coordinates: [[[[9.60717, 47.06091], [9.61216, 47.07732], [9.63395, 47.08443], [9.62623, 47.14685], [9.56539, 47.17124], [9.58264, 47.20673], [9.56981, 47.21926], [9.55176, 47.22585], [9.56766, 47.24281], [9.53116, 47.27029], [9.52406, 47.24959], [9.50318, 47.22153], [9.4891, 47.19346], [9.48774, 47.17402], [9.51044, 47.13727], [9.52089, 47.10019], [9.51362, 47.08505], [9.47139, 47.06402], [9.47548, 47.05257], [9.54041, 47.06495], [9.55721, 47.04762], [9.60717, 47.06091]]]] } },
22801     { type: "Feature", properties: { iso1A2: "LK", iso1A3: "LKA", iso1N3: "144", wikidata: "Q854", nameEn: "Sri Lanka", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["94"] }, geometry: { type: "MultiPolygon", coordinates: [[[[76.59015, 5.591], [85.15017, 5.21497], [80.48418, 10.20786], [79.42124, 9.80115], [79.50447, 8.91876], [76.59015, 5.591]]]] } },
22802     { type: "Feature", properties: { iso1A2: "LR", iso1A3: "LBR", iso1N3: "430", wikidata: "Q1014", nameEn: "Liberia", groups: ["011", "202", "002", "UN"], callingCodes: ["231"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-8.47114, 7.55676], [-8.55874, 7.62525], [-8.55874, 7.70167], [-8.67814, 7.69428], [-8.72789, 7.51429], [-8.8448, 7.35149], [-8.85724, 7.26019], [-8.93435, 7.2824], [-9.09107, 7.1985], [-9.18311, 7.30461], [-9.20798, 7.38109], [-9.305, 7.42056], [-9.41943, 7.41809], [-9.48161, 7.37122], [-9.37465, 7.62032], [-9.35724, 7.74111], [-9.44928, 7.9284], [-9.41445, 8.02448], [-9.50898, 8.18455], [-9.47415, 8.35195], [-9.77763, 8.54633], [-10.05873, 8.42578], [-10.05375, 8.50697], [-10.14579, 8.52665], [-10.203, 8.47991], [-10.27575, 8.48711], [-10.30084, 8.30008], [-10.31635, 8.28554], [-10.29839, 8.21283], [-10.35227, 8.15223], [-10.45023, 8.15627], [-10.51554, 8.1393], [-10.57523, 8.04829], [-10.60492, 8.04072], [-10.60422, 7.7739], [-11.29417, 7.21576], [-11.4027, 6.97746], [-11.50429, 6.92704], [-12.15048, 6.15992], [-7.52774, 3.7105], [-7.53259, 4.35145], [-7.59349, 4.8909], [-7.53876, 4.94294], [-7.55369, 5.08667], [-7.48901, 5.14118], [-7.46165, 5.26256], [-7.36463, 5.32944], [-7.43428, 5.42355], [-7.37209, 5.61173], [-7.43926, 5.74787], [-7.43677, 5.84687], [-7.46165, 5.84934], [-7.48155, 5.80974], [-7.67309, 5.94337], [-7.70294, 5.90625], [-7.78254, 5.99037], [-7.79747, 6.07696], [-7.8497, 6.08932], [-7.83478, 6.20309], [-7.90692, 6.27728], [-8.00642, 6.31684], [-8.17557, 6.28222], [-8.3298, 6.36381], [-8.38453, 6.35887], [-8.45666, 6.49977], [-8.48652, 6.43797], [-8.59456, 6.50612], [-8.31736, 6.82837], [-8.29249, 7.1691], [-8.37458, 7.25794], [-8.41935, 7.51203], [-8.47114, 7.55676]]]] } },
22803     { type: "Feature", properties: { iso1A2: "LS", iso1A3: "LSO", iso1N3: "426", wikidata: "Q1013", nameEn: "Lesotho", groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["266"] }, geometry: { type: "MultiPolygon", coordinates: [[[[29.33204, -29.45598], [29.44883, -29.3772], [29.40524, -29.21246], [28.68043, -28.58744], [28.65091, -28.57025], [28.40612, -28.6215], [28.30518, -28.69531], [28.2348, -28.69471], [28.1317, -28.7293], [28.02503, -28.85991], [27.98675, -28.8787], [27.9392, -28.84864], [27.88933, -28.88156], [27.8907, -28.91612], [27.75458, -28.89839], [27.55974, -29.18954], [27.5158, -29.2261], [27.54258, -29.25575], [27.48679, -29.29349], [27.45125, -29.29708], [27.47254, -29.31968], [27.4358, -29.33465], [27.33464, -29.48161], [27.01016, -29.65439], [27.09489, -29.72796], [27.22719, -30.00718], [27.29603, -30.05473], [27.32555, -30.14785], [27.40778, -30.14577], [27.37293, -30.19401], [27.36649, -30.27246], [27.38108, -30.33456], [27.45452, -30.32239], [27.56901, -30.42504], [27.56781, -30.44562], [27.62137, -30.50509], [27.6521, -30.51707], [27.67819, -30.53437], [27.69467, -30.55862], [27.74814, -30.60635], [28.12073, -30.68072], [28.2319, -30.28476], [28.399, -30.1592], [28.68627, -30.12885], [28.80222, -30.10579], [28.9338, -30.05072], [29.16548, -29.91706], [29.12553, -29.76266], [29.28545, -29.58456], [29.33204, -29.45598]]]] } },
22804     { type: "Feature", properties: { iso1A2: "LT", iso1A3: "LTU", iso1N3: "440", wikidata: "Q37", nameEn: "Lithuania", groups: ["EU", "154", "150", "UN"], callingCodes: ["370"] }, geometry: { type: "MultiPolygon", coordinates: [[[[24.89005, 56.46666], [24.83686, 56.41565], [24.70022, 56.40483], [24.57353, 56.31525], [24.58143, 56.29125], [24.42746, 56.26522], [24.32334, 56.30226], [24.13139, 56.24881], [24.02657, 56.3231], [23.75726, 56.37282], [23.49803, 56.34307], [23.40486, 56.37689], [23.31606, 56.3827], [23.17312, 56.36795], [23.09531, 56.30511], [22.96988, 56.41213], [22.83048, 56.367], [22.69354, 56.36284], [22.56441, 56.39305], [22.3361, 56.4016], [22.09728, 56.42851], [22.00548, 56.41508], [21.74558, 56.33181], [21.57888, 56.31406], [21.49736, 56.29106], [21.24644, 56.16917], [21.15016, 56.07818], [20.68447, 56.04073], [20.60454, 55.40986], [20.95181, 55.27994], [21.26425, 55.24456], [21.35465, 55.28427], [21.38446, 55.29348], [21.46766, 55.21115], [21.51095, 55.18507], [21.55605, 55.20311], [21.64954, 55.1791], [21.85521, 55.09493], [21.96505, 55.07353], [21.99543, 55.08691], [22.03984, 55.07888], [22.02582, 55.05078], [22.06087, 55.02935], [22.11697, 55.02131], [22.14267, 55.05345], [22.31562, 55.0655], [22.47688, 55.04408], [22.58907, 55.07085], [22.60075, 55.01863], [22.65451, 54.97037], [22.68723, 54.9811], [22.76422, 54.92521], [22.85083, 54.88711], [22.87317, 54.79492], [22.73631, 54.72952], [22.73397, 54.66604], [22.75467, 54.6483], [22.74225, 54.64339], [22.7522, 54.63525], [22.68021, 54.58486], [22.71293, 54.56454], [22.67788, 54.532], [22.70208, 54.45312], [22.7253, 54.41732], [22.79705, 54.36264], [22.83756, 54.40827], [23.00584, 54.38514], [22.99649, 54.35927], [23.05726, 54.34565], [23.04323, 54.31567], [23.104, 54.29794], [23.13905, 54.31567], [23.15526, 54.31076], [23.15938, 54.29894], [23.24656, 54.25701], [23.3494, 54.25155], [23.39525, 54.21672], [23.42418, 54.17911], [23.45223, 54.17775], [23.49196, 54.14764], [23.52702, 54.04622], [23.48261, 53.98855], [23.51284, 53.95052], [23.61677, 53.92691], [23.71726, 53.93379], [23.80543, 53.89558], [23.81309, 53.94205], [23.95098, 53.9613], [23.98837, 53.92554], [24.19638, 53.96405], [24.34128, 53.90076], [24.44411, 53.90076], [24.62275, 54.00217], [24.69652, 54.01901], [24.69185, 53.96543], [24.74279, 53.96663], [24.85311, 54.02862], [24.77131, 54.11091], [24.96894, 54.17589], [24.991, 54.14241], [25.0728, 54.13419], [25.19199, 54.219], [25.22705, 54.26271], [25.35559, 54.26544], [25.509, 54.30267], [25.56823, 54.25212], [25.51452, 54.17799], [25.54724, 54.14925], [25.64875, 54.1259], [25.71084, 54.16704], [25.78563, 54.15747], [25.78553, 54.23327], [25.68513, 54.31727], [25.55425, 54.31591], [25.5376, 54.33158], [25.63371, 54.42075], [25.62203, 54.4656], [25.64813, 54.48704], [25.68045, 54.5321], [25.75977, 54.57252], [25.74122, 54.80108], [25.89462, 54.93438], [25.99129, 54.95705], [26.05907, 54.94631], [26.13386, 54.98924], [26.20397, 54.99729], [26.26941, 55.08032], [26.23202, 55.10439], [26.30628, 55.12536], [26.35121, 55.1525], [26.46249, 55.12814], [26.51481, 55.16051], [26.54753, 55.14181], [26.69243, 55.16718], [26.68075, 55.19787], [26.72983, 55.21788], [26.73017, 55.24226], [26.835, 55.28182], [26.83266, 55.30444], [26.80929, 55.31642], [26.6714, 55.33902], [26.5709, 55.32572], [26.44937, 55.34832], [26.5522, 55.40277], [26.55094, 55.5093], [26.63167, 55.57887], [26.63231, 55.67968], [26.58248, 55.6754], [26.46661, 55.70375], [26.39561, 55.71156], [26.18509, 55.86813], [26.03815, 55.95884], [25.90047, 56.0013], [25.85893, 56.00188], [25.81773, 56.05444], [25.69246, 56.08892], [25.68588, 56.14725], [25.53621, 56.16663], [25.39751, 56.15707], [25.23099, 56.19147], [25.09325, 56.1878], [25.05762, 56.26742], [24.89005, 56.46666]]]] } },
22805     { type: "Feature", properties: { iso1A2: "LU", iso1A3: "LUX", iso1N3: "442", wikidata: "Q32", nameEn: "Luxembourg", groups: ["EU", "155", "150", "UN"], callingCodes: ["352"] }, geometry: { type: "MultiPolygon", coordinates: [[[[6.1379, 50.12964], [6.1137, 50.13668], [6.12028, 50.16374], [6.08577, 50.17246], [6.06406, 50.15344], [6.03093, 50.16362], [6.02488, 50.18283], [5.96453, 50.17259], [5.95929, 50.13295], [5.89488, 50.11476], [5.8857, 50.07824], [5.85474, 50.06342], [5.86904, 50.04614], [5.8551, 50.02683], [5.81866, 50.01286], [5.82331, 49.99662], [5.83968, 49.9892], [5.83467, 49.97823], [5.81163, 49.97142], [5.80833, 49.96451], [5.77291, 49.96056], [5.77314, 49.93646], [5.73621, 49.89796], [5.78415, 49.87922], [5.75269, 49.8711], [5.75861, 49.85631], [5.74567, 49.85368], [5.75884, 49.84811], [5.74953, 49.84709], [5.74975, 49.83933], [5.74076, 49.83823], [5.7404, 49.83452], [5.74844, 49.82435], [5.74364, 49.82058], [5.74953, 49.81428], [5.75409, 49.79239], [5.78871, 49.7962], [5.82245, 49.75048], [5.83149, 49.74729], [5.82562, 49.72395], [5.84193, 49.72161], [5.86503, 49.72739], [5.88677, 49.70951], [5.86527, 49.69291], [5.86175, 49.67862], [5.9069, 49.66377], [5.90164, 49.6511], [5.90599, 49.63853], [5.88552, 49.63507], [5.88393, 49.62802], [5.87609, 49.62047], [5.8762, 49.60898], [5.84826, 49.5969], [5.84971, 49.58674], [5.86986, 49.58756], [5.87256, 49.57539], [5.8424, 49.56082], [5.84692, 49.55663], [5.84143, 49.5533], [5.81838, 49.54777], [5.80871, 49.5425], [5.81664, 49.53775], [5.83648, 49.5425], [5.84466, 49.53027], [5.83467, 49.52717], [5.83389, 49.52152], [5.86571, 49.50015], [5.94128, 49.50034], [5.94224, 49.49608], [5.96876, 49.49053], [5.97693, 49.45513], [6.02648, 49.45451], [6.02743, 49.44845], [6.04176, 49.44801], [6.05553, 49.46663], [6.07887, 49.46399], [6.08373, 49.45594], [6.10072, 49.45268], [6.09845, 49.46351], [6.10325, 49.4707], [6.12346, 49.4735], [6.12814, 49.49365], [6.14321, 49.48796], [6.16115, 49.49297], [6.15366, 49.50226], [6.17386, 49.50934], [6.19543, 49.50536], [6.2409, 49.51408], [6.25029, 49.50609], [6.27875, 49.503], [6.28818, 49.48465], [6.3687, 49.4593], [6.36778, 49.46937], [6.36907, 49.48931], [6.36788, 49.50377], [6.35666, 49.52931], [6.38072, 49.55171], [6.38228, 49.55855], [6.35825, 49.57053], [6.36676, 49.57813], [6.38024, 49.57593], [6.38342, 49.5799], [6.37464, 49.58886], [6.385, 49.59946], [6.39822, 49.60081], [6.41861, 49.61723], [6.4413, 49.65722], [6.43768, 49.66021], [6.42726, 49.66078], [6.42937, 49.66857], [6.44654, 49.67799], [6.46048, 49.69092], [6.48014, 49.69767], [6.49785, 49.71118], [6.50647, 49.71353], [6.5042, 49.71808], [6.49694, 49.72205], [6.49535, 49.72645], [6.50261, 49.72718], [6.51397, 49.72058], [6.51805, 49.72425], [6.50193, 49.73291], [6.50174, 49.75292], [6.51646, 49.75961], [6.51828, 49.76855], [6.51056, 49.77515], [6.51669, 49.78336], [6.50534, 49.78952], [6.52169, 49.79787], [6.53122, 49.80666], [6.52121, 49.81338], [6.51215, 49.80124], [6.50647, 49.80916], [6.48718, 49.81267], [6.47111, 49.82263], [6.45425, 49.81164], [6.44131, 49.81443], [6.42905, 49.81091], [6.42521, 49.81591], [6.40022, 49.82029], [6.36576, 49.85032], [6.34267, 49.84974], [6.33585, 49.83785], [6.32098, 49.83728], [6.32303, 49.85133], [6.30963, 49.87021], [6.29692, 49.86685], [6.28874, 49.87592], [6.26146, 49.88203], [6.23496, 49.89972], [6.22926, 49.92096], [6.21882, 49.92403], [6.22608, 49.929], [6.22094, 49.94955], [6.19856, 49.95053], [6.19089, 49.96991], [6.18045, 49.96611], [6.18554, 49.95622], [6.17872, 49.9537], [6.16466, 49.97086], [6.1701, 49.98518], [6.14147, 49.99563], [6.14948, 50.00908], [6.13806, 50.01056], [6.1295, 50.01849], [6.13273, 50.02019], [6.13794, 50.01466], [6.14666, 50.02207], [6.13044, 50.02929], [6.13458, 50.04141], [6.11274, 50.05916], [6.12055, 50.09171], [6.1379, 50.12964]]]] } },
22806     { type: "Feature", properties: { iso1A2: "LV", iso1A3: "LVA", iso1N3: "428", wikidata: "Q211", nameEn: "Latvia", groups: ["EU", "154", "150", "UN"], callingCodes: ["371"] }, geometry: { type: "MultiPolygon", coordinates: [[[[27.34698, 57.52242], [26.90364, 57.62823], [26.54675, 57.51813], [26.46527, 57.56885], [26.29253, 57.59244], [26.1866, 57.6849], [26.2029, 57.7206], [26.08098, 57.76619], [26.0543, 57.76105], [26.03332, 57.7718], [26.02415, 57.76865], [26.02069, 57.77169], [26.0266, 57.77441], [26.027, 57.78158], [26.02456, 57.78342], [26.0324, 57.79037], [26.05949, 57.84744], [25.73499, 57.90193], [25.29581, 58.08288], [25.28237, 57.98539], [25.19484, 58.0831], [24.3579, 57.87471], [24.26221, 57.91787], [23.20055, 57.56697], [22.80496, 57.87798], [19.84909, 57.57876], [19.64795, 57.06466], [20.68447, 56.04073], [21.15016, 56.07818], [21.24644, 56.16917], [21.49736, 56.29106], [21.57888, 56.31406], [21.74558, 56.33181], [22.00548, 56.41508], [22.09728, 56.42851], [22.3361, 56.4016], [22.56441, 56.39305], [22.69354, 56.36284], [22.83048, 56.367], [22.96988, 56.41213], [23.09531, 56.30511], [23.17312, 56.36795], [23.31606, 56.3827], [23.40486, 56.37689], [23.49803, 56.34307], [23.75726, 56.37282], [24.02657, 56.3231], [24.13139, 56.24881], [24.32334, 56.30226], [24.42746, 56.26522], [24.58143, 56.29125], [24.57353, 56.31525], [24.70022, 56.40483], [24.83686, 56.41565], [24.89005, 56.46666], [25.05762, 56.26742], [25.09325, 56.1878], [25.23099, 56.19147], [25.39751, 56.15707], [25.53621, 56.16663], [25.68588, 56.14725], [25.69246, 56.08892], [25.81773, 56.05444], [25.85893, 56.00188], [25.90047, 56.0013], [26.03815, 55.95884], [26.18509, 55.86813], [26.39561, 55.71156], [26.46661, 55.70375], [26.58248, 55.6754], [26.63231, 55.67968], [26.64888, 55.70515], [26.71802, 55.70645], [26.76872, 55.67658], [26.87448, 55.7172], [26.97153, 55.8102], [27.1559, 55.85032], [27.27804, 55.78299], [27.3541, 55.8089], [27.61683, 55.78558], [27.63065, 55.89687], [27.97865, 56.11849], [28.15217, 56.16964], [28.23716, 56.27588], [28.16599, 56.37806], [28.19057, 56.44637], [28.10069, 56.524], [28.13526, 56.57989], [28.04768, 56.59004], [27.86101, 56.88204], [27.66511, 56.83921], [27.86101, 57.29402], [27.52453, 57.42826], [27.56832, 57.53728], [27.34698, 57.52242]]]] } },
22807     { type: "Feature", properties: { iso1A2: "LY", iso1A3: "LBY", iso1N3: "434", wikidata: "Q1016", nameEn: "Libya", groups: ["015", "002", "UN"], callingCodes: ["218"] }, geometry: { type: "MultiPolygon", coordinates: [[[[26.92891, 33.39516], [11.58941, 33.36891], [11.55852, 33.1409], [11.51549, 33.09826], [11.46037, 32.6307], [11.57828, 32.48013], [11.53898, 32.4138], [11.04234, 32.2145], [10.7315, 31.97235], [10.62788, 31.96629], [10.48497, 31.72956], [10.31364, 31.72648], [10.12239, 31.42098], [10.29516, 30.90337], [9.88152, 30.34074], [9.76848, 30.34366], [9.55544, 30.23971], [9.3876, 30.16738], [9.78136, 29.40961], [9.89569, 26.57696], [9.51696, 26.39148], [9.38834, 26.19288], [10.03146, 25.35635], [10.02432, 24.98124], [10.33159, 24.5465], [10.85323, 24.5595], [11.41061, 24.21456], [11.62498, 24.26669], [11.96886, 23.51735], [13.5631, 23.16574], [14.22918, 22.61719], [14.99751, 23.00539], [15.99566, 23.49639], [23.99539, 19.49944], [23.99715, 20.00038], [24.99794, 19.99661], [24.99885, 21.99535], [24.99968, 29.24574], [24.71117, 30.17441], [25.01077, 30.73861], [24.8458, 31.39877], [26.92891, 33.39516]]]] } },
22808     { type: "Feature", properties: { iso1A2: "MA", iso1A3: "MAR", iso1N3: "504", wikidata: "Q1028", nameEn: "Morocco", groups: ["015", "002", "UN"], callingCodes: ["212"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-2.27707, 35.35051], [-5.10878, 36.05227], [-7.2725, 35.73269], [-14.43883, 27.02969], [-17.27295, 21.93519], [-17.21511, 21.34226], [-17.02707, 21.34022], [-16.9978, 21.36239], [-16.44269, 21.39745], [-14.78487, 21.36587], [-14.47329, 21.63839], [-14.48112, 22.00886], [-14.1291, 22.41636], [-14.10361, 22.75501], [-13.75627, 23.77231], [-13.00628, 24.01923], [-12.92147, 24.39502], [-12.12281, 25.13682], [-12.06001, 26.04442], [-11.62052, 26.05229], [-11.38635, 26.611], [-11.23622, 26.72023], [-11.35695, 26.8505], [-10.68417, 26.90984], [-9.81998, 26.71379], [-9.56957, 26.90042], [-9.08698, 26.98639], [-8.71787, 26.9898], [-8.77527, 27.66663], [-8.66879, 27.6666], [-8.6715, 28.71194], [-7.61585, 29.36252], [-6.95824, 29.50924], [-6.78351, 29.44634], [-6.69965, 29.51623], [-5.75616, 29.61407], [-5.72121, 29.52322], [-5.58831, 29.48103], [-5.21671, 29.95253], [-4.6058, 30.28343], [-4.31774, 30.53229], [-3.64735, 30.67539], [-3.65418, 30.85566], [-3.54944, 31.0503], [-3.77103, 31.14984], [-3.77647, 31.31912], [-3.66386, 31.39202], [-3.66314, 31.6339], [-2.82784, 31.79459], [-2.93873, 32.06557], [-2.46166, 32.16603], [-1.22829, 32.07832], [-1.15735, 32.12096], [-1.24453, 32.1917], [-1.24998, 32.32993], [-0.9912, 32.52467], [-1.37794, 32.73628], [-1.54244, 32.95499], [-1.46249, 33.0499], [-1.67067, 33.27084], [-1.59508, 33.59929], [-1.73494, 33.71721], [-1.64666, 34.10405], [-1.78042, 34.39018], [-1.69788, 34.48056], [-1.84569, 34.61907], [-1.73707, 34.74226], [-1.97469, 34.886], [-1.97833, 34.93218], [-2.04734, 34.93218], [-2.21445, 35.04378], [-2.21248, 35.08532], [-2.27707, 35.35051]], [[-2.91909, 35.33927], [-2.92272, 35.27509], [-2.93893, 35.26737], [-2.95065, 35.26576], [-2.95431, 35.2728], [-2.96516, 35.27967], [-2.96826, 35.28296], [-2.96507, 35.28801], [-2.97035, 35.28852], [-2.96978, 35.29459], [-2.96648, 35.30475], [-2.96038, 35.31609], [-2.91909, 35.33927]], [[-3.90602, 35.21494], [-3.89343, 35.22728], [-3.88372, 35.20767], [-3.90602, 35.21494]], [[-4.30191, 35.17419], [-4.29436, 35.17149], [-4.30112, 35.17058], [-4.30191, 35.17419]], [[-2.40316, 35.16893], [-2.45965, 35.16527], [-2.43262, 35.20652], [-2.40316, 35.16893]], [[-5.38491, 35.92591], [-5.21179, 35.90091], [-5.34379, 35.8711], [-5.35844, 35.87375], [-5.37338, 35.88417], [-5.38491, 35.92591]]]] } },
22809     { type: "Feature", properties: { iso1A2: "MC", iso1A3: "MCO", iso1N3: "492", wikidata: "Q235", nameEn: "Monaco", groups: ["155", "150", "UN"], callingCodes: ["377"] }, geometry: { type: "MultiPolygon", coordinates: [[[[7.47823, 43.73341], [7.4379, 43.74963], [7.4389, 43.75151], [7.43708, 43.75197], [7.43624, 43.75014], [7.43013, 43.74895], [7.42809, 43.74396], [7.42443, 43.74087], [7.42299, 43.74176], [7.42062, 43.73977], [7.41233, 43.73439], [7.41298, 43.73311], [7.41291, 43.73168], [7.41113, 43.73156], [7.40903, 43.7296], [7.42422, 43.72209], [7.47823, 43.73341]]]] } },
22810     { type: "Feature", properties: { iso1A2: "MD", iso1A3: "MDA", iso1N3: "498", wikidata: "Q217", nameEn: "Moldova", groups: ["151", "150", "UN"], callingCodes: ["373"] }, geometry: { type: "MultiPolygon", coordinates: [[[[27.74422, 48.45926], [27.6658, 48.44034], [27.59027, 48.46311], [27.5889, 48.49224], [27.46942, 48.454], [27.44333, 48.41209], [27.37741, 48.41026], [27.37604, 48.44398], [27.32159, 48.4434], [27.27855, 48.37534], [27.13434, 48.37288], [27.08078, 48.43214], [27.0231, 48.42485], [27.03821, 48.37653], [26.93384, 48.36558], [26.85556, 48.41095], [26.71274, 48.40388], [26.82809, 48.31629], [26.79239, 48.29071], [26.6839, 48.35828], [26.62823, 48.25804], [26.81161, 48.25049], [26.87708, 48.19919], [26.94265, 48.1969], [26.98042, 48.15752], [26.96119, 48.13003], [27.04118, 48.12522], [27.02985, 48.09083], [27.15622, 47.98538], [27.1618, 47.92391], [27.29069, 47.73722], [27.25519, 47.71366], [27.32202, 47.64009], [27.3979, 47.59473], [27.47942, 47.48113], [27.55731, 47.46637], [27.60263, 47.32507], [27.68706, 47.28962], [27.73172, 47.29248], [27.81892, 47.1381], [28.09095, 46.97621], [28.12173, 46.82283], [28.24808, 46.64305], [28.22281, 46.50481], [28.25769, 46.43334], [28.18902, 46.35283], [28.19864, 46.31869], [28.10937, 46.22852], [28.13684, 46.18099], [28.08612, 46.01105], [28.13111, 45.92819], [28.16568, 45.6421], [28.08927, 45.6051], [28.18741, 45.47358], [28.21139, 45.46895], [28.30201, 45.54744], [28.41836, 45.51715], [28.43072, 45.48538], [28.51449, 45.49982], [28.49252, 45.56716], [28.54196, 45.58062], [28.51587, 45.6613], [28.47879, 45.66994], [28.52823, 45.73803], [28.70401, 45.78019], [28.69852, 45.81753], [28.78503, 45.83475], [28.74383, 45.96664], [28.98004, 46.00385], [29.00613, 46.04962], [28.94643, 46.09176], [29.06656, 46.19716], [28.94953, 46.25852], [28.98478, 46.31803], [29.004, 46.31495], [28.9306, 46.45699], [29.01241, 46.46177], [29.02409, 46.49582], [29.23547, 46.55435], [29.24886, 46.37912], [29.35357, 46.49505], [29.49914, 46.45889], [29.5939, 46.35472], [29.6763, 46.36041], [29.66359, 46.4215], [29.74496, 46.45605], [29.88329, 46.35851], [29.94114, 46.40114], [30.09103, 46.38694], [30.16794, 46.40967], [30.02511, 46.45132], [29.88916, 46.54302], [29.94409, 46.56002], [29.9743, 46.75325], [29.94522, 46.80055], [29.98814, 46.82358], [29.87405, 46.88199], [29.75458, 46.8604], [29.72986, 46.92234], [29.57056, 46.94766], [29.62137, 47.05069], [29.61038, 47.09932], [29.53044, 47.07851], [29.49732, 47.12878], [29.57696, 47.13581], [29.54996, 47.24962], [29.59665, 47.25521], [29.5733, 47.36508], [29.48678, 47.36043], [29.47854, 47.30366], [29.39889, 47.30179], [29.3261, 47.44664], [29.18603, 47.43387], [29.11743, 47.55001], [29.22414, 47.60012], [29.22242, 47.73607], [29.27255, 47.79953], [29.20663, 47.80367], [29.27804, 47.88893], [29.19839, 47.89261], [29.1723, 47.99013], [28.9306, 47.96255], [28.8414, 48.03392], [28.85232, 48.12506], [28.69896, 48.13106], [28.53921, 48.17453], [28.48428, 48.0737], [28.42454, 48.12047], [28.43701, 48.15832], [28.38712, 48.17567], [28.34009, 48.13147], [28.30609, 48.14018], [28.30586, 48.1597], [28.34912, 48.1787], [28.36996, 48.20543], [28.35519, 48.24957], [28.32508, 48.23384], [28.2856, 48.23202], [28.19314, 48.20749], [28.17666, 48.25963], [28.07504, 48.23494], [28.09873, 48.3124], [28.04527, 48.32661], [27.95883, 48.32368], [27.88391, 48.36699], [27.87533, 48.4037], [27.81902, 48.41874], [27.79225, 48.44244], [27.74422, 48.45926]]]] } },
22811     { type: "Feature", properties: { iso1A2: "ME", iso1A3: "MNE", iso1N3: "499", wikidata: "Q236", nameEn: "Montenegro", groups: ["039", "150", "UN"], callingCodes: ["382"] }, geometry: { type: "MultiPolygon", coordinates: [[[[19.22807, 43.5264], [19.15685, 43.53943], [19.13933, 43.5282], [19.04934, 43.50384], [19.01078, 43.55806], [18.91379, 43.50299], [18.95469, 43.49367], [18.96053, 43.45042], [19.01078, 43.43854], [19.04071, 43.397], [19.08673, 43.31453], [19.08206, 43.29668], [19.04233, 43.30008], [19.00844, 43.24988], [18.95001, 43.29327], [18.95819, 43.32899], [18.90911, 43.36383], [18.83912, 43.34795], [18.84794, 43.33735], [18.85342, 43.32426], [18.76538, 43.29838], [18.6976, 43.25243], [18.71747, 43.2286], [18.66605, 43.2056], [18.64735, 43.14766], [18.66254, 43.03928], [18.52232, 43.01451], [18.49076, 42.95553], [18.49661, 42.89306], [18.4935, 42.86433], [18.47633, 42.85829], [18.45921, 42.81682], [18.47324, 42.74992], [18.56789, 42.72074], [18.55221, 42.69045], [18.54603, 42.69171], [18.54841, 42.68328], [18.57373, 42.64429], [18.52232, 42.62279], [18.55504, 42.58409], [18.53751, 42.57376], [18.49778, 42.58409], [18.43735, 42.55921], [18.44307, 42.51077], [18.43588, 42.48556], [18.52152, 42.42302], [18.54128, 42.39171], [18.45131, 42.21682], [19.26406, 41.74971], [19.37597, 41.84849], [19.37451, 41.8842], [19.33812, 41.90669], [19.34601, 41.95675], [19.37691, 41.96977], [19.36867, 42.02564], [19.37548, 42.06835], [19.40687, 42.10024], [19.28623, 42.17745], [19.42, 42.33019], [19.42352, 42.36546], [19.4836, 42.40831], [19.65972, 42.62774], [19.73244, 42.66299], [19.77375, 42.58517], [19.74731, 42.57422], [19.76549, 42.50237], [19.82333, 42.46581], [19.9324, 42.51699], [20.00842, 42.5109], [20.01834, 42.54622], [20.07761, 42.55582], [20.0969, 42.65559], [20.02915, 42.71147], [20.02088, 42.74789], [20.04898, 42.77701], [20.2539, 42.76245], [20.27869, 42.81945], [20.35692, 42.8335], [20.34528, 42.90676], [20.16415, 42.97177], [20.14896, 42.99058], [20.12325, 42.96237], [20.05431, 42.99571], [20.04729, 43.02732], [19.98887, 43.0538], [19.96549, 43.11098], [19.92576, 43.08539], [19.79255, 43.11951], [19.76918, 43.16044], [19.64063, 43.19027], [19.62661, 43.2286], [19.54598, 43.25158], [19.52962, 43.31623], [19.48171, 43.32644], [19.44315, 43.38846], [19.22229, 43.47926], [19.22807, 43.5264]]]] } },
22812     { type: "Feature", properties: { iso1A2: "MF", iso1A3: "MAF", iso1N3: "663", wikidata: "Q126125", nameEn: "Saint-Martin", country: "FR", groups: ["Q3320166", "EU", "029", "003", "419", "019", "UN"], callingCodes: ["590"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.93924, 18.02904], [-62.62718, 18.26185], [-63.35989, 18.06012], [-63.33064, 17.9615], [-63.13502, 18.05445], [-63.11042, 18.05339], [-63.09686, 18.04608], [-63.07759, 18.04943], [-63.0579, 18.06614], [-63.04039, 18.05619], [-63.02323, 18.05757], [-62.93924, 18.02904]]]] } },
22813     { type: "Feature", properties: { iso1A2: "MG", iso1A3: "MDG", iso1N3: "450", wikidata: "Q1019", nameEn: "Madagascar", aliases: ["RM"], groups: ["014", "202", "002", "UN"], callingCodes: ["261"] }, geometry: { type: "MultiPolygon", coordinates: [[[[51.93891, -10.85085], [45.84651, -12.77177], [42.14681, -19.63341], [45.80092, -33.00974], [51.93891, -10.85085]]]] } },
22814     { type: "Feature", properties: { iso1A2: "MH", iso1A3: "MHL", iso1N3: "584", wikidata: "Q709", nameEn: "Marshall Islands", groups: ["057", "009", "UN"], roadSpeedUnit: "mph", callingCodes: ["692"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169, 3.9], [173.53711, 5.70687], [169.29099, 15.77133], [159.04653, 10.59067], [169, 3.9]]]] } },
22815     { type: "Feature", properties: { iso1A2: "MK", iso1A3: "MKD", iso1N3: "807", wikidata: "Q221", nameEn: "North Macedonia", groups: ["039", "150", "UN"], callingCodes: ["389"] }, geometry: { type: "MultiPolygon", coordinates: [[[[22.34773, 42.31725], [22.29275, 42.34913], [22.29605, 42.37477], [22.16384, 42.32103], [22.02908, 42.29848], [21.94405, 42.34669], [21.91595, 42.30392], [21.84654, 42.3247], [21.77176, 42.2648], [21.70111, 42.23789], [21.58992, 42.25915], [21.52145, 42.24465], [21.50823, 42.27156], [21.43882, 42.2789], [21.43882, 42.23609], [21.38428, 42.24465], [21.30496, 42.1418], [21.29913, 42.13954], [21.31983, 42.10993], [21.22728, 42.08909], [21.16614, 42.19815], [21.11491, 42.20794], [20.75464, 42.05229], [20.76786, 41.91839], [20.68523, 41.85318], [20.59524, 41.8818], [20.55976, 41.87068], [20.57144, 41.7897], [20.53405, 41.78099], [20.51301, 41.72433], [20.52937, 41.69292], [20.51769, 41.65975], [20.55508, 41.58113], [20.52103, 41.56473], [20.45809, 41.5549], [20.45331, 41.51436], [20.49039, 41.49277], [20.51301, 41.442], [20.55976, 41.4087], [20.52119, 41.34381], [20.49432, 41.33679], [20.51068, 41.2323], [20.59715, 41.13644], [20.58546, 41.11179], [20.59832, 41.09066], [20.63454, 41.0889], [20.65558, 41.08009], [20.71634, 40.91781], [20.73504, 40.9081], [20.81567, 40.89662], [20.83671, 40.92752], [20.94305, 40.92399], [20.97693, 40.90103], [20.97887, 40.85475], [21.15262, 40.85546], [21.21105, 40.8855], [21.25779, 40.86165], [21.35595, 40.87578], [21.41555, 40.9173], [21.53007, 40.90759], [21.57448, 40.86076], [21.69601, 40.9429], [21.7556, 40.92525], [21.91102, 41.04786], [21.90869, 41.09191], [22.06527, 41.15617], [22.1424, 41.12449], [22.17629, 41.15969], [22.26744, 41.16409], [22.42285, 41.11921], [22.5549, 41.13065], [22.58295, 41.11568], [22.62852, 41.14385], [22.65306, 41.18168], [22.71266, 41.13945], [22.74538, 41.16321], [22.76408, 41.32225], [22.81199, 41.3398], [22.93334, 41.34104], [22.96331, 41.35782], [22.95513, 41.63265], [23.03342, 41.71034], [23.01239, 41.76527], [22.96682, 41.77137], [22.90254, 41.87587], [22.86749, 42.02275], [22.67701, 42.06614], [22.51224, 42.15457], [22.50289, 42.19527], [22.47251, 42.20393], [22.38136, 42.30339], [22.34773, 42.31725]]]] } },
22816     { type: "Feature", properties: { iso1A2: "ML", iso1A3: "MLI", iso1N3: "466", wikidata: "Q912", nameEn: "Mali", groups: ["011", "202", "002", "UN"], callingCodes: ["223"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-4.83423, 24.99935], [-6.57191, 25.0002], [-5.60725, 16.49919], [-5.33435, 16.33354], [-5.50165, 15.50061], [-9.32979, 15.50032], [-9.31106, 15.69412], [-9.33314, 15.7044], [-9.44673, 15.60553], [-9.40447, 15.4396], [-10.71721, 15.4223], [-10.90932, 15.11001], [-11.43483, 15.62339], [-11.70705, 15.51558], [-11.94903, 14.76143], [-12.23936, 14.76324], [-11.93043, 13.84505], [-12.06897, 13.71049], [-11.83345, 13.33333], [-11.63025, 13.39174], [-11.39935, 12.97808], [-11.37536, 12.40788], [-11.50006, 12.17826], [-11.24136, 12.01286], [-10.99758, 12.24634], [-10.80355, 12.1053], [-10.71897, 11.91552], [-10.30604, 12.24634], [-9.714, 12.0226], [-9.63938, 12.18312], [-9.32097, 12.29009], [-9.38067, 12.48446], [-9.13689, 12.50875], [-8.94784, 12.34842], [-8.80854, 11.66715], [-8.40058, 11.37466], [-8.66923, 10.99397], [-8.35083, 11.06234], [-8.2667, 10.91762], [-8.32614, 10.69273], [-8.22711, 10.41722], [-8.10207, 10.44649], [-7.9578, 10.2703], [-7.97971, 10.17117], [-7.92107, 10.15577], [-7.63048, 10.46334], [-7.54462, 10.40921], [-7.52261, 10.4655], [-7.44555, 10.44602], [-7.3707, 10.24677], [-7.13331, 10.24877], [-7.0603, 10.14711], [-7.00966, 10.15794], [-6.97444, 10.21644], [-7.01186, 10.25111], [-6.93921, 10.35291], [-6.68164, 10.35074], [-6.63541, 10.66893], [-6.52974, 10.59104], [-6.42847, 10.5694], [-6.40646, 10.69922], [-6.325, 10.68624], [-6.24795, 10.74248], [-6.1731, 10.46983], [-6.18851, 10.24244], [-5.99478, 10.19694], [-5.78124, 10.43952], [-5.65135, 10.46767], [-5.51058, 10.43177], [-5.46643, 10.56074], [-5.47083, 10.75329], [-5.41579, 10.84628], [-5.49284, 11.07538], [-5.32994, 11.13371], [-5.32553, 11.21578], [-5.25949, 11.24816], [-5.25509, 11.36905], [-5.20665, 11.43811], [-5.22867, 11.60421], [-5.29251, 11.61715], [-5.26389, 11.75728], [-5.40258, 11.8327], [-5.26389, 11.84778], [-5.07897, 11.97918], [-4.72893, 12.01579], [-4.70692, 12.06746], [-4.62987, 12.06531], [-4.62546, 12.13204], [-4.54841, 12.1385], [-4.57703, 12.19875], [-4.41412, 12.31922], [-4.47356, 12.71252], [-4.238, 12.71467], [-4.21819, 12.95722], [-4.34477, 13.12927], [-3.96501, 13.49778], [-3.90558, 13.44375], [-3.96282, 13.38164], [-3.7911, 13.36665], [-3.54454, 13.1781], [-3.4313, 13.1588], [-3.43507, 13.27272], [-3.23599, 13.29035], [-3.28396, 13.5422], [-3.26407, 13.70699], [-2.88189, 13.64921], [-2.90831, 13.81174], [-2.84667, 14.05532], [-2.66175, 14.14713], [-2.47587, 14.29671], [-2.10223, 14.14878], [-1.9992, 14.19011], [-1.97945, 14.47709], [-1.68083, 14.50023], [-1.32166, 14.72774], [-1.05875, 14.7921], [-0.72004, 15.08655], [-0.24673, 15.07805], [0.06588, 14.96961], [0.23859, 15.00135], [0.72632, 14.95898], [0.96711, 14.98275], [1.31275, 15.27978], [3.01806, 15.34571], [3.03134, 15.42221], [3.50368, 15.35934], [4.19893, 16.39923], [4.21787, 17.00118], [4.26762, 17.00432], [4.26651, 19.14224], [3.36082, 18.9745], [3.12501, 19.1366], [3.24648, 19.81703], [1.20992, 20.73533], [1.15698, 21.12843], [-4.83423, 24.99935]]]] } },
22817     { type: "Feature", properties: { iso1A2: "MM", iso1A3: "MMR", iso1N3: "104", wikidata: "Q836", nameEn: "Myanmar", aliases: ["Burma", "BU"], groups: ["035", "142", "UN"], callingCodes: ["95"] }, geometry: { type: "MultiPolygon", coordinates: [[[[92.62187, 21.87037], [92.59775, 21.6092], [92.68152, 21.28454], [92.60187, 21.24615], [92.55105, 21.3856], [92.43158, 21.37025], [92.37939, 21.47764], [92.20087, 21.337], [92.17752, 21.17445], [92.26071, 21.05697], [92.47409, 20.38654], [92.61042, 13.76986], [94.6371, 13.81803], [97.63455, 9.60854], [98.12555, 9.44056], [98.33094, 9.91973], [98.47298, 9.95782], [98.52291, 9.92389], [98.55174, 9.92804], [98.7391, 10.31488], [98.81944, 10.52761], [98.77275, 10.62548], [98.78511, 10.68351], [98.86819, 10.78336], [99.0069, 10.85485], [98.99701, 10.92962], [99.02337, 10.97217], [99.06938, 10.94857], [99.32756, 11.28545], [99.31573, 11.32081], [99.39485, 11.3925], [99.47598, 11.62434], [99.5672, 11.62732], [99.64108, 11.78948], [99.64891, 11.82699], [99.53424, 12.02317], [99.56445, 12.14805], [99.47519, 12.1353], [99.409, 12.60603], [99.29254, 12.68921], [99.18905, 12.84799], [99.18748, 12.9898], [99.10646, 13.05804], [99.12225, 13.19847], [99.20617, 13.20575], [99.16695, 13.72621], [98.97356, 14.04868], [98.56762, 14.37701], [98.24874, 14.83013], [98.18821, 15.13125], [98.22, 15.21327], [98.30446, 15.30667], [98.40522, 15.25268], [98.41906, 15.27103], [98.39351, 15.34177], [98.4866, 15.39154], [98.56027, 15.33471], [98.58598, 15.46821], [98.541, 15.65406], [98.59853, 15.87197], [98.57019, 16.04578], [98.69585, 16.13353], [98.8376, 16.11706], [98.92656, 16.36425], [98.84485, 16.42354], [98.68074, 16.27068], [98.63817, 16.47424], [98.57912, 16.55983], [98.5695, 16.62826], [98.51113, 16.64503], [98.51833, 16.676], [98.51472, 16.68521], [98.51579, 16.69433], [98.51043, 16.70107], [98.49713, 16.69022], [98.50253, 16.7139], [98.46994, 16.73613], [98.53833, 16.81934], [98.49603, 16.8446], [98.52624, 16.89979], [98.39441, 17.06266], [98.34566, 17.04822], [98.10439, 17.33847], [98.11185, 17.36829], [97.91829, 17.54504], [97.76407, 17.71595], [97.66794, 17.88005], [97.73723, 17.97912], [97.60841, 18.23846], [97.64116, 18.29778], [97.56219, 18.33885], [97.50383, 18.26844], [97.34522, 18.54596], [97.36444, 18.57138], [97.5258, 18.4939], [97.76752, 18.58097], [97.73836, 18.88478], [97.66487, 18.9371], [97.73654, 18.9812], [97.73797, 19.04261], [97.83479, 19.09972], [97.84024, 19.22217], [97.78606, 19.26769], [97.84186, 19.29526], [97.78769, 19.39429], [97.88423, 19.5041], [97.84715, 19.55782], [98.04364, 19.65755], [98.03314, 19.80941], [98.13829, 19.78541], [98.24884, 19.67876], [98.51182, 19.71303], [98.56065, 19.67807], [98.83661, 19.80931], [98.98679, 19.7419], [99.0735, 20.10298], [99.20328, 20.12877], [99.416, 20.08614], [99.52943, 20.14811], [99.5569, 20.20676], [99.46077, 20.36198], [99.46008, 20.39673], [99.68255, 20.32077], [99.81096, 20.33687], [99.86383, 20.44371], [99.88211, 20.44488], [99.88451, 20.44596], [99.89168, 20.44548], [99.89301, 20.44311], [99.89692, 20.44789], [99.90499, 20.4487], [99.91616, 20.44986], [99.95721, 20.46301], [100.08404, 20.36626], [100.1957, 20.68247], [100.36375, 20.82783], [100.51079, 20.82194], [100.60112, 20.8347], [100.64628, 20.88279], [100.50974, 20.88574], [100.55281, 21.02796], [100.63578, 21.05639], [100.72716, 21.31786], [100.80173, 21.2934], [101.00234, 21.39612], [101.16198, 21.52808], [101.15156, 21.56129], [101.11744, 21.77659], [100.87265, 21.67396], [100.72143, 21.51898], [100.57861, 21.45637], [100.4811, 21.46148], [100.42892, 21.54325], [100.35201, 21.53176], [100.25863, 21.47043], [100.18447, 21.51898], [100.1625, 21.48704], [100.12542, 21.50365], [100.10757, 21.59945], [100.17486, 21.65306], [100.12679, 21.70539], [100.04956, 21.66843], [99.98654, 21.71064], [99.94003, 21.82782], [99.99084, 21.97053], [99.96612, 22.05965], [99.85351, 22.04183], [99.47585, 22.13345], [99.33166, 22.09656], [99.1552, 22.15874], [99.19176, 22.16983], [99.17318, 22.18025], [99.28771, 22.4105], [99.37972, 22.50188], [99.38247, 22.57544], [99.31243, 22.73893], [99.45654, 22.85726], [99.43537, 22.94086], [99.54218, 22.90014], [99.52214, 23.08218], [99.34127, 23.13099], [99.25741, 23.09025], [99.04601, 23.12215], [99.05975, 23.16382], [98.88597, 23.18656], [98.92515, 23.29535], [98.93958, 23.31414], [98.87573, 23.33038], [98.92104, 23.36946], [98.87683, 23.48995], [98.82877, 23.47908], [98.80294, 23.5345], [98.88396, 23.59555], [98.81775, 23.694], [98.82933, 23.72921], [98.79607, 23.77947], [98.68209, 23.80492], [98.67797, 23.9644], [98.89632, 24.10612], [98.87998, 24.15624], [98.85319, 24.13042], [98.59256, 24.08371], [98.54476, 24.13119], [98.20666, 24.11406], [98.07806, 24.07988], [98.06703, 24.08028], [98.0607, 24.07812], [98.05671, 24.07961], [98.05302, 24.07408], [98.04709, 24.07616], [97.99583, 24.04932], [97.98691, 24.03897], [97.93951, 24.01953], [97.90998, 24.02094], [97.88616, 24.00463], [97.88414, 23.99405], [97.88814, 23.98605], [97.89683, 23.98389], [97.89676, 23.97931], [97.8955, 23.97758], [97.88811, 23.97446], [97.86545, 23.97723], [97.84328, 23.97603], [97.79416, 23.95663], [97.79456, 23.94836], [97.72302, 23.89288], [97.64667, 23.84574], [97.5247, 23.94032], [97.62363, 24.00506], [97.72903, 24.12606], [97.75305, 24.16902], [97.72799, 24.18883], [97.72998, 24.2302], [97.76799, 24.26365], [97.71941, 24.29652], [97.66723, 24.30027], [97.65624, 24.33781], [97.7098, 24.35658], [97.66998, 24.45288], [97.60029, 24.4401], [97.52757, 24.43748], [97.56286, 24.54535], [97.56525, 24.72838], [97.54675, 24.74202], [97.5542, 24.74943], [97.56383, 24.75535], [97.56648, 24.76475], [97.64354, 24.79171], [97.70181, 24.84557], [97.73127, 24.83015], [97.76481, 24.8289], [97.79949, 24.85655], [97.72903, 24.91332], [97.72216, 25.08508], [97.77023, 25.11492], [97.83614, 25.2715], [97.92541, 25.20815], [98.14925, 25.41547], [98.12591, 25.50722], [98.18084, 25.56298], [98.16848, 25.62739], [98.25774, 25.6051], [98.31268, 25.55307], [98.40606, 25.61129], [98.54064, 25.85129], [98.63128, 25.79937], [98.70818, 25.86241], [98.60763, 26.01512], [98.57085, 26.11547], [98.63128, 26.15492], [98.66884, 26.09165], [98.7329, 26.17218], [98.67797, 26.24487], [98.72741, 26.36183], [98.77547, 26.61994], [98.7333, 26.85615], [98.69582, 27.56499], [98.43353, 27.67086], [98.42529, 27.55404], [98.32641, 27.51385], [98.13964, 27.9478], [98.15337, 28.12114], [97.90069, 28.3776], [97.79632, 28.33168], [97.70705, 28.5056], [97.56835, 28.55628], [97.50518, 28.49716], [97.47085, 28.2688], [97.41729, 28.29783], [97.34547, 28.21385], [97.31292, 28.06784], [97.35412, 28.06663], [97.38845, 28.01329], [97.35824, 27.87256], [97.29919, 27.92233], [96.90112, 27.62149], [96.91431, 27.45752], [97.17422, 27.14052], [97.14675, 27.09041], [96.89132, 27.17474], [96.85287, 27.2065], [96.88445, 27.25046], [96.73888, 27.36638], [96.55761, 27.29928], [96.40779, 27.29818], [96.15591, 27.24572], [96.04949, 27.19428], [95.93002, 27.04149], [95.81603, 27.01335], [95.437, 26.7083], [95.30339, 26.65372], [95.23513, 26.68499], [95.05798, 26.45408], [95.12801, 26.38397], [95.11428, 26.1019], [95.18556, 26.07338], [94.80117, 25.49359], [94.68032, 25.47003], [94.57458, 25.20318], [94.74212, 25.13606], [94.73937, 25.00545], [94.60204, 24.70889], [94.5526, 24.70764], [94.50729, 24.59281], [94.45279, 24.56656], [94.32362, 24.27692], [94.30215, 24.23752], [94.14081, 23.83333], [93.92089, 23.95812], [93.80279, 23.92549], [93.75952, 24.0003], [93.62871, 24.00922], [93.50616, 23.94432], [93.46633, 23.97067], [93.41415, 24.07854], [93.34735, 24.10151], [93.32351, 24.04468], [93.36059, 23.93176], [93.3908, 23.92925], [93.3908, 23.7622], [93.43475, 23.68299], [93.38805, 23.4728], [93.39981, 23.38828], [93.38781, 23.36139], [93.36862, 23.35426], [93.38478, 23.13698], [93.2878, 23.00464], [93.12988, 23.05772], [93.134, 22.92498], [93.09417, 22.69459], [93.134, 22.59573], [93.11477, 22.54374], [93.13537, 22.45873], [93.18206, 22.43716], [93.19991, 22.25425], [93.14224, 22.24535], [93.15734, 22.18687], [93.04885, 22.20595], [92.99255, 22.05965], [92.99804, 21.98964], [92.93899, 22.02656], [92.89504, 21.95143], [92.86208, 22.05456], [92.70416, 22.16017], [92.67532, 22.03547], [92.60949, 21.97638], [92.62187, 21.87037]]]] } },
22818     { type: "Feature", properties: { iso1A2: "MN", iso1A3: "MNG", iso1N3: "496", wikidata: "Q711", nameEn: "Mongolia", groups: ["030", "142", "UN"], callingCodes: ["976"] }, geometry: { type: "MultiPolygon", coordinates: [[[[102.14032, 51.35566], [101.5044, 51.50467], [101.39085, 51.45753], [100.61116, 51.73028], [99.89203, 51.74903], [99.75578, 51.90108], [99.27888, 51.96876], [98.87768, 52.14563], [98.74142, 51.8637], [98.33222, 51.71832], [98.22053, 51.46579], [98.05257, 51.46696], [97.83305, 51.00248], [98.01472, 50.86652], [97.9693, 50.78044], [98.06393, 50.61262], [98.31373, 50.4996], [98.29481, 50.33561], [97.85197, 49.91339], [97.76871, 49.99861], [97.56432, 49.92801], [97.56811, 49.84265], [97.24639, 49.74737], [96.97388, 49.88413], [95.80056, 50.04239], [95.74757, 49.97915], [95.02465, 49.96941], [94.97166, 50.04725], [94.6121, 50.04239], [94.49477, 50.17832], [94.39258, 50.22193], [94.30823, 50.57498], [92.99595, 50.63183], [93.01109, 50.79001], [92.44714, 50.78762], [92.07173, 50.69585], [91.86048, 50.73734], [89.59711, 49.90851], [89.70687, 49.72535], [88.82499, 49.44808], [88.42449, 49.48821], [88.17223, 49.46934], [88.15543, 49.30314], [87.98977, 49.18147], [87.81333, 49.17354], [87.88171, 48.95853], [87.73822, 48.89582], [88.0788, 48.71436], [87.96361, 48.58478], [88.58939, 48.34531], [88.58316, 48.21893], [88.8011, 48.11302], [88.93186, 48.10263], [89.0711, 47.98528], [89.55453, 48.0423], [89.76624, 47.82745], [90.06512, 47.88177], [90.10871, 47.7375], [90.33598, 47.68303], [90.48854, 47.41826], [90.48542, 47.30438], [90.76108, 46.99399], [90.84035, 46.99525], [91.03649, 46.72916], [91.0147, 46.58171], [91.07696, 46.57315], [90.89639, 46.30711], [90.99672, 46.14207], [91.03026, 46.04194], [90.70907, 45.73437], [90.65114, 45.49314], [90.89169, 45.19667], [91.64048, 45.07408], [93.51161, 44.95964], [94.10003, 44.71016], [94.71959, 44.35284], [95.01191, 44.25274], [95.39772, 44.2805], [95.32891, 44.02407], [95.52594, 43.99353], [95.89543, 43.2528], [96.35658, 42.90363], [96.37926, 42.72055], [97.1777, 42.7964], [99.50671, 42.56535], [100.33297, 42.68231], [100.84979, 42.67087], [101.80515, 42.50074], [102.07645, 42.22519], [102.72403, 42.14675], [103.92804, 41.78246], [104.52258, 41.8706], [104.51667, 41.66113], [105.0123, 41.63188], [106.76517, 42.28741], [107.24774, 42.36107], [107.29755, 42.41395], [107.49681, 42.46221], [107.57258, 42.40898], [108.84489, 42.40246], [109.00679, 42.45302], [109.452, 42.44842], [109.89402, 42.63111], [110.08401, 42.6411], [110.4327, 42.78293], [111.0149, 43.3289], [111.59087, 43.51207], [111.79758, 43.6637], [111.93776, 43.68709], [111.96289, 43.81596], [111.40498, 44.3461], [111.76275, 44.98032], [111.98695, 45.09074], [112.4164, 45.06858], [112.74662, 44.86297], [113.70918, 44.72891], [114.5166, 45.27189], [114.54801, 45.38337], [114.74612, 45.43585], [114.94546, 45.37377], [115.60329, 45.44717], [116.16989, 45.68603], [116.27366, 45.78637], [116.24012, 45.8778], [116.26678, 45.96479], [116.58612, 46.30211], [116.75551, 46.33083], [116.83166, 46.38637], [117.36609, 46.36335], [117.41782, 46.57862], [117.60748, 46.59771], [117.69554, 46.50991], [118.30534, 46.73519], [118.78747, 46.68689], [118.8337, 46.77742], [118.89974, 46.77139], [118.92616, 46.72765], [119.00541, 46.74273], [119.10448, 46.65516], [119.24978, 46.64761], [119.32827, 46.61433], [119.42827, 46.63783], [119.65265, 46.62342], [119.68127, 46.59015], [119.77373, 46.62947], [119.80455, 46.67631], [119.89261, 46.66423], [119.91242, 46.90091], [119.85518, 46.92196], [119.71209, 47.19192], [119.62403, 47.24575], [119.56019, 47.24874], [119.54918, 47.29505], [119.31964, 47.42617], [119.35892, 47.48104], [119.13995, 47.53997], [119.12343, 47.66458], [118.7564, 47.76947], [118.55766, 47.99277], [118.29654, 48.00246], [118.22677, 48.03853], [118.11009, 48.04], [118.03676, 48.00982], [117.80196, 48.01661], [117.50181, 47.77216], [117.37875, 47.63627], [116.9723, 47.87285], [116.67405, 47.89039], [116.4465, 47.83662], [116.21879, 47.88505], [115.94296, 47.67741], [115.57128, 47.91988], [115.52082, 48.15367], [115.811, 48.25699], [115.78876, 48.51781], [116.06565, 48.81716], [116.03781, 48.87014], [116.71193, 49.83813], [116.62502, 49.92919], [116.22402, 50.04477], [115.73602, 49.87688], [115.26068, 49.97367], [114.9703, 50.19254], [114.325, 50.28098], [113.20216, 49.83356], [113.02647, 49.60772], [110.64493, 49.1816], [110.39891, 49.25083], [110.24373, 49.16676], [109.51325, 49.22859], [109.18017, 49.34709], [108.53969, 49.32325], [108.27937, 49.53167], [107.95387, 49.66659], [107.96116, 49.93191], [107.36407, 49.97612], [107.1174, 50.04239], [107.00007, 50.1977], [106.80326, 50.30177], [106.58373, 50.34044], [106.51122, 50.34408], [106.49628, 50.32436], [106.47156, 50.31909], [106.07865, 50.33474], [106.05562, 50.40582], [105.32528, 50.4648], [103.70343, 50.13952], [102.71178, 50.38873], [102.32194, 50.67982], [102.14032, 51.35566]]]] } },
22819     { type: "Feature", properties: { iso1A2: "MO", iso1A3: "MAC", iso1N3: "446", wikidata: "Q14773", nameEn: "Macau", aliases: ["Macao"], country: "CN", groups: ["030", "142", "UN"], driveSide: "left", callingCodes: ["853"] }, geometry: { type: "MultiPolygon", coordinates: [[[[113.54942, 22.14519], [113.54839, 22.10909], [113.57191, 22.07696], [113.63011, 22.10782], [113.60504, 22.20464], [113.57123, 22.20416], [113.56865, 22.20973], [113.5508, 22.21672], [113.54333, 22.21688], [113.54093, 22.21314], [113.53593, 22.2137], [113.53301, 22.21235], [113.53552, 22.20607], [113.52659, 22.18271], [113.54093, 22.15497], [113.54942, 22.14519]]]] } },
22820     { type: "Feature", properties: { iso1A2: "MP", iso1A3: "MNP", iso1N3: "580", wikidata: "Q16644", nameEn: "Northern Mariana Islands", aliases: ["US-MP"], country: "US", groups: ["Q1352230", "Q153732", "057", "009", "UN"], roadSpeedUnit: "mph", callingCodes: ["1 670"] }, geometry: { type: "MultiPolygon", coordinates: [[[[135.52896, 14.32623], [152.19114, 13.63487], [145.05972, 21.28731], [135.52896, 14.32623]]]] } },
22821     { type: "Feature", properties: { iso1A2: "MQ", iso1A3: "MTQ", iso1N3: "474", wikidata: "Q17054", nameEn: "Martinique", country: "FR", groups: ["Q3320166", "EU", "029", "003", "419", "019", "UN"], callingCodes: ["596"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-59.95997, 14.20285], [-61.07821, 15.25109], [-61.69315, 14.26451], [-59.95997, 14.20285]]]] } },
22822     { type: "Feature", properties: { iso1A2: "MR", iso1A3: "MRT", iso1N3: "478", wikidata: "Q1025", nameEn: "Mauritania", groups: ["011", "202", "002", "UN"], callingCodes: ["222"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-5.60725, 16.49919], [-6.57191, 25.0002], [-4.83423, 24.99935], [-8.66674, 27.31569], [-8.66721, 25.99918], [-12.0002, 25.9986], [-12.00251, 23.4538], [-12.14969, 23.41935], [-12.36213, 23.3187], [-12.5741, 23.28975], [-13.00412, 23.02297], [-13.10753, 22.89493], [-13.15313, 22.75649], [-13.08438, 22.53866], [-13.01525, 21.33343], [-16.95474, 21.33997], [-16.99806, 21.12142], [-17.0357, 21.05368], [-17.0396, 20.9961], [-17.06781, 20.92697], [-17.0695, 20.85742], [-17.0471, 20.76408], [-17.15288, 16.07139], [-16.50854, 16.09032], [-16.48967, 16.0496], [-16.44814, 16.09753], [-16.4429, 16.20605], [-16.27016, 16.51565], [-15.6509, 16.50315], [-15.00557, 16.64997], [-14.32144, 16.61495], [-13.80075, 16.13961], [-13.43135, 16.09022], [-13.11029, 15.52116], [-12.23936, 14.76324], [-11.94903, 14.76143], [-11.70705, 15.51558], [-11.43483, 15.62339], [-10.90932, 15.11001], [-10.71721, 15.4223], [-9.40447, 15.4396], [-9.44673, 15.60553], [-9.33314, 15.7044], [-9.31106, 15.69412], [-9.32979, 15.50032], [-5.50165, 15.50061], [-5.33435, 16.33354], [-5.60725, 16.49919]]]] } },
22823     { type: "Feature", properties: { iso1A2: "MS", iso1A3: "MSR", iso1N3: "500", wikidata: "Q13353", nameEn: "Montserrat", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 664"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-61.91508, 16.51165], [-62.1023, 16.97277], [-62.58307, 16.68909], [-61.91508, 16.51165]]]] } },
22824     { type: "Feature", properties: { iso1A2: "MT", iso1A3: "MLT", iso1N3: "470", wikidata: "Q233", nameEn: "Malta", groups: ["EU", "039", "150", "UN"], driveSide: "left", callingCodes: ["356"] }, geometry: { type: "MultiPolygon", coordinates: [[[[15.70991, 35.79901], [14.07544, 36.41525], [13.27636, 35.20764], [15.70991, 35.79901]]]] } },
22825     { type: "Feature", properties: { iso1A2: "MU", iso1A3: "MUS", iso1N3: "480", wikidata: "Q1027", nameEn: "Mauritius", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["230"] }, geometry: { type: "MultiPolygon", coordinates: [[[[56.09755, -9.55401], [57.50644, -31.92637], [68.4673, -19.15185], [56.09755, -9.55401]]]] } },
22826     { type: "Feature", properties: { iso1A2: "MV", iso1A3: "MDV", iso1N3: "462", wikidata: "Q826", nameEn: "Maldives", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["960"] }, geometry: { type: "MultiPolygon", coordinates: [[[[71.9161, 8.55531], [72.57428, -3.7623], [76.59015, 5.591], [71.9161, 8.55531]]]] } },
22827     { type: "Feature", properties: { iso1A2: "MW", iso1A3: "MWI", iso1N3: "454", wikidata: "Q1020", nameEn: "Malawi", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["265"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.48052, -9.62442], [33.31581, -9.48554], [33.14925, -9.49322], [32.99397, -9.36712], [32.95389, -9.40138], [33.00476, -9.5133], [33.00256, -9.63053], [33.05485, -9.61316], [33.10163, -9.66525], [33.12144, -9.58929], [33.2095, -9.61099], [33.31517, -9.82364], [33.36581, -9.81063], [33.37902, -9.9104], [33.31297, -10.05133], [33.53863, -10.20148], [33.54797, -10.36077], [33.70675, -10.56896], [33.47636, -10.78465], [33.28022, -10.84428], [33.25998, -10.88862], [33.39697, -11.15296], [33.29267, -11.3789], [33.29267, -11.43536], [33.23663, -11.40637], [33.24252, -11.59302], [33.32692, -11.59248], [33.33937, -11.91252], [33.25998, -12.14242], [33.3705, -12.34931], [33.47636, -12.32498], [33.54485, -12.35996], [33.37517, -12.54085], [33.28177, -12.54692], [33.18837, -12.61377], [33.05917, -12.59554], [32.94397, -12.76868], [32.96733, -12.88251], [33.02181, -12.88707], [32.98289, -13.12671], [33.0078, -13.19492], [32.86113, -13.47292], [32.84176, -13.52794], [32.73683, -13.57682], [32.68436, -13.55769], [32.66468, -13.60019], [32.68654, -13.64268], [32.7828, -13.64805], [32.84528, -13.71576], [32.76962, -13.77224], [32.79015, -13.80755], [32.88985, -13.82956], [32.99042, -13.95689], [33.02977, -14.05022], [33.07568, -13.98447], [33.16749, -13.93992], [33.24249, -14.00019], [33.66677, -14.61306], [33.7247, -14.4989], [33.88503, -14.51652], [33.92898, -14.47929], [34.08588, -14.48893], [34.18733, -14.43823], [34.22355, -14.43607], [34.34453, -14.3985], [34.35843, -14.38652], [34.39277, -14.39467], [34.4192, -14.43191], [34.44641, -14.47746], [34.45053, -14.49873], [34.47628, -14.53363], [34.48932, -14.53646], [34.49636, -14.55091], [34.52366, -14.5667], [34.53962, -14.59776], [34.55112, -14.64494], [34.53516, -14.67782], [34.52057, -14.68263], [34.54503, -14.74672], [34.567, -14.77345], [34.61522, -14.99583], [34.57503, -15.30619], [34.43126, -15.44778], [34.44981, -15.60864], [34.25195, -15.90321], [34.43126, -16.04737], [34.40344, -16.20923], [35.04805, -16.83167], [35.13771, -16.81687], [35.17017, -16.93521], [35.04805, -17.00027], [35.0923, -17.13235], [35.3062, -17.1244], [35.27065, -16.93817], [35.30929, -16.82871], [35.27219, -16.69402], [35.14235, -16.56812], [35.25828, -16.4792], [35.30157, -16.2211], [35.43355, -16.11371], [35.52365, -16.15414], [35.70107, -16.10147], [35.80487, -16.03907], [35.85303, -15.41913], [35.78799, -15.17428], [35.91812, -14.89514], [35.87212, -14.89478], [35.86945, -14.67481], [35.5299, -14.27714], [35.47989, -14.15594], [34.86229, -13.48958], [34.60253, -13.48487], [34.37831, -12.17408], [34.46088, -12.0174], [34.70739, -12.15652], [34.82903, -12.04837], [34.57917, -11.87849], [34.64241, -11.57499], [34.96296, -11.57354], [34.91153, -11.39799], [34.79375, -11.32245], [34.63305, -11.11731], [34.61161, -11.01611], [34.67047, -10.93796], [34.65946, -10.6828], [34.57581, -10.56271], [34.51911, -10.12279], [34.54499, -10.0678], [34.03865, -9.49398], [33.95829, -9.54066], [33.9638, -9.62206], [33.93298, -9.71647], [33.76677, -9.58516], [33.48052, -9.62442]]]] } },
22828     { type: "Feature", properties: { iso1A2: "MX", iso1A3: "MEX", iso1N3: "484", wikidata: "Q96", nameEn: "Mexico", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["52"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-117.1243, 32.53427], [-118.48109, 32.5991], [-120.12904, 18.41089], [-92.37213, 14.39277], [-92.2261, 14.53423], [-92.1454, 14.6804], [-92.18161, 14.84147], [-92.1423, 14.88647], [-92.1454, 14.98143], [-92.0621, 15.07406], [-92.20983, 15.26077], [-91.73182, 16.07371], [-90.44567, 16.07573], [-90.40499, 16.40524], [-90.61212, 16.49832], [-90.69064, 16.70697], [-91.04436, 16.92175], [-91.43809, 17.25373], [-90.99199, 17.25192], [-90.98678, 17.81655], [-89.14985, 17.81563], [-89.15105, 17.95104], [-89.03839, 18.0067], [-88.8716, 17.89535], [-88.71505, 18.0707], [-88.48242, 18.49164], [-88.3268, 18.49048], [-88.29909, 18.47591], [-88.26593, 18.47617], [-88.03238, 18.41778], [-88.03165, 18.16657], [-87.90671, 18.15213], [-87.87604, 18.18313], [-87.86657, 18.19971], [-87.85693, 18.18266], [-87.84815, 18.18511], [-86.92368, 17.61462], [-85.9092, 21.8218], [-96.92418, 25.97377], [-97.13927, 25.96583], [-97.35946, 25.92189], [-97.37332, 25.83854], [-97.42511, 25.83969], [-97.45669, 25.86874], [-97.49828, 25.89877], [-97.52025, 25.88518], [-97.66511, 26.01708], [-97.95155, 26.0625], [-97.97017, 26.05232], [-98.24603, 26.07191], [-98.27075, 26.09457], [-98.30491, 26.10475], [-98.35126, 26.15129], [-99.00546, 26.3925], [-99.03053, 26.41249], [-99.08477, 26.39849], [-99.53573, 27.30926], [-99.49744, 27.43746], [-99.482, 27.47128], [-99.48045, 27.49016], [-99.50208, 27.50021], [-99.52955, 27.49747], [-99.51478, 27.55836], [-99.55409, 27.61314], [-100.50029, 28.66117], [-100.51222, 28.70679], [-100.5075, 28.74066], [-100.52313, 28.75598], [-100.59809, 28.88197], [-100.63689, 28.90812], [-100.67294, 29.09744], [-100.79696, 29.24688], [-100.87982, 29.296], [-100.94056, 29.33371], [-100.94579, 29.34523], [-100.96725, 29.3477], [-101.01128, 29.36947], [-101.05686, 29.44738], [-101.47277, 29.7744], [-102.60596, 29.8192], [-103.15787, 28.93865], [-104.37752, 29.54255], [-104.39363, 29.55396], [-104.3969, 29.57105], [-104.5171, 29.64671], [-104.77674, 30.4236], [-106.00363, 31.39181], [-106.09025, 31.40569], [-106.20346, 31.46305], [-106.23711, 31.51262], [-106.24612, 31.54193], [-106.28084, 31.56173], [-106.30305, 31.62154], [-106.33419, 31.66303], [-106.34864, 31.69663], [-106.3718, 31.71165], [-106.38003, 31.73151], [-106.41773, 31.75196], [-106.43419, 31.75478], [-106.45244, 31.76523], [-106.46726, 31.75998], [-106.47298, 31.75054], [-106.48815, 31.74769], [-106.50111, 31.75714], [-106.50962, 31.76155], [-106.51251, 31.76922], [-106.52266, 31.77509], [-106.529, 31.784], [-108.20899, 31.78534], [-108.20979, 31.33316], [-111.07523, 31.33232], [-114.82011, 32.49609], [-114.79524, 32.55731], [-114.81141, 32.55543], [-114.80584, 32.62028], [-114.76736, 32.64094], [-114.71871, 32.71894], [-115.88053, 32.63624], [-117.1243, 32.53427]]]] } },
22829     { type: "Feature", properties: { iso1A2: "MY", iso1A3: "MYS", iso1N3: "458", wikidata: "Q833", nameEn: "Malaysia" }, geometry: null },
22830     { type: "Feature", properties: { iso1A2: "MZ", iso1A3: "MOZ", iso1N3: "508", wikidata: "Q1029", nameEn: "Mozambique", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["258"] }, geometry: { type: "MultiPolygon", coordinates: [[[[40.74206, -10.25691], [40.44265, -10.4618], [40.00295, -10.80255], [39.58249, -10.96043], [39.24395, -11.17433], [38.88996, -11.16978], [38.47258, -11.4199], [38.21598, -11.27289], [37.93618, -11.26228], [37.8388, -11.3123], [37.76614, -11.53352], [37.3936, -11.68949], [36.80309, -11.56836], [36.62068, -11.72884], [36.19094, -11.70008], [36.19094, -11.57593], [35.82767, -11.41081], [35.63599, -11.55927], [34.96296, -11.57354], [34.64241, -11.57499], [34.57917, -11.87849], [34.82903, -12.04837], [34.70739, -12.15652], [34.46088, -12.0174], [34.37831, -12.17408], [34.60253, -13.48487], [34.86229, -13.48958], [35.47989, -14.15594], [35.5299, -14.27714], [35.86945, -14.67481], [35.87212, -14.89478], [35.91812, -14.89514], [35.78799, -15.17428], [35.85303, -15.41913], [35.80487, -16.03907], [35.70107, -16.10147], [35.52365, -16.15414], [35.43355, -16.11371], [35.30157, -16.2211], [35.25828, -16.4792], [35.14235, -16.56812], [35.27219, -16.69402], [35.30929, -16.82871], [35.27065, -16.93817], [35.3062, -17.1244], [35.0923, -17.13235], [35.04805, -17.00027], [35.17017, -16.93521], [35.13771, -16.81687], [35.04805, -16.83167], [34.40344, -16.20923], [34.43126, -16.04737], [34.25195, -15.90321], [34.44981, -15.60864], [34.43126, -15.44778], [34.57503, -15.30619], [34.61522, -14.99583], [34.567, -14.77345], [34.54503, -14.74672], [34.52057, -14.68263], [34.53516, -14.67782], [34.55112, -14.64494], [34.53962, -14.59776], [34.52366, -14.5667], [34.49636, -14.55091], [34.48932, -14.53646], [34.47628, -14.53363], [34.45053, -14.49873], [34.44641, -14.47746], [34.4192, -14.43191], [34.39277, -14.39467], [34.35843, -14.38652], [34.34453, -14.3985], [34.22355, -14.43607], [34.18733, -14.43823], [34.08588, -14.48893], [33.92898, -14.47929], [33.88503, -14.51652], [33.7247, -14.4989], [33.66677, -14.61306], [33.24249, -14.00019], [30.22098, -14.99447], [30.41902, -15.62269], [30.42568, -15.9962], [30.91597, -15.99924], [30.97761, -16.05848], [31.13171, -15.98019], [31.30563, -16.01193], [31.42451, -16.15154], [31.67988, -16.19595], [31.90223, -16.34388], [31.91324, -16.41569], [32.02772, -16.43892], [32.28529, -16.43892], [32.42838, -16.4727], [32.71017, -16.59932], [32.69917, -16.66893], [32.78943, -16.70267], [32.97655, -16.70689], [32.91051, -16.89446], [32.84113, -16.92259], [32.96554, -17.11971], [33.00517, -17.30477], [33.0426, -17.3468], [32.96554, -17.48964], [32.98536, -17.55891], [33.0492, -17.60298], [32.94133, -17.99705], [33.03159, -18.35054], [33.02278, -18.4696], [32.88629, -18.51344], [32.88629, -18.58023], [32.95013, -18.69079], [32.9017, -18.7992], [32.82465, -18.77419], [32.70137, -18.84712], [32.73439, -18.92628], [32.69917, -18.94293], [32.72118, -19.02204], [32.84006, -19.0262], [32.87088, -19.09279], [32.85107, -19.29238], [32.77966, -19.36098], [32.78282, -19.47513], [32.84446, -19.48343], [32.84666, -19.68462], [32.95013, -19.67219], [33.06461, -19.77787], [33.01178, -20.02007], [32.93032, -20.03868], [32.85987, -20.16686], [32.85987, -20.27841], [32.66174, -20.56106], [32.55167, -20.56312], [32.48122, -20.63319], [32.51644, -20.91929], [32.37115, -21.133], [32.48236, -21.32873], [32.41234, -21.31246], [31.38336, -22.36919], [31.30611, -22.422], [31.55779, -23.176], [31.56539, -23.47268], [31.67942, -23.60858], [31.70223, -23.72695], [31.77445, -23.90082], [31.87707, -23.95293], [31.90368, -24.18892], [31.9835, -24.29983], [32.03196, -25.10785], [32.01676, -25.38117], [31.97875, -25.46356], [32.00631, -25.65044], [31.92649, -25.84216], [31.974, -25.95387], [32.00916, -25.999], [32.08599, -26.00978], [32.10435, -26.15656], [32.07352, -26.40185], [32.13409, -26.5317], [32.13315, -26.84345], [32.19409, -26.84032], [32.22302, -26.84136], [32.29584, -26.852], [32.35222, -26.86027], [34.51034, -26.91792], [42.99868, -12.65261], [40.74206, -10.25691]]]] } },
22831     { type: "Feature", properties: { iso1A2: "NA", iso1A3: "NAM", iso1N3: "516", wikidata: "Q1030", nameEn: "Namibia", groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["264"] }, geometry: { type: "MultiPolygon", coordinates: [[[[14.28743, -17.38814], [13.95896, -17.43141], [13.36212, -16.98048], [12.97145, -16.98567], [12.52111, -17.24495], [12.07076, -17.15165], [11.75063, -17.25013], [10.5065, -17.25284], [12.51595, -32.27486], [16.45332, -28.63117], [16.46592, -28.57126], [16.59922, -28.53246], [16.90446, -28.057], [17.15405, -28.08573], [17.4579, -28.68718], [18.99885, -28.89165], [19.99882, -28.42622], [19.99817, -24.76768], [19.99912, -21.99991], [20.99751, -22.00026], [20.99904, -18.31743], [21.45556, -18.31795], [23.0996, -18.00075], [23.29618, -17.99855], [23.61088, -18.4881], [24.19416, -18.01919], [24.40577, -17.95726], [24.57485, -18.07151], [24.6303, -17.9863], [24.71887, -17.9218], [24.73364, -17.89338], [24.95586, -17.79674], [25.05895, -17.84452], [25.16882, -17.78253], [25.26433, -17.79571], [25.00198, -17.58221], [24.70864, -17.49501], [24.5621, -17.52963], [24.38712, -17.46818], [24.32811, -17.49082], [24.23619, -17.47489], [23.47474, -17.62877], [21.42741, -18.02787], [21.14283, -17.94318], [18.84226, -17.80375], [18.39229, -17.38927], [14.28743, -17.38814]]]] } },
22832     { type: "Feature", properties: { iso1A2: "NC", iso1A3: "NCL", iso1N3: "540", wikidata: "Q33788", nameEn: "New Caledonia", country: "FR", groups: ["EU", "Q1451600", "054", "009", "UN"], callingCodes: ["687"] }, geometry: { type: "MultiPolygon", coordinates: [[[[159.77159, -28.41151], [174.245, -23.1974], [156.73836, -14.50464], [159.77159, -28.41151]]]] } },
22833     { type: "Feature", properties: { iso1A2: "NE", iso1A3: "NER", iso1N3: "562", wikidata: "Q1032", nameEn: "Niger", aliases: ["RN"], groups: ["011", "202", "002", "UN"], callingCodes: ["227"] }, geometry: { type: "MultiPolygon", coordinates: [[[[14.22918, 22.61719], [13.5631, 23.16574], [11.96886, 23.51735], [7.48273, 20.87258], [7.38361, 20.79165], [5.8153, 19.45101], [4.26651, 19.14224], [4.26762, 17.00432], [4.21787, 17.00118], [4.19893, 16.39923], [3.50368, 15.35934], [3.03134, 15.42221], [3.01806, 15.34571], [1.31275, 15.27978], [0.96711, 14.98275], [0.72632, 14.95898], [0.23859, 15.00135], [0.16936, 14.51654], [0.38051, 14.05575], [0.61924, 13.68491], [0.77377, 13.6866], [0.77637, 13.64442], [0.99514, 13.5668], [1.02813, 13.46635], [1.20088, 13.38951], [1.24429, 13.39373], [1.28509, 13.35488], [1.24516, 13.33968], [1.21217, 13.37853], [1.18873, 13.31771], [0.99253, 13.37515], [0.99167, 13.10727], [2.26349, 12.41915], [2.05785, 12.35539], [2.39723, 11.89473], [2.45824, 11.98672], [2.39657, 12.10952], [2.37783, 12.24804], [2.6593, 12.30631], [2.83978, 12.40585], [3.25352, 12.01467], [3.31613, 11.88495], [3.48187, 11.86092], [3.59375, 11.70269], [3.61075, 11.69181], [3.67988, 11.75429], [3.67122, 11.80865], [3.63063, 11.83042], [3.61955, 11.91847], [3.67775, 11.97599], [3.63136, 12.11826], [3.66364, 12.25884], [3.65111, 12.52223], [3.94339, 12.74979], [4.10006, 12.98862], [4.14367, 13.17189], [4.14186, 13.47586], [4.23456, 13.47725], [4.4668, 13.68286], [4.87425, 13.78], [4.9368, 13.7345], [5.07396, 13.75052], [5.21026, 13.73627], [5.27797, 13.75474], [5.35437, 13.83567], [5.52957, 13.8845], [6.15771, 13.64564], [6.27411, 13.67835], [6.43053, 13.6006], [6.69617, 13.34057], [6.94445, 12.99825], [7.0521, 13.00076], [7.12676, 13.02445], [7.22399, 13.1293], [7.39241, 13.09717], [7.81085, 13.34902], [8.07997, 13.30847], [8.25185, 13.20369], [8.41853, 13.06166], [8.49493, 13.07519], [8.60431, 13.01768], [8.64251, 12.93985], [8.97413, 12.83661], [9.65995, 12.80614], [10.00373, 13.18171], [10.19993, 13.27129], [10.46731, 13.28819], [10.66004, 13.36422], [11.4535, 13.37773], [11.88236, 13.2527], [12.04209, 13.14452], [12.16189, 13.10056], [12.19315, 13.12423], [12.47095, 13.06673], [12.58033, 13.27805], [12.6793, 13.29157], [12.87376, 13.48919], [13.05085, 13.53984], [13.19844, 13.52802], [13.33213, 13.71195], [13.6302, 13.71094], [13.47559, 14.40881], [13.48259, 14.46704], [13.68573, 14.55276], [13.67878, 14.64013], [13.809, 14.72915], [13.78991, 14.87519], [13.86301, 15.04043], [14.37425, 15.72591], [15.50373, 16.89649], [15.6032, 18.77402], [15.75098, 19.93002], [15.99632, 20.35364], [15.6721, 20.70069], [15.59841, 20.74039], [15.56004, 20.79488], [15.55382, 20.86507], [15.57248, 20.92138], [15.62515, 20.95395], [15.28332, 21.44557], [15.20213, 21.49365], [15.19692, 21.99339], [14.99751, 23.00539], [14.22918, 22.61719]]]] } },
22834     { type: "Feature", properties: { iso1A2: "NF", iso1A3: "NFK", iso1N3: "574", wikidata: "Q31057", nameEn: "Norfolk Island", country: "AU", groups: ["053", "009", "UN"], driveSide: "left", callingCodes: ["672 3"] }, geometry: { type: "MultiPolygon", coordinates: [[[[169.82316, -28.16667], [166.29505, -28.29175], [167.94076, -30.60745], [169.82316, -28.16667]]]] } },
22835     { type: "Feature", properties: { iso1A2: "NG", iso1A3: "NGA", iso1N3: "566", wikidata: "Q1033", nameEn: "Nigeria", groups: ["011", "202", "002", "UN"], callingCodes: ["234"] }, geometry: { type: "MultiPolygon", coordinates: [[[[6.15771, 13.64564], [5.52957, 13.8845], [5.35437, 13.83567], [5.27797, 13.75474], [5.21026, 13.73627], [5.07396, 13.75052], [4.9368, 13.7345], [4.87425, 13.78], [4.4668, 13.68286], [4.23456, 13.47725], [4.14186, 13.47586], [4.14367, 13.17189], [4.10006, 12.98862], [3.94339, 12.74979], [3.65111, 12.52223], [3.66364, 12.25884], [3.63136, 12.11826], [3.67775, 11.97599], [3.61955, 11.91847], [3.63063, 11.83042], [3.67122, 11.80865], [3.67988, 11.75429], [3.61075, 11.69181], [3.59375, 11.70269], [3.49175, 11.29765], [3.71505, 11.13015], [3.84243, 10.59316], [3.78292, 10.40538], [3.6844, 10.46351], [3.57275, 10.27185], [3.66908, 10.18136], [3.54429, 9.87739], [3.35383, 9.83641], [3.32099, 9.78032], [3.34726, 9.70696], [3.25093, 9.61632], [3.13928, 9.47167], [3.14147, 9.28375], [3.08017, 9.10006], [2.77907, 9.06924], [2.67523, 7.87825], [2.73095, 7.7755], [2.73405, 7.5423], [2.78668, 7.5116], [2.79442, 7.43486], [2.74489, 7.42565], [2.76965, 7.13543], [2.71702, 6.95722], [2.74024, 6.92802], [2.73405, 6.78508], [2.78823, 6.76356], [2.78204, 6.70514], [2.7325, 6.64057], [2.74334, 6.57291], [2.70464, 6.50831], [2.70566, 6.38038], [2.74181, 6.13349], [5.87055, 3.78489], [8.34397, 4.30689], [8.60302, 4.87353], [8.78027, 5.1243], [8.92029, 5.58403], [8.83687, 5.68483], [8.88156, 5.78857], [8.84209, 5.82562], [9.51757, 6.43874], [9.70674, 6.51717], [9.77824, 6.79088], [9.86314, 6.77756], [10.15135, 7.03781], [10.21466, 6.88996], [10.53639, 6.93432], [10.57214, 7.16345], [10.59746, 7.14719], [10.60789, 7.06885], [10.83727, 6.9358], [10.8179, 6.83377], [10.94302, 6.69325], [11.09644, 6.68437], [11.09495, 6.51717], [11.42041, 6.53789], [11.42264, 6.5882], [11.51499, 6.60892], [11.57755, 6.74059], [11.55818, 6.86186], [11.63117, 6.9905], [11.87396, 7.09398], [11.84864, 7.26098], [11.93205, 7.47812], [12.01844, 7.52981], [11.99908, 7.67302], [12.20909, 7.97553], [12.19271, 8.10826], [12.24782, 8.17904], [12.26123, 8.43696], [12.4489, 8.52536], [12.44146, 8.6152], [12.68722, 8.65938], [12.71701, 8.7595], [12.79, 8.75361], [12.81085, 8.91992], [12.90022, 9.11411], [12.91958, 9.33905], [12.85628, 9.36698], [13.02385, 9.49334], [13.22642, 9.57266], [13.25472, 9.76795], [13.29941, 9.8296], [13.25025, 9.86042], [13.24132, 9.91031], [13.27409, 9.93232], [13.286, 9.9822], [13.25323, 10.00127], [13.25025, 10.03647], [13.34111, 10.12299], [13.43644, 10.13326], [13.5705, 10.53183], [13.54964, 10.61236], [13.73434, 10.9255], [13.70753, 10.94451], [13.7403, 11.00593], [13.78945, 11.00154], [13.97489, 11.30258], [14.17821, 11.23831], [14.6124, 11.51283], [14.64591, 11.66166], [14.55207, 11.72001], [14.61612, 11.7798], [14.6474, 12.17466], [14.4843, 12.35223], [14.22215, 12.36533], [14.17523, 12.41916], [14.20204, 12.53405], [14.08251, 13.0797], [13.6302, 13.71094], [13.33213, 13.71195], [13.19844, 13.52802], [13.05085, 13.53984], [12.87376, 13.48919], [12.6793, 13.29157], [12.58033, 13.27805], [12.47095, 13.06673], [12.19315, 13.12423], [12.16189, 13.10056], [12.04209, 13.14452], [11.88236, 13.2527], [11.4535, 13.37773], [10.66004, 13.36422], [10.46731, 13.28819], [10.19993, 13.27129], [10.00373, 13.18171], [9.65995, 12.80614], [8.97413, 12.83661], [8.64251, 12.93985], [8.60431, 13.01768], [8.49493, 13.07519], [8.41853, 13.06166], [8.25185, 13.20369], [8.07997, 13.30847], [7.81085, 13.34902], [7.39241, 13.09717], [7.22399, 13.1293], [7.12676, 13.02445], [7.0521, 13.00076], [6.94445, 12.99825], [6.69617, 13.34057], [6.43053, 13.6006], [6.27411, 13.67835], [6.15771, 13.64564]]]] } },
22836     { type: "Feature", properties: { iso1A2: "NI", iso1A3: "NIC", iso1N3: "558", wikidata: "Q811", nameEn: "Nicaragua", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["505"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-83.13724, 15.00002], [-83.49268, 15.01158], [-83.62101, 14.89448], [-83.89551, 14.76697], [-84.10584, 14.76353], [-84.48373, 14.63249], [-84.70119, 14.68078], [-84.82596, 14.82212], [-84.90082, 14.80489], [-85.1575, 14.53934], [-85.18602, 14.24929], [-85.32149, 14.2562], [-85.45762, 14.11304], [-85.73964, 13.9698], [-85.75477, 13.8499], [-86.03458, 13.99181], [-86.00685, 14.08474], [-86.14801, 14.04317], [-86.35219, 13.77157], [-86.76812, 13.79605], [-86.71267, 13.30348], [-86.87066, 13.30641], [-86.93383, 13.18677], [-86.93197, 13.05313], [-87.03785, 12.98682], [-87.06306, 13.00892], [-87.37107, 12.98646], [-87.55124, 13.12523], [-87.7346, 13.13228], [-88.11443, 12.63306], [-86.14524, 11.09059], [-85.71223, 11.06868], [-85.60529, 11.22607], [-84.92439, 10.9497], [-84.68197, 11.07568], [-83.90838, 10.71161], [-83.66597, 10.79916], [-83.68276, 11.01562], [-82.56142, 11.91792], [-82.06974, 14.49418], [-83.04763, 15.03256], [-83.13724, 15.00002]]]] } },
22837     { type: "Feature", properties: { iso1A2: "NL", iso1A3: "NLD", iso1N3: "528", wikidata: "Q29999", nameEn: "Kingdom of the Netherlands" }, geometry: null },
22838     { type: "Feature", properties: { iso1A2: "NO", iso1A3: "NOR", iso1N3: "578", wikidata: "Q20", nameEn: "Norway" }, geometry: null },
22839     { type: "Feature", properties: { iso1A2: "NP", iso1A3: "NPL", iso1N3: "524", wikidata: "Q837", nameEn: "Nepal", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["977"] }, geometry: { type: "MultiPolygon", coordinates: [[[[88.13378, 27.88015], [87.82681, 27.95248], [87.72718, 27.80938], [87.56996, 27.84517], [87.11696, 27.84104], [87.03757, 27.94835], [86.75582, 28.04182], [86.74181, 28.10638], [86.56265, 28.09569], [86.51609, 27.96623], [86.42736, 27.91122], [86.22966, 27.9786], [86.18607, 28.17364], [86.088, 28.09264], [86.08333, 28.02121], [86.12069, 27.93047], [86.06309, 27.90021], [85.94946, 27.9401], [85.97813, 27.99023], [85.90743, 28.05144], [85.84672, 28.18187], [85.74864, 28.23126], [85.71907, 28.38064], [85.69105, 28.38475], [85.60854, 28.25045], [85.59765, 28.30529], [85.4233, 28.32996], [85.38127, 28.28336], [85.10729, 28.34092], [85.18668, 28.54076], [85.19135, 28.62825], [85.06059, 28.68562], [84.85511, 28.58041], [84.62317, 28.73887], [84.47528, 28.74023], [84.2231, 28.89571], [84.24801, 29.02783], [84.18107, 29.23451], [83.97559, 29.33091], [83.82303, 29.30513], [83.63156, 29.16249], [83.44787, 29.30513], [83.28131, 29.56813], [83.07116, 29.61957], [82.73024, 29.81695], [82.5341, 29.9735], [82.38622, 30.02608], [82.16984, 30.0692], [82.19475, 30.16884], [82.10757, 30.23745], [82.10135, 30.35439], [81.99082, 30.33423], [81.62033, 30.44703], [81.5459, 30.37688], [81.41018, 30.42153], [81.39928, 30.21862], [81.33355, 30.15303], [81.2623, 30.14596], [81.29032, 30.08806], [81.24362, 30.0126], [81.12842, 30.01395], [81.03953, 30.20059], [80.92547, 30.17193], [80.91143, 30.22173], [80.86673, 30.17321], [80.8778, 30.13384], [80.67076, 29.95732], [80.60226, 29.95732], [80.57179, 29.91422], [80.56247, 29.86661], [80.48997, 29.79566], [80.43458, 29.80466], [80.41554, 29.79451], [80.36803, 29.73865], [80.38428, 29.68513], [80.41858, 29.63581], [80.37939, 29.57098], [80.24322, 29.44299], [80.31428, 29.30784], [80.28626, 29.20327], [80.24112, 29.21414], [80.26602, 29.13938], [80.23178, 29.11626], [80.18085, 29.13649], [80.05743, 28.91479], [80.06957, 28.82763], [80.12125, 28.82346], [80.37188, 28.63371], [80.44504, 28.63098], [80.52443, 28.54897], [80.50575, 28.6706], [80.55142, 28.69182], [81.03471, 28.40054], [81.19847, 28.36284], [81.32923, 28.13521], [81.38683, 28.17638], [81.48179, 28.12148], [81.47867, 28.08303], [81.91223, 27.84995], [81.97214, 27.93322], [82.06554, 27.92222], [82.46405, 27.6716], [82.70378, 27.72122], [82.74119, 27.49838], [82.93261, 27.50328], [82.94938, 27.46036], [83.19413, 27.45632], [83.27197, 27.38309], [83.2673, 27.36235], [83.29999, 27.32778], [83.35136, 27.33885], [83.38872, 27.39276], [83.39495, 27.4798], [83.61288, 27.47013], [83.85595, 27.35797], [83.86182, 27.4241], [83.93306, 27.44939], [84.02229, 27.43836], [84.10791, 27.52399], [84.21376, 27.45218], [84.25735, 27.44941], [84.29315, 27.39], [84.62161, 27.33885], [84.69166, 27.21294], [84.64496, 27.04669], [84.793, 26.9968], [84.82913, 27.01989], [84.85754, 26.98984], [84.96687, 26.95599], [84.97186, 26.9149], [85.00536, 26.89523], [85.05592, 26.88991], [85.02635, 26.85381], [85.15883, 26.86966], [85.19291, 26.86909], [85.18046, 26.80519], [85.21159, 26.75933], [85.34302, 26.74954], [85.47752, 26.79292], [85.56471, 26.84133], [85.5757, 26.85955], [85.59461, 26.85161], [85.61621, 26.86721], [85.66239, 26.84822], [85.73483, 26.79613], [85.72315, 26.67471], [85.76907, 26.63076], [85.83126, 26.61134], [85.85126, 26.60866], [85.8492, 26.56667], [86.02729, 26.66756], [86.13596, 26.60651], [86.22513, 26.58863], [86.26235, 26.61886], [86.31564, 26.61925], [86.49726, 26.54218], [86.54258, 26.53819], [86.57073, 26.49825], [86.61313, 26.48658], [86.62686, 26.46891], [86.69124, 26.45169], [86.74025, 26.42386], [86.76797, 26.45892], [86.82898, 26.43919], [86.94543, 26.52076], [86.95912, 26.52076], [87.01559, 26.53228], [87.04691, 26.58685], [87.0707, 26.58571], [87.09147, 26.45039], [87.14751, 26.40542], [87.18863, 26.40558], [87.24682, 26.4143], [87.26587, 26.40592], [87.26568, 26.37294], [87.34568, 26.34787], [87.37314, 26.40815], [87.46566, 26.44058], [87.51571, 26.43106], [87.55274, 26.40596], [87.59175, 26.38342], [87.66803, 26.40294], [87.67893, 26.43501], [87.76004, 26.40711], [87.7918, 26.46737], [87.84193, 26.43663], [87.89085, 26.48565], [87.90115, 26.44923], [88.00895, 26.36029], [88.09414, 26.43732], [88.09963, 26.54195], [88.16452, 26.64111], [88.1659, 26.68177], [88.19107, 26.75516], [88.12302, 26.95324], [88.13422, 26.98705], [88.11719, 26.98758], [87.9887, 27.11045], [88.01587, 27.21388], [88.01646, 27.21612], [88.07277, 27.43007], [88.04008, 27.49223], [88.19107, 27.79285], [88.1973, 27.85067], [88.13378, 27.88015]]]] } },
22840     { type: "Feature", properties: { iso1A2: "NR", iso1A3: "NRU", iso1N3: "520", wikidata: "Q697", nameEn: "Nauru", groups: ["057", "009", "UN"], driveSide: "left", callingCodes: ["674"] }, geometry: { type: "MultiPolygon", coordinates: [[[[166.95155, 0.14829], [166.21778, -0.7977], [167.60042, -0.88259], [166.95155, 0.14829]]]] } },
22841     { type: "Feature", properties: { iso1A2: "NU", iso1A3: "NIU", iso1N3: "570", wikidata: "Q34020", nameEn: "Niue", country: "NZ", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["683"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-170.83899, -18.53439], [-170.82274, -20.44429], [-168.63096, -18.60489], [-170.83899, -18.53439]]]] } },
22842     { type: "Feature", properties: { iso1A2: "NZ", iso1A3: "NZL", iso1N3: "554", wikidata: "Q664", nameEn: "New Zealand" }, geometry: null },
22843     { type: "Feature", properties: { iso1A2: "OM", iso1A3: "OMN", iso1N3: "512", wikidata: "Q842", nameEn: "Oman", groups: ["145", "142", "UN"], callingCodes: ["968"] }, geometry: { type: "MultiPolygon", coordinates: [[[[56.82555, 25.7713], [56.79239, 26.41236], [56.68954, 26.76645], [56.2644, 26.58649], [55.81777, 26.18798], [56.08666, 26.05038], [56.15498, 26.06828], [56.19334, 25.9795], [56.13963, 25.82765], [56.17416, 25.77239], [56.13579, 25.73524], [56.14826, 25.66351], [56.18363, 25.65508], [56.20473, 25.61119], [56.25365, 25.60211], [56.26636, 25.60643], [56.25341, 25.61443], [56.26534, 25.62825], [56.82555, 25.7713]]], [[[56.26062, 25.33108], [56.23362, 25.31253], [56.25008, 25.28843], [56.24465, 25.27505], [56.20838, 25.25668], [56.20872, 25.24104], [56.24341, 25.22867], [56.27628, 25.23404], [56.34438, 25.26653], [56.35172, 25.30681], [56.3111, 25.30107], [56.3005, 25.31815], [56.26062, 25.33108]], [[56.28423, 25.26344], [56.27086, 25.26128], [56.2716, 25.27916], [56.28102, 25.28486], [56.29379, 25.2754], [56.28423, 25.26344]]], [[[61.45114, 22.55394], [56.86325, 25.03856], [56.3227, 24.97284], [56.34873, 24.93205], [56.30269, 24.88334], [56.20568, 24.85063], [56.20062, 24.78565], [56.13684, 24.73699], [56.06128, 24.74457], [56.03535, 24.81161], [55.97836, 24.87673], [55.97467, 24.89639], [56.05106, 24.87461], [56.05715, 24.95727], [55.96316, 25.00857], [55.90849, 24.96771], [55.85094, 24.96858], [55.81116, 24.9116], [55.81348, 24.80102], [55.83408, 24.77858], [55.83271, 24.68567], [55.76461, 24.5287], [55.83271, 24.41521], [55.83395, 24.32776], [55.80747, 24.31069], [55.79145, 24.27914], [55.76781, 24.26209], [55.75939, 24.26114], [55.75382, 24.2466], [55.75257, 24.23466], [55.76558, 24.23227], [55.77658, 24.23476], [55.83367, 24.20193], [55.95472, 24.2172], [56.01799, 24.07426], [55.8308, 24.01633], [55.73301, 24.05994], [55.48677, 23.94946], [55.57358, 23.669], [55.22634, 23.10378], [55.2137, 22.71065], [55.66469, 21.99658], [54.99756, 20.00083], [52.00311, 19.00083], [52.78009, 17.35124], [52.74267, 17.29519], [52.81185, 17.28568], [57.49095, 8.14549], [61.45114, 22.55394]]]] } },
22844     { type: "Feature", properties: { iso1A2: "PA", iso1A3: "PAN", iso1N3: "591", wikidata: "Q804", nameEn: "Panama", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["507"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-77.32389, 8.81247], [-77.58292, 9.22278], [-78.79327, 9.93766], [-82.51044, 9.65379], [-82.56507, 9.57279], [-82.61345, 9.49881], [-82.66667, 9.49746], [-82.77206, 9.59573], [-82.87919, 9.62645], [-82.84871, 9.4973], [-82.93516, 9.46741], [-82.93516, 9.07687], [-82.72126, 8.97125], [-82.88253, 8.83331], [-82.91377, 8.774], [-82.92068, 8.74832], [-82.8794, 8.6981], [-82.82739, 8.60153], [-82.83975, 8.54755], [-82.83322, 8.52464], [-82.8382, 8.48117], [-82.8679, 8.44042], [-82.93056, 8.43465], [-83.05209, 8.33394], [-82.9388, 8.26634], [-82.88641, 8.10219], [-82.89137, 8.05755], [-82.89978, 8.04083], [-82.94503, 7.93865], [-82.13751, 6.97312], [-78.06168, 7.07793], [-77.89178, 7.22681], [-77.81426, 7.48319], [-77.72157, 7.47612], [-77.72514, 7.72348], [-77.57185, 7.51147], [-77.17257, 7.97422], [-77.45064, 8.49991], [-77.32389, 8.81247]]]] } },
22845     { type: "Feature", properties: { iso1A2: "PE", iso1A3: "PER", iso1N3: "604", wikidata: "Q419", nameEn: "Peru", groups: ["005", "419", "019", "UN"], callingCodes: ["51"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-74.26675, -0.97229], [-74.42701, -0.50218], [-75.18513, -0.0308], [-75.25764, -0.11943], [-75.40192, -0.17196], [-75.61997, -0.10012], [-75.60169, -0.18708], [-75.53615, -0.19213], [-75.22862, -0.60048], [-75.22862, -0.95588], [-75.3872, -0.9374], [-75.57429, -1.55961], [-76.05203, -2.12179], [-76.6324, -2.58397], [-77.94147, -3.05454], [-78.19369, -3.36431], [-78.14324, -3.47653], [-78.22642, -3.51113], [-78.24589, -3.39907], [-78.34362, -3.38633], [-78.68394, -4.60754], [-78.85149, -4.66795], [-79.01659, -5.01481], [-79.1162, -4.97774], [-79.26248, -4.95167], [-79.59402, -4.46848], [-79.79722, -4.47558], [-80.13945, -4.29786], [-80.39256, -4.48269], [-80.46386, -4.41516], [-80.32114, -4.21323], [-80.45023, -4.20938], [-80.4822, -4.05477], [-80.46386, -4.01342], [-80.13232, -3.90317], [-80.19926, -3.68894], [-80.18741, -3.63994], [-80.19848, -3.59249], [-80.21642, -3.5888], [-80.20535, -3.51667], [-80.22629, -3.501], [-80.23651, -3.48652], [-80.24586, -3.48677], [-80.24123, -3.46124], [-80.20647, -3.431], [-80.30602, -3.39149], [-84.52388, -3.36941], [-85.71054, -21.15413], [-70.59118, -18.35072], [-70.378, -18.3495], [-70.31267, -18.31258], [-70.16394, -18.31737], [-69.96732, -18.25992], [-69.81607, -18.12582], [-69.75305, -17.94605], [-69.82868, -17.72048], [-69.79087, -17.65563], [-69.66483, -17.65083], [-69.46897, -17.4988], [-69.46863, -17.37466], [-69.62883, -17.28142], [-69.16896, -16.72233], [-69.00853, -16.66769], [-69.04027, -16.57214], [-68.98358, -16.42165], [-68.79464, -16.33272], [-68.96238, -16.194], [-69.09986, -16.22693], [-69.20291, -16.16668], [-69.40336, -15.61358], [-69.14856, -15.23478], [-69.36254, -14.94634], [-68.88135, -14.18639], [-69.05265, -13.68546], [-68.8864, -13.40792], [-68.85615, -12.87769], [-68.65044, -12.50689], [-68.98115, -11.8979], [-69.57156, -10.94555], [-69.57835, -10.94051], [-69.90896, -10.92744], [-70.38791, -11.07096], [-70.51395, -10.92249], [-70.64134, -11.0108], [-70.62487, -9.80666], [-70.55429, -9.76692], [-70.58453, -9.58303], [-70.53373, -9.42628], [-71.23394, -9.9668], [-72.14742, -9.98049], [-72.31883, -9.5184], [-72.72216, -9.41397], [-73.21498, -9.40904], [-72.92886, -9.04074], [-73.76576, -7.89884], [-73.65485, -7.77897], [-73.96938, -7.58465], [-73.77011, -7.28944], [-73.73986, -6.87919], [-73.12983, -6.43852], [-73.24579, -6.05764], [-72.83973, -5.14765], [-72.64391, -5.0391], [-71.87003, -4.51661], [-70.96814, -4.36915], [-70.77601, -4.15717], [-70.33236, -4.15214], [-70.19582, -4.3607], [-70.11305, -4.27281], [-70.00888, -4.37833], [-69.94708, -4.2431], [-70.3374, -3.79505], [-70.52393, -3.87553], [-70.71396, -3.7921], [-70.04609, -2.73906], [-70.94377, -2.23142], [-71.75223, -2.15058], [-72.92587, -2.44514], [-73.65312, -1.26222], [-74.26675, -0.97229]]]] } },
22846     { type: "Feature", properties: { iso1A2: "PF", iso1A3: "PYF", iso1N3: "258", wikidata: "Q30971", nameEn: "French Polynesia", country: "FR", groups: ["EU", "Q1451600", "061", "009", "UN"], callingCodes: ["689"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-135.59706, -4.70473], [-156.48634, -15.52824], [-156.45576, -31.75456], [-133.59543, -28.4709], [-135.59706, -4.70473]]]] } },
22847     { type: "Feature", properties: { iso1A2: "PG", iso1A3: "PNG", iso1N3: "598", wikidata: "Q691", nameEn: "Papua New Guinea", groups: ["054", "009", "UN"], driveSide: "left", callingCodes: ["675"] }, geometry: { type: "MultiPolygon", coordinates: [[[[141.03157, 2.12829], [140.99813, -6.3233], [140.85295, -6.72996], [140.90448, -6.85033], [141.01763, -6.90181], [141.01842, -9.35091], [141.88934, -9.36111], [142.19246, -9.15378], [142.48658, -9.36754], [143.29772, -9.33993], [143.87386, -9.02382], [145.2855, -9.62524], [156.73836, -14.50464], [154.74815, -7.33315], [155.60735, -6.92266], [155.69784, -6.92661], [155.92557, -6.84664], [156.03993, -6.65703], [156.03296, -6.55528], [160.43769, -4.17974], [141.03157, 2.12829]]]] } },
22848     { type: "Feature", properties: { iso1A2: "PH", iso1A3: "PHL", iso1N3: "608", wikidata: "Q928", nameEn: "Philippines", aliases: ["PI", "RP"], groups: ["035", "142", "UN"], callingCodes: ["63"] }, geometry: { type: "MultiPolygon", coordinates: [[[[129.19694, 7.84182], [121.8109, 21.77688], [120.69238, 21.52331], [118.82252, 14.67191], [115.39742, 10.92666], [116.79524, 7.43869], [117.17735, 7.52841], [117.93857, 6.89845], [117.98544, 6.27477], [119.52945, 5.35672], [118.93936, 4.09009], [118.06469, 4.16638], [121.14448, 2.12444], [129.19694, 7.84182]]]] } },
22849     { type: "Feature", properties: { iso1A2: "PK", iso1A3: "PAK", iso1N3: "586", wikidata: "Q843", nameEn: "Pakistan", groups: ["034", "142", "UN"], driveSide: "left", callingCodes: ["92"] }, geometry: { type: "MultiPolygon", coordinates: [[[[75.72737, 36.7529], [75.45562, 36.71971], [75.40481, 36.95382], [75.13839, 37.02622], [74.56453, 37.03023], [74.53739, 36.96224], [74.43389, 37.00977], [74.04856, 36.82648], [73.82685, 36.91421], [72.6323, 36.84601], [72.18135, 36.71838], [71.80267, 36.49924], [71.60491, 36.39429], [71.19505, 36.04134], [71.37969, 35.95865], [71.55273, 35.71483], [71.49917, 35.6267], [71.65435, 35.4479], [71.54294, 35.31037], [71.5541, 35.28776], [71.67495, 35.21262], [71.52938, 35.09023], [71.55273, 35.02615], [71.49917, 35.00478], [71.50329, 34.97328], [71.29472, 34.87728], [71.28356, 34.80882], [71.08718, 34.69034], [71.11602, 34.63047], [71.0089, 34.54568], [71.02401, 34.44835], [71.17662, 34.36769], [71.12815, 34.26619], [71.13078, 34.16503], [71.09453, 34.13524], [71.09307, 34.11961], [71.06933, 34.10564], [71.07345, 34.06242], [70.88119, 33.97933], [70.54336, 33.9463], [69.90203, 34.04194], [69.87307, 33.9689], [69.85671, 33.93719], [70.00503, 33.73528], [70.14236, 33.71701], [70.14785, 33.6553], [70.20141, 33.64387], [70.17062, 33.53535], [70.32775, 33.34496], [70.13686, 33.21064], [70.07369, 33.22557], [70.02563, 33.14282], [69.85259, 33.09451], [69.79766, 33.13247], [69.71526, 33.09911], [69.57656, 33.09911], [69.49004, 33.01509], [69.49854, 32.88843], [69.5436, 32.8768], [69.47082, 32.85834], [69.38018, 32.76601], [69.43649, 32.7302], [69.44747, 32.6678], [69.38155, 32.56601], [69.2868, 32.53938], [69.23599, 32.45946], [69.27932, 32.29119], [69.27032, 32.14141], [69.3225, 31.93186], [69.20577, 31.85957], [69.11514, 31.70782], [69.00939, 31.62249], [68.95995, 31.64822], [68.91078, 31.59687], [68.79997, 31.61665], [68.6956, 31.75687], [68.57475, 31.83158], [68.44222, 31.76446], [68.27605, 31.75863], [68.25614, 31.80357], [68.1655, 31.82691], [68.00071, 31.6564], [67.86887, 31.63536], [67.72056, 31.52304], [67.58323, 31.52772], [67.62374, 31.40473], [67.7748, 31.4188], [67.78854, 31.33203], [67.29964, 31.19586], [67.03323, 31.24519], [67.04147, 31.31561], [66.83273, 31.26867], [66.72561, 31.20526], [66.68166, 31.07597], [66.58175, 30.97532], [66.42645, 30.95309], [66.39194, 30.9408], [66.28413, 30.57001], [66.34869, 30.404], [66.23609, 30.06321], [66.36042, 29.9583], [66.24175, 29.85181], [65.04005, 29.53957], [64.62116, 29.58903], [64.19796, 29.50407], [64.12966, 29.39157], [63.5876, 29.50456], [62.47751, 29.40782], [60.87231, 29.86514], [61.31508, 29.38903], [61.53765, 29.00507], [61.65978, 28.77937], [61.93581, 28.55284], [62.40259, 28.42703], [62.59499, 28.24842], [62.79412, 28.28108], [62.7638, 28.02992], [62.84905, 27.47627], [62.79684, 27.34381], [62.80604, 27.22412], [63.19649, 27.25674], [63.32283, 27.14437], [63.25005, 27.08692], [63.25005, 26.84212], [63.18688, 26.83844], [63.1889, 26.65072], [62.77352, 26.64099], [62.31484, 26.528], [62.21304, 26.26601], [62.05117, 26.31647], [61.89391, 26.26251], [61.83831, 26.07249], [61.83968, 25.7538], [61.683, 25.66638], [61.6433, 25.27541], [61.46682, 24.57869], [68.11329, 23.53945], [68.20763, 23.85849], [68.39339, 23.96838], [68.74643, 23.97027], [68.7416, 24.31904], [68.90914, 24.33156], [68.97781, 24.26021], [69.07806, 24.29777], [69.19341, 24.25646], [69.29778, 24.28712], [69.59579, 24.29777], [69.73335, 24.17007], [70.03428, 24.172], [70.11712, 24.30915], [70.5667, 24.43787], [70.57906, 24.27774], [70.71502, 24.23517], [70.88393, 24.27398], [70.85784, 24.30903], [70.94985, 24.3791], [71.04461, 24.34657], [71.12838, 24.42662], [71.00341, 24.46038], [70.97594, 24.60904], [71.09405, 24.69017], [70.94002, 24.92843], [70.89148, 25.15064], [70.66695, 25.39314], [70.67382, 25.68186], [70.60378, 25.71898], [70.53649, 25.68928], [70.37444, 25.67443], [70.2687, 25.71156], [70.0985, 25.93238], [70.08193, 26.08094], [70.17532, 26.24118], [70.17532, 26.55362], [70.05584, 26.60398], [69.88555, 26.56836], [69.50904, 26.74892], [69.58519, 27.18109], [70.03136, 27.56627], [70.12502, 27.8057], [70.37307, 28.01208], [70.60927, 28.02178], [70.79054, 27.68423], [71.89921, 27.96035], [71.9244, 28.11555], [72.20329, 28.3869], [72.29495, 28.66367], [72.40402, 28.78283], [72.94272, 29.02487], [73.01337, 29.16422], [73.05886, 29.1878], [73.28094, 29.56646], [73.3962, 29.94707], [73.58665, 30.01848], [73.80299, 30.06969], [73.97225, 30.19829], [73.95736, 30.28466], [73.88993, 30.36305], [74.5616, 31.04153], [74.67971, 31.05479], [74.6852, 31.12771], [74.60006, 31.13711], [74.60281, 31.10419], [74.56023, 31.08303], [74.51629, 31.13829], [74.53223, 31.30321], [74.59773, 31.4136], [74.64713, 31.45605], [74.59319, 31.50197], [74.61517, 31.55698], [74.57498, 31.60382], [74.47771, 31.72227], [74.58907, 31.87824], [74.79919, 31.95983], [74.86236, 32.04485], [74.9269, 32.0658], [75.00793, 32.03786], [75.25649, 32.10187], [75.38046, 32.26836], [75.28259, 32.36556], [75.03265, 32.49538], [74.97634, 32.45367], [74.84725, 32.49075], [74.68362, 32.49298], [74.67431, 32.56676], [74.65251, 32.56416], [74.64424, 32.60985], [74.69542, 32.66792], [74.65345, 32.71225], [74.7113, 32.84219], [74.64675, 32.82604], [74.6289, 32.75561], [74.45312, 32.77755], [74.41467, 32.90563], [74.31227, 32.92795], [74.34875, 32.97823], [74.31854, 33.02891], [74.17571, 33.07495], [74.15374, 33.13477], [74.02144, 33.18908], [74.01366, 33.25199], [74.08782, 33.26232], [74.17983, 33.3679], [74.18121, 33.4745], [74.10115, 33.56392], [74.03576, 33.56718], [73.97367, 33.64061], [73.98968, 33.66155], [73.96423, 33.73071], [74.00891, 33.75437], [74.05898, 33.82089], [74.14001, 33.83002], [74.26086, 33.92237], [74.25262, 34.01577], [74.21554, 34.03853], [73.91341, 34.01235], [73.88732, 34.05105], [73.90677, 34.10504], [73.98208, 34.2522], [73.90517, 34.35317], [73.8475, 34.32935], [73.74862, 34.34183], [73.74999, 34.3781], [73.88732, 34.48911], [73.89419, 34.54568], [73.93951, 34.57169], [73.93401, 34.63386], [73.96423, 34.68244], [74.12897, 34.70073], [74.31239, 34.79626], [74.58083, 34.77386], [74.6663, 34.703], [75.01479, 34.64629], [75.38009, 34.55021], [75.75438, 34.51827], [76.04614, 34.67566], [76.15463, 34.6429], [76.47186, 34.78965], [76.67648, 34.76371], [76.74377, 34.84039], [76.74514, 34.92488], [76.87193, 34.96906], [76.99251, 34.93349], [77.11796, 35.05419], [76.93465, 35.39866], [76.85088, 35.39754], [76.75475, 35.52617], [76.77323, 35.66062], [76.50961, 35.8908], [76.33453, 35.84296], [76.14913, 35.82848], [76.15325, 35.9264], [75.93028, 36.13136], [76.00906, 36.17511], [76.0324, 36.41198], [75.92391, 36.56986], [75.72737, 36.7529]]]] } },
22850     { type: "Feature", properties: { iso1A2: "PL", iso1A3: "POL", iso1N3: "616", wikidata: "Q36", nameEn: "Poland", groups: ["EU", "151", "150", "UN"], callingCodes: ["48"] }, geometry: { type: "MultiPolygon", coordinates: [[[[18.57853, 55.25302], [14.20811, 54.12784], [14.22634, 53.9291], [14.20647, 53.91671], [14.18544, 53.91258], [14.20823, 53.90776], [14.21323, 53.8664], [14.27249, 53.74464], [14.26782, 53.69866], [14.2836, 53.67721], [14.27133, 53.66613], [14.28477, 53.65955], [14.2853, 53.63392], [14.31904, 53.61581], [14.30416, 53.55499], [14.3273, 53.50587], [14.35209, 53.49506], [14.4215, 53.27724], [14.44133, 53.27427], [14.45125, 53.26241], [14.40662, 53.21098], [14.37853, 53.20405], [14.36696, 53.16444], [14.38679, 53.13669], [14.35044, 53.05829], [14.25954, 53.00264], [14.14056, 52.95786], [14.15873, 52.87715], [14.12256, 52.84311], [14.13806, 52.82392], [14.22071, 52.81175], [14.61073, 52.59847], [14.6289, 52.57136], [14.60081, 52.53116], [14.63056, 52.48993], [14.54423, 52.42568], [14.55228, 52.35264], [14.56378, 52.33838], [14.58149, 52.28007], [14.70139, 52.25038], [14.71319, 52.22144], [14.68344, 52.19612], [14.70616, 52.16927], [14.67683, 52.13936], [14.6917, 52.10283], [14.72971, 52.09167], [14.76026, 52.06624], [14.71339, 52.00337], [14.70488, 51.97679], [14.7139, 51.95643], [14.71836, 51.95606], [14.72163, 51.95188], [14.7177, 51.94048], [14.70601, 51.92944], [14.6933, 51.9044], [14.6588, 51.88359], [14.59089, 51.83302], [14.60493, 51.80473], [14.64625, 51.79472], [14.66386, 51.73282], [14.69065, 51.70842], [14.75392, 51.67445], [14.75759, 51.62318], [14.7727, 51.61263], [14.71125, 51.56209], [14.73047, 51.54606], [14.72652, 51.53902], [14.73219, 51.52922], [14.94749, 51.47155], [14.9652, 51.44793], [14.96899, 51.38367], [14.98008, 51.33449], [15.04288, 51.28387], [15.01242, 51.21285], [15.0047, 51.16874], [14.99311, 51.16249], [14.99414, 51.15813], [15.00083, 51.14974], [14.99646, 51.14365], [14.99079, 51.14284], [14.99689, 51.12205], [14.98229, 51.11354], [14.97938, 51.07742], [14.95529, 51.04552], [14.92942, 50.99744], [14.89252, 50.94999], [14.89681, 50.9422], [14.81664, 50.88148], [14.82803, 50.86966], [14.99852, 50.86817], [15.01088, 50.97984], [14.96419, 50.99108], [15.02433, 51.0242], [15.03895, 51.0123], [15.06218, 51.02269], [15.10152, 51.01095], [15.11937, 50.99021], [15.16744, 51.01959], [15.1743, 50.9833], [15.2361, 50.99886], [15.27043, 50.97724], [15.2773, 50.8907], [15.36656, 50.83956], [15.3803, 50.77187], [15.43798, 50.80833], [15.73186, 50.73885], [15.81683, 50.75666], [15.87331, 50.67188], [15.97219, 50.69799], [16.0175, 50.63009], [15.98317, 50.61528], [16.02437, 50.60046], [16.10265, 50.66405], [16.20839, 50.63096], [16.23174, 50.67101], [16.33611, 50.66579], [16.44597, 50.58041], [16.34572, 50.49575], [16.31413, 50.50274], [16.19526, 50.43291], [16.21585, 50.40627], [16.22821, 50.41054], [16.28118, 50.36891], [16.30289, 50.38292], [16.36495, 50.37679], [16.3622, 50.34875], [16.39379, 50.3207], [16.42674, 50.32509], [16.56407, 50.21009], [16.55446, 50.16613], [16.63137, 50.1142], [16.7014, 50.09659], [16.8456, 50.20834], [16.98018, 50.24172], [17.00353, 50.21449], [17.02825, 50.23118], [16.99803, 50.25753], [17.02138, 50.27772], [16.99803, 50.30316], [16.94448, 50.31281], [16.90877, 50.38642], [16.85933, 50.41093], [16.89229, 50.45117], [17.1224, 50.39494], [17.14498, 50.38117], [17.19579, 50.38817], [17.19991, 50.3654], [17.27681, 50.32246], [17.34273, 50.32947], [17.34548, 50.2628], [17.3702, 50.28123], [17.58889, 50.27837], [17.67764, 50.28977], [17.69292, 50.32859], [17.74648, 50.29966], [17.72176, 50.25665], [17.76296, 50.23382], [17.70528, 50.18812], [17.59404, 50.16437], [17.66683, 50.10275], [17.6888, 50.12037], [17.7506, 50.07896], [17.77669, 50.02253], [17.86886, 49.97452], [18.00191, 50.01723], [18.04585, 50.01194], [18.04585, 50.03311], [18.00396, 50.04954], [18.03212, 50.06574], [18.07898, 50.04535], [18.10628, 50.00223], [18.20241, 49.99958], [18.21752, 49.97309], [18.27107, 49.96779], [18.27794, 49.93863], [18.31914, 49.91565], [18.33278, 49.92415], [18.33562, 49.94747], [18.41604, 49.93498], [18.53423, 49.89906], [18.54495, 49.9079], [18.54299, 49.92537], [18.57697, 49.91565], [18.57045, 49.87849], [18.60341, 49.86256], [18.57183, 49.83334], [18.61278, 49.7618], [18.61368, 49.75426], [18.62645, 49.75002], [18.62943, 49.74603], [18.62676, 49.71983], [18.69817, 49.70473], [18.72838, 49.68163], [18.80479, 49.6815], [18.84786, 49.5446], [18.84521, 49.51672], [18.94536, 49.52143], [18.97283, 49.49914], [18.9742, 49.39557], [19.18019, 49.41165], [19.25435, 49.53391], [19.36009, 49.53747], [19.37795, 49.574], [19.45348, 49.61583], [19.52626, 49.57311], [19.53313, 49.52856], [19.57845, 49.46077], [19.64162, 49.45184], [19.6375, 49.40897], [19.72127, 49.39288], [19.78581, 49.41701], [19.82237, 49.27806], [19.75286, 49.20751], [19.86409, 49.19316], [19.90529, 49.23532], [19.98494, 49.22904], [20.08238, 49.1813], [20.13738, 49.31685], [20.21977, 49.35265], [20.31453, 49.34817], [20.31728, 49.39914], [20.39939, 49.3896], [20.46422, 49.41612], [20.5631, 49.375], [20.61666, 49.41791], [20.72274, 49.41813], [20.77971, 49.35383], [20.9229, 49.29626], [20.98733, 49.30774], [21.09799, 49.37176], [21.041, 49.41791], [21.12477, 49.43666], [21.19756, 49.4054], [21.27858, 49.45988], [21.43376, 49.41433], [21.62328, 49.4447], [21.77983, 49.35443], [21.82927, 49.39467], [21.96385, 49.3437], [22.04427, 49.22136], [22.56155, 49.08865], [22.89122, 49.00725], [22.86336, 49.10513], [22.72009, 49.20288], [22.748, 49.32759], [22.69444, 49.49378], [22.64534, 49.53094], [22.78304, 49.65543], [22.80261, 49.69098], [22.83179, 49.69875], [22.99329, 49.84249], [23.28221, 50.0957], [23.67635, 50.33385], [23.71382, 50.38248], [23.79445, 50.40481], [23.99563, 50.41289], [24.03668, 50.44507], [24.07048, 50.5071], [24.0996, 50.60752], [24.0595, 50.71625], [23.95925, 50.79271], [23.99254, 50.83847], [24.0952, 50.83262], [24.14524, 50.86128], [24.04576, 50.90196], [23.92217, 51.00836], [23.90376, 51.07697], [23.80678, 51.18405], [23.63858, 51.32182], [23.69905, 51.40871], [23.62751, 51.50512], [23.56236, 51.53673], [23.57053, 51.55938], [23.53198, 51.74298], [23.62691, 51.78208], [23.61523, 51.92066], [23.68733, 51.9906], [23.64066, 52.07626], [23.61, 52.11264], [23.54314, 52.12148], [23.47859, 52.18215], [23.20071, 52.22848], [23.18196, 52.28812], [23.34141, 52.44845], [23.45112, 52.53774], [23.58296, 52.59868], [23.73615, 52.6149], [23.93763, 52.71332], [23.91805, 52.94016], [23.94689, 52.95919], [23.92184, 53.02079], [23.87548, 53.0831], [23.91393, 53.16469], [23.85657, 53.22923], [23.81995, 53.24131], [23.62004, 53.60942], [23.51284, 53.95052], [23.48261, 53.98855], [23.52702, 54.04622], [23.49196, 54.14764], [23.45223, 54.17775], [23.42418, 54.17911], [23.39525, 54.21672], [23.3494, 54.25155], [23.24656, 54.25701], [23.15938, 54.29894], [23.15526, 54.31076], [23.13905, 54.31567], [23.104, 54.29794], [23.04323, 54.31567], [23.05726, 54.34565], [22.99649, 54.35927], [23.00584, 54.38514], [22.83756, 54.40827], [22.79705, 54.36264], [21.41123, 54.32395], [20.63871, 54.3706], [19.8038, 54.44203], [19.64312, 54.45423], [18.57853, 55.25302]]]] } },
22851     { type: "Feature", properties: { iso1A2: "PM", iso1A3: "SPM", iso1N3: "666", wikidata: "Q34617", nameEn: "Saint Pierre and Miquelon", country: "FR", groups: ["EU", "Q1451600", "021", "003", "019", "UN"], callingCodes: ["508"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-56.72993, 46.65575], [-55.90758, 46.6223], [-56.27503, 47.39728], [-56.72993, 46.65575]]]] } },
22852     { type: "Feature", properties: { iso1A2: "PN", iso1A3: "PCN", iso1N3: "612", wikidata: "Q35672", nameEn: "Pitcairn Islands", country: "GB", groups: ["BOTS", "061", "009", "UN"], driveSide: "left", callingCodes: ["64"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-133.59543, -28.4709], [-122.0366, -24.55017], [-133.61511, -21.93325], [-133.59543, -28.4709]]]] } },
22853     { type: "Feature", properties: { iso1A2: "PR", iso1A3: "PRI", iso1N3: "630", wikidata: "Q1183", nameEn: "Puerto Rico", aliases: ["US-PR"], country: "US", groups: ["Q1352230", "029", "003", "419", "019", "UN"], roadSpeedUnit: "mph", callingCodes: ["1 787", "1 939"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-65.27974, 17.56928], [-65.02435, 18.73231], [-67.99519, 18.97186], [-68.23894, 17.84663], [-65.27974, 17.56928]]]] } },
22854     { type: "Feature", properties: { iso1A2: "PS", iso1A3: "PSE", iso1N3: "275", wikidata: "Q219060", nameEn: "Palestine" }, geometry: null },
22855     { type: "Feature", properties: { iso1A2: "PT", iso1A3: "PRT", iso1N3: "620", wikidata: "Q45", nameEn: "Portugal" }, geometry: null },
22856     { type: "Feature", properties: { iso1A2: "PW", iso1A3: "PLW", iso1N3: "585", wikidata: "Q695", nameEn: "Palau", groups: ["057", "009", "UN"], roadSpeedUnit: "mph", callingCodes: ["680"] }, geometry: { type: "MultiPolygon", coordinates: [[[[128.97621, 3.08804], [136.39296, 1.54187], [136.04605, 12.45908], [128.97621, 3.08804]]]] } },
22857     { type: "Feature", properties: { iso1A2: "PY", iso1A3: "PRY", iso1N3: "600", wikidata: "Q733", nameEn: "Paraguay", groups: ["005", "419", "019", "UN"], callingCodes: ["595"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-58.16225, -20.16193], [-58.23216, -19.80058], [-59.06965, -19.29148], [-60.00638, -19.2981], [-61.73723, -19.63958], [-61.93912, -20.10053], [-62.26883, -20.55311], [-62.2757, -21.06657], [-62.64455, -22.25091], [-62.51761, -22.37684], [-62.22768, -22.55807], [-61.9756, -23.0507], [-61.0782, -23.62932], [-60.99754, -23.80934], [-60.28163, -24.04436], [-60.03367, -24.00701], [-59.45482, -24.34787], [-59.33886, -24.49935], [-58.33055, -24.97099], [-58.25492, -24.92528], [-57.80821, -25.13863], [-57.57431, -25.47269], [-57.87176, -25.93604], [-58.1188, -26.16704], [-58.3198, -26.83443], [-58.65321, -27.14028], [-58.59549, -27.29973], [-58.04205, -27.2387], [-56.85337, -27.5165], [-56.18313, -27.29851], [-55.89195, -27.3467], [-55.74475, -27.44485], [-55.59094, -27.32444], [-55.62322, -27.1941], [-55.39611, -26.97679], [-55.25243, -26.93808], [-55.16948, -26.96068], [-55.06351, -26.80195], [-55.00584, -26.78754], [-54.80868, -26.55669], [-54.70732, -26.45099], [-54.69333, -26.37705], [-54.67359, -25.98607], [-54.60664, -25.9691], [-54.62063, -25.91213], [-54.59398, -25.59224], [-54.59509, -25.53696], [-54.60196, -25.48397], [-54.62033, -25.46026], [-54.4423, -25.13381], [-54.28207, -24.07305], [-54.32807, -24.01865], [-54.6238, -23.83078], [-55.02691, -23.97317], [-55.0518, -23.98666], [-55.12292, -23.99669], [-55.41784, -23.9657], [-55.44117, -23.9185], [-55.43585, -23.87157], [-55.5555, -23.28237], [-55.52288, -23.2595], [-55.5446, -23.22811], [-55.63849, -22.95122], [-55.62493, -22.62765], [-55.68742, -22.58407], [-55.6986, -22.56268], [-55.72366, -22.5519], [-55.741, -22.52018], [-55.74941, -22.46436], [-55.8331, -22.29008], [-56.23206, -22.25347], [-56.45893, -22.08072], [-56.5212, -22.11556], [-56.6508, -22.28387], [-57.98625, -22.09157], [-57.94642, -21.73799], [-57.88239, -21.6868], [-57.93492, -21.65505], [-57.84536, -20.93155], [-58.16225, -20.16193]]]] } },
22858     { type: "Feature", properties: { iso1A2: "QA", iso1A3: "QAT", iso1N3: "634", wikidata: "Q846", nameEn: "Qatar", groups: ["145", "142", "UN"], callingCodes: ["974"] }, geometry: { type: "MultiPolygon", coordinates: [[[[50.92992, 24.54396], [51.09638, 24.46907], [51.29972, 24.50747], [51.39468, 24.62785], [51.58834, 24.66608], [51.83108, 24.71675], [51.83682, 26.70231], [50.93865, 26.30758], [50.81266, 25.88946], [50.86149, 25.6965], [50.7801, 25.595], [50.80824, 25.54641], [50.57069, 25.57887], [50.8133, 24.74049], [50.92992, 24.54396]]]] } },
22859     { type: "Feature", properties: { iso1A2: "RE", iso1A3: "REU", iso1N3: "638", wikidata: "Q17070", nameEn: "R\xE9union", country: "FR", groups: ["Q3320166", "EU", "014", "202", "002", "UN"], callingCodes: ["262"] }, geometry: { type: "MultiPolygon", coordinates: [[[[53.37984, -21.23941], [56.73473, -21.9174], [56.62373, -20.2711], [53.37984, -21.23941]]]] } },
22860     { type: "Feature", properties: { iso1A2: "RO", iso1A3: "ROU", iso1N3: "642", wikidata: "Q218", nameEn: "Romania", groups: ["EU", "151", "150", "UN"], callingCodes: ["40"] }, geometry: { type: "MultiPolygon", coordinates: [[[[27.15622, 47.98538], [27.02985, 48.09083], [27.04118, 48.12522], [26.96119, 48.13003], [26.98042, 48.15752], [26.94265, 48.1969], [26.87708, 48.19919], [26.81161, 48.25049], [26.62823, 48.25804], [26.55202, 48.22445], [26.33504, 48.18418], [26.17711, 47.99246], [26.05901, 47.9897], [25.77723, 47.93919], [25.63878, 47.94924], [25.23778, 47.89403], [25.11144, 47.75203], [24.88896, 47.7234], [24.81893, 47.82031], [24.70632, 47.84428], [24.61994, 47.95062], [24.43578, 47.97131], [24.34926, 47.9244], [24.22566, 47.90231], [24.11281, 47.91487], [24.06466, 47.95317], [24.02999, 47.95087], [24.00801, 47.968], [23.98553, 47.96076], [23.96337, 47.96672], [23.94192, 47.94868], [23.89352, 47.94512], [23.8602, 47.9329], [23.80904, 47.98142], [23.75188, 47.99705], [23.66262, 47.98786], [23.63894, 48.00293], [23.5653, 48.00499], [23.52803, 48.01818], [23.4979, 47.96858], [23.33577, 48.0237], [23.27397, 48.08245], [23.15999, 48.12188], [23.1133, 48.08061], [23.08858, 48.00716], [23.0158, 47.99338], [22.92241, 48.02002], [22.94301, 47.96672], [22.89849, 47.95851], [22.77991, 47.87211], [22.76617, 47.8417], [22.67247, 47.7871], [22.46559, 47.76583], [22.41979, 47.7391], [22.31816, 47.76126], [22.00917, 47.50492], [22.03389, 47.42508], [22.01055, 47.37767], [21.94463, 47.38046], [21.78395, 47.11104], [21.648, 47.03902], [21.68645, 46.99595], [21.59581, 46.91628], [21.59307, 46.86935], [21.52028, 46.84118], [21.48935, 46.7577], [21.5151, 46.72147], [21.43926, 46.65109], [21.33214, 46.63035], [21.26929, 46.4993], [21.28061, 46.44941], [21.16872, 46.30118], [21.06572, 46.24897], [20.86797, 46.28884], [20.74574, 46.25467], [20.76085, 46.21002], [20.63863, 46.12728], [20.49718, 46.18721], [20.45377, 46.14405], [20.35573, 46.16629], [20.28324, 46.1438], [20.26068, 46.12332], [20.35862, 45.99356], [20.54818, 45.89939], [20.65645, 45.82801], [20.70069, 45.7493], [20.77416, 45.75601], [20.78446, 45.78522], [20.82364, 45.77738], [20.80361, 45.65875], [20.76798, 45.60969], [20.83321, 45.53567], [20.77217, 45.49788], [20.86026, 45.47295], [20.87948, 45.42743], [21.09894, 45.30144], [21.17612, 45.32566], [21.20392, 45.2677], [21.29398, 45.24148], [21.48278, 45.19557], [21.51299, 45.15345], [21.4505, 45.04294], [21.35855, 45.01941], [21.54938, 44.9327], [21.56328, 44.89502], [21.48202, 44.87199], [21.44013, 44.87613], [21.35643, 44.86364], [21.38802, 44.78133], [21.55007, 44.77304], [21.60019, 44.75208], [21.61942, 44.67059], [21.67504, 44.67107], [21.71692, 44.65349], [21.7795, 44.66165], [21.99364, 44.63395], [22.08016, 44.49844], [22.13234, 44.47444], [22.18315, 44.48179], [22.30844, 44.6619], [22.45301, 44.7194], [22.61917, 44.61489], [22.69196, 44.61587], [22.76749, 44.54446], [22.70981, 44.51852], [22.61368, 44.55719], [22.56493, 44.53419], [22.54021, 44.47836], [22.45436, 44.47258], [22.56012, 44.30712], [22.68166, 44.28206], [22.67173, 44.21564], [23.04988, 44.07694], [23.01674, 44.01946], [22.87873, 43.9844], [22.83753, 43.88055], [22.85314, 43.84452], [23.05288, 43.79494], [23.26772, 43.84843], [23.4507, 43.84936], [23.61687, 43.79289], [23.73978, 43.80627], [24.18149, 43.68218], [24.35364, 43.70211], [24.50264, 43.76314], [24.62281, 43.74082], [24.73542, 43.68523], [24.96682, 43.72693], [25.10718, 43.6831], [25.17144, 43.70261], [25.39528, 43.61866], [25.72792, 43.69263], [25.94911, 43.85745], [26.05584, 43.90925], [26.10115, 43.96908], [26.38764, 44.04356], [26.62712, 44.05698], [26.95141, 44.13555], [27.26845, 44.12602], [27.39757, 44.0141], [27.60834, 44.01206], [27.64542, 44.04958], [27.73468, 43.95326], [27.92008, 44.00761], [27.99558, 43.84193], [28.23293, 43.76], [29.24336, 43.70874], [30.04414, 45.08461], [29.69272, 45.19227], [29.65428, 45.25629], [29.68175, 45.26885], [29.59798, 45.38857], [29.42632, 45.44545], [29.24779, 45.43388], [28.96077, 45.33164], [28.94292, 45.28045], [28.81383, 45.3384], [28.78911, 45.24179], [28.71358, 45.22631], [28.5735, 45.24759], [28.34554, 45.32102], [28.28504, 45.43907], [28.21139, 45.46895], [28.18741, 45.47358], [28.08927, 45.6051], [28.16568, 45.6421], [28.13111, 45.92819], [28.08612, 46.01105], [28.13684, 46.18099], [28.10937, 46.22852], [28.19864, 46.31869], [28.18902, 46.35283], [28.25769, 46.43334], [28.22281, 46.50481], [28.24808, 46.64305], [28.12173, 46.82283], [28.09095, 46.97621], [27.81892, 47.1381], [27.73172, 47.29248], [27.68706, 47.28962], [27.60263, 47.32507], [27.55731, 47.46637], [27.47942, 47.48113], [27.3979, 47.59473], [27.32202, 47.64009], [27.25519, 47.71366], [27.29069, 47.73722], [27.1618, 47.92391], [27.15622, 47.98538]]]] } },
22861     { type: "Feature", properties: { iso1A2: "RS", iso1A3: "SRB", iso1N3: "688", wikidata: "Q403", nameEn: "Serbia", groups: ["039", "150", "UN"], callingCodes: ["381"] }, geometry: { type: "MultiPolygon", coordinates: [[[[19.66007, 46.19005], [19.56113, 46.16824], [19.52473, 46.1171], [19.28826, 45.99694], [19.14543, 45.9998], [19.10388, 46.04015], [19.0791, 45.96458], [19.01284, 45.96529], [18.99712, 45.93537], [18.81394, 45.91329], [18.85783, 45.85493], [18.90305, 45.71863], [18.96691, 45.66731], [18.88776, 45.57253], [18.94562, 45.53712], [19.07471, 45.53086], [19.08364, 45.48804], [18.99918, 45.49333], [18.97446, 45.37528], [19.10774, 45.29547], [19.28208, 45.23813], [19.41941, 45.23475], [19.43589, 45.17137], [19.19144, 45.17863], [19.14063, 45.12972], [19.07952, 45.14668], [19.1011, 45.01191], [19.05205, 44.97692], [19.15573, 44.95409], [19.06853, 44.89915], [19.02871, 44.92541], [18.98957, 44.90645], [19.01994, 44.85493], [19.18183, 44.92055], [19.36722, 44.88164], [19.32543, 44.74058], [19.26388, 44.65412], [19.16699, 44.52197], [19.13369, 44.52521], [19.12278, 44.50132], [19.14837, 44.45253], [19.14681, 44.41463], [19.11785, 44.40313], [19.10749, 44.39421], [19.10704, 44.38249], [19.10365, 44.37795], [19.10298, 44.36924], [19.11865, 44.36712], [19.1083, 44.3558], [19.11547, 44.34218], [19.13556, 44.338], [19.13332, 44.31492], [19.16741, 44.28648], [19.18328, 44.28383], [19.20508, 44.2917], [19.23306, 44.26097], [19.26945, 44.26957], [19.32464, 44.27185], [19.34773, 44.23244], [19.3588, 44.18353], [19.40927, 44.16722], [19.43905, 44.13088], [19.47338, 44.15034], [19.48386, 44.14332], [19.47321, 44.1193], [19.51167, 44.08158], [19.55999, 44.06894], [19.57467, 44.04716], [19.61991, 44.05254], [19.61836, 44.01464], [19.56498, 43.99922], [19.52515, 43.95573], [19.38439, 43.96611], [19.24363, 44.01502], [19.23465, 43.98764], [19.3986, 43.79668], [19.5176, 43.71403], [19.50455, 43.58385], [19.42696, 43.57987], [19.41941, 43.54056], [19.36653, 43.60921], [19.33426, 43.58833], [19.2553, 43.5938], [19.24774, 43.53061], [19.22807, 43.5264], [19.22229, 43.47926], [19.44315, 43.38846], [19.48171, 43.32644], [19.52962, 43.31623], [19.54598, 43.25158], [19.62661, 43.2286], [19.64063, 43.19027], [19.76918, 43.16044], [19.79255, 43.11951], [19.92576, 43.08539], [19.96549, 43.11098], [19.98887, 43.0538], [20.04729, 43.02732], [20.05431, 42.99571], [20.12325, 42.96237], [20.14896, 42.99058], [20.16415, 42.97177], [20.34528, 42.90676], [20.35692, 42.8335], [20.40594, 42.84853], [20.43734, 42.83157], [20.53484, 42.8885], [20.48692, 42.93208], [20.59929, 43.01067], [20.64557, 43.00826], [20.69515, 43.09641], [20.59929, 43.20492], [20.68688, 43.21335], [20.73811, 43.25068], [20.82145, 43.26769], [20.88685, 43.21697], [20.83727, 43.17842], [20.96287, 43.12416], [21.00749, 43.13984], [21.05378, 43.10707], [21.08952, 43.13471], [21.14465, 43.11089], [21.16734, 42.99694], [21.2041, 43.02277], [21.23877, 43.00848], [21.23534, 42.95523], [21.2719, 42.8994], [21.32974, 42.90424], [21.36941, 42.87397], [21.44047, 42.87276], [21.39045, 42.74888], [21.47498, 42.74695], [21.59154, 42.72643], [21.58755, 42.70418], [21.6626, 42.67813], [21.75025, 42.70125], [21.79413, 42.65923], [21.75672, 42.62695], [21.7327, 42.55041], [21.70522, 42.54176], [21.7035, 42.51899], [21.62556, 42.45106], [21.64209, 42.41081], [21.62887, 42.37664], [21.59029, 42.38042], [21.57021, 42.3647], [21.53467, 42.36809], [21.5264, 42.33634], [21.56772, 42.30946], [21.58992, 42.25915], [21.70111, 42.23789], [21.77176, 42.2648], [21.84654, 42.3247], [21.91595, 42.30392], [21.94405, 42.34669], [22.02908, 42.29848], [22.16384, 42.32103], [22.29605, 42.37477], [22.29275, 42.34913], [22.34773, 42.31725], [22.45919, 42.33822], [22.47498, 42.3915], [22.51961, 42.3991], [22.55669, 42.50144], [22.43983, 42.56851], [22.4997, 42.74144], [22.43309, 42.82057], [22.54302, 42.87774], [22.74826, 42.88701], [22.78397, 42.98253], [22.89521, 43.03625], [22.98104, 43.11199], [23.00806, 43.19279], [22.89727, 43.22417], [22.82036, 43.33665], [22.53397, 43.47225], [22.47582, 43.6558], [22.41043, 43.69566], [22.35558, 43.81281], [22.41449, 44.00514], [22.61688, 44.06534], [22.61711, 44.16938], [22.67173, 44.21564], [22.68166, 44.28206], [22.56012, 44.30712], [22.45436, 44.47258], [22.54021, 44.47836], [22.56493, 44.53419], [22.61368, 44.55719], [22.70981, 44.51852], [22.76749, 44.54446], [22.69196, 44.61587], [22.61917, 44.61489], [22.45301, 44.7194], [22.30844, 44.6619], [22.18315, 44.48179], [22.13234, 44.47444], [22.08016, 44.49844], [21.99364, 44.63395], [21.7795, 44.66165], [21.71692, 44.65349], [21.67504, 44.67107], [21.61942, 44.67059], [21.60019, 44.75208], [21.55007, 44.77304], [21.38802, 44.78133], [21.35643, 44.86364], [21.44013, 44.87613], [21.48202, 44.87199], [21.56328, 44.89502], [21.54938, 44.9327], [21.35855, 45.01941], [21.4505, 45.04294], [21.51299, 45.15345], [21.48278, 45.19557], [21.29398, 45.24148], [21.20392, 45.2677], [21.17612, 45.32566], [21.09894, 45.30144], [20.87948, 45.42743], [20.86026, 45.47295], [20.77217, 45.49788], [20.83321, 45.53567], [20.76798, 45.60969], [20.80361, 45.65875], [20.82364, 45.77738], [20.78446, 45.78522], [20.77416, 45.75601], [20.70069, 45.7493], [20.65645, 45.82801], [20.54818, 45.89939], [20.35862, 45.99356], [20.26068, 46.12332], [20.09713, 46.17315], [20.03533, 46.14509], [20.01816, 46.17696], [19.93508, 46.17553], [19.81491, 46.1313], [19.66007, 46.19005]]]] } },
22862     { type: "Feature", properties: { iso1A2: "RU", iso1A3: "RUS", iso1N3: "643", wikidata: "Q159", nameEn: "Russia" }, geometry: null },
22863     { type: "Feature", properties: { iso1A2: "RW", iso1A3: "RWA", iso1N3: "646", wikidata: "Q1037", nameEn: "Rwanda", groups: ["014", "202", "002", "UN"], callingCodes: ["250"] }, geometry: { type: "MultiPolygon", coordinates: [[[[30.47194, -1.0555], [30.35212, -1.06896], [30.16369, -1.34303], [29.912, -1.48269], [29.82657, -1.31187], [29.59061, -1.39016], [29.53062, -1.40499], [29.45038, -1.5054], [29.36322, -1.50887], [29.24323, -1.66826], [29.24458, -1.69663], [29.11847, -1.90576], [29.17562, -2.12278], [29.105, -2.27043], [29.00051, -2.29001], [28.95642, -2.37321], [28.89601, -2.37321], [28.86826, -2.41888], [28.86846, -2.44866], [28.89132, -2.47557], [28.89342, -2.49017], [28.88846, -2.50493], [28.87497, -2.50887], [28.86209, -2.5231], [28.86193, -2.53185], [28.87943, -2.55165], [28.89288, -2.55848], [28.90226, -2.62385], [28.89793, -2.66111], [28.94346, -2.69124], [29.00357, -2.70596], [29.04081, -2.7416], [29.0562, -2.58632], [29.32234, -2.6483], [29.36805, -2.82933], [29.88237, -2.75105], [29.95911, -2.33348], [30.14034, -2.43626], [30.42933, -2.31064], [30.54501, -2.41404], [30.83915, -2.35795], [30.89303, -2.08223], [30.80802, -1.91477], [30.84079, -1.64652], [30.71974, -1.43244], [30.57123, -1.33264], [30.50889, -1.16412], [30.45116, -1.10641], [30.47194, -1.0555]]]] } },
22864     { type: "Feature", properties: { iso1A2: "SA", iso1A3: "SAU", iso1N3: "682", wikidata: "Q851", nameEn: "Saudi Arabia", groups: ["145", "142", "UN"], callingCodes: ["966"] }, geometry: { type: "MultiPolygon", coordinates: [[[[40.01521, 32.05667], [39.29903, 32.23259], [38.99233, 31.99721], [36.99791, 31.50081], [37.99354, 30.49998], [37.66395, 30.33245], [37.4971, 29.99949], [36.75083, 29.86903], [36.50005, 29.49696], [36.07081, 29.18469], [34.8812, 29.36878], [34.4454, 27.91479], [37.8565, 22.00903], [39.63762, 18.37348], [40.99158, 15.81743], [42.15205, 16.40211], [42.76801, 16.40371], [42.94625, 16.39721], [42.94351, 16.49467], [42.97215, 16.51093], [43.11601, 16.53166], [43.15274, 16.67248], [43.22066, 16.65179], [43.21325, 16.74416], [43.25857, 16.75304], [43.26303, 16.79479], [43.24801, 16.80613], [43.22956, 16.80613], [43.22012, 16.83932], [43.18338, 16.84852], [43.1398, 16.90696], [43.19328, 16.94703], [43.1813, 16.98438], [43.18233, 17.02673], [43.23967, 17.03428], [43.17787, 17.14717], [43.20156, 17.25901], [43.32653, 17.31179], [43.22533, 17.38343], [43.29185, 17.53224], [43.43005, 17.56148], [43.70631, 17.35762], [44.50126, 17.47475], [46.31018, 17.20464], [46.76494, 17.29151], [47.00571, 16.94765], [47.48245, 17.10808], [47.58351, 17.50366], [48.19996, 18.20584], [49.04884, 18.59899], [52.00311, 19.00083], [54.99756, 20.00083], [55.66469, 21.99658], [55.2137, 22.71065], [55.13599, 22.63334], [52.56622, 22.94341], [51.59617, 24.12041], [51.58871, 24.27256], [51.41644, 24.39615], [51.58834, 24.66608], [51.39468, 24.62785], [51.29972, 24.50747], [51.09638, 24.46907], [50.92992, 24.54396], [50.8133, 24.74049], [50.57069, 25.57887], [50.302, 25.87592], [50.26923, 26.08243], [50.38162, 26.53976], [50.71771, 26.73086], [50.37726, 27.89227], [49.98877, 27.87827], [49.00421, 28.81495], [48.42991, 28.53628], [47.70561, 28.5221], [47.59863, 28.66798], [47.58376, 28.83382], [47.46202, 29.0014], [46.5527, 29.10283], [46.42415, 29.05947], [44.72255, 29.19736], [42.97796, 30.48295], [42.97601, 30.72204], [40.01521, 32.05667]]]] } },
22865     { type: "Feature", properties: { iso1A2: "SB", iso1A3: "SLB", iso1N3: "090", wikidata: "Q685", nameEn: "Solomon Islands", groups: ["054", "009", "UN"], driveSide: "left", callingCodes: ["677"] }, geometry: { type: "MultiPolygon", coordinates: [[[[172.71443, -12.01327], [160.43769, -4.17974], [156.03296, -6.55528], [156.03993, -6.65703], [155.92557, -6.84664], [155.69784, -6.92661], [155.60735, -6.92266], [154.74815, -7.33315], [156.73836, -14.50464], [172.71443, -12.01327]]]] } },
22866     { type: "Feature", properties: { iso1A2: "SC", iso1A3: "SYC", iso1N3: "690", wikidata: "Q1042", nameEn: "Seychelles", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["248"] }, geometry: { type: "MultiPolygon", coordinates: [[[[43.75112, -10.38913], [54.83239, -10.93575], [66.3222, 5.65313], [43.75112, -10.38913]]]] } },
22867     { type: "Feature", properties: { iso1A2: "SD", iso1A3: "SDN", iso1N3: "729", wikidata: "Q1049", nameEn: "Sudan", groups: ["015", "002", "UN"], callingCodes: ["249"] }, geometry: { type: "MultiPolygon", coordinates: [[[[37.8565, 22.00903], [34.0765, 22.00501], [33.99686, 21.76784], [33.57251, 21.72406], [33.17563, 22.00405], [24.99885, 21.99535], [24.99794, 19.99661], [23.99715, 20.00038], [23.99539, 19.49944], [23.99997, 15.69575], [23.62785, 15.7804], [23.38812, 15.69649], [23.10792, 15.71297], [22.93201, 15.55107], [22.92579, 15.47007], [22.99584, 15.40105], [22.99584, 15.22989], [22.66115, 14.86308], [22.70474, 14.69149], [22.38562, 14.58907], [22.44944, 14.24986], [22.55997, 14.23024], [22.5553, 14.11704], [22.22995, 13.96754], [22.08674, 13.77863], [22.29689, 13.3731], [22.1599, 13.19281], [22.02914, 13.13976], [21.94819, 13.05637], [21.81432, 12.81362], [21.89371, 12.68001], [21.98711, 12.63292], [22.15679, 12.66634], [22.22684, 12.74682], [22.46345, 12.61925], [22.38873, 12.45514], [22.50548, 12.16769], [22.48369, 12.02766], [22.64092, 12.07485], [22.54907, 11.64372], [22.7997, 11.40424], [22.93124, 11.41645], [22.97249, 11.21955], [22.87758, 10.91915], [23.02221, 10.69235], [23.3128, 10.45214], [23.67164, 9.86923], [23.69155, 9.67566], [24.09319, 9.66572], [24.12744, 9.73784], [24.49389, 9.79962], [24.84653, 9.80643], [24.97739, 9.9081], [25.05688, 10.06776], [25.0918, 10.33718], [25.78141, 10.42599], [25.93163, 10.38159], [25.93241, 10.17941], [26.21338, 9.91545], [26.35815, 9.57946], [26.70685, 9.48735], [27.14427, 9.62858], [27.90704, 9.61323], [28.99983, 9.67155], [29.06988, 9.74826], [29.53844, 9.75133], [29.54, 10.07949], [29.94629, 10.29245], [30.00389, 10.28633], [30.53005, 9.95992], [30.82893, 9.71451], [30.84605, 9.7498], [31.28504, 9.75287], [31.77539, 10.28939], [31.99177, 10.65065], [32.46967, 11.04662], [32.39358, 11.18207], [32.39578, 11.70208], [32.10079, 11.95203], [32.73921, 11.95203], [32.73921, 12.22757], [33.25876, 12.22111], [33.13988, 11.43248], [33.26977, 10.83632], [33.24645, 10.77913], [33.52294, 10.64382], [33.66604, 10.44254], [33.80913, 10.32994], [33.90159, 10.17179], [33.96984, 10.15446], [33.99185, 9.99623], [33.96323, 9.80972], [33.9082, 9.762], [33.87958, 9.49937], [34.10229, 9.50238], [34.08717, 9.55243], [34.13186, 9.7492], [34.20484, 9.9033], [34.22718, 10.02506], [34.32102, 10.11599], [34.34783, 10.23914], [34.2823, 10.53508], [34.4372, 10.781], [34.59062, 10.89072], [34.77383, 10.74588], [34.77532, 10.69027], [34.86618, 10.74588], [34.86916, 10.78832], [34.97491, 10.86147], [34.97789, 10.91559], [34.93172, 10.95946], [35.01215, 11.19626], [34.95704, 11.24448], [35.09556, 11.56278], [35.05832, 11.71158], [35.11492, 11.85156], [35.24302, 11.91132], [35.70476, 12.67101], [36.01458, 12.72478], [36.14268, 12.70879], [36.16651, 12.88019], [36.13374, 12.92665], [36.24545, 13.36759], [36.38993, 13.56459], [36.48824, 13.83954], [36.44653, 13.95666], [36.54376, 14.25597], [36.44337, 15.14963], [36.54276, 15.23478], [36.69761, 15.75323], [36.76371, 15.80831], [36.92193, 16.23451], [36.99777, 17.07172], [37.42694, 17.04041], [37.50967, 17.32199], [38.13362, 17.53906], [38.37133, 17.66269], [38.45916, 17.87167], [38.57727, 17.98125], [39.63762, 18.37348], [37.8565, 22.00903]]]] } },
22868     { type: "Feature", properties: { iso1A2: "SE", iso1A3: "SWE", iso1N3: "752", wikidata: "Q34", nameEn: "Sweden", groups: ["EU", "154", "150", "UN"], callingCodes: ["46"] }, geometry: { type: "MultiPolygon", coordinates: [[[[24.15791, 65.85385], [23.90497, 66.15802], [23.71339, 66.21299], [23.64982, 66.30603], [23.67591, 66.3862], [23.63776, 66.43568], [23.85959, 66.56434], [23.89488, 66.772], [23.98059, 66.79585], [23.98563, 66.84149], [23.56214, 67.17038], [23.58735, 67.20752], [23.54701, 67.25435], [23.75372, 67.29914], [23.75372, 67.43688], [23.39577, 67.46974], [23.54701, 67.59306], [23.45627, 67.85297], [23.65793, 67.9497], [23.40081, 68.05545], [23.26469, 68.15134], [23.15377, 68.14759], [23.10336, 68.26551], [22.73028, 68.40881], [22.00429, 68.50692], [21.03001, 68.88969], [20.90649, 68.89696], [20.85104, 68.93142], [20.91658, 68.96764], [20.78802, 69.03087], [20.55258, 69.06069], [20.0695, 69.04469], [20.28444, 68.93283], [20.33435, 68.80174], [20.22027, 68.67246], [19.95647, 68.55546], [20.22027, 68.48759], [19.93508, 68.35911], [18.97255, 68.52416], [18.63032, 68.50849], [18.39503, 68.58672], [18.1241, 68.53721], [18.13836, 68.20874], [17.90787, 67.96537], [17.30416, 68.11591], [16.7409, 67.91037], [16.38441, 67.52923], [16.12774, 67.52106], [16.09922, 67.4364], [16.39154, 67.21653], [16.35589, 67.06419], [15.37197, 66.48217], [15.49318, 66.28509], [15.05113, 66.15572], [14.53778, 66.12399], [14.50926, 65.31786], [13.64276, 64.58402], [14.11117, 64.46674], [14.16051, 64.18725], [13.98222, 64.00953], [13.23411, 64.09087], [12.74105, 64.02171], [12.14928, 63.59373], [12.19919, 63.47935], [11.98529, 63.27487], [12.19919, 63.00104], [12.07085, 62.6297], [12.29187, 62.25699], [12.14746, 61.7147], [12.40595, 61.57226], [12.57707, 61.56547], [12.86939, 61.35427], [12.69115, 61.06584], [12.2277, 61.02442], [12.59133, 60.50559], [12.52003, 60.13846], [12.36317, 59.99259], [12.15641, 59.8926], [11.87121, 59.86039], [11.92112, 59.69531], [11.69297, 59.59442], [11.8213, 59.24985], [11.65732, 58.90177], [11.45199, 58.89604], [11.4601, 58.99022], [11.34459, 59.11672], [11.15367, 59.07862], [11.08911, 58.98745], [10.64958, 58.89391], [10.40861, 58.38489], [12.16597, 56.60205], [12.07466, 56.29488], [12.65312, 56.04345], [12.6372, 55.91371], [12.88472, 55.63369], [12.60345, 55.42675], [12.84405, 55.13257], [14.28399, 55.1553], [14.89259, 55.5623], [15.79951, 55.54655], [19.64795, 57.06466], [19.84909, 57.57876], [20.5104, 59.15546], [19.08191, 60.19152], [19.23413, 60.61414], [20.15877, 63.06556], [24.14112, 65.39731], [24.15107, 65.81427], [24.14798, 65.83466], [24.15791, 65.85385]]]] } },
22869     { type: "Feature", properties: { iso1A2: "SG", iso1A3: "SGP", iso1N3: "702", wikidata: "Q334", nameEn: "Singapore", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["65"] }, geometry: { type: "MultiPolygon", coordinates: [[[[104.00131, 1.42405], [103.93384, 1.42926], [103.89565, 1.42841], [103.86383, 1.46288], [103.81181, 1.47953], [103.76395, 1.45183], [103.74161, 1.4502], [103.7219, 1.46108], [103.67468, 1.43166], [103.62738, 1.35255], [103.56591, 1.19719], [103.66049, 1.18825], [103.74084, 1.12902], [104.03085, 1.26954], [104.12282, 1.27714], [104.08072, 1.35998], [104.09162, 1.39694], [104.08871, 1.42015], [104.07348, 1.43322], [104.04622, 1.44691], [104.02277, 1.4438], [104.00131, 1.42405]]]] } },
22870     { type: "Feature", properties: { iso1A2: "SH", iso1A3: "SHN", iso1N3: "654", wikidata: "Q192184", nameEn: "Saint Helena, Ascension and Tristan da Cunha", country: "GB" }, geometry: null },
22871     { type: "Feature", properties: { iso1A2: "SI", iso1A3: "SVN", iso1N3: "705", wikidata: "Q215", nameEn: "Slovenia", groups: ["EU", "039", "150", "UN"], callingCodes: ["386"] }, geometry: { type: "MultiPolygon", coordinates: [[[[16.50139, 46.56684], [16.39217, 46.63673], [16.38594, 46.6549], [16.41863, 46.66238], [16.42641, 46.69228], [16.37816, 46.69975], [16.30966, 46.7787], [16.31303, 46.79838], [16.3408, 46.80641], [16.34547, 46.83836], [16.2941, 46.87137], [16.2365, 46.87775], [16.21892, 46.86961], [16.15711, 46.85434], [16.14365, 46.8547], [16.10983, 46.867], [16.05786, 46.83927], [15.99054, 46.82772], [15.99126, 46.78199], [15.98432, 46.74991], [15.99769, 46.7266], [16.02808, 46.71094], [16.04347, 46.68694], [16.04036, 46.6549], [15.99988, 46.67947], [15.98512, 46.68463], [15.94864, 46.68769], [15.87691, 46.7211], [15.8162, 46.71897], [15.78518, 46.70712], [15.76771, 46.69863], [15.73823, 46.70011], [15.72279, 46.69548], [15.69523, 46.69823], [15.67411, 46.70735], [15.6543, 46.70616], [15.6543, 46.69228], [15.6365, 46.6894], [15.63255, 46.68069], [15.62317, 46.67947], [15.59826, 46.68908], [15.54533, 46.66985], [15.55333, 46.64988], [15.54431, 46.6312], [15.46906, 46.61321], [15.45514, 46.63697], [15.41235, 46.65556], [15.23711, 46.63994], [15.14215, 46.66131], [15.01451, 46.641], [14.98024, 46.6009], [14.96002, 46.63459], [14.92283, 46.60848], [14.87129, 46.61], [14.86419, 46.59411], [14.83549, 46.56614], [14.81836, 46.51046], [14.72185, 46.49974], [14.66892, 46.44936], [14.5942, 46.43434], [14.56463, 46.37208], [14.52176, 46.42617], [14.45877, 46.41717], [14.42608, 46.44614], [14.314, 46.43327], [14.28326, 46.44315], [14.15989, 46.43327], [14.12097, 46.47724], [14.04002, 46.49117], [14.00422, 46.48474], [13.89837, 46.52331], [13.7148, 46.5222], [13.68684, 46.43881], [13.59777, 46.44137], [13.5763, 46.42613], [13.5763, 46.40915], [13.47019, 46.3621], [13.43418, 46.35992], [13.44808, 46.33507], [13.37671, 46.29668], [13.42218, 46.20758], [13.47587, 46.22725], [13.56114, 46.2054], [13.56682, 46.18703], [13.64451, 46.18966], [13.66472, 46.17392], [13.64053, 46.13587], [13.57072, 46.09022], [13.50104, 46.05986], [13.49568, 46.04839], [13.50998, 46.04498], [13.49702, 46.01832], [13.47474, 46.00546], [13.50104, 45.98078], [13.52963, 45.96588], [13.56759, 45.96991], [13.58903, 45.99009], [13.62074, 45.98388], [13.63458, 45.98947], [13.64307, 45.98326], [13.6329, 45.94894], [13.63815, 45.93607], [13.61931, 45.91782], [13.60857, 45.89907], [13.59565, 45.89446], [13.58644, 45.88173], [13.57563, 45.8425], [13.58858, 45.83503], [13.59784, 45.8072], [13.66986, 45.79955], [13.8235, 45.7176], [13.83332, 45.70855], [13.83422, 45.68703], [13.87933, 45.65207], [13.9191, 45.6322], [13.8695, 45.60835], [13.86771, 45.59898], [13.84106, 45.58185], [13.78445, 45.5825], [13.74587, 45.59811], [13.7198, 45.59352], [13.6076, 45.64761], [13.45644, 45.59464], [13.56979, 45.4895], [13.62902, 45.45898], [13.67398, 45.4436], [13.7785, 45.46787], [13.81742, 45.43729], [13.88124, 45.42637], [13.90771, 45.45149], [13.97309, 45.45258], [13.99488, 45.47551], [13.96063, 45.50825], [14.00578, 45.52352], [14.07116, 45.48752], [14.20348, 45.46896], [14.22371, 45.50388], [14.24239, 45.50607], [14.26611, 45.48239], [14.27681, 45.4902], [14.32487, 45.47142], [14.36693, 45.48642], [14.49769, 45.54424], [14.5008, 45.60852], [14.53816, 45.6205], [14.57397, 45.67165], [14.60977, 45.66403], [14.59576, 45.62812], [14.69694, 45.57366], [14.68605, 45.53006], [14.71718, 45.53442], [14.80124, 45.49515], [14.81992, 45.45913], [14.90554, 45.47769], [14.92266, 45.52788], [15.02385, 45.48533], [15.05187, 45.49079], [15.16862, 45.42309], [15.27758, 45.46678], [15.33051, 45.45258], [15.38188, 45.48752], [15.30249, 45.53224], [15.29837, 45.5841], [15.27747, 45.60504], [15.31027, 45.6303], [15.34695, 45.63382], [15.34214, 45.64702], [15.38952, 45.63682], [15.4057, 45.64727], [15.34919, 45.71623], [15.30872, 45.69014], [15.25423, 45.72275], [15.40836, 45.79491], [15.47531, 45.79802], [15.47325, 45.8253], [15.52234, 45.82195], [15.57952, 45.84953], [15.64185, 45.82915], [15.66662, 45.84085], [15.70411, 45.8465], [15.68232, 45.86819], [15.68383, 45.88867], [15.67967, 45.90455], [15.70636, 45.92116], [15.70327, 46.00015], [15.71246, 46.01196], [15.72977, 46.04682], [15.62317, 46.09103], [15.6083, 46.11992], [15.59909, 46.14761], [15.64904, 46.19229], [15.6434, 46.21396], [15.67395, 46.22478], [15.75436, 46.21969], [15.75479, 46.20336], [15.78817, 46.21719], [15.79284, 46.25811], [15.97965, 46.30652], [16.07616, 46.3463], [16.07314, 46.36458], [16.05065, 46.3833], [16.05281, 46.39141], [16.14859, 46.40547], [16.18824, 46.38282], [16.30233, 46.37837], [16.30162, 46.40437], [16.27329, 46.41467], [16.27398, 46.42875], [16.25124, 46.48067], [16.23961, 46.49653], [16.26759, 46.50566], [16.26733, 46.51505], [16.29793, 46.5121], [16.37193, 46.55008], [16.38771, 46.53608], [16.44036, 46.5171], [16.5007, 46.49644], [16.52604, 46.47831], [16.59527, 46.47524], [16.52604, 46.5051], [16.52885, 46.53303], [16.50139, 46.56684]]]] } },
22872     { type: "Feature", properties: { iso1A2: "SJ", iso1A3: "SJM", iso1N3: "744", wikidata: "Q842829", nameEn: "Svalbard and Jan Mayen", country: "NO" }, geometry: null },
22873     { type: "Feature", properties: { iso1A2: "SK", iso1A3: "SVK", iso1N3: "703", wikidata: "Q214", nameEn: "Slovakia", groups: ["EU", "151", "150", "UN"], callingCodes: ["421"] }, geometry: { type: "MultiPolygon", coordinates: [[[[19.82237, 49.27806], [19.78581, 49.41701], [19.72127, 49.39288], [19.6375, 49.40897], [19.64162, 49.45184], [19.57845, 49.46077], [19.53313, 49.52856], [19.52626, 49.57311], [19.45348, 49.61583], [19.37795, 49.574], [19.36009, 49.53747], [19.25435, 49.53391], [19.18019, 49.41165], [18.9742, 49.39557], [18.97283, 49.49914], [18.94536, 49.52143], [18.84521, 49.51672], [18.74761, 49.492], [18.67757, 49.50895], [18.6144, 49.49824], [18.57183, 49.51162], [18.53063, 49.49022], [18.54848, 49.47059], [18.44686, 49.39467], [18.4084, 49.40003], [18.4139, 49.36517], [18.36446, 49.3267], [18.18456, 49.28909], [18.15022, 49.24518], [18.1104, 49.08624], [18.06885, 49.03157], [17.91814, 49.01784], [17.87831, 48.92679], [17.77944, 48.92318], [17.73126, 48.87885], [17.7094, 48.86721], [17.5295, 48.81117], [17.45671, 48.85004], [17.3853, 48.80936], [17.29054, 48.85546], [17.19355, 48.87602], [17.11202, 48.82925], [17.00215, 48.70887], [16.93955, 48.60371], [16.94611, 48.53614], [16.85204, 48.44968], [16.8497, 48.38321], [16.83588, 48.3844], [16.83317, 48.38138], [16.84243, 48.35258], [16.90903, 48.32519], [16.89461, 48.31332], [16.97701, 48.17385], [17.02919, 48.13996], [17.05735, 48.14179], [17.09168, 48.09366], [17.07039, 48.0317], [17.16001, 48.00636], [17.23699, 48.02094], [17.71215, 47.7548], [18.02938, 47.75665], [18.29305, 47.73541], [18.56496, 47.76588], [18.66521, 47.76772], [18.74074, 47.8157], [18.8506, 47.82308], [18.76821, 47.87469], [18.76134, 47.97499], [18.82176, 48.04206], [19.01952, 48.07052], [19.23924, 48.0595], [19.28182, 48.08336], [19.47957, 48.09437], [19.52489, 48.19791], [19.63338, 48.25006], [19.92452, 48.1283], [20.24312, 48.2784], [20.29943, 48.26104], [20.5215, 48.53336], [20.83248, 48.5824], [21.11516, 48.49546], [21.44063, 48.58456], [21.6068, 48.50365], [21.67134, 48.3989], [21.72525, 48.34628], [21.8279, 48.33321], [21.83339, 48.36242], [22.14689, 48.4005], [22.16023, 48.56548], [22.21379, 48.6218], [22.34151, 48.68893], [22.42934, 48.92857], [22.48296, 48.99172], [22.54338, 49.01424], [22.56155, 49.08865], [22.04427, 49.22136], [21.96385, 49.3437], [21.82927, 49.39467], [21.77983, 49.35443], [21.62328, 49.4447], [21.43376, 49.41433], [21.27858, 49.45988], [21.19756, 49.4054], [21.12477, 49.43666], [21.041, 49.41791], [21.09799, 49.37176], [20.98733, 49.30774], [20.9229, 49.29626], [20.77971, 49.35383], [20.72274, 49.41813], [20.61666, 49.41791], [20.5631, 49.375], [20.46422, 49.41612], [20.39939, 49.3896], [20.31728, 49.39914], [20.31453, 49.34817], [20.21977, 49.35265], [20.13738, 49.31685], [20.08238, 49.1813], [19.98494, 49.22904], [19.90529, 49.23532], [19.86409, 49.19316], [19.75286, 49.20751], [19.82237, 49.27806]]]] } },
22874     { type: "Feature", properties: { iso1A2: "SL", iso1A3: "SLE", iso1N3: "694", wikidata: "Q1044", nameEn: "Sierra Leone", groups: ["011", "202", "002", "UN"], callingCodes: ["232"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-10.27575, 8.48711], [-10.37257, 8.48941], [-10.54891, 8.31174], [-10.63934, 8.35326], [-10.70565, 8.29235], [-10.61422, 8.5314], [-10.47707, 8.67669], [-10.56197, 8.81225], [-10.5783, 9.06386], [-10.74484, 9.07998], [-10.6534, 9.29919], [-11.2118, 10.00098], [-11.89624, 9.99763], [-11.91023, 9.93927], [-12.12634, 9.87203], [-12.24262, 9.92386], [-12.47254, 9.86834], [-12.76788, 9.3133], [-12.94095, 9.26335], [-13.08953, 9.0409], [-13.18586, 9.0925], [-13.29911, 9.04245], [-14.36218, 8.64107], [-12.15048, 6.15992], [-11.50429, 6.92704], [-11.4027, 6.97746], [-11.29417, 7.21576], [-10.60422, 7.7739], [-10.60492, 8.04072], [-10.57523, 8.04829], [-10.51554, 8.1393], [-10.45023, 8.15627], [-10.35227, 8.15223], [-10.29839, 8.21283], [-10.31635, 8.28554], [-10.30084, 8.30008], [-10.27575, 8.48711]]]] } },
22875     { type: "Feature", properties: { iso1A2: "SM", iso1A3: "SMR", iso1N3: "674", wikidata: "Q238", nameEn: "San Marino", groups: ["039", "150", "UN"], callingCodes: ["378"] }, geometry: { type: "MultiPolygon", coordinates: [[[[12.45648, 43.89369], [12.48771, 43.89706], [12.49429, 43.90973], [12.49247, 43.91774], [12.49724, 43.92248], [12.50269, 43.92363], [12.50496, 43.93017], [12.51553, 43.94096], [12.51427, 43.94897], [12.50655, 43.95796], [12.50875, 43.96198], [12.50622, 43.97131], [12.51109, 43.97201], [12.51064, 43.98165], [12.5154, 43.98508], [12.51463, 43.99122], [12.50678, 43.99113], [12.49406, 43.98492], [12.47853, 43.98052], [12.46205, 43.97463], [12.44684, 43.96597], [12.43662, 43.95698], [12.42005, 43.9578], [12.41414, 43.95273], [12.40415, 43.95485], [12.40506, 43.94325], [12.41165, 43.93769], [12.41551, 43.92984], [12.40733, 43.92379], [12.41233, 43.90956], [12.40935, 43.9024], [12.41641, 43.89991], [12.44184, 43.90498], [12.45648, 43.89369]]]] } },
22876     { type: "Feature", properties: { iso1A2: "SN", iso1A3: "SEN", iso1N3: "686", wikidata: "Q1041", nameEn: "Senegal", groups: ["011", "202", "002", "UN"], callingCodes: ["221"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-14.32144, 16.61495], [-15.00557, 16.64997], [-15.6509, 16.50315], [-16.27016, 16.51565], [-16.4429, 16.20605], [-16.44814, 16.09753], [-16.48967, 16.0496], [-16.50854, 16.09032], [-17.15288, 16.07139], [-18.35085, 14.63444], [-17.43598, 13.59273], [-15.47902, 13.58758], [-15.36504, 13.79313], [-14.93719, 13.80173], [-14.34721, 13.46578], [-13.8955, 13.59126], [-13.79409, 13.34472], [-14.36795, 13.23033], [-15.14917, 13.57989], [-15.26908, 13.37768], [-15.80478, 13.34832], [-15.80355, 13.16729], [-16.69343, 13.16791], [-16.74676, 13.06025], [-17.43966, 13.04579], [-17.4623, 11.92379], [-16.70562, 12.34803], [-16.38191, 12.36449], [-16.20591, 12.46157], [-15.67302, 12.42974], [-15.17582, 12.6847], [-13.70523, 12.68013], [-13.05296, 12.64003], [-13.06603, 12.49342], [-12.87336, 12.51892], [-12.35415, 12.32758], [-11.91331, 12.42008], [-11.46267, 12.44559], [-11.37536, 12.40788], [-11.39935, 12.97808], [-11.63025, 13.39174], [-11.83345, 13.33333], [-12.06897, 13.71049], [-11.93043, 13.84505], [-12.23936, 14.76324], [-13.11029, 15.52116], [-13.43135, 16.09022], [-13.80075, 16.13961], [-14.32144, 16.61495]]]] } },
22877     { type: "Feature", properties: { iso1A2: "SO", iso1A3: "SOM", iso1N3: "706", wikidata: "Q1045", nameEn: "Somalia", groups: ["014", "202", "002", "UN"], callingCodes: ["252"] }, geometry: { type: "MultiPolygon", coordinates: [[[[51.12877, 12.56479], [43.90659, 12.3823], [42.95776, 10.98533], [42.69452, 10.62672], [42.87643, 10.18441], [43.0937, 9.90579], [43.23518, 9.84605], [43.32613, 9.59205], [44.19222, 8.93028], [46.99339, 7.9989], [47.92477, 8.00111], [47.97917, 8.00124], [44.98104, 4.91821], [44.02436, 4.9451], [43.40263, 4.79289], [43.04177, 4.57923], [42.97746, 4.44032], [42.84526, 4.28357], [42.55853, 4.20518], [42.07619, 4.17667], [41.89488, 3.97375], [41.31368, 3.14314], [40.98767, 2.82959], [41.00099, -0.83068], [41.56, -1.59812], [41.56362, -1.66375], [41.75542, -1.85308], [57.49095, 8.14549], [51.12877, 12.56479]]]] } },
22878     { type: "Feature", properties: { iso1A2: "SR", iso1A3: "SUR", iso1N3: "740", wikidata: "Q730", nameEn: "Suriname", groups: ["005", "419", "019", "UN"], driveSide: "left", callingCodes: ["597"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-54.26916, 5.26909], [-54.01877, 5.52789], [-54.01074, 5.68785], [-53.7094, 6.2264], [-56.84822, 6.73257], [-57.31629, 5.33714], [-57.22536, 5.15605], [-57.37442, 5.0208], [-57.8699, 4.89394], [-58.0307, 3.95513], [-57.35891, 3.32121], [-56.70519, 2.02964], [-56.55439, 2.02003], [-56.47045, 1.95135], [-55.99278, 1.83137], [-55.89863, 1.89861], [-55.92159, 2.05236], [-56.13054, 2.27723], [-55.96292, 2.53188], [-55.71493, 2.40342], [-55.01919, 2.564], [-54.6084, 2.32856], [-54.42864, 2.42442], [-54.28534, 2.67798], [-53.9849, 3.58697], [-53.98914, 3.627], [-54.05128, 3.63557], [-54.19367, 3.84387], [-54.38444, 4.13222], [-54.4717, 4.91964], [-54.26916, 5.26909]]]] } },
22879     { type: "Feature", properties: { iso1A2: "SS", iso1A3: "SSD", iso1N3: "728", wikidata: "Q958", nameEn: "South Sudan", groups: ["014", "202", "002", "UN"], callingCodes: ["211"] }, geometry: { type: "MultiPolygon", coordinates: [[[[34.10229, 9.50238], [33.87958, 9.49937], [33.9082, 9.762], [33.96323, 9.80972], [33.99185, 9.99623], [33.96984, 10.15446], [33.90159, 10.17179], [33.80913, 10.32994], [33.66604, 10.44254], [33.52294, 10.64382], [33.24645, 10.77913], [33.26977, 10.83632], [33.13988, 11.43248], [33.25876, 12.22111], [32.73921, 12.22757], [32.73921, 11.95203], [32.10079, 11.95203], [32.39578, 11.70208], [32.39358, 11.18207], [32.46967, 11.04662], [31.99177, 10.65065], [31.77539, 10.28939], [31.28504, 9.75287], [30.84605, 9.7498], [30.82893, 9.71451], [30.53005, 9.95992], [30.00389, 10.28633], [29.94629, 10.29245], [29.54, 10.07949], [29.53844, 9.75133], [29.06988, 9.74826], [28.99983, 9.67155], [27.90704, 9.61323], [27.14427, 9.62858], [26.70685, 9.48735], [26.35815, 9.57946], [26.21338, 9.91545], [25.93241, 10.17941], [25.93163, 10.38159], [25.78141, 10.42599], [25.0918, 10.33718], [25.05688, 10.06776], [24.97739, 9.9081], [24.84653, 9.80643], [24.49389, 9.79962], [24.12744, 9.73784], [24.09319, 9.66572], [23.69155, 9.67566], [23.62179, 9.53823], [23.64981, 9.44303], [23.64358, 9.28637], [23.56263, 9.19418], [23.4848, 9.16959], [23.44744, 8.99128], [23.59065, 8.99743], [23.51905, 8.71749], [24.25691, 8.69288], [24.13238, 8.36959], [24.35965, 8.26177], [24.85156, 8.16933], [24.98855, 7.96588], [25.25319, 7.8487], [25.29214, 7.66675], [25.20649, 7.61115], [25.20337, 7.50312], [25.35281, 7.42595], [25.37461, 7.33024], [25.90076, 7.09549], [26.38022, 6.63493], [26.32729, 6.36272], [26.58259, 6.1987], [26.51721, 6.09655], [27.22705, 5.71254], [27.22705, 5.62889], [27.28621, 5.56382], [27.23017, 5.37167], [27.26886, 5.25876], [27.44012, 5.07349], [27.56656, 4.89375], [27.65462, 4.89375], [27.76469, 4.79284], [27.79551, 4.59976], [28.20719, 4.35614], [28.6651, 4.42638], [28.8126, 4.48784], [29.03054, 4.48784], [29.22207, 4.34297], [29.43341, 4.50101], [29.49726, 4.7007], [29.82087, 4.56246], [29.79666, 4.37809], [30.06964, 4.13221], [30.1621, 4.10586], [30.22374, 3.93896], [30.27658, 3.95653], [30.47691, 3.83353], [30.55396, 3.84451], [30.57378, 3.74567], [30.56277, 3.62703], [30.78512, 3.67097], [30.80713, 3.60506], [30.85997, 3.5743], [30.85153, 3.48867], [30.97601, 3.693], [31.16666, 3.79853], [31.29476, 3.8015], [31.50478, 3.67814], [31.50776, 3.63652], [31.72075, 3.74354], [31.81459, 3.82083], [31.86821, 3.78664], [31.96205, 3.6499], [31.95907, 3.57408], [32.05187, 3.589], [32.08491, 3.56287], [32.08866, 3.53543], [32.19888, 3.50867], [32.20782, 3.6053], [32.41337, 3.748], [32.72021, 3.77327], [32.89746, 3.81339], [33.02852, 3.89296], [33.18356, 3.77812], [33.51264, 3.75068], [33.9873, 4.23316], [34.47601, 4.72162], [35.34151, 5.02364], [35.30992, 4.90402], [35.47843, 4.91872], [35.42366, 4.76969], [35.51424, 4.61643], [35.9419, 4.61933], [35.82118, 4.77382], [35.81968, 5.10757], [35.8576, 5.33413], [35.50792, 5.42431], [35.29938, 5.34042], [35.31188, 5.50106], [35.13058, 5.62118], [35.12611, 5.68937], [35.00546, 5.89387], [34.96227, 6.26415], [35.01738, 6.46991], [34.87736, 6.60161], [34.77459, 6.5957], [34.65096, 6.72589], [34.53776, 6.74808], [34.53925, 6.82794], [34.47669, 6.91076], [34.35753, 6.91963], [34.19369, 7.04382], [34.19369, 7.12807], [34.01495, 7.25664], [34.03878, 7.27437], [34.02984, 7.36449], [33.87642, 7.5491], [33.71407, 7.65983], [33.44745, 7.7543], [33.32531, 7.71297], [33.24637, 7.77939], [33.04944, 7.78989], [33.0006, 7.90333], [33.08401, 8.05822], [33.18083, 8.13047], [33.1853, 8.29264], [33.19721, 8.40317], [33.3119, 8.45474], [33.54575, 8.47094], [33.66938, 8.44442], [33.71407, 8.3678], [33.87195, 8.41938], [33.89579, 8.4842], [34.01346, 8.50041], [34.14453, 8.60204], [34.14304, 9.04654], [34.10229, 9.50238]]]] } },
22880     { type: "Feature", properties: { iso1A2: "ST", iso1A3: "STP", iso1N3: "678", wikidata: "Q1039", nameEn: "S\xE3o Tom\xE9 and Principe", groups: ["017", "202", "002", "UN"], callingCodes: ["239"] }, geometry: { type: "MultiPolygon", coordinates: [[[[4.34149, 1.91417], [6.6507, -0.28606], [7.9035, 1.92304], [4.34149, 1.91417]]]] } },
22881     { type: "Feature", properties: { iso1A2: "SV", iso1A3: "SLV", iso1N3: "222", wikidata: "Q792", nameEn: "El Salvador", groups: ["013", "003", "419", "019", "UN"], callingCodes: ["503"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-89.34776, 14.43013], [-89.39028, 14.44561], [-89.57441, 14.41637], [-89.58814, 14.33165], [-89.50614, 14.26084], [-89.52397, 14.22628], [-89.61844, 14.21937], [-89.70756, 14.1537], [-89.75569, 14.07073], [-89.73251, 14.04133], [-89.76103, 14.02923], [-89.81807, 14.07073], [-89.88937, 14.0396], [-90.10505, 13.85104], [-90.11344, 13.73679], [-90.55276, 12.8866], [-88.11443, 12.63306], [-87.7346, 13.13228], [-87.55124, 13.12523], [-87.69751, 13.25228], [-87.73714, 13.32715], [-87.80177, 13.35689], [-87.84675, 13.41078], [-87.83467, 13.44655], [-87.77354, 13.45767], [-87.73841, 13.44169], [-87.72115, 13.46083], [-87.71657, 13.50577], [-87.78148, 13.52906], [-87.73106, 13.75443], [-87.68821, 13.80829], [-87.7966, 13.91353], [-88.00331, 13.86948], [-88.07641, 13.98447], [-88.23018, 13.99915], [-88.25791, 13.91108], [-88.48982, 13.86458], [-88.49738, 13.97224], [-88.70661, 14.04317], [-88.73182, 14.10919], [-88.815, 14.11652], [-88.85785, 14.17763], [-88.94608, 14.20207], [-89.04187, 14.33644], [-89.34776, 14.43013]]]] } },
22882     { type: "Feature", properties: { iso1A2: "SX", iso1A3: "SXM", iso1N3: "534", wikidata: "Q26273", nameEn: "Sint Maarten", aliases: ["NL-SX"], country: "NL", groups: ["Q1451600", "029", "003", "419", "019", "UN"], callingCodes: ["1 721"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-63.33064, 17.9615], [-63.1055, 17.86651], [-62.93924, 18.02904], [-63.02323, 18.05757], [-63.04039, 18.05619], [-63.0579, 18.06614], [-63.07759, 18.04943], [-63.09686, 18.04608], [-63.11042, 18.05339], [-63.13502, 18.05445], [-63.33064, 17.9615]]]] } },
22883     { type: "Feature", properties: { iso1A2: "SY", iso1A3: "SYR", iso1N3: "760", wikidata: "Q858", nameEn: "Syria", groups: ["145", "142", "UN"], callingCodes: ["963"] }, geometry: { type: "MultiPolygon", coordinates: [[[[42.23683, 37.2863], [42.21548, 37.28026], [42.20454, 37.28715], [42.22381, 37.30238], [42.22257, 37.31395], [42.2112, 37.32491], [42.19301, 37.31323], [42.18225, 37.28569], [42.00894, 37.17209], [41.515, 37.08084], [41.21937, 37.07665], [40.90856, 37.13147], [40.69136, 37.0996], [39.81589, 36.75538], [39.21538, 36.66834], [39.03217, 36.70911], [38.74042, 36.70629], [38.55908, 36.84429], [38.38859, 36.90064], [38.21064, 36.91842], [37.81974, 36.76055], [37.68048, 36.75065], [37.49103, 36.66904], [37.47253, 36.63243], [37.21988, 36.6736], [37.16177, 36.66069], [37.10894, 36.6704], [37.08279, 36.63495], [37.02088, 36.66422], [37.01647, 36.69512], [37.04619, 36.71101], [37.04399, 36.73483], [36.99886, 36.74012], [36.99557, 36.75997], [36.66727, 36.82901], [36.61581, 36.74629], [36.62681, 36.71189], [36.57398, 36.65186], [36.58829, 36.58295], [36.54206, 36.49539], [36.6081, 36.33772], [36.65653, 36.33861], [36.68672, 36.23677], [36.6125, 36.22592], [36.50463, 36.2419], [36.4617, 36.20461], [36.39206, 36.22088], [36.37474, 36.01163], [36.33956, 35.98687], [36.30099, 36.00985], [36.28338, 36.00273], [36.29769, 35.96086], [36.27678, 35.94839], [36.25366, 35.96264], [36.19973, 35.95195], [36.17441, 35.92076], [36.1623, 35.80925], [36.14029, 35.81015], [36.13919, 35.83692], [36.11827, 35.85923], [35.99829, 35.88242], [36.01844, 35.92403], [36.00514, 35.94113], [35.98499, 35.94107], [35.931, 35.92109], [35.51152, 36.10954], [35.48515, 34.70851], [35.97386, 34.63322], [35.98718, 34.64977], [36.29165, 34.62991], [36.32399, 34.69334], [36.35135, 34.68516], [36.35384, 34.65447], [36.42941, 34.62505], [36.46003, 34.6378], [36.45299, 34.59438], [36.41429, 34.61175], [36.39846, 34.55672], [36.3369, 34.52629], [36.34745, 34.5002], [36.4442, 34.50165], [36.46179, 34.46541], [36.55853, 34.41609], [36.53039, 34.3798], [36.56556, 34.31881], [36.60778, 34.31009], [36.58667, 34.27667], [36.59195, 34.2316], [36.62537, 34.20251], [36.5128, 34.09916], [36.50576, 34.05982], [36.41078, 34.05253], [36.28589, 33.91981], [36.38263, 33.86579], [36.3967, 33.83365], [36.14517, 33.85118], [36.06778, 33.82927], [35.9341, 33.6596], [36.05723, 33.57904], [35.94465, 33.52774], [35.94816, 33.47886], [35.88668, 33.43183], [35.82577, 33.40479], [35.81324, 33.36354], [35.77477, 33.33609], [35.813, 33.3172], [35.77513, 33.27342], [35.81295, 33.24841], [35.81647, 33.2028], [35.83846, 33.19397], [35.84285, 33.16673], [35.81911, 33.1336], [35.81911, 33.11077], [35.84802, 33.1031], [35.87188, 32.98028], [35.89298, 32.9456], [35.87012, 32.91976], [35.84021, 32.8725], [35.83758, 32.82817], [35.78745, 32.77938], [35.75983, 32.74803], [35.88405, 32.71321], [35.93307, 32.71966], [35.96633, 32.66237], [36.02239, 32.65911], [36.08074, 32.51463], [36.20379, 32.52751], [36.20875, 32.49529], [36.23948, 32.50108], [36.40959, 32.37908], [36.83946, 32.31293], [38.79171, 33.37328], [40.64314, 34.31604], [40.97676, 34.39788], [41.12388, 34.65742], [41.2345, 34.80049], [41.21654, 35.1508], [41.26569, 35.42708], [41.38184, 35.62502], [41.37027, 35.84095], [41.2564, 36.06012], [41.28864, 36.35368], [41.40058, 36.52502], [41.81736, 36.58782], [42.36697, 37.0627], [42.35724, 37.10998], [42.32313, 37.17814], [42.34735, 37.22548], [42.2824, 37.2798], [42.26039, 37.27017], [42.23683, 37.2863]]]] } },
22884     { type: "Feature", properties: { iso1A2: "SZ", iso1A3: "SWZ", iso1N3: "748", wikidata: "Q1050", nameEn: "Eswatini", aliases: ["Swaziland"], groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["268"] }, geometry: { type: "MultiPolygon", coordinates: [[[[31.86881, -25.99973], [31.4175, -25.71886], [31.31237, -25.7431], [31.13073, -25.91558], [30.95819, -26.26303], [30.78927, -26.48271], [30.81101, -26.84722], [30.88826, -26.79622], [30.97757, -26.92706], [30.96088, -27.0245], [31.15027, -27.20151], [31.49834, -27.31549], [31.97592, -27.31675], [31.97463, -27.11057], [32.00893, -26.8096], [32.09664, -26.80721], [32.13315, -26.84345], [32.13409, -26.5317], [32.07352, -26.40185], [32.10435, -26.15656], [32.08599, -26.00978], [32.00916, -25.999], [31.974, -25.95387], [31.86881, -25.99973]]]] } },
22885     { type: "Feature", properties: { iso1A2: "TA", iso1A3: "TAA", wikidata: "Q220982", nameEn: "Tristan da Cunha", aliases: ["SH-TA"], country: "GB", groups: ["SH", "BOTS", "011", "202", "002", "UN"], isoStatus: "excRes", driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["290 8", "44 20"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-13.38232, -34.07258], [-16.67337, -41.9188], [-5.88482, -41.4829], [-13.38232, -34.07258]]]] } },
22886     { type: "Feature", properties: { iso1A2: "TC", iso1A3: "TCA", iso1N3: "796", wikidata: "Q18221", nameEn: "Turks and Caicos Islands", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 649"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-71.70065, 25.7637], [-72.98446, 20.4801], [-69.80718, 21.35956], [-71.70065, 25.7637]]]] } },
22887     { type: "Feature", properties: { iso1A2: "TD", iso1A3: "TCD", iso1N3: "148", wikidata: "Q657", nameEn: "Chad", groups: ["017", "202", "002", "UN"], callingCodes: ["235"] }, geometry: { type: "MultiPolygon", coordinates: [[[[23.99539, 19.49944], [15.99566, 23.49639], [14.99751, 23.00539], [15.19692, 21.99339], [15.20213, 21.49365], [15.28332, 21.44557], [15.62515, 20.95395], [15.57248, 20.92138], [15.55382, 20.86507], [15.56004, 20.79488], [15.59841, 20.74039], [15.6721, 20.70069], [15.99632, 20.35364], [15.75098, 19.93002], [15.6032, 18.77402], [15.50373, 16.89649], [14.37425, 15.72591], [13.86301, 15.04043], [13.78991, 14.87519], [13.809, 14.72915], [13.67878, 14.64013], [13.68573, 14.55276], [13.48259, 14.46704], [13.47559, 14.40881], [13.6302, 13.71094], [14.08251, 13.0797], [14.46881, 13.08259], [14.56101, 12.91036], [14.55058, 12.78256], [14.83314, 12.62963], [14.90827, 12.3269], [14.89019, 12.16593], [14.96952, 12.0925], [15.00146, 12.1223], [15.0349, 12.10698], [15.05786, 12.0608], [15.04808, 11.8731], [15.11579, 11.79313], [15.06595, 11.71126], [15.13149, 11.5537], [15.0585, 11.40481], [15.10021, 11.04101], [15.04957, 11.02347], [15.09127, 10.87431], [15.06737, 10.80921], [15.15532, 10.62846], [15.14936, 10.53915], [15.23724, 10.47764], [15.30874, 10.31063], [15.50535, 10.1098], [15.68761, 9.99344], [15.41408, 9.92876], [15.24618, 9.99246], [15.14043, 9.99246], [15.05999, 9.94845], [14.95722, 9.97926], [14.80082, 9.93818], [14.4673, 10.00264], [14.20411, 10.00055], [14.1317, 9.82413], [14.01793, 9.73169], [13.97544, 9.6365], [14.37094, 9.2954], [14.35707, 9.19611], [14.83566, 8.80557], [15.09484, 8.65982], [15.20426, 8.50892], [15.50743, 7.79302], [15.59272, 7.7696], [15.56964, 7.58936], [15.49743, 7.52179], [15.73118, 7.52006], [15.79942, 7.44149], [16.40703, 7.68809], [16.41583, 7.77971], [16.58315, 7.88657], [16.59415, 7.76444], [16.658, 7.75353], [16.6668, 7.67281], [16.8143, 7.53971], [17.67288, 7.98905], [17.93926, 7.95853], [18.02731, 8.01085], [18.6085, 8.05009], [18.64153, 8.08714], [18.62612, 8.14163], [18.67455, 8.22226], [18.79783, 8.25929], [19.11044, 8.68172], [18.86388, 8.87971], [19.06421, 9.00367], [20.36748, 9.11019], [20.82979, 9.44696], [21.26348, 9.97642], [21.34934, 9.95907], [21.52766, 10.2105], [21.63553, 10.217], [21.71479, 10.29932], [21.72139, 10.64136], [22.45889, 11.00246], [22.87758, 10.91915], [22.97249, 11.21955], [22.93124, 11.41645], [22.7997, 11.40424], [22.54907, 11.64372], [22.64092, 12.07485], [22.48369, 12.02766], [22.50548, 12.16769], [22.38873, 12.45514], [22.46345, 12.61925], [22.22684, 12.74682], [22.15679, 12.66634], [21.98711, 12.63292], [21.89371, 12.68001], [21.81432, 12.81362], [21.94819, 13.05637], [22.02914, 13.13976], [22.1599, 13.19281], [22.29689, 13.3731], [22.08674, 13.77863], [22.22995, 13.96754], [22.5553, 14.11704], [22.55997, 14.23024], [22.44944, 14.24986], [22.38562, 14.58907], [22.70474, 14.69149], [22.66115, 14.86308], [22.99584, 15.22989], [22.99584, 15.40105], [22.92579, 15.47007], [22.93201, 15.55107], [23.10792, 15.71297], [23.38812, 15.69649], [23.62785, 15.7804], [23.99997, 15.69575], [23.99539, 19.49944]]]] } },
22888     { type: "Feature", properties: { iso1A2: "TF", iso1A3: "ATF", iso1N3: "260", wikidata: "Q129003", nameEn: "French Southern Territories", country: "FR", groups: ["EU", "UN"] }, geometry: null },
22889     { type: "Feature", properties: { iso1A2: "TG", iso1A3: "TGO", iso1N3: "768", wikidata: "Q945", nameEn: "Togo", groups: ["011", "202", "002", "UN"], callingCodes: ["228"] }, geometry: { type: "MultiPolygon", coordinates: [[[[0.50388, 11.01011], [-0.13493, 11.14075], [-0.14462, 11.10811], [-0.05733, 11.08628], [-0.0275, 11.11202], [-514e-5, 11.10763], [342e-5, 11.08317], [0.02395, 11.06229], [0.03355, 10.9807], [-63e-4, 10.96417], [-908e-5, 10.91644], [-0.02685, 10.8783], [-0.0228, 10.81916], [-0.07183, 10.76794], [-0.07327, 10.71845], [-0.09141, 10.7147], [-0.05945, 10.63458], [0.12886, 10.53149], [0.18846, 10.4096], [0.29453, 10.41546], [0.33028, 10.30408], [0.39584, 10.31112], [0.35293, 10.09412], [0.41371, 10.06361], [0.41252, 10.02018], [0.36366, 10.03309], [0.32075, 9.72781], [0.34816, 9.71607], [0.34816, 9.66907], [0.32313, 9.6491], [0.28261, 9.69022], [0.26712, 9.66437], [0.29334, 9.59387], [0.36008, 9.6256], [0.38153, 9.58682], [0.23851, 9.57389], [0.2409, 9.52335], [0.30406, 9.521], [0.31241, 9.50337], [0.2254, 9.47869], [0.25758, 9.42696], [0.33148, 9.44812], [0.36485, 9.49749], [0.49118, 9.48339], [0.56388, 9.40697], [0.45424, 9.04581], [0.52455, 8.87746], [0.37319, 8.75262], [0.47211, 8.59945], [0.64731, 8.48866], [0.73432, 8.29529], [0.63897, 8.25873], [0.5913, 8.19622], [0.61156, 8.18324], [0.6056, 8.13959], [0.58891, 8.12779], [0.62943, 7.85751], [0.58295, 7.62368], [0.51979, 7.58706], [0.52455, 7.45354], [0.57223, 7.39326], [0.62943, 7.41099], [0.65327, 7.31643], [0.59606, 7.01252], [0.52217, 6.9723], [0.52098, 6.94391], [0.56508, 6.92971], [0.52853, 6.82921], [0.57406, 6.80348], [0.58176, 6.76049], [0.6497, 6.73682], [0.63659, 6.63857], [0.74862, 6.56517], [0.71048, 6.53083], [0.89283, 6.33779], [0.99652, 6.33779], [1.03108, 6.24064], [1.05969, 6.22998], [1.09187, 6.17074], [1.19966, 6.17069], [1.19771, 6.11522], [1.27574, 5.93551], [1.67336, 6.02702], [1.62913, 6.24075], [1.79826, 6.28221], [1.76906, 6.43189], [1.58105, 6.68619], [1.61812, 6.74843], [1.55877, 6.99737], [1.64249, 6.99562], [1.61838, 9.0527], [1.5649, 9.16941], [1.41746, 9.3226], [1.33675, 9.54765], [1.36624, 9.5951], [1.35507, 9.99525], [0.77666, 10.37665], [0.80358, 10.71459], [0.8804, 10.803], [0.91245, 10.99597], [0.66104, 10.99964], [0.4958, 10.93269], [0.50521, 10.98035], [0.48852, 10.98561], [0.50388, 11.01011]]]] } },
22890     { type: "Feature", properties: { iso1A2: "TH", iso1A3: "THA", iso1N3: "764", wikidata: "Q869", nameEn: "Thailand", groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["66"] }, geometry: { type: "MultiPolygon", coordinates: [[[[100.08404, 20.36626], [99.95721, 20.46301], [99.91616, 20.44986], [99.90499, 20.4487], [99.89692, 20.44789], [99.89301, 20.44311], [99.89168, 20.44548], [99.88451, 20.44596], [99.88211, 20.44488], [99.86383, 20.44371], [99.81096, 20.33687], [99.68255, 20.32077], [99.46008, 20.39673], [99.46077, 20.36198], [99.5569, 20.20676], [99.52943, 20.14811], [99.416, 20.08614], [99.20328, 20.12877], [99.0735, 20.10298], [98.98679, 19.7419], [98.83661, 19.80931], [98.56065, 19.67807], [98.51182, 19.71303], [98.24884, 19.67876], [98.13829, 19.78541], [98.03314, 19.80941], [98.04364, 19.65755], [97.84715, 19.55782], [97.88423, 19.5041], [97.78769, 19.39429], [97.84186, 19.29526], [97.78606, 19.26769], [97.84024, 19.22217], [97.83479, 19.09972], [97.73797, 19.04261], [97.73654, 18.9812], [97.66487, 18.9371], [97.73836, 18.88478], [97.76752, 18.58097], [97.5258, 18.4939], [97.36444, 18.57138], [97.34522, 18.54596], [97.50383, 18.26844], [97.56219, 18.33885], [97.64116, 18.29778], [97.60841, 18.23846], [97.73723, 17.97912], [97.66794, 17.88005], [97.76407, 17.71595], [97.91829, 17.54504], [98.11185, 17.36829], [98.10439, 17.33847], [98.34566, 17.04822], [98.39441, 17.06266], [98.52624, 16.89979], [98.49603, 16.8446], [98.53833, 16.81934], [98.46994, 16.73613], [98.50253, 16.7139], [98.49713, 16.69022], [98.51043, 16.70107], [98.51579, 16.69433], [98.51472, 16.68521], [98.51833, 16.676], [98.51113, 16.64503], [98.5695, 16.62826], [98.57912, 16.55983], [98.63817, 16.47424], [98.68074, 16.27068], [98.84485, 16.42354], [98.92656, 16.36425], [98.8376, 16.11706], [98.69585, 16.13353], [98.57019, 16.04578], [98.59853, 15.87197], [98.541, 15.65406], [98.58598, 15.46821], [98.56027, 15.33471], [98.4866, 15.39154], [98.39351, 15.34177], [98.41906, 15.27103], [98.40522, 15.25268], [98.30446, 15.30667], [98.22, 15.21327], [98.18821, 15.13125], [98.24874, 14.83013], [98.56762, 14.37701], [98.97356, 14.04868], [99.16695, 13.72621], [99.20617, 13.20575], [99.12225, 13.19847], [99.10646, 13.05804], [99.18748, 12.9898], [99.18905, 12.84799], [99.29254, 12.68921], [99.409, 12.60603], [99.47519, 12.1353], [99.56445, 12.14805], [99.53424, 12.02317], [99.64891, 11.82699], [99.64108, 11.78948], [99.5672, 11.62732], [99.47598, 11.62434], [99.39485, 11.3925], [99.31573, 11.32081], [99.32756, 11.28545], [99.06938, 10.94857], [99.02337, 10.97217], [98.99701, 10.92962], [99.0069, 10.85485], [98.86819, 10.78336], [98.78511, 10.68351], [98.77275, 10.62548], [98.81944, 10.52761], [98.7391, 10.31488], [98.55174, 9.92804], [98.52291, 9.92389], [98.47298, 9.95782], [98.33094, 9.91973], [98.12555, 9.44056], [97.63455, 9.60854], [97.19814, 8.18901], [99.31854, 5.99868], [99.50117, 6.44501], [99.91873, 6.50233], [100.0756, 6.4045], [100.12, 6.42105], [100.19511, 6.72559], [100.29651, 6.68439], [100.30828, 6.66462], [100.31618, 6.66781], [100.31884, 6.66423], [100.32671, 6.66526], [100.32607, 6.65933], [100.31929, 6.65413], [100.35413, 6.54932], [100.41152, 6.52299], [100.41791, 6.5189], [100.42351, 6.51762], [100.43027, 6.52389], [100.66986, 6.45086], [100.74361, 6.50811], [100.74822, 6.46231], [100.81045, 6.45086], [100.85884, 6.24929], [101.10313, 6.25617], [101.12618, 6.19431], [101.06165, 6.14161], [101.12388, 6.11411], [101.087, 5.9193], [101.02708, 5.91013], [100.98815, 5.79464], [101.14062, 5.61613], [101.25755, 5.71065], [101.25524, 5.78633], [101.58019, 5.93534], [101.69773, 5.75881], [101.75074, 5.79091], [101.80144, 5.74505], [101.89188, 5.8386], [101.91776, 5.84269], [101.92819, 5.85511], [101.94712, 5.98421], [101.9714, 6.00575], [101.97114, 6.01992], [101.99209, 6.04075], [102.01835, 6.05407], [102.09182, 6.14161], [102.07732, 6.193], [102.08127, 6.22679], [102.09086, 6.23546], [102.46318, 7.22462], [102.47649, 9.66162], [102.52395, 11.25257], [102.91449, 11.65512], [102.90973, 11.75613], [102.83957, 11.8519], [102.78427, 11.98746], [102.77026, 12.06815], [102.70176, 12.1686], [102.73134, 12.37091], [102.78116, 12.40284], [102.7796, 12.43781], [102.57567, 12.65358], [102.51963, 12.66117], [102.4994, 12.71736], [102.53053, 12.77506], [102.49335, 12.92711], [102.48694, 12.97537], [102.52275, 12.99813], [102.46011, 13.08057], [102.43422, 13.09061], [102.36146, 13.26006], [102.36001, 13.31142], [102.34611, 13.35618], [102.35692, 13.38274], [102.35563, 13.47307], [102.361, 13.50551], [102.33828, 13.55613], [102.36859, 13.57488], [102.44601, 13.5637], [102.5358, 13.56933], [102.57573, 13.60461], [102.62483, 13.60883], [102.58635, 13.6286], [102.5481, 13.6589], [102.56848, 13.69366], [102.72727, 13.77806], [102.77864, 13.93374], [102.91251, 14.01531], [102.93275, 14.19044], [103.16469, 14.33075], [103.39353, 14.35639], [103.53518, 14.42575], [103.71109, 14.4348], [103.70175, 14.38052], [103.93836, 14.3398], [104.27616, 14.39861], [104.55014, 14.36091], [104.69335, 14.42726], [104.97667, 14.38806], [105.02804, 14.23722], [105.08408, 14.20402], [105.14012, 14.23873], [105.17748, 14.34432], [105.20894, 14.34967], [105.43783, 14.43865], [105.53864, 14.55731], [105.5121, 14.80802], [105.61162, 15.00037], [105.46661, 15.13132], [105.58043, 15.32724], [105.50662, 15.32054], [105.4692, 15.33709], [105.47635, 15.3796], [105.58191, 15.41031], [105.60446, 15.53301], [105.61756, 15.68792], [105.46573, 15.74742], [105.42285, 15.76971], [105.37959, 15.84074], [105.34115, 15.92737], [105.38508, 15.987], [105.42001, 16.00657], [105.06204, 16.09792], [105.00262, 16.25627], [104.88057, 16.37311], [104.73349, 16.565], [104.76099, 16.69302], [104.7397, 16.81005], [104.76442, 16.84752], [104.7373, 16.91125], [104.73712, 17.01404], [104.80716, 17.19025], [104.80061, 17.39367], [104.69867, 17.53038], [104.45404, 17.66788], [104.35432, 17.82871], [104.2757, 17.86139], [104.21776, 17.99335], [104.10927, 18.10826], [104.06533, 18.21656], [103.97725, 18.33631], [103.93916, 18.33914], [103.85642, 18.28666], [103.82449, 18.33979], [103.699, 18.34125], [103.60957, 18.40528], [103.47773, 18.42841], [103.41044, 18.4486], [103.30977, 18.4341], [103.24779, 18.37807], [103.23818, 18.34875], [103.29757, 18.30475], [103.17093, 18.2618], [103.14994, 18.23172], [103.1493, 18.17799], [103.07343, 18.12351], [103.07823, 18.03833], [103.0566, 18.00144], [103.01998, 17.97095], [102.9912, 17.9949], [102.95812, 18.0054], [102.86323, 17.97531], [102.81988, 17.94233], [102.79044, 17.93612], [102.75954, 17.89561], [102.68538, 17.86653], [102.67543, 17.84529], [102.69946, 17.81686], [102.68194, 17.80151], [102.59485, 17.83537], [102.5896, 17.84889], [102.61432, 17.92273], [102.60971, 17.95411], [102.59234, 17.96127], [102.45523, 17.97106], [102.11359, 18.21532], [101.88485, 18.02474], [101.78087, 18.07559], [101.72294, 17.92867], [101.44667, 17.7392], [101.15108, 17.47586], [100.96541, 17.57926], [101.02185, 17.87637], [101.1793, 18.0544], [101.19118, 18.2125], [101.15108, 18.25624], [101.18227, 18.34367], [101.06047, 18.43247], [101.27585, 18.68875], [101.22832, 18.73377], [101.25803, 18.89545], [101.35606, 19.04716], [101.261, 19.12717], [101.24911, 19.33334], [101.20604, 19.35296], [101.21347, 19.46223], [101.26991, 19.48324], [101.26545, 19.59242], [101.08928, 19.59748], [100.90302, 19.61901], [100.77231, 19.48324], [100.64606, 19.55884], [100.58219, 19.49164], [100.49604, 19.53504], [100.398, 19.75047], [100.5094, 19.87904], [100.58808, 20.15791], [100.55218, 20.17741], [100.51052, 20.14928], [100.47567, 20.19133], [100.4537, 20.19971], [100.44992, 20.23644], [100.41473, 20.25625], [100.37439, 20.35156], [100.33383, 20.4028], [100.25769, 20.3992], [100.22076, 20.31598], [100.16668, 20.2986], [100.1712, 20.24324], [100.11785, 20.24787], [100.09337, 20.26293], [100.09999, 20.31614], [100.08404, 20.36626]]]] } },
22891     { type: "Feature", properties: { iso1A2: "TJ", iso1A3: "TJK", iso1N3: "762", wikidata: "Q863", nameEn: "Tajikistan", groups: ["143", "142", "UN"], callingCodes: ["992"] }, geometry: { type: "MultiPolygon", coordinates: [[[[70.45251, 41.04438], [70.38028, 41.02014], [70.36655, 40.90296], [69.69434, 40.62615], [69.59441, 40.70181], [69.53021, 40.77621], [69.38327, 40.7918], [69.32834, 40.70233], [69.3455, 40.57988], [69.2643, 40.57506], [69.21063, 40.54469], [69.27066, 40.49274], [69.28525, 40.41894], [69.30774, 40.36102], [69.33794, 40.34819], [69.32833, 40.29794], [69.30808, 40.2821], [69.24817, 40.30357], [69.25229, 40.26362], [69.30104, 40.24502], [69.30448, 40.18774], [69.2074, 40.21488], [69.15659, 40.2162], [69.04544, 40.22904], [68.85832, 40.20885], [68.84357, 40.18604], [68.79276, 40.17555], [68.77902, 40.20492], [68.5332, 40.14826], [68.52771, 40.11676], [68.62796, 40.07789], [69.01523, 40.15771], [69.01935, 40.11466], [68.96579, 40.06949], [68.84906, 40.04952], [68.93695, 39.91167], [68.88889, 39.87163], [68.63071, 39.85265], [68.61972, 39.68905], [68.54166, 39.53929], [68.12053, 39.56317], [67.70992, 39.66156], [67.62889, 39.60234], [67.44899, 39.57799], [67.46547, 39.53564], [67.39681, 39.52505], [67.46822, 39.46146], [67.45998, 39.315], [67.36522, 39.31287], [67.33226, 39.23739], [67.67833, 39.14479], [67.68915, 39.00775], [68.09704, 39.02589], [68.19743, 38.85985], [68.06948, 38.82115], [68.12877, 38.73677], [68.05598, 38.71641], [68.0807, 38.64136], [68.05873, 38.56087], [68.11366, 38.47169], [68.06274, 38.39435], [68.13289, 38.40822], [68.40343, 38.19484], [68.27159, 37.91477], [68.12635, 37.93], [67.81566, 37.43107], [67.8474, 37.31594], [67.78329, 37.1834], [67.7803, 37.08978], [67.87917, 37.0591], [68.02194, 36.91923], [68.18542, 37.02074], [68.27605, 37.00977], [68.29253, 37.10621], [68.41201, 37.10402], [68.41888, 37.13906], [68.61851, 37.19815], [68.6798, 37.27906], [68.81438, 37.23862], [68.80889, 37.32494], [68.91189, 37.26704], [68.88168, 37.33368], [68.96407, 37.32603], [69.03274, 37.25174], [69.25152, 37.09426], [69.39529, 37.16752], [69.45022, 37.23315], [69.36645, 37.40462], [69.44954, 37.4869], [69.51888, 37.5844], [69.80041, 37.5746], [69.84435, 37.60616], [69.93362, 37.61378], [69.95971, 37.5659], [70.15015, 37.52519], [70.28243, 37.66706], [70.27694, 37.81258], [70.1863, 37.84296], [70.17206, 37.93276], [70.4898, 38.12546], [70.54673, 38.24541], [70.60407, 38.28046], [70.61526, 38.34774], [70.64966, 38.34999], [70.69189, 38.37031], [70.6761, 38.39144], [70.67438, 38.40597], [70.69807, 38.41861], [70.72485, 38.4131], [70.75455, 38.4252], [70.77132, 38.45548], [70.78581, 38.45502], [70.78702, 38.45031], [70.79766, 38.44944], [70.80521, 38.44447], [70.81697, 38.44507], [70.82538, 38.45394], [70.84376, 38.44688], [70.88719, 38.46826], [70.92728, 38.43021], [70.98693, 38.48862], [71.03545, 38.44779], [71.0556, 38.40176], [71.09542, 38.42517], [71.10592, 38.42077], [71.10957, 38.40671], [71.1451, 38.40106], [71.21291, 38.32797], [71.33114, 38.30339], [71.33869, 38.27335], [71.37803, 38.25641], [71.36444, 38.15358], [71.29878, 38.04429], [71.28922, 38.01272], [71.27622, 37.99946], [71.27278, 37.96496], [71.24969, 37.93031], [71.2809, 37.91995], [71.296, 37.93403], [71.32871, 37.88564], [71.51565, 37.95349], [71.58843, 37.92425], [71.59255, 37.79956], [71.55752, 37.78677], [71.54324, 37.77104], [71.53053, 37.76534], [71.55234, 37.73209], [71.54186, 37.69691], [71.51972, 37.61945], [71.5065, 37.60912], [71.49693, 37.53527], [71.50616, 37.50733], [71.5256, 37.47971], [71.49612, 37.4279], [71.47685, 37.40281], [71.4862, 37.33405], [71.49821, 37.31975], [71.50674, 37.31502], [71.48536, 37.26017], [71.4824, 37.24921], [71.48339, 37.23937], [71.47386, 37.2269], [71.4555, 37.21418], [71.4494, 37.18137], [71.44127, 37.11856], [71.43097, 37.05855], [71.45578, 37.03094], [71.46923, 36.99925], [71.48481, 36.93218], [71.51502, 36.89128], [71.57195, 36.74943], [71.67083, 36.67346], [71.83229, 36.68084], [72.31676, 36.98115], [72.54095, 37.00007], [72.66381, 37.02014], [72.79693, 37.22222], [73.06884, 37.31729], [73.29633, 37.46495], [73.77197, 37.4417], [73.76647, 37.33913], [73.61129, 37.27469], [73.64974, 37.23643], [73.82552, 37.22659], [73.8564, 37.26158], [74.20308, 37.34208], [74.23339, 37.41116], [74.41055, 37.3948], [74.56161, 37.37734], [74.68383, 37.3948], [74.8294, 37.3435], [74.88887, 37.23275], [75.12328, 37.31839], [75.09719, 37.37297], [75.15899, 37.41443], [75.06011, 37.52779], [74.94338, 37.55501], [74.8912, 37.67576], [75.00935, 37.77486], [74.92416, 37.83428], [74.9063, 38.03033], [74.82665, 38.07359], [74.80331, 38.19889], [74.69894, 38.22155], [74.69619, 38.42947], [74.51217, 38.47034], [74.17022, 38.65504], [73.97933, 38.52945], [73.79806, 38.61106], [73.80656, 38.66449], [73.7033, 38.84782], [73.7445, 38.93867], [73.82964, 38.91517], [73.81728, 39.04007], [73.75823, 39.023], [73.60638, 39.24534], [73.54572, 39.27567], [73.55396, 39.3543], [73.5004, 39.38402], [73.59241, 39.40843], [73.59831, 39.46425], [73.45096, 39.46677], [73.31912, 39.38615], [73.18454, 39.35536], [72.85934, 39.35116], [72.62027, 39.39696], [72.33173, 39.33093], [72.23834, 39.17248], [72.17242, 39.2661], [72.09689, 39.26823], [72.04059, 39.36704], [71.90601, 39.27674], [71.79202, 39.27355], [71.7522, 39.32031], [71.80164, 39.40631], [71.76816, 39.45456], [71.62688, 39.44056], [71.5517, 39.45722], [71.55856, 39.57588], [71.49814, 39.61397], [71.08752, 39.50704], [71.06418, 39.41586], [70.7854, 39.38933], [70.64087, 39.58792], [70.44757, 39.60128], [70.2869, 39.53141], [70.11111, 39.58223], [69.87491, 39.53882], [69.68677, 39.59281], [69.3594, 39.52516], [69.26938, 39.8127], [69.35649, 40.01994], [69.43134, 39.98431], [69.43557, 39.92877], [69.53615, 39.93991], [69.5057, 40.03277], [69.53855, 40.0887], [69.53794, 40.11833], [69.55555, 40.12296], [69.57615, 40.10524], [69.64704, 40.12165], [69.67001, 40.10639], [70.01283, 40.23288], [70.58297, 40.00891], [70.57384, 39.99394], [70.47557, 39.93216], [70.55033, 39.96619], [70.58912, 39.95211], [70.65946, 39.9878], [70.65827, 40.0981], [70.7928, 40.12797], [70.80495, 40.16813], [70.9818, 40.22392], [70.8607, 40.217], [70.62342, 40.17396], [70.56394, 40.26421], [70.57149, 40.3442], [70.37511, 40.38605], [70.32626, 40.45174], [70.49871, 40.52503], [70.80009, 40.72825], [70.45251, 41.04438]]], [[[70.68112, 40.90612], [70.6158, 40.97661], [70.56077, 41.00642], [70.54223, 40.98787], [70.57501, 40.98941], [70.6721, 40.90555], [70.68112, 40.90612]]], [[[70.74189, 39.86319], [70.53651, 39.89155], [70.52631, 39.86989], [70.54998, 39.85137], [70.59667, 39.83542], [70.63105, 39.77923], [70.74189, 39.86319]]]] } },
22892     { type: "Feature", properties: { iso1A2: "TK", iso1A3: "TKL", iso1N3: "772", wikidata: "Q36823", nameEn: "Tokelau", country: "NZ", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["690"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-168.251, -9.44289], [-174.18635, -7.80441], [-174.17993, -10.13616], [-168.251, -9.44289]]]] } },
22893     { type: "Feature", properties: { iso1A2: "TL", iso1A3: "TLS", iso1N3: "626", wikidata: "Q574", nameEn: "East Timor", aliases: ["Timor-Leste", "TP"], groups: ["035", "142", "UN"], driveSide: "left", callingCodes: ["670"] }, geometry: { type: "MultiPolygon", coordinates: [[[[124.46701, -9.13002], [124.94011, -8.85617], [124.97742, -9.08128], [125.11764, -8.96359], [125.18632, -9.03142], [125.18907, -9.16434], [125.09434, -9.19669], [125.04044, -9.17093], [124.97892, -9.19281], [125.09025, -9.46406], [125.68138, -9.85176], [127.55165, -9.05052], [127.42116, -8.22471], [125.87691, -8.31789], [125.58506, -7.95311], [124.92337, -8.75859], [124.33472, -9.11416], [124.04628, -9.22671], [124.04286, -9.34243], [124.10539, -9.41206], [124.14517, -9.42324], [124.21247, -9.36904], [124.28115, -9.42189], [124.28115, -9.50453], [124.3535, -9.48493], [124.35258, -9.43002], [124.38554, -9.3582], [124.45971, -9.30263], [124.46701, -9.13002]]]] } },
22894     { type: "Feature", properties: { iso1A2: "TM", iso1A3: "TKM", iso1N3: "795", wikidata: "Q874", nameEn: "Turkmenistan", groups: ["143", "142", "UN"], callingCodes: ["993"] }, geometry: { type: "MultiPolygon", coordinates: [[[[60.5078, 41.21694], [60.06581, 41.4363], [60.18117, 41.60082], [60.06032, 41.76287], [60.08504, 41.80997], [60.33223, 41.75058], [59.95046, 41.97966], [60.0356, 42.01028], [60.04659, 42.08982], [59.96419, 42.1428], [60.00539, 42.212], [59.94633, 42.27655], [59.4341, 42.29738], [59.2955, 42.37064], [59.17317, 42.52248], [58.93422, 42.5407], [58.6266, 42.79314], [58.57991, 42.64988], [58.27504, 42.69632], [58.14321, 42.62159], [58.29427, 42.56497], [58.51674, 42.30348], [58.40688, 42.29535], [58.3492, 42.43335], [57.99214, 42.50021], [57.90975, 42.4374], [57.92897, 42.24047], [57.84932, 42.18555], [57.6296, 42.16519], [57.30275, 42.14076], [57.03633, 41.92043], [56.96218, 41.80383], [57.03359, 41.41777], [57.13796, 41.36625], [57.03423, 41.25435], [56.00314, 41.32584], [55.45471, 41.25609], [54.95182, 41.92424], [54.20635, 42.38477], [52.97575, 42.1308], [52.47884, 41.78034], [52.26048, 41.69249], [51.7708, 40.29239], [53.89734, 37.3464], [54.24565, 37.32047], [54.36211, 37.34912], [54.58664, 37.45809], [54.67247, 37.43532], [54.77822, 37.51597], [54.81804, 37.61285], [54.77684, 37.62264], [54.851, 37.75739], [55.13412, 37.94705], [55.44152, 38.08564], [55.76561, 38.12238], [55.97847, 38.08024], [56.33278, 38.08132], [56.32454, 38.18502], [56.43303, 38.26054], [56.62255, 38.24005], [56.73928, 38.27887], [57.03453, 38.18717], [57.21169, 38.28965], [57.37236, 38.09321], [57.35042, 37.98546], [57.79534, 37.89299], [58.21399, 37.77281], [58.22999, 37.6856], [58.39959, 37.63134], [58.47786, 37.6433], [58.5479, 37.70526], [58.6921, 37.64548], [58.9338, 37.67374], [59.22905, 37.51161], [59.33507, 37.53146], [59.39797, 37.47892], [59.39385, 37.34257], [59.55178, 37.13594], [59.74678, 37.12499], [60.00768, 37.04102], [60.34767, 36.63214], [61.14516, 36.64644], [61.18187, 36.55348], [61.1393, 36.38782], [61.22719, 36.12759], [61.12007, 35.95992], [61.22444, 35.92879], [61.26152, 35.80749], [61.22719, 35.67038], [61.27371, 35.61482], [61.58742, 35.43803], [61.77693, 35.41341], [61.97743, 35.4604], [62.05709, 35.43803], [62.15871, 35.33278], [62.29191, 35.25964], [62.29878, 35.13312], [62.48006, 35.28796], [62.62288, 35.22067], [62.74098, 35.25432], [62.90853, 35.37086], [63.0898, 35.43131], [63.12276, 35.53196], [63.10079, 35.63024], [63.23262, 35.67487], [63.10318, 35.81782], [63.12276, 35.86208], [63.29579, 35.85985], [63.53475, 35.90881], [63.56496, 35.95106], [63.98519, 36.03773], [64.05385, 36.10433], [64.43288, 36.24401], [64.57295, 36.34362], [64.62514, 36.44311], [64.61141, 36.6351], [64.97945, 37.21913], [65.51778, 37.23881], [65.64263, 37.34388], [65.64137, 37.45061], [65.72274, 37.55438], [66.30993, 37.32409], [66.55743, 37.35409], [66.52303, 37.39827], [66.65761, 37.45497], [66.52852, 37.58568], [66.53676, 37.80084], [66.67684, 37.96776], [66.56697, 38.0435], [66.41042, 38.02403], [66.24013, 38.16238], [65.83913, 38.25733], [65.55873, 38.29052], [64.32576, 38.98691], [64.19086, 38.95561], [63.70778, 39.22349], [63.6913, 39.27666], [62.43337, 39.98528], [62.34273, 40.43206], [62.11751, 40.58242], [61.87856, 41.12257], [61.4446, 41.29407], [61.39732, 41.19873], [61.33199, 41.14946], [61.22212, 41.14946], [61.03261, 41.25691], [60.5078, 41.21694]]]] } },
22895     { type: "Feature", properties: { iso1A2: "TN", iso1A3: "TUN", iso1N3: "788", wikidata: "Q948", nameEn: "Tunisia", groups: ["015", "002", "UN"], callingCodes: ["216"] }, geometry: { type: "MultiPolygon", coordinates: [[[[11.2718, 37.6713], [7.89009, 38.19924], [8.59123, 37.14286], [8.64044, 36.9401], [8.62972, 36.86499], [8.67706, 36.8364], [8.57613, 36.78062], [8.46537, 36.7706], [8.47609, 36.66607], [8.16167, 36.48817], [8.18936, 36.44939], [8.40731, 36.42208], [8.2626, 35.91733], [8.26472, 35.73669], [8.35371, 35.66373], [8.36086, 35.47774], [8.30329, 35.29884], [8.47318, 35.23376], [8.3555, 35.10007], [8.30727, 34.95378], [8.25189, 34.92009], [8.29655, 34.72798], [8.20482, 34.57575], [7.86264, 34.3987], [7.81242, 34.21841], [7.74207, 34.16492], [7.66174, 34.20167], [7.52851, 34.06493], [7.54088, 33.7726], [7.73687, 33.42114], [7.83028, 33.18851], [8.11433, 33.10175], [8.1179, 33.05086], [8.31895, 32.83483], [8.35999, 32.50101], [9.07483, 32.07865], [9.55544, 30.23971], [9.76848, 30.34366], [9.88152, 30.34074], [10.29516, 30.90337], [10.12239, 31.42098], [10.31364, 31.72648], [10.48497, 31.72956], [10.62788, 31.96629], [10.7315, 31.97235], [11.04234, 32.2145], [11.53898, 32.4138], [11.57828, 32.48013], [11.46037, 32.6307], [11.51549, 33.09826], [11.55852, 33.1409], [11.58941, 33.36891], [11.2718, 37.6713]]]] } },
22896     { type: "Feature", properties: { iso1A2: "TO", iso1A3: "TON", iso1N3: "776", wikidata: "Q678", nameEn: "Tonga", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["676"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-176.74538, -22.89767], [-180, -22.90585], [-180, -24.21376], [-173.10761, -24.19665], [-173.13438, -14.94228], [-176.76826, -14.95183], [-176.74538, -22.89767]]]] } },
22897     { type: "Feature", properties: { iso1A2: "TR", iso1A3: "TUR", iso1N3: "792", wikidata: "Q43", nameEn: "Turkey", groups: ["145", "142", "UN"], callingCodes: ["90"] }, geometry: { type: "MultiPolygon", coordinates: [[[[41.54366, 41.52185], [40.89217, 41.72528], [34.8305, 42.4581], [28.32297, 41.98371], [28.02971, 41.98066], [27.91479, 41.97902], [27.83492, 41.99709], [27.81235, 41.94803], [27.69949, 41.97515], [27.55191, 41.90928], [27.52379, 41.93756], [27.45478, 41.96591], [27.27411, 42.10409], [27.22376, 42.10152], [27.19251, 42.06028], [27.08486, 42.08735], [27.03277, 42.0809], [26.95638, 42.00741], [26.79143, 41.97386], [26.62996, 41.97644], [26.56051, 41.92995], [26.57961, 41.90024], [26.53968, 41.82653], [26.36952, 41.82265], [26.33589, 41.76802], [26.32952, 41.73637], [26.35957, 41.71149], [26.47958, 41.67037], [26.5209, 41.62592], [26.59196, 41.60491], [26.59742, 41.48058], [26.61767, 41.42281], [26.62997, 41.34613], [26.5837, 41.32131], [26.5209, 41.33993], [26.39861, 41.25053], [26.32259, 41.24929], [26.31928, 41.07386], [26.3606, 41.02027], [26.33297, 40.98388], [26.35894, 40.94292], [26.32259, 40.94042], [26.28623, 40.93005], [26.29441, 40.89119], [26.26169, 40.9168], [26.20856, 40.86048], [26.21351, 40.83298], [26.15685, 40.80709], [26.12854, 40.77339], [26.12495, 40.74283], [26.08638, 40.73214], [26.0754, 40.72772], [26.03489, 40.73051], [25.94795, 40.72797], [26.04292, 40.3958], [25.61285, 40.17161], [25.94257, 39.39358], [26.43357, 39.43096], [26.70773, 39.0312], [26.61814, 38.81372], [26.21136, 38.65436], [26.32173, 38.48731], [26.24183, 38.44695], [26.21136, 38.17558], [27.05537, 37.9131], [27.16428, 37.72343], [26.99377, 37.69034], [26.95583, 37.64989], [27.14757, 37.32], [27.20312, 36.94571], [27.45627, 36.9008], [27.24613, 36.71622], [27.46117, 36.53789], [27.89482, 36.69898], [27.95037, 36.46155], [28.23708, 36.56812], [29.30783, 36.01033], [29.48192, 36.18377], [29.61002, 36.1731], [29.61805, 36.14179], [29.69611, 36.10365], [29.73302, 35.92555], [32.82353, 35.70297], [35.51152, 36.10954], [35.931, 35.92109], [35.98499, 35.94107], [36.00514, 35.94113], [36.01844, 35.92403], [35.99829, 35.88242], [36.11827, 35.85923], [36.13919, 35.83692], [36.14029, 35.81015], [36.1623, 35.80925], [36.17441, 35.92076], [36.19973, 35.95195], [36.25366, 35.96264], [36.27678, 35.94839], [36.29769, 35.96086], [36.28338, 36.00273], [36.30099, 36.00985], [36.33956, 35.98687], [36.37474, 36.01163], [36.39206, 36.22088], [36.4617, 36.20461], [36.50463, 36.2419], [36.6125, 36.22592], [36.68672, 36.23677], [36.65653, 36.33861], [36.6081, 36.33772], [36.54206, 36.49539], [36.58829, 36.58295], [36.57398, 36.65186], [36.62681, 36.71189], [36.61581, 36.74629], [36.66727, 36.82901], [36.99557, 36.75997], [36.99886, 36.74012], [37.04399, 36.73483], [37.04619, 36.71101], [37.01647, 36.69512], [37.02088, 36.66422], [37.08279, 36.63495], [37.10894, 36.6704], [37.16177, 36.66069], [37.21988, 36.6736], [37.47253, 36.63243], [37.49103, 36.66904], [37.68048, 36.75065], [37.81974, 36.76055], [38.21064, 36.91842], [38.38859, 36.90064], [38.55908, 36.84429], [38.74042, 36.70629], [39.03217, 36.70911], [39.21538, 36.66834], [39.81589, 36.75538], [40.69136, 37.0996], [40.90856, 37.13147], [41.21937, 37.07665], [41.515, 37.08084], [42.00894, 37.17209], [42.18225, 37.28569], [42.19301, 37.31323], [42.2112, 37.32491], [42.22257, 37.31395], [42.22381, 37.30238], [42.20454, 37.28715], [42.21548, 37.28026], [42.23683, 37.2863], [42.26039, 37.27017], [42.2824, 37.2798], [42.34735, 37.22548], [42.32313, 37.17814], [42.35724, 37.10998], [42.56725, 37.14878], [42.78887, 37.38615], [42.93705, 37.32015], [43.11403, 37.37436], [43.30083, 37.30629], [43.33508, 37.33105], [43.50787, 37.24436], [43.56702, 37.25675], [43.63085, 37.21957], [43.7009, 37.23692], [43.8052, 37.22825], [43.82699, 37.19477], [43.84878, 37.22205], [43.90949, 37.22453], [44.02002, 37.33229], [44.13521, 37.32486], [44.2613, 37.25055], [44.27998, 37.16501], [44.22239, 37.15756], [44.18503, 37.09551], [44.25975, 36.98119], [44.30645, 36.97373], [44.35937, 37.02843], [44.35315, 37.04955], [44.38117, 37.05825], [44.42631, 37.05825], [44.63179, 37.19229], [44.76698, 37.16162], [44.78319, 37.1431], [44.7868, 37.16644], [44.75986, 37.21549], [44.81021, 37.2915], [44.58449, 37.45018], [44.61401, 37.60165], [44.56887, 37.6429], [44.62096, 37.71985], [44.55498, 37.783], [44.45948, 37.77065], [44.3883, 37.85433], [44.22509, 37.88859], [44.42476, 38.25763], [44.50115, 38.33939], [44.44386, 38.38295], [44.38309, 38.36117], [44.3119, 38.37887], [44.3207, 38.49799], [44.32058, 38.62752], [44.28065, 38.6465], [44.26155, 38.71427], [44.30322, 38.81581], [44.18863, 38.93881], [44.20946, 39.13975], [44.1043, 39.19842], [44.03667, 39.39223], [44.22452, 39.4169], [44.29818, 39.378], [44.37921, 39.4131], [44.42832, 39.4131], [44.41849, 39.56659], [44.48111, 39.61579], [44.47298, 39.68788], [44.6137, 39.78393], [44.65422, 39.72163], [44.71806, 39.71124], [44.81043, 39.62677], [44.80977, 39.65768], [44.75779, 39.7148], [44.61845, 39.8281], [44.46635, 39.97733], [44.26973, 40.04866], [44.1778, 40.02845], [44.1057, 40.03555], [43.92307, 40.01787], [43.65688, 40.11199], [43.65221, 40.14889], [43.71136, 40.16673], [43.59928, 40.34019], [43.60862, 40.43267], [43.54791, 40.47413], [43.63664, 40.54159], [43.7425, 40.66805], [43.74872, 40.7365], [43.67712, 40.84846], [43.67712, 40.93084], [43.58683, 40.98961], [43.47319, 41.02251], [43.44984, 41.0988], [43.4717, 41.12611], [43.44973, 41.17666], [43.36118, 41.2028], [43.23096, 41.17536], [43.1945, 41.25242], [43.13373, 41.25503], [43.21707, 41.30331], [43.02956, 41.37891], [42.8785, 41.50516], [42.84899, 41.47265], [42.78995, 41.50126], [42.84471, 41.58912], [42.72794, 41.59714], [42.59202, 41.58183], [42.51772, 41.43606], [42.26387, 41.49346], [41.95134, 41.52466], [41.81939, 41.43621], [41.7124, 41.47417], [41.7148, 41.4932], [41.54366, 41.52185]]]] } },
22898     { type: "Feature", properties: { iso1A2: "TT", iso1A3: "TTO", iso1N3: "780", wikidata: "Q754", nameEn: "Trinidad and Tobago", groups: ["029", "003", "419", "019", "UN"], driveSide: "left", callingCodes: ["1 868"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-61.62505, 11.18974], [-62.08693, 10.04435], [-60.89962, 9.81445], [-60.07172, 11.77667], [-61.62505, 11.18974]]]] } },
22899     { type: "Feature", properties: { iso1A2: "TV", iso1A3: "TUV", iso1N3: "798", wikidata: "Q672", nameEn: "Tuvalu", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["688"] }, geometry: { type: "MultiPolygon", coordinates: [[[[174, -5], [174, -11.5], [179.99999, -11.5], [179.99999, -5], [174, -5]]]] } },
22900     { type: "Feature", properties: { iso1A2: "TW", iso1A3: "TWN", iso1N3: "158", wikidata: "Q865", nameEn: "Taiwan", aliases: ["RC"], groups: ["030", "142"], callingCodes: ["886"] }, geometry: { type: "MultiPolygon", coordinates: [[[[121.8109, 21.77688], [122.26612, 25.98197], [120.5128, 26.536], [120.0693, 26.3959], [119.78816, 26.2348], [119.98511, 25.37624], [119.42295, 25.0886], [118.6333, 24.46259], [118.42453, 24.54644], [118.35291, 24.51645], [118.28244, 24.51231], [118.11703, 24.39734], [120.69238, 21.52331], [121.8109, 21.77688]]]] } },
22901     { type: "Feature", properties: { iso1A2: "TZ", iso1A3: "TZA", iso1N3: "834", wikidata: "Q924", nameEn: "Tanzania", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["255"] }, geometry: { type: "MultiPolygon", coordinates: [[[[30.80408, -0.99911], [30.76635, -0.9852], [30.70631, -1.01175], [30.64166, -1.06601], [30.47194, -1.0555], [30.45116, -1.10641], [30.50889, -1.16412], [30.57123, -1.33264], [30.71974, -1.43244], [30.84079, -1.64652], [30.80802, -1.91477], [30.89303, -2.08223], [30.83915, -2.35795], [30.54501, -2.41404], [30.41789, -2.66266], [30.52747, -2.65841], [30.40662, -2.86151], [30.4987, -2.9573], [30.57926, -2.89791], [30.6675, -2.98987], [30.83823, -2.97837], [30.84165, -3.25152], [30.45915, -3.56532], [30.22042, -4.01738], [30.03323, -4.26631], [29.88172, -4.35743], [29.82885, -4.36153], [29.77289, -4.41733], [29.75109, -4.45836], [29.63827, -4.44681], [29.43673, -4.44845], [29.52552, -6.2731], [30.2567, -7.14121], [30.79243, -8.27382], [31.00796, -8.58615], [31.37533, -8.60769], [31.57147, -8.70619], [31.57147, -8.81388], [31.71158, -8.91386], [31.81587, -8.88618], [31.94663, -8.93846], [31.94196, -9.02303], [31.98866, -9.07069], [32.08206, -9.04609], [32.16146, -9.05993], [32.25486, -9.13371], [32.43543, -9.11988], [32.49147, -9.14754], [32.53661, -9.24281], [32.75611, -9.28583], [32.76233, -9.31963], [32.95389, -9.40138], [32.99397, -9.36712], [33.14925, -9.49322], [33.31581, -9.48554], [33.48052, -9.62442], [33.76677, -9.58516], [33.93298, -9.71647], [33.9638, -9.62206], [33.95829, -9.54066], [34.03865, -9.49398], [34.54499, -10.0678], [34.51911, -10.12279], [34.57581, -10.56271], [34.65946, -10.6828], [34.67047, -10.93796], [34.61161, -11.01611], [34.63305, -11.11731], [34.79375, -11.32245], [34.91153, -11.39799], [34.96296, -11.57354], [35.63599, -11.55927], [35.82767, -11.41081], [36.19094, -11.57593], [36.19094, -11.70008], [36.62068, -11.72884], [36.80309, -11.56836], [37.3936, -11.68949], [37.76614, -11.53352], [37.8388, -11.3123], [37.93618, -11.26228], [38.21598, -11.27289], [38.47258, -11.4199], [38.88996, -11.16978], [39.24395, -11.17433], [39.58249, -10.96043], [40.00295, -10.80255], [40.44265, -10.4618], [40.74206, -10.25691], [40.14328, -4.64201], [39.62121, -4.68136], [39.44306, -4.93877], [39.21631, -4.67835], [37.81321, -3.69179], [37.75036, -3.54243], [37.63099, -3.50723], [37.5903, -3.42735], [37.71745, -3.304], [37.67199, -3.06222], [34.0824, -1.02264], [34.03084, -1.05101], [34.02286, -1.00779], [33.93107, -0.99298], [30.80408, -0.99911]]]] } },
22902     { type: "Feature", properties: { iso1A2: "UA", iso1A3: "UKR", iso1N3: "804", wikidata: "Q212", nameEn: "Ukraine", groups: ["151", "150", "UN"], callingCodes: ["380"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.57318, 46.10317], [33.61467, 46.13561], [33.63854, 46.14147], [33.61517, 46.22615], [33.646, 46.23028], [33.74047, 46.18555], [33.79715, 46.20482], [33.85234, 46.19863], [33.91549, 46.15938], [34.05272, 46.10838], [34.07311, 46.11769], [34.12929, 46.10494], [34.181, 46.06804], [34.25111, 46.0532], [34.33912, 46.06114], [34.41221, 46.00245], [34.44155, 45.95995], [34.48729, 45.94267], [34.52011, 45.95097], [34.55889, 45.99347], [34.60861, 45.99347], [34.66679, 45.97136], [34.75479, 45.90705], [34.80153, 45.90047], [34.79905, 45.81009], [34.96015, 45.75634], [35.23066, 45.79231], [37.62608, 46.82615], [38.12112, 46.86078], [38.3384, 46.98085], [38.22955, 47.12069], [38.23049, 47.2324], [38.32112, 47.2585], [38.33074, 47.30508], [38.22225, 47.30788], [38.28954, 47.39255], [38.28679, 47.53552], [38.35062, 47.61631], [38.76379, 47.69346], [38.79628, 47.81109], [38.87979, 47.87719], [39.73935, 47.82876], [39.82213, 47.96396], [39.77544, 48.04206], [39.88256, 48.04482], [39.83724, 48.06501], [39.94847, 48.22811], [40.00752, 48.22445], [39.99241, 48.31768], [39.97325, 48.31399], [39.9693, 48.29904], [39.95248, 48.29972], [39.91465, 48.26743], [39.90041, 48.3049], [39.84273, 48.30947], [39.84136, 48.33321], [39.94847, 48.35055], [39.88794, 48.44226], [39.86196, 48.46633], [39.84548, 48.57821], [39.79764, 48.58668], [39.67226, 48.59368], [39.71765, 48.68673], [39.73104, 48.7325], [39.79466, 48.83739], [39.97182, 48.79398], [40.08168, 48.87443], [40.03636, 48.91957], [39.98967, 48.86901], [39.78368, 48.91596], [39.74874, 48.98675], [39.72649, 48.9754], [39.71353, 48.98959], [39.6683, 48.99454], [39.6836, 49.05121], [39.93437, 49.05709], [40.01988, 49.1761], [40.22176, 49.25683], [40.18331, 49.34996], [40.14912, 49.37681], [40.1141, 49.38798], [40.03087, 49.45452], [40.03636, 49.52321], [40.16683, 49.56865], [40.13249, 49.61672], [39.84548, 49.56064], [39.65047, 49.61761], [39.59142, 49.73758], [39.44496, 49.76067], [39.27968, 49.75976], [39.1808, 49.88911], [38.9391, 49.79524], [38.90477, 49.86787], [38.73311, 49.90238], [38.68677, 50.00904], [38.65688, 49.97176], [38.35408, 50.00664], [38.32524, 50.08866], [38.18517, 50.08161], [38.21675, 49.98104], [38.02999, 49.90592], [38.02999, 49.94482], [37.90776, 50.04194], [37.79515, 50.08425], [37.75807, 50.07896], [37.61113, 50.21976], [37.62879, 50.24481], [37.62486, 50.29966], [37.47243, 50.36277], [37.48204, 50.46079], [37.08468, 50.34935], [36.91762, 50.34963], [36.69377, 50.26982], [36.64571, 50.218], [36.56655, 50.2413], [36.58371, 50.28563], [36.47817, 50.31457], [36.30101, 50.29088], [36.20763, 50.3943], [36.06893, 50.45205], [35.8926, 50.43829], [35.80388, 50.41356], [35.73659, 50.35489], [35.61711, 50.35707], [35.58003, 50.45117], [35.47463, 50.49247], [35.39464, 50.64751], [35.48116, 50.66405], [35.47704, 50.77274], [35.41367, 50.80227], [35.39307, 50.92145], [35.32598, 50.94524], [35.40837, 51.04119], [35.31774, 51.08434], [35.20375, 51.04723], [35.12685, 51.16191], [35.14058, 51.23162], [34.97304, 51.2342], [34.82472, 51.17483], [34.6874, 51.18], [34.6613, 51.25053], [34.38802, 51.2746], [34.31661, 51.23936], [34.23009, 51.26429], [34.33446, 51.363], [34.22048, 51.4187], [34.30562, 51.5205], [34.17599, 51.63253], [34.07765, 51.67065], [34.42922, 51.72852], [34.41136, 51.82793], [34.09413, 52.00835], [34.11199, 52.14087], [34.05239, 52.20132], [33.78789, 52.37204], [33.55718, 52.30324], [33.48027, 52.31499], [33.51323, 52.35779], [33.18913, 52.3754], [32.89937, 52.2461], [32.85405, 52.27888], [32.69475, 52.25535], [32.54781, 52.32423], [32.3528, 52.32842], [32.38988, 52.24946], [32.33083, 52.23685], [32.34044, 52.1434], [32.2777, 52.10266], [32.23331, 52.08085], [32.08813, 52.03319], [31.92159, 52.05144], [31.96141, 52.08015], [31.85018, 52.11305], [31.81722, 52.09955], [31.7822, 52.11406], [31.38326, 52.12991], [31.25142, 52.04131], [31.13332, 52.1004], [30.95589, 52.07775], [30.90897, 52.00699], [30.76443, 51.89739], [30.68804, 51.82806], [30.51946, 51.59649], [30.64992, 51.35014], [30.56203, 51.25655], [30.36153, 51.33984], [30.34642, 51.42555], [30.17888, 51.51025], [29.77376, 51.4461], [29.7408, 51.53417], [29.54372, 51.48372], [29.49773, 51.39814], [29.42357, 51.4187], [29.32881, 51.37843], [29.25191, 51.49828], [29.25603, 51.57089], [29.20659, 51.56918], [29.16402, 51.64679], [29.1187, 51.65872], [28.99098, 51.56833], [28.95528, 51.59222], [28.81795, 51.55552], [28.76027, 51.48802], [28.78224, 51.45294], [28.75615, 51.41442], [28.73143, 51.46236], [28.69161, 51.44695], [28.64429, 51.5664], [28.47051, 51.59734], [28.37592, 51.54505], [28.23452, 51.66988], [28.10658, 51.57857], [27.95827, 51.56065], [27.91844, 51.61952], [27.85253, 51.62293], [27.76052, 51.47604], [27.67125, 51.50854], [27.71932, 51.60672], [27.55727, 51.63486], [27.51058, 51.5854], [27.47212, 51.61184], [27.24828, 51.60161], [27.26613, 51.65957], [27.20948, 51.66713], [27.20602, 51.77291], [26.99422, 51.76933], [26.9489, 51.73788], [26.80043, 51.75777], [26.69759, 51.82284], [26.46962, 51.80501], [26.39367, 51.87315], [26.19084, 51.86781], [26.00408, 51.92967], [25.83217, 51.92587], [25.80574, 51.94556], [25.73673, 51.91973], [25.46163, 51.92205], [25.20228, 51.97143], [24.98784, 51.91273], [24.37123, 51.88222], [24.29021, 51.80841], [24.3163, 51.75063], [24.13075, 51.66979], [23.99907, 51.58369], [23.8741, 51.59734], [23.91118, 51.63316], [23.7766, 51.66809], [23.60906, 51.62122], [23.6736, 51.50255], [23.62751, 51.50512], [23.69905, 51.40871], [23.63858, 51.32182], [23.80678, 51.18405], [23.90376, 51.07697], [23.92217, 51.00836], [24.04576, 50.90196], [24.14524, 50.86128], [24.0952, 50.83262], [23.99254, 50.83847], [23.95925, 50.79271], [24.0595, 50.71625], [24.0996, 50.60752], [24.07048, 50.5071], [24.03668, 50.44507], [23.99563, 50.41289], [23.79445, 50.40481], [23.71382, 50.38248], [23.67635, 50.33385], [23.28221, 50.0957], [22.99329, 49.84249], [22.83179, 49.69875], [22.80261, 49.69098], [22.78304, 49.65543], [22.64534, 49.53094], [22.69444, 49.49378], [22.748, 49.32759], [22.72009, 49.20288], [22.86336, 49.10513], [22.89122, 49.00725], [22.56155, 49.08865], [22.54338, 49.01424], [22.48296, 48.99172], [22.42934, 48.92857], [22.34151, 48.68893], [22.21379, 48.6218], [22.16023, 48.56548], [22.14689, 48.4005], [22.2083, 48.42534], [22.38133, 48.23726], [22.49806, 48.25189], [22.59007, 48.15121], [22.58733, 48.10813], [22.66835, 48.09162], [22.73427, 48.12005], [22.81804, 48.11363], [22.87847, 48.04665], [22.84276, 47.98602], [22.89849, 47.95851], [22.94301, 47.96672], [22.92241, 48.02002], [23.0158, 47.99338], [23.08858, 48.00716], [23.1133, 48.08061], [23.15999, 48.12188], [23.27397, 48.08245], [23.33577, 48.0237], [23.4979, 47.96858], [23.52803, 48.01818], [23.5653, 48.00499], [23.63894, 48.00293], [23.66262, 47.98786], [23.75188, 47.99705], [23.80904, 47.98142], [23.8602, 47.9329], [23.89352, 47.94512], [23.94192, 47.94868], [23.96337, 47.96672], [23.98553, 47.96076], [24.00801, 47.968], [24.02999, 47.95087], [24.06466, 47.95317], [24.11281, 47.91487], [24.22566, 47.90231], [24.34926, 47.9244], [24.43578, 47.97131], [24.61994, 47.95062], [24.70632, 47.84428], [24.81893, 47.82031], [24.88896, 47.7234], [25.11144, 47.75203], [25.23778, 47.89403], [25.63878, 47.94924], [25.77723, 47.93919], [26.05901, 47.9897], [26.17711, 47.99246], [26.33504, 48.18418], [26.55202, 48.22445], [26.62823, 48.25804], [26.6839, 48.35828], [26.79239, 48.29071], [26.82809, 48.31629], [26.71274, 48.40388], [26.85556, 48.41095], [26.93384, 48.36558], [27.03821, 48.37653], [27.0231, 48.42485], [27.08078, 48.43214], [27.13434, 48.37288], [27.27855, 48.37534], [27.32159, 48.4434], [27.37604, 48.44398], [27.37741, 48.41026], [27.44333, 48.41209], [27.46942, 48.454], [27.5889, 48.49224], [27.59027, 48.46311], [27.6658, 48.44034], [27.74422, 48.45926], [27.79225, 48.44244], [27.81902, 48.41874], [27.87533, 48.4037], [27.88391, 48.36699], [27.95883, 48.32368], [28.04527, 48.32661], [28.09873, 48.3124], [28.07504, 48.23494], [28.17666, 48.25963], [28.19314, 48.20749], [28.2856, 48.23202], [28.32508, 48.23384], [28.35519, 48.24957], [28.36996, 48.20543], [28.34912, 48.1787], [28.30586, 48.1597], [28.30609, 48.14018], [28.34009, 48.13147], [28.38712, 48.17567], [28.43701, 48.15832], [28.42454, 48.12047], [28.48428, 48.0737], [28.53921, 48.17453], [28.69896, 48.13106], [28.85232, 48.12506], [28.8414, 48.03392], [28.9306, 47.96255], [29.1723, 47.99013], [29.19839, 47.89261], [29.27804, 47.88893], [29.20663, 47.80367], [29.27255, 47.79953], [29.22242, 47.73607], [29.22414, 47.60012], [29.11743, 47.55001], [29.18603, 47.43387], [29.3261, 47.44664], [29.39889, 47.30179], [29.47854, 47.30366], [29.48678, 47.36043], [29.5733, 47.36508], [29.59665, 47.25521], [29.54996, 47.24962], [29.57696, 47.13581], [29.49732, 47.12878], [29.53044, 47.07851], [29.61038, 47.09932], [29.62137, 47.05069], [29.57056, 46.94766], [29.72986, 46.92234], [29.75458, 46.8604], [29.87405, 46.88199], [29.98814, 46.82358], [29.94522, 46.80055], [29.9743, 46.75325], [29.94409, 46.56002], [29.88916, 46.54302], [30.02511, 46.45132], [30.16794, 46.40967], [30.09103, 46.38694], [29.94114, 46.40114], [29.88329, 46.35851], [29.74496, 46.45605], [29.66359, 46.4215], [29.6763, 46.36041], [29.5939, 46.35472], [29.49914, 46.45889], [29.35357, 46.49505], [29.24886, 46.37912], [29.23547, 46.55435], [29.02409, 46.49582], [29.01241, 46.46177], [28.9306, 46.45699], [29.004, 46.31495], [28.98478, 46.31803], [28.94953, 46.25852], [29.06656, 46.19716], [28.94643, 46.09176], [29.00613, 46.04962], [28.98004, 46.00385], [28.74383, 45.96664], [28.78503, 45.83475], [28.69852, 45.81753], [28.70401, 45.78019], [28.52823, 45.73803], [28.47879, 45.66994], [28.51587, 45.6613], [28.54196, 45.58062], [28.49252, 45.56716], [28.51449, 45.49982], [28.43072, 45.48538], [28.41836, 45.51715], [28.30201, 45.54744], [28.21139, 45.46895], [28.28504, 45.43907], [28.34554, 45.32102], [28.5735, 45.24759], [28.71358, 45.22631], [28.78911, 45.24179], [28.81383, 45.3384], [28.94292, 45.28045], [28.96077, 45.33164], [29.24779, 45.43388], [29.42632, 45.44545], [29.59798, 45.38857], [29.68175, 45.26885], [29.65428, 45.25629], [29.69272, 45.19227], [30.04414, 45.08461], [31.62627, 45.50633], [33.54017, 46.0123], [33.59087, 46.06013], [33.57318, 46.10317]]]] } },
22903     { type: "Feature", properties: { iso1A2: "UG", iso1A3: "UGA", iso1N3: "800", wikidata: "Q1036", nameEn: "Uganda", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["256"] }, geometry: { type: "MultiPolygon", coordinates: [[[[33.93107, -0.99298], [33.9264, -0.54188], [33.98449, -0.13079], [33.90936, 0.10581], [34.10067, 0.36372], [34.08727, 0.44713], [34.11408, 0.48884], [34.13493, 0.58118], [34.20196, 0.62289], [34.27345, 0.63182], [34.31516, 0.75693], [34.40041, 0.80266], [34.43349, 0.85254], [34.52369, 1.10692], [34.57427, 1.09868], [34.58029, 1.14712], [34.67562, 1.21265], [34.80223, 1.22754], [34.82606, 1.26626], [34.82606, 1.30944], [34.7918, 1.36752], [34.87819, 1.5596], [34.92734, 1.56109], [34.9899, 1.6668], [34.98692, 1.97348], [34.90947, 2.42447], [34.95267, 2.47209], [34.77244, 2.70272], [34.78137, 2.76223], [34.73967, 2.85447], [34.65774, 2.8753], [34.60114, 2.93034], [34.56242, 3.11478], [34.45815, 3.18319], [34.40006, 3.37949], [34.41794, 3.44342], [34.39112, 3.48802], [34.44922, 3.51627], [34.45815, 3.67385], [34.15429, 3.80464], [34.06046, 4.15235], [33.9873, 4.23316], [33.51264, 3.75068], [33.18356, 3.77812], [33.02852, 3.89296], [32.89746, 3.81339], [32.72021, 3.77327], [32.41337, 3.748], [32.20782, 3.6053], [32.19888, 3.50867], [32.08866, 3.53543], [32.08491, 3.56287], [32.05187, 3.589], [31.95907, 3.57408], [31.96205, 3.6499], [31.86821, 3.78664], [31.81459, 3.82083], [31.72075, 3.74354], [31.50776, 3.63652], [31.50478, 3.67814], [31.29476, 3.8015], [31.16666, 3.79853], [30.97601, 3.693], [30.85153, 3.48867], [30.94081, 3.50847], [30.93486, 3.40737], [30.84251, 3.26908], [30.77101, 3.04897], [30.8574, 2.9508], [30.8857, 2.83923], [30.75612, 2.5863], [30.74271, 2.43601], [30.83059, 2.42559], [30.91102, 2.33332], [30.96911, 2.41071], [31.06593, 2.35862], [31.07934, 2.30207], [31.12104, 2.27676], [31.1985, 2.29462], [31.20148, 2.2217], [31.28042, 2.17853], [31.30127, 2.11006], [30.48503, 1.21675], [30.24671, 1.14974], [30.22139, 0.99635], [30.1484, 0.89805], [29.98307, 0.84295], [29.95477, 0.64486], [29.97413, 0.52124], [29.87284, 0.39166], [29.81922, 0.16824], [29.77454, 0.16675], [29.7224, 0.07291], [29.72687, -0.08051], [29.65091, -0.46777], [29.67474, -0.47969], [29.67176, -0.55714], [29.62708, -0.71055], [29.63006, -0.8997], [29.58388, -0.89821], [29.59061, -1.39016], [29.82657, -1.31187], [29.912, -1.48269], [30.16369, -1.34303], [30.35212, -1.06896], [30.47194, -1.0555], [30.64166, -1.06601], [30.70631, -1.01175], [30.76635, -0.9852], [30.80408, -0.99911], [33.93107, -0.99298]]]] } },
22904     { type: "Feature", properties: { iso1A2: "UM", iso1A3: "UMI", iso1N3: "581", wikidata: "Q16645", nameEn: "United States Minor Outlying Islands", country: "US" }, geometry: null },
22905     { type: "Feature", properties: { iso1A2: "UN", wikidata: "Q1065", nameEn: "United Nations", level: "unitedNations", isoStatus: "excRes" }, geometry: null },
22906     { type: "Feature", properties: { iso1A2: "US", iso1A3: "USA", iso1N3: "840", wikidata: "Q30", nameEn: "United States of America" }, geometry: null },
22907     { type: "Feature", properties: { iso1A2: "UY", iso1A3: "URY", iso1N3: "858", wikidata: "Q77", nameEn: "Uruguay", groups: ["005", "419", "019", "UN"], callingCodes: ["598"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-57.65132, -30.19229], [-57.61478, -30.25165], [-57.64859, -30.35095], [-57.89115, -30.49572], [-57.8024, -30.77193], [-57.89476, -30.95994], [-57.86729, -31.06352], [-57.9908, -31.34924], [-57.98127, -31.3872], [-58.07569, -31.44916], [-58.0023, -31.53084], [-58.00076, -31.65016], [-58.20252, -31.86966], [-58.10036, -32.25338], [-58.22362, -32.52416], [-58.1224, -32.98842], [-58.40475, -33.11777], [-58.44442, -33.84033], [-58.34425, -34.15035], [-57.83001, -34.69099], [-54.78916, -36.21945], [-52.83257, -34.01481], [-53.37138, -33.74313], [-53.39593, -33.75169], [-53.44031, -33.69344], [-53.52794, -33.68908], [-53.53459, -33.16843], [-53.1111, -32.71147], [-53.37671, -32.57005], [-53.39572, -32.58596], [-53.76024, -32.0751], [-54.17384, -31.86168], [-55.50821, -30.91349], [-55.50841, -30.9027], [-55.51862, -30.89828], [-55.52712, -30.89997], [-55.53276, -30.90218], [-55.53431, -30.89714], [-55.54572, -30.89051], [-55.55218, -30.88193], [-55.55373, -30.8732], [-55.5634, -30.8686], [-55.58866, -30.84117], [-55.87388, -31.05053], [-56.4619, -30.38457], [-56.4795, -30.3899], [-56.49267, -30.39471], [-56.90236, -30.02578], [-57.22502, -30.26121], [-57.65132, -30.19229]]]] } },
22908     { type: "Feature", properties: { iso1A2: "UZ", iso1A3: "UZB", iso1N3: "860", wikidata: "Q265", nameEn: "Uzbekistan", groups: ["143", "142", "UN"], callingCodes: ["998"] }, geometry: { type: "MultiPolygon", coordinates: [[[[65.85194, 42.85481], [65.53277, 43.31856], [65.18666, 43.48835], [64.96464, 43.74748], [64.53885, 43.56941], [63.34656, 43.64003], [62.01711, 43.51008], [61.01475, 44.41383], [58.59711, 45.58671], [55.97842, 44.99622], [55.97832, 44.99622], [55.97822, 44.99617], [55.97811, 44.99617], [55.97801, 44.99612], [55.97801, 44.99607], [55.97791, 44.99607], [55.9778, 44.99607], [55.9777, 44.99601], [55.9777, 44.99596], [55.9776, 44.99591], [55.97749, 44.99591], [55.97739, 44.99591], [55.97739, 44.99586], [55.97729, 44.99586], [55.97718, 44.99581], [55.97708, 44.99576], [55.97698, 44.9957], [55.97698, 44.99565], [55.97687, 44.9956], [55.97677, 44.9956], [55.97677, 44.99555], [55.97677, 44.9955], [55.97667, 44.99545], [55.97656, 44.99539], [55.97646, 44.99534], [55.97646, 44.99529], [55.97636, 44.99524], [55.97636, 44.99519], [55.97625, 44.99514], [55.97615, 44.99508], [55.97615, 44.99503], [55.97615, 44.99498], [55.97615, 44.99493], [55.97615, 44.99483], [55.97615, 44.99477], [55.97605, 44.99477], [55.97605, 44.99467], [55.97605, 44.99462], [55.97605, 44.99457], [55.97605, 44.99452], [55.97594, 44.99446], [55.97584, 44.99441], [55.97584, 44.99436], [55.97584, 44.99431], [55.97584, 44.99426], [55.97584, 44.99421], [55.97584, 44.99415], [55.97584, 44.99405], [55.97584, 44.994], [55.97584, 44.9939], [55.97584, 44.99384], [55.97584, 44.99374], [55.97584, 44.99369], [55.97584, 44.99359], [55.97584, 44.99353], [55.97584, 44.99348], [55.97584, 44.99343], [55.97584, 44.99338], [55.97584, 44.99328], [55.97584, 44.99322], [56.00314, 41.32584], [57.03423, 41.25435], [57.13796, 41.36625], [57.03359, 41.41777], [56.96218, 41.80383], [57.03633, 41.92043], [57.30275, 42.14076], [57.6296, 42.16519], [57.84932, 42.18555], [57.92897, 42.24047], [57.90975, 42.4374], [57.99214, 42.50021], [58.3492, 42.43335], [58.40688, 42.29535], [58.51674, 42.30348], [58.29427, 42.56497], [58.14321, 42.62159], [58.27504, 42.69632], [58.57991, 42.64988], [58.6266, 42.79314], [58.93422, 42.5407], [59.17317, 42.52248], [59.2955, 42.37064], [59.4341, 42.29738], [59.94633, 42.27655], [60.00539, 42.212], [59.96419, 42.1428], [60.04659, 42.08982], [60.0356, 42.01028], [59.95046, 41.97966], [60.33223, 41.75058], [60.08504, 41.80997], [60.06032, 41.76287], [60.18117, 41.60082], [60.06581, 41.4363], [60.5078, 41.21694], [61.03261, 41.25691], [61.22212, 41.14946], [61.33199, 41.14946], [61.39732, 41.19873], [61.4446, 41.29407], [61.87856, 41.12257], [62.11751, 40.58242], [62.34273, 40.43206], [62.43337, 39.98528], [63.6913, 39.27666], [63.70778, 39.22349], [64.19086, 38.95561], [64.32576, 38.98691], [65.55873, 38.29052], [65.83913, 38.25733], [66.24013, 38.16238], [66.41042, 38.02403], [66.56697, 38.0435], [66.67684, 37.96776], [66.53676, 37.80084], [66.52852, 37.58568], [66.65761, 37.45497], [66.52303, 37.39827], [66.55743, 37.35409], [66.64699, 37.32958], [66.95598, 37.40162], [67.08232, 37.35469], [67.13039, 37.27168], [67.2224, 37.24545], [67.2581, 37.17216], [67.51868, 37.26102], [67.78329, 37.1834], [67.8474, 37.31594], [67.81566, 37.43107], [68.12635, 37.93], [68.27159, 37.91477], [68.40343, 38.19484], [68.13289, 38.40822], [68.06274, 38.39435], [68.11366, 38.47169], [68.05873, 38.56087], [68.0807, 38.64136], [68.05598, 38.71641], [68.12877, 38.73677], [68.06948, 38.82115], [68.19743, 38.85985], [68.09704, 39.02589], [67.68915, 39.00775], [67.67833, 39.14479], [67.33226, 39.23739], [67.36522, 39.31287], [67.45998, 39.315], [67.46822, 39.46146], [67.39681, 39.52505], [67.46547, 39.53564], [67.44899, 39.57799], [67.62889, 39.60234], [67.70992, 39.66156], [68.12053, 39.56317], [68.54166, 39.53929], [68.61972, 39.68905], [68.63071, 39.85265], [68.88889, 39.87163], [68.93695, 39.91167], [68.84906, 40.04952], [68.96579, 40.06949], [69.01935, 40.11466], [69.01523, 40.15771], [68.62796, 40.07789], [68.52771, 40.11676], [68.5332, 40.14826], [68.77902, 40.20492], [68.79276, 40.17555], [68.84357, 40.18604], [68.85832, 40.20885], [69.04544, 40.22904], [69.15659, 40.2162], [69.2074, 40.21488], [69.30448, 40.18774], [69.30104, 40.24502], [69.25229, 40.26362], [69.24817, 40.30357], [69.30808, 40.2821], [69.32833, 40.29794], [69.33794, 40.34819], [69.30774, 40.36102], [69.28525, 40.41894], [69.27066, 40.49274], [69.21063, 40.54469], [69.2643, 40.57506], [69.3455, 40.57988], [69.32834, 40.70233], [69.38327, 40.7918], [69.53021, 40.77621], [69.59441, 40.70181], [69.69434, 40.62615], [70.36655, 40.90296], [70.38028, 41.02014], [70.45251, 41.04438], [70.80009, 40.72825], [70.49871, 40.52503], [70.32626, 40.45174], [70.37511, 40.38605], [70.57149, 40.3442], [70.56394, 40.26421], [70.62342, 40.17396], [70.8607, 40.217], [70.9818, 40.22392], [70.95789, 40.28761], [71.05901, 40.28765], [71.13042, 40.34106], [71.36663, 40.31593], [71.4246, 40.28619], [71.51215, 40.26943], [71.51549, 40.22986], [71.61725, 40.20615], [71.61931, 40.26775], [71.68386, 40.26984], [71.70569, 40.20391], [71.69621, 40.18492], [71.71719, 40.17886], [71.73054, 40.14818], [71.82646, 40.21872], [71.85002, 40.25647], [72.05464, 40.27586], [71.96401, 40.31907], [72.18648, 40.49893], [72.24368, 40.46091], [72.40346, 40.4007], [72.44191, 40.48222], [72.41513, 40.50856], [72.38384, 40.51535], [72.41714, 40.55736], [72.34406, 40.60144], [72.40517, 40.61917], [72.47795, 40.5532], [72.66713, 40.5219], [72.66713, 40.59076], [72.69579, 40.59778], [72.73995, 40.58409], [72.74768, 40.58051], [72.74862, 40.57131], [72.75982, 40.57273], [72.74894, 40.59592], [72.74866, 40.60873], [72.80137, 40.67856], [72.84754, 40.67229], [72.85372, 40.7116], [72.8722, 40.71111], [72.93296, 40.73089], [72.99133, 40.76457], [73.0612, 40.76678], [73.13412, 40.79122], [73.13267, 40.83512], [73.01869, 40.84681], [72.94454, 40.8094], [72.84291, 40.85512], [72.68157, 40.84942], [72.59136, 40.86947], [72.55109, 40.96046], [72.48742, 40.97136], [72.45206, 41.03018], [72.38511, 41.02785], [72.36138, 41.04384], [72.34757, 41.06104], [72.34026, 41.04539], [72.324, 41.03381], [72.18339, 40.99571], [72.17594, 41.02377], [72.21061, 41.05607], [72.1792, 41.10621], [72.14864, 41.13363], [72.17594, 41.15522], [72.16433, 41.16483], [72.10745, 41.15483], [72.07249, 41.11739], [71.85964, 41.19081], [71.91457, 41.2982], [71.83914, 41.3546], [71.76625, 41.4466], [71.71132, 41.43012], [71.73054, 41.54713], [71.65914, 41.49599], [71.6787, 41.42111], [71.57227, 41.29175], [71.46688, 41.31883], [71.43814, 41.19644], [71.46148, 41.13958], [71.40198, 41.09436], [71.34877, 41.16807], [71.27187, 41.11015], [71.25813, 41.18796], [71.11806, 41.15359], [71.02193, 41.19494], [70.9615, 41.16393], [70.86263, 41.23833], [70.77885, 41.24813], [70.78572, 41.36419], [70.67586, 41.47953], [70.48909, 41.40335], [70.17682, 41.5455], [70.69777, 41.92554], [71.28719, 42.18033], [71.13263, 42.28356], [70.94483, 42.26238], [69.49545, 41.545], [69.45751, 41.56863], [69.39485, 41.51518], [69.45081, 41.46246], [69.37468, 41.46555], [69.35554, 41.47211], [69.29778, 41.43673], [69.25059, 41.46693], [69.23332, 41.45847], [69.22671, 41.46298], [69.20439, 41.45391], [69.18528, 41.45175], [69.17701, 41.43769], [69.15137, 41.43078], [69.05006, 41.36183], [69.01308, 41.22804], [68.7217, 41.05025], [68.73945, 40.96989], [68.65662, 40.93861], [68.62221, 41.03019], [68.49983, 40.99669], [68.58444, 40.91447], [68.63, 40.59358], [68.49983, 40.56437], [67.96736, 40.83798], [68.1271, 41.0324], [68.08273, 41.08148], [67.98511, 41.02794], [67.9644, 41.14611], [66.69129, 41.1311], [66.53302, 41.87388], [66.00546, 41.94455], [66.09482, 42.93426], [65.85194, 42.85481]], [[70.68112, 40.90612], [70.6721, 40.90555], [70.57501, 40.98941], [70.54223, 40.98787], [70.56077, 41.00642], [70.6158, 40.97661], [70.68112, 40.90612]]], [[[71.21139, 40.03369], [71.12218, 40.03052], [71.06305, 40.1771], [71.00236, 40.18154], [71.01035, 40.05481], [71.11037, 40.01984], [71.11668, 39.99291], [71.09063, 39.99], [71.10501, 39.95568], [71.04979, 39.89808], [71.10531, 39.91354], [71.16101, 39.88423], [71.23067, 39.93581], [71.1427, 39.95026], [71.21139, 40.03369]]], [[[71.86463, 39.98598], [71.78838, 40.01404], [71.71511, 39.96348], [71.7504, 39.93701], [71.84316, 39.95582], [71.86463, 39.98598]]]] } },
22909     { type: "Feature", properties: { iso1A2: "VA", iso1A3: "VAT", iso1N3: "336", wikidata: "Q237", nameEn: "Vatican City", aliases: ["Holy See"], groups: ["039", "150"], callingCodes: ["379", "39 06"] }, geometry: { type: "MultiPolygon", coordinates: [[[[12.45181, 41.90056], [12.45446, 41.90028], [12.45435, 41.90143], [12.45626, 41.90172], [12.45691, 41.90125], [12.4577, 41.90115], [12.45834, 41.90174], [12.45826, 41.90281], [12.45755, 41.9033], [12.45762, 41.9058], [12.45561, 41.90629], [12.45543, 41.90738], [12.45091, 41.90625], [12.44984, 41.90545], [12.44815, 41.90326], [12.44582, 41.90194], [12.44834, 41.90095], [12.45181, 41.90056]]]] } },
22910     { type: "Feature", properties: { iso1A2: "VC", iso1A3: "VCT", iso1N3: "670", wikidata: "Q757", nameEn: "St. Vincent and the Grenadines", aliases: ["WV"], groups: ["029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", callingCodes: ["1 784"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-62.64026, 12.69984], [-59.94058, 12.34011], [-61.69315, 14.26451], [-62.64026, 12.69984]]]] } },
22911     { type: "Feature", properties: { iso1A2: "VE", iso1A3: "VEN", iso1N3: "862", wikidata: "Q717", nameEn: "Venezuela", aliases: ["YV"], groups: ["005", "419", "019", "UN"], callingCodes: ["58"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-71.22331, 13.01387], [-70.92579, 11.96275], [-71.3275, 11.85], [-71.9675, 11.65536], [-72.24983, 11.14138], [-72.4767, 11.1117], [-72.88002, 10.44309], [-72.98085, 9.85253], [-73.36905, 9.16636], [-73.02119, 9.27584], [-72.94052, 9.10663], [-72.77415, 9.10165], [-72.65474, 8.61428], [-72.4042, 8.36513], [-72.36987, 8.19976], [-72.35163, 8.01163], [-72.39137, 8.03534], [-72.47213, 7.96106], [-72.48801, 7.94329], [-72.48183, 7.92909], [-72.47042, 7.92306], [-72.45806, 7.91141], [-72.46183, 7.90682], [-72.44454, 7.86031], [-72.46763, 7.79518], [-72.47827, 7.65604], [-72.45321, 7.57232], [-72.47415, 7.48928], [-72.43132, 7.40034], [-72.19437, 7.37034], [-72.04895, 7.03837], [-71.82441, 7.04314], [-71.44118, 7.02116], [-71.42212, 7.03854], [-71.37234, 7.01588], [-71.03941, 6.98163], [-70.7596, 7.09799], [-70.10716, 6.96516], [-69.41843, 6.1072], [-67.60654, 6.2891], [-67.4625, 6.20625], [-67.43513, 5.98835], [-67.58558, 5.84537], [-67.63914, 5.64963], [-67.59141, 5.5369], [-67.83341, 5.31104], [-67.85358, 4.53249], [-67.62671, 3.74303], [-67.50067, 3.75812], [-67.30945, 3.38393], [-67.85862, 2.86727], [-67.85862, 2.79173], [-67.65696, 2.81691], [-67.21967, 2.35778], [-66.85795, 1.22998], [-66.28507, 0.74585], [-65.6727, 1.01353], [-65.50158, 0.92086], [-65.57288, 0.62856], [-65.11657, 1.12046], [-64.38932, 1.5125], [-64.34654, 1.35569], [-64.08274, 1.64792], [-64.06135, 1.94722], [-63.39827, 2.16098], [-63.39114, 2.4317], [-64.0257, 2.48156], [-64.02908, 2.79797], [-64.48379, 3.7879], [-64.84028, 4.24665], [-64.72977, 4.28931], [-64.57648, 4.12576], [-64.14512, 4.12932], [-63.99183, 3.90172], [-63.86082, 3.94796], [-63.70218, 3.91417], [-63.67099, 4.01731], [-63.50611, 3.83592], [-63.42233, 3.89995], [-63.4464, 3.9693], [-63.21111, 3.96219], [-62.98296, 3.59935], [-62.7655, 3.73099], [-62.74411, 4.03331], [-62.57656, 4.04754], [-62.44822, 4.18621], [-62.13094, 4.08309], [-61.54629, 4.2822], [-61.48569, 4.43149], [-61.29675, 4.44216], [-61.31457, 4.54167], [-61.15703, 4.49839], [-60.98303, 4.54167], [-60.86539, 4.70512], [-60.5802, 4.94312], [-60.73204, 5.20931], [-61.4041, 5.95304], [-61.15058, 6.19558], [-61.20762, 6.58174], [-61.13632, 6.70922], [-60.54873, 6.8631], [-60.39419, 6.94847], [-60.28074, 7.1162], [-60.44116, 7.20817], [-60.54098, 7.14804], [-60.63367, 7.25061], [-60.59802, 7.33194], [-60.71923, 7.55817], [-60.64793, 7.56877], [-60.51959, 7.83373], [-60.38056, 7.8302], [-60.02407, 8.04557], [-59.97059, 8.20791], [-59.83156, 8.23261], [-59.80661, 8.28906], [-59.85562, 8.35213], [-59.98508, 8.53046], [-59.54058, 8.6862], [-60.89962, 9.81445], [-62.08693, 10.04435], [-61.62505, 11.18974], [-63.73917, 11.92623], [-63.19938, 16.44103], [-67.89186, 12.4116], [-68.01417, 11.77722], [-68.33524, 11.78151], [-68.99639, 11.79035], [-71.22331, 13.01387]]]] } },
22912     { type: "Feature", properties: { iso1A2: "VG", iso1A3: "VGB", iso1N3: "092", wikidata: "Q25305", nameEn: "British Virgin Islands", country: "GB", groups: ["BOTS", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 284"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-64.47127, 17.55688], [-63.88746, 19.15706], [-65.02435, 18.73231], [-64.86027, 18.39056], [-64.64673, 18.36549], [-64.47127, 17.55688]]]] } },
22913     { type: "Feature", properties: { iso1A2: "VI", iso1A3: "VIR", iso1N3: "850", wikidata: "Q11703", nameEn: "United States Virgin Islands", aliases: ["US-VI"], country: "US", groups: ["Q1352230", "029", "003", "419", "019", "UN"], driveSide: "left", roadSpeedUnit: "mph", roadHeightUnit: "ft", callingCodes: ["1 340"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-65.02435, 18.73231], [-65.27974, 17.56928], [-64.47127, 17.55688], [-64.64673, 18.36549], [-64.86027, 18.39056], [-65.02435, 18.73231]]]] } },
22914     { type: "Feature", properties: { iso1A2: "VN", iso1A3: "VNM", iso1N3: "704", wikidata: "Q881", nameEn: "Vietnam", groups: ["035", "142", "UN"], callingCodes: ["84"] }, geometry: { type: "MultiPolygon", coordinates: [[[[108.10003, 21.47338], [108.0569, 21.53604], [108.02926, 21.54997], [107.97932, 21.54503], [107.97383, 21.53961], [107.97074, 21.54072], [107.96774, 21.53601], [107.95232, 21.5388], [107.92652, 21.58906], [107.90006, 21.5905], [107.86114, 21.65128], [107.80355, 21.66141], [107.66967, 21.60787], [107.56537, 21.61945], [107.54047, 21.5934], [107.49065, 21.59774], [107.49532, 21.62958], [107.47197, 21.6672], [107.41593, 21.64839], [107.38636, 21.59774], [107.35989, 21.60063], [107.35834, 21.6672], [107.29296, 21.74674], [107.24625, 21.7077], [107.20734, 21.71493], [107.10771, 21.79879], [107.02615, 21.81981], [107.00964, 21.85948], [107.06101, 21.88982], [107.05634, 21.92303], [106.99252, 21.95191], [106.97228, 21.92592], [106.92714, 21.93459], [106.9178, 21.97357], [106.81038, 21.97934], [106.74345, 22.00965], [106.72551, 21.97923], [106.69276, 21.96013], [106.68274, 21.99811], [106.70142, 22.02409], [106.6983, 22.15102], [106.67495, 22.1885], [106.69986, 22.22309], [106.6516, 22.33977], [106.55976, 22.34841], [106.57221, 22.37], [106.55665, 22.46498], [106.58395, 22.474], [106.61269, 22.60301], [106.65316, 22.5757], [106.71698, 22.58432], [106.72321, 22.63606], [106.76293, 22.73491], [106.82404, 22.7881], [106.83685, 22.8098], [106.81271, 22.8226], [106.78422, 22.81532], [106.71128, 22.85982], [106.71387, 22.88296], [106.6734, 22.89587], [106.6516, 22.86862], [106.60179, 22.92884], [106.55976, 22.92311], [106.51306, 22.94891], [106.49749, 22.91164], [106.34961, 22.86718], [106.27022, 22.87722], [106.19705, 22.98475], [106.00179, 22.99049], [105.99568, 22.94178], [105.90119, 22.94168], [105.8726, 22.92756], [105.72382, 23.06641], [105.57594, 23.075], [105.56037, 23.16806], [105.49966, 23.20669], [105.42805, 23.30824], [105.40782, 23.28107], [105.32376, 23.39684], [105.22569, 23.27249], [105.17276, 23.28679], [105.11672, 23.25247], [105.07002, 23.26248], [104.98712, 23.19176], [104.96532, 23.20463], [104.9486, 23.17235], [104.91435, 23.18666], [104.87992, 23.17141], [104.87382, 23.12854], [104.79478, 23.12934], [104.8334, 23.01484], [104.86765, 22.95178], [104.84942, 22.93631], [104.77114, 22.90017], [104.72755, 22.81984], [104.65283, 22.83419], [104.60457, 22.81841], [104.58122, 22.85571], [104.47225, 22.75813], [104.35593, 22.69353], [104.25683, 22.76534], [104.27084, 22.8457], [104.11384, 22.80363], [104.03734, 22.72945], [104.01088, 22.51823], [103.99247, 22.51958], [103.97384, 22.50634], [103.96783, 22.51173], [103.96352, 22.50584], [103.95191, 22.5134], [103.94513, 22.52553], [103.93286, 22.52703], [103.87904, 22.56683], [103.64506, 22.79979], [103.56255, 22.69499], [103.57812, 22.65764], [103.52675, 22.59155], [103.43646, 22.70648], [103.43179, 22.75816], [103.32282, 22.8127], [103.28079, 22.68063], [103.18895, 22.64471], [103.15782, 22.59873], [103.17961, 22.55705], [103.07843, 22.50097], [103.0722, 22.44775], [102.9321, 22.48659], [102.8636, 22.60735], [102.60675, 22.73376], [102.57095, 22.7036], [102.51802, 22.77969], [102.46665, 22.77108], [102.42618, 22.69212], [102.38415, 22.67919], [102.41061, 22.64184], [102.25339, 22.4607], [102.26428, 22.41321], [102.16621, 22.43336], [102.14099, 22.40092], [102.18712, 22.30403], [102.51734, 22.02676], [102.49092, 21.99002], [102.62301, 21.91447], [102.67145, 21.65894], [102.74189, 21.66713], [102.82115, 21.73667], [102.81894, 21.83888], [102.85637, 21.84501], [102.86077, 21.71213], [102.97965, 21.74076], [102.98846, 21.58936], [102.86297, 21.4255], [102.94223, 21.46034], [102.88939, 21.3107], [102.80794, 21.25736], [102.89825, 21.24707], [102.97745, 21.05821], [103.03469, 21.05821], [103.12055, 20.89994], [103.21497, 20.89832], [103.38032, 20.79501], [103.45737, 20.82382], [103.68633, 20.66324], [103.73478, 20.6669], [103.82282, 20.8732], [103.98024, 20.91531], [104.11121, 20.96779], [104.27412, 20.91433], [104.63957, 20.6653], [104.38199, 20.47155], [104.40621, 20.3849], [104.47886, 20.37459], [104.66158, 20.47774], [104.72102, 20.40554], [104.62195, 20.36633], [104.61315, 20.24452], [104.86852, 20.14121], [104.91695, 20.15567], [104.9874, 20.09573], [104.8465, 19.91783], [104.8355, 19.80395], [104.68359, 19.72729], [104.64837, 19.62365], [104.53169, 19.61743], [104.41281, 19.70035], [104.23229, 19.70242], [104.06498, 19.66926], [104.05617, 19.61743], [104.10832, 19.51575], [104.06058, 19.43484], [103.87125, 19.31854], [104.5361, 18.97747], [104.64617, 18.85668], [105.12829, 18.70453], [105.19654, 18.64196], [105.1327, 18.58355], [105.10408, 18.43533], [105.15942, 18.38691], [105.38366, 18.15315], [105.46292, 18.22008], [105.64784, 17.96687], [105.60381, 17.89356], [105.76612, 17.67147], [105.85744, 17.63221], [106.09019, 17.36399], [106.18991, 17.28227], [106.24444, 17.24714], [106.29287, 17.3018], [106.31929, 17.20509], [106.43597, 17.01362], [106.50862, 16.9673], [106.55045, 17.0031], [106.54824, 16.92729], [106.51963, 16.92097], [106.52183, 16.87884], [106.55265, 16.86831], [106.55485, 16.68704], [106.59013, 16.62259], [106.58267, 16.6012], [106.61477, 16.60713], [106.66052, 16.56892], [106.65832, 16.47816], [106.74418, 16.41904], [106.84104, 16.55415], [106.88727, 16.52671], [106.88067, 16.43594], [106.96638, 16.34938], [106.97385, 16.30204], [107.02597, 16.31132], [107.09091, 16.3092], [107.15035, 16.26271], [107.14595, 16.17816], [107.25822, 16.13587], [107.33968, 16.05549], [107.44975, 16.08511], [107.46296, 16.01106], [107.39471, 15.88829], [107.34188, 15.89464], [107.21419, 15.83747], [107.21859, 15.74638], [107.27143, 15.71459], [107.27583, 15.62769], [107.34408, 15.62345], [107.3815, 15.49832], [107.50699, 15.48771], [107.53341, 15.40496], [107.62367, 15.42193], [107.60605, 15.37524], [107.62587, 15.2266], [107.58844, 15.20111], [107.61926, 15.13949], [107.61486, 15.0566], [107.46516, 15.00982], [107.48277, 14.93751], [107.59285, 14.87795], [107.51579, 14.79282], [107.54361, 14.69092], [107.55371, 14.628], [107.52102, 14.59034], [107.52569, 14.54665], [107.48521, 14.40346], [107.44941, 14.41552], [107.39493, 14.32655], [107.40427, 14.24509], [107.33577, 14.11832], [107.37158, 14.07906], [107.35757, 14.02319], [107.38247, 13.99147], [107.44318, 13.99751], [107.46498, 13.91593], [107.45252, 13.78897], [107.53503, 13.73908], [107.61909, 13.52577], [107.62843, 13.3668], [107.49144, 13.01215], [107.49611, 12.88926], [107.55993, 12.7982], [107.5755, 12.52177], [107.55059, 12.36824], [107.4463, 12.29373], [107.42917, 12.24657], [107.34511, 12.33327], [107.15831, 12.27547], [106.99953, 12.08983], [106.92325, 12.06548], [106.79405, 12.0807], [106.70687, 11.96956], [106.4111, 11.97413], [106.4687, 11.86751], [106.44068, 11.86294], [106.44535, 11.8279], [106.41577, 11.76999], [106.45158, 11.68616], [106.44691, 11.66787], [106.37219, 11.69836], [106.30525, 11.67549], [106.26478, 11.72122], [106.18539, 11.75171], [106.13158, 11.73283], [106.06708, 11.77761], [106.02038, 11.77457], [106.00792, 11.7197], [105.95188, 11.63738], [105.88962, 11.67854], [105.8507, 11.66635], [105.80867, 11.60536], [105.81645, 11.56876], [105.87328, 11.55953], [105.88962, 11.43605], [105.86782, 11.28343], [106.10444, 11.07879], [106.1527, 11.10476], [106.1757, 11.07301], [106.20095, 10.97795], [106.14301, 10.98176], [106.18539, 10.79451], [106.06708, 10.8098], [105.94535, 10.9168], [105.93403, 10.83853], [105.84603, 10.85873], [105.86376, 10.89839], [105.77751, 11.03671], [105.50045, 10.94586], [105.42884, 10.96878], [105.34011, 10.86179], [105.11449, 10.96332], [105.08326, 10.95656], [105.02722, 10.89236], [105.09571, 10.72722], [104.95094, 10.64003], [104.87933, 10.52833], [104.59018, 10.53073], [104.49869, 10.4057], [104.47963, 10.43046], [104.43778, 10.42386], [103.99198, 10.48391], [102.47649, 9.66162], [104.81582, 8.03101], [109.55486, 8.10026], [111.60491, 13.57105], [108.00365, 17.98159], [108.10003, 21.47338]]]] } },
22915     { type: "Feature", properties: { iso1A2: "VU", iso1A3: "VUT", iso1N3: "548", wikidata: "Q686", nameEn: "Vanuatu", groups: ["054", "009", "UN"], callingCodes: ["678"] }, geometry: { type: "MultiPolygon", coordinates: [[[[156.73836, -14.50464], [174.245, -23.1974], [172.71443, -12.01327], [156.73836, -14.50464]]]] } },
22916     { type: "Feature", properties: { iso1A2: "WF", iso1A3: "WLF", iso1N3: "876", wikidata: "Q35555", nameEn: "Wallis and Futuna", country: "FR", groups: ["EU", "Q1451600", "061", "009", "UN"], callingCodes: ["681"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-178.66551, -14.32452], [-176.76826, -14.95183], [-175.59809, -12.61507], [-178.66551, -14.32452]]]] } },
22917     { type: "Feature", properties: { iso1A2: "WS", iso1A3: "WSM", iso1N3: "882", wikidata: "Q683", nameEn: "Samoa", groups: ["061", "009", "UN"], driveSide: "left", callingCodes: ["685"] }, geometry: { type: "MultiPolygon", coordinates: [[[[-173.74402, -14.26669], [-170.99605, -15.1275], [-171.39864, -10.21587], [-173.74402, -14.26669]]]] } },
22918     { type: "Feature", properties: { iso1A2: "XK", iso1A3: "XKX", wikidata: "Q1246", nameEn: "Kosovo", aliases: ["KV"], groups: ["039", "150"], isoStatus: "usrAssn", callingCodes: ["383"] }, geometry: { type: "MultiPolygon", coordinates: [[[[21.39045, 42.74888], [21.44047, 42.87276], [21.36941, 42.87397], [21.32974, 42.90424], [21.2719, 42.8994], [21.23534, 42.95523], [21.23877, 43.00848], [21.2041, 43.02277], [21.16734, 42.99694], [21.14465, 43.11089], [21.08952, 43.13471], [21.05378, 43.10707], [21.00749, 43.13984], [20.96287, 43.12416], [20.83727, 43.17842], [20.88685, 43.21697], [20.82145, 43.26769], [20.73811, 43.25068], [20.68688, 43.21335], [20.59929, 43.20492], [20.69515, 43.09641], [20.64557, 43.00826], [20.59929, 43.01067], [20.48692, 42.93208], [20.53484, 42.8885], [20.43734, 42.83157], [20.40594, 42.84853], [20.35692, 42.8335], [20.27869, 42.81945], [20.2539, 42.76245], [20.04898, 42.77701], [20.02088, 42.74789], [20.02915, 42.71147], [20.0969, 42.65559], [20.07761, 42.55582], [20.17127, 42.50469], [20.21797, 42.41237], [20.24399, 42.32168], [20.34479, 42.32656], [20.3819, 42.3029], [20.48857, 42.25444], [20.56955, 42.12097], [20.55633, 42.08173], [20.59434, 42.03879], [20.63069, 41.94913], [20.57946, 41.91593], [20.59524, 41.8818], [20.68523, 41.85318], [20.76786, 41.91839], [20.75464, 42.05229], [21.11491, 42.20794], [21.16614, 42.19815], [21.22728, 42.08909], [21.31983, 42.10993], [21.29913, 42.13954], [21.30496, 42.1418], [21.38428, 42.24465], [21.43882, 42.23609], [21.43882, 42.2789], [21.50823, 42.27156], [21.52145, 42.24465], [21.58992, 42.25915], [21.56772, 42.30946], [21.5264, 42.33634], [21.53467, 42.36809], [21.57021, 42.3647], [21.59029, 42.38042], [21.62887, 42.37664], [21.64209, 42.41081], [21.62556, 42.45106], [21.7035, 42.51899], [21.70522, 42.54176], [21.7327, 42.55041], [21.75672, 42.62695], [21.79413, 42.65923], [21.75025, 42.70125], [21.6626, 42.67813], [21.58755, 42.70418], [21.59154, 42.72643], [21.47498, 42.74695], [21.39045, 42.74888]]]] } },
22919     { type: "Feature", properties: { iso1A2: "YE", iso1A3: "YEM", iso1N3: "887", wikidata: "Q805", nameEn: "Yemen", groups: ["145", "142", "UN"], callingCodes: ["967"] }, geometry: { type: "MultiPolygon", coordinates: [[[[57.49095, 8.14549], [52.81185, 17.28568], [52.74267, 17.29519], [52.78009, 17.35124], [52.00311, 19.00083], [49.04884, 18.59899], [48.19996, 18.20584], [47.58351, 17.50366], [47.48245, 17.10808], [47.00571, 16.94765], [46.76494, 17.29151], [46.31018, 17.20464], [44.50126, 17.47475], [43.70631, 17.35762], [43.43005, 17.56148], [43.29185, 17.53224], [43.22533, 17.38343], [43.32653, 17.31179], [43.20156, 17.25901], [43.17787, 17.14717], [43.23967, 17.03428], [43.18233, 17.02673], [43.1813, 16.98438], [43.19328, 16.94703], [43.1398, 16.90696], [43.18338, 16.84852], [43.22012, 16.83932], [43.22956, 16.80613], [43.24801, 16.80613], [43.26303, 16.79479], [43.25857, 16.75304], [43.21325, 16.74416], [43.22066, 16.65179], [43.15274, 16.67248], [43.11601, 16.53166], [42.97215, 16.51093], [42.94351, 16.49467], [42.94625, 16.39721], [42.76801, 16.40371], [42.15205, 16.40211], [40.99158, 15.81743], [43.29075, 12.79154], [43.32909, 12.59711], [43.90659, 12.3823], [51.12877, 12.56479], [57.49095, 8.14549]]]] } },
22920     { type: "Feature", properties: { iso1A2: "YT", iso1A3: "MYT", iso1N3: "175", wikidata: "Q17063", nameEn: "Mayotte", country: "FR", groups: ["Q3320166", "EU", "014", "202", "002", "UN"], callingCodes: ["262"] }, geometry: { type: "MultiPolygon", coordinates: [[[[43.28731, -13.97126], [45.54824, -13.22353], [45.4971, -11.75965], [43.28731, -13.97126]]]] } },
22921     { type: "Feature", properties: { iso1A2: "ZA", iso1A3: "ZAF", iso1N3: "710", wikidata: "Q258", nameEn: "South Africa", groups: ["018", "202", "002", "UN"], driveSide: "left", callingCodes: ["27"] }, geometry: { type: "MultiPolygon", coordinates: [[[[31.30611, -22.422], [31.16344, -22.32599], [31.08932, -22.34884], [30.86696, -22.28907], [30.6294, -22.32599], [30.48686, -22.31368], [30.38614, -22.34533], [30.28351, -22.35587], [30.2265, -22.2961], [30.13147, -22.30841], [29.92242, -22.19408], [29.76848, -22.14128], [29.64609, -22.12917], [29.37703, -22.19581], [29.21955, -22.17771], [29.18974, -22.18599], [29.15268, -22.21399], [29.10881, -22.21202], [29.0151, -22.22907], [28.91889, -22.44299], [28.63287, -22.55887], [28.34874, -22.5694], [28.04562, -22.8394], [28.04752, -22.90243], [27.93729, -22.96194], [27.93539, -23.04941], [27.74154, -23.2137], [27.6066, -23.21894], [27.52393, -23.37952], [27.33768, -23.40917], [26.99749, -23.65486], [26.84165, -24.24885], [26.51667, -24.47219], [26.46346, -24.60358], [26.39409, -24.63468], [25.8515, -24.75727], [25.84295, -24.78661], [25.88571, -24.87802], [25.72702, -25.25503], [25.69661, -25.29284], [25.6643, -25.4491], [25.58543, -25.6343], [25.33076, -25.76616], [25.12266, -25.75931], [25.01718, -25.72507], [24.8946, -25.80723], [24.67319, -25.81749], [24.44703, -25.73021], [24.36531, -25.773], [24.18287, -25.62916], [23.9244, -25.64286], [23.47588, -25.29971], [23.03497, -25.29971], [22.86012, -25.50572], [22.70808, -25.99186], [22.56365, -26.19668], [22.41921, -26.23078], [22.21206, -26.3773], [22.06192, -26.61882], [21.90703, -26.66808], [21.83291, -26.65959], [21.77114, -26.69015], [21.7854, -26.79199], [21.69322, -26.86152], [21.37869, -26.82083], [21.13353, -26.86661], [20.87031, -26.80047], [20.68596, -26.9039], [20.63275, -26.78181], [20.61754, -26.4692], [20.86081, -26.14892], [20.64795, -25.47827], [20.29826, -24.94869], [20.03678, -24.81004], [20.02809, -24.78725], [19.99817, -24.76768], [19.99882, -28.42622], [18.99885, -28.89165], [17.4579, -28.68718], [17.15405, -28.08573], [16.90446, -28.057], [16.59922, -28.53246], [16.46592, -28.57126], [16.45332, -28.63117], [12.51595, -32.27486], [38.88176, -48.03306], [34.51034, -26.91792], [32.35222, -26.86027], [32.29584, -26.852], [32.22302, -26.84136], [32.19409, -26.84032], [32.13315, -26.84345], [32.09664, -26.80721], [32.00893, -26.8096], [31.97463, -27.11057], [31.97592, -27.31675], [31.49834, -27.31549], [31.15027, -27.20151], [30.96088, -27.0245], [30.97757, -26.92706], [30.88826, -26.79622], [30.81101, -26.84722], [30.78927, -26.48271], [30.95819, -26.26303], [31.13073, -25.91558], [31.31237, -25.7431], [31.4175, -25.71886], [31.86881, -25.99973], [31.974, -25.95387], [31.92649, -25.84216], [32.00631, -25.65044], [31.97875, -25.46356], [32.01676, -25.38117], [32.03196, -25.10785], [31.9835, -24.29983], [31.90368, -24.18892], [31.87707, -23.95293], [31.77445, -23.90082], [31.70223, -23.72695], [31.67942, -23.60858], [31.56539, -23.47268], [31.55779, -23.176], [31.30611, -22.422]], [[29.33204, -29.45598], [29.28545, -29.58456], [29.12553, -29.76266], [29.16548, -29.91706], [28.9338, -30.05072], [28.80222, -30.10579], [28.68627, -30.12885], [28.399, -30.1592], [28.2319, -30.28476], [28.12073, -30.68072], [27.74814, -30.60635], [27.69467, -30.55862], [27.67819, -30.53437], [27.6521, -30.51707], [27.62137, -30.50509], [27.56781, -30.44562], [27.56901, -30.42504], [27.45452, -30.32239], [27.38108, -30.33456], [27.36649, -30.27246], [27.37293, -30.19401], [27.40778, -30.14577], [27.32555, -30.14785], [27.29603, -30.05473], [27.22719, -30.00718], [27.09489, -29.72796], [27.01016, -29.65439], [27.33464, -29.48161], [27.4358, -29.33465], [27.47254, -29.31968], [27.45125, -29.29708], [27.48679, -29.29349], [27.54258, -29.25575], [27.5158, -29.2261], [27.55974, -29.18954], [27.75458, -28.89839], [27.8907, -28.91612], [27.88933, -28.88156], [27.9392, -28.84864], [27.98675, -28.8787], [28.02503, -28.85991], [28.1317, -28.7293], [28.2348, -28.69471], [28.30518, -28.69531], [28.40612, -28.6215], [28.65091, -28.57025], [28.68043, -28.58744], [29.40524, -29.21246], [29.44883, -29.3772], [29.33204, -29.45598]]]] } },
22922     { type: "Feature", properties: { iso1A2: "ZM", iso1A3: "ZMB", iso1N3: "894", wikidata: "Q953", nameEn: "Zambia", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["260"] }, geometry: { type: "MultiPolygon", coordinates: [[[[32.95389, -9.40138], [32.76233, -9.31963], [32.75611, -9.28583], [32.53661, -9.24281], [32.49147, -9.14754], [32.43543, -9.11988], [32.25486, -9.13371], [32.16146, -9.05993], [32.08206, -9.04609], [31.98866, -9.07069], [31.94196, -9.02303], [31.94663, -8.93846], [31.81587, -8.88618], [31.71158, -8.91386], [31.57147, -8.81388], [31.57147, -8.70619], [31.37533, -8.60769], [31.00796, -8.58615], [30.79243, -8.27382], [28.88917, -8.4831], [28.9711, -8.66935], [28.38526, -9.23393], [28.36562, -9.30091], [28.52636, -9.35379], [28.51627, -9.44726], [28.56208, -9.49122], [28.68532, -9.78], [28.62795, -9.92942], [28.65032, -10.65133], [28.37241, -11.57848], [28.48357, -11.87532], [29.18592, -12.37921], [29.4992, -12.43843], [29.48404, -12.23604], [29.8139, -12.14898], [29.81551, -13.44683], [29.65078, -13.41844], [29.60531, -13.21685], [29.01918, -13.41353], [28.33199, -12.41375], [27.59932, -12.22123], [27.21025, -11.76157], [27.22541, -11.60323], [27.04351, -11.61312], [26.88687, -12.01868], [26.01777, -11.91488], [25.33058, -11.65767], [25.34069, -11.19707], [24.42612, -11.44975], [24.34528, -11.06816], [24.00027, -10.89356], [24.02603, -11.15368], [23.98804, -12.13149], [24.06672, -12.29058], [23.90937, -12.844], [24.03339, -12.99091], [21.97988, -13.00148], [22.00323, -16.18028], [22.17217, -16.50269], [23.20038, -17.47563], [23.47474, -17.62877], [24.23619, -17.47489], [24.32811, -17.49082], [24.38712, -17.46818], [24.5621, -17.52963], [24.70864, -17.49501], [25.00198, -17.58221], [25.26433, -17.79571], [25.51646, -17.86232], [25.6827, -17.81987], [25.85738, -17.91403], [25.85892, -17.97726], [26.08925, -17.98168], [26.0908, -17.93021], [26.21601, -17.88608], [26.55918, -17.99638], [26.68403, -18.07411], [26.74314, -18.0199], [26.89926, -17.98756], [27.14196, -17.81398], [27.30736, -17.60487], [27.61377, -17.34378], [27.62795, -17.24365], [27.83141, -16.96274], [28.73725, -16.5528], [28.76199, -16.51575], [28.81454, -16.48611], [28.8501, -16.04537], [28.9243, -15.93987], [29.01298, -15.93805], [29.21955, -15.76589], [29.4437, -15.68702], [29.8317, -15.6126], [30.35574, -15.6513], [30.41902, -15.62269], [30.22098, -14.99447], [33.24249, -14.00019], [33.16749, -13.93992], [33.07568, -13.98447], [33.02977, -14.05022], [32.99042, -13.95689], [32.88985, -13.82956], [32.79015, -13.80755], [32.76962, -13.77224], [32.84528, -13.71576], [32.7828, -13.64805], [32.68654, -13.64268], [32.66468, -13.60019], [32.68436, -13.55769], [32.73683, -13.57682], [32.84176, -13.52794], [32.86113, -13.47292], [33.0078, -13.19492], [32.98289, -13.12671], [33.02181, -12.88707], [32.96733, -12.88251], [32.94397, -12.76868], [33.05917, -12.59554], [33.18837, -12.61377], [33.28177, -12.54692], [33.37517, -12.54085], [33.54485, -12.35996], [33.47636, -12.32498], [33.3705, -12.34931], [33.25998, -12.14242], [33.33937, -11.91252], [33.32692, -11.59248], [33.24252, -11.59302], [33.23663, -11.40637], [33.29267, -11.43536], [33.29267, -11.3789], [33.39697, -11.15296], [33.25998, -10.88862], [33.28022, -10.84428], [33.47636, -10.78465], [33.70675, -10.56896], [33.54797, -10.36077], [33.53863, -10.20148], [33.31297, -10.05133], [33.37902, -9.9104], [33.36581, -9.81063], [33.31517, -9.82364], [33.2095, -9.61099], [33.12144, -9.58929], [33.10163, -9.66525], [33.05485, -9.61316], [33.00256, -9.63053], [33.00476, -9.5133], [32.95389, -9.40138]]]] } },
22923     { type: "Feature", properties: { iso1A2: "ZW", iso1A3: "ZWE", iso1N3: "716", wikidata: "Q954", nameEn: "Zimbabwe", groups: ["014", "202", "002", "UN"], driveSide: "left", callingCodes: ["263"] }, geometry: { type: "MultiPolygon", coordinates: [[[[30.41902, -15.62269], [30.35574, -15.6513], [29.8317, -15.6126], [29.4437, -15.68702], [29.21955, -15.76589], [29.01298, -15.93805], [28.9243, -15.93987], [28.8501, -16.04537], [28.81454, -16.48611], [28.76199, -16.51575], [28.73725, -16.5528], [27.83141, -16.96274], [27.62795, -17.24365], [27.61377, -17.34378], [27.30736, -17.60487], [27.14196, -17.81398], [26.89926, -17.98756], [26.74314, -18.0199], [26.68403, -18.07411], [26.55918, -17.99638], [26.21601, -17.88608], [26.0908, -17.93021], [26.08925, -17.98168], [25.85892, -17.97726], [25.85738, -17.91403], [25.6827, -17.81987], [25.51646, -17.86232], [25.26433, -17.79571], [25.23909, -17.90832], [25.31799, -18.07091], [25.39972, -18.12691], [25.53465, -18.39041], [25.68859, -18.56165], [25.79217, -18.6355], [25.82353, -18.82808], [25.94326, -18.90362], [25.99837, -19.02943], [25.96226, -19.08152], [26.17227, -19.53709], [26.72246, -19.92707], [27.21278, -20.08244], [27.29831, -20.28935], [27.28865, -20.49873], [27.69361, -20.48531], [27.72972, -20.51735], [27.69171, -21.08409], [27.91407, -21.31621], [28.01669, -21.57624], [28.29416, -21.59037], [28.49942, -21.66634], [28.58114, -21.63455], [29.07763, -21.81877], [29.04023, -21.85864], [29.02191, -21.90647], [29.02191, -21.95665], [29.04108, -22.00563], [29.08495, -22.04867], [29.14501, -22.07275], [29.1974, -22.07472], [29.24648, -22.05967], [29.3533, -22.18363], [29.37703, -22.19581], [29.64609, -22.12917], [29.76848, -22.14128], [29.92242, -22.19408], [30.13147, -22.30841], [30.2265, -22.2961], [30.28351, -22.35587], [30.38614, -22.34533], [30.48686, -22.31368], [30.6294, -22.32599], [30.86696, -22.28907], [31.08932, -22.34884], [31.16344, -22.32599], [31.30611, -22.422], [31.38336, -22.36919], [32.41234, -21.31246], [32.48236, -21.32873], [32.37115, -21.133], [32.51644, -20.91929], [32.48122, -20.63319], [32.55167, -20.56312], [32.66174, -20.56106], [32.85987, -20.27841], [32.85987, -20.16686], [32.93032, -20.03868], [33.01178, -20.02007], [33.06461, -19.77787], [32.95013, -19.67219], [32.84666, -19.68462], [32.84446, -19.48343], [32.78282, -19.47513], [32.77966, -19.36098], [32.85107, -19.29238], [32.87088, -19.09279], [32.84006, -19.0262], [32.72118, -19.02204], [32.69917, -18.94293], [32.73439, -18.92628], [32.70137, -18.84712], [32.82465, -18.77419], [32.9017, -18.7992], [32.95013, -18.69079], [32.88629, -18.58023], [32.88629, -18.51344], [33.02278, -18.4696], [33.03159, -18.35054], [32.94133, -17.99705], [33.0492, -17.60298], [32.98536, -17.55891], [32.96554, -17.48964], [33.0426, -17.3468], [33.00517, -17.30477], [32.96554, -17.11971], [32.84113, -16.92259], [32.91051, -16.89446], [32.97655, -16.70689], [32.78943, -16.70267], [32.69917, -16.66893], [32.71017, -16.59932], [32.42838, -16.4727], [32.28529, -16.43892], [32.02772, -16.43892], [31.91324, -16.41569], [31.90223, -16.34388], [31.67988, -16.19595], [31.42451, -16.15154], [31.30563, -16.01193], [31.13171, -15.98019], [30.97761, -16.05848], [30.91597, -15.99924], [30.42568, -15.9962], [30.41902, -15.62269]]]] } }
22924   ] };
22925   var borders = borders_default;
22926   var _whichPolygon = {};
22927   var _featuresByCode = {};
22928   var idFilterRegex = /(?=(?!^(and|the|of|el|la|de)$))(\b(and|the|of|el|la|de)\b)|[-_ .,'()&[\]/]/gi;
22929   function canonicalID(id2) {
22930     const s2 = id2 || "";
22931     if (s2.charAt(0) === ".") {
22932       return s2.toUpperCase();
22933     } else {
22934       return s2.replace(idFilterRegex, "").toUpperCase();
22935     }
22936   }
22937   var levels = [
22938     "subterritory",
22939     "territory",
22940     "subcountryGroup",
22941     "country",
22942     "sharedLandform",
22943     "intermediateRegion",
22944     "subregion",
22945     "region",
22946     "subunion",
22947     "union",
22948     "unitedNations",
22949     "world"
22950   ];
22951   loadDerivedDataAndCaches(borders);
22952   function loadDerivedDataAndCaches(borders2) {
22953     const identifierProps = ["iso1A2", "iso1A3", "m49", "wikidata", "emojiFlag", "ccTLD", "nameEn"];
22954     let geometryFeatures = [];
22955     for (const feature22 of borders2.features) {
22956       const props = feature22.properties;
22957       props.id = props.iso1A2 || props.m49 || props.wikidata;
22958       loadM49(feature22);
22959       loadTLD(feature22);
22960       loadIsoStatus(feature22);
22961       loadLevel(feature22);
22962       loadGroups(feature22);
22963       loadFlag(feature22);
22964       cacheFeatureByIDs(feature22);
22965       if (feature22.geometry) {
22966         geometryFeatures.push(feature22);
22967       }
22968     }
22969     for (const feature22 of borders2.features) {
22970       feature22.properties.groups = feature22.properties.groups.map((groupID) => {
22971         return _featuresByCode[groupID].properties.id;
22972       });
22973       loadMembersForGroupsOf(feature22);
22974     }
22975     for (const feature22 of borders2.features) {
22976       loadRoadSpeedUnit(feature22);
22977       loadRoadHeightUnit(feature22);
22978       loadDriveSide(feature22);
22979       loadCallingCodes(feature22);
22980       loadGroupGroups(feature22);
22981     }
22982     for (const feature22 of borders2.features) {
22983       feature22.properties.groups.sort((groupID1, groupID2) => {
22984         return levels.indexOf(_featuresByCode[groupID1].properties.level) - levels.indexOf(_featuresByCode[groupID2].properties.level);
22985       });
22986       if (feature22.properties.members) {
22987         feature22.properties.members.sort((id1, id2) => {
22988           const diff = levels.indexOf(_featuresByCode[id1].properties.level) - levels.indexOf(_featuresByCode[id2].properties.level);
22989           if (diff === 0) {
22990             return borders2.features.indexOf(_featuresByCode[id1]) - borders2.features.indexOf(_featuresByCode[id2]);
22991           }
22992           return diff;
22993         });
22994       }
22995     }
22996     const geometryOnlyCollection = {
22997       type: "FeatureCollection",
22998       features: geometryFeatures
22999     };
23000     _whichPolygon = (0, import_which_polygon.default)(geometryOnlyCollection);
23001     function loadGroups(feature22) {
23002       const props = feature22.properties;
23003       if (!props.groups) {
23004         props.groups = [];
23005       }
23006       if (feature22.geometry && props.country) {
23007         props.groups.push(props.country);
23008       }
23009       if (props.m49 !== "001") {
23010         props.groups.push("001");
23011       }
23012     }
23013     function loadM49(feature22) {
23014       const props = feature22.properties;
23015       if (!props.m49 && props.iso1N3) {
23016         props.m49 = props.iso1N3;
23017       }
23018     }
23019     function loadTLD(feature22) {
23020       const props = feature22.properties;
23021       if (props.level === "unitedNations")
23022         return;
23023       if (!props.ccTLD && props.iso1A2) {
23024         props.ccTLD = "." + props.iso1A2.toLowerCase();
23025       }
23026     }
23027     function loadIsoStatus(feature22) {
23028       const props = feature22.properties;
23029       if (!props.isoStatus && props.iso1A2) {
23030         props.isoStatus = "official";
23031       }
23032     }
23033     function loadLevel(feature22) {
23034       const props = feature22.properties;
23035       if (props.level)
23036         return;
23037       if (!props.country) {
23038         props.level = "country";
23039       } else if (!props.iso1A2 || props.isoStatus === "official") {
23040         props.level = "territory";
23041       } else {
23042         props.level = "subterritory";
23043       }
23044     }
23045     function loadGroupGroups(feature22) {
23046       const props = feature22.properties;
23047       if (feature22.geometry || !props.members)
23048         return;
23049       const featureLevelIndex = levels.indexOf(props.level);
23050       let sharedGroups = [];
23051       props.members.forEach((memberID, index) => {
23052         const member = _featuresByCode[memberID];
23053         const memberGroups = member.properties.groups.filter((groupID) => {
23054           return groupID !== feature22.properties.id && featureLevelIndex < levels.indexOf(_featuresByCode[groupID].properties.level);
23055         });
23056         if (index === 0) {
23057           sharedGroups = memberGroups;
23058         } else {
23059           sharedGroups = sharedGroups.filter((groupID) => memberGroups.indexOf(groupID) !== -1);
23060         }
23061       });
23062       props.groups = props.groups.concat(
23063         sharedGroups.filter((groupID) => props.groups.indexOf(groupID) === -1)
23064       );
23065       for (const groupID of sharedGroups) {
23066         const groupFeature = _featuresByCode[groupID];
23067         if (groupFeature.properties.members.indexOf(props.id) === -1) {
23068           groupFeature.properties.members.push(props.id);
23069         }
23070       }
23071     }
23072     function loadRoadSpeedUnit(feature22) {
23073       const props = feature22.properties;
23074       if (feature22.geometry) {
23075         if (!props.roadSpeedUnit)
23076           props.roadSpeedUnit = "km/h";
23077       } else if (props.members) {
23078         const vals = Array.from(
23079           new Set(
23080             props.members.map((id2) => {
23081               const member = _featuresByCode[id2];
23082               if (member.geometry)
23083                 return member.properties.roadSpeedUnit || "km/h";
23084             }).filter(Boolean)
23085           )
23086         );
23087         if (vals.length === 1)
23088           props.roadSpeedUnit = vals[0];
23089       }
23090     }
23091     function loadRoadHeightUnit(feature22) {
23092       const props = feature22.properties;
23093       if (feature22.geometry) {
23094         if (!props.roadHeightUnit)
23095           props.roadHeightUnit = "m";
23096       } else if (props.members) {
23097         const vals = Array.from(
23098           new Set(
23099             props.members.map((id2) => {
23100               const member = _featuresByCode[id2];
23101               if (member.geometry)
23102                 return member.properties.roadHeightUnit || "m";
23103             }).filter(Boolean)
23104           )
23105         );
23106         if (vals.length === 1)
23107           props.roadHeightUnit = vals[0];
23108       }
23109     }
23110     function loadDriveSide(feature22) {
23111       const props = feature22.properties;
23112       if (feature22.geometry) {
23113         if (!props.driveSide)
23114           props.driveSide = "right";
23115       } else if (props.members) {
23116         const vals = Array.from(
23117           new Set(
23118             props.members.map((id2) => {
23119               const member = _featuresByCode[id2];
23120               if (member.geometry)
23121                 return member.properties.driveSide || "right";
23122             }).filter(Boolean)
23123           )
23124         );
23125         if (vals.length === 1)
23126           props.driveSide = vals[0];
23127       }
23128     }
23129     function loadCallingCodes(feature22) {
23130       const props = feature22.properties;
23131       if (!feature22.geometry && props.members) {
23132         props.callingCodes = Array.from(
23133           new Set(
23134             props.members.reduce((array2, id2) => {
23135               const member = _featuresByCode[id2];
23136               if (member.geometry && member.properties.callingCodes) {
23137                 return array2.concat(member.properties.callingCodes);
23138               }
23139               return array2;
23140             }, [])
23141           )
23142         );
23143       }
23144     }
23145     function loadFlag(feature22) {
23146       if (!feature22.properties.iso1A2)
23147         return;
23148       const flag = feature22.properties.iso1A2.replace(/./g, function(char) {
23149         return String.fromCodePoint(char.charCodeAt(0) + 127397);
23150       });
23151       feature22.properties.emojiFlag = flag;
23152     }
23153     function loadMembersForGroupsOf(feature22) {
23154       for (const groupID of feature22.properties.groups) {
23155         const groupFeature = _featuresByCode[groupID];
23156         if (!groupFeature.properties.members) {
23157           groupFeature.properties.members = [];
23158         }
23159         groupFeature.properties.members.push(feature22.properties.id);
23160       }
23161     }
23162     function cacheFeatureByIDs(feature22) {
23163       let ids = [];
23164       for (const prop of identifierProps) {
23165         const id2 = feature22.properties[prop];
23166         if (id2) {
23167           ids.push(id2);
23168         }
23169       }
23170       for (const alias of feature22.properties.aliases || []) {
23171         ids.push(alias);
23172       }
23173       for (const id2 of ids) {
23174         const cid = canonicalID(id2);
23175         _featuresByCode[cid] = feature22;
23176       }
23177     }
23178   }
23179   function locArray(loc) {
23180     if (Array.isArray(loc)) {
23181       return loc;
23182     } else if (loc.coordinates) {
23183       return loc.coordinates;
23184     }
23185     return loc.geometry.coordinates;
23186   }
23187   function smallestFeature(loc) {
23188     const query = locArray(loc);
23189     const featureProperties = _whichPolygon(query);
23190     if (!featureProperties)
23191       return null;
23192     return _featuresByCode[featureProperties.id];
23193   }
23194   function countryFeature(loc) {
23195     const feature22 = smallestFeature(loc);
23196     if (!feature22)
23197       return null;
23198     const countryCode = feature22.properties.country || feature22.properties.iso1A2;
23199     return _featuresByCode[countryCode] || null;
23200   }
23201   var defaultOpts = {
23202     level: void 0,
23203     maxLevel: void 0,
23204     withProp: void 0
23205   };
23206   function featureForLoc(loc, opts) {
23207     const targetLevel = opts.level || "country";
23208     const maxLevel = opts.maxLevel || "world";
23209     const withProp = opts.withProp;
23210     const targetLevelIndex = levels.indexOf(targetLevel);
23211     if (targetLevelIndex === -1)
23212       return null;
23213     const maxLevelIndex = levels.indexOf(maxLevel);
23214     if (maxLevelIndex === -1)
23215       return null;
23216     if (maxLevelIndex < targetLevelIndex)
23217       return null;
23218     if (targetLevel === "country") {
23219       const fastFeature = countryFeature(loc);
23220       if (fastFeature) {
23221         if (!withProp || fastFeature.properties[withProp]) {
23222           return fastFeature;
23223         }
23224       }
23225     }
23226     const features = featuresContaining(loc);
23227     const match = features.find((feature22) => {
23228       let levelIndex = levels.indexOf(feature22.properties.level);
23229       if (feature22.properties.level === targetLevel || // if no feature exists at the target level, return the first feature at the next level up
23230       levelIndex > targetLevelIndex && levelIndex <= maxLevelIndex) {
23231         if (!withProp || feature22.properties[withProp]) {
23232           return feature22;
23233         }
23234       }
23235       return false;
23236     });
23237     return match || null;
23238   }
23239   function featureForID(id2) {
23240     let stringID;
23241     if (typeof id2 === "number") {
23242       stringID = id2.toString();
23243       if (stringID.length === 1) {
23244         stringID = "00" + stringID;
23245       } else if (stringID.length === 2) {
23246         stringID = "0" + stringID;
23247       }
23248     } else {
23249       stringID = canonicalID(id2);
23250     }
23251     return _featuresByCode[stringID] || null;
23252   }
23253   function smallestFeaturesForBbox(bbox2) {
23254     return _whichPolygon.bbox(bbox2).map((props) => _featuresByCode[props.id]);
23255   }
23256   function smallestOrMatchingFeature(query) {
23257     if (typeof query === "object") {
23258       return smallestFeature(query);
23259     }
23260     return featureForID(query);
23261   }
23262   function feature(query, opts = defaultOpts) {
23263     if (typeof query === "object") {
23264       return featureForLoc(query, opts);
23265     }
23266     return featureForID(query);
23267   }
23268   function iso1A2Code(query, opts = defaultOpts) {
23269     opts.withProp = "iso1A2";
23270     const match = feature(query, opts);
23271     if (!match)
23272       return null;
23273     return match.properties.iso1A2 || null;
23274   }
23275   function propertiesForQuery(query, property) {
23276     const features = featuresContaining(query, false);
23277     return features.map((feature22) => feature22.properties[property]).filter(Boolean);
23278   }
23279   function iso1A2Codes(query) {
23280     return propertiesForQuery(query, "iso1A2");
23281   }
23282   function featuresContaining(query, strict) {
23283     let matchingFeatures;
23284     if (Array.isArray(query) && query.length === 4) {
23285       matchingFeatures = smallestFeaturesForBbox(query);
23286     } else {
23287       const smallestOrMatching = smallestOrMatchingFeature(query);
23288       matchingFeatures = smallestOrMatching ? [smallestOrMatching] : [];
23289     }
23290     if (!matchingFeatures.length)
23291       return [];
23292     let returnFeatures;
23293     if (!strict || typeof query === "object") {
23294       returnFeatures = matchingFeatures.slice();
23295     } else {
23296       returnFeatures = [];
23297     }
23298     for (const feature22 of matchingFeatures) {
23299       const properties = feature22.properties;
23300       for (const groupID of properties.groups) {
23301         const groupFeature = _featuresByCode[groupID];
23302         if (returnFeatures.indexOf(groupFeature) === -1) {
23303           returnFeatures.push(groupFeature);
23304         }
23305       }
23306     }
23307     return returnFeatures;
23308   }
23309   function featuresIn(id2, strict) {
23310     const feature22 = featureForID(id2);
23311     if (!feature22)
23312       return [];
23313     let features = [];
23314     if (!strict) {
23315       features.push(feature22);
23316     }
23317     const properties = feature22.properties;
23318     for (const memberID of properties.members || []) {
23319       features.push(_featuresByCode[memberID]);
23320     }
23321     return features;
23322   }
23323   function aggregateFeature(id2) {
23324     var _a2;
23325     const features = featuresIn(id2, false);
23326     if (features.length === 0)
23327       return null;
23328     let aggregateCoordinates = [];
23329     for (const feature22 of features) {
23330       if (((_a2 = feature22.geometry) == null ? void 0 : _a2.type) === "MultiPolygon" && feature22.geometry.coordinates) {
23331         aggregateCoordinates = aggregateCoordinates.concat(feature22.geometry.coordinates);
23332       }
23333     }
23334     return {
23335       type: "Feature",
23336       properties: features[0].properties,
23337       geometry: {
23338         type: "MultiPolygon",
23339         coordinates: aggregateCoordinates
23340       }
23341     };
23342   }
23343   function roadSpeedUnit(query) {
23344     const feature22 = smallestOrMatchingFeature(query);
23345     return feature22 && feature22.properties.roadSpeedUnit || null;
23346   }
23347   function roadHeightUnit(query) {
23348     const feature22 = smallestOrMatchingFeature(query);
23349     return feature22 && feature22.properties.roadHeightUnit || null;
23350   }
23351
23352   // node_modules/polyclip-ts/dist/constant.js
23353   var constant_default5 = (x2) => {
23354     return () => {
23355       return x2;
23356     };
23357   };
23358
23359   // node_modules/polyclip-ts/dist/compare.js
23360   var compare_default = (eps) => {
23361     const almostEqual = eps ? (a2, b2) => b2.minus(a2).abs().isLessThanOrEqualTo(eps) : constant_default5(false);
23362     return (a2, b2) => {
23363       if (almostEqual(a2, b2))
23364         return 0;
23365       return a2.comparedTo(b2);
23366     };
23367   };
23368
23369   // node_modules/polyclip-ts/dist/orient.js
23370   function orient_default(eps) {
23371     const almostCollinear = eps ? (area2, ax, ay, cx, cy) => area2.exponentiatedBy(2).isLessThanOrEqualTo(cx.minus(ax).exponentiatedBy(2).plus(cy.minus(ay).exponentiatedBy(2)).times(eps)) : constant_default5(false);
23372     return (a2, b2, c2) => {
23373       const ax = a2.x, ay = a2.y, cx = c2.x, cy = c2.y;
23374       const area2 = ay.minus(cy).times(b2.x.minus(cx)).minus(ax.minus(cx).times(b2.y.minus(cy)));
23375       if (almostCollinear(area2, ax, ay, cx, cy))
23376         return 0;
23377       return area2.comparedTo(0);
23378     };
23379   }
23380
23381   // node_modules/bignumber.js/bignumber.mjs
23382   var isNumeric = /^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i;
23383   var mathceil = Math.ceil;
23384   var mathfloor = Math.floor;
23385   var bignumberError = "[BigNumber Error] ";
23386   var tooManyDigits = bignumberError + "Number primitive has more than 15 significant digits: ";
23387   var BASE = 1e14;
23388   var LOG_BASE = 14;
23389   var MAX_SAFE_INTEGER = 9007199254740991;
23390   var POWS_TEN = [1, 10, 100, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, 1e10, 1e11, 1e12, 1e13];
23391   var SQRT_BASE = 1e7;
23392   var MAX = 1e9;
23393   function clone(configObject) {
23394     var div, convertBase, parseNumeric2, P2 = BigNumber2.prototype = { constructor: BigNumber2, toString: null, valueOf: null }, ONE = new BigNumber2(1), DECIMAL_PLACES = 20, ROUNDING_MODE = 4, TO_EXP_NEG = -7, TO_EXP_POS = 21, MIN_EXP = -1e7, MAX_EXP = 1e7, CRYPTO = false, MODULO_MODE = 1, POW_PRECISION = 0, FORMAT = {
23395       prefix: "",
23396       groupSize: 3,
23397       secondaryGroupSize: 0,
23398       groupSeparator: ",",
23399       decimalSeparator: ".",
23400       fractionGroupSize: 0,
23401       fractionGroupSeparator: "\xA0",
23402       // non-breaking space
23403       suffix: ""
23404     }, ALPHABET = "0123456789abcdefghijklmnopqrstuvwxyz", alphabetHasNormalDecimalDigits = true;
23405     function BigNumber2(v2, b2) {
23406       var alphabet, c2, caseChanged, e3, i3, isNum, len, str, x2 = this;
23407       if (!(x2 instanceof BigNumber2))
23408         return new BigNumber2(v2, b2);
23409       if (b2 == null) {
23410         if (v2 && v2._isBigNumber === true) {
23411           x2.s = v2.s;
23412           if (!v2.c || v2.e > MAX_EXP) {
23413             x2.c = x2.e = null;
23414           } else if (v2.e < MIN_EXP) {
23415             x2.c = [x2.e = 0];
23416           } else {
23417             x2.e = v2.e;
23418             x2.c = v2.c.slice();
23419           }
23420           return;
23421         }
23422         if ((isNum = typeof v2 == "number") && v2 * 0 == 0) {
23423           x2.s = 1 / v2 < 0 ? (v2 = -v2, -1) : 1;
23424           if (v2 === ~~v2) {
23425             for (e3 = 0, i3 = v2; i3 >= 10; i3 /= 10, e3++)
23426               ;
23427             if (e3 > MAX_EXP) {
23428               x2.c = x2.e = null;
23429             } else {
23430               x2.e = e3;
23431               x2.c = [v2];
23432             }
23433             return;
23434           }
23435           str = String(v2);
23436         } else {
23437           if (!isNumeric.test(str = String(v2)))
23438             return parseNumeric2(x2, str, isNum);
23439           x2.s = str.charCodeAt(0) == 45 ? (str = str.slice(1), -1) : 1;
23440         }
23441         if ((e3 = str.indexOf(".")) > -1)
23442           str = str.replace(".", "");
23443         if ((i3 = str.search(/e/i)) > 0) {
23444           if (e3 < 0)
23445             e3 = i3;
23446           e3 += +str.slice(i3 + 1);
23447           str = str.substring(0, i3);
23448         } else if (e3 < 0) {
23449           e3 = str.length;
23450         }
23451       } else {
23452         intCheck(b2, 2, ALPHABET.length, "Base");
23453         if (b2 == 10 && alphabetHasNormalDecimalDigits) {
23454           x2 = new BigNumber2(v2);
23455           return round(x2, DECIMAL_PLACES + x2.e + 1, ROUNDING_MODE);
23456         }
23457         str = String(v2);
23458         if (isNum = typeof v2 == "number") {
23459           if (v2 * 0 != 0)
23460             return parseNumeric2(x2, str, isNum, b2);
23461           x2.s = 1 / v2 < 0 ? (str = str.slice(1), -1) : 1;
23462           if (BigNumber2.DEBUG && str.replace(/^0\.0*|\./, "").length > 15) {
23463             throw Error(tooManyDigits + v2);
23464           }
23465         } else {
23466           x2.s = str.charCodeAt(0) === 45 ? (str = str.slice(1), -1) : 1;
23467         }
23468         alphabet = ALPHABET.slice(0, b2);
23469         e3 = i3 = 0;
23470         for (len = str.length; i3 < len; i3++) {
23471           if (alphabet.indexOf(c2 = str.charAt(i3)) < 0) {
23472             if (c2 == ".") {
23473               if (i3 > e3) {
23474                 e3 = len;
23475                 continue;
23476               }
23477             } else if (!caseChanged) {
23478               if (str == str.toUpperCase() && (str = str.toLowerCase()) || str == str.toLowerCase() && (str = str.toUpperCase())) {
23479                 caseChanged = true;
23480                 i3 = -1;
23481                 e3 = 0;
23482                 continue;
23483               }
23484             }
23485             return parseNumeric2(x2, String(v2), isNum, b2);
23486           }
23487         }
23488         isNum = false;
23489         str = convertBase(str, b2, 10, x2.s);
23490         if ((e3 = str.indexOf(".")) > -1)
23491           str = str.replace(".", "");
23492         else
23493           e3 = str.length;
23494       }
23495       for (i3 = 0; str.charCodeAt(i3) === 48; i3++)
23496         ;
23497       for (len = str.length; str.charCodeAt(--len) === 48; )
23498         ;
23499       if (str = str.slice(i3, ++len)) {
23500         len -= i3;
23501         if (isNum && BigNumber2.DEBUG && len > 15 && (v2 > MAX_SAFE_INTEGER || v2 !== mathfloor(v2))) {
23502           throw Error(tooManyDigits + x2.s * v2);
23503         }
23504         if ((e3 = e3 - i3 - 1) > MAX_EXP) {
23505           x2.c = x2.e = null;
23506         } else if (e3 < MIN_EXP) {
23507           x2.c = [x2.e = 0];
23508         } else {
23509           x2.e = e3;
23510           x2.c = [];
23511           i3 = (e3 + 1) % LOG_BASE;
23512           if (e3 < 0)
23513             i3 += LOG_BASE;
23514           if (i3 < len) {
23515             if (i3)
23516               x2.c.push(+str.slice(0, i3));
23517             for (len -= LOG_BASE; i3 < len; ) {
23518               x2.c.push(+str.slice(i3, i3 += LOG_BASE));
23519             }
23520             i3 = LOG_BASE - (str = str.slice(i3)).length;
23521           } else {
23522             i3 -= len;
23523           }
23524           for (; i3--; str += "0")
23525             ;
23526           x2.c.push(+str);
23527         }
23528       } else {
23529         x2.c = [x2.e = 0];
23530       }
23531     }
23532     BigNumber2.clone = clone;
23533     BigNumber2.ROUND_UP = 0;
23534     BigNumber2.ROUND_DOWN = 1;
23535     BigNumber2.ROUND_CEIL = 2;
23536     BigNumber2.ROUND_FLOOR = 3;
23537     BigNumber2.ROUND_HALF_UP = 4;
23538     BigNumber2.ROUND_HALF_DOWN = 5;
23539     BigNumber2.ROUND_HALF_EVEN = 6;
23540     BigNumber2.ROUND_HALF_CEIL = 7;
23541     BigNumber2.ROUND_HALF_FLOOR = 8;
23542     BigNumber2.EUCLID = 9;
23543     BigNumber2.config = BigNumber2.set = function(obj) {
23544       var p2, v2;
23545       if (obj != null) {
23546         if (typeof obj == "object") {
23547           if (obj.hasOwnProperty(p2 = "DECIMAL_PLACES")) {
23548             v2 = obj[p2];
23549             intCheck(v2, 0, MAX, p2);
23550             DECIMAL_PLACES = v2;
23551           }
23552           if (obj.hasOwnProperty(p2 = "ROUNDING_MODE")) {
23553             v2 = obj[p2];
23554             intCheck(v2, 0, 8, p2);
23555             ROUNDING_MODE = v2;
23556           }
23557           if (obj.hasOwnProperty(p2 = "EXPONENTIAL_AT")) {
23558             v2 = obj[p2];
23559             if (v2 && v2.pop) {
23560               intCheck(v2[0], -MAX, 0, p2);
23561               intCheck(v2[1], 0, MAX, p2);
23562               TO_EXP_NEG = v2[0];
23563               TO_EXP_POS = v2[1];
23564             } else {
23565               intCheck(v2, -MAX, MAX, p2);
23566               TO_EXP_NEG = -(TO_EXP_POS = v2 < 0 ? -v2 : v2);
23567             }
23568           }
23569           if (obj.hasOwnProperty(p2 = "RANGE")) {
23570             v2 = obj[p2];
23571             if (v2 && v2.pop) {
23572               intCheck(v2[0], -MAX, -1, p2);
23573               intCheck(v2[1], 1, MAX, p2);
23574               MIN_EXP = v2[0];
23575               MAX_EXP = v2[1];
23576             } else {
23577               intCheck(v2, -MAX, MAX, p2);
23578               if (v2) {
23579                 MIN_EXP = -(MAX_EXP = v2 < 0 ? -v2 : v2);
23580               } else {
23581                 throw Error(bignumberError + p2 + " cannot be zero: " + v2);
23582               }
23583             }
23584           }
23585           if (obj.hasOwnProperty(p2 = "CRYPTO")) {
23586             v2 = obj[p2];
23587             if (v2 === !!v2) {
23588               if (v2) {
23589                 if (typeof crypto != "undefined" && crypto && (crypto.getRandomValues || crypto.randomBytes)) {
23590                   CRYPTO = v2;
23591                 } else {
23592                   CRYPTO = !v2;
23593                   throw Error(bignumberError + "crypto unavailable");
23594                 }
23595               } else {
23596                 CRYPTO = v2;
23597               }
23598             } else {
23599               throw Error(bignumberError + p2 + " not true or false: " + v2);
23600             }
23601           }
23602           if (obj.hasOwnProperty(p2 = "MODULO_MODE")) {
23603             v2 = obj[p2];
23604             intCheck(v2, 0, 9, p2);
23605             MODULO_MODE = v2;
23606           }
23607           if (obj.hasOwnProperty(p2 = "POW_PRECISION")) {
23608             v2 = obj[p2];
23609             intCheck(v2, 0, MAX, p2);
23610             POW_PRECISION = v2;
23611           }
23612           if (obj.hasOwnProperty(p2 = "FORMAT")) {
23613             v2 = obj[p2];
23614             if (typeof v2 == "object")
23615               FORMAT = v2;
23616             else
23617               throw Error(bignumberError + p2 + " not an object: " + v2);
23618           }
23619           if (obj.hasOwnProperty(p2 = "ALPHABET")) {
23620             v2 = obj[p2];
23621             if (typeof v2 == "string" && !/^.?$|[+\-.\s]|(.).*\1/.test(v2)) {
23622               alphabetHasNormalDecimalDigits = v2.slice(0, 10) == "0123456789";
23623               ALPHABET = v2;
23624             } else {
23625               throw Error(bignumberError + p2 + " invalid: " + v2);
23626             }
23627           }
23628         } else {
23629           throw Error(bignumberError + "Object expected: " + obj);
23630         }
23631       }
23632       return {
23633         DECIMAL_PLACES,
23634         ROUNDING_MODE,
23635         EXPONENTIAL_AT: [TO_EXP_NEG, TO_EXP_POS],
23636         RANGE: [MIN_EXP, MAX_EXP],
23637         CRYPTO,
23638         MODULO_MODE,
23639         POW_PRECISION,
23640         FORMAT,
23641         ALPHABET
23642       };
23643     };
23644     BigNumber2.isBigNumber = function(v2) {
23645       if (!v2 || v2._isBigNumber !== true)
23646         return false;
23647       if (!BigNumber2.DEBUG)
23648         return true;
23649       var i3, n3, c2 = v2.c, e3 = v2.e, s2 = v2.s;
23650       out:
23651         if ({}.toString.call(c2) == "[object Array]") {
23652           if ((s2 === 1 || s2 === -1) && e3 >= -MAX && e3 <= MAX && e3 === mathfloor(e3)) {
23653             if (c2[0] === 0) {
23654               if (e3 === 0 && c2.length === 1)
23655                 return true;
23656               break out;
23657             }
23658             i3 = (e3 + 1) % LOG_BASE;
23659             if (i3 < 1)
23660               i3 += LOG_BASE;
23661             if (String(c2[0]).length == i3) {
23662               for (i3 = 0; i3 < c2.length; i3++) {
23663                 n3 = c2[i3];
23664                 if (n3 < 0 || n3 >= BASE || n3 !== mathfloor(n3))
23665                   break out;
23666               }
23667               if (n3 !== 0)
23668                 return true;
23669             }
23670           }
23671         } else if (c2 === null && e3 === null && (s2 === null || s2 === 1 || s2 === -1)) {
23672           return true;
23673         }
23674       throw Error(bignumberError + "Invalid BigNumber: " + v2);
23675     };
23676     BigNumber2.maximum = BigNumber2.max = function() {
23677       return maxOrMin(arguments, -1);
23678     };
23679     BigNumber2.minimum = BigNumber2.min = function() {
23680       return maxOrMin(arguments, 1);
23681     };
23682     BigNumber2.random = function() {
23683       var pow2_53 = 9007199254740992;
23684       var random53bitInt = Math.random() * pow2_53 & 2097151 ? function() {
23685         return mathfloor(Math.random() * pow2_53);
23686       } : function() {
23687         return (Math.random() * 1073741824 | 0) * 8388608 + (Math.random() * 8388608 | 0);
23688       };
23689       return function(dp) {
23690         var a2, b2, e3, k2, v2, i3 = 0, c2 = [], rand = new BigNumber2(ONE);
23691         if (dp == null)
23692           dp = DECIMAL_PLACES;
23693         else
23694           intCheck(dp, 0, MAX);
23695         k2 = mathceil(dp / LOG_BASE);
23696         if (CRYPTO) {
23697           if (crypto.getRandomValues) {
23698             a2 = crypto.getRandomValues(new Uint32Array(k2 *= 2));
23699             for (; i3 < k2; ) {
23700               v2 = a2[i3] * 131072 + (a2[i3 + 1] >>> 11);
23701               if (v2 >= 9e15) {
23702                 b2 = crypto.getRandomValues(new Uint32Array(2));
23703                 a2[i3] = b2[0];
23704                 a2[i3 + 1] = b2[1];
23705               } else {
23706                 c2.push(v2 % 1e14);
23707                 i3 += 2;
23708               }
23709             }
23710             i3 = k2 / 2;
23711           } else if (crypto.randomBytes) {
23712             a2 = crypto.randomBytes(k2 *= 7);
23713             for (; i3 < k2; ) {
23714               v2 = (a2[i3] & 31) * 281474976710656 + a2[i3 + 1] * 1099511627776 + a2[i3 + 2] * 4294967296 + a2[i3 + 3] * 16777216 + (a2[i3 + 4] << 16) + (a2[i3 + 5] << 8) + a2[i3 + 6];
23715               if (v2 >= 9e15) {
23716                 crypto.randomBytes(7).copy(a2, i3);
23717               } else {
23718                 c2.push(v2 % 1e14);
23719                 i3 += 7;
23720               }
23721             }
23722             i3 = k2 / 7;
23723           } else {
23724             CRYPTO = false;
23725             throw Error(bignumberError + "crypto unavailable");
23726           }
23727         }
23728         if (!CRYPTO) {
23729           for (; i3 < k2; ) {
23730             v2 = random53bitInt();
23731             if (v2 < 9e15)
23732               c2[i3++] = v2 % 1e14;
23733           }
23734         }
23735         k2 = c2[--i3];
23736         dp %= LOG_BASE;
23737         if (k2 && dp) {
23738           v2 = POWS_TEN[LOG_BASE - dp];
23739           c2[i3] = mathfloor(k2 / v2) * v2;
23740         }
23741         for (; c2[i3] === 0; c2.pop(), i3--)
23742           ;
23743         if (i3 < 0) {
23744           c2 = [e3 = 0];
23745         } else {
23746           for (e3 = -1; c2[0] === 0; c2.splice(0, 1), e3 -= LOG_BASE)
23747             ;
23748           for (i3 = 1, v2 = c2[0]; v2 >= 10; v2 /= 10, i3++)
23749             ;
23750           if (i3 < LOG_BASE)
23751             e3 -= LOG_BASE - i3;
23752         }
23753         rand.e = e3;
23754         rand.c = c2;
23755         return rand;
23756       };
23757     }();
23758     BigNumber2.sum = function() {
23759       var i3 = 1, args = arguments, sum = new BigNumber2(args[0]);
23760       for (; i3 < args.length; )
23761         sum = sum.plus(args[i3++]);
23762       return sum;
23763     };
23764     convertBase = /* @__PURE__ */ function() {
23765       var decimal = "0123456789";
23766       function toBaseOut(str, baseIn, baseOut, alphabet) {
23767         var j2, arr = [0], arrL, i3 = 0, len = str.length;
23768         for (; i3 < len; ) {
23769           for (arrL = arr.length; arrL--; arr[arrL] *= baseIn)
23770             ;
23771           arr[0] += alphabet.indexOf(str.charAt(i3++));
23772           for (j2 = 0; j2 < arr.length; j2++) {
23773             if (arr[j2] > baseOut - 1) {
23774               if (arr[j2 + 1] == null)
23775                 arr[j2 + 1] = 0;
23776               arr[j2 + 1] += arr[j2] / baseOut | 0;
23777               arr[j2] %= baseOut;
23778             }
23779           }
23780         }
23781         return arr.reverse();
23782       }
23783       return function(str, baseIn, baseOut, sign2, callerIsToString) {
23784         var alphabet, d2, e3, k2, r2, x2, xc, y2, i3 = str.indexOf("."), dp = DECIMAL_PLACES, rm = ROUNDING_MODE;
23785         if (i3 >= 0) {
23786           k2 = POW_PRECISION;
23787           POW_PRECISION = 0;
23788           str = str.replace(".", "");
23789           y2 = new BigNumber2(baseIn);
23790           x2 = y2.pow(str.length - i3);
23791           POW_PRECISION = k2;
23792           y2.c = toBaseOut(
23793             toFixedPoint(coeffToString(x2.c), x2.e, "0"),
23794             10,
23795             baseOut,
23796             decimal
23797           );
23798           y2.e = y2.c.length;
23799         }
23800         xc = toBaseOut(str, baseIn, baseOut, callerIsToString ? (alphabet = ALPHABET, decimal) : (alphabet = decimal, ALPHABET));
23801         e3 = k2 = xc.length;
23802         for (; xc[--k2] == 0; xc.pop())
23803           ;
23804         if (!xc[0])
23805           return alphabet.charAt(0);
23806         if (i3 < 0) {
23807           --e3;
23808         } else {
23809           x2.c = xc;
23810           x2.e = e3;
23811           x2.s = sign2;
23812           x2 = div(x2, y2, dp, rm, baseOut);
23813           xc = x2.c;
23814           r2 = x2.r;
23815           e3 = x2.e;
23816         }
23817         d2 = e3 + dp + 1;
23818         i3 = xc[d2];
23819         k2 = baseOut / 2;
23820         r2 = r2 || d2 < 0 || xc[d2 + 1] != null;
23821         r2 = rm < 4 ? (i3 != null || r2) && (rm == 0 || rm == (x2.s < 0 ? 3 : 2)) : i3 > k2 || i3 == k2 && (rm == 4 || r2 || rm == 6 && xc[d2 - 1] & 1 || rm == (x2.s < 0 ? 8 : 7));
23822         if (d2 < 1 || !xc[0]) {
23823           str = r2 ? toFixedPoint(alphabet.charAt(1), -dp, alphabet.charAt(0)) : alphabet.charAt(0);
23824         } else {
23825           xc.length = d2;
23826           if (r2) {
23827             for (--baseOut; ++xc[--d2] > baseOut; ) {
23828               xc[d2] = 0;
23829               if (!d2) {
23830                 ++e3;
23831                 xc = [1].concat(xc);
23832               }
23833             }
23834           }
23835           for (k2 = xc.length; !xc[--k2]; )
23836             ;
23837           for (i3 = 0, str = ""; i3 <= k2; str += alphabet.charAt(xc[i3++]))
23838             ;
23839           str = toFixedPoint(str, e3, alphabet.charAt(0));
23840         }
23841         return str;
23842       };
23843     }();
23844     div = /* @__PURE__ */ function() {
23845       function multiply(x2, k2, base) {
23846         var m2, temp, xlo, xhi, carry = 0, i3 = x2.length, klo = k2 % SQRT_BASE, khi = k2 / SQRT_BASE | 0;
23847         for (x2 = x2.slice(); i3--; ) {
23848           xlo = x2[i3] % SQRT_BASE;
23849           xhi = x2[i3] / SQRT_BASE | 0;
23850           m2 = khi * xlo + xhi * klo;
23851           temp = klo * xlo + m2 % SQRT_BASE * SQRT_BASE + carry;
23852           carry = (temp / base | 0) + (m2 / SQRT_BASE | 0) + khi * xhi;
23853           x2[i3] = temp % base;
23854         }
23855         if (carry)
23856           x2 = [carry].concat(x2);
23857         return x2;
23858       }
23859       function compare2(a2, b2, aL, bL) {
23860         var i3, cmp;
23861         if (aL != bL) {
23862           cmp = aL > bL ? 1 : -1;
23863         } else {
23864           for (i3 = cmp = 0; i3 < aL; i3++) {
23865             if (a2[i3] != b2[i3]) {
23866               cmp = a2[i3] > b2[i3] ? 1 : -1;
23867               break;
23868             }
23869           }
23870         }
23871         return cmp;
23872       }
23873       function subtract(a2, b2, aL, base) {
23874         var i3 = 0;
23875         for (; aL--; ) {
23876           a2[aL] -= i3;
23877           i3 = a2[aL] < b2[aL] ? 1 : 0;
23878           a2[aL] = i3 * base + a2[aL] - b2[aL];
23879         }
23880         for (; !a2[0] && a2.length > 1; a2.splice(0, 1))
23881           ;
23882       }
23883       return function(x2, y2, dp, rm, base) {
23884         var cmp, e3, i3, more, n3, prod, prodL, q2, qc, rem, remL, rem0, xi, xL, yc0, yL, yz, s2 = x2.s == y2.s ? 1 : -1, xc = x2.c, yc = y2.c;
23885         if (!xc || !xc[0] || !yc || !yc[0]) {
23886           return new BigNumber2(
23887             // Return NaN if either NaN, or both Infinity or 0.
23888             !x2.s || !y2.s || (xc ? yc && xc[0] == yc[0] : !yc) ? NaN : (
23889               // Return ±0 if x is ±0 or y is ±Infinity, or return ±Infinity as y is ±0.
23890               xc && xc[0] == 0 || !yc ? s2 * 0 : s2 / 0
23891             )
23892           );
23893         }
23894         q2 = new BigNumber2(s2);
23895         qc = q2.c = [];
23896         e3 = x2.e - y2.e;
23897         s2 = dp + e3 + 1;
23898         if (!base) {
23899           base = BASE;
23900           e3 = bitFloor(x2.e / LOG_BASE) - bitFloor(y2.e / LOG_BASE);
23901           s2 = s2 / LOG_BASE | 0;
23902         }
23903         for (i3 = 0; yc[i3] == (xc[i3] || 0); i3++)
23904           ;
23905         if (yc[i3] > (xc[i3] || 0))
23906           e3--;
23907         if (s2 < 0) {
23908           qc.push(1);
23909           more = true;
23910         } else {
23911           xL = xc.length;
23912           yL = yc.length;
23913           i3 = 0;
23914           s2 += 2;
23915           n3 = mathfloor(base / (yc[0] + 1));
23916           if (n3 > 1) {
23917             yc = multiply(yc, n3, base);
23918             xc = multiply(xc, n3, base);
23919             yL = yc.length;
23920             xL = xc.length;
23921           }
23922           xi = yL;
23923           rem = xc.slice(0, yL);
23924           remL = rem.length;
23925           for (; remL < yL; rem[remL++] = 0)
23926             ;
23927           yz = yc.slice();
23928           yz = [0].concat(yz);
23929           yc0 = yc[0];
23930           if (yc[1] >= base / 2)
23931             yc0++;
23932           do {
23933             n3 = 0;
23934             cmp = compare2(yc, rem, yL, remL);
23935             if (cmp < 0) {
23936               rem0 = rem[0];
23937               if (yL != remL)
23938                 rem0 = rem0 * base + (rem[1] || 0);
23939               n3 = mathfloor(rem0 / yc0);
23940               if (n3 > 1) {
23941                 if (n3 >= base)
23942                   n3 = base - 1;
23943                 prod = multiply(yc, n3, base);
23944                 prodL = prod.length;
23945                 remL = rem.length;
23946                 while (compare2(prod, rem, prodL, remL) == 1) {
23947                   n3--;
23948                   subtract(prod, yL < prodL ? yz : yc, prodL, base);
23949                   prodL = prod.length;
23950                   cmp = 1;
23951                 }
23952               } else {
23953                 if (n3 == 0) {
23954                   cmp = n3 = 1;
23955                 }
23956                 prod = yc.slice();
23957                 prodL = prod.length;
23958               }
23959               if (prodL < remL)
23960                 prod = [0].concat(prod);
23961               subtract(rem, prod, remL, base);
23962               remL = rem.length;
23963               if (cmp == -1) {
23964                 while (compare2(yc, rem, yL, remL) < 1) {
23965                   n3++;
23966                   subtract(rem, yL < remL ? yz : yc, remL, base);
23967                   remL = rem.length;
23968                 }
23969               }
23970             } else if (cmp === 0) {
23971               n3++;
23972               rem = [0];
23973             }
23974             qc[i3++] = n3;
23975             if (rem[0]) {
23976               rem[remL++] = xc[xi] || 0;
23977             } else {
23978               rem = [xc[xi]];
23979               remL = 1;
23980             }
23981           } while ((xi++ < xL || rem[0] != null) && s2--);
23982           more = rem[0] != null;
23983           if (!qc[0])
23984             qc.splice(0, 1);
23985         }
23986         if (base == BASE) {
23987           for (i3 = 1, s2 = qc[0]; s2 >= 10; s2 /= 10, i3++)
23988             ;
23989           round(q2, dp + (q2.e = i3 + e3 * LOG_BASE - 1) + 1, rm, more);
23990         } else {
23991           q2.e = e3;
23992           q2.r = +more;
23993         }
23994         return q2;
23995       };
23996     }();
23997     function format2(n3, i3, rm, id2) {
23998       var c0, e3, ne2, len, str;
23999       if (rm == null)
24000         rm = ROUNDING_MODE;
24001       else
24002         intCheck(rm, 0, 8);
24003       if (!n3.c)
24004         return n3.toString();
24005       c0 = n3.c[0];
24006       ne2 = n3.e;
24007       if (i3 == null) {
24008         str = coeffToString(n3.c);
24009         str = id2 == 1 || id2 == 2 && (ne2 <= TO_EXP_NEG || ne2 >= TO_EXP_POS) ? toExponential(str, ne2) : toFixedPoint(str, ne2, "0");
24010       } else {
24011         n3 = round(new BigNumber2(n3), i3, rm);
24012         e3 = n3.e;
24013         str = coeffToString(n3.c);
24014         len = str.length;
24015         if (id2 == 1 || id2 == 2 && (i3 <= e3 || e3 <= TO_EXP_NEG)) {
24016           for (; len < i3; str += "0", len++)
24017             ;
24018           str = toExponential(str, e3);
24019         } else {
24020           i3 -= ne2;
24021           str = toFixedPoint(str, e3, "0");
24022           if (e3 + 1 > len) {
24023             if (--i3 > 0)
24024               for (str += "."; i3--; str += "0")
24025                 ;
24026           } else {
24027             i3 += e3 - len;
24028             if (i3 > 0) {
24029               if (e3 + 1 == len)
24030                 str += ".";
24031               for (; i3--; str += "0")
24032                 ;
24033             }
24034           }
24035         }
24036       }
24037       return n3.s < 0 && c0 ? "-" + str : str;
24038     }
24039     function maxOrMin(args, n3) {
24040       var k2, y2, i3 = 1, x2 = new BigNumber2(args[0]);
24041       for (; i3 < args.length; i3++) {
24042         y2 = new BigNumber2(args[i3]);
24043         if (!y2.s || (k2 = compare(x2, y2)) === n3 || k2 === 0 && x2.s === n3) {
24044           x2 = y2;
24045         }
24046       }
24047       return x2;
24048     }
24049     function normalise(n3, c2, e3) {
24050       var i3 = 1, j2 = c2.length;
24051       for (; !c2[--j2]; c2.pop())
24052         ;
24053       for (j2 = c2[0]; j2 >= 10; j2 /= 10, i3++)
24054         ;
24055       if ((e3 = i3 + e3 * LOG_BASE - 1) > MAX_EXP) {
24056         n3.c = n3.e = null;
24057       } else if (e3 < MIN_EXP) {
24058         n3.c = [n3.e = 0];
24059       } else {
24060         n3.e = e3;
24061         n3.c = c2;
24062       }
24063       return n3;
24064     }
24065     parseNumeric2 = /* @__PURE__ */ function() {
24066       var basePrefix = /^(-?)0([xbo])(?=\w[\w.]*$)/i, dotAfter = /^([^.]+)\.$/, dotBefore = /^\.([^.]+)$/, isInfinityOrNaN = /^-?(Infinity|NaN)$/, whitespaceOrPlus = /^\s*\+(?=[\w.])|^\s+|\s+$/g;
24067       return function(x2, str, isNum, b2) {
24068         var base, s2 = isNum ? str : str.replace(whitespaceOrPlus, "");
24069         if (isInfinityOrNaN.test(s2)) {
24070           x2.s = isNaN(s2) ? null : s2 < 0 ? -1 : 1;
24071         } else {
24072           if (!isNum) {
24073             s2 = s2.replace(basePrefix, function(m2, p1, p2) {
24074               base = (p2 = p2.toLowerCase()) == "x" ? 16 : p2 == "b" ? 2 : 8;
24075               return !b2 || b2 == base ? p1 : m2;
24076             });
24077             if (b2) {
24078               base = b2;
24079               s2 = s2.replace(dotAfter, "$1").replace(dotBefore, "0.$1");
24080             }
24081             if (str != s2)
24082               return new BigNumber2(s2, base);
24083           }
24084           if (BigNumber2.DEBUG) {
24085             throw Error(bignumberError + "Not a" + (b2 ? " base " + b2 : "") + " number: " + str);
24086           }
24087           x2.s = null;
24088         }
24089         x2.c = x2.e = null;
24090       };
24091     }();
24092     function round(x2, sd, rm, r2) {
24093       var d2, i3, j2, k2, n3, ni, rd, xc = x2.c, pows10 = POWS_TEN;
24094       if (xc) {
24095         out: {
24096           for (d2 = 1, k2 = xc[0]; k2 >= 10; k2 /= 10, d2++)
24097             ;
24098           i3 = sd - d2;
24099           if (i3 < 0) {
24100             i3 += LOG_BASE;
24101             j2 = sd;
24102             n3 = xc[ni = 0];
24103             rd = mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
24104           } else {
24105             ni = mathceil((i3 + 1) / LOG_BASE);
24106             if (ni >= xc.length) {
24107               if (r2) {
24108                 for (; xc.length <= ni; xc.push(0))
24109                   ;
24110                 n3 = rd = 0;
24111                 d2 = 1;
24112                 i3 %= LOG_BASE;
24113                 j2 = i3 - LOG_BASE + 1;
24114               } else {
24115                 break out;
24116               }
24117             } else {
24118               n3 = k2 = xc[ni];
24119               for (d2 = 1; k2 >= 10; k2 /= 10, d2++)
24120                 ;
24121               i3 %= LOG_BASE;
24122               j2 = i3 - LOG_BASE + d2;
24123               rd = j2 < 0 ? 0 : mathfloor(n3 / pows10[d2 - j2 - 1] % 10);
24124             }
24125           }
24126           r2 = r2 || sd < 0 || // Are there any non-zero digits after the rounding digit?
24127           // The expression  n % pows10[d - j - 1]  returns all digits of n to the right
24128           // of the digit at j, e.g. if n is 908714 and j is 2, the expression gives 714.
24129           xc[ni + 1] != null || (j2 < 0 ? n3 : n3 % pows10[d2 - j2 - 1]);
24130           r2 = rm < 4 ? (rd || r2) && (rm == 0 || rm == (x2.s < 0 ? 3 : 2)) : rd > 5 || rd == 5 && (rm == 4 || r2 || rm == 6 && // Check whether the digit to the left of the rounding digit is odd.
24131           (i3 > 0 ? j2 > 0 ? n3 / pows10[d2 - j2] : 0 : xc[ni - 1]) % 10 & 1 || rm == (x2.s < 0 ? 8 : 7));
24132           if (sd < 1 || !xc[0]) {
24133             xc.length = 0;
24134             if (r2) {
24135               sd -= x2.e + 1;
24136               xc[0] = pows10[(LOG_BASE - sd % LOG_BASE) % LOG_BASE];
24137               x2.e = -sd || 0;
24138             } else {
24139               xc[0] = x2.e = 0;
24140             }
24141             return x2;
24142           }
24143           if (i3 == 0) {
24144             xc.length = ni;
24145             k2 = 1;
24146             ni--;
24147           } else {
24148             xc.length = ni + 1;
24149             k2 = pows10[LOG_BASE - i3];
24150             xc[ni] = j2 > 0 ? mathfloor(n3 / pows10[d2 - j2] % pows10[j2]) * k2 : 0;
24151           }
24152           if (r2) {
24153             for (; ; ) {
24154               if (ni == 0) {
24155                 for (i3 = 1, j2 = xc[0]; j2 >= 10; j2 /= 10, i3++)
24156                   ;
24157                 j2 = xc[0] += k2;
24158                 for (k2 = 1; j2 >= 10; j2 /= 10, k2++)
24159                   ;
24160                 if (i3 != k2) {
24161                   x2.e++;
24162                   if (xc[0] == BASE)
24163                     xc[0] = 1;
24164                 }
24165                 break;
24166               } else {
24167                 xc[ni] += k2;
24168                 if (xc[ni] != BASE)
24169                   break;
24170                 xc[ni--] = 0;
24171                 k2 = 1;
24172               }
24173             }
24174           }
24175           for (i3 = xc.length; xc[--i3] === 0; xc.pop())
24176             ;
24177         }
24178         if (x2.e > MAX_EXP) {
24179           x2.c = x2.e = null;
24180         } else if (x2.e < MIN_EXP) {
24181           x2.c = [x2.e = 0];
24182         }
24183       }
24184       return x2;
24185     }
24186     function valueOf(n3) {
24187       var str, e3 = n3.e;
24188       if (e3 === null)
24189         return n3.toString();
24190       str = coeffToString(n3.c);
24191       str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(str, e3) : toFixedPoint(str, e3, "0");
24192       return n3.s < 0 ? "-" + str : str;
24193     }
24194     P2.absoluteValue = P2.abs = function() {
24195       var x2 = new BigNumber2(this);
24196       if (x2.s < 0)
24197         x2.s = 1;
24198       return x2;
24199     };
24200     P2.comparedTo = function(y2, b2) {
24201       return compare(this, new BigNumber2(y2, b2));
24202     };
24203     P2.decimalPlaces = P2.dp = function(dp, rm) {
24204       var c2, n3, v2, x2 = this;
24205       if (dp != null) {
24206         intCheck(dp, 0, MAX);
24207         if (rm == null)
24208           rm = ROUNDING_MODE;
24209         else
24210           intCheck(rm, 0, 8);
24211         return round(new BigNumber2(x2), dp + x2.e + 1, rm);
24212       }
24213       if (!(c2 = x2.c))
24214         return null;
24215       n3 = ((v2 = c2.length - 1) - bitFloor(this.e / LOG_BASE)) * LOG_BASE;
24216       if (v2 = c2[v2])
24217         for (; v2 % 10 == 0; v2 /= 10, n3--)
24218           ;
24219       if (n3 < 0)
24220         n3 = 0;
24221       return n3;
24222     };
24223     P2.dividedBy = P2.div = function(y2, b2) {
24224       return div(this, new BigNumber2(y2, b2), DECIMAL_PLACES, ROUNDING_MODE);
24225     };
24226     P2.dividedToIntegerBy = P2.idiv = function(y2, b2) {
24227       return div(this, new BigNumber2(y2, b2), 0, 1);
24228     };
24229     P2.exponentiatedBy = P2.pow = function(n3, m2) {
24230       var half, isModExp, i3, k2, more, nIsBig, nIsNeg, nIsOdd, y2, x2 = this;
24231       n3 = new BigNumber2(n3);
24232       if (n3.c && !n3.isInteger()) {
24233         throw Error(bignumberError + "Exponent not an integer: " + valueOf(n3));
24234       }
24235       if (m2 != null)
24236         m2 = new BigNumber2(m2);
24237       nIsBig = n3.e > 14;
24238       if (!x2.c || !x2.c[0] || x2.c[0] == 1 && !x2.e && x2.c.length == 1 || !n3.c || !n3.c[0]) {
24239         y2 = new BigNumber2(Math.pow(+valueOf(x2), nIsBig ? n3.s * (2 - isOdd(n3)) : +valueOf(n3)));
24240         return m2 ? y2.mod(m2) : y2;
24241       }
24242       nIsNeg = n3.s < 0;
24243       if (m2) {
24244         if (m2.c ? !m2.c[0] : !m2.s)
24245           return new BigNumber2(NaN);
24246         isModExp = !nIsNeg && x2.isInteger() && m2.isInteger();
24247         if (isModExp)
24248           x2 = x2.mod(m2);
24249       } else if (n3.e > 9 && (x2.e > 0 || x2.e < -1 || (x2.e == 0 ? x2.c[0] > 1 || nIsBig && x2.c[1] >= 24e7 : x2.c[0] < 8e13 || nIsBig && x2.c[0] <= 9999975e7))) {
24250         k2 = x2.s < 0 && isOdd(n3) ? -0 : 0;
24251         if (x2.e > -1)
24252           k2 = 1 / k2;
24253         return new BigNumber2(nIsNeg ? 1 / k2 : k2);
24254       } else if (POW_PRECISION) {
24255         k2 = mathceil(POW_PRECISION / LOG_BASE + 2);
24256       }
24257       if (nIsBig) {
24258         half = new BigNumber2(0.5);
24259         if (nIsNeg)
24260           n3.s = 1;
24261         nIsOdd = isOdd(n3);
24262       } else {
24263         i3 = Math.abs(+valueOf(n3));
24264         nIsOdd = i3 % 2;
24265       }
24266       y2 = new BigNumber2(ONE);
24267       for (; ; ) {
24268         if (nIsOdd) {
24269           y2 = y2.times(x2);
24270           if (!y2.c)
24271             break;
24272           if (k2) {
24273             if (y2.c.length > k2)
24274               y2.c.length = k2;
24275           } else if (isModExp) {
24276             y2 = y2.mod(m2);
24277           }
24278         }
24279         if (i3) {
24280           i3 = mathfloor(i3 / 2);
24281           if (i3 === 0)
24282             break;
24283           nIsOdd = i3 % 2;
24284         } else {
24285           n3 = n3.times(half);
24286           round(n3, n3.e + 1, 1);
24287           if (n3.e > 14) {
24288             nIsOdd = isOdd(n3);
24289           } else {
24290             i3 = +valueOf(n3);
24291             if (i3 === 0)
24292               break;
24293             nIsOdd = i3 % 2;
24294           }
24295         }
24296         x2 = x2.times(x2);
24297         if (k2) {
24298           if (x2.c && x2.c.length > k2)
24299             x2.c.length = k2;
24300         } else if (isModExp) {
24301           x2 = x2.mod(m2);
24302         }
24303       }
24304       if (isModExp)
24305         return y2;
24306       if (nIsNeg)
24307         y2 = ONE.div(y2);
24308       return m2 ? y2.mod(m2) : k2 ? round(y2, POW_PRECISION, ROUNDING_MODE, more) : y2;
24309     };
24310     P2.integerValue = function(rm) {
24311       var n3 = new BigNumber2(this);
24312       if (rm == null)
24313         rm = ROUNDING_MODE;
24314       else
24315         intCheck(rm, 0, 8);
24316       return round(n3, n3.e + 1, rm);
24317     };
24318     P2.isEqualTo = P2.eq = function(y2, b2) {
24319       return compare(this, new BigNumber2(y2, b2)) === 0;
24320     };
24321     P2.isFinite = function() {
24322       return !!this.c;
24323     };
24324     P2.isGreaterThan = P2.gt = function(y2, b2) {
24325       return compare(this, new BigNumber2(y2, b2)) > 0;
24326     };
24327     P2.isGreaterThanOrEqualTo = P2.gte = function(y2, b2) {
24328       return (b2 = compare(this, new BigNumber2(y2, b2))) === 1 || b2 === 0;
24329     };
24330     P2.isInteger = function() {
24331       return !!this.c && bitFloor(this.e / LOG_BASE) > this.c.length - 2;
24332     };
24333     P2.isLessThan = P2.lt = function(y2, b2) {
24334       return compare(this, new BigNumber2(y2, b2)) < 0;
24335     };
24336     P2.isLessThanOrEqualTo = P2.lte = function(y2, b2) {
24337       return (b2 = compare(this, new BigNumber2(y2, b2))) === -1 || b2 === 0;
24338     };
24339     P2.isNaN = function() {
24340       return !this.s;
24341     };
24342     P2.isNegative = function() {
24343       return this.s < 0;
24344     };
24345     P2.isPositive = function() {
24346       return this.s > 0;
24347     };
24348     P2.isZero = function() {
24349       return !!this.c && this.c[0] == 0;
24350     };
24351     P2.minus = function(y2, b2) {
24352       var i3, j2, t2, xLTy, x2 = this, a2 = x2.s;
24353       y2 = new BigNumber2(y2, b2);
24354       b2 = y2.s;
24355       if (!a2 || !b2)
24356         return new BigNumber2(NaN);
24357       if (a2 != b2) {
24358         y2.s = -b2;
24359         return x2.plus(y2);
24360       }
24361       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
24362       if (!xe2 || !ye2) {
24363         if (!xc || !yc)
24364           return xc ? (y2.s = -b2, y2) : new BigNumber2(yc ? x2 : NaN);
24365         if (!xc[0] || !yc[0]) {
24366           return yc[0] ? (y2.s = -b2, y2) : new BigNumber2(xc[0] ? x2 : (
24367             // IEEE 754 (2008) 6.3: n - n = -0 when rounding to -Infinity
24368             ROUNDING_MODE == 3 ? -0 : 0
24369           ));
24370         }
24371       }
24372       xe2 = bitFloor(xe2);
24373       ye2 = bitFloor(ye2);
24374       xc = xc.slice();
24375       if (a2 = xe2 - ye2) {
24376         if (xLTy = a2 < 0) {
24377           a2 = -a2;
24378           t2 = xc;
24379         } else {
24380           ye2 = xe2;
24381           t2 = yc;
24382         }
24383         t2.reverse();
24384         for (b2 = a2; b2--; t2.push(0))
24385           ;
24386         t2.reverse();
24387       } else {
24388         j2 = (xLTy = (a2 = xc.length) < (b2 = yc.length)) ? a2 : b2;
24389         for (a2 = b2 = 0; b2 < j2; b2++) {
24390           if (xc[b2] != yc[b2]) {
24391             xLTy = xc[b2] < yc[b2];
24392             break;
24393           }
24394         }
24395       }
24396       if (xLTy) {
24397         t2 = xc;
24398         xc = yc;
24399         yc = t2;
24400         y2.s = -y2.s;
24401       }
24402       b2 = (j2 = yc.length) - (i3 = xc.length);
24403       if (b2 > 0)
24404         for (; b2--; xc[i3++] = 0)
24405           ;
24406       b2 = BASE - 1;
24407       for (; j2 > a2; ) {
24408         if (xc[--j2] < yc[j2]) {
24409           for (i3 = j2; i3 && !xc[--i3]; xc[i3] = b2)
24410             ;
24411           --xc[i3];
24412           xc[j2] += BASE;
24413         }
24414         xc[j2] -= yc[j2];
24415       }
24416       for (; xc[0] == 0; xc.splice(0, 1), --ye2)
24417         ;
24418       if (!xc[0]) {
24419         y2.s = ROUNDING_MODE == 3 ? -1 : 1;
24420         y2.c = [y2.e = 0];
24421         return y2;
24422       }
24423       return normalise(y2, xc, ye2);
24424     };
24425     P2.modulo = P2.mod = function(y2, b2) {
24426       var q2, s2, x2 = this;
24427       y2 = new BigNumber2(y2, b2);
24428       if (!x2.c || !y2.s || y2.c && !y2.c[0]) {
24429         return new BigNumber2(NaN);
24430       } else if (!y2.c || x2.c && !x2.c[0]) {
24431         return new BigNumber2(x2);
24432       }
24433       if (MODULO_MODE == 9) {
24434         s2 = y2.s;
24435         y2.s = 1;
24436         q2 = div(x2, y2, 0, 3);
24437         y2.s = s2;
24438         q2.s *= s2;
24439       } else {
24440         q2 = div(x2, y2, 0, MODULO_MODE);
24441       }
24442       y2 = x2.minus(q2.times(y2));
24443       if (!y2.c[0] && MODULO_MODE == 1)
24444         y2.s = x2.s;
24445       return y2;
24446     };
24447     P2.multipliedBy = P2.times = function(y2, b2) {
24448       var c2, e3, i3, j2, k2, m2, xcL, xlo, xhi, ycL, ylo, yhi, zc, base, sqrtBase, x2 = this, xc = x2.c, yc = (y2 = new BigNumber2(y2, b2)).c;
24449       if (!xc || !yc || !xc[0] || !yc[0]) {
24450         if (!x2.s || !y2.s || xc && !xc[0] && !yc || yc && !yc[0] && !xc) {
24451           y2.c = y2.e = y2.s = null;
24452         } else {
24453           y2.s *= x2.s;
24454           if (!xc || !yc) {
24455             y2.c = y2.e = null;
24456           } else {
24457             y2.c = [0];
24458             y2.e = 0;
24459           }
24460         }
24461         return y2;
24462       }
24463       e3 = bitFloor(x2.e / LOG_BASE) + bitFloor(y2.e / LOG_BASE);
24464       y2.s *= x2.s;
24465       xcL = xc.length;
24466       ycL = yc.length;
24467       if (xcL < ycL) {
24468         zc = xc;
24469         xc = yc;
24470         yc = zc;
24471         i3 = xcL;
24472         xcL = ycL;
24473         ycL = i3;
24474       }
24475       for (i3 = xcL + ycL, zc = []; i3--; zc.push(0))
24476         ;
24477       base = BASE;
24478       sqrtBase = SQRT_BASE;
24479       for (i3 = ycL; --i3 >= 0; ) {
24480         c2 = 0;
24481         ylo = yc[i3] % sqrtBase;
24482         yhi = yc[i3] / sqrtBase | 0;
24483         for (k2 = xcL, j2 = i3 + k2; j2 > i3; ) {
24484           xlo = xc[--k2] % sqrtBase;
24485           xhi = xc[k2] / sqrtBase | 0;
24486           m2 = yhi * xlo + xhi * ylo;
24487           xlo = ylo * xlo + m2 % sqrtBase * sqrtBase + zc[j2] + c2;
24488           c2 = (xlo / base | 0) + (m2 / sqrtBase | 0) + yhi * xhi;
24489           zc[j2--] = xlo % base;
24490         }
24491         zc[j2] = c2;
24492       }
24493       if (c2) {
24494         ++e3;
24495       } else {
24496         zc.splice(0, 1);
24497       }
24498       return normalise(y2, zc, e3);
24499     };
24500     P2.negated = function() {
24501       var x2 = new BigNumber2(this);
24502       x2.s = -x2.s || null;
24503       return x2;
24504     };
24505     P2.plus = function(y2, b2) {
24506       var t2, x2 = this, a2 = x2.s;
24507       y2 = new BigNumber2(y2, b2);
24508       b2 = y2.s;
24509       if (!a2 || !b2)
24510         return new BigNumber2(NaN);
24511       if (a2 != b2) {
24512         y2.s = -b2;
24513         return x2.minus(y2);
24514       }
24515       var xe2 = x2.e / LOG_BASE, ye2 = y2.e / LOG_BASE, xc = x2.c, yc = y2.c;
24516       if (!xe2 || !ye2) {
24517         if (!xc || !yc)
24518           return new BigNumber2(a2 / 0);
24519         if (!xc[0] || !yc[0])
24520           return yc[0] ? y2 : new BigNumber2(xc[0] ? x2 : a2 * 0);
24521       }
24522       xe2 = bitFloor(xe2);
24523       ye2 = bitFloor(ye2);
24524       xc = xc.slice();
24525       if (a2 = xe2 - ye2) {
24526         if (a2 > 0) {
24527           ye2 = xe2;
24528           t2 = yc;
24529         } else {
24530           a2 = -a2;
24531           t2 = xc;
24532         }
24533         t2.reverse();
24534         for (; a2--; t2.push(0))
24535           ;
24536         t2.reverse();
24537       }
24538       a2 = xc.length;
24539       b2 = yc.length;
24540       if (a2 - b2 < 0) {
24541         t2 = yc;
24542         yc = xc;
24543         xc = t2;
24544         b2 = a2;
24545       }
24546       for (a2 = 0; b2; ) {
24547         a2 = (xc[--b2] = xc[b2] + yc[b2] + a2) / BASE | 0;
24548         xc[b2] = BASE === xc[b2] ? 0 : xc[b2] % BASE;
24549       }
24550       if (a2) {
24551         xc = [a2].concat(xc);
24552         ++ye2;
24553       }
24554       return normalise(y2, xc, ye2);
24555     };
24556     P2.precision = P2.sd = function(sd, rm) {
24557       var c2, n3, v2, x2 = this;
24558       if (sd != null && sd !== !!sd) {
24559         intCheck(sd, 1, MAX);
24560         if (rm == null)
24561           rm = ROUNDING_MODE;
24562         else
24563           intCheck(rm, 0, 8);
24564         return round(new BigNumber2(x2), sd, rm);
24565       }
24566       if (!(c2 = x2.c))
24567         return null;
24568       v2 = c2.length - 1;
24569       n3 = v2 * LOG_BASE + 1;
24570       if (v2 = c2[v2]) {
24571         for (; v2 % 10 == 0; v2 /= 10, n3--)
24572           ;
24573         for (v2 = c2[0]; v2 >= 10; v2 /= 10, n3++)
24574           ;
24575       }
24576       if (sd && x2.e + 1 > n3)
24577         n3 = x2.e + 1;
24578       return n3;
24579     };
24580     P2.shiftedBy = function(k2) {
24581       intCheck(k2, -MAX_SAFE_INTEGER, MAX_SAFE_INTEGER);
24582       return this.times("1e" + k2);
24583     };
24584     P2.squareRoot = P2.sqrt = function() {
24585       var m2, n3, r2, rep, t2, x2 = this, c2 = x2.c, s2 = x2.s, e3 = x2.e, dp = DECIMAL_PLACES + 4, half = new BigNumber2("0.5");
24586       if (s2 !== 1 || !c2 || !c2[0]) {
24587         return new BigNumber2(!s2 || s2 < 0 && (!c2 || c2[0]) ? NaN : c2 ? x2 : 1 / 0);
24588       }
24589       s2 = Math.sqrt(+valueOf(x2));
24590       if (s2 == 0 || s2 == 1 / 0) {
24591         n3 = coeffToString(c2);
24592         if ((n3.length + e3) % 2 == 0)
24593           n3 += "0";
24594         s2 = Math.sqrt(+n3);
24595         e3 = bitFloor((e3 + 1) / 2) - (e3 < 0 || e3 % 2);
24596         if (s2 == 1 / 0) {
24597           n3 = "5e" + e3;
24598         } else {
24599           n3 = s2.toExponential();
24600           n3 = n3.slice(0, n3.indexOf("e") + 1) + e3;
24601         }
24602         r2 = new BigNumber2(n3);
24603       } else {
24604         r2 = new BigNumber2(s2 + "");
24605       }
24606       if (r2.c[0]) {
24607         e3 = r2.e;
24608         s2 = e3 + dp;
24609         if (s2 < 3)
24610           s2 = 0;
24611         for (; ; ) {
24612           t2 = r2;
24613           r2 = half.times(t2.plus(div(x2, t2, dp, 1)));
24614           if (coeffToString(t2.c).slice(0, s2) === (n3 = coeffToString(r2.c)).slice(0, s2)) {
24615             if (r2.e < e3)
24616               --s2;
24617             n3 = n3.slice(s2 - 3, s2 + 1);
24618             if (n3 == "9999" || !rep && n3 == "4999") {
24619               if (!rep) {
24620                 round(t2, t2.e + DECIMAL_PLACES + 2, 0);
24621                 if (t2.times(t2).eq(x2)) {
24622                   r2 = t2;
24623                   break;
24624                 }
24625               }
24626               dp += 4;
24627               s2 += 4;
24628               rep = 1;
24629             } else {
24630               if (!+n3 || !+n3.slice(1) && n3.charAt(0) == "5") {
24631                 round(r2, r2.e + DECIMAL_PLACES + 2, 1);
24632                 m2 = !r2.times(r2).eq(x2);
24633               }
24634               break;
24635             }
24636           }
24637         }
24638       }
24639       return round(r2, r2.e + DECIMAL_PLACES + 1, ROUNDING_MODE, m2);
24640     };
24641     P2.toExponential = function(dp, rm) {
24642       if (dp != null) {
24643         intCheck(dp, 0, MAX);
24644         dp++;
24645       }
24646       return format2(this, dp, rm, 1);
24647     };
24648     P2.toFixed = function(dp, rm) {
24649       if (dp != null) {
24650         intCheck(dp, 0, MAX);
24651         dp = dp + this.e + 1;
24652       }
24653       return format2(this, dp, rm);
24654     };
24655     P2.toFormat = function(dp, rm, format3) {
24656       var str, x2 = this;
24657       if (format3 == null) {
24658         if (dp != null && rm && typeof rm == "object") {
24659           format3 = rm;
24660           rm = null;
24661         } else if (dp && typeof dp == "object") {
24662           format3 = dp;
24663           dp = rm = null;
24664         } else {
24665           format3 = FORMAT;
24666         }
24667       } else if (typeof format3 != "object") {
24668         throw Error(bignumberError + "Argument not an object: " + format3);
24669       }
24670       str = x2.toFixed(dp, rm);
24671       if (x2.c) {
24672         var i3, arr = str.split("."), g1 = +format3.groupSize, g22 = +format3.secondaryGroupSize, groupSeparator = format3.groupSeparator || "", intPart = arr[0], fractionPart = arr[1], isNeg = x2.s < 0, intDigits = isNeg ? intPart.slice(1) : intPart, len = intDigits.length;
24673         if (g22) {
24674           i3 = g1;
24675           g1 = g22;
24676           g22 = i3;
24677           len -= i3;
24678         }
24679         if (g1 > 0 && len > 0) {
24680           i3 = len % g1 || g1;
24681           intPart = intDigits.substr(0, i3);
24682           for (; i3 < len; i3 += g1)
24683             intPart += groupSeparator + intDigits.substr(i3, g1);
24684           if (g22 > 0)
24685             intPart += groupSeparator + intDigits.slice(i3);
24686           if (isNeg)
24687             intPart = "-" + intPart;
24688         }
24689         str = fractionPart ? intPart + (format3.decimalSeparator || "") + ((g22 = +format3.fractionGroupSize) ? fractionPart.replace(
24690           new RegExp("\\d{" + g22 + "}\\B", "g"),
24691           "$&" + (format3.fractionGroupSeparator || "")
24692         ) : fractionPart) : intPart;
24693       }
24694       return (format3.prefix || "") + str + (format3.suffix || "");
24695     };
24696     P2.toFraction = function(md) {
24697       var d2, d0, d1, d22, e3, exp2, n3, n0, n1, q2, r2, s2, x2 = this, xc = x2.c;
24698       if (md != null) {
24699         n3 = new BigNumber2(md);
24700         if (!n3.isInteger() && (n3.c || n3.s !== 1) || n3.lt(ONE)) {
24701           throw Error(bignumberError + "Argument " + (n3.isInteger() ? "out of range: " : "not an integer: ") + valueOf(n3));
24702         }
24703       }
24704       if (!xc)
24705         return new BigNumber2(x2);
24706       d2 = new BigNumber2(ONE);
24707       n1 = d0 = new BigNumber2(ONE);
24708       d1 = n0 = new BigNumber2(ONE);
24709       s2 = coeffToString(xc);
24710       e3 = d2.e = s2.length - x2.e - 1;
24711       d2.c[0] = POWS_TEN[(exp2 = e3 % LOG_BASE) < 0 ? LOG_BASE + exp2 : exp2];
24712       md = !md || n3.comparedTo(d2) > 0 ? e3 > 0 ? d2 : n1 : n3;
24713       exp2 = MAX_EXP;
24714       MAX_EXP = 1 / 0;
24715       n3 = new BigNumber2(s2);
24716       n0.c[0] = 0;
24717       for (; ; ) {
24718         q2 = div(n3, d2, 0, 1);
24719         d22 = d0.plus(q2.times(d1));
24720         if (d22.comparedTo(md) == 1)
24721           break;
24722         d0 = d1;
24723         d1 = d22;
24724         n1 = n0.plus(q2.times(d22 = n1));
24725         n0 = d22;
24726         d2 = n3.minus(q2.times(d22 = d2));
24727         n3 = d22;
24728       }
24729       d22 = div(md.minus(d0), d1, 0, 1);
24730       n0 = n0.plus(d22.times(n1));
24731       d0 = d0.plus(d22.times(d1));
24732       n0.s = n1.s = x2.s;
24733       e3 = e3 * 2;
24734       r2 = div(n1, d1, e3, ROUNDING_MODE).minus(x2).abs().comparedTo(
24735         div(n0, d0, e3, ROUNDING_MODE).minus(x2).abs()
24736       ) < 1 ? [n1, d1] : [n0, d0];
24737       MAX_EXP = exp2;
24738       return r2;
24739     };
24740     P2.toNumber = function() {
24741       return +valueOf(this);
24742     };
24743     P2.toPrecision = function(sd, rm) {
24744       if (sd != null)
24745         intCheck(sd, 1, MAX);
24746       return format2(this, sd, rm, 2);
24747     };
24748     P2.toString = function(b2) {
24749       var str, n3 = this, s2 = n3.s, e3 = n3.e;
24750       if (e3 === null) {
24751         if (s2) {
24752           str = "Infinity";
24753           if (s2 < 0)
24754             str = "-" + str;
24755         } else {
24756           str = "NaN";
24757         }
24758       } else {
24759         if (b2 == null) {
24760           str = e3 <= TO_EXP_NEG || e3 >= TO_EXP_POS ? toExponential(coeffToString(n3.c), e3) : toFixedPoint(coeffToString(n3.c), e3, "0");
24761         } else if (b2 === 10 && alphabetHasNormalDecimalDigits) {
24762           n3 = round(new BigNumber2(n3), DECIMAL_PLACES + e3 + 1, ROUNDING_MODE);
24763           str = toFixedPoint(coeffToString(n3.c), n3.e, "0");
24764         } else {
24765           intCheck(b2, 2, ALPHABET.length, "Base");
24766           str = convertBase(toFixedPoint(coeffToString(n3.c), e3, "0"), 10, b2, s2, true);
24767         }
24768         if (s2 < 0 && n3.c[0])
24769           str = "-" + str;
24770       }
24771       return str;
24772     };
24773     P2.valueOf = P2.toJSON = function() {
24774       return valueOf(this);
24775     };
24776     P2._isBigNumber = true;
24777     P2[Symbol.toStringTag] = "BigNumber";
24778     P2[Symbol.for("nodejs.util.inspect.custom")] = P2.valueOf;
24779     if (configObject != null)
24780       BigNumber2.set(configObject);
24781     return BigNumber2;
24782   }
24783   function bitFloor(n3) {
24784     var i3 = n3 | 0;
24785     return n3 > 0 || n3 === i3 ? i3 : i3 - 1;
24786   }
24787   function coeffToString(a2) {
24788     var s2, z2, i3 = 1, j2 = a2.length, r2 = a2[0] + "";
24789     for (; i3 < j2; ) {
24790       s2 = a2[i3++] + "";
24791       z2 = LOG_BASE - s2.length;
24792       for (; z2--; s2 = "0" + s2)
24793         ;
24794       r2 += s2;
24795     }
24796     for (j2 = r2.length; r2.charCodeAt(--j2) === 48; )
24797       ;
24798     return r2.slice(0, j2 + 1 || 1);
24799   }
24800   function compare(x2, y2) {
24801     var a2, b2, xc = x2.c, yc = y2.c, i3 = x2.s, j2 = y2.s, k2 = x2.e, l2 = y2.e;
24802     if (!i3 || !j2)
24803       return null;
24804     a2 = xc && !xc[0];
24805     b2 = yc && !yc[0];
24806     if (a2 || b2)
24807       return a2 ? b2 ? 0 : -j2 : i3;
24808     if (i3 != j2)
24809       return i3;
24810     a2 = i3 < 0;
24811     b2 = k2 == l2;
24812     if (!xc || !yc)
24813       return b2 ? 0 : !xc ^ a2 ? 1 : -1;
24814     if (!b2)
24815       return k2 > l2 ^ a2 ? 1 : -1;
24816     j2 = (k2 = xc.length) < (l2 = yc.length) ? k2 : l2;
24817     for (i3 = 0; i3 < j2; i3++)
24818       if (xc[i3] != yc[i3])
24819         return xc[i3] > yc[i3] ^ a2 ? 1 : -1;
24820     return k2 == l2 ? 0 : k2 > l2 ^ a2 ? 1 : -1;
24821   }
24822   function intCheck(n3, min3, max3, name) {
24823     if (n3 < min3 || n3 > max3 || n3 !== mathfloor(n3)) {
24824       throw Error(bignumberError + (name || "Argument") + (typeof n3 == "number" ? n3 < min3 || n3 > max3 ? " out of range: " : " not an integer: " : " not a primitive number: ") + String(n3));
24825     }
24826   }
24827   function isOdd(n3) {
24828     var k2 = n3.c.length - 1;
24829     return bitFloor(n3.e / LOG_BASE) == k2 && n3.c[k2] % 2 != 0;
24830   }
24831   function toExponential(str, e3) {
24832     return (str.length > 1 ? str.charAt(0) + "." + str.slice(1) : str) + (e3 < 0 ? "e" : "e+") + e3;
24833   }
24834   function toFixedPoint(str, e3, z2) {
24835     var len, zs;
24836     if (e3 < 0) {
24837       for (zs = z2 + "."; ++e3; zs += z2)
24838         ;
24839       str = zs + str;
24840     } else {
24841       len = str.length;
24842       if (++e3 > len) {
24843         for (zs = z2, e3 -= len; --e3; zs += z2)
24844           ;
24845         str += zs;
24846       } else if (e3 < len) {
24847         str = str.slice(0, e3) + "." + str.slice(e3);
24848       }
24849     }
24850     return str;
24851   }
24852   var BigNumber = clone();
24853   var bignumber_default = BigNumber;
24854
24855   // node_modules/splaytree-ts/dist/index.js
24856   var SplayTreeNode = class {
24857     constructor(key) {
24858       __publicField(this, "key");
24859       __publicField(this, "left", null);
24860       __publicField(this, "right", null);
24861       this.key = key;
24862     }
24863   };
24864   var SplayTreeSetNode = class extends SplayTreeNode {
24865     constructor(key) {
24866       super(key);
24867     }
24868   };
24869   var SplayTree = class {
24870     constructor() {
24871       __publicField(this, "size", 0);
24872       __publicField(this, "modificationCount", 0);
24873       __publicField(this, "splayCount", 0);
24874     }
24875     splay(key) {
24876       const root3 = this.root;
24877       if (root3 == null) {
24878         this.compare(key, key);
24879         return -1;
24880       }
24881       let right = null;
24882       let newTreeRight = null;
24883       let left = null;
24884       let newTreeLeft = null;
24885       let current = root3;
24886       const compare2 = this.compare;
24887       let comp;
24888       while (true) {
24889         comp = compare2(current.key, key);
24890         if (comp > 0) {
24891           let currentLeft = current.left;
24892           if (currentLeft == null)
24893             break;
24894           comp = compare2(currentLeft.key, key);
24895           if (comp > 0) {
24896             current.left = currentLeft.right;
24897             currentLeft.right = current;
24898             current = currentLeft;
24899             currentLeft = current.left;
24900             if (currentLeft == null)
24901               break;
24902           }
24903           if (right == null) {
24904             newTreeRight = current;
24905           } else {
24906             right.left = current;
24907           }
24908           right = current;
24909           current = currentLeft;
24910         } else if (comp < 0) {
24911           let currentRight = current.right;
24912           if (currentRight == null)
24913             break;
24914           comp = compare2(currentRight.key, key);
24915           if (comp < 0) {
24916             current.right = currentRight.left;
24917             currentRight.left = current;
24918             current = currentRight;
24919             currentRight = current.right;
24920             if (currentRight == null)
24921               break;
24922           }
24923           if (left == null) {
24924             newTreeLeft = current;
24925           } else {
24926             left.right = current;
24927           }
24928           left = current;
24929           current = currentRight;
24930         } else {
24931           break;
24932         }
24933       }
24934       if (left != null) {
24935         left.right = current.left;
24936         current.left = newTreeLeft;
24937       }
24938       if (right != null) {
24939         right.left = current.right;
24940         current.right = newTreeRight;
24941       }
24942       if (this.root !== current) {
24943         this.root = current;
24944         this.splayCount++;
24945       }
24946       return comp;
24947     }
24948     splayMin(node) {
24949       let current = node;
24950       let nextLeft = current.left;
24951       while (nextLeft != null) {
24952         const left = nextLeft;
24953         current.left = left.right;
24954         left.right = current;
24955         current = left;
24956         nextLeft = current.left;
24957       }
24958       return current;
24959     }
24960     splayMax(node) {
24961       let current = node;
24962       let nextRight = current.right;
24963       while (nextRight != null) {
24964         const right = nextRight;
24965         current.right = right.left;
24966         right.left = current;
24967         current = right;
24968         nextRight = current.right;
24969       }
24970       return current;
24971     }
24972     _delete(key) {
24973       if (this.root == null)
24974         return null;
24975       const comp = this.splay(key);
24976       if (comp != 0)
24977         return null;
24978       let root3 = this.root;
24979       const result = root3;
24980       const left = root3.left;
24981       this.size--;
24982       if (left == null) {
24983         this.root = root3.right;
24984       } else {
24985         const right = root3.right;
24986         root3 = this.splayMax(left);
24987         root3.right = right;
24988         this.root = root3;
24989       }
24990       this.modificationCount++;
24991       return result;
24992     }
24993     addNewRoot(node, comp) {
24994       this.size++;
24995       this.modificationCount++;
24996       const root3 = this.root;
24997       if (root3 == null) {
24998         this.root = node;
24999         return;
25000       }
25001       if (comp < 0) {
25002         node.left = root3;
25003         node.right = root3.right;
25004         root3.right = null;
25005       } else {
25006         node.right = root3;
25007         node.left = root3.left;
25008         root3.left = null;
25009       }
25010       this.root = node;
25011     }
25012     _first() {
25013       const root3 = this.root;
25014       if (root3 == null)
25015         return null;
25016       this.root = this.splayMin(root3);
25017       return this.root;
25018     }
25019     _last() {
25020       const root3 = this.root;
25021       if (root3 == null)
25022         return null;
25023       this.root = this.splayMax(root3);
25024       return this.root;
25025     }
25026     clear() {
25027       this.root = null;
25028       this.size = 0;
25029       this.modificationCount++;
25030     }
25031     has(key) {
25032       return this.validKey(key) && this.splay(key) == 0;
25033     }
25034     defaultCompare() {
25035       return (a2, b2) => a2 < b2 ? -1 : a2 > b2 ? 1 : 0;
25036     }
25037     wrap() {
25038       return {
25039         getRoot: () => {
25040           return this.root;
25041         },
25042         setRoot: (root3) => {
25043           this.root = root3;
25044         },
25045         getSize: () => {
25046           return this.size;
25047         },
25048         getModificationCount: () => {
25049           return this.modificationCount;
25050         },
25051         getSplayCount: () => {
25052           return this.splayCount;
25053         },
25054         setSplayCount: (count) => {
25055           this.splayCount = count;
25056         },
25057         splay: (key) => {
25058           return this.splay(key);
25059         },
25060         has: (key) => {
25061           return this.has(key);
25062         }
25063       };
25064     }
25065   };
25066   var _a;
25067   var _SplayTreeSet = class _SplayTreeSet extends SplayTree {
25068     constructor(compare2, isValidKey) {
25069       super();
25070       __publicField(this, "root", null);
25071       __publicField(this, "compare");
25072       __publicField(this, "validKey");
25073       __publicField(this, _a, "[object Set]");
25074       this.compare = compare2 != null ? compare2 : this.defaultCompare();
25075       this.validKey = isValidKey != null ? isValidKey : (v2) => v2 != null && v2 != void 0;
25076     }
25077     delete(element) {
25078       if (!this.validKey(element))
25079         return false;
25080       return this._delete(element) != null;
25081     }
25082     deleteAll(elements) {
25083       for (const element of elements) {
25084         this.delete(element);
25085       }
25086     }
25087     forEach(f2) {
25088       const nodes = this[Symbol.iterator]();
25089       let result;
25090       while (result = nodes.next(), !result.done) {
25091         f2(result.value, result.value, this);
25092       }
25093     }
25094     add(element) {
25095       const compare2 = this.splay(element);
25096       if (compare2 != 0)
25097         this.addNewRoot(new SplayTreeSetNode(element), compare2);
25098       return this;
25099     }
25100     addAndReturn(element) {
25101       const compare2 = this.splay(element);
25102       if (compare2 != 0)
25103         this.addNewRoot(new SplayTreeSetNode(element), compare2);
25104       return this.root.key;
25105     }
25106     addAll(elements) {
25107       for (const element of elements) {
25108         this.add(element);
25109       }
25110     }
25111     isEmpty() {
25112       return this.root == null;
25113     }
25114     isNotEmpty() {
25115       return this.root != null;
25116     }
25117     single() {
25118       if (this.size == 0)
25119         throw "Bad state: No element";
25120       if (this.size > 1)
25121         throw "Bad state: Too many element";
25122       return this.root.key;
25123     }
25124     first() {
25125       if (this.size == 0)
25126         throw "Bad state: No element";
25127       return this._first().key;
25128     }
25129     last() {
25130       if (this.size == 0)
25131         throw "Bad state: No element";
25132       return this._last().key;
25133     }
25134     lastBefore(element) {
25135       if (element == null)
25136         throw "Invalid arguments(s)";
25137       if (this.root == null)
25138         return null;
25139       const comp = this.splay(element);
25140       if (comp < 0)
25141         return this.root.key;
25142       let node = this.root.left;
25143       if (node == null)
25144         return null;
25145       let nodeRight = node.right;
25146       while (nodeRight != null) {
25147         node = nodeRight;
25148         nodeRight = node.right;
25149       }
25150       return node.key;
25151     }
25152     firstAfter(element) {
25153       if (element == null)
25154         throw "Invalid arguments(s)";
25155       if (this.root == null)
25156         return null;
25157       const comp = this.splay(element);
25158       if (comp > 0)
25159         return this.root.key;
25160       let node = this.root.right;
25161       if (node == null)
25162         return null;
25163       let nodeLeft = node.left;
25164       while (nodeLeft != null) {
25165         node = nodeLeft;
25166         nodeLeft = node.left;
25167       }
25168       return node.key;
25169     }
25170     retainAll(elements) {
25171       const retainSet = new _SplayTreeSet(this.compare, this.validKey);
25172       const modificationCount = this.modificationCount;
25173       for (const object of elements) {
25174         if (modificationCount != this.modificationCount) {
25175           throw "Concurrent modification during iteration.";
25176         }
25177         if (this.validKey(object) && this.splay(object) == 0) {
25178           retainSet.add(this.root.key);
25179         }
25180       }
25181       if (retainSet.size != this.size) {
25182         this.root = retainSet.root;
25183         this.size = retainSet.size;
25184         this.modificationCount++;
25185       }
25186     }
25187     lookup(object) {
25188       if (!this.validKey(object))
25189         return null;
25190       const comp = this.splay(object);
25191       if (comp != 0)
25192         return null;
25193       return this.root.key;
25194     }
25195     intersection(other) {
25196       const result = new _SplayTreeSet(this.compare, this.validKey);
25197       for (const element of this) {
25198         if (other.has(element))
25199           result.add(element);
25200       }
25201       return result;
25202     }
25203     difference(other) {
25204       const result = new _SplayTreeSet(this.compare, this.validKey);
25205       for (const element of this) {
25206         if (!other.has(element))
25207           result.add(element);
25208       }
25209       return result;
25210     }
25211     union(other) {
25212       const u2 = this.clone();
25213       u2.addAll(other);
25214       return u2;
25215     }
25216     clone() {
25217       const set4 = new _SplayTreeSet(this.compare, this.validKey);
25218       set4.size = this.size;
25219       set4.root = this.copyNode(this.root);
25220       return set4;
25221     }
25222     copyNode(node) {
25223       if (node == null)
25224         return null;
25225       function copyChildren(node2, dest) {
25226         let left;
25227         let right;
25228         do {
25229           left = node2.left;
25230           right = node2.right;
25231           if (left != null) {
25232             const newLeft = new SplayTreeSetNode(left.key);
25233             dest.left = newLeft;
25234             copyChildren(left, newLeft);
25235           }
25236           if (right != null) {
25237             const newRight = new SplayTreeSetNode(right.key);
25238             dest.right = newRight;
25239             node2 = right;
25240             dest = newRight;
25241           }
25242         } while (right != null);
25243       }
25244       const result = new SplayTreeSetNode(node.key);
25245       copyChildren(node, result);
25246       return result;
25247     }
25248     toSet() {
25249       return this.clone();
25250     }
25251     entries() {
25252       return new SplayTreeSetEntryIterableIterator(this.wrap());
25253     }
25254     keys() {
25255       return this[Symbol.iterator]();
25256     }
25257     values() {
25258       return this[Symbol.iterator]();
25259     }
25260     [Symbol.iterator]() {
25261       return new SplayTreeKeyIterableIterator(this.wrap());
25262     }
25263   };
25264   _a = Symbol.toStringTag;
25265   var SplayTreeSet = _SplayTreeSet;
25266   var SplayTreeIterableIterator = class {
25267     constructor(tree) {
25268       __publicField(this, "tree");
25269       __publicField(this, "path", new Array());
25270       __publicField(this, "modificationCount", null);
25271       __publicField(this, "splayCount");
25272       this.tree = tree;
25273       this.splayCount = tree.getSplayCount();
25274     }
25275     [Symbol.iterator]() {
25276       return this;
25277     }
25278     next() {
25279       if (this.moveNext())
25280         return { done: false, value: this.current() };
25281       return { done: true, value: null };
25282     }
25283     current() {
25284       if (!this.path.length)
25285         return null;
25286       const node = this.path[this.path.length - 1];
25287       return this.getValue(node);
25288     }
25289     rebuildPath(key) {
25290       this.path.splice(0, this.path.length);
25291       this.tree.splay(key);
25292       this.path.push(this.tree.getRoot());
25293       this.splayCount = this.tree.getSplayCount();
25294     }
25295     findLeftMostDescendent(node) {
25296       while (node != null) {
25297         this.path.push(node);
25298         node = node.left;
25299       }
25300     }
25301     moveNext() {
25302       if (this.modificationCount != this.tree.getModificationCount()) {
25303         if (this.modificationCount == null) {
25304           this.modificationCount = this.tree.getModificationCount();
25305           let node2 = this.tree.getRoot();
25306           while (node2 != null) {
25307             this.path.push(node2);
25308             node2 = node2.left;
25309           }
25310           return this.path.length > 0;
25311         }
25312         throw "Concurrent modification during iteration.";
25313       }
25314       if (!this.path.length)
25315         return false;
25316       if (this.splayCount != this.tree.getSplayCount()) {
25317         this.rebuildPath(this.path[this.path.length - 1].key);
25318       }
25319       let node = this.path[this.path.length - 1];
25320       let next = node.right;
25321       if (next != null) {
25322         while (next != null) {
25323           this.path.push(next);
25324           next = next.left;
25325         }
25326         return true;
25327       }
25328       this.path.pop();
25329       while (this.path.length && this.path[this.path.length - 1].right === node) {
25330         node = this.path.pop();
25331       }
25332       return this.path.length > 0;
25333     }
25334   };
25335   var SplayTreeKeyIterableIterator = class extends SplayTreeIterableIterator {
25336     getValue(node) {
25337       return node.key;
25338     }
25339   };
25340   var SplayTreeSetEntryIterableIterator = class extends SplayTreeIterableIterator {
25341     getValue(node) {
25342       return [node.key, node.key];
25343     }
25344   };
25345
25346   // node_modules/polyclip-ts/dist/identity.js
25347   var identity_default3 = (x2) => {
25348     return x2;
25349   };
25350
25351   // node_modules/polyclip-ts/dist/snap.js
25352   var snap_default = (eps) => {
25353     if (eps) {
25354       const xTree = new SplayTreeSet(compare_default(eps));
25355       const yTree = new SplayTreeSet(compare_default(eps));
25356       const snapCoord = (coord2, tree) => {
25357         return tree.addAndReturn(coord2);
25358       };
25359       const snap = (v2) => {
25360         return {
25361           x: snapCoord(v2.x, xTree),
25362           y: snapCoord(v2.y, yTree)
25363         };
25364       };
25365       snap({ x: new bignumber_default(0), y: new bignumber_default(0) });
25366       return snap;
25367     }
25368     return identity_default3;
25369   };
25370
25371   // node_modules/polyclip-ts/dist/precision.js
25372   var set3 = (eps) => {
25373     return {
25374       set: (eps2) => {
25375         precision = set3(eps2);
25376       },
25377       reset: () => set3(eps),
25378       compare: compare_default(eps),
25379       snap: snap_default(eps),
25380       orient: orient_default(eps)
25381     };
25382   };
25383   var precision = set3();
25384
25385   // node_modules/polyclip-ts/dist/bbox.js
25386   var isInBbox = (bbox2, point2) => {
25387     return bbox2.ll.x.isLessThanOrEqualTo(point2.x) && point2.x.isLessThanOrEqualTo(bbox2.ur.x) && bbox2.ll.y.isLessThanOrEqualTo(point2.y) && point2.y.isLessThanOrEqualTo(bbox2.ur.y);
25388   };
25389   var getBboxOverlap = (b1, b2) => {
25390     if (b2.ur.x.isLessThan(b1.ll.x) || b1.ur.x.isLessThan(b2.ll.x) || b2.ur.y.isLessThan(b1.ll.y) || b1.ur.y.isLessThan(b2.ll.y))
25391       return null;
25392     const lowerX = b1.ll.x.isLessThan(b2.ll.x) ? b2.ll.x : b1.ll.x;
25393     const upperX = b1.ur.x.isLessThan(b2.ur.x) ? b1.ur.x : b2.ur.x;
25394     const lowerY = b1.ll.y.isLessThan(b2.ll.y) ? b2.ll.y : b1.ll.y;
25395     const upperY = b1.ur.y.isLessThan(b2.ur.y) ? b1.ur.y : b2.ur.y;
25396     return { ll: { x: lowerX, y: lowerY }, ur: { x: upperX, y: upperY } };
25397   };
25398
25399   // node_modules/polyclip-ts/dist/vector.js
25400   var crossProduct = (a2, b2) => a2.x.times(b2.y).minus(a2.y.times(b2.x));
25401   var dotProduct = (a2, b2) => a2.x.times(b2.x).plus(a2.y.times(b2.y));
25402   var length = (v2) => dotProduct(v2, v2).sqrt();
25403   var sineOfAngle = (pShared, pBase, pAngle) => {
25404     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
25405     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
25406     return crossProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
25407   };
25408   var cosineOfAngle = (pShared, pBase, pAngle) => {
25409     const vBase = { x: pBase.x.minus(pShared.x), y: pBase.y.minus(pShared.y) };
25410     const vAngle = { x: pAngle.x.minus(pShared.x), y: pAngle.y.minus(pShared.y) };
25411     return dotProduct(vAngle, vBase).div(length(vAngle)).div(length(vBase));
25412   };
25413   var horizontalIntersection = (pt2, v2, y2) => {
25414     if (v2.y.isZero())
25415       return null;
25416     return { x: pt2.x.plus(v2.x.div(v2.y).times(y2.minus(pt2.y))), y: y2 };
25417   };
25418   var verticalIntersection = (pt2, v2, x2) => {
25419     if (v2.x.isZero())
25420       return null;
25421     return { x: x2, y: pt2.y.plus(v2.y.div(v2.x).times(x2.minus(pt2.x))) };
25422   };
25423   var intersection = (pt1, v1, pt2, v2) => {
25424     if (v1.x.isZero())
25425       return verticalIntersection(pt2, v2, pt1.x);
25426     if (v2.x.isZero())
25427       return verticalIntersection(pt1, v1, pt2.x);
25428     if (v1.y.isZero())
25429       return horizontalIntersection(pt2, v2, pt1.y);
25430     if (v2.y.isZero())
25431       return horizontalIntersection(pt1, v1, pt2.y);
25432     const kross = crossProduct(v1, v2);
25433     if (kross.isZero())
25434       return null;
25435     const ve2 = { x: pt2.x.minus(pt1.x), y: pt2.y.minus(pt1.y) };
25436     const d1 = crossProduct(ve2, v1).div(kross);
25437     const d2 = crossProduct(ve2, v2).div(kross);
25438     const x12 = pt1.x.plus(d2.times(v1.x)), x2 = pt2.x.plus(d1.times(v2.x));
25439     const y12 = pt1.y.plus(d2.times(v1.y)), y2 = pt2.y.plus(d1.times(v2.y));
25440     const x3 = x12.plus(x2).div(2);
25441     const y3 = y12.plus(y2).div(2);
25442     return { x: x3, y: y3 };
25443   };
25444
25445   // node_modules/polyclip-ts/dist/sweep-event.js
25446   var SweepEvent = class _SweepEvent {
25447     // Warning: 'point' input will be modified and re-used (for performance)
25448     constructor(point2, isLeft) {
25449       __publicField(this, "point");
25450       __publicField(this, "isLeft");
25451       __publicField(this, "segment");
25452       __publicField(this, "otherSE");
25453       __publicField(this, "consumedBy");
25454       if (point2.events === void 0)
25455         point2.events = [this];
25456       else
25457         point2.events.push(this);
25458       this.point = point2;
25459       this.isLeft = isLeft;
25460     }
25461     // for ordering sweep events in the sweep event queue
25462     static compare(a2, b2) {
25463       const ptCmp = _SweepEvent.comparePoints(a2.point, b2.point);
25464       if (ptCmp !== 0)
25465         return ptCmp;
25466       if (a2.point !== b2.point)
25467         a2.link(b2);
25468       if (a2.isLeft !== b2.isLeft)
25469         return a2.isLeft ? 1 : -1;
25470       return Segment.compare(a2.segment, b2.segment);
25471     }
25472     // for ordering points in sweep line order
25473     static comparePoints(aPt, bPt) {
25474       if (aPt.x.isLessThan(bPt.x))
25475         return -1;
25476       if (aPt.x.isGreaterThan(bPt.x))
25477         return 1;
25478       if (aPt.y.isLessThan(bPt.y))
25479         return -1;
25480       if (aPt.y.isGreaterThan(bPt.y))
25481         return 1;
25482       return 0;
25483     }
25484     link(other) {
25485       if (other.point === this.point) {
25486         throw new Error("Tried to link already linked events");
25487       }
25488       const otherEvents = other.point.events;
25489       for (let i3 = 0, iMax = otherEvents.length; i3 < iMax; i3++) {
25490         const evt = otherEvents[i3];
25491         this.point.events.push(evt);
25492         evt.point = this.point;
25493       }
25494       this.checkForConsuming();
25495     }
25496     /* Do a pass over our linked events and check to see if any pair
25497      * of segments match, and should be consumed. */
25498     checkForConsuming() {
25499       const numEvents = this.point.events.length;
25500       for (let i3 = 0; i3 < numEvents; i3++) {
25501         const evt1 = this.point.events[i3];
25502         if (evt1.segment.consumedBy !== void 0)
25503           continue;
25504         for (let j2 = i3 + 1; j2 < numEvents; j2++) {
25505           const evt2 = this.point.events[j2];
25506           if (evt2.consumedBy !== void 0)
25507             continue;
25508           if (evt1.otherSE.point.events !== evt2.otherSE.point.events)
25509             continue;
25510           evt1.segment.consume(evt2.segment);
25511         }
25512       }
25513     }
25514     getAvailableLinkedEvents() {
25515       const events = [];
25516       for (let i3 = 0, iMax = this.point.events.length; i3 < iMax; i3++) {
25517         const evt = this.point.events[i3];
25518         if (evt !== this && !evt.segment.ringOut && evt.segment.isInResult()) {
25519           events.push(evt);
25520         }
25521       }
25522       return events;
25523     }
25524     /**
25525      * Returns a comparator function for sorting linked events that will
25526      * favor the event that will give us the smallest left-side angle.
25527      * All ring construction starts as low as possible heading to the right,
25528      * so by always turning left as sharp as possible we'll get polygons
25529      * without uncessary loops & holes.
25530      *
25531      * The comparator function has a compute cache such that it avoids
25532      * re-computing already-computed values.
25533      */
25534     getLeftmostComparator(baseEvent) {
25535       const cache = /* @__PURE__ */ new Map();
25536       const fillCache = (linkedEvent) => {
25537         const nextEvent = linkedEvent.otherSE;
25538         cache.set(linkedEvent, {
25539           sine: sineOfAngle(this.point, baseEvent.point, nextEvent.point),
25540           cosine: cosineOfAngle(this.point, baseEvent.point, nextEvent.point)
25541         });
25542       };
25543       return (a2, b2) => {
25544         if (!cache.has(a2))
25545           fillCache(a2);
25546         if (!cache.has(b2))
25547           fillCache(b2);
25548         const { sine: asine, cosine: acosine } = cache.get(a2);
25549         const { sine: bsine, cosine: bcosine } = cache.get(b2);
25550         if (asine.isGreaterThanOrEqualTo(0) && bsine.isGreaterThanOrEqualTo(0)) {
25551           if (acosine.isLessThan(bcosine))
25552             return 1;
25553           if (acosine.isGreaterThan(bcosine))
25554             return -1;
25555           return 0;
25556         }
25557         if (asine.isLessThan(0) && bsine.isLessThan(0)) {
25558           if (acosine.isLessThan(bcosine))
25559             return -1;
25560           if (acosine.isGreaterThan(bcosine))
25561             return 1;
25562           return 0;
25563         }
25564         if (bsine.isLessThan(asine))
25565           return -1;
25566         if (bsine.isGreaterThan(asine))
25567           return 1;
25568         return 0;
25569       };
25570     }
25571   };
25572
25573   // node_modules/polyclip-ts/dist/segment.js
25574   var segmentId = 0;
25575   var Segment = class _Segment {
25576     /* Warning: a reference to ringWindings input will be stored,
25577      *  and possibly will be later modified */
25578     constructor(leftSE, rightSE, rings, windings) {
25579       __publicField(this, "id");
25580       __publicField(this, "leftSE");
25581       __publicField(this, "rightSE");
25582       __publicField(this, "rings");
25583       __publicField(this, "windings");
25584       __publicField(this, "ringOut");
25585       __publicField(this, "consumedBy");
25586       __publicField(this, "prev");
25587       __publicField(this, "_prevInResult");
25588       __publicField(this, "_beforeState");
25589       __publicField(this, "_afterState");
25590       __publicField(this, "_isInResult");
25591       this.id = ++segmentId;
25592       this.leftSE = leftSE;
25593       leftSE.segment = this;
25594       leftSE.otherSE = rightSE;
25595       this.rightSE = rightSE;
25596       rightSE.segment = this;
25597       rightSE.otherSE = leftSE;
25598       this.rings = rings;
25599       this.windings = windings;
25600     }
25601     /* This compare() function is for ordering segments in the sweep
25602      * line tree, and does so according to the following criteria:
25603      *
25604      * Consider the vertical line that lies an infinestimal step to the
25605      * right of the right-more of the two left endpoints of the input
25606      * segments. Imagine slowly moving a point up from negative infinity
25607      * in the increasing y direction. Which of the two segments will that
25608      * point intersect first? That segment comes 'before' the other one.
25609      *
25610      * If neither segment would be intersected by such a line, (if one
25611      * or more of the segments are vertical) then the line to be considered
25612      * is directly on the right-more of the two left inputs.
25613      */
25614     static compare(a2, b2) {
25615       const alx = a2.leftSE.point.x;
25616       const blx = b2.leftSE.point.x;
25617       const arx = a2.rightSE.point.x;
25618       const brx = b2.rightSE.point.x;
25619       if (brx.isLessThan(alx))
25620         return 1;
25621       if (arx.isLessThan(blx))
25622         return -1;
25623       const aly = a2.leftSE.point.y;
25624       const bly = b2.leftSE.point.y;
25625       const ary = a2.rightSE.point.y;
25626       const bry = b2.rightSE.point.y;
25627       if (alx.isLessThan(blx)) {
25628         if (bly.isLessThan(aly) && bly.isLessThan(ary))
25629           return 1;
25630         if (bly.isGreaterThan(aly) && bly.isGreaterThan(ary))
25631           return -1;
25632         const aCmpBLeft = a2.comparePoint(b2.leftSE.point);
25633         if (aCmpBLeft < 0)
25634           return 1;
25635         if (aCmpBLeft > 0)
25636           return -1;
25637         const bCmpARight = b2.comparePoint(a2.rightSE.point);
25638         if (bCmpARight !== 0)
25639           return bCmpARight;
25640         return -1;
25641       }
25642       if (alx.isGreaterThan(blx)) {
25643         if (aly.isLessThan(bly) && aly.isLessThan(bry))
25644           return -1;
25645         if (aly.isGreaterThan(bly) && aly.isGreaterThan(bry))
25646           return 1;
25647         const bCmpALeft = b2.comparePoint(a2.leftSE.point);
25648         if (bCmpALeft !== 0)
25649           return bCmpALeft;
25650         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
25651         if (aCmpBRight < 0)
25652           return 1;
25653         if (aCmpBRight > 0)
25654           return -1;
25655         return 1;
25656       }
25657       if (aly.isLessThan(bly))
25658         return -1;
25659       if (aly.isGreaterThan(bly))
25660         return 1;
25661       if (arx.isLessThan(brx)) {
25662         const bCmpARight = b2.comparePoint(a2.rightSE.point);
25663         if (bCmpARight !== 0)
25664           return bCmpARight;
25665       }
25666       if (arx.isGreaterThan(brx)) {
25667         const aCmpBRight = a2.comparePoint(b2.rightSE.point);
25668         if (aCmpBRight < 0)
25669           return 1;
25670         if (aCmpBRight > 0)
25671           return -1;
25672       }
25673       if (!arx.eq(brx)) {
25674         const ay = ary.minus(aly);
25675         const ax = arx.minus(alx);
25676         const by = bry.minus(bly);
25677         const bx = brx.minus(blx);
25678         if (ay.isGreaterThan(ax) && by.isLessThan(bx))
25679           return 1;
25680         if (ay.isLessThan(ax) && by.isGreaterThan(bx))
25681           return -1;
25682       }
25683       if (arx.isGreaterThan(brx))
25684         return 1;
25685       if (arx.isLessThan(brx))
25686         return -1;
25687       if (ary.isLessThan(bry))
25688         return -1;
25689       if (ary.isGreaterThan(bry))
25690         return 1;
25691       if (a2.id < b2.id)
25692         return -1;
25693       if (a2.id > b2.id)
25694         return 1;
25695       return 0;
25696     }
25697     static fromRing(pt1, pt2, ring) {
25698       let leftPt, rightPt, winding;
25699       const cmpPts = SweepEvent.comparePoints(pt1, pt2);
25700       if (cmpPts < 0) {
25701         leftPt = pt1;
25702         rightPt = pt2;
25703         winding = 1;
25704       } else if (cmpPts > 0) {
25705         leftPt = pt2;
25706         rightPt = pt1;
25707         winding = -1;
25708       } else
25709         throw new Error("Tried to create degenerate segment at [".concat(pt1.x, ", ").concat(pt1.y, "]"));
25710       const leftSE = new SweepEvent(leftPt, true);
25711       const rightSE = new SweepEvent(rightPt, false);
25712       return new _Segment(leftSE, rightSE, [ring], [winding]);
25713     }
25714     /* When a segment is split, the rightSE is replaced with a new sweep event */
25715     replaceRightSE(newRightSE) {
25716       this.rightSE = newRightSE;
25717       this.rightSE.segment = this;
25718       this.rightSE.otherSE = this.leftSE;
25719       this.leftSE.otherSE = this.rightSE;
25720     }
25721     bbox() {
25722       const y12 = this.leftSE.point.y;
25723       const y2 = this.rightSE.point.y;
25724       return {
25725         ll: { x: this.leftSE.point.x, y: y12.isLessThan(y2) ? y12 : y2 },
25726         ur: { x: this.rightSE.point.x, y: y12.isGreaterThan(y2) ? y12 : y2 }
25727       };
25728     }
25729     /* A vector from the left point to the right */
25730     vector() {
25731       return {
25732         x: this.rightSE.point.x.minus(this.leftSE.point.x),
25733         y: this.rightSE.point.y.minus(this.leftSE.point.y)
25734       };
25735     }
25736     isAnEndpoint(pt2) {
25737       return pt2.x.eq(this.leftSE.point.x) && pt2.y.eq(this.leftSE.point.y) || pt2.x.eq(this.rightSE.point.x) && pt2.y.eq(this.rightSE.point.y);
25738     }
25739     /* Compare this segment with a point.
25740      *
25741      * A point P is considered to be colinear to a segment if there
25742      * exists a distance D such that if we travel along the segment
25743      * from one * endpoint towards the other a distance D, we find
25744      * ourselves at point P.
25745      *
25746      * Return value indicates:
25747      *
25748      *   1: point lies above the segment (to the left of vertical)
25749      *   0: point is colinear to segment
25750      *  -1: point lies below the segment (to the right of vertical)
25751      */
25752     comparePoint(point2) {
25753       return precision.orient(this.leftSE.point, point2, this.rightSE.point);
25754     }
25755     /**
25756      * Given another segment, returns the first non-trivial intersection
25757      * between the two segments (in terms of sweep line ordering), if it exists.
25758      *
25759      * A 'non-trivial' intersection is one that will cause one or both of the
25760      * segments to be split(). As such, 'trivial' vs. 'non-trivial' intersection:
25761      *
25762      *   * endpoint of segA with endpoint of segB --> trivial
25763      *   * endpoint of segA with point along segB --> non-trivial
25764      *   * endpoint of segB with point along segA --> non-trivial
25765      *   * point along segA with point along segB --> non-trivial
25766      *
25767      * If no non-trivial intersection exists, return null
25768      * Else, return null.
25769      */
25770     getIntersection(other) {
25771       const tBbox = this.bbox();
25772       const oBbox = other.bbox();
25773       const bboxOverlap = getBboxOverlap(tBbox, oBbox);
25774       if (bboxOverlap === null)
25775         return null;
25776       const tlp = this.leftSE.point;
25777       const trp = this.rightSE.point;
25778       const olp = other.leftSE.point;
25779       const orp = other.rightSE.point;
25780       const touchesOtherLSE = isInBbox(tBbox, olp) && this.comparePoint(olp) === 0;
25781       const touchesThisLSE = isInBbox(oBbox, tlp) && other.comparePoint(tlp) === 0;
25782       const touchesOtherRSE = isInBbox(tBbox, orp) && this.comparePoint(orp) === 0;
25783       const touchesThisRSE = isInBbox(oBbox, trp) && other.comparePoint(trp) === 0;
25784       if (touchesThisLSE && touchesOtherLSE) {
25785         if (touchesThisRSE && !touchesOtherRSE)
25786           return trp;
25787         if (!touchesThisRSE && touchesOtherRSE)
25788           return orp;
25789         return null;
25790       }
25791       if (touchesThisLSE) {
25792         if (touchesOtherRSE) {
25793           if (tlp.x.eq(orp.x) && tlp.y.eq(orp.y))
25794             return null;
25795         }
25796         return tlp;
25797       }
25798       if (touchesOtherLSE) {
25799         if (touchesThisRSE) {
25800           if (trp.x.eq(olp.x) && trp.y.eq(olp.y))
25801             return null;
25802         }
25803         return olp;
25804       }
25805       if (touchesThisRSE && touchesOtherRSE)
25806         return null;
25807       if (touchesThisRSE)
25808         return trp;
25809       if (touchesOtherRSE)
25810         return orp;
25811       const pt2 = intersection(tlp, this.vector(), olp, other.vector());
25812       if (pt2 === null)
25813         return null;
25814       if (!isInBbox(bboxOverlap, pt2))
25815         return null;
25816       return precision.snap(pt2);
25817     }
25818     /**
25819      * Split the given segment into multiple segments on the given points.
25820      *  * Each existing segment will retain its leftSE and a new rightSE will be
25821      *    generated for it.
25822      *  * A new segment will be generated which will adopt the original segment's
25823      *    rightSE, and a new leftSE will be generated for it.
25824      *  * If there are more than two points given to split on, new segments
25825      *    in the middle will be generated with new leftSE and rightSE's.
25826      *  * An array of the newly generated SweepEvents will be returned.
25827      *
25828      * Warning: input array of points is modified
25829      */
25830     split(point2) {
25831       const newEvents = [];
25832       const alreadyLinked = point2.events !== void 0;
25833       const newLeftSE = new SweepEvent(point2, true);
25834       const newRightSE = new SweepEvent(point2, false);
25835       const oldRightSE = this.rightSE;
25836       this.replaceRightSE(newRightSE);
25837       newEvents.push(newRightSE);
25838       newEvents.push(newLeftSE);
25839       const newSeg = new _Segment(newLeftSE, oldRightSE, this.rings.slice(), this.windings.slice());
25840       if (SweepEvent.comparePoints(newSeg.leftSE.point, newSeg.rightSE.point) > 0) {
25841         newSeg.swapEvents();
25842       }
25843       if (SweepEvent.comparePoints(this.leftSE.point, this.rightSE.point) > 0) {
25844         this.swapEvents();
25845       }
25846       if (alreadyLinked) {
25847         newLeftSE.checkForConsuming();
25848         newRightSE.checkForConsuming();
25849       }
25850       return newEvents;
25851     }
25852     /* Swap which event is left and right */
25853     swapEvents() {
25854       const tmpEvt = this.rightSE;
25855       this.rightSE = this.leftSE;
25856       this.leftSE = tmpEvt;
25857       this.leftSE.isLeft = true;
25858       this.rightSE.isLeft = false;
25859       for (let i3 = 0, iMax = this.windings.length; i3 < iMax; i3++) {
25860         this.windings[i3] *= -1;
25861       }
25862     }
25863     /* Consume another segment. We take their rings under our wing
25864      * and mark them as consumed. Use for perfectly overlapping segments */
25865     consume(other) {
25866       let consumer = this;
25867       let consumee = other;
25868       while (consumer.consumedBy)
25869         consumer = consumer.consumedBy;
25870       while (consumee.consumedBy)
25871         consumee = consumee.consumedBy;
25872       const cmp = _Segment.compare(consumer, consumee);
25873       if (cmp === 0)
25874         return;
25875       if (cmp > 0) {
25876         const tmp = consumer;
25877         consumer = consumee;
25878         consumee = tmp;
25879       }
25880       if (consumer.prev === consumee) {
25881         const tmp = consumer;
25882         consumer = consumee;
25883         consumee = tmp;
25884       }
25885       for (let i3 = 0, iMax = consumee.rings.length; i3 < iMax; i3++) {
25886         const ring = consumee.rings[i3];
25887         const winding = consumee.windings[i3];
25888         const index = consumer.rings.indexOf(ring);
25889         if (index === -1) {
25890           consumer.rings.push(ring);
25891           consumer.windings.push(winding);
25892         } else
25893           consumer.windings[index] += winding;
25894       }
25895       consumee.rings = null;
25896       consumee.windings = null;
25897       consumee.consumedBy = consumer;
25898       consumee.leftSE.consumedBy = consumer.leftSE;
25899       consumee.rightSE.consumedBy = consumer.rightSE;
25900     }
25901     /* The first segment previous segment chain that is in the result */
25902     prevInResult() {
25903       if (this._prevInResult !== void 0)
25904         return this._prevInResult;
25905       if (!this.prev)
25906         this._prevInResult = null;
25907       else if (this.prev.isInResult())
25908         this._prevInResult = this.prev;
25909       else
25910         this._prevInResult = this.prev.prevInResult();
25911       return this._prevInResult;
25912     }
25913     beforeState() {
25914       if (this._beforeState !== void 0)
25915         return this._beforeState;
25916       if (!this.prev)
25917         this._beforeState = {
25918           rings: [],
25919           windings: [],
25920           multiPolys: []
25921         };
25922       else {
25923         const seg = this.prev.consumedBy || this.prev;
25924         this._beforeState = seg.afterState();
25925       }
25926       return this._beforeState;
25927     }
25928     afterState() {
25929       if (this._afterState !== void 0)
25930         return this._afterState;
25931       const beforeState = this.beforeState();
25932       this._afterState = {
25933         rings: beforeState.rings.slice(0),
25934         windings: beforeState.windings.slice(0),
25935         multiPolys: []
25936       };
25937       const ringsAfter = this._afterState.rings;
25938       const windingsAfter = this._afterState.windings;
25939       const mpsAfter = this._afterState.multiPolys;
25940       for (let i3 = 0, iMax = this.rings.length; i3 < iMax; i3++) {
25941         const ring = this.rings[i3];
25942         const winding = this.windings[i3];
25943         const index = ringsAfter.indexOf(ring);
25944         if (index === -1) {
25945           ringsAfter.push(ring);
25946           windingsAfter.push(winding);
25947         } else
25948           windingsAfter[index] += winding;
25949       }
25950       const polysAfter = [];
25951       const polysExclude = [];
25952       for (let i3 = 0, iMax = ringsAfter.length; i3 < iMax; i3++) {
25953         if (windingsAfter[i3] === 0)
25954           continue;
25955         const ring = ringsAfter[i3];
25956         const poly = ring.poly;
25957         if (polysExclude.indexOf(poly) !== -1)
25958           continue;
25959         if (ring.isExterior)
25960           polysAfter.push(poly);
25961         else {
25962           if (polysExclude.indexOf(poly) === -1)
25963             polysExclude.push(poly);
25964           const index = polysAfter.indexOf(ring.poly);
25965           if (index !== -1)
25966             polysAfter.splice(index, 1);
25967         }
25968       }
25969       for (let i3 = 0, iMax = polysAfter.length; i3 < iMax; i3++) {
25970         const mp = polysAfter[i3].multiPoly;
25971         if (mpsAfter.indexOf(mp) === -1)
25972           mpsAfter.push(mp);
25973       }
25974       return this._afterState;
25975     }
25976     /* Is this segment part of the final result? */
25977     isInResult() {
25978       if (this.consumedBy)
25979         return false;
25980       if (this._isInResult !== void 0)
25981         return this._isInResult;
25982       const mpsBefore = this.beforeState().multiPolys;
25983       const mpsAfter = this.afterState().multiPolys;
25984       switch (operation_default.type) {
25985         case "union": {
25986           const noBefores = mpsBefore.length === 0;
25987           const noAfters = mpsAfter.length === 0;
25988           this._isInResult = noBefores !== noAfters;
25989           break;
25990         }
25991         case "intersection": {
25992           let least;
25993           let most;
25994           if (mpsBefore.length < mpsAfter.length) {
25995             least = mpsBefore.length;
25996             most = mpsAfter.length;
25997           } else {
25998             least = mpsAfter.length;
25999             most = mpsBefore.length;
26000           }
26001           this._isInResult = most === operation_default.numMultiPolys && least < most;
26002           break;
26003         }
26004         case "xor": {
26005           const diff = Math.abs(mpsBefore.length - mpsAfter.length);
26006           this._isInResult = diff % 2 === 1;
26007           break;
26008         }
26009         case "difference": {
26010           const isJustSubject = (mps) => mps.length === 1 && mps[0].isSubject;
26011           this._isInResult = isJustSubject(mpsBefore) !== isJustSubject(mpsAfter);
26012           break;
26013         }
26014       }
26015       return this._isInResult;
26016     }
26017   };
26018
26019   // node_modules/polyclip-ts/dist/geom-in.js
26020   var RingIn = class {
26021     constructor(geomRing, poly, isExterior) {
26022       __publicField(this, "poly");
26023       __publicField(this, "isExterior");
26024       __publicField(this, "segments");
26025       __publicField(this, "bbox");
26026       if (!Array.isArray(geomRing) || geomRing.length === 0) {
26027         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26028       }
26029       this.poly = poly;
26030       this.isExterior = isExterior;
26031       this.segments = [];
26032       if (typeof geomRing[0][0] !== "number" || typeof geomRing[0][1] !== "number") {
26033         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26034       }
26035       const firstPoint = precision.snap({ x: new bignumber_default(geomRing[0][0]), y: new bignumber_default(geomRing[0][1]) });
26036       this.bbox = {
26037         ll: { x: firstPoint.x, y: firstPoint.y },
26038         ur: { x: firstPoint.x, y: firstPoint.y }
26039       };
26040       let prevPoint = firstPoint;
26041       for (let i3 = 1, iMax = geomRing.length; i3 < iMax; i3++) {
26042         if (typeof geomRing[i3][0] !== "number" || typeof geomRing[i3][1] !== "number") {
26043           throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26044         }
26045         const point2 = precision.snap({ x: new bignumber_default(geomRing[i3][0]), y: new bignumber_default(geomRing[i3][1]) });
26046         if (point2.x.eq(prevPoint.x) && point2.y.eq(prevPoint.y))
26047           continue;
26048         this.segments.push(Segment.fromRing(prevPoint, point2, this));
26049         if (point2.x.isLessThan(this.bbox.ll.x))
26050           this.bbox.ll.x = point2.x;
26051         if (point2.y.isLessThan(this.bbox.ll.y))
26052           this.bbox.ll.y = point2.y;
26053         if (point2.x.isGreaterThan(this.bbox.ur.x))
26054           this.bbox.ur.x = point2.x;
26055         if (point2.y.isGreaterThan(this.bbox.ur.y))
26056           this.bbox.ur.y = point2.y;
26057         prevPoint = point2;
26058       }
26059       if (!firstPoint.x.eq(prevPoint.x) || !firstPoint.y.eq(prevPoint.y)) {
26060         this.segments.push(Segment.fromRing(prevPoint, firstPoint, this));
26061       }
26062     }
26063     getSweepEvents() {
26064       const sweepEvents = [];
26065       for (let i3 = 0, iMax = this.segments.length; i3 < iMax; i3++) {
26066         const segment = this.segments[i3];
26067         sweepEvents.push(segment.leftSE);
26068         sweepEvents.push(segment.rightSE);
26069       }
26070       return sweepEvents;
26071     }
26072   };
26073   var PolyIn = class {
26074     constructor(geomPoly, multiPoly) {
26075       __publicField(this, "multiPoly");
26076       __publicField(this, "exteriorRing");
26077       __publicField(this, "interiorRings");
26078       __publicField(this, "bbox");
26079       if (!Array.isArray(geomPoly)) {
26080         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26081       }
26082       this.exteriorRing = new RingIn(geomPoly[0], this, true);
26083       this.bbox = {
26084         ll: { x: this.exteriorRing.bbox.ll.x, y: this.exteriorRing.bbox.ll.y },
26085         ur: { x: this.exteriorRing.bbox.ur.x, y: this.exteriorRing.bbox.ur.y }
26086       };
26087       this.interiorRings = [];
26088       for (let i3 = 1, iMax = geomPoly.length; i3 < iMax; i3++) {
26089         const ring = new RingIn(geomPoly[i3], this, false);
26090         if (ring.bbox.ll.x.isLessThan(this.bbox.ll.x))
26091           this.bbox.ll.x = ring.bbox.ll.x;
26092         if (ring.bbox.ll.y.isLessThan(this.bbox.ll.y))
26093           this.bbox.ll.y = ring.bbox.ll.y;
26094         if (ring.bbox.ur.x.isGreaterThan(this.bbox.ur.x))
26095           this.bbox.ur.x = ring.bbox.ur.x;
26096         if (ring.bbox.ur.y.isGreaterThan(this.bbox.ur.y))
26097           this.bbox.ur.y = ring.bbox.ur.y;
26098         this.interiorRings.push(ring);
26099       }
26100       this.multiPoly = multiPoly;
26101     }
26102     getSweepEvents() {
26103       const sweepEvents = this.exteriorRing.getSweepEvents();
26104       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
26105         const ringSweepEvents = this.interiorRings[i3].getSweepEvents();
26106         for (let j2 = 0, jMax = ringSweepEvents.length; j2 < jMax; j2++) {
26107           sweepEvents.push(ringSweepEvents[j2]);
26108         }
26109       }
26110       return sweepEvents;
26111     }
26112   };
26113   var MultiPolyIn = class {
26114     constructor(geom, isSubject) {
26115       __publicField(this, "isSubject");
26116       __publicField(this, "polys");
26117       __publicField(this, "bbox");
26118       if (!Array.isArray(geom)) {
26119         throw new Error("Input geometry is not a valid Polygon or MultiPolygon");
26120       }
26121       try {
26122         if (typeof geom[0][0][0] === "number")
26123           geom = [geom];
26124       } catch (ex) {
26125       }
26126       this.polys = [];
26127       this.bbox = {
26128         ll: { x: new bignumber_default(Number.POSITIVE_INFINITY), y: new bignumber_default(Number.POSITIVE_INFINITY) },
26129         ur: { x: new bignumber_default(Number.NEGATIVE_INFINITY), y: new bignumber_default(Number.NEGATIVE_INFINITY) }
26130       };
26131       for (let i3 = 0, iMax = geom.length; i3 < iMax; i3++) {
26132         const poly = new PolyIn(geom[i3], this);
26133         if (poly.bbox.ll.x.isLessThan(this.bbox.ll.x))
26134           this.bbox.ll.x = poly.bbox.ll.x;
26135         if (poly.bbox.ll.y.isLessThan(this.bbox.ll.y))
26136           this.bbox.ll.y = poly.bbox.ll.y;
26137         if (poly.bbox.ur.x.isGreaterThan(this.bbox.ur.x))
26138           this.bbox.ur.x = poly.bbox.ur.x;
26139         if (poly.bbox.ur.y.isGreaterThan(this.bbox.ur.y))
26140           this.bbox.ur.y = poly.bbox.ur.y;
26141         this.polys.push(poly);
26142       }
26143       this.isSubject = isSubject;
26144     }
26145     getSweepEvents() {
26146       const sweepEvents = [];
26147       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
26148         const polySweepEvents = this.polys[i3].getSweepEvents();
26149         for (let j2 = 0, jMax = polySweepEvents.length; j2 < jMax; j2++) {
26150           sweepEvents.push(polySweepEvents[j2]);
26151         }
26152       }
26153       return sweepEvents;
26154     }
26155   };
26156
26157   // node_modules/polyclip-ts/dist/geom-out.js
26158   var RingOut = class _RingOut {
26159     constructor(events) {
26160       __publicField(this, "events");
26161       __publicField(this, "poly");
26162       __publicField(this, "_isExteriorRing");
26163       __publicField(this, "_enclosingRing");
26164       this.events = events;
26165       for (let i3 = 0, iMax = events.length; i3 < iMax; i3++) {
26166         events[i3].segment.ringOut = this;
26167       }
26168       this.poly = null;
26169     }
26170     /* Given the segments from the sweep line pass, compute & return a series
26171      * of closed rings from all the segments marked to be part of the result */
26172     static factory(allSegments) {
26173       const ringsOut = [];
26174       for (let i3 = 0, iMax = allSegments.length; i3 < iMax; i3++) {
26175         const segment = allSegments[i3];
26176         if (!segment.isInResult() || segment.ringOut)
26177           continue;
26178         let prevEvent = null;
26179         let event = segment.leftSE;
26180         let nextEvent = segment.rightSE;
26181         const events = [event];
26182         const startingPoint = event.point;
26183         const intersectionLEs = [];
26184         while (true) {
26185           prevEvent = event;
26186           event = nextEvent;
26187           events.push(event);
26188           if (event.point === startingPoint)
26189             break;
26190           while (true) {
26191             const availableLEs = event.getAvailableLinkedEvents();
26192             if (availableLEs.length === 0) {
26193               const firstPt = events[0].point;
26194               const lastPt = events[events.length - 1].point;
26195               throw new Error("Unable to complete output ring starting at [".concat(firstPt.x, ",") + " ".concat(firstPt.y, "]. Last matching segment found ends at") + " [".concat(lastPt.x, ", ").concat(lastPt.y, "]."));
26196             }
26197             if (availableLEs.length === 1) {
26198               nextEvent = availableLEs[0].otherSE;
26199               break;
26200             }
26201             let indexLE = null;
26202             for (let j2 = 0, jMax = intersectionLEs.length; j2 < jMax; j2++) {
26203               if (intersectionLEs[j2].point === event.point) {
26204                 indexLE = j2;
26205                 break;
26206               }
26207             }
26208             if (indexLE !== null) {
26209               const intersectionLE = intersectionLEs.splice(indexLE)[0];
26210               const ringEvents = events.splice(intersectionLE.index);
26211               ringEvents.unshift(ringEvents[0].otherSE);
26212               ringsOut.push(new _RingOut(ringEvents.reverse()));
26213               continue;
26214             }
26215             intersectionLEs.push({
26216               index: events.length,
26217               point: event.point
26218             });
26219             const comparator = event.getLeftmostComparator(prevEvent);
26220             nextEvent = availableLEs.sort(comparator)[0].otherSE;
26221             break;
26222           }
26223         }
26224         ringsOut.push(new _RingOut(events));
26225       }
26226       return ringsOut;
26227     }
26228     getGeom() {
26229       let prevPt = this.events[0].point;
26230       const points = [prevPt];
26231       for (let i3 = 1, iMax = this.events.length - 1; i3 < iMax; i3++) {
26232         const pt3 = this.events[i3].point;
26233         const nextPt2 = this.events[i3 + 1].point;
26234         if (precision.orient(pt3, prevPt, nextPt2) === 0)
26235           continue;
26236         points.push(pt3);
26237         prevPt = pt3;
26238       }
26239       if (points.length === 1)
26240         return null;
26241       const pt2 = points[0];
26242       const nextPt = points[1];
26243       if (precision.orient(pt2, prevPt, nextPt) === 0)
26244         points.shift();
26245       points.push(points[0]);
26246       const step = this.isExteriorRing() ? 1 : -1;
26247       const iStart = this.isExteriorRing() ? 0 : points.length - 1;
26248       const iEnd = this.isExteriorRing() ? points.length : -1;
26249       const orderedPoints = [];
26250       for (let i3 = iStart; i3 != iEnd; i3 += step)
26251         orderedPoints.push([points[i3].x.toNumber(), points[i3].y.toNumber()]);
26252       return orderedPoints;
26253     }
26254     isExteriorRing() {
26255       if (this._isExteriorRing === void 0) {
26256         const enclosing = this.enclosingRing();
26257         this._isExteriorRing = enclosing ? !enclosing.isExteriorRing() : true;
26258       }
26259       return this._isExteriorRing;
26260     }
26261     enclosingRing() {
26262       if (this._enclosingRing === void 0) {
26263         this._enclosingRing = this._calcEnclosingRing();
26264       }
26265       return this._enclosingRing;
26266     }
26267     /* Returns the ring that encloses this one, if any */
26268     _calcEnclosingRing() {
26269       var _a2, _b;
26270       let leftMostEvt = this.events[0];
26271       for (let i3 = 1, iMax = this.events.length; i3 < iMax; i3++) {
26272         const evt = this.events[i3];
26273         if (SweepEvent.compare(leftMostEvt, evt) > 0)
26274           leftMostEvt = evt;
26275       }
26276       let prevSeg = leftMostEvt.segment.prevInResult();
26277       let prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
26278       while (true) {
26279         if (!prevSeg)
26280           return null;
26281         if (!prevPrevSeg)
26282           return prevSeg.ringOut;
26283         if (prevPrevSeg.ringOut !== prevSeg.ringOut) {
26284           if (((_a2 = prevPrevSeg.ringOut) == null ? void 0 : _a2.enclosingRing()) !== prevSeg.ringOut) {
26285             return prevSeg.ringOut;
26286           } else
26287             return (_b = prevSeg.ringOut) == null ? void 0 : _b.enclosingRing();
26288         }
26289         prevSeg = prevPrevSeg.prevInResult();
26290         prevPrevSeg = prevSeg ? prevSeg.prevInResult() : null;
26291       }
26292     }
26293   };
26294   var PolyOut = class {
26295     constructor(exteriorRing) {
26296       __publicField(this, "exteriorRing");
26297       __publicField(this, "interiorRings");
26298       this.exteriorRing = exteriorRing;
26299       exteriorRing.poly = this;
26300       this.interiorRings = [];
26301     }
26302     addInterior(ring) {
26303       this.interiorRings.push(ring);
26304       ring.poly = this;
26305     }
26306     getGeom() {
26307       const geom = [this.exteriorRing.getGeom()];
26308       if (geom[0] === null)
26309         return null;
26310       for (let i3 = 0, iMax = this.interiorRings.length; i3 < iMax; i3++) {
26311         const ringGeom = this.interiorRings[i3].getGeom();
26312         if (ringGeom === null)
26313           continue;
26314         geom.push(ringGeom);
26315       }
26316       return geom;
26317     }
26318   };
26319   var MultiPolyOut = class {
26320     constructor(rings) {
26321       __publicField(this, "rings");
26322       __publicField(this, "polys");
26323       this.rings = rings;
26324       this.polys = this._composePolys(rings);
26325     }
26326     getGeom() {
26327       const geom = [];
26328       for (let i3 = 0, iMax = this.polys.length; i3 < iMax; i3++) {
26329         const polyGeom = this.polys[i3].getGeom();
26330         if (polyGeom === null)
26331           continue;
26332         geom.push(polyGeom);
26333       }
26334       return geom;
26335     }
26336     _composePolys(rings) {
26337       var _a2;
26338       const polys = [];
26339       for (let i3 = 0, iMax = rings.length; i3 < iMax; i3++) {
26340         const ring = rings[i3];
26341         if (ring.poly)
26342           continue;
26343         if (ring.isExteriorRing())
26344           polys.push(new PolyOut(ring));
26345         else {
26346           const enclosingRing = ring.enclosingRing();
26347           if (!(enclosingRing == null ? void 0 : enclosingRing.poly))
26348             polys.push(new PolyOut(enclosingRing));
26349           (_a2 = enclosingRing == null ? void 0 : enclosingRing.poly) == null ? void 0 : _a2.addInterior(ring);
26350         }
26351       }
26352       return polys;
26353     }
26354   };
26355
26356   // node_modules/polyclip-ts/dist/sweep-line.js
26357   var SweepLine = class {
26358     constructor(queue, comparator = Segment.compare) {
26359       __publicField(this, "queue");
26360       __publicField(this, "tree");
26361       __publicField(this, "segments");
26362       this.queue = queue;
26363       this.tree = new SplayTreeSet(comparator);
26364       this.segments = [];
26365     }
26366     process(event) {
26367       const segment = event.segment;
26368       const newEvents = [];
26369       if (event.consumedBy) {
26370         if (event.isLeft)
26371           this.queue.delete(event.otherSE);
26372         else
26373           this.tree.delete(segment);
26374         return newEvents;
26375       }
26376       if (event.isLeft)
26377         this.tree.add(segment);
26378       let prevSeg = segment;
26379       let nextSeg = segment;
26380       do {
26381         prevSeg = this.tree.lastBefore(prevSeg);
26382       } while (prevSeg != null && prevSeg.consumedBy != void 0);
26383       do {
26384         nextSeg = this.tree.firstAfter(nextSeg);
26385       } while (nextSeg != null && nextSeg.consumedBy != void 0);
26386       if (event.isLeft) {
26387         let prevMySplitter = null;
26388         if (prevSeg) {
26389           const prevInter = prevSeg.getIntersection(segment);
26390           if (prevInter !== null) {
26391             if (!segment.isAnEndpoint(prevInter))
26392               prevMySplitter = prevInter;
26393             if (!prevSeg.isAnEndpoint(prevInter)) {
26394               const newEventsFromSplit = this._splitSafely(prevSeg, prevInter);
26395               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26396                 newEvents.push(newEventsFromSplit[i3]);
26397               }
26398             }
26399           }
26400         }
26401         let nextMySplitter = null;
26402         if (nextSeg) {
26403           const nextInter = nextSeg.getIntersection(segment);
26404           if (nextInter !== null) {
26405             if (!segment.isAnEndpoint(nextInter))
26406               nextMySplitter = nextInter;
26407             if (!nextSeg.isAnEndpoint(nextInter)) {
26408               const newEventsFromSplit = this._splitSafely(nextSeg, nextInter);
26409               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26410                 newEvents.push(newEventsFromSplit[i3]);
26411               }
26412             }
26413           }
26414         }
26415         if (prevMySplitter !== null || nextMySplitter !== null) {
26416           let mySplitter = null;
26417           if (prevMySplitter === null)
26418             mySplitter = nextMySplitter;
26419           else if (nextMySplitter === null)
26420             mySplitter = prevMySplitter;
26421           else {
26422             const cmpSplitters = SweepEvent.comparePoints(prevMySplitter, nextMySplitter);
26423             mySplitter = cmpSplitters <= 0 ? prevMySplitter : nextMySplitter;
26424           }
26425           this.queue.delete(segment.rightSE);
26426           newEvents.push(segment.rightSE);
26427           const newEventsFromSplit = segment.split(mySplitter);
26428           for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26429             newEvents.push(newEventsFromSplit[i3]);
26430           }
26431         }
26432         if (newEvents.length > 0) {
26433           this.tree.delete(segment);
26434           newEvents.push(event);
26435         } else {
26436           this.segments.push(segment);
26437           segment.prev = prevSeg;
26438         }
26439       } else {
26440         if (prevSeg && nextSeg) {
26441           const inter = prevSeg.getIntersection(nextSeg);
26442           if (inter !== null) {
26443             if (!prevSeg.isAnEndpoint(inter)) {
26444               const newEventsFromSplit = this._splitSafely(prevSeg, inter);
26445               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26446                 newEvents.push(newEventsFromSplit[i3]);
26447               }
26448             }
26449             if (!nextSeg.isAnEndpoint(inter)) {
26450               const newEventsFromSplit = this._splitSafely(nextSeg, inter);
26451               for (let i3 = 0, iMax = newEventsFromSplit.length; i3 < iMax; i3++) {
26452                 newEvents.push(newEventsFromSplit[i3]);
26453               }
26454             }
26455           }
26456         }
26457         this.tree.delete(segment);
26458       }
26459       return newEvents;
26460     }
26461     /* Safely split a segment that is currently in the datastructures
26462      * IE - a segment other than the one that is currently being processed. */
26463     _splitSafely(seg, pt2) {
26464       this.tree.delete(seg);
26465       const rightSE = seg.rightSE;
26466       this.queue.delete(rightSE);
26467       const newEvents = seg.split(pt2);
26468       newEvents.push(rightSE);
26469       if (seg.consumedBy === void 0)
26470         this.tree.add(seg);
26471       return newEvents;
26472     }
26473   };
26474
26475   // node_modules/polyclip-ts/dist/operation.js
26476   var Operation = class {
26477     constructor() {
26478       __publicField(this, "type");
26479       __publicField(this, "numMultiPolys");
26480     }
26481     run(type2, geom, moreGeoms) {
26482       operation.type = type2;
26483       const multipolys = [new MultiPolyIn(geom, true)];
26484       for (let i3 = 0, iMax = moreGeoms.length; i3 < iMax; i3++) {
26485         multipolys.push(new MultiPolyIn(moreGeoms[i3], false));
26486       }
26487       operation.numMultiPolys = multipolys.length;
26488       if (operation.type === "difference") {
26489         const subject = multipolys[0];
26490         let i3 = 1;
26491         while (i3 < multipolys.length) {
26492           if (getBboxOverlap(multipolys[i3].bbox, subject.bbox) !== null)
26493             i3++;
26494           else
26495             multipolys.splice(i3, 1);
26496         }
26497       }
26498       if (operation.type === "intersection") {
26499         for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
26500           const mpA = multipolys[i3];
26501           for (let j2 = i3 + 1, jMax = multipolys.length; j2 < jMax; j2++) {
26502             if (getBboxOverlap(mpA.bbox, multipolys[j2].bbox) === null)
26503               return [];
26504           }
26505         }
26506       }
26507       const queue = new SplayTreeSet(SweepEvent.compare);
26508       for (let i3 = 0, iMax = multipolys.length; i3 < iMax; i3++) {
26509         const sweepEvents = multipolys[i3].getSweepEvents();
26510         for (let j2 = 0, jMax = sweepEvents.length; j2 < jMax; j2++) {
26511           queue.add(sweepEvents[j2]);
26512         }
26513       }
26514       const sweepLine = new SweepLine(queue);
26515       let evt = null;
26516       if (queue.size != 0) {
26517         evt = queue.first();
26518         queue.delete(evt);
26519       }
26520       while (evt) {
26521         const newEvents = sweepLine.process(evt);
26522         for (let i3 = 0, iMax = newEvents.length; i3 < iMax; i3++) {
26523           const evt2 = newEvents[i3];
26524           if (evt2.consumedBy === void 0)
26525             queue.add(evt2);
26526         }
26527         if (queue.size != 0) {
26528           evt = queue.first();
26529           queue.delete(evt);
26530         } else {
26531           evt = null;
26532         }
26533       }
26534       precision.reset();
26535       const ringsOut = RingOut.factory(sweepLine.segments);
26536       const result = new MultiPolyOut(ringsOut);
26537       return result.getGeom();
26538     }
26539   };
26540   var operation = new Operation();
26541   var operation_default = operation;
26542
26543   // node_modules/polyclip-ts/dist/index.js
26544   var union = (geom, ...moreGeoms) => operation_default.run("union", geom, moreGeoms);
26545   var difference = (geom, ...moreGeoms) => operation_default.run("difference", geom, moreGeoms);
26546   var setPrecision = precision.set;
26547
26548   // node_modules/@rapideditor/location-conflation/index.mjs
26549   var import_geojson_area = __toESM(require_geojson_area(), 1);
26550   var import_circle_to_polygon = __toESM(require_circle_to_polygon(), 1);
26551   var import_geojson_precision = __toESM(require_geojson_precision(), 1);
26552   var import_json_stringify_pretty_compact = __toESM(require_json_stringify_pretty_compact(), 1);
26553   var LocationConflation = class {
26554     // constructor
26555     //
26556     // `fc`  Optional FeatureCollection of known features
26557     //
26558     // Optionally pass a GeoJSON FeatureCollection of known features which we can refer to later.
26559     // Each feature must have a filename-like `id`, for example: `something.geojson`
26560     //
26561     // {
26562     //   "type": "FeatureCollection"
26563     //   "features": [
26564     //     {
26565     //       "type": "Feature",
26566     //       "id": "philly_metro.geojson",
26567     //       "properties": { … },
26568     //       "geometry": { … }
26569     //     }
26570     //   ]
26571     // }
26572     constructor(fc) {
26573       this._cache = {};
26574       this.strict = true;
26575       if (fc && fc.type === "FeatureCollection" && Array.isArray(fc.features)) {
26576         fc.features.forEach((feature3) => {
26577           feature3.properties = feature3.properties || {};
26578           let props = feature3.properties;
26579           let id2 = feature3.id || props.id;
26580           if (!id2 || !/^\S+\.geojson$/i.test(id2))
26581             return;
26582           id2 = id2.toLowerCase();
26583           feature3.id = id2;
26584           props.id = id2;
26585           if (!props.area) {
26586             const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
26587             props.area = Number(area.toFixed(2));
26588           }
26589           this._cache[id2] = feature3;
26590         });
26591       }
26592       let world = _cloneDeep(feature("Q2"));
26593       world.geometry = {
26594         type: "Polygon",
26595         coordinates: [[[-180, -90], [180, -90], [180, 90], [-180, 90], [-180, -90]]]
26596       };
26597       world.id = "Q2";
26598       world.properties.id = "Q2";
26599       world.properties.area = import_geojson_area.default.geometry(world.geometry) / 1e6;
26600       this._cache.Q2 = world;
26601     }
26602     // validateLocation
26603     // `location`  The location to validate
26604     //
26605     // Pass a `location` value to validate
26606     //
26607     // Returns a result like:
26608     //   {
26609     //     type:     'point', 'geojson', or 'countrycoder'
26610     //     location:  the queried location
26611     //     id:        the stable identifier for the feature
26612     //   }
26613     // or `null` if the location is invalid
26614     //
26615     validateLocation(location) {
26616       if (Array.isArray(location) && (location.length === 2 || location.length === 3)) {
26617         const lon = location[0];
26618         const lat = location[1];
26619         const radius = location[2];
26620         if (Number.isFinite(lon) && lon >= -180 && lon <= 180 && Number.isFinite(lat) && lat >= -90 && lat <= 90 && (location.length === 2 || Number.isFinite(radius) && radius > 0)) {
26621           const id2 = "[" + location.toString() + "]";
26622           return { type: "point", location, id: id2 };
26623         }
26624       } else if (typeof location === "string" && /^\S+\.geojson$/i.test(location)) {
26625         const id2 = location.toLowerCase();
26626         if (this._cache[id2]) {
26627           return { type: "geojson", location, id: id2 };
26628         }
26629       } else if (typeof location === "string" || typeof location === "number") {
26630         const feature3 = feature(location);
26631         if (feature3) {
26632           const id2 = feature3.properties.wikidata;
26633           return { type: "countrycoder", location, id: id2 };
26634         }
26635       }
26636       if (this.strict) {
26637         throw new Error('validateLocation:  Invalid location: "'.concat(location, '".'));
26638       } else {
26639         return null;
26640       }
26641     }
26642     // resolveLocation
26643     // `location`  The location to resolve
26644     //
26645     // Pass a `location` value to resolve
26646     //
26647     // Returns a result like:
26648     //   {
26649     //     type:      'point', 'geojson', or 'countrycoder'
26650     //     location:  the queried location
26651     //     id:        a stable identifier for the feature
26652     //     feature:   the resolved GeoJSON feature
26653     //   }
26654     //  or `null` if the location is invalid
26655     //
26656     resolveLocation(location) {
26657       const valid = this.validateLocation(location);
26658       if (!valid)
26659         return null;
26660       const id2 = valid.id;
26661       if (this._cache[id2]) {
26662         return Object.assign(valid, { feature: this._cache[id2] });
26663       }
26664       if (valid.type === "point") {
26665         const lon = location[0];
26666         const lat = location[1];
26667         const radius = location[2] || 25;
26668         const EDGES = 10;
26669         const PRECISION = 3;
26670         const area = Math.PI * radius * radius;
26671         const feature3 = this._cache[id2] = (0, import_geojson_precision.default)({
26672           type: "Feature",
26673           id: id2,
26674           properties: { id: id2, area: Number(area.toFixed(2)) },
26675           geometry: (0, import_circle_to_polygon.default)([lon, lat], radius * 1e3, EDGES)
26676           // km to m
26677         }, PRECISION);
26678         return Object.assign(valid, { feature: feature3 });
26679       } else if (valid.type === "geojson") {
26680       } else if (valid.type === "countrycoder") {
26681         let feature3 = _cloneDeep(feature(id2));
26682         let props = feature3.properties;
26683         if (Array.isArray(props.members)) {
26684           let aggregate = aggregateFeature(id2);
26685           aggregate.geometry.coordinates = _clip([aggregate], "UNION").geometry.coordinates;
26686           feature3.geometry = aggregate.geometry;
26687         }
26688         if (!props.area) {
26689           const area = import_geojson_area.default.geometry(feature3.geometry) / 1e6;
26690           props.area = Number(area.toFixed(2));
26691         }
26692         feature3.id = id2;
26693         props.id = id2;
26694         this._cache[id2] = feature3;
26695         return Object.assign(valid, { feature: feature3 });
26696       }
26697       if (this.strict) {
26698         throw new Error("resolveLocation:  Couldn't resolve location \"".concat(location, '".'));
26699       } else {
26700         return null;
26701       }
26702     }
26703     // validateLocationSet
26704     // `locationSet`  the locationSet to validate
26705     //
26706     // Pass a locationSet Object to validate like:
26707     //   {
26708     //     include: [ Array of locations ],
26709     //     exclude: [ Array of locations ]
26710     //   }
26711     //
26712     // Returns a result like:
26713     //   {
26714     //     type:         'locationset'
26715     //     locationSet:  the queried locationSet
26716     //     id:           the stable identifier for the feature
26717     //   }
26718     // or `null` if the locationSet is invalid
26719     //
26720     validateLocationSet(locationSet) {
26721       locationSet = locationSet || {};
26722       const validator = this.validateLocation.bind(this);
26723       let include = (locationSet.include || []).map(validator).filter(Boolean);
26724       let exclude = (locationSet.exclude || []).map(validator).filter(Boolean);
26725       if (!include.length) {
26726         if (this.strict) {
26727           throw new Error("validateLocationSet:  LocationSet includes nothing.");
26728         } else {
26729           locationSet.include = ["Q2"];
26730           include = [{ type: "countrycoder", location: "Q2", id: "Q2" }];
26731         }
26732       }
26733       include.sort(_sortLocations);
26734       let id2 = "+[" + include.map((d2) => d2.id).join(",") + "]";
26735       if (exclude.length) {
26736         exclude.sort(_sortLocations);
26737         id2 += "-[" + exclude.map((d2) => d2.id).join(",") + "]";
26738       }
26739       return { type: "locationset", locationSet, id: id2 };
26740     }
26741     // resolveLocationSet
26742     // `locationSet`  the locationSet to resolve
26743     //
26744     // Pass a locationSet Object to validate like:
26745     //   {
26746     //     include: [ Array of locations ],
26747     //     exclude: [ Array of locations ]
26748     //   }
26749     //
26750     // Returns a result like:
26751     //   {
26752     //     type:         'locationset'
26753     //     locationSet:  the queried locationSet
26754     //     id:           the stable identifier for the feature
26755     //     feature:      the resolved GeoJSON feature
26756     //   }
26757     // or `null` if the locationSet is invalid
26758     //
26759     resolveLocationSet(locationSet) {
26760       locationSet = locationSet || {};
26761       const valid = this.validateLocationSet(locationSet);
26762       if (!valid)
26763         return null;
26764       const id2 = valid.id;
26765       if (this._cache[id2]) {
26766         return Object.assign(valid, { feature: this._cache[id2] });
26767       }
26768       const resolver = this.resolveLocation.bind(this);
26769       const includes = (locationSet.include || []).map(resolver).filter(Boolean);
26770       const excludes = (locationSet.exclude || []).map(resolver).filter(Boolean);
26771       if (includes.length === 1 && excludes.length === 0) {
26772         return Object.assign(valid, { feature: includes[0].feature });
26773       }
26774       const includeGeoJSON = _clip(includes.map((d2) => d2.feature), "UNION");
26775       const excludeGeoJSON = _clip(excludes.map((d2) => d2.feature), "UNION");
26776       let resultGeoJSON = excludeGeoJSON ? _clip([includeGeoJSON, excludeGeoJSON], "DIFFERENCE") : includeGeoJSON;
26777       const area = import_geojson_area.default.geometry(resultGeoJSON.geometry) / 1e6;
26778       resultGeoJSON.id = id2;
26779       resultGeoJSON.properties = { id: id2, area: Number(area.toFixed(2)) };
26780       this._cache[id2] = resultGeoJSON;
26781       return Object.assign(valid, { feature: resultGeoJSON });
26782     }
26783     // stringify
26784     // convenience method to prettyStringify the given object
26785     stringify(obj, options2) {
26786       return (0, import_json_stringify_pretty_compact.default)(obj, options2);
26787     }
26788   };
26789   function _clip(features, which) {
26790     if (!Array.isArray(features) || !features.length)
26791       return null;
26792     const fn = { UNION: union, DIFFERENCE: difference }[which];
26793     const args = features.map((feature3) => feature3.geometry.coordinates);
26794     const coords = fn.apply(null, args);
26795     return {
26796       type: "Feature",
26797       properties: {},
26798       geometry: {
26799         type: whichType(coords),
26800         coordinates: coords
26801       }
26802     };
26803     function whichType(coords2) {
26804       const a2 = Array.isArray(coords2);
26805       const b2 = a2 && Array.isArray(coords2[0]);
26806       const c2 = b2 && Array.isArray(coords2[0][0]);
26807       const d2 = c2 && Array.isArray(coords2[0][0][0]);
26808       return d2 ? "MultiPolygon" : "Polygon";
26809     }
26810   }
26811   function _cloneDeep(obj) {
26812     return JSON.parse(JSON.stringify(obj));
26813   }
26814   function _sortLocations(a2, b2) {
26815     const rank = { countrycoder: 1, geojson: 2, point: 3 };
26816     const aRank = rank[a2.type];
26817     const bRank = rank[b2.type];
26818     return aRank > bRank ? 1 : aRank < bRank ? -1 : a2.id.localeCompare(b2.id);
26819   }
26820
26821   // modules/core/LocationManager.js
26822   var import_which_polygon2 = __toESM(require_which_polygon());
26823   var import_geojson_area2 = __toESM(require_geojson_area());
26824   var _loco = new LocationConflation();
26825   var LocationManager = class {
26826     /**
26827      * @constructor
26828      */
26829     constructor() {
26830       this._wp = null;
26831       this._resolved = /* @__PURE__ */ new Map();
26832       this._knownLocationSets = /* @__PURE__ */ new Map();
26833       this._locationIncludedIn = /* @__PURE__ */ new Map();
26834       this._locationExcludedIn = /* @__PURE__ */ new Map();
26835       const world = { locationSet: { include: ["Q2"] } };
26836       this._resolveLocationSet(world);
26837       this._rebuildIndex();
26838     }
26839     /**
26840      * _validateLocationSet
26841      * Pass an Object with a `locationSet` property.
26842      * Validates the `locationSet` and sets a `locationSetID` property on the object.
26843      * To avoid so much computation we only resolve the include and exclude regions, but not the locationSet itself.
26844      *
26845      * Use `_resolveLocationSet()` instead if you need to resolve geojson of locationSet, for example to render it.
26846      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
26847      *
26848      * @param  `obj`  Object to check, it should have `locationSet` property
26849      */
26850     _validateLocationSet(obj) {
26851       if (obj.locationSetID)
26852         return;
26853       try {
26854         let locationSet = obj.locationSet;
26855         if (!locationSet) {
26856           throw new Error("object missing locationSet property");
26857         }
26858         if (!locationSet.include) {
26859           locationSet.include = ["Q2"];
26860         }
26861         const locationSetID = _loco.validateLocationSet(locationSet).id;
26862         obj.locationSetID = locationSetID;
26863         if (this._knownLocationSets.has(locationSetID))
26864           return;
26865         let area = 0;
26866         (locationSet.include || []).forEach((location) => {
26867           const locationID = _loco.validateLocation(location).id;
26868           let geojson = this._resolved.get(locationID);
26869           if (!geojson) {
26870             geojson = _loco.resolveLocation(location).feature;
26871             this._resolved.set(locationID, geojson);
26872           }
26873           area += geojson.properties.area;
26874           let s2 = this._locationIncludedIn.get(locationID);
26875           if (!s2) {
26876             s2 = /* @__PURE__ */ new Set();
26877             this._locationIncludedIn.set(locationID, s2);
26878           }
26879           s2.add(locationSetID);
26880         });
26881         (locationSet.exclude || []).forEach((location) => {
26882           const locationID = _loco.validateLocation(location).id;
26883           let geojson = this._resolved.get(locationID);
26884           if (!geojson) {
26885             geojson = _loco.resolveLocation(location).feature;
26886             this._resolved.set(locationID, geojson);
26887           }
26888           area -= geojson.properties.area;
26889           let s2 = this._locationExcludedIn.get(locationID);
26890           if (!s2) {
26891             s2 = /* @__PURE__ */ new Set();
26892             this._locationExcludedIn.set(locationID, s2);
26893           }
26894           s2.add(locationSetID);
26895         });
26896         this._knownLocationSets.set(locationSetID, area);
26897       } catch (err) {
26898         obj.locationSet = { include: ["Q2"] };
26899         obj.locationSetID = "+[Q2]";
26900       }
26901     }
26902     /**
26903      * _resolveLocationSet
26904      * Does everything that `_validateLocationSet()` does, but then "resolves" the locationSet into GeoJSON.
26905      * This step is a bit more computationally expensive, so really only needed if you intend to render the shape.
26906      *
26907      * Note: You need to call `_rebuildIndex()` after you're all finished validating the locationSets.
26908      *
26909      * @param  `obj`  Object to check, it should have `locationSet` property
26910      */
26911     _resolveLocationSet(obj) {
26912       this._validateLocationSet(obj);
26913       if (this._resolved.has(obj.locationSetID))
26914         return;
26915       try {
26916         const result = _loco.resolveLocationSet(obj.locationSet);
26917         const locationSetID = result.id;
26918         obj.locationSetID = locationSetID;
26919         if (!result.feature.geometry.coordinates.length || !result.feature.properties.area) {
26920           throw new Error("locationSet ".concat(locationSetID, " resolves to an empty feature."));
26921         }
26922         let geojson = JSON.parse(JSON.stringify(result.feature));
26923         geojson.id = locationSetID;
26924         geojson.properties.id = locationSetID;
26925         this._resolved.set(locationSetID, geojson);
26926       } catch (err) {
26927         obj.locationSet = { include: ["Q2"] };
26928         obj.locationSetID = "+[Q2]";
26929       }
26930     }
26931     /**
26932      * _rebuildIndex
26933      * Rebuilds the whichPolygon index with whatever features have been resolved into GeoJSON.
26934      */
26935     _rebuildIndex() {
26936       this._wp = (0, import_which_polygon2.default)({ features: [...this._resolved.values()] });
26937     }
26938     /**
26939      * mergeCustomGeoJSON
26940      * Accepts a FeatureCollection-like object containing custom locations
26941      * Each feature must have a filename-like `id`, for example: `something.geojson`
26942      * {
26943      *   "type": "FeatureCollection"
26944      *   "features": [
26945      *     {
26946      *       "type": "Feature",
26947      *       "id": "philly_metro.geojson",
26948      *       "properties": { … },
26949      *       "geometry": { … }
26950      *     }
26951      *   ]
26952      * }
26953      *
26954      * @param  `fc`  FeatureCollection-like Object containing custom locations
26955      */
26956     mergeCustomGeoJSON(fc) {
26957       if (!fc || fc.type !== "FeatureCollection" || !Array.isArray(fc.features))
26958         return;
26959       fc.features.forEach((feature3) => {
26960         feature3.properties = feature3.properties || {};
26961         let props = feature3.properties;
26962         let id2 = feature3.id || props.id;
26963         if (!id2 || !/^\S+\.geojson$/i.test(id2))
26964           return;
26965         id2 = id2.toLowerCase();
26966         feature3.id = id2;
26967         props.id = id2;
26968         if (!props.area) {
26969           const area = import_geojson_area2.default.geometry(feature3.geometry) / 1e6;
26970           props.area = Number(area.toFixed(2));
26971         }
26972         _loco._cache[id2] = feature3;
26973       });
26974     }
26975     /**
26976      * mergeLocationSets
26977      * Accepts an Array of Objects containing `locationSet` properties:
26978      * [
26979      *  { id: 'preset1', locationSet: {…} },
26980      *  { id: 'preset2', locationSet: {…} },
26981      *  …
26982      * ]
26983      * After validating, the Objects will be decorated with a `locationSetID` property:
26984      * [
26985      *  { id: 'preset1', locationSet: {…}, locationSetID: '+[Q2]' },
26986      *  { id: 'preset2', locationSet: {…}, locationSetID: '+[Q30]' },
26987      *  …
26988      * ]
26989      *
26990      * @param  `objects`  Objects to check - they should have `locationSet` property
26991      * @return  Promise resolved true (this function used to be slow/async, now it's faster and sync)
26992      */
26993     mergeLocationSets(objects) {
26994       if (!Array.isArray(objects))
26995         return Promise.reject("nothing to do");
26996       objects.forEach((obj) => this._validateLocationSet(obj));
26997       this._rebuildIndex();
26998       return Promise.resolve(objects);
26999     }
27000     /**
27001      * locationSetID
27002      * Returns a locationSetID for a given locationSet (fallback to `+[Q2]`, world)
27003      * (The locationSet doesn't necessarily need to be resolved to compute its `id`)
27004      *
27005      * @param  `locationSet`  A locationSet Object, e.g. `{ include: ['us'] }`
27006      * @return  String locationSetID, e.g. `+[Q30]`
27007      */
27008     locationSetID(locationSet) {
27009       let locationSetID;
27010       try {
27011         locationSetID = _loco.validateLocationSet(locationSet).id;
27012       } catch (err) {
27013         locationSetID = "+[Q2]";
27014       }
27015       return locationSetID;
27016     }
27017     /**
27018      * feature
27019      * Returns the resolved GeoJSON feature for a given locationSetID (fallback to 'world')
27020      * A GeoJSON feature:
27021      * {
27022      *   type: 'Feature',
27023      *   id: '+[Q30]',
27024      *   properties: { id: '+[Q30]', area: 21817019.17, … },
27025      *   geometry: { … }
27026      * }
27027      *
27028      * @param  `locationSetID`  String identifier, e.g. `+[Q30]`
27029      * @return  GeoJSON object (fallback to world)
27030      */
27031     feature(locationSetID = "+[Q2]") {
27032       const feature3 = this._resolved.get(locationSetID);
27033       return feature3 || this._resolved.get("+[Q2]");
27034     }
27035     /**
27036      * locationSetsAt
27037      * Find all the locationSets valid at the given location.
27038      * Results include the area (in km²) to facilitate sorting.
27039      *
27040      * Object of locationSetIDs to areas (in km²)
27041      * {
27042      *   "+[Q2]": 511207893.3958111,
27043      *   "+[Q30]": 21817019.17,
27044      *   "+[new_jersey.geojson]": 22390.77,
27045      *   …
27046      * }
27047      *
27048      * @param  `loc`  `[lon,lat]` location to query, e.g. `[-74.4813, 40.7967]`
27049      * @return  Object of locationSetIDs valid at given location
27050      */
27051     locationSetsAt(loc) {
27052       let result = {};
27053       const hits = this._wp(loc, true) || [];
27054       const thiz = this;
27055       hits.forEach((prop) => {
27056         if (prop.id[0] !== "+")
27057           return;
27058         const locationSetID = prop.id;
27059         const area = thiz._knownLocationSets.get(locationSetID);
27060         if (area) {
27061           result[locationSetID] = area;
27062         }
27063       });
27064       hits.forEach((prop) => {
27065         if (prop.id[0] === "+")
27066           return;
27067         const locationID = prop.id;
27068         const included = thiz._locationIncludedIn.get(locationID);
27069         (included || []).forEach((locationSetID) => {
27070           const area = thiz._knownLocationSets.get(locationSetID);
27071           if (area) {
27072             result[locationSetID] = area;
27073           }
27074         });
27075       });
27076       hits.forEach((prop) => {
27077         if (prop.id[0] === "+")
27078           return;
27079         const locationID = prop.id;
27080         const excluded = thiz._locationExcludedIn.get(locationID);
27081         (excluded || []).forEach((locationSetID) => {
27082           delete result[locationSetID];
27083         });
27084       });
27085       return result;
27086     }
27087     // Direct access to the location-conflation resolver
27088     loco() {
27089       return _loco;
27090     }
27091   };
27092   var _sharedLocationManager = new LocationManager();
27093
27094   // node_modules/lodash-es/_freeGlobal.js
27095   var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
27096   var freeGlobal_default = freeGlobal;
27097
27098   // node_modules/lodash-es/_root.js
27099   var freeSelf = typeof self == "object" && self && self.Object === Object && self;
27100   var root2 = freeGlobal_default || freeSelf || Function("return this")();
27101   var root_default = root2;
27102
27103   // node_modules/lodash-es/_Symbol.js
27104   var Symbol2 = root_default.Symbol;
27105   var Symbol_default = Symbol2;
27106
27107   // node_modules/lodash-es/_getRawTag.js
27108   var objectProto = Object.prototype;
27109   var hasOwnProperty = objectProto.hasOwnProperty;
27110   var nativeObjectToString = objectProto.toString;
27111   var symToStringTag = Symbol_default ? Symbol_default.toStringTag : void 0;
27112   function getRawTag(value) {
27113     var isOwn = hasOwnProperty.call(value, symToStringTag), tag2 = value[symToStringTag];
27114     try {
27115       value[symToStringTag] = void 0;
27116       var unmasked = true;
27117     } catch (e3) {
27118     }
27119     var result = nativeObjectToString.call(value);
27120     if (unmasked) {
27121       if (isOwn) {
27122         value[symToStringTag] = tag2;
27123       } else {
27124         delete value[symToStringTag];
27125       }
27126     }
27127     return result;
27128   }
27129   var getRawTag_default = getRawTag;
27130
27131   // node_modules/lodash-es/_objectToString.js
27132   var objectProto2 = Object.prototype;
27133   var nativeObjectToString2 = objectProto2.toString;
27134   function objectToString(value) {
27135     return nativeObjectToString2.call(value);
27136   }
27137   var objectToString_default = objectToString;
27138
27139   // node_modules/lodash-es/_baseGetTag.js
27140   var nullTag = "[object Null]";
27141   var undefinedTag = "[object Undefined]";
27142   var symToStringTag2 = Symbol_default ? Symbol_default.toStringTag : void 0;
27143   function baseGetTag(value) {
27144     if (value == null) {
27145       return value === void 0 ? undefinedTag : nullTag;
27146     }
27147     return symToStringTag2 && symToStringTag2 in Object(value) ? getRawTag_default(value) : objectToString_default(value);
27148   }
27149   var baseGetTag_default = baseGetTag;
27150
27151   // node_modules/lodash-es/isObjectLike.js
27152   function isObjectLike(value) {
27153     return value != null && typeof value == "object";
27154   }
27155   var isObjectLike_default = isObjectLike;
27156
27157   // node_modules/lodash-es/isSymbol.js
27158   var symbolTag = "[object Symbol]";
27159   function isSymbol(value) {
27160     return typeof value == "symbol" || isObjectLike_default(value) && baseGetTag_default(value) == symbolTag;
27161   }
27162   var isSymbol_default = isSymbol;
27163
27164   // node_modules/lodash-es/_arrayMap.js
27165   function arrayMap(array2, iteratee) {
27166     var index = -1, length2 = array2 == null ? 0 : array2.length, result = Array(length2);
27167     while (++index < length2) {
27168       result[index] = iteratee(array2[index], index, array2);
27169     }
27170     return result;
27171   }
27172   var arrayMap_default = arrayMap;
27173
27174   // node_modules/lodash-es/isArray.js
27175   var isArray = Array.isArray;
27176   var isArray_default = isArray;
27177
27178   // node_modules/lodash-es/_baseToString.js
27179   var INFINITY = 1 / 0;
27180   var symbolProto = Symbol_default ? Symbol_default.prototype : void 0;
27181   var symbolToString = symbolProto ? symbolProto.toString : void 0;
27182   function baseToString(value) {
27183     if (typeof value == "string") {
27184       return value;
27185     }
27186     if (isArray_default(value)) {
27187       return arrayMap_default(value, baseToString) + "";
27188     }
27189     if (isSymbol_default(value)) {
27190       return symbolToString ? symbolToString.call(value) : "";
27191     }
27192     var result = value + "";
27193     return result == "0" && 1 / value == -INFINITY ? "-0" : result;
27194   }
27195   var baseToString_default = baseToString;
27196
27197   // node_modules/lodash-es/_trimmedEndIndex.js
27198   var reWhitespace = /\s/;
27199   function trimmedEndIndex(string) {
27200     var index = string.length;
27201     while (index-- && reWhitespace.test(string.charAt(index))) {
27202     }
27203     return index;
27204   }
27205   var trimmedEndIndex_default = trimmedEndIndex;
27206
27207   // node_modules/lodash-es/_baseTrim.js
27208   var reTrimStart = /^\s+/;
27209   function baseTrim(string) {
27210     return string ? string.slice(0, trimmedEndIndex_default(string) + 1).replace(reTrimStart, "") : string;
27211   }
27212   var baseTrim_default = baseTrim;
27213
27214   // node_modules/lodash-es/isObject.js
27215   function isObject(value) {
27216     var type2 = typeof value;
27217     return value != null && (type2 == "object" || type2 == "function");
27218   }
27219   var isObject_default = isObject;
27220
27221   // node_modules/lodash-es/toNumber.js
27222   var NAN = 0 / 0;
27223   var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
27224   var reIsBinary = /^0b[01]+$/i;
27225   var reIsOctal = /^0o[0-7]+$/i;
27226   var freeParseInt = parseInt;
27227   function toNumber(value) {
27228     if (typeof value == "number") {
27229       return value;
27230     }
27231     if (isSymbol_default(value)) {
27232       return NAN;
27233     }
27234     if (isObject_default(value)) {
27235       var other = typeof value.valueOf == "function" ? value.valueOf() : value;
27236       value = isObject_default(other) ? other + "" : other;
27237     }
27238     if (typeof value != "string") {
27239       return value === 0 ? value : +value;
27240     }
27241     value = baseTrim_default(value);
27242     var isBinary = reIsBinary.test(value);
27243     return isBinary || reIsOctal.test(value) ? freeParseInt(value.slice(2), isBinary ? 2 : 8) : reIsBadHex.test(value) ? NAN : +value;
27244   }
27245   var toNumber_default = toNumber;
27246
27247   // node_modules/lodash-es/isFunction.js
27248   var asyncTag = "[object AsyncFunction]";
27249   var funcTag = "[object Function]";
27250   var genTag = "[object GeneratorFunction]";
27251   var proxyTag = "[object Proxy]";
27252   function isFunction(value) {
27253     if (!isObject_default(value)) {
27254       return false;
27255     }
27256     var tag2 = baseGetTag_default(value);
27257     return tag2 == funcTag || tag2 == genTag || tag2 == asyncTag || tag2 == proxyTag;
27258   }
27259   var isFunction_default = isFunction;
27260
27261   // node_modules/lodash-es/_coreJsData.js
27262   var coreJsData = root_default["__core-js_shared__"];
27263   var coreJsData_default = coreJsData;
27264
27265   // node_modules/lodash-es/_isMasked.js
27266   var maskSrcKey = function() {
27267     var uid = /[^.]+$/.exec(coreJsData_default && coreJsData_default.keys && coreJsData_default.keys.IE_PROTO || "");
27268     return uid ? "Symbol(src)_1." + uid : "";
27269   }();
27270   function isMasked(func) {
27271     return !!maskSrcKey && maskSrcKey in func;
27272   }
27273   var isMasked_default = isMasked;
27274
27275   // node_modules/lodash-es/_toSource.js
27276   var funcProto = Function.prototype;
27277   var funcToString = funcProto.toString;
27278   function toSource(func) {
27279     if (func != null) {
27280       try {
27281         return funcToString.call(func);
27282       } catch (e3) {
27283       }
27284       try {
27285         return func + "";
27286       } catch (e3) {
27287       }
27288     }
27289     return "";
27290   }
27291   var toSource_default = toSource;
27292
27293   // node_modules/lodash-es/_baseIsNative.js
27294   var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
27295   var reIsHostCtor = /^\[object .+?Constructor\]$/;
27296   var funcProto2 = Function.prototype;
27297   var objectProto3 = Object.prototype;
27298   var funcToString2 = funcProto2.toString;
27299   var hasOwnProperty2 = objectProto3.hasOwnProperty;
27300   var reIsNative = RegExp(
27301     "^" + funcToString2.call(hasOwnProperty2).replace(reRegExpChar, "\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, "$1.*?") + "$"
27302   );
27303   function baseIsNative(value) {
27304     if (!isObject_default(value) || isMasked_default(value)) {
27305       return false;
27306     }
27307     var pattern = isFunction_default(value) ? reIsNative : reIsHostCtor;
27308     return pattern.test(toSource_default(value));
27309   }
27310   var baseIsNative_default = baseIsNative;
27311
27312   // node_modules/lodash-es/_getValue.js
27313   function getValue(object, key) {
27314     return object == null ? void 0 : object[key];
27315   }
27316   var getValue_default = getValue;
27317
27318   // node_modules/lodash-es/_getNative.js
27319   function getNative(object, key) {
27320     var value = getValue_default(object, key);
27321     return baseIsNative_default(value) ? value : void 0;
27322   }
27323   var getNative_default = getNative;
27324
27325   // node_modules/lodash-es/_WeakMap.js
27326   var WeakMap = getNative_default(root_default, "WeakMap");
27327   var WeakMap_default = WeakMap;
27328
27329   // node_modules/lodash-es/_isIndex.js
27330   var MAX_SAFE_INTEGER2 = 9007199254740991;
27331   var reIsUint = /^(?:0|[1-9]\d*)$/;
27332   function isIndex(value, length2) {
27333     var type2 = typeof value;
27334     length2 = length2 == null ? MAX_SAFE_INTEGER2 : length2;
27335     return !!length2 && (type2 == "number" || type2 != "symbol" && reIsUint.test(value)) && (value > -1 && value % 1 == 0 && value < length2);
27336   }
27337   var isIndex_default = isIndex;
27338
27339   // node_modules/lodash-es/eq.js
27340   function eq(value, other) {
27341     return value === other || value !== value && other !== other;
27342   }
27343   var eq_default = eq;
27344
27345   // node_modules/lodash-es/isLength.js
27346   var MAX_SAFE_INTEGER3 = 9007199254740991;
27347   function isLength(value) {
27348     return typeof value == "number" && value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER3;
27349   }
27350   var isLength_default = isLength;
27351
27352   // node_modules/lodash-es/isArrayLike.js
27353   function isArrayLike(value) {
27354     return value != null && isLength_default(value.length) && !isFunction_default(value);
27355   }
27356   var isArrayLike_default = isArrayLike;
27357
27358   // node_modules/lodash-es/_isPrototype.js
27359   var objectProto4 = Object.prototype;
27360   function isPrototype(value) {
27361     var Ctor = value && value.constructor, proto = typeof Ctor == "function" && Ctor.prototype || objectProto4;
27362     return value === proto;
27363   }
27364   var isPrototype_default = isPrototype;
27365
27366   // node_modules/lodash-es/_baseTimes.js
27367   function baseTimes(n3, iteratee) {
27368     var index = -1, result = Array(n3);
27369     while (++index < n3) {
27370       result[index] = iteratee(index);
27371     }
27372     return result;
27373   }
27374   var baseTimes_default = baseTimes;
27375
27376   // node_modules/lodash-es/_baseIsArguments.js
27377   var argsTag = "[object Arguments]";
27378   function baseIsArguments(value) {
27379     return isObjectLike_default(value) && baseGetTag_default(value) == argsTag;
27380   }
27381   var baseIsArguments_default = baseIsArguments;
27382
27383   // node_modules/lodash-es/isArguments.js
27384   var objectProto5 = Object.prototype;
27385   var hasOwnProperty3 = objectProto5.hasOwnProperty;
27386   var propertyIsEnumerable = objectProto5.propertyIsEnumerable;
27387   var isArguments = baseIsArguments_default(/* @__PURE__ */ function() {
27388     return arguments;
27389   }()) ? baseIsArguments_default : function(value) {
27390     return isObjectLike_default(value) && hasOwnProperty3.call(value, "callee") && !propertyIsEnumerable.call(value, "callee");
27391   };
27392   var isArguments_default = isArguments;
27393
27394   // node_modules/lodash-es/stubFalse.js
27395   function stubFalse() {
27396     return false;
27397   }
27398   var stubFalse_default = stubFalse;
27399
27400   // node_modules/lodash-es/isBuffer.js
27401   var freeExports = typeof exports == "object" && exports && !exports.nodeType && exports;
27402   var freeModule = freeExports && typeof module == "object" && module && !module.nodeType && module;
27403   var moduleExports = freeModule && freeModule.exports === freeExports;
27404   var Buffer2 = moduleExports ? root_default.Buffer : void 0;
27405   var nativeIsBuffer = Buffer2 ? Buffer2.isBuffer : void 0;
27406   var isBuffer = nativeIsBuffer || stubFalse_default;
27407   var isBuffer_default = isBuffer;
27408
27409   // node_modules/lodash-es/_baseIsTypedArray.js
27410   var argsTag2 = "[object Arguments]";
27411   var arrayTag = "[object Array]";
27412   var boolTag = "[object Boolean]";
27413   var dateTag = "[object Date]";
27414   var errorTag = "[object Error]";
27415   var funcTag2 = "[object Function]";
27416   var mapTag = "[object Map]";
27417   var numberTag = "[object Number]";
27418   var objectTag = "[object Object]";
27419   var regexpTag = "[object RegExp]";
27420   var setTag = "[object Set]";
27421   var stringTag = "[object String]";
27422   var weakMapTag = "[object WeakMap]";
27423   var arrayBufferTag = "[object ArrayBuffer]";
27424   var dataViewTag = "[object DataView]";
27425   var float32Tag = "[object Float32Array]";
27426   var float64Tag = "[object Float64Array]";
27427   var int8Tag = "[object Int8Array]";
27428   var int16Tag = "[object Int16Array]";
27429   var int32Tag = "[object Int32Array]";
27430   var uint8Tag = "[object Uint8Array]";
27431   var uint8ClampedTag = "[object Uint8ClampedArray]";
27432   var uint16Tag = "[object Uint16Array]";
27433   var uint32Tag = "[object Uint32Array]";
27434   var typedArrayTags = {};
27435   typedArrayTags[float32Tag] = typedArrayTags[float64Tag] = typedArrayTags[int8Tag] = typedArrayTags[int16Tag] = typedArrayTags[int32Tag] = typedArrayTags[uint8Tag] = typedArrayTags[uint8ClampedTag] = typedArrayTags[uint16Tag] = typedArrayTags[uint32Tag] = true;
27436   typedArrayTags[argsTag2] = typedArrayTags[arrayTag] = typedArrayTags[arrayBufferTag] = typedArrayTags[boolTag] = typedArrayTags[dataViewTag] = typedArrayTags[dateTag] = typedArrayTags[errorTag] = typedArrayTags[funcTag2] = typedArrayTags[mapTag] = typedArrayTags[numberTag] = typedArrayTags[objectTag] = typedArrayTags[regexpTag] = typedArrayTags[setTag] = typedArrayTags[stringTag] = typedArrayTags[weakMapTag] = false;
27437   function baseIsTypedArray(value) {
27438     return isObjectLike_default(value) && isLength_default(value.length) && !!typedArrayTags[baseGetTag_default(value)];
27439   }
27440   var baseIsTypedArray_default = baseIsTypedArray;
27441
27442   // node_modules/lodash-es/_baseUnary.js
27443   function baseUnary(func) {
27444     return function(value) {
27445       return func(value);
27446     };
27447   }
27448   var baseUnary_default = baseUnary;
27449
27450   // node_modules/lodash-es/_nodeUtil.js
27451   var freeExports2 = typeof exports == "object" && exports && !exports.nodeType && exports;
27452   var freeModule2 = freeExports2 && typeof module == "object" && module && !module.nodeType && module;
27453   var moduleExports2 = freeModule2 && freeModule2.exports === freeExports2;
27454   var freeProcess = moduleExports2 && freeGlobal_default.process;
27455   var nodeUtil = function() {
27456     try {
27457       var types = freeModule2 && freeModule2.require && freeModule2.require("util").types;
27458       if (types) {
27459         return types;
27460       }
27461       return freeProcess && freeProcess.binding && freeProcess.binding("util");
27462     } catch (e3) {
27463     }
27464   }();
27465   var nodeUtil_default = nodeUtil;
27466
27467   // node_modules/lodash-es/isTypedArray.js
27468   var nodeIsTypedArray = nodeUtil_default && nodeUtil_default.isTypedArray;
27469   var isTypedArray = nodeIsTypedArray ? baseUnary_default(nodeIsTypedArray) : baseIsTypedArray_default;
27470   var isTypedArray_default = isTypedArray;
27471
27472   // node_modules/lodash-es/_arrayLikeKeys.js
27473   var objectProto6 = Object.prototype;
27474   var hasOwnProperty4 = objectProto6.hasOwnProperty;
27475   function arrayLikeKeys(value, inherited) {
27476     var isArr = isArray_default(value), isArg = !isArr && isArguments_default(value), isBuff = !isArr && !isArg && isBuffer_default(value), isType = !isArr && !isArg && !isBuff && isTypedArray_default(value), skipIndexes = isArr || isArg || isBuff || isType, result = skipIndexes ? baseTimes_default(value.length, String) : [], length2 = result.length;
27477     for (var key in value) {
27478       if ((inherited || hasOwnProperty4.call(value, key)) && !(skipIndexes && // Safari 9 has enumerable `arguments.length` in strict mode.
27479       (key == "length" || // Node.js 0.10 has enumerable non-index properties on buffers.
27480       isBuff && (key == "offset" || key == "parent") || // PhantomJS 2 has enumerable non-index properties on typed arrays.
27481       isType && (key == "buffer" || key == "byteLength" || key == "byteOffset") || // Skip index properties.
27482       isIndex_default(key, length2)))) {
27483         result.push(key);
27484       }
27485     }
27486     return result;
27487   }
27488   var arrayLikeKeys_default = arrayLikeKeys;
27489
27490   // node_modules/lodash-es/_overArg.js
27491   function overArg(func, transform2) {
27492     return function(arg) {
27493       return func(transform2(arg));
27494     };
27495   }
27496   var overArg_default = overArg;
27497
27498   // node_modules/lodash-es/_nativeKeys.js
27499   var nativeKeys = overArg_default(Object.keys, Object);
27500   var nativeKeys_default = nativeKeys;
27501
27502   // node_modules/lodash-es/_baseKeys.js
27503   var objectProto7 = Object.prototype;
27504   var hasOwnProperty5 = objectProto7.hasOwnProperty;
27505   function baseKeys(object) {
27506     if (!isPrototype_default(object)) {
27507       return nativeKeys_default(object);
27508     }
27509     var result = [];
27510     for (var key in Object(object)) {
27511       if (hasOwnProperty5.call(object, key) && key != "constructor") {
27512         result.push(key);
27513       }
27514     }
27515     return result;
27516   }
27517   var baseKeys_default = baseKeys;
27518
27519   // node_modules/lodash-es/keys.js
27520   function keys(object) {
27521     return isArrayLike_default(object) ? arrayLikeKeys_default(object) : baseKeys_default(object);
27522   }
27523   var keys_default = keys;
27524
27525   // node_modules/lodash-es/_nativeCreate.js
27526   var nativeCreate = getNative_default(Object, "create");
27527   var nativeCreate_default = nativeCreate;
27528
27529   // node_modules/lodash-es/_hashClear.js
27530   function hashClear() {
27531     this.__data__ = nativeCreate_default ? nativeCreate_default(null) : {};
27532     this.size = 0;
27533   }
27534   var hashClear_default = hashClear;
27535
27536   // node_modules/lodash-es/_hashDelete.js
27537   function hashDelete(key) {
27538     var result = this.has(key) && delete this.__data__[key];
27539     this.size -= result ? 1 : 0;
27540     return result;
27541   }
27542   var hashDelete_default = hashDelete;
27543
27544   // node_modules/lodash-es/_hashGet.js
27545   var HASH_UNDEFINED = "__lodash_hash_undefined__";
27546   var objectProto8 = Object.prototype;
27547   var hasOwnProperty6 = objectProto8.hasOwnProperty;
27548   function hashGet(key) {
27549     var data = this.__data__;
27550     if (nativeCreate_default) {
27551       var result = data[key];
27552       return result === HASH_UNDEFINED ? void 0 : result;
27553     }
27554     return hasOwnProperty6.call(data, key) ? data[key] : void 0;
27555   }
27556   var hashGet_default = hashGet;
27557
27558   // node_modules/lodash-es/_hashHas.js
27559   var objectProto9 = Object.prototype;
27560   var hasOwnProperty7 = objectProto9.hasOwnProperty;
27561   function hashHas(key) {
27562     var data = this.__data__;
27563     return nativeCreate_default ? data[key] !== void 0 : hasOwnProperty7.call(data, key);
27564   }
27565   var hashHas_default = hashHas;
27566
27567   // node_modules/lodash-es/_hashSet.js
27568   var HASH_UNDEFINED2 = "__lodash_hash_undefined__";
27569   function hashSet(key, value) {
27570     var data = this.__data__;
27571     this.size += this.has(key) ? 0 : 1;
27572     data[key] = nativeCreate_default && value === void 0 ? HASH_UNDEFINED2 : value;
27573     return this;
27574   }
27575   var hashSet_default = hashSet;
27576
27577   // node_modules/lodash-es/_Hash.js
27578   function Hash(entries) {
27579     var index = -1, length2 = entries == null ? 0 : entries.length;
27580     this.clear();
27581     while (++index < length2) {
27582       var entry = entries[index];
27583       this.set(entry[0], entry[1]);
27584     }
27585   }
27586   Hash.prototype.clear = hashClear_default;
27587   Hash.prototype["delete"] = hashDelete_default;
27588   Hash.prototype.get = hashGet_default;
27589   Hash.prototype.has = hashHas_default;
27590   Hash.prototype.set = hashSet_default;
27591   var Hash_default = Hash;
27592
27593   // node_modules/lodash-es/_listCacheClear.js
27594   function listCacheClear() {
27595     this.__data__ = [];
27596     this.size = 0;
27597   }
27598   var listCacheClear_default = listCacheClear;
27599
27600   // node_modules/lodash-es/_assocIndexOf.js
27601   function assocIndexOf(array2, key) {
27602     var length2 = array2.length;
27603     while (length2--) {
27604       if (eq_default(array2[length2][0], key)) {
27605         return length2;
27606       }
27607     }
27608     return -1;
27609   }
27610   var assocIndexOf_default = assocIndexOf;
27611
27612   // node_modules/lodash-es/_listCacheDelete.js
27613   var arrayProto = Array.prototype;
27614   var splice = arrayProto.splice;
27615   function listCacheDelete(key) {
27616     var data = this.__data__, index = assocIndexOf_default(data, key);
27617     if (index < 0) {
27618       return false;
27619     }
27620     var lastIndex = data.length - 1;
27621     if (index == lastIndex) {
27622       data.pop();
27623     } else {
27624       splice.call(data, index, 1);
27625     }
27626     --this.size;
27627     return true;
27628   }
27629   var listCacheDelete_default = listCacheDelete;
27630
27631   // node_modules/lodash-es/_listCacheGet.js
27632   function listCacheGet(key) {
27633     var data = this.__data__, index = assocIndexOf_default(data, key);
27634     return index < 0 ? void 0 : data[index][1];
27635   }
27636   var listCacheGet_default = listCacheGet;
27637
27638   // node_modules/lodash-es/_listCacheHas.js
27639   function listCacheHas(key) {
27640     return assocIndexOf_default(this.__data__, key) > -1;
27641   }
27642   var listCacheHas_default = listCacheHas;
27643
27644   // node_modules/lodash-es/_listCacheSet.js
27645   function listCacheSet(key, value) {
27646     var data = this.__data__, index = assocIndexOf_default(data, key);
27647     if (index < 0) {
27648       ++this.size;
27649       data.push([key, value]);
27650     } else {
27651       data[index][1] = value;
27652     }
27653     return this;
27654   }
27655   var listCacheSet_default = listCacheSet;
27656
27657   // node_modules/lodash-es/_ListCache.js
27658   function ListCache(entries) {
27659     var index = -1, length2 = entries == null ? 0 : entries.length;
27660     this.clear();
27661     while (++index < length2) {
27662       var entry = entries[index];
27663       this.set(entry[0], entry[1]);
27664     }
27665   }
27666   ListCache.prototype.clear = listCacheClear_default;
27667   ListCache.prototype["delete"] = listCacheDelete_default;
27668   ListCache.prototype.get = listCacheGet_default;
27669   ListCache.prototype.has = listCacheHas_default;
27670   ListCache.prototype.set = listCacheSet_default;
27671   var ListCache_default = ListCache;
27672
27673   // node_modules/lodash-es/_Map.js
27674   var Map2 = getNative_default(root_default, "Map");
27675   var Map_default = Map2;
27676
27677   // node_modules/lodash-es/_mapCacheClear.js
27678   function mapCacheClear() {
27679     this.size = 0;
27680     this.__data__ = {
27681       "hash": new Hash_default(),
27682       "map": new (Map_default || ListCache_default)(),
27683       "string": new Hash_default()
27684     };
27685   }
27686   var mapCacheClear_default = mapCacheClear;
27687
27688   // node_modules/lodash-es/_isKeyable.js
27689   function isKeyable(value) {
27690     var type2 = typeof value;
27691     return type2 == "string" || type2 == "number" || type2 == "symbol" || type2 == "boolean" ? value !== "__proto__" : value === null;
27692   }
27693   var isKeyable_default = isKeyable;
27694
27695   // node_modules/lodash-es/_getMapData.js
27696   function getMapData(map2, key) {
27697     var data = map2.__data__;
27698     return isKeyable_default(key) ? data[typeof key == "string" ? "string" : "hash"] : data.map;
27699   }
27700   var getMapData_default = getMapData;
27701
27702   // node_modules/lodash-es/_mapCacheDelete.js
27703   function mapCacheDelete(key) {
27704     var result = getMapData_default(this, key)["delete"](key);
27705     this.size -= result ? 1 : 0;
27706     return result;
27707   }
27708   var mapCacheDelete_default = mapCacheDelete;
27709
27710   // node_modules/lodash-es/_mapCacheGet.js
27711   function mapCacheGet(key) {
27712     return getMapData_default(this, key).get(key);
27713   }
27714   var mapCacheGet_default = mapCacheGet;
27715
27716   // node_modules/lodash-es/_mapCacheHas.js
27717   function mapCacheHas(key) {
27718     return getMapData_default(this, key).has(key);
27719   }
27720   var mapCacheHas_default = mapCacheHas;
27721
27722   // node_modules/lodash-es/_mapCacheSet.js
27723   function mapCacheSet(key, value) {
27724     var data = getMapData_default(this, key), size = data.size;
27725     data.set(key, value);
27726     this.size += data.size == size ? 0 : 1;
27727     return this;
27728   }
27729   var mapCacheSet_default = mapCacheSet;
27730
27731   // node_modules/lodash-es/_MapCache.js
27732   function MapCache(entries) {
27733     var index = -1, length2 = entries == null ? 0 : entries.length;
27734     this.clear();
27735     while (++index < length2) {
27736       var entry = entries[index];
27737       this.set(entry[0], entry[1]);
27738     }
27739   }
27740   MapCache.prototype.clear = mapCacheClear_default;
27741   MapCache.prototype["delete"] = mapCacheDelete_default;
27742   MapCache.prototype.get = mapCacheGet_default;
27743   MapCache.prototype.has = mapCacheHas_default;
27744   MapCache.prototype.set = mapCacheSet_default;
27745   var MapCache_default = MapCache;
27746
27747   // node_modules/lodash-es/toString.js
27748   function toString(value) {
27749     return value == null ? "" : baseToString_default(value);
27750   }
27751   var toString_default = toString;
27752
27753   // node_modules/lodash-es/_arrayPush.js
27754   function arrayPush(array2, values) {
27755     var index = -1, length2 = values.length, offset = array2.length;
27756     while (++index < length2) {
27757       array2[offset + index] = values[index];
27758     }
27759     return array2;
27760   }
27761   var arrayPush_default = arrayPush;
27762
27763   // node_modules/lodash-es/_basePropertyOf.js
27764   function basePropertyOf(object) {
27765     return function(key) {
27766       return object == null ? void 0 : object[key];
27767     };
27768   }
27769   var basePropertyOf_default = basePropertyOf;
27770
27771   // node_modules/lodash-es/_stackClear.js
27772   function stackClear() {
27773     this.__data__ = new ListCache_default();
27774     this.size = 0;
27775   }
27776   var stackClear_default = stackClear;
27777
27778   // node_modules/lodash-es/_stackDelete.js
27779   function stackDelete(key) {
27780     var data = this.__data__, result = data["delete"](key);
27781     this.size = data.size;
27782     return result;
27783   }
27784   var stackDelete_default = stackDelete;
27785
27786   // node_modules/lodash-es/_stackGet.js
27787   function stackGet(key) {
27788     return this.__data__.get(key);
27789   }
27790   var stackGet_default = stackGet;
27791
27792   // node_modules/lodash-es/_stackHas.js
27793   function stackHas(key) {
27794     return this.__data__.has(key);
27795   }
27796   var stackHas_default = stackHas;
27797
27798   // node_modules/lodash-es/_stackSet.js
27799   var LARGE_ARRAY_SIZE = 200;
27800   function stackSet(key, value) {
27801     var data = this.__data__;
27802     if (data instanceof ListCache_default) {
27803       var pairs2 = data.__data__;
27804       if (!Map_default || pairs2.length < LARGE_ARRAY_SIZE - 1) {
27805         pairs2.push([key, value]);
27806         this.size = ++data.size;
27807         return this;
27808       }
27809       data = this.__data__ = new MapCache_default(pairs2);
27810     }
27811     data.set(key, value);
27812     this.size = data.size;
27813     return this;
27814   }
27815   var stackSet_default = stackSet;
27816
27817   // node_modules/lodash-es/_Stack.js
27818   function Stack(entries) {
27819     var data = this.__data__ = new ListCache_default(entries);
27820     this.size = data.size;
27821   }
27822   Stack.prototype.clear = stackClear_default;
27823   Stack.prototype["delete"] = stackDelete_default;
27824   Stack.prototype.get = stackGet_default;
27825   Stack.prototype.has = stackHas_default;
27826   Stack.prototype.set = stackSet_default;
27827   var Stack_default = Stack;
27828
27829   // node_modules/lodash-es/_arrayFilter.js
27830   function arrayFilter(array2, predicate) {
27831     var index = -1, length2 = array2 == null ? 0 : array2.length, resIndex = 0, result = [];
27832     while (++index < length2) {
27833       var value = array2[index];
27834       if (predicate(value, index, array2)) {
27835         result[resIndex++] = value;
27836       }
27837     }
27838     return result;
27839   }
27840   var arrayFilter_default = arrayFilter;
27841
27842   // node_modules/lodash-es/stubArray.js
27843   function stubArray() {
27844     return [];
27845   }
27846   var stubArray_default = stubArray;
27847
27848   // node_modules/lodash-es/_getSymbols.js
27849   var objectProto10 = Object.prototype;
27850   var propertyIsEnumerable2 = objectProto10.propertyIsEnumerable;
27851   var nativeGetSymbols = Object.getOwnPropertySymbols;
27852   var getSymbols = !nativeGetSymbols ? stubArray_default : function(object) {
27853     if (object == null) {
27854       return [];
27855     }
27856     object = Object(object);
27857     return arrayFilter_default(nativeGetSymbols(object), function(symbol) {
27858       return propertyIsEnumerable2.call(object, symbol);
27859     });
27860   };
27861   var getSymbols_default = getSymbols;
27862
27863   // node_modules/lodash-es/_baseGetAllKeys.js
27864   function baseGetAllKeys(object, keysFunc, symbolsFunc) {
27865     var result = keysFunc(object);
27866     return isArray_default(object) ? result : arrayPush_default(result, symbolsFunc(object));
27867   }
27868   var baseGetAllKeys_default = baseGetAllKeys;
27869
27870   // node_modules/lodash-es/_getAllKeys.js
27871   function getAllKeys(object) {
27872     return baseGetAllKeys_default(object, keys_default, getSymbols_default);
27873   }
27874   var getAllKeys_default = getAllKeys;
27875
27876   // node_modules/lodash-es/_DataView.js
27877   var DataView2 = getNative_default(root_default, "DataView");
27878   var DataView_default = DataView2;
27879
27880   // node_modules/lodash-es/_Promise.js
27881   var Promise2 = getNative_default(root_default, "Promise");
27882   var Promise_default = Promise2;
27883
27884   // node_modules/lodash-es/_Set.js
27885   var Set2 = getNative_default(root_default, "Set");
27886   var Set_default = Set2;
27887
27888   // node_modules/lodash-es/_getTag.js
27889   var mapTag2 = "[object Map]";
27890   var objectTag2 = "[object Object]";
27891   var promiseTag = "[object Promise]";
27892   var setTag2 = "[object Set]";
27893   var weakMapTag2 = "[object WeakMap]";
27894   var dataViewTag2 = "[object DataView]";
27895   var dataViewCtorString = toSource_default(DataView_default);
27896   var mapCtorString = toSource_default(Map_default);
27897   var promiseCtorString = toSource_default(Promise_default);
27898   var setCtorString = toSource_default(Set_default);
27899   var weakMapCtorString = toSource_default(WeakMap_default);
27900   var getTag = baseGetTag_default;
27901   if (DataView_default && getTag(new DataView_default(new ArrayBuffer(1))) != dataViewTag2 || Map_default && getTag(new Map_default()) != mapTag2 || Promise_default && getTag(Promise_default.resolve()) != promiseTag || Set_default && getTag(new Set_default()) != setTag2 || WeakMap_default && getTag(new WeakMap_default()) != weakMapTag2) {
27902     getTag = function(value) {
27903       var result = baseGetTag_default(value), Ctor = result == objectTag2 ? value.constructor : void 0, ctorString = Ctor ? toSource_default(Ctor) : "";
27904       if (ctorString) {
27905         switch (ctorString) {
27906           case dataViewCtorString:
27907             return dataViewTag2;
27908           case mapCtorString:
27909             return mapTag2;
27910           case promiseCtorString:
27911             return promiseTag;
27912           case setCtorString:
27913             return setTag2;
27914           case weakMapCtorString:
27915             return weakMapTag2;
27916         }
27917       }
27918       return result;
27919     };
27920   }
27921   var getTag_default = getTag;
27922
27923   // node_modules/lodash-es/_Uint8Array.js
27924   var Uint8Array2 = root_default.Uint8Array;
27925   var Uint8Array_default = Uint8Array2;
27926
27927   // node_modules/lodash-es/_setCacheAdd.js
27928   var HASH_UNDEFINED3 = "__lodash_hash_undefined__";
27929   function setCacheAdd(value) {
27930     this.__data__.set(value, HASH_UNDEFINED3);
27931     return this;
27932   }
27933   var setCacheAdd_default = setCacheAdd;
27934
27935   // node_modules/lodash-es/_setCacheHas.js
27936   function setCacheHas(value) {
27937     return this.__data__.has(value);
27938   }
27939   var setCacheHas_default = setCacheHas;
27940
27941   // node_modules/lodash-es/_SetCache.js
27942   function SetCache(values) {
27943     var index = -1, length2 = values == null ? 0 : values.length;
27944     this.__data__ = new MapCache_default();
27945     while (++index < length2) {
27946       this.add(values[index]);
27947     }
27948   }
27949   SetCache.prototype.add = SetCache.prototype.push = setCacheAdd_default;
27950   SetCache.prototype.has = setCacheHas_default;
27951   var SetCache_default = SetCache;
27952
27953   // node_modules/lodash-es/_arraySome.js
27954   function arraySome(array2, predicate) {
27955     var index = -1, length2 = array2 == null ? 0 : array2.length;
27956     while (++index < length2) {
27957       if (predicate(array2[index], index, array2)) {
27958         return true;
27959       }
27960     }
27961     return false;
27962   }
27963   var arraySome_default = arraySome;
27964
27965   // node_modules/lodash-es/_cacheHas.js
27966   function cacheHas(cache, key) {
27967     return cache.has(key);
27968   }
27969   var cacheHas_default = cacheHas;
27970
27971   // node_modules/lodash-es/_equalArrays.js
27972   var COMPARE_PARTIAL_FLAG = 1;
27973   var COMPARE_UNORDERED_FLAG = 2;
27974   function equalArrays(array2, other, bitmask, customizer, equalFunc, stack) {
27975     var isPartial = bitmask & COMPARE_PARTIAL_FLAG, arrLength = array2.length, othLength = other.length;
27976     if (arrLength != othLength && !(isPartial && othLength > arrLength)) {
27977       return false;
27978     }
27979     var arrStacked = stack.get(array2);
27980     var othStacked = stack.get(other);
27981     if (arrStacked && othStacked) {
27982       return arrStacked == other && othStacked == array2;
27983     }
27984     var index = -1, result = true, seen = bitmask & COMPARE_UNORDERED_FLAG ? new SetCache_default() : void 0;
27985     stack.set(array2, other);
27986     stack.set(other, array2);
27987     while (++index < arrLength) {
27988       var arrValue = array2[index], othValue = other[index];
27989       if (customizer) {
27990         var compared = isPartial ? customizer(othValue, arrValue, index, other, array2, stack) : customizer(arrValue, othValue, index, array2, other, stack);
27991       }
27992       if (compared !== void 0) {
27993         if (compared) {
27994           continue;
27995         }
27996         result = false;
27997         break;
27998       }
27999       if (seen) {
28000         if (!arraySome_default(other, function(othValue2, othIndex) {
28001           if (!cacheHas_default(seen, othIndex) && (arrValue === othValue2 || equalFunc(arrValue, othValue2, bitmask, customizer, stack))) {
28002             return seen.push(othIndex);
28003           }
28004         })) {
28005           result = false;
28006           break;
28007         }
28008       } else if (!(arrValue === othValue || equalFunc(arrValue, othValue, bitmask, customizer, stack))) {
28009         result = false;
28010         break;
28011       }
28012     }
28013     stack["delete"](array2);
28014     stack["delete"](other);
28015     return result;
28016   }
28017   var equalArrays_default = equalArrays;
28018
28019   // node_modules/lodash-es/_mapToArray.js
28020   function mapToArray(map2) {
28021     var index = -1, result = Array(map2.size);
28022     map2.forEach(function(value, key) {
28023       result[++index] = [key, value];
28024     });
28025     return result;
28026   }
28027   var mapToArray_default = mapToArray;
28028
28029   // node_modules/lodash-es/_setToArray.js
28030   function setToArray(set4) {
28031     var index = -1, result = Array(set4.size);
28032     set4.forEach(function(value) {
28033       result[++index] = value;
28034     });
28035     return result;
28036   }
28037   var setToArray_default = setToArray;
28038
28039   // node_modules/lodash-es/_equalByTag.js
28040   var COMPARE_PARTIAL_FLAG2 = 1;
28041   var COMPARE_UNORDERED_FLAG2 = 2;
28042   var boolTag2 = "[object Boolean]";
28043   var dateTag2 = "[object Date]";
28044   var errorTag2 = "[object Error]";
28045   var mapTag3 = "[object Map]";
28046   var numberTag2 = "[object Number]";
28047   var regexpTag2 = "[object RegExp]";
28048   var setTag3 = "[object Set]";
28049   var stringTag2 = "[object String]";
28050   var symbolTag2 = "[object Symbol]";
28051   var arrayBufferTag2 = "[object ArrayBuffer]";
28052   var dataViewTag3 = "[object DataView]";
28053   var symbolProto2 = Symbol_default ? Symbol_default.prototype : void 0;
28054   var symbolValueOf = symbolProto2 ? symbolProto2.valueOf : void 0;
28055   function equalByTag(object, other, tag2, bitmask, customizer, equalFunc, stack) {
28056     switch (tag2) {
28057       case dataViewTag3:
28058         if (object.byteLength != other.byteLength || object.byteOffset != other.byteOffset) {
28059           return false;
28060         }
28061         object = object.buffer;
28062         other = other.buffer;
28063       case arrayBufferTag2:
28064         if (object.byteLength != other.byteLength || !equalFunc(new Uint8Array_default(object), new Uint8Array_default(other))) {
28065           return false;
28066         }
28067         return true;
28068       case boolTag2:
28069       case dateTag2:
28070       case numberTag2:
28071         return eq_default(+object, +other);
28072       case errorTag2:
28073         return object.name == other.name && object.message == other.message;
28074       case regexpTag2:
28075       case stringTag2:
28076         return object == other + "";
28077       case mapTag3:
28078         var convert = mapToArray_default;
28079       case setTag3:
28080         var isPartial = bitmask & COMPARE_PARTIAL_FLAG2;
28081         convert || (convert = setToArray_default);
28082         if (object.size != other.size && !isPartial) {
28083           return false;
28084         }
28085         var stacked = stack.get(object);
28086         if (stacked) {
28087           return stacked == other;
28088         }
28089         bitmask |= COMPARE_UNORDERED_FLAG2;
28090         stack.set(object, other);
28091         var result = equalArrays_default(convert(object), convert(other), bitmask, customizer, equalFunc, stack);
28092         stack["delete"](object);
28093         return result;
28094       case symbolTag2:
28095         if (symbolValueOf) {
28096           return symbolValueOf.call(object) == symbolValueOf.call(other);
28097         }
28098     }
28099     return false;
28100   }
28101   var equalByTag_default = equalByTag;
28102
28103   // node_modules/lodash-es/_equalObjects.js
28104   var COMPARE_PARTIAL_FLAG3 = 1;
28105   var objectProto11 = Object.prototype;
28106   var hasOwnProperty8 = objectProto11.hasOwnProperty;
28107   function equalObjects(object, other, bitmask, customizer, equalFunc, stack) {
28108     var isPartial = bitmask & COMPARE_PARTIAL_FLAG3, objProps = getAllKeys_default(object), objLength = objProps.length, othProps = getAllKeys_default(other), othLength = othProps.length;
28109     if (objLength != othLength && !isPartial) {
28110       return false;
28111     }
28112     var index = objLength;
28113     while (index--) {
28114       var key = objProps[index];
28115       if (!(isPartial ? key in other : hasOwnProperty8.call(other, key))) {
28116         return false;
28117       }
28118     }
28119     var objStacked = stack.get(object);
28120     var othStacked = stack.get(other);
28121     if (objStacked && othStacked) {
28122       return objStacked == other && othStacked == object;
28123     }
28124     var result = true;
28125     stack.set(object, other);
28126     stack.set(other, object);
28127     var skipCtor = isPartial;
28128     while (++index < objLength) {
28129       key = objProps[index];
28130       var objValue = object[key], othValue = other[key];
28131       if (customizer) {
28132         var compared = isPartial ? customizer(othValue, objValue, key, other, object, stack) : customizer(objValue, othValue, key, object, other, stack);
28133       }
28134       if (!(compared === void 0 ? objValue === othValue || equalFunc(objValue, othValue, bitmask, customizer, stack) : compared)) {
28135         result = false;
28136         break;
28137       }
28138       skipCtor || (skipCtor = key == "constructor");
28139     }
28140     if (result && !skipCtor) {
28141       var objCtor = object.constructor, othCtor = other.constructor;
28142       if (objCtor != othCtor && ("constructor" in object && "constructor" in other) && !(typeof objCtor == "function" && objCtor instanceof objCtor && typeof othCtor == "function" && othCtor instanceof othCtor)) {
28143         result = false;
28144       }
28145     }
28146     stack["delete"](object);
28147     stack["delete"](other);
28148     return result;
28149   }
28150   var equalObjects_default = equalObjects;
28151
28152   // node_modules/lodash-es/_baseIsEqualDeep.js
28153   var COMPARE_PARTIAL_FLAG4 = 1;
28154   var argsTag3 = "[object Arguments]";
28155   var arrayTag2 = "[object Array]";
28156   var objectTag3 = "[object Object]";
28157   var objectProto12 = Object.prototype;
28158   var hasOwnProperty9 = objectProto12.hasOwnProperty;
28159   function baseIsEqualDeep(object, other, bitmask, customizer, equalFunc, stack) {
28160     var objIsArr = isArray_default(object), othIsArr = isArray_default(other), objTag = objIsArr ? arrayTag2 : getTag_default(object), othTag = othIsArr ? arrayTag2 : getTag_default(other);
28161     objTag = objTag == argsTag3 ? objectTag3 : objTag;
28162     othTag = othTag == argsTag3 ? objectTag3 : othTag;
28163     var objIsObj = objTag == objectTag3, othIsObj = othTag == objectTag3, isSameTag = objTag == othTag;
28164     if (isSameTag && isBuffer_default(object)) {
28165       if (!isBuffer_default(other)) {
28166         return false;
28167       }
28168       objIsArr = true;
28169       objIsObj = false;
28170     }
28171     if (isSameTag && !objIsObj) {
28172       stack || (stack = new Stack_default());
28173       return objIsArr || isTypedArray_default(object) ? equalArrays_default(object, other, bitmask, customizer, equalFunc, stack) : equalByTag_default(object, other, objTag, bitmask, customizer, equalFunc, stack);
28174     }
28175     if (!(bitmask & COMPARE_PARTIAL_FLAG4)) {
28176       var objIsWrapped = objIsObj && hasOwnProperty9.call(object, "__wrapped__"), othIsWrapped = othIsObj && hasOwnProperty9.call(other, "__wrapped__");
28177       if (objIsWrapped || othIsWrapped) {
28178         var objUnwrapped = objIsWrapped ? object.value() : object, othUnwrapped = othIsWrapped ? other.value() : other;
28179         stack || (stack = new Stack_default());
28180         return equalFunc(objUnwrapped, othUnwrapped, bitmask, customizer, stack);
28181       }
28182     }
28183     if (!isSameTag) {
28184       return false;
28185     }
28186     stack || (stack = new Stack_default());
28187     return equalObjects_default(object, other, bitmask, customizer, equalFunc, stack);
28188   }
28189   var baseIsEqualDeep_default = baseIsEqualDeep;
28190
28191   // node_modules/lodash-es/_baseIsEqual.js
28192   function baseIsEqual(value, other, bitmask, customizer, stack) {
28193     if (value === other) {
28194       return true;
28195     }
28196     if (value == null || other == null || !isObjectLike_default(value) && !isObjectLike_default(other)) {
28197       return value !== value && other !== other;
28198     }
28199     return baseIsEqualDeep_default(value, other, bitmask, customizer, baseIsEqual, stack);
28200   }
28201   var baseIsEqual_default = baseIsEqual;
28202
28203   // node_modules/lodash-es/now.js
28204   var now2 = function() {
28205     return root_default.Date.now();
28206   };
28207   var now_default = now2;
28208
28209   // node_modules/lodash-es/debounce.js
28210   var FUNC_ERROR_TEXT = "Expected a function";
28211   var nativeMax = Math.max;
28212   var nativeMin = Math.min;
28213   function debounce(func, wait, options2) {
28214     var lastArgs, lastThis, maxWait, result, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
28215     if (typeof func != "function") {
28216       throw new TypeError(FUNC_ERROR_TEXT);
28217     }
28218     wait = toNumber_default(wait) || 0;
28219     if (isObject_default(options2)) {
28220       leading = !!options2.leading;
28221       maxing = "maxWait" in options2;
28222       maxWait = maxing ? nativeMax(toNumber_default(options2.maxWait) || 0, wait) : maxWait;
28223       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
28224     }
28225     function invokeFunc(time) {
28226       var args = lastArgs, thisArg = lastThis;
28227       lastArgs = lastThis = void 0;
28228       lastInvokeTime = time;
28229       result = func.apply(thisArg, args);
28230       return result;
28231     }
28232     function leadingEdge(time) {
28233       lastInvokeTime = time;
28234       timerId = setTimeout(timerExpired, wait);
28235       return leading ? invokeFunc(time) : result;
28236     }
28237     function remainingWait(time) {
28238       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime, timeWaiting = wait - timeSinceLastCall;
28239       return maxing ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke) : timeWaiting;
28240     }
28241     function shouldInvoke(time) {
28242       var timeSinceLastCall = time - lastCallTime, timeSinceLastInvoke = time - lastInvokeTime;
28243       return lastCallTime === void 0 || timeSinceLastCall >= wait || timeSinceLastCall < 0 || maxing && timeSinceLastInvoke >= maxWait;
28244     }
28245     function timerExpired() {
28246       var time = now_default();
28247       if (shouldInvoke(time)) {
28248         return trailingEdge(time);
28249       }
28250       timerId = setTimeout(timerExpired, remainingWait(time));
28251     }
28252     function trailingEdge(time) {
28253       timerId = void 0;
28254       if (trailing && lastArgs) {
28255         return invokeFunc(time);
28256       }
28257       lastArgs = lastThis = void 0;
28258       return result;
28259     }
28260     function cancel() {
28261       if (timerId !== void 0) {
28262         clearTimeout(timerId);
28263       }
28264       lastInvokeTime = 0;
28265       lastArgs = lastCallTime = lastThis = timerId = void 0;
28266     }
28267     function flush() {
28268       return timerId === void 0 ? result : trailingEdge(now_default());
28269     }
28270     function debounced() {
28271       var time = now_default(), isInvoking = shouldInvoke(time);
28272       lastArgs = arguments;
28273       lastThis = this;
28274       lastCallTime = time;
28275       if (isInvoking) {
28276         if (timerId === void 0) {
28277           return leadingEdge(lastCallTime);
28278         }
28279         if (maxing) {
28280           clearTimeout(timerId);
28281           timerId = setTimeout(timerExpired, wait);
28282           return invokeFunc(lastCallTime);
28283         }
28284       }
28285       if (timerId === void 0) {
28286         timerId = setTimeout(timerExpired, wait);
28287       }
28288       return result;
28289     }
28290     debounced.cancel = cancel;
28291     debounced.flush = flush;
28292     return debounced;
28293   }
28294   var debounce_default = debounce;
28295
28296   // node_modules/lodash-es/_escapeHtmlChar.js
28297   var htmlEscapes = {
28298     "&": "&amp;",
28299     "<": "&lt;",
28300     ">": "&gt;",
28301     '"': "&quot;",
28302     "'": "&#39;"
28303   };
28304   var escapeHtmlChar = basePropertyOf_default(htmlEscapes);
28305   var escapeHtmlChar_default = escapeHtmlChar;
28306
28307   // node_modules/lodash-es/escape.js
28308   var reUnescapedHtml = /[&<>"']/g;
28309   var reHasUnescapedHtml = RegExp(reUnescapedHtml.source);
28310   function escape2(string) {
28311     string = toString_default(string);
28312     return string && reHasUnescapedHtml.test(string) ? string.replace(reUnescapedHtml, escapeHtmlChar_default) : string;
28313   }
28314   var escape_default = escape2;
28315
28316   // node_modules/lodash-es/isEqual.js
28317   function isEqual(value, other) {
28318     return baseIsEqual_default(value, other);
28319   }
28320   var isEqual_default = isEqual;
28321
28322   // node_modules/lodash-es/isNumber.js
28323   var numberTag3 = "[object Number]";
28324   function isNumber(value) {
28325     return typeof value == "number" || isObjectLike_default(value) && baseGetTag_default(value) == numberTag3;
28326   }
28327   var isNumber_default = isNumber;
28328
28329   // node_modules/lodash-es/throttle.js
28330   var FUNC_ERROR_TEXT2 = "Expected a function";
28331   function throttle(func, wait, options2) {
28332     var leading = true, trailing = true;
28333     if (typeof func != "function") {
28334       throw new TypeError(FUNC_ERROR_TEXT2);
28335     }
28336     if (isObject_default(options2)) {
28337       leading = "leading" in options2 ? !!options2.leading : leading;
28338       trailing = "trailing" in options2 ? !!options2.trailing : trailing;
28339     }
28340     return debounce_default(func, wait, {
28341       "leading": leading,
28342       "maxWait": wait,
28343       "trailing": trailing
28344     });
28345   }
28346   var throttle_default = throttle;
28347
28348   // node_modules/lodash-es/_unescapeHtmlChar.js
28349   var htmlUnescapes = {
28350     "&amp;": "&",
28351     "&lt;": "<",
28352     "&gt;": ">",
28353     "&quot;": '"',
28354     "&#39;": "'"
28355   };
28356   var unescapeHtmlChar = basePropertyOf_default(htmlUnescapes);
28357   var unescapeHtmlChar_default = unescapeHtmlChar;
28358
28359   // node_modules/lodash-es/unescape.js
28360   var reEscapedHtml = /&(?:amp|lt|gt|quot|#39);/g;
28361   var reHasEscapedHtml = RegExp(reEscapedHtml.source);
28362   function unescape(string) {
28363     string = toString_default(string);
28364     return string && reHasEscapedHtml.test(string) ? string.replace(reEscapedHtml, unescapeHtmlChar_default) : string;
28365   }
28366   var unescape_default = unescape;
28367
28368   // modules/util/detect.js
28369   var _detected;
28370   function utilDetect(refresh2) {
28371     if (_detected && !refresh2)
28372       return _detected;
28373     _detected = {};
28374     const ua = navigator.userAgent;
28375     let m2 = null;
28376     m2 = ua.match(/(edge)\/?\s*(\.?\d+(\.\d+)*)/i);
28377     if (m2 !== null) {
28378       _detected.browser = m2[1];
28379       _detected.version = m2[2];
28380     }
28381     if (!_detected.browser) {
28382       m2 = ua.match(/Trident\/.*rv:([0-9]{1,}[\.0-9]{0,})/i);
28383       if (m2 !== null) {
28384         _detected.browser = "msie";
28385         _detected.version = m2[1];
28386       }
28387     }
28388     if (!_detected.browser) {
28389       m2 = ua.match(/(opr)\/?\s*(\.?\d+(\.\d+)*)/i);
28390       if (m2 !== null) {
28391         _detected.browser = "Opera";
28392         _detected.version = m2[2];
28393       }
28394     }
28395     if (!_detected.browser) {
28396       m2 = ua.match(/(opera|chrome|safari|firefox|msie)\/?\s*(\.?\d+(\.\d+)*)/i);
28397       if (m2 !== null) {
28398         _detected.browser = m2[1];
28399         _detected.version = m2[2];
28400         m2 = ua.match(/version\/([\.\d]+)/i);
28401         if (m2 !== null)
28402           _detected.version = m2[1];
28403       }
28404     }
28405     if (!_detected.browser) {
28406       _detected.browser = navigator.appName;
28407       _detected.version = navigator.appVersion;
28408     }
28409     _detected.version = _detected.version.split(/\W/).slice(0, 2).join(".");
28410     _detected.opera = _detected.browser.toLowerCase() === "opera" && Number(_detected.version) < 15;
28411     if (_detected.browser.toLowerCase() === "msie") {
28412       _detected.ie = true;
28413       _detected.browser = "Internet Explorer";
28414       _detected.support = false;
28415     } else {
28416       _detected.ie = false;
28417       _detected.support = true;
28418     }
28419     _detected.filedrop = window.FileReader && "ondrop" in window;
28420     if (/Win/.test(ua)) {
28421       _detected.os = "win";
28422       _detected.platform = "Windows";
28423     } else if (/Mac/.test(ua)) {
28424       _detected.os = "mac";
28425       _detected.platform = "Macintosh";
28426     } else if (/X11/.test(ua) || /Linux/.test(ua)) {
28427       _detected.os = "linux";
28428       _detected.platform = "Linux";
28429     } else {
28430       _detected.os = "win";
28431       _detected.platform = "Unknown";
28432     }
28433     _detected.isMobileWebKit = (/\b(iPad|iPhone|iPod)\b/.test(ua) || // HACK: iPadOS 13+ requests desktop sites by default by using a Mac user agent,
28434     // so assume any "mac" with multitouch is actually iOS
28435     navigator.platform === "MacIntel" && "maxTouchPoints" in navigator && navigator.maxTouchPoints > 1) && /WebKit/.test(ua) && !/Edge/.test(ua) && !window.MSStream;
28436     _detected.browserLocales = Array.from(new Set(
28437       // remove duplicates
28438       [navigator.language].concat(navigator.languages || []).concat([
28439         // old property for backwards compatibility
28440         navigator.userLanguage
28441       ]).filter(Boolean)
28442     ));
28443     const loc = window.top.location;
28444     let origin = loc.origin;
28445     if (!origin) {
28446       origin = loc.protocol + "//" + loc.hostname + (loc.port ? ":" + loc.port : "");
28447     }
28448     _detected.host = origin + loc.pathname;
28449     return _detected;
28450   }
28451
28452   // modules/util/aes.js
28453   var import_aes_js = __toESM(require_aes_js());
28454   var DEFAULT_128 = [250, 157, 60, 79, 142, 134, 229, 129, 138, 126, 210, 129, 29, 71, 160, 208];
28455   function utilAesEncrypt(text, key) {
28456     key = key || DEFAULT_128;
28457     const textBytes = import_aes_js.default.utils.utf8.toBytes(text);
28458     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
28459     const encryptedBytes = aesCtr.encrypt(textBytes);
28460     const encryptedHex = import_aes_js.default.utils.hex.fromBytes(encryptedBytes);
28461     return encryptedHex;
28462   }
28463   function utilAesDecrypt(encryptedHex, key) {
28464     key = key || DEFAULT_128;
28465     const encryptedBytes = import_aes_js.default.utils.hex.toBytes(encryptedHex);
28466     const aesCtr = new import_aes_js.default.ModeOfOperation.ctr(key);
28467     const decryptedBytes = aesCtr.decrypt(encryptedBytes);
28468     const text = import_aes_js.default.utils.utf8.fromBytes(decryptedBytes);
28469     return text;
28470   }
28471
28472   // modules/util/clean_tags.js
28473   function utilCleanTags(tags) {
28474     var out = {};
28475     for (var k2 in tags) {
28476       if (!k2)
28477         continue;
28478       var v2 = tags[k2];
28479       if (v2 !== void 0) {
28480         out[k2] = cleanValue(k2, v2);
28481       }
28482     }
28483     return out;
28484     function cleanValue(k3, v3) {
28485       function keepSpaces(k4) {
28486         return /_hours|_times|:conditional$/.test(k4);
28487       }
28488       function skip(k4) {
28489         return /^(description|note|fixme)$/.test(k4);
28490       }
28491       if (skip(k3))
28492         return v3;
28493       var cleaned = v3.split(";").map(function(s2) {
28494         return s2.trim();
28495       }).join(keepSpaces(k3) ? "; " : ";");
28496       if (k3.indexOf("website") !== -1 || k3.indexOf("email") !== -1 || cleaned.indexOf("http") === 0) {
28497         cleaned = cleaned.replace(/[\u200B-\u200F\uFEFF]/g, "");
28498       }
28499       return cleaned;
28500     }
28501   }
28502
28503   // modules/util/get_set_value.js
28504   function utilGetSetValue(selection2, value, shouldUpdate) {
28505     function setValue(value2, shouldUpdate2) {
28506       function valueNull() {
28507         delete this.value;
28508       }
28509       function valueConstant() {
28510         if (shouldUpdate2(this.value, value2)) {
28511           this.value = value2;
28512         }
28513       }
28514       function valueFunction() {
28515         var x2 = value2.apply(this, arguments);
28516         if (x2 === null || x2 === void 0) {
28517           delete this.value;
28518         } else if (shouldUpdate2(this.value, x2)) {
28519           this.value = x2;
28520         }
28521       }
28522       return value2 === null || value2 === void 0 ? valueNull : typeof value2 === "function" ? valueFunction : valueConstant;
28523     }
28524     if (arguments.length === 1) {
28525       return selection2.property("value");
28526     }
28527     if (shouldUpdate === void 0) {
28528       shouldUpdate = (a2, b2) => a2 !== b2;
28529     }
28530     return selection2.each(setValue(value, shouldUpdate));
28531   }
28532
28533   // modules/util/keybinding.js
28534   function utilKeybinding(namespace) {
28535     var _keybindings = {};
28536     function testBindings(d3_event, isCapturing) {
28537       var didMatch = false;
28538       var bindings = Object.keys(_keybindings).map(function(id2) {
28539         return _keybindings[id2];
28540       });
28541       var i3, binding;
28542       for (i3 = 0; i3 < bindings.length; i3++) {
28543         binding = bindings[i3];
28544         if (!binding.event.modifiers.shiftKey)
28545           continue;
28546         if (!!binding.capture !== isCapturing)
28547           continue;
28548         if (matches(d3_event, binding, true)) {
28549           binding.callback(d3_event);
28550           didMatch = true;
28551           break;
28552         }
28553       }
28554       if (didMatch)
28555         return;
28556       for (i3 = 0; i3 < bindings.length; i3++) {
28557         binding = bindings[i3];
28558         if (binding.event.modifiers.shiftKey)
28559           continue;
28560         if (!!binding.capture !== isCapturing)
28561           continue;
28562         if (matches(d3_event, binding, false)) {
28563           binding.callback(d3_event);
28564           break;
28565         }
28566       }
28567       function matches(d3_event2, binding2, testShift) {
28568         var event = d3_event2;
28569         var isMatch = false;
28570         var tryKeyCode = true;
28571         if (event.key !== void 0) {
28572           tryKeyCode = event.key.charCodeAt(0) > 127;
28573           isMatch = true;
28574           if (binding2.event.key === void 0) {
28575             isMatch = false;
28576           } else if (Array.isArray(binding2.event.key)) {
28577             if (binding2.event.key.map(function(s2) {
28578               return s2.toLowerCase();
28579             }).indexOf(event.key.toLowerCase()) === -1) {
28580               isMatch = false;
28581             }
28582           } else {
28583             if (event.key.toLowerCase() !== binding2.event.key.toLowerCase()) {
28584               isMatch = false;
28585             }
28586           }
28587         }
28588         if (!isMatch && (tryKeyCode || binding2.event.modifiers.altKey)) {
28589           isMatch = event.keyCode === binding2.event.keyCode;
28590         }
28591         if (!isMatch)
28592           return false;
28593         if (!(event.ctrlKey && event.altKey)) {
28594           if (event.ctrlKey !== binding2.event.modifiers.ctrlKey)
28595             return false;
28596           if (event.altKey !== binding2.event.modifiers.altKey)
28597             return false;
28598         }
28599         if (event.metaKey !== binding2.event.modifiers.metaKey)
28600           return false;
28601         if (testShift && event.shiftKey !== binding2.event.modifiers.shiftKey)
28602           return false;
28603         return true;
28604       }
28605     }
28606     function capture(d3_event) {
28607       testBindings(d3_event, true);
28608     }
28609     function bubble(d3_event) {
28610       var tagName = select_default2(d3_event.target).node().tagName;
28611       if (tagName === "INPUT" || tagName === "SELECT" || tagName === "TEXTAREA") {
28612         return;
28613       }
28614       testBindings(d3_event, false);
28615     }
28616     function keybinding(selection2) {
28617       selection2 = selection2 || select_default2(document);
28618       selection2.on("keydown.capture." + namespace, capture, true);
28619       selection2.on("keydown.bubble." + namespace, bubble, false);
28620       return keybinding;
28621     }
28622     keybinding.unbind = function(selection2) {
28623       _keybindings = [];
28624       selection2 = selection2 || select_default2(document);
28625       selection2.on("keydown.capture." + namespace, null);
28626       selection2.on("keydown.bubble." + namespace, null);
28627       return keybinding;
28628     };
28629     keybinding.clear = function() {
28630       _keybindings = {};
28631       return keybinding;
28632     };
28633     keybinding.off = function(codes, capture2) {
28634       var arr = utilArrayUniq([].concat(codes));
28635       for (var i3 = 0; i3 < arr.length; i3++) {
28636         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
28637         delete _keybindings[id2];
28638       }
28639       return keybinding;
28640     };
28641     keybinding.on = function(codes, callback, capture2) {
28642       if (typeof callback !== "function") {
28643         return keybinding.off(codes, capture2);
28644       }
28645       var arr = utilArrayUniq([].concat(codes));
28646       for (var i3 = 0; i3 < arr.length; i3++) {
28647         var id2 = arr[i3] + (capture2 ? "-capture" : "-bubble");
28648         var binding = {
28649           id: id2,
28650           capture: capture2,
28651           callback,
28652           event: {
28653             key: void 0,
28654             // preferred
28655             keyCode: 0,
28656             // fallback
28657             modifiers: {
28658               shiftKey: false,
28659               ctrlKey: false,
28660               altKey: false,
28661               metaKey: false
28662             }
28663           }
28664         };
28665         if (_keybindings[id2]) {
28666           console.warn('warning: duplicate keybinding for "' + id2 + '"');
28667         }
28668         _keybindings[id2] = binding;
28669         var matches = arr[i3].toLowerCase().match(/(?:(?:[^+⇧⌃⌥⌘])+|[⇧⌃⌥⌘]|\+\+|^\+$)/g);
28670         for (var j2 = 0; j2 < matches.length; j2++) {
28671           if (matches[j2] === "++")
28672             matches[j2] = "+";
28673           if (matches[j2] in utilKeybinding.modifierCodes) {
28674             var prop = utilKeybinding.modifierProperties[utilKeybinding.modifierCodes[matches[j2]]];
28675             binding.event.modifiers[prop] = true;
28676           } else {
28677             binding.event.key = utilKeybinding.keys[matches[j2]] || matches[j2];
28678             if (matches[j2] in utilKeybinding.keyCodes) {
28679               binding.event.keyCode = utilKeybinding.keyCodes[matches[j2]];
28680             }
28681           }
28682         }
28683       }
28684       return keybinding;
28685     };
28686     return keybinding;
28687   }
28688   utilKeybinding.modifierCodes = {
28689     // Shift key, ⇧
28690     "\u21E7": 16,
28691     shift: 16,
28692     // CTRL key, on Mac: ⌃
28693     "\u2303": 17,
28694     ctrl: 17,
28695     // ALT key, on Mac: ⌥ (Alt)
28696     "\u2325": 18,
28697     alt: 18,
28698     option: 18,
28699     // META, on Mac: ⌘ (CMD), on Windows (Win), on Linux (Super)
28700     "\u2318": 91,
28701     meta: 91,
28702     cmd: 91,
28703     "super": 91,
28704     win: 91
28705   };
28706   utilKeybinding.modifierProperties = {
28707     16: "shiftKey",
28708     17: "ctrlKey",
28709     18: "altKey",
28710     91: "metaKey"
28711   };
28712   utilKeybinding.plusKeys = ["plus", "ffplus", "=", "ffequals", "\u2260", "\xB1"];
28713   utilKeybinding.minusKeys = ["_", "-", "ffminus", "dash", "\u2013", "\u2014"];
28714   utilKeybinding.keys = {
28715     // Backspace key, on Mac: ⌫ (Backspace)
28716     "\u232B": "Backspace",
28717     backspace: "Backspace",
28718     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
28719     "\u21E5": "Tab",
28720     "\u21C6": "Tab",
28721     tab: "Tab",
28722     // Return key, ↩
28723     "\u21A9": "Enter",
28724     "\u21B5": "Enter",
28725     "\u23CE": "Enter",
28726     "return": "Enter",
28727     enter: "Enter",
28728     "\u2305": "Enter",
28729     // Pause/Break key
28730     "pause": "Pause",
28731     "pause-break": "Pause",
28732     // Caps Lock key, ⇪
28733     "\u21EA": "CapsLock",
28734     caps: "CapsLock",
28735     "caps-lock": "CapsLock",
28736     // Escape key, on Mac: ⎋, on Windows: Esc
28737     "\u238B": ["Escape", "Esc"],
28738     escape: ["Escape", "Esc"],
28739     esc: ["Escape", "Esc"],
28740     // Space key
28741     space: [" ", "Spacebar"],
28742     // Page-Up key, or pgup, on Mac: ↖
28743     "\u2196": "PageUp",
28744     pgup: "PageUp",
28745     "page-up": "PageUp",
28746     // Page-Down key, or pgdown, on Mac: ↘
28747     "\u2198": "PageDown",
28748     pgdown: "PageDown",
28749     "page-down": "PageDown",
28750     // END key, on Mac: ⇟
28751     "\u21DF": "End",
28752     end: "End",
28753     // HOME key, on Mac: ⇞
28754     "\u21DE": "Home",
28755     home: "Home",
28756     // Insert key, or ins
28757     ins: "Insert",
28758     insert: "Insert",
28759     // Delete key, on Mac: ⌦ (Delete)
28760     "\u2326": ["Delete", "Del"],
28761     del: ["Delete", "Del"],
28762     "delete": ["Delete", "Del"],
28763     // Left Arrow Key, or ←
28764     "\u2190": ["ArrowLeft", "Left"],
28765     left: ["ArrowLeft", "Left"],
28766     "arrow-left": ["ArrowLeft", "Left"],
28767     // Up Arrow Key, or ↑
28768     "\u2191": ["ArrowUp", "Up"],
28769     up: ["ArrowUp", "Up"],
28770     "arrow-up": ["ArrowUp", "Up"],
28771     // Right Arrow Key, or →
28772     "\u2192": ["ArrowRight", "Right"],
28773     right: ["ArrowRight", "Right"],
28774     "arrow-right": ["ArrowRight", "Right"],
28775     // Up Arrow Key, or ↓
28776     "\u2193": ["ArrowDown", "Down"],
28777     down: ["ArrowDown", "Down"],
28778     "arrow-down": ["ArrowDown", "Down"],
28779     // odities, stuff for backward compatibility (browsers and code):
28780     // Num-Multiply, or *
28781     "*": ["*", "Multiply"],
28782     star: ["*", "Multiply"],
28783     asterisk: ["*", "Multiply"],
28784     multiply: ["*", "Multiply"],
28785     // Num-Plus or +
28786     "+": ["+", "Add"],
28787     "plus": ["+", "Add"],
28788     // Num-Subtract, or -
28789     "-": ["-", "Subtract"],
28790     subtract: ["-", "Subtract"],
28791     "dash": ["-", "Subtract"],
28792     // Semicolon
28793     semicolon: ";",
28794     // = or equals
28795     equals: "=",
28796     // Comma, or ,
28797     comma: ",",
28798     // Period, or ., or full-stop
28799     period: ".",
28800     "full-stop": ".",
28801     // Slash, or /, or forward-slash
28802     slash: "/",
28803     "forward-slash": "/",
28804     // Tick, or `, or back-quote
28805     tick: "`",
28806     "back-quote": "`",
28807     // Open bracket, or [
28808     "open-bracket": "[",
28809     // Back slash, or \
28810     "back-slash": "\\",
28811     // Close bracket, or ]
28812     "close-bracket": "]",
28813     // Apostrophe, or Quote, or '
28814     quote: "'",
28815     apostrophe: "'",
28816     // NUMPAD 0-9
28817     "num-0": "0",
28818     "num-1": "1",
28819     "num-2": "2",
28820     "num-3": "3",
28821     "num-4": "4",
28822     "num-5": "5",
28823     "num-6": "6",
28824     "num-7": "7",
28825     "num-8": "8",
28826     "num-9": "9",
28827     // F1-F25
28828     f1: "F1",
28829     f2: "F2",
28830     f3: "F3",
28831     f4: "F4",
28832     f5: "F5",
28833     f6: "F6",
28834     f7: "F7",
28835     f8: "F8",
28836     f9: "F9",
28837     f10: "F10",
28838     f11: "F11",
28839     f12: "F12",
28840     f13: "F13",
28841     f14: "F14",
28842     f15: "F15",
28843     f16: "F16",
28844     f17: "F17",
28845     f18: "F18",
28846     f19: "F19",
28847     f20: "F20",
28848     f21: "F21",
28849     f22: "F22",
28850     f23: "F23",
28851     f24: "F24",
28852     f25: "F25"
28853   };
28854   utilKeybinding.keyCodes = {
28855     // Backspace key, on Mac: ⌫ (Backspace)
28856     "\u232B": 8,
28857     backspace: 8,
28858     // Tab Key, on Mac: ⇥ (Tab), on Windows ⇥⇥
28859     "\u21E5": 9,
28860     "\u21C6": 9,
28861     tab: 9,
28862     // Return key, ↩
28863     "\u21A9": 13,
28864     "\u21B5": 13,
28865     "\u23CE": 13,
28866     "return": 13,
28867     enter: 13,
28868     "\u2305": 13,
28869     // Pause/Break key
28870     "pause": 19,
28871     "pause-break": 19,
28872     // Caps Lock key, ⇪
28873     "\u21EA": 20,
28874     caps: 20,
28875     "caps-lock": 20,
28876     // Escape key, on Mac: ⎋, on Windows: Esc
28877     "\u238B": 27,
28878     escape: 27,
28879     esc: 27,
28880     // Space key
28881     space: 32,
28882     // Page-Up key, or pgup, on Mac: ↖
28883     "\u2196": 33,
28884     pgup: 33,
28885     "page-up": 33,
28886     // Page-Down key, or pgdown, on Mac: ↘
28887     "\u2198": 34,
28888     pgdown: 34,
28889     "page-down": 34,
28890     // END key, on Mac: ⇟
28891     "\u21DF": 35,
28892     end: 35,
28893     // HOME key, on Mac: ⇞
28894     "\u21DE": 36,
28895     home: 36,
28896     // Insert key, or ins
28897     ins: 45,
28898     insert: 45,
28899     // Delete key, on Mac: ⌦ (Delete)
28900     "\u2326": 46,
28901     del: 46,
28902     "delete": 46,
28903     // Left Arrow Key, or ←
28904     "\u2190": 37,
28905     left: 37,
28906     "arrow-left": 37,
28907     // Up Arrow Key, or ↑
28908     "\u2191": 38,
28909     up: 38,
28910     "arrow-up": 38,
28911     // Right Arrow Key, or →
28912     "\u2192": 39,
28913     right: 39,
28914     "arrow-right": 39,
28915     // Up Arrow Key, or ↓
28916     "\u2193": 40,
28917     down: 40,
28918     "arrow-down": 40,
28919     // odities, printing characters that come out wrong:
28920     // Firefox Equals
28921     "ffequals": 61,
28922     // Num-Multiply, or *
28923     "*": 106,
28924     star: 106,
28925     asterisk: 106,
28926     multiply: 106,
28927     // Num-Plus or +
28928     "+": 107,
28929     "plus": 107,
28930     // Num-Subtract, or -
28931     "-": 109,
28932     subtract: 109,
28933     // Vertical Bar / Pipe
28934     "|": 124,
28935     // Firefox Plus
28936     "ffplus": 171,
28937     // Firefox Minus
28938     "ffminus": 173,
28939     // Semicolon
28940     ";": 186,
28941     semicolon: 186,
28942     // = or equals
28943     "=": 187,
28944     "equals": 187,
28945     // Comma, or ,
28946     ",": 188,
28947     comma: 188,
28948     // Dash / Underscore key
28949     "dash": 189,
28950     // Period, or ., or full-stop
28951     ".": 190,
28952     period: 190,
28953     "full-stop": 190,
28954     // Slash, or /, or forward-slash
28955     "/": 191,
28956     slash: 191,
28957     "forward-slash": 191,
28958     // Tick, or `, or back-quote
28959     "`": 192,
28960     tick: 192,
28961     "back-quote": 192,
28962     // Open bracket, or [
28963     "[": 219,
28964     "open-bracket": 219,
28965     // Back slash, or \
28966     "\\": 220,
28967     "back-slash": 220,
28968     // Close bracket, or ]
28969     "]": 221,
28970     "close-bracket": 221,
28971     // Apostrophe, or Quote, or '
28972     "'": 222,
28973     quote: 222,
28974     apostrophe: 222
28975   };
28976   var i = 95;
28977   var n = 0;
28978   while (++i < 106) {
28979     utilKeybinding.keyCodes["num-" + n] = i;
28980     ++n;
28981   }
28982   i = 47;
28983   n = 0;
28984   while (++i < 58) {
28985     utilKeybinding.keyCodes[n] = i;
28986     ++n;
28987   }
28988   i = 111;
28989   n = 1;
28990   while (++i < 136) {
28991     utilKeybinding.keyCodes["f" + n] = i;
28992     ++n;
28993   }
28994   i = 64;
28995   while (++i < 91) {
28996     utilKeybinding.keyCodes[String.fromCharCode(i).toLowerCase()] = i;
28997   }
28998
28999   // modules/util/object.js
29000   function utilObjectOmit(obj, omitKeys) {
29001     return Object.keys(obj).reduce(function(result, key) {
29002       if (omitKeys.indexOf(key) === -1) {
29003         result[key] = obj[key];
29004       }
29005       return result;
29006     }, {});
29007   }
29008
29009   // modules/util/rebind.js
29010   function utilRebind(target, source) {
29011     var i3 = 1, n3 = arguments.length, method;
29012     while (++i3 < n3) {
29013       target[method = arguments[i3]] = d3_rebind(target, source, source[method]);
29014     }
29015     return target;
29016   }
29017   function d3_rebind(target, source, method) {
29018     return function() {
29019       var value = method.apply(source, arguments);
29020       return value === source ? target : value;
29021     };
29022   }
29023
29024   // modules/util/session_mutex.js
29025   function utilSessionMutex(name) {
29026     var mutex = {};
29027     var intervalID;
29028     function renew() {
29029       var expires = /* @__PURE__ */ new Date();
29030       expires.setSeconds(expires.getSeconds() + 5);
29031       document.cookie = name + "=1; expires=" + expires.toUTCString() + "; sameSite=strict";
29032     }
29033     mutex.lock = function() {
29034       if (intervalID)
29035         return true;
29036       var cookie = document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + name + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1");
29037       if (cookie)
29038         return false;
29039       renew();
29040       intervalID = window.setInterval(renew, 4e3);
29041       return true;
29042     };
29043     mutex.unlock = function() {
29044       if (!intervalID)
29045         return;
29046       document.cookie = name + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT; sameSite=strict";
29047       clearInterval(intervalID);
29048       intervalID = null;
29049     };
29050     mutex.locked = function() {
29051       return !!intervalID;
29052     };
29053     return mutex;
29054   }
29055
29056   // modules/util/tiler.js
29057   function utilTiler() {
29058     var _size = [256, 256];
29059     var _scale = 256;
29060     var _tileSize = 256;
29061     var _zoomExtent = [0, 20];
29062     var _translate = [_size[0] / 2, _size[1] / 2];
29063     var _margin = 0;
29064     var _skipNullIsland = false;
29065     function clamp3(num, min3, max3) {
29066       return Math.max(min3, Math.min(num, max3));
29067     }
29068     function nearNullIsland(tile) {
29069       var x2 = tile[0];
29070       var y2 = tile[1];
29071       var z2 = tile[2];
29072       if (z2 >= 7) {
29073         var center = Math.pow(2, z2 - 1);
29074         var width = Math.pow(2, z2 - 6);
29075         var min3 = center - width / 2;
29076         var max3 = center + width / 2 - 1;
29077         return x2 >= min3 && x2 <= max3 && y2 >= min3 && y2 <= max3;
29078       }
29079       return false;
29080     }
29081     function tiler9() {
29082       var z2 = geoScaleToZoom(_scale / (2 * Math.PI), _tileSize);
29083       var z0 = clamp3(Math.round(z2), _zoomExtent[0], _zoomExtent[1]);
29084       var tileMin = 0;
29085       var tileMax = Math.pow(2, z0) - 1;
29086       var log2ts = Math.log(_tileSize) * Math.LOG2E;
29087       var k2 = Math.pow(2, z2 - z0 + log2ts);
29088       var origin = [
29089         (_translate[0] - _scale / 2) / k2,
29090         (_translate[1] - _scale / 2) / k2
29091       ];
29092       var cols = range(
29093         clamp3(Math.floor(-origin[0]) - _margin, tileMin, tileMax + 1),
29094         clamp3(Math.ceil(_size[0] / k2 - origin[0]) + _margin, tileMin, tileMax + 1)
29095       );
29096       var rows = range(
29097         clamp3(Math.floor(-origin[1]) - _margin, tileMin, tileMax + 1),
29098         clamp3(Math.ceil(_size[1] / k2 - origin[1]) + _margin, tileMin, tileMax + 1)
29099       );
29100       var tiles = [];
29101       for (var i3 = 0; i3 < rows.length; i3++) {
29102         var y2 = rows[i3];
29103         for (var j2 = 0; j2 < cols.length; j2++) {
29104           var x2 = cols[j2];
29105           if (i3 >= _margin && i3 <= rows.length - _margin && j2 >= _margin && j2 <= cols.length - _margin) {
29106             tiles.unshift([x2, y2, z0]);
29107           } else {
29108             tiles.push([x2, y2, z0]);
29109           }
29110         }
29111       }
29112       tiles.translate = origin;
29113       tiles.scale = k2;
29114       return tiles;
29115     }
29116     tiler9.getTiles = function(projection2) {
29117       var origin = [
29118         projection2.scale() * Math.PI - projection2.translate()[0],
29119         projection2.scale() * Math.PI - projection2.translate()[1]
29120       ];
29121       this.size(projection2.clipExtent()[1]).scale(projection2.scale() * 2 * Math.PI).translate(projection2.translate());
29122       var tiles = tiler9();
29123       var ts = tiles.scale;
29124       return tiles.map(function(tile) {
29125         if (_skipNullIsland && nearNullIsland(tile)) {
29126           return false;
29127         }
29128         var x2 = tile[0] * ts - origin[0];
29129         var y2 = tile[1] * ts - origin[1];
29130         return {
29131           id: tile.toString(),
29132           xyz: tile,
29133           extent: geoExtent(
29134             projection2.invert([x2, y2 + ts]),
29135             projection2.invert([x2 + ts, y2])
29136           )
29137         };
29138       }).filter(Boolean);
29139     };
29140     tiler9.getGeoJSON = function(projection2) {
29141       var features = tiler9.getTiles(projection2).map(function(tile) {
29142         return {
29143           type: "Feature",
29144           properties: {
29145             id: tile.id,
29146             name: tile.id
29147           },
29148           geometry: {
29149             type: "Polygon",
29150             coordinates: [tile.extent.polygon()]
29151           }
29152         };
29153       });
29154       return {
29155         type: "FeatureCollection",
29156         features
29157       };
29158     };
29159     tiler9.tileSize = function(val) {
29160       if (!arguments.length)
29161         return _tileSize;
29162       _tileSize = val;
29163       return tiler9;
29164     };
29165     tiler9.zoomExtent = function(val) {
29166       if (!arguments.length)
29167         return _zoomExtent;
29168       _zoomExtent = val;
29169       return tiler9;
29170     };
29171     tiler9.size = function(val) {
29172       if (!arguments.length)
29173         return _size;
29174       _size = val;
29175       return tiler9;
29176     };
29177     tiler9.scale = function(val) {
29178       if (!arguments.length)
29179         return _scale;
29180       _scale = val;
29181       return tiler9;
29182     };
29183     tiler9.translate = function(val) {
29184       if (!arguments.length)
29185         return _translate;
29186       _translate = val;
29187       return tiler9;
29188     };
29189     tiler9.margin = function(val) {
29190       if (!arguments.length)
29191         return _margin;
29192       _margin = +val;
29193       return tiler9;
29194     };
29195     tiler9.skipNullIsland = function(val) {
29196       if (!arguments.length)
29197         return _skipNullIsland;
29198       _skipNullIsland = val;
29199       return tiler9;
29200     };
29201     return tiler9;
29202   }
29203
29204   // modules/util/trigger_event.js
29205   function utilTriggerEvent(target, type2, eventProperties) {
29206     target.each(function() {
29207       var evt = document.createEvent("HTMLEvents");
29208       evt.initEvent(type2, true, true);
29209       for (var prop in eventProperties) {
29210         evt[prop] = eventProperties[prop];
29211       }
29212       this.dispatchEvent(evt);
29213     });
29214   }
29215
29216   // modules/util/units.js
29217   var OSM_PRECISION = 7;
29218   function displayLength(m2, isImperial) {
29219     var d2 = m2 * (isImperial ? 3.28084 : 1);
29220     var unit2;
29221     if (isImperial) {
29222       if (d2 >= 5280) {
29223         d2 /= 5280;
29224         unit2 = "miles";
29225       } else {
29226         unit2 = "feet";
29227       }
29228     } else {
29229       if (d2 >= 1e3) {
29230         d2 /= 1e3;
29231         unit2 = "kilometers";
29232       } else {
29233         unit2 = "meters";
29234       }
29235     }
29236     return _t("units." + unit2, {
29237       quantity: d2.toLocaleString(_mainLocalizer.localeCode(), {
29238         maximumSignificantDigits: 4
29239       })
29240     });
29241   }
29242   function displayArea(m2, isImperial) {
29243     var locale2 = _mainLocalizer.localeCode();
29244     var d2 = m2 * (isImperial ? 10.7639111056 : 1);
29245     var d1, d22, area;
29246     var unit1 = "";
29247     var unit2 = "";
29248     if (isImperial) {
29249       if (d2 >= 6969600) {
29250         d1 = d2 / 27878400;
29251         unit1 = "square_miles";
29252       } else {
29253         d1 = d2;
29254         unit1 = "square_feet";
29255       }
29256       if (d2 > 4356 && d2 < 4356e4) {
29257         d22 = d2 / 43560;
29258         unit2 = "acres";
29259       }
29260     } else {
29261       if (d2 >= 25e4) {
29262         d1 = d2 / 1e6;
29263         unit1 = "square_kilometers";
29264       } else {
29265         d1 = d2;
29266         unit1 = "square_meters";
29267       }
29268       if (d2 > 1e3 && d2 < 1e7) {
29269         d22 = d2 / 1e4;
29270         unit2 = "hectares";
29271       }
29272     }
29273     area = _t("units." + unit1, {
29274       quantity: d1.toLocaleString(locale2, {
29275         maximumSignificantDigits: 4
29276       })
29277     });
29278     if (d22) {
29279       return _t("units.area_pair", {
29280         area1: area,
29281         area2: _t("units." + unit2, {
29282           quantity: d22.toLocaleString(locale2, {
29283             maximumSignificantDigits: 2
29284           })
29285         })
29286       });
29287     } else {
29288       return area;
29289     }
29290   }
29291   function wrap(x2, min3, max3) {
29292     var d2 = max3 - min3;
29293     return ((x2 - min3) % d2 + d2) % d2 + min3;
29294   }
29295   function clamp(x2, min3, max3) {
29296     return Math.max(min3, Math.min(x2, max3));
29297   }
29298   function roundToDecimal(target, decimalPlace) {
29299     target = Number(target);
29300     decimalPlace = Number(decimalPlace);
29301     const factor = Math.pow(10, decimalPlace);
29302     return Math.round(target * factor) / factor;
29303   }
29304   function displayCoordinate(deg, pos, neg) {
29305     var displayCoordinate2;
29306     var locale2 = _mainLocalizer.localeCode();
29307     var degreesFloor = Math.floor(Math.abs(deg));
29308     var min3 = (Math.abs(deg) - degreesFloor) * 60;
29309     var minFloor = Math.floor(min3);
29310     var sec = (min3 - minFloor) * 60;
29311     var fix = roundToDecimal(sec, 8);
29312     var secRounded = roundToDecimal(fix, 0);
29313     if (secRounded === 60) {
29314       secRounded = 0;
29315       minFloor += 1;
29316       if (minFloor === 60) {
29317         minFloor = 0;
29318         degreesFloor += 1;
29319       }
29320     }
29321     displayCoordinate2 = _t("units.arcdegrees", {
29322       quantity: degreesFloor.toLocaleString(locale2)
29323     }) + (minFloor !== 0 || secRounded !== 0 ? _t("units.arcminutes", {
29324       quantity: minFloor.toLocaleString(locale2)
29325     }) : "") + (secRounded !== 0 ? _t("units.arcseconds", {
29326       quantity: secRounded.toLocaleString(locale2)
29327     }) : "");
29328     if (deg === 0) {
29329       return displayCoordinate2;
29330     } else {
29331       return _t("units.coordinate", {
29332         coordinate: displayCoordinate2,
29333         direction: _t("units." + (deg > 0 ? pos : neg))
29334       });
29335     }
29336   }
29337   function dmsCoordinatePair(coord2) {
29338     return _t("units.coordinate_pair", {
29339       latitude: displayCoordinate(clamp(coord2[1], -90, 90), "north", "south"),
29340       longitude: displayCoordinate(wrap(coord2[0], -180, 180), "east", "west")
29341     });
29342   }
29343   function decimalCoordinatePair(coord2) {
29344     return _t("units.coordinate_pair", {
29345       latitude: clamp(coord2[1], -90, 90).toFixed(OSM_PRECISION),
29346       longitude: wrap(coord2[0], -180, 180).toFixed(OSM_PRECISION)
29347     });
29348   }
29349   function dmsMatcher(q2) {
29350     const matchers = [
29351       // D M SS , D M SS  ex: 35 11 10.1 , 136 49 53.8
29352       {
29353         condition: /^\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+)\s+(\d+\.?\d*)\s*$/,
29354         parser: function(q3) {
29355           const match = this.condition.exec(q3);
29356           const lat = +match[2] + +match[3] / 60 + +match[4] / 3600;
29357           const lng = +match[6] + +match[7] / 60 + +match[8] / 3600;
29358           const isNegLat = match[1] === "-" ? -lat : lat;
29359           const isNegLng = match[5] === "-" ? -lng : lng;
29360           const d2 = [isNegLat, isNegLng];
29361           return d2;
29362         }
29363       },
29364       // D MM , D MM ex: 35 11.1683 , 136 49.8966
29365       {
29366         condition: /^\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*\,\s*(-?)\s*(\d+)\s+(\d+\.?\d*)\s*$/,
29367         parser: function(q3) {
29368           const match = this.condition.exec(q3);
29369           const lat = +match[2] + +match[3] / 60;
29370           const lng = +match[5] + +match[6] / 60;
29371           const isNegLat = match[1] === "-" ? -lat : lat;
29372           const isNegLng = match[4] === "-" ? -lng : lng;
29373           const d2 = [isNegLat, isNegLng];
29374           return d2;
29375         }
29376       }
29377     ];
29378     for (const matcher of matchers) {
29379       if (matcher.condition.test(q2)) {
29380         return matcher.parser(q2);
29381       }
29382     }
29383     return null;
29384   }
29385
29386   // modules/core/localizer.js
29387   var _mainLocalizer = coreLocalizer();
29388   var _t = _mainLocalizer.t;
29389   function coreLocalizer() {
29390     let localizer = {};
29391     let _dataLanguages = {};
29392     let _dataLocales = {};
29393     let _localeStrings = {};
29394     let _localeCode = "en-US";
29395     let _localeCodes = ["en-US", "en"];
29396     let _languageCode = "en";
29397     let _textDirection = "ltr";
29398     let _usesMetric = false;
29399     let _languageNames = {};
29400     let _scriptNames = {};
29401     localizer.localeCode = () => _localeCode;
29402     localizer.localeCodes = () => _localeCodes;
29403     localizer.languageCode = () => _languageCode;
29404     localizer.textDirection = () => _textDirection;
29405     localizer.usesMetric = () => _usesMetric;
29406     localizer.languageNames = () => _languageNames;
29407     localizer.scriptNames = () => _scriptNames;
29408     let _preferredLocaleCodes = [];
29409     localizer.preferredLocaleCodes = function(codes) {
29410       if (!arguments.length)
29411         return _preferredLocaleCodes;
29412       if (typeof codes === "string") {
29413         _preferredLocaleCodes = codes.split(/,|;| /gi).filter(Boolean);
29414       } else {
29415         _preferredLocaleCodes = codes;
29416       }
29417       return localizer;
29418     };
29419     var _loadPromise;
29420     localizer.ensureLoaded = () => {
29421       if (_loadPromise)
29422         return _loadPromise;
29423       let filesToFetch = [
29424         "languages",
29425         // load the list of languages
29426         "locales"
29427         // load the list of supported locales
29428       ];
29429       const localeDirs = {
29430         general: "locales",
29431         tagging: presetsCdnUrl + "dist/translations"
29432       };
29433       let fileMap = _mainFileFetcher.fileMap();
29434       for (let scopeId in localeDirs) {
29435         const key = "locales_index_".concat(scopeId);
29436         if (!fileMap[key]) {
29437           fileMap[key] = localeDirs[scopeId] + "/index.min.json";
29438         }
29439         filesToFetch.push(key);
29440       }
29441       return _loadPromise = Promise.all(filesToFetch.map((key) => _mainFileFetcher.get(key))).then((results) => {
29442         _dataLanguages = results[0];
29443         _dataLocales = results[1];
29444         let indexes = results.slice(2);
29445         let requestedLocales = (_preferredLocaleCodes || []).concat(utilDetect().browserLocales).concat(["en"]);
29446         _localeCodes = localesToUseFrom(requestedLocales);
29447         _localeCode = _localeCodes[0];
29448         let loadStringsPromises = [];
29449         indexes.forEach((index, i3) => {
29450           const fullCoverageIndex = _localeCodes.findIndex(function(locale2) {
29451             return index[locale2] && index[locale2].pct === 1;
29452           });
29453           _localeCodes.slice(0, fullCoverageIndex + 1).forEach(function(code) {
29454             let scopeId = Object.keys(localeDirs)[i3];
29455             let directory = Object.values(localeDirs)[i3];
29456             if (index[code])
29457               loadStringsPromises.push(localizer.loadLocale(code, scopeId, directory));
29458           });
29459         });
29460         return Promise.all(loadStringsPromises);
29461       }).then(() => {
29462         updateForCurrentLocale();
29463       }).catch((err) => console.error(err));
29464     };
29465     function localesToUseFrom(requestedLocales) {
29466       let supportedLocales = _dataLocales;
29467       let toUse = [];
29468       for (let i3 in requestedLocales) {
29469         let locale2 = requestedLocales[i3];
29470         if (supportedLocales[locale2])
29471           toUse.push(locale2);
29472         if (locale2.includes("-")) {
29473           let langPart = locale2.split("-")[0];
29474           if (supportedLocales[langPart])
29475             toUse.push(langPart);
29476         }
29477       }
29478       return utilArrayUniq(toUse);
29479     }
29480     function updateForCurrentLocale() {
29481       if (!_localeCode)
29482         return;
29483       _languageCode = _localeCode.split("-")[0];
29484       const currentData = _dataLocales[_localeCode] || _dataLocales[_languageCode];
29485       const hash = utilStringQs(window.location.hash);
29486       if (hash.rtl === "true") {
29487         _textDirection = "rtl";
29488       } else if (hash.rtl === "false") {
29489         _textDirection = "ltr";
29490       } else {
29491         _textDirection = currentData && currentData.rtl ? "rtl" : "ltr";
29492       }
29493       let locale2 = _localeCode;
29494       if (locale2.toLowerCase() === "en-us")
29495         locale2 = "en";
29496       _languageNames = _localeStrings.general[locale2].languageNames || _localeStrings.general[_languageCode].languageNames;
29497       _scriptNames = _localeStrings.general[locale2].scriptNames || _localeStrings.general[_languageCode].scriptNames;
29498       _usesMetric = _localeCode.slice(-3).toLowerCase() !== "-us";
29499     }
29500     localizer.loadLocale = (locale2, scopeId, directory) => {
29501       if (locale2.toLowerCase() === "en-us")
29502         locale2 = "en";
29503       if (_localeStrings[scopeId] && _localeStrings[scopeId][locale2]) {
29504         return Promise.resolve(locale2);
29505       }
29506       let fileMap = _mainFileFetcher.fileMap();
29507       const key = "locale_".concat(scopeId, "_").concat(locale2);
29508       if (!fileMap[key]) {
29509         fileMap[key] = "".concat(directory, "/").concat(locale2, ".min.json");
29510       }
29511       return _mainFileFetcher.get(key).then((d2) => {
29512         if (!_localeStrings[scopeId])
29513           _localeStrings[scopeId] = {};
29514         _localeStrings[scopeId][locale2] = d2[locale2];
29515         return locale2;
29516       });
29517     };
29518     localizer.pluralRule = function(number3) {
29519       return pluralRule(number3, _localeCode);
29520     };
29521     function pluralRule(number3, localeCode) {
29522       const rules = "Intl" in window && Intl.PluralRules && new Intl.PluralRules(localeCode);
29523       if (rules) {
29524         return rules.select(number3);
29525       }
29526       if (number3 === 1)
29527         return "one";
29528       return "other";
29529     }
29530     localizer.tInfo = function(origStringId, replacements, locale2) {
29531       let stringId = origStringId.trim();
29532       let scopeId = "general";
29533       if (stringId[0] === "_") {
29534         let split = stringId.split(".");
29535         scopeId = split[0].slice(1);
29536         stringId = split.slice(1).join(".");
29537       }
29538       locale2 = locale2 || _localeCode;
29539       let path = stringId.split(".").map((s2) => s2.replace(/<TX_DOT>/g, ".")).reverse();
29540       let stringsKey = locale2;
29541       if (stringsKey.toLowerCase() === "en-us")
29542         stringsKey = "en";
29543       let result = _localeStrings && _localeStrings[scopeId] && _localeStrings[scopeId][stringsKey];
29544       while (result !== void 0 && path.length) {
29545         result = result[path.pop()];
29546       }
29547       if (result !== void 0) {
29548         if (replacements) {
29549           if (typeof result === "object" && Object.keys(result).length) {
29550             const number3 = Object.values(replacements).find(function(value) {
29551               return typeof value === "number";
29552             });
29553             if (number3 !== void 0) {
29554               const rule = pluralRule(number3, locale2);
29555               if (result[rule]) {
29556                 result = result[rule];
29557               } else {
29558                 result = Object.values(result)[0];
29559               }
29560             }
29561           }
29562           if (typeof result === "string") {
29563             for (let key in replacements) {
29564               let value = replacements[key];
29565               if (typeof value === "number") {
29566                 if (value.toLocaleString) {
29567                   value = value.toLocaleString(locale2, {
29568                     style: "decimal",
29569                     useGrouping: true,
29570                     minimumFractionDigits: 0
29571                   });
29572                 } else {
29573                   value = value.toString();
29574                 }
29575               }
29576               const token = "{".concat(key, "}");
29577               const regex = new RegExp(token, "g");
29578               result = result.replace(regex, value);
29579             }
29580           }
29581         }
29582         if (typeof result === "string") {
29583           return {
29584             text: result,
29585             locale: locale2
29586           };
29587         }
29588       }
29589       let index = _localeCodes.indexOf(locale2);
29590       if (index >= 0 && index < _localeCodes.length - 1) {
29591         let fallback = _localeCodes[index + 1];
29592         return localizer.tInfo(origStringId, replacements, fallback);
29593       }
29594       if (replacements && "default" in replacements) {
29595         return {
29596           text: replacements.default,
29597           locale: null
29598         };
29599       }
29600       const missing = "Missing ".concat(locale2, " translation: ").concat(origStringId);
29601       if (typeof console !== "undefined")
29602         console.error(missing);
29603       return {
29604         text: missing,
29605         locale: "en"
29606       };
29607     };
29608     localizer.hasTextForStringId = function(stringId) {
29609       return !!localizer.tInfo(stringId, { default: "nothing found" }).locale;
29610     };
29611     localizer.t = function(stringId, replacements, locale2) {
29612       return localizer.tInfo(stringId, replacements, locale2).text;
29613     };
29614     localizer.t.html = function(stringId, replacements, locale2) {
29615       replacements = Object.assign({}, replacements);
29616       for (var k2 in replacements) {
29617         if (typeof replacements[k2] === "string") {
29618           replacements[k2] = escape_default(replacements[k2]);
29619         }
29620         if (typeof replacements[k2] === "object" && typeof replacements[k2].html === "string") {
29621           replacements[k2] = replacements[k2].html;
29622         }
29623       }
29624       const info = localizer.tInfo(stringId, replacements, locale2);
29625       if (info.text) {
29626         return '<span class="localized-text" lang="'.concat(info.locale || "und", '">').concat(info.text, "</span>");
29627       } else {
29628         return "";
29629       }
29630     };
29631     localizer.t.append = function(stringId, replacements, locale2) {
29632       const ret = function(selection2) {
29633         const info = localizer.tInfo(stringId, replacements, locale2);
29634         return selection2.append("span").attr("class", "localized-text").attr("lang", info.locale || "und").text((replacements && replacements.prefix || "") + info.text + (replacements && replacements.suffix || ""));
29635       };
29636       ret.stringId = stringId;
29637       return ret;
29638     };
29639     localizer.languageName = (code, options2) => {
29640       if (_languageNames && _languageNames[code]) {
29641         return _languageNames[code];
29642       }
29643       if (options2 && options2.localOnly)
29644         return null;
29645       const langInfo = _dataLanguages[code];
29646       if (langInfo) {
29647         if (langInfo.nativeName) {
29648           return localizer.t("translate.language_and_code", { language: langInfo.nativeName, code });
29649         } else if (langInfo.base && langInfo.script) {
29650           const base = langInfo.base;
29651           if (_languageNames && _languageNames[base]) {
29652             const scriptCode = langInfo.script;
29653             const script = _scriptNames && _scriptNames[scriptCode] || scriptCode;
29654             return localizer.t("translate.language_and_code", { language: _languageNames[base], code: script });
29655           } else if (_dataLanguages[base] && _dataLanguages[base].nativeName) {
29656             return localizer.t("translate.language_and_code", { language: _dataLanguages[base].nativeName, code });
29657           }
29658         }
29659       }
29660       return code;
29661     };
29662     localizer.floatFormatter = (locale2) => {
29663       if (!("Intl" in window && "NumberFormat" in Intl && "formatToParts" in Intl.NumberFormat.prototype)) {
29664         return (number3, fractionDigits) => {
29665           return fractionDigits === void 0 ? number3.toString() : number3.toFixed(fractionDigits);
29666         };
29667       } else {
29668         return (number3, fractionDigits) => number3.toLocaleString(locale2, {
29669           minimumFractionDigits: fractionDigits,
29670           maximumFractionDigits: fractionDigits === void 0 ? 20 : fractionDigits
29671         });
29672       }
29673     };
29674     localizer.floatParser = (locale2) => {
29675       const polyfill = (string) => +string.trim();
29676       if (!("Intl" in window && "NumberFormat" in Intl))
29677         return polyfill;
29678       const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
29679       if (!("formatToParts" in format2))
29680         return polyfill;
29681       const parts = format2.formatToParts(-12345.6);
29682       const numerals = Array.from({ length: 10 }).map((_2, i3) => format2.format(i3));
29683       const index = new Map(numerals.map((d2, i3) => [d2, i3]));
29684       const literalPart = parts.find((d2) => d2.type === "literal");
29685       const literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
29686       const groupPart = parts.find((d2) => d2.type === "group");
29687       const group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
29688       const decimalPart = parts.find((d2) => d2.type === "decimal");
29689       const decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
29690       const numeral = new RegExp("[".concat(numerals.join(""), "]"), "g");
29691       const getIndex = (d2) => index.get(d2);
29692       return (string) => {
29693         string = string.trim();
29694         if (literal)
29695           string = string.replace(literal, "");
29696         if (group)
29697           string = string.replace(group, "");
29698         if (decimal)
29699           string = string.replace(decimal, ".");
29700         string = string.replace(numeral, getIndex);
29701         return string ? +string : NaN;
29702       };
29703     };
29704     localizer.decimalPlaceCounter = (locale2) => {
29705       var literal, group, decimal;
29706       if ("Intl" in window && "NumberFormat" in Intl) {
29707         const format2 = new Intl.NumberFormat(locale2, { maximumFractionDigits: 20 });
29708         if ("formatToParts" in format2) {
29709           const parts = format2.formatToParts(-12345.6);
29710           const literalPart = parts.find((d2) => d2.type === "literal");
29711           literal = literalPart && new RegExp("[".concat(literalPart.value, "]"), "g");
29712           const groupPart = parts.find((d2) => d2.type === "group");
29713           group = groupPart && new RegExp("[".concat(groupPart.value, "]"), "g");
29714           const decimalPart = parts.find((d2) => d2.type === "decimal");
29715           decimal = decimalPart && new RegExp("[".concat(decimalPart.value, "]"));
29716         }
29717       }
29718       return (string) => {
29719         string = string.trim();
29720         if (literal)
29721           string = string.replace(literal, "");
29722         if (group)
29723           string = string.replace(group, "");
29724         const parts = string.split(decimal || ".");
29725         return parts && parts[1] && parts[1].length || 0;
29726       };
29727     };
29728     return localizer;
29729   }
29730
29731   // modules/presets/collection.js
29732   function presetCollection(collection) {
29733     const MAXRESULTS = 50;
29734     let _this = {};
29735     let _memo = {};
29736     _this.collection = collection;
29737     _this.item = (id2) => {
29738       if (_memo[id2])
29739         return _memo[id2];
29740       const found = _this.collection.find((d2) => d2.id === id2);
29741       if (found)
29742         _memo[id2] = found;
29743       return found;
29744     };
29745     _this.index = (id2) => _this.collection.findIndex((d2) => d2.id === id2);
29746     _this.matchGeometry = (geometry) => {
29747       return presetCollection(
29748         _this.collection.filter((d2) => d2.matchGeometry(geometry))
29749       );
29750     };
29751     _this.matchAllGeometry = (geometries) => {
29752       return presetCollection(
29753         _this.collection.filter((d2) => d2 && d2.matchAllGeometry(geometries))
29754       );
29755     };
29756     _this.matchAnyGeometry = (geometries) => {
29757       return presetCollection(
29758         _this.collection.filter((d2) => geometries.some((geom) => d2.matchGeometry(geom)))
29759       );
29760     };
29761     _this.fallback = (geometry) => {
29762       let id2 = geometry;
29763       if (id2 === "vertex")
29764         id2 = "point";
29765       return _this.item(id2);
29766     };
29767     _this.search = (value, geometry, loc) => {
29768       if (!value)
29769         return _this;
29770       value = value.toLowerCase().trim();
29771       function leading(a2) {
29772         const index = a2.indexOf(value);
29773         return index === 0 || a2[index - 1] === " ";
29774       }
29775       function leadingStrict(a2) {
29776         const index = a2.indexOf(value);
29777         return index === 0;
29778       }
29779       function sortPresets(nameProp, aliasesProp) {
29780         return function sortNames(a2, b2) {
29781           let aCompare = a2[nameProp]();
29782           let bCompare = b2[nameProp]();
29783           if (aliasesProp) {
29784             const findMatchingAlias = (strings) => {
29785               if (strings.some((s2) => s2 === value)) {
29786                 return strings.find((s2) => s2 === value);
29787               } else {
29788                 return strings.filter((s2) => s2.includes(value)).sort((a3, b3) => a3.length - b3.length)[0];
29789               }
29790             };
29791             aCompare = findMatchingAlias([aCompare].concat(a2[aliasesProp]()));
29792             bCompare = findMatchingAlias([bCompare].concat(b2[aliasesProp]()));
29793           }
29794           if (value === aCompare)
29795             return -1;
29796           if (value === bCompare)
29797             return 1;
29798           let i3 = b2.originalScore - a2.originalScore;
29799           if (i3 !== 0)
29800             return i3;
29801           i3 = aCompare.indexOf(value) - bCompare.indexOf(value);
29802           if (i3 !== 0)
29803             return i3;
29804           return aCompare.length - bCompare.length;
29805         };
29806       }
29807       let pool = _this.collection;
29808       if (Array.isArray(loc)) {
29809         const validHere = _sharedLocationManager.locationSetsAt(loc);
29810         pool = pool.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
29811       }
29812       const searchable = pool.filter((a2) => a2.searchable !== false && a2.suggestion !== true);
29813       const suggestions = pool.filter((a2) => a2.suggestion === true);
29814       const leadingNames = searchable.filter((a2) => leading(a2.searchName()) || a2.searchAliases().some(leading)).sort(sortPresets("searchName", "searchAliases"));
29815       const leadingSuggestions = suggestions.filter((a2) => leadingStrict(a2.searchName())).sort(sortPresets("searchName"));
29816       const leadingNamesStripped = searchable.filter((a2) => leading(a2.searchNameStripped()) || a2.searchAliasesStripped().some(leading)).sort(sortPresets("searchNameStripped", "searchAliasesStripped"));
29817       const leadingSuggestionsStripped = suggestions.filter((a2) => leadingStrict(a2.searchNameStripped())).sort(sortPresets("searchNameStripped"));
29818       const leadingTerms = searchable.filter((a2) => (a2.terms() || []).some(leading));
29819       const leadingSuggestionTerms = suggestions.filter((a2) => (a2.terms() || []).some(leading));
29820       const leadingTagValues = searchable.filter((a2) => Object.values(a2.tags || {}).filter((val) => val !== "*").some(leading));
29821       const similarName = searchable.map((a2) => ({ preset: a2, dist: utilEditDistance(value, a2.searchName()) })).filter((a2) => a2.dist + Math.min(value.length - a2.preset.searchName().length, 0) < 3).sort((a2, b2) => a2.dist - b2.dist).map((a2) => a2.preset);
29822       const similarSuggestions = suggestions.map((a2) => ({ preset: a2, dist: utilEditDistance(value, a2.searchName()) })).filter((a2) => a2.dist + Math.min(value.length - a2.preset.searchName().length, 0) < 1).sort((a2, b2) => a2.dist - b2.dist).map((a2) => a2.preset);
29823       const similarTerms = searchable.filter((a2) => {
29824         return (a2.terms() || []).some((b2) => {
29825           return utilEditDistance(value, b2) + Math.min(value.length - b2.length, 0) < 3;
29826         });
29827       });
29828       let leadingTagKeyValues = [];
29829       if (value.includes("=")) {
29830         leadingTagKeyValues = searchable.filter((a2) => a2.tags && Object.keys(a2.tags).some((key) => key + "=" + a2.tags[key] === value)).concat(searchable.filter((a2) => a2.tags && Object.keys(a2.tags).some((key) => leading(key + "=" + a2.tags[key]))));
29831       }
29832       let results = leadingNames.concat(
29833         leadingSuggestions,
29834         leadingNamesStripped,
29835         leadingSuggestionsStripped,
29836         leadingTerms,
29837         leadingSuggestionTerms,
29838         leadingTagValues,
29839         similarName,
29840         similarSuggestions,
29841         similarTerms,
29842         leadingTagKeyValues
29843       ).slice(0, MAXRESULTS - 1);
29844       if (geometry) {
29845         if (typeof geometry === "string") {
29846           results.push(_this.fallback(geometry));
29847         } else {
29848           geometry.forEach((geom) => results.push(_this.fallback(geom)));
29849         }
29850       }
29851       return presetCollection(utilArrayUniq(results));
29852     };
29853     return _this;
29854   }
29855
29856   // modules/presets/category.js
29857   function presetCategory(categoryID, category, allPresets) {
29858     let _this = Object.assign({}, category);
29859     let _searchName;
29860     let _searchNameStripped;
29861     _this.id = categoryID;
29862     _this.members = presetCollection(
29863       (category.members || []).map((presetID) => allPresets[presetID]).filter(Boolean)
29864     );
29865     _this.geometry = _this.members.collection.reduce((acc, preset) => {
29866       for (let i3 in preset.geometry) {
29867         const geometry = preset.geometry[i3];
29868         if (acc.indexOf(geometry) === -1) {
29869           acc.push(geometry);
29870         }
29871       }
29872       return acc;
29873     }, []);
29874     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
29875     _this.matchAllGeometry = (geometries) => _this.members.collection.some((preset) => preset.matchAllGeometry(geometries));
29876     _this.matchScore = () => -1;
29877     _this.name = () => _t("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
29878     _this.nameLabel = () => _t.append("_tagging.presets.categories.".concat(categoryID, ".name"), { "default": categoryID });
29879     _this.terms = () => [];
29880     _this.searchName = () => {
29881       if (!_searchName) {
29882         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
29883       }
29884       return _searchName;
29885     };
29886     _this.searchNameStripped = () => {
29887       if (!_searchNameStripped) {
29888         _searchNameStripped = _this.searchName();
29889         if (_searchNameStripped.normalize)
29890           _searchNameStripped = _searchNameStripped.normalize("NFD");
29891         _searchNameStripped = _searchNameStripped.replace(/[\u0300-\u036f]/g, "");
29892       }
29893       return _searchNameStripped;
29894     };
29895     _this.searchAliases = () => [];
29896     _this.searchAliasesStripped = () => [];
29897     return _this;
29898   }
29899
29900   // modules/presets/field.js
29901   function presetField(fieldID, field, allFields) {
29902     allFields = allFields || {};
29903     let _this = Object.assign({}, field);
29904     _this.id = fieldID;
29905     _this.safeid = utilSafeClassName(fieldID);
29906     _this.matchGeometry = (geom) => !_this.geometry || _this.geometry.indexOf(geom) !== -1;
29907     _this.matchAllGeometry = (geometries) => {
29908       return !_this.geometry || geometries.every((geom) => _this.geometry.indexOf(geom) !== -1);
29909     };
29910     _this.t = (scope, options2) => _t("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
29911     _this.t.html = (scope, options2) => _t.html("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
29912     _this.t.append = (scope, options2) => _t.append("_tagging.presets.fields.".concat(fieldID, ".").concat(scope), options2);
29913     _this.hasTextForStringId = (scope) => _mainLocalizer.hasTextForStringId("_tagging.presets.fields.".concat(fieldID, ".").concat(scope));
29914     _this.resolveReference = (which) => {
29915       const referenceRegex = /^\{(.*)\}$/;
29916       const match = (field[which] || "").match(referenceRegex);
29917       if (match) {
29918         const field2 = allFields[match[1]];
29919         if (field2) {
29920           return field2;
29921         }
29922         console.error("Unable to resolve referenced field: ".concat(match[1]));
29923       }
29924       return _this;
29925     };
29926     _this.title = () => _this.overrideLabel || _this.resolveReference("label").t("label", { "default": fieldID });
29927     _this.label = () => _this.overrideLabel ? (selection2) => selection2.text(_this.overrideLabel) : _this.resolveReference("label").t.append("label", { "default": fieldID });
29928     _this.placeholder = () => _this.resolveReference("placeholder").t("placeholder", { "default": "" });
29929     _this.originalTerms = (_this.terms || []).join();
29930     _this.terms = () => _this.resolveReference("label").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
29931     _this.increment = _this.type === "number" ? _this.increment || 1 : void 0;
29932     return _this;
29933   }
29934
29935   // modules/presets/preset.js
29936   var import_lodash = __toESM(require_lodash());
29937   function presetPreset(presetID, preset, addable, allFields, allPresets) {
29938     allFields = allFields || {};
29939     allPresets = allPresets || {};
29940     let _this = Object.assign({}, preset);
29941     let _addable = addable || false;
29942     let _searchName;
29943     let _searchNameStripped;
29944     let _searchAliases;
29945     let _searchAliasesStripped;
29946     const referenceRegex = /^\{(.*)\}$/;
29947     _this.id = presetID;
29948     _this.safeid = utilSafeClassName(presetID);
29949     _this.originalTerms = (_this.terms || []).join();
29950     _this.originalName = _this.name || "";
29951     _this.originalAliases = (_this.aliases || []).join("\n");
29952     _this.originalScore = _this.matchScore || 1;
29953     _this.originalReference = _this.reference || {};
29954     _this.originalFields = _this.fields || [];
29955     _this.originalMoreFields = _this.moreFields || [];
29956     _this.fields = (loc) => resolveFields("fields", loc);
29957     _this.moreFields = (loc) => resolveFields("moreFields", loc);
29958     _this.tags = _this.tags || {};
29959     _this.addTags = _this.addTags || _this.tags;
29960     _this.removeTags = _this.removeTags || _this.addTags;
29961     _this.geometry = _this.geometry || [];
29962     _this.matchGeometry = (geom) => _this.geometry.indexOf(geom) >= 0;
29963     _this.matchAllGeometry = (geoms) => geoms.every(_this.matchGeometry);
29964     _this.matchScore = (entityTags) => {
29965       const tags = _this.tags;
29966       let seen = {};
29967       let score = 0;
29968       for (let k2 in tags) {
29969         seen[k2] = true;
29970         if (entityTags[k2] === tags[k2]) {
29971           score += _this.originalScore;
29972         } else if (tags[k2] === "*" && k2 in entityTags) {
29973           score += _this.originalScore / 2;
29974         } else {
29975           return -1;
29976         }
29977       }
29978       const addTags = _this.addTags;
29979       for (let k2 in addTags) {
29980         if (!seen[k2] && entityTags[k2] === addTags[k2]) {
29981           score += _this.originalScore;
29982         }
29983       }
29984       if (_this.searchable === false) {
29985         score *= 0.999;
29986       }
29987       return score;
29988     };
29989     _this.t = (scope, options2) => {
29990       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
29991       return _t(textID, options2);
29992     };
29993     _this.t.append = (scope, options2) => {
29994       const textID = "_tagging.presets.presets.".concat(presetID, ".").concat(scope);
29995       return _t.append(textID, options2);
29996     };
29997     function resolveReference(which) {
29998       const match = (_this[which] || "").match(referenceRegex);
29999       if (match) {
30000         const preset2 = allPresets[match[1]];
30001         if (preset2) {
30002           return preset2;
30003         }
30004         console.error("Unable to resolve referenced preset: ".concat(match[1]));
30005       }
30006       return _this;
30007     }
30008     _this.name = () => {
30009       return resolveReference("originalName").t("name", { "default": _this.originalName || presetID });
30010     };
30011     _this.nameLabel = () => {
30012       return resolveReference("originalName").t.append("name", { "default": _this.originalName || presetID });
30013     };
30014     _this.subtitle = () => {
30015       if (_this.suggestion) {
30016         let path = presetID.split("/");
30017         path.pop();
30018         return _t("_tagging.presets.presets." + path.join("/") + ".name");
30019       }
30020       return null;
30021     };
30022     _this.subtitleLabel = () => {
30023       if (_this.suggestion) {
30024         let path = presetID.split("/");
30025         path.pop();
30026         return _t.append("_tagging.presets.presets." + path.join("/") + ".name");
30027       }
30028       return null;
30029     };
30030     _this.aliases = () => {
30031       return resolveReference("originalName").t("aliases", { "default": _this.originalAliases }).trim().split(/\s*[\r\n]+\s*/);
30032     };
30033     _this.terms = () => {
30034       return resolveReference("originalName").t("terms", { "default": _this.originalTerms }).toLowerCase().trim().split(/\s*,+\s*/);
30035     };
30036     _this.searchName = () => {
30037       if (!_searchName) {
30038         _searchName = (_this.suggestion ? _this.originalName : _this.name()).toLowerCase();
30039       }
30040       return _searchName;
30041     };
30042     _this.searchNameStripped = () => {
30043       if (!_searchNameStripped) {
30044         _searchNameStripped = stripDiacritics(_this.searchName());
30045       }
30046       return _searchNameStripped;
30047     };
30048     _this.searchAliases = () => {
30049       if (!_searchAliases) {
30050         _searchAliases = _this.aliases().map((alias) => alias.toLowerCase());
30051       }
30052       return _searchAliases;
30053     };
30054     _this.searchAliasesStripped = () => {
30055       if (!_searchAliasesStripped) {
30056         _searchAliasesStripped = _this.searchAliases();
30057         _searchAliasesStripped = _searchAliasesStripped.map(stripDiacritics);
30058       }
30059       return _searchAliasesStripped;
30060     };
30061     _this.isFallback = () => {
30062       const tagCount = Object.keys(_this.tags).length;
30063       return tagCount === 0 || tagCount === 1 && _this.tags.hasOwnProperty("area");
30064     };
30065     _this.addable = function(val) {
30066       if (!arguments.length)
30067         return _addable;
30068       _addable = val;
30069       return _this;
30070     };
30071     _this.reference = () => {
30072       const qid = _this.tags.wikidata || _this.tags["flag:wikidata"] || _this.tags["brand:wikidata"] || _this.tags["network:wikidata"] || _this.tags["operator:wikidata"];
30073       if (qid) {
30074         return { qid };
30075       }
30076       let key = _this.originalReference.key || Object.keys(utilObjectOmit(_this.tags, "name"))[0];
30077       let value = _this.originalReference.value || _this.tags[key];
30078       if (value === "*") {
30079         return { key };
30080       } else {
30081         return { key, value };
30082       }
30083     };
30084     _this.unsetTags = (tags, geometry, ignoringKeys, skipFieldDefaults, loc) => {
30085       let removeTags = ignoringKeys ? utilObjectOmit(_this.removeTags, ignoringKeys) : _this.removeTags;
30086       tags = utilObjectOmit(tags, Object.keys(removeTags));
30087       if (geometry && !skipFieldDefaults) {
30088         _this.fields(loc).forEach((field) => {
30089           if (field.matchGeometry(geometry) && field.key && field.default === tags[field.key] && (!ignoringKeys || ignoringKeys.indexOf(field.key) === -1)) {
30090             delete tags[field.key];
30091           }
30092         });
30093       }
30094       delete tags.area;
30095       return tags;
30096     };
30097     _this.setTags = (tags, geometry, skipFieldDefaults, loc) => {
30098       const addTags = _this.addTags;
30099       tags = Object.assign({}, tags);
30100       for (let k2 in addTags) {
30101         if (addTags[k2] === "*") {
30102           if (_this.tags[k2] || !tags[k2]) {
30103             tags[k2] = "yes";
30104           }
30105         } else {
30106           tags[k2] = addTags[k2];
30107         }
30108       }
30109       if (!addTags.hasOwnProperty("area")) {
30110         delete tags.area;
30111         if (geometry === "area") {
30112           let needsAreaTag = true;
30113           for (let k2 in addTags) {
30114             if (_this.geometry.indexOf("line") === -1 && k2 in osmAreaKeys || k2 in osmAreaKeysExceptions && addTags[k2] in osmAreaKeysExceptions[k2]) {
30115               needsAreaTag = false;
30116               break;
30117             }
30118           }
30119           if (needsAreaTag) {
30120             tags.area = "yes";
30121           }
30122         }
30123       }
30124       if (geometry && !skipFieldDefaults) {
30125         _this.fields(loc).forEach((field) => {
30126           if (field.matchGeometry(geometry) && field.key && !tags[field.key] && field.default) {
30127             tags[field.key] = field.default;
30128           }
30129         });
30130       }
30131       return tags;
30132     };
30133     function resolveFields(which, loc) {
30134       const fieldIDs = which === "fields" ? _this.originalFields : _this.originalMoreFields;
30135       let resolved = [];
30136       fieldIDs.forEach((fieldID) => {
30137         const match = fieldID.match(referenceRegex);
30138         if (match !== null) {
30139           resolved = resolved.concat(inheritFields(allPresets[match[1]], which));
30140         } else if (allFields[fieldID]) {
30141           resolved.push(allFields[fieldID]);
30142         } else {
30143           console.log('Cannot resolve "'.concat(fieldID, '" found in ').concat(_this.id, ".").concat(which));
30144         }
30145       });
30146       if (!resolved.length) {
30147         const endIndex = _this.id.lastIndexOf("/");
30148         const parentID = endIndex && _this.id.substring(0, endIndex);
30149         if (parentID) {
30150           let parent = allPresets[parentID];
30151           if (loc) {
30152             const validHere = _sharedLocationManager.locationSetsAt(loc);
30153             if ((parent == null ? void 0 : parent.locationSetID) && !validHere[parent.locationSetID]) {
30154               const candidateIDs = Object.keys(allPresets).filter((k2) => k2.startsWith(parentID));
30155               parent = allPresets[candidateIDs.find((candidateID) => {
30156                 const candidate = allPresets[candidateID];
30157                 return validHere[candidate.locationSetID] && (0, import_lodash.isEqual)(candidate.tags, parent.tags);
30158               })];
30159             }
30160           }
30161           resolved = inheritFields(parent, which);
30162         }
30163       }
30164       return utilArrayUniq(resolved);
30165       function inheritFields(parent, which2) {
30166         if (!parent)
30167           return [];
30168         if (which2 === "fields") {
30169           return parent.fields().filter(shouldInherit);
30170         } else if (which2 === "moreFields") {
30171           return parent.moreFields();
30172         } else {
30173           return [];
30174         }
30175       }
30176       function shouldInherit(f2) {
30177         if (f2.key && _this.tags[f2.key] !== void 0 && // inherit anyway if multiple values are allowed or just a checkbox
30178         f2.type !== "multiCombo" && f2.type !== "semiCombo" && f2.type !== "manyCombo" && f2.type !== "check")
30179           return false;
30180         return true;
30181       }
30182     }
30183     function stripDiacritics(s2) {
30184       if (s2.normalize)
30185         s2 = s2.normalize("NFD");
30186       s2 = s2.replace(/[\u0300-\u036f]/g, "");
30187       return s2;
30188     }
30189     return _this;
30190   }
30191
30192   // modules/presets/index.js
30193   var _mainPresetIndex = presetIndex();
30194   function presetIndex() {
30195     const dispatch14 = dispatch_default("favoritePreset", "recentsChange");
30196     const MAXRECENTS = 30;
30197     const POINT = presetPreset("point", { name: "Point", tags: {}, geometry: ["point", "vertex"], matchScore: 0.1 });
30198     const LINE = presetPreset("line", { name: "Line", tags: {}, geometry: ["line"], matchScore: 0.1 });
30199     const AREA = presetPreset("area", { name: "Area", tags: { area: "yes" }, geometry: ["area"], matchScore: 0.1 });
30200     const RELATION = presetPreset("relation", { name: "Relation", tags: {}, geometry: ["relation"], matchScore: 0.1 });
30201     let _this = presetCollection([POINT, LINE, AREA, RELATION]);
30202     let _presets = { point: POINT, line: LINE, area: AREA, relation: RELATION };
30203     let _defaults2 = {
30204       point: presetCollection([POINT]),
30205       vertex: presetCollection([POINT]),
30206       line: presetCollection([LINE]),
30207       area: presetCollection([AREA]),
30208       relation: presetCollection([RELATION])
30209     };
30210     let _fields = {};
30211     let _categories = {};
30212     let _universal = [];
30213     let _addablePresetIDs = null;
30214     let _recents;
30215     let _favorites;
30216     let _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
30217     let _loadPromise;
30218     _this.ensureLoaded = () => {
30219       if (_loadPromise)
30220         return _loadPromise;
30221       return _loadPromise = Promise.all([
30222         _mainFileFetcher.get("preset_categories"),
30223         _mainFileFetcher.get("preset_defaults"),
30224         _mainFileFetcher.get("preset_presets"),
30225         _mainFileFetcher.get("preset_fields")
30226       ]).then((vals) => {
30227         _this.merge({
30228           categories: vals[0],
30229           defaults: vals[1],
30230           presets: vals[2],
30231           fields: vals[3]
30232         });
30233         osmSetAreaKeys(_this.areaKeys());
30234         osmSetLineTags(_this.lineTags());
30235         osmSetPointTags(_this.pointTags());
30236         osmSetVertexTags(_this.vertexTags());
30237       });
30238     };
30239     _this.merge = (d2) => {
30240       let newLocationSets = [];
30241       if (d2.fields) {
30242         Object.keys(d2.fields).forEach((fieldID) => {
30243           let f2 = d2.fields[fieldID];
30244           if (f2) {
30245             f2 = presetField(fieldID, f2, _fields);
30246             if (f2.locationSet)
30247               newLocationSets.push(f2);
30248             _fields[fieldID] = f2;
30249           } else {
30250             delete _fields[fieldID];
30251           }
30252         });
30253       }
30254       if (d2.presets) {
30255         Object.keys(d2.presets).forEach((presetID) => {
30256           let p2 = d2.presets[presetID];
30257           if (p2) {
30258             const isAddable = !_addablePresetIDs || _addablePresetIDs.has(presetID);
30259             p2 = presetPreset(presetID, p2, isAddable, _fields, _presets);
30260             if (p2.locationSet)
30261               newLocationSets.push(p2);
30262             _presets[presetID] = p2;
30263           } else {
30264             const existing = _presets[presetID];
30265             if (existing && !existing.isFallback()) {
30266               delete _presets[presetID];
30267             }
30268           }
30269         });
30270       }
30271       if (d2.categories) {
30272         Object.keys(d2.categories).forEach((categoryID) => {
30273           let c2 = d2.categories[categoryID];
30274           if (c2) {
30275             c2 = presetCategory(categoryID, c2, _presets);
30276             if (c2.locationSet)
30277               newLocationSets.push(c2);
30278             _categories[categoryID] = c2;
30279           } else {
30280             delete _categories[categoryID];
30281           }
30282         });
30283       }
30284       _this.collection = Object.values(_presets).concat(Object.values(_categories));
30285       if (d2.defaults) {
30286         Object.keys(d2.defaults).forEach((geometry) => {
30287           const def2 = d2.defaults[geometry];
30288           if (Array.isArray(def2)) {
30289             _defaults2[geometry] = presetCollection(
30290               def2.map((id2) => _presets[id2] || _categories[id2]).filter(Boolean)
30291             );
30292           } else {
30293             delete _defaults2[geometry];
30294           }
30295         });
30296       }
30297       _universal = Object.values(_fields).filter((field) => field.universal);
30298       _geometryIndex = { point: {}, vertex: {}, line: {}, area: {}, relation: {} };
30299       _this.collection.forEach((preset) => {
30300         (preset.geometry || []).forEach((geometry) => {
30301           let g3 = _geometryIndex[geometry];
30302           for (let key in preset.tags) {
30303             g3[key] = g3[key] || {};
30304             let value = preset.tags[key];
30305             (g3[key][value] = g3[key][value] || []).push(preset);
30306           }
30307         });
30308       });
30309       if (d2.featureCollection && Array.isArray(d2.featureCollection.features)) {
30310         _sharedLocationManager.mergeCustomGeoJSON(d2.featureCollection);
30311       }
30312       if (newLocationSets.length) {
30313         _sharedLocationManager.mergeLocationSets(newLocationSets);
30314       }
30315       return _this;
30316     };
30317     _this.match = (entity, resolver) => {
30318       return resolver.transient(entity, "presetMatch", () => {
30319         let geometry = entity.geometry(resolver);
30320         if (geometry === "vertex" && entity.isOnAddressLine(resolver)) {
30321           geometry = "point";
30322         }
30323         const entityExtent = entity.extent(resolver);
30324         return _this.matchTags(entity.tags, geometry, entityExtent.center());
30325       });
30326     };
30327     _this.matchTags = (tags, geometry, loc) => {
30328       const keyIndex = _geometryIndex[geometry];
30329       let bestScore = -1;
30330       let bestMatch;
30331       let matchCandidates = [];
30332       for (let k2 in tags) {
30333         let indexMatches = [];
30334         let valueIndex = keyIndex[k2];
30335         if (!valueIndex)
30336           continue;
30337         let keyValueMatches = valueIndex[tags[k2]];
30338         if (keyValueMatches)
30339           indexMatches.push(...keyValueMatches);
30340         let keyStarMatches = valueIndex["*"];
30341         if (keyStarMatches)
30342           indexMatches.push(...keyStarMatches);
30343         if (indexMatches.length === 0)
30344           continue;
30345         for (let i3 = 0; i3 < indexMatches.length; i3++) {
30346           const candidate = indexMatches[i3];
30347           const score = candidate.matchScore(tags);
30348           if (score === -1) {
30349             continue;
30350           }
30351           matchCandidates.push({ score, candidate });
30352           if (score > bestScore) {
30353             bestScore = score;
30354             bestMatch = candidate;
30355           }
30356         }
30357       }
30358       if (bestMatch && bestMatch.locationSetID && bestMatch.locationSetID !== "+[Q2]" && Array.isArray(loc)) {
30359         const validHere = _sharedLocationManager.locationSetsAt(loc);
30360         if (!validHere[bestMatch.locationSetID]) {
30361           matchCandidates.sort((a2, b2) => a2.score < b2.score ? 1 : -1);
30362           for (let i3 = 0; i3 < matchCandidates.length; i3++) {
30363             const candidateScore = matchCandidates[i3];
30364             if (!candidateScore.candidate.locationSetID || validHere[candidateScore.candidate.locationSetID]) {
30365               bestMatch = candidateScore.candidate;
30366               bestScore = candidateScore.score;
30367               break;
30368             }
30369           }
30370         }
30371       }
30372       if (!bestMatch || bestMatch.isFallback()) {
30373         for (let k2 in tags) {
30374           if (/^addr:/.test(k2) && keyIndex["addr:*"] && keyIndex["addr:*"]["*"]) {
30375             bestMatch = keyIndex["addr:*"]["*"][0];
30376             break;
30377           }
30378         }
30379       }
30380       return bestMatch || _this.fallback(geometry);
30381     };
30382     _this.allowsVertex = (entity, resolver) => {
30383       if (entity.type !== "node")
30384         return false;
30385       if (Object.keys(entity.tags).length === 0)
30386         return true;
30387       return resolver.transient(entity, "vertexMatch", () => {
30388         if (entity.isOnAddressLine(resolver))
30389           return true;
30390         const geometries = osmNodeGeometriesForTags(entity.tags);
30391         if (geometries.vertex)
30392           return true;
30393         if (geometries.point)
30394           return false;
30395         return true;
30396       });
30397     };
30398     _this.areaKeys = () => {
30399       const ignore = {
30400         barrier: true,
30401         highway: true,
30402         footway: true,
30403         railway: true,
30404         junction: true,
30405         type: true
30406       };
30407       let areaKeys = {};
30408       const presets = _this.collection.filter((p2) => !p2.suggestion && !p2.replacement);
30409       presets.forEach((p2) => {
30410         const keys2 = p2.tags && Object.keys(p2.tags);
30411         const key = keys2 && keys2.length && keys2[0];
30412         if (!key)
30413           return;
30414         if (ignore[key])
30415           return;
30416         if (p2.geometry.indexOf("area") !== -1) {
30417           areaKeys[key] = areaKeys[key] || {};
30418         }
30419       });
30420       presets.forEach((p2) => {
30421         let key;
30422         for (key in p2.addTags) {
30423           const value = p2.addTags[key];
30424           if (key in areaKeys && // probably an area...
30425           p2.geometry.indexOf("line") !== -1 && // but sometimes a line
30426           value !== "*") {
30427             areaKeys[key][value] = true;
30428           }
30429         }
30430       });
30431       return areaKeys;
30432     };
30433     _this.lineTags = () => {
30434       return _this.collection.filter((lineTags, d2) => {
30435         if (d2.suggestion || d2.replacement || d2.searchable === false)
30436           return lineTags;
30437         const keys2 = d2.tags && Object.keys(d2.tags);
30438         const key = keys2 && keys2.length && keys2[0];
30439         if (!key)
30440           return lineTags;
30441         if (d2.geometry.indexOf("line") !== -1) {
30442           lineTags[key] = lineTags[key] || [];
30443           lineTags[key].push(d2.tags);
30444         }
30445         return lineTags;
30446       }, {});
30447     };
30448     _this.pointTags = () => {
30449       return _this.collection.reduce((pointTags, d2) => {
30450         if (d2.suggestion || d2.replacement || d2.searchable === false)
30451           return pointTags;
30452         const keys2 = d2.tags && Object.keys(d2.tags);
30453         const key = keys2 && keys2.length && keys2[0];
30454         if (!key)
30455           return pointTags;
30456         if (d2.geometry.indexOf("point") !== -1) {
30457           pointTags[key] = pointTags[key] || {};
30458           pointTags[key][d2.tags[key]] = true;
30459         }
30460         return pointTags;
30461       }, {});
30462     };
30463     _this.vertexTags = () => {
30464       return _this.collection.reduce((vertexTags, d2) => {
30465         if (d2.suggestion || d2.replacement || d2.searchable === false)
30466           return vertexTags;
30467         const keys2 = d2.tags && Object.keys(d2.tags);
30468         const key = keys2 && keys2.length && keys2[0];
30469         if (!key)
30470           return vertexTags;
30471         if (d2.geometry.indexOf("vertex") !== -1) {
30472           vertexTags[key] = vertexTags[key] || {};
30473           vertexTags[key][d2.tags[key]] = true;
30474         }
30475         return vertexTags;
30476       }, {});
30477     };
30478     _this.field = (id2) => _fields[id2];
30479     _this.universal = () => _universal;
30480     _this.defaults = (geometry, n3, startWithRecents, loc, extraPresets) => {
30481       let recents = [];
30482       if (startWithRecents) {
30483         recents = _this.recent().matchGeometry(geometry).collection.slice(0, 4);
30484       }
30485       let defaults;
30486       if (_addablePresetIDs) {
30487         defaults = Array.from(_addablePresetIDs).map(function(id2) {
30488           var preset = _this.item(id2);
30489           if (preset && preset.matchGeometry(geometry))
30490             return preset;
30491           return null;
30492         }).filter(Boolean);
30493       } else {
30494         defaults = _defaults2[geometry].collection.concat(_this.fallback(geometry));
30495       }
30496       let result = presetCollection(
30497         utilArrayUniq(recents.concat(defaults).concat(extraPresets || [])).slice(0, n3 - 1)
30498       );
30499       if (Array.isArray(loc)) {
30500         const validHere = _sharedLocationManager.locationSetsAt(loc);
30501         result.collection = result.collection.filter((a2) => !a2.locationSetID || validHere[a2.locationSetID]);
30502       }
30503       return result;
30504     };
30505     _this.addablePresetIDs = function(val) {
30506       if (!arguments.length)
30507         return _addablePresetIDs;
30508       if (Array.isArray(val))
30509         val = new Set(val);
30510       _addablePresetIDs = val;
30511       if (_addablePresetIDs) {
30512         _this.collection.forEach((p2) => {
30513           if (p2.addable)
30514             p2.addable(_addablePresetIDs.has(p2.id));
30515         });
30516       } else {
30517         _this.collection.forEach((p2) => {
30518           if (p2.addable)
30519             p2.addable(true);
30520         });
30521       }
30522       return _this;
30523     };
30524     _this.recent = () => {
30525       return presetCollection(
30526         utilArrayUniq(_this.getRecents().map((d2) => d2.preset).filter((d2) => d2.searchable !== false))
30527       );
30528     };
30529     function RibbonItem(preset, source) {
30530       let item = {};
30531       item.preset = preset;
30532       item.source = source;
30533       item.isFavorite = () => item.source === "favorite";
30534       item.isRecent = () => item.source === "recent";
30535       item.matches = (preset2) => item.preset.id === preset2.id;
30536       item.minified = () => ({ pID: item.preset.id });
30537       return item;
30538     }
30539     function ribbonItemForMinified(d2, source) {
30540       if (d2 && d2.pID) {
30541         const preset = _this.item(d2.pID);
30542         if (!preset)
30543           return null;
30544         return RibbonItem(preset, source);
30545       }
30546       return null;
30547     }
30548     _this.getGenericRibbonItems = () => {
30549       return ["point", "line", "area"].map((id2) => RibbonItem(_this.item(id2), "generic"));
30550     };
30551     _this.getAddable = () => {
30552       if (!_addablePresetIDs)
30553         return [];
30554       return _addablePresetIDs.map((id2) => {
30555         const preset = _this.item(id2);
30556         if (preset)
30557           return RibbonItem(preset, "addable");
30558         return null;
30559       }).filter(Boolean);
30560     };
30561     function setRecents(items) {
30562       _recents = items;
30563       const minifiedItems = items.map((d2) => d2.minified());
30564       corePreferences("preset_recents", JSON.stringify(minifiedItems));
30565       dispatch14.call("recentsChange");
30566     }
30567     _this.getRecents = () => {
30568       if (!_recents) {
30569         _recents = (JSON.parse(corePreferences("preset_recents")) || []).reduce((acc, d2) => {
30570           let item = ribbonItemForMinified(d2, "recent");
30571           if (item && item.preset.addable())
30572             acc.push(item);
30573           return acc;
30574         }, []);
30575       }
30576       return _recents;
30577     };
30578     _this.addRecent = (preset, besidePreset, after) => {
30579       const recents = _this.getRecents();
30580       const beforeItem = _this.recentMatching(besidePreset);
30581       let toIndex = recents.indexOf(beforeItem);
30582       if (after)
30583         toIndex += 1;
30584       const newItem = RibbonItem(preset, "recent");
30585       recents.splice(toIndex, 0, newItem);
30586       setRecents(recents);
30587     };
30588     _this.removeRecent = (preset) => {
30589       const item = _this.recentMatching(preset);
30590       if (item) {
30591         let items = _this.getRecents();
30592         items.splice(items.indexOf(item), 1);
30593         setRecents(items);
30594       }
30595     };
30596     _this.recentMatching = (preset) => {
30597       const items = _this.getRecents();
30598       for (let i3 in items) {
30599         if (items[i3].matches(preset)) {
30600           return items[i3];
30601         }
30602       }
30603       return null;
30604     };
30605     _this.moveItem = (items, fromIndex, toIndex) => {
30606       if (fromIndex === toIndex || fromIndex < 0 || toIndex < 0 || fromIndex >= items.length || toIndex >= items.length)
30607         return null;
30608       items.splice(toIndex, 0, items.splice(fromIndex, 1)[0]);
30609       return items;
30610     };
30611     _this.moveRecent = (item, beforeItem) => {
30612       const recents = _this.getRecents();
30613       const fromIndex = recents.indexOf(item);
30614       const toIndex = recents.indexOf(beforeItem);
30615       const items = _this.moveItem(recents, fromIndex, toIndex);
30616       if (items)
30617         setRecents(items);
30618     };
30619     _this.setMostRecent = (preset) => {
30620       if (preset.searchable === false)
30621         return;
30622       let items = _this.getRecents();
30623       let item = _this.recentMatching(preset);
30624       if (item) {
30625         items.splice(items.indexOf(item), 1);
30626       } else {
30627         item = RibbonItem(preset, "recent");
30628       }
30629       while (items.length >= MAXRECENTS) {
30630         items.pop();
30631       }
30632       items.unshift(item);
30633       setRecents(items);
30634     };
30635     function setFavorites(items) {
30636       _favorites = items;
30637       const minifiedItems = items.map((d2) => d2.minified());
30638       corePreferences("preset_favorites", JSON.stringify(minifiedItems));
30639       dispatch14.call("favoritePreset");
30640     }
30641     _this.addFavorite = (preset, besidePreset, after) => {
30642       const favorites = _this.getFavorites();
30643       const beforeItem = _this.favoriteMatching(besidePreset);
30644       let toIndex = favorites.indexOf(beforeItem);
30645       if (after)
30646         toIndex += 1;
30647       const newItem = RibbonItem(preset, "favorite");
30648       favorites.splice(toIndex, 0, newItem);
30649       setFavorites(favorites);
30650     };
30651     _this.toggleFavorite = (preset) => {
30652       const favs = _this.getFavorites();
30653       const favorite = _this.favoriteMatching(preset);
30654       if (favorite) {
30655         favs.splice(favs.indexOf(favorite), 1);
30656       } else {
30657         if (favs.length === 10) {
30658           favs.pop();
30659         }
30660         favs.push(RibbonItem(preset, "favorite"));
30661       }
30662       setFavorites(favs);
30663     };
30664     _this.removeFavorite = (preset) => {
30665       const item = _this.favoriteMatching(preset);
30666       if (item) {
30667         const items = _this.getFavorites();
30668         items.splice(items.indexOf(item), 1);
30669         setFavorites(items);
30670       }
30671     };
30672     _this.getFavorites = () => {
30673       if (!_favorites) {
30674         let rawFavorites = JSON.parse(corePreferences("preset_favorites"));
30675         if (!rawFavorites) {
30676           rawFavorites = [];
30677           corePreferences("preset_favorites", JSON.stringify(rawFavorites));
30678         }
30679         _favorites = rawFavorites.reduce((output, d2) => {
30680           const item = ribbonItemForMinified(d2, "favorite");
30681           if (item && item.preset.addable())
30682             output.push(item);
30683           return output;
30684         }, []);
30685       }
30686       return _favorites;
30687     };
30688     _this.favoriteMatching = (preset) => {
30689       const favs = _this.getFavorites();
30690       for (let index in favs) {
30691         if (favs[index].matches(preset)) {
30692           return favs[index];
30693         }
30694       }
30695       return null;
30696     };
30697     return utilRebind(_this, dispatch14, "on");
30698   }
30699
30700   // modules/util/util.js
30701   function utilTagText(entity) {
30702     var obj = entity && entity.tags || {};
30703     return Object.keys(obj).map(function(k2) {
30704       return k2 + "=" + obj[k2];
30705     }).join(", ");
30706   }
30707   function utilTotalExtent(array2, graph) {
30708     var extent = geoExtent();
30709     var val, entity;
30710     for (var i3 = 0; i3 < array2.length; i3++) {
30711       val = array2[i3];
30712       entity = typeof val === "string" ? graph.hasEntity(val) : val;
30713       if (entity) {
30714         extent._extend(entity.extent(graph));
30715       }
30716     }
30717     return extent;
30718   }
30719   function utilTagDiff(oldTags, newTags) {
30720     var tagDiff = [];
30721     var keys2 = utilArrayUnion(Object.keys(oldTags), Object.keys(newTags)).sort();
30722     keys2.forEach(function(k2) {
30723       var oldVal = oldTags[k2];
30724       var newVal = newTags[k2];
30725       if ((oldVal || oldVal === "") && (newVal === void 0 || newVal !== oldVal)) {
30726         tagDiff.push({
30727           type: "-",
30728           key: k2,
30729           oldVal,
30730           newVal,
30731           display: "- " + k2 + "=" + oldVal
30732         });
30733       }
30734       if ((newVal || newVal === "") && (oldVal === void 0 || newVal !== oldVal)) {
30735         tagDiff.push({
30736           type: "+",
30737           key: k2,
30738           oldVal,
30739           newVal,
30740           display: "+ " + k2 + "=" + newVal
30741         });
30742       }
30743     });
30744     return tagDiff;
30745   }
30746   function utilEntitySelector(ids) {
30747     return ids.length ? "." + ids.join(",.") : "nothing";
30748   }
30749   function utilEntityOrMemberSelector(ids, graph) {
30750     var seen = new Set(ids);
30751     ids.forEach(collectShallowDescendants);
30752     return utilEntitySelector(Array.from(seen));
30753     function collectShallowDescendants(id2) {
30754       var entity = graph.hasEntity(id2);
30755       if (!entity || entity.type !== "relation")
30756         return;
30757       entity.members.map(function(member) {
30758         return member.id;
30759       }).forEach(function(id3) {
30760         seen.add(id3);
30761       });
30762     }
30763   }
30764   function utilEntityOrDeepMemberSelector(ids, graph) {
30765     return utilEntitySelector(utilEntityAndDeepMemberIDs(ids, graph));
30766   }
30767   function utilEntityAndDeepMemberIDs(ids, graph) {
30768     var seen = /* @__PURE__ */ new Set();
30769     ids.forEach(collectDeepDescendants);
30770     return Array.from(seen);
30771     function collectDeepDescendants(id2) {
30772       if (seen.has(id2))
30773         return;
30774       seen.add(id2);
30775       var entity = graph.hasEntity(id2);
30776       if (!entity || entity.type !== "relation")
30777         return;
30778       entity.members.map(function(member) {
30779         return member.id;
30780       }).forEach(collectDeepDescendants);
30781     }
30782   }
30783   function utilDeepMemberSelector(ids, graph, skipMultipolgonMembers) {
30784     var idsSet = new Set(ids);
30785     var seen = /* @__PURE__ */ new Set();
30786     var returners = /* @__PURE__ */ new Set();
30787     ids.forEach(collectDeepDescendants);
30788     return utilEntitySelector(Array.from(returners));
30789     function collectDeepDescendants(id2) {
30790       if (seen.has(id2))
30791         return;
30792       seen.add(id2);
30793       if (!idsSet.has(id2)) {
30794         returners.add(id2);
30795       }
30796       var entity = graph.hasEntity(id2);
30797       if (!entity || entity.type !== "relation")
30798         return;
30799       if (skipMultipolgonMembers && entity.isMultipolygon())
30800         return;
30801       entity.members.map(function(member) {
30802         return member.id;
30803       }).forEach(collectDeepDescendants);
30804     }
30805   }
30806   function utilHighlightEntities(ids, highlighted, context) {
30807     context.surface().selectAll(utilEntityOrDeepMemberSelector(ids, context.graph())).classed("highlighted", highlighted);
30808   }
30809   function utilGetAllNodes(ids, graph) {
30810     var seen = /* @__PURE__ */ new Set();
30811     var nodes = /* @__PURE__ */ new Set();
30812     ids.forEach(collectNodes);
30813     return Array.from(nodes);
30814     function collectNodes(id2) {
30815       if (seen.has(id2))
30816         return;
30817       seen.add(id2);
30818       var entity = graph.hasEntity(id2);
30819       if (!entity)
30820         return;
30821       if (entity.type === "node") {
30822         nodes.add(entity);
30823       } else if (entity.type === "way") {
30824         entity.nodes.forEach(collectNodes);
30825       } else {
30826         entity.members.map(function(member) {
30827           return member.id;
30828         }).forEach(collectNodes);
30829       }
30830     }
30831   }
30832   function utilDisplayName(entity) {
30833     var localizedNameKey = "name:" + _mainLocalizer.languageCode().toLowerCase();
30834     var name = entity.tags[localizedNameKey] || entity.tags.name || "";
30835     if (name)
30836       return name;
30837     var tags = {
30838       direction: entity.tags.direction,
30839       from: entity.tags.from,
30840       network: entity.tags.cycle_network || entity.tags.network,
30841       ref: entity.tags.ref,
30842       to: entity.tags.to,
30843       via: entity.tags.via
30844     };
30845     var keyComponents = [];
30846     if (tags.network) {
30847       keyComponents.push("network");
30848     }
30849     if (tags.ref) {
30850       keyComponents.push("ref");
30851     }
30852     if (entity.tags.route) {
30853       if (tags.direction) {
30854         keyComponents.push("direction");
30855       } else if (tags.from && tags.to) {
30856         keyComponents.push("from");
30857         keyComponents.push("to");
30858         if (tags.via) {
30859           keyComponents.push("via");
30860         }
30861       }
30862     }
30863     if (keyComponents.length) {
30864       name = _t("inspector.display_name." + keyComponents.join("_"), tags);
30865     }
30866     return name;
30867   }
30868   function utilDisplayNameForPath(entity) {
30869     var name = utilDisplayName(entity);
30870     var isFirefox = utilDetect().browser.toLowerCase().indexOf("firefox") > -1;
30871     var isNewChromium = Number(utilDetect().version.split(".")[0]) >= 96;
30872     if (!isFirefox && !isNewChromium && name && rtlRegex.test(name)) {
30873       name = fixRTLTextForSvg(name);
30874     }
30875     return name;
30876   }
30877   function utilDisplayType(id2) {
30878     return {
30879       n: _t("inspector.node"),
30880       w: _t("inspector.way"),
30881       r: _t("inspector.relation")
30882     }[id2.charAt(0)];
30883   }
30884   function utilDisplayLabel(entity, graphOrGeometry, verbose) {
30885     var result;
30886     var displayName = utilDisplayName(entity);
30887     var preset = typeof graphOrGeometry === "string" ? _mainPresetIndex.matchTags(entity.tags, graphOrGeometry) : _mainPresetIndex.match(entity, graphOrGeometry);
30888     var presetName = preset && (preset.suggestion ? preset.subtitle() : preset.name());
30889     if (verbose) {
30890       result = [presetName, displayName].filter(Boolean).join(" ");
30891     } else {
30892       result = displayName || presetName;
30893     }
30894     return result || utilDisplayType(entity.id);
30895   }
30896   function utilEntityRoot(entityType) {
30897     return {
30898       node: "n",
30899       way: "w",
30900       relation: "r"
30901     }[entityType];
30902   }
30903   function utilCombinedTags(entityIDs, graph) {
30904     var tags = {};
30905     var tagCounts = {};
30906     var allKeys = /* @__PURE__ */ new Set();
30907     var entities = entityIDs.map(function(entityID) {
30908       return graph.hasEntity(entityID);
30909     }).filter(Boolean);
30910     entities.forEach(function(entity) {
30911       var keys2 = Object.keys(entity.tags).filter(Boolean);
30912       keys2.forEach(function(key2) {
30913         allKeys.add(key2);
30914       });
30915     });
30916     entities.forEach(function(entity) {
30917       allKeys.forEach(function(key2) {
30918         var value = entity.tags[key2];
30919         if (!tags.hasOwnProperty(key2)) {
30920           tags[key2] = value;
30921         } else {
30922           if (!Array.isArray(tags[key2])) {
30923             if (tags[key2] !== value) {
30924               tags[key2] = [tags[key2], value];
30925             }
30926           } else {
30927             if (tags[key2].indexOf(value) === -1) {
30928               tags[key2].push(value);
30929             }
30930           }
30931         }
30932         var tagHash = key2 + "=" + value;
30933         if (!tagCounts[tagHash])
30934           tagCounts[tagHash] = 0;
30935         tagCounts[tagHash] += 1;
30936       });
30937     });
30938     for (var key in tags) {
30939       if (!Array.isArray(tags[key]))
30940         continue;
30941       tags[key] = tags[key].sort(function(val12, val2) {
30942         var key2 = key2;
30943         var count2 = tagCounts[key2 + "=" + val2];
30944         var count1 = tagCounts[key2 + "=" + val12];
30945         if (count2 !== count1) {
30946           return count2 - count1;
30947         }
30948         if (val2 && val12) {
30949           return val12.localeCompare(val2);
30950         }
30951         return val12 ? 1 : -1;
30952       });
30953     }
30954     return tags;
30955   }
30956   function utilStringQs(str) {
30957     var i3 = 0;
30958     while (i3 < str.length && (str[i3] === "?" || str[i3] === "#"))
30959       i3++;
30960     str = str.slice(i3);
30961     return str.split("&").reduce(function(obj, pair3) {
30962       var parts = pair3.split("=");
30963       if (parts.length === 2) {
30964         obj[parts[0]] = null === parts[1] ? "" : decodeURIComponent(parts[1]);
30965       }
30966       return obj;
30967     }, {});
30968   }
30969   function utilQsString(obj, noencode) {
30970     function softEncode(s2) {
30971       return encodeURIComponent(s2).replace(/(%2F|%3A|%2C|%7B|%7D)/g, decodeURIComponent);
30972     }
30973     return Object.keys(obj).sort().map(function(key) {
30974       return encodeURIComponent(key) + "=" + (noencode ? softEncode(obj[key]) : encodeURIComponent(obj[key]));
30975     }).join("&");
30976   }
30977   function utilPrefixDOMProperty(property) {
30978     var prefixes2 = ["webkit", "ms", "moz", "o"];
30979     var i3 = -1;
30980     var n3 = prefixes2.length;
30981     var s2 = document.body;
30982     if (property in s2)
30983       return property;
30984     property = property.slice(0, 1).toUpperCase() + property.slice(1);
30985     while (++i3 < n3) {
30986       if (prefixes2[i3] + property in s2) {
30987         return prefixes2[i3] + property;
30988       }
30989     }
30990     return false;
30991   }
30992   function utilPrefixCSSProperty(property) {
30993     var prefixes2 = ["webkit", "ms", "Moz", "O"];
30994     var i3 = -1;
30995     var n3 = prefixes2.length;
30996     var s2 = document.body.style;
30997     if (property.toLowerCase() in s2) {
30998       return property.toLowerCase();
30999     }
31000     while (++i3 < n3) {
31001       if (prefixes2[i3] + property in s2) {
31002         return "-" + prefixes2[i3].toLowerCase() + property.replace(/([A-Z])/g, "-$1").toLowerCase();
31003       }
31004     }
31005     return false;
31006   }
31007   var transformProperty;
31008   function utilSetTransform(el, x2, y2, scale) {
31009     var prop = transformProperty = transformProperty || utilPrefixCSSProperty("Transform");
31010     var translate = utilDetect().opera ? "translate(" + x2 + "px," + y2 + "px)" : "translate3d(" + x2 + "px," + y2 + "px,0)";
31011     return el.style(prop, translate + (scale ? " scale(" + scale + ")" : ""));
31012   }
31013   function utilEditDistance(a2, b2) {
31014     a2 = (0, import_diacritics.remove)(a2.toLowerCase());
31015     b2 = (0, import_diacritics.remove)(b2.toLowerCase());
31016     if (a2.length === 0)
31017       return b2.length;
31018     if (b2.length === 0)
31019       return a2.length;
31020     var matrix = [];
31021     var i3, j2;
31022     for (i3 = 0; i3 <= b2.length; i3++) {
31023       matrix[i3] = [i3];
31024     }
31025     for (j2 = 0; j2 <= a2.length; j2++) {
31026       matrix[0][j2] = j2;
31027     }
31028     for (i3 = 1; i3 <= b2.length; i3++) {
31029       for (j2 = 1; j2 <= a2.length; j2++) {
31030         if (b2.charAt(i3 - 1) === a2.charAt(j2 - 1)) {
31031           matrix[i3][j2] = matrix[i3 - 1][j2 - 1];
31032         } else {
31033           matrix[i3][j2] = Math.min(
31034             matrix[i3 - 1][j2 - 1] + 1,
31035             // substitution
31036             Math.min(
31037               matrix[i3][j2 - 1] + 1,
31038               // insertion
31039               matrix[i3 - 1][j2] + 1
31040             )
31041           );
31042         }
31043       }
31044     }
31045     return matrix[b2.length][a2.length];
31046   }
31047   function utilFastMouse(container) {
31048     var rect = container.getBoundingClientRect();
31049     var rectLeft = rect.left;
31050     var rectTop = rect.top;
31051     var clientLeft = +container.clientLeft;
31052     var clientTop = +container.clientTop;
31053     return function(e3) {
31054       return [
31055         e3.clientX - rectLeft - clientLeft,
31056         e3.clientY - rectTop - clientTop
31057       ];
31058     };
31059   }
31060   function utilAsyncMap(inputs, func, callback) {
31061     var remaining = inputs.length;
31062     var results = [];
31063     var errors = [];
31064     inputs.forEach(function(d2, i3) {
31065       func(d2, function done(err, data) {
31066         errors[i3] = err;
31067         results[i3] = data;
31068         remaining--;
31069         if (!remaining)
31070           callback(errors, results);
31071       });
31072     });
31073   }
31074   function utilWrap(index, length2) {
31075     if (index < 0) {
31076       index += Math.ceil(-index / length2) * length2;
31077     }
31078     return index % length2;
31079   }
31080   function utilFunctor(value) {
31081     if (typeof value === "function")
31082       return value;
31083     return function() {
31084       return value;
31085     };
31086   }
31087   function utilNoAuto(selection2) {
31088     var isText = selection2.size() && selection2.node().tagName.toLowerCase() === "textarea";
31089     return selection2.attr("autocomplete", "new-password").attr("autocorrect", "off").attr("autocapitalize", "off").attr("spellcheck", isText ? "true" : "false");
31090   }
31091   function utilHashcode(str) {
31092     var hash = 0;
31093     if (str.length === 0) {
31094       return hash;
31095     }
31096     for (var i3 = 0; i3 < str.length; i3++) {
31097       var char = str.charCodeAt(i3);
31098       hash = (hash << 5) - hash + char;
31099       hash = hash & hash;
31100     }
31101     return hash;
31102   }
31103   function utilSafeClassName(str) {
31104     return str.toLowerCase().replace(/[^a-z0-9]+/g, "_");
31105   }
31106   function utilUniqueDomId(val) {
31107     return "ideditor-" + utilSafeClassName(val.toString()) + "-" + (/* @__PURE__ */ new Date()).getTime().toString();
31108   }
31109   function utilUnicodeCharsCount(str) {
31110     return Array.from(str).length;
31111   }
31112   function utilUnicodeCharsTruncated(str, limit) {
31113     return Array.from(str).slice(0, limit).join("");
31114   }
31115   function toNumericID(id2) {
31116     var match = id2.match(/^[cnwr](-?\d+)$/);
31117     if (match) {
31118       return parseInt(match[1], 10);
31119     }
31120     return NaN;
31121   }
31122   function compareNumericIDs(left, right) {
31123     if (isNaN(left) && isNaN(right))
31124       return -1;
31125     if (isNaN(left))
31126       return 1;
31127     if (isNaN(right))
31128       return -1;
31129     if (Math.sign(left) !== Math.sign(right))
31130       return -Math.sign(left);
31131     if (Math.sign(left) < 0)
31132       return Math.sign(right - left);
31133     return Math.sign(left - right);
31134   }
31135   function utilCompareIDs(left, right) {
31136     return compareNumericIDs(toNumericID(left), toNumericID(right));
31137   }
31138   function utilOldestID(ids) {
31139     if (ids.length === 0) {
31140       return void 0;
31141     }
31142     var oldestIDIndex = 0;
31143     var oldestID = toNumericID(ids[0]);
31144     for (var i3 = 1; i3 < ids.length; i3++) {
31145       var num = toNumericID(ids[i3]);
31146       if (compareNumericIDs(oldestID, num) === 1) {
31147         oldestIDIndex = i3;
31148         oldestID = num;
31149       }
31150     }
31151     return ids[oldestIDIndex];
31152   }
31153   function utilCleanOsmString(val, maxChars) {
31154     if (val === void 0 || val === null) {
31155       val = "";
31156     } else {
31157       val = val.toString();
31158     }
31159     val = val.trim();
31160     if (val.normalize)
31161       val = val.normalize("NFC");
31162     return utilUnicodeCharsTruncated(val, maxChars);
31163   }
31164
31165   // modules/osm/entity.js
31166   function osmEntity(attrs) {
31167     if (this instanceof osmEntity)
31168       return;
31169     if (attrs && attrs.type) {
31170       return osmEntity[attrs.type].apply(this, arguments);
31171     } else if (attrs && attrs.id) {
31172       return osmEntity[osmEntity.id.type(attrs.id)].apply(this, arguments);
31173     }
31174     return new osmEntity().initialize(arguments);
31175   }
31176   osmEntity.id = function(type2) {
31177     return osmEntity.id.fromOSM(type2, osmEntity.id.next[type2]--);
31178   };
31179   osmEntity.id.next = {
31180     changeset: -1,
31181     node: -1,
31182     way: -1,
31183     relation: -1
31184   };
31185   osmEntity.id.fromOSM = function(type2, id2) {
31186     return type2[0] + id2;
31187   };
31188   osmEntity.id.toOSM = function(id2) {
31189     var match = id2.match(/^[cnwr](-?\d+)$/);
31190     if (match) {
31191       return match[1];
31192     }
31193     return "";
31194   };
31195   osmEntity.id.type = function(id2) {
31196     return { "c": "changeset", "n": "node", "w": "way", "r": "relation" }[id2[0]];
31197   };
31198   osmEntity.key = function(entity) {
31199     return entity.id + "v" + (entity.v || 0);
31200   };
31201   var _deprecatedTagValuesByKey;
31202   osmEntity.deprecatedTagValuesByKey = function(dataDeprecated) {
31203     if (!_deprecatedTagValuesByKey) {
31204       _deprecatedTagValuesByKey = {};
31205       dataDeprecated.forEach(function(d2) {
31206         var oldKeys = Object.keys(d2.old);
31207         if (oldKeys.length === 1) {
31208           var oldKey = oldKeys[0];
31209           var oldValue = d2.old[oldKey];
31210           if (oldValue !== "*") {
31211             if (!_deprecatedTagValuesByKey[oldKey]) {
31212               _deprecatedTagValuesByKey[oldKey] = [oldValue];
31213             } else {
31214               _deprecatedTagValuesByKey[oldKey].push(oldValue);
31215             }
31216           }
31217         }
31218       });
31219     }
31220     return _deprecatedTagValuesByKey;
31221   };
31222   osmEntity.prototype = {
31223     tags: {},
31224     initialize: function(sources) {
31225       for (var i3 = 0; i3 < sources.length; ++i3) {
31226         var source = sources[i3];
31227         for (var prop in source) {
31228           if (Object.prototype.hasOwnProperty.call(source, prop)) {
31229             if (source[prop] === void 0) {
31230               delete this[prop];
31231             } else {
31232               this[prop] = source[prop];
31233             }
31234           }
31235         }
31236       }
31237       if (!this.id && this.type) {
31238         this.id = osmEntity.id(this.type);
31239       }
31240       if (!this.hasOwnProperty("visible")) {
31241         this.visible = true;
31242       }
31243       if (debug) {
31244         Object.freeze(this);
31245         Object.freeze(this.tags);
31246         if (this.loc)
31247           Object.freeze(this.loc);
31248         if (this.nodes)
31249           Object.freeze(this.nodes);
31250         if (this.members)
31251           Object.freeze(this.members);
31252       }
31253       return this;
31254     },
31255     copy: function(resolver, copies) {
31256       if (copies[this.id])
31257         return copies[this.id];
31258       var copy2 = osmEntity(this, { id: void 0, user: void 0, version: void 0 });
31259       copies[this.id] = copy2;
31260       return copy2;
31261     },
31262     osmId: function() {
31263       return osmEntity.id.toOSM(this.id);
31264     },
31265     isNew: function() {
31266       var osmId = osmEntity.id.toOSM(this.id);
31267       return osmId.length === 0 || osmId[0] === "-";
31268     },
31269     update: function(attrs) {
31270       return osmEntity(this, attrs, { v: 1 + (this.v || 0) });
31271     },
31272     mergeTags: function(tags) {
31273       var merged = Object.assign({}, this.tags);
31274       var changed = false;
31275       for (var k2 in tags) {
31276         var t1 = merged[k2];
31277         var t2 = tags[k2];
31278         if (!t1) {
31279           changed = true;
31280           merged[k2] = t2;
31281         } else if (t1 !== t2) {
31282           changed = true;
31283           merged[k2] = utilUnicodeCharsTruncated(
31284             utilArrayUnion(t1.split(/;\s*/), t2.split(/;\s*/)).join(";"),
31285             255
31286             // avoid exceeding character limit; see also context.maxCharsForTagValue()
31287           );
31288         }
31289       }
31290       return changed ? this.update({ tags: merged }) : this;
31291     },
31292     intersects: function(extent, resolver) {
31293       return this.extent(resolver).intersects(extent);
31294     },
31295     hasNonGeometryTags: function() {
31296       return Object.keys(this.tags).some(function(k2) {
31297         return k2 !== "area";
31298       });
31299     },
31300     hasParentRelations: function(resolver) {
31301       return resolver.parentRelations(this).length > 0;
31302     },
31303     hasInterestingTags: function() {
31304       return Object.keys(this.tags).some(osmIsInterestingTag);
31305     },
31306     isHighwayIntersection: function() {
31307       return false;
31308     },
31309     isDegenerate: function() {
31310       return true;
31311     },
31312     deprecatedTags: function(dataDeprecated) {
31313       var tags = this.tags;
31314       if (Object.keys(tags).length === 0)
31315         return [];
31316       var deprecated = [];
31317       dataDeprecated.forEach(function(d2) {
31318         var oldKeys = Object.keys(d2.old);
31319         if (d2.replace) {
31320           var hasExistingValues = Object.keys(d2.replace).some(function(replaceKey) {
31321             if (!tags[replaceKey] || d2.old[replaceKey])
31322               return false;
31323             var replaceValue = d2.replace[replaceKey];
31324             if (replaceValue === "*")
31325               return false;
31326             if (replaceValue === tags[replaceKey])
31327               return false;
31328             return true;
31329           });
31330           if (hasExistingValues)
31331             return;
31332         }
31333         var matchesDeprecatedTags = oldKeys.every(function(oldKey) {
31334           if (!tags[oldKey])
31335             return false;
31336           if (d2.old[oldKey] === "*")
31337             return true;
31338           if (d2.old[oldKey] === tags[oldKey])
31339             return true;
31340           var vals = tags[oldKey].split(";").filter(Boolean);
31341           if (vals.length === 0) {
31342             return false;
31343           } else if (vals.length > 1) {
31344             return vals.indexOf(d2.old[oldKey]) !== -1;
31345           } else {
31346             if (tags[oldKey] === d2.old[oldKey]) {
31347               if (d2.replace && d2.old[oldKey] === d2.replace[oldKey]) {
31348                 var replaceKeys = Object.keys(d2.replace);
31349                 return !replaceKeys.every(function(replaceKey) {
31350                   return tags[replaceKey] === d2.replace[replaceKey];
31351                 });
31352               } else {
31353                 return true;
31354               }
31355             }
31356           }
31357           return false;
31358         });
31359         if (matchesDeprecatedTags) {
31360           deprecated.push(d2);
31361         }
31362       });
31363       return deprecated;
31364     }
31365   };
31366
31367   // modules/osm/lanes.js
31368   function osmLanes(entity) {
31369     if (entity.type !== "way")
31370       return null;
31371     if (!entity.tags.highway)
31372       return null;
31373     var tags = entity.tags;
31374     var isOneWay = entity.isOneWay();
31375     var laneCount = getLaneCount(tags, isOneWay);
31376     var maxspeed = parseMaxspeed(tags);
31377     var laneDirections = parseLaneDirections(tags, isOneWay, laneCount);
31378     var forward = laneDirections.forward;
31379     var backward = laneDirections.backward;
31380     var bothways = laneDirections.bothways;
31381     var turnLanes = {};
31382     turnLanes.unspecified = parseTurnLanes(tags["turn:lanes"]);
31383     turnLanes.forward = parseTurnLanes(tags["turn:lanes:forward"]);
31384     turnLanes.backward = parseTurnLanes(tags["turn:lanes:backward"]);
31385     var maxspeedLanes = {};
31386     maxspeedLanes.unspecified = parseMaxspeedLanes(tags["maxspeed:lanes"], maxspeed);
31387     maxspeedLanes.forward = parseMaxspeedLanes(tags["maxspeed:lanes:forward"], maxspeed);
31388     maxspeedLanes.backward = parseMaxspeedLanes(tags["maxspeed:lanes:backward"], maxspeed);
31389     var psvLanes = {};
31390     psvLanes.unspecified = parseMiscLanes(tags["psv:lanes"]);
31391     psvLanes.forward = parseMiscLanes(tags["psv:lanes:forward"]);
31392     psvLanes.backward = parseMiscLanes(tags["psv:lanes:backward"]);
31393     var busLanes = {};
31394     busLanes.unspecified = parseMiscLanes(tags["bus:lanes"]);
31395     busLanes.forward = parseMiscLanes(tags["bus:lanes:forward"]);
31396     busLanes.backward = parseMiscLanes(tags["bus:lanes:backward"]);
31397     var taxiLanes = {};
31398     taxiLanes.unspecified = parseMiscLanes(tags["taxi:lanes"]);
31399     taxiLanes.forward = parseMiscLanes(tags["taxi:lanes:forward"]);
31400     taxiLanes.backward = parseMiscLanes(tags["taxi:lanes:backward"]);
31401     var hovLanes = {};
31402     hovLanes.unspecified = parseMiscLanes(tags["hov:lanes"]);
31403     hovLanes.forward = parseMiscLanes(tags["hov:lanes:forward"]);
31404     hovLanes.backward = parseMiscLanes(tags["hov:lanes:backward"]);
31405     var hgvLanes = {};
31406     hgvLanes.unspecified = parseMiscLanes(tags["hgv:lanes"]);
31407     hgvLanes.forward = parseMiscLanes(tags["hgv:lanes:forward"]);
31408     hgvLanes.backward = parseMiscLanes(tags["hgv:lanes:backward"]);
31409     var bicyclewayLanes = {};
31410     bicyclewayLanes.unspecified = parseBicycleWay(tags["bicycleway:lanes"]);
31411     bicyclewayLanes.forward = parseBicycleWay(tags["bicycleway:lanes:forward"]);
31412     bicyclewayLanes.backward = parseBicycleWay(tags["bicycleway:lanes:backward"]);
31413     var lanesObj = {
31414       forward: [],
31415       backward: [],
31416       unspecified: []
31417     };
31418     mapToLanesObj(lanesObj, turnLanes, "turnLane");
31419     mapToLanesObj(lanesObj, maxspeedLanes, "maxspeed");
31420     mapToLanesObj(lanesObj, psvLanes, "psv");
31421     mapToLanesObj(lanesObj, busLanes, "bus");
31422     mapToLanesObj(lanesObj, taxiLanes, "taxi");
31423     mapToLanesObj(lanesObj, hovLanes, "hov");
31424     mapToLanesObj(lanesObj, hgvLanes, "hgv");
31425     mapToLanesObj(lanesObj, bicyclewayLanes, "bicycleway");
31426     return {
31427       metadata: {
31428         count: laneCount,
31429         oneway: isOneWay,
31430         forward,
31431         backward,
31432         bothways,
31433         turnLanes,
31434         maxspeed,
31435         maxspeedLanes,
31436         psvLanes,
31437         busLanes,
31438         taxiLanes,
31439         hovLanes,
31440         hgvLanes,
31441         bicyclewayLanes
31442       },
31443       lanes: lanesObj
31444     };
31445   }
31446   function getLaneCount(tags, isOneWay) {
31447     var count;
31448     if (tags.lanes) {
31449       count = parseInt(tags.lanes, 10);
31450       if (count > 0) {
31451         return count;
31452       }
31453     }
31454     switch (tags.highway) {
31455       case "trunk":
31456       case "motorway":
31457         count = isOneWay ? 2 : 4;
31458         break;
31459       default:
31460         count = isOneWay ? 1 : 2;
31461         break;
31462     }
31463     return count;
31464   }
31465   function parseMaxspeed(tags) {
31466     var maxspeed = tags.maxspeed;
31467     if (!maxspeed)
31468       return;
31469     var maxspeedRegex = /^([0-9][\.0-9]+?)(?:[ ]?(?:km\/h|kmh|kph|mph|knots))?$/;
31470     if (!maxspeedRegex.test(maxspeed))
31471       return;
31472     return parseInt(maxspeed, 10);
31473   }
31474   function parseLaneDirections(tags, isOneWay, laneCount) {
31475     var forward = parseInt(tags["lanes:forward"], 10);
31476     var backward = parseInt(tags["lanes:backward"], 10);
31477     var bothways = parseInt(tags["lanes:both_ways"], 10) > 0 ? 1 : 0;
31478     if (parseInt(tags.oneway, 10) === -1) {
31479       forward = 0;
31480       bothways = 0;
31481       backward = laneCount;
31482     } else if (isOneWay) {
31483       forward = laneCount;
31484       bothways = 0;
31485       backward = 0;
31486     } else if (isNaN(forward) && isNaN(backward)) {
31487       backward = Math.floor((laneCount - bothways) / 2);
31488       forward = laneCount - bothways - backward;
31489     } else if (isNaN(forward)) {
31490       if (backward > laneCount - bothways) {
31491         backward = laneCount - bothways;
31492       }
31493       forward = laneCount - bothways - backward;
31494     } else if (isNaN(backward)) {
31495       if (forward > laneCount - bothways) {
31496         forward = laneCount - bothways;
31497       }
31498       backward = laneCount - bothways - forward;
31499     }
31500     return {
31501       forward,
31502       backward,
31503       bothways
31504     };
31505   }
31506   function parseTurnLanes(tag2) {
31507     if (!tag2)
31508       return;
31509     var validValues = [
31510       "left",
31511       "slight_left",
31512       "sharp_left",
31513       "through",
31514       "right",
31515       "slight_right",
31516       "sharp_right",
31517       "reverse",
31518       "merge_to_left",
31519       "merge_to_right",
31520       "none"
31521     ];
31522     return tag2.split("|").map(function(s2) {
31523       if (s2 === "")
31524         s2 = "none";
31525       return s2.split(";").map(function(d2) {
31526         return validValues.indexOf(d2) === -1 ? "unknown" : d2;
31527       });
31528     });
31529   }
31530   function parseMaxspeedLanes(tag2, maxspeed) {
31531     if (!tag2)
31532       return;
31533     return tag2.split("|").map(function(s2) {
31534       if (s2 === "none")
31535         return s2;
31536       var m2 = parseInt(s2, 10);
31537       if (s2 === "" || m2 === maxspeed)
31538         return null;
31539       return isNaN(m2) ? "unknown" : m2;
31540     });
31541   }
31542   function parseMiscLanes(tag2) {
31543     if (!tag2)
31544       return;
31545     var validValues = [
31546       "yes",
31547       "no",
31548       "designated"
31549     ];
31550     return tag2.split("|").map(function(s2) {
31551       if (s2 === "")
31552         s2 = "no";
31553       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
31554     });
31555   }
31556   function parseBicycleWay(tag2) {
31557     if (!tag2)
31558       return;
31559     var validValues = [
31560       "yes",
31561       "no",
31562       "designated",
31563       "lane"
31564     ];
31565     return tag2.split("|").map(function(s2) {
31566       if (s2 === "")
31567         s2 = "no";
31568       return validValues.indexOf(s2) === -1 ? "unknown" : s2;
31569     });
31570   }
31571   function mapToLanesObj(lanesObj, data, key) {
31572     if (data.forward) {
31573       data.forward.forEach(function(l2, i3) {
31574         if (!lanesObj.forward[i3])
31575           lanesObj.forward[i3] = {};
31576         lanesObj.forward[i3][key] = l2;
31577       });
31578     }
31579     if (data.backward) {
31580       data.backward.forEach(function(l2, i3) {
31581         if (!lanesObj.backward[i3])
31582           lanesObj.backward[i3] = {};
31583         lanesObj.backward[i3][key] = l2;
31584       });
31585     }
31586     if (data.unspecified) {
31587       data.unspecified.forEach(function(l2, i3) {
31588         if (!lanesObj.unspecified[i3])
31589           lanesObj.unspecified[i3] = {};
31590         lanesObj.unspecified[i3][key] = l2;
31591       });
31592     }
31593   }
31594
31595   // modules/osm/way.js
31596   function osmWay() {
31597     if (!(this instanceof osmWay)) {
31598       return new osmWay().initialize(arguments);
31599     } else if (arguments.length) {
31600       this.initialize(arguments);
31601     }
31602   }
31603   osmEntity.way = osmWay;
31604   osmWay.prototype = Object.create(osmEntity.prototype);
31605   Object.assign(osmWay.prototype, {
31606     type: "way",
31607     nodes: [],
31608     copy: function(resolver, copies) {
31609       if (copies[this.id])
31610         return copies[this.id];
31611       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
31612       var nodes = this.nodes.map(function(id2) {
31613         return resolver.entity(id2).copy(resolver, copies).id;
31614       });
31615       copy2 = copy2.update({ nodes });
31616       copies[this.id] = copy2;
31617       return copy2;
31618     },
31619     extent: function(resolver) {
31620       return resolver.transient(this, "extent", function() {
31621         var extent = geoExtent();
31622         for (var i3 = 0; i3 < this.nodes.length; i3++) {
31623           var node = resolver.hasEntity(this.nodes[i3]);
31624           if (node) {
31625             extent._extend(node.extent());
31626           }
31627         }
31628         return extent;
31629       });
31630     },
31631     first: function() {
31632       return this.nodes[0];
31633     },
31634     last: function() {
31635       return this.nodes[this.nodes.length - 1];
31636     },
31637     contains: function(node) {
31638       return this.nodes.indexOf(node) >= 0;
31639     },
31640     affix: function(node) {
31641       if (this.nodes[0] === node)
31642         return "prefix";
31643       if (this.nodes[this.nodes.length - 1] === node)
31644         return "suffix";
31645     },
31646     layer: function() {
31647       if (isFinite(this.tags.layer)) {
31648         return Math.max(-10, Math.min(+this.tags.layer, 10));
31649       }
31650       if (this.tags.covered === "yes")
31651         return -1;
31652       if (this.tags.location === "overground")
31653         return 1;
31654       if (this.tags.location === "underground")
31655         return -1;
31656       if (this.tags.location === "underwater")
31657         return -10;
31658       if (this.tags.power === "line")
31659         return 10;
31660       if (this.tags.power === "minor_line")
31661         return 10;
31662       if (this.tags.aerialway)
31663         return 10;
31664       if (this.tags.bridge)
31665         return 1;
31666       if (this.tags.cutting)
31667         return -1;
31668       if (this.tags.tunnel)
31669         return -1;
31670       if (this.tags.waterway)
31671         return -1;
31672       if (this.tags.man_made === "pipeline")
31673         return -10;
31674       if (this.tags.boundary)
31675         return -10;
31676       return 0;
31677     },
31678     // the approximate width of the line based on its tags except its `width` tag
31679     impliedLineWidthMeters: function() {
31680       var averageWidths = {
31681         highway: {
31682           // width is for single lane
31683           motorway: 5,
31684           motorway_link: 5,
31685           trunk: 4.5,
31686           trunk_link: 4.5,
31687           primary: 4,
31688           secondary: 4,
31689           tertiary: 4,
31690           primary_link: 4,
31691           secondary_link: 4,
31692           tertiary_link: 4,
31693           unclassified: 4,
31694           road: 4,
31695           living_street: 4,
31696           bus_guideway: 4,
31697           busway: 4,
31698           pedestrian: 4,
31699           residential: 3.5,
31700           service: 3.5,
31701           track: 3,
31702           cycleway: 2.5,
31703           bridleway: 2,
31704           corridor: 2,
31705           steps: 2,
31706           path: 1.5,
31707           footway: 1.5
31708         },
31709         railway: {
31710           // width includes ties and rail bed, not just track gauge
31711           rail: 2.5,
31712           light_rail: 2.5,
31713           tram: 2.5,
31714           subway: 2.5,
31715           monorail: 2.5,
31716           funicular: 2.5,
31717           disused: 2.5,
31718           preserved: 2.5,
31719           miniature: 1.5,
31720           narrow_gauge: 1.5
31721         },
31722         waterway: {
31723           river: 50,
31724           canal: 25,
31725           stream: 5,
31726           tidal_channel: 5,
31727           fish_pass: 2.5,
31728           drain: 2.5,
31729           ditch: 1.5
31730         }
31731       };
31732       for (var key in averageWidths) {
31733         if (this.tags[key] && averageWidths[key][this.tags[key]]) {
31734           var width = averageWidths[key][this.tags[key]];
31735           if (key === "highway") {
31736             var laneCount = this.tags.lanes && parseInt(this.tags.lanes, 10);
31737             if (!laneCount)
31738               laneCount = this.isOneWay() ? 1 : 2;
31739             return width * laneCount;
31740           }
31741           return width;
31742         }
31743       }
31744       return null;
31745     },
31746     isOneWay: function() {
31747       var values = {
31748         "yes": true,
31749         "1": true,
31750         "-1": true,
31751         "reversible": true,
31752         "alternating": true,
31753         "no": false,
31754         "0": false
31755       };
31756       if (values[this.tags.oneway] !== void 0) {
31757         return values[this.tags.oneway];
31758       }
31759       for (var key in this.tags) {
31760         if (key in osmOneWayTags && this.tags[key] in osmOneWayTags[key]) {
31761           return true;
31762         }
31763       }
31764       return false;
31765     },
31766     // Some identifier for tag that implies that this way is "sided",
31767     // i.e. the right side is the 'inside' (e.g. the right side of a
31768     // natural=cliff is lower).
31769     sidednessIdentifier: function() {
31770       for (const realKey in this.tags) {
31771         const value = this.tags[realKey];
31772         const key = osmRemoveLifecyclePrefix(realKey);
31773         if (key in osmRightSideIsInsideTags && value in osmRightSideIsInsideTags[key]) {
31774           if (osmRightSideIsInsideTags[key][value] === true) {
31775             return key;
31776           } else {
31777             return osmRightSideIsInsideTags[key][value];
31778           }
31779         }
31780       }
31781       return null;
31782     },
31783     isSided: function() {
31784       if (this.tags.two_sided === "yes") {
31785         return false;
31786       }
31787       return this.sidednessIdentifier() !== null;
31788     },
31789     lanes: function() {
31790       return osmLanes(this);
31791     },
31792     isClosed: function() {
31793       return this.nodes.length > 1 && this.first() === this.last();
31794     },
31795     isConvex: function(resolver) {
31796       if (!this.isClosed() || this.isDegenerate())
31797         return null;
31798       var nodes = utilArrayUniq(resolver.childNodes(this));
31799       var coords = nodes.map(function(n3) {
31800         return n3.loc;
31801       });
31802       var curr = 0;
31803       var prev = 0;
31804       for (var i3 = 0; i3 < coords.length; i3++) {
31805         var o2 = coords[(i3 + 1) % coords.length];
31806         var a2 = coords[i3];
31807         var b2 = coords[(i3 + 2) % coords.length];
31808         var res = geoVecCross(a2, b2, o2);
31809         curr = res > 0 ? 1 : res < 0 ? -1 : 0;
31810         if (curr === 0) {
31811           continue;
31812         } else if (prev && curr !== prev) {
31813           return false;
31814         }
31815         prev = curr;
31816       }
31817       return true;
31818     },
31819     // returns an object with the tag that implies this is an area, if any
31820     tagSuggestingArea: function() {
31821       return osmTagSuggestingArea(this.tags);
31822     },
31823     isArea: function() {
31824       if (this.tags.area === "yes")
31825         return true;
31826       if (!this.isClosed() || this.tags.area === "no")
31827         return false;
31828       return this.tagSuggestingArea() !== null;
31829     },
31830     isDegenerate: function() {
31831       return new Set(this.nodes).size < (this.isArea() ? 3 : 2);
31832     },
31833     areAdjacent: function(n1, n22) {
31834       for (var i3 = 0; i3 < this.nodes.length; i3++) {
31835         if (this.nodes[i3] === n1) {
31836           if (this.nodes[i3 - 1] === n22)
31837             return true;
31838           if (this.nodes[i3 + 1] === n22)
31839             return true;
31840         }
31841       }
31842       return false;
31843     },
31844     geometry: function(graph) {
31845       return graph.transient(this, "geometry", function() {
31846         return this.isArea() ? "area" : "line";
31847       });
31848     },
31849     // returns an array of objects representing the segments between the nodes in this way
31850     segments: function(graph) {
31851       function segmentExtent(graph2) {
31852         var n1 = graph2.hasEntity(this.nodes[0]);
31853         var n22 = graph2.hasEntity(this.nodes[1]);
31854         return n1 && n22 && geoExtent([
31855           [
31856             Math.min(n1.loc[0], n22.loc[0]),
31857             Math.min(n1.loc[1], n22.loc[1])
31858           ],
31859           [
31860             Math.max(n1.loc[0], n22.loc[0]),
31861             Math.max(n1.loc[1], n22.loc[1])
31862           ]
31863         ]);
31864       }
31865       return graph.transient(this, "segments", function() {
31866         var segments = [];
31867         for (var i3 = 0; i3 < this.nodes.length - 1; i3++) {
31868           segments.push({
31869             id: this.id + "-" + i3,
31870             wayId: this.id,
31871             index: i3,
31872             nodes: [this.nodes[i3], this.nodes[i3 + 1]],
31873             extent: segmentExtent
31874           });
31875         }
31876         return segments;
31877       });
31878     },
31879     // If this way is not closed, append the beginning node to the end of the nodelist to close it.
31880     close: function() {
31881       if (this.isClosed() || !this.nodes.length)
31882         return this;
31883       var nodes = this.nodes.slice();
31884       nodes = nodes.filter(noRepeatNodes);
31885       nodes.push(nodes[0]);
31886       return this.update({ nodes });
31887     },
31888     // If this way is closed, remove any connector nodes from the end of the nodelist to unclose it.
31889     unclose: function() {
31890       if (!this.isClosed())
31891         return this;
31892       var nodes = this.nodes.slice();
31893       var connector = this.first();
31894       var i3 = nodes.length - 1;
31895       while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
31896         nodes.splice(i3, 1);
31897         i3 = nodes.length - 1;
31898       }
31899       nodes = nodes.filter(noRepeatNodes);
31900       return this.update({ nodes });
31901     },
31902     // Adds a node (id) in front of the node which is currently at position index.
31903     // If index is undefined, the node will be added to the end of the way for linear ways,
31904     //   or just before the final connecting node for circular ways.
31905     // Consecutive duplicates are eliminated including existing ones.
31906     // Circularity is always preserved when adding a node.
31907     addNode: function(id2, index) {
31908       var nodes = this.nodes.slice();
31909       var isClosed = this.isClosed();
31910       var max3 = isClosed ? nodes.length - 1 : nodes.length;
31911       if (index === void 0) {
31912         index = max3;
31913       }
31914       if (index < 0 || index > max3) {
31915         throw new RangeError("index " + index + " out of range 0.." + max3);
31916       }
31917       if (isClosed) {
31918         var connector = this.first();
31919         var i3 = 1;
31920         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
31921           nodes.splice(i3, 1);
31922           if (index > i3)
31923             index--;
31924         }
31925         i3 = nodes.length - 1;
31926         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
31927           nodes.splice(i3, 1);
31928           if (index > i3)
31929             index--;
31930           i3 = nodes.length - 1;
31931         }
31932       }
31933       nodes.splice(index, 0, id2);
31934       nodes = nodes.filter(noRepeatNodes);
31935       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31936         nodes.push(nodes[0]);
31937       }
31938       return this.update({ nodes });
31939     },
31940     // Replaces the node which is currently at position index with the given node (id).
31941     // Consecutive duplicates are eliminated including existing ones.
31942     // Circularity is preserved when updating a node.
31943     updateNode: function(id2, index) {
31944       var nodes = this.nodes.slice();
31945       var isClosed = this.isClosed();
31946       var max3 = nodes.length - 1;
31947       if (index === void 0 || index < 0 || index > max3) {
31948         throw new RangeError("index " + index + " out of range 0.." + max3);
31949       }
31950       if (isClosed) {
31951         var connector = this.first();
31952         var i3 = 1;
31953         while (i3 < nodes.length && nodes.length > 2 && nodes[i3] === connector) {
31954           nodes.splice(i3, 1);
31955           if (index > i3)
31956             index--;
31957         }
31958         i3 = nodes.length - 1;
31959         while (i3 > 0 && nodes.length > 1 && nodes[i3] === connector) {
31960           nodes.splice(i3, 1);
31961           if (index === i3)
31962             index = 0;
31963           i3 = nodes.length - 1;
31964         }
31965       }
31966       nodes.splice(index, 1, id2);
31967       nodes = nodes.filter(noRepeatNodes);
31968       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31969         nodes.push(nodes[0]);
31970       }
31971       return this.update({ nodes });
31972     },
31973     // Replaces each occurrence of node id needle with replacement.
31974     // Consecutive duplicates are eliminated including existing ones.
31975     // Circularity is preserved.
31976     replaceNode: function(needleID, replacementID) {
31977       var nodes = this.nodes.slice();
31978       var isClosed = this.isClosed();
31979       for (var i3 = 0; i3 < nodes.length; i3++) {
31980         if (nodes[i3] === needleID) {
31981           nodes[i3] = replacementID;
31982         }
31983       }
31984       nodes = nodes.filter(noRepeatNodes);
31985       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
31986         nodes.push(nodes[0]);
31987       }
31988       return this.update({ nodes });
31989     },
31990     // Removes each occurrence of node id.
31991     // Consecutive duplicates are eliminated including existing ones.
31992     // Circularity is preserved.
31993     removeNode: function(id2) {
31994       var nodes = this.nodes.slice();
31995       var isClosed = this.isClosed();
31996       nodes = nodes.filter(function(node) {
31997         return node !== id2;
31998       }).filter(noRepeatNodes);
31999       if (isClosed && (nodes.length === 1 || nodes[0] !== nodes[nodes.length - 1])) {
32000         nodes.push(nodes[0]);
32001       }
32002       return this.update({ nodes });
32003     },
32004     asJXON: function(changeset_id) {
32005       var r2 = {
32006         way: {
32007           "@id": this.osmId(),
32008           "@version": this.version || 0,
32009           nd: this.nodes.map(function(id2) {
32010             return { keyAttributes: { ref: osmEntity.id.toOSM(id2) } };
32011           }, this),
32012           tag: Object.keys(this.tags).map(function(k2) {
32013             return { keyAttributes: { k: k2, v: this.tags[k2] } };
32014           }, this)
32015         }
32016       };
32017       if (changeset_id) {
32018         r2.way["@changeset"] = changeset_id;
32019       }
32020       return r2;
32021     },
32022     asGeoJSON: function(resolver) {
32023       return resolver.transient(this, "GeoJSON", function() {
32024         var coordinates = resolver.childNodes(this).map(function(n3) {
32025           return n3.loc;
32026         });
32027         if (this.isArea() && this.isClosed()) {
32028           return {
32029             type: "Polygon",
32030             coordinates: [coordinates]
32031           };
32032         } else {
32033           return {
32034             type: "LineString",
32035             coordinates
32036           };
32037         }
32038       });
32039     },
32040     area: function(resolver) {
32041       return resolver.transient(this, "area", function() {
32042         var nodes = resolver.childNodes(this);
32043         var json = {
32044           type: "Polygon",
32045           coordinates: [nodes.map(function(n3) {
32046             return n3.loc;
32047           })]
32048         };
32049         if (!this.isClosed() && nodes.length) {
32050           json.coordinates[0].push(nodes[0].loc);
32051         }
32052         var area = area_default(json);
32053         if (area > 2 * Math.PI) {
32054           json.coordinates[0] = json.coordinates[0].reverse();
32055           area = area_default(json);
32056         }
32057         return isNaN(area) ? 0 : area;
32058       });
32059     }
32060   });
32061   function noRepeatNodes(node, i3, arr) {
32062     return i3 === 0 || node !== arr[i3 - 1];
32063   }
32064
32065   // modules/osm/multipolygon.js
32066   function osmOldMultipolygonOuterMemberOfRelation(entity, graph) {
32067     if (entity.type !== "relation" || !entity.isMultipolygon() || Object.keys(entity.tags).filter(osmIsInterestingTag).length > 1) {
32068       return false;
32069     }
32070     var outerMember;
32071     for (var memberIndex in entity.members) {
32072       var member = entity.members[memberIndex];
32073       if (!member.role || member.role === "outer") {
32074         if (outerMember)
32075           return false;
32076         if (member.type !== "way")
32077           return false;
32078         if (!graph.hasEntity(member.id))
32079           return false;
32080         outerMember = graph.entity(member.id);
32081         if (Object.keys(outerMember.tags).filter(osmIsInterestingTag).length === 0) {
32082           return false;
32083         }
32084       }
32085     }
32086     return outerMember;
32087   }
32088   function osmIsOldMultipolygonOuterMember(entity, graph) {
32089     if (entity.type !== "way" || Object.keys(entity.tags).filter(osmIsInterestingTag).length === 0) {
32090       return false;
32091     }
32092     var parents = graph.parentRelations(entity);
32093     if (parents.length !== 1)
32094       return false;
32095     var parent = parents[0];
32096     if (!parent.isMultipolygon() || Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1) {
32097       return false;
32098     }
32099     var members = parent.members, member;
32100     for (var i3 = 0; i3 < members.length; i3++) {
32101       member = members[i3];
32102       if (member.id === entity.id && member.role && member.role !== "outer") {
32103         return false;
32104       }
32105       if (member.id !== entity.id && (!member.role || member.role === "outer")) {
32106         return false;
32107       }
32108     }
32109     return parent;
32110   }
32111   function osmOldMultipolygonOuterMember(entity, graph) {
32112     if (entity.type !== "way")
32113       return false;
32114     var parents = graph.parentRelations(entity);
32115     if (parents.length !== 1)
32116       return false;
32117     var parent = parents[0];
32118     if (!parent.isMultipolygon() || Object.keys(parent.tags).filter(osmIsInterestingTag).length > 1) {
32119       return false;
32120     }
32121     var members = parent.members, member, outerMember;
32122     for (var i3 = 0; i3 < members.length; i3++) {
32123       member = members[i3];
32124       if (!member.role || member.role === "outer") {
32125         if (outerMember)
32126           return false;
32127         outerMember = member;
32128       }
32129     }
32130     if (!outerMember)
32131       return false;
32132     var outerEntity = graph.hasEntity(outerMember.id);
32133     if (!outerEntity || !Object.keys(outerEntity.tags).filter(osmIsInterestingTag).length) {
32134       return false;
32135     }
32136     return outerEntity;
32137   }
32138   function osmJoinWays(toJoin, graph) {
32139     function resolve(member) {
32140       return graph.childNodes(graph.entity(member.id));
32141     }
32142     function reverse(item2) {
32143       var action = actionReverse(item2.id, { reverseOneway: true });
32144       sequences.actions.push(action);
32145       return item2 instanceof osmWay ? action(graph).entity(item2.id) : item2;
32146     }
32147     toJoin = toJoin.filter(function(member) {
32148       return member.type === "way" && graph.hasEntity(member.id);
32149     });
32150     var i3;
32151     var joinAsMembers = true;
32152     for (i3 = 0; i3 < toJoin.length; i3++) {
32153       if (toJoin[i3] instanceof osmWay) {
32154         joinAsMembers = false;
32155         break;
32156       }
32157     }
32158     var sequences = [];
32159     sequences.actions = [];
32160     while (toJoin.length) {
32161       var item = toJoin.shift();
32162       var currWays = [item];
32163       var currNodes = resolve(item).slice();
32164       while (toJoin.length) {
32165         var start2 = currNodes[0];
32166         var end = currNodes[currNodes.length - 1];
32167         var fn = null;
32168         var nodes = null;
32169         for (i3 = 0; i3 < toJoin.length; i3++) {
32170           item = toJoin[i3];
32171           nodes = resolve(item);
32172           if (joinAsMembers && currWays.length === 1 && nodes[0] !== end && nodes[nodes.length - 1] !== end && (nodes[nodes.length - 1] === start2 || nodes[0] === start2)) {
32173             currWays[0] = reverse(currWays[0]);
32174             currNodes.reverse();
32175             start2 = currNodes[0];
32176             end = currNodes[currNodes.length - 1];
32177           }
32178           if (nodes[0] === end) {
32179             fn = currNodes.push;
32180             nodes = nodes.slice(1);
32181             break;
32182           } else if (nodes[nodes.length - 1] === end) {
32183             fn = currNodes.push;
32184             nodes = nodes.slice(0, -1).reverse();
32185             item = reverse(item);
32186             break;
32187           } else if (nodes[nodes.length - 1] === start2) {
32188             fn = currNodes.unshift;
32189             nodes = nodes.slice(0, -1);
32190             break;
32191           } else if (nodes[0] === start2) {
32192             fn = currNodes.unshift;
32193             nodes = nodes.slice(1).reverse();
32194             item = reverse(item);
32195             break;
32196           } else {
32197             fn = nodes = null;
32198           }
32199         }
32200         if (!nodes) {
32201           break;
32202         }
32203         fn.apply(currWays, [item]);
32204         fn.apply(currNodes, nodes);
32205         toJoin.splice(i3, 1);
32206       }
32207       currWays.nodes = currNodes;
32208       sequences.push(currWays);
32209     }
32210     return sequences;
32211   }
32212
32213   // modules/actions/add_member.js
32214   function actionAddMember(relationId, member, memberIndex, insertPair) {
32215     return function action(graph) {
32216       var relation = graph.entity(relationId);
32217       var isPTv2 = /stop|platform/.test(member.role);
32218       if ((isNaN(memberIndex) || insertPair) && member.type === "way" && !isPTv2) {
32219         graph = addWayMember(relation, graph);
32220       } else {
32221         if (isPTv2 && isNaN(memberIndex)) {
32222           memberIndex = 0;
32223         }
32224         graph = graph.replace(relation.addMember(member, memberIndex));
32225       }
32226       return graph;
32227     };
32228     function addWayMember(relation, graph) {
32229       var groups, tempWay, insertPairIsReversed, item, i3, j2, k2;
32230       var PTv2members = [];
32231       var members = [];
32232       for (i3 = 0; i3 < relation.members.length; i3++) {
32233         var m2 = relation.members[i3];
32234         if (/stop|platform/.test(m2.role)) {
32235           PTv2members.push(m2);
32236         } else {
32237           members.push(m2);
32238         }
32239       }
32240       relation = relation.update({ members });
32241       if (insertPair) {
32242         tempWay = osmWay({ id: "wTemp", nodes: insertPair.nodes });
32243         graph = graph.replace(tempWay);
32244         var tempMember = { id: tempWay.id, type: "way", role: member.role };
32245         var tempRelation = relation.replaceMember({ id: insertPair.originalID }, tempMember, true);
32246         groups = utilArrayGroupBy(tempRelation.members, "type");
32247         groups.way = groups.way || [];
32248         var originalWay = graph.entity(insertPair.originalID);
32249         var insertedWay = graph.entity(insertPair.insertedID);
32250         insertPairIsReversed = originalWay.nodes.length > 0 && insertedWay.nodes.length > 0 && insertedWay.nodes[insertedWay.nodes.length - 1] === originalWay.nodes[0] && originalWay.nodes[originalWay.nodes.length - 1] !== insertedWay.nodes[0];
32251       } else {
32252         groups = utilArrayGroupBy(relation.members, "type");
32253         groups.way = groups.way || [];
32254         groups.way.push(member);
32255       }
32256       members = withIndex(groups.way);
32257       var joined = osmJoinWays(members, graph);
32258       for (i3 = 0; i3 < joined.length; i3++) {
32259         var segment = joined[i3];
32260         var nodes = segment.nodes.slice();
32261         var startIndex = segment[0].index;
32262         for (j2 = 0; j2 < members.length; j2++) {
32263           if (members[j2].index === startIndex) {
32264             break;
32265           }
32266         }
32267         for (k2 = 0; k2 < segment.length; k2++) {
32268           item = segment[k2];
32269           var way = graph.entity(item.id);
32270           if (tempWay && item.id === tempWay.id) {
32271             var reverse = nodes[0].id !== insertPair.nodes[0] ^ insertPairIsReversed;
32272             if (reverse) {
32273               item.pair = [
32274                 { id: insertPair.insertedID, type: "way", role: item.role },
32275                 { id: insertPair.originalID, type: "way", role: item.role }
32276               ];
32277             } else {
32278               item.pair = [
32279                 { id: insertPair.originalID, type: "way", role: item.role },
32280                 { id: insertPair.insertedID, type: "way", role: item.role }
32281               ];
32282             }
32283           }
32284           if (k2 > 0) {
32285             if (j2 + k2 >= members.length || item.index !== members[j2 + k2].index) {
32286               moveMember(members, item.index, j2 + k2);
32287             }
32288           }
32289           nodes.splice(0, way.nodes.length - 1);
32290         }
32291       }
32292       if (tempWay) {
32293         graph = graph.remove(tempWay);
32294       }
32295       var wayMembers = [];
32296       for (i3 = 0; i3 < members.length; i3++) {
32297         item = members[i3];
32298         if (item.index === -1)
32299           continue;
32300         if (item.pair) {
32301           wayMembers.push(item.pair[0]);
32302           wayMembers.push(item.pair[1]);
32303         } else {
32304           wayMembers.push(utilObjectOmit(item, ["index"]));
32305         }
32306       }
32307       var newMembers = PTv2members.concat(groups.node || [], wayMembers, groups.relation || []);
32308       return graph.replace(relation.update({ members: newMembers }));
32309       function moveMember(arr, findIndex, toIndex) {
32310         var i4;
32311         for (i4 = 0; i4 < arr.length; i4++) {
32312           if (arr[i4].index === findIndex) {
32313             break;
32314           }
32315         }
32316         var item2 = Object.assign({}, arr[i4]);
32317         arr[i4].index = -1;
32318         item2.index = toIndex;
32319         arr.splice(toIndex, 0, item2);
32320       }
32321       function withIndex(arr) {
32322         var result = new Array(arr.length);
32323         for (var i4 = 0; i4 < arr.length; i4++) {
32324           result[i4] = Object.assign({}, arr[i4]);
32325           result[i4].index = i4;
32326         }
32327         return result;
32328       }
32329     }
32330   }
32331
32332   // modules/actions/add_midpoint.js
32333   function actionAddMidpoint(midpoint, node) {
32334     return function(graph) {
32335       graph = graph.replace(node.move(midpoint.loc));
32336       var parents = utilArrayIntersection(
32337         graph.parentWays(graph.entity(midpoint.edge[0])),
32338         graph.parentWays(graph.entity(midpoint.edge[1]))
32339       );
32340       parents.forEach(function(way) {
32341         for (var i3 = 0; i3 < way.nodes.length - 1; i3++) {
32342           if (geoEdgeEqual([way.nodes[i3], way.nodes[i3 + 1]], midpoint.edge)) {
32343             graph = graph.replace(graph.entity(way.id).addNode(node.id, i3 + 1));
32344             return;
32345           }
32346         }
32347       });
32348       return graph;
32349     };
32350   }
32351
32352   // modules/actions/add_vertex.js
32353   function actionAddVertex(wayId, nodeId, index) {
32354     return function(graph) {
32355       return graph.replace(graph.entity(wayId).addNode(nodeId, index));
32356     };
32357   }
32358
32359   // modules/actions/change_member.js
32360   function actionChangeMember(relationId, member, memberIndex) {
32361     return function(graph) {
32362       return graph.replace(graph.entity(relationId).updateMember(member, memberIndex));
32363     };
32364   }
32365
32366   // modules/actions/change_preset.js
32367   function actionChangePreset(entityID, oldPreset, newPreset, skipFieldDefaults) {
32368     return function action(graph) {
32369       var entity = graph.entity(entityID);
32370       var geometry = entity.geometry(graph);
32371       var tags = entity.tags;
32372       const loc = entity.extent(graph).center();
32373       var preserveKeys;
32374       if (newPreset) {
32375         preserveKeys = [];
32376         if (newPreset.addTags) {
32377           preserveKeys = preserveKeys.concat(Object.keys(newPreset.addTags));
32378         }
32379         if (oldPreset && !oldPreset.id.startsWith(newPreset.id)) {
32380           newPreset.fields(loc).concat(newPreset.moreFields(loc)).filter((f2) => f2.matchGeometry(geometry)).map((f2) => f2.key).filter(Boolean).forEach((key) => preserveKeys.push(key));
32381         }
32382       }
32383       if (oldPreset)
32384         tags = oldPreset.unsetTags(tags, geometry, preserveKeys, false, loc);
32385       if (newPreset)
32386         tags = newPreset.setTags(tags, geometry, skipFieldDefaults, loc);
32387       return graph.replace(entity.update({ tags }));
32388     };
32389   }
32390
32391   // modules/actions/change_tags.js
32392   function actionChangeTags(entityId, tags) {
32393     return function(graph) {
32394       var entity = graph.entity(entityId);
32395       return graph.replace(entity.update({ tags }));
32396     };
32397   }
32398
32399   // modules/osm/node.js
32400   var cardinal = {
32401     north: 0,
32402     n: 0,
32403     northnortheast: 22,
32404     nne: 22,
32405     northeast: 45,
32406     ne: 45,
32407     eastnortheast: 67,
32408     ene: 67,
32409     east: 90,
32410     e: 90,
32411     eastsoutheast: 112,
32412     ese: 112,
32413     southeast: 135,
32414     se: 135,
32415     southsoutheast: 157,
32416     sse: 157,
32417     south: 180,
32418     s: 180,
32419     southsouthwest: 202,
32420     ssw: 202,
32421     southwest: 225,
32422     sw: 225,
32423     westsouthwest: 247,
32424     wsw: 247,
32425     west: 270,
32426     w: 270,
32427     westnorthwest: 292,
32428     wnw: 292,
32429     northwest: 315,
32430     nw: 315,
32431     northnorthwest: 337,
32432     nnw: 337
32433   };
32434   function osmNode() {
32435     if (!(this instanceof osmNode)) {
32436       return new osmNode().initialize(arguments);
32437     } else if (arguments.length) {
32438       this.initialize(arguments);
32439     }
32440   }
32441   osmEntity.node = osmNode;
32442   osmNode.prototype = Object.create(osmEntity.prototype);
32443   Object.assign(osmNode.prototype, {
32444     type: "node",
32445     loc: [9999, 9999],
32446     extent: function() {
32447       return new geoExtent(this.loc);
32448     },
32449     geometry: function(graph) {
32450       return graph.transient(this, "geometry", function() {
32451         return graph.isPoi(this) ? "point" : "vertex";
32452       });
32453     },
32454     move: function(loc) {
32455       return this.update({ loc });
32456     },
32457     isDegenerate: function() {
32458       return !(Array.isArray(this.loc) && this.loc.length === 2 && this.loc[0] >= -180 && this.loc[0] <= 180 && this.loc[1] >= -90 && this.loc[1] <= 90);
32459     },
32460     // Inspect tags and geometry to determine which direction(s) this node/vertex points
32461     directions: function(resolver, projection2) {
32462       var val;
32463       var i3;
32464       if (this.isHighwayIntersection(resolver) && (this.tags.stop || "").toLowerCase() === "all") {
32465         val = "all";
32466       } else {
32467         val = (this.tags.direction || "").toLowerCase();
32468         var re3 = /:direction$/i;
32469         var keys2 = Object.keys(this.tags);
32470         for (i3 = 0; i3 < keys2.length; i3++) {
32471           if (re3.test(keys2[i3])) {
32472             val = this.tags[keys2[i3]].toLowerCase();
32473             break;
32474           }
32475         }
32476       }
32477       if (val === "")
32478         return [];
32479       var values = val.split(";");
32480       var results = [];
32481       values.forEach(function(v2) {
32482         if (cardinal[v2] !== void 0) {
32483           v2 = cardinal[v2];
32484         }
32485         if (v2 !== "" && !isNaN(+v2)) {
32486           results.push(+v2);
32487           return;
32488         }
32489         var lookBackward = this.tags["traffic_sign:backward"] || v2 === "backward" || v2 === "both" || v2 === "all";
32490         var lookForward = this.tags["traffic_sign:forward"] || v2 === "forward" || v2 === "both" || v2 === "all";
32491         if (!lookForward && !lookBackward)
32492           return;
32493         var nodeIds = {};
32494         resolver.parentWays(this).forEach(function(parent) {
32495           var nodes = parent.nodes;
32496           for (i3 = 0; i3 < nodes.length; i3++) {
32497             if (nodes[i3] === this.id) {
32498               if (lookForward && i3 > 0) {
32499                 nodeIds[nodes[i3 - 1]] = true;
32500               }
32501               if (lookBackward && i3 < nodes.length - 1) {
32502                 nodeIds[nodes[i3 + 1]] = true;
32503               }
32504             }
32505           }
32506         }, this);
32507         Object.keys(nodeIds).forEach(function(nodeId) {
32508           results.push(
32509             geoAngle(this, resolver.entity(nodeId), projection2) * (180 / Math.PI) + 90
32510           );
32511         }, this);
32512       }, this);
32513       return utilArrayUniq(results);
32514     },
32515     isCrossing: function() {
32516       return this.tags.highway === "crossing" || this.tags.railway && this.tags.railway.indexOf("crossing") !== -1;
32517     },
32518     isEndpoint: function(resolver) {
32519       return resolver.transient(this, "isEndpoint", function() {
32520         var id2 = this.id;
32521         return resolver.parentWays(this).filter(function(parent) {
32522           return !parent.isClosed() && !!parent.affix(id2);
32523         }).length > 0;
32524       });
32525     },
32526     isConnected: function(resolver) {
32527       return resolver.transient(this, "isConnected", function() {
32528         var parents = resolver.parentWays(this);
32529         if (parents.length > 1) {
32530           for (var i3 in parents) {
32531             if (parents[i3].geometry(resolver) === "line" && parents[i3].hasInterestingTags())
32532               return true;
32533           }
32534         } else if (parents.length === 1) {
32535           var way = parents[0];
32536           var nodes = way.nodes.slice();
32537           if (way.isClosed()) {
32538             nodes.pop();
32539           }
32540           return nodes.indexOf(this.id) !== nodes.lastIndexOf(this.id);
32541         }
32542         return false;
32543       });
32544     },
32545     parentIntersectionWays: function(resolver) {
32546       return resolver.transient(this, "parentIntersectionWays", function() {
32547         return resolver.parentWays(this).filter(function(parent) {
32548           return (parent.tags.highway || parent.tags.waterway || parent.tags.railway || parent.tags.aeroway) && parent.geometry(resolver) === "line";
32549         });
32550       });
32551     },
32552     isIntersection: function(resolver) {
32553       return this.parentIntersectionWays(resolver).length > 1;
32554     },
32555     isHighwayIntersection: function(resolver) {
32556       return resolver.transient(this, "isHighwayIntersection", function() {
32557         return resolver.parentWays(this).filter(function(parent) {
32558           return parent.tags.highway && parent.geometry(resolver) === "line";
32559         }).length > 1;
32560       });
32561     },
32562     isOnAddressLine: function(resolver) {
32563       return resolver.transient(this, "isOnAddressLine", function() {
32564         return resolver.parentWays(this).filter(function(parent) {
32565           return parent.tags.hasOwnProperty("addr:interpolation") && parent.geometry(resolver) === "line";
32566         }).length > 0;
32567       });
32568     },
32569     asJXON: function(changeset_id) {
32570       var r2 = {
32571         node: {
32572           "@id": this.osmId(),
32573           "@lon": this.loc[0],
32574           "@lat": this.loc[1],
32575           "@version": this.version || 0,
32576           tag: Object.keys(this.tags).map(function(k2) {
32577             return { keyAttributes: { k: k2, v: this.tags[k2] } };
32578           }, this)
32579         }
32580       };
32581       if (changeset_id)
32582         r2.node["@changeset"] = changeset_id;
32583       return r2;
32584     },
32585     asGeoJSON: function() {
32586       return {
32587         type: "Point",
32588         coordinates: this.loc
32589       };
32590     }
32591   });
32592
32593   // modules/actions/circularize.js
32594   function actionCircularize(wayId, projection2, maxAngle) {
32595     maxAngle = (maxAngle || 20) * Math.PI / 180;
32596     var action = function(graph, t2) {
32597       if (t2 === null || !isFinite(t2))
32598         t2 = 1;
32599       t2 = Math.min(Math.max(+t2, 0), 1);
32600       var way = graph.entity(wayId);
32601       var origNodes = {};
32602       graph.childNodes(way).forEach(function(node2) {
32603         if (!origNodes[node2.id])
32604           origNodes[node2.id] = node2;
32605       });
32606       if (!way.isConvex(graph)) {
32607         graph = action.makeConvex(graph);
32608       }
32609       var nodes = utilArrayUniq(graph.childNodes(way));
32610       var keyNodes = nodes.filter(function(n3) {
32611         return graph.parentWays(n3).length !== 1;
32612       });
32613       var points = nodes.map(function(n3) {
32614         return projection2(n3.loc);
32615       });
32616       var keyPoints = keyNodes.map(function(n3) {
32617         return projection2(n3.loc);
32618       });
32619       var centroid = points.length === 2 ? geoVecInterp(points[0], points[1], 0.5) : centroid_default2(points);
32620       var radius = median(points, function(p2) {
32621         return geoVecLength(centroid, p2);
32622       });
32623       var sign2 = area_default3(points) > 0 ? 1 : -1;
32624       var ids, i3, j2, k2;
32625       if (!keyNodes.length) {
32626         keyNodes = [nodes[0]];
32627         keyPoints = [points[0]];
32628       }
32629       if (keyNodes.length === 1) {
32630         var index = nodes.indexOf(keyNodes[0]);
32631         var oppositeIndex = Math.floor((index + nodes.length / 2) % nodes.length);
32632         keyNodes.push(nodes[oppositeIndex]);
32633         keyPoints.push(points[oppositeIndex]);
32634       }
32635       for (i3 = 0; i3 < keyPoints.length; i3++) {
32636         var nextKeyNodeIndex = (i3 + 1) % keyNodes.length;
32637         var startNode = keyNodes[i3];
32638         var endNode = keyNodes[nextKeyNodeIndex];
32639         var startNodeIndex = nodes.indexOf(startNode);
32640         var endNodeIndex = nodes.indexOf(endNode);
32641         var numberNewPoints = -1;
32642         var indexRange = endNodeIndex - startNodeIndex;
32643         var nearNodes = {};
32644         var inBetweenNodes = [];
32645         var startAngle, endAngle, totalAngle, eachAngle;
32646         var angle2, loc, node, origNode;
32647         if (indexRange < 0) {
32648           indexRange += nodes.length;
32649         }
32650         var distance = geoVecLength(centroid, keyPoints[i3]) || 1e-4;
32651         keyPoints[i3] = [
32652           centroid[0] + (keyPoints[i3][0] - centroid[0]) / distance * radius,
32653           centroid[1] + (keyPoints[i3][1] - centroid[1]) / distance * radius
32654         ];
32655         loc = projection2.invert(keyPoints[i3]);
32656         node = keyNodes[i3];
32657         origNode = origNodes[node.id];
32658         node = node.move(geoVecInterp(origNode.loc, loc, t2));
32659         graph = graph.replace(node);
32660         startAngle = Math.atan2(keyPoints[i3][1] - centroid[1], keyPoints[i3][0] - centroid[0]);
32661         endAngle = Math.atan2(keyPoints[nextKeyNodeIndex][1] - centroid[1], keyPoints[nextKeyNodeIndex][0] - centroid[0]);
32662         totalAngle = endAngle - startAngle;
32663         if (totalAngle * sign2 > 0) {
32664           totalAngle = -sign2 * (2 * Math.PI - Math.abs(totalAngle));
32665         }
32666         do {
32667           numberNewPoints++;
32668           eachAngle = totalAngle / (indexRange + numberNewPoints);
32669         } while (Math.abs(eachAngle) > maxAngle);
32670         for (j2 = 1; j2 < indexRange; j2++) {
32671           angle2 = startAngle + j2 * eachAngle;
32672           loc = projection2.invert([
32673             centroid[0] + Math.cos(angle2) * radius,
32674             centroid[1] + Math.sin(angle2) * radius
32675           ]);
32676           node = nodes[(j2 + startNodeIndex) % nodes.length];
32677           origNode = origNodes[node.id];
32678           nearNodes[node.id] = angle2;
32679           node = node.move(geoVecInterp(origNode.loc, loc, t2));
32680           graph = graph.replace(node);
32681         }
32682         for (j2 = 0; j2 < numberNewPoints; j2++) {
32683           angle2 = startAngle + (indexRange + j2) * eachAngle;
32684           loc = projection2.invert([
32685             centroid[0] + Math.cos(angle2) * radius,
32686             centroid[1] + Math.sin(angle2) * radius
32687           ]);
32688           var min3 = Infinity;
32689           for (var nodeId in nearNodes) {
32690             var nearAngle = nearNodes[nodeId];
32691             var dist = Math.abs(nearAngle - angle2);
32692             if (dist < min3) {
32693               min3 = dist;
32694               origNode = origNodes[nodeId];
32695             }
32696           }
32697           node = osmNode({ loc: geoVecInterp(origNode.loc, loc, t2) });
32698           graph = graph.replace(node);
32699           nodes.splice(endNodeIndex + j2, 0, node);
32700           inBetweenNodes.push(node.id);
32701         }
32702         if (indexRange === 1 && inBetweenNodes.length) {
32703           var startIndex1 = way.nodes.lastIndexOf(startNode.id);
32704           var endIndex1 = way.nodes.lastIndexOf(endNode.id);
32705           var wayDirection1 = endIndex1 - startIndex1;
32706           if (wayDirection1 < -1) {
32707             wayDirection1 = 1;
32708           }
32709           var parentWays = graph.parentWays(keyNodes[i3]);
32710           for (j2 = 0; j2 < parentWays.length; j2++) {
32711             var sharedWay = parentWays[j2];
32712             if (sharedWay === way)
32713               continue;
32714             if (sharedWay.areAdjacent(startNode.id, endNode.id)) {
32715               var startIndex2 = sharedWay.nodes.lastIndexOf(startNode.id);
32716               var endIndex2 = sharedWay.nodes.lastIndexOf(endNode.id);
32717               var wayDirection2 = endIndex2 - startIndex2;
32718               var insertAt = endIndex2;
32719               if (wayDirection2 < -1) {
32720                 wayDirection2 = 1;
32721               }
32722               if (wayDirection1 !== wayDirection2) {
32723                 inBetweenNodes.reverse();
32724                 insertAt = startIndex2;
32725               }
32726               for (k2 = 0; k2 < inBetweenNodes.length; k2++) {
32727                 sharedWay = sharedWay.addNode(inBetweenNodes[k2], insertAt + k2);
32728               }
32729               graph = graph.replace(sharedWay);
32730             }
32731           }
32732         }
32733       }
32734       ids = nodes.map(function(n3) {
32735         return n3.id;
32736       });
32737       ids.push(ids[0]);
32738       way = way.update({ nodes: ids });
32739       graph = graph.replace(way);
32740       return graph;
32741     };
32742     action.makeConvex = function(graph) {
32743       var way = graph.entity(wayId);
32744       var nodes = utilArrayUniq(graph.childNodes(way));
32745       var points = nodes.map(function(n3) {
32746         return projection2(n3.loc);
32747       });
32748       var sign2 = area_default3(points) > 0 ? 1 : -1;
32749       var hull = hull_default(points);
32750       var i3, j2;
32751       if (sign2 === -1) {
32752         nodes.reverse();
32753         points.reverse();
32754       }
32755       for (i3 = 0; i3 < hull.length - 1; i3++) {
32756         var startIndex = points.indexOf(hull[i3]);
32757         var endIndex = points.indexOf(hull[i3 + 1]);
32758         var indexRange = endIndex - startIndex;
32759         if (indexRange < 0) {
32760           indexRange += nodes.length;
32761         }
32762         for (j2 = 1; j2 < indexRange; j2++) {
32763           var point2 = geoVecInterp(hull[i3], hull[i3 + 1], j2 / indexRange);
32764           var node = nodes[(j2 + startIndex) % nodes.length].move(projection2.invert(point2));
32765           graph = graph.replace(node);
32766         }
32767       }
32768       return graph;
32769     };
32770     action.disabled = function(graph) {
32771       if (!graph.entity(wayId).isClosed()) {
32772         return "not_closed";
32773       }
32774       var way = graph.entity(wayId);
32775       var nodes = utilArrayUniq(graph.childNodes(way));
32776       var points = nodes.map(function(n3) {
32777         return projection2(n3.loc);
32778       });
32779       var hull = hull_default(points);
32780       var epsilonAngle = Math.PI / 180;
32781       if (hull.length !== points.length || hull.length < 3) {
32782         return false;
32783       }
32784       var centroid = centroid_default2(points);
32785       var radius = geoVecLengthSquare(centroid, points[0]);
32786       var i3, actualPoint;
32787       for (i3 = 0; i3 < hull.length; i3++) {
32788         actualPoint = hull[i3];
32789         var actualDist = geoVecLengthSquare(actualPoint, centroid);
32790         var diff = Math.abs(actualDist - radius);
32791         if (diff > 0.05 * radius) {
32792           return false;
32793         }
32794       }
32795       for (i3 = 0; i3 < hull.length; i3++) {
32796         actualPoint = hull[i3];
32797         var nextPoint = hull[(i3 + 1) % hull.length];
32798         var startAngle = Math.atan2(actualPoint[1] - centroid[1], actualPoint[0] - centroid[0]);
32799         var endAngle = Math.atan2(nextPoint[1] - centroid[1], nextPoint[0] - centroid[0]);
32800         var angle2 = endAngle - startAngle;
32801         if (angle2 < 0) {
32802           angle2 = -angle2;
32803         }
32804         if (angle2 > Math.PI) {
32805           angle2 = 2 * Math.PI - angle2;
32806         }
32807         if (angle2 > maxAngle + epsilonAngle) {
32808           return false;
32809         }
32810       }
32811       return "already_circular";
32812     };
32813     action.transitionable = true;
32814     return action;
32815   }
32816
32817   // modules/actions/delete_way.js
32818   function actionDeleteWay(wayID) {
32819     function canDeleteNode(node, graph) {
32820       if (graph.parentWays(node).length || graph.parentRelations(node).length)
32821         return false;
32822       var geometries = osmNodeGeometriesForTags(node.tags);
32823       if (geometries.point)
32824         return false;
32825       if (geometries.vertex)
32826         return true;
32827       return !node.hasInterestingTags();
32828     }
32829     var action = function(graph) {
32830       var way = graph.entity(wayID);
32831       graph.parentRelations(way).forEach(function(parent) {
32832         parent = parent.removeMembersWithID(wayID);
32833         graph = graph.replace(parent);
32834         if (parent.isDegenerate()) {
32835           graph = actionDeleteRelation(parent.id)(graph);
32836         }
32837       });
32838       new Set(way.nodes).forEach(function(nodeID) {
32839         graph = graph.replace(way.removeNode(nodeID));
32840         var node = graph.entity(nodeID);
32841         if (canDeleteNode(node, graph)) {
32842           graph = graph.remove(node);
32843         }
32844       });
32845       return graph.remove(way);
32846     };
32847     return action;
32848   }
32849
32850   // modules/actions/delete_multiple.js
32851   function actionDeleteMultiple(ids) {
32852     var actions = {
32853       way: actionDeleteWay,
32854       node: actionDeleteNode,
32855       relation: actionDeleteRelation
32856     };
32857     var action = function(graph) {
32858       ids.forEach(function(id2) {
32859         if (graph.hasEntity(id2)) {
32860           graph = actions[graph.entity(id2).type](id2)(graph);
32861         }
32862       });
32863       return graph;
32864     };
32865     return action;
32866   }
32867
32868   // modules/actions/delete_relation.js
32869   function actionDeleteRelation(relationID, allowUntaggedMembers) {
32870     function canDeleteEntity(entity, graph) {
32871       return !graph.parentWays(entity).length && !graph.parentRelations(entity).length && (!entity.hasInterestingTags() && !allowUntaggedMembers);
32872     }
32873     var action = function(graph) {
32874       var relation = graph.entity(relationID);
32875       graph.parentRelations(relation).forEach(function(parent) {
32876         parent = parent.removeMembersWithID(relationID);
32877         graph = graph.replace(parent);
32878         if (parent.isDegenerate()) {
32879           graph = actionDeleteRelation(parent.id)(graph);
32880         }
32881       });
32882       var memberIDs = utilArrayUniq(relation.members.map(function(m2) {
32883         return m2.id;
32884       }));
32885       memberIDs.forEach(function(memberID) {
32886         graph = graph.replace(relation.removeMembersWithID(memberID));
32887         var entity = graph.entity(memberID);
32888         if (canDeleteEntity(entity, graph)) {
32889           graph = actionDeleteMultiple([memberID])(graph);
32890         }
32891       });
32892       return graph.remove(relation);
32893     };
32894     return action;
32895   }
32896
32897   // modules/actions/delete_node.js
32898   function actionDeleteNode(nodeId) {
32899     var action = function(graph) {
32900       var node = graph.entity(nodeId);
32901       graph.parentWays(node).forEach(function(parent) {
32902         parent = parent.removeNode(nodeId);
32903         graph = graph.replace(parent);
32904         if (parent.isDegenerate()) {
32905           graph = actionDeleteWay(parent.id)(graph);
32906         }
32907       });
32908       graph.parentRelations(node).forEach(function(parent) {
32909         parent = parent.removeMembersWithID(nodeId);
32910         graph = graph.replace(parent);
32911         if (parent.isDegenerate()) {
32912           graph = actionDeleteRelation(parent.id)(graph);
32913         }
32914       });
32915       return graph.remove(node);
32916     };
32917     return action;
32918   }
32919
32920   // modules/actions/connect.js
32921   function actionConnect(nodeIDs) {
32922     var action = function(graph) {
32923       var survivor;
32924       var node;
32925       var parents;
32926       var i3, j2;
32927       nodeIDs.reverse();
32928       var interestingIDs = [];
32929       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32930         node = graph.entity(nodeIDs[i3]);
32931         if (node.hasInterestingTags()) {
32932           if (!node.isNew()) {
32933             interestingIDs.push(node.id);
32934           }
32935         }
32936       }
32937       survivor = graph.entity(utilOldestID(interestingIDs.length > 0 ? interestingIDs : nodeIDs));
32938       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32939         node = graph.entity(nodeIDs[i3]);
32940         if (node.id === survivor.id)
32941           continue;
32942         parents = graph.parentWays(node);
32943         for (j2 = 0; j2 < parents.length; j2++) {
32944           graph = graph.replace(parents[j2].replaceNode(node.id, survivor.id));
32945         }
32946         parents = graph.parentRelations(node);
32947         for (j2 = 0; j2 < parents.length; j2++) {
32948           graph = graph.replace(parents[j2].replaceMember(node, survivor));
32949         }
32950         survivor = survivor.mergeTags(node.tags);
32951         graph = actionDeleteNode(node.id)(graph);
32952       }
32953       graph = graph.replace(survivor);
32954       parents = graph.parentWays(survivor);
32955       for (i3 = 0; i3 < parents.length; i3++) {
32956         if (parents[i3].isDegenerate()) {
32957           graph = actionDeleteWay(parents[i3].id)(graph);
32958         }
32959       }
32960       return graph;
32961     };
32962     action.disabled = function(graph) {
32963       var seen = {};
32964       var restrictionIDs = [];
32965       var survivor;
32966       var node, way;
32967       var relations, relation, role;
32968       var i3, j2, k2;
32969       survivor = graph.entity(utilOldestID(nodeIDs));
32970       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32971         node = graph.entity(nodeIDs[i3]);
32972         relations = graph.parentRelations(node);
32973         for (j2 = 0; j2 < relations.length; j2++) {
32974           relation = relations[j2];
32975           role = relation.memberById(node.id).role || "";
32976           if (relation.hasFromViaTo()) {
32977             restrictionIDs.push(relation.id);
32978           }
32979           if (seen[relation.id] !== void 0 && seen[relation.id] !== role) {
32980             return "relation";
32981           } else {
32982             seen[relation.id] = role;
32983           }
32984         }
32985       }
32986       for (i3 = 0; i3 < nodeIDs.length; i3++) {
32987         node = graph.entity(nodeIDs[i3]);
32988         var parents = graph.parentWays(node);
32989         for (j2 = 0; j2 < parents.length; j2++) {
32990           var parent = parents[j2];
32991           relations = graph.parentRelations(parent);
32992           for (k2 = 0; k2 < relations.length; k2++) {
32993             relation = relations[k2];
32994             if (relation.hasFromViaTo()) {
32995               restrictionIDs.push(relation.id);
32996             }
32997           }
32998         }
32999       }
33000       restrictionIDs = utilArrayUniq(restrictionIDs);
33001       for (i3 = 0; i3 < restrictionIDs.length; i3++) {
33002         relation = graph.entity(restrictionIDs[i3]);
33003         if (!relation.isComplete(graph))
33004           continue;
33005         var memberWays = relation.members.filter(function(m2) {
33006           return m2.type === "way";
33007         }).map(function(m2) {
33008           return graph.entity(m2.id);
33009         });
33010         memberWays = utilArrayUniq(memberWays);
33011         var f2 = relation.memberByRole("from");
33012         var t2 = relation.memberByRole("to");
33013         var isUturn = f2.id === t2.id;
33014         var nodes = { from: [], via: [], to: [], keyfrom: [], keyto: [] };
33015         for (j2 = 0; j2 < relation.members.length; j2++) {
33016           collectNodes(relation.members[j2], nodes);
33017         }
33018         nodes.keyfrom = utilArrayUniq(nodes.keyfrom.filter(hasDuplicates));
33019         nodes.keyto = utilArrayUniq(nodes.keyto.filter(hasDuplicates));
33020         var filter2 = keyNodeFilter(nodes.keyfrom, nodes.keyto);
33021         nodes.from = nodes.from.filter(filter2);
33022         nodes.via = nodes.via.filter(filter2);
33023         nodes.to = nodes.to.filter(filter2);
33024         var connectFrom = false;
33025         var connectVia = false;
33026         var connectTo = false;
33027         var connectKeyFrom = false;
33028         var connectKeyTo = false;
33029         for (j2 = 0; j2 < nodeIDs.length; j2++) {
33030           var n3 = nodeIDs[j2];
33031           if (nodes.from.indexOf(n3) !== -1) {
33032             connectFrom = true;
33033           }
33034           if (nodes.via.indexOf(n3) !== -1) {
33035             connectVia = true;
33036           }
33037           if (nodes.to.indexOf(n3) !== -1) {
33038             connectTo = true;
33039           }
33040           if (nodes.keyfrom.indexOf(n3) !== -1) {
33041             connectKeyFrom = true;
33042           }
33043           if (nodes.keyto.indexOf(n3) !== -1) {
33044             connectKeyTo = true;
33045           }
33046         }
33047         if (connectFrom && connectTo && !isUturn) {
33048           return "restriction";
33049         }
33050         if (connectFrom && connectVia) {
33051           return "restriction";
33052         }
33053         if (connectTo && connectVia) {
33054           return "restriction";
33055         }
33056         if (connectKeyFrom || connectKeyTo) {
33057           if (nodeIDs.length !== 2) {
33058             return "restriction";
33059           }
33060           var n0 = null;
33061           var n1 = null;
33062           for (j2 = 0; j2 < memberWays.length; j2++) {
33063             way = memberWays[j2];
33064             if (way.contains(nodeIDs[0])) {
33065               n0 = nodeIDs[0];
33066             }
33067             if (way.contains(nodeIDs[1])) {
33068               n1 = nodeIDs[1];
33069             }
33070           }
33071           if (n0 && n1) {
33072             var ok = false;
33073             for (j2 = 0; j2 < memberWays.length; j2++) {
33074               way = memberWays[j2];
33075               if (way.areAdjacent(n0, n1)) {
33076                 ok = true;
33077                 break;
33078               }
33079             }
33080             if (!ok) {
33081               return "restriction";
33082             }
33083           }
33084         }
33085         for (j2 = 0; j2 < memberWays.length; j2++) {
33086           way = memberWays[j2].update({});
33087           for (k2 = 0; k2 < nodeIDs.length; k2++) {
33088             if (nodeIDs[k2] === survivor.id)
33089               continue;
33090             if (way.areAdjacent(nodeIDs[k2], survivor.id)) {
33091               way = way.removeNode(nodeIDs[k2]);
33092             } else {
33093               way = way.replaceNode(nodeIDs[k2], survivor.id);
33094             }
33095           }
33096           if (way.isDegenerate()) {
33097             return "restriction";
33098           }
33099         }
33100       }
33101       return false;
33102       function hasDuplicates(n4, i4, arr) {
33103         return arr.indexOf(n4) !== arr.lastIndexOf(n4);
33104       }
33105       function keyNodeFilter(froms, tos) {
33106         return function(n4) {
33107           return froms.indexOf(n4) === -1 && tos.indexOf(n4) === -1;
33108         };
33109       }
33110       function collectNodes(member, collection) {
33111         var entity = graph.hasEntity(member.id);
33112         if (!entity)
33113           return;
33114         var role2 = member.role || "";
33115         if (!collection[role2]) {
33116           collection[role2] = [];
33117         }
33118         if (member.type === "node") {
33119           collection[role2].push(member.id);
33120           if (role2 === "via") {
33121             collection.keyfrom.push(member.id);
33122             collection.keyto.push(member.id);
33123           }
33124         } else if (member.type === "way") {
33125           collection[role2].push.apply(collection[role2], entity.nodes);
33126           if (role2 === "from" || role2 === "via") {
33127             collection.keyfrom.push(entity.first());
33128             collection.keyfrom.push(entity.last());
33129           }
33130           if (role2 === "to" || role2 === "via") {
33131             collection.keyto.push(entity.first());
33132             collection.keyto.push(entity.last());
33133           }
33134         }
33135       }
33136     };
33137     return action;
33138   }
33139
33140   // modules/actions/copy_entities.js
33141   function actionCopyEntities(ids, fromGraph) {
33142     var _copies = {};
33143     var action = function(graph) {
33144       ids.forEach(function(id3) {
33145         fromGraph.entity(id3).copy(fromGraph, _copies);
33146       });
33147       for (var id2 in _copies) {
33148         graph = graph.replace(_copies[id2]);
33149       }
33150       return graph;
33151     };
33152     action.copies = function() {
33153       return _copies;
33154     };
33155     return action;
33156   }
33157
33158   // modules/actions/delete_member.js
33159   function actionDeleteMember(relationId, memberIndex) {
33160     return function(graph) {
33161       var relation = graph.entity(relationId).removeMember(memberIndex);
33162       graph = graph.replace(relation);
33163       if (relation.isDegenerate()) {
33164         graph = actionDeleteRelation(relation.id)(graph);
33165       }
33166       return graph;
33167     };
33168   }
33169
33170   // modules/actions/discard_tags.js
33171   function actionDiscardTags(difference2, discardTags) {
33172     discardTags = discardTags || {};
33173     return (graph) => {
33174       difference2.modified().forEach(checkTags);
33175       difference2.created().forEach(checkTags);
33176       return graph;
33177       function checkTags(entity) {
33178         const keys2 = Object.keys(entity.tags);
33179         let didDiscard = false;
33180         let tags = {};
33181         for (let i3 = 0; i3 < keys2.length; i3++) {
33182           const k2 = keys2[i3];
33183           if (discardTags[k2] || !entity.tags[k2]) {
33184             didDiscard = true;
33185           } else {
33186             tags[k2] = entity.tags[k2];
33187           }
33188         }
33189         if (didDiscard) {
33190           graph = graph.replace(entity.update({ tags }));
33191         }
33192       }
33193     };
33194   }
33195
33196   // modules/actions/disconnect.js
33197   function actionDisconnect(nodeId, newNodeId) {
33198     var wayIds;
33199     var disconnectableRelationTypes = {
33200       "associatedStreet": true,
33201       "enforcement": true,
33202       "site": true
33203     };
33204     var action = function(graph) {
33205       var node = graph.entity(nodeId);
33206       var connections = action.connections(graph);
33207       connections.forEach(function(connection) {
33208         var way = graph.entity(connection.wayID);
33209         var newNode = osmNode({ id: newNodeId, loc: node.loc, tags: node.tags });
33210         graph = graph.replace(newNode);
33211         if (connection.index === 0 && way.isArea()) {
33212           graph = graph.replace(way.replaceNode(way.nodes[0], newNode.id));
33213         } else if (way.isClosed() && connection.index === way.nodes.length - 1) {
33214           graph = graph.replace(way.unclose().addNode(newNode.id));
33215         } else {
33216           graph = graph.replace(way.updateNode(newNode.id, connection.index));
33217         }
33218       });
33219       return graph;
33220     };
33221     action.connections = function(graph) {
33222       var candidates = [];
33223       var keeping = false;
33224       var parentWays = graph.parentWays(graph.entity(nodeId));
33225       var way, waynode;
33226       for (var i3 = 0; i3 < parentWays.length; i3++) {
33227         way = parentWays[i3];
33228         if (wayIds && wayIds.indexOf(way.id) === -1) {
33229           keeping = true;
33230           continue;
33231         }
33232         if (way.isArea() && way.nodes[0] === nodeId) {
33233           candidates.push({ wayID: way.id, index: 0 });
33234         } else {
33235           for (var j2 = 0; j2 < way.nodes.length; j2++) {
33236             waynode = way.nodes[j2];
33237             if (waynode === nodeId) {
33238               if (way.isClosed() && parentWays.length > 1 && wayIds && wayIds.indexOf(way.id) !== -1 && j2 === way.nodes.length - 1) {
33239                 continue;
33240               }
33241               candidates.push({ wayID: way.id, index: j2 });
33242             }
33243           }
33244         }
33245       }
33246       return keeping ? candidates : candidates.slice(1);
33247     };
33248     action.disabled = function(graph) {
33249       var connections = action.connections(graph);
33250       if (connections.length === 0)
33251         return "not_connected";
33252       var parentWays = graph.parentWays(graph.entity(nodeId));
33253       var seenRelationIds = {};
33254       var sharedRelation;
33255       parentWays.forEach(function(way) {
33256         var relations = graph.parentRelations(way);
33257         relations.filter((relation) => !disconnectableRelationTypes[relation.tags.type]).forEach(function(relation) {
33258           if (relation.id in seenRelationIds) {
33259             if (wayIds) {
33260               if (wayIds.indexOf(way.id) !== -1 || wayIds.indexOf(seenRelationIds[relation.id]) !== -1) {
33261                 sharedRelation = relation;
33262               }
33263             } else {
33264               sharedRelation = relation;
33265             }
33266           } else {
33267             seenRelationIds[relation.id] = way.id;
33268           }
33269         });
33270       });
33271       if (sharedRelation)
33272         return "relation";
33273     };
33274     action.limitWays = function(val) {
33275       if (!arguments.length)
33276         return wayIds;
33277       wayIds = val;
33278       return action;
33279     };
33280     return action;
33281   }
33282
33283   // modules/actions/extract.js
33284   function actionExtract(entityID, projection2) {
33285     var extractedNodeID;
33286     var action = function(graph) {
33287       var entity = graph.entity(entityID);
33288       if (entity.type === "node") {
33289         return extractFromNode(entity, graph);
33290       }
33291       return extractFromWayOrRelation(entity, graph);
33292     };
33293     function extractFromNode(node, graph) {
33294       extractedNodeID = node.id;
33295       var replacement = osmNode({ loc: node.loc });
33296       graph = graph.replace(replacement);
33297       graph = graph.parentWays(node).reduce(function(accGraph, parentWay) {
33298         return accGraph.replace(parentWay.replaceNode(entityID, replacement.id));
33299       }, graph);
33300       return graph.parentRelations(node).reduce(function(accGraph, parentRel) {
33301         return accGraph.replace(parentRel.replaceMember(node, replacement));
33302       }, graph);
33303     }
33304     function extractFromWayOrRelation(entity, graph) {
33305       var fromGeometry = entity.geometry(graph);
33306       var keysToCopyAndRetain = ["source", "wheelchair"];
33307       var keysToRetain = ["area"];
33308       var buildingKeysToRetain = ["architect", "building", "height", "layer", "nycdoitt:bin"];
33309       var extractedLoc = path_default(projection2).centroid(entity.asGeoJSON(graph));
33310       extractedLoc = extractedLoc && projection2.invert(extractedLoc);
33311       if (!extractedLoc || !isFinite(extractedLoc[0]) || !isFinite(extractedLoc[1])) {
33312         extractedLoc = entity.extent(graph).center();
33313       }
33314       var indoorAreaValues = {
33315         area: true,
33316         corridor: true,
33317         elevator: true,
33318         level: true,
33319         room: true
33320       };
33321       var isBuilding = entity.tags.building && entity.tags.building !== "no" || entity.tags["building:part"] && entity.tags["building:part"] !== "no";
33322       var isIndoorArea = fromGeometry === "area" && entity.tags.indoor && indoorAreaValues[entity.tags.indoor];
33323       var entityTags = Object.assign({}, entity.tags);
33324       var pointTags = {};
33325       for (var key in entityTags) {
33326         if (entity.type === "relation" && key === "type") {
33327           continue;
33328         }
33329         if (keysToRetain.indexOf(key) !== -1) {
33330           continue;
33331         }
33332         if (isBuilding) {
33333           if (buildingKeysToRetain.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/))
33334             continue;
33335         }
33336         if (isIndoorArea && key === "indoor") {
33337           continue;
33338         }
33339         pointTags[key] = entityTags[key];
33340         if (keysToCopyAndRetain.indexOf(key) !== -1 || key.match(/^addr:.{1,}/)) {
33341           continue;
33342         } else if (isIndoorArea && key === "level") {
33343           continue;
33344         }
33345         delete entityTags[key];
33346       }
33347       if (!isBuilding && !isIndoorArea && fromGeometry === "area") {
33348         entityTags.area = "yes";
33349       }
33350       var replacement = osmNode({ loc: extractedLoc, tags: pointTags });
33351       graph = graph.replace(replacement);
33352       extractedNodeID = replacement.id;
33353       return graph.replace(entity.update({ tags: entityTags }));
33354     }
33355     action.getExtractedNodeID = function() {
33356       return extractedNodeID;
33357     };
33358     return action;
33359   }
33360
33361   // modules/actions/join.js
33362   function actionJoin(ids) {
33363     function groupEntitiesByGeometry(graph) {
33364       var entities = ids.map(function(id2) {
33365         return graph.entity(id2);
33366       });
33367       return Object.assign(
33368         { line: [] },
33369         utilArrayGroupBy(entities, function(entity) {
33370           return entity.geometry(graph);
33371         })
33372       );
33373     }
33374     var action = function(graph) {
33375       var ways = ids.map(graph.entity, graph);
33376       var survivorID = utilOldestID(ways.map((way) => way.id));
33377       ways.sort(function(a2, b2) {
33378         var aSided = a2.isSided();
33379         var bSided = b2.isSided();
33380         return aSided && !bSided ? -1 : bSided && !aSided ? 1 : 0;
33381       });
33382       var sequences = osmJoinWays(ways, graph);
33383       var joined = sequences[0];
33384       graph = sequences.actions.reduce(function(g3, action2) {
33385         return action2(g3);
33386       }, graph);
33387       var survivor = graph.entity(survivorID);
33388       survivor = survivor.update({ nodes: joined.nodes.map(function(n3) {
33389         return n3.id;
33390       }) });
33391       graph = graph.replace(survivor);
33392       joined.forEach(function(way) {
33393         if (way.id === survivorID)
33394           return;
33395         graph.parentRelations(way).forEach(function(parent) {
33396           graph = graph.replace(parent.replaceMember(way, survivor));
33397         });
33398         survivor = survivor.mergeTags(way.tags);
33399         graph = graph.replace(survivor);
33400         graph = actionDeleteWay(way.id)(graph);
33401       });
33402       function checkForSimpleMultipolygon() {
33403         if (!survivor.isClosed())
33404           return;
33405         var multipolygons = graph.parentMultipolygons(survivor).filter(function(multipolygon2) {
33406           return multipolygon2.members.length === 1;
33407         });
33408         if (multipolygons.length !== 1)
33409           return;
33410         var multipolygon = multipolygons[0];
33411         for (var key in survivor.tags) {
33412           if (multipolygon.tags[key] && // don't collapse if tags cannot be cleanly merged
33413           multipolygon.tags[key] !== survivor.tags[key])
33414             return;
33415         }
33416         survivor = survivor.mergeTags(multipolygon.tags);
33417         graph = graph.replace(survivor);
33418         graph = actionDeleteRelation(
33419           multipolygon.id,
33420           true
33421           /* allow untagged members */
33422         )(graph);
33423         var tags = Object.assign({}, survivor.tags);
33424         if (survivor.geometry(graph) !== "area") {
33425           tags.area = "yes";
33426         }
33427         delete tags.type;
33428         survivor = survivor.update({ tags });
33429         graph = graph.replace(survivor);
33430       }
33431       checkForSimpleMultipolygon();
33432       return graph;
33433     };
33434     action.resultingWayNodesLength = function(graph) {
33435       return ids.reduce(function(count, id2) {
33436         return count + graph.entity(id2).nodes.length;
33437       }, 0) - ids.length - 1;
33438     };
33439     action.disabled = function(graph) {
33440       var geometries = groupEntitiesByGeometry(graph);
33441       if (ids.length < 2 || ids.length !== geometries.line.length) {
33442         return "not_eligible";
33443       }
33444       var joined = osmJoinWays(ids.map(graph.entity, graph), graph);
33445       if (joined.length > 1) {
33446         return "not_adjacent";
33447       }
33448       var i3;
33449       var sortedParentRelations = function(id2) {
33450         return graph.parentRelations(graph.entity(id2)).filter((rel) => !rel.isRestriction() && !rel.isConnectivity()).sort((a2, b2) => a2.id - b2.id);
33451       };
33452       var relsA = sortedParentRelations(ids[0]);
33453       for (i3 = 1; i3 < ids.length; i3++) {
33454         var relsB = sortedParentRelations(ids[i3]);
33455         if (!utilArrayIdentical(relsA, relsB)) {
33456           return "conflicting_relations";
33457         }
33458       }
33459       for (i3 = 0; i3 < ids.length - 1; i3++) {
33460         for (var j2 = i3 + 1; j2 < ids.length; j2++) {
33461           var path1 = graph.childNodes(graph.entity(ids[i3])).map(function(e3) {
33462             return e3.loc;
33463           });
33464           var path2 = graph.childNodes(graph.entity(ids[j2])).map(function(e3) {
33465             return e3.loc;
33466           });
33467           var intersections = geoPathIntersections(path1, path2);
33468           var common = utilArrayIntersection(
33469             joined[0].nodes.map(function(n3) {
33470               return n3.loc.toString();
33471             }),
33472             intersections.map(function(n3) {
33473               return n3.toString();
33474             })
33475           );
33476           if (common.length !== intersections.length) {
33477             return "paths_intersect";
33478           }
33479         }
33480       }
33481       var nodeIds = joined[0].nodes.map(function(n3) {
33482         return n3.id;
33483       }).slice(1, -1);
33484       var relation;
33485       var tags = {};
33486       var conflicting = false;
33487       joined[0].forEach(function(way) {
33488         var parents = graph.parentRelations(way);
33489         parents.forEach(function(parent) {
33490           if ((parent.isRestriction() || parent.isConnectivity()) && parent.members.some(function(m2) {
33491             return nodeIds.indexOf(m2.id) >= 0;
33492           })) {
33493             relation = parent;
33494           }
33495         });
33496         for (var k2 in way.tags) {
33497           if (!(k2 in tags)) {
33498             tags[k2] = way.tags[k2];
33499           } else if (tags[k2] && osmIsInterestingTag(k2) && tags[k2] !== way.tags[k2]) {
33500             conflicting = true;
33501           }
33502         }
33503       });
33504       if (relation) {
33505         return relation.isRestriction() ? "restriction" : "connectivity";
33506       }
33507       if (conflicting) {
33508         return "conflicting_tags";
33509       }
33510     };
33511     return action;
33512   }
33513
33514   // modules/actions/merge.js
33515   function actionMerge(ids) {
33516     function groupEntitiesByGeometry(graph) {
33517       var entities = ids.map(function(id2) {
33518         return graph.entity(id2);
33519       });
33520       return Object.assign(
33521         { point: [], area: [], line: [], relation: [] },
33522         utilArrayGroupBy(entities, function(entity) {
33523           return entity.geometry(graph);
33524         })
33525       );
33526     }
33527     var action = function(graph) {
33528       var geometries = groupEntitiesByGeometry(graph);
33529       var target = geometries.area[0] || geometries.line[0];
33530       var points = geometries.point;
33531       points.forEach(function(point2) {
33532         target = target.mergeTags(point2.tags);
33533         graph = graph.replace(target);
33534         graph.parentRelations(point2).forEach(function(parent) {
33535           graph = graph.replace(parent.replaceMember(point2, target));
33536         });
33537         var nodes = utilArrayUniq(graph.childNodes(target));
33538         var removeNode = point2;
33539         if (!point2.isNew()) {
33540           var inserted = false;
33541           var canBeReplaced = function(node2) {
33542             return !(graph.parentWays(node2).length > 1 || graph.parentRelations(node2).length);
33543           };
33544           var replaceNode = function(node2) {
33545             graph = graph.replace(point2.update({ tags: node2.tags, loc: node2.loc }));
33546             target = target.replaceNode(node2.id, point2.id);
33547             graph = graph.replace(target);
33548             removeNode = node2;
33549             inserted = true;
33550           };
33551           var i3;
33552           var node;
33553           for (i3 = 0; i3 < nodes.length; i3++) {
33554             node = nodes[i3];
33555             if (canBeReplaced(node) && node.isNew()) {
33556               replaceNode(node);
33557               break;
33558             }
33559           }
33560           if (!inserted && point2.hasInterestingTags()) {
33561             for (i3 = 0; i3 < nodes.length; i3++) {
33562               node = nodes[i3];
33563               if (canBeReplaced(node) && !node.hasInterestingTags()) {
33564                 replaceNode(node);
33565                 break;
33566               }
33567             }
33568             if (!inserted) {
33569               for (i3 = 0; i3 < nodes.length; i3++) {
33570                 node = nodes[i3];
33571                 if (canBeReplaced(node) && utilCompareIDs(point2.id, node.id) < 0) {
33572                   replaceNode(node);
33573                   break;
33574                 }
33575               }
33576             }
33577           }
33578         }
33579         graph = graph.remove(removeNode);
33580       });
33581       if (target.tags.area === "yes") {
33582         var tags = Object.assign({}, target.tags);
33583         delete tags.area;
33584         if (osmTagSuggestingArea(tags)) {
33585           target = target.update({ tags });
33586           graph = graph.replace(target);
33587         }
33588       }
33589       return graph;
33590     };
33591     action.disabled = function(graph) {
33592       var geometries = groupEntitiesByGeometry(graph);
33593       if (geometries.point.length === 0 || geometries.area.length + geometries.line.length !== 1 || geometries.relation.length !== 0) {
33594         return "not_eligible";
33595       }
33596     };
33597     return action;
33598   }
33599
33600   // modules/actions/merge_nodes.js
33601   function actionMergeNodes(nodeIDs, loc) {
33602     function chooseLoc(graph) {
33603       if (!nodeIDs.length)
33604         return null;
33605       var sum = [0, 0];
33606       var interestingCount = 0;
33607       var interestingLoc;
33608       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
33609         var node = graph.entity(nodeIDs[i3]);
33610         if (node.hasInterestingTags()) {
33611           interestingLoc = ++interestingCount === 1 ? node.loc : null;
33612         }
33613         sum = geoVecAdd(sum, node.loc);
33614       }
33615       return interestingLoc || geoVecScale(sum, 1 / nodeIDs.length);
33616     }
33617     var action = function(graph) {
33618       if (nodeIDs.length < 2)
33619         return graph;
33620       var toLoc = loc;
33621       if (!toLoc) {
33622         toLoc = chooseLoc(graph);
33623       }
33624       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
33625         var node = graph.entity(nodeIDs[i3]);
33626         if (node.loc !== toLoc) {
33627           graph = graph.replace(node.move(toLoc));
33628         }
33629       }
33630       return actionConnect(nodeIDs)(graph);
33631     };
33632     action.disabled = function(graph) {
33633       if (nodeIDs.length < 2)
33634         return "not_eligible";
33635       for (var i3 = 0; i3 < nodeIDs.length; i3++) {
33636         var entity = graph.entity(nodeIDs[i3]);
33637         if (entity.type !== "node")
33638           return "not_eligible";
33639       }
33640       return actionConnect(nodeIDs).disabled(graph);
33641     };
33642     return action;
33643   }
33644
33645   // modules/osm/changeset.js
33646   function osmChangeset() {
33647     if (!(this instanceof osmChangeset)) {
33648       return new osmChangeset().initialize(arguments);
33649     } else if (arguments.length) {
33650       this.initialize(arguments);
33651     }
33652   }
33653   osmEntity.changeset = osmChangeset;
33654   osmChangeset.prototype = Object.create(osmEntity.prototype);
33655   Object.assign(osmChangeset.prototype, {
33656     type: "changeset",
33657     extent: function() {
33658       return new geoExtent();
33659     },
33660     geometry: function() {
33661       return "changeset";
33662     },
33663     asJXON: function() {
33664       return {
33665         osm: {
33666           changeset: {
33667             tag: Object.keys(this.tags).map(function(k2) {
33668               return { "@k": k2, "@v": this.tags[k2] };
33669             }, this),
33670             "@version": 0.6,
33671             "@generator": "iD"
33672           }
33673         }
33674       };
33675     },
33676     // Generate [osmChange](http://wiki.openstreetmap.org/wiki/OsmChange)
33677     // XML. Returns a string.
33678     osmChangeJXON: function(changes) {
33679       var changeset_id = this.id;
33680       function nest(x2, order) {
33681         var groups = {};
33682         for (var i3 = 0; i3 < x2.length; i3++) {
33683           var tagName = Object.keys(x2[i3])[0];
33684           if (!groups[tagName])
33685             groups[tagName] = [];
33686           groups[tagName].push(x2[i3][tagName]);
33687         }
33688         var ordered = {};
33689         order.forEach(function(o2) {
33690           if (groups[o2])
33691             ordered[o2] = groups[o2];
33692         });
33693         return ordered;
33694       }
33695       function sort(changes2) {
33696         function resolve(item) {
33697           return relations.find(function(relation2) {
33698             return item.keyAttributes.type === "relation" && item.keyAttributes.ref === relation2["@id"];
33699           });
33700         }
33701         function isNew(item) {
33702           return !sorted[item["@id"]] && !processing.find(function(proc) {
33703             return proc["@id"] === item["@id"];
33704           });
33705         }
33706         var processing = [];
33707         var sorted = {};
33708         var relations = changes2.relation;
33709         if (!relations)
33710           return changes2;
33711         for (var i3 = 0; i3 < relations.length; i3++) {
33712           var relation = relations[i3];
33713           if (!sorted[relation["@id"]]) {
33714             processing.push(relation);
33715           }
33716           while (processing.length > 0) {
33717             var next = processing[0], deps = next.member.map(resolve).filter(Boolean).filter(isNew);
33718             if (deps.length === 0) {
33719               sorted[next["@id"]] = next;
33720               processing.shift();
33721             } else {
33722               processing = deps.concat(processing);
33723             }
33724           }
33725         }
33726         changes2.relation = Object.values(sorted);
33727         return changes2;
33728       }
33729       function rep(entity) {
33730         return entity.asJXON(changeset_id);
33731       }
33732       return {
33733         osmChange: {
33734           "@version": 0.6,
33735           "@generator": "iD",
33736           "create": sort(nest(changes.created.map(rep), ["node", "way", "relation"])),
33737           "modify": nest(changes.modified.map(rep), ["node", "way", "relation"]),
33738           "delete": Object.assign(nest(changes.deleted.map(rep), ["relation", "way", "node"]), { "@if-unused": true })
33739         }
33740       };
33741     },
33742     asGeoJSON: function() {
33743       return {};
33744     }
33745   });
33746
33747   // modules/osm/note.js
33748   function osmNote() {
33749     if (!(this instanceof osmNote)) {
33750       return new osmNote().initialize(arguments);
33751     } else if (arguments.length) {
33752       this.initialize(arguments);
33753     }
33754   }
33755   osmNote.id = function() {
33756     return osmNote.id.next--;
33757   };
33758   osmNote.id.next = -1;
33759   Object.assign(osmNote.prototype, {
33760     type: "note",
33761     initialize: function(sources) {
33762       for (var i3 = 0; i3 < sources.length; ++i3) {
33763         var source = sources[i3];
33764         for (var prop in source) {
33765           if (Object.prototype.hasOwnProperty.call(source, prop)) {
33766             if (source[prop] === void 0) {
33767               delete this[prop];
33768             } else {
33769               this[prop] = source[prop];
33770             }
33771           }
33772         }
33773       }
33774       if (!this.id) {
33775         this.id = osmNote.id().toString();
33776       }
33777       return this;
33778     },
33779     extent: function() {
33780       return new geoExtent(this.loc);
33781     },
33782     update: function(attrs) {
33783       return osmNote(this, attrs);
33784     },
33785     isNew: function() {
33786       return this.id < 0;
33787     },
33788     move: function(loc) {
33789       return this.update({ loc });
33790     }
33791   });
33792
33793   // modules/osm/relation.js
33794   function osmRelation() {
33795     if (!(this instanceof osmRelation)) {
33796       return new osmRelation().initialize(arguments);
33797     } else if (arguments.length) {
33798       this.initialize(arguments);
33799     }
33800   }
33801   osmEntity.relation = osmRelation;
33802   osmRelation.prototype = Object.create(osmEntity.prototype);
33803   osmRelation.creationOrder = function(a2, b2) {
33804     var aId = parseInt(osmEntity.id.toOSM(a2.id), 10);
33805     var bId = parseInt(osmEntity.id.toOSM(b2.id), 10);
33806     if (aId < 0 || bId < 0)
33807       return aId - bId;
33808     return bId - aId;
33809   };
33810   Object.assign(osmRelation.prototype, {
33811     type: "relation",
33812     members: [],
33813     copy: function(resolver, copies) {
33814       if (copies[this.id])
33815         return copies[this.id];
33816       var copy2 = osmEntity.prototype.copy.call(this, resolver, copies);
33817       var members = this.members.map(function(member) {
33818         return Object.assign({}, member, { id: resolver.entity(member.id).copy(resolver, copies).id });
33819       });
33820       copy2 = copy2.update({ members });
33821       copies[this.id] = copy2;
33822       return copy2;
33823     },
33824     extent: function(resolver, memo) {
33825       return resolver.transient(this, "extent", function() {
33826         if (memo && memo[this.id])
33827           return geoExtent();
33828         memo = memo || {};
33829         memo[this.id] = true;
33830         var extent = geoExtent();
33831         for (var i3 = 0; i3 < this.members.length; i3++) {
33832           var member = resolver.hasEntity(this.members[i3].id);
33833           if (member) {
33834             extent._extend(member.extent(resolver, memo));
33835           }
33836         }
33837         return extent;
33838       });
33839     },
33840     geometry: function(graph) {
33841       return graph.transient(this, "geometry", function() {
33842         return this.isMultipolygon() ? "area" : "relation";
33843       });
33844     },
33845     isDegenerate: function() {
33846       return this.members.length === 0;
33847     },
33848     // Return an array of members, each extended with an 'index' property whose value
33849     // is the member index.
33850     indexedMembers: function() {
33851       var result = new Array(this.members.length);
33852       for (var i3 = 0; i3 < this.members.length; i3++) {
33853         result[i3] = Object.assign({}, this.members[i3], { index: i3 });
33854       }
33855       return result;
33856     },
33857     // Return the first member with the given role. A copy of the member object
33858     // is returned, extended with an 'index' property whose value is the member index.
33859     memberByRole: function(role) {
33860       for (var i3 = 0; i3 < this.members.length; i3++) {
33861         if (this.members[i3].role === role) {
33862           return Object.assign({}, this.members[i3], { index: i3 });
33863         }
33864       }
33865     },
33866     // Same as memberByRole, but returns all members with the given role
33867     membersByRole: function(role) {
33868       var result = [];
33869       for (var i3 = 0; i3 < this.members.length; i3++) {
33870         if (this.members[i3].role === role) {
33871           result.push(Object.assign({}, this.members[i3], { index: i3 }));
33872         }
33873       }
33874       return result;
33875     },
33876     // Return the first member with the given id. A copy of the member object
33877     // is returned, extended with an 'index' property whose value is the member index.
33878     memberById: function(id2) {
33879       for (var i3 = 0; i3 < this.members.length; i3++) {
33880         if (this.members[i3].id === id2) {
33881           return Object.assign({}, this.members[i3], { index: i3 });
33882         }
33883       }
33884     },
33885     // Return the first member with the given id and role. A copy of the member object
33886     // is returned, extended with an 'index' property whose value is the member index.
33887     memberByIdAndRole: function(id2, role) {
33888       for (var i3 = 0; i3 < this.members.length; i3++) {
33889         if (this.members[i3].id === id2 && this.members[i3].role === role) {
33890           return Object.assign({}, this.members[i3], { index: i3 });
33891         }
33892       }
33893     },
33894     addMember: function(member, index) {
33895       var members = this.members.slice();
33896       members.splice(index === void 0 ? members.length : index, 0, member);
33897       return this.update({ members });
33898     },
33899     updateMember: function(member, index) {
33900       var members = this.members.slice();
33901       members.splice(index, 1, Object.assign({}, members[index], member));
33902       return this.update({ members });
33903     },
33904     removeMember: function(index) {
33905       var members = this.members.slice();
33906       members.splice(index, 1);
33907       return this.update({ members });
33908     },
33909     removeMembersWithID: function(id2) {
33910       var members = this.members.filter(function(m2) {
33911         return m2.id !== id2;
33912       });
33913       return this.update({ members });
33914     },
33915     moveMember: function(fromIndex, toIndex) {
33916       var members = this.members.slice();
33917       members.splice(toIndex, 0, members.splice(fromIndex, 1)[0]);
33918       return this.update({ members });
33919     },
33920     // Wherever a member appears with id `needle.id`, replace it with a member
33921     // with id `replacement.id`, type `replacement.type`, and the original role,
33922     // By default, adding a duplicate member (by id and role) is prevented.
33923     // Return an updated relation.
33924     replaceMember: function(needle, replacement, keepDuplicates) {
33925       if (!this.memberById(needle.id))
33926         return this;
33927       var members = [];
33928       for (var i3 = 0; i3 < this.members.length; i3++) {
33929         var member = this.members[i3];
33930         if (member.id !== needle.id) {
33931           members.push(member);
33932         } else if (keepDuplicates || !this.memberByIdAndRole(replacement.id, member.role)) {
33933           members.push({ id: replacement.id, type: replacement.type, role: member.role });
33934         }
33935       }
33936       return this.update({ members });
33937     },
33938     asJXON: function(changeset_id) {
33939       var r2 = {
33940         relation: {
33941           "@id": this.osmId(),
33942           "@version": this.version || 0,
33943           member: this.members.map(function(member) {
33944             return {
33945               keyAttributes: {
33946                 type: member.type,
33947                 role: member.role,
33948                 ref: osmEntity.id.toOSM(member.id)
33949               }
33950             };
33951           }, this),
33952           tag: Object.keys(this.tags).map(function(k2) {
33953             return { keyAttributes: { k: k2, v: this.tags[k2] } };
33954           }, this)
33955         }
33956       };
33957       if (changeset_id) {
33958         r2.relation["@changeset"] = changeset_id;
33959       }
33960       return r2;
33961     },
33962     asGeoJSON: function(resolver) {
33963       return resolver.transient(this, "GeoJSON", function() {
33964         if (this.isMultipolygon()) {
33965           return {
33966             type: "MultiPolygon",
33967             coordinates: this.multipolygon(resolver)
33968           };
33969         } else {
33970           return {
33971             type: "FeatureCollection",
33972             properties: this.tags,
33973             features: this.members.map(function(member) {
33974               return Object.assign({ role: member.role }, resolver.entity(member.id).asGeoJSON(resolver));
33975             })
33976           };
33977         }
33978       });
33979     },
33980     area: function(resolver) {
33981       return resolver.transient(this, "area", function() {
33982         return area_default(this.asGeoJSON(resolver));
33983       });
33984     },
33985     isMultipolygon: function() {
33986       return this.tags.type === "multipolygon";
33987     },
33988     isComplete: function(resolver) {
33989       for (var i3 = 0; i3 < this.members.length; i3++) {
33990         if (!resolver.hasEntity(this.members[i3].id)) {
33991           return false;
33992         }
33993       }
33994       return true;
33995     },
33996     hasFromViaTo: function() {
33997       return this.members.some(function(m2) {
33998         return m2.role === "from";
33999       }) && this.members.some(function(m2) {
34000         return m2.role === "via";
34001       }) && this.members.some(function(m2) {
34002         return m2.role === "to";
34003       });
34004     },
34005     isRestriction: function() {
34006       return !!(this.tags.type && this.tags.type.match(/^restriction:?/));
34007     },
34008     isValidRestriction: function() {
34009       if (!this.isRestriction())
34010         return false;
34011       var froms = this.members.filter(function(m2) {
34012         return m2.role === "from";
34013       });
34014       var vias = this.members.filter(function(m2) {
34015         return m2.role === "via";
34016       });
34017       var tos = this.members.filter(function(m2) {
34018         return m2.role === "to";
34019       });
34020       if (froms.length !== 1 && this.tags.restriction !== "no_entry")
34021         return false;
34022       if (froms.some(function(m2) {
34023         return m2.type !== "way";
34024       }))
34025         return false;
34026       if (tos.length !== 1 && this.tags.restriction !== "no_exit")
34027         return false;
34028       if (tos.some(function(m2) {
34029         return m2.type !== "way";
34030       }))
34031         return false;
34032       if (vias.length === 0)
34033         return false;
34034       if (vias.length > 1 && vias.some(function(m2) {
34035         return m2.type !== "way";
34036       }))
34037         return false;
34038       return true;
34039     },
34040     isConnectivity: function() {
34041       return !!(this.tags.type && this.tags.type.match(/^connectivity:?/));
34042     },
34043     // Returns an array [A0, ... An], each Ai being an array of node arrays [Nds0, ... Ndsm],
34044     // where Nds0 is an outer ring and subsequent Ndsi's (if any i > 0) being inner rings.
34045     //
34046     // This corresponds to the structure needed for rendering a multipolygon path using a
34047     // `evenodd` fill rule, as well as the structure of a GeoJSON MultiPolygon geometry.
34048     //
34049     // In the case of invalid geometries, this function will still return a result which
34050     // includes the nodes of all way members, but some Nds may be unclosed and some inner
34051     // rings not matched with the intended outer ring.
34052     //
34053     multipolygon: function(resolver) {
34054       var outers = this.members.filter(function(m2) {
34055         return "outer" === (m2.role || "outer");
34056       });
34057       var inners = this.members.filter(function(m2) {
34058         return "inner" === m2.role;
34059       });
34060       outers = osmJoinWays(outers, resolver);
34061       inners = osmJoinWays(inners, resolver);
34062       var sequenceToLineString = function(sequence) {
34063         if (sequence.nodes.length > 2 && sequence.nodes[0] !== sequence.nodes[sequence.nodes.length - 1]) {
34064           sequence.nodes.push(sequence.nodes[0]);
34065         }
34066         return sequence.nodes.map(function(node) {
34067           return node.loc;
34068         });
34069       };
34070       outers = outers.map(sequenceToLineString);
34071       inners = inners.map(sequenceToLineString);
34072       var result = outers.map(function(o3) {
34073         return [area_default({ type: "Polygon", coordinates: [o3] }) > 2 * Math.PI ? o3.reverse() : o3];
34074       });
34075       function findOuter(inner2) {
34076         var o3, outer;
34077         for (o3 = 0; o3 < outers.length; o3++) {
34078           outer = outers[o3];
34079           if (geoPolygonContainsPolygon(outer, inner2)) {
34080             return o3;
34081           }
34082         }
34083         for (o3 = 0; o3 < outers.length; o3++) {
34084           outer = outers[o3];
34085           if (geoPolygonIntersectsPolygon(outer, inner2, false)) {
34086             return o3;
34087           }
34088         }
34089       }
34090       for (var i3 = 0; i3 < inners.length; i3++) {
34091         var inner = inners[i3];
34092         if (area_default({ type: "Polygon", coordinates: [inner] }) < 2 * Math.PI) {
34093           inner = inner.reverse();
34094         }
34095         var o2 = findOuter(inners[i3]);
34096         if (o2 !== void 0) {
34097           result[o2].push(inners[i3]);
34098         } else {
34099           result.push([inners[i3]]);
34100         }
34101       }
34102       return result;
34103     }
34104   });
34105
34106   // modules/osm/qa_item.js
34107   var QAItem = class _QAItem {
34108     constructor(loc, service, itemType, id2, props) {
34109       this.loc = loc;
34110       this.service = service.title;
34111       this.itemType = itemType;
34112       this.id = id2 ? id2 : "".concat(_QAItem.id());
34113       this.update(props);
34114       if (service && typeof service.getIcon === "function") {
34115         this.icon = service.getIcon(itemType);
34116       }
34117     }
34118     update(props) {
34119       const { loc, service, itemType, id: id2 } = this;
34120       Object.keys(props).forEach((prop) => this[prop] = props[prop]);
34121       this.loc = loc;
34122       this.service = service;
34123       this.itemType = itemType;
34124       this.id = id2;
34125       return this;
34126     }
34127     // Generic handling for newly created QAItems
34128     static id() {
34129       return this.nextId--;
34130     }
34131   };
34132   QAItem.nextId = -1;
34133
34134   // modules/actions/split.js
34135   function actionSplit(nodeIds, newWayIds) {
34136     if (typeof nodeIds === "string")
34137       nodeIds = [nodeIds];
34138     var _wayIDs;
34139     var _keepHistoryOn = "longest";
34140     var _createdWayIDs = [];
34141     function dist(graph, nA, nB) {
34142       var locA = graph.entity(nA).loc;
34143       var locB = graph.entity(nB).loc;
34144       var epsilon3 = 1e-6;
34145       return locA && locB ? geoSphericalDistance(locA, locB) : epsilon3;
34146     }
34147     function splitArea(nodes, idxA, graph) {
34148       var lengths = new Array(nodes.length);
34149       var length2;
34150       var i3;
34151       var best = 0;
34152       var idxB;
34153       function wrap2(index) {
34154         return utilWrap(index, nodes.length);
34155       }
34156       length2 = 0;
34157       for (i3 = wrap2(idxA + 1); i3 !== idxA; i3 = wrap2(i3 + 1)) {
34158         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 - 1)]);
34159         lengths[i3] = length2;
34160       }
34161       length2 = 0;
34162       for (i3 = wrap2(idxA - 1); i3 !== idxA; i3 = wrap2(i3 - 1)) {
34163         length2 += dist(graph, nodes[i3], nodes[wrap2(i3 + 1)]);
34164         if (length2 < lengths[i3]) {
34165           lengths[i3] = length2;
34166         }
34167       }
34168       for (i3 = 0; i3 < nodes.length; i3++) {
34169         var cost = lengths[i3] / dist(graph, nodes[idxA], nodes[i3]);
34170         if (cost > best) {
34171           idxB = i3;
34172           best = cost;
34173         }
34174       }
34175       return idxB;
34176     }
34177     function totalLengthBetweenNodes(graph, nodes) {
34178       var totalLength = 0;
34179       for (var i3 = 0; i3 < nodes.length - 1; i3++) {
34180         totalLength += dist(graph, nodes[i3], nodes[i3 + 1]);
34181       }
34182       return totalLength;
34183     }
34184     function split(graph, nodeId, wayA, newWayId) {
34185       var wayB = osmWay({ id: newWayId, tags: wayA.tags });
34186       var origNodes = wayA.nodes.slice();
34187       var nodesA;
34188       var nodesB;
34189       var isArea = wayA.isArea();
34190       var isOuter = osmIsOldMultipolygonOuterMember(wayA, graph);
34191       if (wayA.isClosed()) {
34192         var nodes = wayA.nodes.slice(0, -1);
34193         var idxA = nodes.indexOf(nodeId);
34194         var idxB = splitArea(nodes, idxA, graph);
34195         if (idxB < idxA) {
34196           nodesA = nodes.slice(idxA).concat(nodes.slice(0, idxB + 1));
34197           nodesB = nodes.slice(idxB, idxA + 1);
34198         } else {
34199           nodesA = nodes.slice(idxA, idxB + 1);
34200           nodesB = nodes.slice(idxB).concat(nodes.slice(0, idxA + 1));
34201         }
34202       } else {
34203         var idx = wayA.nodes.indexOf(nodeId, 1);
34204         nodesA = wayA.nodes.slice(0, idx + 1);
34205         nodesB = wayA.nodes.slice(idx);
34206       }
34207       var lengthA = totalLengthBetweenNodes(graph, nodesA);
34208       var lengthB = totalLengthBetweenNodes(graph, nodesB);
34209       if (_keepHistoryOn === "longest" && lengthB > lengthA) {
34210         wayA = wayA.update({ nodes: nodesB });
34211         wayB = wayB.update({ nodes: nodesA });
34212         var temp = lengthA;
34213         lengthA = lengthB;
34214         lengthB = temp;
34215       } else {
34216         wayA = wayA.update({ nodes: nodesA });
34217         wayB = wayB.update({ nodes: nodesB });
34218       }
34219       if (wayA.tags.step_count) {
34220         var stepCount = Number(wayA.tags.step_count);
34221         if (stepCount && // ensure a number
34222         isFinite(stepCount) && // ensure positive
34223         stepCount > 0 && // ensure integer
34224         Math.round(stepCount) === stepCount) {
34225           var tagsA = Object.assign({}, wayA.tags);
34226           var tagsB = Object.assign({}, wayB.tags);
34227           var ratioA = lengthA / (lengthA + lengthB);
34228           var countA = Math.round(stepCount * ratioA);
34229           tagsA.step_count = countA.toString();
34230           tagsB.step_count = (stepCount - countA).toString();
34231           wayA = wayA.update({ tags: tagsA });
34232           wayB = wayB.update({ tags: tagsB });
34233         }
34234       }
34235       graph = graph.replace(wayA);
34236       graph = graph.replace(wayB);
34237       graph.parentRelations(wayA).forEach(function(relation) {
34238         var member;
34239         if (relation.hasFromViaTo()) {
34240           var f2 = relation.memberByRole("from");
34241           var v2 = relation.membersByRole("via");
34242           var t2 = relation.memberByRole("to");
34243           var i3;
34244           if (f2.id === wayA.id || t2.id === wayA.id) {
34245             var keepB = false;
34246             if (v2.length === 1 && v2[0].type === "node") {
34247               keepB = wayB.contains(v2[0].id);
34248             } else {
34249               for (i3 = 0; i3 < v2.length; i3++) {
34250                 if (v2[i3].type === "way") {
34251                   var wayVia = graph.hasEntity(v2[i3].id);
34252                   if (wayVia && utilArrayIntersection(wayB.nodes, wayVia.nodes).length) {
34253                     keepB = true;
34254                     break;
34255                   }
34256                 }
34257               }
34258             }
34259             if (keepB) {
34260               relation = relation.replaceMember(wayA, wayB);
34261               graph = graph.replace(relation);
34262             }
34263           } else {
34264             for (i3 = 0; i3 < v2.length; i3++) {
34265               if (v2[i3].type === "way" && v2[i3].id === wayA.id) {
34266                 member = {
34267                   id: wayB.id,
34268                   type: "way",
34269                   role: "via"
34270                 };
34271                 graph = actionAddMember(relation.id, member, v2[i3].index + 1)(graph);
34272                 break;
34273               }
34274             }
34275           }
34276         } else {
34277           if (relation === isOuter) {
34278             graph = graph.replace(relation.mergeTags(wayA.tags));
34279             graph = graph.replace(wayA.update({ tags: {} }));
34280             graph = graph.replace(wayB.update({ tags: {} }));
34281           }
34282           member = {
34283             id: wayB.id,
34284             type: "way",
34285             role: relation.memberById(wayA.id).role
34286           };
34287           var insertPair = {
34288             originalID: wayA.id,
34289             insertedID: wayB.id,
34290             nodes: origNodes
34291           };
34292           graph = actionAddMember(relation.id, member, void 0, insertPair)(graph);
34293         }
34294       });
34295       if (!isOuter && isArea) {
34296         var multipolygon = osmRelation({
34297           tags: Object.assign({}, wayA.tags, { type: "multipolygon" }),
34298           members: [
34299             { id: wayA.id, role: "outer", type: "way" },
34300             { id: wayB.id, role: "outer", type: "way" }
34301           ]
34302         });
34303         graph = graph.replace(multipolygon);
34304         graph = graph.replace(wayA.update({ tags: {} }));
34305         graph = graph.replace(wayB.update({ tags: {} }));
34306       }
34307       _createdWayIDs.push(wayB.id);
34308       return graph;
34309     }
34310     var action = function(graph) {
34311       _createdWayIDs = [];
34312       var newWayIndex = 0;
34313       for (var i3 = 0; i3 < nodeIds.length; i3++) {
34314         var nodeId = nodeIds[i3];
34315         var candidates = action.waysForNode(nodeId, graph);
34316         for (var j2 = 0; j2 < candidates.length; j2++) {
34317           graph = split(graph, nodeId, candidates[j2], newWayIds && newWayIds[newWayIndex]);
34318           newWayIndex += 1;
34319         }
34320       }
34321       return graph;
34322     };
34323     action.getCreatedWayIDs = function() {
34324       return _createdWayIDs;
34325     };
34326     action.waysForNode = function(nodeId, graph) {
34327       var node = graph.entity(nodeId);
34328       var splittableParents = graph.parentWays(node).filter(isSplittable);
34329       if (!_wayIDs) {
34330         var hasLine = splittableParents.some(function(parent) {
34331           return parent.geometry(graph) === "line";
34332         });
34333         if (hasLine) {
34334           return splittableParents.filter(function(parent) {
34335             return parent.geometry(graph) === "line";
34336           });
34337         }
34338       }
34339       return splittableParents;
34340       function isSplittable(parent) {
34341         if (_wayIDs && _wayIDs.indexOf(parent.id) === -1)
34342           return false;
34343         if (parent.isClosed())
34344           return true;
34345         for (var i3 = 1; i3 < parent.nodes.length - 1; i3++) {
34346           if (parent.nodes[i3] === nodeId)
34347             return true;
34348         }
34349         return false;
34350       }
34351     };
34352     action.ways = function(graph) {
34353       return utilArrayUniq([].concat.apply([], nodeIds.map(function(nodeId) {
34354         return action.waysForNode(nodeId, graph);
34355       })));
34356     };
34357     action.disabled = function(graph) {
34358       for (var i3 = 0; i3 < nodeIds.length; i3++) {
34359         var nodeId = nodeIds[i3];
34360         var candidates = action.waysForNode(nodeId, graph);
34361         if (candidates.length === 0 || _wayIDs && _wayIDs.length !== candidates.length) {
34362           return "not_eligible";
34363         }
34364       }
34365     };
34366     action.limitWays = function(val) {
34367       if (!arguments.length)
34368         return _wayIDs;
34369       _wayIDs = val;
34370       return action;
34371     };
34372     action.keepHistoryOn = function(val) {
34373       if (!arguments.length)
34374         return _keepHistoryOn;
34375       _keepHistoryOn = val;
34376       return action;
34377     };
34378     return action;
34379   }
34380
34381   // modules/core/graph.js
34382   function coreGraph(other, mutable) {
34383     if (!(this instanceof coreGraph))
34384       return new coreGraph(other, mutable);
34385     if (other instanceof coreGraph) {
34386       var base = other.base();
34387       this.entities = Object.assign(Object.create(base.entities), other.entities);
34388       this._parentWays = Object.assign(Object.create(base.parentWays), other._parentWays);
34389       this._parentRels = Object.assign(Object.create(base.parentRels), other._parentRels);
34390     } else {
34391       this.entities = /* @__PURE__ */ Object.create({});
34392       this._parentWays = /* @__PURE__ */ Object.create({});
34393       this._parentRels = /* @__PURE__ */ Object.create({});
34394       this.rebase(other || [], [this]);
34395     }
34396     this.transients = {};
34397     this._childNodes = {};
34398     this.frozen = !mutable;
34399   }
34400   coreGraph.prototype = {
34401     hasEntity: function(id2) {
34402       return this.entities[id2];
34403     },
34404     entity: function(id2) {
34405       var entity = this.entities[id2];
34406       if (!entity) {
34407         entity = this.entities.__proto__[id2];
34408       }
34409       if (!entity) {
34410         throw new Error("entity " + id2 + " not found");
34411       }
34412       return entity;
34413     },
34414     geometry: function(id2) {
34415       return this.entity(id2).geometry(this);
34416     },
34417     transient: function(entity, key, fn) {
34418       var id2 = entity.id;
34419       var transients = this.transients[id2] || (this.transients[id2] = {});
34420       if (transients[key] !== void 0) {
34421         return transients[key];
34422       }
34423       transients[key] = fn.call(entity);
34424       return transients[key];
34425     },
34426     parentWays: function(entity) {
34427       var parents = this._parentWays[entity.id];
34428       var result = [];
34429       if (parents) {
34430         parents.forEach(function(id2) {
34431           result.push(this.entity(id2));
34432         }, this);
34433       }
34434       return result;
34435     },
34436     isPoi: function(entity) {
34437       var parents = this._parentWays[entity.id];
34438       return !parents || parents.size === 0;
34439     },
34440     isShared: function(entity) {
34441       var parents = this._parentWays[entity.id];
34442       return parents && parents.size > 1;
34443     },
34444     parentRelations: function(entity) {
34445       var parents = this._parentRels[entity.id];
34446       var result = [];
34447       if (parents) {
34448         parents.forEach(function(id2) {
34449           result.push(this.entity(id2));
34450         }, this);
34451       }
34452       return result;
34453     },
34454     parentMultipolygons: function(entity) {
34455       return this.parentRelations(entity).filter(function(relation) {
34456         return relation.isMultipolygon();
34457       });
34458     },
34459     childNodes: function(entity) {
34460       if (this._childNodes[entity.id])
34461         return this._childNodes[entity.id];
34462       if (!entity.nodes)
34463         return [];
34464       var nodes = [];
34465       for (var i3 = 0; i3 < entity.nodes.length; i3++) {
34466         nodes[i3] = this.entity(entity.nodes[i3]);
34467       }
34468       if (debug)
34469         Object.freeze(nodes);
34470       this._childNodes[entity.id] = nodes;
34471       return this._childNodes[entity.id];
34472     },
34473     base: function() {
34474       return {
34475         "entities": Object.getPrototypeOf(this.entities),
34476         "parentWays": Object.getPrototypeOf(this._parentWays),
34477         "parentRels": Object.getPrototypeOf(this._parentRels)
34478       };
34479     },
34480     // Unlike other graph methods, rebase mutates in place. This is because it
34481     // is used only during the history operation that merges newly downloaded
34482     // data into each state. To external consumers, it should appear as if the
34483     // graph always contained the newly downloaded data.
34484     rebase: function(entities, stack, force) {
34485       var base = this.base();
34486       var i3, j2, k2, id2;
34487       for (i3 = 0; i3 < entities.length; i3++) {
34488         var entity = entities[i3];
34489         if (!entity.visible || !force && base.entities[entity.id])
34490           continue;
34491         base.entities[entity.id] = entity;
34492         this._updateCalculated(void 0, entity, base.parentWays, base.parentRels);
34493         if (entity.type === "way") {
34494           for (j2 = 0; j2 < entity.nodes.length; j2++) {
34495             id2 = entity.nodes[j2];
34496             for (k2 = 1; k2 < stack.length; k2++) {
34497               var ents = stack[k2].entities;
34498               if (ents.hasOwnProperty(id2) && ents[id2] === void 0) {
34499                 delete ents[id2];
34500               }
34501             }
34502           }
34503         }
34504       }
34505       for (i3 = 0; i3 < stack.length; i3++) {
34506         stack[i3]._updateRebased();
34507       }
34508     },
34509     _updateRebased: function() {
34510       var base = this.base();
34511       Object.keys(this._parentWays).forEach(function(child) {
34512         if (base.parentWays[child]) {
34513           base.parentWays[child].forEach(function(id2) {
34514             if (!this.entities.hasOwnProperty(id2)) {
34515               this._parentWays[child].add(id2);
34516             }
34517           }, this);
34518         }
34519       }, this);
34520       Object.keys(this._parentRels).forEach(function(child) {
34521         if (base.parentRels[child]) {
34522           base.parentRels[child].forEach(function(id2) {
34523             if (!this.entities.hasOwnProperty(id2)) {
34524               this._parentRels[child].add(id2);
34525             }
34526           }, this);
34527         }
34528       }, this);
34529       this.transients = {};
34530     },
34531     // Updates calculated properties (parentWays, parentRels) for the specified change
34532     _updateCalculated: function(oldentity, entity, parentWays, parentRels) {
34533       parentWays = parentWays || this._parentWays;
34534       parentRels = parentRels || this._parentRels;
34535       var type2 = entity && entity.type || oldentity && oldentity.type;
34536       var removed, added, i3;
34537       if (type2 === "way") {
34538         if (oldentity && entity) {
34539           removed = utilArrayDifference(oldentity.nodes, entity.nodes);
34540           added = utilArrayDifference(entity.nodes, oldentity.nodes);
34541         } else if (oldentity) {
34542           removed = oldentity.nodes;
34543           added = [];
34544         } else if (entity) {
34545           removed = [];
34546           added = entity.nodes;
34547         }
34548         for (i3 = 0; i3 < removed.length; i3++) {
34549           parentWays[removed[i3]] = new Set(parentWays[removed[i3]]);
34550           parentWays[removed[i3]].delete(oldentity.id);
34551         }
34552         for (i3 = 0; i3 < added.length; i3++) {
34553           parentWays[added[i3]] = new Set(parentWays[added[i3]]);
34554           parentWays[added[i3]].add(entity.id);
34555         }
34556       } else if (type2 === "relation") {
34557         var oldentityMemberIDs = oldentity ? oldentity.members.map(function(m2) {
34558           return m2.id;
34559         }) : [];
34560         var entityMemberIDs = entity ? entity.members.map(function(m2) {
34561           return m2.id;
34562         }) : [];
34563         if (oldentity && entity) {
34564           removed = utilArrayDifference(oldentityMemberIDs, entityMemberIDs);
34565           added = utilArrayDifference(entityMemberIDs, oldentityMemberIDs);
34566         } else if (oldentity) {
34567           removed = oldentityMemberIDs;
34568           added = [];
34569         } else if (entity) {
34570           removed = [];
34571           added = entityMemberIDs;
34572         }
34573         for (i3 = 0; i3 < removed.length; i3++) {
34574           parentRels[removed[i3]] = new Set(parentRels[removed[i3]]);
34575           parentRels[removed[i3]].delete(oldentity.id);
34576         }
34577         for (i3 = 0; i3 < added.length; i3++) {
34578           parentRels[added[i3]] = new Set(parentRels[added[i3]]);
34579           parentRels[added[i3]].add(entity.id);
34580         }
34581       }
34582     },
34583     replace: function(entity) {
34584       if (this.entities[entity.id] === entity)
34585         return this;
34586       return this.update(function() {
34587         this._updateCalculated(this.entities[entity.id], entity);
34588         this.entities[entity.id] = entity;
34589       });
34590     },
34591     remove: function(entity) {
34592       return this.update(function() {
34593         this._updateCalculated(entity, void 0);
34594         this.entities[entity.id] = void 0;
34595       });
34596     },
34597     revert: function(id2) {
34598       var baseEntity = this.base().entities[id2];
34599       var headEntity = this.entities[id2];
34600       if (headEntity === baseEntity)
34601         return this;
34602       return this.update(function() {
34603         this._updateCalculated(headEntity, baseEntity);
34604         delete this.entities[id2];
34605       });
34606     },
34607     update: function() {
34608       var graph = this.frozen ? coreGraph(this, true) : this;
34609       for (var i3 = 0; i3 < arguments.length; i3++) {
34610         arguments[i3].call(graph, graph);
34611       }
34612       if (this.frozen)
34613         graph.frozen = true;
34614       return graph;
34615     },
34616     // Obliterates any existing entities
34617     load: function(entities) {
34618       var base = this.base();
34619       this.entities = Object.create(base.entities);
34620       for (var i3 in entities) {
34621         this.entities[i3] = entities[i3];
34622         this._updateCalculated(base.entities[i3], this.entities[i3]);
34623       }
34624       return this;
34625     }
34626   };
34627
34628   // modules/osm/intersection.js
34629   function osmTurn(turn) {
34630     if (!(this instanceof osmTurn)) {
34631       return new osmTurn(turn);
34632     }
34633     Object.assign(this, turn);
34634   }
34635   function osmIntersection(graph, startVertexId, maxDistance) {
34636     maxDistance = maxDistance || 30;
34637     var vgraph = coreGraph();
34638     var i3, j2, k2;
34639     function memberOfRestriction(entity) {
34640       return graph.parentRelations(entity).some(function(r2) {
34641         return r2.isRestriction();
34642       });
34643     }
34644     function isRoad(way2) {
34645       if (way2.isArea() || way2.isDegenerate())
34646         return false;
34647       var roads = {
34648         "motorway": true,
34649         "motorway_link": true,
34650         "trunk": true,
34651         "trunk_link": true,
34652         "primary": true,
34653         "primary_link": true,
34654         "secondary": true,
34655         "secondary_link": true,
34656         "tertiary": true,
34657         "tertiary_link": true,
34658         "residential": true,
34659         "unclassified": true,
34660         "living_street": true,
34661         "service": true,
34662         "busway": true,
34663         "road": true,
34664         "track": true
34665       };
34666       return roads[way2.tags.highway];
34667     }
34668     var startNode = graph.entity(startVertexId);
34669     var checkVertices = [startNode];
34670     var checkWays;
34671     var vertices = [];
34672     var vertexIds = [];
34673     var vertex;
34674     var ways = [];
34675     var wayIds = [];
34676     var way;
34677     var nodes = [];
34678     var node;
34679     var parents = [];
34680     var parent;
34681     var actions = [];
34682     while (checkVertices.length) {
34683       vertex = checkVertices.pop();
34684       checkWays = graph.parentWays(vertex);
34685       var hasWays = false;
34686       for (i3 = 0; i3 < checkWays.length; i3++) {
34687         way = checkWays[i3];
34688         if (!isRoad(way) && !memberOfRestriction(way))
34689           continue;
34690         ways.push(way);
34691         hasWays = true;
34692         nodes = utilArrayUniq(graph.childNodes(way));
34693         for (j2 = 0; j2 < nodes.length; j2++) {
34694           node = nodes[j2];
34695           if (node === vertex)
34696             continue;
34697           if (vertices.indexOf(node) !== -1)
34698             continue;
34699           if (geoSphericalDistance(node.loc, startNode.loc) > maxDistance)
34700             continue;
34701           var hasParents = false;
34702           parents = graph.parentWays(node);
34703           for (k2 = 0; k2 < parents.length; k2++) {
34704             parent = parents[k2];
34705             if (parent === way)
34706               continue;
34707             if (ways.indexOf(parent) !== -1)
34708               continue;
34709             if (!isRoad(parent))
34710               continue;
34711             hasParents = true;
34712             break;
34713           }
34714           if (hasParents) {
34715             checkVertices.push(node);
34716           }
34717         }
34718       }
34719       if (hasWays) {
34720         vertices.push(vertex);
34721       }
34722     }
34723     vertices = utilArrayUniq(vertices);
34724     ways = utilArrayUniq(ways);
34725     ways.forEach(function(way2) {
34726       graph.childNodes(way2).forEach(function(node2) {
34727         vgraph = vgraph.replace(node2);
34728       });
34729       vgraph = vgraph.replace(way2);
34730       graph.parentRelations(way2).forEach(function(relation) {
34731         if (relation.isRestriction()) {
34732           if (relation.isValidRestriction(graph)) {
34733             vgraph = vgraph.replace(relation);
34734           } else if (relation.isComplete(graph)) {
34735             actions.push(actionDeleteRelation(relation.id));
34736           }
34737         }
34738       });
34739     });
34740     ways.forEach(function(w2) {
34741       var way2 = vgraph.entity(w2.id);
34742       if (way2.tags.oneway === "-1") {
34743         var action = actionReverse(way2.id, { reverseOneway: true });
34744         actions.push(action);
34745         vgraph = action(vgraph);
34746       }
34747     });
34748     var origCount = osmEntity.id.next.way;
34749     vertices.forEach(function(v2) {
34750       var splitAll = actionSplit([v2.id]).keepHistoryOn("first");
34751       if (!splitAll.disabled(vgraph)) {
34752         splitAll.ways(vgraph).forEach(function(way2) {
34753           var splitOne = actionSplit([v2.id]).limitWays([way2.id]).keepHistoryOn("first");
34754           actions.push(splitOne);
34755           vgraph = splitOne(vgraph);
34756         });
34757       }
34758     });
34759     osmEntity.id.next.way = origCount;
34760     vertexIds = vertices.map(function(v2) {
34761       return v2.id;
34762     });
34763     vertices = [];
34764     ways = [];
34765     vertexIds.forEach(function(id2) {
34766       var vertex2 = vgraph.entity(id2);
34767       var parents2 = vgraph.parentWays(vertex2);
34768       vertices.push(vertex2);
34769       ways = ways.concat(parents2);
34770     });
34771     vertices = utilArrayUniq(vertices);
34772     ways = utilArrayUniq(ways);
34773     vertexIds = vertices.map(function(v2) {
34774       return v2.id;
34775     });
34776     wayIds = ways.map(function(w2) {
34777       return w2.id;
34778     });
34779     function withMetadata(way2, vertexIds2) {
34780       var __oneWay = way2.isOneWay();
34781       var __first = vertexIds2.indexOf(way2.first()) !== -1;
34782       var __last = vertexIds2.indexOf(way2.last()) !== -1;
34783       var __via = __first && __last;
34784       var __from = __first && !__oneWay || __last;
34785       var __to = __first || __last && !__oneWay;
34786       return way2.update({
34787         __first,
34788         __last,
34789         __from,
34790         __via,
34791         __to,
34792         __oneWay
34793       });
34794     }
34795     ways = [];
34796     wayIds.forEach(function(id2) {
34797       var way2 = withMetadata(vgraph.entity(id2), vertexIds);
34798       vgraph = vgraph.replace(way2);
34799       ways.push(way2);
34800     });
34801     var keepGoing;
34802     var removeWayIds = [];
34803     var removeVertexIds = [];
34804     do {
34805       keepGoing = false;
34806       checkVertices = vertexIds.slice();
34807       for (i3 = 0; i3 < checkVertices.length; i3++) {
34808         var vertexId = checkVertices[i3];
34809         vertex = vgraph.hasEntity(vertexId);
34810         if (!vertex) {
34811           if (vertexIds.indexOf(vertexId) !== -1) {
34812             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
34813           }
34814           removeVertexIds.push(vertexId);
34815           continue;
34816         }
34817         parents = vgraph.parentWays(vertex);
34818         if (parents.length < 3) {
34819           if (vertexIds.indexOf(vertexId) !== -1) {
34820             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
34821           }
34822         }
34823         if (parents.length === 2) {
34824           var a2 = parents[0];
34825           var b2 = parents[1];
34826           var aIsLeaf = a2 && !a2.__via;
34827           var bIsLeaf = b2 && !b2.__via;
34828           var leaf, survivor;
34829           if (aIsLeaf && !bIsLeaf) {
34830             leaf = a2;
34831             survivor = b2;
34832           } else if (!aIsLeaf && bIsLeaf) {
34833             leaf = b2;
34834             survivor = a2;
34835           }
34836           if (leaf && survivor) {
34837             survivor = withMetadata(survivor, vertexIds);
34838             vgraph = vgraph.replace(survivor).remove(leaf);
34839             removeWayIds.push(leaf.id);
34840             keepGoing = true;
34841           }
34842         }
34843         parents = vgraph.parentWays(vertex);
34844         if (parents.length < 2) {
34845           if (vertexIds.indexOf(vertexId) !== -1) {
34846             vertexIds.splice(vertexIds.indexOf(vertexId), 1);
34847           }
34848           removeVertexIds.push(vertexId);
34849           keepGoing = true;
34850         }
34851         if (parents.length < 1) {
34852           vgraph = vgraph.remove(vertex);
34853         }
34854       }
34855     } while (keepGoing);
34856     vertices = vertices.filter(function(vertex2) {
34857       return removeVertexIds.indexOf(vertex2.id) === -1;
34858     }).map(function(vertex2) {
34859       return vgraph.entity(vertex2.id);
34860     });
34861     ways = ways.filter(function(way2) {
34862       return removeWayIds.indexOf(way2.id) === -1;
34863     }).map(function(way2) {
34864       return vgraph.entity(way2.id);
34865     });
34866     var intersection2 = {
34867       graph: vgraph,
34868       actions,
34869       vertices,
34870       ways
34871     };
34872     intersection2.turns = function(fromWayId, maxViaWay) {
34873       if (!fromWayId)
34874         return [];
34875       if (!maxViaWay)
34876         maxViaWay = 0;
34877       var vgraph2 = intersection2.graph;
34878       var keyVertexIds = intersection2.vertices.map(function(v2) {
34879         return v2.id;
34880       });
34881       var start2 = vgraph2.entity(fromWayId);
34882       if (!start2 || !(start2.__from || start2.__via))
34883         return [];
34884       var maxPathLength = maxViaWay * 2 + 3;
34885       var turns = [];
34886       step(start2);
34887       return turns;
34888       function step(entity, currPath, currRestrictions, matchedRestriction) {
34889         currPath = (currPath || []).slice();
34890         if (currPath.length >= maxPathLength)
34891           return;
34892         currPath.push(entity.id);
34893         currRestrictions = (currRestrictions || []).slice();
34894         if (entity.type === "node") {
34895           stepNode(entity, currPath, currRestrictions);
34896         } else {
34897           stepWay(entity, currPath, currRestrictions, matchedRestriction);
34898         }
34899       }
34900       function stepNode(entity, currPath, currRestrictions) {
34901         var i4, j3;
34902         var parents2 = vgraph2.parentWays(entity);
34903         var nextWays = [];
34904         for (i4 = 0; i4 < parents2.length; i4++) {
34905           var way2 = parents2[i4];
34906           if (way2.__oneWay && way2.nodes[0] !== entity.id)
34907             continue;
34908           if (currPath.indexOf(way2.id) !== -1 && currPath.length >= 3)
34909             continue;
34910           var restrict = null;
34911           for (j3 = 0; j3 < currRestrictions.length; j3++) {
34912             var restriction = currRestrictions[j3];
34913             var f2 = restriction.memberByRole("from");
34914             var v2 = restriction.membersByRole("via");
34915             var t2 = restriction.memberByRole("to");
34916             var isNo = /^no_/.test(restriction.tags.restriction);
34917             var isOnly = /^only_/.test(restriction.tags.restriction);
34918             if (!(isNo || isOnly)) {
34919               continue;
34920             }
34921             var matchesFrom = f2.id === fromWayId;
34922             var matchesViaTo = false;
34923             var isAlongOnlyPath = false;
34924             if (t2.id === way2.id) {
34925               if (v2.length === 1 && v2[0].type === "node") {
34926                 matchesViaTo = v2[0].id === entity.id && (matchesFrom && currPath.length === 2 || !matchesFrom && currPath.length > 2);
34927               } else {
34928                 var pathVias = [];
34929                 for (k2 = 2; k2 < currPath.length; k2 += 2) {
34930                   pathVias.push(currPath[k2]);
34931                 }
34932                 var restrictionVias = [];
34933                 for (k2 = 0; k2 < v2.length; k2++) {
34934                   if (v2[k2].type === "way") {
34935                     restrictionVias.push(v2[k2].id);
34936                   }
34937                 }
34938                 var diff = utilArrayDifference(pathVias, restrictionVias);
34939                 matchesViaTo = !diff.length;
34940               }
34941             } else if (isOnly) {
34942               for (k2 = 0; k2 < v2.length; k2++) {
34943                 if (v2[k2].type === "way" && v2[k2].id === way2.id) {
34944                   isAlongOnlyPath = true;
34945                   break;
34946                 }
34947               }
34948             }
34949             if (matchesViaTo) {
34950               if (isOnly) {
34951                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, only: true, end: true };
34952               } else {
34953                 restrict = { id: restriction.id, direct: matchesFrom, from: f2.id, no: true, end: true };
34954               }
34955             } else {
34956               if (isAlongOnlyPath) {
34957                 restrict = { id: restriction.id, direct: false, from: f2.id, only: true, end: false };
34958               } else if (isOnly) {
34959                 restrict = { id: restriction.id, direct: false, from: f2.id, no: true, end: true };
34960               }
34961             }
34962             if (restrict && restrict.direct)
34963               break;
34964           }
34965           nextWays.push({ way: way2, restrict });
34966         }
34967         nextWays.forEach(function(nextWay) {
34968           step(nextWay.way, currPath, currRestrictions, nextWay.restrict);
34969         });
34970       }
34971       function stepWay(entity, currPath, currRestrictions, matchedRestriction) {
34972         var i4;
34973         if (currPath.length >= 3) {
34974           var turnPath = currPath.slice();
34975           if (matchedRestriction && matchedRestriction.direct === false) {
34976             for (i4 = 0; i4 < turnPath.length; i4++) {
34977               if (turnPath[i4] === matchedRestriction.from) {
34978                 turnPath = turnPath.slice(i4);
34979                 break;
34980               }
34981             }
34982           }
34983           var turn = pathToTurn(turnPath);
34984           if (turn) {
34985             if (matchedRestriction) {
34986               turn.restrictionID = matchedRestriction.id;
34987               turn.no = matchedRestriction.no;
34988               turn.only = matchedRestriction.only;
34989               turn.direct = matchedRestriction.direct;
34990             }
34991             turns.push(osmTurn(turn));
34992           }
34993           if (currPath[0] === currPath[2])
34994             return;
34995         }
34996         if (matchedRestriction && matchedRestriction.end)
34997           return;
34998         var n1 = vgraph2.entity(entity.first());
34999         var n22 = vgraph2.entity(entity.last());
35000         var dist = geoSphericalDistance(n1.loc, n22.loc);
35001         var nextNodes = [];
35002         if (currPath.length > 1) {
35003           if (dist > maxDistance)
35004             return;
35005           if (!entity.__via)
35006             return;
35007         }
35008         if (!entity.__oneWay && // bidirectional..
35009         keyVertexIds.indexOf(n1.id) !== -1 && // key vertex..
35010         currPath.indexOf(n1.id) === -1) {
35011           nextNodes.push(n1);
35012         }
35013         if (keyVertexIds.indexOf(n22.id) !== -1 && // key vertex..
35014         currPath.indexOf(n22.id) === -1) {
35015           nextNodes.push(n22);
35016         }
35017         nextNodes.forEach(function(nextNode) {
35018           var fromRestrictions = vgraph2.parentRelations(entity).filter(function(r2) {
35019             if (!r2.isRestriction())
35020               return false;
35021             var f2 = r2.memberByRole("from");
35022             if (!f2 || f2.id !== entity.id)
35023               return false;
35024             var isOnly = /^only_/.test(r2.tags.restriction);
35025             if (!isOnly)
35026               return true;
35027             var isOnlyVia = false;
35028             var v2 = r2.membersByRole("via");
35029             if (v2.length === 1 && v2[0].type === "node") {
35030               isOnlyVia = v2[0].id === nextNode.id;
35031             } else {
35032               for (var i5 = 0; i5 < v2.length; i5++) {
35033                 if (v2[i5].type !== "way")
35034                   continue;
35035                 var viaWay = vgraph2.entity(v2[i5].id);
35036                 if (viaWay.first() === nextNode.id || viaWay.last() === nextNode.id) {
35037                   isOnlyVia = true;
35038                   break;
35039                 }
35040               }
35041             }
35042             return isOnlyVia;
35043           });
35044           step(nextNode, currPath, currRestrictions.concat(fromRestrictions), false);
35045         });
35046       }
35047       function pathToTurn(path) {
35048         if (path.length < 3)
35049           return;
35050         var fromWayId2, fromNodeId, fromVertexId;
35051         var toWayId, toNodeId, toVertexId;
35052         var viaWayIds, viaNodeId, isUturn;
35053         fromWayId2 = path[0];
35054         toWayId = path[path.length - 1];
35055         if (path.length === 3 && fromWayId2 === toWayId) {
35056           var way2 = vgraph2.entity(fromWayId2);
35057           if (way2.__oneWay)
35058             return null;
35059           isUturn = true;
35060           viaNodeId = fromVertexId = toVertexId = path[1];
35061           fromNodeId = toNodeId = adjacentNode(fromWayId2, viaNodeId);
35062         } else {
35063           isUturn = false;
35064           fromVertexId = path[1];
35065           fromNodeId = adjacentNode(fromWayId2, fromVertexId);
35066           toVertexId = path[path.length - 2];
35067           toNodeId = adjacentNode(toWayId, toVertexId);
35068           if (path.length === 3) {
35069             viaNodeId = path[1];
35070           } else {
35071             viaWayIds = path.filter(function(entityId) {
35072               return entityId[0] === "w";
35073             });
35074             viaWayIds = viaWayIds.slice(1, viaWayIds.length - 1);
35075           }
35076         }
35077         return {
35078           key: path.join("_"),
35079           path,
35080           from: { node: fromNodeId, way: fromWayId2, vertex: fromVertexId },
35081           via: { node: viaNodeId, ways: viaWayIds },
35082           to: { node: toNodeId, way: toWayId, vertex: toVertexId },
35083           u: isUturn
35084         };
35085         function adjacentNode(wayId, affixId) {
35086           var nodes2 = vgraph2.entity(wayId).nodes;
35087           return affixId === nodes2[0] ? nodes2[1] : nodes2[nodes2.length - 2];
35088         }
35089       }
35090     };
35091     return intersection2;
35092   }
35093   function osmInferRestriction(graph, turn, projection2) {
35094     var fromWay = graph.entity(turn.from.way);
35095     var fromNode = graph.entity(turn.from.node);
35096     var fromVertex = graph.entity(turn.from.vertex);
35097     var toWay = graph.entity(turn.to.way);
35098     var toNode = graph.entity(turn.to.node);
35099     var toVertex = graph.entity(turn.to.vertex);
35100     var fromOneWay = fromWay.tags.oneway === "yes";
35101     var toOneWay = toWay.tags.oneway === "yes";
35102     var angle2 = (geoAngle(fromVertex, fromNode, projection2) - geoAngle(toVertex, toNode, projection2)) * 180 / Math.PI;
35103     while (angle2 < 0) {
35104       angle2 += 360;
35105     }
35106     if (fromNode === toNode) {
35107       return "no_u_turn";
35108     }
35109     if ((angle2 < 23 || angle2 > 336) && fromOneWay && toOneWay) {
35110       return "no_u_turn";
35111     }
35112     if ((angle2 < 40 || angle2 > 319) && fromOneWay && toOneWay && turn.from.vertex !== turn.to.vertex) {
35113       return "no_u_turn";
35114     }
35115     if (angle2 < 158) {
35116       return "no_right_turn";
35117     }
35118     if (angle2 > 202) {
35119       return "no_left_turn";
35120     }
35121     return "no_straight_on";
35122   }
35123
35124   // modules/actions/merge_polygon.js
35125   function actionMergePolygon(ids, newRelationId) {
35126     function groupEntities(graph) {
35127       var entities = ids.map(function(id2) {
35128         return graph.entity(id2);
35129       });
35130       var geometryGroups = utilArrayGroupBy(entities, function(entity) {
35131         if (entity.type === "way" && entity.isClosed()) {
35132           return "closedWay";
35133         } else if (entity.type === "relation" && entity.isMultipolygon()) {
35134           return "multipolygon";
35135         } else {
35136           return "other";
35137         }
35138       });
35139       return Object.assign(
35140         { closedWay: [], multipolygon: [], other: [] },
35141         geometryGroups
35142       );
35143     }
35144     var action = function(graph) {
35145       var entities = groupEntities(graph);
35146       var polygons = entities.multipolygon.reduce(function(polygons2, m2) {
35147         return polygons2.concat(osmJoinWays(m2.members, graph));
35148       }, []).concat(entities.closedWay.map(function(d2) {
35149         var member = [{ id: d2.id }];
35150         member.nodes = graph.childNodes(d2);
35151         return member;
35152       }));
35153       var contained = polygons.map(function(w2, i3) {
35154         return polygons.map(function(d2, n3) {
35155           if (i3 === n3)
35156             return null;
35157           return geoPolygonContainsPolygon(
35158             d2.nodes.map(function(n4) {
35159               return n4.loc;
35160             }),
35161             w2.nodes.map(function(n4) {
35162               return n4.loc;
35163             })
35164           );
35165         });
35166       });
35167       var members = [];
35168       var outer = true;
35169       while (polygons.length) {
35170         extractUncontained(polygons);
35171         polygons = polygons.filter(isContained);
35172         contained = contained.filter(isContained).map(filterContained);
35173       }
35174       function isContained(d2, i3) {
35175         return contained[i3].some(function(val) {
35176           return val;
35177         });
35178       }
35179       function filterContained(d2) {
35180         return d2.filter(isContained);
35181       }
35182       function extractUncontained(polygons2) {
35183         polygons2.forEach(function(d2, i3) {
35184           if (!isContained(d2, i3)) {
35185             d2.forEach(function(member) {
35186               members.push({
35187                 type: "way",
35188                 id: member.id,
35189                 role: outer ? "outer" : "inner"
35190               });
35191             });
35192           }
35193         });
35194         outer = !outer;
35195       }
35196       var relation;
35197       if (entities.multipolygon.length > 0) {
35198         var oldestID = utilOldestID(entities.multipolygon.map((entity) => entity.id));
35199         relation = entities.multipolygon.find((entity) => entity.id === oldestID);
35200       } else {
35201         relation = osmRelation({ id: newRelationId, tags: { type: "multipolygon" } });
35202       }
35203       entities.multipolygon.forEach(function(m2) {
35204         if (m2.id !== relation.id) {
35205           relation = relation.mergeTags(m2.tags);
35206           graph = graph.remove(m2);
35207         }
35208       });
35209       entities.closedWay.forEach(function(way) {
35210         function isThisOuter(m2) {
35211           return m2.id === way.id && m2.role !== "inner";
35212         }
35213         if (members.some(isThisOuter)) {
35214           relation = relation.mergeTags(way.tags);
35215           graph = graph.replace(way.update({ tags: {} }));
35216         }
35217       });
35218       return graph.replace(relation.update({
35219         members,
35220         tags: utilObjectOmit(relation.tags, ["area"])
35221       }));
35222     };
35223     action.disabled = function(graph) {
35224       var entities = groupEntities(graph);
35225       if (entities.other.length > 0 || entities.closedWay.length + entities.multipolygon.length < 2) {
35226         return "not_eligible";
35227       }
35228       if (!entities.multipolygon.every(function(r2) {
35229         return r2.isComplete(graph);
35230       })) {
35231         return "incomplete_relation";
35232       }
35233       if (!entities.multipolygon.length) {
35234         var sharedMultipolygons = [];
35235         entities.closedWay.forEach(function(way, i3) {
35236           if (i3 === 0) {
35237             sharedMultipolygons = graph.parentMultipolygons(way);
35238           } else {
35239             sharedMultipolygons = utilArrayIntersection(sharedMultipolygons, graph.parentMultipolygons(way));
35240           }
35241         });
35242         sharedMultipolygons = sharedMultipolygons.filter(function(relation) {
35243           return relation.members.length === entities.closedWay.length;
35244         });
35245         if (sharedMultipolygons.length) {
35246           return "not_eligible";
35247         }
35248       } else if (entities.closedWay.some(function(way) {
35249         return utilArrayIntersection(graph.parentMultipolygons(way), entities.multipolygon).length;
35250       })) {
35251         return "not_eligible";
35252       }
35253     };
35254     return action;
35255   }
35256
35257   // modules/actions/merge_remote_changes.js
35258   var import_fast_deep_equal = __toESM(require_fast_deep_equal());
35259
35260   // node_modules/node-diff3/index.mjs
35261   function LCS(buffer1, buffer2) {
35262     let equivalenceClasses = {};
35263     for (let j2 = 0; j2 < buffer2.length; j2++) {
35264       const item = buffer2[j2];
35265       if (equivalenceClasses[item]) {
35266         equivalenceClasses[item].push(j2);
35267       } else {
35268         equivalenceClasses[item] = [j2];
35269       }
35270     }
35271     const NULLRESULT = { buffer1index: -1, buffer2index: -1, chain: null };
35272     let candidates = [NULLRESULT];
35273     for (let i3 = 0; i3 < buffer1.length; i3++) {
35274       const item = buffer1[i3];
35275       const buffer2indices = equivalenceClasses[item] || [];
35276       let r2 = 0;
35277       let c2 = candidates[0];
35278       for (let jx = 0; jx < buffer2indices.length; jx++) {
35279         const j2 = buffer2indices[jx];
35280         let s2;
35281         for (s2 = r2; s2 < candidates.length; s2++) {
35282           if (candidates[s2].buffer2index < j2 && (s2 === candidates.length - 1 || candidates[s2 + 1].buffer2index > j2)) {
35283             break;
35284           }
35285         }
35286         if (s2 < candidates.length) {
35287           const newCandidate = { buffer1index: i3, buffer2index: j2, chain: candidates[s2] };
35288           if (r2 === candidates.length) {
35289             candidates.push(c2);
35290           } else {
35291             candidates[r2] = c2;
35292           }
35293           r2 = s2 + 1;
35294           c2 = newCandidate;
35295           if (r2 === candidates.length) {
35296             break;
35297           }
35298         }
35299       }
35300       candidates[r2] = c2;
35301     }
35302     return candidates[candidates.length - 1];
35303   }
35304   function diffIndices(buffer1, buffer2) {
35305     const lcs = LCS(buffer1, buffer2);
35306     let result = [];
35307     let tail1 = buffer1.length;
35308     let tail2 = buffer2.length;
35309     for (let candidate = lcs; candidate !== null; candidate = candidate.chain) {
35310       const mismatchLength1 = tail1 - candidate.buffer1index - 1;
35311       const mismatchLength2 = tail2 - candidate.buffer2index - 1;
35312       tail1 = candidate.buffer1index;
35313       tail2 = candidate.buffer2index;
35314       if (mismatchLength1 || mismatchLength2) {
35315         result.push({
35316           buffer1: [tail1 + 1, mismatchLength1],
35317           buffer1Content: buffer1.slice(tail1 + 1, tail1 + 1 + mismatchLength1),
35318           buffer2: [tail2 + 1, mismatchLength2],
35319           buffer2Content: buffer2.slice(tail2 + 1, tail2 + 1 + mismatchLength2)
35320         });
35321       }
35322     }
35323     result.reverse();
35324     return result;
35325   }
35326   function diff3MergeRegions(a2, o2, b2) {
35327     let hunks = [];
35328     function addHunk(h2, ab) {
35329       hunks.push({
35330         ab,
35331         oStart: h2.buffer1[0],
35332         oLength: h2.buffer1[1],
35333         // length of o to remove
35334         abStart: h2.buffer2[0],
35335         abLength: h2.buffer2[1]
35336         // length of a/b to insert
35337         // abContent: (ab === 'a' ? a : b).slice(h.buffer2[0], h.buffer2[0] + h.buffer2[1])
35338       });
35339     }
35340     diffIndices(o2, a2).forEach((item) => addHunk(item, "a"));
35341     diffIndices(o2, b2).forEach((item) => addHunk(item, "b"));
35342     hunks.sort((x2, y2) => x2.oStart - y2.oStart);
35343     let results = [];
35344     let currOffset = 0;
35345     function advanceTo(endOffset) {
35346       if (endOffset > currOffset) {
35347         results.push({
35348           stable: true,
35349           buffer: "o",
35350           bufferStart: currOffset,
35351           bufferLength: endOffset - currOffset,
35352           bufferContent: o2.slice(currOffset, endOffset)
35353         });
35354         currOffset = endOffset;
35355       }
35356     }
35357     while (hunks.length) {
35358       let hunk = hunks.shift();
35359       let regionStart = hunk.oStart;
35360       let regionEnd = hunk.oStart + hunk.oLength;
35361       let regionHunks = [hunk];
35362       advanceTo(regionStart);
35363       while (hunks.length) {
35364         const nextHunk = hunks[0];
35365         const nextHunkStart = nextHunk.oStart;
35366         if (nextHunkStart > regionEnd)
35367           break;
35368         regionEnd = Math.max(regionEnd, nextHunkStart + nextHunk.oLength);
35369         regionHunks.push(hunks.shift());
35370       }
35371       if (regionHunks.length === 1) {
35372         if (hunk.abLength > 0) {
35373           const buffer = hunk.ab === "a" ? a2 : b2;
35374           results.push({
35375             stable: true,
35376             buffer: hunk.ab,
35377             bufferStart: hunk.abStart,
35378             bufferLength: hunk.abLength,
35379             bufferContent: buffer.slice(hunk.abStart, hunk.abStart + hunk.abLength)
35380           });
35381         }
35382       } else {
35383         let bounds = {
35384           a: [a2.length, -1, o2.length, -1],
35385           b: [b2.length, -1, o2.length, -1]
35386         };
35387         while (regionHunks.length) {
35388           hunk = regionHunks.shift();
35389           const oStart = hunk.oStart;
35390           const oEnd = oStart + hunk.oLength;
35391           const abStart = hunk.abStart;
35392           const abEnd = abStart + hunk.abLength;
35393           let b3 = bounds[hunk.ab];
35394           b3[0] = Math.min(abStart, b3[0]);
35395           b3[1] = Math.max(abEnd, b3[1]);
35396           b3[2] = Math.min(oStart, b3[2]);
35397           b3[3] = Math.max(oEnd, b3[3]);
35398         }
35399         const aStart = bounds.a[0] + (regionStart - bounds.a[2]);
35400         const aEnd = bounds.a[1] + (regionEnd - bounds.a[3]);
35401         const bStart = bounds.b[0] + (regionStart - bounds.b[2]);
35402         const bEnd = bounds.b[1] + (regionEnd - bounds.b[3]);
35403         let result = {
35404           stable: false,
35405           aStart,
35406           aLength: aEnd - aStart,
35407           aContent: a2.slice(aStart, aEnd),
35408           oStart: regionStart,
35409           oLength: regionEnd - regionStart,
35410           oContent: o2.slice(regionStart, regionEnd),
35411           bStart,
35412           bLength: bEnd - bStart,
35413           bContent: b2.slice(bStart, bEnd)
35414         };
35415         results.push(result);
35416       }
35417       currOffset = regionEnd;
35418     }
35419     advanceTo(o2.length);
35420     return results;
35421   }
35422   function diff3Merge(a2, o2, b2, options2) {
35423     let defaults = {
35424       excludeFalseConflicts: true,
35425       stringSeparator: /\s+/
35426     };
35427     options2 = Object.assign(defaults, options2);
35428     if (typeof a2 === "string")
35429       a2 = a2.split(options2.stringSeparator);
35430     if (typeof o2 === "string")
35431       o2 = o2.split(options2.stringSeparator);
35432     if (typeof b2 === "string")
35433       b2 = b2.split(options2.stringSeparator);
35434     let results = [];
35435     const regions = diff3MergeRegions(a2, o2, b2);
35436     let okBuffer = [];
35437     function flushOk() {
35438       if (okBuffer.length) {
35439         results.push({ ok: okBuffer });
35440       }
35441       okBuffer = [];
35442     }
35443     function isFalseConflict(a3, b3) {
35444       if (a3.length !== b3.length)
35445         return false;
35446       for (let i3 = 0; i3 < a3.length; i3++) {
35447         if (a3[i3] !== b3[i3])
35448           return false;
35449       }
35450       return true;
35451     }
35452     regions.forEach((region) => {
35453       if (region.stable) {
35454         okBuffer.push(...region.bufferContent);
35455       } else {
35456         if (options2.excludeFalseConflicts && isFalseConflict(region.aContent, region.bContent)) {
35457           okBuffer.push(...region.aContent);
35458         } else {
35459           flushOk();
35460           results.push({
35461             conflict: {
35462               a: region.aContent,
35463               aIndex: region.aStart,
35464               o: region.oContent,
35465               oIndex: region.oStart,
35466               b: region.bContent,
35467               bIndex: region.bStart
35468             }
35469           });
35470         }
35471       }
35472     });
35473     flushOk();
35474     return results;
35475   }
35476
35477   // modules/actions/merge_remote_changes.js
35478   var import_lodash2 = __toESM(require_lodash());
35479   function actionMergeRemoteChanges(id2, localGraph, remoteGraph, discardTags, formatUser) {
35480     discardTags = discardTags || {};
35481     var _option = "safe";
35482     var _conflicts = [];
35483     function user(d2) {
35484       return typeof formatUser === "function" ? formatUser(d2) : (0, import_lodash2.escape)(d2);
35485     }
35486     function mergeLocation(remote, target) {
35487       function pointEqual(a2, b2) {
35488         var epsilon3 = 1e-6;
35489         return Math.abs(a2[0] - b2[0]) < epsilon3 && Math.abs(a2[1] - b2[1]) < epsilon3;
35490       }
35491       if (_option === "force_local" || pointEqual(target.loc, remote.loc)) {
35492         return target;
35493       }
35494       if (_option === "force_remote") {
35495         return target.update({ loc: remote.loc });
35496       }
35497       _conflicts.push(_t.html("merge_remote_changes.conflict.location", { user: { html: user(remote.user) } }));
35498       return target;
35499     }
35500     function mergeNodes(base, remote, target) {
35501       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.nodes, remote.nodes)) {
35502         return target;
35503       }
35504       if (_option === "force_remote") {
35505         return target.update({ nodes: remote.nodes });
35506       }
35507       var ccount = _conflicts.length;
35508       var o2 = base.nodes || [];
35509       var a2 = target.nodes || [];
35510       var b2 = remote.nodes || [];
35511       var nodes = [];
35512       var hunks = diff3Merge(a2, o2, b2, { excludeFalseConflicts: true });
35513       for (var i3 = 0; i3 < hunks.length; i3++) {
35514         var hunk = hunks[i3];
35515         if (hunk.ok) {
35516           nodes.push.apply(nodes, hunk.ok);
35517         } else {
35518           var c2 = hunk.conflict;
35519           if ((0, import_fast_deep_equal.default)(c2.o, c2.a)) {
35520             nodes.push.apply(nodes, c2.b);
35521           } else if ((0, import_fast_deep_equal.default)(c2.o, c2.b)) {
35522             nodes.push.apply(nodes, c2.a);
35523           } else {
35524             _conflicts.push(_t.html("merge_remote_changes.conflict.nodelist", { user: { html: user(remote.user) } }));
35525             break;
35526           }
35527         }
35528       }
35529       return _conflicts.length === ccount ? target.update({ nodes }) : target;
35530     }
35531     function mergeChildren(targetWay, children2, updates, graph) {
35532       function isUsed(node2, targetWay2) {
35533         var hasInterestingParent = graph.parentWays(node2).some(function(way) {
35534           return way.id !== targetWay2.id;
35535         });
35536         return node2.hasInterestingTags() || hasInterestingParent || graph.parentRelations(node2).length > 0;
35537       }
35538       var ccount = _conflicts.length;
35539       for (var i3 = 0; i3 < children2.length; i3++) {
35540         var id3 = children2[i3];
35541         var node = graph.hasEntity(id3);
35542         if (targetWay.nodes.indexOf(id3) === -1) {
35543           if (node && !isUsed(node, targetWay)) {
35544             updates.removeIds.push(id3);
35545           }
35546           continue;
35547         }
35548         var local = localGraph.hasEntity(id3);
35549         var remote = remoteGraph.hasEntity(id3);
35550         var target;
35551         if (_option === "force_remote" && remote && remote.visible) {
35552           updates.replacements.push(remote);
35553         } else if (_option === "force_local" && local) {
35554           target = osmEntity(local);
35555           if (remote) {
35556             target = target.update({ version: remote.version });
35557           }
35558           updates.replacements.push(target);
35559         } else if (_option === "safe" && local && remote && local.version !== remote.version) {
35560           target = osmEntity(local, { version: remote.version });
35561           if (remote.visible) {
35562             target = mergeLocation(remote, target);
35563           } else {
35564             _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
35565           }
35566           if (_conflicts.length !== ccount)
35567             break;
35568           updates.replacements.push(target);
35569         }
35570       }
35571       return targetWay;
35572     }
35573     function updateChildren(updates, graph) {
35574       for (var i3 = 0; i3 < updates.replacements.length; i3++) {
35575         graph = graph.replace(updates.replacements[i3]);
35576       }
35577       if (updates.removeIds.length) {
35578         graph = actionDeleteMultiple(updates.removeIds)(graph);
35579       }
35580       return graph;
35581     }
35582     function mergeMembers(remote, target) {
35583       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.members, remote.members)) {
35584         return target;
35585       }
35586       if (_option === "force_remote") {
35587         return target.update({ members: remote.members });
35588       }
35589       _conflicts.push(_t.html("merge_remote_changes.conflict.memberlist", { user: { html: user(remote.user) } }));
35590       return target;
35591     }
35592     function mergeTags(base, remote, target) {
35593       if (_option === "force_local" || (0, import_fast_deep_equal.default)(target.tags, remote.tags)) {
35594         return target;
35595       }
35596       if (_option === "force_remote") {
35597         return target.update({ tags: remote.tags });
35598       }
35599       var ccount = _conflicts.length;
35600       var o2 = base.tags || {};
35601       var a2 = target.tags || {};
35602       var b2 = remote.tags || {};
35603       var keys2 = utilArrayUnion(utilArrayUnion(Object.keys(o2), Object.keys(a2)), Object.keys(b2)).filter(function(k3) {
35604         return !discardTags[k3];
35605       });
35606       var tags = Object.assign({}, a2);
35607       var changed = false;
35608       for (var i3 = 0; i3 < keys2.length; i3++) {
35609         var k2 = keys2[i3];
35610         if (o2[k2] !== b2[k2] && a2[k2] !== b2[k2]) {
35611           if (o2[k2] !== a2[k2]) {
35612             _conflicts.push(_t.html(
35613               "merge_remote_changes.conflict.tags",
35614               { tag: k2, local: a2[k2], remote: b2[k2], user: { html: user(remote.user) } }
35615             ));
35616           } else {
35617             if (b2.hasOwnProperty(k2)) {
35618               tags[k2] = b2[k2];
35619             } else {
35620               delete tags[k2];
35621             }
35622             changed = true;
35623           }
35624         }
35625       }
35626       return changed && _conflicts.length === ccount ? target.update({ tags }) : target;
35627     }
35628     var action = function(graph) {
35629       var updates = { replacements: [], removeIds: [] };
35630       var base = graph.base().entities[id2];
35631       var local = localGraph.entity(id2);
35632       var remote = remoteGraph.entity(id2);
35633       var target = osmEntity(local, { version: remote.version });
35634       if (!remote.visible) {
35635         if (_option === "force_remote") {
35636           return actionDeleteMultiple([id2])(graph);
35637         } else if (_option === "force_local") {
35638           if (target.type === "way") {
35639             target = mergeChildren(target, utilArrayUniq(local.nodes), updates, graph);
35640             graph = updateChildren(updates, graph);
35641           }
35642           return graph.replace(target);
35643         } else {
35644           _conflicts.push(_t.html("merge_remote_changes.conflict.deleted", { user: { html: user(remote.user) } }));
35645           return graph;
35646         }
35647       }
35648       if (target.type === "node") {
35649         target = mergeLocation(remote, target);
35650       } else if (target.type === "way") {
35651         graph.rebase(remoteGraph.childNodes(remote), [graph], false);
35652         target = mergeNodes(base, remote, target);
35653         target = mergeChildren(target, utilArrayUnion(local.nodes, remote.nodes), updates, graph);
35654       } else if (target.type === "relation") {
35655         target = mergeMembers(remote, target);
35656       }
35657       target = mergeTags(base, remote, target);
35658       if (!_conflicts.length) {
35659         graph = updateChildren(updates, graph).replace(target);
35660       }
35661       return graph;
35662     };
35663     action.withOption = function(opt) {
35664       _option = opt;
35665       return action;
35666     };
35667     action.conflicts = function() {
35668       return _conflicts;
35669     };
35670     return action;
35671   }
35672
35673   // modules/actions/move.js
35674   function actionMove(moveIDs, tryDelta, projection2, cache) {
35675     var _delta = tryDelta;
35676     function setupCache(graph) {
35677       function canMove(nodeID) {
35678         if (moveIDs.indexOf(nodeID) !== -1)
35679           return true;
35680         var parents = graph.parentWays(graph.entity(nodeID));
35681         if (parents.length < 3)
35682           return true;
35683         var parentsMoving = parents.every(function(way) {
35684           return cache.moving[way.id];
35685         });
35686         if (!parentsMoving)
35687           delete cache.moving[nodeID];
35688         return parentsMoving;
35689       }
35690       function cacheEntities(ids) {
35691         for (var i3 = 0; i3 < ids.length; i3++) {
35692           var id2 = ids[i3];
35693           if (cache.moving[id2])
35694             continue;
35695           cache.moving[id2] = true;
35696           var entity = graph.hasEntity(id2);
35697           if (!entity)
35698             continue;
35699           if (entity.type === "node") {
35700             cache.nodes.push(id2);
35701             cache.startLoc[id2] = entity.loc;
35702           } else if (entity.type === "way") {
35703             cache.ways.push(id2);
35704             cacheEntities(entity.nodes);
35705           } else {
35706             cacheEntities(entity.members.map(function(member) {
35707               return member.id;
35708             }));
35709           }
35710         }
35711       }
35712       function cacheIntersections(ids) {
35713         function isEndpoint(way2, id3) {
35714           return !way2.isClosed() && !!way2.affix(id3);
35715         }
35716         for (var i3 = 0; i3 < ids.length; i3++) {
35717           var id2 = ids[i3];
35718           var childNodes = graph.childNodes(graph.entity(id2));
35719           for (var j2 = 0; j2 < childNodes.length; j2++) {
35720             var node = childNodes[j2];
35721             var parents = graph.parentWays(node);
35722             if (parents.length !== 2)
35723               continue;
35724             var moved = graph.entity(id2);
35725             var unmoved = null;
35726             for (var k2 = 0; k2 < parents.length; k2++) {
35727               var way = parents[k2];
35728               if (!cache.moving[way.id]) {
35729                 unmoved = way;
35730                 break;
35731               }
35732             }
35733             if (!unmoved)
35734               continue;
35735             if (utilArrayIntersection(moved.nodes, unmoved.nodes).length > 2)
35736               continue;
35737             if (moved.isArea() || unmoved.isArea())
35738               continue;
35739             cache.intersections.push({
35740               nodeId: node.id,
35741               movedId: moved.id,
35742               unmovedId: unmoved.id,
35743               movedIsEP: isEndpoint(moved, node.id),
35744               unmovedIsEP: isEndpoint(unmoved, node.id)
35745             });
35746           }
35747         }
35748       }
35749       if (!cache) {
35750         cache = {};
35751       }
35752       if (!cache.ok) {
35753         cache.moving = {};
35754         cache.intersections = [];
35755         cache.replacedVertex = {};
35756         cache.startLoc = {};
35757         cache.nodes = [];
35758         cache.ways = [];
35759         cacheEntities(moveIDs);
35760         cacheIntersections(cache.ways);
35761         cache.nodes = cache.nodes.filter(canMove);
35762         cache.ok = true;
35763       }
35764     }
35765     function replaceMovedVertex(nodeId, wayId, graph, delta) {
35766       var way = graph.entity(wayId);
35767       var moved = graph.entity(nodeId);
35768       var movedIndex = way.nodes.indexOf(nodeId);
35769       var len, prevIndex, nextIndex;
35770       if (way.isClosed()) {
35771         len = way.nodes.length - 1;
35772         prevIndex = (movedIndex + len - 1) % len;
35773         nextIndex = (movedIndex + len + 1) % len;
35774       } else {
35775         len = way.nodes.length;
35776         prevIndex = movedIndex - 1;
35777         nextIndex = movedIndex + 1;
35778       }
35779       var prev = graph.hasEntity(way.nodes[prevIndex]);
35780       var next = graph.hasEntity(way.nodes[nextIndex]);
35781       if (!prev || !next)
35782         return graph;
35783       var key = wayId + "_" + nodeId;
35784       var orig = cache.replacedVertex[key];
35785       if (!orig) {
35786         orig = osmNode();
35787         cache.replacedVertex[key] = orig;
35788         cache.startLoc[orig.id] = cache.startLoc[nodeId];
35789       }
35790       var start2, end;
35791       if (delta) {
35792         start2 = projection2(cache.startLoc[nodeId]);
35793         end = projection2.invert(geoVecAdd(start2, delta));
35794       } else {
35795         end = cache.startLoc[nodeId];
35796       }
35797       orig = orig.move(end);
35798       var angle2 = Math.abs(geoAngle(orig, prev, projection2) - geoAngle(orig, next, projection2)) * 180 / Math.PI;
35799       if (angle2 > 175 && angle2 < 185)
35800         return graph;
35801       var p1 = [prev.loc, orig.loc, moved.loc, next.loc].map(projection2);
35802       var p2 = [prev.loc, moved.loc, orig.loc, next.loc].map(projection2);
35803       var d1 = geoPathLength(p1);
35804       var d2 = geoPathLength(p2);
35805       var insertAt = d1 <= d2 ? movedIndex : nextIndex;
35806       if (way.isClosed() && insertAt === 0)
35807         insertAt = len;
35808       way = way.addNode(orig.id, insertAt);
35809       return graph.replace(orig).replace(way);
35810     }
35811     function removeDuplicateVertices(wayId, graph) {
35812       var way = graph.entity(wayId);
35813       var epsilon3 = 1e-6;
35814       var prev, curr;
35815       function isInteresting(node, graph2) {
35816         return graph2.parentWays(node).length > 1 || graph2.parentRelations(node).length || node.hasInterestingTags();
35817       }
35818       for (var i3 = 0; i3 < way.nodes.length; i3++) {
35819         curr = graph.entity(way.nodes[i3]);
35820         if (prev && curr && geoVecEqual(prev.loc, curr.loc, epsilon3)) {
35821           if (!isInteresting(prev, graph)) {
35822             way = way.removeNode(prev.id);
35823             graph = graph.replace(way).remove(prev);
35824           } else if (!isInteresting(curr, graph)) {
35825             way = way.removeNode(curr.id);
35826             graph = graph.replace(way).remove(curr);
35827           }
35828         }
35829         prev = curr;
35830       }
35831       return graph;
35832     }
35833     function unZorroIntersection(intersection2, graph) {
35834       var vertex = graph.entity(intersection2.nodeId);
35835       var way1 = graph.entity(intersection2.movedId);
35836       var way2 = graph.entity(intersection2.unmovedId);
35837       var isEP1 = intersection2.movedIsEP;
35838       var isEP2 = intersection2.unmovedIsEP;
35839       if (isEP1 && isEP2)
35840         return graph;
35841       var nodes1 = graph.childNodes(way1).filter(function(n3) {
35842         return n3 !== vertex;
35843       });
35844       var nodes2 = graph.childNodes(way2).filter(function(n3) {
35845         return n3 !== vertex;
35846       });
35847       if (way1.isClosed() && way1.first() === vertex.id)
35848         nodes1.push(nodes1[0]);
35849       if (way2.isClosed() && way2.first() === vertex.id)
35850         nodes2.push(nodes2[0]);
35851       var edge1 = !isEP1 && geoChooseEdge(nodes1, projection2(vertex.loc), projection2);
35852       var edge2 = !isEP2 && geoChooseEdge(nodes2, projection2(vertex.loc), projection2);
35853       var loc;
35854       if (!isEP1 && !isEP2) {
35855         var epsilon3 = 1e-6, maxIter = 10;
35856         for (var i3 = 0; i3 < maxIter; i3++) {
35857           loc = geoVecInterp(edge1.loc, edge2.loc, 0.5);
35858           edge1 = geoChooseEdge(nodes1, projection2(loc), projection2);
35859           edge2 = geoChooseEdge(nodes2, projection2(loc), projection2);
35860           if (Math.abs(edge1.distance - edge2.distance) < epsilon3)
35861             break;
35862         }
35863       } else if (!isEP1) {
35864         loc = edge1.loc;
35865       } else {
35866         loc = edge2.loc;
35867       }
35868       graph = graph.replace(vertex.move(loc));
35869       if (!isEP1 && edge1.index !== way1.nodes.indexOf(vertex.id)) {
35870         way1 = way1.removeNode(vertex.id).addNode(vertex.id, edge1.index);
35871         graph = graph.replace(way1);
35872       }
35873       if (!isEP2 && edge2.index !== way2.nodes.indexOf(vertex.id)) {
35874         way2 = way2.removeNode(vertex.id).addNode(vertex.id, edge2.index);
35875         graph = graph.replace(way2);
35876       }
35877       return graph;
35878     }
35879     function cleanupIntersections(graph) {
35880       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
35881         var obj = cache.intersections[i3];
35882         graph = replaceMovedVertex(obj.nodeId, obj.movedId, graph, _delta);
35883         graph = replaceMovedVertex(obj.nodeId, obj.unmovedId, graph, null);
35884         graph = unZorroIntersection(obj, graph);
35885         graph = removeDuplicateVertices(obj.movedId, graph);
35886         graph = removeDuplicateVertices(obj.unmovedId, graph);
35887       }
35888       return graph;
35889     }
35890     function limitDelta(graph) {
35891       function moveNode(loc) {
35892         return geoVecAdd(projection2(loc), _delta);
35893       }
35894       for (var i3 = 0; i3 < cache.intersections.length; i3++) {
35895         var obj = cache.intersections[i3];
35896         if (obj.movedIsEP && obj.unmovedIsEP)
35897           continue;
35898         if (!obj.movedIsEP)
35899           continue;
35900         var node = graph.entity(obj.nodeId);
35901         var start2 = projection2(node.loc);
35902         var end = geoVecAdd(start2, _delta);
35903         var movedNodes = graph.childNodes(graph.entity(obj.movedId));
35904         var movedPath = movedNodes.map(function(n3) {
35905           return moveNode(n3.loc);
35906         });
35907         var unmovedNodes = graph.childNodes(graph.entity(obj.unmovedId));
35908         var unmovedPath = unmovedNodes.map(function(n3) {
35909           return projection2(n3.loc);
35910         });
35911         var hits = geoPathIntersections(movedPath, unmovedPath);
35912         for (var j2 = 0; i3 < hits.length; i3++) {
35913           if (geoVecEqual(hits[j2], end))
35914             continue;
35915           var edge = geoChooseEdge(unmovedNodes, end, projection2);
35916           _delta = geoVecSubtract(projection2(edge.loc), start2);
35917         }
35918       }
35919     }
35920     var action = function(graph) {
35921       if (_delta[0] === 0 && _delta[1] === 0)
35922         return graph;
35923       setupCache(graph);
35924       if (cache.intersections.length) {
35925         limitDelta(graph);
35926       }
35927       for (var i3 = 0; i3 < cache.nodes.length; i3++) {
35928         var node = graph.entity(cache.nodes[i3]);
35929         var start2 = projection2(node.loc);
35930         var end = geoVecAdd(start2, _delta);
35931         graph = graph.replace(node.move(projection2.invert(end)));
35932       }
35933       if (cache.intersections.length) {
35934         graph = cleanupIntersections(graph);
35935       }
35936       return graph;
35937     };
35938     action.delta = function() {
35939       return _delta;
35940     };
35941     return action;
35942   }
35943
35944   // modules/actions/move_member.js
35945   function actionMoveMember(relationId, fromIndex, toIndex) {
35946     return function(graph) {
35947       return graph.replace(graph.entity(relationId).moveMember(fromIndex, toIndex));
35948     };
35949   }
35950
35951   // modules/actions/move_node.js
35952   function actionMoveNode(nodeID, toLoc) {
35953     var action = function(graph, t2) {
35954       if (t2 === null || !isFinite(t2))
35955         t2 = 1;
35956       t2 = Math.min(Math.max(+t2, 0), 1);
35957       var node = graph.entity(nodeID);
35958       return graph.replace(
35959         node.move(geoVecInterp(node.loc, toLoc, t2))
35960       );
35961     };
35962     action.transitionable = true;
35963     return action;
35964   }
35965
35966   // modules/actions/noop.js
35967   function actionNoop() {
35968     return function(graph) {
35969       return graph;
35970     };
35971   }
35972
35973   // modules/actions/orthogonalize.js
35974   function actionOrthogonalize(wayID, projection2, vertexID, degThresh, ep) {
35975     var epsilon3 = ep || 1e-4;
35976     var threshold = degThresh || 13;
35977     var lowerThreshold = Math.cos((90 - threshold) * Math.PI / 180);
35978     var upperThreshold = Math.cos(threshold * Math.PI / 180);
35979     var action = function(graph, t2) {
35980       if (t2 === null || !isFinite(t2))
35981         t2 = 1;
35982       t2 = Math.min(Math.max(+t2, 0), 1);
35983       var way = graph.entity(wayID);
35984       way = way.removeNode("");
35985       if (way.tags.nonsquare) {
35986         var tags = Object.assign({}, way.tags);
35987         delete tags.nonsquare;
35988         way = way.update({ tags });
35989       }
35990       graph = graph.replace(way);
35991       var isClosed = way.isClosed();
35992       var nodes = graph.childNodes(way).slice();
35993       if (isClosed)
35994         nodes.pop();
35995       if (vertexID !== void 0) {
35996         nodes = nodeSubset(nodes, vertexID, isClosed);
35997         if (nodes.length !== 3)
35998           return graph;
35999       }
36000       var nodeCount = {};
36001       var points = [];
36002       var corner = { i: 0, dotp: 1 };
36003       var node, point2, loc, score, motions, i3, j2;
36004       for (i3 = 0; i3 < nodes.length; i3++) {
36005         node = nodes[i3];
36006         nodeCount[node.id] = (nodeCount[node.id] || 0) + 1;
36007         points.push({ id: node.id, coord: projection2(node.loc) });
36008       }
36009       if (points.length === 3) {
36010         for (i3 = 0; i3 < 1e3; i3++) {
36011           motions = points.map(calcMotion);
36012           points[corner.i].coord = geoVecAdd(points[corner.i].coord, motions[corner.i]);
36013           score = corner.dotp;
36014           if (score < epsilon3) {
36015             break;
36016           }
36017         }
36018         node = graph.entity(nodes[corner.i].id);
36019         loc = projection2.invert(points[corner.i].coord);
36020         graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
36021       } else {
36022         var straights = [];
36023         var simplified = [];
36024         for (i3 = 0; i3 < points.length; i3++) {
36025           point2 = points[i3];
36026           var dotp = 0;
36027           if (isClosed || i3 > 0 && i3 < points.length - 1) {
36028             var a2 = points[(i3 - 1 + points.length) % points.length];
36029             var b2 = points[(i3 + 1) % points.length];
36030             dotp = Math.abs(geoOrthoNormalizedDotProduct(a2.coord, b2.coord, point2.coord));
36031           }
36032           if (dotp > upperThreshold) {
36033             straights.push(point2);
36034           } else {
36035             simplified.push(point2);
36036           }
36037         }
36038         var bestPoints = clonePoints(simplified);
36039         var originalPoints = clonePoints(simplified);
36040         score = Infinity;
36041         for (i3 = 0; i3 < 1e3; i3++) {
36042           motions = simplified.map(calcMotion);
36043           for (j2 = 0; j2 < motions.length; j2++) {
36044             simplified[j2].coord = geoVecAdd(simplified[j2].coord, motions[j2]);
36045           }
36046           var newScore = geoOrthoCalcScore(simplified, isClosed, epsilon3, threshold);
36047           if (newScore < score) {
36048             bestPoints = clonePoints(simplified);
36049             score = newScore;
36050           }
36051           if (score < epsilon3) {
36052             break;
36053           }
36054         }
36055         var bestCoords = bestPoints.map(function(p2) {
36056           return p2.coord;
36057         });
36058         if (isClosed)
36059           bestCoords.push(bestCoords[0]);
36060         for (i3 = 0; i3 < bestPoints.length; i3++) {
36061           point2 = bestPoints[i3];
36062           if (!geoVecEqual(originalPoints[i3].coord, point2.coord)) {
36063             node = graph.entity(point2.id);
36064             loc = projection2.invert(point2.coord);
36065             graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
36066           }
36067         }
36068         for (i3 = 0; i3 < straights.length; i3++) {
36069           point2 = straights[i3];
36070           if (nodeCount[point2.id] > 1)
36071             continue;
36072           node = graph.entity(point2.id);
36073           if (t2 === 1 && graph.parentWays(node).length === 1 && graph.parentRelations(node).length === 0 && !node.hasInterestingTags()) {
36074             graph = actionDeleteNode(node.id)(graph);
36075           } else {
36076             var choice = geoVecProject(point2.coord, bestCoords);
36077             if (choice) {
36078               loc = projection2.invert(choice.target);
36079               graph = graph.replace(node.move(geoVecInterp(node.loc, loc, t2)));
36080             }
36081           }
36082         }
36083       }
36084       return graph;
36085       function clonePoints(array2) {
36086         return array2.map(function(p2) {
36087           return { id: p2.id, coord: [p2.coord[0], p2.coord[1]] };
36088         });
36089       }
36090       function calcMotion(point3, i4, array2) {
36091         if (!isClosed && (i4 === 0 || i4 === array2.length - 1))
36092           return [0, 0];
36093         if (nodeCount[array2[i4].id] > 1)
36094           return [0, 0];
36095         var a3 = array2[(i4 - 1 + array2.length) % array2.length].coord;
36096         var origin = point3.coord;
36097         var b3 = array2[(i4 + 1) % array2.length].coord;
36098         var p2 = geoVecSubtract(a3, origin);
36099         var q2 = geoVecSubtract(b3, origin);
36100         var scale = 2 * Math.min(geoVecLength(p2), geoVecLength(q2));
36101         p2 = geoVecNormalize(p2);
36102         q2 = geoVecNormalize(q2);
36103         var dotp2 = p2[0] * q2[0] + p2[1] * q2[1];
36104         var val = Math.abs(dotp2);
36105         if (val < lowerThreshold) {
36106           corner.i = i4;
36107           corner.dotp = val;
36108           var vec = geoVecNormalize(geoVecAdd(p2, q2));
36109           return geoVecScale(vec, 0.1 * dotp2 * scale);
36110         }
36111         return [0, 0];
36112       }
36113     };
36114     function nodeSubset(nodes, vertexID2, isClosed) {
36115       var first = isClosed ? 0 : 1;
36116       var last = isClosed ? nodes.length : nodes.length - 1;
36117       for (var i3 = first; i3 < last; i3++) {
36118         if (nodes[i3].id === vertexID2) {
36119           return [
36120             nodes[(i3 - 1 + nodes.length) % nodes.length],
36121             nodes[i3],
36122             nodes[(i3 + 1) % nodes.length]
36123           ];
36124         }
36125       }
36126       return [];
36127     }
36128     action.disabled = function(graph) {
36129       var way = graph.entity(wayID);
36130       way = way.removeNode("");
36131       graph = graph.replace(way);
36132       var isClosed = way.isClosed();
36133       var nodes = graph.childNodes(way).slice();
36134       if (isClosed)
36135         nodes.pop();
36136       var allowStraightAngles = false;
36137       if (vertexID !== void 0) {
36138         allowStraightAngles = true;
36139         nodes = nodeSubset(nodes, vertexID, isClosed);
36140         if (nodes.length !== 3)
36141           return "end_vertex";
36142       }
36143       var coords = nodes.map(function(n3) {
36144         return projection2(n3.loc);
36145       });
36146       var score = geoOrthoCanOrthogonalize(coords, isClosed, epsilon3, threshold, allowStraightAngles);
36147       if (score === null) {
36148         return "not_squarish";
36149       } else if (score === 0) {
36150         return "square_enough";
36151       } else {
36152         return false;
36153       }
36154     };
36155     action.transitionable = true;
36156     return action;
36157   }
36158
36159   // modules/actions/restrict_turn.js
36160   function actionRestrictTurn(turn, restrictionType, restrictionID) {
36161     return function(graph) {
36162       var fromWay = graph.entity(turn.from.way);
36163       var toWay = graph.entity(turn.to.way);
36164       var viaNode = turn.via.node && graph.entity(turn.via.node);
36165       var viaWays = turn.via.ways && turn.via.ways.map(function(id2) {
36166         return graph.entity(id2);
36167       });
36168       var members = [];
36169       members.push({ id: fromWay.id, type: "way", role: "from" });
36170       if (viaNode) {
36171         members.push({ id: viaNode.id, type: "node", role: "via" });
36172       } else if (viaWays) {
36173         viaWays.forEach(function(viaWay) {
36174           members.push({ id: viaWay.id, type: "way", role: "via" });
36175         });
36176       }
36177       members.push({ id: toWay.id, type: "way", role: "to" });
36178       return graph.replace(osmRelation({
36179         id: restrictionID,
36180         tags: {
36181           type: "restriction",
36182           restriction: restrictionType
36183         },
36184         members
36185       }));
36186     };
36187   }
36188
36189   // modules/actions/revert.js
36190   function actionRevert(id2) {
36191     var action = function(graph) {
36192       var entity = graph.hasEntity(id2), base = graph.base().entities[id2];
36193       if (entity && !base) {
36194         if (entity.type === "node") {
36195           graph.parentWays(entity).forEach(function(parent) {
36196             parent = parent.removeNode(id2);
36197             graph = graph.replace(parent);
36198             if (parent.isDegenerate()) {
36199               graph = actionDeleteWay(parent.id)(graph);
36200             }
36201           });
36202         }
36203         graph.parentRelations(entity).forEach(function(parent) {
36204           parent = parent.removeMembersWithID(id2);
36205           graph = graph.replace(parent);
36206           if (parent.isDegenerate()) {
36207             graph = actionDeleteRelation(parent.id)(graph);
36208           }
36209         });
36210       }
36211       return graph.revert(id2);
36212     };
36213     return action;
36214   }
36215
36216   // modules/actions/rotate.js
36217   function actionRotate(rotateIds, pivot, angle2, projection2) {
36218     var action = function(graph) {
36219       return graph.update(function(graph2) {
36220         utilGetAllNodes(rotateIds, graph2).forEach(function(node) {
36221           var point2 = geoRotate([projection2(node.loc)], angle2, pivot)[0];
36222           graph2 = graph2.replace(node.move(projection2.invert(point2)));
36223         });
36224       });
36225     };
36226     return action;
36227   }
36228
36229   // modules/actions/scale.js
36230   function actionScale(ids, pivotLoc, scaleFactor, projection2) {
36231     return function(graph) {
36232       return graph.update(function(graph2) {
36233         let point2, radial;
36234         utilGetAllNodes(ids, graph2).forEach(function(node) {
36235           point2 = projection2(node.loc);
36236           radial = [
36237             point2[0] - pivotLoc[0],
36238             point2[1] - pivotLoc[1]
36239           ];
36240           point2 = [
36241             pivotLoc[0] + scaleFactor * radial[0],
36242             pivotLoc[1] + scaleFactor * radial[1]
36243           ];
36244           graph2 = graph2.replace(node.move(projection2.invert(point2)));
36245         });
36246       });
36247     };
36248   }
36249
36250   // modules/actions/straighten_nodes.js
36251   function actionStraightenNodes(nodeIDs, projection2) {
36252     function positionAlongWay(a2, o2, b2) {
36253       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
36254     }
36255     function getEndpoints(points) {
36256       var ssr = geoGetSmallestSurroundingRectangle(points);
36257       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
36258       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
36259       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
36260       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
36261       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
36262       if (isLong) {
36263         return [p1, q1];
36264       }
36265       return [p2, q2];
36266     }
36267     var action = function(graph, t2) {
36268       if (t2 === null || !isFinite(t2))
36269         t2 = 1;
36270       t2 = Math.min(Math.max(+t2, 0), 1);
36271       var nodes = nodeIDs.map(function(id2) {
36272         return graph.entity(id2);
36273       });
36274       var points = nodes.map(function(n3) {
36275         return projection2(n3.loc);
36276       });
36277       var endpoints = getEndpoints(points);
36278       var startPoint = endpoints[0];
36279       var endPoint = endpoints[1];
36280       for (var i3 = 0; i3 < points.length; i3++) {
36281         var node = nodes[i3];
36282         var point2 = points[i3];
36283         var u2 = positionAlongWay(point2, startPoint, endPoint);
36284         var point22 = geoVecInterp(startPoint, endPoint, u2);
36285         var loc2 = projection2.invert(point22);
36286         graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
36287       }
36288       return graph;
36289     };
36290     action.disabled = function(graph) {
36291       var nodes = nodeIDs.map(function(id2) {
36292         return graph.entity(id2);
36293       });
36294       var points = nodes.map(function(n3) {
36295         return projection2(n3.loc);
36296       });
36297       var endpoints = getEndpoints(points);
36298       var startPoint = endpoints[0];
36299       var endPoint = endpoints[1];
36300       var maxDistance = 0;
36301       for (var i3 = 0; i3 < points.length; i3++) {
36302         var point2 = points[i3];
36303         var u2 = positionAlongWay(point2, startPoint, endPoint);
36304         var p2 = geoVecInterp(startPoint, endPoint, u2);
36305         var dist = geoVecLength(p2, point2);
36306         if (!isNaN(dist) && dist > maxDistance) {
36307           maxDistance = dist;
36308         }
36309       }
36310       if (maxDistance < 1e-4) {
36311         return "straight_enough";
36312       }
36313     };
36314     action.transitionable = true;
36315     return action;
36316   }
36317
36318   // modules/actions/straighten_way.js
36319   function actionStraightenWay(selectedIDs, projection2) {
36320     function positionAlongWay(a2, o2, b2) {
36321       return geoVecDot(a2, b2, o2) / geoVecDot(b2, b2, o2);
36322     }
36323     function allNodes(graph) {
36324       var nodes = [];
36325       var startNodes = [];
36326       var endNodes = [];
36327       var remainingWays = [];
36328       var selectedWays = selectedIDs.filter(function(w2) {
36329         return graph.entity(w2).type === "way";
36330       });
36331       var selectedNodes = selectedIDs.filter(function(n3) {
36332         return graph.entity(n3).type === "node";
36333       });
36334       for (var i3 = 0; i3 < selectedWays.length; i3++) {
36335         var way = graph.entity(selectedWays[i3]);
36336         nodes = way.nodes.slice(0);
36337         remainingWays.push(nodes);
36338         startNodes.push(nodes[0]);
36339         endNodes.push(nodes[nodes.length - 1]);
36340       }
36341       startNodes = startNodes.filter(function(n3) {
36342         return startNodes.indexOf(n3) === startNodes.lastIndexOf(n3);
36343       });
36344       endNodes = endNodes.filter(function(n3) {
36345         return endNodes.indexOf(n3) === endNodes.lastIndexOf(n3);
36346       });
36347       var currNode = utilArrayDifference(startNodes, endNodes).concat(utilArrayDifference(endNodes, startNodes))[0];
36348       var nextWay = [];
36349       nodes = [];
36350       var getNextWay = function(currNode2, remainingWays2) {
36351         return remainingWays2.filter(function(way2) {
36352           return way2[0] === currNode2 || way2[way2.length - 1] === currNode2;
36353         })[0];
36354       };
36355       while (remainingWays.length) {
36356         nextWay = getNextWay(currNode, remainingWays);
36357         remainingWays = utilArrayDifference(remainingWays, [nextWay]);
36358         if (nextWay[0] !== currNode) {
36359           nextWay.reverse();
36360         }
36361         nodes = nodes.concat(nextWay);
36362         currNode = nodes[nodes.length - 1];
36363       }
36364       if (selectedNodes.length === 2) {
36365         var startNodeIdx = nodes.indexOf(selectedNodes[0]);
36366         var endNodeIdx = nodes.indexOf(selectedNodes[1]);
36367         var sortedStartEnd = [startNodeIdx, endNodeIdx];
36368         sortedStartEnd.sort(function(a2, b2) {
36369           return a2 - b2;
36370         });
36371         nodes = nodes.slice(sortedStartEnd[0], sortedStartEnd[1] + 1);
36372       }
36373       return nodes.map(function(n3) {
36374         return graph.entity(n3);
36375       });
36376     }
36377     function shouldKeepNode(node, graph) {
36378       return graph.parentWays(node).length > 1 || graph.parentRelations(node).length || node.hasInterestingTags();
36379     }
36380     var action = function(graph, t2) {
36381       if (t2 === null || !isFinite(t2))
36382         t2 = 1;
36383       t2 = Math.min(Math.max(+t2, 0), 1);
36384       var nodes = allNodes(graph);
36385       var points = nodes.map(function(n3) {
36386         return projection2(n3.loc);
36387       });
36388       var startPoint = points[0];
36389       var endPoint = points[points.length - 1];
36390       var toDelete = [];
36391       var i3;
36392       for (i3 = 1; i3 < points.length - 1; i3++) {
36393         var node = nodes[i3];
36394         var point2 = points[i3];
36395         if (t2 < 1 || shouldKeepNode(node, graph)) {
36396           var u2 = positionAlongWay(point2, startPoint, endPoint);
36397           var p2 = geoVecInterp(startPoint, endPoint, u2);
36398           var loc2 = projection2.invert(p2);
36399           graph = graph.replace(node.move(geoVecInterp(node.loc, loc2, t2)));
36400         } else {
36401           if (toDelete.indexOf(node) === -1) {
36402             toDelete.push(node);
36403           }
36404         }
36405       }
36406       for (i3 = 0; i3 < toDelete.length; i3++) {
36407         graph = actionDeleteNode(toDelete[i3].id)(graph);
36408       }
36409       return graph;
36410     };
36411     action.disabled = function(graph) {
36412       var nodes = allNodes(graph);
36413       var points = nodes.map(function(n3) {
36414         return projection2(n3.loc);
36415       });
36416       var startPoint = points[0];
36417       var endPoint = points[points.length - 1];
36418       var threshold = 0.2 * geoVecLength(startPoint, endPoint);
36419       var i3;
36420       if (threshold === 0) {
36421         return "too_bendy";
36422       }
36423       var maxDistance = 0;
36424       for (i3 = 1; i3 < points.length - 1; i3++) {
36425         var point2 = points[i3];
36426         var u2 = positionAlongWay(point2, startPoint, endPoint);
36427         var p2 = geoVecInterp(startPoint, endPoint, u2);
36428         var dist = geoVecLength(p2, point2);
36429         if (isNaN(dist) || dist > threshold) {
36430           return "too_bendy";
36431         } else if (dist > maxDistance) {
36432           maxDistance = dist;
36433         }
36434       }
36435       var keepingAllNodes = nodes.every(function(node, i4) {
36436         return i4 === 0 || i4 === nodes.length - 1 || shouldKeepNode(node, graph);
36437       });
36438       if (maxDistance < 1e-4 && // Allow straightening even if already straight in order to remove extraneous nodes
36439       keepingAllNodes) {
36440         return "straight_enough";
36441       }
36442     };
36443     action.transitionable = true;
36444     return action;
36445   }
36446
36447   // modules/actions/unrestrict_turn.js
36448   function actionUnrestrictTurn(turn) {
36449     return function(graph) {
36450       return actionDeleteRelation(turn.restrictionID)(graph);
36451     };
36452   }
36453
36454   // modules/actions/reflect.js
36455   function actionReflect(reflectIds, projection2) {
36456     var _useLongAxis = true;
36457     var action = function(graph, t2) {
36458       if (t2 === null || !isFinite(t2))
36459         t2 = 1;
36460       t2 = Math.min(Math.max(+t2, 0), 1);
36461       var nodes = utilGetAllNodes(reflectIds, graph);
36462       var points = nodes.map(function(n3) {
36463         return projection2(n3.loc);
36464       });
36465       var ssr = geoGetSmallestSurroundingRectangle(points);
36466       var p1 = [(ssr.poly[0][0] + ssr.poly[1][0]) / 2, (ssr.poly[0][1] + ssr.poly[1][1]) / 2];
36467       var q1 = [(ssr.poly[2][0] + ssr.poly[3][0]) / 2, (ssr.poly[2][1] + ssr.poly[3][1]) / 2];
36468       var p2 = [(ssr.poly[3][0] + ssr.poly[4][0]) / 2, (ssr.poly[3][1] + ssr.poly[4][1]) / 2];
36469       var q2 = [(ssr.poly[1][0] + ssr.poly[2][0]) / 2, (ssr.poly[1][1] + ssr.poly[2][1]) / 2];
36470       var p3, q3;
36471       var isLong = geoVecLength(p1, q1) > geoVecLength(p2, q2);
36472       if (_useLongAxis && isLong || !_useLongAxis && !isLong) {
36473         p3 = p1;
36474         q3 = q1;
36475       } else {
36476         p3 = p2;
36477         q3 = q2;
36478       }
36479       var dx = q3[0] - p3[0];
36480       var dy = q3[1] - p3[1];
36481       var a2 = (dx * dx - dy * dy) / (dx * dx + dy * dy);
36482       var b2 = 2 * dx * dy / (dx * dx + dy * dy);
36483       for (var i3 = 0; i3 < nodes.length; i3++) {
36484         var node = nodes[i3];
36485         var c2 = projection2(node.loc);
36486         var c22 = [
36487           a2 * (c2[0] - p3[0]) + b2 * (c2[1] - p3[1]) + p3[0],
36488           b2 * (c2[0] - p3[0]) - a2 * (c2[1] - p3[1]) + p3[1]
36489         ];
36490         var loc2 = projection2.invert(c22);
36491         node = node.move(geoVecInterp(node.loc, loc2, t2));
36492         graph = graph.replace(node);
36493       }
36494       return graph;
36495     };
36496     action.useLongAxis = function(val) {
36497       if (!arguments.length)
36498         return _useLongAxis;
36499       _useLongAxis = val;
36500       return action;
36501     };
36502     action.transitionable = true;
36503     return action;
36504   }
36505
36506   // modules/actions/upgrade_tags.js
36507   function actionUpgradeTags(entityId, oldTags, replaceTags) {
36508     return function(graph) {
36509       var entity = graph.entity(entityId);
36510       var tags = Object.assign({}, entity.tags);
36511       var transferValue;
36512       var semiIndex;
36513       for (var oldTagKey in oldTags) {
36514         if (!(oldTagKey in tags))
36515           continue;
36516         if (oldTags[oldTagKey] === "*") {
36517           transferValue = tags[oldTagKey];
36518           delete tags[oldTagKey];
36519         } else if (oldTags[oldTagKey] === tags[oldTagKey]) {
36520           delete tags[oldTagKey];
36521         } else {
36522           var vals = tags[oldTagKey].split(";").filter(Boolean);
36523           var oldIndex = vals.indexOf(oldTags[oldTagKey]);
36524           if (vals.length === 1 || oldIndex === -1) {
36525             delete tags[oldTagKey];
36526           } else {
36527             if (replaceTags && replaceTags[oldTagKey]) {
36528               semiIndex = oldIndex;
36529             }
36530             vals.splice(oldIndex, 1);
36531             tags[oldTagKey] = vals.join(";");
36532           }
36533         }
36534       }
36535       if (replaceTags) {
36536         for (var replaceKey in replaceTags) {
36537           var replaceValue = replaceTags[replaceKey];
36538           if (replaceValue === "*") {
36539             if (tags[replaceKey] && tags[replaceKey] !== "no") {
36540               continue;
36541             } else {
36542               tags[replaceKey] = "yes";
36543             }
36544           } else if (replaceValue === "$1") {
36545             tags[replaceKey] = transferValue;
36546           } else {
36547             if (tags[replaceKey] && oldTags[replaceKey] && semiIndex !== void 0) {
36548               var existingVals = tags[replaceKey].split(";").filter(Boolean);
36549               if (existingVals.indexOf(replaceValue) === -1) {
36550                 existingVals.splice(semiIndex, 0, replaceValue);
36551                 tags[replaceKey] = existingVals.join(";");
36552               }
36553             } else {
36554               tags[replaceKey] = replaceValue;
36555             }
36556           }
36557         }
36558       }
36559       return graph.replace(entity.update({ tags }));
36560     };
36561   }
36562
36563   // modules/behavior/edit.js
36564   function behaviorEdit(context) {
36565     function behavior() {
36566       context.map().minzoom(context.minEditableZoom());
36567     }
36568     behavior.off = function() {
36569       context.map().minzoom(0);
36570     };
36571     return behavior;
36572   }
36573
36574   // modules/behavior/hover.js
36575   function behaviorHover(context) {
36576     var dispatch14 = dispatch_default("hover");
36577     var _selection = select_default2(null);
36578     var _newNodeId = null;
36579     var _initialNodeID = null;
36580     var _altDisables;
36581     var _ignoreVertex;
36582     var _targets = [];
36583     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
36584     function keydown(d3_event) {
36585       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
36586         _selection.selectAll(".hover").classed("hover-suppressed", true).classed("hover", false);
36587         _selection.classed("hover-disabled", true);
36588         dispatch14.call("hover", this, null);
36589       }
36590     }
36591     function keyup(d3_event) {
36592       if (_altDisables && d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
36593         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false).classed("hover", true);
36594         _selection.classed("hover-disabled", false);
36595         dispatch14.call("hover", this, _targets);
36596       }
36597     }
36598     function behavior(selection2) {
36599       _selection = selection2;
36600       _targets = [];
36601       if (_initialNodeID) {
36602         _newNodeId = _initialNodeID;
36603         _initialNodeID = null;
36604       } else {
36605         _newNodeId = null;
36606       }
36607       _selection.on(_pointerPrefix + "over.hover", pointerover).on(_pointerPrefix + "out.hover", pointerout).on(_pointerPrefix + "down.hover", pointerover);
36608       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", pointerout, true).on("keydown.hover", keydown).on("keyup.hover", keyup);
36609       function eventTarget(d3_event) {
36610         var datum2 = d3_event.target && d3_event.target.__data__;
36611         if (typeof datum2 !== "object")
36612           return null;
36613         if (!(datum2 instanceof osmEntity) && datum2.properties && datum2.properties.entity instanceof osmEntity) {
36614           return datum2.properties.entity;
36615         }
36616         return datum2;
36617       }
36618       function pointerover(d3_event) {
36619         if (context.mode().id.indexOf("drag") === -1 && (!d3_event.pointerType || d3_event.pointerType === "mouse") && d3_event.buttons)
36620           return;
36621         var target = eventTarget(d3_event);
36622         if (target && _targets.indexOf(target) === -1) {
36623           _targets.push(target);
36624           updateHover(d3_event, _targets);
36625         }
36626       }
36627       function pointerout(d3_event) {
36628         var target = eventTarget(d3_event);
36629         var index = _targets.indexOf(target);
36630         if (index !== -1) {
36631           _targets.splice(index);
36632           updateHover(d3_event, _targets);
36633         }
36634       }
36635       function allowsVertex(d2) {
36636         return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
36637       }
36638       function modeAllowsHover(target) {
36639         var mode = context.mode();
36640         if (mode.id === "add-point") {
36641           return mode.preset.matchGeometry("vertex") || target.type !== "way" && target.geometry(context.graph()) !== "vertex";
36642         }
36643         return true;
36644       }
36645       function updateHover(d3_event, targets) {
36646         _selection.selectAll(".hover").classed("hover", false);
36647         _selection.selectAll(".hover-suppressed").classed("hover-suppressed", false);
36648         var mode = context.mode();
36649         if (!_newNodeId && (mode.id === "draw-line" || mode.id === "draw-area")) {
36650           var node = targets.find(function(target) {
36651             return target instanceof osmEntity && target.type === "node";
36652           });
36653           _newNodeId = node && node.id;
36654         }
36655         targets = targets.filter(function(datum3) {
36656           if (datum3 instanceof osmEntity) {
36657             return datum3.id !== _newNodeId && (datum3.type !== "node" || !_ignoreVertex || allowsVertex(datum3)) && modeAllowsHover(datum3);
36658           }
36659           return true;
36660         });
36661         var selector = "";
36662         for (var i3 in targets) {
36663           var datum2 = targets[i3];
36664           if (datum2.__featurehash__) {
36665             selector += ", .data" + datum2.__featurehash__;
36666           } else if (datum2 instanceof QAItem) {
36667             selector += ", ." + datum2.service + ".itemId-" + datum2.id;
36668           } else if (datum2 instanceof osmNote) {
36669             selector += ", .note-" + datum2.id;
36670           } else if (datum2 instanceof osmEntity) {
36671             selector += ", ." + datum2.id;
36672             if (datum2.type === "relation") {
36673               for (var j2 in datum2.members) {
36674                 selector += ", ." + datum2.members[j2].id;
36675               }
36676             }
36677           }
36678         }
36679         var suppressed = _altDisables && d3_event && d3_event.altKey;
36680         if (selector.trim().length) {
36681           selector = selector.slice(1);
36682           _selection.selectAll(selector).classed(suppressed ? "hover-suppressed" : "hover", true);
36683         }
36684         dispatch14.call("hover", this, !suppressed && targets);
36685       }
36686     }
36687     behavior.off = function(selection2) {
36688       selection2.selectAll(".hover").classed("hover", false);
36689       selection2.selectAll(".hover-suppressed").classed("hover-suppressed", false);
36690       selection2.classed("hover-disabled", false);
36691       selection2.on(_pointerPrefix + "over.hover", null).on(_pointerPrefix + "out.hover", null).on(_pointerPrefix + "down.hover", null);
36692       select_default2(window).on(_pointerPrefix + "up.hover pointercancel.hover", null, true).on("keydown.hover", null).on("keyup.hover", null);
36693     };
36694     behavior.altDisables = function(val) {
36695       if (!arguments.length)
36696         return _altDisables;
36697       _altDisables = val;
36698       return behavior;
36699     };
36700     behavior.ignoreVertex = function(val) {
36701       if (!arguments.length)
36702         return _ignoreVertex;
36703       _ignoreVertex = val;
36704       return behavior;
36705     };
36706     behavior.initialNodeID = function(nodeId) {
36707       _initialNodeID = nodeId;
36708       return behavior;
36709     };
36710     return utilRebind(behavior, dispatch14, "on");
36711   }
36712
36713   // modules/behavior/draw.js
36714   var _disableSpace = false;
36715   var _lastSpace = null;
36716   function behaviorDraw(context) {
36717     var dispatch14 = dispatch_default(
36718       "move",
36719       "down",
36720       "downcancel",
36721       "click",
36722       "clickWay",
36723       "clickNode",
36724       "undo",
36725       "cancel",
36726       "finish"
36727     );
36728     var keybinding = utilKeybinding("draw");
36729     var _hover = behaviorHover(context).altDisables(true).ignoreVertex(true).on("hover", context.ui().sidebar.hover);
36730     var _edit = behaviorEdit(context);
36731     var _closeTolerance = 4;
36732     var _tolerance = 12;
36733     var _mouseLeave = false;
36734     var _lastMouse = null;
36735     var _lastPointerUpEvent;
36736     var _downPointer;
36737     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
36738     function datum2(d3_event) {
36739       var mode = context.mode();
36740       var isNote = mode && mode.id.indexOf("note") !== -1;
36741       if (d3_event.altKey || isNote)
36742         return {};
36743       var element;
36744       if (d3_event.type === "keydown") {
36745         element = _lastMouse && _lastMouse.target;
36746       } else {
36747         element = d3_event.target;
36748       }
36749       var d2 = element.__data__;
36750       return d2 && d2.properties && d2.properties.target ? d2 : {};
36751     }
36752     function pointerdown(d3_event) {
36753       if (_downPointer)
36754         return;
36755       var pointerLocGetter = utilFastMouse(this);
36756       _downPointer = {
36757         id: d3_event.pointerId || "mouse",
36758         pointerLocGetter,
36759         downTime: +/* @__PURE__ */ new Date(),
36760         downLoc: pointerLocGetter(d3_event)
36761       };
36762       dispatch14.call("down", this, d3_event, datum2(d3_event));
36763     }
36764     function pointerup(d3_event) {
36765       if (!_downPointer || _downPointer.id !== (d3_event.pointerId || "mouse"))
36766         return;
36767       var downPointer = _downPointer;
36768       _downPointer = null;
36769       _lastPointerUpEvent = d3_event;
36770       if (downPointer.isCancelled)
36771         return;
36772       var t2 = +/* @__PURE__ */ new Date();
36773       var p2 = downPointer.pointerLocGetter(d3_event);
36774       var dist = geoVecLength(downPointer.downLoc, p2);
36775       if (dist < _closeTolerance || dist < _tolerance && t2 - downPointer.downTime < 500) {
36776         select_default2(window).on("click.draw-block", function() {
36777           d3_event.stopPropagation();
36778         }, true);
36779         context.map().dblclickZoomEnable(false);
36780         window.setTimeout(function() {
36781           context.map().dblclickZoomEnable(true);
36782           select_default2(window).on("click.draw-block", null);
36783         }, 500);
36784         click(d3_event, p2);
36785       }
36786     }
36787     function pointermove(d3_event) {
36788       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse") && !_downPointer.isCancelled) {
36789         var p2 = _downPointer.pointerLocGetter(d3_event);
36790         var dist = geoVecLength(_downPointer.downLoc, p2);
36791         if (dist >= _closeTolerance) {
36792           _downPointer.isCancelled = true;
36793           dispatch14.call("downcancel", this);
36794         }
36795       }
36796       if (d3_event.pointerType && d3_event.pointerType !== "mouse" || d3_event.buttons || _downPointer)
36797         return;
36798       if (_lastPointerUpEvent && _lastPointerUpEvent.pointerType !== "mouse" && d3_event.timeStamp - _lastPointerUpEvent.timeStamp < 100)
36799         return;
36800       _lastMouse = d3_event;
36801       dispatch14.call("move", this, d3_event, datum2(d3_event));
36802     }
36803     function pointercancel(d3_event) {
36804       if (_downPointer && _downPointer.id === (d3_event.pointerId || "mouse")) {
36805         if (!_downPointer.isCancelled) {
36806           dispatch14.call("downcancel", this);
36807         }
36808         _downPointer = null;
36809       }
36810     }
36811     function mouseenter() {
36812       _mouseLeave = false;
36813     }
36814     function mouseleave() {
36815       _mouseLeave = true;
36816     }
36817     function allowsVertex(d2) {
36818       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
36819     }
36820     function click(d3_event, loc) {
36821       var d2 = datum2(d3_event);
36822       var target = d2 && d2.properties && d2.properties.entity;
36823       var mode = context.mode();
36824       if (target && target.type === "node" && allowsVertex(target)) {
36825         dispatch14.call("clickNode", this, target, d2);
36826         return;
36827       } else if (target && target.type === "way" && (mode.id !== "add-point" || mode.preset.matchGeometry("vertex"))) {
36828         var choice = geoChooseEdge(
36829           context.graph().childNodes(target),
36830           loc,
36831           context.projection,
36832           context.activeID()
36833         );
36834         if (choice) {
36835           var edge = [target.nodes[choice.index - 1], target.nodes[choice.index]];
36836           dispatch14.call("clickWay", this, choice.loc, edge, d2);
36837           return;
36838         }
36839       } else if (mode.id !== "add-point" || mode.preset.matchGeometry("point")) {
36840         var locLatLng = context.projection.invert(loc);
36841         dispatch14.call("click", this, locLatLng, d2);
36842       }
36843     }
36844     function space(d3_event) {
36845       d3_event.preventDefault();
36846       d3_event.stopPropagation();
36847       var currSpace = context.map().mouse();
36848       if (_disableSpace && _lastSpace) {
36849         var dist = geoVecLength(_lastSpace, currSpace);
36850         if (dist > _tolerance) {
36851           _disableSpace = false;
36852         }
36853       }
36854       if (_disableSpace || _mouseLeave || !_lastMouse)
36855         return;
36856       _lastSpace = currSpace;
36857       _disableSpace = true;
36858       select_default2(window).on("keyup.space-block", function() {
36859         d3_event.preventDefault();
36860         d3_event.stopPropagation();
36861         _disableSpace = false;
36862         select_default2(window).on("keyup.space-block", null);
36863       });
36864       var loc = context.map().mouse() || // or the map center if the mouse has never entered the map
36865       context.projection(context.map().center());
36866       click(d3_event, loc);
36867     }
36868     function backspace(d3_event) {
36869       d3_event.preventDefault();
36870       dispatch14.call("undo");
36871     }
36872     function del(d3_event) {
36873       d3_event.preventDefault();
36874       dispatch14.call("cancel");
36875     }
36876     function ret(d3_event) {
36877       d3_event.preventDefault();
36878       dispatch14.call("finish");
36879     }
36880     function behavior(selection2) {
36881       context.install(_hover);
36882       context.install(_edit);
36883       _downPointer = null;
36884       keybinding.on("\u232B", backspace).on("\u2326", del).on("\u238B", ret).on("\u21A9", ret).on("space", space).on("\u2325space", space);
36885       selection2.on("mouseenter.draw", mouseenter).on("mouseleave.draw", mouseleave).on(_pointerPrefix + "down.draw", pointerdown).on(_pointerPrefix + "move.draw", pointermove);
36886       select_default2(window).on(_pointerPrefix + "up.draw", pointerup, true).on("pointercancel.draw", pointercancel, true);
36887       select_default2(document).call(keybinding);
36888       return behavior;
36889     }
36890     behavior.off = function(selection2) {
36891       context.ui().sidebar.hover.cancel();
36892       context.uninstall(_hover);
36893       context.uninstall(_edit);
36894       selection2.on("mouseenter.draw", null).on("mouseleave.draw", null).on(_pointerPrefix + "down.draw", null).on(_pointerPrefix + "move.draw", null);
36895       select_default2(window).on(_pointerPrefix + "up.draw", null).on("pointercancel.draw", null);
36896       select_default2(document).call(keybinding.unbind);
36897     };
36898     behavior.hover = function() {
36899       return _hover;
36900     };
36901     return utilRebind(behavior, dispatch14, "on");
36902   }
36903
36904   // modules/behavior/breathe.js
36905   var import_fast_deep_equal2 = __toESM(require_fast_deep_equal());
36906
36907   // node_modules/d3-scale/src/init.js
36908   function initRange(domain, range3) {
36909     switch (arguments.length) {
36910       case 0:
36911         break;
36912       case 1:
36913         this.range(domain);
36914         break;
36915       default:
36916         this.range(range3).domain(domain);
36917         break;
36918     }
36919     return this;
36920   }
36921
36922   // node_modules/d3-scale/src/constant.js
36923   function constants(x2) {
36924     return function() {
36925       return x2;
36926     };
36927   }
36928
36929   // node_modules/d3-scale/src/number.js
36930   function number2(x2) {
36931     return +x2;
36932   }
36933
36934   // node_modules/d3-scale/src/continuous.js
36935   var unit = [0, 1];
36936   function identity3(x2) {
36937     return x2;
36938   }
36939   function normalize(a2, b2) {
36940     return (b2 -= a2 = +a2) ? function(x2) {
36941       return (x2 - a2) / b2;
36942     } : constants(isNaN(b2) ? NaN : 0.5);
36943   }
36944   function clamper(a2, b2) {
36945     var t2;
36946     if (a2 > b2)
36947       t2 = a2, a2 = b2, b2 = t2;
36948     return function(x2) {
36949       return Math.max(a2, Math.min(b2, x2));
36950     };
36951   }
36952   function bimap(domain, range3, interpolate) {
36953     var d0 = domain[0], d1 = domain[1], r0 = range3[0], r1 = range3[1];
36954     if (d1 < d0)
36955       d0 = normalize(d1, d0), r0 = interpolate(r1, r0);
36956     else
36957       d0 = normalize(d0, d1), r0 = interpolate(r0, r1);
36958     return function(x2) {
36959       return r0(d0(x2));
36960     };
36961   }
36962   function polymap(domain, range3, interpolate) {
36963     var j2 = Math.min(domain.length, range3.length) - 1, d2 = new Array(j2), r2 = new Array(j2), i3 = -1;
36964     if (domain[j2] < domain[0]) {
36965       domain = domain.slice().reverse();
36966       range3 = range3.slice().reverse();
36967     }
36968     while (++i3 < j2) {
36969       d2[i3] = normalize(domain[i3], domain[i3 + 1]);
36970       r2[i3] = interpolate(range3[i3], range3[i3 + 1]);
36971     }
36972     return function(x2) {
36973       var i4 = bisect_default(domain, x2, 1, j2) - 1;
36974       return r2[i4](d2[i4](x2));
36975     };
36976   }
36977   function copy(source, target) {
36978     return target.domain(source.domain()).range(source.range()).interpolate(source.interpolate()).clamp(source.clamp()).unknown(source.unknown());
36979   }
36980   function transformer2() {
36981     var domain = unit, range3 = unit, interpolate = value_default, transform2, untransform, unknown, clamp3 = identity3, piecewise, output, input;
36982     function rescale() {
36983       var n3 = Math.min(domain.length, range3.length);
36984       if (clamp3 !== identity3)
36985         clamp3 = clamper(domain[0], domain[n3 - 1]);
36986       piecewise = n3 > 2 ? polymap : bimap;
36987       output = input = null;
36988       return scale;
36989     }
36990     function scale(x2) {
36991       return x2 == null || isNaN(x2 = +x2) ? unknown : (output || (output = piecewise(domain.map(transform2), range3, interpolate)))(transform2(clamp3(x2)));
36992     }
36993     scale.invert = function(y2) {
36994       return clamp3(untransform((input || (input = piecewise(range3, domain.map(transform2), number_default)))(y2)));
36995     };
36996     scale.domain = function(_2) {
36997       return arguments.length ? (domain = Array.from(_2, number2), rescale()) : domain.slice();
36998     };
36999     scale.range = function(_2) {
37000       return arguments.length ? (range3 = Array.from(_2), rescale()) : range3.slice();
37001     };
37002     scale.rangeRound = function(_2) {
37003       return range3 = Array.from(_2), interpolate = round_default, rescale();
37004     };
37005     scale.clamp = function(_2) {
37006       return arguments.length ? (clamp3 = _2 ? true : identity3, rescale()) : clamp3 !== identity3;
37007     };
37008     scale.interpolate = function(_2) {
37009       return arguments.length ? (interpolate = _2, rescale()) : interpolate;
37010     };
37011     scale.unknown = function(_2) {
37012       return arguments.length ? (unknown = _2, scale) : unknown;
37013     };
37014     return function(t2, u2) {
37015       transform2 = t2, untransform = u2;
37016       return rescale();
37017     };
37018   }
37019   function continuous() {
37020     return transformer2()(identity3, identity3);
37021   }
37022
37023   // node_modules/d3-format/src/formatDecimal.js
37024   function formatDecimal_default(x2) {
37025     return Math.abs(x2 = Math.round(x2)) >= 1e21 ? x2.toLocaleString("en").replace(/,/g, "") : x2.toString(10);
37026   }
37027   function formatDecimalParts(x2, p2) {
37028     if ((i3 = (x2 = p2 ? x2.toExponential(p2 - 1) : x2.toExponential()).indexOf("e")) < 0)
37029       return null;
37030     var i3, coefficient = x2.slice(0, i3);
37031     return [
37032       coefficient.length > 1 ? coefficient[0] + coefficient.slice(2) : coefficient,
37033       +x2.slice(i3 + 1)
37034     ];
37035   }
37036
37037   // node_modules/d3-format/src/exponent.js
37038   function exponent_default(x2) {
37039     return x2 = formatDecimalParts(Math.abs(x2)), x2 ? x2[1] : NaN;
37040   }
37041
37042   // node_modules/d3-format/src/formatGroup.js
37043   function formatGroup_default(grouping, thousands) {
37044     return function(value, width) {
37045       var i3 = value.length, t2 = [], j2 = 0, g3 = grouping[0], length2 = 0;
37046       while (i3 > 0 && g3 > 0) {
37047         if (length2 + g3 + 1 > width)
37048           g3 = Math.max(1, width - length2);
37049         t2.push(value.substring(i3 -= g3, i3 + g3));
37050         if ((length2 += g3 + 1) > width)
37051           break;
37052         g3 = grouping[j2 = (j2 + 1) % grouping.length];
37053       }
37054       return t2.reverse().join(thousands);
37055     };
37056   }
37057
37058   // node_modules/d3-format/src/formatNumerals.js
37059   function formatNumerals_default(numerals) {
37060     return function(value) {
37061       return value.replace(/[0-9]/g, function(i3) {
37062         return numerals[+i3];
37063       });
37064     };
37065   }
37066
37067   // node_modules/d3-format/src/formatSpecifier.js
37068   var re = /^(?:(.)?([<>=^]))?([+\-( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?(~)?([a-z%])?$/i;
37069   function formatSpecifier(specifier) {
37070     if (!(match = re.exec(specifier)))
37071       throw new Error("invalid format: " + specifier);
37072     var match;
37073     return new FormatSpecifier({
37074       fill: match[1],
37075       align: match[2],
37076       sign: match[3],
37077       symbol: match[4],
37078       zero: match[5],
37079       width: match[6],
37080       comma: match[7],
37081       precision: match[8] && match[8].slice(1),
37082       trim: match[9],
37083       type: match[10]
37084     });
37085   }
37086   formatSpecifier.prototype = FormatSpecifier.prototype;
37087   function FormatSpecifier(specifier) {
37088     this.fill = specifier.fill === void 0 ? " " : specifier.fill + "";
37089     this.align = specifier.align === void 0 ? ">" : specifier.align + "";
37090     this.sign = specifier.sign === void 0 ? "-" : specifier.sign + "";
37091     this.symbol = specifier.symbol === void 0 ? "" : specifier.symbol + "";
37092     this.zero = !!specifier.zero;
37093     this.width = specifier.width === void 0 ? void 0 : +specifier.width;
37094     this.comma = !!specifier.comma;
37095     this.precision = specifier.precision === void 0 ? void 0 : +specifier.precision;
37096     this.trim = !!specifier.trim;
37097     this.type = specifier.type === void 0 ? "" : specifier.type + "";
37098   }
37099   FormatSpecifier.prototype.toString = function() {
37100     return this.fill + this.align + this.sign + this.symbol + (this.zero ? "0" : "") + (this.width === void 0 ? "" : Math.max(1, this.width | 0)) + (this.comma ? "," : "") + (this.precision === void 0 ? "" : "." + Math.max(0, this.precision | 0)) + (this.trim ? "~" : "") + this.type;
37101   };
37102
37103   // node_modules/d3-format/src/formatTrim.js
37104   function formatTrim_default(s2) {
37105     out:
37106       for (var n3 = s2.length, i3 = 1, i0 = -1, i1; i3 < n3; ++i3) {
37107         switch (s2[i3]) {
37108           case ".":
37109             i0 = i1 = i3;
37110             break;
37111           case "0":
37112             if (i0 === 0)
37113               i0 = i3;
37114             i1 = i3;
37115             break;
37116           default:
37117             if (!+s2[i3])
37118               break out;
37119             if (i0 > 0)
37120               i0 = 0;
37121             break;
37122         }
37123       }
37124     return i0 > 0 ? s2.slice(0, i0) + s2.slice(i1 + 1) : s2;
37125   }
37126
37127   // node_modules/d3-format/src/formatPrefixAuto.js
37128   var prefixExponent;
37129   function formatPrefixAuto_default(x2, p2) {
37130     var d2 = formatDecimalParts(x2, p2);
37131     if (!d2)
37132       return x2 + "";
37133     var coefficient = d2[0], exponent = d2[1], i3 = exponent - (prefixExponent = Math.max(-8, Math.min(8, Math.floor(exponent / 3))) * 3) + 1, n3 = coefficient.length;
37134     return i3 === n3 ? coefficient : i3 > n3 ? coefficient + new Array(i3 - n3 + 1).join("0") : i3 > 0 ? coefficient.slice(0, i3) + "." + coefficient.slice(i3) : "0." + new Array(1 - i3).join("0") + formatDecimalParts(x2, Math.max(0, p2 + i3 - 1))[0];
37135   }
37136
37137   // node_modules/d3-format/src/formatRounded.js
37138   function formatRounded_default(x2, p2) {
37139     var d2 = formatDecimalParts(x2, p2);
37140     if (!d2)
37141       return x2 + "";
37142     var coefficient = d2[0], exponent = d2[1];
37143     return exponent < 0 ? "0." + new Array(-exponent).join("0") + coefficient : coefficient.length > exponent + 1 ? coefficient.slice(0, exponent + 1) + "." + coefficient.slice(exponent + 1) : coefficient + new Array(exponent - coefficient.length + 2).join("0");
37144   }
37145
37146   // node_modules/d3-format/src/formatTypes.js
37147   var formatTypes_default = {
37148     "%": (x2, p2) => (x2 * 100).toFixed(p2),
37149     "b": (x2) => Math.round(x2).toString(2),
37150     "c": (x2) => x2 + "",
37151     "d": formatDecimal_default,
37152     "e": (x2, p2) => x2.toExponential(p2),
37153     "f": (x2, p2) => x2.toFixed(p2),
37154     "g": (x2, p2) => x2.toPrecision(p2),
37155     "o": (x2) => Math.round(x2).toString(8),
37156     "p": (x2, p2) => formatRounded_default(x2 * 100, p2),
37157     "r": formatRounded_default,
37158     "s": formatPrefixAuto_default,
37159     "X": (x2) => Math.round(x2).toString(16).toUpperCase(),
37160     "x": (x2) => Math.round(x2).toString(16)
37161   };
37162
37163   // node_modules/d3-format/src/identity.js
37164   function identity_default4(x2) {
37165     return x2;
37166   }
37167
37168   // node_modules/d3-format/src/locale.js
37169   var map = Array.prototype.map;
37170   var prefixes = ["y", "z", "a", "f", "p", "n", "\xB5", "m", "", "k", "M", "G", "T", "P", "E", "Z", "Y"];
37171   function locale_default(locale2) {
37172     var group = locale2.grouping === void 0 || locale2.thousands === void 0 ? identity_default4 : formatGroup_default(map.call(locale2.grouping, Number), locale2.thousands + ""), currencyPrefix = locale2.currency === void 0 ? "" : locale2.currency[0] + "", currencySuffix = locale2.currency === void 0 ? "" : locale2.currency[1] + "", decimal = locale2.decimal === void 0 ? "." : locale2.decimal + "", numerals = locale2.numerals === void 0 ? identity_default4 : formatNumerals_default(map.call(locale2.numerals, String)), percent = locale2.percent === void 0 ? "%" : locale2.percent + "", minus = locale2.minus === void 0 ? "\u2212" : locale2.minus + "", nan = locale2.nan === void 0 ? "NaN" : locale2.nan + "";
37173     function newFormat(specifier) {
37174       specifier = formatSpecifier(specifier);
37175       var fill = specifier.fill, align = specifier.align, sign2 = specifier.sign, symbol = specifier.symbol, zero3 = specifier.zero, width = specifier.width, comma = specifier.comma, precision3 = specifier.precision, trim = specifier.trim, type2 = specifier.type;
37176       if (type2 === "n")
37177         comma = true, type2 = "g";
37178       else if (!formatTypes_default[type2])
37179         precision3 === void 0 && (precision3 = 12), trim = true, type2 = "g";
37180       if (zero3 || fill === "0" && align === "=")
37181         zero3 = true, fill = "0", align = "=";
37182       var prefix = symbol === "$" ? currencyPrefix : symbol === "#" && /[boxX]/.test(type2) ? "0" + type2.toLowerCase() : "", suffix = symbol === "$" ? currencySuffix : /[%p]/.test(type2) ? percent : "";
37183       var formatType = formatTypes_default[type2], maybeSuffix = /[defgprs%]/.test(type2);
37184       precision3 = precision3 === void 0 ? 6 : /[gprs]/.test(type2) ? Math.max(1, Math.min(21, precision3)) : Math.max(0, Math.min(20, precision3));
37185       function format2(value) {
37186         var valuePrefix = prefix, valueSuffix = suffix, i3, n3, c2;
37187         if (type2 === "c") {
37188           valueSuffix = formatType(value) + valueSuffix;
37189           value = "";
37190         } else {
37191           value = +value;
37192           var valueNegative = value < 0 || 1 / value < 0;
37193           value = isNaN(value) ? nan : formatType(Math.abs(value), precision3);
37194           if (trim)
37195             value = formatTrim_default(value);
37196           if (valueNegative && +value === 0 && sign2 !== "+")
37197             valueNegative = false;
37198           valuePrefix = (valueNegative ? sign2 === "(" ? sign2 : minus : sign2 === "-" || sign2 === "(" ? "" : sign2) + valuePrefix;
37199           valueSuffix = (type2 === "s" ? prefixes[8 + prefixExponent / 3] : "") + valueSuffix + (valueNegative && sign2 === "(" ? ")" : "");
37200           if (maybeSuffix) {
37201             i3 = -1, n3 = value.length;
37202             while (++i3 < n3) {
37203               if (c2 = value.charCodeAt(i3), 48 > c2 || c2 > 57) {
37204                 valueSuffix = (c2 === 46 ? decimal + value.slice(i3 + 1) : value.slice(i3)) + valueSuffix;
37205                 value = value.slice(0, i3);
37206                 break;
37207               }
37208             }
37209           }
37210         }
37211         if (comma && !zero3)
37212           value = group(value, Infinity);
37213         var length2 = valuePrefix.length + value.length + valueSuffix.length, padding = length2 < width ? new Array(width - length2 + 1).join(fill) : "";
37214         if (comma && zero3)
37215           value = group(padding + value, padding.length ? width - valueSuffix.length : Infinity), padding = "";
37216         switch (align) {
37217           case "<":
37218             value = valuePrefix + value + valueSuffix + padding;
37219             break;
37220           case "=":
37221             value = valuePrefix + padding + value + valueSuffix;
37222             break;
37223           case "^":
37224             value = padding.slice(0, length2 = padding.length >> 1) + valuePrefix + value + valueSuffix + padding.slice(length2);
37225             break;
37226           default:
37227             value = padding + valuePrefix + value + valueSuffix;
37228             break;
37229         }
37230         return numerals(value);
37231       }
37232       format2.toString = function() {
37233         return specifier + "";
37234       };
37235       return format2;
37236     }
37237     function formatPrefix2(specifier, value) {
37238       var f2 = newFormat((specifier = formatSpecifier(specifier), specifier.type = "f", specifier)), e3 = Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3, k2 = Math.pow(10, -e3), prefix = prefixes[8 + e3 / 3];
37239       return function(value2) {
37240         return f2(k2 * value2) + prefix;
37241       };
37242     }
37243     return {
37244       format: newFormat,
37245       formatPrefix: formatPrefix2
37246     };
37247   }
37248
37249   // node_modules/d3-format/src/defaultLocale.js
37250   var locale;
37251   var format;
37252   var formatPrefix;
37253   defaultLocale({
37254     thousands: ",",
37255     grouping: [3],
37256     currency: ["$", ""]
37257   });
37258   function defaultLocale(definition) {
37259     locale = locale_default(definition);
37260     format = locale.format;
37261     formatPrefix = locale.formatPrefix;
37262     return locale;
37263   }
37264
37265   // node_modules/d3-format/src/precisionFixed.js
37266   function precisionFixed_default(step) {
37267     return Math.max(0, -exponent_default(Math.abs(step)));
37268   }
37269
37270   // node_modules/d3-format/src/precisionPrefix.js
37271   function precisionPrefix_default(step, value) {
37272     return Math.max(0, Math.max(-8, Math.min(8, Math.floor(exponent_default(value) / 3))) * 3 - exponent_default(Math.abs(step)));
37273   }
37274
37275   // node_modules/d3-format/src/precisionRound.js
37276   function precisionRound_default(step, max3) {
37277     step = Math.abs(step), max3 = Math.abs(max3) - step;
37278     return Math.max(0, exponent_default(max3) - exponent_default(step)) + 1;
37279   }
37280
37281   // node_modules/d3-scale/src/tickFormat.js
37282   function tickFormat(start2, stop, count, specifier) {
37283     var step = tickStep(start2, stop, count), precision3;
37284     specifier = formatSpecifier(specifier == null ? ",f" : specifier);
37285     switch (specifier.type) {
37286       case "s": {
37287         var value = Math.max(Math.abs(start2), Math.abs(stop));
37288         if (specifier.precision == null && !isNaN(precision3 = precisionPrefix_default(step, value)))
37289           specifier.precision = precision3;
37290         return formatPrefix(specifier, value);
37291       }
37292       case "":
37293       case "e":
37294       case "g":
37295       case "p":
37296       case "r": {
37297         if (specifier.precision == null && !isNaN(precision3 = precisionRound_default(step, Math.max(Math.abs(start2), Math.abs(stop)))))
37298           specifier.precision = precision3 - (specifier.type === "e");
37299         break;
37300       }
37301       case "f":
37302       case "%": {
37303         if (specifier.precision == null && !isNaN(precision3 = precisionFixed_default(step)))
37304           specifier.precision = precision3 - (specifier.type === "%") * 2;
37305         break;
37306       }
37307     }
37308     return format(specifier);
37309   }
37310
37311   // node_modules/d3-scale/src/linear.js
37312   function linearish(scale) {
37313     var domain = scale.domain;
37314     scale.ticks = function(count) {
37315       var d2 = domain();
37316       return ticks(d2[0], d2[d2.length - 1], count == null ? 10 : count);
37317     };
37318     scale.tickFormat = function(count, specifier) {
37319       var d2 = domain();
37320       return tickFormat(d2[0], d2[d2.length - 1], count == null ? 10 : count, specifier);
37321     };
37322     scale.nice = function(count) {
37323       if (count == null)
37324         count = 10;
37325       var d2 = domain();
37326       var i0 = 0;
37327       var i1 = d2.length - 1;
37328       var start2 = d2[i0];
37329       var stop = d2[i1];
37330       var prestep;
37331       var step;
37332       var maxIter = 10;
37333       if (stop < start2) {
37334         step = start2, start2 = stop, stop = step;
37335         step = i0, i0 = i1, i1 = step;
37336       }
37337       while (maxIter-- > 0) {
37338         step = tickIncrement(start2, stop, count);
37339         if (step === prestep) {
37340           d2[i0] = start2;
37341           d2[i1] = stop;
37342           return domain(d2);
37343         } else if (step > 0) {
37344           start2 = Math.floor(start2 / step) * step;
37345           stop = Math.ceil(stop / step) * step;
37346         } else if (step < 0) {
37347           start2 = Math.ceil(start2 * step) / step;
37348           stop = Math.floor(stop * step) / step;
37349         } else {
37350           break;
37351         }
37352         prestep = step;
37353       }
37354       return scale;
37355     };
37356     return scale;
37357   }
37358   function linear3() {
37359     var scale = continuous();
37360     scale.copy = function() {
37361       return copy(scale, linear3());
37362     };
37363     initRange.apply(scale, arguments);
37364     return linearish(scale);
37365   }
37366
37367   // node_modules/d3-scale/src/quantize.js
37368   function quantize() {
37369     var x05 = 0, x12 = 1, n3 = 1, domain = [0.5], range3 = [0, 1], unknown;
37370     function scale(x2) {
37371       return x2 != null && x2 <= x2 ? range3[bisect_default(domain, x2, 0, n3)] : unknown;
37372     }
37373     function rescale() {
37374       var i3 = -1;
37375       domain = new Array(n3);
37376       while (++i3 < n3)
37377         domain[i3] = ((i3 + 1) * x12 - (i3 - n3) * x05) / (n3 + 1);
37378       return scale;
37379     }
37380     scale.domain = function(_2) {
37381       return arguments.length ? ([x05, x12] = _2, x05 = +x05, x12 = +x12, rescale()) : [x05, x12];
37382     };
37383     scale.range = function(_2) {
37384       return arguments.length ? (n3 = (range3 = Array.from(_2)).length - 1, rescale()) : range3.slice();
37385     };
37386     scale.invertExtent = function(y2) {
37387       var i3 = range3.indexOf(y2);
37388       return i3 < 0 ? [NaN, NaN] : i3 < 1 ? [x05, domain[0]] : i3 >= n3 ? [domain[n3 - 1], x12] : [domain[i3 - 1], domain[i3]];
37389     };
37390     scale.unknown = function(_2) {
37391       return arguments.length ? (unknown = _2, scale) : scale;
37392     };
37393     scale.thresholds = function() {
37394       return domain.slice();
37395     };
37396     scale.copy = function() {
37397       return quantize().domain([x05, x12]).range(range3).unknown(unknown);
37398     };
37399     return initRange.apply(linearish(scale), arguments);
37400   }
37401
37402   // modules/behavior/breathe.js
37403   function behaviorBreathe() {
37404     var duration = 800;
37405     var steps = 4;
37406     var selector = ".selected.shadow, .selected .shadow";
37407     var _selected = select_default2(null);
37408     var _classed = "";
37409     var _params = {};
37410     var _done = false;
37411     var _timer;
37412     function ratchetyInterpolator(a2, b2, steps2, units) {
37413       a2 = Number(a2);
37414       b2 = Number(b2);
37415       var sample = quantize().domain([0, 1]).range(quantize_default(number_default(a2, b2), steps2));
37416       return function(t2) {
37417         return String(sample(t2)) + (units || "");
37418       };
37419     }
37420     function reset(selection2) {
37421       selection2.style("stroke-opacity", null).style("stroke-width", null).style("fill-opacity", null).style("r", null);
37422     }
37423     function setAnimationParams(transition2, fromTo) {
37424       var toFrom = fromTo === "from" ? "to" : "from";
37425       transition2.styleTween("stroke-opacity", function(d2) {
37426         return ratchetyInterpolator(
37427           _params[d2.id][toFrom].opacity,
37428           _params[d2.id][fromTo].opacity,
37429           steps
37430         );
37431       }).styleTween("stroke-width", function(d2) {
37432         return ratchetyInterpolator(
37433           _params[d2.id][toFrom].width,
37434           _params[d2.id][fromTo].width,
37435           steps,
37436           "px"
37437         );
37438       }).styleTween("fill-opacity", function(d2) {
37439         return ratchetyInterpolator(
37440           _params[d2.id][toFrom].opacity,
37441           _params[d2.id][fromTo].opacity,
37442           steps
37443         );
37444       }).styleTween("r", function(d2) {
37445         return ratchetyInterpolator(
37446           _params[d2.id][toFrom].width,
37447           _params[d2.id][fromTo].width,
37448           steps,
37449           "px"
37450         );
37451       });
37452     }
37453     function calcAnimationParams(selection2) {
37454       selection2.call(reset).each(function(d2) {
37455         var s2 = select_default2(this);
37456         var tag2 = s2.node().tagName;
37457         var p2 = { "from": {}, "to": {} };
37458         var opacity;
37459         var width;
37460         if (tag2 === "circle") {
37461           opacity = Number(s2.style("fill-opacity") || 0.5);
37462           width = Number(s2.style("r") || 15.5);
37463         } else {
37464           opacity = Number(s2.style("stroke-opacity") || 0.7);
37465           width = Number(s2.style("stroke-width") || 10);
37466         }
37467         p2.tag = tag2;
37468         p2.from.opacity = opacity * 0.6;
37469         p2.to.opacity = opacity * 1.25;
37470         p2.from.width = width * 0.7;
37471         p2.to.width = width * (tag2 === "circle" ? 1.5 : 1);
37472         _params[d2.id] = p2;
37473       });
37474     }
37475     function run(surface, fromTo) {
37476       var toFrom = fromTo === "from" ? "to" : "from";
37477       var currSelected = surface.selectAll(selector);
37478       var currClassed = surface.attr("class");
37479       if (_done || currSelected.empty()) {
37480         _selected.call(reset);
37481         _selected = select_default2(null);
37482         return;
37483       }
37484       if (!(0, import_fast_deep_equal2.default)(currSelected.data(), _selected.data()) || currClassed !== _classed) {
37485         _selected.call(reset);
37486         _classed = currClassed;
37487         _selected = currSelected.call(calcAnimationParams);
37488       }
37489       var didCallNextRun = false;
37490       _selected.transition().duration(duration).call(setAnimationParams, fromTo).on("end", function() {
37491         if (!didCallNextRun) {
37492           surface.call(run, toFrom);
37493           didCallNextRun = true;
37494         }
37495         if (!select_default2(this).classed("selected")) {
37496           reset(select_default2(this));
37497         }
37498       });
37499     }
37500     function behavior(surface) {
37501       _done = false;
37502       _timer = timer(function() {
37503         if (surface.selectAll(selector).empty()) {
37504           return false;
37505         }
37506         surface.call(run, "from");
37507         _timer.stop();
37508         return true;
37509       }, 20);
37510     }
37511     behavior.restartIfNeeded = function(surface) {
37512       if (_selected.empty()) {
37513         surface.call(run, "from");
37514         if (_timer) {
37515           _timer.stop();
37516         }
37517       }
37518     };
37519     behavior.off = function() {
37520       _done = true;
37521       if (_timer) {
37522         _timer.stop();
37523       }
37524       _selected.interrupt().call(reset);
37525     };
37526     return behavior;
37527   }
37528
37529   // modules/behavior/operation.js
37530   function behaviorOperation(context) {
37531     var _operation;
37532     function keypress(d3_event) {
37533       if (!context.map().withinEditableZoom())
37534         return;
37535       if (_operation.availableForKeypress && !_operation.availableForKeypress())
37536         return;
37537       d3_event.preventDefault();
37538       var disabled = _operation.disabled();
37539       if (disabled) {
37540         context.ui().flash.duration(4e3).iconName("#iD-operation-" + _operation.id).iconClass("operation disabled").label(_operation.tooltip())();
37541       } else {
37542         context.ui().flash.duration(2e3).iconName("#iD-operation-" + _operation.id).iconClass("operation").label(_operation.annotation() || _operation.title)();
37543         if (_operation.point)
37544           _operation.point(null);
37545         _operation();
37546       }
37547     }
37548     function behavior() {
37549       if (_operation && _operation.available()) {
37550         context.keybinding().on(_operation.keys, keypress);
37551       }
37552       return behavior;
37553     }
37554     behavior.off = function() {
37555       context.keybinding().off(_operation.keys);
37556     };
37557     behavior.which = function(_2) {
37558       if (!arguments.length)
37559         return _operation;
37560       _operation = _2;
37561       return behavior;
37562     };
37563     return behavior;
37564   }
37565
37566   // modules/operations/circularize.js
37567   function operationCircularize(context, selectedIDs) {
37568     var _extent;
37569     var _actions = selectedIDs.map(getAction).filter(Boolean);
37570     var _amount = _actions.length === 1 ? "single" : "multiple";
37571     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
37572       return n3.loc;
37573     });
37574     function getAction(entityID) {
37575       var entity = context.entity(entityID);
37576       if (entity.type !== "way" || new Set(entity.nodes).size <= 1)
37577         return null;
37578       if (!_extent) {
37579         _extent = entity.extent(context.graph());
37580       } else {
37581         _extent = _extent.extend(entity.extent(context.graph()));
37582       }
37583       return actionCircularize(entityID, context.projection);
37584     }
37585     var operation2 = function() {
37586       if (!_actions.length)
37587         return;
37588       var combinedAction = function(graph, t2) {
37589         _actions.forEach(function(action) {
37590           if (!action.disabled(graph)) {
37591             graph = action(graph, t2);
37592           }
37593         });
37594         return graph;
37595       };
37596       combinedAction.transitionable = true;
37597       context.perform(combinedAction, operation2.annotation());
37598       window.setTimeout(function() {
37599         context.validator().validate();
37600       }, 300);
37601     };
37602     operation2.available = function() {
37603       return _actions.length && selectedIDs.length === _actions.length;
37604     };
37605     operation2.disabled = function() {
37606       if (!_actions.length)
37607         return "";
37608       var actionDisableds = _actions.map(function(action) {
37609         return action.disabled(context.graph());
37610       }).filter(Boolean);
37611       if (actionDisableds.length === _actions.length) {
37612         if (new Set(actionDisableds).size > 1) {
37613           return "multiple_blockers";
37614         }
37615         return actionDisableds[0];
37616       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
37617         return "too_large";
37618       } else if (someMissing()) {
37619         return "not_downloaded";
37620       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37621         return "connected_to_hidden";
37622       }
37623       return false;
37624       function someMissing() {
37625         if (context.inIntro())
37626           return false;
37627         var osm = context.connection();
37628         if (osm) {
37629           var missing = _coords.filter(function(loc) {
37630             return !osm.isDataLoaded(loc);
37631           });
37632           if (missing.length) {
37633             missing.forEach(function(loc) {
37634               context.loadTileAtLoc(loc);
37635             });
37636             return true;
37637           }
37638         }
37639         return false;
37640       }
37641     };
37642     operation2.tooltip = function() {
37643       var disable = operation2.disabled();
37644       return disable ? _t.append("operations.circularize." + disable + "." + _amount) : _t.append("operations.circularize.description." + _amount);
37645     };
37646     operation2.annotation = function() {
37647       return _t("operations.circularize.annotation.feature", { n: _actions.length });
37648     };
37649     operation2.id = "circularize";
37650     operation2.keys = [_t("operations.circularize.key")];
37651     operation2.title = _t.append("operations.circularize.title");
37652     operation2.behavior = behaviorOperation(context).which(operation2);
37653     return operation2;
37654   }
37655
37656   // modules/ui/cmd.js
37657   var uiCmd = function(code) {
37658     var detected = utilDetect();
37659     if (detected.os === "mac") {
37660       return code;
37661     }
37662     if (detected.os === "win") {
37663       if (code === "\u2318\u21E7Z")
37664         return "Ctrl+Y";
37665     }
37666     var result = "", replacements = {
37667       "\u2318": "Ctrl",
37668       "\u21E7": "Shift",
37669       "\u2325": "Alt",
37670       "\u232B": "Backspace",
37671       "\u2326": "Delete"
37672     };
37673     for (var i3 = 0; i3 < code.length; i3++) {
37674       if (code[i3] in replacements) {
37675         result += replacements[code[i3]] + (i3 < code.length - 1 ? "+" : "");
37676       } else {
37677         result += code[i3];
37678       }
37679     }
37680     return result;
37681   };
37682   uiCmd.display = function(code) {
37683     if (code.length !== 1)
37684       return code;
37685     var detected = utilDetect();
37686     var mac = detected.os === "mac";
37687     var replacements = {
37688       "\u2318": mac ? "\u2318 " + _t("shortcuts.key.cmd") : _t("shortcuts.key.ctrl"),
37689       "\u21E7": mac ? "\u21E7 " + _t("shortcuts.key.shift") : _t("shortcuts.key.shift"),
37690       "\u2325": mac ? "\u2325 " + _t("shortcuts.key.option") : _t("shortcuts.key.alt"),
37691       "\u2303": mac ? "\u2303 " + _t("shortcuts.key.ctrl") : _t("shortcuts.key.ctrl"),
37692       "\u232B": mac ? "\u232B " + _t("shortcuts.key.delete") : _t("shortcuts.key.backspace"),
37693       "\u2326": mac ? "\u2326 " + _t("shortcuts.key.del") : _t("shortcuts.key.del"),
37694       "\u2196": mac ? "\u2196 " + _t("shortcuts.key.pgup") : _t("shortcuts.key.pgup"),
37695       "\u2198": mac ? "\u2198 " + _t("shortcuts.key.pgdn") : _t("shortcuts.key.pgdn"),
37696       "\u21DE": mac ? "\u21DE " + _t("shortcuts.key.home") : _t("shortcuts.key.home"),
37697       "\u21DF": mac ? "\u21DF " + _t("shortcuts.key.end") : _t("shortcuts.key.end"),
37698       "\u21B5": mac ? "\u23CE " + _t("shortcuts.key.return") : _t("shortcuts.key.enter"),
37699       "\u238B": mac ? "\u238B " + _t("shortcuts.key.esc") : _t("shortcuts.key.esc"),
37700       "\u2630": mac ? "\u2630 " + _t("shortcuts.key.menu") : _t("shortcuts.key.menu")
37701     };
37702     return replacements[code] || code;
37703   };
37704
37705   // modules/operations/delete.js
37706   function operationDelete(context, selectedIDs) {
37707     var multi = selectedIDs.length === 1 ? "single" : "multiple";
37708     var action = actionDeleteMultiple(selectedIDs);
37709     var nodes = utilGetAllNodes(selectedIDs, context.graph());
37710     var coords = nodes.map(function(n3) {
37711       return n3.loc;
37712     });
37713     var extent = utilTotalExtent(selectedIDs, context.graph());
37714     var operation2 = function() {
37715       var nextSelectedID;
37716       var nextSelectedLoc;
37717       if (selectedIDs.length === 1) {
37718         var id2 = selectedIDs[0];
37719         var entity = context.entity(id2);
37720         var geometry = entity.geometry(context.graph());
37721         var parents = context.graph().parentWays(entity);
37722         var parent = parents[0];
37723         if (geometry === "vertex") {
37724           var nodes2 = parent.nodes;
37725           var i3 = nodes2.indexOf(id2);
37726           if (i3 === 0) {
37727             i3++;
37728           } else if (i3 === nodes2.length - 1) {
37729             i3--;
37730           } else {
37731             var a2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 - 1]).loc);
37732             var b2 = geoSphericalDistance(entity.loc, context.entity(nodes2[i3 + 1]).loc);
37733             i3 = a2 < b2 ? i3 - 1 : i3 + 1;
37734           }
37735           nextSelectedID = nodes2[i3];
37736           nextSelectedLoc = context.entity(nextSelectedID).loc;
37737         }
37738       }
37739       context.perform(action, operation2.annotation());
37740       context.validator().validate();
37741       if (nextSelectedID && nextSelectedLoc) {
37742         if (context.hasEntity(nextSelectedID)) {
37743           context.enter(modeSelect(context, [nextSelectedID]).follow(true));
37744         } else {
37745           context.map().centerEase(nextSelectedLoc);
37746           context.enter(modeBrowse(context));
37747         }
37748       } else {
37749         context.enter(modeBrowse(context));
37750       }
37751     };
37752     operation2.available = function() {
37753       return true;
37754     };
37755     operation2.disabled = function() {
37756       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
37757         return "too_large";
37758       } else if (someMissing()) {
37759         return "not_downloaded";
37760       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37761         return "connected_to_hidden";
37762       } else if (selectedIDs.some(protectedMember)) {
37763         return "part_of_relation";
37764       } else if (selectedIDs.some(incompleteRelation)) {
37765         return "incomplete_relation";
37766       } else if (selectedIDs.some(hasWikidataTag)) {
37767         return "has_wikidata_tag";
37768       }
37769       return false;
37770       function someMissing() {
37771         if (context.inIntro())
37772           return false;
37773         var osm = context.connection();
37774         if (osm) {
37775           var missing = coords.filter(function(loc) {
37776             return !osm.isDataLoaded(loc);
37777           });
37778           if (missing.length) {
37779             missing.forEach(function(loc) {
37780               context.loadTileAtLoc(loc);
37781             });
37782             return true;
37783           }
37784         }
37785         return false;
37786       }
37787       function hasWikidataTag(id2) {
37788         var entity = context.entity(id2);
37789         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
37790       }
37791       function incompleteRelation(id2) {
37792         var entity = context.entity(id2);
37793         return entity.type === "relation" && !entity.isComplete(context.graph());
37794       }
37795       function protectedMember(id2) {
37796         var entity = context.entity(id2);
37797         if (entity.type !== "way")
37798           return false;
37799         var parents = context.graph().parentRelations(entity);
37800         for (var i3 = 0; i3 < parents.length; i3++) {
37801           var parent = parents[i3];
37802           var type2 = parent.tags.type;
37803           var role = parent.memberById(id2).role || "outer";
37804           if (type2 === "route" || type2 === "boundary" || type2 === "multipolygon" && role === "outer") {
37805             return true;
37806           }
37807         }
37808         return false;
37809       }
37810     };
37811     operation2.tooltip = function() {
37812       var disable = operation2.disabled();
37813       return disable ? _t.append("operations.delete." + disable + "." + multi) : _t.append("operations.delete.description." + multi);
37814     };
37815     operation2.annotation = function() {
37816       return selectedIDs.length === 1 ? _t("operations.delete.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.delete.annotation.feature", { n: selectedIDs.length });
37817     };
37818     operation2.id = "delete";
37819     operation2.keys = [uiCmd("\u2318\u232B"), uiCmd("\u2318\u2326"), uiCmd("\u2326")];
37820     operation2.title = _t.append("operations.delete.title");
37821     operation2.behavior = behaviorOperation(context).which(operation2);
37822     return operation2;
37823   }
37824
37825   // modules/operations/orthogonalize.js
37826   function operationOrthogonalize(context, selectedIDs) {
37827     var _extent;
37828     var _type;
37829     var _actions = selectedIDs.map(chooseAction).filter(Boolean);
37830     var _amount = _actions.length === 1 ? "single" : "multiple";
37831     var _coords = utilGetAllNodes(selectedIDs, context.graph()).map(function(n3) {
37832       return n3.loc;
37833     });
37834     function chooseAction(entityID) {
37835       var entity = context.entity(entityID);
37836       var geometry = entity.geometry(context.graph());
37837       if (!_extent) {
37838         _extent = entity.extent(context.graph());
37839       } else {
37840         _extent = _extent.extend(entity.extent(context.graph()));
37841       }
37842       if (entity.type === "way" && new Set(entity.nodes).size > 2) {
37843         if (_type && _type !== "feature")
37844           return null;
37845         _type = "feature";
37846         return actionOrthogonalize(entityID, context.projection);
37847       } else if (geometry === "vertex") {
37848         if (_type && _type !== "corner")
37849           return null;
37850         _type = "corner";
37851         var graph = context.graph();
37852         var parents = graph.parentWays(entity);
37853         if (parents.length === 1) {
37854           var way = parents[0];
37855           if (way.nodes.indexOf(entityID) !== -1) {
37856             return actionOrthogonalize(way.id, context.projection, entityID);
37857           }
37858         }
37859       }
37860       return null;
37861     }
37862     var operation2 = function() {
37863       if (!_actions.length)
37864         return;
37865       var combinedAction = function(graph, t2) {
37866         _actions.forEach(function(action) {
37867           if (!action.disabled(graph)) {
37868             graph = action(graph, t2);
37869           }
37870         });
37871         return graph;
37872       };
37873       combinedAction.transitionable = true;
37874       context.perform(combinedAction, operation2.annotation());
37875       window.setTimeout(function() {
37876         context.validator().validate();
37877       }, 300);
37878     };
37879     operation2.available = function() {
37880       return _actions.length && selectedIDs.length === _actions.length;
37881     };
37882     operation2.disabled = function() {
37883       if (!_actions.length)
37884         return "";
37885       var actionDisableds = _actions.map(function(action) {
37886         return action.disabled(context.graph());
37887       }).filter(Boolean);
37888       if (actionDisableds.length === _actions.length) {
37889         if (new Set(actionDisableds).size > 1) {
37890           return "multiple_blockers";
37891         }
37892         return actionDisableds[0];
37893       } else if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
37894         return "too_large";
37895       } else if (someMissing()) {
37896         return "not_downloaded";
37897       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37898         return "connected_to_hidden";
37899       }
37900       return false;
37901       function someMissing() {
37902         if (context.inIntro())
37903           return false;
37904         var osm = context.connection();
37905         if (osm) {
37906           var missing = _coords.filter(function(loc) {
37907             return !osm.isDataLoaded(loc);
37908           });
37909           if (missing.length) {
37910             missing.forEach(function(loc) {
37911               context.loadTileAtLoc(loc);
37912             });
37913             return true;
37914           }
37915         }
37916         return false;
37917       }
37918     };
37919     operation2.tooltip = function() {
37920       var disable = operation2.disabled();
37921       return disable ? _t.append("operations.orthogonalize." + disable + "." + _amount) : _t.append("operations.orthogonalize.description." + _type + "." + _amount);
37922     };
37923     operation2.annotation = function() {
37924       return _t("operations.orthogonalize.annotation." + _type, { n: _actions.length });
37925     };
37926     operation2.id = "orthogonalize";
37927     operation2.keys = [_t("operations.orthogonalize.key")];
37928     operation2.title = _t.append("operations.orthogonalize.title");
37929     operation2.behavior = behaviorOperation(context).which(operation2);
37930     return operation2;
37931   }
37932
37933   // modules/operations/reflect.js
37934   function operationReflectShort(context, selectedIDs) {
37935     return operationReflect(context, selectedIDs, "short");
37936   }
37937   function operationReflectLong(context, selectedIDs) {
37938     return operationReflect(context, selectedIDs, "long");
37939   }
37940   function operationReflect(context, selectedIDs, axis) {
37941     axis = axis || "long";
37942     var multi = selectedIDs.length === 1 ? "single" : "multiple";
37943     var nodes = utilGetAllNodes(selectedIDs, context.graph());
37944     var coords = nodes.map(function(n3) {
37945       return n3.loc;
37946     });
37947     var extent = utilTotalExtent(selectedIDs, context.graph());
37948     var operation2 = function() {
37949       var action = actionReflect(selectedIDs, context.projection).useLongAxis(Boolean(axis === "long"));
37950       context.perform(action, operation2.annotation());
37951       window.setTimeout(function() {
37952         context.validator().validate();
37953       }, 300);
37954     };
37955     operation2.available = function() {
37956       return nodes.length >= 3;
37957     };
37958     operation2.disabled = function() {
37959       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
37960         return "too_large";
37961       } else if (someMissing()) {
37962         return "not_downloaded";
37963       } else if (selectedIDs.some(context.hasHiddenConnections)) {
37964         return "connected_to_hidden";
37965       } else if (selectedIDs.some(incompleteRelation)) {
37966         return "incomplete_relation";
37967       }
37968       return false;
37969       function someMissing() {
37970         if (context.inIntro())
37971           return false;
37972         var osm = context.connection();
37973         if (osm) {
37974           var missing = coords.filter(function(loc) {
37975             return !osm.isDataLoaded(loc);
37976           });
37977           if (missing.length) {
37978             missing.forEach(function(loc) {
37979               context.loadTileAtLoc(loc);
37980             });
37981             return true;
37982           }
37983         }
37984         return false;
37985       }
37986       function incompleteRelation(id2) {
37987         var entity = context.entity(id2);
37988         return entity.type === "relation" && !entity.isComplete(context.graph());
37989       }
37990     };
37991     operation2.tooltip = function() {
37992       var disable = operation2.disabled();
37993       return disable ? _t.append("operations.reflect." + disable + "." + multi) : _t.append("operations.reflect.description." + axis + "." + multi);
37994     };
37995     operation2.annotation = function() {
37996       return _t("operations.reflect.annotation." + axis + ".feature", { n: selectedIDs.length });
37997     };
37998     operation2.id = "reflect-" + axis;
37999     operation2.keys = [_t("operations.reflect.key." + axis)];
38000     operation2.title = _t.append("operations.reflect.title." + axis);
38001     operation2.behavior = behaviorOperation(context).which(operation2);
38002     return operation2;
38003   }
38004
38005   // modules/operations/move.js
38006   function operationMove(context, selectedIDs) {
38007     var multi = selectedIDs.length === 1 ? "single" : "multiple";
38008     var nodes = utilGetAllNodes(selectedIDs, context.graph());
38009     var coords = nodes.map(function(n3) {
38010       return n3.loc;
38011     });
38012     var extent = utilTotalExtent(selectedIDs, context.graph());
38013     var operation2 = function() {
38014       context.enter(modeMove(context, selectedIDs));
38015     };
38016     operation2.available = function() {
38017       return selectedIDs.length > 0;
38018     };
38019     operation2.disabled = function() {
38020       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
38021         return "too_large";
38022       } else if (someMissing()) {
38023         return "not_downloaded";
38024       } else if (selectedIDs.some(context.hasHiddenConnections)) {
38025         return "connected_to_hidden";
38026       } else if (selectedIDs.some(incompleteRelation)) {
38027         return "incomplete_relation";
38028       }
38029       return false;
38030       function someMissing() {
38031         if (context.inIntro())
38032           return false;
38033         var osm = context.connection();
38034         if (osm) {
38035           var missing = coords.filter(function(loc) {
38036             return !osm.isDataLoaded(loc);
38037           });
38038           if (missing.length) {
38039             missing.forEach(function(loc) {
38040               context.loadTileAtLoc(loc);
38041             });
38042             return true;
38043           }
38044         }
38045         return false;
38046       }
38047       function incompleteRelation(id2) {
38048         var entity = context.entity(id2);
38049         return entity.type === "relation" && !entity.isComplete(context.graph());
38050       }
38051     };
38052     operation2.tooltip = function() {
38053       var disable = operation2.disabled();
38054       return disable ? _t.append("operations.move." + disable + "." + multi) : _t.append("operations.move.description." + multi);
38055     };
38056     operation2.annotation = function() {
38057       return selectedIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.move.annotation.feature", { n: selectedIDs.length });
38058     };
38059     operation2.id = "move";
38060     operation2.keys = [_t("operations.move.key")];
38061     operation2.title = _t.append("operations.move.title");
38062     operation2.behavior = behaviorOperation(context).which(operation2);
38063     operation2.mouseOnly = true;
38064     return operation2;
38065   }
38066
38067   // modules/modes/rotate.js
38068   function modeRotate(context, entityIDs) {
38069     var _tolerancePx = 4;
38070     var mode = {
38071       id: "rotate",
38072       button: "browse"
38073     };
38074     var keybinding = utilKeybinding("rotate");
38075     var behaviors = [
38076       behaviorEdit(context),
38077       operationCircularize(context, entityIDs).behavior,
38078       operationDelete(context, entityIDs).behavior,
38079       operationMove(context, entityIDs).behavior,
38080       operationOrthogonalize(context, entityIDs).behavior,
38081       operationReflectLong(context, entityIDs).behavior,
38082       operationReflectShort(context, entityIDs).behavior
38083     ];
38084     var annotation = entityIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.rotate.annotation.feature", { n: entityIDs.length });
38085     var _prevGraph;
38086     var _prevAngle;
38087     var _prevTransform;
38088     var _pivot;
38089     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
38090     function doRotate(d3_event) {
38091       var fn;
38092       if (context.graph() !== _prevGraph) {
38093         fn = context.perform;
38094       } else {
38095         fn = context.replace;
38096       }
38097       var projection2 = context.projection;
38098       var currTransform = projection2.transform();
38099       if (!_prevTransform || currTransform.k !== _prevTransform.k || currTransform.x !== _prevTransform.x || currTransform.y !== _prevTransform.y) {
38100         var nodes = utilGetAllNodes(entityIDs, context.graph());
38101         var points = nodes.map(function(n3) {
38102           return projection2(n3.loc);
38103         });
38104         _pivot = getPivot(points);
38105         _prevAngle = void 0;
38106       }
38107       var currMouse = context.map().mouse(d3_event);
38108       var currAngle = Math.atan2(currMouse[1] - _pivot[1], currMouse[0] - _pivot[0]);
38109       if (typeof _prevAngle === "undefined")
38110         _prevAngle = currAngle;
38111       var delta = currAngle - _prevAngle;
38112       fn(actionRotate(entityIDs, _pivot, delta, projection2));
38113       _prevTransform = currTransform;
38114       _prevAngle = currAngle;
38115       _prevGraph = context.graph();
38116     }
38117     function getPivot(points) {
38118       var _pivot2;
38119       if (points.length === 1) {
38120         _pivot2 = points[0];
38121       } else if (points.length === 2) {
38122         _pivot2 = geoVecInterp(points[0], points[1], 0.5);
38123       } else {
38124         var polygonHull = hull_default(points);
38125         if (polygonHull.length === 2) {
38126           _pivot2 = geoVecInterp(points[0], points[1], 0.5);
38127         } else {
38128           _pivot2 = centroid_default2(hull_default(points));
38129         }
38130       }
38131       return _pivot2;
38132     }
38133     function finish(d3_event) {
38134       d3_event.stopPropagation();
38135       context.replace(actionNoop(), annotation);
38136       context.enter(modeSelect(context, entityIDs));
38137     }
38138     function cancel() {
38139       if (_prevGraph)
38140         context.pop();
38141       context.enter(modeSelect(context, entityIDs));
38142     }
38143     function undone() {
38144       context.enter(modeBrowse(context));
38145     }
38146     mode.enter = function() {
38147       _prevGraph = null;
38148       context.features().forceVisible(entityIDs);
38149       behaviors.forEach(context.install);
38150       var downEvent;
38151       context.surface().on(_pointerPrefix + "down.modeRotate", function(d3_event) {
38152         downEvent = d3_event;
38153       });
38154       select_default2(window).on(_pointerPrefix + "move.modeRotate", doRotate, true).on(_pointerPrefix + "up.modeRotate", function(d3_event) {
38155         if (!downEvent)
38156           return;
38157         var mapNode = context.container().select(".main-map").node();
38158         var pointGetter = utilFastMouse(mapNode);
38159         var p1 = pointGetter(downEvent);
38160         var p2 = pointGetter(d3_event);
38161         var dist = geoVecLength(p1, p2);
38162         if (dist <= _tolerancePx)
38163           finish(d3_event);
38164         downEvent = null;
38165       }, true);
38166       context.history().on("undone.modeRotate", undone);
38167       keybinding.on("\u238B", cancel).on("\u21A9", finish);
38168       select_default2(document).call(keybinding);
38169     };
38170     mode.exit = function() {
38171       behaviors.forEach(context.uninstall);
38172       context.surface().on(_pointerPrefix + "down.modeRotate", null);
38173       select_default2(window).on(_pointerPrefix + "move.modeRotate", null, true).on(_pointerPrefix + "up.modeRotate", null, true);
38174       context.history().on("undone.modeRotate", null);
38175       select_default2(document).call(keybinding.unbind);
38176       context.features().forceVisible([]);
38177     };
38178     mode.selectedIDs = function() {
38179       if (!arguments.length)
38180         return entityIDs;
38181       return mode;
38182     };
38183     return mode;
38184   }
38185
38186   // modules/operations/rotate.js
38187   function operationRotate(context, selectedIDs) {
38188     var multi = selectedIDs.length === 1 ? "single" : "multiple";
38189     var nodes = utilGetAllNodes(selectedIDs, context.graph());
38190     var coords = nodes.map(function(n3) {
38191       return n3.loc;
38192     });
38193     var extent = utilTotalExtent(selectedIDs, context.graph());
38194     var operation2 = function() {
38195       context.enter(modeRotate(context, selectedIDs));
38196     };
38197     operation2.available = function() {
38198       return nodes.length >= 2;
38199     };
38200     operation2.disabled = function() {
38201       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
38202         return "too_large";
38203       } else if (someMissing()) {
38204         return "not_downloaded";
38205       } else if (selectedIDs.some(context.hasHiddenConnections)) {
38206         return "connected_to_hidden";
38207       } else if (selectedIDs.some(incompleteRelation)) {
38208         return "incomplete_relation";
38209       }
38210       return false;
38211       function someMissing() {
38212         if (context.inIntro())
38213           return false;
38214         var osm = context.connection();
38215         if (osm) {
38216           var missing = coords.filter(function(loc) {
38217             return !osm.isDataLoaded(loc);
38218           });
38219           if (missing.length) {
38220             missing.forEach(function(loc) {
38221               context.loadTileAtLoc(loc);
38222             });
38223             return true;
38224           }
38225         }
38226         return false;
38227       }
38228       function incompleteRelation(id2) {
38229         var entity = context.entity(id2);
38230         return entity.type === "relation" && !entity.isComplete(context.graph());
38231       }
38232     };
38233     operation2.tooltip = function() {
38234       var disable = operation2.disabled();
38235       return disable ? _t.append("operations.rotate." + disable + "." + multi) : _t.append("operations.rotate.description." + multi);
38236     };
38237     operation2.annotation = function() {
38238       return selectedIDs.length === 1 ? _t("operations.rotate.annotation." + context.graph().geometry(selectedIDs[0])) : _t("operations.rotate.annotation.feature", { n: selectedIDs.length });
38239     };
38240     operation2.id = "rotate";
38241     operation2.keys = [_t("operations.rotate.key")];
38242     operation2.title = _t.append("operations.rotate.title");
38243     operation2.behavior = behaviorOperation(context).which(operation2);
38244     operation2.mouseOnly = true;
38245     return operation2;
38246   }
38247
38248   // modules/modes/move.js
38249   function modeMove(context, entityIDs, baseGraph) {
38250     var _tolerancePx = 4;
38251     var mode = {
38252       id: "move",
38253       button: "browse"
38254     };
38255     var keybinding = utilKeybinding("move");
38256     var behaviors = [
38257       behaviorEdit(context),
38258       operationCircularize(context, entityIDs).behavior,
38259       operationDelete(context, entityIDs).behavior,
38260       operationOrthogonalize(context, entityIDs).behavior,
38261       operationReflectLong(context, entityIDs).behavior,
38262       operationReflectShort(context, entityIDs).behavior,
38263       operationRotate(context, entityIDs).behavior
38264     ];
38265     var annotation = entityIDs.length === 1 ? _t("operations.move.annotation." + context.graph().geometry(entityIDs[0])) : _t("operations.move.annotation.feature", { n: entityIDs.length });
38266     var _prevGraph;
38267     var _cache5;
38268     var _origin;
38269     var _nudgeInterval;
38270     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
38271     function doMove(nudge) {
38272       nudge = nudge || [0, 0];
38273       var fn;
38274       if (_prevGraph !== context.graph()) {
38275         _cache5 = {};
38276         _origin = context.map().mouseCoordinates();
38277         fn = context.perform;
38278       } else {
38279         fn = context.overwrite;
38280       }
38281       var currMouse = context.map().mouse();
38282       var origMouse = context.projection(_origin);
38283       var delta = geoVecSubtract(geoVecSubtract(currMouse, origMouse), nudge);
38284       fn(actionMove(entityIDs, delta, context.projection, _cache5));
38285       _prevGraph = context.graph();
38286     }
38287     function startNudge(nudge) {
38288       if (_nudgeInterval)
38289         window.clearInterval(_nudgeInterval);
38290       _nudgeInterval = window.setInterval(function() {
38291         context.map().pan(nudge);
38292         doMove(nudge);
38293       }, 50);
38294     }
38295     function stopNudge() {
38296       if (_nudgeInterval) {
38297         window.clearInterval(_nudgeInterval);
38298         _nudgeInterval = null;
38299       }
38300     }
38301     function move() {
38302       doMove();
38303       var nudge = geoViewportEdge(context.map().mouse(), context.map().dimensions());
38304       if (nudge) {
38305         startNudge(nudge);
38306       } else {
38307         stopNudge();
38308       }
38309     }
38310     function finish(d3_event) {
38311       d3_event.stopPropagation();
38312       context.replace(actionNoop(), annotation);
38313       context.enter(modeSelect(context, entityIDs));
38314       stopNudge();
38315     }
38316     function cancel() {
38317       if (baseGraph) {
38318         while (context.graph() !== baseGraph)
38319           context.pop();
38320         context.enter(modeBrowse(context));
38321       } else {
38322         if (_prevGraph)
38323           context.pop();
38324         context.enter(modeSelect(context, entityIDs));
38325       }
38326       stopNudge();
38327     }
38328     function undone() {
38329       context.enter(modeBrowse(context));
38330     }
38331     mode.enter = function() {
38332       _origin = context.map().mouseCoordinates();
38333       _prevGraph = null;
38334       _cache5 = {};
38335       context.features().forceVisible(entityIDs);
38336       behaviors.forEach(context.install);
38337       var downEvent;
38338       context.surface().on(_pointerPrefix + "down.modeMove", function(d3_event) {
38339         downEvent = d3_event;
38340       });
38341       select_default2(window).on(_pointerPrefix + "move.modeMove", move, true).on(_pointerPrefix + "up.modeMove", function(d3_event) {
38342         if (!downEvent)
38343           return;
38344         var mapNode = context.container().select(".main-map").node();
38345         var pointGetter = utilFastMouse(mapNode);
38346         var p1 = pointGetter(downEvent);
38347         var p2 = pointGetter(d3_event);
38348         var dist = geoVecLength(p1, p2);
38349         if (dist <= _tolerancePx)
38350           finish(d3_event);
38351         downEvent = null;
38352       }, true);
38353       context.history().on("undone.modeMove", undone);
38354       keybinding.on("\u238B", cancel).on("\u21A9", finish);
38355       select_default2(document).call(keybinding);
38356     };
38357     mode.exit = function() {
38358       stopNudge();
38359       behaviors.forEach(function(behavior) {
38360         context.uninstall(behavior);
38361       });
38362       context.surface().on(_pointerPrefix + "down.modeMove", null);
38363       select_default2(window).on(_pointerPrefix + "move.modeMove", null, true).on(_pointerPrefix + "up.modeMove", null, true);
38364       context.history().on("undone.modeMove", null);
38365       select_default2(document).call(keybinding.unbind);
38366       context.features().forceVisible([]);
38367     };
38368     mode.selectedIDs = function() {
38369       if (!arguments.length)
38370         return entityIDs;
38371       return mode;
38372     };
38373     return mode;
38374   }
38375
38376   // modules/behavior/paste.js
38377   function behaviorPaste(context) {
38378     function doPaste(d3_event) {
38379       if (!context.map().withinEditableZoom())
38380         return;
38381       d3_event.preventDefault();
38382       var baseGraph = context.graph();
38383       var mouse = context.map().mouse();
38384       var projection2 = context.projection;
38385       var viewport = geoExtent(projection2.clipExtent()).polygon();
38386       if (!geoPointInPolygon(mouse, viewport))
38387         return;
38388       var oldIDs = context.copyIDs();
38389       if (!oldIDs.length)
38390         return;
38391       var extent = geoExtent();
38392       var oldGraph = context.copyGraph();
38393       var newIDs = [];
38394       var action = actionCopyEntities(oldIDs, oldGraph);
38395       context.perform(action);
38396       var copies = action.copies();
38397       var originals = /* @__PURE__ */ new Set();
38398       Object.values(copies).forEach(function(entity) {
38399         originals.add(entity.id);
38400       });
38401       for (var id2 in copies) {
38402         var oldEntity = oldGraph.entity(id2);
38403         var newEntity = copies[id2];
38404         extent._extend(oldEntity.extent(oldGraph));
38405         var parents = context.graph().parentWays(newEntity);
38406         var parentCopied = parents.some(function(parent) {
38407           return originals.has(parent.id);
38408         });
38409         if (!parentCopied) {
38410           newIDs.push(newEntity.id);
38411         }
38412       }
38413       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
38414       var delta = geoVecSubtract(mouse, copyPoint);
38415       context.perform(actionMove(newIDs, delta, projection2));
38416       context.enter(modeMove(context, newIDs, baseGraph));
38417     }
38418     function behavior() {
38419       context.keybinding().on(uiCmd("\u2318V"), doPaste);
38420       return behavior;
38421     }
38422     behavior.off = function() {
38423       context.keybinding().off(uiCmd("\u2318V"));
38424     };
38425     return behavior;
38426   }
38427
38428   // modules/behavior/drag.js
38429   function behaviorDrag() {
38430     var dispatch14 = dispatch_default("start", "move", "end");
38431     var _tolerancePx = 1;
38432     var _penTolerancePx = 4;
38433     var _origin = null;
38434     var _selector = "";
38435     var _targetNode;
38436     var _targetEntity;
38437     var _surface;
38438     var _pointerId;
38439     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
38440     var d3_event_userSelectProperty = utilPrefixCSSProperty("UserSelect");
38441     var d3_event_userSelectSuppress = function() {
38442       var selection2 = selection_default();
38443       var select = selection2.style(d3_event_userSelectProperty);
38444       selection2.style(d3_event_userSelectProperty, "none");
38445       return function() {
38446         selection2.style(d3_event_userSelectProperty, select);
38447       };
38448     };
38449     function pointerdown(d3_event) {
38450       if (_pointerId)
38451         return;
38452       _pointerId = d3_event.pointerId || "mouse";
38453       _targetNode = this;
38454       var pointerLocGetter = utilFastMouse(_surface || _targetNode.parentNode);
38455       var offset;
38456       var startOrigin = pointerLocGetter(d3_event);
38457       var started = false;
38458       var selectEnable = d3_event_userSelectSuppress();
38459       select_default2(window).on(_pointerPrefix + "move.drag", pointermove).on(_pointerPrefix + "up.drag pointercancel.drag", pointerup, true);
38460       if (_origin) {
38461         offset = _origin.call(_targetNode, _targetEntity);
38462         offset = [offset[0] - startOrigin[0], offset[1] - startOrigin[1]];
38463       } else {
38464         offset = [0, 0];
38465       }
38466       d3_event.stopPropagation();
38467       function pointermove(d3_event2) {
38468         if (_pointerId !== (d3_event2.pointerId || "mouse"))
38469           return;
38470         var p2 = pointerLocGetter(d3_event2);
38471         if (!started) {
38472           var dist = geoVecLength(startOrigin, p2);
38473           var tolerance = d3_event2.pointerType === "pen" ? _penTolerancePx : _tolerancePx;
38474           if (dist < tolerance)
38475             return;
38476           started = true;
38477           dispatch14.call("start", this, d3_event2, _targetEntity);
38478         } else {
38479           startOrigin = p2;
38480           d3_event2.stopPropagation();
38481           d3_event2.preventDefault();
38482           var dx = p2[0] - startOrigin[0];
38483           var dy = p2[1] - startOrigin[1];
38484           dispatch14.call("move", this, d3_event2, _targetEntity, [p2[0] + offset[0], p2[1] + offset[1]], [dx, dy]);
38485         }
38486       }
38487       function pointerup(d3_event2) {
38488         if (_pointerId !== (d3_event2.pointerId || "mouse"))
38489           return;
38490         _pointerId = null;
38491         if (started) {
38492           dispatch14.call("end", this, d3_event2, _targetEntity);
38493           d3_event2.preventDefault();
38494         }
38495         select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
38496         selectEnable();
38497       }
38498     }
38499     function behavior(selection2) {
38500       var matchesSelector = utilPrefixDOMProperty("matchesSelector");
38501       var delegate = pointerdown;
38502       if (_selector) {
38503         delegate = function(d3_event) {
38504           var root3 = this;
38505           var target = d3_event.target;
38506           for (; target && target !== root3; target = target.parentNode) {
38507             var datum2 = target.__data__;
38508             _targetEntity = datum2 instanceof osmNote ? datum2 : datum2 && datum2.properties && datum2.properties.entity;
38509             if (_targetEntity && target[matchesSelector](_selector)) {
38510               return pointerdown.call(target, d3_event);
38511             }
38512           }
38513         };
38514       }
38515       selection2.on(_pointerPrefix + "down.drag" + _selector, delegate);
38516     }
38517     behavior.off = function(selection2) {
38518       selection2.on(_pointerPrefix + "down.drag" + _selector, null);
38519     };
38520     behavior.selector = function(_2) {
38521       if (!arguments.length)
38522         return _selector;
38523       _selector = _2;
38524       return behavior;
38525     };
38526     behavior.origin = function(_2) {
38527       if (!arguments.length)
38528         return _origin;
38529       _origin = _2;
38530       return behavior;
38531     };
38532     behavior.cancel = function() {
38533       select_default2(window).on(_pointerPrefix + "move.drag", null).on(_pointerPrefix + "up.drag pointercancel.drag", null);
38534       return behavior;
38535     };
38536     behavior.targetNode = function(_2) {
38537       if (!arguments.length)
38538         return _targetNode;
38539       _targetNode = _2;
38540       return behavior;
38541     };
38542     behavior.targetEntity = function(_2) {
38543       if (!arguments.length)
38544         return _targetEntity;
38545       _targetEntity = _2;
38546       return behavior;
38547     };
38548     behavior.surface = function(_2) {
38549       if (!arguments.length)
38550         return _surface;
38551       _surface = _2;
38552       return behavior;
38553     };
38554     return utilRebind(behavior, dispatch14, "on");
38555   }
38556
38557   // modules/modes/drag_node.js
38558   function modeDragNode(context) {
38559     var mode = {
38560       id: "drag-node",
38561       button: "browse"
38562     };
38563     var hover = behaviorHover(context).altDisables(true).on("hover", context.ui().sidebar.hover);
38564     var edit2 = behaviorEdit(context);
38565     var _nudgeInterval;
38566     var _restoreSelectedIDs = [];
38567     var _wasMidpoint = false;
38568     var _isCancelled = false;
38569     var _activeEntity;
38570     var _startLoc;
38571     var _lastLoc;
38572     function startNudge(d3_event, entity, nudge) {
38573       if (_nudgeInterval)
38574         window.clearInterval(_nudgeInterval);
38575       _nudgeInterval = window.setInterval(function() {
38576         context.map().pan(nudge);
38577         doMove(d3_event, entity, nudge);
38578       }, 50);
38579     }
38580     function stopNudge() {
38581       if (_nudgeInterval) {
38582         window.clearInterval(_nudgeInterval);
38583         _nudgeInterval = null;
38584       }
38585     }
38586     function moveAnnotation(entity) {
38587       return _t("operations.move.annotation." + entity.geometry(context.graph()));
38588     }
38589     function connectAnnotation(nodeEntity, targetEntity) {
38590       var nodeGeometry = nodeEntity.geometry(context.graph());
38591       var targetGeometry = targetEntity.geometry(context.graph());
38592       if (nodeGeometry === "vertex" && targetGeometry === "vertex") {
38593         var nodeParentWayIDs = context.graph().parentWays(nodeEntity);
38594         var targetParentWayIDs = context.graph().parentWays(targetEntity);
38595         var sharedParentWays = utilArrayIntersection(nodeParentWayIDs, targetParentWayIDs);
38596         if (sharedParentWays.length !== 0) {
38597           if (sharedParentWays[0].areAdjacent(nodeEntity.id, targetEntity.id)) {
38598             return _t("operations.connect.annotation.from_vertex.to_adjacent_vertex");
38599           }
38600           return _t("operations.connect.annotation.from_vertex.to_sibling_vertex");
38601         }
38602       }
38603       return _t("operations.connect.annotation.from_" + nodeGeometry + ".to_" + targetGeometry);
38604     }
38605     function shouldSnapToNode(target) {
38606       if (!_activeEntity)
38607         return false;
38608       return _activeEntity.geometry(context.graph()) !== "vertex" || (target.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(target, context.graph()));
38609     }
38610     function origin(entity) {
38611       return context.projection(entity.loc);
38612     }
38613     function keydown(d3_event) {
38614       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
38615         if (context.surface().classed("nope")) {
38616           context.surface().classed("nope-suppressed", true);
38617         }
38618         context.surface().classed("nope", false).classed("nope-disabled", true);
38619       }
38620     }
38621     function keyup(d3_event) {
38622       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
38623         if (context.surface().classed("nope-suppressed")) {
38624           context.surface().classed("nope", true);
38625         }
38626         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
38627       }
38628     }
38629     function start2(d3_event, entity) {
38630       _wasMidpoint = entity.type === "midpoint";
38631       var hasHidden = context.features().hasHiddenConnections(entity, context.graph());
38632       _isCancelled = !context.editable() || d3_event.shiftKey || hasHidden;
38633       if (_isCancelled) {
38634         if (hasHidden) {
38635           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("modes.drag_node.connected_to_hidden"))();
38636         }
38637         return drag.cancel();
38638       }
38639       if (_wasMidpoint) {
38640         var midpoint = entity;
38641         entity = osmNode();
38642         context.perform(actionAddMidpoint(midpoint, entity));
38643         entity = context.entity(entity.id);
38644         var vertex = context.surface().selectAll("." + entity.id);
38645         drag.targetNode(vertex.node()).targetEntity(entity);
38646       } else {
38647         context.perform(actionNoop());
38648       }
38649       _activeEntity = entity;
38650       _startLoc = entity.loc;
38651       hover.ignoreVertex(entity.geometry(context.graph()) === "vertex");
38652       context.surface().selectAll("." + _activeEntity.id).classed("active", true);
38653       context.enter(mode);
38654     }
38655     function datum2(d3_event) {
38656       if (!d3_event || d3_event.altKey) {
38657         return {};
38658       } else {
38659         var d2 = d3_event.target.__data__;
38660         return d2 && d2.properties && d2.properties.target ? d2 : {};
38661       }
38662     }
38663     function doMove(d3_event, entity, nudge) {
38664       nudge = nudge || [0, 0];
38665       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
38666       var currMouse = geoVecSubtract(currPoint, nudge);
38667       var loc = context.projection.invert(currMouse);
38668       var target, edge;
38669       if (!_nudgeInterval) {
38670         var d2 = datum2(d3_event);
38671         target = d2 && d2.properties && d2.properties.entity;
38672         var targetLoc = target && target.loc;
38673         var targetNodes = d2 && d2.properties && d2.properties.nodes;
38674         if (targetLoc) {
38675           if (shouldSnapToNode(target)) {
38676             loc = targetLoc;
38677           }
38678         } else if (targetNodes) {
38679           edge = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, end.id);
38680           if (edge) {
38681             loc = edge.loc;
38682           }
38683         }
38684       }
38685       context.replace(
38686         actionMoveNode(entity.id, loc)
38687       );
38688       var isInvalid = false;
38689       if (target) {
38690         isInvalid = hasRelationConflict(entity, target, edge, context.graph());
38691       }
38692       if (!isInvalid) {
38693         isInvalid = hasInvalidGeometry(entity, context.graph());
38694       }
38695       var nope = context.surface().classed("nope");
38696       if (isInvalid === "relation" || isInvalid === "restriction") {
38697         if (!nope) {
38698           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append(
38699             "operations.connect." + isInvalid,
38700             { relation: _mainPresetIndex.item("type/restriction").name() }
38701           ))();
38702         }
38703       } else if (isInvalid) {
38704         var errorID = isInvalid === "line" ? "lines" : "areas";
38705         context.ui().flash.duration(3e3).iconName("#iD-icon-no").label(_t.append("self_intersection.error." + errorID))();
38706       } else {
38707         if (nope) {
38708           context.ui().flash.duration(1).label("")();
38709         }
38710       }
38711       var nopeDisabled = context.surface().classed("nope-disabled");
38712       if (nopeDisabled) {
38713         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
38714       } else {
38715         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
38716       }
38717       _lastLoc = loc;
38718     }
38719     function hasRelationConflict(entity, target, edge, graph) {
38720       var testGraph = graph.update();
38721       if (edge) {
38722         var midpoint = osmNode();
38723         var action = actionAddMidpoint({
38724           loc: edge.loc,
38725           edge: [target.nodes[edge.index - 1], target.nodes[edge.index]]
38726         }, midpoint);
38727         testGraph = action(testGraph);
38728         target = midpoint;
38729       }
38730       var ids = [entity.id, target.id];
38731       return actionConnect(ids).disabled(testGraph);
38732     }
38733     function hasInvalidGeometry(entity, graph) {
38734       var parents = graph.parentWays(entity);
38735       var i3, j2, k2;
38736       for (i3 = 0; i3 < parents.length; i3++) {
38737         var parent = parents[i3];
38738         var nodes = [];
38739         var activeIndex = null;
38740         var relations = graph.parentRelations(parent);
38741         for (j2 = 0; j2 < relations.length; j2++) {
38742           if (!relations[j2].isMultipolygon())
38743             continue;
38744           var rings = osmJoinWays(relations[j2].members, graph);
38745           for (k2 = 0; k2 < rings.length; k2++) {
38746             nodes = rings[k2].nodes;
38747             if (nodes.find(function(n3) {
38748               return n3.id === entity.id;
38749             })) {
38750               activeIndex = k2;
38751               if (geoHasSelfIntersections(nodes, entity.id)) {
38752                 return "multipolygonMember";
38753               }
38754             }
38755             rings[k2].coords = nodes.map(function(n3) {
38756               return n3.loc;
38757             });
38758           }
38759           for (k2 = 0; k2 < rings.length; k2++) {
38760             if (k2 === activeIndex)
38761               continue;
38762             if (geoHasLineIntersections(rings[activeIndex].nodes, rings[k2].nodes, entity.id)) {
38763               return "multipolygonRing";
38764             }
38765           }
38766         }
38767         if (activeIndex === null) {
38768           nodes = parent.nodes.map(function(nodeID) {
38769             return graph.entity(nodeID);
38770           });
38771           if (nodes.length && geoHasSelfIntersections(nodes, entity.id)) {
38772             return parent.geometry(graph);
38773           }
38774         }
38775       }
38776       return false;
38777     }
38778     function move(d3_event, entity, point2) {
38779       if (_isCancelled)
38780         return;
38781       d3_event.stopPropagation();
38782       context.surface().classed("nope-disabled", d3_event.altKey);
38783       _lastLoc = context.projection.invert(point2);
38784       doMove(d3_event, entity);
38785       var nudge = geoViewportEdge(point2, context.map().dimensions());
38786       if (nudge) {
38787         startNudge(d3_event, entity, nudge);
38788       } else {
38789         stopNudge();
38790       }
38791     }
38792     function end(d3_event, entity) {
38793       if (_isCancelled)
38794         return;
38795       var wasPoint = entity.geometry(context.graph()) === "point";
38796       var d2 = datum2(d3_event);
38797       var nope = d2 && d2.properties && d2.properties.nope || context.surface().classed("nope");
38798       var target = d2 && d2.properties && d2.properties.entity;
38799       if (nope) {
38800         context.perform(
38801           _actionBounceBack(entity.id, _startLoc)
38802         );
38803       } else if (target && target.type === "way") {
38804         var choice = geoChooseEdge(context.graph().childNodes(target), context.map().mouse(), context.projection, entity.id);
38805         context.replace(
38806           actionAddMidpoint({
38807             loc: choice.loc,
38808             edge: [target.nodes[choice.index - 1], target.nodes[choice.index]]
38809           }, entity),
38810           connectAnnotation(entity, target)
38811         );
38812       } else if (target && target.type === "node" && shouldSnapToNode(target)) {
38813         context.replace(
38814           actionConnect([target.id, entity.id]),
38815           connectAnnotation(entity, target)
38816         );
38817       } else if (_wasMidpoint) {
38818         context.replace(
38819           actionNoop(),
38820           _t("operations.add.annotation.vertex")
38821         );
38822       } else {
38823         context.replace(
38824           actionNoop(),
38825           moveAnnotation(entity)
38826         );
38827       }
38828       if (wasPoint) {
38829         context.enter(modeSelect(context, [entity.id]));
38830       } else {
38831         var reselection = _restoreSelectedIDs.filter(function(id2) {
38832           return context.graph().hasEntity(id2);
38833         });
38834         if (reselection.length) {
38835           context.enter(modeSelect(context, reselection));
38836         } else {
38837           context.enter(modeBrowse(context));
38838         }
38839       }
38840     }
38841     function _actionBounceBack(nodeID, toLoc) {
38842       var moveNode = actionMoveNode(nodeID, toLoc);
38843       var action = function(graph, t2) {
38844         if (t2 === 1)
38845           context.pop();
38846         return moveNode(graph, t2);
38847       };
38848       action.transitionable = true;
38849       return action;
38850     }
38851     function cancel() {
38852       drag.cancel();
38853       context.enter(modeBrowse(context));
38854     }
38855     var drag = behaviorDrag().selector(".layer-touch.points .target").surface(context.container().select(".main-map").node()).origin(origin).on("start", start2).on("move", move).on("end", end);
38856     mode.enter = function() {
38857       context.install(hover);
38858       context.install(edit2);
38859       select_default2(window).on("keydown.dragNode", keydown).on("keyup.dragNode", keyup);
38860       context.history().on("undone.drag-node", cancel);
38861     };
38862     mode.exit = function() {
38863       context.ui().sidebar.hover.cancel();
38864       context.uninstall(hover);
38865       context.uninstall(edit2);
38866       select_default2(window).on("keydown.dragNode", null).on("keyup.dragNode", null);
38867       context.history().on("undone.drag-node", null);
38868       _activeEntity = null;
38869       context.surface().classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false).selectAll(".active").classed("active", false);
38870       stopNudge();
38871     };
38872     mode.selectedIDs = function() {
38873       if (!arguments.length)
38874         return _activeEntity ? [_activeEntity.id] : [];
38875       return mode;
38876     };
38877     mode.activeID = function() {
38878       if (!arguments.length)
38879         return _activeEntity && _activeEntity.id;
38880       return mode;
38881     };
38882     mode.restoreSelectedIDs = function(_2) {
38883       if (!arguments.length)
38884         return _restoreSelectedIDs;
38885       _restoreSelectedIDs = _2;
38886       return mode;
38887     };
38888     mode.behavior = drag;
38889     return mode;
38890   }
38891
38892   // modules/services/keepRight.js
38893   var import_rbush = __toESM(require_rbush_min());
38894
38895   // node_modules/d3-fetch/src/text.js
38896   function responseText(response) {
38897     if (!response.ok)
38898       throw new Error(response.status + " " + response.statusText);
38899     return response.text();
38900   }
38901   function text_default3(input, init2) {
38902     return fetch(input, init2).then(responseText);
38903   }
38904
38905   // node_modules/d3-fetch/src/json.js
38906   function responseJson(response) {
38907     if (!response.ok)
38908       throw new Error(response.status + " " + response.statusText);
38909     if (response.status === 204 || response.status === 205)
38910       return;
38911     return response.json();
38912   }
38913   function json_default(input, init2) {
38914     return fetch(input, init2).then(responseJson);
38915   }
38916
38917   // node_modules/d3-fetch/src/xml.js
38918   function parser(type2) {
38919     return (input, init2) => text_default3(input, init2).then((text) => new DOMParser().parseFromString(text, type2));
38920   }
38921   var xml_default = parser("application/xml");
38922   var html = parser("text/html");
38923   var svg = parser("image/svg+xml");
38924
38925   // modules/services/keepRight.js
38926   var tiler = utilTiler();
38927   var dispatch2 = dispatch_default("loaded");
38928   var _tileZoom = 14;
38929   var _krUrlRoot = "https://www.keepright.at";
38930   var _krData = { errorTypes: {}, localizeStrings: {} };
38931   var _cache;
38932   var _krRuleset = [
38933     // no 20 - multiple node on same spot - these are mostly boundaries overlapping roads
38934     30,
38935     40,
38936     50,
38937     60,
38938     70,
38939     90,
38940     100,
38941     110,
38942     120,
38943     130,
38944     150,
38945     160,
38946     170,
38947     180,
38948     190,
38949     191,
38950     192,
38951     193,
38952     194,
38953     195,
38954     196,
38955     197,
38956     198,
38957     200,
38958     201,
38959     202,
38960     203,
38961     204,
38962     205,
38963     206,
38964     207,
38965     208,
38966     210,
38967     220,
38968     230,
38969     231,
38970     232,
38971     270,
38972     280,
38973     281,
38974     282,
38975     283,
38976     284,
38977     285,
38978     290,
38979     291,
38980     292,
38981     293,
38982     294,
38983     295,
38984     296,
38985     297,
38986     298,
38987     300,
38988     310,
38989     311,
38990     312,
38991     313,
38992     320,
38993     350,
38994     360,
38995     370,
38996     380,
38997     390,
38998     400,
38999     401,
39000     402,
39001     410,
39002     411,
39003     412,
39004     413
39005   ];
39006   function abortRequest(controller) {
39007     if (controller) {
39008       controller.abort();
39009     }
39010   }
39011   function abortUnwantedRequests(cache, tiles) {
39012     Object.keys(cache.inflightTile).forEach((k2) => {
39013       const wanted = tiles.find((tile) => k2 === tile.id);
39014       if (!wanted) {
39015         abortRequest(cache.inflightTile[k2]);
39016         delete cache.inflightTile[k2];
39017       }
39018     });
39019   }
39020   function encodeIssueRtree(d2) {
39021     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
39022   }
39023   function updateRtree(item, replace) {
39024     _cache.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
39025     if (replace) {
39026       _cache.rtree.insert(item);
39027     }
39028   }
39029   function tokenReplacements(d2) {
39030     if (!(d2 instanceof QAItem))
39031       return;
39032     const replacements = {};
39033     const issueTemplate = _krData.errorTypes[d2.whichType];
39034     if (!issueTemplate) {
39035       console.log("No Template: ", d2.whichType);
39036       console.log("  ", d2.description);
39037       return;
39038     }
39039     if (!issueTemplate.regex)
39040       return;
39041     const errorRegex = new RegExp(issueTemplate.regex, "i");
39042     const errorMatch = errorRegex.exec(d2.description);
39043     if (!errorMatch) {
39044       console.log("Unmatched: ", d2.whichType);
39045       console.log("  ", d2.description);
39046       console.log("  ", errorRegex);
39047       return;
39048     }
39049     for (let i3 = 1; i3 < errorMatch.length; i3++) {
39050       let capture = errorMatch[i3];
39051       let idType;
39052       idType = "IDs" in issueTemplate ? issueTemplate.IDs[i3 - 1] : "";
39053       if (idType && capture) {
39054         capture = parseError(capture, idType);
39055       } else {
39056         const compare2 = capture.toLowerCase();
39057         if (_krData.localizeStrings[compare2]) {
39058           capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
39059         } else {
39060           capture = unescape_default(capture);
39061         }
39062       }
39063       replacements["var" + i3] = capture;
39064     }
39065     return replacements;
39066   }
39067   function parseError(capture, idType) {
39068     const compare2 = capture.toLowerCase();
39069     if (_krData.localizeStrings[compare2]) {
39070       capture = _t("QA.keepRight.error_parts." + _krData.localizeStrings[compare2]);
39071     }
39072     switch (idType) {
39073       case "this":
39074         capture = linkErrorObject2(capture);
39075         break;
39076       case "url":
39077         capture = linkURL(capture);
39078         break;
39079       case "n":
39080       case "w":
39081       case "r":
39082         capture = linkEntity2(idType + capture);
39083         break;
39084       case "20":
39085         capture = parse20(capture);
39086         break;
39087       case "211":
39088         capture = parse211(capture);
39089         break;
39090       case "231":
39091         capture = parse231(capture);
39092         break;
39093       case "294":
39094         capture = parse294(capture);
39095         break;
39096       case "370":
39097         capture = parse370(capture);
39098         break;
39099     }
39100     return capture;
39101     function linkErrorObject2(d2) {
39102       return { html: '<a class="error_object_link">'.concat(d2, "</a>") };
39103     }
39104     function linkEntity2(d2) {
39105       return { html: '<a class="error_entity_link">'.concat(d2, "</a>") };
39106     }
39107     function linkURL(d2) {
39108       return { html: '<a class="kr_external_link" target="_blank" href="'.concat(d2, '">').concat(d2, "</a>") };
39109     }
39110     function parse211(capture2) {
39111       let newList = [];
39112       const items = capture2.split(", ");
39113       items.forEach((item) => {
39114         let id2 = linkEntity2("n" + item.slice(1));
39115         newList.push(id2);
39116       });
39117       return newList.join(", ");
39118     }
39119     function parse231(capture2) {
39120       let newList = [];
39121       const items = capture2.split("),");
39122       items.forEach((item) => {
39123         const match = item.match(/\#(\d+)\((.+)\)?/);
39124         if (match !== null && match.length > 2) {
39125           newList.push(
39126             linkEntity2("w" + match[1]) + " " + _t("QA.keepRight.errorTypes.231.layer", { layer: match[2] })
39127           );
39128         }
39129       });
39130       return newList.join(", ");
39131     }
39132     function parse294(capture2) {
39133       let newList = [];
39134       const items = capture2.split(",");
39135       items.forEach((item) => {
39136         item = item.split(" ");
39137         const role = '"'.concat(item[0], '"');
39138         const idType2 = item[1].slice(0, 1);
39139         let id2 = item[2].slice(1);
39140         id2 = linkEntity2(idType2 + id2);
39141         newList.push("".concat(role, " ").concat(item[1], " ").concat(id2));
39142       });
39143       return newList.join(", ");
39144     }
39145     function parse370(capture2) {
39146       if (!capture2)
39147         return "";
39148       const match = capture2.match(/\(including the name (\'.+\')\)/);
39149       if (match && match.length) {
39150         return _t("QA.keepRight.errorTypes.370.including_the_name", { name: match[1] });
39151       }
39152       return "";
39153     }
39154     function parse20(capture2) {
39155       let newList = [];
39156       const items = capture2.split(",");
39157       items.forEach((item) => {
39158         const id2 = linkEntity2("n" + item.slice(1));
39159         newList.push(id2);
39160       });
39161       return newList.join(", ");
39162     }
39163   }
39164   var keepRight_default = {
39165     title: "keepRight",
39166     init() {
39167       _mainFileFetcher.get("keepRight").then((d2) => _krData = d2);
39168       if (!_cache) {
39169         this.reset();
39170       }
39171       this.event = utilRebind(this, dispatch2, "on");
39172     },
39173     reset() {
39174       if (_cache) {
39175         Object.values(_cache.inflightTile).forEach(abortRequest);
39176       }
39177       _cache = {
39178         data: {},
39179         loadedTile: {},
39180         inflightTile: {},
39181         inflightPost: {},
39182         closed: {},
39183         rtree: new import_rbush.default()
39184       };
39185     },
39186     // KeepRight API:  http://osm.mueschelsoft.de/keepright/interfacing.php
39187     loadIssues(projection2) {
39188       const options2 = {
39189         format: "geojson",
39190         ch: _krRuleset
39191       };
39192       const tiles = tiler.zoomExtent([_tileZoom, _tileZoom]).getTiles(projection2);
39193       abortUnwantedRequests(_cache, tiles);
39194       tiles.forEach((tile) => {
39195         if (_cache.loadedTile[tile.id] || _cache.inflightTile[tile.id])
39196           return;
39197         const [left, top, right, bottom] = tile.extent.rectangle();
39198         const params = Object.assign({}, options2, { left, bottom, right, top });
39199         const url = "".concat(_krUrlRoot, "/export.php?") + utilQsString(params);
39200         const controller = new AbortController();
39201         _cache.inflightTile[tile.id] = controller;
39202         json_default(url, { signal: controller.signal }).then((data) => {
39203           delete _cache.inflightTile[tile.id];
39204           _cache.loadedTile[tile.id] = true;
39205           if (!data || !data.features || !data.features.length) {
39206             throw new Error("No Data");
39207           }
39208           data.features.forEach((feature3) => {
39209             const {
39210               properties: {
39211                 error_type: itemType,
39212                 error_id: id2,
39213                 comment = null,
39214                 object_id: objectId,
39215                 object_type: objectType,
39216                 schema,
39217                 title
39218               }
39219             } = feature3;
39220             let {
39221               geometry: { coordinates: loc },
39222               properties: { description = "" }
39223             } = feature3;
39224             const issueTemplate = _krData.errorTypes[itemType];
39225             const parentIssueType = (Math.floor(itemType / 10) * 10).toString();
39226             const whichType = issueTemplate ? itemType : parentIssueType;
39227             const whichTemplate = _krData.errorTypes[whichType];
39228             switch (whichType) {
39229               case "170":
39230                 description = "This feature has a FIXME tag: ".concat(description);
39231                 break;
39232               case "292":
39233               case "293":
39234                 description = description.replace("A turn-", "This turn-");
39235                 break;
39236               case "294":
39237               case "295":
39238               case "296":
39239               case "297":
39240               case "298":
39241                 description = "This turn-restriction~".concat(description);
39242                 break;
39243               case "300":
39244                 description = "This highway is missing a maxspeed tag";
39245                 break;
39246               case "411":
39247               case "412":
39248               case "413":
39249                 description = "This feature~".concat(description);
39250                 break;
39251             }
39252             let coincident = false;
39253             do {
39254               let delta = coincident ? [1e-5, 0] : [0, 1e-5];
39255               loc = geoVecAdd(loc, delta);
39256               let bbox2 = geoExtent(loc).bbox();
39257               coincident = _cache.rtree.search(bbox2).length;
39258             } while (coincident);
39259             let d2 = new QAItem(loc, this, itemType, id2, {
39260               comment,
39261               description,
39262               whichType,
39263               parentIssueType,
39264               severity: whichTemplate.severity || "error",
39265               objectId,
39266               objectType,
39267               schema,
39268               title
39269             });
39270             d2.replacements = tokenReplacements(d2);
39271             _cache.data[id2] = d2;
39272             _cache.rtree.insert(encodeIssueRtree(d2));
39273           });
39274           dispatch2.call("loaded");
39275         }).catch(() => {
39276           delete _cache.inflightTile[tile.id];
39277           _cache.loadedTile[tile.id] = true;
39278         });
39279       });
39280     },
39281     postUpdate(d2, callback) {
39282       if (_cache.inflightPost[d2.id]) {
39283         return callback({ message: "Error update already inflight", status: -2 }, d2);
39284       }
39285       const params = { schema: d2.schema, id: d2.id };
39286       if (d2.newStatus) {
39287         params.st = d2.newStatus;
39288       }
39289       if (d2.newComment !== void 0) {
39290         params.co = d2.newComment;
39291       }
39292       const url = "".concat(_krUrlRoot, "/comment.php?") + utilQsString(params);
39293       const controller = new AbortController();
39294       _cache.inflightPost[d2.id] = controller;
39295       json_default(url, { signal: controller.signal }).finally(() => {
39296         delete _cache.inflightPost[d2.id];
39297         if (d2.newStatus === "ignore") {
39298           this.removeItem(d2);
39299         } else if (d2.newStatus === "ignore_t") {
39300           this.removeItem(d2);
39301           _cache.closed["".concat(d2.schema, ":").concat(d2.id)] = true;
39302         } else {
39303           d2 = this.replaceItem(d2.update({
39304             comment: d2.newComment,
39305             newComment: void 0,
39306             newState: void 0
39307           }));
39308         }
39309         if (callback)
39310           callback(null, d2);
39311       });
39312     },
39313     // Get all cached QAItems covering the viewport
39314     getItems(projection2) {
39315       const viewport = projection2.clipExtent();
39316       const min3 = [viewport[0][0], viewport[1][1]];
39317       const max3 = [viewport[1][0], viewport[0][1]];
39318       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
39319       return _cache.rtree.search(bbox2).map((d2) => d2.data);
39320     },
39321     // Get a QAItem from cache
39322     // NOTE: Don't change method name until UI v3 is merged
39323     getError(id2) {
39324       return _cache.data[id2];
39325     },
39326     // Replace a single QAItem in the cache
39327     replaceItem(item) {
39328       if (!(item instanceof QAItem) || !item.id)
39329         return;
39330       _cache.data[item.id] = item;
39331       updateRtree(encodeIssueRtree(item), true);
39332       return item;
39333     },
39334     // Remove a single QAItem from the cache
39335     removeItem(item) {
39336       if (!(item instanceof QAItem) || !item.id)
39337         return;
39338       delete _cache.data[item.id];
39339       updateRtree(encodeIssueRtree(item), false);
39340     },
39341     issueURL(item) {
39342       return "".concat(_krUrlRoot, "/report_map.php?schema=").concat(item.schema, "&error=").concat(item.id);
39343     },
39344     // Get an array of issues closed during this session.
39345     // Used to populate `closed:keepright` changeset tag
39346     getClosedIDs() {
39347       return Object.keys(_cache.closed).sort();
39348     }
39349   };
39350
39351   // modules/services/improveOSM.js
39352   var import_rbush2 = __toESM(require_rbush_min());
39353   var tiler2 = utilTiler();
39354   var dispatch3 = dispatch_default("loaded");
39355   var _tileZoom2 = 14;
39356   var _impOsmUrls = {
39357     ow: "https://grab.community.improve-osm.org/directionOfFlowService",
39358     mr: "https://grab.community.improve-osm.org/missingGeoService",
39359     tr: "https://grab.community.improve-osm.org/turnRestrictionService"
39360   };
39361   var _impOsmData = { icons: {} };
39362   var _cache2;
39363   function abortRequest2(i3) {
39364     Object.values(i3).forEach((controller) => {
39365       if (controller) {
39366         controller.abort();
39367       }
39368     });
39369   }
39370   function abortUnwantedRequests2(cache, tiles) {
39371     Object.keys(cache.inflightTile).forEach((k2) => {
39372       const wanted = tiles.find((tile) => k2 === tile.id);
39373       if (!wanted) {
39374         abortRequest2(cache.inflightTile[k2]);
39375         delete cache.inflightTile[k2];
39376       }
39377     });
39378   }
39379   function encodeIssueRtree2(d2) {
39380     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
39381   }
39382   function updateRtree2(item, replace) {
39383     _cache2.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
39384     if (replace) {
39385       _cache2.rtree.insert(item);
39386     }
39387   }
39388   function linkErrorObject(d2) {
39389     return { html: '<a class="error_object_link">'.concat(d2, "</a>") };
39390   }
39391   function linkEntity(d2) {
39392     return { html: '<a class="error_entity_link">'.concat(d2, "</a>") };
39393   }
39394   function pointAverage(points) {
39395     if (points.length) {
39396       const sum = points.reduce(
39397         (acc, point2) => geoVecAdd(acc, [point2.lon, point2.lat]),
39398         [0, 0]
39399       );
39400       return geoVecScale(sum, 1 / points.length);
39401     } else {
39402       return [0, 0];
39403     }
39404   }
39405   function relativeBearing(p1, p2) {
39406     let angle2 = Math.atan2(p2.lon - p1.lon, p2.lat - p1.lat);
39407     if (angle2 < 0) {
39408       angle2 += 2 * Math.PI;
39409     }
39410     return angle2 * 180 / Math.PI;
39411   }
39412   function cardinalDirection(bearing) {
39413     const dir = 45 * Math.round(bearing / 45);
39414     const compass = {
39415       0: "north",
39416       45: "northeast",
39417       90: "east",
39418       135: "southeast",
39419       180: "south",
39420       225: "southwest",
39421       270: "west",
39422       315: "northwest",
39423       360: "north"
39424     };
39425     return _t("QA.improveOSM.directions.".concat(compass[dir]));
39426   }
39427   function preventCoincident(loc, bumpUp) {
39428     let coincident = false;
39429     do {
39430       let delta = coincident ? [1e-5, 0] : bumpUp ? [0, 1e-5] : [0, 0];
39431       loc = geoVecAdd(loc, delta);
39432       let bbox2 = geoExtent(loc).bbox();
39433       coincident = _cache2.rtree.search(bbox2).length;
39434     } while (coincident);
39435     return loc;
39436   }
39437   var improveOSM_default = {
39438     title: "improveOSM",
39439     init() {
39440       _mainFileFetcher.get("qa_data").then((d2) => _impOsmData = d2.improveOSM);
39441       if (!_cache2) {
39442         this.reset();
39443       }
39444       this.event = utilRebind(this, dispatch3, "on");
39445     },
39446     reset() {
39447       if (_cache2) {
39448         Object.values(_cache2.inflightTile).forEach(abortRequest2);
39449       }
39450       _cache2 = {
39451         data: {},
39452         loadedTile: {},
39453         inflightTile: {},
39454         inflightPost: {},
39455         closed: {},
39456         rtree: new import_rbush2.default()
39457       };
39458     },
39459     loadIssues(projection2) {
39460       const options2 = {
39461         client: "iD",
39462         status: "OPEN",
39463         zoom: "19"
39464         // Use a high zoom so that clusters aren't returned
39465       };
39466       const tiles = tiler2.zoomExtent([_tileZoom2, _tileZoom2]).getTiles(projection2);
39467       abortUnwantedRequests2(_cache2, tiles);
39468       tiles.forEach((tile) => {
39469         if (_cache2.loadedTile[tile.id] || _cache2.inflightTile[tile.id])
39470           return;
39471         const [east, north, west, south] = tile.extent.rectangle();
39472         const params = Object.assign({}, options2, { east, south, west, north });
39473         const requests = {};
39474         Object.keys(_impOsmUrls).forEach((k2) => {
39475           const kParams = Object.assign(
39476             {},
39477             params,
39478             k2 === "mr" ? { type: "PARKING,ROAD,BOTH,PATH" } : { confidenceLevel: "C1" }
39479           );
39480           const url = "".concat(_impOsmUrls[k2], "/search?") + utilQsString(kParams);
39481           const controller = new AbortController();
39482           requests[k2] = controller;
39483           json_default(url, { signal: controller.signal }).then((data) => {
39484             delete _cache2.inflightTile[tile.id][k2];
39485             if (!Object.keys(_cache2.inflightTile[tile.id]).length) {
39486               delete _cache2.inflightTile[tile.id];
39487               _cache2.loadedTile[tile.id] = true;
39488             }
39489             if (data.roadSegments) {
39490               data.roadSegments.forEach((feature3) => {
39491                 const { points, wayId, fromNodeId, toNodeId } = feature3;
39492                 const itemId = "".concat(wayId).concat(fromNodeId).concat(toNodeId);
39493                 let mid = points.length / 2;
39494                 let loc;
39495                 if (mid % 1 === 0) {
39496                   loc = pointAverage([points[mid - 1], points[mid]]);
39497                 } else {
39498                   mid = points[Math.floor(mid)];
39499                   loc = [mid.lon, mid.lat];
39500                 }
39501                 loc = preventCoincident(loc, false);
39502                 let d2 = new QAItem(loc, this, k2, itemId, {
39503                   issueKey: k2,
39504                   // used as a category
39505                   identifier: {
39506                     // used to post changes
39507                     wayId,
39508                     fromNodeId,
39509                     toNodeId
39510                   },
39511                   objectId: wayId,
39512                   objectType: "way"
39513                 });
39514                 d2.replacements = {
39515                   percentage: feature3.percentOfTrips,
39516                   num_trips: feature3.numberOfTrips,
39517                   highway: linkErrorObject(_t("QA.keepRight.error_parts.highway")),
39518                   from_node: linkEntity("n" + feature3.fromNodeId),
39519                   to_node: linkEntity("n" + feature3.toNodeId)
39520                 };
39521                 _cache2.data[d2.id] = d2;
39522                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39523               });
39524             }
39525             if (data.tiles) {
39526               data.tiles.forEach((feature3) => {
39527                 const { type: type2, x: x2, y: y2, numberOfTrips } = feature3;
39528                 const geoType = type2.toLowerCase();
39529                 const itemId = "".concat(geoType).concat(x2).concat(y2).concat(numberOfTrips);
39530                 let loc = pointAverage(feature3.points);
39531                 loc = preventCoincident(loc, false);
39532                 let d2 = new QAItem(loc, this, "".concat(k2, "-").concat(geoType), itemId, {
39533                   issueKey: k2,
39534                   identifier: { x: x2, y: y2 }
39535                 });
39536                 d2.replacements = {
39537                   num_trips: numberOfTrips,
39538                   geometry_type: _t("QA.improveOSM.geometry_types.".concat(geoType))
39539                 };
39540                 if (numberOfTrips === -1) {
39541                   d2.desc = _t("QA.improveOSM.error_types.mr.description_alt", d2.replacements);
39542                 }
39543                 _cache2.data[d2.id] = d2;
39544                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39545               });
39546             }
39547             if (data.entities) {
39548               data.entities.forEach((feature3) => {
39549                 const { point: point2, id: id2, segments, numberOfPasses, turnType } = feature3;
39550                 const itemId = "".concat(id2.replace(/[,:+#]/g, "_"));
39551                 const loc = preventCoincident([point2.lon, point2.lat], true);
39552                 const ids = id2.split(",");
39553                 const from_way = ids[0];
39554                 const via_node = ids[3];
39555                 const to_way = ids[2].split(":")[1];
39556                 let d2 = new QAItem(loc, this, k2, itemId, {
39557                   issueKey: k2,
39558                   identifier: id2,
39559                   objectId: via_node,
39560                   objectType: "node"
39561                 });
39562                 const [p1, p2] = segments[0].points;
39563                 const dir_of_travel = cardinalDirection(relativeBearing(p1, p2));
39564                 d2.replacements = {
39565                   num_passed: numberOfPasses,
39566                   num_trips: segments[0].numberOfTrips,
39567                   turn_restriction: turnType.toLowerCase(),
39568                   from_way: linkEntity("w" + from_way),
39569                   to_way: linkEntity("w" + to_way),
39570                   travel_direction: dir_of_travel,
39571                   junction: linkErrorObject(_t("QA.keepRight.error_parts.this_node"))
39572                 };
39573                 _cache2.data[d2.id] = d2;
39574                 _cache2.rtree.insert(encodeIssueRtree2(d2));
39575                 dispatch3.call("loaded");
39576               });
39577             }
39578           }).catch(() => {
39579             delete _cache2.inflightTile[tile.id][k2];
39580             if (!Object.keys(_cache2.inflightTile[tile.id]).length) {
39581               delete _cache2.inflightTile[tile.id];
39582               _cache2.loadedTile[tile.id] = true;
39583             }
39584           });
39585         });
39586         _cache2.inflightTile[tile.id] = requests;
39587       });
39588     },
39589     getComments(item) {
39590       if (item.comments) {
39591         return Promise.resolve(item);
39592       }
39593       const key = item.issueKey;
39594       let qParams = {};
39595       if (key === "ow") {
39596         qParams = item.identifier;
39597       } else if (key === "mr") {
39598         qParams.tileX = item.identifier.x;
39599         qParams.tileY = item.identifier.y;
39600       } else if (key === "tr") {
39601         qParams.targetId = item.identifier;
39602       }
39603       const url = "".concat(_impOsmUrls[key], "/retrieveComments?") + utilQsString(qParams);
39604       const cacheComments = (data) => {
39605         item.comments = data.comments ? data.comments.reverse() : [];
39606         this.replaceItem(item);
39607       };
39608       return json_default(url).then(cacheComments).then(() => item);
39609     },
39610     postUpdate(d2, callback) {
39611       if (!osm_default.authenticated()) {
39612         return callback({ message: "Not Authenticated", status: -3 }, d2);
39613       }
39614       if (_cache2.inflightPost[d2.id]) {
39615         return callback({ message: "Error update already inflight", status: -2 }, d2);
39616       }
39617       osm_default.userDetails(sendPayload.bind(this));
39618       function sendPayload(err, user) {
39619         if (err) {
39620           return callback(err, d2);
39621         }
39622         const key = d2.issueKey;
39623         const url = "".concat(_impOsmUrls[key], "/comment");
39624         const payload = {
39625           username: user.display_name,
39626           targetIds: [d2.identifier]
39627         };
39628         if (d2.newStatus) {
39629           payload.status = d2.newStatus;
39630           payload.text = "status changed";
39631         }
39632         if (d2.newComment) {
39633           payload.text = d2.newComment;
39634         }
39635         const controller = new AbortController();
39636         _cache2.inflightPost[d2.id] = controller;
39637         const options2 = {
39638           method: "POST",
39639           signal: controller.signal,
39640           body: JSON.stringify(payload)
39641         };
39642         json_default(url, options2).then(() => {
39643           delete _cache2.inflightPost[d2.id];
39644           if (!d2.newStatus) {
39645             const now3 = /* @__PURE__ */ new Date();
39646             let comments = d2.comments ? d2.comments : [];
39647             comments.push({
39648               username: payload.username,
39649               text: payload.text,
39650               timestamp: now3.getTime() / 1e3
39651             });
39652             this.replaceItem(d2.update({
39653               comments,
39654               newComment: void 0
39655             }));
39656           } else {
39657             this.removeItem(d2);
39658             if (d2.newStatus === "SOLVED") {
39659               if (!(d2.issueKey in _cache2.closed)) {
39660                 _cache2.closed[d2.issueKey] = 0;
39661               }
39662               _cache2.closed[d2.issueKey] += 1;
39663             }
39664           }
39665           if (callback)
39666             callback(null, d2);
39667         }).catch((err2) => {
39668           delete _cache2.inflightPost[d2.id];
39669           if (callback)
39670             callback(err2.message);
39671         });
39672       }
39673     },
39674     // Get all cached QAItems covering the viewport
39675     getItems(projection2) {
39676       const viewport = projection2.clipExtent();
39677       const min3 = [viewport[0][0], viewport[1][1]];
39678       const max3 = [viewport[1][0], viewport[0][1]];
39679       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
39680       return _cache2.rtree.search(bbox2).map((d2) => d2.data);
39681     },
39682     // Get a QAItem from cache
39683     // NOTE: Don't change method name until UI v3 is merged
39684     getError(id2) {
39685       return _cache2.data[id2];
39686     },
39687     // get the name of the icon to display for this item
39688     getIcon(itemType) {
39689       return _impOsmData.icons[itemType];
39690     },
39691     // Replace a single QAItem in the cache
39692     replaceItem(issue) {
39693       if (!(issue instanceof QAItem) || !issue.id)
39694         return;
39695       _cache2.data[issue.id] = issue;
39696       updateRtree2(encodeIssueRtree2(issue), true);
39697       return issue;
39698     },
39699     // Remove a single QAItem from the cache
39700     removeItem(issue) {
39701       if (!(issue instanceof QAItem) || !issue.id)
39702         return;
39703       delete _cache2.data[issue.id];
39704       updateRtree2(encodeIssueRtree2(issue), false);
39705     },
39706     // Used to populate `closed:improveosm:*` changeset tags
39707     getClosedCounts() {
39708       return _cache2.closed;
39709     }
39710   };
39711
39712   // modules/services/osmose.js
39713   var import_rbush3 = __toESM(require_rbush_min());
39714
39715   // node_modules/marked/lib/marked.esm.js
39716   function _getDefaults() {
39717     return {
39718       async: false,
39719       breaks: false,
39720       extensions: null,
39721       gfm: true,
39722       hooks: null,
39723       pedantic: false,
39724       renderer: null,
39725       silent: false,
39726       tokenizer: null,
39727       walkTokens: null
39728     };
39729   }
39730   var _defaults = _getDefaults();
39731   function changeDefaults(newDefaults) {
39732     _defaults = newDefaults;
39733   }
39734   var escapeTest = /[&<>"']/;
39735   var escapeReplace = new RegExp(escapeTest.source, "g");
39736   var escapeTestNoEncode = /[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/;
39737   var escapeReplaceNoEncode = new RegExp(escapeTestNoEncode.source, "g");
39738   var escapeReplacements = {
39739     "&": "&amp;",
39740     "<": "&lt;",
39741     ">": "&gt;",
39742     '"': "&quot;",
39743     "'": "&#39;"
39744   };
39745   var getEscapeReplacement = (ch) => escapeReplacements[ch];
39746   function escape$1(html3, encode) {
39747     if (encode) {
39748       if (escapeTest.test(html3)) {
39749         return html3.replace(escapeReplace, getEscapeReplacement);
39750       }
39751     } else {
39752       if (escapeTestNoEncode.test(html3)) {
39753         return html3.replace(escapeReplaceNoEncode, getEscapeReplacement);
39754       }
39755     }
39756     return html3;
39757   }
39758   var unescapeTest = /&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig;
39759   function unescape2(html3) {
39760     return html3.replace(unescapeTest, (_2, n3) => {
39761       n3 = n3.toLowerCase();
39762       if (n3 === "colon")
39763         return ":";
39764       if (n3.charAt(0) === "#") {
39765         return n3.charAt(1) === "x" ? String.fromCharCode(parseInt(n3.substring(2), 16)) : String.fromCharCode(+n3.substring(1));
39766       }
39767       return "";
39768     });
39769   }
39770   var caret = /(^|[^\[])\^/g;
39771   function edit(regex, opt) {
39772     let source = typeof regex === "string" ? regex : regex.source;
39773     opt = opt || "";
39774     const obj = {
39775       replace: (name, val) => {
39776         let valSource = typeof val === "string" ? val : val.source;
39777         valSource = valSource.replace(caret, "$1");
39778         source = source.replace(name, valSource);
39779         return obj;
39780       },
39781       getRegex: () => {
39782         return new RegExp(source, opt);
39783       }
39784     };
39785     return obj;
39786   }
39787   function cleanUrl(href) {
39788     try {
39789       href = encodeURI(href).replace(/%25/g, "%");
39790     } catch (e3) {
39791       return null;
39792     }
39793     return href;
39794   }
39795   var noopTest = { exec: () => null };
39796   function splitCells(tableRow, count) {
39797     const row = tableRow.replace(/\|/g, (match, offset, str) => {
39798       let escaped = false;
39799       let curr = offset;
39800       while (--curr >= 0 && str[curr] === "\\")
39801         escaped = !escaped;
39802       if (escaped) {
39803         return "|";
39804       } else {
39805         return " |";
39806       }
39807     }), cells = row.split(/ \|/);
39808     let i3 = 0;
39809     if (!cells[0].trim()) {
39810       cells.shift();
39811     }
39812     if (cells.length > 0 && !cells[cells.length - 1].trim()) {
39813       cells.pop();
39814     }
39815     if (count) {
39816       if (cells.length > count) {
39817         cells.splice(count);
39818       } else {
39819         while (cells.length < count)
39820           cells.push("");
39821       }
39822     }
39823     for (; i3 < cells.length; i3++) {
39824       cells[i3] = cells[i3].trim().replace(/\\\|/g, "|");
39825     }
39826     return cells;
39827   }
39828   function rtrim(str, c2, invert) {
39829     const l2 = str.length;
39830     if (l2 === 0) {
39831       return "";
39832     }
39833     let suffLen = 0;
39834     while (suffLen < l2) {
39835       const currChar = str.charAt(l2 - suffLen - 1);
39836       if (currChar === c2 && !invert) {
39837         suffLen++;
39838       } else if (currChar !== c2 && invert) {
39839         suffLen++;
39840       } else {
39841         break;
39842       }
39843     }
39844     return str.slice(0, l2 - suffLen);
39845   }
39846   function findClosingBracket(str, b2) {
39847     if (str.indexOf(b2[1]) === -1) {
39848       return -1;
39849     }
39850     let level = 0;
39851     for (let i3 = 0; i3 < str.length; i3++) {
39852       if (str[i3] === "\\") {
39853         i3++;
39854       } else if (str[i3] === b2[0]) {
39855         level++;
39856       } else if (str[i3] === b2[1]) {
39857         level--;
39858         if (level < 0) {
39859           return i3;
39860         }
39861       }
39862     }
39863     return -1;
39864   }
39865   function outputLink(cap, link3, raw, lexer2) {
39866     const href = link3.href;
39867     const title = link3.title ? escape$1(link3.title) : null;
39868     const text = cap[1].replace(/\\([\[\]])/g, "$1");
39869     if (cap[0].charAt(0) !== "!") {
39870       lexer2.state.inLink = true;
39871       const token = {
39872         type: "link",
39873         raw,
39874         href,
39875         title,
39876         text,
39877         tokens: lexer2.inlineTokens(text)
39878       };
39879       lexer2.state.inLink = false;
39880       return token;
39881     }
39882     return {
39883       type: "image",
39884       raw,
39885       href,
39886       title,
39887       text: escape$1(text)
39888     };
39889   }
39890   function indentCodeCompensation(raw, text) {
39891     const matchIndentToCode = raw.match(/^(\s+)(?:```)/);
39892     if (matchIndentToCode === null) {
39893       return text;
39894     }
39895     const indentToCode = matchIndentToCode[1];
39896     return text.split("\n").map((node) => {
39897       const matchIndentInNode = node.match(/^\s+/);
39898       if (matchIndentInNode === null) {
39899         return node;
39900       }
39901       const [indentInNode] = matchIndentInNode;
39902       if (indentInNode.length >= indentToCode.length) {
39903         return node.slice(indentToCode.length);
39904       }
39905       return node;
39906     }).join("\n");
39907   }
39908   var _Tokenizer = class {
39909     // set by the lexer
39910     constructor(options2) {
39911       __publicField(this, "options");
39912       __publicField(this, "rules");
39913       // set by the lexer
39914       __publicField(this, "lexer");
39915       this.options = options2 || _defaults;
39916     }
39917     space(src) {
39918       const cap = this.rules.block.newline.exec(src);
39919       if (cap && cap[0].length > 0) {
39920         return {
39921           type: "space",
39922           raw: cap[0]
39923         };
39924       }
39925     }
39926     code(src) {
39927       const cap = this.rules.block.code.exec(src);
39928       if (cap) {
39929         const text = cap[0].replace(/^ {1,4}/gm, "");
39930         return {
39931           type: "code",
39932           raw: cap[0],
39933           codeBlockStyle: "indented",
39934           text: !this.options.pedantic ? rtrim(text, "\n") : text
39935         };
39936       }
39937     }
39938     fences(src) {
39939       const cap = this.rules.block.fences.exec(src);
39940       if (cap) {
39941         const raw = cap[0];
39942         const text = indentCodeCompensation(raw, cap[3] || "");
39943         return {
39944           type: "code",
39945           raw,
39946           lang: cap[2] ? cap[2].trim().replace(this.rules.inline.anyPunctuation, "$1") : cap[2],
39947           text
39948         };
39949       }
39950     }
39951     heading(src) {
39952       const cap = this.rules.block.heading.exec(src);
39953       if (cap) {
39954         let text = cap[2].trim();
39955         if (/#$/.test(text)) {
39956           const trimmed = rtrim(text, "#");
39957           if (this.options.pedantic) {
39958             text = trimmed.trim();
39959           } else if (!trimmed || / $/.test(trimmed)) {
39960             text = trimmed.trim();
39961           }
39962         }
39963         return {
39964           type: "heading",
39965           raw: cap[0],
39966           depth: cap[1].length,
39967           text,
39968           tokens: this.lexer.inline(text)
39969         };
39970       }
39971     }
39972     hr(src) {
39973       const cap = this.rules.block.hr.exec(src);
39974       if (cap) {
39975         return {
39976           type: "hr",
39977           raw: cap[0]
39978         };
39979       }
39980     }
39981     blockquote(src) {
39982       const cap = this.rules.block.blockquote.exec(src);
39983       if (cap) {
39984         const text = rtrim(cap[0].replace(/^ *>[ \t]?/gm, ""), "\n");
39985         const top = this.lexer.state.top;
39986         this.lexer.state.top = true;
39987         const tokens = this.lexer.blockTokens(text);
39988         this.lexer.state.top = top;
39989         return {
39990           type: "blockquote",
39991           raw: cap[0],
39992           tokens,
39993           text
39994         };
39995       }
39996     }
39997     list(src) {
39998       let cap = this.rules.block.list.exec(src);
39999       if (cap) {
40000         let bull = cap[1].trim();
40001         const isordered = bull.length > 1;
40002         const list2 = {
40003           type: "list",
40004           raw: "",
40005           ordered: isordered,
40006           start: isordered ? +bull.slice(0, -1) : "",
40007           loose: false,
40008           items: []
40009         };
40010         bull = isordered ? "\\d{1,9}\\".concat(bull.slice(-1)) : "\\".concat(bull);
40011         if (this.options.pedantic) {
40012           bull = isordered ? bull : "[*+-]";
40013         }
40014         const itemRegex = new RegExp("^( {0,3}".concat(bull, ")((?:[     ][^\\n]*)?(?:\\n|$))"));
40015         let raw = "";
40016         let itemContents = "";
40017         let endsWithBlankLine = false;
40018         while (src) {
40019           let endEarly = false;
40020           if (!(cap = itemRegex.exec(src))) {
40021             break;
40022           }
40023           if (this.rules.block.hr.test(src)) {
40024             break;
40025           }
40026           raw = cap[0];
40027           src = src.substring(raw.length);
40028           let line = cap[2].split("\n", 1)[0].replace(/^\t+/, (t2) => " ".repeat(3 * t2.length));
40029           let nextLine = src.split("\n", 1)[0];
40030           let indent = 0;
40031           if (this.options.pedantic) {
40032             indent = 2;
40033             itemContents = line.trimStart();
40034           } else {
40035             indent = cap[2].search(/[^ ]/);
40036             indent = indent > 4 ? 1 : indent;
40037             itemContents = line.slice(indent);
40038             indent += cap[1].length;
40039           }
40040           let blankLine = false;
40041           if (!line && /^ *$/.test(nextLine)) {
40042             raw += nextLine + "\n";
40043             src = src.substring(nextLine.length + 1);
40044             endEarly = true;
40045           }
40046           if (!endEarly) {
40047             const nextBulletRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:[*+-]|\\d{1,9}[.)])((?:[    ][^\\n]*)?(?:\\n|$))"));
40048             const hrRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)"));
40049             const fencesBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}(?:```|~~~)"));
40050             const headingBeginRegex = new RegExp("^ {0,".concat(Math.min(3, indent - 1), "}#"));
40051             while (src) {
40052               const rawLine = src.split("\n", 1)[0];
40053               nextLine = rawLine;
40054               if (this.options.pedantic) {
40055                 nextLine = nextLine.replace(/^ {1,4}(?=( {4})*[^ ])/g, "  ");
40056               }
40057               if (fencesBeginRegex.test(nextLine)) {
40058                 break;
40059               }
40060               if (headingBeginRegex.test(nextLine)) {
40061                 break;
40062               }
40063               if (nextBulletRegex.test(nextLine)) {
40064                 break;
40065               }
40066               if (hrRegex.test(src)) {
40067                 break;
40068               }
40069               if (nextLine.search(/[^ ]/) >= indent || !nextLine.trim()) {
40070                 itemContents += "\n" + nextLine.slice(indent);
40071               } else {
40072                 if (blankLine) {
40073                   break;
40074                 }
40075                 if (line.search(/[^ ]/) >= 4) {
40076                   break;
40077                 }
40078                 if (fencesBeginRegex.test(line)) {
40079                   break;
40080                 }
40081                 if (headingBeginRegex.test(line)) {
40082                   break;
40083                 }
40084                 if (hrRegex.test(line)) {
40085                   break;
40086                 }
40087                 itemContents += "\n" + nextLine;
40088               }
40089               if (!blankLine && !nextLine.trim()) {
40090                 blankLine = true;
40091               }
40092               raw += rawLine + "\n";
40093               src = src.substring(rawLine.length + 1);
40094               line = nextLine.slice(indent);
40095             }
40096           }
40097           if (!list2.loose) {
40098             if (endsWithBlankLine) {
40099               list2.loose = true;
40100             } else if (/\n *\n *$/.test(raw)) {
40101               endsWithBlankLine = true;
40102             }
40103           }
40104           let istask = null;
40105           let ischecked;
40106           if (this.options.gfm) {
40107             istask = /^\[[ xX]\] /.exec(itemContents);
40108             if (istask) {
40109               ischecked = istask[0] !== "[ ] ";
40110               itemContents = itemContents.replace(/^\[[ xX]\] +/, "");
40111             }
40112           }
40113           list2.items.push({
40114             type: "list_item",
40115             raw,
40116             task: !!istask,
40117             checked: ischecked,
40118             loose: false,
40119             text: itemContents,
40120             tokens: []
40121           });
40122           list2.raw += raw;
40123         }
40124         list2.items[list2.items.length - 1].raw = raw.trimEnd();
40125         list2.items[list2.items.length - 1].text = itemContents.trimEnd();
40126         list2.raw = list2.raw.trimEnd();
40127         for (let i3 = 0; i3 < list2.items.length; i3++) {
40128           this.lexer.state.top = false;
40129           list2.items[i3].tokens = this.lexer.blockTokens(list2.items[i3].text, []);
40130           if (!list2.loose) {
40131             const spacers = list2.items[i3].tokens.filter((t2) => t2.type === "space");
40132             const hasMultipleLineBreaks = spacers.length > 0 && spacers.some((t2) => /\n.*\n/.test(t2.raw));
40133             list2.loose = hasMultipleLineBreaks;
40134           }
40135         }
40136         if (list2.loose) {
40137           for (let i3 = 0; i3 < list2.items.length; i3++) {
40138             list2.items[i3].loose = true;
40139           }
40140         }
40141         return list2;
40142       }
40143     }
40144     html(src) {
40145       const cap = this.rules.block.html.exec(src);
40146       if (cap) {
40147         const token = {
40148           type: "html",
40149           block: true,
40150           raw: cap[0],
40151           pre: cap[1] === "pre" || cap[1] === "script" || cap[1] === "style",
40152           text: cap[0]
40153         };
40154         return token;
40155       }
40156     }
40157     def(src) {
40158       const cap = this.rules.block.def.exec(src);
40159       if (cap) {
40160         const tag2 = cap[1].toLowerCase().replace(/\s+/g, " ");
40161         const href = cap[2] ? cap[2].replace(/^<(.*)>$/, "$1").replace(this.rules.inline.anyPunctuation, "$1") : "";
40162         const title = cap[3] ? cap[3].substring(1, cap[3].length - 1).replace(this.rules.inline.anyPunctuation, "$1") : cap[3];
40163         return {
40164           type: "def",
40165           tag: tag2,
40166           raw: cap[0],
40167           href,
40168           title
40169         };
40170       }
40171     }
40172     table(src) {
40173       const cap = this.rules.block.table.exec(src);
40174       if (!cap) {
40175         return;
40176       }
40177       if (!/[:|]/.test(cap[2])) {
40178         return;
40179       }
40180       const headers = splitCells(cap[1]);
40181       const aligns = cap[2].replace(/^\||\| *$/g, "").split("|");
40182       const rows = cap[3] && cap[3].trim() ? cap[3].replace(/\n[ \t]*$/, "").split("\n") : [];
40183       const item = {
40184         type: "table",
40185         raw: cap[0],
40186         header: [],
40187         align: [],
40188         rows: []
40189       };
40190       if (headers.length !== aligns.length) {
40191         return;
40192       }
40193       for (const align of aligns) {
40194         if (/^ *-+: *$/.test(align)) {
40195           item.align.push("right");
40196         } else if (/^ *:-+: *$/.test(align)) {
40197           item.align.push("center");
40198         } else if (/^ *:-+ *$/.test(align)) {
40199           item.align.push("left");
40200         } else {
40201           item.align.push(null);
40202         }
40203       }
40204       for (const header of headers) {
40205         item.header.push({
40206           text: header,
40207           tokens: this.lexer.inline(header)
40208         });
40209       }
40210       for (const row of rows) {
40211         item.rows.push(splitCells(row, item.header.length).map((cell) => {
40212           return {
40213             text: cell,
40214             tokens: this.lexer.inline(cell)
40215           };
40216         }));
40217       }
40218       return item;
40219     }
40220     lheading(src) {
40221       const cap = this.rules.block.lheading.exec(src);
40222       if (cap) {
40223         return {
40224           type: "heading",
40225           raw: cap[0],
40226           depth: cap[2].charAt(0) === "=" ? 1 : 2,
40227           text: cap[1],
40228           tokens: this.lexer.inline(cap[1])
40229         };
40230       }
40231     }
40232     paragraph(src) {
40233       const cap = this.rules.block.paragraph.exec(src);
40234       if (cap) {
40235         const text = cap[1].charAt(cap[1].length - 1) === "\n" ? cap[1].slice(0, -1) : cap[1];
40236         return {
40237           type: "paragraph",
40238           raw: cap[0],
40239           text,
40240           tokens: this.lexer.inline(text)
40241         };
40242       }
40243     }
40244     text(src) {
40245       const cap = this.rules.block.text.exec(src);
40246       if (cap) {
40247         return {
40248           type: "text",
40249           raw: cap[0],
40250           text: cap[0],
40251           tokens: this.lexer.inline(cap[0])
40252         };
40253       }
40254     }
40255     escape(src) {
40256       const cap = this.rules.inline.escape.exec(src);
40257       if (cap) {
40258         return {
40259           type: "escape",
40260           raw: cap[0],
40261           text: escape$1(cap[1])
40262         };
40263       }
40264     }
40265     tag(src) {
40266       const cap = this.rules.inline.tag.exec(src);
40267       if (cap) {
40268         if (!this.lexer.state.inLink && /^<a /i.test(cap[0])) {
40269           this.lexer.state.inLink = true;
40270         } else if (this.lexer.state.inLink && /^<\/a>/i.test(cap[0])) {
40271           this.lexer.state.inLink = false;
40272         }
40273         if (!this.lexer.state.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
40274           this.lexer.state.inRawBlock = true;
40275         } else if (this.lexer.state.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
40276           this.lexer.state.inRawBlock = false;
40277         }
40278         return {
40279           type: "html",
40280           raw: cap[0],
40281           inLink: this.lexer.state.inLink,
40282           inRawBlock: this.lexer.state.inRawBlock,
40283           block: false,
40284           text: cap[0]
40285         };
40286       }
40287     }
40288     link(src) {
40289       const cap = this.rules.inline.link.exec(src);
40290       if (cap) {
40291         const trimmedUrl = cap[2].trim();
40292         if (!this.options.pedantic && /^</.test(trimmedUrl)) {
40293           if (!/>$/.test(trimmedUrl)) {
40294             return;
40295           }
40296           const rtrimSlash = rtrim(trimmedUrl.slice(0, -1), "\\");
40297           if ((trimmedUrl.length - rtrimSlash.length) % 2 === 0) {
40298             return;
40299           }
40300         } else {
40301           const lastParenIndex = findClosingBracket(cap[2], "()");
40302           if (lastParenIndex > -1) {
40303             const start2 = cap[0].indexOf("!") === 0 ? 5 : 4;
40304             const linkLen = start2 + cap[1].length + lastParenIndex;
40305             cap[2] = cap[2].substring(0, lastParenIndex);
40306             cap[0] = cap[0].substring(0, linkLen).trim();
40307             cap[3] = "";
40308           }
40309         }
40310         let href = cap[2];
40311         let title = "";
40312         if (this.options.pedantic) {
40313           const link3 = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
40314           if (link3) {
40315             href = link3[1];
40316             title = link3[3];
40317           }
40318         } else {
40319           title = cap[3] ? cap[3].slice(1, -1) : "";
40320         }
40321         href = href.trim();
40322         if (/^</.test(href)) {
40323           if (this.options.pedantic && !/>$/.test(trimmedUrl)) {
40324             href = href.slice(1);
40325           } else {
40326             href = href.slice(1, -1);
40327           }
40328         }
40329         return outputLink(cap, {
40330           href: href ? href.replace(this.rules.inline.anyPunctuation, "$1") : href,
40331           title: title ? title.replace(this.rules.inline.anyPunctuation, "$1") : title
40332         }, cap[0], this.lexer);
40333       }
40334     }
40335     reflink(src, links) {
40336       let cap;
40337       if ((cap = this.rules.inline.reflink.exec(src)) || (cap = this.rules.inline.nolink.exec(src))) {
40338         const linkString = (cap[2] || cap[1]).replace(/\s+/g, " ");
40339         const link3 = links[linkString.toLowerCase()];
40340         if (!link3) {
40341           const text = cap[0].charAt(0);
40342           return {
40343             type: "text",
40344             raw: text,
40345             text
40346           };
40347         }
40348         return outputLink(cap, link3, cap[0], this.lexer);
40349       }
40350     }
40351     emStrong(src, maskedSrc, prevChar = "") {
40352       let match = this.rules.inline.emStrongLDelim.exec(src);
40353       if (!match)
40354         return;
40355       if (match[3] && prevChar.match(/[\p{L}\p{N}]/u))
40356         return;
40357       const nextChar = match[1] || match[2] || "";
40358       if (!nextChar || !prevChar || this.rules.inline.punctuation.exec(prevChar)) {
40359         const lLength = [...match[0]].length - 1;
40360         let rDelim, rLength, delimTotal = lLength, midDelimTotal = 0;
40361         const endReg = match[0][0] === "*" ? this.rules.inline.emStrongRDelimAst : this.rules.inline.emStrongRDelimUnd;
40362         endReg.lastIndex = 0;
40363         maskedSrc = maskedSrc.slice(-1 * src.length + lLength);
40364         while ((match = endReg.exec(maskedSrc)) != null) {
40365           rDelim = match[1] || match[2] || match[3] || match[4] || match[5] || match[6];
40366           if (!rDelim)
40367             continue;
40368           rLength = [...rDelim].length;
40369           if (match[3] || match[4]) {
40370             delimTotal += rLength;
40371             continue;
40372           } else if (match[5] || match[6]) {
40373             if (lLength % 3 && !((lLength + rLength) % 3)) {
40374               midDelimTotal += rLength;
40375               continue;
40376             }
40377           }
40378           delimTotal -= rLength;
40379           if (delimTotal > 0)
40380             continue;
40381           rLength = Math.min(rLength, rLength + delimTotal + midDelimTotal);
40382           const lastCharLength = [...match[0]][0].length;
40383           const raw = src.slice(0, lLength + match.index + lastCharLength + rLength);
40384           if (Math.min(lLength, rLength) % 2) {
40385             const text2 = raw.slice(1, -1);
40386             return {
40387               type: "em",
40388               raw,
40389               text: text2,
40390               tokens: this.lexer.inlineTokens(text2)
40391             };
40392           }
40393           const text = raw.slice(2, -2);
40394           return {
40395             type: "strong",
40396             raw,
40397             text,
40398             tokens: this.lexer.inlineTokens(text)
40399           };
40400         }
40401       }
40402     }
40403     codespan(src) {
40404       const cap = this.rules.inline.code.exec(src);
40405       if (cap) {
40406         let text = cap[2].replace(/\n/g, " ");
40407         const hasNonSpaceChars = /[^ ]/.test(text);
40408         const hasSpaceCharsOnBothEnds = /^ /.test(text) && / $/.test(text);
40409         if (hasNonSpaceChars && hasSpaceCharsOnBothEnds) {
40410           text = text.substring(1, text.length - 1);
40411         }
40412         text = escape$1(text, true);
40413         return {
40414           type: "codespan",
40415           raw: cap[0],
40416           text
40417         };
40418       }
40419     }
40420     br(src) {
40421       const cap = this.rules.inline.br.exec(src);
40422       if (cap) {
40423         return {
40424           type: "br",
40425           raw: cap[0]
40426         };
40427       }
40428     }
40429     del(src) {
40430       const cap = this.rules.inline.del.exec(src);
40431       if (cap) {
40432         return {
40433           type: "del",
40434           raw: cap[0],
40435           text: cap[2],
40436           tokens: this.lexer.inlineTokens(cap[2])
40437         };
40438       }
40439     }
40440     autolink(src) {
40441       const cap = this.rules.inline.autolink.exec(src);
40442       if (cap) {
40443         let text, href;
40444         if (cap[2] === "@") {
40445           text = escape$1(cap[1]);
40446           href = "mailto:" + text;
40447         } else {
40448           text = escape$1(cap[1]);
40449           href = text;
40450         }
40451         return {
40452           type: "link",
40453           raw: cap[0],
40454           text,
40455           href,
40456           tokens: [
40457             {
40458               type: "text",
40459               raw: text,
40460               text
40461             }
40462           ]
40463         };
40464       }
40465     }
40466     url(src) {
40467       var _a2, _b;
40468       let cap;
40469       if (cap = this.rules.inline.url.exec(src)) {
40470         let text, href;
40471         if (cap[2] === "@") {
40472           text = escape$1(cap[0]);
40473           href = "mailto:" + text;
40474         } else {
40475           let prevCapZero;
40476           do {
40477             prevCapZero = cap[0];
40478             cap[0] = (_b = (_a2 = this.rules.inline._backpedal.exec(cap[0])) == null ? void 0 : _a2[0]) != null ? _b : "";
40479           } while (prevCapZero !== cap[0]);
40480           text = escape$1(cap[0]);
40481           if (cap[1] === "www.") {
40482             href = "http://" + cap[0];
40483           } else {
40484             href = cap[0];
40485           }
40486         }
40487         return {
40488           type: "link",
40489           raw: cap[0],
40490           text,
40491           href,
40492           tokens: [
40493             {
40494               type: "text",
40495               raw: text,
40496               text
40497             }
40498           ]
40499         };
40500       }
40501     }
40502     inlineText(src) {
40503       const cap = this.rules.inline.text.exec(src);
40504       if (cap) {
40505         let text;
40506         if (this.lexer.state.inRawBlock) {
40507           text = cap[0];
40508         } else {
40509           text = escape$1(cap[0]);
40510         }
40511         return {
40512           type: "text",
40513           raw: cap[0],
40514           text
40515         };
40516       }
40517     }
40518   };
40519   var newline = /^(?: *(?:\n|$))+/;
40520   var blockCode = /^( {4}[^\n]+(?:\n(?: *(?:\n|$))*)?)+/;
40521   var fences = /^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/;
40522   var hr = /^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/;
40523   var heading = /^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/;
40524   var bullet = /(?:[*+-]|\d{1,9}[.)])/;
40525   var lheading = edit(/^(?!bull )((?:.|\n(?!\s*?\n|bull ))+?)\n {0,3}(=+|-+) *(?:\n+|$)/).replace(/bull/g, bullet).getRegex();
40526   var _paragraph = /^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/;
40527   var blockText = /^[^\n]+/;
40528   var _blockLabel = /(?!\s*\])(?:\\.|[^\[\]\\])+/;
40529   var def = edit(/^ {0,3}\[(label)\]: *(?:\n *)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n *)?| *\n *)(title))? *(?:\n+|$)/).replace("label", _blockLabel).replace("title", /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex();
40530   var list = edit(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g, bullet).getRegex();
40531   var _tag = "address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul";
40532   var _comment = /<!--(?:-?>|[\s\S]*?(?:-->|$))/;
40533   var html2 = edit("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|<![A-Z][\\s\\S]*?(?:>\\n*|$)|<!\\[CDATA\\[[\\s\\S]*?(?:\\]\\]>\\n*|$)|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:(?:\\n *)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$)|</(?!script|pre|style|textarea)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n *)+\\n|$))", "i").replace("comment", _comment).replace("tag", _tag).replace("attribute", / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex();
40534   var paragraph = edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("|table", "").replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
40535   var blockquote = edit(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph", paragraph).getRegex();
40536   var blockNormal = {
40537     blockquote,
40538     code: blockCode,
40539     def,
40540     fences,
40541     heading,
40542     hr,
40543     html: html2,
40544     lheading,
40545     list,
40546     newline,
40547     paragraph,
40548     table: noopTest,
40549     text: blockText
40550   };
40551   var gfmTable = edit("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("blockquote", " {0,3}>").replace("code", " {4}[^\\n]").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex();
40552   var blockGfm = {
40553     ...blockNormal,
40554     table: gfmTable,
40555     paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " {0,3}#{1,6}(?:\\s|$)").replace("|lheading", "").replace("table", gfmTable).replace("blockquote", " {0,3}>").replace("fences", " {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list", " {0,3}(?:[*+-]|1[.)]) ").replace("html", "</?(?:tag)(?: +|\\n|/?>)|<(?:script|pre|style|textarea|!--)").replace("tag", _tag).getRegex()
40556   };
40557   var blockPedantic = {
40558     ...blockNormal,
40559     html: edit("^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)|<tag(?:\"[^\"]*\"|'[^']*'|\\s[^'\"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))").replace("comment", _comment).replace(/tag/g, "(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),
40560     def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,
40561     heading: /^(#{1,6})(.*)(?:\n+|$)/,
40562     fences: noopTest,
40563     // fences not supported
40564     lheading: /^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,
40565     paragraph: edit(_paragraph).replace("hr", hr).replace("heading", " *#{1,6} *[^\n]").replace("lheading", lheading).replace("|table", "").replace("blockquote", " {0,3}>").replace("|fences", "").replace("|list", "").replace("|html", "").replace("|tag", "").getRegex()
40566   };
40567   var escape4 = /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/;
40568   var inlineCode = /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/;
40569   var br = /^( {2,}|\\)\n(?!\s*$)/;
40570   var inlineText = /^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\<!\[`*_]|\b_|$)|[^ ](?= {2,}\n)))/;
40571   var _punctuation = "\\p{P}\\p{S}";
40572   var punctuation = edit(/^((?![*_])[\spunctuation])/, "u").replace(/punctuation/g, _punctuation).getRegex();
40573   var blockSkip = /\[[^[\]]*?\]\([^\(\)]*?\)|`[^`]*?`|<[^<>]*?>/g;
40574   var emStrongLDelim = edit(/^(?:\*+(?:((?!\*)[punct])|[^\s*]))|^_+(?:((?!_)[punct])|([^\s_]))/, "u").replace(/punct/g, _punctuation).getRegex();
40575   var emStrongRDelimAst = edit("^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)[punct](\\*+)(?=[\\s]|$)|[^punct\\s](\\*+)(?!\\*)(?=[punct\\s]|$)|(?!\\*)[punct\\s](\\*+)(?=[^punct\\s])|[\\s](\\*+)(?!\\*)(?=[punct])|(?!\\*)[punct](\\*+)(?!\\*)(?=[punct])|[^punct\\s](\\*+)(?=[^punct\\s])", "gu").replace(/punct/g, _punctuation).getRegex();
40576   var emStrongRDelimUnd = edit("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)[punct](_+)(?=[\\s]|$)|[^punct\\s](_+)(?!_)(?=[punct\\s]|$)|(?!_)[punct\\s](_+)(?=[^punct\\s])|[\\s](_+)(?!_)(?=[punct])|(?!_)[punct](_+)(?!_)(?=[punct])", "gu").replace(/punct/g, _punctuation).getRegex();
40577   var anyPunctuation = edit(/\\([punct])/, "gu").replace(/punct/g, _punctuation).getRegex();
40578   var autolink = edit(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme", /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email", /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex();
40579   var _inlineComment = edit(_comment).replace("(?:-->|$)", "-->").getRegex();
40580   var tag = edit("^comment|^</[a-zA-Z][\\w:-]*\\s*>|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^<![a-zA-Z]+\\s[\\s\\S]*?>|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>").replace("comment", _inlineComment).replace("attribute", /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex();
40581   var _inlineLabel = /(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/;
40582   var link2 = edit(/^!?\[(label)\]\(\s*(href)(?:\s+(title))?\s*\)/).replace("label", _inlineLabel).replace("href", /<(?:\\.|[^\n<>\\])+>|[^\s\x00-\x1f]*/).replace("title", /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex();
40583   var reflink = edit(/^!?\[(label)\]\[(ref)\]/).replace("label", _inlineLabel).replace("ref", _blockLabel).getRegex();
40584   var nolink = edit(/^!?\[(ref)\](?:\[\])?/).replace("ref", _blockLabel).getRegex();
40585   var reflinkSearch = edit("reflink|nolink(?!\\()", "g").replace("reflink", reflink).replace("nolink", nolink).getRegex();
40586   var inlineNormal = {
40587     _backpedal: noopTest,
40588     // only used for GFM url
40589     anyPunctuation,
40590     autolink,
40591     blockSkip,
40592     br,
40593     code: inlineCode,
40594     del: noopTest,
40595     emStrongLDelim,
40596     emStrongRDelimAst,
40597     emStrongRDelimUnd,
40598     escape: escape4,
40599     link: link2,
40600     nolink,
40601     punctuation,
40602     reflink,
40603     reflinkSearch,
40604     tag,
40605     text: inlineText,
40606     url: noopTest
40607   };
40608   var inlinePedantic = {
40609     ...inlineNormal,
40610     link: edit(/^!?\[(label)\]\((.*?)\)/).replace("label", _inlineLabel).getRegex(),
40611     reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label", _inlineLabel).getRegex()
40612   };
40613   var inlineGfm = {
40614     ...inlineNormal,
40615     escape: edit(escape4).replace("])", "~|])").getRegex(),
40616     url: edit(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/, "i").replace("email", /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),
40617     _backpedal: /(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,
40618     del: /^(~~?)(?=[^\s~])([\s\S]*?[^\s~])\1(?=[^~]|$)/,
40619     text: /^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\<!\[`*~_]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)))/
40620   };
40621   var inlineBreaks = {
40622     ...inlineGfm,
40623     br: edit(br).replace("{2,}", "*").getRegex(),
40624     text: edit(inlineGfm.text).replace("\\b_", "\\b_| {2,}\\n").replace(/\{2,\}/g, "*").getRegex()
40625   };
40626   var block = {
40627     normal: blockNormal,
40628     gfm: blockGfm,
40629     pedantic: blockPedantic
40630   };
40631   var inline = {
40632     normal: inlineNormal,
40633     gfm: inlineGfm,
40634     breaks: inlineBreaks,
40635     pedantic: inlinePedantic
40636   };
40637   var _Lexer = class __Lexer {
40638     constructor(options2) {
40639       __publicField(this, "tokens");
40640       __publicField(this, "options");
40641       __publicField(this, "state");
40642       __publicField(this, "tokenizer");
40643       __publicField(this, "inlineQueue");
40644       this.tokens = [];
40645       this.tokens.links = /* @__PURE__ */ Object.create(null);
40646       this.options = options2 || _defaults;
40647       this.options.tokenizer = this.options.tokenizer || new _Tokenizer();
40648       this.tokenizer = this.options.tokenizer;
40649       this.tokenizer.options = this.options;
40650       this.tokenizer.lexer = this;
40651       this.inlineQueue = [];
40652       this.state = {
40653         inLink: false,
40654         inRawBlock: false,
40655         top: true
40656       };
40657       const rules = {
40658         block: block.normal,
40659         inline: inline.normal
40660       };
40661       if (this.options.pedantic) {
40662         rules.block = block.pedantic;
40663         rules.inline = inline.pedantic;
40664       } else if (this.options.gfm) {
40665         rules.block = block.gfm;
40666         if (this.options.breaks) {
40667           rules.inline = inline.breaks;
40668         } else {
40669           rules.inline = inline.gfm;
40670         }
40671       }
40672       this.tokenizer.rules = rules;
40673     }
40674     /**
40675      * Expose Rules
40676      */
40677     static get rules() {
40678       return {
40679         block,
40680         inline
40681       };
40682     }
40683     /**
40684      * Static Lex Method
40685      */
40686     static lex(src, options2) {
40687       const lexer2 = new __Lexer(options2);
40688       return lexer2.lex(src);
40689     }
40690     /**
40691      * Static Lex Inline Method
40692      */
40693     static lexInline(src, options2) {
40694       const lexer2 = new __Lexer(options2);
40695       return lexer2.inlineTokens(src);
40696     }
40697     /**
40698      * Preprocessing
40699      */
40700     lex(src) {
40701       src = src.replace(/\r\n|\r/g, "\n");
40702       this.blockTokens(src, this.tokens);
40703       for (let i3 = 0; i3 < this.inlineQueue.length; i3++) {
40704         const next = this.inlineQueue[i3];
40705         this.inlineTokens(next.src, next.tokens);
40706       }
40707       this.inlineQueue = [];
40708       return this.tokens;
40709     }
40710     blockTokens(src, tokens = []) {
40711       if (this.options.pedantic) {
40712         src = src.replace(/\t/g, "    ").replace(/^ +$/gm, "");
40713       } else {
40714         src = src.replace(/^( *)(\t+)/gm, (_2, leading, tabs) => {
40715           return leading + "    ".repeat(tabs.length);
40716         });
40717       }
40718       let token;
40719       let lastToken;
40720       let cutSrc;
40721       let lastParagraphClipped;
40722       while (src) {
40723         if (this.options.extensions && this.options.extensions.block && this.options.extensions.block.some((extTokenizer) => {
40724           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
40725             src = src.substring(token.raw.length);
40726             tokens.push(token);
40727             return true;
40728           }
40729           return false;
40730         })) {
40731           continue;
40732         }
40733         if (token = this.tokenizer.space(src)) {
40734           src = src.substring(token.raw.length);
40735           if (token.raw.length === 1 && tokens.length > 0) {
40736             tokens[tokens.length - 1].raw += "\n";
40737           } else {
40738             tokens.push(token);
40739           }
40740           continue;
40741         }
40742         if (token = this.tokenizer.code(src)) {
40743           src = src.substring(token.raw.length);
40744           lastToken = tokens[tokens.length - 1];
40745           if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
40746             lastToken.raw += "\n" + token.raw;
40747             lastToken.text += "\n" + token.text;
40748             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40749           } else {
40750             tokens.push(token);
40751           }
40752           continue;
40753         }
40754         if (token = this.tokenizer.fences(src)) {
40755           src = src.substring(token.raw.length);
40756           tokens.push(token);
40757           continue;
40758         }
40759         if (token = this.tokenizer.heading(src)) {
40760           src = src.substring(token.raw.length);
40761           tokens.push(token);
40762           continue;
40763         }
40764         if (token = this.tokenizer.hr(src)) {
40765           src = src.substring(token.raw.length);
40766           tokens.push(token);
40767           continue;
40768         }
40769         if (token = this.tokenizer.blockquote(src)) {
40770           src = src.substring(token.raw.length);
40771           tokens.push(token);
40772           continue;
40773         }
40774         if (token = this.tokenizer.list(src)) {
40775           src = src.substring(token.raw.length);
40776           tokens.push(token);
40777           continue;
40778         }
40779         if (token = this.tokenizer.html(src)) {
40780           src = src.substring(token.raw.length);
40781           tokens.push(token);
40782           continue;
40783         }
40784         if (token = this.tokenizer.def(src)) {
40785           src = src.substring(token.raw.length);
40786           lastToken = tokens[tokens.length - 1];
40787           if (lastToken && (lastToken.type === "paragraph" || lastToken.type === "text")) {
40788             lastToken.raw += "\n" + token.raw;
40789             lastToken.text += "\n" + token.raw;
40790             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40791           } else if (!this.tokens.links[token.tag]) {
40792             this.tokens.links[token.tag] = {
40793               href: token.href,
40794               title: token.title
40795             };
40796           }
40797           continue;
40798         }
40799         if (token = this.tokenizer.table(src)) {
40800           src = src.substring(token.raw.length);
40801           tokens.push(token);
40802           continue;
40803         }
40804         if (token = this.tokenizer.lheading(src)) {
40805           src = src.substring(token.raw.length);
40806           tokens.push(token);
40807           continue;
40808         }
40809         cutSrc = src;
40810         if (this.options.extensions && this.options.extensions.startBlock) {
40811           let startIndex = Infinity;
40812           const tempSrc = src.slice(1);
40813           let tempStart;
40814           this.options.extensions.startBlock.forEach((getStartIndex) => {
40815             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
40816             if (typeof tempStart === "number" && tempStart >= 0) {
40817               startIndex = Math.min(startIndex, tempStart);
40818             }
40819           });
40820           if (startIndex < Infinity && startIndex >= 0) {
40821             cutSrc = src.substring(0, startIndex + 1);
40822           }
40823         }
40824         if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
40825           lastToken = tokens[tokens.length - 1];
40826           if (lastParagraphClipped && lastToken.type === "paragraph") {
40827             lastToken.raw += "\n" + token.raw;
40828             lastToken.text += "\n" + token.text;
40829             this.inlineQueue.pop();
40830             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40831           } else {
40832             tokens.push(token);
40833           }
40834           lastParagraphClipped = cutSrc.length !== src.length;
40835           src = src.substring(token.raw.length);
40836           continue;
40837         }
40838         if (token = this.tokenizer.text(src)) {
40839           src = src.substring(token.raw.length);
40840           lastToken = tokens[tokens.length - 1];
40841           if (lastToken && lastToken.type === "text") {
40842             lastToken.raw += "\n" + token.raw;
40843             lastToken.text += "\n" + token.text;
40844             this.inlineQueue.pop();
40845             this.inlineQueue[this.inlineQueue.length - 1].src = lastToken.text;
40846           } else {
40847             tokens.push(token);
40848           }
40849           continue;
40850         }
40851         if (src) {
40852           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
40853           if (this.options.silent) {
40854             console.error(errMsg);
40855             break;
40856           } else {
40857             throw new Error(errMsg);
40858           }
40859         }
40860       }
40861       this.state.top = true;
40862       return tokens;
40863     }
40864     inline(src, tokens = []) {
40865       this.inlineQueue.push({ src, tokens });
40866       return tokens;
40867     }
40868     /**
40869      * Lexing/Compiling
40870      */
40871     inlineTokens(src, tokens = []) {
40872       let token, lastToken, cutSrc;
40873       let maskedSrc = src;
40874       let match;
40875       let keepPrevChar, prevChar;
40876       if (this.tokens.links) {
40877         const links = Object.keys(this.tokens.links);
40878         if (links.length > 0) {
40879           while ((match = this.tokenizer.rules.inline.reflinkSearch.exec(maskedSrc)) != null) {
40880             if (links.includes(match[0].slice(match[0].lastIndexOf("[") + 1, -1))) {
40881               maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex);
40882             }
40883           }
40884         }
40885       }
40886       while ((match = this.tokenizer.rules.inline.blockSkip.exec(maskedSrc)) != null) {
40887         maskedSrc = maskedSrc.slice(0, match.index) + "[" + "a".repeat(match[0].length - 2) + "]" + maskedSrc.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);
40888       }
40889       while ((match = this.tokenizer.rules.inline.anyPunctuation.exec(maskedSrc)) != null) {
40890         maskedSrc = maskedSrc.slice(0, match.index) + "++" + maskedSrc.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);
40891       }
40892       while (src) {
40893         if (!keepPrevChar) {
40894           prevChar = "";
40895         }
40896         keepPrevChar = false;
40897         if (this.options.extensions && this.options.extensions.inline && this.options.extensions.inline.some((extTokenizer) => {
40898           if (token = extTokenizer.call({ lexer: this }, src, tokens)) {
40899             src = src.substring(token.raw.length);
40900             tokens.push(token);
40901             return true;
40902           }
40903           return false;
40904         })) {
40905           continue;
40906         }
40907         if (token = this.tokenizer.escape(src)) {
40908           src = src.substring(token.raw.length);
40909           tokens.push(token);
40910           continue;
40911         }
40912         if (token = this.tokenizer.tag(src)) {
40913           src = src.substring(token.raw.length);
40914           lastToken = tokens[tokens.length - 1];
40915           if (lastToken && token.type === "text" && lastToken.type === "text") {
40916             lastToken.raw += token.raw;
40917             lastToken.text += token.text;
40918           } else {
40919             tokens.push(token);
40920           }
40921           continue;
40922         }
40923         if (token = this.tokenizer.link(src)) {
40924           src = src.substring(token.raw.length);
40925           tokens.push(token);
40926           continue;
40927         }
40928         if (token = this.tokenizer.reflink(src, this.tokens.links)) {
40929           src = src.substring(token.raw.length);
40930           lastToken = tokens[tokens.length - 1];
40931           if (lastToken && token.type === "text" && lastToken.type === "text") {
40932             lastToken.raw += token.raw;
40933             lastToken.text += token.text;
40934           } else {
40935             tokens.push(token);
40936           }
40937           continue;
40938         }
40939         if (token = this.tokenizer.emStrong(src, maskedSrc, prevChar)) {
40940           src = src.substring(token.raw.length);
40941           tokens.push(token);
40942           continue;
40943         }
40944         if (token = this.tokenizer.codespan(src)) {
40945           src = src.substring(token.raw.length);
40946           tokens.push(token);
40947           continue;
40948         }
40949         if (token = this.tokenizer.br(src)) {
40950           src = src.substring(token.raw.length);
40951           tokens.push(token);
40952           continue;
40953         }
40954         if (token = this.tokenizer.del(src)) {
40955           src = src.substring(token.raw.length);
40956           tokens.push(token);
40957           continue;
40958         }
40959         if (token = this.tokenizer.autolink(src)) {
40960           src = src.substring(token.raw.length);
40961           tokens.push(token);
40962           continue;
40963         }
40964         if (!this.state.inLink && (token = this.tokenizer.url(src))) {
40965           src = src.substring(token.raw.length);
40966           tokens.push(token);
40967           continue;
40968         }
40969         cutSrc = src;
40970         if (this.options.extensions && this.options.extensions.startInline) {
40971           let startIndex = Infinity;
40972           const tempSrc = src.slice(1);
40973           let tempStart;
40974           this.options.extensions.startInline.forEach((getStartIndex) => {
40975             tempStart = getStartIndex.call({ lexer: this }, tempSrc);
40976             if (typeof tempStart === "number" && tempStart >= 0) {
40977               startIndex = Math.min(startIndex, tempStart);
40978             }
40979           });
40980           if (startIndex < Infinity && startIndex >= 0) {
40981             cutSrc = src.substring(0, startIndex + 1);
40982           }
40983         }
40984         if (token = this.tokenizer.inlineText(cutSrc)) {
40985           src = src.substring(token.raw.length);
40986           if (token.raw.slice(-1) !== "_") {
40987             prevChar = token.raw.slice(-1);
40988           }
40989           keepPrevChar = true;
40990           lastToken = tokens[tokens.length - 1];
40991           if (lastToken && lastToken.type === "text") {
40992             lastToken.raw += token.raw;
40993             lastToken.text += token.text;
40994           } else {
40995             tokens.push(token);
40996           }
40997           continue;
40998         }
40999         if (src) {
41000           const errMsg = "Infinite loop on byte: " + src.charCodeAt(0);
41001           if (this.options.silent) {
41002             console.error(errMsg);
41003             break;
41004           } else {
41005             throw new Error(errMsg);
41006           }
41007         }
41008       }
41009       return tokens;
41010     }
41011   };
41012   var _Renderer = class {
41013     constructor(options2) {
41014       __publicField(this, "options");
41015       this.options = options2 || _defaults;
41016     }
41017     code(code, infostring, escaped) {
41018       var _a2;
41019       const lang = (_a2 = (infostring || "").match(/^\S*/)) == null ? void 0 : _a2[0];
41020       code = code.replace(/\n$/, "") + "\n";
41021       if (!lang) {
41022         return "<pre><code>" + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
41023       }
41024       return '<pre><code class="language-' + escape$1(lang) + '">' + (escaped ? code : escape$1(code, true)) + "</code></pre>\n";
41025     }
41026     blockquote(quote) {
41027       return "<blockquote>\n".concat(quote, "</blockquote>\n");
41028     }
41029     html(html3, block2) {
41030       return html3;
41031     }
41032     heading(text, level, raw) {
41033       return "<h".concat(level, ">").concat(text, "</h").concat(level, ">\n");
41034     }
41035     hr() {
41036       return "<hr>\n";
41037     }
41038     list(body, ordered, start2) {
41039       const type2 = ordered ? "ol" : "ul";
41040       const startatt = ordered && start2 !== 1 ? ' start="' + start2 + '"' : "";
41041       return "<" + type2 + startatt + ">\n" + body + "</" + type2 + ">\n";
41042     }
41043     listitem(text, task, checked) {
41044       return "<li>".concat(text, "</li>\n");
41045     }
41046     checkbox(checked) {
41047       return "<input " + (checked ? 'checked="" ' : "") + 'disabled="" type="checkbox">';
41048     }
41049     paragraph(text) {
41050       return "<p>".concat(text, "</p>\n");
41051     }
41052     table(header, body) {
41053       if (body)
41054         body = "<tbody>".concat(body, "</tbody>");
41055       return "<table>\n<thead>\n" + header + "</thead>\n" + body + "</table>\n";
41056     }
41057     tablerow(content) {
41058       return "<tr>\n".concat(content, "</tr>\n");
41059     }
41060     tablecell(content, flags) {
41061       const type2 = flags.header ? "th" : "td";
41062       const tag2 = flags.align ? "<".concat(type2, ' align="').concat(flags.align, '">') : "<".concat(type2, ">");
41063       return tag2 + content + "</".concat(type2, ">\n");
41064     }
41065     /**
41066      * span level renderer
41067      */
41068     strong(text) {
41069       return "<strong>".concat(text, "</strong>");
41070     }
41071     em(text) {
41072       return "<em>".concat(text, "</em>");
41073     }
41074     codespan(text) {
41075       return "<code>".concat(text, "</code>");
41076     }
41077     br() {
41078       return "<br>";
41079     }
41080     del(text) {
41081       return "<del>".concat(text, "</del>");
41082     }
41083     link(href, title, text) {
41084       const cleanHref = cleanUrl(href);
41085       if (cleanHref === null) {
41086         return text;
41087       }
41088       href = cleanHref;
41089       let out = '<a href="' + href + '"';
41090       if (title) {
41091         out += ' title="' + title + '"';
41092       }
41093       out += ">" + text + "</a>";
41094       return out;
41095     }
41096     image(href, title, text) {
41097       const cleanHref = cleanUrl(href);
41098       if (cleanHref === null) {
41099         return text;
41100       }
41101       href = cleanHref;
41102       let out = '<img src="'.concat(href, '" alt="').concat(text, '"');
41103       if (title) {
41104         out += ' title="'.concat(title, '"');
41105       }
41106       out += ">";
41107       return out;
41108     }
41109     text(text) {
41110       return text;
41111     }
41112   };
41113   var _TextRenderer = class {
41114     // no need for block level renderers
41115     strong(text) {
41116       return text;
41117     }
41118     em(text) {
41119       return text;
41120     }
41121     codespan(text) {
41122       return text;
41123     }
41124     del(text) {
41125       return text;
41126     }
41127     html(text) {
41128       return text;
41129     }
41130     text(text) {
41131       return text;
41132     }
41133     link(href, title, text) {
41134       return "" + text;
41135     }
41136     image(href, title, text) {
41137       return "" + text;
41138     }
41139     br() {
41140       return "";
41141     }
41142   };
41143   var _Parser = class __Parser {
41144     constructor(options2) {
41145       __publicField(this, "options");
41146       __publicField(this, "renderer");
41147       __publicField(this, "textRenderer");
41148       this.options = options2 || _defaults;
41149       this.options.renderer = this.options.renderer || new _Renderer();
41150       this.renderer = this.options.renderer;
41151       this.renderer.options = this.options;
41152       this.textRenderer = new _TextRenderer();
41153     }
41154     /**
41155      * Static Parse Method
41156      */
41157     static parse(tokens, options2) {
41158       const parser3 = new __Parser(options2);
41159       return parser3.parse(tokens);
41160     }
41161     /**
41162      * Static Parse Inline Method
41163      */
41164     static parseInline(tokens, options2) {
41165       const parser3 = new __Parser(options2);
41166       return parser3.parseInline(tokens);
41167     }
41168     /**
41169      * Parse Loop
41170      */
41171     parse(tokens, top = true) {
41172       let out = "";
41173       for (let i3 = 0; i3 < tokens.length; i3++) {
41174         const token = tokens[i3];
41175         if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
41176           const genericToken = token;
41177           const ret = this.options.extensions.renderers[genericToken.type].call({ parser: this }, genericToken);
41178           if (ret !== false || !["space", "hr", "heading", "code", "table", "blockquote", "list", "html", "paragraph", "text"].includes(genericToken.type)) {
41179             out += ret || "";
41180             continue;
41181           }
41182         }
41183         switch (token.type) {
41184           case "space": {
41185             continue;
41186           }
41187           case "hr": {
41188             out += this.renderer.hr();
41189             continue;
41190           }
41191           case "heading": {
41192             const headingToken = token;
41193             out += this.renderer.heading(this.parseInline(headingToken.tokens), headingToken.depth, unescape2(this.parseInline(headingToken.tokens, this.textRenderer)));
41194             continue;
41195           }
41196           case "code": {
41197             const codeToken = token;
41198             out += this.renderer.code(codeToken.text, codeToken.lang, !!codeToken.escaped);
41199             continue;
41200           }
41201           case "table": {
41202             const tableToken = token;
41203             let header = "";
41204             let cell = "";
41205             for (let j2 = 0; j2 < tableToken.header.length; j2++) {
41206               cell += this.renderer.tablecell(this.parseInline(tableToken.header[j2].tokens), { header: true, align: tableToken.align[j2] });
41207             }
41208             header += this.renderer.tablerow(cell);
41209             let body = "";
41210             for (let j2 = 0; j2 < tableToken.rows.length; j2++) {
41211               const row = tableToken.rows[j2];
41212               cell = "";
41213               for (let k2 = 0; k2 < row.length; k2++) {
41214                 cell += this.renderer.tablecell(this.parseInline(row[k2].tokens), { header: false, align: tableToken.align[k2] });
41215               }
41216               body += this.renderer.tablerow(cell);
41217             }
41218             out += this.renderer.table(header, body);
41219             continue;
41220           }
41221           case "blockquote": {
41222             const blockquoteToken = token;
41223             const body = this.parse(blockquoteToken.tokens);
41224             out += this.renderer.blockquote(body);
41225             continue;
41226           }
41227           case "list": {
41228             const listToken = token;
41229             const ordered = listToken.ordered;
41230             const start2 = listToken.start;
41231             const loose = listToken.loose;
41232             let body = "";
41233             for (let j2 = 0; j2 < listToken.items.length; j2++) {
41234               const item = listToken.items[j2];
41235               const checked = item.checked;
41236               const task = item.task;
41237               let itemBody = "";
41238               if (item.task) {
41239                 const checkbox = this.renderer.checkbox(!!checked);
41240                 if (loose) {
41241                   if (item.tokens.length > 0 && item.tokens[0].type === "paragraph") {
41242                     item.tokens[0].text = checkbox + " " + item.tokens[0].text;
41243                     if (item.tokens[0].tokens && item.tokens[0].tokens.length > 0 && item.tokens[0].tokens[0].type === "text") {
41244                       item.tokens[0].tokens[0].text = checkbox + " " + item.tokens[0].tokens[0].text;
41245                     }
41246                   } else {
41247                     item.tokens.unshift({
41248                       type: "text",
41249                       text: checkbox + " "
41250                     });
41251                   }
41252                 } else {
41253                   itemBody += checkbox + " ";
41254                 }
41255               }
41256               itemBody += this.parse(item.tokens, loose);
41257               body += this.renderer.listitem(itemBody, task, !!checked);
41258             }
41259             out += this.renderer.list(body, ordered, start2);
41260             continue;
41261           }
41262           case "html": {
41263             const htmlToken = token;
41264             out += this.renderer.html(htmlToken.text, htmlToken.block);
41265             continue;
41266           }
41267           case "paragraph": {
41268             const paragraphToken = token;
41269             out += this.renderer.paragraph(this.parseInline(paragraphToken.tokens));
41270             continue;
41271           }
41272           case "text": {
41273             let textToken = token;
41274             let body = textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text;
41275             while (i3 + 1 < tokens.length && tokens[i3 + 1].type === "text") {
41276               textToken = tokens[++i3];
41277               body += "\n" + (textToken.tokens ? this.parseInline(textToken.tokens) : textToken.text);
41278             }
41279             out += top ? this.renderer.paragraph(body) : body;
41280             continue;
41281           }
41282           default: {
41283             const errMsg = 'Token with "' + token.type + '" type was not found.';
41284             if (this.options.silent) {
41285               console.error(errMsg);
41286               return "";
41287             } else {
41288               throw new Error(errMsg);
41289             }
41290           }
41291         }
41292       }
41293       return out;
41294     }
41295     /**
41296      * Parse Inline Tokens
41297      */
41298     parseInline(tokens, renderer) {
41299       renderer = renderer || this.renderer;
41300       let out = "";
41301       for (let i3 = 0; i3 < tokens.length; i3++) {
41302         const token = tokens[i3];
41303         if (this.options.extensions && this.options.extensions.renderers && this.options.extensions.renderers[token.type]) {
41304           const ret = this.options.extensions.renderers[token.type].call({ parser: this }, token);
41305           if (ret !== false || !["escape", "html", "link", "image", "strong", "em", "codespan", "br", "del", "text"].includes(token.type)) {
41306             out += ret || "";
41307             continue;
41308           }
41309         }
41310         switch (token.type) {
41311           case "escape": {
41312             const escapeToken = token;
41313             out += renderer.text(escapeToken.text);
41314             break;
41315           }
41316           case "html": {
41317             const tagToken = token;
41318             out += renderer.html(tagToken.text);
41319             break;
41320           }
41321           case "link": {
41322             const linkToken = token;
41323             out += renderer.link(linkToken.href, linkToken.title, this.parseInline(linkToken.tokens, renderer));
41324             break;
41325           }
41326           case "image": {
41327             const imageToken = token;
41328             out += renderer.image(imageToken.href, imageToken.title, imageToken.text);
41329             break;
41330           }
41331           case "strong": {
41332             const strongToken = token;
41333             out += renderer.strong(this.parseInline(strongToken.tokens, renderer));
41334             break;
41335           }
41336           case "em": {
41337             const emToken = token;
41338             out += renderer.em(this.parseInline(emToken.tokens, renderer));
41339             break;
41340           }
41341           case "codespan": {
41342             const codespanToken = token;
41343             out += renderer.codespan(codespanToken.text);
41344             break;
41345           }
41346           case "br": {
41347             out += renderer.br();
41348             break;
41349           }
41350           case "del": {
41351             const delToken = token;
41352             out += renderer.del(this.parseInline(delToken.tokens, renderer));
41353             break;
41354           }
41355           case "text": {
41356             const textToken = token;
41357             out += renderer.text(textToken.text);
41358             break;
41359           }
41360           default: {
41361             const errMsg = 'Token with "' + token.type + '" type was not found.';
41362             if (this.options.silent) {
41363               console.error(errMsg);
41364               return "";
41365             } else {
41366               throw new Error(errMsg);
41367             }
41368           }
41369         }
41370       }
41371       return out;
41372     }
41373   };
41374   var _Hooks = class {
41375     constructor(options2) {
41376       __publicField(this, "options");
41377       this.options = options2 || _defaults;
41378     }
41379     /**
41380      * Process markdown before marked
41381      */
41382     preprocess(markdown) {
41383       return markdown;
41384     }
41385     /**
41386      * Process HTML after marked is finished
41387      */
41388     postprocess(html3) {
41389       return html3;
41390     }
41391     /**
41392      * Process all tokens before walk tokens
41393      */
41394     processAllTokens(tokens) {
41395       return tokens;
41396     }
41397   };
41398   __publicField(_Hooks, "passThroughHooks", /* @__PURE__ */ new Set([
41399     "preprocess",
41400     "postprocess",
41401     "processAllTokens"
41402   ]));
41403   var _parseMarkdown, parseMarkdown_fn, _onError, onError_fn;
41404   var Marked = class {
41405     constructor(...args) {
41406       __privateAdd(this, _parseMarkdown);
41407       __privateAdd(this, _onError);
41408       __publicField(this, "defaults", _getDefaults());
41409       __publicField(this, "options", this.setOptions);
41410       __publicField(this, "parse", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lex, _Parser.parse));
41411       __publicField(this, "parseInline", __privateMethod(this, _parseMarkdown, parseMarkdown_fn).call(this, _Lexer.lexInline, _Parser.parseInline));
41412       __publicField(this, "Parser", _Parser);
41413       __publicField(this, "Renderer", _Renderer);
41414       __publicField(this, "TextRenderer", _TextRenderer);
41415       __publicField(this, "Lexer", _Lexer);
41416       __publicField(this, "Tokenizer", _Tokenizer);
41417       __publicField(this, "Hooks", _Hooks);
41418       this.use(...args);
41419     }
41420     /**
41421      * Run callback for every token
41422      */
41423     walkTokens(tokens, callback) {
41424       var _a2, _b;
41425       let values = [];
41426       for (const token of tokens) {
41427         values = values.concat(callback.call(this, token));
41428         switch (token.type) {
41429           case "table": {
41430             const tableToken = token;
41431             for (const cell of tableToken.header) {
41432               values = values.concat(this.walkTokens(cell.tokens, callback));
41433             }
41434             for (const row of tableToken.rows) {
41435               for (const cell of row) {
41436                 values = values.concat(this.walkTokens(cell.tokens, callback));
41437               }
41438             }
41439             break;
41440           }
41441           case "list": {
41442             const listToken = token;
41443             values = values.concat(this.walkTokens(listToken.items, callback));
41444             break;
41445           }
41446           default: {
41447             const genericToken = token;
41448             if ((_b = (_a2 = this.defaults.extensions) == null ? void 0 : _a2.childTokens) == null ? void 0 : _b[genericToken.type]) {
41449               this.defaults.extensions.childTokens[genericToken.type].forEach((childTokens) => {
41450                 const tokens2 = genericToken[childTokens].flat(Infinity);
41451                 values = values.concat(this.walkTokens(tokens2, callback));
41452               });
41453             } else if (genericToken.tokens) {
41454               values = values.concat(this.walkTokens(genericToken.tokens, callback));
41455             }
41456           }
41457         }
41458       }
41459       return values;
41460     }
41461     use(...args) {
41462       const extensions = this.defaults.extensions || { renderers: {}, childTokens: {} };
41463       args.forEach((pack) => {
41464         const opts = { ...pack };
41465         opts.async = this.defaults.async || opts.async || false;
41466         if (pack.extensions) {
41467           pack.extensions.forEach((ext) => {
41468             if (!ext.name) {
41469               throw new Error("extension name required");
41470             }
41471             if ("renderer" in ext) {
41472               const prevRenderer = extensions.renderers[ext.name];
41473               if (prevRenderer) {
41474                 extensions.renderers[ext.name] = function(...args2) {
41475                   let ret = ext.renderer.apply(this, args2);
41476                   if (ret === false) {
41477                     ret = prevRenderer.apply(this, args2);
41478                   }
41479                   return ret;
41480                 };
41481               } else {
41482                 extensions.renderers[ext.name] = ext.renderer;
41483               }
41484             }
41485             if ("tokenizer" in ext) {
41486               if (!ext.level || ext.level !== "block" && ext.level !== "inline") {
41487                 throw new Error("extension level must be 'block' or 'inline'");
41488               }
41489               const extLevel = extensions[ext.level];
41490               if (extLevel) {
41491                 extLevel.unshift(ext.tokenizer);
41492               } else {
41493                 extensions[ext.level] = [ext.tokenizer];
41494               }
41495               if (ext.start) {
41496                 if (ext.level === "block") {
41497                   if (extensions.startBlock) {
41498                     extensions.startBlock.push(ext.start);
41499                   } else {
41500                     extensions.startBlock = [ext.start];
41501                   }
41502                 } else if (ext.level === "inline") {
41503                   if (extensions.startInline) {
41504                     extensions.startInline.push(ext.start);
41505                   } else {
41506                     extensions.startInline = [ext.start];
41507                   }
41508                 }
41509               }
41510             }
41511             if ("childTokens" in ext && ext.childTokens) {
41512               extensions.childTokens[ext.name] = ext.childTokens;
41513             }
41514           });
41515           opts.extensions = extensions;
41516         }
41517         if (pack.renderer) {
41518           const renderer = this.defaults.renderer || new _Renderer(this.defaults);
41519           for (const prop in pack.renderer) {
41520             if (!(prop in renderer)) {
41521               throw new Error("renderer '".concat(prop, "' does not exist"));
41522             }
41523             if (prop === "options") {
41524               continue;
41525             }
41526             const rendererProp = prop;
41527             const rendererFunc = pack.renderer[rendererProp];
41528             const prevRenderer = renderer[rendererProp];
41529             renderer[rendererProp] = (...args2) => {
41530               let ret = rendererFunc.apply(renderer, args2);
41531               if (ret === false) {
41532                 ret = prevRenderer.apply(renderer, args2);
41533               }
41534               return ret || "";
41535             };
41536           }
41537           opts.renderer = renderer;
41538         }
41539         if (pack.tokenizer) {
41540           const tokenizer = this.defaults.tokenizer || new _Tokenizer(this.defaults);
41541           for (const prop in pack.tokenizer) {
41542             if (!(prop in tokenizer)) {
41543               throw new Error("tokenizer '".concat(prop, "' does not exist"));
41544             }
41545             if (["options", "rules", "lexer"].includes(prop)) {
41546               continue;
41547             }
41548             const tokenizerProp = prop;
41549             const tokenizerFunc = pack.tokenizer[tokenizerProp];
41550             const prevTokenizer = tokenizer[tokenizerProp];
41551             tokenizer[tokenizerProp] = (...args2) => {
41552               let ret = tokenizerFunc.apply(tokenizer, args2);
41553               if (ret === false) {
41554                 ret = prevTokenizer.apply(tokenizer, args2);
41555               }
41556               return ret;
41557             };
41558           }
41559           opts.tokenizer = tokenizer;
41560         }
41561         if (pack.hooks) {
41562           const hooks = this.defaults.hooks || new _Hooks();
41563           for (const prop in pack.hooks) {
41564             if (!(prop in hooks)) {
41565               throw new Error("hook '".concat(prop, "' does not exist"));
41566             }
41567             if (prop === "options") {
41568               continue;
41569             }
41570             const hooksProp = prop;
41571             const hooksFunc = pack.hooks[hooksProp];
41572             const prevHook = hooks[hooksProp];
41573             if (_Hooks.passThroughHooks.has(prop)) {
41574               hooks[hooksProp] = (arg) => {
41575                 if (this.defaults.async) {
41576                   return Promise.resolve(hooksFunc.call(hooks, arg)).then((ret2) => {
41577                     return prevHook.call(hooks, ret2);
41578                   });
41579                 }
41580                 const ret = hooksFunc.call(hooks, arg);
41581                 return prevHook.call(hooks, ret);
41582               };
41583             } else {
41584               hooks[hooksProp] = (...args2) => {
41585                 let ret = hooksFunc.apply(hooks, args2);
41586                 if (ret === false) {
41587                   ret = prevHook.apply(hooks, args2);
41588                 }
41589                 return ret;
41590               };
41591             }
41592           }
41593           opts.hooks = hooks;
41594         }
41595         if (pack.walkTokens) {
41596           const walkTokens2 = this.defaults.walkTokens;
41597           const packWalktokens = pack.walkTokens;
41598           opts.walkTokens = function(token) {
41599             let values = [];
41600             values.push(packWalktokens.call(this, token));
41601             if (walkTokens2) {
41602               values = values.concat(walkTokens2.call(this, token));
41603             }
41604             return values;
41605           };
41606         }
41607         this.defaults = { ...this.defaults, ...opts };
41608       });
41609       return this;
41610     }
41611     setOptions(opt) {
41612       this.defaults = { ...this.defaults, ...opt };
41613       return this;
41614     }
41615     lexer(src, options2) {
41616       return _Lexer.lex(src, options2 != null ? options2 : this.defaults);
41617     }
41618     parser(tokens, options2) {
41619       return _Parser.parse(tokens, options2 != null ? options2 : this.defaults);
41620     }
41621   };
41622   _parseMarkdown = new WeakSet();
41623   parseMarkdown_fn = function(lexer2, parser3) {
41624     return (src, options2) => {
41625       const origOpt = { ...options2 };
41626       const opt = { ...this.defaults, ...origOpt };
41627       if (this.defaults.async === true && origOpt.async === false) {
41628         if (!opt.silent) {
41629           console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored.");
41630         }
41631         opt.async = true;
41632       }
41633       const throwError = __privateMethod(this, _onError, onError_fn).call(this, !!opt.silent, !!opt.async);
41634       if (typeof src === "undefined" || src === null) {
41635         return throwError(new Error("marked(): input parameter is undefined or null"));
41636       }
41637       if (typeof src !== "string") {
41638         return throwError(new Error("marked(): input parameter is of type " + Object.prototype.toString.call(src) + ", string expected"));
41639       }
41640       if (opt.hooks) {
41641         opt.hooks.options = opt;
41642       }
41643       if (opt.async) {
41644         return Promise.resolve(opt.hooks ? opt.hooks.preprocess(src) : src).then((src2) => lexer2(src2, opt)).then((tokens) => opt.hooks ? opt.hooks.processAllTokens(tokens) : tokens).then((tokens) => opt.walkTokens ? Promise.all(this.walkTokens(tokens, opt.walkTokens)).then(() => tokens) : tokens).then((tokens) => parser3(tokens, opt)).then((html3) => opt.hooks ? opt.hooks.postprocess(html3) : html3).catch(throwError);
41645       }
41646       try {
41647         if (opt.hooks) {
41648           src = opt.hooks.preprocess(src);
41649         }
41650         let tokens = lexer2(src, opt);
41651         if (opt.hooks) {
41652           tokens = opt.hooks.processAllTokens(tokens);
41653         }
41654         if (opt.walkTokens) {
41655           this.walkTokens(tokens, opt.walkTokens);
41656         }
41657         let html3 = parser3(tokens, opt);
41658         if (opt.hooks) {
41659           html3 = opt.hooks.postprocess(html3);
41660         }
41661         return html3;
41662       } catch (e3) {
41663         return throwError(e3);
41664       }
41665     };
41666   };
41667   _onError = new WeakSet();
41668   onError_fn = function(silent, async) {
41669     return (e3) => {
41670       e3.message += "\nPlease report this to https://github.com/markedjs/marked.";
41671       if (silent) {
41672         const msg = "<p>An error occurred:</p><pre>" + escape$1(e3.message + "", true) + "</pre>";
41673         if (async) {
41674           return Promise.resolve(msg);
41675         }
41676         return msg;
41677       }
41678       if (async) {
41679         return Promise.reject(e3);
41680       }
41681       throw e3;
41682     };
41683   };
41684   var markedInstance = new Marked();
41685   function marked(src, opt) {
41686     return markedInstance.parse(src, opt);
41687   }
41688   marked.options = marked.setOptions = function(options2) {
41689     markedInstance.setOptions(options2);
41690     marked.defaults = markedInstance.defaults;
41691     changeDefaults(marked.defaults);
41692     return marked;
41693   };
41694   marked.getDefaults = _getDefaults;
41695   marked.defaults = _defaults;
41696   marked.use = function(...args) {
41697     markedInstance.use(...args);
41698     marked.defaults = markedInstance.defaults;
41699     changeDefaults(marked.defaults);
41700     return marked;
41701   };
41702   marked.walkTokens = function(tokens, callback) {
41703     return markedInstance.walkTokens(tokens, callback);
41704   };
41705   marked.parseInline = markedInstance.parseInline;
41706   marked.Parser = _Parser;
41707   marked.parser = _Parser.parse;
41708   marked.Renderer = _Renderer;
41709   marked.TextRenderer = _TextRenderer;
41710   marked.Lexer = _Lexer;
41711   marked.lexer = _Lexer.lex;
41712   marked.Tokenizer = _Tokenizer;
41713   marked.Hooks = _Hooks;
41714   marked.parse = marked;
41715   var options = marked.options;
41716   var setOptions = marked.setOptions;
41717   var use = marked.use;
41718   var walkTokens = marked.walkTokens;
41719   var parseInline = marked.parseInline;
41720   var parser2 = _Parser.parse;
41721   var lexer = _Lexer.lex;
41722
41723   // modules/services/osmose.js
41724   var tiler3 = utilTiler();
41725   var dispatch4 = dispatch_default("loaded");
41726   var _tileZoom3 = 14;
41727   var _osmoseUrlRoot = "https://osmose.openstreetmap.fr/api/0.3";
41728   var _osmoseData = { icons: {}, items: [] };
41729   var _cache3;
41730   function abortRequest3(controller) {
41731     if (controller) {
41732       controller.abort();
41733     }
41734   }
41735   function abortUnwantedRequests3(cache, tiles) {
41736     Object.keys(cache.inflightTile).forEach((k2) => {
41737       let wanted = tiles.find((tile) => k2 === tile.id);
41738       if (!wanted) {
41739         abortRequest3(cache.inflightTile[k2]);
41740         delete cache.inflightTile[k2];
41741       }
41742     });
41743   }
41744   function encodeIssueRtree3(d2) {
41745     return { minX: d2.loc[0], minY: d2.loc[1], maxX: d2.loc[0], maxY: d2.loc[1], data: d2 };
41746   }
41747   function updateRtree3(item, replace) {
41748     _cache3.rtree.remove(item, (a2, b2) => a2.data.id === b2.data.id);
41749     if (replace) {
41750       _cache3.rtree.insert(item);
41751     }
41752   }
41753   function preventCoincident2(loc) {
41754     let coincident = false;
41755     do {
41756       let delta = coincident ? [1e-5, 0] : [0, 1e-5];
41757       loc = geoVecAdd(loc, delta);
41758       let bbox2 = geoExtent(loc).bbox();
41759       coincident = _cache3.rtree.search(bbox2).length;
41760     } while (coincident);
41761     return loc;
41762   }
41763   var osmose_default = {
41764     title: "osmose",
41765     init() {
41766       _mainFileFetcher.get("qa_data").then((d2) => {
41767         _osmoseData = d2.osmose;
41768         _osmoseData.items = Object.keys(d2.osmose.icons).map((s2) => s2.split("-")[0]).reduce((unique, item) => unique.indexOf(item) !== -1 ? unique : [...unique, item], []);
41769       });
41770       if (!_cache3) {
41771         this.reset();
41772       }
41773       this.event = utilRebind(this, dispatch4, "on");
41774     },
41775     reset() {
41776       let _strings = {};
41777       let _colors = {};
41778       if (_cache3) {
41779         Object.values(_cache3.inflightTile).forEach(abortRequest3);
41780         _strings = _cache3.strings;
41781         _colors = _cache3.colors;
41782       }
41783       _cache3 = {
41784         data: {},
41785         loadedTile: {},
41786         inflightTile: {},
41787         inflightPost: {},
41788         closed: {},
41789         rtree: new import_rbush3.default(),
41790         strings: _strings,
41791         colors: _colors
41792       };
41793     },
41794     loadIssues(projection2) {
41795       let params = {
41796         // Tiles return a maximum # of issues
41797         // So we want to filter our request for only types iD supports
41798         item: _osmoseData.items
41799       };
41800       let tiles = tiler3.zoomExtent([_tileZoom3, _tileZoom3]).getTiles(projection2);
41801       abortUnwantedRequests3(_cache3, tiles);
41802       tiles.forEach((tile) => {
41803         if (_cache3.loadedTile[tile.id] || _cache3.inflightTile[tile.id])
41804           return;
41805         let [x2, y2, z2] = tile.xyz;
41806         let url = "".concat(_osmoseUrlRoot, "/issues/").concat(z2, "/").concat(x2, "/").concat(y2, ".geojson?") + utilQsString(params);
41807         let controller = new AbortController();
41808         _cache3.inflightTile[tile.id] = controller;
41809         json_default(url, { signal: controller.signal }).then((data) => {
41810           delete _cache3.inflightTile[tile.id];
41811           _cache3.loadedTile[tile.id] = true;
41812           if (data.features) {
41813             data.features.forEach((issue) => {
41814               const { item, class: cl, uuid: id2 } = issue.properties;
41815               const itemType = "".concat(item, "-").concat(cl);
41816               if (itemType in _osmoseData.icons) {
41817                 let loc = issue.geometry.coordinates;
41818                 loc = preventCoincident2(loc);
41819                 let d2 = new QAItem(loc, this, itemType, id2, { item });
41820                 if (item === 8300 || item === 8360) {
41821                   d2.elems = [];
41822                 }
41823                 _cache3.data[d2.id] = d2;
41824                 _cache3.rtree.insert(encodeIssueRtree3(d2));
41825               }
41826             });
41827           }
41828           dispatch4.call("loaded");
41829         }).catch(() => {
41830           delete _cache3.inflightTile[tile.id];
41831           _cache3.loadedTile[tile.id] = true;
41832         });
41833       });
41834     },
41835     loadIssueDetail(issue) {
41836       if (issue.elems !== void 0) {
41837         return Promise.resolve(issue);
41838       }
41839       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "?langs=").concat(_mainLocalizer.localeCode());
41840       const cacheDetails = (data) => {
41841         issue.elems = data.elems.map((e3) => e3.type.substring(0, 1) + e3.id);
41842         issue.detail = data.subtitle ? marked(data.subtitle.auto) : "";
41843         this.replaceItem(issue);
41844       };
41845       return json_default(url).then(cacheDetails).then(() => issue);
41846     },
41847     loadStrings(locale2 = _mainLocalizer.localeCode()) {
41848       const items = Object.keys(_osmoseData.icons);
41849       if (locale2 in _cache3.strings && Object.keys(_cache3.strings[locale2]).length === items.length) {
41850         return Promise.resolve(_cache3.strings[locale2]);
41851       }
41852       if (!(locale2 in _cache3.strings)) {
41853         _cache3.strings[locale2] = {};
41854       }
41855       const allRequests = items.map((itemType) => {
41856         if (itemType in _cache3.strings[locale2])
41857           return null;
41858         const cacheData = (data) => {
41859           const [cat = { items: [] }] = data.categories;
41860           const [item2 = { class: [] }] = cat.items;
41861           const [cl2 = null] = item2.class;
41862           if (!cl2) {
41863             console.log("Osmose strings request (".concat(itemType, ") had unexpected data"));
41864             return;
41865           }
41866           const { item: itemInt, color: color2 } = item2;
41867           if (/^#[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}/.test(color2)) {
41868             _cache3.colors[itemInt] = color2;
41869           }
41870           const { title, detail, fix, trap } = cl2;
41871           let issueStrings = {};
41872           if (title)
41873             issueStrings.title = title.auto;
41874           if (detail)
41875             issueStrings.detail = marked(detail.auto);
41876           if (trap)
41877             issueStrings.trap = marked(trap.auto);
41878           if (fix)
41879             issueStrings.fix = marked(fix.auto);
41880           _cache3.strings[locale2][itemType] = issueStrings;
41881         };
41882         const [item, cl] = itemType.split("-");
41883         const url = "".concat(_osmoseUrlRoot, "/items/").concat(item, "/class/").concat(cl, "?langs=").concat(locale2);
41884         return json_default(url).then(cacheData);
41885       }).filter(Boolean);
41886       return Promise.all(allRequests).then(() => _cache3.strings[locale2]);
41887     },
41888     getStrings(itemType, locale2 = _mainLocalizer.localeCode()) {
41889       return locale2 in _cache3.strings ? _cache3.strings[locale2][itemType] : {};
41890     },
41891     getColor(itemType) {
41892       return itemType in _cache3.colors ? _cache3.colors[itemType] : "#FFFFFF";
41893     },
41894     postUpdate(issue, callback) {
41895       if (_cache3.inflightPost[issue.id]) {
41896         return callback({ message: "Issue update already inflight", status: -2 }, issue);
41897       }
41898       const url = "".concat(_osmoseUrlRoot, "/issue/").concat(issue.id, "/").concat(issue.newStatus);
41899       const controller = new AbortController();
41900       const after = () => {
41901         delete _cache3.inflightPost[issue.id];
41902         this.removeItem(issue);
41903         if (issue.newStatus === "done") {
41904           if (!(issue.item in _cache3.closed)) {
41905             _cache3.closed[issue.item] = 0;
41906           }
41907           _cache3.closed[issue.item] += 1;
41908         }
41909         if (callback)
41910           callback(null, issue);
41911       };
41912       _cache3.inflightPost[issue.id] = controller;
41913       fetch(url, { signal: controller.signal }).then(after).catch((err) => {
41914         delete _cache3.inflightPost[issue.id];
41915         if (callback)
41916           callback(err.message);
41917       });
41918     },
41919     // Get all cached QAItems covering the viewport
41920     getItems(projection2) {
41921       const viewport = projection2.clipExtent();
41922       const min3 = [viewport[0][0], viewport[1][1]];
41923       const max3 = [viewport[1][0], viewport[0][1]];
41924       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
41925       return _cache3.rtree.search(bbox2).map((d2) => d2.data);
41926     },
41927     // Get a QAItem from cache
41928     // NOTE: Don't change method name until UI v3 is merged
41929     getError(id2) {
41930       return _cache3.data[id2];
41931     },
41932     // get the name of the icon to display for this item
41933     getIcon(itemType) {
41934       return _osmoseData.icons[itemType];
41935     },
41936     // Replace a single QAItem in the cache
41937     replaceItem(item) {
41938       if (!(item instanceof QAItem) || !item.id)
41939         return;
41940       _cache3.data[item.id] = item;
41941       updateRtree3(encodeIssueRtree3(item), true);
41942       return item;
41943     },
41944     // Remove a single QAItem from the cache
41945     removeItem(item) {
41946       if (!(item instanceof QAItem) || !item.id)
41947         return;
41948       delete _cache3.data[item.id];
41949       updateRtree3(encodeIssueRtree3(item), false);
41950     },
41951     // Used to populate `closed:osmose:*` changeset tags
41952     getClosedCounts() {
41953       return _cache3.closed;
41954     },
41955     itemURL(item) {
41956       return "https://osmose.openstreetmap.fr/en/error/".concat(item.id);
41957     }
41958   };
41959
41960   // modules/services/mapillary.js
41961   var import_pbf = __toESM(require_pbf());
41962   var import_rbush4 = __toESM(require_rbush_min());
41963   var import_vector_tile = __toESM(require_vector_tile());
41964   var accessToken = "MLY|4100327730013843|5bb78b81720791946a9a7b956c57b7cf";
41965   var apiUrl = "https://graph.mapillary.com/";
41966   var baseTileUrl = "https://tiles.mapillary.com/maps/vtp";
41967   var mapFeatureTileUrl = "".concat(baseTileUrl, "/mly_map_feature_point/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41968   var tileUrl = "".concat(baseTileUrl, "/mly1_public/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41969   var trafficSignTileUrl = "".concat(baseTileUrl, "/mly_map_feature_traffic_sign/2/{z}/{x}/{y}?access_token=").concat(accessToken);
41970   var viewercss = "mapillary-js/mapillary.css";
41971   var viewerjs = "mapillary-js/mapillary.js";
41972   var minZoom = 14;
41973   var dispatch5 = dispatch_default("change", "loadedImages", "loadedSigns", "loadedMapFeatures", "bearingChanged", "imageChanged");
41974   var _loadViewerPromise;
41975   var _mlyActiveImage;
41976   var _mlyCache;
41977   var _mlyFallback = false;
41978   var _mlyHighlightedDetection;
41979   var _mlyShowFeatureDetections = false;
41980   var _mlyShowSignDetections = false;
41981   var _mlyViewer;
41982   var _mlyViewerFilter = ["all"];
41983   function loadTiles(which, url, maxZoom2, projection2) {
41984     const tiler9 = utilTiler().zoomExtent([minZoom, maxZoom2]).skipNullIsland(true);
41985     const tiles = tiler9.getTiles(projection2);
41986     tiles.forEach(function(tile) {
41987       loadTile(which, url, tile);
41988     });
41989   }
41990   function loadTile(which, url, tile) {
41991     const cache = _mlyCache.requests;
41992     const tileId = "".concat(tile.id, "-").concat(which);
41993     if (cache.loaded[tileId] || cache.inflight[tileId])
41994       return;
41995     const controller = new AbortController();
41996     cache.inflight[tileId] = controller;
41997     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
41998     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
41999       if (!response.ok) {
42000         throw new Error(response.status + " " + response.statusText);
42001       }
42002       cache.loaded[tileId] = true;
42003       delete cache.inflight[tileId];
42004       return response.arrayBuffer();
42005     }).then(function(data) {
42006       if (!data) {
42007         throw new Error("No Data");
42008       }
42009       loadTileDataToCache(data, tile, which);
42010       if (which === "images") {
42011         dispatch5.call("loadedImages");
42012       } else if (which === "signs") {
42013         dispatch5.call("loadedSigns");
42014       } else if (which === "points") {
42015         dispatch5.call("loadedMapFeatures");
42016       }
42017     }).catch(function() {
42018       cache.loaded[tileId] = true;
42019       delete cache.inflight[tileId];
42020     });
42021   }
42022   function loadTileDataToCache(data, tile, which) {
42023     const vectorTile = new import_vector_tile.VectorTile(new import_pbf.default(data));
42024     let features, cache, layer, i3, feature3, loc, d2;
42025     if (vectorTile.layers.hasOwnProperty("image")) {
42026       features = [];
42027       cache = _mlyCache.images;
42028       layer = vectorTile.layers.image;
42029       for (i3 = 0; i3 < layer.length; i3++) {
42030         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42031         loc = feature3.geometry.coordinates;
42032         d2 = {
42033           loc,
42034           captured_at: feature3.properties.captured_at,
42035           ca: feature3.properties.compass_angle,
42036           id: feature3.properties.id,
42037           is_pano: feature3.properties.is_pano,
42038           sequence_id: feature3.properties.sequence_id
42039         };
42040         cache.forImageId[d2.id] = d2;
42041         features.push({
42042           minX: loc[0],
42043           minY: loc[1],
42044           maxX: loc[0],
42045           maxY: loc[1],
42046           data: d2
42047         });
42048       }
42049       if (cache.rtree) {
42050         cache.rtree.load(features);
42051       }
42052     }
42053     if (vectorTile.layers.hasOwnProperty("sequence")) {
42054       features = [];
42055       cache = _mlyCache.sequences;
42056       layer = vectorTile.layers.sequence;
42057       for (i3 = 0; i3 < layer.length; i3++) {
42058         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42059         if (cache.lineString[feature3.properties.id]) {
42060           cache.lineString[feature3.properties.id].push(feature3);
42061         } else {
42062           cache.lineString[feature3.properties.id] = [feature3];
42063         }
42064       }
42065     }
42066     if (vectorTile.layers.hasOwnProperty("point")) {
42067       features = [];
42068       cache = _mlyCache[which];
42069       layer = vectorTile.layers.point;
42070       for (i3 = 0; i3 < layer.length; i3++) {
42071         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42072         loc = feature3.geometry.coordinates;
42073         d2 = {
42074           loc,
42075           id: feature3.properties.id,
42076           first_seen_at: feature3.properties.first_seen_at,
42077           last_seen_at: feature3.properties.last_seen_at,
42078           value: feature3.properties.value
42079         };
42080         features.push({
42081           minX: loc[0],
42082           minY: loc[1],
42083           maxX: loc[0],
42084           maxY: loc[1],
42085           data: d2
42086         });
42087       }
42088       if (cache.rtree) {
42089         cache.rtree.load(features);
42090       }
42091     }
42092     if (vectorTile.layers.hasOwnProperty("traffic_sign")) {
42093       features = [];
42094       cache = _mlyCache[which];
42095       layer = vectorTile.layers.traffic_sign;
42096       for (i3 = 0; i3 < layer.length; i3++) {
42097         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
42098         loc = feature3.geometry.coordinates;
42099         d2 = {
42100           loc,
42101           id: feature3.properties.id,
42102           first_seen_at: feature3.properties.first_seen_at,
42103           last_seen_at: feature3.properties.last_seen_at,
42104           value: feature3.properties.value
42105         };
42106         features.push({
42107           minX: loc[0],
42108           minY: loc[1],
42109           maxX: loc[0],
42110           maxY: loc[1],
42111           data: d2
42112         });
42113       }
42114       if (cache.rtree) {
42115         cache.rtree.load(features);
42116       }
42117     }
42118   }
42119   function loadData(url) {
42120     return fetch(url).then(function(response) {
42121       if (!response.ok) {
42122         throw new Error(response.status + " " + response.statusText);
42123       }
42124       return response.json();
42125     }).then(function(result) {
42126       if (!result) {
42127         return [];
42128       }
42129       return result.data || [];
42130     });
42131   }
42132   function partitionViewport(projection2) {
42133     const z2 = geoScaleToZoom(projection2.scale());
42134     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
42135     const tiler9 = utilTiler().zoomExtent([z22, z22]);
42136     return tiler9.getTiles(projection2).map(function(tile) {
42137       return tile.extent;
42138     });
42139   }
42140   function searchLimited(limit, projection2, rtree) {
42141     limit = limit || 5;
42142     return partitionViewport(projection2).reduce(function(result, extent) {
42143       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
42144         return d2.data;
42145       });
42146       return found.length ? result.concat(found) : result;
42147     }, []);
42148   }
42149   var mapillary_default = {
42150     // Initialize Mapillary
42151     init: function() {
42152       if (!_mlyCache) {
42153         this.reset();
42154       }
42155       this.event = utilRebind(this, dispatch5, "on");
42156     },
42157     // Reset cache and state
42158     reset: function() {
42159       if (_mlyCache) {
42160         Object.values(_mlyCache.requests.inflight).forEach(function(request3) {
42161           request3.abort();
42162         });
42163       }
42164       _mlyCache = {
42165         images: { rtree: new import_rbush4.default(), forImageId: {} },
42166         image_detections: { forImageId: {} },
42167         signs: { rtree: new import_rbush4.default() },
42168         points: { rtree: new import_rbush4.default() },
42169         sequences: { rtree: new import_rbush4.default(), lineString: {} },
42170         requests: { loaded: {}, inflight: {} }
42171       };
42172       _mlyActiveImage = null;
42173     },
42174     // Get visible images
42175     images: function(projection2) {
42176       const limit = 5;
42177       return searchLimited(limit, projection2, _mlyCache.images.rtree);
42178     },
42179     // Get visible traffic signs
42180     signs: function(projection2) {
42181       const limit = 5;
42182       return searchLimited(limit, projection2, _mlyCache.signs.rtree);
42183     },
42184     // Get visible map (point) features
42185     mapFeatures: function(projection2) {
42186       const limit = 5;
42187       return searchLimited(limit, projection2, _mlyCache.points.rtree);
42188     },
42189     // Get cached image by id
42190     cachedImage: function(imageId) {
42191       return _mlyCache.images.forImageId[imageId];
42192     },
42193     // Get visible sequences
42194     sequences: function(projection2) {
42195       const viewport = projection2.clipExtent();
42196       const min3 = [viewport[0][0], viewport[1][1]];
42197       const max3 = [viewport[1][0], viewport[0][1]];
42198       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
42199       const sequenceIds = {};
42200       let lineStrings = [];
42201       _mlyCache.images.rtree.search(bbox2).forEach(function(d2) {
42202         if (d2.data.sequence_id) {
42203           sequenceIds[d2.data.sequence_id] = true;
42204         }
42205       });
42206       Object.keys(sequenceIds).forEach(function(sequenceId) {
42207         if (_mlyCache.sequences.lineString[sequenceId]) {
42208           lineStrings = lineStrings.concat(_mlyCache.sequences.lineString[sequenceId]);
42209         }
42210       });
42211       return lineStrings;
42212     },
42213     // Load images in the visible area
42214     loadImages: function(projection2) {
42215       loadTiles("images", tileUrl, 14, projection2);
42216     },
42217     // Load traffic signs in the visible area
42218     loadSigns: function(projection2) {
42219       loadTiles("signs", trafficSignTileUrl, 14, projection2);
42220     },
42221     // Load map (point) features in the visible area
42222     loadMapFeatures: function(projection2) {
42223       loadTiles("points", mapFeatureTileUrl, 14, projection2);
42224     },
42225     // Return a promise that resolves when the image viewer (Mapillary JS) library has finished loading
42226     ensureViewerLoaded: function(context) {
42227       if (_loadViewerPromise)
42228         return _loadViewerPromise;
42229       const wrap2 = context.container().select(".photoviewer").selectAll(".mly-wrapper").data([0]);
42230       wrap2.enter().append("div").attr("id", "ideditor-mly").attr("class", "photo-wrapper mly-wrapper").classed("hide", true);
42231       const that = this;
42232       _loadViewerPromise = new Promise((resolve, reject) => {
42233         let loadedCount = 0;
42234         function loaded() {
42235           loadedCount += 1;
42236           if (loadedCount === 2)
42237             resolve();
42238         }
42239         const head = select_default2("head");
42240         head.selectAll("#ideditor-mapillary-viewercss").data([0]).enter().append("link").attr("id", "ideditor-mapillary-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(viewercss)).on("load.serviceMapillary", loaded).on("error.serviceMapillary", function() {
42241           reject();
42242         });
42243         head.selectAll("#ideditor-mapillary-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-mapillary-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(viewerjs)).on("load.serviceMapillary", loaded).on("error.serviceMapillary", function() {
42244           reject();
42245         });
42246       }).catch(function() {
42247         _loadViewerPromise = null;
42248       }).then(function() {
42249         that.initViewer(context);
42250       });
42251       return _loadViewerPromise;
42252     },
42253     // Load traffic sign image sprites
42254     loadSignResources: function(context) {
42255       context.ui().svgDefs.addSprites(
42256         ["mapillary-sprite"],
42257         false
42258         /* don't override colors */
42259       );
42260       return this;
42261     },
42262     // Load map (point) feature image sprites
42263     loadObjectResources: function(context) {
42264       context.ui().svgDefs.addSprites(
42265         ["mapillary-object-sprite"],
42266         false
42267         /* don't override colors */
42268       );
42269       return this;
42270     },
42271     // Remove previous detections in image viewer
42272     resetTags: function() {
42273       if (_mlyViewer && !_mlyFallback) {
42274         _mlyViewer.getComponent("tag").removeAll();
42275       }
42276     },
42277     // Show map feature detections in image viewer
42278     showFeatureDetections: function(value) {
42279       _mlyShowFeatureDetections = value;
42280       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
42281         this.resetTags();
42282       }
42283     },
42284     // Show traffic sign detections in image viewer
42285     showSignDetections: function(value) {
42286       _mlyShowSignDetections = value;
42287       if (!_mlyShowFeatureDetections && !_mlyShowSignDetections) {
42288         this.resetTags();
42289       }
42290     },
42291     // Apply filter to image viewer
42292     filterViewer: function(context) {
42293       const showsPano = context.photos().showsPanoramic();
42294       const showsFlat = context.photos().showsFlat();
42295       const fromDate = context.photos().fromDate();
42296       const toDate = context.photos().toDate();
42297       const filter2 = ["all"];
42298       if (!showsPano)
42299         filter2.push(["!=", "cameraType", "spherical"]);
42300       if (!showsFlat && showsPano)
42301         filter2.push(["==", "pano", true]);
42302       if (fromDate) {
42303         filter2.push([">=", "capturedAt", new Date(fromDate).getTime()]);
42304       }
42305       if (toDate) {
42306         filter2.push([">=", "capturedAt", new Date(toDate).getTime()]);
42307       }
42308       if (_mlyViewer) {
42309         _mlyViewer.setFilter(filter2);
42310       }
42311       _mlyViewerFilter = filter2;
42312       return filter2;
42313     },
42314     // Make the image viewer visible
42315     showViewer: function(context) {
42316       const wrap2 = context.container().select(".photoviewer").classed("hide", false);
42317       const isHidden = wrap2.selectAll(".photo-wrapper.mly-wrapper.hide").size();
42318       if (isHidden && _mlyViewer) {
42319         wrap2.selectAll(".photo-wrapper:not(.mly-wrapper)").classed("hide", true);
42320         wrap2.selectAll(".photo-wrapper.mly-wrapper").classed("hide", false);
42321         _mlyViewer.resize();
42322       }
42323       return this;
42324     },
42325     // Hide the image viewer and resets map markers
42326     hideViewer: function(context) {
42327       _mlyActiveImage = null;
42328       if (!_mlyFallback && _mlyViewer) {
42329         _mlyViewer.getComponent("sequence").stop();
42330       }
42331       const viewer = context.container().select(".photoviewer");
42332       if (!viewer.empty())
42333         viewer.datum(null);
42334       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
42335       this.updateUrlImage(null);
42336       dispatch5.call("imageChanged");
42337       dispatch5.call("loadedMapFeatures");
42338       dispatch5.call("loadedSigns");
42339       return this.setStyles(context, null);
42340     },
42341     // Update the URL with current image id
42342     updateUrlImage: function(imageId) {
42343       if (!window.mocha) {
42344         const hash = utilStringQs(window.location.hash);
42345         if (imageId) {
42346           hash.photo = "mapillary/" + imageId;
42347         } else {
42348           delete hash.photo;
42349         }
42350         window.location.replace("#" + utilQsString(hash, true));
42351       }
42352     },
42353     // Highlight the detection in the viewer that is related to the clicked map feature
42354     highlightDetection: function(detection) {
42355       if (detection) {
42356         _mlyHighlightedDetection = detection.id;
42357       }
42358       return this;
42359     },
42360     // Initialize image viewer (Mapillar JS)
42361     initViewer: function(context) {
42362       const that = this;
42363       if (!window.mapillary)
42364         return;
42365       const opts = {
42366         accessToken,
42367         component: {
42368           cover: false,
42369           keyboard: false,
42370           tag: true
42371         },
42372         container: "ideditor-mly"
42373       };
42374       if (!mapillary.isSupported() && mapillary.isFallbackSupported()) {
42375         _mlyFallback = true;
42376         opts.component = {
42377           cover: false,
42378           direction: false,
42379           imagePlane: false,
42380           keyboard: false,
42381           mouse: false,
42382           sequence: false,
42383           tag: false,
42384           image: true,
42385           // fallback
42386           navigation: true
42387           // fallback
42388         };
42389       }
42390       _mlyViewer = new mapillary.Viewer(opts);
42391       _mlyViewer.on("image", imageChanged);
42392       _mlyViewer.on("bearing", bearingChanged);
42393       if (_mlyViewerFilter) {
42394         _mlyViewer.setFilter(_mlyViewerFilter);
42395       }
42396       context.ui().photoviewer.on("resize.mapillary", function() {
42397         if (_mlyViewer)
42398           _mlyViewer.resize();
42399       });
42400       function imageChanged(node) {
42401         that.resetTags();
42402         const image = node.image;
42403         that.setActiveImage(image);
42404         that.setStyles(context, null);
42405         const loc = [image.originalLngLat.lng, image.originalLngLat.lat];
42406         context.map().centerEase(loc);
42407         that.updateUrlImage(image.id);
42408         if (_mlyShowFeatureDetections || _mlyShowSignDetections) {
42409           that.updateDetections(image.id, "".concat(apiUrl, "/").concat(image.id, "/detections?access_token=").concat(accessToken, "&fields=id,image,geometry,value"));
42410         }
42411         dispatch5.call("imageChanged");
42412       }
42413       function bearingChanged(e3) {
42414         dispatch5.call("bearingChanged", void 0, e3);
42415       }
42416     },
42417     // Move to an image
42418     selectImage: function(context, imageId) {
42419       if (_mlyViewer && imageId) {
42420         _mlyViewer.moveTo(imageId).catch(function(e3) {
42421           console.error("mly3", e3);
42422         });
42423       }
42424       return this;
42425     },
42426     // Return the currently displayed image
42427     getActiveImage: function() {
42428       return _mlyActiveImage;
42429     },
42430     // Return a list of detection objects for the given id
42431     getDetections: function(id2) {
42432       return loadData("".concat(apiUrl, "/").concat(id2, "/detections?access_token=").concat(accessToken, "&fields=id,value,image"));
42433     },
42434     // Set the currently visible image
42435     setActiveImage: function(image) {
42436       if (image) {
42437         _mlyActiveImage = {
42438           ca: image.originalCompassAngle,
42439           id: image.id,
42440           loc: [image.originalLngLat.lng, image.originalLngLat.lat],
42441           is_pano: image.cameraType === "spherical",
42442           sequence_id: image.sequenceId
42443         };
42444       } else {
42445         _mlyActiveImage = null;
42446       }
42447     },
42448     // Update the currently highlighted sequence and selected bubble.
42449     setStyles: function(context, hovered) {
42450       const hoveredImageId = hovered && hovered.id;
42451       const hoveredSequenceId = hovered && hovered.sequence_id;
42452       const selectedSequenceId = _mlyActiveImage && _mlyActiveImage.sequence_id;
42453       context.container().selectAll(".layer-mapillary .viewfield-group").classed("highlighted", function(d2) {
42454         return d2.sequence_id === selectedSequenceId || d2.id === hoveredImageId;
42455       }).classed("hovered", function(d2) {
42456         return d2.id === hoveredImageId;
42457       });
42458       context.container().selectAll(".layer-mapillary .sequence").classed("highlighted", function(d2) {
42459         return d2.properties.id === hoveredSequenceId;
42460       }).classed("currentView", function(d2) {
42461         return d2.properties.id === selectedSequenceId;
42462       });
42463       return this;
42464     },
42465     // Get detections for the current image and shows them in the image viewer
42466     updateDetections: function(imageId, url) {
42467       if (!_mlyViewer || _mlyFallback)
42468         return;
42469       if (!imageId)
42470         return;
42471       const cache = _mlyCache.image_detections;
42472       if (cache.forImageId[imageId]) {
42473         showDetections(_mlyCache.image_detections.forImageId[imageId]);
42474       } else {
42475         loadData(url).then((detections) => {
42476           detections.forEach(function(detection) {
42477             if (!cache.forImageId[imageId]) {
42478               cache.forImageId[imageId] = [];
42479             }
42480             cache.forImageId[imageId].push({
42481               geometry: detection.geometry,
42482               id: detection.id,
42483               image_id: imageId,
42484               value: detection.value
42485             });
42486           });
42487           showDetections(_mlyCache.image_detections.forImageId[imageId] || []);
42488         });
42489       }
42490       function showDetections(detections) {
42491         const tagComponent = _mlyViewer.getComponent("tag");
42492         detections.forEach(function(data) {
42493           const tag2 = makeTag(data);
42494           if (tag2) {
42495             tagComponent.add([tag2]);
42496           }
42497         });
42498       }
42499       function makeTag(data) {
42500         const valueParts = data.value.split("--");
42501         if (!valueParts.length)
42502           return;
42503         let tag2;
42504         let text;
42505         let color2 = 16777215;
42506         if (_mlyHighlightedDetection === data.id) {
42507           color2 = 16776960;
42508           text = valueParts[1];
42509           if (text === "flat" || text === "discrete" || text === "sign") {
42510             text = valueParts[2];
42511           }
42512           text = text.replace(/-/g, " ");
42513           text = text.charAt(0).toUpperCase() + text.slice(1);
42514           _mlyHighlightedDetection = null;
42515         }
42516         var decodedGeometry = window.atob(data.geometry);
42517         var uintArray = new Uint8Array(decodedGeometry.length);
42518         for (var i3 = 0; i3 < decodedGeometry.length; i3++) {
42519           uintArray[i3] = decodedGeometry.charCodeAt(i3);
42520         }
42521         const tile = new import_vector_tile.VectorTile(new import_pbf.default(uintArray.buffer));
42522         const layer = tile.layers["mpy-or"];
42523         const geometries = layer.feature(0).loadGeometry();
42524         const polygon2 = geometries.map((ring) => ring.map((point2) => [point2.x / layer.extent, point2.y / layer.extent]));
42525         tag2 = new mapillary.OutlineTag(
42526           data.id,
42527           new mapillary.PolygonGeometry(polygon2[0]),
42528           {
42529             text,
42530             textColor: color2,
42531             lineColor: color2,
42532             lineWidth: 2,
42533             fillColor: color2,
42534             fillOpacity: 0.3
42535           }
42536         );
42537         return tag2;
42538       }
42539     },
42540     // Return the current cache
42541     cache: function() {
42542       return _mlyCache;
42543     }
42544   };
42545
42546   // modules/core/validation/models.js
42547   function validationIssue(attrs) {
42548     this.type = attrs.type;
42549     this.subtype = attrs.subtype;
42550     this.severity = attrs.severity;
42551     this.message = attrs.message;
42552     this.reference = attrs.reference;
42553     this.entityIds = attrs.entityIds;
42554     this.loc = attrs.loc;
42555     this.data = attrs.data;
42556     this.dynamicFixes = attrs.dynamicFixes;
42557     this.hash = attrs.hash;
42558     this.id = generateID.apply(this);
42559     this.key = generateKey.apply(this);
42560     this.autoFix = null;
42561     function generateID() {
42562       var parts = [this.type];
42563       if (this.hash) {
42564         parts.push(this.hash);
42565       }
42566       if (this.subtype) {
42567         parts.push(this.subtype);
42568       }
42569       if (this.entityIds) {
42570         var entityKeys = this.entityIds.slice().sort();
42571         parts.push.apply(parts, entityKeys);
42572       }
42573       return parts.join(":");
42574     }
42575     function generateKey() {
42576       return this.id + ":" + Date.now().toString();
42577     }
42578     this.extent = function(resolver) {
42579       if (this.loc) {
42580         return geoExtent(this.loc);
42581       }
42582       if (this.entityIds && this.entityIds.length) {
42583         return this.entityIds.reduce(function(extent, entityId) {
42584           return extent.extend(resolver.entity(entityId).extent(resolver));
42585         }, geoExtent());
42586       }
42587       return null;
42588     };
42589     this.fixes = function(context) {
42590       var fixes = this.dynamicFixes ? this.dynamicFixes(context) : [];
42591       var issue = this;
42592       if (issue.severity === "warning") {
42593         fixes.push(new validationIssueFix({
42594           title: _t.append("issues.fix.ignore_issue.title"),
42595           icon: "iD-icon-close",
42596           onClick: function() {
42597             context.validator().ignoreIssue(this.issue.id);
42598           }
42599         }));
42600       }
42601       fixes.forEach(function(fix) {
42602         fix.id = fix.title.stringId;
42603         fix.issue = issue;
42604         if (fix.autoArgs) {
42605           issue.autoFix = fix;
42606         }
42607       });
42608       return fixes;
42609     };
42610   }
42611   function validationIssueFix(attrs) {
42612     this.title = attrs.title;
42613     this.onClick = attrs.onClick;
42614     this.disabledReason = attrs.disabledReason;
42615     this.icon = attrs.icon;
42616     this.entityIds = attrs.entityIds || [];
42617     this.autoArgs = attrs.autoArgs;
42618     this.issue = null;
42619   }
42620
42621   // modules/services/maprules.js
42622   var buildRuleChecks = function() {
42623     return {
42624       equals: function(equals) {
42625         return function(tags) {
42626           return Object.keys(equals).every(function(k2) {
42627             return equals[k2] === tags[k2];
42628           });
42629         };
42630       },
42631       notEquals: function(notEquals) {
42632         return function(tags) {
42633           return Object.keys(notEquals).some(function(k2) {
42634             return notEquals[k2] !== tags[k2];
42635           });
42636         };
42637       },
42638       absence: function(absence) {
42639         return function(tags) {
42640           return Object.keys(tags).indexOf(absence) === -1;
42641         };
42642       },
42643       presence: function(presence) {
42644         return function(tags) {
42645           return Object.keys(tags).indexOf(presence) > -1;
42646         };
42647       },
42648       greaterThan: function(greaterThan) {
42649         var key = Object.keys(greaterThan)[0];
42650         var value = greaterThan[key];
42651         return function(tags) {
42652           return tags[key] > value;
42653         };
42654       },
42655       greaterThanEqual: function(greaterThanEqual) {
42656         var key = Object.keys(greaterThanEqual)[0];
42657         var value = greaterThanEqual[key];
42658         return function(tags) {
42659           return tags[key] >= value;
42660         };
42661       },
42662       lessThan: function(lessThan) {
42663         var key = Object.keys(lessThan)[0];
42664         var value = lessThan[key];
42665         return function(tags) {
42666           return tags[key] < value;
42667         };
42668       },
42669       lessThanEqual: function(lessThanEqual) {
42670         var key = Object.keys(lessThanEqual)[0];
42671         var value = lessThanEqual[key];
42672         return function(tags) {
42673           return tags[key] <= value;
42674         };
42675       },
42676       positiveRegex: function(positiveRegex) {
42677         var tagKey = Object.keys(positiveRegex)[0];
42678         var expression = positiveRegex[tagKey].join("|");
42679         var regex = new RegExp(expression);
42680         return function(tags) {
42681           return regex.test(tags[tagKey]);
42682         };
42683       },
42684       negativeRegex: function(negativeRegex) {
42685         var tagKey = Object.keys(negativeRegex)[0];
42686         var expression = negativeRegex[tagKey].join("|");
42687         var regex = new RegExp(expression);
42688         return function(tags) {
42689           return !regex.test(tags[tagKey]);
42690         };
42691       }
42692     };
42693   };
42694   var buildLineKeys = function() {
42695     return {
42696       highway: {
42697         rest_area: true,
42698         services: true
42699       },
42700       railway: {
42701         roundhouse: true,
42702         station: true,
42703         traverser: true,
42704         turntable: true,
42705         wash: true
42706       }
42707     };
42708   };
42709   var maprules_default = {
42710     init: function() {
42711       this._ruleChecks = buildRuleChecks();
42712       this._validationRules = [];
42713       this._areaKeys = osmAreaKeys;
42714       this._lineKeys = buildLineKeys();
42715     },
42716     // list of rules only relevant to tag checks...
42717     filterRuleChecks: function(selector) {
42718       var _ruleChecks = this._ruleChecks;
42719       return Object.keys(selector).reduce(function(rules, key) {
42720         if (["geometry", "error", "warning"].indexOf(key) === -1) {
42721           rules.push(_ruleChecks[key](selector[key]));
42722         }
42723         return rules;
42724       }, []);
42725     },
42726     // builds tagMap from mapcss-parse selector object...
42727     buildTagMap: function(selector) {
42728       var getRegexValues = function(regexes) {
42729         return regexes.map(function(regex) {
42730           return regex.replace(/\$|\^/g, "");
42731         });
42732       };
42733       var tagMap = Object.keys(selector).reduce(function(expectedTags, key) {
42734         var values;
42735         var isRegex = /regex/gi.test(key);
42736         var isEqual4 = /equals/gi.test(key);
42737         if (isRegex || isEqual4) {
42738           Object.keys(selector[key]).forEach(function(selectorKey) {
42739             values = isEqual4 ? [selector[key][selectorKey]] : getRegexValues(selector[key][selectorKey]);
42740             if (expectedTags.hasOwnProperty(selectorKey)) {
42741               values = values.concat(expectedTags[selectorKey]);
42742             }
42743             expectedTags[selectorKey] = values;
42744           });
42745         } else if (/(greater|less)Than(Equal)?|presence/g.test(key)) {
42746           var tagKey = /presence/.test(key) ? selector[key] : Object.keys(selector[key])[0];
42747           values = [selector[key][tagKey]];
42748           if (expectedTags.hasOwnProperty(tagKey)) {
42749             values = values.concat(expectedTags[tagKey]);
42750           }
42751           expectedTags[tagKey] = values;
42752         }
42753         return expectedTags;
42754       }, {});
42755       return tagMap;
42756     },
42757     // inspired by osmWay#isArea()
42758     inferGeometry: function(tagMap) {
42759       var _lineKeys = this._lineKeys;
42760       var _areaKeys = this._areaKeys;
42761       var keyValueDoesNotImplyArea = function(key2) {
42762         return utilArrayIntersection(tagMap[key2], Object.keys(_areaKeys[key2])).length > 0;
42763       };
42764       var keyValueImpliesLine = function(key2) {
42765         return utilArrayIntersection(tagMap[key2], Object.keys(_lineKeys[key2])).length > 0;
42766       };
42767       if (tagMap.hasOwnProperty("area")) {
42768         if (tagMap.area.indexOf("yes") > -1) {
42769           return "area";
42770         }
42771         if (tagMap.area.indexOf("no") > -1) {
42772           return "line";
42773         }
42774       }
42775       for (var key in tagMap) {
42776         if (key in _areaKeys && !keyValueDoesNotImplyArea(key)) {
42777           return "area";
42778         }
42779         if (key in _lineKeys && keyValueImpliesLine(key)) {
42780           return "area";
42781         }
42782       }
42783       return "line";
42784     },
42785     // adds from mapcss-parse selector check...
42786     addRule: function(selector) {
42787       var rule = {
42788         // checks relevant to mapcss-selector
42789         checks: this.filterRuleChecks(selector),
42790         // true if all conditions for a tag error are true..
42791         matches: function(entity) {
42792           return this.checks.every(function(check) {
42793             return check(entity.tags);
42794           });
42795         },
42796         // borrowed from Way#isArea()
42797         inferredGeometry: this.inferGeometry(this.buildTagMap(selector), this._areaKeys),
42798         geometryMatches: function(entity, graph) {
42799           if (entity.type === "node" || entity.type === "relation") {
42800             return selector.geometry === entity.type;
42801           } else if (entity.type === "way") {
42802             return this.inferredGeometry === entity.geometry(graph);
42803           }
42804         },
42805         // when geometries match and tag matches are present, return a warning...
42806         findIssues: function(entity, graph, issues) {
42807           if (this.geometryMatches(entity, graph) && this.matches(entity)) {
42808             var severity = Object.keys(selector).indexOf("error") > -1 ? "error" : "warning";
42809             var message = selector[severity];
42810             issues.push(new validationIssue({
42811               type: "maprules",
42812               severity,
42813               message: function() {
42814                 return message;
42815               },
42816               entityIds: [entity.id]
42817             }));
42818           }
42819         }
42820       };
42821       this._validationRules.push(rule);
42822     },
42823     clearRules: function() {
42824       this._validationRules = [];
42825     },
42826     // returns validationRules...
42827     validationRules: function() {
42828       return this._validationRules;
42829     },
42830     // returns ruleChecks
42831     ruleChecks: function() {
42832       return this._ruleChecks;
42833     }
42834   };
42835
42836   // modules/services/nominatim.js
42837   var import_rbush7 = __toESM(require_rbush_min());
42838
42839   // modules/core/difference.js
42840   var import_fast_deep_equal3 = __toESM(require_fast_deep_equal());
42841   function coreDifference(base, head) {
42842     var _changes = {};
42843     var _didChange = {};
42844     var _diff = {};
42845     function checkEntityID(id2) {
42846       var h2 = head.entities[id2];
42847       var b2 = base.entities[id2];
42848       if (h2 === b2)
42849         return;
42850       if (_changes[id2])
42851         return;
42852       if (!h2 && b2) {
42853         _changes[id2] = { base: b2, head: h2 };
42854         _didChange.deletion = true;
42855         return;
42856       }
42857       if (h2 && !b2) {
42858         _changes[id2] = { base: b2, head: h2 };
42859         _didChange.addition = true;
42860         return;
42861       }
42862       if (h2 && b2) {
42863         if (h2.members && b2.members && !(0, import_fast_deep_equal3.default)(h2.members, b2.members)) {
42864           _changes[id2] = { base: b2, head: h2 };
42865           _didChange.geometry = true;
42866           _didChange.properties = true;
42867           return;
42868         }
42869         if (h2.loc && b2.loc && !geoVecEqual(h2.loc, b2.loc)) {
42870           _changes[id2] = { base: b2, head: h2 };
42871           _didChange.geometry = true;
42872         }
42873         if (h2.nodes && b2.nodes && !(0, import_fast_deep_equal3.default)(h2.nodes, b2.nodes)) {
42874           _changes[id2] = { base: b2, head: h2 };
42875           _didChange.geometry = true;
42876         }
42877         if (h2.tags && b2.tags && !(0, import_fast_deep_equal3.default)(h2.tags, b2.tags)) {
42878           _changes[id2] = { base: b2, head: h2 };
42879           _didChange.properties = true;
42880         }
42881       }
42882     }
42883     function load() {
42884       var ids = utilArrayUniq(Object.keys(head.entities).concat(Object.keys(base.entities)));
42885       for (var i3 = 0; i3 < ids.length; i3++) {
42886         checkEntityID(ids[i3]);
42887       }
42888     }
42889     load();
42890     _diff.length = function length2() {
42891       return Object.keys(_changes).length;
42892     };
42893     _diff.changes = function changes() {
42894       return _changes;
42895     };
42896     _diff.didChange = _didChange;
42897     _diff.extantIDs = function extantIDs(includeRelMembers) {
42898       var result = /* @__PURE__ */ new Set();
42899       Object.keys(_changes).forEach(function(id2) {
42900         if (_changes[id2].head) {
42901           result.add(id2);
42902         }
42903         var h2 = _changes[id2].head;
42904         var b2 = _changes[id2].base;
42905         var entity = h2 || b2;
42906         if (includeRelMembers && entity.type === "relation") {
42907           var mh = h2 ? h2.members.map(function(m2) {
42908             return m2.id;
42909           }) : [];
42910           var mb = b2 ? b2.members.map(function(m2) {
42911             return m2.id;
42912           }) : [];
42913           utilArrayUnion(mh, mb).forEach(function(memberID) {
42914             if (head.hasEntity(memberID)) {
42915               result.add(memberID);
42916             }
42917           });
42918         }
42919       });
42920       return Array.from(result);
42921     };
42922     _diff.modified = function modified() {
42923       var result = [];
42924       Object.values(_changes).forEach(function(change) {
42925         if (change.base && change.head) {
42926           result.push(change.head);
42927         }
42928       });
42929       return result;
42930     };
42931     _diff.created = function created() {
42932       var result = [];
42933       Object.values(_changes).forEach(function(change) {
42934         if (!change.base && change.head) {
42935           result.push(change.head);
42936         }
42937       });
42938       return result;
42939     };
42940     _diff.deleted = function deleted() {
42941       var result = [];
42942       Object.values(_changes).forEach(function(change) {
42943         if (change.base && !change.head) {
42944           result.push(change.base);
42945         }
42946       });
42947       return result;
42948     };
42949     _diff.summary = function summary() {
42950       var relevant = {};
42951       var keys2 = Object.keys(_changes);
42952       for (var i3 = 0; i3 < keys2.length; i3++) {
42953         var change = _changes[keys2[i3]];
42954         if (change.head && change.head.geometry(head) !== "vertex") {
42955           addEntity(change.head, head, change.base ? "modified" : "created");
42956         } else if (change.base && change.base.geometry(base) !== "vertex") {
42957           addEntity(change.base, base, "deleted");
42958         } else if (change.base && change.head) {
42959           var moved = !(0, import_fast_deep_equal3.default)(change.base.loc, change.head.loc);
42960           var retagged = !(0, import_fast_deep_equal3.default)(change.base.tags, change.head.tags);
42961           if (moved) {
42962             addParents(change.head);
42963           }
42964           if (retagged || moved && change.head.hasInterestingTags()) {
42965             addEntity(change.head, head, "modified");
42966           }
42967         } else if (change.head && change.head.hasInterestingTags()) {
42968           addEntity(change.head, head, "created");
42969         } else if (change.base && change.base.hasInterestingTags()) {
42970           addEntity(change.base, base, "deleted");
42971         }
42972       }
42973       return Object.values(relevant);
42974       function addEntity(entity, graph, changeType) {
42975         relevant[entity.id] = {
42976           entity,
42977           graph,
42978           changeType
42979         };
42980       }
42981       function addParents(entity) {
42982         var parents = head.parentWays(entity);
42983         for (var j2 = parents.length - 1; j2 >= 0; j2--) {
42984           var parent = parents[j2];
42985           if (!(parent.id in relevant)) {
42986             addEntity(parent, head, "modified");
42987           }
42988         }
42989       }
42990     };
42991     _diff.complete = function complete(extent) {
42992       var result = {};
42993       var id2, change;
42994       for (id2 in _changes) {
42995         change = _changes[id2];
42996         var h2 = change.head;
42997         var b2 = change.base;
42998         var entity = h2 || b2;
42999         var i3;
43000         if (extent && (!h2 || !h2.intersects(extent, head)) && (!b2 || !b2.intersects(extent, base))) {
43001           continue;
43002         }
43003         result[id2] = h2;
43004         if (entity.type === "way") {
43005           var nh = h2 ? h2.nodes : [];
43006           var nb = b2 ? b2.nodes : [];
43007           var diff;
43008           diff = utilArrayDifference(nh, nb);
43009           for (i3 = 0; i3 < diff.length; i3++) {
43010             result[diff[i3]] = head.hasEntity(diff[i3]);
43011           }
43012           diff = utilArrayDifference(nb, nh);
43013           for (i3 = 0; i3 < diff.length; i3++) {
43014             result[diff[i3]] = head.hasEntity(diff[i3]);
43015           }
43016         }
43017         if (entity.type === "relation" && entity.isMultipolygon()) {
43018           var mh = h2 ? h2.members.map(function(m2) {
43019             return m2.id;
43020           }) : [];
43021           var mb = b2 ? b2.members.map(function(m2) {
43022             return m2.id;
43023           }) : [];
43024           var ids = utilArrayUnion(mh, mb);
43025           for (i3 = 0; i3 < ids.length; i3++) {
43026             var member = head.hasEntity(ids[i3]);
43027             if (!member)
43028               continue;
43029             if (extent && !member.intersects(extent, head))
43030               continue;
43031             result[ids[i3]] = member;
43032           }
43033         }
43034         addParents(head.parentWays(entity), result);
43035         addParents(head.parentRelations(entity), result);
43036       }
43037       return result;
43038       function addParents(parents, result2) {
43039         for (var i4 = 0; i4 < parents.length; i4++) {
43040           var parent = parents[i4];
43041           if (parent.id in result2)
43042             continue;
43043           result2[parent.id] = parent;
43044           addParents(head.parentRelations(parent), result2);
43045         }
43046       }
43047     };
43048     return _diff;
43049   }
43050
43051   // modules/core/tree.js
43052   var import_rbush5 = __toESM(require_rbush_min());
43053   function coreTree(head) {
43054     var _rtree = new import_rbush5.default();
43055     var _bboxes = {};
43056     var _segmentsRTree = new import_rbush5.default();
43057     var _segmentsBBoxes = {};
43058     var _segmentsByWayId = {};
43059     var tree = {};
43060     function entityBBox(entity) {
43061       var bbox2 = entity.extent(head).bbox();
43062       bbox2.id = entity.id;
43063       _bboxes[entity.id] = bbox2;
43064       return bbox2;
43065     }
43066     function segmentBBox(segment) {
43067       var extent = segment.extent(head);
43068       if (!extent)
43069         return null;
43070       var bbox2 = extent.bbox();
43071       bbox2.segment = segment;
43072       _segmentsBBoxes[segment.id] = bbox2;
43073       return bbox2;
43074     }
43075     function removeEntity(entity) {
43076       _rtree.remove(_bboxes[entity.id]);
43077       delete _bboxes[entity.id];
43078       if (_segmentsByWayId[entity.id]) {
43079         _segmentsByWayId[entity.id].forEach(function(segment) {
43080           _segmentsRTree.remove(_segmentsBBoxes[segment.id]);
43081           delete _segmentsBBoxes[segment.id];
43082         });
43083         delete _segmentsByWayId[entity.id];
43084       }
43085     }
43086     function loadEntities(entities) {
43087       _rtree.load(entities.map(entityBBox));
43088       var segments = [];
43089       entities.forEach(function(entity) {
43090         if (entity.segments) {
43091           var entitySegments = entity.segments(head);
43092           _segmentsByWayId[entity.id] = entitySegments;
43093           segments = segments.concat(entitySegments);
43094         }
43095       });
43096       if (segments.length)
43097         _segmentsRTree.load(segments.map(segmentBBox).filter(Boolean));
43098     }
43099     function updateParents(entity, insertions, memo) {
43100       head.parentWays(entity).forEach(function(way) {
43101         if (_bboxes[way.id]) {
43102           removeEntity(way);
43103           insertions[way.id] = way;
43104         }
43105         updateParents(way, insertions, memo);
43106       });
43107       head.parentRelations(entity).forEach(function(relation) {
43108         if (memo[entity.id])
43109           return;
43110         memo[entity.id] = true;
43111         if (_bboxes[relation.id]) {
43112           removeEntity(relation);
43113           insertions[relation.id] = relation;
43114         }
43115         updateParents(relation, insertions, memo);
43116       });
43117     }
43118     tree.rebase = function(entities, force) {
43119       var insertions = {};
43120       for (var i3 = 0; i3 < entities.length; i3++) {
43121         var entity = entities[i3];
43122         if (!entity.visible)
43123           continue;
43124         if (head.entities.hasOwnProperty(entity.id) || _bboxes[entity.id]) {
43125           if (!force) {
43126             continue;
43127           } else if (_bboxes[entity.id]) {
43128             removeEntity(entity);
43129           }
43130         }
43131         insertions[entity.id] = entity;
43132         updateParents(entity, insertions, {});
43133       }
43134       loadEntities(Object.values(insertions));
43135       return tree;
43136     };
43137     function updateToGraph(graph) {
43138       if (graph === head)
43139         return;
43140       var diff = coreDifference(head, graph);
43141       head = graph;
43142       var changed = diff.didChange;
43143       if (!changed.addition && !changed.deletion && !changed.geometry)
43144         return;
43145       var insertions = {};
43146       if (changed.deletion) {
43147         diff.deleted().forEach(function(entity) {
43148           removeEntity(entity);
43149         });
43150       }
43151       if (changed.geometry) {
43152         diff.modified().forEach(function(entity) {
43153           removeEntity(entity);
43154           insertions[entity.id] = entity;
43155           updateParents(entity, insertions, {});
43156         });
43157       }
43158       if (changed.addition) {
43159         diff.created().forEach(function(entity) {
43160           insertions[entity.id] = entity;
43161         });
43162       }
43163       loadEntities(Object.values(insertions));
43164     }
43165     tree.intersects = function(extent, graph) {
43166       updateToGraph(graph);
43167       return _rtree.search(extent.bbox()).map(function(bbox2) {
43168         return graph.entity(bbox2.id);
43169       });
43170     };
43171     tree.waySegments = function(extent, graph) {
43172       updateToGraph(graph);
43173       return _segmentsRTree.search(extent.bbox()).map(function(bbox2) {
43174         return bbox2.segment;
43175       });
43176     };
43177     return tree;
43178   }
43179
43180   // modules/svg/icon.js
43181   function svgIcon(name, svgklass, useklass) {
43182     return function drawIcon(selection2) {
43183       selection2.selectAll("svg.icon" + (svgklass ? "." + svgklass.split(" ")[0] : "")).data([0]).enter().append("svg").attr("class", "icon " + (svgklass || "")).append("use").attr("xlink:href", name).attr("class", useklass);
43184     };
43185   }
43186
43187   // modules/ui/modal.js
43188   function uiModal(selection2, blocking) {
43189     let keybinding = utilKeybinding("modal");
43190     let previous = selection2.select("div.modal");
43191     let animate = previous.empty();
43192     previous.transition().duration(200).style("opacity", 0).remove();
43193     let shaded = selection2.append("div").attr("class", "shaded").style("opacity", 0);
43194     shaded.close = () => {
43195       shaded.transition().duration(200).style("opacity", 0).remove();
43196       modal.transition().duration(200).style("top", "0px");
43197       select_default2(document).call(keybinding.unbind);
43198     };
43199     let modal = shaded.append("div").attr("class", "modal fillL");
43200     modal.append("input").attr("class", "keytrap keytrap-first").on("focus.keytrap", moveFocusToLast);
43201     if (!blocking) {
43202       shaded.on("click.remove-modal", (d3_event) => {
43203         if (d3_event.target === this) {
43204           shaded.close();
43205         }
43206       });
43207       modal.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", shaded.close).call(svgIcon("#iD-icon-close"));
43208       keybinding.on("\u232B", shaded.close).on("\u238B", shaded.close);
43209       select_default2(document).call(keybinding);
43210     }
43211     modal.append("div").attr("class", "content");
43212     modal.append("input").attr("class", "keytrap keytrap-last").on("focus.keytrap", moveFocusToFirst);
43213     if (animate) {
43214       shaded.transition().style("opacity", 1);
43215     } else {
43216       shaded.style("opacity", 1);
43217     }
43218     return shaded;
43219     function moveFocusToFirst() {
43220       let node = modal.select("a, button, input:not(.keytrap), select, textarea").node();
43221       if (node) {
43222         node.focus();
43223       } else {
43224         select_default2(this).node().blur();
43225       }
43226     }
43227     function moveFocusToLast() {
43228       let nodes = modal.selectAll("a, button, input:not(.keytrap), select, textarea").nodes();
43229       if (nodes.length) {
43230         nodes[nodes.length - 1].focus();
43231       } else {
43232         select_default2(this).node().blur();
43233       }
43234     }
43235   }
43236
43237   // modules/ui/loading.js
43238   function uiLoading(context) {
43239     let _modalSelection = select_default2(null);
43240     let _message = "";
43241     let _blocking = false;
43242     let loading = (selection2) => {
43243       _modalSelection = uiModal(selection2, _blocking);
43244       let loadertext = _modalSelection.select(".content").classed("loading-modal", true).append("div").attr("class", "modal-section fillL");
43245       loadertext.append("img").attr("class", "loader").attr("src", context.imagePath("loader-white.gif"));
43246       loadertext.append("h3").html(_message);
43247       _modalSelection.select("button.close").attr("class", "hide");
43248       return loading;
43249     };
43250     loading.message = function(val) {
43251       if (!arguments.length)
43252         return _message;
43253       _message = val;
43254       return loading;
43255     };
43256     loading.blocking = function(val) {
43257       if (!arguments.length)
43258         return _blocking;
43259       _blocking = val;
43260       return loading;
43261     };
43262     loading.close = () => {
43263       _modalSelection.remove();
43264     };
43265     loading.isShown = () => {
43266       return _modalSelection && !_modalSelection.empty() && _modalSelection.node().parentNode;
43267     };
43268     return loading;
43269   }
43270
43271   // modules/core/history.js
43272   function coreHistory(context) {
43273     var dispatch14 = dispatch_default("reset", "change", "merge", "restore", "undone", "redone", "storage_error");
43274     var lock = utilSessionMutex("lock");
43275     var _hasUnresolvedRestorableChanges = lock.lock() && !!corePreferences(getKey("saved_history"));
43276     var duration = 150;
43277     var _imageryUsed = [];
43278     var _photoOverlaysUsed = [];
43279     var _checkpoints = {};
43280     var _pausedGraph;
43281     var _stack;
43282     var _index;
43283     var _tree;
43284     function _act(actions, t2) {
43285       actions = Array.prototype.slice.call(actions);
43286       var annotation;
43287       if (typeof actions[actions.length - 1] !== "function") {
43288         annotation = actions.pop();
43289       }
43290       var graph = _stack[_index].graph;
43291       for (var i3 = 0; i3 < actions.length; i3++) {
43292         graph = actions[i3](graph, t2);
43293       }
43294       return {
43295         graph,
43296         annotation,
43297         imageryUsed: _imageryUsed,
43298         photoOverlaysUsed: _photoOverlaysUsed,
43299         transform: context.projection.transform(),
43300         selectedIDs: context.selectedIDs()
43301       };
43302     }
43303     function _perform(args, t2) {
43304       var previous = _stack[_index].graph;
43305       _stack = _stack.slice(0, _index + 1);
43306       var actionResult = _act(args, t2);
43307       _stack.push(actionResult);
43308       _index++;
43309       return change(previous);
43310     }
43311     function _replace(args, t2) {
43312       var previous = _stack[_index].graph;
43313       var actionResult = _act(args, t2);
43314       _stack[_index] = actionResult;
43315       return change(previous);
43316     }
43317     function _overwrite(args, t2) {
43318       var previous = _stack[_index].graph;
43319       if (_index > 0) {
43320         _index--;
43321         _stack.pop();
43322       }
43323       _stack = _stack.slice(0, _index + 1);
43324       var actionResult = _act(args, t2);
43325       _stack.push(actionResult);
43326       _index++;
43327       return change(previous);
43328     }
43329     function change(previous) {
43330       var difference2 = coreDifference(previous, history.graph());
43331       if (!_pausedGraph) {
43332         dispatch14.call("change", this, difference2);
43333       }
43334       return difference2;
43335     }
43336     function getKey(n3) {
43337       return "iD_" + window.location.origin + "_" + n3;
43338     }
43339     var history = {
43340       graph: function() {
43341         return _stack[_index].graph;
43342       },
43343       tree: function() {
43344         return _tree;
43345       },
43346       base: function() {
43347         return _stack[0].graph;
43348       },
43349       merge: function(entities) {
43350         var stack = _stack.map(function(state) {
43351           return state.graph;
43352         });
43353         _stack[0].graph.rebase(entities, stack, false);
43354         _tree.rebase(entities, false);
43355         dispatch14.call("merge", this, entities);
43356       },
43357       perform: function() {
43358         select_default2(document).interrupt("history.perform");
43359         var transitionable = false;
43360         var action0 = arguments[0];
43361         if (arguments.length === 1 || arguments.length === 2 && typeof arguments[1] !== "function") {
43362           transitionable = !!action0.transitionable;
43363         }
43364         if (transitionable) {
43365           var origArguments = arguments;
43366           select_default2(document).transition("history.perform").duration(duration).ease(linear2).tween("history.tween", function() {
43367             return function(t2) {
43368               if (t2 < 1)
43369                 _overwrite([action0], t2);
43370             };
43371           }).on("start", function() {
43372             _perform([action0], 0);
43373           }).on("end interrupt", function() {
43374             _overwrite(origArguments, 1);
43375           });
43376         } else {
43377           return _perform(arguments);
43378         }
43379       },
43380       replace: function() {
43381         select_default2(document).interrupt("history.perform");
43382         return _replace(arguments, 1);
43383       },
43384       // Same as calling pop and then perform
43385       overwrite: function() {
43386         select_default2(document).interrupt("history.perform");
43387         return _overwrite(arguments, 1);
43388       },
43389       pop: function(n3) {
43390         select_default2(document).interrupt("history.perform");
43391         var previous = _stack[_index].graph;
43392         if (isNaN(+n3) || +n3 < 0) {
43393           n3 = 1;
43394         }
43395         while (n3-- > 0 && _index > 0) {
43396           _index--;
43397           _stack.pop();
43398         }
43399         return change(previous);
43400       },
43401       // Back to the previous annotated state or _index = 0.
43402       undo: function() {
43403         select_default2(document).interrupt("history.perform");
43404         var previousStack = _stack[_index];
43405         var previous = previousStack.graph;
43406         while (_index > 0) {
43407           _index--;
43408           if (_stack[_index].annotation)
43409             break;
43410         }
43411         dispatch14.call("undone", this, _stack[_index], previousStack);
43412         return change(previous);
43413       },
43414       // Forward to the next annotated state.
43415       redo: function() {
43416         select_default2(document).interrupt("history.perform");
43417         var previousStack = _stack[_index];
43418         var previous = previousStack.graph;
43419         var tryIndex = _index;
43420         while (tryIndex < _stack.length - 1) {
43421           tryIndex++;
43422           if (_stack[tryIndex].annotation) {
43423             _index = tryIndex;
43424             dispatch14.call("redone", this, _stack[_index], previousStack);
43425             break;
43426           }
43427         }
43428         return change(previous);
43429       },
43430       pauseChangeDispatch: function() {
43431         if (!_pausedGraph) {
43432           _pausedGraph = _stack[_index].graph;
43433         }
43434       },
43435       resumeChangeDispatch: function() {
43436         if (_pausedGraph) {
43437           var previous = _pausedGraph;
43438           _pausedGraph = null;
43439           return change(previous);
43440         }
43441       },
43442       undoAnnotation: function() {
43443         var i3 = _index;
43444         while (i3 >= 0) {
43445           if (_stack[i3].annotation)
43446             return _stack[i3].annotation;
43447           i3--;
43448         }
43449       },
43450       redoAnnotation: function() {
43451         var i3 = _index + 1;
43452         while (i3 <= _stack.length - 1) {
43453           if (_stack[i3].annotation)
43454             return _stack[i3].annotation;
43455           i3++;
43456         }
43457       },
43458       // Returns the entities from the active graph with bounding boxes
43459       // overlapping the given `extent`.
43460       intersects: function(extent) {
43461         return _tree.intersects(extent, _stack[_index].graph);
43462       },
43463       difference: function() {
43464         var base = _stack[0].graph;
43465         var head = _stack[_index].graph;
43466         return coreDifference(base, head);
43467       },
43468       changes: function(action) {
43469         var base = _stack[0].graph;
43470         var head = _stack[_index].graph;
43471         if (action) {
43472           head = action(head);
43473         }
43474         var difference2 = coreDifference(base, head);
43475         return {
43476           modified: difference2.modified(),
43477           created: difference2.created(),
43478           deleted: difference2.deleted()
43479         };
43480       },
43481       hasChanges: function() {
43482         return this.difference().length() > 0;
43483       },
43484       imageryUsed: function(sources) {
43485         if (sources) {
43486           _imageryUsed = sources;
43487           return history;
43488         } else {
43489           var s2 = /* @__PURE__ */ new Set();
43490           _stack.slice(1, _index + 1).forEach(function(state) {
43491             state.imageryUsed.forEach(function(source) {
43492               if (source !== "Custom") {
43493                 s2.add(source);
43494               }
43495             });
43496           });
43497           return Array.from(s2);
43498         }
43499       },
43500       photoOverlaysUsed: function(sources) {
43501         if (sources) {
43502           _photoOverlaysUsed = sources;
43503           return history;
43504         } else {
43505           var s2 = /* @__PURE__ */ new Set();
43506           _stack.slice(1, _index + 1).forEach(function(state) {
43507             if (state.photoOverlaysUsed && Array.isArray(state.photoOverlaysUsed)) {
43508               state.photoOverlaysUsed.forEach(function(photoOverlay) {
43509                 s2.add(photoOverlay);
43510               });
43511             }
43512           });
43513           return Array.from(s2);
43514         }
43515       },
43516       // save the current history state
43517       checkpoint: function(key) {
43518         _checkpoints[key] = {
43519           stack: _stack,
43520           index: _index
43521         };
43522         return history;
43523       },
43524       // restore history state to a given checkpoint or reset completely
43525       reset: function(key) {
43526         if (key !== void 0 && _checkpoints.hasOwnProperty(key)) {
43527           _stack = _checkpoints[key].stack;
43528           _index = _checkpoints[key].index;
43529         } else {
43530           _stack = [{ graph: coreGraph() }];
43531           _index = 0;
43532           _tree = coreTree(_stack[0].graph);
43533           _checkpoints = {};
43534         }
43535         dispatch14.call("reset");
43536         dispatch14.call("change");
43537         return history;
43538       },
43539       // `toIntroGraph()` is used to export the intro graph used by the walkthrough.
43540       //
43541       // To use it:
43542       //  1. Start the walkthrough.
43543       //  2. Get to a "free editing" tutorial step
43544       //  3. Make your edits to the walkthrough map
43545       //  4. In your browser dev console run:
43546       //        `id.history().toIntroGraph()`
43547       //  5. This outputs stringified JSON to the browser console
43548       //  6. Copy it to `data/intro_graph.json` and prettify it in your code editor
43549       toIntroGraph: function() {
43550         var nextID = { n: 0, r: 0, w: 0 };
43551         var permIDs = {};
43552         var graph = this.graph();
43553         var baseEntities = {};
43554         Object.values(graph.base().entities).forEach(function(entity) {
43555           var copy2 = copyIntroEntity(entity);
43556           baseEntities[copy2.id] = copy2;
43557         });
43558         Object.keys(graph.entities).forEach(function(id2) {
43559           var entity = graph.entities[id2];
43560           if (entity) {
43561             var copy2 = copyIntroEntity(entity);
43562             baseEntities[copy2.id] = copy2;
43563           } else {
43564             delete baseEntities[id2];
43565           }
43566         });
43567         Object.values(baseEntities).forEach(function(entity) {
43568           if (Array.isArray(entity.nodes)) {
43569             entity.nodes = entity.nodes.map(function(node) {
43570               return permIDs[node] || node;
43571             });
43572           }
43573           if (Array.isArray(entity.members)) {
43574             entity.members = entity.members.map(function(member) {
43575               member.id = permIDs[member.id] || member.id;
43576               return member;
43577             });
43578           }
43579         });
43580         return JSON.stringify({ dataIntroGraph: baseEntities });
43581         function copyIntroEntity(source) {
43582           var copy2 = utilObjectOmit(source, ["type", "user", "v", "version", "visible"]);
43583           if (copy2.tags && !Object.keys(copy2.tags)) {
43584             delete copy2.tags;
43585           }
43586           if (Array.isArray(copy2.loc)) {
43587             copy2.loc[0] = +copy2.loc[0].toFixed(6);
43588             copy2.loc[1] = +copy2.loc[1].toFixed(6);
43589           }
43590           var match = source.id.match(/([nrw])-\d*/);
43591           if (match !== null) {
43592             var nrw = match[1];
43593             var permID;
43594             do {
43595               permID = nrw + ++nextID[nrw];
43596             } while (baseEntities.hasOwnProperty(permID));
43597             copy2.id = permIDs[source.id] = permID;
43598           }
43599           return copy2;
43600         }
43601       },
43602       toJSON: function() {
43603         if (!this.hasChanges())
43604           return;
43605         var allEntities = {};
43606         var baseEntities = {};
43607         var base = _stack[0];
43608         var s2 = _stack.map(function(i3) {
43609           var modified = [];
43610           var deleted = [];
43611           Object.keys(i3.graph.entities).forEach(function(id2) {
43612             var entity = i3.graph.entities[id2];
43613             if (entity) {
43614               var key = osmEntity.key(entity);
43615               allEntities[key] = entity;
43616               modified.push(key);
43617             } else {
43618               deleted.push(id2);
43619             }
43620             if (id2 in base.graph.entities) {
43621               baseEntities[id2] = base.graph.entities[id2];
43622             }
43623             if (entity && entity.nodes) {
43624               entity.nodes.forEach(function(nodeID) {
43625                 if (nodeID in base.graph.entities) {
43626                   baseEntities[nodeID] = base.graph.entities[nodeID];
43627                 }
43628               });
43629             }
43630             var baseParents = base.graph._parentWays[id2];
43631             if (baseParents) {
43632               baseParents.forEach(function(parentID) {
43633                 if (parentID in base.graph.entities) {
43634                   baseEntities[parentID] = base.graph.entities[parentID];
43635                 }
43636               });
43637             }
43638           });
43639           var x2 = {};
43640           if (modified.length)
43641             x2.modified = modified;
43642           if (deleted.length)
43643             x2.deleted = deleted;
43644           if (i3.imageryUsed)
43645             x2.imageryUsed = i3.imageryUsed;
43646           if (i3.photoOverlaysUsed)
43647             x2.photoOverlaysUsed = i3.photoOverlaysUsed;
43648           if (i3.annotation)
43649             x2.annotation = i3.annotation;
43650           if (i3.transform)
43651             x2.transform = i3.transform;
43652           if (i3.selectedIDs)
43653             x2.selectedIDs = i3.selectedIDs;
43654           return x2;
43655         });
43656         return JSON.stringify({
43657           version: 3,
43658           entities: Object.values(allEntities),
43659           baseEntities: Object.values(baseEntities),
43660           stack: s2,
43661           nextIDs: osmEntity.id.next,
43662           index: _index,
43663           // note the time the changes were saved
43664           timestamp: (/* @__PURE__ */ new Date()).getTime()
43665         });
43666       },
43667       fromJSON: function(json, loadChildNodes) {
43668         var h2 = JSON.parse(json);
43669         var loadComplete = true;
43670         osmEntity.id.next = h2.nextIDs;
43671         _index = h2.index;
43672         if (h2.version === 2 || h2.version === 3) {
43673           var allEntities = {};
43674           h2.entities.forEach(function(entity) {
43675             allEntities[osmEntity.key(entity)] = osmEntity(entity);
43676           });
43677           if (h2.version === 3) {
43678             var baseEntities = h2.baseEntities.map(function(d2) {
43679               return osmEntity(d2);
43680             });
43681             var stack = _stack.map(function(state) {
43682               return state.graph;
43683             });
43684             _stack[0].graph.rebase(baseEntities, stack, true);
43685             _tree.rebase(baseEntities, true);
43686             if (loadChildNodes) {
43687               var osm = context.connection();
43688               var baseWays = baseEntities.filter(function(e3) {
43689                 return e3.type === "way";
43690               });
43691               var nodeIDs = baseWays.reduce(function(acc, way) {
43692                 return utilArrayUnion(acc, way.nodes);
43693               }, []);
43694               var missing = nodeIDs.filter(function(n3) {
43695                 return !_stack[0].graph.hasEntity(n3);
43696               });
43697               if (missing.length && osm) {
43698                 loadComplete = false;
43699                 context.map().redrawEnable(false);
43700                 var loading = uiLoading(context).blocking(true);
43701                 context.container().call(loading);
43702                 var childNodesLoaded = function(err, result) {
43703                   if (!err) {
43704                     var visibleGroups = utilArrayGroupBy(result.data, "visible");
43705                     var visibles = visibleGroups.true || [];
43706                     var invisibles = visibleGroups.false || [];
43707                     if (visibles.length) {
43708                       var visibleIDs = visibles.map(function(entity) {
43709                         return entity.id;
43710                       });
43711                       var stack2 = _stack.map(function(state) {
43712                         return state.graph;
43713                       });
43714                       missing = utilArrayDifference(missing, visibleIDs);
43715                       _stack[0].graph.rebase(visibles, stack2, true);
43716                       _tree.rebase(visibles, true);
43717                     }
43718                     invisibles.forEach(function(entity) {
43719                       osm.loadEntityVersion(entity.id, +entity.version - 1, childNodesLoaded);
43720                     });
43721                   }
43722                   if (err || !missing.length) {
43723                     loading.close();
43724                     context.map().redrawEnable(true);
43725                     dispatch14.call("change");
43726                     dispatch14.call("restore", this);
43727                   }
43728                 };
43729                 osm.loadMultiple(missing, childNodesLoaded);
43730               }
43731             }
43732           }
43733           _stack = h2.stack.map(function(d2) {
43734             var entities = {}, entity;
43735             if (d2.modified) {
43736               d2.modified.forEach(function(key) {
43737                 entity = allEntities[key];
43738                 entities[entity.id] = entity;
43739               });
43740             }
43741             if (d2.deleted) {
43742               d2.deleted.forEach(function(id2) {
43743                 entities[id2] = void 0;
43744               });
43745             }
43746             return {
43747               graph: coreGraph(_stack[0].graph).load(entities),
43748               annotation: d2.annotation,
43749               imageryUsed: d2.imageryUsed,
43750               photoOverlaysUsed: d2.photoOverlaysUsed,
43751               transform: d2.transform,
43752               selectedIDs: d2.selectedIDs
43753             };
43754           });
43755         } else {
43756           _stack = h2.stack.map(function(d2) {
43757             var entities = {};
43758             for (var i3 in d2.entities) {
43759               var entity = d2.entities[i3];
43760               entities[i3] = entity === "undefined" ? void 0 : osmEntity(entity);
43761             }
43762             d2.graph = coreGraph(_stack[0].graph).load(entities);
43763             return d2;
43764           });
43765         }
43766         var transform2 = _stack[_index].transform;
43767         if (transform2) {
43768           context.map().transformEase(transform2, 0);
43769         }
43770         if (loadComplete) {
43771           dispatch14.call("change");
43772           dispatch14.call("restore", this);
43773         }
43774         return history;
43775       },
43776       lock: function() {
43777         return lock.lock();
43778       },
43779       unlock: function() {
43780         lock.unlock();
43781       },
43782       save: function() {
43783         if (lock.locked() && // don't overwrite existing, unresolved changes
43784         !_hasUnresolvedRestorableChanges) {
43785           const success = corePreferences(getKey("saved_history"), history.toJSON() || null);
43786           if (!success)
43787             dispatch14.call("storage_error");
43788         }
43789         return history;
43790       },
43791       // delete the history version saved in localStorage
43792       clearSaved: function() {
43793         context.debouncedSave.cancel();
43794         if (lock.locked()) {
43795           _hasUnresolvedRestorableChanges = false;
43796           corePreferences(getKey("saved_history"), null);
43797           corePreferences("comment", null);
43798           corePreferences("hashtags", null);
43799           corePreferences("source", null);
43800         }
43801         return history;
43802       },
43803       savedHistoryJSON: function() {
43804         return corePreferences(getKey("saved_history"));
43805       },
43806       hasRestorableChanges: function() {
43807         return _hasUnresolvedRestorableChanges;
43808       },
43809       // load history from a version stored in localStorage
43810       restore: function() {
43811         if (lock.locked()) {
43812           _hasUnresolvedRestorableChanges = false;
43813           var json = this.savedHistoryJSON();
43814           if (json)
43815             history.fromJSON(json, true);
43816         }
43817       },
43818       _getKey: getKey
43819     };
43820     history.reset();
43821     return utilRebind(history, dispatch14, "on");
43822   }
43823
43824   // modules/validations/index.js
43825   var validations_exports = {};
43826   __export(validations_exports, {
43827     validationAlmostJunction: () => validationAlmostJunction,
43828     validationCloseNodes: () => validationCloseNodes,
43829     validationCrossingWays: () => validationCrossingWays,
43830     validationDisconnectedWay: () => validationDisconnectedWay,
43831     validationFormatting: () => validationFormatting,
43832     validationHelpRequest: () => validationHelpRequest,
43833     validationImpossibleOneway: () => validationImpossibleOneway,
43834     validationIncompatibleSource: () => validationIncompatibleSource,
43835     validationMaprules: () => validationMaprules,
43836     validationMismatchedGeometry: () => validationMismatchedGeometry,
43837     validationMissingRole: () => validationMissingRole,
43838     validationMissingTag: () => validationMissingTag,
43839     validationMutuallyExclusiveTags: () => validationMutuallyExclusiveTags,
43840     validationOutdatedTags: () => validationOutdatedTags,
43841     validationPrivateData: () => validationPrivateData,
43842     validationSuspiciousName: () => validationSuspiciousName,
43843     validationUnsquareWay: () => validationUnsquareWay
43844   });
43845
43846   // modules/validations/almost_junction.js
43847   function validationAlmostJunction(context) {
43848     const type2 = "almost_junction";
43849     const EXTEND_TH_METERS = 5;
43850     const WELD_TH_METERS = 0.75;
43851     const CLOSE_NODE_TH = EXTEND_TH_METERS - WELD_TH_METERS;
43852     const SIG_ANGLE_TH = Math.atan(WELD_TH_METERS / EXTEND_TH_METERS);
43853     function isHighway(entity) {
43854       return entity.type === "way" && osmRoutableHighwayTagValues[entity.tags.highway];
43855     }
43856     function isTaggedAsNotContinuing(node) {
43857       return node.tags.noexit === "yes" || node.tags.amenity === "parking_entrance" || node.tags.entrance && node.tags.entrance !== "no";
43858     }
43859     const validation = function checkAlmostJunction(entity, graph) {
43860       if (!isHighway(entity))
43861         return [];
43862       if (entity.isDegenerate())
43863         return [];
43864       const tree = context.history().tree();
43865       const extendableNodeInfos = findConnectableEndNodesByExtension(entity);
43866       let issues = [];
43867       extendableNodeInfos.forEach((extendableNodeInfo) => {
43868         issues.push(new validationIssue({
43869           type: type2,
43870           subtype: "highway-highway",
43871           severity: "warning",
43872           message: function(context2) {
43873             const entity1 = context2.hasEntity(this.entityIds[0]);
43874             if (this.entityIds[0] === this.entityIds[2]) {
43875               return entity1 ? _t.append("issues.almost_junction.self.message", {
43876                 feature: utilDisplayLabel(entity1, context2.graph())
43877               }) : "";
43878             } else {
43879               const entity2 = context2.hasEntity(this.entityIds[2]);
43880               return entity1 && entity2 ? _t.append("issues.almost_junction.message", {
43881                 feature: utilDisplayLabel(entity1, context2.graph()),
43882                 feature2: utilDisplayLabel(entity2, context2.graph())
43883               }) : "";
43884             }
43885           },
43886           reference: showReference,
43887           entityIds: [
43888             entity.id,
43889             extendableNodeInfo.node.id,
43890             extendableNodeInfo.wid
43891           ],
43892           loc: extendableNodeInfo.node.loc,
43893           hash: JSON.stringify(extendableNodeInfo.node.loc),
43894           data: {
43895             midId: extendableNodeInfo.mid.id,
43896             edge: extendableNodeInfo.edge,
43897             cross_loc: extendableNodeInfo.cross_loc
43898           },
43899           dynamicFixes: makeFixes
43900         }));
43901       });
43902       return issues;
43903       function makeFixes(context2) {
43904         let fixes = [new validationIssueFix({
43905           icon: "iD-icon-abutment",
43906           title: _t.append("issues.fix.connect_features.title"),
43907           onClick: function(context3) {
43908             const annotation = _t("issues.fix.connect_almost_junction.annotation");
43909             const [, endNodeId, crossWayId] = this.issue.entityIds;
43910             const midNode = context3.entity(this.issue.data.midId);
43911             const endNode = context3.entity(endNodeId);
43912             const crossWay = context3.entity(crossWayId);
43913             const nearEndNodes = findNearbyEndNodes(endNode, crossWay);
43914             if (nearEndNodes.length > 0) {
43915               const collinear = findSmallJoinAngle(midNode, endNode, nearEndNodes);
43916               if (collinear) {
43917                 context3.perform(
43918                   actionMergeNodes([collinear.id, endNode.id], collinear.loc),
43919                   annotation
43920                 );
43921                 return;
43922               }
43923             }
43924             const targetEdge = this.issue.data.edge;
43925             const crossLoc = this.issue.data.cross_loc;
43926             const edgeNodes = [context3.entity(targetEdge[0]), context3.entity(targetEdge[1])];
43927             const closestNodeInfo = geoSphericalClosestNode(edgeNodes, crossLoc);
43928             if (closestNodeInfo.distance < WELD_TH_METERS) {
43929               context3.perform(
43930                 actionMergeNodes([closestNodeInfo.node.id, endNode.id], closestNodeInfo.node.loc),
43931                 annotation
43932               );
43933             } else {
43934               context3.perform(
43935                 actionAddMidpoint({ loc: crossLoc, edge: targetEdge }, endNode),
43936                 annotation
43937               );
43938             }
43939           }
43940         })];
43941         const node = context2.hasEntity(this.entityIds[1]);
43942         if (node && !node.hasInterestingTags()) {
43943           fixes.push(new validationIssueFix({
43944             icon: "maki-barrier",
43945             title: _t.append("issues.fix.tag_as_disconnected.title"),
43946             onClick: function(context3) {
43947               const nodeID = this.issue.entityIds[1];
43948               const tags = Object.assign({}, context3.entity(nodeID).tags);
43949               tags.noexit = "yes";
43950               context3.perform(
43951                 actionChangeTags(nodeID, tags),
43952                 _t("issues.fix.tag_as_disconnected.annotation")
43953               );
43954             }
43955           }));
43956         }
43957         return fixes;
43958       }
43959       function showReference(selection2) {
43960         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.almost_junction.highway-highway.reference"));
43961       }
43962       function isExtendableCandidate(node, way) {
43963         const osm = services.osm;
43964         if (osm && !osm.isDataLoaded(node.loc)) {
43965           return false;
43966         }
43967         if (isTaggedAsNotContinuing(node) || graph.parentWays(node).length !== 1) {
43968           return false;
43969         }
43970         let occurrences = 0;
43971         for (const index in way.nodes) {
43972           if (way.nodes[index] === node.id) {
43973             occurrences += 1;
43974             if (occurrences > 1) {
43975               return false;
43976             }
43977           }
43978         }
43979         return true;
43980       }
43981       function findConnectableEndNodesByExtension(way) {
43982         let results = [];
43983         if (way.isClosed())
43984           return results;
43985         let testNodes;
43986         const indices = [0, way.nodes.length - 1];
43987         indices.forEach((nodeIndex) => {
43988           const nodeID = way.nodes[nodeIndex];
43989           const node = graph.entity(nodeID);
43990           if (!isExtendableCandidate(node, way))
43991             return;
43992           const connectionInfo = canConnectByExtend(way, nodeIndex);
43993           if (!connectionInfo)
43994             return;
43995           testNodes = graph.childNodes(way).slice();
43996           testNodes[nodeIndex] = testNodes[nodeIndex].move(connectionInfo.cross_loc);
43997           if (geoHasSelfIntersections(testNodes, nodeID))
43998             return;
43999           results.push(connectionInfo);
44000         });
44001         return results;
44002       }
44003       function findNearbyEndNodes(node, way) {
44004         return [
44005           way.nodes[0],
44006           way.nodes[way.nodes.length - 1]
44007         ].map((d2) => graph.entity(d2)).filter((d2) => {
44008           return d2.id !== node.id && geoSphericalDistance(node.loc, d2.loc) <= CLOSE_NODE_TH;
44009         });
44010       }
44011       function findSmallJoinAngle(midNode, tipNode, endNodes) {
44012         let joinTo;
44013         let minAngle = Infinity;
44014         endNodes.forEach((endNode) => {
44015           const a1 = geoAngle(midNode, tipNode, context.projection) + Math.PI;
44016           const a2 = geoAngle(midNode, endNode, context.projection) + Math.PI;
44017           const diff = Math.max(a1, a2) - Math.min(a1, a2);
44018           if (diff < minAngle) {
44019             joinTo = endNode;
44020             minAngle = diff;
44021           }
44022         });
44023         if (minAngle <= SIG_ANGLE_TH)
44024           return joinTo;
44025         return null;
44026       }
44027       function hasTag(tags, key) {
44028         return tags[key] !== void 0 && tags[key] !== "no";
44029       }
44030       function canConnectWays(way, way2) {
44031         if (way.id === way2.id)
44032           return true;
44033         if ((hasTag(way.tags, "bridge") || hasTag(way2.tags, "bridge")) && !(hasTag(way.tags, "bridge") && hasTag(way2.tags, "bridge")))
44034           return false;
44035         if ((hasTag(way.tags, "tunnel") || hasTag(way2.tags, "tunnel")) && !(hasTag(way.tags, "tunnel") && hasTag(way2.tags, "tunnel")))
44036           return false;
44037         const layer1 = way.tags.layer || "0", layer2 = way2.tags.layer || "0";
44038         if (layer1 !== layer2)
44039           return false;
44040         const level1 = way.tags.level || "0", level2 = way2.tags.level || "0";
44041         if (level1 !== level2)
44042           return false;
44043         return true;
44044       }
44045       function canConnectByExtend(way, endNodeIdx) {
44046         const tipNid = way.nodes[endNodeIdx];
44047         const midNid = endNodeIdx === 0 ? way.nodes[1] : way.nodes[way.nodes.length - 2];
44048         const tipNode = graph.entity(tipNid);
44049         const midNode = graph.entity(midNid);
44050         const lon = tipNode.loc[0];
44051         const lat = tipNode.loc[1];
44052         const lon_range = geoMetersToLon(EXTEND_TH_METERS, lat) / 2;
44053         const lat_range = geoMetersToLat(EXTEND_TH_METERS) / 2;
44054         const queryExtent = geoExtent([
44055           [lon - lon_range, lat - lat_range],
44056           [lon + lon_range, lat + lat_range]
44057         ]);
44058         const edgeLen = geoSphericalDistance(midNode.loc, tipNode.loc);
44059         const t2 = EXTEND_TH_METERS / edgeLen + 1;
44060         const extTipLoc = geoVecInterp(midNode.loc, tipNode.loc, t2);
44061         const segmentInfos = tree.waySegments(queryExtent, graph);
44062         for (let i3 = 0; i3 < segmentInfos.length; i3++) {
44063           let segmentInfo = segmentInfos[i3];
44064           let way2 = graph.entity(segmentInfo.wayId);
44065           if (!isHighway(way2))
44066             continue;
44067           if (!canConnectWays(way, way2))
44068             continue;
44069           let nAid = segmentInfo.nodes[0], nBid = segmentInfo.nodes[1];
44070           if (nAid === tipNid || nBid === tipNid)
44071             continue;
44072           let nA = graph.entity(nAid), nB = graph.entity(nBid);
44073           let crossLoc = geoLineIntersection([tipNode.loc, extTipLoc], [nA.loc, nB.loc]);
44074           if (crossLoc) {
44075             return {
44076               mid: midNode,
44077               node: tipNode,
44078               wid: way2.id,
44079               edge: [nA.id, nB.id],
44080               cross_loc: crossLoc
44081             };
44082           }
44083         }
44084         return null;
44085       }
44086     };
44087     validation.type = type2;
44088     return validation;
44089   }
44090
44091   // modules/validations/close_nodes.js
44092   function validationCloseNodes(context) {
44093     var type2 = "close_nodes";
44094     var pointThresholdMeters = 0.2;
44095     var validation = function(entity, graph) {
44096       if (entity.type === "node") {
44097         return getIssuesForNode(entity);
44098       } else if (entity.type === "way") {
44099         return getIssuesForWay(entity);
44100       }
44101       return [];
44102       function getIssuesForNode(node) {
44103         var parentWays = graph.parentWays(node);
44104         if (parentWays.length) {
44105           return getIssuesForVertex(node, parentWays);
44106         } else {
44107           return getIssuesForDetachedPoint(node);
44108         }
44109       }
44110       function wayTypeFor(way) {
44111         if (way.tags.boundary && way.tags.boundary !== "no")
44112           return "boundary";
44113         if (way.tags.indoor && way.tags.indoor !== "no")
44114           return "indoor";
44115         if (way.tags.building && way.tags.building !== "no" || way.tags["building:part"] && way.tags["building:part"] !== "no")
44116           return "building";
44117         if (osmPathHighwayTagValues[way.tags.highway])
44118           return "path";
44119         var parentRelations = graph.parentRelations(way);
44120         for (var i3 in parentRelations) {
44121           var relation = parentRelations[i3];
44122           if (relation.tags.type === "boundary")
44123             return "boundary";
44124           if (relation.isMultipolygon()) {
44125             if (relation.tags.indoor && relation.tags.indoor !== "no")
44126               return "indoor";
44127             if (relation.tags.building && relation.tags.building !== "no" || relation.tags["building:part"] && relation.tags["building:part"] !== "no")
44128               return "building";
44129           }
44130         }
44131         return "other";
44132       }
44133       function shouldCheckWay(way) {
44134         if (way.nodes.length <= 2 || way.isClosed() && way.nodes.length <= 4)
44135           return false;
44136         var bbox2 = way.extent(graph).bbox();
44137         var hypotenuseMeters = geoSphericalDistance([bbox2.minX, bbox2.minY], [bbox2.maxX, bbox2.maxY]);
44138         if (hypotenuseMeters < 1.5)
44139           return false;
44140         return true;
44141       }
44142       function getIssuesForWay(way) {
44143         if (!shouldCheckWay(way))
44144           return [];
44145         var issues = [], nodes = graph.childNodes(way);
44146         for (var i3 = 0; i3 < nodes.length - 1; i3++) {
44147           var node1 = nodes[i3];
44148           var node2 = nodes[i3 + 1];
44149           var issue = getWayIssueIfAny(node1, node2, way);
44150           if (issue)
44151             issues.push(issue);
44152         }
44153         return issues;
44154       }
44155       function getIssuesForVertex(node, parentWays) {
44156         var issues = [];
44157         function checkForCloseness(node1, node2, way) {
44158           var issue = getWayIssueIfAny(node1, node2, way);
44159           if (issue)
44160             issues.push(issue);
44161         }
44162         for (var i3 = 0; i3 < parentWays.length; i3++) {
44163           var parentWay = parentWays[i3];
44164           if (!shouldCheckWay(parentWay))
44165             continue;
44166           var lastIndex = parentWay.nodes.length - 1;
44167           for (var j2 = 0; j2 < parentWay.nodes.length; j2++) {
44168             if (j2 !== 0) {
44169               if (parentWay.nodes[j2 - 1] === node.id) {
44170                 checkForCloseness(node, graph.entity(parentWay.nodes[j2]), parentWay);
44171               }
44172             }
44173             if (j2 !== lastIndex) {
44174               if (parentWay.nodes[j2 + 1] === node.id) {
44175                 checkForCloseness(graph.entity(parentWay.nodes[j2]), node, parentWay);
44176               }
44177             }
44178           }
44179         }
44180         return issues;
44181       }
44182       function thresholdMetersForWay(way) {
44183         if (!shouldCheckWay(way))
44184           return 0;
44185         var wayType = wayTypeFor(way);
44186         if (wayType === "boundary")
44187           return 0;
44188         if (wayType === "indoor")
44189           return 0.01;
44190         if (wayType === "building")
44191           return 0.05;
44192         if (wayType === "path")
44193           return 0.1;
44194         return 0.2;
44195       }
44196       function getIssuesForDetachedPoint(node) {
44197         var issues = [];
44198         var lon = node.loc[0];
44199         var lat = node.loc[1];
44200         var lon_range = geoMetersToLon(pointThresholdMeters, lat) / 2;
44201         var lat_range = geoMetersToLat(pointThresholdMeters) / 2;
44202         var queryExtent = geoExtent([
44203           [lon - lon_range, lat - lat_range],
44204           [lon + lon_range, lat + lat_range]
44205         ]);
44206         var intersected = context.history().tree().intersects(queryExtent, graph);
44207         for (var j2 = 0; j2 < intersected.length; j2++) {
44208           var nearby = intersected[j2];
44209           if (nearby.id === node.id)
44210             continue;
44211           if (nearby.type !== "node" || nearby.geometry(graph) !== "point")
44212             continue;
44213           if (nearby.loc === node.loc || geoSphericalDistance(node.loc, nearby.loc) < pointThresholdMeters) {
44214             if ("memorial:type" in node.tags && "memorial:type" in nearby.tags && node.tags["memorial:type"] === "stolperstein" && nearby.tags["memorial:type"] === "stolperstein")
44215               continue;
44216             if ("memorial" in node.tags && "memorial" in nearby.tags && node.tags.memorial === "stolperstein" && nearby.tags.memorial === "stolperstein")
44217               continue;
44218             var zAxisKeys = { layer: true, level: true, "addr:housenumber": true, "addr:unit": true };
44219             var zAxisDifferentiates = false;
44220             for (var key in zAxisKeys) {
44221               var nodeValue = node.tags[key] || "0";
44222               var nearbyValue = nearby.tags[key] || "0";
44223               if (nodeValue !== nearbyValue) {
44224                 zAxisDifferentiates = true;
44225                 break;
44226               }
44227             }
44228             if (zAxisDifferentiates)
44229               continue;
44230             issues.push(new validationIssue({
44231               type: type2,
44232               subtype: "detached",
44233               severity: "warning",
44234               message: function(context2) {
44235                 var entity2 = context2.hasEntity(this.entityIds[0]), entity22 = context2.hasEntity(this.entityIds[1]);
44236                 return entity2 && entity22 ? _t.append("issues.close_nodes.detached.message", {
44237                   feature: utilDisplayLabel(entity2, context2.graph()),
44238                   feature2: utilDisplayLabel(entity22, context2.graph())
44239                 }) : "";
44240               },
44241               reference: showReference,
44242               entityIds: [node.id, nearby.id],
44243               dynamicFixes: function() {
44244                 return [
44245                   new validationIssueFix({
44246                     icon: "iD-operation-disconnect",
44247                     title: _t.append("issues.fix.move_points_apart.title")
44248                   }),
44249                   new validationIssueFix({
44250                     icon: "iD-icon-layers",
44251                     title: _t.append("issues.fix.use_different_layers_or_levels.title")
44252                   })
44253                 ];
44254               }
44255             }));
44256           }
44257         }
44258         return issues;
44259         function showReference(selection2) {
44260           var referenceText = _t("issues.close_nodes.detached.reference");
44261           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
44262         }
44263       }
44264       function getWayIssueIfAny(node1, node2, way) {
44265         if (node1.id === node2.id || node1.hasInterestingTags() && node2.hasInterestingTags()) {
44266           return null;
44267         }
44268         if (node1.loc !== node2.loc) {
44269           var parentWays1 = graph.parentWays(node1);
44270           var parentWays2 = new Set(graph.parentWays(node2));
44271           var sharedWays = parentWays1.filter(function(parentWay) {
44272             return parentWays2.has(parentWay);
44273           });
44274           var thresholds = sharedWays.map(function(parentWay) {
44275             return thresholdMetersForWay(parentWay);
44276           });
44277           var threshold = Math.min(...thresholds);
44278           var distance = geoSphericalDistance(node1.loc, node2.loc);
44279           if (distance > threshold)
44280             return null;
44281         }
44282         return new validationIssue({
44283           type: type2,
44284           subtype: "vertices",
44285           severity: "warning",
44286           message: function(context2) {
44287             var entity2 = context2.hasEntity(this.entityIds[0]);
44288             return entity2 ? _t.append("issues.close_nodes.message", { way: utilDisplayLabel(entity2, context2.graph()) }) : "";
44289           },
44290           reference: showReference,
44291           entityIds: [way.id, node1.id, node2.id],
44292           loc: node1.loc,
44293           dynamicFixes: function() {
44294             return [
44295               new validationIssueFix({
44296                 icon: "iD-icon-plus",
44297                 title: _t.append("issues.fix.merge_points.title"),
44298                 onClick: function(context2) {
44299                   var entityIds = this.issue.entityIds;
44300                   var action = actionMergeNodes([entityIds[1], entityIds[2]]);
44301                   context2.perform(action, _t("issues.fix.merge_close_vertices.annotation"));
44302                 }
44303               }),
44304               new validationIssueFix({
44305                 icon: "iD-operation-disconnect",
44306                 title: _t.append("issues.fix.move_points_apart.title")
44307               })
44308             ];
44309           }
44310         });
44311         function showReference(selection2) {
44312           var referenceText = _t("issues.close_nodes.reference");
44313           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").html(referenceText);
44314         }
44315       }
44316     };
44317     validation.type = type2;
44318     return validation;
44319   }
44320
44321   // modules/validations/crossing_ways.js
44322   var import_lodash3 = __toESM(require_lodash());
44323   function validationCrossingWays(context) {
44324     var type2 = "crossing_ways";
44325     function getFeatureWithFeatureTypeTagsForWay(way, graph) {
44326       if (getFeatureType(way, graph) === null) {
44327         var parentRels = graph.parentRelations(way);
44328         for (var i3 = 0; i3 < parentRels.length; i3++) {
44329           var rel = parentRels[i3];
44330           if (getFeatureType(rel, graph) !== null) {
44331             return rel;
44332           }
44333         }
44334       }
44335       return way;
44336     }
44337     function hasTag(tags, key) {
44338       return tags[key] !== void 0 && tags[key] !== "no";
44339     }
44340     function taggedAsIndoor(tags) {
44341       return hasTag(tags, "indoor") || hasTag(tags, "level") || tags.highway === "corridor";
44342     }
44343     function allowsBridge(featureType) {
44344       return featureType === "highway" || featureType === "railway" || featureType === "waterway";
44345     }
44346     function allowsTunnel(featureType) {
44347       return featureType === "highway" || featureType === "railway" || featureType === "waterway";
44348     }
44349     var ignoredBuildings = {
44350       demolished: true,
44351       dismantled: true,
44352       proposed: true,
44353       razed: true
44354     };
44355     function getFeatureType(entity, graph) {
44356       var geometry = entity.geometry(graph);
44357       if (geometry !== "line" && geometry !== "area")
44358         return null;
44359       var tags = entity.tags;
44360       if (hasTag(tags, "building") && !ignoredBuildings[tags.building])
44361         return "building";
44362       if (hasTag(tags, "highway") && osmRoutableHighwayTagValues[tags.highway])
44363         return "highway";
44364       if (geometry !== "line")
44365         return null;
44366       if (hasTag(tags, "railway") && osmRailwayTrackTagValues[tags.railway])
44367         return "railway";
44368       if (hasTag(tags, "waterway") && osmFlowingWaterwayTagValues[tags.waterway])
44369         return "waterway";
44370       return null;
44371     }
44372     function isLegitCrossing(tags1, featureType1, tags2, featureType2) {
44373       var level1 = tags1.level || "0";
44374       var level2 = tags2.level || "0";
44375       if (taggedAsIndoor(tags1) && taggedAsIndoor(tags2) && level1 !== level2) {
44376         return true;
44377       }
44378       var layer1 = tags1.layer || "0";
44379       var layer2 = tags2.layer || "0";
44380       if (allowsBridge(featureType1) && allowsBridge(featureType2)) {
44381         if (hasTag(tags1, "bridge") && !hasTag(tags2, "bridge"))
44382           return true;
44383         if (!hasTag(tags1, "bridge") && hasTag(tags2, "bridge"))
44384           return true;
44385         if (hasTag(tags1, "bridge") && hasTag(tags2, "bridge") && layer1 !== layer2)
44386           return true;
44387       } else if (allowsBridge(featureType1) && hasTag(tags1, "bridge"))
44388         return true;
44389       else if (allowsBridge(featureType2) && hasTag(tags2, "bridge"))
44390         return true;
44391       if (allowsTunnel(featureType1) && allowsTunnel(featureType2)) {
44392         if (hasTag(tags1, "tunnel") && !hasTag(tags2, "tunnel"))
44393           return true;
44394         if (!hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel"))
44395           return true;
44396         if (hasTag(tags1, "tunnel") && hasTag(tags2, "tunnel") && layer1 !== layer2)
44397           return true;
44398       } else if (allowsTunnel(featureType1) && hasTag(tags1, "tunnel"))
44399         return true;
44400       else if (allowsTunnel(featureType2) && hasTag(tags2, "tunnel"))
44401         return true;
44402       if (featureType1 === "waterway" && featureType2 === "highway" && tags2.man_made === "pier")
44403         return true;
44404       if (featureType2 === "waterway" && featureType1 === "highway" && tags1.man_made === "pier")
44405         return true;
44406       if (featureType1 === "building" || featureType2 === "building" || taggedAsIndoor(tags1) || taggedAsIndoor(tags2)) {
44407         if (layer1 !== layer2)
44408           return true;
44409       }
44410       return false;
44411     }
44412     var highwaysDisallowingFords = {
44413       motorway: true,
44414       motorway_link: true,
44415       trunk: true,
44416       trunk_link: true,
44417       primary: true,
44418       primary_link: true,
44419       secondary: true,
44420       secondary_link: true
44421     };
44422     function tagsForConnectionNodeIfAllowed(entity1, entity2, graph, lessLikelyTags) {
44423       var featureType1 = getFeatureType(entity1, graph);
44424       var featureType2 = getFeatureType(entity2, graph);
44425       var geometry1 = entity1.geometry(graph);
44426       var geometry2 = entity2.geometry(graph);
44427       var bothLines = geometry1 === "line" && geometry2 === "line";
44428       if (featureType1 === featureType2) {
44429         if (featureType1 === "highway") {
44430           var entity1IsPath = osmPathHighwayTagValues[entity1.tags.highway];
44431           var entity2IsPath = osmPathHighwayTagValues[entity2.tags.highway];
44432           if ((entity1IsPath || entity2IsPath) && entity1IsPath !== entity2IsPath) {
44433             var roadFeature = entity1IsPath ? entity2 : entity1;
44434             var pathFeature = entity1IsPath ? entity1 : entity2;
44435             if (roadFeature.tags.highway === "track") {
44436               return {};
44437             }
44438             if (!lessLikelyTags && roadFeature.tags.highway === "service" && pathFeature.tags.highway === "footway" && pathFeature.tags.footway === "sidewalk") {
44439               return {};
44440             }
44441             if (["marked", "unmarked", "traffic_signals", "uncontrolled"].indexOf(pathFeature.tags.crossing) !== -1) {
44442               return bothLines ? { highway: "crossing", crossing: pathFeature.tags.crossing } : {};
44443             }
44444             return bothLines ? { highway: "crossing" } : {};
44445           }
44446           return {};
44447         }
44448         if (featureType1 === "waterway")
44449           return {};
44450         if (featureType1 === "railway")
44451           return {};
44452       } else {
44453         var featureTypes = [featureType1, featureType2];
44454         if (featureTypes.indexOf("highway") !== -1) {
44455           if (featureTypes.indexOf("railway") !== -1) {
44456             if (!bothLines)
44457               return {};
44458             var isTram = entity1.tags.railway === "tram" || entity2.tags.railway === "tram";
44459             if (osmPathHighwayTagValues[entity1.tags.highway] || osmPathHighwayTagValues[entity2.tags.highway]) {
44460               if (isTram)
44461                 return { railway: "tram_crossing" };
44462               return { railway: "crossing" };
44463             } else {
44464               if (isTram)
44465                 return { railway: "tram_level_crossing" };
44466               return { railway: "level_crossing" };
44467             }
44468           }
44469           if (featureTypes.indexOf("waterway") !== -1) {
44470             if (hasTag(entity1.tags, "tunnel") && hasTag(entity2.tags, "tunnel"))
44471               return null;
44472             if (hasTag(entity1.tags, "bridge") && hasTag(entity2.tags, "bridge"))
44473               return null;
44474             if (highwaysDisallowingFords[entity1.tags.highway] || highwaysDisallowingFords[entity2.tags.highway]) {
44475               return null;
44476             }
44477             return bothLines ? { ford: "yes" } : {};
44478           }
44479         }
44480       }
44481       return null;
44482     }
44483     function findCrossingsByWay(way1, graph, tree) {
44484       var edgeCrossInfos = [];
44485       if (way1.type !== "way")
44486         return edgeCrossInfos;
44487       var taggedFeature1 = getFeatureWithFeatureTypeTagsForWay(way1, graph);
44488       var way1FeatureType = getFeatureType(taggedFeature1, graph);
44489       if (way1FeatureType === null)
44490         return edgeCrossInfos;
44491       var checkedSingleCrossingWays = {};
44492       var i3, j2;
44493       var extent;
44494       var n1, n22, nA, nB, nAId, nBId;
44495       var segment1, segment2;
44496       var oneOnly;
44497       var segmentInfos, segment2Info, way2, taggedFeature2, way2FeatureType;
44498       var way1Nodes = graph.childNodes(way1);
44499       var comparedWays = {};
44500       for (i3 = 0; i3 < way1Nodes.length - 1; i3++) {
44501         n1 = way1Nodes[i3];
44502         n22 = way1Nodes[i3 + 1];
44503         extent = geoExtent([
44504           [
44505             Math.min(n1.loc[0], n22.loc[0]),
44506             Math.min(n1.loc[1], n22.loc[1])
44507           ],
44508           [
44509             Math.max(n1.loc[0], n22.loc[0]),
44510             Math.max(n1.loc[1], n22.loc[1])
44511           ]
44512         ]);
44513         segmentInfos = tree.waySegments(extent, graph);
44514         for (j2 = 0; j2 < segmentInfos.length; j2++) {
44515           segment2Info = segmentInfos[j2];
44516           if (segment2Info.wayId === way1.id)
44517             continue;
44518           if (checkedSingleCrossingWays[segment2Info.wayId])
44519             continue;
44520           comparedWays[segment2Info.wayId] = true;
44521           way2 = graph.hasEntity(segment2Info.wayId);
44522           if (!way2)
44523             continue;
44524           taggedFeature2 = getFeatureWithFeatureTypeTagsForWay(way2, graph);
44525           way2FeatureType = getFeatureType(taggedFeature2, graph);
44526           if (way2FeatureType === null || isLegitCrossing(taggedFeature1.tags, way1FeatureType, taggedFeature2.tags, way2FeatureType)) {
44527             continue;
44528           }
44529           oneOnly = way1FeatureType === "building" || way2FeatureType === "building";
44530           nAId = segment2Info.nodes[0];
44531           nBId = segment2Info.nodes[1];
44532           if (nAId === n1.id || nAId === n22.id || nBId === n1.id || nBId === n22.id) {
44533             continue;
44534           }
44535           nA = graph.hasEntity(nAId);
44536           if (!nA)
44537             continue;
44538           nB = graph.hasEntity(nBId);
44539           if (!nB)
44540             continue;
44541           segment1 = [n1.loc, n22.loc];
44542           segment2 = [nA.loc, nB.loc];
44543           var point2 = geoLineIntersection(segment1, segment2);
44544           if (point2) {
44545             edgeCrossInfos.push({
44546               wayInfos: [
44547                 {
44548                   way: way1,
44549                   featureType: way1FeatureType,
44550                   edge: [n1.id, n22.id]
44551                 },
44552                 {
44553                   way: way2,
44554                   featureType: way2FeatureType,
44555                   edge: [nA.id, nB.id]
44556                 }
44557               ],
44558               crossPoint: point2
44559             });
44560             if (oneOnly) {
44561               checkedSingleCrossingWays[way2.id] = true;
44562               break;
44563             }
44564           }
44565         }
44566       }
44567       return edgeCrossInfos;
44568     }
44569     function waysToCheck(entity, graph) {
44570       var featureType = getFeatureType(entity, graph);
44571       if (!featureType)
44572         return [];
44573       if (entity.type === "way") {
44574         return [entity];
44575       } else if (entity.type === "relation") {
44576         return entity.members.reduce(function(array2, member) {
44577           if (member.type === "way" && // only look at geometry ways
44578           (!member.role || member.role === "outer" || member.role === "inner")) {
44579             var entity2 = graph.hasEntity(member.id);
44580             if (entity2 && array2.indexOf(entity2) === -1) {
44581               array2.push(entity2);
44582             }
44583           }
44584           return array2;
44585         }, []);
44586       }
44587       return [];
44588     }
44589     var validation = function checkCrossingWays(entity, graph) {
44590       var tree = context.history().tree();
44591       var ways = waysToCheck(entity, graph);
44592       var issues = [];
44593       var wayIndex, crossingIndex, crossings;
44594       for (wayIndex in ways) {
44595         crossings = findCrossingsByWay(ways[wayIndex], graph, tree);
44596         for (crossingIndex in crossings) {
44597           issues.push(createIssue(crossings[crossingIndex], graph));
44598         }
44599       }
44600       return issues;
44601     };
44602     function createIssue(crossing, graph) {
44603       crossing.wayInfos.sort(function(way1Info, way2Info) {
44604         var type1 = way1Info.featureType;
44605         var type22 = way2Info.featureType;
44606         if (type1 === type22) {
44607           return utilDisplayLabel(way1Info.way, graph) > utilDisplayLabel(way2Info.way, graph);
44608         } else if (type1 === "waterway") {
44609           return true;
44610         } else if (type22 === "waterway") {
44611           return false;
44612         }
44613         return type1 < type22;
44614       });
44615       var entities = crossing.wayInfos.map(function(wayInfo) {
44616         return getFeatureWithFeatureTypeTagsForWay(wayInfo.way, graph);
44617       });
44618       var edges = [crossing.wayInfos[0].edge, crossing.wayInfos[1].edge];
44619       var featureTypes = [crossing.wayInfos[0].featureType, crossing.wayInfos[1].featureType];
44620       var connectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph);
44621       var featureType1 = crossing.wayInfos[0].featureType;
44622       var featureType2 = crossing.wayInfos[1].featureType;
44623       var isCrossingIndoors = taggedAsIndoor(entities[0].tags) && taggedAsIndoor(entities[1].tags);
44624       var isCrossingTunnels = allowsTunnel(featureType1) && hasTag(entities[0].tags, "tunnel") && allowsTunnel(featureType2) && hasTag(entities[1].tags, "tunnel");
44625       var isCrossingBridges = allowsBridge(featureType1) && hasTag(entities[0].tags, "bridge") && allowsBridge(featureType2) && hasTag(entities[1].tags, "bridge");
44626       var subtype = [featureType1, featureType2].sort().join("-");
44627       var crossingTypeID = subtype;
44628       if (isCrossingIndoors) {
44629         crossingTypeID = "indoor-indoor";
44630       } else if (isCrossingTunnels) {
44631         crossingTypeID = "tunnel-tunnel";
44632       } else if (isCrossingBridges) {
44633         crossingTypeID = "bridge-bridge";
44634       }
44635       if (connectionTags && (isCrossingIndoors || isCrossingTunnels || isCrossingBridges)) {
44636         crossingTypeID += "_connectable";
44637       }
44638       var uniqueID = crossing.crossPoint[0].toFixed(4) + "," + crossing.crossPoint[1].toFixed(4);
44639       return new validationIssue({
44640         type: type2,
44641         subtype,
44642         severity: "warning",
44643         message: function(context2) {
44644           var graph2 = context2.graph();
44645           var entity1 = graph2.hasEntity(this.entityIds[0]), entity2 = graph2.hasEntity(this.entityIds[1]);
44646           return entity1 && entity2 ? _t.append("issues.crossing_ways.message", {
44647             feature: utilDisplayLabel(entity1, graph2),
44648             feature2: utilDisplayLabel(entity2, graph2)
44649           }) : "";
44650         },
44651         reference: showReference,
44652         entityIds: entities.map(function(entity) {
44653           return entity.id;
44654         }),
44655         data: {
44656           edges,
44657           featureTypes,
44658           connectionTags
44659         },
44660         hash: uniqueID,
44661         loc: crossing.crossPoint,
44662         dynamicFixes: function(context2) {
44663           var mode = context2.mode();
44664           if (!mode || mode.id !== "select" || mode.selectedIDs().length !== 1)
44665             return [];
44666           var selectedIndex = this.entityIds[0] === mode.selectedIDs()[0] ? 0 : 1;
44667           var selectedFeatureType = this.data.featureTypes[selectedIndex];
44668           var otherFeatureType = this.data.featureTypes[selectedIndex === 0 ? 1 : 0];
44669           var fixes = [];
44670           if (connectionTags) {
44671             fixes.push(makeConnectWaysFix(this.data.connectionTags));
44672             let lessLikelyConnectionTags = tagsForConnectionNodeIfAllowed(entities[0], entities[1], graph, true);
44673             if (lessLikelyConnectionTags && !(0, import_lodash3.isEqual)(connectionTags, lessLikelyConnectionTags)) {
44674               fixes.push(makeConnectWaysFix(lessLikelyConnectionTags));
44675             }
44676           }
44677           if (isCrossingIndoors) {
44678             fixes.push(new validationIssueFix({
44679               icon: "iD-icon-layers",
44680               title: _t.append("issues.fix.use_different_levels.title")
44681             }));
44682           } else if (isCrossingTunnels || isCrossingBridges || featureType1 === "building" || featureType2 === "building") {
44683             fixes.push(makeChangeLayerFix("higher"));
44684             fixes.push(makeChangeLayerFix("lower"));
44685           } else if (context2.graph().geometry(this.entityIds[0]) === "line" && context2.graph().geometry(this.entityIds[1]) === "line") {
44686             if (allowsBridge(selectedFeatureType) && selectedFeatureType !== "waterway") {
44687               fixes.push(makeAddBridgeOrTunnelFix("add_a_bridge", "temaki-bridge", "bridge"));
44688             }
44689             var skipTunnelFix = otherFeatureType === "waterway" && selectedFeatureType !== "waterway";
44690             if (allowsTunnel(selectedFeatureType) && !skipTunnelFix) {
44691               fixes.push(makeAddBridgeOrTunnelFix("add_a_tunnel", "temaki-tunnel", "tunnel"));
44692             }
44693           }
44694           fixes.push(new validationIssueFix({
44695             icon: "iD-operation-move",
44696             title: _t.append("issues.fix.reposition_features.title")
44697           }));
44698           return fixes;
44699         }
44700       });
44701       function showReference(selection2) {
44702         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.crossing_ways." + crossingTypeID + ".reference"));
44703       }
44704     }
44705     function makeAddBridgeOrTunnelFix(fixTitleID, iconName, bridgeOrTunnel) {
44706       return new validationIssueFix({
44707         icon: iconName,
44708         title: _t.append("issues.fix." + fixTitleID + ".title"),
44709         onClick: function(context2) {
44710           var mode = context2.mode();
44711           if (!mode || mode.id !== "select")
44712             return;
44713           var selectedIDs = mode.selectedIDs();
44714           if (selectedIDs.length !== 1)
44715             return;
44716           var selectedWayID = selectedIDs[0];
44717           if (!context2.hasEntity(selectedWayID))
44718             return;
44719           var resultWayIDs = [selectedWayID];
44720           var edge, crossedEdge, crossedWayID;
44721           if (this.issue.entityIds[0] === selectedWayID) {
44722             edge = this.issue.data.edges[0];
44723             crossedEdge = this.issue.data.edges[1];
44724             crossedWayID = this.issue.entityIds[1];
44725           } else {
44726             edge = this.issue.data.edges[1];
44727             crossedEdge = this.issue.data.edges[0];
44728             crossedWayID = this.issue.entityIds[0];
44729           }
44730           var crossingLoc = this.issue.loc;
44731           var projection2 = context2.projection;
44732           var action = function actionAddStructure(graph) {
44733             var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
44734             var crossedWay = graph.hasEntity(crossedWayID);
44735             var structLengthMeters = crossedWay && isFinite(crossedWay.tags.width) && Number(crossedWay.tags.width);
44736             if (!structLengthMeters) {
44737               structLengthMeters = crossedWay && crossedWay.impliedLineWidthMeters();
44738             }
44739             if (structLengthMeters) {
44740               if (getFeatureType(crossedWay, graph) === "railway") {
44741                 structLengthMeters *= 2;
44742               }
44743             } else {
44744               structLengthMeters = 8;
44745             }
44746             var a1 = geoAngle(edgeNodes[0], edgeNodes[1], projection2) + Math.PI;
44747             var a2 = geoAngle(graph.entity(crossedEdge[0]), graph.entity(crossedEdge[1]), projection2) + Math.PI;
44748             var crossingAngle = Math.max(a1, a2) - Math.min(a1, a2);
44749             if (crossingAngle > Math.PI)
44750               crossingAngle -= Math.PI;
44751             structLengthMeters = structLengthMeters / 2 / Math.sin(crossingAngle) * 2;
44752             structLengthMeters += 4;
44753             structLengthMeters = Math.min(Math.max(structLengthMeters, 4), 50);
44754             function geomToProj(geoPoint) {
44755               return [
44756                 geoLonToMeters(geoPoint[0], geoPoint[1]),
44757                 geoLatToMeters(geoPoint[1])
44758               ];
44759             }
44760             function projToGeom(projPoint) {
44761               var lat = geoMetersToLat(projPoint[1]);
44762               return [
44763                 geoMetersToLon(projPoint[0], lat),
44764                 lat
44765               ];
44766             }
44767             var projEdgeNode1 = geomToProj(edgeNodes[0].loc);
44768             var projEdgeNode2 = geomToProj(edgeNodes[1].loc);
44769             var projectedAngle = geoVecAngle(projEdgeNode1, projEdgeNode2);
44770             var projectedCrossingLoc = geomToProj(crossingLoc);
44771             var linearToSphericalMetersRatio = geoVecLength(projEdgeNode1, projEdgeNode2) / geoSphericalDistance(edgeNodes[0].loc, edgeNodes[1].loc);
44772             function locSphericalDistanceFromCrossingLoc(angle2, distanceMeters) {
44773               var lengthSphericalMeters = distanceMeters * linearToSphericalMetersRatio;
44774               return projToGeom([
44775                 projectedCrossingLoc[0] + Math.cos(angle2) * lengthSphericalMeters,
44776                 projectedCrossingLoc[1] + Math.sin(angle2) * lengthSphericalMeters
44777               ]);
44778             }
44779             var endpointLocGetter1 = function(lengthMeters) {
44780               return locSphericalDistanceFromCrossingLoc(projectedAngle, lengthMeters);
44781             };
44782             var endpointLocGetter2 = function(lengthMeters) {
44783               return locSphericalDistanceFromCrossingLoc(projectedAngle + Math.PI, lengthMeters);
44784             };
44785             var minEdgeLengthMeters = 0.55;
44786             function determineEndpoint(edge2, endNode, locGetter) {
44787               var newNode;
44788               var idealLengthMeters = structLengthMeters / 2;
44789               var crossingToEdgeEndDistance = geoSphericalDistance(crossingLoc, endNode.loc);
44790               if (crossingToEdgeEndDistance - idealLengthMeters > minEdgeLengthMeters) {
44791                 var idealNodeLoc = locGetter(idealLengthMeters);
44792                 newNode = osmNode();
44793                 graph = actionAddMidpoint({ loc: idealNodeLoc, edge: edge2 }, newNode)(graph);
44794               } else {
44795                 var edgeCount = 0;
44796                 endNode.parentIntersectionWays(graph).forEach(function(way) {
44797                   way.nodes.forEach(function(nodeID) {
44798                     if (nodeID === endNode.id) {
44799                       if (endNode.id === way.first() && endNode.id !== way.last() || endNode.id === way.last() && endNode.id !== way.first()) {
44800                         edgeCount += 1;
44801                       } else {
44802                         edgeCount += 2;
44803                       }
44804                     }
44805                   });
44806                 });
44807                 if (edgeCount >= 3) {
44808                   var insetLength = crossingToEdgeEndDistance - minEdgeLengthMeters;
44809                   if (insetLength > minEdgeLengthMeters) {
44810                     var insetNodeLoc = locGetter(insetLength);
44811                     newNode = osmNode();
44812                     graph = actionAddMidpoint({ loc: insetNodeLoc, edge: edge2 }, newNode)(graph);
44813                   }
44814                 }
44815               }
44816               if (!newNode)
44817                 newNode = endNode;
44818               var splitAction = actionSplit([newNode.id]).limitWays(resultWayIDs);
44819               graph = splitAction(graph);
44820               if (splitAction.getCreatedWayIDs().length) {
44821                 resultWayIDs.push(splitAction.getCreatedWayIDs()[0]);
44822               }
44823               return newNode;
44824             }
44825             var structEndNode1 = determineEndpoint(edge, edgeNodes[1], endpointLocGetter1);
44826             var structEndNode2 = determineEndpoint([edgeNodes[0].id, structEndNode1.id], edgeNodes[0], endpointLocGetter2);
44827             var structureWay = resultWayIDs.map(function(id2) {
44828               return graph.entity(id2);
44829             }).find(function(way) {
44830               return way.nodes.indexOf(structEndNode1.id) !== -1 && way.nodes.indexOf(structEndNode2.id) !== -1;
44831             });
44832             var tags = Object.assign({}, structureWay.tags);
44833             if (bridgeOrTunnel === "bridge") {
44834               tags.bridge = "yes";
44835               tags.layer = "1";
44836             } else {
44837               var tunnelValue = "yes";
44838               if (getFeatureType(structureWay, graph) === "waterway") {
44839                 tunnelValue = "culvert";
44840               }
44841               tags.tunnel = tunnelValue;
44842               tags.layer = "-1";
44843             }
44844             graph = actionChangeTags(structureWay.id, tags)(graph);
44845             return graph;
44846           };
44847           context2.perform(action, _t("issues.fix." + fixTitleID + ".annotation"));
44848           context2.enter(modeSelect(context2, resultWayIDs));
44849         }
44850       });
44851     }
44852     function makeConnectWaysFix(connectionTags) {
44853       var fixTitleID = "connect_features";
44854       var fixIcon = "iD-icon-crossing";
44855       if (connectionTags.highway === "crossing") {
44856         fixTitleID = "connect_using_crossing";
44857         fixIcon = "temaki-pedestrian";
44858       }
44859       if (connectionTags.ford) {
44860         fixTitleID = "connect_using_ford";
44861         fixIcon = "roentgen-ford";
44862       }
44863       const fix = new validationIssueFix({
44864         icon: fixIcon,
44865         title: _t.append("issues.fix." + fixTitleID + ".title"),
44866         onClick: function(context2) {
44867           var loc = this.issue.loc;
44868           var edges = this.issue.data.edges;
44869           context2.perform(
44870             function actionConnectCrossingWays(graph) {
44871               var node = osmNode({ loc, tags: connectionTags });
44872               graph = graph.replace(node);
44873               var nodesToMerge = [node.id];
44874               var mergeThresholdInMeters = 0.75;
44875               edges.forEach(function(edge) {
44876                 var edgeNodes = [graph.entity(edge[0]), graph.entity(edge[1])];
44877                 var nearby = geoSphericalClosestNode(edgeNodes, loc);
44878                 if ((!nearby.node.hasInterestingTags() || nearby.node.isCrossing()) && nearby.distance < mergeThresholdInMeters) {
44879                   nodesToMerge.push(nearby.node.id);
44880                 } else {
44881                   graph = actionAddMidpoint({ loc, edge }, node)(graph);
44882                 }
44883               });
44884               if (nodesToMerge.length > 1) {
44885                 graph = actionMergeNodes(nodesToMerge, loc)(graph);
44886               }
44887               return graph;
44888             },
44889             _t("issues.fix.connect_crossing_features.annotation")
44890           );
44891         }
44892       });
44893       fix._connectionTags = connectionTags;
44894       return fix;
44895     }
44896     function makeChangeLayerFix(higherOrLower) {
44897       return new validationIssueFix({
44898         icon: "iD-icon-" + (higherOrLower === "higher" ? "up" : "down"),
44899         title: _t.append("issues.fix.tag_this_as_" + higherOrLower + ".title"),
44900         onClick: function(context2) {
44901           var mode = context2.mode();
44902           if (!mode || mode.id !== "select")
44903             return;
44904           var selectedIDs = mode.selectedIDs();
44905           if (selectedIDs.length !== 1)
44906             return;
44907           var selectedID = selectedIDs[0];
44908           if (!this.issue.entityIds.some(function(entityId) {
44909             return entityId === selectedID;
44910           }))
44911             return;
44912           var entity = context2.hasEntity(selectedID);
44913           if (!entity)
44914             return;
44915           var tags = Object.assign({}, entity.tags);
44916           var layer = tags.layer && Number(tags.layer);
44917           if (layer && !isNaN(layer)) {
44918             if (higherOrLower === "higher") {
44919               layer += 1;
44920             } else {
44921               layer -= 1;
44922             }
44923           } else {
44924             if (higherOrLower === "higher") {
44925               layer = 1;
44926             } else {
44927               layer = -1;
44928             }
44929           }
44930           tags.layer = layer.toString();
44931           context2.perform(
44932             actionChangeTags(entity.id, tags),
44933             _t("operations.change_tags.annotation")
44934           );
44935         }
44936       });
44937     }
44938     validation.type = type2;
44939     return validation;
44940   }
44941
44942   // modules/behavior/draw_way.js
44943   function behaviorDrawWay(context, wayID, mode, startGraph) {
44944     const keybinding = utilKeybinding("drawWay");
44945     var dispatch14 = dispatch_default("rejectedSelfIntersection");
44946     var behavior = behaviorDraw(context);
44947     var _nodeIndex;
44948     var _origWay;
44949     var _wayGeometry;
44950     var _headNodeID;
44951     var _annotation;
44952     var _pointerHasMoved = false;
44953     var _drawNode;
44954     var _didResolveTempEdit = false;
44955     function createDrawNode(loc) {
44956       _drawNode = osmNode({ loc });
44957       context.pauseChangeDispatch();
44958       context.replace(function actionAddDrawNode(graph) {
44959         var way = graph.entity(wayID);
44960         return graph.replace(_drawNode).replace(way.addNode(_drawNode.id, _nodeIndex));
44961       }, _annotation);
44962       context.resumeChangeDispatch();
44963       setActiveElements();
44964     }
44965     function removeDrawNode() {
44966       context.pauseChangeDispatch();
44967       context.replace(
44968         function actionDeleteDrawNode(graph) {
44969           var way = graph.entity(wayID);
44970           return graph.replace(way.removeNode(_drawNode.id)).remove(_drawNode);
44971         },
44972         _annotation
44973       );
44974       _drawNode = void 0;
44975       context.resumeChangeDispatch();
44976     }
44977     function keydown(d3_event) {
44978       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
44979         if (context.surface().classed("nope")) {
44980           context.surface().classed("nope-suppressed", true);
44981         }
44982         context.surface().classed("nope", false).classed("nope-disabled", true);
44983       }
44984     }
44985     function keyup(d3_event) {
44986       if (d3_event.keyCode === utilKeybinding.modifierCodes.alt) {
44987         if (context.surface().classed("nope-suppressed")) {
44988           context.surface().classed("nope", true);
44989         }
44990         context.surface().classed("nope-suppressed", false).classed("nope-disabled", false);
44991       }
44992     }
44993     function allowsVertex(d2) {
44994       return d2.geometry(context.graph()) === "vertex" || _mainPresetIndex.allowsVertex(d2, context.graph());
44995     }
44996     function move(d3_event, datum2) {
44997       var loc = context.map().mouseCoordinates();
44998       if (!_drawNode)
44999         createDrawNode(loc);
45000       context.surface().classed("nope-disabled", d3_event.altKey);
45001       var targetLoc = datum2 && datum2.properties && datum2.properties.entity && allowsVertex(datum2.properties.entity) && datum2.properties.entity.loc;
45002       var targetNodes = datum2 && datum2.properties && datum2.properties.nodes;
45003       if (targetLoc) {
45004         loc = targetLoc;
45005       } else if (targetNodes) {
45006         var choice = geoChooseEdge(targetNodes, context.map().mouse(), context.projection, _drawNode.id);
45007         if (choice) {
45008           loc = choice.loc;
45009         }
45010       }
45011       context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
45012       _drawNode = context.entity(_drawNode.id);
45013       checkGeometry(
45014         true
45015         /* includeDrawNode */
45016       );
45017     }
45018     function checkGeometry(includeDrawNode) {
45019       var nopeDisabled = context.surface().classed("nope-disabled");
45020       var isInvalid = isInvalidGeometry(includeDrawNode);
45021       if (nopeDisabled) {
45022         context.surface().classed("nope", false).classed("nope-suppressed", isInvalid);
45023       } else {
45024         context.surface().classed("nope", isInvalid).classed("nope-suppressed", false);
45025       }
45026     }
45027     function isInvalidGeometry(includeDrawNode) {
45028       var testNode = _drawNode;
45029       var parentWay = context.graph().entity(wayID);
45030       var nodes = context.graph().childNodes(parentWay).slice();
45031       if (includeDrawNode) {
45032         if (parentWay.isClosed()) {
45033           nodes.pop();
45034         }
45035       } else {
45036         if (parentWay.isClosed()) {
45037           if (nodes.length < 3)
45038             return false;
45039           if (_drawNode)
45040             nodes.splice(-2, 1);
45041           testNode = nodes[nodes.length - 2];
45042         } else {
45043           return false;
45044         }
45045       }
45046       return testNode && geoHasSelfIntersections(nodes, testNode.id);
45047     }
45048     function undone() {
45049       _didResolveTempEdit = true;
45050       context.pauseChangeDispatch();
45051       var nextMode;
45052       if (context.graph() === startGraph) {
45053         nextMode = modeSelect(context, [wayID]);
45054       } else {
45055         context.pop(1);
45056         nextMode = mode;
45057       }
45058       context.perform(actionNoop());
45059       context.pop(1);
45060       context.resumeChangeDispatch();
45061       context.enter(nextMode);
45062     }
45063     function setActiveElements() {
45064       if (!_drawNode)
45065         return;
45066       context.surface().selectAll("." + _drawNode.id).classed("active", true);
45067     }
45068     function resetToStartGraph() {
45069       while (context.graph() !== startGraph) {
45070         context.pop();
45071       }
45072     }
45073     var drawWay = function(surface) {
45074       _drawNode = void 0;
45075       _didResolveTempEdit = false;
45076       _origWay = context.entity(wayID);
45077       if (typeof _nodeIndex === "number") {
45078         _headNodeID = _origWay.nodes[_nodeIndex];
45079       } else if (_origWay.isClosed()) {
45080         _headNodeID = _origWay.nodes[_origWay.nodes.length - 2];
45081       } else {
45082         _headNodeID = _origWay.nodes[_origWay.nodes.length - 1];
45083       }
45084       _wayGeometry = _origWay.geometry(context.graph());
45085       _annotation = _t(
45086         (_origWay.nodes.length === (_origWay.isClosed() ? 2 : 1) ? "operations.start.annotation." : "operations.continue.annotation.") + _wayGeometry
45087       );
45088       _pointerHasMoved = false;
45089       context.pauseChangeDispatch();
45090       context.perform(actionNoop(), _annotation);
45091       context.resumeChangeDispatch();
45092       behavior.hover().initialNodeID(_headNodeID);
45093       behavior.on("move", function() {
45094         _pointerHasMoved = true;
45095         move.apply(this, arguments);
45096       }).on("down", function() {
45097         move.apply(this, arguments);
45098       }).on("downcancel", function() {
45099         if (_drawNode)
45100           removeDrawNode();
45101       }).on("click", drawWay.add).on("clickWay", drawWay.addWay).on("clickNode", drawWay.addNode).on("undo", context.undo).on("cancel", drawWay.cancel).on("finish", drawWay.finish);
45102       select_default2(window).on("keydown.drawWay", keydown).on("keyup.drawWay", keyup);
45103       context.map().dblclickZoomEnable(false).on("drawn.draw", setActiveElements);
45104       setActiveElements();
45105       surface.call(behavior);
45106       context.history().on("undone.draw", undone);
45107     };
45108     drawWay.off = function(surface) {
45109       if (!_didResolveTempEdit) {
45110         context.pauseChangeDispatch();
45111         resetToStartGraph();
45112         context.resumeChangeDispatch();
45113       }
45114       _drawNode = void 0;
45115       _nodeIndex = void 0;
45116       context.map().on("drawn.draw", null);
45117       surface.call(behavior.off).selectAll(".active").classed("active", false);
45118       surface.classed("nope", false).classed("nope-suppressed", false).classed("nope-disabled", false);
45119       select_default2(window).on("keydown.drawWay", null).on("keyup.drawWay", null);
45120       context.history().on("undone.draw", null);
45121     };
45122     function attemptAdd(d2, loc, doAdd) {
45123       if (_drawNode) {
45124         context.replace(actionMoveNode(_drawNode.id, loc), _annotation);
45125         _drawNode = context.entity(_drawNode.id);
45126       } else {
45127         createDrawNode(loc);
45128       }
45129       checkGeometry(
45130         true
45131         /* includeDrawNode */
45132       );
45133       if (d2 && d2.properties && d2.properties.nope || context.surface().classed("nope")) {
45134         if (!_pointerHasMoved) {
45135           removeDrawNode();
45136         }
45137         dispatch14.call("rejectedSelfIntersection", this);
45138         return;
45139       }
45140       context.pauseChangeDispatch();
45141       doAdd();
45142       _didResolveTempEdit = true;
45143       context.resumeChangeDispatch();
45144       context.enter(mode);
45145     }
45146     drawWay.add = function(loc, d2) {
45147       attemptAdd(d2, loc, function() {
45148       });
45149     };
45150     drawWay.addWay = function(loc, edge, d2) {
45151       attemptAdd(d2, loc, function() {
45152         context.replace(
45153           actionAddMidpoint({ loc, edge }, _drawNode),
45154           _annotation
45155         );
45156       });
45157     };
45158     drawWay.addNode = function(node, d2) {
45159       if (node.id === _headNodeID || // or the first node when drawing an area
45160       _origWay.isClosed() && node.id === _origWay.first()) {
45161         drawWay.finish();
45162         return;
45163       }
45164       attemptAdd(d2, node.loc, function() {
45165         context.replace(
45166           function actionReplaceDrawNode(graph) {
45167             graph = graph.replace(graph.entity(wayID).removeNode(_drawNode.id)).remove(_drawNode);
45168             return graph.replace(graph.entity(wayID).addNode(node.id, _nodeIndex));
45169           },
45170           _annotation
45171         );
45172       });
45173     };
45174     function getFeatureType(ways) {
45175       if (ways.every((way) => way.isClosed()))
45176         return "area";
45177       if (ways.every((way) => !way.isClosed()))
45178         return "line";
45179       return "generic";
45180     }
45181     function followMode() {
45182       if (_didResolveTempEdit)
45183         return;
45184       try {
45185         const isDrawingArea = _origWay.nodes[0] === _origWay.nodes.slice(-1)[0];
45186         const [secondLastNodeId, lastNodeId] = _origWay.nodes.slice(isDrawingArea ? -3 : -2);
45187         const historyGraph = context.history().graph();
45188         if (!lastNodeId || !secondLastNodeId || !historyGraph.hasEntity(lastNodeId) || !historyGraph.hasEntity(secondLastNodeId)) {
45189           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.needs_more_initial_nodes"))();
45190           return;
45191         }
45192         const lastNodesParents = historyGraph.parentWays(historyGraph.entity(lastNodeId)).filter((w2) => w2.id !== wayID);
45193         const secondLastNodesParents = historyGraph.parentWays(historyGraph.entity(secondLastNodeId)).filter((w2) => w2.id !== wayID);
45194         const featureType = getFeatureType(lastNodesParents);
45195         if (lastNodesParents.length !== 1 || secondLastNodesParents.length === 0) {
45196           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_multiple_ways.".concat(featureType)))();
45197           return;
45198         }
45199         if (!secondLastNodesParents.some((n3) => n3.id === lastNodesParents[0].id)) {
45200           context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.intersection_of_different_ways.".concat(featureType)))();
45201           return;
45202         }
45203         const way = lastNodesParents[0];
45204         const indexOfLast = way.nodes.indexOf(lastNodeId);
45205         const indexOfSecondLast = way.nodes.indexOf(secondLastNodeId);
45206         const isDescendingPastZero = indexOfLast === way.nodes.length - 2 && indexOfSecondLast === 0;
45207         let nextNodeIndex = indexOfLast + (indexOfLast > indexOfSecondLast && !isDescendingPastZero ? 1 : -1);
45208         if (nextNodeIndex === -1)
45209           nextNodeIndex = indexOfSecondLast === 1 ? way.nodes.length - 2 : 1;
45210         const nextNode = historyGraph.entity(way.nodes[nextNodeIndex]);
45211         drawWay.addNode(nextNode, {
45212           geometry: { type: "Point", coordinates: nextNode.loc },
45213           id: nextNode.id,
45214           properties: { target: true, entity: nextNode }
45215         });
45216       } catch (ex) {
45217         context.ui().flash.duration(4e3).iconName("#iD-icon-no").label(_t.append("operations.follow.error.unknown"))();
45218       }
45219     }
45220     keybinding.on(_t("operations.follow.key"), followMode);
45221     select_default2(document).call(keybinding);
45222     drawWay.finish = function() {
45223       checkGeometry(
45224         false
45225         /* includeDrawNode */
45226       );
45227       if (context.surface().classed("nope")) {
45228         dispatch14.call("rejectedSelfIntersection", this);
45229         return;
45230       }
45231       context.pauseChangeDispatch();
45232       context.pop(1);
45233       _didResolveTempEdit = true;
45234       context.resumeChangeDispatch();
45235       var way = context.hasEntity(wayID);
45236       if (!way || way.isDegenerate()) {
45237         drawWay.cancel();
45238         return;
45239       }
45240       window.setTimeout(function() {
45241         context.map().dblclickZoomEnable(true);
45242       }, 1e3);
45243       var isNewFeature = !mode.isContinuing;
45244       context.enter(modeSelect(context, [wayID]).newFeature(isNewFeature));
45245     };
45246     drawWay.cancel = function() {
45247       context.pauseChangeDispatch();
45248       resetToStartGraph();
45249       context.resumeChangeDispatch();
45250       window.setTimeout(function() {
45251         context.map().dblclickZoomEnable(true);
45252       }, 1e3);
45253       context.surface().classed("nope", false).classed("nope-disabled", false).classed("nope-suppressed", false);
45254       context.enter(modeBrowse(context));
45255     };
45256     drawWay.nodeIndex = function(val) {
45257       if (!arguments.length)
45258         return _nodeIndex;
45259       _nodeIndex = val;
45260       return drawWay;
45261     };
45262     drawWay.activeID = function() {
45263       if (!arguments.length)
45264         return _drawNode && _drawNode.id;
45265       return drawWay;
45266     };
45267     return utilRebind(drawWay, dispatch14, "on");
45268   }
45269
45270   // modules/modes/draw_line.js
45271   function modeDrawLine(context, wayID, startGraph, button, affix, continuing) {
45272     var mode = {
45273       button,
45274       id: "draw-line"
45275     };
45276     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawLine", function() {
45277       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.lines"))();
45278     });
45279     mode.wayID = wayID;
45280     mode.isContinuing = continuing;
45281     mode.enter = function() {
45282       behavior.nodeIndex(affix === "prefix" ? 0 : void 0);
45283       context.install(behavior);
45284     };
45285     mode.exit = function() {
45286       context.uninstall(behavior);
45287     };
45288     mode.selectedIDs = function() {
45289       return [wayID];
45290     };
45291     mode.activeID = function() {
45292       return behavior && behavior.activeID() || [];
45293     };
45294     return mode;
45295   }
45296
45297   // modules/validations/disconnected_way.js
45298   function validationDisconnectedWay() {
45299     var type2 = "disconnected_way";
45300     function isTaggedAsHighway(entity) {
45301       return osmRoutableHighwayTagValues[entity.tags.highway];
45302     }
45303     var validation = function checkDisconnectedWay(entity, graph) {
45304       var routingIslandWays = routingIslandForEntity(entity);
45305       if (!routingIslandWays)
45306         return [];
45307       return [new validationIssue({
45308         type: type2,
45309         subtype: "highway",
45310         severity: "warning",
45311         message: function(context) {
45312           var entity2 = this.entityIds.length && context.hasEntity(this.entityIds[0]);
45313           var label = entity2 && utilDisplayLabel(entity2, context.graph());
45314           return _t.append("issues.disconnected_way.routable.message", { count: this.entityIds.length, highway: label });
45315         },
45316         reference: showReference,
45317         entityIds: Array.from(routingIslandWays).map(function(way) {
45318           return way.id;
45319         }),
45320         dynamicFixes: makeFixes
45321       })];
45322       function makeFixes(context) {
45323         var fixes = [];
45324         var singleEntity = this.entityIds.length === 1 && context.hasEntity(this.entityIds[0]);
45325         if (singleEntity) {
45326           if (singleEntity.type === "way" && !singleEntity.isClosed()) {
45327             var textDirection = _mainLocalizer.textDirection();
45328             var startFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.first(), "start");
45329             if (startFix)
45330               fixes.push(startFix);
45331             var endFix = makeContinueDrawingFixIfAllowed(textDirection, singleEntity.last(), "end");
45332             if (endFix)
45333               fixes.push(endFix);
45334           }
45335           if (!fixes.length) {
45336             fixes.push(new validationIssueFix({
45337               title: _t.append("issues.fix.connect_feature.title")
45338             }));
45339           }
45340           fixes.push(new validationIssueFix({
45341             icon: "iD-operation-delete",
45342             title: _t.append("issues.fix.delete_feature.title"),
45343             entityIds: [singleEntity.id],
45344             onClick: function(context2) {
45345               var id2 = this.issue.entityIds[0];
45346               var operation2 = operationDelete(context2, [id2]);
45347               if (!operation2.disabled()) {
45348                 operation2();
45349               }
45350             }
45351           }));
45352         } else {
45353           fixes.push(new validationIssueFix({
45354             title: _t.append("issues.fix.connect_features.title")
45355           }));
45356         }
45357         return fixes;
45358       }
45359       function showReference(selection2) {
45360         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.disconnected_way.routable.reference"));
45361       }
45362       function routingIslandForEntity(entity2) {
45363         var routingIsland = /* @__PURE__ */ new Set();
45364         var waysToCheck = [];
45365         function queueParentWays(node) {
45366           graph.parentWays(node).forEach(function(parentWay) {
45367             if (!routingIsland.has(parentWay) && // only check each feature once
45368             isRoutableWay(parentWay, false)) {
45369               routingIsland.add(parentWay);
45370               waysToCheck.push(parentWay);
45371             }
45372           });
45373         }
45374         if (entity2.type === "way" && isRoutableWay(entity2, true)) {
45375           routingIsland.add(entity2);
45376           waysToCheck.push(entity2);
45377         } else if (entity2.type === "node" && isRoutableNode(entity2)) {
45378           routingIsland.add(entity2);
45379           queueParentWays(entity2);
45380         } else {
45381           return null;
45382         }
45383         while (waysToCheck.length) {
45384           var wayToCheck = waysToCheck.pop();
45385           var childNodes = graph.childNodes(wayToCheck);
45386           for (var i3 in childNodes) {
45387             var vertex = childNodes[i3];
45388             if (isConnectedVertex(vertex)) {
45389               return null;
45390             }
45391             if (isRoutableNode(vertex)) {
45392               routingIsland.add(vertex);
45393             }
45394             queueParentWays(vertex);
45395           }
45396         }
45397         return routingIsland;
45398       }
45399       function isConnectedVertex(vertex) {
45400         var osm = services.osm;
45401         if (osm && !osm.isDataLoaded(vertex.loc))
45402           return true;
45403         if (vertex.tags.entrance && vertex.tags.entrance !== "no")
45404           return true;
45405         if (vertex.tags.amenity === "parking_entrance")
45406           return true;
45407         return false;
45408       }
45409       function isRoutableNode(node) {
45410         if (node.tags.highway === "elevator")
45411           return true;
45412         return false;
45413       }
45414       function isRoutableWay(way, ignoreInnerWays) {
45415         if (isTaggedAsHighway(way) || way.tags.route === "ferry")
45416           return true;
45417         return graph.parentRelations(way).some(function(parentRelation) {
45418           if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry")
45419             return true;
45420           if (parentRelation.isMultipolygon() && isTaggedAsHighway(parentRelation) && (!ignoreInnerWays || parentRelation.memberById(way.id).role !== "inner"))
45421             return true;
45422           return false;
45423         });
45424       }
45425       function makeContinueDrawingFixIfAllowed(textDirection, vertexID, whichEnd) {
45426         var vertex = graph.hasEntity(vertexID);
45427         if (!vertex || vertex.tags.noexit === "yes")
45428           return null;
45429         var useLeftContinue = whichEnd === "start" && textDirection === "ltr" || whichEnd === "end" && textDirection === "rtl";
45430         return new validationIssueFix({
45431           icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
45432           title: _t.append("issues.fix.continue_from_" + whichEnd + ".title"),
45433           entityIds: [vertexID],
45434           onClick: function(context) {
45435             var wayId = this.issue.entityIds[0];
45436             var way = context.hasEntity(wayId);
45437             var vertexId = this.entityIds[0];
45438             var vertex2 = context.hasEntity(vertexId);
45439             if (!way || !vertex2)
45440               return;
45441             var map2 = context.map();
45442             if (!context.editable() || !map2.trimmedExtent().contains(vertex2.loc)) {
45443               map2.zoomToEase(vertex2);
45444             }
45445             context.enter(
45446               modeDrawLine(context, wayId, context.graph(), "line", way.affix(vertexId), true)
45447             );
45448           }
45449         });
45450       }
45451     };
45452     validation.type = type2;
45453     return validation;
45454   }
45455
45456   // modules/validations/invalid_format.js
45457   function validationFormatting() {
45458     var type2 = "invalid_format";
45459     var validation = function(entity) {
45460       var issues = [];
45461       function isValidEmail(email) {
45462         var valid_email = /^[^\(\)\\,":;<>@\[\]]+@[^\(\)\\,":;<>@\[\]\.]+(?:\.[a-z0-9-]+)*$/i;
45463         return !email || valid_email.test(email);
45464       }
45465       function showReferenceEmail(selection2) {
45466         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.invalid_format.email.reference"));
45467       }
45468       if (entity.tags.email) {
45469         var emails = entity.tags.email.split(";").map(function(s2) {
45470           return s2.trim();
45471         }).filter(function(x2) {
45472           return !isValidEmail(x2);
45473         });
45474         if (emails.length) {
45475           issues.push(new validationIssue({
45476             type: type2,
45477             subtype: "email",
45478             severity: "warning",
45479             message: function(context) {
45480               var entity2 = context.hasEntity(this.entityIds[0]);
45481               return entity2 ? _t.append(
45482                 "issues.invalid_format.email.message" + this.data,
45483                 { feature: utilDisplayLabel(entity2, context.graph()), email: emails.join(", ") }
45484               ) : "";
45485             },
45486             reference: showReferenceEmail,
45487             entityIds: [entity.id],
45488             hash: emails.join(),
45489             data: emails.length > 1 ? "_multi" : ""
45490           }));
45491         }
45492       }
45493       return issues;
45494     };
45495     validation.type = type2;
45496     return validation;
45497   }
45498
45499   // modules/validations/help_request.js
45500   function validationHelpRequest(context) {
45501     var type2 = "help_request";
45502     var validation = function checkFixmeTag(entity) {
45503       if (!entity.tags.fixme)
45504         return [];
45505       if (entity.version === void 0)
45506         return [];
45507       if (entity.v !== void 0) {
45508         var baseEntity = context.history().base().hasEntity(entity.id);
45509         if (!baseEntity || !baseEntity.tags.fixme)
45510           return [];
45511       }
45512       return [new validationIssue({
45513         type: type2,
45514         subtype: "fixme_tag",
45515         severity: "warning",
45516         message: function(context2) {
45517           var entity2 = context2.hasEntity(this.entityIds[0]);
45518           return entity2 ? _t.append("issues.fixme_tag.message", {
45519             feature: utilDisplayLabel(
45520               entity2,
45521               context2.graph(),
45522               true
45523               /* verbose */
45524             )
45525           }) : "";
45526         },
45527         dynamicFixes: function() {
45528           return [
45529             new validationIssueFix({
45530               title: _t.append("issues.fix.address_the_concern.title")
45531             })
45532           ];
45533         },
45534         reference: showReference,
45535         entityIds: [entity.id]
45536       })];
45537       function showReference(selection2) {
45538         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.fixme_tag.reference"));
45539       }
45540     };
45541     validation.type = type2;
45542     return validation;
45543   }
45544
45545   // modules/validations/impossible_oneway.js
45546   function validationImpossibleOneway() {
45547     var type2 = "impossible_oneway";
45548     var validation = function checkImpossibleOneway(entity, graph) {
45549       if (entity.type !== "way" || entity.geometry(graph) !== "line")
45550         return [];
45551       if (entity.isClosed())
45552         return [];
45553       if (!typeForWay(entity))
45554         return [];
45555       if (!isOneway(entity))
45556         return [];
45557       var firstIssues = issuesForNode(entity, entity.first());
45558       var lastIssues = issuesForNode(entity, entity.last());
45559       return firstIssues.concat(lastIssues);
45560       function typeForWay(way) {
45561         if (way.geometry(graph) !== "line")
45562           return null;
45563         if (osmRoutableHighwayTagValues[way.tags.highway])
45564           return "highway";
45565         if (osmFlowingWaterwayTagValues[way.tags.waterway])
45566           return "waterway";
45567         return null;
45568       }
45569       function isOneway(way) {
45570         if (way.tags.oneway === "yes")
45571           return true;
45572         if (way.tags.oneway)
45573           return false;
45574         for (var key in way.tags) {
45575           if (osmOneWayTags[key] && osmOneWayTags[key][way.tags[key]]) {
45576             return true;
45577           }
45578         }
45579         return false;
45580       }
45581       function nodeOccursMoreThanOnce(way, nodeID) {
45582         var occurrences = 0;
45583         for (var index in way.nodes) {
45584           if (way.nodes[index] === nodeID) {
45585             occurrences += 1;
45586             if (occurrences > 1)
45587               return true;
45588           }
45589         }
45590         return false;
45591       }
45592       function isConnectedViaOtherTypes(way, node) {
45593         var wayType = typeForWay(way);
45594         if (wayType === "highway") {
45595           if (node.tags.entrance && node.tags.entrance !== "no")
45596             return true;
45597           if (node.tags.amenity === "parking_entrance")
45598             return true;
45599         } else if (wayType === "waterway") {
45600           if (node.id === way.first()) {
45601             if (node.tags.natural === "spring")
45602               return true;
45603           } else {
45604             if (node.tags.manhole === "drain")
45605               return true;
45606           }
45607         }
45608         return graph.parentWays(node).some(function(parentWay) {
45609           if (parentWay.id === way.id)
45610             return false;
45611           if (wayType === "highway") {
45612             if (parentWay.geometry(graph) === "area" && osmRoutableHighwayTagValues[parentWay.tags.highway])
45613               return true;
45614             if (parentWay.tags.route === "ferry")
45615               return true;
45616             return graph.parentRelations(parentWay).some(function(parentRelation) {
45617               if (parentRelation.tags.type === "route" && parentRelation.tags.route === "ferry")
45618                 return true;
45619               return parentRelation.isMultipolygon() && osmRoutableHighwayTagValues[parentRelation.tags.highway];
45620             });
45621           } else if (wayType === "waterway") {
45622             if (parentWay.tags.natural === "water" || parentWay.tags.natural === "coastline")
45623               return true;
45624           }
45625           return false;
45626         });
45627       }
45628       function issuesForNode(way, nodeID) {
45629         var isFirst = nodeID === way.first();
45630         var wayType = typeForWay(way);
45631         if (nodeOccursMoreThanOnce(way, nodeID))
45632           return [];
45633         var osm = services.osm;
45634         if (!osm)
45635           return [];
45636         var node = graph.hasEntity(nodeID);
45637         if (!node || !osm.isDataLoaded(node.loc))
45638           return [];
45639         if (isConnectedViaOtherTypes(way, node))
45640           return [];
45641         var attachedWaysOfSameType = graph.parentWays(node).filter(function(parentWay) {
45642           if (parentWay.id === way.id)
45643             return false;
45644           return typeForWay(parentWay) === wayType;
45645         });
45646         if (wayType === "waterway" && attachedWaysOfSameType.length === 0)
45647           return [];
45648         var attachedOneways = attachedWaysOfSameType.filter(function(attachedWay) {
45649           return isOneway(attachedWay);
45650         });
45651         if (attachedOneways.length < attachedWaysOfSameType.length)
45652           return [];
45653         if (attachedOneways.length) {
45654           var connectedEndpointsOkay = attachedOneways.some(function(attachedOneway) {
45655             if ((isFirst ? attachedOneway.first() : attachedOneway.last()) !== nodeID)
45656               return true;
45657             if (nodeOccursMoreThanOnce(attachedOneway, nodeID))
45658               return true;
45659             return false;
45660           });
45661           if (connectedEndpointsOkay)
45662             return [];
45663         }
45664         var placement = isFirst ? "start" : "end", messageID = wayType + ".", referenceID = wayType + ".";
45665         if (wayType === "waterway") {
45666           messageID += "connected." + placement;
45667           referenceID += "connected";
45668         } else {
45669           messageID += placement;
45670           referenceID += placement;
45671         }
45672         return [new validationIssue({
45673           type: type2,
45674           subtype: wayType,
45675           severity: "warning",
45676           message: function(context) {
45677             var entity2 = context.hasEntity(this.entityIds[0]);
45678             return entity2 ? _t.append("issues.impossible_oneway." + messageID + ".message", {
45679               feature: utilDisplayLabel(entity2, context.graph())
45680             }) : "";
45681           },
45682           reference: getReference(referenceID),
45683           entityIds: [way.id, node.id],
45684           dynamicFixes: function() {
45685             var fixes = [];
45686             if (attachedOneways.length) {
45687               fixes.push(new validationIssueFix({
45688                 icon: "iD-operation-reverse",
45689                 title: _t.append("issues.fix.reverse_feature.title"),
45690                 entityIds: [way.id],
45691                 onClick: function(context) {
45692                   var id2 = this.issue.entityIds[0];
45693                   context.perform(actionReverse(id2), _t("operations.reverse.annotation.line", { n: 1 }));
45694                 }
45695               }));
45696             }
45697             if (node.tags.noexit !== "yes") {
45698               var textDirection = _mainLocalizer.textDirection();
45699               var useLeftContinue = isFirst && textDirection === "ltr" || !isFirst && textDirection === "rtl";
45700               fixes.push(new validationIssueFix({
45701                 icon: "iD-operation-continue" + (useLeftContinue ? "-left" : ""),
45702                 title: _t.append("issues.fix.continue_from_" + (isFirst ? "start" : "end") + ".title"),
45703                 onClick: function(context) {
45704                   var entityID = this.issue.entityIds[0];
45705                   var vertexID = this.issue.entityIds[1];
45706                   var way2 = context.entity(entityID);
45707                   var vertex = context.entity(vertexID);
45708                   continueDrawing(way2, vertex, context);
45709                 }
45710               }));
45711             }
45712             return fixes;
45713           },
45714           loc: node.loc
45715         })];
45716         function getReference(referenceID2) {
45717           return function showReference(selection2) {
45718             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.impossible_oneway." + referenceID2 + ".reference"));
45719           };
45720         }
45721       }
45722     };
45723     function continueDrawing(way, vertex, context) {
45724       var map2 = context.map();
45725       if (!context.editable() || !map2.trimmedExtent().contains(vertex.loc)) {
45726         map2.zoomToEase(vertex);
45727       }
45728       context.enter(
45729         modeDrawLine(context, way.id, context.graph(), "line", way.affix(vertex.id), true)
45730       );
45731     }
45732     validation.type = type2;
45733     return validation;
45734   }
45735
45736   // modules/validations/incompatible_source.js
45737   function validationIncompatibleSource() {
45738     const type2 = "incompatible_source";
45739     const incompatibleRules = [
45740       {
45741         id: "amap",
45742         regex: /(^amap$|^amap\.com|autonavi|mapabc|高德)/i
45743       },
45744       {
45745         id: "baidu",
45746         regex: /(baidu|mapbar|百度)/i
45747       },
45748       {
45749         id: "google",
45750         regex: /google/i,
45751         exceptRegex: /((books|drive)\.google|google\s?(books|drive|plus))|(esri\/Google_Africa_Buildings)/i
45752       }
45753     ];
45754     const validation = function checkIncompatibleSource(entity) {
45755       const entitySources = entity.tags && entity.tags.source && entity.tags.source.split(";");
45756       if (!entitySources)
45757         return [];
45758       const entityID = entity.id;
45759       return entitySources.map((source) => {
45760         const matchRule = incompatibleRules.find((rule) => {
45761           if (!rule.regex.test(source))
45762             return false;
45763           if (rule.exceptRegex && rule.exceptRegex.test(source))
45764             return false;
45765           return true;
45766         });
45767         if (!matchRule)
45768           return null;
45769         return new validationIssue({
45770           type: type2,
45771           severity: "warning",
45772           message: (context) => {
45773             const entity2 = context.hasEntity(entityID);
45774             return entity2 ? _t.append("issues.incompatible_source.feature.message", {
45775               feature: utilDisplayLabel(
45776                 entity2,
45777                 context.graph(),
45778                 true
45779                 /* verbose */
45780               ),
45781               value: source
45782             }) : "";
45783           },
45784           reference: getReference(matchRule.id),
45785           entityIds: [entityID],
45786           hash: source,
45787           dynamicFixes: () => {
45788             return [
45789               new validationIssueFix({ title: _t.append("issues.fix.remove_proprietary_data.title") })
45790             ];
45791           }
45792         });
45793       }).filter(Boolean);
45794       function getReference(id2) {
45795         return function showReference(selection2) {
45796           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.incompatible_source.reference.".concat(id2)));
45797         };
45798       }
45799     };
45800     validation.type = type2;
45801     return validation;
45802   }
45803
45804   // modules/validations/maprules.js
45805   function validationMaprules() {
45806     var type2 = "maprules";
45807     var validation = function checkMaprules(entity, graph) {
45808       if (!services.maprules)
45809         return [];
45810       var rules = services.maprules.validationRules();
45811       var issues = [];
45812       for (var i3 = 0; i3 < rules.length; i3++) {
45813         var rule = rules[i3];
45814         rule.findIssues(entity, graph, issues);
45815       }
45816       return issues;
45817     };
45818     validation.type = type2;
45819     return validation;
45820   }
45821
45822   // modules/validations/mismatched_geometry.js
45823   var import_fast_deep_equal4 = __toESM(require_fast_deep_equal());
45824   function validationMismatchedGeometry() {
45825     var type2 = "mismatched_geometry";
45826     function tagSuggestingLineIsArea(entity) {
45827       if (entity.type !== "way" || entity.isClosed())
45828         return null;
45829       var tagSuggestingArea = entity.tagSuggestingArea();
45830       if (!tagSuggestingArea) {
45831         return null;
45832       }
45833       var asLine = _mainPresetIndex.matchTags(tagSuggestingArea, "line");
45834       var asArea = _mainPresetIndex.matchTags(tagSuggestingArea, "area");
45835       if (asLine && asArea && (0, import_fast_deep_equal4.default)(asLine.tags, asArea.tags)) {
45836         return null;
45837       }
45838       return tagSuggestingArea;
45839     }
45840     function makeConnectEndpointsFixOnClick(way, graph) {
45841       if (way.nodes.length < 3)
45842         return null;
45843       var nodes = graph.childNodes(way), testNodes;
45844       var firstToLastDistanceMeters = geoSphericalDistance(nodes[0].loc, nodes[nodes.length - 1].loc);
45845       if (firstToLastDistanceMeters < 0.75) {
45846         testNodes = nodes.slice();
45847         testNodes.pop();
45848         testNodes.push(testNodes[0]);
45849         if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
45850           return function(context) {
45851             var way2 = context.entity(this.issue.entityIds[0]);
45852             context.perform(
45853               actionMergeNodes([way2.nodes[0], way2.nodes[way2.nodes.length - 1]], nodes[0].loc),
45854               _t("issues.fix.connect_endpoints.annotation")
45855             );
45856           };
45857         }
45858       }
45859       testNodes = nodes.slice();
45860       testNodes.push(testNodes[0]);
45861       if (!geoHasSelfIntersections(testNodes, testNodes[0].id)) {
45862         return function(context) {
45863           var wayId = this.issue.entityIds[0];
45864           var way2 = context.entity(wayId);
45865           var nodeId = way2.nodes[0];
45866           var index = way2.nodes.length;
45867           context.perform(
45868             actionAddVertex(wayId, nodeId, index),
45869             _t("issues.fix.connect_endpoints.annotation")
45870           );
45871         };
45872       }
45873     }
45874     function lineTaggedAsAreaIssue(entity) {
45875       var tagSuggestingArea = tagSuggestingLineIsArea(entity);
45876       if (!tagSuggestingArea)
45877         return null;
45878       var validAsLine = false;
45879       var presetAsLine = _mainPresetIndex.matchTags(entity.tags, "line");
45880       if (presetAsLine) {
45881         validAsLine = true;
45882         var key = Object.keys(tagSuggestingArea)[0];
45883         if (presetAsLine.tags[key] && presetAsLine.tags[key] === "*") {
45884           validAsLine = false;
45885         }
45886         if (Object.keys(presetAsLine.tags).length === 0) {
45887           validAsLine = false;
45888         }
45889       }
45890       return new validationIssue({
45891         type: type2,
45892         subtype: "area_as_line",
45893         severity: "warning",
45894         message: function(context) {
45895           var entity2 = context.hasEntity(this.entityIds[0]);
45896           return entity2 ? _t.append("issues.tag_suggests_area.message", {
45897             feature: utilDisplayLabel(
45898               entity2,
45899               "area",
45900               true
45901               /* verbose */
45902             ),
45903             tag: utilTagText({ tags: tagSuggestingArea })
45904           }) : "";
45905         },
45906         reference: showReference,
45907         entityIds: [entity.id],
45908         hash: JSON.stringify(tagSuggestingArea),
45909         dynamicFixes: function(context) {
45910           var fixes = [];
45911           var entity2 = context.entity(this.entityIds[0]);
45912           var connectEndsOnClick = makeConnectEndpointsFixOnClick(entity2, context.graph());
45913           if (!validAsLine) {
45914             fixes.push(new validationIssueFix({
45915               title: _t.append("issues.fix.connect_endpoints.title"),
45916               onClick: connectEndsOnClick
45917             }));
45918           }
45919           fixes.push(new validationIssueFix({
45920             icon: "iD-operation-delete",
45921             title: _t.append("issues.fix.remove_tag.title"),
45922             onClick: function(context2) {
45923               var entityId = this.issue.entityIds[0];
45924               var entity3 = context2.entity(entityId);
45925               var tags = Object.assign({}, entity3.tags);
45926               for (var key2 in tagSuggestingArea) {
45927                 delete tags[key2];
45928               }
45929               context2.perform(
45930                 actionChangeTags(entityId, tags),
45931                 _t("issues.fix.remove_tag.annotation")
45932               );
45933             }
45934           }));
45935           return fixes;
45936         }
45937       });
45938       function showReference(selection2) {
45939         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.tag_suggests_area.reference"));
45940       }
45941     }
45942     function vertexPointIssue(entity, graph) {
45943       if (entity.type !== "node")
45944         return null;
45945       if (Object.keys(entity.tags).length === 0)
45946         return null;
45947       if (entity.isOnAddressLine(graph))
45948         return null;
45949       var geometry = entity.geometry(graph);
45950       var allowedGeometries = osmNodeGeometriesForTags(entity.tags);
45951       if (geometry === "point" && !allowedGeometries.point && allowedGeometries.vertex) {
45952         return new validationIssue({
45953           type: type2,
45954           subtype: "vertex_as_point",
45955           severity: "warning",
45956           message: function(context) {
45957             var entity2 = context.hasEntity(this.entityIds[0]);
45958             return entity2 ? _t.append("issues.vertex_as_point.message", {
45959               feature: utilDisplayLabel(
45960                 entity2,
45961                 "vertex",
45962                 true
45963                 /* verbose */
45964               )
45965             }) : "";
45966           },
45967           reference: function showReference(selection2) {
45968             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.vertex_as_point.reference"));
45969           },
45970           entityIds: [entity.id]
45971         });
45972       } else if (geometry === "vertex" && !allowedGeometries.vertex && allowedGeometries.point) {
45973         return new validationIssue({
45974           type: type2,
45975           subtype: "point_as_vertex",
45976           severity: "warning",
45977           message: function(context) {
45978             var entity2 = context.hasEntity(this.entityIds[0]);
45979             return entity2 ? _t.append("issues.point_as_vertex.message", {
45980               feature: utilDisplayLabel(
45981                 entity2,
45982                 "point",
45983                 true
45984                 /* verbose */
45985               )
45986             }) : "";
45987           },
45988           reference: function showReference(selection2) {
45989             selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.point_as_vertex.reference"));
45990           },
45991           entityIds: [entity.id],
45992           dynamicFixes: extractPointDynamicFixes
45993         });
45994       }
45995       return null;
45996     }
45997     function otherMismatchIssue(entity, graph) {
45998       if (!entity.hasInterestingTags())
45999         return null;
46000       if (entity.type !== "node" && entity.type !== "way")
46001         return null;
46002       if (entity.type === "node" && entity.isOnAddressLine(graph))
46003         return null;
46004       var sourceGeom = entity.geometry(graph);
46005       var targetGeoms = entity.type === "way" ? ["point", "vertex"] : ["line", "area"];
46006       if (sourceGeom === "area")
46007         targetGeoms.unshift("line");
46008       var asSource = _mainPresetIndex.match(entity, graph);
46009       var targetGeom = targetGeoms.find((nodeGeom) => {
46010         var asTarget = _mainPresetIndex.matchTags(entity.tags, nodeGeom);
46011         if (!asSource || !asTarget || asSource === asTarget || // sometimes there are two presets with the same tags for different geometries
46012         (0, import_fast_deep_equal4.default)(asSource.tags, asTarget.tags))
46013           return false;
46014         if (asTarget.isFallback())
46015           return false;
46016         var primaryKey = Object.keys(asTarget.tags)[0];
46017         if (primaryKey === "building")
46018           return false;
46019         if (asTarget.tags[primaryKey] === "*")
46020           return false;
46021         return asSource.isFallback() || asSource.tags[primaryKey] === "*";
46022       });
46023       if (!targetGeom)
46024         return null;
46025       var subtype = targetGeom + "_as_" + sourceGeom;
46026       if (targetGeom === "vertex")
46027         targetGeom = "point";
46028       if (sourceGeom === "vertex")
46029         sourceGeom = "point";
46030       var referenceId = targetGeom + "_as_" + sourceGeom;
46031       var dynamicFixes;
46032       if (targetGeom === "point") {
46033         dynamicFixes = extractPointDynamicFixes;
46034       } else if (sourceGeom === "area" && targetGeom === "line") {
46035         dynamicFixes = lineToAreaDynamicFixes;
46036       }
46037       return new validationIssue({
46038         type: type2,
46039         subtype,
46040         severity: "warning",
46041         message: function(context) {
46042           var entity2 = context.hasEntity(this.entityIds[0]);
46043           return entity2 ? _t.append("issues." + referenceId + ".message", {
46044             feature: utilDisplayLabel(
46045               entity2,
46046               targetGeom,
46047               true
46048               /* verbose */
46049             )
46050           }) : "";
46051         },
46052         reference: function showReference(selection2) {
46053           selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.mismatched_geometry.reference"));
46054         },
46055         entityIds: [entity.id],
46056         dynamicFixes
46057       });
46058     }
46059     function lineToAreaDynamicFixes(context) {
46060       var convertOnClick;
46061       var entityId = this.entityIds[0];
46062       var entity = context.entity(entityId);
46063       var tags = Object.assign({}, entity.tags);
46064       delete tags.area;
46065       if (!osmTagSuggestingArea(tags)) {
46066         convertOnClick = function(context2) {
46067           var entityId2 = this.issue.entityIds[0];
46068           var entity2 = context2.entity(entityId2);
46069           var tags2 = Object.assign({}, entity2.tags);
46070           if (tags2.area) {
46071             delete tags2.area;
46072           }
46073           context2.perform(
46074             actionChangeTags(entityId2, tags2),
46075             _t("issues.fix.convert_to_line.annotation")
46076           );
46077         };
46078       }
46079       return [
46080         new validationIssueFix({
46081           icon: "iD-icon-line",
46082           title: _t.append("issues.fix.convert_to_line.title"),
46083           onClick: convertOnClick
46084         })
46085       ];
46086     }
46087     function extractPointDynamicFixes(context) {
46088       var entityId = this.entityIds[0];
46089       var extractOnClick = null;
46090       if (!context.hasHiddenConnections(entityId)) {
46091         extractOnClick = function(context2) {
46092           var entityId2 = this.issue.entityIds[0];
46093           var action = actionExtract(entityId2, context2.projection);
46094           context2.perform(
46095             action,
46096             _t("operations.extract.annotation", { n: 1 })
46097           );
46098           context2.enter(modeSelect(context2, [action.getExtractedNodeID()]));
46099         };
46100       }
46101       return [
46102         new validationIssueFix({
46103           icon: "iD-operation-extract",
46104           title: _t.append("issues.fix.extract_point.title"),
46105           onClick: extractOnClick
46106         })
46107       ];
46108     }
46109     function unclosedMultipolygonPartIssues(entity, graph) {
46110       if (entity.type !== "relation" || !entity.isMultipolygon() || entity.isDegenerate() || // cannot determine issues for incompletely-downloaded relations
46111       !entity.isComplete(graph))
46112         return [];
46113       var sequences = osmJoinWays(entity.members, graph);
46114       var issues = [];
46115       for (var i3 in sequences) {
46116         var sequence = sequences[i3];
46117         if (!sequence.nodes)
46118           continue;
46119         var firstNode = sequence.nodes[0];
46120         var lastNode = sequence.nodes[sequence.nodes.length - 1];
46121         if (firstNode === lastNode)
46122           continue;
46123         var issue = new validationIssue({
46124           type: type2,
46125           subtype: "unclosed_multipolygon_part",
46126           severity: "warning",
46127           message: function(context) {
46128             var entity2 = context.hasEntity(this.entityIds[0]);
46129             return entity2 ? _t.append("issues.unclosed_multipolygon_part.message", {
46130               feature: utilDisplayLabel(
46131                 entity2,
46132                 context.graph(),
46133                 true
46134                 /* verbose */
46135               )
46136             }) : "";
46137           },
46138           reference: showReference,
46139           loc: sequence.nodes[0].loc,
46140           entityIds: [entity.id],
46141           hash: sequence.map(function(way) {
46142             return way.id;
46143           }).join()
46144         });
46145         issues.push(issue);
46146       }
46147       return issues;
46148       function showReference(selection2) {
46149         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unclosed_multipolygon_part.reference"));
46150       }
46151     }
46152     var validation = function checkMismatchedGeometry(entity, graph) {
46153       var vertexPoint = vertexPointIssue(entity, graph);
46154       if (vertexPoint)
46155         return [vertexPoint];
46156       var lineAsArea = lineTaggedAsAreaIssue(entity);
46157       if (lineAsArea)
46158         return [lineAsArea];
46159       var mismatch = otherMismatchIssue(entity, graph);
46160       if (mismatch)
46161         return [mismatch];
46162       return unclosedMultipolygonPartIssues(entity, graph);
46163     };
46164     validation.type = type2;
46165     return validation;
46166   }
46167
46168   // modules/validations/missing_role.js
46169   function validationMissingRole() {
46170     var type2 = "missing_role";
46171     var validation = function checkMissingRole(entity, graph) {
46172       var issues = [];
46173       if (entity.type === "way") {
46174         graph.parentRelations(entity).forEach(function(relation) {
46175           if (!relation.isMultipolygon())
46176             return;
46177           var member = relation.memberById(entity.id);
46178           if (member && isMissingRole(member)) {
46179             issues.push(makeIssue(entity, relation, member));
46180           }
46181         });
46182       } else if (entity.type === "relation" && entity.isMultipolygon()) {
46183         entity.indexedMembers().forEach(function(member) {
46184           var way = graph.hasEntity(member.id);
46185           if (way && isMissingRole(member)) {
46186             issues.push(makeIssue(way, entity, member));
46187           }
46188         });
46189       }
46190       return issues;
46191     };
46192     function isMissingRole(member) {
46193       return !member.role || !member.role.trim().length;
46194     }
46195     function makeIssue(way, relation, member) {
46196       return new validationIssue({
46197         type: type2,
46198         severity: "warning",
46199         message: function(context) {
46200           var member2 = context.hasEntity(this.entityIds[1]), relation2 = context.hasEntity(this.entityIds[0]);
46201           return member2 && relation2 ? _t.append("issues.missing_role.message", {
46202             member: utilDisplayLabel(member2, context.graph()),
46203             relation: utilDisplayLabel(relation2, context.graph())
46204           }) : "";
46205         },
46206         reference: showReference,
46207         entityIds: [relation.id, way.id],
46208         data: {
46209           member
46210         },
46211         hash: member.index.toString(),
46212         dynamicFixes: function() {
46213           return [
46214             makeAddRoleFix("inner"),
46215             makeAddRoleFix("outer"),
46216             new validationIssueFix({
46217               icon: "iD-operation-delete",
46218               title: _t.append("issues.fix.remove_from_relation.title"),
46219               onClick: function(context) {
46220                 context.perform(
46221                   actionDeleteMember(this.issue.entityIds[0], this.issue.data.member.index),
46222                   _t("operations.delete_member.annotation", {
46223                     n: 1
46224                   })
46225                 );
46226               }
46227             })
46228           ];
46229         }
46230       });
46231       function showReference(selection2) {
46232         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.missing_role.multipolygon.reference"));
46233       }
46234     }
46235     function makeAddRoleFix(role) {
46236       return new validationIssueFix({
46237         title: _t.append("issues.fix.set_as_" + role + ".title"),
46238         onClick: function(context) {
46239           var oldMember = this.issue.data.member;
46240           var member = { id: this.issue.entityIds[1], type: oldMember.type, role };
46241           context.perform(
46242             actionChangeMember(this.issue.entityIds[0], member, oldMember.index),
46243             _t("operations.change_role.annotation", {
46244               n: 1
46245             })
46246           );
46247         }
46248       });
46249     }
46250     validation.type = type2;
46251     return validation;
46252   }
46253
46254   // modules/validations/missing_tag.js
46255   function validationMissingTag(context) {
46256     var type2 = "missing_tag";
46257     function hasDescriptiveTags(entity, graph) {
46258       var onlyAttributeKeys = ["description", "name", "note", "start_date"];
46259       var entityDescriptiveKeys = Object.keys(entity.tags).filter(function(k2) {
46260         if (k2 === "area" || !osmIsInterestingTag(k2))
46261           return false;
46262         return !onlyAttributeKeys.some(function(attributeKey) {
46263           return k2 === attributeKey || k2.indexOf(attributeKey + ":") === 0;
46264         });
46265       });
46266       if (entity.type === "relation" && entityDescriptiveKeys.length === 1 && entity.tags.type === "multipolygon") {
46267         return osmOldMultipolygonOuterMemberOfRelation(entity, graph);
46268       }
46269       return entityDescriptiveKeys.length > 0;
46270     }
46271     function isUnknownRoad(entity) {
46272       return entity.type === "way" && entity.tags.highway === "road";
46273     }
46274     function isUntypedRelation(entity) {
46275       return entity.type === "relation" && !entity.tags.type;
46276     }
46277     var validation = function checkMissingTag(entity, graph) {
46278       var subtype;
46279       var osm = context.connection();
46280       var isUnloadedNode = entity.type === "node" && osm && !osm.isDataLoaded(entity.loc);
46281       if (!isUnloadedNode && // allow untagged nodes that are part of ways
46282       entity.geometry(graph) !== "vertex" && // allow untagged entities that are part of relations
46283       !entity.hasParentRelations(graph)) {
46284         if (Object.keys(entity.tags).length === 0) {
46285           subtype = "any";
46286         } else if (!hasDescriptiveTags(entity, graph)) {
46287           subtype = "descriptive";
46288         } else if (isUntypedRelation(entity)) {
46289           subtype = "relation_type";
46290         }
46291       }
46292       if (!subtype && isUnknownRoad(entity)) {
46293         subtype = "highway_classification";
46294       }
46295       if (!subtype)
46296         return [];
46297       var messageID = subtype === "highway_classification" ? "unknown_road" : "missing_tag." + subtype;
46298       var referenceID = subtype === "highway_classification" ? "unknown_road" : "missing_tag";
46299       var canDelete = entity.version === void 0 || entity.v !== void 0;
46300       var severity = canDelete && subtype !== "highway_classification" ? "error" : "warning";
46301       return [new validationIssue({
46302         type: type2,
46303         subtype,
46304         severity,
46305         message: function(context2) {
46306           var entity2 = context2.hasEntity(this.entityIds[0]);
46307           return entity2 ? _t.append("issues." + messageID + ".message", {
46308             feature: utilDisplayLabel(entity2, context2.graph())
46309           }) : "";
46310         },
46311         reference: showReference,
46312         entityIds: [entity.id],
46313         dynamicFixes: function(context2) {
46314           var fixes = [];
46315           var selectFixType = subtype === "highway_classification" ? "select_road_type" : "select_preset";
46316           fixes.push(new validationIssueFix({
46317             icon: "iD-icon-search",
46318             title: _t.append("issues.fix." + selectFixType + ".title"),
46319             onClick: function(context3) {
46320               context3.ui().sidebar.showPresetList();
46321             }
46322           }));
46323           var deleteOnClick;
46324           var id2 = this.entityIds[0];
46325           var operation2 = operationDelete(context2, [id2]);
46326           var disabledReasonID = operation2.disabled();
46327           if (!disabledReasonID) {
46328             deleteOnClick = function(context3) {
46329               var id3 = this.issue.entityIds[0];
46330               var operation3 = operationDelete(context3, [id3]);
46331               if (!operation3.disabled()) {
46332                 operation3();
46333               }
46334             };
46335           }
46336           fixes.push(
46337             new validationIssueFix({
46338               icon: "iD-operation-delete",
46339               title: _t.append("issues.fix.delete_feature.title"),
46340               disabledReason: disabledReasonID ? _t("operations.delete." + disabledReasonID + ".single") : void 0,
46341               onClick: deleteOnClick
46342             })
46343           );
46344           return fixes;
46345         }
46346       })];
46347       function showReference(selection2) {
46348         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues." + referenceID + ".reference"));
46349       }
46350     };
46351     validation.type = type2;
46352     return validation;
46353   }
46354
46355   // modules/validations/mutually_exclusive_tags.js
46356   function validationMutuallyExclusiveTags() {
46357     const type2 = "mutually_exclusive_tags";
46358     const tagKeyPairs = osmMutuallyExclusiveTagPairs;
46359     const validation = function checkMutuallyExclusiveTags(entity) {
46360       let pairsFounds = tagKeyPairs.filter((pair3) => {
46361         return pair3[0] in entity.tags && pair3[1] in entity.tags;
46362       }).filter((pair3) => {
46363         return !(pair3[0].match(/^(addr:)?no[a-z]/) && entity.tags[pair3[0]] === "no" || pair3[1].match(/^(addr:)?no[a-z]/) && entity.tags[pair3[1]] === "no");
46364       });
46365       Object.keys(entity.tags).forEach((key) => {
46366         let negative_key = "not:" + key;
46367         if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
46368           pairsFounds.push([negative_key, key, "same_value"]);
46369         }
46370         if (key.match(/^name:[a-z]+/)) {
46371           negative_key = "not:name";
46372           if (negative_key in entity.tags && entity.tags[negative_key].split(";").includes(entity.tags[key])) {
46373             pairsFounds.push([negative_key, key, "same_value"]);
46374           }
46375         }
46376       });
46377       let issues = pairsFounds.map((pair3) => {
46378         const subtype = pair3[2] || "default";
46379         return new validationIssue({
46380           type: type2,
46381           subtype,
46382           severity: "warning",
46383           message: function(context) {
46384             let entity2 = context.hasEntity(this.entityIds[0]);
46385             return entity2 ? _t.append("issues.".concat(type2, ".").concat(subtype, ".message"), {
46386               feature: utilDisplayLabel(entity2, context.graph()),
46387               tag1: pair3[0],
46388               tag2: pair3[1]
46389             }) : "";
46390           },
46391           reference: (selection2) => showReference(selection2, pair3, subtype),
46392           entityIds: [entity.id],
46393           dynamicFixes: () => pair3.slice(0, 2).map((tagToRemove) => createIssueFix(tagToRemove))
46394         });
46395       });
46396       function createIssueFix(tagToRemove) {
46397         return new validationIssueFix({
46398           icon: "iD-operation-delete",
46399           title: _t.append("issues.fix.remove_named_tag.title", { tag: tagToRemove }),
46400           onClick: function(context) {
46401             const entityId = this.issue.entityIds[0];
46402             const entity2 = context.entity(entityId);
46403             let tags = Object.assign({}, entity2.tags);
46404             delete tags[tagToRemove];
46405             context.perform(
46406               actionChangeTags(entityId, tags),
46407               _t("issues.fix.remove_named_tag.annotation", { tag: tagToRemove })
46408             );
46409           }
46410         });
46411       }
46412       function showReference(selection2, pair3, subtype) {
46413         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.".concat(type2, ".").concat(subtype, ".reference"), { tag1: pair3[0], tag2: pair3[1] }));
46414       }
46415       return issues;
46416     };
46417     validation.type = type2;
46418     return validation;
46419   }
46420
46421   // modules/validations/outdated_tags.js
46422   function validationOutdatedTags() {
46423     const type2 = "outdated_tags";
46424     let _waitingForDeprecated = true;
46425     let _dataDeprecated;
46426     _mainFileFetcher.get("deprecated").then((d2) => _dataDeprecated = d2).catch(() => {
46427     }).finally(() => _waitingForDeprecated = false);
46428     function oldTagIssues(entity, graph) {
46429       if (!entity.hasInterestingTags())
46430         return [];
46431       let preset = _mainPresetIndex.match(entity, graph);
46432       if (!preset)
46433         return [];
46434       const oldTags = Object.assign({}, entity.tags);
46435       let subtype = "deprecated_tags";
46436       if (preset.replacement) {
46437         const newPreset = _mainPresetIndex.item(preset.replacement);
46438         graph = actionChangePreset(
46439           entity.id,
46440           preset,
46441           newPreset,
46442           true
46443           /* skip field defaults */
46444         )(graph);
46445         entity = graph.entity(entity.id);
46446         preset = newPreset;
46447       }
46448       if (_dataDeprecated) {
46449         const deprecatedTags = entity.deprecatedTags(_dataDeprecated);
46450         if (deprecatedTags.length) {
46451           deprecatedTags.forEach((tag2) => {
46452             graph = actionUpgradeTags(entity.id, tag2.old, tag2.replace)(graph);
46453           });
46454           entity = graph.entity(entity.id);
46455         }
46456       }
46457       let newTags = Object.assign({}, entity.tags);
46458       if (preset.tags !== preset.addTags) {
46459         Object.keys(preset.addTags).forEach((k2) => {
46460           if (!newTags[k2]) {
46461             if (preset.addTags[k2] === "*") {
46462               newTags[k2] = "yes";
46463             } else {
46464               newTags[k2] = preset.addTags[k2];
46465             }
46466           }
46467         });
46468       }
46469       const nsi = services.nsi;
46470       let waitingForNsi = false;
46471       let nsiResult;
46472       if (nsi) {
46473         waitingForNsi = nsi.status() === "loading";
46474         if (!waitingForNsi) {
46475           const loc = entity.extent(graph).center();
46476           nsiResult = nsi.upgradeTags(newTags, loc);
46477           if (nsiResult) {
46478             newTags = nsiResult.newTags;
46479             subtype = "noncanonical_brand";
46480           }
46481         }
46482       }
46483       let issues = [];
46484       issues.provisional = _waitingForDeprecated || waitingForNsi;
46485       const tagDiff = utilTagDiff(oldTags, newTags);
46486       if (!tagDiff.length)
46487         return issues;
46488       const isOnlyAddingTags = tagDiff.every((d2) => d2.type === "+");
46489       let prefix = "";
46490       if (nsiResult) {
46491         prefix = "noncanonical_brand.";
46492       } else if (subtype === "deprecated_tags" && isOnlyAddingTags) {
46493         subtype = "incomplete_tags";
46494         prefix = "incomplete.";
46495       }
46496       let autoArgs = subtype !== "noncanonical_brand" ? [doUpgrade, _t("issues.fix.upgrade_tags.annotation")] : null;
46497       issues.push(new validationIssue({
46498         type: type2,
46499         subtype,
46500         severity: "warning",
46501         message: showMessage,
46502         reference: showReference,
46503         entityIds: [entity.id],
46504         hash: utilHashcode(JSON.stringify(tagDiff)),
46505         dynamicFixes: () => {
46506           let fixes = [
46507             new validationIssueFix({
46508               autoArgs,
46509               title: _t.append("issues.fix.upgrade_tags.title"),
46510               onClick: (context) => {
46511                 context.perform(doUpgrade, _t("issues.fix.upgrade_tags.annotation"));
46512               }
46513             })
46514           ];
46515           const item = nsiResult && nsiResult.matched;
46516           if (item) {
46517             fixes.push(
46518               new validationIssueFix({
46519                 title: _t.append("issues.fix.tag_as_not.title", { name: item.displayName }),
46520                 onClick: (context) => {
46521                   context.perform(addNotTag, _t("issues.fix.tag_as_not.annotation"));
46522                 }
46523               })
46524             );
46525           }
46526           return fixes;
46527         }
46528       }));
46529       return issues;
46530       function doUpgrade(graph2) {
46531         const currEntity = graph2.hasEntity(entity.id);
46532         if (!currEntity)
46533           return graph2;
46534         let newTags2 = Object.assign({}, currEntity.tags);
46535         tagDiff.forEach((diff) => {
46536           if (diff.type === "-") {
46537             delete newTags2[diff.key];
46538           } else if (diff.type === "+") {
46539             newTags2[diff.key] = diff.newVal;
46540           }
46541         });
46542         return actionChangeTags(currEntity.id, newTags2)(graph2);
46543       }
46544       function addNotTag(graph2) {
46545         const currEntity = graph2.hasEntity(entity.id);
46546         if (!currEntity)
46547           return graph2;
46548         const item = nsiResult && nsiResult.matched;
46549         if (!item)
46550           return graph2;
46551         let newTags2 = Object.assign({}, currEntity.tags);
46552         const wd = item.mainTag;
46553         const notwd = "not:".concat(wd);
46554         const qid = item.tags[wd];
46555         newTags2[notwd] = qid;
46556         if (newTags2[wd] === qid) {
46557           const wp = item.mainTag.replace("wikidata", "wikipedia");
46558           delete newTags2[wd];
46559           delete newTags2[wp];
46560         }
46561         return actionChangeTags(currEntity.id, newTags2)(graph2);
46562       }
46563       function showMessage(context) {
46564         const currEntity = context.hasEntity(entity.id);
46565         if (!currEntity)
46566           return "";
46567         let messageID = "issues.outdated_tags.".concat(prefix, "message");
46568         if (subtype === "noncanonical_brand" && isOnlyAddingTags) {
46569           messageID += "_incomplete";
46570         }
46571         return _t.append(messageID, {
46572           feature: utilDisplayLabel(
46573             currEntity,
46574             context.graph(),
46575             true
46576             /* verbose */
46577           )
46578         });
46579       }
46580       function showReference(selection2) {
46581         let enter = selection2.selectAll(".issue-reference").data([0]).enter();
46582         enter.append("div").attr("class", "issue-reference").call(_t.append("issues.outdated_tags.".concat(prefix, "reference")));
46583         enter.append("strong").call(_t.append("issues.suggested"));
46584         enter.append("table").attr("class", "tagDiff-table").selectAll(".tagDiff-row").data(tagDiff).enter().append("tr").attr("class", "tagDiff-row").append("td").attr("class", (d2) => {
46585           let klass = d2.type === "+" ? "add" : "remove";
46586           return "tagDiff-cell tagDiff-cell-".concat(klass);
46587         }).html((d2) => d2.display);
46588       }
46589     }
46590     function oldMultipolygonIssues(entity, graph) {
46591       let multipolygon, outerWay;
46592       if (entity.type === "relation") {
46593         outerWay = osmOldMultipolygonOuterMemberOfRelation(entity, graph);
46594         multipolygon = entity;
46595       } else if (entity.type === "way") {
46596         multipolygon = osmIsOldMultipolygonOuterMember(entity, graph);
46597         outerWay = entity;
46598       } else {
46599         return [];
46600       }
46601       if (!multipolygon || !outerWay)
46602         return [];
46603       return [new validationIssue({
46604         type: type2,
46605         subtype: "old_multipolygon",
46606         severity: "warning",
46607         message: showMessage,
46608         reference: showReference,
46609         entityIds: [outerWay.id, multipolygon.id],
46610         dynamicFixes: () => {
46611           return [
46612             new validationIssueFix({
46613               autoArgs: [doUpgrade, _t("issues.fix.move_tags.annotation")],
46614               title: _t.append("issues.fix.move_tags.title"),
46615               onClick: (context) => {
46616                 context.perform(doUpgrade, _t("issues.fix.move_tags.annotation"));
46617               }
46618             })
46619           ];
46620         }
46621       })];
46622       function doUpgrade(graph2) {
46623         let currMultipolygon = graph2.hasEntity(multipolygon.id);
46624         let currOuterWay = graph2.hasEntity(outerWay.id);
46625         if (!currMultipolygon || !currOuterWay)
46626           return graph2;
46627         currMultipolygon = currMultipolygon.mergeTags(currOuterWay.tags);
46628         graph2 = graph2.replace(currMultipolygon);
46629         return actionChangeTags(currOuterWay.id, {})(graph2);
46630       }
46631       function showMessage(context) {
46632         let currMultipolygon = context.hasEntity(multipolygon.id);
46633         if (!currMultipolygon)
46634           return "";
46635         return _t.append(
46636           "issues.old_multipolygon.message",
46637           { multipolygon: utilDisplayLabel(
46638             currMultipolygon,
46639             context.graph(),
46640             true
46641             /* verbose */
46642           ) }
46643         );
46644       }
46645       function showReference(selection2) {
46646         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.old_multipolygon.reference"));
46647       }
46648     }
46649     let validation = function checkOutdatedTags(entity, graph) {
46650       let issues = oldMultipolygonIssues(entity, graph);
46651       if (!issues.length)
46652         issues = oldTagIssues(entity, graph);
46653       return issues;
46654     };
46655     validation.type = type2;
46656     return validation;
46657   }
46658
46659   // modules/validations/private_data.js
46660   function validationPrivateData() {
46661     var type2 = "private_data";
46662     var privateBuildingValues = {
46663       detached: true,
46664       farm: true,
46665       house: true,
46666       houseboat: true,
46667       residential: true,
46668       semidetached_house: true,
46669       static_caravan: true
46670     };
46671     var publicKeys = {
46672       amenity: true,
46673       craft: true,
46674       historic: true,
46675       leisure: true,
46676       office: true,
46677       shop: true,
46678       tourism: true
46679     };
46680     var personalTags = {
46681       "contact:email": true,
46682       "contact:fax": true,
46683       "contact:phone": true,
46684       email: true,
46685       fax: true,
46686       phone: true
46687     };
46688     var validation = function checkPrivateData(entity) {
46689       var tags = entity.tags;
46690       if (!tags.building || !privateBuildingValues[tags.building])
46691         return [];
46692       var keepTags = {};
46693       for (var k2 in tags) {
46694         if (publicKeys[k2])
46695           return [];
46696         if (!personalTags[k2]) {
46697           keepTags[k2] = tags[k2];
46698         }
46699       }
46700       var tagDiff = utilTagDiff(tags, keepTags);
46701       if (!tagDiff.length)
46702         return [];
46703       var fixID = tagDiff.length === 1 ? "remove_tag" : "remove_tags";
46704       return [new validationIssue({
46705         type: type2,
46706         severity: "warning",
46707         message: showMessage,
46708         reference: showReference,
46709         entityIds: [entity.id],
46710         dynamicFixes: function() {
46711           return [
46712             new validationIssueFix({
46713               icon: "iD-operation-delete",
46714               title: _t.append("issues.fix." + fixID + ".title"),
46715               onClick: function(context) {
46716                 context.perform(doUpgrade, _t("issues.fix.remove_tag.annotation"));
46717               }
46718             })
46719           ];
46720         }
46721       })];
46722       function doUpgrade(graph) {
46723         var currEntity = graph.hasEntity(entity.id);
46724         if (!currEntity)
46725           return graph;
46726         var newTags = Object.assign({}, currEntity.tags);
46727         tagDiff.forEach(function(diff) {
46728           if (diff.type === "-") {
46729             delete newTags[diff.key];
46730           } else if (diff.type === "+") {
46731             newTags[diff.key] = diff.newVal;
46732           }
46733         });
46734         return actionChangeTags(currEntity.id, newTags)(graph);
46735       }
46736       function showMessage(context) {
46737         var currEntity = context.hasEntity(this.entityIds[0]);
46738         if (!currEntity)
46739           return "";
46740         return _t.append(
46741           "issues.private_data.contact.message",
46742           { feature: utilDisplayLabel(currEntity, context.graph()) }
46743         );
46744       }
46745       function showReference(selection2) {
46746         var enter = selection2.selectAll(".issue-reference").data([0]).enter();
46747         enter.append("div").attr("class", "issue-reference").call(_t.append("issues.private_data.reference"));
46748         enter.append("strong").call(_t.append("issues.suggested"));
46749         enter.append("table").attr("class", "tagDiff-table").selectAll(".tagDiff-row").data(tagDiff).enter().append("tr").attr("class", "tagDiff-row").append("td").attr("class", function(d2) {
46750           var klass = d2.type === "+" ? "add" : "remove";
46751           return "tagDiff-cell tagDiff-cell-" + klass;
46752         }).html(function(d2) {
46753           return d2.display;
46754         });
46755       }
46756     };
46757     validation.type = type2;
46758     return validation;
46759   }
46760
46761   // modules/validations/suspicious_name.js
46762   function validationSuspiciousName() {
46763     const type2 = "suspicious_name";
46764     const keysToTestForGenericValues = [
46765       "aerialway",
46766       "aeroway",
46767       "amenity",
46768       "building",
46769       "craft",
46770       "highway",
46771       "leisure",
46772       "railway",
46773       "man_made",
46774       "office",
46775       "shop",
46776       "tourism",
46777       "waterway"
46778     ];
46779     let _waitingForNsi = false;
46780     function isGenericMatchInNsi(tags) {
46781       const nsi = services.nsi;
46782       if (nsi) {
46783         _waitingForNsi = nsi.status() === "loading";
46784         if (!_waitingForNsi) {
46785           return nsi.isGenericName(tags);
46786         }
46787       }
46788       return false;
46789     }
46790     function nameMatchesRawTag(lowercaseName, tags) {
46791       for (let i3 = 0; i3 < keysToTestForGenericValues.length; i3++) {
46792         let key = keysToTestForGenericValues[i3];
46793         let val = tags[key];
46794         if (val) {
46795           val = val.toLowerCase();
46796           if (key === lowercaseName || val === lowercaseName || key.replace(/\_/g, " ") === lowercaseName || val.replace(/\_/g, " ") === lowercaseName) {
46797             return true;
46798           }
46799         }
46800       }
46801       return false;
46802     }
46803     function isGenericName(name, tags) {
46804       name = name.toLowerCase();
46805       return nameMatchesRawTag(name, tags) || isGenericMatchInNsi(tags);
46806     }
46807     function makeGenericNameIssue(entityId, nameKey, genericName, langCode) {
46808       return new validationIssue({
46809         type: type2,
46810         subtype: "generic_name",
46811         severity: "warning",
46812         message: function(context) {
46813           let entity = context.hasEntity(this.entityIds[0]);
46814           if (!entity)
46815             return "";
46816           let preset = _mainPresetIndex.match(entity, context.graph());
46817           let langName = langCode && _mainLocalizer.languageName(langCode);
46818           return _t.append(
46819             "issues.generic_name.message" + (langName ? "_language" : ""),
46820             { feature: preset.name(), name: genericName, language: langName }
46821           );
46822         },
46823         reference: showReference,
46824         entityIds: [entityId],
46825         hash: "".concat(nameKey, "=").concat(genericName),
46826         dynamicFixes: function() {
46827           return [
46828             new validationIssueFix({
46829               icon: "iD-operation-delete",
46830               title: _t.append("issues.fix.remove_the_name.title"),
46831               onClick: function(context) {
46832                 let entityId2 = this.issue.entityIds[0];
46833                 let entity = context.entity(entityId2);
46834                 let tags = Object.assign({}, entity.tags);
46835                 delete tags[nameKey];
46836                 context.perform(
46837                   actionChangeTags(entityId2, tags),
46838                   _t("issues.fix.remove_generic_name.annotation")
46839                 );
46840               }
46841             })
46842           ];
46843         }
46844       });
46845       function showReference(selection2) {
46846         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.generic_name.reference"));
46847       }
46848     }
46849     let validation = function checkGenericName(entity) {
46850       const tags = entity.tags;
46851       const hasWikidata = !!tags.wikidata || !!tags["brand:wikidata"] || !!tags["operator:wikidata"];
46852       if (hasWikidata)
46853         return [];
46854       let issues = [];
46855       for (let key in tags) {
46856         const m2 = key.match(/^name(?:(?::)([a-zA-Z_-]+))?$/);
46857         if (!m2)
46858           continue;
46859         const langCode = m2.length >= 2 ? m2[1] : null;
46860         const value = tags[key];
46861         if (isGenericName(value, tags)) {
46862           issues.provisional = _waitingForNsi;
46863           issues.push(makeGenericNameIssue(entity.id, key, value, langCode));
46864         }
46865       }
46866       return issues;
46867     };
46868     validation.type = type2;
46869     return validation;
46870   }
46871
46872   // modules/validations/unsquare_way.js
46873   function validationUnsquareWay(context) {
46874     var type2 = "unsquare_way";
46875     var DEFAULT_DEG_THRESHOLD = 5;
46876     var epsilon3 = 0.05;
46877     var nodeThreshold = 10;
46878     function isBuilding(entity, graph) {
46879       if (entity.type !== "way" || entity.geometry(graph) !== "area")
46880         return false;
46881       return entity.tags.building && entity.tags.building !== "no";
46882     }
46883     var validation = function checkUnsquareWay(entity, graph) {
46884       if (!isBuilding(entity, graph))
46885         return [];
46886       if (entity.tags.nonsquare === "yes")
46887         return [];
46888       var isClosed = entity.isClosed();
46889       if (!isClosed)
46890         return [];
46891       var nodes = graph.childNodes(entity).slice();
46892       if (nodes.length > nodeThreshold + 1)
46893         return [];
46894       var osm = services.osm;
46895       if (!osm || nodes.some(function(node) {
46896         return !osm.isDataLoaded(node.loc);
46897       }))
46898         return [];
46899       var hasConnectedSquarableWays = nodes.some(function(node) {
46900         return graph.parentWays(node).some(function(way) {
46901           if (way.id === entity.id)
46902             return false;
46903           if (isBuilding(way, graph))
46904             return true;
46905           return graph.parentRelations(way).some(function(parentRelation) {
46906             return parentRelation.isMultipolygon() && parentRelation.tags.building && parentRelation.tags.building !== "no";
46907           });
46908         });
46909       });
46910       if (hasConnectedSquarableWays)
46911         return [];
46912       var storedDegreeThreshold = corePreferences("validate-square-degrees");
46913       var degreeThreshold = isFinite(storedDegreeThreshold) ? Number(storedDegreeThreshold) : DEFAULT_DEG_THRESHOLD;
46914       var points = nodes.map(function(node) {
46915         return context.projection(node.loc);
46916       });
46917       if (!geoOrthoCanOrthogonalize(points, isClosed, epsilon3, degreeThreshold, true))
46918         return [];
46919       var autoArgs;
46920       if (!entity.tags.wikidata) {
46921         var autoAction = actionOrthogonalize(entity.id, context.projection, void 0, degreeThreshold);
46922         autoAction.transitionable = false;
46923         autoArgs = [autoAction, _t("operations.orthogonalize.annotation.feature", { n: 1 })];
46924       }
46925       return [new validationIssue({
46926         type: type2,
46927         subtype: "building",
46928         severity: "warning",
46929         message: function(context2) {
46930           var entity2 = context2.hasEntity(this.entityIds[0]);
46931           return entity2 ? _t.append("issues.unsquare_way.message", {
46932             feature: utilDisplayLabel(entity2, context2.graph())
46933           }) : "";
46934         },
46935         reference: showReference,
46936         entityIds: [entity.id],
46937         hash: degreeThreshold,
46938         dynamicFixes: function() {
46939           return [
46940             new validationIssueFix({
46941               icon: "iD-operation-orthogonalize",
46942               title: _t.append("issues.fix.square_feature.title"),
46943               autoArgs,
46944               onClick: function(context2, completionHandler) {
46945                 var entityId = this.issue.entityIds[0];
46946                 context2.perform(
46947                   actionOrthogonalize(entityId, context2.projection, void 0, degreeThreshold),
46948                   _t("operations.orthogonalize.annotation.feature", { n: 1 })
46949                 );
46950                 window.setTimeout(function() {
46951                   completionHandler();
46952                 }, 175);
46953               }
46954             })
46955             /*
46956             new validationIssueFix({
46957                 title: t.append('issues.fix.tag_as_unsquare.title'),
46958                 onClick: function(context) {
46959                     var entityId = this.issue.entityIds[0];
46960                     var entity = context.entity(entityId);
46961                     var tags = Object.assign({}, entity.tags);  // shallow copy
46962                     tags.nonsquare = 'yes';
46963                     context.perform(
46964                         actionChangeTags(entityId, tags),
46965                         t('issues.fix.tag_as_unsquare.annotation')
46966                     );
46967                 }
46968             })
46969             */
46970           ];
46971         }
46972       })];
46973       function showReference(selection2) {
46974         selection2.selectAll(".issue-reference").data([0]).enter().append("div").attr("class", "issue-reference").call(_t.append("issues.unsquare_way.buildings.reference"));
46975       }
46976     };
46977     validation.type = type2;
46978     return validation;
46979   }
46980
46981   // modules/core/validator.js
46982   function coreValidator(context) {
46983     let dispatch14 = dispatch_default("validated", "focusedIssue");
46984     let validator = utilRebind({}, dispatch14, "on");
46985     let _rules = {};
46986     let _disabledRules = {};
46987     let _ignoredIssueIDs = /* @__PURE__ */ new Set();
46988     let _resolvedIssueIDs = /* @__PURE__ */ new Set();
46989     let _baseCache = validationCache("base");
46990     let _headCache = validationCache("head");
46991     let _completeDiff = {};
46992     let _headIsCurrent = false;
46993     let _deferredRIC = {};
46994     let _deferredST = /* @__PURE__ */ new Set();
46995     let _headPromise;
46996     const RETRY = 5e3;
46997     const _errorOverrides = parseHashParam(context.initialHashParams.validationError);
46998     const _warningOverrides = parseHashParam(context.initialHashParams.validationWarning);
46999     const _disableOverrides = parseHashParam(context.initialHashParams.validationDisable);
47000     function parseHashParam(param) {
47001       let result = [];
47002       let rules = (param || "").split(",");
47003       rules.forEach((rule) => {
47004         rule = rule.trim();
47005         const parts = rule.split("/", 2);
47006         const type2 = parts[0];
47007         const subtype = parts[1] || "*";
47008         if (!type2 || !subtype)
47009           return;
47010         result.push({ type: makeRegExp(type2), subtype: makeRegExp(subtype) });
47011       });
47012       return result;
47013       function makeRegExp(str) {
47014         const escaped = str.replace(/[-\/\\^$+?.()|[\]{}]/g, "\\$&").replace(/\*/g, ".*");
47015         return new RegExp("^" + escaped + "$");
47016       }
47017     }
47018     validator.init = () => {
47019       Object.values(validations_exports).forEach((validation) => {
47020         if (typeof validation !== "function")
47021           return;
47022         const fn = validation(context);
47023         const key = fn.type;
47024         _rules[key] = fn;
47025       });
47026       let disabledRules = corePreferences("validate-disabledRules");
47027       if (disabledRules) {
47028         disabledRules.split(",").forEach((k2) => _disabledRules[k2] = true);
47029       }
47030     };
47031     function reset(resetIgnored) {
47032       _baseCache.queue = [];
47033       _headCache.queue = [];
47034       Object.keys(_deferredRIC).forEach((key) => {
47035         window.cancelIdleCallback(key);
47036         _deferredRIC[key]();
47037       });
47038       _deferredRIC = {};
47039       _deferredST.forEach(window.clearTimeout);
47040       _deferredST.clear();
47041       if (resetIgnored)
47042         _ignoredIssueIDs.clear();
47043       _resolvedIssueIDs.clear();
47044       _baseCache = validationCache("base");
47045       _headCache = validationCache("head");
47046       _completeDiff = {};
47047       _headIsCurrent = false;
47048     }
47049     validator.reset = () => {
47050       reset(true);
47051     };
47052     validator.resetIgnoredIssues = () => {
47053       _ignoredIssueIDs.clear();
47054       dispatch14.call("validated");
47055     };
47056     validator.revalidateUnsquare = () => {
47057       revalidateUnsquare(_headCache);
47058       revalidateUnsquare(_baseCache);
47059       dispatch14.call("validated");
47060     };
47061     function revalidateUnsquare(cache) {
47062       const checkUnsquareWay = _rules.unsquare_way;
47063       if (!cache.graph || typeof checkUnsquareWay !== "function")
47064         return;
47065       cache.uncacheIssuesOfType("unsquare_way");
47066       const buildings = context.history().tree().intersects(geoExtent([-180, -90], [180, 90]), cache.graph).filter((entity) => entity.type === "way" && entity.tags.building && entity.tags.building !== "no");
47067       buildings.forEach((entity) => {
47068         const detected = checkUnsquareWay(entity, cache.graph);
47069         if (!detected.length)
47070           return;
47071         cache.cacheIssues(detected);
47072       });
47073     }
47074     validator.getIssues = (options2) => {
47075       const opts = Object.assign({ what: "all", where: "all", includeIgnored: false, includeDisabledRules: false }, options2);
47076       const view = context.map().extent();
47077       let seen = /* @__PURE__ */ new Set();
47078       let results = [];
47079       if (_headCache.graph && _headCache.graph !== _baseCache.graph) {
47080         Object.values(_headCache.issuesByIssueID).forEach((issue) => {
47081           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
47082           if (opts.what === "edited" && !userModified)
47083             return;
47084           if (!filter2(issue))
47085             return;
47086           seen.add(issue.id);
47087           results.push(issue);
47088         });
47089       }
47090       if (opts.what === "all") {
47091         Object.values(_baseCache.issuesByIssueID).forEach((issue) => {
47092           if (!filter2(issue))
47093             return;
47094           seen.add(issue.id);
47095           results.push(issue);
47096         });
47097       }
47098       return results;
47099       function filter2(issue) {
47100         if (!issue)
47101           return false;
47102         if (seen.has(issue.id))
47103           return false;
47104         if (_resolvedIssueIDs.has(issue.id))
47105           return false;
47106         if (opts.includeDisabledRules === "only" && !_disabledRules[issue.type])
47107           return false;
47108         if (!opts.includeDisabledRules && _disabledRules[issue.type])
47109           return false;
47110         if (opts.includeIgnored === "only" && !_ignoredIssueIDs.has(issue.id))
47111           return false;
47112         if (!opts.includeIgnored && _ignoredIssueIDs.has(issue.id))
47113           return false;
47114         if ((issue.entityIds || []).some((id2) => !context.hasEntity(id2)))
47115           return false;
47116         if (opts.where === "visible") {
47117           const extent = issue.extent(context.graph());
47118           if (!view.intersects(extent))
47119             return false;
47120         }
47121         return true;
47122       }
47123     };
47124     validator.getResolvedIssues = () => {
47125       return Array.from(_resolvedIssueIDs).map((issueID) => _baseCache.issuesByIssueID[issueID]).filter(Boolean);
47126     };
47127     validator.focusIssue = (issue) => {
47128       const graph = context.graph();
47129       let selectID;
47130       let focusCenter;
47131       const issueExtent = issue.extent(graph);
47132       if (issueExtent) {
47133         focusCenter = issueExtent.center();
47134       }
47135       if (issue.entityIds && issue.entityIds.length) {
47136         selectID = issue.entityIds[0];
47137         if (selectID && selectID.charAt(0) === "r") {
47138           const ids = utilEntityAndDeepMemberIDs([selectID], graph);
47139           let nodeID = ids.find((id2) => id2.charAt(0) === "n" && graph.hasEntity(id2));
47140           if (!nodeID) {
47141             const wayID = ids.find((id2) => id2.charAt(0) === "w" && graph.hasEntity(id2));
47142             if (wayID) {
47143               nodeID = graph.entity(wayID).first();
47144             }
47145           }
47146           if (nodeID) {
47147             focusCenter = graph.entity(nodeID).loc;
47148           }
47149         }
47150       }
47151       if (focusCenter) {
47152         const setZoom = Math.max(context.map().zoom(), 19);
47153         context.map().unobscuredCenterZoomEase(focusCenter, setZoom);
47154       }
47155       if (selectID) {
47156         window.setTimeout(() => {
47157           context.enter(modeSelect(context, [selectID]));
47158           dispatch14.call("focusedIssue", this, issue);
47159         }, 250);
47160       }
47161     };
47162     validator.getIssuesBySeverity = (options2) => {
47163       let groups = utilArrayGroupBy(validator.getIssues(options2), "severity");
47164       groups.error = groups.error || [];
47165       groups.warning = groups.warning || [];
47166       return groups;
47167     };
47168     validator.getSharedEntityIssues = (entityIDs, options2) => {
47169       const orderedIssueTypes = [
47170         // Show some issue types in a particular order:
47171         "missing_tag",
47172         "missing_role",
47173         // - missing data first
47174         "outdated_tags",
47175         "mismatched_geometry",
47176         // - identity issues
47177         "crossing_ways",
47178         "almost_junction",
47179         // - geometry issues where fixing them might solve connectivity issues
47180         "disconnected_way",
47181         "impossible_oneway"
47182         // - finally connectivity issues
47183       ];
47184       const allIssues = validator.getIssues(options2);
47185       const forEntityIDs = new Set(entityIDs);
47186       return allIssues.filter((issue) => (issue.entityIds || []).some((entityID) => forEntityIDs.has(entityID))).sort((issue1, issue2) => {
47187         if (issue1.type === issue2.type) {
47188           return issue1.id < issue2.id ? -1 : 1;
47189         }
47190         const index1 = orderedIssueTypes.indexOf(issue1.type);
47191         const index2 = orderedIssueTypes.indexOf(issue2.type);
47192         if (index1 !== -1 && index2 !== -1) {
47193           return index1 - index2;
47194         } else if (index1 === -1 && index2 === -1) {
47195           return issue1.type < issue2.type ? -1 : 1;
47196         } else {
47197           return index1 !== -1 ? -1 : 1;
47198         }
47199       });
47200     };
47201     validator.getEntityIssues = (entityID, options2) => {
47202       return validator.getSharedEntityIssues([entityID], options2);
47203     };
47204     validator.getRuleKeys = () => {
47205       return Object.keys(_rules);
47206     };
47207     validator.isRuleEnabled = (key) => {
47208       return !_disabledRules[key];
47209     };
47210     validator.toggleRule = (key) => {
47211       if (_disabledRules[key]) {
47212         delete _disabledRules[key];
47213       } else {
47214         _disabledRules[key] = true;
47215       }
47216       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
47217       validator.validate();
47218     };
47219     validator.disableRules = (keys2) => {
47220       _disabledRules = {};
47221       keys2.forEach((k2) => _disabledRules[k2] = true);
47222       corePreferences("validate-disabledRules", Object.keys(_disabledRules).join(","));
47223       validator.validate();
47224     };
47225     validator.ignoreIssue = (issueID) => {
47226       _ignoredIssueIDs.add(issueID);
47227     };
47228     validator.validate = () => {
47229       const baseGraph = context.history().base();
47230       if (!_headCache.graph)
47231         _headCache.graph = baseGraph;
47232       if (!_baseCache.graph)
47233         _baseCache.graph = baseGraph;
47234       const prevGraph = _headCache.graph;
47235       const currGraph = context.graph();
47236       if (currGraph === prevGraph) {
47237         _headIsCurrent = true;
47238         dispatch14.call("validated");
47239         return Promise.resolve();
47240       }
47241       if (_headPromise) {
47242         _headIsCurrent = false;
47243         return _headPromise;
47244       }
47245       _headCache.graph = currGraph;
47246       _completeDiff = context.history().difference().complete();
47247       const incrementalDiff = coreDifference(prevGraph, currGraph);
47248       let entityIDs = Object.keys(incrementalDiff.complete());
47249       entityIDs = _headCache.withAllRelatedEntities(entityIDs);
47250       if (!entityIDs.size) {
47251         dispatch14.call("validated");
47252         return Promise.resolve();
47253       }
47254       _headPromise = validateEntitiesAsync(entityIDs, _headCache).then(() => updateResolvedIssues(entityIDs)).then(() => dispatch14.call("validated")).catch(() => {
47255       }).then(() => {
47256         _headPromise = null;
47257         if (!_headIsCurrent) {
47258           validator.validate();
47259         }
47260       });
47261       return _headPromise;
47262     };
47263     context.history().on("restore.validator", validator.validate).on("undone.validator", validator.validate).on("redone.validator", validator.validate).on("reset.validator", () => {
47264       reset(false);
47265       validator.validate();
47266     });
47267     context.on("exit.validator", validator.validate);
47268     context.history().on("merge.validator", (entities) => {
47269       if (!entities)
47270         return;
47271       const baseGraph = context.history().base();
47272       if (!_headCache.graph)
47273         _headCache.graph = baseGraph;
47274       if (!_baseCache.graph)
47275         _baseCache.graph = baseGraph;
47276       let entityIDs = entities.map((entity) => entity.id);
47277       entityIDs = _baseCache.withAllRelatedEntities(entityIDs);
47278       validateEntitiesAsync(entityIDs, _baseCache);
47279     });
47280     function validateEntity(entity, graph) {
47281       let result = { issues: [], provisional: false };
47282       Object.keys(_rules).forEach(runValidation);
47283       return result;
47284       function runValidation(key) {
47285         const fn = _rules[key];
47286         if (typeof fn !== "function") {
47287           console.error("no such validation rule = " + key);
47288           return;
47289         }
47290         let detected = fn(entity, graph);
47291         if (detected.provisional) {
47292           result.provisional = true;
47293         }
47294         detected = detected.filter(applySeverityOverrides);
47295         result.issues = result.issues.concat(detected);
47296         function applySeverityOverrides(issue) {
47297           const type2 = issue.type;
47298           const subtype = issue.subtype || "";
47299           let i3;
47300           for (i3 = 0; i3 < _errorOverrides.length; i3++) {
47301             if (_errorOverrides[i3].type.test(type2) && _errorOverrides[i3].subtype.test(subtype)) {
47302               issue.severity = "error";
47303               return true;
47304             }
47305           }
47306           for (i3 = 0; i3 < _warningOverrides.length; i3++) {
47307             if (_warningOverrides[i3].type.test(type2) && _warningOverrides[i3].subtype.test(subtype)) {
47308               issue.severity = "warning";
47309               return true;
47310             }
47311           }
47312           for (i3 = 0; i3 < _disableOverrides.length; i3++) {
47313             if (_disableOverrides[i3].type.test(type2) && _disableOverrides[i3].subtype.test(subtype)) {
47314               return false;
47315             }
47316           }
47317           return true;
47318         }
47319       }
47320     }
47321     function updateResolvedIssues(entityIDs) {
47322       entityIDs.forEach((entityID) => {
47323         const baseIssues = _baseCache.issuesByEntityID[entityID];
47324         if (!baseIssues)
47325           return;
47326         baseIssues.forEach((issueID) => {
47327           const issue = _baseCache.issuesByIssueID[issueID];
47328           const userModified = (issue.entityIds || []).some((id2) => _completeDiff.hasOwnProperty(id2));
47329           if (userModified && !_headCache.issuesByIssueID[issueID]) {
47330             _resolvedIssueIDs.add(issueID);
47331           } else {
47332             _resolvedIssueIDs.delete(issueID);
47333           }
47334         });
47335       });
47336     }
47337     function validateEntitiesAsync(entityIDs, cache) {
47338       const jobs = Array.from(entityIDs).map((entityID) => {
47339         if (cache.queuedEntityIDs.has(entityID))
47340           return null;
47341         cache.queuedEntityIDs.add(entityID);
47342         cache.uncacheEntityID(entityID);
47343         return () => {
47344           cache.queuedEntityIDs.delete(entityID);
47345           const graph = cache.graph;
47346           if (!graph)
47347             return;
47348           const entity = graph.hasEntity(entityID);
47349           if (!entity)
47350             return;
47351           const result = validateEntity(entity, graph);
47352           if (result.provisional) {
47353             cache.provisionalEntityIDs.add(entityID);
47354           }
47355           cache.cacheIssues(result.issues);
47356         };
47357       }).filter(Boolean);
47358       cache.queue = cache.queue.concat(utilArrayChunk(jobs, 100));
47359       if (cache.queuePromise)
47360         return cache.queuePromise;
47361       cache.queuePromise = processQueue(cache).then(() => revalidateProvisionalEntities(cache)).catch(() => {
47362       }).finally(() => cache.queuePromise = null);
47363       return cache.queuePromise;
47364     }
47365     function revalidateProvisionalEntities(cache) {
47366       if (!cache.provisionalEntityIDs.size)
47367         return;
47368       const handle = window.setTimeout(() => {
47369         _deferredST.delete(handle);
47370         if (!cache.provisionalEntityIDs.size)
47371           return;
47372         validateEntitiesAsync(Array.from(cache.provisionalEntityIDs), cache);
47373       }, RETRY);
47374       _deferredST.add(handle);
47375     }
47376     function processQueue(cache) {
47377       if (!cache.queue.length)
47378         return Promise.resolve();
47379       const chunk = cache.queue.pop();
47380       return new Promise((resolvePromise, rejectPromise) => {
47381         const handle = window.requestIdleCallback(() => {
47382           delete _deferredRIC[handle];
47383           chunk.forEach((job) => job());
47384           resolvePromise();
47385         });
47386         _deferredRIC[handle] = rejectPromise;
47387       }).then(() => {
47388         if (cache.queue.length % 25 === 0)
47389           dispatch14.call("validated");
47390       }).then(() => processQueue(cache));
47391     }
47392     return validator;
47393   }
47394   function validationCache(which) {
47395     let cache = {
47396       which,
47397       graph: null,
47398       queue: [],
47399       queuePromise: null,
47400       queuedEntityIDs: /* @__PURE__ */ new Set(),
47401       provisionalEntityIDs: /* @__PURE__ */ new Set(),
47402       issuesByIssueID: {},
47403       // issue.id -> issue
47404       issuesByEntityID: {}
47405       // entity.id -> Set(issue.id)
47406     };
47407     cache.cacheIssue = (issue) => {
47408       (issue.entityIds || []).forEach((entityID) => {
47409         if (!cache.issuesByEntityID[entityID]) {
47410           cache.issuesByEntityID[entityID] = /* @__PURE__ */ new Set();
47411         }
47412         cache.issuesByEntityID[entityID].add(issue.id);
47413       });
47414       cache.issuesByIssueID[issue.id] = issue;
47415     };
47416     cache.uncacheIssue = (issue) => {
47417       (issue.entityIds || []).forEach((entityID) => {
47418         if (cache.issuesByEntityID[entityID]) {
47419           cache.issuesByEntityID[entityID].delete(issue.id);
47420         }
47421       });
47422       delete cache.issuesByIssueID[issue.id];
47423     };
47424     cache.cacheIssues = (issues) => {
47425       issues.forEach(cache.cacheIssue);
47426     };
47427     cache.uncacheIssues = (issues) => {
47428       issues.forEach(cache.uncacheIssue);
47429     };
47430     cache.uncacheIssuesOfType = (type2) => {
47431       const issuesOfType = Object.values(cache.issuesByIssueID).filter((issue) => issue.type === type2);
47432       cache.uncacheIssues(issuesOfType);
47433     };
47434     cache.uncacheEntityID = (entityID) => {
47435       const entityIssueIDs = cache.issuesByEntityID[entityID];
47436       if (entityIssueIDs) {
47437         entityIssueIDs.forEach((issueID) => {
47438           const issue = cache.issuesByIssueID[issueID];
47439           if (issue) {
47440             cache.uncacheIssue(issue);
47441           } else {
47442             delete cache.issuesByIssueID[issueID];
47443           }
47444         });
47445       }
47446       delete cache.issuesByEntityID[entityID];
47447       cache.provisionalEntityIDs.delete(entityID);
47448     };
47449     cache.withAllRelatedEntities = (entityIDs) => {
47450       let result = /* @__PURE__ */ new Set();
47451       (entityIDs || []).forEach((entityID) => {
47452         result.add(entityID);
47453         const entityIssueIDs = cache.issuesByEntityID[entityID];
47454         if (entityIssueIDs) {
47455           entityIssueIDs.forEach((issueID) => {
47456             const issue = cache.issuesByIssueID[issueID];
47457             if (issue) {
47458               (issue.entityIds || []).forEach((relatedID) => result.add(relatedID));
47459             } else {
47460               delete cache.issuesByIssueID[issueID];
47461             }
47462           });
47463         }
47464       });
47465       return result;
47466     };
47467     return cache;
47468   }
47469
47470   // modules/core/uploader.js
47471   function coreUploader(context) {
47472     var dispatch14 = dispatch_default(
47473       // Start and end events are dispatched exactly once each per legitimate outside call to `save`
47474       "saveStarted",
47475       // dispatched as soon as a call to `save` has been deemed legitimate
47476       "saveEnded",
47477       // dispatched after the result event has been dispatched
47478       "willAttemptUpload",
47479       // dispatched before the actual upload call occurs, if it will
47480       "progressChanged",
47481       // Each save results in one of these outcomes:
47482       "resultNoChanges",
47483       // upload wasn't attempted since there were no edits
47484       "resultErrors",
47485       // upload failed due to errors
47486       "resultConflicts",
47487       // upload failed due to data conflicts
47488       "resultSuccess"
47489       // upload completed without errors
47490     );
47491     var _isSaving = false;
47492     var _conflicts = [];
47493     var _errors = [];
47494     var _origChanges;
47495     var _discardTags = {};
47496     _mainFileFetcher.get("discarded").then(function(d2) {
47497       _discardTags = d2;
47498     }).catch(function() {
47499     });
47500     var uploader = utilRebind({}, dispatch14, "on");
47501     uploader.isSaving = function() {
47502       return _isSaving;
47503     };
47504     uploader.save = function(changeset, tryAgain, checkConflicts) {
47505       if (_isSaving && !tryAgain) {
47506         return;
47507       }
47508       var osm = context.connection();
47509       if (!osm)
47510         return;
47511       if (!osm.authenticated()) {
47512         osm.authenticate(function(err) {
47513           if (!err) {
47514             uploader.save(changeset, tryAgain, checkConflicts);
47515           }
47516         });
47517         return;
47518       }
47519       if (!_isSaving) {
47520         _isSaving = true;
47521         dispatch14.call("saveStarted", this);
47522       }
47523       var history = context.history();
47524       _conflicts = [];
47525       _errors = [];
47526       _origChanges = history.changes(actionDiscardTags(history.difference(), _discardTags));
47527       if (!tryAgain) {
47528         history.perform(actionNoop());
47529       }
47530       if (!checkConflicts) {
47531         upload(changeset);
47532       } else {
47533         performFullConflictCheck(changeset);
47534       }
47535     };
47536     function performFullConflictCheck(changeset) {
47537       var osm = context.connection();
47538       if (!osm)
47539         return;
47540       var history = context.history();
47541       var localGraph = context.graph();
47542       var remoteGraph = coreGraph(history.base(), true);
47543       var summary = history.difference().summary();
47544       var _toCheck = [];
47545       for (var i3 = 0; i3 < summary.length; i3++) {
47546         var item = summary[i3];
47547         if (item.changeType === "modified") {
47548           _toCheck.push(item.entity.id);
47549         }
47550       }
47551       var _toLoad = withChildNodes(_toCheck, localGraph);
47552       var _loaded = {};
47553       var _toLoadCount = 0;
47554       var _toLoadTotal = _toLoad.length;
47555       if (_toCheck.length) {
47556         dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
47557         _toLoad.forEach(function(id2) {
47558           _loaded[id2] = false;
47559         });
47560         osm.loadMultiple(_toLoad, loaded);
47561       } else {
47562         upload(changeset);
47563       }
47564       return;
47565       function withChildNodes(ids, graph) {
47566         var s2 = new Set(ids);
47567         ids.forEach(function(id2) {
47568           var entity = graph.entity(id2);
47569           if (entity.type !== "way")
47570             return;
47571           graph.childNodes(entity).forEach(function(child) {
47572             if (child.version !== void 0) {
47573               s2.add(child.id);
47574             }
47575           });
47576         });
47577         return Array.from(s2);
47578       }
47579       function loaded(err, result) {
47580         if (_errors.length)
47581           return;
47582         if (err) {
47583           _errors.push({
47584             msg: err.message || err.responseText,
47585             details: [_t("save.status_code", { code: err.status })]
47586           });
47587           didResultInErrors();
47588         } else {
47589           var loadMore = [];
47590           result.data.forEach(function(entity) {
47591             remoteGraph.replace(entity);
47592             _loaded[entity.id] = true;
47593             _toLoad = _toLoad.filter(function(val) {
47594               return val !== entity.id;
47595             });
47596             if (!entity.visible)
47597               return;
47598             var i4, id2;
47599             if (entity.type === "way") {
47600               for (i4 = 0; i4 < entity.nodes.length; i4++) {
47601                 id2 = entity.nodes[i4];
47602                 if (_loaded[id2] === void 0) {
47603                   _loaded[id2] = false;
47604                   loadMore.push(id2);
47605                 }
47606               }
47607             } else if (entity.type === "relation" && entity.isMultipolygon()) {
47608               for (i4 = 0; i4 < entity.members.length; i4++) {
47609                 id2 = entity.members[i4].id;
47610                 if (_loaded[id2] === void 0) {
47611                   _loaded[id2] = false;
47612                   loadMore.push(id2);
47613                 }
47614               }
47615             }
47616           });
47617           _toLoadCount += result.data.length;
47618           _toLoadTotal += loadMore.length;
47619           dispatch14.call("progressChanged", this, _toLoadCount, _toLoadTotal);
47620           if (loadMore.length) {
47621             _toLoad.push.apply(_toLoad, loadMore);
47622             osm.loadMultiple(loadMore, loaded);
47623           }
47624           if (!_toLoad.length) {
47625             detectConflicts();
47626             upload(changeset);
47627           }
47628         }
47629       }
47630       function detectConflicts() {
47631         function choice(id2, text, action) {
47632           return {
47633             id: id2,
47634             text,
47635             action: function() {
47636               history.replace(action);
47637             }
47638           };
47639         }
47640         function formatUser(d2) {
47641           return '<a href="' + osm.userURL(d2) + '" target="_blank">' + escape_default(d2) + "</a>";
47642         }
47643         function entityName(entity) {
47644           return utilDisplayName(entity) || utilDisplayType(entity.id) + " " + entity.id;
47645         }
47646         function sameVersions(local, remote) {
47647           if (local.version !== remote.version)
47648             return false;
47649           if (local.type === "way") {
47650             var children2 = utilArrayUnion(local.nodes, remote.nodes);
47651             for (var i4 = 0; i4 < children2.length; i4++) {
47652               var a2 = localGraph.hasEntity(children2[i4]);
47653               var b2 = remoteGraph.hasEntity(children2[i4]);
47654               if (a2 && b2 && a2.version !== b2.version)
47655                 return false;
47656             }
47657           }
47658           return true;
47659         }
47660         _toCheck.forEach(function(id2) {
47661           var local = localGraph.entity(id2);
47662           var remote = remoteGraph.entity(id2);
47663           if (sameVersions(local, remote))
47664             return;
47665           var merge2 = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags, formatUser);
47666           history.replace(merge2);
47667           var mergeConflicts = merge2.conflicts();
47668           if (!mergeConflicts.length)
47669             return;
47670           var forceLocal = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_local");
47671           var forceRemote = actionMergeRemoteChanges(id2, localGraph, remoteGraph, _discardTags).withOption("force_remote");
47672           var keepMine = _t("save.conflict." + (remote.visible ? "keep_local" : "restore"));
47673           var keepTheirs = _t("save.conflict." + (remote.visible ? "keep_remote" : "delete"));
47674           _conflicts.push({
47675             id: id2,
47676             name: entityName(local),
47677             details: mergeConflicts,
47678             chosen: 1,
47679             choices: [
47680               choice(id2, keepMine, forceLocal),
47681               choice(id2, keepTheirs, forceRemote)
47682             ]
47683           });
47684         });
47685       }
47686     }
47687     function upload(changeset) {
47688       var osm = context.connection();
47689       if (!osm) {
47690         _errors.push({ msg: "No OSM Service" });
47691       }
47692       if (_conflicts.length) {
47693         didResultInConflicts(changeset);
47694       } else if (_errors.length) {
47695         didResultInErrors();
47696       } else {
47697         var history = context.history();
47698         var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
47699         if (changes.modified.length || changes.created.length || changes.deleted.length) {
47700           dispatch14.call("willAttemptUpload", this);
47701           osm.putChangeset(changeset, changes, uploadCallback);
47702         } else {
47703           didResultInNoChanges();
47704         }
47705       }
47706     }
47707     function uploadCallback(err, changeset) {
47708       if (err) {
47709         if (err.status === 409) {
47710           uploader.save(changeset, true, true);
47711         } else {
47712           _errors.push({
47713             msg: err.message || err.responseText,
47714             details: [_t("save.status_code", { code: err.status })]
47715           });
47716           didResultInErrors();
47717         }
47718       } else {
47719         didResultInSuccess(changeset);
47720       }
47721     }
47722     function didResultInNoChanges() {
47723       dispatch14.call("resultNoChanges", this);
47724       endSave();
47725       context.flush();
47726     }
47727     function didResultInErrors() {
47728       context.history().pop();
47729       dispatch14.call("resultErrors", this, _errors);
47730       endSave();
47731     }
47732     function didResultInConflicts(changeset) {
47733       _conflicts.sort(function(a2, b2) {
47734         return b2.id.localeCompare(a2.id);
47735       });
47736       dispatch14.call("resultConflicts", this, changeset, _conflicts, _origChanges);
47737       endSave();
47738     }
47739     function didResultInSuccess(changeset) {
47740       context.history().clearSaved();
47741       dispatch14.call("resultSuccess", this, changeset);
47742       window.setTimeout(function() {
47743         endSave();
47744         context.flush();
47745       }, 2500);
47746     }
47747     function endSave() {
47748       _isSaving = false;
47749       dispatch14.call("saveEnded", this);
47750     }
47751     uploader.cancelConflictResolution = function() {
47752       context.history().pop();
47753     };
47754     uploader.processResolvedConflicts = function(changeset) {
47755       var history = context.history();
47756       for (var i3 = 0; i3 < _conflicts.length; i3++) {
47757         if (_conflicts[i3].chosen === 1) {
47758           var entity = context.hasEntity(_conflicts[i3].id);
47759           if (entity && entity.type === "way") {
47760             var children2 = utilArrayUniq(entity.nodes);
47761             for (var j2 = 0; j2 < children2.length; j2++) {
47762               history.replace(actionRevert(children2[j2]));
47763             }
47764           }
47765           history.replace(actionRevert(_conflicts[i3].id));
47766         }
47767       }
47768       uploader.save(changeset, true, false);
47769     };
47770     uploader.reset = function() {
47771     };
47772     return uploader;
47773   }
47774
47775   // modules/renderer/background_source.js
47776   var import_lodash4 = __toESM(require_lodash());
47777
47778   // modules/util/IntervalTasksQueue.js
47779   var IntervalTasksQueue = class {
47780     /**
47781      * Interval in milliseconds inside which only 1 task can execute.
47782      * e.g. if interval is 200ms, and 5 async tasks are unqueued,
47783      * they will complete in ~1s if not cleared
47784      * @param {number} intervalInMs
47785      */
47786     constructor(intervalInMs) {
47787       this.intervalInMs = intervalInMs;
47788       this.pendingHandles = [];
47789       this.time = 0;
47790     }
47791     enqueue(task) {
47792       let taskTimeout = this.time;
47793       this.time += this.intervalInMs;
47794       this.pendingHandles.push(setTimeout(() => {
47795         this.time -= this.intervalInMs;
47796         task();
47797       }, taskTimeout));
47798     }
47799     clear() {
47800       this.pendingHandles.forEach((timeoutHandle) => {
47801         clearTimeout(timeoutHandle);
47802       });
47803       this.pendingHandles = [];
47804       this.time = 0;
47805     }
47806   };
47807
47808   // modules/renderer/background_source.js
47809   var isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
47810   window.matchMedia("\n        (-webkit-min-device-pixel-ratio: 2), /* Safari */\n        (min-resolution: 2dppx),             /* standard */\n        (min-resolution: 192dpi)             /* fallback */\n    ").addListener(function() {
47811     isRetina = window.devicePixelRatio && window.devicePixelRatio >= 2;
47812   });
47813   function localeDateString(s2) {
47814     if (!s2)
47815       return null;
47816     var options2 = { day: "numeric", month: "short", year: "numeric" };
47817     var d2 = new Date(s2);
47818     if (isNaN(d2.getTime()))
47819       return null;
47820     return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
47821   }
47822   function vintageRange(vintage) {
47823     var s2;
47824     if (vintage.start || vintage.end) {
47825       s2 = vintage.start || "?";
47826       if (vintage.start !== vintage.end) {
47827         s2 += " - " + (vintage.end || "?");
47828       }
47829     }
47830     return s2;
47831   }
47832   function rendererBackgroundSource(data) {
47833     var source = Object.assign({}, data);
47834     var _offset = [0, 0];
47835     var _name = source.name;
47836     var _description = source.description;
47837     var _best = !!source.best;
47838     var _template = source.encrypted ? utilAesDecrypt(source.template) : source.template;
47839     source.tileSize = data.tileSize || 256;
47840     source.zoomExtent = data.zoomExtent || [0, 22];
47841     source.overzoom = data.overzoom !== false;
47842     source.offset = function(val) {
47843       if (!arguments.length)
47844         return _offset;
47845       _offset = val;
47846       return source;
47847     };
47848     source.nudge = function(val, zoomlevel) {
47849       _offset[0] += val[0] / Math.pow(2, zoomlevel);
47850       _offset[1] += val[1] / Math.pow(2, zoomlevel);
47851       return source;
47852     };
47853     source.name = function() {
47854       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47855       return _t("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
47856     };
47857     source.label = function() {
47858       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47859       return _t.append("imagery." + id_safe + ".name", { default: (0, import_lodash4.escape)(_name) });
47860     };
47861     source.hasDescription = function() {
47862       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47863       var descriptionText = _mainLocalizer.tInfo("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) }).text;
47864       return descriptionText !== "";
47865     };
47866     source.description = function() {
47867       var id_safe = source.id.replace(/\./g, "<TX_DOT>");
47868       return _t.append("imagery." + id_safe + ".description", { default: (0, import_lodash4.escape)(_description) });
47869     };
47870     source.best = function() {
47871       return _best;
47872     };
47873     source.area = function() {
47874       if (!data.polygon)
47875         return Number.MAX_VALUE;
47876       var area = area_default({ type: "MultiPolygon", coordinates: [data.polygon] });
47877       return isNaN(area) ? 0 : area;
47878     };
47879     source.imageryUsed = function() {
47880       return _name || source.id;
47881     };
47882     source.template = function(val) {
47883       if (!arguments.length)
47884         return _template;
47885       if (source.id === "custom" || source.id === "Bing") {
47886         _template = val;
47887       }
47888       return source;
47889     };
47890     source.url = function(coord2) {
47891       var result = _template.replace(/#[\s\S]*/u, "");
47892       if (result === "")
47893         return result;
47894       if (!source.type || source.id === "custom") {
47895         if (/SERVICE=WMS|\{(proj|wkid|bbox)\}/.test(result)) {
47896           source.type = "wms";
47897           source.projection = "EPSG:3857";
47898         } else if (/\{(x|y)\}/.test(result)) {
47899           source.type = "tms";
47900         } else if (/\{u\}/.test(result)) {
47901           source.type = "bing";
47902         }
47903       }
47904       if (source.type === "wms") {
47905         var tileToProjectedCoords = function(x2, y2, z2) {
47906           var zoomSize = Math.pow(2, z2);
47907           var lon = x2 / zoomSize * Math.PI * 2 - Math.PI;
47908           var lat = Math.atan(Math.sinh(Math.PI * (1 - 2 * y2 / zoomSize)));
47909           switch (source.projection) {
47910             case "EPSG:4326":
47911               return {
47912                 x: lon * 180 / Math.PI,
47913                 y: lat * 180 / Math.PI
47914               };
47915             default:
47916               var mercCoords = mercatorRaw(lon, lat);
47917               return {
47918                 x: 2003750834e-2 / Math.PI * mercCoords[0],
47919                 y: 2003750834e-2 / Math.PI * mercCoords[1]
47920               };
47921           }
47922         };
47923         var tileSize = source.tileSize;
47924         var projection2 = source.projection;
47925         var minXmaxY = tileToProjectedCoords(coord2[0], coord2[1], coord2[2]);
47926         var maxXminY = tileToProjectedCoords(coord2[0] + 1, coord2[1] + 1, coord2[2]);
47927         result = result.replace(/\{(\w+)\}/g, function(token, key) {
47928           switch (key) {
47929             case "width":
47930             case "height":
47931               return tileSize;
47932             case "proj":
47933               return projection2;
47934             case "wkid":
47935               return projection2.replace(/^EPSG:/, "");
47936             case "bbox":
47937               if (projection2 === "EPSG:4326" && // The CRS parameter implies version 1.3 (prior versions use SRS)
47938               /VERSION=1.3|CRS={proj}/.test(source.template().toUpperCase())) {
47939                 return maxXminY.y + "," + minXmaxY.x + "," + minXmaxY.y + "," + maxXminY.x;
47940               } else {
47941                 return minXmaxY.x + "," + maxXminY.y + "," + maxXminY.x + "," + minXmaxY.y;
47942               }
47943             case "w":
47944               return minXmaxY.x;
47945             case "s":
47946               return maxXminY.y;
47947             case "n":
47948               return maxXminY.x;
47949             case "e":
47950               return minXmaxY.y;
47951             default:
47952               return token;
47953           }
47954         });
47955       } else if (source.type === "tms") {
47956         result = result.replace("{x}", coord2[0]).replace("{y}", coord2[1]).replace(/\{[t-]y\}/, Math.pow(2, coord2[2]) - coord2[1] - 1).replace(/\{z(oom)?\}/, coord2[2]).replace(/\{@2x\}|\{r\}/, isRetina ? "@2x" : "");
47957       } else if (source.type === "bing") {
47958         result = result.replace("{u}", function() {
47959           var u2 = "";
47960           for (var zoom = coord2[2]; zoom > 0; zoom--) {
47961             var b2 = 0;
47962             var mask = 1 << zoom - 1;
47963             if ((coord2[0] & mask) !== 0)
47964               b2++;
47965             if ((coord2[1] & mask) !== 0)
47966               b2 += 2;
47967             u2 += b2.toString();
47968           }
47969           return u2;
47970         });
47971       }
47972       result = result.replace(/\{switch:([^}]+)\}/, function(s2, r2) {
47973         var subdomains = r2.split(",");
47974         return subdomains[(coord2[0] + coord2[1]) % subdomains.length];
47975       });
47976       return result;
47977     };
47978     source.validZoom = function(z2) {
47979       return source.zoomExtent[0] <= z2 && (source.overzoom || source.zoomExtent[1] > z2);
47980     };
47981     source.isLocatorOverlay = function() {
47982       return source.id === "mapbox_locator_overlay";
47983     };
47984     source.isHidden = function() {
47985       return source.id === "DigitalGlobe-Premium-vintage" || source.id === "DigitalGlobe-Standard-vintage";
47986     };
47987     source.copyrightNotices = function() {
47988     };
47989     source.getMetadata = function(center, tileCoord, callback) {
47990       var vintage = {
47991         start: localeDateString(source.startDate),
47992         end: localeDateString(source.endDate)
47993       };
47994       vintage.range = vintageRange(vintage);
47995       var metadata = { vintage };
47996       callback(null, metadata);
47997     };
47998     return source;
47999   }
48000   rendererBackgroundSource.Bing = function(data, dispatch14) {
48001     data.template = "https://ecn.t{switch:0,1,2,3}.tiles.virtualearth.net/tiles/a{u}.jpeg?g=1&pr=odbl&n=z";
48002     var bing = rendererBackgroundSource(data);
48003     var key = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
48004     const strictParam = "n";
48005     var url = "https://dev.virtualearth.net/REST/v1/Imagery/Metadata/AerialOSM?include=ImageryProviders&uriScheme=https&key=" + key;
48006     var cache = {};
48007     var inflight = {};
48008     var providers = [];
48009     var taskQueue = new IntervalTasksQueue(250);
48010     var metadataLastZoom = -1;
48011     json_default(url).then(function(json) {
48012       let imageryResource = json.resourceSets[0].resources[0];
48013       let template = imageryResource.imageUrl;
48014       let subDomains = imageryResource.imageUrlSubdomains;
48015       let subDomainNumbers = subDomains.map((subDomain) => {
48016         return subDomain.substring(1);
48017       }).join(",");
48018       template = template.replace("{subdomain}", "t{switch:".concat(subDomainNumbers, "}")).replace("{quadkey}", "{u}");
48019       if (!new URLSearchParams(template).has(strictParam)) {
48020         template += "&".concat(strictParam, "=z");
48021       }
48022       bing.template(template);
48023       providers = imageryResource.imageryProviders.map(function(provider) {
48024         return {
48025           attribution: provider.attribution,
48026           areas: provider.coverageAreas.map(function(area) {
48027             return {
48028               zoom: [area.zoomMin, area.zoomMax],
48029               extent: geoExtent([area.bbox[1], area.bbox[0]], [area.bbox[3], area.bbox[2]])
48030             };
48031           })
48032         };
48033       });
48034       dispatch14.call("change");
48035     }).catch(function() {
48036     });
48037     bing.copyrightNotices = function(zoom, extent) {
48038       zoom = Math.min(zoom, 21);
48039       return providers.filter(function(provider) {
48040         return provider.areas.some(function(area) {
48041           return extent.intersects(area.extent) && area.zoom[0] <= zoom && area.zoom[1] >= zoom;
48042         });
48043       }).map(function(provider) {
48044         return provider.attribution;
48045       }).join(", ");
48046     };
48047     bing.getMetadata = function(center, tileCoord, callback) {
48048       var tileID = tileCoord.slice(0, 3).join("/");
48049       var zoom = Math.min(tileCoord[2], 21);
48050       var centerPoint = center[1] + "," + center[0];
48051       var url2 = "https://dev.virtualearth.net/REST/v1/Imagery/BasicMetadata/AerialOSM/" + centerPoint + "?zl=" + zoom + "&key=" + key;
48052       if (inflight[tileID])
48053         return;
48054       if (!cache[tileID]) {
48055         cache[tileID] = {};
48056       }
48057       if (cache[tileID] && cache[tileID].metadata) {
48058         return callback(null, cache[tileID].metadata);
48059       }
48060       inflight[tileID] = true;
48061       if (metadataLastZoom !== tileCoord[2]) {
48062         metadataLastZoom = tileCoord[2];
48063         taskQueue.clear();
48064       }
48065       taskQueue.enqueue(() => {
48066         json_default(url2).then(function(result) {
48067           delete inflight[tileID];
48068           if (!result) {
48069             throw new Error("Unknown Error");
48070           }
48071           var vintage = {
48072             start: localeDateString(result.resourceSets[0].resources[0].vintageStart),
48073             end: localeDateString(result.resourceSets[0].resources[0].vintageEnd)
48074           };
48075           vintage.range = vintageRange(vintage);
48076           var metadata = { vintage };
48077           cache[tileID].metadata = metadata;
48078           if (callback)
48079             callback(null, metadata);
48080         }).catch(function(err) {
48081           delete inflight[tileID];
48082           if (callback)
48083             callback(err.message);
48084         });
48085       });
48086     };
48087     bing.terms_url = "https://blog.openstreetmap.org/2010/11/30/microsoft-imagery-details";
48088     return bing;
48089   };
48090   rendererBackgroundSource.Esri = function(data) {
48091     if (data.template.match(/blankTile/) === null) {
48092       data.template = data.template + "?blankTile=false";
48093     }
48094     var esri = rendererBackgroundSource(data);
48095     var cache = {};
48096     var inflight = {};
48097     var _prevCenter;
48098     esri.fetchTilemap = function(center) {
48099       if (_prevCenter && geoSphericalDistance(center, _prevCenter) < 5e3)
48100         return;
48101       _prevCenter = center;
48102       var z2 = 20;
48103       var dummyUrl = esri.url([1, 2, 3]);
48104       var x2 = Math.floor((center[0] + 180) / 360 * Math.pow(2, z2));
48105       var y2 = Math.floor((1 - Math.log(Math.tan(center[1] * Math.PI / 180) + 1 / Math.cos(center[1] * Math.PI / 180)) / Math.PI) / 2 * Math.pow(2, z2));
48106       var tilemapUrl = dummyUrl.replace(/tile\/[0-9]+\/[0-9]+\/[0-9]+\?blankTile=false/, "tilemap") + "/" + z2 + "/" + y2 + "/" + x2 + "/8/8";
48107       json_default(tilemapUrl).then(function(tilemap) {
48108         if (!tilemap) {
48109           throw new Error("Unknown Error");
48110         }
48111         var hasTiles = true;
48112         for (var i3 = 0; i3 < tilemap.data.length; i3++) {
48113           if (!tilemap.data[i3]) {
48114             hasTiles = false;
48115             break;
48116           }
48117         }
48118         esri.zoomExtent[1] = hasTiles ? 22 : 19;
48119       }).catch(function() {
48120       });
48121     };
48122     esri.getMetadata = function(center, tileCoord, callback) {
48123       if (esri.id !== "EsriWorldImagery") {
48124         return callback(null, {});
48125       }
48126       var tileID = tileCoord.slice(0, 3).join("/");
48127       var zoom = Math.min(tileCoord[2], esri.zoomExtent[1]);
48128       var centerPoint = center[0] + "," + center[1];
48129       var unknown = _t("info_panels.background.unknown");
48130       var vintage = {};
48131       var metadata = {};
48132       if (inflight[tileID])
48133         return;
48134       var url = "https://services.arcgisonline.com/arcgis/rest/services/World_Imagery/MapServer/4/query";
48135       url += "?returnGeometry=false&geometry=" + centerPoint + "&inSR=4326&geometryType=esriGeometryPoint&outFields=*&f=json";
48136       if (!cache[tileID]) {
48137         cache[tileID] = {};
48138       }
48139       if (cache[tileID] && cache[tileID].metadata) {
48140         return callback(null, cache[tileID].metadata);
48141       }
48142       inflight[tileID] = true;
48143       json_default(url).then(function(result) {
48144         delete inflight[tileID];
48145         result = result.features.map((f2) => f2.attributes).filter((a2) => a2.MinMapLevel <= zoom && a2.MaxMapLevel >= zoom)[0];
48146         if (!result) {
48147           throw new Error("Unknown Error");
48148         } else if (result.features && result.features.length < 1) {
48149           throw new Error("No Results");
48150         } else if (result.error && result.error.message) {
48151           throw new Error(result.error.message);
48152         }
48153         var captureDate = localeDateString(result.SRC_DATE2);
48154         vintage = {
48155           start: captureDate,
48156           end: captureDate,
48157           range: captureDate
48158         };
48159         metadata = {
48160           vintage,
48161           source: clean2(result.NICE_NAME),
48162           description: clean2(result.NICE_DESC),
48163           resolution: clean2(+Number(result.SRC_RES).toFixed(4)),
48164           accuracy: clean2(+Number(result.SRC_ACC).toFixed(4))
48165         };
48166         if (isFinite(metadata.resolution)) {
48167           metadata.resolution += " m";
48168         }
48169         if (isFinite(metadata.accuracy)) {
48170           metadata.accuracy += " m";
48171         }
48172         cache[tileID].metadata = metadata;
48173         if (callback)
48174           callback(null, metadata);
48175       }).catch(function(err) {
48176         delete inflight[tileID];
48177         if (callback)
48178           callback(err.message);
48179       });
48180       function clean2(val) {
48181         return String(val).trim() || unknown;
48182       }
48183     };
48184     return esri;
48185   };
48186   rendererBackgroundSource.None = function() {
48187     var source = rendererBackgroundSource({ id: "none", template: "" });
48188     source.name = function() {
48189       return _t("background.none");
48190     };
48191     source.label = function() {
48192       return _t.append("background.none");
48193     };
48194     source.imageryUsed = function() {
48195       return null;
48196     };
48197     source.area = function() {
48198       return -1;
48199     };
48200     return source;
48201   };
48202   rendererBackgroundSource.Custom = function(template) {
48203     var source = rendererBackgroundSource({ id: "custom", template });
48204     source.name = function() {
48205       return _t("background.custom");
48206     };
48207     source.label = function() {
48208       return _t.append("background.custom");
48209     };
48210     source.imageryUsed = function() {
48211       var cleaned = source.template();
48212       if (cleaned.indexOf("?") !== -1) {
48213         var parts = cleaned.split("?", 2);
48214         var qs = utilStringQs(parts[1]);
48215         ["access_token", "connectId", "token", "Signature"].forEach(function(param) {
48216           if (qs[param]) {
48217             qs[param] = "{apikey}";
48218           }
48219         });
48220         cleaned = parts[0] + "?" + utilQsString(qs, true);
48221       }
48222       cleaned = cleaned.replace(/token\/(\w+)/, "token/{apikey}").replace(/key=(\w+)/, "key={apikey}");
48223       return "Custom (" + cleaned + " )";
48224     };
48225     source.area = function() {
48226       return -2;
48227     };
48228     return source;
48229   };
48230
48231   // node_modules/@turf/helpers/dist/es/index.js
48232   var earthRadius = 63710088e-1;
48233   var factors = {
48234     centimeters: earthRadius * 100,
48235     centimetres: earthRadius * 100,
48236     degrees: earthRadius / 111325,
48237     feet: earthRadius * 3.28084,
48238     inches: earthRadius * 39.37,
48239     kilometers: earthRadius / 1e3,
48240     kilometres: earthRadius / 1e3,
48241     meters: earthRadius,
48242     metres: earthRadius,
48243     miles: earthRadius / 1609.344,
48244     millimeters: earthRadius * 1e3,
48245     millimetres: earthRadius * 1e3,
48246     nauticalmiles: earthRadius / 1852,
48247     radians: 1,
48248     yards: earthRadius * 1.0936
48249   };
48250   var unitsFactors = {
48251     centimeters: 100,
48252     centimetres: 100,
48253     degrees: 1 / 111325,
48254     feet: 3.28084,
48255     inches: 39.37,
48256     kilometers: 1 / 1e3,
48257     kilometres: 1 / 1e3,
48258     meters: 1,
48259     metres: 1,
48260     miles: 1 / 1609.344,
48261     millimeters: 1e3,
48262     millimetres: 1e3,
48263     nauticalmiles: 1 / 1852,
48264     radians: 1 / earthRadius,
48265     yards: 1.0936133
48266   };
48267   function feature2(geom, properties, options2) {
48268     if (options2 === void 0) {
48269       options2 = {};
48270     }
48271     var feat = { type: "Feature" };
48272     if (options2.id === 0 || options2.id) {
48273       feat.id = options2.id;
48274     }
48275     if (options2.bbox) {
48276       feat.bbox = options2.bbox;
48277     }
48278     feat.properties = properties || {};
48279     feat.geometry = geom;
48280     return feat;
48281   }
48282   function polygon(coordinates, properties, options2) {
48283     if (options2 === void 0) {
48284       options2 = {};
48285     }
48286     for (var _i = 0, coordinates_1 = coordinates; _i < coordinates_1.length; _i++) {
48287       var ring = coordinates_1[_i];
48288       if (ring.length < 4) {
48289         throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");
48290       }
48291       for (var j2 = 0; j2 < ring[ring.length - 1].length; j2++) {
48292         if (ring[ring.length - 1][j2] !== ring[0][j2]) {
48293           throw new Error("First and last Position are not equivalent.");
48294         }
48295       }
48296     }
48297     var geom = {
48298       type: "Polygon",
48299       coordinates
48300     };
48301     return feature2(geom, properties, options2);
48302   }
48303   function lineString(coordinates, properties, options2) {
48304     if (options2 === void 0) {
48305       options2 = {};
48306     }
48307     if (coordinates.length < 2) {
48308       throw new Error("coordinates must be an array of two or more positions");
48309     }
48310     var geom = {
48311       type: "LineString",
48312       coordinates
48313     };
48314     return feature2(geom, properties, options2);
48315   }
48316   function multiLineString(coordinates, properties, options2) {
48317     if (options2 === void 0) {
48318       options2 = {};
48319     }
48320     var geom = {
48321       type: "MultiLineString",
48322       coordinates
48323     };
48324     return feature2(geom, properties, options2);
48325   }
48326   function multiPolygon(coordinates, properties, options2) {
48327     if (options2 === void 0) {
48328       options2 = {};
48329     }
48330     var geom = {
48331       type: "MultiPolygon",
48332       coordinates
48333     };
48334     return feature2(geom, properties, options2);
48335   }
48336
48337   // node_modules/@turf/invariant/dist/es/index.js
48338   function getGeom(geojson) {
48339     if (geojson.type === "Feature") {
48340       return geojson.geometry;
48341     }
48342     return geojson;
48343   }
48344
48345   // node_modules/@turf/bbox-clip/dist/es/lib/lineclip.js
48346   function lineclip(points, bbox2, result) {
48347     var len = points.length, codeA = bitCode(points[0], bbox2), part = [], i3, codeB, lastCode;
48348     var a2;
48349     var b2;
48350     if (!result)
48351       result = [];
48352     for (i3 = 1; i3 < len; i3++) {
48353       a2 = points[i3 - 1];
48354       b2 = points[i3];
48355       codeB = lastCode = bitCode(b2, bbox2);
48356       while (true) {
48357         if (!(codeA | codeB)) {
48358           part.push(a2);
48359           if (codeB !== lastCode) {
48360             part.push(b2);
48361             if (i3 < len - 1) {
48362               result.push(part);
48363               part = [];
48364             }
48365           } else if (i3 === len - 1) {
48366             part.push(b2);
48367           }
48368           break;
48369         } else if (codeA & codeB) {
48370           break;
48371         } else if (codeA) {
48372           a2 = intersect(a2, b2, codeA, bbox2);
48373           codeA = bitCode(a2, bbox2);
48374         } else {
48375           b2 = intersect(a2, b2, codeB, bbox2);
48376           codeB = bitCode(b2, bbox2);
48377         }
48378       }
48379       codeA = lastCode;
48380     }
48381     if (part.length)
48382       result.push(part);
48383     return result;
48384   }
48385   function polygonclip(points, bbox2) {
48386     var result, edge, prev, prevInside, i3, p2, inside;
48387     for (edge = 1; edge <= 8; edge *= 2) {
48388       result = [];
48389       prev = points[points.length - 1];
48390       prevInside = !(bitCode(prev, bbox2) & edge);
48391       for (i3 = 0; i3 < points.length; i3++) {
48392         p2 = points[i3];
48393         inside = !(bitCode(p2, bbox2) & edge);
48394         if (inside !== prevInside)
48395           result.push(intersect(prev, p2, edge, bbox2));
48396         if (inside)
48397           result.push(p2);
48398         prev = p2;
48399         prevInside = inside;
48400       }
48401       points = result;
48402       if (!points.length)
48403         break;
48404     }
48405     return result;
48406   }
48407   function intersect(a2, b2, edge, bbox2) {
48408     return edge & 8 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[3] - a2[1]) / (b2[1] - a2[1]), bbox2[3]] : edge & 4 ? [a2[0] + (b2[0] - a2[0]) * (bbox2[1] - a2[1]) / (b2[1] - a2[1]), bbox2[1]] : edge & 2 ? [bbox2[2], a2[1] + (b2[1] - a2[1]) * (bbox2[2] - a2[0]) / (b2[0] - a2[0])] : edge & 1 ? [bbox2[0], a2[1] + (b2[1] - a2[1]) * (bbox2[0] - a2[0]) / (b2[0] - a2[0])] : null;
48409   }
48410   function bitCode(p2, bbox2) {
48411     var code = 0;
48412     if (p2[0] < bbox2[0])
48413       code |= 1;
48414     else if (p2[0] > bbox2[2])
48415       code |= 2;
48416     if (p2[1] < bbox2[1])
48417       code |= 4;
48418     else if (p2[1] > bbox2[3])
48419       code |= 8;
48420     return code;
48421   }
48422
48423   // node_modules/@turf/bbox-clip/dist/es/index.js
48424   function bboxClip(feature3, bbox2) {
48425     var geom = getGeom(feature3);
48426     var type2 = geom.type;
48427     var properties = feature3.type === "Feature" ? feature3.properties : {};
48428     var coords = geom.coordinates;
48429     switch (type2) {
48430       case "LineString":
48431       case "MultiLineString": {
48432         var lines_1 = [];
48433         if (type2 === "LineString") {
48434           coords = [coords];
48435         }
48436         coords.forEach(function(line) {
48437           lineclip(line, bbox2, lines_1);
48438         });
48439         if (lines_1.length === 1) {
48440           return lineString(lines_1[0], properties);
48441         }
48442         return multiLineString(lines_1, properties);
48443       }
48444       case "Polygon":
48445         return polygon(clipPolygon(coords, bbox2), properties);
48446       case "MultiPolygon":
48447         return multiPolygon(coords.map(function(poly) {
48448           return clipPolygon(poly, bbox2);
48449         }), properties);
48450       default:
48451         throw new Error("geometry " + type2 + " not supported");
48452     }
48453   }
48454   function clipPolygon(rings, bbox2) {
48455     var outRings = [];
48456     for (var _i = 0, rings_1 = rings; _i < rings_1.length; _i++) {
48457       var ring = rings_1[_i];
48458       var clipped = polygonclip(ring, bbox2);
48459       if (clipped.length > 0) {
48460         if (clipped[0][0] !== clipped[clipped.length - 1][0] || clipped[0][1] !== clipped[clipped.length - 1][1]) {
48461           clipped.push(clipped[0]);
48462         }
48463         if (clipped.length >= 4) {
48464           outRings.push(clipped);
48465         }
48466       }
48467     }
48468     return outRings;
48469   }
48470
48471   // node_modules/@turf/meta/dist/es/index.js
48472   function coordEach(geojson, callback, excludeWrapCoord) {
48473     if (geojson === null)
48474       return;
48475     var j2, k2, l2, geometry, stopG, coords, geometryMaybeCollection, wrapShrink = 0, coordIndex = 0, isGeometryCollection, type2 = geojson.type, isFeatureCollection = type2 === "FeatureCollection", isFeature = type2 === "Feature", stop = isFeatureCollection ? geojson.features.length : 1;
48476     for (var featureIndex = 0; featureIndex < stop; featureIndex++) {
48477       geometryMaybeCollection = isFeatureCollection ? geojson.features[featureIndex].geometry : isFeature ? geojson.geometry : geojson;
48478       isGeometryCollection = geometryMaybeCollection ? geometryMaybeCollection.type === "GeometryCollection" : false;
48479       stopG = isGeometryCollection ? geometryMaybeCollection.geometries.length : 1;
48480       for (var geomIndex = 0; geomIndex < stopG; geomIndex++) {
48481         var multiFeatureIndex = 0;
48482         var geometryIndex = 0;
48483         geometry = isGeometryCollection ? geometryMaybeCollection.geometries[geomIndex] : geometryMaybeCollection;
48484         if (geometry === null)
48485           continue;
48486         coords = geometry.coordinates;
48487         var geomType = geometry.type;
48488         wrapShrink = excludeWrapCoord && (geomType === "Polygon" || geomType === "MultiPolygon") ? 1 : 0;
48489         switch (geomType) {
48490           case null:
48491             break;
48492           case "Point":
48493             if (callback(
48494               coords,
48495               coordIndex,
48496               featureIndex,
48497               multiFeatureIndex,
48498               geometryIndex
48499             ) === false)
48500               return false;
48501             coordIndex++;
48502             multiFeatureIndex++;
48503             break;
48504           case "LineString":
48505           case "MultiPoint":
48506             for (j2 = 0; j2 < coords.length; j2++) {
48507               if (callback(
48508                 coords[j2],
48509                 coordIndex,
48510                 featureIndex,
48511                 multiFeatureIndex,
48512                 geometryIndex
48513               ) === false)
48514                 return false;
48515               coordIndex++;
48516               if (geomType === "MultiPoint")
48517                 multiFeatureIndex++;
48518             }
48519             if (geomType === "LineString")
48520               multiFeatureIndex++;
48521             break;
48522           case "Polygon":
48523           case "MultiLineString":
48524             for (j2 = 0; j2 < coords.length; j2++) {
48525               for (k2 = 0; k2 < coords[j2].length - wrapShrink; k2++) {
48526                 if (callback(
48527                   coords[j2][k2],
48528                   coordIndex,
48529                   featureIndex,
48530                   multiFeatureIndex,
48531                   geometryIndex
48532                 ) === false)
48533                   return false;
48534                 coordIndex++;
48535               }
48536               if (geomType === "MultiLineString")
48537                 multiFeatureIndex++;
48538               if (geomType === "Polygon")
48539                 geometryIndex++;
48540             }
48541             if (geomType === "Polygon")
48542               multiFeatureIndex++;
48543             break;
48544           case "MultiPolygon":
48545             for (j2 = 0; j2 < coords.length; j2++) {
48546               geometryIndex = 0;
48547               for (k2 = 0; k2 < coords[j2].length; k2++) {
48548                 for (l2 = 0; l2 < coords[j2][k2].length - wrapShrink; l2++) {
48549                   if (callback(
48550                     coords[j2][k2][l2],
48551                     coordIndex,
48552                     featureIndex,
48553                     multiFeatureIndex,
48554                     geometryIndex
48555                   ) === false)
48556                     return false;
48557                   coordIndex++;
48558                 }
48559                 geometryIndex++;
48560               }
48561               multiFeatureIndex++;
48562             }
48563             break;
48564           case "GeometryCollection":
48565             for (j2 = 0; j2 < geometry.geometries.length; j2++)
48566               if (coordEach(geometry.geometries[j2], callback, excludeWrapCoord) === false)
48567                 return false;
48568             break;
48569           default:
48570             throw new Error("Unknown Geometry Type");
48571         }
48572       }
48573     }
48574   }
48575
48576   // node_modules/@turf/bbox/dist/es/index.js
48577   function bbox(geojson) {
48578     var result = [Infinity, Infinity, -Infinity, -Infinity];
48579     coordEach(geojson, function(coord2) {
48580       if (result[0] > coord2[0]) {
48581         result[0] = coord2[0];
48582       }
48583       if (result[1] > coord2[1]) {
48584         result[1] = coord2[1];
48585       }
48586       if (result[2] < coord2[0]) {
48587         result[2] = coord2[0];
48588       }
48589       if (result[3] < coord2[1]) {
48590         result[3] = coord2[1];
48591       }
48592     });
48593     return result;
48594   }
48595   bbox["default"] = bbox;
48596   var es_default = bbox;
48597
48598   // modules/renderer/background.js
48599   var import_which_polygon3 = __toESM(require_which_polygon());
48600
48601   // modules/renderer/tile_layer.js
48602   function rendererTileLayer(context) {
48603     var transformProp = utilPrefixCSSProperty("Transform");
48604     var tiler9 = utilTiler();
48605     var _tileSize = 256;
48606     var _projection;
48607     var _cache5 = {};
48608     var _tileOrigin;
48609     var _zoom;
48610     var _source;
48611     function tileSizeAtZoom(d2, z2) {
48612       var EPSILON = 2e-3;
48613       return _tileSize * Math.pow(2, z2 - d2[2]) / _tileSize + EPSILON;
48614     }
48615     function atZoom(t2, distance) {
48616       var power = Math.pow(2, distance);
48617       return [
48618         Math.floor(t2[0] * power),
48619         Math.floor(t2[1] * power),
48620         t2[2] + distance
48621       ];
48622     }
48623     function lookUp(d2) {
48624       for (var up = -1; up > -d2[2]; up--) {
48625         var tile = atZoom(d2, up);
48626         if (_cache5[_source.url(tile)] !== false) {
48627           return tile;
48628         }
48629       }
48630     }
48631     function uniqueBy(a2, n3) {
48632       var o2 = [];
48633       var seen = {};
48634       for (var i3 = 0; i3 < a2.length; i3++) {
48635         if (seen[a2[i3][n3]] === void 0) {
48636           o2.push(a2[i3]);
48637           seen[a2[i3][n3]] = true;
48638         }
48639       }
48640       return o2;
48641     }
48642     function addSource(d2) {
48643       d2.push(_source.url(d2));
48644       return d2;
48645     }
48646     function background(selection2) {
48647       _zoom = geoScaleToZoom(_projection.scale(), _tileSize);
48648       var pixelOffset;
48649       if (_source) {
48650         pixelOffset = [
48651           _source.offset()[0] * Math.pow(2, _zoom),
48652           _source.offset()[1] * Math.pow(2, _zoom)
48653         ];
48654       } else {
48655         pixelOffset = [0, 0];
48656       }
48657       var translate = [
48658         _projection.translate()[0] + pixelOffset[0],
48659         _projection.translate()[1] + pixelOffset[1]
48660       ];
48661       tiler9.scale(_projection.scale() * 2 * Math.PI).translate(translate);
48662       _tileOrigin = [
48663         _projection.scale() * Math.PI - translate[0],
48664         _projection.scale() * Math.PI - translate[1]
48665       ];
48666       render(selection2);
48667     }
48668     function render(selection2) {
48669       if (!_source)
48670         return;
48671       var requests = [];
48672       var showDebug = context.getDebug("tile") && !_source.overlay;
48673       if (_source.validZoom(_zoom)) {
48674         tiler9.skipNullIsland(!!_source.overlay);
48675         tiler9().forEach(function(d2) {
48676           addSource(d2);
48677           if (d2[3] === "")
48678             return;
48679           if (typeof d2[3] !== "string")
48680             return;
48681           requests.push(d2);
48682           if (_cache5[d2[3]] === false && lookUp(d2)) {
48683             requests.push(addSource(lookUp(d2)));
48684           }
48685         });
48686         requests = uniqueBy(requests, 3).filter(function(r2) {
48687           return _cache5[r2[3]] !== false;
48688         });
48689       }
48690       function load(d3_event, d2) {
48691         _cache5[d2[3]] = true;
48692         select_default2(this).on("error", null).on("load", null).classed("tile-loaded", true);
48693         render(selection2);
48694       }
48695       function error(d3_event, d2) {
48696         _cache5[d2[3]] = false;
48697         select_default2(this).on("error", null).on("load", null).remove();
48698         render(selection2);
48699       }
48700       function imageTransform(d2) {
48701         var ts = _tileSize * Math.pow(2, _zoom - d2[2]);
48702         var scale = tileSizeAtZoom(d2, _zoom);
48703         return "translate(" + (d2[0] * ts - _tileOrigin[0]) + "px," + (d2[1] * ts - _tileOrigin[1]) + "px) scale(" + scale + "," + scale + ")";
48704       }
48705       function tileCenter(d2) {
48706         var ts = _tileSize * Math.pow(2, _zoom - d2[2]);
48707         return [
48708           d2[0] * ts - _tileOrigin[0] + ts / 2,
48709           d2[1] * ts - _tileOrigin[1] + ts / 2
48710         ];
48711       }
48712       function debugTransform(d2) {
48713         var coord2 = tileCenter(d2);
48714         return "translate(" + coord2[0] + "px," + coord2[1] + "px)";
48715       }
48716       var dims = tiler9.size();
48717       var mapCenter = [dims[0] / 2, dims[1] / 2];
48718       var minDist = Math.max(dims[0], dims[1]);
48719       var nearCenter;
48720       requests.forEach(function(d2) {
48721         var c2 = tileCenter(d2);
48722         var dist = geoVecLength(c2, mapCenter);
48723         if (dist < minDist) {
48724           minDist = dist;
48725           nearCenter = d2;
48726         }
48727       });
48728       var image = selection2.selectAll("img").data(requests, function(d2) {
48729         return d2[3];
48730       });
48731       image.exit().style(transformProp, imageTransform).classed("tile-removing", true).classed("tile-center", false).each(function() {
48732         var tile = select_default2(this);
48733         window.setTimeout(function() {
48734           if (tile.classed("tile-removing")) {
48735             tile.remove();
48736           }
48737         }, 300);
48738       });
48739       image.enter().append("img").attr("class", "tile").attr("alt", "").attr("draggable", "false").style("width", _tileSize + "px").style("height", _tileSize + "px").attr("src", function(d2) {
48740         return d2[3];
48741       }).on("error", error).on("load", load).merge(image).style(transformProp, imageTransform).classed("tile-debug", showDebug).classed("tile-removing", false).classed("tile-center", function(d2) {
48742         return d2 === nearCenter;
48743       });
48744       var debug2 = selection2.selectAll(".tile-label-debug").data(showDebug ? requests : [], function(d2) {
48745         return d2[3];
48746       });
48747       debug2.exit().remove();
48748       if (showDebug) {
48749         var debugEnter = debug2.enter().append("div").attr("class", "tile-label-debug");
48750         debugEnter.append("div").attr("class", "tile-label-debug-coord");
48751         debugEnter.append("div").attr("class", "tile-label-debug-vintage");
48752         debug2 = debug2.merge(debugEnter);
48753         debug2.style(transformProp, debugTransform);
48754         debug2.selectAll(".tile-label-debug-coord").text(function(d2) {
48755           return d2[2] + " / " + d2[0] + " / " + d2[1];
48756         });
48757         debug2.selectAll(".tile-label-debug-vintage").each(function(d2) {
48758           var span = select_default2(this);
48759           var center = context.projection.invert(tileCenter(d2));
48760           _source.getMetadata(center, d2, function(err, result) {
48761             if (result && result.vintage && result.vintage.range) {
48762               span.text(result.vintage.range);
48763             } else {
48764               span.text("");
48765               span.call(_t.append("info_panels.background.vintage"));
48766               span.append("span").text(": ");
48767               span.call(_t.append("info_panels.background.unknown"));
48768             }
48769           });
48770         });
48771       }
48772     }
48773     background.projection = function(val) {
48774       if (!arguments.length)
48775         return _projection;
48776       _projection = val;
48777       return background;
48778     };
48779     background.dimensions = function(val) {
48780       if (!arguments.length)
48781         return tiler9.size();
48782       tiler9.size(val);
48783       return background;
48784     };
48785     background.source = function(val) {
48786       if (!arguments.length)
48787         return _source;
48788       _source = val;
48789       _tileSize = _source.tileSize;
48790       _cache5 = {};
48791       tiler9.tileSize(_source.tileSize).zoomExtent(_source.zoomExtent);
48792       return background;
48793     };
48794     return background;
48795   }
48796
48797   // modules/renderer/background.js
48798   var _imageryIndex = null;
48799   function rendererBackground(context) {
48800     const dispatch14 = dispatch_default("change");
48801     const baseLayer = rendererTileLayer(context).projection(context.projection);
48802     let _checkedBlocklists = [];
48803     let _isValid = true;
48804     let _overlayLayers = [];
48805     let _brightness = 1;
48806     let _contrast = 1;
48807     let _saturation = 1;
48808     let _sharpness = 1;
48809     function ensureImageryIndex() {
48810       return _mainFileFetcher.get("imagery").then((sources) => {
48811         if (_imageryIndex)
48812           return _imageryIndex;
48813         _imageryIndex = {
48814           imagery: sources,
48815           features: {}
48816         };
48817         const features = sources.map((source) => {
48818           if (!source.polygon)
48819             return null;
48820           const rings = source.polygon.map((ring) => [ring]);
48821           const feature3 = {
48822             type: "Feature",
48823             properties: { id: source.id },
48824             geometry: { type: "MultiPolygon", coordinates: rings }
48825           };
48826           _imageryIndex.features[source.id] = feature3;
48827           return feature3;
48828         }).filter(Boolean);
48829         _imageryIndex.query = (0, import_which_polygon3.default)({ type: "FeatureCollection", features });
48830         _imageryIndex.backgrounds = sources.map((source) => {
48831           if (source.type === "bing") {
48832             return rendererBackgroundSource.Bing(source, dispatch14);
48833           } else if (/^EsriWorldImagery/.test(source.id)) {
48834             return rendererBackgroundSource.Esri(source);
48835           } else {
48836             return rendererBackgroundSource(source);
48837           }
48838         });
48839         _imageryIndex.backgrounds.unshift(rendererBackgroundSource.None());
48840         let template = corePreferences("background-custom-template") || "";
48841         const custom = rendererBackgroundSource.Custom(template);
48842         _imageryIndex.backgrounds.unshift(custom);
48843         return _imageryIndex;
48844       });
48845     }
48846     function background(selection2) {
48847       const currSource = baseLayer.source();
48848       if (context.map().zoom() > 18) {
48849         if (currSource && /^EsriWorldImagery/.test(currSource.id)) {
48850           const center = context.map().center();
48851           currSource.fetchTilemap(center);
48852         }
48853       }
48854       const sources = background.sources(context.map().extent());
48855       const wasValid = _isValid;
48856       _isValid = !!sources.filter((d2) => d2 === currSource).length;
48857       if (wasValid !== _isValid) {
48858         background.updateImagery();
48859       }
48860       let baseFilter = "";
48861       if (_brightness !== 1) {
48862         baseFilter += " brightness(".concat(_brightness, ")");
48863       }
48864       if (_contrast !== 1) {
48865         baseFilter += " contrast(".concat(_contrast, ")");
48866       }
48867       if (_saturation !== 1) {
48868         baseFilter += " saturate(".concat(_saturation, ")");
48869       }
48870       if (_sharpness < 1) {
48871         const blur = number_default(0.5, 5)(1 - _sharpness);
48872         baseFilter += " blur(".concat(blur, "px)");
48873       }
48874       let base = selection2.selectAll(".layer-background").data([0]);
48875       base = base.enter().insert("div", ".layer-data").attr("class", "layer layer-background").merge(base);
48876       base.style("filter", baseFilter || null);
48877       let imagery = base.selectAll(".layer-imagery").data([0]);
48878       imagery.enter().append("div").attr("class", "layer layer-imagery").merge(imagery).call(baseLayer);
48879       let maskFilter = "";
48880       let mixBlendMode = "";
48881       if (_sharpness > 1) {
48882         mixBlendMode = "overlay";
48883         maskFilter = "saturate(0) blur(3px) invert(1)";
48884         let contrast = _sharpness - 1;
48885         maskFilter += " contrast(".concat(contrast, ")");
48886         let brightness = number_default(1, 0.85)(_sharpness - 1);
48887         maskFilter += " brightness(".concat(brightness, ")");
48888       }
48889       let mask = base.selectAll(".layer-unsharp-mask").data(_sharpness > 1 ? [0] : []);
48890       mask.exit().remove();
48891       mask.enter().append("div").attr("class", "layer layer-mask layer-unsharp-mask").merge(mask).call(baseLayer).style("filter", maskFilter || null).style("mix-blend-mode", mixBlendMode || null);
48892       let overlays = selection2.selectAll(".layer-overlay").data(_overlayLayers, (d2) => d2.source().name());
48893       overlays.exit().remove();
48894       overlays.enter().insert("div", ".layer-data").attr("class", "layer layer-overlay").merge(overlays).each((layer, i3, nodes) => select_default2(nodes[i3]).call(layer));
48895     }
48896     background.updateImagery = function() {
48897       let currSource = baseLayer.source();
48898       if (context.inIntro() || !currSource)
48899         return;
48900       let o2 = _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).map((d2) => d2.source().id).join(",");
48901       const meters = geoOffsetToMeters(currSource.offset());
48902       const EPSILON = 0.01;
48903       const x2 = +meters[0].toFixed(2);
48904       const y2 = +meters[1].toFixed(2);
48905       let hash = utilStringQs(window.location.hash);
48906       let id2 = currSource.id;
48907       if (id2 === "custom") {
48908         id2 = "custom:".concat(currSource.template());
48909       }
48910       if (id2) {
48911         hash.background = id2;
48912       } else {
48913         delete hash.background;
48914       }
48915       if (o2) {
48916         hash.overlays = o2;
48917       } else {
48918         delete hash.overlays;
48919       }
48920       if (Math.abs(x2) > EPSILON || Math.abs(y2) > EPSILON) {
48921         hash.offset = "".concat(x2, ",").concat(y2);
48922       } else {
48923         delete hash.offset;
48924       }
48925       if (!window.mocha) {
48926         window.location.replace("#" + utilQsString(hash, true));
48927       }
48928       let imageryUsed = [];
48929       let photoOverlaysUsed = [];
48930       const currUsed = currSource.imageryUsed();
48931       if (currUsed && _isValid) {
48932         imageryUsed.push(currUsed);
48933       }
48934       _overlayLayers.filter((d2) => !d2.source().isLocatorOverlay() && !d2.source().isHidden()).forEach((d2) => imageryUsed.push(d2.source().imageryUsed()));
48935       const dataLayer = context.layers().layer("data");
48936       if (dataLayer && dataLayer.enabled() && dataLayer.hasData()) {
48937         imageryUsed.push(dataLayer.getSrc());
48938       }
48939       const photoOverlayLayers = {
48940         streetside: "Bing Streetside",
48941         mapillary: "Mapillary Images",
48942         "mapillary-map-features": "Mapillary Map Features",
48943         "mapillary-signs": "Mapillary Signs",
48944         kartaview: "KartaView Images",
48945         vegbilder: "Norwegian Road Administration Images",
48946         mapilio: "Mapilio Images"
48947       };
48948       for (let layerID in photoOverlayLayers) {
48949         const layer = context.layers().layer(layerID);
48950         if (layer && layer.enabled()) {
48951           photoOverlaysUsed.push(layerID);
48952           imageryUsed.push(photoOverlayLayers[layerID]);
48953         }
48954       }
48955       context.history().imageryUsed(imageryUsed);
48956       context.history().photoOverlaysUsed(photoOverlaysUsed);
48957     };
48958     background.sources = (extent, zoom, includeCurrent) => {
48959       if (!_imageryIndex)
48960         return [];
48961       let visible = {};
48962       (_imageryIndex.query.bbox(extent.rectangle(), true) || []).forEach((d2) => visible[d2.id] = true);
48963       const currSource = baseLayer.source();
48964       const osm = context.connection();
48965       const blocklists = osm && osm.imageryBlocklists() || [];
48966       const blocklistChanged = blocklists.length !== _checkedBlocklists.length || blocklists.some((regex, index) => String(regex) !== _checkedBlocklists[index]);
48967       if (blocklistChanged) {
48968         _imageryIndex.backgrounds.forEach((source) => {
48969           source.isBlocked = blocklists.some((regex) => regex.test(source.template()));
48970         });
48971         _checkedBlocklists = blocklists.map((regex) => String(regex));
48972       }
48973       return _imageryIndex.backgrounds.filter((source) => {
48974         if (includeCurrent && currSource === source)
48975           return true;
48976         if (source.isBlocked)
48977           return false;
48978         if (!source.polygon)
48979           return true;
48980         if (zoom && zoom < 6)
48981           return false;
48982         return visible[source.id];
48983       });
48984     };
48985     background.dimensions = (val) => {
48986       if (!val)
48987         return;
48988       baseLayer.dimensions(val);
48989       _overlayLayers.forEach((layer) => layer.dimensions(val));
48990     };
48991     background.baseLayerSource = function(d2) {
48992       if (!arguments.length)
48993         return baseLayer.source();
48994       const osm = context.connection();
48995       if (!osm)
48996         return background;
48997       const blocklists = osm.imageryBlocklists();
48998       const template = d2.template();
48999       let fail = false;
49000       let tested = 0;
49001       let regex;
49002       for (let i3 = 0; i3 < blocklists.length; i3++) {
49003         regex = blocklists[i3];
49004         fail = regex.test(template);
49005         tested++;
49006         if (fail)
49007           break;
49008       }
49009       if (!tested) {
49010         regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
49011         fail = regex.test(template);
49012       }
49013       baseLayer.source(!fail ? d2 : background.findSource("none"));
49014       dispatch14.call("change");
49015       background.updateImagery();
49016       return background;
49017     };
49018     background.findSource = (id2) => {
49019       if (!id2 || !_imageryIndex)
49020         return null;
49021       return _imageryIndex.backgrounds.find((d2) => d2.id && d2.id === id2);
49022     };
49023     background.bing = () => {
49024       background.baseLayerSource(background.findSource("Bing"));
49025     };
49026     background.showsLayer = (d2) => {
49027       const currSource = baseLayer.source();
49028       if (!d2 || !currSource)
49029         return false;
49030       return d2.id === currSource.id || _overlayLayers.some((layer) => d2.id === layer.source().id);
49031     };
49032     background.overlayLayerSources = () => {
49033       return _overlayLayers.map((layer) => layer.source());
49034     };
49035     background.toggleOverlayLayer = (d2) => {
49036       let layer;
49037       for (let i3 = 0; i3 < _overlayLayers.length; i3++) {
49038         layer = _overlayLayers[i3];
49039         if (layer.source() === d2) {
49040           _overlayLayers.splice(i3, 1);
49041           dispatch14.call("change");
49042           background.updateImagery();
49043           return;
49044         }
49045       }
49046       layer = rendererTileLayer(context).source(d2).projection(context.projection).dimensions(
49047         baseLayer.dimensions()
49048       );
49049       _overlayLayers.push(layer);
49050       dispatch14.call("change");
49051       background.updateImagery();
49052     };
49053     background.nudge = (d2, zoom) => {
49054       const currSource = baseLayer.source();
49055       if (currSource) {
49056         currSource.nudge(d2, zoom);
49057         dispatch14.call("change");
49058         background.updateImagery();
49059       }
49060       return background;
49061     };
49062     background.offset = function(d2) {
49063       const currSource = baseLayer.source();
49064       if (!arguments.length) {
49065         return currSource && currSource.offset() || [0, 0];
49066       }
49067       if (currSource) {
49068         currSource.offset(d2);
49069         dispatch14.call("change");
49070         background.updateImagery();
49071       }
49072       return background;
49073     };
49074     background.brightness = function(d2) {
49075       if (!arguments.length)
49076         return _brightness;
49077       _brightness = d2;
49078       if (context.mode())
49079         dispatch14.call("change");
49080       return background;
49081     };
49082     background.contrast = function(d2) {
49083       if (!arguments.length)
49084         return _contrast;
49085       _contrast = d2;
49086       if (context.mode())
49087         dispatch14.call("change");
49088       return background;
49089     };
49090     background.saturation = function(d2) {
49091       if (!arguments.length)
49092         return _saturation;
49093       _saturation = d2;
49094       if (context.mode())
49095         dispatch14.call("change");
49096       return background;
49097     };
49098     background.sharpness = function(d2) {
49099       if (!arguments.length)
49100         return _sharpness;
49101       _sharpness = d2;
49102       if (context.mode())
49103         dispatch14.call("change");
49104       return background;
49105     };
49106     let _loadPromise;
49107     background.ensureLoaded = () => {
49108       if (_loadPromise)
49109         return _loadPromise;
49110       return _loadPromise = ensureImageryIndex();
49111     };
49112     background.init = () => {
49113       const loadPromise = background.ensureLoaded();
49114       const hash = utilStringQs(window.location.hash);
49115       const requestedBackground = hash.background || hash.layer;
49116       const lastUsedBackground = corePreferences("background-last-used");
49117       return loadPromise.then((imageryIndex) => {
49118         const extent = context.map().extent();
49119         const validBackgrounds = background.sources(extent).filter((d2) => d2.id !== "none" && d2.id !== "custom");
49120         const first = validBackgrounds.length && validBackgrounds[0];
49121         const isLastUsedValid = !!validBackgrounds.find((d2) => d2.id && d2.id === lastUsedBackground);
49122         let best;
49123         if (!requestedBackground && extent) {
49124           const viewArea = extent.area();
49125           best = validBackgrounds.find((s2) => {
49126             if (!s2.best() || s2.overlay)
49127               return false;
49128             let bbox2 = es_default(bboxClip(
49129               { type: "MultiPolygon", coordinates: [s2.polygon || [extent.polygon()]] },
49130               extent.rectangle()
49131             ));
49132             let area = geoExtent(bbox2.slice(0, 2), bbox2.slice(2, 4)).area();
49133             return area / viewArea > 0.5;
49134           });
49135         }
49136         if (requestedBackground && requestedBackground.indexOf("custom:") === 0) {
49137           const template = requestedBackground.replace(/^custom:/, "");
49138           const custom = background.findSource("custom");
49139           background.baseLayerSource(custom.template(template));
49140           corePreferences("background-custom-template", template);
49141         } else {
49142           background.baseLayerSource(
49143             background.findSource(requestedBackground) || best || isLastUsedValid && background.findSource(lastUsedBackground) || background.findSource("Bing") || first || background.findSource("none")
49144           );
49145         }
49146         const locator = imageryIndex.backgrounds.find((d2) => d2.overlay && d2.default);
49147         if (locator) {
49148           background.toggleOverlayLayer(locator);
49149         }
49150         const overlays = (hash.overlays || "").split(",");
49151         overlays.forEach((overlay) => {
49152           overlay = background.findSource(overlay);
49153           if (overlay) {
49154             background.toggleOverlayLayer(overlay);
49155           }
49156         });
49157         if (hash.gpx) {
49158           const gpx2 = context.layers().layer("data");
49159           if (gpx2) {
49160             gpx2.url(hash.gpx, ".gpx");
49161           }
49162         }
49163         if (hash.offset) {
49164           const offset = hash.offset.replace(/;/g, ",").split(",").map((n3) => !isNaN(n3) && n3);
49165           if (offset.length === 2) {
49166             background.offset(geoMetersToOffset(offset));
49167           }
49168         }
49169       }).catch((err) => {
49170         console.error(err);
49171       });
49172     };
49173     return utilRebind(background, dispatch14, "on");
49174   }
49175
49176   // modules/renderer/features.js
49177   function rendererFeatures(context) {
49178     var dispatch14 = dispatch_default("change", "redraw");
49179     var features = utilRebind({}, dispatch14, "on");
49180     var _deferred2 = /* @__PURE__ */ new Set();
49181     var traffic_roads = {
49182       "motorway": true,
49183       "motorway_link": true,
49184       "trunk": true,
49185       "trunk_link": true,
49186       "primary": true,
49187       "primary_link": true,
49188       "secondary": true,
49189       "secondary_link": true,
49190       "tertiary": true,
49191       "tertiary_link": true,
49192       "residential": true,
49193       "unclassified": true,
49194       "living_street": true,
49195       "busway": true
49196     };
49197     var service_roads = {
49198       "service": true,
49199       "road": true,
49200       "track": true
49201     };
49202     var paths = {
49203       "path": true,
49204       "footway": true,
49205       "cycleway": true,
49206       "bridleway": true,
49207       "steps": true,
49208       "pedestrian": true
49209     };
49210     var _cullFactor = 1;
49211     var _cache5 = {};
49212     var _rules = {};
49213     var _stats = {};
49214     var _keys = [];
49215     var _hidden = [];
49216     var _forceVisible = {};
49217     function update() {
49218       if (!window.mocha) {
49219         var hash = utilStringQs(window.location.hash);
49220         var disabled = features.disabled();
49221         if (disabled.length) {
49222           hash.disable_features = disabled.join(",");
49223         } else {
49224           delete hash.disable_features;
49225         }
49226         window.location.replace("#" + utilQsString(hash, true));
49227         corePreferences("disabled-features", disabled.join(","));
49228       }
49229       _hidden = features.hidden();
49230       dispatch14.call("change");
49231       dispatch14.call("redraw");
49232     }
49233     function defineRule(k2, filter2, max3) {
49234       var isEnabled = true;
49235       _keys.push(k2);
49236       _rules[k2] = {
49237         filter: filter2,
49238         enabled: isEnabled,
49239         // whether the user wants it enabled..
49240         count: 0,
49241         currentMax: max3 || Infinity,
49242         defaultMax: max3 || Infinity,
49243         enable: function() {
49244           this.enabled = true;
49245           this.currentMax = this.defaultMax;
49246         },
49247         disable: function() {
49248           this.enabled = false;
49249           this.currentMax = 0;
49250         },
49251         hidden: function() {
49252           return this.count === 0 && !this.enabled || this.count > this.currentMax * _cullFactor;
49253         },
49254         autoHidden: function() {
49255           return this.hidden() && this.currentMax > 0;
49256         }
49257       };
49258     }
49259     defineRule("points", function isPoint(tags, geometry) {
49260       return geometry === "point";
49261     }, 200);
49262     defineRule("traffic_roads", function isTrafficRoad(tags) {
49263       return traffic_roads[tags.highway];
49264     });
49265     defineRule("service_roads", function isServiceRoad(tags) {
49266       return service_roads[tags.highway];
49267     });
49268     defineRule("paths", function isPath(tags) {
49269       return paths[tags.highway];
49270     });
49271     defineRule("buildings", function isBuilding(tags) {
49272       return !!tags.building && tags.building !== "no" || tags.parking === "multi-storey" || tags.parking === "sheds" || tags.parking === "carports" || tags.parking === "garage_boxes";
49273     }, 250);
49274     defineRule("building_parts", function isBuildingPart(tags) {
49275       return tags["building:part"];
49276     });
49277     defineRule("indoor", function isIndoor(tags) {
49278       return tags.indoor;
49279     });
49280     defineRule("landuse", function isLanduse(tags, geometry) {
49281       return geometry === "area" && !_rules.buildings.filter(tags) && !_rules.building_parts.filter(tags) && !_rules.indoor.filter(tags) && !_rules.water.filter(tags) && !_rules.pistes.filter(tags);
49282     });
49283     defineRule("boundaries", function isBoundary(tags, geometry) {
49284       return (geometry === "line" && !!tags.boundary || geometry === "relation" && tags.type === "boundary") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway] || tags.waterway || tags.railway || tags.landuse || tags.natural || tags.building || tags.power);
49285     });
49286     defineRule("water", function isWater(tags) {
49287       return !!tags.waterway || tags.natural === "water" || tags.natural === "coastline" || tags.natural === "bay" || tags.landuse === "pond" || tags.landuse === "basin" || tags.landuse === "reservoir" || tags.landuse === "salt_pond";
49288     });
49289     defineRule("rail", function isRail(tags) {
49290       return (!!tags.railway || tags.landuse === "railway") && !(traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]);
49291     });
49292     defineRule("pistes", function isPiste(tags) {
49293       return tags["piste:type"];
49294     });
49295     defineRule("aerialways", function isPiste(tags) {
49296       return tags.aerialway && tags.aerialway !== "yes" && tags.aerialway !== "station";
49297     });
49298     defineRule("power", function isPower(tags) {
49299       return !!tags.power;
49300     });
49301     defineRule("past_future", function isPastFuture(tags) {
49302       if (traffic_roads[tags.highway] || service_roads[tags.highway] || paths[tags.highway]) {
49303         return false;
49304       }
49305       var strings = Object.keys(tags);
49306       for (var i3 = 0; i3 < strings.length; i3++) {
49307         var s2 = strings[i3];
49308         if (osmLifecyclePrefixes[s2] || osmLifecyclePrefixes[tags[s2]])
49309           return true;
49310       }
49311       return false;
49312     });
49313     defineRule("others", function isOther(tags, geometry) {
49314       return geometry === "line" || geometry === "area";
49315     });
49316     features.features = function() {
49317       return _rules;
49318     };
49319     features.keys = function() {
49320       return _keys;
49321     };
49322     features.enabled = function(k2) {
49323       if (!arguments.length) {
49324         return _keys.filter(function(k3) {
49325           return _rules[k3].enabled;
49326         });
49327       }
49328       return _rules[k2] && _rules[k2].enabled;
49329     };
49330     features.disabled = function(k2) {
49331       if (!arguments.length) {
49332         return _keys.filter(function(k3) {
49333           return !_rules[k3].enabled;
49334         });
49335       }
49336       return _rules[k2] && !_rules[k2].enabled;
49337     };
49338     features.hidden = function(k2) {
49339       if (!arguments.length) {
49340         return _keys.filter(function(k3) {
49341           return _rules[k3].hidden();
49342         });
49343       }
49344       return _rules[k2] && _rules[k2].hidden();
49345     };
49346     features.autoHidden = function(k2) {
49347       if (!arguments.length) {
49348         return _keys.filter(function(k3) {
49349           return _rules[k3].autoHidden();
49350         });
49351       }
49352       return _rules[k2] && _rules[k2].autoHidden();
49353     };
49354     features.enable = function(k2) {
49355       if (_rules[k2] && !_rules[k2].enabled) {
49356         _rules[k2].enable();
49357         update();
49358       }
49359     };
49360     features.enableAll = function() {
49361       var didEnable = false;
49362       for (var k2 in _rules) {
49363         if (!_rules[k2].enabled) {
49364           didEnable = true;
49365           _rules[k2].enable();
49366         }
49367       }
49368       if (didEnable)
49369         update();
49370     };
49371     features.disable = function(k2) {
49372       if (_rules[k2] && _rules[k2].enabled) {
49373         _rules[k2].disable();
49374         update();
49375       }
49376     };
49377     features.disableAll = function() {
49378       var didDisable = false;
49379       for (var k2 in _rules) {
49380         if (_rules[k2].enabled) {
49381           didDisable = true;
49382           _rules[k2].disable();
49383         }
49384       }
49385       if (didDisable)
49386         update();
49387     };
49388     features.toggle = function(k2) {
49389       if (_rules[k2]) {
49390         (function(f2) {
49391           return f2.enabled ? f2.disable() : f2.enable();
49392         })(_rules[k2]);
49393         update();
49394       }
49395     };
49396     features.resetStats = function() {
49397       for (var i3 = 0; i3 < _keys.length; i3++) {
49398         _rules[_keys[i3]].count = 0;
49399       }
49400       dispatch14.call("change");
49401     };
49402     features.gatherStats = function(d2, resolver, dimensions) {
49403       var needsRedraw = false;
49404       var types = utilArrayGroupBy(d2, "type");
49405       var entities = [].concat(types.relation || [], types.way || [], types.node || []);
49406       var currHidden, geometry, matches, i3, j2;
49407       for (i3 = 0; i3 < _keys.length; i3++) {
49408         _rules[_keys[i3]].count = 0;
49409       }
49410       _cullFactor = dimensions[0] * dimensions[1] / 1e6;
49411       for (i3 = 0; i3 < entities.length; i3++) {
49412         geometry = entities[i3].geometry(resolver);
49413         matches = Object.keys(features.getMatches(entities[i3], resolver, geometry));
49414         for (j2 = 0; j2 < matches.length; j2++) {
49415           _rules[matches[j2]].count++;
49416         }
49417       }
49418       currHidden = features.hidden();
49419       if (currHidden !== _hidden) {
49420         _hidden = currHidden;
49421         needsRedraw = true;
49422         dispatch14.call("change");
49423       }
49424       return needsRedraw;
49425     };
49426     features.stats = function() {
49427       for (var i3 = 0; i3 < _keys.length; i3++) {
49428         _stats[_keys[i3]] = _rules[_keys[i3]].count;
49429       }
49430       return _stats;
49431     };
49432     features.clear = function(d2) {
49433       for (var i3 = 0; i3 < d2.length; i3++) {
49434         features.clearEntity(d2[i3]);
49435       }
49436     };
49437     features.clearEntity = function(entity) {
49438       delete _cache5[osmEntity.key(entity)];
49439     };
49440     features.reset = function() {
49441       Array.from(_deferred2).forEach(function(handle) {
49442         window.cancelIdleCallback(handle);
49443         _deferred2.delete(handle);
49444       });
49445       _cache5 = {};
49446     };
49447     function relationShouldBeChecked(relation) {
49448       return relation.tags.type === "boundary";
49449     }
49450     features.getMatches = function(entity, resolver, geometry) {
49451       if (geometry === "vertex" || geometry === "relation" && !relationShouldBeChecked(entity))
49452         return {};
49453       var ent = osmEntity.key(entity);
49454       if (!_cache5[ent]) {
49455         _cache5[ent] = {};
49456       }
49457       if (!_cache5[ent].matches) {
49458         var matches = {};
49459         var hasMatch = false;
49460         for (var i3 = 0; i3 < _keys.length; i3++) {
49461           if (_keys[i3] === "others") {
49462             if (hasMatch)
49463               continue;
49464             if (entity.type === "way") {
49465               var parents = features.getParents(entity, resolver, geometry);
49466               if (parents.length === 1 && parents[0].isMultipolygon() || // 2b. or belongs only to boundary relations
49467               parents.length > 0 && parents.every(function(parent) {
49468                 return parent.tags.type === "boundary";
49469               })) {
49470                 var pkey = osmEntity.key(parents[0]);
49471                 if (_cache5[pkey] && _cache5[pkey].matches) {
49472                   matches = Object.assign({}, _cache5[pkey].matches);
49473                   continue;
49474                 }
49475               }
49476             }
49477           }
49478           if (_rules[_keys[i3]].filter(entity.tags, geometry)) {
49479             matches[_keys[i3]] = hasMatch = true;
49480           }
49481         }
49482         _cache5[ent].matches = matches;
49483       }
49484       return _cache5[ent].matches;
49485     };
49486     features.getParents = function(entity, resolver, geometry) {
49487       if (geometry === "point")
49488         return [];
49489       var ent = osmEntity.key(entity);
49490       if (!_cache5[ent]) {
49491         _cache5[ent] = {};
49492       }
49493       if (!_cache5[ent].parents) {
49494         var parents = [];
49495         if (geometry === "vertex") {
49496           parents = resolver.parentWays(entity);
49497         } else {
49498           parents = resolver.parentRelations(entity);
49499         }
49500         _cache5[ent].parents = parents;
49501       }
49502       return _cache5[ent].parents;
49503     };
49504     features.isHiddenPreset = function(preset, geometry) {
49505       if (!_hidden.length)
49506         return false;
49507       if (!preset.tags)
49508         return false;
49509       var test = preset.setTags({}, geometry);
49510       for (var key in _rules) {
49511         if (_rules[key].filter(test, geometry)) {
49512           if (_hidden.indexOf(key) !== -1) {
49513             return key;
49514           }
49515           return false;
49516         }
49517       }
49518       return false;
49519     };
49520     features.isHiddenFeature = function(entity, resolver, geometry) {
49521       if (!_hidden.length)
49522         return false;
49523       if (!entity.version)
49524         return false;
49525       if (_forceVisible[entity.id])
49526         return false;
49527       var matches = Object.keys(features.getMatches(entity, resolver, geometry));
49528       return matches.length && matches.every(function(k2) {
49529         return features.hidden(k2);
49530       });
49531     };
49532     features.isHiddenChild = function(entity, resolver, geometry) {
49533       if (!_hidden.length)
49534         return false;
49535       if (!entity.version || geometry === "point")
49536         return false;
49537       if (_forceVisible[entity.id])
49538         return false;
49539       var parents = features.getParents(entity, resolver, geometry);
49540       if (!parents.length)
49541         return false;
49542       for (var i3 = 0; i3 < parents.length; i3++) {
49543         if (!features.isHidden(parents[i3], resolver, parents[i3].geometry(resolver))) {
49544           return false;
49545         }
49546       }
49547       return true;
49548     };
49549     features.hasHiddenConnections = function(entity, resolver) {
49550       if (!_hidden.length)
49551         return false;
49552       var childNodes, connections;
49553       if (entity.type === "midpoint") {
49554         childNodes = [resolver.entity(entity.edge[0]), resolver.entity(entity.edge[1])];
49555         connections = [];
49556       } else {
49557         childNodes = entity.nodes ? resolver.childNodes(entity) : [];
49558         connections = features.getParents(entity, resolver, entity.geometry(resolver));
49559       }
49560       connections = childNodes.reduce(function(result, e3) {
49561         return resolver.isShared(e3) ? utilArrayUnion(result, resolver.parentWays(e3)) : result;
49562       }, connections);
49563       return connections.some(function(e3) {
49564         return features.isHidden(e3, resolver, e3.geometry(resolver));
49565       });
49566     };
49567     features.isHidden = function(entity, resolver, geometry) {
49568       if (!_hidden.length)
49569         return false;
49570       if (!entity.version)
49571         return false;
49572       var fn = geometry === "vertex" ? features.isHiddenChild : features.isHiddenFeature;
49573       return fn(entity, resolver, geometry);
49574     };
49575     features.filter = function(d2, resolver) {
49576       if (!_hidden.length)
49577         return d2;
49578       var result = [];
49579       for (var i3 = 0; i3 < d2.length; i3++) {
49580         var entity = d2[i3];
49581         if (!features.isHidden(entity, resolver, entity.geometry(resolver))) {
49582           result.push(entity);
49583         }
49584       }
49585       return result;
49586     };
49587     features.forceVisible = function(entityIDs) {
49588       if (!arguments.length)
49589         return Object.keys(_forceVisible);
49590       _forceVisible = {};
49591       for (var i3 = 0; i3 < entityIDs.length; i3++) {
49592         _forceVisible[entityIDs[i3]] = true;
49593         var entity = context.hasEntity(entityIDs[i3]);
49594         if (entity && entity.type === "relation") {
49595           for (var j2 in entity.members) {
49596             _forceVisible[entity.members[j2].id] = true;
49597           }
49598         }
49599       }
49600       return features;
49601     };
49602     features.init = function() {
49603       var storage = corePreferences("disabled-features");
49604       if (storage) {
49605         var storageDisabled = storage.replace(/;/g, ",").split(",");
49606         storageDisabled.forEach(features.disable);
49607       }
49608       var hash = utilStringQs(window.location.hash);
49609       if (hash.disable_features) {
49610         var hashDisabled = hash.disable_features.replace(/;/g, ",").split(",");
49611         hashDisabled.forEach(features.disable);
49612       }
49613     };
49614     context.history().on("merge.features", function(newEntities) {
49615       if (!newEntities)
49616         return;
49617       var handle = window.requestIdleCallback(function() {
49618         var graph = context.graph();
49619         var types = utilArrayGroupBy(newEntities, "type");
49620         var entities = [].concat(types.relation || [], types.way || [], types.node || []);
49621         for (var i3 = 0; i3 < entities.length; i3++) {
49622           var geometry = entities[i3].geometry(graph);
49623           features.getMatches(entities[i3], graph, geometry);
49624         }
49625       });
49626       _deferred2.add(handle);
49627     });
49628     return features;
49629   }
49630
49631   // modules/svg/areas.js
49632   var import_fast_deep_equal5 = __toESM(require_fast_deep_equal());
49633
49634   // modules/svg/helpers.js
49635   function svgPassiveVertex(node, graph, activeID) {
49636     if (!activeID)
49637       return 1;
49638     if (activeID === node.id)
49639       return 0;
49640     var parents = graph.parentWays(node);
49641     var i3, j2, nodes, isClosed, ix1, ix2, ix3, ix4, max3;
49642     for (i3 = 0; i3 < parents.length; i3++) {
49643       nodes = parents[i3].nodes;
49644       isClosed = parents[i3].isClosed();
49645       for (j2 = 0; j2 < nodes.length; j2++) {
49646         if (nodes[j2] === node.id) {
49647           ix1 = j2 - 2;
49648           ix2 = j2 - 1;
49649           ix3 = j2 + 1;
49650           ix4 = j2 + 2;
49651           if (isClosed) {
49652             max3 = nodes.length - 1;
49653             if (ix1 < 0)
49654               ix1 = max3 + ix1;
49655             if (ix2 < 0)
49656               ix2 = max3 + ix2;
49657             if (ix3 > max3)
49658               ix3 = ix3 - max3;
49659             if (ix4 > max3)
49660               ix4 = ix4 - max3;
49661           }
49662           if (nodes[ix1] === activeID)
49663             return 0;
49664           else if (nodes[ix2] === activeID)
49665             return 2;
49666           else if (nodes[ix3] === activeID)
49667             return 2;
49668           else if (nodes[ix4] === activeID)
49669             return 0;
49670           else if (isClosed && nodes.indexOf(activeID) !== -1)
49671             return 0;
49672         }
49673       }
49674     }
49675     return 1;
49676   }
49677   function svgMarkerSegments(projection2, graph, dt2, shouldReverse, bothDirections) {
49678     return function(entity) {
49679       var i3 = 0;
49680       var offset = dt2;
49681       var segments = [];
49682       var clip = identity_default2().clipExtent(projection2.clipExtent()).stream;
49683       var coordinates = graph.childNodes(entity).map(function(n3) {
49684         return n3.loc;
49685       });
49686       var a2, b2;
49687       if (shouldReverse(entity)) {
49688         coordinates.reverse();
49689       }
49690       stream_default({
49691         type: "LineString",
49692         coordinates
49693       }, projection2.stream(clip({
49694         lineStart: function() {
49695         },
49696         lineEnd: function() {
49697           a2 = null;
49698         },
49699         point: function(x2, y2) {
49700           b2 = [x2, y2];
49701           if (a2) {
49702             var span = geoVecLength(a2, b2) - offset;
49703             if (span >= 0) {
49704               var heading2 = geoVecAngle(a2, b2);
49705               var dx = dt2 * Math.cos(heading2);
49706               var dy = dt2 * Math.sin(heading2);
49707               var p2 = [
49708                 a2[0] + offset * Math.cos(heading2),
49709                 a2[1] + offset * Math.sin(heading2)
49710               ];
49711               var coord2 = [a2, p2];
49712               for (span -= dt2; span >= 0; span -= dt2) {
49713                 p2 = geoVecAdd(p2, [dx, dy]);
49714                 coord2.push(p2);
49715               }
49716               coord2.push(b2);
49717               var segment = "";
49718               var j2;
49719               for (j2 = 0; j2 < coord2.length; j2++) {
49720                 segment += (j2 === 0 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
49721               }
49722               segments.push({ id: entity.id, index: i3++, d: segment });
49723               if (bothDirections(entity)) {
49724                 segment = "";
49725                 for (j2 = coord2.length - 1; j2 >= 0; j2--) {
49726                   segment += (j2 === coord2.length - 1 ? "M" : "L") + coord2[j2][0] + "," + coord2[j2][1];
49727                 }
49728                 segments.push({ id: entity.id, index: i3++, d: segment });
49729               }
49730             }
49731             offset = -span;
49732           }
49733           a2 = b2;
49734         }
49735       })));
49736       return segments;
49737     };
49738   }
49739   function svgPath(projection2, graph, isArea) {
49740     var cache = {};
49741     var padding = isArea ? 65 : 5;
49742     var viewport = projection2.clipExtent();
49743     var paddedExtent = [
49744       [viewport[0][0] - padding, viewport[0][1] - padding],
49745       [viewport[1][0] + padding, viewport[1][1] + padding]
49746     ];
49747     var clip = identity_default2().clipExtent(paddedExtent).stream;
49748     var project = projection2.stream;
49749     var path = path_default().projection({ stream: function(output) {
49750       return project(clip(output));
49751     } });
49752     var svgpath = function(entity) {
49753       if (entity.id in cache) {
49754         return cache[entity.id];
49755       } else {
49756         return cache[entity.id] = path(entity.asGeoJSON(graph));
49757       }
49758     };
49759     svgpath.geojson = function(d2) {
49760       if (d2.__featurehash__ !== void 0) {
49761         if (d2.__featurehash__ in cache) {
49762           return cache[d2.__featurehash__];
49763         } else {
49764           return cache[d2.__featurehash__] = path(d2);
49765         }
49766       } else {
49767         return path(d2);
49768       }
49769     };
49770     return svgpath;
49771   }
49772   function svgPointTransform(projection2) {
49773     var svgpoint = function(entity) {
49774       var pt2 = projection2(entity.loc);
49775       return "translate(" + pt2[0] + "," + pt2[1] + ")";
49776     };
49777     svgpoint.geojson = function(d2) {
49778       return svgpoint(d2.properties.entity);
49779     };
49780     return svgpoint;
49781   }
49782   function svgRelationMemberTags(graph) {
49783     return function(entity) {
49784       var tags = entity.tags;
49785       var shouldCopyMultipolygonTags = !entity.hasInterestingTags();
49786       graph.parentRelations(entity).forEach(function(relation) {
49787         var type2 = relation.tags.type;
49788         if (type2 === "multipolygon" && shouldCopyMultipolygonTags || type2 === "boundary") {
49789           tags = Object.assign({}, relation.tags, tags);
49790         }
49791       });
49792       return tags;
49793     };
49794   }
49795   function svgSegmentWay(way, graph, activeID) {
49796     if (activeID === void 0) {
49797       return graph.transient(way, "waySegments", getWaySegments);
49798     } else {
49799       return getWaySegments();
49800     }
49801     function getWaySegments() {
49802       var isActiveWay = way.nodes.indexOf(activeID) !== -1;
49803       var features = { passive: [], active: [] };
49804       var start2 = {};
49805       var end = {};
49806       var node, type2;
49807       for (var i3 = 0; i3 < way.nodes.length; i3++) {
49808         node = graph.entity(way.nodes[i3]);
49809         type2 = svgPassiveVertex(node, graph, activeID);
49810         end = { node, type: type2 };
49811         if (start2.type !== void 0) {
49812           if (start2.node.id === activeID || end.node.id === activeID) {
49813           } else if (isActiveWay && (start2.type === 2 || end.type === 2)) {
49814             pushActive(start2, end, i3);
49815           } else if (start2.type === 0 && end.type === 0) {
49816             pushActive(start2, end, i3);
49817           } else {
49818             pushPassive(start2, end, i3);
49819           }
49820         }
49821         start2 = end;
49822       }
49823       return features;
49824       function pushActive(start3, end2, index) {
49825         features.active.push({
49826           type: "Feature",
49827           id: way.id + "-" + index + "-nope",
49828           properties: {
49829             nope: true,
49830             target: true,
49831             entity: way,
49832             nodes: [start3.node, end2.node],
49833             index
49834           },
49835           geometry: {
49836             type: "LineString",
49837             coordinates: [start3.node.loc, end2.node.loc]
49838           }
49839         });
49840       }
49841       function pushPassive(start3, end2, index) {
49842         features.passive.push({
49843           type: "Feature",
49844           id: way.id + "-" + index,
49845           properties: {
49846             target: true,
49847             entity: way,
49848             nodes: [start3.node, end2.node],
49849             index
49850           },
49851           geometry: {
49852             type: "LineString",
49853             coordinates: [start3.node.loc, end2.node.loc]
49854           }
49855         });
49856       }
49857     }
49858   }
49859
49860   // modules/svg/tag_classes.js
49861   function svgTagClasses() {
49862     var primaries = [
49863       "building",
49864       "highway",
49865       "railway",
49866       "waterway",
49867       "aeroway",
49868       "aerialway",
49869       "piste:type",
49870       "boundary",
49871       "power",
49872       "amenity",
49873       "natural",
49874       "landuse",
49875       "leisure",
49876       "military",
49877       "place",
49878       "man_made",
49879       "route",
49880       "attraction",
49881       "roller_coaster",
49882       "building:part",
49883       "indoor"
49884     ];
49885     var statuses = Object.keys(osmLifecyclePrefixes);
49886     var secondaries = [
49887       "oneway",
49888       "bridge",
49889       "tunnel",
49890       "embankment",
49891       "cutting",
49892       "barrier",
49893       "surface",
49894       "tracktype",
49895       "footway",
49896       "crossing",
49897       "service",
49898       "sport",
49899       "public_transport",
49900       "location",
49901       "parking",
49902       "golf",
49903       "type",
49904       "leisure",
49905       "man_made",
49906       "indoor",
49907       "construction",
49908       "proposed"
49909     ];
49910     var _tags = function(entity) {
49911       return entity.tags;
49912     };
49913     var tagClasses = function(selection2) {
49914       selection2.each(function tagClassesEach(entity) {
49915         var value = this.className;
49916         if (value.baseVal !== void 0) {
49917           value = value.baseVal;
49918         }
49919         var t2 = _tags(entity);
49920         var computed = tagClasses.getClassesString(t2, value);
49921         if (computed !== value) {
49922           select_default2(this).attr("class", computed);
49923         }
49924       });
49925     };
49926     tagClasses.getClassesString = function(t2, value) {
49927       var primary, status;
49928       var i3, j2, k2, v2;
49929       var overrideGeometry;
49930       if (/\bstroke\b/.test(value)) {
49931         if (!!t2.barrier && t2.barrier !== "no") {
49932           overrideGeometry = "line";
49933         }
49934       }
49935       var classes = value.trim().split(/\s+/).filter(function(klass) {
49936         return klass.length && !/^tag-/.test(klass);
49937       }).map(function(klass) {
49938         return klass === "line" || klass === "area" ? overrideGeometry || klass : klass;
49939       });
49940       for (i3 = 0; i3 < primaries.length; i3++) {
49941         k2 = primaries[i3];
49942         v2 = t2[k2];
49943         if (!v2 || v2 === "no")
49944           continue;
49945         if (k2 === "piste:type") {
49946           k2 = "piste";
49947         } else if (k2 === "building:part") {
49948           k2 = "building_part";
49949         }
49950         primary = k2;
49951         if (statuses.indexOf(v2) !== -1) {
49952           status = v2;
49953           classes.push("tag-" + k2);
49954         } else {
49955           classes.push("tag-" + k2);
49956           classes.push("tag-" + k2 + "-" + v2);
49957         }
49958         break;
49959       }
49960       if (!primary) {
49961         for (i3 = 0; i3 < statuses.length; i3++) {
49962           for (j2 = 0; j2 < primaries.length; j2++) {
49963             k2 = statuses[i3] + ":" + primaries[j2];
49964             v2 = t2[k2];
49965             if (!v2 || v2 === "no")
49966               continue;
49967             status = statuses[i3];
49968             break;
49969           }
49970         }
49971       }
49972       if (!status) {
49973         for (i3 = 0; i3 < statuses.length; i3++) {
49974           k2 = statuses[i3];
49975           v2 = t2[k2];
49976           if (!v2 || v2 === "no")
49977             continue;
49978           if (v2 === "yes") {
49979             status = k2;
49980           } else if (primary && primary === v2) {
49981             status = k2;
49982           } else if (!primary && primaries.indexOf(v2) !== -1) {
49983             status = k2;
49984             primary = v2;
49985             classes.push("tag-" + v2);
49986           }
49987           if (status)
49988             break;
49989         }
49990       }
49991       if (status) {
49992         classes.push("tag-status");
49993         classes.push("tag-status-" + status);
49994       }
49995       for (i3 = 0; i3 < secondaries.length; i3++) {
49996         k2 = secondaries[i3];
49997         v2 = t2[k2];
49998         if (!v2 || v2 === "no" || k2 === primary)
49999           continue;
50000         classes.push("tag-" + k2);
50001         classes.push("tag-" + k2 + "-" + v2);
50002       }
50003       if (primary === "highway" && !osmPathHighwayTagValues[t2.highway] || primary === "aeroway") {
50004         var surface = t2.highway === "track" ? "unpaved" : "paved";
50005         for (k2 in t2) {
50006           v2 = t2[k2];
50007           if (k2 in osmPavedTags) {
50008             surface = osmPavedTags[k2][v2] ? "paved" : "unpaved";
50009           }
50010           if (k2 in osmSemipavedTags && !!osmSemipavedTags[k2][v2]) {
50011             surface = "semipaved";
50012           }
50013         }
50014         classes.push("tag-" + surface);
50015       }
50016       var qid = t2.wikidata || t2["flag:wikidata"] || t2["brand:wikidata"] || t2["network:wikidata"] || t2["operator:wikidata"];
50017       if (qid) {
50018         classes.push("tag-wikidata");
50019       }
50020       return classes.filter((klass) => /^[-_a-z0-9]+$/.test(klass)).join(" ").trim();
50021     };
50022     tagClasses.tags = function(val) {
50023       if (!arguments.length)
50024         return _tags;
50025       _tags = val;
50026       return tagClasses;
50027     };
50028     return tagClasses;
50029   }
50030
50031   // modules/svg/tag_pattern.js
50032   var patterns = {
50033     // tag - pattern name
50034     // -or-
50035     // tag - value - pattern name
50036     // -or-
50037     // tag - value - rules (optional tag-values, pattern name)
50038     // (matches earlier rules first, so fallback should be last entry)
50039     amenity: {
50040       grave_yard: "cemetery",
50041       fountain: "water_standing"
50042     },
50043     landuse: {
50044       cemetery: [
50045         { religion: "christian", pattern: "cemetery_christian" },
50046         { religion: "buddhist", pattern: "cemetery_buddhist" },
50047         { religion: "muslim", pattern: "cemetery_muslim" },
50048         { religion: "jewish", pattern: "cemetery_jewish" },
50049         { pattern: "cemetery" }
50050       ],
50051       construction: "construction",
50052       farmland: "farmland",
50053       farmyard: "farmyard",
50054       forest: [
50055         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
50056         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
50057         { leaf_type: "leafless", pattern: "forest_leafless" },
50058         { pattern: "forest" }
50059         // same as 'leaf_type:mixed'
50060       ],
50061       grave_yard: "cemetery",
50062       grass: "grass",
50063       landfill: "landfill",
50064       meadow: "meadow",
50065       military: "construction",
50066       orchard: "orchard",
50067       quarry: "quarry",
50068       vineyard: "vineyard"
50069     },
50070     leisure: {
50071       horse_riding: "farmyard"
50072     },
50073     natural: {
50074       beach: "beach",
50075       grassland: "grass",
50076       sand: "beach",
50077       scrub: "scrub",
50078       water: [
50079         { water: "pond", pattern: "pond" },
50080         { water: "reservoir", pattern: "water_standing" },
50081         { pattern: "waves" }
50082       ],
50083       wetland: [
50084         { wetland: "marsh", pattern: "wetland_marsh" },
50085         { wetland: "swamp", pattern: "wetland_swamp" },
50086         { wetland: "bog", pattern: "wetland_bog" },
50087         { wetland: "reedbed", pattern: "wetland_reedbed" },
50088         { pattern: "wetland" }
50089       ],
50090       wood: [
50091         { leaf_type: "broadleaved", pattern: "forest_broadleaved" },
50092         { leaf_type: "needleleaved", pattern: "forest_needleleaved" },
50093         { leaf_type: "leafless", pattern: "forest_leafless" },
50094         { pattern: "forest" }
50095         // same as 'leaf_type:mixed'
50096       ]
50097     },
50098     golf: {
50099       green: "golf_green",
50100       tee: "grass",
50101       fairway: "grass",
50102       rough: "scrub"
50103     },
50104     surface: {
50105       grass: "grass",
50106       sand: "beach"
50107     }
50108   };
50109   function svgTagPattern(tags) {
50110     if (tags.building && tags.building !== "no") {
50111       return null;
50112     }
50113     for (var tag2 in patterns) {
50114       var entityValue = tags[tag2];
50115       if (!entityValue)
50116         continue;
50117       if (typeof patterns[tag2] === "string") {
50118         return "pattern-" + patterns[tag2];
50119       } else {
50120         var values = patterns[tag2];
50121         for (var value in values) {
50122           if (entityValue !== value)
50123             continue;
50124           var rules = values[value];
50125           if (typeof rules === "string") {
50126             return "pattern-" + rules;
50127           }
50128           for (var ruleKey in rules) {
50129             var rule = rules[ruleKey];
50130             var pass = true;
50131             for (var criterion in rule) {
50132               if (criterion !== "pattern") {
50133                 var v2 = tags[criterion];
50134                 if (!v2 || v2 !== rule[criterion]) {
50135                   pass = false;
50136                   break;
50137                 }
50138               }
50139             }
50140             if (pass) {
50141               return "pattern-" + rule.pattern;
50142             }
50143           }
50144         }
50145       }
50146     }
50147     return null;
50148   }
50149
50150   // modules/svg/areas.js
50151   function svgAreas(projection2, context) {
50152     function getPatternStyle(tags) {
50153       var imageID = svgTagPattern(tags);
50154       if (imageID) {
50155         return 'url("#ideditor-' + imageID + '")';
50156       }
50157       return "";
50158     }
50159     function drawTargets(selection2, graph, entities, filter2) {
50160       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
50161       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
50162       var getPath = svgPath(projection2).geojson;
50163       var activeID = context.activeID();
50164       var base = context.history().base();
50165       var data = { targets: [], nopes: [] };
50166       entities.forEach(function(way) {
50167         var features = svgSegmentWay(way, graph, activeID);
50168         data.targets.push.apply(data.targets, features.passive);
50169         data.nopes.push.apply(data.nopes, features.active);
50170       });
50171       var targetData = data.targets.filter(getPath);
50172       var targets = selection2.selectAll(".area.target-allowed").filter(function(d2) {
50173         return filter2(d2.properties.entity);
50174       }).data(targetData, function key(d2) {
50175         return d2.id;
50176       });
50177       targets.exit().remove();
50178       var segmentWasEdited = function(d2) {
50179         var wayID = d2.properties.entity.id;
50180         if (!base.entities[wayID] || !(0, import_fast_deep_equal5.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
50181           return false;
50182         }
50183         return d2.properties.nodes.some(function(n3) {
50184           return !base.entities[n3.id] || !(0, import_fast_deep_equal5.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
50185         });
50186       };
50187       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
50188         return "way area target target-allowed " + targetClass + d2.id;
50189       }).classed("segment-edited", segmentWasEdited);
50190       var nopeData = data.nopes.filter(getPath);
50191       var nopes = selection2.selectAll(".area.target-nope").filter(function(d2) {
50192         return filter2(d2.properties.entity);
50193       }).data(nopeData, function key(d2) {
50194         return d2.id;
50195       });
50196       nopes.exit().remove();
50197       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
50198         return "way area target target-nope " + nopeClass + d2.id;
50199       }).classed("segment-edited", segmentWasEdited);
50200     }
50201     function drawAreas(selection2, graph, entities, filter2) {
50202       var path = svgPath(projection2, graph, true);
50203       var areas = {};
50204       var multipolygon;
50205       var base = context.history().base();
50206       for (var i3 = 0; i3 < entities.length; i3++) {
50207         var entity = entities[i3];
50208         if (entity.geometry(graph) !== "area")
50209           continue;
50210         multipolygon = osmIsOldMultipolygonOuterMember(entity, graph);
50211         if (multipolygon) {
50212           areas[multipolygon.id] = {
50213             entity: multipolygon.mergeTags(entity.tags),
50214             area: Math.abs(entity.area(graph))
50215           };
50216         } else if (!areas[entity.id]) {
50217           areas[entity.id] = {
50218             entity,
50219             area: Math.abs(entity.area(graph))
50220           };
50221         }
50222       }
50223       var fills = Object.values(areas).filter(function hasPath(a2) {
50224         return path(a2.entity);
50225       });
50226       fills.sort(function areaSort(a2, b2) {
50227         return b2.area - a2.area;
50228       });
50229       fills = fills.map(function(a2) {
50230         return a2.entity;
50231       });
50232       var strokes = fills.filter(function(area) {
50233         return area.type === "way";
50234       });
50235       var data = {
50236         clip: fills,
50237         shadow: strokes,
50238         stroke: strokes,
50239         fill: fills
50240       };
50241       var clipPaths = context.surface().selectAll("defs").selectAll(".clipPath-osm").filter(filter2).data(data.clip, osmEntity.key);
50242       clipPaths.exit().remove();
50243       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-osm").attr("id", function(entity2) {
50244         return "ideditor-" + entity2.id + "-clippath";
50245       });
50246       clipPathsEnter.append("path");
50247       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", path);
50248       var drawLayer = selection2.selectAll(".layer-osm.areas");
50249       var touchLayer = selection2.selectAll(".layer-touch.areas");
50250       var areagroup = drawLayer.selectAll("g.areagroup").data(["fill", "shadow", "stroke"]);
50251       areagroup = areagroup.enter().append("g").attr("class", function(d2) {
50252         return "areagroup area-" + d2;
50253       }).merge(areagroup);
50254       var paths = areagroup.selectAll("path").filter(filter2).data(function(layer) {
50255         return data[layer];
50256       }, osmEntity.key);
50257       paths.exit().remove();
50258       var fillpaths = selection2.selectAll(".area-fill path.area").nodes();
50259       var bisect = bisector(function(node) {
50260         return -node.__data__.area(graph);
50261       }).left;
50262       function sortedByArea(entity2) {
50263         if (this._parent.__data__ === "fill") {
50264           return fillpaths[bisect(fillpaths, -entity2.area(graph))];
50265         }
50266       }
50267       paths = paths.enter().insert("path", sortedByArea).merge(paths).each(function(entity2) {
50268         var layer = this.parentNode.__data__;
50269         this.setAttribute("class", entity2.type + " area " + layer + " " + entity2.id);
50270         if (layer === "fill") {
50271           this.setAttribute("clip-path", "url(#ideditor-" + entity2.id + "-clippath)");
50272           this.style.fill = this.style.stroke = getPatternStyle(entity2.tags);
50273         }
50274       }).classed("added", function(d2) {
50275         return !base.entities[d2.id];
50276       }).classed("geometry-edited", function(d2) {
50277         return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal5.default)(graph.entities[d2.id].nodes, base.entities[d2.id].nodes);
50278       }).classed("retagged", function(d2) {
50279         return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal5.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
50280       }).call(svgTagClasses()).attr("d", path);
50281       touchLayer.call(drawTargets, graph, data.stroke, filter2);
50282     }
50283     return drawAreas;
50284   }
50285
50286   // modules/svg/data.js
50287   var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringify());
50288
50289   // node_modules/@tmcw/togeojson/dist/togeojson.es.mjs
50290   function $(element, tagName) {
50291     return Array.from(element.getElementsByTagName(tagName));
50292   }
50293   function normalizeId(id2) {
50294     return id2[0] === "#" ? id2 : "#".concat(id2);
50295   }
50296   function $ns(element, tagName, ns) {
50297     return Array.from(element.getElementsByTagNameNS(ns, tagName));
50298   }
50299   function nodeVal(node) {
50300     node == null ? void 0 : node.normalize();
50301     return node && node.textContent || "";
50302   }
50303   function get1(node, tagName, callback) {
50304     const n3 = node.getElementsByTagName(tagName);
50305     const result = n3.length ? n3[0] : null;
50306     if (result && callback)
50307       callback(result);
50308     return result;
50309   }
50310   function get3(node, tagName, callback) {
50311     const properties = {};
50312     if (!node)
50313       return properties;
50314     const n3 = node.getElementsByTagName(tagName);
50315     const result = n3.length ? n3[0] : null;
50316     if (result && callback) {
50317       return callback(result, properties);
50318     }
50319     return properties;
50320   }
50321   function val1(node, tagName, callback) {
50322     const val = nodeVal(get1(node, tagName));
50323     if (val && callback)
50324       return callback(val) || {};
50325     return {};
50326   }
50327   function $num(node, tagName, callback) {
50328     const val = parseFloat(nodeVal(get1(node, tagName)));
50329     if (isNaN(val))
50330       return void 0;
50331     if (val && callback)
50332       return callback(val) || {};
50333     return {};
50334   }
50335   function num1(node, tagName, callback) {
50336     const val = parseFloat(nodeVal(get1(node, tagName)));
50337     if (isNaN(val))
50338       return void 0;
50339     if (callback)
50340       callback(val);
50341     return val;
50342   }
50343   function getMulti(node, propertyNames) {
50344     const properties = {};
50345     for (const property of propertyNames) {
50346       val1(node, property, (val) => {
50347         properties[property] = val;
50348       });
50349     }
50350     return properties;
50351   }
50352   function isElement(node) {
50353     return (node == null ? void 0 : node.nodeType) === 1;
50354   }
50355   function getLineStyle(node) {
50356     return get3(node, "line", (lineStyle) => {
50357       const val = Object.assign({}, val1(lineStyle, "color", (color2) => {
50358         return { stroke: "#".concat(color2) };
50359       }), $num(lineStyle, "opacity", (opacity) => {
50360         return { "stroke-opacity": opacity };
50361       }), $num(lineStyle, "width", (width) => {
50362         return { "stroke-width": width * 96 / 25.4 };
50363       }));
50364       return val;
50365     });
50366   }
50367   function getExtensions(node) {
50368     let values = [];
50369     if (node === null)
50370       return values;
50371     for (const child of Array.from(node.childNodes)) {
50372       if (!isElement(child))
50373         continue;
50374       const name = abbreviateName(child.nodeName);
50375       if (name === "gpxtpx:TrackPointExtension") {
50376         values = values.concat(getExtensions(child));
50377       } else {
50378         const val = nodeVal(child);
50379         values.push([name, parseNumeric(val)]);
50380       }
50381     }
50382     return values;
50383   }
50384   function abbreviateName(name) {
50385     return ["heart", "gpxtpx:hr", "hr"].includes(name) ? "heart" : name;
50386   }
50387   function parseNumeric(val) {
50388     const num = parseFloat(val);
50389     return isNaN(num) ? val : num;
50390   }
50391   function coordPair$1(node) {
50392     const ll = [
50393       parseFloat(node.getAttribute("lon") || ""),
50394       parseFloat(node.getAttribute("lat") || "")
50395     ];
50396     if (isNaN(ll[0]) || isNaN(ll[1])) {
50397       return null;
50398     }
50399     num1(node, "ele", (val) => {
50400       ll.push(val);
50401     });
50402     const time = get1(node, "time");
50403     return {
50404       coordinates: ll,
50405       time: time ? nodeVal(time) : null,
50406       extendedValues: getExtensions(get1(node, "extensions"))
50407     };
50408   }
50409   function extractProperties(node) {
50410     var _a2;
50411     const properties = getMulti(node, [
50412       "name",
50413       "cmt",
50414       "desc",
50415       "type",
50416       "time",
50417       "keywords"
50418     ]);
50419     const extensions = Array.from(node.getElementsByTagNameNS("http://www.garmin.com/xmlschemas/GpxExtensions/v3", "*"));
50420     for (const child of extensions) {
50421       if (((_a2 = child.parentNode) == null ? void 0 : _a2.parentNode) === node) {
50422         properties[child.tagName.replace(":", "_")] = nodeVal(child);
50423       }
50424     }
50425     const links = $(node, "link");
50426     if (links.length) {
50427       properties.links = links.map((link3) => Object.assign({ href: link3.getAttribute("href") }, getMulti(link3, ["text", "type"])));
50428     }
50429     return properties;
50430   }
50431   function getPoints$1(node, pointname) {
50432     const pts = $(node, pointname);
50433     const line = [];
50434     const times = [];
50435     const extendedValues = {};
50436     for (let i3 = 0; i3 < pts.length; i3++) {
50437       const c2 = coordPair$1(pts[i3]);
50438       if (!c2) {
50439         continue;
50440       }
50441       line.push(c2.coordinates);
50442       if (c2.time)
50443         times.push(c2.time);
50444       for (const [name, val] of c2.extendedValues) {
50445         const plural = name === "heart" ? name : name.replace("gpxtpx:", "") + "s";
50446         if (!extendedValues[plural]) {
50447           extendedValues[plural] = Array(pts.length).fill(null);
50448         }
50449         extendedValues[plural][i3] = val;
50450       }
50451     }
50452     if (line.length < 2)
50453       return;
50454     return {
50455       line,
50456       times,
50457       extendedValues
50458     };
50459   }
50460   function getRoute(node) {
50461     const line = getPoints$1(node, "rtept");
50462     if (!line)
50463       return;
50464     return {
50465       type: "Feature",
50466       properties: Object.assign({ _gpxType: "rte" }, extractProperties(node), getLineStyle(get1(node, "extensions"))),
50467       geometry: {
50468         type: "LineString",
50469         coordinates: line.line
50470       }
50471     };
50472   }
50473   function getTrack(node) {
50474     const segments = $(node, "trkseg");
50475     const track = [];
50476     const times = [];
50477     const extractedLines = [];
50478     for (const segment of segments) {
50479       const line = getPoints$1(segment, "trkpt");
50480       if (line) {
50481         extractedLines.push(line);
50482         if (line.times && line.times.length)
50483           times.push(line.times);
50484       }
50485     }
50486     if (extractedLines.length === 0)
50487       return null;
50488     const multi = extractedLines.length > 1;
50489     const properties = Object.assign({ _gpxType: "trk" }, extractProperties(node), getLineStyle(get1(node, "extensions")), times.length ? {
50490       coordinateProperties: {
50491         times: multi ? times : times[0]
50492       }
50493     } : {});
50494     for (const line of extractedLines) {
50495       track.push(line.line);
50496       if (!properties.coordinateProperties) {
50497         properties.coordinateProperties = {};
50498       }
50499       const props = properties.coordinateProperties;
50500       const entries = Object.entries(line.extendedValues);
50501       for (let i3 = 0; i3 < entries.length; i3++) {
50502         const [name, val] = entries[i3];
50503         if (multi) {
50504           if (!props[name]) {
50505             props[name] = extractedLines.map((line2) => new Array(line2.line.length).fill(null));
50506           }
50507           props[name][i3] = val;
50508         } else {
50509           props[name] = val;
50510         }
50511       }
50512     }
50513     return {
50514       type: "Feature",
50515       properties,
50516       geometry: multi ? {
50517         type: "MultiLineString",
50518         coordinates: track
50519       } : {
50520         type: "LineString",
50521         coordinates: track[0]
50522       }
50523     };
50524   }
50525   function getPoint(node) {
50526     const properties = Object.assign(extractProperties(node), getMulti(node, ["sym"]));
50527     const pair3 = coordPair$1(node);
50528     if (!pair3)
50529       return null;
50530     return {
50531       type: "Feature",
50532       properties,
50533       geometry: {
50534         type: "Point",
50535         coordinates: pair3.coordinates
50536       }
50537     };
50538   }
50539   function* gpxGen(node) {
50540     for (const track of $(node, "trk")) {
50541       const feature3 = getTrack(track);
50542       if (feature3)
50543         yield feature3;
50544     }
50545     for (const route of $(node, "rte")) {
50546       const feature3 = getRoute(route);
50547       if (feature3)
50548         yield feature3;
50549     }
50550     for (const waypoint of $(node, "wpt")) {
50551       const point2 = getPoint(waypoint);
50552       if (point2)
50553         yield point2;
50554     }
50555   }
50556   function gpx(node) {
50557     return {
50558       type: "FeatureCollection",
50559       features: Array.from(gpxGen(node))
50560     };
50561   }
50562   function fixColor(v2, prefix) {
50563     const properties = {};
50564     const colorProp = prefix == "stroke" || prefix === "fill" ? prefix : prefix + "-color";
50565     if (v2[0] === "#") {
50566       v2 = v2.substring(1);
50567     }
50568     if (v2.length === 6 || v2.length === 3) {
50569       properties[colorProp] = "#" + v2;
50570     } else if (v2.length === 8) {
50571       properties[prefix + "-opacity"] = parseInt(v2.substring(0, 2), 16) / 255;
50572       properties[colorProp] = "#" + v2.substring(6, 8) + v2.substring(4, 6) + v2.substring(2, 4);
50573     }
50574     return properties;
50575   }
50576   function numericProperty(node, source, target) {
50577     const properties = {};
50578     num1(node, source, (val) => {
50579       properties[target] = val;
50580     });
50581     return properties;
50582   }
50583   function getColor(node, output) {
50584     return get3(node, "color", (elem) => fixColor(nodeVal(elem), output));
50585   }
50586   function extractIconHref(node) {
50587     return get3(node, "Icon", (icon2, properties) => {
50588       val1(icon2, "href", (href) => {
50589         properties.icon = href;
50590       });
50591       return properties;
50592     });
50593   }
50594   function extractIcon(node) {
50595     return get3(node, "IconStyle", (iconStyle) => {
50596       return Object.assign(getColor(iconStyle, "icon"), numericProperty(iconStyle, "scale", "icon-scale"), numericProperty(iconStyle, "heading", "icon-heading"), get3(iconStyle, "hotSpot", (hotspot) => {
50597         const left = parseFloat(hotspot.getAttribute("x") || "");
50598         const top = parseFloat(hotspot.getAttribute("y") || "");
50599         const xunits = hotspot.getAttribute("xunits") || "";
50600         const yunits = hotspot.getAttribute("yunits") || "";
50601         if (!isNaN(left) && !isNaN(top))
50602           return {
50603             "icon-offset": [left, top],
50604             "icon-offset-units": [xunits, yunits]
50605           };
50606         return {};
50607       }), extractIconHref(iconStyle));
50608     });
50609   }
50610   function extractLabel(node) {
50611     return get3(node, "LabelStyle", (labelStyle) => {
50612       return Object.assign(getColor(labelStyle, "label"), numericProperty(labelStyle, "scale", "label-scale"));
50613     });
50614   }
50615   function extractLine(node) {
50616     return get3(node, "LineStyle", (lineStyle) => {
50617       return Object.assign(getColor(lineStyle, "stroke"), numericProperty(lineStyle, "width", "stroke-width"));
50618     });
50619   }
50620   function extractPoly(node) {
50621     return get3(node, "PolyStyle", (polyStyle, properties) => {
50622       return Object.assign(properties, get3(polyStyle, "color", (elem) => fixColor(nodeVal(elem), "fill")), val1(polyStyle, "fill", (fill) => {
50623         if (fill === "0")
50624           return { "fill-opacity": 0 };
50625       }), val1(polyStyle, "outline", (outline) => {
50626         if (outline === "0")
50627           return { "stroke-opacity": 0 };
50628       }));
50629     });
50630   }
50631   function extractStyle(node) {
50632     return Object.assign({}, extractPoly(node), extractLine(node), extractLabel(node), extractIcon(node));
50633   }
50634   var toNumber2 = (x2) => Number(x2);
50635   var typeConverters = {
50636     string: (x2) => x2,
50637     int: toNumber2,
50638     uint: toNumber2,
50639     short: toNumber2,
50640     ushort: toNumber2,
50641     float: toNumber2,
50642     double: toNumber2,
50643     bool: (x2) => Boolean(x2)
50644   };
50645   function extractExtendedData(node, schema) {
50646     return get3(node, "ExtendedData", (extendedData, properties) => {
50647       for (const data of $(extendedData, "Data")) {
50648         properties[data.getAttribute("name") || ""] = nodeVal(get1(data, "value"));
50649       }
50650       for (const simpleData of $(extendedData, "SimpleData")) {
50651         const name = simpleData.getAttribute("name") || "";
50652         const typeConverter = schema[name] || typeConverters.string;
50653         properties[name] = typeConverter(nodeVal(simpleData));
50654       }
50655       return properties;
50656     });
50657   }
50658   function getMaybeHTMLDescription(node) {
50659     const descriptionNode = get1(node, "description");
50660     for (const c2 of Array.from((descriptionNode == null ? void 0 : descriptionNode.childNodes) || [])) {
50661       if (c2.nodeType === 4) {
50662         return {
50663           description: {
50664             "@type": "html",
50665             value: nodeVal(c2)
50666           }
50667         };
50668       }
50669     }
50670     return {};
50671   }
50672   function extractTimeSpan(node) {
50673     return get3(node, "TimeSpan", (timeSpan) => {
50674       return {
50675         timespan: {
50676           begin: nodeVal(get1(timeSpan, "begin")),
50677           end: nodeVal(get1(timeSpan, "end"))
50678         }
50679       };
50680     });
50681   }
50682   function extractTimeStamp(node) {
50683     return get3(node, "TimeStamp", (timeStamp) => {
50684       return { timestamp: nodeVal(get1(timeStamp, "when")) };
50685     });
50686   }
50687   function extractCascadedStyle(node, styleMap) {
50688     return val1(node, "styleUrl", (styleUrl) => {
50689       styleUrl = normalizeId(styleUrl);
50690       if (styleMap[styleUrl]) {
50691         return Object.assign({ styleUrl }, styleMap[styleUrl]);
50692       }
50693       return { styleUrl };
50694     });
50695   }
50696   var removeSpace = /\s*/g;
50697   var trimSpace = /^\s*|\s*$/g;
50698   var splitSpace = /\s+/;
50699   function coord1(value) {
50700     return value.replace(removeSpace, "").split(",").map(parseFloat).filter((num) => !isNaN(num)).slice(0, 3);
50701   }
50702   function coord(value) {
50703     return value.replace(trimSpace, "").split(splitSpace).map(coord1).filter((coord2) => {
50704       return coord2.length >= 2;
50705     });
50706   }
50707   function gxCoords(node) {
50708     let elems = $(node, "coord");
50709     if (elems.length === 0) {
50710       elems = $ns(node, "coord", "*");
50711     }
50712     const coordinates = elems.map((elem) => {
50713       return nodeVal(elem).split(" ").map(parseFloat);
50714     });
50715     if (coordinates.length === 0) {
50716       return null;
50717     }
50718     return {
50719       geometry: coordinates.length > 2 ? {
50720         type: "LineString",
50721         coordinates
50722       } : {
50723         type: "Point",
50724         coordinates: coordinates[0]
50725       },
50726       times: $(node, "when").map((elem) => nodeVal(elem))
50727     };
50728   }
50729   function fixRing(ring) {
50730     if (ring.length === 0)
50731       return ring;
50732     const first = ring[0];
50733     const last = ring[ring.length - 1];
50734     let equal = true;
50735     for (let i3 = 0; i3 < Math.max(first.length, last.length); i3++) {
50736       if (first[i3] !== last[i3]) {
50737         equal = false;
50738         break;
50739       }
50740     }
50741     if (!equal) {
50742       return ring.concat([ring[0]]);
50743     }
50744     return ring;
50745   }
50746   function getCoordinates(node) {
50747     return nodeVal(get1(node, "coordinates"));
50748   }
50749   function getGeometry(node) {
50750     let geometries = [];
50751     let coordTimes = [];
50752     for (let i3 = 0; i3 < node.childNodes.length; i3++) {
50753       const child = node.childNodes.item(i3);
50754       if (isElement(child)) {
50755         switch (child.tagName) {
50756           case "MultiGeometry":
50757           case "MultiTrack":
50758           case "gx:MultiTrack": {
50759             const childGeometries = getGeometry(child);
50760             geometries = geometries.concat(childGeometries.geometries);
50761             coordTimes = coordTimes.concat(childGeometries.coordTimes);
50762             break;
50763           }
50764           case "Point": {
50765             const coordinates = coord1(getCoordinates(child));
50766             if (coordinates.length >= 2) {
50767               geometries.push({
50768                 type: "Point",
50769                 coordinates
50770               });
50771             }
50772             break;
50773           }
50774           case "LinearRing":
50775           case "LineString": {
50776             const coordinates = coord(getCoordinates(child));
50777             if (coordinates.length >= 2) {
50778               geometries.push({
50779                 type: "LineString",
50780                 coordinates
50781               });
50782             }
50783             break;
50784           }
50785           case "Polygon": {
50786             const coords = [];
50787             for (const linearRing of $(child, "LinearRing")) {
50788               const ring = fixRing(coord(getCoordinates(linearRing)));
50789               if (ring.length >= 4) {
50790                 coords.push(ring);
50791               }
50792             }
50793             if (coords.length) {
50794               geometries.push({
50795                 type: "Polygon",
50796                 coordinates: coords
50797               });
50798             }
50799             break;
50800           }
50801           case "Track":
50802           case "gx:Track": {
50803             const gx = gxCoords(child);
50804             if (!gx)
50805               break;
50806             const { times, geometry } = gx;
50807             geometries.push(geometry);
50808             if (times.length)
50809               coordTimes.push(times);
50810             break;
50811           }
50812         }
50813       }
50814     }
50815     return {
50816       geometries,
50817       coordTimes
50818     };
50819   }
50820   function geometryListToGeometry(geometries) {
50821     return geometries.length === 0 ? null : geometries.length === 1 ? geometries[0] : {
50822       type: "GeometryCollection",
50823       geometries
50824     };
50825   }
50826   function getPlacemark(node, styleMap, schema, options2) {
50827     var _a2;
50828     const { coordTimes, geometries } = getGeometry(node);
50829     const geometry = geometryListToGeometry(geometries);
50830     if (!geometry && options2.skipNullGeometry) {
50831       return null;
50832     }
50833     const feature3 = {
50834       type: "Feature",
50835       geometry,
50836       properties: Object.assign(getMulti(node, [
50837         "name",
50838         "address",
50839         "visibility",
50840         "open",
50841         "phoneNumber",
50842         "description"
50843       ]), getMaybeHTMLDescription(node), extractCascadedStyle(node, styleMap), extractStyle(node), extractExtendedData(node, schema), extractTimeSpan(node), extractTimeStamp(node), coordTimes.length ? {
50844         coordinateProperties: {
50845           times: coordTimes.length === 1 ? coordTimes[0] : coordTimes
50846         }
50847       } : {})
50848     };
50849     if (((_a2 = feature3.properties) == null ? void 0 : _a2.visibility) !== void 0) {
50850       feature3.properties.visibility = feature3.properties.visibility !== "0";
50851     }
50852     const id2 = node.getAttribute("id");
50853     if (id2 !== null && id2 !== "")
50854       feature3.id = id2;
50855     return feature3;
50856   }
50857   function getGroundOverlayBox(node) {
50858     const latLonQuad = get1(node, "gx:LatLonQuad");
50859     if (latLonQuad) {
50860       const ring = fixRing(coord(getCoordinates(node)));
50861       return {
50862         geometry: {
50863           type: "Polygon",
50864           coordinates: [ring]
50865         }
50866       };
50867     }
50868     return getLatLonBox(node);
50869   }
50870   var DEGREES_TO_RADIANS = Math.PI / 180;
50871   function rotateBox(bbox2, coordinates, rotation) {
50872     const center = [(bbox2[0] + bbox2[2]) / 2, (bbox2[1] + bbox2[3]) / 2];
50873     return [
50874       coordinates[0].map((coordinate) => {
50875         const dy = coordinate[1] - center[1];
50876         const dx = coordinate[0] - center[0];
50877         const distance = Math.sqrt(Math.pow(dy, 2) + Math.pow(dx, 2));
50878         const angle2 = Math.atan2(dy, dx) + rotation * DEGREES_TO_RADIANS;
50879         return [
50880           center[0] + Math.cos(angle2) * distance,
50881           center[1] + Math.sin(angle2) * distance
50882         ];
50883       })
50884     ];
50885   }
50886   function getLatLonBox(node) {
50887     const latLonBox = get1(node, "LatLonBox");
50888     if (latLonBox) {
50889       const north = num1(latLonBox, "north");
50890       const west = num1(latLonBox, "west");
50891       const east = num1(latLonBox, "east");
50892       const south = num1(latLonBox, "south");
50893       const rotation = num1(latLonBox, "rotation");
50894       if (typeof north === "number" && typeof south === "number" && typeof west === "number" && typeof east === "number") {
50895         const bbox2 = [west, south, east, north];
50896         let coordinates = [
50897           [
50898             [west, north],
50899             [east, north],
50900             [east, south],
50901             [west, south],
50902             [west, north]
50903             // top left (again)
50904           ]
50905         ];
50906         if (typeof rotation === "number") {
50907           coordinates = rotateBox(bbox2, coordinates, rotation);
50908         }
50909         return {
50910           bbox: bbox2,
50911           geometry: {
50912             type: "Polygon",
50913             coordinates
50914           }
50915         };
50916       }
50917     }
50918     return null;
50919   }
50920   function getGroundOverlay(node, styleMap, schema, options2) {
50921     var _a2;
50922     const box = getGroundOverlayBox(node);
50923     const geometry = (box == null ? void 0 : box.geometry) || null;
50924     if (!geometry && options2.skipNullGeometry) {
50925       return null;
50926     }
50927     const feature3 = {
50928       type: "Feature",
50929       geometry,
50930       properties: Object.assign(
50931         /**
50932          * Related to
50933          * https://gist.github.com/tmcw/037a1cb6660d74a392e9da7446540f46
50934          */
50935         { "@geometry-type": "groundoverlay" },
50936         getMulti(node, [
50937           "name",
50938           "address",
50939           "visibility",
50940           "open",
50941           "phoneNumber",
50942           "description"
50943         ]),
50944         getMaybeHTMLDescription(node),
50945         extractCascadedStyle(node, styleMap),
50946         extractStyle(node),
50947         extractIconHref(node),
50948         extractExtendedData(node, schema),
50949         extractTimeSpan(node),
50950         extractTimeStamp(node)
50951       )
50952     };
50953     if (box == null ? void 0 : box.bbox) {
50954       feature3.bbox = box.bbox;
50955     }
50956     if (((_a2 = feature3.properties) == null ? void 0 : _a2.visibility) !== void 0) {
50957       feature3.properties.visibility = feature3.properties.visibility !== "0";
50958     }
50959     const id2 = node.getAttribute("id");
50960     if (id2 !== null && id2 !== "")
50961       feature3.id = id2;
50962     return feature3;
50963   }
50964   function getStyleId(style) {
50965     let id2 = style.getAttribute("id");
50966     const parentNode = style.parentNode;
50967     if (!id2 && isElement(parentNode) && parentNode.localName === "CascadingStyle") {
50968       id2 = parentNode.getAttribute("kml:id") || parentNode.getAttribute("id");
50969     }
50970     return normalizeId(id2 || "");
50971   }
50972   function buildStyleMap(node) {
50973     const styleMap = {};
50974     for (const style of $(node, "Style")) {
50975       styleMap[getStyleId(style)] = extractStyle(style);
50976     }
50977     for (const map2 of $(node, "StyleMap")) {
50978       const id2 = normalizeId(map2.getAttribute("id") || "");
50979       val1(map2, "styleUrl", (styleUrl) => {
50980         styleUrl = normalizeId(styleUrl);
50981         if (styleMap[styleUrl]) {
50982           styleMap[id2] = styleMap[styleUrl];
50983         }
50984       });
50985     }
50986     return styleMap;
50987   }
50988   function buildSchema(node) {
50989     const schema = {};
50990     for (const field of $(node, "SimpleField")) {
50991       schema[field.getAttribute("name") || ""] = typeConverters[field.getAttribute("type") || ""] || typeConverters["string"];
50992     }
50993     return schema;
50994   }
50995   function* kmlGen(node, options2 = {
50996     skipNullGeometry: false
50997   }) {
50998     const styleMap = buildStyleMap(node);
50999     const schema = buildSchema(node);
51000     for (const placemark of $(node, "Placemark")) {
51001       const feature3 = getPlacemark(placemark, styleMap, schema, options2);
51002       if (feature3)
51003         yield feature3;
51004     }
51005     for (const groundOverlay of $(node, "GroundOverlay")) {
51006       const feature3 = getGroundOverlay(groundOverlay, styleMap, schema, options2);
51007       if (feature3)
51008         yield feature3;
51009     }
51010   }
51011   function kml(node, options2 = {
51012     skipNullGeometry: false
51013   }) {
51014     return {
51015       type: "FeatureCollection",
51016       features: Array.from(kmlGen(node, options2))
51017     };
51018   }
51019
51020   // modules/svg/data.js
51021   var _initialized = false;
51022   var _enabled = false;
51023   var _geojson;
51024   function svgData(projection2, context, dispatch14) {
51025     var throttledRedraw = throttle_default(function() {
51026       dispatch14.call("change");
51027     }, 1e3);
51028     var _showLabels = true;
51029     var detected = utilDetect();
51030     var layer = select_default2(null);
51031     var _vtService;
51032     var _fileList;
51033     var _template;
51034     var _src;
51035     const supportedFormats = [
51036       ".gpx",
51037       ".kml",
51038       ".geojson",
51039       ".json"
51040     ];
51041     function init2() {
51042       if (_initialized)
51043         return;
51044       _geojson = {};
51045       _enabled = true;
51046       function over(d3_event) {
51047         d3_event.stopPropagation();
51048         d3_event.preventDefault();
51049         d3_event.dataTransfer.dropEffect = "copy";
51050       }
51051       context.container().attr("dropzone", "copy").on("drop.svgData", function(d3_event) {
51052         d3_event.stopPropagation();
51053         d3_event.preventDefault();
51054         if (!detected.filedrop)
51055           return;
51056         var f2 = d3_event.dataTransfer.files[0];
51057         var extension = getExtension(f2.name);
51058         if (!supportedFormats.includes(extension))
51059           return;
51060         drawData.fileList(d3_event.dataTransfer.files);
51061       }).on("dragenter.svgData", over).on("dragexit.svgData", over).on("dragover.svgData", over);
51062       _initialized = true;
51063     }
51064     function getService() {
51065       if (services.vectorTile && !_vtService) {
51066         _vtService = services.vectorTile;
51067         _vtService.event.on("loadedData", throttledRedraw);
51068       } else if (!services.vectorTile && _vtService) {
51069         _vtService = null;
51070       }
51071       return _vtService;
51072     }
51073     function showLayer() {
51074       layerOn();
51075       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
51076         dispatch14.call("change");
51077       });
51078     }
51079     function hideLayer() {
51080       throttledRedraw.cancel();
51081       layer.transition().duration(250).style("opacity", 0).on("end", layerOff);
51082     }
51083     function layerOn() {
51084       layer.style("display", "block");
51085     }
51086     function layerOff() {
51087       layer.selectAll(".viewfield-group").remove();
51088       layer.style("display", "none");
51089     }
51090     function ensureIDs(gj) {
51091       if (!gj)
51092         return null;
51093       if (gj.type === "FeatureCollection") {
51094         for (var i3 = 0; i3 < gj.features.length; i3++) {
51095           ensureFeatureID(gj.features[i3]);
51096         }
51097       } else {
51098         ensureFeatureID(gj);
51099       }
51100       return gj;
51101     }
51102     function ensureFeatureID(feature3) {
51103       if (!feature3)
51104         return;
51105       feature3.__featurehash__ = utilHashcode((0, import_fast_json_stable_stringify.default)(feature3));
51106       return feature3;
51107     }
51108     function getFeatures(gj) {
51109       if (!gj)
51110         return [];
51111       if (gj.type === "FeatureCollection") {
51112         return gj.features;
51113       } else {
51114         return [gj];
51115       }
51116     }
51117     function featureKey(d2) {
51118       return d2.__featurehash__;
51119     }
51120     function isPolygon(d2) {
51121       return d2.geometry.type === "Polygon" || d2.geometry.type === "MultiPolygon";
51122     }
51123     function clipPathID(d2) {
51124       return "ideditor-data-" + d2.__featurehash__ + "-clippath";
51125     }
51126     function featureClasses(d2) {
51127       return [
51128         "data" + d2.__featurehash__,
51129         d2.geometry.type,
51130         isPolygon(d2) ? "area" : "",
51131         d2.__layerID__ || ""
51132       ].filter(Boolean).join(" ");
51133     }
51134     function drawData(selection2) {
51135       var vtService = getService();
51136       var getPath = svgPath(projection2).geojson;
51137       var getAreaPath = svgPath(projection2, null, true).geojson;
51138       var hasData = drawData.hasData();
51139       layer = selection2.selectAll(".layer-mapdata").data(_enabled && hasData ? [0] : []);
51140       layer.exit().remove();
51141       layer = layer.enter().append("g").attr("class", "layer-mapdata").merge(layer);
51142       var surface = context.surface();
51143       if (!surface || surface.empty())
51144         return;
51145       var geoData, polygonData;
51146       if (_template && vtService) {
51147         var sourceID = _template;
51148         vtService.loadTiles(sourceID, _template, projection2);
51149         geoData = vtService.data(sourceID, projection2);
51150       } else {
51151         geoData = getFeatures(_geojson);
51152       }
51153       geoData = geoData.filter(getPath);
51154       polygonData = geoData.filter(isPolygon);
51155       var clipPaths = surface.selectAll("defs").selectAll(".clipPath-data").data(polygonData, featureKey);
51156       clipPaths.exit().remove();
51157       var clipPathsEnter = clipPaths.enter().append("clipPath").attr("class", "clipPath-data").attr("id", clipPathID);
51158       clipPathsEnter.append("path");
51159       clipPaths.merge(clipPathsEnter).selectAll("path").attr("d", getAreaPath);
51160       var datagroups = layer.selectAll("g.datagroup").data(["fill", "shadow", "stroke"]);
51161       datagroups = datagroups.enter().append("g").attr("class", function(d2) {
51162         return "datagroup datagroup-" + d2;
51163       }).merge(datagroups);
51164       var pathData = {
51165         fill: polygonData,
51166         shadow: geoData,
51167         stroke: geoData
51168       };
51169       var paths = datagroups.selectAll("path").data(function(layer2) {
51170         return pathData[layer2];
51171       }, featureKey);
51172       paths.exit().remove();
51173       paths = paths.enter().append("path").attr("class", function(d2) {
51174         var datagroup = this.parentNode.__data__;
51175         return "pathdata " + datagroup + " " + featureClasses(d2);
51176       }).attr("clip-path", function(d2) {
51177         var datagroup = this.parentNode.__data__;
51178         return datagroup === "fill" ? "url(#" + clipPathID(d2) + ")" : null;
51179       }).merge(paths).attr("d", function(d2) {
51180         var datagroup = this.parentNode.__data__;
51181         return datagroup === "fill" ? getAreaPath(d2) : getPath(d2);
51182       });
51183       layer.call(drawLabels, "label-halo", geoData).call(drawLabels, "label", geoData);
51184       function drawLabels(selection3, textClass, data) {
51185         var labelPath = path_default(projection2);
51186         var labelData = data.filter(function(d2) {
51187           return _showLabels && d2.properties && (d2.properties.desc || d2.properties.name);
51188         });
51189         var labels = selection3.selectAll("text." + textClass).data(labelData, featureKey);
51190         labels.exit().remove();
51191         labels = labels.enter().append("text").attr("class", function(d2) {
51192           return textClass + " " + featureClasses(d2);
51193         }).merge(labels).text(function(d2) {
51194           return d2.properties.desc || d2.properties.name;
51195         }).attr("x", function(d2) {
51196           var centroid = labelPath.centroid(d2);
51197           return centroid[0] + 11;
51198         }).attr("y", function(d2) {
51199           var centroid = labelPath.centroid(d2);
51200           return centroid[1];
51201         });
51202       }
51203     }
51204     function getExtension(fileName) {
51205       if (!fileName)
51206         return;
51207       var re3 = /\.(gpx|kml|(geo)?json|png)$/i;
51208       var match = fileName.toLowerCase().match(re3);
51209       return match && match.length && match[0];
51210     }
51211     function xmlToDom(textdata) {
51212       return new DOMParser().parseFromString(textdata, "text/xml");
51213     }
51214     function stringifyGeojsonProperties(feature3) {
51215       const properties = feature3.properties;
51216       for (const key in properties) {
51217         const property = properties[key];
51218         if (typeof property === "number" || typeof property === "boolean" || Array.isArray(property)) {
51219           properties[key] = property.toString();
51220         } else if (property === null) {
51221           properties[key] = "null";
51222         } else if (typeof property === "object") {
51223           properties[key] = JSON.stringify(property);
51224         }
51225       }
51226     }
51227     drawData.setFile = function(extension, data) {
51228       _template = null;
51229       _fileList = null;
51230       _geojson = null;
51231       _src = null;
51232       var gj;
51233       switch (extension) {
51234         case ".gpx":
51235           gj = gpx(xmlToDom(data));
51236           break;
51237         case ".kml":
51238           gj = kml(xmlToDom(data));
51239           break;
51240         case ".geojson":
51241         case ".json":
51242           gj = JSON.parse(data);
51243           if (gj.type === "FeatureCollection") {
51244             gj.features.forEach(stringifyGeojsonProperties);
51245           } else if (gj.type === "Feature") {
51246             stringifyGeojsonProperties(gj);
51247           }
51248           break;
51249       }
51250       gj = gj || {};
51251       if (Object.keys(gj).length) {
51252         _geojson = ensureIDs(gj);
51253         _src = extension + " data file";
51254         this.fitZoom();
51255       }
51256       dispatch14.call("change");
51257       return this;
51258     };
51259     drawData.showLabels = function(val) {
51260       if (!arguments.length)
51261         return _showLabels;
51262       _showLabels = val;
51263       return this;
51264     };
51265     drawData.enabled = function(val) {
51266       if (!arguments.length)
51267         return _enabled;
51268       _enabled = val;
51269       if (_enabled) {
51270         showLayer();
51271       } else {
51272         hideLayer();
51273       }
51274       dispatch14.call("change");
51275       return this;
51276     };
51277     drawData.hasData = function() {
51278       var gj = _geojson || {};
51279       return !!(_template || Object.keys(gj).length);
51280     };
51281     drawData.template = function(val, src) {
51282       if (!arguments.length)
51283         return _template;
51284       var osm = context.connection();
51285       if (osm) {
51286         var blocklists = osm.imageryBlocklists();
51287         var fail = false;
51288         var tested = 0;
51289         var regex;
51290         for (var i3 = 0; i3 < blocklists.length; i3++) {
51291           regex = blocklists[i3];
51292           fail = regex.test(val);
51293           tested++;
51294           if (fail)
51295             break;
51296         }
51297         if (!tested) {
51298           regex = /.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/;
51299           fail = regex.test(val);
51300         }
51301       }
51302       _template = val;
51303       _fileList = null;
51304       _geojson = null;
51305       _src = src || "vectortile:" + val.split(/[?#]/)[0];
51306       dispatch14.call("change");
51307       return this;
51308     };
51309     drawData.geojson = function(gj, src) {
51310       if (!arguments.length)
51311         return _geojson;
51312       _template = null;
51313       _fileList = null;
51314       _geojson = null;
51315       _src = null;
51316       gj = gj || {};
51317       if (Object.keys(gj).length) {
51318         _geojson = ensureIDs(gj);
51319         _src = src || "unknown.geojson";
51320       }
51321       dispatch14.call("change");
51322       return this;
51323     };
51324     drawData.fileList = function(fileList) {
51325       if (!arguments.length)
51326         return _fileList;
51327       _template = null;
51328       _geojson = null;
51329       _src = null;
51330       _fileList = fileList;
51331       if (!fileList || !fileList.length)
51332         return this;
51333       var f2 = fileList[0];
51334       var extension = getExtension(f2.name);
51335       var reader = new FileReader();
51336       reader.onload = /* @__PURE__ */ function() {
51337         return function(e3) {
51338           drawData.setFile(extension, e3.target.result);
51339         };
51340       }(f2);
51341       reader.readAsText(f2);
51342       return this;
51343     };
51344     drawData.url = function(url, defaultExtension) {
51345       _template = null;
51346       _fileList = null;
51347       _geojson = null;
51348       _src = null;
51349       var testUrl = url.split(/[?#]/)[0];
51350       var extension = getExtension(testUrl) || defaultExtension;
51351       if (extension) {
51352         _template = null;
51353         text_default3(url).then(function(data) {
51354           drawData.setFile(extension, data);
51355         }).catch(function() {
51356         });
51357       } else {
51358         drawData.template(url);
51359       }
51360       return this;
51361     };
51362     drawData.getSrc = function() {
51363       return _src || "";
51364     };
51365     drawData.fitZoom = function() {
51366       var features = getFeatures(_geojson);
51367       if (!features.length)
51368         return;
51369       var map2 = context.map();
51370       var viewport = map2.trimmedExtent().polygon();
51371       var coords = features.reduce(function(coords2, feature3) {
51372         var geom = feature3.geometry;
51373         if (!geom)
51374           return coords2;
51375         var c2 = geom.coordinates;
51376         switch (geom.type) {
51377           case "Point":
51378             c2 = [c2];
51379           case "MultiPoint":
51380           case "LineString":
51381             break;
51382           case "MultiPolygon":
51383             c2 = utilArrayFlatten(c2);
51384           case "Polygon":
51385           case "MultiLineString":
51386             c2 = utilArrayFlatten(c2);
51387             break;
51388         }
51389         return utilArrayUnion(coords2, c2);
51390       }, []);
51391       if (!geoPolygonIntersectsPolygon(viewport, coords, true)) {
51392         var extent = geoExtent(bounds_default({ type: "LineString", coordinates: coords }));
51393         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
51394       }
51395       return this;
51396     };
51397     init2();
51398     return drawData;
51399   }
51400
51401   // modules/svg/debug.js
51402   function svgDebug(projection2, context) {
51403     function drawDebug(selection2) {
51404       const showTile = context.getDebug("tile");
51405       const showCollision = context.getDebug("collision");
51406       const showImagery = context.getDebug("imagery");
51407       const showTouchTargets = context.getDebug("target");
51408       const showDownloaded = context.getDebug("downloaded");
51409       let debugData = [];
51410       if (showTile) {
51411         debugData.push({ class: "red", label: "tile" });
51412       }
51413       if (showCollision) {
51414         debugData.push({ class: "yellow", label: "collision" });
51415       }
51416       if (showImagery) {
51417         debugData.push({ class: "orange", label: "imagery" });
51418       }
51419       if (showTouchTargets) {
51420         debugData.push({ class: "pink", label: "touchTargets" });
51421       }
51422       if (showDownloaded) {
51423         debugData.push({ class: "purple", label: "downloaded" });
51424       }
51425       let legend = context.container().select(".main-content").selectAll(".debug-legend").data(debugData.length ? [0] : []);
51426       legend.exit().remove();
51427       legend = legend.enter().append("div").attr("class", "fillD debug-legend").merge(legend);
51428       let legendItems = legend.selectAll(".debug-legend-item").data(debugData, (d2) => d2.label);
51429       legendItems.exit().remove();
51430       legendItems.enter().append("span").attr("class", (d2) => "debug-legend-item ".concat(d2.class)).text((d2) => d2.label);
51431       let layer = selection2.selectAll(".layer-debug").data(showImagery || showDownloaded ? [0] : []);
51432       layer.exit().remove();
51433       layer = layer.enter().append("g").attr("class", "layer-debug").merge(layer);
51434       const extent = context.map().extent();
51435       _mainFileFetcher.get("imagery").then((d2) => {
51436         const hits = showImagery && d2.query.bbox(extent.rectangle(), true) || [];
51437         const features = hits.map((d4) => d4.features[d4.id]);
51438         let imagery = layer.selectAll("path.debug-imagery").data(features);
51439         imagery.exit().remove();
51440         imagery.enter().append("path").attr("class", "debug-imagery debug orange");
51441       }).catch(() => {
51442       });
51443       const osm = context.connection();
51444       let dataDownloaded = [];
51445       if (osm && showDownloaded) {
51446         const rtree = osm.caches("get").tile.rtree;
51447         dataDownloaded = rtree.all().map((bbox2) => {
51448           return {
51449             type: "Feature",
51450             properties: { id: bbox2.id },
51451             geometry: {
51452               type: "Polygon",
51453               coordinates: [[
51454                 [bbox2.minX, bbox2.minY],
51455                 [bbox2.minX, bbox2.maxY],
51456                 [bbox2.maxX, bbox2.maxY],
51457                 [bbox2.maxX, bbox2.minY],
51458                 [bbox2.minX, bbox2.minY]
51459               ]]
51460             }
51461           };
51462         });
51463       }
51464       let downloaded = layer.selectAll("path.debug-downloaded").data(showDownloaded ? dataDownloaded : []);
51465       downloaded.exit().remove();
51466       downloaded.enter().append("path").attr("class", "debug-downloaded debug purple");
51467       layer.selectAll("path").attr("d", svgPath(projection2).geojson);
51468     }
51469     drawDebug.enabled = function() {
51470       if (!arguments.length) {
51471         return context.getDebug("tile") || context.getDebug("collision") || context.getDebug("imagery") || context.getDebug("target") || context.getDebug("downloaded");
51472       } else {
51473         return this;
51474       }
51475     };
51476     return drawDebug;
51477   }
51478
51479   // modules/svg/defs.js
51480   function svgDefs(context) {
51481     var _defsSelection = select_default2(null);
51482     var _spritesheetIds = [
51483       "iD-sprite",
51484       "maki-sprite",
51485       "temaki-sprite",
51486       "fa-sprite",
51487       "roentgen-sprite",
51488       "community-sprite"
51489     ];
51490     function drawDefs(selection2) {
51491       _defsSelection = selection2.append("defs");
51492       _defsSelection.append("marker").attr("id", "ideditor-oneway-marker").attr("viewBox", "0 0 10 5").attr("refX", 2.5).attr("refY", 2.5).attr("markerWidth", 2).attr("markerHeight", 2).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "oneway-marker-path").attr("d", "M 5,3 L 0,3 L 0,2 L 5,2 L 5,0 L 10,2.5 L 5,5 z").attr("stroke", "none").attr("fill", "#000").attr("opacity", "0.75");
51493       function addSidedMarker(name, color2, offset) {
51494         _defsSelection.append("marker").attr("id", "ideditor-sided-marker-" + name).attr("viewBox", "0 0 2 2").attr("refX", 1).attr("refY", -offset).attr("markerWidth", 1.5).attr("markerHeight", 1.5).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "sided-marker-path sided-marker-" + name + "-path").attr("d", "M 0,0 L 1,1 L 2,0 z").attr("stroke", "none").attr("fill", color2);
51495       }
51496       addSidedMarker("natural", "rgb(170, 170, 170)", 0);
51497       addSidedMarker("coastline", "#77dede", 1);
51498       addSidedMarker("waterway", "#77dede", 1);
51499       addSidedMarker("barrier", "#ddd", 1);
51500       addSidedMarker("man_made", "#fff", 0);
51501       _defsSelection.append("marker").attr("id", "ideditor-viewfield-marker").attr("viewBox", "0 0 16 16").attr("refX", 8).attr("refY", 16).attr("markerWidth", 4).attr("markerHeight", 4).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "viewfield-marker-path").attr("d", "M 6,14 C 8,13.4 8,13.4 10,14 L 16,3 C 12,0 4,0 0,3 z").attr("fill", "#333").attr("fill-opacity", "0.75").attr("stroke", "#fff").attr("stroke-width", "0.5px").attr("stroke-opacity", "0.75");
51502       _defsSelection.append("marker").attr("id", "ideditor-viewfield-marker-wireframe").attr("viewBox", "0 0 16 16").attr("refX", 8).attr("refY", 16).attr("markerWidth", 4).attr("markerHeight", 4).attr("markerUnits", "strokeWidth").attr("orient", "auto").append("path").attr("class", "viewfield-marker-path").attr("d", "M 6,14 C 8,13.4 8,13.4 10,14 L 16,3 C 12,0 4,0 0,3 z").attr("fill", "none").attr("stroke", "#fff").attr("stroke-width", "0.5px").attr("stroke-opacity", "0.75");
51503       var patterns2 = _defsSelection.selectAll("pattern").data([
51504         // pattern name, pattern image name
51505         ["beach", "dots"],
51506         ["construction", "construction"],
51507         ["cemetery", "cemetery"],
51508         ["cemetery_christian", "cemetery_christian"],
51509         ["cemetery_buddhist", "cemetery_buddhist"],
51510         ["cemetery_muslim", "cemetery_muslim"],
51511         ["cemetery_jewish", "cemetery_jewish"],
51512         ["farmland", "farmland"],
51513         ["farmyard", "farmyard"],
51514         ["forest", "forest"],
51515         ["forest_broadleaved", "forest_broadleaved"],
51516         ["forest_needleleaved", "forest_needleleaved"],
51517         ["forest_leafless", "forest_leafless"],
51518         ["golf_green", "grass"],
51519         ["grass", "grass"],
51520         ["landfill", "landfill"],
51521         ["meadow", "grass"],
51522         ["orchard", "orchard"],
51523         ["pond", "pond"],
51524         ["quarry", "quarry"],
51525         ["scrub", "bushes"],
51526         ["vineyard", "vineyard"],
51527         ["water_standing", "lines"],
51528         ["waves", "waves"],
51529         ["wetland", "wetland"],
51530         ["wetland_marsh", "wetland_marsh"],
51531         ["wetland_swamp", "wetland_swamp"],
51532         ["wetland_bog", "wetland_bog"],
51533         ["wetland_reedbed", "wetland_reedbed"]
51534       ]).enter().append("pattern").attr("id", function(d2) {
51535         return "ideditor-pattern-" + d2[0];
51536       }).attr("width", 32).attr("height", 32).attr("patternUnits", "userSpaceOnUse");
51537       patterns2.append("rect").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("class", function(d2) {
51538         return "pattern-color-" + d2[0];
51539       });
51540       patterns2.append("image").attr("x", 0).attr("y", 0).attr("width", 32).attr("height", 32).attr("xlink:href", function(d2) {
51541         return context.imagePath("pattern/" + d2[1] + ".png");
51542       });
51543       _defsSelection.selectAll("clipPath").data([12, 18, 20, 32, 45]).enter().append("clipPath").attr("id", function(d2) {
51544         return "ideditor-clip-square-" + d2;
51545       }).append("rect").attr("x", 0).attr("y", 0).attr("width", function(d2) {
51546         return d2;
51547       }).attr("height", function(d2) {
51548         return d2;
51549       });
51550       addSprites(_spritesheetIds, true);
51551     }
51552     function addSprites(ids, overrideColors) {
51553       _spritesheetIds = utilArrayUniq(_spritesheetIds.concat(ids));
51554       var spritesheets = _defsSelection.selectAll(".spritesheet").data(_spritesheetIds);
51555       spritesheets.enter().append("g").attr("class", function(d2) {
51556         return "spritesheet spritesheet-" + d2;
51557       }).each(function(d2) {
51558         var url = context.imagePath(d2 + ".svg");
51559         var node = select_default2(this).node();
51560         svg(url).then(function(svg2) {
51561           node.appendChild(
51562             select_default2(svg2.documentElement).attr("id", "ideditor-" + d2).node()
51563           );
51564           if (overrideColors && d2 !== "iD-sprite") {
51565             select_default2(node).selectAll("path").attr("fill", "currentColor");
51566           }
51567         }).catch(function() {
51568         });
51569       });
51570       spritesheets.exit().remove();
51571     }
51572     drawDefs.addSprites = addSprites;
51573     return drawDefs;
51574   }
51575
51576   // modules/svg/keepRight.js
51577   var _layerEnabled = false;
51578   var _qaService;
51579   function svgKeepRight(projection2, context, dispatch14) {
51580     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
51581     const minZoom4 = 12;
51582     let touchLayer = select_default2(null);
51583     let drawLayer = select_default2(null);
51584     let layerVisible = false;
51585     function markerPath(selection2, klass) {
51586       selection2.attr("class", klass).attr("transform", "translate(-4, -24)").attr("d", "M11.6,6.2H7.1l1.4-5.1C8.6,0.6,8.1,0,7.5,0H2.2C1.7,0,1.3,0.3,1.3,0.8L0,10.2c-0.1,0.6,0.4,1.1,0.9,1.1h4.6l-1.8,7.6C3.6,19.4,4.1,20,4.7,20c0.3,0,0.6-0.2,0.8-0.5l6.9-11.9C12.7,7,12.3,6.2,11.6,6.2z");
51587     }
51588     function getService() {
51589       if (services.keepRight && !_qaService) {
51590         _qaService = services.keepRight;
51591         _qaService.on("loaded", throttledRedraw);
51592       } else if (!services.keepRight && _qaService) {
51593         _qaService = null;
51594       }
51595       return _qaService;
51596     }
51597     function editOn() {
51598       if (!layerVisible) {
51599         layerVisible = true;
51600         drawLayer.style("display", "block");
51601       }
51602     }
51603     function editOff() {
51604       if (layerVisible) {
51605         layerVisible = false;
51606         drawLayer.style("display", "none");
51607         drawLayer.selectAll(".qaItem.keepRight").remove();
51608         touchLayer.selectAll(".qaItem.keepRight").remove();
51609       }
51610     }
51611     function layerOn() {
51612       editOn();
51613       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
51614     }
51615     function layerOff() {
51616       throttledRedraw.cancel();
51617       drawLayer.interrupt();
51618       touchLayer.selectAll(".qaItem.keepRight").remove();
51619       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
51620         editOff();
51621         dispatch14.call("change");
51622       });
51623     }
51624     function updateMarkers() {
51625       if (!layerVisible || !_layerEnabled)
51626         return;
51627       const service = getService();
51628       const selectedID = context.selectedErrorID();
51629       const data = service ? service.getItems(projection2) : [];
51630       const getTransform = svgPointTransform(projection2);
51631       const markers = drawLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
51632       markers.exit().remove();
51633       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.parentIssueType));
51634       markersEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
51635       markersEnter.append("path").call(markerPath, "shadow");
51636       markersEnter.append("use").attr("class", "qaItem-fill").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").attr("xlink:href", "#iD-icon-bolt");
51637       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
51638       if (touchLayer.empty())
51639         return;
51640       const fillClass = context.getDebug("target") ? "pink " : "nocolor ";
51641       const targets = touchLayer.selectAll(".qaItem.keepRight").data(data, (d2) => d2.id);
51642       targets.exit().remove();
51643       targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", (d2) => "qaItem ".concat(d2.service, " target ").concat(fillClass, " itemId-").concat(d2.id)).attr("transform", getTransform);
51644       function sortY(a2, b2) {
51645         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : a2.severity === "error" && b2.severity !== "error" ? 1 : b2.severity === "error" && a2.severity !== "error" ? -1 : b2.loc[1] - a2.loc[1];
51646       }
51647     }
51648     function drawKeepRight(selection2) {
51649       const service = getService();
51650       const surface = context.surface();
51651       if (surface && !surface.empty()) {
51652         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
51653       }
51654       drawLayer = selection2.selectAll(".layer-keepRight").data(service ? [0] : []);
51655       drawLayer.exit().remove();
51656       drawLayer = drawLayer.enter().append("g").attr("class", "layer-keepRight").style("display", _layerEnabled ? "block" : "none").merge(drawLayer);
51657       if (_layerEnabled) {
51658         if (service && ~~context.map().zoom() >= minZoom4) {
51659           editOn();
51660           service.loadIssues(projection2);
51661           updateMarkers();
51662         } else {
51663           editOff();
51664         }
51665       }
51666     }
51667     drawKeepRight.enabled = function(val) {
51668       if (!arguments.length)
51669         return _layerEnabled;
51670       _layerEnabled = val;
51671       if (_layerEnabled) {
51672         layerOn();
51673       } else {
51674         layerOff();
51675         if (context.selectedErrorID()) {
51676           context.enter(modeBrowse(context));
51677         }
51678       }
51679       dispatch14.call("change");
51680       return this;
51681     };
51682     drawKeepRight.supported = () => !!getService();
51683     return drawKeepRight;
51684   }
51685
51686   // modules/svg/geolocate.js
51687   function svgGeolocate(projection2) {
51688     var layer = select_default2(null);
51689     var _position;
51690     function init2() {
51691       if (svgGeolocate.initialized)
51692         return;
51693       svgGeolocate.enabled = false;
51694       svgGeolocate.initialized = true;
51695     }
51696     function showLayer() {
51697       layer.style("display", "block");
51698     }
51699     function hideLayer() {
51700       layer.transition().duration(250).style("opacity", 0);
51701     }
51702     function layerOn() {
51703       layer.style("opacity", 0).transition().duration(250).style("opacity", 1);
51704     }
51705     function layerOff() {
51706       layer.style("display", "none");
51707     }
51708     function transform2(d2) {
51709       return svgPointTransform(projection2)(d2);
51710     }
51711     function accuracy(accuracy2, loc) {
51712       var degreesRadius = geoMetersToLat(accuracy2), tangentLoc = [loc[0], loc[1] + degreesRadius], projectedTangent = projection2(tangentLoc), projectedLoc = projection2([loc[0], loc[1]]);
51713       return Math.round(projectedLoc[1] - projectedTangent[1]).toString();
51714     }
51715     function update() {
51716       var geolocation = { loc: [_position.coords.longitude, _position.coords.latitude] };
51717       var groups = layer.selectAll(".geolocations").selectAll(".geolocation").data([geolocation]);
51718       groups.exit().remove();
51719       var pointsEnter = groups.enter().append("g").attr("class", "geolocation");
51720       pointsEnter.append("circle").attr("class", "geolocate-radius").attr("dx", "0").attr("dy", "0").attr("fill", "rgb(15,128,225)").attr("fill-opacity", "0.3").attr("r", "0");
51721       pointsEnter.append("circle").attr("dx", "0").attr("dy", "0").attr("fill", "rgb(15,128,225)").attr("stroke", "white").attr("stroke-width", "1.5").attr("r", "6");
51722       groups.merge(pointsEnter).attr("transform", transform2);
51723       layer.select(".geolocate-radius").attr("r", accuracy(_position.coords.accuracy, geolocation.loc));
51724     }
51725     function drawLocation(selection2) {
51726       var enabled = svgGeolocate.enabled;
51727       layer = selection2.selectAll(".layer-geolocate").data([0]);
51728       layer.exit().remove();
51729       var layerEnter = layer.enter().append("g").attr("class", "layer-geolocate").style("display", enabled ? "block" : "none");
51730       layerEnter.append("g").attr("class", "geolocations");
51731       layer = layerEnter.merge(layer);
51732       if (enabled) {
51733         update();
51734       } else {
51735         layerOff();
51736       }
51737     }
51738     drawLocation.enabled = function(position, enabled) {
51739       if (!arguments.length)
51740         return svgGeolocate.enabled;
51741       _position = position;
51742       svgGeolocate.enabled = enabled;
51743       if (svgGeolocate.enabled) {
51744         showLayer();
51745         layerOn();
51746       } else {
51747         hideLayer();
51748       }
51749       return this;
51750     };
51751     init2();
51752     return drawLocation;
51753   }
51754
51755   // modules/svg/labels.js
51756   var import_rbush6 = __toESM(require_rbush_min());
51757   function svgLabels(projection2, context) {
51758     var path = path_default(projection2);
51759     var detected = utilDetect();
51760     var baselineHack = detected.ie || detected.browser.toLowerCase() === "edge" || detected.browser.toLowerCase() === "firefox" && detected.version >= 70;
51761     var _rdrawn = new import_rbush6.default();
51762     var _rskipped = new import_rbush6.default();
51763     var _textWidthCache = {};
51764     var _entitybboxes = {};
51765     var labelStack = [
51766       ["line", "aeroway", "*", 12],
51767       ["line", "highway", "motorway", 12],
51768       ["line", "highway", "trunk", 12],
51769       ["line", "highway", "primary", 12],
51770       ["line", "highway", "secondary", 12],
51771       ["line", "highway", "tertiary", 12],
51772       ["line", "highway", "*", 12],
51773       ["line", "railway", "*", 12],
51774       ["line", "waterway", "*", 12],
51775       ["area", "aeroway", "*", 12],
51776       ["area", "amenity", "*", 12],
51777       ["area", "building", "*", 12],
51778       ["area", "historic", "*", 12],
51779       ["area", "leisure", "*", 12],
51780       ["area", "man_made", "*", 12],
51781       ["area", "natural", "*", 12],
51782       ["area", "shop", "*", 12],
51783       ["area", "tourism", "*", 12],
51784       ["area", "camp_site", "*", 12],
51785       ["point", "aeroway", "*", 10],
51786       ["point", "amenity", "*", 10],
51787       ["point", "building", "*", 10],
51788       ["point", "historic", "*", 10],
51789       ["point", "leisure", "*", 10],
51790       ["point", "man_made", "*", 10],
51791       ["point", "natural", "*", 10],
51792       ["point", "shop", "*", 10],
51793       ["point", "tourism", "*", 10],
51794       ["point", "camp_site", "*", 10],
51795       ["line", "ref", "*", 12],
51796       ["area", "ref", "*", 12],
51797       ["point", "ref", "*", 10],
51798       ["line", "name", "*", 12],
51799       ["area", "name", "*", 12],
51800       ["point", "name", "*", 10]
51801     ];
51802     function shouldSkipIcon(preset) {
51803       var noIcons = ["building", "landuse", "natural"];
51804       return noIcons.some(function(s2) {
51805         return preset.id.indexOf(s2) >= 0;
51806       });
51807     }
51808     function get4(array2, prop) {
51809       return function(d2, i3) {
51810         return array2[i3][prop];
51811       };
51812     }
51813     function textWidth(text, size, elem) {
51814       var c2 = _textWidthCache[size];
51815       if (!c2)
51816         c2 = _textWidthCache[size] = {};
51817       if (c2[text]) {
51818         return c2[text];
51819       } else if (elem) {
51820         c2[text] = elem.getComputedTextLength();
51821         return c2[text];
51822       } else {
51823         var str = encodeURIComponent(text).match(/%[CDEFcdef]/g);
51824         if (str === null) {
51825           return size / 3 * 2 * text.length;
51826         } else {
51827           return size / 3 * (2 * text.length + str.length);
51828         }
51829       }
51830     }
51831     function drawLinePaths(selection2, entities, filter2, classes, labels) {
51832       var paths = selection2.selectAll("path").filter(filter2).data(entities, osmEntity.key);
51833       paths.exit().remove();
51834       paths.enter().append("path").style("stroke-width", get4(labels, "font-size")).attr("id", function(d2) {
51835         return "ideditor-labelpath-" + d2.id;
51836       }).attr("class", classes).merge(paths).attr("d", get4(labels, "lineString"));
51837     }
51838     function drawLineLabels(selection2, entities, filter2, classes, labels) {
51839       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
51840       texts.exit().remove();
51841       texts.enter().append("text").attr("class", function(d2, i3) {
51842         return classes + " " + labels[i3].classes + " " + d2.id;
51843       }).attr("dy", baselineHack ? "0.35em" : null).append("textPath").attr("class", "textpath");
51844       selection2.selectAll("text." + classes).selectAll(".textpath").filter(filter2).data(entities, osmEntity.key).attr("startOffset", "50%").attr("xlink:href", function(d2) {
51845         return "#ideditor-labelpath-" + d2.id;
51846       }).text(utilDisplayNameForPath);
51847     }
51848     function drawPointLabels(selection2, entities, filter2, classes, labels) {
51849       var texts = selection2.selectAll("text." + classes).filter(filter2).data(entities, osmEntity.key);
51850       texts.exit().remove();
51851       texts.enter().append("text").attr("class", function(d2, i3) {
51852         return classes + " " + labels[i3].classes + " " + d2.id;
51853       }).merge(texts).attr("x", get4(labels, "x")).attr("y", get4(labels, "y")).style("text-anchor", get4(labels, "textAnchor")).text(utilDisplayName).each(function(d2, i3) {
51854         textWidth(utilDisplayName(d2), labels[i3].height, this);
51855       });
51856     }
51857     function drawAreaLabels(selection2, entities, filter2, classes, labels) {
51858       entities = entities.filter(hasText);
51859       labels = labels.filter(hasText);
51860       drawPointLabels(selection2, entities, filter2, classes, labels);
51861       function hasText(d2, i3) {
51862         return labels[i3].hasOwnProperty("x") && labels[i3].hasOwnProperty("y");
51863       }
51864     }
51865     function drawAreaIcons(selection2, entities, filter2, classes, labels) {
51866       var icons = selection2.selectAll("use." + classes).filter(filter2).data(entities, osmEntity.key);
51867       icons.exit().remove();
51868       icons.enter().append("use").attr("class", "icon " + classes).attr("width", "17px").attr("height", "17px").merge(icons).attr("transform", get4(labels, "transform")).attr("xlink:href", function(d2) {
51869         var preset = _mainPresetIndex.match(d2, context.graph());
51870         var picon = preset && preset.icon;
51871         return picon ? "#" + picon : "";
51872       });
51873     }
51874     function drawCollisionBoxes(selection2, rtree, which) {
51875       var classes = "debug " + which + " " + (which === "debug-skipped" ? "orange" : "yellow");
51876       var gj = [];
51877       if (context.getDebug("collision")) {
51878         gj = rtree.all().map(function(d2) {
51879           return { type: "Polygon", coordinates: [[
51880             [d2.minX, d2.minY],
51881             [d2.maxX, d2.minY],
51882             [d2.maxX, d2.maxY],
51883             [d2.minX, d2.maxY],
51884             [d2.minX, d2.minY]
51885           ]] };
51886         });
51887       }
51888       var boxes = selection2.selectAll("." + which).data(gj);
51889       boxes.exit().remove();
51890       boxes.enter().append("path").attr("class", classes).merge(boxes).attr("d", path_default());
51891     }
51892     function drawLabels(selection2, graph, entities, filter2, dimensions, fullRedraw) {
51893       var wireframe = context.surface().classed("fill-wireframe");
51894       var zoom = geoScaleToZoom(projection2.scale());
51895       var labelable = [];
51896       var renderNodeAs = {};
51897       var i3, j2, k2, entity, geometry;
51898       for (i3 = 0; i3 < labelStack.length; i3++) {
51899         labelable.push([]);
51900       }
51901       if (fullRedraw) {
51902         _rdrawn.clear();
51903         _rskipped.clear();
51904         _entitybboxes = {};
51905       } else {
51906         for (i3 = 0; i3 < entities.length; i3++) {
51907           entity = entities[i3];
51908           var toRemove = [].concat(_entitybboxes[entity.id] || []).concat(_entitybboxes[entity.id + "I"] || []);
51909           for (j2 = 0; j2 < toRemove.length; j2++) {
51910             _rdrawn.remove(toRemove[j2]);
51911             _rskipped.remove(toRemove[j2]);
51912           }
51913         }
51914       }
51915       for (i3 = 0; i3 < entities.length; i3++) {
51916         entity = entities[i3];
51917         geometry = entity.geometry(graph);
51918         if (geometry === "point" || geometry === "vertex" && isInterestingVertex(entity)) {
51919           var hasDirections = entity.directions(graph, projection2).length;
51920           var markerPadding;
51921           if (!wireframe && geometry === "point" && !(zoom >= 18 && hasDirections)) {
51922             renderNodeAs[entity.id] = "point";
51923             markerPadding = 20;
51924           } else {
51925             renderNodeAs[entity.id] = "vertex";
51926             markerPadding = 0;
51927           }
51928           var coord2 = projection2(entity.loc);
51929           var nodePadding = 10;
51930           var bbox2 = {
51931             minX: coord2[0] - nodePadding,
51932             minY: coord2[1] - nodePadding - markerPadding,
51933             maxX: coord2[0] + nodePadding,
51934             maxY: coord2[1] + nodePadding
51935           };
51936           doInsert(bbox2, entity.id + "P");
51937         }
51938         if (geometry === "vertex") {
51939           geometry = "point";
51940         }
51941         var preset = geometry === "area" && _mainPresetIndex.match(entity, graph);
51942         var icon2 = preset && !shouldSkipIcon(preset) && preset.icon;
51943         if (!icon2 && !utilDisplayName(entity))
51944           continue;
51945         for (k2 = 0; k2 < labelStack.length; k2++) {
51946           var matchGeom = labelStack[k2][0];
51947           var matchKey = labelStack[k2][1];
51948           var matchVal = labelStack[k2][2];
51949           var hasVal = entity.tags[matchKey];
51950           if (geometry === matchGeom && hasVal && (matchVal === "*" || matchVal === hasVal)) {
51951             labelable[k2].push(entity);
51952             break;
51953           }
51954         }
51955       }
51956       var positions = {
51957         point: [],
51958         line: [],
51959         area: []
51960       };
51961       var labelled = {
51962         point: [],
51963         line: [],
51964         area: []
51965       };
51966       for (k2 = 0; k2 < labelable.length; k2++) {
51967         var fontSize = labelStack[k2][3];
51968         for (i3 = 0; i3 < labelable[k2].length; i3++) {
51969           entity = labelable[k2][i3];
51970           geometry = entity.geometry(graph);
51971           var getName = geometry === "line" ? utilDisplayNameForPath : utilDisplayName;
51972           var name = getName(entity);
51973           var width = name && textWidth(name, fontSize);
51974           var p2 = null;
51975           if (geometry === "point" || geometry === "vertex") {
51976             if (wireframe)
51977               continue;
51978             var renderAs = renderNodeAs[entity.id];
51979             if (renderAs === "vertex" && zoom < 17)
51980               continue;
51981             p2 = getPointLabel(entity, width, fontSize, renderAs);
51982           } else if (geometry === "line") {
51983             p2 = getLineLabel(entity, width, fontSize);
51984           } else if (geometry === "area") {
51985             p2 = getAreaLabel(entity, width, fontSize);
51986           }
51987           if (p2) {
51988             if (geometry === "vertex") {
51989               geometry = "point";
51990             }
51991             p2.classes = geometry + " tag-" + labelStack[k2][1];
51992             positions[geometry].push(p2);
51993             labelled[geometry].push(entity);
51994           }
51995         }
51996       }
51997       function isInterestingVertex(entity2) {
51998         var selectedIDs = context.selectedIDs();
51999         return entity2.hasInterestingTags() || entity2.isEndpoint(graph) || entity2.isConnected(graph) || selectedIDs.indexOf(entity2.id) !== -1 || graph.parentWays(entity2).some(function(parent) {
52000           return selectedIDs.indexOf(parent.id) !== -1;
52001         });
52002       }
52003       function getPointLabel(entity2, width2, height, geometry2) {
52004         var y2 = geometry2 === "point" ? -12 : 0;
52005         var pointOffsets = {
52006           ltr: [15, y2, "start"],
52007           rtl: [-15, y2, "end"]
52008         };
52009         var textDirection = _mainLocalizer.textDirection();
52010         var coord3 = projection2(entity2.loc);
52011         var textPadding = 2;
52012         var offset = pointOffsets[textDirection];
52013         var p3 = {
52014           height,
52015           width: width2,
52016           x: coord3[0] + offset[0],
52017           y: coord3[1] + offset[1],
52018           textAnchor: offset[2]
52019         };
52020         var bbox3;
52021         if (textDirection === "rtl") {
52022           bbox3 = {
52023             minX: p3.x - width2 - textPadding,
52024             minY: p3.y - height / 2 - textPadding,
52025             maxX: p3.x + textPadding,
52026             maxY: p3.y + height / 2 + textPadding
52027           };
52028         } else {
52029           bbox3 = {
52030             minX: p3.x - textPadding,
52031             minY: p3.y - height / 2 - textPadding,
52032             maxX: p3.x + width2 + textPadding,
52033             maxY: p3.y + height / 2 + textPadding
52034           };
52035         }
52036         if (tryInsert([bbox3], entity2.id, true)) {
52037           return p3;
52038         }
52039       }
52040       function getLineLabel(entity2, width2, height) {
52041         var viewport = geoExtent(context.projection.clipExtent()).polygon();
52042         var points = graph.childNodes(entity2).map(function(node) {
52043           return projection2(node.loc);
52044         });
52045         var length2 = geoPathLength(points);
52046         if (length2 < width2 + 20)
52047           return;
52048         var lineOffsets = [
52049           50,
52050           45,
52051           55,
52052           40,
52053           60,
52054           35,
52055           65,
52056           30,
52057           70,
52058           25,
52059           75,
52060           20,
52061           80,
52062           15,
52063           95,
52064           10,
52065           90,
52066           5,
52067           95
52068         ];
52069         var padding = 3;
52070         for (var i4 = 0; i4 < lineOffsets.length; i4++) {
52071           var offset = lineOffsets[i4];
52072           var middle = offset / 100 * length2;
52073           var start2 = middle - width2 / 2;
52074           if (start2 < 0 || start2 + width2 > length2)
52075             continue;
52076           var sub = subpath(points, start2, start2 + width2);
52077           if (!sub || !geoPolygonIntersectsPolygon(viewport, sub, true)) {
52078             continue;
52079           }
52080           var isReverse = reverse(sub);
52081           if (isReverse) {
52082             sub = sub.reverse();
52083           }
52084           var bboxes = [];
52085           var boxsize = (height + 2) / 2;
52086           for (var j3 = 0; j3 < sub.length - 1; j3++) {
52087             var a2 = sub[j3];
52088             var b2 = sub[j3 + 1];
52089             var num = Math.max(1, Math.floor(geoVecLength(a2, b2) / boxsize / 2));
52090             for (var box = 0; box < num; box++) {
52091               var p3 = geoVecInterp(a2, b2, box / num);
52092               var x05 = p3[0] - boxsize - padding;
52093               var y05 = p3[1] - boxsize - padding;
52094               var x12 = p3[0] + boxsize + padding;
52095               var y12 = p3[1] + boxsize + padding;
52096               bboxes.push({
52097                 minX: Math.min(x05, x12),
52098                 minY: Math.min(y05, y12),
52099                 maxX: Math.max(x05, x12),
52100                 maxY: Math.max(y05, y12)
52101               });
52102             }
52103           }
52104           if (tryInsert(bboxes, entity2.id, false)) {
52105             return {
52106               "font-size": height + 2,
52107               lineString: lineString2(sub),
52108               startOffset: offset + "%"
52109             };
52110           }
52111         }
52112         function reverse(p4) {
52113           var angle2 = Math.atan2(p4[1][1] - p4[0][1], p4[1][0] - p4[0][0]);
52114           return !(p4[0][0] < p4[p4.length - 1][0] && angle2 < Math.PI / 2 && angle2 > -Math.PI / 2);
52115         }
52116         function lineString2(points2) {
52117           return "M" + points2.join("L");
52118         }
52119         function subpath(points2, from, to) {
52120           var sofar = 0;
52121           var start3, end, i0, i1;
52122           for (var i5 = 0; i5 < points2.length - 1; i5++) {
52123             var a3 = points2[i5];
52124             var b3 = points2[i5 + 1];
52125             var current = geoVecLength(a3, b3);
52126             var portion;
52127             if (!start3 && sofar + current >= from) {
52128               portion = (from - sofar) / current;
52129               start3 = [
52130                 a3[0] + portion * (b3[0] - a3[0]),
52131                 a3[1] + portion * (b3[1] - a3[1])
52132               ];
52133               i0 = i5 + 1;
52134             }
52135             if (!end && sofar + current >= to) {
52136               portion = (to - sofar) / current;
52137               end = [
52138                 a3[0] + portion * (b3[0] - a3[0]),
52139                 a3[1] + portion * (b3[1] - a3[1])
52140               ];
52141               i1 = i5 + 1;
52142             }
52143             sofar += current;
52144           }
52145           var result = points2.slice(i0, i1);
52146           result.unshift(start3);
52147           result.push(end);
52148           return result;
52149         }
52150       }
52151       function getAreaLabel(entity2, width2, height) {
52152         var centroid = path.centroid(entity2.asGeoJSON(graph));
52153         var extent = entity2.extent(graph);
52154         var areaWidth = projection2(extent[1])[0] - projection2(extent[0])[0];
52155         if (isNaN(centroid[0]) || areaWidth < 20)
52156           return;
52157         var preset2 = _mainPresetIndex.match(entity2, context.graph());
52158         var picon = preset2 && preset2.icon;
52159         var iconSize = 17;
52160         var padding = 2;
52161         var p3 = {};
52162         if (picon) {
52163           if (addIcon()) {
52164             addLabel(iconSize + padding);
52165             return p3;
52166           }
52167         } else {
52168           if (addLabel(0)) {
52169             return p3;
52170           }
52171         }
52172         function addIcon() {
52173           var iconX = centroid[0] - iconSize / 2;
52174           var iconY = centroid[1] - iconSize / 2;
52175           var bbox3 = {
52176             minX: iconX,
52177             minY: iconY,
52178             maxX: iconX + iconSize,
52179             maxY: iconY + iconSize
52180           };
52181           if (tryInsert([bbox3], entity2.id + "I", true)) {
52182             p3.transform = "translate(" + iconX + "," + iconY + ")";
52183             return true;
52184           }
52185           return false;
52186         }
52187         function addLabel(yOffset) {
52188           if (width2 && areaWidth >= width2 + 20) {
52189             var labelX = centroid[0];
52190             var labelY = centroid[1] + yOffset;
52191             var bbox3 = {
52192               minX: labelX - width2 / 2 - padding,
52193               minY: labelY - height / 2 - padding,
52194               maxX: labelX + width2 / 2 + padding,
52195               maxY: labelY + height / 2 + padding
52196             };
52197             if (tryInsert([bbox3], entity2.id, true)) {
52198               p3.x = labelX;
52199               p3.y = labelY;
52200               p3.textAnchor = "middle";
52201               p3.height = height;
52202               return true;
52203             }
52204           }
52205           return false;
52206         }
52207       }
52208       function doInsert(bbox3, id2) {
52209         bbox3.id = id2;
52210         var oldbox = _entitybboxes[id2];
52211         if (oldbox) {
52212           _rdrawn.remove(oldbox);
52213         }
52214         _entitybboxes[id2] = bbox3;
52215         _rdrawn.insert(bbox3);
52216       }
52217       function tryInsert(bboxes, id2, saveSkipped) {
52218         var skipped = false;
52219         for (var i4 = 0; i4 < bboxes.length; i4++) {
52220           var bbox3 = bboxes[i4];
52221           bbox3.id = id2;
52222           if (bbox3.minX < 0 || bbox3.minY < 0 || bbox3.maxX > dimensions[0] || bbox3.maxY > dimensions[1]) {
52223             skipped = true;
52224             break;
52225           }
52226           if (_rdrawn.collides(bbox3)) {
52227             skipped = true;
52228             break;
52229           }
52230         }
52231         _entitybboxes[id2] = bboxes;
52232         if (skipped) {
52233           if (saveSkipped) {
52234             _rskipped.load(bboxes);
52235           }
52236         } else {
52237           _rdrawn.load(bboxes);
52238         }
52239         return !skipped;
52240       }
52241       var layer = selection2.selectAll(".layer-osm.labels");
52242       layer.selectAll(".labels-group").data(["halo", "label", "debug"]).enter().append("g").attr("class", function(d2) {
52243         return "labels-group " + d2;
52244       });
52245       var halo = layer.selectAll(".labels-group.halo");
52246       var label = layer.selectAll(".labels-group.label");
52247       var debug2 = layer.selectAll(".labels-group.debug");
52248       drawPointLabels(label, labelled.point, filter2, "pointlabel", positions.point);
52249       drawPointLabels(halo, labelled.point, filter2, "pointlabel-halo", positions.point);
52250       drawLinePaths(layer, labelled.line, filter2, "", positions.line);
52251       drawLineLabels(label, labelled.line, filter2, "linelabel", positions.line);
52252       drawLineLabels(halo, labelled.line, filter2, "linelabel-halo", positions.line);
52253       drawAreaLabels(label, labelled.area, filter2, "arealabel", positions.area);
52254       drawAreaLabels(halo, labelled.area, filter2, "arealabel-halo", positions.area);
52255       drawAreaIcons(label, labelled.area, filter2, "areaicon", positions.area);
52256       drawAreaIcons(halo, labelled.area, filter2, "areaicon-halo", positions.area);
52257       drawCollisionBoxes(debug2, _rskipped, "debug-skipped");
52258       drawCollisionBoxes(debug2, _rdrawn, "debug-drawn");
52259       layer.call(filterLabels);
52260     }
52261     function filterLabels(selection2) {
52262       var drawLayer = selection2.selectAll(".layer-osm.labels");
52263       var layers = drawLayer.selectAll(".labels-group.halo, .labels-group.label");
52264       layers.selectAll(".nolabel").classed("nolabel", false);
52265       var mouse = context.map().mouse();
52266       var graph = context.graph();
52267       var selectedIDs = context.selectedIDs();
52268       var ids = [];
52269       var pad2, bbox2;
52270       if (mouse) {
52271         pad2 = 20;
52272         bbox2 = { minX: mouse[0] - pad2, minY: mouse[1] - pad2, maxX: mouse[0] + pad2, maxY: mouse[1] + pad2 };
52273         var nearMouse = _rdrawn.search(bbox2).map(function(entity2) {
52274           return entity2.id;
52275         });
52276         ids.push.apply(ids, nearMouse);
52277       }
52278       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
52279         var entity = graph.hasEntity(selectedIDs[i3]);
52280         if (entity && entity.type === "node") {
52281           ids.push(selectedIDs[i3]);
52282         }
52283       }
52284       layers.selectAll(utilEntitySelector(ids)).classed("nolabel", true);
52285       var debug2 = selection2.selectAll(".labels-group.debug");
52286       var gj = [];
52287       if (context.getDebug("collision")) {
52288         gj = bbox2 ? [{
52289           type: "Polygon",
52290           coordinates: [[
52291             [bbox2.minX, bbox2.minY],
52292             [bbox2.maxX, bbox2.minY],
52293             [bbox2.maxX, bbox2.maxY],
52294             [bbox2.minX, bbox2.maxY],
52295             [bbox2.minX, bbox2.minY]
52296           ]]
52297         }] : [];
52298       }
52299       var box = debug2.selectAll(".debug-mouse").data(gj);
52300       box.exit().remove();
52301       box.enter().append("path").attr("class", "debug debug-mouse yellow").merge(box).attr("d", path_default());
52302     }
52303     var throttleFilterLabels = throttle_default(filterLabels, 100);
52304     drawLabels.observe = function(selection2) {
52305       var listener = function() {
52306         throttleFilterLabels(selection2);
52307       };
52308       selection2.on("mousemove.hidelabels", listener);
52309       context.on("enter.hidelabels", listener);
52310     };
52311     drawLabels.off = function(selection2) {
52312       throttleFilterLabels.cancel();
52313       selection2.on("mousemove.hidelabels", null);
52314       context.on("enter.hidelabels", null);
52315     };
52316     return drawLabels;
52317   }
52318
52319   // node_modules/exifr/dist/full.esm.mjs
52320   var e = "undefined" != typeof self ? self : global;
52321   var t = "undefined" != typeof navigator;
52322   var i2 = t && "undefined" == typeof HTMLImageElement;
52323   var n2 = !("undefined" == typeof global || "undefined" == typeof process || !process.versions || !process.versions.node);
52324   var s = e.Buffer;
52325   var r = e.BigInt;
52326   var a = !!s;
52327   var o = (e3) => e3;
52328   function l(e3, t2 = o) {
52329     if (n2)
52330       try {
52331         return "function" == typeof __require ? Promise.resolve(t2(__require(e3))) : import(
52332           /* webpackIgnore: true */
52333           e3
52334         ).then(t2);
52335       } catch (t3) {
52336         console.warn("Couldn't load ".concat(e3));
52337       }
52338   }
52339   var h = e.fetch;
52340   var u = (e3) => h = e3;
52341   if (!e.fetch) {
52342     const e3 = l("http", (e4) => e4), t2 = l("https", (e4) => e4), i3 = (n3, { headers: s2 } = {}) => new Promise(async (r2, a2) => {
52343       let { port: o2, hostname: l2, pathname: h2, protocol: u2, search: c2 } = new URL(n3);
52344       const f2 = { method: "GET", hostname: l2, path: encodeURI(h2) + c2, headers: s2 };
52345       "" !== o2 && (f2.port = Number(o2));
52346       const d2 = ("https:" === u2 ? await t2 : await e3).request(f2, (e4) => {
52347         if (301 === e4.statusCode || 302 === e4.statusCode) {
52348           let t3 = new URL(e4.headers.location, n3).toString();
52349           return i3(t3, { headers: s2 }).then(r2).catch(a2);
52350         }
52351         r2({ status: e4.statusCode, arrayBuffer: () => new Promise((t3) => {
52352           let i4 = [];
52353           e4.on("data", (e6) => i4.push(e6)), e4.on("end", () => t3(Buffer.concat(i4)));
52354         }) });
52355       });
52356       d2.on("error", a2), d2.end();
52357     });
52358     u(i3);
52359   }
52360   function c(e3, t2, i3) {
52361     return t2 in e3 ? Object.defineProperty(e3, t2, { value: i3, enumerable: true, configurable: true, writable: true }) : e3[t2] = i3, e3;
52362   }
52363   var f = (e3) => p(e3) ? void 0 : e3;
52364   var d = (e3) => void 0 !== e3;
52365   function p(e3) {
52366     return void 0 === e3 || (e3 instanceof Map ? 0 === e3.size : 0 === Object.values(e3).filter(d).length);
52367   }
52368   function g2(e3) {
52369     let t2 = new Error(e3);
52370     throw delete t2.stack, t2;
52371   }
52372   function m(e3) {
52373     return "" === (e3 = function(e4) {
52374       for (; e4.endsWith("\0"); )
52375         e4 = e4.slice(0, -1);
52376       return e4;
52377     }(e3).trim()) ? void 0 : e3;
52378   }
52379   function S(e3) {
52380     let t2 = function(e4) {
52381       let t3 = 0;
52382       return e4.ifd0.enabled && (t3 += 1024), e4.exif.enabled && (t3 += 2048), e4.makerNote && (t3 += 2048), e4.userComment && (t3 += 1024), e4.gps.enabled && (t3 += 512), e4.interop.enabled && (t3 += 100), e4.ifd1.enabled && (t3 += 1024), t3 + 2048;
52383     }(e3);
52384     return e3.jfif.enabled && (t2 += 50), e3.xmp.enabled && (t2 += 2e4), e3.iptc.enabled && (t2 += 14e3), e3.icc.enabled && (t2 += 6e3), t2;
52385   }
52386   var C = (e3) => String.fromCharCode.apply(null, e3);
52387   var y = "undefined" != typeof TextDecoder ? new TextDecoder("utf-8") : void 0;
52388   function b(e3) {
52389     return y ? y.decode(e3) : a ? Buffer.from(e3).toString("utf8") : decodeURIComponent(escape(C(e3)));
52390   }
52391   var I = class _I {
52392     static from(e3, t2) {
52393       return e3 instanceof this && e3.le === t2 ? e3 : new _I(e3, void 0, void 0, t2);
52394     }
52395     constructor(e3, t2 = 0, i3, n3) {
52396       if ("boolean" == typeof n3 && (this.le = n3), Array.isArray(e3) && (e3 = new Uint8Array(e3)), 0 === e3)
52397         this.byteOffset = 0, this.byteLength = 0;
52398       else if (e3 instanceof ArrayBuffer) {
52399         void 0 === i3 && (i3 = e3.byteLength - t2);
52400         let n4 = new DataView(e3, t2, i3);
52401         this._swapDataView(n4);
52402       } else if (e3 instanceof Uint8Array || e3 instanceof DataView || e3 instanceof _I) {
52403         void 0 === i3 && (i3 = e3.byteLength - t2), (t2 += e3.byteOffset) + i3 > e3.byteOffset + e3.byteLength && g2("Creating view outside of available memory in ArrayBuffer");
52404         let n4 = new DataView(e3.buffer, t2, i3);
52405         this._swapDataView(n4);
52406       } else if ("number" == typeof e3) {
52407         let t3 = new DataView(new ArrayBuffer(e3));
52408         this._swapDataView(t3);
52409       } else
52410         g2("Invalid input argument for BufferView: " + e3);
52411     }
52412     _swapArrayBuffer(e3) {
52413       this._swapDataView(new DataView(e3));
52414     }
52415     _swapBuffer(e3) {
52416       this._swapDataView(new DataView(e3.buffer, e3.byteOffset, e3.byteLength));
52417     }
52418     _swapDataView(e3) {
52419       this.dataView = e3, this.buffer = e3.buffer, this.byteOffset = e3.byteOffset, this.byteLength = e3.byteLength;
52420     }
52421     _lengthToEnd(e3) {
52422       return this.byteLength - e3;
52423     }
52424     set(e3, t2, i3 = _I) {
52425       return e3 instanceof DataView || e3 instanceof _I ? e3 = new Uint8Array(e3.buffer, e3.byteOffset, e3.byteLength) : e3 instanceof ArrayBuffer && (e3 = new Uint8Array(e3)), e3 instanceof Uint8Array || g2("BufferView.set(): Invalid data argument."), this.toUint8().set(e3, t2), new i3(this, t2, e3.byteLength);
52426     }
52427     subarray(e3, t2) {
52428       return t2 = t2 || this._lengthToEnd(e3), new _I(this, e3, t2);
52429     }
52430     toUint8() {
52431       return new Uint8Array(this.buffer, this.byteOffset, this.byteLength);
52432     }
52433     getUint8Array(e3, t2) {
52434       return new Uint8Array(this.buffer, this.byteOffset + e3, t2);
52435     }
52436     getString(e3 = 0, t2 = this.byteLength) {
52437       return b(this.getUint8Array(e3, t2));
52438     }
52439     getLatin1String(e3 = 0, t2 = this.byteLength) {
52440       let i3 = this.getUint8Array(e3, t2);
52441       return C(i3);
52442     }
52443     getUnicodeString(e3 = 0, t2 = this.byteLength) {
52444       const i3 = [];
52445       for (let n3 = 0; n3 < t2 && e3 + n3 < this.byteLength; n3 += 2)
52446         i3.push(this.getUint16(e3 + n3));
52447       return C(i3);
52448     }
52449     getInt8(e3) {
52450       return this.dataView.getInt8(e3);
52451     }
52452     getUint8(e3) {
52453       return this.dataView.getUint8(e3);
52454     }
52455     getInt16(e3, t2 = this.le) {
52456       return this.dataView.getInt16(e3, t2);
52457     }
52458     getInt32(e3, t2 = this.le) {
52459       return this.dataView.getInt32(e3, t2);
52460     }
52461     getUint16(e3, t2 = this.le) {
52462       return this.dataView.getUint16(e3, t2);
52463     }
52464     getUint32(e3, t2 = this.le) {
52465       return this.dataView.getUint32(e3, t2);
52466     }
52467     getFloat32(e3, t2 = this.le) {
52468       return this.dataView.getFloat32(e3, t2);
52469     }
52470     getFloat64(e3, t2 = this.le) {
52471       return this.dataView.getFloat64(e3, t2);
52472     }
52473     getFloat(e3, t2 = this.le) {
52474       return this.dataView.getFloat32(e3, t2);
52475     }
52476     getDouble(e3, t2 = this.le) {
52477       return this.dataView.getFloat64(e3, t2);
52478     }
52479     getUintBytes(e3, t2, i3) {
52480       switch (t2) {
52481         case 1:
52482           return this.getUint8(e3, i3);
52483         case 2:
52484           return this.getUint16(e3, i3);
52485         case 4:
52486           return this.getUint32(e3, i3);
52487         case 8:
52488           return this.getUint64 && this.getUint64(e3, i3);
52489       }
52490     }
52491     getUint(e3, t2, i3) {
52492       switch (t2) {
52493         case 8:
52494           return this.getUint8(e3, i3);
52495         case 16:
52496           return this.getUint16(e3, i3);
52497         case 32:
52498           return this.getUint32(e3, i3);
52499         case 64:
52500           return this.getUint64 && this.getUint64(e3, i3);
52501       }
52502     }
52503     toString(e3) {
52504       return this.dataView.toString(e3, this.constructor.name);
52505     }
52506     ensureChunk() {
52507     }
52508   };
52509   function P(e3, t2) {
52510     g2("".concat(e3, " '").concat(t2, "' was not loaded, try using full build of exifr."));
52511   }
52512   var k = class extends Map {
52513     constructor(e3) {
52514       super(), this.kind = e3;
52515     }
52516     get(e3, t2) {
52517       return this.has(e3) || P(this.kind, e3), t2 && (e3 in t2 || function(e4, t3) {
52518         g2("Unknown ".concat(e4, " '").concat(t3, "'."));
52519       }(this.kind, e3), t2[e3].enabled || P(this.kind, e3)), super.get(e3);
52520     }
52521     keyList() {
52522       return Array.from(this.keys());
52523     }
52524   };
52525   var w = new k("file parser");
52526   var T = new k("segment parser");
52527   var A = new k("file reader");
52528   function D(e3, n3) {
52529     return "string" == typeof e3 ? O(e3, n3) : t && !i2 && e3 instanceof HTMLImageElement ? O(e3.src, n3) : e3 instanceof Uint8Array || e3 instanceof ArrayBuffer || e3 instanceof DataView ? new I(e3) : t && e3 instanceof Blob ? x(e3, n3, "blob", R) : void g2("Invalid input argument");
52530   }
52531   function O(e3, i3) {
52532     return (s2 = e3).startsWith("data:") || s2.length > 1e4 ? v(e3, i3, "base64") : n2 && e3.includes("://") ? x(e3, i3, "url", M) : n2 ? v(e3, i3, "fs") : t ? x(e3, i3, "url", M) : void g2("Invalid input argument");
52533     var s2;
52534   }
52535   async function x(e3, t2, i3, n3) {
52536     return A.has(i3) ? v(e3, t2, i3) : n3 ? async function(e4, t3) {
52537       let i4 = await t3(e4);
52538       return new I(i4);
52539     }(e3, n3) : void g2("Parser ".concat(i3, " is not loaded"));
52540   }
52541   async function v(e3, t2, i3) {
52542     let n3 = new (A.get(i3))(e3, t2);
52543     return await n3.read(), n3;
52544   }
52545   var M = (e3) => h(e3).then((e4) => e4.arrayBuffer());
52546   var R = (e3) => new Promise((t2, i3) => {
52547     let n3 = new FileReader();
52548     n3.onloadend = () => t2(n3.result || new ArrayBuffer()), n3.onerror = i3, n3.readAsArrayBuffer(e3);
52549   });
52550   var L = class extends Map {
52551     get tagKeys() {
52552       return this.allKeys || (this.allKeys = Array.from(this.keys())), this.allKeys;
52553     }
52554     get tagValues() {
52555       return this.allValues || (this.allValues = Array.from(this.values())), this.allValues;
52556     }
52557   };
52558   function U(e3, t2, i3) {
52559     let n3 = new L();
52560     for (let [e4, t3] of i3)
52561       n3.set(e4, t3);
52562     if (Array.isArray(t2))
52563       for (let i4 of t2)
52564         e3.set(i4, n3);
52565     else
52566       e3.set(t2, n3);
52567     return n3;
52568   }
52569   function F(e3, t2, i3) {
52570     let n3, s2 = e3.get(t2);
52571     for (n3 of i3)
52572       s2.set(n3[0], n3[1]);
52573   }
52574   var E = /* @__PURE__ */ new Map();
52575   var B = /* @__PURE__ */ new Map();
52576   var N = /* @__PURE__ */ new Map();
52577   var G = ["chunked", "firstChunkSize", "firstChunkSizeNode", "firstChunkSizeBrowser", "chunkSize", "chunkLimit"];
52578   var V = ["jfif", "xmp", "icc", "iptc", "ihdr"];
52579   var z = ["tiff", ...V];
52580   var H = ["ifd0", "ifd1", "exif", "gps", "interop"];
52581   var j = [...z, ...H];
52582   var W = ["makerNote", "userComment"];
52583   var K = ["translateKeys", "translateValues", "reviveValues", "multiSegment"];
52584   var X = [...K, "sanitize", "mergeOutput", "silentErrors"];
52585   var _ = class {
52586     get translate() {
52587       return this.translateKeys || this.translateValues || this.reviveValues;
52588     }
52589   };
52590   var Y = class extends _ {
52591     get needed() {
52592       return this.enabled || this.deps.size > 0;
52593     }
52594     constructor(e3, t2, i3, n3) {
52595       if (super(), c(this, "enabled", false), c(this, "skip", /* @__PURE__ */ new Set()), c(this, "pick", /* @__PURE__ */ new Set()), c(this, "deps", /* @__PURE__ */ new Set()), c(this, "translateKeys", false), c(this, "translateValues", false), c(this, "reviveValues", false), this.key = e3, this.enabled = t2, this.parse = this.enabled, this.applyInheritables(n3), this.canBeFiltered = H.includes(e3), this.canBeFiltered && (this.dict = E.get(e3)), void 0 !== i3)
52596         if (Array.isArray(i3))
52597           this.parse = this.enabled = true, this.canBeFiltered && i3.length > 0 && this.translateTagSet(i3, this.pick);
52598         else if ("object" == typeof i3) {
52599           if (this.enabled = true, this.parse = false !== i3.parse, this.canBeFiltered) {
52600             let { pick: e4, skip: t3 } = i3;
52601             e4 && e4.length > 0 && this.translateTagSet(e4, this.pick), t3 && t3.length > 0 && this.translateTagSet(t3, this.skip);
52602           }
52603           this.applyInheritables(i3);
52604         } else
52605           true === i3 || false === i3 ? this.parse = this.enabled = i3 : g2("Invalid options argument: ".concat(i3));
52606     }
52607     applyInheritables(e3) {
52608       let t2, i3;
52609       for (t2 of K)
52610         i3 = e3[t2], void 0 !== i3 && (this[t2] = i3);
52611     }
52612     translateTagSet(e3, t2) {
52613       if (this.dict) {
52614         let i3, n3, { tagKeys: s2, tagValues: r2 } = this.dict;
52615         for (i3 of e3)
52616           "string" == typeof i3 ? (n3 = r2.indexOf(i3), -1 === n3 && (n3 = s2.indexOf(Number(i3))), -1 !== n3 && t2.add(Number(s2[n3]))) : t2.add(i3);
52617       } else
52618         for (let i3 of e3)
52619           t2.add(i3);
52620     }
52621     finalizeFilters() {
52622       !this.enabled && this.deps.size > 0 ? (this.enabled = true, ee(this.pick, this.deps)) : this.enabled && this.pick.size > 0 && ee(this.pick, this.deps);
52623     }
52624   };
52625   var $2 = { jfif: false, tiff: true, xmp: false, icc: false, iptc: false, ifd0: true, ifd1: false, exif: true, gps: true, interop: false, ihdr: void 0, makerNote: false, userComment: false, multiSegment: false, skip: [], pick: [], translateKeys: true, translateValues: true, reviveValues: true, sanitize: true, mergeOutput: true, silentErrors: true, chunked: true, firstChunkSize: void 0, firstChunkSizeNode: 512, firstChunkSizeBrowser: 65536, chunkSize: 65536, chunkLimit: 5 };
52626   var J = /* @__PURE__ */ new Map();
52627   var q = class extends _ {
52628     static useCached(e3) {
52629       let t2 = J.get(e3);
52630       return void 0 !== t2 || (t2 = new this(e3), J.set(e3, t2)), t2;
52631     }
52632     constructor(e3) {
52633       super(), true === e3 ? this.setupFromTrue() : void 0 === e3 ? this.setupFromUndefined() : Array.isArray(e3) ? this.setupFromArray(e3) : "object" == typeof e3 ? this.setupFromObject(e3) : g2("Invalid options argument ".concat(e3)), void 0 === this.firstChunkSize && (this.firstChunkSize = t ? this.firstChunkSizeBrowser : this.firstChunkSizeNode), this.mergeOutput && (this.ifd1.enabled = false), this.filterNestedSegmentTags(), this.traverseTiffDependencyTree(), this.checkLoadedPlugins();
52634     }
52635     setupFromUndefined() {
52636       let e3;
52637       for (e3 of G)
52638         this[e3] = $2[e3];
52639       for (e3 of X)
52640         this[e3] = $2[e3];
52641       for (e3 of W)
52642         this[e3] = $2[e3];
52643       for (e3 of j)
52644         this[e3] = new Y(e3, $2[e3], void 0, this);
52645     }
52646     setupFromTrue() {
52647       let e3;
52648       for (e3 of G)
52649         this[e3] = $2[e3];
52650       for (e3 of X)
52651         this[e3] = $2[e3];
52652       for (e3 of W)
52653         this[e3] = true;
52654       for (e3 of j)
52655         this[e3] = new Y(e3, true, void 0, this);
52656     }
52657     setupFromArray(e3) {
52658       let t2;
52659       for (t2 of G)
52660         this[t2] = $2[t2];
52661       for (t2 of X)
52662         this[t2] = $2[t2];
52663       for (t2 of W)
52664         this[t2] = $2[t2];
52665       for (t2 of j)
52666         this[t2] = new Y(t2, false, void 0, this);
52667       this.setupGlobalFilters(e3, void 0, H);
52668     }
52669     setupFromObject(e3) {
52670       let t2;
52671       for (t2 of (H.ifd0 = H.ifd0 || H.image, H.ifd1 = H.ifd1 || H.thumbnail, Object.assign(this, e3), G))
52672         this[t2] = Z(e3[t2], $2[t2]);
52673       for (t2 of X)
52674         this[t2] = Z(e3[t2], $2[t2]);
52675       for (t2 of W)
52676         this[t2] = Z(e3[t2], $2[t2]);
52677       for (t2 of z)
52678         this[t2] = new Y(t2, $2[t2], e3[t2], this);
52679       for (t2 of H)
52680         this[t2] = new Y(t2, $2[t2], e3[t2], this.tiff);
52681       this.setupGlobalFilters(e3.pick, e3.skip, H, j), true === e3.tiff ? this.batchEnableWithBool(H, true) : false === e3.tiff ? this.batchEnableWithUserValue(H, e3) : Array.isArray(e3.tiff) ? this.setupGlobalFilters(e3.tiff, void 0, H) : "object" == typeof e3.tiff && this.setupGlobalFilters(e3.tiff.pick, e3.tiff.skip, H);
52682     }
52683     batchEnableWithBool(e3, t2) {
52684       for (let i3 of e3)
52685         this[i3].enabled = t2;
52686     }
52687     batchEnableWithUserValue(e3, t2) {
52688       for (let i3 of e3) {
52689         let e4 = t2[i3];
52690         this[i3].enabled = false !== e4 && void 0 !== e4;
52691       }
52692     }
52693     setupGlobalFilters(e3, t2, i3, n3 = i3) {
52694       if (e3 && e3.length) {
52695         for (let e4 of n3)
52696           this[e4].enabled = false;
52697         let t3 = Q(e3, i3);
52698         for (let [e4, i4] of t3)
52699           ee(this[e4].pick, i4), this[e4].enabled = true;
52700       } else if (t2 && t2.length) {
52701         let e4 = Q(t2, i3);
52702         for (let [t3, i4] of e4)
52703           ee(this[t3].skip, i4);
52704       }
52705     }
52706     filterNestedSegmentTags() {
52707       let { ifd0: e3, exif: t2, xmp: i3, iptc: n3, icc: s2 } = this;
52708       this.makerNote ? t2.deps.add(37500) : t2.skip.add(37500), this.userComment ? t2.deps.add(37510) : t2.skip.add(37510), i3.enabled || e3.skip.add(700), n3.enabled || e3.skip.add(33723), s2.enabled || e3.skip.add(34675);
52709     }
52710     traverseTiffDependencyTree() {
52711       let { ifd0: e3, exif: t2, gps: i3, interop: n3 } = this;
52712       n3.needed && (t2.deps.add(40965), e3.deps.add(40965)), t2.needed && e3.deps.add(34665), i3.needed && e3.deps.add(34853), this.tiff.enabled = H.some((e4) => true === this[e4].enabled) || this.makerNote || this.userComment;
52713       for (let e4 of H)
52714         this[e4].finalizeFilters();
52715     }
52716     get onlyTiff() {
52717       return !V.map((e3) => this[e3].enabled).some((e3) => true === e3) && this.tiff.enabled;
52718     }
52719     checkLoadedPlugins() {
52720       for (let e3 of z)
52721         this[e3].enabled && !T.has(e3) && P("segment parser", e3);
52722     }
52723   };
52724   function Q(e3, t2) {
52725     let i3, n3, s2, r2, a2 = [];
52726     for (s2 of t2) {
52727       for (r2 of (i3 = E.get(s2), n3 = [], i3))
52728         (e3.includes(r2[0]) || e3.includes(r2[1])) && n3.push(r2[0]);
52729       n3.length && a2.push([s2, n3]);
52730     }
52731     return a2;
52732   }
52733   function Z(e3, t2) {
52734     return void 0 !== e3 ? e3 : void 0 !== t2 ? t2 : void 0;
52735   }
52736   function ee(e3, t2) {
52737     for (let i3 of t2)
52738       e3.add(i3);
52739   }
52740   c(q, "default", $2);
52741   var te = class {
52742     constructor(e3) {
52743       c(this, "parsers", {}), c(this, "output", {}), c(this, "errors", []), c(this, "pushToErrors", (e4) => this.errors.push(e4)), this.options = q.useCached(e3);
52744     }
52745     async read(e3) {
52746       this.file = await D(e3, this.options);
52747     }
52748     setup() {
52749       if (this.fileParser)
52750         return;
52751       let { file: e3 } = this, t2 = e3.getUint16(0);
52752       for (let [i3, n3] of w)
52753         if (n3.canHandle(e3, t2))
52754           return this.fileParser = new n3(this.options, this.file, this.parsers), e3[i3] = true;
52755       this.file.close && this.file.close(), g2("Unknown file format");
52756     }
52757     async parse() {
52758       let { output: e3, errors: t2 } = this;
52759       return this.setup(), this.options.silentErrors ? (await this.executeParsers().catch(this.pushToErrors), t2.push(...this.fileParser.errors)) : await this.executeParsers(), this.file.close && this.file.close(), this.options.silentErrors && t2.length > 0 && (e3.errors = t2), f(e3);
52760     }
52761     async executeParsers() {
52762       let { output: e3 } = this;
52763       await this.fileParser.parse();
52764       let t2 = Object.values(this.parsers).map(async (t3) => {
52765         let i3 = await t3.parse();
52766         t3.assignToOutput(e3, i3);
52767       });
52768       this.options.silentErrors && (t2 = t2.map((e4) => e4.catch(this.pushToErrors))), await Promise.all(t2);
52769     }
52770     async extractThumbnail() {
52771       this.setup();
52772       let { options: e3, file: t2 } = this, i3 = T.get("tiff", e3);
52773       var n3;
52774       if (t2.tiff ? n3 = { start: 0, type: "tiff" } : t2.jpeg && (n3 = await this.fileParser.getOrFindSegment("tiff")), void 0 === n3)
52775         return;
52776       let s2 = await this.fileParser.ensureSegmentChunk(n3), r2 = this.parsers.tiff = new i3(s2, e3, t2), a2 = await r2.extractThumbnail();
52777       return t2.close && t2.close(), a2;
52778     }
52779   };
52780   async function ie(e3, t2) {
52781     let i3 = new te(t2);
52782     return await i3.read(e3), i3.parse();
52783   }
52784   var ne = Object.freeze({ __proto__: null, parse: ie, Exifr: te, fileParsers: w, segmentParsers: T, fileReaders: A, tagKeys: E, tagValues: B, tagRevivers: N, createDictionary: U, extendDictionary: F, fetchUrlAsArrayBuffer: M, readBlobAsArrayBuffer: R, chunkedProps: G, otherSegments: V, segments: z, tiffBlocks: H, segmentsAndBlocks: j, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q });
52785   var se = class {
52786     constructor(e3, t2, i3) {
52787       c(this, "errors", []), c(this, "ensureSegmentChunk", async (e4) => {
52788         let t3 = e4.start, i4 = e4.size || 65536;
52789         if (this.file.chunked)
52790           if (this.file.available(t3, i4))
52791             e4.chunk = this.file.subarray(t3, i4);
52792           else
52793             try {
52794               e4.chunk = await this.file.readChunk(t3, i4);
52795             } catch (t4) {
52796               g2("Couldn't read segment: ".concat(JSON.stringify(e4), ". ").concat(t4.message));
52797             }
52798         else
52799           this.file.byteLength > t3 + i4 ? e4.chunk = this.file.subarray(t3, i4) : void 0 === e4.size ? e4.chunk = this.file.subarray(t3) : g2("Segment unreachable: " + JSON.stringify(e4));
52800         return e4.chunk;
52801       }), this.extendOptions && this.extendOptions(e3), this.options = e3, this.file = t2, this.parsers = i3;
52802     }
52803     injectSegment(e3, t2) {
52804       this.options[e3].enabled && this.createParser(e3, t2);
52805     }
52806     createParser(e3, t2) {
52807       let i3 = new (T.get(e3))(t2, this.options, this.file);
52808       return this.parsers[e3] = i3;
52809     }
52810     createParsers(e3) {
52811       for (let t2 of e3) {
52812         let { type: e4, chunk: i3 } = t2, n3 = this.options[e4];
52813         if (n3 && n3.enabled) {
52814           let t3 = this.parsers[e4];
52815           t3 && t3.append || t3 || this.createParser(e4, i3);
52816         }
52817       }
52818     }
52819     async readSegments(e3) {
52820       let t2 = e3.map(this.ensureSegmentChunk);
52821       await Promise.all(t2);
52822     }
52823   };
52824   var re2 = class {
52825     static findPosition(e3, t2) {
52826       let i3 = e3.getUint16(t2 + 2) + 2, n3 = "function" == typeof this.headerLength ? this.headerLength(e3, t2, i3) : this.headerLength, s2 = t2 + n3, r2 = i3 - n3;
52827       return { offset: t2, length: i3, headerLength: n3, start: s2, size: r2, end: s2 + r2 };
52828     }
52829     static parse(e3, t2 = {}) {
52830       return new this(e3, new q({ [this.type]: t2 }), e3).parse();
52831     }
52832     normalizeInput(e3) {
52833       return e3 instanceof I ? e3 : new I(e3);
52834     }
52835     constructor(e3, t2 = {}, i3) {
52836       c(this, "errors", []), c(this, "raw", /* @__PURE__ */ new Map()), c(this, "handleError", (e4) => {
52837         if (!this.options.silentErrors)
52838           throw e4;
52839         this.errors.push(e4.message);
52840       }), this.chunk = this.normalizeInput(e3), this.file = i3, this.type = this.constructor.type, this.globalOptions = this.options = t2, this.localOptions = t2[this.type], this.canTranslate = this.localOptions && this.localOptions.translate;
52841     }
52842     translate() {
52843       this.canTranslate && (this.translated = this.translateBlock(this.raw, this.type));
52844     }
52845     get output() {
52846       return this.translated ? this.translated : this.raw ? Object.fromEntries(this.raw) : void 0;
52847     }
52848     translateBlock(e3, t2) {
52849       let i3 = N.get(t2), n3 = B.get(t2), s2 = E.get(t2), r2 = this.options[t2], a2 = r2.reviveValues && !!i3, o2 = r2.translateValues && !!n3, l2 = r2.translateKeys && !!s2, h2 = {};
52850       for (let [t3, r3] of e3)
52851         a2 && i3.has(t3) ? r3 = i3.get(t3)(r3) : o2 && n3.has(t3) && (r3 = this.translateValue(r3, n3.get(t3))), l2 && s2.has(t3) && (t3 = s2.get(t3) || t3), h2[t3] = r3;
52852       return h2;
52853     }
52854     translateValue(e3, t2) {
52855       return t2[e3] || t2.DEFAULT || e3;
52856     }
52857     assignToOutput(e3, t2) {
52858       this.assignObjectToOutput(e3, this.constructor.type, t2);
52859     }
52860     assignObjectToOutput(e3, t2, i3) {
52861       if (this.globalOptions.mergeOutput)
52862         return Object.assign(e3, i3);
52863       e3[t2] ? Object.assign(e3[t2], i3) : e3[t2] = i3;
52864     }
52865   };
52866   c(re2, "headerLength", 4), c(re2, "type", void 0), c(re2, "multiSegment", false), c(re2, "canHandle", () => false);
52867   function ae(e3) {
52868     return 192 === e3 || 194 === e3 || 196 === e3 || 219 === e3 || 221 === e3 || 218 === e3 || 254 === e3;
52869   }
52870   function oe(e3) {
52871     return e3 >= 224 && e3 <= 239;
52872   }
52873   function le(e3, t2, i3) {
52874     for (let [n3, s2] of T)
52875       if (s2.canHandle(e3, t2, i3))
52876         return n3;
52877   }
52878   var he = class extends se {
52879     constructor(...e3) {
52880       super(...e3), c(this, "appSegments", []), c(this, "jpegSegments", []), c(this, "unknownSegments", []);
52881     }
52882     static canHandle(e3, t2) {
52883       return 65496 === t2;
52884     }
52885     async parse() {
52886       await this.findAppSegments(), await this.readSegments(this.appSegments), this.mergeMultiSegments(), this.createParsers(this.mergedAppSegments || this.appSegments);
52887     }
52888     setupSegmentFinderArgs(e3) {
52889       true === e3 ? (this.findAll = true, this.wanted = new Set(T.keyList())) : (e3 = void 0 === e3 ? T.keyList().filter((e4) => this.options[e4].enabled) : e3.filter((e4) => this.options[e4].enabled && T.has(e4)), this.findAll = false, this.remaining = new Set(e3), this.wanted = new Set(e3)), this.unfinishedMultiSegment = false;
52890     }
52891     async findAppSegments(e3 = 0, t2) {
52892       this.setupSegmentFinderArgs(t2);
52893       let { file: i3, findAll: n3, wanted: s2, remaining: r2 } = this;
52894       if (!n3 && this.file.chunked && (n3 = Array.from(s2).some((e4) => {
52895         let t3 = T.get(e4), i4 = this.options[e4];
52896         return t3.multiSegment && i4.multiSegment;
52897       }), n3 && await this.file.readWhole()), e3 = this.findAppSegmentsInRange(e3, i3.byteLength), !this.options.onlyTiff && i3.chunked) {
52898         let t3 = false;
52899         for (; r2.size > 0 && !t3 && (i3.canReadNextChunk || this.unfinishedMultiSegment); ) {
52900           let { nextChunkOffset: n4 } = i3, s3 = this.appSegments.some((e4) => !this.file.available(e4.offset || e4.start, e4.length || e4.size));
52901           if (t3 = e3 > n4 && !s3 ? !await i3.readNextChunk(e3) : !await i3.readNextChunk(n4), void 0 === (e3 = this.findAppSegmentsInRange(e3, i3.byteLength)))
52902             return;
52903         }
52904       }
52905     }
52906     findAppSegmentsInRange(e3, t2) {
52907       t2 -= 2;
52908       let i3, n3, s2, r2, a2, o2, { file: l2, findAll: h2, wanted: u2, remaining: c2, options: f2 } = this;
52909       for (; e3 < t2; e3++)
52910         if (255 === l2.getUint8(e3)) {
52911           if (i3 = l2.getUint8(e3 + 1), oe(i3)) {
52912             if (n3 = l2.getUint16(e3 + 2), s2 = le(l2, e3, n3), s2 && u2.has(s2) && (r2 = T.get(s2), a2 = r2.findPosition(l2, e3), o2 = f2[s2], a2.type = s2, this.appSegments.push(a2), !h2 && (r2.multiSegment && o2.multiSegment ? (this.unfinishedMultiSegment = a2.chunkNumber < a2.chunkCount, this.unfinishedMultiSegment || c2.delete(s2)) : c2.delete(s2), 0 === c2.size)))
52913               break;
52914             f2.recordUnknownSegments && (a2 = re2.findPosition(l2, e3), a2.marker = i3, this.unknownSegments.push(a2)), e3 += n3 + 1;
52915           } else if (ae(i3)) {
52916             if (n3 = l2.getUint16(e3 + 2), 218 === i3 && false !== f2.stopAfterSos)
52917               return;
52918             f2.recordJpegSegments && this.jpegSegments.push({ offset: e3, length: n3, marker: i3 }), e3 += n3 + 1;
52919           }
52920         }
52921       return e3;
52922     }
52923     mergeMultiSegments() {
52924       if (!this.appSegments.some((e4) => e4.multiSegment))
52925         return;
52926       let e3 = function(e4, t2) {
52927         let i3, n3, s2, r2 = /* @__PURE__ */ new Map();
52928         for (let a2 = 0; a2 < e4.length; a2++)
52929           i3 = e4[a2], n3 = i3[t2], r2.has(n3) ? s2 = r2.get(n3) : r2.set(n3, s2 = []), s2.push(i3);
52930         return Array.from(r2);
52931       }(this.appSegments, "type");
52932       this.mergedAppSegments = e3.map(([e4, t2]) => {
52933         let i3 = T.get(e4, this.options);
52934         if (i3.handleMultiSegments) {
52935           return { type: e4, chunk: i3.handleMultiSegments(t2) };
52936         }
52937         return t2[0];
52938       });
52939     }
52940     getSegment(e3) {
52941       return this.appSegments.find((t2) => t2.type === e3);
52942     }
52943     async getOrFindSegment(e3) {
52944       let t2 = this.getSegment(e3);
52945       return void 0 === t2 && (await this.findAppSegments(0, [e3]), t2 = this.getSegment(e3)), t2;
52946     }
52947   };
52948   c(he, "type", "jpeg"), w.set("jpeg", he);
52949   var ue = [void 0, 1, 1, 2, 4, 8, 1, 1, 2, 4, 8, 4, 8, 4];
52950   var ce = class extends re2 {
52951     parseHeader() {
52952       var e3 = this.chunk.getUint16();
52953       18761 === e3 ? this.le = true : 19789 === e3 && (this.le = false), this.chunk.le = this.le, this.headerParsed = true;
52954     }
52955     parseTags(e3, t2, i3 = /* @__PURE__ */ new Map()) {
52956       let { pick: n3, skip: s2 } = this.options[t2];
52957       n3 = new Set(n3);
52958       let r2 = n3.size > 0, a2 = 0 === s2.size, o2 = this.chunk.getUint16(e3);
52959       e3 += 2;
52960       for (let l2 = 0; l2 < o2; l2++) {
52961         let o3 = this.chunk.getUint16(e3);
52962         if (r2) {
52963           if (n3.has(o3) && (i3.set(o3, this.parseTag(e3, o3, t2)), n3.delete(o3), 0 === n3.size))
52964             break;
52965         } else
52966           !a2 && s2.has(o3) || i3.set(o3, this.parseTag(e3, o3, t2));
52967         e3 += 12;
52968       }
52969       return i3;
52970     }
52971     parseTag(e3, t2, i3) {
52972       let { chunk: n3 } = this, s2 = n3.getUint16(e3 + 2), r2 = n3.getUint32(e3 + 4), a2 = ue[s2];
52973       if (a2 * r2 <= 4 ? e3 += 8 : e3 = n3.getUint32(e3 + 8), (s2 < 1 || s2 > 13) && g2("Invalid TIFF value type. block: ".concat(i3.toUpperCase(), ", tag: ").concat(t2.toString(16), ", type: ").concat(s2, ", offset ").concat(e3)), e3 > n3.byteLength && g2("Invalid TIFF value offset. block: ".concat(i3.toUpperCase(), ", tag: ").concat(t2.toString(16), ", type: ").concat(s2, ", offset ").concat(e3, " is outside of chunk size ").concat(n3.byteLength)), 1 === s2)
52974         return n3.getUint8Array(e3, r2);
52975       if (2 === s2)
52976         return m(n3.getString(e3, r2));
52977       if (7 === s2)
52978         return n3.getUint8Array(e3, r2);
52979       if (1 === r2)
52980         return this.parseTagValue(s2, e3);
52981       {
52982         let t3 = new (function(e4) {
52983           switch (e4) {
52984             case 1:
52985               return Uint8Array;
52986             case 3:
52987               return Uint16Array;
52988             case 4:
52989               return Uint32Array;
52990             case 5:
52991               return Array;
52992             case 6:
52993               return Int8Array;
52994             case 8:
52995               return Int16Array;
52996             case 9:
52997               return Int32Array;
52998             case 10:
52999               return Array;
53000             case 11:
53001               return Float32Array;
53002             case 12:
53003               return Float64Array;
53004             default:
53005               return Array;
53006           }
53007         }(s2))(r2), i4 = a2;
53008         for (let n4 = 0; n4 < r2; n4++)
53009           t3[n4] = this.parseTagValue(s2, e3), e3 += i4;
53010         return t3;
53011       }
53012     }
53013     parseTagValue(e3, t2) {
53014       let { chunk: i3 } = this;
53015       switch (e3) {
53016         case 1:
53017           return i3.getUint8(t2);
53018         case 3:
53019           return i3.getUint16(t2);
53020         case 4:
53021           return i3.getUint32(t2);
53022         case 5:
53023           return i3.getUint32(t2) / i3.getUint32(t2 + 4);
53024         case 6:
53025           return i3.getInt8(t2);
53026         case 8:
53027           return i3.getInt16(t2);
53028         case 9:
53029           return i3.getInt32(t2);
53030         case 10:
53031           return i3.getInt32(t2) / i3.getInt32(t2 + 4);
53032         case 11:
53033           return i3.getFloat(t2);
53034         case 12:
53035           return i3.getDouble(t2);
53036         case 13:
53037           return i3.getUint32(t2);
53038         default:
53039           g2("Invalid tiff type ".concat(e3));
53040       }
53041     }
53042   };
53043   var fe = class extends ce {
53044     static canHandle(e3, t2) {
53045       return 225 === e3.getUint8(t2 + 1) && 1165519206 === e3.getUint32(t2 + 4) && 0 === e3.getUint16(t2 + 8);
53046     }
53047     async parse() {
53048       this.parseHeader();
53049       let { options: e3 } = this;
53050       return e3.ifd0.enabled && await this.parseIfd0Block(), e3.exif.enabled && await this.safeParse("parseExifBlock"), e3.gps.enabled && await this.safeParse("parseGpsBlock"), e3.interop.enabled && await this.safeParse("parseInteropBlock"), e3.ifd1.enabled && await this.safeParse("parseThumbnailBlock"), this.createOutput();
53051     }
53052     safeParse(e3) {
53053       let t2 = this[e3]();
53054       return void 0 !== t2.catch && (t2 = t2.catch(this.handleError)), t2;
53055     }
53056     findIfd0Offset() {
53057       void 0 === this.ifd0Offset && (this.ifd0Offset = this.chunk.getUint32(4));
53058     }
53059     findIfd1Offset() {
53060       if (void 0 === this.ifd1Offset) {
53061         this.findIfd0Offset();
53062         let e3 = this.chunk.getUint16(this.ifd0Offset), t2 = this.ifd0Offset + 2 + 12 * e3;
53063         this.ifd1Offset = this.chunk.getUint32(t2);
53064       }
53065     }
53066     parseBlock(e3, t2) {
53067       let i3 = /* @__PURE__ */ new Map();
53068       return this[t2] = i3, this.parseTags(e3, t2, i3), i3;
53069     }
53070     async parseIfd0Block() {
53071       if (this.ifd0)
53072         return;
53073       let { file: e3 } = this;
53074       this.findIfd0Offset(), this.ifd0Offset < 8 && g2("Malformed EXIF data"), !e3.chunked && this.ifd0Offset > e3.byteLength && g2("IFD0 offset points to outside of file.\nthis.ifd0Offset: ".concat(this.ifd0Offset, ", file.byteLength: ").concat(e3.byteLength)), e3.tiff && await e3.ensureChunk(this.ifd0Offset, S(this.options));
53075       let t2 = this.parseBlock(this.ifd0Offset, "ifd0");
53076       return 0 !== t2.size ? (this.exifOffset = t2.get(34665), this.interopOffset = t2.get(40965), this.gpsOffset = t2.get(34853), this.xmp = t2.get(700), this.iptc = t2.get(33723), this.icc = t2.get(34675), this.options.sanitize && (t2.delete(34665), t2.delete(40965), t2.delete(34853), t2.delete(700), t2.delete(33723), t2.delete(34675)), t2) : void 0;
53077     }
53078     async parseExifBlock() {
53079       if (this.exif)
53080         return;
53081       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.exifOffset)
53082         return;
53083       this.file.tiff && await this.file.ensureChunk(this.exifOffset, S(this.options));
53084       let e3 = this.parseBlock(this.exifOffset, "exif");
53085       return this.interopOffset || (this.interopOffset = e3.get(40965)), this.makerNote = e3.get(37500), this.userComment = e3.get(37510), this.options.sanitize && (e3.delete(40965), e3.delete(37500), e3.delete(37510)), this.unpack(e3, 41728), this.unpack(e3, 41729), e3;
53086     }
53087     unpack(e3, t2) {
53088       let i3 = e3.get(t2);
53089       i3 && 1 === i3.length && e3.set(t2, i3[0]);
53090     }
53091     async parseGpsBlock() {
53092       if (this.gps)
53093         return;
53094       if (this.ifd0 || await this.parseIfd0Block(), void 0 === this.gpsOffset)
53095         return;
53096       let e3 = this.parseBlock(this.gpsOffset, "gps");
53097       return e3 && e3.has(2) && e3.has(4) && (e3.set("latitude", de(...e3.get(2), e3.get(1))), e3.set("longitude", de(...e3.get(4), e3.get(3)))), e3;
53098     }
53099     async parseInteropBlock() {
53100       if (!this.interop && (this.ifd0 || await this.parseIfd0Block(), void 0 !== this.interopOffset || this.exif || await this.parseExifBlock(), void 0 !== this.interopOffset))
53101         return this.parseBlock(this.interopOffset, "interop");
53102     }
53103     async parseThumbnailBlock(e3 = false) {
53104       if (!this.ifd1 && !this.ifd1Parsed && (!this.options.mergeOutput || e3))
53105         return this.findIfd1Offset(), this.ifd1Offset > 0 && (this.parseBlock(this.ifd1Offset, "ifd1"), this.ifd1Parsed = true), this.ifd1;
53106     }
53107     async extractThumbnail() {
53108       if (this.headerParsed || this.parseHeader(), this.ifd1Parsed || await this.parseThumbnailBlock(true), void 0 === this.ifd1)
53109         return;
53110       let e3 = this.ifd1.get(513), t2 = this.ifd1.get(514);
53111       return this.chunk.getUint8Array(e3, t2);
53112     }
53113     get image() {
53114       return this.ifd0;
53115     }
53116     get thumbnail() {
53117       return this.ifd1;
53118     }
53119     createOutput() {
53120       let e3, t2, i3, n3 = {};
53121       for (t2 of H)
53122         if (e3 = this[t2], !p(e3))
53123           if (i3 = this.canTranslate ? this.translateBlock(e3, t2) : Object.fromEntries(e3), this.options.mergeOutput) {
53124             if ("ifd1" === t2)
53125               continue;
53126             Object.assign(n3, i3);
53127           } else
53128             n3[t2] = i3;
53129       return this.makerNote && (n3.makerNote = this.makerNote), this.userComment && (n3.userComment = this.userComment), n3;
53130     }
53131     assignToOutput(e3, t2) {
53132       if (this.globalOptions.mergeOutput)
53133         Object.assign(e3, t2);
53134       else
53135         for (let [i3, n3] of Object.entries(t2))
53136           this.assignObjectToOutput(e3, i3, n3);
53137     }
53138   };
53139   function de(e3, t2, i3, n3) {
53140     var s2 = e3 + t2 / 60 + i3 / 3600;
53141     return "S" !== n3 && "W" !== n3 || (s2 *= -1), s2;
53142   }
53143   c(fe, "type", "tiff"), c(fe, "headerLength", 10), T.set("tiff", fe);
53144   var pe = Object.freeze({ __proto__: null, default: ne, Exifr: te, fileParsers: w, segmentParsers: T, fileReaders: A, tagKeys: E, tagValues: B, tagRevivers: N, createDictionary: U, extendDictionary: F, fetchUrlAsArrayBuffer: M, readBlobAsArrayBuffer: R, chunkedProps: G, otherSegments: V, segments: z, tiffBlocks: H, segmentsAndBlocks: j, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q, parse: ie });
53145   var ge = { ifd0: false, ifd1: false, exif: false, gps: false, interop: false, sanitize: false, reviveValues: true, translateKeys: false, translateValues: false, mergeOutput: false };
53146   var me = Object.assign({}, ge, { firstChunkSize: 4e4, gps: [1, 2, 3, 4] });
53147   async function Se(e3) {
53148     let t2 = new te(me);
53149     await t2.read(e3);
53150     let i3 = await t2.parse();
53151     if (i3 && i3.gps) {
53152       let { latitude: e4, longitude: t3 } = i3.gps;
53153       return { latitude: e4, longitude: t3 };
53154     }
53155   }
53156   var Ce = Object.assign({}, ge, { tiff: false, ifd1: true, mergeOutput: false });
53157   async function ye(e3) {
53158     let t2 = new te(Ce);
53159     await t2.read(e3);
53160     let i3 = await t2.extractThumbnail();
53161     return i3 && a ? s.from(i3) : i3;
53162   }
53163   async function be(e3) {
53164     let t2 = await this.thumbnail(e3);
53165     if (void 0 !== t2) {
53166       let e4 = new Blob([t2]);
53167       return URL.createObjectURL(e4);
53168     }
53169   }
53170   var Ie = Object.assign({}, ge, { firstChunkSize: 4e4, ifd0: [274] });
53171   async function Pe(e3) {
53172     let t2 = new te(Ie);
53173     await t2.read(e3);
53174     let i3 = await t2.parse();
53175     if (i3 && i3.ifd0)
53176       return i3.ifd0[274];
53177   }
53178   var ke = Object.freeze({ 1: { dimensionSwapped: false, scaleX: 1, scaleY: 1, deg: 0, rad: 0 }, 2: { dimensionSwapped: false, scaleX: -1, scaleY: 1, deg: 0, rad: 0 }, 3: { dimensionSwapped: false, scaleX: 1, scaleY: 1, deg: 180, rad: 180 * Math.PI / 180 }, 4: { dimensionSwapped: false, scaleX: -1, scaleY: 1, deg: 180, rad: 180 * Math.PI / 180 }, 5: { dimensionSwapped: true, scaleX: 1, scaleY: -1, deg: 90, rad: 90 * Math.PI / 180 }, 6: { dimensionSwapped: true, scaleX: 1, scaleY: 1, deg: 90, rad: 90 * Math.PI / 180 }, 7: { dimensionSwapped: true, scaleX: 1, scaleY: -1, deg: 270, rad: 270 * Math.PI / 180 }, 8: { dimensionSwapped: true, scaleX: 1, scaleY: 1, deg: 270, rad: 270 * Math.PI / 180 } });
53179   var we = true;
53180   var Te = true;
53181   if ("object" == typeof navigator) {
53182     let e3 = navigator.userAgent;
53183     if (e3.includes("iPad") || e3.includes("iPhone")) {
53184       let t2 = e3.match(/OS (\d+)_(\d+)/);
53185       if (t2) {
53186         let [, e4, i3] = t2, n3 = Number(e4) + 0.1 * Number(i3);
53187         we = n3 < 13.4, Te = false;
53188       }
53189     } else if (e3.includes("OS X 10")) {
53190       let [, t2] = e3.match(/OS X 10[_.](\d+)/);
53191       we = Te = Number(t2) < 15;
53192     }
53193     if (e3.includes("Chrome/")) {
53194       let [, t2] = e3.match(/Chrome\/(\d+)/);
53195       we = Te = Number(t2) < 81;
53196     } else if (e3.includes("Firefox/")) {
53197       let [, t2] = e3.match(/Firefox\/(\d+)/);
53198       we = Te = Number(t2) < 77;
53199     }
53200   }
53201   async function Ae(e3) {
53202     let t2 = await Pe(e3);
53203     return Object.assign({ canvas: we, css: Te }, ke[t2]);
53204   }
53205   var De = class extends I {
53206     constructor(...e3) {
53207       super(...e3), c(this, "ranges", new Oe()), 0 !== this.byteLength && this.ranges.add(0, this.byteLength);
53208     }
53209     _tryExtend(e3, t2, i3) {
53210       if (0 === e3 && 0 === this.byteLength && i3) {
53211         let e4 = new DataView(i3.buffer || i3, i3.byteOffset, i3.byteLength);
53212         this._swapDataView(e4);
53213       } else {
53214         let i4 = e3 + t2;
53215         if (i4 > this.byteLength) {
53216           let { dataView: e4 } = this._extend(i4);
53217           this._swapDataView(e4);
53218         }
53219       }
53220     }
53221     _extend(e3) {
53222       let t2;
53223       t2 = a ? s.allocUnsafe(e3) : new Uint8Array(e3);
53224       let i3 = new DataView(t2.buffer, t2.byteOffset, t2.byteLength);
53225       return t2.set(new Uint8Array(this.buffer, this.byteOffset, this.byteLength), 0), { uintView: t2, dataView: i3 };
53226     }
53227     subarray(e3, t2, i3 = false) {
53228       return t2 = t2 || this._lengthToEnd(e3), i3 && this._tryExtend(e3, t2), this.ranges.add(e3, t2), super.subarray(e3, t2);
53229     }
53230     set(e3, t2, i3 = false) {
53231       i3 && this._tryExtend(t2, e3.byteLength, e3);
53232       let n3 = super.set(e3, t2);
53233       return this.ranges.add(t2, n3.byteLength), n3;
53234     }
53235     async ensureChunk(e3, t2) {
53236       this.chunked && (this.ranges.available(e3, t2) || await this.readChunk(e3, t2));
53237     }
53238     available(e3, t2) {
53239       return this.ranges.available(e3, t2);
53240     }
53241   };
53242   var Oe = class {
53243     constructor() {
53244       c(this, "list", []);
53245     }
53246     get length() {
53247       return this.list.length;
53248     }
53249     add(e3, t2, i3 = 0) {
53250       let n3 = e3 + t2, s2 = this.list.filter((t3) => xe(e3, t3.offset, n3) || xe(e3, t3.end, n3));
53251       if (s2.length > 0) {
53252         e3 = Math.min(e3, ...s2.map((e4) => e4.offset)), n3 = Math.max(n3, ...s2.map((e4) => e4.end)), t2 = n3 - e3;
53253         let i4 = s2.shift();
53254         i4.offset = e3, i4.length = t2, i4.end = n3, this.list = this.list.filter((e4) => !s2.includes(e4));
53255       } else
53256         this.list.push({ offset: e3, length: t2, end: n3 });
53257     }
53258     available(e3, t2) {
53259       let i3 = e3 + t2;
53260       return this.list.some((t3) => t3.offset <= e3 && i3 <= t3.end);
53261     }
53262   };
53263   function xe(e3, t2, i3) {
53264     return e3 <= t2 && t2 <= i3;
53265   }
53266   var ve = class extends De {
53267     constructor(e3, t2) {
53268       super(0), c(this, "chunksRead", 0), this.input = e3, this.options = t2;
53269     }
53270     async readWhole() {
53271       this.chunked = false, await this.readChunk(this.nextChunkOffset);
53272     }
53273     async readChunked() {
53274       this.chunked = true, await this.readChunk(0, this.options.firstChunkSize);
53275     }
53276     async readNextChunk(e3 = this.nextChunkOffset) {
53277       if (this.fullyRead)
53278         return this.chunksRead++, false;
53279       let t2 = this.options.chunkSize, i3 = await this.readChunk(e3, t2);
53280       return !!i3 && i3.byteLength === t2;
53281     }
53282     async readChunk(e3, t2) {
53283       if (this.chunksRead++, 0 !== (t2 = this.safeWrapAddress(e3, t2)))
53284         return this._readChunk(e3, t2);
53285     }
53286     safeWrapAddress(e3, t2) {
53287       return void 0 !== this.size && e3 + t2 > this.size ? Math.max(0, this.size - e3) : t2;
53288     }
53289     get nextChunkOffset() {
53290       if (0 !== this.ranges.list.length)
53291         return this.ranges.list[0].length;
53292     }
53293     get canReadNextChunk() {
53294       return this.chunksRead < this.options.chunkLimit;
53295     }
53296     get fullyRead() {
53297       return void 0 !== this.size && this.nextChunkOffset === this.size;
53298     }
53299     read() {
53300       return this.options.chunked ? this.readChunked() : this.readWhole();
53301     }
53302     close() {
53303     }
53304   };
53305   A.set("blob", class extends ve {
53306     async readWhole() {
53307       this.chunked = false;
53308       let e3 = await R(this.input);
53309       this._swapArrayBuffer(e3);
53310     }
53311     readChunked() {
53312       return this.chunked = true, this.size = this.input.size, super.readChunked();
53313     }
53314     async _readChunk(e3, t2) {
53315       let i3 = t2 ? e3 + t2 : void 0, n3 = this.input.slice(e3, i3), s2 = await R(n3);
53316       return this.set(s2, e3, true);
53317     }
53318   });
53319   var Me = Object.freeze({ __proto__: null, default: pe, Exifr: te, fileParsers: w, segmentParsers: T, fileReaders: A, tagKeys: E, tagValues: B, tagRevivers: N, createDictionary: U, extendDictionary: F, fetchUrlAsArrayBuffer: M, readBlobAsArrayBuffer: R, chunkedProps: G, otherSegments: V, segments: z, tiffBlocks: H, segmentsAndBlocks: j, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q, parse: ie, gpsOnlyOptions: me, gps: Se, thumbnailOnlyOptions: Ce, thumbnail: ye, thumbnailUrl: be, orientationOnlyOptions: Ie, orientation: Pe, rotations: ke, get rotateCanvas() {
53320     return we;
53321   }, get rotateCss() {
53322     return Te;
53323   }, rotation: Ae });
53324   A.set("url", class extends ve {
53325     async readWhole() {
53326       this.chunked = false;
53327       let e3 = await M(this.input);
53328       e3 instanceof ArrayBuffer ? this._swapArrayBuffer(e3) : e3 instanceof Uint8Array && this._swapBuffer(e3);
53329     }
53330     async _readChunk(e3, t2) {
53331       let i3 = t2 ? e3 + t2 - 1 : void 0, n3 = this.options.httpHeaders || {};
53332       (e3 || i3) && (n3.range = "bytes=".concat([e3, i3].join("-")));
53333       let s2 = await h(this.input, { headers: n3 }), r2 = await s2.arrayBuffer(), a2 = r2.byteLength;
53334       if (416 !== s2.status)
53335         return a2 !== t2 && (this.size = e3 + a2), this.set(r2, e3, true);
53336     }
53337   });
53338   I.prototype.getUint64 = function(e3) {
53339     let t2 = this.getUint32(e3), i3 = this.getUint32(e3 + 4);
53340     return t2 < 1048575 ? t2 << 32 | i3 : void 0 !== typeof r ? (console.warn("Using BigInt because of type 64uint but JS can only handle 53b numbers."), r(t2) << r(32) | r(i3)) : void g2("Trying to read 64b value but JS can only handle 53b numbers.");
53341   };
53342   var Re = class extends se {
53343     parseBoxes(e3 = 0) {
53344       let t2 = [];
53345       for (; e3 < this.file.byteLength - 4; ) {
53346         let i3 = this.parseBoxHead(e3);
53347         if (t2.push(i3), 0 === i3.length)
53348           break;
53349         e3 += i3.length;
53350       }
53351       return t2;
53352     }
53353     parseSubBoxes(e3) {
53354       e3.boxes = this.parseBoxes(e3.start);
53355     }
53356     findBox(e3, t2) {
53357       return void 0 === e3.boxes && this.parseSubBoxes(e3), e3.boxes.find((e4) => e4.kind === t2);
53358     }
53359     parseBoxHead(e3) {
53360       let t2 = this.file.getUint32(e3), i3 = this.file.getString(e3 + 4, 4), n3 = e3 + 8;
53361       return 1 === t2 && (t2 = this.file.getUint64(e3 + 8), n3 += 8), { offset: e3, length: t2, kind: i3, start: n3 };
53362     }
53363     parseBoxFullHead(e3) {
53364       if (void 0 !== e3.version)
53365         return;
53366       let t2 = this.file.getUint32(e3.start);
53367       e3.version = t2 >> 24, e3.start += 4;
53368     }
53369   };
53370   var Le = class extends Re {
53371     static canHandle(e3, t2) {
53372       if (0 !== t2)
53373         return false;
53374       let i3 = e3.getUint16(2);
53375       if (i3 > 50)
53376         return false;
53377       let n3 = 16, s2 = [];
53378       for (; n3 < i3; )
53379         s2.push(e3.getString(n3, 4)), n3 += 4;
53380       return s2.includes(this.type);
53381     }
53382     async parse() {
53383       let e3 = this.file.getUint32(0), t2 = this.parseBoxHead(e3);
53384       for (; "meta" !== t2.kind; )
53385         e3 += t2.length, await this.file.ensureChunk(e3, 16), t2 = this.parseBoxHead(e3);
53386       await this.file.ensureChunk(t2.offset, t2.length), this.parseBoxFullHead(t2), this.parseSubBoxes(t2), this.options.icc.enabled && await this.findIcc(t2), this.options.tiff.enabled && await this.findExif(t2);
53387     }
53388     async registerSegment(e3, t2, i3) {
53389       await this.file.ensureChunk(t2, i3);
53390       let n3 = this.file.subarray(t2, i3);
53391       this.createParser(e3, n3);
53392     }
53393     async findIcc(e3) {
53394       let t2 = this.findBox(e3, "iprp");
53395       if (void 0 === t2)
53396         return;
53397       let i3 = this.findBox(t2, "ipco");
53398       if (void 0 === i3)
53399         return;
53400       let n3 = this.findBox(i3, "colr");
53401       void 0 !== n3 && await this.registerSegment("icc", n3.offset + 12, n3.length);
53402     }
53403     async findExif(e3) {
53404       let t2 = this.findBox(e3, "iinf");
53405       if (void 0 === t2)
53406         return;
53407       let i3 = this.findBox(e3, "iloc");
53408       if (void 0 === i3)
53409         return;
53410       let n3 = this.findExifLocIdInIinf(t2), s2 = this.findExtentInIloc(i3, n3);
53411       if (void 0 === s2)
53412         return;
53413       let [r2, a2] = s2;
53414       await this.file.ensureChunk(r2, a2);
53415       let o2 = 4 + this.file.getUint32(r2);
53416       r2 += o2, a2 -= o2, await this.registerSegment("tiff", r2, a2);
53417     }
53418     findExifLocIdInIinf(e3) {
53419       this.parseBoxFullHead(e3);
53420       let t2, i3, n3, s2, r2 = e3.start, a2 = this.file.getUint16(r2);
53421       for (r2 += 2; a2--; ) {
53422         if (t2 = this.parseBoxHead(r2), this.parseBoxFullHead(t2), i3 = t2.start, t2.version >= 2 && (n3 = 3 === t2.version ? 4 : 2, s2 = this.file.getString(i3 + n3 + 2, 4), "Exif" === s2))
53423           return this.file.getUintBytes(i3, n3);
53424         r2 += t2.length;
53425       }
53426     }
53427     get8bits(e3) {
53428       let t2 = this.file.getUint8(e3);
53429       return [t2 >> 4, 15 & t2];
53430     }
53431     findExtentInIloc(e3, t2) {
53432       this.parseBoxFullHead(e3);
53433       let i3 = e3.start, [n3, s2] = this.get8bits(i3++), [r2, a2] = this.get8bits(i3++), o2 = 2 === e3.version ? 4 : 2, l2 = 1 === e3.version || 2 === e3.version ? 2 : 0, h2 = a2 + n3 + s2, u2 = 2 === e3.version ? 4 : 2, c2 = this.file.getUintBytes(i3, u2);
53434       for (i3 += u2; c2--; ) {
53435         let e4 = this.file.getUintBytes(i3, o2);
53436         i3 += o2 + l2 + 2 + r2;
53437         let u3 = this.file.getUint16(i3);
53438         if (i3 += 2, e4 === t2)
53439           return u3 > 1 && console.warn("ILOC box has more than one extent but we're only processing one\nPlease create an issue at https://github.com/MikeKovarik/exifr with this file"), [this.file.getUintBytes(i3 + a2, n3), this.file.getUintBytes(i3 + a2 + n3, s2)];
53440         i3 += u3 * h2;
53441       }
53442     }
53443   };
53444   var Ue = class extends Le {
53445   };
53446   c(Ue, "type", "heic");
53447   var Fe = class extends Le {
53448   };
53449   c(Fe, "type", "avif"), w.set("heic", Ue), w.set("avif", Fe), U(E, ["ifd0", "ifd1"], [[256, "ImageWidth"], [257, "ImageHeight"], [258, "BitsPerSample"], [259, "Compression"], [262, "PhotometricInterpretation"], [270, "ImageDescription"], [271, "Make"], [272, "Model"], [273, "StripOffsets"], [274, "Orientation"], [277, "SamplesPerPixel"], [278, "RowsPerStrip"], [279, "StripByteCounts"], [282, "XResolution"], [283, "YResolution"], [284, "PlanarConfiguration"], [296, "ResolutionUnit"], [301, "TransferFunction"], [305, "Software"], [306, "ModifyDate"], [315, "Artist"], [316, "HostComputer"], [317, "Predictor"], [318, "WhitePoint"], [319, "PrimaryChromaticities"], [513, "ThumbnailOffset"], [514, "ThumbnailLength"], [529, "YCbCrCoefficients"], [530, "YCbCrSubSampling"], [531, "YCbCrPositioning"], [532, "ReferenceBlackWhite"], [700, "ApplicationNotes"], [33432, "Copyright"], [33723, "IPTC"], [34665, "ExifIFD"], [34675, "ICC"], [34853, "GpsIFD"], [330, "SubIFD"], [40965, "InteropIFD"], [40091, "XPTitle"], [40092, "XPComment"], [40093, "XPAuthor"], [40094, "XPKeywords"], [40095, "XPSubject"]]), U(E, "exif", [[33434, "ExposureTime"], [33437, "FNumber"], [34850, "ExposureProgram"], [34852, "SpectralSensitivity"], [34855, "ISO"], [34858, "TimeZoneOffset"], [34859, "SelfTimerMode"], [34864, "SensitivityType"], [34865, "StandardOutputSensitivity"], [34866, "RecommendedExposureIndex"], [34867, "ISOSpeed"], [34868, "ISOSpeedLatitudeyyy"], [34869, "ISOSpeedLatitudezzz"], [36864, "ExifVersion"], [36867, "DateTimeOriginal"], [36868, "CreateDate"], [36873, "GooglePlusUploadCode"], [36880, "OffsetTime"], [36881, "OffsetTimeOriginal"], [36882, "OffsetTimeDigitized"], [37121, "ComponentsConfiguration"], [37122, "CompressedBitsPerPixel"], [37377, "ShutterSpeedValue"], [37378, "ApertureValue"], [37379, "BrightnessValue"], [37380, "ExposureCompensation"], [37381, "MaxApertureValue"], [37382, "SubjectDistance"], [37383, "MeteringMode"], [37384, "LightSource"], [37385, "Flash"], [37386, "FocalLength"], [37393, "ImageNumber"], [37394, "SecurityClassification"], [37395, "ImageHistory"], [37396, "SubjectArea"], [37500, "MakerNote"], [37510, "UserComment"], [37520, "SubSecTime"], [37521, "SubSecTimeOriginal"], [37522, "SubSecTimeDigitized"], [37888, "AmbientTemperature"], [37889, "Humidity"], [37890, "Pressure"], [37891, "WaterDepth"], [37892, "Acceleration"], [37893, "CameraElevationAngle"], [40960, "FlashpixVersion"], [40961, "ColorSpace"], [40962, "ExifImageWidth"], [40963, "ExifImageHeight"], [40964, "RelatedSoundFile"], [41483, "FlashEnergy"], [41486, "FocalPlaneXResolution"], [41487, "FocalPlaneYResolution"], [41488, "FocalPlaneResolutionUnit"], [41492, "SubjectLocation"], [41493, "ExposureIndex"], [41495, "SensingMethod"], [41728, "FileSource"], [41729, "SceneType"], [41730, "CFAPattern"], [41985, "CustomRendered"], [41986, "ExposureMode"], [41987, "WhiteBalance"], [41988, "DigitalZoomRatio"], [41989, "FocalLengthIn35mmFormat"], [41990, "SceneCaptureType"], [41991, "GainControl"], [41992, "Contrast"], [41993, "Saturation"], [41994, "Sharpness"], [41996, "SubjectDistanceRange"], [42016, "ImageUniqueID"], [42032, "OwnerName"], [42033, "SerialNumber"], [42034, "LensInfo"], [42035, "LensMake"], [42036, "LensModel"], [42037, "LensSerialNumber"], [42080, "CompositeImage"], [42081, "CompositeImageCount"], [42082, "CompositeImageExposureTimes"], [42240, "Gamma"], [59932, "Padding"], [59933, "OffsetSchema"], [65e3, "OwnerName"], [65001, "SerialNumber"], [65002, "Lens"], [65100, "RawFile"], [65101, "Converter"], [65102, "WhiteBalance"], [65105, "Exposure"], [65106, "Shadows"], [65107, "Brightness"], [65108, "Contrast"], [65109, "Saturation"], [65110, "Sharpness"], [65111, "Smoothness"], [65112, "MoireFilter"], [40965, "InteropIFD"]]), U(E, "gps", [[0, "GPSVersionID"], [1, "GPSLatitudeRef"], [2, "GPSLatitude"], [3, "GPSLongitudeRef"], [4, "GPSLongitude"], [5, "GPSAltitudeRef"], [6, "GPSAltitude"], [7, "GPSTimeStamp"], [8, "GPSSatellites"], [9, "GPSStatus"], [10, "GPSMeasureMode"], [11, "GPSDOP"], [12, "GPSSpeedRef"], [13, "GPSSpeed"], [14, "GPSTrackRef"], [15, "GPSTrack"], [16, "GPSImgDirectionRef"], [17, "GPSImgDirection"], [18, "GPSMapDatum"], [19, "GPSDestLatitudeRef"], [20, "GPSDestLatitude"], [21, "GPSDestLongitudeRef"], [22, "GPSDestLongitude"], [23, "GPSDestBearingRef"], [24, "GPSDestBearing"], [25, "GPSDestDistanceRef"], [26, "GPSDestDistance"], [27, "GPSProcessingMethod"], [28, "GPSAreaInformation"], [29, "GPSDateStamp"], [30, "GPSDifferential"], [31, "GPSHPositioningError"]]), U(B, ["ifd0", "ifd1"], [[274, { 1: "Horizontal (normal)", 2: "Mirror horizontal", 3: "Rotate 180", 4: "Mirror vertical", 5: "Mirror horizontal and rotate 270 CW", 6: "Rotate 90 CW", 7: "Mirror horizontal and rotate 90 CW", 8: "Rotate 270 CW" }], [296, { 1: "None", 2: "inches", 3: "cm" }]]);
53450   var Ee = U(B, "exif", [[34850, { 0: "Not defined", 1: "Manual", 2: "Normal program", 3: "Aperture priority", 4: "Shutter priority", 5: "Creative program", 6: "Action program", 7: "Portrait mode", 8: "Landscape mode" }], [37121, { 0: "-", 1: "Y", 2: "Cb", 3: "Cr", 4: "R", 5: "G", 6: "B" }], [37383, { 0: "Unknown", 1: "Average", 2: "CenterWeightedAverage", 3: "Spot", 4: "MultiSpot", 5: "Pattern", 6: "Partial", 255: "Other" }], [37384, { 0: "Unknown", 1: "Daylight", 2: "Fluorescent", 3: "Tungsten (incandescent light)", 4: "Flash", 9: "Fine weather", 10: "Cloudy weather", 11: "Shade", 12: "Daylight fluorescent (D 5700 - 7100K)", 13: "Day white fluorescent (N 4600 - 5400K)", 14: "Cool white fluorescent (W 3900 - 4500K)", 15: "White fluorescent (WW 3200 - 3700K)", 17: "Standard light A", 18: "Standard light B", 19: "Standard light C", 20: "D55", 21: "D65", 22: "D75", 23: "D50", 24: "ISO studio tungsten", 255: "Other" }], [37385, { 0: "Flash did not fire", 1: "Flash fired", 5: "Strobe return light not detected", 7: "Strobe return light detected", 9: "Flash fired, compulsory flash mode", 13: "Flash fired, compulsory flash mode, return light not detected", 15: "Flash fired, compulsory flash mode, return light detected", 16: "Flash did not fire, compulsory flash mode", 24: "Flash did not fire, auto mode", 25: "Flash fired, auto mode", 29: "Flash fired, auto mode, return light not detected", 31: "Flash fired, auto mode, return light detected", 32: "No flash function", 65: "Flash fired, red-eye reduction mode", 69: "Flash fired, red-eye reduction mode, return light not detected", 71: "Flash fired, red-eye reduction mode, return light detected", 73: "Flash fired, compulsory flash mode, red-eye reduction mode", 77: "Flash fired, compulsory flash mode, red-eye reduction mode, return light not detected", 79: "Flash fired, compulsory flash mode, red-eye reduction mode, return light detected", 89: "Flash fired, auto mode, red-eye reduction mode", 93: "Flash fired, auto mode, return light not detected, red-eye reduction mode", 95: "Flash fired, auto mode, return light detected, red-eye reduction mode" }], [41495, { 1: "Not defined", 2: "One-chip color area sensor", 3: "Two-chip color area sensor", 4: "Three-chip color area sensor", 5: "Color sequential area sensor", 7: "Trilinear sensor", 8: "Color sequential linear sensor" }], [41728, { 1: "Film Scanner", 2: "Reflection Print Scanner", 3: "Digital Camera" }], [41729, { 1: "Directly photographed" }], [41985, { 0: "Normal", 1: "Custom", 2: "HDR (no original saved)", 3: "HDR (original saved)", 4: "Original (for HDR)", 6: "Panorama", 7: "Portrait HDR", 8: "Portrait" }], [41986, { 0: "Auto", 1: "Manual", 2: "Auto bracket" }], [41987, { 0: "Auto", 1: "Manual" }], [41990, { 0: "Standard", 1: "Landscape", 2: "Portrait", 3: "Night", 4: "Other" }], [41991, { 0: "None", 1: "Low gain up", 2: "High gain up", 3: "Low gain down", 4: "High gain down" }], [41996, { 0: "Unknown", 1: "Macro", 2: "Close", 3: "Distant" }], [42080, { 0: "Unknown", 1: "Not a Composite Image", 2: "General Composite Image", 3: "Composite Image Captured While Shooting" }]]);
53451   var Be = { 1: "No absolute unit of measurement", 2: "Inch", 3: "Centimeter" };
53452   Ee.set(37392, Be), Ee.set(41488, Be);
53453   var Ne = { 0: "Normal", 1: "Low", 2: "High" };
53454   function Ge(e3) {
53455     return "object" == typeof e3 && void 0 !== e3.length ? e3[0] : e3;
53456   }
53457   function Ve(e3) {
53458     let t2 = Array.from(e3).slice(1);
53459     return t2[1] > 15 && (t2 = t2.map((e4) => String.fromCharCode(e4))), "0" !== t2[2] && 0 !== t2[2] || t2.pop(), t2.join(".");
53460   }
53461   function ze(e3) {
53462     if ("string" == typeof e3) {
53463       var [t2, i3, n3, s2, r2, a2] = e3.trim().split(/[-: ]/g).map(Number), o2 = new Date(t2, i3 - 1, n3);
53464       return Number.isNaN(s2) || Number.isNaN(r2) || Number.isNaN(a2) || (o2.setHours(s2), o2.setMinutes(r2), o2.setSeconds(a2)), Number.isNaN(+o2) ? e3 : o2;
53465     }
53466   }
53467   function He(e3) {
53468     if ("string" == typeof e3)
53469       return e3;
53470     let t2 = [];
53471     if (0 === e3[1] && 0 === e3[e3.length - 1])
53472       for (let i3 = 0; i3 < e3.length; i3 += 2)
53473         t2.push(je(e3[i3 + 1], e3[i3]));
53474     else
53475       for (let i3 = 0; i3 < e3.length; i3 += 2)
53476         t2.push(je(e3[i3], e3[i3 + 1]));
53477     return m(String.fromCodePoint(...t2));
53478   }
53479   function je(e3, t2) {
53480     return e3 << 8 | t2;
53481   }
53482   Ee.set(41992, Ne), Ee.set(41993, Ne), Ee.set(41994, Ne), U(N, ["ifd0", "ifd1"], [[50827, function(e3) {
53483     return "string" != typeof e3 ? b(e3) : e3;
53484   }], [306, ze], [40091, He], [40092, He], [40093, He], [40094, He], [40095, He]]), U(N, "exif", [[40960, Ve], [36864, Ve], [36867, ze], [36868, ze], [40962, Ge], [40963, Ge]]), U(N, "gps", [[0, (e3) => Array.from(e3).join(".")], [7, (e3) => Array.from(e3).join(":")]]);
53485   var We = class extends re2 {
53486     static canHandle(e3, t2) {
53487       return 225 === e3.getUint8(t2 + 1) && 1752462448 === e3.getUint32(t2 + 4) && "http://ns.adobe.com/" === e3.getString(t2 + 4, "http://ns.adobe.com/".length);
53488     }
53489     static headerLength(e3, t2) {
53490       return "http://ns.adobe.com/xmp/extension/" === e3.getString(t2 + 4, "http://ns.adobe.com/xmp/extension/".length) ? 79 : 4 + "http://ns.adobe.com/xap/1.0/".length + 1;
53491     }
53492     static findPosition(e3, t2) {
53493       let i3 = super.findPosition(e3, t2);
53494       return i3.multiSegment = i3.extended = 79 === i3.headerLength, i3.multiSegment ? (i3.chunkCount = e3.getUint8(t2 + 72), i3.chunkNumber = e3.getUint8(t2 + 76), 0 !== e3.getUint8(t2 + 77) && i3.chunkNumber++) : (i3.chunkCount = 1 / 0, i3.chunkNumber = -1), i3;
53495     }
53496     static handleMultiSegments(e3) {
53497       return e3.map((e4) => e4.chunk.getString()).join("");
53498     }
53499     normalizeInput(e3) {
53500       return "string" == typeof e3 ? e3 : I.from(e3).getString();
53501     }
53502     parse(e3 = this.chunk) {
53503       if (!this.localOptions.parse)
53504         return e3;
53505       e3 = function(e4) {
53506         let t3 = {}, i4 = {};
53507         for (let e6 of Ze)
53508           t3[e6] = [], i4[e6] = 0;
53509         return e4.replace(et, (e6, n4, s2) => {
53510           if ("<" === n4) {
53511             let n5 = ++i4[s2];
53512             return t3[s2].push(n5), "".concat(e6, "#").concat(n5);
53513           }
53514           return "".concat(e6, "#").concat(t3[s2].pop());
53515         });
53516       }(e3);
53517       let t2 = Xe.findAll(e3, "rdf", "Description");
53518       0 === t2.length && t2.push(new Xe("rdf", "Description", void 0, e3));
53519       let i3, n3 = {};
53520       for (let e4 of t2)
53521         for (let t3 of e4.properties)
53522           i3 = Je(t3.ns, n3), _e(t3, i3);
53523       return function(e4) {
53524         let t3;
53525         for (let i4 in e4)
53526           t3 = e4[i4] = f(e4[i4]), void 0 === t3 && delete e4[i4];
53527         return f(e4);
53528       }(n3);
53529     }
53530     assignToOutput(e3, t2) {
53531       if (this.localOptions.parse)
53532         for (let [i3, n3] of Object.entries(t2))
53533           switch (i3) {
53534             case "tiff":
53535               this.assignObjectToOutput(e3, "ifd0", n3);
53536               break;
53537             case "exif":
53538               this.assignObjectToOutput(e3, "exif", n3);
53539               break;
53540             case "xmlns":
53541               break;
53542             default:
53543               this.assignObjectToOutput(e3, i3, n3);
53544           }
53545       else
53546         e3.xmp = t2;
53547     }
53548   };
53549   c(We, "type", "xmp"), c(We, "multiSegment", true), T.set("xmp", We);
53550   var Ke = class _Ke {
53551     static findAll(e3) {
53552       return qe(e3, /([a-zA-Z0-9-]+):([a-zA-Z0-9-]+)=("[^"]*"|'[^']*')/gm).map(_Ke.unpackMatch);
53553     }
53554     static unpackMatch(e3) {
53555       let t2 = e3[1], i3 = e3[2], n3 = e3[3].slice(1, -1);
53556       return n3 = Qe(n3), new _Ke(t2, i3, n3);
53557     }
53558     constructor(e3, t2, i3) {
53559       this.ns = e3, this.name = t2, this.value = i3;
53560     }
53561     serialize() {
53562       return this.value;
53563     }
53564   };
53565   var Xe = class _Xe {
53566     static findAll(e3, t2, i3) {
53567       if (void 0 !== t2 || void 0 !== i3) {
53568         t2 = t2 || "[\\w\\d-]+", i3 = i3 || "[\\w\\d-]+";
53569         var n3 = new RegExp("<(".concat(t2, "):(").concat(i3, ")(#\\d+)?((\\s+?[\\w\\d-:]+=(\"[^\"]*\"|'[^']*'))*\\s*)(\\/>|>([\\s\\S]*?)<\\/\\1:\\2\\3>)"), "gm");
53570       } else
53571         n3 = /<([\w\d-]+):([\w\d-]+)(#\d+)?((\s+?[\w\d-:]+=("[^"]*"|'[^']*'))*\s*)(\/>|>([\s\S]*?)<\/\1:\2\3>)/gm;
53572       return qe(e3, n3).map(_Xe.unpackMatch);
53573     }
53574     static unpackMatch(e3) {
53575       let t2 = e3[1], i3 = e3[2], n3 = e3[4], s2 = e3[8];
53576       return new _Xe(t2, i3, n3, s2);
53577     }
53578     constructor(e3, t2, i3, n3) {
53579       this.ns = e3, this.name = t2, this.attrString = i3, this.innerXml = n3, this.attrs = Ke.findAll(i3), this.children = _Xe.findAll(n3), this.value = 0 === this.children.length ? Qe(n3) : void 0, this.properties = [...this.attrs, ...this.children];
53580     }
53581     get isPrimitive() {
53582       return void 0 !== this.value && 0 === this.attrs.length && 0 === this.children.length;
53583     }
53584     get isListContainer() {
53585       return 1 === this.children.length && this.children[0].isList;
53586     }
53587     get isList() {
53588       let { ns: e3, name: t2 } = this;
53589       return "rdf" === e3 && ("Seq" === t2 || "Bag" === t2 || "Alt" === t2);
53590     }
53591     get isListItem() {
53592       return "rdf" === this.ns && "li" === this.name;
53593     }
53594     serialize() {
53595       if (0 === this.properties.length && void 0 === this.value)
53596         return;
53597       if (this.isPrimitive)
53598         return this.value;
53599       if (this.isListContainer)
53600         return this.children[0].serialize();
53601       if (this.isList)
53602         return $e(this.children.map(Ye));
53603       if (this.isListItem && 1 === this.children.length && 0 === this.attrs.length)
53604         return this.children[0].serialize();
53605       let e3 = {};
53606       for (let t2 of this.properties)
53607         _e(t2, e3);
53608       return void 0 !== this.value && (e3.value = this.value), f(e3);
53609     }
53610   };
53611   function _e(e3, t2) {
53612     let i3 = e3.serialize();
53613     void 0 !== i3 && (t2[e3.name] = i3);
53614   }
53615   var Ye = (e3) => e3.serialize();
53616   var $e = (e3) => 1 === e3.length ? e3[0] : e3;
53617   var Je = (e3, t2) => t2[e3] ? t2[e3] : t2[e3] = {};
53618   function qe(e3, t2) {
53619     let i3, n3 = [];
53620     if (!e3)
53621       return n3;
53622     for (; null !== (i3 = t2.exec(e3)); )
53623       n3.push(i3);
53624     return n3;
53625   }
53626   function Qe(e3) {
53627     if (function(e4) {
53628       return null == e4 || "null" === e4 || "undefined" === e4 || "" === e4 || "" === e4.trim();
53629     }(e3))
53630       return;
53631     let t2 = Number(e3);
53632     if (!Number.isNaN(t2))
53633       return t2;
53634     let i3 = e3.toLowerCase();
53635     return "true" === i3 || "false" !== i3 && e3.trim();
53636   }
53637   var Ze = ["rdf:li", "rdf:Seq", "rdf:Bag", "rdf:Alt", "rdf:Description"];
53638   var et = new RegExp("(<|\\/)(".concat(Ze.join("|"), ")"), "g");
53639   var tt = Object.freeze({ __proto__: null, default: Me, Exifr: te, fileParsers: w, segmentParsers: T, fileReaders: A, tagKeys: E, tagValues: B, tagRevivers: N, createDictionary: U, extendDictionary: F, fetchUrlAsArrayBuffer: M, readBlobAsArrayBuffer: R, chunkedProps: G, otherSegments: V, segments: z, tiffBlocks: H, segmentsAndBlocks: j, tiffExtractables: W, inheritables: K, allFormatters: X, Options: q, parse: ie, gpsOnlyOptions: me, gps: Se, thumbnailOnlyOptions: Ce, thumbnail: ye, thumbnailUrl: be, orientationOnlyOptions: Ie, orientation: Pe, rotations: ke, get rotateCanvas() {
53640     return we;
53641   }, get rotateCss() {
53642     return Te;
53643   }, rotation: Ae });
53644   var at = l("fs", (e3) => e3.promises);
53645   A.set("fs", class extends ve {
53646     async readWhole() {
53647       this.chunked = false, this.fs = await at;
53648       let e3 = await this.fs.readFile(this.input);
53649       this._swapBuffer(e3);
53650     }
53651     async readChunked() {
53652       this.chunked = true, this.fs = await at, await this.open(), await this.readChunk(0, this.options.firstChunkSize);
53653     }
53654     async open() {
53655       void 0 === this.fh && (this.fh = await this.fs.open(this.input, "r"), this.size = (await this.fh.stat(this.input)).size);
53656     }
53657     async _readChunk(e3, t2) {
53658       void 0 === this.fh && await this.open(), e3 + t2 > this.size && (t2 = this.size - e3);
53659       var i3 = this.subarray(e3, t2, true);
53660       return await this.fh.read(i3.dataView, 0, t2, e3), i3;
53661     }
53662     async close() {
53663       if (this.fh) {
53664         let e3 = this.fh;
53665         this.fh = void 0, await e3.close();
53666       }
53667     }
53668   });
53669   A.set("base64", class extends ve {
53670     constructor(...e3) {
53671       super(...e3), this.input = this.input.replace(/^data:([^;]+);base64,/gim, ""), this.size = this.input.length / 4 * 3, this.input.endsWith("==") ? this.size -= 2 : this.input.endsWith("=") && (this.size -= 1);
53672     }
53673     async _readChunk(e3, t2) {
53674       let i3, n3, r2 = this.input;
53675       void 0 === e3 ? (e3 = 0, i3 = 0, n3 = 0) : (i3 = 4 * Math.floor(e3 / 3), n3 = e3 - i3 / 4 * 3), void 0 === t2 && (t2 = this.size);
53676       let o2 = e3 + t2, l2 = i3 + 4 * Math.ceil(o2 / 3);
53677       r2 = r2.slice(i3, l2);
53678       let h2 = Math.min(t2, this.size - e3);
53679       if (a) {
53680         let t3 = s.from(r2, "base64").slice(n3, n3 + h2);
53681         return this.set(t3, e3, true);
53682       }
53683       {
53684         let t3 = this.subarray(e3, h2, true), i4 = atob(r2), s2 = t3.toUint8();
53685         for (let e4 = 0; e4 < h2; e4++)
53686           s2[e4] = i4.charCodeAt(n3 + e4);
53687         return t3;
53688       }
53689     }
53690   });
53691   var ot = class extends se {
53692     static canHandle(e3, t2) {
53693       return 18761 === t2 || 19789 === t2;
53694     }
53695     extendOptions(e3) {
53696       let { ifd0: t2, xmp: i3, iptc: n3, icc: s2 } = e3;
53697       i3.enabled && t2.deps.add(700), n3.enabled && t2.deps.add(33723), s2.enabled && t2.deps.add(34675), t2.finalizeFilters();
53698     }
53699     async parse() {
53700       let { tiff: e3, xmp: t2, iptc: i3, icc: n3 } = this.options;
53701       if (e3.enabled || t2.enabled || i3.enabled || n3.enabled) {
53702         let e4 = Math.max(S(this.options), this.options.chunkSize);
53703         await this.file.ensureChunk(0, e4), this.createParser("tiff", this.file), this.parsers.tiff.parseHeader(), await this.parsers.tiff.parseIfd0Block(), this.adaptTiffPropAsSegment("xmp"), this.adaptTiffPropAsSegment("iptc"), this.adaptTiffPropAsSegment("icc");
53704       }
53705     }
53706     adaptTiffPropAsSegment(e3) {
53707       if (this.parsers.tiff[e3]) {
53708         let t2 = this.parsers.tiff[e3];
53709         this.injectSegment(e3, t2);
53710       }
53711     }
53712   };
53713   c(ot, "type", "tiff"), w.set("tiff", ot);
53714   var lt = l("zlib");
53715   var ht = ["ihdr", "iccp", "text", "itxt", "exif"];
53716   var ut = class extends se {
53717     constructor(...e3) {
53718       super(...e3), c(this, "catchError", (e4) => this.errors.push(e4)), c(this, "metaChunks", []), c(this, "unknownChunks", []);
53719     }
53720     static canHandle(e3, t2) {
53721       return 35152 === t2 && 2303741511 === e3.getUint32(0) && 218765834 === e3.getUint32(4);
53722     }
53723     async parse() {
53724       let { file: e3 } = this;
53725       await this.findPngChunksInRange("\x89PNG\r\n\1a\n".length, e3.byteLength), await this.readSegments(this.metaChunks), this.findIhdr(), this.parseTextChunks(), await this.findExif().catch(this.catchError), await this.findXmp().catch(this.catchError), await this.findIcc().catch(this.catchError);
53726     }
53727     async findPngChunksInRange(e3, t2) {
53728       let { file: i3 } = this;
53729       for (; e3 < t2; ) {
53730         let t3 = i3.getUint32(e3), n3 = i3.getUint32(e3 + 4), s2 = i3.getString(e3 + 4, 4).toLowerCase(), r2 = t3 + 4 + 4 + 4, a2 = { type: s2, offset: e3, length: r2, start: e3 + 4 + 4, size: t3, marker: n3 };
53731         ht.includes(s2) ? this.metaChunks.push(a2) : this.unknownChunks.push(a2), e3 += r2;
53732       }
53733     }
53734     parseTextChunks() {
53735       let e3 = this.metaChunks.filter((e4) => "text" === e4.type);
53736       for (let t2 of e3) {
53737         let [e4, i3] = this.file.getString(t2.start, t2.size).split("\0");
53738         this.injectKeyValToIhdr(e4, i3);
53739       }
53740     }
53741     injectKeyValToIhdr(e3, t2) {
53742       let i3 = this.parsers.ihdr;
53743       i3 && i3.raw.set(e3, t2);
53744     }
53745     findIhdr() {
53746       let e3 = this.metaChunks.find((e4) => "ihdr" === e4.type);
53747       e3 && false !== this.options.ihdr.enabled && this.createParser("ihdr", e3.chunk);
53748     }
53749     async findExif() {
53750       let e3 = this.metaChunks.find((e4) => "exif" === e4.type);
53751       e3 && this.injectSegment("tiff", e3.chunk);
53752     }
53753     async findXmp() {
53754       let e3 = this.metaChunks.filter((e4) => "itxt" === e4.type);
53755       for (let t2 of e3) {
53756         "XML:com.adobe.xmp" === t2.chunk.getString(0, "XML:com.adobe.xmp".length) && this.injectSegment("xmp", t2.chunk);
53757       }
53758     }
53759     async findIcc() {
53760       let e3 = this.metaChunks.find((e4) => "iccp" === e4.type);
53761       if (!e3)
53762         return;
53763       let { chunk: t2 } = e3, i3 = t2.getUint8Array(0, 81), s2 = 0;
53764       for (; s2 < 80 && 0 !== i3[s2]; )
53765         s2++;
53766       let r2 = s2 + 2, a2 = t2.getString(0, s2);
53767       if (this.injectKeyValToIhdr("ProfileName", a2), n2) {
53768         let e4 = await lt, i4 = t2.getUint8Array(r2);
53769         i4 = e4.inflateSync(i4), this.injectSegment("icc", i4);
53770       }
53771     }
53772   };
53773   c(ut, "type", "png"), w.set("png", ut), U(E, "interop", [[1, "InteropIndex"], [2, "InteropVersion"], [4096, "RelatedImageFileFormat"], [4097, "RelatedImageWidth"], [4098, "RelatedImageHeight"]]), F(E, "ifd0", [[11, "ProcessingSoftware"], [254, "SubfileType"], [255, "OldSubfileType"], [263, "Thresholding"], [264, "CellWidth"], [265, "CellLength"], [266, "FillOrder"], [269, "DocumentName"], [280, "MinSampleValue"], [281, "MaxSampleValue"], [285, "PageName"], [286, "XPosition"], [287, "YPosition"], [290, "GrayResponseUnit"], [297, "PageNumber"], [321, "HalftoneHints"], [322, "TileWidth"], [323, "TileLength"], [332, "InkSet"], [337, "TargetPrinter"], [18246, "Rating"], [18249, "RatingPercent"], [33550, "PixelScale"], [34264, "ModelTransform"], [34377, "PhotoshopSettings"], [50706, "DNGVersion"], [50707, "DNGBackwardVersion"], [50708, "UniqueCameraModel"], [50709, "LocalizedCameraModel"], [50736, "DNGLensInfo"], [50739, "ShadowScale"], [50740, "DNGPrivateData"], [33920, "IntergraphMatrix"], [33922, "ModelTiePoint"], [34118, "SEMInfo"], [34735, "GeoTiffDirectory"], [34736, "GeoTiffDoubleParams"], [34737, "GeoTiffAsciiParams"], [50341, "PrintIM"], [50721, "ColorMatrix1"], [50722, "ColorMatrix2"], [50723, "CameraCalibration1"], [50724, "CameraCalibration2"], [50725, "ReductionMatrix1"], [50726, "ReductionMatrix2"], [50727, "AnalogBalance"], [50728, "AsShotNeutral"], [50729, "AsShotWhiteXY"], [50730, "BaselineExposure"], [50731, "BaselineNoise"], [50732, "BaselineSharpness"], [50734, "LinearResponseLimit"], [50735, "CameraSerialNumber"], [50741, "MakerNoteSafety"], [50778, "CalibrationIlluminant1"], [50779, "CalibrationIlluminant2"], [50781, "RawDataUniqueID"], [50827, "OriginalRawFileName"], [50828, "OriginalRawFileData"], [50831, "AsShotICCProfile"], [50832, "AsShotPreProfileMatrix"], [50833, "CurrentICCProfile"], [50834, "CurrentPreProfileMatrix"], [50879, "ColorimetricReference"], [50885, "SRawType"], [50898, "PanasonicTitle"], [50899, "PanasonicTitle2"], [50931, "CameraCalibrationSig"], [50932, "ProfileCalibrationSig"], [50933, "ProfileIFD"], [50934, "AsShotProfileName"], [50936, "ProfileName"], [50937, "ProfileHueSatMapDims"], [50938, "ProfileHueSatMapData1"], [50939, "ProfileHueSatMapData2"], [50940, "ProfileToneCurve"], [50941, "ProfileEmbedPolicy"], [50942, "ProfileCopyright"], [50964, "ForwardMatrix1"], [50965, "ForwardMatrix2"], [50966, "PreviewApplicationName"], [50967, "PreviewApplicationVersion"], [50968, "PreviewSettingsName"], [50969, "PreviewSettingsDigest"], [50970, "PreviewColorSpace"], [50971, "PreviewDateTime"], [50972, "RawImageDigest"], [50973, "OriginalRawFileDigest"], [50981, "ProfileLookTableDims"], [50982, "ProfileLookTableData"], [51043, "TimeCodes"], [51044, "FrameRate"], [51058, "TStop"], [51081, "ReelName"], [51089, "OriginalDefaultFinalSize"], [51090, "OriginalBestQualitySize"], [51091, "OriginalDefaultCropSize"], [51105, "CameraLabel"], [51107, "ProfileHueSatMapEncoding"], [51108, "ProfileLookTableEncoding"], [51109, "BaselineExposureOffset"], [51110, "DefaultBlackRender"], [51111, "NewRawImageDigest"], [51112, "RawToPreviewGain"]]);
53774   var ct = [[273, "StripOffsets"], [279, "StripByteCounts"], [288, "FreeOffsets"], [289, "FreeByteCounts"], [291, "GrayResponseCurve"], [292, "T4Options"], [293, "T6Options"], [300, "ColorResponseUnit"], [320, "ColorMap"], [324, "TileOffsets"], [325, "TileByteCounts"], [326, "BadFaxLines"], [327, "CleanFaxData"], [328, "ConsecutiveBadFaxLines"], [330, "SubIFD"], [333, "InkNames"], [334, "NumberofInks"], [336, "DotRange"], [338, "ExtraSamples"], [339, "SampleFormat"], [340, "SMinSampleValue"], [341, "SMaxSampleValue"], [342, "TransferRange"], [343, "ClipPath"], [344, "XClipPathUnits"], [345, "YClipPathUnits"], [346, "Indexed"], [347, "JPEGTables"], [351, "OPIProxy"], [400, "GlobalParametersIFD"], [401, "ProfileType"], [402, "FaxProfile"], [403, "CodingMethods"], [404, "VersionYear"], [405, "ModeNumber"], [433, "Decode"], [434, "DefaultImageColor"], [435, "T82Options"], [437, "JPEGTables"], [512, "JPEGProc"], [515, "JPEGRestartInterval"], [517, "JPEGLosslessPredictors"], [518, "JPEGPointTransforms"], [519, "JPEGQTables"], [520, "JPEGDCTables"], [521, "JPEGACTables"], [559, "StripRowCounts"], [999, "USPTOMiscellaneous"], [18247, "XP_DIP_XML"], [18248, "StitchInfo"], [28672, "SonyRawFileType"], [28688, "SonyToneCurve"], [28721, "VignettingCorrection"], [28722, "VignettingCorrParams"], [28724, "ChromaticAberrationCorrection"], [28725, "ChromaticAberrationCorrParams"], [28726, "DistortionCorrection"], [28727, "DistortionCorrParams"], [29895, "SonyCropTopLeft"], [29896, "SonyCropSize"], [32781, "ImageID"], [32931, "WangTag1"], [32932, "WangAnnotation"], [32933, "WangTag3"], [32934, "WangTag4"], [32953, "ImageReferencePoints"], [32954, "RegionXformTackPoint"], [32955, "WarpQuadrilateral"], [32956, "AffineTransformMat"], [32995, "Matteing"], [32996, "DataType"], [32997, "ImageDepth"], [32998, "TileDepth"], [33300, "ImageFullWidth"], [33301, "ImageFullHeight"], [33302, "TextureFormat"], [33303, "WrapModes"], [33304, "FovCot"], [33305, "MatrixWorldToScreen"], [33306, "MatrixWorldToCamera"], [33405, "Model2"], [33421, "CFARepeatPatternDim"], [33422, "CFAPattern2"], [33423, "BatteryLevel"], [33424, "KodakIFD"], [33445, "MDFileTag"], [33446, "MDScalePixel"], [33447, "MDColorTable"], [33448, "MDLabName"], [33449, "MDSampleInfo"], [33450, "MDPrepDate"], [33451, "MDPrepTime"], [33452, "MDFileUnits"], [33589, "AdventScale"], [33590, "AdventRevision"], [33628, "UIC1Tag"], [33629, "UIC2Tag"], [33630, "UIC3Tag"], [33631, "UIC4Tag"], [33918, "IntergraphPacketData"], [33919, "IntergraphFlagRegisters"], [33921, "INGRReserved"], [34016, "Site"], [34017, "ColorSequence"], [34018, "IT8Header"], [34019, "RasterPadding"], [34020, "BitsPerRunLength"], [34021, "BitsPerExtendedRunLength"], [34022, "ColorTable"], [34023, "ImageColorIndicator"], [34024, "BackgroundColorIndicator"], [34025, "ImageColorValue"], [34026, "BackgroundColorValue"], [34027, "PixelIntensityRange"], [34028, "TransparencyIndicator"], [34029, "ColorCharacterization"], [34030, "HCUsage"], [34031, "TrapIndicator"], [34032, "CMYKEquivalent"], [34152, "AFCP_IPTC"], [34232, "PixelMagicJBIGOptions"], [34263, "JPLCartoIFD"], [34306, "WB_GRGBLevels"], [34310, "LeafData"], [34687, "TIFF_FXExtensions"], [34688, "MultiProfiles"], [34689, "SharedData"], [34690, "T88Options"], [34732, "ImageLayer"], [34750, "JBIGOptions"], [34856, "Opto-ElectricConvFactor"], [34857, "Interlace"], [34908, "FaxRecvParams"], [34909, "FaxSubAddress"], [34910, "FaxRecvTime"], [34929, "FedexEDR"], [34954, "LeafSubIFD"], [37387, "FlashEnergy"], [37388, "SpatialFrequencyResponse"], [37389, "Noise"], [37390, "FocalPlaneXResolution"], [37391, "FocalPlaneYResolution"], [37392, "FocalPlaneResolutionUnit"], [37397, "ExposureIndex"], [37398, "TIFF-EPStandardID"], [37399, "SensingMethod"], [37434, "CIP3DataFile"], [37435, "CIP3Sheet"], [37436, "CIP3Side"], [37439, "StoNits"], [37679, "MSDocumentText"], [37680, "MSPropertySetStorage"], [37681, "MSDocumentTextPosition"], [37724, "ImageSourceData"], [40965, "InteropIFD"], [40976, "SamsungRawPointersOffset"], [40977, "SamsungRawPointersLength"], [41217, "SamsungRawByteOrder"], [41218, "SamsungRawUnknown"], [41484, "SpatialFrequencyResponse"], [41485, "Noise"], [41489, "ImageNumber"], [41490, "SecurityClassification"], [41491, "ImageHistory"], [41494, "TIFF-EPStandardID"], [41995, "DeviceSettingDescription"], [42112, "GDALMetadata"], [42113, "GDALNoData"], [44992, "ExpandSoftware"], [44993, "ExpandLens"], [44994, "ExpandFilm"], [44995, "ExpandFilterLens"], [44996, "ExpandScanner"], [44997, "ExpandFlashLamp"], [46275, "HasselbladRawImage"], [48129, "PixelFormat"], [48130, "Transformation"], [48131, "Uncompressed"], [48132, "ImageType"], [48256, "ImageWidth"], [48257, "ImageHeight"], [48258, "WidthResolution"], [48259, "HeightResolution"], [48320, "ImageOffset"], [48321, "ImageByteCount"], [48322, "AlphaOffset"], [48323, "AlphaByteCount"], [48324, "ImageDataDiscard"], [48325, "AlphaDataDiscard"], [50215, "OceScanjobDesc"], [50216, "OceApplicationSelector"], [50217, "OceIDNumber"], [50218, "OceImageLogic"], [50255, "Annotations"], [50459, "HasselbladExif"], [50547, "OriginalFileName"], [50560, "USPTOOriginalContentType"], [50656, "CR2CFAPattern"], [50710, "CFAPlaneColor"], [50711, "CFALayout"], [50712, "LinearizationTable"], [50713, "BlackLevelRepeatDim"], [50714, "BlackLevel"], [50715, "BlackLevelDeltaH"], [50716, "BlackLevelDeltaV"], [50717, "WhiteLevel"], [50718, "DefaultScale"], [50719, "DefaultCropOrigin"], [50720, "DefaultCropSize"], [50733, "BayerGreenSplit"], [50737, "ChromaBlurRadius"], [50738, "AntiAliasStrength"], [50752, "RawImageSegmentation"], [50780, "BestQualityScale"], [50784, "AliasLayerMetadata"], [50829, "ActiveArea"], [50830, "MaskedAreas"], [50935, "NoiseReductionApplied"], [50974, "SubTileBlockSize"], [50975, "RowInterleaveFactor"], [51008, "OpcodeList1"], [51009, "OpcodeList2"], [51022, "OpcodeList3"], [51041, "NoiseProfile"], [51114, "CacheVersion"], [51125, "DefaultUserCrop"], [51157, "NikonNEFInfo"], [65024, "KdcIFD"]];
53775   F(E, "ifd0", ct), F(E, "exif", ct), U(B, "gps", [[23, { M: "Magnetic North", T: "True North" }], [25, { K: "Kilometers", M: "Miles", N: "Nautical Miles" }]]);
53776   var ft = class extends re2 {
53777     static canHandle(e3, t2) {
53778       return 224 === e3.getUint8(t2 + 1) && 1246120262 === e3.getUint32(t2 + 4) && 0 === e3.getUint8(t2 + 8);
53779     }
53780     parse() {
53781       return this.parseTags(), this.translate(), this.output;
53782     }
53783     parseTags() {
53784       this.raw = /* @__PURE__ */ new Map([[0, this.chunk.getUint16(0)], [2, this.chunk.getUint8(2)], [3, this.chunk.getUint16(3)], [5, this.chunk.getUint16(5)], [7, this.chunk.getUint8(7)], [8, this.chunk.getUint8(8)]]);
53785     }
53786   };
53787   c(ft, "type", "jfif"), c(ft, "headerLength", 9), T.set("jfif", ft), U(E, "jfif", [[0, "JFIFVersion"], [2, "ResolutionUnit"], [3, "XResolution"], [5, "YResolution"], [7, "ThumbnailWidth"], [8, "ThumbnailHeight"]]);
53788   var dt = class extends re2 {
53789     parse() {
53790       return this.parseTags(), this.translate(), this.output;
53791     }
53792     parseTags() {
53793       this.raw = new Map([[0, this.chunk.getUint32(0)], [4, this.chunk.getUint32(4)], [8, this.chunk.getUint8(8)], [9, this.chunk.getUint8(9)], [10, this.chunk.getUint8(10)], [11, this.chunk.getUint8(11)], [12, this.chunk.getUint8(12)], ...Array.from(this.raw)]);
53794     }
53795   };
53796   c(dt, "type", "ihdr"), T.set("ihdr", dt), U(E, "ihdr", [[0, "ImageWidth"], [4, "ImageHeight"], [8, "BitDepth"], [9, "ColorType"], [10, "Compression"], [11, "Filter"], [12, "Interlace"]]), U(B, "ihdr", [[9, { 0: "Grayscale", 2: "RGB", 3: "Palette", 4: "Grayscale with Alpha", 6: "RGB with Alpha", DEFAULT: "Unknown" }], [10, { 0: "Deflate/Inflate", DEFAULT: "Unknown" }], [11, { 0: "Adaptive", DEFAULT: "Unknown" }], [12, { 0: "Noninterlaced", 1: "Adam7 Interlace", DEFAULT: "Unknown" }]]);
53797   var pt = class extends re2 {
53798     static canHandle(e3, t2) {
53799       return 226 === e3.getUint8(t2 + 1) && 1229144927 === e3.getUint32(t2 + 4);
53800     }
53801     static findPosition(e3, t2) {
53802       let i3 = super.findPosition(e3, t2);
53803       return i3.chunkNumber = e3.getUint8(t2 + 16), i3.chunkCount = e3.getUint8(t2 + 17), i3.multiSegment = i3.chunkCount > 1, i3;
53804     }
53805     static handleMultiSegments(e3) {
53806       return function(e4) {
53807         let t2 = function(e6) {
53808           let t3 = e6[0].constructor, i3 = 0;
53809           for (let t4 of e6)
53810             i3 += t4.length;
53811           let n3 = new t3(i3), s2 = 0;
53812           for (let t4 of e6)
53813             n3.set(t4, s2), s2 += t4.length;
53814           return n3;
53815         }(e4.map((e6) => e6.chunk.toUint8()));
53816         return new I(t2);
53817       }(e3);
53818     }
53819     parse() {
53820       return this.raw = /* @__PURE__ */ new Map(), this.parseHeader(), this.parseTags(), this.translate(), this.output;
53821     }
53822     parseHeader() {
53823       let { raw: e3 } = this;
53824       this.chunk.byteLength < 84 && g2("ICC header is too short");
53825       for (let [t2, i3] of Object.entries(gt)) {
53826         t2 = parseInt(t2, 10);
53827         let n3 = i3(this.chunk, t2);
53828         "\0\0\0\0" !== n3 && e3.set(t2, n3);
53829       }
53830     }
53831     parseTags() {
53832       let e3, t2, i3, n3, s2, { raw: r2 } = this, a2 = this.chunk.getUint32(128), o2 = 132, l2 = this.chunk.byteLength;
53833       for (; a2--; ) {
53834         if (e3 = this.chunk.getString(o2, 4), t2 = this.chunk.getUint32(o2 + 4), i3 = this.chunk.getUint32(o2 + 8), n3 = this.chunk.getString(t2, 4), t2 + i3 > l2)
53835           return void console.warn("reached the end of the first ICC chunk. Enable options.tiff.multiSegment to read all ICC segments.");
53836         s2 = this.parseTag(n3, t2, i3), void 0 !== s2 && "\0\0\0\0" !== s2 && r2.set(e3, s2), o2 += 12;
53837       }
53838     }
53839     parseTag(e3, t2, i3) {
53840       switch (e3) {
53841         case "desc":
53842           return this.parseDesc(t2);
53843         case "mluc":
53844           return this.parseMluc(t2);
53845         case "text":
53846           return this.parseText(t2, i3);
53847         case "sig ":
53848           return this.parseSig(t2);
53849       }
53850       if (!(t2 + i3 > this.chunk.byteLength))
53851         return this.chunk.getUint8Array(t2, i3);
53852     }
53853     parseDesc(e3) {
53854       let t2 = this.chunk.getUint32(e3 + 8) - 1;
53855       return m(this.chunk.getString(e3 + 12, t2));
53856     }
53857     parseText(e3, t2) {
53858       return m(this.chunk.getString(e3 + 8, t2 - 8));
53859     }
53860     parseSig(e3) {
53861       return m(this.chunk.getString(e3 + 8, 4));
53862     }
53863     parseMluc(e3) {
53864       let { chunk: t2 } = this, i3 = t2.getUint32(e3 + 8), n3 = t2.getUint32(e3 + 12), s2 = e3 + 16, r2 = [];
53865       for (let a2 = 0; a2 < i3; a2++) {
53866         let i4 = t2.getString(s2 + 0, 2), a3 = t2.getString(s2 + 2, 2), o2 = t2.getUint32(s2 + 4), l2 = t2.getUint32(s2 + 8) + e3, h2 = m(t2.getUnicodeString(l2, o2));
53867         r2.push({ lang: i4, country: a3, text: h2 }), s2 += n3;
53868       }
53869       return 1 === i3 ? r2[0].text : r2;
53870     }
53871     translateValue(e3, t2) {
53872       return "string" == typeof e3 ? t2[e3] || t2[e3.toLowerCase()] || e3 : t2[e3] || e3;
53873     }
53874   };
53875   c(pt, "type", "icc"), c(pt, "multiSegment", true), c(pt, "headerLength", 18);
53876   var gt = { 4: mt, 8: function(e3, t2) {
53877     return [e3.getUint8(t2), e3.getUint8(t2 + 1) >> 4, e3.getUint8(t2 + 1) % 16].map((e4) => e4.toString(10)).join(".");
53878   }, 12: mt, 16: mt, 20: mt, 24: function(e3, t2) {
53879     const i3 = e3.getUint16(t2), n3 = e3.getUint16(t2 + 2) - 1, s2 = e3.getUint16(t2 + 4), r2 = e3.getUint16(t2 + 6), a2 = e3.getUint16(t2 + 8), o2 = e3.getUint16(t2 + 10);
53880     return new Date(Date.UTC(i3, n3, s2, r2, a2, o2));
53881   }, 36: mt, 40: mt, 48: mt, 52: mt, 64: (e3, t2) => e3.getUint32(t2), 80: mt };
53882   function mt(e3, t2) {
53883     return m(e3.getString(t2, 4));
53884   }
53885   T.set("icc", pt), U(E, "icc", [[4, "ProfileCMMType"], [8, "ProfileVersion"], [12, "ProfileClass"], [16, "ColorSpaceData"], [20, "ProfileConnectionSpace"], [24, "ProfileDateTime"], [36, "ProfileFileSignature"], [40, "PrimaryPlatform"], [44, "CMMFlags"], [48, "DeviceManufacturer"], [52, "DeviceModel"], [56, "DeviceAttributes"], [64, "RenderingIntent"], [68, "ConnectionSpaceIlluminant"], [80, "ProfileCreator"], [84, "ProfileID"], ["Header", "ProfileHeader"], ["MS00", "WCSProfiles"], ["bTRC", "BlueTRC"], ["bXYZ", "BlueMatrixColumn"], ["bfd", "UCRBG"], ["bkpt", "MediaBlackPoint"], ["calt", "CalibrationDateTime"], ["chad", "ChromaticAdaptation"], ["chrm", "Chromaticity"], ["ciis", "ColorimetricIntentImageState"], ["clot", "ColorantTableOut"], ["clro", "ColorantOrder"], ["clrt", "ColorantTable"], ["cprt", "ProfileCopyright"], ["crdi", "CRDInfo"], ["desc", "ProfileDescription"], ["devs", "DeviceSettings"], ["dmdd", "DeviceModelDesc"], ["dmnd", "DeviceMfgDesc"], ["dscm", "ProfileDescriptionML"], ["fpce", "FocalPlaneColorimetryEstimates"], ["gTRC", "GreenTRC"], ["gXYZ", "GreenMatrixColumn"], ["gamt", "Gamut"], ["kTRC", "GrayTRC"], ["lumi", "Luminance"], ["meas", "Measurement"], ["meta", "Metadata"], ["mmod", "MakeAndModel"], ["ncl2", "NamedColor2"], ["ncol", "NamedColor"], ["ndin", "NativeDisplayInfo"], ["pre0", "Preview0"], ["pre1", "Preview1"], ["pre2", "Preview2"], ["ps2i", "PS2RenderingIntent"], ["ps2s", "PostScript2CSA"], ["psd0", "PostScript2CRD0"], ["psd1", "PostScript2CRD1"], ["psd2", "PostScript2CRD2"], ["psd3", "PostScript2CRD3"], ["pseq", "ProfileSequenceDesc"], ["psid", "ProfileSequenceIdentifier"], ["psvm", "PS2CRDVMSize"], ["rTRC", "RedTRC"], ["rXYZ", "RedMatrixColumn"], ["resp", "OutputResponse"], ["rhoc", "ReflectionHardcopyOrigColorimetry"], ["rig0", "PerceptualRenderingIntentGamut"], ["rig2", "SaturationRenderingIntentGamut"], ["rpoc", "ReflectionPrintOutputColorimetry"], ["sape", "SceneAppearanceEstimates"], ["scoe", "SceneColorimetryEstimates"], ["scrd", "ScreeningDesc"], ["scrn", "Screening"], ["targ", "CharTarget"], ["tech", "Technology"], ["vcgt", "VideoCardGamma"], ["view", "ViewingConditions"], ["vued", "ViewingCondDesc"], ["wtpt", "MediaWhitePoint"]]);
53886   var St = { "4d2p": "Erdt Systems", AAMA: "Aamazing Technologies", ACER: "Acer", ACLT: "Acolyte Color Research", ACTI: "Actix Sytems", ADAR: "Adara Technology", ADBE: "Adobe", ADI: "ADI Systems", AGFA: "Agfa Graphics", ALMD: "Alps Electric", ALPS: "Alps Electric", ALWN: "Alwan Color Expertise", AMTI: "Amiable Technologies", AOC: "AOC International", APAG: "Apago", APPL: "Apple Computer", AST: "AST", "AT&T": "AT&T", BAEL: "BARBIERI electronic", BRCO: "Barco NV", BRKP: "Breakpoint", BROT: "Brother", BULL: "Bull", BUS: "Bus Computer Systems", "C-IT": "C-Itoh", CAMR: "Intel", CANO: "Canon", CARR: "Carroll Touch", CASI: "Casio", CBUS: "Colorbus PL", CEL: "Crossfield", CELx: "Crossfield", CGS: "CGS Publishing Technologies International", CHM: "Rochester Robotics", CIGL: "Colour Imaging Group, London", CITI: "Citizen", CL00: "Candela", CLIQ: "Color IQ", CMCO: "Chromaco", CMiX: "CHROMiX", COLO: "Colorgraphic Communications", COMP: "Compaq", COMp: "Compeq/Focus Technology", CONR: "Conrac Display Products", CORD: "Cordata Technologies", CPQ: "Compaq", CPRO: "ColorPro", CRN: "Cornerstone", CTX: "CTX International", CVIS: "ColorVision", CWC: "Fujitsu Laboratories", DARI: "Darius Technology", DATA: "Dataproducts", DCP: "Dry Creek Photo", DCRC: "Digital Contents Resource Center, Chung-Ang University", DELL: "Dell Computer", DIC: "Dainippon Ink and Chemicals", DICO: "Diconix", DIGI: "Digital", "DL&C": "Digital Light & Color", DPLG: "Doppelganger", DS: "Dainippon Screen", DSOL: "DOOSOL", DUPN: "DuPont", EPSO: "Epson", ESKO: "Esko-Graphics", ETRI: "Electronics and Telecommunications Research Institute", EVER: "Everex Systems", EXAC: "ExactCODE", Eizo: "Eizo", FALC: "Falco Data Products", FF: "Fuji Photo Film", FFEI: "FujiFilm Electronic Imaging", FNRD: "Fnord Software", FORA: "Fora", FORE: "Forefront Technology", FP: "Fujitsu", FPA: "WayTech Development", FUJI: "Fujitsu", FX: "Fuji Xerox", GCC: "GCC Technologies", GGSL: "Global Graphics Software", GMB: "Gretagmacbeth", GMG: "GMG", GOLD: "GoldStar Technology", GOOG: "Google", GPRT: "Giantprint", GTMB: "Gretagmacbeth", GVC: "WayTech Development", GW2K: "Sony", HCI: "HCI", HDM: "Heidelberger Druckmaschinen", HERM: "Hermes", HITA: "Hitachi America", HP: "Hewlett-Packard", HTC: "Hitachi", HiTi: "HiTi Digital", IBM: "IBM", IDNT: "Scitex", IEC: "Hewlett-Packard", IIYA: "Iiyama North America", IKEG: "Ikegami Electronics", IMAG: "Image Systems", IMI: "Ingram Micro", INTC: "Intel", INTL: "N/A (INTL)", INTR: "Intra Electronics", IOCO: "Iocomm International Technology", IPS: "InfoPrint Solutions Company", IRIS: "Scitex", ISL: "Ichikawa Soft Laboratory", ITNL: "N/A (ITNL)", IVM: "IVM", IWAT: "Iwatsu Electric", Idnt: "Scitex", Inca: "Inca Digital Printers", Iris: "Scitex", JPEG: "Joint Photographic Experts Group", JSFT: "Jetsoft Development", JVC: "JVC Information Products", KART: "Scitex", KFC: "KFC Computek Components", KLH: "KLH Computers", KMHD: "Konica Minolta", KNCA: "Konica", KODA: "Kodak", KYOC: "Kyocera", Kart: "Scitex", LCAG: "Leica", LCCD: "Leeds Colour", LDAK: "Left Dakota", LEAD: "Leading Technology", LEXM: "Lexmark International", LINK: "Link Computer", LINO: "Linotronic", LITE: "Lite-On", Leaf: "Leaf", Lino: "Linotronic", MAGC: "Mag Computronic", MAGI: "MAG Innovision", MANN: "Mannesmann", MICN: "Micron Technology", MICR: "Microtek", MICV: "Microvitec", MINO: "Minolta", MITS: "Mitsubishi Electronics America", MITs: "Mitsuba", MNLT: "Minolta", MODG: "Modgraph", MONI: "Monitronix", MONS: "Monaco Systems", MORS: "Morse Technology", MOTI: "Motive Systems", MSFT: "Microsoft", MUTO: "MUTOH INDUSTRIES", Mits: "Mitsubishi Electric", NANA: "NANAO", NEC: "NEC", NEXP: "NexPress Solutions", NISS: "Nissei Sangyo America", NKON: "Nikon", NONE: "none", OCE: "Oce Technologies", OCEC: "OceColor", OKI: "Oki", OKID: "Okidata", OKIP: "Okidata", OLIV: "Olivetti", OLYM: "Olympus", ONYX: "Onyx Graphics", OPTI: "Optiquest", PACK: "Packard Bell", PANA: "Matsushita Electric Industrial", PANT: "Pantone", PBN: "Packard Bell", PFU: "PFU", PHIL: "Philips Consumer Electronics", PNTX: "HOYA", POne: "Phase One A/S", PREM: "Premier Computer Innovations", PRIN: "Princeton Graphic Systems", PRIP: "Princeton Publishing Labs", QLUX: "Hong Kong", QMS: "QMS", QPCD: "QPcard AB", QUAD: "QuadLaser", QUME: "Qume", RADI: "Radius", RDDx: "Integrated Color Solutions", RDG: "Roland DG", REDM: "REDMS Group", RELI: "Relisys", RGMS: "Rolf Gierling Multitools", RICO: "Ricoh", RNLD: "Edmund Ronald", ROYA: "Royal", RPC: "Ricoh Printing Systems", RTL: "Royal Information Electronics", SAMP: "Sampo", SAMS: "Samsung", SANT: "Jaime Santana Pomares", SCIT: "Scitex", SCRN: "Dainippon Screen", SDP: "Scitex", SEC: "Samsung", SEIK: "Seiko Instruments", SEIk: "Seikosha", SGUY: "ScanGuy.com", SHAR: "Sharp Laboratories", SICC: "International Color Consortium", SONY: "Sony", SPCL: "SpectraCal", STAR: "Star", STC: "Sampo Technology", Scit: "Scitex", Sdp: "Scitex", Sony: "Sony", TALO: "Talon Technology", TAND: "Tandy", TATU: "Tatung", TAXA: "TAXAN America", TDS: "Tokyo Denshi Sekei", TECO: "TECO Information Systems", TEGR: "Tegra", TEKT: "Tektronix", TI: "Texas Instruments", TMKR: "TypeMaker", TOSB: "Toshiba", TOSH: "Toshiba", TOTK: "TOTOKU ELECTRIC", TRIU: "Triumph", TSBT: "Toshiba", TTX: "TTX Computer Products", TVM: "TVM Professional Monitor", TW: "TW Casper", ULSX: "Ulead Systems", UNIS: "Unisys", UTZF: "Utz Fehlau & Sohn", VARI: "Varityper", VIEW: "Viewsonic", VISL: "Visual communication", VIVO: "Vivo Mobile Communication", WANG: "Wang", WLBR: "Wilbur Imaging", WTG2: "Ware To Go", WYSE: "WYSE Technology", XERX: "Xerox", XRIT: "X-Rite", ZRAN: "Zoran", Zebr: "Zebra Technologies", appl: "Apple Computer", bICC: "basICColor", berg: "bergdesign", ceyd: "Integrated Color Solutions", clsp: "MacDermid ColorSpan", ds: "Dainippon Screen", dupn: "DuPont", ffei: "FujiFilm Electronic Imaging", flux: "FluxData", iris: "Scitex", kart: "Scitex", lcms: "Little CMS", lino: "Linotronic", none: "none", ob4d: "Erdt Systems", obic: "Medigraph", quby: "Qubyx Sarl", scit: "Scitex", scrn: "Dainippon Screen", sdp: "Scitex", siwi: "SIWI GRAFIKA", yxym: "YxyMaster" };
53887   var Ct = { scnr: "Scanner", mntr: "Monitor", prtr: "Printer", link: "Device Link", abst: "Abstract", spac: "Color Space Conversion Profile", nmcl: "Named Color", cenc: "ColorEncodingSpace profile", mid: "MultiplexIdentification profile", mlnk: "MultiplexLink profile", mvis: "MultiplexVisualization profile", nkpf: "Nikon Input Device Profile (NON-STANDARD!)" };
53888   U(B, "icc", [[4, St], [12, Ct], [40, Object.assign({}, St, Ct)], [48, St], [80, St], [64, { 0: "Perceptual", 1: "Relative Colorimetric", 2: "Saturation", 3: "Absolute Colorimetric" }], ["tech", { amd: "Active Matrix Display", crt: "Cathode Ray Tube Display", kpcd: "Photo CD", pmd: "Passive Matrix Display", dcam: "Digital Camera", dcpj: "Digital Cinema Projector", dmpc: "Digital Motion Picture Camera", dsub: "Dye Sublimation Printer", epho: "Electrophotographic Printer", esta: "Electrostatic Printer", flex: "Flexography", fprn: "Film Writer", fscn: "Film Scanner", grav: "Gravure", ijet: "Ink Jet Printer", imgs: "Photo Image Setter", mpfr: "Motion Picture Film Recorder", mpfs: "Motion Picture Film Scanner", offs: "Offset Lithography", pjtv: "Projection Television", rpho: "Photographic Paper Printer", rscn: "Reflective Scanner", silk: "Silkscreen", twax: "Thermal Wax Printer", vidc: "Video Camera", vidm: "Video Monitor" }]]);
53889   var yt = class extends re2 {
53890     static canHandle(e3, t2, i3) {
53891       return 237 === e3.getUint8(t2 + 1) && "Photoshop" === e3.getString(t2 + 4, 9) && void 0 !== this.containsIptc8bim(e3, t2, i3);
53892     }
53893     static headerLength(e3, t2, i3) {
53894       let n3, s2 = this.containsIptc8bim(e3, t2, i3);
53895       if (void 0 !== s2)
53896         return n3 = e3.getUint8(t2 + s2 + 7), n3 % 2 != 0 && (n3 += 1), 0 === n3 && (n3 = 4), s2 + 8 + n3;
53897     }
53898     static containsIptc8bim(e3, t2, i3) {
53899       for (let n3 = 0; n3 < i3; n3++)
53900         if (this.isIptcSegmentHead(e3, t2 + n3))
53901           return n3;
53902     }
53903     static isIptcSegmentHead(e3, t2) {
53904       return 56 === e3.getUint8(t2) && 943868237 === e3.getUint32(t2) && 1028 === e3.getUint16(t2 + 4);
53905     }
53906     parse() {
53907       let { raw: e3 } = this, t2 = this.chunk.byteLength - 1, i3 = false;
53908       for (let n3 = 0; n3 < t2; n3++)
53909         if (28 === this.chunk.getUint8(n3) && 2 === this.chunk.getUint8(n3 + 1)) {
53910           i3 = true;
53911           let t3 = this.chunk.getUint16(n3 + 3), s2 = this.chunk.getUint8(n3 + 2), r2 = this.chunk.getLatin1String(n3 + 5, t3);
53912           e3.set(s2, this.pluralizeValue(e3.get(s2), r2)), n3 += 4 + t3;
53913         } else if (i3)
53914           break;
53915       return this.translate(), this.output;
53916     }
53917     pluralizeValue(e3, t2) {
53918       return void 0 !== e3 ? e3 instanceof Array ? (e3.push(t2), e3) : [e3, t2] : t2;
53919     }
53920   };
53921   c(yt, "type", "iptc"), c(yt, "translateValues", false), c(yt, "reviveValues", false), T.set("iptc", yt), U(E, "iptc", [[0, "ApplicationRecordVersion"], [3, "ObjectTypeReference"], [4, "ObjectAttributeReference"], [5, "ObjectName"], [7, "EditStatus"], [8, "EditorialUpdate"], [10, "Urgency"], [12, "SubjectReference"], [15, "Category"], [20, "SupplementalCategories"], [22, "FixtureIdentifier"], [25, "Keywords"], [26, "ContentLocationCode"], [27, "ContentLocationName"], [30, "ReleaseDate"], [35, "ReleaseTime"], [37, "ExpirationDate"], [38, "ExpirationTime"], [40, "SpecialInstructions"], [42, "ActionAdvised"], [45, "ReferenceService"], [47, "ReferenceDate"], [50, "ReferenceNumber"], [55, "DateCreated"], [60, "TimeCreated"], [62, "DigitalCreationDate"], [63, "DigitalCreationTime"], [65, "OriginatingProgram"], [70, "ProgramVersion"], [75, "ObjectCycle"], [80, "Byline"], [85, "BylineTitle"], [90, "City"], [92, "Sublocation"], [95, "State"], [100, "CountryCode"], [101, "Country"], [103, "OriginalTransmissionReference"], [105, "Headline"], [110, "Credit"], [115, "Source"], [116, "CopyrightNotice"], [118, "Contact"], [120, "Caption"], [121, "LocalCaption"], [122, "Writer"], [125, "RasterizedCaption"], [130, "ImageType"], [131, "ImageOrientation"], [135, "LanguageIdentifier"], [150, "AudioType"], [151, "AudioSamplingRate"], [152, "AudioSamplingResolution"], [153, "AudioDuration"], [154, "AudioOutcue"], [184, "JobID"], [185, "MasterDocumentID"], [186, "ShortDocumentID"], [187, "UniqueDocumentID"], [188, "OwnerID"], [200, "ObjectPreviewFileFormat"], [201, "ObjectPreviewFileVersion"], [202, "ObjectPreviewData"], [221, "Prefs"], [225, "ClassifyState"], [228, "SimilarityIndex"], [230, "DocumentNotes"], [231, "DocumentHistory"], [232, "ExifCameraInfo"], [255, "CatalogSets"]]), U(B, "iptc", [[10, { 0: "0 (reserved)", 1: "1 (most urgent)", 2: "2", 3: "3", 4: "4", 5: "5 (normal urgency)", 6: "6", 7: "7", 8: "8 (least urgent)", 9: "9 (user-defined priority)" }], [75, { a: "Morning", b: "Both Morning and Evening", p: "Evening" }], [131, { L: "Landscape", P: "Portrait", S: "Square" }]]);
53922   var full_esm_default = tt;
53923
53924   // modules/services/plane_photo.js
53925   var dispatch6 = dispatch_default("viewerChanged");
53926   var _photo;
53927   var _wrapper;
53928   var imgZoom;
53929   var _widthOverflow;
53930   function zoomPan(d3_event) {
53931     let t2 = d3_event.transform;
53932     _photo.call(utilSetTransform, t2.x, t2.y, t2.k);
53933   }
53934   function zoomBeahvior() {
53935     const { width: wrapperWidth, height: wrapperHeight } = _wrapper.node().getBoundingClientRect();
53936     const { naturalHeight, naturalWidth } = _photo.node();
53937     const intrinsicRatio = naturalWidth / naturalHeight;
53938     _widthOverflow = wrapperHeight * intrinsicRatio - wrapperWidth;
53939     return zoom_default2().extent([[0, 0], [wrapperWidth, wrapperHeight]]).translateExtent([[0, 0], [wrapperWidth + _widthOverflow, wrapperHeight]]).scaleExtent([1, 15]).on("zoom", zoomPan);
53940   }
53941   function loadImage(selection2, path) {
53942     return new Promise((resolve) => {
53943       selection2.attr("src", path);
53944       selection2.on("load", () => {
53945         resolve(selection2);
53946       });
53947     });
53948   }
53949   var plane_photo_default = {
53950     init: async function(context, selection2) {
53951       this.event = utilRebind(this, dispatch6, "on");
53952       _wrapper = selection2.append("div").attr("class", "photo-frame plane-frame").classed("hide", true);
53953       _photo = _wrapper.append("img").attr("class", "plane-photo");
53954       context.ui().photoviewer.on("resize.plane", () => {
53955         imgZoom = zoomBeahvior();
53956         _wrapper.call(imgZoom);
53957       });
53958       await Promise.resolve();
53959       return this;
53960     },
53961     showPhotoFrame: function(context) {
53962       const isHidden = context.selectAll(".photo-frame.plane-frame.hide").size();
53963       if (isHidden) {
53964         context.selectAll(".photo-frame:not(.plane-frame)").classed("hide", true);
53965         context.selectAll(".photo-frame.plane-frame").classed("hide", false);
53966       }
53967       return this;
53968     },
53969     hidePhotoFrame: function(context) {
53970       context.select("photo-frame.plane-frame").classed("hide", false);
53971       return this;
53972     },
53973     selectPhoto: function(data, keepOrientation) {
53974       dispatch6.call("viewerChanged");
53975       loadImage(_photo, "");
53976       loadImage(_photo, data.image_path).then(() => {
53977         if (!keepOrientation) {
53978           imgZoom = zoomBeahvior();
53979           _wrapper.call(imgZoom);
53980           _wrapper.call(imgZoom.transform, identity2.translate(-_widthOverflow / 2, 0));
53981         }
53982       });
53983       return this;
53984     },
53985     getYaw: function() {
53986       return 0;
53987     }
53988   };
53989
53990   // modules/svg/local_photos.js
53991   var _initialized2 = false;
53992   var _enabled2 = false;
53993   var minViewfieldZoom = 16;
53994   function svgLocalPhotos(projection2, context, dispatch14) {
53995     const detected = utilDetect();
53996     let layer = select_default2(null);
53997     let _fileList;
53998     let _photos = [];
53999     let _idAutoinc = 0;
54000     let _photoFrame;
54001     function init2() {
54002       if (_initialized2)
54003         return;
54004       _enabled2 = true;
54005       function over(d3_event) {
54006         d3_event.stopPropagation();
54007         d3_event.preventDefault();
54008         d3_event.dataTransfer.dropEffect = "copy";
54009       }
54010       context.container().attr("dropzone", "copy").on("drop.svgLocalPhotos", function(d3_event) {
54011         d3_event.stopPropagation();
54012         d3_event.preventDefault();
54013         if (!detected.filedrop)
54014           return;
54015         drawPhotos.fileList(d3_event.dataTransfer.files, (loaded) => {
54016           if (loaded.length > 0) {
54017             drawPhotos.fitZoom(false);
54018           }
54019         });
54020       }).on("dragenter.svgLocalPhotos", over).on("dragexit.svgLocalPhotos", over).on("dragover.svgLocalPhotos", over);
54021       _initialized2 = true;
54022     }
54023     function ensureViewerLoaded(context2) {
54024       if (_photoFrame) {
54025         return Promise.resolve(_photoFrame);
54026       }
54027       const viewer = context2.container().select(".photoviewer").selectAll(".local-photos-wrapper").data([0]);
54028       const viewerEnter = viewer.enter().append("div").attr("class", "photo-wrapper local-photos-wrapper").classed("hide", true);
54029       viewerEnter.append("div").attr("class", "photo-attribution photo-attribution-dual fillD");
54030       return plane_photo_default.init(context2, viewerEnter).then((planePhotoFrame) => {
54031         _photoFrame = planePhotoFrame;
54032       });
54033     }
54034     function click(d3_event, image, zoomTo) {
54035       ensureViewerLoaded(context).then(() => {
54036         const viewer = context.container().select(".photoviewer").datum(image).classed("hide", false);
54037         const viewerWrap = viewer.select(".local-photos-wrapper").classed("hide", false);
54038         const attribution = viewerWrap.selectAll(".photo-attribution").text("");
54039         if (image.date) {
54040           attribution.append("span").text(image.date.toLocaleString());
54041         }
54042         if (image.name) {
54043           attribution.append("span").classed("filename", true).text(image.name);
54044         }
54045         _photoFrame.selectPhoto({ image_path: "" });
54046         image.getSrc().then((src) => {
54047           _photoFrame.selectPhoto({ image_path: src }).showPhotoFrame(viewerWrap);
54048           setStyles();
54049         });
54050       });
54051       if (zoomTo) {
54052         context.map().centerEase(image.loc);
54053       }
54054     }
54055     function transform2(d2) {
54056       var svgpoint = projection2(d2.loc);
54057       return "translate(" + svgpoint[0] + "," + svgpoint[1] + ")";
54058     }
54059     function setStyles(hovered) {
54060       const viewer = context.container().select(".photoviewer");
54061       const selected = viewer.empty() ? void 0 : viewer.datum();
54062       context.container().selectAll(".layer-local-photos .viewfield-group").classed("hovered", (d2) => d2.id === (hovered == null ? void 0 : hovered.id)).classed("highlighted", (d2) => d2.id === (hovered == null ? void 0 : hovered.id) || d2.id === (selected == null ? void 0 : selected.id)).classed("currentView", (d2) => d2.id === (selected == null ? void 0 : selected.id));
54063     }
54064     function display_markers(imageList) {
54065       imageList = imageList.filter((image) => isArray_default(image.loc) && isNumber_default(image.loc[0]) && isNumber_default(image.loc[1]));
54066       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(imageList, function(d2) {
54067         return d2.id;
54068       });
54069       groups.exit().remove();
54070       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", (d3_event, d2) => setStyles(d2)).on("mouseleave", () => setStyles(null)).on("click", click);
54071       groupsEnter.append("g").attr("class", "viewfield-scale");
54072       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
54073       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54074       const showViewfields = context.map().zoom() >= minViewfieldZoom;
54075       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54076       viewfields.exit().remove();
54077       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", function() {
54078         var _a2;
54079         const d2 = this.parentNode.__data__;
54080         return "rotate(".concat(Math.round((_a2 = d2.direction) != null ? _a2 : 0), ",0,0),scale(1.5,1.5),translate(-8,-13)");
54081       }).attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z").style("visibility", function() {
54082         const d2 = this.parentNode.__data__;
54083         return isNumber_default(d2.direction) ? "visible" : "hidden";
54084       });
54085     }
54086     function drawPhotos(selection2) {
54087       layer = selection2.selectAll(".layer-local-photos").data(_photos ? [0] : []);
54088       layer.exit().remove();
54089       const layerEnter = layer.enter().append("g").attr("class", "layer-local-photos");
54090       layerEnter.append("g").attr("class", "markers");
54091       layer = layerEnter.merge(layer);
54092       if (_photos) {
54093         display_markers(_photos);
54094       }
54095     }
54096     function readFileAsDataURL(file) {
54097       return new Promise((resolve, reject) => {
54098         const reader = new FileReader();
54099         reader.onload = () => resolve(reader.result);
54100         reader.onerror = (error) => reject(error);
54101         reader.readAsDataURL(file);
54102       });
54103     }
54104     async function readmultifiles(files, callback) {
54105       const loaded = [];
54106       for (const file of files) {
54107         try {
54108           const exifData = await full_esm_default.parse(file);
54109           const photo = {
54110             id: _idAutoinc++,
54111             name: file.name,
54112             getSrc: () => readFileAsDataURL(file),
54113             file,
54114             loc: [exifData.longitude, exifData.latitude],
54115             direction: exifData.GPSImgDirection,
54116             date: exifData.CreateDate || exifData.DateTimeOriginal || exifData.ModifyDate
54117           };
54118           loaded.push(photo);
54119           const sameName = _photos.filter((i3) => i3.name === photo.name);
54120           if (sameName.length === 0) {
54121             _photos.push(photo);
54122           } else {
54123             const thisContent = await photo.getSrc();
54124             const sameNameContent = await Promise.allSettled(sameName.map((i3) => i3.getSrc()));
54125             if (!sameNameContent.some((i3) => i3.value === thisContent)) {
54126               _photos.push(photo);
54127             }
54128           }
54129         } catch (err) {
54130         }
54131       }
54132       if (typeof callback === "function")
54133         callback(loaded);
54134       dispatch14.call("change");
54135     }
54136     drawPhotos.setFiles = function(fileList, callback) {
54137       readmultifiles(Array.from(fileList), callback);
54138       return this;
54139     };
54140     drawPhotos.fileList = function(fileList, callback) {
54141       if (!arguments.length)
54142         return _fileList;
54143       _fileList = fileList;
54144       if (!fileList || !fileList.length)
54145         return this;
54146       drawPhotos.setFiles(_fileList, callback);
54147       return this;
54148     };
54149     drawPhotos.getPhotos = function() {
54150       return _photos;
54151     };
54152     drawPhotos.removePhoto = function(id2) {
54153       _photos = _photos.filter((i3) => i3.id !== id2);
54154       dispatch14.call("change");
54155       return _photos;
54156     };
54157     drawPhotos.openPhoto = click;
54158     drawPhotos.fitZoom = function(force) {
54159       const coords = _photos.map((image) => image.loc).filter((l2) => isArray_default(l2) && isNumber_default(l2[0]) && isNumber_default(l2[1]));
54160       if (coords.length === 0)
54161         return;
54162       const extent = coords.map((l2) => geoExtent(l2, l2)).reduce((a2, b2) => a2.extend(b2));
54163       const map2 = context.map();
54164       var viewport = map2.trimmedExtent().polygon();
54165       if (force !== false || !geoPolygonIntersectsPolygon(viewport, coords, true)) {
54166         map2.centerZoom(extent.center(), Math.min(18, map2.trimmedExtentZoom(extent)));
54167       }
54168     };
54169     function showLayer() {
54170       layer.style("display", "block");
54171       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54172         dispatch14.call("change");
54173       });
54174     }
54175     function hideLayer() {
54176       layer.transition().duration(250).style("opacity", 0).on("end", () => {
54177         layer.selectAll(".viewfield-group").remove();
54178         layer.style("display", "none");
54179       });
54180     }
54181     drawPhotos.enabled = function(val) {
54182       if (!arguments.length)
54183         return _enabled2;
54184       _enabled2 = val;
54185       if (_enabled2) {
54186         showLayer();
54187       } else {
54188         hideLayer();
54189       }
54190       dispatch14.call("change");
54191       return this;
54192     };
54193     drawPhotos.hasData = function() {
54194       return isArray_default(_photos) && _photos.length > 0;
54195     };
54196     init2();
54197     return drawPhotos;
54198   }
54199
54200   // modules/svg/improveOSM.js
54201   var _layerEnabled2 = false;
54202   var _qaService2;
54203   function svgImproveOSM(projection2, context, dispatch14) {
54204     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
54205     const minZoom4 = 12;
54206     let touchLayer = select_default2(null);
54207     let drawLayer = select_default2(null);
54208     let layerVisible = false;
54209     function markerPath(selection2, klass) {
54210       selection2.attr("class", klass).attr("transform", "translate(-10, -28)").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6");
54211     }
54212     function getService() {
54213       if (services.improveOSM && !_qaService2) {
54214         _qaService2 = services.improveOSM;
54215         _qaService2.on("loaded", throttledRedraw);
54216       } else if (!services.improveOSM && _qaService2) {
54217         _qaService2 = null;
54218       }
54219       return _qaService2;
54220     }
54221     function editOn() {
54222       if (!layerVisible) {
54223         layerVisible = true;
54224         drawLayer.style("display", "block");
54225       }
54226     }
54227     function editOff() {
54228       if (layerVisible) {
54229         layerVisible = false;
54230         drawLayer.style("display", "none");
54231         drawLayer.selectAll(".qaItem.improveOSM").remove();
54232         touchLayer.selectAll(".qaItem.improveOSM").remove();
54233       }
54234     }
54235     function layerOn() {
54236       editOn();
54237       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
54238     }
54239     function layerOff() {
54240       throttledRedraw.cancel();
54241       drawLayer.interrupt();
54242       touchLayer.selectAll(".qaItem.improveOSM").remove();
54243       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
54244         editOff();
54245         dispatch14.call("change");
54246       });
54247     }
54248     function updateMarkers() {
54249       if (!layerVisible || !_layerEnabled2)
54250         return;
54251       const service = getService();
54252       const selectedID = context.selectedErrorID();
54253       const data = service ? service.getItems(projection2) : [];
54254       const getTransform = svgPointTransform(projection2);
54255       const markers = drawLayer.selectAll(".qaItem.improveOSM").data(data, (d2) => d2.id);
54256       markers.exit().remove();
54257       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
54258       markersEnter.append("polygon").call(markerPath, "shadow");
54259       markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke");
54260       markersEnter.append("polygon").attr("fill", "currentColor").call(markerPath, "qaItem-fill");
54261       markersEnter.append("use").attr("class", "icon-annotation").attr("transform", "translate(-6, -22)").attr("width", "12px").attr("height", "12px").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : "");
54262       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
54263       if (touchLayer.empty())
54264         return;
54265       const fillClass = context.getDebug("target") ? "pink " : "nocolor ";
54266       const targets = touchLayer.selectAll(".qaItem.improveOSM").data(data, (d2) => d2.id);
54267       targets.exit().remove();
54268       targets.enter().append("rect").attr("width", "20px").attr("height", "30px").attr("x", "-10px").attr("y", "-28px").merge(targets).sort(sortY).attr("class", (d2) => "qaItem ".concat(d2.service, " target ").concat(fillClass, " itemId-").concat(d2.id)).attr("transform", getTransform);
54269       function sortY(a2, b2) {
54270         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1];
54271       }
54272     }
54273     function drawImproveOSM(selection2) {
54274       const service = getService();
54275       const surface = context.surface();
54276       if (surface && !surface.empty()) {
54277         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
54278       }
54279       drawLayer = selection2.selectAll(".layer-improveOSM").data(service ? [0] : []);
54280       drawLayer.exit().remove();
54281       drawLayer = drawLayer.enter().append("g").attr("class", "layer-improveOSM").style("display", _layerEnabled2 ? "block" : "none").merge(drawLayer);
54282       if (_layerEnabled2) {
54283         if (service && ~~context.map().zoom() >= minZoom4) {
54284           editOn();
54285           service.loadIssues(projection2);
54286           updateMarkers();
54287         } else {
54288           editOff();
54289         }
54290       }
54291     }
54292     drawImproveOSM.enabled = function(val) {
54293       if (!arguments.length)
54294         return _layerEnabled2;
54295       _layerEnabled2 = val;
54296       if (_layerEnabled2) {
54297         layerOn();
54298       } else {
54299         layerOff();
54300         if (context.selectedErrorID()) {
54301           context.enter(modeBrowse(context));
54302         }
54303       }
54304       dispatch14.call("change");
54305       return this;
54306     };
54307     drawImproveOSM.supported = () => !!getService();
54308     return drawImproveOSM;
54309   }
54310
54311   // modules/svg/osmose.js
54312   var _layerEnabled3 = false;
54313   var _qaService3;
54314   function svgOsmose(projection2, context, dispatch14) {
54315     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
54316     const minZoom4 = 12;
54317     let touchLayer = select_default2(null);
54318     let drawLayer = select_default2(null);
54319     let layerVisible = false;
54320     function markerPath(selection2, klass) {
54321       selection2.attr("class", klass).attr("transform", "translate(-10, -28)").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6");
54322     }
54323     function getService() {
54324       if (services.osmose && !_qaService3) {
54325         _qaService3 = services.osmose;
54326         _qaService3.on("loaded", throttledRedraw);
54327       } else if (!services.osmose && _qaService3) {
54328         _qaService3 = null;
54329       }
54330       return _qaService3;
54331     }
54332     function editOn() {
54333       if (!layerVisible) {
54334         layerVisible = true;
54335         drawLayer.style("display", "block");
54336       }
54337     }
54338     function editOff() {
54339       if (layerVisible) {
54340         layerVisible = false;
54341         drawLayer.style("display", "none");
54342         drawLayer.selectAll(".qaItem.osmose").remove();
54343         touchLayer.selectAll(".qaItem.osmose").remove();
54344       }
54345     }
54346     function layerOn() {
54347       editOn();
54348       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", () => dispatch14.call("change"));
54349     }
54350     function layerOff() {
54351       throttledRedraw.cancel();
54352       drawLayer.interrupt();
54353       touchLayer.selectAll(".qaItem.osmose").remove();
54354       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", () => {
54355         editOff();
54356         dispatch14.call("change");
54357       });
54358     }
54359     function updateMarkers() {
54360       if (!layerVisible || !_layerEnabled3)
54361         return;
54362       const service = getService();
54363       const selectedID = context.selectedErrorID();
54364       const data = service ? service.getItems(projection2) : [];
54365       const getTransform = svgPointTransform(projection2);
54366       const markers = drawLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
54367       markers.exit().remove();
54368       const markersEnter = markers.enter().append("g").attr("class", (d2) => "qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
54369       markersEnter.append("polygon").call(markerPath, "shadow");
54370       markersEnter.append("ellipse").attr("cx", 0).attr("cy", 0).attr("rx", 4.5).attr("ry", 2).attr("class", "stroke");
54371       markersEnter.append("polygon").attr("fill", (d2) => service.getColor(d2.item)).call(markerPath, "qaItem-fill");
54372       markersEnter.append("use").attr("class", "icon-annotation").attr("transform", "translate(-6, -22)").attr("width", "12px").attr("height", "12px").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : "");
54373       markers.merge(markersEnter).sort(sortY).classed("selected", (d2) => d2.id === selectedID).attr("transform", getTransform);
54374       if (touchLayer.empty())
54375         return;
54376       const fillClass = context.getDebug("target") ? "pink" : "nocolor";
54377       const targets = touchLayer.selectAll(".qaItem.osmose").data(data, (d2) => d2.id);
54378       targets.exit().remove();
54379       targets.enter().append("rect").attr("width", "20px").attr("height", "30px").attr("x", "-10px").attr("y", "-28px").merge(targets).sort(sortY).attr("class", (d2) => "qaItem ".concat(d2.service, " target ").concat(fillClass, " itemId-").concat(d2.id)).attr("transform", getTransform);
54380       function sortY(a2, b2) {
54381         return a2.id === selectedID ? 1 : b2.id === selectedID ? -1 : b2.loc[1] - a2.loc[1];
54382       }
54383     }
54384     function drawOsmose(selection2) {
54385       const service = getService();
54386       const surface = context.surface();
54387       if (surface && !surface.empty()) {
54388         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
54389       }
54390       drawLayer = selection2.selectAll(".layer-osmose").data(service ? [0] : []);
54391       drawLayer.exit().remove();
54392       drawLayer = drawLayer.enter().append("g").attr("class", "layer-osmose").style("display", _layerEnabled3 ? "block" : "none").merge(drawLayer);
54393       if (_layerEnabled3) {
54394         if (service && ~~context.map().zoom() >= minZoom4) {
54395           editOn();
54396           service.loadIssues(projection2);
54397           updateMarkers();
54398         } else {
54399           editOff();
54400         }
54401       }
54402     }
54403     drawOsmose.enabled = function(val) {
54404       if (!arguments.length)
54405         return _layerEnabled3;
54406       _layerEnabled3 = val;
54407       if (_layerEnabled3) {
54408         getService().loadStrings().then(layerOn).catch((err) => {
54409           console.log(err);
54410         });
54411       } else {
54412         layerOff();
54413         if (context.selectedErrorID()) {
54414           context.enter(modeBrowse(context));
54415         }
54416       }
54417       dispatch14.call("change");
54418       return this;
54419     };
54420     drawOsmose.supported = () => !!getService();
54421     return drawOsmose;
54422   }
54423
54424   // modules/svg/streetside.js
54425   function svgStreetside(projection2, context, dispatch14) {
54426     var throttledRedraw = throttle_default(function() {
54427       dispatch14.call("change");
54428     }, 1e3);
54429     var minZoom4 = 14;
54430     var minMarkerZoom = 16;
54431     var minViewfieldZoom2 = 18;
54432     var layer = select_default2(null);
54433     var _viewerYaw = 0;
54434     var _selectedSequence = null;
54435     var _streetside;
54436     function init2() {
54437       if (svgStreetside.initialized)
54438         return;
54439       svgStreetside.enabled = false;
54440       svgStreetside.initialized = true;
54441     }
54442     function getService() {
54443       if (services.streetside && !_streetside) {
54444         _streetside = services.streetside;
54445         _streetside.event.on("viewerChanged.svgStreetside", viewerChanged).on("loadedImages.svgStreetside", throttledRedraw);
54446       } else if (!services.streetside && _streetside) {
54447         _streetside = null;
54448       }
54449       return _streetside;
54450     }
54451     function showLayer() {
54452       var service = getService();
54453       if (!service)
54454         return;
54455       editOn();
54456       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54457         dispatch14.call("change");
54458       });
54459     }
54460     function hideLayer() {
54461       throttledRedraw.cancel();
54462       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54463     }
54464     function editOn() {
54465       layer.style("display", "block");
54466     }
54467     function editOff() {
54468       layer.selectAll(".viewfield-group").remove();
54469       layer.style("display", "none");
54470     }
54471     function click(d3_event, d2) {
54472       var service = getService();
54473       if (!service)
54474         return;
54475       if (d2.sequenceKey !== _selectedSequence) {
54476         _viewerYaw = 0;
54477       }
54478       _selectedSequence = d2.sequenceKey;
54479       service.ensureViewerLoaded(context).then(function() {
54480         service.selectImage(context, d2.key).yaw(_viewerYaw).showViewer(context);
54481       });
54482       context.map().centerEase(d2.loc);
54483     }
54484     function mouseover(d3_event, d2) {
54485       var service = getService();
54486       if (service)
54487         service.setStyles(context, d2);
54488     }
54489     function mouseout() {
54490       var service = getService();
54491       if (service)
54492         service.setStyles(context, null);
54493     }
54494     function transform2(d2) {
54495       var t2 = svgPointTransform(projection2)(d2);
54496       var rot = d2.ca + _viewerYaw;
54497       if (rot) {
54498         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
54499       }
54500       return t2;
54501     }
54502     function viewerChanged() {
54503       var service = getService();
54504       if (!service)
54505         return;
54506       var viewer = service.viewer();
54507       if (!viewer)
54508         return;
54509       _viewerYaw = viewer.getYaw();
54510       if (context.map().isTransformed())
54511         return;
54512       layer.selectAll(".viewfield-group.currentView").attr("transform", transform2);
54513     }
54514     function filterBubbles(bubbles) {
54515       var fromDate = context.photos().fromDate();
54516       var toDate = context.photos().toDate();
54517       var usernames = context.photos().usernames();
54518       if (fromDate) {
54519         var fromTimestamp = new Date(fromDate).getTime();
54520         bubbles = bubbles.filter(function(bubble) {
54521           return new Date(bubble.captured_at).getTime() >= fromTimestamp;
54522         });
54523       }
54524       if (toDate) {
54525         var toTimestamp = new Date(toDate).getTime();
54526         bubbles = bubbles.filter(function(bubble) {
54527           return new Date(bubble.captured_at).getTime() <= toTimestamp;
54528         });
54529       }
54530       if (usernames) {
54531         bubbles = bubbles.filter(function(bubble) {
54532           return usernames.indexOf(bubble.captured_by) !== -1;
54533         });
54534       }
54535       return bubbles;
54536     }
54537     function filterSequences(sequences) {
54538       var fromDate = context.photos().fromDate();
54539       var toDate = context.photos().toDate();
54540       var usernames = context.photos().usernames();
54541       if (fromDate) {
54542         var fromTimestamp = new Date(fromDate).getTime();
54543         sequences = sequences.filter(function(sequences2) {
54544           return new Date(sequences2.properties.captured_at).getTime() >= fromTimestamp;
54545         });
54546       }
54547       if (toDate) {
54548         var toTimestamp = new Date(toDate).getTime();
54549         sequences = sequences.filter(function(sequences2) {
54550           return new Date(sequences2.properties.captured_at).getTime() <= toTimestamp;
54551         });
54552       }
54553       if (usernames) {
54554         sequences = sequences.filter(function(sequences2) {
54555           return usernames.indexOf(sequences2.properties.captured_by) !== -1;
54556         });
54557       }
54558       return sequences;
54559     }
54560     function update() {
54561       var viewer = context.container().select(".photoviewer");
54562       var selected = viewer.empty() ? void 0 : viewer.datum();
54563       var z2 = ~~context.map().zoom();
54564       var showMarkers = z2 >= minMarkerZoom;
54565       var showViewfields = z2 >= minViewfieldZoom2;
54566       var service = getService();
54567       var sequences = [];
54568       var bubbles = [];
54569       if (context.photos().showsPanoramic()) {
54570         sequences = service ? service.sequences(projection2) : [];
54571         bubbles = service && showMarkers ? service.bubbles(projection2) : [];
54572         sequences = filterSequences(sequences);
54573         bubbles = filterBubbles(bubbles);
54574       }
54575       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54576         return d2.properties.key;
54577       });
54578       traces.exit().remove();
54579       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54580       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(bubbles, function(d2) {
54581         return d2.key + (d2.sequenceKey ? "v1" : "v0");
54582       });
54583       groups.exit().remove();
54584       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54585       groupsEnter.append("g").attr("class", "viewfield-scale");
54586       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
54587         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
54588       }).attr("transform", transform2).select(".viewfield-scale");
54589       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54590       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54591       viewfields.exit().remove();
54592       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54593       function viewfieldPath() {
54594         var d2 = this.parentNode.__data__;
54595         if (d2.pano) {
54596           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54597         } else {
54598           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54599         }
54600       }
54601     }
54602     function drawImages(selection2) {
54603       var enabled = svgStreetside.enabled;
54604       var service = getService();
54605       layer = selection2.selectAll(".layer-streetside-images").data(service ? [0] : []);
54606       layer.exit().remove();
54607       var layerEnter = layer.enter().append("g").attr("class", "layer-streetside-images").style("display", enabled ? "block" : "none");
54608       layerEnter.append("g").attr("class", "sequences");
54609       layerEnter.append("g").attr("class", "markers");
54610       layer = layerEnter.merge(layer);
54611       if (enabled) {
54612         if (service && ~~context.map().zoom() >= minZoom4) {
54613           editOn();
54614           update();
54615           service.loadBubbles(projection2);
54616         } else {
54617           editOff();
54618         }
54619       }
54620     }
54621     drawImages.enabled = function(_2) {
54622       if (!arguments.length)
54623         return svgStreetside.enabled;
54624       svgStreetside.enabled = _2;
54625       if (svgStreetside.enabled) {
54626         showLayer();
54627         context.photos().on("change.streetside", update);
54628       } else {
54629         hideLayer();
54630         context.photos().on("change.streetside", null);
54631       }
54632       dispatch14.call("change");
54633       return this;
54634     };
54635     drawImages.supported = function() {
54636       return !!getService();
54637     };
54638     drawImages.rendered = function(zoom) {
54639       return zoom >= minZoom4;
54640     };
54641     init2();
54642     return drawImages;
54643   }
54644
54645   // modules/svg/vegbilder.js
54646   function svgVegbilder(projection2, context, dispatch14) {
54647     const throttledRedraw = throttle_default(() => dispatch14.call("change"), 1e3);
54648     const minZoom4 = 14;
54649     const minMarkerZoom = 16;
54650     const minViewfieldZoom2 = 18;
54651     let layer = select_default2(null);
54652     let _viewerYaw = 0;
54653     let _vegbilder;
54654     function init2() {
54655       if (svgVegbilder.initialized)
54656         return;
54657       svgVegbilder.enabled = false;
54658       svgVegbilder.initialized = true;
54659     }
54660     function getService() {
54661       if (services.vegbilder && !_vegbilder) {
54662         _vegbilder = services.vegbilder;
54663         _vegbilder.event.on("viewerChanged.svgVegbilder", viewerChanged).on("loadedImages.svgVegbilder", throttledRedraw);
54664       } else if (!services.vegbilder && _vegbilder) {
54665         _vegbilder = null;
54666       }
54667       return _vegbilder;
54668     }
54669     function showLayer() {
54670       const service = getService();
54671       if (!service)
54672         return;
54673       editOn();
54674       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", () => dispatch14.call("change"));
54675     }
54676     function hideLayer() {
54677       throttledRedraw.cancel();
54678       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54679     }
54680     function editOn() {
54681       layer.style("display", "block");
54682     }
54683     function editOff() {
54684       layer.selectAll(".viewfield-group").remove();
54685       layer.style("display", "none");
54686     }
54687     function click(d3_event, d2) {
54688       const service = getService();
54689       if (!service)
54690         return;
54691       service.ensureViewerLoaded(context).then(() => {
54692         service.selectImage(context, d2.key).showViewer(context);
54693       });
54694       context.map().centerEase(d2.loc);
54695     }
54696     function mouseover(d3_event, d2) {
54697       const service = getService();
54698       if (service)
54699         service.setStyles(context, d2);
54700     }
54701     function mouseout() {
54702       const service = getService();
54703       if (service)
54704         service.setStyles(context, null);
54705     }
54706     function transform2(d2, selected) {
54707       let t2 = svgPointTransform(projection2)(d2);
54708       let rot = d2.ca;
54709       if (d2 === selected) {
54710         rot += _viewerYaw;
54711       }
54712       if (rot) {
54713         t2 += " rotate(" + Math.floor(rot) + ",0,0)";
54714       }
54715       return t2;
54716     }
54717     function viewerChanged() {
54718       const service = getService();
54719       if (!service)
54720         return;
54721       const frame2 = service.photoFrame();
54722       _viewerYaw = frame2.getYaw();
54723       if (context.map().isTransformed())
54724         return;
54725       layer.selectAll(".viewfield-group.currentView").attr("transform", (d2) => transform2(d2, d2));
54726     }
54727     function filterImages(images) {
54728       const photoContext = context.photos();
54729       const fromDateString = photoContext.fromDate();
54730       const toDateString = photoContext.toDate();
54731       const showsFlat = photoContext.showsFlat();
54732       const showsPano = photoContext.showsPanoramic();
54733       if (fromDateString) {
54734         const fromDate = new Date(fromDateString);
54735         images = images.filter((image) => image.captured_at.getTime() >= fromDate.getTime());
54736       }
54737       if (toDateString) {
54738         const toDate = new Date(toDateString);
54739         images = images.filter((image) => image.captured_at.getTime() <= toDate.getTime());
54740       }
54741       if (!showsPano) {
54742         images = images.filter((image) => !image.is_sphere);
54743       }
54744       if (!showsFlat) {
54745         images = images.filter((image) => image.is_sphere);
54746       }
54747       return images;
54748     }
54749     function filterSequences(sequences) {
54750       const photoContext = context.photos();
54751       const fromDateString = photoContext.fromDate();
54752       const toDateString = photoContext.toDate();
54753       const showsFlat = photoContext.showsFlat();
54754       const showsPano = photoContext.showsPanoramic();
54755       if (fromDateString) {
54756         const fromDate = new Date(fromDateString);
54757         sequences = sequences.filter(({ images }) => images[0].captured_at.getTime() >= fromDate.getTime());
54758       }
54759       if (toDateString) {
54760         const toDate = new Date(toDateString);
54761         sequences = sequences.filter(({ images }) => images[images.length - 1].captured_at.getTime() <= toDate.getTime());
54762       }
54763       if (!showsPano) {
54764         sequences = sequences.filter(({ images }) => !images[0].is_sphere);
54765       }
54766       if (!showsFlat) {
54767         sequences = sequences.filter(({ images }) => images[0].is_sphere);
54768       }
54769       return sequences;
54770     }
54771     function update() {
54772       const viewer = context.container().select(".photoviewer");
54773       const selected = viewer.empty() ? void 0 : viewer.datum();
54774       const z2 = ~~context.map().zoom();
54775       const showMarkers = z2 >= minMarkerZoom;
54776       const showViewfields = z2 >= minViewfieldZoom2;
54777       const service = getService();
54778       let sequences = [];
54779       let images = [];
54780       if (service) {
54781         service.loadImages(context);
54782         sequences = service.sequences(projection2);
54783         images = showMarkers ? service.images(projection2) : [];
54784         images = filterImages(images);
54785         sequences = filterSequences(sequences);
54786       }
54787       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, (d2) => d2.key);
54788       traces.exit().remove();
54789       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54790       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, (d2) => d2.key);
54791       groups.exit().remove();
54792       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54793       groupsEnter.append("g").attr("class", "viewfield-scale");
54794       const markers = groups.merge(groupsEnter).sort((a2, b2) => {
54795         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
54796       }).attr("transform", (d2) => transform2(d2, selected)).select(".viewfield-scale");
54797       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
54798       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
54799       viewfields.exit().remove();
54800       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
54801       function viewfieldPath() {
54802         const d2 = this.parentNode.__data__;
54803         if (d2.is_sphere) {
54804           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
54805         } else {
54806           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
54807         }
54808       }
54809     }
54810     function drawImages(selection2) {
54811       const enabled = svgVegbilder.enabled;
54812       const service = getService();
54813       layer = selection2.selectAll(".layer-vegbilder").data(service ? [0] : []);
54814       layer.exit().remove();
54815       const layerEnter = layer.enter().append("g").attr("class", "layer-vegbilder").style("display", enabled ? "block" : "none");
54816       layerEnter.append("g").attr("class", "sequences");
54817       layerEnter.append("g").attr("class", "markers");
54818       layer = layerEnter.merge(layer);
54819       if (enabled) {
54820         if (service && ~~context.map().zoom() >= minZoom4) {
54821           editOn();
54822           update();
54823           service.loadImages(context);
54824         } else {
54825           editOff();
54826         }
54827       }
54828     }
54829     drawImages.enabled = function(_2) {
54830       if (!arguments.length)
54831         return svgVegbilder.enabled;
54832       svgVegbilder.enabled = _2;
54833       if (svgVegbilder.enabled) {
54834         showLayer();
54835         context.photos().on("change.vegbilder", update);
54836       } else {
54837         hideLayer();
54838         context.photos().on("change.vegbilder", null);
54839       }
54840       dispatch14.call("change");
54841       return this;
54842     };
54843     drawImages.supported = function() {
54844       return !!getService();
54845     };
54846     drawImages.rendered = function(zoom) {
54847       return zoom >= minZoom4;
54848     };
54849     drawImages.validHere = function(extent, zoom) {
54850       return zoom >= minZoom4 - 2 && getService().validHere(extent);
54851     };
54852     init2();
54853     return drawImages;
54854   }
54855
54856   // modules/svg/mapillary_images.js
54857   function svgMapillaryImages(projection2, context, dispatch14) {
54858     const throttledRedraw = throttle_default(function() {
54859       dispatch14.call("change");
54860     }, 1e3);
54861     const minZoom4 = 12;
54862     const minMarkerZoom = 16;
54863     const minViewfieldZoom2 = 18;
54864     let layer = select_default2(null);
54865     let _mapillary;
54866     function init2() {
54867       if (svgMapillaryImages.initialized)
54868         return;
54869       svgMapillaryImages.enabled = false;
54870       svgMapillaryImages.initialized = true;
54871     }
54872     function getService() {
54873       if (services.mapillary && !_mapillary) {
54874         _mapillary = services.mapillary;
54875         _mapillary.event.on("loadedImages", throttledRedraw);
54876       } else if (!services.mapillary && _mapillary) {
54877         _mapillary = null;
54878       }
54879       return _mapillary;
54880     }
54881     function showLayer() {
54882       const service = getService();
54883       if (!service)
54884         return;
54885       editOn();
54886       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
54887         dispatch14.call("change");
54888       });
54889     }
54890     function hideLayer() {
54891       throttledRedraw.cancel();
54892       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
54893     }
54894     function editOn() {
54895       layer.style("display", "block");
54896     }
54897     function editOff() {
54898       layer.selectAll(".viewfield-group").remove();
54899       layer.style("display", "none");
54900     }
54901     function click(d3_event, image) {
54902       const service = getService();
54903       if (!service)
54904         return;
54905       service.ensureViewerLoaded(context).then(function() {
54906         service.selectImage(context, image.id).showViewer(context);
54907       });
54908       context.map().centerEase(image.loc);
54909     }
54910     function mouseover(d3_event, image) {
54911       const service = getService();
54912       if (service)
54913         service.setStyles(context, image);
54914     }
54915     function mouseout() {
54916       const service = getService();
54917       if (service)
54918         service.setStyles(context, null);
54919     }
54920     function transform2(d2) {
54921       let t2 = svgPointTransform(projection2)(d2);
54922       if (d2.ca) {
54923         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
54924       }
54925       return t2;
54926     }
54927     function filterImages(images) {
54928       const showsPano = context.photos().showsPanoramic();
54929       const showsFlat = context.photos().showsFlat();
54930       const fromDate = context.photos().fromDate();
54931       const toDate = context.photos().toDate();
54932       if (!showsPano || !showsFlat) {
54933         images = images.filter(function(image) {
54934           if (image.is_pano)
54935             return showsPano;
54936           return showsFlat;
54937         });
54938       }
54939       if (fromDate) {
54940         images = images.filter(function(image) {
54941           return new Date(image.captured_at).getTime() >= new Date(fromDate).getTime();
54942         });
54943       }
54944       if (toDate) {
54945         images = images.filter(function(image) {
54946           return new Date(image.captured_at).getTime() <= new Date(toDate).getTime();
54947         });
54948       }
54949       return images;
54950     }
54951     function filterSequences(sequences) {
54952       const showsPano = context.photos().showsPanoramic();
54953       const showsFlat = context.photos().showsFlat();
54954       const fromDate = context.photos().fromDate();
54955       const toDate = context.photos().toDate();
54956       if (!showsPano || !showsFlat) {
54957         sequences = sequences.filter(function(sequence) {
54958           if (sequence.properties.hasOwnProperty("is_pano")) {
54959             if (sequence.properties.is_pano)
54960               return showsPano;
54961             return showsFlat;
54962           }
54963           return false;
54964         });
54965       }
54966       if (fromDate) {
54967         sequences = sequences.filter(function(sequence) {
54968           return new Date(sequence.properties.captured_at).getTime() >= new Date(fromDate).getTime().toString();
54969         });
54970       }
54971       if (toDate) {
54972         sequences = sequences.filter(function(sequence) {
54973           return new Date(sequence.properties.captured_at).getTime() <= new Date(toDate).getTime().toString();
54974         });
54975       }
54976       return sequences;
54977     }
54978     function update() {
54979       const z2 = ~~context.map().zoom();
54980       const showMarkers = z2 >= minMarkerZoom;
54981       const showViewfields = z2 >= minViewfieldZoom2;
54982       const service = getService();
54983       let sequences = service ? service.sequences(projection2) : [];
54984       let images = service && showMarkers ? service.images(projection2) : [];
54985       images = filterImages(images);
54986       sequences = filterSequences(sequences, service);
54987       service.filterViewer(context);
54988       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
54989         return d2.properties.id;
54990       });
54991       traces.exit().remove();
54992       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
54993       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
54994         return d2.id;
54995       });
54996       groups.exit().remove();
54997       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
54998       groupsEnter.append("g").attr("class", "viewfield-scale");
54999       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
55000         return b2.loc[1] - a2.loc[1];
55001       }).attr("transform", transform2).select(".viewfield-scale");
55002       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55003       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55004       viewfields.exit().remove();
55005       viewfields.enter().insert("path", "circle").attr("class", "viewfield").classed("pano", function() {
55006         return this.parentNode.__data__.is_pano;
55007       }).attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
55008       function viewfieldPath() {
55009         if (this.parentNode.__data__.is_pano) {
55010           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
55011         } else {
55012           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
55013         }
55014       }
55015     }
55016     function drawImages(selection2) {
55017       const enabled = svgMapillaryImages.enabled;
55018       const service = getService();
55019       layer = selection2.selectAll(".layer-mapillary").data(service ? [0] : []);
55020       layer.exit().remove();
55021       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary").style("display", enabled ? "block" : "none");
55022       layerEnter.append("g").attr("class", "sequences");
55023       layerEnter.append("g").attr("class", "markers");
55024       layer = layerEnter.merge(layer);
55025       if (enabled) {
55026         if (service && ~~context.map().zoom() >= minZoom4) {
55027           editOn();
55028           update();
55029           service.loadImages(projection2);
55030         } else {
55031           editOff();
55032         }
55033       }
55034     }
55035     drawImages.enabled = function(_2) {
55036       if (!arguments.length)
55037         return svgMapillaryImages.enabled;
55038       svgMapillaryImages.enabled = _2;
55039       if (svgMapillaryImages.enabled) {
55040         showLayer();
55041         context.photos().on("change.mapillary_images", update);
55042       } else {
55043         hideLayer();
55044         context.photos().on("change.mapillary_images", null);
55045       }
55046       dispatch14.call("change");
55047       return this;
55048     };
55049     drawImages.supported = function() {
55050       return !!getService();
55051     };
55052     drawImages.rendered = function(zoom) {
55053       return zoom >= minZoom4;
55054     };
55055     init2();
55056     return drawImages;
55057   }
55058
55059   // modules/svg/mapillary_position.js
55060   function svgMapillaryPosition(projection2, context) {
55061     const throttledRedraw = throttle_default(function() {
55062       update();
55063     }, 1e3);
55064     const minZoom4 = 12;
55065     const minViewfieldZoom2 = 18;
55066     let layer = select_default2(null);
55067     let _mapillary;
55068     let viewerCompassAngle;
55069     function init2() {
55070       if (svgMapillaryPosition.initialized)
55071         return;
55072       svgMapillaryPosition.initialized = true;
55073     }
55074     function getService() {
55075       if (services.mapillary && !_mapillary) {
55076         _mapillary = services.mapillary;
55077         _mapillary.event.on("imageChanged", throttledRedraw);
55078         _mapillary.event.on("bearingChanged", function(e3) {
55079           viewerCompassAngle = e3.bearing;
55080           if (context.map().isTransformed())
55081             return;
55082           layer.selectAll(".viewfield-group.currentView").filter(function(d2) {
55083             return d2.is_pano;
55084           }).attr("transform", transform2);
55085         });
55086       } else if (!services.mapillary && _mapillary) {
55087         _mapillary = null;
55088       }
55089       return _mapillary;
55090     }
55091     function editOn() {
55092       layer.style("display", "block");
55093     }
55094     function editOff() {
55095       layer.selectAll(".viewfield-group").remove();
55096       layer.style("display", "none");
55097     }
55098     function transform2(d2) {
55099       let t2 = svgPointTransform(projection2)(d2);
55100       if (d2.is_pano && viewerCompassAngle !== null && isFinite(viewerCompassAngle)) {
55101         t2 += " rotate(" + Math.floor(viewerCompassAngle) + ",0,0)";
55102       } else if (d2.ca) {
55103         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
55104       }
55105       return t2;
55106     }
55107     function update() {
55108       const z2 = ~~context.map().zoom();
55109       const showViewfields = z2 >= minViewfieldZoom2;
55110       const service = getService();
55111       const image = service && service.getActiveImage();
55112       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(image ? [image] : [], function(d2) {
55113         return d2.id;
55114       });
55115       groups.exit().remove();
55116       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group currentView highlighted");
55117       groupsEnter.append("g").attr("class", "viewfield-scale");
55118       const markers = groups.merge(groupsEnter).attr("transform", transform2).select(".viewfield-scale");
55119       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55120       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55121       viewfields.exit().remove();
55122       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z");
55123     }
55124     function drawImages(selection2) {
55125       const service = getService();
55126       layer = selection2.selectAll(".layer-mapillary-position").data(service ? [0] : []);
55127       layer.exit().remove();
55128       const layerEnter = layer.enter().append("g").attr("class", "layer-mapillary-position");
55129       layerEnter.append("g").attr("class", "markers");
55130       layer = layerEnter.merge(layer);
55131       if (service && ~~context.map().zoom() >= minZoom4) {
55132         editOn();
55133         update();
55134       } else {
55135         editOff();
55136       }
55137     }
55138     drawImages.enabled = function() {
55139       update();
55140       return this;
55141     };
55142     drawImages.supported = function() {
55143       return !!getService();
55144     };
55145     drawImages.rendered = function(zoom) {
55146       return zoom >= minZoom4;
55147     };
55148     init2();
55149     return drawImages;
55150   }
55151
55152   // modules/svg/mapillary_signs.js
55153   function svgMapillarySigns(projection2, context, dispatch14) {
55154     const throttledRedraw = throttle_default(function() {
55155       dispatch14.call("change");
55156     }, 1e3);
55157     const minZoom4 = 12;
55158     let layer = select_default2(null);
55159     let _mapillary;
55160     function init2() {
55161       if (svgMapillarySigns.initialized)
55162         return;
55163       svgMapillarySigns.enabled = false;
55164       svgMapillarySigns.initialized = true;
55165     }
55166     function getService() {
55167       if (services.mapillary && !_mapillary) {
55168         _mapillary = services.mapillary;
55169         _mapillary.event.on("loadedSigns", throttledRedraw);
55170       } else if (!services.mapillary && _mapillary) {
55171         _mapillary = null;
55172       }
55173       return _mapillary;
55174     }
55175     function showLayer() {
55176       const service = getService();
55177       if (!service)
55178         return;
55179       service.loadSignResources(context);
55180       editOn();
55181     }
55182     function hideLayer() {
55183       throttledRedraw.cancel();
55184       editOff();
55185     }
55186     function editOn() {
55187       layer.style("display", "block");
55188     }
55189     function editOff() {
55190       layer.selectAll(".icon-sign").remove();
55191       layer.style("display", "none");
55192     }
55193     function click(d3_event, d2) {
55194       const service = getService();
55195       if (!service)
55196         return;
55197       context.map().centerEase(d2.loc);
55198       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
55199       service.getDetections(d2.id).then((detections) => {
55200         if (detections.length) {
55201           const imageId = detections[0].image.id;
55202           if (imageId === selectedImageId) {
55203             service.highlightDetection(detections[0]).selectImage(context, imageId);
55204           } else {
55205             service.ensureViewerLoaded(context).then(function() {
55206               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
55207             });
55208           }
55209         }
55210       });
55211     }
55212     function filterData(detectedFeatures) {
55213       var fromDate = context.photos().fromDate();
55214       var toDate = context.photos().toDate();
55215       if (fromDate) {
55216         var fromTimestamp = new Date(fromDate).getTime();
55217         detectedFeatures = detectedFeatures.filter(function(feature3) {
55218           return new Date(feature3.last_seen_at).getTime() >= fromTimestamp;
55219         });
55220       }
55221       if (toDate) {
55222         var toTimestamp = new Date(toDate).getTime();
55223         detectedFeatures = detectedFeatures.filter(function(feature3) {
55224           return new Date(feature3.first_seen_at).getTime() <= toTimestamp;
55225         });
55226       }
55227       return detectedFeatures;
55228     }
55229     function update() {
55230       const service = getService();
55231       let data = service ? service.signs(projection2) : [];
55232       data = filterData(data);
55233       const transform2 = svgPointTransform(projection2);
55234       const signs = layer.selectAll(".icon-sign").data(data, function(d2) {
55235         return d2.id;
55236       });
55237       signs.exit().remove();
55238       const enter = signs.enter().append("g").attr("class", "icon-sign icon-detected").on("click", click);
55239       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
55240         return "#" + d2.value;
55241       });
55242       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
55243       signs.merge(enter).attr("transform", transform2);
55244     }
55245     function drawSigns(selection2) {
55246       const enabled = svgMapillarySigns.enabled;
55247       const service = getService();
55248       layer = selection2.selectAll(".layer-mapillary-signs").data(service ? [0] : []);
55249       layer.exit().remove();
55250       layer = layer.enter().append("g").attr("class", "layer-mapillary-signs layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
55251       if (enabled) {
55252         if (service && ~~context.map().zoom() >= minZoom4) {
55253           editOn();
55254           update();
55255           service.loadSigns(projection2);
55256           service.showSignDetections(true);
55257         } else {
55258           editOff();
55259         }
55260       } else if (service) {
55261         service.showSignDetections(false);
55262       }
55263     }
55264     drawSigns.enabled = function(_2) {
55265       if (!arguments.length)
55266         return svgMapillarySigns.enabled;
55267       svgMapillarySigns.enabled = _2;
55268       if (svgMapillarySigns.enabled) {
55269         showLayer();
55270         context.photos().on("change.mapillary_signs", update);
55271       } else {
55272         hideLayer();
55273         context.photos().on("change.mapillary_signs", null);
55274       }
55275       dispatch14.call("change");
55276       return this;
55277     };
55278     drawSigns.supported = function() {
55279       return !!getService();
55280     };
55281     drawSigns.rendered = function(zoom) {
55282       return zoom >= minZoom4;
55283     };
55284     init2();
55285     return drawSigns;
55286   }
55287
55288   // modules/svg/mapillary_map_features.js
55289   function svgMapillaryMapFeatures(projection2, context, dispatch14) {
55290     const throttledRedraw = throttle_default(function() {
55291       dispatch14.call("change");
55292     }, 1e3);
55293     const minZoom4 = 12;
55294     let layer = select_default2(null);
55295     let _mapillary;
55296     function init2() {
55297       if (svgMapillaryMapFeatures.initialized)
55298         return;
55299       svgMapillaryMapFeatures.enabled = false;
55300       svgMapillaryMapFeatures.initialized = true;
55301     }
55302     function getService() {
55303       if (services.mapillary && !_mapillary) {
55304         _mapillary = services.mapillary;
55305         _mapillary.event.on("loadedMapFeatures", throttledRedraw);
55306       } else if (!services.mapillary && _mapillary) {
55307         _mapillary = null;
55308       }
55309       return _mapillary;
55310     }
55311     function showLayer() {
55312       const service = getService();
55313       if (!service)
55314         return;
55315       service.loadObjectResources(context);
55316       editOn();
55317     }
55318     function hideLayer() {
55319       throttledRedraw.cancel();
55320       editOff();
55321     }
55322     function editOn() {
55323       layer.style("display", "block");
55324     }
55325     function editOff() {
55326       layer.selectAll(".icon-map-feature").remove();
55327       layer.style("display", "none");
55328     }
55329     function click(d3_event, d2) {
55330       const service = getService();
55331       if (!service)
55332         return;
55333       context.map().centerEase(d2.loc);
55334       const selectedImageId = service.getActiveImage() && service.getActiveImage().id;
55335       service.getDetections(d2.id).then((detections) => {
55336         if (detections.length) {
55337           const imageId = detections[0].image.id;
55338           if (imageId === selectedImageId) {
55339             service.highlightDetection(detections[0]).selectImage(context, imageId);
55340           } else {
55341             service.ensureViewerLoaded(context).then(function() {
55342               service.highlightDetection(detections[0]).selectImage(context, imageId).showViewer(context);
55343             });
55344           }
55345         }
55346       });
55347     }
55348     function filterData(detectedFeatures) {
55349       const fromDate = context.photos().fromDate();
55350       const toDate = context.photos().toDate();
55351       if (fromDate) {
55352         detectedFeatures = detectedFeatures.filter(function(feature3) {
55353           return new Date(feature3.last_seen_at).getTime() >= new Date(fromDate).getTime();
55354         });
55355       }
55356       if (toDate) {
55357         detectedFeatures = detectedFeatures.filter(function(feature3) {
55358           return new Date(feature3.first_seen_at).getTime() <= new Date(toDate).getTime();
55359         });
55360       }
55361       return detectedFeatures;
55362     }
55363     function update() {
55364       const service = getService();
55365       let data = service ? service.mapFeatures(projection2) : [];
55366       data = filterData(data);
55367       const transform2 = svgPointTransform(projection2);
55368       const mapFeatures = layer.selectAll(".icon-map-feature").data(data, function(d2) {
55369         return d2.id;
55370       });
55371       mapFeatures.exit().remove();
55372       const enter = mapFeatures.enter().append("g").attr("class", "icon-map-feature icon-detected").on("click", click);
55373       enter.append("title").text(function(d2) {
55374         var id2 = d2.value.replace(/--/g, ".").replace(/-/g, "_");
55375         return _t("mapillary_map_features." + id2);
55376       });
55377       enter.append("use").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px").attr("xlink:href", function(d2) {
55378         if (d2.value === "object--billboard") {
55379           return "#object--sign--advertisement";
55380         }
55381         return "#" + d2.value;
55382       });
55383       enter.append("rect").attr("width", "24px").attr("height", "24px").attr("x", "-12px").attr("y", "-12px");
55384       mapFeatures.merge(enter).attr("transform", transform2);
55385     }
55386     function drawMapFeatures(selection2) {
55387       const enabled = svgMapillaryMapFeatures.enabled;
55388       const service = getService();
55389       layer = selection2.selectAll(".layer-mapillary-map-features").data(service ? [0] : []);
55390       layer.exit().remove();
55391       layer = layer.enter().append("g").attr("class", "layer-mapillary-map-features layer-mapillary-detections").style("display", enabled ? "block" : "none").merge(layer);
55392       if (enabled) {
55393         if (service && ~~context.map().zoom() >= minZoom4) {
55394           editOn();
55395           update();
55396           service.loadMapFeatures(projection2);
55397           service.showFeatureDetections(true);
55398         } else {
55399           editOff();
55400         }
55401       } else if (service) {
55402         service.showFeatureDetections(false);
55403       }
55404     }
55405     drawMapFeatures.enabled = function(_2) {
55406       if (!arguments.length)
55407         return svgMapillaryMapFeatures.enabled;
55408       svgMapillaryMapFeatures.enabled = _2;
55409       if (svgMapillaryMapFeatures.enabled) {
55410         showLayer();
55411         context.photos().on("change.mapillary_map_features", update);
55412       } else {
55413         hideLayer();
55414         context.photos().on("change.mapillary_map_features", null);
55415       }
55416       dispatch14.call("change");
55417       return this;
55418     };
55419     drawMapFeatures.supported = function() {
55420       return !!getService();
55421     };
55422     drawMapFeatures.rendered = function(zoom) {
55423       return zoom >= minZoom4;
55424     };
55425     init2();
55426     return drawMapFeatures;
55427   }
55428
55429   // modules/svg/kartaview_images.js
55430   function svgKartaviewImages(projection2, context, dispatch14) {
55431     var throttledRedraw = throttle_default(function() {
55432       dispatch14.call("change");
55433     }, 1e3);
55434     var minZoom4 = 12;
55435     var minMarkerZoom = 16;
55436     var minViewfieldZoom2 = 18;
55437     var layer = select_default2(null);
55438     var _kartaview;
55439     function init2() {
55440       if (svgKartaviewImages.initialized)
55441         return;
55442       svgKartaviewImages.enabled = false;
55443       svgKartaviewImages.initialized = true;
55444     }
55445     function getService() {
55446       if (services.kartaview && !_kartaview) {
55447         _kartaview = services.kartaview;
55448         _kartaview.event.on("loadedImages", throttledRedraw);
55449       } else if (!services.kartaview && _kartaview) {
55450         _kartaview = null;
55451       }
55452       return _kartaview;
55453     }
55454     function showLayer() {
55455       var service = getService();
55456       if (!service)
55457         return;
55458       editOn();
55459       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
55460         dispatch14.call("change");
55461       });
55462     }
55463     function hideLayer() {
55464       throttledRedraw.cancel();
55465       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
55466     }
55467     function editOn() {
55468       layer.style("display", "block");
55469     }
55470     function editOff() {
55471       layer.selectAll(".viewfield-group").remove();
55472       layer.style("display", "none");
55473     }
55474     function click(d3_event, d2) {
55475       var service = getService();
55476       if (!service)
55477         return;
55478       service.ensureViewerLoaded(context).then(function() {
55479         service.selectImage(context, d2.key).showViewer(context);
55480       });
55481       context.map().centerEase(d2.loc);
55482     }
55483     function mouseover(d3_event, d2) {
55484       var service = getService();
55485       if (service)
55486         service.setStyles(context, d2);
55487     }
55488     function mouseout() {
55489       var service = getService();
55490       if (service)
55491         service.setStyles(context, null);
55492     }
55493     function transform2(d2) {
55494       var t2 = svgPointTransform(projection2)(d2);
55495       if (d2.ca) {
55496         t2 += " rotate(" + Math.floor(d2.ca) + ",0,0)";
55497       }
55498       return t2;
55499     }
55500     function filterImages(images) {
55501       var fromDate = context.photos().fromDate();
55502       var toDate = context.photos().toDate();
55503       var usernames = context.photos().usernames();
55504       if (fromDate) {
55505         var fromTimestamp = new Date(fromDate).getTime();
55506         images = images.filter(function(item) {
55507           return new Date(item.captured_at).getTime() >= fromTimestamp;
55508         });
55509       }
55510       if (toDate) {
55511         var toTimestamp = new Date(toDate).getTime();
55512         images = images.filter(function(item) {
55513           return new Date(item.captured_at).getTime() <= toTimestamp;
55514         });
55515       }
55516       if (usernames) {
55517         images = images.filter(function(item) {
55518           return usernames.indexOf(item.captured_by) !== -1;
55519         });
55520       }
55521       return images;
55522     }
55523     function filterSequences(sequences) {
55524       var fromDate = context.photos().fromDate();
55525       var toDate = context.photos().toDate();
55526       var usernames = context.photos().usernames();
55527       if (fromDate) {
55528         var fromTimestamp = new Date(fromDate).getTime();
55529         sequences = sequences.filter(function(image) {
55530           return new Date(image.properties.captured_at).getTime() >= fromTimestamp;
55531         });
55532       }
55533       if (toDate) {
55534         var toTimestamp = new Date(toDate).getTime();
55535         sequences = sequences.filter(function(image) {
55536           return new Date(image.properties.captured_at).getTime() <= toTimestamp;
55537         });
55538       }
55539       if (usernames) {
55540         sequences = sequences.filter(function(image) {
55541           return usernames.indexOf(image.properties.captured_by) !== -1;
55542         });
55543       }
55544       return sequences;
55545     }
55546     function update() {
55547       var viewer = context.container().select(".photoviewer");
55548       var selected = viewer.empty() ? void 0 : viewer.datum();
55549       var z2 = ~~context.map().zoom();
55550       var showMarkers = z2 >= minMarkerZoom;
55551       var showViewfields = z2 >= minViewfieldZoom2;
55552       var service = getService();
55553       var sequences = [];
55554       var images = [];
55555       if (context.photos().showsFlat()) {
55556         sequences = service ? service.sequences(projection2) : [];
55557         images = service && showMarkers ? service.images(projection2) : [];
55558         sequences = filterSequences(sequences);
55559         images = filterImages(images);
55560       }
55561       var traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
55562         return d2.properties.key;
55563       });
55564       traces.exit().remove();
55565       traces = traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
55566       var groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
55567         return d2.key;
55568       });
55569       groups.exit().remove();
55570       var groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
55571       groupsEnter.append("g").attr("class", "viewfield-scale");
55572       var markers = groups.merge(groupsEnter).sort(function(a2, b2) {
55573         return a2 === selected ? 1 : b2 === selected ? -1 : b2.loc[1] - a2.loc[1];
55574       }).attr("transform", transform2).select(".viewfield-scale");
55575       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55576       var viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55577       viewfields.exit().remove();
55578       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z");
55579     }
55580     function drawImages(selection2) {
55581       var enabled = svgKartaviewImages.enabled, service = getService();
55582       layer = selection2.selectAll(".layer-kartaview").data(service ? [0] : []);
55583       layer.exit().remove();
55584       var layerEnter = layer.enter().append("g").attr("class", "layer-kartaview").style("display", enabled ? "block" : "none");
55585       layerEnter.append("g").attr("class", "sequences");
55586       layerEnter.append("g").attr("class", "markers");
55587       layer = layerEnter.merge(layer);
55588       if (enabled) {
55589         if (service && ~~context.map().zoom() >= minZoom4) {
55590           editOn();
55591           update();
55592           service.loadImages(projection2);
55593         } else {
55594           editOff();
55595         }
55596       }
55597     }
55598     drawImages.enabled = function(_2) {
55599       if (!arguments.length)
55600         return svgKartaviewImages.enabled;
55601       svgKartaviewImages.enabled = _2;
55602       if (svgKartaviewImages.enabled) {
55603         showLayer();
55604         context.photos().on("change.kartaview_images", update);
55605       } else {
55606         hideLayer();
55607         context.photos().on("change.kartaview_images", null);
55608       }
55609       dispatch14.call("change");
55610       return this;
55611     };
55612     drawImages.supported = function() {
55613       return !!getService();
55614     };
55615     drawImages.rendered = function(zoom) {
55616       return zoom >= minZoom4;
55617     };
55618     init2();
55619     return drawImages;
55620   }
55621
55622   // modules/svg/mapilio_images.js
55623   function svgMapilioImages(projection2, context, dispatch14) {
55624     const throttledRedraw = throttle_default(function() {
55625       dispatch14.call("change");
55626     }, 1e3);
55627     const minZoom4 = 12;
55628     let layer = select_default2(null);
55629     let _mapilio;
55630     const viewFieldZoomLevel = 18;
55631     function init2() {
55632       if (svgMapilioImages.initialized)
55633         return;
55634       svgMapilioImages.enabled = false;
55635       svgMapilioImages.initialized = true;
55636     }
55637     function getService() {
55638       if (services.mapilio && !_mapilio) {
55639         _mapilio = services.mapilio;
55640         _mapilio.event.on("loadedImages", throttledRedraw);
55641       } else if (!services.mapilio && _mapilio) {
55642         _mapilio = null;
55643       }
55644       return _mapilio;
55645     }
55646     function showLayer() {
55647       const service = getService();
55648       if (!service)
55649         return;
55650       editOn();
55651       layer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end", function() {
55652         dispatch14.call("change");
55653       });
55654     }
55655     function hideLayer() {
55656       throttledRedraw.cancel();
55657       layer.transition().duration(250).style("opacity", 0).on("end", editOff);
55658     }
55659     function transform2(d2) {
55660       let t2 = svgPointTransform(projection2)(d2);
55661       if (d2.heading) {
55662         t2 += " rotate(" + Math.floor(d2.heading) + ",0,0)";
55663       }
55664       return t2;
55665     }
55666     function editOn() {
55667       layer.style("display", "block");
55668     }
55669     function editOff() {
55670       layer.selectAll(".viewfield-group").remove();
55671       layer.style("display", "none");
55672     }
55673     function click(d3_event, image) {
55674       const service = getService();
55675       if (!service)
55676         return;
55677       service.ensureViewerLoaded(context, image.id).then(function() {
55678         service.selectImage(context, image.id).showViewer(context);
55679       });
55680       context.map().centerEase(image.loc);
55681     }
55682     function mouseover(d3_event, image) {
55683       const service = getService();
55684       if (service)
55685         service.setStyles(context, image);
55686     }
55687     function mouseout() {
55688       const service = getService();
55689       if (service)
55690         service.setStyles(context, null);
55691     }
55692     function update() {
55693       const z2 = ~~context.map().zoom();
55694       const showViewfields = z2 >= viewFieldZoomLevel;
55695       const service = getService();
55696       let sequences = service ? service.sequences(projection2) : [];
55697       let images = service ? service.images(projection2) : [];
55698       let traces = layer.selectAll(".sequences").selectAll(".sequence").data(sequences, function(d2) {
55699         return d2.properties.id;
55700       });
55701       traces.exit().remove();
55702       traces.enter().append("path").attr("class", "sequence").merge(traces).attr("d", svgPath(projection2).geojson);
55703       const groups = layer.selectAll(".markers").selectAll(".viewfield-group").data(images, function(d2) {
55704         return d2.id;
55705       });
55706       groups.exit().remove();
55707       const groupsEnter = groups.enter().append("g").attr("class", "viewfield-group").on("mouseenter", mouseover).on("mouseleave", mouseout).on("click", click);
55708       groupsEnter.append("g").attr("class", "viewfield-scale");
55709       const markers = groups.merge(groupsEnter).sort(function(a2, b2) {
55710         return b2.loc[1] - a2.loc[1];
55711       }).attr("transform", transform2).select(".viewfield-scale");
55712       markers.selectAll("circle").data([0]).enter().append("circle").attr("dx", "0").attr("dy", "0").attr("r", "6");
55713       const viewfields = markers.selectAll(".viewfield").data(showViewfields ? [0] : []);
55714       viewfields.exit().remove();
55715       viewfields.enter().insert("path", "circle").attr("class", "viewfield").attr("transform", "scale(1.5,1.5),translate(-8, -13)").attr("d", viewfieldPath);
55716       function viewfieldPath() {
55717         if (this.parentNode.__data__.isPano) {
55718           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
55719         } else {
55720           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
55721         }
55722       }
55723     }
55724     function drawImages(selection2) {
55725       const enabled = svgMapilioImages.enabled;
55726       const service = getService();
55727       layer = selection2.selectAll(".layer-mapilio").data(service ? [0] : []);
55728       layer.exit().remove();
55729       const layerEnter = layer.enter().append("g").attr("class", "layer-mapilio").style("display", enabled ? "block" : "none");
55730       layerEnter.append("g").attr("class", "sequences");
55731       layerEnter.append("g").attr("class", "markers");
55732       layer = layerEnter.merge(layer);
55733       if (enabled) {
55734         if (service && ~~context.map().zoom() >= minZoom4) {
55735           editOn();
55736           update();
55737           service.loadImages(projection2);
55738           service.loadLines(projection2);
55739         } else {
55740           editOff();
55741         }
55742       }
55743     }
55744     drawImages.enabled = function(_2) {
55745       if (!arguments.length)
55746         return svgMapilioImages.enabled;
55747       svgMapilioImages.enabled = _2;
55748       if (svgMapilioImages.enabled) {
55749         showLayer();
55750         context.photos().on("change.mapilio_images", null);
55751       } else {
55752         hideLayer();
55753         context.photos().on("change.mapilio_images", null);
55754       }
55755       dispatch14.call("change");
55756       return this;
55757     };
55758     drawImages.supported = function() {
55759       return !!getService();
55760     };
55761     drawImages.rendered = function(zoom) {
55762       return zoom >= minZoom4;
55763     };
55764     init2();
55765     return drawImages;
55766   }
55767
55768   // modules/svg/osm.js
55769   function svgOsm(projection2, context, dispatch14) {
55770     var enabled = true;
55771     function drawOsm(selection2) {
55772       selection2.selectAll(".layer-osm").data(["covered", "areas", "lines", "points", "labels"]).enter().append("g").attr("class", function(d2) {
55773         return "layer-osm " + d2;
55774       });
55775       selection2.selectAll(".layer-osm.points").selectAll(".points-group").data(["points", "midpoints", "vertices", "turns"]).enter().append("g").attr("class", function(d2) {
55776         return "points-group " + d2;
55777       });
55778     }
55779     function showLayer() {
55780       var layer = context.surface().selectAll(".data-layer.osm");
55781       layer.interrupt();
55782       layer.classed("disabled", false).style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
55783         dispatch14.call("change");
55784       });
55785     }
55786     function hideLayer() {
55787       var layer = context.surface().selectAll(".data-layer.osm");
55788       layer.interrupt();
55789       layer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
55790         layer.classed("disabled", true);
55791         dispatch14.call("change");
55792       });
55793     }
55794     drawOsm.enabled = function(val) {
55795       if (!arguments.length)
55796         return enabled;
55797       enabled = val;
55798       if (enabled) {
55799         showLayer();
55800       } else {
55801         hideLayer();
55802       }
55803       dispatch14.call("change");
55804       return this;
55805     };
55806     return drawOsm;
55807   }
55808
55809   // modules/svg/notes.js
55810   var _notesEnabled = false;
55811   var _osmService;
55812   function svgNotes(projection2, context, dispatch14) {
55813     if (!dispatch14) {
55814       dispatch14 = dispatch_default("change");
55815     }
55816     var throttledRedraw = throttle_default(function() {
55817       dispatch14.call("change");
55818     }, 1e3);
55819     var minZoom4 = 12;
55820     var touchLayer = select_default2(null);
55821     var drawLayer = select_default2(null);
55822     var _notesVisible = false;
55823     function markerPath(selection2, klass) {
55824       selection2.attr("class", klass).attr("transform", "translate(-8, -22)").attr("d", "m17.5,0l-15,0c-1.37,0 -2.5,1.12 -2.5,2.5l0,11.25c0,1.37 1.12,2.5 2.5,2.5l3.75,0l0,3.28c0,0.38 0.43,0.6 0.75,0.37l4.87,-3.65l5.62,0c1.37,0 2.5,-1.12 2.5,-2.5l0,-11.25c0,-1.37 -1.12,-2.5 -2.5,-2.5z");
55825     }
55826     function getService() {
55827       if (services.osm && !_osmService) {
55828         _osmService = services.osm;
55829         _osmService.on("loadedNotes", throttledRedraw);
55830       } else if (!services.osm && _osmService) {
55831         _osmService = null;
55832       }
55833       return _osmService;
55834     }
55835     function editOn() {
55836       if (!_notesVisible) {
55837         _notesVisible = true;
55838         drawLayer.style("display", "block");
55839       }
55840     }
55841     function editOff() {
55842       if (_notesVisible) {
55843         _notesVisible = false;
55844         drawLayer.style("display", "none");
55845         drawLayer.selectAll(".note").remove();
55846         touchLayer.selectAll(".note").remove();
55847       }
55848     }
55849     function layerOn() {
55850       editOn();
55851       drawLayer.style("opacity", 0).transition().duration(250).style("opacity", 1).on("end interrupt", function() {
55852         dispatch14.call("change");
55853       });
55854     }
55855     function layerOff() {
55856       throttledRedraw.cancel();
55857       drawLayer.interrupt();
55858       touchLayer.selectAll(".note").remove();
55859       drawLayer.transition().duration(250).style("opacity", 0).on("end interrupt", function() {
55860         editOff();
55861         dispatch14.call("change");
55862       });
55863     }
55864     function updateMarkers() {
55865       if (!_notesVisible || !_notesEnabled)
55866         return;
55867       var service = getService();
55868       var selectedID = context.selectedNoteID();
55869       var data = service ? service.notes(projection2) : [];
55870       var getTransform = svgPointTransform(projection2);
55871       var notes = drawLayer.selectAll(".note").data(data, function(d2) {
55872         return d2.status + d2.id;
55873       });
55874       notes.exit().remove();
55875       var notesEnter = notes.enter().append("g").attr("class", function(d2) {
55876         return "note note-" + d2.id + " " + d2.status;
55877       }).classed("new", function(d2) {
55878         return d2.id < 0;
55879       });
55880       notesEnter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
55881       notesEnter.append("path").call(markerPath, "shadow");
55882       notesEnter.append("use").attr("class", "note-fill").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").attr("xlink:href", "#iD-icon-note");
55883       notesEnter.selectAll(".icon-annotation").data(function(d2) {
55884         return [d2];
55885       }).enter().append("use").attr("class", "icon-annotation").attr("width", "10px").attr("height", "10px").attr("x", "-3px").attr("y", "-19px").attr("xlink:href", function(d2) {
55886         if (d2.id < 0)
55887           return "#iD-icon-plus";
55888         if (d2.status === "open")
55889           return "#iD-icon-close";
55890         return "#iD-icon-apply";
55891       });
55892       notes.merge(notesEnter).sort(sortY).classed("selected", function(d2) {
55893         var mode = context.mode();
55894         var isMoving = mode && mode.id === "drag-note";
55895         return !isMoving && d2.id === selectedID;
55896       }).attr("transform", getTransform);
55897       if (touchLayer.empty())
55898         return;
55899       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
55900       var targets = touchLayer.selectAll(".note").data(data, function(d2) {
55901         return d2.id;
55902       });
55903       targets.exit().remove();
55904       targets.enter().append("rect").attr("width", "20px").attr("height", "20px").attr("x", "-8px").attr("y", "-22px").merge(targets).sort(sortY).attr("class", function(d2) {
55905         var newClass = d2.id < 0 ? "new" : "";
55906         return "note target note-" + d2.id + " " + fillClass + newClass;
55907       }).attr("transform", getTransform);
55908       function sortY(a2, b2) {
55909         if (a2.id === selectedID)
55910           return 1;
55911         if (b2.id === selectedID)
55912           return -1;
55913         return b2.loc[1] - a2.loc[1];
55914       }
55915     }
55916     function drawNotes(selection2) {
55917       var service = getService();
55918       var surface = context.surface();
55919       if (surface && !surface.empty()) {
55920         touchLayer = surface.selectAll(".data-layer.touch .layer-touch.markers");
55921       }
55922       drawLayer = selection2.selectAll(".layer-notes").data(service ? [0] : []);
55923       drawLayer.exit().remove();
55924       drawLayer = drawLayer.enter().append("g").attr("class", "layer-notes").style("display", _notesEnabled ? "block" : "none").merge(drawLayer);
55925       if (_notesEnabled) {
55926         if (service && ~~context.map().zoom() >= minZoom4) {
55927           editOn();
55928           service.loadNotes(projection2);
55929           updateMarkers();
55930         } else {
55931           editOff();
55932         }
55933       }
55934     }
55935     drawNotes.enabled = function(val) {
55936       if (!arguments.length)
55937         return _notesEnabled;
55938       _notesEnabled = val;
55939       if (_notesEnabled) {
55940         layerOn();
55941       } else {
55942         layerOff();
55943         if (context.selectedNoteID()) {
55944           context.enter(modeBrowse(context));
55945         }
55946       }
55947       dispatch14.call("change");
55948       return this;
55949     };
55950     return drawNotes;
55951   }
55952
55953   // modules/svg/touch.js
55954   function svgTouch() {
55955     function drawTouch(selection2) {
55956       selection2.selectAll(".layer-touch").data(["areas", "lines", "points", "turns", "markers"]).enter().append("g").attr("class", function(d2) {
55957         return "layer-touch " + d2;
55958       });
55959     }
55960     return drawTouch;
55961   }
55962
55963   // modules/util/dimensions.js
55964   function refresh(selection2, node) {
55965     var cr = node.getBoundingClientRect();
55966     var prop = [cr.width, cr.height];
55967     selection2.property("__dimensions__", prop);
55968     return prop;
55969   }
55970   function utilGetDimensions(selection2, force) {
55971     if (!selection2 || selection2.empty()) {
55972       return [0, 0];
55973     }
55974     var node = selection2.node(), cached = selection2.property("__dimensions__");
55975     return !cached || force ? refresh(selection2, node) : cached;
55976   }
55977   function utilSetDimensions(selection2, dimensions) {
55978     if (!selection2 || selection2.empty()) {
55979       return selection2;
55980     }
55981     var node = selection2.node();
55982     if (dimensions === null) {
55983       refresh(selection2, node);
55984       return selection2;
55985     }
55986     return selection2.property("__dimensions__", [dimensions[0], dimensions[1]]).attr("width", dimensions[0]).attr("height", dimensions[1]);
55987   }
55988
55989   // modules/svg/layers.js
55990   function svgLayers(projection2, context) {
55991     var dispatch14 = dispatch_default("change");
55992     var svg2 = select_default2(null);
55993     var _layers = [
55994       { id: "osm", layer: svgOsm(projection2, context, dispatch14) },
55995       { id: "notes", layer: svgNotes(projection2, context, dispatch14) },
55996       { id: "data", layer: svgData(projection2, context, dispatch14) },
55997       { id: "keepRight", layer: svgKeepRight(projection2, context, dispatch14) },
55998       { id: "improveOSM", layer: svgImproveOSM(projection2, context, dispatch14) },
55999       { id: "osmose", layer: svgOsmose(projection2, context, dispatch14) },
56000       { id: "streetside", layer: svgStreetside(projection2, context, dispatch14) },
56001       { id: "mapillary", layer: svgMapillaryImages(projection2, context, dispatch14) },
56002       { id: "mapillary-position", layer: svgMapillaryPosition(projection2, context, dispatch14) },
56003       { id: "mapillary-map-features", layer: svgMapillaryMapFeatures(projection2, context, dispatch14) },
56004       { id: "mapillary-signs", layer: svgMapillarySigns(projection2, context, dispatch14) },
56005       { id: "kartaview", layer: svgKartaviewImages(projection2, context, dispatch14) },
56006       { id: "mapilio", layer: svgMapilioImages(projection2, context, dispatch14) },
56007       { id: "vegbilder", layer: svgVegbilder(projection2, context, dispatch14) },
56008       { id: "local-photos", layer: svgLocalPhotos(projection2, context, dispatch14) },
56009       { id: "debug", layer: svgDebug(projection2, context, dispatch14) },
56010       { id: "geolocate", layer: svgGeolocate(projection2, context, dispatch14) },
56011       { id: "touch", layer: svgTouch(projection2, context, dispatch14) }
56012     ];
56013     function drawLayers(selection2) {
56014       svg2 = selection2.selectAll(".surface").data([0]);
56015       svg2 = svg2.enter().append("svg").attr("class", "surface").merge(svg2);
56016       var defs = svg2.selectAll(".surface-defs").data([0]);
56017       defs.enter().append("defs").attr("class", "surface-defs");
56018       var groups = svg2.selectAll(".data-layer").data(_layers);
56019       groups.exit().remove();
56020       groups.enter().append("g").attr("class", function(d2) {
56021         return "data-layer " + d2.id;
56022       }).merge(groups).each(function(d2) {
56023         select_default2(this).call(d2.layer);
56024       });
56025     }
56026     drawLayers.all = function() {
56027       return _layers;
56028     };
56029     drawLayers.layer = function(id2) {
56030       var obj = _layers.find(function(o2) {
56031         return o2.id === id2;
56032       });
56033       return obj && obj.layer;
56034     };
56035     drawLayers.only = function(what) {
56036       var arr = [].concat(what);
56037       var all = _layers.map(function(layer) {
56038         return layer.id;
56039       });
56040       return drawLayers.remove(utilArrayDifference(all, arr));
56041     };
56042     drawLayers.remove = function(what) {
56043       var arr = [].concat(what);
56044       arr.forEach(function(id2) {
56045         _layers = _layers.filter(function(o2) {
56046           return o2.id !== id2;
56047         });
56048       });
56049       dispatch14.call("change");
56050       return this;
56051     };
56052     drawLayers.add = function(what) {
56053       var arr = [].concat(what);
56054       arr.forEach(function(obj) {
56055         if ("id" in obj && "layer" in obj) {
56056           _layers.push(obj);
56057         }
56058       });
56059       dispatch14.call("change");
56060       return this;
56061     };
56062     drawLayers.dimensions = function(val) {
56063       if (!arguments.length)
56064         return utilGetDimensions(svg2);
56065       utilSetDimensions(svg2, val);
56066       return this;
56067     };
56068     return utilRebind(drawLayers, dispatch14, "on");
56069   }
56070
56071   // modules/svg/lines.js
56072   var import_fast_deep_equal6 = __toESM(require_fast_deep_equal());
56073   function svgLines(projection2, context) {
56074     var detected = utilDetect();
56075     var highway_stack = {
56076       motorway: 0,
56077       motorway_link: 1,
56078       trunk: 2,
56079       trunk_link: 3,
56080       primary: 4,
56081       primary_link: 5,
56082       secondary: 6,
56083       tertiary: 7,
56084       unclassified: 8,
56085       residential: 9,
56086       service: 10,
56087       busway: 11,
56088       footway: 12
56089     };
56090     function drawTargets(selection2, graph, entities, filter2) {
56091       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
56092       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
56093       var getPath = svgPath(projection2).geojson;
56094       var activeID = context.activeID();
56095       var base = context.history().base();
56096       var data = { targets: [], nopes: [] };
56097       entities.forEach(function(way) {
56098         var features = svgSegmentWay(way, graph, activeID);
56099         data.targets.push.apply(data.targets, features.passive);
56100         data.nopes.push.apply(data.nopes, features.active);
56101       });
56102       var targetData = data.targets.filter(getPath);
56103       var targets = selection2.selectAll(".line.target-allowed").filter(function(d2) {
56104         return filter2(d2.properties.entity);
56105       }).data(targetData, function key(d2) {
56106         return d2.id;
56107       });
56108       targets.exit().remove();
56109       var segmentWasEdited = function(d2) {
56110         var wayID = d2.properties.entity.id;
56111         if (!base.entities[wayID] || !(0, import_fast_deep_equal6.default)(graph.entities[wayID].nodes, base.entities[wayID].nodes)) {
56112           return false;
56113         }
56114         return d2.properties.nodes.some(function(n3) {
56115           return !base.entities[n3.id] || !(0, import_fast_deep_equal6.default)(graph.entities[n3.id].loc, base.entities[n3.id].loc);
56116         });
56117       };
56118       targets.enter().append("path").merge(targets).attr("d", getPath).attr("class", function(d2) {
56119         return "way line target target-allowed " + targetClass + d2.id;
56120       }).classed("segment-edited", segmentWasEdited);
56121       var nopeData = data.nopes.filter(getPath);
56122       var nopes = selection2.selectAll(".line.target-nope").filter(function(d2) {
56123         return filter2(d2.properties.entity);
56124       }).data(nopeData, function key(d2) {
56125         return d2.id;
56126       });
56127       nopes.exit().remove();
56128       nopes.enter().append("path").merge(nopes).attr("d", getPath).attr("class", function(d2) {
56129         return "way line target target-nope " + nopeClass + d2.id;
56130       }).classed("segment-edited", segmentWasEdited);
56131     }
56132     function drawLines(selection2, graph, entities, filter2) {
56133       var base = context.history().base();
56134       function waystack(a2, b2) {
56135         var selected = context.selectedIDs();
56136         var scoreA = selected.indexOf(a2.id) !== -1 ? 20 : 0;
56137         var scoreB = selected.indexOf(b2.id) !== -1 ? 20 : 0;
56138         if (a2.tags.highway) {
56139           scoreA -= highway_stack[a2.tags.highway];
56140         }
56141         if (b2.tags.highway) {
56142           scoreB -= highway_stack[b2.tags.highway];
56143         }
56144         return scoreA - scoreB;
56145       }
56146       function drawLineGroup(selection3, klass, isSelected) {
56147         var mode = context.mode();
56148         var isDrawing = mode && /^draw/.test(mode.id);
56149         var selectedClass = !isDrawing && isSelected ? "selected " : "";
56150         var lines = selection3.selectAll("path").filter(filter2).data(getPathData(isSelected), osmEntity.key);
56151         lines.exit().remove();
56152         lines.enter().append("path").attr("class", function(d2) {
56153           var prefix = "way line";
56154           if (!d2.hasInterestingTags()) {
56155             var parentRelations = graph.parentRelations(d2);
56156             var parentMultipolygons = parentRelations.filter(function(relation) {
56157               return relation.isMultipolygon();
56158             });
56159             if (parentMultipolygons.length > 0 && // and only multipolygon relations
56160             parentRelations.length === parentMultipolygons.length) {
56161               prefix = "relation area";
56162             }
56163           }
56164           var oldMPClass = oldMultiPolygonOuters[d2.id] ? "old-multipolygon " : "";
56165           return prefix + " " + klass + " " + selectedClass + oldMPClass + d2.id;
56166         }).classed("added", function(d2) {
56167           return !base.entities[d2.id];
56168         }).classed("geometry-edited", function(d2) {
56169           return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal6.default)(graph.entities[d2.id].nodes, base.entities[d2.id].nodes);
56170         }).classed("retagged", function(d2) {
56171           return graph.entities[d2.id] && base.entities[d2.id] && !(0, import_fast_deep_equal6.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
56172         }).call(svgTagClasses()).merge(lines).sort(waystack).attr("d", getPath).call(svgTagClasses().tags(svgRelationMemberTags(graph)));
56173         return selection3;
56174       }
56175       function getPathData(isSelected) {
56176         return function() {
56177           var layer = this.parentNode.__data__;
56178           var data = pathdata[layer] || [];
56179           return data.filter(function(d2) {
56180             if (isSelected) {
56181               return context.selectedIDs().indexOf(d2.id) !== -1;
56182             } else {
56183               return context.selectedIDs().indexOf(d2.id) === -1;
56184             }
56185           });
56186         };
56187       }
56188       function addMarkers(layergroup, pathclass, groupclass, groupdata, marker) {
56189         var markergroup = layergroup.selectAll("g." + groupclass).data([pathclass]);
56190         markergroup = markergroup.enter().append("g").attr("class", groupclass).merge(markergroup);
56191         var markers = markergroup.selectAll("path").filter(filter2).data(
56192           function data() {
56193             return groupdata[this.parentNode.__data__] || [];
56194           },
56195           function key(d2) {
56196             return [d2.id, d2.index];
56197           }
56198         );
56199         markers.exit().remove();
56200         markers = markers.enter().append("path").attr("class", pathclass).merge(markers).attr("marker-mid", marker).attr("d", function(d2) {
56201           return d2.d;
56202         });
56203         if (detected.ie) {
56204           markers.each(function() {
56205             this.parentNode.insertBefore(this, this);
56206           });
56207         }
56208       }
56209       var getPath = svgPath(projection2, graph);
56210       var ways = [];
56211       var onewaydata = {};
56212       var sideddata = {};
56213       var oldMultiPolygonOuters = {};
56214       for (var i3 = 0; i3 < entities.length; i3++) {
56215         var entity = entities[i3];
56216         var outer = osmOldMultipolygonOuterMember(entity, graph);
56217         if (outer) {
56218           ways.push(entity.mergeTags(outer.tags));
56219           oldMultiPolygonOuters[outer.id] = true;
56220         } else if (entity.geometry(graph) === "line" || entity.geometry(graph) === "area" && entity.sidednessIdentifier && entity.sidednessIdentifier() === "coastline") {
56221           ways.push(entity);
56222         }
56223       }
56224       ways = ways.filter(getPath);
56225       var pathdata = utilArrayGroupBy(ways, function(way) {
56226         return way.layer();
56227       });
56228       Object.keys(pathdata).forEach(function(k2) {
56229         var v2 = pathdata[k2];
56230         var onewayArr = v2.filter(function(d2) {
56231           return d2.isOneWay();
56232         });
56233         var onewaySegments = svgMarkerSegments(
56234           projection2,
56235           graph,
56236           35,
56237           function shouldReverse(entity2) {
56238             return entity2.tags.oneway === "-1";
56239           },
56240           function bothDirections(entity2) {
56241             return entity2.tags.oneway === "reversible" || entity2.tags.oneway === "alternating";
56242           }
56243         );
56244         onewaydata[k2] = utilArrayFlatten(onewayArr.map(onewaySegments));
56245         var sidedArr = v2.filter(function(d2) {
56246           return d2.isSided();
56247         });
56248         var sidedSegments = svgMarkerSegments(
56249           projection2,
56250           graph,
56251           30,
56252           function shouldReverse() {
56253             return false;
56254           },
56255           function bothDirections() {
56256             return false;
56257           }
56258         );
56259         sideddata[k2] = utilArrayFlatten(sidedArr.map(sidedSegments));
56260       });
56261       var covered = selection2.selectAll(".layer-osm.covered");
56262       var uncovered = selection2.selectAll(".layer-osm.lines");
56263       var touchLayer = selection2.selectAll(".layer-touch.lines");
56264       [covered, uncovered].forEach(function(selection3) {
56265         var range3 = selection3 === covered ? range(-10, 0) : range(0, 11);
56266         var layergroup = selection3.selectAll("g.layergroup").data(range3);
56267         layergroup = layergroup.enter().append("g").attr("class", function(d2) {
56268           return "layergroup layer" + String(d2);
56269         }).merge(layergroup);
56270         layergroup.selectAll("g.linegroup").data(["shadow", "casing", "stroke", "shadow-highlighted", "casing-highlighted", "stroke-highlighted"]).enter().append("g").attr("class", function(d2) {
56271           return "linegroup line-" + d2;
56272         });
56273         layergroup.selectAll("g.line-shadow").call(drawLineGroup, "shadow", false);
56274         layergroup.selectAll("g.line-casing").call(drawLineGroup, "casing", false);
56275         layergroup.selectAll("g.line-stroke").call(drawLineGroup, "stroke", false);
56276         layergroup.selectAll("g.line-shadow-highlighted").call(drawLineGroup, "shadow", true);
56277         layergroup.selectAll("g.line-casing-highlighted").call(drawLineGroup, "casing", true);
56278         layergroup.selectAll("g.line-stroke-highlighted").call(drawLineGroup, "stroke", true);
56279         addMarkers(layergroup, "oneway", "onewaygroup", onewaydata, "url(#ideditor-oneway-marker)");
56280         addMarkers(
56281           layergroup,
56282           "sided",
56283           "sidedgroup",
56284           sideddata,
56285           function marker(d2) {
56286             var category = graph.entity(d2.id).sidednessIdentifier();
56287             return "url(#ideditor-sided-marker-" + category + ")";
56288           }
56289         );
56290       });
56291       touchLayer.call(drawTargets, graph, ways, filter2);
56292     }
56293     return drawLines;
56294   }
56295
56296   // modules/svg/midpoints.js
56297   function svgMidpoints(projection2, context) {
56298     var targetRadius = 8;
56299     function drawTargets(selection2, graph, entities, filter2) {
56300       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
56301       var getTransform = svgPointTransform(projection2).geojson;
56302       var data = entities.map(function(midpoint) {
56303         return {
56304           type: "Feature",
56305           id: midpoint.id,
56306           properties: {
56307             target: true,
56308             entity: midpoint
56309           },
56310           geometry: {
56311             type: "Point",
56312             coordinates: midpoint.loc
56313           }
56314         };
56315       });
56316       var targets = selection2.selectAll(".midpoint.target").filter(function(d2) {
56317         return filter2(d2.properties.entity);
56318       }).data(data, function key(d2) {
56319         return d2.id;
56320       });
56321       targets.exit().remove();
56322       targets.enter().append("circle").attr("r", targetRadius).merge(targets).attr("class", function(d2) {
56323         return "node midpoint target " + fillClass + d2.id;
56324       }).attr("transform", getTransform);
56325     }
56326     function drawMidpoints(selection2, graph, entities, filter2, extent) {
56327       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.midpoints");
56328       var touchLayer = selection2.selectAll(".layer-touch.points");
56329       var mode = context.mode();
56330       if (mode && mode.id !== "select" || !context.map().withinEditableZoom()) {
56331         drawLayer.selectAll(".midpoint").remove();
56332         touchLayer.selectAll(".midpoint.target").remove();
56333         return;
56334       }
56335       var poly = extent.polygon();
56336       var midpoints = {};
56337       for (var i3 = 0; i3 < entities.length; i3++) {
56338         var entity = entities[i3];
56339         if (entity.type !== "way")
56340           continue;
56341         if (!filter2(entity))
56342           continue;
56343         if (context.selectedIDs().indexOf(entity.id) < 0)
56344           continue;
56345         var nodes = graph.childNodes(entity);
56346         for (var j2 = 0; j2 < nodes.length - 1; j2++) {
56347           var a2 = nodes[j2];
56348           var b2 = nodes[j2 + 1];
56349           var id2 = [a2.id, b2.id].sort().join("-");
56350           if (midpoints[id2]) {
56351             midpoints[id2].parents.push(entity);
56352           } else if (geoVecLength(projection2(a2.loc), projection2(b2.loc)) > 40) {
56353             var point2 = geoVecInterp(a2.loc, b2.loc, 0.5);
56354             var loc = null;
56355             if (extent.intersects(point2)) {
56356               loc = point2;
56357             } else {
56358               for (var k2 = 0; k2 < 4; k2++) {
56359                 point2 = geoLineIntersection([a2.loc, b2.loc], [poly[k2], poly[k2 + 1]]);
56360                 if (point2 && geoVecLength(projection2(a2.loc), projection2(point2)) > 20 && geoVecLength(projection2(b2.loc), projection2(point2)) > 20) {
56361                   loc = point2;
56362                   break;
56363                 }
56364               }
56365             }
56366             if (loc) {
56367               midpoints[id2] = {
56368                 type: "midpoint",
56369                 id: id2,
56370                 loc,
56371                 edge: [a2.id, b2.id],
56372                 parents: [entity]
56373               };
56374             }
56375           }
56376         }
56377       }
56378       function midpointFilter(d2) {
56379         if (midpoints[d2.id])
56380           return true;
56381         for (var i4 = 0; i4 < d2.parents.length; i4++) {
56382           if (filter2(d2.parents[i4])) {
56383             return true;
56384           }
56385         }
56386         return false;
56387       }
56388       var groups = drawLayer.selectAll(".midpoint").filter(midpointFilter).data(Object.values(midpoints), function(d2) {
56389         return d2.id;
56390       });
56391       groups.exit().remove();
56392       var enter = groups.enter().insert("g", ":first-child").attr("class", "midpoint");
56393       enter.append("polygon").attr("points", "-6,8 10,0 -6,-8").attr("class", "shadow");
56394       enter.append("polygon").attr("points", "-3,4 5,0 -3,-4").attr("class", "fill");
56395       groups = groups.merge(enter).attr("transform", function(d2) {
56396         var translate = svgPointTransform(projection2);
56397         var a3 = graph.entity(d2.edge[0]);
56398         var b3 = graph.entity(d2.edge[1]);
56399         var angle2 = geoAngle(a3, b3, projection2) * (180 / Math.PI);
56400         return translate(d2) + " rotate(" + angle2 + ")";
56401       }).call(svgTagClasses().tags(
56402         function(d2) {
56403           return d2.parents[0].tags;
56404         }
56405       ));
56406       groups.select("polygon.shadow");
56407       groups.select("polygon.fill");
56408       touchLayer.call(drawTargets, graph, Object.values(midpoints), midpointFilter);
56409     }
56410     return drawMidpoints;
56411   }
56412
56413   // modules/svg/points.js
56414   var import_fast_deep_equal7 = __toESM(require_fast_deep_equal());
56415   function svgPoints(projection2, context) {
56416     function markerPath(selection2, klass) {
56417       selection2.attr("class", klass).attr("transform", "translate(-8, -23)").attr("d", "M 17,8 C 17,13 11,21 8.5,23.5 C 6,21 0,13 0,8 C 0,4 4,-0.5 8.5,-0.5 C 13,-0.5 17,4 17,8 z");
56418     }
56419     function sortY(a2, b2) {
56420       return b2.loc[1] - a2.loc[1];
56421     }
56422     function fastEntityKey(d2) {
56423       var mode = context.mode();
56424       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56425       return isMoving ? d2.id : osmEntity.key(d2);
56426     }
56427     function drawTargets(selection2, graph, entities, filter2) {
56428       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
56429       var getTransform = svgPointTransform(projection2).geojson;
56430       var activeID = context.activeID();
56431       var data = [];
56432       entities.forEach(function(node) {
56433         if (activeID === node.id)
56434           return;
56435         data.push({
56436           type: "Feature",
56437           id: node.id,
56438           properties: {
56439             target: true,
56440             entity: node
56441           },
56442           geometry: node.asGeoJSON()
56443         });
56444       });
56445       var targets = selection2.selectAll(".point.target").filter(function(d2) {
56446         return filter2(d2.properties.entity);
56447       }).data(data, function key(d2) {
56448         return d2.id;
56449       });
56450       targets.exit().remove();
56451       targets.enter().append("rect").attr("x", -10).attr("y", -26).attr("width", 20).attr("height", 30).merge(targets).attr("class", function(d2) {
56452         return "node point target " + fillClass + d2.id;
56453       }).attr("transform", getTransform);
56454     }
56455     function drawPoints(selection2, graph, entities, filter2) {
56456       var wireframe = context.surface().classed("fill-wireframe");
56457       var zoom = geoScaleToZoom(projection2.scale());
56458       var base = context.history().base();
56459       function renderAsPoint(entity) {
56460         return entity.geometry(graph) === "point" && !(zoom >= 18 && entity.directions(graph, projection2).length);
56461       }
56462       var points = wireframe ? [] : entities.filter(renderAsPoint);
56463       points.sort(sortY);
56464       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.points");
56465       var touchLayer = selection2.selectAll(".layer-touch.points");
56466       var groups = drawLayer.selectAll("g.point").filter(filter2).data(points, fastEntityKey);
56467       groups.exit().remove();
56468       var enter = groups.enter().append("g").attr("class", function(d2) {
56469         return "node point " + d2.id;
56470       }).order();
56471       enter.append("path").call(markerPath, "shadow");
56472       enter.append("ellipse").attr("cx", 0.5).attr("cy", 1).attr("rx", 6.5).attr("ry", 3).attr("class", "stroke");
56473       enter.append("path").call(markerPath, "stroke");
56474       enter.append("use").attr("transform", "translate(-5.5, -20)").attr("class", "icon").attr("width", "12px").attr("height", "12px");
56475       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("added", function(d2) {
56476         return !base.entities[d2.id];
56477       }).classed("moved", function(d2) {
56478         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
56479       }).classed("retagged", function(d2) {
56480         return base.entities[d2.id] && !(0, import_fast_deep_equal7.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
56481       }).call(svgTagClasses());
56482       groups.select(".shadow");
56483       groups.select(".stroke");
56484       groups.select(".icon").attr("xlink:href", function(entity) {
56485         var preset = _mainPresetIndex.match(entity, graph);
56486         var picon = preset && preset.icon;
56487         return picon ? "#" + picon : "";
56488       });
56489       touchLayer.call(drawTargets, graph, points, filter2);
56490     }
56491     return drawPoints;
56492   }
56493
56494   // modules/svg/turns.js
56495   function svgTurns(projection2, context) {
56496     function icon2(turn) {
56497       var u2 = turn.u ? "-u" : "";
56498       if (turn.no)
56499         return "#iD-turn-no" + u2;
56500       if (turn.only)
56501         return "#iD-turn-only" + u2;
56502       return "#iD-turn-yes" + u2;
56503     }
56504     function drawTurns(selection2, graph, turns) {
56505       function turnTransform(d2) {
56506         var pxRadius = 50;
56507         var toWay = graph.entity(d2.to.way);
56508         var toPoints = graph.childNodes(toWay).map(function(n3) {
56509           return n3.loc;
56510         }).map(projection2);
56511         var toLength = geoPathLength(toPoints);
56512         var mid = toLength / 2;
56513         var toNode = graph.entity(d2.to.node);
56514         var toVertex = graph.entity(d2.to.vertex);
56515         var a2 = geoAngle(toVertex, toNode, projection2);
56516         var o2 = projection2(toVertex.loc);
56517         var r2 = d2.u ? 0 : !toWay.__via ? pxRadius : Math.min(mid, pxRadius);
56518         return "translate(" + (r2 * Math.cos(a2) + o2[0]) + "," + (r2 * Math.sin(a2) + o2[1]) + ") rotate(" + a2 * 180 / Math.PI + ")";
56519       }
56520       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.turns");
56521       var touchLayer = selection2.selectAll(".layer-touch.turns");
56522       var groups = drawLayer.selectAll("g.turn").data(turns, function(d2) {
56523         return d2.key;
56524       });
56525       groups.exit().remove();
56526       var groupsEnter = groups.enter().append("g").attr("class", function(d2) {
56527         return "turn " + d2.key;
56528       });
56529       var turnsEnter = groupsEnter.filter(function(d2) {
56530         return !d2.u;
56531       });
56532       turnsEnter.append("rect").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
56533       turnsEnter.append("use").attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
56534       var uEnter = groupsEnter.filter(function(d2) {
56535         return d2.u;
56536       });
56537       uEnter.append("circle").attr("r", "16");
56538       uEnter.append("use").attr("transform", "translate(-16, -16)").attr("width", "32").attr("height", "32");
56539       groups = groups.merge(groupsEnter).attr("opacity", function(d2) {
56540         return d2.direct === false ? "0.7" : null;
56541       }).attr("transform", turnTransform);
56542       groups.select("use").attr("xlink:href", icon2);
56543       groups.select("rect");
56544       groups.select("circle");
56545       var fillClass = context.getDebug("target") ? "pink " : "nocolor ";
56546       groups = touchLayer.selectAll("g.turn").data(turns, function(d2) {
56547         return d2.key;
56548       });
56549       groups.exit().remove();
56550       groupsEnter = groups.enter().append("g").attr("class", function(d2) {
56551         return "turn " + d2.key;
56552       });
56553       turnsEnter = groupsEnter.filter(function(d2) {
56554         return !d2.u;
56555       });
56556       turnsEnter.append("rect").attr("class", "target " + fillClass).attr("transform", "translate(-22, -12)").attr("width", "44").attr("height", "24");
56557       uEnter = groupsEnter.filter(function(d2) {
56558         return d2.u;
56559       });
56560       uEnter.append("circle").attr("class", "target " + fillClass).attr("r", "16");
56561       groups = groups.merge(groupsEnter).attr("transform", turnTransform);
56562       groups.select("rect");
56563       groups.select("circle");
56564       return this;
56565     }
56566     return drawTurns;
56567   }
56568
56569   // modules/svg/vertices.js
56570   var import_fast_deep_equal8 = __toESM(require_fast_deep_equal());
56571   function svgVertices(projection2, context) {
56572     var radiuses = {
56573       //       z16-, z17,   z18+,  w/icon
56574       shadow: [6, 7.5, 7.5, 12],
56575       stroke: [2.5, 3.5, 3.5, 8],
56576       fill: [1, 1.5, 1.5, 1.5]
56577     };
56578     var _currHoverTarget;
56579     var _currPersistent = {};
56580     var _currHover = {};
56581     var _prevHover = {};
56582     var _currSelected = {};
56583     var _prevSelected = {};
56584     var _radii = {};
56585     function sortY(a2, b2) {
56586       return b2.loc[1] - a2.loc[1];
56587     }
56588     function fastEntityKey(d2) {
56589       var mode = context.mode();
56590       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56591       return isMoving ? d2.id : osmEntity.key(d2);
56592     }
56593     function draw(selection2, graph, vertices, sets2, filter2) {
56594       sets2 = sets2 || { selected: {}, important: {}, hovered: {} };
56595       var icons = {};
56596       var directions = {};
56597       var wireframe = context.surface().classed("fill-wireframe");
56598       var zoom = geoScaleToZoom(projection2.scale());
56599       var z2 = zoom < 17 ? 0 : zoom < 18 ? 1 : 2;
56600       var activeID = context.activeID();
56601       var base = context.history().base();
56602       function getIcon(d2) {
56603         var entity = graph.entity(d2.id);
56604         if (entity.id in icons)
56605           return icons[entity.id];
56606         icons[entity.id] = entity.hasInterestingTags() && _mainPresetIndex.match(entity, graph).icon;
56607         return icons[entity.id];
56608       }
56609       function getDirections(entity) {
56610         if (entity.id in directions)
56611           return directions[entity.id];
56612         var angles = entity.directions(graph, projection2);
56613         directions[entity.id] = angles.length ? angles : false;
56614         return angles;
56615       }
56616       function updateAttributes(selection3) {
56617         ["shadow", "stroke", "fill"].forEach(function(klass) {
56618           var rads = radiuses[klass];
56619           selection3.selectAll("." + klass).each(function(entity) {
56620             var i3 = z2 && getIcon(entity);
56621             var r2 = rads[i3 ? 3 : z2];
56622             if (entity.id !== activeID && entity.isEndpoint(graph) && !entity.isConnected(graph)) {
56623               r2 += 1.5;
56624             }
56625             if (klass === "shadow") {
56626               _radii[entity.id] = r2;
56627             }
56628             select_default2(this).attr("r", r2).attr("visibility", i3 && klass === "fill" ? "hidden" : null);
56629           });
56630         });
56631       }
56632       vertices.sort(sortY);
56633       var groups = selection2.selectAll("g.vertex").filter(filter2).data(vertices, fastEntityKey);
56634       groups.exit().remove();
56635       var enter = groups.enter().append("g").attr("class", function(d2) {
56636         return "node vertex " + d2.id;
56637       }).order();
56638       enter.append("circle").attr("class", "shadow");
56639       enter.append("circle").attr("class", "stroke");
56640       enter.filter(function(d2) {
56641         return d2.hasInterestingTags();
56642       }).append("circle").attr("class", "fill");
56643       groups = groups.merge(enter).attr("transform", svgPointTransform(projection2)).classed("sibling", function(d2) {
56644         return d2.id in sets2.selected;
56645       }).classed("shared", function(d2) {
56646         return graph.isShared(d2);
56647       }).classed("endpoint", function(d2) {
56648         return d2.isEndpoint(graph);
56649       }).classed("added", function(d2) {
56650         return !base.entities[d2.id];
56651       }).classed("moved", function(d2) {
56652         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].loc, base.entities[d2.id].loc);
56653       }).classed("retagged", function(d2) {
56654         return base.entities[d2.id] && !(0, import_fast_deep_equal8.default)(graph.entities[d2.id].tags, base.entities[d2.id].tags);
56655       }).call(updateAttributes);
56656       var iconUse = groups.selectAll(".icon").data(function data(d2) {
56657         return zoom >= 17 && getIcon(d2) ? [d2] : [];
56658       }, fastEntityKey);
56659       iconUse.exit().remove();
56660       iconUse.enter().append("use").attr("class", "icon").attr("width", "12px").attr("height", "12px").attr("transform", "translate(-6, -6)").attr("xlink:href", function(d2) {
56661         var picon = getIcon(d2);
56662         return picon ? "#" + picon : "";
56663       });
56664       var dgroups = groups.selectAll(".viewfieldgroup").data(function data(d2) {
56665         return zoom >= 18 && getDirections(d2) ? [d2] : [];
56666       }, fastEntityKey);
56667       dgroups.exit().remove();
56668       dgroups = dgroups.enter().insert("g", ".shadow").attr("class", "viewfieldgroup").merge(dgroups);
56669       var viewfields = dgroups.selectAll(".viewfield").data(getDirections, function key(d2) {
56670         return osmEntity.key(d2);
56671       });
56672       viewfields.exit().remove();
56673       viewfields.enter().append("path").attr("class", "viewfield").attr("d", "M0,0H0").merge(viewfields).attr("marker-start", "url(#ideditor-viewfield-marker" + (wireframe ? "-wireframe" : "") + ")").attr("transform", function(d2) {
56674         return "rotate(" + d2 + ")";
56675       });
56676     }
56677     function drawTargets(selection2, graph, entities, filter2) {
56678       var targetClass = context.getDebug("target") ? "pink " : "nocolor ";
56679       var nopeClass = context.getDebug("target") ? "red " : "nocolor ";
56680       var getTransform = svgPointTransform(projection2).geojson;
56681       var activeID = context.activeID();
56682       var data = { targets: [], nopes: [] };
56683       entities.forEach(function(node) {
56684         if (activeID === node.id)
56685           return;
56686         var vertexType = svgPassiveVertex(node, graph, activeID);
56687         if (vertexType !== 0) {
56688           data.targets.push({
56689             type: "Feature",
56690             id: node.id,
56691             properties: {
56692               target: true,
56693               entity: node
56694             },
56695             geometry: node.asGeoJSON()
56696           });
56697         } else {
56698           data.nopes.push({
56699             type: "Feature",
56700             id: node.id + "-nope",
56701             properties: {
56702               nope: true,
56703               target: true,
56704               entity: node
56705             },
56706             geometry: node.asGeoJSON()
56707           });
56708         }
56709       });
56710       var targets = selection2.selectAll(".vertex.target-allowed").filter(function(d2) {
56711         return filter2(d2.properties.entity);
56712       }).data(data.targets, function key(d2) {
56713         return d2.id;
56714       });
56715       targets.exit().remove();
56716       targets.enter().append("circle").attr("r", function(d2) {
56717         return _radii[d2.id] || radiuses.shadow[3];
56718       }).merge(targets).attr("class", function(d2) {
56719         return "node vertex target target-allowed " + targetClass + d2.id;
56720       }).attr("transform", getTransform);
56721       var nopes = selection2.selectAll(".vertex.target-nope").filter(function(d2) {
56722         return filter2(d2.properties.entity);
56723       }).data(data.nopes, function key(d2) {
56724         return d2.id;
56725       });
56726       nopes.exit().remove();
56727       nopes.enter().append("circle").attr("r", function(d2) {
56728         return _radii[d2.properties.entity.id] || radiuses.shadow[3];
56729       }).merge(nopes).attr("class", function(d2) {
56730         return "node vertex target target-nope " + nopeClass + d2.id;
56731       }).attr("transform", getTransform);
56732     }
56733     function renderAsVertex(entity, graph, wireframe, zoom) {
56734       var geometry = entity.geometry(graph);
56735       return geometry === "vertex" || geometry === "point" && (wireframe || zoom >= 18 && entity.directions(graph, projection2).length);
56736     }
56737     function isEditedNode(node, base, head) {
56738       var baseNode = base.entities[node.id];
56739       var headNode = head.entities[node.id];
56740       return !headNode || !baseNode || !(0, import_fast_deep_equal8.default)(headNode.tags, baseNode.tags) || !(0, import_fast_deep_equal8.default)(headNode.loc, baseNode.loc);
56741     }
56742     function getSiblingAndChildVertices(ids, graph, wireframe, zoom) {
56743       var results = {};
56744       var seenIds = {};
56745       function addChildVertices(entity) {
56746         if (seenIds[entity.id])
56747           return;
56748         seenIds[entity.id] = true;
56749         var geometry = entity.geometry(graph);
56750         if (!context.features().isHiddenFeature(entity, graph, geometry)) {
56751           var i3;
56752           if (entity.type === "way") {
56753             for (i3 = 0; i3 < entity.nodes.length; i3++) {
56754               var child = graph.hasEntity(entity.nodes[i3]);
56755               if (child) {
56756                 addChildVertices(child);
56757               }
56758             }
56759           } else if (entity.type === "relation") {
56760             for (i3 = 0; i3 < entity.members.length; i3++) {
56761               var member = graph.hasEntity(entity.members[i3].id);
56762               if (member) {
56763                 addChildVertices(member);
56764               }
56765             }
56766           } else if (renderAsVertex(entity, graph, wireframe, zoom)) {
56767             results[entity.id] = entity;
56768           }
56769         }
56770       }
56771       ids.forEach(function(id2) {
56772         var entity = graph.hasEntity(id2);
56773         if (!entity)
56774           return;
56775         if (entity.type === "node") {
56776           if (renderAsVertex(entity, graph, wireframe, zoom)) {
56777             results[entity.id] = entity;
56778             graph.parentWays(entity).forEach(function(entity2) {
56779               addChildVertices(entity2);
56780             });
56781           }
56782         } else {
56783           addChildVertices(entity);
56784         }
56785       });
56786       return results;
56787     }
56788     function drawVertices(selection2, graph, entities, filter2, extent, fullRedraw) {
56789       var wireframe = context.surface().classed("fill-wireframe");
56790       var visualDiff = context.surface().classed("highlight-edited");
56791       var zoom = geoScaleToZoom(projection2.scale());
56792       var mode = context.mode();
56793       var isMoving = mode && /^(add|draw|drag|move|rotate)/.test(mode.id);
56794       var base = context.history().base();
56795       var drawLayer = selection2.selectAll(".layer-osm.points .points-group.vertices");
56796       var touchLayer = selection2.selectAll(".layer-touch.points");
56797       if (fullRedraw) {
56798         _currPersistent = {};
56799         _radii = {};
56800       }
56801       for (var i3 = 0; i3 < entities.length; i3++) {
56802         var entity = entities[i3];
56803         var geometry = entity.geometry(graph);
56804         var keep = false;
56805         if (geometry === "point" && renderAsVertex(entity, graph, wireframe, zoom)) {
56806           _currPersistent[entity.id] = entity;
56807           keep = true;
56808         } else if (geometry === "vertex" && (entity.hasInterestingTags() || entity.isEndpoint(graph) || entity.isConnected(graph) || visualDiff && isEditedNode(entity, base, graph))) {
56809           _currPersistent[entity.id] = entity;
56810           keep = true;
56811         }
56812         if (!keep && !fullRedraw) {
56813           delete _currPersistent[entity.id];
56814         }
56815       }
56816       var sets2 = {
56817         persistent: _currPersistent,
56818         // persistent = important vertices (render always)
56819         selected: _currSelected,
56820         // selected + siblings of selected (render always)
56821         hovered: _currHover
56822         // hovered + siblings of hovered (render only in draw modes)
56823       };
56824       var all = Object.assign({}, isMoving ? _currHover : {}, _currSelected, _currPersistent);
56825       var filterRendered = function(d2) {
56826         return d2.id in _currPersistent || d2.id in _currSelected || d2.id in _currHover || filter2(d2);
56827       };
56828       drawLayer.call(draw, graph, currentVisible(all), sets2, filterRendered);
56829       var filterTouch = function(d2) {
56830         return isMoving ? true : filterRendered(d2);
56831       };
56832       touchLayer.call(drawTargets, graph, currentVisible(all), filterTouch);
56833       function currentVisible(which) {
56834         return Object.keys(which).map(graph.hasEntity, graph).filter(function(entity2) {
56835           return entity2 && entity2.intersects(extent, graph);
56836         });
56837       }
56838     }
56839     drawVertices.drawSelected = function(selection2, graph, extent) {
56840       var wireframe = context.surface().classed("fill-wireframe");
56841       var zoom = geoScaleToZoom(projection2.scale());
56842       _prevSelected = _currSelected || {};
56843       if (context.map().isInWideSelection()) {
56844         _currSelected = {};
56845         context.selectedIDs().forEach(function(id2) {
56846           var entity = graph.hasEntity(id2);
56847           if (!entity)
56848             return;
56849           if (entity.type === "node") {
56850             if (renderAsVertex(entity, graph, wireframe, zoom)) {
56851               _currSelected[entity.id] = entity;
56852             }
56853           }
56854         });
56855       } else {
56856         _currSelected = getSiblingAndChildVertices(context.selectedIDs(), graph, wireframe, zoom);
56857       }
56858       var filter2 = function(d2) {
56859         return d2.id in _prevSelected;
56860       };
56861       drawVertices(selection2, graph, Object.values(_prevSelected), filter2, extent, false);
56862     };
56863     drawVertices.drawHover = function(selection2, graph, target, extent) {
56864       if (target === _currHoverTarget)
56865         return;
56866       var wireframe = context.surface().classed("fill-wireframe");
56867       var zoom = geoScaleToZoom(projection2.scale());
56868       _prevHover = _currHover || {};
56869       _currHoverTarget = target;
56870       var entity = target && target.properties && target.properties.entity;
56871       if (entity) {
56872         _currHover = getSiblingAndChildVertices([entity.id], graph, wireframe, zoom);
56873       } else {
56874         _currHover = {};
56875       }
56876       var filter2 = function(d2) {
56877         return d2.id in _prevHover;
56878       };
56879       drawVertices(selection2, graph, Object.values(_prevHover), filter2, extent, false);
56880     };
56881     return drawVertices;
56882   }
56883
56884   // modules/util/bind_once.js
56885   function utilBindOnce(target, type2, listener, capture) {
56886     var typeOnce = type2 + ".once";
56887     function one2() {
56888       target.on(typeOnce, null);
56889       listener.apply(this, arguments);
56890     }
56891     target.on(typeOnce, one2, capture);
56892     return this;
56893   }
56894
56895   // modules/util/zoom_pan.js
56896   function defaultFilter3(d3_event) {
56897     return !d3_event.ctrlKey && !d3_event.button;
56898   }
56899   function defaultExtent2() {
56900     var e3 = this;
56901     if (e3 instanceof SVGElement) {
56902       e3 = e3.ownerSVGElement || e3;
56903       if (e3.hasAttribute("viewBox")) {
56904         e3 = e3.viewBox.baseVal;
56905         return [[e3.x, e3.y], [e3.x + e3.width, e3.y + e3.height]];
56906       }
56907       return [[0, 0], [e3.width.baseVal.value, e3.height.baseVal.value]];
56908     }
56909     return [[0, 0], [e3.clientWidth, e3.clientHeight]];
56910   }
56911   function defaultWheelDelta2(d3_event) {
56912     return -d3_event.deltaY * (d3_event.deltaMode === 1 ? 0.05 : d3_event.deltaMode ? 1 : 2e-3);
56913   }
56914   function defaultConstrain2(transform2, extent, translateExtent) {
56915     var dx0 = transform2.invertX(extent[0][0]) - translateExtent[0][0], dx1 = transform2.invertX(extent[1][0]) - translateExtent[1][0], dy0 = transform2.invertY(extent[0][1]) - translateExtent[0][1], dy1 = transform2.invertY(extent[1][1]) - translateExtent[1][1];
56916     return transform2.translate(
56917       dx1 > dx0 ? (dx0 + dx1) / 2 : Math.min(0, dx0) || Math.max(0, dx1),
56918       dy1 > dy0 ? (dy0 + dy1) / 2 : Math.min(0, dy0) || Math.max(0, dy1)
56919     );
56920   }
56921   function utilZoomPan() {
56922     var filter2 = defaultFilter3, extent = defaultExtent2, constrain = defaultConstrain2, wheelDelta = defaultWheelDelta2, scaleExtent = [0, Infinity], translateExtent = [[-Infinity, -Infinity], [Infinity, Infinity]], interpolate = zoom_default, dispatch14 = dispatch_default("start", "zoom", "end"), _wheelDelay = 150, _transform = identity2, _activeGesture;
56923     function zoom(selection2) {
56924       selection2.on("pointerdown.zoom", pointerdown).on("wheel.zoom", wheeled).style("touch-action", "none").style("-webkit-tap-highlight-color", "rgba(0,0,0,0)");
56925       select_default2(window).on("pointermove.zoompan", pointermove).on("pointerup.zoompan pointercancel.zoompan", pointerup);
56926     }
56927     zoom.transform = function(collection, transform2, point2) {
56928       var selection2 = collection.selection ? collection.selection() : collection;
56929       if (collection !== selection2) {
56930         schedule(collection, transform2, point2);
56931       } else {
56932         selection2.interrupt().each(function() {
56933           gesture(this, arguments).start(null).zoom(null, null, typeof transform2 === "function" ? transform2.apply(this, arguments) : transform2).end(null);
56934         });
56935       }
56936     };
56937     zoom.scaleBy = function(selection2, k2, p2) {
56938       zoom.scaleTo(selection2, function() {
56939         var k0 = _transform.k, k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
56940         return k0 * k1;
56941       }, p2);
56942     };
56943     zoom.scaleTo = function(selection2, k2, p2) {
56944       zoom.transform(selection2, function() {
56945         var e3 = extent.apply(this, arguments), t0 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2, p1 = t0.invert(p02), k1 = typeof k2 === "function" ? k2.apply(this, arguments) : k2;
56946         return constrain(translate(scale(t0, k1), p02, p1), e3, translateExtent);
56947       }, p2);
56948     };
56949     zoom.translateBy = function(selection2, x2, y2) {
56950       zoom.transform(selection2, function() {
56951         return constrain(_transform.translate(
56952           typeof x2 === "function" ? x2.apply(this, arguments) : x2,
56953           typeof y2 === "function" ? y2.apply(this, arguments) : y2
56954         ), extent.apply(this, arguments), translateExtent);
56955       });
56956     };
56957     zoom.translateTo = function(selection2, x2, y2, p2) {
56958       zoom.transform(selection2, function() {
56959         var e3 = extent.apply(this, arguments), t2 = _transform, p02 = !p2 ? centroid(e3) : typeof p2 === "function" ? p2.apply(this, arguments) : p2;
56960         return constrain(identity2.translate(p02[0], p02[1]).scale(t2.k).translate(
56961           typeof x2 === "function" ? -x2.apply(this, arguments) : -x2,
56962           typeof y2 === "function" ? -y2.apply(this, arguments) : -y2
56963         ), e3, translateExtent);
56964       }, p2);
56965     };
56966     function scale(transform2, k2) {
56967       k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], k2));
56968       return k2 === transform2.k ? transform2 : new Transform(k2, transform2.x, transform2.y);
56969     }
56970     function translate(transform2, p02, p1) {
56971       var x2 = p02[0] - p1[0] * transform2.k, y2 = p02[1] - p1[1] * transform2.k;
56972       return x2 === transform2.x && y2 === transform2.y ? transform2 : new Transform(transform2.k, x2, y2);
56973     }
56974     function centroid(extent2) {
56975       return [(+extent2[0][0] + +extent2[1][0]) / 2, (+extent2[0][1] + +extent2[1][1]) / 2];
56976     }
56977     function schedule(transition2, transform2, point2) {
56978       transition2.on("start.zoom", function() {
56979         gesture(this, arguments).start(null);
56980       }).on("interrupt.zoom end.zoom", function() {
56981         gesture(this, arguments).end(null);
56982       }).tween("zoom", function() {
56983         var that = this, args = arguments, g3 = gesture(that, args), e3 = extent.apply(that, args), p2 = !point2 ? centroid(e3) : typeof point2 === "function" ? point2.apply(that, args) : point2, w2 = Math.max(e3[1][0] - e3[0][0], e3[1][1] - e3[0][1]), a2 = _transform, b2 = typeof transform2 === "function" ? transform2.apply(that, args) : transform2, i3 = interpolate(a2.invert(p2).concat(w2 / a2.k), b2.invert(p2).concat(w2 / b2.k));
56984         return function(t2) {
56985           if (t2 === 1) {
56986             t2 = b2;
56987           } else {
56988             var l2 = i3(t2);
56989             var k2 = w2 / l2[2];
56990             t2 = new Transform(k2, p2[0] - l2[0] * k2, p2[1] - l2[1] * k2);
56991           }
56992           g3.zoom(null, null, t2);
56993         };
56994       });
56995     }
56996     function gesture(that, args, clean2) {
56997       return !clean2 && _activeGesture || new Gesture(that, args);
56998     }
56999     function Gesture(that, args) {
57000       this.that = that;
57001       this.args = args;
57002       this.active = 0;
57003       this.extent = extent.apply(that, args);
57004     }
57005     Gesture.prototype = {
57006       start: function(d3_event) {
57007         if (++this.active === 1) {
57008           _activeGesture = this;
57009           dispatch14.call("start", this, d3_event);
57010         }
57011         return this;
57012       },
57013       zoom: function(d3_event, key, transform2) {
57014         if (this.mouse && key !== "mouse")
57015           this.mouse[1] = transform2.invert(this.mouse[0]);
57016         if (this.pointer0 && key !== "touch")
57017           this.pointer0[1] = transform2.invert(this.pointer0[0]);
57018         if (this.pointer1 && key !== "touch")
57019           this.pointer1[1] = transform2.invert(this.pointer1[0]);
57020         _transform = transform2;
57021         dispatch14.call("zoom", this, d3_event, key, transform2);
57022         return this;
57023       },
57024       end: function(d3_event) {
57025         if (--this.active === 0) {
57026           _activeGesture = null;
57027           dispatch14.call("end", this, d3_event);
57028         }
57029         return this;
57030       }
57031     };
57032     function wheeled(d3_event) {
57033       if (!filter2.apply(this, arguments))
57034         return;
57035       var g3 = gesture(this, arguments), t2 = _transform, k2 = Math.max(scaleExtent[0], Math.min(scaleExtent[1], t2.k * Math.pow(2, wheelDelta.apply(this, arguments)))), p2 = utilFastMouse(this)(d3_event);
57036       if (g3.wheel) {
57037         if (g3.mouse[0][0] !== p2[0] || g3.mouse[0][1] !== p2[1]) {
57038           g3.mouse[1] = t2.invert(g3.mouse[0] = p2);
57039         }
57040         clearTimeout(g3.wheel);
57041       } else {
57042         g3.mouse = [p2, t2.invert(p2)];
57043         interrupt_default(this);
57044         g3.start(d3_event);
57045       }
57046       d3_event.preventDefault();
57047       d3_event.stopImmediatePropagation();
57048       g3.wheel = setTimeout(wheelidled, _wheelDelay);
57049       g3.zoom(d3_event, "mouse", constrain(translate(scale(t2, k2), g3.mouse[0], g3.mouse[1]), g3.extent, translateExtent));
57050       function wheelidled() {
57051         g3.wheel = null;
57052         g3.end(d3_event);
57053       }
57054     }
57055     var _downPointerIDs = /* @__PURE__ */ new Set();
57056     var _pointerLocGetter;
57057     function pointerdown(d3_event) {
57058       _downPointerIDs.add(d3_event.pointerId);
57059       if (!filter2.apply(this, arguments))
57060         return;
57061       var g3 = gesture(this, arguments, _downPointerIDs.size === 1);
57062       var started;
57063       d3_event.stopImmediatePropagation();
57064       _pointerLocGetter = utilFastMouse(this);
57065       var loc = _pointerLocGetter(d3_event);
57066       var p2 = [loc, _transform.invert(loc), d3_event.pointerId];
57067       if (!g3.pointer0) {
57068         g3.pointer0 = p2;
57069         started = true;
57070       } else if (!g3.pointer1 && g3.pointer0[2] !== p2[2]) {
57071         g3.pointer1 = p2;
57072       }
57073       if (started) {
57074         interrupt_default(this);
57075         g3.start(d3_event);
57076       }
57077     }
57078     function pointermove(d3_event) {
57079       if (!_downPointerIDs.has(d3_event.pointerId))
57080         return;
57081       if (!_activeGesture || !_pointerLocGetter)
57082         return;
57083       var g3 = gesture(this, arguments);
57084       var isPointer0 = g3.pointer0 && g3.pointer0[2] === d3_event.pointerId;
57085       var isPointer1 = !isPointer0 && g3.pointer1 && g3.pointer1[2] === d3_event.pointerId;
57086       if ((isPointer0 || isPointer1) && "buttons" in d3_event && !d3_event.buttons) {
57087         if (g3.pointer0)
57088           _downPointerIDs.delete(g3.pointer0[2]);
57089         if (g3.pointer1)
57090           _downPointerIDs.delete(g3.pointer1[2]);
57091         g3.end(d3_event);
57092         return;
57093       }
57094       d3_event.preventDefault();
57095       d3_event.stopImmediatePropagation();
57096       var loc = _pointerLocGetter(d3_event);
57097       var t2, p2, l2;
57098       if (isPointer0)
57099         g3.pointer0[0] = loc;
57100       else if (isPointer1)
57101         g3.pointer1[0] = loc;
57102       t2 = _transform;
57103       if (g3.pointer1) {
57104         var p02 = g3.pointer0[0], l0 = g3.pointer0[1], p1 = g3.pointer1[0], l1 = g3.pointer1[1], dp = (dp = p1[0] - p02[0]) * dp + (dp = p1[1] - p02[1]) * dp, dl = (dl = l1[0] - l0[0]) * dl + (dl = l1[1] - l0[1]) * dl;
57105         t2 = scale(t2, Math.sqrt(dp / dl));
57106         p2 = [(p02[0] + p1[0]) / 2, (p02[1] + p1[1]) / 2];
57107         l2 = [(l0[0] + l1[0]) / 2, (l0[1] + l1[1]) / 2];
57108       } else if (g3.pointer0) {
57109         p2 = g3.pointer0[0];
57110         l2 = g3.pointer0[1];
57111       } else {
57112         return;
57113       }
57114       g3.zoom(d3_event, "touch", constrain(translate(t2, p2, l2), g3.extent, translateExtent));
57115     }
57116     function pointerup(d3_event) {
57117       if (!_downPointerIDs.has(d3_event.pointerId))
57118         return;
57119       _downPointerIDs.delete(d3_event.pointerId);
57120       if (!_activeGesture)
57121         return;
57122       var g3 = gesture(this, arguments);
57123       d3_event.stopImmediatePropagation();
57124       if (g3.pointer0 && g3.pointer0[2] === d3_event.pointerId)
57125         delete g3.pointer0;
57126       else if (g3.pointer1 && g3.pointer1[2] === d3_event.pointerId)
57127         delete g3.pointer1;
57128       if (g3.pointer1 && !g3.pointer0) {
57129         g3.pointer0 = g3.pointer1;
57130         delete g3.pointer1;
57131       }
57132       if (g3.pointer0) {
57133         g3.pointer0[1] = _transform.invert(g3.pointer0[0]);
57134       } else {
57135         g3.end(d3_event);
57136       }
57137     }
57138     zoom.wheelDelta = function(_2) {
57139       return arguments.length ? (wheelDelta = utilFunctor(+_2), zoom) : wheelDelta;
57140     };
57141     zoom.filter = function(_2) {
57142       return arguments.length ? (filter2 = utilFunctor(!!_2), zoom) : filter2;
57143     };
57144     zoom.extent = function(_2) {
57145       return arguments.length ? (extent = utilFunctor([[+_2[0][0], +_2[0][1]], [+_2[1][0], +_2[1][1]]]), zoom) : extent;
57146     };
57147     zoom.scaleExtent = function(_2) {
57148       return arguments.length ? (scaleExtent[0] = +_2[0], scaleExtent[1] = +_2[1], zoom) : [scaleExtent[0], scaleExtent[1]];
57149     };
57150     zoom.translateExtent = function(_2) {
57151       return arguments.length ? (translateExtent[0][0] = +_2[0][0], translateExtent[1][0] = +_2[1][0], translateExtent[0][1] = +_2[0][1], translateExtent[1][1] = +_2[1][1], zoom) : [[translateExtent[0][0], translateExtent[0][1]], [translateExtent[1][0], translateExtent[1][1]]];
57152     };
57153     zoom.constrain = function(_2) {
57154       return arguments.length ? (constrain = _2, zoom) : constrain;
57155     };
57156     zoom.interpolate = function(_2) {
57157       return arguments.length ? (interpolate = _2, zoom) : interpolate;
57158     };
57159     zoom._transform = function(_2) {
57160       return arguments.length ? (_transform = _2, zoom) : _transform;
57161     };
57162     return utilRebind(zoom, dispatch14, "on");
57163   }
57164
57165   // modules/util/double_up.js
57166   function utilDoubleUp() {
57167     var dispatch14 = dispatch_default("doubleUp");
57168     var _maxTimespan = 500;
57169     var _maxDistance = 20;
57170     var _pointer;
57171     function pointerIsValidFor(loc) {
57172       return (/* @__PURE__ */ new Date()).getTime() - _pointer.startTime <= _maxTimespan && // all pointer events must occur within a small distance of the first pointerdown
57173       geoVecLength(_pointer.startLoc, loc) <= _maxDistance;
57174     }
57175     function pointerdown(d3_event) {
57176       if (d3_event.ctrlKey || d3_event.button === 2)
57177         return;
57178       var loc = [d3_event.clientX, d3_event.clientY];
57179       if (_pointer && !pointerIsValidFor(loc)) {
57180         _pointer = void 0;
57181       }
57182       if (!_pointer) {
57183         _pointer = {
57184           startLoc: loc,
57185           startTime: (/* @__PURE__ */ new Date()).getTime(),
57186           upCount: 0,
57187           pointerId: d3_event.pointerId
57188         };
57189       } else {
57190         _pointer.pointerId = d3_event.pointerId;
57191       }
57192     }
57193     function pointerup(d3_event) {
57194       if (d3_event.ctrlKey || d3_event.button === 2)
57195         return;
57196       if (!_pointer || _pointer.pointerId !== d3_event.pointerId)
57197         return;
57198       _pointer.upCount += 1;
57199       if (_pointer.upCount === 2) {
57200         var loc = [d3_event.clientX, d3_event.clientY];
57201         if (pointerIsValidFor(loc)) {
57202           var locInThis = utilFastMouse(this)(d3_event);
57203           dispatch14.call("doubleUp", this, d3_event, locInThis);
57204         }
57205         _pointer = void 0;
57206       }
57207     }
57208     function doubleUp(selection2) {
57209       if ("PointerEvent" in window) {
57210         selection2.on("pointerdown.doubleUp", pointerdown).on("pointerup.doubleUp", pointerup);
57211       } else {
57212         selection2.on("dblclick.doubleUp", function(d3_event) {
57213           dispatch14.call("doubleUp", this, d3_event, utilFastMouse(this)(d3_event));
57214         });
57215       }
57216     }
57217     doubleUp.off = function(selection2) {
57218       selection2.on("pointerdown.doubleUp", null).on("pointerup.doubleUp", null).on("dblclick.doubleUp", null);
57219     };
57220     return utilRebind(doubleUp, dispatch14, "on");
57221   }
57222
57223   // modules/renderer/map.js
57224   var TILESIZE = 256;
57225   var minZoom2 = 2;
57226   var maxZoom = 24;
57227   var kMin = geoZoomToScale(minZoom2, TILESIZE);
57228   var kMax = geoZoomToScale(maxZoom, TILESIZE);
57229   function clamp2(num, min3, max3) {
57230     return Math.max(min3, Math.min(num, max3));
57231   }
57232   function rendererMap(context) {
57233     var dispatch14 = dispatch_default(
57234       "move",
57235       "drawn",
57236       "crossEditableZoom",
57237       "hitMinZoom",
57238       "changeHighlighting",
57239       "changeAreaFill"
57240     );
57241     var projection2 = context.projection;
57242     var curtainProjection = context.curtainProjection;
57243     var drawLayers;
57244     var drawPoints;
57245     var drawVertices;
57246     var drawLines;
57247     var drawAreas;
57248     var drawMidpoints;
57249     var drawLabels;
57250     var _selection = select_default2(null);
57251     var supersurface = select_default2(null);
57252     var wrapper = select_default2(null);
57253     var surface = select_default2(null);
57254     var _dimensions = [1, 1];
57255     var _dblClickZoomEnabled = true;
57256     var _redrawEnabled = true;
57257     var _gestureTransformStart;
57258     var _transformStart = projection2.transform();
57259     var _transformLast;
57260     var _isTransformed = false;
57261     var _minzoom = 0;
57262     var _getMouseCoords;
57263     var _lastPointerEvent;
57264     var _lastWithinEditableZoom;
57265     var _pointerDown = false;
57266     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
57267     var _zoomerPannerFunction = "PointerEvent" in window ? utilZoomPan : zoom_default2;
57268     var _zoomerPanner = _zoomerPannerFunction().scaleExtent([kMin, kMax]).interpolate(value_default).filter(zoomEventFilter).on("zoom.map", zoomPan2).on("start.map", function(d3_event) {
57269       _pointerDown = d3_event && (d3_event.type === "pointerdown" || d3_event.sourceEvent && d3_event.sourceEvent.type === "pointerdown");
57270     }).on("end.map", function() {
57271       _pointerDown = false;
57272     });
57273     var _doubleUpHandler = utilDoubleUp();
57274     var scheduleRedraw = throttle_default(redraw, 750);
57275     function cancelPendingRedraw() {
57276       scheduleRedraw.cancel();
57277     }
57278     function map2(selection2) {
57279       _selection = selection2;
57280       context.on("change.map", immediateRedraw);
57281       var osm = context.connection();
57282       if (osm) {
57283         osm.on("change.map", immediateRedraw);
57284       }
57285       function didUndoOrRedo(targetTransform) {
57286         var mode = context.mode().id;
57287         if (mode !== "browse" && mode !== "select")
57288           return;
57289         if (targetTransform) {
57290           map2.transformEase(targetTransform);
57291         }
57292       }
57293       context.history().on("merge.map", function() {
57294         scheduleRedraw();
57295       }).on("change.map", immediateRedraw).on("undone.map", function(stack, fromStack) {
57296         didUndoOrRedo(fromStack.transform);
57297       }).on("redone.map", function(stack) {
57298         didUndoOrRedo(stack.transform);
57299       });
57300       context.background().on("change.map", immediateRedraw);
57301       context.features().on("redraw.map", immediateRedraw);
57302       drawLayers.on("change.map", function() {
57303         context.background().updateImagery();
57304         immediateRedraw();
57305       });
57306       selection2.on("wheel.map mousewheel.map", function(d3_event) {
57307         d3_event.preventDefault();
57308       }).call(_zoomerPanner).call(_zoomerPanner.transform, projection2.transform()).on("dblclick.zoom", null);
57309       map2.supersurface = supersurface = selection2.append("div").attr("class", "supersurface").call(utilSetTransform, 0, 0);
57310       wrapper = supersurface.append("div").attr("class", "layer layer-data");
57311       map2.surface = surface = wrapper.call(drawLayers).selectAll(".surface");
57312       surface.call(drawLabels.observe).call(_doubleUpHandler).on(_pointerPrefix + "down.zoom", function(d3_event) {
57313         _lastPointerEvent = d3_event;
57314         if (d3_event.button === 2) {
57315           d3_event.stopPropagation();
57316         }
57317       }, true).on(_pointerPrefix + "up.zoom", function(d3_event) {
57318         _lastPointerEvent = d3_event;
57319         if (resetTransform()) {
57320           immediateRedraw();
57321         }
57322       }).on(_pointerPrefix + "move.map", function(d3_event) {
57323         _lastPointerEvent = d3_event;
57324       }).on(_pointerPrefix + "over.vertices", function(d3_event) {
57325         if (map2.editableDataEnabled() && !_isTransformed) {
57326           var hover = d3_event.target.__data__;
57327           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
57328           dispatch14.call("drawn", this, { full: false });
57329         }
57330       }).on(_pointerPrefix + "out.vertices", function(d3_event) {
57331         if (map2.editableDataEnabled() && !_isTransformed) {
57332           var hover = d3_event.relatedTarget && d3_event.relatedTarget.__data__;
57333           surface.call(drawVertices.drawHover, context.graph(), hover, map2.extent());
57334           dispatch14.call("drawn", this, { full: false });
57335         }
57336       });
57337       var detected = utilDetect();
57338       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
57339       // but we only need to do this on desktop Safari anyway. – #7694
57340       !detected.isMobileWebKit) {
57341         surface.on("gesturestart.surface", function(d3_event) {
57342           d3_event.preventDefault();
57343           _gestureTransformStart = projection2.transform();
57344         }).on("gesturechange.surface", gestureChange);
57345       }
57346       updateAreaFill();
57347       _doubleUpHandler.on("doubleUp.map", function(d3_event, p02) {
57348         if (!_dblClickZoomEnabled)
57349           return;
57350         if (typeof d3_event.target.__data__ === "object" && // or area fills
57351         !select_default2(d3_event.target).classed("fill"))
57352           return;
57353         var zoomOut2 = d3_event.shiftKey;
57354         var t2 = projection2.transform();
57355         var p1 = t2.invert(p02);
57356         t2 = t2.scale(zoomOut2 ? 0.5 : 2);
57357         t2.x = p02[0] - p1[0] * t2.k;
57358         t2.y = p02[1] - p1[1] * t2.k;
57359         map2.transformEase(t2);
57360       });
57361       context.on("enter.map", function() {
57362         if (!map2.editableDataEnabled(
57363           true
57364           /* skip zoom check */
57365         ))
57366           return;
57367         if (_isTransformed)
57368           return;
57369         var graph = context.graph();
57370         var selectedAndParents = {};
57371         context.selectedIDs().forEach(function(id2) {
57372           var entity = graph.hasEntity(id2);
57373           if (entity) {
57374             selectedAndParents[entity.id] = entity;
57375             if (entity.type === "node") {
57376               graph.parentWays(entity).forEach(function(parent) {
57377                 selectedAndParents[parent.id] = parent;
57378               });
57379             }
57380           }
57381         });
57382         var data = Object.values(selectedAndParents);
57383         var filter2 = function(d2) {
57384           return d2.id in selectedAndParents;
57385         };
57386         data = context.features().filter(data, graph);
57387         surface.call(drawVertices.drawSelected, graph, map2.extent()).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent());
57388         dispatch14.call("drawn", this, { full: false });
57389         scheduleRedraw();
57390       });
57391       map2.dimensions(utilGetDimensions(selection2));
57392     }
57393     function zoomEventFilter(d3_event) {
57394       if (d3_event.type === "mousedown") {
57395         var hasOrphan = false;
57396         var listeners = window.__on;
57397         for (var i3 = 0; i3 < listeners.length; i3++) {
57398           var listener = listeners[i3];
57399           if (listener.name === "zoom" && listener.type === "mouseup") {
57400             hasOrphan = true;
57401             break;
57402           }
57403         }
57404         if (hasOrphan) {
57405           var event = window.CustomEvent;
57406           if (event) {
57407             event = new event("mouseup");
57408           } else {
57409             event = window.document.createEvent("Event");
57410             event.initEvent("mouseup", false, false);
57411           }
57412           event.view = window;
57413           window.dispatchEvent(event);
57414         }
57415       }
57416       return d3_event.button !== 2;
57417     }
57418     function pxCenter() {
57419       return [_dimensions[0] / 2, _dimensions[1] / 2];
57420     }
57421     function drawEditable(difference2, extent) {
57422       var mode = context.mode();
57423       var graph = context.graph();
57424       var features = context.features();
57425       var all = context.history().intersects(map2.extent());
57426       var fullRedraw = false;
57427       var data;
57428       var set4;
57429       var filter2;
57430       var applyFeatureLayerFilters = true;
57431       if (map2.isInWideSelection()) {
57432         data = [];
57433         utilEntityAndDeepMemberIDs(mode.selectedIDs(), context.graph()).forEach(function(id2) {
57434           var entity = context.hasEntity(id2);
57435           if (entity)
57436             data.push(entity);
57437         });
57438         fullRedraw = true;
57439         filter2 = utilFunctor(true);
57440         applyFeatureLayerFilters = false;
57441       } else if (difference2) {
57442         var complete = difference2.complete(map2.extent());
57443         data = Object.values(complete).filter(Boolean);
57444         set4 = new Set(Object.keys(complete));
57445         filter2 = function(d2) {
57446           return set4.has(d2.id);
57447         };
57448         features.clear(data);
57449       } else {
57450         if (features.gatherStats(all, graph, _dimensions)) {
57451           extent = void 0;
57452         }
57453         if (extent) {
57454           data = context.history().intersects(map2.extent().intersection(extent));
57455           set4 = new Set(data.map(function(entity) {
57456             return entity.id;
57457           }));
57458           filter2 = function(d2) {
57459             return set4.has(d2.id);
57460           };
57461         } else {
57462           data = all;
57463           fullRedraw = true;
57464           filter2 = utilFunctor(true);
57465         }
57466       }
57467       if (applyFeatureLayerFilters) {
57468         data = features.filter(data, graph);
57469       } else {
57470         context.features().resetStats();
57471       }
57472       if (mode && mode.id === "select") {
57473         surface.call(drawVertices.drawSelected, graph, map2.extent());
57474       }
57475       surface.call(drawVertices, graph, data, filter2, map2.extent(), fullRedraw).call(drawLines, graph, data, filter2).call(drawAreas, graph, data, filter2).call(drawMidpoints, graph, data, filter2, map2.trimmedExtent()).call(drawLabels, graph, data, filter2, _dimensions, fullRedraw).call(drawPoints, graph, data, filter2);
57476       dispatch14.call("drawn", this, { full: true });
57477     }
57478     map2.init = function() {
57479       drawLayers = svgLayers(projection2, context);
57480       drawPoints = svgPoints(projection2, context);
57481       drawVertices = svgVertices(projection2, context);
57482       drawLines = svgLines(projection2, context);
57483       drawAreas = svgAreas(projection2, context);
57484       drawMidpoints = svgMidpoints(projection2, context);
57485       drawLabels = svgLabels(projection2, context);
57486     };
57487     function editOff() {
57488       context.features().resetStats();
57489       surface.selectAll(".layer-osm *").remove();
57490       surface.selectAll(".layer-touch:not(.markers) *").remove();
57491       var allowed = {
57492         "browse": true,
57493         "save": true,
57494         "select-note": true,
57495         "select-data": true,
57496         "select-error": true
57497       };
57498       var mode = context.mode();
57499       if (mode && !allowed[mode.id]) {
57500         context.enter(modeBrowse(context));
57501       }
57502       dispatch14.call("drawn", this, { full: true });
57503     }
57504     function gestureChange(d3_event) {
57505       var e3 = d3_event;
57506       e3.preventDefault();
57507       var props = {
57508         deltaMode: 0,
57509         // dummy values to ignore in zoomPan
57510         deltaY: 1,
57511         // dummy values to ignore in zoomPan
57512         clientX: e3.clientX,
57513         clientY: e3.clientY,
57514         screenX: e3.screenX,
57515         screenY: e3.screenY,
57516         x: e3.x,
57517         y: e3.y
57518       };
57519       var e22 = new WheelEvent("wheel", props);
57520       e22._scale = e3.scale;
57521       e22._rotation = e3.rotation;
57522       _selection.node().dispatchEvent(e22);
57523     }
57524     function zoomPan2(event, key, transform2) {
57525       var source = event && event.sourceEvent || event;
57526       var eventTransform = transform2 || event && event.transform;
57527       var x2 = eventTransform.x;
57528       var y2 = eventTransform.y;
57529       var k2 = eventTransform.k;
57530       if (source && source.type === "wheel") {
57531         if (_pointerDown)
57532           return;
57533         var detected = utilDetect();
57534         var dX = source.deltaX;
57535         var dY = source.deltaY;
57536         var x22 = x2;
57537         var y22 = y2;
57538         var k22 = k2;
57539         var t0, p02, p1;
57540         if (source.deltaMode === 1) {
57541           var lines = Math.abs(source.deltaY);
57542           var sign2 = source.deltaY > 0 ? 1 : -1;
57543           dY = sign2 * clamp2(
57544             Math.exp((lines - 1) * 0.75) * 4.000244140625,
57545             4.000244140625,
57546             // min
57547             350.000244140625
57548             // max
57549           );
57550           if (detected.os !== "mac") {
57551             dY *= 5;
57552           }
57553           t0 = _isTransformed ? _transformLast : _transformStart;
57554           p02 = _getMouseCoords(source);
57555           p1 = t0.invert(p02);
57556           k22 = t0.k * Math.pow(2, -dY / 500);
57557           k22 = clamp2(k22, kMin, kMax);
57558           x22 = p02[0] - p1[0] * k22;
57559           y22 = p02[1] - p1[1] * k22;
57560         } else if (source._scale) {
57561           t0 = _gestureTransformStart;
57562           p02 = _getMouseCoords(source);
57563           p1 = t0.invert(p02);
57564           k22 = t0.k * source._scale;
57565           k22 = clamp2(k22, kMin, kMax);
57566           x22 = p02[0] - p1[0] * k22;
57567           y22 = p02[1] - p1[1] * k22;
57568         } else if (source.ctrlKey && !isInteger(dY)) {
57569           dY *= 6;
57570           t0 = _isTransformed ? _transformLast : _transformStart;
57571           p02 = _getMouseCoords(source);
57572           p1 = t0.invert(p02);
57573           k22 = t0.k * Math.pow(2, -dY / 500);
57574           k22 = clamp2(k22, kMin, kMax);
57575           x22 = p02[0] - p1[0] * k22;
57576           y22 = p02[1] - p1[1] * k22;
57577         } else if ((source.altKey || source.shiftKey) && isInteger(dY)) {
57578           t0 = _isTransformed ? _transformLast : _transformStart;
57579           p02 = _getMouseCoords(source);
57580           p1 = t0.invert(p02);
57581           k22 = t0.k * Math.pow(2, -dY / 500);
57582           k22 = clamp2(k22, kMin, kMax);
57583           x22 = p02[0] - p1[0] * k22;
57584           y22 = p02[1] - p1[1] * k22;
57585         } else if (detected.os === "mac" && detected.browser !== "Firefox" && !source.ctrlKey && isInteger(dX) && isInteger(dY)) {
57586           p1 = projection2.translate();
57587           x22 = p1[0] - dX;
57588           y22 = p1[1] - dY;
57589           k22 = projection2.scale();
57590           k22 = clamp2(k22, kMin, kMax);
57591         }
57592         if (x22 !== x2 || y22 !== y2 || k22 !== k2) {
57593           x2 = x22;
57594           y2 = y22;
57595           k2 = k22;
57596           eventTransform = identity2.translate(x22, y22).scale(k22);
57597           if (_zoomerPanner._transform) {
57598             _zoomerPanner._transform(eventTransform);
57599           } else {
57600             _selection.node().__zoom = eventTransform;
57601           }
57602         }
57603       }
57604       if (_transformStart.x === x2 && _transformStart.y === y2 && _transformStart.k === k2) {
57605         return;
57606       }
57607       if (geoScaleToZoom(k2, TILESIZE) < _minzoom) {
57608         surface.interrupt();
57609         dispatch14.call("hitMinZoom", this, map2);
57610         setCenterZoom(map2.center(), context.minEditableZoom(), 0, true);
57611         scheduleRedraw();
57612         dispatch14.call("move", this, map2);
57613         return;
57614       }
57615       projection2.transform(eventTransform);
57616       var withinEditableZoom = map2.withinEditableZoom();
57617       if (_lastWithinEditableZoom !== withinEditableZoom) {
57618         if (_lastWithinEditableZoom !== void 0) {
57619           dispatch14.call("crossEditableZoom", this, withinEditableZoom);
57620         }
57621         _lastWithinEditableZoom = withinEditableZoom;
57622       }
57623       var scale = k2 / _transformStart.k;
57624       var tX = (x2 / scale - _transformStart.x) * scale;
57625       var tY = (y2 / scale - _transformStart.y) * scale;
57626       if (context.inIntro()) {
57627         curtainProjection.transform({
57628           x: x2 - tX,
57629           y: y2 - tY,
57630           k: k2
57631         });
57632       }
57633       if (source) {
57634         _lastPointerEvent = event;
57635       }
57636       _isTransformed = true;
57637       _transformLast = eventTransform;
57638       utilSetTransform(supersurface, tX, tY, scale);
57639       scheduleRedraw();
57640       dispatch14.call("move", this, map2);
57641       function isInteger(val) {
57642         return typeof val === "number" && isFinite(val) && Math.floor(val) === val;
57643       }
57644     }
57645     function resetTransform() {
57646       if (!_isTransformed)
57647         return false;
57648       utilSetTransform(supersurface, 0, 0);
57649       _isTransformed = false;
57650       if (context.inIntro()) {
57651         curtainProjection.transform(projection2.transform());
57652       }
57653       return true;
57654     }
57655     function redraw(difference2, extent) {
57656       if (surface.empty() || !_redrawEnabled)
57657         return;
57658       if (resetTransform()) {
57659         difference2 = extent = void 0;
57660       }
57661       var zoom = map2.zoom();
57662       var z2 = String(~~zoom);
57663       if (surface.attr("data-zoom") !== z2) {
57664         surface.attr("data-zoom", z2);
57665       }
57666       var lat = map2.center()[1];
57667       var lowzoom = linear3().domain([-60, 0, 60]).range([17, 18.5, 17]).clamp(true);
57668       surface.classed("low-zoom", zoom <= lowzoom(lat));
57669       if (!difference2) {
57670         supersurface.call(context.background());
57671         wrapper.call(drawLayers);
57672       }
57673       if (map2.editableDataEnabled() || map2.isInWideSelection()) {
57674         context.loadTiles(projection2);
57675         drawEditable(difference2, extent);
57676       } else {
57677         editOff();
57678       }
57679       _transformStart = projection2.transform();
57680       return map2;
57681     }
57682     var immediateRedraw = function(difference2, extent) {
57683       if (!difference2 && !extent)
57684         cancelPendingRedraw();
57685       redraw(difference2, extent);
57686     };
57687     map2.lastPointerEvent = function() {
57688       return _lastPointerEvent;
57689     };
57690     map2.mouse = function(d3_event) {
57691       var event = d3_event || _lastPointerEvent;
57692       if (event) {
57693         var s2;
57694         while (s2 = event.sourceEvent) {
57695           event = s2;
57696         }
57697         return _getMouseCoords(event);
57698       }
57699       return null;
57700     };
57701     map2.mouseCoordinates = function() {
57702       var coord2 = map2.mouse() || pxCenter();
57703       return projection2.invert(coord2);
57704     };
57705     map2.dblclickZoomEnable = function(val) {
57706       if (!arguments.length)
57707         return _dblClickZoomEnabled;
57708       _dblClickZoomEnabled = val;
57709       return map2;
57710     };
57711     map2.redrawEnable = function(val) {
57712       if (!arguments.length)
57713         return _redrawEnabled;
57714       _redrawEnabled = val;
57715       return map2;
57716     };
57717     map2.isTransformed = function() {
57718       return _isTransformed;
57719     };
57720     function setTransform(t2, duration, force) {
57721       var t3 = projection2.transform();
57722       if (!force && t2.k === t3.k && t2.x === t3.x && t2.y === t3.y)
57723         return false;
57724       if (duration) {
57725         _selection.transition().duration(duration).on("start", function() {
57726           map2.startEase();
57727         }).call(_zoomerPanner.transform, identity2.translate(t2.x, t2.y).scale(t2.k));
57728       } else {
57729         projection2.transform(t2);
57730         _transformStart = t2;
57731         _selection.call(_zoomerPanner.transform, _transformStart);
57732       }
57733       return true;
57734     }
57735     function setCenterZoom(loc2, z2, duration, force) {
57736       var c2 = map2.center();
57737       var z3 = map2.zoom();
57738       if (loc2[0] === c2[0] && loc2[1] === c2[1] && z2 === z3 && !force)
57739         return false;
57740       var proj = geoRawMercator().transform(projection2.transform());
57741       var k2 = clamp2(geoZoomToScale(z2, TILESIZE), kMin, kMax);
57742       proj.scale(k2);
57743       var t2 = proj.translate();
57744       var point2 = proj(loc2);
57745       var center = pxCenter();
57746       t2[0] += center[0] - point2[0];
57747       t2[1] += center[1] - point2[1];
57748       return setTransform(identity2.translate(t2[0], t2[1]).scale(k2), duration, force);
57749     }
57750     map2.pan = function(delta, duration) {
57751       var t2 = projection2.translate();
57752       var k2 = projection2.scale();
57753       t2[0] += delta[0];
57754       t2[1] += delta[1];
57755       if (duration) {
57756         _selection.transition().duration(duration).on("start", function() {
57757           map2.startEase();
57758         }).call(_zoomerPanner.transform, identity2.translate(t2[0], t2[1]).scale(k2));
57759       } else {
57760         projection2.translate(t2);
57761         _transformStart = projection2.transform();
57762         _selection.call(_zoomerPanner.transform, _transformStart);
57763         dispatch14.call("move", this, map2);
57764         immediateRedraw();
57765       }
57766       return map2;
57767     };
57768     map2.dimensions = function(val) {
57769       if (!arguments.length)
57770         return _dimensions;
57771       _dimensions = val;
57772       drawLayers.dimensions(_dimensions);
57773       context.background().dimensions(_dimensions);
57774       projection2.clipExtent([[0, 0], _dimensions]);
57775       _getMouseCoords = utilFastMouse(supersurface.node());
57776       scheduleRedraw();
57777       return map2;
57778     };
57779     function zoomIn(delta) {
57780       setCenterZoom(map2.center(), ~~map2.zoom() + delta, 250, true);
57781     }
57782     function zoomOut(delta) {
57783       setCenterZoom(map2.center(), ~~map2.zoom() - delta, 250, true);
57784     }
57785     map2.zoomIn = function() {
57786       zoomIn(1);
57787     };
57788     map2.zoomInFurther = function() {
57789       zoomIn(4);
57790     };
57791     map2.canZoomIn = function() {
57792       return map2.zoom() < maxZoom;
57793     };
57794     map2.zoomOut = function() {
57795       zoomOut(1);
57796     };
57797     map2.zoomOutFurther = function() {
57798       zoomOut(4);
57799     };
57800     map2.canZoomOut = function() {
57801       return map2.zoom() > minZoom2;
57802     };
57803     map2.center = function(loc2) {
57804       if (!arguments.length) {
57805         return projection2.invert(pxCenter());
57806       }
57807       if (setCenterZoom(loc2, map2.zoom())) {
57808         dispatch14.call("move", this, map2);
57809       }
57810       scheduleRedraw();
57811       return map2;
57812     };
57813     map2.unobscuredCenterZoomEase = function(loc, zoom) {
57814       var offset = map2.unobscuredOffsetPx();
57815       var proj = geoRawMercator().transform(projection2.transform());
57816       proj.scale(geoZoomToScale(zoom, TILESIZE));
57817       var locPx = proj(loc);
57818       var offsetLocPx = [locPx[0] + offset[0], locPx[1] + offset[1]];
57819       var offsetLoc = proj.invert(offsetLocPx);
57820       map2.centerZoomEase(offsetLoc, zoom);
57821     };
57822     map2.unobscuredOffsetPx = function() {
57823       var openPane = context.container().select(".map-panes .map-pane.shown");
57824       if (!openPane.empty()) {
57825         return [openPane.node().offsetWidth / 2, 0];
57826       }
57827       return [0, 0];
57828     };
57829     map2.zoom = function(z2) {
57830       if (!arguments.length) {
57831         return Math.max(geoScaleToZoom(projection2.scale(), TILESIZE), 0);
57832       }
57833       if (z2 < _minzoom) {
57834         surface.interrupt();
57835         dispatch14.call("hitMinZoom", this, map2);
57836         z2 = context.minEditableZoom();
57837       }
57838       if (setCenterZoom(map2.center(), z2)) {
57839         dispatch14.call("move", this, map2);
57840       }
57841       scheduleRedraw();
57842       return map2;
57843     };
57844     map2.centerZoom = function(loc2, z2) {
57845       if (setCenterZoom(loc2, z2)) {
57846         dispatch14.call("move", this, map2);
57847       }
57848       scheduleRedraw();
57849       return map2;
57850     };
57851     map2.zoomTo = function(entity) {
57852       var extent = entity.extent(context.graph());
57853       if (!isFinite(extent.area()))
57854         return map2;
57855       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
57856       return map2.centerZoom(extent.center(), z2);
57857     };
57858     map2.centerEase = function(loc2, duration) {
57859       duration = duration || 250;
57860       setCenterZoom(loc2, map2.zoom(), duration);
57861       return map2;
57862     };
57863     map2.zoomEase = function(z2, duration) {
57864       duration = duration || 250;
57865       setCenterZoom(map2.center(), z2, duration, false);
57866       return map2;
57867     };
57868     map2.centerZoomEase = function(loc2, z2, duration) {
57869       duration = duration || 250;
57870       setCenterZoom(loc2, z2, duration, false);
57871       return map2;
57872     };
57873     map2.transformEase = function(t2, duration) {
57874       duration = duration || 250;
57875       setTransform(
57876         t2,
57877         duration,
57878         false
57879         /* don't force */
57880       );
57881       return map2;
57882     };
57883     map2.zoomToEase = function(obj, duration) {
57884       var extent;
57885       if (Array.isArray(obj)) {
57886         obj.forEach(function(entity) {
57887           var entityExtent = entity.extent(context.graph());
57888           if (!extent) {
57889             extent = entityExtent;
57890           } else {
57891             extent = extent.extend(entityExtent);
57892           }
57893         });
57894       } else {
57895         extent = obj.extent(context.graph());
57896       }
57897       if (!isFinite(extent.area()))
57898         return map2;
57899       var z2 = clamp2(map2.trimmedExtentZoom(extent), 0, 20);
57900       return map2.centerZoomEase(extent.center(), z2, duration);
57901     };
57902     map2.startEase = function() {
57903       utilBindOnce(surface, _pointerPrefix + "down.ease", function() {
57904         map2.cancelEase();
57905       });
57906       return map2;
57907     };
57908     map2.cancelEase = function() {
57909       _selection.interrupt();
57910       return map2;
57911     };
57912     map2.extent = function(val) {
57913       if (!arguments.length) {
57914         return new geoExtent(
57915           projection2.invert([0, _dimensions[1]]),
57916           projection2.invert([_dimensions[0], 0])
57917         );
57918       } else {
57919         var extent = geoExtent(val);
57920         map2.centerZoom(extent.center(), map2.extentZoom(extent));
57921       }
57922     };
57923     map2.trimmedExtent = function(val) {
57924       if (!arguments.length) {
57925         var headerY = 71;
57926         var footerY = 30;
57927         var pad2 = 10;
57928         return new geoExtent(
57929           projection2.invert([pad2, _dimensions[1] - footerY - pad2]),
57930           projection2.invert([_dimensions[0] - pad2, headerY + pad2])
57931         );
57932       } else {
57933         var extent = geoExtent(val);
57934         map2.centerZoom(extent.center(), map2.trimmedExtentZoom(extent));
57935       }
57936     };
57937     function calcExtentZoom(extent, dim) {
57938       var tl = projection2([extent[0][0], extent[1][1]]);
57939       var br2 = projection2([extent[1][0], extent[0][1]]);
57940       var hFactor = (br2[0] - tl[0]) / dim[0];
57941       var vFactor = (br2[1] - tl[1]) / dim[1];
57942       var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
57943       var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
57944       var newZoom = map2.zoom() - Math.max(hZoomDiff, vZoomDiff);
57945       return newZoom;
57946     }
57947     map2.extentZoom = function(val) {
57948       return calcExtentZoom(geoExtent(val), _dimensions);
57949     };
57950     map2.trimmedExtentZoom = function(val) {
57951       var trimY = 120;
57952       var trimX = 40;
57953       var trimmed = [_dimensions[0] - trimX, _dimensions[1] - trimY];
57954       return calcExtentZoom(geoExtent(val), trimmed);
57955     };
57956     map2.withinEditableZoom = function() {
57957       return map2.zoom() >= context.minEditableZoom();
57958     };
57959     map2.isInWideSelection = function() {
57960       return !map2.withinEditableZoom() && context.selectedIDs().length;
57961     };
57962     map2.editableDataEnabled = function(skipZoomCheck) {
57963       var layer = context.layers().layer("osm");
57964       if (!layer || !layer.enabled())
57965         return false;
57966       return skipZoomCheck || map2.withinEditableZoom();
57967     };
57968     map2.notesEditable = function() {
57969       var layer = context.layers().layer("notes");
57970       if (!layer || !layer.enabled())
57971         return false;
57972       return map2.withinEditableZoom();
57973     };
57974     map2.minzoom = function(val) {
57975       if (!arguments.length)
57976         return _minzoom;
57977       _minzoom = val;
57978       return map2;
57979     };
57980     map2.toggleHighlightEdited = function() {
57981       surface.classed("highlight-edited", !surface.classed("highlight-edited"));
57982       map2.pan([0, 0]);
57983       dispatch14.call("changeHighlighting", this);
57984     };
57985     map2.areaFillOptions = ["wireframe", "partial", "full"];
57986     map2.activeAreaFill = function(val) {
57987       if (!arguments.length)
57988         return corePreferences("area-fill") || "partial";
57989       corePreferences("area-fill", val);
57990       if (val !== "wireframe") {
57991         corePreferences("area-fill-toggle", val);
57992       }
57993       updateAreaFill();
57994       map2.pan([0, 0]);
57995       dispatch14.call("changeAreaFill", this);
57996       return map2;
57997     };
57998     map2.toggleWireframe = function() {
57999       var activeFill = map2.activeAreaFill();
58000       if (activeFill === "wireframe") {
58001         activeFill = corePreferences("area-fill-toggle") || "partial";
58002       } else {
58003         activeFill = "wireframe";
58004       }
58005       map2.activeAreaFill(activeFill);
58006     };
58007     function updateAreaFill() {
58008       var activeFill = map2.activeAreaFill();
58009       map2.areaFillOptions.forEach(function(opt) {
58010         surface.classed("fill-" + opt, Boolean(opt === activeFill));
58011       });
58012     }
58013     map2.layers = () => drawLayers;
58014     map2.doubleUpHandler = function() {
58015       return _doubleUpHandler;
58016     };
58017     return utilRebind(map2, dispatch14, "on");
58018   }
58019
58020   // modules/renderer/photos.js
58021   function rendererPhotos(context) {
58022     var dispatch14 = dispatch_default("change");
58023     var _layerIDs = ["streetside", "mapillary", "mapillary-map-features", "mapillary-signs", "kartaview", "mapilio", "vegbilder"];
58024     var _allPhotoTypes = ["flat", "panoramic"];
58025     var _shownPhotoTypes = _allPhotoTypes.slice();
58026     var _dateFilters = ["fromDate", "toDate"];
58027     var _fromDate;
58028     var _toDate;
58029     var _usernames;
58030     function photos() {
58031     }
58032     function updateStorage() {
58033       if (window.mocha)
58034         return;
58035       var hash = utilStringQs(window.location.hash);
58036       var enabled = context.layers().all().filter(function(d2) {
58037         return _layerIDs.indexOf(d2.id) !== -1 && d2.layer && d2.layer.supported() && d2.layer.enabled();
58038       }).map(function(d2) {
58039         return d2.id;
58040       });
58041       if (enabled.length) {
58042         hash.photo_overlay = enabled.join(",");
58043       } else {
58044         delete hash.photo_overlay;
58045       }
58046       window.location.replace("#" + utilQsString(hash, true));
58047     }
58048     photos.overlayLayerIDs = function() {
58049       return _layerIDs;
58050     };
58051     photos.allPhotoTypes = function() {
58052       return _allPhotoTypes;
58053     };
58054     photos.dateFilters = function() {
58055       return _dateFilters;
58056     };
58057     photos.dateFilterValue = function(val) {
58058       return val === _dateFilters[0] ? _fromDate : _toDate;
58059     };
58060     photos.setDateFilter = function(type2, val, updateUrl) {
58061       var date = val && new Date(val);
58062       if (date && !isNaN(date)) {
58063         val = date.toISOString().slice(0, 10);
58064       } else {
58065         val = null;
58066       }
58067       if (type2 === _dateFilters[0]) {
58068         _fromDate = val;
58069         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
58070           _toDate = _fromDate;
58071         }
58072       }
58073       if (type2 === _dateFilters[1]) {
58074         _toDate = val;
58075         if (_fromDate && _toDate && new Date(_toDate) < new Date(_fromDate)) {
58076           _fromDate = _toDate;
58077         }
58078       }
58079       dispatch14.call("change", this);
58080       if (updateUrl) {
58081         var rangeString;
58082         if (_fromDate || _toDate) {
58083           rangeString = (_fromDate || "") + "_" + (_toDate || "");
58084         }
58085         setUrlFilterValue("photo_dates", rangeString);
58086       }
58087     };
58088     photos.setUsernameFilter = function(val, updateUrl) {
58089       if (val && typeof val === "string")
58090         val = val.replace(/;/g, ",").split(",");
58091       if (val) {
58092         val = val.map((d2) => d2.trim()).filter(Boolean);
58093         if (!val.length) {
58094           val = null;
58095         }
58096       }
58097       _usernames = val;
58098       dispatch14.call("change", this);
58099       if (updateUrl) {
58100         var hashString;
58101         if (_usernames) {
58102           hashString = _usernames.join(",");
58103         }
58104         setUrlFilterValue("photo_username", hashString);
58105       }
58106     };
58107     function setUrlFilterValue(property, val) {
58108       if (!window.mocha) {
58109         var hash = utilStringQs(window.location.hash);
58110         if (val) {
58111           if (hash[property] === val)
58112             return;
58113           hash[property] = val;
58114         } else {
58115           if (!(property in hash))
58116             return;
58117           delete hash[property];
58118         }
58119         window.location.replace("#" + utilQsString(hash, true));
58120       }
58121     }
58122     function showsLayer(id2) {
58123       var layer = context.layers().layer(id2);
58124       return layer && layer.supported() && layer.enabled();
58125     }
58126     photos.shouldFilterByDate = function() {
58127       return showsLayer("mapillary") || showsLayer("kartaview") || showsLayer("streetside") || showsLayer("vegbilder");
58128     };
58129     photos.shouldFilterByPhotoType = function() {
58130       return showsLayer("mapillary") || showsLayer("streetside") && showsLayer("kartaview") || showsLayer("vegbilder");
58131     };
58132     photos.shouldFilterByUsername = function() {
58133       return !showsLayer("mapillary") && showsLayer("kartaview") && !showsLayer("streetside");
58134     };
58135     photos.showsPhotoType = function(val) {
58136       if (!photos.shouldFilterByPhotoType())
58137         return true;
58138       return _shownPhotoTypes.indexOf(val) !== -1;
58139     };
58140     photos.showsFlat = function() {
58141       return photos.showsPhotoType("flat");
58142     };
58143     photos.showsPanoramic = function() {
58144       return photos.showsPhotoType("panoramic");
58145     };
58146     photos.fromDate = function() {
58147       return _fromDate;
58148     };
58149     photos.toDate = function() {
58150       return _toDate;
58151     };
58152     photos.togglePhotoType = function(val) {
58153       var index = _shownPhotoTypes.indexOf(val);
58154       if (index !== -1) {
58155         _shownPhotoTypes.splice(index, 1);
58156       } else {
58157         _shownPhotoTypes.push(val);
58158       }
58159       dispatch14.call("change", this);
58160       return photos;
58161     };
58162     photos.usernames = function() {
58163       return _usernames;
58164     };
58165     photos.init = function() {
58166       var hash = utilStringQs(window.location.hash);
58167       if (hash.photo_dates) {
58168         var parts = /^(.*)[–_](.*)$/g.exec(hash.photo_dates.trim());
58169         this.setDateFilter("fromDate", parts && parts.length >= 2 && parts[1], false);
58170         this.setDateFilter("toDate", parts && parts.length >= 3 && parts[2], false);
58171       }
58172       if (hash.photo_username) {
58173         this.setUsernameFilter(hash.photo_username, false);
58174       }
58175       if (hash.photo_overlay) {
58176         var hashOverlayIDs = hash.photo_overlay.replace(/;/g, ",").split(",");
58177         hashOverlayIDs.forEach(function(id2) {
58178           if (id2 === "openstreetcam")
58179             id2 = "kartaview";
58180           var layer2 = _layerIDs.indexOf(id2) !== -1 && context.layers().layer(id2);
58181           if (layer2 && !layer2.enabled())
58182             layer2.enabled(true);
58183         });
58184       }
58185       if (hash.photo) {
58186         var photoIds = hash.photo.replace(/;/g, ",").split(",");
58187         var photoId = photoIds.length && photoIds[0].trim();
58188         var results = /(.*)\/(.*)/g.exec(photoId);
58189         if (results && results.length >= 3) {
58190           var serviceId = results[1];
58191           if (serviceId === "openstreetcam")
58192             serviceId = "kartaview";
58193           var photoKey = results[2];
58194           var service = services[serviceId];
58195           if (service && service.ensureViewerLoaded) {
58196             var layer = _layerIDs.indexOf(serviceId) !== -1 && context.layers().layer(serviceId);
58197             if (layer && !layer.enabled())
58198               layer.enabled(true);
58199             var baselineTime = Date.now();
58200             service.on("loadedImages.rendererPhotos", function() {
58201               if (Date.now() - baselineTime > 45e3) {
58202                 service.on("loadedImages.rendererPhotos", null);
58203                 return;
58204               }
58205               if (!service.cachedImage(photoKey))
58206                 return;
58207               service.on("loadedImages.rendererPhotos", null);
58208               service.ensureViewerLoaded(context).then(function() {
58209                 service.selectImage(context, photoKey).showViewer(context);
58210               });
58211             });
58212           }
58213         }
58214       }
58215       context.layers().on("change.rendererPhotos", updateStorage);
58216     };
58217     return utilRebind(photos, dispatch14, "on");
58218   }
58219
58220   // modules/ui/account.js
58221   function uiAccount(context) {
58222     const osm = context.connection();
58223     function updateUserDetails(selection2) {
58224       if (!osm)
58225         return;
58226       if (!osm.authenticated()) {
58227         render(selection2, null);
58228       } else {
58229         osm.userDetails((err, user) => render(selection2, user));
58230       }
58231     }
58232     function render(selection2, user) {
58233       let userInfo = selection2.select(".userInfo");
58234       let loginLogout = selection2.select(".loginLogout");
58235       if (user) {
58236         userInfo.html("").classed("hide", false);
58237         let userLink = userInfo.append("a").attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
58238         if (user.image_url) {
58239           userLink.append("img").attr("class", "icon pre-text user-icon").attr("src", user.image_url);
58240         } else {
58241           userLink.call(svgIcon("#iD-icon-avatar", "pre-text light"));
58242         }
58243         userLink.append("span").attr("class", "label").text(user.display_name);
58244         loginLogout.classed("hide", false).select("a").text(_t("logout")).on("click", (e3) => {
58245           e3.preventDefault();
58246           osm.logout();
58247           tryLogout();
58248         });
58249       } else {
58250         userInfo.html("").classed("hide", true);
58251         loginLogout.classed("hide", false).select("a").text(_t("login")).on("click", (e3) => {
58252           e3.preventDefault();
58253           osm.authenticate();
58254         });
58255       }
58256     }
58257     function tryLogout() {
58258       if (!osm)
58259         return;
58260       const url = osm.getUrlRoot() + "/logout?referer=%2Flogin";
58261       const w2 = 600;
58262       const h2 = 550;
58263       const settings = [
58264         ["width", w2],
58265         ["height", h2],
58266         ["left", window.screen.width / 2 - w2 / 2],
58267         ["top", window.screen.height / 2 - h2 / 2]
58268       ].map((x2) => x2.join("=")).join(",");
58269       window.open(url, "_blank", settings);
58270     }
58271     return function(selection2) {
58272       if (!osm)
58273         return;
58274       selection2.append("li").attr("class", "userInfo").classed("hide", true);
58275       selection2.append("li").attr("class", "loginLogout").classed("hide", true).append("a").attr("href", "#");
58276       osm.on("change.account", () => updateUserDetails(selection2));
58277       updateUserDetails(selection2);
58278     };
58279   }
58280
58281   // modules/ui/attribution.js
58282   function uiAttribution(context) {
58283     let _selection = select_default2(null);
58284     function render(selection2, data, klass) {
58285       let div = selection2.selectAll(".".concat(klass)).data([0]);
58286       div = div.enter().append("div").attr("class", klass).merge(div);
58287       let attributions = div.selectAll(".attribution").data(data, (d2) => d2.id);
58288       attributions.exit().remove();
58289       attributions = attributions.enter().append("span").attr("class", "attribution").each((d2, i3, nodes) => {
58290         let attribution = select_default2(nodes[i3]);
58291         if (d2.terms_html) {
58292           attribution.html(d2.terms_html);
58293           return;
58294         }
58295         if (d2.terms_url) {
58296           attribution = attribution.append("a").attr("href", d2.terms_url).attr("target", "_blank");
58297         }
58298         const sourceID = d2.id.replace(/\./g, "<TX_DOT>");
58299         const terms_text = _t(
58300           "imagery.".concat(sourceID, ".attribution.text"),
58301           { default: d2.terms_text || d2.id || d2.name() }
58302         );
58303         if (d2.icon && !d2.overlay) {
58304           attribution.append("img").attr("class", "source-image").attr("src", d2.icon);
58305         }
58306         attribution.append("span").attr("class", "attribution-text").text(terms_text);
58307       }).merge(attributions);
58308       let copyright = attributions.selectAll(".copyright-notice").data((d2) => {
58309         let notice = d2.copyrightNotices(context.map().zoom(), context.map().extent());
58310         return notice ? [notice] : [];
58311       });
58312       copyright.exit().remove();
58313       copyright = copyright.enter().append("span").attr("class", "copyright-notice").merge(copyright);
58314       copyright.text(String);
58315     }
58316     function update() {
58317       let baselayer = context.background().baseLayerSource();
58318       _selection.call(render, baselayer ? [baselayer] : [], "base-layer-attribution");
58319       const z2 = context.map().zoom();
58320       let overlays = context.background().overlayLayerSources() || [];
58321       _selection.call(render, overlays.filter((s2) => s2.validZoom(z2)), "overlay-layer-attribution");
58322     }
58323     return function(selection2) {
58324       _selection = selection2;
58325       context.background().on("change.attribution", update);
58326       context.map().on("move.attribution", throttle_default(update, 400, { leading: false }));
58327       update();
58328     };
58329   }
58330
58331   // modules/ui/contributors.js
58332   function uiContributors(context) {
58333     var osm = context.connection(), debouncedUpdate = debounce_default(function() {
58334       update();
58335     }, 1e3), limit = 4, hidden = false, wrap2 = select_default2(null);
58336     function update() {
58337       if (!osm)
58338         return;
58339       var users = {}, entities = context.history().intersects(context.map().extent());
58340       entities.forEach(function(entity) {
58341         if (entity && entity.user)
58342           users[entity.user] = true;
58343       });
58344       var u2 = Object.keys(users), subset = u2.slice(0, u2.length > limit ? limit - 1 : limit);
58345       wrap2.html("").call(svgIcon("#iD-icon-nearby", "pre-text light"));
58346       var userList = select_default2(document.createElement("span"));
58347       userList.selectAll().data(subset).enter().append("a").attr("class", "user-link").attr("href", function(d2) {
58348         return osm.userURL(d2);
58349       }).attr("target", "_blank").text(String);
58350       if (u2.length > limit) {
58351         var count = select_default2(document.createElement("span"));
58352         var othersNum = u2.length - limit + 1;
58353         count.append("a").attr("target", "_blank").attr("href", function() {
58354           return osm.changesetsURL(context.map().center(), context.map().zoom());
58355         }).text(othersNum);
58356         wrap2.append("span").html(_t.html("contributors.truncated_list", { n: othersNum, users: { html: userList.html() }, count: { html: count.html() } }));
58357       } else {
58358         wrap2.append("span").html(_t.html("contributors.list", { users: { html: userList.html() } }));
58359       }
58360       if (!u2.length) {
58361         hidden = true;
58362         wrap2.transition().style("opacity", 0);
58363       } else if (hidden) {
58364         wrap2.transition().style("opacity", 1);
58365       }
58366     }
58367     return function(selection2) {
58368       if (!osm)
58369         return;
58370       wrap2 = selection2;
58371       update();
58372       osm.on("loaded.contributors", debouncedUpdate);
58373       context.map().on("move.contributors", debouncedUpdate);
58374     };
58375   }
58376
58377   // modules/ui/popover.js
58378   var _popoverID = 0;
58379   function uiPopover(klass) {
58380     var _id = _popoverID++;
58381     var _anchorSelection = select_default2(null);
58382     var popover = function(selection2) {
58383       _anchorSelection = selection2;
58384       selection2.each(setup);
58385     };
58386     var _animation = utilFunctor(false);
58387     var _placement = utilFunctor("top");
58388     var _alignment = utilFunctor("center");
58389     var _scrollContainer = utilFunctor(select_default2(null));
58390     var _content;
58391     var _displayType = utilFunctor("");
58392     var _hasArrow = utilFunctor(true);
58393     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
58394     popover.displayType = function(val) {
58395       if (arguments.length) {
58396         _displayType = utilFunctor(val);
58397         return popover;
58398       } else {
58399         return _displayType;
58400       }
58401     };
58402     popover.hasArrow = function(val) {
58403       if (arguments.length) {
58404         _hasArrow = utilFunctor(val);
58405         return popover;
58406       } else {
58407         return _hasArrow;
58408       }
58409     };
58410     popover.placement = function(val) {
58411       if (arguments.length) {
58412         _placement = utilFunctor(val);
58413         return popover;
58414       } else {
58415         return _placement;
58416       }
58417     };
58418     popover.alignment = function(val) {
58419       if (arguments.length) {
58420         _alignment = utilFunctor(val);
58421         return popover;
58422       } else {
58423         return _alignment;
58424       }
58425     };
58426     popover.scrollContainer = function(val) {
58427       if (arguments.length) {
58428         _scrollContainer = utilFunctor(val);
58429         return popover;
58430       } else {
58431         return _scrollContainer;
58432       }
58433     };
58434     popover.content = function(val) {
58435       if (arguments.length) {
58436         _content = val;
58437         return popover;
58438       } else {
58439         return _content;
58440       }
58441     };
58442     popover.isShown = function() {
58443       var popoverSelection = _anchorSelection.select(".popover-" + _id);
58444       return !popoverSelection.empty() && popoverSelection.classed("in");
58445     };
58446     popover.show = function() {
58447       _anchorSelection.each(show);
58448     };
58449     popover.updateContent = function() {
58450       _anchorSelection.each(updateContent);
58451     };
58452     popover.hide = function() {
58453       _anchorSelection.each(hide);
58454     };
58455     popover.toggle = function() {
58456       _anchorSelection.each(toggle);
58457     };
58458     popover.destroy = function(selection2, selector) {
58459       selector = selector || ".popover-" + _id;
58460       selection2.on(_pointerPrefix + "enter.popover", null).on(_pointerPrefix + "leave.popover", null).on(_pointerPrefix + "up.popover", null).on(_pointerPrefix + "down.popover", null).on("click.popover", null).attr("title", function() {
58461         return this.getAttribute("data-original-title") || this.getAttribute("title");
58462       }).attr("data-original-title", null).selectAll(selector).remove();
58463     };
58464     popover.destroyAny = function(selection2) {
58465       selection2.call(popover.destroy, ".popover");
58466     };
58467     function setup() {
58468       var anchor = select_default2(this);
58469       var animate = _animation.apply(this, arguments);
58470       var popoverSelection = anchor.selectAll(".popover-" + _id).data([0]);
58471       var enter = popoverSelection.enter().append("div").attr("class", "popover popover-" + _id + " " + (klass ? klass : "")).classed("arrowed", _hasArrow.apply(this, arguments));
58472       enter.append("div").attr("class", "popover-arrow");
58473       enter.append("div").attr("class", "popover-inner");
58474       popoverSelection = enter.merge(popoverSelection);
58475       if (animate) {
58476         popoverSelection.classed("fade", true);
58477       }
58478       var display = _displayType.apply(this, arguments);
58479       if (display === "hover") {
58480         var _lastNonMouseEnterTime;
58481         anchor.on(_pointerPrefix + "enter.popover", function(d3_event) {
58482           if (d3_event.pointerType) {
58483             if (d3_event.pointerType !== "mouse") {
58484               _lastNonMouseEnterTime = d3_event.timeStamp;
58485               return;
58486             } else if (_lastNonMouseEnterTime && d3_event.timeStamp - _lastNonMouseEnterTime < 1500) {
58487               return;
58488             }
58489           }
58490           if (d3_event.buttons !== 0)
58491             return;
58492           show.apply(this, arguments);
58493         }).on(_pointerPrefix + "leave.popover", function() {
58494           hide.apply(this, arguments);
58495         }).on("focus.popover", function() {
58496           show.apply(this, arguments);
58497         }).on("blur.popover", function() {
58498           hide.apply(this, arguments);
58499         });
58500       } else if (display === "clickFocus") {
58501         anchor.on(_pointerPrefix + "down.popover", function(d3_event) {
58502           d3_event.preventDefault();
58503           d3_event.stopPropagation();
58504         }).on(_pointerPrefix + "up.popover", function(d3_event) {
58505           d3_event.preventDefault();
58506           d3_event.stopPropagation();
58507         }).on("click.popover", toggle);
58508         popoverSelection.attr("tabindex", 0).on("blur.popover", function() {
58509           anchor.each(function() {
58510             hide.apply(this, arguments);
58511           });
58512         });
58513       }
58514     }
58515     function show() {
58516       var anchor = select_default2(this);
58517       var popoverSelection = anchor.selectAll(".popover-" + _id);
58518       if (popoverSelection.empty()) {
58519         anchor.call(popover.destroy);
58520         anchor.each(setup);
58521         popoverSelection = anchor.selectAll(".popover-" + _id);
58522       }
58523       popoverSelection.classed("in", true);
58524       var displayType = _displayType.apply(this, arguments);
58525       if (displayType === "clickFocus") {
58526         anchor.classed("active", true);
58527         popoverSelection.node().focus();
58528       }
58529       anchor.each(updateContent);
58530     }
58531     function updateContent() {
58532       var anchor = select_default2(this);
58533       if (_content) {
58534         anchor.selectAll(".popover-" + _id + " > .popover-inner").call(_content.apply(this, arguments));
58535       }
58536       updatePosition.apply(this, arguments);
58537       updatePosition.apply(this, arguments);
58538       updatePosition.apply(this, arguments);
58539     }
58540     function updatePosition() {
58541       var anchor = select_default2(this);
58542       var popoverSelection = anchor.selectAll(".popover-" + _id);
58543       var scrollContainer = _scrollContainer && _scrollContainer.apply(this, arguments);
58544       var scrollNode = scrollContainer && !scrollContainer.empty() && scrollContainer.node();
58545       var scrollLeft = scrollNode ? scrollNode.scrollLeft : 0;
58546       var scrollTop = scrollNode ? scrollNode.scrollTop : 0;
58547       var placement = _placement.apply(this, arguments);
58548       popoverSelection.classed("left", false).classed("right", false).classed("top", false).classed("bottom", false).classed(placement, true);
58549       var alignment = _alignment.apply(this, arguments);
58550       var alignFactor = 0.5;
58551       if (alignment === "leading") {
58552         alignFactor = 0;
58553       } else if (alignment === "trailing") {
58554         alignFactor = 1;
58555       }
58556       var anchorFrame = getFrame(anchor.node());
58557       var popoverFrame = getFrame(popoverSelection.node());
58558       var position;
58559       switch (placement) {
58560         case "top":
58561           position = {
58562             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
58563             y: anchorFrame.y - popoverFrame.h
58564           };
58565           break;
58566         case "bottom":
58567           position = {
58568             x: anchorFrame.x + (anchorFrame.w - popoverFrame.w) * alignFactor,
58569             y: anchorFrame.y + anchorFrame.h
58570           };
58571           break;
58572         case "left":
58573           position = {
58574             x: anchorFrame.x - popoverFrame.w,
58575             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
58576           };
58577           break;
58578         case "right":
58579           position = {
58580             x: anchorFrame.x + anchorFrame.w,
58581             y: anchorFrame.y + (anchorFrame.h - popoverFrame.h) * alignFactor
58582           };
58583           break;
58584       }
58585       if (position) {
58586         if (scrollNode && (placement === "top" || placement === "bottom")) {
58587           var initialPosX = position.x;
58588           if (position.x + popoverFrame.w > scrollNode.offsetWidth - 10) {
58589             position.x = scrollNode.offsetWidth - 10 - popoverFrame.w;
58590           } else if (position.x < 10) {
58591             position.x = 10;
58592           }
58593           var arrow = anchor.selectAll(".popover-" + _id + " > .popover-arrow");
58594           var arrowPosX = Math.min(Math.max(popoverFrame.w / 2 - (position.x - initialPosX), 10), popoverFrame.w - 10);
58595           arrow.style("left", ~~arrowPosX + "px");
58596         }
58597         popoverSelection.style("left", ~~position.x + "px").style("top", ~~position.y + "px");
58598       } else {
58599         popoverSelection.style("left", null).style("top", null);
58600       }
58601       function getFrame(node) {
58602         var positionStyle = select_default2(node).style("position");
58603         if (positionStyle === "absolute" || positionStyle === "static") {
58604           return {
58605             x: node.offsetLeft - scrollLeft,
58606             y: node.offsetTop - scrollTop,
58607             w: node.offsetWidth,
58608             h: node.offsetHeight
58609           };
58610         } else {
58611           return {
58612             x: 0,
58613             y: 0,
58614             w: node.offsetWidth,
58615             h: node.offsetHeight
58616           };
58617         }
58618       }
58619     }
58620     function hide() {
58621       var anchor = select_default2(this);
58622       if (_displayType.apply(this, arguments) === "clickFocus") {
58623         anchor.classed("active", false);
58624       }
58625       anchor.selectAll(".popover-" + _id).classed("in", false);
58626     }
58627     function toggle() {
58628       if (select_default2(this).select(".popover-" + _id).classed("in")) {
58629         hide.apply(this, arguments);
58630       } else {
58631         show.apply(this, arguments);
58632       }
58633     }
58634     return popover;
58635   }
58636
58637   // modules/ui/tooltip.js
58638   function uiTooltip(klass) {
58639     var tooltip = uiPopover((klass || "") + " tooltip").displayType("hover");
58640     var _title = function() {
58641       var title = this.getAttribute("data-original-title");
58642       if (title) {
58643         return title;
58644       } else {
58645         title = this.getAttribute("title");
58646         this.removeAttribute("title");
58647         this.setAttribute("data-original-title", title);
58648       }
58649       return title;
58650     };
58651     var _heading = utilFunctor(null);
58652     var _keys = utilFunctor(null);
58653     tooltip.title = function(val) {
58654       if (!arguments.length)
58655         return _title;
58656       _title = utilFunctor(val);
58657       return tooltip;
58658     };
58659     tooltip.heading = function(val) {
58660       if (!arguments.length)
58661         return _heading;
58662       _heading = utilFunctor(val);
58663       return tooltip;
58664     };
58665     tooltip.keys = function(val) {
58666       if (!arguments.length)
58667         return _keys;
58668       _keys = utilFunctor(val);
58669       return tooltip;
58670     };
58671     tooltip.content(function() {
58672       var heading2 = _heading.apply(this, arguments);
58673       var text = _title.apply(this, arguments);
58674       var keys2 = _keys.apply(this, arguments);
58675       var headingCallback = typeof heading2 === "function" ? heading2 : (s2) => s2.text(heading2);
58676       var textCallback = typeof text === "function" ? text : (s2) => s2.text(text);
58677       return function(selection2) {
58678         var headingSelect = selection2.selectAll(".tooltip-heading").data(heading2 ? [heading2] : []);
58679         headingSelect.exit().remove();
58680         headingSelect.enter().append("div").attr("class", "tooltip-heading").merge(headingSelect).text("").call(headingCallback);
58681         var textSelect = selection2.selectAll(".tooltip-text").data(text ? [text] : []);
58682         textSelect.exit().remove();
58683         textSelect.enter().append("div").attr("class", "tooltip-text").merge(textSelect).text("").call(textCallback);
58684         var keyhintWrap = selection2.selectAll(".keyhint-wrap").data(keys2 && keys2.length ? [0] : []);
58685         keyhintWrap.exit().remove();
58686         var keyhintWrapEnter = keyhintWrap.enter().append("div").attr("class", "keyhint-wrap");
58687         keyhintWrapEnter.append("span").call(_t.append("tooltip_keyhint"));
58688         keyhintWrap = keyhintWrapEnter.merge(keyhintWrap);
58689         keyhintWrap.selectAll("kbd.shortcut").data(keys2 && keys2.length ? keys2 : []).enter().append("kbd").attr("class", "shortcut").text(function(d2) {
58690           return d2;
58691         });
58692       };
58693     });
58694     return tooltip;
58695   }
58696
58697   // modules/ui/edit_menu.js
58698   function uiEditMenu(context) {
58699     var dispatch14 = dispatch_default("toggled");
58700     var _menu = select_default2(null);
58701     var _operations = [];
58702     var _anchorLoc = [0, 0];
58703     var _anchorLocLonLat = [0, 0];
58704     var _triggerType = "";
58705     var _vpTopMargin = 85;
58706     var _vpBottomMargin = 45;
58707     var _vpSideMargin = 35;
58708     var _menuTop = false;
58709     var _menuHeight;
58710     var _menuWidth;
58711     var _verticalPadding = 4;
58712     var _tooltipWidth = 210;
58713     var _menuSideMargin = 10;
58714     var _tooltips = [];
58715     var editMenu = function(selection2) {
58716       var isTouchMenu = _triggerType.includes("touch") || _triggerType.includes("pen");
58717       var ops = _operations.filter(function(op) {
58718         return !isTouchMenu || !op.mouseOnly;
58719       });
58720       if (!ops.length)
58721         return;
58722       _tooltips = [];
58723       _menuTop = isTouchMenu;
58724       var showLabels = isTouchMenu;
58725       var buttonHeight = showLabels ? 32 : 34;
58726       if (showLabels) {
58727         _menuWidth = 52 + Math.min(120, 6 * Math.max.apply(Math, ops.map(function(op) {
58728           return op.title.length;
58729         })));
58730       } else {
58731         _menuWidth = 44;
58732       }
58733       _menuHeight = _verticalPadding * 2 + ops.length * buttonHeight;
58734       _menu = selection2.append("div").attr("class", "edit-menu").classed("touch-menu", isTouchMenu).style("padding", _verticalPadding + "px 0");
58735       var buttons = _menu.selectAll(".edit-menu-item").data(ops);
58736       var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
58737         return "edit-menu-item edit-menu-item-" + d2.id;
58738       }).style("height", buttonHeight + "px").on("click", click).on("pointerup", pointerup).on("pointerdown mousedown", function pointerdown(d3_event) {
58739         d3_event.stopPropagation();
58740       }).on("mouseenter.highlight", function(d3_event, d2) {
58741         if (!d2.relatedEntityIds || select_default2(this).classed("disabled"))
58742           return;
58743         utilHighlightEntities(d2.relatedEntityIds(), true, context);
58744       }).on("mouseleave.highlight", function(d3_event, d2) {
58745         if (!d2.relatedEntityIds)
58746           return;
58747         utilHighlightEntities(d2.relatedEntityIds(), false, context);
58748       });
58749       buttonsEnter.each(function(d2) {
58750         var tooltip = uiTooltip().heading(() => d2.title).title(d2.tooltip).keys([d2.keys[0]]);
58751         _tooltips.push(tooltip);
58752         select_default2(this).call(tooltip).append("div").attr("class", "icon-wrap").call(svgIcon(d2.icon && d2.icon() || "#iD-operation-" + d2.id, "operation"));
58753       });
58754       if (showLabels) {
58755         buttonsEnter.append("span").attr("class", "label").each(function(d2) {
58756           select_default2(this).call(d2.title);
58757         });
58758       }
58759       buttonsEnter.merge(buttons).classed("disabled", function(d2) {
58760         return d2.disabled();
58761       });
58762       updatePosition();
58763       var initialScale = context.projection.scale();
58764       context.map().on("move.edit-menu", function() {
58765         if (initialScale !== context.projection.scale()) {
58766           editMenu.close();
58767         }
58768       }).on("drawn.edit-menu", function(info) {
58769         if (info.full)
58770           updatePosition();
58771       });
58772       var lastPointerUpType;
58773       function pointerup(d3_event) {
58774         lastPointerUpType = d3_event.pointerType;
58775       }
58776       function click(d3_event, operation2) {
58777         d3_event.stopPropagation();
58778         if (operation2.relatedEntityIds) {
58779           utilHighlightEntities(operation2.relatedEntityIds(), false, context);
58780         }
58781         if (operation2.disabled()) {
58782           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
58783             context.ui().flash.duration(4e3).iconName("#iD-operation-" + operation2.id).iconClass("operation disabled").label(operation2.tooltip())();
58784           }
58785         } else {
58786           if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
58787             context.ui().flash.duration(2e3).iconName("#iD-operation-" + operation2.id).iconClass("operation").label(operation2.annotation() || operation2.title)();
58788           }
58789           operation2();
58790           editMenu.close();
58791         }
58792         lastPointerUpType = null;
58793       }
58794       dispatch14.call("toggled", this, true);
58795     };
58796     function updatePosition() {
58797       if (!_menu || _menu.empty())
58798         return;
58799       var anchorLoc = context.projection(_anchorLocLonLat);
58800       var viewport = context.surfaceRect();
58801       if (anchorLoc[0] < 0 || anchorLoc[0] > viewport.width || anchorLoc[1] < 0 || anchorLoc[1] > viewport.height) {
58802         editMenu.close();
58803         return;
58804       }
58805       var menuLeft = displayOnLeft(viewport);
58806       var offset = [0, 0];
58807       offset[0] = menuLeft ? -1 * (_menuSideMargin + _menuWidth) : _menuSideMargin;
58808       if (_menuTop) {
58809         if (anchorLoc[1] - _menuHeight < _vpTopMargin) {
58810           offset[1] = -anchorLoc[1] + _vpTopMargin;
58811         } else {
58812           offset[1] = -_menuHeight;
58813         }
58814       } else {
58815         if (anchorLoc[1] + _menuHeight > viewport.height - _vpBottomMargin) {
58816           offset[1] = -anchorLoc[1] - _menuHeight + viewport.height - _vpBottomMargin;
58817         } else {
58818           offset[1] = 0;
58819         }
58820       }
58821       var origin = geoVecAdd(anchorLoc, offset);
58822       _menu.style("left", origin[0] + "px").style("top", origin[1] + "px");
58823       var tooltipSide = tooltipPosition(viewport, menuLeft);
58824       _tooltips.forEach(function(tooltip) {
58825         tooltip.placement(tooltipSide);
58826       });
58827       function displayOnLeft(viewport2) {
58828         if (_mainLocalizer.textDirection() === "ltr") {
58829           if (anchorLoc[0] + _menuSideMargin + _menuWidth > viewport2.width - _vpSideMargin) {
58830             return true;
58831           }
58832           return false;
58833         } else {
58834           if (anchorLoc[0] - _menuSideMargin - _menuWidth < _vpSideMargin) {
58835             return false;
58836           }
58837           return true;
58838         }
58839       }
58840       function tooltipPosition(viewport2, menuLeft2) {
58841         if (_mainLocalizer.textDirection() === "ltr") {
58842           if (menuLeft2) {
58843             return "left";
58844           }
58845           if (anchorLoc[0] + _menuSideMargin + _menuWidth + _tooltipWidth > viewport2.width - _vpSideMargin) {
58846             return "left";
58847           }
58848           return "right";
58849         } else {
58850           if (!menuLeft2) {
58851             return "right";
58852           }
58853           if (anchorLoc[0] - _menuSideMargin - _menuWidth - _tooltipWidth < _vpSideMargin) {
58854             return "right";
58855           }
58856           return "left";
58857         }
58858       }
58859     }
58860     editMenu.close = function() {
58861       context.map().on("move.edit-menu", null).on("drawn.edit-menu", null);
58862       _menu.remove();
58863       _tooltips = [];
58864       dispatch14.call("toggled", this, false);
58865     };
58866     editMenu.anchorLoc = function(val) {
58867       if (!arguments.length)
58868         return _anchorLoc;
58869       _anchorLoc = val;
58870       _anchorLocLonLat = context.projection.invert(_anchorLoc);
58871       return editMenu;
58872     };
58873     editMenu.triggerType = function(val) {
58874       if (!arguments.length)
58875         return _triggerType;
58876       _triggerType = val;
58877       return editMenu;
58878     };
58879     editMenu.operations = function(val) {
58880       if (!arguments.length)
58881         return _operations;
58882       _operations = val;
58883       return editMenu;
58884     };
58885     return utilRebind(editMenu, dispatch14, "on");
58886   }
58887
58888   // modules/ui/feature_info.js
58889   function uiFeatureInfo(context) {
58890     function update(selection2) {
58891       var features = context.features();
58892       var stats = features.stats();
58893       var count = 0;
58894       var hiddenList = features.hidden().map(function(k2) {
58895         if (stats[k2]) {
58896           count += stats[k2];
58897           return _t.append("inspector.title_count", {
58898             title: _t("feature." + k2 + ".description"),
58899             count: stats[k2]
58900           });
58901         }
58902         return null;
58903       }).filter(Boolean);
58904       selection2.text("");
58905       if (hiddenList.length) {
58906         var tooltipBehavior = uiTooltip().placement("top").title(function() {
58907           return (selection3) => {
58908             hiddenList.forEach((hiddenFeature) => {
58909               selection3.append("div").call(hiddenFeature);
58910             });
58911           };
58912         });
58913         selection2.append("a").attr("class", "chip").attr("href", "#").call(_t.append("feature_info.hidden_warning", { count })).call(tooltipBehavior).on("click", function(d3_event) {
58914           tooltipBehavior.hide();
58915           d3_event.preventDefault();
58916           context.ui().togglePanes(context.container().select(".map-panes .map-data-pane"));
58917         });
58918       }
58919       selection2.classed("hide", !hiddenList.length);
58920     }
58921     return function(selection2) {
58922       update(selection2);
58923       context.features().on("change.feature_info", function() {
58924         update(selection2);
58925       });
58926     };
58927   }
58928
58929   // modules/ui/flash.js
58930   function uiFlash(context) {
58931     var _flashTimer;
58932     var _duration = 2e3;
58933     var _iconName = "#iD-icon-no";
58934     var _iconClass = "disabled";
58935     var _label = (s2) => s2.text("");
58936     function flash() {
58937       if (_flashTimer) {
58938         _flashTimer.stop();
58939       }
58940       context.container().select(".main-footer-wrap").classed("footer-hide", true).classed("footer-show", false);
58941       context.container().select(".flash-wrap").classed("footer-hide", false).classed("footer-show", true);
58942       var content = context.container().select(".flash-wrap").selectAll(".flash-content").data([0]);
58943       var contentEnter = content.enter().append("div").attr("class", "flash-content");
58944       var iconEnter = contentEnter.append("svg").attr("class", "flash-icon icon").append("g").attr("transform", "translate(10,10)");
58945       iconEnter.append("circle").attr("r", 9);
58946       iconEnter.append("use").attr("transform", "translate(-7,-7)").attr("width", "14").attr("height", "14");
58947       contentEnter.append("div").attr("class", "flash-text");
58948       content = content.merge(contentEnter);
58949       content.selectAll(".flash-icon").attr("class", "icon flash-icon " + (_iconClass || ""));
58950       content.selectAll(".flash-icon use").attr("xlink:href", _iconName);
58951       content.selectAll(".flash-text").attr("class", "flash-text").call(_label);
58952       _flashTimer = timeout_default(function() {
58953         _flashTimer = null;
58954         context.container().select(".main-footer-wrap").classed("footer-hide", false).classed("footer-show", true);
58955         context.container().select(".flash-wrap").classed("footer-hide", true).classed("footer-show", false);
58956       }, _duration);
58957       return content;
58958     }
58959     flash.duration = function(_2) {
58960       if (!arguments.length)
58961         return _duration;
58962       _duration = _2;
58963       return flash;
58964     };
58965     flash.label = function(_2) {
58966       if (!arguments.length)
58967         return _label;
58968       if (typeof _2 !== "function") {
58969         _label = (selection2) => selection2.text(_2);
58970       } else {
58971         _label = (selection2) => selection2.text("").call(_2);
58972       }
58973       return flash;
58974     };
58975     flash.iconName = function(_2) {
58976       if (!arguments.length)
58977         return _iconName;
58978       _iconName = _2;
58979       return flash;
58980     };
58981     flash.iconClass = function(_2) {
58982       if (!arguments.length)
58983         return _iconClass;
58984       _iconClass = _2;
58985       return flash;
58986     };
58987     return flash;
58988   }
58989
58990   // modules/ui/full_screen.js
58991   function uiFullScreen(context) {
58992     var element = context.container().node();
58993     function getFullScreenFn() {
58994       if (element.requestFullscreen) {
58995         return element.requestFullscreen;
58996       } else if (element.msRequestFullscreen) {
58997         return element.msRequestFullscreen;
58998       } else if (element.mozRequestFullScreen) {
58999         return element.mozRequestFullScreen;
59000       } else if (element.webkitRequestFullscreen) {
59001         return element.webkitRequestFullscreen;
59002       }
59003     }
59004     function getExitFullScreenFn() {
59005       if (document.exitFullscreen) {
59006         return document.exitFullscreen;
59007       } else if (document.msExitFullscreen) {
59008         return document.msExitFullscreen;
59009       } else if (document.mozCancelFullScreen) {
59010         return document.mozCancelFullScreen;
59011       } else if (document.webkitExitFullscreen) {
59012         return document.webkitExitFullscreen;
59013       }
59014     }
59015     function isFullScreen() {
59016       return document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement;
59017     }
59018     function isSupported() {
59019       return !!getFullScreenFn();
59020     }
59021     function fullScreen(d3_event) {
59022       d3_event.preventDefault();
59023       if (!isFullScreen()) {
59024         getFullScreenFn().apply(element);
59025       } else {
59026         getExitFullScreenFn().apply(document);
59027       }
59028     }
59029     return function() {
59030       if (!isSupported())
59031         return;
59032       var detected = utilDetect();
59033       var keys2 = detected.os === "mac" ? [uiCmd("\u2303\u2318F"), "f11"] : ["f11"];
59034       context.keybinding().on(keys2, fullScreen);
59035     };
59036   }
59037
59038   // modules/ui/geolocate.js
59039   function uiGeolocate(context) {
59040     var _geolocationOptions = {
59041       // prioritize speed and power usage over precision
59042       enableHighAccuracy: false,
59043       // don't hang indefinitely getting the location
59044       timeout: 6e3
59045       // 6sec
59046     };
59047     var _locating = uiLoading(context).message(_t.html("geolocate.locating")).blocking(true);
59048     var _layer = context.layers().layer("geolocate");
59049     var _position;
59050     var _extent;
59051     var _timeoutID;
59052     var _button = select_default2(null);
59053     function click() {
59054       if (context.inIntro())
59055         return;
59056       if (!_layer.enabled() && !_locating.isShown()) {
59057         _timeoutID = setTimeout(
59058           error,
59059           1e4
59060           /* 10sec */
59061         );
59062         context.container().call(_locating);
59063         navigator.geolocation.getCurrentPosition(success, error, _geolocationOptions);
59064       } else {
59065         _locating.close();
59066         _layer.enabled(null, false);
59067         updateButtonState();
59068       }
59069     }
59070     function zoomTo() {
59071       context.enter(modeBrowse(context));
59072       var map2 = context.map();
59073       _layer.enabled(_position, true);
59074       updateButtonState();
59075       map2.centerZoomEase(_extent.center(), Math.min(20, map2.extentZoom(_extent)));
59076     }
59077     function success(geolocation) {
59078       _position = geolocation;
59079       var coords = _position.coords;
59080       _extent = geoExtent([coords.longitude, coords.latitude]).padByMeters(coords.accuracy);
59081       zoomTo();
59082       finish();
59083     }
59084     function error() {
59085       if (_position) {
59086         zoomTo();
59087       } else {
59088         context.ui().flash.label(_t.append("geolocate.location_unavailable")).iconName("#iD-icon-geolocate")();
59089       }
59090       finish();
59091     }
59092     function finish() {
59093       _locating.close();
59094       if (_timeoutID) {
59095         clearTimeout(_timeoutID);
59096       }
59097       _timeoutID = void 0;
59098     }
59099     function updateButtonState() {
59100       _button.classed("active", _layer.enabled());
59101       _button.attr("aria-pressed", _layer.enabled());
59102     }
59103     return function(selection2) {
59104       if (!navigator.geolocation || !navigator.geolocation.getCurrentPosition)
59105         return;
59106       _button = selection2.append("button").on("click", click).attr("aria-pressed", false).call(svgIcon("#iD-icon-geolocate", "light")).call(
59107         uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _t.append("geolocate.title")).keys([_t("geolocate.key")])
59108       );
59109       context.keybinding().on(_t("geolocate.key"), click);
59110     };
59111   }
59112
59113   // modules/ui/panels/background.js
59114   function uiPanelBackground(context) {
59115     var background = context.background();
59116     var _currSourceName = null;
59117     var _metadata = {};
59118     var _metadataKeys = [
59119       "zoom",
59120       "vintage",
59121       "source",
59122       "description",
59123       "resolution",
59124       "accuracy"
59125     ];
59126     var debouncedRedraw = debounce_default(redraw, 250);
59127     function redraw(selection2) {
59128       var source = background.baseLayerSource();
59129       if (!source)
59130         return;
59131       var isDG = source.id.match(/^DigitalGlobe/i) !== null;
59132       var sourceLabel = source.label();
59133       if (_currSourceName !== sourceLabel) {
59134         _currSourceName = sourceLabel;
59135         _metadata = {};
59136       }
59137       selection2.text("");
59138       var list2 = selection2.append("ul").attr("class", "background-info");
59139       list2.append("li").call(_currSourceName);
59140       _metadataKeys.forEach(function(k2) {
59141         if (isDG && k2 === "vintage")
59142           return;
59143         list2.append("li").attr("class", "background-info-list-" + k2).classed("hide", !_metadata[k2]).call(_t.append("info_panels.background." + k2, { suffix: ":" })).append("span").attr("class", "background-info-span-" + k2).text(_metadata[k2]);
59144       });
59145       debouncedGetMetadata(selection2);
59146       var toggleTiles = context.getDebug("tile") ? "hide_tiles" : "show_tiles";
59147       selection2.append("a").call(_t.append("info_panels.background." + toggleTiles)).attr("href", "#").attr("class", "button button-toggle-tiles").on("click", function(d3_event) {
59148         d3_event.preventDefault();
59149         context.setDebug("tile", !context.getDebug("tile"));
59150         selection2.call(redraw);
59151       });
59152       if (isDG) {
59153         var key = source.id + "-vintage";
59154         var sourceVintage = context.background().findSource(key);
59155         var showsVintage = context.background().showsLayer(sourceVintage);
59156         var toggleVintage = showsVintage ? "hide_vintage" : "show_vintage";
59157         selection2.append("a").call(_t.append("info_panels.background." + toggleVintage)).attr("href", "#").attr("class", "button button-toggle-vintage").on("click", function(d3_event) {
59158           d3_event.preventDefault();
59159           context.background().toggleOverlayLayer(sourceVintage);
59160           selection2.call(redraw);
59161         });
59162       }
59163       ["DigitalGlobe-Premium", "DigitalGlobe-Standard"].forEach(function(layerId) {
59164         if (source.id !== layerId) {
59165           var key2 = layerId + "-vintage";
59166           var sourceVintage2 = context.background().findSource(key2);
59167           if (context.background().showsLayer(sourceVintage2)) {
59168             context.background().toggleOverlayLayer(sourceVintage2);
59169           }
59170         }
59171       });
59172     }
59173     var debouncedGetMetadata = debounce_default(getMetadata, 250);
59174     function getMetadata(selection2) {
59175       var tile = context.container().select(".layer-background img.tile-center");
59176       if (tile.empty())
59177         return;
59178       var sourceName = _currSourceName;
59179       var d2 = tile.datum();
59180       var zoom = d2 && d2.length >= 3 && d2[2] || Math.floor(context.map().zoom());
59181       var center = context.map().center();
59182       _metadata.zoom = String(zoom);
59183       selection2.selectAll(".background-info-list-zoom").classed("hide", false).selectAll(".background-info-span-zoom").text(_metadata.zoom);
59184       if (!d2 || !d2.length >= 3)
59185         return;
59186       background.baseLayerSource().getMetadata(center, d2, function(err, result) {
59187         if (err || _currSourceName !== sourceName)
59188           return;
59189         var vintage = result.vintage;
59190         _metadata.vintage = vintage && vintage.range || _t("info_panels.background.unknown");
59191         selection2.selectAll(".background-info-list-vintage").classed("hide", false).selectAll(".background-info-span-vintage").text(_metadata.vintage);
59192         _metadataKeys.forEach(function(k2) {
59193           if (k2 === "zoom" || k2 === "vintage")
59194             return;
59195           var val = result[k2];
59196           _metadata[k2] = val;
59197           selection2.selectAll(".background-info-list-" + k2).classed("hide", !val).selectAll(".background-info-span-" + k2).text(val);
59198         });
59199       });
59200     }
59201     var panel = function(selection2) {
59202       selection2.call(redraw);
59203       context.map().on("drawn.info-background", function() {
59204         selection2.call(debouncedRedraw);
59205       }).on("move.info-background", function() {
59206         selection2.call(debouncedGetMetadata);
59207       });
59208     };
59209     panel.off = function() {
59210       context.map().on("drawn.info-background", null).on("move.info-background", null);
59211     };
59212     panel.id = "background";
59213     panel.label = _t.append("info_panels.background.title");
59214     panel.key = _t("info_panels.background.key");
59215     return panel;
59216   }
59217
59218   // modules/ui/panels/history.js
59219   function uiPanelHistory(context) {
59220     var osm;
59221     function displayTimestamp(timestamp) {
59222       if (!timestamp)
59223         return _t("info_panels.history.unknown");
59224       var options2 = {
59225         day: "numeric",
59226         month: "short",
59227         year: "numeric",
59228         hour: "numeric",
59229         minute: "numeric",
59230         second: "numeric"
59231       };
59232       var d2 = new Date(timestamp);
59233       if (isNaN(d2.getTime()))
59234         return _t("info_panels.history.unknown");
59235       return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
59236     }
59237     function displayUser(selection2, userName) {
59238       if (!userName) {
59239         selection2.append("span").call(_t.append("info_panels.history.unknown"));
59240         return;
59241       }
59242       selection2.append("span").attr("class", "user-name").text(userName);
59243       var links = selection2.append("div").attr("class", "links");
59244       if (osm) {
59245         links.append("a").attr("class", "user-osm-link").attr("href", osm.userURL(userName)).attr("target", "_blank").call(_t.append("info_panels.history.profile_link"));
59246       }
59247       links.append("a").attr("class", "user-hdyc-link").attr("href", "https://hdyc.neis-one.org/?" + userName).attr("target", "_blank").attr("tabindex", -1).text("HDYC");
59248     }
59249     function displayChangeset(selection2, changeset) {
59250       if (!changeset) {
59251         selection2.append("span").call(_t.append("info_panels.history.unknown"));
59252         return;
59253       }
59254       selection2.append("span").attr("class", "changeset-id").text(changeset);
59255       var links = selection2.append("div").attr("class", "links");
59256       if (osm) {
59257         links.append("a").attr("class", "changeset-osm-link").attr("href", osm.changesetURL(changeset)).attr("target", "_blank").call(_t.append("info_panels.history.changeset_link"));
59258       }
59259       links.append("a").attr("class", "changeset-osmcha-link").attr("href", "https://osmcha.org/changesets/" + changeset).attr("target", "_blank").text("OSMCha");
59260       links.append("a").attr("class", "changeset-achavi-link").attr("href", "https://overpass-api.de/achavi/?changeset=" + changeset).attr("target", "_blank").text("Achavi");
59261     }
59262     function redraw(selection2) {
59263       var selectedNoteID = context.selectedNoteID();
59264       osm = context.connection();
59265       var selected, note, entity;
59266       if (selectedNoteID && osm) {
59267         selected = [_t.html("note.note") + " " + selectedNoteID];
59268         note = osm.getNote(selectedNoteID);
59269       } else {
59270         selected = context.selectedIDs().filter(function(e3) {
59271           return context.hasEntity(e3);
59272         });
59273         if (selected.length) {
59274           entity = context.entity(selected[0]);
59275         }
59276       }
59277       var singular = selected.length === 1 ? selected[0] : null;
59278       selection2.html("");
59279       if (singular) {
59280         selection2.append("h4").attr("class", "history-heading").html(singular);
59281       } else {
59282         selection2.append("h4").attr("class", "history-heading").call(_t.append("info_panels.selected", { n: selected.length }));
59283       }
59284       if (!singular)
59285         return;
59286       if (entity) {
59287         selection2.call(redrawEntity, entity);
59288       } else if (note) {
59289         selection2.call(redrawNote, note);
59290       }
59291     }
59292     function redrawNote(selection2, note) {
59293       if (!note || note.isNew()) {
59294         selection2.append("div").call(_t.append("info_panels.history.note_no_history"));
59295         return;
59296       }
59297       var list2 = selection2.append("ul");
59298       list2.append("li").call(_t.append("info_panels.history.note_comments", { suffix: ":" })).append("span").text(note.comments.length);
59299       if (note.comments.length) {
59300         list2.append("li").call(_t.append("info_panels.history.note_created_date", { suffix: ":" })).append("span").text(displayTimestamp(note.comments[0].date));
59301         list2.append("li").call(_t.append("info_panels.history.note_created_user", { suffix: ":" })).call(displayUser, note.comments[0].user);
59302       }
59303       if (osm) {
59304         selection2.append("a").attr("class", "view-history-on-osm").attr("target", "_blank").attr("href", osm.noteURL(note)).call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("info_panels.history.note_link_text"));
59305       }
59306     }
59307     function redrawEntity(selection2, entity) {
59308       if (!entity || entity.isNew()) {
59309         selection2.append("div").call(_t.append("info_panels.history.no_history"));
59310         return;
59311       }
59312       var links = selection2.append("div").attr("class", "links");
59313       if (osm) {
59314         links.append("a").attr("class", "view-history-on-osm").attr("href", osm.historyURL(entity)).attr("target", "_blank").call(_t.append("info_panels.history.history_link"));
59315       }
59316       links.append("a").attr("class", "pewu-history-viewer-link").attr("href", "https://pewu.github.io/osm-history/#/" + entity.type + "/" + entity.osmId()).attr("target", "_blank").attr("tabindex", -1).text("PeWu");
59317       var list2 = selection2.append("ul");
59318       list2.append("li").call(_t.append("info_panels.history.version", { suffix: ":" })).append("span").text(entity.version);
59319       list2.append("li").call(_t.append("info_panels.history.last_edit", { suffix: ":" })).append("span").text(displayTimestamp(entity.timestamp));
59320       list2.append("li").call(_t.append("info_panels.history.edited_by", { suffix: ":" })).call(displayUser, entity.user);
59321       list2.append("li").call(_t.append("info_panels.history.changeset", { suffix: ":" })).call(displayChangeset, entity.changeset);
59322     }
59323     var panel = function(selection2) {
59324       selection2.call(redraw);
59325       context.map().on("drawn.info-history", function() {
59326         selection2.call(redraw);
59327       });
59328       context.on("enter.info-history", function() {
59329         selection2.call(redraw);
59330       });
59331     };
59332     panel.off = function() {
59333       context.map().on("drawn.info-history", null);
59334       context.on("enter.info-history", null);
59335     };
59336     panel.id = "history";
59337     panel.label = _t.append("info_panels.history.title");
59338     panel.key = _t("info_panels.history.key");
59339     return panel;
59340   }
59341
59342   // modules/ui/panels/location.js
59343   function uiPanelLocation(context) {
59344     var currLocation = "";
59345     function redraw(selection2) {
59346       selection2.html("");
59347       var list2 = selection2.append("ul");
59348       var coord2 = context.map().mouseCoordinates();
59349       if (coord2.some(isNaN)) {
59350         coord2 = context.map().center();
59351       }
59352       list2.append("li").text(dmsCoordinatePair(coord2)).append("li").text(decimalCoordinatePair(coord2));
59353       selection2.append("div").attr("class", "location-info").text(currLocation || " ");
59354       debouncedGetLocation(selection2, coord2);
59355     }
59356     var debouncedGetLocation = debounce_default(getLocation, 250);
59357     function getLocation(selection2, coord2) {
59358       if (!services.geocoder) {
59359         currLocation = _t("info_panels.location.unknown_location");
59360         selection2.selectAll(".location-info").text(currLocation);
59361       } else {
59362         services.geocoder.reverse(coord2, function(err, result) {
59363           currLocation = result ? result.display_name : _t("info_panels.location.unknown_location");
59364           selection2.selectAll(".location-info").text(currLocation);
59365         });
59366       }
59367     }
59368     var panel = function(selection2) {
59369       selection2.call(redraw);
59370       context.surface().on(("PointerEvent" in window ? "pointer" : "mouse") + "move.info-location", function() {
59371         selection2.call(redraw);
59372       });
59373     };
59374     panel.off = function() {
59375       context.surface().on(".info-location", null);
59376     };
59377     panel.id = "location";
59378     panel.label = _t.append("info_panels.location.title");
59379     panel.key = _t("info_panels.location.key");
59380     return panel;
59381   }
59382
59383   // modules/ui/panels/measurement.js
59384   function uiPanelMeasurement(context) {
59385     function radiansToMeters(r2) {
59386       return r2 * 63710071809e-4;
59387     }
59388     function steradiansToSqmeters(r2) {
59389       return r2 / (4 * Math.PI) * 510065621724e3;
59390     }
59391     function toLineString(feature3) {
59392       if (feature3.type === "LineString")
59393         return feature3;
59394       var result = { type: "LineString", coordinates: [] };
59395       if (feature3.type === "Polygon") {
59396         result.coordinates = feature3.coordinates[0];
59397       } else if (feature3.type === "MultiPolygon") {
59398         result.coordinates = feature3.coordinates[0][0];
59399       }
59400       return result;
59401     }
59402     var _isImperial = !_mainLocalizer.usesMetric();
59403     function redraw(selection2) {
59404       var graph = context.graph();
59405       var selectedNoteID = context.selectedNoteID();
59406       var osm = services.osm;
59407       var localeCode = _mainLocalizer.localeCode();
59408       var heading2;
59409       var center, location, centroid;
59410       var closed, geometry;
59411       var totalNodeCount, length2 = 0, area = 0, distance;
59412       if (selectedNoteID && osm) {
59413         var note = osm.getNote(selectedNoteID);
59414         heading2 = _t.html("note.note") + " " + selectedNoteID;
59415         location = note.loc;
59416         geometry = "note";
59417       } else {
59418         var selectedIDs = context.selectedIDs().filter(function(id2) {
59419           return context.hasEntity(id2);
59420         });
59421         var selected = selectedIDs.map(function(id2) {
59422           return context.entity(id2);
59423         });
59424         heading2 = selected.length === 1 ? selected[0].id : _t.html("info_panels.selected", { n: selected.length });
59425         if (selected.length) {
59426           var extent = geoExtent();
59427           for (var i3 in selected) {
59428             var entity = selected[i3];
59429             extent._extend(entity.extent(graph));
59430             geometry = entity.geometry(graph);
59431             if (geometry === "line" || geometry === "area") {
59432               closed = entity.type === "relation" || entity.isClosed() && !entity.isDegenerate();
59433               var feature3 = entity.asGeoJSON(graph);
59434               length2 += radiansToMeters(length_default(toLineString(feature3)));
59435               centroid = path_default(context.projection).centroid(entity.asGeoJSON(graph));
59436               centroid = centroid && context.projection.invert(centroid);
59437               if (!centroid || !isFinite(centroid[0]) || !isFinite(centroid[1])) {
59438                 centroid = entity.extent(graph).center();
59439               }
59440               if (closed) {
59441                 area += steradiansToSqmeters(entity.area(graph));
59442               }
59443             }
59444           }
59445           if (selected.length > 1) {
59446             geometry = null;
59447             closed = null;
59448             centroid = null;
59449           }
59450           if (selected.length === 2 && selected[0].type === "node" && selected[1].type === "node") {
59451             distance = geoSphericalDistance(selected[0].loc, selected[1].loc);
59452           }
59453           if (selected.length === 1 && selected[0].type === "node") {
59454             location = selected[0].loc;
59455           } else {
59456             totalNodeCount = utilGetAllNodes(selectedIDs, context.graph()).length;
59457           }
59458           if (!location && !centroid) {
59459             center = extent.center();
59460           }
59461         }
59462       }
59463       selection2.html("");
59464       if (heading2) {
59465         selection2.append("h4").attr("class", "measurement-heading").html(heading2);
59466       }
59467       var list2 = selection2.append("ul");
59468       var coordItem;
59469       if (geometry) {
59470         list2.append("li").call(_t.append("info_panels.measurement.geometry", { suffix: ":" })).append("span").html(
59471           closed ? _t.html("info_panels.measurement.closed_" + geometry) : _t.html("geometry." + geometry)
59472         );
59473       }
59474       if (totalNodeCount) {
59475         list2.append("li").call(_t.append("info_panels.measurement.node_count", { suffix: ":" })).append("span").text(totalNodeCount.toLocaleString(localeCode));
59476       }
59477       if (area) {
59478         list2.append("li").call(_t.append("info_panels.measurement.area", { suffix: ":" })).append("span").text(displayArea(area, _isImperial));
59479       }
59480       if (length2) {
59481         list2.append("li").call(_t.append("info_panels.measurement." + (closed ? "perimeter" : "length"), { suffix: ":" })).append("span").text(displayLength(length2, _isImperial));
59482       }
59483       if (typeof distance === "number") {
59484         list2.append("li").call(_t.append("info_panels.measurement.distance", { suffix: ":" })).append("span").text(displayLength(distance, _isImperial));
59485       }
59486       if (location) {
59487         coordItem = list2.append("li").call(_t.append("info_panels.measurement.location", { suffix: ":" }));
59488         coordItem.append("span").text(dmsCoordinatePair(location));
59489         coordItem.append("span").text(decimalCoordinatePair(location));
59490       }
59491       if (centroid) {
59492         coordItem = list2.append("li").call(_t.append("info_panels.measurement.centroid", { suffix: ":" }));
59493         coordItem.append("span").text(dmsCoordinatePair(centroid));
59494         coordItem.append("span").text(decimalCoordinatePair(centroid));
59495       }
59496       if (center) {
59497         coordItem = list2.append("li").call(_t.append("info_panels.measurement.center", { suffix: ":" }));
59498         coordItem.append("span").text(dmsCoordinatePair(center));
59499         coordItem.append("span").text(decimalCoordinatePair(center));
59500       }
59501       if (length2 || area || typeof distance === "number") {
59502         var toggle = _isImperial ? "imperial" : "metric";
59503         selection2.append("a").call(_t.append("info_panels.measurement." + toggle)).attr("href", "#").attr("class", "button button-toggle-units").on("click", function(d3_event) {
59504           d3_event.preventDefault();
59505           _isImperial = !_isImperial;
59506           selection2.call(redraw);
59507         });
59508       }
59509     }
59510     var panel = function(selection2) {
59511       selection2.call(redraw);
59512       context.map().on("drawn.info-measurement", function() {
59513         selection2.call(redraw);
59514       });
59515       context.on("enter.info-measurement", function() {
59516         selection2.call(redraw);
59517       });
59518     };
59519     panel.off = function() {
59520       context.map().on("drawn.info-measurement", null);
59521       context.on("enter.info-measurement", null);
59522     };
59523     panel.id = "measurement";
59524     panel.label = _t.append("info_panels.measurement.title");
59525     panel.key = _t("info_panels.measurement.key");
59526     return panel;
59527   }
59528
59529   // modules/ui/panels/index.js
59530   var uiInfoPanels = {
59531     background: uiPanelBackground,
59532     history: uiPanelHistory,
59533     location: uiPanelLocation,
59534     measurement: uiPanelMeasurement
59535   };
59536
59537   // modules/ui/info.js
59538   function uiInfo(context) {
59539     var ids = Object.keys(uiInfoPanels);
59540     var wasActive = ["measurement"];
59541     var panels = {};
59542     var active = {};
59543     ids.forEach(function(k2) {
59544       if (!panels[k2]) {
59545         panels[k2] = uiInfoPanels[k2](context);
59546         active[k2] = false;
59547       }
59548     });
59549     function info(selection2) {
59550       function redraw() {
59551         var activeids = ids.filter(function(k2) {
59552           return active[k2];
59553         }).sort();
59554         var containers = infoPanels.selectAll(".panel-container").data(activeids, function(k2) {
59555           return k2;
59556         });
59557         containers.exit().style("opacity", 1).transition().duration(200).style("opacity", 0).on("end", function(d2) {
59558           select_default2(this).call(panels[d2].off).remove();
59559         });
59560         var enter = containers.enter().append("div").attr("class", function(d2) {
59561           return "fillD2 panel-container panel-container-" + d2;
59562         });
59563         enter.style("opacity", 0).transition().duration(200).style("opacity", 1);
59564         var title = enter.append("div").attr("class", "panel-title fillD2");
59565         title.append("h3").each(function(d2) {
59566           return panels[d2].label(select_default2(this));
59567         });
59568         title.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function(d3_event, d2) {
59569           d3_event.stopImmediatePropagation();
59570           d3_event.preventDefault();
59571           info.toggle(d2);
59572         }).call(svgIcon("#iD-icon-close"));
59573         enter.append("div").attr("class", function(d2) {
59574           return "panel-content panel-content-" + d2;
59575         });
59576         infoPanels.selectAll(".panel-content").each(function(d2) {
59577           select_default2(this).call(panels[d2]);
59578         });
59579       }
59580       info.toggle = function(which) {
59581         var activeids = ids.filter(function(k2) {
59582           return active[k2];
59583         });
59584         if (which) {
59585           active[which] = !active[which];
59586           if (activeids.length === 1 && activeids[0] === which) {
59587             wasActive = [which];
59588           }
59589           context.container().select("." + which + "-panel-toggle-item").classed("active", active[which]).select("input").property("checked", active[which]);
59590         } else {
59591           if (activeids.length) {
59592             wasActive = activeids;
59593             activeids.forEach(function(k2) {
59594               active[k2] = false;
59595             });
59596           } else {
59597             wasActive.forEach(function(k2) {
59598               active[k2] = true;
59599             });
59600           }
59601         }
59602         redraw();
59603       };
59604       var infoPanels = selection2.selectAll(".info-panels").data([0]);
59605       infoPanels = infoPanels.enter().append("div").attr("class", "info-panels").merge(infoPanels);
59606       redraw();
59607       context.keybinding().on(uiCmd("\u2318" + _t("info_panels.key")), function(d3_event) {
59608         d3_event.stopImmediatePropagation();
59609         d3_event.preventDefault();
59610         info.toggle();
59611       });
59612       ids.forEach(function(k2) {
59613         var key = _t("info_panels." + k2 + ".key", { default: null });
59614         if (!key)
59615           return;
59616         context.keybinding().on(uiCmd("\u2318\u21E7" + key), function(d3_event) {
59617           d3_event.stopImmediatePropagation();
59618           d3_event.preventDefault();
59619           info.toggle(k2);
59620         });
59621       });
59622     }
59623     return info;
59624   }
59625
59626   // modules/ui/intro/helper.js
59627   function pointBox(loc, context) {
59628     var rect = context.surfaceRect();
59629     var point2 = context.curtainProjection(loc);
59630     return {
59631       left: point2[0] + rect.left - 40,
59632       top: point2[1] + rect.top - 60,
59633       width: 80,
59634       height: 90
59635     };
59636   }
59637   function pad(locOrBox, padding, context) {
59638     var box;
59639     if (locOrBox instanceof Array) {
59640       var rect = context.surfaceRect();
59641       var point2 = context.curtainProjection(locOrBox);
59642       box = {
59643         left: point2[0] + rect.left,
59644         top: point2[1] + rect.top
59645       };
59646     } else {
59647       box = locOrBox;
59648     }
59649     return {
59650       left: box.left - padding,
59651       top: box.top - padding,
59652       width: (box.width || 0) + 2 * padding,
59653       height: (box.width || 0) + 2 * padding
59654     };
59655   }
59656   function icon(name, svgklass, useklass) {
59657     return '<svg class="icon ' + (svgklass || "") + '"><use xlink:href="' + name + '"' + (useklass ? ' class="' + useklass + '"' : "") + "></use></svg>";
59658   }
59659   var helpStringReplacements;
59660   function helpHtml(id2, replacements) {
59661     if (!helpStringReplacements) {
59662       helpStringReplacements = {
59663         // insert icons corresponding to various UI elements
59664         point_icon: icon("#iD-icon-point", "inline"),
59665         line_icon: icon("#iD-icon-line", "inline"),
59666         area_icon: icon("#iD-icon-area", "inline"),
59667         note_icon: icon("#iD-icon-note", "inline add-note"),
59668         plus: icon("#iD-icon-plus", "inline"),
59669         minus: icon("#iD-icon-minus", "inline"),
59670         layers_icon: icon("#iD-icon-layers", "inline"),
59671         data_icon: icon("#iD-icon-data", "inline"),
59672         inspect: icon("#iD-icon-inspect", "inline"),
59673         help_icon: icon("#iD-icon-help", "inline"),
59674         undo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo", "inline"),
59675         redo_icon: icon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-undo" : "#iD-icon-redo", "inline"),
59676         save_icon: icon("#iD-icon-save", "inline"),
59677         // operation icons
59678         circularize_icon: icon("#iD-operation-circularize", "inline operation"),
59679         continue_icon: icon("#iD-operation-continue", "inline operation"),
59680         copy_icon: icon("#iD-operation-copy", "inline operation"),
59681         delete_icon: icon("#iD-operation-delete", "inline operation"),
59682         disconnect_icon: icon("#iD-operation-disconnect", "inline operation"),
59683         downgrade_icon: icon("#iD-operation-downgrade", "inline operation"),
59684         extract_icon: icon("#iD-operation-extract", "inline operation"),
59685         merge_icon: icon("#iD-operation-merge", "inline operation"),
59686         move_icon: icon("#iD-operation-move", "inline operation"),
59687         orthogonalize_icon: icon("#iD-operation-orthogonalize", "inline operation"),
59688         paste_icon: icon("#iD-operation-paste", "inline operation"),
59689         reflect_long_icon: icon("#iD-operation-reflect-long", "inline operation"),
59690         reflect_short_icon: icon("#iD-operation-reflect-short", "inline operation"),
59691         reverse_icon: icon("#iD-operation-reverse", "inline operation"),
59692         rotate_icon: icon("#iD-operation-rotate", "inline operation"),
59693         split_icon: icon("#iD-operation-split", "inline operation"),
59694         straighten_icon: icon("#iD-operation-straighten", "inline operation"),
59695         // interaction icons
59696         leftclick: icon("#iD-walkthrough-mouse-left", "inline operation"),
59697         rightclick: icon("#iD-walkthrough-mouse-right", "inline operation"),
59698         mousewheel_icon: icon("#iD-walkthrough-mousewheel", "inline operation"),
59699         tap_icon: icon("#iD-walkthrough-tap", "inline operation"),
59700         doubletap_icon: icon("#iD-walkthrough-doubletap", "inline operation"),
59701         longpress_icon: icon("#iD-walkthrough-longpress", "inline operation"),
59702         touchdrag_icon: icon("#iD-walkthrough-touchdrag", "inline operation"),
59703         pinch_icon: icon("#iD-walkthrough-pinch-apart", "inline operation"),
59704         // insert keys; may be localized and platform-dependent
59705         shift: uiCmd.display("\u21E7"),
59706         alt: uiCmd.display("\u2325"),
59707         return: uiCmd.display("\u21B5"),
59708         esc: _t.html("shortcuts.key.esc"),
59709         space: _t.html("shortcuts.key.space"),
59710         add_note_key: _t.html("modes.add_note.key"),
59711         help_key: _t.html("help.key"),
59712         shortcuts_key: _t.html("shortcuts.toggle.key"),
59713         // reference localized UI labels directly so that they'll always match
59714         save: _t.html("save.title"),
59715         undo: _t.html("undo.title"),
59716         redo: _t.html("redo.title"),
59717         upload: _t.html("commit.save"),
59718         point: _t.html("modes.add_point.title"),
59719         line: _t.html("modes.add_line.title"),
59720         area: _t.html("modes.add_area.title"),
59721         note: _t.html("modes.add_note.label"),
59722         circularize: _t.html("operations.circularize.title"),
59723         continue: _t.html("operations.continue.title"),
59724         copy: _t.html("operations.copy.title"),
59725         delete: _t.html("operations.delete.title"),
59726         disconnect: _t.html("operations.disconnect.title"),
59727         downgrade: _t.html("operations.downgrade.title"),
59728         extract: _t.html("operations.extract.title"),
59729         merge: _t.html("operations.merge.title"),
59730         move: _t.html("operations.move.title"),
59731         orthogonalize: _t.html("operations.orthogonalize.title"),
59732         paste: _t.html("operations.paste.title"),
59733         reflect_long: _t.html("operations.reflect.title.long"),
59734         reflect_short: _t.html("operations.reflect.title.short"),
59735         reverse: _t.html("operations.reverse.title"),
59736         rotate: _t.html("operations.rotate.title"),
59737         split: _t.html("operations.split.title"),
59738         straighten: _t.html("operations.straighten.title"),
59739         map_data: _t.html("map_data.title"),
59740         osm_notes: _t.html("map_data.layers.notes.title"),
59741         fields: _t.html("inspector.fields"),
59742         tags: _t.html("inspector.tags"),
59743         relations: _t.html("inspector.relations"),
59744         new_relation: _t.html("inspector.new_relation"),
59745         turn_restrictions: _t.html("_tagging.presets.fields.restrictions.label"),
59746         background_settings: _t.html("background.description"),
59747         imagery_offset: _t.html("background.fix_misalignment"),
59748         start_the_walkthrough: _t.html("splash.walkthrough"),
59749         help: _t.html("help.title"),
59750         ok: _t.html("intro.ok")
59751       };
59752       for (var key in helpStringReplacements) {
59753         helpStringReplacements[key] = { html: helpStringReplacements[key] };
59754       }
59755     }
59756     var reps;
59757     if (replacements) {
59758       reps = Object.assign(replacements, helpStringReplacements);
59759     } else {
59760       reps = helpStringReplacements;
59761     }
59762     return _t.html(id2, reps).replace(/\`(.*?)\`/g, "<kbd>$1</kbd>");
59763   }
59764   function slugify(text) {
59765     return text.toString().toLowerCase().replace(/\s+/g, "-").replace(/[^\w\-]+/g, "").replace(/\-\-+/g, "-").replace(/^-+/, "").replace(/-+$/, "");
59766   }
59767   var missingStrings = {};
59768   function checkKey(key, text) {
59769     if (_t(key, { default: void 0 }) === void 0) {
59770       if (missingStrings.hasOwnProperty(key))
59771         return;
59772       missingStrings[key] = text;
59773       var missing = key + ": " + text;
59774       if (typeof console !== "undefined")
59775         console.log(missing);
59776     }
59777   }
59778   function localize(obj) {
59779     var key;
59780     var name = obj.tags && obj.tags.name;
59781     if (name) {
59782       key = "intro.graph.name." + slugify(name);
59783       obj.tags.name = _t(key, { default: name });
59784       checkKey(key, name);
59785     }
59786     var street = obj.tags && obj.tags["addr:street"];
59787     if (street) {
59788       key = "intro.graph.name." + slugify(street);
59789       obj.tags["addr:street"] = _t(key, { default: street });
59790       checkKey(key, street);
59791       var addrTags = [
59792         "block_number",
59793         "city",
59794         "county",
59795         "district",
59796         "hamlet",
59797         "neighbourhood",
59798         "postcode",
59799         "province",
59800         "quarter",
59801         "state",
59802         "subdistrict",
59803         "suburb"
59804       ];
59805       addrTags.forEach(function(k2) {
59806         var key2 = "intro.graph." + k2;
59807         var tag2 = "addr:" + k2;
59808         var val = obj.tags && obj.tags[tag2];
59809         var str = _t(key2, { default: val });
59810         if (str) {
59811           if (str.match(/^<.*>$/) !== null) {
59812             delete obj.tags[tag2];
59813           } else {
59814             obj.tags[tag2] = str;
59815           }
59816         }
59817       });
59818     }
59819     return obj;
59820   }
59821   function isMostlySquare(points) {
59822     var threshold = 15;
59823     var lowerBound = Math.cos((90 - threshold) * Math.PI / 180);
59824     var upperBound = Math.cos(threshold * Math.PI / 180);
59825     for (var i3 = 0; i3 < points.length; i3++) {
59826       var a2 = points[(i3 - 1 + points.length) % points.length];
59827       var origin = points[i3];
59828       var b2 = points[(i3 + 1) % points.length];
59829       var dotp = geoVecNormalizedDot(a2, b2, origin);
59830       var mag = Math.abs(dotp);
59831       if (mag > lowerBound && mag < upperBound) {
59832         return false;
59833       }
59834     }
59835     return true;
59836   }
59837   function selectMenuItem(context, operation2) {
59838     return context.container().select(".edit-menu .edit-menu-item-" + operation2);
59839   }
59840   function transitionTime(point1, point2) {
59841     var distance = geoSphericalDistance(point1, point2);
59842     if (distance === 0) {
59843       return 0;
59844     } else if (distance < 80) {
59845       return 500;
59846     } else {
59847       return 1e3;
59848     }
59849   }
59850
59851   // modules/ui/toggle.js
59852   function uiToggle(show, callback) {
59853     return function(selection2) {
59854       selection2.style("opacity", show ? 0 : 1).classed("hide", false).transition().style("opacity", show ? 1 : 0).on("end", function() {
59855         select_default2(this).classed("hide", !show).style("opacity", null);
59856         if (callback)
59857           callback.apply(this);
59858       });
59859     };
59860   }
59861
59862   // modules/ui/curtain.js
59863   function uiCurtain(containerNode) {
59864     var surface = select_default2(null), tooltip = select_default2(null), darkness = select_default2(null);
59865     function curtain(selection2) {
59866       surface = selection2.append("svg").attr("class", "curtain").style("top", 0).style("left", 0);
59867       darkness = surface.append("path").attr("x", 0).attr("y", 0).attr("class", "curtain-darkness");
59868       select_default2(window).on("resize.curtain", resize);
59869       tooltip = selection2.append("div").attr("class", "tooltip");
59870       tooltip.append("div").attr("class", "popover-arrow");
59871       tooltip.append("div").attr("class", "popover-inner");
59872       resize();
59873       function resize() {
59874         surface.attr("width", containerNode.clientWidth).attr("height", containerNode.clientHeight);
59875         curtain.cut(darkness.datum());
59876       }
59877     }
59878     curtain.reveal = function(box, html3, options2) {
59879       options2 = options2 || {};
59880       if (typeof box === "string") {
59881         box = select_default2(box).node();
59882       }
59883       if (box && box.getBoundingClientRect) {
59884         box = copyBox(box.getBoundingClientRect());
59885         var containerRect = containerNode.getBoundingClientRect();
59886         box.top -= containerRect.top;
59887         box.left -= containerRect.left;
59888       }
59889       if (box && options2.padding) {
59890         box.top -= options2.padding;
59891         box.left -= options2.padding;
59892         box.bottom += options2.padding;
59893         box.right += options2.padding;
59894         box.height += options2.padding * 2;
59895         box.width += options2.padding * 2;
59896       }
59897       var tooltipBox;
59898       if (options2.tooltipBox) {
59899         tooltipBox = options2.tooltipBox;
59900         if (typeof tooltipBox === "string") {
59901           tooltipBox = select_default2(tooltipBox).node();
59902         }
59903         if (tooltipBox && tooltipBox.getBoundingClientRect) {
59904           tooltipBox = copyBox(tooltipBox.getBoundingClientRect());
59905         }
59906       } else {
59907         tooltipBox = box;
59908       }
59909       if (tooltipBox && html3) {
59910         if (html3.indexOf("**") !== -1) {
59911           if (html3.indexOf("<span") === 0) {
59912             html3 = html3.replace(/^(<span.*?>)(.+?)(\*\*)/, "$1<span>$2</span>$3");
59913           } else {
59914             html3 = html3.replace(/^(.+?)(\*\*)/, "<span>$1</span>$2");
59915           }
59916           html3 = html3.replace(/\*\*(.*?)\*\*/g, '<span class="instruction">$1</span>');
59917         }
59918         html3 = html3.replace(/\*(.*?)\*/g, "<em>$1</em>");
59919         html3 = html3.replace(/\{br\}/g, "<br/><br/>");
59920         if (options2.buttonText && options2.buttonCallback) {
59921           html3 += '<div class="button-section"><button href="#" class="button action">' + options2.buttonText + "</button></div>";
59922         }
59923         var classes = "curtain-tooltip popover tooltip arrowed in " + (options2.tooltipClass || "");
59924         tooltip.classed(classes, true).selectAll(".popover-inner").html(html3);
59925         if (options2.buttonText && options2.buttonCallback) {
59926           var button = tooltip.selectAll(".button-section .button.action");
59927           button.on("click", function(d3_event) {
59928             d3_event.preventDefault();
59929             options2.buttonCallback();
59930           });
59931         }
59932         var tip = copyBox(tooltip.node().getBoundingClientRect()), w2 = containerNode.clientWidth, h2 = containerNode.clientHeight, tooltipWidth = 200, tooltipArrow = 5, side, pos;
59933         if (options2.tooltipClass === "intro-mouse") {
59934           tip.height += 80;
59935         }
59936         if (tooltipBox.top + tooltipBox.height > h2) {
59937           tooltipBox.height -= tooltipBox.top + tooltipBox.height - h2;
59938         }
59939         if (tooltipBox.left + tooltipBox.width > w2) {
59940           tooltipBox.width -= tooltipBox.left + tooltipBox.width - w2;
59941         }
59942         if (tooltipBox.top + tooltipBox.height < 100) {
59943           side = "bottom";
59944           pos = [
59945             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
59946             tooltipBox.top + tooltipBox.height
59947           ];
59948         } else if (tooltipBox.top > h2 - 140) {
59949           side = "top";
59950           pos = [
59951             tooltipBox.left + tooltipBox.width / 2 - tip.width / 2,
59952             tooltipBox.top - tip.height
59953           ];
59954         } else {
59955           var tipY = tooltipBox.top + tooltipBox.height / 2 - tip.height / 2;
59956           if (_mainLocalizer.textDirection() === "rtl") {
59957             if (tooltipBox.left - tooltipWidth - tooltipArrow < 70) {
59958               side = "right";
59959               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
59960             } else {
59961               side = "left";
59962               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
59963             }
59964           } else {
59965             if (tooltipBox.left + tooltipBox.width + tooltipArrow + tooltipWidth > w2 - 70) {
59966               side = "left";
59967               pos = [tooltipBox.left - tooltipWidth - tooltipArrow, tipY];
59968             } else {
59969               side = "right";
59970               pos = [tooltipBox.left + tooltipBox.width + tooltipArrow, tipY];
59971             }
59972           }
59973         }
59974         if (options2.duration !== 0 || !tooltip.classed(side)) {
59975           tooltip.call(uiToggle(true));
59976         }
59977         tooltip.style("top", pos[1] + "px").style("left", pos[0] + "px").attr("class", classes + " " + side);
59978         var shiftY = 0;
59979         if (side === "left" || side === "right") {
59980           if (pos[1] < 60) {
59981             shiftY = 60 - pos[1];
59982           } else if (pos[1] + tip.height > h2 - 100) {
59983             shiftY = h2 - pos[1] - tip.height - 100;
59984           }
59985         }
59986         tooltip.selectAll(".popover-inner").style("top", shiftY + "px");
59987       } else {
59988         tooltip.classed("in", false).call(uiToggle(false));
59989       }
59990       curtain.cut(box, options2.duration);
59991       return tooltip;
59992     };
59993     curtain.cut = function(datum2, duration) {
59994       darkness.datum(datum2).interrupt();
59995       var selection2;
59996       if (duration === 0) {
59997         selection2 = darkness;
59998       } else {
59999         selection2 = darkness.transition().duration(duration || 600).ease(linear2);
60000       }
60001       selection2.attr("d", function(d2) {
60002         var containerWidth = containerNode.clientWidth;
60003         var containerHeight = containerNode.clientHeight;
60004         var string = "M 0,0 L 0," + containerHeight + " L " + containerWidth + "," + containerHeight + "L" + containerWidth + ",0 Z";
60005         if (!d2)
60006           return string;
60007         return string + "M" + d2.left + "," + d2.top + "L" + d2.left + "," + (d2.top + d2.height) + "L" + (d2.left + d2.width) + "," + (d2.top + d2.height) + "L" + (d2.left + d2.width) + "," + d2.top + "Z";
60008       });
60009     };
60010     curtain.remove = function() {
60011       surface.remove();
60012       tooltip.remove();
60013       select_default2(window).on("resize.curtain", null);
60014     };
60015     function copyBox(src) {
60016       return {
60017         top: src.top,
60018         right: src.right,
60019         bottom: src.bottom,
60020         left: src.left,
60021         width: src.width,
60022         height: src.height
60023       };
60024     }
60025     return curtain;
60026   }
60027
60028   // modules/ui/intro/welcome.js
60029   function uiIntroWelcome(context, reveal) {
60030     var dispatch14 = dispatch_default("done");
60031     var chapter = {
60032       title: "intro.welcome.title"
60033     };
60034     function welcome() {
60035       context.map().centerZoom([-85.63591, 41.94285], 19);
60036       reveal(
60037         ".intro-nav-wrap .chapter-welcome",
60038         helpHtml("intro.welcome.welcome"),
60039         { buttonText: _t.html("intro.ok"), buttonCallback: practice }
60040       );
60041     }
60042     function practice() {
60043       reveal(
60044         ".intro-nav-wrap .chapter-welcome",
60045         helpHtml("intro.welcome.practice"),
60046         { buttonText: _t.html("intro.ok"), buttonCallback: words }
60047       );
60048     }
60049     function words() {
60050       reveal(
60051         ".intro-nav-wrap .chapter-welcome",
60052         helpHtml("intro.welcome.words"),
60053         { buttonText: _t.html("intro.ok"), buttonCallback: chapters }
60054       );
60055     }
60056     function chapters() {
60057       dispatch14.call("done");
60058       reveal(
60059         ".intro-nav-wrap .chapter-navigation",
60060         helpHtml("intro.welcome.chapters", { next: _t("intro.navigation.title") })
60061       );
60062     }
60063     chapter.enter = function() {
60064       welcome();
60065     };
60066     chapter.exit = function() {
60067       context.container().select(".curtain-tooltip.intro-mouse").selectAll(".counter").remove();
60068     };
60069     chapter.restart = function() {
60070       chapter.exit();
60071       chapter.enter();
60072     };
60073     return utilRebind(chapter, dispatch14, "on");
60074   }
60075
60076   // modules/ui/intro/navigation.js
60077   function uiIntroNavigation(context, reveal) {
60078     var dispatch14 = dispatch_default("done");
60079     var timeouts = [];
60080     var hallId = "n2061";
60081     var townHall = [-85.63591, 41.94285];
60082     var springStreetId = "w397";
60083     var springStreetEndId = "n1834";
60084     var springStreet = [-85.63582, 41.94255];
60085     var onewayField = _mainPresetIndex.field("oneway");
60086     var maxspeedField = _mainPresetIndex.field("maxspeed");
60087     var chapter = {
60088       title: "intro.navigation.title"
60089     };
60090     function timeout2(f2, t2) {
60091       timeouts.push(window.setTimeout(f2, t2));
60092     }
60093     function eventCancel(d3_event) {
60094       d3_event.stopPropagation();
60095       d3_event.preventDefault();
60096     }
60097     function isTownHallSelected() {
60098       var ids = context.selectedIDs();
60099       return ids.length === 1 && ids[0] === hallId;
60100     }
60101     function dragMap() {
60102       context.enter(modeBrowse(context));
60103       context.history().reset("initial");
60104       var msec = transitionTime(townHall, context.map().center());
60105       if (msec) {
60106         reveal(null, null, { duration: 0 });
60107       }
60108       context.map().centerZoomEase(townHall, 19, msec);
60109       timeout2(function() {
60110         var centerStart = context.map().center();
60111         var textId = context.lastPointerType() === "mouse" ? "drag" : "drag_touch";
60112         var dragString = helpHtml("intro.navigation.map_info") + "{br}" + helpHtml("intro.navigation." + textId);
60113         reveal(".surface", dragString);
60114         context.map().on("drawn.intro", function() {
60115           reveal(".surface", dragString, { duration: 0 });
60116         });
60117         context.map().on("move.intro", function() {
60118           var centerNow = context.map().center();
60119           if (centerStart[0] !== centerNow[0] || centerStart[1] !== centerNow[1]) {
60120             context.map().on("move.intro", null);
60121             timeout2(function() {
60122               continueTo(zoomMap);
60123             }, 3e3);
60124           }
60125         });
60126       }, msec + 100);
60127       function continueTo(nextStep) {
60128         context.map().on("move.intro drawn.intro", null);
60129         nextStep();
60130       }
60131     }
60132     function zoomMap() {
60133       var zoomStart = context.map().zoom();
60134       var textId = context.lastPointerType() === "mouse" ? "zoom" : "zoom_touch";
60135       var zoomString = helpHtml("intro.navigation." + textId);
60136       reveal(".surface", zoomString);
60137       context.map().on("drawn.intro", function() {
60138         reveal(".surface", zoomString, { duration: 0 });
60139       });
60140       context.map().on("move.intro", function() {
60141         if (context.map().zoom() !== zoomStart) {
60142           context.map().on("move.intro", null);
60143           timeout2(function() {
60144             continueTo(features);
60145           }, 3e3);
60146         }
60147       });
60148       function continueTo(nextStep) {
60149         context.map().on("move.intro drawn.intro", null);
60150         nextStep();
60151       }
60152     }
60153     function features() {
60154       var onClick = function() {
60155         continueTo(pointsLinesAreas);
60156       };
60157       reveal(
60158         ".surface",
60159         helpHtml("intro.navigation.features"),
60160         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60161       );
60162       context.map().on("drawn.intro", function() {
60163         reveal(
60164           ".surface",
60165           helpHtml("intro.navigation.features"),
60166           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60167         );
60168       });
60169       function continueTo(nextStep) {
60170         context.map().on("drawn.intro", null);
60171         nextStep();
60172       }
60173     }
60174     function pointsLinesAreas() {
60175       var onClick = function() {
60176         continueTo(nodesWays);
60177       };
60178       reveal(
60179         ".surface",
60180         helpHtml("intro.navigation.points_lines_areas"),
60181         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60182       );
60183       context.map().on("drawn.intro", function() {
60184         reveal(
60185           ".surface",
60186           helpHtml("intro.navigation.points_lines_areas"),
60187           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60188         );
60189       });
60190       function continueTo(nextStep) {
60191         context.map().on("drawn.intro", null);
60192         nextStep();
60193       }
60194     }
60195     function nodesWays() {
60196       var onClick = function() {
60197         continueTo(clickTownHall);
60198       };
60199       reveal(
60200         ".surface",
60201         helpHtml("intro.navigation.nodes_ways"),
60202         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60203       );
60204       context.map().on("drawn.intro", function() {
60205         reveal(
60206           ".surface",
60207           helpHtml("intro.navigation.nodes_ways"),
60208           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60209         );
60210       });
60211       function continueTo(nextStep) {
60212         context.map().on("drawn.intro", null);
60213         nextStep();
60214       }
60215     }
60216     function clickTownHall() {
60217       context.enter(modeBrowse(context));
60218       context.history().reset("initial");
60219       var entity = context.hasEntity(hallId);
60220       if (!entity)
60221         return;
60222       reveal(null, null, { duration: 0 });
60223       context.map().centerZoomEase(entity.loc, 19, 500);
60224       timeout2(function() {
60225         var entity2 = context.hasEntity(hallId);
60226         if (!entity2)
60227           return;
60228         var box = pointBox(entity2.loc, context);
60229         var textId = context.lastPointerType() === "mouse" ? "click_townhall" : "tap_townhall";
60230         reveal(box, helpHtml("intro.navigation." + textId));
60231         context.map().on("move.intro drawn.intro", function() {
60232           var entity3 = context.hasEntity(hallId);
60233           if (!entity3)
60234             return;
60235           var box2 = pointBox(entity3.loc, context);
60236           reveal(box2, helpHtml("intro.navigation." + textId), { duration: 0 });
60237         });
60238         context.on("enter.intro", function() {
60239           if (isTownHallSelected())
60240             continueTo(selectedTownHall);
60241         });
60242       }, 550);
60243       context.history().on("change.intro", function() {
60244         if (!context.hasEntity(hallId)) {
60245           continueTo(clickTownHall);
60246         }
60247       });
60248       function continueTo(nextStep) {
60249         context.on("enter.intro", null);
60250         context.map().on("move.intro drawn.intro", null);
60251         context.history().on("change.intro", null);
60252         nextStep();
60253       }
60254     }
60255     function selectedTownHall() {
60256       if (!isTownHallSelected())
60257         return clickTownHall();
60258       var entity = context.hasEntity(hallId);
60259       if (!entity)
60260         return clickTownHall();
60261       var box = pointBox(entity.loc, context);
60262       var onClick = function() {
60263         continueTo(editorTownHall);
60264       };
60265       reveal(
60266         box,
60267         helpHtml("intro.navigation.selected_townhall"),
60268         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60269       );
60270       context.map().on("move.intro drawn.intro", function() {
60271         var entity2 = context.hasEntity(hallId);
60272         if (!entity2)
60273           return;
60274         var box2 = pointBox(entity2.loc, context);
60275         reveal(
60276           box2,
60277           helpHtml("intro.navigation.selected_townhall"),
60278           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60279         );
60280       });
60281       context.history().on("change.intro", function() {
60282         if (!context.hasEntity(hallId)) {
60283           continueTo(clickTownHall);
60284         }
60285       });
60286       function continueTo(nextStep) {
60287         context.map().on("move.intro drawn.intro", null);
60288         context.history().on("change.intro", null);
60289         nextStep();
60290       }
60291     }
60292     function editorTownHall() {
60293       if (!isTownHallSelected())
60294         return clickTownHall();
60295       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60296       var onClick = function() {
60297         continueTo(presetTownHall);
60298       };
60299       reveal(
60300         ".entity-editor-pane",
60301         helpHtml("intro.navigation.editor_townhall"),
60302         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60303       );
60304       context.on("exit.intro", function() {
60305         continueTo(clickTownHall);
60306       });
60307       context.history().on("change.intro", function() {
60308         if (!context.hasEntity(hallId)) {
60309           continueTo(clickTownHall);
60310         }
60311       });
60312       function continueTo(nextStep) {
60313         context.on("exit.intro", null);
60314         context.history().on("change.intro", null);
60315         context.container().select(".inspector-wrap").on("wheel.intro", null);
60316         nextStep();
60317       }
60318     }
60319     function presetTownHall() {
60320       if (!isTownHallSelected())
60321         return clickTownHall();
60322       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60323       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60324       var entity = context.entity(context.selectedIDs()[0]);
60325       var preset = _mainPresetIndex.match(entity, context.graph());
60326       var onClick = function() {
60327         continueTo(fieldsTownHall);
60328       };
60329       reveal(
60330         ".entity-editor-pane .section-feature-type",
60331         helpHtml("intro.navigation.preset_townhall", { preset: preset.name() }),
60332         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60333       );
60334       context.on("exit.intro", function() {
60335         continueTo(clickTownHall);
60336       });
60337       context.history().on("change.intro", function() {
60338         if (!context.hasEntity(hallId)) {
60339           continueTo(clickTownHall);
60340         }
60341       });
60342       function continueTo(nextStep) {
60343         context.on("exit.intro", null);
60344         context.history().on("change.intro", null);
60345         context.container().select(".inspector-wrap").on("wheel.intro", null);
60346         nextStep();
60347       }
60348     }
60349     function fieldsTownHall() {
60350       if (!isTownHallSelected())
60351         return clickTownHall();
60352       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60353       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60354       var onClick = function() {
60355         continueTo(closeTownHall);
60356       };
60357       reveal(
60358         ".entity-editor-pane .section-preset-fields",
60359         helpHtml("intro.navigation.fields_townhall"),
60360         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60361       );
60362       context.on("exit.intro", function() {
60363         continueTo(clickTownHall);
60364       });
60365       context.history().on("change.intro", function() {
60366         if (!context.hasEntity(hallId)) {
60367           continueTo(clickTownHall);
60368         }
60369       });
60370       function continueTo(nextStep) {
60371         context.on("exit.intro", null);
60372         context.history().on("change.intro", null);
60373         context.container().select(".inspector-wrap").on("wheel.intro", null);
60374         nextStep();
60375       }
60376     }
60377     function closeTownHall() {
60378       if (!isTownHallSelected())
60379         return clickTownHall();
60380       var selector = ".entity-editor-pane button.close svg use";
60381       var href = select_default2(selector).attr("href") || "#iD-icon-close";
60382       reveal(
60383         ".entity-editor-pane",
60384         helpHtml("intro.navigation.close_townhall", { button: { html: icon(href, "inline") } })
60385       );
60386       context.on("exit.intro", function() {
60387         continueTo(searchStreet);
60388       });
60389       context.history().on("change.intro", function() {
60390         var selector2 = ".entity-editor-pane button.close svg use";
60391         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
60392         reveal(
60393           ".entity-editor-pane",
60394           helpHtml("intro.navigation.close_townhall", { button: { html: icon(href2, "inline") } }),
60395           { duration: 0 }
60396         );
60397       });
60398       function continueTo(nextStep) {
60399         context.on("exit.intro", null);
60400         context.history().on("change.intro", null);
60401         nextStep();
60402       }
60403     }
60404     function searchStreet() {
60405       context.enter(modeBrowse(context));
60406       context.history().reset("initial");
60407       var msec = transitionTime(springStreet, context.map().center());
60408       if (msec) {
60409         reveal(null, null, { duration: 0 });
60410       }
60411       context.map().centerZoomEase(springStreet, 19, msec);
60412       timeout2(function() {
60413         reveal(
60414           ".search-header input",
60415           helpHtml("intro.navigation.search_street", { name: _t("intro.graph.name.spring-street") })
60416         );
60417         context.container().select(".search-header input").on("keyup.intro", checkSearchResult);
60418       }, msec + 100);
60419     }
60420     function checkSearchResult() {
60421       var first = context.container().select(".feature-list-item:nth-child(0n+2)");
60422       var firstName = first.select(".entity-name");
60423       var name = _t("intro.graph.name.spring-street");
60424       if (!firstName.empty() && firstName.html() === name) {
60425         reveal(
60426           first.node(),
60427           helpHtml("intro.navigation.choose_street", { name }),
60428           { duration: 300 }
60429         );
60430         context.on("exit.intro", function() {
60431           continueTo(selectedStreet);
60432         });
60433         context.container().select(".search-header input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
60434       }
60435       function continueTo(nextStep) {
60436         context.on("exit.intro", null);
60437         context.container().select(".search-header input").on("keydown.intro", null).on("keyup.intro", null);
60438         nextStep();
60439       }
60440     }
60441     function selectedStreet() {
60442       if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
60443         return searchStreet();
60444       }
60445       var onClick = function() {
60446         continueTo(editorStreet);
60447       };
60448       var entity = context.entity(springStreetEndId);
60449       var box = pointBox(entity.loc, context);
60450       box.height = 500;
60451       reveal(
60452         box,
60453         helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
60454         { duration: 600, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60455       );
60456       timeout2(function() {
60457         context.map().on("move.intro drawn.intro", function() {
60458           var entity2 = context.hasEntity(springStreetEndId);
60459           if (!entity2)
60460             return;
60461           var box2 = pointBox(entity2.loc, context);
60462           box2.height = 500;
60463           reveal(
60464             box2,
60465             helpHtml("intro.navigation.selected_street", { name: _t("intro.graph.name.spring-street") }),
60466             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
60467           );
60468         });
60469       }, 600);
60470       context.on("enter.intro", function(mode) {
60471         if (!context.hasEntity(springStreetId)) {
60472           return continueTo(searchStreet);
60473         }
60474         var ids = context.selectedIDs();
60475         if (mode.id !== "select" || !ids.length || ids[0] !== springStreetId) {
60476           context.enter(modeSelect(context, [springStreetId]));
60477         }
60478       });
60479       context.history().on("change.intro", function() {
60480         if (!context.hasEntity(springStreetEndId) || !context.hasEntity(springStreetId)) {
60481           timeout2(function() {
60482             continueTo(searchStreet);
60483           }, 300);
60484         }
60485       });
60486       function continueTo(nextStep) {
60487         context.map().on("move.intro drawn.intro", null);
60488         context.on("enter.intro", null);
60489         context.history().on("change.intro", null);
60490         nextStep();
60491       }
60492     }
60493     function editorStreet() {
60494       var selector = ".entity-editor-pane button.close svg use";
60495       var href = select_default2(selector).attr("href") || "#iD-icon-close";
60496       reveal(".entity-editor-pane", helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
60497         button: { html: icon(href, "inline") },
60498         field1: onewayField.title(),
60499         field2: maxspeedField.title()
60500       }));
60501       context.on("exit.intro", function() {
60502         continueTo(play);
60503       });
60504       context.history().on("change.intro", function() {
60505         var selector2 = ".entity-editor-pane button.close svg use";
60506         var href2 = select_default2(selector2).attr("href") || "#iD-icon-close";
60507         reveal(
60508           ".entity-editor-pane",
60509           helpHtml("intro.navigation.street_different_fields") + "{br}" + helpHtml("intro.navigation.editor_street", {
60510             button: { html: icon(href2, "inline") },
60511             field1: onewayField.title(),
60512             field2: maxspeedField.title()
60513           }),
60514           { duration: 0 }
60515         );
60516       });
60517       function continueTo(nextStep) {
60518         context.on("exit.intro", null);
60519         context.history().on("change.intro", null);
60520         nextStep();
60521       }
60522     }
60523     function play() {
60524       dispatch14.call("done");
60525       reveal(
60526         ".ideditor",
60527         helpHtml("intro.navigation.play", { next: _t("intro.points.title") }),
60528         {
60529           tooltipBox: ".intro-nav-wrap .chapter-point",
60530           buttonText: _t.html("intro.ok"),
60531           buttonCallback: function() {
60532             reveal(".ideditor");
60533           }
60534         }
60535       );
60536     }
60537     chapter.enter = function() {
60538       dragMap();
60539     };
60540     chapter.exit = function() {
60541       timeouts.forEach(window.clearTimeout);
60542       context.on("enter.intro exit.intro", null);
60543       context.map().on("move.intro drawn.intro", null);
60544       context.history().on("change.intro", null);
60545       context.container().select(".inspector-wrap").on("wheel.intro", null);
60546       context.container().select(".search-header input").on("keydown.intro keyup.intro", null);
60547     };
60548     chapter.restart = function() {
60549       chapter.exit();
60550       chapter.enter();
60551     };
60552     return utilRebind(chapter, dispatch14, "on");
60553   }
60554
60555   // modules/ui/intro/point.js
60556   function uiIntroPoint(context, reveal) {
60557     var dispatch14 = dispatch_default("done");
60558     var timeouts = [];
60559     var intersection2 = [-85.63279, 41.94394];
60560     var building = [-85.632422, 41.944045];
60561     var cafePreset = _mainPresetIndex.item("amenity/cafe");
60562     var _pointID = null;
60563     var chapter = {
60564       title: "intro.points.title"
60565     };
60566     function timeout2(f2, t2) {
60567       timeouts.push(window.setTimeout(f2, t2));
60568     }
60569     function eventCancel(d3_event) {
60570       d3_event.stopPropagation();
60571       d3_event.preventDefault();
60572     }
60573     function addPoint() {
60574       context.enter(modeBrowse(context));
60575       context.history().reset("initial");
60576       var msec = transitionTime(intersection2, context.map().center());
60577       if (msec) {
60578         reveal(null, null, { duration: 0 });
60579       }
60580       context.map().centerZoomEase(intersection2, 19, msec);
60581       timeout2(function() {
60582         var tooltip = reveal(
60583           "button.add-point",
60584           helpHtml("intro.points.points_info") + "{br}" + helpHtml("intro.points.add_point")
60585         );
60586         _pointID = null;
60587         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-points");
60588         context.on("enter.intro", function(mode) {
60589           if (mode.id !== "add-point")
60590             return;
60591           continueTo(placePoint);
60592         });
60593       }, msec + 100);
60594       function continueTo(nextStep) {
60595         context.on("enter.intro", null);
60596         nextStep();
60597       }
60598     }
60599     function placePoint() {
60600       if (context.mode().id !== "add-point") {
60601         return chapter.restart();
60602       }
60603       var pointBox2 = pad(building, 150, context);
60604       var textId = context.lastPointerType() === "mouse" ? "place_point" : "place_point_touch";
60605       reveal(pointBox2, helpHtml("intro.points." + textId));
60606       context.map().on("move.intro drawn.intro", function() {
60607         pointBox2 = pad(building, 150, context);
60608         reveal(pointBox2, helpHtml("intro.points." + textId), { duration: 0 });
60609       });
60610       context.on("enter.intro", function(mode) {
60611         if (mode.id !== "select")
60612           return chapter.restart();
60613         _pointID = context.mode().selectedIDs()[0];
60614         continueTo(searchPreset);
60615       });
60616       function continueTo(nextStep) {
60617         context.map().on("move.intro drawn.intro", null);
60618         context.on("enter.intro", null);
60619         nextStep();
60620       }
60621     }
60622     function searchPreset() {
60623       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60624         return addPoint();
60625       }
60626       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60627       context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
60628       reveal(
60629         ".preset-search-input",
60630         helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
60631       );
60632       context.on("enter.intro", function(mode) {
60633         if (!_pointID || !context.hasEntity(_pointID)) {
60634           return continueTo(addPoint);
60635         }
60636         var ids = context.selectedIDs();
60637         if (mode.id !== "select" || !ids.length || ids[0] !== _pointID) {
60638           context.enter(modeSelect(context, [_pointID]));
60639           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60640           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
60641           reveal(
60642             ".preset-search-input",
60643             helpHtml("intro.points.search_cafe", { preset: cafePreset.name() })
60644           );
60645           context.history().on("change.intro", null);
60646         }
60647       });
60648       function checkPresetSearch() {
60649         var first = context.container().select(".preset-list-item:first-child");
60650         if (first.classed("preset-amenity-cafe")) {
60651           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
60652           reveal(
60653             first.select(".preset-list-button").node(),
60654             helpHtml("intro.points.choose_cafe", { preset: cafePreset.name() }),
60655             { duration: 300 }
60656           );
60657           context.history().on("change.intro", function() {
60658             continueTo(aboutFeatureEditor);
60659           });
60660         }
60661       }
60662       function continueTo(nextStep) {
60663         context.on("enter.intro", null);
60664         context.history().on("change.intro", null);
60665         context.container().select(".inspector-wrap").on("wheel.intro", null);
60666         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60667         nextStep();
60668       }
60669     }
60670     function aboutFeatureEditor() {
60671       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60672         return addPoint();
60673       }
60674       timeout2(function() {
60675         reveal(".entity-editor-pane", helpHtml("intro.points.feature_editor"), {
60676           tooltipClass: "intro-points-describe",
60677           buttonText: _t.html("intro.ok"),
60678           buttonCallback: function() {
60679             continueTo(addName);
60680           }
60681         });
60682       }, 400);
60683       context.on("exit.intro", function() {
60684         continueTo(reselectPoint);
60685       });
60686       function continueTo(nextStep) {
60687         context.on("exit.intro", null);
60688         nextStep();
60689       }
60690     }
60691     function addName() {
60692       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60693         return addPoint();
60694       }
60695       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60696       var addNameString = helpHtml("intro.points.fields_info") + "{br}" + helpHtml("intro.points.add_name");
60697       timeout2(function() {
60698         var entity = context.entity(_pointID);
60699         if (entity.tags.name) {
60700           var tooltip = reveal(".entity-editor-pane", addNameString, {
60701             tooltipClass: "intro-points-describe",
60702             buttonText: _t.html("intro.ok"),
60703             buttonCallback: function() {
60704               continueTo(addCloseEditor);
60705             }
60706           });
60707           tooltip.select(".instruction").style("display", "none");
60708         } else {
60709           reveal(
60710             ".entity-editor-pane",
60711             addNameString,
60712             { tooltipClass: "intro-points-describe" }
60713           );
60714         }
60715       }, 400);
60716       context.history().on("change.intro", function() {
60717         continueTo(addCloseEditor);
60718       });
60719       context.on("exit.intro", function() {
60720         continueTo(reselectPoint);
60721       });
60722       function continueTo(nextStep) {
60723         context.on("exit.intro", null);
60724         context.history().on("change.intro", null);
60725         nextStep();
60726       }
60727     }
60728     function addCloseEditor() {
60729       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60730       var selector = ".entity-editor-pane button.close svg use";
60731       var href = select_default2(selector).attr("href") || "#iD-icon-close";
60732       context.on("exit.intro", function() {
60733         continueTo(reselectPoint);
60734       });
60735       reveal(
60736         ".entity-editor-pane",
60737         helpHtml("intro.points.add_close", { button: { html: icon(href, "inline") } })
60738       );
60739       function continueTo(nextStep) {
60740         context.on("exit.intro", null);
60741         nextStep();
60742       }
60743     }
60744     function reselectPoint() {
60745       if (!_pointID)
60746         return chapter.restart();
60747       var entity = context.hasEntity(_pointID);
60748       if (!entity)
60749         return chapter.restart();
60750       var oldPreset = _mainPresetIndex.match(entity, context.graph());
60751       context.replace(actionChangePreset(_pointID, oldPreset, cafePreset));
60752       context.enter(modeBrowse(context));
60753       var msec = transitionTime(entity.loc, context.map().center());
60754       if (msec) {
60755         reveal(null, null, { duration: 0 });
60756       }
60757       context.map().centerEase(entity.loc, msec);
60758       timeout2(function() {
60759         var box = pointBox(entity.loc, context);
60760         reveal(box, helpHtml("intro.points.reselect"), { duration: 600 });
60761         timeout2(function() {
60762           context.map().on("move.intro drawn.intro", function() {
60763             var entity2 = context.hasEntity(_pointID);
60764             if (!entity2)
60765               return chapter.restart();
60766             var box2 = pointBox(entity2.loc, context);
60767             reveal(box2, helpHtml("intro.points.reselect"), { duration: 0 });
60768           });
60769         }, 600);
60770         context.on("enter.intro", function(mode) {
60771           if (mode.id !== "select")
60772             return;
60773           continueTo(updatePoint);
60774         });
60775       }, msec + 100);
60776       function continueTo(nextStep) {
60777         context.map().on("move.intro drawn.intro", null);
60778         context.on("enter.intro", null);
60779         nextStep();
60780       }
60781     }
60782     function updatePoint() {
60783       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60784         return continueTo(reselectPoint);
60785       }
60786       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60787       context.on("exit.intro", function() {
60788         continueTo(reselectPoint);
60789       });
60790       context.history().on("change.intro", function() {
60791         continueTo(updateCloseEditor);
60792       });
60793       timeout2(function() {
60794         reveal(
60795           ".entity-editor-pane",
60796           helpHtml("intro.points.update"),
60797           { tooltipClass: "intro-points-describe" }
60798         );
60799       }, 400);
60800       function continueTo(nextStep) {
60801         context.on("exit.intro", null);
60802         context.history().on("change.intro", null);
60803         nextStep();
60804       }
60805     }
60806     function updateCloseEditor() {
60807       if (context.mode().id !== "select" || !_pointID || !context.hasEntity(_pointID)) {
60808         return continueTo(reselectPoint);
60809       }
60810       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
60811       context.on("exit.intro", function() {
60812         continueTo(rightClickPoint);
60813       });
60814       timeout2(function() {
60815         reveal(
60816           ".entity-editor-pane",
60817           helpHtml("intro.points.update_close", { button: { html: icon("#iD-icon-close", "inline") } })
60818         );
60819       }, 500);
60820       function continueTo(nextStep) {
60821         context.on("exit.intro", null);
60822         nextStep();
60823       }
60824     }
60825     function rightClickPoint() {
60826       if (!_pointID)
60827         return chapter.restart();
60828       var entity = context.hasEntity(_pointID);
60829       if (!entity)
60830         return chapter.restart();
60831       context.enter(modeBrowse(context));
60832       var box = pointBox(entity.loc, context);
60833       var textId = context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch";
60834       reveal(box, helpHtml("intro.points." + textId), { duration: 600 });
60835       timeout2(function() {
60836         context.map().on("move.intro", function() {
60837           var entity2 = context.hasEntity(_pointID);
60838           if (!entity2)
60839             return chapter.restart();
60840           var box2 = pointBox(entity2.loc, context);
60841           reveal(box2, helpHtml("intro.points." + textId), { duration: 0 });
60842         });
60843       }, 600);
60844       context.on("enter.intro", function(mode) {
60845         if (mode.id !== "select")
60846           return;
60847         var ids = context.selectedIDs();
60848         if (ids.length !== 1 || ids[0] !== _pointID)
60849           return;
60850         timeout2(function() {
60851           var node = selectMenuItem(context, "delete").node();
60852           if (!node)
60853             return;
60854           continueTo(enterDelete);
60855         }, 50);
60856       });
60857       function continueTo(nextStep) {
60858         context.on("enter.intro", null);
60859         context.map().on("move.intro", null);
60860         nextStep();
60861       }
60862     }
60863     function enterDelete() {
60864       if (!_pointID)
60865         return chapter.restart();
60866       var entity = context.hasEntity(_pointID);
60867       if (!entity)
60868         return chapter.restart();
60869       var node = selectMenuItem(context, "delete").node();
60870       if (!node) {
60871         return continueTo(rightClickPoint);
60872       }
60873       reveal(
60874         ".edit-menu",
60875         helpHtml("intro.points.delete"),
60876         { padding: 50 }
60877       );
60878       timeout2(function() {
60879         context.map().on("move.intro", function() {
60880           reveal(
60881             ".edit-menu",
60882             helpHtml("intro.points.delete"),
60883             { duration: 0, padding: 50 }
60884           );
60885         });
60886       }, 300);
60887       context.on("exit.intro", function() {
60888         if (!_pointID)
60889           return chapter.restart();
60890         var entity2 = context.hasEntity(_pointID);
60891         if (entity2)
60892           return continueTo(rightClickPoint);
60893       });
60894       context.history().on("change.intro", function(changed) {
60895         if (changed.deleted().length) {
60896           continueTo(undo);
60897         }
60898       });
60899       function continueTo(nextStep) {
60900         context.map().on("move.intro", null);
60901         context.history().on("change.intro", null);
60902         context.on("exit.intro", null);
60903         nextStep();
60904       }
60905     }
60906     function undo() {
60907       context.history().on("change.intro", function() {
60908         continueTo(play);
60909       });
60910       reveal(
60911         ".top-toolbar button.undo-button",
60912         helpHtml("intro.points.undo")
60913       );
60914       function continueTo(nextStep) {
60915         context.history().on("change.intro", null);
60916         nextStep();
60917       }
60918     }
60919     function play() {
60920       dispatch14.call("done");
60921       reveal(
60922         ".ideditor",
60923         helpHtml("intro.points.play", { next: _t("intro.areas.title") }),
60924         {
60925           tooltipBox: ".intro-nav-wrap .chapter-area",
60926           buttonText: _t.html("intro.ok"),
60927           buttonCallback: function() {
60928             reveal(".ideditor");
60929           }
60930         }
60931       );
60932     }
60933     chapter.enter = function() {
60934       addPoint();
60935     };
60936     chapter.exit = function() {
60937       timeouts.forEach(window.clearTimeout);
60938       context.on("enter.intro exit.intro", null);
60939       context.map().on("move.intro drawn.intro", null);
60940       context.history().on("change.intro", null);
60941       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
60942       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
60943     };
60944     chapter.restart = function() {
60945       chapter.exit();
60946       chapter.enter();
60947     };
60948     return utilRebind(chapter, dispatch14, "on");
60949   }
60950
60951   // modules/ui/intro/area.js
60952   function uiIntroArea(context, reveal) {
60953     var dispatch14 = dispatch_default("done");
60954     var playground = [-85.63552, 41.94159];
60955     var playgroundPreset = _mainPresetIndex.item("leisure/playground");
60956     var nameField = _mainPresetIndex.field("name");
60957     var descriptionField = _mainPresetIndex.field("description");
60958     var timeouts = [];
60959     var _areaID;
60960     var chapter = {
60961       title: "intro.areas.title"
60962     };
60963     function timeout2(f2, t2) {
60964       timeouts.push(window.setTimeout(f2, t2));
60965     }
60966     function eventCancel(d3_event) {
60967       d3_event.stopPropagation();
60968       d3_event.preventDefault();
60969     }
60970     function revealPlayground(center, text, options2) {
60971       var padding = 180 * Math.pow(2, context.map().zoom() - 19.5);
60972       var box = pad(center, padding, context);
60973       reveal(box, text, options2);
60974     }
60975     function addArea() {
60976       context.enter(modeBrowse(context));
60977       context.history().reset("initial");
60978       _areaID = null;
60979       var msec = transitionTime(playground, context.map().center());
60980       if (msec) {
60981         reveal(null, null, { duration: 0 });
60982       }
60983       context.map().centerZoomEase(playground, 19, msec);
60984       timeout2(function() {
60985         var tooltip = reveal(
60986           "button.add-area",
60987           helpHtml("intro.areas.add_playground")
60988         );
60989         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-areas");
60990         context.on("enter.intro", function(mode) {
60991           if (mode.id !== "add-area")
60992             return;
60993           continueTo(startPlayground);
60994         });
60995       }, msec + 100);
60996       function continueTo(nextStep) {
60997         context.on("enter.intro", null);
60998         nextStep();
60999       }
61000     }
61001     function startPlayground() {
61002       if (context.mode().id !== "add-area") {
61003         return chapter.restart();
61004       }
61005       _areaID = null;
61006       context.map().zoomEase(19.5, 500);
61007       timeout2(function() {
61008         var textId = context.lastPointerType() === "mouse" ? "starting_node_click" : "starting_node_tap";
61009         var startDrawString = helpHtml("intro.areas.start_playground") + helpHtml("intro.areas." + textId);
61010         revealPlayground(
61011           playground,
61012           startDrawString,
61013           { duration: 250 }
61014         );
61015         timeout2(function() {
61016           context.map().on("move.intro drawn.intro", function() {
61017             revealPlayground(
61018               playground,
61019               startDrawString,
61020               { duration: 0 }
61021             );
61022           });
61023           context.on("enter.intro", function(mode) {
61024             if (mode.id !== "draw-area")
61025               return chapter.restart();
61026             continueTo(continuePlayground);
61027           });
61028         }, 250);
61029       }, 550);
61030       function continueTo(nextStep) {
61031         context.map().on("move.intro drawn.intro", null);
61032         context.on("enter.intro", null);
61033         nextStep();
61034       }
61035     }
61036     function continuePlayground() {
61037       if (context.mode().id !== "draw-area") {
61038         return chapter.restart();
61039       }
61040       _areaID = null;
61041       revealPlayground(
61042         playground,
61043         helpHtml("intro.areas.continue_playground"),
61044         { duration: 250 }
61045       );
61046       timeout2(function() {
61047         context.map().on("move.intro drawn.intro", function() {
61048           revealPlayground(
61049             playground,
61050             helpHtml("intro.areas.continue_playground"),
61051             { duration: 0 }
61052           );
61053         });
61054       }, 250);
61055       context.on("enter.intro", function(mode) {
61056         if (mode.id === "draw-area") {
61057           var entity = context.hasEntity(context.selectedIDs()[0]);
61058           if (entity && entity.nodes.length >= 6) {
61059             return continueTo(finishPlayground);
61060           } else {
61061             return;
61062           }
61063         } else if (mode.id === "select") {
61064           _areaID = context.selectedIDs()[0];
61065           return continueTo(searchPresets);
61066         } else {
61067           return chapter.restart();
61068         }
61069       });
61070       function continueTo(nextStep) {
61071         context.map().on("move.intro drawn.intro", null);
61072         context.on("enter.intro", null);
61073         nextStep();
61074       }
61075     }
61076     function finishPlayground() {
61077       if (context.mode().id !== "draw-area") {
61078         return chapter.restart();
61079       }
61080       _areaID = null;
61081       var finishString = helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.areas.finish_playground");
61082       revealPlayground(
61083         playground,
61084         finishString,
61085         { duration: 250 }
61086       );
61087       timeout2(function() {
61088         context.map().on("move.intro drawn.intro", function() {
61089           revealPlayground(
61090             playground,
61091             finishString,
61092             { duration: 0 }
61093           );
61094         });
61095       }, 250);
61096       context.on("enter.intro", function(mode) {
61097         if (mode.id === "draw-area") {
61098           return;
61099         } else if (mode.id === "select") {
61100           _areaID = context.selectedIDs()[0];
61101           return continueTo(searchPresets);
61102         } else {
61103           return chapter.restart();
61104         }
61105       });
61106       function continueTo(nextStep) {
61107         context.map().on("move.intro drawn.intro", null);
61108         context.on("enter.intro", null);
61109         nextStep();
61110       }
61111     }
61112     function searchPresets() {
61113       if (!_areaID || !context.hasEntity(_areaID)) {
61114         return addArea();
61115       }
61116       var ids = context.selectedIDs();
61117       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61118         context.enter(modeSelect(context, [_areaID]));
61119       }
61120       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61121       timeout2(function() {
61122         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
61123         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
61124         reveal(
61125           ".preset-search-input",
61126           helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
61127         );
61128       }, 400);
61129       context.on("enter.intro", function(mode) {
61130         if (!_areaID || !context.hasEntity(_areaID)) {
61131           return continueTo(addArea);
61132         }
61133         var ids2 = context.selectedIDs();
61134         if (mode.id !== "select" || !ids2.length || ids2[0] !== _areaID) {
61135           context.enter(modeSelect(context, [_areaID]));
61136           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
61137           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61138           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
61139           reveal(
61140             ".preset-search-input",
61141             helpHtml("intro.areas.search_playground", { preset: playgroundPreset.name() })
61142           );
61143           context.history().on("change.intro", null);
61144         }
61145       });
61146       function checkPresetSearch() {
61147         var first = context.container().select(".preset-list-item:first-child");
61148         if (first.classed("preset-leisure-playground")) {
61149           reveal(
61150             first.select(".preset-list-button").node(),
61151             helpHtml("intro.areas.choose_playground", { preset: playgroundPreset.name() }),
61152             { duration: 300 }
61153           );
61154           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
61155           context.history().on("change.intro", function() {
61156             continueTo(clickAddField);
61157           });
61158         }
61159       }
61160       function continueTo(nextStep) {
61161         context.container().select(".inspector-wrap").on("wheel.intro", null);
61162         context.on("enter.intro", null);
61163         context.history().on("change.intro", null);
61164         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
61165         nextStep();
61166       }
61167     }
61168     function clickAddField() {
61169       if (!_areaID || !context.hasEntity(_areaID)) {
61170         return addArea();
61171       }
61172       var ids = context.selectedIDs();
61173       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61174         return searchPresets();
61175       }
61176       if (!context.container().select(".form-field-description").empty()) {
61177         return continueTo(describePlayground);
61178       }
61179       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61180       timeout2(function() {
61181         context.container().select(".inspector-wrap .panewrap").style("right", "0%");
61182         var entity = context.entity(_areaID);
61183         if (entity.tags.description) {
61184           return continueTo(play);
61185         }
61186         var box = context.container().select(".more-fields").node().getBoundingClientRect();
61187         if (box.top > 300) {
61188           var pane = context.container().select(".entity-editor-pane .inspector-body");
61189           var start2 = pane.node().scrollTop;
61190           var end = start2 + (box.top - 300);
61191           pane.transition().duration(250).tween("scroll.inspector", function() {
61192             var node = this;
61193             var i3 = number_default(start2, end);
61194             return function(t2) {
61195               node.scrollTop = i3(t2);
61196             };
61197           });
61198         }
61199         timeout2(function() {
61200           reveal(
61201             ".more-fields .combobox-input",
61202             helpHtml("intro.areas.add_field", {
61203               name: nameField.title(),
61204               description: descriptionField.title()
61205             }),
61206             { duration: 300 }
61207           );
61208           context.container().select(".more-fields .combobox-input").on("click.intro", function() {
61209             var watcher;
61210             watcher = window.setInterval(function() {
61211               if (!context.container().select("div.combobox").empty()) {
61212                 window.clearInterval(watcher);
61213                 continueTo(chooseDescriptionField);
61214               }
61215             }, 300);
61216           });
61217         }, 300);
61218       }, 400);
61219       context.on("exit.intro", function() {
61220         return continueTo(searchPresets);
61221       });
61222       function continueTo(nextStep) {
61223         context.container().select(".inspector-wrap").on("wheel.intro", null);
61224         context.container().select(".more-fields .combobox-input").on("click.intro", null);
61225         context.on("exit.intro", null);
61226         nextStep();
61227       }
61228     }
61229     function chooseDescriptionField() {
61230       if (!_areaID || !context.hasEntity(_areaID)) {
61231         return addArea();
61232       }
61233       var ids = context.selectedIDs();
61234       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61235         return searchPresets();
61236       }
61237       if (!context.container().select(".form-field-description").empty()) {
61238         return continueTo(describePlayground);
61239       }
61240       if (context.container().select("div.combobox").empty()) {
61241         return continueTo(clickAddField);
61242       }
61243       var watcher;
61244       watcher = window.setInterval(function() {
61245         if (context.container().select("div.combobox").empty()) {
61246           window.clearInterval(watcher);
61247           timeout2(function() {
61248             if (context.container().select(".form-field-description").empty()) {
61249               continueTo(retryChooseDescription);
61250             } else {
61251               continueTo(describePlayground);
61252             }
61253           }, 300);
61254         }
61255       }, 300);
61256       reveal(
61257         "div.combobox",
61258         helpHtml("intro.areas.choose_field", { field: descriptionField.title() }),
61259         { duration: 300 }
61260       );
61261       context.on("exit.intro", function() {
61262         return continueTo(searchPresets);
61263       });
61264       function continueTo(nextStep) {
61265         if (watcher)
61266           window.clearInterval(watcher);
61267         context.on("exit.intro", null);
61268         nextStep();
61269       }
61270     }
61271     function describePlayground() {
61272       if (!_areaID || !context.hasEntity(_areaID)) {
61273         return addArea();
61274       }
61275       var ids = context.selectedIDs();
61276       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61277         return searchPresets();
61278       }
61279       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
61280       if (context.container().select(".form-field-description").empty()) {
61281         return continueTo(retryChooseDescription);
61282       }
61283       context.on("exit.intro", function() {
61284         continueTo(play);
61285       });
61286       reveal(
61287         ".entity-editor-pane",
61288         helpHtml("intro.areas.describe_playground", { button: { html: icon("#iD-icon-close", "inline") } }),
61289         { duration: 300 }
61290       );
61291       function continueTo(nextStep) {
61292         context.on("exit.intro", null);
61293         nextStep();
61294       }
61295     }
61296     function retryChooseDescription() {
61297       if (!_areaID || !context.hasEntity(_areaID)) {
61298         return addArea();
61299       }
61300       var ids = context.selectedIDs();
61301       if (context.mode().id !== "select" || !ids.length || ids[0] !== _areaID) {
61302         return searchPresets();
61303       }
61304       context.container().select(".inspector-wrap .panewrap").style("right", "0%");
61305       reveal(
61306         ".entity-editor-pane",
61307         helpHtml("intro.areas.retry_add_field", { field: descriptionField.title() }),
61308         {
61309           buttonText: _t.html("intro.ok"),
61310           buttonCallback: function() {
61311             continueTo(clickAddField);
61312           }
61313         }
61314       );
61315       context.on("exit.intro", function() {
61316         return continueTo(searchPresets);
61317       });
61318       function continueTo(nextStep) {
61319         context.on("exit.intro", null);
61320         nextStep();
61321       }
61322     }
61323     function play() {
61324       dispatch14.call("done");
61325       reveal(
61326         ".ideditor",
61327         helpHtml("intro.areas.play", { next: _t("intro.lines.title") }),
61328         {
61329           tooltipBox: ".intro-nav-wrap .chapter-line",
61330           buttonText: _t.html("intro.ok"),
61331           buttonCallback: function() {
61332             reveal(".ideditor");
61333           }
61334         }
61335       );
61336     }
61337     chapter.enter = function() {
61338       addArea();
61339     };
61340     chapter.exit = function() {
61341       timeouts.forEach(window.clearTimeout);
61342       context.on("enter.intro exit.intro", null);
61343       context.map().on("move.intro drawn.intro", null);
61344       context.history().on("change.intro", null);
61345       context.container().select(".inspector-wrap").on("wheel.intro", null);
61346       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
61347       context.container().select(".more-fields .combobox-input").on("click.intro", null);
61348     };
61349     chapter.restart = function() {
61350       chapter.exit();
61351       chapter.enter();
61352     };
61353     return utilRebind(chapter, dispatch14, "on");
61354   }
61355
61356   // modules/ui/intro/line.js
61357   function uiIntroLine(context, reveal) {
61358     var dispatch14 = dispatch_default("done");
61359     var timeouts = [];
61360     var _tulipRoadID = null;
61361     var flowerRoadID = "w646";
61362     var tulipRoadStart = [-85.6297754121684, 41.95805253325314];
61363     var tulipRoadMidpoint = [-85.62975395449628, 41.95787501510204];
61364     var tulipRoadIntersection = [-85.62974496187628, 41.95742515554585];
61365     var roadCategory = _mainPresetIndex.item("category-road_minor");
61366     var residentialPreset = _mainPresetIndex.item("highway/residential");
61367     var woodRoadID = "w525";
61368     var woodRoadEndID = "n2862";
61369     var woodRoadAddNode = [-85.62390110349587, 41.95397111462291];
61370     var woodRoadDragEndpoint = [-85.623867390213, 41.95466987786487];
61371     var woodRoadDragMidpoint = [-85.62386254803509, 41.95430395953872];
61372     var washingtonStreetID = "w522";
61373     var twelfthAvenueID = "w1";
61374     var eleventhAvenueEndID = "n3550";
61375     var twelfthAvenueEndID = "n5";
61376     var _washingtonSegmentID = null;
61377     var eleventhAvenueEnd = context.entity(eleventhAvenueEndID).loc;
61378     var twelfthAvenueEnd = context.entity(twelfthAvenueEndID).loc;
61379     var deleteLinesLoc = [-85.6219395542764, 41.95228033922477];
61380     var twelfthAvenue = [-85.62219310052491, 41.952505413152956];
61381     var chapter = {
61382       title: "intro.lines.title"
61383     };
61384     function timeout2(f2, t2) {
61385       timeouts.push(window.setTimeout(f2, t2));
61386     }
61387     function eventCancel(d3_event) {
61388       d3_event.stopPropagation();
61389       d3_event.preventDefault();
61390     }
61391     function addLine() {
61392       context.enter(modeBrowse(context));
61393       context.history().reset("initial");
61394       var msec = transitionTime(tulipRoadStart, context.map().center());
61395       if (msec) {
61396         reveal(null, null, { duration: 0 });
61397       }
61398       context.map().centerZoomEase(tulipRoadStart, 18.5, msec);
61399       timeout2(function() {
61400         var tooltip = reveal(
61401           "button.add-line",
61402           helpHtml("intro.lines.add_line")
61403         );
61404         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-lines");
61405         context.on("enter.intro", function(mode) {
61406           if (mode.id !== "add-line")
61407             return;
61408           continueTo(startLine);
61409         });
61410       }, msec + 100);
61411       function continueTo(nextStep) {
61412         context.on("enter.intro", null);
61413         nextStep();
61414       }
61415     }
61416     function startLine() {
61417       if (context.mode().id !== "add-line")
61418         return chapter.restart();
61419       _tulipRoadID = null;
61420       var padding = 70 * Math.pow(2, context.map().zoom() - 18);
61421       var box = pad(tulipRoadStart, padding, context);
61422       box.height = box.height + 100;
61423       var textId = context.lastPointerType() === "mouse" ? "start_line" : "start_line_tap";
61424       var startLineString = helpHtml("intro.lines.missing_road") + "{br}" + helpHtml("intro.lines.line_draw_info") + helpHtml("intro.lines." + textId);
61425       reveal(box, startLineString);
61426       context.map().on("move.intro drawn.intro", function() {
61427         padding = 70 * Math.pow(2, context.map().zoom() - 18);
61428         box = pad(tulipRoadStart, padding, context);
61429         box.height = box.height + 100;
61430         reveal(box, startLineString, { duration: 0 });
61431       });
61432       context.on("enter.intro", function(mode) {
61433         if (mode.id !== "draw-line")
61434           return chapter.restart();
61435         continueTo(drawLine);
61436       });
61437       function continueTo(nextStep) {
61438         context.map().on("move.intro drawn.intro", null);
61439         context.on("enter.intro", null);
61440         nextStep();
61441       }
61442     }
61443     function drawLine() {
61444       if (context.mode().id !== "draw-line")
61445         return chapter.restart();
61446       _tulipRoadID = context.mode().selectedIDs()[0];
61447       context.map().centerEase(tulipRoadMidpoint, 500);
61448       timeout2(function() {
61449         var padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
61450         var box = pad(tulipRoadMidpoint, padding, context);
61451         box.height = box.height * 2;
61452         reveal(
61453           box,
61454           helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") })
61455         );
61456         context.map().on("move.intro drawn.intro", function() {
61457           padding = 200 * Math.pow(2, context.map().zoom() - 18.5);
61458           box = pad(tulipRoadMidpoint, padding, context);
61459           box.height = box.height * 2;
61460           reveal(
61461             box,
61462             helpHtml("intro.lines.intersect", { name: _t("intro.graph.name.flower-street") }),
61463             { duration: 0 }
61464           );
61465         });
61466       }, 550);
61467       context.history().on("change.intro", function() {
61468         if (isLineConnected()) {
61469           continueTo(continueLine);
61470         }
61471       });
61472       context.on("enter.intro", function(mode) {
61473         if (mode.id === "draw-line") {
61474           return;
61475         } else if (mode.id === "select") {
61476           continueTo(retryIntersect);
61477           return;
61478         } else {
61479           return chapter.restart();
61480         }
61481       });
61482       function continueTo(nextStep) {
61483         context.map().on("move.intro drawn.intro", null);
61484         context.history().on("change.intro", null);
61485         context.on("enter.intro", null);
61486         nextStep();
61487       }
61488     }
61489     function isLineConnected() {
61490       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
61491       if (!entity)
61492         return false;
61493       var drawNodes = context.graph().childNodes(entity);
61494       return drawNodes.some(function(node) {
61495         return context.graph().parentWays(node).some(function(parent) {
61496           return parent.id === flowerRoadID;
61497         });
61498       });
61499     }
61500     function retryIntersect() {
61501       select_default2(window).on("pointerdown.intro mousedown.intro", eventCancel, true);
61502       var box = pad(tulipRoadIntersection, 80, context);
61503       reveal(
61504         box,
61505         helpHtml("intro.lines.retry_intersect", { name: _t("intro.graph.name.flower-street") })
61506       );
61507       timeout2(chapter.restart, 3e3);
61508     }
61509     function continueLine() {
61510       if (context.mode().id !== "draw-line")
61511         return chapter.restart();
61512       var entity = _tulipRoadID && context.hasEntity(_tulipRoadID);
61513       if (!entity)
61514         return chapter.restart();
61515       context.map().centerEase(tulipRoadIntersection, 500);
61516       var continueLineText = helpHtml("intro.lines.continue_line") + "{br}" + helpHtml("intro.lines.finish_line_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.lines.finish_road");
61517       reveal(".surface", continueLineText);
61518       context.on("enter.intro", function(mode) {
61519         if (mode.id === "draw-line") {
61520           return;
61521         } else if (mode.id === "select") {
61522           return continueTo(chooseCategoryRoad);
61523         } else {
61524           return chapter.restart();
61525         }
61526       });
61527       function continueTo(nextStep) {
61528         context.on("enter.intro", null);
61529         nextStep();
61530       }
61531     }
61532     function chooseCategoryRoad() {
61533       if (context.mode().id !== "select")
61534         return chapter.restart();
61535       context.on("exit.intro", function() {
61536         return chapter.restart();
61537       });
61538       var button = context.container().select(".preset-category-road_minor .preset-list-button");
61539       if (button.empty())
61540         return chapter.restart();
61541       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61542       timeout2(function() {
61543         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
61544         reveal(
61545           button.node(),
61546           helpHtml("intro.lines.choose_category_road", { category: roadCategory.name() })
61547         );
61548         button.on("click.intro", function() {
61549           continueTo(choosePresetResidential);
61550         });
61551       }, 400);
61552       function continueTo(nextStep) {
61553         context.container().select(".inspector-wrap").on("wheel.intro", null);
61554         context.container().select(".preset-list-button").on("click.intro", null);
61555         context.on("exit.intro", null);
61556         nextStep();
61557       }
61558     }
61559     function choosePresetResidential() {
61560       if (context.mode().id !== "select")
61561         return chapter.restart();
61562       context.on("exit.intro", function() {
61563         return chapter.restart();
61564       });
61565       var subgrid = context.container().select(".preset-category-road_minor .subgrid");
61566       if (subgrid.empty())
61567         return chapter.restart();
61568       subgrid.selectAll(":not(.preset-highway-residential) .preset-list-button").on("click.intro", function() {
61569         continueTo(retryPresetResidential);
61570       });
61571       subgrid.selectAll(".preset-highway-residential .preset-list-button").on("click.intro", function() {
61572         continueTo(nameRoad);
61573       });
61574       timeout2(function() {
61575         reveal(
61576           subgrid.node(),
61577           helpHtml("intro.lines.choose_preset_residential", { preset: residentialPreset.name() }),
61578           { tooltipBox: ".preset-highway-residential .preset-list-button", duration: 300 }
61579         );
61580       }, 300);
61581       function continueTo(nextStep) {
61582         context.container().select(".preset-list-button").on("click.intro", null);
61583         context.on("exit.intro", null);
61584         nextStep();
61585       }
61586     }
61587     function retryPresetResidential() {
61588       if (context.mode().id !== "select")
61589         return chapter.restart();
61590       context.on("exit.intro", function() {
61591         return chapter.restart();
61592       });
61593       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
61594       timeout2(function() {
61595         var button = context.container().select(".entity-editor-pane .preset-list-button");
61596         reveal(
61597           button.node(),
61598           helpHtml("intro.lines.retry_preset_residential", { preset: residentialPreset.name() })
61599         );
61600         button.on("click.intro", function() {
61601           continueTo(chooseCategoryRoad);
61602         });
61603       }, 500);
61604       function continueTo(nextStep) {
61605         context.container().select(".inspector-wrap").on("wheel.intro", null);
61606         context.container().select(".preset-list-button").on("click.intro", null);
61607         context.on("exit.intro", null);
61608         nextStep();
61609       }
61610     }
61611     function nameRoad() {
61612       context.on("exit.intro", function() {
61613         continueTo(didNameRoad);
61614       });
61615       timeout2(function() {
61616         reveal(
61617           ".entity-editor-pane",
61618           helpHtml("intro.lines.name_road", { button: { html: icon("#iD-icon-close", "inline") } }),
61619           { tooltipClass: "intro-lines-name_road" }
61620         );
61621       }, 500);
61622       function continueTo(nextStep) {
61623         context.on("exit.intro", null);
61624         nextStep();
61625       }
61626     }
61627     function didNameRoad() {
61628       context.history().checkpoint("doneAddLine");
61629       timeout2(function() {
61630         reveal(".surface", helpHtml("intro.lines.did_name_road"), {
61631           buttonText: _t.html("intro.ok"),
61632           buttonCallback: function() {
61633             continueTo(updateLine);
61634           }
61635         });
61636       }, 500);
61637       function continueTo(nextStep) {
61638         nextStep();
61639       }
61640     }
61641     function updateLine() {
61642       context.history().reset("doneAddLine");
61643       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61644         return chapter.restart();
61645       }
61646       var msec = transitionTime(woodRoadDragMidpoint, context.map().center());
61647       if (msec) {
61648         reveal(null, null, { duration: 0 });
61649       }
61650       context.map().centerZoomEase(woodRoadDragMidpoint, 19, msec);
61651       timeout2(function() {
61652         var padding = 250 * Math.pow(2, context.map().zoom() - 19);
61653         var box = pad(woodRoadDragMidpoint, padding, context);
61654         var advance = function() {
61655           continueTo(addNode);
61656         };
61657         reveal(
61658           box,
61659           helpHtml("intro.lines.update_line"),
61660           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61661         );
61662         context.map().on("move.intro drawn.intro", function() {
61663           var padding2 = 250 * Math.pow(2, context.map().zoom() - 19);
61664           var box2 = pad(woodRoadDragMidpoint, padding2, context);
61665           reveal(
61666             box2,
61667             helpHtml("intro.lines.update_line"),
61668             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61669           );
61670         });
61671       }, msec + 100);
61672       function continueTo(nextStep) {
61673         context.map().on("move.intro drawn.intro", null);
61674         nextStep();
61675       }
61676     }
61677     function addNode() {
61678       context.history().reset("doneAddLine");
61679       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61680         return chapter.restart();
61681       }
61682       var padding = 40 * Math.pow(2, context.map().zoom() - 19);
61683       var box = pad(woodRoadAddNode, padding, context);
61684       var addNodeString = helpHtml("intro.lines.add_node" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
61685       reveal(box, addNodeString);
61686       context.map().on("move.intro drawn.intro", function() {
61687         var padding2 = 40 * Math.pow(2, context.map().zoom() - 19);
61688         var box2 = pad(woodRoadAddNode, padding2, context);
61689         reveal(box2, addNodeString, { duration: 0 });
61690       });
61691       context.history().on("change.intro", function(changed) {
61692         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61693           return continueTo(updateLine);
61694         }
61695         if (changed.created().length === 1) {
61696           timeout2(function() {
61697             continueTo(startDragEndpoint);
61698           }, 500);
61699         }
61700       });
61701       context.on("enter.intro", function(mode) {
61702         if (mode.id !== "select") {
61703           continueTo(updateLine);
61704         }
61705       });
61706       function continueTo(nextStep) {
61707         context.map().on("move.intro drawn.intro", null);
61708         context.history().on("change.intro", null);
61709         context.on("enter.intro", null);
61710         nextStep();
61711       }
61712     }
61713     function startDragEndpoint() {
61714       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61715         return continueTo(updateLine);
61716       }
61717       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
61718       var box = pad(woodRoadDragEndpoint, padding, context);
61719       var startDragString = helpHtml("intro.lines.start_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch")) + helpHtml("intro.lines.drag_to_intersection");
61720       reveal(box, startDragString);
61721       context.map().on("move.intro drawn.intro", function() {
61722         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61723           return continueTo(updateLine);
61724         }
61725         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
61726         var box2 = pad(woodRoadDragEndpoint, padding2, context);
61727         reveal(box2, startDragString, { duration: 0 });
61728         var entity = context.entity(woodRoadEndID);
61729         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) <= 4) {
61730           continueTo(finishDragEndpoint);
61731         }
61732       });
61733       function continueTo(nextStep) {
61734         context.map().on("move.intro drawn.intro", null);
61735         nextStep();
61736       }
61737     }
61738     function finishDragEndpoint() {
61739       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61740         return continueTo(updateLine);
61741       }
61742       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
61743       var box = pad(woodRoadDragEndpoint, padding, context);
61744       var finishDragString = helpHtml("intro.lines.spot_looks_good") + helpHtml("intro.lines.finish_drag_endpoint" + (context.lastPointerType() === "mouse" ? "" : "_touch"));
61745       reveal(box, finishDragString);
61746       context.map().on("move.intro drawn.intro", function() {
61747         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61748           return continueTo(updateLine);
61749         }
61750         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
61751         var box2 = pad(woodRoadDragEndpoint, padding2, context);
61752         reveal(box2, finishDragString, { duration: 0 });
61753         var entity = context.entity(woodRoadEndID);
61754         if (geoSphericalDistance(entity.loc, woodRoadDragEndpoint) > 4) {
61755           continueTo(startDragEndpoint);
61756         }
61757       });
61758       context.on("enter.intro", function() {
61759         continueTo(startDragMidpoint);
61760       });
61761       function continueTo(nextStep) {
61762         context.map().on("move.intro drawn.intro", null);
61763         context.on("enter.intro", null);
61764         nextStep();
61765       }
61766     }
61767     function startDragMidpoint() {
61768       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61769         return continueTo(updateLine);
61770       }
61771       if (context.selectedIDs().indexOf(woodRoadID) === -1) {
61772         context.enter(modeSelect(context, [woodRoadID]));
61773       }
61774       var padding = 80 * Math.pow(2, context.map().zoom() - 19);
61775       var box = pad(woodRoadDragMidpoint, padding, context);
61776       reveal(box, helpHtml("intro.lines.start_drag_midpoint"));
61777       context.map().on("move.intro drawn.intro", function() {
61778         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61779           return continueTo(updateLine);
61780         }
61781         var padding2 = 80 * Math.pow(2, context.map().zoom() - 19);
61782         var box2 = pad(woodRoadDragMidpoint, padding2, context);
61783         reveal(box2, helpHtml("intro.lines.start_drag_midpoint"), { duration: 0 });
61784       });
61785       context.history().on("change.intro", function(changed) {
61786         if (changed.created().length === 1) {
61787           continueTo(continueDragMidpoint);
61788         }
61789       });
61790       context.on("enter.intro", function(mode) {
61791         if (mode.id !== "select") {
61792           context.enter(modeSelect(context, [woodRoadID]));
61793         }
61794       });
61795       function continueTo(nextStep) {
61796         context.map().on("move.intro drawn.intro", null);
61797         context.history().on("change.intro", null);
61798         context.on("enter.intro", null);
61799         nextStep();
61800       }
61801     }
61802     function continueDragMidpoint() {
61803       if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61804         return continueTo(updateLine);
61805       }
61806       var padding = 100 * Math.pow(2, context.map().zoom() - 19);
61807       var box = pad(woodRoadDragEndpoint, padding, context);
61808       box.height += 400;
61809       var advance = function() {
61810         context.history().checkpoint("doneUpdateLine");
61811         continueTo(deleteLines);
61812       };
61813       reveal(
61814         box,
61815         helpHtml("intro.lines.continue_drag_midpoint"),
61816         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61817       );
61818       context.map().on("move.intro drawn.intro", function() {
61819         if (!context.hasEntity(woodRoadID) || !context.hasEntity(woodRoadEndID)) {
61820           return continueTo(updateLine);
61821         }
61822         var padding2 = 100 * Math.pow(2, context.map().zoom() - 19);
61823         var box2 = pad(woodRoadDragEndpoint, padding2, context);
61824         box2.height += 400;
61825         reveal(
61826           box2,
61827           helpHtml("intro.lines.continue_drag_midpoint"),
61828           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61829         );
61830       });
61831       function continueTo(nextStep) {
61832         context.map().on("move.intro drawn.intro", null);
61833         nextStep();
61834       }
61835     }
61836     function deleteLines() {
61837       context.history().reset("doneUpdateLine");
61838       context.enter(modeBrowse(context));
61839       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
61840         return chapter.restart();
61841       }
61842       var msec = transitionTime(deleteLinesLoc, context.map().center());
61843       if (msec) {
61844         reveal(null, null, { duration: 0 });
61845       }
61846       context.map().centerZoomEase(deleteLinesLoc, 18, msec);
61847       timeout2(function() {
61848         var padding = 200 * Math.pow(2, context.map().zoom() - 18);
61849         var box = pad(deleteLinesLoc, padding, context);
61850         box.top -= 200;
61851         box.height += 400;
61852         var advance = function() {
61853           continueTo(rightClickIntersection);
61854         };
61855         reveal(
61856           box,
61857           helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
61858           { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61859         );
61860         context.map().on("move.intro drawn.intro", function() {
61861           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
61862           var box2 = pad(deleteLinesLoc, padding2, context);
61863           box2.top -= 200;
61864           box2.height += 400;
61865           reveal(
61866             box2,
61867             helpHtml("intro.lines.delete_lines", { street: _t("intro.graph.name.12th-avenue") }),
61868             { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
61869           );
61870         });
61871         context.history().on("change.intro", function() {
61872           timeout2(function() {
61873             continueTo(deleteLines);
61874           }, 500);
61875         });
61876       }, msec + 100);
61877       function continueTo(nextStep) {
61878         context.map().on("move.intro drawn.intro", null);
61879         context.history().on("change.intro", null);
61880         nextStep();
61881       }
61882     }
61883     function rightClickIntersection() {
61884       context.history().reset("doneUpdateLine");
61885       context.enter(modeBrowse(context));
61886       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
61887       var rightClickString = helpHtml("intro.lines.split_street", {
61888         street1: _t("intro.graph.name.11th-avenue"),
61889         street2: _t("intro.graph.name.washington-street")
61890       }) + helpHtml("intro.lines." + (context.lastPointerType() === "mouse" ? "rightclick_intersection" : "edit_menu_intersection_touch"));
61891       timeout2(function() {
61892         var padding = 60 * Math.pow(2, context.map().zoom() - 18);
61893         var box = pad(eleventhAvenueEnd, padding, context);
61894         reveal(box, rightClickString);
61895         context.map().on("move.intro drawn.intro", function() {
61896           var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
61897           var box2 = pad(eleventhAvenueEnd, padding2, context);
61898           reveal(
61899             box2,
61900             rightClickString,
61901             { duration: 0 }
61902           );
61903         });
61904         context.on("enter.intro", function(mode) {
61905           if (mode.id !== "select")
61906             return;
61907           var ids = context.selectedIDs();
61908           if (ids.length !== 1 || ids[0] !== eleventhAvenueEndID)
61909             return;
61910           timeout2(function() {
61911             var node = selectMenuItem(context, "split").node();
61912             if (!node)
61913               return;
61914             continueTo(splitIntersection);
61915           }, 50);
61916         });
61917         context.history().on("change.intro", function() {
61918           timeout2(function() {
61919             continueTo(deleteLines);
61920           }, 300);
61921         });
61922       }, 600);
61923       function continueTo(nextStep) {
61924         context.map().on("move.intro drawn.intro", null);
61925         context.on("enter.intro", null);
61926         context.history().on("change.intro", null);
61927         nextStep();
61928       }
61929     }
61930     function splitIntersection() {
61931       if (!context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
61932         return continueTo(deleteLines);
61933       }
61934       var node = selectMenuItem(context, "split").node();
61935       if (!node) {
61936         return continueTo(rightClickIntersection);
61937       }
61938       var wasChanged = false;
61939       _washingtonSegmentID = null;
61940       reveal(
61941         ".edit-menu",
61942         helpHtml(
61943           "intro.lines.split_intersection",
61944           { street: _t("intro.graph.name.washington-street") }
61945         ),
61946         { padding: 50 }
61947       );
61948       context.map().on("move.intro drawn.intro", function() {
61949         var node2 = selectMenuItem(context, "split").node();
61950         if (!wasChanged && !node2) {
61951           return continueTo(rightClickIntersection);
61952         }
61953         reveal(
61954           ".edit-menu",
61955           helpHtml(
61956             "intro.lines.split_intersection",
61957             { street: _t("intro.graph.name.washington-street") }
61958           ),
61959           { duration: 0, padding: 50 }
61960         );
61961       });
61962       context.history().on("change.intro", function(changed) {
61963         wasChanged = true;
61964         timeout2(function() {
61965           if (context.history().undoAnnotation() === _t("operations.split.annotation.line", { n: 1 })) {
61966             _washingtonSegmentID = changed.created()[0].id;
61967             continueTo(didSplit);
61968           } else {
61969             _washingtonSegmentID = null;
61970             continueTo(retrySplit);
61971           }
61972         }, 300);
61973       });
61974       function continueTo(nextStep) {
61975         context.map().on("move.intro drawn.intro", null);
61976         context.history().on("change.intro", null);
61977         nextStep();
61978       }
61979     }
61980     function retrySplit() {
61981       context.enter(modeBrowse(context));
61982       context.map().centerZoomEase(eleventhAvenueEnd, 18, 500);
61983       var advance = function() {
61984         continueTo(rightClickIntersection);
61985       };
61986       var padding = 60 * Math.pow(2, context.map().zoom() - 18);
61987       var box = pad(eleventhAvenueEnd, padding, context);
61988       reveal(
61989         box,
61990         helpHtml("intro.lines.retry_split"),
61991         { buttonText: _t.html("intro.ok"), buttonCallback: advance }
61992       );
61993       context.map().on("move.intro drawn.intro", function() {
61994         var padding2 = 60 * Math.pow(2, context.map().zoom() - 18);
61995         var box2 = pad(eleventhAvenueEnd, padding2, context);
61996         reveal(
61997           box2,
61998           helpHtml("intro.lines.retry_split"),
61999           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: advance }
62000         );
62001       });
62002       function continueTo(nextStep) {
62003         context.map().on("move.intro drawn.intro", null);
62004         nextStep();
62005       }
62006     }
62007     function didSplit() {
62008       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62009         return continueTo(rightClickIntersection);
62010       }
62011       var ids = context.selectedIDs();
62012       var string = "intro.lines.did_split_" + (ids.length > 1 ? "multi" : "single");
62013       var street = _t("intro.graph.name.washington-street");
62014       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
62015       var box = pad(twelfthAvenue, padding, context);
62016       box.width = box.width / 2;
62017       reveal(
62018         box,
62019         helpHtml(string, { street1: street, street2: street }),
62020         { duration: 500 }
62021       );
62022       timeout2(function() {
62023         context.map().centerZoomEase(twelfthAvenue, 18, 500);
62024         context.map().on("move.intro drawn.intro", function() {
62025           var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
62026           var box2 = pad(twelfthAvenue, padding2, context);
62027           box2.width = box2.width / 2;
62028           reveal(
62029             box2,
62030             helpHtml(string, { street1: street, street2: street }),
62031             { duration: 0 }
62032           );
62033         });
62034       }, 600);
62035       context.on("enter.intro", function() {
62036         var ids2 = context.selectedIDs();
62037         if (ids2.length === 1 && ids2[0] === _washingtonSegmentID) {
62038           continueTo(multiSelect);
62039         }
62040       });
62041       context.history().on("change.intro", function() {
62042         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62043           return continueTo(rightClickIntersection);
62044         }
62045       });
62046       function continueTo(nextStep) {
62047         context.map().on("move.intro drawn.intro", null);
62048         context.on("enter.intro", null);
62049         context.history().on("change.intro", null);
62050         nextStep();
62051       }
62052     }
62053     function multiSelect() {
62054       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62055         return continueTo(rightClickIntersection);
62056       }
62057       var ids = context.selectedIDs();
62058       var hasWashington = ids.indexOf(_washingtonSegmentID) !== -1;
62059       var hasTwelfth = ids.indexOf(twelfthAvenueID) !== -1;
62060       if (hasWashington && hasTwelfth) {
62061         return continueTo(multiRightClick);
62062       } else if (!hasWashington && !hasTwelfth) {
62063         return continueTo(didSplit);
62064       }
62065       context.map().centerZoomEase(twelfthAvenue, 18, 500);
62066       timeout2(function() {
62067         var selected, other, padding, box;
62068         if (hasWashington) {
62069           selected = _t("intro.graph.name.washington-street");
62070           other = _t("intro.graph.name.12th-avenue");
62071           padding = 60 * Math.pow(2, context.map().zoom() - 18);
62072           box = pad(twelfthAvenueEnd, padding, context);
62073           box.width *= 3;
62074         } else {
62075           selected = _t("intro.graph.name.12th-avenue");
62076           other = _t("intro.graph.name.washington-street");
62077           padding = 200 * Math.pow(2, context.map().zoom() - 18);
62078           box = pad(twelfthAvenue, padding, context);
62079           box.width /= 2;
62080         }
62081         reveal(
62082           box,
62083           helpHtml(
62084             "intro.lines.multi_select",
62085             { selected, other1: other }
62086           ) + " " + helpHtml(
62087             "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
62088             { selected, other2: other }
62089           )
62090         );
62091         context.map().on("move.intro drawn.intro", function() {
62092           if (hasWashington) {
62093             selected = _t("intro.graph.name.washington-street");
62094             other = _t("intro.graph.name.12th-avenue");
62095             padding = 60 * Math.pow(2, context.map().zoom() - 18);
62096             box = pad(twelfthAvenueEnd, padding, context);
62097             box.width *= 3;
62098           } else {
62099             selected = _t("intro.graph.name.12th-avenue");
62100             other = _t("intro.graph.name.washington-street");
62101             padding = 200 * Math.pow(2, context.map().zoom() - 18);
62102             box = pad(twelfthAvenue, padding, context);
62103             box.width /= 2;
62104           }
62105           reveal(
62106             box,
62107             helpHtml(
62108               "intro.lines.multi_select",
62109               { selected, other1: other }
62110             ) + " " + helpHtml(
62111               "intro.lines.add_to_selection_" + (context.lastPointerType() === "mouse" ? "click" : "touch"),
62112               { selected, other2: other }
62113             ),
62114             { duration: 0 }
62115           );
62116         });
62117         context.on("enter.intro", function() {
62118           continueTo(multiSelect);
62119         });
62120         context.history().on("change.intro", function() {
62121           if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62122             return continueTo(rightClickIntersection);
62123           }
62124         });
62125       }, 600);
62126       function continueTo(nextStep) {
62127         context.map().on("move.intro drawn.intro", null);
62128         context.on("enter.intro", null);
62129         context.history().on("change.intro", null);
62130         nextStep();
62131       }
62132     }
62133     function multiRightClick() {
62134       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62135         return continueTo(rightClickIntersection);
62136       }
62137       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
62138       var box = pad(twelfthAvenue, padding, context);
62139       var rightClickString = helpHtml("intro.lines.multi_select_success") + helpHtml("intro.lines.multi_" + (context.lastPointerType() === "mouse" ? "rightclick" : "edit_menu_touch"));
62140       reveal(box, rightClickString);
62141       context.map().on("move.intro drawn.intro", function() {
62142         var padding2 = 200 * Math.pow(2, context.map().zoom() - 18);
62143         var box2 = pad(twelfthAvenue, padding2, context);
62144         reveal(box2, rightClickString, { duration: 0 });
62145       });
62146       context.ui().editMenu().on("toggled.intro", function(open) {
62147         if (!open)
62148           return;
62149         timeout2(function() {
62150           var ids = context.selectedIDs();
62151           if (ids.length === 2 && ids.indexOf(twelfthAvenueID) !== -1 && ids.indexOf(_washingtonSegmentID) !== -1) {
62152             var node = selectMenuItem(context, "delete").node();
62153             if (!node)
62154               return;
62155             continueTo(multiDelete);
62156           } else if (ids.length === 1 && ids.indexOf(_washingtonSegmentID) !== -1) {
62157             return continueTo(multiSelect);
62158           } else {
62159             return continueTo(didSplit);
62160           }
62161         }, 300);
62162       });
62163       context.history().on("change.intro", function() {
62164         if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62165           return continueTo(rightClickIntersection);
62166         }
62167       });
62168       function continueTo(nextStep) {
62169         context.map().on("move.intro drawn.intro", null);
62170         context.ui().editMenu().on("toggled.intro", null);
62171         context.history().on("change.intro", null);
62172         nextStep();
62173       }
62174     }
62175     function multiDelete() {
62176       if (!_washingtonSegmentID || !context.hasEntity(_washingtonSegmentID) || !context.hasEntity(washingtonStreetID) || !context.hasEntity(twelfthAvenueID) || !context.hasEntity(eleventhAvenueEndID)) {
62177         return continueTo(rightClickIntersection);
62178       }
62179       var node = selectMenuItem(context, "delete").node();
62180       if (!node)
62181         return continueTo(multiRightClick);
62182       reveal(
62183         ".edit-menu",
62184         helpHtml("intro.lines.multi_delete"),
62185         { padding: 50 }
62186       );
62187       context.map().on("move.intro drawn.intro", function() {
62188         reveal(
62189           ".edit-menu",
62190           helpHtml("intro.lines.multi_delete"),
62191           { duration: 0, padding: 50 }
62192         );
62193       });
62194       context.on("exit.intro", function() {
62195         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
62196           return continueTo(multiSelect);
62197         }
62198       });
62199       context.history().on("change.intro", function() {
62200         if (context.hasEntity(_washingtonSegmentID) || context.hasEntity(twelfthAvenueID)) {
62201           continueTo(retryDelete);
62202         } else {
62203           continueTo(play);
62204         }
62205       });
62206       function continueTo(nextStep) {
62207         context.map().on("move.intro drawn.intro", null);
62208         context.on("exit.intro", null);
62209         context.history().on("change.intro", null);
62210         nextStep();
62211       }
62212     }
62213     function retryDelete() {
62214       context.enter(modeBrowse(context));
62215       var padding = 200 * Math.pow(2, context.map().zoom() - 18);
62216       var box = pad(twelfthAvenue, padding, context);
62217       reveal(box, helpHtml("intro.lines.retry_delete"), {
62218         buttonText: _t.html("intro.ok"),
62219         buttonCallback: function() {
62220           continueTo(multiSelect);
62221         }
62222       });
62223       function continueTo(nextStep) {
62224         nextStep();
62225       }
62226     }
62227     function play() {
62228       dispatch14.call("done");
62229       reveal(
62230         ".ideditor",
62231         helpHtml("intro.lines.play", { next: _t("intro.buildings.title") }),
62232         {
62233           tooltipBox: ".intro-nav-wrap .chapter-building",
62234           buttonText: _t.html("intro.ok"),
62235           buttonCallback: function() {
62236             reveal(".ideditor");
62237           }
62238         }
62239       );
62240     }
62241     chapter.enter = function() {
62242       addLine();
62243     };
62244     chapter.exit = function() {
62245       timeouts.forEach(window.clearTimeout);
62246       select_default2(window).on("pointerdown.intro mousedown.intro", null, true);
62247       context.on("enter.intro exit.intro", null);
62248       context.map().on("move.intro drawn.intro", null);
62249       context.history().on("change.intro", null);
62250       context.container().select(".inspector-wrap").on("wheel.intro", null);
62251       context.container().select(".preset-list-button").on("click.intro", null);
62252     };
62253     chapter.restart = function() {
62254       chapter.exit();
62255       chapter.enter();
62256     };
62257     return utilRebind(chapter, dispatch14, "on");
62258   }
62259
62260   // modules/ui/intro/building.js
62261   function uiIntroBuilding(context, reveal) {
62262     var dispatch14 = dispatch_default("done");
62263     var house = [-85.62815, 41.95638];
62264     var tank = [-85.62732, 41.95347];
62265     var buildingCatetory = _mainPresetIndex.item("category-building");
62266     var housePreset = _mainPresetIndex.item("building/house");
62267     var tankPreset = _mainPresetIndex.item("man_made/storage_tank");
62268     var timeouts = [];
62269     var _houseID = null;
62270     var _tankID = null;
62271     var chapter = {
62272       title: "intro.buildings.title"
62273     };
62274     function timeout2(f2, t2) {
62275       timeouts.push(window.setTimeout(f2, t2));
62276     }
62277     function eventCancel(d3_event) {
62278       d3_event.stopPropagation();
62279       d3_event.preventDefault();
62280     }
62281     function revealHouse(center, text, options2) {
62282       var padding = 160 * Math.pow(2, context.map().zoom() - 20);
62283       var box = pad(center, padding, context);
62284       reveal(box, text, options2);
62285     }
62286     function revealTank(center, text, options2) {
62287       var padding = 190 * Math.pow(2, context.map().zoom() - 19.5);
62288       var box = pad(center, padding, context);
62289       reveal(box, text, options2);
62290     }
62291     function addHouse() {
62292       context.enter(modeBrowse(context));
62293       context.history().reset("initial");
62294       _houseID = null;
62295       var msec = transitionTime(house, context.map().center());
62296       if (msec) {
62297         reveal(null, null, { duration: 0 });
62298       }
62299       context.map().centerZoomEase(house, 19, msec);
62300       timeout2(function() {
62301         var tooltip = reveal(
62302           "button.add-area",
62303           helpHtml("intro.buildings.add_building")
62304         );
62305         tooltip.selectAll(".popover-inner").insert("svg", "span").attr("class", "tooltip-illustration").append("use").attr("xlink:href", "#iD-graphic-buildings");
62306         context.on("enter.intro", function(mode) {
62307           if (mode.id !== "add-area")
62308             return;
62309           continueTo(startHouse);
62310         });
62311       }, msec + 100);
62312       function continueTo(nextStep) {
62313         context.on("enter.intro", null);
62314         nextStep();
62315       }
62316     }
62317     function startHouse() {
62318       if (context.mode().id !== "add-area") {
62319         return continueTo(addHouse);
62320       }
62321       _houseID = null;
62322       context.map().zoomEase(20, 500);
62323       timeout2(function() {
62324         var startString = helpHtml("intro.buildings.start_building") + helpHtml("intro.buildings.building_corner_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
62325         revealHouse(house, startString);
62326         context.map().on("move.intro drawn.intro", function() {
62327           revealHouse(house, startString, { duration: 0 });
62328         });
62329         context.on("enter.intro", function(mode) {
62330           if (mode.id !== "draw-area")
62331             return chapter.restart();
62332           continueTo(continueHouse);
62333         });
62334       }, 550);
62335       function continueTo(nextStep) {
62336         context.map().on("move.intro drawn.intro", null);
62337         context.on("enter.intro", null);
62338         nextStep();
62339       }
62340     }
62341     function continueHouse() {
62342       if (context.mode().id !== "draw-area") {
62343         return continueTo(addHouse);
62344       }
62345       _houseID = null;
62346       var continueString = helpHtml("intro.buildings.continue_building") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_building");
62347       revealHouse(house, continueString);
62348       context.map().on("move.intro drawn.intro", function() {
62349         revealHouse(house, continueString, { duration: 0 });
62350       });
62351       context.on("enter.intro", function(mode) {
62352         if (mode.id === "draw-area") {
62353           return;
62354         } else if (mode.id === "select") {
62355           var graph = context.graph();
62356           var way = context.entity(context.selectedIDs()[0]);
62357           var nodes = graph.childNodes(way);
62358           var points = utilArrayUniq(nodes).map(function(n3) {
62359             return context.projection(n3.loc);
62360           });
62361           if (isMostlySquare(points)) {
62362             _houseID = way.id;
62363             return continueTo(chooseCategoryBuilding);
62364           } else {
62365             return continueTo(retryHouse);
62366           }
62367         } else {
62368           return chapter.restart();
62369         }
62370       });
62371       function continueTo(nextStep) {
62372         context.map().on("move.intro drawn.intro", null);
62373         context.on("enter.intro", null);
62374         nextStep();
62375       }
62376     }
62377     function retryHouse() {
62378       var onClick = function() {
62379         continueTo(addHouse);
62380       };
62381       revealHouse(
62382         house,
62383         helpHtml("intro.buildings.retry_building"),
62384         { buttonText: _t.html("intro.ok"), buttonCallback: onClick }
62385       );
62386       context.map().on("move.intro drawn.intro", function() {
62387         revealHouse(
62388           house,
62389           helpHtml("intro.buildings.retry_building"),
62390           { duration: 0, buttonText: _t.html("intro.ok"), buttonCallback: onClick }
62391         );
62392       });
62393       function continueTo(nextStep) {
62394         context.map().on("move.intro drawn.intro", null);
62395         nextStep();
62396       }
62397     }
62398     function chooseCategoryBuilding() {
62399       if (!_houseID || !context.hasEntity(_houseID)) {
62400         return addHouse();
62401       }
62402       var ids = context.selectedIDs();
62403       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
62404         context.enter(modeSelect(context, [_houseID]));
62405       }
62406       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62407       timeout2(function() {
62408         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62409         var button = context.container().select(".preset-category-building .preset-list-button");
62410         reveal(
62411           button.node(),
62412           helpHtml("intro.buildings.choose_category_building", { category: buildingCatetory.name() })
62413         );
62414         button.on("click.intro", function() {
62415           button.on("click.intro", null);
62416           continueTo(choosePresetHouse);
62417         });
62418       }, 400);
62419       context.on("enter.intro", function(mode) {
62420         if (!_houseID || !context.hasEntity(_houseID)) {
62421           return continueTo(addHouse);
62422         }
62423         var ids2 = context.selectedIDs();
62424         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
62425           return continueTo(chooseCategoryBuilding);
62426         }
62427       });
62428       function continueTo(nextStep) {
62429         context.container().select(".inspector-wrap").on("wheel.intro", null);
62430         context.container().select(".preset-list-button").on("click.intro", null);
62431         context.on("enter.intro", null);
62432         nextStep();
62433       }
62434     }
62435     function choosePresetHouse() {
62436       if (!_houseID || !context.hasEntity(_houseID)) {
62437         return addHouse();
62438       }
62439       var ids = context.selectedIDs();
62440       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
62441         context.enter(modeSelect(context, [_houseID]));
62442       }
62443       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62444       timeout2(function() {
62445         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62446         var button = context.container().select(".preset-building-house .preset-list-button");
62447         reveal(
62448           button.node(),
62449           helpHtml("intro.buildings.choose_preset_house", { preset: housePreset.name() }),
62450           { duration: 300 }
62451         );
62452         button.on("click.intro", function() {
62453           button.on("click.intro", null);
62454           continueTo(closeEditorHouse);
62455         });
62456       }, 400);
62457       context.on("enter.intro", function(mode) {
62458         if (!_houseID || !context.hasEntity(_houseID)) {
62459           return continueTo(addHouse);
62460         }
62461         var ids2 = context.selectedIDs();
62462         if (mode.id !== "select" || !ids2.length || ids2[0] !== _houseID) {
62463           return continueTo(chooseCategoryBuilding);
62464         }
62465       });
62466       function continueTo(nextStep) {
62467         context.container().select(".inspector-wrap").on("wheel.intro", null);
62468         context.container().select(".preset-list-button").on("click.intro", null);
62469         context.on("enter.intro", null);
62470         nextStep();
62471       }
62472     }
62473     function closeEditorHouse() {
62474       if (!_houseID || !context.hasEntity(_houseID)) {
62475         return addHouse();
62476       }
62477       var ids = context.selectedIDs();
62478       if (context.mode().id !== "select" || !ids.length || ids[0] !== _houseID) {
62479         context.enter(modeSelect(context, [_houseID]));
62480       }
62481       context.history().checkpoint("hasHouse");
62482       context.on("exit.intro", function() {
62483         continueTo(rightClickHouse);
62484       });
62485       timeout2(function() {
62486         reveal(
62487           ".entity-editor-pane",
62488           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
62489         );
62490       }, 500);
62491       function continueTo(nextStep) {
62492         context.on("exit.intro", null);
62493         nextStep();
62494       }
62495     }
62496     function rightClickHouse() {
62497       if (!_houseID)
62498         return chapter.restart();
62499       context.enter(modeBrowse(context));
62500       context.history().reset("hasHouse");
62501       var zoom = context.map().zoom();
62502       if (zoom < 20) {
62503         zoom = 20;
62504       }
62505       context.map().centerZoomEase(house, zoom, 500);
62506       context.on("enter.intro", function(mode) {
62507         if (mode.id !== "select")
62508           return;
62509         var ids = context.selectedIDs();
62510         if (ids.length !== 1 || ids[0] !== _houseID)
62511           return;
62512         timeout2(function() {
62513           var node = selectMenuItem(context, "orthogonalize").node();
62514           if (!node)
62515             return;
62516           continueTo(clickSquare);
62517         }, 50);
62518       });
62519       context.map().on("move.intro drawn.intro", function() {
62520         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_building" : "edit_menu_building_touch"));
62521         revealHouse(house, rightclickString, { duration: 0 });
62522       });
62523       context.history().on("change.intro", function() {
62524         continueTo(rightClickHouse);
62525       });
62526       function continueTo(nextStep) {
62527         context.on("enter.intro", null);
62528         context.map().on("move.intro drawn.intro", null);
62529         context.history().on("change.intro", null);
62530         nextStep();
62531       }
62532     }
62533     function clickSquare() {
62534       if (!_houseID)
62535         return chapter.restart();
62536       var entity = context.hasEntity(_houseID);
62537       if (!entity)
62538         return continueTo(rightClickHouse);
62539       var node = selectMenuItem(context, "orthogonalize").node();
62540       if (!node) {
62541         return continueTo(rightClickHouse);
62542       }
62543       var wasChanged = false;
62544       reveal(
62545         ".edit-menu",
62546         helpHtml("intro.buildings.square_building"),
62547         { padding: 50 }
62548       );
62549       context.on("enter.intro", function(mode) {
62550         if (mode.id === "browse") {
62551           continueTo(rightClickHouse);
62552         } else if (mode.id === "move" || mode.id === "rotate") {
62553           continueTo(retryClickSquare);
62554         }
62555       });
62556       context.map().on("move.intro", function() {
62557         var node2 = selectMenuItem(context, "orthogonalize").node();
62558         if (!wasChanged && !node2) {
62559           return continueTo(rightClickHouse);
62560         }
62561         reveal(
62562           ".edit-menu",
62563           helpHtml("intro.buildings.square_building"),
62564           { duration: 0, padding: 50 }
62565         );
62566       });
62567       context.history().on("change.intro", function() {
62568         wasChanged = true;
62569         context.history().on("change.intro", null);
62570         timeout2(function() {
62571           if (context.history().undoAnnotation() === _t("operations.orthogonalize.annotation.feature", { n: 1 })) {
62572             continueTo(doneSquare);
62573           } else {
62574             continueTo(retryClickSquare);
62575           }
62576         }, 500);
62577       });
62578       function continueTo(nextStep) {
62579         context.on("enter.intro", null);
62580         context.map().on("move.intro", null);
62581         context.history().on("change.intro", null);
62582         nextStep();
62583       }
62584     }
62585     function retryClickSquare() {
62586       context.enter(modeBrowse(context));
62587       revealHouse(house, helpHtml("intro.buildings.retry_square"), {
62588         buttonText: _t.html("intro.ok"),
62589         buttonCallback: function() {
62590           continueTo(rightClickHouse);
62591         }
62592       });
62593       function continueTo(nextStep) {
62594         nextStep();
62595       }
62596     }
62597     function doneSquare() {
62598       context.history().checkpoint("doneSquare");
62599       revealHouse(house, helpHtml("intro.buildings.done_square"), {
62600         buttonText: _t.html("intro.ok"),
62601         buttonCallback: function() {
62602           continueTo(addTank);
62603         }
62604       });
62605       function continueTo(nextStep) {
62606         nextStep();
62607       }
62608     }
62609     function addTank() {
62610       context.enter(modeBrowse(context));
62611       context.history().reset("doneSquare");
62612       _tankID = null;
62613       var msec = transitionTime(tank, context.map().center());
62614       if (msec) {
62615         reveal(null, null, { duration: 0 });
62616       }
62617       context.map().centerZoomEase(tank, 19.5, msec);
62618       timeout2(function() {
62619         reveal(
62620           "button.add-area",
62621           helpHtml("intro.buildings.add_tank")
62622         );
62623         context.on("enter.intro", function(mode) {
62624           if (mode.id !== "add-area")
62625             return;
62626           continueTo(startTank);
62627         });
62628       }, msec + 100);
62629       function continueTo(nextStep) {
62630         context.on("enter.intro", null);
62631         nextStep();
62632       }
62633     }
62634     function startTank() {
62635       if (context.mode().id !== "add-area") {
62636         return continueTo(addTank);
62637       }
62638       _tankID = null;
62639       timeout2(function() {
62640         var startString = helpHtml("intro.buildings.start_tank") + helpHtml("intro.buildings.tank_edge_" + (context.lastPointerType() === "mouse" ? "click" : "tap"));
62641         revealTank(tank, startString);
62642         context.map().on("move.intro drawn.intro", function() {
62643           revealTank(tank, startString, { duration: 0 });
62644         });
62645         context.on("enter.intro", function(mode) {
62646           if (mode.id !== "draw-area")
62647             return chapter.restart();
62648           continueTo(continueTank);
62649         });
62650       }, 550);
62651       function continueTo(nextStep) {
62652         context.map().on("move.intro drawn.intro", null);
62653         context.on("enter.intro", null);
62654         nextStep();
62655       }
62656     }
62657     function continueTank() {
62658       if (context.mode().id !== "draw-area") {
62659         return continueTo(addTank);
62660       }
62661       _tankID = null;
62662       var continueString = helpHtml("intro.buildings.continue_tank") + "{br}" + helpHtml("intro.areas.finish_area_" + (context.lastPointerType() === "mouse" ? "click" : "tap")) + helpHtml("intro.buildings.finish_tank");
62663       revealTank(tank, continueString);
62664       context.map().on("move.intro drawn.intro", function() {
62665         revealTank(tank, continueString, { duration: 0 });
62666       });
62667       context.on("enter.intro", function(mode) {
62668         if (mode.id === "draw-area") {
62669           return;
62670         } else if (mode.id === "select") {
62671           _tankID = context.selectedIDs()[0];
62672           return continueTo(searchPresetTank);
62673         } else {
62674           return continueTo(addTank);
62675         }
62676       });
62677       function continueTo(nextStep) {
62678         context.map().on("move.intro drawn.intro", null);
62679         context.on("enter.intro", null);
62680         nextStep();
62681       }
62682     }
62683     function searchPresetTank() {
62684       if (!_tankID || !context.hasEntity(_tankID)) {
62685         return addTank();
62686       }
62687       var ids = context.selectedIDs();
62688       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
62689         context.enter(modeSelect(context, [_tankID]));
62690       }
62691       context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62692       timeout2(function() {
62693         context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62694         context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
62695         reveal(
62696           ".preset-search-input",
62697           helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
62698         );
62699       }, 400);
62700       context.on("enter.intro", function(mode) {
62701         if (!_tankID || !context.hasEntity(_tankID)) {
62702           return continueTo(addTank);
62703         }
62704         var ids2 = context.selectedIDs();
62705         if (mode.id !== "select" || !ids2.length || ids2[0] !== _tankID) {
62706           context.enter(modeSelect(context, [_tankID]));
62707           context.container().select(".inspector-wrap .panewrap").style("right", "-100%");
62708           context.container().select(".inspector-wrap").on("wheel.intro", eventCancel);
62709           context.container().select(".preset-search-input").on("keydown.intro", null).on("keyup.intro", checkPresetSearch);
62710           reveal(
62711             ".preset-search-input",
62712             helpHtml("intro.buildings.search_tank", { preset: tankPreset.name() })
62713           );
62714           context.history().on("change.intro", null);
62715         }
62716       });
62717       function checkPresetSearch() {
62718         var first = context.container().select(".preset-list-item:first-child");
62719         if (first.classed("preset-man_made-storage_tank")) {
62720           reveal(
62721             first.select(".preset-list-button").node(),
62722             helpHtml("intro.buildings.choose_tank", { preset: tankPreset.name() }),
62723             { duration: 300 }
62724           );
62725           context.container().select(".preset-search-input").on("keydown.intro", eventCancel, true).on("keyup.intro", null);
62726           context.history().on("change.intro", function() {
62727             continueTo(closeEditorTank);
62728           });
62729         }
62730       }
62731       function continueTo(nextStep) {
62732         context.container().select(".inspector-wrap").on("wheel.intro", null);
62733         context.on("enter.intro", null);
62734         context.history().on("change.intro", null);
62735         context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
62736         nextStep();
62737       }
62738     }
62739     function closeEditorTank() {
62740       if (!_tankID || !context.hasEntity(_tankID)) {
62741         return addTank();
62742       }
62743       var ids = context.selectedIDs();
62744       if (context.mode().id !== "select" || !ids.length || ids[0] !== _tankID) {
62745         context.enter(modeSelect(context, [_tankID]));
62746       }
62747       context.history().checkpoint("hasTank");
62748       context.on("exit.intro", function() {
62749         continueTo(rightClickTank);
62750       });
62751       timeout2(function() {
62752         reveal(
62753           ".entity-editor-pane",
62754           helpHtml("intro.buildings.close", { button: { html: icon("#iD-icon-close", "inline") } })
62755         );
62756       }, 500);
62757       function continueTo(nextStep) {
62758         context.on("exit.intro", null);
62759         nextStep();
62760       }
62761     }
62762     function rightClickTank() {
62763       if (!_tankID)
62764         return continueTo(addTank);
62765       context.enter(modeBrowse(context));
62766       context.history().reset("hasTank");
62767       context.map().centerEase(tank, 500);
62768       timeout2(function() {
62769         context.on("enter.intro", function(mode) {
62770           if (mode.id !== "select")
62771             return;
62772           var ids = context.selectedIDs();
62773           if (ids.length !== 1 || ids[0] !== _tankID)
62774             return;
62775           timeout2(function() {
62776             var node = selectMenuItem(context, "circularize").node();
62777             if (!node)
62778               return;
62779             continueTo(clickCircle);
62780           }, 50);
62781         });
62782         var rightclickString = helpHtml("intro.buildings." + (context.lastPointerType() === "mouse" ? "rightclick_tank" : "edit_menu_tank_touch"));
62783         revealTank(tank, rightclickString);
62784         context.map().on("move.intro drawn.intro", function() {
62785           revealTank(tank, rightclickString, { duration: 0 });
62786         });
62787         context.history().on("change.intro", function() {
62788           continueTo(rightClickTank);
62789         });
62790       }, 600);
62791       function continueTo(nextStep) {
62792         context.on("enter.intro", null);
62793         context.map().on("move.intro drawn.intro", null);
62794         context.history().on("change.intro", null);
62795         nextStep();
62796       }
62797     }
62798     function clickCircle() {
62799       if (!_tankID)
62800         return chapter.restart();
62801       var entity = context.hasEntity(_tankID);
62802       if (!entity)
62803         return continueTo(rightClickTank);
62804       var node = selectMenuItem(context, "circularize").node();
62805       if (!node) {
62806         return continueTo(rightClickTank);
62807       }
62808       var wasChanged = false;
62809       reveal(
62810         ".edit-menu",
62811         helpHtml("intro.buildings.circle_tank"),
62812         { padding: 50 }
62813       );
62814       context.on("enter.intro", function(mode) {
62815         if (mode.id === "browse") {
62816           continueTo(rightClickTank);
62817         } else if (mode.id === "move" || mode.id === "rotate") {
62818           continueTo(retryClickCircle);
62819         }
62820       });
62821       context.map().on("move.intro", function() {
62822         var node2 = selectMenuItem(context, "circularize").node();
62823         if (!wasChanged && !node2) {
62824           return continueTo(rightClickTank);
62825         }
62826         reveal(
62827           ".edit-menu",
62828           helpHtml("intro.buildings.circle_tank"),
62829           { duration: 0, padding: 50 }
62830         );
62831       });
62832       context.history().on("change.intro", function() {
62833         wasChanged = true;
62834         context.history().on("change.intro", null);
62835         timeout2(function() {
62836           if (context.history().undoAnnotation() === _t("operations.circularize.annotation.feature", { n: 1 })) {
62837             continueTo(play);
62838           } else {
62839             continueTo(retryClickCircle);
62840           }
62841         }, 500);
62842       });
62843       function continueTo(nextStep) {
62844         context.on("enter.intro", null);
62845         context.map().on("move.intro", null);
62846         context.history().on("change.intro", null);
62847         nextStep();
62848       }
62849     }
62850     function retryClickCircle() {
62851       context.enter(modeBrowse(context));
62852       revealTank(tank, helpHtml("intro.buildings.retry_circle"), {
62853         buttonText: _t.html("intro.ok"),
62854         buttonCallback: function() {
62855           continueTo(rightClickTank);
62856         }
62857       });
62858       function continueTo(nextStep) {
62859         nextStep();
62860       }
62861     }
62862     function play() {
62863       dispatch14.call("done");
62864       reveal(
62865         ".ideditor",
62866         helpHtml("intro.buildings.play", { next: _t("intro.startediting.title") }),
62867         {
62868           tooltipBox: ".intro-nav-wrap .chapter-startEditing",
62869           buttonText: _t.html("intro.ok"),
62870           buttonCallback: function() {
62871             reveal(".ideditor");
62872           }
62873         }
62874       );
62875     }
62876     chapter.enter = function() {
62877       addHouse();
62878     };
62879     chapter.exit = function() {
62880       timeouts.forEach(window.clearTimeout);
62881       context.on("enter.intro exit.intro", null);
62882       context.map().on("move.intro drawn.intro", null);
62883       context.history().on("change.intro", null);
62884       context.container().select(".inspector-wrap").on("wheel.intro", null);
62885       context.container().select(".preset-search-input").on("keydown.intro keyup.intro", null);
62886       context.container().select(".more-fields .combobox-input").on("click.intro", null);
62887     };
62888     chapter.restart = function() {
62889       chapter.exit();
62890       chapter.enter();
62891     };
62892     return utilRebind(chapter, dispatch14, "on");
62893   }
62894
62895   // modules/ui/intro/start_editing.js
62896   function uiIntroStartEditing(context, reveal) {
62897     var dispatch14 = dispatch_default("done", "startEditing");
62898     var modalSelection = select_default2(null);
62899     var chapter = {
62900       title: "intro.startediting.title"
62901     };
62902     function showHelp() {
62903       reveal(
62904         ".map-control.help-control",
62905         helpHtml("intro.startediting.help"),
62906         {
62907           buttonText: _t.html("intro.ok"),
62908           buttonCallback: function() {
62909             shortcuts();
62910           }
62911         }
62912       );
62913     }
62914     function shortcuts() {
62915       reveal(
62916         ".map-control.help-control",
62917         helpHtml("intro.startediting.shortcuts"),
62918         {
62919           buttonText: _t.html("intro.ok"),
62920           buttonCallback: function() {
62921             showSave();
62922           }
62923         }
62924       );
62925     }
62926     function showSave() {
62927       context.container().selectAll(".shaded").remove();
62928       reveal(
62929         ".top-toolbar button.save",
62930         helpHtml("intro.startediting.save"),
62931         {
62932           buttonText: _t.html("intro.ok"),
62933           buttonCallback: function() {
62934             showStart();
62935           }
62936         }
62937       );
62938     }
62939     function showStart() {
62940       context.container().selectAll(".shaded").remove();
62941       modalSelection = uiModal(context.container());
62942       modalSelection.select(".modal").attr("class", "modal-splash modal");
62943       modalSelection.selectAll(".close").remove();
62944       var startbutton = modalSelection.select(".content").attr("class", "fillL").append("button").attr("class", "modal-section huge-modal-button").on("click", function() {
62945         modalSelection.remove();
62946       });
62947       startbutton.append("svg").attr("class", "illustration").append("use").attr("xlink:href", "#iD-logo-walkthrough");
62948       startbutton.append("h2").call(_t.append("intro.startediting.start"));
62949       dispatch14.call("startEditing");
62950     }
62951     chapter.enter = function() {
62952       showHelp();
62953     };
62954     chapter.exit = function() {
62955       modalSelection.remove();
62956       context.container().selectAll(".shaded").remove();
62957     };
62958     return utilRebind(chapter, dispatch14, "on");
62959   }
62960
62961   // modules/ui/intro/intro.js
62962   var chapterUi = {
62963     welcome: uiIntroWelcome,
62964     navigation: uiIntroNavigation,
62965     point: uiIntroPoint,
62966     area: uiIntroArea,
62967     line: uiIntroLine,
62968     building: uiIntroBuilding,
62969     startEditing: uiIntroStartEditing
62970   };
62971   var chapterFlow = [
62972     "welcome",
62973     "navigation",
62974     "point",
62975     "area",
62976     "line",
62977     "building",
62978     "startEditing"
62979   ];
62980   function uiIntro(context) {
62981     const INTRO_IMAGERY = "EsriWorldImageryClarity";
62982     let _introGraph = {};
62983     let _currChapter;
62984     function intro(selection2) {
62985       _mainFileFetcher.get("intro_graph").then((dataIntroGraph) => {
62986         for (let id2 in dataIntroGraph) {
62987           if (!_introGraph[id2]) {
62988             _introGraph[id2] = osmEntity(localize(dataIntroGraph[id2]));
62989           }
62990         }
62991         selection2.call(startIntro);
62992       }).catch(function() {
62993       });
62994     }
62995     function startIntro(selection2) {
62996       context.enter(modeBrowse(context));
62997       let osm = context.connection();
62998       let history = context.history().toJSON();
62999       let hash = window.location.hash;
63000       let center = context.map().center();
63001       let zoom = context.map().zoom();
63002       let background = context.background().baseLayerSource();
63003       let overlays = context.background().overlayLayerSources();
63004       let opacity = context.container().selectAll(".main-map .layer-background").style("opacity");
63005       let caches = osm && osm.caches();
63006       let baseEntities = context.history().graph().base().entities;
63007       context.ui().sidebar.expand();
63008       context.container().selectAll("button.sidebar-toggle").classed("disabled", true);
63009       context.inIntro(true);
63010       if (osm) {
63011         osm.toggle(false).reset();
63012       }
63013       context.history().reset();
63014       context.history().merge(Object.values(coreGraph().load(_introGraph).entities));
63015       context.history().checkpoint("initial");
63016       let imagery = context.background().findSource(INTRO_IMAGERY);
63017       if (imagery) {
63018         context.background().baseLayerSource(imagery);
63019       } else {
63020         context.background().bing();
63021       }
63022       overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
63023       let layers = context.layers();
63024       layers.all().forEach((item) => {
63025         if (typeof item.layer.enabled === "function") {
63026           item.layer.enabled(item.id === "osm");
63027         }
63028       });
63029       context.container().selectAll(".main-map .layer-background").style("opacity", 1);
63030       let curtain = uiCurtain(context.container().node());
63031       selection2.call(curtain);
63032       corePreferences("walkthrough_started", "yes");
63033       let storedProgress = corePreferences("walkthrough_progress") || "";
63034       let progress = storedProgress.split(";").filter(Boolean);
63035       let chapters = chapterFlow.map((chapter, i3) => {
63036         let s2 = chapterUi[chapter](context, curtain.reveal).on("done", () => {
63037           buttons.filter((d2) => d2.title === s2.title).classed("finished", true);
63038           if (i3 < chapterFlow.length - 1) {
63039             const next = chapterFlow[i3 + 1];
63040             context.container().select("button.chapter-".concat(next)).classed("next", true);
63041           }
63042           progress.push(chapter);
63043           corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
63044         });
63045         return s2;
63046       });
63047       chapters[chapters.length - 1].on("startEditing", () => {
63048         progress.push("startEditing");
63049         corePreferences("walkthrough_progress", utilArrayUniq(progress).join(";"));
63050         let incomplete = utilArrayDifference(chapterFlow, progress);
63051         if (!incomplete.length) {
63052           corePreferences("walkthrough_completed", "yes");
63053         }
63054         curtain.remove();
63055         navwrap.remove();
63056         context.container().selectAll(".main-map .layer-background").style("opacity", opacity);
63057         context.container().selectAll("button.sidebar-toggle").classed("disabled", false);
63058         if (osm) {
63059           osm.toggle(true).reset().caches(caches);
63060         }
63061         context.history().reset().merge(Object.values(baseEntities));
63062         context.background().baseLayerSource(background);
63063         overlays.forEach((d2) => context.background().toggleOverlayLayer(d2));
63064         if (history) {
63065           context.history().fromJSON(history, false);
63066         }
63067         context.map().centerZoom(center, zoom);
63068         window.location.replace(hash);
63069         context.inIntro(false);
63070       });
63071       let navwrap = selection2.append("div").attr("class", "intro-nav-wrap fillD");
63072       navwrap.append("svg").attr("class", "intro-nav-wrap-logo").append("use").attr("xlink:href", "#iD-logo-walkthrough");
63073       let buttonwrap = navwrap.append("div").attr("class", "joined").selectAll("button.chapter");
63074       let buttons = buttonwrap.data(chapters).enter().append("button").attr("class", (d2, i3) => "chapter chapter-".concat(chapterFlow[i3])).on("click", enterChapter);
63075       buttons.append("span").html((d2) => _t.html(d2.title));
63076       buttons.append("span").attr("class", "status").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
63077       enterChapter(null, chapters[0]);
63078       function enterChapter(d3_event, newChapter) {
63079         if (_currChapter) {
63080           _currChapter.exit();
63081         }
63082         context.enter(modeBrowse(context));
63083         _currChapter = newChapter;
63084         _currChapter.enter();
63085         buttons.classed("next", false).classed("active", (d2) => d2.title === _currChapter.title);
63086       }
63087     }
63088     return intro;
63089   }
63090
63091   // modules/ui/issues_info.js
63092   function uiIssuesInfo(context) {
63093     var warningsItem = {
63094       id: "warnings",
63095       count: 0,
63096       iconID: "iD-icon-alert",
63097       descriptionID: "issues.warnings_and_errors"
63098     };
63099     var resolvedItem = {
63100       id: "resolved",
63101       count: 0,
63102       iconID: "iD-icon-apply",
63103       descriptionID: "issues.user_resolved_issues"
63104     };
63105     function update(selection2) {
63106       var shownItems = [];
63107       var liveIssues = context.validator().getIssues({
63108         what: corePreferences("validate-what") || "edited",
63109         where: corePreferences("validate-where") || "all"
63110       });
63111       if (liveIssues.length) {
63112         warningsItem.count = liveIssues.length;
63113         shownItems.push(warningsItem);
63114       }
63115       if (corePreferences("validate-what") === "all") {
63116         var resolvedIssues = context.validator().getResolvedIssues();
63117         if (resolvedIssues.length) {
63118           resolvedItem.count = resolvedIssues.length;
63119           shownItems.push(resolvedItem);
63120         }
63121       }
63122       var chips = selection2.selectAll(".chip").data(shownItems, function(d2) {
63123         return d2.id;
63124       });
63125       chips.exit().remove();
63126       var enter = chips.enter().append("a").attr("class", function(d2) {
63127         return "chip " + d2.id + "-count";
63128       }).attr("href", "#").each(function(d2) {
63129         var chipSelection = select_default2(this);
63130         var tooltipBehavior = uiTooltip().placement("top").title(() => _t.append(d2.descriptionID));
63131         chipSelection.call(tooltipBehavior).on("click", function(d3_event) {
63132           d3_event.preventDefault();
63133           tooltipBehavior.hide(select_default2(this));
63134           context.ui().togglePanes(context.container().select(".map-panes .issues-pane"));
63135         });
63136         chipSelection.call(svgIcon("#" + d2.iconID));
63137       });
63138       enter.append("span").attr("class", "count");
63139       enter.merge(chips).selectAll("span.count").text(function(d2) {
63140         return d2.count.toString();
63141       });
63142     }
63143     return function(selection2) {
63144       update(selection2);
63145       context.validator().on("validated.infobox", function() {
63146         update(selection2);
63147       });
63148     };
63149   }
63150
63151   // modules/ui/map_in_map.js
63152   function uiMapInMap(context) {
63153     function mapInMap(selection2) {
63154       var backgroundLayer = rendererTileLayer(context);
63155       var overlayLayers = {};
63156       var projection2 = geoRawMercator();
63157       var dataLayer = svgData(projection2, context).showLabels(false);
63158       var debugLayer = svgDebug(projection2, context);
63159       var zoom = zoom_default2().scaleExtent([geoZoomToScale(0.5), geoZoomToScale(24)]).on("start", zoomStarted).on("zoom", zoomed).on("end", zoomEnded);
63160       var wrap2 = select_default2(null);
63161       var tiles = select_default2(null);
63162       var viewport = select_default2(null);
63163       var _isTransformed = false;
63164       var _isHidden = true;
63165       var _skipEvents = false;
63166       var _gesture = null;
63167       var _zDiff = 6;
63168       var _dMini;
63169       var _cMini;
63170       var _tStart;
63171       var _tCurr;
63172       var _timeoutID;
63173       function zoomStarted() {
63174         if (_skipEvents)
63175           return;
63176         _tStart = _tCurr = projection2.transform();
63177         _gesture = null;
63178       }
63179       function zoomed(d3_event) {
63180         if (_skipEvents)
63181           return;
63182         var x2 = d3_event.transform.x;
63183         var y2 = d3_event.transform.y;
63184         var k2 = d3_event.transform.k;
63185         var isZooming = k2 !== _tStart.k;
63186         var isPanning = x2 !== _tStart.x || y2 !== _tStart.y;
63187         if (!isZooming && !isPanning) {
63188           return;
63189         }
63190         if (!_gesture) {
63191           _gesture = isZooming ? "zoom" : "pan";
63192         }
63193         var tMini = projection2.transform();
63194         var tX, tY, scale;
63195         if (_gesture === "zoom") {
63196           scale = k2 / tMini.k;
63197           tX = (_cMini[0] / scale - _cMini[0]) * scale;
63198           tY = (_cMini[1] / scale - _cMini[1]) * scale;
63199         } else {
63200           k2 = tMini.k;
63201           scale = 1;
63202           tX = x2 - tMini.x;
63203           tY = y2 - tMini.y;
63204         }
63205         utilSetTransform(tiles, tX, tY, scale);
63206         utilSetTransform(viewport, 0, 0, scale);
63207         _isTransformed = true;
63208         _tCurr = identity2.translate(x2, y2).scale(k2);
63209         var zMain = geoScaleToZoom(context.projection.scale());
63210         var zMini = geoScaleToZoom(k2);
63211         _zDiff = zMain - zMini;
63212         queueRedraw();
63213       }
63214       function zoomEnded() {
63215         if (_skipEvents)
63216           return;
63217         if (_gesture !== "pan")
63218           return;
63219         updateProjection();
63220         _gesture = null;
63221         context.map().center(projection2.invert(_cMini));
63222       }
63223       function updateProjection() {
63224         var loc = context.map().center();
63225         var tMain = context.projection.transform();
63226         var zMain = geoScaleToZoom(tMain.k);
63227         var zMini = Math.max(zMain - _zDiff, 0.5);
63228         var kMini = geoZoomToScale(zMini);
63229         projection2.translate([tMain.x, tMain.y]).scale(kMini);
63230         var point2 = projection2(loc);
63231         var mouse = _gesture === "pan" ? geoVecSubtract([_tCurr.x, _tCurr.y], [_tStart.x, _tStart.y]) : [0, 0];
63232         var xMini = _cMini[0] - point2[0] + tMain.x + mouse[0];
63233         var yMini = _cMini[1] - point2[1] + tMain.y + mouse[1];
63234         projection2.translate([xMini, yMini]).clipExtent([[0, 0], _dMini]);
63235         _tCurr = projection2.transform();
63236         if (_isTransformed) {
63237           utilSetTransform(tiles, 0, 0);
63238           utilSetTransform(viewport, 0, 0);
63239           _isTransformed = false;
63240         }
63241         zoom.scaleExtent([geoZoomToScale(0.5), geoZoomToScale(zMain - 3)]);
63242         _skipEvents = true;
63243         wrap2.call(zoom.transform, _tCurr);
63244         _skipEvents = false;
63245       }
63246       function redraw() {
63247         clearTimeout(_timeoutID);
63248         if (_isHidden)
63249           return;
63250         updateProjection();
63251         var zMini = geoScaleToZoom(projection2.scale());
63252         tiles = wrap2.selectAll(".map-in-map-tiles").data([0]);
63253         tiles = tiles.enter().append("div").attr("class", "map-in-map-tiles").merge(tiles);
63254         backgroundLayer.source(context.background().baseLayerSource()).projection(projection2).dimensions(_dMini);
63255         var background = tiles.selectAll(".map-in-map-background").data([0]);
63256         background.enter().append("div").attr("class", "map-in-map-background").merge(background).call(backgroundLayer);
63257         var overlaySources = context.background().overlayLayerSources();
63258         var activeOverlayLayers = [];
63259         for (var i3 = 0; i3 < overlaySources.length; i3++) {
63260           if (overlaySources[i3].validZoom(zMini)) {
63261             if (!overlayLayers[i3])
63262               overlayLayers[i3] = rendererTileLayer(context);
63263             activeOverlayLayers.push(overlayLayers[i3].source(overlaySources[i3]).projection(projection2).dimensions(_dMini));
63264           }
63265         }
63266         var overlay = tiles.selectAll(".map-in-map-overlay").data([0]);
63267         overlay = overlay.enter().append("div").attr("class", "map-in-map-overlay").merge(overlay);
63268         var overlays = overlay.selectAll("div").data(activeOverlayLayers, function(d2) {
63269           return d2.source().name();
63270         });
63271         overlays.exit().remove();
63272         overlays = overlays.enter().append("div").merge(overlays).each(function(layer) {
63273           select_default2(this).call(layer);
63274         });
63275         var dataLayers = tiles.selectAll(".map-in-map-data").data([0]);
63276         dataLayers.exit().remove();
63277         dataLayers = dataLayers.enter().append("svg").attr("class", "map-in-map-data").merge(dataLayers).call(dataLayer).call(debugLayer);
63278         if (_gesture !== "pan") {
63279           var getPath = path_default(projection2);
63280           var bbox2 = { type: "Polygon", coordinates: [context.map().extent().polygon()] };
63281           viewport = wrap2.selectAll(".map-in-map-viewport").data([0]);
63282           viewport = viewport.enter().append("svg").attr("class", "map-in-map-viewport").merge(viewport);
63283           var path = viewport.selectAll(".map-in-map-bbox").data([bbox2]);
63284           path.enter().append("path").attr("class", "map-in-map-bbox").merge(path).attr("d", getPath).classed("thick", function(d2) {
63285             return getPath.area(d2) < 30;
63286           });
63287         }
63288       }
63289       function queueRedraw() {
63290         clearTimeout(_timeoutID);
63291         _timeoutID = setTimeout(function() {
63292           redraw();
63293         }, 750);
63294       }
63295       function toggle(d3_event) {
63296         if (d3_event)
63297           d3_event.preventDefault();
63298         _isHidden = !_isHidden;
63299         context.container().select(".minimap-toggle-item").classed("active", !_isHidden).select("input").property("checked", !_isHidden);
63300         if (_isHidden) {
63301           wrap2.style("display", "block").style("opacity", "1").transition().duration(200).style("opacity", "0").on("end", function() {
63302             selection2.selectAll(".map-in-map").style("display", "none");
63303           });
63304         } else {
63305           wrap2.style("display", "block").style("opacity", "0").transition().duration(200).style("opacity", "1").on("end", function() {
63306             redraw();
63307           });
63308         }
63309       }
63310       uiMapInMap.toggle = toggle;
63311       wrap2 = selection2.selectAll(".map-in-map").data([0]);
63312       wrap2 = wrap2.enter().append("div").attr("class", "map-in-map").style("display", _isHidden ? "none" : "block").call(zoom).on("dblclick.zoom", null).merge(wrap2);
63313       _dMini = [200, 150];
63314       _cMini = geoVecScale(_dMini, 0.5);
63315       context.map().on("drawn.map-in-map", function(drawn) {
63316         if (drawn.full === true) {
63317           redraw();
63318         }
63319       });
63320       redraw();
63321       context.keybinding().on(_t("background.minimap.key"), toggle);
63322     }
63323     return mapInMap;
63324   }
63325
63326   // modules/ui/notice.js
63327   function uiNotice(context) {
63328     return function(selection2) {
63329       var div = selection2.append("div").attr("class", "notice");
63330       var button = div.append("button").attr("class", "zoom-to notice fillD").on("click", function() {
63331         context.map().zoomEase(context.minEditableZoom());
63332       }).on("wheel", function(d3_event) {
63333         var e22 = new WheelEvent(d3_event.type, d3_event);
63334         context.surface().node().dispatchEvent(e22);
63335       });
63336       button.call(svgIcon("#iD-icon-plus", "pre-text")).append("span").attr("class", "label").call(_t.append("zoom_in_edit"));
63337       function disableTooHigh() {
63338         var canEdit = context.map().zoom() >= context.minEditableZoom();
63339         div.style("display", canEdit ? "none" : "block");
63340       }
63341       context.map().on("move.notice", debounce_default(disableTooHigh, 500));
63342       disableTooHigh();
63343     };
63344   }
63345
63346   // modules/ui/photoviewer.js
63347   function uiPhotoviewer(context) {
63348     var dispatch14 = dispatch_default("resize");
63349     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
63350     function photoviewer(selection2) {
63351       selection2.append("button").attr("class", "thumb-hide").attr("title", _t("icons.close")).on("click", function() {
63352         if (services.streetside) {
63353           services.streetside.hideViewer(context);
63354         }
63355         if (services.mapillary) {
63356           services.mapillary.hideViewer(context);
63357         }
63358         if (services.kartaview) {
63359           services.kartaview.hideViewer(context);
63360         }
63361         if (services.mapilio) {
63362           services.mapilio.hideViewer(context);
63363         }
63364         if (services.vegbilder) {
63365           services.vegbilder.hideViewer(context);
63366         }
63367       }).append("div").call(svgIcon("#iD-icon-close"));
63368       function preventDefault(d3_event) {
63369         d3_event.preventDefault();
63370       }
63371       selection2.append("button").attr("class", "resize-handle-xy").on("touchstart touchdown touchend", preventDefault).on(
63372         _pointerPrefix + "down",
63373         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true, resizeOnY: true })
63374       );
63375       selection2.append("button").attr("class", "resize-handle-x").on("touchstart touchdown touchend", preventDefault).on(
63376         _pointerPrefix + "down",
63377         buildResizeListener(selection2, "resize", dispatch14, { resizeOnX: true })
63378       );
63379       selection2.append("button").attr("class", "resize-handle-y").on("touchstart touchdown touchend", preventDefault).on(
63380         _pointerPrefix + "down",
63381         buildResizeListener(selection2, "resize", dispatch14, { resizeOnY: true })
63382       );
63383       function buildResizeListener(target, eventName, dispatch15, options2) {
63384         var resizeOnX = !!options2.resizeOnX;
63385         var resizeOnY = !!options2.resizeOnY;
63386         var minHeight = options2.minHeight || 240;
63387         var minWidth = options2.minWidth || 320;
63388         var pointerId;
63389         var startX;
63390         var startY;
63391         var startWidth;
63392         var startHeight;
63393         function startResize(d3_event) {
63394           if (pointerId !== (d3_event.pointerId || "mouse"))
63395             return;
63396           d3_event.preventDefault();
63397           d3_event.stopPropagation();
63398           var mapSize = context.map().dimensions();
63399           if (resizeOnX) {
63400             var maxWidth = mapSize[0];
63401             var newWidth = clamp3(startWidth + d3_event.clientX - startX, minWidth, maxWidth);
63402             target.style("width", newWidth + "px");
63403           }
63404           if (resizeOnY) {
63405             var maxHeight = mapSize[1] - 90;
63406             var newHeight = clamp3(startHeight + startY - d3_event.clientY, minHeight, maxHeight);
63407             target.style("height", newHeight + "px");
63408           }
63409           dispatch15.call(eventName, target, subtractPadding(utilGetDimensions(target, true), target));
63410         }
63411         function clamp3(num, min3, max3) {
63412           return Math.max(min3, Math.min(num, max3));
63413         }
63414         function stopResize(d3_event) {
63415           if (pointerId !== (d3_event.pointerId || "mouse"))
63416             return;
63417           d3_event.preventDefault();
63418           d3_event.stopPropagation();
63419           select_default2(window).on("." + eventName, null);
63420         }
63421         return function initResize(d3_event) {
63422           d3_event.preventDefault();
63423           d3_event.stopPropagation();
63424           pointerId = d3_event.pointerId || "mouse";
63425           startX = d3_event.clientX;
63426           startY = d3_event.clientY;
63427           var targetRect = target.node().getBoundingClientRect();
63428           startWidth = targetRect.width;
63429           startHeight = targetRect.height;
63430           select_default2(window).on(_pointerPrefix + "move." + eventName, startResize, false).on(_pointerPrefix + "up." + eventName, stopResize, false);
63431           if (_pointerPrefix === "pointer") {
63432             select_default2(window).on("pointercancel." + eventName, stopResize, false);
63433           }
63434         };
63435       }
63436     }
63437     photoviewer.onMapResize = function() {
63438       var photoviewer2 = context.container().select(".photoviewer");
63439       var content = context.container().select(".main-content");
63440       var mapDimensions = utilGetDimensions(content, true);
63441       var photoDimensions = utilGetDimensions(photoviewer2, true);
63442       if (photoDimensions[0] > mapDimensions[0] || photoDimensions[1] > mapDimensions[1] - 90) {
63443         var setPhotoDimensions = [
63444           Math.min(photoDimensions[0], mapDimensions[0]),
63445           Math.min(photoDimensions[1], mapDimensions[1] - 90)
63446         ];
63447         photoviewer2.style("width", setPhotoDimensions[0] + "px").style("height", setPhotoDimensions[1] + "px");
63448         dispatch14.call("resize", photoviewer2, subtractPadding(setPhotoDimensions, photoviewer2));
63449       }
63450     };
63451     function subtractPadding(dimensions, selection2) {
63452       return [
63453         dimensions[0] - parseFloat(selection2.style("padding-left")) - parseFloat(selection2.style("padding-right")),
63454         dimensions[1] - parseFloat(selection2.style("padding-top")) - parseFloat(selection2.style("padding-bottom"))
63455       ];
63456     }
63457     return utilRebind(photoviewer, dispatch14, "on");
63458   }
63459
63460   // modules/ui/restore.js
63461   function uiRestore(context) {
63462     return function(selection2) {
63463       if (!context.history().hasRestorableChanges())
63464         return;
63465       let modalSelection = uiModal(selection2, true);
63466       modalSelection.select(".modal").attr("class", "modal fillL");
63467       let introModal = modalSelection.select(".content");
63468       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("restore.heading"));
63469       introModal.append("div").attr("class", "modal-section").append("p").call(_t.append("restore.description"));
63470       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
63471       let restore = buttonWrap.append("button").attr("class", "restore").on("click", () => {
63472         context.history().restore();
63473         modalSelection.remove();
63474       });
63475       restore.append("svg").attr("class", "logo logo-restore").append("use").attr("xlink:href", "#iD-logo-restore");
63476       restore.append("div").call(_t.append("restore.restore"));
63477       let reset = buttonWrap.append("button").attr("class", "reset").on("click", () => {
63478         context.history().clearSaved();
63479         modalSelection.remove();
63480       });
63481       reset.append("svg").attr("class", "logo logo-reset").append("use").attr("xlink:href", "#iD-logo-reset");
63482       reset.append("div").call(_t.append("restore.reset"));
63483       restore.node().focus();
63484     };
63485   }
63486
63487   // modules/ui/scale.js
63488   function uiScale(context) {
63489     var projection2 = context.projection, isImperial = !_mainLocalizer.usesMetric(), maxLength = 180, tickHeight = 8;
63490     function scaleDefs(loc1, loc2) {
63491       var lat = (loc2[1] + loc1[1]) / 2, conversion = isImperial ? 3.28084 : 1, dist = geoLonToMeters(loc2[0] - loc1[0], lat) * conversion, scale = { dist: 0, px: 0, text: "" }, buckets, i3, val, dLon;
63492       if (isImperial) {
63493         buckets = [528e4, 528e3, 52800, 5280, 500, 50, 5, 1];
63494       } else {
63495         buckets = [5e6, 5e5, 5e4, 5e3, 500, 50, 5, 1];
63496       }
63497       for (i3 = 0; i3 < buckets.length; i3++) {
63498         val = buckets[i3];
63499         if (dist >= val) {
63500           scale.dist = Math.floor(dist / val) * val;
63501           break;
63502         } else {
63503           scale.dist = +dist.toFixed(2);
63504         }
63505       }
63506       dLon = geoMetersToLon(scale.dist / conversion, lat);
63507       scale.px = Math.round(projection2([loc1[0] + dLon, loc1[1]])[0]);
63508       scale.text = displayLength(scale.dist / conversion, isImperial);
63509       return scale;
63510     }
63511     function update(selection2) {
63512       var dims = context.map().dimensions(), loc1 = projection2.invert([0, dims[1]]), loc2 = projection2.invert([maxLength, dims[1]]), scale = scaleDefs(loc1, loc2);
63513       selection2.select(".scale-path").attr("d", "M0.5,0.5v" + tickHeight + "h" + scale.px + "v-" + tickHeight);
63514       selection2.select(".scale-text").style(_mainLocalizer.textDirection() === "ltr" ? "left" : "right", scale.px + 16 + "px").text(scale.text);
63515     }
63516     return function(selection2) {
63517       function switchUnits() {
63518         isImperial = !isImperial;
63519         selection2.call(update);
63520       }
63521       var scalegroup = selection2.append("svg").attr("class", "scale").on("click", switchUnits).append("g").attr("transform", "translate(10,11)");
63522       scalegroup.append("path").attr("class", "scale-path");
63523       selection2.append("div").attr("class", "scale-text");
63524       selection2.call(update);
63525       context.map().on("move.scale", function() {
63526         update(selection2);
63527       });
63528     };
63529   }
63530
63531   // modules/ui/shortcuts.js
63532   function uiShortcuts(context) {
63533     var detected = utilDetect();
63534     var _activeTab = 0;
63535     var _modalSelection;
63536     var _selection = select_default2(null);
63537     var _dataShortcuts;
63538     function shortcutsModal(_modalSelection2) {
63539       _modalSelection2.select(".modal").classed("modal-shortcuts", true);
63540       var content = _modalSelection2.select(".content");
63541       content.append("div").attr("class", "modal-section header").append("h2").call(_t.append("shortcuts.title"));
63542       _mainFileFetcher.get("shortcuts").then(function(data) {
63543         _dataShortcuts = data;
63544         content.call(render);
63545       }).catch(function() {
63546       });
63547     }
63548     function render(selection2) {
63549       if (!_dataShortcuts)
63550         return;
63551       var wrapper = selection2.selectAll(".wrapper").data([0]);
63552       var wrapperEnter = wrapper.enter().append("div").attr("class", "wrapper modal-section");
63553       var tabsBar = wrapperEnter.append("div").attr("class", "tabs-bar");
63554       var shortcutsList = wrapperEnter.append("div").attr("class", "shortcuts-list");
63555       wrapper = wrapper.merge(wrapperEnter);
63556       var tabs = tabsBar.selectAll(".tab").data(_dataShortcuts);
63557       var tabsEnter = tabs.enter().append("a").attr("class", "tab").attr("href", "#").on("click", function(d3_event, d2) {
63558         d3_event.preventDefault();
63559         var i3 = _dataShortcuts.indexOf(d2);
63560         _activeTab = i3;
63561         render(selection2);
63562       });
63563       tabsEnter.append("span").html(function(d2) {
63564         return _t.html(d2.text);
63565       });
63566       wrapper.selectAll(".tab").classed("active", function(d2, i3) {
63567         return i3 === _activeTab;
63568       });
63569       var shortcuts = shortcutsList.selectAll(".shortcut-tab").data(_dataShortcuts);
63570       var shortcutsEnter = shortcuts.enter().append("div").attr("class", function(d2) {
63571         return "shortcut-tab shortcut-tab-" + d2.tab;
63572       });
63573       var columnsEnter = shortcutsEnter.selectAll(".shortcut-column").data(function(d2) {
63574         return d2.columns;
63575       }).enter().append("table").attr("class", "shortcut-column");
63576       var rowsEnter = columnsEnter.selectAll(".shortcut-row").data(function(d2) {
63577         return d2.rows;
63578       }).enter().append("tr").attr("class", "shortcut-row");
63579       var sectionRows = rowsEnter.filter(function(d2) {
63580         return !d2.shortcuts;
63581       });
63582       sectionRows.append("td");
63583       sectionRows.append("td").attr("class", "shortcut-section").append("h3").html(function(d2) {
63584         return _t.html(d2.text);
63585       });
63586       var shortcutRows = rowsEnter.filter(function(d2) {
63587         return d2.shortcuts;
63588       });
63589       var shortcutKeys = shortcutRows.append("td").attr("class", "shortcut-keys");
63590       var modifierKeys = shortcutKeys.filter(function(d2) {
63591         return d2.modifiers;
63592       });
63593       modifierKeys.selectAll("kbd.modifier").data(function(d2) {
63594         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
63595           return ["\u2318"];
63596         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
63597           return [];
63598         } else {
63599           return d2.modifiers;
63600         }
63601       }).enter().each(function() {
63602         var selection3 = select_default2(this);
63603         selection3.append("kbd").attr("class", "modifier").text(function(d2) {
63604           return uiCmd.display(d2);
63605         });
63606         selection3.append("span").text("+");
63607       });
63608       shortcutKeys.selectAll("kbd.shortcut").data(function(d2) {
63609         var arr = d2.shortcuts;
63610         if (detected.os === "win" && d2.text === "shortcuts.editing.commands.redo") {
63611           arr = ["Y"];
63612         } else if (detected.os !== "mac" && d2.text === "shortcuts.browsing.display_options.fullscreen") {
63613           arr = ["F11"];
63614         }
63615         arr = arr.map(function(s2) {
63616           return uiCmd.display(s2.indexOf(".") !== -1 ? _t(s2) : s2);
63617         });
63618         return utilArrayUniq(arr).map(function(s2) {
63619           return {
63620             shortcut: s2,
63621             separator: d2.separator,
63622             suffix: d2.suffix
63623           };
63624         });
63625       }).enter().each(function(d2, i3, nodes) {
63626         var selection3 = select_default2(this);
63627         var click = d2.shortcut.toLowerCase().match(/(.*).click/);
63628         if (click && click[1]) {
63629           selection3.call(svgIcon("#iD-walkthrough-mouse-" + click[1], "operation"));
63630         } else if (d2.shortcut.toLowerCase() === "long-press") {
63631           selection3.call(svgIcon("#iD-walkthrough-longpress", "longpress operation"));
63632         } else if (d2.shortcut.toLowerCase() === "tap") {
63633           selection3.call(svgIcon("#iD-walkthrough-tap", "tap operation"));
63634         } else {
63635           selection3.append("kbd").attr("class", "shortcut").text(function(d4) {
63636             return d4.shortcut;
63637           });
63638         }
63639         if (i3 < nodes.length - 1) {
63640           selection3.append("span").html(d2.separator || "\xA0" + _t.html("shortcuts.or") + "\xA0");
63641         } else if (i3 === nodes.length - 1 && d2.suffix) {
63642           selection3.append("span").text(d2.suffix);
63643         }
63644       });
63645       shortcutKeys.filter(function(d2) {
63646         return d2.gesture;
63647       }).each(function() {
63648         var selection3 = select_default2(this);
63649         selection3.append("span").text("+");
63650         selection3.append("span").attr("class", "gesture").html(function(d2) {
63651           return _t.html(d2.gesture);
63652         });
63653       });
63654       shortcutRows.append("td").attr("class", "shortcut-desc").html(function(d2) {
63655         return d2.text ? _t.html(d2.text) : "\xA0";
63656       });
63657       wrapper.selectAll(".shortcut-tab").style("display", function(d2, i3) {
63658         return i3 === _activeTab ? "flex" : "none";
63659       });
63660     }
63661     return function(selection2, show) {
63662       _selection = selection2;
63663       if (show) {
63664         _modalSelection = uiModal(selection2);
63665         _modalSelection.call(shortcutsModal);
63666       } else {
63667         context.keybinding().on([_t("shortcuts.toggle.key"), "?"], function() {
63668           if (context.container().selectAll(".modal-shortcuts").size()) {
63669             if (_modalSelection) {
63670               _modalSelection.close();
63671               _modalSelection = null;
63672             }
63673           } else {
63674             _modalSelection = uiModal(_selection);
63675             _modalSelection.call(shortcutsModal);
63676           }
63677         });
63678       }
63679     };
63680   }
63681
63682   // modules/ui/data_header.js
63683   function uiDataHeader() {
63684     var _datum;
63685     function dataHeader(selection2) {
63686       var header = selection2.selectAll(".data-header").data(
63687         _datum ? [_datum] : [],
63688         function(d2) {
63689           return d2.__featurehash__;
63690         }
63691       );
63692       header.exit().remove();
63693       var headerEnter = header.enter().append("div").attr("class", "data-header");
63694       var iconEnter = headerEnter.append("div").attr("class", "data-header-icon");
63695       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-data", "note-fill"));
63696       headerEnter.append("div").attr("class", "data-header-label").call(_t.append("map_data.layers.custom.title"));
63697     }
63698     dataHeader.datum = function(val) {
63699       if (!arguments.length)
63700         return _datum;
63701       _datum = val;
63702       return this;
63703     };
63704     return dataHeader;
63705   }
63706
63707   // modules/ui/combobox.js
63708   var _comboHideTimerID;
63709   function uiCombobox(context, klass) {
63710     var dispatch14 = dispatch_default("accept", "cancel", "update");
63711     var container = context.container();
63712     var _suggestions = [];
63713     var _data = [];
63714     var _fetched = {};
63715     var _selected = null;
63716     var _canAutocomplete = true;
63717     var _caseSensitive = false;
63718     var _cancelFetch = false;
63719     var _minItems = 2;
63720     var _tDown = 0;
63721     var _mouseEnterHandler, _mouseLeaveHandler;
63722     var _fetcher = function(val, cb) {
63723       cb(_data.filter(function(d2) {
63724         var terms = d2.terms || [];
63725         terms.push(d2.value);
63726         if (d2.key) {
63727           terms.push(d2.key);
63728         }
63729         return terms.some(function(term) {
63730           return term.toString().toLowerCase().indexOf(val.toLowerCase()) !== -1;
63731         });
63732       }));
63733     };
63734     var combobox = function(input, attachTo) {
63735       if (!input || input.empty())
63736         return;
63737       input.classed("combobox-input", true).on("focus.combo-input", focus).on("blur.combo-input", blur).on("keydown.combo-input", keydown).on("keyup.combo-input", keyup).on("input.combo-input", change).on("mousedown.combo-input", mousedown).each(function() {
63738         var parent = this.parentNode;
63739         var sibling = this.nextSibling;
63740         select_default2(parent).selectAll(".combobox-caret").filter(function(d2) {
63741           return d2 === input.node();
63742         }).data([input.node()]).enter().insert("div", function() {
63743           return sibling;
63744         }).attr("class", "combobox-caret").on("mousedown.combo-caret", function(d3_event) {
63745           d3_event.preventDefault();
63746           input.node().focus();
63747           mousedown(d3_event);
63748         }).on("mouseup.combo-caret", function(d3_event) {
63749           d3_event.preventDefault();
63750           mouseup(d3_event);
63751         });
63752       });
63753       function mousedown(d3_event) {
63754         if (d3_event.button !== 0)
63755           return;
63756         if (input.classed("disabled"))
63757           return;
63758         _tDown = +/* @__PURE__ */ new Date();
63759         var start2 = input.property("selectionStart");
63760         var end = input.property("selectionEnd");
63761         if (start2 !== end) {
63762           var val = utilGetSetValue(input);
63763           input.node().setSelectionRange(val.length, val.length);
63764           return;
63765         }
63766         input.on("mouseup.combo-input", mouseup);
63767       }
63768       function mouseup(d3_event) {
63769         input.on("mouseup.combo-input", null);
63770         if (d3_event.button !== 0)
63771           return;
63772         if (input.classed("disabled"))
63773           return;
63774         if (input.node() !== document.activeElement)
63775           return;
63776         var start2 = input.property("selectionStart");
63777         var end = input.property("selectionEnd");
63778         if (start2 !== end)
63779           return;
63780         var combo = container.selectAll(".combobox");
63781         if (combo.empty() || combo.datum() !== input.node()) {
63782           var tOrig = _tDown;
63783           window.setTimeout(function() {
63784             if (tOrig !== _tDown)
63785               return;
63786             fetchComboData("", function() {
63787               show();
63788               render();
63789             });
63790           }, 250);
63791         } else {
63792           hide();
63793         }
63794       }
63795       function focus() {
63796         fetchComboData("");
63797       }
63798       function blur() {
63799         _comboHideTimerID = window.setTimeout(hide, 75);
63800       }
63801       function show() {
63802         hide();
63803         container.insert("div", ":first-child").datum(input.node()).attr("class", "combobox" + (klass ? " combobox-" + klass : "")).style("position", "absolute").style("display", "block").style("left", "0px").on("mousedown.combo-container", function(d3_event) {
63804           d3_event.preventDefault();
63805         });
63806         container.on("scroll.combo-scroll", render, true);
63807       }
63808       function hide() {
63809         if (_comboHideTimerID) {
63810           window.clearTimeout(_comboHideTimerID);
63811           _comboHideTimerID = void 0;
63812         }
63813         container.selectAll(".combobox").remove();
63814         container.on("scroll.combo-scroll", null);
63815       }
63816       function keydown(d3_event) {
63817         var shown = !container.selectAll(".combobox").empty();
63818         var tagName = input.node() ? input.node().tagName.toLowerCase() : "";
63819         switch (d3_event.keyCode) {
63820           case 8:
63821           case 46:
63822             d3_event.stopPropagation();
63823             _selected = null;
63824             render();
63825             input.on("input.combo-input", function() {
63826               var start2 = input.property("selectionStart");
63827               input.node().setSelectionRange(start2, start2);
63828               input.on("input.combo-input", change);
63829               change(false);
63830             });
63831             break;
63832           case 9:
63833             accept(d3_event);
63834             break;
63835           case 13:
63836             d3_event.preventDefault();
63837             d3_event.stopPropagation();
63838             accept(d3_event);
63839             break;
63840           case 38:
63841             if (tagName === "textarea" && !shown)
63842               return;
63843             d3_event.preventDefault();
63844             if (tagName === "input" && !shown) {
63845               show();
63846             }
63847             nav(-1);
63848             break;
63849           case 40:
63850             if (tagName === "textarea" && !shown)
63851               return;
63852             d3_event.preventDefault();
63853             if (tagName === "input" && !shown) {
63854               show();
63855             }
63856             nav(1);
63857             break;
63858         }
63859       }
63860       function keyup(d3_event) {
63861         switch (d3_event.keyCode) {
63862           case 27:
63863             cancel();
63864             break;
63865         }
63866       }
63867       function change(doAutoComplete) {
63868         if (doAutoComplete === void 0)
63869           doAutoComplete = true;
63870         fetchComboData(value(), function(skipAutosuggest) {
63871           _selected = null;
63872           var val = input.property("value");
63873           if (_suggestions.length) {
63874             if (doAutoComplete && !skipAutosuggest && input.property("selectionEnd") === val.length) {
63875               _selected = tryAutocomplete();
63876             }
63877             if (!_selected) {
63878               _selected = val;
63879             }
63880           }
63881           if (val.length) {
63882             var combo = container.selectAll(".combobox");
63883             if (combo.empty()) {
63884               show();
63885             }
63886           } else {
63887             hide();
63888           }
63889           render();
63890         });
63891       }
63892       function nav(dir) {
63893         if (_suggestions.length) {
63894           var index = -1;
63895           for (var i3 = 0; i3 < _suggestions.length; i3++) {
63896             if (_selected && _suggestions[i3].value === _selected) {
63897               index = i3;
63898               break;
63899             }
63900           }
63901           index = Math.max(Math.min(index + dir, _suggestions.length - 1), 0);
63902           _selected = _suggestions[index].value;
63903           utilGetSetValue(input, _selected);
63904           dispatch14.call("update");
63905         }
63906         render();
63907         ensureVisible();
63908       }
63909       function ensureVisible() {
63910         var combo = container.selectAll(".combobox");
63911         if (combo.empty())
63912           return;
63913         var containerRect = container.node().getBoundingClientRect();
63914         var comboRect = combo.node().getBoundingClientRect();
63915         if (comboRect.bottom > containerRect.bottom) {
63916           var node = attachTo ? attachTo.node() : input.node();
63917           node.scrollIntoView({ behavior: "instant", block: "center" });
63918           render();
63919         }
63920         var selected = combo.selectAll(".combobox-option.selected").node();
63921         if (selected) {
63922           selected.scrollIntoView({ behavior: "smooth", block: "nearest" });
63923         }
63924       }
63925       function value() {
63926         var value2 = input.property("value");
63927         var start2 = input.property("selectionStart");
63928         var end = input.property("selectionEnd");
63929         if (start2 && end) {
63930           value2 = value2.substring(0, start2);
63931         }
63932         return value2;
63933       }
63934       function fetchComboData(v2, cb) {
63935         _cancelFetch = false;
63936         _fetcher.call(input, v2, function(results, skipAutosuggest) {
63937           if (_cancelFetch)
63938             return;
63939           _suggestions = results;
63940           results.forEach(function(d2) {
63941             _fetched[d2.value] = d2;
63942           });
63943           if (cb) {
63944             cb(skipAutosuggest);
63945           }
63946         });
63947       }
63948       function tryAutocomplete() {
63949         if (!_canAutocomplete)
63950           return;
63951         var val = _caseSensitive ? value() : value().toLowerCase();
63952         if (!val)
63953           return;
63954         if (isFinite(val))
63955           return;
63956         const suggestionValues = [];
63957         _suggestions.forEach((s2) => {
63958           suggestionValues.push(s2.value);
63959           if (s2.key && s2.key !== s2.value) {
63960             suggestionValues.push(s2.key);
63961           }
63962         });
63963         var bestIndex = -1;
63964         for (var i3 = 0; i3 < suggestionValues.length; i3++) {
63965           var suggestion = suggestionValues[i3];
63966           var compare2 = _caseSensitive ? suggestion : suggestion.toLowerCase();
63967           if (compare2 === val) {
63968             bestIndex = i3;
63969             break;
63970           } else if (bestIndex === -1 && compare2.indexOf(val) === 0) {
63971             bestIndex = i3;
63972           }
63973         }
63974         if (bestIndex !== -1) {
63975           var bestVal = suggestionValues[bestIndex];
63976           input.property("value", bestVal);
63977           input.node().setSelectionRange(val.length, bestVal.length);
63978           dispatch14.call("update");
63979           return bestVal;
63980         }
63981       }
63982       function render() {
63983         if (_suggestions.length < _minItems || document.activeElement !== input.node()) {
63984           hide();
63985           return;
63986         }
63987         var shown = !container.selectAll(".combobox").empty();
63988         if (!shown)
63989           return;
63990         var combo = container.selectAll(".combobox");
63991         var options2 = combo.selectAll(".combobox-option").data(_suggestions, function(d2) {
63992           return d2.value;
63993         });
63994         options2.exit().remove();
63995         options2.enter().append("a").attr("class", function(d2) {
63996           return "combobox-option " + (d2.klass || "");
63997         }).attr("title", function(d2) {
63998           return d2.title;
63999         }).each(function(d2) {
64000           if (d2.display) {
64001             d2.display(select_default2(this));
64002           } else {
64003             select_default2(this).text(d2.value);
64004           }
64005         }).on("mouseenter", _mouseEnterHandler).on("mouseleave", _mouseLeaveHandler).merge(options2).classed("selected", function(d2) {
64006           return d2.value === _selected || d2.key === _selected;
64007         }).on("click.combo-option", accept).order();
64008         var node = attachTo ? attachTo.node() : input.node();
64009         var containerRect = container.node().getBoundingClientRect();
64010         var rect = node.getBoundingClientRect();
64011         combo.style("left", rect.left + 5 - containerRect.left + "px").style("width", rect.width - 10 + "px").style("top", rect.height + rect.top - containerRect.top + "px");
64012       }
64013       function accept(d3_event, d2) {
64014         _cancelFetch = true;
64015         var thiz = input.node();
64016         if (d2) {
64017           utilGetSetValue(input, d2.value);
64018           utilTriggerEvent(input, "change");
64019         }
64020         var val = utilGetSetValue(input);
64021         thiz.setSelectionRange(val.length, val.length);
64022         d2 = _fetched[val];
64023         dispatch14.call("accept", thiz, d2, val);
64024         hide();
64025       }
64026       function cancel() {
64027         _cancelFetch = true;
64028         var thiz = input.node();
64029         var val = utilGetSetValue(input);
64030         var start2 = input.property("selectionStart");
64031         var end = input.property("selectionEnd");
64032         val = val.slice(0, start2) + val.slice(end);
64033         utilGetSetValue(input, val);
64034         thiz.setSelectionRange(val.length, val.length);
64035         dispatch14.call("cancel", thiz);
64036         hide();
64037       }
64038     };
64039     combobox.canAutocomplete = function(val) {
64040       if (!arguments.length)
64041         return _canAutocomplete;
64042       _canAutocomplete = val;
64043       return combobox;
64044     };
64045     combobox.caseSensitive = function(val) {
64046       if (!arguments.length)
64047         return _caseSensitive;
64048       _caseSensitive = val;
64049       return combobox;
64050     };
64051     combobox.data = function(val) {
64052       if (!arguments.length)
64053         return _data;
64054       _data = val;
64055       return combobox;
64056     };
64057     combobox.fetcher = function(val) {
64058       if (!arguments.length)
64059         return _fetcher;
64060       _fetcher = val;
64061       return combobox;
64062     };
64063     combobox.minItems = function(val) {
64064       if (!arguments.length)
64065         return _minItems;
64066       _minItems = val;
64067       return combobox;
64068     };
64069     combobox.itemsMouseEnter = function(val) {
64070       if (!arguments.length)
64071         return _mouseEnterHandler;
64072       _mouseEnterHandler = val;
64073       return combobox;
64074     };
64075     combobox.itemsMouseLeave = function(val) {
64076       if (!arguments.length)
64077         return _mouseLeaveHandler;
64078       _mouseLeaveHandler = val;
64079       return combobox;
64080     };
64081     return utilRebind(combobox, dispatch14, "on");
64082   }
64083   uiCombobox.off = function(input, context) {
64084     input.on("focus.combo-input", null).on("blur.combo-input", null).on("keydown.combo-input", null).on("keyup.combo-input", null).on("input.combo-input", null).on("mousedown.combo-input", null).on("mouseup.combo-input", null);
64085     context.container().on("scroll.combo-scroll", null);
64086   };
64087
64088   // modules/ui/disclosure.js
64089   function uiDisclosure(context, key, expandedDefault) {
64090     var dispatch14 = dispatch_default("toggled");
64091     var _expanded;
64092     var _label = utilFunctor("");
64093     var _updatePreference = true;
64094     var _content = function() {
64095     };
64096     var disclosure = function(selection2) {
64097       if (_expanded === void 0 || _expanded === null) {
64098         var preference = corePreferences("disclosure." + key + ".expanded");
64099         _expanded = preference === null ? !!expandedDefault : preference === "true";
64100       }
64101       var hideToggle = selection2.selectAll(".hide-toggle-" + key).data([0]);
64102       var hideToggleEnter = hideToggle.enter().append("h3").append("a").attr("role", "button").attr("href", "#").attr("class", "hide-toggle hide-toggle-" + key).call(svgIcon("", "pre-text", "hide-toggle-icon"));
64103       hideToggleEnter.append("span").attr("class", "hide-toggle-text");
64104       hideToggle = hideToggleEnter.merge(hideToggle);
64105       hideToggle.on("click", toggle).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand"))).attr("aria-expanded", _expanded).classed("expanded", _expanded);
64106       const label = _label();
64107       const labelSelection = hideToggle.selectAll(".hide-toggle-text");
64108       if (typeof label !== "function") {
64109         labelSelection.text(_label());
64110       } else {
64111         labelSelection.text("").call(label);
64112       }
64113       hideToggle.selectAll(".hide-toggle-icon").attr(
64114         "xlink:href",
64115         _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64116       );
64117       var wrap2 = selection2.selectAll(".disclosure-wrap").data([0]);
64118       wrap2 = wrap2.enter().append("div").attr("class", "disclosure-wrap disclosure-wrap-" + key).merge(wrap2).classed("hide", !_expanded);
64119       if (_expanded) {
64120         wrap2.call(_content);
64121       }
64122       function toggle(d3_event) {
64123         d3_event.preventDefault();
64124         _expanded = !_expanded;
64125         if (_updatePreference) {
64126           corePreferences("disclosure." + key + ".expanded", _expanded);
64127         }
64128         hideToggle.classed("expanded", _expanded).attr("aria-expanded", _expanded).attr("title", _t("icons.".concat(_expanded ? "collapse" : "expand")));
64129         hideToggle.selectAll(".hide-toggle-icon").attr(
64130           "xlink:href",
64131           _expanded ? "#iD-icon-down" : _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward"
64132         );
64133         wrap2.call(uiToggle(_expanded));
64134         if (_expanded) {
64135           wrap2.call(_content);
64136         }
64137         dispatch14.call("toggled", this, _expanded);
64138       }
64139     };
64140     disclosure.label = function(val) {
64141       if (!arguments.length)
64142         return _label;
64143       _label = utilFunctor(val);
64144       return disclosure;
64145     };
64146     disclosure.expanded = function(val) {
64147       if (!arguments.length)
64148         return _expanded;
64149       _expanded = val;
64150       return disclosure;
64151     };
64152     disclosure.updatePreference = function(val) {
64153       if (!arguments.length)
64154         return _updatePreference;
64155       _updatePreference = val;
64156       return disclosure;
64157     };
64158     disclosure.content = function(val) {
64159       if (!arguments.length)
64160         return _content;
64161       _content = val;
64162       return disclosure;
64163     };
64164     return utilRebind(disclosure, dispatch14, "on");
64165   }
64166
64167   // modules/ui/section.js
64168   function uiSection(id2, context) {
64169     var _classes = utilFunctor("");
64170     var _shouldDisplay;
64171     var _content;
64172     var _disclosure;
64173     var _label;
64174     var _expandedByDefault = utilFunctor(true);
64175     var _disclosureContent;
64176     var _disclosureExpanded;
64177     var _containerSelection = select_default2(null);
64178     var section = {
64179       id: id2
64180     };
64181     section.classes = function(val) {
64182       if (!arguments.length)
64183         return _classes;
64184       _classes = utilFunctor(val);
64185       return section;
64186     };
64187     section.label = function(val) {
64188       if (!arguments.length)
64189         return _label;
64190       _label = utilFunctor(val);
64191       return section;
64192     };
64193     section.expandedByDefault = function(val) {
64194       if (!arguments.length)
64195         return _expandedByDefault;
64196       _expandedByDefault = utilFunctor(val);
64197       return section;
64198     };
64199     section.shouldDisplay = function(val) {
64200       if (!arguments.length)
64201         return _shouldDisplay;
64202       _shouldDisplay = utilFunctor(val);
64203       return section;
64204     };
64205     section.content = function(val) {
64206       if (!arguments.length)
64207         return _content;
64208       _content = val;
64209       return section;
64210     };
64211     section.disclosureContent = function(val) {
64212       if (!arguments.length)
64213         return _disclosureContent;
64214       _disclosureContent = val;
64215       return section;
64216     };
64217     section.disclosureExpanded = function(val) {
64218       if (!arguments.length)
64219         return _disclosureExpanded;
64220       _disclosureExpanded = val;
64221       return section;
64222     };
64223     section.render = function(selection2) {
64224       _containerSelection = selection2.selectAll(".section-" + id2).data([0]);
64225       var sectionEnter = _containerSelection.enter().append("div").attr("class", "section section-" + id2 + " " + (_classes && _classes() || ""));
64226       _containerSelection = sectionEnter.merge(_containerSelection);
64227       _containerSelection.call(renderContent);
64228     };
64229     section.reRender = function() {
64230       _containerSelection.call(renderContent);
64231     };
64232     section.selection = function() {
64233       return _containerSelection;
64234     };
64235     section.disclosure = function() {
64236       return _disclosure;
64237     };
64238     function renderContent(selection2) {
64239       if (_shouldDisplay) {
64240         var shouldDisplay = _shouldDisplay();
64241         selection2.classed("hide", !shouldDisplay);
64242         if (!shouldDisplay) {
64243           selection2.html("");
64244           return;
64245         }
64246       }
64247       if (_disclosureContent) {
64248         if (!_disclosure) {
64249           _disclosure = uiDisclosure(context, id2.replace(/-/g, "_"), _expandedByDefault()).label(_label || "").content(_disclosureContent);
64250         }
64251         if (_disclosureExpanded !== void 0) {
64252           _disclosure.expanded(_disclosureExpanded);
64253           _disclosureExpanded = void 0;
64254         }
64255         selection2.call(_disclosure);
64256         return;
64257       }
64258       if (_content) {
64259         selection2.call(_content);
64260       }
64261     }
64262     return section;
64263   }
64264
64265   // modules/ui/tag_reference.js
64266   function uiTagReference(what) {
64267     var wikibase = what.qid ? services.wikidata : services.osmWikibase;
64268     var tagReference = {};
64269     var _button = select_default2(null);
64270     var _body = select_default2(null);
64271     var _loaded;
64272     var _showing;
64273     function load() {
64274       if (!wikibase)
64275         return;
64276       _button.classed("tag-reference-loading", true);
64277       wikibase.getDocs(what, gotDocs);
64278     }
64279     function gotDocs(err, docs) {
64280       _body.html("");
64281       if (!docs || !docs.title) {
64282         _body.append("p").attr("class", "tag-reference-description").call(_t.append("inspector.no_documentation_key"));
64283         done();
64284         return;
64285       }
64286       if (docs.imageURL) {
64287         _body.append("img").attr("class", "tag-reference-wiki-image").attr("alt", docs.description).attr("src", docs.imageURL).on("load", function() {
64288           done();
64289         }).on("error", function() {
64290           select_default2(this).remove();
64291           done();
64292         });
64293       } else {
64294         done();
64295       }
64296       var tagReferenceDescription = _body.append("p").attr("class", "tag-reference-description").append("span");
64297       if (docs.description) {
64298         tagReferenceDescription = tagReferenceDescription.attr("class", "localized-text").attr("lang", docs.descriptionLocaleCode || "und").text(docs.description);
64299       } else {
64300         tagReferenceDescription = tagReferenceDescription.call(_t.append("inspector.no_documentation_key"));
64301       }
64302       tagReferenceDescription.append("a").attr("class", "tag-reference-edit").attr("target", "_blank").attr("title", _t("inspector.edit_reference")).attr("href", docs.editURL).call(svgIcon("#iD-icon-edit", "inline"));
64303       if (docs.wiki) {
64304         _body.append("a").attr("class", "tag-reference-link").attr("target", "_blank").attr("href", docs.wiki.url).call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append(docs.wiki.text));
64305       }
64306       if (what.key === "comment") {
64307         _body.append("a").attr("class", "tag-reference-comment-link").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", _t("commit.about_changeset_comments_link")).append("span").call(_t.append("commit.about_changeset_comments"));
64308       }
64309     }
64310     function done() {
64311       _loaded = true;
64312       _button.classed("tag-reference-loading", false);
64313       _body.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1");
64314       _showing = true;
64315       _button.selectAll("svg.icon use").each(function() {
64316         var iconUse = select_default2(this);
64317         if (iconUse.attr("href") === "#iD-icon-info") {
64318           iconUse.attr("href", "#iD-icon-info-filled");
64319         }
64320       });
64321     }
64322     function hide() {
64323       _body.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
64324         _body.classed("expanded", false);
64325       });
64326       _showing = false;
64327       _button.selectAll("svg.icon use").each(function() {
64328         var iconUse = select_default2(this);
64329         if (iconUse.attr("href") === "#iD-icon-info-filled") {
64330           iconUse.attr("href", "#iD-icon-info");
64331         }
64332       });
64333     }
64334     tagReference.button = function(selection2, klass, iconName) {
64335       _button = selection2.selectAll(".tag-reference-button").data([0]);
64336       _button = _button.enter().append("button").attr("class", "tag-reference-button " + (klass || "")).attr("title", _t("icons.information")).call(svgIcon("#iD-icon-" + (iconName || "inspect"))).merge(_button);
64337       _button.on("click", function(d3_event) {
64338         d3_event.stopPropagation();
64339         d3_event.preventDefault();
64340         this.blur();
64341         if (_showing) {
64342           hide();
64343         } else if (_loaded) {
64344           done();
64345         } else {
64346           load();
64347         }
64348       });
64349     };
64350     tagReference.body = function(selection2) {
64351       var itemID = what.qid || what.key + "-" + (what.value || "");
64352       _body = selection2.selectAll(".tag-reference-body").data([itemID], function(d2) {
64353         return d2;
64354       });
64355       _body.exit().remove();
64356       _body = _body.enter().append("div").attr("class", "tag-reference-body").style("max-height", "0").style("opacity", "0").merge(_body);
64357       if (_showing === false) {
64358         hide();
64359       }
64360     };
64361     tagReference.showing = function(val) {
64362       if (!arguments.length)
64363         return _showing;
64364       _showing = val;
64365       return tagReference;
64366     };
64367     return tagReference;
64368   }
64369
64370   // modules/ui/field_help.js
64371   function uiFieldHelp(context, fieldName) {
64372     var fieldHelp = {};
64373     var _inspector = select_default2(null);
64374     var _wrap = select_default2(null);
64375     var _body = select_default2(null);
64376     var fieldHelpKeys = {
64377       restrictions: [
64378         ["about", [
64379           "about",
64380           "from_via_to",
64381           "maxdist",
64382           "maxvia"
64383         ]],
64384         ["inspecting", [
64385           "about",
64386           "from_shadow",
64387           "allow_shadow",
64388           "restrict_shadow",
64389           "only_shadow",
64390           "restricted",
64391           "only"
64392         ]],
64393         ["modifying", [
64394           "about",
64395           "indicators",
64396           "allow_turn",
64397           "restrict_turn",
64398           "only_turn"
64399         ]],
64400         ["tips", [
64401           "simple",
64402           "simple_example",
64403           "indirect",
64404           "indirect_example",
64405           "indirect_noedit"
64406         ]]
64407       ]
64408     };
64409     var fieldHelpHeadings = {};
64410     var replacements = {
64411       distField: { html: _t.html("restriction.controls.distance") },
64412       viaField: { html: _t.html("restriction.controls.via") },
64413       fromShadow: { html: icon("#iD-turn-shadow", "inline shadow from") },
64414       allowShadow: { html: icon("#iD-turn-shadow", "inline shadow allow") },
64415       restrictShadow: { html: icon("#iD-turn-shadow", "inline shadow restrict") },
64416       onlyShadow: { html: icon("#iD-turn-shadow", "inline shadow only") },
64417       allowTurn: { html: icon("#iD-turn-yes", "inline turn") },
64418       restrictTurn: { html: icon("#iD-turn-no", "inline turn") },
64419       onlyTurn: { html: icon("#iD-turn-only", "inline turn") }
64420     };
64421     var docs = fieldHelpKeys[fieldName].map(function(key) {
64422       var helpkey = "help.field." + fieldName + "." + key[0];
64423       var text = key[1].reduce(function(all, part) {
64424         var subkey = helpkey + "." + part;
64425         var depth = fieldHelpHeadings[subkey];
64426         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
64427         return all + hhh + _t.html(subkey, replacements) + "\n\n";
64428       }, "");
64429       return {
64430         key: helpkey,
64431         title: _t.html(helpkey + ".title"),
64432         html: marked(text.trim())
64433       };
64434     });
64435     function show() {
64436       updatePosition();
64437       _body.classed("hide", false).style("opacity", "0").transition().duration(200).style("opacity", "1");
64438     }
64439     function hide() {
64440       _body.classed("hide", true).transition().duration(200).style("opacity", "0").on("end", function() {
64441         _body.classed("hide", true);
64442       });
64443     }
64444     function clickHelp(index) {
64445       var d2 = docs[index];
64446       var tkeys = fieldHelpKeys[fieldName][index][1];
64447       _body.selectAll(".field-help-nav-item").classed("active", function(d4, i3) {
64448         return i3 === index;
64449       });
64450       var content = _body.selectAll(".field-help-content").html(d2.html);
64451       content.selectAll("p").attr("class", function(d4, i3) {
64452         return tkeys[i3];
64453       });
64454       if (d2.key === "help.field.restrictions.inspecting") {
64455         content.insert("img", "p.from_shadow").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_inspect.gif"));
64456       } else if (d2.key === "help.field.restrictions.modifying") {
64457         content.insert("img", "p.allow_turn").attr("class", "field-help-image cf").attr("src", context.imagePath("tr_modify.gif"));
64458       }
64459     }
64460     fieldHelp.button = function(selection2) {
64461       if (_body.empty())
64462         return;
64463       var button = selection2.selectAll(".field-help-button").data([0]);
64464       button.enter().append("button").attr("class", "field-help-button").call(svgIcon("#iD-icon-help")).merge(button).on("click", function(d3_event) {
64465         d3_event.stopPropagation();
64466         d3_event.preventDefault();
64467         if (_body.classed("hide")) {
64468           show();
64469         } else {
64470           hide();
64471         }
64472       });
64473     };
64474     function updatePosition() {
64475       var wrap2 = _wrap.node();
64476       var inspector = _inspector.node();
64477       var wRect = wrap2.getBoundingClientRect();
64478       var iRect = inspector.getBoundingClientRect();
64479       _body.style("top", wRect.top + inspector.scrollTop - iRect.top + "px");
64480     }
64481     fieldHelp.body = function(selection2) {
64482       _wrap = selection2.selectAll(".form-field-input-wrap");
64483       if (_wrap.empty())
64484         return;
64485       _inspector = context.container().select(".sidebar .entity-editor-pane .inspector-body");
64486       if (_inspector.empty())
64487         return;
64488       _body = _inspector.selectAll(".field-help-body").data([0]);
64489       var enter = _body.enter().append("div").attr("class", "field-help-body hide");
64490       var titleEnter = enter.append("div").attr("class", "field-help-title cf");
64491       titleEnter.append("h2").attr("class", _mainLocalizer.textDirection() === "rtl" ? "fr" : "fl").call(_t.append("help.field." + fieldName + ".title"));
64492       titleEnter.append("button").attr("class", "fr close").attr("title", _t("icons.close")).on("click", function(d3_event) {
64493         d3_event.stopPropagation();
64494         d3_event.preventDefault();
64495         hide();
64496       }).call(svgIcon("#iD-icon-close"));
64497       var navEnter = enter.append("div").attr("class", "field-help-nav cf");
64498       var titles = docs.map(function(d2) {
64499         return d2.title;
64500       });
64501       navEnter.selectAll(".field-help-nav-item").data(titles).enter().append("div").attr("class", "field-help-nav-item").html(function(d2) {
64502         return d2;
64503       }).on("click", function(d3_event, d2) {
64504         d3_event.stopPropagation();
64505         d3_event.preventDefault();
64506         clickHelp(titles.indexOf(d2));
64507       });
64508       enter.append("div").attr("class", "field-help-content");
64509       _body = _body.merge(enter);
64510       clickHelp(0);
64511     };
64512     return fieldHelp;
64513   }
64514
64515   // modules/ui/fields/check.js
64516   function uiFieldCheck(field, context) {
64517     var dispatch14 = dispatch_default("change");
64518     var options2 = field.options;
64519     var values = [];
64520     var texts = [];
64521     var _tags;
64522     var input = select_default2(null);
64523     var text = select_default2(null);
64524     var label = select_default2(null);
64525     var reverser = select_default2(null);
64526     var _impliedYes;
64527     var _entityIDs = [];
64528     var _value;
64529     var stringsField = field.resolveReference("stringsCrossReference");
64530     if (!options2 && stringsField.options) {
64531       options2 = stringsField.options;
64532     }
64533     if (options2) {
64534       for (var i3 in options2) {
64535         var v2 = options2[i3];
64536         values.push(v2 === "undefined" ? void 0 : v2);
64537         texts.push(stringsField.t.html("options." + v2, { "default": v2 }));
64538       }
64539     } else {
64540       values = [void 0, "yes"];
64541       texts = [_t.html("inspector.unknown"), _t.html("inspector.check.yes")];
64542       if (field.type !== "defaultCheck") {
64543         values.push("no");
64544         texts.push(_t.html("inspector.check.no"));
64545       }
64546     }
64547     function checkImpliedYes() {
64548       _impliedYes = field.id === "oneway_yes";
64549       if (field.id === "oneway") {
64550         var entity = context.entity(_entityIDs[0]);
64551         for (var key in entity.tags) {
64552           if (key in osmOneWayTags && entity.tags[key] in osmOneWayTags[key]) {
64553             _impliedYes = true;
64554             texts[0] = _t.html("_tagging.presets.fields.oneway_yes.options.undefined");
64555             break;
64556           }
64557         }
64558       }
64559     }
64560     function reverserHidden() {
64561       if (!context.container().select("div.inspector-hover").empty())
64562         return true;
64563       return !(_value === "yes" || _impliedYes && !_value);
64564     }
64565     function reverserSetText(selection2) {
64566       var entity = _entityIDs.length && context.hasEntity(_entityIDs[0]);
64567       if (reverserHidden() || !entity)
64568         return selection2;
64569       var first = entity.first();
64570       var last = entity.isClosed() ? entity.nodes[entity.nodes.length - 2] : entity.last();
64571       var pseudoDirection = first < last;
64572       var icon2 = pseudoDirection ? "#iD-icon-forward" : "#iD-icon-backward";
64573       selection2.selectAll(".reverser-span").html("").call(_t.append("inspector.check.reverser")).call(svgIcon(icon2, "inline"));
64574       return selection2;
64575     }
64576     var check = function(selection2) {
64577       checkImpliedYes();
64578       label = selection2.selectAll(".form-field-input-wrap").data([0]);
64579       var enter = label.enter().append("label").attr("class", "form-field-input-wrap form-field-input-check");
64580       enter.append("input").property("indeterminate", field.type !== "defaultCheck").attr("type", "checkbox").attr("id", field.domId);
64581       enter.append("span").html(texts[0]).attr("class", "value");
64582       if (field.type === "onewayCheck") {
64583         enter.append("button").attr("class", "reverser" + (reverserHidden() ? " hide" : "")).append("span").attr("class", "reverser-span");
64584       }
64585       label = label.merge(enter);
64586       input = label.selectAll("input");
64587       text = label.selectAll("span.value");
64588       input.on("click", function(d3_event) {
64589         d3_event.stopPropagation();
64590         var t2 = {};
64591         if (Array.isArray(_tags[field.key])) {
64592           if (values.indexOf("yes") !== -1) {
64593             t2[field.key] = "yes";
64594           } else {
64595             t2[field.key] = values[0];
64596           }
64597         } else {
64598           t2[field.key] = values[(values.indexOf(_value) + 1) % values.length];
64599         }
64600         if (t2[field.key] === "reversible" || t2[field.key] === "alternating") {
64601           t2[field.key] = values[0];
64602         }
64603         dispatch14.call("change", this, t2);
64604       });
64605       if (field.type === "onewayCheck") {
64606         reverser = label.selectAll(".reverser");
64607         reverser.call(reverserSetText).on("click", function(d3_event) {
64608           d3_event.preventDefault();
64609           d3_event.stopPropagation();
64610           context.perform(
64611             function(graph) {
64612               for (var i4 in _entityIDs) {
64613                 graph = actionReverse(_entityIDs[i4])(graph);
64614               }
64615               return graph;
64616             },
64617             _t("operations.reverse.annotation.line", { n: 1 })
64618           );
64619           context.validator().validate();
64620           select_default2(this).call(reverserSetText);
64621         });
64622       }
64623     };
64624     check.entityIDs = function(val) {
64625       if (!arguments.length)
64626         return _entityIDs;
64627       _entityIDs = val;
64628       return check;
64629     };
64630     check.tags = function(tags) {
64631       _tags = tags;
64632       function isChecked(val) {
64633         return val !== "no" && val !== "" && val !== void 0 && val !== null;
64634       }
64635       function textFor(val) {
64636         if (val === "")
64637           val = void 0;
64638         var index = values.indexOf(val);
64639         return index !== -1 ? texts[index] : '"' + val + '"';
64640       }
64641       checkImpliedYes();
64642       var isMixed = Array.isArray(tags[field.key]);
64643       _value = !isMixed && tags[field.key] && tags[field.key].toLowerCase();
64644       if (field.type === "onewayCheck" && (_value === "1" || _value === "-1")) {
64645         _value = "yes";
64646       }
64647       input.property("indeterminate", isMixed || field.type !== "defaultCheck" && !_value).property("checked", isChecked(_value));
64648       text.html(isMixed ? _t.html("inspector.multiple_values") : textFor(_value)).classed("mixed", isMixed);
64649       label.classed("set", !!_value);
64650       if (field.type === "onewayCheck") {
64651         reverser.classed("hide", reverserHidden()).call(reverserSetText);
64652       }
64653     };
64654     check.focus = function() {
64655       input.node().focus();
64656     };
64657     return utilRebind(check, dispatch14, "on");
64658   }
64659
64660   // modules/ui/length_indicator.js
64661   function uiLengthIndicator(maxChars) {
64662     var _wrap = select_default2(null);
64663     var _tooltip = uiPopover("tooltip max-length-warning").placement("bottom").hasArrow(true).content(() => (selection2) => {
64664       selection2.text("");
64665       selection2.call(svgIcon("#iD-icon-alert", "inline"));
64666       selection2.call(_t.append("inspector.max_length_reached", { maxChars }));
64667     });
64668     var _silent = false;
64669     var lengthIndicator = function(selection2) {
64670       _wrap = selection2.selectAll("span.length-indicator-wrap").data([0]);
64671       _wrap = _wrap.enter().append("span").merge(_wrap).classed("length-indicator-wrap", true);
64672       selection2.call(_tooltip);
64673     };
64674     lengthIndicator.update = function(val) {
64675       const strLen = utilUnicodeCharsCount(utilCleanOsmString(val, Number.POSITIVE_INFINITY));
64676       let indicator = _wrap.selectAll("span.length-indicator").data([strLen]);
64677       indicator.enter().append("span").merge(indicator).classed("length-indicator", true).classed("limit-reached", (d2) => d2 > maxChars).style("border-right-width", (d2) => "".concat(Math.abs(maxChars - d2) * 2, "px")).style("margin-right", (d2) => d2 > maxChars ? "".concat((maxChars - d2) * 2, "px") : 0).style("opacity", (d2) => d2 > maxChars * 0.8 ? Math.min(1, (d2 / maxChars - 0.8) / (1 - 0.8)) : 0).style("pointer-events", (d2) => d2 > maxChars * 0.8 ? null : "none");
64678       if (_silent)
64679         return;
64680       if (strLen > maxChars) {
64681         _tooltip.show();
64682       } else {
64683         _tooltip.hide();
64684       }
64685     };
64686     lengthIndicator.silent = function(val) {
64687       if (!arguments.length)
64688         return _silent;
64689       _silent = val;
64690       return lengthIndicator;
64691     };
64692     return lengthIndicator;
64693   }
64694
64695   // modules/ui/fields/combo.js
64696   function uiFieldCombo(field, context) {
64697     var dispatch14 = dispatch_default("change");
64698     var _isMulti = field.type === "multiCombo" || field.type === "manyCombo";
64699     var _isNetwork = field.type === "networkCombo";
64700     var _isSemi = field.type === "semiCombo";
64701     var _showTagInfoSuggestions = field.type !== "manyCombo" && field.autoSuggestions !== false;
64702     var _allowCustomValues = field.type !== "manyCombo" && field.customValues !== false;
64703     var _snake_case = field.snake_case || field.snake_case === void 0;
64704     var _combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(field.caseSensitive).minItems(1);
64705     var _container = select_default2(null);
64706     var _inputWrap = select_default2(null);
64707     var _input = select_default2(null);
64708     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
64709     var _comboData = [];
64710     var _multiData = [];
64711     var _entityIDs = [];
64712     var _tags;
64713     var _countryCode;
64714     var _staticPlaceholder;
64715     var _dataDeprecated = [];
64716     _mainFileFetcher.get("deprecated").then(function(d2) {
64717       _dataDeprecated = d2;
64718     }).catch(function() {
64719     });
64720     if (_isMulti && field.key && /[^:]$/.test(field.key)) {
64721       field.key += ":";
64722     }
64723     function snake(s2) {
64724       return s2.replace(/\s+/g, "_");
64725     }
64726     function clean2(s2) {
64727       return s2.split(";").map(function(s3) {
64728         return s3.trim();
64729       }).join(";");
64730     }
64731     function tagValue(dval) {
64732       dval = clean2(dval || "");
64733       var found = getOptions(true).find(function(o2) {
64734         return o2.key && clean2(o2.value) === dval;
64735       });
64736       if (found)
64737         return found.key;
64738       if (field.type === "typeCombo" && !dval) {
64739         return "yes";
64740       }
64741       return restrictTagValueSpelling(dval) || void 0;
64742     }
64743     function restrictTagValueSpelling(dval) {
64744       if (_snake_case) {
64745         dval = snake(dval);
64746       }
64747       if (!field.caseSensitive) {
64748         dval = dval.toLowerCase();
64749       }
64750       return dval;
64751     }
64752     function getLabelId(field2, v2) {
64753       return field2.hasTextForStringId("options.".concat(v2, ".title")) ? "options.".concat(v2, ".title") : "options.".concat(v2);
64754     }
64755     function displayValue(tval) {
64756       tval = tval || "";
64757       var stringsField = field.resolveReference("stringsCrossReference");
64758       const labelId = getLabelId(stringsField, tval);
64759       if (stringsField.hasTextForStringId(labelId)) {
64760         return stringsField.t(labelId, { default: tval });
64761       }
64762       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
64763         return "";
64764       }
64765       return tval;
64766     }
64767     function renderValue(tval) {
64768       tval = tval || "";
64769       var stringsField = field.resolveReference("stringsCrossReference");
64770       const labelId = getLabelId(stringsField, tval);
64771       if (stringsField.hasTextForStringId(labelId)) {
64772         return stringsField.t.append(labelId, { default: tval });
64773       }
64774       if (field.type === "typeCombo" && tval.toLowerCase() === "yes") {
64775         tval = "";
64776       }
64777       return (selection2) => selection2.text(tval);
64778     }
64779     function objectDifference(a2, b2) {
64780       return a2.filter(function(d1) {
64781         return !b2.some(function(d2) {
64782           return d1.value === d2.value;
64783         });
64784       });
64785     }
64786     function initCombo(selection2, attachTo) {
64787       if (!_allowCustomValues) {
64788         selection2.attr("readonly", "readonly");
64789       }
64790       if (_showTagInfoSuggestions && services.taginfo) {
64791         selection2.call(_combobox.fetcher(setTaginfoValues), attachTo);
64792         setTaginfoValues("", setPlaceholder);
64793       } else {
64794         selection2.call(_combobox, attachTo);
64795         setTimeout(() => setStaticValues(setPlaceholder), 0);
64796       }
64797     }
64798     function getOptions(allOptions) {
64799       var stringsField = field.resolveReference("stringsCrossReference");
64800       if (!(field.options || stringsField.options))
64801         return [];
64802       let options2;
64803       if (allOptions !== true) {
64804         options2 = field.options || stringsField.options;
64805       } else {
64806         options2 = [].concat(field.options, stringsField.options).filter(Boolean);
64807       }
64808       return options2.map(function(v2) {
64809         const labelId = getLabelId(stringsField, v2);
64810         return {
64811           key: v2,
64812           value: stringsField.t(labelId, { default: v2 }),
64813           title: stringsField.t("options.".concat(v2, ".description"), { default: v2 }),
64814           display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
64815           klass: stringsField.hasTextForStringId(labelId) ? "" : "raw-option"
64816         };
64817       });
64818     }
64819     function hasStaticValues() {
64820       return getOptions().length > 0;
64821     }
64822     function setStaticValues(callback, filter2) {
64823       _comboData = getOptions();
64824       if (filter2 !== void 0) {
64825         _comboData = _comboData.filter(filter2);
64826       }
64827       _comboData = objectDifference(_comboData, _multiData);
64828       _combobox.data(_comboData);
64829       if (callback)
64830         callback(_comboData);
64831     }
64832     function setTaginfoValues(q2, callback) {
64833       var queryFilter = (d2) => d2.value.toLowerCase().includes(q2.toLowerCase()) || d2.key.toLowerCase().includes(q2.toLowerCase());
64834       if (hasStaticValues()) {
64835         setStaticValues(callback, queryFilter);
64836       }
64837       var stringsField = field.resolveReference("stringsCrossReference");
64838       var fn = _isMulti ? "multikeys" : "values";
64839       var query = (_isMulti ? field.key : "") + q2;
64840       var hasCountryPrefix = _isNetwork && _countryCode && _countryCode.indexOf(q2.toLowerCase()) === 0;
64841       if (hasCountryPrefix) {
64842         query = _countryCode + ":";
64843       }
64844       var params = {
64845         debounce: q2 !== "",
64846         key: field.key,
64847         query
64848       };
64849       if (_entityIDs.length) {
64850         params.geometry = context.graph().geometry(_entityIDs[0]);
64851       }
64852       services.taginfo[fn](params, function(err, data) {
64853         if (err)
64854           return;
64855         data = data.filter((d2) => field.type !== "typeCombo" || d2.value !== "yes");
64856         data = data.filter((d2) => {
64857           var value = d2.value;
64858           if (_isMulti) {
64859             value = value.slice(field.key.length);
64860           }
64861           return value === restrictTagValueSpelling(value);
64862         });
64863         var deprecatedValues = osmEntity.deprecatedTagValuesByKey(_dataDeprecated)[field.key];
64864         if (deprecatedValues) {
64865           data = data.filter((d2) => !deprecatedValues.includes(d2.value));
64866         }
64867         if (hasCountryPrefix) {
64868           data = data.filter((d2) => d2.value.toLowerCase().indexOf(_countryCode + ":") === 0);
64869         }
64870         const additionalOptions = (field.options || stringsField.options || []).filter((v2) => !data.some((dv) => dv.value === (_isMulti ? field.key + v2 : v2))).map((v2) => ({ value: v2 }));
64871         _container.classed("empty-combobox", data.length === 0);
64872         _comboData = data.concat(additionalOptions).map(function(d2) {
64873           var v2 = d2.value;
64874           if (_isMulti)
64875             v2 = v2.replace(field.key, "");
64876           const labelId = getLabelId(stringsField, v2);
64877           var isLocalizable = stringsField.hasTextForStringId(labelId);
64878           var label = stringsField.t(labelId, { default: v2 });
64879           return {
64880             key: v2,
64881             value: label,
64882             title: stringsField.t("options.".concat(v2, ".description"), { default: isLocalizable ? v2 : d2.title !== label ? d2.title : "" }),
64883             display: addComboboxIcons(stringsField.t.append(labelId, { default: v2 }), v2),
64884             klass: isLocalizable ? "" : "raw-option"
64885           };
64886         });
64887         _comboData = _comboData.filter(queryFilter);
64888         _comboData = objectDifference(_comboData, _multiData);
64889         if (callback)
64890           callback(_comboData, hasStaticValues());
64891       });
64892     }
64893     function addComboboxIcons(disp, value) {
64894       const iconsField = field.resolveReference("iconsCrossReference");
64895       if (iconsField.icons) {
64896         return function(selection2) {
64897           var span = selection2.insert("span", ":first-child").attr("class", "tag-value-icon");
64898           if (iconsField.icons[value]) {
64899             span.call(svgIcon("#".concat(iconsField.icons[value])));
64900           }
64901           disp.call(this, selection2);
64902         };
64903       }
64904       return disp;
64905     }
64906     function setPlaceholder(values) {
64907       if (_isMulti || _isSemi) {
64908         _staticPlaceholder = field.placeholder() || _t("inspector.add");
64909       } else {
64910         var vals = values.map(function(d2) {
64911           return d2.value;
64912         }).filter(function(s2) {
64913           return s2.length < 20;
64914         });
64915         var placeholders = vals.length > 1 ? vals : values.map(function(d2) {
64916           return d2.key;
64917         });
64918         _staticPlaceholder = field.placeholder() || placeholders.slice(0, 3).join(", ");
64919       }
64920       if (!/(…|\.\.\.)$/.test(_staticPlaceholder)) {
64921         _staticPlaceholder += "\u2026";
64922       }
64923       var ph;
64924       if (!_isMulti && !_isSemi && _tags && Array.isArray(_tags[field.key])) {
64925         ph = _t("inspector.multiple_values");
64926       } else {
64927         ph = _staticPlaceholder;
64928       }
64929       _container.selectAll("input").attr("placeholder", ph);
64930       var hideAdd = !_allowCustomValues && !values.length;
64931       _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
64932     }
64933     function change() {
64934       var t2 = {};
64935       var val;
64936       if (_isMulti || _isSemi) {
64937         var vals;
64938         if (_isMulti) {
64939           vals = [tagValue(utilGetSetValue(_input))];
64940         } else if (_isSemi) {
64941           val = tagValue(utilGetSetValue(_input)) || "";
64942           val = val.replace(/,/g, ";");
64943           vals = val.split(";");
64944         }
64945         vals = vals.filter(Boolean);
64946         if (!vals.length)
64947           return;
64948         _container.classed("active", false);
64949         utilGetSetValue(_input, "");
64950         if (_isMulti) {
64951           utilArrayUniq(vals).forEach(function(v2) {
64952             var key = (field.key || "") + v2;
64953             if (_tags) {
64954               var old = _tags[key];
64955               if (typeof old === "string" && old.toLowerCase() !== "no")
64956                 return;
64957             }
64958             key = context.cleanTagKey(key);
64959             field.keys.push(key);
64960             t2[key] = "yes";
64961           });
64962         } else if (_isSemi) {
64963           var arr = _multiData.map(function(d2) {
64964             return d2.key;
64965           });
64966           arr = arr.concat(vals);
64967           t2[field.key] = context.cleanTagValue(utilArrayUniq(arr).filter(Boolean).join(";"));
64968         }
64969         window.setTimeout(function() {
64970           _input.node().focus();
64971         }, 10);
64972       } else {
64973         var rawValue = utilGetSetValue(_input);
64974         if (!rawValue && Array.isArray(_tags[field.key]))
64975           return;
64976         val = context.cleanTagValue(tagValue(rawValue));
64977         t2[field.key] = val || void 0;
64978       }
64979       dispatch14.call("change", this, t2);
64980     }
64981     function removeMultikey(d3_event, d2) {
64982       d3_event.preventDefault();
64983       d3_event.stopPropagation();
64984       var t2 = {};
64985       if (_isMulti) {
64986         t2[d2.key] = void 0;
64987       } else if (_isSemi) {
64988         var arr = _multiData.map(function(md) {
64989           return md.key === d2.key ? null : md.key;
64990         }).filter(Boolean);
64991         arr = utilArrayUniq(arr);
64992         t2[field.key] = arr.length ? arr.join(";") : void 0;
64993         _lengthIndicator.update(t2[field.key]);
64994       }
64995       dispatch14.call("change", this, t2);
64996     }
64997     function invertMultikey(d3_event, d2) {
64998       d3_event.preventDefault();
64999       d3_event.stopPropagation();
65000       var t2 = {};
65001       if (_isMulti) {
65002         t2[d2.key] = _tags[d2.key] === "yes" ? "no" : "yes";
65003       }
65004       dispatch14.call("change", this, t2);
65005     }
65006     function combo(selection2) {
65007       _container = selection2.selectAll(".form-field-input-wrap").data([0]);
65008       var type2 = _isMulti || _isSemi ? "multicombo" : "combo";
65009       _container = _container.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + type2).merge(_container);
65010       if (_isMulti || _isSemi) {
65011         _container = _container.selectAll(".chiplist").data([0]);
65012         var listClass = "chiplist";
65013         if (field.key === "destination" || field.key === "via") {
65014           listClass += " full-line-chips";
65015         }
65016         _container = _container.enter().append("ul").attr("class", listClass).on("click", function() {
65017           window.setTimeout(function() {
65018             _input.node().focus();
65019           }, 10);
65020         }).merge(_container);
65021         _inputWrap = _container.selectAll(".input-wrap").data([0]);
65022         _inputWrap = _inputWrap.enter().append("li").attr("class", "input-wrap").merge(_inputWrap);
65023         var hideAdd = !_allowCustomValues && !_comboData.length;
65024         _inputWrap.style("display", hideAdd ? "none" : null);
65025         _input = _inputWrap.selectAll("input").data([0]);
65026       } else {
65027         _input = _container.selectAll("input").data([0]);
65028       }
65029       _input = _input.enter().append("input").attr("type", "text").attr("id", field.domId).call(utilNoAuto).call(initCombo, _container).merge(_input);
65030       if (_isSemi) {
65031         _inputWrap.call(_lengthIndicator);
65032       } else if (!_isMulti) {
65033         _container.call(_lengthIndicator);
65034       }
65035       if (_isNetwork) {
65036         var extent = combinedEntityExtent();
65037         var countryCode = extent && iso1A2Code(extent.center());
65038         _countryCode = countryCode && countryCode.toLowerCase();
65039       }
65040       _input.on("change", change).on("blur", change).on("input", function() {
65041         let val = utilGetSetValue(_input);
65042         updateIcon(val);
65043         if (_isSemi && _tags[field.key]) {
65044           val += ";" + _tags[field.key];
65045         }
65046         _lengthIndicator.update(val);
65047       });
65048       _input.on("keydown.field", function(d3_event) {
65049         switch (d3_event.keyCode) {
65050           case 13:
65051             _input.node().blur();
65052             d3_event.stopPropagation();
65053             break;
65054         }
65055       });
65056       if (_isMulti || _isSemi) {
65057         _combobox.on("accept", function() {
65058           _input.node().blur();
65059           _input.node().focus();
65060         });
65061         _input.on("focus", function() {
65062           _container.classed("active", true);
65063         });
65064       }
65065       _combobox.on("cancel", function() {
65066         _input.node().blur();
65067       }).on("update", function() {
65068         updateIcon(utilGetSetValue(_input));
65069       });
65070     }
65071     function updateIcon(value) {
65072       value = tagValue(value);
65073       let container = _container;
65074       if (field.type === "multiCombo" || field.type === "semiCombo") {
65075         container = _container.select(".input-wrap");
65076       }
65077       const iconsField = field.resolveReference("iconsCrossReference");
65078       if (iconsField.icons) {
65079         container.selectAll(".tag-value-icon").remove();
65080         if (iconsField.icons[value]) {
65081           container.selectAll(".tag-value-icon").data([value]).enter().insert("div", "input").attr("class", "tag-value-icon").call(svgIcon("#".concat(iconsField.icons[value])));
65082         }
65083       }
65084     }
65085     combo.tags = function(tags) {
65086       _tags = tags;
65087       var stringsField = field.resolveReference("stringsCrossReference");
65088       var isMixed = Array.isArray(tags[field.key]);
65089       var showsValue = (value) => !isMixed && value && !(field.type === "typeCombo" && value === "yes");
65090       var isRawValue = (value) => showsValue(value) && !stringsField.hasTextForStringId("options.".concat(value)) && !stringsField.hasTextForStringId("options.".concat(value, ".title"));
65091       var isKnownValue = (value) => showsValue(value) && !isRawValue(value);
65092       var isReadOnly = !_allowCustomValues;
65093       if (_isMulti || _isSemi) {
65094         _multiData = [];
65095         var maxLength;
65096         if (_isMulti) {
65097           for (var k2 in tags) {
65098             if (field.key && k2.indexOf(field.key) !== 0)
65099               continue;
65100             if (!field.key && field.keys.indexOf(k2) === -1)
65101               continue;
65102             var v2 = tags[k2];
65103             var suffix = field.key ? k2.slice(field.key.length) : k2;
65104             _multiData.push({
65105               key: k2,
65106               value: displayValue(suffix),
65107               display: addComboboxIcons(renderValue(suffix), suffix),
65108               state: typeof v2 === "string" ? v2.toLowerCase() : "",
65109               isMixed: Array.isArray(v2)
65110             });
65111           }
65112           if (field.key) {
65113             field.keys = _multiData.map(function(d2) {
65114               return d2.key;
65115             });
65116             maxLength = context.maxCharsForTagKey() - utilUnicodeCharsCount(field.key);
65117           } else {
65118             maxLength = context.maxCharsForTagKey();
65119           }
65120         } else if (_isSemi) {
65121           var allValues = [];
65122           var commonValues;
65123           if (Array.isArray(tags[field.key])) {
65124             tags[field.key].forEach(function(tagVal) {
65125               var thisVals = utilArrayUniq((tagVal || "").split(";")).filter(Boolean);
65126               allValues = allValues.concat(thisVals);
65127               if (!commonValues) {
65128                 commonValues = thisVals;
65129               } else {
65130                 commonValues = commonValues.filter((value) => thisVals.includes(value));
65131               }
65132             });
65133             allValues = utilArrayUniq(allValues).filter(Boolean);
65134           } else {
65135             allValues = utilArrayUniq((tags[field.key] || "").split(";")).filter(Boolean);
65136             commonValues = allValues;
65137           }
65138           _multiData = allValues.map(function(v3) {
65139             return {
65140               key: v3,
65141               value: displayValue(v3),
65142               display: addComboboxIcons(renderValue(v3), v3),
65143               isMixed: !commonValues.includes(v3)
65144             };
65145           });
65146           var currLength = utilUnicodeCharsCount(commonValues.join(";"));
65147           maxLength = context.maxCharsForTagValue() - currLength;
65148           if (currLength > 0) {
65149             maxLength -= 1;
65150           }
65151         }
65152         maxLength = Math.max(0, maxLength);
65153         var hideAdd = maxLength <= 0 || !_allowCustomValues && !_comboData.length;
65154         _container.selectAll(".chiplist .input-wrap").style("display", hideAdd ? "none" : null);
65155         var allowDragAndDrop = _isSemi && !Array.isArray(tags[field.key]);
65156         var chips = _container.selectAll(".chip").data(_multiData);
65157         chips.exit().remove();
65158         var enter = chips.enter().insert("li", ".input-wrap").attr("class", "chip");
65159         enter.append("span");
65160         const field_buttons = enter.append("div").attr("class", "field_buttons");
65161         field_buttons.append("a").attr("class", "remove");
65162         chips = chips.merge(enter).order().classed("raw-value", function(d2) {
65163           var k3 = d2.key;
65164           if (_isMulti)
65165             k3 = k3.replace(field.key, "");
65166           return !stringsField.hasTextForStringId("options." + k3);
65167         }).classed("draggable", allowDragAndDrop).classed("mixed", function(d2) {
65168           return d2.isMixed;
65169         }).attr("title", function(d2) {
65170           if (d2.isMixed) {
65171             return _t("inspector.unshared_value_tooltip");
65172           }
65173           if (!["yes", "no"].includes(d2.state)) {
65174             return d2.state;
65175           }
65176           return null;
65177         }).classed("negated", (d2) => d2.state === "no");
65178         if (!_isSemi) {
65179           chips.selectAll("input[type=checkbox]").remove();
65180           chips.insert("input", "span").attr("type", "checkbox").property("checked", (d2) => d2.state === "yes").property("indeterminate", (d2) => d2.isMixed || !["yes", "no"].includes(d2.state)).on("click", invertMultikey);
65181         }
65182         if (allowDragAndDrop) {
65183           registerDragAndDrop(chips);
65184         }
65185         chips.each(function(d2) {
65186           const selection2 = select_default2(this);
65187           const text_span = selection2.select("span");
65188           const field_buttons2 = selection2.select(".field_buttons");
65189           const clean_value = d2.value.trim();
65190           text_span.text("");
65191           if (clean_value.startsWith("https://")) {
65192             text_span.text(clean_value);
65193             field_buttons2.select("button").remove();
65194             field_buttons2.append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", () => _t("icons.visit_website")).attr("aria-label", () => _t("icons.visit_website")).on("click", function(d3_event) {
65195               d3_event.preventDefault();
65196               window.open(clean_value, "_blank");
65197             });
65198             return;
65199           }
65200           if (d2.display) {
65201             d2.display(text_span);
65202             return;
65203           }
65204           text_span.text(d2.value);
65205         });
65206         chips.select("a.remove").attr("href", "#").on("click", removeMultikey).attr("class", "remove").text("\xD7");
65207         updateIcon("");
65208       } else {
65209         var mixedValues = isMixed && tags[field.key].map(function(val) {
65210           return displayValue(val);
65211         }).filter(Boolean);
65212         utilGetSetValue(_input, !isMixed ? displayValue(tags[field.key]) : "").data([tags[field.key]]).classed("raw-value", isRawValue).classed("known-value", isKnownValue).attr("readonly", isReadOnly ? "readonly" : void 0).attr("title", isMixed ? mixedValues.join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : _staticPlaceholder || "").classed("mixed", isMixed).on("keydown.deleteCapture", function(d3_event) {
65213           if (isReadOnly && isKnownValue(tags[field.key]) && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
65214             d3_event.preventDefault();
65215             d3_event.stopPropagation();
65216             var t2 = {};
65217             t2[field.key] = void 0;
65218             dispatch14.call("change", this, t2);
65219           }
65220         });
65221         if (!Array.isArray(tags[field.key])) {
65222           updateIcon(tags[field.key]);
65223         }
65224         if (!isMixed) {
65225           _lengthIndicator.update(tags[field.key]);
65226         }
65227       }
65228       const refreshStyles = () => {
65229         _input.data([tagValue(utilGetSetValue(_input))]).classed("raw-value", isRawValue).classed("known-value", isKnownValue);
65230       };
65231       _input.on("input.refreshStyles", refreshStyles);
65232       _combobox.on("update.refreshStyles", refreshStyles);
65233       refreshStyles();
65234     };
65235     function registerDragAndDrop(selection2) {
65236       var dragOrigin, targetIndex;
65237       selection2.call(
65238         drag_default().on("start", function(d3_event) {
65239           dragOrigin = {
65240             x: d3_event.x,
65241             y: d3_event.y
65242           };
65243           targetIndex = null;
65244         }).on("drag", function(d3_event) {
65245           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
65246           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
65247           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5)
65248             return;
65249           var index = selection2.nodes().indexOf(this);
65250           select_default2(this).classed("dragging", true);
65251           targetIndex = null;
65252           var targetIndexOffsetTop = null;
65253           var draggedTagWidth = select_default2(this).node().offsetWidth;
65254           if (field.key === "destination" || field.key === "via") {
65255             _container.selectAll(".chip").style("transform", function(d2, index2) {
65256               var node = select_default2(this).node();
65257               if (index === index2) {
65258                 return "translate(" + x2 + "px, " + y2 + "px)";
65259               } else if (index2 > index && d3_event.y > node.offsetTop) {
65260                 if (targetIndex === null || index2 > targetIndex) {
65261                   targetIndex = index2;
65262                 }
65263                 return "translateY(-100%)";
65264               } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
65265                 if (targetIndex === null || index2 < targetIndex) {
65266                   targetIndex = index2;
65267                 }
65268                 return "translateY(100%)";
65269               }
65270               return null;
65271             });
65272           } else {
65273             _container.selectAll(".chip").each(function(d2, index2) {
65274               var node = select_default2(this).node();
65275               if (index !== index2 && d3_event.x < node.offsetLeft + node.offsetWidth + 5 && d3_event.x > node.offsetLeft && d3_event.y < node.offsetTop + node.offsetHeight && d3_event.y > node.offsetTop) {
65276                 targetIndex = index2;
65277                 targetIndexOffsetTop = node.offsetTop;
65278               }
65279             }).style("transform", function(d2, index2) {
65280               var node = select_default2(this).node();
65281               if (index === index2) {
65282                 return "translate(" + x2 + "px, " + y2 + "px)";
65283               }
65284               if (node.offsetTop === targetIndexOffsetTop) {
65285                 if (index2 < index && index2 >= targetIndex) {
65286                   return "translateX(" + draggedTagWidth + "px)";
65287                 } else if (index2 > index && index2 <= targetIndex) {
65288                   return "translateX(-" + draggedTagWidth + "px)";
65289                 }
65290               }
65291               return null;
65292             });
65293           }
65294         }).on("end", function() {
65295           if (!select_default2(this).classed("dragging")) {
65296             return;
65297           }
65298           var index = selection2.nodes().indexOf(this);
65299           select_default2(this).classed("dragging", false);
65300           _container.selectAll(".chip").style("transform", null);
65301           if (typeof targetIndex === "number") {
65302             var element = _multiData[index];
65303             _multiData.splice(index, 1);
65304             _multiData.splice(targetIndex, 0, element);
65305             var t2 = {};
65306             if (_multiData.length) {
65307               t2[field.key] = _multiData.map(function(element2) {
65308                 return element2.key;
65309               }).join(";");
65310             } else {
65311               t2[field.key] = void 0;
65312             }
65313             dispatch14.call("change", this, t2);
65314           }
65315           dragOrigin = void 0;
65316           targetIndex = void 0;
65317         })
65318       );
65319     }
65320     combo.focus = function() {
65321       _input.node().focus();
65322     };
65323     combo.entityIDs = function(val) {
65324       if (!arguments.length)
65325         return _entityIDs;
65326       _entityIDs = val;
65327       return combo;
65328     };
65329     function combinedEntityExtent() {
65330       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
65331     }
65332     return utilRebind(combo, dispatch14, "on");
65333   }
65334
65335   // modules/ui/fields/input.js
65336   var likelyRawNumberFormat = /^-?(0\.\d*|\d*\.\d{0,2}(\d{4,})?|\d{4,}\.\d{3})$/;
65337   function uiFieldText(field, context) {
65338     var dispatch14 = dispatch_default("change");
65339     var input = select_default2(null);
65340     var outlinkButton = select_default2(null);
65341     var wrap2 = select_default2(null);
65342     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
65343     var _entityIDs = [];
65344     var _tags;
65345     var _phoneFormats = {};
65346     const isDirectionField = field.key.split(":").some((keyPart) => keyPart === "direction");
65347     const formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
65348     const parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
65349     const countDecimalPlaces = _mainLocalizer.decimalPlaceCounter(_mainLocalizer.languageCode());
65350     if (field.type === "tel") {
65351       _mainFileFetcher.get("phone_formats").then(function(d2) {
65352         _phoneFormats = d2;
65353         updatePhonePlaceholder();
65354       }).catch(function() {
65355       });
65356     }
65357     function calcLocked() {
65358       var isLocked = (field.id === "brand" || field.id === "network" || field.id === "operator" || field.id === "flag") && _entityIDs.length && _entityIDs.some(function(entityID) {
65359         var entity = context.graph().hasEntity(entityID);
65360         if (!entity)
65361           return false;
65362         if (entity.tags.wikidata)
65363           return true;
65364         var preset = _mainPresetIndex.match(entity, context.graph());
65365         var isSuggestion = preset && preset.suggestion;
65366         var which = field.id;
65367         return isSuggestion && !!entity.tags[which] && !!entity.tags[which + ":wikidata"];
65368       });
65369       field.locked(isLocked);
65370     }
65371     function i3(selection2) {
65372       calcLocked();
65373       var isLocked = field.locked();
65374       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
65375       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
65376       input = wrap2.selectAll("input").data([0]);
65377       input = input.enter().append("input").attr("type", field.type === "identifier" ? "text" : field.type).attr("id", field.domId).classed(field.type, true).call(utilNoAuto).merge(input);
65378       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
65379       wrap2.call(_lengthIndicator);
65380       if (field.type === "tel") {
65381         updatePhonePlaceholder();
65382       } else if (field.type === "number") {
65383         var rtl = _mainLocalizer.textDirection() === "rtl";
65384         input.attr("type", "text");
65385         var inc = field.increment;
65386         var buttons = wrap2.selectAll(".increment, .decrement").data(rtl ? [inc, -inc] : [-inc, inc]);
65387         buttons.enter().append("button").attr("class", function(d2) {
65388           var which = d2 > 0 ? "increment" : "decrement";
65389           return "form-field-button " + which;
65390         }).attr("title", function(d2) {
65391           var which = d2 > 0 ? "increment" : "decrement";
65392           return _t("inspector.".concat(which));
65393         }).merge(buttons).on("click", function(d3_event, d2) {
65394           d3_event.preventDefault();
65395           var isMixed = Array.isArray(_tags[field.key]);
65396           if (isMixed)
65397             return;
65398           var raw_vals = input.node().value || "0";
65399           var vals = raw_vals.split(";");
65400           vals = vals.map(function(v2) {
65401             v2 = v2.trim();
65402             const isRawNumber = likelyRawNumberFormat.test(v2);
65403             var num = isRawNumber ? parseFloat(v2) : parseLocaleFloat(v2);
65404             if (isDirectionField) {
65405               const compassDir = cardinal[v2.toLowerCase()];
65406               if (compassDir !== void 0) {
65407                 num = compassDir;
65408               }
65409             }
65410             if (!isFinite(num))
65411               return v2;
65412             num = parseFloat(num);
65413             if (!isFinite(num))
65414               return v2;
65415             num += d2;
65416             if (isDirectionField) {
65417               num = (num % 360 + 360) % 360;
65418             }
65419             return formatFloat(clamped(num), isRawNumber ? v2.includes(".") ? v2.split(".")[1].length : 0 : countDecimalPlaces(v2));
65420           });
65421           input.node().value = vals.join(";");
65422           change()();
65423         });
65424       } else if (field.type === "identifier" && field.urlFormat && field.pattern) {
65425         input.attr("type", "text");
65426         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
65427         outlinkButton = outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", function() {
65428           var domainResults = /^https?:\/\/(.{1,}?)\//.exec(field.urlFormat);
65429           if (domainResults.length >= 2 && domainResults[1]) {
65430             var domain = domainResults[1];
65431             return _t("icons.view_on", { domain });
65432           }
65433           return "";
65434         }).merge(outlinkButton);
65435         outlinkButton.on("click", function(d3_event) {
65436           d3_event.preventDefault();
65437           var value = validIdentifierValueForLink();
65438           if (value) {
65439             var url = field.urlFormat.replace(/{value}/, encodeURIComponent(value));
65440             window.open(url, "_blank");
65441           }
65442         }).classed("disabled", () => !validIdentifierValueForLink()).merge(outlinkButton);
65443       } else if (field.type === "url") {
65444         input.attr("type", "text");
65445         outlinkButton = wrap2.selectAll(".foreign-id-permalink").data([0]);
65446         outlinkButton.enter().append("button").call(svgIcon("#iD-icon-out-link")).attr("class", "form-field-button foreign-id-permalink").attr("title", () => _t("icons.visit_website")).on("click", function(d3_event) {
65447           d3_event.preventDefault();
65448           const value = validIdentifierValueForLink();
65449           if (value)
65450             window.open(value, "_blank");
65451         }).merge(outlinkButton);
65452       } else if (field.type === "colour") {
65453         input.attr("type", "text");
65454         updateColourPreview();
65455       } else if (field.type === "date") {
65456         input.attr("type", "text");
65457         updateDateField();
65458       }
65459     }
65460     function updateColourPreview() {
65461       wrap2.selectAll(".colour-preview").remove();
65462       const colour = utilGetSetValue(input);
65463       if (!isColourValid(colour) && colour !== "") {
65464         wrap2.selectAll("input.colour-selector").remove();
65465         wrap2.selectAll(".form-field-button").remove();
65466         return;
65467       }
65468       var colourSelector = wrap2.selectAll(".colour-selector").data([0]);
65469       colourSelector.enter().append("input").attr("type", "color").attr("class", "colour-selector").on("input", debounce_default(function(d3_event) {
65470         d3_event.preventDefault();
65471         var colour2 = this.value;
65472         if (!isColourValid(colour2))
65473           return;
65474         utilGetSetValue(input, this.value);
65475         change()();
65476         updateColourPreview();
65477       }, 100));
65478       wrap2.selectAll("input.colour-selector").attr("value", colour);
65479       var chooserButton = wrap2.selectAll(".colour-preview").data([colour]);
65480       chooserButton = chooserButton.enter().append("div").attr("class", "form-field-button colour-preview").append("div").style("background-color", (d2) => d2).attr("class", "colour-box");
65481       if (colour === "") {
65482         chooserButton = chooserButton.call(svgIcon("#iD-icon-edit"));
65483       }
65484       chooserButton.on("click", () => wrap2.select(".colour-selector").node().showPicker());
65485     }
65486     function updateDateField() {
65487       function isDateValid(date2) {
65488         return date2.match(/^[0-9]{4}(-[0-9]{2}(-[0-9]{2})?)?$/);
65489       }
65490       const date = utilGetSetValue(input);
65491       const now3 = /* @__PURE__ */ new Date();
65492       const today = new Date(now3.getTime() - now3.getTimezoneOffset() * 6e4).toISOString().split("T")[0];
65493       if ((field.key === "check_date" || field.key === "survey:date") && date !== today) {
65494         wrap2.selectAll(".date-set-today").data([0]).enter().append("button").attr("class", "form-field-button date-set-today").call(svgIcon("#fas-rotate")).call(uiTooltip().title(() => _t.append("inspector.set_today"))).on("click", () => {
65495           utilGetSetValue(input, today);
65496           change()();
65497           updateDateField();
65498         });
65499       } else {
65500         wrap2.selectAll(".date-set-today").remove();
65501       }
65502       if (!isDateValid(date) && date !== "") {
65503         wrap2.selectAll("input.date-selector").remove();
65504         wrap2.selectAll(".date-calendar").remove();
65505         return;
65506       }
65507       if (utilDetect().browser !== "Safari") {
65508         var dateSelector = wrap2.selectAll(".date-selector").data([0]);
65509         dateSelector.enter().append("input").attr("type", "date").attr("class", "date-selector").on("input", debounce_default(function(d3_event) {
65510           d3_event.preventDefault();
65511           var date2 = this.value;
65512           if (!isDateValid(date2))
65513             return;
65514           utilGetSetValue(input, this.value);
65515           change()();
65516           updateDateField();
65517         }, 100));
65518         wrap2.selectAll("input.date-selector").attr("value", date);
65519         var calendarButton = wrap2.selectAll(".date-calendar").data([date]);
65520         calendarButton = calendarButton.enter().append("button").attr("class", "form-field-button date-calendar").call(svgIcon("#fas-calendar-days"));
65521         calendarButton.on("click", () => wrap2.select(".date-selector").node().showPicker());
65522       }
65523     }
65524     function updatePhonePlaceholder() {
65525       if (input.empty() || !Object.keys(_phoneFormats).length)
65526         return;
65527       var extent = combinedEntityExtent();
65528       var countryCode = extent && iso1A2Code(extent.center());
65529       var format2 = countryCode && _phoneFormats[countryCode.toLowerCase()];
65530       if (format2)
65531         input.attr("placeholder", format2);
65532     }
65533     function validIdentifierValueForLink() {
65534       var _a2;
65535       const value = utilGetSetValue(input).trim();
65536       if (field.type === "url" && value) {
65537         try {
65538           return new URL(value).href;
65539         } catch (e3) {
65540           return null;
65541         }
65542       }
65543       if (field.type === "identifier" && field.pattern) {
65544         return value && ((_a2 = value.match(new RegExp(field.pattern))) == null ? void 0 : _a2[0]);
65545       }
65546       return null;
65547     }
65548     function clamped(num) {
65549       if (field.minValue !== void 0) {
65550         num = Math.max(num, field.minValue);
65551       }
65552       if (field.maxValue !== void 0) {
65553         num = Math.min(num, field.maxValue);
65554       }
65555       return num;
65556     }
65557     function getVals(tags) {
65558       if (field.keys) {
65559         const multiSelection = context.selectedIDs();
65560         tags = multiSelection.length > 1 ? context.selectedIDs().map((id2) => context.graph().entity(id2)).map((entity) => entity.tags) : [tags];
65561         return tags.map((tags2) => new Set(field.keys.reduce((acc, key) => acc.concat(tags2[key]), []).filter(Boolean))).map((vals) => vals.size === 0 ? /* @__PURE__ */ new Set([void 0]) : vals).reduce((a2, b2) => /* @__PURE__ */ new Set([...a2, ...b2]));
65562       } else {
65563         return new Set([].concat(tags[field.key]));
65564       }
65565     }
65566     function change(onInput) {
65567       return function() {
65568         var t2 = {};
65569         var val = utilGetSetValue(input);
65570         if (!onInput)
65571           val = context.cleanTagValue(val);
65572         if (!val && getVals(_tags).size > 1)
65573           return;
65574         var displayVal = val;
65575         if (field.type === "number" && val) {
65576           var numbers2 = val.split(";");
65577           numbers2 = numbers2.map(function(v2) {
65578             if (likelyRawNumberFormat.test(v2)) {
65579               return v2;
65580             }
65581             var num = parseLocaleFloat(v2);
65582             const fractionDigits = countDecimalPlaces(v2);
65583             return isFinite(num) ? clamped(num).toFixed(fractionDigits) : v2;
65584           });
65585           val = numbers2.join(";");
65586         }
65587         if (!onInput)
65588           utilGetSetValue(input, displayVal);
65589         t2[field.key] = val || void 0;
65590         if (field.keys) {
65591           dispatch14.call("change", this, (tags) => {
65592             if (field.keys.some((key) => tags[key])) {
65593               field.keys.filter((key) => tags[key]).forEach((key) => {
65594                 tags[key] = val || void 0;
65595               });
65596             } else {
65597               tags[field.key] = val || void 0;
65598             }
65599             return tags;
65600           }, onInput);
65601         } else {
65602           dispatch14.call("change", this, t2, onInput);
65603         }
65604       };
65605     }
65606     i3.entityIDs = function(val) {
65607       if (!arguments.length)
65608         return _entityIDs;
65609       _entityIDs = val;
65610       return i3;
65611     };
65612     i3.tags = function(tags) {
65613       var _a2;
65614       _tags = tags;
65615       const vals = getVals(tags);
65616       const isMixed = vals.size > 1;
65617       var val = vals.size === 1 ? (_a2 = [...vals][0]) != null ? _a2 : "" : "";
65618       var shouldUpdate;
65619       if (field.type === "number" && val) {
65620         var numbers2 = val.split(";");
65621         var oriNumbers = utilGetSetValue(input).split(";");
65622         if (numbers2.length !== oriNumbers.length)
65623           shouldUpdate = true;
65624         numbers2 = numbers2.map(function(v2) {
65625           v2 = v2.trim();
65626           var num = Number(v2);
65627           if (!isFinite(num) || v2 === "")
65628             return v2;
65629           const fractionDigits = v2.includes(".") ? v2.split(".")[1].length : 0;
65630           return formatFloat(num, fractionDigits);
65631         });
65632         val = numbers2.join(";");
65633         shouldUpdate = (inputValue, setValue) => {
65634           const inputNums = inputValue.split(";").map(
65635             (setVal) => likelyRawNumberFormat.test(setVal) ? parseFloat(setVal) : parseLocaleFloat(setVal)
65636           );
65637           const setNums = setValue.split(";").map(parseLocaleFloat);
65638           return !isEqual_default(inputNums, setNums);
65639         };
65640       }
65641       utilGetSetValue(input, val, shouldUpdate).attr("title", isMixed ? [...vals].join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder() || _t("inspector.unknown")).classed("mixed", isMixed);
65642       if (field.type === "number") {
65643         const buttons = wrap2.selectAll(".increment, .decrement");
65644         if (isMixed) {
65645           buttons.attr("disabled", "disabled").classed("disabled", true);
65646         } else {
65647           var raw_vals = tags[field.key] || "0";
65648           const canIncDec = raw_vals.split(";").some((val2) => isFinite(Number(val2)) || isDirectionField && cardinal[val2.trim().toLowerCase()]);
65649           buttons.attr("disabled", canIncDec ? null : "disabled").classed("disabled", !canIncDec);
65650         }
65651       }
65652       if (field.type === "tel")
65653         updatePhonePlaceholder();
65654       if (field.type === "colour")
65655         updateColourPreview();
65656       if (field.type === "date")
65657         updateDateField();
65658       if (outlinkButton && !outlinkButton.empty()) {
65659         var disabled = !validIdentifierValueForLink();
65660         outlinkButton.classed("disabled", disabled);
65661       }
65662       if (!isMixed) {
65663         _lengthIndicator.update(tags[field.key]);
65664       }
65665     };
65666     i3.focus = function() {
65667       var node = input.node();
65668       if (node)
65669         node.focus();
65670     };
65671     function combinedEntityExtent() {
65672       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
65673     }
65674     return utilRebind(i3, dispatch14, "on");
65675   }
65676
65677   // modules/ui/fields/access.js
65678   function uiFieldAccess(field, context) {
65679     var dispatch14 = dispatch_default("change");
65680     var items = select_default2(null);
65681     var _tags;
65682     function access(selection2) {
65683       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
65684       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
65685       var list2 = wrap2.selectAll("ul").data([0]);
65686       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
65687       items = list2.selectAll("li").data(field.keys);
65688       var enter = items.enter().append("li").attr("class", function(d2) {
65689         return "labeled-input preset-access-" + d2;
65690       });
65691       enter.append("div").attr("class", "label preset-label-access").attr("for", function(d2) {
65692         return "preset-input-access-" + d2;
65693       }).html(function(d2) {
65694         return field.t.html("types." + d2);
65695       });
65696       enter.append("div").attr("class", "preset-input-access-wrap").append("input").attr("type", "text").attr("class", function(d2) {
65697         return "preset-input-access preset-input-access-" + d2;
65698       }).call(utilNoAuto).each(function(d2) {
65699         select_default2(this).call(
65700           uiCombobox(context, "access-" + d2).data(access.options(d2))
65701         );
65702       });
65703       items = items.merge(enter);
65704       wrap2.selectAll(".preset-input-access").on("change", change).on("blur", change);
65705     }
65706     function change(d3_event, d2) {
65707       var tag2 = {};
65708       var value = context.cleanTagValue(utilGetSetValue(select_default2(this)));
65709       if (!value && typeof _tags[d2] !== "string")
65710         return;
65711       tag2[d2] = value || void 0;
65712       dispatch14.call("change", this, tag2);
65713     }
65714     access.options = function(type2) {
65715       var options2 = [
65716         "yes",
65717         "no",
65718         "designated",
65719         "permissive",
65720         "destination",
65721         "customers",
65722         "private",
65723         "permit",
65724         "unknown"
65725       ];
65726       if (type2 === "access") {
65727         options2 = options2.filter((v2) => v2 !== "yes" && v2 !== "designated");
65728       }
65729       if (type2 === "bicycle") {
65730         options2.splice(options2.length - 4, 0, "dismount");
65731       }
65732       var stringsField = field.resolveReference("stringsCrossReference");
65733       return options2.map(function(option) {
65734         return {
65735           title: stringsField.t("options." + option + ".description"),
65736           value: option
65737         };
65738       });
65739     };
65740     const placeholdersByTag = {
65741       highway: {
65742         footway: {
65743           foot: "designated",
65744           motor_vehicle: "no"
65745         },
65746         steps: {
65747           foot: "yes",
65748           motor_vehicle: "no",
65749           bicycle: "no",
65750           horse: "no"
65751         },
65752         pedestrian: {
65753           foot: "yes",
65754           motor_vehicle: "no"
65755         },
65756         cycleway: {
65757           motor_vehicle: "no",
65758           bicycle: "designated"
65759         },
65760         bridleway: {
65761           motor_vehicle: "no",
65762           horse: "designated"
65763         },
65764         path: {
65765           foot: "yes",
65766           motor_vehicle: "no",
65767           bicycle: "yes",
65768           horse: "yes"
65769         },
65770         motorway: {
65771           foot: "no",
65772           motor_vehicle: "yes",
65773           bicycle: "no",
65774           horse: "no"
65775         },
65776         trunk: {
65777           motor_vehicle: "yes"
65778         },
65779         primary: {
65780           foot: "yes",
65781           motor_vehicle: "yes",
65782           bicycle: "yes",
65783           horse: "yes"
65784         },
65785         secondary: {
65786           foot: "yes",
65787           motor_vehicle: "yes",
65788           bicycle: "yes",
65789           horse: "yes"
65790         },
65791         tertiary: {
65792           foot: "yes",
65793           motor_vehicle: "yes",
65794           bicycle: "yes",
65795           horse: "yes"
65796         },
65797         residential: {
65798           foot: "yes",
65799           motor_vehicle: "yes",
65800           bicycle: "yes",
65801           horse: "yes"
65802         },
65803         unclassified: {
65804           foot: "yes",
65805           motor_vehicle: "yes",
65806           bicycle: "yes",
65807           horse: "yes"
65808         },
65809         service: {
65810           foot: "yes",
65811           motor_vehicle: "yes",
65812           bicycle: "yes",
65813           horse: "yes"
65814         },
65815         motorway_link: {
65816           foot: "no",
65817           motor_vehicle: "yes",
65818           bicycle: "no",
65819           horse: "no"
65820         },
65821         trunk_link: {
65822           motor_vehicle: "yes"
65823         },
65824         primary_link: {
65825           foot: "yes",
65826           motor_vehicle: "yes",
65827           bicycle: "yes",
65828           horse: "yes"
65829         },
65830         secondary_link: {
65831           foot: "yes",
65832           motor_vehicle: "yes",
65833           bicycle: "yes",
65834           horse: "yes"
65835         },
65836         tertiary_link: {
65837           foot: "yes",
65838           motor_vehicle: "yes",
65839           bicycle: "yes",
65840           horse: "yes"
65841         },
65842         construction: {
65843           access: "no"
65844         },
65845         busway: {
65846           access: "no",
65847           bus: "designated",
65848           emergency: "yes"
65849         }
65850       },
65851       barrier: {
65852         bollard: {
65853           access: "no",
65854           bicycle: "yes",
65855           foot: "yes"
65856         },
65857         bus_trap: {
65858           motor_vehicle: "no",
65859           psv: "yes",
65860           foot: "yes",
65861           bicycle: "yes"
65862         },
65863         city_wall: {
65864           access: "no"
65865         },
65866         coupure: {
65867           access: "yes"
65868         },
65869         cycle_barrier: {
65870           motor_vehicle: "no"
65871         },
65872         ditch: {
65873           access: "no"
65874         },
65875         entrance: {
65876           access: "yes"
65877         },
65878         fence: {
65879           access: "no"
65880         },
65881         hedge: {
65882           access: "no"
65883         },
65884         jersey_barrier: {
65885           access: "no"
65886         },
65887         motorcycle_barrier: {
65888           motor_vehicle: "no"
65889         },
65890         rail_guard: {
65891           access: "no"
65892         }
65893       }
65894     };
65895     access.tags = function(tags) {
65896       _tags = tags;
65897       utilGetSetValue(items.selectAll(".preset-input-access"), function(d2) {
65898         return typeof tags[d2] === "string" ? tags[d2] : "";
65899       }).classed("mixed", function(d2) {
65900         return tags[d2] && Array.isArray(tags[d2]);
65901       }).attr("title", function(d2) {
65902         return tags[d2] && Array.isArray(tags[d2]) && tags[d2].filter(Boolean).join("\n");
65903       }).attr("placeholder", function(d2) {
65904         if (tags[d2] && Array.isArray(tags[d2])) {
65905           return _t("inspector.multiple_values");
65906         }
65907         if (d2 === "bicycle" || d2 === "motor_vehicle") {
65908           if (tags.vehicle && typeof tags.vehicle === "string") {
65909             return tags.vehicle;
65910           }
65911         }
65912         if (tags.access && typeof tags.access === "string") {
65913           return tags.access;
65914         }
65915         function getPlaceholdersByTag(key, placeholdersByKey) {
65916           if (typeof tags[key] === "string") {
65917             if (placeholdersByKey[tags[key]] && placeholdersByKey[tags[key]][d2]) {
65918               return placeholdersByKey[tags[key]][d2];
65919             }
65920           } else {
65921             var impliedAccesses = tags[key].filter(Boolean).map(function(val) {
65922               return placeholdersByKey[val] && placeholdersByKey[val][d2];
65923             }).filter(Boolean);
65924             if (impliedAccesses.length === tags[key].length && new Set(impliedAccesses).size === 1) {
65925               return impliedAccesses[0];
65926             }
65927           }
65928         }
65929         for (const key in placeholdersByTag) {
65930           if (tags[key]) {
65931             const impliedAccess = getPlaceholdersByTag(key, placeholdersByTag[key]);
65932             if (impliedAccess) {
65933               return impliedAccess;
65934             }
65935           }
65936         }
65937         if (d2 === "access" && !tags.barrier) {
65938           return "yes";
65939         }
65940         return field.placeholder();
65941       });
65942     };
65943     access.focus = function() {
65944       items.selectAll(".preset-input-access").node().focus();
65945     };
65946     return utilRebind(access, dispatch14, "on");
65947   }
65948
65949   // modules/ui/fields/address.js
65950   function uiFieldAddress(field, context) {
65951     var dispatch14 = dispatch_default("change");
65952     var _selection = select_default2(null);
65953     var _wrap = select_default2(null);
65954     var addrField = _mainPresetIndex.field("address");
65955     var _entityIDs = [];
65956     var _tags;
65957     var _countryCode;
65958     var _addressFormats = [{
65959       format: [
65960         ["housenumber", "street"],
65961         ["city", "postcode"]
65962       ]
65963     }];
65964     _mainFileFetcher.get("address_formats").then(function(d2) {
65965       _addressFormats = d2;
65966       if (!_selection.empty()) {
65967         _selection.call(address);
65968       }
65969     }).catch(function() {
65970     });
65971     function getNear(isAddressable, type2, searchRadius, resultProp) {
65972       var extent = combinedEntityExtent();
65973       var l2 = extent.center();
65974       var box = geoExtent(l2).padByMeters(searchRadius);
65975       var features = context.history().intersects(box).filter(isAddressable).map((d2) => {
65976         let dist = geoSphericalDistance(d2.extent(context.graph()).center(), l2);
65977         if (d2.geometry(context.graph()) === "line") {
65978           var loc = context.projection([
65979             (extent[0][0] + extent[1][0]) / 2,
65980             (extent[0][1] + extent[1][1]) / 2
65981           ]);
65982           var choice = geoChooseEdge(context.graph().childNodes(d2), loc, context.projection);
65983           dist = geoSphericalDistance(choice.loc, l2);
65984         }
65985         const value = resultProp && d2.tags[resultProp] ? d2.tags[resultProp] : d2.tags.name;
65986         let title = value;
65987         if (type2 === "street") {
65988           title = "".concat(addrField.t("placeholders.street"), ": ").concat(title);
65989         } else if (type2 === "place") {
65990           title = "".concat(addrField.t("placeholders.place"), ": ").concat(title);
65991         }
65992         return {
65993           title,
65994           value,
65995           dist,
65996           type: type2,
65997           klass: "address-".concat(type2)
65998         };
65999       }).sort(function(a2, b2) {
66000         return a2.dist - b2.dist;
66001       });
66002       return utilArrayUniqBy(features, "value");
66003     }
66004     function getNearStreets() {
66005       function isAddressable(d2) {
66006         return d2.tags.highway && d2.tags.name && d2.type === "way";
66007       }
66008       return getNear(isAddressable, "street", 200);
66009     }
66010     function getNearPlaces() {
66011       function isAddressable(d2) {
66012         if (d2.tags.name) {
66013           if (d2.tags.place)
66014             return true;
66015           if (d2.tags.boundary === "administrative" && d2.tags.admin_level > 8)
66016             return true;
66017         }
66018         return false;
66019       }
66020       return getNear(isAddressable, "place", 200);
66021     }
66022     function getNearCities() {
66023       function isAddressable(d2) {
66024         if (d2.tags.name) {
66025           if (d2.tags.boundary === "administrative" && d2.tags.admin_level === "8")
66026             return true;
66027           if (d2.tags.border_type === "city")
66028             return true;
66029           if (d2.tags.place === "city" || d2.tags.place === "town" || d2.tags.place === "village")
66030             return true;
66031         }
66032         if (d2.tags["".concat(field.key, ":city")])
66033           return true;
66034         return false;
66035       }
66036       return getNear(isAddressable, "city", 200, "".concat(field.key, ":city"));
66037     }
66038     function getNearPostcodes() {
66039       return [...new Set([].concat(getNearValues("postcode")).concat(getNear((d2) => d2.tags.postal_code, "postcode", 200, "postal_code")))];
66040     }
66041     function getNearValues(key) {
66042       const tagKey = "".concat(field.key, ":").concat(key);
66043       function hasTag(d2) {
66044         return _entityIDs.indexOf(d2.id) === -1 && d2.tags[tagKey];
66045       }
66046       return getNear(hasTag, key, 200, tagKey);
66047     }
66048     function updateForCountryCode() {
66049       if (!_countryCode)
66050         return;
66051       var addressFormat;
66052       for (var i3 = 0; i3 < _addressFormats.length; i3++) {
66053         var format2 = _addressFormats[i3];
66054         if (!format2.countryCodes) {
66055           addressFormat = format2;
66056         } else if (format2.countryCodes.indexOf(_countryCode) !== -1) {
66057           addressFormat = format2;
66058           break;
66059         }
66060       }
66061       var dropdowns = addressFormat.dropdowns || [
66062         "city",
66063         "county",
66064         "country",
66065         "district",
66066         "hamlet",
66067         "neighbourhood",
66068         "place",
66069         "postcode",
66070         "province",
66071         "quarter",
66072         "state",
66073         "street",
66074         "street+place",
66075         "subdistrict",
66076         "suburb"
66077       ];
66078       var widths = addressFormat.widths || {
66079         housenumber: 1 / 5,
66080         unit: 1 / 5,
66081         street: 1 / 2,
66082         place: 1 / 2,
66083         city: 2 / 3,
66084         state: 1 / 4,
66085         postcode: 1 / 3
66086       };
66087       function row(r2) {
66088         var total = r2.reduce(function(sum, key) {
66089           return sum + (widths[key] || 0.5);
66090         }, 0);
66091         return r2.map(function(key) {
66092           return {
66093             id: key,
66094             width: (widths[key] || 0.5) / total
66095           };
66096         });
66097       }
66098       var rows = _wrap.selectAll(".addr-row").data(addressFormat.format, function(d2) {
66099         return d2.toString();
66100       });
66101       rows.exit().remove();
66102       rows.enter().append("div").attr("class", "addr-row").selectAll("input").data(row).enter().append("input").property("type", "text").call(updatePlaceholder).attr("class", function(d2) {
66103         return "addr-" + d2.id;
66104       }).call(utilNoAuto).each(addDropdown).style("width", function(d2) {
66105         return d2.width * 100 + "%";
66106       });
66107       function addDropdown(d2) {
66108         if (dropdowns.indexOf(d2.id) === -1)
66109           return;
66110         var nearValues;
66111         switch (d2.id) {
66112           case "street":
66113             nearValues = getNearStreets;
66114             break;
66115           case "place":
66116             nearValues = getNearPlaces;
66117             break;
66118           case "street+place":
66119             nearValues = () => [].concat(getNearStreets()).concat(getNearPlaces());
66120             d2.isAutoStreetPlace = true;
66121             d2.id = _tags["".concat(field.key, ":place")] ? "place" : "street";
66122             break;
66123           case "city":
66124             nearValues = getNearCities;
66125             break;
66126           case "postcode":
66127             nearValues = getNearPostcodes;
66128             break;
66129           default:
66130             nearValues = getNearValues;
66131         }
66132         select_default2(this).call(
66133           uiCombobox(context, "address-".concat(d2.isAutoStreetPlace ? "street-place" : d2.id)).minItems(1).caseSensitive(true).fetcher(function(typedValue, callback) {
66134             typedValue = typedValue.toLowerCase();
66135             callback(nearValues(d2.id).filter((v2) => v2.value.toLowerCase().indexOf(typedValue) !== -1));
66136           }).on("accept", function(selected) {
66137             if (d2.isAutoStreetPlace) {
66138               d2.id = selected ? selected.type : "street";
66139             }
66140           })
66141         );
66142       }
66143       _wrap.selectAll("input").on("blur", change()).on("change", change());
66144       _wrap.selectAll("input:not(.combobox-input)").on("input", change(true));
66145       if (_tags)
66146         updateTags(_tags);
66147     }
66148     function address(selection2) {
66149       _selection = selection2;
66150       _wrap = selection2.selectAll(".form-field-input-wrap").data([0]);
66151       _wrap = _wrap.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(_wrap);
66152       var extent = combinedEntityExtent();
66153       if (extent) {
66154         var countryCode;
66155         if (context.inIntro()) {
66156           countryCode = _t("intro.graph.countrycode");
66157         } else {
66158           var center = extent.center();
66159           countryCode = iso1A2Code(center);
66160         }
66161         if (countryCode) {
66162           _countryCode = countryCode.toLowerCase();
66163           updateForCountryCode();
66164         }
66165       }
66166     }
66167     function change(onInput) {
66168       return function() {
66169         setTimeout(() => {
66170           var tags = {};
66171           _wrap.selectAll("input").each(function(subfield) {
66172             var key = field.key + ":" + subfield.id;
66173             var value = this.value;
66174             if (!onInput)
66175               value = context.cleanTagValue(value);
66176             if (Array.isArray(_tags[key]) && !value)
66177               return;
66178             if (subfield.isAutoStreetPlace) {
66179               if (subfield.id === "street") {
66180                 tags["".concat(field.key, ":place")] = void 0;
66181               } else if (subfield.id === "place") {
66182                 tags["".concat(field.key, ":street")] = void 0;
66183               }
66184             }
66185             tags[key] = value || void 0;
66186           });
66187           Object.keys(tags).filter((k2) => tags[k2]).forEach((k2) => _tags[k2] = tags[k2]);
66188           dispatch14.call("change", this, tags, onInput);
66189         }, 0);
66190       };
66191     }
66192     function updatePlaceholder(inputSelection) {
66193       return inputSelection.attr("placeholder", function(subfield) {
66194         if (_tags && Array.isArray(_tags[field.key + ":" + subfield.id])) {
66195           return _t("inspector.multiple_values");
66196         }
66197         if (subfield.isAutoStreetPlace) {
66198           return "".concat(getLocalPlaceholder("street"), " / ").concat(getLocalPlaceholder("place"));
66199         }
66200         return getLocalPlaceholder(subfield.id);
66201       });
66202     }
66203     function getLocalPlaceholder(key) {
66204       if (_countryCode) {
66205         var localkey = key + "!" + _countryCode;
66206         var tkey = addrField.hasTextForStringId("placeholders." + localkey) ? localkey : key;
66207         return addrField.t("placeholders." + tkey);
66208       }
66209     }
66210     function updateTags(tags) {
66211       utilGetSetValue(_wrap.selectAll("input"), (subfield) => {
66212         var val;
66213         if (subfield.isAutoStreetPlace) {
66214           const streetKey = "".concat(field.key, ":street");
66215           const placeKey = "".concat(field.key, ":place");
66216           if (tags[streetKey] !== void 0 || tags[placeKey] === void 0) {
66217             val = tags[streetKey];
66218             subfield.id = "street";
66219           } else {
66220             val = tags[placeKey];
66221             subfield.id = "place";
66222           }
66223         } else {
66224           val = tags["".concat(field.key, ":").concat(subfield.id)];
66225         }
66226         return typeof val === "string" ? val : "";
66227       }).attr("title", function(subfield) {
66228         var val = tags[field.key + ":" + subfield.id];
66229         return val && Array.isArray(val) ? val.filter(Boolean).join("\n") : void 0;
66230       }).classed("mixed", function(subfield) {
66231         return Array.isArray(tags[field.key + ":" + subfield.id]);
66232       }).call(updatePlaceholder);
66233     }
66234     function combinedEntityExtent() {
66235       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66236     }
66237     address.entityIDs = function(val) {
66238       if (!arguments.length)
66239         return _entityIDs;
66240       _entityIDs = val;
66241       return address;
66242     };
66243     address.tags = function(tags) {
66244       _tags = tags;
66245       updateTags(tags);
66246     };
66247     address.focus = function() {
66248       var node = _wrap.selectAll("input").node();
66249       if (node)
66250         node.focus();
66251     };
66252     return utilRebind(address, dispatch14, "on");
66253   }
66254
66255   // modules/ui/fields/directional_combo.js
66256   function uiFieldDirectionalCombo(field, context) {
66257     var dispatch14 = dispatch_default("change");
66258     var items = select_default2(null);
66259     var wrap2 = select_default2(null);
66260     var _tags;
66261     var _combos = {};
66262     if (field.type === "cycleway") {
66263       field = {
66264         ...field,
66265         key: field.keys[0],
66266         keys: field.keys.slice(1)
66267       };
66268     }
66269     function directionalCombo(selection2) {
66270       function stripcolon(s2) {
66271         return s2.replace(":", "");
66272       }
66273       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66274       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66275       var div = wrap2.selectAll("ul").data([0]);
66276       div = div.enter().append("ul").attr("class", "rows rows-table").merge(div);
66277       items = div.selectAll("li").data(field.keys);
66278       var enter = items.enter().append("li").attr("class", function(d2) {
66279         return "labeled-input preset-directionalcombo-" + stripcolon(d2);
66280       });
66281       enter.append("div").attr("class", "label preset-label-directionalcombo").attr("for", function(d2) {
66282         return "preset-input-directionalcombo-" + stripcolon(d2);
66283       }).html(function(d2) {
66284         return field.t.html("types." + d2);
66285       });
66286       enter.append("div").attr("class", "preset-input-directionalcombo-wrap form-field-input-wrap").each(function(key) {
66287         const subField = {
66288           ...field,
66289           type: "combo",
66290           key
66291         };
66292         const combo = uiFieldCombo(subField, context);
66293         combo.on("change", (t2) => change(key, t2[key]));
66294         _combos[key] = combo;
66295         select_default2(this).call(combo);
66296       });
66297       items = items.merge(enter);
66298       wrap2.selectAll(".preset-input-directionalcombo").on("change", change).on("blur", change);
66299     }
66300     function change(key, newValue) {
66301       const commonKey = field.key;
66302       const otherKey = key === field.keys[0] ? field.keys[1] : field.keys[0];
66303       dispatch14.call("change", this, (tags) => {
66304         const otherValue = tags[otherKey] || tags[commonKey];
66305         if (newValue === otherValue) {
66306           tags[commonKey] = newValue;
66307           delete tags[key];
66308           delete tags[otherKey];
66309         } else {
66310           tags[key] = newValue;
66311           delete tags[commonKey];
66312           tags[otherKey] = otherValue;
66313         }
66314         return tags;
66315       });
66316     }
66317     directionalCombo.tags = function(tags) {
66318       _tags = tags;
66319       const commonKey = field.key;
66320       for (let key in _combos) {
66321         const uniqueValues = [...new Set([].concat(_tags[commonKey]).concat(_tags[key]).filter(Boolean))];
66322         _combos[key].tags({ [key]: uniqueValues.length > 1 ? uniqueValues : uniqueValues[0] });
66323       }
66324     };
66325     directionalCombo.focus = function() {
66326       var node = wrap2.selectAll("input").node();
66327       if (node)
66328         node.focus();
66329     };
66330     return utilRebind(directionalCombo, dispatch14, "on");
66331   }
66332
66333   // modules/ui/fields/lanes.js
66334   function uiFieldLanes(field, context) {
66335     var dispatch14 = dispatch_default("change");
66336     var LANE_WIDTH = 40;
66337     var LANE_HEIGHT = 200;
66338     var _entityIDs = [];
66339     function lanes(selection2) {
66340       var lanesData = context.entity(_entityIDs[0]).lanes();
66341       if (!context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode) {
66342         selection2.call(lanes.off);
66343         return;
66344       }
66345       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66346       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66347       var surface = wrap2.selectAll(".surface").data([0]);
66348       var d2 = utilGetDimensions(wrap2);
66349       var freeSpace = d2[0] - lanesData.lanes.length * LANE_WIDTH * 1.5 + LANE_WIDTH * 0.5;
66350       surface = surface.enter().append("svg").attr("width", d2[0]).attr("height", 300).attr("class", "surface").merge(surface);
66351       var lanesSelection = surface.selectAll(".lanes").data([0]);
66352       lanesSelection = lanesSelection.enter().append("g").attr("class", "lanes").merge(lanesSelection);
66353       lanesSelection.attr("transform", function() {
66354         return "translate(" + freeSpace / 2 + ", 0)";
66355       });
66356       var lane = lanesSelection.selectAll(".lane").data(lanesData.lanes);
66357       lane.exit().remove();
66358       var enter = lane.enter().append("g").attr("class", "lane");
66359       enter.append("g").append("rect").attr("y", 50).attr("width", LANE_WIDTH).attr("height", LANE_HEIGHT);
66360       enter.append("g").attr("class", "forward").append("text").attr("y", 40).attr("x", 14).text("\u25B2");
66361       enter.append("g").attr("class", "bothways").append("text").attr("y", 40).attr("x", 14).text("\u25B2\u25BC");
66362       enter.append("g").attr("class", "backward").append("text").attr("y", 40).attr("x", 14).text("\u25BC");
66363       lane = lane.merge(enter);
66364       lane.attr("transform", function(d4) {
66365         return "translate(" + LANE_WIDTH * d4.index * 1.5 + ", 0)";
66366       });
66367       lane.select(".forward").style("visibility", function(d4) {
66368         return d4.direction === "forward" ? "visible" : "hidden";
66369       });
66370       lane.select(".bothways").style("visibility", function(d4) {
66371         return d4.direction === "bothways" ? "visible" : "hidden";
66372       });
66373       lane.select(".backward").style("visibility", function(d4) {
66374         return d4.direction === "backward" ? "visible" : "hidden";
66375       });
66376     }
66377     lanes.entityIDs = function(val) {
66378       _entityIDs = val;
66379     };
66380     lanes.tags = function() {
66381     };
66382     lanes.focus = function() {
66383     };
66384     lanes.off = function() {
66385     };
66386     return utilRebind(lanes, dispatch14, "on");
66387   }
66388   uiFieldLanes.supportsMultiselection = false;
66389
66390   // modules/ui/fields/localized.js
66391   var _languagesArray = [];
66392   function uiFieldLocalized(field, context) {
66393     var dispatch14 = dispatch_default("change", "input");
66394     var wikipedia = services.wikipedia;
66395     var input = select_default2(null);
66396     var localizedInputs = select_default2(null);
66397     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue());
66398     var _countryCode;
66399     var _tags;
66400     _mainFileFetcher.get("languages").then(loadLanguagesArray).catch(function() {
66401     });
66402     var _territoryLanguages = {};
66403     _mainFileFetcher.get("territory_languages").then(function(d2) {
66404       _territoryLanguages = d2;
66405     }).catch(function() {
66406     });
66407     var langCombo = uiCombobox(context, "localized-lang").fetcher(fetchLanguages).minItems(0);
66408     var _selection = select_default2(null);
66409     var _multilingual = [];
66410     var _buttonTip = uiTooltip().title(() => _t.append("translate.translate")).placement("left");
66411     var _wikiTitles;
66412     var _entityIDs = [];
66413     function loadLanguagesArray(dataLanguages) {
66414       if (_languagesArray.length !== 0)
66415         return;
66416       var replacements = {
66417         sr: "sr-Cyrl",
66418         // in OSM, `sr` implies Cyrillic
66419         "sr-Cyrl": false
66420         // `sr-Cyrl` isn't used in OSM
66421       };
66422       for (var code in dataLanguages) {
66423         if (replacements[code] === false)
66424           continue;
66425         var metaCode = code;
66426         if (replacements[code])
66427           metaCode = replacements[code];
66428         _languagesArray.push({
66429           localName: _mainLocalizer.languageName(metaCode, { localOnly: true }),
66430           nativeName: dataLanguages[metaCode].nativeName,
66431           code,
66432           label: _mainLocalizer.languageName(metaCode)
66433         });
66434       }
66435     }
66436     function calcLocked() {
66437       var isLocked = field.id === "name" && _entityIDs.length && _entityIDs.some(function(entityID) {
66438         var entity = context.graph().hasEntity(entityID);
66439         if (!entity)
66440           return false;
66441         if (entity.tags.wikidata)
66442           return true;
66443         if (entity.tags["name:etymology:wikidata"])
66444           return true;
66445         var preset = _mainPresetIndex.match(entity, context.graph());
66446         if (preset) {
66447           var isSuggestion = preset.suggestion;
66448           var fields = preset.fields(entity.extent(context.graph()).center());
66449           var showsBrandField = fields.some(function(d2) {
66450             return d2.id === "brand";
66451           });
66452           var showsOperatorField = fields.some(function(d2) {
66453             return d2.id === "operator";
66454           });
66455           var setsName = preset.addTags.name;
66456           var setsBrandWikidata = preset.addTags["brand:wikidata"];
66457           var setsOperatorWikidata = preset.addTags["operator:wikidata"];
66458           return isSuggestion && setsName && (setsBrandWikidata && !showsBrandField || setsOperatorWikidata && !showsOperatorField);
66459         }
66460         return false;
66461       });
66462       field.locked(isLocked);
66463     }
66464     function calcMultilingual(tags) {
66465       var existingLangsOrdered = _multilingual.map(function(item2) {
66466         return item2.lang;
66467       });
66468       var existingLangs = new Set(existingLangsOrdered.filter(Boolean));
66469       for (var k2 in tags) {
66470         var m2 = k2.match(/^(.*):([a-z]{2,3}(?:-[A-Z][a-z]{3})?(?:-[A-Z]{2})?)$/);
66471         if (m2 && m2[1] === field.key && m2[2]) {
66472           var item = { lang: m2[2], value: tags[k2] };
66473           if (existingLangs.has(item.lang)) {
66474             _multilingual[existingLangsOrdered.indexOf(item.lang)].value = item.value;
66475             existingLangs.delete(item.lang);
66476           } else {
66477             _multilingual.push(item);
66478           }
66479         }
66480       }
66481       _multilingual.forEach(function(item2) {
66482         if (item2.lang && existingLangs.has(item2.lang)) {
66483           item2.value = "";
66484         }
66485       });
66486     }
66487     function localized(selection2) {
66488       _selection = selection2;
66489       calcLocked();
66490       var isLocked = field.locked();
66491       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66492       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66493       input = wrap2.selectAll(".localized-main").data([0]);
66494       input = input.enter().append("input").attr("type", "text").attr("id", field.domId).attr("class", "localized-main").call(utilNoAuto).merge(input);
66495       input.classed("disabled", !!isLocked).attr("readonly", isLocked || null).on("input", change(true)).on("blur", change()).on("change", change());
66496       wrap2.call(_lengthIndicator);
66497       var translateButton = wrap2.selectAll(".localized-add").data([0]);
66498       translateButton = translateButton.enter().append("button").attr("class", "localized-add form-field-button").attr("aria-label", _t("icons.plus")).call(svgIcon("#iD-icon-plus")).merge(translateButton);
66499       translateButton.classed("disabled", !!isLocked).call(isLocked ? _buttonTip.destroy : _buttonTip).on("click", addNew);
66500       if (_tags && !_multilingual.length) {
66501         calcMultilingual(_tags);
66502       }
66503       localizedInputs = selection2.selectAll(".localized-multilingual").data([0]);
66504       localizedInputs = localizedInputs.enter().append("div").attr("class", "localized-multilingual").merge(localizedInputs);
66505       localizedInputs.call(renderMultilingual);
66506       localizedInputs.selectAll("button, input").classed("disabled", !!isLocked).attr("readonly", isLocked || null);
66507       selection2.selectAll(".combobox-caret").classed("nope", true);
66508       function addNew(d3_event) {
66509         d3_event.preventDefault();
66510         if (field.locked())
66511           return;
66512         var defaultLang = _mainLocalizer.languageCode().toLowerCase();
66513         var langExists = _multilingual.find(function(datum2) {
66514           return datum2.lang === defaultLang;
66515         });
66516         var isLangEn = defaultLang.indexOf("en") > -1;
66517         if (isLangEn || langExists) {
66518           defaultLang = "";
66519           langExists = _multilingual.find(function(datum2) {
66520             return datum2.lang === defaultLang;
66521           });
66522         }
66523         if (!langExists) {
66524           _multilingual.unshift({ lang: defaultLang, value: "" });
66525           localizedInputs.call(renderMultilingual);
66526         }
66527       }
66528       function change(onInput) {
66529         return function(d3_event) {
66530           if (field.locked()) {
66531             d3_event.preventDefault();
66532             return;
66533           }
66534           var val = utilGetSetValue(select_default2(this));
66535           if (!onInput)
66536             val = context.cleanTagValue(val);
66537           if (!val && Array.isArray(_tags[field.key]))
66538             return;
66539           var t2 = {};
66540           t2[field.key] = val || void 0;
66541           dispatch14.call("change", this, t2, onInput);
66542         };
66543       }
66544     }
66545     function key(lang) {
66546       return field.key + ":" + lang;
66547     }
66548     function changeLang(d3_event, d2) {
66549       var tags = {};
66550       var lang = utilGetSetValue(select_default2(this)).toLowerCase();
66551       var language = _languagesArray.find(function(d4) {
66552         return d4.label.toLowerCase() === lang || d4.localName && d4.localName.toLowerCase() === lang || d4.nativeName && d4.nativeName.toLowerCase() === lang;
66553       });
66554       if (language)
66555         lang = language.code;
66556       if (d2.lang && d2.lang !== lang) {
66557         tags[key(d2.lang)] = void 0;
66558       }
66559       var newKey = lang && context.cleanTagKey(key(lang));
66560       var value = utilGetSetValue(select_default2(this.parentNode).selectAll(".localized-value"));
66561       if (newKey && value) {
66562         tags[newKey] = value;
66563       } else if (newKey && _wikiTitles && _wikiTitles[d2.lang]) {
66564         tags[newKey] = _wikiTitles[d2.lang];
66565       }
66566       d2.lang = lang;
66567       dispatch14.call("change", this, tags);
66568     }
66569     function changeValue(d3_event, d2) {
66570       if (!d2.lang)
66571         return;
66572       var value = context.cleanTagValue(utilGetSetValue(select_default2(this))) || void 0;
66573       if (!value && Array.isArray(d2.value))
66574         return;
66575       var t2 = {};
66576       t2[key(d2.lang)] = value;
66577       d2.value = value;
66578       dispatch14.call("change", this, t2);
66579     }
66580     function fetchLanguages(value, cb) {
66581       var v2 = value.toLowerCase();
66582       var langCodes = [_mainLocalizer.localeCode(), _mainLocalizer.languageCode()];
66583       if (_countryCode && _territoryLanguages[_countryCode]) {
66584         langCodes = langCodes.concat(_territoryLanguages[_countryCode]);
66585       }
66586       var langItems = [];
66587       langCodes.forEach(function(code) {
66588         var langItem = _languagesArray.find(function(item) {
66589           return item.code === code;
66590         });
66591         if (langItem)
66592           langItems.push(langItem);
66593       });
66594       langItems = utilArrayUniq(langItems.concat(_languagesArray));
66595       cb(langItems.filter(function(d2) {
66596         return d2.label.toLowerCase().indexOf(v2) >= 0 || d2.localName && d2.localName.toLowerCase().indexOf(v2) >= 0 || d2.nativeName && d2.nativeName.toLowerCase().indexOf(v2) >= 0 || d2.code.toLowerCase().indexOf(v2) >= 0;
66597       }).map(function(d2) {
66598         return { value: d2.label };
66599       }));
66600     }
66601     function renderMultilingual(selection2) {
66602       var entries = selection2.selectAll("div.entry").data(_multilingual, function(d2) {
66603         return d2.lang;
66604       });
66605       entries.exit().style("top", "0").style("max-height", "240px").transition().duration(200).style("opacity", "0").style("max-height", "0px").remove();
66606       var entriesEnter = entries.enter().append("div").attr("class", "entry").each(function(_2, index) {
66607         var wrap2 = select_default2(this);
66608         var domId = utilUniqueDomId(index);
66609         var label = wrap2.append("label").attr("class", "field-label").attr("for", domId);
66610         var text = label.append("span").attr("class", "label-text");
66611         text.append("span").attr("class", "label-textvalue").call(_t.append("translate.localized_translation_label"));
66612         text.append("span").attr("class", "label-textannotation");
66613         label.append("button").attr("class", "remove-icon-multilingual").attr("title", _t("icons.remove")).on("click", function(d3_event, d2) {
66614           if (field.locked())
66615             return;
66616           d3_event.preventDefault();
66617           _multilingual.splice(_multilingual.indexOf(d2), 1);
66618           var langKey = d2.lang && key(d2.lang);
66619           if (langKey && langKey in _tags) {
66620             delete _tags[langKey];
66621             var t2 = {};
66622             t2[langKey] = void 0;
66623             dispatch14.call("change", this, t2);
66624             return;
66625           }
66626           renderMultilingual(selection2);
66627         }).call(svgIcon("#iD-operation-delete"));
66628         wrap2.append("input").attr("class", "localized-lang").attr("id", domId).attr("type", "text").attr("placeholder", _t("translate.localized_translation_language")).on("blur", changeLang).on("change", changeLang).call(langCombo);
66629         wrap2.append("input").attr("type", "text").attr("class", "localized-value").on("blur", changeValue).on("change", changeValue);
66630       });
66631       entriesEnter.style("margin-top", "0px").style("max-height", "0px").style("opacity", "0").transition().duration(200).style("margin-top", "10px").style("max-height", "240px").style("opacity", "1").on("end", function() {
66632         select_default2(this).style("max-height", "").style("overflow", "visible");
66633       });
66634       entries = entries.merge(entriesEnter);
66635       entries.order();
66636       entries.classed("present", true);
66637       utilGetSetValue(entries.select(".localized-lang"), function(d2) {
66638         var langItem = _languagesArray.find(function(item) {
66639           return item.code === d2.lang;
66640         });
66641         if (langItem)
66642           return langItem.label;
66643         return d2.lang;
66644       });
66645       utilGetSetValue(entries.select(".localized-value"), function(d2) {
66646         return typeof d2.value === "string" ? d2.value : "";
66647       }).attr("title", function(d2) {
66648         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : null;
66649       }).attr("placeholder", function(d2) {
66650         return Array.isArray(d2.value) ? _t("inspector.multiple_values") : _t("translate.localized_translation_name");
66651       }).classed("mixed", function(d2) {
66652         return Array.isArray(d2.value);
66653       });
66654     }
66655     localized.tags = function(tags) {
66656       _tags = tags;
66657       if (typeof tags.wikipedia === "string" && !_wikiTitles) {
66658         _wikiTitles = {};
66659         var wm = tags.wikipedia.match(/([^:]+):(.+)/);
66660         if (wm && wm[0] && wm[1]) {
66661           wikipedia.translations(wm[1], wm[2], function(err, d2) {
66662             if (err || !d2)
66663               return;
66664             _wikiTitles = d2;
66665           });
66666         }
66667       }
66668       var isMixed = Array.isArray(tags[field.key]);
66669       utilGetSetValue(input, typeof tags[field.key] === "string" ? tags[field.key] : "").attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder()).classed("mixed", isMixed);
66670       calcMultilingual(tags);
66671       _selection.call(localized);
66672       if (!isMixed) {
66673         _lengthIndicator.update(tags[field.key]);
66674       }
66675     };
66676     localized.focus = function() {
66677       input.node().focus();
66678     };
66679     localized.entityIDs = function(val) {
66680       if (!arguments.length)
66681         return _entityIDs;
66682       _entityIDs = val;
66683       _multilingual = [];
66684       loadCountryCode();
66685       return localized;
66686     };
66687     function loadCountryCode() {
66688       var extent = combinedEntityExtent();
66689       var countryCode = extent && iso1A2Code(extent.center());
66690       _countryCode = countryCode && countryCode.toLowerCase();
66691     }
66692     function combinedEntityExtent() {
66693       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66694     }
66695     return utilRebind(localized, dispatch14, "on");
66696   }
66697
66698   // modules/ui/fields/roadheight.js
66699   function uiFieldRoadheight(field, context) {
66700     var dispatch14 = dispatch_default("change");
66701     var primaryUnitInput = select_default2(null);
66702     var primaryInput = select_default2(null);
66703     var secondaryInput = select_default2(null);
66704     var secondaryUnitInput = select_default2(null);
66705     var _entityIDs = [];
66706     var _tags;
66707     var _isImperial;
66708     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
66709     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
66710     var primaryUnits = [
66711       {
66712         value: "m",
66713         title: _t("inspector.roadheight.meter")
66714       },
66715       {
66716         value: "ft",
66717         title: _t("inspector.roadheight.foot")
66718       }
66719     ];
66720     var unitCombo = uiCombobox(context, "roadheight-unit").data(primaryUnits);
66721     function roadheight(selection2) {
66722       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66723       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66724       primaryInput = wrap2.selectAll("input.roadheight-number").data([0]);
66725       primaryInput = primaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-number").attr("id", field.domId).call(utilNoAuto).merge(primaryInput);
66726       primaryInput.on("change", change).on("blur", change);
66727       var loc = combinedEntityExtent().center();
66728       _isImperial = roadHeightUnit(loc) === "ft";
66729       primaryUnitInput = wrap2.selectAll("input.roadheight-unit").data([0]);
66730       primaryUnitInput = primaryUnitInput.enter().append("input").attr("type", "text").attr("class", "roadheight-unit").call(unitCombo).merge(primaryUnitInput);
66731       primaryUnitInput.on("blur", changeUnits).on("change", changeUnits);
66732       secondaryInput = wrap2.selectAll("input.roadheight-secondary-number").data([0]);
66733       secondaryInput = secondaryInput.enter().append("input").attr("type", "text").attr("class", "roadheight-secondary-number").call(utilNoAuto).merge(secondaryInput);
66734       secondaryInput.on("change", change).on("blur", change);
66735       secondaryUnitInput = wrap2.selectAll("input.roadheight-secondary-unit").data([0]);
66736       secondaryUnitInput = secondaryUnitInput.enter().append("input").attr("type", "text").call(utilNoAuto).classed("disabled", true).classed("roadheight-secondary-unit", true).attr("readonly", "readonly").merge(secondaryUnitInput);
66737       function changeUnits() {
66738         var primaryUnit = utilGetSetValue(primaryUnitInput);
66739         if (primaryUnit === "m") {
66740           _isImperial = false;
66741         } else if (primaryUnit === "ft") {
66742           _isImperial = true;
66743         }
66744         utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
66745         setUnitSuggestions();
66746         change();
66747       }
66748     }
66749     function setUnitSuggestions() {
66750       utilGetSetValue(primaryUnitInput, _isImperial ? "ft" : "m");
66751     }
66752     function change() {
66753       var tag2 = {};
66754       var primaryValue = utilGetSetValue(primaryInput).trim();
66755       var secondaryValue = utilGetSetValue(secondaryInput).trim();
66756       if (!primaryValue && !secondaryValue && Array.isArray(_tags[field.key]))
66757         return;
66758       if (!primaryValue && !secondaryValue) {
66759         tag2[field.key] = void 0;
66760       } else {
66761         var rawPrimaryValue = likelyRawNumberFormat.test(primaryValue) ? parseFloat(primaryValue) : parseLocaleFloat(primaryValue);
66762         if (isNaN(rawPrimaryValue))
66763           rawPrimaryValue = primaryValue;
66764         var rawSecondaryValue = likelyRawNumberFormat.test(secondaryValue) ? parseFloat(secondaryValue) : parseLocaleFloat(secondaryValue);
66765         if (isNaN(rawSecondaryValue))
66766           rawSecondaryValue = secondaryValue;
66767         if (isNaN(rawPrimaryValue) || isNaN(rawSecondaryValue) || !_isImperial) {
66768           tag2[field.key] = context.cleanTagValue(rawPrimaryValue);
66769         } else {
66770           if (rawPrimaryValue !== "") {
66771             rawPrimaryValue = rawPrimaryValue + "'";
66772           }
66773           if (rawSecondaryValue !== "") {
66774             rawSecondaryValue = rawSecondaryValue + '"';
66775           }
66776           tag2[field.key] = context.cleanTagValue(rawPrimaryValue + rawSecondaryValue);
66777         }
66778       }
66779       dispatch14.call("change", this, tag2);
66780     }
66781     roadheight.tags = function(tags) {
66782       _tags = tags;
66783       var primaryValue = tags[field.key];
66784       var secondaryValue;
66785       var isMixed = Array.isArray(primaryValue);
66786       if (!isMixed) {
66787         if (primaryValue && (primaryValue.indexOf("'") >= 0 || primaryValue.indexOf('"') >= 0)) {
66788           secondaryValue = primaryValue.match(/(-?[\d.]+)"/);
66789           if (secondaryValue !== null) {
66790             secondaryValue = formatFloat(parseFloat(secondaryValue[1]));
66791           }
66792           primaryValue = primaryValue.match(/(-?[\d.]+)'/);
66793           if (primaryValue !== null) {
66794             primaryValue = formatFloat(parseFloat(primaryValue[1]));
66795           }
66796           _isImperial = true;
66797         } else if (primaryValue) {
66798           var rawValue = primaryValue;
66799           primaryValue = parseFloat(rawValue);
66800           if (isNaN(primaryValue)) {
66801             primaryValue = rawValue;
66802           } else {
66803             primaryValue = formatFloat(primaryValue);
66804           }
66805           _isImperial = false;
66806         }
66807       }
66808       setUnitSuggestions();
66809       var inchesPlaceholder = formatFloat(0);
66810       utilGetSetValue(primaryInput, typeof primaryValue === "string" ? primaryValue : "").attr("title", isMixed ? primaryValue.filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : _t("inspector.unknown")).classed("mixed", isMixed);
66811       utilGetSetValue(secondaryInput, typeof secondaryValue === "string" ? secondaryValue : "").attr("placeholder", isMixed ? _t("inspector.multiple_values") : _isImperial ? inchesPlaceholder : null).classed("mixed", isMixed).classed("disabled", !_isImperial).attr("readonly", _isImperial ? null : "readonly");
66812       secondaryUnitInput.attr("value", _isImperial ? _t("inspector.roadheight.inch") : null);
66813     };
66814     roadheight.focus = function() {
66815       primaryInput.node().focus();
66816     };
66817     roadheight.entityIDs = function(val) {
66818       _entityIDs = val;
66819     };
66820     function combinedEntityExtent() {
66821       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66822     }
66823     return utilRebind(roadheight, dispatch14, "on");
66824   }
66825
66826   // modules/ui/fields/roadspeed.js
66827   function uiFieldRoadspeed(field, context) {
66828     var dispatch14 = dispatch_default("change");
66829     var unitInput = select_default2(null);
66830     var input = select_default2(null);
66831     var _entityIDs = [];
66832     var _tags;
66833     var _isImperial;
66834     var formatFloat = _mainLocalizer.floatFormatter(_mainLocalizer.languageCode());
66835     var parseLocaleFloat = _mainLocalizer.floatParser(_mainLocalizer.languageCode());
66836     var speedCombo = uiCombobox(context, "roadspeed");
66837     var unitCombo = uiCombobox(context, "roadspeed-unit").data(["km/h", "mph"].map(comboValues));
66838     var metricValues = [20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120];
66839     var imperialValues = [5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55, 60, 65, 70, 75, 80];
66840     function roadspeed(selection2) {
66841       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66842       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
66843       input = wrap2.selectAll("input.roadspeed-number").data([0]);
66844       input = input.enter().append("input").attr("type", "text").attr("class", "roadspeed-number").attr("id", field.domId).call(utilNoAuto).call(speedCombo).merge(input);
66845       input.on("change", change).on("blur", change);
66846       var loc = combinedEntityExtent().center();
66847       _isImperial = roadSpeedUnit(loc) === "mph";
66848       unitInput = wrap2.selectAll("input.roadspeed-unit").data([0]);
66849       unitInput = unitInput.enter().append("input").attr("type", "text").attr("class", "roadspeed-unit").attr("aria-label", _t("inspector.speed_unit")).call(unitCombo).merge(unitInput);
66850       unitInput.on("blur", changeUnits).on("change", changeUnits);
66851       function changeUnits() {
66852         var unit2 = utilGetSetValue(unitInput);
66853         if (unit2 === "km/h") {
66854           _isImperial = false;
66855         } else if (unit2 === "mph") {
66856           _isImperial = true;
66857         }
66858         utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
66859         setUnitSuggestions();
66860         change();
66861       }
66862     }
66863     function setUnitSuggestions() {
66864       speedCombo.data((_isImperial ? imperialValues : metricValues).map(comboValues));
66865       utilGetSetValue(unitInput, _isImperial ? "mph" : "km/h");
66866     }
66867     function comboValues(d2) {
66868       return {
66869         value: formatFloat(d2),
66870         title: formatFloat(d2)
66871       };
66872     }
66873     function change() {
66874       var tag2 = {};
66875       var value = utilGetSetValue(input).trim();
66876       if (!value && Array.isArray(_tags[field.key]))
66877         return;
66878       if (!value) {
66879         tag2[field.key] = void 0;
66880       } else {
66881         var rawValue = likelyRawNumberFormat.test(value) ? parseFloat(value) : parseLocaleFloat(value);
66882         if (isNaN(rawValue))
66883           rawValue = value;
66884         if (isNaN(rawValue) || !_isImperial) {
66885           tag2[field.key] = context.cleanTagValue(rawValue);
66886         } else {
66887           tag2[field.key] = context.cleanTagValue(rawValue + " mph");
66888         }
66889       }
66890       dispatch14.call("change", this, tag2);
66891     }
66892     roadspeed.tags = function(tags) {
66893       _tags = tags;
66894       var rawValue = tags[field.key];
66895       var value = rawValue;
66896       var isMixed = Array.isArray(value);
66897       if (!isMixed) {
66898         if (rawValue && rawValue.indexOf("mph") >= 0) {
66899           _isImperial = true;
66900         } else if (rawValue) {
66901           _isImperial = false;
66902         }
66903         value = parseInt(value, 10);
66904         if (isNaN(value)) {
66905           value = rawValue;
66906         } else {
66907           value = formatFloat(value);
66908         }
66909       }
66910       setUnitSuggestions();
66911       utilGetSetValue(input, typeof value === "string" ? value : "").attr("title", isMixed ? value.filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder()).classed("mixed", isMixed);
66912     };
66913     roadspeed.focus = function() {
66914       input.node().focus();
66915     };
66916     roadspeed.entityIDs = function(val) {
66917       _entityIDs = val;
66918     };
66919     function combinedEntityExtent() {
66920       return _entityIDs && _entityIDs.length && utilTotalExtent(_entityIDs, context.graph());
66921     }
66922     return utilRebind(roadspeed, dispatch14, "on");
66923   }
66924
66925   // modules/ui/fields/radio.js
66926   function uiFieldRadio(field, context) {
66927     var dispatch14 = dispatch_default("change");
66928     var placeholder = select_default2(null);
66929     var wrap2 = select_default2(null);
66930     var labels = select_default2(null);
66931     var radios = select_default2(null);
66932     var radioData = (field.options || field.keys).slice();
66933     var typeField;
66934     var layerField;
66935     var _oldType = {};
66936     var _entityIDs = [];
66937     function selectedKey() {
66938       var node = wrap2.selectAll(".form-field-input-radio label.active input");
66939       return !node.empty() && node.datum();
66940     }
66941     function radio(selection2) {
66942       selection2.classed("preset-radio", true);
66943       wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
66944       var enter = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-radio");
66945       enter.append("span").attr("class", "placeholder");
66946       wrap2 = wrap2.merge(enter);
66947       placeholder = wrap2.selectAll(".placeholder");
66948       labels = wrap2.selectAll("label").data(radioData);
66949       enter = labels.enter().append("label");
66950       var stringsField = field.resolveReference("stringsCrossReference");
66951       enter.append("input").attr("type", "radio").attr("name", field.id).attr("value", function(d2) {
66952         return stringsField.t("options." + d2, { "default": d2 });
66953       }).attr("checked", false);
66954       enter.append("span").each(function(d2) {
66955         stringsField.t.append("options." + d2, { "default": d2 })(select_default2(this));
66956       });
66957       labels = labels.merge(enter);
66958       radios = labels.selectAll("input").on("change", changeRadio);
66959     }
66960     function structureExtras(selection2, tags) {
66961       var selected = selectedKey() || tags.layer !== void 0;
66962       var type2 = _mainPresetIndex.field(selected);
66963       var layer = _mainPresetIndex.field("layer");
66964       var showLayer = selected === "bridge" || selected === "tunnel" || tags.layer !== void 0;
66965       var extrasWrap = selection2.selectAll(".structure-extras-wrap").data(selected ? [0] : []);
66966       extrasWrap.exit().remove();
66967       extrasWrap = extrasWrap.enter().append("div").attr("class", "structure-extras-wrap").merge(extrasWrap);
66968       var list2 = extrasWrap.selectAll("ul").data([0]);
66969       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
66970       if (type2) {
66971         if (!typeField || typeField.id !== selected) {
66972           typeField = uiField(context, type2, _entityIDs, { wrap: false }).on("change", changeType);
66973         }
66974         typeField.tags(tags);
66975       } else {
66976         typeField = null;
66977       }
66978       var typeItem = list2.selectAll(".structure-type-item").data(typeField ? [typeField] : [], function(d2) {
66979         return d2.id;
66980       });
66981       typeItem.exit().remove();
66982       var typeEnter = typeItem.enter().insert("li", ":first-child").attr("class", "labeled-input structure-type-item");
66983       typeEnter.append("div").attr("class", "label structure-label-type").attr("for", "preset-input-" + selected).call(_t.append("inspector.radio.structure.type"));
66984       typeEnter.append("div").attr("class", "structure-input-type-wrap");
66985       typeItem = typeItem.merge(typeEnter);
66986       if (typeField) {
66987         typeItem.selectAll(".structure-input-type-wrap").call(typeField.render);
66988       }
66989       if (layer && showLayer) {
66990         if (!layerField) {
66991           layerField = uiField(context, layer, _entityIDs, { wrap: false }).on("change", changeLayer);
66992         }
66993         layerField.tags(tags);
66994         field.keys = utilArrayUnion(field.keys, ["layer"]);
66995       } else {
66996         layerField = null;
66997         field.keys = field.keys.filter(function(k2) {
66998           return k2 !== "layer";
66999         });
67000       }
67001       var layerItem = list2.selectAll(".structure-layer-item").data(layerField ? [layerField] : []);
67002       layerItem.exit().remove();
67003       var layerEnter = layerItem.enter().append("li").attr("class", "labeled-input structure-layer-item");
67004       layerEnter.append("div").attr("class", "label structure-label-layer").attr("for", "preset-input-layer").call(_t.append("inspector.radio.structure.layer"));
67005       layerEnter.append("div").attr("class", "structure-input-layer-wrap");
67006       layerItem = layerItem.merge(layerEnter);
67007       if (layerField) {
67008         layerItem.selectAll(".structure-input-layer-wrap").call(layerField.render);
67009       }
67010     }
67011     function changeType(t2, onInput) {
67012       var key = selectedKey();
67013       if (!key)
67014         return;
67015       var val = t2[key];
67016       if (val !== "no") {
67017         _oldType[key] = val;
67018       }
67019       if (field.type === "structureRadio") {
67020         if (val === "no" || key !== "bridge" && key !== "tunnel" || key === "tunnel" && val === "building_passage") {
67021           t2.layer = void 0;
67022         }
67023         if (t2.layer === void 0) {
67024           if (key === "bridge" && val !== "no") {
67025             t2.layer = "1";
67026           }
67027           if (key === "tunnel" && val !== "no" && val !== "building_passage") {
67028             t2.layer = "-1";
67029           }
67030         }
67031       }
67032       dispatch14.call("change", this, t2, onInput);
67033     }
67034     function changeLayer(t2, onInput) {
67035       if (t2.layer === "0") {
67036         t2.layer = void 0;
67037       }
67038       dispatch14.call("change", this, t2, onInput);
67039     }
67040     function changeRadio() {
67041       var t2 = {};
67042       var activeKey;
67043       if (field.key) {
67044         t2[field.key] = void 0;
67045       }
67046       radios.each(function(d2) {
67047         var active = select_default2(this).property("checked");
67048         if (active)
67049           activeKey = d2;
67050         if (field.key) {
67051           if (active)
67052             t2[field.key] = d2;
67053         } else {
67054           var val = _oldType[activeKey] || "yes";
67055           t2[d2] = active ? val : void 0;
67056         }
67057       });
67058       if (field.type === "structureRadio") {
67059         if (activeKey === "bridge") {
67060           t2.layer = "1";
67061         } else if (activeKey === "tunnel" && t2.tunnel !== "building_passage") {
67062           t2.layer = "-1";
67063         } else {
67064           t2.layer = void 0;
67065         }
67066       }
67067       dispatch14.call("change", this, t2);
67068     }
67069     radio.tags = function(tags) {
67070       function isOptionChecked(d2) {
67071         if (field.key) {
67072           return tags[field.key] === d2;
67073         }
67074         return !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
67075       }
67076       function isMixed(d2) {
67077         if (field.key) {
67078           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2);
67079         }
67080         return Array.isArray(tags[d2]);
67081       }
67082       radios.property("checked", function(d2) {
67083         return isOptionChecked(d2) && (field.key || field.options.filter(isOptionChecked).length === 1);
67084       });
67085       labels.classed("active", function(d2) {
67086         if (field.key) {
67087           return Array.isArray(tags[field.key]) && tags[field.key].includes(d2) || tags[field.key] === d2;
67088         }
67089         return Array.isArray(tags[d2]) && tags[d2].some((v2) => typeof v2 === "string" && v2.toLowerCase() !== "no") || !!(typeof tags[d2] === "string" && tags[d2].toLowerCase() !== "no");
67090       }).classed("mixed", isMixed).attr("title", function(d2) {
67091         return isMixed(d2) ? _t("inspector.unshared_value_tooltip") : null;
67092       });
67093       var selection2 = radios.filter(function() {
67094         return this.checked;
67095       });
67096       if (selection2.empty()) {
67097         placeholder.text("");
67098         placeholder.call(_t.append("inspector.none"));
67099       } else {
67100         placeholder.text(selection2.attr("value"));
67101         _oldType[selection2.datum()] = tags[selection2.datum()];
67102       }
67103       if (field.type === "structureRadio") {
67104         if (!!tags.waterway && !_oldType.tunnel) {
67105           _oldType.tunnel = "culvert";
67106         }
67107         wrap2.call(structureExtras, tags);
67108       }
67109     };
67110     radio.focus = function() {
67111       radios.node().focus();
67112     };
67113     radio.entityIDs = function(val) {
67114       if (!arguments.length)
67115         return _entityIDs;
67116       _entityIDs = val;
67117       _oldType = {};
67118       return radio;
67119     };
67120     radio.isAllowed = function() {
67121       return _entityIDs.length === 1;
67122     };
67123     return utilRebind(radio, dispatch14, "on");
67124   }
67125
67126   // modules/ui/fields/restrictions.js
67127   function uiFieldRestrictions(field, context) {
67128     var dispatch14 = dispatch_default("change");
67129     var breathe = behaviorBreathe(context);
67130     corePreferences("turn-restriction-via-way", null);
67131     var storedViaWay = corePreferences("turn-restriction-via-way0");
67132     var storedDistance = corePreferences("turn-restriction-distance");
67133     var _maxViaWay = storedViaWay !== null ? +storedViaWay : 0;
67134     var _maxDistance = storedDistance ? +storedDistance : 30;
67135     var _initialized3 = false;
67136     var _parent = select_default2(null);
67137     var _container = select_default2(null);
67138     var _oldTurns;
67139     var _graph;
67140     var _vertexID;
67141     var _intersection;
67142     var _fromWayID;
67143     var _lastXPos;
67144     function restrictions(selection2) {
67145       _parent = selection2;
67146       if (_vertexID && (context.graph() !== _graph || !_intersection)) {
67147         _graph = context.graph();
67148         _intersection = osmIntersection(_graph, _vertexID, _maxDistance);
67149       }
67150       var isOK = _intersection && _intersection.vertices.length && // has vertices
67151       _intersection.vertices.filter(function(vertex) {
67152         return vertex.id === _vertexID;
67153       }).length && _intersection.ways.length > 2;
67154       select_default2(selection2.node().parentNode).classed("hide", !isOK);
67155       if (!isOK || !context.container().select(".inspector-wrap.inspector-hidden").empty() || !selection2.node().parentNode || !selection2.node().parentNode.parentNode) {
67156         selection2.call(restrictions.off);
67157         return;
67158       }
67159       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67160       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
67161       var container = wrap2.selectAll(".restriction-container").data([0]);
67162       var containerEnter = container.enter().append("div").attr("class", "restriction-container");
67163       containerEnter.append("div").attr("class", "restriction-help");
67164       _container = containerEnter.merge(container).call(renderViewer);
67165       var controls = wrap2.selectAll(".restriction-controls").data([0]);
67166       controls.enter().append("div").attr("class", "restriction-controls-container").append("div").attr("class", "restriction-controls").merge(controls).call(renderControls);
67167     }
67168     function renderControls(selection2) {
67169       var distControl = selection2.selectAll(".restriction-distance").data([0]);
67170       distControl.exit().remove();
67171       var distControlEnter = distControl.enter().append("div").attr("class", "restriction-control restriction-distance");
67172       distControlEnter.append("span").attr("class", "restriction-control-label restriction-distance-label").call(_t.append("restriction.controls.distance", { suffix: ":" }));
67173       distControlEnter.append("input").attr("class", "restriction-distance-input").attr("type", "range").attr("min", "20").attr("max", "50").attr("step", "5");
67174       distControlEnter.append("span").attr("class", "restriction-distance-text");
67175       selection2.selectAll(".restriction-distance-input").property("value", _maxDistance).on("input", function() {
67176         var val = select_default2(this).property("value");
67177         _maxDistance = +val;
67178         _intersection = null;
67179         _container.selectAll(".layer-osm .layer-turns *").remove();
67180         corePreferences("turn-restriction-distance", _maxDistance);
67181         _parent.call(restrictions);
67182       });
67183       selection2.selectAll(".restriction-distance-text").call(displayMaxDistance(_maxDistance));
67184       var viaControl = selection2.selectAll(".restriction-via-way").data([0]);
67185       viaControl.exit().remove();
67186       var viaControlEnter = viaControl.enter().append("div").attr("class", "restriction-control restriction-via-way");
67187       viaControlEnter.append("span").attr("class", "restriction-control-label restriction-via-way-label").call(_t.append("restriction.controls.via", { suffix: ":" }));
67188       viaControlEnter.append("input").attr("class", "restriction-via-way-input").attr("type", "range").attr("min", "0").attr("max", "2").attr("step", "1");
67189       viaControlEnter.append("span").attr("class", "restriction-via-way-text");
67190       selection2.selectAll(".restriction-via-way-input").property("value", _maxViaWay).on("input", function() {
67191         var val = select_default2(this).property("value");
67192         _maxViaWay = +val;
67193         _container.selectAll(".layer-osm .layer-turns *").remove();
67194         corePreferences("turn-restriction-via-way0", _maxViaWay);
67195         _parent.call(restrictions);
67196       });
67197       selection2.selectAll(".restriction-via-way-text").call(displayMaxVia(_maxViaWay));
67198     }
67199     function renderViewer(selection2) {
67200       if (!_intersection)
67201         return;
67202       var vgraph = _intersection.graph;
67203       var filter2 = utilFunctor(true);
67204       var projection2 = geoRawMercator();
67205       var sdims = utilGetDimensions(context.container().select(".sidebar"));
67206       var d2 = [sdims[0] - 50, 370];
67207       var c2 = geoVecScale(d2, 0.5);
67208       var z2 = 22;
67209       projection2.scale(geoZoomToScale(z2));
67210       var extent = geoExtent();
67211       for (var i3 = 0; i3 < _intersection.vertices.length; i3++) {
67212         extent._extend(_intersection.vertices[i3].extent());
67213       }
67214       var padTop = 35;
67215       if (_intersection.vertices.length > 1) {
67216         var hPadding = Math.min(160, Math.max(110, d2[0] * 0.4));
67217         var vPadding = 160;
67218         var tl = projection2([extent[0][0], extent[1][1]]);
67219         var br2 = projection2([extent[1][0], extent[0][1]]);
67220         var hFactor = (br2[0] - tl[0]) / (d2[0] - hPadding);
67221         var vFactor = (br2[1] - tl[1]) / (d2[1] - vPadding - padTop);
67222         var hZoomDiff = Math.log(Math.abs(hFactor)) / Math.LN2;
67223         var vZoomDiff = Math.log(Math.abs(vFactor)) / Math.LN2;
67224         z2 = z2 - Math.max(hZoomDiff, vZoomDiff);
67225         projection2.scale(geoZoomToScale(z2));
67226       }
67227       var extentCenter = projection2(extent.center());
67228       extentCenter[1] = extentCenter[1] - padTop / 2;
67229       projection2.translate(geoVecSubtract(c2, extentCenter)).clipExtent([[0, 0], d2]);
67230       var drawLayers = svgLayers(projection2, context).only(["osm", "touch"]).dimensions(d2);
67231       var drawVertices = svgVertices(projection2, context);
67232       var drawLines = svgLines(projection2, context);
67233       var drawTurns = svgTurns(projection2, context);
67234       var firstTime = selection2.selectAll(".surface").empty();
67235       selection2.call(drawLayers);
67236       var surface = selection2.selectAll(".surface").classed("tr", true);
67237       if (firstTime) {
67238         _initialized3 = true;
67239         surface.call(breathe);
67240       }
67241       if (_fromWayID && !vgraph.hasEntity(_fromWayID)) {
67242         _fromWayID = null;
67243         _oldTurns = null;
67244       }
67245       surface.call(utilSetDimensions, d2).call(drawVertices, vgraph, _intersection.vertices, filter2, extent, z2).call(drawLines, vgraph, _intersection.ways, filter2).call(drawTurns, vgraph, _intersection.turns(_fromWayID, _maxViaWay));
67246       surface.on("click.restrictions", click).on("mouseover.restrictions", mouseover);
67247       surface.selectAll(".selected").classed("selected", false);
67248       surface.selectAll(".related").classed("related", false);
67249       var way;
67250       if (_fromWayID) {
67251         way = vgraph.entity(_fromWayID);
67252         surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
67253       }
67254       document.addEventListener("resizeWindow", function() {
67255         utilSetDimensions(_container, null);
67256         redraw(1);
67257       }, false);
67258       updateHints(null);
67259       function click(d3_event) {
67260         surface.call(breathe.off).call(breathe);
67261         var datum2 = d3_event.target.__data__;
67262         var entity = datum2 && datum2.properties && datum2.properties.entity;
67263         if (entity) {
67264           datum2 = entity;
67265         }
67266         if (datum2 instanceof osmWay && (datum2.__from || datum2.__via)) {
67267           _fromWayID = datum2.id;
67268           _oldTurns = null;
67269           redraw();
67270         } else if (datum2 instanceof osmTurn) {
67271           var actions, extraActions, turns, i4;
67272           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
67273           if (datum2.restrictionID && !datum2.direct) {
67274             return;
67275           } else if (datum2.restrictionID && !datum2.only) {
67276             var seen = {};
67277             var datumOnly = JSON.parse(JSON.stringify(datum2));
67278             datumOnly.only = true;
67279             restrictionType = restrictionType.replace(/^no/, "only");
67280             turns = _intersection.turns(_fromWayID, 2);
67281             extraActions = [];
67282             _oldTurns = [];
67283             for (i4 = 0; i4 < turns.length; i4++) {
67284               var turn = turns[i4];
67285               if (seen[turn.restrictionID])
67286                 continue;
67287               if (turn.direct && turn.path[1] === datum2.path[1]) {
67288                 seen[turns[i4].restrictionID] = true;
67289                 turn.restrictionType = osmInferRestriction(vgraph, turn, projection2);
67290                 _oldTurns.push(turn);
67291                 extraActions.push(actionUnrestrictTurn(turn));
67292               }
67293             }
67294             actions = _intersection.actions.concat(extraActions, [
67295               actionRestrictTurn(datumOnly, restrictionType),
67296               _t("operations.restriction.annotation.create")
67297             ]);
67298           } else if (datum2.restrictionID) {
67299             turns = _oldTurns || [];
67300             extraActions = [];
67301             for (i4 = 0; i4 < turns.length; i4++) {
67302               if (turns[i4].key !== datum2.key) {
67303                 extraActions.push(actionRestrictTurn(turns[i4], turns[i4].restrictionType));
67304               }
67305             }
67306             _oldTurns = null;
67307             actions = _intersection.actions.concat(extraActions, [
67308               actionUnrestrictTurn(datum2),
67309               _t("operations.restriction.annotation.delete")
67310             ]);
67311           } else {
67312             actions = _intersection.actions.concat([
67313               actionRestrictTurn(datum2, restrictionType),
67314               _t("operations.restriction.annotation.create")
67315             ]);
67316           }
67317           context.perform.apply(context, actions);
67318           var s2 = surface.selectAll("." + datum2.key);
67319           datum2 = s2.empty() ? null : s2.datum();
67320           updateHints(datum2);
67321         } else {
67322           _fromWayID = null;
67323           _oldTurns = null;
67324           redraw();
67325         }
67326       }
67327       function mouseover(d3_event) {
67328         var datum2 = d3_event.target.__data__;
67329         updateHints(datum2);
67330       }
67331       _lastXPos = _lastXPos || sdims[0];
67332       function redraw(minChange) {
67333         var xPos = -1;
67334         if (minChange) {
67335           xPos = utilGetDimensions(context.container().select(".sidebar"))[0];
67336         }
67337         if (!minChange || minChange && Math.abs(xPos - _lastXPos) >= minChange) {
67338           if (context.hasEntity(_vertexID)) {
67339             _lastXPos = xPos;
67340             _container.call(renderViewer);
67341           }
67342         }
67343       }
67344       function highlightPathsFrom(wayID) {
67345         surface.selectAll(".related").classed("related", false).classed("allow", false).classed("restrict", false).classed("only", false);
67346         surface.selectAll("." + wayID).classed("related", true);
67347         if (wayID) {
67348           var turns = _intersection.turns(wayID, _maxViaWay);
67349           for (var i4 = 0; i4 < turns.length; i4++) {
67350             var turn = turns[i4];
67351             var ids = [turn.to.way];
67352             var klass = turn.no ? "restrict" : turn.only ? "only" : "allow";
67353             if (turn.only || turns.length === 1) {
67354               if (turn.via.ways) {
67355                 ids = ids.concat(turn.via.ways);
67356               }
67357             } else if (turn.to.way === wayID) {
67358               continue;
67359             }
67360             surface.selectAll(utilEntitySelector(ids)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
67361           }
67362         }
67363       }
67364       function updateHints(datum2) {
67365         var help = _container.selectAll(".restriction-help").html("");
67366         var placeholders = {};
67367         ["from", "via", "to"].forEach(function(k2) {
67368           placeholders[k2] = { html: '<span class="qualifier">' + _t("restriction.help." + k2) + "</span>" };
67369         });
67370         var entity = datum2 && datum2.properties && datum2.properties.entity;
67371         if (entity) {
67372           datum2 = entity;
67373         }
67374         if (_fromWayID) {
67375           way = vgraph.entity(_fromWayID);
67376           surface.selectAll("." + _fromWayID).classed("selected", true).classed("related", true);
67377         }
67378         if (datum2 instanceof osmWay && datum2.__from) {
67379           way = datum2;
67380           highlightPathsFrom(_fromWayID ? null : way.id);
67381           surface.selectAll("." + way.id).classed("related", true);
67382           var clickSelect = !_fromWayID || _fromWayID !== way.id;
67383           help.append("div").html(_t.html("restriction.help." + (clickSelect ? "select_from_name" : "from_name"), {
67384             from: placeholders.from,
67385             fromName: displayName(way.id, vgraph)
67386           }));
67387         } else if (datum2 instanceof osmTurn) {
67388           var restrictionType = osmInferRestriction(vgraph, datum2, projection2);
67389           var turnType = restrictionType.replace(/^(only|no)\_/, "");
67390           var indirect = datum2.direct === false ? _t.html("restriction.help.indirect") : "";
67391           var klass, turnText, nextText;
67392           if (datum2.no) {
67393             klass = "restrict";
67394             turnText = _t.html("restriction.help.turn.no_" + turnType, { indirect: { html: indirect } });
67395             nextText = _t.html("restriction.help.turn.only_" + turnType, { indirect: "" });
67396           } else if (datum2.only) {
67397             klass = "only";
67398             turnText = _t.html("restriction.help.turn.only_" + turnType, { indirect: { html: indirect } });
67399             nextText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: "" });
67400           } else {
67401             klass = "allow";
67402             turnText = _t.html("restriction.help.turn.allowed_" + turnType, { indirect: { html: indirect } });
67403             nextText = _t.html("restriction.help.turn.no_" + turnType, { indirect: "" });
67404           }
67405           help.append("div").attr("class", "qualifier " + klass).html(turnText);
67406           help.append("div").html(_t.html("restriction.help.from_name_to_name", {
67407             from: placeholders.from,
67408             fromName: displayName(datum2.from.way, vgraph),
67409             to: placeholders.to,
67410             toName: displayName(datum2.to.way, vgraph)
67411           }));
67412           if (datum2.via.ways && datum2.via.ways.length) {
67413             var names = [];
67414             for (var i4 = 0; i4 < datum2.via.ways.length; i4++) {
67415               var prev = names[names.length - 1];
67416               var curr = displayName(datum2.via.ways[i4], vgraph);
67417               if (!prev || curr !== prev) {
67418                 names.push(curr);
67419               }
67420             }
67421             help.append("div").html(_t.html("restriction.help.via_names", {
67422               via: placeholders.via,
67423               viaNames: names.join(", ")
67424             }));
67425           }
67426           if (!indirect) {
67427             help.append("div").html(_t.html("restriction.help.toggle", { turn: { html: nextText.trim() } }));
67428           }
67429           highlightPathsFrom(null);
67430           var alongIDs = datum2.path.slice();
67431           surface.selectAll(utilEntitySelector(alongIDs)).classed("related", true).classed("allow", klass === "allow").classed("restrict", klass === "restrict").classed("only", klass === "only");
67432         } else {
67433           highlightPathsFrom(null);
67434           if (_fromWayID) {
67435             help.append("div").html(_t.html("restriction.help.from_name", {
67436               from: placeholders.from,
67437               fromName: displayName(_fromWayID, vgraph)
67438             }));
67439           } else {
67440             help.append("div").html(_t.html("restriction.help.select_from", {
67441               from: placeholders.from
67442             }));
67443           }
67444         }
67445       }
67446     }
67447     function displayMaxDistance(maxDist) {
67448       return (selection2) => {
67449         var isImperial = !_mainLocalizer.usesMetric();
67450         var opts;
67451         if (isImperial) {
67452           var distToFeet = {
67453             // imprecise conversion for prettier display
67454             20: 70,
67455             25: 85,
67456             30: 100,
67457             35: 115,
67458             40: 130,
67459             45: 145,
67460             50: 160
67461           }[maxDist];
67462           opts = { distance: _t("units.feet", { quantity: distToFeet }) };
67463         } else {
67464           opts = { distance: _t("units.meters", { quantity: maxDist }) };
67465         }
67466         return selection2.html("").call(_t.append("restriction.controls.distance_up_to", opts));
67467       };
67468     }
67469     function displayMaxVia(maxVia) {
67470       return (selection2) => {
67471         selection2 = selection2.html("");
67472         return maxVia === 0 ? selection2.call(_t.append("restriction.controls.via_node_only")) : maxVia === 1 ? selection2.call(_t.append("restriction.controls.via_up_to_one")) : selection2.call(_t.append("restriction.controls.via_up_to_two"));
67473       };
67474     }
67475     function displayName(entityID, graph) {
67476       var entity = graph.entity(entityID);
67477       var name = utilDisplayName(entity) || "";
67478       var matched = _mainPresetIndex.match(entity, graph);
67479       var type2 = matched && matched.name() || utilDisplayType(entity.id);
67480       return name || type2;
67481     }
67482     restrictions.entityIDs = function(val) {
67483       _intersection = null;
67484       _fromWayID = null;
67485       _oldTurns = null;
67486       _vertexID = val[0];
67487     };
67488     restrictions.tags = function() {
67489     };
67490     restrictions.focus = function() {
67491     };
67492     restrictions.off = function(selection2) {
67493       if (!_initialized3)
67494         return;
67495       selection2.selectAll(".surface").call(breathe.off).on("click.restrictions", null).on("mouseover.restrictions", null);
67496       select_default2(window).on("resize.restrictions", null);
67497     };
67498     return utilRebind(restrictions, dispatch14, "on");
67499   }
67500   uiFieldRestrictions.supportsMultiselection = false;
67501
67502   // modules/ui/fields/textarea.js
67503   function uiFieldTextarea(field, context) {
67504     var dispatch14 = dispatch_default("change");
67505     var input = select_default2(null);
67506     var _lengthIndicator = uiLengthIndicator(context.maxCharsForTagValue()).silent(field.usage === "changeset" && field.key === "comment");
67507     var _tags;
67508     function textarea(selection2) {
67509       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67510       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).style("position", "relative").merge(wrap2);
67511       input = wrap2.selectAll("textarea").data([0]);
67512       input = input.enter().append("textarea").attr("id", field.domId).call(utilNoAuto).on("input", change(true)).on("blur", change()).on("change", change()).merge(input);
67513       wrap2.call(_lengthIndicator);
67514       function change(onInput) {
67515         return function() {
67516           var val = utilGetSetValue(input);
67517           if (!onInput)
67518             val = context.cleanTagValue(val);
67519           if (!val && Array.isArray(_tags[field.key]))
67520             return;
67521           var t2 = {};
67522           t2[field.key] = val || void 0;
67523           dispatch14.call("change", this, t2, onInput);
67524         };
67525       }
67526     }
67527     textarea.tags = function(tags) {
67528       _tags = tags;
67529       var isMixed = Array.isArray(tags[field.key]);
67530       utilGetSetValue(input, !isMixed && tags[field.key] ? tags[field.key] : "").attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : void 0).attr("placeholder", isMixed ? _t("inspector.multiple_values") : field.placeholder() || _t("inspector.unknown")).classed("mixed", isMixed);
67531       if (!isMixed) {
67532         _lengthIndicator.update(tags[field.key]);
67533       }
67534     };
67535     textarea.focus = function() {
67536       input.node().focus();
67537     };
67538     return utilRebind(textarea, dispatch14, "on");
67539   }
67540
67541   // modules/ui/fields/wikidata.js
67542   function uiFieldWikidata(field, context) {
67543     var wikidata = services.wikidata;
67544     var dispatch14 = dispatch_default("change");
67545     var _selection = select_default2(null);
67546     var _searchInput = select_default2(null);
67547     var _qid = null;
67548     var _wikidataEntity = null;
67549     var _wikiURL = "";
67550     var _entityIDs = [];
67551     var _wikipediaKey = field.keys && field.keys.find(function(key) {
67552       return key.includes("wikipedia");
67553     });
67554     var _hintKey = field.key === "wikidata" ? "name" : field.key.split(":")[0];
67555     var combobox = uiCombobox(context, "combo-" + field.safeid).caseSensitive(true).minItems(1);
67556     function wiki(selection2) {
67557       _selection = selection2;
67558       var wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67559       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-" + field.type).merge(wrap2);
67560       var list2 = wrap2.selectAll("ul").data([0]);
67561       list2 = list2.enter().append("ul").attr("class", "rows").merge(list2);
67562       var searchRow = list2.selectAll("li.wikidata-search").data([0]);
67563       var searchRowEnter = searchRow.enter().append("li").attr("class", "wikidata-search");
67564       searchRowEnter.append("input").attr("type", "text").attr("id", field.domId).style("flex", "1").call(utilNoAuto).on("focus", function() {
67565         var node = select_default2(this).node();
67566         node.setSelectionRange(0, node.value.length);
67567       }).on("blur", function() {
67568         setLabelForEntity();
67569       }).call(combobox.fetcher(fetchWikidataItems));
67570       combobox.on("accept", function(d2) {
67571         if (d2) {
67572           _qid = d2.id;
67573           change();
67574         }
67575       }).on("cancel", function() {
67576         setLabelForEntity();
67577       });
67578       searchRowEnter.append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain: "wikidata.org" })).call(svgIcon("#iD-icon-out-link")).on("click", function(d3_event) {
67579         d3_event.preventDefault();
67580         if (_wikiURL)
67581           window.open(_wikiURL, "_blank");
67582       });
67583       searchRow = searchRow.merge(searchRowEnter);
67584       _searchInput = searchRow.select("input");
67585       var wikidataProperties = ["description", "identifier"];
67586       var items = list2.selectAll("li.labeled-input").data(wikidataProperties);
67587       var enter = items.enter().append("li").attr("class", function(d2) {
67588         return "labeled-input preset-wikidata-" + d2;
67589       });
67590       enter.append("span").attr("class", "label").html(function(d2) {
67591         return _t.html("wikidata." + d2);
67592       });
67593       enter.append("input").attr("type", "text").call(utilNoAuto).classed("disabled", "true").attr("readonly", "true");
67594       enter.append("button").attr("class", "form-field-button").attr("title", _t("icons.copy")).call(svgIcon("#iD-operation-copy")).on("click", function(d3_event) {
67595         d3_event.preventDefault();
67596         select_default2(this.parentNode).select("input").node().select();
67597         document.execCommand("copy");
67598       });
67599     }
67600     function fetchWikidataItems(q2, callback) {
67601       if (!q2 && _hintKey) {
67602         for (var i3 in _entityIDs) {
67603           var entity = context.hasEntity(_entityIDs[i3]);
67604           if (entity.tags[_hintKey]) {
67605             q2 = entity.tags[_hintKey];
67606             break;
67607           }
67608         }
67609       }
67610       wikidata.itemsForSearchQuery(q2, function(err, data) {
67611         if (err) {
67612           if (err !== "No query")
67613             console.error(err);
67614           return;
67615         }
67616         var result = data.map(function(item) {
67617           return {
67618             id: item.id,
67619             value: item.display.label.value + " (" + item.id + ")",
67620             display: (selection2) => selection2.append("span").attr("class", "localized-text").attr("lang", item.display.label.language).text(item.display.label.value),
67621             title: item.display.description && item.display.description.value,
67622             terms: item.aliases
67623           };
67624         });
67625         if (callback)
67626           callback(result);
67627       });
67628     }
67629     function change() {
67630       var syncTags = {};
67631       syncTags[field.key] = _qid;
67632       dispatch14.call("change", this, syncTags);
67633       var initGraph = context.graph();
67634       var initEntityIDs = _entityIDs;
67635       wikidata.entityByQID(_qid, function(err, entity) {
67636         if (err)
67637           return;
67638         if (context.graph() !== initGraph)
67639           return;
67640         if (!entity.sitelinks)
67641           return;
67642         var langs = wikidata.languagesToQuery();
67643         ["labels", "descriptions"].forEach(function(key) {
67644           if (!entity[key])
67645             return;
67646           var valueLangs = Object.keys(entity[key]);
67647           if (valueLangs.length === 0)
67648             return;
67649           var valueLang = valueLangs[0];
67650           if (langs.indexOf(valueLang) === -1) {
67651             langs.push(valueLang);
67652           }
67653         });
67654         var newWikipediaValue;
67655         if (_wikipediaKey) {
67656           var foundPreferred;
67657           for (var i3 in langs) {
67658             var lang = langs[i3];
67659             var siteID = lang.replace("-", "_") + "wiki";
67660             if (entity.sitelinks[siteID]) {
67661               foundPreferred = true;
67662               newWikipediaValue = lang + ":" + entity.sitelinks[siteID].title;
67663               break;
67664             }
67665           }
67666           if (!foundPreferred) {
67667             var wikiSiteKeys = Object.keys(entity.sitelinks).filter(function(site) {
67668               return site.endsWith("wiki");
67669             });
67670             if (wikiSiteKeys.length === 0) {
67671               newWikipediaValue = null;
67672             } else {
67673               var wikiLang = wikiSiteKeys[0].slice(0, -4).replace("_", "-");
67674               var wikiTitle = entity.sitelinks[wikiSiteKeys[0]].title;
67675               newWikipediaValue = wikiLang + ":" + wikiTitle;
67676             }
67677           }
67678         }
67679         if (newWikipediaValue) {
67680           newWikipediaValue = context.cleanTagValue(newWikipediaValue);
67681         }
67682         if (typeof newWikipediaValue === "undefined")
67683           return;
67684         var actions = initEntityIDs.map(function(entityID) {
67685           var entity2 = context.hasEntity(entityID);
67686           if (!entity2)
67687             return null;
67688           var currTags = Object.assign({}, entity2.tags);
67689           if (newWikipediaValue === null) {
67690             if (!currTags[_wikipediaKey])
67691               return null;
67692             delete currTags[_wikipediaKey];
67693           } else {
67694             currTags[_wikipediaKey] = newWikipediaValue;
67695           }
67696           return actionChangeTags(entityID, currTags);
67697         }).filter(Boolean);
67698         if (!actions.length)
67699           return;
67700         context.overwrite(
67701           function actionUpdateWikipediaTags(graph) {
67702             actions.forEach(function(action) {
67703               graph = action(graph);
67704             });
67705             return graph;
67706           },
67707           context.history().undoAnnotation()
67708         );
67709       });
67710     }
67711     function setLabelForEntity() {
67712       var label = "";
67713       if (_wikidataEntity) {
67714         label = entityPropertyForDisplay(_wikidataEntity, "labels");
67715         if (label.length === 0) {
67716           label = _wikidataEntity.id.toString();
67717         }
67718       }
67719       utilGetSetValue(_searchInput, label);
67720     }
67721     wiki.tags = function(tags) {
67722       var isMixed = Array.isArray(tags[field.key]);
67723       _searchInput.attr("title", isMixed ? tags[field.key].filter(Boolean).join("\n") : null).attr("placeholder", isMixed ? _t("inspector.multiple_values") : "").classed("mixed", isMixed);
67724       _qid = typeof tags[field.key] === "string" && tags[field.key] || "";
67725       if (!/^Q[0-9]*$/.test(_qid)) {
67726         unrecognized();
67727         return;
67728       }
67729       _wikiURL = "https://wikidata.org/wiki/" + _qid;
67730       wikidata.entityByQID(_qid, function(err, entity) {
67731         if (err) {
67732           unrecognized();
67733           return;
67734         }
67735         _wikidataEntity = entity;
67736         setLabelForEntity();
67737         var description = entityPropertyForDisplay(entity, "descriptions");
67738         _selection.select("button.wiki-link").classed("disabled", false);
67739         _selection.select(".preset-wikidata-description").style("display", function() {
67740           return description.length > 0 ? "flex" : "none";
67741         }).select("input").attr("value", description);
67742         _selection.select(".preset-wikidata-identifier").style("display", function() {
67743           return entity.id ? "flex" : "none";
67744         }).select("input").attr("value", entity.id);
67745       });
67746       function unrecognized() {
67747         _wikidataEntity = null;
67748         setLabelForEntity();
67749         _selection.select(".preset-wikidata-description").style("display", "none");
67750         _selection.select(".preset-wikidata-identifier").style("display", "none");
67751         _selection.select("button.wiki-link").classed("disabled", true);
67752         if (_qid && _qid !== "") {
67753           _wikiURL = "https://wikidata.org/wiki/Special:Search?search=" + _qid;
67754         } else {
67755           _wikiURL = "";
67756         }
67757       }
67758     };
67759     function entityPropertyForDisplay(wikidataEntity, propKey) {
67760       if (!wikidataEntity[propKey])
67761         return "";
67762       var propObj = wikidataEntity[propKey];
67763       var langKeys = Object.keys(propObj);
67764       if (langKeys.length === 0)
67765         return "";
67766       var langs = wikidata.languagesToQuery();
67767       for (var i3 in langs) {
67768         var lang = langs[i3];
67769         var valueObj = propObj[lang];
67770         if (valueObj && valueObj.value && valueObj.value.length > 0)
67771           return valueObj.value;
67772       }
67773       return propObj[langKeys[0]].value;
67774     }
67775     wiki.entityIDs = function(val) {
67776       if (!arguments.length)
67777         return _entityIDs;
67778       _entityIDs = val;
67779       return wiki;
67780     };
67781     wiki.focus = function() {
67782       _searchInput.node().focus();
67783     };
67784     return utilRebind(wiki, dispatch14, "on");
67785   }
67786
67787   // modules/ui/fields/wikipedia.js
67788   function uiFieldWikipedia(field, context) {
67789     const dispatch14 = dispatch_default("change");
67790     const wikipedia = services.wikipedia;
67791     const wikidata = services.wikidata;
67792     let _langInput = select_default2(null);
67793     let _titleInput = select_default2(null);
67794     let _wikiURL = "";
67795     let _entityIDs;
67796     let _tags;
67797     let _dataWikipedia = [];
67798     _mainFileFetcher.get("wmf_sitematrix").then((d2) => {
67799       _dataWikipedia = d2;
67800       if (_tags)
67801         updateForTags(_tags);
67802     }).catch(() => {
67803     });
67804     const langCombo = uiCombobox(context, "wikipedia-lang").fetcher((value, callback) => {
67805       const v2 = value.toLowerCase();
67806       callback(
67807         _dataWikipedia.filter((d2) => {
67808           return d2[0].toLowerCase().indexOf(v2) >= 0 || d2[1].toLowerCase().indexOf(v2) >= 0 || d2[2].toLowerCase().indexOf(v2) >= 0;
67809         }).map((d2) => ({ value: d2[1] }))
67810       );
67811     });
67812     const titleCombo = uiCombobox(context, "wikipedia-title").fetcher((value, callback) => {
67813       if (!value) {
67814         value = "";
67815         for (let i3 in _entityIDs) {
67816           let entity = context.hasEntity(_entityIDs[i3]);
67817           if (entity.tags.name) {
67818             value = entity.tags.name;
67819             break;
67820           }
67821         }
67822       }
67823       const searchfn = value.length > 7 ? wikipedia.search : wikipedia.suggestions;
67824       searchfn(language()[2], value, (query, data) => {
67825         callback(data.map((d2) => ({ value: d2 })));
67826       });
67827     });
67828     function wiki(selection2) {
67829       let wrap2 = selection2.selectAll(".form-field-input-wrap").data([0]);
67830       wrap2 = wrap2.enter().append("div").attr("class", "form-field-input-wrap form-field-input-".concat(field.type)).merge(wrap2);
67831       let langContainer = wrap2.selectAll(".wiki-lang-container").data([0]);
67832       langContainer = langContainer.enter().append("div").attr("class", "wiki-lang-container").merge(langContainer);
67833       _langInput = langContainer.selectAll("input.wiki-lang").data([0]);
67834       _langInput = _langInput.enter().append("input").attr("type", "text").attr("class", "wiki-lang").attr("placeholder", _t("translate.localized_translation_language")).call(utilNoAuto).call(langCombo).merge(_langInput);
67835       _langInput.on("blur", changeLang).on("change", changeLang);
67836       let titleContainer = wrap2.selectAll(".wiki-title-container").data([0]);
67837       titleContainer = titleContainer.enter().append("div").attr("class", "wiki-title-container").merge(titleContainer);
67838       _titleInput = titleContainer.selectAll("input.wiki-title").data([0]);
67839       _titleInput = _titleInput.enter().append("input").attr("type", "text").attr("class", "wiki-title").attr("id", field.domId).call(utilNoAuto).call(titleCombo).merge(_titleInput);
67840       _titleInput.on("blur", function() {
67841         change(true);
67842       }).on("change", function() {
67843         change(false);
67844       });
67845       let link3 = titleContainer.selectAll(".wiki-link").data([0]);
67846       link3 = link3.enter().append("button").attr("class", "form-field-button wiki-link").attr("title", _t("icons.view_on", { domain: "wikipedia.org" })).call(svgIcon("#iD-icon-out-link")).merge(link3);
67847       link3.on("click", (d3_event) => {
67848         d3_event.preventDefault();
67849         if (_wikiURL)
67850           window.open(_wikiURL, "_blank");
67851       });
67852     }
67853     function defaultLanguageInfo(skipEnglishFallback) {
67854       const langCode = _mainLocalizer.languageCode().toLowerCase();
67855       for (let i3 in _dataWikipedia) {
67856         let d2 = _dataWikipedia[i3];
67857         if (d2[2] === langCode)
67858           return d2;
67859       }
67860       return skipEnglishFallback ? ["", "", ""] : ["English", "English", "en"];
67861     }
67862     function language(skipEnglishFallback) {
67863       const value = utilGetSetValue(_langInput).toLowerCase();
67864       for (let i3 in _dataWikipedia) {
67865         let d2 = _dataWikipedia[i3];
67866         if (d2[0].toLowerCase() === value || d2[1].toLowerCase() === value || d2[2] === value)
67867           return d2;
67868       }
67869       return defaultLanguageInfo(skipEnglishFallback);
67870     }
67871     function changeLang() {
67872       utilGetSetValue(_langInput, language()[1]);
67873       change(true);
67874     }
67875     function change(skipWikidata) {
67876       let value = utilGetSetValue(_titleInput);
67877       const m2 = value.match(/https?:\/\/([-a-z]+)\.wikipedia\.org\/(?:wiki|\1-[-a-z]+)\/([^#]+)(?:#(.+))?/);
67878       const langInfo = m2 && _dataWikipedia.find((d2) => m2[1] === d2[2]);
67879       let syncTags = {};
67880       if (langInfo) {
67881         const nativeLangName = langInfo[1];
67882         value = decodeURIComponent(m2[2]).replace(/_/g, " ");
67883         if (m2[3]) {
67884           let anchor;
67885           anchor = decodeURIComponent(m2[3]);
67886           value += "#" + anchor.replace(/_/g, " ");
67887         }
67888         value = value.slice(0, 1).toUpperCase() + value.slice(1);
67889         utilGetSetValue(_langInput, nativeLangName);
67890         utilGetSetValue(_titleInput, value);
67891       }
67892       if (value) {
67893         syncTags.wikipedia = context.cleanTagValue(language()[2] + ":" + value);
67894       } else {
67895         syncTags.wikipedia = void 0;
67896       }
67897       dispatch14.call("change", this, syncTags);
67898       if (skipWikidata || !value || !language()[2])
67899         return;
67900       const initGraph = context.graph();
67901       const initEntityIDs = _entityIDs;
67902       wikidata.itemsByTitle(language()[2], value, (err, data) => {
67903         if (err || !data || !Object.keys(data).length)
67904           return;
67905         if (context.graph() !== initGraph)
67906           return;
67907         const qids = Object.keys(data);
67908         const value2 = qids && qids.find((id2) => id2.match(/^Q\d+$/));
67909         let actions = initEntityIDs.map((entityID) => {
67910           let entity = context.entity(entityID).tags;
67911           let currTags = Object.assign({}, entity);
67912           if (currTags.wikidata !== value2) {
67913             currTags.wikidata = value2;
67914             return actionChangeTags(entityID, currTags);
67915           }
67916           return null;
67917         }).filter(Boolean);
67918         if (!actions.length)
67919           return;
67920         context.overwrite(
67921           function actionUpdateWikidataTags(graph) {
67922             actions.forEach(function(action) {
67923               graph = action(graph);
67924             });
67925             return graph;
67926           },
67927           context.history().undoAnnotation()
67928         );
67929       });
67930     }
67931     wiki.tags = (tags) => {
67932       _tags = tags;
67933       updateForTags(tags);
67934     };
67935     function updateForTags(tags) {
67936       const value = typeof tags[field.key] === "string" ? tags[field.key] : "";
67937       const m2 = value.match(/([^:]+):([^#]+)(?:#(.+))?/);
67938       const tagLang = m2 && m2[1];
67939       const tagArticleTitle = m2 && m2[2];
67940       let anchor = m2 && m2[3];
67941       const tagLangInfo = tagLang && _dataWikipedia.find((d2) => tagLang === d2[2]);
67942       if (tagLangInfo) {
67943         const nativeLangName = tagLangInfo[1];
67944         utilGetSetValue(_langInput, nativeLangName);
67945         utilGetSetValue(_titleInput, tagArticleTitle + (anchor ? "#" + anchor : ""));
67946         if (anchor) {
67947           try {
67948             anchor = encodeURIComponent(anchor.replace(/ /g, "_")).replace(/%/g, ".");
67949           } catch (e3) {
67950             anchor = anchor.replace(/ /g, "_");
67951           }
67952         }
67953         _wikiURL = "https://" + tagLang + ".wikipedia.org/wiki/" + tagArticleTitle.replace(/ /g, "_") + (anchor ? "#" + anchor : "");
67954       } else {
67955         utilGetSetValue(_titleInput, value);
67956         if (value && value !== "") {
67957           utilGetSetValue(_langInput, "");
67958           const defaultLangInfo = defaultLanguageInfo();
67959           _wikiURL = "https://".concat(defaultLangInfo[2], ".wikipedia.org/w/index.php?fulltext=1&search=").concat(value);
67960         } else {
67961           const shownOrDefaultLangInfo = language(
67962             true
67963             /* skipEnglishFallback */
67964           );
67965           utilGetSetValue(_langInput, shownOrDefaultLangInfo[1]);
67966           _wikiURL = "";
67967         }
67968       }
67969     }
67970     wiki.entityIDs = (val) => {
67971       if (!arguments.length)
67972         return _entityIDs;
67973       _entityIDs = val;
67974       return wiki;
67975     };
67976     wiki.focus = () => {
67977       _titleInput.node().focus();
67978     };
67979     return utilRebind(wiki, dispatch14, "on");
67980   }
67981   uiFieldWikipedia.supportsMultiselection = false;
67982
67983   // modules/ui/fields/index.js
67984   var uiFields = {
67985     access: uiFieldAccess,
67986     address: uiFieldAddress,
67987     check: uiFieldCheck,
67988     colour: uiFieldText,
67989     combo: uiFieldCombo,
67990     cycleway: uiFieldDirectionalCombo,
67991     date: uiFieldText,
67992     defaultCheck: uiFieldCheck,
67993     directionalCombo: uiFieldDirectionalCombo,
67994     email: uiFieldText,
67995     identifier: uiFieldText,
67996     lanes: uiFieldLanes,
67997     localized: uiFieldLocalized,
67998     roadheight: uiFieldRoadheight,
67999     roadspeed: uiFieldRoadspeed,
68000     manyCombo: uiFieldCombo,
68001     multiCombo: uiFieldCombo,
68002     networkCombo: uiFieldCombo,
68003     number: uiFieldText,
68004     onewayCheck: uiFieldCheck,
68005     radio: uiFieldRadio,
68006     restrictions: uiFieldRestrictions,
68007     semiCombo: uiFieldCombo,
68008     structureRadio: uiFieldRadio,
68009     tel: uiFieldText,
68010     text: uiFieldText,
68011     textarea: uiFieldTextarea,
68012     typeCombo: uiFieldCombo,
68013     url: uiFieldText,
68014     wikidata: uiFieldWikidata,
68015     wikipedia: uiFieldWikipedia
68016   };
68017
68018   // modules/ui/field.js
68019   function uiField(context, presetField2, entityIDs, options2) {
68020     options2 = Object.assign({
68021       show: true,
68022       wrap: true,
68023       remove: true,
68024       revert: true,
68025       info: true
68026     }, options2);
68027     var dispatch14 = dispatch_default("change", "revert");
68028     var field = Object.assign({}, presetField2);
68029     field.domId = utilUniqueDomId("form-field-" + field.safeid);
68030     var _show = options2.show;
68031     var _state = "";
68032     var _tags = {};
68033     var _entityExtent;
68034     if (entityIDs && entityIDs.length) {
68035       _entityExtent = entityIDs.reduce(function(extent, entityID) {
68036         var entity = context.graph().entity(entityID);
68037         return extent.extend(entity.extent(context.graph()));
68038       }, geoExtent());
68039     }
68040     var _locked = false;
68041     var _lockedTip = uiTooltip().title(() => _t.append("inspector.lock.suggestion", { label: field.title })).placement("bottom");
68042     if (_show && !field.impl) {
68043       createField();
68044     }
68045     function createField() {
68046       field.impl = uiFields[field.type](field, context).on("change", function(t2, onInput) {
68047         dispatch14.call("change", field, t2, onInput);
68048       });
68049       if (entityIDs) {
68050         field.entityIDs = entityIDs;
68051         if (field.impl.entityIDs) {
68052           field.impl.entityIDs(entityIDs);
68053         }
68054       }
68055     }
68056     function allKeys() {
68057       let keys2 = field.keys || [field.key];
68058       if (field.type === "directionalCombo" && field.key) {
68059         keys2 = keys2.concat(field.key);
68060       }
68061       return keys2;
68062     }
68063     function isModified() {
68064       if (!entityIDs || !entityIDs.length)
68065         return false;
68066       return entityIDs.some(function(entityID) {
68067         var original = context.graph().base().entities[entityID];
68068         var latest = context.graph().entity(entityID);
68069         return allKeys().some(function(key) {
68070           return original ? latest.tags[key] !== original.tags[key] : latest.tags[key];
68071         });
68072       });
68073     }
68074     function tagsContainFieldKey() {
68075       return allKeys().some(function(key) {
68076         if (field.type === "multiCombo") {
68077           for (var tagKey in _tags) {
68078             if (tagKey.indexOf(key) === 0) {
68079               return true;
68080             }
68081           }
68082           return false;
68083         }
68084         return _tags[key] !== void 0;
68085       });
68086     }
68087     function revert(d3_event, d2) {
68088       d3_event.stopPropagation();
68089       d3_event.preventDefault();
68090       if (!entityIDs || _locked)
68091         return;
68092       dispatch14.call("revert", d2, allKeys());
68093     }
68094     function remove2(d3_event, d2) {
68095       d3_event.stopPropagation();
68096       d3_event.preventDefault();
68097       if (_locked)
68098         return;
68099       var t2 = {};
68100       allKeys().forEach(function(key) {
68101         t2[key] = void 0;
68102       });
68103       dispatch14.call("change", d2, t2);
68104     }
68105     field.render = function(selection2) {
68106       var container = selection2.selectAll(".form-field").data([field]);
68107       var enter = container.enter().append("div").attr("class", function(d2) {
68108         return "form-field form-field-" + d2.safeid;
68109       }).classed("nowrap", !options2.wrap);
68110       if (options2.wrap) {
68111         var labelEnter = enter.append("label").attr("class", "field-label").attr("for", function(d2) {
68112           return d2.domId;
68113         });
68114         var textEnter = labelEnter.append("span").attr("class", "label-text");
68115         textEnter.append("span").attr("class", "label-textvalue").each(function(d2) {
68116           d2.label()(select_default2(this));
68117         });
68118         textEnter.append("span").attr("class", "label-textannotation");
68119         if (options2.remove) {
68120           labelEnter.append("button").attr("class", "remove-icon").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
68121         }
68122         if (options2.revert) {
68123           labelEnter.append("button").attr("class", "modified-icon").attr("title", _t("icons.undo")).call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-redo" : "#iD-icon-undo"));
68124         }
68125       }
68126       container = container.merge(enter);
68127       container.select(".field-label > .remove-icon").on("click", remove2);
68128       container.select(".field-label > .modified-icon").on("click", revert);
68129       container.each(function(d2) {
68130         var selection3 = select_default2(this);
68131         if (!d2.impl) {
68132           createField();
68133         }
68134         var reference, help;
68135         if (options2.wrap && field.type === "restrictions") {
68136           help = uiFieldHelp(context, "restrictions");
68137         }
68138         if (options2.wrap && options2.info) {
68139           var referenceKey = d2.key || "";
68140           if (d2.type === "multiCombo") {
68141             referenceKey = referenceKey.replace(/:$/, "");
68142           }
68143           var referenceOptions = d2.reference || {
68144             key: referenceKey,
68145             value: _tags[referenceKey]
68146           };
68147           reference = uiTagReference(referenceOptions, context);
68148           if (_state === "hover") {
68149             reference.showing(false);
68150           }
68151         }
68152         selection3.call(d2.impl);
68153         if (help) {
68154           selection3.call(help.body).select(".field-label").call(help.button);
68155         }
68156         if (reference) {
68157           selection3.call(reference.body).select(".field-label").call(reference.button);
68158         }
68159         d2.impl.tags(_tags);
68160       });
68161       container.classed("locked", _locked).classed("modified", isModified()).classed("present", tagsContainFieldKey());
68162       var annotation = container.selectAll(".field-label .label-textannotation");
68163       var icon2 = annotation.selectAll(".icon").data(_locked ? [0] : []);
68164       icon2.exit().remove();
68165       icon2.enter().append("svg").attr("class", "icon").append("use").attr("xlink:href", "#fas-lock");
68166       container.call(_locked ? _lockedTip : _lockedTip.destroy);
68167     };
68168     field.state = function(val) {
68169       if (!arguments.length)
68170         return _state;
68171       _state = val;
68172       return field;
68173     };
68174     field.tags = function(val) {
68175       if (!arguments.length)
68176         return _tags;
68177       _tags = val;
68178       if (tagsContainFieldKey() && !_show) {
68179         _show = true;
68180         if (!field.impl) {
68181           createField();
68182         }
68183       }
68184       return field;
68185     };
68186     field.locked = function(val) {
68187       if (!arguments.length)
68188         return _locked;
68189       _locked = val;
68190       return field;
68191     };
68192     field.show = function() {
68193       _show = true;
68194       if (!field.impl) {
68195         createField();
68196       }
68197       if (field.default && field.key && _tags[field.key] !== field.default) {
68198         var t2 = {};
68199         t2[field.key] = field.default;
68200         dispatch14.call("change", this, t2);
68201       }
68202     };
68203     field.isShown = function() {
68204       return _show;
68205     };
68206     field.isAllowed = function() {
68207       if (entityIDs && entityIDs.length > 1 && uiFields[field.type].supportsMultiselection === false)
68208         return false;
68209       if (field.geometry && !entityIDs.every(function(entityID) {
68210         return field.matchGeometry(context.graph().geometry(entityID));
68211       }))
68212         return false;
68213       if (entityIDs && _entityExtent && field.locationSetID) {
68214         var validHere = _sharedLocationManager.locationSetsAt(_entityExtent.center());
68215         if (!validHere[field.locationSetID])
68216           return false;
68217       }
68218       var prerequisiteTag = field.prerequisiteTag;
68219       if (entityIDs && !tagsContainFieldKey() && // ignore tagging prerequisites if a value is already present
68220       prerequisiteTag) {
68221         if (!entityIDs.every(function(entityID) {
68222           var entity = context.graph().entity(entityID);
68223           if (prerequisiteTag.key) {
68224             var value = entity.tags[prerequisiteTag.key];
68225             if (!value)
68226               return false;
68227             if (prerequisiteTag.valueNot) {
68228               return prerequisiteTag.valueNot !== value;
68229             }
68230             if (prerequisiteTag.value) {
68231               return prerequisiteTag.value === value;
68232             }
68233           } else if (prerequisiteTag.keyNot) {
68234             if (entity.tags[prerequisiteTag.keyNot])
68235               return false;
68236           }
68237           return true;
68238         }))
68239           return false;
68240       }
68241       return true;
68242     };
68243     field.focus = function() {
68244       if (field.impl) {
68245         field.impl.focus();
68246       }
68247     };
68248     return utilRebind(field, dispatch14, "on");
68249   }
68250
68251   // modules/ui/form_fields.js
68252   function uiFormFields(context) {
68253     var moreCombo = uiCombobox(context, "more-fields").minItems(1);
68254     var _fieldsArr = [];
68255     var _lastPlaceholder = "";
68256     var _state = "";
68257     var _klass = "";
68258     function formFields(selection2) {
68259       var allowedFields = _fieldsArr.filter(function(field) {
68260         return field.isAllowed();
68261       });
68262       var shown = allowedFields.filter(function(field) {
68263         return field.isShown();
68264       });
68265       var notShown = allowedFields.filter(function(field) {
68266         return !field.isShown();
68267       });
68268       var container = selection2.selectAll(".form-fields-container").data([0]);
68269       container = container.enter().append("div").attr("class", "form-fields-container " + (_klass || "")).merge(container);
68270       var fields = container.selectAll(".wrap-form-field").data(shown, function(d2) {
68271         return d2.id + (d2.entityIDs ? d2.entityIDs.join() : "");
68272       });
68273       fields.exit().remove();
68274       var enter = fields.enter().append("div").attr("class", function(d2) {
68275         return "wrap-form-field wrap-form-field-" + d2.safeid;
68276       });
68277       fields = fields.merge(enter);
68278       fields.order().each(function(d2) {
68279         select_default2(this).call(d2.render);
68280       });
68281       var titles = [];
68282       var moreFields = notShown.map(function(field) {
68283         var title = field.title();
68284         titles.push(title);
68285         var terms = field.terms();
68286         if (field.key)
68287           terms.push(field.key);
68288         if (field.keys)
68289           terms = terms.concat(field.keys);
68290         return {
68291           display: field.label(),
68292           value: title,
68293           title,
68294           field,
68295           terms
68296         };
68297       });
68298       var placeholder = titles.slice(0, 3).join(", ") + (titles.length > 3 ? "\u2026" : "");
68299       var more = selection2.selectAll(".more-fields").data(_state === "hover" || moreFields.length === 0 ? [] : [0]);
68300       more.exit().remove();
68301       var moreEnter = more.enter().append("div").attr("class", "more-fields").append("label");
68302       moreEnter.append("span").call(_t.append("inspector.add_fields"));
68303       more = moreEnter.merge(more);
68304       var input = more.selectAll(".value").data([0]);
68305       input.exit().remove();
68306       input = input.enter().append("input").attr("class", "value").attr("type", "text").attr("placeholder", placeholder).call(utilNoAuto).merge(input);
68307       input.call(utilGetSetValue, "").call(
68308         moreCombo.data(moreFields).on("accept", function(d2) {
68309           if (!d2)
68310             return;
68311           var field = d2.field;
68312           field.show();
68313           selection2.call(formFields);
68314           field.focus();
68315         })
68316       );
68317       if (_lastPlaceholder !== placeholder) {
68318         input.attr("placeholder", placeholder);
68319         _lastPlaceholder = placeholder;
68320       }
68321     }
68322     formFields.fieldsArr = function(val) {
68323       if (!arguments.length)
68324         return _fieldsArr;
68325       _fieldsArr = val || [];
68326       return formFields;
68327     };
68328     formFields.state = function(val) {
68329       if (!arguments.length)
68330         return _state;
68331       _state = val;
68332       return formFields;
68333     };
68334     formFields.klass = function(val) {
68335       if (!arguments.length)
68336         return _klass;
68337       _klass = val;
68338       return formFields;
68339     };
68340     return formFields;
68341   }
68342
68343   // modules/ui/changeset_editor.js
68344   function uiChangesetEditor(context) {
68345     var dispatch14 = dispatch_default("change");
68346     var formFields = uiFormFields(context);
68347     var commentCombo = uiCombobox(context, "comment").caseSensitive(true);
68348     var _fieldsArr;
68349     var _tags;
68350     var _changesetID;
68351     function changesetEditor(selection2) {
68352       render(selection2);
68353     }
68354     function render(selection2) {
68355       var initial = false;
68356       if (!_fieldsArr) {
68357         initial = true;
68358         var presets = _mainPresetIndex;
68359         _fieldsArr = [
68360           uiField(context, presets.field("comment"), null, { show: true, revert: false }),
68361           uiField(context, presets.field("source"), null, { show: true, revert: false }),
68362           uiField(context, presets.field("hashtags"), null, { show: false, revert: false })
68363         ];
68364         _fieldsArr.forEach(function(field) {
68365           field.on("change", function(t2, onInput) {
68366             dispatch14.call("change", field, void 0, t2, onInput);
68367           });
68368         });
68369       }
68370       _fieldsArr.forEach(function(field) {
68371         field.tags(_tags);
68372       });
68373       selection2.call(formFields.fieldsArr(_fieldsArr));
68374       if (initial) {
68375         var commentField = selection2.select(".form-field-comment textarea");
68376         var commentNode = commentField.node();
68377         if (commentNode) {
68378           commentNode.focus();
68379           commentNode.select();
68380         }
68381         utilTriggerEvent(commentField, "blur");
68382         var osm = context.connection();
68383         if (osm) {
68384           osm.userChangesets(function(err, changesets) {
68385             if (err)
68386               return;
68387             var comments = changesets.map(function(changeset) {
68388               var comment = changeset.tags.comment;
68389               return comment ? { title: comment, value: comment } : null;
68390             }).filter(Boolean);
68391             commentField.call(
68392               commentCombo.data(utilArrayUniqBy(comments, "title"))
68393             );
68394           });
68395         }
68396       }
68397       const warnings = [];
68398       if (_tags.comment.match(/google/i)) {
68399         warnings.push({
68400           id: 'contains "google"',
68401           msg: _t.append("commit.google_warning"),
68402           link: _t("commit.google_warning_link")
68403         });
68404       }
68405       const maxChars = context.maxCharsForTagValue();
68406       const strLen = utilUnicodeCharsCount(utilCleanOsmString(_tags.comment, Number.POSITIVE_INFINITY));
68407       if (strLen > maxChars || false) {
68408         warnings.push({
68409           id: "message too long",
68410           msg: _t.append("commit.changeset_comment_length_warning", { maxChars })
68411         });
68412       }
68413       var commentWarning = selection2.select(".form-field-comment").selectAll(".comment-warning").data(warnings, (d2) => d2.id);
68414       commentWarning.exit().transition().duration(200).style("opacity", 0).remove();
68415       var commentEnter = commentWarning.enter().insert("div", ".comment-warning").attr("class", "comment-warning field-warning").style("opacity", 0);
68416       commentEnter.call(svgIcon("#iD-icon-alert", "inline")).append("span");
68417       commentEnter.transition().duration(200).style("opacity", 1);
68418       commentWarning.merge(commentEnter).selectAll("div > span").text("").each(function(d2) {
68419         let selection3 = select_default2(this);
68420         if (d2.link) {
68421           selection3 = selection3.append("a").attr("target", "_blank").attr("href", d2.link);
68422         }
68423         selection3.call(d2.msg);
68424       });
68425     }
68426     changesetEditor.tags = function(_2) {
68427       if (!arguments.length)
68428         return _tags;
68429       _tags = _2;
68430       return changesetEditor;
68431     };
68432     changesetEditor.changesetID = function(_2) {
68433       if (!arguments.length)
68434         return _changesetID;
68435       if (_changesetID === _2)
68436         return changesetEditor;
68437       _changesetID = _2;
68438       _fieldsArr = null;
68439       return changesetEditor;
68440     };
68441     return utilRebind(changesetEditor, dispatch14, "on");
68442   }
68443
68444   // modules/ui/commit.js
68445   var import_fast_deep_equal9 = __toESM(require_fast_deep_equal());
68446
68447   // modules/util/jxon.js
68448   var JXON = new function() {
68449     var sValueProp = "keyValue", sAttributesProp = "keyAttributes", sAttrPref = "@", aCache = [], rIsNull = /^\s*$/, rIsBool = /^(?:true|false)$/i;
68450     function parseText(sValue) {
68451       if (rIsNull.test(sValue)) {
68452         return null;
68453       }
68454       if (rIsBool.test(sValue)) {
68455         return sValue.toLowerCase() === "true";
68456       }
68457       if (isFinite(sValue)) {
68458         return parseFloat(sValue);
68459       }
68460       if (isFinite(Date.parse(sValue))) {
68461         return new Date(sValue);
68462       }
68463       return sValue;
68464     }
68465     function EmptyTree() {
68466     }
68467     EmptyTree.prototype.toString = function() {
68468       return "null";
68469     };
68470     EmptyTree.prototype.valueOf = function() {
68471       return null;
68472     };
68473     function objectify(vValue) {
68474       return vValue === null ? new EmptyTree() : vValue instanceof Object ? vValue : new vValue.constructor(vValue);
68475     }
68476     function createObjTree(oParentNode, nVerb, bFreeze, bNesteAttr) {
68477       var nLevelStart = aCache.length, bChildren = oParentNode.hasChildNodes(), bAttributes = oParentNode.hasAttributes(), bHighVerb = Boolean(nVerb & 2);
68478       var sProp, vContent, nLength = 0, sCollectedTxt = "", vResult = bHighVerb ? {} : (
68479         /* put here the default value for empty nodes: */
68480         true
68481       );
68482       if (bChildren) {
68483         for (var oNode, nItem = 0; nItem < oParentNode.childNodes.length; nItem++) {
68484           oNode = oParentNode.childNodes.item(nItem);
68485           if (oNode.nodeType === 4) {
68486             sCollectedTxt += oNode.nodeValue;
68487           } else if (oNode.nodeType === 3) {
68488             sCollectedTxt += oNode.nodeValue.trim();
68489           } else if (oNode.nodeType === 1 && !oNode.prefix) {
68490             aCache.push(oNode);
68491           }
68492         }
68493       }
68494       var nLevelEnd = aCache.length, vBuiltVal = parseText(sCollectedTxt);
68495       if (!bHighVerb && (bChildren || bAttributes)) {
68496         vResult = nVerb === 0 ? objectify(vBuiltVal) : {};
68497       }
68498       for (var nElId = nLevelStart; nElId < nLevelEnd; nElId++) {
68499         sProp = aCache[nElId].nodeName.toLowerCase();
68500         vContent = createObjTree(aCache[nElId], nVerb, bFreeze, bNesteAttr);
68501         if (vResult.hasOwnProperty(sProp)) {
68502           if (vResult[sProp].constructor !== Array) {
68503             vResult[sProp] = [vResult[sProp]];
68504           }
68505           vResult[sProp].push(vContent);
68506         } else {
68507           vResult[sProp] = vContent;
68508           nLength++;
68509         }
68510       }
68511       if (bAttributes) {
68512         var nAttrLen = oParentNode.attributes.length, sAPrefix = bNesteAttr ? "" : sAttrPref, oAttrParent = bNesteAttr ? {} : vResult;
68513         for (var oAttrib, nAttrib = 0; nAttrib < nAttrLen; nLength++, nAttrib++) {
68514           oAttrib = oParentNode.attributes.item(nAttrib);
68515           oAttrParent[sAPrefix + oAttrib.name.toLowerCase()] = parseText(oAttrib.value.trim());
68516         }
68517         if (bNesteAttr) {
68518           if (bFreeze) {
68519             Object.freeze(oAttrParent);
68520           }
68521           vResult[sAttributesProp] = oAttrParent;
68522           nLength -= nAttrLen - 1;
68523         }
68524       }
68525       if (nVerb === 3 || (nVerb === 2 || nVerb === 1 && nLength > 0) && sCollectedTxt) {
68526         vResult[sValueProp] = vBuiltVal;
68527       } else if (!bHighVerb && nLength === 0 && sCollectedTxt) {
68528         vResult = vBuiltVal;
68529       }
68530       if (bFreeze && (bHighVerb || nLength > 0)) {
68531         Object.freeze(vResult);
68532       }
68533       aCache.length = nLevelStart;
68534       return vResult;
68535     }
68536     function loadObjTree(oXMLDoc, oParentEl, oParentObj) {
68537       var vValue, oChild;
68538       if (oParentObj instanceof String || oParentObj instanceof Number || oParentObj instanceof Boolean) {
68539         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toString()));
68540       } else if (oParentObj.constructor === Date) {
68541         oParentEl.appendChild(oXMLDoc.createTextNode(oParentObj.toGMTString()));
68542       }
68543       for (var sName in oParentObj) {
68544         vValue = oParentObj[sName];
68545         if (isFinite(sName) || vValue instanceof Function) {
68546           continue;
68547         }
68548         if (sName === sValueProp) {
68549           if (vValue !== null && vValue !== true) {
68550             oParentEl.appendChild(oXMLDoc.createTextNode(vValue.constructor === Date ? vValue.toGMTString() : String(vValue)));
68551           }
68552         } else if (sName === sAttributesProp) {
68553           for (var sAttrib in vValue) {
68554             oParentEl.setAttribute(sAttrib, vValue[sAttrib]);
68555           }
68556         } else if (sName.charAt(0) === sAttrPref) {
68557           oParentEl.setAttribute(sName.slice(1), vValue);
68558         } else if (vValue.constructor === Array) {
68559           for (var nItem = 0; nItem < vValue.length; nItem++) {
68560             oChild = oXMLDoc.createElement(sName);
68561             loadObjTree(oXMLDoc, oChild, vValue[nItem]);
68562             oParentEl.appendChild(oChild);
68563           }
68564         } else {
68565           oChild = oXMLDoc.createElement(sName);
68566           if (vValue instanceof Object) {
68567             loadObjTree(oXMLDoc, oChild, vValue);
68568           } else if (vValue !== null && vValue !== true) {
68569             oChild.appendChild(oXMLDoc.createTextNode(vValue.toString()));
68570           }
68571           oParentEl.appendChild(oChild);
68572         }
68573       }
68574     }
68575     this.build = function(oXMLParent, nVerbosity, bFreeze, bNesteAttributes) {
68576       var _nVerb = arguments.length > 1 && typeof nVerbosity === "number" ? nVerbosity & 3 : (
68577         /* put here the default verbosity level: */
68578         1
68579       );
68580       return createObjTree(oXMLParent, _nVerb, bFreeze || false, arguments.length > 3 ? bNesteAttributes : _nVerb === 3);
68581     };
68582     this.unbuild = function(oObjTree) {
68583       var oNewDoc = document.implementation.createDocument("", "", null);
68584       loadObjTree(oNewDoc, oNewDoc, oObjTree);
68585       return oNewDoc;
68586     };
68587     this.stringify = function(oObjTree) {
68588       return new XMLSerializer().serializeToString(JXON.unbuild(oObjTree));
68589     };
68590   }();
68591
68592   // modules/ui/sections/changes.js
68593   function uiSectionChanges(context) {
68594     var _discardTags = {};
68595     _mainFileFetcher.get("discarded").then(function(d2) {
68596       _discardTags = d2;
68597     }).catch(function() {
68598     });
68599     var section = uiSection("changes-list", context).label(function() {
68600       var history = context.history();
68601       var summary = history.difference().summary();
68602       return _t.append("inspector.title_count", { title: _t("commit.changes"), count: summary.length });
68603     }).disclosureContent(renderDisclosureContent);
68604     function renderDisclosureContent(selection2) {
68605       var history = context.history();
68606       var summary = history.difference().summary();
68607       var container = selection2.selectAll(".commit-section").data([0]);
68608       var containerEnter = container.enter().append("div").attr("class", "commit-section");
68609       containerEnter.append("ul").attr("class", "changeset-list");
68610       container = containerEnter.merge(container);
68611       var items = container.select("ul").selectAll("li").data(summary);
68612       var itemsEnter = items.enter().append("li").attr("class", "change-item");
68613       var buttons = itemsEnter.append("button").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
68614       buttons.each(function(d2) {
68615         select_default2(this).call(svgIcon("#iD-icon-" + d2.entity.geometry(d2.graph), "pre-text " + d2.changeType));
68616       });
68617       buttons.append("span").attr("class", "change-type").html(function(d2) {
68618         return _t.html("commit." + d2.changeType) + " ";
68619       });
68620       buttons.append("strong").attr("class", "entity-type").text(function(d2) {
68621         var matched = _mainPresetIndex.match(d2.entity, d2.graph);
68622         return matched && matched.name() || utilDisplayType(d2.entity.id);
68623       });
68624       buttons.append("span").attr("class", "entity-name").text(function(d2) {
68625         var name = utilDisplayName(d2.entity) || "", string = "";
68626         if (name !== "") {
68627           string += ":";
68628         }
68629         return string += " " + name;
68630       });
68631       items = itemsEnter.merge(items);
68632       var changeset = new osmChangeset().update({ id: void 0 });
68633       var changes = history.changes(actionDiscardTags(history.difference(), _discardTags));
68634       delete changeset.id;
68635       var data = JXON.stringify(changeset.osmChangeJXON(changes));
68636       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
68637       var fileName = "changes.osc";
68638       var linkEnter = container.selectAll(".download-changes").data([0]).enter().append("a").attr("class", "download-changes");
68639       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
68640       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("commit.download_changes"));
68641       function mouseover(d2) {
68642         if (d2.entity) {
68643           context.surface().selectAll(
68644             utilEntityOrMemberSelector([d2.entity.id], context.graph())
68645           ).classed("hover", true);
68646         }
68647       }
68648       function mouseout() {
68649         context.surface().selectAll(".hover").classed("hover", false);
68650       }
68651       function click(d3_event, change) {
68652         if (change.changeType !== "deleted") {
68653           var entity = change.entity;
68654           context.map().zoomToEase(entity);
68655           context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
68656         }
68657       }
68658     }
68659     return section;
68660   }
68661
68662   // modules/ui/commit_warnings.js
68663   function uiCommitWarnings(context) {
68664     function commitWarnings(selection2) {
68665       var issuesBySeverity = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeDisabledRules: true });
68666       for (var severity in issuesBySeverity) {
68667         var issues = issuesBySeverity[severity];
68668         if (severity !== "error") {
68669           issues = issues.filter(function(issue) {
68670             return issue.type !== "help_request";
68671           });
68672         }
68673         var section = severity + "-section";
68674         var issueItem = severity + "-item";
68675         var container = selection2.selectAll("." + section).data(issues.length ? [0] : []);
68676         container.exit().remove();
68677         var containerEnter = container.enter().append("div").attr("class", "modal-section " + section + " fillL2");
68678         containerEnter.append("h3").call(severity === "warning" ? _t.append("commit.warnings") : _t.append("commit.errors"));
68679         containerEnter.append("ul").attr("class", "changeset-list");
68680         container = containerEnter.merge(container);
68681         var items = container.select("ul").selectAll("li").data(issues, function(d2) {
68682           return d2.key;
68683         });
68684         items.exit().remove();
68685         var itemsEnter = items.enter().append("li").attr("class", issueItem);
68686         var buttons = itemsEnter.append("button").on("mouseover", function(d3_event, d2) {
68687           if (d2.entityIds) {
68688             context.surface().selectAll(
68689               utilEntityOrMemberSelector(
68690                 d2.entityIds,
68691                 context.graph()
68692               )
68693             ).classed("hover", true);
68694           }
68695         }).on("mouseout", function() {
68696           context.surface().selectAll(".hover").classed("hover", false);
68697         }).on("click", function(d3_event, d2) {
68698           context.validator().focusIssue(d2);
68699         });
68700         buttons.call(svgIcon("#iD-icon-alert", "pre-text"));
68701         buttons.append("strong").attr("class", "issue-message");
68702         buttons.filter(function(d2) {
68703           return d2.tooltip;
68704         }).call(
68705           uiTooltip().title(function(d2) {
68706             return d2.tooltip;
68707           }).placement("top")
68708         );
68709         items = itemsEnter.merge(items);
68710         items.selectAll(".issue-message").text("").each(function(d2) {
68711           return d2.message(context)(select_default2(this));
68712         });
68713       }
68714     }
68715     return commitWarnings;
68716   }
68717
68718   // modules/ui/commit.js
68719   var readOnlyTags = [
68720     /^changesets_count$/,
68721     /^created_by$/,
68722     /^ideditor:/,
68723     /^imagery_used$/,
68724     /^host$/,
68725     /^locale$/,
68726     /^warnings:/,
68727     /^resolved:/,
68728     /^closed:note$/,
68729     /^closed:keepright$/,
68730     /^closed:improveosm:/,
68731     /^closed:osmose:/
68732   ];
68733   var hashtagRegex = /(#[^\u2000-\u206F\u2E00-\u2E7F\s\\'!"#$%()*,.\/:;<=>?@\[\]^`{|}~]+)/g;
68734   function uiCommit(context) {
68735     var dispatch14 = dispatch_default("cancel");
68736     var _userDetails2;
68737     var _selection;
68738     var changesetEditor = uiChangesetEditor(context).on("change", changeTags);
68739     var rawTagEditor = uiSectionRawTagEditor("changeset-tag-editor", context).on("change", changeTags).readOnlyTags(readOnlyTags);
68740     var commitChanges = uiSectionChanges(context);
68741     var commitWarnings = uiCommitWarnings(context);
68742     function commit(selection2) {
68743       _selection = selection2;
68744       if (!context.changeset)
68745         initChangeset();
68746       loadDerivedChangesetTags();
68747       selection2.call(render);
68748     }
68749     function initChangeset() {
68750       var commentDate = +corePreferences("commentDate") || 0;
68751       var currDate = Date.now();
68752       var cutoff = 2 * 86400 * 1e3;
68753       if (commentDate > currDate || currDate - commentDate > cutoff) {
68754         corePreferences("comment", null);
68755         corePreferences("hashtags", null);
68756         corePreferences("source", null);
68757       }
68758       if (context.defaultChangesetComment()) {
68759         corePreferences("comment", context.defaultChangesetComment());
68760         corePreferences("commentDate", Date.now());
68761       }
68762       if (context.defaultChangesetSource()) {
68763         corePreferences("source", context.defaultChangesetSource());
68764         corePreferences("commentDate", Date.now());
68765       }
68766       if (context.defaultChangesetHashtags()) {
68767         corePreferences("hashtags", context.defaultChangesetHashtags());
68768         corePreferences("commentDate", Date.now());
68769       }
68770       var detected = utilDetect();
68771       var tags = {
68772         comment: corePreferences("comment") || "",
68773         created_by: context.cleanTagValue("iD " + context.version),
68774         host: context.cleanTagValue(detected.host),
68775         locale: context.cleanTagValue(_mainLocalizer.localeCode())
68776       };
68777       findHashtags(tags, true);
68778       var hashtags = corePreferences("hashtags");
68779       if (hashtags) {
68780         tags.hashtags = hashtags;
68781       }
68782       var source = corePreferences("source");
68783       if (source) {
68784         tags.source = source;
68785       }
68786       var photoOverlaysUsed = context.history().photoOverlaysUsed();
68787       if (photoOverlaysUsed.length) {
68788         var sources = (tags.source || "").split(";");
68789         if (sources.indexOf("streetlevel imagery") === -1) {
68790           sources.push("streetlevel imagery");
68791         }
68792         photoOverlaysUsed.forEach(function(photoOverlay) {
68793           if (sources.indexOf(photoOverlay) === -1) {
68794             sources.push(photoOverlay);
68795           }
68796         });
68797         tags.source = context.cleanTagValue(sources.join(";"));
68798       }
68799       context.changeset = new osmChangeset({ tags });
68800     }
68801     function loadDerivedChangesetTags() {
68802       var osm = context.connection();
68803       if (!osm)
68804         return;
68805       var tags = Object.assign({}, context.changeset.tags);
68806       var imageryUsed = context.cleanTagValue(context.history().imageryUsed().join(";"));
68807       tags.imagery_used = imageryUsed || "None";
68808       var osmClosed = osm.getClosedIDs();
68809       var itemType;
68810       if (osmClosed.length) {
68811         tags["closed:note"] = context.cleanTagValue(osmClosed.join(";"));
68812       }
68813       if (services.keepRight) {
68814         var krClosed = services.keepRight.getClosedIDs();
68815         if (krClosed.length) {
68816           tags["closed:keepright"] = context.cleanTagValue(krClosed.join(";"));
68817         }
68818       }
68819       if (services.improveOSM) {
68820         var iOsmClosed = services.improveOSM.getClosedCounts();
68821         for (itemType in iOsmClosed) {
68822           tags["closed:improveosm:" + itemType] = context.cleanTagValue(iOsmClosed[itemType].toString());
68823         }
68824       }
68825       if (services.osmose) {
68826         var osmoseClosed = services.osmose.getClosedCounts();
68827         for (itemType in osmoseClosed) {
68828           tags["closed:osmose:" + itemType] = context.cleanTagValue(osmoseClosed[itemType].toString());
68829         }
68830       }
68831       for (var key in tags) {
68832         if (key.match(/(^warnings:)|(^resolved:)/)) {
68833           delete tags[key];
68834         }
68835       }
68836       function addIssueCounts(issues, prefix) {
68837         var issuesByType = utilArrayGroupBy(issues, "type");
68838         for (var issueType in issuesByType) {
68839           var issuesOfType = issuesByType[issueType];
68840           if (issuesOfType[0].subtype) {
68841             var issuesBySubtype = utilArrayGroupBy(issuesOfType, "subtype");
68842             for (var issueSubtype in issuesBySubtype) {
68843               var issuesOfSubtype = issuesBySubtype[issueSubtype];
68844               tags[prefix + ":" + issueType + ":" + issueSubtype] = context.cleanTagValue(issuesOfSubtype.length.toString());
68845             }
68846           } else {
68847             tags[prefix + ":" + issueType] = context.cleanTagValue(issuesOfType.length.toString());
68848           }
68849         }
68850       }
68851       var warnings = context.validator().getIssuesBySeverity({ what: "edited", where: "all", includeIgnored: true, includeDisabledRules: true }).warning.filter(function(issue) {
68852         return issue.type !== "help_request";
68853       });
68854       addIssueCounts(warnings, "warnings");
68855       var resolvedIssues = context.validator().getResolvedIssues();
68856       addIssueCounts(resolvedIssues, "resolved");
68857       context.changeset = context.changeset.update({ tags });
68858     }
68859     function render(selection2) {
68860       var osm = context.connection();
68861       if (!osm)
68862         return;
68863       var header = selection2.selectAll(".header").data([0]);
68864       var headerTitle = header.enter().append("div").attr("class", "header fillL");
68865       headerTitle.append("div").append("h2").call(_t.append("commit.title"));
68866       headerTitle.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
68867         dispatch14.call("cancel", this);
68868       }).call(svgIcon("#iD-icon-close"));
68869       var body = selection2.selectAll(".body").data([0]);
68870       body = body.enter().append("div").attr("class", "body").merge(body);
68871       var changesetSection = body.selectAll(".changeset-editor").data([0]);
68872       changesetSection = changesetSection.enter().append("div").attr("class", "modal-section changeset-editor").merge(changesetSection);
68873       changesetSection.call(
68874         changesetEditor.changesetID(context.changeset.id).tags(context.changeset.tags)
68875       );
68876       body.call(commitWarnings);
68877       var saveSection = body.selectAll(".save-section").data([0]);
68878       saveSection = saveSection.enter().append("div").attr("class", "modal-section save-section fillL").merge(saveSection);
68879       var prose = saveSection.selectAll(".commit-info").data([0]);
68880       if (prose.enter().size()) {
68881         _userDetails2 = null;
68882       }
68883       prose = prose.enter().append("p").attr("class", "commit-info").call(_t.append("commit.upload_explanation")).merge(prose);
68884       osm.userDetails(function(err, user) {
68885         if (err)
68886           return;
68887         if (_userDetails2 === user)
68888           return;
68889         _userDetails2 = user;
68890         var userLink = select_default2(document.createElement("div"));
68891         if (user.image_url) {
68892           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
68893         }
68894         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
68895         prose.html(_t.html("commit.upload_explanation_with_user", { user: { html: userLink.html() } }));
68896       });
68897       var requestReview = saveSection.selectAll(".request-review").data([0]);
68898       var requestReviewEnter = requestReview.enter().append("div").attr("class", "request-review");
68899       var requestReviewDomId = utilUniqueDomId("commit-input-request-review");
68900       var labelEnter = requestReviewEnter.append("label").attr("for", requestReviewDomId);
68901       if (!labelEnter.empty()) {
68902         labelEnter.call(uiTooltip().title(() => _t.append("commit.request_review_info")).placement("top"));
68903       }
68904       labelEnter.append("input").attr("type", "checkbox").attr("id", requestReviewDomId);
68905       labelEnter.append("span").call(_t.append("commit.request_review"));
68906       requestReview = requestReview.merge(requestReviewEnter);
68907       var requestReviewInput = requestReview.selectAll("input").property("checked", isReviewRequested(context.changeset.tags)).on("change", toggleRequestReview);
68908       var buttonSection = saveSection.selectAll(".buttons").data([0]);
68909       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons fillL");
68910       buttonEnter.append("button").attr("class", "secondary-action button cancel-button").append("span").attr("class", "label").call(_t.append("commit.cancel"));
68911       var uploadButton = buttonEnter.append("button").attr("class", "action button save-button");
68912       uploadButton.append("span").attr("class", "label").call(_t.append("commit.save"));
68913       var uploadBlockerTooltipText = getUploadBlockerMessage();
68914       buttonSection = buttonSection.merge(buttonEnter);
68915       buttonSection.selectAll(".cancel-button").on("click.cancel", function() {
68916         dispatch14.call("cancel", this);
68917       });
68918       buttonSection.selectAll(".save-button").classed("disabled", uploadBlockerTooltipText !== null).on("click.save", function() {
68919         if (!select_default2(this).classed("disabled")) {
68920           this.blur();
68921           for (var key in context.changeset.tags) {
68922             if (!key)
68923               delete context.changeset.tags[key];
68924           }
68925           context.uploader().save(context.changeset);
68926         }
68927       });
68928       uiTooltip().destroyAny(buttonSection.selectAll(".save-button"));
68929       if (uploadBlockerTooltipText) {
68930         buttonSection.selectAll(".save-button").call(uiTooltip().title(() => uploadBlockerTooltipText).placement("top"));
68931       }
68932       var tagSection = body.selectAll(".tag-section.raw-tag-editor").data([0]);
68933       tagSection = tagSection.enter().append("div").attr("class", "modal-section tag-section raw-tag-editor").merge(tagSection);
68934       tagSection.call(
68935         rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
68936       );
68937       var changesSection = body.selectAll(".commit-changes-section").data([0]);
68938       changesSection = changesSection.enter().append("div").attr("class", "modal-section commit-changes-section").merge(changesSection);
68939       changesSection.call(commitChanges.render);
68940       function toggleRequestReview() {
68941         var rr = requestReviewInput.property("checked");
68942         updateChangeset({ review_requested: rr ? "yes" : void 0 });
68943         tagSection.call(
68944           rawTagEditor.tags(Object.assign({}, context.changeset.tags)).render
68945         );
68946       }
68947     }
68948     function getUploadBlockerMessage() {
68949       var errors = context.validator().getIssuesBySeverity({ what: "edited", where: "all" }).error;
68950       if (errors.length) {
68951         return _t.append("commit.outstanding_errors_message", { count: errors.length });
68952       } else {
68953         var hasChangesetComment = context.changeset && context.changeset.tags.comment && context.changeset.tags.comment.trim().length;
68954         if (!hasChangesetComment) {
68955           return _t.append("commit.comment_needed_message");
68956         }
68957       }
68958       return null;
68959     }
68960     function changeTags(_2, changed, onInput) {
68961       if (changed.hasOwnProperty("comment")) {
68962         if (changed.comment === void 0) {
68963           changed.comment = "";
68964         }
68965         if (!onInput) {
68966           corePreferences("comment", changed.comment);
68967           corePreferences("commentDate", Date.now());
68968         }
68969       }
68970       if (changed.hasOwnProperty("source")) {
68971         if (changed.source === void 0) {
68972           corePreferences("source", null);
68973         } else if (!onInput) {
68974           corePreferences("source", changed.source);
68975           corePreferences("commentDate", Date.now());
68976         }
68977       }
68978       updateChangeset(changed, onInput);
68979       if (_selection) {
68980         _selection.call(render);
68981       }
68982     }
68983     function findHashtags(tags, commentOnly) {
68984       var detectedHashtags = commentHashtags();
68985       if (detectedHashtags.length) {
68986         corePreferences("hashtags", null);
68987       }
68988       if (!detectedHashtags.length || !commentOnly) {
68989         detectedHashtags = detectedHashtags.concat(hashtagHashtags());
68990       }
68991       var allLowerCase = /* @__PURE__ */ new Set();
68992       return detectedHashtags.filter(function(hashtag) {
68993         var lowerCase = hashtag.toLowerCase();
68994         if (!allLowerCase.has(lowerCase)) {
68995           allLowerCase.add(lowerCase);
68996           return true;
68997         }
68998         return false;
68999       });
69000       function commentHashtags() {
69001         var matches = (tags.comment || "").replace(/http\S*/g, "").match(hashtagRegex);
69002         return matches || [];
69003       }
69004       function hashtagHashtags() {
69005         var matches = (tags.hashtags || "").split(/[,;\s]+/).map(function(s2) {
69006           if (s2[0] !== "#") {
69007             s2 = "#" + s2;
69008           }
69009           var matched = s2.match(hashtagRegex);
69010           return matched && matched[0];
69011         }).filter(Boolean);
69012         return matches || [];
69013       }
69014     }
69015     function isReviewRequested(tags) {
69016       var rr = tags.review_requested;
69017       if (rr === void 0)
69018         return false;
69019       rr = rr.trim().toLowerCase();
69020       return !(rr === "" || rr === "no");
69021     }
69022     function updateChangeset(changed, onInput) {
69023       var tags = Object.assign({}, context.changeset.tags);
69024       Object.keys(changed).forEach(function(k2) {
69025         var v2 = changed[k2];
69026         k2 = context.cleanTagKey(k2);
69027         if (readOnlyTags.indexOf(k2) !== -1)
69028           return;
69029         if (v2 === void 0) {
69030           delete tags[k2];
69031         } else if (onInput) {
69032           tags[k2] = v2;
69033         } else {
69034           tags[k2] = context.cleanTagValue(v2);
69035         }
69036       });
69037       if (!onInput) {
69038         var commentOnly = changed.hasOwnProperty("comment") && changed.comment !== "";
69039         var arr = findHashtags(tags, commentOnly);
69040         if (arr.length) {
69041           tags.hashtags = context.cleanTagValue(arr.join(";"));
69042           corePreferences("hashtags", tags.hashtags);
69043         } else {
69044           delete tags.hashtags;
69045           corePreferences("hashtags", null);
69046         }
69047       }
69048       if (_userDetails2 && _userDetails2.changesets_count !== void 0) {
69049         var changesetsCount = parseInt(_userDetails2.changesets_count, 10) + 1;
69050         tags.changesets_count = String(changesetsCount);
69051         if (changesetsCount <= 100) {
69052           var s2;
69053           s2 = corePreferences("walkthrough_completed");
69054           if (s2) {
69055             tags["ideditor:walkthrough_completed"] = s2;
69056           }
69057           s2 = corePreferences("walkthrough_progress");
69058           if (s2) {
69059             tags["ideditor:walkthrough_progress"] = s2;
69060           }
69061           s2 = corePreferences("walkthrough_started");
69062           if (s2) {
69063             tags["ideditor:walkthrough_started"] = s2;
69064           }
69065         }
69066       } else {
69067         delete tags.changesets_count;
69068       }
69069       if (!(0, import_fast_deep_equal9.default)(context.changeset.tags, tags)) {
69070         context.changeset = context.changeset.update({ tags });
69071       }
69072     }
69073     commit.reset = function() {
69074       context.changeset = null;
69075     };
69076     return utilRebind(commit, dispatch14, "on");
69077   }
69078
69079   // modules/ui/confirm.js
69080   function uiConfirm(selection2) {
69081     var modalSelection = uiModal(selection2);
69082     modalSelection.select(".modal").classed("modal-alert", true);
69083     var section = modalSelection.select(".content");
69084     section.append("div").attr("class", "modal-section header");
69085     section.append("div").attr("class", "modal-section message-text");
69086     var buttons = section.append("div").attr("class", "modal-section buttons cf");
69087     modalSelection.okButton = function() {
69088       buttons.append("button").attr("class", "button ok-button action").on("click.confirm", function() {
69089         modalSelection.remove();
69090       }).call(_t.append("confirm.okay")).node().focus();
69091       return modalSelection;
69092     };
69093     return modalSelection;
69094   }
69095
69096   // modules/ui/conflicts.js
69097   function uiConflicts(context) {
69098     var dispatch14 = dispatch_default("cancel", "save");
69099     var keybinding = utilKeybinding("conflicts");
69100     var _origChanges;
69101     var _conflictList;
69102     var _shownConflictIndex;
69103     function keybindingOn() {
69104       select_default2(document).call(keybinding.on("\u238B", cancel, true));
69105     }
69106     function keybindingOff() {
69107       select_default2(document).call(keybinding.unbind);
69108     }
69109     function tryAgain() {
69110       keybindingOff();
69111       dispatch14.call("save");
69112     }
69113     function cancel() {
69114       keybindingOff();
69115       dispatch14.call("cancel");
69116     }
69117     function conflicts(selection2) {
69118       keybindingOn();
69119       var headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
69120       headerEnter.append("button").attr("class", "fr").attr("title", _t("icons.close")).on("click", cancel).call(svgIcon("#iD-icon-close"));
69121       headerEnter.append("h2").call(_t.append("save.conflict.header"));
69122       var bodyEnter = selection2.selectAll(".body").data([0]).enter().append("div").attr("class", "body fillL");
69123       var conflictsHelpEnter = bodyEnter.append("div").attr("class", "conflicts-help").call(_t.append("save.conflict.help"));
69124       var changeset = new osmChangeset();
69125       delete changeset.id;
69126       var data = JXON.stringify(changeset.osmChangeJXON(_origChanges));
69127       var blob = new Blob([data], { type: "text/xml;charset=utf-8;" });
69128       var fileName = "changes.osc";
69129       var linkEnter = conflictsHelpEnter.selectAll(".download-changes").append("a").attr("class", "download-changes");
69130       linkEnter.attr("href", window.URL.createObjectURL(blob)).attr("download", fileName);
69131       linkEnter.call(svgIcon("#iD-icon-load", "inline")).append("span").call(_t.append("save.conflict.download_changes"));
69132       bodyEnter.append("div").attr("class", "conflict-container fillL3").call(showConflict, 0);
69133       bodyEnter.append("div").attr("class", "conflicts-done").attr("opacity", 0).style("display", "none").call(_t.append("save.conflict.done"));
69134       var buttonsEnter = bodyEnter.append("div").attr("class", "buttons col12 joined conflicts-buttons");
69135       buttonsEnter.append("button").attr("disabled", _conflictList.length > 1).attr("class", "action conflicts-button col6").call(_t.append("save.title")).on("click.try_again", tryAgain);
69136       buttonsEnter.append("button").attr("class", "secondary-action conflicts-button col6").call(_t.append("confirm.cancel")).on("click.cancel", cancel);
69137     }
69138     function showConflict(selection2, index) {
69139       index = utilWrap(index, _conflictList.length);
69140       _shownConflictIndex = index;
69141       var parent = select_default2(selection2.node().parentNode);
69142       if (index === _conflictList.length - 1) {
69143         window.setTimeout(function() {
69144           parent.select(".conflicts-button").attr("disabled", null);
69145           parent.select(".conflicts-done").transition().attr("opacity", 1).style("display", "block");
69146         }, 250);
69147       }
69148       var conflict = selection2.selectAll(".conflict").data([_conflictList[index]]);
69149       conflict.exit().remove();
69150       var conflictEnter = conflict.enter().append("div").attr("class", "conflict");
69151       conflictEnter.append("h4").attr("class", "conflict-count").call(_t.append("save.conflict.count", { num: index + 1, total: _conflictList.length }));
69152       conflictEnter.append("a").attr("class", "conflict-description").attr("href", "#").text(function(d2) {
69153         return d2.name;
69154       }).on("click", function(d3_event, d2) {
69155         d3_event.preventDefault();
69156         zoomToEntity(d2.id);
69157       });
69158       var details = conflictEnter.append("div").attr("class", "conflict-detail-container");
69159       details.append("ul").attr("class", "conflict-detail-list").selectAll("li").data(function(d2) {
69160         return d2.details || [];
69161       }).enter().append("li").attr("class", "conflict-detail-item").html(function(d2) {
69162         return d2;
69163       });
69164       details.append("div").attr("class", "conflict-choices").call(addChoices);
69165       details.append("div").attr("class", "conflict-nav-buttons joined cf").selectAll("button").data(["previous", "next"]).enter().append("button").attr("class", "conflict-nav-button action col6").attr("disabled", function(d2, i3) {
69166         return i3 === 0 && index === 0 || i3 === 1 && index === _conflictList.length - 1 || null;
69167       }).on("click", function(d3_event, d2) {
69168         d3_event.preventDefault();
69169         var container = parent.selectAll(".conflict-container");
69170         var sign2 = d2 === "previous" ? -1 : 1;
69171         container.selectAll(".conflict").remove();
69172         container.call(showConflict, index + sign2);
69173       }).each(function(d2) {
69174         _t.append("save.conflict." + d2)(select_default2(this));
69175       });
69176     }
69177     function addChoices(selection2) {
69178       var choices = selection2.append("ul").attr("class", "layer-list").selectAll("li").data(function(d2) {
69179         return d2.choices || [];
69180       });
69181       var choicesEnter = choices.enter().append("li").attr("class", "layer");
69182       var labelEnter = choicesEnter.append("label");
69183       labelEnter.append("input").attr("type", "radio").attr("name", function(d2) {
69184         return d2.id;
69185       }).on("change", function(d3_event, d2) {
69186         var ul = this.parentNode.parentNode.parentNode;
69187         ul.__data__.chosen = d2.id;
69188         choose(d3_event, ul, d2);
69189       });
69190       labelEnter.append("span").text(function(d2) {
69191         return d2.text;
69192       });
69193       choicesEnter.merge(choices).each(function(d2) {
69194         var ul = this.parentNode;
69195         if (ul.__data__.chosen === d2.id) {
69196           choose(null, ul, d2);
69197         }
69198       });
69199     }
69200     function choose(d3_event, ul, datum2) {
69201       if (d3_event)
69202         d3_event.preventDefault();
69203       select_default2(ul).selectAll("li").classed("active", function(d2) {
69204         return d2 === datum2;
69205       }).selectAll("input").property("checked", function(d2) {
69206         return d2 === datum2;
69207       });
69208       var extent = geoExtent();
69209       var entity;
69210       entity = context.graph().hasEntity(datum2.id);
69211       if (entity)
69212         extent._extend(entity.extent(context.graph()));
69213       datum2.action();
69214       entity = context.graph().hasEntity(datum2.id);
69215       if (entity)
69216         extent._extend(entity.extent(context.graph()));
69217       zoomToEntity(datum2.id, extent);
69218     }
69219     function zoomToEntity(id2, extent) {
69220       context.surface().selectAll(".hover").classed("hover", false);
69221       var entity = context.graph().hasEntity(id2);
69222       if (entity) {
69223         if (extent) {
69224           context.map().trimmedExtent(extent);
69225         } else {
69226           context.map().zoomToEase(entity);
69227         }
69228         context.surface().selectAll(utilEntityOrMemberSelector([entity.id], context.graph())).classed("hover", true);
69229       }
69230     }
69231     conflicts.conflictList = function(_2) {
69232       if (!arguments.length)
69233         return _conflictList;
69234       _conflictList = _2;
69235       return conflicts;
69236     };
69237     conflicts.origChanges = function(_2) {
69238       if (!arguments.length)
69239         return _origChanges;
69240       _origChanges = _2;
69241       return conflicts;
69242     };
69243     conflicts.shownEntityIds = function() {
69244       if (_conflictList && typeof _shownConflictIndex === "number") {
69245         return [_conflictList[_shownConflictIndex].id];
69246       }
69247       return [];
69248     };
69249     return utilRebind(conflicts, dispatch14, "on");
69250   }
69251
69252   // modules/ui/entity_editor.js
69253   var import_fast_deep_equal10 = __toESM(require_fast_deep_equal());
69254
69255   // modules/ui/sections/entity_issues.js
69256   function uiSectionEntityIssues(context) {
69257     var preference = corePreferences("entity-issues.reference.expanded");
69258     var _expanded = preference === null ? true : preference === "true";
69259     var _entityIDs = [];
69260     var _issues = [];
69261     var _activeIssueID;
69262     var section = uiSection("entity-issues", context).shouldDisplay(function() {
69263       return _issues.length > 0;
69264     }).label(function() {
69265       return _t.append("inspector.title_count", { title: _t("issues.list_title"), count: _issues.length });
69266     }).disclosureContent(renderDisclosureContent);
69267     context.validator().on("validated.entity_issues", function() {
69268       reloadIssues();
69269       section.reRender();
69270     }).on("focusedIssue.entity_issues", function(issue) {
69271       makeActiveIssue(issue.id);
69272     });
69273     function reloadIssues() {
69274       _issues = context.validator().getSharedEntityIssues(_entityIDs, { includeDisabledRules: true });
69275     }
69276     function makeActiveIssue(issueID) {
69277       _activeIssueID = issueID;
69278       section.selection().selectAll(".issue-container").classed("active", function(d2) {
69279         return d2.id === _activeIssueID;
69280       });
69281     }
69282     function renderDisclosureContent(selection2) {
69283       selection2.classed("grouped-items-area", true);
69284       _activeIssueID = _issues.length > 0 ? _issues[0].id : null;
69285       var containers = selection2.selectAll(".issue-container").data(_issues, function(d2) {
69286         return d2.key;
69287       });
69288       containers.exit().remove();
69289       var containersEnter = containers.enter().append("div").attr("class", "issue-container");
69290       var itemsEnter = containersEnter.append("div").attr("class", function(d2) {
69291         return "issue severity-" + d2.severity;
69292       }).on("mouseover.highlight", function(d3_event, d2) {
69293         var ids = d2.entityIds.filter(function(e3) {
69294           return _entityIDs.indexOf(e3) === -1;
69295         });
69296         utilHighlightEntities(ids, true, context);
69297       }).on("mouseout.highlight", function(d3_event, d2) {
69298         var ids = d2.entityIds.filter(function(e3) {
69299           return _entityIDs.indexOf(e3) === -1;
69300         });
69301         utilHighlightEntities(ids, false, context);
69302       });
69303       var labelsEnter = itemsEnter.append("div").attr("class", "issue-label");
69304       var textEnter = labelsEnter.append("button").attr("class", "issue-text").on("click", function(d3_event, d2) {
69305         makeActiveIssue(d2.id);
69306         var extent = d2.extent(context.graph());
69307         if (extent) {
69308           var setZoom = Math.max(context.map().zoom(), 19);
69309           context.map().unobscuredCenterZoomEase(extent.center(), setZoom);
69310         }
69311       });
69312       textEnter.each(function(d2) {
69313         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
69314         select_default2(this).call(svgIcon(iconName, "issue-icon"));
69315       });
69316       textEnter.append("span").attr("class", "issue-message");
69317       var infoButton = labelsEnter.append("button").attr("class", "issue-info-button").attr("title", _t("icons.information")).call(svgIcon("#iD-icon-inspect"));
69318       infoButton.on("click", function(d3_event) {
69319         d3_event.stopPropagation();
69320         d3_event.preventDefault();
69321         this.blur();
69322         var container = select_default2(this.parentNode.parentNode.parentNode);
69323         var info = container.selectAll(".issue-info");
69324         var isExpanded = info.classed("expanded");
69325         _expanded = !isExpanded;
69326         corePreferences("entity-issues.reference.expanded", _expanded);
69327         if (isExpanded) {
69328           info.transition().duration(200).style("max-height", "0px").style("opacity", "0").on("end", function() {
69329             info.classed("expanded", false);
69330           });
69331         } else {
69332           info.classed("expanded", true).transition().duration(200).style("max-height", "200px").style("opacity", "1").on("end", function() {
69333             info.style("max-height", null);
69334           });
69335         }
69336       });
69337       itemsEnter.append("ul").attr("class", "issue-fix-list");
69338       containersEnter.append("div").attr("class", "issue-info" + (_expanded ? " expanded" : "")).style("max-height", _expanded ? null : "0").style("opacity", _expanded ? "1" : "0").each(function(d2) {
69339         if (typeof d2.reference === "function") {
69340           select_default2(this).call(d2.reference);
69341         } else {
69342           select_default2(this).call(_t.append("inspector.no_documentation_key"));
69343         }
69344       });
69345       containers = containers.merge(containersEnter).classed("active", function(d2) {
69346         return d2.id === _activeIssueID;
69347       });
69348       containers.selectAll(".issue-message").text("").each(function(d2) {
69349         return d2.message(context)(select_default2(this));
69350       });
69351       var fixLists = containers.selectAll(".issue-fix-list");
69352       var fixes = fixLists.selectAll(".issue-fix-item").data(function(d2) {
69353         return d2.fixes ? d2.fixes(context) : [];
69354       }, function(fix) {
69355         return fix.id;
69356       });
69357       fixes.exit().remove();
69358       var fixesEnter = fixes.enter().append("li").attr("class", "issue-fix-item");
69359       var buttons = fixesEnter.append("button").on("click", function(d3_event, d2) {
69360         if (select_default2(this).attr("disabled") || !d2.onClick)
69361           return;
69362         if (d2.issue.dateLastRanFix && /* @__PURE__ */ new Date() - d2.issue.dateLastRanFix < 1e3)
69363           return;
69364         d2.issue.dateLastRanFix = /* @__PURE__ */ new Date();
69365         utilHighlightEntities(d2.issue.entityIds.concat(d2.entityIds), false, context);
69366         new Promise(function(resolve, reject) {
69367           d2.onClick(context, resolve, reject);
69368           if (d2.onClick.length <= 1) {
69369             resolve();
69370           }
69371         }).then(function() {
69372           context.validator().validate();
69373         });
69374       }).on("mouseover.highlight", function(d3_event, d2) {
69375         utilHighlightEntities(d2.entityIds, true, context);
69376       }).on("mouseout.highlight", function(d3_event, d2) {
69377         utilHighlightEntities(d2.entityIds, false, context);
69378       });
69379       buttons.each(function(d2) {
69380         var iconName = d2.icon || "iD-icon-wrench";
69381         if (iconName.startsWith("maki")) {
69382           iconName += "-15";
69383         }
69384         select_default2(this).call(svgIcon("#" + iconName, "fix-icon"));
69385       });
69386       buttons.append("span").attr("class", "fix-message").each(function(d2) {
69387         return d2.title(select_default2(this));
69388       });
69389       fixesEnter.merge(fixes).selectAll("button").classed("actionable", function(d2) {
69390         return d2.onClick;
69391       }).attr("disabled", function(d2) {
69392         return d2.onClick ? null : "true";
69393       }).attr("title", function(d2) {
69394         if (d2.disabledReason) {
69395           return d2.disabledReason;
69396         }
69397         return null;
69398       });
69399     }
69400     section.entityIDs = function(val) {
69401       if (!arguments.length)
69402         return _entityIDs;
69403       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
69404         _entityIDs = val;
69405         _activeIssueID = null;
69406         reloadIssues();
69407       }
69408       return section;
69409     };
69410     return section;
69411   }
69412
69413   // modules/ui/preset_icon.js
69414   function uiPresetIcon() {
69415     let _preset;
69416     let _geometry;
69417     function presetIcon(selection2) {
69418       selection2.each(render);
69419     }
69420     function getIcon(p2, geom) {
69421       if (p2.isFallback && p2.isFallback())
69422         return geom === "vertex" ? "" : "iD-icon-" + p2.id;
69423       if (p2.icon)
69424         return p2.icon;
69425       if (geom === "line")
69426         return "iD-other-line";
69427       if (geom === "vertex")
69428         return "temaki-vertex";
69429       return "maki-marker-stroked";
69430     }
69431     function renderPointBorder(container, drawPoint) {
69432       let pointBorder = container.selectAll(".preset-icon-point-border").data(drawPoint ? [0] : []);
69433       pointBorder.exit().remove();
69434       let pointBorderEnter = pointBorder.enter();
69435       const w2 = 40;
69436       const h2 = 40;
69437       pointBorderEnter.append("svg").attr("class", "preset-icon-fill preset-icon-point-border").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2)).append("path").attr("transform", "translate(11.5, 8)").attr("d", "M 17,8 C 17,13 11,21 8.5,23.5 C 6,21 0,13 0,8 C 0,4 4,-0.5 8.5,-0.5 C 13,-0.5 17,4 17,8 z");
69438       pointBorder = pointBorderEnter.merge(pointBorder);
69439     }
69440     function renderCategoryBorder(container, category) {
69441       let categoryBorder = container.selectAll(".preset-icon-category-border").data(category ? [0] : []);
69442       categoryBorder.exit().remove();
69443       let categoryBorderEnter = categoryBorder.enter();
69444       const d2 = 60;
69445       let svgEnter = categoryBorderEnter.append("svg").attr("class", "preset-icon-fill preset-icon-category-border").attr("width", d2).attr("height", d2).attr("viewBox", "0 0 ".concat(d2, " ").concat(d2));
69446       svgEnter.append("path").attr("class", "area").attr("d", "M9.5,7.5 L25.5,7.5 L28.5,12.5 L49.5,12.5 C51.709139,12.5 53.5,14.290861 53.5,16.5 L53.5,43.5 C53.5,45.709139 51.709139,47.5 49.5,47.5 L10.5,47.5 C8.290861,47.5 6.5,45.709139 6.5,43.5 L6.5,12.5 L9.5,7.5 Z");
69447       categoryBorder = categoryBorderEnter.merge(categoryBorder);
69448       if (category) {
69449         categoryBorder.selectAll("path").attr("class", "area ".concat(category.id));
69450       }
69451     }
69452     function renderCircleFill(container, drawVertex) {
69453       let vertexFill = container.selectAll(".preset-icon-fill-vertex").data(drawVertex ? [0] : []);
69454       vertexFill.exit().remove();
69455       let vertexFillEnter = vertexFill.enter();
69456       const w2 = 60;
69457       const h2 = 60;
69458       const d2 = 40;
69459       vertexFillEnter.append("svg").attr("class", "preset-icon-fill preset-icon-fill-vertex").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2)).append("circle").attr("cx", w2 / 2).attr("cy", h2 / 2).attr("r", d2 / 2);
69460       vertexFill = vertexFillEnter.merge(vertexFill);
69461     }
69462     function renderSquareFill(container, drawArea, tagClasses) {
69463       let fill = container.selectAll(".preset-icon-fill-area").data(drawArea ? [0] : []);
69464       fill.exit().remove();
69465       let fillEnter = fill.enter();
69466       const d2 = 60;
69467       const w2 = d2;
69468       const h2 = d2;
69469       const l2 = d2 * 2 / 3;
69470       const c1 = (w2 - l2) / 2;
69471       const c2 = c1 + l2;
69472       fillEnter = fillEnter.append("svg").attr("class", "preset-icon-fill preset-icon-fill-area").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
69473       ["fill", "stroke"].forEach((klass) => {
69474         fillEnter.append("path").attr("d", "M".concat(c1, " ").concat(c1, " L").concat(c1, " ").concat(c2, " L").concat(c2, " ").concat(c2, " L").concat(c2, " ").concat(c1, " Z")).attr("class", "area ".concat(klass));
69475       });
69476       const rVertex = 2.5;
69477       [[c1, c1], [c1, c2], [c2, c2], [c2, c1]].forEach((point2) => {
69478         fillEnter.append("circle").attr("class", "vertex").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", rVertex);
69479       });
69480       const rMidpoint = 1.25;
69481       [[c1, w2 / 2], [c2, w2 / 2], [h2 / 2, c1], [h2 / 2, c2]].forEach((point2) => {
69482         fillEnter.append("circle").attr("class", "midpoint").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", rMidpoint);
69483       });
69484       fill = fillEnter.merge(fill);
69485       fill.selectAll("path.stroke").attr("class", "area stroke ".concat(tagClasses));
69486       fill.selectAll("path.fill").attr("class", "area fill ".concat(tagClasses));
69487     }
69488     function renderLine(container, drawLine, tagClasses) {
69489       let line = container.selectAll(".preset-icon-line").data(drawLine ? [0] : []);
69490       line.exit().remove();
69491       let lineEnter = line.enter();
69492       const d2 = 60;
69493       const w2 = d2;
69494       const h2 = d2;
69495       const y2 = Math.round(d2 * 0.72);
69496       const l2 = Math.round(d2 * 0.6);
69497       const r2 = 2.5;
69498       const x12 = (w2 - l2) / 2;
69499       const x2 = x12 + l2;
69500       lineEnter = lineEnter.append("svg").attr("class", "preset-icon-line").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
69501       ["casing", "stroke"].forEach((klass) => {
69502         lineEnter.append("path").attr("d", "M".concat(x12, " ").concat(y2, " L").concat(x2, " ").concat(y2)).attr("class", "line ".concat(klass));
69503       });
69504       [[x12 - 1, y2], [x2 + 1, y2]].forEach((point2) => {
69505         lineEnter.append("circle").attr("class", "vertex").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", r2);
69506       });
69507       line = lineEnter.merge(line);
69508       line.selectAll("path.stroke").attr("class", "line stroke ".concat(tagClasses));
69509       line.selectAll("path.casing").attr("class", "line casing ".concat(tagClasses));
69510     }
69511     function renderRoute(container, drawRoute, p2) {
69512       let route = container.selectAll(".preset-icon-route").data(drawRoute ? [0] : []);
69513       route.exit().remove();
69514       let routeEnter = route.enter();
69515       const d2 = 60;
69516       const w2 = d2;
69517       const h2 = d2;
69518       const y12 = Math.round(d2 * 0.8);
69519       const y2 = Math.round(d2 * 0.68);
69520       const l2 = Math.round(d2 * 0.6);
69521       const r2 = 2;
69522       const x12 = (w2 - l2) / 2;
69523       const x2 = x12 + l2 / 3;
69524       const x3 = x2 + l2 / 3;
69525       const x4 = x3 + l2 / 3;
69526       routeEnter = routeEnter.append("svg").attr("class", "preset-icon-route").attr("width", w2).attr("height", h2).attr("viewBox", "0 0 ".concat(w2, " ").concat(h2));
69527       ["casing", "stroke"].forEach((klass) => {
69528         routeEnter.append("path").attr("d", "M".concat(x12, " ").concat(y12, " L").concat(x2, " ").concat(y2)).attr("class", "segment0 line ".concat(klass));
69529         routeEnter.append("path").attr("d", "M".concat(x2, " ").concat(y2, " L").concat(x3, " ").concat(y12)).attr("class", "segment1 line ".concat(klass));
69530         routeEnter.append("path").attr("d", "M".concat(x3, " ").concat(y12, " L").concat(x4, " ").concat(y2)).attr("class", "segment2 line ".concat(klass));
69531       });
69532       [[x12, y12], [x2, y2], [x3, y12], [x4, y2]].forEach((point2) => {
69533         routeEnter.append("circle").attr("class", "vertex").attr("cx", point2[0]).attr("cy", point2[1]).attr("r", r2);
69534       });
69535       route = routeEnter.merge(route);
69536       if (drawRoute) {
69537         let routeType = p2.tags.type === "waterway" ? "waterway" : p2.tags.route;
69538         const segmentPresetIDs = routeSegments[routeType];
69539         for (let i3 in segmentPresetIDs) {
69540           const segmentPreset = _mainPresetIndex.item(segmentPresetIDs[i3]);
69541           const segmentTagClasses = svgTagClasses().getClassesString(segmentPreset.tags, "");
69542           route.selectAll("path.stroke.segment".concat(i3)).attr("class", "segment".concat(i3, " line stroke ").concat(segmentTagClasses));
69543           route.selectAll("path.casing.segment".concat(i3)).attr("class", "segment".concat(i3, " line casing ").concat(segmentTagClasses));
69544         }
69545       }
69546     }
69547     function renderSvgIcon(container, picon, geom, isFramed, category, tagClasses) {
69548       const isMaki = picon && /^maki-/.test(picon);
69549       const isTemaki = picon && /^temaki-/.test(picon);
69550       const isFa = picon && /^fa[srb]-/.test(picon);
69551       const isR\u00F6ntgen = picon && /^roentgen-/.test(picon);
69552       const isiDIcon = picon && !(isMaki || isTemaki || isFa || isR\u00F6ntgen);
69553       let icon2 = container.selectAll(".preset-icon").data(picon ? [0] : []);
69554       icon2.exit().remove();
69555       icon2 = icon2.enter().append("div").attr("class", "preset-icon").call(svgIcon("")).merge(icon2);
69556       icon2.attr("class", "preset-icon " + (geom ? geom + "-geom" : "")).classed("category", category).classed("framed", isFramed).classed("preset-icon-iD", isiDIcon);
69557       icon2.selectAll("svg").attr("class", "icon " + picon + " " + (!isiDIcon && geom !== "line" ? "" : tagClasses));
69558       icon2.selectAll("use").attr("href", "#" + picon);
69559     }
69560     function renderImageIcon(container, imageURL) {
69561       let imageIcon = container.selectAll("img.image-icon").data(imageURL ? [0] : []);
69562       imageIcon.exit().remove();
69563       imageIcon = imageIcon.enter().append("img").attr("class", "image-icon").on("load", () => container.classed("showing-img", true)).on("error", () => container.classed("showing-img", false)).merge(imageIcon);
69564       imageIcon.attr("src", imageURL);
69565     }
69566     const routeSegments = {
69567       bicycle: ["highway/cycleway", "highway/cycleway", "highway/cycleway"],
69568       bus: ["highway/unclassified", "highway/secondary", "highway/primary"],
69569       trolleybus: ["highway/unclassified", "highway/secondary", "highway/primary"],
69570       detour: ["highway/tertiary", "highway/residential", "highway/unclassified"],
69571       ferry: ["route/ferry", "route/ferry", "route/ferry"],
69572       foot: ["highway/footway", "highway/footway", "highway/footway"],
69573       hiking: ["highway/path", "highway/path", "highway/path"],
69574       horse: ["highway/bridleway", "highway/bridleway", "highway/bridleway"],
69575       light_rail: ["railway/light_rail", "railway/light_rail", "railway/light_rail"],
69576       monorail: ["railway/monorail", "railway/monorail", "railway/monorail"],
69577       mtb: ["highway/path", "highway/track", "highway/bridleway"],
69578       pipeline: ["man_made/pipeline", "man_made/pipeline", "man_made/pipeline"],
69579       piste: ["piste/downhill", "piste/hike", "piste/nordic"],
69580       power: ["power/line", "power/line", "power/line"],
69581       road: ["highway/secondary", "highway/primary", "highway/trunk"],
69582       subway: ["railway/subway", "railway/subway", "railway/subway"],
69583       train: ["railway/rail", "railway/rail", "railway/rail"],
69584       tram: ["railway/tram", "railway/tram", "railway/tram"],
69585       railway: ["railway/rail", "railway/rail", "railway/rail"],
69586       waterway: ["waterway/stream", "waterway/stream", "waterway/stream"]
69587     };
69588     function render() {
69589       let p2 = _preset.apply(this, arguments);
69590       let geom = _geometry ? _geometry.apply(this, arguments) : null;
69591       if (geom === "relation" && p2.tags && (p2.tags.type === "route" && p2.tags.route && routeSegments[p2.tags.route] || p2.tags.type === "waterway")) {
69592         geom = "route";
69593       }
69594       const showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
69595       const isFallback = p2.isFallback && p2.isFallback();
69596       const imageURL = showThirdPartyIcons === "true" && p2.imageURL;
69597       const picon = getIcon(p2, geom);
69598       const isCategory = !p2.setTags;
69599       const drawPoint = false;
69600       const drawVertex = picon !== null && geom === "vertex";
69601       const drawLine = picon && geom === "line" && !isFallback && !isCategory;
69602       const drawArea = picon && geom === "area" && !isFallback && !isCategory;
69603       const drawRoute = picon && geom === "route";
69604       const isFramed = drawVertex || drawArea || drawLine || drawRoute || isCategory;
69605       let tags = !isCategory ? p2.setTags({}, geom) : {};
69606       for (let k2 in tags) {
69607         if (tags[k2] === "*") {
69608           tags[k2] = "yes";
69609         }
69610       }
69611       let tagClasses = svgTagClasses().getClassesString(tags, "");
69612       let selection2 = select_default2(this);
69613       let container = selection2.selectAll(".preset-icon-container").data([0]);
69614       container = container.enter().append("div").attr("class", "preset-icon-container").merge(container);
69615       container.classed("showing-img", !!imageURL).classed("fallback", isFallback);
69616       renderCategoryBorder(container, isCategory && p2);
69617       renderPointBorder(container, drawPoint);
69618       renderCircleFill(container, drawVertex);
69619       renderSquareFill(container, drawArea, tagClasses);
69620       renderLine(container, drawLine, tagClasses);
69621       renderRoute(container, drawRoute, p2);
69622       renderSvgIcon(container, picon, geom, isFramed, isCategory, tagClasses);
69623       renderImageIcon(container, imageURL);
69624     }
69625     presetIcon.preset = function(val) {
69626       if (!arguments.length)
69627         return _preset;
69628       _preset = utilFunctor(val);
69629       return presetIcon;
69630     };
69631     presetIcon.geometry = function(val) {
69632       if (!arguments.length)
69633         return _geometry;
69634       _geometry = utilFunctor(val);
69635       return presetIcon;
69636     };
69637     return presetIcon;
69638   }
69639
69640   // modules/ui/sections/feature_type.js
69641   function uiSectionFeatureType(context) {
69642     var dispatch14 = dispatch_default("choose");
69643     var _entityIDs = [];
69644     var _presets = [];
69645     var _tagReference;
69646     var section = uiSection("feature-type", context).label(() => _t.append("inspector.feature_type")).disclosureContent(renderDisclosureContent);
69647     function renderDisclosureContent(selection2) {
69648       selection2.classed("preset-list-item", true);
69649       selection2.classed("mixed-types", _presets.length > 1);
69650       var presetButtonWrap = selection2.selectAll(".preset-list-button-wrap").data([0]).enter().append("div").attr("class", "preset-list-button-wrap");
69651       var presetButton = presetButtonWrap.append("button").attr("class", "preset-list-button preset-reset").call(
69652         uiTooltip().title(() => _t.append("inspector.back_tooltip")).placement("bottom")
69653       );
69654       presetButton.append("div").attr("class", "preset-icon-container");
69655       presetButton.append("div").attr("class", "label").append("div").attr("class", "label-inner");
69656       presetButtonWrap.append("div").attr("class", "accessory-buttons");
69657       var tagReferenceBodyWrap = selection2.selectAll(".tag-reference-body-wrap").data([0]);
69658       tagReferenceBodyWrap = tagReferenceBodyWrap.enter().append("div").attr("class", "tag-reference-body-wrap").merge(tagReferenceBodyWrap);
69659       if (_tagReference) {
69660         selection2.selectAll(".preset-list-button-wrap .accessory-buttons").style("display", _presets.length === 1 ? null : "none").call(_tagReference.button);
69661         tagReferenceBodyWrap.style("display", _presets.length === 1 ? null : "none").call(_tagReference.body);
69662       }
69663       selection2.selectAll(".preset-reset").on("click", function() {
69664         dispatch14.call("choose", this, _presets);
69665       }).on("pointerdown pointerup mousedown mouseup", function(d3_event) {
69666         d3_event.preventDefault();
69667         d3_event.stopPropagation();
69668       });
69669       var geometries = entityGeometries();
69670       selection2.select(".preset-list-item button").call(
69671         uiPresetIcon().geometry(_presets.length === 1 ? geometries.length === 1 && geometries[0] : null).preset(_presets.length === 1 ? _presets[0] : _mainPresetIndex.item("point"))
69672       );
69673       var names = _presets.length === 1 ? [
69674         _presets[0].nameLabel(),
69675         _presets[0].subtitleLabel()
69676       ].filter(Boolean) : [_t.append("inspector.multiple_types")];
69677       var label = selection2.select(".label-inner");
69678       var nameparts = label.selectAll(".namepart").data(names, (d2) => d2.stringId);
69679       nameparts.exit().remove();
69680       nameparts.enter().append("div").attr("class", "namepart").text("").each(function(d2) {
69681         d2(select_default2(this));
69682       });
69683     }
69684     section.entityIDs = function(val) {
69685       if (!arguments.length)
69686         return _entityIDs;
69687       _entityIDs = val;
69688       return section;
69689     };
69690     section.presets = function(val) {
69691       if (!arguments.length)
69692         return _presets;
69693       if (!utilArrayIdentical(val, _presets)) {
69694         _presets = val;
69695         if (_presets.length === 1) {
69696           _tagReference = uiTagReference(_presets[0].reference(), context).showing(false);
69697         }
69698       }
69699       return section;
69700     };
69701     function entityGeometries() {
69702       var counts = {};
69703       for (var i3 in _entityIDs) {
69704         var geometry = context.graph().geometry(_entityIDs[i3]);
69705         if (!counts[geometry])
69706           counts[geometry] = 0;
69707         counts[geometry] += 1;
69708       }
69709       return Object.keys(counts).sort(function(geom1, geom2) {
69710         return counts[geom2] - counts[geom1];
69711       });
69712     }
69713     return utilRebind(section, dispatch14, "on");
69714   }
69715
69716   // modules/ui/sections/preset_fields.js
69717   function uiSectionPresetFields(context) {
69718     var section = uiSection("preset-fields", context).label(() => _t.append("inspector.fields")).disclosureContent(renderDisclosureContent);
69719     var dispatch14 = dispatch_default("change", "revert");
69720     var formFields = uiFormFields(context);
69721     var _state;
69722     var _fieldsArr;
69723     var _presets = [];
69724     var _tags;
69725     var _entityIDs;
69726     function renderDisclosureContent(selection2) {
69727       if (!_fieldsArr) {
69728         var graph = context.graph();
69729         var geometries = Object.keys(_entityIDs.reduce(function(geoms, entityID) {
69730           geoms[graph.entity(entityID).geometry(graph)] = true;
69731           return geoms;
69732         }, {}));
69733         const loc = _entityIDs.reduce(function(extent, entityID) {
69734           var entity = context.graph().entity(entityID);
69735           return extent.extend(entity.extent(context.graph()));
69736         }, geoExtent()).center();
69737         var presetsManager = _mainPresetIndex;
69738         var allFields = [];
69739         var allMoreFields = [];
69740         var sharedTotalFields;
69741         _presets.forEach(function(preset) {
69742           var fields = preset.fields(loc);
69743           var moreFields = preset.moreFields(loc);
69744           allFields = utilArrayUnion(allFields, fields);
69745           allMoreFields = utilArrayUnion(allMoreFields, moreFields);
69746           if (!sharedTotalFields) {
69747             sharedTotalFields = utilArrayUnion(fields, moreFields);
69748           } else {
69749             sharedTotalFields = sharedTotalFields.filter(function(field) {
69750               return fields.indexOf(field) !== -1 || moreFields.indexOf(field) !== -1;
69751             });
69752           }
69753         });
69754         var sharedFields = allFields.filter(function(field) {
69755           return sharedTotalFields.indexOf(field) !== -1;
69756         });
69757         var sharedMoreFields = allMoreFields.filter(function(field) {
69758           return sharedTotalFields.indexOf(field) !== -1;
69759         });
69760         _fieldsArr = [];
69761         sharedFields.forEach(function(field) {
69762           if (field.matchAllGeometry(geometries)) {
69763             _fieldsArr.push(
69764               uiField(context, field, _entityIDs)
69765             );
69766           }
69767         });
69768         var singularEntity = _entityIDs.length === 1 && graph.hasEntity(_entityIDs[0]);
69769         if (singularEntity && singularEntity.isHighwayIntersection(graph) && presetsManager.field("restrictions")) {
69770           _fieldsArr.push(
69771             uiField(context, presetsManager.field("restrictions"), _entityIDs)
69772           );
69773         }
69774         var additionalFields = utilArrayUnion(sharedMoreFields, presetsManager.universal());
69775         additionalFields.sort(function(field1, field2) {
69776           return field1.title().localeCompare(field2.title(), _mainLocalizer.localeCode());
69777         });
69778         additionalFields.forEach(function(field) {
69779           if (sharedFields.indexOf(field) === -1 && field.matchAllGeometry(geometries)) {
69780             _fieldsArr.push(
69781               uiField(context, field, _entityIDs, { show: false })
69782             );
69783           }
69784         });
69785         _fieldsArr.forEach(function(field) {
69786           field.on("change", function(t2, onInput) {
69787             dispatch14.call("change", field, _entityIDs, t2, onInput);
69788           }).on("revert", function(keys2) {
69789             dispatch14.call("revert", field, keys2);
69790           });
69791         });
69792       }
69793       _fieldsArr.forEach(function(field) {
69794         field.state(_state).tags(_tags);
69795       });
69796       selection2.call(
69797         formFields.fieldsArr(_fieldsArr).state(_state).klass("grouped-items-area")
69798       );
69799     }
69800     section.presets = function(val) {
69801       if (!arguments.length)
69802         return _presets;
69803       if (!_presets || !val || !utilArrayIdentical(_presets, val)) {
69804         _presets = val;
69805         _fieldsArr = null;
69806       }
69807       return section;
69808     };
69809     section.state = function(val) {
69810       if (!arguments.length)
69811         return _state;
69812       _state = val;
69813       return section;
69814     };
69815     section.tags = function(val) {
69816       if (!arguments.length)
69817         return _tags;
69818       _tags = val;
69819       return section;
69820     };
69821     section.entityIDs = function(val) {
69822       if (!arguments.length)
69823         return _entityIDs;
69824       if (!val || !_entityIDs || !utilArrayIdentical(_entityIDs, val)) {
69825         _entityIDs = val;
69826         _fieldsArr = null;
69827       }
69828       return section;
69829     };
69830     return utilRebind(section, dispatch14, "on");
69831   }
69832
69833   // modules/ui/sections/raw_member_editor.js
69834   function uiSectionRawMemberEditor(context) {
69835     var section = uiSection("raw-member-editor", context).shouldDisplay(function() {
69836       if (!_entityIDs || _entityIDs.length !== 1)
69837         return false;
69838       var entity = context.hasEntity(_entityIDs[0]);
69839       return entity && entity.type === "relation";
69840     }).label(function() {
69841       var entity = context.hasEntity(_entityIDs[0]);
69842       if (!entity)
69843         return "";
69844       var gt2 = entity.members.length > _maxMembers ? ">" : "";
69845       var count = gt2 + entity.members.slice(0, _maxMembers).length;
69846       return _t.append("inspector.title_count", { title: _t("inspector.members"), count });
69847     }).disclosureContent(renderDisclosureContent);
69848     var taginfo = services.taginfo;
69849     var _entityIDs;
69850     var _maxMembers = 1e3;
69851     function downloadMember(d3_event, d2) {
69852       d3_event.preventDefault();
69853       select_default2(this.parentNode).classed("tag-reference-loading", true);
69854       context.loadEntity(d2.id, function() {
69855         section.reRender();
69856       });
69857     }
69858     function zoomToMember(d3_event, d2) {
69859       d3_event.preventDefault();
69860       var entity = context.entity(d2.id);
69861       context.map().zoomToEase(entity);
69862       utilHighlightEntities([d2.id], true, context);
69863     }
69864     function selectMember(d3_event, d2) {
69865       d3_event.preventDefault();
69866       utilHighlightEntities([d2.id], false, context);
69867       var entity = context.entity(d2.id);
69868       var mapExtent = context.map().extent();
69869       if (!entity.intersects(mapExtent, context.graph())) {
69870         context.map().zoomToEase(entity);
69871       }
69872       context.enter(modeSelect(context, [d2.id]));
69873     }
69874     function changeRole(d3_event, d2) {
69875       var oldRole = d2.role;
69876       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
69877       if (oldRole !== newRole) {
69878         var member = { id: d2.id, type: d2.type, role: newRole };
69879         context.perform(
69880           actionChangeMember(d2.relation.id, member, d2.index),
69881           _t("operations.change_role.annotation", {
69882             n: 1
69883           })
69884         );
69885         context.validator().validate();
69886       }
69887     }
69888     function deleteMember(d3_event, d2) {
69889       utilHighlightEntities([d2.id], false, context);
69890       context.perform(
69891         actionDeleteMember(d2.relation.id, d2.index),
69892         _t("operations.delete_member.annotation", {
69893           n: 1
69894         })
69895       );
69896       if (!context.hasEntity(d2.relation.id)) {
69897         context.enter(modeBrowse(context));
69898       } else {
69899         context.validator().validate();
69900       }
69901     }
69902     function renderDisclosureContent(selection2) {
69903       var entityID = _entityIDs[0];
69904       var memberships = [];
69905       var entity = context.entity(entityID);
69906       entity.members.slice(0, _maxMembers).forEach(function(member, index) {
69907         memberships.push({
69908           index,
69909           id: member.id,
69910           type: member.type,
69911           role: member.role,
69912           relation: entity,
69913           member: context.hasEntity(member.id),
69914           domId: utilUniqueDomId(entityID + "-member-" + index)
69915         });
69916       });
69917       var list2 = selection2.selectAll(".member-list").data([0]);
69918       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
69919       var items = list2.selectAll("li").data(memberships, function(d2) {
69920         return osmEntity.key(d2.relation) + "," + d2.index + "," + (d2.member ? osmEntity.key(d2.member) : "incomplete");
69921       });
69922       items.exit().each(unbind).remove();
69923       var itemsEnter = items.enter().append("li").attr("class", "member-row form-field").classed("member-incomplete", function(d2) {
69924         return !d2.member;
69925       });
69926       itemsEnter.each(function(d2) {
69927         var item = select_default2(this);
69928         var label = item.append("label").attr("class", "field-label").attr("for", d2.domId);
69929         if (d2.member) {
69930           item.on("mouseover", function() {
69931             utilHighlightEntities([d2.id], true, context);
69932           }).on("mouseout", function() {
69933             utilHighlightEntities([d2.id], false, context);
69934           });
69935           var labelLink = label.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectMember);
69936           labelLink.append("span").attr("class", "member-entity-type").text(function(d4) {
69937             var matched = _mainPresetIndex.match(d4.member, context.graph());
69938             return matched && matched.name() || utilDisplayType(d4.member.id);
69939           });
69940           labelLink.append("span").attr("class", "member-entity-name").classed("has-colour", (d4) => d4.member.type === "relation" && d4.member.tags.colour && isColourValid(d4.member.tags.colour)).style("border-color", (d4) => d4.member.type === "relation" && d4.member.tags.colour).text(function(d4) {
69941             return utilDisplayName(d4.member);
69942           });
69943           label.append("button").attr("title", _t("icons.remove")).attr("class", "remove member-delete").call(svgIcon("#iD-operation-delete"));
69944           label.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToMember);
69945         } else {
69946           var labelText = label.append("span").attr("class", "label-text");
69947           labelText.append("span").attr("class", "member-entity-type").call(_t.append("inspector." + d2.type, { id: d2.id }));
69948           labelText.append("span").attr("class", "member-entity-name").call(_t.append("inspector.incomplete", { id: d2.id }));
69949           label.append("button").attr("class", "member-download").attr("title", _t("icons.download")).call(svgIcon("#iD-icon-load")).on("click", downloadMember);
69950         }
69951       });
69952       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
69953       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
69954         return d2.domId;
69955       }).property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
69956       if (taginfo) {
69957         wrapEnter.each(bindTypeahead);
69958       }
69959       items = items.merge(itemsEnter).order();
69960       items.select("input.member-role").property("value", function(d2) {
69961         return d2.role;
69962       }).on("blur", changeRole).on("change", changeRole);
69963       items.select("button.member-delete").on("click", deleteMember);
69964       var dragOrigin, targetIndex;
69965       items.call(
69966         drag_default().on("start", function(d3_event) {
69967           dragOrigin = {
69968             x: d3_event.x,
69969             y: d3_event.y
69970           };
69971           targetIndex = null;
69972         }).on("drag", function(d3_event) {
69973           var x2 = d3_event.x - dragOrigin.x, y2 = d3_event.y - dragOrigin.y;
69974           if (!select_default2(this).classed("dragging") && // don't display drag until dragging beyond a distance threshold
69975           Math.sqrt(Math.pow(x2, 2) + Math.pow(y2, 2)) <= 5)
69976             return;
69977           var index = items.nodes().indexOf(this);
69978           select_default2(this).classed("dragging", true);
69979           targetIndex = null;
69980           selection2.selectAll("li.member-row").style("transform", function(d2, index2) {
69981             var node = select_default2(this).node();
69982             if (index === index2) {
69983               return "translate(" + x2 + "px, " + y2 + "px)";
69984             } else if (index2 > index && d3_event.y > node.offsetTop) {
69985               if (targetIndex === null || index2 > targetIndex) {
69986                 targetIndex = index2;
69987               }
69988               return "translateY(-100%)";
69989             } else if (index2 < index && d3_event.y < node.offsetTop + node.offsetHeight) {
69990               if (targetIndex === null || index2 < targetIndex) {
69991                 targetIndex = index2;
69992               }
69993               return "translateY(100%)";
69994             }
69995             return null;
69996           });
69997         }).on("end", function(d3_event, d2) {
69998           if (!select_default2(this).classed("dragging"))
69999             return;
70000           var index = items.nodes().indexOf(this);
70001           select_default2(this).classed("dragging", false);
70002           selection2.selectAll("li.member-row").style("transform", null);
70003           if (targetIndex !== null) {
70004             context.perform(
70005               actionMoveMember(d2.relation.id, index, targetIndex),
70006               _t("operations.reorder_members.annotation")
70007             );
70008             context.validator().validate();
70009           }
70010         })
70011       );
70012       function bindTypeahead(d2) {
70013         var row = select_default2(this);
70014         var role = row.selectAll("input.member-role");
70015         var origValue = role.property("value");
70016         function sort(value, data) {
70017           var sameletter = [];
70018           var other = [];
70019           for (var i3 = 0; i3 < data.length; i3++) {
70020             if (data[i3].value.substring(0, value.length) === value) {
70021               sameletter.push(data[i3]);
70022             } else {
70023               other.push(data[i3]);
70024             }
70025           }
70026           return sameletter.concat(other);
70027         }
70028         role.call(
70029           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
70030             var geometry;
70031             if (d2.member) {
70032               geometry = context.graph().geometry(d2.member.id);
70033             } else if (d2.type === "relation") {
70034               geometry = "relation";
70035             } else if (d2.type === "way") {
70036               geometry = "line";
70037             } else {
70038               geometry = "point";
70039             }
70040             var rtype = entity.tags.type;
70041             taginfo.roles({
70042               debounce: true,
70043               rtype: rtype || "",
70044               geometry,
70045               query: role2
70046             }, function(err, data) {
70047               if (!err)
70048                 callback(sort(role2, data));
70049             });
70050           }).on("cancel", function() {
70051             role.property("value", origValue);
70052           })
70053         );
70054       }
70055       function unbind() {
70056         var row = select_default2(this);
70057         row.selectAll("input.member-role").call(uiCombobox.off, context);
70058       }
70059     }
70060     section.entityIDs = function(val) {
70061       if (!arguments.length)
70062         return _entityIDs;
70063       _entityIDs = val;
70064       return section;
70065     };
70066     return section;
70067   }
70068
70069   // modules/actions/delete_members.js
70070   function actionDeleteMembers(relationId, memberIndexes) {
70071     return function(graph) {
70072       memberIndexes.sort((a2, b2) => b2 - a2);
70073       for (var i3 in memberIndexes) {
70074         graph = actionDeleteMember(relationId, memberIndexes[i3])(graph);
70075       }
70076       return graph;
70077     };
70078   }
70079
70080   // modules/ui/sections/raw_membership_editor.js
70081   function uiSectionRawMembershipEditor(context) {
70082     var section = uiSection("raw-membership-editor", context).shouldDisplay(function() {
70083       return _entityIDs && _entityIDs.length;
70084     }).label(function() {
70085       var parents = getSharedParentRelations();
70086       var gt2 = parents.length > _maxMemberships ? ">" : "";
70087       var count = gt2 + parents.slice(0, _maxMemberships).length;
70088       return _t.append("inspector.title_count", { title: _t("inspector.relations"), count });
70089     }).disclosureContent(renderDisclosureContent);
70090     var taginfo = services.taginfo;
70091     var nearbyCombo = uiCombobox(context, "parent-relation").minItems(1).fetcher(fetchNearbyRelations).itemsMouseEnter(function(d3_event, d2) {
70092       if (d2.relation)
70093         utilHighlightEntities([d2.relation.id], true, context);
70094     }).itemsMouseLeave(function(d3_event, d2) {
70095       if (d2.relation)
70096         utilHighlightEntities([d2.relation.id], false, context);
70097     });
70098     var _inChange = false;
70099     var _entityIDs = [];
70100     var _showBlank;
70101     var _maxMemberships = 1e3;
70102     function getSharedParentRelations() {
70103       var parents = [];
70104       for (var i3 = 0; i3 < _entityIDs.length; i3++) {
70105         var entity = context.graph().hasEntity(_entityIDs[i3]);
70106         if (!entity)
70107           continue;
70108         if (i3 === 0) {
70109           parents = context.graph().parentRelations(entity);
70110         } else {
70111           parents = utilArrayIntersection(parents, context.graph().parentRelations(entity));
70112         }
70113         if (!parents.length)
70114           break;
70115       }
70116       return parents;
70117     }
70118     function getMemberships() {
70119       var memberships = [];
70120       var relations = getSharedParentRelations().slice(0, _maxMemberships);
70121       var isMultiselect = _entityIDs.length > 1;
70122       var i3, relation, membership, index, member, indexedMember;
70123       for (i3 = 0; i3 < relations.length; i3++) {
70124         relation = relations[i3];
70125         membership = {
70126           relation,
70127           members: [],
70128           hash: osmEntity.key(relation)
70129         };
70130         for (index = 0; index < relation.members.length; index++) {
70131           member = relation.members[index];
70132           if (_entityIDs.indexOf(member.id) !== -1) {
70133             indexedMember = Object.assign({}, member, { index });
70134             membership.members.push(indexedMember);
70135             membership.hash += "," + index.toString();
70136             if (!isMultiselect) {
70137               memberships.push(membership);
70138               membership = {
70139                 relation,
70140                 members: [],
70141                 hash: osmEntity.key(relation)
70142               };
70143             }
70144           }
70145         }
70146         if (membership.members.length)
70147           memberships.push(membership);
70148       }
70149       memberships.forEach(function(membership2) {
70150         membership2.domId = utilUniqueDomId("membership-" + membership2.relation.id);
70151         var roles = [];
70152         membership2.members.forEach(function(member2) {
70153           if (roles.indexOf(member2.role) === -1)
70154             roles.push(member2.role);
70155         });
70156         membership2.role = roles.length === 1 ? roles[0] : roles;
70157       });
70158       return memberships;
70159     }
70160     function selectRelation(d3_event, d2) {
70161       d3_event.preventDefault();
70162       utilHighlightEntities([d2.relation.id], false, context);
70163       context.enter(modeSelect(context, [d2.relation.id]));
70164     }
70165     function zoomToRelation(d3_event, d2) {
70166       d3_event.preventDefault();
70167       var entity = context.entity(d2.relation.id);
70168       context.map().zoomToEase(entity);
70169       utilHighlightEntities([d2.relation.id], true, context);
70170     }
70171     function changeRole(d3_event, d2) {
70172       if (d2 === 0)
70173         return;
70174       if (_inChange)
70175         return;
70176       var newRole = context.cleanRelationRole(select_default2(this).property("value"));
70177       if (!newRole.trim() && typeof d2.role !== "string")
70178         return;
70179       var membersToUpdate = d2.members.filter(function(member) {
70180         return member.role !== newRole;
70181       });
70182       if (membersToUpdate.length) {
70183         _inChange = true;
70184         context.perform(
70185           function actionChangeMemberRoles(graph) {
70186             membersToUpdate.forEach(function(member) {
70187               var newMember = Object.assign({}, member, { role: newRole });
70188               delete newMember.index;
70189               graph = actionChangeMember(d2.relation.id, newMember, member.index)(graph);
70190             });
70191             return graph;
70192           },
70193           _t("operations.change_role.annotation", {
70194             n: membersToUpdate.length
70195           })
70196         );
70197         context.validator().validate();
70198       }
70199       _inChange = false;
70200     }
70201     function addMembership(d2, role) {
70202       this.blur();
70203       _showBlank = false;
70204       function actionAddMembers(relationId, ids, role2) {
70205         return function(graph) {
70206           for (var i3 in ids) {
70207             var member = { id: ids[i3], type: graph.entity(ids[i3]).type, role: role2 };
70208             graph = actionAddMember(relationId, member)(graph);
70209           }
70210           return graph;
70211         };
70212       }
70213       if (d2.relation) {
70214         context.perform(
70215           actionAddMembers(d2.relation.id, _entityIDs, role),
70216           _t("operations.add_member.annotation", {
70217             n: _entityIDs.length
70218           })
70219         );
70220         context.validator().validate();
70221       } else {
70222         var relation = osmRelation();
70223         context.perform(
70224           actionAddEntity(relation),
70225           actionAddMembers(relation.id, _entityIDs, role),
70226           _t("operations.add.annotation.relation")
70227         );
70228         context.enter(modeSelect(context, [relation.id]).newFeature(true));
70229       }
70230     }
70231     function deleteMembership(d3_event, d2) {
70232       this.blur();
70233       if (d2 === 0)
70234         return;
70235       utilHighlightEntities([d2.relation.id], false, context);
70236       var indexes = d2.members.map(function(member) {
70237         return member.index;
70238       });
70239       context.perform(
70240         actionDeleteMembers(d2.relation.id, indexes),
70241         _t("operations.delete_member.annotation", {
70242           n: _entityIDs.length
70243         })
70244       );
70245       context.validator().validate();
70246     }
70247     function fetchNearbyRelations(q2, callback) {
70248       var newRelation = {
70249         relation: null,
70250         value: _t("inspector.new_relation"),
70251         display: _t.append("inspector.new_relation")
70252       };
70253       var entityID = _entityIDs[0];
70254       var result = [];
70255       var graph = context.graph();
70256       function baseDisplayValue(entity) {
70257         var matched = _mainPresetIndex.match(entity, graph);
70258         var presetName = matched && matched.name() || _t("inspector.relation");
70259         var entityName = utilDisplayName(entity) || "";
70260         return presetName + " " + entityName;
70261       }
70262       function baseDisplayLabel(entity) {
70263         var matched = _mainPresetIndex.match(entity, graph);
70264         var presetName = matched && matched.name() || _t("inspector.relation");
70265         var entityName = utilDisplayName(entity) || "";
70266         return (selection2) => {
70267           selection2.append("b").text(presetName + " ");
70268           selection2.append("span").classed("has-colour", entity.tags.colour && isColourValid(entity.tags.colour)).style("border-color", entity.tags.colour).text(entityName);
70269         };
70270       }
70271       var explicitRelation = q2 && context.hasEntity(q2.toLowerCase());
70272       if (explicitRelation && explicitRelation.type === "relation" && explicitRelation.id !== entityID) {
70273         result.push({
70274           relation: explicitRelation,
70275           value: baseDisplayValue(explicitRelation) + " " + explicitRelation.id,
70276           display: baseDisplayLabel(explicitRelation)
70277         });
70278       } else {
70279         context.history().intersects(context.map().extent()).forEach(function(entity) {
70280           if (entity.type !== "relation" || entity.id === entityID)
70281             return;
70282           var value = baseDisplayValue(entity);
70283           if (q2 && (value + " " + entity.id).toLowerCase().indexOf(q2.toLowerCase()) === -1)
70284             return;
70285           result.push({
70286             relation: entity,
70287             value,
70288             display: baseDisplayLabel(entity)
70289           });
70290         });
70291         result.sort(function(a2, b2) {
70292           return osmRelation.creationOrder(a2.relation, b2.relation);
70293         });
70294         var dupeGroups = Object.values(utilArrayGroupBy(result, "value")).filter(function(v2) {
70295           return v2.length > 1;
70296         });
70297         dupeGroups.forEach(function(group) {
70298           group.forEach(function(obj) {
70299             obj.value += " " + obj.relation.id;
70300           });
70301         });
70302       }
70303       result.forEach(function(obj) {
70304         obj.title = obj.value;
70305       });
70306       result.unshift(newRelation);
70307       callback(result);
70308     }
70309     function renderDisclosureContent(selection2) {
70310       var memberships = getMemberships();
70311       var list2 = selection2.selectAll(".member-list").data([0]);
70312       list2 = list2.enter().append("ul").attr("class", "member-list").merge(list2);
70313       var items = list2.selectAll("li.member-row-normal").data(memberships, function(d2) {
70314         return d2.hash;
70315       });
70316       items.exit().each(unbind).remove();
70317       var itemsEnter = items.enter().append("li").attr("class", "member-row member-row-normal form-field");
70318       itemsEnter.on("mouseover", function(d3_event, d2) {
70319         utilHighlightEntities([d2.relation.id], true, context);
70320       }).on("mouseout", function(d3_event, d2) {
70321         utilHighlightEntities([d2.relation.id], false, context);
70322       });
70323       var labelEnter = itemsEnter.append("label").attr("class", "field-label").attr("for", function(d2) {
70324         return d2.domId;
70325       });
70326       var labelLink = labelEnter.append("span").attr("class", "label-text").append("a").attr("href", "#").on("click", selectRelation);
70327       labelLink.append("span").attr("class", "member-entity-type").text(function(d2) {
70328         var matched = _mainPresetIndex.match(d2.relation, context.graph());
70329         return matched && matched.name() || _t.html("inspector.relation");
70330       });
70331       labelLink.append("span").attr("class", "member-entity-name").classed("has-colour", (d2) => d2.relation.tags.colour && isColourValid(d2.relation.tags.colour)).style("border-color", (d2) => d2.relation.tags.colour).text(function(d2) {
70332         return utilDisplayName(d2.relation);
70333       });
70334       labelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", deleteMembership);
70335       labelEnter.append("button").attr("class", "member-zoom").attr("title", _t("icons.zoom_to")).call(svgIcon("#iD-icon-framed-dot", "monochrome")).on("click", zoomToRelation);
70336       var wrapEnter = itemsEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
70337       wrapEnter.append("input").attr("class", "member-role").attr("id", function(d2) {
70338         return d2.domId;
70339       }).property("type", "text").property("value", function(d2) {
70340         return typeof d2.role === "string" ? d2.role : "";
70341       }).attr("title", function(d2) {
70342         return Array.isArray(d2.role) ? d2.role.filter(Boolean).join("\n") : d2.role;
70343       }).attr("placeholder", function(d2) {
70344         return Array.isArray(d2.role) ? _t("inspector.multiple_roles") : _t("inspector.role");
70345       }).classed("mixed", function(d2) {
70346         return Array.isArray(d2.role);
70347       }).call(utilNoAuto).on("blur", changeRole).on("change", changeRole);
70348       if (taginfo) {
70349         wrapEnter.each(bindTypeahead);
70350       }
70351       var newMembership = list2.selectAll(".member-row-new").data(_showBlank ? [0] : []);
70352       newMembership.exit().remove();
70353       var newMembershipEnter = newMembership.enter().append("li").attr("class", "member-row member-row-new form-field");
70354       var newLabelEnter = newMembershipEnter.append("label").attr("class", "field-label");
70355       newLabelEnter.append("input").attr("placeholder", _t("inspector.choose_relation")).attr("type", "text").attr("class", "member-entity-input").call(utilNoAuto);
70356       newLabelEnter.append("button").attr("class", "remove member-delete").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete")).on("click", function() {
70357         list2.selectAll(".member-row-new").remove();
70358       });
70359       var newWrapEnter = newMembershipEnter.append("div").attr("class", "form-field-input-wrap form-field-input-member");
70360       newWrapEnter.append("input").attr("class", "member-role").property("type", "text").attr("placeholder", _t("inspector.role")).call(utilNoAuto);
70361       newMembership = newMembership.merge(newMembershipEnter);
70362       newMembership.selectAll(".member-entity-input").on("blur", cancelEntity).call(
70363         nearbyCombo.on("accept", acceptEntity).on("cancel", cancelEntity)
70364       );
70365       var addRow = selection2.selectAll(".add-row").data([0]);
70366       var addRowEnter = addRow.enter().append("div").attr("class", "add-row");
70367       var addRelationButton = addRowEnter.append("button").attr("class", "add-relation").attr("aria-label", _t("inspector.add_to_relation"));
70368       addRelationButton.call(svgIcon("#iD-icon-plus", "light"));
70369       addRelationButton.call(uiTooltip().title(() => _t.append("inspector.add_to_relation")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left"));
70370       addRowEnter.append("div").attr("class", "space-value");
70371       addRowEnter.append("div").attr("class", "space-buttons");
70372       addRow = addRow.merge(addRowEnter);
70373       addRow.select(".add-relation").on("click", function() {
70374         _showBlank = true;
70375         section.reRender();
70376         list2.selectAll(".member-entity-input").node().focus();
70377       });
70378       function acceptEntity(d2) {
70379         if (!d2) {
70380           cancelEntity();
70381           return;
70382         }
70383         if (d2.relation)
70384           utilHighlightEntities([d2.relation.id], false, context);
70385         var role = context.cleanRelationRole(list2.selectAll(".member-row-new .member-role").property("value"));
70386         addMembership(d2, role);
70387       }
70388       function cancelEntity() {
70389         var input = newMembership.selectAll(".member-entity-input");
70390         input.property("value", "");
70391         context.surface().selectAll(".highlighted").classed("highlighted", false);
70392       }
70393       function bindTypeahead(d2) {
70394         var row = select_default2(this);
70395         var role = row.selectAll("input.member-role");
70396         var origValue = role.property("value");
70397         function sort(value, data) {
70398           var sameletter = [];
70399           var other = [];
70400           for (var i3 = 0; i3 < data.length; i3++) {
70401             if (data[i3].value.substring(0, value.length) === value) {
70402               sameletter.push(data[i3]);
70403             } else {
70404               other.push(data[i3]);
70405             }
70406           }
70407           return sameletter.concat(other);
70408         }
70409         role.call(
70410           uiCombobox(context, "member-role").fetcher(function(role2, callback) {
70411             var rtype = d2.relation.tags.type;
70412             taginfo.roles({
70413               debounce: true,
70414               rtype: rtype || "",
70415               geometry: context.graph().geometry(_entityIDs[0]),
70416               query: role2
70417             }, function(err, data) {
70418               if (!err)
70419                 callback(sort(role2, data));
70420             });
70421           }).on("cancel", function() {
70422             role.property("value", origValue);
70423           })
70424         );
70425       }
70426       function unbind() {
70427         var row = select_default2(this);
70428         row.selectAll("input.member-role").call(uiCombobox.off, context);
70429       }
70430     }
70431     section.entityIDs = function(val) {
70432       if (!arguments.length)
70433         return _entityIDs;
70434       _entityIDs = val;
70435       _showBlank = false;
70436       return section;
70437     };
70438     return section;
70439   }
70440
70441   // modules/ui/sections/selection_list.js
70442   function uiSectionSelectionList(context) {
70443     var _selectedIDs = [];
70444     var section = uiSection("selected-features", context).shouldDisplay(function() {
70445       return _selectedIDs.length > 1;
70446     }).label(function() {
70447       return _t.append("inspector.title_count", { title: _t("inspector.features"), count: _selectedIDs.length });
70448     }).disclosureContent(renderDisclosureContent);
70449     context.history().on("change.selectionList", function(difference2) {
70450       if (difference2) {
70451         section.reRender();
70452       }
70453     });
70454     section.entityIDs = function(val) {
70455       if (!arguments.length)
70456         return _selectedIDs;
70457       _selectedIDs = val;
70458       return section;
70459     };
70460     function selectEntity(d3_event, entity) {
70461       context.enter(modeSelect(context, [entity.id]));
70462     }
70463     function deselectEntity(d3_event, entity) {
70464       var selectedIDs = _selectedIDs.slice();
70465       var index = selectedIDs.indexOf(entity.id);
70466       if (index > -1) {
70467         selectedIDs.splice(index, 1);
70468         context.enter(modeSelect(context, selectedIDs));
70469       }
70470     }
70471     function renderDisclosureContent(selection2) {
70472       var list2 = selection2.selectAll(".feature-list").data([0]);
70473       list2 = list2.enter().append("ul").attr("class", "feature-list").merge(list2);
70474       var entities = _selectedIDs.map(function(id2) {
70475         return context.hasEntity(id2);
70476       }).filter(Boolean);
70477       var items = list2.selectAll(".feature-list-item").data(entities, osmEntity.key);
70478       items.exit().remove();
70479       var enter = items.enter().append("li").attr("class", "feature-list-item").each(function(d2) {
70480         select_default2(this).on("mouseover", function() {
70481           utilHighlightEntities([d2.id], true, context);
70482         }).on("mouseout", function() {
70483           utilHighlightEntities([d2.id], false, context);
70484         });
70485       });
70486       var label = enter.append("button").attr("class", "label").on("click", selectEntity);
70487       label.append("span").attr("class", "entity-geom-icon").call(svgIcon("", "pre-text"));
70488       label.append("span").attr("class", "entity-type");
70489       label.append("span").attr("class", "entity-name");
70490       enter.append("button").attr("class", "close").attr("title", _t("icons.deselect")).on("click", deselectEntity).call(svgIcon("#iD-icon-close"));
70491       items = items.merge(enter);
70492       items.selectAll(".entity-geom-icon use").attr("href", function() {
70493         var entity = this.parentNode.parentNode.__data__;
70494         return "#iD-icon-" + entity.geometry(context.graph());
70495       });
70496       items.selectAll(".entity-type").text(function(entity) {
70497         return _mainPresetIndex.match(entity, context.graph()).name();
70498       });
70499       items.selectAll(".entity-name").text(function(d2) {
70500         var entity = context.entity(d2.id);
70501         return utilDisplayName(entity);
70502       });
70503     }
70504     return section;
70505   }
70506
70507   // modules/ui/entity_editor.js
70508   function uiEntityEditor(context) {
70509     var dispatch14 = dispatch_default("choose");
70510     var _state = "select";
70511     var _coalesceChanges = false;
70512     var _modified = false;
70513     var _base;
70514     var _entityIDs;
70515     var _activePresets = [];
70516     var _newFeature;
70517     var _sections;
70518     function entityEditor(selection2) {
70519       var combinedTags = utilCombinedTags(_entityIDs, context.graph());
70520       var header = selection2.selectAll(".header").data([0]);
70521       var headerEnter = header.enter().append("div").attr("class", "header fillL");
70522       var direction = _mainLocalizer.textDirection() === "rtl" ? "forward" : "backward";
70523       headerEnter.append("button").attr("class", "preset-reset preset-choose").attr("title", _t("inspector.back_tooltip")).call(svgIcon("#iD-icon-".concat(direction)));
70524       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
70525         context.enter(modeBrowse(context));
70526       }).call(svgIcon(_modified ? "#iD-icon-apply" : "#iD-icon-close"));
70527       headerEnter.append("h2");
70528       header = header.merge(headerEnter);
70529       header.selectAll("h2").text("").call(_entityIDs.length === 1 ? _t.append("inspector.edit") : _t.append("inspector.edit_features"));
70530       header.selectAll(".preset-reset").on("click", function() {
70531         dispatch14.call("choose", this, _activePresets);
70532       });
70533       var body = selection2.selectAll(".inspector-body").data([0]);
70534       var bodyEnter = body.enter().append("div").attr("class", "entity-editor inspector-body sep-top");
70535       body = body.merge(bodyEnter);
70536       if (!_sections) {
70537         _sections = [
70538           uiSectionSelectionList(context),
70539           uiSectionFeatureType(context).on("choose", function(presets) {
70540             dispatch14.call("choose", this, presets);
70541           }),
70542           uiSectionEntityIssues(context),
70543           uiSectionPresetFields(context).on("change", changeTags).on("revert", revertTags),
70544           uiSectionRawTagEditor("raw-tag-editor", context).on("change", changeTags),
70545           uiSectionRawMemberEditor(context),
70546           uiSectionRawMembershipEditor(context)
70547         ];
70548       }
70549       _sections.forEach(function(section) {
70550         if (section.entityIDs) {
70551           section.entityIDs(_entityIDs);
70552         }
70553         if (section.presets) {
70554           section.presets(_activePresets);
70555         }
70556         if (section.tags) {
70557           section.tags(combinedTags);
70558         }
70559         if (section.state) {
70560           section.state(_state);
70561         }
70562         body.call(section.render);
70563       });
70564       context.history().on("change.entity-editor", historyChanged);
70565       function historyChanged(difference2) {
70566         if (selection2.selectAll(".entity-editor").empty())
70567           return;
70568         if (_state === "hide")
70569           return;
70570         var significant = !difference2 || difference2.didChange.properties || difference2.didChange.addition || difference2.didChange.deletion;
70571         if (!significant)
70572           return;
70573         _entityIDs = _entityIDs.filter(context.hasEntity);
70574         if (!_entityIDs.length)
70575           return;
70576         var priorActivePreset = _activePresets.length === 1 && _activePresets[0];
70577         loadActivePresets();
70578         var graph = context.graph();
70579         entityEditor.modified(_base !== graph);
70580         entityEditor(selection2);
70581         if (priorActivePreset && _activePresets.length === 1 && priorActivePreset !== _activePresets[0]) {
70582           context.container().selectAll(".entity-editor button.preset-reset .label").style("background-color", "#fff").transition().duration(750).style("background-color", null);
70583         }
70584       }
70585     }
70586     function changeTags(entityIDs, changed, onInput) {
70587       var actions = [];
70588       for (var i3 in entityIDs) {
70589         var entityID = entityIDs[i3];
70590         var entity = context.entity(entityID);
70591         var tags = Object.assign({}, entity.tags);
70592         if (typeof changed === "function") {
70593           tags = changed(tags);
70594         } else {
70595           for (var k2 in changed) {
70596             if (!k2)
70597               continue;
70598             var v2 = changed[k2];
70599             if (typeof v2 === "object") {
70600               tags[k2] = tags[v2.oldKey];
70601             } else if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
70602               tags[k2] = v2;
70603             }
70604           }
70605         }
70606         if (!onInput) {
70607           tags = utilCleanTags(tags);
70608         }
70609         if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) {
70610           actions.push(actionChangeTags(entityID, tags));
70611         }
70612       }
70613       if (actions.length) {
70614         var combinedAction = function(graph) {
70615           actions.forEach(function(action) {
70616             graph = action(graph);
70617           });
70618           return graph;
70619         };
70620         var annotation = _t("operations.change_tags.annotation");
70621         if (_coalesceChanges) {
70622           context.overwrite(combinedAction, annotation);
70623         } else {
70624           context.perform(combinedAction, annotation);
70625           _coalesceChanges = !!onInput;
70626         }
70627       }
70628       if (!onInput) {
70629         context.validator().validate();
70630       }
70631     }
70632     function revertTags(keys2) {
70633       var actions = [];
70634       for (var i3 in _entityIDs) {
70635         var entityID = _entityIDs[i3];
70636         var original = context.graph().base().entities[entityID];
70637         var changed = {};
70638         for (var j2 in keys2) {
70639           var key = keys2[j2];
70640           changed[key] = original ? original.tags[key] : void 0;
70641         }
70642         var entity = context.entity(entityID);
70643         var tags = Object.assign({}, entity.tags);
70644         for (var k2 in changed) {
70645           if (!k2)
70646             continue;
70647           var v2 = changed[k2];
70648           if (v2 !== void 0 || tags.hasOwnProperty(k2)) {
70649             tags[k2] = v2;
70650           }
70651         }
70652         tags = utilCleanTags(tags);
70653         if (!(0, import_fast_deep_equal10.default)(entity.tags, tags)) {
70654           actions.push(actionChangeTags(entityID, tags));
70655         }
70656       }
70657       if (actions.length) {
70658         var combinedAction = function(graph) {
70659           actions.forEach(function(action) {
70660             graph = action(graph);
70661           });
70662           return graph;
70663         };
70664         var annotation = _t("operations.change_tags.annotation");
70665         if (_coalesceChanges) {
70666           context.overwrite(combinedAction, annotation);
70667         } else {
70668           context.perform(combinedAction, annotation);
70669           _coalesceChanges = false;
70670         }
70671       }
70672       context.validator().validate();
70673     }
70674     entityEditor.modified = function(val) {
70675       if (!arguments.length)
70676         return _modified;
70677       _modified = val;
70678       return entityEditor;
70679     };
70680     entityEditor.state = function(val) {
70681       if (!arguments.length)
70682         return _state;
70683       _state = val;
70684       return entityEditor;
70685     };
70686     entityEditor.entityIDs = function(val) {
70687       if (!arguments.length)
70688         return _entityIDs;
70689       _base = context.graph();
70690       _coalesceChanges = false;
70691       if (val && _entityIDs && utilArrayIdentical(_entityIDs, val))
70692         return entityEditor;
70693       _entityIDs = val;
70694       loadActivePresets(true);
70695       return entityEditor.modified(false);
70696     };
70697     entityEditor.newFeature = function(val) {
70698       if (!arguments.length)
70699         return _newFeature;
70700       _newFeature = val;
70701       return entityEditor;
70702     };
70703     function loadActivePresets(isForNewSelection) {
70704       var graph = context.graph();
70705       var counts = {};
70706       for (var i3 in _entityIDs) {
70707         var entity = graph.hasEntity(_entityIDs[i3]);
70708         if (!entity)
70709           return;
70710         var match = _mainPresetIndex.match(entity, graph);
70711         if (!counts[match.id])
70712           counts[match.id] = 0;
70713         counts[match.id] += 1;
70714       }
70715       var matches = Object.keys(counts).sort(function(p1, p2) {
70716         return counts[p2] - counts[p1];
70717       }).map(function(pID) {
70718         return _mainPresetIndex.item(pID);
70719       });
70720       if (!isForNewSelection) {
70721         var weakPreset = _activePresets.length === 1 && !_activePresets[0].isFallback() && Object.keys(_activePresets[0].addTags || {}).length === 0;
70722         if (weakPreset && matches.length === 1 && matches[0].isFallback())
70723           return;
70724       }
70725       entityEditor.presets(matches);
70726     }
70727     entityEditor.presets = function(val) {
70728       if (!arguments.length)
70729         return _activePresets;
70730       if (!utilArrayIdentical(val, _activePresets)) {
70731         _activePresets = val;
70732       }
70733       return entityEditor;
70734     };
70735     return utilRebind(entityEditor, dispatch14, "on");
70736   }
70737
70738   // modules/ui/feature_list.js
70739   var sexagesimal = __toESM(require_sexagesimal());
70740
70741   // modules/modes/draw_area.js
70742   function modeDrawArea(context, wayID, startGraph, button) {
70743     var mode = {
70744       button,
70745       id: "draw-area"
70746     };
70747     var behavior = behaviorDrawWay(context, wayID, mode, startGraph).on("rejectedSelfIntersection.modeDrawArea", function() {
70748       context.ui().flash.iconName("#iD-icon-no").label(_t.append("self_intersection.error.areas"))();
70749     });
70750     mode.wayID = wayID;
70751     mode.enter = function() {
70752       context.install(behavior);
70753     };
70754     mode.exit = function() {
70755       context.uninstall(behavior);
70756     };
70757     mode.selectedIDs = function() {
70758       return [wayID];
70759     };
70760     mode.activeID = function() {
70761       return behavior && behavior.activeID() || [];
70762     };
70763     return mode;
70764   }
70765
70766   // modules/modes/add_area.js
70767   function modeAddArea(context, mode) {
70768     mode.id = "add-area";
70769     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
70770     function defaultTags(loc) {
70771       var defaultTags2 = { area: "yes" };
70772       if (mode.preset)
70773         defaultTags2 = mode.preset.setTags(defaultTags2, "area", false, loc);
70774       return defaultTags2;
70775     }
70776     function actionClose(wayId) {
70777       return function(graph) {
70778         return graph.replace(graph.entity(wayId).close());
70779       };
70780     }
70781     function start2(loc) {
70782       var startGraph = context.graph();
70783       var node = osmNode({ loc });
70784       var way = osmWay({ tags: defaultTags(loc) });
70785       context.perform(
70786         actionAddEntity(node),
70787         actionAddEntity(way),
70788         actionAddVertex(way.id, node.id),
70789         actionClose(way.id)
70790       );
70791       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
70792     }
70793     function startFromWay(loc, edge) {
70794       var startGraph = context.graph();
70795       var node = osmNode({ loc });
70796       var way = osmWay({ tags: defaultTags(loc) });
70797       context.perform(
70798         actionAddEntity(node),
70799         actionAddEntity(way),
70800         actionAddVertex(way.id, node.id),
70801         actionClose(way.id),
70802         actionAddMidpoint({ loc, edge }, node)
70803       );
70804       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
70805     }
70806     function startFromNode(node) {
70807       var startGraph = context.graph();
70808       var way = osmWay({ tags: defaultTags(node.loc) });
70809       context.perform(
70810         actionAddEntity(way),
70811         actionAddVertex(way.id, node.id),
70812         actionClose(way.id)
70813       );
70814       context.enter(modeDrawArea(context, way.id, startGraph, mode.button));
70815     }
70816     mode.enter = function() {
70817       context.install(behavior);
70818     };
70819     mode.exit = function() {
70820       context.uninstall(behavior);
70821     };
70822     return mode;
70823   }
70824
70825   // modules/modes/add_line.js
70826   function modeAddLine(context, mode) {
70827     mode.id = "add-line";
70828     var behavior = behaviorAddWay(context).on("start", start2).on("startFromWay", startFromWay).on("startFromNode", startFromNode);
70829     function defaultTags(loc) {
70830       var defaultTags2 = {};
70831       if (mode.preset)
70832         defaultTags2 = mode.preset.setTags(defaultTags2, "line", false, loc);
70833       return defaultTags2;
70834     }
70835     function start2(loc) {
70836       var startGraph = context.graph();
70837       var node = osmNode({ loc });
70838       var way = osmWay({ tags: defaultTags(loc) });
70839       context.perform(
70840         actionAddEntity(node),
70841         actionAddEntity(way),
70842         actionAddVertex(way.id, node.id)
70843       );
70844       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
70845     }
70846     function startFromWay(loc, edge) {
70847       var startGraph = context.graph();
70848       var node = osmNode({ loc });
70849       var way = osmWay({ tags: defaultTags(loc) });
70850       context.perform(
70851         actionAddEntity(node),
70852         actionAddEntity(way),
70853         actionAddVertex(way.id, node.id),
70854         actionAddMidpoint({ loc, edge }, node)
70855       );
70856       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
70857     }
70858     function startFromNode(node) {
70859       var startGraph = context.graph();
70860       var way = osmWay({ tags: defaultTags(node.loc) });
70861       context.perform(
70862         actionAddEntity(way),
70863         actionAddVertex(way.id, node.id)
70864       );
70865       context.enter(modeDrawLine(context, way.id, startGraph, mode.button));
70866     }
70867     mode.enter = function() {
70868       context.install(behavior);
70869     };
70870     mode.exit = function() {
70871       context.uninstall(behavior);
70872     };
70873     return mode;
70874   }
70875
70876   // modules/modes/add_point.js
70877   function modeAddPoint(context, mode) {
70878     mode.id = "add-point";
70879     var behavior = behaviorDraw(context).on("click", add).on("clickWay", addWay).on("clickNode", addNode).on("cancel", cancel).on("finish", cancel);
70880     function defaultTags(loc) {
70881       var defaultTags2 = {};
70882       if (mode.preset)
70883         defaultTags2 = mode.preset.setTags(defaultTags2, "point", false, loc);
70884       return defaultTags2;
70885     }
70886     function add(loc) {
70887       var node = osmNode({ loc, tags: defaultTags(loc) });
70888       context.perform(
70889         actionAddEntity(node),
70890         _t("operations.add.annotation.point")
70891       );
70892       enterSelectMode(node);
70893     }
70894     function addWay(loc, edge) {
70895       var node = osmNode({ tags: defaultTags(loc) });
70896       context.perform(
70897         actionAddMidpoint({ loc, edge }, node),
70898         _t("operations.add.annotation.vertex")
70899       );
70900       enterSelectMode(node);
70901     }
70902     function enterSelectMode(node) {
70903       context.enter(
70904         modeSelect(context, [node.id]).newFeature(true)
70905       );
70906     }
70907     function addNode(node) {
70908       const _defaultTags = defaultTags(node.loc);
70909       if (Object.keys(_defaultTags).length === 0) {
70910         enterSelectMode(node);
70911         return;
70912       }
70913       var tags = Object.assign({}, node.tags);
70914       for (var key in _defaultTags) {
70915         tags[key] = _defaultTags[key];
70916       }
70917       context.perform(
70918         actionChangeTags(node.id, tags),
70919         _t("operations.add.annotation.point")
70920       );
70921       enterSelectMode(node);
70922     }
70923     function cancel() {
70924       context.enter(modeBrowse(context));
70925     }
70926     mode.enter = function() {
70927       context.install(behavior);
70928     };
70929     mode.exit = function() {
70930       context.uninstall(behavior);
70931     };
70932     return mode;
70933   }
70934
70935   // modules/ui/note_comments.js
70936   function uiNoteComments() {
70937     var _note;
70938     function noteComments(selection2) {
70939       if (_note.isNew())
70940         return;
70941       var comments = selection2.selectAll(".comments-container").data([0]);
70942       comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
70943       var commentEnter = comments.selectAll(".comment").data(_note.comments).enter().append("div").attr("class", "comment");
70944       commentEnter.append("div").attr("class", function(d2) {
70945         return "comment-avatar user-" + d2.uid;
70946       }).call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
70947       var mainEnter = commentEnter.append("div").attr("class", "comment-main");
70948       var metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
70949       metadataEnter.append("div").attr("class", "comment-author").each(function(d2) {
70950         var selection3 = select_default2(this);
70951         var osm = services.osm;
70952         if (osm && d2.user) {
70953           selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d2.user)).attr("target", "_blank");
70954         }
70955         if (d2.user) {
70956           selection3.text(d2.user);
70957         } else {
70958           selection3.call(_t.append("note.anonymous"));
70959         }
70960       });
70961       metadataEnter.append("div").attr("class", "comment-date").html(function(d2) {
70962         return _t.html("note.status." + d2.action, { when: localeDateString2(d2.date) });
70963       });
70964       mainEnter.append("div").attr("class", "comment-text").html(function(d2) {
70965         return d2.html;
70966       }).selectAll("a").attr("rel", "noopener nofollow").attr("target", "_blank");
70967       comments.call(replaceAvatars);
70968     }
70969     function replaceAvatars(selection2) {
70970       var showThirdPartyIcons = corePreferences("preferences.privacy.thirdpartyicons") || "true";
70971       var osm = services.osm;
70972       if (showThirdPartyIcons !== "true" || !osm)
70973         return;
70974       var uids = {};
70975       _note.comments.forEach(function(d2) {
70976         if (d2.uid)
70977           uids[d2.uid] = true;
70978       });
70979       Object.keys(uids).forEach(function(uid) {
70980         osm.loadUser(uid, function(err, user) {
70981           if (!user || !user.image_url)
70982             return;
70983           selection2.selectAll(".comment-avatar.user-" + uid).html("").append("img").attr("class", "icon comment-avatar-icon").attr("src", user.image_url).attr("alt", user.display_name);
70984         });
70985       });
70986     }
70987     function localeDateString2(s2) {
70988       if (!s2)
70989         return null;
70990       var options2 = { day: "numeric", month: "short", year: "numeric" };
70991       s2 = s2.replace(/-/g, "/");
70992       var d2 = new Date(s2);
70993       if (isNaN(d2.getTime()))
70994         return null;
70995       return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
70996     }
70997     noteComments.note = function(val) {
70998       if (!arguments.length)
70999         return _note;
71000       _note = val;
71001       return noteComments;
71002     };
71003     return noteComments;
71004   }
71005
71006   // modules/ui/note_header.js
71007   function uiNoteHeader() {
71008     var _note;
71009     function noteHeader(selection2) {
71010       var header = selection2.selectAll(".note-header").data(
71011         _note ? [_note] : [],
71012         function(d2) {
71013           return d2.status + d2.id;
71014         }
71015       );
71016       header.exit().remove();
71017       var headerEnter = header.enter().append("div").attr("class", "note-header");
71018       var iconEnter = headerEnter.append("div").attr("class", function(d2) {
71019         return "note-header-icon " + d2.status;
71020       }).classed("new", function(d2) {
71021         return d2.id < 0;
71022       });
71023       iconEnter.append("div").attr("class", "preset-icon-28").call(svgIcon("#iD-icon-note", "note-fill"));
71024       iconEnter.each(function(d2) {
71025         var statusIcon;
71026         if (d2.id < 0) {
71027           statusIcon = "#iD-icon-plus";
71028         } else if (d2.status === "open") {
71029           statusIcon = "#iD-icon-close";
71030         } else {
71031           statusIcon = "#iD-icon-apply";
71032         }
71033         iconEnter.append("div").attr("class", "note-icon-annotation").attr("title", _t("icons.close")).call(svgIcon(statusIcon, "icon-annotation"));
71034       });
71035       headerEnter.append("div").attr("class", "note-header-label").html(function(d2) {
71036         if (_note.isNew()) {
71037           return _t.html("note.new");
71038         }
71039         return _t.html("note.note") + " " + d2.id + " " + (d2.status === "closed" ? _t.html("note.closed") : "");
71040       });
71041     }
71042     noteHeader.note = function(val) {
71043       if (!arguments.length)
71044         return _note;
71045       _note = val;
71046       return noteHeader;
71047     };
71048     return noteHeader;
71049   }
71050
71051   // modules/ui/note_report.js
71052   function uiNoteReport() {
71053     var _note;
71054     function noteReport(selection2) {
71055       var url;
71056       if (services.osm && _note instanceof osmNote && !_note.isNew()) {
71057         url = services.osm.noteReportURL(_note);
71058       }
71059       var link3 = selection2.selectAll(".note-report").data(url ? [url] : []);
71060       link3.exit().remove();
71061       var linkEnter = link3.enter().append("a").attr("class", "note-report").attr("target", "_blank").attr("href", function(d2) {
71062         return d2;
71063       }).call(svgIcon("#iD-icon-out-link", "inline"));
71064       linkEnter.append("span").call(_t.append("note.report"));
71065     }
71066     noteReport.note = function(val) {
71067       if (!arguments.length)
71068         return _note;
71069       _note = val;
71070       return noteReport;
71071     };
71072     return noteReport;
71073   }
71074
71075   // modules/ui/view_on_osm.js
71076   function uiViewOnOSM(context) {
71077     var _what;
71078     function viewOnOSM(selection2) {
71079       var url;
71080       if (_what instanceof osmEntity) {
71081         url = context.connection().entityURL(_what);
71082       } else if (_what instanceof osmNote) {
71083         url = context.connection().noteURL(_what);
71084       }
71085       var data = !_what || _what.isNew() ? [] : [_what];
71086       var link3 = selection2.selectAll(".view-on-osm").data(data, function(d2) {
71087         return d2.id;
71088       });
71089       link3.exit().remove();
71090       var linkEnter = link3.enter().append("a").attr("class", "view-on-osm").attr("target", "_blank").attr("href", url).call(svgIcon("#iD-icon-out-link", "inline"));
71091       linkEnter.append("span").call(_t.append("inspector.view_on_osm"));
71092     }
71093     viewOnOSM.what = function(_2) {
71094       if (!arguments.length)
71095         return _what;
71096       _what = _2;
71097       return viewOnOSM;
71098     };
71099     return viewOnOSM;
71100   }
71101
71102   // modules/ui/note_editor.js
71103   function uiNoteEditor(context) {
71104     var dispatch14 = dispatch_default("change");
71105     var noteComments = uiNoteComments(context);
71106     var noteHeader = uiNoteHeader();
71107     var _note;
71108     var _newNote;
71109     function noteEditor(selection2) {
71110       var header = selection2.selectAll(".header").data([0]);
71111       var headerEnter = header.enter().append("div").attr("class", "header fillL");
71112       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
71113         context.enter(modeBrowse(context));
71114       }).call(svgIcon("#iD-icon-close"));
71115       headerEnter.append("h2").call(_t.append("note.title"));
71116       var body = selection2.selectAll(".body").data([0]);
71117       body = body.enter().append("div").attr("class", "body").merge(body);
71118       var editor = body.selectAll(".note-editor").data([0]);
71119       editor.enter().append("div").attr("class", "modal-section note-editor").merge(editor).call(noteHeader.note(_note)).call(noteComments.note(_note)).call(noteSaveSection);
71120       var footer = selection2.selectAll(".footer").data([0]);
71121       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOSM(context).what(_note)).call(uiNoteReport(context).note(_note));
71122       var osm = services.osm;
71123       if (osm) {
71124         osm.on("change.note-save", function() {
71125           selection2.call(noteEditor);
71126         });
71127       }
71128     }
71129     function noteSaveSection(selection2) {
71130       var isSelected = _note && _note.id === context.selectedNoteID();
71131       var noteSave = selection2.selectAll(".note-save").data(isSelected ? [_note] : [], function(d2) {
71132         return d2.status + d2.id;
71133       });
71134       noteSave.exit().remove();
71135       var noteSaveEnter = noteSave.enter().append("div").attr("class", "note-save save-section cf");
71136       noteSaveEnter.append("h4").attr("class", ".note-save-header").html(function() {
71137         return _note.isNew() ? _t.html("note.newDescription") : _t.html("note.newComment");
71138       });
71139       var commentTextarea = noteSaveEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("note.inputPlaceholder")).attr("maxlength", 1e3).property("value", function(d2) {
71140         return d2.newComment;
71141       }).call(utilNoAuto).on("keydown.note-input", keydown).on("input.note-input", changeInput).on("blur.note-input", changeInput);
71142       if (!commentTextarea.empty() && _newNote) {
71143         commentTextarea.node().focus();
71144       }
71145       noteSave = noteSaveEnter.merge(noteSave).call(userDetails).call(noteSaveButtons);
71146       function keydown(d3_event) {
71147         if (!(d3_event.keyCode === 13 && // ↩ Return
71148         d3_event.metaKey))
71149           return;
71150         var osm = services.osm;
71151         if (!osm)
71152           return;
71153         var hasAuth = osm.authenticated();
71154         if (!hasAuth)
71155           return;
71156         if (!_note.newComment)
71157           return;
71158         d3_event.preventDefault();
71159         select_default2(this).on("keydown.note-input", null);
71160         window.setTimeout(function() {
71161           if (_note.isNew()) {
71162             noteSave.selectAll(".save-button").node().focus();
71163             clickSave(_note);
71164           } else {
71165             noteSave.selectAll(".comment-button").node().focus();
71166             clickComment(_note);
71167           }
71168         }, 10);
71169       }
71170       function changeInput() {
71171         var input = select_default2(this);
71172         var val = input.property("value").trim() || void 0;
71173         _note = _note.update({ newComment: val });
71174         var osm = services.osm;
71175         if (osm) {
71176           osm.replaceNote(_note);
71177         }
71178         noteSave.call(noteSaveButtons);
71179       }
71180     }
71181     function userDetails(selection2) {
71182       var detailSection = selection2.selectAll(".detail-section").data([0]);
71183       detailSection = detailSection.enter().append("div").attr("class", "detail-section").merge(detailSection);
71184       var osm = services.osm;
71185       if (!osm)
71186         return;
71187       var hasAuth = osm.authenticated();
71188       var authWarning = detailSection.selectAll(".auth-warning").data(hasAuth ? [] : [0]);
71189       authWarning.exit().transition().duration(200).style("opacity", 0).remove();
71190       var authEnter = authWarning.enter().insert("div", ".tag-reference-body").attr("class", "field-warning auth-warning").style("opacity", 0);
71191       authEnter.call(svgIcon("#iD-icon-alert", "inline"));
71192       authEnter.append("span").call(_t.append("note.login"));
71193       authEnter.append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("login")).on("click.note-login", function(d3_event) {
71194         d3_event.preventDefault();
71195         osm.authenticate();
71196       });
71197       authEnter.transition().duration(200).style("opacity", 1);
71198       var prose = detailSection.selectAll(".note-save-prose").data(hasAuth ? [0] : []);
71199       prose.exit().remove();
71200       prose = prose.enter().append("p").attr("class", "note-save-prose").call(_t.append("note.upload_explanation")).merge(prose);
71201       osm.userDetails(function(err, user) {
71202         if (err)
71203           return;
71204         var userLink = select_default2(document.createElement("div"));
71205         if (user.image_url) {
71206           userLink.append("img").attr("src", user.image_url).attr("class", "icon pre-text user-icon");
71207         }
71208         userLink.append("a").attr("class", "user-info").text(user.display_name).attr("href", osm.userURL(user.display_name)).attr("target", "_blank");
71209         prose.html(_t.html("note.upload_explanation_with_user", { user: { html: userLink.html() } }));
71210       });
71211     }
71212     function noteSaveButtons(selection2) {
71213       var osm = services.osm;
71214       var hasAuth = osm && osm.authenticated();
71215       var isSelected = _note && _note.id === context.selectedNoteID();
71216       var buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_note] : [], function(d2) {
71217         return d2.status + d2.id;
71218       });
71219       buttonSection.exit().remove();
71220       var buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
71221       if (_note.isNew()) {
71222         buttonEnter.append("button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
71223         buttonEnter.append("button").attr("class", "button save-button action").call(_t.append("note.save"));
71224       } else {
71225         buttonEnter.append("button").attr("class", "button status-button action");
71226         buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("note.comment"));
71227       }
71228       buttonSection = buttonSection.merge(buttonEnter);
71229       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
71230       buttonSection.select(".save-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
71231       buttonSection.select(".status-button").attr("disabled", hasAuth ? null : true).html(function(d2) {
71232         var action = d2.status === "open" ? "close" : "open";
71233         var andComment = d2.newComment ? "_comment" : "";
71234         return _t.html("note." + action + andComment);
71235       }).on("click.status", clickStatus);
71236       buttonSection.select(".comment-button").attr("disabled", isSaveDisabled).on("click.comment", clickComment);
71237       function isSaveDisabled(d2) {
71238         return hasAuth && d2.status === "open" && d2.newComment ? null : true;
71239       }
71240     }
71241     function clickCancel(d3_event, d2) {
71242       this.blur();
71243       var osm = services.osm;
71244       if (osm) {
71245         osm.removeNote(d2);
71246       }
71247       context.enter(modeBrowse(context));
71248       dispatch14.call("change");
71249     }
71250     function clickSave(d3_event, d2) {
71251       this.blur();
71252       var osm = services.osm;
71253       if (osm) {
71254         osm.postNoteCreate(d2, function(err, note) {
71255           dispatch14.call("change", note);
71256         });
71257       }
71258     }
71259     function clickStatus(d3_event, d2) {
71260       this.blur();
71261       var osm = services.osm;
71262       if (osm) {
71263         var setStatus = d2.status === "open" ? "closed" : "open";
71264         osm.postNoteUpdate(d2, setStatus, function(err, note) {
71265           dispatch14.call("change", note);
71266         });
71267       }
71268     }
71269     function clickComment(d3_event, d2) {
71270       this.blur();
71271       var osm = services.osm;
71272       if (osm) {
71273         osm.postNoteUpdate(d2, d2.status, function(err, note) {
71274           dispatch14.call("change", note);
71275         });
71276       }
71277     }
71278     noteEditor.note = function(val) {
71279       if (!arguments.length)
71280         return _note;
71281       _note = val;
71282       return noteEditor;
71283     };
71284     noteEditor.newNote = function(val) {
71285       if (!arguments.length)
71286         return _newNote;
71287       _newNote = val;
71288       return noteEditor;
71289     };
71290     return utilRebind(noteEditor, dispatch14, "on");
71291   }
71292
71293   // modules/modes/select_note.js
71294   function modeSelectNote(context, selectedNoteID) {
71295     var mode = {
71296       id: "select-note",
71297       button: "browse"
71298     };
71299     var _keybinding = utilKeybinding("select-note");
71300     var _noteEditor = uiNoteEditor(context).on("change", function() {
71301       context.map().pan([0, 0]);
71302       var note = checkSelectedID();
71303       if (!note)
71304         return;
71305       context.ui().sidebar.show(_noteEditor.note(note));
71306     });
71307     var _behaviors = [
71308       behaviorBreathe(context),
71309       behaviorHover(context),
71310       behaviorSelect(context),
71311       behaviorLasso(context),
71312       modeDragNode(context).behavior,
71313       modeDragNote(context).behavior
71314     ];
71315     var _newFeature = false;
71316     function checkSelectedID() {
71317       if (!services.osm)
71318         return;
71319       var note = services.osm.getNote(selectedNoteID);
71320       if (!note) {
71321         context.enter(modeBrowse(context));
71322       }
71323       return note;
71324     }
71325     function selectNote(d3_event, drawn) {
71326       if (!checkSelectedID())
71327         return;
71328       var selection2 = context.surface().selectAll(".layer-notes .note-" + selectedNoteID);
71329       if (selection2.empty()) {
71330         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
71331         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
71332           context.enter(modeBrowse(context));
71333         }
71334       } else {
71335         selection2.classed("selected", true);
71336         context.selectedNoteID(selectedNoteID);
71337       }
71338     }
71339     function esc() {
71340       if (context.container().select(".combobox").size())
71341         return;
71342       context.enter(modeBrowse(context));
71343     }
71344     mode.zoomToSelected = function() {
71345       if (!services.osm)
71346         return;
71347       var note = services.osm.getNote(selectedNoteID);
71348       if (note) {
71349         context.map().centerZoomEase(note.loc, 20);
71350       }
71351     };
71352     mode.newFeature = function(val) {
71353       if (!arguments.length)
71354         return _newFeature;
71355       _newFeature = val;
71356       return mode;
71357     };
71358     mode.enter = function() {
71359       var note = checkSelectedID();
71360       if (!note)
71361         return;
71362       _behaviors.forEach(context.install);
71363       _keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
71364       select_default2(document).call(_keybinding);
71365       selectNote();
71366       var sidebar = context.ui().sidebar;
71367       sidebar.show(_noteEditor.note(note).newNote(_newFeature));
71368       sidebar.expand(sidebar.intersects(note.extent()));
71369       context.map().on("drawn.select", selectNote);
71370     };
71371     mode.exit = function() {
71372       _behaviors.forEach(context.uninstall);
71373       select_default2(document).call(_keybinding.unbind);
71374       context.surface().selectAll(".layer-notes .selected").classed("selected hover", false);
71375       context.map().on("drawn.select", null);
71376       context.ui().sidebar.hide();
71377       context.selectedNoteID(null);
71378     };
71379     return mode;
71380   }
71381
71382   // modules/modes/add_note.js
71383   function modeAddNote(context) {
71384     var mode = {
71385       id: "add-note",
71386       button: "note",
71387       description: _t.append("modes.add_note.description"),
71388       key: _t("modes.add_note.key")
71389     };
71390     var behavior = behaviorDraw(context).on("click", add).on("cancel", cancel).on("finish", cancel);
71391     function add(loc) {
71392       var osm = services.osm;
71393       if (!osm)
71394         return;
71395       var note = osmNote({ loc, status: "open", comments: [] });
71396       osm.replaceNote(note);
71397       context.map().pan([0, 0]);
71398       context.selectedNoteID(note.id).enter(modeSelectNote(context, note.id).newFeature(true));
71399     }
71400     function cancel() {
71401       context.enter(modeBrowse(context));
71402     }
71403     mode.enter = function() {
71404       context.install(behavior);
71405     };
71406     mode.exit = function() {
71407       context.uninstall(behavior);
71408     };
71409     return mode;
71410   }
71411
71412   // node_modules/osm-community-index/lib/simplify.js
71413   var import_diacritics2 = __toESM(require_diacritics(), 1);
71414   function simplify(str) {
71415     if (typeof str !== "string")
71416       return "";
71417     return import_diacritics2.default.remove(
71418       str.replace(/&/g, "and").replace(/(İ|i̇)/ig, "i").replace(/[\s\-=_!"#%'*{},.\/:;?\(\)\[\]@\\$\^*+<>«»~`’\u00a1\u00a7\u00b6\u00b7\u00bf\u037e\u0387\u055a-\u055f\u0589\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0af0\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f14\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1360-\u1368\u166d\u166e\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u1805\u1807-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cc0-\u1cc7\u1cd3\u2000-\u206f\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e7f\u3001-\u3003\u303d\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uaaf0\uaaf1\uabeb\ufe10-\ufe16\ufe19\ufe30\ufe45\ufe46\ufe49-\ufe4c\ufe50-\ufe52\ufe54-\ufe57\ufe5f-\ufe61\ufe68\ufe6a\ufe6b\ufeff\uff01-\uff03\uff05-\uff07\uff0a\uff0c\uff0e\uff0f\uff1a\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65]+/g, "").toLowerCase()
71419     );
71420   }
71421
71422   // node_modules/osm-community-index/lib/resolve_strings.js
71423   function resolveStrings(item, defaults, localizerFn) {
71424     let itemStrings = Object.assign({}, item.strings);
71425     let defaultStrings = Object.assign({}, defaults[item.type]);
71426     const anyToken = new RegExp(/(\{\w+\})/, "gi");
71427     if (localizerFn) {
71428       if (itemStrings.community) {
71429         const communityID = simplify(itemStrings.community);
71430         itemStrings.community = localizerFn("_communities.".concat(communityID));
71431       }
71432       ["name", "description", "extendedDescription"].forEach((prop) => {
71433         if (defaultStrings[prop])
71434           defaultStrings[prop] = localizerFn("_defaults.".concat(item.type, ".").concat(prop));
71435         if (itemStrings[prop])
71436           itemStrings[prop] = localizerFn("".concat(item.id, ".").concat(prop));
71437       });
71438     }
71439     let replacements = {
71440       account: item.account,
71441       community: itemStrings.community,
71442       signupUrl: itemStrings.signupUrl,
71443       url: itemStrings.url
71444     };
71445     if (!replacements.signupUrl) {
71446       replacements.signupUrl = resolve(itemStrings.signupUrl || defaultStrings.signupUrl);
71447     }
71448     if (!replacements.url) {
71449       replacements.url = resolve(itemStrings.url || defaultStrings.url);
71450     }
71451     let resolved = {
71452       name: resolve(itemStrings.name || defaultStrings.name),
71453       url: resolve(itemStrings.url || defaultStrings.url),
71454       signupUrl: resolve(itemStrings.signupUrl || defaultStrings.signupUrl),
71455       description: resolve(itemStrings.description || defaultStrings.description),
71456       extendedDescription: resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription)
71457     };
71458     resolved.nameHTML = linkify(resolved.url, resolved.name);
71459     resolved.urlHTML = linkify(resolved.url);
71460     resolved.signupUrlHTML = linkify(resolved.signupUrl);
71461     resolved.descriptionHTML = resolve(itemStrings.description || defaultStrings.description, true);
71462     resolved.extendedDescriptionHTML = resolve(itemStrings.extendedDescription || defaultStrings.extendedDescription, true);
71463     return resolved;
71464     function resolve(s2, addLinks) {
71465       if (!s2)
71466         return void 0;
71467       let result = s2;
71468       for (let key in replacements) {
71469         const token = "{".concat(key, "}");
71470         const regex = new RegExp(token, "g");
71471         if (regex.test(result)) {
71472           let replacement = replacements[key];
71473           if (!replacement) {
71474             throw new Error("Cannot resolve token: ".concat(token));
71475           } else {
71476             if (addLinks && (key === "signupUrl" || key === "url")) {
71477               replacement = linkify(replacement);
71478             }
71479             result = result.replace(regex, replacement);
71480           }
71481         }
71482       }
71483       const leftovers = result.match(anyToken);
71484       if (leftovers) {
71485         throw new Error("Cannot resolve tokens: ".concat(leftovers));
71486       }
71487       if (addLinks && item.type === "reddit") {
71488         result = result.replace(/(\/r\/\w+\/*)/i, (match) => linkify(resolved.url, match));
71489       }
71490       return result;
71491     }
71492     function linkify(url, text) {
71493       if (!url)
71494         return void 0;
71495       text = text || url;
71496       return '<a target="_blank" href="'.concat(url, '">').concat(text, "</a>");
71497     }
71498   }
71499
71500   // modules/ui/success.js
71501   var _oci = null;
71502   function uiSuccess(context) {
71503     const MAXEVENTS = 2;
71504     const dispatch14 = dispatch_default("cancel");
71505     let _changeset2;
71506     let _location;
71507     ensureOSMCommunityIndex();
71508     function ensureOSMCommunityIndex() {
71509       const data = _mainFileFetcher;
71510       return Promise.all([
71511         data.get("oci_features"),
71512         data.get("oci_resources"),
71513         data.get("oci_defaults")
71514       ]).then((vals) => {
71515         if (_oci)
71516           return _oci;
71517         if (vals[0] && Array.isArray(vals[0].features)) {
71518           _sharedLocationManager.mergeCustomGeoJSON(vals[0]);
71519         }
71520         let ociResources = Object.values(vals[1].resources);
71521         if (ociResources.length) {
71522           return _sharedLocationManager.mergeLocationSets(ociResources).then(() => {
71523             _oci = {
71524               resources: ociResources,
71525               defaults: vals[2].defaults
71526             };
71527             return _oci;
71528           });
71529         } else {
71530           _oci = {
71531             resources: [],
71532             // no resources?
71533             defaults: vals[2].defaults
71534           };
71535           return _oci;
71536         }
71537       });
71538     }
71539     function parseEventDate(when) {
71540       if (!when)
71541         return;
71542       let raw = when.trim();
71543       if (!raw)
71544         return;
71545       if (!/Z$/.test(raw)) {
71546         raw += "Z";
71547       }
71548       const parsed = new Date(raw);
71549       return new Date(parsed.toUTCString().slice(0, 25));
71550     }
71551     function success(selection2) {
71552       let header = selection2.append("div").attr("class", "header fillL");
71553       header.append("h2").call(_t.append("success.just_edited"));
71554       header.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => dispatch14.call("cancel")).call(svgIcon("#iD-icon-close"));
71555       let body = selection2.append("div").attr("class", "body save-success fillL");
71556       let summary = body.append("div").attr("class", "save-summary");
71557       summary.append("h3").call(_t.append("success.thank_you" + (_location ? "_location" : ""), { where: _location }));
71558       summary.append("p").call(_t.append("success.help_html")).append("a").attr("class", "link-out").attr("target", "_blank").attr("href", _t("success.help_link_url")).call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("success.help_link_text"));
71559       let osm = context.connection();
71560       if (!osm)
71561         return;
71562       let changesetURL = osm.changesetURL(_changeset2.id);
71563       let table = summary.append("table").attr("class", "summary-table");
71564       let row = table.append("tr").attr("class", "summary-row");
71565       row.append("td").attr("class", "cell-icon summary-icon").append("a").attr("target", "_blank").attr("href", changesetURL).append("svg").attr("class", "logo-small").append("use").attr("xlink:href", "#iD-logo-osm");
71566       let summaryDetail = row.append("td").attr("class", "cell-detail summary-detail");
71567       summaryDetail.append("a").attr("class", "cell-detail summary-view-on-osm").attr("target", "_blank").attr("href", changesetURL).call(_t.append("success.view_on_osm"));
71568       summaryDetail.append("div").html(_t.html("success.changeset_id", {
71569         changeset_id: { html: '<a href="'.concat(changesetURL, '" target="_blank">').concat(_changeset2.id, "</a>") }
71570       }));
71571       if (showDonationMessage !== false) {
71572         const donationUrl = "https://supporting.openstreetmap.org/";
71573         let supporting = body.append("div").attr("class", "save-supporting");
71574         supporting.append("h3").call(_t.append("success.supporting.title"));
71575         supporting.append("p").call(_t.append("success.supporting.details"));
71576         table = supporting.append("table").attr("class", "supporting-table");
71577         row = table.append("tr").attr("class", "supporting-row");
71578         row.append("td").attr("class", "cell-icon supporting-icon").append("a").attr("target", "_blank").attr("href", donationUrl).append("svg").attr("class", "logo-small").append("use").attr("xlink:href", "#iD-donation");
71579         let supportingDetail = row.append("td").attr("class", "cell-detail supporting-detail");
71580         supportingDetail.append("a").attr("class", "cell-detail support-the-map").attr("target", "_blank").attr("href", donationUrl).call(_t.append("success.supporting.donation.title"));
71581         supportingDetail.append("div").call(_t.append("success.supporting.donation.details"));
71582       }
71583       ensureOSMCommunityIndex().then((oci) => {
71584         const loc = context.map().center();
71585         const validHere = _sharedLocationManager.locationSetsAt(loc);
71586         let communities = [];
71587         oci.resources.forEach((resource) => {
71588           let area = validHere[resource.locationSetID];
71589           if (!area)
71590             return;
71591           const localizer = (stringID) => _t.html("community.".concat(stringID));
71592           resource.resolved = resolveStrings(resource, oci.defaults, localizer);
71593           communities.push({
71594             area,
71595             order: resource.order || 0,
71596             resource
71597           });
71598         });
71599         communities.sort((a2, b2) => a2.area - b2.area || b2.order - a2.order);
71600         body.call(showCommunityLinks, communities.map((c2) => c2.resource));
71601       });
71602     }
71603     function showCommunityLinks(selection2, resources) {
71604       let communityLinks = selection2.append("div").attr("class", "save-communityLinks");
71605       communityLinks.append("h3").call(_t.append("success.like_osm"));
71606       let table = communityLinks.append("table").attr("class", "community-table");
71607       let row = table.selectAll(".community-row").data(resources);
71608       let rowEnter = row.enter().append("tr").attr("class", "community-row");
71609       rowEnter.append("td").attr("class", "cell-icon community-icon").append("a").attr("target", "_blank").attr("href", (d2) => d2.resolved.url).append("svg").attr("class", "logo-small").append("use").attr("xlink:href", (d2) => "#community-".concat(d2.type));
71610       let communityDetail = rowEnter.append("td").attr("class", "cell-detail community-detail");
71611       communityDetail.each(showCommunityDetails);
71612       communityLinks.append("div").attr("class", "community-missing").call(_t.append("success.missing")).append("a").attr("class", "link-out").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/osmlab/osm-community-index/issues").append("span").call(_t.append("success.tell_us"));
71613     }
71614     function showCommunityDetails(d2) {
71615       let selection2 = select_default2(this);
71616       let communityID = d2.id;
71617       selection2.append("div").attr("class", "community-name").html(d2.resolved.nameHTML);
71618       selection2.append("div").attr("class", "community-description").html(d2.resolved.descriptionHTML);
71619       if (d2.resolved.extendedDescriptionHTML || d2.languageCodes && d2.languageCodes.length) {
71620         selection2.append("div").call(
71621           uiDisclosure(context, "community-more-".concat(d2.id), false).expanded(false).updatePreference(false).label(() => _t.append("success.more")).content(showMore)
71622         );
71623       }
71624       let nextEvents = (d2.events || []).map((event) => {
71625         event.date = parseEventDate(event.when);
71626         return event;
71627       }).filter((event) => {
71628         const t2 = event.date.getTime();
71629         const now3 = (/* @__PURE__ */ new Date()).setHours(0, 0, 0, 0);
71630         return !isNaN(t2) && t2 >= now3;
71631       }).sort((a2, b2) => {
71632         return a2.date < b2.date ? -1 : a2.date > b2.date ? 1 : 0;
71633       }).slice(0, MAXEVENTS);
71634       if (nextEvents.length) {
71635         selection2.append("div").call(
71636           uiDisclosure(context, "community-events-".concat(d2.id), false).expanded(false).updatePreference(false).label(_t.html("success.events")).content(showNextEvents)
71637         ).select(".hide-toggle").append("span").attr("class", "badge-text").text(nextEvents.length);
71638       }
71639       function showMore(selection3) {
71640         let more = selection3.selectAll(".community-more").data([0]);
71641         let moreEnter = more.enter().append("div").attr("class", "community-more");
71642         if (d2.resolved.extendedDescriptionHTML) {
71643           moreEnter.append("div").attr("class", "community-extended-description").html(d2.resolved.extendedDescriptionHTML);
71644         }
71645         if (d2.languageCodes && d2.languageCodes.length) {
71646           const languageList = d2.languageCodes.map((code) => _mainLocalizer.languageName(code)).join(", ");
71647           moreEnter.append("div").attr("class", "community-languages").call(_t.append("success.languages", { languages: languageList }));
71648         }
71649       }
71650       function showNextEvents(selection3) {
71651         let events = selection3.append("div").attr("class", "community-events");
71652         let item = events.selectAll(".community-event").data(nextEvents);
71653         let itemEnter = item.enter().append("div").attr("class", "community-event");
71654         itemEnter.append("div").attr("class", "community-event-name").append("a").attr("target", "_blank").attr("href", (d4) => d4.url).text((d4) => {
71655           let name = d4.name;
71656           if (d4.i18n && d4.id) {
71657             name = _t("community.".concat(communityID, ".events.").concat(d4.id, ".name"), { default: name });
71658           }
71659           return name;
71660         });
71661         itemEnter.append("div").attr("class", "community-event-when").text((d4) => {
71662           let options2 = { weekday: "short", day: "numeric", month: "short", year: "numeric" };
71663           if (d4.date.getHours() || d4.date.getMinutes()) {
71664             options2.hour = "numeric";
71665             options2.minute = "numeric";
71666           }
71667           return d4.date.toLocaleString(_mainLocalizer.localeCode(), options2);
71668         });
71669         itemEnter.append("div").attr("class", "community-event-where").text((d4) => {
71670           let where = d4.where;
71671           if (d4.i18n && d4.id) {
71672             where = _t("community.".concat(communityID, ".events.").concat(d4.id, ".where"), { default: where });
71673           }
71674           return where;
71675         });
71676         itemEnter.append("div").attr("class", "community-event-description").text((d4) => {
71677           let description = d4.description;
71678           if (d4.i18n && d4.id) {
71679             description = _t("community.".concat(communityID, ".events.").concat(d4.id, ".description"), { default: description });
71680           }
71681           return description;
71682         });
71683       }
71684     }
71685     success.changeset = function(val) {
71686       if (!arguments.length)
71687         return _changeset2;
71688       _changeset2 = val;
71689       return success;
71690     };
71691     success.location = function(val) {
71692       if (!arguments.length)
71693         return _location;
71694       _location = val;
71695       return success;
71696     };
71697     return utilRebind(success, dispatch14, "on");
71698   }
71699
71700   // modules/modes/save.js
71701   function modeSave(context) {
71702     var mode = { id: "save" };
71703     var keybinding = utilKeybinding("modeSave");
71704     var commit = uiCommit(context).on("cancel", cancel);
71705     var _conflictsUi;
71706     var _location;
71707     var _success;
71708     var uploader = context.uploader().on("saveStarted.modeSave", function() {
71709       keybindingOff();
71710     }).on("willAttemptUpload.modeSave", prepareForSuccess).on("progressChanged.modeSave", showProgress).on("resultNoChanges.modeSave", function() {
71711       cancel();
71712     }).on("resultErrors.modeSave", showErrors).on("resultConflicts.modeSave", showConflicts).on("resultSuccess.modeSave", showSuccess);
71713     function cancel() {
71714       context.enter(modeBrowse(context));
71715     }
71716     function showProgress(num, total) {
71717       var modal = context.container().select(".loading-modal .modal-section");
71718       var progress = modal.selectAll(".progress").data([0]);
71719       progress.enter().append("div").attr("class", "progress").merge(progress).text(_t("save.conflict_progress", { num, total }));
71720     }
71721     function showConflicts(changeset, conflicts, origChanges) {
71722       var selection2 = context.container().select(".sidebar").append("div").attr("class", "sidebar-component");
71723       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
71724       _conflictsUi = uiConflicts(context).conflictList(conflicts).origChanges(origChanges).on("cancel", function() {
71725         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
71726         selection2.remove();
71727         keybindingOn();
71728         uploader.cancelConflictResolution();
71729       }).on("save", function() {
71730         context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
71731         selection2.remove();
71732         uploader.processResolvedConflicts(changeset);
71733       });
71734       selection2.call(_conflictsUi);
71735     }
71736     function showErrors(errors) {
71737       keybindingOn();
71738       var selection2 = uiConfirm(context.container());
71739       selection2.select(".modal-section.header").append("h3").text(_t("save.error"));
71740       addErrors(selection2, errors);
71741       selection2.okButton();
71742     }
71743     function addErrors(selection2, data) {
71744       var message = selection2.select(".modal-section.message-text");
71745       var items = message.selectAll(".error-container").data(data);
71746       var enter = items.enter().append("div").attr("class", "error-container");
71747       enter.append("a").attr("class", "error-description").attr("href", "#").classed("hide-toggle", true).text(function(d2) {
71748         return d2.msg || _t("save.unknown_error_details");
71749       }).on("click", function(d3_event) {
71750         d3_event.preventDefault();
71751         var error = select_default2(this);
71752         var detail = select_default2(this.nextElementSibling);
71753         var exp2 = error.classed("expanded");
71754         detail.style("display", exp2 ? "none" : "block");
71755         error.classed("expanded", !exp2);
71756       });
71757       var details = enter.append("div").attr("class", "error-detail-container").style("display", "none");
71758       details.append("ul").attr("class", "error-detail-list").selectAll("li").data(function(d2) {
71759         return d2.details || [];
71760       }).enter().append("li").attr("class", "error-detail-item").text(function(d2) {
71761         return d2;
71762       });
71763       items.exit().remove();
71764     }
71765     function showSuccess(changeset) {
71766       commit.reset();
71767       var ui = _success.changeset(changeset).location(_location).on("cancel", function() {
71768         context.ui().sidebar.hide();
71769       });
71770       context.enter(modeBrowse(context).sidebar(ui));
71771     }
71772     function keybindingOn() {
71773       select_default2(document).call(keybinding.on("\u238B", cancel, true));
71774     }
71775     function keybindingOff() {
71776       select_default2(document).call(keybinding.unbind);
71777     }
71778     function prepareForSuccess() {
71779       _success = uiSuccess(context);
71780       _location = null;
71781       if (!services.geocoder)
71782         return;
71783       services.geocoder.reverse(context.map().center(), function(err, result) {
71784         if (err || !result || !result.address)
71785           return;
71786         var addr = result.address;
71787         var place = addr && (addr.town || addr.city || addr.county) || "";
71788         var region = addr && (addr.state || addr.country) || "";
71789         var separator = place && region ? _t("success.thank_you_where.separator") : "";
71790         _location = _t(
71791           "success.thank_you_where.format",
71792           { place, separator, region }
71793         );
71794       });
71795     }
71796     mode.selectedIDs = function() {
71797       return _conflictsUi ? _conflictsUi.shownEntityIds() : [];
71798     };
71799     mode.enter = function() {
71800       context.ui().sidebar.expand();
71801       function done() {
71802         context.ui().sidebar.show(commit);
71803       }
71804       keybindingOn();
71805       context.container().selectAll(".main-content").classed("active", false).classed("inactive", true);
71806       var osm = context.connection();
71807       if (!osm) {
71808         cancel();
71809         return;
71810       }
71811       if (osm.authenticated()) {
71812         done();
71813       } else {
71814         osm.authenticate(function(err) {
71815           if (err) {
71816             cancel();
71817           } else {
71818             done();
71819           }
71820         });
71821       }
71822     };
71823     mode.exit = function() {
71824       keybindingOff();
71825       context.container().selectAll(".main-content").classed("active", true).classed("inactive", false);
71826       context.ui().sidebar.hide();
71827     };
71828     return mode;
71829   }
71830
71831   // modules/ui/improveOSM_comments.js
71832   function uiImproveOsmComments() {
71833     let _qaItem;
71834     function issueComments(selection2) {
71835       let comments = selection2.selectAll(".comments-container").data([0]);
71836       comments = comments.enter().append("div").attr("class", "comments-container").merge(comments);
71837       services.improveOSM.getComments(_qaItem).then((d2) => {
71838         if (!d2.comments)
71839           return;
71840         const commentEnter = comments.selectAll(".comment").data(d2.comments).enter().append("div").attr("class", "comment");
71841         commentEnter.append("div").attr("class", "comment-avatar").call(svgIcon("#iD-icon-avatar", "comment-avatar-icon"));
71842         const mainEnter = commentEnter.append("div").attr("class", "comment-main");
71843         const metadataEnter = mainEnter.append("div").attr("class", "comment-metadata");
71844         metadataEnter.append("div").attr("class", "comment-author").each(function(d4) {
71845           const osm = services.osm;
71846           let selection3 = select_default2(this);
71847           if (osm && d4.username) {
71848             selection3 = selection3.append("a").attr("class", "comment-author-link").attr("href", osm.userURL(d4.username)).attr("target", "_blank");
71849           }
71850           selection3.text((d5) => d5.username);
71851         });
71852         metadataEnter.append("div").attr("class", "comment-date").html((d4) => _t.html("note.status.commented", { when: localeDateString2(d4.timestamp) }));
71853         mainEnter.append("div").attr("class", "comment-text").append("p").text((d4) => d4.text);
71854       }).catch((err) => {
71855         console.log(err);
71856       });
71857     }
71858     function localeDateString2(s2) {
71859       if (!s2)
71860         return null;
71861       const options2 = { day: "numeric", month: "short", year: "numeric" };
71862       const d2 = new Date(s2 * 1e3);
71863       if (isNaN(d2.getTime()))
71864         return null;
71865       return d2.toLocaleDateString(_mainLocalizer.localeCode(), options2);
71866     }
71867     issueComments.issue = function(val) {
71868       if (!arguments.length)
71869         return _qaItem;
71870       _qaItem = val;
71871       return issueComments;
71872     };
71873     return issueComments;
71874   }
71875
71876   // modules/ui/improveOSM_details.js
71877   function uiImproveOsmDetails(context) {
71878     let _qaItem;
71879     function issueDetail(d2) {
71880       if (d2.desc)
71881         return d2.desc;
71882       const issueKey = d2.issueKey;
71883       d2.replacements = d2.replacements || {};
71884       d2.replacements.default = { html: _t.html("inspector.unknown") };
71885       return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".description"), d2.replacements);
71886     }
71887     function improveOsmDetails(selection2) {
71888       const details = selection2.selectAll(".error-details").data(
71889         _qaItem ? [_qaItem] : [],
71890         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
71891       );
71892       details.exit().remove();
71893       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
71894       const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
71895       descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
71896       descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
71897       let relatedEntities = [];
71898       descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
71899         const link3 = select_default2(this);
71900         const isObjectLink = link3.classed("error_object_link");
71901         const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
71902         const entity = context.hasEntity(entityID);
71903         relatedEntities.push(entityID);
71904         link3.on("mouseenter", () => {
71905           utilHighlightEntities([entityID], true, context);
71906         }).on("mouseleave", () => {
71907           utilHighlightEntities([entityID], false, context);
71908         }).on("click", (d3_event) => {
71909           d3_event.preventDefault();
71910           utilHighlightEntities([entityID], false, context);
71911           const osmlayer = context.layers().layer("osm");
71912           if (!osmlayer.enabled()) {
71913             osmlayer.enabled(true);
71914           }
71915           context.map().centerZoom(_qaItem.loc, 20);
71916           if (entity) {
71917             context.enter(modeSelect(context, [entityID]));
71918           } else {
71919             context.loadEntity(entityID, (err, result) => {
71920               if (err)
71921                 return;
71922               const entity2 = result.data.find((e3) => e3.id === entityID);
71923               if (entity2)
71924                 context.enter(modeSelect(context, [entityID]));
71925             });
71926           }
71927         });
71928         if (entity) {
71929           let name = utilDisplayName(entity);
71930           if (!name && !isObjectLink) {
71931             const preset = _mainPresetIndex.match(entity, context.graph());
71932             name = preset && !preset.isFallback() && preset.name();
71933           }
71934           if (name) {
71935             this.innerText = name;
71936           }
71937         }
71938       });
71939       context.features().forceVisible(relatedEntities);
71940       context.map().pan([0, 0]);
71941     }
71942     improveOsmDetails.issue = function(val) {
71943       if (!arguments.length)
71944         return _qaItem;
71945       _qaItem = val;
71946       return improveOsmDetails;
71947     };
71948     return improveOsmDetails;
71949   }
71950
71951   // modules/ui/improveOSM_header.js
71952   function uiImproveOsmHeader() {
71953     let _qaItem;
71954     function issueTitle(d2) {
71955       const issueKey = d2.issueKey;
71956       d2.replacements = d2.replacements || {};
71957       d2.replacements.default = { html: _t.html("inspector.unknown") };
71958       return _t.html("QA.improveOSM.error_types.".concat(issueKey, ".title"), d2.replacements);
71959     }
71960     function improveOsmHeader(selection2) {
71961       const header = selection2.selectAll(".qa-header").data(
71962         _qaItem ? [_qaItem] : [],
71963         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
71964       );
71965       header.exit().remove();
71966       const headerEnter = header.enter().append("div").attr("class", "qa-header");
71967       const svgEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0).append("svg").attr("width", "20px").attr("height", "30px").attr("viewbox", "0 0 20 30").attr("class", (d2) => "preset-icon-28 qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
71968       svgEnter.append("polygon").attr("fill", "currentColor").attr("class", "qaItem-fill").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6");
71969       svgEnter.append("use").attr("class", "icon-annotation").attr("width", "12px").attr("height", "12px").attr("transform", "translate(4, 5.5)").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : "");
71970       headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
71971     }
71972     improveOsmHeader.issue = function(val) {
71973       if (!arguments.length)
71974         return _qaItem;
71975       _qaItem = val;
71976       return improveOsmHeader;
71977     };
71978     return improveOsmHeader;
71979   }
71980
71981   // modules/ui/improveOSM_editor.js
71982   function uiImproveOsmEditor(context) {
71983     const dispatch14 = dispatch_default("change");
71984     const qaDetails = uiImproveOsmDetails(context);
71985     const qaComments = uiImproveOsmComments(context);
71986     const qaHeader = uiImproveOsmHeader(context);
71987     let _qaItem;
71988     function improveOsmEditor(selection2) {
71989       const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
71990       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
71991       headerEnter.append("h2").call(_t.append("QA.improveOSM.title"));
71992       let body = selection2.selectAll(".body").data([0]);
71993       body = body.enter().append("div").attr("class", "body").merge(body);
71994       const editor = body.selectAll(".qa-editor").data([0]);
71995       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(qaComments.issue(_qaItem)).call(improveOsmSaveSection);
71996     }
71997     function improveOsmSaveSection(selection2) {
71998       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
71999       const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
72000       let saveSection = selection2.selectAll(".qa-save").data(
72001         isShown ? [_qaItem] : [],
72002         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72003       );
72004       saveSection.exit().remove();
72005       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
72006       saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("note.newComment"));
72007       saveSectionEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("QA.keepRight.comment_placeholder")).attr("maxlength", 1e3).property("value", (d2) => d2.newComment).call(utilNoAuto).on("input", changeInput).on("blur", changeInput);
72008       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
72009       function changeInput() {
72010         const input = select_default2(this);
72011         let val = input.property("value").trim();
72012         if (val === "") {
72013           val = void 0;
72014         }
72015         _qaItem = _qaItem.update({ newComment: val });
72016         const qaService = services.improveOSM;
72017         if (qaService) {
72018           qaService.replaceItem(_qaItem);
72019         }
72020         saveSection.call(qaSaveButtons);
72021       }
72022     }
72023     function qaSaveButtons(selection2) {
72024       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72025       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
72026       buttonSection.exit().remove();
72027       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
72028       buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
72029       buttonEnter.append("button").attr("class", "button close-button action");
72030       buttonEnter.append("button").attr("class", "button ignore-button action");
72031       buttonSection = buttonSection.merge(buttonEnter);
72032       buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
72033         this.blur();
72034         const qaService = services.improveOSM;
72035         if (qaService) {
72036           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72037         }
72038       });
72039       buttonSection.select(".close-button").html((d2) => {
72040         const andComment = d2.newComment ? "_comment" : "";
72041         return _t.html("QA.keepRight.close".concat(andComment));
72042       }).on("click.close", function(d3_event, d2) {
72043         this.blur();
72044         const qaService = services.improveOSM;
72045         if (qaService) {
72046           d2.newStatus = "SOLVED";
72047           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72048         }
72049       });
72050       buttonSection.select(".ignore-button").html((d2) => {
72051         const andComment = d2.newComment ? "_comment" : "";
72052         return _t.html("QA.keepRight.ignore".concat(andComment));
72053       }).on("click.ignore", function(d3_event, d2) {
72054         this.blur();
72055         const qaService = services.improveOSM;
72056         if (qaService) {
72057           d2.newStatus = "INVALID";
72058           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72059         }
72060       });
72061     }
72062     improveOsmEditor.error = function(val) {
72063       if (!arguments.length)
72064         return _qaItem;
72065       _qaItem = val;
72066       return improveOsmEditor;
72067     };
72068     return utilRebind(improveOsmEditor, dispatch14, "on");
72069   }
72070
72071   // modules/ui/keepRight_details.js
72072   function uiKeepRightDetails(context) {
72073     let _qaItem;
72074     function issueDetail(d2) {
72075       const { itemType, parentIssueType } = d2;
72076       const unknown = { html: _t.html("inspector.unknown") };
72077       let replacements = d2.replacements || {};
72078       replacements.default = unknown;
72079       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
72080         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".description"), replacements);
72081       } else {
72082         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".description"), replacements);
72083       }
72084     }
72085     function keepRightDetails(selection2) {
72086       const details = selection2.selectAll(".error-details").data(
72087         _qaItem ? [_qaItem] : [],
72088         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72089       );
72090       details.exit().remove();
72091       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
72092       const descriptionEnter = detailsEnter.append("div").attr("class", "qa-details-subsection");
72093       descriptionEnter.append("h4").call(_t.append("QA.keepRight.detail_description"));
72094       descriptionEnter.append("div").attr("class", "qa-details-description-text").html(issueDetail);
72095       let relatedEntities = [];
72096       descriptionEnter.selectAll(".error_entity_link, .error_object_link").attr("href", "#").each(function() {
72097         const link3 = select_default2(this);
72098         const isObjectLink = link3.classed("error_object_link");
72099         const entityID = isObjectLink ? utilEntityRoot(_qaItem.objectType) + _qaItem.objectId : this.textContent;
72100         const entity = context.hasEntity(entityID);
72101         relatedEntities.push(entityID);
72102         link3.on("mouseenter", () => {
72103           utilHighlightEntities([entityID], true, context);
72104         }).on("mouseleave", () => {
72105           utilHighlightEntities([entityID], false, context);
72106         }).on("click", (d3_event) => {
72107           d3_event.preventDefault();
72108           utilHighlightEntities([entityID], false, context);
72109           const osmlayer = context.layers().layer("osm");
72110           if (!osmlayer.enabled()) {
72111             osmlayer.enabled(true);
72112           }
72113           context.map().centerZoomEase(_qaItem.loc, 20);
72114           if (entity) {
72115             context.enter(modeSelect(context, [entityID]));
72116           } else {
72117             context.loadEntity(entityID, (err, result) => {
72118               if (err)
72119                 return;
72120               const entity2 = result.data.find((e3) => e3.id === entityID);
72121               if (entity2)
72122                 context.enter(modeSelect(context, [entityID]));
72123             });
72124           }
72125         });
72126         if (entity) {
72127           let name = utilDisplayName(entity);
72128           if (!name && !isObjectLink) {
72129             const preset = _mainPresetIndex.match(entity, context.graph());
72130             name = preset && !preset.isFallback() && preset.name();
72131           }
72132           if (name) {
72133             this.innerText = name;
72134           }
72135         }
72136       });
72137       context.features().forceVisible(relatedEntities);
72138       context.map().pan([0, 0]);
72139     }
72140     keepRightDetails.issue = function(val) {
72141       if (!arguments.length)
72142         return _qaItem;
72143       _qaItem = val;
72144       return keepRightDetails;
72145     };
72146     return keepRightDetails;
72147   }
72148
72149   // modules/ui/keepRight_header.js
72150   function uiKeepRightHeader() {
72151     let _qaItem;
72152     function issueTitle(d2) {
72153       const { itemType, parentIssueType } = d2;
72154       const unknown = _t.html("inspector.unknown");
72155       let replacements = d2.replacements || {};
72156       replacements.default = { html: unknown };
72157       if (_mainLocalizer.hasTextForStringId("QA.keepRight.errorTypes.".concat(itemType, ".title"))) {
72158         return _t.html("QA.keepRight.errorTypes.".concat(itemType, ".title"), replacements);
72159       } else {
72160         return _t.html("QA.keepRight.errorTypes.".concat(parentIssueType, ".title"), replacements);
72161       }
72162     }
72163     function keepRightHeader(selection2) {
72164       const header = selection2.selectAll(".qa-header").data(
72165         _qaItem ? [_qaItem] : [],
72166         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72167       );
72168       header.exit().remove();
72169       const headerEnter = header.enter().append("div").attr("class", "qa-header");
72170       const iconEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0);
72171       iconEnter.append("div").attr("class", (d2) => "preset-icon-28 qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.parentIssueType)).call(svgIcon("#iD-icon-bolt", "qaItem-fill"));
72172       headerEnter.append("div").attr("class", "qa-header-label").html(issueTitle);
72173     }
72174     keepRightHeader.issue = function(val) {
72175       if (!arguments.length)
72176         return _qaItem;
72177       _qaItem = val;
72178       return keepRightHeader;
72179     };
72180     return keepRightHeader;
72181   }
72182
72183   // modules/ui/view_on_keepRight.js
72184   function uiViewOnKeepRight() {
72185     let _qaItem;
72186     function viewOnKeepRight(selection2) {
72187       let url;
72188       if (services.keepRight && _qaItem instanceof QAItem) {
72189         url = services.keepRight.issueURL(_qaItem);
72190       }
72191       const link3 = selection2.selectAll(".view-on-keepRight").data(url ? [url] : []);
72192       link3.exit().remove();
72193       const linkEnter = link3.enter().append("a").attr("class", "view-on-keepRight").attr("target", "_blank").attr("rel", "noopener").attr("href", (d2) => d2).call(svgIcon("#iD-icon-out-link", "inline"));
72194       linkEnter.append("span").call(_t.append("inspector.view_on_keepRight"));
72195     }
72196     viewOnKeepRight.what = function(val) {
72197       if (!arguments.length)
72198         return _qaItem;
72199       _qaItem = val;
72200       return viewOnKeepRight;
72201     };
72202     return viewOnKeepRight;
72203   }
72204
72205   // modules/ui/keepRight_editor.js
72206   function uiKeepRightEditor(context) {
72207     const dispatch14 = dispatch_default("change");
72208     const qaDetails = uiKeepRightDetails(context);
72209     const qaHeader = uiKeepRightHeader(context);
72210     let _qaItem;
72211     function keepRightEditor(selection2) {
72212       const headerEnter = selection2.selectAll(".header").data([0]).enter().append("div").attr("class", "header fillL");
72213       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
72214       headerEnter.append("h2").call(_t.append("QA.keepRight.title"));
72215       let body = selection2.selectAll(".body").data([0]);
72216       body = body.enter().append("div").attr("class", "body").merge(body);
72217       const editor = body.selectAll(".qa-editor").data([0]);
72218       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(keepRightSaveSection);
72219       const footer = selection2.selectAll(".footer").data([0]);
72220       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnKeepRight(context).what(_qaItem));
72221     }
72222     function keepRightSaveSection(selection2) {
72223       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72224       const isShown = _qaItem && (isSelected || _qaItem.newComment || _qaItem.comment);
72225       let saveSection = selection2.selectAll(".qa-save").data(
72226         isShown ? [_qaItem] : [],
72227         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72228       );
72229       saveSection.exit().remove();
72230       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
72231       saveSectionEnter.append("h4").attr("class", ".qa-save-header").call(_t.append("QA.keepRight.comment"));
72232       saveSectionEnter.append("textarea").attr("class", "new-comment-input").attr("placeholder", _t("QA.keepRight.comment_placeholder")).attr("maxlength", 1e3).property("value", (d2) => d2.newComment || d2.comment).call(utilNoAuto).on("input", changeInput).on("blur", changeInput);
72233       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
72234       function changeInput() {
72235         const input = select_default2(this);
72236         let val = input.property("value").trim();
72237         if (val === _qaItem.comment) {
72238           val = void 0;
72239         }
72240         _qaItem = _qaItem.update({ newComment: val });
72241         const qaService = services.keepRight;
72242         if (qaService) {
72243           qaService.replaceItem(_qaItem);
72244         }
72245         saveSection.call(qaSaveButtons);
72246       }
72247     }
72248     function qaSaveButtons(selection2) {
72249       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72250       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
72251       buttonSection.exit().remove();
72252       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
72253       buttonEnter.append("button").attr("class", "button comment-button action").call(_t.append("QA.keepRight.save_comment"));
72254       buttonEnter.append("button").attr("class", "button close-button action");
72255       buttonEnter.append("button").attr("class", "button ignore-button action");
72256       buttonSection = buttonSection.merge(buttonEnter);
72257       buttonSection.select(".comment-button").attr("disabled", (d2) => d2.newComment ? null : true).on("click.comment", function(d3_event, d2) {
72258         this.blur();
72259         const qaService = services.keepRight;
72260         if (qaService) {
72261           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72262         }
72263       });
72264       buttonSection.select(".close-button").html((d2) => {
72265         const andComment = d2.newComment ? "_comment" : "";
72266         return _t.html("QA.keepRight.close".concat(andComment));
72267       }).on("click.close", function(d3_event, d2) {
72268         this.blur();
72269         const qaService = services.keepRight;
72270         if (qaService) {
72271           d2.newStatus = "ignore_t";
72272           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72273         }
72274       });
72275       buttonSection.select(".ignore-button").html((d2) => {
72276         const andComment = d2.newComment ? "_comment" : "";
72277         return _t.html("QA.keepRight.ignore".concat(andComment));
72278       }).on("click.ignore", function(d3_event, d2) {
72279         this.blur();
72280         const qaService = services.keepRight;
72281         if (qaService) {
72282           d2.newStatus = "ignore";
72283           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72284         }
72285       });
72286     }
72287     keepRightEditor.error = function(val) {
72288       if (!arguments.length)
72289         return _qaItem;
72290       _qaItem = val;
72291       return keepRightEditor;
72292     };
72293     return utilRebind(keepRightEditor, dispatch14, "on");
72294   }
72295
72296   // modules/ui/osmose_details.js
72297   function uiOsmoseDetails(context) {
72298     let _qaItem;
72299     function issueString(d2, type2) {
72300       if (!d2)
72301         return "";
72302       const s2 = services.osmose.getStrings(d2.itemType);
72303       return type2 in s2 ? s2[type2] : "";
72304     }
72305     function osmoseDetails(selection2) {
72306       const details = selection2.selectAll(".error-details").data(
72307         _qaItem ? [_qaItem] : [],
72308         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72309       );
72310       details.exit().remove();
72311       const detailsEnter = details.enter().append("div").attr("class", "error-details qa-details-container");
72312       if (issueString(_qaItem, "detail")) {
72313         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
72314         div.append("h4").call(_t.append("QA.keepRight.detail_description"));
72315         div.append("p").attr("class", "qa-details-description-text").html((d2) => issueString(d2, "detail")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72316       }
72317       const detailsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
72318       const elemsDiv = detailsEnter.append("div").attr("class", "qa-details-subsection");
72319       if (issueString(_qaItem, "fix")) {
72320         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
72321         div.append("h4").call(_t.append("QA.osmose.fix_title"));
72322         div.append("p").html((d2) => issueString(d2, "fix")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72323       }
72324       if (issueString(_qaItem, "trap")) {
72325         const div = detailsEnter.append("div").attr("class", "qa-details-subsection");
72326         div.append("h4").call(_t.append("QA.osmose.trap_title"));
72327         div.append("p").html((d2) => issueString(d2, "trap")).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72328       }
72329       const thisItem = _qaItem;
72330       services.osmose.loadIssueDetail(_qaItem).then((d2) => {
72331         if (!d2.elems || d2.elems.length === 0)
72332           return;
72333         if (context.selectedErrorID() !== thisItem.id && context.container().selectAll(".qaItem.osmose.hover.itemId-".concat(thisItem.id)).empty())
72334           return;
72335         if (d2.detail) {
72336           detailsDiv.append("h4").call(_t.append("QA.osmose.detail_title"));
72337           detailsDiv.append("p").html((d4) => d4.detail).selectAll("a").attr("rel", "noopener").attr("target", "_blank");
72338         }
72339         elemsDiv.append("h4").call(_t.append("QA.osmose.elems_title"));
72340         elemsDiv.append("ul").selectAll("li").data(d2.elems).enter().append("li").append("a").attr("href", "#").attr("class", "error_entity_link").text((d4) => d4).each(function() {
72341           const link3 = select_default2(this);
72342           const entityID = this.textContent;
72343           const entity = context.hasEntity(entityID);
72344           link3.on("mouseenter", () => {
72345             utilHighlightEntities([entityID], true, context);
72346           }).on("mouseleave", () => {
72347             utilHighlightEntities([entityID], false, context);
72348           }).on("click", (d3_event) => {
72349             d3_event.preventDefault();
72350             utilHighlightEntities([entityID], false, context);
72351             const osmlayer = context.layers().layer("osm");
72352             if (!osmlayer.enabled()) {
72353               osmlayer.enabled(true);
72354             }
72355             context.map().centerZoom(d2.loc, 20);
72356             if (entity) {
72357               context.enter(modeSelect(context, [entityID]));
72358             } else {
72359               context.loadEntity(entityID, (err, result) => {
72360                 if (err)
72361                   return;
72362                 const entity2 = result.data.find((e3) => e3.id === entityID);
72363                 if (entity2)
72364                   context.enter(modeSelect(context, [entityID]));
72365               });
72366             }
72367           });
72368           if (entity) {
72369             let name = utilDisplayName(entity);
72370             if (!name) {
72371               const preset = _mainPresetIndex.match(entity, context.graph());
72372               name = preset && !preset.isFallback() && preset.name();
72373             }
72374             if (name) {
72375               this.innerText = name;
72376             }
72377           }
72378         });
72379         context.features().forceVisible(d2.elems);
72380         context.map().pan([0, 0]);
72381       }).catch((err) => {
72382         console.log(err);
72383       });
72384     }
72385     osmoseDetails.issue = function(val) {
72386       if (!arguments.length)
72387         return _qaItem;
72388       _qaItem = val;
72389       return osmoseDetails;
72390     };
72391     return osmoseDetails;
72392   }
72393
72394   // modules/ui/osmose_header.js
72395   function uiOsmoseHeader() {
72396     let _qaItem;
72397     function issueTitle(d2) {
72398       const unknown = _t("inspector.unknown");
72399       if (!d2)
72400         return unknown;
72401       const s2 = services.osmose.getStrings(d2.itemType);
72402       return "title" in s2 ? s2.title : unknown;
72403     }
72404     function osmoseHeader(selection2) {
72405       const header = selection2.selectAll(".qa-header").data(
72406         _qaItem ? [_qaItem] : [],
72407         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72408       );
72409       header.exit().remove();
72410       const headerEnter = header.enter().append("div").attr("class", "qa-header");
72411       const svgEnter = headerEnter.append("div").attr("class", "qa-header-icon").classed("new", (d2) => d2.id < 0).append("svg").attr("width", "20px").attr("height", "30px").attr("viewbox", "0 0 20 30").attr("class", (d2) => "preset-icon-28 qaItem ".concat(d2.service, " itemId-").concat(d2.id, " itemType-").concat(d2.itemType));
72412       svgEnter.append("polygon").attr("fill", (d2) => services.osmose.getColor(d2.item)).attr("class", "qaItem-fill").attr("points", "16,3 4,3 1,6 1,17 4,20 7,20 10,27 13,20 16,20 19,17.033 19,6");
72413       svgEnter.append("use").attr("class", "icon-annotation").attr("width", "12px").attr("height", "12px").attr("transform", "translate(4, 5.5)").attr("xlink:href", (d2) => d2.icon ? "#" + d2.icon : "");
72414       headerEnter.append("div").attr("class", "qa-header-label").text(issueTitle);
72415     }
72416     osmoseHeader.issue = function(val) {
72417       if (!arguments.length)
72418         return _qaItem;
72419       _qaItem = val;
72420       return osmoseHeader;
72421     };
72422     return osmoseHeader;
72423   }
72424
72425   // modules/ui/view_on_osmose.js
72426   function uiViewOnOsmose() {
72427     let _qaItem;
72428     function viewOnOsmose(selection2) {
72429       let url;
72430       if (services.osmose && _qaItem instanceof QAItem) {
72431         url = services.osmose.itemURL(_qaItem);
72432       }
72433       const link3 = selection2.selectAll(".view-on-osmose").data(url ? [url] : []);
72434       link3.exit().remove();
72435       const linkEnter = link3.enter().append("a").attr("class", "view-on-osmose").attr("target", "_blank").attr("rel", "noopener").attr("href", (d2) => d2).call(svgIcon("#iD-icon-out-link", "inline"));
72436       linkEnter.append("span").call(_t.append("inspector.view_on_osmose"));
72437     }
72438     viewOnOsmose.what = function(val) {
72439       if (!arguments.length)
72440         return _qaItem;
72441       _qaItem = val;
72442       return viewOnOsmose;
72443     };
72444     return viewOnOsmose;
72445   }
72446
72447   // modules/ui/osmose_editor.js
72448   function uiOsmoseEditor(context) {
72449     const dispatch14 = dispatch_default("change");
72450     const qaDetails = uiOsmoseDetails(context);
72451     const qaHeader = uiOsmoseHeader(context);
72452     let _qaItem;
72453     function osmoseEditor(selection2) {
72454       const header = selection2.selectAll(".header").data([0]);
72455       const headerEnter = header.enter().append("div").attr("class", "header fillL");
72456       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", () => context.enter(modeBrowse(context))).call(svgIcon("#iD-icon-close"));
72457       headerEnter.append("h2").call(_t.append("QA.osmose.title"));
72458       let body = selection2.selectAll(".body").data([0]);
72459       body = body.enter().append("div").attr("class", "body").merge(body);
72460       let editor = body.selectAll(".qa-editor").data([0]);
72461       editor.enter().append("div").attr("class", "modal-section qa-editor").merge(editor).call(qaHeader.issue(_qaItem)).call(qaDetails.issue(_qaItem)).call(osmoseSaveSection);
72462       const footer = selection2.selectAll(".footer").data([0]);
72463       footer.enter().append("div").attr("class", "footer").merge(footer).call(uiViewOnOsmose(context).what(_qaItem));
72464     }
72465     function osmoseSaveSection(selection2) {
72466       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72467       const isShown = _qaItem && isSelected;
72468       let saveSection = selection2.selectAll(".qa-save").data(
72469         isShown ? [_qaItem] : [],
72470         (d2) => "".concat(d2.id, "-").concat(d2.status || 0)
72471       );
72472       saveSection.exit().remove();
72473       const saveSectionEnter = saveSection.enter().append("div").attr("class", "qa-save save-section cf");
72474       saveSection = saveSectionEnter.merge(saveSection).call(qaSaveButtons);
72475     }
72476     function qaSaveButtons(selection2) {
72477       const isSelected = _qaItem && _qaItem.id === context.selectedErrorID();
72478       let buttonSection = selection2.selectAll(".buttons").data(isSelected ? [_qaItem] : [], (d2) => d2.status + d2.id);
72479       buttonSection.exit().remove();
72480       const buttonEnter = buttonSection.enter().append("div").attr("class", "buttons");
72481       buttonEnter.append("button").attr("class", "button close-button action");
72482       buttonEnter.append("button").attr("class", "button ignore-button action");
72483       buttonSection = buttonSection.merge(buttonEnter);
72484       buttonSection.select(".close-button").call(_t.append("QA.keepRight.close")).on("click.close", function(d3_event, d2) {
72485         this.blur();
72486         const qaService = services.osmose;
72487         if (qaService) {
72488           d2.newStatus = "done";
72489           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72490         }
72491       });
72492       buttonSection.select(".ignore-button").call(_t.append("QA.keepRight.ignore")).on("click.ignore", function(d3_event, d2) {
72493         this.blur();
72494         const qaService = services.osmose;
72495         if (qaService) {
72496           d2.newStatus = "false";
72497           qaService.postUpdate(d2, (err, item) => dispatch14.call("change", item));
72498         }
72499       });
72500     }
72501     osmoseEditor.error = function(val) {
72502       if (!arguments.length)
72503         return _qaItem;
72504       _qaItem = val;
72505       return osmoseEditor;
72506     };
72507     return utilRebind(osmoseEditor, dispatch14, "on");
72508   }
72509
72510   // modules/modes/select_error.js
72511   function modeSelectError(context, selectedErrorID, selectedErrorService) {
72512     var mode = {
72513       id: "select-error",
72514       button: "browse"
72515     };
72516     var keybinding = utilKeybinding("select-error");
72517     var errorService = services[selectedErrorService];
72518     var errorEditor;
72519     switch (selectedErrorService) {
72520       case "improveOSM":
72521         errorEditor = uiImproveOsmEditor(context).on("change", function() {
72522           context.map().pan([0, 0]);
72523           var error = checkSelectedID();
72524           if (!error)
72525             return;
72526           context.ui().sidebar.show(errorEditor.error(error));
72527         });
72528         break;
72529       case "keepRight":
72530         errorEditor = uiKeepRightEditor(context).on("change", function() {
72531           context.map().pan([0, 0]);
72532           var error = checkSelectedID();
72533           if (!error)
72534             return;
72535           context.ui().sidebar.show(errorEditor.error(error));
72536         });
72537         break;
72538       case "osmose":
72539         errorEditor = uiOsmoseEditor(context).on("change", function() {
72540           context.map().pan([0, 0]);
72541           var error = checkSelectedID();
72542           if (!error)
72543             return;
72544           context.ui().sidebar.show(errorEditor.error(error));
72545         });
72546         break;
72547     }
72548     var behaviors = [
72549       behaviorBreathe(context),
72550       behaviorHover(context),
72551       behaviorSelect(context),
72552       behaviorLasso(context),
72553       modeDragNode(context).behavior,
72554       modeDragNote(context).behavior
72555     ];
72556     function checkSelectedID() {
72557       if (!errorService)
72558         return;
72559       var error = errorService.getError(selectedErrorID);
72560       if (!error) {
72561         context.enter(modeBrowse(context));
72562       }
72563       return error;
72564     }
72565     mode.zoomToSelected = function() {
72566       if (!errorService)
72567         return;
72568       var error = errorService.getError(selectedErrorID);
72569       if (error) {
72570         context.map().centerZoomEase(error.loc, 20);
72571       }
72572     };
72573     mode.enter = function() {
72574       var error = checkSelectedID();
72575       if (!error)
72576         return;
72577       behaviors.forEach(context.install);
72578       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
72579       select_default2(document).call(keybinding);
72580       selectError();
72581       var sidebar = context.ui().sidebar;
72582       sidebar.show(errorEditor.error(error));
72583       context.map().on("drawn.select-error", selectError);
72584       function selectError(d3_event, drawn) {
72585         if (!checkSelectedID())
72586           return;
72587         var selection2 = context.surface().selectAll(".itemId-" + selectedErrorID + "." + selectedErrorService);
72588         if (selection2.empty()) {
72589           var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
72590           if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
72591             context.enter(modeBrowse(context));
72592           }
72593         } else {
72594           selection2.classed("selected", true);
72595           context.selectedErrorID(selectedErrorID);
72596         }
72597       }
72598       function esc() {
72599         if (context.container().select(".combobox").size())
72600           return;
72601         context.enter(modeBrowse(context));
72602       }
72603     };
72604     mode.exit = function() {
72605       behaviors.forEach(context.uninstall);
72606       select_default2(document).call(keybinding.unbind);
72607       context.surface().selectAll(".qaItem.selected").classed("selected hover", false);
72608       context.map().on("drawn.select-error", null);
72609       context.ui().sidebar.hide();
72610       context.selectedErrorID(null);
72611       context.features().forceVisible([]);
72612     };
72613     return mode;
72614   }
72615
72616   // modules/ui/feature_list.js
72617   function uiFeatureList(context) {
72618     var _geocodeResults;
72619     function featureList(selection2) {
72620       var header = selection2.append("div").attr("class", "header fillL");
72621       header.append("h2").call(_t.append("inspector.feature_list"));
72622       var searchWrap = selection2.append("div").attr("class", "search-header");
72623       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
72624       var search = searchWrap.append("input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keypress", keypress).on("keydown", keydown).on("input", inputevent);
72625       var listWrap = selection2.append("div").attr("class", "inspector-body");
72626       var list2 = listWrap.append("div").attr("class", "feature-list");
72627       context.on("exit.feature-list", clearSearch);
72628       context.map().on("drawn.feature-list", mapDrawn);
72629       context.keybinding().on(uiCmd("\u2318F"), focusSearch);
72630       function focusSearch(d3_event) {
72631         var mode = context.mode() && context.mode().id;
72632         if (mode !== "browse")
72633           return;
72634         d3_event.preventDefault();
72635         search.node().focus();
72636       }
72637       function keydown(d3_event) {
72638         if (d3_event.keyCode === 27) {
72639           search.node().blur();
72640         }
72641       }
72642       function keypress(d3_event) {
72643         var q2 = search.property("value"), items = list2.selectAll(".feature-list-item");
72644         if (d3_event.keyCode === 13 && // ↩ Return
72645         q2.length && items.size()) {
72646           click(d3_event, items.datum());
72647         }
72648       }
72649       function inputevent() {
72650         _geocodeResults = void 0;
72651         drawList();
72652       }
72653       function clearSearch() {
72654         search.property("value", "");
72655         drawList();
72656       }
72657       function mapDrawn(e3) {
72658         if (e3.full) {
72659           drawList();
72660         }
72661       }
72662       function features() {
72663         var result = [];
72664         var graph = context.graph();
72665         var visibleCenter = context.map().extent().center();
72666         var q2 = search.property("value").toLowerCase();
72667         if (!q2)
72668           return result;
72669         var locationMatch = sexagesimal.pair(q2.toUpperCase()) || dmsMatcher(q2);
72670         if (locationMatch) {
72671           var loc = [Number(locationMatch[0]), Number(locationMatch[1])];
72672           result.push({
72673             id: -1,
72674             geometry: "point",
72675             type: _t("inspector.location"),
72676             name: dmsCoordinatePair([loc[1], loc[0]]),
72677             location: loc
72678           });
72679         }
72680         var idMatch = !locationMatch && q2.match(/(?:^|\W)(node|way|relation|note|[nwr])\W{0,2}0*([1-9]\d*)(?:\W|$)/i);
72681         if (idMatch) {
72682           var elemType = idMatch[1] === "note" ? idMatch[1] : idMatch[1].charAt(0);
72683           var elemId = idMatch[2];
72684           result.push({
72685             id: elemType + elemId,
72686             geometry: elemType === "n" ? "point" : elemType === "w" ? "line" : elemType === "note" ? "note" : "relation",
72687             type: elemType === "n" ? _t("inspector.node") : elemType === "w" ? _t("inspector.way") : elemType === "note" ? _t("note.note") : _t("inspector.relation"),
72688             name: elemId
72689           });
72690         }
72691         var allEntities = graph.entities;
72692         var localResults = [];
72693         for (var id2 in allEntities) {
72694           var entity = allEntities[id2];
72695           if (!entity)
72696             continue;
72697           var name = utilDisplayName(entity) || "";
72698           if (name.toLowerCase().indexOf(q2) < 0)
72699             continue;
72700           var matched = _mainPresetIndex.match(entity, graph);
72701           var type2 = matched && matched.name() || utilDisplayType(entity.id);
72702           var extent = entity.extent(graph);
72703           var distance = extent ? geoSphericalDistance(visibleCenter, extent.center()) : 0;
72704           localResults.push({
72705             id: entity.id,
72706             entity,
72707             geometry: entity.geometry(graph),
72708             type: type2,
72709             name,
72710             distance
72711           });
72712           if (localResults.length > 100)
72713             break;
72714         }
72715         localResults = localResults.sort(function byDistance(a2, b2) {
72716           return a2.distance - b2.distance;
72717         });
72718         result = result.concat(localResults);
72719         (_geocodeResults || []).forEach(function(d2) {
72720           if (d2.osm_type && d2.osm_id) {
72721             var id3 = osmEntity.id.fromOSM(d2.osm_type, d2.osm_id);
72722             var tags = {};
72723             tags[d2.class] = d2.type;
72724             var attrs = { id: id3, type: d2.osm_type, tags };
72725             if (d2.osm_type === "way") {
72726               attrs.nodes = ["a", "a"];
72727             }
72728             var tempEntity = osmEntity(attrs);
72729             var tempGraph = coreGraph([tempEntity]);
72730             var matched2 = _mainPresetIndex.match(tempEntity, tempGraph);
72731             var type3 = matched2 && matched2.name() || utilDisplayType(id3);
72732             result.push({
72733               id: tempEntity.id,
72734               geometry: tempEntity.geometry(tempGraph),
72735               type: type3,
72736               name: d2.display_name,
72737               extent: new geoExtent(
72738                 [Number(d2.boundingbox[3]), Number(d2.boundingbox[0])],
72739                 [Number(d2.boundingbox[2]), Number(d2.boundingbox[1])]
72740               )
72741             });
72742           }
72743         });
72744         if (q2.match(/^[0-9]+$/)) {
72745           result.push({
72746             id: "n" + q2,
72747             geometry: "point",
72748             type: _t("inspector.node"),
72749             name: q2
72750           });
72751           result.push({
72752             id: "w" + q2,
72753             geometry: "line",
72754             type: _t("inspector.way"),
72755             name: q2
72756           });
72757           result.push({
72758             id: "r" + q2,
72759             geometry: "relation",
72760             type: _t("inspector.relation"),
72761             name: q2
72762           });
72763           result.push({
72764             id: "note" + q2,
72765             geometry: "note",
72766             type: _t("note.note"),
72767             name: q2
72768           });
72769         }
72770         return result;
72771       }
72772       function drawList() {
72773         var value = search.property("value");
72774         var results = features();
72775         list2.classed("filtered", value.length);
72776         var resultsIndicator = list2.selectAll(".no-results-item").data([0]).enter().append("button").property("disabled", true).attr("class", "no-results-item").call(svgIcon("#iD-icon-alert", "pre-text"));
72777         resultsIndicator.append("span").attr("class", "entity-name");
72778         list2.selectAll(".no-results-item .entity-name").html("").call(_t.append("geocoder.no_results_worldwide"));
72779         if (services.geocoder) {
72780           list2.selectAll(".geocode-item").data([0]).enter().append("button").attr("class", "geocode-item secondary-action").on("click", geocoderSearch).append("div").attr("class", "label").append("span").attr("class", "entity-name").call(_t.append("geocoder.search"));
72781         }
72782         list2.selectAll(".no-results-item").style("display", value.length && !results.length ? "block" : "none");
72783         list2.selectAll(".geocode-item").style("display", value && _geocodeResults === void 0 ? "block" : "none");
72784         list2.selectAll(".feature-list-item").data([-1]).remove();
72785         var items = list2.selectAll(".feature-list-item").data(results, function(d2) {
72786           return d2.id;
72787         });
72788         var enter = items.enter().insert("button", ".geocode-item").attr("class", "feature-list-item").on("mouseover", mouseover).on("mouseout", mouseout).on("click", click);
72789         var label = enter.append("div").attr("class", "label");
72790         label.each(function(d2) {
72791           select_default2(this).call(svgIcon("#iD-icon-" + d2.geometry, "pre-text"));
72792         });
72793         label.append("span").attr("class", "entity-type").text(function(d2) {
72794           return d2.type;
72795         });
72796         label.append("span").attr("class", "entity-name").classed("has-colour", (d2) => d2.entity && d2.entity.type === "relation" && d2.entity.tags.colour && isColourValid(d2.entity.tags.colour)).style("border-color", (d2) => d2.entity && d2.entity.type === "relation" && d2.entity.tags.colour).text(function(d2) {
72797           return d2.name;
72798         });
72799         enter.style("opacity", 0).transition().style("opacity", 1);
72800         items.order();
72801         items.exit().remove();
72802       }
72803       function mouseover(d3_event, d2) {
72804         if (d2.id === -1)
72805           return;
72806         utilHighlightEntities([d2.id], true, context);
72807       }
72808       function mouseout(d3_event, d2) {
72809         if (d2.id === -1)
72810           return;
72811         utilHighlightEntities([d2.id], false, context);
72812       }
72813       function click(d3_event, d2) {
72814         d3_event.preventDefault();
72815         if (d2.location) {
72816           context.map().centerZoomEase([d2.location[1], d2.location[0]], 19);
72817         } else if (d2.entity) {
72818           utilHighlightEntities([d2.id], false, context);
72819           context.enter(modeSelect(context, [d2.entity.id]));
72820           context.map().zoomToEase(d2.entity);
72821         } else if (d2.geometry === "note") {
72822           const noteId = d2.id.replace(/\D/g, "");
72823           context.loadNote(noteId, (err, result) => {
72824             if (err)
72825               return;
72826             const entity = result.data.find((e3) => e3.id === noteId);
72827             if (entity) {
72828               const note = services.osm.getNote(noteId);
72829               context.map().centerZoom(note.loc, 15);
72830               const noteLayer = context.layers().layer("notes");
72831               noteLayer.enabled(true);
72832               context.enter(modeSelectNote(context, noteId));
72833             }
72834           });
72835         } else {
72836           context.zoomToEntity(d2.id);
72837         }
72838       }
72839       function geocoderSearch() {
72840         services.geocoder.search(search.property("value"), function(err, resp) {
72841           _geocodeResults = resp || [];
72842           drawList();
72843         });
72844       }
72845     }
72846     return featureList;
72847   }
72848
72849   // modules/ui/preset_list.js
72850   function uiPresetList(context) {
72851     var dispatch14 = dispatch_default("cancel", "choose");
72852     var _entityIDs;
72853     var _currLoc;
72854     var _currentPresets;
72855     var _autofocus = false;
72856     function presetList(selection2) {
72857       if (!_entityIDs)
72858         return;
72859       var presets = _mainPresetIndex.matchAllGeometry(entityGeometries());
72860       selection2.html("");
72861       var messagewrap = selection2.append("div").attr("class", "header fillL");
72862       var message = messagewrap.append("h2").call(_t.append("inspector.choose"));
72863       var direction = _mainLocalizer.textDirection() === "rtl" ? "backward" : "forward";
72864       messagewrap.append("button").attr("class", "preset-choose").attr("title", _entityIDs.length === 1 ? _t("inspector.edit") : _t("inspector.edit_features")).on("click", function() {
72865         dispatch14.call("cancel", this);
72866       }).call(svgIcon("#iD-icon-".concat(direction)));
72867       function initialKeydown(d3_event) {
72868         if (search.property("value").length === 0 && (d3_event.keyCode === utilKeybinding.keyCodes["\u232B"] || d3_event.keyCode === utilKeybinding.keyCodes["\u2326"])) {
72869           d3_event.preventDefault();
72870           d3_event.stopPropagation();
72871           operationDelete(context, _entityIDs)();
72872         } else if (search.property("value").length === 0 && (d3_event.ctrlKey || d3_event.metaKey) && d3_event.keyCode === utilKeybinding.keyCodes.z) {
72873           d3_event.preventDefault();
72874           d3_event.stopPropagation();
72875           context.undo();
72876         } else if (!d3_event.ctrlKey && !d3_event.metaKey) {
72877           select_default2(this).on("keydown", keydown);
72878           keydown.call(this, d3_event);
72879         }
72880       }
72881       function keydown(d3_event) {
72882         if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"] && // if insertion point is at the end of the string
72883         search.node().selectionStart === search.property("value").length) {
72884           d3_event.preventDefault();
72885           d3_event.stopPropagation();
72886           var buttons = list2.selectAll(".preset-list-button");
72887           if (!buttons.empty())
72888             buttons.nodes()[0].focus();
72889         }
72890       }
72891       function keypress(d3_event) {
72892         var value = search.property("value");
72893         if (d3_event.keyCode === 13 && // ↩ Return
72894         value.length) {
72895           list2.selectAll(".preset-list-item:first-child").each(function(d2) {
72896             d2.choose.call(this);
72897           });
72898         }
72899       }
72900       function inputevent() {
72901         var value = search.property("value");
72902         list2.classed("filtered", value.length);
72903         var results, messageText;
72904         if (value.length) {
72905           results = presets.search(value, entityGeometries()[0], _currLoc);
72906           messageText = _t.html("inspector.results", {
72907             n: results.collection.length,
72908             search: value
72909           });
72910         } else {
72911           var entityPresets2 = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
72912           results = _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets2);
72913           messageText = _t.html("inspector.choose");
72914         }
72915         list2.call(drawList, results);
72916         message.html(messageText);
72917       }
72918       var searchWrap = selection2.append("div").attr("class", "search-header");
72919       searchWrap.call(svgIcon("#iD-icon-search", "pre-text"));
72920       var search = searchWrap.append("input").attr("class", "preset-search-input").attr("placeholder", _t("inspector.search")).attr("type", "search").call(utilNoAuto).on("keydown", initialKeydown).on("keypress", keypress).on("input", debounce_default(inputevent));
72921       if (_autofocus) {
72922         search.node().focus();
72923         setTimeout(function() {
72924           search.node().focus();
72925         }, 0);
72926       }
72927       var listWrap = selection2.append("div").attr("class", "inspector-body");
72928       var entityPresets = _entityIDs.map((entityID) => _mainPresetIndex.match(context.graph().entity(entityID), context.graph()));
72929       var list2 = listWrap.append("div").attr("class", "preset-list").call(drawList, _mainPresetIndex.defaults(entityGeometries()[0], 36, !context.inIntro(), _currLoc, entityPresets));
72930       context.features().on("change.preset-list", updateForFeatureHiddenState);
72931     }
72932     function drawList(list2, presets) {
72933       presets = presets.matchAllGeometry(entityGeometries());
72934       var collection = presets.collection.reduce(function(collection2, preset) {
72935         if (!preset)
72936           return collection2;
72937         if (preset.members) {
72938           if (preset.members.collection.filter(function(preset2) {
72939             return preset2.addable();
72940           }).length > 1) {
72941             collection2.push(CategoryItem(preset));
72942           }
72943         } else if (preset.addable()) {
72944           collection2.push(PresetItem(preset));
72945         }
72946         return collection2;
72947       }, []);
72948       var items = list2.selectAll(".preset-list-item").data(collection, function(d2) {
72949         return d2.preset.id;
72950       });
72951       items.order();
72952       items.exit().remove();
72953       items.enter().append("div").attr("class", function(item) {
72954         return "preset-list-item preset-" + item.preset.id.replace("/", "-");
72955       }).classed("current", function(item) {
72956         return _currentPresets.indexOf(item.preset) !== -1;
72957       }).each(function(item) {
72958         select_default2(this).call(item);
72959       }).style("opacity", 0).transition().style("opacity", 1);
72960       updateForFeatureHiddenState();
72961     }
72962     function itemKeydown(d3_event) {
72963       var item = select_default2(this.closest(".preset-list-item"));
72964       var parentItem = select_default2(item.node().parentNode.closest(".preset-list-item"));
72965       if (d3_event.keyCode === utilKeybinding.keyCodes["\u2193"]) {
72966         d3_event.preventDefault();
72967         d3_event.stopPropagation();
72968         var nextItem = select_default2(item.node().nextElementSibling);
72969         if (nextItem.empty()) {
72970           if (!parentItem.empty()) {
72971             nextItem = select_default2(parentItem.node().nextElementSibling);
72972           }
72973         } else if (select_default2(this).classed("expanded")) {
72974           nextItem = item.select(".subgrid .preset-list-item:first-child");
72975         }
72976         if (!nextItem.empty()) {
72977           nextItem.select(".preset-list-button").node().focus();
72978         }
72979       } else if (d3_event.keyCode === utilKeybinding.keyCodes["\u2191"]) {
72980         d3_event.preventDefault();
72981         d3_event.stopPropagation();
72982         var previousItem = select_default2(item.node().previousElementSibling);
72983         if (previousItem.empty()) {
72984           if (!parentItem.empty()) {
72985             previousItem = parentItem;
72986           }
72987         } else if (previousItem.select(".preset-list-button").classed("expanded")) {
72988           previousItem = previousItem.select(".subgrid .preset-list-item:last-child");
72989         }
72990         if (!previousItem.empty()) {
72991           previousItem.select(".preset-list-button").node().focus();
72992         } else {
72993           var search = select_default2(this.closest(".preset-list-pane")).select(".preset-search-input");
72994           search.node().focus();
72995         }
72996       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
72997         d3_event.preventDefault();
72998         d3_event.stopPropagation();
72999         if (!parentItem.empty()) {
73000           parentItem.select(".preset-list-button").node().focus();
73001         }
73002       } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
73003         d3_event.preventDefault();
73004         d3_event.stopPropagation();
73005         item.datum().choose.call(select_default2(this).node());
73006       }
73007     }
73008     function CategoryItem(preset) {
73009       var box, sublist, shown = false;
73010       function item(selection2) {
73011         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap category");
73012         function click() {
73013           var isExpanded = select_default2(this).classed("expanded");
73014           var iconName = isExpanded ? _mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward" : "#iD-icon-down";
73015           select_default2(this).classed("expanded", !isExpanded).attr("title", !isExpanded ? _t("icons.collapse") : _t("icons.expand"));
73016           select_default2(this).selectAll("div.label-inner svg.icon use").attr("href", iconName);
73017           item.choose();
73018         }
73019         var geometries = entityGeometries();
73020         var button = wrap2.append("button").attr("class", "preset-list-button").attr("title", _t("icons.expand")).classed("expanded", false).call(uiPresetIcon().geometry(geometries.length === 1 && geometries[0]).preset(preset)).on("click", click).on("keydown", function(d3_event) {
73021           if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2190" : "\u2192"]) {
73022             d3_event.preventDefault();
73023             d3_event.stopPropagation();
73024             if (!select_default2(this).classed("expanded")) {
73025               click.call(this, d3_event);
73026             }
73027           } else if (d3_event.keyCode === utilKeybinding.keyCodes[_mainLocalizer.textDirection() === "rtl" ? "\u2192" : "\u2190"]) {
73028             d3_event.preventDefault();
73029             d3_event.stopPropagation();
73030             if (select_default2(this).classed("expanded")) {
73031               click.call(this, d3_event);
73032             }
73033           } else {
73034             itemKeydown.call(this, d3_event);
73035           }
73036         });
73037         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
73038         label.append("div").attr("class", "namepart").call(svgIcon(_mainLocalizer.textDirection() === "rtl" ? "#iD-icon-backward" : "#iD-icon-forward", "inline")).append("span").call(preset.nameLabel()).append("span").text("\u2026");
73039         box = selection2.append("div").attr("class", "subgrid").style("max-height", "0px").style("opacity", 0);
73040         box.append("div").attr("class", "arrow");
73041         sublist = box.append("div").attr("class", "preset-list fillL3");
73042       }
73043       item.choose = function() {
73044         if (!box || !sublist)
73045           return;
73046         if (shown) {
73047           shown = false;
73048           box.transition().duration(200).style("opacity", "0").style("max-height", "0px").style("padding-bottom", "0px");
73049         } else {
73050           shown = true;
73051           var members = preset.members.matchAllGeometry(entityGeometries());
73052           sublist.call(drawList, members);
73053           box.transition().duration(200).style("opacity", "1").style("max-height", 200 + members.collection.length * 190 + "px").style("padding-bottom", "10px");
73054         }
73055       };
73056       item.preset = preset;
73057       return item;
73058     }
73059     function PresetItem(preset) {
73060       function item(selection2) {
73061         var wrap2 = selection2.append("div").attr("class", "preset-list-button-wrap");
73062         var geometries = entityGeometries();
73063         var button = wrap2.append("button").attr("class", "preset-list-button").call(uiPresetIcon().geometry(geometries.length === 1 && geometries[0]).preset(preset)).on("click", item.choose).on("keydown", itemKeydown);
73064         var label = button.append("div").attr("class", "label").append("div").attr("class", "label-inner");
73065         var nameparts = [
73066           preset.nameLabel(),
73067           preset.subtitleLabel()
73068         ].filter(Boolean);
73069         label.selectAll(".namepart").data(nameparts, (d2) => d2.stringId).enter().append("div").attr("class", "namepart").text("").each(function(d2) {
73070           d2(select_default2(this));
73071         });
73072         wrap2.call(item.reference.button);
73073         selection2.call(item.reference.body);
73074       }
73075       item.choose = function() {
73076         if (select_default2(this).classed("disabled"))
73077           return;
73078         if (!context.inIntro()) {
73079           _mainPresetIndex.setMostRecent(preset, entityGeometries()[0]);
73080         }
73081         context.perform(
73082           function(graph) {
73083             for (var i3 in _entityIDs) {
73084               var entityID = _entityIDs[i3];
73085               var oldPreset = _mainPresetIndex.match(graph.entity(entityID), graph);
73086               graph = actionChangePreset(entityID, oldPreset, preset)(graph);
73087             }
73088             return graph;
73089           },
73090           _t("operations.change_tags.annotation")
73091         );
73092         context.validator().validate();
73093         dispatch14.call("choose", this, preset);
73094       };
73095       item.help = function(d3_event) {
73096         d3_event.stopPropagation();
73097         item.reference.toggle();
73098       };
73099       item.preset = preset;
73100       item.reference = uiTagReference(preset.reference(), context);
73101       return item;
73102     }
73103     function updateForFeatureHiddenState() {
73104       if (!_entityIDs.every(context.hasEntity))
73105         return;
73106       var geometries = entityGeometries();
73107       var button = context.container().selectAll(".preset-list .preset-list-button");
73108       button.call(uiTooltip().destroyAny);
73109       button.each(function(item, index) {
73110         var hiddenPresetFeaturesId;
73111         for (var i3 in geometries) {
73112           hiddenPresetFeaturesId = context.features().isHiddenPreset(item.preset, geometries[i3]);
73113           if (hiddenPresetFeaturesId)
73114             break;
73115         }
73116         var isHiddenPreset = !context.inIntro() && !!hiddenPresetFeaturesId && (_currentPresets.length !== 1 || item.preset !== _currentPresets[0]);
73117         select_default2(this).classed("disabled", isHiddenPreset);
73118         if (isHiddenPreset) {
73119           var isAutoHidden = context.features().autoHidden(hiddenPresetFeaturesId);
73120           select_default2(this).call(
73121             uiTooltip().title(() => _t.append("inspector.hidden_preset." + (isAutoHidden ? "zoom" : "manual"), {
73122               features: _t("feature." + hiddenPresetFeaturesId + ".description")
73123             })).placement(index < 2 ? "bottom" : "top")
73124           );
73125         }
73126       });
73127     }
73128     presetList.autofocus = function(val) {
73129       if (!arguments.length)
73130         return _autofocus;
73131       _autofocus = val;
73132       return presetList;
73133     };
73134     presetList.entityIDs = function(val) {
73135       if (!arguments.length)
73136         return _entityIDs;
73137       _entityIDs = val;
73138       _currLoc = null;
73139       if (_entityIDs && _entityIDs.length) {
73140         const extent = _entityIDs.reduce(function(extent2, entityID) {
73141           var entity = context.graph().entity(entityID);
73142           return extent2.extend(entity.extent(context.graph()));
73143         }, geoExtent());
73144         _currLoc = extent.center();
73145         var presets = _entityIDs.map(function(entityID) {
73146           return _mainPresetIndex.match(context.entity(entityID), context.graph());
73147         });
73148         presetList.presets(presets);
73149       }
73150       return presetList;
73151     };
73152     presetList.presets = function(val) {
73153       if (!arguments.length)
73154         return _currentPresets;
73155       _currentPresets = val;
73156       return presetList;
73157     };
73158     function entityGeometries() {
73159       var counts = {};
73160       for (var i3 in _entityIDs) {
73161         var entityID = _entityIDs[i3];
73162         var entity = context.entity(entityID);
73163         var geometry = entity.geometry(context.graph());
73164         if (geometry === "vertex" && entity.isOnAddressLine(context.graph())) {
73165           geometry = "point";
73166         }
73167         if (!counts[geometry])
73168           counts[geometry] = 0;
73169         counts[geometry] += 1;
73170       }
73171       return Object.keys(counts).sort(function(geom1, geom2) {
73172         return counts[geom2] - counts[geom1];
73173       });
73174     }
73175     return utilRebind(presetList, dispatch14, "on");
73176   }
73177
73178   // modules/ui/inspector.js
73179   function uiInspector(context) {
73180     var presetList = uiPresetList(context);
73181     var entityEditor = uiEntityEditor(context);
73182     var wrap2 = select_default2(null), presetPane = select_default2(null), editorPane = select_default2(null);
73183     var _state = "select";
73184     var _entityIDs;
73185     var _newFeature = false;
73186     function inspector(selection2) {
73187       presetList.entityIDs(_entityIDs).autofocus(_newFeature).on("choose", inspector.setPreset).on("cancel", function() {
73188         inspector.setPreset();
73189       });
73190       entityEditor.state(_state).entityIDs(_entityIDs).on("choose", inspector.showList);
73191       wrap2 = selection2.selectAll(".panewrap").data([0]);
73192       var enter = wrap2.enter().append("div").attr("class", "panewrap");
73193       enter.append("div").attr("class", "preset-list-pane pane");
73194       enter.append("div").attr("class", "entity-editor-pane pane");
73195       wrap2 = wrap2.merge(enter);
73196       presetPane = wrap2.selectAll(".preset-list-pane");
73197       editorPane = wrap2.selectAll(".entity-editor-pane");
73198       function shouldDefaultToPresetList() {
73199         if (_state !== "select")
73200           return false;
73201         if (_entityIDs.length !== 1)
73202           return false;
73203         var entityID = _entityIDs[0];
73204         var entity = context.hasEntity(entityID);
73205         if (!entity)
73206           return false;
73207         if (entity.hasNonGeometryTags())
73208           return false;
73209         if (_newFeature)
73210           return true;
73211         if (entity.geometry(context.graph()) !== "vertex")
73212           return false;
73213         if (context.graph().parentRelations(entity).length)
73214           return false;
73215         if (context.validator().getEntityIssues(entityID).length)
73216           return false;
73217         if (entity.isHighwayIntersection(context.graph()))
73218           return false;
73219         return true;
73220       }
73221       if (shouldDefaultToPresetList()) {
73222         wrap2.style("right", "-100%");
73223         editorPane.classed("hide", true);
73224         presetPane.classed("hide", false).call(presetList);
73225       } else {
73226         wrap2.style("right", "0%");
73227         presetPane.classed("hide", true);
73228         editorPane.classed("hide", false).call(entityEditor);
73229       }
73230       var footer = selection2.selectAll(".footer").data([0]);
73231       footer = footer.enter().append("div").attr("class", "footer").merge(footer);
73232       footer.call(
73233         uiViewOnOSM(context).what(context.hasEntity(_entityIDs.length === 1 && _entityIDs[0]))
73234       );
73235     }
73236     inspector.showList = function(presets) {
73237       presetPane.classed("hide", false);
73238       wrap2.transition().styleTween("right", function() {
73239         return value_default("0%", "-100%");
73240       }).on("end", function() {
73241         editorPane.classed("hide", true);
73242       });
73243       if (presets) {
73244         presetList.presets(presets);
73245       }
73246       presetPane.call(presetList.autofocus(true));
73247     };
73248     inspector.setPreset = function(preset) {
73249       if (preset && preset.id === "type/multipolygon") {
73250         presetPane.call(presetList.autofocus(true));
73251       } else {
73252         editorPane.classed("hide", false);
73253         wrap2.transition().styleTween("right", function() {
73254           return value_default("-100%", "0%");
73255         }).on("end", function() {
73256           presetPane.classed("hide", true);
73257         });
73258         if (preset) {
73259           entityEditor.presets([preset]);
73260         }
73261         editorPane.call(entityEditor);
73262       }
73263     };
73264     inspector.state = function(val) {
73265       if (!arguments.length)
73266         return _state;
73267       _state = val;
73268       entityEditor.state(_state);
73269       context.container().selectAll(".field-help-body").remove();
73270       return inspector;
73271     };
73272     inspector.entityIDs = function(val) {
73273       if (!arguments.length)
73274         return _entityIDs;
73275       _entityIDs = val;
73276       return inspector;
73277     };
73278     inspector.newFeature = function(val) {
73279       if (!arguments.length)
73280         return _newFeature;
73281       _newFeature = val;
73282       return inspector;
73283     };
73284     return inspector;
73285   }
73286
73287   // modules/ui/lasso.js
73288   function uiLasso(context) {
73289     var group, polygon2;
73290     lasso.coordinates = [];
73291     function lasso(selection2) {
73292       context.container().classed("lasso", true);
73293       group = selection2.append("g").attr("class", "lasso hide");
73294       polygon2 = group.append("path").attr("class", "lasso-path");
73295       group.call(uiToggle(true));
73296     }
73297     function draw() {
73298       if (polygon2) {
73299         polygon2.data([lasso.coordinates]).attr("d", function(d2) {
73300           return "M" + d2.join(" L") + " Z";
73301         });
73302       }
73303     }
73304     lasso.extent = function() {
73305       return lasso.coordinates.reduce(function(extent, point2) {
73306         return extent.extend(geoExtent(point2));
73307       }, geoExtent());
73308     };
73309     lasso.p = function(_2) {
73310       if (!arguments.length)
73311         return lasso;
73312       lasso.coordinates.push(_2);
73313       draw();
73314       return lasso;
73315     };
73316     lasso.close = function() {
73317       if (group) {
73318         group.call(uiToggle(false, function() {
73319           select_default2(this).remove();
73320         }));
73321       }
73322       context.container().classed("lasso", false);
73323     };
73324     return lasso;
73325   }
73326
73327   // modules/ui/source_switch.js
73328   function uiSourceSwitch(context) {
73329     var keys2;
73330     function click(d3_event) {
73331       d3_event.preventDefault();
73332       var osm = context.connection();
73333       if (!osm)
73334         return;
73335       if (context.inIntro())
73336         return;
73337       if (context.history().hasChanges() && !window.confirm(_t("source_switch.lose_changes")))
73338         return;
73339       var isLive = select_default2(this).classed("live");
73340       isLive = !isLive;
73341       context.enter(modeBrowse(context));
73342       context.history().clearSaved();
73343       context.flush();
73344       select_default2(this).html(isLive ? _t.html("source_switch.live") : _t.html("source_switch.dev")).classed("live", isLive).classed("chip", isLive);
73345       osm.switch(isLive ? keys2[0] : keys2[1]);
73346     }
73347     var sourceSwitch = function(selection2) {
73348       selection2.append("a").attr("href", "#").call(_t.append("source_switch.live")).attr("class", "live chip").on("click", click);
73349     };
73350     sourceSwitch.keys = function(_2) {
73351       if (!arguments.length)
73352         return keys2;
73353       keys2 = _2;
73354       return sourceSwitch;
73355     };
73356     return sourceSwitch;
73357   }
73358
73359   // modules/ui/spinner.js
73360   function uiSpinner(context) {
73361     var osm = context.connection();
73362     return function(selection2) {
73363       var img = selection2.append("img").attr("src", context.imagePath("loader-black.gif")).style("opacity", 0);
73364       if (osm) {
73365         osm.on("loading.spinner", function() {
73366           img.transition().style("opacity", 1);
73367         }).on("loaded.spinner", function() {
73368           img.transition().style("opacity", 0);
73369         });
73370       }
73371     };
73372   }
73373
73374   // modules/ui/sections/privacy.js
73375   function uiSectionPrivacy(context) {
73376     let section = uiSection("preferences-third-party", context).label(() => _t.append("preferences.privacy.title")).disclosureContent(renderDisclosureContent);
73377     function renderDisclosureContent(selection2) {
73378       selection2.selectAll(".privacy-options-list").data([0]).enter().append("ul").attr("class", "layer-list privacy-options-list");
73379       let thirdPartyIconsEnter = selection2.select(".privacy-options-list").selectAll(".privacy-third-party-icons-item").data([corePreferences("preferences.privacy.thirdpartyicons") || "true"]).enter().append("li").attr("class", "privacy-third-party-icons-item").append("label").call(
73380         uiTooltip().title(() => _t.append("preferences.privacy.third_party_icons.tooltip")).placement("bottom")
73381       );
73382       thirdPartyIconsEnter.append("input").attr("type", "checkbox").on("change", (d3_event, d2) => {
73383         d3_event.preventDefault();
73384         corePreferences("preferences.privacy.thirdpartyicons", d2 === "true" ? "false" : "true");
73385       });
73386       thirdPartyIconsEnter.append("span").call(_t.append("preferences.privacy.third_party_icons.description"));
73387       selection2.selectAll(".privacy-third-party-icons-item").classed("active", (d2) => d2 === "true").select("input").property("checked", (d2) => d2 === "true");
73388       selection2.selectAll(".privacy-link").data([0]).enter().append("div").attr("class", "privacy-link").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/openstreetmap/iD/blob/release/PRIVACY.md").append("span").call(_t.append("preferences.privacy.privacy_link"));
73389     }
73390     corePreferences.onChange("preferences.privacy.thirdpartyicons", section.reRender);
73391     return section;
73392   }
73393
73394   // modules/ui/splash.js
73395   function uiSplash(context) {
73396     return (selection2) => {
73397       if (context.history().hasRestorableChanges())
73398         return;
73399       let updateMessage = "";
73400       const sawPrivacyVersion = corePreferences("sawPrivacyVersion");
73401       let showSplash = !corePreferences("sawSplash");
73402       if (sawPrivacyVersion !== context.privacyVersion) {
73403         updateMessage = _t("splash.privacy_update");
73404         showSplash = true;
73405       }
73406       if (!showSplash)
73407         return;
73408       corePreferences("sawSplash", true);
73409       corePreferences("sawPrivacyVersion", context.privacyVersion);
73410       _mainFileFetcher.get("intro_graph");
73411       let modalSelection = uiModal(selection2);
73412       modalSelection.select(".modal").attr("class", "modal-splash modal");
73413       let introModal = modalSelection.select(".content").append("div").attr("class", "fillL");
73414       introModal.append("div").attr("class", "modal-section").append("h3").call(_t.append("splash.welcome"));
73415       let modalSection = introModal.append("div").attr("class", "modal-section");
73416       modalSection.append("p").html(_t.html("splash.text", {
73417         version: context.version,
73418         website: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/develop/CHANGELOG.md#whats-new">' + _t.html("splash.changelog") + "</a>" },
73419         github: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/issues">github.com</a>' }
73420       }));
73421       modalSection.append("p").html(_t.html("splash.privacy", {
73422         updateMessage,
73423         privacyLink: { html: '<a target="_blank" href="https://github.com/openstreetmap/iD/blob/release/PRIVACY.md">' + _t("splash.privacy_policy") + "</a>" }
73424       }));
73425       uiSectionPrivacy(context).label(() => _t.append("splash.privacy_settings")).render(modalSection);
73426       let buttonWrap = introModal.append("div").attr("class", "modal-actions");
73427       let walkthrough = buttonWrap.append("button").attr("class", "walkthrough").on("click", () => {
73428         context.container().call(uiIntro(context));
73429         modalSelection.close();
73430       });
73431       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
73432       walkthrough.append("div").call(_t.append("splash.walkthrough"));
73433       let startEditing = buttonWrap.append("button").attr("class", "start-editing").on("click", modalSelection.close);
73434       startEditing.append("svg").attr("class", "logo logo-features").append("use").attr("xlink:href", "#iD-logo-features");
73435       startEditing.append("div").call(_t.append("splash.start"));
73436       modalSelection.select("button.close").attr("class", "hide");
73437     };
73438   }
73439
73440   // modules/ui/status.js
73441   function uiStatus(context) {
73442     var osm = context.connection();
73443     return function(selection2) {
73444       if (!osm)
73445         return;
73446       function update(err, apiStatus) {
73447         selection2.html("");
73448         if (err) {
73449           if (apiStatus === "connectionSwitched") {
73450             return;
73451           } else if (apiStatus === "rateLimited") {
73452             selection2.call(_t.append("osm_api_status.message.rateLimit")).append("a").attr("href", "#").attr("class", "api-status-login").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).append("span").call(_t.append("login")).on("click.login", function(d3_event) {
73453               d3_event.preventDefault();
73454               osm.authenticate();
73455             });
73456           } else {
73457             var throttledRetry = throttle_default(function() {
73458               context.loadTiles(context.projection);
73459               osm.reloadApiStatus();
73460             }, 2e3);
73461             selection2.call(_t.append("osm_api_status.message.error", { suffix: " " })).append("a").attr("href", "#").call(_t.append("osm_api_status.retry")).on("click.retry", function(d3_event) {
73462               d3_event.preventDefault();
73463               throttledRetry();
73464             });
73465           }
73466         } else if (apiStatus === "readonly") {
73467           selection2.call(_t.append("osm_api_status.message.readonly"));
73468         } else if (apiStatus === "offline") {
73469           selection2.call(_t.append("osm_api_status.message.offline"));
73470         }
73471         selection2.attr("class", "api-status " + (err ? "error" : apiStatus));
73472       }
73473       osm.on("apiStatusChange.uiStatus", update);
73474       context.history().on("storage_error", () => {
73475         selection2.selectAll("span.local-storage-full").remove();
73476         selection2.append("span").attr("class", "local-storage-full").call(_t.append("osm_api_status.message.local_storage_full"));
73477         selection2.classed("error", true);
73478       });
73479       window.setInterval(function() {
73480         osm.reloadApiStatus();
73481       }, 9e4);
73482       osm.reloadApiStatus();
73483     };
73484   }
73485
73486   // modules/ui/version.js
73487   var sawVersion = null;
73488   var isNewVersion = false;
73489   var isNewUser = false;
73490   function uiVersion(context) {
73491     var currVersion = context.version;
73492     var matchedVersion = currVersion.match(/\d+\.\d+\.\d+.*/);
73493     if (sawVersion === null && matchedVersion !== null) {
73494       if (corePreferences("sawVersion")) {
73495         isNewUser = false;
73496         isNewVersion = corePreferences("sawVersion") !== currVersion && currVersion.indexOf("-") === -1;
73497       } else {
73498         isNewUser = true;
73499         isNewVersion = true;
73500       }
73501       corePreferences("sawVersion", currVersion);
73502       sawVersion = currVersion;
73503     }
73504     return function(selection2) {
73505       selection2.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD").text(currVersion);
73506       if (isNewVersion && !isNewUser) {
73507         selection2.append("a").attr("class", "badge").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD/blob/release/CHANGELOG.md#whats-new").call(svgIcon("#maki-gift")).call(
73508           uiTooltip().title(() => _t.append("version.whats_new", { version: currVersion })).placement("top").scrollContainer(context.container().select(".main-footer-wrap"))
73509         );
73510       }
73511     };
73512   }
73513
73514   // modules/ui/zoom.js
73515   function uiZoom(context) {
73516     var zooms = [{
73517       id: "zoom-in",
73518       icon: "iD-icon-plus",
73519       title: _t.append("zoom.in"),
73520       action: zoomIn,
73521       disabled: function() {
73522         return !context.map().canZoomIn();
73523       },
73524       disabledTitle: _t.append("zoom.disabled.in"),
73525       key: "+"
73526     }, {
73527       id: "zoom-out",
73528       icon: "iD-icon-minus",
73529       title: _t.append("zoom.out"),
73530       action: zoomOut,
73531       disabled: function() {
73532         return !context.map().canZoomOut();
73533       },
73534       disabledTitle: _t.append("zoom.disabled.out"),
73535       key: "-"
73536     }];
73537     function zoomIn(d3_event) {
73538       if (d3_event.shiftKey)
73539         return;
73540       d3_event.preventDefault();
73541       context.map().zoomIn();
73542     }
73543     function zoomOut(d3_event) {
73544       if (d3_event.shiftKey)
73545         return;
73546       d3_event.preventDefault();
73547       context.map().zoomOut();
73548     }
73549     function zoomInFurther(d3_event) {
73550       if (d3_event.shiftKey)
73551         return;
73552       d3_event.preventDefault();
73553       context.map().zoomInFurther();
73554     }
73555     function zoomOutFurther(d3_event) {
73556       if (d3_event.shiftKey)
73557         return;
73558       d3_event.preventDefault();
73559       context.map().zoomOutFurther();
73560     }
73561     return function(selection2) {
73562       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function(d2) {
73563         if (d2.disabled()) {
73564           return d2.disabledTitle;
73565         }
73566         return d2.title;
73567       }).keys(function(d2) {
73568         return [d2.key];
73569       });
73570       var lastPointerUpType;
73571       var buttons = selection2.selectAll("button").data(zooms).enter().append("button").attr("class", function(d2) {
73572         return d2.id;
73573       }).on("pointerup.editor", function(d3_event) {
73574         lastPointerUpType = d3_event.pointerType;
73575       }).on("click.editor", function(d3_event, d2) {
73576         if (!d2.disabled()) {
73577           d2.action(d3_event);
73578         } else if (lastPointerUpType === "touch" || lastPointerUpType === "pen") {
73579           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass("disabled").label(d2.disabledTitle)();
73580         }
73581         lastPointerUpType = null;
73582       }).call(tooltipBehavior);
73583       buttons.each(function(d2) {
73584         select_default2(this).call(svgIcon("#" + d2.icon, "light"));
73585       });
73586       utilKeybinding.plusKeys.forEach(function(key) {
73587         context.keybinding().on([key], zoomIn);
73588         context.keybinding().on([uiCmd("\u2325" + key)], zoomInFurther);
73589       });
73590       utilKeybinding.minusKeys.forEach(function(key) {
73591         context.keybinding().on([key], zoomOut);
73592         context.keybinding().on([uiCmd("\u2325" + key)], zoomOutFurther);
73593       });
73594       function updateButtonStates() {
73595         buttons.classed("disabled", function(d2) {
73596           return d2.disabled();
73597         }).each(function() {
73598           var selection3 = select_default2(this);
73599           if (!selection3.select(".tooltip.in").empty()) {
73600             selection3.call(tooltipBehavior.updateContent);
73601           }
73602         });
73603       }
73604       updateButtonStates();
73605       context.map().on("move.uiZoom", updateButtonStates);
73606     };
73607   }
73608
73609   // modules/ui/sections/raw_tag_editor.js
73610   function uiSectionRawTagEditor(id2, context) {
73611     var section = uiSection(id2, context).classes("raw-tag-editor").label(function() {
73612       var count = Object.keys(_tags).filter(function(d2) {
73613         return d2;
73614       }).length;
73615       return _t.append("inspector.title_count", { title: _t("inspector.tags"), count });
73616     }).expandedByDefault(false).disclosureContent(renderDisclosureContent);
73617     var taginfo = services.taginfo;
73618     var dispatch14 = dispatch_default("change");
73619     var availableViews = [
73620       { id: "list", icon: "#fas-th-list" },
73621       { id: "text", icon: "#fas-i-cursor" }
73622     ];
73623     let _discardTags = {};
73624     _mainFileFetcher.get("discarded").then((d2) => {
73625       _discardTags = d2;
73626     }).catch(() => {
73627     });
73628     var _tagView = corePreferences("raw-tag-editor-view") || "list";
73629     var _readOnlyTags = [];
73630     var _orderedKeys = [];
73631     var _showBlank = false;
73632     var _pendingChange = null;
73633     var _state;
73634     var _presets;
73635     var _tags;
73636     var _entityIDs;
73637     var _didInteract = false;
73638     function interacted() {
73639       _didInteract = true;
73640     }
73641     function renderDisclosureContent(wrap2) {
73642       _orderedKeys = _orderedKeys.filter(function(key) {
73643         return _tags[key] !== void 0;
73644       });
73645       var all = Object.keys(_tags).sort();
73646       var missingKeys = utilArrayDifference(all, _orderedKeys);
73647       for (var i3 in missingKeys) {
73648         _orderedKeys.push(missingKeys[i3]);
73649       }
73650       var rowData = _orderedKeys.map(function(key, i4) {
73651         return { index: i4, key, value: _tags[key] };
73652       });
73653       if (!rowData.length || _showBlank) {
73654         _showBlank = false;
73655         rowData.push({ index: rowData.length, key: "", value: "" });
73656       }
73657       var options2 = wrap2.selectAll(".raw-tag-options").data([0]);
73658       options2.exit().remove();
73659       var optionsEnter = options2.enter().insert("div", ":first-child").attr("class", "raw-tag-options").attr("role", "tablist");
73660       var optionEnter = optionsEnter.selectAll(".raw-tag-option").data(availableViews, function(d2) {
73661         return d2.id;
73662       }).enter();
73663       optionEnter.append("button").attr("class", function(d2) {
73664         return "raw-tag-option raw-tag-option-" + d2.id + (_tagView === d2.id ? " selected" : "");
73665       }).attr("aria-selected", function(d2) {
73666         return _tagView === d2.id;
73667       }).attr("role", "tab").attr("title", function(d2) {
73668         return _t("icons." + d2.id);
73669       }).on("click", function(d3_event, d2) {
73670         _tagView = d2.id;
73671         corePreferences("raw-tag-editor-view", d2.id);
73672         wrap2.selectAll(".raw-tag-option").classed("selected", function(datum2) {
73673           return datum2 === d2;
73674         }).attr("aria-selected", function(datum2) {
73675           return datum2 === d2;
73676         });
73677         wrap2.selectAll(".tag-text").classed("hide", d2.id !== "text").each(setTextareaHeight);
73678         wrap2.selectAll(".tag-list, .add-row").classed("hide", d2.id !== "list");
73679       }).each(function(d2) {
73680         select_default2(this).call(svgIcon(d2.icon));
73681       });
73682       var textData = rowsToText(rowData);
73683       var textarea = wrap2.selectAll(".tag-text").data([0]);
73684       textarea = textarea.enter().append("textarea").attr("class", "tag-text" + (_tagView !== "text" ? " hide" : "")).call(utilNoAuto).attr("placeholder", _t("inspector.key_value")).attr("spellcheck", "false").merge(textarea);
73685       textarea.call(utilGetSetValue, textData).each(setTextareaHeight).on("input", setTextareaHeight).on("focus", interacted).on("blur", textChanged).on("change", textChanged);
73686       var list2 = wrap2.selectAll(".tag-list").data([0]);
73687       list2 = list2.enter().append("ul").attr("class", "tag-list" + (_tagView !== "list" ? " hide" : "")).merge(list2);
73688       var addRowEnter = wrap2.selectAll(".add-row").data([0]).enter().append("div").attr("class", "add-row" + (_tagView !== "list" ? " hide" : ""));
73689       addRowEnter.append("button").attr("class", "add-tag").attr("aria-label", _t("inspector.add_to_tag")).call(svgIcon("#iD-icon-plus", "light")).call(uiTooltip().title(() => _t.append("inspector.add_to_tag")).placement(_mainLocalizer.textDirection() === "ltr" ? "right" : "left")).on("click", addTag);
73690       addRowEnter.append("div").attr("class", "space-value");
73691       addRowEnter.append("div").attr("class", "space-buttons");
73692       var items = list2.selectAll(".tag-row").data(rowData, function(d2) {
73693         return d2.key;
73694       });
73695       items.exit().each(unbind).remove();
73696       var itemsEnter = items.enter().append("li").attr("class", "tag-row").classed("readonly", isReadOnly);
73697       var innerWrap = itemsEnter.append("div").attr("class", "inner-wrap");
73698       innerWrap.append("div").attr("class", "key-wrap").append("input").property("type", "text").attr("class", "key").call(utilNoAuto).on("focus", interacted).on("blur", keyChange).on("change", keyChange);
73699       innerWrap.append("div").attr("class", "value-wrap").append("input").property("type", "text").attr("class", "value").call(utilNoAuto).on("focus", interacted).on("blur", valueChange).on("change", valueChange).on("keydown.push-more", pushMore);
73700       innerWrap.append("button").attr("class", "form-field-button remove").attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
73701       items = items.merge(itemsEnter).sort(function(a2, b2) {
73702         return a2.index - b2.index;
73703       });
73704       items.each(function(d2) {
73705         var row = select_default2(this);
73706         var key = row.select("input.key");
73707         var value = row.select("input.value");
73708         if (_entityIDs && taginfo && _state !== "hover") {
73709           bindTypeahead(key, value);
73710         }
73711         var referenceOptions = { key: d2.key };
73712         if (typeof d2.value === "string") {
73713           referenceOptions.value = d2.value;
73714         }
73715         var reference = uiTagReference(referenceOptions, context);
73716         if (_state === "hover") {
73717           reference.showing(false);
73718         }
73719         row.select(".inner-wrap").call(reference.button);
73720         row.call(reference.body);
73721         row.select("button.remove");
73722       });
73723       items.selectAll("input.key").attr("title", function(d2) {
73724         return d2.key;
73725       }).call(utilGetSetValue, function(d2) {
73726         return d2.key;
73727       }).attr("readonly", function(d2) {
73728         return isReadOnly(d2) || null;
73729       });
73730       items.selectAll("input.value").attr("title", function(d2) {
73731         return Array.isArray(d2.value) ? d2.value.filter(Boolean).join("\n") : d2.value;
73732       }).classed("mixed", function(d2) {
73733         return Array.isArray(d2.value);
73734       }).attr("placeholder", function(d2) {
73735         return typeof d2.value === "string" ? null : _t("inspector.multiple_values");
73736       }).call(utilGetSetValue, function(d2) {
73737         return typeof d2.value === "string" ? d2.value : "";
73738       }).attr("readonly", function(d2) {
73739         return isReadOnly(d2) || null;
73740       });
73741       items.selectAll("button.remove").on(
73742         ("PointerEvent" in window ? "pointer" : "mouse") + "down",
73743         // 'click' fires too late - #5878
73744         (d3_event, d2) => {
73745           if (d3_event.button !== 0)
73746             return;
73747           removeTag(d3_event, d2);
73748         }
73749       );
73750     }
73751     function isReadOnly(d2) {
73752       for (var i3 = 0; i3 < _readOnlyTags.length; i3++) {
73753         if (d2.key.match(_readOnlyTags[i3]) !== null) {
73754           return true;
73755         }
73756       }
73757       return false;
73758     }
73759     function setTextareaHeight() {
73760       if (_tagView !== "text")
73761         return;
73762       var selection2 = select_default2(this);
73763       var matches = selection2.node().value.match(/\n/g);
73764       var lineCount = 2 + Number(matches && matches.length);
73765       var lineHeight = 20;
73766       selection2.style("height", lineCount * lineHeight + "px");
73767     }
73768     function stringify3(s2) {
73769       return JSON.stringify(s2).slice(1, -1);
73770     }
73771     function unstringify(s2) {
73772       var leading = "";
73773       var trailing = "";
73774       if (s2.length < 1 || s2.charAt(0) !== '"') {
73775         leading = '"';
73776       }
73777       if (s2.length < 2 || s2.charAt(s2.length - 1) !== '"' || s2.charAt(s2.length - 1) === '"' && s2.charAt(s2.length - 2) === "\\") {
73778         trailing = '"';
73779       }
73780       return JSON.parse(leading + s2 + trailing);
73781     }
73782     function rowsToText(rows) {
73783       var str = rows.filter(function(row) {
73784         return row.key && row.key.trim() !== "";
73785       }).map(function(row) {
73786         var rawVal = row.value;
73787         if (typeof rawVal !== "string")
73788           rawVal = "*";
73789         var val = rawVal ? stringify3(rawVal) : "";
73790         return stringify3(row.key) + "=" + val;
73791       }).join("\n");
73792       if (_state !== "hover" && str.length) {
73793         return str + "\n";
73794       }
73795       return str;
73796     }
73797     function textChanged() {
73798       var newText = this.value.trim();
73799       var newTags = {};
73800       newText.split("\n").forEach(function(row) {
73801         var m2 = row.match(/^\s*([^=]+)=(.*)$/);
73802         if (m2 !== null) {
73803           var k2 = context.cleanTagKey(unstringify(m2[1].trim()));
73804           var v2 = context.cleanTagValue(unstringify(m2[2].trim()));
73805           newTags[k2] = v2;
73806         }
73807       });
73808       var tagDiff = utilTagDiff(_tags, newTags);
73809       if (!tagDiff.length)
73810         return;
73811       _pendingChange = _pendingChange || {};
73812       tagDiff.forEach(function(change) {
73813         if (isReadOnly({ key: change.key }))
73814           return;
73815         if (change.newVal === "*" && typeof change.oldVal !== "string")
73816           return;
73817         if (change.type === "-") {
73818           _pendingChange[change.key] = void 0;
73819         } else if (change.type === "+") {
73820           _pendingChange[change.key] = change.newVal || "";
73821         }
73822       });
73823       if (Object.keys(_pendingChange).length === 0) {
73824         _pendingChange = null;
73825         return;
73826       }
73827       scheduleChange();
73828     }
73829     function pushMore(d3_event) {
73830       if (d3_event.keyCode === 9 && !d3_event.shiftKey && section.selection().selectAll(".tag-list li:last-child input.value").node() === this && utilGetSetValue(select_default2(this))) {
73831         addTag();
73832       }
73833     }
73834     function bindTypeahead(key, value) {
73835       if (isReadOnly(key.datum()))
73836         return;
73837       if (Array.isArray(value.datum().value)) {
73838         value.call(uiCombobox(context, "tag-value").minItems(1).fetcher(function(value2, callback) {
73839           var keyString = utilGetSetValue(key);
73840           if (!_tags[keyString])
73841             return;
73842           var data = _tags[keyString].map(function(tagValue) {
73843             if (!tagValue) {
73844               return {
73845                 value: " ",
73846                 title: _t("inspector.empty"),
73847                 display: (selection2) => selection2.text("").classed("virtual-option", true).call(_t.append("inspector.empty"))
73848               };
73849             }
73850             return {
73851               value: tagValue,
73852               title: tagValue
73853             };
73854           });
73855           callback(data);
73856         }));
73857         return;
73858       }
73859       var geometry = context.graph().geometry(_entityIDs[0]);
73860       key.call(uiCombobox(context, "tag-key").fetcher(function(value2, callback) {
73861         taginfo.keys({
73862           debounce: true,
73863           geometry,
73864           query: value2
73865         }, function(err, data) {
73866           if (!err) {
73867             const filtered = data.filter((d2) => _tags[d2.value] === void 0).filter((d2) => !(d2.value in _discardTags)).filter((d2) => !/_\d$/.test(d2)).filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase()));
73868             callback(sort(value2, filtered));
73869           }
73870         });
73871       }));
73872       value.call(uiCombobox(context, "tag-value").fetcher(function(value2, callback) {
73873         taginfo.values({
73874           debounce: true,
73875           key: utilGetSetValue(key),
73876           geometry,
73877           query: value2
73878         }, function(err, data) {
73879           if (!err) {
73880             const filtered = data.filter((d2) => d2.value.toLowerCase().includes(value2.toLowerCase()));
73881             callback(sort(value2, filtered));
73882           }
73883         });
73884       }).caseSensitive(allowUpperCaseTagValues.test(utilGetSetValue(key))));
73885       function sort(value2, data) {
73886         var sameletter = [];
73887         var other = [];
73888         for (var i3 = 0; i3 < data.length; i3++) {
73889           if (data[i3].value.substring(0, value2.length) === value2) {
73890             sameletter.push(data[i3]);
73891           } else {
73892             other.push(data[i3]);
73893           }
73894         }
73895         return sameletter.concat(other);
73896       }
73897     }
73898     function unbind() {
73899       var row = select_default2(this);
73900       row.selectAll("input.key").call(uiCombobox.off, context);
73901       row.selectAll("input.value").call(uiCombobox.off, context);
73902     }
73903     function keyChange(d3_event, d2) {
73904       if (select_default2(this).attr("readonly"))
73905         return;
73906       var kOld = d2.key;
73907       if (_pendingChange && _pendingChange.hasOwnProperty(kOld) && _pendingChange[kOld] === void 0)
73908         return;
73909       var kNew = context.cleanTagKey(this.value.trim());
73910       if (isReadOnly({ key: kNew })) {
73911         this.value = kOld;
73912         return;
73913       }
73914       if (kNew && kNew !== kOld && _tags[kNew] !== void 0) {
73915         this.value = kOld;
73916         section.selection().selectAll(".tag-list input.value").each(function(d4) {
73917           if (d4.key === kNew) {
73918             var input = select_default2(this).node();
73919             input.focus();
73920             input.select();
73921           }
73922         });
73923         return;
73924       }
73925       _pendingChange = _pendingChange || {};
73926       if (kOld) {
73927         if (kOld === kNew)
73928           return;
73929         _pendingChange[kNew] = _pendingChange[kOld] || { oldKey: kOld };
73930         _pendingChange[kOld] = void 0;
73931       } else {
73932         let row = this.parentNode.parentNode;
73933         let inputVal = select_default2(row).selectAll("input.value");
73934         let vNew = context.cleanTagValue(utilGetSetValue(inputVal));
73935         _pendingChange[kNew] = vNew;
73936         utilGetSetValue(inputVal, vNew);
73937       }
73938       var existingKeyIndex = _orderedKeys.indexOf(kOld);
73939       if (existingKeyIndex !== -1)
73940         _orderedKeys[existingKeyIndex] = kNew;
73941       d2.key = kNew;
73942       this.value = kNew;
73943       scheduleChange();
73944     }
73945     function valueChange(d3_event, d2) {
73946       if (isReadOnly(d2))
73947         return;
73948       if (typeof d2.value !== "string" && !this.value)
73949         return;
73950       if (!this.value.trim())
73951         return removeTag(d3_event, d2);
73952       if (_pendingChange && _pendingChange.hasOwnProperty(d2.key) && _pendingChange[d2.key] === void 0)
73953         return;
73954       _pendingChange = _pendingChange || {};
73955       _pendingChange[d2.key] = context.cleanTagValue(this.value);
73956       scheduleChange();
73957     }
73958     function removeTag(d3_event, d2) {
73959       if (isReadOnly(d2))
73960         return;
73961       if (d2.key === "") {
73962         _showBlank = false;
73963         section.reRender();
73964       } else {
73965         _orderedKeys = _orderedKeys.filter(function(key) {
73966           return key !== d2.key;
73967         });
73968         _pendingChange = _pendingChange || {};
73969         _pendingChange[d2.key] = void 0;
73970         scheduleChange();
73971       }
73972     }
73973     function addTag() {
73974       window.setTimeout(function() {
73975         _showBlank = true;
73976         section.reRender();
73977         section.selection().selectAll(".tag-list li:last-child input.key").node().focus();
73978       }, 20);
73979     }
73980     function scheduleChange() {
73981       var entityIDs = _entityIDs;
73982       window.setTimeout(function() {
73983         if (!_pendingChange)
73984           return;
73985         dispatch14.call("change", this, entityIDs, _pendingChange);
73986         _pendingChange = null;
73987       }, 10);
73988     }
73989     section.state = function(val) {
73990       if (!arguments.length)
73991         return _state;
73992       if (_state !== val) {
73993         _orderedKeys = [];
73994         _state = val;
73995       }
73996       return section;
73997     };
73998     section.presets = function(val) {
73999       if (!arguments.length)
74000         return _presets;
74001       _presets = val;
74002       if (_presets && _presets.length && _presets[0].isFallback()) {
74003         section.disclosureExpanded(true);
74004       } else if (!_didInteract) {
74005         section.disclosureExpanded(null);
74006       }
74007       return section;
74008     };
74009     section.tags = function(val) {
74010       if (!arguments.length)
74011         return _tags;
74012       _tags = val;
74013       return section;
74014     };
74015     section.entityIDs = function(val) {
74016       if (!arguments.length)
74017         return _entityIDs;
74018       if (!_entityIDs || !val || !utilArrayIdentical(_entityIDs, val)) {
74019         _entityIDs = val;
74020         _orderedKeys = [];
74021       }
74022       return section;
74023     };
74024     section.readOnlyTags = function(val) {
74025       if (!arguments.length)
74026         return _readOnlyTags;
74027       _readOnlyTags = val;
74028       return section;
74029     };
74030     return utilRebind(section, dispatch14, "on");
74031   }
74032
74033   // modules/ui/data_editor.js
74034   function uiDataEditor(context) {
74035     var dataHeader = uiDataHeader();
74036     var rawTagEditor = uiSectionRawTagEditor("custom-data-tag-editor", context).expandedByDefault(true).readOnlyTags([/./]);
74037     var _datum;
74038     function dataEditor(selection2) {
74039       var header = selection2.selectAll(".header").data([0]);
74040       var headerEnter = header.enter().append("div").attr("class", "header fillL");
74041       headerEnter.append("button").attr("class", "close").attr("title", _t("icons.close")).on("click", function() {
74042         context.enter(modeBrowse(context));
74043       }).call(svgIcon("#iD-icon-close"));
74044       headerEnter.append("h2").call(_t.append("map_data.title"));
74045       var body = selection2.selectAll(".body").data([0]);
74046       body = body.enter().append("div").attr("class", "body").merge(body);
74047       var editor = body.selectAll(".data-editor").data([0]);
74048       editor.enter().append("div").attr("class", "modal-section data-editor").merge(editor).call(dataHeader.datum(_datum));
74049       var rte = body.selectAll(".raw-tag-editor").data([0]);
74050       rte.enter().append("div").attr("class", "raw-tag-editor data-editor").merge(rte).call(
74051         rawTagEditor.tags(_datum && _datum.properties || {}).state("hover").render
74052       ).selectAll("textarea.tag-text").attr("readonly", true).classed("readonly", true);
74053     }
74054     dataEditor.datum = function(val) {
74055       if (!arguments.length)
74056         return _datum;
74057       _datum = val;
74058       return this;
74059     };
74060     return dataEditor;
74061   }
74062
74063   // modules/ui/sidebar.js
74064   function uiSidebar(context) {
74065     var inspector = uiInspector(context);
74066     var dataEditor = uiDataEditor(context);
74067     var noteEditor = uiNoteEditor(context);
74068     var improveOsmEditor = uiImproveOsmEditor(context);
74069     var keepRightEditor = uiKeepRightEditor(context);
74070     var osmoseEditor = uiOsmoseEditor(context);
74071     var _current;
74072     var _wasData = false;
74073     var _wasNote = false;
74074     var _wasQaItem = false;
74075     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
74076     function sidebar(selection2) {
74077       var container = context.container();
74078       var minWidth = 240;
74079       var sidebarWidth;
74080       var containerWidth;
74081       var dragOffset;
74082       selection2.style("min-width", minWidth + "px").style("max-width", "400px").style("width", "33.3333%");
74083       var resizer = selection2.append("div").attr("class", "sidebar-resizer").on(_pointerPrefix + "down.sidebar-resizer", pointerdown);
74084       var downPointerId, lastClientX, containerLocGetter;
74085       function pointerdown(d3_event) {
74086         if (downPointerId)
74087           return;
74088         if ("button" in d3_event && d3_event.button !== 0)
74089           return;
74090         downPointerId = d3_event.pointerId || "mouse";
74091         lastClientX = d3_event.clientX;
74092         containerLocGetter = utilFastMouse(container.node());
74093         dragOffset = utilFastMouse(resizer.node())(d3_event)[0] - 1;
74094         sidebarWidth = selection2.node().getBoundingClientRect().width;
74095         containerWidth = container.node().getBoundingClientRect().width;
74096         var widthPct = sidebarWidth / containerWidth * 100;
74097         selection2.style("width", widthPct + "%").style("max-width", "85%");
74098         resizer.classed("dragging", true);
74099         select_default2(window).on("touchmove.sidebar-resizer", function(d3_event2) {
74100           d3_event2.preventDefault();
74101         }, { passive: false }).on(_pointerPrefix + "move.sidebar-resizer", pointermove).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", pointerup);
74102       }
74103       function pointermove(d3_event) {
74104         if (downPointerId !== (d3_event.pointerId || "mouse"))
74105           return;
74106         d3_event.preventDefault();
74107         var dx = d3_event.clientX - lastClientX;
74108         lastClientX = d3_event.clientX;
74109         var isRTL = _mainLocalizer.textDirection() === "rtl";
74110         var scaleX = isRTL ? 0 : 1;
74111         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
74112         var x2 = containerLocGetter(d3_event)[0] - dragOffset;
74113         sidebarWidth = isRTL ? containerWidth - x2 : x2;
74114         var isCollapsed = selection2.classed("collapsed");
74115         var shouldCollapse = sidebarWidth < minWidth;
74116         selection2.classed("collapsed", shouldCollapse);
74117         if (shouldCollapse) {
74118           if (!isCollapsed) {
74119             selection2.style(xMarginProperty, "-400px").style("width", "400px");
74120             context.ui().onResize([(sidebarWidth - dx) * scaleX, 0]);
74121           }
74122         } else {
74123           var widthPct = sidebarWidth / containerWidth * 100;
74124           selection2.style(xMarginProperty, null).style("width", widthPct + "%");
74125           if (isCollapsed) {
74126             context.ui().onResize([-sidebarWidth * scaleX, 0]);
74127           } else {
74128             context.ui().onResize([-dx * scaleX, 0]);
74129           }
74130         }
74131       }
74132       function pointerup(d3_event) {
74133         if (downPointerId !== (d3_event.pointerId || "mouse"))
74134           return;
74135         downPointerId = null;
74136         resizer.classed("dragging", false);
74137         select_default2(window).on("touchmove.sidebar-resizer", null).on(_pointerPrefix + "move.sidebar-resizer", null).on(_pointerPrefix + "up.sidebar-resizer pointercancel.sidebar-resizer", null);
74138       }
74139       var featureListWrap = selection2.append("div").attr("class", "feature-list-pane").call(uiFeatureList(context));
74140       var inspectorWrap = selection2.append("div").attr("class", "inspector-hidden inspector-wrap");
74141       var hoverModeSelect = function(targets) {
74142         context.container().selectAll(".feature-list-item button").classed("hover", false);
74143         if (context.selectedIDs().length > 1 && targets && targets.length) {
74144           var elements = context.container().selectAll(".feature-list-item button").filter(function(node) {
74145             return targets.indexOf(node) !== -1;
74146           });
74147           if (!elements.empty()) {
74148             elements.classed("hover", true);
74149           }
74150         }
74151       };
74152       sidebar.hoverModeSelect = throttle_default(hoverModeSelect, 200);
74153       function hover(targets) {
74154         var datum2 = targets && targets.length && targets[0];
74155         if (datum2 && datum2.__featurehash__) {
74156           _wasData = true;
74157           sidebar.show(dataEditor.datum(datum2));
74158           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
74159         } else if (datum2 instanceof osmNote) {
74160           if (context.mode().id === "drag-note")
74161             return;
74162           _wasNote = true;
74163           var osm = services.osm;
74164           if (osm) {
74165             datum2 = osm.getNote(datum2.id);
74166           }
74167           sidebar.show(noteEditor.note(datum2));
74168           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
74169         } else if (datum2 instanceof QAItem) {
74170           _wasQaItem = true;
74171           var errService = services[datum2.service];
74172           if (errService) {
74173             datum2 = errService.getError(datum2.id);
74174           }
74175           var errEditor;
74176           if (datum2.service === "keepRight") {
74177             errEditor = keepRightEditor;
74178           } else if (datum2.service === "osmose") {
74179             errEditor = osmoseEditor;
74180           } else {
74181             errEditor = improveOsmEditor;
74182           }
74183           context.container().selectAll(".qaItem." + datum2.service).classed("hover", function(d2) {
74184             return d2.id === datum2.id;
74185           });
74186           sidebar.show(errEditor.error(datum2));
74187           selection2.selectAll(".sidebar-component").classed("inspector-hover", true);
74188         } else if (!_current && datum2 instanceof osmEntity) {
74189           featureListWrap.classed("inspector-hidden", true);
74190           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", true);
74191           if (!inspector.entityIDs() || !utilArrayIdentical(inspector.entityIDs(), [datum2.id]) || inspector.state() !== "hover") {
74192             inspector.state("hover").entityIDs([datum2.id]).newFeature(false);
74193             inspectorWrap.call(inspector);
74194           }
74195         } else if (!_current) {
74196           featureListWrap.classed("inspector-hidden", false);
74197           inspectorWrap.classed("inspector-hidden", true);
74198           inspector.state("hide");
74199         } else if (_wasData || _wasNote || _wasQaItem) {
74200           _wasNote = false;
74201           _wasData = false;
74202           _wasQaItem = false;
74203           context.container().selectAll(".note").classed("hover", false);
74204           context.container().selectAll(".qaItem").classed("hover", false);
74205           sidebar.hide();
74206         }
74207       }
74208       sidebar.hover = throttle_default(hover, 200);
74209       sidebar.intersects = function(extent) {
74210         var rect = selection2.node().getBoundingClientRect();
74211         return extent.intersects([
74212           context.projection.invert([0, rect.height]),
74213           context.projection.invert([rect.width, 0])
74214         ]);
74215       };
74216       sidebar.select = function(ids, newFeature) {
74217         sidebar.hide();
74218         if (ids && ids.length) {
74219           var entity = ids.length === 1 && context.entity(ids[0]);
74220           if (entity && newFeature && selection2.classed("collapsed")) {
74221             var extent = entity.extent(context.graph());
74222             sidebar.expand(sidebar.intersects(extent));
74223           }
74224           featureListWrap.classed("inspector-hidden", true);
74225           inspectorWrap.classed("inspector-hidden", false).classed("inspector-hover", false);
74226           inspector.state("select").entityIDs(ids).newFeature(newFeature);
74227           inspectorWrap.call(inspector);
74228         } else {
74229           inspector.state("hide");
74230         }
74231       };
74232       sidebar.showPresetList = function() {
74233         inspector.showList();
74234       };
74235       sidebar.show = function(component, element) {
74236         featureListWrap.classed("inspector-hidden", true);
74237         inspectorWrap.classed("inspector-hidden", true);
74238         if (_current)
74239           _current.remove();
74240         _current = selection2.append("div").attr("class", "sidebar-component").call(component, element);
74241       };
74242       sidebar.hide = function() {
74243         featureListWrap.classed("inspector-hidden", false);
74244         inspectorWrap.classed("inspector-hidden", true);
74245         if (_current)
74246           _current.remove();
74247         _current = null;
74248       };
74249       sidebar.expand = function(moveMap) {
74250         if (selection2.classed("collapsed")) {
74251           sidebar.toggle(moveMap);
74252         }
74253       };
74254       sidebar.collapse = function(moveMap) {
74255         if (!selection2.classed("collapsed")) {
74256           sidebar.toggle(moveMap);
74257         }
74258       };
74259       sidebar.toggle = function(moveMap) {
74260         if (context.inIntro())
74261           return;
74262         var isCollapsed = selection2.classed("collapsed");
74263         var isCollapsing = !isCollapsed;
74264         var isRTL = _mainLocalizer.textDirection() === "rtl";
74265         var scaleX = isRTL ? 0 : 1;
74266         var xMarginProperty = isRTL ? "margin-right" : "margin-left";
74267         sidebarWidth = selection2.node().getBoundingClientRect().width;
74268         selection2.style("width", sidebarWidth + "px");
74269         var startMargin, endMargin, lastMargin;
74270         if (isCollapsing) {
74271           startMargin = lastMargin = 0;
74272           endMargin = -sidebarWidth;
74273         } else {
74274           startMargin = lastMargin = -sidebarWidth;
74275           endMargin = 0;
74276         }
74277         if (!isCollapsing) {
74278           selection2.classed("collapsed", isCollapsing);
74279         }
74280         selection2.transition().style(xMarginProperty, endMargin + "px").tween("panner", function() {
74281           var i3 = number_default(startMargin, endMargin);
74282           return function(t2) {
74283             var dx = lastMargin - Math.round(i3(t2));
74284             lastMargin = lastMargin - dx;
74285             context.ui().onResize(moveMap ? void 0 : [dx * scaleX, 0]);
74286           };
74287         }).on("end", function() {
74288           if (isCollapsing) {
74289             selection2.classed("collapsed", isCollapsing);
74290           }
74291           if (!isCollapsing) {
74292             var containerWidth2 = container.node().getBoundingClientRect().width;
74293             var widthPct = sidebarWidth / containerWidth2 * 100;
74294             selection2.style(xMarginProperty, null).style("width", widthPct + "%");
74295           }
74296         });
74297       };
74298       resizer.on("dblclick", function(d3_event) {
74299         d3_event.preventDefault();
74300         if (d3_event.sourceEvent) {
74301           d3_event.sourceEvent.preventDefault();
74302         }
74303         sidebar.toggle();
74304       });
74305       context.map().on("crossEditableZoom.sidebar", function(within) {
74306         if (!within && !selection2.select(".inspector-hover").empty()) {
74307           hover([]);
74308         }
74309       });
74310     }
74311     sidebar.showPresetList = function() {
74312     };
74313     sidebar.hover = function() {
74314     };
74315     sidebar.hover.cancel = function() {
74316     };
74317     sidebar.intersects = function() {
74318     };
74319     sidebar.select = function() {
74320     };
74321     sidebar.show = function() {
74322     };
74323     sidebar.hide = function() {
74324     };
74325     sidebar.expand = function() {
74326     };
74327     sidebar.collapse = function() {
74328     };
74329     sidebar.toggle = function() {
74330     };
74331     return sidebar;
74332   }
74333
74334   // modules/ui/tools/modes.js
74335   function uiToolDrawModes(context) {
74336     var tool = {
74337       id: "old_modes",
74338       label: _t.append("toolbar.add_feature")
74339     };
74340     var modes = [
74341       modeAddPoint(context, {
74342         title: _t.append("modes.add_point.title"),
74343         button: "point",
74344         description: _t.append("modes.add_point.description"),
74345         preset: _mainPresetIndex.item("point"),
74346         key: "1"
74347       }),
74348       modeAddLine(context, {
74349         title: _t.append("modes.add_line.title"),
74350         button: "line",
74351         description: _t.append("modes.add_line.description"),
74352         preset: _mainPresetIndex.item("line"),
74353         key: "2"
74354       }),
74355       modeAddArea(context, {
74356         title: _t.append("modes.add_area.title"),
74357         button: "area",
74358         description: _t.append("modes.add_area.description"),
74359         preset: _mainPresetIndex.item("area"),
74360         key: "3"
74361       })
74362     ];
74363     function enabled(_mode) {
74364       return osmEditable();
74365     }
74366     function osmEditable() {
74367       return context.editable();
74368     }
74369     modes.forEach(function(mode) {
74370       context.keybinding().on(mode.key, function() {
74371         if (!enabled(mode))
74372           return;
74373         if (mode.id === context.mode().id) {
74374           context.enter(modeBrowse(context));
74375         } else {
74376           context.enter(mode);
74377         }
74378       });
74379     });
74380     tool.render = function(selection2) {
74381       var wrap2 = selection2.append("div").attr("class", "joined").style("display", "flex");
74382       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74383       context.map().on("move.modes", debouncedUpdate).on("drawn.modes", debouncedUpdate);
74384       context.on("enter.modes", update);
74385       update();
74386       function update() {
74387         var buttons = wrap2.selectAll("button.add-button").data(modes, function(d2) {
74388           return d2.id;
74389         });
74390         buttons.exit().remove();
74391         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
74392           return d2.id + " add-button bar-button";
74393         }).on("click.mode-buttons", function(d3_event, d2) {
74394           if (!enabled(d2))
74395             return;
74396           var currMode = context.mode().id;
74397           if (/^draw/.test(currMode))
74398             return;
74399           if (d2.id === currMode) {
74400             context.enter(modeBrowse(context));
74401           } else {
74402             context.enter(d2);
74403           }
74404         }).call(
74405           uiTooltip().placement("bottom").title(function(d2) {
74406             return d2.description;
74407           }).keys(function(d2) {
74408             return [d2.key];
74409           }).scrollContainer(context.container().select(".top-toolbar"))
74410         );
74411         buttonsEnter.each(function(d2) {
74412           select_default2(this).call(svgIcon("#iD-icon-" + d2.button));
74413         });
74414         buttonsEnter.append("span").attr("class", "label").text("").each(function(mode) {
74415           mode.title(select_default2(this));
74416         });
74417         if (buttons.enter().size() || buttons.exit().size()) {
74418           context.ui().checkOverflow(".top-toolbar", true);
74419         }
74420         buttons = buttons.merge(buttonsEnter).attr("aria-disabled", function(d2) {
74421           return !enabled(d2);
74422         }).classed("disabled", function(d2) {
74423           return !enabled(d2);
74424         }).attr("aria-pressed", function(d2) {
74425           return context.mode() && context.mode().button === d2.button;
74426         }).classed("active", function(d2) {
74427           return context.mode() && context.mode().button === d2.button;
74428         });
74429       }
74430     };
74431     return tool;
74432   }
74433
74434   // modules/ui/tools/notes.js
74435   function uiToolNotes(context) {
74436     var tool = {
74437       id: "notes",
74438       label: _t.append("modes.add_note.label")
74439     };
74440     var mode = modeAddNote(context);
74441     function enabled() {
74442       return notesEnabled() && notesEditable();
74443     }
74444     function notesEnabled() {
74445       var noteLayer = context.layers().layer("notes");
74446       return noteLayer && noteLayer.enabled();
74447     }
74448     function notesEditable() {
74449       var mode2 = context.mode();
74450       return context.map().notesEditable() && mode2 && mode2.id !== "save";
74451     }
74452     context.keybinding().on(mode.key, function() {
74453       if (!enabled())
74454         return;
74455       if (mode.id === context.mode().id) {
74456         context.enter(modeBrowse(context));
74457       } else {
74458         context.enter(mode);
74459       }
74460     });
74461     tool.render = function(selection2) {
74462       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74463       context.map().on("move.notes", debouncedUpdate).on("drawn.notes", debouncedUpdate);
74464       context.on("enter.notes", update);
74465       update();
74466       function update() {
74467         var showNotes = notesEnabled();
74468         var data = showNotes ? [mode] : [];
74469         var buttons = selection2.selectAll("button.add-button").data(data, function(d2) {
74470           return d2.id;
74471         });
74472         buttons.exit().remove();
74473         var buttonsEnter = buttons.enter().append("button").attr("class", function(d2) {
74474           return d2.id + " add-button bar-button";
74475         }).on("click.notes", function(d3_event, d2) {
74476           if (!enabled())
74477             return;
74478           var currMode = context.mode().id;
74479           if (/^draw/.test(currMode))
74480             return;
74481           if (d2.id === currMode) {
74482             context.enter(modeBrowse(context));
74483           } else {
74484             context.enter(d2);
74485           }
74486         }).call(
74487           uiTooltip().placement("bottom").title(function(d2) {
74488             return d2.description;
74489           }).keys(function(d2) {
74490             return [d2.key];
74491           }).scrollContainer(context.container().select(".top-toolbar"))
74492         );
74493         buttonsEnter.each(function(d2) {
74494           select_default2(this).call(svgIcon(d2.icon || "#iD-icon-" + d2.button));
74495         });
74496         if (buttons.enter().size() || buttons.exit().size()) {
74497           context.ui().checkOverflow(".top-toolbar", true);
74498         }
74499         buttons = buttons.merge(buttonsEnter).classed("disabled", function() {
74500           return !enabled();
74501         }).attr("aria-disabled", function() {
74502           return !enabled();
74503         }).classed("active", function(d2) {
74504           return context.mode() && context.mode().button === d2.button;
74505         }).attr("aria-pressed", function(d2) {
74506           return context.mode() && context.mode().button === d2.button;
74507         });
74508       }
74509     };
74510     tool.uninstall = function() {
74511       context.on("enter.editor.notes", null).on("exit.editor.notes", null).on("enter.notes", null);
74512       context.map().on("move.notes", null).on("drawn.notes", null);
74513     };
74514     return tool;
74515   }
74516
74517   // modules/ui/tools/save.js
74518   function uiToolSave(context) {
74519     var tool = {
74520       id: "save",
74521       label: _t.append("save.title")
74522     };
74523     var button = null;
74524     var tooltipBehavior = null;
74525     var history = context.history();
74526     var key = uiCmd("\u2318S");
74527     var _numChanges = 0;
74528     function isSaving() {
74529       var mode = context.mode();
74530       return mode && mode.id === "save";
74531     }
74532     function isDisabled() {
74533       return _numChanges === 0 || isSaving();
74534     }
74535     function save(d3_event) {
74536       d3_event.preventDefault();
74537       if (!context.inIntro() && !isSaving() && history.hasChanges()) {
74538         context.enter(modeSave(context));
74539       }
74540     }
74541     function bgColor(numChanges) {
74542       var step;
74543       if (numChanges === 0) {
74544         return null;
74545       } else if (numChanges <= 50) {
74546         step = numChanges / 50;
74547         return rgb_default("#fff", "#ff8")(step);
74548       } else {
74549         step = Math.min((numChanges - 50) / 50, 1);
74550         return rgb_default("#ff8", "#f88")(step);
74551       }
74552     }
74553     function updateCount() {
74554       var val = history.difference().summary().length;
74555       if (val === _numChanges)
74556         return;
74557       _numChanges = val;
74558       if (tooltipBehavior) {
74559         tooltipBehavior.title(() => _t.append(_numChanges > 0 ? "save.help" : "save.no_changes")).keys([key]);
74560       }
74561       if (button) {
74562         button.classed("disabled", isDisabled()).style("background", bgColor(_numChanges));
74563         button.select("span.count").text(_numChanges);
74564       }
74565     }
74566     tool.render = function(selection2) {
74567       tooltipBehavior = uiTooltip().placement("bottom").title(() => _t.append("save.no_changes")).keys([key]).scrollContainer(context.container().select(".top-toolbar"));
74568       var lastPointerUpType;
74569       button = selection2.append("button").attr("class", "save disabled bar-button").on("pointerup", function(d3_event) {
74570         lastPointerUpType = d3_event.pointerType;
74571       }).on("click", function(d3_event) {
74572         save(d3_event);
74573         if (_numChanges === 0 && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
74574           context.ui().flash.duration(2e3).iconName("#iD-icon-save").iconClass("disabled").label(_t.append("save.no_changes"))();
74575         }
74576         lastPointerUpType = null;
74577       }).call(tooltipBehavior);
74578       button.call(svgIcon("#iD-icon-save"));
74579       button.append("span").attr("class", "count").attr("aria-hidden", "true").text("0");
74580       updateCount();
74581       context.keybinding().on(key, save, true);
74582       context.history().on("change.save", updateCount);
74583       context.on("enter.save", function() {
74584         if (button) {
74585           button.classed("disabled", isDisabled());
74586           if (isSaving()) {
74587             button.call(tooltipBehavior.hide);
74588           }
74589         }
74590       });
74591     };
74592     tool.uninstall = function() {
74593       context.keybinding().off(key, true);
74594       context.history().on("change.save", null);
74595       context.on("enter.save", null);
74596       button = null;
74597       tooltipBehavior = null;
74598     };
74599     return tool;
74600   }
74601
74602   // modules/ui/tools/sidebar_toggle.js
74603   function uiToolSidebarToggle(context) {
74604     var tool = {
74605       id: "sidebar_toggle",
74606       label: _t.append("toolbar.inspect")
74607     };
74608     tool.render = function(selection2) {
74609       selection2.append("button").attr("class", "bar-button").attr("aria-label", _t("sidebar.tooltip")).on("click", function() {
74610         context.ui().sidebar.toggle();
74611       }).call(
74612         uiTooltip().placement("bottom").title(() => _t.append("sidebar.tooltip")).keys([_t("sidebar.key")]).scrollContainer(context.container().select(".top-toolbar"))
74613       ).call(svgIcon("#iD-icon-sidebar-" + (_mainLocalizer.textDirection() === "rtl" ? "right" : "left")));
74614     };
74615     return tool;
74616   }
74617
74618   // modules/ui/tools/undo_redo.js
74619   function uiToolUndoRedo(context) {
74620     var tool = {
74621       id: "undo_redo",
74622       label: _t.append("toolbar.undo_redo")
74623     };
74624     var commands = [{
74625       id: "undo",
74626       cmd: uiCmd("\u2318Z"),
74627       action: function() {
74628         context.undo();
74629       },
74630       annotation: function() {
74631         return context.history().undoAnnotation();
74632       },
74633       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")
74634     }, {
74635       id: "redo",
74636       cmd: uiCmd("\u2318\u21E7Z"),
74637       action: function() {
74638         context.redo();
74639       },
74640       annotation: function() {
74641         return context.history().redoAnnotation();
74642       },
74643       icon: "iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "undo" : "redo")
74644     }];
74645     function editable() {
74646       return context.mode() && context.mode().id !== "save" && context.map().editableDataEnabled(
74647         true
74648         /* ignore min zoom */
74649       );
74650     }
74651     tool.render = function(selection2) {
74652       var tooltipBehavior = uiTooltip().placement("bottom").title(function(d2) {
74653         return d2.annotation() ? _t.append(d2.id + ".tooltip", { action: d2.annotation() }) : _t.append(d2.id + ".nothing");
74654       }).keys(function(d2) {
74655         return [d2.cmd];
74656       }).scrollContainer(context.container().select(".top-toolbar"));
74657       var lastPointerUpType;
74658       var buttons = selection2.selectAll("button").data(commands).enter().append("button").attr("class", function(d2) {
74659         return "disabled " + d2.id + "-button bar-button";
74660       }).on("pointerup", function(d3_event) {
74661         lastPointerUpType = d3_event.pointerType;
74662       }).on("click", function(d3_event, d2) {
74663         d3_event.preventDefault();
74664         var annotation = d2.annotation();
74665         if (editable() && annotation) {
74666           d2.action();
74667         }
74668         if (editable() && (lastPointerUpType === "touch" || lastPointerUpType === "pen")) {
74669           var label = annotation ? _t.append(d2.id + ".tooltip", { action: annotation }) : _t.append(d2.id + ".nothing");
74670           context.ui().flash.duration(2e3).iconName("#" + d2.icon).iconClass(annotation ? "" : "disabled").label(label)();
74671         }
74672         lastPointerUpType = null;
74673       }).call(tooltipBehavior);
74674       buttons.each(function(d2) {
74675         select_default2(this).call(svgIcon("#" + d2.icon));
74676       });
74677       context.keybinding().on(commands[0].cmd, function(d3_event) {
74678         d3_event.preventDefault();
74679         if (editable())
74680           commands[0].action();
74681       }).on(commands[1].cmd, function(d3_event) {
74682         d3_event.preventDefault();
74683         if (editable())
74684           commands[1].action();
74685       });
74686       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74687       context.map().on("move.undo_redo", debouncedUpdate).on("drawn.undo_redo", debouncedUpdate);
74688       context.history().on("change.undo_redo", function(difference2) {
74689         if (difference2)
74690           update();
74691       });
74692       context.on("enter.undo_redo", update);
74693       function update() {
74694         buttons.classed("disabled", function(d2) {
74695           return !editable() || !d2.annotation();
74696         }).each(function() {
74697           var selection3 = select_default2(this);
74698           if (!selection3.select(".tooltip.in").empty()) {
74699             selection3.call(tooltipBehavior.updateContent);
74700           }
74701         });
74702       }
74703     };
74704     tool.uninstall = function() {
74705       context.keybinding().off(commands[0].cmd).off(commands[1].cmd);
74706       context.map().on("move.undo_redo", null).on("drawn.undo_redo", null);
74707       context.history().on("change.undo_redo", null);
74708       context.on("enter.undo_redo", null);
74709     };
74710     return tool;
74711   }
74712
74713   // modules/ui/top_toolbar.js
74714   function uiTopToolbar(context) {
74715     var sidebarToggle = uiToolSidebarToggle(context), modes = uiToolDrawModes(context), notes = uiToolNotes(context), undoRedo = uiToolUndoRedo(context), save = uiToolSave(context);
74716     function notesEnabled() {
74717       var noteLayer = context.layers().layer("notes");
74718       return noteLayer && noteLayer.enabled();
74719     }
74720     function topToolbar(bar) {
74721       bar.on("wheel.topToolbar", function(d3_event) {
74722         if (!d3_event.deltaX) {
74723           bar.node().scrollLeft += d3_event.deltaY;
74724         }
74725       });
74726       var debouncedUpdate = debounce_default(update, 500, { leading: true, trailing: true });
74727       context.layers().on("change.topToolbar", debouncedUpdate);
74728       update();
74729       function update() {
74730         var tools = [
74731           sidebarToggle,
74732           "spacer",
74733           modes
74734         ];
74735         tools.push("spacer");
74736         if (notesEnabled()) {
74737           tools = tools.concat([notes, "spacer"]);
74738         }
74739         tools = tools.concat([undoRedo, save]);
74740         var toolbarItems = bar.selectAll(".toolbar-item").data(tools, function(d2) {
74741           return d2.id || d2;
74742         });
74743         toolbarItems.exit().each(function(d2) {
74744           if (d2.uninstall) {
74745             d2.uninstall();
74746           }
74747         }).remove();
74748         var itemsEnter = toolbarItems.enter().append("div").attr("class", function(d2) {
74749           var classes = "toolbar-item " + (d2.id || d2).replace("_", "-");
74750           if (d2.klass)
74751             classes += " " + d2.klass;
74752           return classes;
74753         });
74754         var actionableItems = itemsEnter.filter(function(d2) {
74755           return d2 !== "spacer";
74756         });
74757         actionableItems.append("div").attr("class", "item-content").each(function(d2) {
74758           select_default2(this).call(d2.render, bar);
74759         });
74760         actionableItems.append("div").attr("class", "item-label").each(function(d2) {
74761           d2.label(select_default2(this));
74762         });
74763       }
74764     }
74765     return topToolbar;
74766   }
74767
74768   // modules/ui/zoom_to_selection.js
74769   function uiZoomToSelection(context) {
74770     function isDisabled() {
74771       var mode = context.mode();
74772       return !mode || !mode.zoomToSelected;
74773     }
74774     var _lastPointerUpType;
74775     function pointerup(d3_event) {
74776       _lastPointerUpType = d3_event.pointerType;
74777     }
74778     function click(d3_event) {
74779       d3_event.preventDefault();
74780       if (isDisabled()) {
74781         if (_lastPointerUpType === "touch" || _lastPointerUpType === "pen") {
74782           context.ui().flash.duration(2e3).iconName("#iD-icon-framed-dot").iconClass("disabled").label(_t.append("inspector.zoom_to.no_selection"))();
74783         }
74784       } else {
74785         var mode = context.mode();
74786         if (mode && mode.zoomToSelected) {
74787           mode.zoomToSelected();
74788         }
74789       }
74790       _lastPointerUpType = null;
74791     }
74792     return function(selection2) {
74793       var tooltipBehavior = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(function() {
74794         if (isDisabled()) {
74795           return _t.append("inspector.zoom_to.no_selection");
74796         }
74797         return _t.append("inspector.zoom_to.title");
74798       }).keys([_t("inspector.zoom_to.key")]);
74799       var button = selection2.append("button").on("pointerup", pointerup).on("click", click).call(svgIcon("#iD-icon-framed-dot", "light")).call(tooltipBehavior);
74800       function setEnabledState() {
74801         button.classed("disabled", isDisabled());
74802         if (!button.select(".tooltip.in").empty()) {
74803           button.call(tooltipBehavior.updateContent);
74804         }
74805       }
74806       context.on("enter.uiZoomToSelection", setEnabledState);
74807       setEnabledState();
74808     };
74809   }
74810
74811   // modules/ui/pane.js
74812   function uiPane(id2, context) {
74813     var _key;
74814     var _label = "";
74815     var _description = "";
74816     var _iconName = "";
74817     var _sections;
74818     var _paneSelection = select_default2(null);
74819     var _paneTooltip;
74820     var pane = {
74821       id: id2
74822     };
74823     pane.label = function(val) {
74824       if (!arguments.length)
74825         return _label;
74826       _label = val;
74827       return pane;
74828     };
74829     pane.key = function(val) {
74830       if (!arguments.length)
74831         return _key;
74832       _key = val;
74833       return pane;
74834     };
74835     pane.description = function(val) {
74836       if (!arguments.length)
74837         return _description;
74838       _description = val;
74839       return pane;
74840     };
74841     pane.iconName = function(val) {
74842       if (!arguments.length)
74843         return _iconName;
74844       _iconName = val;
74845       return pane;
74846     };
74847     pane.sections = function(val) {
74848       if (!arguments.length)
74849         return _sections;
74850       _sections = val;
74851       return pane;
74852     };
74853     pane.selection = function() {
74854       return _paneSelection;
74855     };
74856     function hidePane() {
74857       context.ui().togglePanes();
74858     }
74859     pane.togglePane = function(d3_event) {
74860       if (d3_event)
74861         d3_event.preventDefault();
74862       _paneTooltip.hide();
74863       context.ui().togglePanes(!_paneSelection.classed("shown") ? _paneSelection : void 0);
74864     };
74865     pane.renderToggleButton = function(selection2) {
74866       if (!_paneTooltip) {
74867         _paneTooltip = uiTooltip().placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left").title(() => _description).keys([_key]);
74868       }
74869       selection2.append("button").on("click", pane.togglePane).call(svgIcon("#" + _iconName, "light")).call(_paneTooltip);
74870     };
74871     pane.renderContent = function(selection2) {
74872       if (_sections) {
74873         _sections.forEach(function(section) {
74874           selection2.call(section.render);
74875         });
74876       }
74877     };
74878     pane.renderPane = function(selection2) {
74879       _paneSelection = selection2.append("div").attr("class", "fillL map-pane hide " + id2 + "-pane").attr("pane", id2);
74880       var heading2 = _paneSelection.append("div").attr("class", "pane-heading");
74881       heading2.append("h2").text("").call(_label);
74882       heading2.append("button").attr("title", _t("icons.close")).on("click", hidePane).call(svgIcon("#iD-icon-close"));
74883       _paneSelection.append("div").attr("class", "pane-content").call(pane.renderContent);
74884       if (_key) {
74885         context.keybinding().on(_key, pane.togglePane);
74886       }
74887     };
74888     return pane;
74889   }
74890
74891   // modules/ui/sections/background_display_options.js
74892   function uiSectionBackgroundDisplayOptions(context) {
74893     var section = uiSection("background-display-options", context).label(() => _t.append("background.display_options")).disclosureContent(renderDisclosureContent);
74894     var _storedOpacity = corePreferences("background-opacity");
74895     var _minVal = 0;
74896     var _maxVal = 3;
74897     var _sliders = ["brightness", "contrast", "saturation", "sharpness"];
74898     var _options = {
74899       brightness: _storedOpacity !== null ? +_storedOpacity : 1,
74900       contrast: 1,
74901       saturation: 1,
74902       sharpness: 1
74903     };
74904     function clamp3(x2, min3, max3) {
74905       return Math.max(min3, Math.min(x2, max3));
74906     }
74907     function updateValue(d2, val) {
74908       val = clamp3(val, _minVal, _maxVal);
74909       _options[d2] = val;
74910       context.background()[d2](val);
74911       if (d2 === "brightness") {
74912         corePreferences("background-opacity", val);
74913       }
74914       section.reRender();
74915     }
74916     function renderDisclosureContent(selection2) {
74917       var container = selection2.selectAll(".display-options-container").data([0]);
74918       var containerEnter = container.enter().append("div").attr("class", "display-options-container controls-list");
74919       var slidersEnter = containerEnter.selectAll(".display-control").data(_sliders).enter().append("label").attr("class", function(d2) {
74920         return "display-control display-control-" + d2;
74921       });
74922       slidersEnter.html(function(d2) {
74923         return _t.html("background." + d2);
74924       }).append("span").attr("class", function(d2) {
74925         return "display-option-value display-option-value-" + d2;
74926       });
74927       var sildersControlEnter = slidersEnter.append("div").attr("class", "control-wrap");
74928       sildersControlEnter.append("input").attr("class", function(d2) {
74929         return "display-option-input display-option-input-" + d2;
74930       }).attr("type", "range").attr("min", _minVal).attr("max", _maxVal).attr("step", "0.05").on("input", function(d3_event, d2) {
74931         var val = select_default2(this).property("value");
74932         if (!val && d3_event && d3_event.target) {
74933           val = d3_event.target.value;
74934         }
74935         updateValue(d2, val);
74936       });
74937       sildersControlEnter.append("button").attr("title", function(d2) {
74938         return "".concat(_t("background.reset"), " ").concat(_t("background." + d2));
74939       }).attr("class", function(d2) {
74940         return "display-option-reset display-option-reset-" + d2;
74941       }).on("click", function(d3_event, d2) {
74942         if (d3_event.button !== 0)
74943           return;
74944         updateValue(d2, 1);
74945       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
74946       containerEnter.append("a").attr("class", "display-option-resetlink").attr("role", "button").attr("href", "#").call(_t.append("background.reset_all")).on("click", function(d3_event) {
74947         d3_event.preventDefault();
74948         for (var i3 = 0; i3 < _sliders.length; i3++) {
74949           updateValue(_sliders[i3], 1);
74950         }
74951       });
74952       container = containerEnter.merge(container);
74953       container.selectAll(".display-option-input").property("value", function(d2) {
74954         return _options[d2];
74955       });
74956       container.selectAll(".display-option-value").text(function(d2) {
74957         return Math.floor(_options[d2] * 100) + "%";
74958       });
74959       container.selectAll(".display-option-reset").classed("disabled", function(d2) {
74960         return _options[d2] === 1;
74961       });
74962       if (containerEnter.size() && _options.brightness !== 1) {
74963         context.background().brightness(_options.brightness);
74964       }
74965     }
74966     return section;
74967   }
74968
74969   // modules/ui/settings/custom_background.js
74970   function uiSettingsCustomBackground() {
74971     var dispatch14 = dispatch_default("change");
74972     function render(selection2) {
74973       var _origSettings = {
74974         template: corePreferences("background-custom-template")
74975       };
74976       var _currSettings = {
74977         template: corePreferences("background-custom-template")
74978       };
74979       var example = "https://tile.openstreetmap.org/{zoom}/{x}/{y}.png";
74980       var modal = uiConfirm(selection2).okButton();
74981       modal.classed("settings-modal settings-custom-background", true);
74982       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_background.header"));
74983       var textSection = modal.select(".modal-section.message-text");
74984       var instructions = "".concat(_t.html("settings.custom_background.instructions.info"), "\n") + "\n" + "#### ".concat(_t.html("settings.custom_background.instructions.wms.tokens_label"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.proj"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.wkid"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.dimensions"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.wms.tokens.bbox"), "\n") + "\n" + "#### ".concat(_t.html("settings.custom_background.instructions.tms.tokens_label"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.xyz"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.flipped_y"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.switch"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.quadtile"), "\n") + "* ".concat(_t.html("settings.custom_background.instructions.tms.tokens.scale_factor"), "\n") + "\n" + "#### ".concat(_t.html("settings.custom_background.instructions.example"), "\n") + "`".concat(example, "`");
74985       textSection.append("div").attr("class", "instructions-template").html(marked(instructions));
74986       textSection.append("textarea").attr("class", "field-template").attr("placeholder", _t("settings.custom_background.template.placeholder")).call(utilNoAuto).property("value", _currSettings.template);
74987       var buttonSection = modal.select(".modal-section.buttons");
74988       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
74989       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
74990       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
74991       function isSaveDisabled() {
74992         return null;
74993       }
74994       function clickCancel() {
74995         textSection.select(".field-template").property("value", _origSettings.template);
74996         corePreferences("background-custom-template", _origSettings.template);
74997         this.blur();
74998         modal.close();
74999       }
75000       function clickSave() {
75001         _currSettings.template = textSection.select(".field-template").property("value");
75002         corePreferences("background-custom-template", _currSettings.template);
75003         this.blur();
75004         modal.close();
75005         dispatch14.call("change", this, _currSettings);
75006       }
75007     }
75008     return utilRebind(render, dispatch14, "on");
75009   }
75010
75011   // modules/ui/sections/background_list.js
75012   function uiSectionBackgroundList(context) {
75013     var _backgroundList = select_default2(null);
75014     var _customSource = context.background().findSource("custom");
75015     var _settingsCustomBackground = uiSettingsCustomBackground(context).on("change", customChanged);
75016     var section = uiSection("background-list", context).label(() => _t.append("background.backgrounds")).disclosureContent(renderDisclosureContent);
75017     function previousBackgroundID() {
75018       return corePreferences("background-last-used-toggle");
75019     }
75020     function renderDisclosureContent(selection2) {
75021       var container = selection2.selectAll(".layer-background-list").data([0]);
75022       _backgroundList = container.enter().append("ul").attr("class", "layer-list layer-background-list").attr("dir", "auto").merge(container);
75023       var bgExtrasListEnter = selection2.selectAll(".bg-extras-list").data([0]).enter().append("ul").attr("class", "layer-list bg-extras-list");
75024       var minimapLabelEnter = bgExtrasListEnter.append("li").attr("class", "minimap-toggle-item").append("label").call(
75025         uiTooltip().title(() => _t.append("background.minimap.tooltip")).keys([_t("background.minimap.key")]).placement("top")
75026       );
75027       minimapLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
75028         d3_event.preventDefault();
75029         uiMapInMap.toggle();
75030       });
75031       minimapLabelEnter.append("span").call(_t.append("background.minimap.description"));
75032       var panelLabelEnter = bgExtrasListEnter.append("li").attr("class", "background-panel-toggle-item").append("label").call(
75033         uiTooltip().title(() => _t.append("background.panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.background.key"))]).placement("top")
75034       );
75035       panelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
75036         d3_event.preventDefault();
75037         context.ui().info.toggle("background");
75038       });
75039       panelLabelEnter.append("span").call(_t.append("background.panel.description"));
75040       var locPanelLabelEnter = bgExtrasListEnter.append("li").attr("class", "location-panel-toggle-item").append("label").call(
75041         uiTooltip().title(() => _t.append("background.location_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.location.key"))]).placement("top")
75042       );
75043       locPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
75044         d3_event.preventDefault();
75045         context.ui().info.toggle("location");
75046       });
75047       locPanelLabelEnter.append("span").call(_t.append("background.location_panel.description"));
75048       selection2.selectAll(".imagery-faq").data([0]).enter().append("div").attr("class", "imagery-faq").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/openstreetmap/iD/blob/develop/FAQ.md#how-can-i-report-an-issue-with-background-imagery").append("span").call(_t.append("background.imagery_problem_faq"));
75049       _backgroundList.call(drawListItems, "radio", function(d3_event, d2) {
75050         chooseBackground(d2);
75051       }, function(d2) {
75052         return !d2.isHidden() && !d2.overlay;
75053       });
75054     }
75055     function setTooltips(selection2) {
75056       selection2.each(function(d2, i3, nodes) {
75057         var item = select_default2(this).select("label");
75058         var span = item.select("span");
75059         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
75060         var hasDescription = d2.hasDescription();
75061         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
75062         item.call(uiTooltip().destroyAny);
75063         if (d2.id === previousBackgroundID()) {
75064           item.call(
75065             uiTooltip().placement(placement).title(() => _t.append("background.switch")).keys([uiCmd("\u2318" + _t("background.key"))])
75066           );
75067         } else if (hasDescription || isOverflowing) {
75068           item.call(
75069             uiTooltip().placement(placement).title(() => hasDescription ? d2.description() : d2.label())
75070           );
75071         }
75072       });
75073     }
75074     function drawListItems(layerList, type2, change, filter2) {
75075       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2).sort(function(a2, b2) {
75076         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
75077       });
75078       var layerLinks = layerList.selectAll("li").data(sources, function(d2, i3) {
75079         return d2.id + "---" + i3;
75080       });
75081       layerLinks.exit().remove();
75082       var enter = layerLinks.enter().append("li").classed("layer-custom", function(d2) {
75083         return d2.id === "custom";
75084       }).classed("best", function(d2) {
75085         return d2.best();
75086       });
75087       var label = enter.append("label");
75088       label.append("input").attr("type", type2).attr("name", "background-layer").attr("value", function(d2) {
75089         return d2.id;
75090       }).on("change", change);
75091       label.append("span").each(function(d2) {
75092         d2.label()(select_default2(this));
75093       });
75094       enter.filter(function(d2) {
75095         return d2.id === "custom";
75096       }).append("button").attr("class", "layer-browse").call(
75097         uiTooltip().title(() => _t.append("settings.custom_background.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
75098       ).on("click", function(d3_event) {
75099         d3_event.preventDefault();
75100         editCustom();
75101       }).call(svgIcon("#iD-icon-more"));
75102       enter.filter(function(d2) {
75103         return d2.best();
75104       }).append("div").attr("class", "best").call(
75105         uiTooltip().title(() => _t.append("background.best_imagery")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
75106       ).append("span").text("\u2605");
75107       layerList.call(updateLayerSelections);
75108     }
75109     function updateLayerSelections(selection2) {
75110       function active(d2) {
75111         return context.background().showsLayer(d2);
75112       }
75113       selection2.selectAll("li").classed("active", active).classed("switch", function(d2) {
75114         return d2.id === previousBackgroundID();
75115       }).call(setTooltips).selectAll("input").property("checked", active);
75116     }
75117     function chooseBackground(d2) {
75118       if (d2.id === "custom" && !d2.template()) {
75119         return editCustom();
75120       }
75121       var previousBackground = context.background().baseLayerSource();
75122       corePreferences("background-last-used-toggle", previousBackground.id);
75123       corePreferences("background-last-used", d2.id);
75124       context.background().baseLayerSource(d2);
75125     }
75126     function customChanged(d2) {
75127       if (d2 && d2.template) {
75128         _customSource.template(d2.template);
75129         chooseBackground(_customSource);
75130       } else {
75131         _customSource.template("");
75132         chooseBackground(context.background().findSource("none"));
75133       }
75134     }
75135     function editCustom() {
75136       context.container().call(_settingsCustomBackground);
75137     }
75138     context.background().on("change.background_list", function() {
75139       _backgroundList.call(updateLayerSelections);
75140     });
75141     context.map().on(
75142       "move.background_list",
75143       debounce_default(function() {
75144         window.requestIdleCallback(section.reRender);
75145       }, 1e3)
75146     );
75147     return section;
75148   }
75149
75150   // modules/ui/sections/background_offset.js
75151   function uiSectionBackgroundOffset(context) {
75152     var section = uiSection("background-offset", context).label(() => _t.append("background.fix_misalignment")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
75153     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
75154     var _directions = [
75155       ["top", [0, -0.5]],
75156       ["left", [-0.5, 0]],
75157       ["right", [0.5, 0]],
75158       ["bottom", [0, 0.5]]
75159     ];
75160     function updateValue() {
75161       var meters = geoOffsetToMeters(context.background().offset());
75162       var x2 = +meters[0].toFixed(2);
75163       var y2 = +meters[1].toFixed(2);
75164       context.container().selectAll(".nudge-inner-rect").select("input").classed("error", false).property("value", x2 + ", " + y2);
75165       context.container().selectAll(".nudge-reset").classed("disabled", function() {
75166         return x2 === 0 && y2 === 0;
75167       });
75168     }
75169     function resetOffset() {
75170       context.background().offset([0, 0]);
75171       updateValue();
75172     }
75173     function nudge(d2) {
75174       context.background().nudge(d2, context.map().zoom());
75175       updateValue();
75176     }
75177     function inputOffset() {
75178       var input = select_default2(this);
75179       var d2 = input.node().value;
75180       if (d2 === "")
75181         return resetOffset();
75182       d2 = d2.replace(/;/g, ",").split(",").map(function(n3) {
75183         return !isNaN(n3) && n3;
75184       });
75185       if (d2.length !== 2 || !d2[0] || !d2[1]) {
75186         input.classed("error", true);
75187         return;
75188       }
75189       context.background().offset(geoMetersToOffset(d2));
75190       updateValue();
75191     }
75192     function dragOffset(d3_event) {
75193       if (d3_event.button !== 0)
75194         return;
75195       var origin = [d3_event.clientX, d3_event.clientY];
75196       var pointerId = d3_event.pointerId || "mouse";
75197       context.container().append("div").attr("class", "nudge-surface");
75198       select_default2(window).on(_pointerPrefix + "move.drag-bg-offset", pointermove).on(_pointerPrefix + "up.drag-bg-offset", pointerup);
75199       if (_pointerPrefix === "pointer") {
75200         select_default2(window).on("pointercancel.drag-bg-offset", pointerup);
75201       }
75202       function pointermove(d3_event2) {
75203         if (pointerId !== (d3_event2.pointerId || "mouse"))
75204           return;
75205         var latest = [d3_event2.clientX, d3_event2.clientY];
75206         var d2 = [
75207           -(origin[0] - latest[0]) / 4,
75208           -(origin[1] - latest[1]) / 4
75209         ];
75210         origin = latest;
75211         nudge(d2);
75212       }
75213       function pointerup(d3_event2) {
75214         if (pointerId !== (d3_event2.pointerId || "mouse"))
75215           return;
75216         if (d3_event2.button !== 0)
75217           return;
75218         context.container().selectAll(".nudge-surface").remove();
75219         select_default2(window).on(".drag-bg-offset", null);
75220       }
75221     }
75222     function renderDisclosureContent(selection2) {
75223       var container = selection2.selectAll(".nudge-container").data([0]);
75224       var containerEnter = container.enter().append("div").attr("class", "nudge-container");
75225       containerEnter.append("div").attr("class", "nudge-instructions").call(_t.append("background.offset"));
75226       var nudgeWrapEnter = containerEnter.append("div").attr("class", "nudge-controls-wrap");
75227       var nudgeEnter = nudgeWrapEnter.append("div").attr("class", "nudge-outer-rect").on(_pointerPrefix + "down", dragOffset);
75228       nudgeEnter.append("div").attr("class", "nudge-inner-rect").append("input").attr("type", "text").attr("aria-label", _t("background.offset_label")).on("change", inputOffset);
75229       nudgeWrapEnter.append("div").selectAll("button").data(_directions).enter().append("button").attr("title", function(d2) {
75230         return _t("background.nudge.".concat(d2[0]));
75231       }).attr("class", function(d2) {
75232         return d2[0] + " nudge";
75233       }).on("click", function(d3_event, d2) {
75234         nudge(d2[1]);
75235       });
75236       nudgeWrapEnter.append("button").attr("title", _t("background.reset")).attr("class", "nudge-reset disabled").on("click", function(d3_event) {
75237         d3_event.preventDefault();
75238         resetOffset();
75239       }).call(svgIcon("#iD-icon-" + (_mainLocalizer.textDirection() === "rtl" ? "redo" : "undo")));
75240       updateValue();
75241     }
75242     context.background().on("change.backgroundOffset-update", updateValue);
75243     return section;
75244   }
75245
75246   // modules/ui/sections/overlay_list.js
75247   function uiSectionOverlayList(context) {
75248     var section = uiSection("overlay-list", context).label(() => _t.append("background.overlays")).disclosureContent(renderDisclosureContent);
75249     var _overlayList = select_default2(null);
75250     function setTooltips(selection2) {
75251       selection2.each(function(d2, i3, nodes) {
75252         var item = select_default2(this).select("label");
75253         var span = item.select("span");
75254         var placement = i3 < nodes.length / 2 ? "bottom" : "top";
75255         var description = d2.description();
75256         var isOverflowing = span.property("clientWidth") !== span.property("scrollWidth");
75257         item.call(uiTooltip().destroyAny);
75258         if (description || isOverflowing) {
75259           item.call(
75260             uiTooltip().placement(placement).title(() => description || d2.name())
75261           );
75262         }
75263       });
75264     }
75265     function updateLayerSelections(selection2) {
75266       function active(d2) {
75267         return context.background().showsLayer(d2);
75268       }
75269       selection2.selectAll("li").classed("active", active).call(setTooltips).selectAll("input").property("checked", active);
75270     }
75271     function chooseOverlay(d3_event, d2) {
75272       d3_event.preventDefault();
75273       context.background().toggleOverlayLayer(d2);
75274       _overlayList.call(updateLayerSelections);
75275       document.activeElement.blur();
75276     }
75277     function drawListItems(layerList, type2, change, filter2) {
75278       var sources = context.background().sources(context.map().extent(), context.map().zoom(), true).filter(filter2);
75279       var layerLinks = layerList.selectAll("li").data(sources, function(d2) {
75280         return d2.name();
75281       });
75282       layerLinks.exit().remove();
75283       var enter = layerLinks.enter().append("li");
75284       var label = enter.append("label");
75285       label.append("input").attr("type", type2).attr("name", "layers").on("change", change);
75286       label.append("span").each(function(d2) {
75287         d2.label()(select_default2(this));
75288       });
75289       layerList.selectAll("li").sort(sortSources);
75290       layerList.call(updateLayerSelections);
75291       function sortSources(a2, b2) {
75292         return a2.best() && !b2.best() ? -1 : b2.best() && !a2.best() ? 1 : descending(a2.area(), b2.area()) || ascending(a2.name(), b2.name()) || 0;
75293       }
75294     }
75295     function renderDisclosureContent(selection2) {
75296       var container = selection2.selectAll(".layer-overlay-list").data([0]);
75297       _overlayList = container.enter().append("ul").attr("class", "layer-list layer-overlay-list").attr("dir", "auto").merge(container);
75298       _overlayList.call(drawListItems, "checkbox", chooseOverlay, function(d2) {
75299         return !d2.isHidden() && d2.overlay;
75300       });
75301     }
75302     context.map().on(
75303       "move.overlay_list",
75304       debounce_default(function() {
75305         window.requestIdleCallback(section.reRender);
75306       }, 1e3)
75307     );
75308     return section;
75309   }
75310
75311   // modules/ui/panes/background.js
75312   function uiPaneBackground(context) {
75313     var backgroundPane = uiPane("background", context).key(_t("background.key")).label(_t.append("background.title")).description(_t.append("background.description")).iconName("iD-icon-layers").sections([
75314       uiSectionBackgroundList(context),
75315       uiSectionOverlayList(context),
75316       uiSectionBackgroundDisplayOptions(context),
75317       uiSectionBackgroundOffset(context)
75318     ]);
75319     return backgroundPane;
75320   }
75321
75322   // modules/ui/panes/help.js
75323   function uiPaneHelp(context) {
75324     var docKeys = [
75325       ["help", [
75326         "welcome",
75327         "open_data_h",
75328         "open_data",
75329         "before_start_h",
75330         "before_start",
75331         "open_source_h",
75332         "open_source",
75333         "open_source_attribution",
75334         "open_source_help"
75335       ]],
75336       ["overview", [
75337         "navigation_h",
75338         "navigation_drag",
75339         "navigation_zoom",
75340         "features_h",
75341         "features",
75342         "nodes_ways"
75343       ]],
75344       ["editing", [
75345         "select_h",
75346         "select_left_click",
75347         "select_right_click",
75348         "select_space",
75349         "multiselect_h",
75350         "multiselect",
75351         "multiselect_shift_click",
75352         "multiselect_lasso",
75353         "undo_redo_h",
75354         "undo_redo",
75355         "save_h",
75356         "save",
75357         "save_validation",
75358         "upload_h",
75359         "upload",
75360         "backups_h",
75361         "backups",
75362         "keyboard_h",
75363         "keyboard"
75364       ]],
75365       ["feature_editor", [
75366         "intro",
75367         "definitions",
75368         "type_h",
75369         "type",
75370         "type_picker",
75371         "fields_h",
75372         "fields_all_fields",
75373         "fields_example",
75374         "fields_add_field",
75375         "tags_h",
75376         "tags_all_tags",
75377         "tags_resources"
75378       ]],
75379       ["points", [
75380         "intro",
75381         "add_point_h",
75382         "add_point",
75383         "add_point_finish",
75384         "move_point_h",
75385         "move_point",
75386         "delete_point_h",
75387         "delete_point",
75388         "delete_point_command"
75389       ]],
75390       ["lines", [
75391         "intro",
75392         "add_line_h",
75393         "add_line",
75394         "add_line_draw",
75395         "add_line_continue",
75396         "add_line_finish",
75397         "modify_line_h",
75398         "modify_line_dragnode",
75399         "modify_line_addnode",
75400         "connect_line_h",
75401         "connect_line",
75402         "connect_line_display",
75403         "connect_line_drag",
75404         "connect_line_tag",
75405         "disconnect_line_h",
75406         "disconnect_line_command",
75407         "move_line_h",
75408         "move_line_command",
75409         "move_line_connected",
75410         "delete_line_h",
75411         "delete_line",
75412         "delete_line_command"
75413       ]],
75414       ["areas", [
75415         "intro",
75416         "point_or_area_h",
75417         "point_or_area",
75418         "add_area_h",
75419         "add_area_command",
75420         "add_area_draw",
75421         "add_area_continue",
75422         "add_area_finish",
75423         "square_area_h",
75424         "square_area_command",
75425         "modify_area_h",
75426         "modify_area_dragnode",
75427         "modify_area_addnode",
75428         "delete_area_h",
75429         "delete_area",
75430         "delete_area_command"
75431       ]],
75432       ["relations", [
75433         "intro",
75434         "edit_relation_h",
75435         "edit_relation",
75436         "edit_relation_add",
75437         "edit_relation_delete",
75438         "maintain_relation_h",
75439         "maintain_relation",
75440         "relation_types_h",
75441         "multipolygon_h",
75442         "multipolygon",
75443         "multipolygon_create",
75444         "multipolygon_merge",
75445         "turn_restriction_h",
75446         "turn_restriction",
75447         "turn_restriction_field",
75448         "turn_restriction_editing",
75449         "route_h",
75450         "route",
75451         "route_add",
75452         "boundary_h",
75453         "boundary",
75454         "boundary_add"
75455       ]],
75456       ["operations", [
75457         "intro",
75458         "intro_2",
75459         "straighten",
75460         "orthogonalize",
75461         "circularize",
75462         "move",
75463         "rotate",
75464         "reflect",
75465         "continue",
75466         "reverse",
75467         "disconnect",
75468         "split",
75469         "extract",
75470         "merge",
75471         "delete",
75472         "downgrade",
75473         "copy_paste"
75474       ]],
75475       ["notes", [
75476         "intro",
75477         "add_note_h",
75478         "add_note",
75479         "place_note",
75480         "move_note",
75481         "update_note_h",
75482         "update_note",
75483         "save_note_h",
75484         "save_note"
75485       ]],
75486       ["imagery", [
75487         "intro",
75488         "sources_h",
75489         "choosing",
75490         "sources",
75491         "offsets_h",
75492         "offset",
75493         "offset_change"
75494       ]],
75495       ["streetlevel", [
75496         "intro",
75497         "using_h",
75498         "using",
75499         "photos",
75500         "viewer"
75501       ]],
75502       ["gps", [
75503         "intro",
75504         "survey",
75505         "using_h",
75506         "using",
75507         "tracing",
75508         "upload"
75509       ]],
75510       ["qa", [
75511         "intro",
75512         "tools_h",
75513         "tools",
75514         "issues_h",
75515         "issues"
75516       ]]
75517     ];
75518     var headings = {
75519       "help.help.open_data_h": 3,
75520       "help.help.before_start_h": 3,
75521       "help.help.open_source_h": 3,
75522       "help.overview.navigation_h": 3,
75523       "help.overview.features_h": 3,
75524       "help.editing.select_h": 3,
75525       "help.editing.multiselect_h": 3,
75526       "help.editing.undo_redo_h": 3,
75527       "help.editing.save_h": 3,
75528       "help.editing.upload_h": 3,
75529       "help.editing.backups_h": 3,
75530       "help.editing.keyboard_h": 3,
75531       "help.feature_editor.type_h": 3,
75532       "help.feature_editor.fields_h": 3,
75533       "help.feature_editor.tags_h": 3,
75534       "help.points.add_point_h": 3,
75535       "help.points.move_point_h": 3,
75536       "help.points.delete_point_h": 3,
75537       "help.lines.add_line_h": 3,
75538       "help.lines.modify_line_h": 3,
75539       "help.lines.connect_line_h": 3,
75540       "help.lines.disconnect_line_h": 3,
75541       "help.lines.move_line_h": 3,
75542       "help.lines.delete_line_h": 3,
75543       "help.areas.point_or_area_h": 3,
75544       "help.areas.add_area_h": 3,
75545       "help.areas.square_area_h": 3,
75546       "help.areas.modify_area_h": 3,
75547       "help.areas.delete_area_h": 3,
75548       "help.relations.edit_relation_h": 3,
75549       "help.relations.maintain_relation_h": 3,
75550       "help.relations.relation_types_h": 2,
75551       "help.relations.multipolygon_h": 3,
75552       "help.relations.turn_restriction_h": 3,
75553       "help.relations.route_h": 3,
75554       "help.relations.boundary_h": 3,
75555       "help.notes.add_note_h": 3,
75556       "help.notes.update_note_h": 3,
75557       "help.notes.save_note_h": 3,
75558       "help.imagery.sources_h": 3,
75559       "help.imagery.offsets_h": 3,
75560       "help.streetlevel.using_h": 3,
75561       "help.gps.using_h": 3,
75562       "help.qa.tools_h": 3,
75563       "help.qa.issues_h": 3
75564     };
75565     var docs = docKeys.map(function(key) {
75566       var helpkey = "help." + key[0];
75567       var helpPaneReplacements = { version: context.version };
75568       var text = key[1].reduce(function(all, part) {
75569         var subkey = helpkey + "." + part;
75570         var depth = headings[subkey];
75571         var hhh = depth ? Array(depth + 1).join("#") + " " : "";
75572         return all + hhh + helpHtml(subkey, helpPaneReplacements) + "\n\n";
75573       }, "");
75574       return {
75575         title: _t.html(helpkey + ".title"),
75576         content: marked(text.trim()).replace(/<code>/g, "<kbd>").replace(/<\/code>/g, "</kbd>")
75577       };
75578     });
75579     var helpPane = uiPane("help", context).key(_t("help.key")).label(_t.append("help.title")).description(_t.append("help.title")).iconName("iD-icon-help");
75580     helpPane.renderContent = function(content) {
75581       function clickHelp(d2, i3) {
75582         var rtl = _mainLocalizer.textDirection() === "rtl";
75583         content.property("scrollTop", 0);
75584         helpPane.selection().select(".pane-heading h2").html(d2.title);
75585         body.html(d2.content);
75586         body.selectAll("a").attr("target", "_blank");
75587         menuItems.classed("selected", function(m2) {
75588           return m2.title === d2.title;
75589         });
75590         nav.html("");
75591         if (rtl) {
75592           nav.call(drawNext).call(drawPrevious);
75593         } else {
75594           nav.call(drawPrevious).call(drawNext);
75595         }
75596         function drawNext(selection2) {
75597           if (i3 < docs.length - 1) {
75598             var nextLink = selection2.append("a").attr("href", "#").attr("class", "next").on("click", function(d3_event) {
75599               d3_event.preventDefault();
75600               clickHelp(docs[i3 + 1], i3 + 1);
75601             });
75602             nextLink.append("span").html(docs[i3 + 1].title).call(svgIcon(rtl ? "#iD-icon-backward" : "#iD-icon-forward", "inline"));
75603           }
75604         }
75605         function drawPrevious(selection2) {
75606           if (i3 > 0) {
75607             var prevLink = selection2.append("a").attr("href", "#").attr("class", "previous").on("click", function(d3_event) {
75608               d3_event.preventDefault();
75609               clickHelp(docs[i3 - 1], i3 - 1);
75610             });
75611             prevLink.call(svgIcon(rtl ? "#iD-icon-forward" : "#iD-icon-backward", "inline")).append("span").html(docs[i3 - 1].title);
75612           }
75613         }
75614       }
75615       function clickWalkthrough(d3_event) {
75616         d3_event.preventDefault();
75617         if (context.inIntro())
75618           return;
75619         context.container().call(uiIntro(context));
75620         context.ui().togglePanes();
75621       }
75622       function clickShortcuts(d3_event) {
75623         d3_event.preventDefault();
75624         context.container().call(context.ui().shortcuts, true);
75625       }
75626       var toc = content.append("ul").attr("class", "toc");
75627       var menuItems = toc.selectAll("li").data(docs).enter().append("li").append("a").attr("role", "button").attr("href", "#").html(function(d2) {
75628         return d2.title;
75629       }).on("click", function(d3_event, d2) {
75630         d3_event.preventDefault();
75631         clickHelp(d2, docs.indexOf(d2));
75632       });
75633       var shortcuts = toc.append("li").attr("class", "shortcuts").call(
75634         uiTooltip().title(() => _t.append("shortcuts.tooltip")).keys(["?"]).placement("top")
75635       ).append("a").attr("href", "#").on("click", clickShortcuts);
75636       shortcuts.append("div").call(_t.append("shortcuts.title"));
75637       var walkthrough = toc.append("li").attr("class", "walkthrough").append("a").attr("href", "#").on("click", clickWalkthrough);
75638       walkthrough.append("svg").attr("class", "logo logo-walkthrough").append("use").attr("xlink:href", "#iD-logo-walkthrough");
75639       walkthrough.append("div").call(_t.append("splash.walkthrough"));
75640       var helpContent = content.append("div").attr("class", "left-content");
75641       var body = helpContent.append("div").attr("class", "body");
75642       var nav = helpContent.append("div").attr("class", "nav");
75643       clickHelp(docs[0], 0);
75644     };
75645     return helpPane;
75646   }
75647
75648   // modules/ui/sections/validation_issues.js
75649   function uiSectionValidationIssues(id2, severity, context) {
75650     var _issues = [];
75651     var section = uiSection(id2, context).label(function() {
75652       if (!_issues)
75653         return "";
75654       var issueCountText = _issues.length > 1e3 ? "1000+" : String(_issues.length);
75655       return _t.append("inspector.title_count", { title: _t("issues." + severity + "s.list_title"), count: issueCountText });
75656     }).disclosureContent(renderDisclosureContent).shouldDisplay(function() {
75657       return _issues && _issues.length;
75658     });
75659     function getOptions() {
75660       return {
75661         what: corePreferences("validate-what") || "edited",
75662         where: corePreferences("validate-where") || "all"
75663       };
75664     }
75665     function reloadIssues() {
75666       _issues = context.validator().getIssuesBySeverity(getOptions())[severity];
75667     }
75668     function renderDisclosureContent(selection2) {
75669       var center = context.map().center();
75670       var graph = context.graph();
75671       var issues = _issues.map(function withDistance(issue) {
75672         var extent = issue.extent(graph);
75673         var dist = extent ? geoSphericalDistance(center, extent.center()) : 0;
75674         return Object.assign(issue, { dist });
75675       }).sort(function byDistance(a2, b2) {
75676         return a2.dist - b2.dist;
75677       });
75678       issues = issues.slice(0, 1e3);
75679       selection2.call(drawIssuesList, issues);
75680     }
75681     function drawIssuesList(selection2, issues) {
75682       var list2 = selection2.selectAll(".issues-list").data([0]);
75683       list2 = list2.enter().append("ul").attr("class", "layer-list issues-list " + severity + "s-list").merge(list2);
75684       var items = list2.selectAll("li").data(issues, function(d2) {
75685         return d2.key;
75686       });
75687       items.exit().remove();
75688       var itemsEnter = items.enter().append("li").attr("class", function(d2) {
75689         return "issue severity-" + d2.severity;
75690       });
75691       var labelsEnter = itemsEnter.append("button").attr("class", "issue-label").on("click", function(d3_event, d2) {
75692         context.validator().focusIssue(d2);
75693       }).on("mouseover", function(d3_event, d2) {
75694         utilHighlightEntities(d2.entityIds, true, context);
75695       }).on("mouseout", function(d3_event, d2) {
75696         utilHighlightEntities(d2.entityIds, false, context);
75697       });
75698       var textEnter = labelsEnter.append("span").attr("class", "issue-text");
75699       textEnter.append("span").attr("class", "issue-icon").each(function(d2) {
75700         var iconName = "#iD-icon-" + (d2.severity === "warning" ? "alert" : "error");
75701         select_default2(this).call(svgIcon(iconName));
75702       });
75703       textEnter.append("span").attr("class", "issue-message");
75704       items = items.merge(itemsEnter).order();
75705       items.selectAll(".issue-message").text("").each(function(d2) {
75706         return d2.message(context)(select_default2(this));
75707       });
75708     }
75709     context.validator().on("validated.uiSectionValidationIssues" + id2, function() {
75710       window.requestIdleCallback(function() {
75711         reloadIssues();
75712         section.reRender();
75713       });
75714     });
75715     context.map().on(
75716       "move.uiSectionValidationIssues" + id2,
75717       debounce_default(function() {
75718         window.requestIdleCallback(function() {
75719           if (getOptions().where === "visible") {
75720             reloadIssues();
75721           }
75722           section.reRender();
75723         });
75724       }, 1e3)
75725     );
75726     return section;
75727   }
75728
75729   // modules/ui/sections/validation_options.js
75730   function uiSectionValidationOptions(context) {
75731     var section = uiSection("issues-options", context).content(renderContent);
75732     function renderContent(selection2) {
75733       var container = selection2.selectAll(".issues-options-container").data([0]);
75734       container = container.enter().append("div").attr("class", "issues-options-container").merge(container);
75735       var data = [
75736         { key: "what", values: ["edited", "all"] },
75737         { key: "where", values: ["visible", "all"] }
75738       ];
75739       var options2 = container.selectAll(".issues-option").data(data, function(d2) {
75740         return d2.key;
75741       });
75742       var optionsEnter = options2.enter().append("div").attr("class", function(d2) {
75743         return "issues-option issues-option-" + d2.key;
75744       });
75745       optionsEnter.append("div").attr("class", "issues-option-title").html(function(d2) {
75746         return _t.html("issues.options." + d2.key + ".title");
75747       });
75748       var valuesEnter = optionsEnter.selectAll("label").data(function(d2) {
75749         return d2.values.map(function(val) {
75750           return { value: val, key: d2.key };
75751         });
75752       }).enter().append("label");
75753       valuesEnter.append("input").attr("type", "radio").attr("name", function(d2) {
75754         return "issues-option-" + d2.key;
75755       }).attr("value", function(d2) {
75756         return d2.value;
75757       }).property("checked", function(d2) {
75758         return getOptions()[d2.key] === d2.value;
75759       }).on("change", function(d3_event, d2) {
75760         updateOptionValue(d3_event, d2.key, d2.value);
75761       });
75762       valuesEnter.append("span").html(function(d2) {
75763         return _t.html("issues.options." + d2.key + "." + d2.value);
75764       });
75765     }
75766     function getOptions() {
75767       return {
75768         what: corePreferences("validate-what") || "edited",
75769         // 'all', 'edited'
75770         where: corePreferences("validate-where") || "all"
75771         // 'all', 'visible'
75772       };
75773     }
75774     function updateOptionValue(d3_event, d2, val) {
75775       if (!val && d3_event && d3_event.target) {
75776         val = d3_event.target.value;
75777       }
75778       corePreferences("validate-" + d2, val);
75779       context.validator().validate();
75780     }
75781     return section;
75782   }
75783
75784   // modules/ui/sections/validation_rules.js
75785   function uiSectionValidationRules(context) {
75786     var MINSQUARE = 0;
75787     var MAXSQUARE = 20;
75788     var DEFAULTSQUARE = 5;
75789     var section = uiSection("issues-rules", context).disclosureContent(renderDisclosureContent).label(() => _t.append("issues.rules.title"));
75790     var _ruleKeys = context.validator().getRuleKeys().filter(function(key) {
75791       return key !== "maprules";
75792     }).sort(function(key1, key2) {
75793       return _t("issues." + key1 + ".title") < _t("issues." + key2 + ".title") ? -1 : 1;
75794     });
75795     function renderDisclosureContent(selection2) {
75796       var container = selection2.selectAll(".issues-rulelist-container").data([0]);
75797       var containerEnter = container.enter().append("div").attr("class", "issues-rulelist-container");
75798       containerEnter.append("ul").attr("class", "layer-list issue-rules-list");
75799       var ruleLinks = containerEnter.append("div").attr("class", "issue-rules-links section-footer");
75800       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
75801         d3_event.preventDefault();
75802         context.validator().disableRules(_ruleKeys);
75803       });
75804       ruleLinks.append("a").attr("class", "issue-rules-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
75805         d3_event.preventDefault();
75806         context.validator().disableRules([]);
75807       });
75808       container = container.merge(containerEnter);
75809       container.selectAll(".issue-rules-list").call(drawListItems, _ruleKeys, "checkbox", "rule", toggleRule, isRuleEnabled);
75810     }
75811     function drawListItems(selection2, data, type2, name, change, active) {
75812       var items = selection2.selectAll("li").data(data);
75813       items.exit().remove();
75814       var enter = items.enter().append("li");
75815       if (name === "rule") {
75816         enter.call(
75817           uiTooltip().title(function(d2) {
75818             return _t.append("issues." + d2 + ".tip");
75819           }).placement("top")
75820         );
75821       }
75822       var label = enter.append("label");
75823       label.append("input").attr("type", type2).attr("name", name).on("change", change);
75824       label.append("span").html(function(d2) {
75825         var params = {};
75826         if (d2 === "unsquare_way") {
75827           params.val = { html: '<span class="square-degrees"></span>' };
75828         }
75829         return _t.html("issues." + d2 + ".title", params);
75830       });
75831       items = items.merge(enter);
75832       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
75833       var degStr = corePreferences("validate-square-degrees");
75834       if (degStr === null) {
75835         degStr = DEFAULTSQUARE.toString();
75836       }
75837       var span = items.selectAll(".square-degrees");
75838       var input = span.selectAll(".square-degrees-input").data([0]);
75839       input.enter().append("input").attr("type", "number").attr("min", MINSQUARE.toString()).attr("max", MAXSQUARE.toString()).attr("step", "0.5").attr("class", "square-degrees-input").call(utilNoAuto).on("click", function(d3_event) {
75840         d3_event.preventDefault();
75841         d3_event.stopPropagation();
75842         this.select();
75843       }).on("keyup", function(d3_event) {
75844         if (d3_event.keyCode === 13) {
75845           this.blur();
75846           this.select();
75847         }
75848       }).on("blur", changeSquare).merge(input).property("value", degStr);
75849     }
75850     function changeSquare() {
75851       var input = select_default2(this);
75852       var degStr = utilGetSetValue(input).trim();
75853       var degNum = Number(degStr);
75854       if (!isFinite(degNum)) {
75855         degNum = DEFAULTSQUARE;
75856       } else if (degNum > MAXSQUARE) {
75857         degNum = MAXSQUARE;
75858       } else if (degNum < MINSQUARE) {
75859         degNum = MINSQUARE;
75860       }
75861       degNum = Math.round(degNum * 10) / 10;
75862       degStr = degNum.toString();
75863       input.property("value", degStr);
75864       corePreferences("validate-square-degrees", degStr);
75865       context.validator().revalidateUnsquare();
75866     }
75867     function isRuleEnabled(d2) {
75868       return context.validator().isRuleEnabled(d2);
75869     }
75870     function toggleRule(d3_event, d2) {
75871       context.validator().toggleRule(d2);
75872     }
75873     context.validator().on("validated.uiSectionValidationRules", function() {
75874       window.requestIdleCallback(section.reRender);
75875     });
75876     return section;
75877   }
75878
75879   // modules/ui/sections/validation_status.js
75880   function uiSectionValidationStatus(context) {
75881     var section = uiSection("issues-status", context).content(renderContent).shouldDisplay(function() {
75882       var issues = context.validator().getIssues(getOptions());
75883       return issues.length === 0;
75884     });
75885     function getOptions() {
75886       return {
75887         what: corePreferences("validate-what") || "edited",
75888         where: corePreferences("validate-where") || "all"
75889       };
75890     }
75891     function renderContent(selection2) {
75892       var box = selection2.selectAll(".box").data([0]);
75893       var boxEnter = box.enter().append("div").attr("class", "box");
75894       boxEnter.append("div").call(svgIcon("#iD-icon-apply", "pre-text"));
75895       var noIssuesMessage = boxEnter.append("span");
75896       noIssuesMessage.append("strong").attr("class", "message");
75897       noIssuesMessage.append("br");
75898       noIssuesMessage.append("span").attr("class", "details");
75899       renderIgnoredIssuesReset(selection2);
75900       setNoIssuesText(selection2);
75901     }
75902     function renderIgnoredIssuesReset(selection2) {
75903       var ignoredIssues = context.validator().getIssues({ what: "all", where: "all", includeDisabledRules: true, includeIgnored: "only" });
75904       var resetIgnored = selection2.selectAll(".reset-ignored").data(ignoredIssues.length ? [0] : []);
75905       resetIgnored.exit().remove();
75906       var resetIgnoredEnter = resetIgnored.enter().append("div").attr("class", "reset-ignored section-footer");
75907       resetIgnoredEnter.append("a").attr("href", "#");
75908       resetIgnored = resetIgnored.merge(resetIgnoredEnter);
75909       resetIgnored.select("a").html(_t.html("inspector.title_count", { title: { html: _t.html("issues.reset_ignored") }, count: ignoredIssues.length }));
75910       resetIgnored.on("click", function(d3_event) {
75911         d3_event.preventDefault();
75912         context.validator().resetIgnoredIssues();
75913       });
75914     }
75915     function setNoIssuesText(selection2) {
75916       var opts = getOptions();
75917       function checkForHiddenIssues(cases) {
75918         for (var type2 in cases) {
75919           var hiddenOpts = cases[type2];
75920           var hiddenIssues = context.validator().getIssues(hiddenOpts);
75921           if (hiddenIssues.length) {
75922             selection2.select(".box .details").html("").call(_t.append(
75923               "issues.no_issues.hidden_issues." + type2,
75924               { count: hiddenIssues.length.toString() }
75925             ));
75926             return;
75927           }
75928         }
75929         selection2.select(".box .details").html("").call(_t.append("issues.no_issues.hidden_issues.none"));
75930       }
75931       var messageType;
75932       if (opts.what === "edited" && opts.where === "visible") {
75933         messageType = "edits_in_view";
75934         checkForHiddenIssues({
75935           elsewhere: { what: "edited", where: "all" },
75936           everything_else: { what: "all", where: "visible" },
75937           disabled_rules: { what: "edited", where: "visible", includeDisabledRules: "only" },
75938           everything_else_elsewhere: { what: "all", where: "all" },
75939           disabled_rules_elsewhere: { what: "edited", where: "all", includeDisabledRules: "only" },
75940           ignored_issues: { what: "edited", where: "visible", includeIgnored: "only" },
75941           ignored_issues_elsewhere: { what: "edited", where: "all", includeIgnored: "only" }
75942         });
75943       } else if (opts.what === "edited" && opts.where === "all") {
75944         messageType = "edits";
75945         checkForHiddenIssues({
75946           everything_else: { what: "all", where: "all" },
75947           disabled_rules: { what: "edited", where: "all", includeDisabledRules: "only" },
75948           ignored_issues: { what: "edited", where: "all", includeIgnored: "only" }
75949         });
75950       } else if (opts.what === "all" && opts.where === "visible") {
75951         messageType = "everything_in_view";
75952         checkForHiddenIssues({
75953           elsewhere: { what: "all", where: "all" },
75954           disabled_rules: { what: "all", where: "visible", includeDisabledRules: "only" },
75955           disabled_rules_elsewhere: { what: "all", where: "all", includeDisabledRules: "only" },
75956           ignored_issues: { what: "all", where: "visible", includeIgnored: "only" },
75957           ignored_issues_elsewhere: { what: "all", where: "all", includeIgnored: "only" }
75958         });
75959       } else if (opts.what === "all" && opts.where === "all") {
75960         messageType = "everything";
75961         checkForHiddenIssues({
75962           disabled_rules: { what: "all", where: "all", includeDisabledRules: "only" },
75963           ignored_issues: { what: "all", where: "all", includeIgnored: "only" }
75964         });
75965       }
75966       if (opts.what === "edited" && context.history().difference().summary().length === 0) {
75967         messageType = "no_edits";
75968       }
75969       selection2.select(".box .message").html("").call(_t.append("issues.no_issues.message." + messageType));
75970     }
75971     context.validator().on("validated.uiSectionValidationStatus", function() {
75972       window.requestIdleCallback(section.reRender);
75973     });
75974     context.map().on(
75975       "move.uiSectionValidationStatus",
75976       debounce_default(function() {
75977         window.requestIdleCallback(section.reRender);
75978       }, 1e3)
75979     );
75980     return section;
75981   }
75982
75983   // modules/ui/panes/issues.js
75984   function uiPaneIssues(context) {
75985     var issuesPane = uiPane("issues", context).key(_t("issues.key")).label(_t.append("issues.title")).description(_t.append("issues.title")).iconName("iD-icon-alert").sections([
75986       uiSectionValidationOptions(context),
75987       uiSectionValidationStatus(context),
75988       uiSectionValidationIssues("issues-errors", "error", context),
75989       uiSectionValidationIssues("issues-warnings", "warning", context),
75990       uiSectionValidationRules(context)
75991     ]);
75992     return issuesPane;
75993   }
75994
75995   // modules/ui/settings/custom_data.js
75996   function uiSettingsCustomData(context) {
75997     var dispatch14 = dispatch_default("change");
75998     function render(selection2) {
75999       var dataLayer = context.layers().layer("data");
76000       var _origSettings = {
76001         fileList: dataLayer && dataLayer.fileList() || null,
76002         url: corePreferences("settings-custom-data-url")
76003       };
76004       var _currSettings = {
76005         fileList: dataLayer && dataLayer.fileList() || null
76006         // url: prefs('settings-custom-data-url')
76007       };
76008       var modal = uiConfirm(selection2).okButton();
76009       modal.classed("settings-modal settings-custom-data", true);
76010       modal.select(".modal-section.header").append("h3").call(_t.append("settings.custom_data.header"));
76011       var textSection = modal.select(".modal-section.message-text");
76012       textSection.append("pre").attr("class", "instructions-file").call(_t.append("settings.custom_data.file.instructions"));
76013       textSection.append("input").attr("class", "field-file").attr("type", "file").attr("accept", ".gpx,.kml,.geojson,.json,application/gpx+xml,application/vnd.google-earth.kml+xml,application/geo+json,application/json").property("files", _currSettings.fileList).on("change", function(d3_event) {
76014         var files = d3_event.target.files;
76015         if (files && files.length) {
76016           _currSettings.url = "";
76017           textSection.select(".field-url").property("value", "");
76018           _currSettings.fileList = files;
76019         } else {
76020           _currSettings.fileList = null;
76021         }
76022       });
76023       textSection.append("h4").call(_t.append("settings.custom_data.or"));
76024       textSection.append("pre").attr("class", "instructions-url").call(_t.append("settings.custom_data.url.instructions"));
76025       textSection.append("textarea").attr("class", "field-url").attr("placeholder", _t("settings.custom_data.url.placeholder")).call(utilNoAuto).property("value", _currSettings.url);
76026       var buttonSection = modal.select(".modal-section.buttons");
76027       buttonSection.insert("button", ".ok-button").attr("class", "button cancel-button secondary-action").call(_t.append("confirm.cancel"));
76028       buttonSection.select(".cancel-button").on("click.cancel", clickCancel);
76029       buttonSection.select(".ok-button").attr("disabled", isSaveDisabled).on("click.save", clickSave);
76030       function isSaveDisabled() {
76031         return null;
76032       }
76033       function clickCancel() {
76034         textSection.select(".field-url").property("value", _origSettings.url);
76035         corePreferences("settings-custom-data-url", _origSettings.url);
76036         this.blur();
76037         modal.close();
76038       }
76039       function clickSave() {
76040         _currSettings.url = textSection.select(".field-url").property("value").trim();
76041         if (_currSettings.url) {
76042           _currSettings.fileList = null;
76043         }
76044         if (_currSettings.fileList) {
76045           _currSettings.url = "";
76046         }
76047         corePreferences("settings-custom-data-url", _currSettings.url);
76048         this.blur();
76049         modal.close();
76050         dispatch14.call("change", this, _currSettings);
76051       }
76052     }
76053     return utilRebind(render, dispatch14, "on");
76054   }
76055
76056   // modules/ui/sections/data_layers.js
76057   function uiSectionDataLayers(context) {
76058     var settingsCustomData = uiSettingsCustomData(context).on("change", customChanged);
76059     var layers = context.layers();
76060     var section = uiSection("data-layers", context).label(() => _t.append("map_data.data_layers")).disclosureContent(renderDisclosureContent);
76061     function renderDisclosureContent(selection2) {
76062       var container = selection2.selectAll(".data-layer-container").data([0]);
76063       container.enter().append("div").attr("class", "data-layer-container").merge(container).call(drawOsmItems).call(drawQAItems).call(drawCustomDataItems).call(drawVectorItems).call(drawPanelItems);
76064     }
76065     function showsLayer(which) {
76066       var layer = layers.layer(which);
76067       if (layer) {
76068         return layer.enabled();
76069       }
76070       return false;
76071     }
76072     function setLayer(which, enabled) {
76073       var mode = context.mode();
76074       if (mode && /^draw/.test(mode.id))
76075         return;
76076       var layer = layers.layer(which);
76077       if (layer) {
76078         layer.enabled(enabled);
76079         if (!enabled && (which === "osm" || which === "notes")) {
76080           context.enter(modeBrowse(context));
76081         }
76082       }
76083     }
76084     function toggleLayer(which) {
76085       setLayer(which, !showsLayer(which));
76086     }
76087     function drawOsmItems(selection2) {
76088       var osmKeys = ["osm", "notes"];
76089       var osmLayers = layers.all().filter(function(obj) {
76090         return osmKeys.indexOf(obj.id) !== -1;
76091       });
76092       var ul = selection2.selectAll(".layer-list-osm").data([0]);
76093       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-osm").merge(ul);
76094       var li = ul.selectAll(".list-item").data(osmLayers);
76095       li.exit().remove();
76096       var liEnter = li.enter().append("li").attr("class", function(d2) {
76097         return "list-item list-item-" + d2.id;
76098       });
76099       var labelEnter = liEnter.append("label").each(function(d2) {
76100         if (d2.id === "osm") {
76101           select_default2(this).call(
76102             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).keys([uiCmd("\u2325" + _t("area_fill.wireframe.key"))]).placement("bottom")
76103           );
76104         } else {
76105           select_default2(this).call(
76106             uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
76107           );
76108         }
76109       });
76110       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76111         toggleLayer(d2.id);
76112       });
76113       labelEnter.append("span").html(function(d2) {
76114         return _t.html("map_data.layers." + d2.id + ".title");
76115       });
76116       li.merge(liEnter).classed("active", function(d2) {
76117         return d2.layer.enabled();
76118       }).selectAll("input").property("checked", function(d2) {
76119         return d2.layer.enabled();
76120       });
76121     }
76122     function drawQAItems(selection2) {
76123       var qaKeys = ["keepRight", "improveOSM", "osmose"];
76124       var qaLayers = layers.all().filter(function(obj) {
76125         return qaKeys.indexOf(obj.id) !== -1;
76126       });
76127       var ul = selection2.selectAll(".layer-list-qa").data([0]);
76128       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-qa").merge(ul);
76129       var li = ul.selectAll(".list-item").data(qaLayers);
76130       li.exit().remove();
76131       var liEnter = li.enter().append("li").attr("class", function(d2) {
76132         return "list-item list-item-" + d2.id;
76133       });
76134       var labelEnter = liEnter.append("label").each(function(d2) {
76135         select_default2(this).call(
76136           uiTooltip().title(() => _t.append("map_data.layers." + d2.id + ".tooltip")).placement("bottom")
76137         );
76138       });
76139       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76140         toggleLayer(d2.id);
76141       });
76142       labelEnter.append("span").each(function(d2) {
76143         _t.append("map_data.layers." + d2.id + ".title")(select_default2(this));
76144       });
76145       li.merge(liEnter).classed("active", function(d2) {
76146         return d2.layer.enabled();
76147       }).selectAll("input").property("checked", function(d2) {
76148         return d2.layer.enabled();
76149       });
76150     }
76151     function drawVectorItems(selection2) {
76152       var dataLayer = layers.layer("data");
76153       var vtData = [
76154         {
76155           name: "Detroit Neighborhoods/Parks",
76156           src: "neighborhoods-parks",
76157           tooltip: "Neighborhood boundaries and parks as compiled by City of Detroit in concert with community groups.",
76158           template: "https://{switch:a,b,c,d}.tiles.mapbox.com/v4/jonahadkins.cjksmur6x34562qp9iv1u3ksf-54hev,jonahadkins.cjksmqxdx33jj2wp90xd9x2md-4e5y2/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1Ijoiam9uYWhhZGtpbnMiLCJhIjoiRlVVVkx3VSJ9.9sdVEK_B_VkEXPjssU5MqA"
76159         },
76160         {
76161           name: "Detroit Composite POIs",
76162           src: "composite-poi",
76163           tooltip: "Fire Inspections, Business Licenses, and other public location data collated from the City of Detroit.",
76164           template: "https://{switch:a,b,c,d}.tiles.mapbox.com/v4/jonahadkins.cjksmm6a02sli31myxhsr7zf3-2sw8h/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1Ijoiam9uYWhhZGtpbnMiLCJhIjoiRlVVVkx3VSJ9.9sdVEK_B_VkEXPjssU5MqA"
76165         },
76166         {
76167           name: "Detroit All-The-Places POIs",
76168           src: "alltheplaces-poi",
76169           tooltip: "Public domain business location data created by web scrapers.",
76170           template: "https://{switch:a,b,c,d}.tiles.mapbox.com/v4/jonahadkins.cjksmswgk340g2vo06p1w9w0j-8fjjc/{z}/{x}/{y}.vector.pbf?access_token=pk.eyJ1Ijoiam9uYWhhZGtpbnMiLCJhIjoiRlVVVkx3VSJ9.9sdVEK_B_VkEXPjssU5MqA"
76171         }
76172       ];
76173       var detroit = geoExtent([-83.5, 42.1], [-82.8, 42.5]);
76174       var showVectorItems = context.map().zoom() > 9 && detroit.contains(context.map().center());
76175       var container = selection2.selectAll(".vectortile-container").data(showVectorItems ? [0] : []);
76176       container.exit().remove();
76177       var containerEnter = container.enter().append("div").attr("class", "vectortile-container");
76178       containerEnter.append("h4").attr("class", "vectortile-header").text("Detroit Vector Tiles (Beta)");
76179       containerEnter.append("ul").attr("class", "layer-list layer-list-vectortile");
76180       containerEnter.append("div").attr("class", "vectortile-footer").append("a").attr("target", "_blank").call(svgIcon("#iD-icon-out-link", "inline")).attr("href", "https://github.com/osmus/detroit-mapping-challenge").append("span").text("About these layers");
76181       container = container.merge(containerEnter);
76182       var ul = container.selectAll(".layer-list-vectortile");
76183       var li = ul.selectAll(".list-item").data(vtData);
76184       li.exit().remove();
76185       var liEnter = li.enter().append("li").attr("class", function(d2) {
76186         return "list-item list-item-" + d2.src;
76187       });
76188       var labelEnter = liEnter.append("label").each(function(d2) {
76189         select_default2(this).call(
76190           uiTooltip().title(d2.tooltip).placement("top")
76191         );
76192       });
76193       labelEnter.append("input").attr("type", "radio").attr("name", "vectortile").on("change", selectVTLayer);
76194       labelEnter.append("span").text(function(d2) {
76195         return d2.name;
76196       });
76197       li.merge(liEnter).classed("active", isVTLayerSelected).selectAll("input").property("checked", isVTLayerSelected);
76198       function isVTLayerSelected(d2) {
76199         return dataLayer && dataLayer.template() === d2.template;
76200       }
76201       function selectVTLayer(d3_event, d2) {
76202         corePreferences("settings-custom-data-url", d2.template);
76203         if (dataLayer) {
76204           dataLayer.template(d2.template, d2.src);
76205           dataLayer.enabled(true);
76206         }
76207       }
76208     }
76209     function drawCustomDataItems(selection2) {
76210       var dataLayer = layers.layer("data");
76211       var hasData = dataLayer && dataLayer.hasData();
76212       var showsData = hasData && dataLayer.enabled();
76213       var ul = selection2.selectAll(".layer-list-data").data(dataLayer ? [0] : []);
76214       ul.exit().remove();
76215       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-data");
76216       var liEnter = ulEnter.append("li").attr("class", "list-item-data");
76217       var labelEnter = liEnter.append("label").call(
76218         uiTooltip().title(() => _t.append("map_data.layers.custom.tooltip")).placement("top")
76219       );
76220       labelEnter.append("input").attr("type", "checkbox").on("change", function() {
76221         toggleLayer("data");
76222       });
76223       labelEnter.append("span").call(_t.append("map_data.layers.custom.title"));
76224       liEnter.append("button").attr("class", "open-data-options").call(
76225         uiTooltip().title(() => _t.append("settings.custom_data.tooltip")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76226       ).on("click", function(d3_event) {
76227         d3_event.preventDefault();
76228         editCustom();
76229       }).call(svgIcon("#iD-icon-more"));
76230       liEnter.append("button").attr("class", "zoom-to-data").call(
76231         uiTooltip().title(() => _t.append("map_data.layers.custom.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76232       ).on("click", function(d3_event) {
76233         if (select_default2(this).classed("disabled"))
76234           return;
76235         d3_event.preventDefault();
76236         d3_event.stopPropagation();
76237         dataLayer.fitZoom();
76238       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
76239       ul = ul.merge(ulEnter);
76240       ul.selectAll(".list-item-data").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
76241       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
76242     }
76243     function editCustom() {
76244       context.container().call(settingsCustomData);
76245     }
76246     function customChanged(d2) {
76247       var dataLayer = layers.layer("data");
76248       if (d2 && d2.url) {
76249         dataLayer.url(d2.url);
76250       } else if (d2 && d2.fileList) {
76251         dataLayer.fileList(d2.fileList);
76252       }
76253     }
76254     function drawPanelItems(selection2) {
76255       var panelsListEnter = selection2.selectAll(".md-extras-list").data([0]).enter().append("ul").attr("class", "layer-list md-extras-list");
76256       var historyPanelLabelEnter = panelsListEnter.append("li").attr("class", "history-panel-toggle-item").append("label").call(
76257         uiTooltip().title(() => _t.append("map_data.history_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.history.key"))]).placement("top")
76258       );
76259       historyPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
76260         d3_event.preventDefault();
76261         context.ui().info.toggle("history");
76262       });
76263       historyPanelLabelEnter.append("span").call(_t.append("map_data.history_panel.title"));
76264       var measurementPanelLabelEnter = panelsListEnter.append("li").attr("class", "measurement-panel-toggle-item").append("label").call(
76265         uiTooltip().title(() => _t.append("map_data.measurement_panel.tooltip")).keys([uiCmd("\u2318\u21E7" + _t("info_panels.measurement.key"))]).placement("top")
76266       );
76267       measurementPanelLabelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event) {
76268         d3_event.preventDefault();
76269         context.ui().info.toggle("measurement");
76270       });
76271       measurementPanelLabelEnter.append("span").call(_t.append("map_data.measurement_panel.title"));
76272     }
76273     context.layers().on("change.uiSectionDataLayers", section.reRender);
76274     context.map().on(
76275       "move.uiSectionDataLayers",
76276       debounce_default(function() {
76277         window.requestIdleCallback(section.reRender);
76278       }, 1e3)
76279     );
76280     return section;
76281   }
76282
76283   // modules/ui/sections/map_features.js
76284   function uiSectionMapFeatures(context) {
76285     var _features = context.features().keys();
76286     var section = uiSection("map-features", context).label(() => _t.append("map_data.map_features")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
76287     function renderDisclosureContent(selection2) {
76288       var container = selection2.selectAll(".layer-feature-list-container").data([0]);
76289       var containerEnter = container.enter().append("div").attr("class", "layer-feature-list-container");
76290       containerEnter.append("ul").attr("class", "layer-list layer-feature-list");
76291       var footer = containerEnter.append("div").attr("class", "feature-list-links section-footer");
76292       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.disable_all")).on("click", function(d3_event) {
76293         d3_event.preventDefault();
76294         context.features().disableAll();
76295       });
76296       footer.append("a").attr("class", "feature-list-link").attr("role", "button").attr("href", "#").call(_t.append("issues.enable_all")).on("click", function(d3_event) {
76297         d3_event.preventDefault();
76298         context.features().enableAll();
76299       });
76300       container = container.merge(containerEnter);
76301       container.selectAll(".layer-feature-list").call(drawListItems, _features, "checkbox", "feature", clickFeature, showsFeature);
76302     }
76303     function drawListItems(selection2, data, type2, name, change, active) {
76304       var items = selection2.selectAll("li").data(data);
76305       items.exit().remove();
76306       var enter = items.enter().append("li").call(
76307         uiTooltip().title(function(d2) {
76308           var tip = _t.append(name + "." + d2 + ".tooltip");
76309           if (autoHiddenFeature(d2)) {
76310             var msg = showsLayer("osm") ? _t.append("map_data.autohidden") : _t.append("map_data.osmhidden");
76311             return (selection3) => {
76312               selection3.call(tip);
76313               selection3.append("div").call(msg);
76314             };
76315           }
76316           return tip;
76317         }).placement("top")
76318       );
76319       var label = enter.append("label");
76320       label.append("input").attr("type", type2).attr("name", name).on("change", change);
76321       label.append("span").html(function(d2) {
76322         return _t.html(name + "." + d2 + ".description");
76323       });
76324       items = items.merge(enter);
76325       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", autoHiddenFeature);
76326     }
76327     function autoHiddenFeature(d2) {
76328       return context.features().autoHidden(d2);
76329     }
76330     function showsFeature(d2) {
76331       return context.features().enabled(d2);
76332     }
76333     function clickFeature(d3_event, d2) {
76334       context.features().toggle(d2);
76335     }
76336     function showsLayer(id2) {
76337       var layer = context.layers().layer(id2);
76338       return layer && layer.enabled();
76339     }
76340     context.features().on("change.map_features", section.reRender);
76341     return section;
76342   }
76343
76344   // modules/ui/sections/map_style_options.js
76345   function uiSectionMapStyleOptions(context) {
76346     var section = uiSection("fill-area", context).label(() => _t.append("map_data.style_options")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
76347     function renderDisclosureContent(selection2) {
76348       var container = selection2.selectAll(".layer-fill-list").data([0]);
76349       container.enter().append("ul").attr("class", "layer-list layer-fill-list").merge(container).call(drawListItems, context.map().areaFillOptions, "radio", "area_fill", setFill, isActiveFill);
76350       var container2 = selection2.selectAll(".layer-visual-diff-list").data([0]);
76351       container2.enter().append("ul").attr("class", "layer-list layer-visual-diff-list").merge(container2).call(drawListItems, ["highlight_edits"], "checkbox", "visual_diff", toggleHighlightEdited, function() {
76352         return context.surface().classed("highlight-edited");
76353       });
76354     }
76355     function drawListItems(selection2, data, type2, name, change, active) {
76356       var items = selection2.selectAll("li").data(data);
76357       items.exit().remove();
76358       var enter = items.enter().append("li").call(
76359         uiTooltip().title(function(d2) {
76360           return _t.append(name + "." + d2 + ".tooltip");
76361         }).keys(function(d2) {
76362           var key = d2 === "wireframe" ? _t("area_fill.wireframe.key") : null;
76363           if (d2 === "highlight_edits")
76364             key = _t("map_data.highlight_edits.key");
76365           return key ? [key] : null;
76366         }).placement("top")
76367       );
76368       var label = enter.append("label");
76369       label.append("input").attr("type", type2).attr("name", name).on("change", change);
76370       label.append("span").html(function(d2) {
76371         return _t.html(name + "." + d2 + ".description");
76372       });
76373       items = items.merge(enter);
76374       items.classed("active", active).selectAll("input").property("checked", active).property("indeterminate", false);
76375     }
76376     function isActiveFill(d2) {
76377       return context.map().activeAreaFill() === d2;
76378     }
76379     function toggleHighlightEdited(d3_event) {
76380       d3_event.preventDefault();
76381       context.map().toggleHighlightEdited();
76382     }
76383     function setFill(d3_event, d2) {
76384       context.map().activeAreaFill(d2);
76385     }
76386     context.map().on("changeHighlighting.ui_style, changeAreaFill.ui_style", section.reRender);
76387     return section;
76388   }
76389
76390   // modules/ui/settings/local_photos.js
76391   function uiSettingsLocalPhotos(context) {
76392     var dispatch14 = dispatch_default("change");
76393     var photoLayer = context.layers().layer("local-photos");
76394     var modal;
76395     function render(selection2) {
76396       modal = uiConfirm(selection2).okButton();
76397       modal.classed("settings-modal settings-local-photos", true);
76398       modal.select(".modal-section.header").append("h3").call(_t.append("local_photos.header"));
76399       modal.select(".modal-section.message-text").append("div").classed("local-photos", true);
76400       var instructionsSection = modal.select(".modal-section.message-text .local-photos").append("div").classed("instructions", true);
76401       instructionsSection.append("p").classed("instructions-local-photos", true).call(_t.append("local_photos.file.instructions"));
76402       instructionsSection.append("input").classed("field-file", true).attr("type", "file").attr("multiple", "multiple").attr("accept", ".jpg,.jpeg,.png,image/png,image/jpeg").style("visibility", "hidden").attr("id", "local-photo-files").on("change", function(d3_event) {
76403         var files = d3_event.target.files;
76404         if (files && files.length) {
76405           photoList.select("ul").append("li").classed("placeholder", true).append("div");
76406           dispatch14.call("change", this, files);
76407         }
76408         d3_event.target.value = null;
76409       });
76410       instructionsSection.append("label").attr("for", "local-photo-files").classed("button", true).call(_t.append("local_photos.file.label"));
76411       const photoList = modal.select(".modal-section.message-text .local-photos").append("div").append("div").classed("list-local-photos", true);
76412       photoList.append("ul");
76413       updatePhotoList(photoList.select("ul"));
76414       context.layers().on("change", () => updatePhotoList(photoList.select("ul")));
76415     }
76416     function updatePhotoList(container) {
76417       var _a2;
76418       function locationUnavailable(d2) {
76419         return !(isArray_default(d2.loc) && isNumber_default(d2.loc[0]) && isNumber_default(d2.loc[1]));
76420       }
76421       container.selectAll("li.placeholder").remove();
76422       let selection2 = container.selectAll("li").data((_a2 = photoLayer.getPhotos()) != null ? _a2 : [], (d2) => d2.id);
76423       selection2.exit().remove();
76424       const selectionEnter = selection2.enter().append("li");
76425       selectionEnter.append("span").classed("filename", true);
76426       selectionEnter.append("button").classed("form-field-button zoom-to-data", true).attr("title", _t("local_photos.zoom_single")).call(svgIcon("#iD-icon-framed-dot"));
76427       selectionEnter.append("button").classed("form-field-button no-geolocation", true).call(svgIcon("#iD-icon-alert")).call(
76428         uiTooltip().title(() => _t.append("local_photos.no_geolocation.tooltip")).placement("left")
76429       );
76430       selectionEnter.append("button").classed("form-field-button remove", true).attr("title", _t("icons.remove")).call(svgIcon("#iD-operation-delete"));
76431       selection2 = selection2.merge(selectionEnter);
76432       selection2.classed("invalid", locationUnavailable);
76433       selection2.select("span.filename").text((d2) => d2.name).attr("title", (d2) => d2.name);
76434       selection2.select("span.filename").on("click", (d3_event, d2) => {
76435         photoLayer.openPhoto(d3_event, d2, false);
76436       });
76437       selection2.select("button.zoom-to-data").on("click", (d3_event, d2) => {
76438         photoLayer.openPhoto(d3_event, d2, true);
76439       });
76440       selection2.select("button.remove").on("click", (d3_event, d2) => {
76441         photoLayer.removePhoto(d2.id);
76442         updatePhotoList(container);
76443       });
76444     }
76445     return utilRebind(render, dispatch14, "on");
76446   }
76447
76448   // modules/ui/sections/photo_overlays.js
76449   function uiSectionPhotoOverlays(context) {
76450     var settingsLocalPhotos = uiSettingsLocalPhotos(context).on("change", localPhotosChanged);
76451     var layers = context.layers();
76452     var section = uiSection("photo-overlays", context).label(() => _t.append("photo_overlays.title")).disclosureContent(renderDisclosureContent).expandedByDefault(false);
76453     function renderDisclosureContent(selection2) {
76454       var container = selection2.selectAll(".photo-overlay-container").data([0]);
76455       container.enter().append("div").attr("class", "photo-overlay-container").merge(container).call(drawPhotoItems).call(drawPhotoTypeItems).call(drawDateFilter).call(drawUsernameFilter).call(drawLocalPhotos);
76456     }
76457     function drawPhotoItems(selection2) {
76458       var photoKeys = context.photos().overlayLayerIDs();
76459       var photoLayers = layers.all().filter(function(obj) {
76460         return photoKeys.indexOf(obj.id) !== -1;
76461       });
76462       var data = photoLayers.filter(function(obj) {
76463         if (!obj.layer.supported())
76464           return false;
76465         if (layerEnabled(obj))
76466           return true;
76467         if (typeof obj.layer.validHere === "function") {
76468           return obj.layer.validHere(context.map().extent(), context.map().zoom());
76469         }
76470         return true;
76471       });
76472       function layerSupported(d2) {
76473         return d2.layer && d2.layer.supported();
76474       }
76475       function layerEnabled(d2) {
76476         return layerSupported(d2) && d2.layer.enabled();
76477       }
76478       function layerRendered(d2) {
76479         var _a2, _b, _c;
76480         return (_c = (_b = (_a2 = d2.layer).rendered) == null ? void 0 : _b.call(_a2, context.map().zoom())) != null ? _c : true;
76481       }
76482       var ul = selection2.selectAll(".layer-list-photos").data([0]);
76483       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photos").merge(ul);
76484       var li = ul.selectAll(".list-item-photos").data(data);
76485       li.exit().remove();
76486       var liEnter = li.enter().append("li").attr("class", function(d2) {
76487         var classes = "list-item-photos list-item-" + d2.id;
76488         if (d2.id === "mapillary-signs" || d2.id === "mapillary-map-features") {
76489           classes += " indented";
76490         }
76491         return classes;
76492       });
76493       var labelEnter = liEnter.append("label").each(function(d2) {
76494         var titleID;
76495         if (d2.id === "mapillary-signs")
76496           titleID = "mapillary.signs.tooltip";
76497         else if (d2.id === "mapillary")
76498           titleID = "mapillary_images.tooltip";
76499         else if (d2.id === "kartaview")
76500           titleID = "kartaview_images.tooltip";
76501         else
76502           titleID = d2.id.replace(/-/g, "_") + ".tooltip";
76503         select_default2(this).call(
76504           uiTooltip().title(() => {
76505             if (!layerRendered(d2)) {
76506               return _t.append("street_side.minzoom_tooltip");
76507             } else {
76508               return _t.append(titleID);
76509             }
76510           }).placement("top")
76511         );
76512       });
76513       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76514         toggleLayer(d2.id);
76515       });
76516       labelEnter.append("span").html(function(d2) {
76517         var id2 = d2.id;
76518         if (id2 === "mapillary-signs")
76519           id2 = "photo_overlays.traffic_signs";
76520         return _t.html(id2.replace(/-/g, "_") + ".title");
76521       });
76522       li.merge(liEnter).classed("active", layerEnabled).selectAll("input").property("disabled", (d2) => !layerRendered(d2)).property("checked", layerEnabled);
76523     }
76524     function drawPhotoTypeItems(selection2) {
76525       var data = context.photos().allPhotoTypes();
76526       function typeEnabled(d2) {
76527         return context.photos().showsPhotoType(d2);
76528       }
76529       var ul = selection2.selectAll(".layer-list-photo-types").data([0]);
76530       ul.exit().remove();
76531       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-photo-types").merge(ul);
76532       var li = ul.selectAll(".list-item-photo-types").data(context.photos().shouldFilterByPhotoType() ? data : []);
76533       li.exit().remove();
76534       var liEnter = li.enter().append("li").attr("class", function(d2) {
76535         return "list-item-photo-types list-item-" + d2;
76536       });
76537       var labelEnter = liEnter.append("label").each(function(d2) {
76538         select_default2(this).call(
76539           uiTooltip().title(() => _t.append("photo_overlays.photo_type." + d2 + ".tooltip")).placement("top")
76540         );
76541       });
76542       labelEnter.append("input").attr("type", "checkbox").on("change", function(d3_event, d2) {
76543         context.photos().togglePhotoType(d2);
76544       });
76545       labelEnter.append("span").html(function(d2) {
76546         return _t.html("photo_overlays.photo_type." + d2 + ".title");
76547       });
76548       li.merge(liEnter).classed("active", typeEnabled).selectAll("input").property("checked", typeEnabled);
76549     }
76550     function drawDateFilter(selection2) {
76551       var data = context.photos().dateFilters();
76552       function filterEnabled(d2) {
76553         return context.photos().dateFilterValue(d2);
76554       }
76555       var ul = selection2.selectAll(".layer-list-date-filter").data([0]);
76556       ul.exit().remove();
76557       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-date-filter").merge(ul);
76558       var li = ul.selectAll(".list-item-date-filter").data(context.photos().shouldFilterByDate() ? data : []);
76559       li.exit().remove();
76560       var liEnter = li.enter().append("li").attr("class", "list-item-date-filter");
76561       var labelEnter = liEnter.append("label").each(function(d2) {
76562         select_default2(this).call(
76563           uiTooltip().title(() => _t.append("photo_overlays.date_filter." + d2 + ".tooltip")).placement("top")
76564         );
76565       });
76566       labelEnter.append("span").each(function(d2) {
76567         _t.append("photo_overlays.date_filter." + d2 + ".title")(select_default2(this));
76568       });
76569       labelEnter.append("input").attr("type", "date").attr("class", "list-item-input").attr("placeholder", _t("units.year_month_day")).call(utilNoAuto).each(function(d2) {
76570         utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d2) || "");
76571       }).on("change", function(d3_event, d2) {
76572         var value = utilGetSetValue(select_default2(this)).trim();
76573         context.photos().setDateFilter(d2, value, true);
76574         li.selectAll("input").each(function(d4) {
76575           utilGetSetValue(select_default2(this), context.photos().dateFilterValue(d4) || "");
76576         });
76577       });
76578       li = li.merge(liEnter).classed("active", filterEnabled);
76579     }
76580     function drawUsernameFilter(selection2) {
76581       function filterEnabled() {
76582         return context.photos().usernames();
76583       }
76584       var ul = selection2.selectAll(".layer-list-username-filter").data([0]);
76585       ul.exit().remove();
76586       ul = ul.enter().append("ul").attr("class", "layer-list layer-list-username-filter").merge(ul);
76587       var li = ul.selectAll(".list-item-username-filter").data(context.photos().shouldFilterByUsername() ? ["username-filter"] : []);
76588       li.exit().remove();
76589       var liEnter = li.enter().append("li").attr("class", "list-item-username-filter");
76590       var labelEnter = liEnter.append("label").each(function() {
76591         select_default2(this).call(
76592           uiTooltip().title(() => _t.append("photo_overlays.username_filter.tooltip")).placement("top")
76593         );
76594       });
76595       labelEnter.append("span").call(_t.append("photo_overlays.username_filter.title"));
76596       labelEnter.append("input").attr("type", "text").attr("class", "list-item-input").call(utilNoAuto).property("value", usernameValue).on("change", function() {
76597         var value = select_default2(this).property("value");
76598         context.photos().setUsernameFilter(value, true);
76599         select_default2(this).property("value", usernameValue);
76600       });
76601       li.merge(liEnter).classed("active", filterEnabled);
76602       function usernameValue() {
76603         var usernames = context.photos().usernames();
76604         if (usernames)
76605           return usernames.join("; ");
76606         return usernames;
76607       }
76608     }
76609     function toggleLayer(which) {
76610       setLayer(which, !showsLayer(which));
76611     }
76612     function showsLayer(which) {
76613       var layer = layers.layer(which);
76614       if (layer) {
76615         return layer.enabled();
76616       }
76617       return false;
76618     }
76619     function setLayer(which, enabled) {
76620       var layer = layers.layer(which);
76621       if (layer) {
76622         layer.enabled(enabled);
76623       }
76624     }
76625     function drawLocalPhotos(selection2) {
76626       var photoLayer = layers.layer("local-photos");
76627       var hasData = photoLayer && photoLayer.hasData();
76628       var showsData = hasData && photoLayer.enabled();
76629       var ul = selection2.selectAll(".layer-list-local-photos").data(photoLayer ? [0] : []);
76630       ul.exit().remove();
76631       var ulEnter = ul.enter().append("ul").attr("class", "layer-list layer-list-local-photos");
76632       var localPhotosEnter = ulEnter.append("li").attr("class", "list-item-local-photos");
76633       var localPhotosLabelEnter = localPhotosEnter.append("label").call(uiTooltip().title(() => _t.append("local_photos.tooltip")));
76634       localPhotosLabelEnter.append("input").attr("type", "checkbox").on("change", function() {
76635         toggleLayer("local-photos");
76636       });
76637       localPhotosLabelEnter.call(_t.append("local_photos.header"));
76638       localPhotosEnter.append("button").attr("class", "open-data-options").call(
76639         uiTooltip().title(() => _t.append("local_photos.tooltip_edit")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76640       ).on("click", function(d3_event) {
76641         d3_event.preventDefault();
76642         editLocalPhotos();
76643       }).call(svgIcon("#iD-icon-more"));
76644       localPhotosEnter.append("button").attr("class", "zoom-to-data").call(
76645         uiTooltip().title(() => _t.append("local_photos.zoom")).placement(_mainLocalizer.textDirection() === "rtl" ? "right" : "left")
76646       ).on("click", function(d3_event) {
76647         if (select_default2(this).classed("disabled"))
76648           return;
76649         d3_event.preventDefault();
76650         d3_event.stopPropagation();
76651         photoLayer.fitZoom();
76652       }).call(svgIcon("#iD-icon-framed-dot", "monochrome"));
76653       ul = ul.merge(ulEnter);
76654       ul.selectAll(".list-item-local-photos").classed("active", showsData).selectAll("label").classed("deemphasize", !hasData).selectAll("input").property("disabled", !hasData).property("checked", showsData);
76655       ul.selectAll("button.zoom-to-data").classed("disabled", !hasData);
76656     }
76657     function editLocalPhotos() {
76658       context.container().call(settingsLocalPhotos);
76659     }
76660     function localPhotosChanged(d2) {
76661       var localPhotosLayer = layers.layer("local-photos");
76662       localPhotosLayer.fileList(d2);
76663     }
76664     context.layers().on("change.uiSectionPhotoOverlays", section.reRender);
76665     context.photos().on("change.uiSectionPhotoOverlays", section.reRender);
76666     context.map().on(
76667       "move.photo_overlays",
76668       debounce_default(function() {
76669         window.requestIdleCallback(section.reRender);
76670       }, 1e3)
76671     );
76672     return section;
76673   }
76674
76675   // modules/ui/panes/map_data.js
76676   function uiPaneMapData(context) {
76677     var mapDataPane = uiPane("map-data", context).key(_t("map_data.key")).label(_t.append("map_data.title")).description(_t.append("map_data.description")).iconName("iD-icon-data").sections([
76678       uiSectionDataLayers(context),
76679       uiSectionPhotoOverlays(context),
76680       uiSectionMapStyleOptions(context),
76681       uiSectionMapFeatures(context)
76682     ]);
76683     return mapDataPane;
76684   }
76685
76686   // modules/ui/panes/preferences.js
76687   function uiPanePreferences(context) {
76688     let preferencesPane = uiPane("preferences", context).key(_t("preferences.key")).label(_t.append("preferences.title")).description(_t.append("preferences.description")).iconName("fas-user-cog").sections([
76689       uiSectionPrivacy(context)
76690     ]);
76691     return preferencesPane;
76692   }
76693
76694   // modules/ui/init.js
76695   function uiInit(context) {
76696     var _initCounter = 0;
76697     var _needWidth = {};
76698     var _lastPointerType;
76699     function render(container) {
76700       container.on("click.ui", function(d3_event) {
76701         if (d3_event.button !== 0)
76702           return;
76703         if (!d3_event.composedPath)
76704           return;
76705         var isOkayTarget = d3_event.composedPath().some(function(node) {
76706           return node.nodeType === 1 && // clicking <input> focuses it and/or changes a value
76707           (node.nodeName === "INPUT" || // clicking <label> affects its <input> by default
76708           node.nodeName === "LABEL" || // clicking <a> opens a hyperlink by default
76709           node.nodeName === "A");
76710         });
76711         if (isOkayTarget)
76712           return;
76713         d3_event.preventDefault();
76714       });
76715       var detected = utilDetect();
76716       if ("GestureEvent" in window && // Listening for gesture events on iOS 13.4+ breaks double-tapping,
76717       // but we only need to do this on desktop Safari anyway. – #7694
76718       !detected.isMobileWebKit) {
76719         container.on("gesturestart.ui gesturechange.ui gestureend.ui", function(d3_event) {
76720           d3_event.preventDefault();
76721         });
76722       }
76723       if ("PointerEvent" in window) {
76724         select_default2(window).on("pointerdown.ui pointerup.ui", function(d3_event) {
76725           var pointerType = d3_event.pointerType || "mouse";
76726           if (_lastPointerType !== pointerType) {
76727             _lastPointerType = pointerType;
76728             container.attr("pointer", pointerType);
76729           }
76730         }, true);
76731       } else {
76732         _lastPointerType = "mouse";
76733         container.attr("pointer", "mouse");
76734       }
76735       container.attr("lang", _mainLocalizer.localeCode()).attr("dir", _mainLocalizer.textDirection());
76736       container.call(uiFullScreen(context));
76737       var map2 = context.map();
76738       map2.redrawEnable(false);
76739       map2.on("hitMinZoom.ui", function() {
76740         ui.flash.iconName("#iD-icon-no").label(_t.append("cannot_zoom"))();
76741       });
76742       container.append("svg").attr("id", "ideditor-defs").call(ui.svgDefs);
76743       container.append("div").attr("class", "sidebar").call(ui.sidebar);
76744       var content = container.append("div").attr("class", "main-content active");
76745       content.append("div").attr("class", "top-toolbar-wrap").append("div").attr("class", "top-toolbar fillD").call(uiTopToolbar(context));
76746       content.append("div").attr("class", "main-map").attr("dir", "ltr").call(map2);
76747       var overMap = content.append("div").attr("class", "over-map");
76748       overMap.append("div").attr("class", "select-trap").text("t");
76749       overMap.call(uiMapInMap(context)).call(uiNotice(context));
76750       overMap.append("div").attr("class", "spinner").call(uiSpinner(context));
76751       var controlsWrap = overMap.append("div").attr("class", "map-controls-wrap");
76752       var controls = controlsWrap.append("div").attr("class", "map-controls");
76753       controls.append("div").attr("class", "map-control zoombuttons").call(uiZoom(context));
76754       controls.append("div").attr("class", "map-control zoom-to-selection-control").call(uiZoomToSelection(context));
76755       controls.append("div").attr("class", "map-control geolocate-control").call(uiGeolocate(context));
76756       controlsWrap.on("wheel.mapControls", function(d3_event) {
76757         if (!d3_event.deltaX) {
76758           controlsWrap.node().scrollTop += d3_event.deltaY;
76759         }
76760       });
76761       var panes = overMap.append("div").attr("class", "map-panes");
76762       var uiPanes = [
76763         uiPaneBackground(context),
76764         uiPaneMapData(context),
76765         uiPaneIssues(context),
76766         uiPanePreferences(context),
76767         uiPaneHelp(context)
76768       ];
76769       uiPanes.forEach(function(pane) {
76770         controls.append("div").attr("class", "map-control map-pane-control " + pane.id + "-control").call(pane.renderToggleButton);
76771         panes.call(pane.renderPane);
76772       });
76773       ui.info = uiInfo(context);
76774       overMap.call(ui.info);
76775       overMap.append("div").attr("class", "photoviewer").classed("al", true).classed("hide", true).call(ui.photoviewer);
76776       overMap.append("div").attr("class", "attribution-wrap").attr("dir", "ltr").call(uiAttribution(context));
76777       var about = content.append("div").attr("class", "map-footer");
76778       about.append("div").attr("class", "api-status").call(uiStatus(context));
76779       var footer = about.append("div").attr("class", "map-footer-bar fillD");
76780       footer.append("div").attr("class", "flash-wrap footer-hide");
76781       var footerWrap = footer.append("div").attr("class", "main-footer-wrap footer-show");
76782       footerWrap.append("div").attr("class", "scale-block").call(uiScale(context));
76783       var aboutList = footerWrap.append("div").attr("class", "info-block").append("ul").attr("class", "map-footer-list");
76784       aboutList.append("li").attr("class", "user-list").call(uiContributors(context));
76785       var apiConnections = context.connection().apiConnections();
76786       if (apiConnections && apiConnections.length > 1) {
76787         aboutList.append("li").attr("class", "source-switch").call(
76788           uiSourceSwitch(context).keys(apiConnections)
76789         );
76790       }
76791       aboutList.append("li").attr("class", "issues-info").call(uiIssuesInfo(context));
76792       aboutList.append("li").attr("class", "feature-warning").call(uiFeatureInfo(context));
76793       var issueLinks = aboutList.append("li");
76794       issueLinks.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD/issues").attr("aria-label", _t("report_a_bug")).call(svgIcon("#iD-icon-bug", "light")).call(uiTooltip().title(() => _t.append("report_a_bug")).placement("top"));
76795       issueLinks.append("a").attr("target", "_blank").attr("href", "https://github.com/openstreetmap/iD/blob/develop/CONTRIBUTING.md#translating").attr("aria-label", _t("help_translate")).call(svgIcon("#iD-icon-translate", "light")).call(uiTooltip().title(() => _t.append("help_translate")).placement("top"));
76796       aboutList.append("li").attr("class", "version").call(uiVersion(context));
76797       if (!context.embed()) {
76798         aboutList.call(uiAccount(context));
76799       }
76800       ui.onResize();
76801       map2.redrawEnable(true);
76802       ui.hash = behaviorHash(context);
76803       ui.hash();
76804       if (!ui.hash.hadLocation) {
76805         map2.centerZoom([0, 0], 2);
76806       }
76807       window.onbeforeunload = function() {
76808         return context.save();
76809       };
76810       window.onunload = function() {
76811         context.history().unlock();
76812       };
76813       select_default2(window).on("resize.editor", function() {
76814         ui.onResize();
76815       });
76816       var panPixels = 80;
76817       context.keybinding().on("\u232B", function(d3_event) {
76818         d3_event.preventDefault();
76819       }).on([_t("sidebar.key"), "`", "\xB2", "@"], ui.sidebar.toggle).on("\u2190", pan([panPixels, 0])).on("\u2191", pan([0, panPixels])).on("\u2192", pan([-panPixels, 0])).on("\u2193", pan([0, -panPixels])).on(uiCmd("\u2325\u2190"), pan([map2.dimensions()[0], 0])).on(uiCmd("\u2325\u2191"), pan([0, map2.dimensions()[1]])).on(uiCmd("\u2325\u2192"), pan([-map2.dimensions()[0], 0])).on(uiCmd("\u2325\u2193"), pan([0, -map2.dimensions()[1]])).on(uiCmd("\u2318" + _t("background.key")), function quickSwitch(d3_event) {
76820         if (d3_event) {
76821           d3_event.stopImmediatePropagation();
76822           d3_event.preventDefault();
76823         }
76824         var previousBackground = context.background().findSource(corePreferences("background-last-used-toggle"));
76825         if (previousBackground) {
76826           var currentBackground = context.background().baseLayerSource();
76827           corePreferences("background-last-used-toggle", currentBackground.id);
76828           corePreferences("background-last-used", previousBackground.id);
76829           context.background().baseLayerSource(previousBackground);
76830         }
76831       }).on(_t("area_fill.wireframe.key"), function toggleWireframe(d3_event) {
76832         d3_event.preventDefault();
76833         d3_event.stopPropagation();
76834         context.map().toggleWireframe();
76835       }).on(uiCmd("\u2325" + _t("area_fill.wireframe.key")), function toggleOsmData(d3_event) {
76836         d3_event.preventDefault();
76837         d3_event.stopPropagation();
76838         var mode = context.mode();
76839         if (mode && /^draw/.test(mode.id))
76840           return;
76841         var layer = context.layers().layer("osm");
76842         if (layer) {
76843           layer.enabled(!layer.enabled());
76844           if (!layer.enabled()) {
76845             context.enter(modeBrowse(context));
76846           }
76847         }
76848       }).on(_t("map_data.highlight_edits.key"), function toggleHighlightEdited(d3_event) {
76849         d3_event.preventDefault();
76850         context.map().toggleHighlightEdited();
76851       });
76852       context.on("enter.editor", function(entered) {
76853         container.classed("mode-" + entered.id, true);
76854       }).on("exit.editor", function(exited) {
76855         container.classed("mode-" + exited.id, false);
76856       });
76857       context.enter(modeBrowse(context));
76858       if (!_initCounter++) {
76859         if (!ui.hash.startWalkthrough) {
76860           context.container().call(uiSplash(context)).call(uiRestore(context));
76861         }
76862         context.container().call(ui.shortcuts);
76863       }
76864       var osm = context.connection();
76865       var auth = uiLoading(context).message(_t.html("loading_auth")).blocking(true);
76866       if (osm && auth) {
76867         osm.on("authLoading.ui", function() {
76868           context.container().call(auth);
76869         }).on("authDone.ui", function() {
76870           auth.close();
76871         });
76872       }
76873       _initCounter++;
76874       if (ui.hash.startWalkthrough) {
76875         ui.hash.startWalkthrough = false;
76876         context.container().call(uiIntro(context));
76877       }
76878       function pan(d2) {
76879         return function(d3_event) {
76880           if (d3_event.shiftKey)
76881             return;
76882           if (context.container().select(".combobox").size())
76883             return;
76884           d3_event.preventDefault();
76885           context.map().pan(d2, 100);
76886         };
76887       }
76888     }
76889     let ui = {};
76890     let _loadPromise;
76891     ui.ensureLoaded = () => {
76892       if (_loadPromise)
76893         return _loadPromise;
76894       return _loadPromise = Promise.all([
76895         // must have strings and presets before loading the UI
76896         _mainLocalizer.ensureLoaded(),
76897         _mainPresetIndex.ensureLoaded()
76898       ]).then(() => {
76899         if (!context.container().empty())
76900           render(context.container());
76901       }).catch((err) => console.error(err));
76902     };
76903     ui.restart = function() {
76904       context.keybinding().clear();
76905       _loadPromise = null;
76906       context.container().selectAll("*").remove();
76907       ui.ensureLoaded();
76908     };
76909     ui.lastPointerType = function() {
76910       return _lastPointerType;
76911     };
76912     ui.svgDefs = svgDefs(context);
76913     ui.flash = uiFlash(context);
76914     ui.sidebar = uiSidebar(context);
76915     ui.photoviewer = uiPhotoviewer(context);
76916     ui.shortcuts = uiShortcuts(context);
76917     ui.onResize = function(withPan) {
76918       var map2 = context.map();
76919       var mapDimensions = utilGetDimensions(context.container().select(".main-content"), true);
76920       utilGetDimensions(context.container().select(".sidebar"), true);
76921       if (withPan !== void 0) {
76922         map2.redrawEnable(false);
76923         map2.pan(withPan);
76924         map2.redrawEnable(true);
76925       }
76926       map2.dimensions(mapDimensions);
76927       ui.photoviewer.onMapResize();
76928       ui.checkOverflow(".top-toolbar");
76929       ui.checkOverflow(".map-footer-bar");
76930       var resizeWindowEvent = document.createEvent("Event");
76931       resizeWindowEvent.initEvent("resizeWindow", true, true);
76932       document.dispatchEvent(resizeWindowEvent);
76933     };
76934     ui.checkOverflow = function(selector, reset) {
76935       if (reset) {
76936         delete _needWidth[selector];
76937       }
76938       var selection2 = context.container().select(selector);
76939       if (selection2.empty())
76940         return;
76941       var scrollWidth = selection2.property("scrollWidth");
76942       var clientWidth = selection2.property("clientWidth");
76943       var needed = _needWidth[selector] || scrollWidth;
76944       if (scrollWidth > clientWidth) {
76945         selection2.classed("narrow", true);
76946         if (!_needWidth[selector]) {
76947           _needWidth[selector] = scrollWidth;
76948         }
76949       } else if (scrollWidth >= needed) {
76950         selection2.classed("narrow", false);
76951       }
76952     };
76953     ui.togglePanes = function(showPane) {
76954       var hidePanes = context.container().selectAll(".map-pane.shown");
76955       var side = _mainLocalizer.textDirection() === "ltr" ? "right" : "left";
76956       hidePanes.classed("shown", false).classed("hide", true);
76957       context.container().selectAll(".map-pane-control button").classed("active", false);
76958       if (showPane) {
76959         hidePanes.classed("shown", false).classed("hide", true).style(side, "-500px");
76960         context.container().selectAll("." + showPane.attr("pane") + "-control button").classed("active", true);
76961         showPane.classed("shown", true).classed("hide", false);
76962         if (hidePanes.empty()) {
76963           showPane.style(side, "-500px").transition().duration(200).style(side, "0px");
76964         } else {
76965           showPane.style(side, "0px");
76966         }
76967       } else {
76968         hidePanes.classed("shown", true).classed("hide", false).style(side, "0px").transition().duration(200).style(side, "-500px").on("end", function() {
76969           select_default2(this).classed("shown", false).classed("hide", true);
76970         });
76971       }
76972     };
76973     var _editMenu = uiEditMenu(context);
76974     ui.editMenu = function() {
76975       return _editMenu;
76976     };
76977     ui.showEditMenu = function(anchorPoint, triggerType, operations) {
76978       ui.closeEditMenu();
76979       if (!operations && context.mode().operations)
76980         operations = context.mode().operations();
76981       if (!operations || !operations.length)
76982         return;
76983       if (!context.map().editableDataEnabled())
76984         return;
76985       var surfaceNode = context.surface().node();
76986       if (surfaceNode.focus) {
76987         surfaceNode.focus();
76988       }
76989       operations.forEach(function(operation2) {
76990         if (operation2.point)
76991           operation2.point(anchorPoint);
76992       });
76993       _editMenu.anchorLoc(anchorPoint).triggerType(triggerType).operations(operations);
76994       context.map().supersurface.call(_editMenu);
76995     };
76996     ui.closeEditMenu = function() {
76997       context.map().supersurface.select(".edit-menu").remove();
76998     };
76999     var _saveLoading = select_default2(null);
77000     context.uploader().on("saveStarted.ui", function() {
77001       _saveLoading = uiLoading(context).message(_t.html("save.uploading")).blocking(true);
77002       context.container().call(_saveLoading);
77003     }).on("saveEnded.ui", function() {
77004       _saveLoading.close();
77005       _saveLoading = select_default2(null);
77006     });
77007     marked.use({
77008       mangle: false,
77009       headerIds: false
77010     });
77011     return ui;
77012   }
77013
77014   // modules/core/context.js
77015   function coreContext() {
77016     const dispatch14 = dispatch_default("enter", "exit", "change");
77017     let context = utilRebind({}, dispatch14, "on");
77018     let _deferred2 = /* @__PURE__ */ new Set();
77019     context.version = package_default.version;
77020     context.privacyVersion = "20201202";
77021     context.initialHashParams = window.location.hash ? utilStringQs(window.location.hash) : {};
77022     context.changeset = null;
77023     let _defaultChangesetComment = context.initialHashParams.comment;
77024     let _defaultChangesetSource = context.initialHashParams.source;
77025     let _defaultChangesetHashtags = context.initialHashParams.hashtags;
77026     context.defaultChangesetComment = function(val) {
77027       if (!arguments.length)
77028         return _defaultChangesetComment;
77029       _defaultChangesetComment = val;
77030       return context;
77031     };
77032     context.defaultChangesetSource = function(val) {
77033       if (!arguments.length)
77034         return _defaultChangesetSource;
77035       _defaultChangesetSource = val;
77036       return context;
77037     };
77038     context.defaultChangesetHashtags = function(val) {
77039       if (!arguments.length)
77040         return _defaultChangesetHashtags;
77041       _defaultChangesetHashtags = val;
77042       return context;
77043     };
77044     let _setsDocumentTitle = true;
77045     context.setsDocumentTitle = function(val) {
77046       if (!arguments.length)
77047         return _setsDocumentTitle;
77048       _setsDocumentTitle = val;
77049       return context;
77050     };
77051     let _documentTitleBase = document.title;
77052     context.documentTitleBase = function(val) {
77053       if (!arguments.length)
77054         return _documentTitleBase;
77055       _documentTitleBase = val;
77056       return context;
77057     };
77058     let _ui;
77059     context.ui = () => _ui;
77060     context.lastPointerType = () => _ui.lastPointerType();
77061     let _keybinding = utilKeybinding("context");
77062     context.keybinding = () => _keybinding;
77063     select_default2(document).call(_keybinding);
77064     let _connection = services.osm;
77065     let _history;
77066     let _validator;
77067     let _uploader;
77068     context.connection = () => _connection;
77069     context.history = () => _history;
77070     context.validator = () => _validator;
77071     context.uploader = () => _uploader;
77072     context.preauth = (options2) => {
77073       if (_connection) {
77074         _connection.switch(options2);
77075       }
77076       return context;
77077     };
77078     context.locale = function(locale2) {
77079       if (!arguments.length)
77080         return _mainLocalizer.localeCode();
77081       _mainLocalizer.preferredLocaleCodes(locale2);
77082       return context;
77083     };
77084     function afterLoad(cid, callback) {
77085       return (err, result) => {
77086         if (err) {
77087           if (err.status === 400 || err.status === 401 || err.status === 403) {
77088             if (_connection) {
77089               _connection.logout();
77090             }
77091           }
77092           if (typeof callback === "function") {
77093             callback(err);
77094           }
77095           return;
77096         } else if (_connection && _connection.getConnectionId() !== cid) {
77097           if (typeof callback === "function") {
77098             callback({ message: "Connection Switched", status: -1 });
77099           }
77100           return;
77101         } else {
77102           _history.merge(result.data, result.extent);
77103           if (typeof callback === "function") {
77104             callback(err, result);
77105           }
77106           return;
77107         }
77108       };
77109     }
77110     context.loadTiles = (projection2, callback) => {
77111       const handle = window.requestIdleCallback(() => {
77112         _deferred2.delete(handle);
77113         if (_connection && context.editableDataEnabled()) {
77114           const cid = _connection.getConnectionId();
77115           _connection.loadTiles(projection2, afterLoad(cid, callback));
77116         }
77117       });
77118       _deferred2.add(handle);
77119     };
77120     context.loadTileAtLoc = (loc, callback) => {
77121       const handle = window.requestIdleCallback(() => {
77122         _deferred2.delete(handle);
77123         if (_connection && context.editableDataEnabled()) {
77124           const cid = _connection.getConnectionId();
77125           _connection.loadTileAtLoc(loc, afterLoad(cid, callback));
77126         }
77127       });
77128       _deferred2.add(handle);
77129     };
77130     context.loadEntity = (entityID, callback) => {
77131       if (_connection) {
77132         const cid = _connection.getConnectionId();
77133         _connection.loadEntity(entityID, afterLoad(cid, callback));
77134         _connection.loadEntityRelations(entityID, afterLoad(cid, callback));
77135       }
77136     };
77137     context.loadNote = (entityID, callback) => {
77138       if (_connection) {
77139         const cid = _connection.getConnectionId();
77140         _connection.loadEntityNote(entityID, afterLoad(cid, callback));
77141       }
77142     };
77143     context.zoomToEntity = (entityID, zoomTo) => {
77144       context.loadEntity(entityID, (err, result) => {
77145         if (err)
77146           return;
77147         if (zoomTo !== false) {
77148           const entity = result.data.find((e3) => e3.id === entityID);
77149           if (entity) {
77150             _map.zoomTo(entity);
77151           }
77152         }
77153       });
77154       _map.on("drawn.zoomToEntity", () => {
77155         if (!context.hasEntity(entityID))
77156           return;
77157         _map.on("drawn.zoomToEntity", null);
77158         context.on("enter.zoomToEntity", null);
77159         context.enter(modeSelect(context, [entityID]));
77160       });
77161       context.on("enter.zoomToEntity", () => {
77162         if (_mode.id !== "browse") {
77163           _map.on("drawn.zoomToEntity", null);
77164           context.on("enter.zoomToEntity", null);
77165         }
77166       });
77167     };
77168     let _minEditableZoom = 16;
77169     context.minEditableZoom = function(val) {
77170       if (!arguments.length)
77171         return _minEditableZoom;
77172       _minEditableZoom = val;
77173       if (_connection) {
77174         _connection.tileZoom(val);
77175       }
77176       return context;
77177     };
77178     context.maxCharsForTagKey = () => 255;
77179     context.maxCharsForTagValue = () => 255;
77180     context.maxCharsForRelationRole = () => 255;
77181     context.cleanTagKey = (val) => utilCleanOsmString(val, context.maxCharsForTagKey());
77182     context.cleanTagValue = (val) => utilCleanOsmString(val, context.maxCharsForTagValue());
77183     context.cleanRelationRole = (val) => utilCleanOsmString(val, context.maxCharsForRelationRole());
77184     let _inIntro = false;
77185     context.inIntro = function(val) {
77186       if (!arguments.length)
77187         return _inIntro;
77188       _inIntro = val;
77189       return context;
77190     };
77191     context.save = () => {
77192       if (_inIntro || context.container().select(".modal").size())
77193         return;
77194       let canSave;
77195       if (_mode && _mode.id === "save") {
77196         canSave = false;
77197         if (services.osm && services.osm.isChangesetInflight()) {
77198           _history.clearSaved();
77199           return;
77200         }
77201       } else {
77202         canSave = context.selectedIDs().every((id2) => {
77203           const entity = context.hasEntity(id2);
77204           return entity && !entity.isDegenerate();
77205         });
77206       }
77207       if (canSave) {
77208         _history.save();
77209       }
77210       if (_history.hasChanges()) {
77211         return _t("save.unsaved_changes");
77212       }
77213     };
77214     context.debouncedSave = debounce_default(context.save, 350);
77215     function withDebouncedSave(fn) {
77216       return function() {
77217         const result = fn.apply(_history, arguments);
77218         context.debouncedSave();
77219         return result;
77220       };
77221     }
77222     context.hasEntity = (id2) => _history.graph().hasEntity(id2);
77223     context.entity = (id2) => _history.graph().entity(id2);
77224     let _mode;
77225     context.mode = () => _mode;
77226     context.enter = (newMode) => {
77227       if (_mode) {
77228         _mode.exit();
77229         dispatch14.call("exit", this, _mode);
77230       }
77231       _mode = newMode;
77232       _mode.enter();
77233       dispatch14.call("enter", this, _mode);
77234     };
77235     context.selectedIDs = () => _mode && _mode.selectedIDs && _mode.selectedIDs() || [];
77236     context.activeID = () => _mode && _mode.activeID && _mode.activeID();
77237     let _selectedNoteID;
77238     context.selectedNoteID = function(noteID) {
77239       if (!arguments.length)
77240         return _selectedNoteID;
77241       _selectedNoteID = noteID;
77242       return context;
77243     };
77244     let _selectedErrorID;
77245     context.selectedErrorID = function(errorID) {
77246       if (!arguments.length)
77247         return _selectedErrorID;
77248       _selectedErrorID = errorID;
77249       return context;
77250     };
77251     context.install = (behavior) => context.surface().call(behavior);
77252     context.uninstall = (behavior) => context.surface().call(behavior.off);
77253     let _copyGraph;
77254     context.copyGraph = () => _copyGraph;
77255     let _copyIDs = [];
77256     context.copyIDs = function(val) {
77257       if (!arguments.length)
77258         return _copyIDs;
77259       _copyIDs = val;
77260       _copyGraph = _history.graph();
77261       return context;
77262     };
77263     let _copyLonLat;
77264     context.copyLonLat = function(val) {
77265       if (!arguments.length)
77266         return _copyLonLat;
77267       _copyLonLat = val;
77268       return context;
77269     };
77270     let _background;
77271     context.background = () => _background;
77272     let _features;
77273     context.features = () => _features;
77274     context.hasHiddenConnections = (id2) => {
77275       const graph = _history.graph();
77276       const entity = graph.entity(id2);
77277       return _features.hasHiddenConnections(entity, graph);
77278     };
77279     let _photos;
77280     context.photos = () => _photos;
77281     let _map;
77282     context.map = () => _map;
77283     context.layers = () => _map.layers();
77284     context.surface = () => _map.surface;
77285     context.editableDataEnabled = () => _map.editableDataEnabled();
77286     context.surfaceRect = () => _map.surface.node().getBoundingClientRect();
77287     context.editable = () => {
77288       const mode = context.mode();
77289       if (!mode || mode.id === "save")
77290         return false;
77291       return _map.editableDataEnabled();
77292     };
77293     let _debugFlags = {
77294       tile: false,
77295       // tile boundaries
77296       collision: false,
77297       // label collision bounding boxes
77298       imagery: false,
77299       // imagery bounding polygons
77300       target: false,
77301       // touch targets
77302       downloaded: false
77303       // downloaded data from osm
77304     };
77305     context.debugFlags = () => _debugFlags;
77306     context.getDebug = (flag) => flag && _debugFlags[flag];
77307     context.setDebug = function(flag, val) {
77308       if (arguments.length === 1)
77309         val = true;
77310       _debugFlags[flag] = val;
77311       dispatch14.call("change");
77312       return context;
77313     };
77314     let _container = select_default2(null);
77315     context.container = function(val) {
77316       if (!arguments.length)
77317         return _container;
77318       _container = val;
77319       _container.classed("ideditor", true);
77320       return context;
77321     };
77322     context.containerNode = function(val) {
77323       if (!arguments.length)
77324         return context.container().node();
77325       context.container(select_default2(val));
77326       return context;
77327     };
77328     let _embed;
77329     context.embed = function(val) {
77330       if (!arguments.length)
77331         return _embed;
77332       _embed = val;
77333       return context;
77334     };
77335     let _assetPath = "";
77336     context.assetPath = function(val) {
77337       if (!arguments.length)
77338         return _assetPath;
77339       _assetPath = val;
77340       _mainFileFetcher.assetPath(val);
77341       return context;
77342     };
77343     let _assetMap = {};
77344     context.assetMap = function(val) {
77345       if (!arguments.length)
77346         return _assetMap;
77347       _assetMap = val;
77348       _mainFileFetcher.assetMap(val);
77349       return context;
77350     };
77351     context.asset = (val) => {
77352       if (/^http(s)?:\/\//i.test(val))
77353         return val;
77354       const filename = _assetPath + val;
77355       return _assetMap[filename] || filename;
77356     };
77357     context.imagePath = (val) => context.asset("img/".concat(val));
77358     context.reset = context.flush = () => {
77359       context.debouncedSave.cancel();
77360       Array.from(_deferred2).forEach((handle) => {
77361         window.cancelIdleCallback(handle);
77362         _deferred2.delete(handle);
77363       });
77364       Object.values(services).forEach((service) => {
77365         if (service && typeof service.reset === "function") {
77366           service.reset(context);
77367         }
77368       });
77369       context.changeset = null;
77370       _validator.reset();
77371       _features.reset();
77372       _history.reset();
77373       _uploader.reset();
77374       context.container().select(".inspector-wrap *").remove();
77375       return context;
77376     };
77377     context.projection = geoRawMercator();
77378     context.curtainProjection = geoRawMercator();
77379     context.init = () => {
77380       instantiateInternal();
77381       initializeDependents();
77382       return context;
77383       function instantiateInternal() {
77384         _history = coreHistory(context);
77385         context.graph = _history.graph;
77386         context.pauseChangeDispatch = _history.pauseChangeDispatch;
77387         context.resumeChangeDispatch = _history.resumeChangeDispatch;
77388         context.perform = withDebouncedSave(_history.perform);
77389         context.replace = withDebouncedSave(_history.replace);
77390         context.pop = withDebouncedSave(_history.pop);
77391         context.overwrite = withDebouncedSave(_history.overwrite);
77392         context.undo = withDebouncedSave(_history.undo);
77393         context.redo = withDebouncedSave(_history.redo);
77394         _validator = coreValidator(context);
77395         _uploader = coreUploader(context);
77396         _background = rendererBackground(context);
77397         _features = rendererFeatures(context);
77398         _map = rendererMap(context);
77399         _photos = rendererPhotos(context);
77400         _ui = uiInit(context);
77401       }
77402       function initializeDependents() {
77403         if (context.initialHashParams.presets) {
77404           _mainPresetIndex.addablePresetIDs(new Set(context.initialHashParams.presets.split(",")));
77405         }
77406         if (context.initialHashParams.locale) {
77407           _mainLocalizer.preferredLocaleCodes(context.initialHashParams.locale);
77408         }
77409         _mainLocalizer.ensureLoaded();
77410         _mainPresetIndex.ensureLoaded();
77411         _background.ensureLoaded();
77412         Object.values(services).forEach((service) => {
77413           if (service && typeof service.init === "function") {
77414             service.init();
77415           }
77416         });
77417         _map.init();
77418         _validator.init();
77419         _features.init();
77420         if (services.maprules && context.initialHashParams.maprules) {
77421           json_default(context.initialHashParams.maprules).then((mapcss) => {
77422             services.maprules.init();
77423             mapcss.forEach((mapcssSelector) => services.maprules.addRule(mapcssSelector));
77424           }).catch(() => {
77425           });
77426         }
77427         if (!context.container().empty()) {
77428           _ui.ensureLoaded().then(() => {
77429             _background.init();
77430             _photos.init();
77431           });
77432         }
77433       }
77434     };
77435     return context;
77436   }
77437
77438   // modules/services/nominatim.js
77439   var apibase = nominatimApiUrl;
77440   var _inflight = {};
77441   var _nominatimCache;
77442   var nominatim_default = {
77443     init: function() {
77444       _inflight = {};
77445       _nominatimCache = new import_rbush7.default();
77446     },
77447     reset: function() {
77448       Object.values(_inflight).forEach(function(controller) {
77449         controller.abort();
77450       });
77451       _inflight = {};
77452       _nominatimCache = new import_rbush7.default();
77453     },
77454     countryCode: function(location, callback) {
77455       this.reverse(location, function(err, result) {
77456         if (err) {
77457           return callback(err);
77458         } else if (result.address) {
77459           return callback(null, result.address.country_code);
77460         } else {
77461           return callback("Unable to geocode", null);
77462         }
77463       });
77464     },
77465     reverse: function(loc, callback) {
77466       var cached = _nominatimCache.search(
77467         { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] }
77468       );
77469       if (cached.length > 0) {
77470         if (callback)
77471           callback(null, cached[0].data);
77472         return;
77473       }
77474       var params = { zoom: 13, format: "json", addressdetails: 1, lat: loc[1], lon: loc[0] };
77475       var url = apibase + "reverse?" + utilQsString(params);
77476       if (_inflight[url])
77477         return;
77478       var controller = new AbortController();
77479       _inflight[url] = controller;
77480       json_default(url, {
77481         signal: controller.signal,
77482         headers: {
77483           "Accept-Language": _mainLocalizer.localeCodes().join(",")
77484         }
77485       }).then(function(result) {
77486         delete _inflight[url];
77487         if (result && result.error) {
77488           throw new Error(result.error);
77489         }
77490         var extent = geoExtent(loc).padByMeters(200);
77491         _nominatimCache.insert(Object.assign(extent.bbox(), { data: result }));
77492         if (callback)
77493           callback(null, result);
77494       }).catch(function(err) {
77495         delete _inflight[url];
77496         if (err.name === "AbortError")
77497           return;
77498         if (callback)
77499           callback(err.message);
77500       });
77501     },
77502     search: function(val, callback) {
77503       const params = {
77504         q: val,
77505         limit: 10,
77506         format: "json"
77507       };
77508       var url = apibase + "search?" + utilQsString(params);
77509       if (_inflight[url])
77510         return;
77511       var controller = new AbortController();
77512       _inflight[url] = controller;
77513       json_default(url, {
77514         signal: controller.signal,
77515         headers: {
77516           "Accept-Language": _mainLocalizer.localeCodes().join(",")
77517         }
77518       }).then(function(result) {
77519         delete _inflight[url];
77520         if (result && result.error) {
77521           throw new Error(result.error);
77522         }
77523         if (callback)
77524           callback(null, result);
77525       }).catch(function(err) {
77526         delete _inflight[url];
77527         if (err.name === "AbortError")
77528           return;
77529         if (callback)
77530           callback(err.message);
77531       });
77532     }
77533   };
77534
77535   // node_modules/name-suggestion-index/lib/matcher.js
77536   var import_which_polygon4 = __toESM(require_which_polygon(), 1);
77537
77538   // node_modules/name-suggestion-index/lib/simplify.js
77539   var import_diacritics3 = __toESM(require_diacritics(), 1);
77540   function simplify2(str) {
77541     if (typeof str !== "string")
77542       return "";
77543     return import_diacritics3.default.remove(
77544       str.replace(/&/g, "and").replace(/İ/ig, "i").replace(/[\s\-=_!"#%'*{},.\/:;?\(\)\[\]@\\$\^*+<>«»~`’\u00a1\u00a7\u00b6\u00b7\u00bf\u037e\u0387\u055a-\u055f\u0589\u05c0\u05c3\u05c6\u05f3\u05f4\u0609\u060a\u060c\u060d\u061b\u061e\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0830-\u083e\u085e\u0964\u0965\u0970\u0af0\u0df4\u0e4f\u0e5a\u0e5b\u0f04-\u0f12\u0f14\u0f85\u0fd0-\u0fd4\u0fd9\u0fda\u104a-\u104f\u10fb\u1360-\u1368\u166d\u166e\u16eb-\u16ed\u1735\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u1805\u1807-\u180a\u1944\u1945\u1a1e\u1a1f\u1aa0-\u1aa6\u1aa8-\u1aad\u1b5a-\u1b60\u1bfc-\u1bff\u1c3b-\u1c3f\u1c7e\u1c7f\u1cc0-\u1cc7\u1cd3\u2000-\u206f\u2cf9-\u2cfc\u2cfe\u2cff\u2d70\u2e00-\u2e7f\u3001-\u3003\u303d\u30fb\ua4fe\ua4ff\ua60d-\ua60f\ua673\ua67e\ua6f2-\ua6f7\ua874-\ua877\ua8ce\ua8cf\ua8f8-\ua8fa\ua92e\ua92f\ua95f\ua9c1-\ua9cd\ua9de\ua9df\uaa5c-\uaa5f\uaade\uaadf\uaaf0\uaaf1\uabeb\ufe10-\ufe16\ufe19\ufe30\ufe45\ufe46\ufe49-\ufe4c\ufe50-\ufe52\ufe54-\ufe57\ufe5f-\ufe61\ufe68\ufe6a\ufe6b\ufeff\uff01-\uff03\uff05-\uff07\uff0a\uff0c\uff0e\uff0f\uff1a\uff1b\uff1f\uff20\uff3c\uff61\uff64\uff65]+/g, "").toLowerCase()
77545     );
77546   }
77547
77548   // node_modules/name-suggestion-index/config/matchGroups.json
77549   var matchGroups_default = {
77550     matchGroups: {
77551       adult_gaming_centre: [
77552         "amenity/casino",
77553         "amenity/gambling",
77554         "leisure/adult_gaming_centre"
77555       ],
77556       beauty: [
77557         "shop/beauty",
77558         "shop/hairdresser_supply"
77559       ],
77560       bed: [
77561         "shop/bed",
77562         "shop/furniture"
77563       ],
77564       beverages: [
77565         "shop/alcohol",
77566         "shop/beer",
77567         "shop/beverages",
77568         "shop/kiosk",
77569         "shop/wine"
77570       ],
77571       camping: [
77572         "tourism/camp_site",
77573         "tourism/caravan_site"
77574       ],
77575       car_parts: [
77576         "shop/car_parts",
77577         "shop/car_repair",
77578         "shop/tires",
77579         "shop/tyres"
77580       ],
77581       clinic: [
77582         "amenity/clinic",
77583         "amenity/doctors",
77584         "healthcare/clinic",
77585         "healthcare/laboratory",
77586         "healthcare/physiotherapist",
77587         "healthcare/sample_collection",
77588         "healthcare/dialysis"
77589       ],
77590       convenience: [
77591         "shop/beauty",
77592         "shop/chemist",
77593         "shop/convenience",
77594         "shop/cosmetics",
77595         "shop/grocery",
77596         "shop/kiosk",
77597         "shop/newsagent",
77598         "shop/perfumery"
77599       ],
77600       coworking: [
77601         "amenity/coworking_space",
77602         "office/coworking",
77603         "office/coworking_space"
77604       ],
77605       dentist: [
77606         "amenity/dentist",
77607         "amenity/doctors",
77608         "healthcare/dentist"
77609       ],
77610       electronics: [
77611         "office/telecommunication",
77612         "shop/computer",
77613         "shop/electronics",
77614         "shop/hifi",
77615         "shop/kiosk",
77616         "shop/mobile",
77617         "shop/mobile_phone",
77618         "shop/telecommunication"
77619       ],
77620       fabric: [
77621         "shop/fabric",
77622         "shop/haberdashery",
77623         "shop/sewing"
77624       ],
77625       fashion: [
77626         "shop/accessories",
77627         "shop/bag",
77628         "shop/boutique",
77629         "shop/clothes",
77630         "shop/department_store",
77631         "shop/fashion",
77632         "shop/fashion_accessories",
77633         "shop/sports",
77634         "shop/shoes"
77635       ],
77636       financial: [
77637         "amenity/bank",
77638         "office/accountant",
77639         "office/financial",
77640         "office/financial_advisor",
77641         "office/tax_advisor",
77642         "shop/tax"
77643       ],
77644       fitness: [
77645         "leisure/fitness_centre",
77646         "leisure/fitness_center",
77647         "leisure/sports_centre",
77648         "leisure/sports_center"
77649       ],
77650       food: [
77651         "amenity/bar",
77652         "amenity/cafe",
77653         "amenity/fast_food",
77654         "amenity/ice_cream",
77655         "amenity/pub",
77656         "amenity/restaurant",
77657         "shop/bakery",
77658         "shop/candy",
77659         "shop/chocolate",
77660         "shop/coffee",
77661         "shop/confectionary",
77662         "shop/confectionery",
77663         "shop/food",
77664         "shop/kiosk",
77665         "shop/ice_cream",
77666         "shop/pastry",
77667         "shop/tea"
77668       ],
77669       fuel: [
77670         "amenity/fuel",
77671         "shop/gas",
77672         "shop/convenience;gas",
77673         "shop/gas;convenience"
77674       ],
77675       gift: [
77676         "shop/gift",
77677         "shop/card",
77678         "shop/cards",
77679         "shop/kiosk",
77680         "shop/stationery"
77681       ],
77682       hardware: [
77683         "shop/bathroom_furnishing",
77684         "shop/carpet",
77685         "shop/diy",
77686         "shop/doityourself",
77687         "shop/doors",
77688         "shop/electrical",
77689         "shop/flooring",
77690         "shop/hardware",
77691         "shop/hardware_store",
77692         "shop/power_tools",
77693         "shop/tool_hire",
77694         "shop/tools",
77695         "shop/trade"
77696       ],
77697       health_food: [
77698         "shop/health",
77699         "shop/health_food",
77700         "shop/herbalist",
77701         "shop/nutrition_supplements"
77702       ],
77703       hobby: [
77704         "shop/electronics",
77705         "shop/hobby",
77706         "shop/books",
77707         "shop/games",
77708         "shop/collector",
77709         "shop/toys",
77710         "shop/model",
77711         "shop/video_games",
77712         "shop/anime"
77713       ],
77714       hospital: [
77715         "amenity/doctors",
77716         "amenity/hospital",
77717         "healthcare/hospital"
77718       ],
77719       houseware: [
77720         "shop/houseware",
77721         "shop/interior_decoration"
77722       ],
77723       lifeboat_station: [
77724         "amenity/lifeboat_station",
77725         "emergency/lifeboat_station",
77726         "emergency/marine_rescue"
77727       ],
77728       lodging: [
77729         "tourism/hotel",
77730         "tourism/motel"
77731       ],
77732       money_transfer: [
77733         "amenity/money_transfer",
77734         "shop/money_transfer"
77735       ],
77736       office_supplies: [
77737         "shop/office_supplies",
77738         "shop/stationary",
77739         "shop/stationery"
77740       ],
77741       outdoor: [
77742         "shop/clothes",
77743         "shop/outdoor",
77744         "shop/sports"
77745       ],
77746       parcel_locker: [
77747         "amenity/parcel_locker",
77748         "amenity/vending_machine"
77749       ],
77750       pharmacy: [
77751         "amenity/doctors",
77752         "amenity/pharmacy",
77753         "healthcare/pharmacy"
77754       ],
77755       playground: [
77756         "amenity/theme_park",
77757         "leisure/amusement_arcade",
77758         "leisure/playground"
77759       ],
77760       rental: [
77761         "amenity/bicycle_rental",
77762         "amenity/boat_rental",
77763         "amenity/car_rental",
77764         "amenity/truck_rental",
77765         "amenity/vehicle_rental",
77766         "shop/kiosk",
77767         "shop/rental"
77768       ],
77769       school: [
77770         "amenity/childcare",
77771         "amenity/college",
77772         "amenity/kindergarten",
77773         "amenity/language_school",
77774         "amenity/prep_school",
77775         "amenity/school",
77776         "amenity/university"
77777       ],
77778       storage: [
77779         "shop/storage_units",
77780         "shop/storage_rental"
77781       ],
77782       substation: [
77783         "power/station",
77784         "power/substation",
77785         "power/sub_station"
77786       ],
77787       supermarket: [
77788         "shop/food",
77789         "shop/frozen_food",
77790         "shop/greengrocer",
77791         "shop/grocery",
77792         "shop/supermarket",
77793         "shop/wholesale"
77794       ],
77795       variety_store: [
77796         "shop/variety_store",
77797         "shop/discount",
77798         "shop/convenience"
77799       ],
77800       vending: [
77801         "amenity/vending_machine",
77802         "shop/kiosk",
77803         "shop/vending_machine"
77804       ],
77805       weight_loss: [
77806         "amenity/clinic",
77807         "amenity/doctors",
77808         "amenity/weight_clinic",
77809         "healthcare/counselling",
77810         "leisure/fitness_centre",
77811         "office/therapist",
77812         "shop/beauty",
77813         "shop/diet",
77814         "shop/food",
77815         "shop/health_food",
77816         "shop/herbalist",
77817         "shop/nutrition",
77818         "shop/nutrition_supplements",
77819         "shop/weight_loss"
77820       ],
77821       wholesale: [
77822         "shop/wholesale",
77823         "shop/supermarket",
77824         "shop/department_store"
77825       ]
77826     }
77827   };
77828
77829   // node_modules/name-suggestion-index/config/genericWords.json
77830   var genericWords_default = {
77831     genericWords: [
77832       "^(barn|bazaa?r|bench|bou?tique|building|casa|church)$",
77833       "^(baseball|basketball|football|soccer|softball|tennis(halle)?)\\s?(field|court)?$",
77834       "^(club|green|out|ware)\\s?house$",
77835       "^(driveway|el \xE1rbol|fountain|generic|golf|government|graveyard)$",
77836       "^(fixme|n\\s?\\/?\\s?a|name|no\\s?name|none|null|temporary|test|unknown)$",
77837       "^(hofladen|librairie|magazine?|maison)$",
77838       "^(mobile home|skate)?\\s?park$",
77839       "^(obuwie|pond|pool|sale|shops?|sklep|stores?)$",
77840       "^\\?+$",
77841       "^private$",
77842       "^tattoo( studio)?$",
77843       "^windmill$",
77844       "^\u0446\u0435\u0440\u043A\u043E\u0432\u043D\u0430\u044F( \u043B\u0430\u0432\u043A\u0430)?$"
77845     ]
77846   };
77847
77848   // node_modules/name-suggestion-index/config/trees.json
77849   var trees_default = {
77850     trees: {
77851       brands: {
77852         emoji: "\u{1F354}",
77853         mainTag: "brand:wikidata",
77854         sourceTags: ["brand", "name"],
77855         nameTags: {
77856           primary: "^(name|name:\\w+)$",
77857           alternate: "^(brand|brand:\\w+|operator|operator:\\w+|\\w+_name|\\w+_name:\\w+)$"
77858         }
77859       },
77860       flags: {
77861         emoji: "\u{1F6A9}",
77862         mainTag: "flag:wikidata",
77863         nameTags: {
77864           primary: "^(flag:name|flag:name:\\w+)$",
77865           alternate: "^(country|country:\\w+|flag|flag:\\w+|subject|subject:\\w+)$"
77866         }
77867       },
77868       operators: {
77869         emoji: "\u{1F4BC}",
77870         mainTag: "operator:wikidata",
77871         sourceTags: ["operator"],
77872         nameTags: {
77873           primary: "^(name|name:\\w+|operator|operator:\\w+)$",
77874           alternate: "^(brand|brand:\\w+|\\w+_name|\\w+_name:\\w+)$"
77875         }
77876       },
77877       transit: {
77878         emoji: "\u{1F687}",
77879         mainTag: "network:wikidata",
77880         sourceTags: ["network"],
77881         nameTags: {
77882           primary: "^network$",
77883           alternate: "^(operator|operator:\\w+|network:\\w+|\\w+_name|\\w+_name:\\w+)$"
77884         }
77885       }
77886     }
77887   };
77888
77889   // node_modules/name-suggestion-index/lib/matcher.js
77890   var matchGroups = matchGroups_default.matchGroups;
77891   var trees = trees_default.trees;
77892   var Matcher = class {
77893     //
77894     // `constructor`
77895     // initialize the genericWords regexes
77896     constructor() {
77897       this.matchIndex = void 0;
77898       this.genericWords = /* @__PURE__ */ new Map();
77899       (genericWords_default.genericWords || []).forEach((s2) => this.genericWords.set(s2, new RegExp(s2, "i")));
77900       this.itemLocation = void 0;
77901       this.locationSets = void 0;
77902       this.locationIndex = void 0;
77903       this.warnings = [];
77904     }
77905     //
77906     // `buildMatchIndex()`
77907     // Call this to prepare the matcher for use
77908     //
77909     // `data` needs to be an Object indexed on a 'tree/key/value' path.
77910     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
77911     // {
77912     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
77913     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
77914     //    …
77915     // }
77916     //
77917     buildMatchIndex(data) {
77918       const that = this;
77919       if (that.matchIndex)
77920         return;
77921       that.matchIndex = /* @__PURE__ */ new Map();
77922       const seenTree = /* @__PURE__ */ new Map();
77923       Object.keys(data).forEach((tkv) => {
77924         const category = data[tkv];
77925         const parts = tkv.split("/", 3);
77926         const t2 = parts[0];
77927         const k2 = parts[1];
77928         const v2 = parts[2];
77929         const thiskv = "".concat(k2, "/").concat(v2);
77930         const tree = trees[t2];
77931         let branch = that.matchIndex.get(thiskv);
77932         if (!branch) {
77933           branch = {
77934             primary: /* @__PURE__ */ new Map(),
77935             alternate: /* @__PURE__ */ new Map(),
77936             excludeGeneric: /* @__PURE__ */ new Map(),
77937             excludeNamed: /* @__PURE__ */ new Map()
77938           };
77939           that.matchIndex.set(thiskv, branch);
77940         }
77941         const properties = category.properties || {};
77942         const exclude = properties.exclude || {};
77943         (exclude.generic || []).forEach((s2) => branch.excludeGeneric.set(s2, new RegExp(s2, "i")));
77944         (exclude.named || []).forEach((s2) => branch.excludeNamed.set(s2, new RegExp(s2, "i")));
77945         const excludeRegexes = [...branch.excludeGeneric.values(), ...branch.excludeNamed.values()];
77946         let items = category.items;
77947         if (!Array.isArray(items) || !items.length)
77948           return;
77949         const primaryName = new RegExp(tree.nameTags.primary, "i");
77950         const alternateName = new RegExp(tree.nameTags.alternate, "i");
77951         const notName = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
77952         const skipGenericKV = skipGenericKVMatches(t2, k2, v2);
77953         const genericKV = /* @__PURE__ */ new Set(["".concat(k2, "/yes"), "building/yes"]);
77954         const matchGroupKV = /* @__PURE__ */ new Set();
77955         Object.values(matchGroups).forEach((matchGroup) => {
77956           const inGroup = matchGroup.some((otherkv) => otherkv === thiskv);
77957           if (!inGroup)
77958             return;
77959           matchGroup.forEach((otherkv) => {
77960             if (otherkv === thiskv)
77961               return;
77962             matchGroupKV.add(otherkv);
77963             const otherk = otherkv.split("/", 2)[0];
77964             genericKV.add("".concat(otherk, "/yes"));
77965           });
77966         });
77967         items.forEach((item) => {
77968           if (!item.id)
77969             return;
77970           if (Array.isArray(item.matchTags) && item.matchTags.length) {
77971             item.matchTags = item.matchTags.filter((matchTag) => !matchGroupKV.has(matchTag) && !genericKV.has(matchTag));
77972             if (!item.matchTags.length)
77973               delete item.matchTags;
77974           }
77975           let kvTags = ["".concat(thiskv)].concat(item.matchTags || []);
77976           if (!skipGenericKV) {
77977             kvTags = kvTags.concat(Array.from(genericKV));
77978           }
77979           Object.keys(item.tags).forEach((osmkey) => {
77980             if (notName.test(osmkey))
77981               return;
77982             const osmvalue = item.tags[osmkey];
77983             if (!osmvalue || excludeRegexes.some((regex) => regex.test(osmvalue)))
77984               return;
77985             if (primaryName.test(osmkey)) {
77986               kvTags.forEach((kv) => insertName("primary", t2, kv, simplify2(osmvalue), item.id));
77987             } else if (alternateName.test(osmkey)) {
77988               kvTags.forEach((kv) => insertName("alternate", t2, kv, simplify2(osmvalue), item.id));
77989             }
77990           });
77991           let keepMatchNames = /* @__PURE__ */ new Set();
77992           (item.matchNames || []).forEach((matchName) => {
77993             const nsimple = simplify2(matchName);
77994             kvTags.forEach((kv) => {
77995               const branch2 = that.matchIndex.get(kv);
77996               const primaryLeaf = branch2 && branch2.primary.get(nsimple);
77997               const alternateLeaf = branch2 && branch2.alternate.get(nsimple);
77998               const inPrimary = primaryLeaf && primaryLeaf.has(item.id);
77999               const inAlternate = alternateLeaf && alternateLeaf.has(item.id);
78000               if (!inPrimary && !inAlternate) {
78001                 insertName("alternate", t2, kv, nsimple, item.id);
78002                 keepMatchNames.add(matchName);
78003               }
78004             });
78005           });
78006           if (keepMatchNames.size) {
78007             item.matchNames = Array.from(keepMatchNames);
78008           } else {
78009             delete item.matchNames;
78010           }
78011         });
78012       });
78013       function insertName(which, t2, kv, nsimple, itemID) {
78014         if (!nsimple) {
78015           that.warnings.push("Warning: skipping empty ".concat(which, " name for item ").concat(t2, "/").concat(kv, ": ").concat(itemID));
78016           return;
78017         }
78018         let branch = that.matchIndex.get(kv);
78019         if (!branch) {
78020           branch = {
78021             primary: /* @__PURE__ */ new Map(),
78022             alternate: /* @__PURE__ */ new Map(),
78023             excludeGeneric: /* @__PURE__ */ new Map(),
78024             excludeNamed: /* @__PURE__ */ new Map()
78025           };
78026           that.matchIndex.set(kv, branch);
78027         }
78028         let leaf = branch[which].get(nsimple);
78029         if (!leaf) {
78030           leaf = /* @__PURE__ */ new Set();
78031           branch[which].set(nsimple, leaf);
78032         }
78033         leaf.add(itemID);
78034         if (!/yes$/.test(kv)) {
78035           const kvnsimple = "".concat(kv, "/").concat(nsimple);
78036           const existing = seenTree.get(kvnsimple);
78037           if (existing && existing !== t2) {
78038             const items = Array.from(leaf);
78039             that.warnings.push('Duplicate cache key "'.concat(kvnsimple, '" in trees "').concat(t2, '" and "').concat(existing, '", check items: ').concat(items));
78040             return;
78041           }
78042           seenTree.set(kvnsimple, t2);
78043         }
78044       }
78045       function skipGenericKVMatches(t2, k2, v2) {
78046         return t2 === "flags" || t2 === "transit" || k2 === "landuse" || v2 === "atm" || v2 === "bicycle_parking" || v2 === "car_sharing" || v2 === "caravan_site" || v2 === "charging_station" || v2 === "dog_park" || v2 === "parking" || v2 === "phone" || v2 === "playground" || v2 === "post_box" || v2 === "public_bookcase" || v2 === "recycling" || v2 === "vending_machine";
78047       }
78048     }
78049     //
78050     // `buildLocationIndex()`
78051     // Call this to prepare a which-polygon location index.
78052     // This *resolves* all the locationSets into GeoJSON, which takes some time.
78053     // You can skip this step if you don't care about matching within a location.
78054     //
78055     // `data` needs to be an Object indexed on a 'tree/key/value' path.
78056     // (e.g. cache filled by `fileTree.read` or data found in `dist/nsi.json`)
78057     // {
78058     //    'brands/amenity/bank': { properties: {}, items: [ {}, {}, … ] },
78059     //    'brands/amenity/bar':  { properties: {}, items: [ {}, {}, … ] },
78060     //    …
78061     // }
78062     //
78063     buildLocationIndex(data, loco) {
78064       const that = this;
78065       if (that.locationIndex)
78066         return;
78067       that.itemLocation = /* @__PURE__ */ new Map();
78068       that.locationSets = /* @__PURE__ */ new Map();
78069       Object.keys(data).forEach((tkv) => {
78070         const items = data[tkv].items;
78071         if (!Array.isArray(items) || !items.length)
78072           return;
78073         items.forEach((item) => {
78074           if (that.itemLocation.has(item.id))
78075             return;
78076           let resolved;
78077           try {
78078             resolved = loco.resolveLocationSet(item.locationSet);
78079           } catch (err) {
78080             console.warn("buildLocationIndex: ".concat(err.message));
78081           }
78082           if (!resolved || !resolved.id)
78083             return;
78084           that.itemLocation.set(item.id, resolved.id);
78085           if (that.locationSets.has(resolved.id))
78086             return;
78087           let feature3 = _cloneDeep2(resolved.feature);
78088           feature3.id = resolved.id;
78089           feature3.properties.id = resolved.id;
78090           if (!feature3.geometry.coordinates.length || !feature3.properties.area) {
78091             console.warn("buildLocationIndex: locationSet ".concat(resolved.id, " for ").concat(item.id, " resolves to an empty feature:"));
78092             console.warn(JSON.stringify(feature3));
78093             return;
78094           }
78095           that.locationSets.set(resolved.id, feature3);
78096         });
78097       });
78098       that.locationIndex = (0, import_which_polygon4.default)({ type: "FeatureCollection", features: [...that.locationSets.values()] });
78099       function _cloneDeep2(obj) {
78100         return JSON.parse(JSON.stringify(obj));
78101       }
78102     }
78103     //
78104     // `match()`
78105     // Pass parts and return an Array of matches.
78106     // `k` - key
78107     // `v` - value
78108     // `n` - namelike
78109     // `loc` - optional - [lon,lat] location to search
78110     //
78111     // 1. If the [k,v,n] tuple matches a canonical item…
78112     // Return an Array of match results.
78113     // Each result will include the area in km² that the item is valid.
78114     //
78115     // Order of results:
78116     // Primary ordering will be on the "match" column:
78117     //   "primary" - where the query matches the `name` tag, followed by
78118     //   "alternate" - where the query matches an alternate name tag (e.g. short_name, brand, operator, etc)
78119     // Secondary ordering will be on the "area" column:
78120     //   "area descending" if no location was provided, (worldwide before local)
78121     //   "area ascending" if location was provided (local before worldwide)
78122     //
78123     // [
78124     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
78125     //   { match: 'primary',   itemID: String,  area: Number,  kv: String,  nsimple: String },
78126     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
78127     //   { match: 'alternate', itemID: String,  area: Number,  kv: String,  nsimple: String },
78128     //   …
78129     // ]
78130     //
78131     // -or-
78132     //
78133     // 2. If the [k,v,n] tuple matches an exclude pattern…
78134     // Return an Array with a single exclude result, either
78135     //
78136     // [ { match: 'excludeGeneric', pattern: String,  kv: String } ]  // "generic" e.g. "Food Court"
78137     //   or
78138     // [ { match: 'excludeNamed', pattern: String,  kv: String } ]    // "named", e.g. "Kebabai"
78139     //
78140     // About results
78141     //   "generic" - a generic word that is probably not really a name.
78142     //     For these, iD should warn the user "Hey don't put 'food court' in the name tag".
78143     //   "named" - a real name like "Kebabai" that is just common, but not a brand.
78144     //     For these, iD should just let it be. We don't include these in NSI, but we don't want to nag users about it either.
78145     //
78146     // -or-
78147     //
78148     // 3. If the [k,v,n] tuple matches nothing of any kind, return `null`
78149     //
78150     //
78151     match(k2, v2, n3, loc) {
78152       const that = this;
78153       if (!that.matchIndex) {
78154         throw new Error("match:  matchIndex not built.");
78155       }
78156       let matchLocations;
78157       if (Array.isArray(loc) && that.locationIndex) {
78158         matchLocations = that.locationIndex([loc[0], loc[1], loc[0], loc[1]], true);
78159       }
78160       const nsimple = simplify2(n3);
78161       let seen = /* @__PURE__ */ new Set();
78162       let results = [];
78163       gatherResults("primary");
78164       gatherResults("alternate");
78165       if (results.length)
78166         return results;
78167       gatherResults("exclude");
78168       return results.length ? results : null;
78169       function gatherResults(which) {
78170         const kv = "".concat(k2, "/").concat(v2);
78171         let didMatch = tryMatch(which, kv);
78172         if (didMatch)
78173           return;
78174         for (let mg in matchGroups) {
78175           const matchGroup = matchGroups[mg];
78176           const inGroup = matchGroup.some((otherkv) => otherkv === kv);
78177           if (!inGroup)
78178             continue;
78179           for (let i3 = 0; i3 < matchGroup.length; i3++) {
78180             const otherkv = matchGroup[i3];
78181             if (otherkv === kv)
78182               continue;
78183             didMatch = tryMatch(which, otherkv);
78184             if (didMatch)
78185               return;
78186           }
78187         }
78188         if (which === "exclude") {
78189           const regex = [...that.genericWords.values()].find((regex2) => regex2.test(n3));
78190           if (regex) {
78191             results.push({ match: "excludeGeneric", pattern: String(regex) });
78192             return;
78193           }
78194         }
78195       }
78196       function tryMatch(which, kv) {
78197         const branch = that.matchIndex.get(kv);
78198         if (!branch)
78199           return;
78200         if (which === "exclude") {
78201           let regex = [...branch.excludeNamed.values()].find((regex2) => regex2.test(n3));
78202           if (regex) {
78203             results.push({ match: "excludeNamed", pattern: String(regex), kv });
78204             return;
78205           }
78206           regex = [...branch.excludeGeneric.values()].find((regex2) => regex2.test(n3));
78207           if (regex) {
78208             results.push({ match: "excludeGeneric", pattern: String(regex), kv });
78209             return;
78210           }
78211           return;
78212         }
78213         const leaf = branch[which].get(nsimple);
78214         if (!leaf || !leaf.size)
78215           return;
78216         let hits = Array.from(leaf).map((itemID) => {
78217           let area = Infinity;
78218           if (that.itemLocation && that.locationSets) {
78219             const location = that.locationSets.get(that.itemLocation.get(itemID));
78220             area = location && location.properties.area || Infinity;
78221           }
78222           return { match: which, itemID, area, kv, nsimple };
78223         });
78224         let sortFn = byAreaDescending;
78225         if (matchLocations) {
78226           hits = hits.filter(isValidLocation);
78227           sortFn = byAreaAscending;
78228         }
78229         if (!hits.length)
78230           return;
78231         hits.sort(sortFn).forEach((hit) => {
78232           if (seen.has(hit.itemID))
78233             return;
78234           seen.add(hit.itemID);
78235           results.push(hit);
78236         });
78237         return true;
78238         function isValidLocation(hit) {
78239           if (!that.itemLocation)
78240             return true;
78241           return matchLocations.find((props) => props.id === that.itemLocation.get(hit.itemID));
78242         }
78243         function byAreaAscending(hitA, hitB) {
78244           return hitA.area - hitB.area;
78245         }
78246         function byAreaDescending(hitA, hitB) {
78247           return hitB.area - hitA.area;
78248         }
78249       }
78250     }
78251     //
78252     // `getWarnings()`
78253     // Return any warnings discovered when buiding the index.
78254     // (currently this does nothing)
78255     //
78256     getWarnings() {
78257       return this.warnings;
78258     }
78259   };
78260
78261   // modules/services/nsi.js
78262   var import_vparse2 = __toESM(require_vparse());
78263   var _nsiStatus = "loading";
78264   var _nsi = {};
78265   var buildingPreset = {
78266     "building/commercial": true,
78267     "building/government": true,
78268     "building/hotel": true,
78269     "building/retail": true,
78270     "building/office": true,
78271     "building/supermarket": true,
78272     "building/yes": true
78273   };
78274   var notNames = /:(colou?r|type|forward|backward|left|right|etymology|pronunciation|wikipedia)$/i;
78275   var notBranches = /(coop|express|wireless|factory|outlet)/i;
78276   function setNsiSources() {
78277     const nsiVersion = package_default.dependencies["name-suggestion-index"] || package_default.devDependencies["name-suggestion-index"];
78278     const v2 = (0, import_vparse2.default)(nsiVersion);
78279     const vMinor = "".concat(v2.major, ".").concat(v2.minor);
78280     const cdn = nsiCdnUrl.replace("{version}", vMinor);
78281     const sources = {
78282       "nsi_data": cdn + "dist/nsi.min.json",
78283       "nsi_dissolved": cdn + "dist/dissolved.min.json",
78284       "nsi_features": cdn + "dist/featureCollection.min.json",
78285       "nsi_generics": cdn + "dist/genericWords.min.json",
78286       "nsi_presets": cdn + "dist/presets/nsi-id-presets.min.json",
78287       "nsi_replacements": cdn + "dist/replacements.min.json",
78288       "nsi_trees": cdn + "dist/trees.min.json"
78289     };
78290     let fileMap = _mainFileFetcher.fileMap();
78291     for (const k2 in sources) {
78292       if (!fileMap[k2])
78293         fileMap[k2] = sources[k2];
78294     }
78295   }
78296   function loadNsiPresets() {
78297     return Promise.all([
78298       _mainFileFetcher.get("nsi_presets"),
78299       _mainFileFetcher.get("nsi_features")
78300     ]).then((vals) => {
78301       Object.values(vals[0].presets).forEach((preset) => preset.suggestion = true);
78302       Object.values(vals[0].presets).forEach((preset) => {
78303         if (preset.tags["brand:wikidata"]) {
78304           preset.removeTags = { "brand:wikipedia": "*", ...preset.removeTags || preset.addTags || preset.tags };
78305         }
78306         if (preset.tags["operator:wikidata"]) {
78307           preset.removeTags = { "operator:wikipedia": "*", ...preset.removeTags || preset.addTags || preset.tags };
78308         }
78309         if (preset.tags["network:wikidata"]) {
78310           preset.removeTags = { "network:wikipedia": "*", ...preset.removeTags || preset.addTags || preset.tags };
78311         }
78312       });
78313       _mainPresetIndex.merge({
78314         presets: vals[0].presets,
78315         featureCollection: vals[1]
78316       });
78317     });
78318   }
78319   function loadNsiData() {
78320     return Promise.all([
78321       _mainFileFetcher.get("nsi_data"),
78322       _mainFileFetcher.get("nsi_dissolved"),
78323       _mainFileFetcher.get("nsi_replacements"),
78324       _mainFileFetcher.get("nsi_trees")
78325     ]).then((vals) => {
78326       _nsi = {
78327         data: vals[0].nsi,
78328         // the raw name-suggestion-index data
78329         dissolved: vals[1].dissolved,
78330         // list of dissolved items
78331         replacements: vals[2].replacements,
78332         // trivial old->new qid replacements
78333         trees: vals[3].trees,
78334         // metadata about trees, main tags
78335         kvt: /* @__PURE__ */ new Map(),
78336         // Map (k -> Map (v -> t) )
78337         qids: /* @__PURE__ */ new Map(),
78338         // Map (wd/wp tag values -> qids)
78339         ids: /* @__PURE__ */ new Map()
78340         // Map (id -> NSI item)
78341       };
78342       const matcher = _nsi.matcher = new Matcher();
78343       matcher.buildMatchIndex(_nsi.data);
78344       matcher.itemLocation = /* @__PURE__ */ new Map();
78345       matcher.locationSets = /* @__PURE__ */ new Map();
78346       Object.keys(_nsi.data).forEach((tkv) => {
78347         const items = _nsi.data[tkv].items;
78348         if (!Array.isArray(items) || !items.length)
78349           return;
78350         items.forEach((item) => {
78351           if (matcher.itemLocation.has(item.id))
78352             return;
78353           const locationSetID = _sharedLocationManager.locationSetID(item.locationSet);
78354           matcher.itemLocation.set(item.id, locationSetID);
78355           if (matcher.locationSets.has(locationSetID))
78356             return;
78357           const fakeFeature = { id: locationSetID, properties: { id: locationSetID, area: 1 } };
78358           matcher.locationSets.set(locationSetID, fakeFeature);
78359         });
78360       });
78361       matcher.locationIndex = (bbox2) => {
78362         const validHere = _sharedLocationManager.locationSetsAt([bbox2[0], bbox2[1]]);
78363         const results = [];
78364         for (const [locationSetID, area] of Object.entries(validHere)) {
78365           const fakeFeature = matcher.locationSets.get(locationSetID);
78366           if (fakeFeature) {
78367             fakeFeature.properties.area = area;
78368             results.push(fakeFeature);
78369           }
78370         }
78371         return results;
78372       };
78373       Object.keys(_nsi.data).forEach((tkv) => {
78374         const category = _nsi.data[tkv];
78375         const parts = tkv.split("/", 3);
78376         const t2 = parts[0];
78377         const k2 = parts[1];
78378         const v2 = parts[2];
78379         let vmap = _nsi.kvt.get(k2);
78380         if (!vmap) {
78381           vmap = /* @__PURE__ */ new Map();
78382           _nsi.kvt.set(k2, vmap);
78383         }
78384         vmap.set(v2, t2);
78385         const tree = _nsi.trees[t2];
78386         const mainTag = tree.mainTag;
78387         const items = category.items || [];
78388         items.forEach((item) => {
78389           item.tkv = tkv;
78390           item.mainTag = mainTag;
78391           _nsi.ids.set(item.id, item);
78392           const wd = item.tags[mainTag];
78393           const wp = item.tags[mainTag.replace("wikidata", "wikipedia")];
78394           if (wd)
78395             _nsi.qids.set(wd, wd);
78396           if (wp && wd)
78397             _nsi.qids.set(wp, wd);
78398         });
78399       });
78400     });
78401   }
78402   function gatherKVs(tags) {
78403     let primary = /* @__PURE__ */ new Set();
78404     let alternate = /* @__PURE__ */ new Set();
78405     Object.keys(tags).forEach((osmkey) => {
78406       const osmvalue = tags[osmkey];
78407       if (!osmvalue)
78408         return;
78409       if (osmkey === "route_master")
78410         osmkey = "route";
78411       const vmap = _nsi.kvt.get(osmkey);
78412       if (!vmap)
78413         return;
78414       if (vmap.get(osmvalue)) {
78415         primary.add("".concat(osmkey, "/").concat(osmvalue));
78416       } else if (osmvalue === "yes") {
78417         alternate.add("".concat(osmkey, "/").concat(osmvalue));
78418       }
78419     });
78420     const preset = _mainPresetIndex.matchTags(tags, "area");
78421     if (buildingPreset[preset.id]) {
78422       alternate.add("building/yes");
78423     }
78424     return { primary, alternate };
78425   }
78426   function identifyTree(tags) {
78427     let unknown;
78428     let t2;
78429     Object.keys(tags).forEach((osmkey) => {
78430       if (t2)
78431         return;
78432       const osmvalue = tags[osmkey];
78433       if (!osmvalue)
78434         return;
78435       if (osmkey === "route_master")
78436         osmkey = "route";
78437       const vmap = _nsi.kvt.get(osmkey);
78438       if (!vmap)
78439         return;
78440       if (osmvalue === "yes") {
78441         unknown = "unknown";
78442       } else {
78443         t2 = vmap.get(osmvalue);
78444       }
78445     });
78446     return t2 || unknown || null;
78447   }
78448   function gatherNames(tags) {
78449     const empty2 = { primary: /* @__PURE__ */ new Set(), alternate: /* @__PURE__ */ new Set() };
78450     let primary = /* @__PURE__ */ new Set();
78451     let alternate = /* @__PURE__ */ new Set();
78452     let foundSemi = false;
78453     let testNameFragments = false;
78454     let patterns2;
78455     let t2 = identifyTree(tags);
78456     if (!t2)
78457       return empty2;
78458     if (t2 === "transit") {
78459       patterns2 = {
78460         primary: /^network$/i,
78461         alternate: /^(operator|operator:\w+|network:\w+|\w+_name|\w+_name:\w+)$/i
78462       };
78463     } else if (t2 === "flags") {
78464       patterns2 = {
78465         primary: /^(flag:name|flag:name:\w+)$/i,
78466         alternate: /^(flag|flag:\w+|subject|subject:\w+)$/i
78467         // note: no `country`, we special-case it below
78468       };
78469     } else if (t2 === "brands") {
78470       testNameFragments = true;
78471       patterns2 = {
78472         primary: /^(name|name:\w+)$/i,
78473         alternate: /^(brand|brand:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
78474       };
78475     } else if (t2 === "operators") {
78476       testNameFragments = true;
78477       patterns2 = {
78478         primary: /^(name|name:\w+|operator|operator:\w+)$/i,
78479         alternate: /^(brand|brand:\w+|\w+_name|\w+_name:\w+)/i
78480       };
78481     } else {
78482       testNameFragments = true;
78483       patterns2 = {
78484         primary: /^(name|name:\w+)$/i,
78485         alternate: /^(brand|brand:\w+|network|network:\w+|operator|operator:\w+|\w+_name|\w+_name:\w+)/i
78486       };
78487     }
78488     if (tags.name && testNameFragments) {
78489       const nameParts = tags.name.split(/[\s\-\/,.]/);
78490       for (let split = nameParts.length; split > 0; split--) {
78491         const name = nameParts.slice(0, split).join(" ");
78492         primary.add(name);
78493       }
78494     }
78495     Object.keys(tags).forEach((osmkey) => {
78496       const osmvalue = tags[osmkey];
78497       if (!osmvalue)
78498         return;
78499       if (isNamelike(osmkey, "primary")) {
78500         if (/;/.test(osmvalue)) {
78501           foundSemi = true;
78502         } else {
78503           primary.add(osmvalue);
78504           alternate.delete(osmvalue);
78505         }
78506       } else if (!primary.has(osmvalue) && isNamelike(osmkey, "alternate")) {
78507         if (/;/.test(osmvalue)) {
78508           foundSemi = true;
78509         } else {
78510           alternate.add(osmvalue);
78511         }
78512       }
78513     });
78514     if (tags.man_made === "flagpole" && !primary.size && !alternate.size && !!tags.country) {
78515       const osmvalue = tags.country;
78516       if (/;/.test(osmvalue)) {
78517         foundSemi = true;
78518       } else {
78519         alternate.add(osmvalue);
78520       }
78521     }
78522     if (foundSemi) {
78523       return empty2;
78524     } else {
78525       return { primary, alternate };
78526     }
78527     function isNamelike(osmkey, which) {
78528       if (osmkey === "old_name")
78529         return false;
78530       return patterns2[which].test(osmkey) && !notNames.test(osmkey);
78531     }
78532   }
78533   function gatherTuples(tryKVs, tryNames) {
78534     let tuples = [];
78535     ["primary", "alternate"].forEach((whichName) => {
78536       const arr = Array.from(tryNames[whichName]).sort((a2, b2) => b2.length - a2.length);
78537       arr.forEach((n3) => {
78538         ["primary", "alternate"].forEach((whichKV) => {
78539           tryKVs[whichKV].forEach((kv) => {
78540             const parts = kv.split("/", 2);
78541             const k2 = parts[0];
78542             const v2 = parts[1];
78543             tuples.push({ k: k2, v: v2, n: n3 });
78544           });
78545         });
78546       });
78547     });
78548     return tuples;
78549   }
78550   function _upgradeTags(tags, loc) {
78551     let newTags = Object.assign({}, tags);
78552     let changed = false;
78553     Object.keys(newTags).forEach((osmkey) => {
78554       const matchTag = osmkey.match(/^(\w+:)?wikidata$/);
78555       if (matchTag) {
78556         const prefix = matchTag[1] || "";
78557         const wd = newTags[osmkey];
78558         const replace = _nsi.replacements[wd];
78559         if (replace && replace.wikidata !== void 0) {
78560           changed = true;
78561           if (replace.wikidata) {
78562             newTags[osmkey] = replace.wikidata;
78563           } else {
78564             delete newTags[osmkey];
78565           }
78566         }
78567         if (replace && replace.wikipedia !== void 0) {
78568           changed = true;
78569           const wpkey = "".concat(prefix, "wikipedia");
78570           if (replace.wikipedia) {
78571             newTags[wpkey] = replace.wikipedia;
78572           } else {
78573             delete newTags[wpkey];
78574           }
78575         }
78576       }
78577     });
78578     const isRouteMaster = tags.type === "route_master";
78579     const tryKVs = gatherKVs(tags);
78580     if (!tryKVs.primary.size && !tryKVs.alternate.size) {
78581       return changed ? { newTags, matched: null } : null;
78582     }
78583     const tryNames = gatherNames(tags);
78584     const foundQID = _nsi.qids.get(tags.wikidata) || _nsi.qids.get(tags.wikipedia);
78585     if (foundQID)
78586       tryNames.primary.add(foundQID);
78587     if (!tryNames.primary.size && !tryNames.alternate.size) {
78588       return changed ? { newTags, matched: null } : null;
78589     }
78590     const tuples = gatherTuples(tryKVs, tryNames);
78591     for (let i3 = 0; i3 < tuples.length; i3++) {
78592       const tuple = tuples[i3];
78593       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n, loc);
78594       if (!hits || !hits.length)
78595         continue;
78596       if (hits[0].match !== "primary" && hits[0].match !== "alternate")
78597         break;
78598       let itemID, item;
78599       for (let j2 = 0; j2 < hits.length; j2++) {
78600         const hit = hits[j2];
78601         itemID = hit.itemID;
78602         if (_nsi.dissolved[itemID])
78603           continue;
78604         item = _nsi.ids.get(itemID);
78605         if (!item)
78606           continue;
78607         const mainTag = item.mainTag;
78608         const itemQID = item.tags[mainTag];
78609         const notQID = newTags["not:".concat(mainTag)];
78610         if (
78611           // Exceptions, skip this hit
78612           !itemQID || itemQID === notQID || // No `*:wikidata` or matched a `not:*:wikidata`
78613           newTags.office && !item.tags.office
78614         ) {
78615           item = null;
78616           continue;
78617         } else {
78618           break;
78619         }
78620       }
78621       if (!item)
78622         continue;
78623       item = JSON.parse(JSON.stringify(item));
78624       const tkv = item.tkv;
78625       const parts = tkv.split("/", 3);
78626       const k2 = parts[1];
78627       const v2 = parts[2];
78628       const category = _nsi.data[tkv];
78629       const properties = category.properties || {};
78630       let preserveTags = item.preserveTags || properties.preserveTags || [];
78631       ["building", "emergency", "internet_access", "takeaway"].forEach((osmkey) => {
78632         if (k2 !== osmkey)
78633           preserveTags.push("^".concat(osmkey, "$"));
78634       });
78635       const regexes = preserveTags.map((s2) => new RegExp(s2, "i"));
78636       let keepTags = {};
78637       Object.keys(newTags).forEach((osmkey) => {
78638         if (regexes.some((regex) => regex.test(osmkey))) {
78639           keepTags[osmkey] = newTags[osmkey];
78640         }
78641       });
78642       _nsi.kvt.forEach((vmap, k3) => {
78643         if (newTags[k3] === "yes")
78644           delete newTags[k3];
78645       });
78646       if (foundQID) {
78647         delete newTags.wikipedia;
78648         delete newTags.wikidata;
78649       }
78650       Object.assign(newTags, item.tags, keepTags);
78651       if (isRouteMaster) {
78652         newTags.route_master = newTags.route;
78653         delete newTags.route;
78654       }
78655       const origName = tags.name;
78656       const newName = newTags.name;
78657       if (newName && origName && newName !== origName && !newTags.branch) {
78658         const newNames = gatherNames(newTags);
78659         const newSet = /* @__PURE__ */ new Set([...newNames.primary, ...newNames.alternate]);
78660         const isMoved = newSet.has(origName);
78661         if (!isMoved) {
78662           const nameParts = origName.split(/[\s\-\/,.]/);
78663           for (let split = nameParts.length; split > 0; split--) {
78664             const name = nameParts.slice(0, split).join(" ");
78665             const branch = nameParts.slice(split).join(" ");
78666             const nameHits = _nsi.matcher.match(k2, v2, name, loc);
78667             if (!nameHits || !nameHits.length)
78668               continue;
78669             if (nameHits.some((hit) => hit.itemID === itemID)) {
78670               if (branch) {
78671                 if (notBranches.test(branch)) {
78672                   newTags.name = origName;
78673                 } else {
78674                   const branchHits = _nsi.matcher.match(k2, v2, branch, loc);
78675                   if (branchHits && branchHits.length) {
78676                     if (branchHits[0].match === "primary" || branchHits[0].match === "alternate") {
78677                       return null;
78678                     }
78679                   } else {
78680                     newTags.branch = branch;
78681                   }
78682                 }
78683               }
78684               break;
78685             }
78686           }
78687         }
78688       }
78689       return { newTags, matched: item };
78690     }
78691     return changed ? { newTags, matched: null } : null;
78692   }
78693   function _isGenericName(tags) {
78694     const n3 = tags.name;
78695     if (!n3)
78696       return false;
78697     const tryNames = { primary: /* @__PURE__ */ new Set([n3]), alternate: /* @__PURE__ */ new Set() };
78698     const tryKVs = gatherKVs(tags);
78699     if (!tryKVs.primary.size && !tryKVs.alternate.size)
78700       return false;
78701     const tuples = gatherTuples(tryKVs, tryNames);
78702     for (let i3 = 0; i3 < tuples.length; i3++) {
78703       const tuple = tuples[i3];
78704       const hits = _nsi.matcher.match(tuple.k, tuple.v, tuple.n);
78705       if (hits && hits.length && hits[0].match === "excludeGeneric")
78706         return true;
78707     }
78708     return false;
78709   }
78710   var nsi_default = {
78711     // `init()`
78712     // On init, start preparing the name-suggestion-index
78713     //
78714     init: () => {
78715       setNsiSources();
78716       _mainPresetIndex.ensureLoaded().then(() => loadNsiPresets()).then(() => loadNsiData()).then(() => _nsiStatus = "ok").catch(() => _nsiStatus = "failed");
78717     },
78718     // `reset()`
78719     // Reset is called when user saves data to OSM (does nothing here)
78720     //
78721     reset: () => {
78722     },
78723     // `status()`
78724     // To let other code know how it's going...
78725     //
78726     // Returns
78727     //   `String`: 'loading', 'ok', 'failed'
78728     //
78729     status: () => _nsiStatus,
78730     // `isGenericName()`
78731     // Is the `name` tag generic?
78732     //
78733     // Arguments
78734     //   `tags`: `Object` containing the feature's OSM tags
78735     // Returns
78736     //   `true` if it is generic, `false` if not
78737     //
78738     isGenericName: (tags) => _isGenericName(tags),
78739     // `upgradeTags()`
78740     // Suggest tag upgrades.
78741     // This function will not modify the input tags, it makes a copy.
78742     //
78743     // Arguments
78744     //   `tags`: `Object` containing the feature's OSM tags
78745     //   `loc`: Location where this feature exists, as a [lon, lat]
78746     // Returns
78747     //   `Object` containing the result, or `null` if no changes needed:
78748     //   {
78749     //     'newTags': `Object` - The tags the the feature should have
78750     //     'matched': `Object` - The matched item
78751     //   }
78752     //
78753     upgradeTags: (tags, loc) => _upgradeTags(tags, loc),
78754     // `cache()`
78755     // Direct access to the NSI cache, useful for testing or breaking things
78756     //
78757     // Returns
78758     //   `Object`: the internal NSI cache
78759     //
78760     cache: () => _nsi
78761   };
78762
78763   // modules/services/kartaview.js
78764   var import_rbush8 = __toESM(require_rbush_min());
78765   var apibase2 = "https://kartaview.org";
78766   var maxResults = 1e3;
78767   var tileZoom = 14;
78768   var tiler4 = utilTiler().zoomExtent([tileZoom, tileZoom]).skipNullIsland(true);
78769   var dispatch7 = dispatch_default("loadedImages");
78770   var imgZoom2 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
78771   var _oscCache;
78772   var _oscSelectedImage;
78773   var _loadViewerPromise2;
78774   function abortRequest4(controller) {
78775     controller.abort();
78776   }
78777   function maxPageAtZoom(z2) {
78778     if (z2 < 15)
78779       return 2;
78780     if (z2 === 15)
78781       return 5;
78782     if (z2 === 16)
78783       return 10;
78784     if (z2 === 17)
78785       return 20;
78786     if (z2 === 18)
78787       return 40;
78788     if (z2 > 18)
78789       return 80;
78790   }
78791   function loadTiles2(which, url, projection2) {
78792     var currZoom = Math.floor(geoScaleToZoom(projection2.scale()));
78793     var tiles = tiler4.getTiles(projection2);
78794     var cache = _oscCache[which];
78795     Object.keys(cache.inflight).forEach(function(k2) {
78796       var wanted = tiles.find(function(tile) {
78797         return k2.indexOf(tile.id + ",") === 0;
78798       });
78799       if (!wanted) {
78800         abortRequest4(cache.inflight[k2]);
78801         delete cache.inflight[k2];
78802       }
78803     });
78804     tiles.forEach(function(tile) {
78805       loadNextTilePage(which, currZoom, url, tile);
78806     });
78807   }
78808   function loadNextTilePage(which, currZoom, url, tile) {
78809     var cache = _oscCache[which];
78810     var bbox2 = tile.extent.bbox();
78811     var maxPages = maxPageAtZoom(currZoom);
78812     var nextPage = cache.nextPage[tile.id] || 1;
78813     var params = utilQsString({
78814       ipp: maxResults,
78815       page: nextPage,
78816       // client_id: clientId,
78817       bbTopLeft: [bbox2.maxY, bbox2.minX].join(","),
78818       bbBottomRight: [bbox2.minY, bbox2.maxX].join(",")
78819     }, true);
78820     if (nextPage > maxPages)
78821       return;
78822     var id2 = tile.id + "," + String(nextPage);
78823     if (cache.loaded[id2] || cache.inflight[id2])
78824       return;
78825     var controller = new AbortController();
78826     cache.inflight[id2] = controller;
78827     var options2 = {
78828       method: "POST",
78829       signal: controller.signal,
78830       body: params,
78831       headers: { "Content-Type": "application/x-www-form-urlencoded" }
78832     };
78833     json_default(url, options2).then(function(data) {
78834       cache.loaded[id2] = true;
78835       delete cache.inflight[id2];
78836       if (!data || !data.currentPageItems || !data.currentPageItems.length) {
78837         throw new Error("No Data");
78838       }
78839       var features = data.currentPageItems.map(function(item) {
78840         var loc = [+item.lng, +item.lat];
78841         var d2;
78842         if (which === "images") {
78843           d2 = {
78844             loc,
78845             key: item.id,
78846             ca: +item.heading,
78847             captured_at: item.shot_date || item.date_added,
78848             captured_by: item.username,
78849             imagePath: item.lth_name,
78850             sequence_id: item.sequence_id,
78851             sequence_index: +item.sequence_index
78852           };
78853           var seq = _oscCache.sequences[d2.sequence_id];
78854           if (!seq) {
78855             seq = { rotation: 0, images: [] };
78856             _oscCache.sequences[d2.sequence_id] = seq;
78857           }
78858           seq.images[d2.sequence_index] = d2;
78859           _oscCache.images.forImageKey[d2.key] = d2;
78860         }
78861         return {
78862           minX: loc[0],
78863           minY: loc[1],
78864           maxX: loc[0],
78865           maxY: loc[1],
78866           data: d2
78867         };
78868       });
78869       cache.rtree.load(features);
78870       if (data.currentPageItems.length === maxResults) {
78871         cache.nextPage[tile.id] = nextPage + 1;
78872         loadNextTilePage(which, currZoom, url, tile);
78873       } else {
78874         cache.nextPage[tile.id] = Infinity;
78875       }
78876       if (which === "images") {
78877         dispatch7.call("loadedImages");
78878       }
78879     }).catch(function() {
78880       cache.loaded[id2] = true;
78881       delete cache.inflight[id2];
78882     });
78883   }
78884   function partitionViewport2(projection2) {
78885     var z2 = geoScaleToZoom(projection2.scale());
78886     var z22 = Math.ceil(z2 * 2) / 2 + 2.5;
78887     var tiler9 = utilTiler().zoomExtent([z22, z22]);
78888     return tiler9.getTiles(projection2).map(function(tile) {
78889       return tile.extent;
78890     });
78891   }
78892   function searchLimited2(limit, projection2, rtree) {
78893     limit = limit || 5;
78894     return partitionViewport2(projection2).reduce(function(result, extent) {
78895       var found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
78896         return d2.data;
78897       });
78898       return found.length ? result.concat(found) : result;
78899     }, []);
78900   }
78901   var kartaview_default = {
78902     init: function() {
78903       if (!_oscCache) {
78904         this.reset();
78905       }
78906       this.event = utilRebind(this, dispatch7, "on");
78907     },
78908     reset: function() {
78909       if (_oscCache) {
78910         Object.values(_oscCache.images.inflight).forEach(abortRequest4);
78911       }
78912       _oscCache = {
78913         images: { inflight: {}, loaded: {}, nextPage: {}, rtree: new import_rbush8.default(), forImageKey: {} },
78914         sequences: {}
78915       };
78916       _oscSelectedImage = null;
78917     },
78918     images: function(projection2) {
78919       var limit = 5;
78920       return searchLimited2(limit, projection2, _oscCache.images.rtree);
78921     },
78922     sequences: function(projection2) {
78923       var viewport = projection2.clipExtent();
78924       var min3 = [viewport[0][0], viewport[1][1]];
78925       var max3 = [viewport[1][0], viewport[0][1]];
78926       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
78927       var sequenceKeys = {};
78928       _oscCache.images.rtree.search(bbox2).forEach(function(d2) {
78929         sequenceKeys[d2.data.sequence_id] = true;
78930       });
78931       var lineStrings = [];
78932       Object.keys(sequenceKeys).forEach(function(sequenceKey) {
78933         var seq = _oscCache.sequences[sequenceKey];
78934         var images = seq && seq.images;
78935         if (images) {
78936           lineStrings.push({
78937             type: "LineString",
78938             coordinates: images.map(function(d2) {
78939               return d2.loc;
78940             }).filter(Boolean),
78941             properties: {
78942               captured_at: images[0] ? images[0].captured_at : null,
78943               captured_by: images[0] ? images[0].captured_by : null,
78944               key: sequenceKey
78945             }
78946           });
78947         }
78948       });
78949       return lineStrings;
78950     },
78951     cachedImage: function(imageKey) {
78952       return _oscCache.images.forImageKey[imageKey];
78953     },
78954     loadImages: function(projection2) {
78955       var url = apibase2 + "/1.0/list/nearby-photos/";
78956       loadTiles2("images", url, projection2);
78957     },
78958     ensureViewerLoaded: function(context) {
78959       if (_loadViewerPromise2)
78960         return _loadViewerPromise2;
78961       var wrap2 = context.container().select(".photoviewer").selectAll(".kartaview-wrapper").data([0]);
78962       var that = this;
78963       var wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper kartaview-wrapper").classed("hide", true).call(imgZoom2.on("zoom", zoomPan2)).on("dblclick.zoom", null);
78964       wrapEnter.append("div").attr("class", "photo-attribution fillD");
78965       var controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
78966       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
78967       controlsEnter.append("button").on("click.rotate-ccw", rotate(-90)).text("\u293F");
78968       controlsEnter.append("button").on("click.rotate-cw", rotate(90)).text("\u293E");
78969       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
78970       wrapEnter.append("div").attr("class", "kartaview-image-wrap");
78971       context.ui().photoviewer.on("resize.kartaview", function(dimensions) {
78972         imgZoom2.extent([[0, 0], dimensions]).translateExtent([[0, 0], dimensions]);
78973       });
78974       function zoomPan2(d3_event) {
78975         var t2 = d3_event.transform;
78976         context.container().select(".photoviewer .kartaview-image-wrap").call(utilSetTransform, t2.x, t2.y, t2.k);
78977       }
78978       function rotate(deg) {
78979         return function() {
78980           if (!_oscSelectedImage)
78981             return;
78982           var sequenceKey = _oscSelectedImage.sequence_id;
78983           var sequence = _oscCache.sequences[sequenceKey];
78984           if (!sequence)
78985             return;
78986           var r2 = sequence.rotation || 0;
78987           r2 += deg;
78988           if (r2 > 180)
78989             r2 -= 360;
78990           if (r2 < -180)
78991             r2 += 360;
78992           sequence.rotation = r2;
78993           var wrap3 = context.container().select(".photoviewer .kartaview-wrapper");
78994           wrap3.transition().duration(100).call(imgZoom2.transform, identity2);
78995           wrap3.selectAll(".kartaview-image").transition().duration(100).style("transform", "rotate(" + r2 + "deg)");
78996         };
78997       }
78998       function step(stepBy) {
78999         return function() {
79000           if (!_oscSelectedImage)
79001             return;
79002           var sequenceKey = _oscSelectedImage.sequence_id;
79003           var sequence = _oscCache.sequences[sequenceKey];
79004           if (!sequence)
79005             return;
79006           var nextIndex = _oscSelectedImage.sequence_index + stepBy;
79007           var nextImage = sequence.images[nextIndex];
79008           if (!nextImage)
79009             return;
79010           context.map().centerEase(nextImage.loc);
79011           that.selectImage(context, nextImage.key);
79012         };
79013       }
79014       _loadViewerPromise2 = Promise.resolve();
79015       return _loadViewerPromise2;
79016     },
79017     showViewer: function(context) {
79018       var viewer = context.container().select(".photoviewer").classed("hide", false);
79019       var isHidden = viewer.selectAll(".photo-wrapper.kartaview-wrapper.hide").size();
79020       if (isHidden) {
79021         viewer.selectAll(".photo-wrapper:not(.kartaview-wrapper)").classed("hide", true);
79022         viewer.selectAll(".photo-wrapper.kartaview-wrapper").classed("hide", false);
79023       }
79024       return this;
79025     },
79026     hideViewer: function(context) {
79027       _oscSelectedImage = null;
79028       this.updateUrlImage(null);
79029       var viewer = context.container().select(".photoviewer");
79030       if (!viewer.empty())
79031         viewer.datum(null);
79032       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
79033       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
79034       return this.setStyles(context, null, true);
79035     },
79036     selectImage: function(context, imageKey) {
79037       var d2 = this.cachedImage(imageKey);
79038       _oscSelectedImage = d2;
79039       this.updateUrlImage(imageKey);
79040       var viewer = context.container().select(".photoviewer");
79041       if (!viewer.empty())
79042         viewer.datum(d2);
79043       this.setStyles(context, null, true);
79044       context.container().selectAll(".icon-sign").classed("currentView", false);
79045       if (!d2)
79046         return this;
79047       var wrap2 = context.container().select(".photoviewer .kartaview-wrapper");
79048       var imageWrap = wrap2.selectAll(".kartaview-image-wrap");
79049       var attribution = wrap2.selectAll(".photo-attribution").text("");
79050       wrap2.transition().duration(100).call(imgZoom2.transform, identity2);
79051       imageWrap.selectAll(".kartaview-image").remove();
79052       if (d2) {
79053         var sequence = _oscCache.sequences[d2.sequence_id];
79054         var r2 = sequence && sequence.rotation || 0;
79055         imageWrap.append("img").attr("class", "kartaview-image").attr("src", apibase2 + "/" + d2.imagePath).style("transform", "rotate(" + r2 + "deg)");
79056         if (d2.captured_by) {
79057           attribution.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://kartaview.org/user/" + encodeURIComponent(d2.captured_by)).text("@" + d2.captured_by);
79058           attribution.append("span").text("|");
79059         }
79060         if (d2.captured_at) {
79061           attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.captured_at));
79062           attribution.append("span").text("|");
79063         }
79064         attribution.append("a").attr("class", "image-link").attr("target", "_blank").attr("href", "https://kartaview.org/details/" + d2.sequence_id + "/" + d2.sequence_index).text("kartaview.org");
79065       }
79066       return this;
79067       function localeDateString2(s2) {
79068         if (!s2)
79069           return null;
79070         var options2 = { day: "numeric", month: "short", year: "numeric" };
79071         var d4 = new Date(s2);
79072         if (isNaN(d4.getTime()))
79073           return null;
79074         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
79075       }
79076     },
79077     getSelectedImage: function() {
79078       return _oscSelectedImage;
79079     },
79080     getSequenceKeyForImage: function(d2) {
79081       return d2 && d2.sequence_id;
79082     },
79083     // Updates the currently highlighted sequence and selected bubble.
79084     // Reset is only necessary when interacting with the viewport because
79085     // this implicitly changes the currently selected bubble/sequence
79086     setStyles: function(context, hovered, reset) {
79087       if (reset) {
79088         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
79089         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
79090       }
79091       var hoveredImageKey = hovered && hovered.key;
79092       var hoveredSequenceKey = this.getSequenceKeyForImage(hovered);
79093       var hoveredSequence = hoveredSequenceKey && _oscCache.sequences[hoveredSequenceKey];
79094       var hoveredImageKeys = hoveredSequence && hoveredSequence.images.map(function(d2) {
79095         return d2.key;
79096       }) || [];
79097       var viewer = context.container().select(".photoviewer");
79098       var selected = viewer.empty() ? void 0 : viewer.datum();
79099       var selectedImageKey = selected && selected.key;
79100       var selectedSequenceKey = this.getSequenceKeyForImage(selected);
79101       var selectedSequence = selectedSequenceKey && _oscCache.sequences[selectedSequenceKey];
79102       var selectedImageKeys = selectedSequence && selectedSequence.images.map(function(d2) {
79103         return d2.key;
79104       }) || [];
79105       var highlightedImageKeys = utilArrayUnion(hoveredImageKeys, selectedImageKeys);
79106       context.container().selectAll(".layer-kartaview .viewfield-group").classed("highlighted", function(d2) {
79107         return highlightedImageKeys.indexOf(d2.key) !== -1;
79108       }).classed("hovered", function(d2) {
79109         return d2.key === hoveredImageKey;
79110       }).classed("currentView", function(d2) {
79111         return d2.key === selectedImageKey;
79112       });
79113       context.container().selectAll(".layer-kartaview .sequence").classed("highlighted", function(d2) {
79114         return d2.properties.key === hoveredSequenceKey;
79115       }).classed("currentView", function(d2) {
79116         return d2.properties.key === selectedSequenceKey;
79117       });
79118       context.container().selectAll(".layer-kartaview .viewfield-group .viewfield").attr("d", viewfieldPath);
79119       function viewfieldPath() {
79120         var d2 = this.parentNode.__data__;
79121         if (d2.pano && d2.key !== selectedImageKey) {
79122           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
79123         } else {
79124           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
79125         }
79126       }
79127       return this;
79128     },
79129     updateUrlImage: function(imageKey) {
79130       if (!window.mocha) {
79131         var hash = utilStringQs(window.location.hash);
79132         if (imageKey) {
79133           hash.photo = "kartaview/" + imageKey;
79134         } else {
79135           delete hash.photo;
79136         }
79137         window.location.replace("#" + utilQsString(hash, true));
79138       }
79139     },
79140     cache: function() {
79141       return _oscCache;
79142     }
79143   };
79144
79145   // modules/services/vegbilder.js
79146   var import_rbush9 = __toESM(require_rbush_min());
79147
79148   // modules/services/pannellum_photo.js
79149   var pannellumViewerCSS = "pannellum/pannellum.css";
79150   var pannellumViewerJS = "pannellum/pannellum.js";
79151   var dispatch8 = dispatch_default("viewerChanged");
79152   var _currScenes = [];
79153   var _pannellumViewer;
79154   var pannellum_photo_default = {
79155     init: async function(context, selection2) {
79156       selection2.append("div").attr("class", "photo-frame pannellum-frame").attr("id", "ideditor-pannellum-viewer").classed("hide", true);
79157       if (!window.pannellum) {
79158         await this.loadPannellum(context);
79159       }
79160       const options2 = {
79161         "default": { firstScene: "" },
79162         scenes: {}
79163       };
79164       _pannellumViewer = window.pannellum.viewer("ideditor-pannellum-viewer", options2);
79165       _pannellumViewer.on("mousedown", () => {
79166         select_default2(window).on("pointermove.pannellum mousemove.pannellum", () => {
79167           dispatch8.call("viewerChanged");
79168         });
79169       }).on("mouseup", () => {
79170         select_default2(window).on("pointermove.pannellum mousemove.pannellum", null);
79171       }).on("animatefinished", () => {
79172         dispatch8.call("viewerChanged");
79173       });
79174       context.ui().photoviewer.on("resize.pannellum", () => {
79175         _pannellumViewer.resize();
79176       });
79177       this.event = utilRebind(this, dispatch8, "on");
79178       return this;
79179     },
79180     loadPannellum: function(context) {
79181       const head = select_default2("head");
79182       return Promise.all([
79183         new Promise((resolve, reject) => {
79184           head.selectAll("#ideditor-pannellum-viewercss").data([0]).enter().append("link").attr("id", "ideditor-pannellum-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(pannellumViewerCSS)).on("load.pannellum", resolve).on("error.pannellum", reject);
79185         }),
79186         new Promise((resolve, reject) => {
79187           head.selectAll("#ideditor-pannellum-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-pannellum-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(pannellumViewerJS)).on("load.pannellum", resolve).on("error.pannellum", reject);
79188         })
79189       ]);
79190     },
79191     showPhotoFrame: function(context) {
79192       const isHidden = context.selectAll(".photo-frame.pannellum-frame.hide").size();
79193       if (isHidden) {
79194         context.selectAll(".photo-frame:not(.pannellum-frame)").classed("hide", true);
79195         context.selectAll(".photo-frame.pannellum-frame").classed("hide", false);
79196       }
79197       return this;
79198     },
79199     hidePhotoFrame: function(viewerContext) {
79200       viewerContext.select("photo-frame.pannellum-frame").classed("hide", false);
79201       return this;
79202     },
79203     selectPhoto: function(data, keepOrientation) {
79204       const { key } = data;
79205       if (!(key in _currScenes)) {
79206         let newSceneOptions = {
79207           showFullscreenCtrl: false,
79208           autoLoad: false,
79209           compass: true,
79210           yaw: 0,
79211           type: "equirectangular",
79212           preview: data.preview_path,
79213           panorama: data.image_path,
79214           northOffset: data.ca
79215         };
79216         _currScenes.push(key);
79217         _pannellumViewer.addScene(key, newSceneOptions);
79218       }
79219       let yaw = 0;
79220       let pitch = 0;
79221       if (keepOrientation) {
79222         yaw = this.getYaw();
79223         pitch = _pannellumViewer.getPitch();
79224       }
79225       _pannellumViewer.loadScene(key, pitch, yaw);
79226       dispatch8.call("viewerChanged");
79227       if (_currScenes.length > 3) {
79228         const old_key = _currScenes.shift();
79229         _pannellumViewer.removeScene(old_key);
79230       }
79231       return this;
79232     },
79233     getYaw: function() {
79234       return _pannellumViewer.getYaw();
79235     }
79236   };
79237
79238   // modules/services/vegbilder.js
79239   var owsEndpoint = "https://www.vegvesen.no/kart/ogc/vegbilder_1_0/ows?";
79240   var tileZoom2 = 14;
79241   var tiler5 = utilTiler().zoomExtent([tileZoom2, tileZoom2]).skipNullIsland(true);
79242   var dispatch9 = dispatch_default("loadedImages", "viewerChanged");
79243   var directionEnum = Object.freeze({
79244     forward: Symbol(0),
79245     backward: Symbol(1)
79246   });
79247   var _planeFrame;
79248   var _pannellumFrame;
79249   var _currentFrame;
79250   var _loadViewerPromise3;
79251   var _vegbilderCache;
79252   async function fetchAvailableLayers() {
79253     var _a2, _b, _c;
79254     const params = {
79255       service: "WFS",
79256       request: "GetCapabilities",
79257       version: "2.0.0"
79258     };
79259     const urlForRequest = owsEndpoint + utilQsString(params);
79260     const response = await xml_default(urlForRequest);
79261     const xPathSelector = "/wfs:WFS_Capabilities/wfs:FeatureTypeList/wfs:FeatureType/wfs:Name";
79262     const regexMatcher = /^vegbilder_1_0:Vegbilder(?<image_type>_360)?_(?<year>\d{4})$/;
79263     const NSResolver = response.createNSResolver(response);
79264     const l2 = response.evaluate(
79265       xPathSelector,
79266       response,
79267       NSResolver,
79268       XPathResult.ANY_TYPE
79269     );
79270     let node;
79271     const availableLayers = [];
79272     while ((node = l2.iterateNext()) !== null) {
79273       const match = (_a2 = node.textContent) == null ? void 0 : _a2.match(regexMatcher);
79274       if (match) {
79275         availableLayers.push({
79276           name: match[0],
79277           is_sphere: !!((_b = match.groups) == null ? void 0 : _b.image_type),
79278           year: parseInt((_c = match.groups) == null ? void 0 : _c.year, 10)
79279         });
79280       }
79281     }
79282     return availableLayers;
79283   }
79284   function filterAvailableLayers(photoContex) {
79285     const fromDateString = photoContex.fromDate();
79286     const toDateString = photoContex.toDate();
79287     const fromYear = fromDateString ? new Date(fromDateString).getFullYear() : 2016;
79288     const toYear = toDateString ? new Date(toDateString).getFullYear() : null;
79289     const showsFlat = photoContex.showsFlat();
79290     const showsPano = photoContex.showsPanoramic();
79291     return Array.from(_vegbilderCache.wfslayers.values()).filter(({ layerInfo }) => layerInfo.year >= fromYear && (!toYear || layerInfo.year <= toYear) && (!layerInfo.is_sphere && showsFlat || layerInfo.is_sphere && showsPano));
79292   }
79293   function loadWFSLayers(projection2, margin, wfslayers) {
79294     const tiles = tiler5.margin(margin).getTiles(projection2);
79295     for (const cache of wfslayers) {
79296       loadWFSLayer(projection2, cache, tiles);
79297     }
79298   }
79299   function loadWFSLayer(projection2, cache, tiles) {
79300     for (const [key, controller] of cache.inflight.entries()) {
79301       const wanted = tiles.some((tile) => key === tile.id);
79302       if (!wanted) {
79303         controller.abort();
79304         cache.inflight.delete(key);
79305       }
79306     }
79307     Promise.all(tiles.map(
79308       (tile) => loadTile2(cache, cache.layerInfo.name, tile)
79309     )).then(() => orderSequences(projection2, cache));
79310   }
79311   async function loadTile2(cache, typename, tile) {
79312     const bbox2 = tile.extent.bbox();
79313     const tileid = tile.id;
79314     if (cache.loaded.get(tileid) === true || cache.inflight.has(tileid))
79315       return;
79316     const params = {
79317       service: "WFS",
79318       request: "GetFeature",
79319       version: "2.0.0",
79320       typenames: typename,
79321       bbox: [bbox2.minY, bbox2.minX, bbox2.maxY, bbox2.maxX].join(","),
79322       outputFormat: "json"
79323     };
79324     const controller = new AbortController();
79325     cache.inflight.set(tileid, controller);
79326     const options2 = {
79327       method: "GET",
79328       signal: controller.signal
79329     };
79330     const urlForRequest = owsEndpoint + utilQsString(params);
79331     let featureCollection;
79332     try {
79333       featureCollection = await json_default(urlForRequest, options2);
79334     } catch {
79335       cache.loaded.set(tileid, false);
79336       return;
79337     } finally {
79338       cache.inflight.delete(tileid);
79339     }
79340     cache.loaded.set(tileid, true);
79341     if (featureCollection.features.length === 0) {
79342       return;
79343     }
79344     const features = featureCollection.features.map((feature3) => {
79345       const loc = feature3.geometry.coordinates;
79346       const key = feature3.id;
79347       const properties = feature3.properties;
79348       const {
79349         RETNING: ca,
79350         TIDSPUNKT: captured_at,
79351         URL: image_path,
79352         URLPREVIEW: preview_path,
79353         BILDETYPE: image_type,
79354         METER: metering,
79355         FELTKODE: lane_code
79356       } = properties;
79357       const lane_number = parseInt(lane_code.match(/^[0-9]+/)[0], 10);
79358       const direction = lane_number % 2 === 0 ? directionEnum.backward : directionEnum.forward;
79359       const data = {
79360         loc,
79361         key,
79362         ca,
79363         image_path,
79364         preview_path,
79365         road_reference: roadReference(properties),
79366         metering,
79367         lane_code,
79368         direction,
79369         captured_at: new Date(captured_at),
79370         is_sphere: image_type === "360"
79371       };
79372       cache.points.set(key, data);
79373       return {
79374         minX: loc[0],
79375         minY: loc[1],
79376         maxX: loc[0],
79377         maxY: loc[1],
79378         data
79379       };
79380     });
79381     _vegbilderCache.rtree.load(features);
79382     dispatch9.call("loadedImages");
79383   }
79384   function orderSequences(projection2, cache) {
79385     const { points } = cache;
79386     const grouped = Array.from(points.values()).reduce((grouped2, image) => {
79387       const key = image.road_reference;
79388       if (grouped2.has(key)) {
79389         grouped2.get(key).push(image);
79390       } else {
79391         grouped2.set(key, [image]);
79392       }
79393       return grouped2;
79394     }, /* @__PURE__ */ new Map());
79395     const imageSequences = Array.from(grouped.values()).reduce((imageSequences2, imageGroup) => {
79396       imageGroup.sort((a2, b2) => {
79397         if (a2.captured_at.valueOf() > b2.captured_at.valueOf()) {
79398           return 1;
79399         } else if (a2.captured_at.valueOf() < b2.captured_at.valueOf()) {
79400           return -1;
79401         } else {
79402           const { direction } = a2;
79403           if (direction === directionEnum.forward) {
79404             return a2.metering - b2.metering;
79405           } else {
79406             return b2.metering - a2.metering;
79407           }
79408         }
79409       });
79410       let imageSequence = [imageGroup[0]];
79411       let angle2 = null;
79412       for (const [lastImage, image] of pairs(imageGroup)) {
79413         if (lastImage.ca === null) {
79414           const b2 = projection2(lastImage.loc);
79415           const a2 = projection2(image.loc);
79416           if (!geoVecEqual(a2, b2)) {
79417             angle2 = geoVecAngle(a2, b2);
79418             angle2 *= 180 / Math.PI;
79419             angle2 -= 90;
79420             angle2 = angle2 >= 0 ? angle2 : angle2 + 360;
79421           }
79422           lastImage.ca = angle2;
79423         }
79424         if (image.direction === lastImage.direction && image.captured_at.valueOf() - lastImage.captured_at.valueOf() <= 2e4) {
79425           imageSequence.push(image);
79426         } else {
79427           imageSequences2.push(imageSequence);
79428           imageSequence = [image];
79429         }
79430       }
79431       imageSequences2.push(imageSequence);
79432       return imageSequences2;
79433     }, []);
79434     cache.sequences = imageSequences.map((images) => {
79435       const sequence = {
79436         images,
79437         key: images[0].key,
79438         geometry: {
79439           type: "LineString",
79440           coordinates: images.map((image) => image.loc)
79441         }
79442       };
79443       for (const image of images) {
79444         _vegbilderCache.image2sequence_map.set(image.key, sequence);
79445       }
79446       return sequence;
79447     });
79448   }
79449   function roadReference(properties) {
79450     const {
79451       FYLKENUMMER: county_number,
79452       VEGKATEGORI: road_class,
79453       VEGSTATUS: road_status,
79454       VEGNUMMER: road_number,
79455       STREKNING: section,
79456       DELSTREKNING: subsection,
79457       HP: parcel,
79458       KRYSSDEL: junction_part,
79459       SIDEANLEGGSDEL: services_part,
79460       ANKERPUNKT: anker_point,
79461       AAR: year
79462     } = properties;
79463     let reference;
79464     if (year >= 2020) {
79465       reference = "".concat(road_class).concat(road_status).concat(road_number, " S").concat(section, "D").concat(subsection);
79466       if (junction_part) {
79467         reference = "".concat(reference, " M").concat(anker_point, " KD").concat(junction_part);
79468       } else if (services_part) {
79469         reference = "".concat(reference, " M").concat(anker_point, " SD").concat(services_part);
79470       }
79471     } else {
79472       reference = "".concat(county_number).concat(road_class).concat(road_status).concat(road_number, " HP").concat(parcel);
79473     }
79474     return reference;
79475   }
79476   function localeTimestamp(date) {
79477     const options2 = {
79478       day: "2-digit",
79479       month: "2-digit",
79480       year: "numeric",
79481       hour: "numeric",
79482       minute: "numeric",
79483       second: "numeric"
79484     };
79485     return date.toLocaleString(_mainLocalizer.localeCode(), options2);
79486   }
79487   function partitionViewport3(projection2) {
79488     const zoom = geoScaleToZoom(projection2.scale());
79489     const roundZoom = Math.ceil(zoom * 2) / 2 + 2.5;
79490     const tiler9 = utilTiler().zoomExtent([roundZoom, roundZoom]);
79491     return tiler9.getTiles(projection2).map((tile) => tile.extent);
79492   }
79493   function searchLimited3(limit, projection2, rtree) {
79494     limit != null ? limit : limit = 5;
79495     return partitionViewport3(projection2).reduce((result, extent) => {
79496       const found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
79497       return result.concat(found);
79498     }, []);
79499   }
79500   var vegbilder_default = {
79501     init: function() {
79502       this.event = utilRebind(this, dispatch9, "on");
79503     },
79504     reset: async function() {
79505       if (_vegbilderCache) {
79506         for (const layer of _vegbilderCache.wfslayers.values()) {
79507           for (const controller of layer.inflight.values()) {
79508             controller.abort();
79509           }
79510         }
79511       }
79512       _vegbilderCache = {
79513         wfslayers: /* @__PURE__ */ new Map(),
79514         rtree: new import_rbush9.default(),
79515         image2sequence_map: /* @__PURE__ */ new Map()
79516       };
79517       const availableLayers = await fetchAvailableLayers();
79518       const { wfslayers } = _vegbilderCache;
79519       for (const layerInfo of availableLayers) {
79520         const cache = {
79521           layerInfo,
79522           loaded: /* @__PURE__ */ new Map(),
79523           inflight: /* @__PURE__ */ new Map(),
79524           points: /* @__PURE__ */ new Map(),
79525           sequences: []
79526         };
79527         wfslayers.set(layerInfo.name, cache);
79528       }
79529     },
79530     images: function(projection2) {
79531       const limit = 5;
79532       return searchLimited3(limit, projection2, _vegbilderCache.rtree);
79533     },
79534     sequences: function(projection2) {
79535       const viewport = projection2.clipExtent();
79536       const min3 = [viewport[0][0], viewport[1][1]];
79537       const max3 = [viewport[1][0], viewport[0][1]];
79538       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
79539       const seen = /* @__PURE__ */ new Set();
79540       const line_strings = [];
79541       for (const { data } of _vegbilderCache.rtree.search(bbox2)) {
79542         const sequence = _vegbilderCache.image2sequence_map.get(data.key);
79543         if (!sequence)
79544           continue;
79545         const { key, geometry, images } = sequence;
79546         if (seen.has(key))
79547           continue;
79548         seen.add(key);
79549         const line = {
79550           type: "LineString",
79551           coordinates: geometry.coordinates,
79552           key,
79553           images
79554         };
79555         line_strings.push(line);
79556       }
79557       return line_strings;
79558     },
79559     cachedImage: function(key) {
79560       for (const { points } of _vegbilderCache.wfslayers.values()) {
79561         if (points.has(key))
79562           return points.get(key);
79563       }
79564     },
79565     getSequenceForImage: function(image) {
79566       return _vegbilderCache == null ? void 0 : _vegbilderCache.image2sequence_map.get(image == null ? void 0 : image.key);
79567     },
79568     loadImages: async function(context, margin) {
79569       if (!_vegbilderCache) {
79570         await this.reset();
79571       }
79572       margin != null ? margin : margin = 1;
79573       const wfslayers = filterAvailableLayers(context.photos());
79574       loadWFSLayers(context.projection, margin, wfslayers);
79575     },
79576     photoFrame: function() {
79577       return _currentFrame;
79578     },
79579     ensureViewerLoaded: function(context) {
79580       if (_loadViewerPromise3)
79581         return _loadViewerPromise3;
79582       const step = (stepBy) => () => {
79583         const viewer = context.container().select(".photoviewer");
79584         const selected = viewer.empty() ? void 0 : viewer.datum();
79585         if (!selected)
79586           return;
79587         const sequence = this.getSequenceForImage(selected);
79588         const nextIndex = sequence.images.indexOf(selected) + stepBy;
79589         const nextImage = sequence.images[nextIndex];
79590         if (!nextImage)
79591           return;
79592         context.map().centerEase(nextImage.loc);
79593         this.selectImage(context, nextImage.key, true);
79594       };
79595       const wrap2 = context.container().select(".photoviewer").selectAll(".vegbilder-wrapper").data([0]);
79596       const wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper vegbilder-wrapper").classed("hide", true);
79597       wrapEnter.append("div").attr("class", "photo-attribution fillD");
79598       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
79599       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
79600       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
79601       _loadViewerPromise3 = Promise.all([
79602         pannellum_photo_default.init(context, wrapEnter),
79603         plane_photo_default.init(context, wrapEnter)
79604       ]).then(([pannellumPhotoFrame, planePhotoFrame]) => {
79605         _pannellumFrame = pannellumPhotoFrame;
79606         _pannellumFrame.event.on("viewerChanged", () => dispatch9.call("viewerChanged"));
79607         _planeFrame = planePhotoFrame;
79608         _planeFrame.event.on("viewerChanged", () => dispatch9.call("viewerChanged"));
79609       });
79610       return _loadViewerPromise3;
79611     },
79612     selectImage: function(context, key, keepOrientation) {
79613       const d2 = this.cachedImage(key);
79614       this.updateUrlImage(key);
79615       const viewer = context.container().select(".photoviewer");
79616       if (!viewer.empty()) {
79617         viewer.datum(d2);
79618       }
79619       this.setStyles(context, null, true);
79620       if (!d2)
79621         return this;
79622       const wrap2 = context.container().select(".photoviewer .vegbilder-wrapper");
79623       const attribution = wrap2.selectAll(".photo-attribution").text("");
79624       if (d2.captured_at) {
79625         attribution.append("span").attr("class", "captured_at").text(localeTimestamp(d2.captured_at));
79626       }
79627       attribution.append("a").attr("target", "_blank").attr("href", "https://vegvesen.no").call(_t.append("vegbilder.publisher"));
79628       attribution.append("a").attr("target", "_blank").attr("href", "https://vegbilder.atlas.vegvesen.no/?year=".concat(d2.captured_at.getFullYear(), "&lat=").concat(d2.loc[1], "&lng=").concat(d2.loc[0], "&view=image&imageId=").concat(d2.key)).call(_t.append("vegbilder.view_on"));
79629       _currentFrame = d2.is_sphere ? _pannellumFrame : _planeFrame;
79630       _currentFrame.selectPhoto(d2, keepOrientation).showPhotoFrame(wrap2);
79631       return this;
79632     },
79633     showViewer: function(context) {
79634       const viewer = context.container().select(".photoviewer").classed("hide", false);
79635       const isHidden = viewer.selectAll(".photo-wrapper.vegbilder-wrapper.hide").size();
79636       if (isHidden) {
79637         viewer.selectAll(".photo-wrapper:not(.vegbilder-wrapper)").classed("hide", true);
79638         viewer.selectAll(".photo-wrapper.vegbilder-wrapper").classed("hide", false);
79639       }
79640       return this;
79641     },
79642     hideViewer: function(context) {
79643       this.updateUrlImage(null);
79644       const viewer = context.container().select(".photoviewer");
79645       if (!viewer.empty())
79646         viewer.datum(null);
79647       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
79648       context.container().selectAll(".viewfield-group, .sequence").classed("currentView", false);
79649       return this.setStyles(context, null, true);
79650     },
79651     // Updates the currently highlighted sequence and selected bubble.
79652     // Reset is only necessary when interacting with the viewport because
79653     // this implicitly changes the currently selected bubble/sequence
79654     setStyles: function(context, hovered, reset) {
79655       var _a2, _b;
79656       if (reset) {
79657         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
79658         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
79659       }
79660       const hoveredImageKey = hovered == null ? void 0 : hovered.key;
79661       const hoveredSequence = this.getSequenceForImage(hovered);
79662       const hoveredSequenceKey = hoveredSequence == null ? void 0 : hoveredSequence.key;
79663       const hoveredImageKeys = (_a2 = hoveredSequence == null ? void 0 : hoveredSequence.images.map((d2) => d2.key)) != null ? _a2 : [];
79664       const viewer = context.container().select(".photoviewer");
79665       const selected = viewer.empty() ? void 0 : viewer.datum();
79666       const selectedImageKey = selected == null ? void 0 : selected.key;
79667       const selectedSequence = this.getSequenceForImage(selected);
79668       const selectedSequenceKey = selectedSequence == null ? void 0 : selectedSequence.key;
79669       const selectedImageKeys = (_b = selectedSequence == null ? void 0 : selectedSequence.images.map((d2) => d2.key)) != null ? _b : [];
79670       const highlightedImageKeys = utilArrayUnion(hoveredImageKeys, selectedImageKeys);
79671       context.container().selectAll(".layer-vegbilder .viewfield-group").classed("highlighted", (d2) => highlightedImageKeys.indexOf(d2.key) !== -1).classed("hovered", (d2) => d2.key === hoveredImageKey).classed("currentView", (d2) => d2.key === selectedImageKey);
79672       context.container().selectAll(".layer-vegbilder .sequence").classed("highlighted", (d2) => d2.key === hoveredSequenceKey).classed("currentView", (d2) => d2.key === selectedSequenceKey);
79673       context.container().selectAll(".layer-vegbilder .viewfield-group .viewfield").attr("d", viewfieldPath);
79674       function viewfieldPath() {
79675         const d2 = this.parentNode.__data__;
79676         if (d2.is_sphere && d2.key !== selectedImageKey) {
79677           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
79678         } else {
79679           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
79680         }
79681       }
79682       return this;
79683     },
79684     updateUrlImage: function(key) {
79685       if (!window.mocha) {
79686         const hash = utilStringQs(window.location.hash);
79687         if (key) {
79688           hash.photo = "vegbilder/" + key;
79689         } else {
79690           delete hash.photo;
79691         }
79692         window.location.replace("#" + utilQsString(hash, true));
79693       }
79694     },
79695     validHere: function(extent) {
79696       const bbox2 = Object.values(extent.bbox());
79697       return iso1A2Codes(bbox2).includes("NO");
79698     },
79699     cache: function() {
79700       return _vegbilderCache;
79701     }
79702   };
79703
79704   // node_modules/osm-auth/src/osm-auth.mjs
79705   function osmAuth(o2) {
79706     var oauth2 = {};
79707     var _store = null;
79708     try {
79709       _store = window.localStorage;
79710     } catch (e3) {
79711       var _mock = /* @__PURE__ */ new Map();
79712       _store = {
79713         isMocked: true,
79714         hasItem: (k2) => _mock.has(k2),
79715         getItem: (k2) => _mock.get(k2),
79716         setItem: (k2, v2) => _mock.set(k2, v2),
79717         removeItem: (k2) => _mock.delete(k2),
79718         clear: () => _mock.clear()
79719       };
79720     }
79721     function token(k2, v2) {
79722       if (arguments.length === 1)
79723         return _store.getItem(o2.url + k2);
79724       else if (arguments.length === 2)
79725         return _store.setItem(o2.url + k2, v2);
79726     }
79727     oauth2.authenticated = function() {
79728       return !!token("oauth2_access_token");
79729     };
79730     oauth2.logout = function() {
79731       token("oauth2_access_token", "");
79732       token("oauth_token", "");
79733       token("oauth_token_secret", "");
79734       token("oauth_request_token_secret", "");
79735       return oauth2;
79736     };
79737     oauth2.authenticate = function(callback) {
79738       if (oauth2.authenticated()) {
79739         callback(null, oauth2);
79740         return;
79741       }
79742       oauth2.logout();
79743       _preopenPopup(function(error, popup) {
79744         if (error) {
79745           callback(error);
79746         } else {
79747           _generatePkceChallenge(function(pkce) {
79748             _authenticate(pkce, popup, callback);
79749           });
79750         }
79751       });
79752     };
79753     oauth2.authenticateAsync = function() {
79754       if (oauth2.authenticated()) {
79755         return Promise.resolve(oauth2);
79756       }
79757       oauth2.logout();
79758       return new Promise((resolve, reject) => {
79759         var errback = (err, result) => {
79760           if (err) {
79761             reject(err);
79762           } else {
79763             resolve(result);
79764           }
79765         };
79766         _preopenPopup((error, popup) => {
79767           if (error) {
79768             errback(error);
79769           } else {
79770             _generatePkceChallenge((pkce) => _authenticate(pkce, popup, errback));
79771           }
79772         });
79773       });
79774     };
79775     function _preopenPopup(callback) {
79776       if (o2.singlepage) {
79777         callback(null, void 0);
79778         return;
79779       }
79780       var w2 = 550;
79781       var h2 = 610;
79782       var settings = [
79783         ["width", w2],
79784         ["height", h2],
79785         ["left", window.screen.width / 2 - w2 / 2],
79786         ["top", window.screen.height / 2 - h2 / 2]
79787       ].map(function(x2) {
79788         return x2.join("=");
79789       }).join(",");
79790       var popup = window.open("about:blank", "oauth_window", settings);
79791       if (popup) {
79792         callback(null, popup);
79793       } else {
79794         var error = new Error("Popup was blocked");
79795         error.status = "popup-blocked";
79796         callback(error);
79797       }
79798     }
79799     function _authenticate(pkce, popup, callback) {
79800       var state = generateState();
79801       var url = o2.url + "/oauth2/authorize?" + utilQsString2({
79802         client_id: o2.client_id,
79803         redirect_uri: o2.redirect_uri,
79804         response_type: "code",
79805         scope: o2.scope,
79806         state,
79807         code_challenge: pkce.code_challenge,
79808         code_challenge_method: pkce.code_challenge_method
79809       });
79810       if (o2.singlepage) {
79811         if (_store.isMocked) {
79812           var error = new Error("localStorage unavailable, but required in singlepage mode");
79813           error.status = "pkce-localstorage-unavailable";
79814           callback(error);
79815           return;
79816         }
79817         var params = utilStringQs2(window.location.search.slice(1));
79818         if (params.code) {
79819           oauth2.bootstrapToken(params.code, callback);
79820         } else {
79821           token("oauth2_state", state);
79822           token("oauth2_pkce_code_verifier", pkce.code_verifier);
79823           window.location = url;
79824         }
79825       } else {
79826         oauth2.popupWindow = popup;
79827         popup.location = url;
79828       }
79829       window.authComplete = function(url2) {
79830         var params2 = utilStringQs2(url2.split("?")[1]);
79831         if (params2.state !== state) {
79832           error = new Error("Invalid state");
79833           error.status = "invalid-state";
79834           callback(error);
79835           return;
79836         }
79837         _getAccessToken(params2.code, pkce.code_verifier, accessTokenDone);
79838         delete window.authComplete;
79839       };
79840       function accessTokenDone(err, xhr) {
79841         o2.done();
79842         if (err) {
79843           callback(err);
79844           return;
79845         }
79846         var access_token = JSON.parse(xhr.response);
79847         token("oauth2_access_token", access_token.access_token);
79848         callback(null, oauth2);
79849       }
79850     }
79851     function _getAccessToken(auth_code, code_verifier, accessTokenDone) {
79852       var url = o2.url + "/oauth2/token?" + utilQsString2({
79853         client_id: o2.client_id,
79854         redirect_uri: o2.redirect_uri,
79855         grant_type: "authorization_code",
79856         code: auth_code,
79857         code_verifier
79858       });
79859       oauth2.rawxhr("POST", url, null, null, null, accessTokenDone);
79860       o2.loading();
79861     }
79862     oauth2.bringPopupWindowToFront = function() {
79863       var broughtPopupToFront = false;
79864       try {
79865         if (oauth2.popupWindow && !oauth2.popupWindow.closed) {
79866           oauth2.popupWindow.focus();
79867           broughtPopupToFront = true;
79868         }
79869       } catch (err) {
79870       }
79871       return broughtPopupToFront;
79872     };
79873     oauth2.bootstrapToken = function(auth_code, callback) {
79874       var state = token("oauth2_state");
79875       token("oauth2_state", "");
79876       var params = utilStringQs2(window.location.search.slice(1));
79877       if (params.state !== state) {
79878         var error = new Error("Invalid state");
79879         error.status = "invalid-state";
79880         callback(error);
79881         return;
79882       }
79883       var code_verifier = token("oauth2_pkce_code_verifier");
79884       token("oauth2_pkce_code_verifier", "");
79885       _getAccessToken(auth_code, code_verifier, accessTokenDone);
79886       function accessTokenDone(err, xhr) {
79887         o2.done();
79888         if (err) {
79889           callback(err);
79890           return;
79891         }
79892         var access_token = JSON.parse(xhr.response);
79893         token("oauth2_access_token", access_token.access_token);
79894         callback(null, oauth2);
79895       }
79896     };
79897     oauth2.fetch = function(resource, options2) {
79898       if (oauth2.authenticated()) {
79899         return _doFetch();
79900       } else {
79901         if (o2.auto) {
79902           return oauth2.authenticateAsync().then(_doFetch);
79903         } else {
79904           return Promise.reject(new Error("not authenticated"));
79905         }
79906       }
79907       function _doFetch() {
79908         options2 = options2 || {};
79909         if (!options2.headers) {
79910           options2.headers = { "Content-Type": "application/x-www-form-urlencoded" };
79911         }
79912         options2.headers.Authorization = "Bearer " + token("oauth2_access_token");
79913         return fetch(resource, options2);
79914       }
79915     };
79916     oauth2.xhr = function(options2, callback) {
79917       if (oauth2.authenticated()) {
79918         return _doXHR();
79919       } else {
79920         if (o2.auto) {
79921           oauth2.authenticate(_doXHR);
79922           return;
79923         } else {
79924           callback("not authenticated", null);
79925           return;
79926         }
79927       }
79928       function _doXHR() {
79929         var url = options2.prefix !== false ? o2.apiUrl + options2.path : options2.path;
79930         return oauth2.rawxhr(
79931           options2.method,
79932           url,
79933           token("oauth2_access_token"),
79934           options2.content,
79935           options2.headers,
79936           done
79937         );
79938       }
79939       function done(err, xhr) {
79940         if (err) {
79941           callback(err);
79942         } else if (xhr.responseXML) {
79943           callback(err, xhr.responseXML);
79944         } else {
79945           callback(err, xhr.response);
79946         }
79947       }
79948     };
79949     oauth2.rawxhr = function(method, url, access_token, data, headers, callback) {
79950       headers = headers || { "Content-Type": "application/x-www-form-urlencoded" };
79951       if (access_token) {
79952         headers.Authorization = "Bearer " + access_token;
79953       }
79954       var xhr = new XMLHttpRequest();
79955       xhr.onreadystatechange = function() {
79956         if (4 === xhr.readyState && 0 !== xhr.status) {
79957           if (/^20\d$/.test(xhr.status)) {
79958             callback(null, xhr);
79959           } else {
79960             callback(xhr, null);
79961           }
79962         }
79963       };
79964       xhr.onerror = function(e3) {
79965         callback(e3, null);
79966       };
79967       xhr.open(method, url, true);
79968       for (var h2 in headers)
79969         xhr.setRequestHeader(h2, headers[h2]);
79970       xhr.send(data);
79971       return xhr;
79972     };
79973     oauth2.preauth = function(val) {
79974       if (val && val.access_token) {
79975         token("oauth2_access_token", val.access_token);
79976       }
79977       return oauth2;
79978     };
79979     oauth2.options = function(val) {
79980       if (!arguments.length)
79981         return o2;
79982       o2 = val;
79983       o2.apiUrl = o2.apiUrl || "https://api.openstreetmap.org";
79984       o2.url = o2.url || "https://www.openstreetmap.org";
79985       o2.auto = o2.auto || false;
79986       o2.singlepage = o2.singlepage || false;
79987       o2.loading = o2.loading || function() {
79988       };
79989       o2.done = o2.done || function() {
79990       };
79991       return oauth2.preauth(o2);
79992     };
79993     oauth2.options(o2);
79994     return oauth2;
79995   }
79996   function utilQsString2(obj) {
79997     return Object.keys(obj).filter(function(key) {
79998       return obj[key] !== void 0;
79999     }).sort().map(function(key) {
80000       return encodeURIComponent(key) + "=" + encodeURIComponent(obj[key]);
80001     }).join("&");
80002   }
80003   function utilStringQs2(str) {
80004     var i3 = 0;
80005     while (i3 < str.length && (str[i3] === "?" || str[i3] === "#"))
80006       i3++;
80007     str = str.slice(i3);
80008     return str.split("&").reduce(function(obj, pair3) {
80009       var parts = pair3.split("=");
80010       if (parts.length === 2) {
80011         obj[parts[0]] = decodeURIComponent(parts[1]);
80012       }
80013       return obj;
80014     }, {});
80015   }
80016   function supportsWebCryptoAPI() {
80017     return window && window.crypto && window.crypto.getRandomValues && window.crypto.subtle && window.crypto.subtle.digest;
80018   }
80019   function _generatePkceChallenge(callback) {
80020     var code_verifier;
80021     if (supportsWebCryptoAPI()) {
80022       var random = window.crypto.getRandomValues(new Uint8Array(32));
80023       code_verifier = base64(random.buffer);
80024       var verifier = Uint8Array.from(Array.from(code_verifier).map(function(char) {
80025         return char.charCodeAt(0);
80026       }));
80027       window.crypto.subtle.digest("SHA-256", verifier).then(function(hash) {
80028         var code_challenge = base64(hash);
80029         callback({
80030           code_challenge,
80031           code_verifier,
80032           code_challenge_method: "S256"
80033         });
80034       });
80035     } else {
80036       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
80037       code_verifier = "";
80038       for (var i3 = 0; i3 < 64; i3++) {
80039         code_verifier += chars[Math.floor(Math.random() * chars.length)];
80040       }
80041       callback({
80042         code_verifier,
80043         code_challenge: code_verifier,
80044         code_challenge_method: "plain"
80045       });
80046     }
80047   }
80048   function generateState() {
80049     var state;
80050     if (supportsWebCryptoAPI()) {
80051       var random = window.crypto.getRandomValues(new Uint8Array(32));
80052       state = base64(random.buffer);
80053     } else {
80054       var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
80055       state = "";
80056       for (var i3 = 0; i3 < 64; i3++) {
80057         state += chars[Math.floor(Math.random() * chars.length)];
80058       }
80059     }
80060     return state;
80061   }
80062   function base64(buffer) {
80063     return btoa(String.fromCharCode.apply(null, new Uint8Array(buffer))).replace(/\//g, "_").replace(/\+/g, "-").replace(/[=]/g, "");
80064   }
80065
80066   // modules/services/osm.js
80067   var import_rbush10 = __toESM(require_rbush_min());
80068   var tiler6 = utilTiler();
80069   var dispatch10 = dispatch_default("apiStatusChange", "authLoading", "authDone", "change", "loading", "loaded", "loadedNotes");
80070   var urlroot = osmApiConnections[0].url;
80071   var apiUrlroot = osmApiConnections[0].apiUrl || urlroot;
80072   var redirectPath = window.location.origin + window.location.pathname;
80073   var oauth = osmAuth({
80074     url: urlroot,
80075     apiUrl: apiUrlroot,
80076     client_id: osmApiConnections[0].client_id,
80077     client_secret: osmApiConnections[0].client_secret,
80078     scope: "read_prefs write_prefs write_api read_gpx write_notes",
80079     redirect_uri: redirectPath + "land.html",
80080     loading: authLoading,
80081     done: authDone
80082   });
80083   var _apiConnections = osmApiConnections;
80084   var _imageryBlocklists = [/.*\.google(apis)?\..*\/(vt|kh)[\?\/].*([xyz]=.*){3}.*/];
80085   var _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new import_rbush10.default() };
80086   var _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new import_rbush10.default() };
80087   var _userCache = { toLoad: {}, user: {} };
80088   var _cachedApiStatus;
80089   var _changeset = {};
80090   var _deferred = /* @__PURE__ */ new Set();
80091   var _connectionID = 1;
80092   var _tileZoom4 = 16;
80093   var _noteZoom = 12;
80094   var _rateLimitError;
80095   var _userChangesets;
80096   var _userDetails;
80097   var _off;
80098   var _maxWayNodes = 2e3;
80099   function authLoading() {
80100     dispatch10.call("authLoading");
80101   }
80102   function authDone() {
80103     dispatch10.call("authDone");
80104   }
80105   function abortRequest5(controllerOrXHR) {
80106     if (controllerOrXHR) {
80107       controllerOrXHR.abort();
80108     }
80109   }
80110   function hasInflightRequests(cache) {
80111     return Object.keys(cache.inflight).length;
80112   }
80113   function abortUnwantedRequests4(cache, visibleTiles) {
80114     Object.keys(cache.inflight).forEach(function(k2) {
80115       if (cache.toLoad[k2])
80116         return;
80117       if (visibleTiles.find(function(tile) {
80118         return k2 === tile.id;
80119       }))
80120         return;
80121       abortRequest5(cache.inflight[k2]);
80122       delete cache.inflight[k2];
80123     });
80124   }
80125   function getLoc(attrs) {
80126     var lon = attrs.lon && attrs.lon.value;
80127     var lat = attrs.lat && attrs.lat.value;
80128     return [Number(lon), Number(lat)];
80129   }
80130   function getNodes(obj) {
80131     var elems = obj.getElementsByTagName("nd");
80132     var nodes = new Array(elems.length);
80133     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80134       nodes[i3] = "n" + elems[i3].attributes.ref.value;
80135     }
80136     return nodes;
80137   }
80138   function getNodesJSON(obj) {
80139     var elems = obj.nodes;
80140     var nodes = new Array(elems.length);
80141     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80142       nodes[i3] = "n" + elems[i3];
80143     }
80144     return nodes;
80145   }
80146   function getTags(obj) {
80147     var elems = obj.getElementsByTagName("tag");
80148     var tags = {};
80149     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80150       var attrs = elems[i3].attributes;
80151       tags[attrs.k.value] = attrs.v.value;
80152     }
80153     return tags;
80154   }
80155   function getMembers(obj) {
80156     var elems = obj.getElementsByTagName("member");
80157     var members = new Array(elems.length);
80158     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80159       var attrs = elems[i3].attributes;
80160       members[i3] = {
80161         id: attrs.type.value[0] + attrs.ref.value,
80162         type: attrs.type.value,
80163         role: attrs.role.value
80164       };
80165     }
80166     return members;
80167   }
80168   function getMembersJSON(obj) {
80169     var elems = obj.members;
80170     var members = new Array(elems.length);
80171     for (var i3 = 0, l2 = elems.length; i3 < l2; i3++) {
80172       var attrs = elems[i3];
80173       members[i3] = {
80174         id: attrs.type[0] + attrs.ref,
80175         type: attrs.type,
80176         role: attrs.role
80177       };
80178     }
80179     return members;
80180   }
80181   function getVisible(attrs) {
80182     return !attrs.visible || attrs.visible.value !== "false";
80183   }
80184   function parseComments(comments) {
80185     var parsedComments = [];
80186     for (var i3 = 0; i3 < comments.length; i3++) {
80187       var comment = comments[i3];
80188       if (comment.nodeName === "comment") {
80189         var childNodes = comment.childNodes;
80190         var parsedComment = {};
80191         for (var j2 = 0; j2 < childNodes.length; j2++) {
80192           var node = childNodes[j2];
80193           var nodeName = node.nodeName;
80194           if (nodeName === "#text")
80195             continue;
80196           parsedComment[nodeName] = node.textContent;
80197           if (nodeName === "uid") {
80198             var uid = node.textContent;
80199             if (uid && !_userCache.user[uid]) {
80200               _userCache.toLoad[uid] = true;
80201             }
80202           }
80203         }
80204         if (parsedComment) {
80205           parsedComments.push(parsedComment);
80206         }
80207       }
80208     }
80209     return parsedComments;
80210   }
80211   function encodeNoteRtree(note) {
80212     return {
80213       minX: note.loc[0],
80214       minY: note.loc[1],
80215       maxX: note.loc[0],
80216       maxY: note.loc[1],
80217       data: note
80218     };
80219   }
80220   var jsonparsers = {
80221     node: function nodeData(obj, uid) {
80222       return new osmNode({
80223         id: uid,
80224         visible: typeof obj.visible === "boolean" ? obj.visible : true,
80225         version: obj.version && obj.version.toString(),
80226         changeset: obj.changeset && obj.changeset.toString(),
80227         timestamp: obj.timestamp,
80228         user: obj.user,
80229         uid: obj.uid && obj.uid.toString(),
80230         loc: [Number(obj.lon), Number(obj.lat)],
80231         tags: obj.tags
80232       });
80233     },
80234     way: function wayData(obj, uid) {
80235       return new osmWay({
80236         id: uid,
80237         visible: typeof obj.visible === "boolean" ? obj.visible : true,
80238         version: obj.version && obj.version.toString(),
80239         changeset: obj.changeset && obj.changeset.toString(),
80240         timestamp: obj.timestamp,
80241         user: obj.user,
80242         uid: obj.uid && obj.uid.toString(),
80243         tags: obj.tags,
80244         nodes: getNodesJSON(obj)
80245       });
80246     },
80247     relation: function relationData(obj, uid) {
80248       return new osmRelation({
80249         id: uid,
80250         visible: typeof obj.visible === "boolean" ? obj.visible : true,
80251         version: obj.version && obj.version.toString(),
80252         changeset: obj.changeset && obj.changeset.toString(),
80253         timestamp: obj.timestamp,
80254         user: obj.user,
80255         uid: obj.uid && obj.uid.toString(),
80256         tags: obj.tags,
80257         members: getMembersJSON(obj)
80258       });
80259     },
80260     user: function parseUser(obj, uid) {
80261       return {
80262         id: uid,
80263         display_name: obj.display_name,
80264         account_created: obj.account_created,
80265         image_url: obj.img && obj.img.href,
80266         changesets_count: obj.changesets && obj.changesets.count && obj.changesets.count.toString() || "0",
80267         active_blocks: obj.blocks && obj.blocks.received && obj.blocks.received.active && obj.blocks.received.active.toString() || "0"
80268       };
80269     }
80270   };
80271   function parseJSON(payload, callback, options2) {
80272     options2 = Object.assign({ skipSeen: true }, options2);
80273     if (!payload) {
80274       return callback({ message: "No JSON", status: -1 });
80275     }
80276     var json = payload;
80277     if (typeof json !== "object")
80278       json = JSON.parse(payload);
80279     if (!json.elements)
80280       return callback({ message: "No JSON", status: -1 });
80281     var children2 = json.elements;
80282     var handle = window.requestIdleCallback(function() {
80283       _deferred.delete(handle);
80284       var results = [];
80285       var result;
80286       for (var i3 = 0; i3 < children2.length; i3++) {
80287         result = parseChild(children2[i3]);
80288         if (result)
80289           results.push(result);
80290       }
80291       callback(null, results);
80292     });
80293     _deferred.add(handle);
80294     function parseChild(child) {
80295       var parser3 = jsonparsers[child.type];
80296       if (!parser3)
80297         return null;
80298       var uid;
80299       uid = osmEntity.id.fromOSM(child.type, child.id);
80300       if (options2.skipSeen) {
80301         if (_tileCache.seen[uid])
80302           return null;
80303         _tileCache.seen[uid] = true;
80304       }
80305       return parser3(child, uid);
80306     }
80307   }
80308   function parseUserJSON(payload, callback, options2) {
80309     options2 = Object.assign({ skipSeen: true }, options2);
80310     if (!payload) {
80311       return callback({ message: "No JSON", status: -1 });
80312     }
80313     var json = payload;
80314     if (typeof json !== "object")
80315       json = JSON.parse(payload);
80316     if (!json.users && !json.user)
80317       return callback({ message: "No JSON", status: -1 });
80318     var objs = json.users || [json];
80319     var handle = window.requestIdleCallback(function() {
80320       _deferred.delete(handle);
80321       var results = [];
80322       var result;
80323       for (var i3 = 0; i3 < objs.length; i3++) {
80324         result = parseObj(objs[i3]);
80325         if (result)
80326           results.push(result);
80327       }
80328       callback(null, results);
80329     });
80330     _deferred.add(handle);
80331     function parseObj(obj) {
80332       var uid = obj.user.id && obj.user.id.toString();
80333       if (options2.skipSeen && _userCache.user[uid]) {
80334         delete _userCache.toLoad[uid];
80335         return null;
80336       }
80337       var user = jsonparsers.user(obj.user, uid);
80338       _userCache.user[uid] = user;
80339       delete _userCache.toLoad[uid];
80340       return user;
80341     }
80342   }
80343   var parsers = {
80344     node: function nodeData2(obj, uid) {
80345       var attrs = obj.attributes;
80346       return new osmNode({
80347         id: uid,
80348         visible: getVisible(attrs),
80349         version: attrs.version.value,
80350         changeset: attrs.changeset && attrs.changeset.value,
80351         timestamp: attrs.timestamp && attrs.timestamp.value,
80352         user: attrs.user && attrs.user.value,
80353         uid: attrs.uid && attrs.uid.value,
80354         loc: getLoc(attrs),
80355         tags: getTags(obj)
80356       });
80357     },
80358     way: function wayData2(obj, uid) {
80359       var attrs = obj.attributes;
80360       return new osmWay({
80361         id: uid,
80362         visible: getVisible(attrs),
80363         version: attrs.version.value,
80364         changeset: attrs.changeset && attrs.changeset.value,
80365         timestamp: attrs.timestamp && attrs.timestamp.value,
80366         user: attrs.user && attrs.user.value,
80367         uid: attrs.uid && attrs.uid.value,
80368         tags: getTags(obj),
80369         nodes: getNodes(obj)
80370       });
80371     },
80372     relation: function relationData2(obj, uid) {
80373       var attrs = obj.attributes;
80374       return new osmRelation({
80375         id: uid,
80376         visible: getVisible(attrs),
80377         version: attrs.version.value,
80378         changeset: attrs.changeset && attrs.changeset.value,
80379         timestamp: attrs.timestamp && attrs.timestamp.value,
80380         user: attrs.user && attrs.user.value,
80381         uid: attrs.uid && attrs.uid.value,
80382         tags: getTags(obj),
80383         members: getMembers(obj)
80384       });
80385     },
80386     note: function parseNote(obj, uid) {
80387       var attrs = obj.attributes;
80388       var childNodes = obj.childNodes;
80389       var props = {};
80390       props.id = uid;
80391       props.loc = getLoc(attrs);
80392       if (!_noteCache.note[uid]) {
80393         let coincident = false;
80394         const epsilon3 = 1e-5;
80395         do {
80396           if (coincident) {
80397             props.loc = geoVecAdd(props.loc, [epsilon3, epsilon3]);
80398           }
80399           const bbox2 = geoExtent(props.loc).bbox();
80400           coincident = _noteCache.rtree.search(bbox2).length;
80401         } while (coincident);
80402       } else {
80403         props.loc = _noteCache.note[uid].loc;
80404       }
80405       for (var i3 = 0; i3 < childNodes.length; i3++) {
80406         var node = childNodes[i3];
80407         var nodeName = node.nodeName;
80408         if (nodeName === "#text")
80409           continue;
80410         if (nodeName === "comments") {
80411           props[nodeName] = parseComments(node.childNodes);
80412         } else {
80413           props[nodeName] = node.textContent;
80414         }
80415       }
80416       var note = new osmNote(props);
80417       var item = encodeNoteRtree(note);
80418       _noteCache.note[note.id] = note;
80419       updateRtree4(item, true);
80420       return note;
80421     },
80422     user: function parseUser2(obj, uid) {
80423       var attrs = obj.attributes;
80424       var user = {
80425         id: uid,
80426         display_name: attrs.display_name && attrs.display_name.value,
80427         account_created: attrs.account_created && attrs.account_created.value,
80428         changesets_count: "0",
80429         active_blocks: "0"
80430       };
80431       var img = obj.getElementsByTagName("img");
80432       if (img && img[0] && img[0].getAttribute("href")) {
80433         user.image_url = img[0].getAttribute("href");
80434       }
80435       var changesets = obj.getElementsByTagName("changesets");
80436       if (changesets && changesets[0] && changesets[0].getAttribute("count")) {
80437         user.changesets_count = changesets[0].getAttribute("count");
80438       }
80439       var blocks = obj.getElementsByTagName("blocks");
80440       if (blocks && blocks[0]) {
80441         var received = blocks[0].getElementsByTagName("received");
80442         if (received && received[0] && received[0].getAttribute("active")) {
80443           user.active_blocks = received[0].getAttribute("active");
80444         }
80445       }
80446       _userCache.user[uid] = user;
80447       delete _userCache.toLoad[uid];
80448       return user;
80449     }
80450   };
80451   function parseXML(xml, callback, options2) {
80452     options2 = Object.assign({ skipSeen: true }, options2);
80453     if (!xml || !xml.childNodes) {
80454       return callback({ message: "No XML", status: -1 });
80455     }
80456     var root3 = xml.childNodes[0];
80457     var children2 = root3.childNodes;
80458     var handle = window.requestIdleCallback(function() {
80459       _deferred.delete(handle);
80460       var results = [];
80461       var result;
80462       for (var i3 = 0; i3 < children2.length; i3++) {
80463         result = parseChild(children2[i3]);
80464         if (result)
80465           results.push(result);
80466       }
80467       callback(null, results);
80468     });
80469     _deferred.add(handle);
80470     function parseChild(child) {
80471       var parser3 = parsers[child.nodeName];
80472       if (!parser3)
80473         return null;
80474       var uid;
80475       if (child.nodeName === "user") {
80476         uid = child.attributes.id.value;
80477         if (options2.skipSeen && _userCache.user[uid]) {
80478           delete _userCache.toLoad[uid];
80479           return null;
80480         }
80481       } else if (child.nodeName === "note") {
80482         uid = child.getElementsByTagName("id")[0].textContent;
80483       } else {
80484         uid = osmEntity.id.fromOSM(child.nodeName, child.attributes.id.value);
80485         if (options2.skipSeen) {
80486           if (_tileCache.seen[uid])
80487             return null;
80488           _tileCache.seen[uid] = true;
80489         }
80490       }
80491       return parser3(child, uid);
80492     }
80493   }
80494   function updateRtree4(item, replace) {
80495     _noteCache.rtree.remove(item, function isEql(a2, b2) {
80496       return a2.data.id === b2.data.id;
80497     });
80498     if (replace) {
80499       _noteCache.rtree.insert(item);
80500     }
80501   }
80502   function wrapcb(thisArg, callback, cid) {
80503     return function(err, result) {
80504       if (err) {
80505         if (err.status === 400 || err.status === 401 || err.status === 403) {
80506           thisArg.logout();
80507         }
80508         return callback.call(thisArg, err);
80509       } else if (thisArg.getConnectionId() !== cid) {
80510         return callback.call(thisArg, { message: "Connection Switched", status: -1 });
80511       } else {
80512         return callback.call(thisArg, err, result);
80513       }
80514     };
80515   }
80516   var osm_default = {
80517     init: function() {
80518       utilRebind(this, dispatch10, "on");
80519     },
80520     reset: function() {
80521       Array.from(_deferred).forEach(function(handle) {
80522         window.cancelIdleCallback(handle);
80523         _deferred.delete(handle);
80524       });
80525       _connectionID++;
80526       _userChangesets = void 0;
80527       _userDetails = void 0;
80528       _rateLimitError = void 0;
80529       Object.values(_tileCache.inflight).forEach(abortRequest5);
80530       Object.values(_noteCache.inflight).forEach(abortRequest5);
80531       Object.values(_noteCache.inflightPost).forEach(abortRequest5);
80532       if (_changeset.inflight)
80533         abortRequest5(_changeset.inflight);
80534       _tileCache = { toLoad: {}, loaded: {}, inflight: {}, seen: {}, rtree: new import_rbush10.default() };
80535       _noteCache = { toLoad: {}, loaded: {}, inflight: {}, inflightPost: {}, note: {}, closed: {}, rtree: new import_rbush10.default() };
80536       _userCache = { toLoad: {}, user: {} };
80537       _cachedApiStatus = void 0;
80538       _changeset = {};
80539       return this;
80540     },
80541     getConnectionId: function() {
80542       return _connectionID;
80543     },
80544     getUrlRoot: function() {
80545       return urlroot;
80546     },
80547     getApiUrlRoot: function() {
80548       return apiUrlroot;
80549     },
80550     changesetURL: function(changesetID) {
80551       return urlroot + "/changeset/" + changesetID;
80552     },
80553     changesetsURL: function(center, zoom) {
80554       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
80555       return urlroot + "/history#map=" + Math.floor(zoom) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
80556     },
80557     entityURL: function(entity) {
80558       return urlroot + "/" + entity.type + "/" + entity.osmId();
80559     },
80560     historyURL: function(entity) {
80561       return urlroot + "/" + entity.type + "/" + entity.osmId() + "/history";
80562     },
80563     userURL: function(username) {
80564       return urlroot + "/user/" + encodeURIComponent(username);
80565     },
80566     noteURL: function(note) {
80567       return urlroot + "/note/" + note.id;
80568     },
80569     noteReportURL: function(note) {
80570       return urlroot + "/reports/new?reportable_type=Note&reportable_id=" + note.id;
80571     },
80572     // Generic method to load data from the OSM API
80573     // Can handle either auth or unauth calls.
80574     loadFromAPI: function(path, callback, options2) {
80575       options2 = Object.assign({ skipSeen: true }, options2);
80576       var that = this;
80577       var cid = _connectionID;
80578       function done(err, payload) {
80579         if (that.getConnectionId() !== cid) {
80580           if (callback)
80581             callback({ message: "Connection Switched", status: -1 });
80582           return;
80583         }
80584         var isAuthenticated = that.authenticated();
80585         if (isAuthenticated && err && err.status && (err.status === 400 || err.status === 401 || err.status === 403)) {
80586           that.logout();
80587           that.loadFromAPI(path, callback, options2);
80588         } else {
80589           if (!isAuthenticated && !_rateLimitError && err && err.status && (err.status === 509 || err.status === 429)) {
80590             _rateLimitError = err;
80591             dispatch10.call("change");
80592             that.reloadApiStatus();
80593           } else if (err && _cachedApiStatus === "online" || !err && _cachedApiStatus !== "online") {
80594             that.reloadApiStatus();
80595           }
80596           if (callback) {
80597             if (err) {
80598               return callback(err);
80599             } else {
80600               if (path.indexOf(".json") !== -1) {
80601                 return parseJSON(payload, callback, options2);
80602               } else {
80603                 return parseXML(payload, callback, options2);
80604               }
80605             }
80606           }
80607         }
80608       }
80609       if (this.authenticated()) {
80610         return oauth.xhr({
80611           method: "GET",
80612           path
80613         }, done);
80614       } else {
80615         var url = apiUrlroot + path;
80616         var controller = new AbortController();
80617         var fn;
80618         if (path.indexOf(".json") !== -1) {
80619           fn = json_default;
80620         } else {
80621           fn = xml_default;
80622         }
80623         fn(url, { signal: controller.signal }).then(function(data) {
80624           done(null, data);
80625         }).catch(function(err) {
80626           if (err.name === "AbortError")
80627             return;
80628           var match = err.message.match(/^\d{3}/);
80629           if (match) {
80630             done({ status: +match[0], statusText: err.message });
80631           } else {
80632             done(err.message);
80633           }
80634         });
80635         return controller;
80636       }
80637     },
80638     // Load a single entity by id (ways and relations use the `/full` call to include
80639     // nodes and members). Parent relations are not included, see `loadEntityRelations`.
80640     // GET /api/0.6/node/#id
80641     // GET /api/0.6/[way|relation]/#id/full
80642     loadEntity: function(id2, callback) {
80643       var type2 = osmEntity.id.type(id2);
80644       var osmID = osmEntity.id.toOSM(id2);
80645       var options2 = { skipSeen: false };
80646       this.loadFromAPI(
80647         "/api/0.6/" + type2 + "/" + osmID + (type2 !== "node" ? "/full" : "") + ".json",
80648         function(err, entities) {
80649           if (callback)
80650             callback(err, { data: entities });
80651         },
80652         options2
80653       );
80654     },
80655     // Load a single note by id , XML format
80656     // GET /api/0.6/notes/#id
80657     loadEntityNote: function(id2, callback) {
80658       var options2 = { skipSeen: false };
80659       this.loadFromAPI(
80660         "/api/0.6/notes/" + id2,
80661         function(err, entities) {
80662           if (callback)
80663             callback(err, { data: entities });
80664         },
80665         options2
80666       );
80667     },
80668     // Load a single entity with a specific version
80669     // GET /api/0.6/[node|way|relation]/#id/#version
80670     loadEntityVersion: function(id2, version, callback) {
80671       var type2 = osmEntity.id.type(id2);
80672       var osmID = osmEntity.id.toOSM(id2);
80673       var options2 = { skipSeen: false };
80674       this.loadFromAPI(
80675         "/api/0.6/" + type2 + "/" + osmID + "/" + version + ".json",
80676         function(err, entities) {
80677           if (callback)
80678             callback(err, { data: entities });
80679         },
80680         options2
80681       );
80682     },
80683     // Load the relations of a single entity with the given.
80684     // GET /api/0.6/[node|way|relation]/#id/relations
80685     loadEntityRelations: function(id2, callback) {
80686       var type2 = osmEntity.id.type(id2);
80687       var osmID = osmEntity.id.toOSM(id2);
80688       var options2 = { skipSeen: false };
80689       this.loadFromAPI(
80690         "/api/0.6/" + type2 + "/" + osmID + "/relations.json",
80691         function(err, entities) {
80692           if (callback)
80693             callback(err, { data: entities });
80694         },
80695         options2
80696       );
80697     },
80698     // Load multiple entities in chunks
80699     // (note: callback may be called multiple times)
80700     // Unlike `loadEntity`, child nodes and members are not fetched
80701     // GET /api/0.6/[nodes|ways|relations]?#parameters
80702     loadMultiple: function(ids, callback) {
80703       var that = this;
80704       var groups = utilArrayGroupBy(utilArrayUniq(ids), osmEntity.id.type);
80705       Object.keys(groups).forEach(function(k2) {
80706         var type2 = k2 + "s";
80707         var osmIDs = groups[k2].map(function(id2) {
80708           return osmEntity.id.toOSM(id2);
80709         });
80710         var options2 = { skipSeen: false };
80711         utilArrayChunk(osmIDs, 150).forEach(function(arr) {
80712           that.loadFromAPI(
80713             "/api/0.6/" + type2 + ".json?" + type2 + "=" + arr.join(),
80714             function(err, entities) {
80715               if (callback)
80716                 callback(err, { data: entities });
80717             },
80718             options2
80719           );
80720         });
80721       });
80722     },
80723     // Create, upload, and close a changeset
80724     // PUT /api/0.6/changeset/create
80725     // POST /api/0.6/changeset/#id/upload
80726     // PUT /api/0.6/changeset/#id/close
80727     putChangeset: function(changeset, changes, callback) {
80728       var cid = _connectionID;
80729       if (_changeset.inflight) {
80730         return callback({ message: "Changeset already inflight", status: -2 }, changeset);
80731       } else if (_changeset.open) {
80732         return createdChangeset.call(this, null, _changeset.open);
80733       } else {
80734         var options2 = {
80735           method: "PUT",
80736           path: "/api/0.6/changeset/create",
80737           headers: { "Content-Type": "text/xml" },
80738           content: JXON.stringify(changeset.asJXON())
80739         };
80740         _changeset.inflight = oauth.xhr(
80741           options2,
80742           wrapcb(this, createdChangeset, cid)
80743         );
80744       }
80745       function createdChangeset(err, changesetID) {
80746         _changeset.inflight = null;
80747         if (err) {
80748           return callback(err, changeset);
80749         }
80750         _changeset.open = changesetID;
80751         changeset = changeset.update({ id: changesetID });
80752         var options3 = {
80753           method: "POST",
80754           path: "/api/0.6/changeset/" + changesetID + "/upload",
80755           headers: { "Content-Type": "text/xml" },
80756           content: JXON.stringify(changeset.osmChangeJXON(changes))
80757         };
80758         _changeset.inflight = oauth.xhr(
80759           options3,
80760           wrapcb(this, uploadedChangeset, cid)
80761         );
80762       }
80763       function uploadedChangeset(err) {
80764         _changeset.inflight = null;
80765         if (err)
80766           return callback(err, changeset);
80767         window.setTimeout(function() {
80768           callback(null, changeset);
80769         }, 2500);
80770         _changeset.open = null;
80771         if (this.getConnectionId() === cid) {
80772           oauth.xhr({
80773             method: "PUT",
80774             path: "/api/0.6/changeset/" + changeset.id + "/close",
80775             headers: { "Content-Type": "text/xml" }
80776           }, function() {
80777             return true;
80778           });
80779         }
80780       }
80781     },
80782     // Load multiple users in chunks
80783     // (note: callback may be called multiple times)
80784     // GET /api/0.6/users?users=#id1,#id2,...,#idn
80785     loadUsers: function(uids, callback) {
80786       var toLoad = [];
80787       var cached = [];
80788       utilArrayUniq(uids).forEach(function(uid) {
80789         if (_userCache.user[uid]) {
80790           delete _userCache.toLoad[uid];
80791           cached.push(_userCache.user[uid]);
80792         } else {
80793           toLoad.push(uid);
80794         }
80795       });
80796       if (cached.length || !this.authenticated()) {
80797         callback(void 0, cached);
80798         if (!this.authenticated())
80799           return;
80800       }
80801       utilArrayChunk(toLoad, 150).forEach((function(arr) {
80802         oauth.xhr({
80803           method: "GET",
80804           path: "/api/0.6/users.json?users=" + arr.join()
80805         }, wrapcb(this, done, _connectionID));
80806       }).bind(this));
80807       function done(err, payload) {
80808         if (err)
80809           return callback(err);
80810         var options2 = { skipSeen: true };
80811         return parseUserJSON(payload, function(err2, results) {
80812           if (err2)
80813             return callback(err2);
80814           return callback(void 0, results);
80815         }, options2);
80816       }
80817     },
80818     // Load a given user by id
80819     // GET /api/0.6/user/#id
80820     loadUser: function(uid, callback) {
80821       if (_userCache.user[uid] || !this.authenticated()) {
80822         delete _userCache.toLoad[uid];
80823         return callback(void 0, _userCache.user[uid]);
80824       }
80825       oauth.xhr({
80826         method: "GET",
80827         path: "/api/0.6/user/" + uid + ".json"
80828       }, wrapcb(this, done, _connectionID));
80829       function done(err, payload) {
80830         if (err)
80831           return callback(err);
80832         var options2 = { skipSeen: true };
80833         return parseUserJSON(payload, function(err2, results) {
80834           if (err2)
80835             return callback(err2);
80836           return callback(void 0, results[0]);
80837         }, options2);
80838       }
80839     },
80840     // Load the details of the logged-in user
80841     // GET /api/0.6/user/details
80842     userDetails: function(callback) {
80843       if (_userDetails) {
80844         return callback(void 0, _userDetails);
80845       }
80846       oauth.xhr({
80847         method: "GET",
80848         path: "/api/0.6/user/details.json"
80849       }, wrapcb(this, done, _connectionID));
80850       function done(err, payload) {
80851         if (err)
80852           return callback(err);
80853         var options2 = { skipSeen: false };
80854         return parseUserJSON(payload, function(err2, results) {
80855           if (err2)
80856             return callback(err2);
80857           _userDetails = results[0];
80858           return callback(void 0, _userDetails);
80859         }, options2);
80860       }
80861     },
80862     // Load previous changesets for the logged in user
80863     // GET /api/0.6/changesets?user=#id
80864     userChangesets: function(callback) {
80865       if (_userChangesets) {
80866         return callback(void 0, _userChangesets);
80867       }
80868       this.userDetails(
80869         wrapcb(this, gotDetails, _connectionID)
80870       );
80871       function gotDetails(err, user) {
80872         if (err) {
80873           return callback(err);
80874         }
80875         oauth.xhr({
80876           method: "GET",
80877           path: "/api/0.6/changesets?user=" + user.id
80878         }, wrapcb(this, done, _connectionID));
80879       }
80880       function done(err, xml) {
80881         if (err) {
80882           return callback(err);
80883         }
80884         _userChangesets = Array.prototype.map.call(
80885           xml.getElementsByTagName("changeset"),
80886           function(changeset) {
80887             return { tags: getTags(changeset) };
80888           }
80889         ).filter(function(changeset) {
80890           var comment = changeset.tags.comment;
80891           return comment && comment !== "";
80892         });
80893         return callback(void 0, _userChangesets);
80894       }
80895     },
80896     // Fetch the status of the OSM API
80897     // GET /api/capabilities
80898     status: function(callback) {
80899       var url = apiUrlroot + "/api/capabilities";
80900       var errback = wrapcb(this, done, _connectionID);
80901       xml_default(url).then(function(data) {
80902         errback(null, data);
80903       }).catch(function(err) {
80904         errback(err.message);
80905       });
80906       function done(err, xml) {
80907         if (err) {
80908           return callback(err, null);
80909         }
80910         var elements = xml.getElementsByTagName("blacklist");
80911         var regexes = [];
80912         for (var i3 = 0; i3 < elements.length; i3++) {
80913           var regexString = elements[i3].getAttribute("regex");
80914           if (regexString) {
80915             try {
80916               var regex = new RegExp(regexString);
80917               regexes.push(regex);
80918             } catch (e3) {
80919             }
80920           }
80921         }
80922         if (regexes.length) {
80923           _imageryBlocklists = regexes;
80924         }
80925         if (_rateLimitError) {
80926           return callback(_rateLimitError, "rateLimited");
80927         } else {
80928           var waynodes = xml.getElementsByTagName("waynodes");
80929           var maxWayNodes = waynodes.length && parseInt(waynodes[0].getAttribute("maximum"), 10);
80930           if (maxWayNodes && isFinite(maxWayNodes))
80931             _maxWayNodes = maxWayNodes;
80932           var apiStatus = xml.getElementsByTagName("status");
80933           var val = apiStatus[0].getAttribute("api");
80934           return callback(void 0, val);
80935         }
80936       }
80937     },
80938     // Calls `status` and dispatches an `apiStatusChange` event if the returned
80939     // status differs from the cached status.
80940     reloadApiStatus: function() {
80941       if (!this.throttledReloadApiStatus) {
80942         var that = this;
80943         this.throttledReloadApiStatus = throttle_default(function() {
80944           that.status(function(err, status) {
80945             if (status !== _cachedApiStatus) {
80946               _cachedApiStatus = status;
80947               dispatch10.call("apiStatusChange", that, err, status);
80948             }
80949           });
80950         }, 500);
80951       }
80952       this.throttledReloadApiStatus();
80953     },
80954     // Returns the maximum number of nodes a single way can have
80955     maxWayNodes: function() {
80956       return _maxWayNodes;
80957     },
80958     // Load data (entities) from the API in tiles
80959     // GET /api/0.6/map?bbox=
80960     loadTiles: function(projection2, callback) {
80961       if (_off)
80962         return;
80963       var tiles = tiler6.zoomExtent([_tileZoom4, _tileZoom4]).getTiles(projection2);
80964       var hadRequests = hasInflightRequests(_tileCache);
80965       abortUnwantedRequests4(_tileCache, tiles);
80966       if (hadRequests && !hasInflightRequests(_tileCache)) {
80967         dispatch10.call("loaded");
80968       }
80969       tiles.forEach(function(tile) {
80970         this.loadTile(tile, callback);
80971       }, this);
80972     },
80973     // Load a single data tile
80974     // GET /api/0.6/map?bbox=
80975     loadTile: function(tile, callback) {
80976       if (_off)
80977         return;
80978       if (_tileCache.loaded[tile.id] || _tileCache.inflight[tile.id])
80979         return;
80980       if (!hasInflightRequests(_tileCache)) {
80981         dispatch10.call("loading");
80982       }
80983       var path = "/api/0.6/map.json?bbox=";
80984       var options2 = { skipSeen: true };
80985       _tileCache.inflight[tile.id] = this.loadFromAPI(
80986         path + tile.extent.toParam(),
80987         tileCallback,
80988         options2
80989       );
80990       function tileCallback(err, parsed) {
80991         delete _tileCache.inflight[tile.id];
80992         if (!err) {
80993           delete _tileCache.toLoad[tile.id];
80994           _tileCache.loaded[tile.id] = true;
80995           var bbox2 = tile.extent.bbox();
80996           bbox2.id = tile.id;
80997           _tileCache.rtree.insert(bbox2);
80998         }
80999         if (callback) {
81000           callback(err, Object.assign({ data: parsed }, tile));
81001         }
81002         if (!hasInflightRequests(_tileCache)) {
81003           dispatch10.call("loaded");
81004         }
81005       }
81006     },
81007     isDataLoaded: function(loc) {
81008       var bbox2 = { minX: loc[0], minY: loc[1], maxX: loc[0], maxY: loc[1] };
81009       return _tileCache.rtree.collides(bbox2);
81010     },
81011     // load the tile that covers the given `loc`
81012     loadTileAtLoc: function(loc, callback) {
81013       if (Object.keys(_tileCache.toLoad).length > 50)
81014         return;
81015       var k2 = geoZoomToScale(_tileZoom4 + 1);
81016       var offset = geoRawMercator().scale(k2)(loc);
81017       var projection2 = geoRawMercator().transform({ k: k2, x: -offset[0], y: -offset[1] });
81018       var tiles = tiler6.zoomExtent([_tileZoom4, _tileZoom4]).getTiles(projection2);
81019       tiles.forEach(function(tile) {
81020         if (_tileCache.toLoad[tile.id] || _tileCache.loaded[tile.id] || _tileCache.inflight[tile.id])
81021           return;
81022         _tileCache.toLoad[tile.id] = true;
81023         this.loadTile(tile, callback);
81024       }, this);
81025     },
81026     // Load notes from the API in tiles
81027     // GET /api/0.6/notes?bbox=
81028     loadNotes: function(projection2, noteOptions) {
81029       noteOptions = Object.assign({ limit: 1e4, closed: 7 }, noteOptions);
81030       if (_off)
81031         return;
81032       var that = this;
81033       var path = "/api/0.6/notes?limit=" + noteOptions.limit + "&closed=" + noteOptions.closed + "&bbox=";
81034       var throttleLoadUsers = throttle_default(function() {
81035         var uids = Object.keys(_userCache.toLoad);
81036         if (!uids.length)
81037           return;
81038         that.loadUsers(uids, function() {
81039         });
81040       }, 750);
81041       var tiles = tiler6.zoomExtent([_noteZoom, _noteZoom]).getTiles(projection2);
81042       abortUnwantedRequests4(_noteCache, tiles);
81043       tiles.forEach(function(tile) {
81044         if (_noteCache.loaded[tile.id] || _noteCache.inflight[tile.id])
81045           return;
81046         var options2 = { skipSeen: false };
81047         _noteCache.inflight[tile.id] = that.loadFromAPI(
81048           path + tile.extent.toParam(),
81049           function(err) {
81050             delete _noteCache.inflight[tile.id];
81051             if (!err) {
81052               _noteCache.loaded[tile.id] = true;
81053             }
81054             throttleLoadUsers();
81055             dispatch10.call("loadedNotes");
81056           },
81057           options2
81058         );
81059       });
81060     },
81061     // Create a note
81062     // POST /api/0.6/notes?params
81063     postNoteCreate: function(note, callback) {
81064       if (!this.authenticated()) {
81065         return callback({ message: "Not Authenticated", status: -3 }, note);
81066       }
81067       if (_noteCache.inflightPost[note.id]) {
81068         return callback({ message: "Note update already inflight", status: -2 }, note);
81069       }
81070       if (!note.loc[0] || !note.loc[1] || !note.newComment)
81071         return;
81072       var comment = note.newComment;
81073       if (note.newCategory && note.newCategory !== "None") {
81074         comment += " #" + note.newCategory;
81075       }
81076       var path = "/api/0.6/notes?" + utilQsString({ lon: note.loc[0], lat: note.loc[1], text: comment });
81077       _noteCache.inflightPost[note.id] = oauth.xhr({
81078         method: "POST",
81079         path
81080       }, wrapcb(this, done, _connectionID));
81081       function done(err, xml) {
81082         delete _noteCache.inflightPost[note.id];
81083         if (err) {
81084           return callback(err);
81085         }
81086         this.removeNote(note);
81087         var options2 = { skipSeen: false };
81088         return parseXML(xml, function(err2, results) {
81089           if (err2) {
81090             return callback(err2);
81091           } else {
81092             return callback(void 0, results[0]);
81093           }
81094         }, options2);
81095       }
81096     },
81097     // Update a note
81098     // POST /api/0.6/notes/#id/comment?text=comment
81099     // POST /api/0.6/notes/#id/close?text=comment
81100     // POST /api/0.6/notes/#id/reopen?text=comment
81101     postNoteUpdate: function(note, newStatus, callback) {
81102       if (!this.authenticated()) {
81103         return callback({ message: "Not Authenticated", status: -3 }, note);
81104       }
81105       if (_noteCache.inflightPost[note.id]) {
81106         return callback({ message: "Note update already inflight", status: -2 }, note);
81107       }
81108       var action;
81109       if (note.status !== "closed" && newStatus === "closed") {
81110         action = "close";
81111       } else if (note.status !== "open" && newStatus === "open") {
81112         action = "reopen";
81113       } else {
81114         action = "comment";
81115         if (!note.newComment)
81116           return;
81117       }
81118       var path = "/api/0.6/notes/" + note.id + "/" + action;
81119       if (note.newComment) {
81120         path += "?" + utilQsString({ text: note.newComment });
81121       }
81122       _noteCache.inflightPost[note.id] = oauth.xhr({
81123         method: "POST",
81124         path
81125       }, wrapcb(this, done, _connectionID));
81126       function done(err, xml) {
81127         delete _noteCache.inflightPost[note.id];
81128         if (err) {
81129           return callback(err);
81130         }
81131         this.removeNote(note);
81132         if (action === "close") {
81133           _noteCache.closed[note.id] = true;
81134         } else if (action === "reopen") {
81135           delete _noteCache.closed[note.id];
81136         }
81137         var options2 = { skipSeen: false };
81138         return parseXML(xml, function(err2, results) {
81139           if (err2) {
81140             return callback(err2);
81141           } else {
81142             return callback(void 0, results[0]);
81143           }
81144         }, options2);
81145       }
81146     },
81147     /* connection options for source switcher (optional) */
81148     apiConnections: function(val) {
81149       if (!arguments.length)
81150         return _apiConnections;
81151       _apiConnections = val;
81152       return this;
81153     },
81154     switch: function(newOptions) {
81155       urlroot = newOptions.url;
81156       apiUrlroot = newOptions.apiUrl || urlroot;
81157       if (newOptions.url && !newOptions.apiUrl) {
81158         newOptions = {
81159           ...newOptions,
81160           apiUrl: newOptions.url
81161         };
81162       }
81163       const oldOptions = utilObjectOmit(oauth.options(), "access_token");
81164       oauth.options({ ...oldOptions, ...newOptions });
81165       this.reset();
81166       this.userChangesets(function() {
81167       });
81168       dispatch10.call("change");
81169       return this;
81170     },
81171     toggle: function(val) {
81172       _off = !val;
81173       return this;
81174     },
81175     isChangesetInflight: function() {
81176       return !!_changeset.inflight;
81177     },
81178     // get/set cached data
81179     // This is used to save/restore the state when entering/exiting the walkthrough
81180     // Also used for testing purposes.
81181     caches: function(obj) {
81182       function cloneCache(source) {
81183         var target = {};
81184         Object.keys(source).forEach(function(k2) {
81185           if (k2 === "rtree") {
81186             target.rtree = new import_rbush10.default().fromJSON(source.rtree.toJSON());
81187           } else if (k2 === "note") {
81188             target.note = {};
81189             Object.keys(source.note).forEach(function(id2) {
81190               target.note[id2] = osmNote(source.note[id2]);
81191             });
81192           } else {
81193             target[k2] = JSON.parse(JSON.stringify(source[k2]));
81194           }
81195         });
81196         return target;
81197       }
81198       if (!arguments.length) {
81199         return {
81200           tile: cloneCache(_tileCache),
81201           note: cloneCache(_noteCache),
81202           user: cloneCache(_userCache)
81203         };
81204       }
81205       if (obj === "get") {
81206         return {
81207           tile: _tileCache,
81208           note: _noteCache,
81209           user: _userCache
81210         };
81211       }
81212       if (obj.tile) {
81213         _tileCache = obj.tile;
81214         _tileCache.inflight = {};
81215       }
81216       if (obj.note) {
81217         _noteCache = obj.note;
81218         _noteCache.inflight = {};
81219         _noteCache.inflightPost = {};
81220       }
81221       if (obj.user) {
81222         _userCache = obj.user;
81223       }
81224       return this;
81225     },
81226     logout: function() {
81227       _userChangesets = void 0;
81228       _userDetails = void 0;
81229       oauth.logout();
81230       dispatch10.call("change");
81231       return this;
81232     },
81233     authenticated: function() {
81234       return oauth.authenticated();
81235     },
81236     authenticate: function(callback) {
81237       var that = this;
81238       var cid = _connectionID;
81239       _userChangesets = void 0;
81240       _userDetails = void 0;
81241       function done(err, res) {
81242         if (err) {
81243           if (callback)
81244             callback(err);
81245           return;
81246         }
81247         if (that.getConnectionId() !== cid) {
81248           if (callback)
81249             callback({ message: "Connection Switched", status: -1 });
81250           return;
81251         }
81252         _rateLimitError = void 0;
81253         dispatch10.call("change");
81254         if (callback)
81255           callback(err, res);
81256         that.userChangesets(function() {
81257         });
81258       }
81259       oauth.authenticate(done);
81260     },
81261     imageryBlocklists: function() {
81262       return _imageryBlocklists;
81263     },
81264     tileZoom: function(val) {
81265       if (!arguments.length)
81266         return _tileZoom4;
81267       _tileZoom4 = val;
81268       return this;
81269     },
81270     // get all cached notes covering the viewport
81271     notes: function(projection2) {
81272       var viewport = projection2.clipExtent();
81273       var min3 = [viewport[0][0], viewport[1][1]];
81274       var max3 = [viewport[1][0], viewport[0][1]];
81275       var bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
81276       return _noteCache.rtree.search(bbox2).map(function(d2) {
81277         return d2.data;
81278       });
81279     },
81280     // get a single note from the cache
81281     getNote: function(id2) {
81282       return _noteCache.note[id2];
81283     },
81284     // remove a single note from the cache
81285     removeNote: function(note) {
81286       if (!(note instanceof osmNote) || !note.id)
81287         return;
81288       delete _noteCache.note[note.id];
81289       updateRtree4(encodeNoteRtree(note), false);
81290     },
81291     // replace a single note in the cache
81292     replaceNote: function(note) {
81293       if (!(note instanceof osmNote) || !note.id)
81294         return;
81295       _noteCache.note[note.id] = note;
81296       updateRtree4(encodeNoteRtree(note), true);
81297       return note;
81298     },
81299     // Get an array of note IDs closed during this session.
81300     // Used to populate `closed:note` changeset tag
81301     getClosedIDs: function() {
81302       return Object.keys(_noteCache.closed).sort();
81303     }
81304   };
81305
81306   // modules/services/osm_wikibase.js
81307   var apibase3 = "https://wiki.openstreetmap.org/w/api.php";
81308   var _inflight2 = {};
81309   var _wikibaseCache = {};
81310   var _localeIDs = { en: false };
81311   var debouncedRequest = debounce_default(request, 500, { leading: false });
81312   function request(url, callback) {
81313     if (_inflight2[url])
81314       return;
81315     var controller = new AbortController();
81316     _inflight2[url] = controller;
81317     json_default(url, { signal: controller.signal }).then(function(result) {
81318       delete _inflight2[url];
81319       if (callback)
81320         callback(null, result);
81321     }).catch(function(err) {
81322       delete _inflight2[url];
81323       if (err.name === "AbortError")
81324         return;
81325       if (callback)
81326         callback(err.message);
81327     });
81328   }
81329   var osm_wikibase_default = {
81330     init: function() {
81331       _inflight2 = {};
81332       _wikibaseCache = {};
81333       _localeIDs = {};
81334     },
81335     reset: function() {
81336       Object.values(_inflight2).forEach(function(controller) {
81337         controller.abort();
81338       });
81339       _inflight2 = {};
81340     },
81341     /**
81342      * Get the best value for the property, or undefined if not found
81343      * @param entity object from wikibase
81344      * @param property string e.g. 'P4' for image
81345      * @param langCode string e.g. 'fr' for French
81346      */
81347     claimToValue: function(entity, property, langCode) {
81348       if (!entity.claims[property])
81349         return void 0;
81350       var locale2 = _localeIDs[langCode];
81351       var preferredPick, localePick;
81352       entity.claims[property].forEach(function(stmt) {
81353         if (!preferredPick && stmt.rank === "preferred") {
81354           preferredPick = stmt;
81355         }
81356         if (locale2 && stmt.qualifiers && stmt.qualifiers.P26 && stmt.qualifiers.P26[0].datavalue.value.id === locale2) {
81357           localePick = stmt;
81358         }
81359       });
81360       var result = localePick || preferredPick;
81361       if (result) {
81362         var datavalue = result.mainsnak.datavalue;
81363         return datavalue.type === "wikibase-entityid" ? datavalue.value.id : datavalue.value;
81364       } else {
81365         return void 0;
81366       }
81367     },
81368     /**
81369      * Convert monolingual property into a key-value object (language -> value)
81370      * @param entity object from wikibase
81371      * @param property string e.g. 'P31' for monolingual wiki page title
81372      */
81373     monolingualClaimToValueObj: function(entity, property) {
81374       if (!entity || !entity.claims[property])
81375         return void 0;
81376       return entity.claims[property].reduce(function(acc, obj) {
81377         var value = obj.mainsnak.datavalue.value;
81378         acc[value.language] = value.text;
81379         return acc;
81380       }, {});
81381     },
81382     toSitelink: function(key, value) {
81383       var result = value ? "Tag:" + key + "=" + value : "Key:" + key;
81384       return result.replace(/_/g, " ").trim();
81385     },
81386     //
81387     // Pass params object of the form:
81388     // {
81389     //   key: 'string',
81390     //   value: 'string',
81391     //   langCode: 'string'
81392     // }
81393     //
81394     getEntity: function(params, callback) {
81395       var doRequest = params.debounce ? debouncedRequest : request;
81396       var that = this;
81397       var titles = [];
81398       var result = {};
81399       var rtypeSitelink = params.key === "type" && params.value ? ("Relation:" + params.value).replace(/_/g, " ").trim() : false;
81400       var keySitelink = params.key ? this.toSitelink(params.key) : false;
81401       var tagSitelink = params.key && params.value ? this.toSitelink(params.key, params.value) : false;
81402       var localeSitelink;
81403       if (params.langCodes) {
81404         params.langCodes.forEach(function(langCode) {
81405           if (_localeIDs[langCode] === void 0) {
81406             localeSitelink = ("Locale:" + langCode).replace(/_/g, " ").trim();
81407             titles.push(localeSitelink);
81408           }
81409         });
81410       }
81411       if (rtypeSitelink) {
81412         if (_wikibaseCache[rtypeSitelink]) {
81413           result.rtype = _wikibaseCache[rtypeSitelink];
81414         } else {
81415           titles.push(rtypeSitelink);
81416         }
81417       }
81418       if (keySitelink) {
81419         if (_wikibaseCache[keySitelink]) {
81420           result.key = _wikibaseCache[keySitelink];
81421         } else {
81422           titles.push(keySitelink);
81423         }
81424       }
81425       if (tagSitelink) {
81426         if (_wikibaseCache[tagSitelink]) {
81427           result.tag = _wikibaseCache[tagSitelink];
81428         } else {
81429           titles.push(tagSitelink);
81430         }
81431       }
81432       if (!titles.length) {
81433         return callback(null, result);
81434       }
81435       var obj = {
81436         action: "wbgetentities",
81437         sites: "wiki",
81438         titles: titles.join("|"),
81439         languages: params.langCodes.join("|"),
81440         languagefallback: 1,
81441         origin: "*",
81442         format: "json"
81443         // There is an MW Wikibase API bug https://phabricator.wikimedia.org/T212069
81444         // We shouldn't use v1 until it gets fixed, but should switch to it afterwards
81445         // formatversion: 2,
81446       };
81447       var url = apibase3 + "?" + utilQsString(obj);
81448       doRequest(url, function(err, d2) {
81449         if (err) {
81450           callback(err);
81451         } else if (!d2.success || d2.error) {
81452           callback(d2.error.messages.map(function(v2) {
81453             return v2.html["*"];
81454           }).join("<br>"));
81455         } else {
81456           var localeID = false;
81457           Object.values(d2.entities).forEach(function(res) {
81458             if (res.missing !== "") {
81459               var title = res.sitelinks.wiki.title;
81460               if (title === rtypeSitelink) {
81461                 _wikibaseCache[rtypeSitelink] = res;
81462                 result.rtype = res;
81463               } else if (title === keySitelink) {
81464                 _wikibaseCache[keySitelink] = res;
81465                 result.key = res;
81466               } else if (title === tagSitelink) {
81467                 _wikibaseCache[tagSitelink] = res;
81468                 result.tag = res;
81469               } else if (title === localeSitelink) {
81470                 localeID = res.id;
81471               } else {
81472                 console.log("Unexpected title " + title);
81473               }
81474             }
81475           });
81476           if (localeSitelink) {
81477             that.addLocale(params.langCodes[0], localeID);
81478           }
81479           callback(null, result);
81480         }
81481       });
81482     },
81483     //
81484     // Pass params object of the form:
81485     // {
81486     //   key: 'string',     // required
81487     //   value: 'string'    // optional
81488     // }
81489     //
81490     // Get an result object used to display tag documentation
81491     // {
81492     //   title:        'string',
81493     //   description:  'string',
81494     //   editURL:      'string',
81495     //   imageURL:     'string',
81496     //   wiki:         { title: 'string', text: 'string', url: 'string' }
81497     // }
81498     //
81499     getDocs: function(params, callback) {
81500       var that = this;
81501       var langCodes = _mainLocalizer.localeCodes().map(function(code) {
81502         return code.toLowerCase();
81503       });
81504       params.langCodes = langCodes;
81505       this.getEntity(params, function(err, data) {
81506         if (err) {
81507           callback(err);
81508           return;
81509         }
81510         var entity = data.rtype || data.tag || data.key;
81511         if (!entity) {
81512           callback("No entity");
81513           return;
81514         }
81515         var i3;
81516         var description;
81517         for (i3 in langCodes) {
81518           let code2 = langCodes[i3];
81519           if (entity.descriptions[code2] && entity.descriptions[code2].language === code2) {
81520             description = entity.descriptions[code2];
81521             break;
81522           }
81523         }
81524         if (!description && Object.values(entity.descriptions).length)
81525           description = Object.values(entity.descriptions)[0];
81526         var result = {
81527           title: entity.title,
81528           description: description ? description.value : "",
81529           descriptionLocaleCode: description ? description.language : "",
81530           editURL: "https://wiki.openstreetmap.org/wiki/" + entity.title
81531         };
81532         if (entity.claims) {
81533           var imageroot;
81534           var image = that.claimToValue(entity, "P4", langCodes[0]);
81535           if (image) {
81536             imageroot = "https://commons.wikimedia.org/w/index.php";
81537           } else {
81538             image = that.claimToValue(entity, "P28", langCodes[0]);
81539             if (image) {
81540               imageroot = "https://wiki.openstreetmap.org/w/index.php";
81541             }
81542           }
81543           if (imageroot && image) {
81544             result.imageURL = imageroot + "?" + utilQsString({
81545               title: "Special:Redirect/file/" + image,
81546               width: 400
81547             });
81548           }
81549         }
81550         var rtypeWiki = that.monolingualClaimToValueObj(data.rtype, "P31");
81551         var tagWiki = that.monolingualClaimToValueObj(data.tag, "P31");
81552         var keyWiki = that.monolingualClaimToValueObj(data.key, "P31");
81553         var wikis = [rtypeWiki, tagWiki, keyWiki];
81554         for (i3 in wikis) {
81555           var wiki = wikis[i3];
81556           for (var j2 in langCodes) {
81557             var code = langCodes[j2];
81558             var referenceId = langCodes[0].split("-")[0] !== "en" && code.split("-")[0] === "en" ? "inspector.wiki_en_reference" : "inspector.wiki_reference";
81559             var info = getWikiInfo(wiki, code, referenceId);
81560             if (info) {
81561               result.wiki = info;
81562               break;
81563             }
81564           }
81565           if (result.wiki)
81566             break;
81567         }
81568         callback(null, result);
81569         function getWikiInfo(wiki2, langCode, tKey) {
81570           if (wiki2 && wiki2[langCode]) {
81571             return {
81572               title: wiki2[langCode],
81573               text: tKey,
81574               url: "https://wiki.openstreetmap.org/wiki/" + wiki2[langCode]
81575             };
81576           }
81577         }
81578       });
81579     },
81580     addLocale: function(langCode, qid) {
81581       _localeIDs[langCode] = qid;
81582     },
81583     apibase: function(val) {
81584       if (!arguments.length)
81585         return apibase3;
81586       apibase3 = val;
81587       return this;
81588     }
81589   };
81590
81591   // modules/services/streetside.js
81592   var import_rbush11 = __toESM(require_rbush_min());
81593   var streetsideApi = "https://dev.virtualearth.net/REST/v1/Imagery/MetaData/Streetside?mapArea={bbox}&key={key}&count={count}";
81594   var maxResults2 = 500;
81595   var bubbleAppKey = utilAesDecrypt("5c875730b09c6b422433e807e1ff060b6536c791dbfffcffc4c6b18a1bdba1f14593d151adb50e19e1be1ab19aef813bf135d0f103475e5c724dec94389e45d0");
81596   var pannellumViewerCSS2 = "pannellum/pannellum.css";
81597   var pannellumViewerJS2 = "pannellum/pannellum.js";
81598   var tileZoom3 = 16.5;
81599   var tiler7 = utilTiler().zoomExtent([tileZoom3, tileZoom3]).skipNullIsland(true);
81600   var dispatch11 = dispatch_default("loadedImages", "viewerChanged");
81601   var minHfov = 10;
81602   var maxHfov = 90;
81603   var defaultHfov = 45;
81604   var _hires = false;
81605   var _resolution = 512;
81606   var _currScene = 0;
81607   var _ssCache;
81608   var _pannellumViewer2;
81609   var _sceneOptions = {
81610     showFullscreenCtrl: false,
81611     autoLoad: true,
81612     compass: true,
81613     yaw: 0,
81614     minHfov,
81615     maxHfov,
81616     hfov: defaultHfov,
81617     type: "cubemap",
81618     cubeMap: []
81619   };
81620   var _loadViewerPromise4;
81621   function abortRequest6(i3) {
81622     i3.abort();
81623   }
81624   function localeTimestamp2(s2) {
81625     if (!s2)
81626       return null;
81627     const options2 = { day: "numeric", month: "short", year: "numeric" };
81628     const d2 = new Date(s2);
81629     if (isNaN(d2.getTime()))
81630       return null;
81631     return d2.toLocaleString(_mainLocalizer.localeCode(), options2);
81632   }
81633   function loadTiles3(which, url, projection2, margin) {
81634     const tiles = tiler7.margin(margin).getTiles(projection2);
81635     const cache = _ssCache[which];
81636     Object.keys(cache.inflight).forEach((k2) => {
81637       const wanted = tiles.find((tile) => k2.indexOf(tile.id + ",") === 0);
81638       if (!wanted) {
81639         abortRequest6(cache.inflight[k2]);
81640         delete cache.inflight[k2];
81641       }
81642     });
81643     tiles.forEach((tile) => loadNextTilePage2(which, url, tile));
81644   }
81645   function loadNextTilePage2(which, url, tile) {
81646     const cache = _ssCache[which];
81647     const nextPage = cache.nextPage[tile.id] || 0;
81648     const id2 = tile.id + "," + String(nextPage);
81649     if (cache.loaded[id2] || cache.inflight[id2])
81650       return;
81651     cache.inflight[id2] = getBubbles(url, tile, (response) => {
81652       cache.loaded[id2] = true;
81653       delete cache.inflight[id2];
81654       if (!response)
81655         return;
81656       if (response.resourceSets[0].resources.length === maxResults2) {
81657         const split = tile.extent.split();
81658         loadNextTilePage2(which, url, { id: tile.id + ",a", extent: split[0] });
81659         loadNextTilePage2(which, url, { id: tile.id + ",b", extent: split[1] });
81660         loadNextTilePage2(which, url, { id: tile.id + ",c", extent: split[2] });
81661         loadNextTilePage2(which, url, { id: tile.id + ",d", extent: split[3] });
81662       }
81663       const features = response.resourceSets[0].resources.map((bubble) => {
81664         const bubbleId = bubble.imageUrl;
81665         if (cache.points[bubbleId])
81666           return null;
81667         const loc = [bubble.lon, bubble.lat];
81668         const d2 = {
81669           loc,
81670           key: bubbleId,
81671           imageUrl: bubble.imageUrl.replace(
81672             "{subdomain}",
81673             bubble.imageUrlSubdomains[0]
81674           ),
81675           ca: bubble.he,
81676           captured_at: bubble.vintageEnd,
81677           captured_by: "microsoft",
81678           pano: true,
81679           sequenceKey: null
81680         };
81681         cache.points[bubbleId] = d2;
81682         return {
81683           minX: loc[0],
81684           minY: loc[1],
81685           maxX: loc[0],
81686           maxY: loc[1],
81687           data: d2
81688         };
81689       }).filter(Boolean);
81690       cache.rtree.load(features);
81691       if (which === "bubbles") {
81692         dispatch11.call("loadedImages");
81693       }
81694     });
81695   }
81696   function getBubbles(url, tile, callback) {
81697     let rect = tile.extent.rectangle();
81698     let urlForRequest = url.replace("{key}", bubbleAppKey).replace("{bbox}", [rect[1], rect[0], rect[3], rect[2]].join(",")).replace("{count}", maxResults2);
81699     const controller = new AbortController();
81700     fetch(urlForRequest, { signal: controller.signal }).then(function(response) {
81701       if (!response.ok) {
81702         throw new Error(response.status + " " + response.statusText);
81703       }
81704       return response.json();
81705     }).then(function(result) {
81706       if (!result) {
81707         callback(null);
81708       }
81709       return callback(result || []);
81710     }).catch(function(err) {
81711       if (err.name === "AbortError") {
81712       } else {
81713         throw new Error(err);
81714       }
81715     });
81716     return controller;
81717   }
81718   function partitionViewport4(projection2) {
81719     let z2 = geoScaleToZoom(projection2.scale());
81720     let z22 = Math.ceil(z2 * 2) / 2 + 2.5;
81721     let tiler9 = utilTiler().zoomExtent([z22, z22]);
81722     return tiler9.getTiles(projection2).map((tile) => tile.extent);
81723   }
81724   function searchLimited4(limit, projection2, rtree) {
81725     limit = limit || 5;
81726     return partitionViewport4(projection2).reduce((result, extent) => {
81727       let found = rtree.search(extent.bbox()).slice(0, limit).map((d2) => d2.data);
81728       return found.length ? result.concat(found) : result;
81729     }, []);
81730   }
81731   function loadImage2(imgInfo) {
81732     return new Promise((resolve) => {
81733       let img = new Image();
81734       img.onload = () => {
81735         let canvas = document.getElementById("ideditor-canvas" + imgInfo.face);
81736         let ctx = canvas.getContext("2d");
81737         ctx.drawImage(img, imgInfo.x, imgInfo.y);
81738         resolve({ imgInfo, status: "ok" });
81739       };
81740       img.onerror = () => {
81741         resolve({ data: imgInfo, status: "error" });
81742       };
81743       img.setAttribute("crossorigin", "");
81744       img.src = imgInfo.url;
81745     });
81746   }
81747   function loadCanvas(imageGroup) {
81748     return Promise.all(imageGroup.map(loadImage2)).then((data) => {
81749       let canvas = document.getElementById("ideditor-canvas" + data[0].imgInfo.face);
81750       const which = { "01": 0, "02": 1, "03": 2, "10": 3, "11": 4, "12": 5 };
81751       let face = data[0].imgInfo.face;
81752       _sceneOptions.cubeMap[which[face]] = canvas.toDataURL("image/jpeg", 1);
81753       return { status: "loadCanvas for face " + data[0].imgInfo.face + "ok" };
81754     });
81755   }
81756   function loadFaces(faceGroup) {
81757     return Promise.all(faceGroup.map(loadCanvas)).then(() => {
81758       return { status: "loadFaces done" };
81759     });
81760   }
81761   function setupCanvas(selection2, reset) {
81762     if (reset) {
81763       selection2.selectAll("#ideditor-stitcher-canvases").remove();
81764     }
81765     selection2.selectAll("#ideditor-stitcher-canvases").data([0]).enter().append("div").attr("id", "ideditor-stitcher-canvases").attr("display", "none").selectAll("canvas").data(["canvas01", "canvas02", "canvas03", "canvas10", "canvas11", "canvas12"]).enter().append("canvas").attr("id", (d2) => "ideditor-" + d2).attr("width", _resolution).attr("height", _resolution);
81766   }
81767   function qkToXY(qk) {
81768     let x2 = 0;
81769     let y2 = 0;
81770     let scale = 256;
81771     for (let i3 = qk.length; i3 > 0; i3--) {
81772       const key = qk[i3 - 1];
81773       x2 += +(key === "1" || key === "3") * scale;
81774       y2 += +(key === "2" || key === "3") * scale;
81775       scale *= 2;
81776     }
81777     return [x2, y2];
81778   }
81779   function getQuadKeys() {
81780     let dim = _resolution / 256;
81781     let quadKeys;
81782     if (dim === 16) {
81783       quadKeys = [
81784         "0000",
81785         "0001",
81786         "0010",
81787         "0011",
81788         "0100",
81789         "0101",
81790         "0110",
81791         "0111",
81792         "1000",
81793         "1001",
81794         "1010",
81795         "1011",
81796         "1100",
81797         "1101",
81798         "1110",
81799         "1111",
81800         "0002",
81801         "0003",
81802         "0012",
81803         "0013",
81804         "0102",
81805         "0103",
81806         "0112",
81807         "0113",
81808         "1002",
81809         "1003",
81810         "1012",
81811         "1013",
81812         "1102",
81813         "1103",
81814         "1112",
81815         "1113",
81816         "0020",
81817         "0021",
81818         "0030",
81819         "0031",
81820         "0120",
81821         "0121",
81822         "0130",
81823         "0131",
81824         "1020",
81825         "1021",
81826         "1030",
81827         "1031",
81828         "1120",
81829         "1121",
81830         "1130",
81831         "1131",
81832         "0022",
81833         "0023",
81834         "0032",
81835         "0033",
81836         "0122",
81837         "0123",
81838         "0132",
81839         "0133",
81840         "1022",
81841         "1023",
81842         "1032",
81843         "1033",
81844         "1122",
81845         "1123",
81846         "1132",
81847         "1133",
81848         "0200",
81849         "0201",
81850         "0210",
81851         "0211",
81852         "0300",
81853         "0301",
81854         "0310",
81855         "0311",
81856         "1200",
81857         "1201",
81858         "1210",
81859         "1211",
81860         "1300",
81861         "1301",
81862         "1310",
81863         "1311",
81864         "0202",
81865         "0203",
81866         "0212",
81867         "0213",
81868         "0302",
81869         "0303",
81870         "0312",
81871         "0313",
81872         "1202",
81873         "1203",
81874         "1212",
81875         "1213",
81876         "1302",
81877         "1303",
81878         "1312",
81879         "1313",
81880         "0220",
81881         "0221",
81882         "0230",
81883         "0231",
81884         "0320",
81885         "0321",
81886         "0330",
81887         "0331",
81888         "1220",
81889         "1221",
81890         "1230",
81891         "1231",
81892         "1320",
81893         "1321",
81894         "1330",
81895         "1331",
81896         "0222",
81897         "0223",
81898         "0232",
81899         "0233",
81900         "0322",
81901         "0323",
81902         "0332",
81903         "0333",
81904         "1222",
81905         "1223",
81906         "1232",
81907         "1233",
81908         "1322",
81909         "1323",
81910         "1332",
81911         "1333",
81912         "2000",
81913         "2001",
81914         "2010",
81915         "2011",
81916         "2100",
81917         "2101",
81918         "2110",
81919         "2111",
81920         "3000",
81921         "3001",
81922         "3010",
81923         "3011",
81924         "3100",
81925         "3101",
81926         "3110",
81927         "3111",
81928         "2002",
81929         "2003",
81930         "2012",
81931         "2013",
81932         "2102",
81933         "2103",
81934         "2112",
81935         "2113",
81936         "3002",
81937         "3003",
81938         "3012",
81939         "3013",
81940         "3102",
81941         "3103",
81942         "3112",
81943         "3113",
81944         "2020",
81945         "2021",
81946         "2030",
81947         "2031",
81948         "2120",
81949         "2121",
81950         "2130",
81951         "2131",
81952         "3020",
81953         "3021",
81954         "3030",
81955         "3031",
81956         "3120",
81957         "3121",
81958         "3130",
81959         "3131",
81960         "2022",
81961         "2023",
81962         "2032",
81963         "2033",
81964         "2122",
81965         "2123",
81966         "2132",
81967         "2133",
81968         "3022",
81969         "3023",
81970         "3032",
81971         "3033",
81972         "3122",
81973         "3123",
81974         "3132",
81975         "3133",
81976         "2200",
81977         "2201",
81978         "2210",
81979         "2211",
81980         "2300",
81981         "2301",
81982         "2310",
81983         "2311",
81984         "3200",
81985         "3201",
81986         "3210",
81987         "3211",
81988         "3300",
81989         "3301",
81990         "3310",
81991         "3311",
81992         "2202",
81993         "2203",
81994         "2212",
81995         "2213",
81996         "2302",
81997         "2303",
81998         "2312",
81999         "2313",
82000         "3202",
82001         "3203",
82002         "3212",
82003         "3213",
82004         "3302",
82005         "3303",
82006         "3312",
82007         "3313",
82008         "2220",
82009         "2221",
82010         "2230",
82011         "2231",
82012         "2320",
82013         "2321",
82014         "2330",
82015         "2331",
82016         "3220",
82017         "3221",
82018         "3230",
82019         "3231",
82020         "3320",
82021         "3321",
82022         "3330",
82023         "3331",
82024         "2222",
82025         "2223",
82026         "2232",
82027         "2233",
82028         "2322",
82029         "2323",
82030         "2332",
82031         "2333",
82032         "3222",
82033         "3223",
82034         "3232",
82035         "3233",
82036         "3322",
82037         "3323",
82038         "3332",
82039         "3333"
82040       ];
82041     } else if (dim === 8) {
82042       quadKeys = [
82043         "000",
82044         "001",
82045         "010",
82046         "011",
82047         "100",
82048         "101",
82049         "110",
82050         "111",
82051         "002",
82052         "003",
82053         "012",
82054         "013",
82055         "102",
82056         "103",
82057         "112",
82058         "113",
82059         "020",
82060         "021",
82061         "030",
82062         "031",
82063         "120",
82064         "121",
82065         "130",
82066         "131",
82067         "022",
82068         "023",
82069         "032",
82070         "033",
82071         "122",
82072         "123",
82073         "132",
82074         "133",
82075         "200",
82076         "201",
82077         "210",
82078         "211",
82079         "300",
82080         "301",
82081         "310",
82082         "311",
82083         "202",
82084         "203",
82085         "212",
82086         "213",
82087         "302",
82088         "303",
82089         "312",
82090         "313",
82091         "220",
82092         "221",
82093         "230",
82094         "231",
82095         "320",
82096         "321",
82097         "330",
82098         "331",
82099         "222",
82100         "223",
82101         "232",
82102         "233",
82103         "322",
82104         "323",
82105         "332",
82106         "333"
82107       ];
82108     } else if (dim === 4) {
82109       quadKeys = [
82110         "00",
82111         "01",
82112         "10",
82113         "11",
82114         "02",
82115         "03",
82116         "12",
82117         "13",
82118         "20",
82119         "21",
82120         "30",
82121         "31",
82122         "22",
82123         "23",
82124         "32",
82125         "33"
82126       ];
82127     } else {
82128       quadKeys = [
82129         "0",
82130         "1",
82131         "2",
82132         "3"
82133       ];
82134     }
82135     return quadKeys;
82136   }
82137   var streetside_default = {
82138     /**
82139      * init() initialize streetside.
82140      */
82141     init: function() {
82142       if (!_ssCache) {
82143         this.reset();
82144       }
82145       this.event = utilRebind(this, dispatch11, "on");
82146     },
82147     /**
82148      * reset() reset the cache.
82149      */
82150     reset: function() {
82151       if (_ssCache) {
82152         Object.values(_ssCache.bubbles.inflight).forEach(abortRequest6);
82153       }
82154       _ssCache = {
82155         bubbles: { inflight: {}, loaded: {}, nextPage: {}, rtree: new import_rbush11.default(), points: {} },
82156         sequences: {}
82157       };
82158     },
82159     /**
82160      * bubbles()
82161      */
82162     bubbles: function(projection2) {
82163       const limit = 5;
82164       return searchLimited4(limit, projection2, _ssCache.bubbles.rtree);
82165     },
82166     cachedImage: function(imageKey) {
82167       return _ssCache.bubbles.points[imageKey];
82168     },
82169     sequences: function(projection2) {
82170       const viewport = projection2.clipExtent();
82171       const min3 = [viewport[0][0], viewport[1][1]];
82172       const max3 = [viewport[1][0], viewport[0][1]];
82173       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
82174       let seen = {};
82175       let results = [];
82176       _ssCache.bubbles.rtree.search(bbox2).forEach((d2) => {
82177         const key = d2.data.sequenceKey;
82178         if (key && !seen[key]) {
82179           seen[key] = true;
82180           results.push(_ssCache.sequences[key].geojson);
82181         }
82182       });
82183       return results;
82184     },
82185     /**
82186      * loadBubbles()
82187      */
82188     loadBubbles: function(projection2, margin) {
82189       if (margin === void 0)
82190         margin = 2;
82191       loadTiles3("bubbles", streetsideApi, projection2, margin);
82192     },
82193     viewer: function() {
82194       return _pannellumViewer2;
82195     },
82196     initViewer: function() {
82197       if (!window.pannellum)
82198         return;
82199       if (_pannellumViewer2)
82200         return;
82201       _currScene += 1;
82202       const sceneID = _currScene.toString();
82203       const options2 = {
82204         "default": { firstScene: sceneID },
82205         scenes: {}
82206       };
82207       options2.scenes[sceneID] = _sceneOptions;
82208       _pannellumViewer2 = window.pannellum.viewer("ideditor-viewer-streetside", options2);
82209     },
82210     ensureViewerLoaded: function(context) {
82211       if (_loadViewerPromise4)
82212         return _loadViewerPromise4;
82213       let wrap2 = context.container().select(".photoviewer").selectAll(".ms-wrapper").data([0]);
82214       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper ms-wrapper").classed("hide", true);
82215       let that = this;
82216       let pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
82217       wrapEnter.append("div").attr("id", "ideditor-viewer-streetside").on(pointerPrefix + "down.streetside", () => {
82218         select_default2(window).on(pointerPrefix + "move.streetside", () => {
82219           dispatch11.call("viewerChanged");
82220         }, true);
82221       }).on(pointerPrefix + "up.streetside pointercancel.streetside", () => {
82222         select_default2(window).on(pointerPrefix + "move.streetside", null);
82223         let t2 = timer((elapsed) => {
82224           dispatch11.call("viewerChanged");
82225           if (elapsed > 2e3) {
82226             t2.stop();
82227           }
82228         });
82229       }).append("div").attr("class", "photo-attribution fillD");
82230       let controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls");
82231       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
82232       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
82233       wrap2 = wrap2.merge(wrapEnter).call(setupCanvas, true);
82234       context.ui().photoviewer.on("resize.streetside", () => {
82235         if (_pannellumViewer2) {
82236           _pannellumViewer2.resize();
82237         }
82238       });
82239       _loadViewerPromise4 = new Promise((resolve, reject) => {
82240         let loadedCount = 0;
82241         function loaded() {
82242           loadedCount += 1;
82243           if (loadedCount === 2)
82244             resolve();
82245         }
82246         const head = select_default2("head");
82247         head.selectAll("#ideditor-streetside-viewercss").data([0]).enter().append("link").attr("id", "ideditor-streetside-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(pannellumViewerCSS2)).on("load.serviceStreetside", loaded).on("error.serviceStreetside", function() {
82248           reject();
82249         });
82250         head.selectAll("#ideditor-streetside-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-streetside-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(pannellumViewerJS2)).on("load.serviceStreetside", loaded).on("error.serviceStreetside", function() {
82251           reject();
82252         });
82253       }).catch(function() {
82254         _loadViewerPromise4 = null;
82255       });
82256       return _loadViewerPromise4;
82257       function step(stepBy) {
82258         return () => {
82259           let viewer = context.container().select(".photoviewer");
82260           let selected = viewer.empty() ? void 0 : viewer.datum();
82261           if (!selected)
82262             return;
82263           let nextID = stepBy === 1 ? selected.ne : selected.pr;
82264           let yaw = _pannellumViewer2.getYaw();
82265           let ca = selected.ca + yaw;
82266           let origin = selected.loc;
82267           const meters = 35;
82268           let p1 = [
82269             origin[0] + geoMetersToLon(meters / 5, origin[1]),
82270             origin[1]
82271           ];
82272           let p2 = [
82273             origin[0] + geoMetersToLon(meters / 2, origin[1]),
82274             origin[1] + geoMetersToLat(meters)
82275           ];
82276           let p3 = [
82277             origin[0] - geoMetersToLon(meters / 2, origin[1]),
82278             origin[1] + geoMetersToLat(meters)
82279           ];
82280           let p4 = [
82281             origin[0] - geoMetersToLon(meters / 5, origin[1]),
82282             origin[1]
82283           ];
82284           let poly = [p1, p2, p3, p4, p1];
82285           let angle2 = (stepBy === 1 ? ca : ca + 180) * (Math.PI / 180);
82286           poly = geoRotate(poly, -angle2, origin);
82287           let extent = poly.reduce((extent2, point2) => {
82288             return extent2.extend(geoExtent(point2));
82289           }, geoExtent());
82290           let minDist = Infinity;
82291           _ssCache.bubbles.rtree.search(extent.bbox()).forEach((d2) => {
82292             if (d2.data.key === selected.key)
82293               return;
82294             if (!geoPointInPolygon(d2.data.loc, poly))
82295               return;
82296             let dist = geoVecLength(d2.data.loc, selected.loc);
82297             let theta = selected.ca - d2.data.ca;
82298             let minTheta = Math.min(Math.abs(theta), 360 - Math.abs(theta));
82299             if (minTheta > 20) {
82300               dist += 5;
82301             }
82302             if (dist < minDist) {
82303               nextID = d2.data.key;
82304               minDist = dist;
82305             }
82306           });
82307           let nextBubble = nextID && that.cachedImage(nextID);
82308           if (!nextBubble)
82309             return;
82310           context.map().centerEase(nextBubble.loc);
82311           that.selectImage(context, nextBubble.key).yaw(yaw).showViewer(context);
82312         };
82313       }
82314     },
82315     yaw: function(yaw) {
82316       if (typeof yaw !== "number")
82317         return yaw;
82318       _sceneOptions.yaw = yaw;
82319       return this;
82320     },
82321     /**
82322      * showViewer()
82323      */
82324     showViewer: function(context) {
82325       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
82326       let isHidden = wrap2.selectAll(".photo-wrapper.ms-wrapper.hide").size();
82327       if (isHidden) {
82328         wrap2.selectAll(".photo-wrapper:not(.ms-wrapper)").classed("hide", true);
82329         wrap2.selectAll(".photo-wrapper.ms-wrapper").classed("hide", false);
82330       }
82331       return this;
82332     },
82333     /**
82334      * hideViewer()
82335      */
82336     hideViewer: function(context) {
82337       let viewer = context.container().select(".photoviewer");
82338       if (!viewer.empty())
82339         viewer.datum(null);
82340       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
82341       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
82342       this.updateUrlImage(null);
82343       return this.setStyles(context, null, true);
82344     },
82345     /**
82346      * selectImage().
82347      */
82348     selectImage: function(context, key) {
82349       let that = this;
82350       let d2 = this.cachedImage(key);
82351       let viewer = context.container().select(".photoviewer");
82352       if (!viewer.empty())
82353         viewer.datum(d2);
82354       this.setStyles(context, null, true);
82355       let wrap2 = context.container().select(".photoviewer .ms-wrapper");
82356       let attribution = wrap2.selectAll(".photo-attribution").html("");
82357       wrap2.selectAll(".pnlm-load-box").style("display", "block");
82358       if (!d2)
82359         return this;
82360       this.updateUrlImage(key);
82361       _sceneOptions.northOffset = d2.ca;
82362       let line1 = attribution.append("div").attr("class", "attribution-row");
82363       const hiresDomId = utilUniqueDomId("streetside-hires");
82364       let label = line1.append("label").attr("for", hiresDomId).attr("class", "streetside-hires");
82365       label.append("input").attr("type", "checkbox").attr("id", hiresDomId).property("checked", _hires).on("click", (d3_event) => {
82366         d3_event.stopPropagation();
82367         _hires = !_hires;
82368         _resolution = _hires ? 1024 : 512;
82369         wrap2.call(setupCanvas, true);
82370         let viewstate = {
82371           yaw: _pannellumViewer2.getYaw(),
82372           pitch: _pannellumViewer2.getPitch(),
82373           hfov: _pannellumViewer2.getHfov()
82374         };
82375         _sceneOptions = Object.assign(_sceneOptions, viewstate);
82376         that.selectImage(context, d2.key).showViewer(context);
82377       });
82378       label.append("span").call(_t.append("streetside.hires"));
82379       let captureInfo = line1.append("div").attr("class", "attribution-capture-info");
82380       if (d2.captured_by) {
82381         const yyyy = (/* @__PURE__ */ new Date()).getFullYear();
82382         captureInfo.append("a").attr("class", "captured_by").attr("target", "_blank").attr("href", "https://www.microsoft.com/en-us/maps/streetside").text("\xA9" + yyyy + " Microsoft");
82383         captureInfo.append("span").text("|");
82384       }
82385       if (d2.captured_at) {
82386         captureInfo.append("span").attr("class", "captured_at").text(localeTimestamp2(d2.captured_at));
82387       }
82388       let line2 = attribution.append("div").attr("class", "attribution-row");
82389       line2.append("a").attr("class", "image-view-link").attr("target", "_blank").attr("href", "https://www.bing.com/maps?cp=" + d2.loc[1] + "~" + d2.loc[0] + "&lvl=17&dir=" + d2.ca + "&style=x&v=2&sV=1").call(_t.append("streetside.view_on_bing"));
82390       line2.append("a").attr("class", "image-report-link").attr("target", "_blank").attr("href", "https://www.bing.com/maps/privacyreport/streetsideprivacyreport?bubbleid=" + encodeURIComponent(d2.key) + "&focus=photo&lat=" + d2.loc[1] + "&lng=" + d2.loc[0] + "&z=17").call(_t.append("streetside.report"));
82391       const faceKeys = ["01", "02", "03", "10", "11", "12"];
82392       let quadKeys = getQuadKeys();
82393       let faces = faceKeys.map((faceKey) => {
82394         return quadKeys.map((quadKey) => {
82395           const xy = qkToXY(quadKey);
82396           return {
82397             face: faceKey,
82398             url: d2.imageUrl.replace("{faceId}", faceKey).replace("{tileId}", quadKey),
82399             x: xy[0],
82400             y: xy[1]
82401           };
82402         });
82403       });
82404       loadFaces(faces).then(function() {
82405         if (!_pannellumViewer2) {
82406           that.initViewer();
82407         } else {
82408           _currScene += 1;
82409           let sceneID = _currScene.toString();
82410           _pannellumViewer2.addScene(sceneID, _sceneOptions).loadScene(sceneID);
82411           if (_currScene > 2) {
82412             sceneID = (_currScene - 1).toString();
82413             _pannellumViewer2.removeScene(sceneID);
82414           }
82415         }
82416       });
82417       return this;
82418     },
82419     getSequenceKeyForBubble: function(d2) {
82420       return d2 && d2.sequenceKey;
82421     },
82422     // Updates the currently highlighted sequence and selected bubble.
82423     // Reset is only necessary when interacting with the viewport because
82424     // this implicitly changes the currently selected bubble/sequence
82425     setStyles: function(context, hovered, reset) {
82426       if (reset) {
82427         context.container().selectAll(".viewfield-group").classed("highlighted", false).classed("hovered", false).classed("currentView", false);
82428         context.container().selectAll(".sequence").classed("highlighted", false).classed("currentView", false);
82429       }
82430       let hoveredBubbleKey = hovered && hovered.key;
82431       let hoveredSequenceKey = this.getSequenceKeyForBubble(hovered);
82432       let hoveredSequence = hoveredSequenceKey && _ssCache.sequences[hoveredSequenceKey];
82433       let hoveredBubbleKeys = hoveredSequence && hoveredSequence.bubbles.map((d2) => d2.key) || [];
82434       let viewer = context.container().select(".photoviewer");
82435       let selected = viewer.empty() ? void 0 : viewer.datum();
82436       let selectedBubbleKey = selected && selected.key;
82437       let selectedSequenceKey = this.getSequenceKeyForBubble(selected);
82438       let selectedSequence = selectedSequenceKey && _ssCache.sequences[selectedSequenceKey];
82439       let selectedBubbleKeys = selectedSequence && selectedSequence.bubbles.map((d2) => d2.key) || [];
82440       let highlightedBubbleKeys = utilArrayUnion(hoveredBubbleKeys, selectedBubbleKeys);
82441       context.container().selectAll(".layer-streetside-images .viewfield-group").classed("highlighted", (d2) => highlightedBubbleKeys.indexOf(d2.key) !== -1).classed("hovered", (d2) => d2.key === hoveredBubbleKey).classed("currentView", (d2) => d2.key === selectedBubbleKey);
82442       context.container().selectAll(".layer-streetside-images .sequence").classed("highlighted", (d2) => d2.properties.key === hoveredSequenceKey).classed("currentView", (d2) => d2.properties.key === selectedSequenceKey);
82443       context.container().selectAll(".layer-streetside-images .viewfield-group .viewfield").attr("d", viewfieldPath);
82444       function viewfieldPath() {
82445         let d2 = this.parentNode.__data__;
82446         if (d2.pano && d2.key !== selectedBubbleKey) {
82447           return "M 8,13 m -10,0 a 10,10 0 1,0 20,0 a 10,10 0 1,0 -20,0";
82448         } else {
82449           return "M 6,9 C 8,8.4 8,8.4 10,9 L 16,-2 C 12,-5 4,-5 0,-2 z";
82450         }
82451       }
82452       return this;
82453     },
82454     updateUrlImage: function(imageKey) {
82455       if (!window.mocha) {
82456         var hash = utilStringQs(window.location.hash);
82457         if (imageKey) {
82458           hash.photo = "streetside/" + imageKey;
82459         } else {
82460           delete hash.photo;
82461         }
82462         window.location.replace("#" + utilQsString(hash, true));
82463       }
82464     },
82465     /**
82466      * cache().
82467      */
82468     cache: function() {
82469       return _ssCache;
82470     }
82471   };
82472
82473   // modules/services/taginfo.js
82474   var apibase4 = taginfoApiUrl;
82475   var _inflight3 = {};
82476   var _popularKeys = {};
82477   var _taginfoCache = {};
82478   var tag_sorts = {
82479     point: "count_nodes",
82480     vertex: "count_nodes",
82481     area: "count_ways",
82482     line: "count_ways"
82483   };
82484   var tag_sort_members = {
82485     point: "count_node_members",
82486     vertex: "count_node_members",
82487     area: "count_way_members",
82488     line: "count_way_members",
82489     relation: "count_relation_members"
82490   };
82491   var tag_filters = {
82492     point: "nodes",
82493     vertex: "nodes",
82494     area: "ways",
82495     line: "ways"
82496   };
82497   var tag_members_fractions = {
82498     point: "count_node_members_fraction",
82499     vertex: "count_node_members_fraction",
82500     area: "count_way_members_fraction",
82501     line: "count_way_members_fraction",
82502     relation: "count_relation_members_fraction"
82503   };
82504   function sets(params, n3, o2) {
82505     if (params.geometry && o2[params.geometry]) {
82506       params[n3] = o2[params.geometry];
82507     }
82508     return params;
82509   }
82510   function setFilter(params) {
82511     return sets(params, "filter", tag_filters);
82512   }
82513   function setSort(params) {
82514     return sets(params, "sortname", tag_sorts);
82515   }
82516   function setSortMembers(params) {
82517     return sets(params, "sortname", tag_sort_members);
82518   }
82519   function clean(params) {
82520     return utilObjectOmit(params, ["geometry", "debounce"]);
82521   }
82522   function filterKeys(type2) {
82523     var count_type = type2 ? "count_" + type2 : "count_all";
82524     return function(d2) {
82525       return Number(d2[count_type]) > 2500 || d2.in_wiki;
82526     };
82527   }
82528   function filterMultikeys(prefix) {
82529     return function(d2) {
82530       var re3 = new RegExp("^" + prefix + "(.*)$", "i");
82531       var matches = d2.key.match(re3) || [];
82532       return matches.length === 2 && matches[1].indexOf(":") === -1;
82533     };
82534   }
82535   function filterValues(allowUpperCase) {
82536     return function(d2) {
82537       if (d2.value.match(/[;,]/) !== null)
82538         return false;
82539       if (!allowUpperCase && d2.value.match(/[A-Z*]/) !== null)
82540         return false;
82541       return d2.count > 100 || d2.in_wiki;
82542     };
82543   }
82544   function filterRoles(geometry) {
82545     return function(d2) {
82546       if (d2.role === "")
82547         return false;
82548       if (d2.role.match(/[A-Z*;,]/) !== null)
82549         return false;
82550       return Number(d2[tag_members_fractions[geometry]]) > 0;
82551     };
82552   }
82553   function valKey(d2) {
82554     return {
82555       value: d2.key,
82556       title: d2.key
82557     };
82558   }
82559   function valKeyDescription(d2) {
82560     var obj = {
82561       value: d2.value,
82562       title: d2.description || d2.value
82563     };
82564     return obj;
82565   }
82566   function roleKey(d2) {
82567     return {
82568       value: d2.role,
82569       title: d2.role
82570     };
82571   }
82572   function sortKeys(a2, b2) {
82573     return a2.key.indexOf(":") === -1 && b2.key.indexOf(":") !== -1 ? -1 : a2.key.indexOf(":") !== -1 && b2.key.indexOf(":") === -1 ? 1 : 0;
82574   }
82575   var debouncedRequest2 = debounce_default(request2, 300, { leading: false });
82576   function request2(url, params, exactMatch, callback, loaded) {
82577     if (_inflight3[url])
82578       return;
82579     if (checkCache(url, params, exactMatch, callback))
82580       return;
82581     var controller = new AbortController();
82582     _inflight3[url] = controller;
82583     json_default(url, { signal: controller.signal }).then(function(result) {
82584       delete _inflight3[url];
82585       if (loaded)
82586         loaded(null, result);
82587     }).catch(function(err) {
82588       delete _inflight3[url];
82589       if (err.name === "AbortError")
82590         return;
82591       if (loaded)
82592         loaded(err.message);
82593     });
82594   }
82595   function checkCache(url, params, exactMatch, callback) {
82596     var rp = params.rp || 25;
82597     var testQuery = params.query || "";
82598     var testUrl = url;
82599     do {
82600       var hit = _taginfoCache[testUrl];
82601       if (hit && (url === testUrl || hit.length < rp)) {
82602         callback(null, hit);
82603         return true;
82604       }
82605       if (exactMatch || !testQuery.length)
82606         return false;
82607       testQuery = testQuery.slice(0, -1);
82608       testUrl = url.replace(/&query=(.*?)&/, "&query=" + testQuery + "&");
82609     } while (testQuery.length >= 0);
82610     return false;
82611   }
82612   var taginfo_default = {
82613     init: function() {
82614       _inflight3 = {};
82615       _taginfoCache = {};
82616       _popularKeys = {
82617         // manually exclude some keys – #5377, #7485
82618         postal_code: true,
82619         full_name: true,
82620         loc_name: true,
82621         reg_name: true,
82622         short_name: true,
82623         sorting_name: true,
82624         artist_name: true,
82625         nat_name: true,
82626         long_name: true,
82627         via: true,
82628         "bridge:name": true
82629       };
82630       var params = {
82631         rp: 100,
82632         sortname: "values_all",
82633         sortorder: "desc",
82634         page: 1,
82635         debounce: false,
82636         lang: _mainLocalizer.languageCode()
82637       };
82638       this.keys(params, function(err, data) {
82639         if (err)
82640           return;
82641         data.forEach(function(d2) {
82642           if (d2.value === "opening_hours")
82643             return;
82644           _popularKeys[d2.value] = true;
82645         });
82646       });
82647     },
82648     reset: function() {
82649       Object.values(_inflight3).forEach(function(controller) {
82650         controller.abort();
82651       });
82652       _inflight3 = {};
82653     },
82654     keys: function(params, callback) {
82655       var doRequest = params.debounce ? debouncedRequest2 : request2;
82656       params = clean(setSort(params));
82657       params = Object.assign({
82658         rp: 10,
82659         sortname: "count_all",
82660         sortorder: "desc",
82661         page: 1,
82662         lang: _mainLocalizer.languageCode()
82663       }, params);
82664       var url = apibase4 + "keys/all?" + utilQsString(params);
82665       doRequest(url, params, false, callback, function(err, d2) {
82666         if (err) {
82667           callback(err);
82668         } else {
82669           var f2 = filterKeys(params.filter);
82670           var result = d2.data.filter(f2).sort(sortKeys).map(valKey);
82671           _taginfoCache[url] = result;
82672           callback(null, result);
82673         }
82674       });
82675     },
82676     multikeys: function(params, callback) {
82677       var doRequest = params.debounce ? debouncedRequest2 : request2;
82678       params = clean(setSort(params));
82679       params = Object.assign({
82680         rp: 25,
82681         sortname: "count_all",
82682         sortorder: "desc",
82683         page: 1,
82684         lang: _mainLocalizer.languageCode()
82685       }, params);
82686       var prefix = params.query;
82687       var url = apibase4 + "keys/all?" + utilQsString(params);
82688       doRequest(url, params, true, callback, function(err, d2) {
82689         if (err) {
82690           callback(err);
82691         } else {
82692           var f2 = filterMultikeys(prefix);
82693           var result = d2.data.filter(f2).map(valKey);
82694           _taginfoCache[url] = result;
82695           callback(null, result);
82696         }
82697       });
82698     },
82699     values: function(params, callback) {
82700       var key = params.key;
82701       if (key && _popularKeys[key]) {
82702         callback(null, []);
82703         return;
82704       }
82705       var doRequest = params.debounce ? debouncedRequest2 : request2;
82706       params = clean(setSort(setFilter(params)));
82707       params = Object.assign({
82708         rp: 25,
82709         sortname: "count_all",
82710         sortorder: "desc",
82711         page: 1,
82712         lang: _mainLocalizer.languageCode()
82713       }, params);
82714       var url = apibase4 + "key/values?" + utilQsString(params);
82715       doRequest(url, params, false, callback, function(err, d2) {
82716         if (err) {
82717           callback(err);
82718         } else {
82719           var allowUpperCase = allowUpperCaseTagValues.test(params.key);
82720           var f2 = filterValues(allowUpperCase);
82721           var result = d2.data.filter(f2).map(valKeyDescription);
82722           _taginfoCache[url] = result;
82723           callback(null, result);
82724         }
82725       });
82726     },
82727     roles: function(params, callback) {
82728       var doRequest = params.debounce ? debouncedRequest2 : request2;
82729       var geometry = params.geometry;
82730       params = clean(setSortMembers(params));
82731       params = Object.assign({
82732         rp: 25,
82733         sortname: "count_all_members",
82734         sortorder: "desc",
82735         page: 1,
82736         lang: _mainLocalizer.languageCode()
82737       }, params);
82738       var url = apibase4 + "relation/roles?" + utilQsString(params);
82739       doRequest(url, params, true, callback, function(err, d2) {
82740         if (err) {
82741           callback(err);
82742         } else {
82743           var f2 = filterRoles(geometry);
82744           var result = d2.data.filter(f2).map(roleKey);
82745           _taginfoCache[url] = result;
82746           callback(null, result);
82747         }
82748       });
82749     },
82750     docs: function(params, callback) {
82751       var doRequest = params.debounce ? debouncedRequest2 : request2;
82752       params = clean(setSort(params));
82753       var path = "key/wiki_pages?";
82754       if (params.value) {
82755         path = "tag/wiki_pages?";
82756       } else if (params.rtype) {
82757         path = "relation/wiki_pages?";
82758       }
82759       var url = apibase4 + path + utilQsString(params);
82760       doRequest(url, params, true, callback, function(err, d2) {
82761         if (err) {
82762           callback(err);
82763         } else {
82764           _taginfoCache[url] = d2.data;
82765           callback(null, d2.data);
82766         }
82767       });
82768     },
82769     apibase: function(_2) {
82770       if (!arguments.length)
82771         return apibase4;
82772       apibase4 = _2;
82773       return this;
82774     }
82775   };
82776
82777   // modules/services/vector_tile.js
82778   var import_fast_deep_equal11 = __toESM(require_fast_deep_equal());
82779   var import_fast_json_stable_stringify2 = __toESM(require_fast_json_stable_stringify());
82780   var import_polygon_clipping = __toESM(require_polygon_clipping_umd());
82781   var import_pbf2 = __toESM(require_pbf());
82782   var import_vector_tile2 = __toESM(require_vector_tile());
82783   var tiler8 = utilTiler().tileSize(512).margin(1);
82784   var dispatch12 = dispatch_default("loadedData");
82785   var _vtCache;
82786   function abortRequest7(controller) {
82787     controller.abort();
82788   }
82789   function vtToGeoJSON(data, tile, mergeCache) {
82790     var vectorTile = new import_vector_tile2.default.VectorTile(new import_pbf2.default(data));
82791     var layers = Object.keys(vectorTile.layers);
82792     if (!Array.isArray(layers)) {
82793       layers = [layers];
82794     }
82795     var features = [];
82796     layers.forEach(function(layerID) {
82797       var layer = vectorTile.layers[layerID];
82798       if (layer) {
82799         for (var i3 = 0; i3 < layer.length; i3++) {
82800           var feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
82801           var geometry = feature3.geometry;
82802           if (geometry.type === "Polygon") {
82803             geometry.type = "MultiPolygon";
82804             geometry.coordinates = [geometry.coordinates];
82805           }
82806           var isClipped = false;
82807           if (geometry.type === "MultiPolygon") {
82808             var featureClip = bboxClip(feature3, tile.extent.rectangle());
82809             if (!(0, import_fast_deep_equal11.default)(feature3.geometry, featureClip.geometry)) {
82810               isClipped = true;
82811             }
82812             if (!feature3.geometry.coordinates.length)
82813               continue;
82814             if (!feature3.geometry.coordinates[0].length)
82815               continue;
82816           }
82817           var featurehash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3));
82818           var propertyhash = utilHashcode((0, import_fast_json_stable_stringify2.default)(feature3.properties || {}));
82819           feature3.__layerID__ = layerID.replace(/[^_a-zA-Z0-9\-]/g, "_");
82820           feature3.__featurehash__ = featurehash;
82821           feature3.__propertyhash__ = propertyhash;
82822           features.push(feature3);
82823           if (isClipped && geometry.type === "MultiPolygon") {
82824             var merged = mergeCache[propertyhash];
82825             if (merged && merged.length) {
82826               var other = merged[0];
82827               var coords = import_polygon_clipping.default.union(
82828                 feature3.geometry.coordinates,
82829                 other.geometry.coordinates
82830               );
82831               if (!coords || !coords.length) {
82832                 continue;
82833               }
82834               merged.push(feature3);
82835               for (var j2 = 0; j2 < merged.length; j2++) {
82836                 merged[j2].geometry.coordinates = coords;
82837                 merged[j2].__featurehash__ = featurehash;
82838               }
82839             } else {
82840               mergeCache[propertyhash] = [feature3];
82841             }
82842           }
82843         }
82844       }
82845     });
82846     return features;
82847   }
82848   function loadTile3(source, tile) {
82849     if (source.loaded[tile.id] || source.inflight[tile.id])
82850       return;
82851     var url = source.template.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace(/\{[t-]y\}/, Math.pow(2, tile.xyz[2]) - tile.xyz[1] - 1).replace(/\{z(oom)?\}/, tile.xyz[2]).replace(/\{switch:([^}]+)\}/, function(s2, r2) {
82852       var subdomains = r2.split(",");
82853       return subdomains[(tile.xyz[0] + tile.xyz[1]) % subdomains.length];
82854     });
82855     var controller = new AbortController();
82856     source.inflight[tile.id] = controller;
82857     fetch(url, { signal: controller.signal }).then(function(response) {
82858       if (!response.ok) {
82859         throw new Error(response.status + " " + response.statusText);
82860       }
82861       source.loaded[tile.id] = [];
82862       delete source.inflight[tile.id];
82863       return response.arrayBuffer();
82864     }).then(function(data) {
82865       if (!data) {
82866         throw new Error("No Data");
82867       }
82868       var z2 = tile.xyz[2];
82869       if (!source.canMerge[z2]) {
82870         source.canMerge[z2] = {};
82871       }
82872       source.loaded[tile.id] = vtToGeoJSON(data, tile, source.canMerge[z2]);
82873       dispatch12.call("loadedData");
82874     }).catch(function() {
82875       source.loaded[tile.id] = [];
82876       delete source.inflight[tile.id];
82877     });
82878   }
82879   var vector_tile_default = {
82880     init: function() {
82881       if (!_vtCache) {
82882         this.reset();
82883       }
82884       this.event = utilRebind(this, dispatch12, "on");
82885     },
82886     reset: function() {
82887       for (var sourceID in _vtCache) {
82888         var source = _vtCache[sourceID];
82889         if (source && source.inflight) {
82890           Object.values(source.inflight).forEach(abortRequest7);
82891         }
82892       }
82893       _vtCache = {};
82894     },
82895     addSource: function(sourceID, template) {
82896       _vtCache[sourceID] = { template, inflight: {}, loaded: {}, canMerge: {} };
82897       return _vtCache[sourceID];
82898     },
82899     data: function(sourceID, projection2) {
82900       var source = _vtCache[sourceID];
82901       if (!source)
82902         return [];
82903       var tiles = tiler8.getTiles(projection2);
82904       var seen = {};
82905       var results = [];
82906       for (var i3 = 0; i3 < tiles.length; i3++) {
82907         var features = source.loaded[tiles[i3].id];
82908         if (!features || !features.length)
82909           continue;
82910         for (var j2 = 0; j2 < features.length; j2++) {
82911           var feature3 = features[j2];
82912           var hash = feature3.__featurehash__;
82913           if (seen[hash])
82914             continue;
82915           seen[hash] = true;
82916           results.push(Object.assign({}, feature3));
82917         }
82918       }
82919       return results;
82920     },
82921     loadTiles: function(sourceID, template, projection2) {
82922       var source = _vtCache[sourceID];
82923       if (!source) {
82924         source = this.addSource(sourceID, template);
82925       }
82926       var tiles = tiler8.getTiles(projection2);
82927       Object.keys(source.inflight).forEach(function(k2) {
82928         var wanted = tiles.find(function(tile) {
82929           return k2 === tile.id;
82930         });
82931         if (!wanted) {
82932           abortRequest7(source.inflight[k2]);
82933           delete source.inflight[k2];
82934         }
82935       });
82936       tiles.forEach(function(tile) {
82937         loadTile3(source, tile);
82938       });
82939     },
82940     cache: function() {
82941       return _vtCache;
82942     }
82943   };
82944
82945   // modules/services/wikidata.js
82946   var apibase5 = "https://www.wikidata.org/w/api.php?";
82947   var _wikidataCache = {};
82948   var wikidata_default = {
82949     init: function() {
82950     },
82951     reset: function() {
82952       _wikidataCache = {};
82953     },
82954     // Search for Wikidata items matching the query
82955     itemsForSearchQuery: function(query, callback, language) {
82956       if (!query) {
82957         if (callback)
82958           callback("No query", {});
82959         return;
82960       }
82961       var lang = this.languagesToQuery()[0];
82962       var url = apibase5 + utilQsString({
82963         action: "wbsearchentities",
82964         format: "json",
82965         formatversion: 2,
82966         search: query,
82967         type: "item",
82968         // the language to search
82969         language: language || lang,
82970         // the language for the label and description in the result
82971         uselang: lang,
82972         limit: 10,
82973         origin: "*"
82974       });
82975       json_default(url).then((result) => {
82976         if (result && result.error) {
82977           if (result.error.code === "badvalue" && result.error.info.includes(lang) && !language && lang.includes("-")) {
82978             this.itemsForSearchQuery(query, callback, lang.split("-")[0]);
82979             return;
82980           } else {
82981             throw new Error(result.error);
82982           }
82983         }
82984         if (callback)
82985           callback(null, result.search || {});
82986       }).catch(function(err) {
82987         if (callback)
82988           callback(err.message, {});
82989       });
82990     },
82991     // Given a Wikipedia language and article title,
82992     // return an array of corresponding Wikidata entities.
82993     itemsByTitle: function(lang, title, callback) {
82994       if (!title) {
82995         if (callback)
82996           callback("No title", {});
82997         return;
82998       }
82999       lang = lang || "en";
83000       var url = apibase5 + utilQsString({
83001         action: "wbgetentities",
83002         format: "json",
83003         formatversion: 2,
83004         sites: lang.replace(/-/g, "_") + "wiki",
83005         titles: title,
83006         languages: "en",
83007         // shrink response by filtering to one language
83008         origin: "*"
83009       });
83010       json_default(url).then(function(result) {
83011         if (result && result.error) {
83012           throw new Error(result.error);
83013         }
83014         if (callback)
83015           callback(null, result.entities || {});
83016       }).catch(function(err) {
83017         if (callback)
83018           callback(err.message, {});
83019       });
83020     },
83021     languagesToQuery: function() {
83022       return _mainLocalizer.localeCodes().map(function(code) {
83023         return code.toLowerCase();
83024       }).filter(function(code) {
83025         return code !== "en-us";
83026       });
83027     },
83028     entityByQID: function(qid, callback) {
83029       if (!qid) {
83030         callback("No qid", {});
83031         return;
83032       }
83033       if (_wikidataCache[qid]) {
83034         if (callback)
83035           callback(null, _wikidataCache[qid]);
83036         return;
83037       }
83038       var langs = this.languagesToQuery();
83039       var url = apibase5 + utilQsString({
83040         action: "wbgetentities",
83041         format: "json",
83042         formatversion: 2,
83043         ids: qid,
83044         props: "labels|descriptions|claims|sitelinks",
83045         sitefilter: langs.map(function(d2) {
83046           return d2 + "wiki";
83047         }).join("|"),
83048         languages: langs.join("|"),
83049         languagefallback: 1,
83050         origin: "*"
83051       });
83052       json_default(url).then(function(result) {
83053         if (result && result.error) {
83054           throw new Error(result.error);
83055         }
83056         if (callback)
83057           callback(null, result.entities[qid] || {});
83058       }).catch(function(err) {
83059         if (callback)
83060           callback(err.message, {});
83061       });
83062     },
83063     // Pass `params` object of the form:
83064     // {
83065     //   qid: 'string'      // brand wikidata  (e.g. 'Q37158')
83066     // }
83067     //
83068     // Get an result object used to display tag documentation
83069     // {
83070     //   title:        'string',
83071     //   description:  'string',
83072     //   editURL:      'string',
83073     //   imageURL:     'string',
83074     //   wiki:         { title: 'string', text: 'string', url: 'string' }
83075     // }
83076     //
83077     getDocs: function(params, callback) {
83078       var langs = this.languagesToQuery();
83079       this.entityByQID(params.qid, function(err, entity) {
83080         if (err || !entity) {
83081           callback(err || "No entity");
83082           return;
83083         }
83084         var i3;
83085         var description;
83086         for (i3 in langs) {
83087           let code = langs[i3];
83088           if (entity.descriptions[code] && entity.descriptions[code].language === code) {
83089             description = entity.descriptions[code];
83090             break;
83091           }
83092         }
83093         if (!description && Object.values(entity.descriptions).length)
83094           description = Object.values(entity.descriptions)[0];
83095         var result = {
83096           title: entity.id,
83097           description: description ? description.value : "",
83098           descriptionLocaleCode: description ? description.language : "",
83099           editURL: "https://www.wikidata.org/wiki/" + entity.id
83100         };
83101         if (entity.claims) {
83102           var imageroot = "https://commons.wikimedia.org/w/index.php";
83103           var props = ["P154", "P18"];
83104           var prop, image;
83105           for (i3 = 0; i3 < props.length; i3++) {
83106             prop = entity.claims[props[i3]];
83107             if (prop && Object.keys(prop).length > 0) {
83108               image = prop[Object.keys(prop)[0]].mainsnak.datavalue.value;
83109               if (image) {
83110                 result.imageURL = imageroot + "?" + utilQsString({
83111                   title: "Special:Redirect/file/" + image,
83112                   width: 400
83113                 });
83114                 break;
83115               }
83116             }
83117           }
83118         }
83119         if (entity.sitelinks) {
83120           var englishLocale = _mainLocalizer.languageCode().toLowerCase() === "en";
83121           for (i3 = 0; i3 < langs.length; i3++) {
83122             var w2 = langs[i3] + "wiki";
83123             if (entity.sitelinks[w2]) {
83124               var title = entity.sitelinks[w2].title;
83125               var tKey = "inspector.wiki_reference";
83126               if (!englishLocale && langs[i3] === "en") {
83127                 tKey = "inspector.wiki_en_reference";
83128               }
83129               result.wiki = {
83130                 title,
83131                 text: tKey,
83132                 url: "https://" + langs[i3] + ".wikipedia.org/wiki/" + title.replace(/ /g, "_")
83133               };
83134               break;
83135             }
83136           }
83137         }
83138         callback(null, result);
83139       });
83140     }
83141   };
83142
83143   // modules/services/wikipedia.js
83144   var endpoint = "https://en.wikipedia.org/w/api.php?";
83145   var wikipedia_default = {
83146     init: function() {
83147     },
83148     reset: function() {
83149     },
83150     search: function(lang, query, callback) {
83151       if (!query) {
83152         if (callback)
83153           callback("No Query", []);
83154         return;
83155       }
83156       lang = lang || "en";
83157       var url = endpoint.replace("en", lang) + utilQsString({
83158         action: "query",
83159         list: "search",
83160         srlimit: "10",
83161         srinfo: "suggestion",
83162         format: "json",
83163         origin: "*",
83164         srsearch: query
83165       });
83166       json_default(url).then(function(result) {
83167         if (result && result.error) {
83168           throw new Error(result.error);
83169         } else if (!result || !result.query || !result.query.search) {
83170           throw new Error("No Results");
83171         }
83172         if (callback) {
83173           var titles = result.query.search.map(function(d2) {
83174             return d2.title;
83175           });
83176           callback(null, titles);
83177         }
83178       }).catch(function(err) {
83179         if (callback)
83180           callback(err, []);
83181       });
83182     },
83183     suggestions: function(lang, query, callback) {
83184       if (!query) {
83185         if (callback)
83186           callback("", []);
83187         return;
83188       }
83189       lang = lang || "en";
83190       var url = endpoint.replace("en", lang) + utilQsString({
83191         action: "opensearch",
83192         namespace: 0,
83193         suggest: "",
83194         format: "json",
83195         origin: "*",
83196         search: query
83197       });
83198       json_default(url).then(function(result) {
83199         if (result && result.error) {
83200           throw new Error(result.error);
83201         } else if (!result || result.length < 2) {
83202           throw new Error("No Results");
83203         }
83204         if (callback)
83205           callback(null, result[1] || []);
83206       }).catch(function(err) {
83207         if (callback)
83208           callback(err.message, []);
83209       });
83210     },
83211     translations: function(lang, title, callback) {
83212       if (!title) {
83213         if (callback)
83214           callback("No Title");
83215         return;
83216       }
83217       var url = endpoint.replace("en", lang) + utilQsString({
83218         action: "query",
83219         prop: "langlinks",
83220         format: "json",
83221         origin: "*",
83222         lllimit: 500,
83223         titles: title
83224       });
83225       json_default(url).then(function(result) {
83226         if (result && result.error) {
83227           throw new Error(result.error);
83228         } else if (!result || !result.query || !result.query.pages) {
83229           throw new Error("No Results");
83230         }
83231         if (callback) {
83232           var list2 = result.query.pages[Object.keys(result.query.pages)[0]];
83233           var translations = {};
83234           if (list2 && list2.langlinks) {
83235             list2.langlinks.forEach(function(d2) {
83236               translations[d2.lang] = d2["*"];
83237             });
83238           }
83239           callback(null, translations);
83240         }
83241       }).catch(function(err) {
83242         if (callback)
83243           callback(err.message);
83244       });
83245     }
83246   };
83247
83248   // modules/services/mapilio.js
83249   var import_pbf3 = __toESM(require_pbf());
83250   var import_rbush12 = __toESM(require_rbush_min());
83251   var import_vector_tile3 = __toESM(require_vector_tile());
83252   var apiUrl2 = "https://end.mapilio.com";
83253   var imageBaseUrl = "https://cdn.mapilio.com/im";
83254   var baseTileUrl2 = "https://geo.mapilio.com/geoserver/gwc/service/wmts?REQUEST=GetTile&SERVICE=WMTS&VERSION=1.0.0&LAYER=mapilio:";
83255   var pointLayer = "map_points";
83256   var lineLayer = "map_roads_line";
83257   var tileStyle = "&STYLE=&TILEMATRIX=EPSG:900913:{z}&TILEMATRIXSET=EPSG:900913&FORMAT=application/vnd.mapbox-vector-tile&TILECOL={x}&TILEROW={y}";
83258   var minZoom3 = 14;
83259   var dispatch13 = dispatch_default("loadedImages", "loadedLines");
83260   var imgZoom3 = zoom_default2().extent([[0, 0], [320, 240]]).translateExtent([[0, 0], [320, 240]]).scaleExtent([1, 15]);
83261   var pannellumViewerCSS3 = "pannellum/pannellum.css";
83262   var pannellumViewerJS3 = "pannellum/pannellum.js";
83263   var resolution = 1080;
83264   var _activeImage;
83265   var _cache4;
83266   var _loadViewerPromise5;
83267   var _pannellumViewer3;
83268   var _sceneOptions2 = {
83269     showFullscreenCtrl: false,
83270     autoLoad: true,
83271     yaw: 0,
83272     minHfov: 10,
83273     maxHfov: 90,
83274     hfov: 60
83275   };
83276   var _currScene2 = 0;
83277   function partitionViewport5(projection2) {
83278     const z2 = geoScaleToZoom(projection2.scale());
83279     const z22 = Math.ceil(z2 * 2) / 2 + 2.5;
83280     const tiler9 = utilTiler().zoomExtent([z22, z22]);
83281     return tiler9.getTiles(projection2).map(function(tile) {
83282       return tile.extent;
83283     });
83284   }
83285   function searchLimited5(limit, projection2, rtree) {
83286     limit = limit || 5;
83287     return partitionViewport5(projection2).reduce(function(result, extent) {
83288       const found = rtree.search(extent.bbox()).slice(0, limit).map(function(d2) {
83289         return d2.data;
83290       });
83291       return found.length ? result.concat(found) : result;
83292     }, []);
83293   }
83294   function loadTiles4(which, url, maxZoom2, projection2) {
83295     const tiler9 = utilTiler().zoomExtent([minZoom3, maxZoom2]).skipNullIsland(true);
83296     const tiles = tiler9.getTiles(projection2);
83297     tiles.forEach(function(tile) {
83298       loadTile4(which, url, tile);
83299     });
83300   }
83301   function loadTile4(which, url, tile) {
83302     const cache = _cache4.requests;
83303     const tileId = "".concat(tile.id, "-").concat(which);
83304     if (cache.loaded[tileId] || cache.inflight[tileId])
83305       return;
83306     const controller = new AbortController();
83307     cache.inflight[tileId] = controller;
83308     const requestUrl = url.replace("{x}", tile.xyz[0]).replace("{y}", tile.xyz[1]).replace("{z}", tile.xyz[2]);
83309     fetch(requestUrl, { signal: controller.signal }).then(function(response) {
83310       if (!response.ok) {
83311         throw new Error(response.status + " " + response.statusText);
83312       }
83313       cache.loaded[tileId] = true;
83314       delete cache.inflight[tileId];
83315       return response.arrayBuffer();
83316     }).then(function(data) {
83317       if (data.byteLength === 0) {
83318         throw new Error("No Data");
83319       }
83320       loadTileDataToCache2(data, tile, which);
83321       if (which === "images") {
83322         dispatch13.call("loadedImages");
83323       } else {
83324         dispatch13.call("loadedLines");
83325       }
83326     }).catch(function(e3) {
83327       if (e3.message === "No Data") {
83328         cache.loaded[tileId] = true;
83329       } else {
83330         console.error(e3);
83331       }
83332     });
83333   }
83334   function loadTileDataToCache2(data, tile) {
83335     const vectorTile = new import_vector_tile3.VectorTile(new import_pbf3.default(data));
83336     let features, cache, layer, i3, feature3, loc, d2;
83337     if (vectorTile.layers.hasOwnProperty(pointLayer)) {
83338       features = [];
83339       cache = _cache4.images;
83340       layer = vectorTile.layers[pointLayer];
83341       for (i3 = 0; i3 < layer.length; i3++) {
83342         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
83343         loc = feature3.geometry.coordinates;
83344         let resolutionArr = feature3.properties.resolution.split("x");
83345         let sourceWidth = Math.max(resolutionArr[0], resolutionArr[1]);
83346         let sourceHeight = Math.min(resolutionArr[0], resolutionArr[1]);
83347         let isPano = sourceWidth % sourceHeight === 0;
83348         d2 = {
83349           loc,
83350           capture_time: feature3.properties.capture_time,
83351           id: feature3.properties.id,
83352           sequence_id: feature3.properties.sequence_uuid,
83353           heading: feature3.properties.heading,
83354           resolution: feature3.properties.resolution,
83355           isPano
83356         };
83357         cache.forImageId[d2.id] = d2;
83358         features.push({
83359           minX: loc[0],
83360           minY: loc[1],
83361           maxX: loc[0],
83362           maxY: loc[1],
83363           data: d2
83364         });
83365       }
83366       if (cache.rtree) {
83367         cache.rtree.load(features);
83368       }
83369     }
83370     if (vectorTile.layers.hasOwnProperty(lineLayer)) {
83371       cache = _cache4.sequences;
83372       layer = vectorTile.layers[lineLayer];
83373       for (i3 = 0; i3 < layer.length; i3++) {
83374         feature3 = layer.feature(i3).toGeoJSON(tile.xyz[0], tile.xyz[1], tile.xyz[2]);
83375         if (cache.lineString[feature3.properties.sequence_uuid]) {
83376           cache.lineString[feature3.properties.sequence_uuid].push(feature3);
83377         } else {
83378           cache.lineString[feature3.properties.sequence_uuid] = [feature3];
83379         }
83380       }
83381     }
83382   }
83383   function getImageData(imageId, sequenceId) {
83384     return fetch(apiUrl2 + "/api/sequence-detail?sequence_uuid=".concat(sequenceId), { method: "GET" }).then(function(response) {
83385       if (!response.ok) {
83386         throw new Error(response.status + " " + response.statusText);
83387       }
83388       return response.json();
83389     }).then(function(data) {
83390       let index = data.data.findIndex((feature3) => feature3.id === imageId);
83391       const { filename, uploaded_hash } = data.data[index];
83392       _sceneOptions2.panorama = imageBaseUrl + "/" + uploaded_hash + "/" + filename + "/" + resolution;
83393     });
83394   }
83395   var mapilio_default = {
83396     // Initialize Mapilio
83397     init: function() {
83398       if (!_cache4) {
83399         this.reset();
83400       }
83401       this.event = utilRebind(this, dispatch13, "on");
83402     },
83403     // Reset cache and state
83404     reset: function() {
83405       if (_cache4) {
83406         Object.values(_cache4.requests.inflight).forEach(function(request3) {
83407           request3.abort();
83408         });
83409       }
83410       _cache4 = {
83411         images: { rtree: new import_rbush12.default(), forImageId: {} },
83412         sequences: { rtree: new import_rbush12.default(), lineString: {} },
83413         requests: { loaded: {}, inflight: {} }
83414       };
83415       _activeImage = null;
83416     },
83417     // Get visible images
83418     images: function(projection2) {
83419       const limit = 5;
83420       return searchLimited5(limit, projection2, _cache4.images.rtree);
83421     },
83422     cachedImage: function(imageKey) {
83423       return _cache4.images.forImageId[imageKey];
83424     },
83425     // Load images in the visible area
83426     loadImages: function(projection2) {
83427       let url = baseTileUrl2 + pointLayer + tileStyle;
83428       loadTiles4("images", url, 14, projection2);
83429     },
83430     // Load line in the visible area
83431     loadLines: function(projection2) {
83432       let url = baseTileUrl2 + lineLayer + tileStyle;
83433       loadTiles4("line", url, 14, projection2);
83434     },
83435     // Get visible sequences
83436     sequences: function(projection2) {
83437       const viewport = projection2.clipExtent();
83438       const min3 = [viewport[0][0], viewport[1][1]];
83439       const max3 = [viewport[1][0], viewport[0][1]];
83440       const bbox2 = geoExtent(projection2.invert(min3), projection2.invert(max3)).bbox();
83441       const sequenceIds = {};
83442       let lineStrings = [];
83443       _cache4.images.rtree.search(bbox2).forEach(function(d2) {
83444         if (d2.data.sequence_id) {
83445           sequenceIds[d2.data.sequence_id] = true;
83446         }
83447       });
83448       Object.keys(sequenceIds).forEach(function(sequenceId) {
83449         if (_cache4.sequences.lineString[sequenceId]) {
83450           lineStrings = lineStrings.concat(_cache4.sequences.lineString[sequenceId]);
83451         }
83452       });
83453       return lineStrings;
83454     },
83455     // Set the currently visible image
83456     setActiveImage: function(image) {
83457       if (image) {
83458         _activeImage = {
83459           id: image.id,
83460           sequence_id: image.sequence_id
83461         };
83462       } else {
83463         _activeImage = null;
83464       }
83465     },
83466     // Update the currently highlighted sequence and selected bubble.
83467     setStyles: function(context, hovered) {
83468       const hoveredImageId = hovered && hovered.id;
83469       const hoveredSequenceId = hovered && hovered.sequence_id;
83470       const selectedSequenceId = _activeImage && _activeImage.sequence_id;
83471       const selectedImageId = _activeImage && _activeImage.id;
83472       const markers = context.container().selectAll(".layer-mapilio .viewfield-group");
83473       const sequences = context.container().selectAll(".layer-mapilio .sequence");
83474       markers.classed("highlighted", function(d2) {
83475         return d2.id === hoveredImageId;
83476       }).classed("hovered", function(d2) {
83477         return d2.id === hoveredImageId;
83478       }).classed("currentView", function(d2) {
83479         return d2.id === selectedImageId;
83480       });
83481       sequences.classed("highlighted", function(d2) {
83482         return d2.properties.sequence_uuid === hoveredSequenceId;
83483       }).classed("currentView", function(d2) {
83484         return d2.properties.sequence_uuid === selectedSequenceId;
83485       });
83486       return this;
83487     },
83488     updateUrlImage: function(imageKey) {
83489       if (!window.mocha) {
83490         var hash = utilStringQs(window.location.hash);
83491         if (imageKey) {
83492           hash.photo = "mapilio/" + imageKey;
83493         } else {
83494           delete hash.photo;
83495         }
83496         window.location.replace("#" + utilQsString(hash, true));
83497       }
83498     },
83499     initViewer: function() {
83500       if (!window.pannellum)
83501         return;
83502       if (_pannellumViewer3)
83503         return;
83504       _currScene2 += 1;
83505       const sceneID = _currScene2.toString();
83506       const options2 = {
83507         "default": { firstScene: sceneID },
83508         scenes: {}
83509       };
83510       options2.scenes[sceneID] = _sceneOptions2;
83511       _pannellumViewer3 = window.pannellum.viewer("ideditor-viewer-mapilio-pnlm", options2);
83512     },
83513     selectImage: function(context, id2) {
83514       let that = this;
83515       let d2 = this.cachedImage(id2);
83516       this.setActiveImage(d2);
83517       this.updateUrlImage(d2.id);
83518       let viewer = context.container().select(".photoviewer");
83519       if (!viewer.empty())
83520         viewer.datum(d2);
83521       this.setStyles(context, null);
83522       if (!d2)
83523         return this;
83524       let wrap2 = context.container().select(".photoviewer .mapilio-wrapper");
83525       let attribution = wrap2.selectAll(".photo-attribution").text("");
83526       if (d2.capture_time) {
83527         attribution.append("span").attr("class", "captured_at").text(localeDateString2(d2.capture_time));
83528         attribution.append("span").text("|");
83529       }
83530       attribution.append("a").attr("class", "image-link").attr("target", "_blank").attr("href", "https://mapilio.com/app?lat=".concat(d2.loc[1], "&lng=").concat(d2.loc[0], "&zoom=17&pId=").concat(d2.id)).text("mapilio.com");
83531       wrap2.transition().duration(100).call(imgZoom3.transform, identity2);
83532       wrap2.selectAll("img").remove();
83533       getImageData(d2.id, d2.sequence_id).then(function() {
83534         if (d2.isPano) {
83535           if (!_pannellumViewer3) {
83536             that.initViewer();
83537           } else {
83538             _currScene2 += 1;
83539             let sceneID = _currScene2.toString();
83540             _pannellumViewer3.addScene(sceneID, _sceneOptions2).loadScene(sceneID);
83541             if (_currScene2 > 2) {
83542               sceneID = (_currScene2 - 1).toString();
83543               _pannellumViewer3.removeScene(sceneID);
83544             }
83545           }
83546         } else {
83547           that.initOnlyPhoto(context);
83548         }
83549       });
83550       function localeDateString2(s2) {
83551         if (!s2)
83552           return null;
83553         var options2 = { day: "numeric", month: "short", year: "numeric" };
83554         var d4 = new Date(s2);
83555         if (isNaN(d4.getTime()))
83556           return null;
83557         return d4.toLocaleDateString(_mainLocalizer.localeCode(), options2);
83558       }
83559       return this;
83560     },
83561     initOnlyPhoto: function(context) {
83562       if (_pannellumViewer3) {
83563         _pannellumViewer3.destroy();
83564         _pannellumViewer3 = null;
83565       }
83566       let wrap2 = context.container().select("#ideditor-viewer-mapilio-simple");
83567       let imgWrap = wrap2.select("img");
83568       if (!imgWrap.empty()) {
83569         imgWrap.attr("src", _sceneOptions2.panorama);
83570       } else {
83571         wrap2.append("img").attr("src", _sceneOptions2.panorama);
83572       }
83573     },
83574     ensureViewerLoaded: function(context) {
83575       let that = this;
83576       let imgWrap = context.container().select("#ideditor-viewer-mapilio-simple > img");
83577       if (!imgWrap.empty()) {
83578         imgWrap.remove();
83579       }
83580       if (_loadViewerPromise5)
83581         return _loadViewerPromise5;
83582       let wrap2 = context.container().select(".photoviewer").selectAll(".mapilio-wrapper").data([0]);
83583       let wrapEnter = wrap2.enter().append("div").attr("class", "photo-wrapper mapilio-wrapper").classed("hide", true).on("dblclick.zoom", null);
83584       wrapEnter.append("div").attr("class", "photo-attribution fillD");
83585       const controlsEnter = wrapEnter.append("div").attr("class", "photo-controls-wrap").append("div").attr("class", "photo-controls-mapilio");
83586       controlsEnter.append("button").on("click.back", step(-1)).text("\u25C4");
83587       controlsEnter.append("button").on("click.forward", step(1)).text("\u25BA");
83588       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-pnlm");
83589       wrapEnter.append("div").attr("id", "ideditor-viewer-mapilio-simple-wrap").call(imgZoom3.on("zoom", zoomPan2)).append("div").attr("id", "ideditor-viewer-mapilio-simple");
83590       context.ui().photoviewer.on("resize.mapilio", () => {
83591         if (_pannellumViewer3) {
83592           _pannellumViewer3.resize();
83593         }
83594       });
83595       _loadViewerPromise5 = new Promise((resolve, reject) => {
83596         let loadedCount = 0;
83597         function loaded() {
83598           loadedCount += 1;
83599           if (loadedCount === 2)
83600             resolve();
83601         }
83602         const head = select_default2("head");
83603         head.selectAll("#ideditor-mapilio-viewercss").data([0]).enter().append("link").attr("id", "ideditor-mapilio-viewercss").attr("rel", "stylesheet").attr("crossorigin", "anonymous").attr("href", context.asset(pannellumViewerCSS3)).on("load.serviceMapilio", loaded).on("error.serviceMapilio", function() {
83604           reject();
83605         });
83606         head.selectAll("#ideditor-mapilio-viewerjs").data([0]).enter().append("script").attr("id", "ideditor-mapilio-viewerjs").attr("crossorigin", "anonymous").attr("src", context.asset(pannellumViewerJS3)).on("load.serviceMapilio", loaded).on("error.serviceMapilio", function() {
83607           reject();
83608         });
83609       }).catch(function() {
83610         _loadViewerPromise5 = null;
83611       });
83612       function step(stepBy) {
83613         return function() {
83614           if (!_activeImage)
83615             return;
83616           const imageId = _activeImage.id;
83617           const nextIndex = imageId + stepBy;
83618           if (!nextIndex)
83619             return;
83620           const nextImage = _cache4.images.forImageId[nextIndex];
83621           context.map().centerEase(nextImage.loc);
83622           that.selectImage(context, nextImage.id);
83623         };
83624       }
83625       function zoomPan2(d3_event) {
83626         var t2 = d3_event.transform;
83627         context.container().select(".photoviewer #ideditor-viewer-mapilio-simple").call(utilSetTransform, t2.x, t2.y, t2.k);
83628       }
83629       return _loadViewerPromise5;
83630     },
83631     showViewer: function(context) {
83632       let wrap2 = context.container().select(".photoviewer").classed("hide", false);
83633       let isHidden = wrap2.selectAll(".photo-wrapper.mapilio-wrapper.hide").size();
83634       if (isHidden) {
83635         wrap2.selectAll(".photo-wrapper:not(.mapilio-wrapper)").classed("hide", true);
83636         wrap2.selectAll(".photo-wrapper.mapilio-wrapper").classed("hide", false);
83637       }
83638       return this;
83639     },
83640     /**
83641      * hideViewer()
83642      */
83643     hideViewer: function(context) {
83644       let viewer = context.container().select(".photoviewer");
83645       if (!viewer.empty())
83646         viewer.datum(null);
83647       this.updateUrlImage(null);
83648       viewer.classed("hide", true).selectAll(".photo-wrapper").classed("hide", true);
83649       context.container().selectAll(".viewfield-group, .sequence, .icon-sign").classed("currentView", false);
83650       this.setActiveImage();
83651       return this.setStyles(context, null);
83652     },
83653     // Return the current cache
83654     cache: function() {
83655       return _cache4;
83656     }
83657   };
83658
83659   // modules/services/index.js
83660   var services = {
83661     geocoder: nominatim_default,
83662     keepRight: keepRight_default,
83663     improveOSM: improveOSM_default,
83664     osmose: osmose_default,
83665     mapillary: mapillary_default,
83666     nsi: nsi_default,
83667     kartaview: kartaview_default,
83668     vegbilder: vegbilder_default,
83669     osm: osm_default,
83670     osmWikibase: osm_wikibase_default,
83671     maprules: maprules_default,
83672     streetside: streetside_default,
83673     taginfo: taginfo_default,
83674     vectorTile: vector_tile_default,
83675     wikidata: wikidata_default,
83676     wikipedia: wikipedia_default,
83677     mapilio: mapilio_default
83678   };
83679
83680   // modules/modes/drag_note.js
83681   function modeDragNote(context) {
83682     var mode = {
83683       id: "drag-note",
83684       button: "browse"
83685     };
83686     var edit2 = behaviorEdit(context);
83687     var _nudgeInterval;
83688     var _lastLoc;
83689     var _note;
83690     function startNudge(d3_event, nudge) {
83691       if (_nudgeInterval)
83692         window.clearInterval(_nudgeInterval);
83693       _nudgeInterval = window.setInterval(function() {
83694         context.map().pan(nudge);
83695         doMove(d3_event, nudge);
83696       }, 50);
83697     }
83698     function stopNudge() {
83699       if (_nudgeInterval) {
83700         window.clearInterval(_nudgeInterval);
83701         _nudgeInterval = null;
83702       }
83703     }
83704     function origin(note) {
83705       return context.projection(note.loc);
83706     }
83707     function start2(d3_event, note) {
83708       _note = note;
83709       var osm = services.osm;
83710       if (osm) {
83711         _note = osm.getNote(_note.id);
83712       }
83713       context.surface().selectAll(".note-" + _note.id).classed("active", true);
83714       context.perform(actionNoop());
83715       context.enter(mode);
83716       context.selectedNoteID(_note.id);
83717     }
83718     function move(d3_event, entity, point2) {
83719       d3_event.stopPropagation();
83720       _lastLoc = context.projection.invert(point2);
83721       doMove(d3_event);
83722       var nudge = geoViewportEdge(point2, context.map().dimensions());
83723       if (nudge) {
83724         startNudge(d3_event, nudge);
83725       } else {
83726         stopNudge();
83727       }
83728     }
83729     function doMove(d3_event, nudge) {
83730       nudge = nudge || [0, 0];
83731       var currPoint = d3_event && d3_event.point || context.projection(_lastLoc);
83732       var currMouse = geoVecSubtract(currPoint, nudge);
83733       var loc = context.projection.invert(currMouse);
83734       _note = _note.move(loc);
83735       var osm = services.osm;
83736       if (osm) {
83737         osm.replaceNote(_note);
83738       }
83739       context.replace(actionNoop());
83740     }
83741     function end() {
83742       context.replace(actionNoop());
83743       context.selectedNoteID(_note.id).enter(modeSelectNote(context, _note.id));
83744     }
83745     var drag = behaviorDrag().selector(".layer-touch.markers .target.note.new").surface(context.container().select(".main-map").node()).origin(origin).on("start", start2).on("move", move).on("end", end);
83746     mode.enter = function() {
83747       context.install(edit2);
83748     };
83749     mode.exit = function() {
83750       context.ui().sidebar.hover.cancel();
83751       context.uninstall(edit2);
83752       context.surface().selectAll(".active").classed("active", false);
83753       stopNudge();
83754     };
83755     mode.behavior = drag;
83756     return mode;
83757   }
83758
83759   // modules/modes/select_data.js
83760   function modeSelectData(context, selectedDatum) {
83761     var mode = {
83762       id: "select-data",
83763       button: "browse"
83764     };
83765     var keybinding = utilKeybinding("select-data");
83766     var dataEditor = uiDataEditor(context);
83767     var behaviors = [
83768       behaviorBreathe(context),
83769       behaviorHover(context),
83770       behaviorSelect(context),
83771       behaviorLasso(context),
83772       modeDragNode(context).behavior,
83773       modeDragNote(context).behavior
83774     ];
83775     function selectData(d3_event, drawn) {
83776       var selection2 = context.surface().selectAll(".layer-mapdata .data" + selectedDatum.__featurehash__);
83777       if (selection2.empty()) {
83778         var source = d3_event && d3_event.type === "zoom" && d3_event.sourceEvent;
83779         if (drawn && source && (source.type === "pointermove" || source.type === "mousemove" || source.type === "touchmove")) {
83780           context.enter(modeBrowse(context));
83781         }
83782       } else {
83783         selection2.classed("selected", true);
83784       }
83785     }
83786     function esc() {
83787       if (context.container().select(".combobox").size())
83788         return;
83789       context.enter(modeBrowse(context));
83790     }
83791     mode.zoomToSelected = function() {
83792       var extent = geoExtent(bounds_default(selectedDatum));
83793       context.map().centerZoomEase(extent.center(), context.map().trimmedExtentZoom(extent));
83794     };
83795     mode.enter = function() {
83796       behaviors.forEach(context.install);
83797       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on("\u238B", esc, true);
83798       select_default2(document).call(keybinding);
83799       selectData();
83800       var sidebar = context.ui().sidebar;
83801       sidebar.show(dataEditor.datum(selectedDatum));
83802       var extent = geoExtent(bounds_default(selectedDatum));
83803       sidebar.expand(sidebar.intersects(extent));
83804       context.map().on("drawn.select-data", selectData);
83805     };
83806     mode.exit = function() {
83807       behaviors.forEach(context.uninstall);
83808       select_default2(document).call(keybinding.unbind);
83809       context.surface().selectAll(".layer-mapdata .selected").classed("selected hover", false);
83810       context.map().on("drawn.select-data", null);
83811       context.ui().sidebar.hide();
83812     };
83813     return mode;
83814   }
83815
83816   // modules/behavior/select.js
83817   function behaviorSelect(context) {
83818     var _tolerancePx = 4;
83819     var _lastMouseEvent = null;
83820     var _showMenu = false;
83821     var _downPointers = {};
83822     var _longPressTimeout = null;
83823     var _lastInteractionType = null;
83824     var _multiselectionPointerId = null;
83825     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
83826     function keydown(d3_event) {
83827       if (d3_event.keyCode === 32) {
83828         var activeNode = document.activeElement;
83829         if (activeNode && (/* @__PURE__ */ new Set(["INPUT", "TEXTAREA"])).has(activeNode.nodeName))
83830           return;
83831       }
83832       if (d3_event.keyCode === 93 || // context menu key
83833       d3_event.keyCode === 32) {
83834         d3_event.preventDefault();
83835       }
83836       if (d3_event.repeat)
83837         return;
83838       cancelLongPress();
83839       if (d3_event.shiftKey) {
83840         context.surface().classed("behavior-multiselect", true);
83841       }
83842       if (d3_event.keyCode === 32) {
83843         if (!_downPointers.spacebar && _lastMouseEvent) {
83844           cancelLongPress();
83845           _longPressTimeout = window.setTimeout(didLongPress, 500, "spacebar", "spacebar");
83846           _downPointers.spacebar = {
83847             firstEvent: _lastMouseEvent,
83848             lastEvent: _lastMouseEvent
83849           };
83850         }
83851       }
83852     }
83853     function keyup(d3_event) {
83854       cancelLongPress();
83855       if (!d3_event.shiftKey) {
83856         context.surface().classed("behavior-multiselect", false);
83857       }
83858       if (d3_event.keyCode === 93) {
83859         d3_event.preventDefault();
83860         _lastInteractionType = "menukey";
83861         contextmenu(d3_event);
83862       } else if (d3_event.keyCode === 32) {
83863         var pointer = _downPointers.spacebar;
83864         if (pointer) {
83865           delete _downPointers.spacebar;
83866           if (pointer.done)
83867             return;
83868           d3_event.preventDefault();
83869           _lastInteractionType = "spacebar";
83870           click(pointer.firstEvent, pointer.lastEvent, "spacebar");
83871         }
83872       }
83873     }
83874     function pointerdown(d3_event) {
83875       var id2 = (d3_event.pointerId || "mouse").toString();
83876       cancelLongPress();
83877       if (d3_event.buttons && d3_event.buttons !== 1)
83878         return;
83879       context.ui().closeEditMenu();
83880       if (d3_event.pointerType !== "mouse") {
83881         _longPressTimeout = window.setTimeout(didLongPress, 500, id2, "longdown-" + (d3_event.pointerType || "mouse"));
83882       }
83883       _downPointers[id2] = {
83884         firstEvent: d3_event,
83885         lastEvent: d3_event
83886       };
83887     }
83888     function didLongPress(id2, interactionType) {
83889       var pointer = _downPointers[id2];
83890       if (!pointer)
83891         return;
83892       for (var i3 in _downPointers) {
83893         _downPointers[i3].done = true;
83894       }
83895       _longPressTimeout = null;
83896       _lastInteractionType = interactionType;
83897       _showMenu = true;
83898       click(pointer.firstEvent, pointer.lastEvent, id2);
83899     }
83900     function pointermove(d3_event) {
83901       var id2 = (d3_event.pointerId || "mouse").toString();
83902       if (_downPointers[id2]) {
83903         _downPointers[id2].lastEvent = d3_event;
83904       }
83905       if (!d3_event.pointerType || d3_event.pointerType === "mouse") {
83906         _lastMouseEvent = d3_event;
83907         if (_downPointers.spacebar) {
83908           _downPointers.spacebar.lastEvent = d3_event;
83909         }
83910       }
83911     }
83912     function pointerup(d3_event) {
83913       var id2 = (d3_event.pointerId || "mouse").toString();
83914       var pointer = _downPointers[id2];
83915       if (!pointer)
83916         return;
83917       delete _downPointers[id2];
83918       if (_multiselectionPointerId === id2) {
83919         _multiselectionPointerId = null;
83920       }
83921       if (pointer.done)
83922         return;
83923       click(pointer.firstEvent, d3_event, id2);
83924     }
83925     function pointercancel(d3_event) {
83926       var id2 = (d3_event.pointerId || "mouse").toString();
83927       if (!_downPointers[id2])
83928         return;
83929       delete _downPointers[id2];
83930       if (_multiselectionPointerId === id2) {
83931         _multiselectionPointerId = null;
83932       }
83933     }
83934     function contextmenu(d3_event) {
83935       d3_event.preventDefault();
83936       if (!+d3_event.clientX && !+d3_event.clientY) {
83937         if (_lastMouseEvent) {
83938           d3_event = _lastMouseEvent;
83939         } else {
83940           return;
83941         }
83942       } else {
83943         _lastMouseEvent = d3_event;
83944         if (d3_event.pointerType === "touch" || d3_event.pointerType === "pen" || d3_event.mozInputSource && // firefox doesn't give a pointerType on contextmenu events
83945         (d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_TOUCH || d3_event.mozInputSource === MouseEvent.MOZ_SOURCE_PEN)) {
83946           _lastInteractionType = "touch";
83947         } else {
83948           _lastInteractionType = "rightclick";
83949         }
83950       }
83951       _showMenu = true;
83952       click(d3_event, d3_event);
83953     }
83954     function click(firstEvent, lastEvent, pointerId) {
83955       cancelLongPress();
83956       var mapNode = context.container().select(".main-map").node();
83957       var pointGetter = utilFastMouse(mapNode);
83958       var p1 = pointGetter(firstEvent);
83959       var p2 = pointGetter(lastEvent);
83960       var dist = geoVecLength(p1, p2);
83961       if (dist > _tolerancePx || !mapContains(lastEvent)) {
83962         resetProperties();
83963         return;
83964       }
83965       var targetDatum = lastEvent.target.__data__;
83966       var multiselectEntityId;
83967       if (!_multiselectionPointerId) {
83968         var selectPointerInfo = pointerDownOnSelection(pointerId);
83969         if (selectPointerInfo) {
83970           _multiselectionPointerId = selectPointerInfo.pointerId;
83971           multiselectEntityId = !selectPointerInfo.selected && selectPointerInfo.entityId;
83972           _downPointers[selectPointerInfo.pointerId].done = true;
83973         }
83974       }
83975       var isMultiselect = context.mode().id === "select" && // and shift key is down
83976       (lastEvent && lastEvent.shiftKey || // or we're lasso-selecting
83977       context.surface().select(".lasso").node() || // or a pointer is down over a selected feature
83978       _multiselectionPointerId && !multiselectEntityId);
83979       processClick(targetDatum, isMultiselect, p2, multiselectEntityId);
83980       function mapContains(event) {
83981         var rect = mapNode.getBoundingClientRect();
83982         return event.clientX >= rect.left && event.clientX <= rect.right && event.clientY >= rect.top && event.clientY <= rect.bottom;
83983       }
83984       function pointerDownOnSelection(skipPointerId) {
83985         var mode = context.mode();
83986         var selectedIDs = mode.id === "select" ? mode.selectedIDs() : [];
83987         for (var pointerId2 in _downPointers) {
83988           if (pointerId2 === "spacebar" || pointerId2 === skipPointerId)
83989             continue;
83990           var pointerInfo = _downPointers[pointerId2];
83991           var p12 = pointGetter(pointerInfo.firstEvent);
83992           var p22 = pointGetter(pointerInfo.lastEvent);
83993           if (geoVecLength(p12, p22) > _tolerancePx)
83994             continue;
83995           var datum2 = pointerInfo.firstEvent.target.__data__;
83996           var entity = datum2 && datum2.properties && datum2.properties.entity || datum2;
83997           if (context.graph().hasEntity(entity.id)) {
83998             return {
83999               pointerId: pointerId2,
84000               entityId: entity.id,
84001               selected: selectedIDs.indexOf(entity.id) !== -1
84002             };
84003           }
84004         }
84005         return null;
84006       }
84007     }
84008     function processClick(datum2, isMultiselect, point2, alsoSelectId) {
84009       var mode = context.mode();
84010       var showMenu = _showMenu;
84011       var interactionType = _lastInteractionType;
84012       var entity = datum2 && datum2.properties && datum2.properties.entity;
84013       if (entity)
84014         datum2 = entity;
84015       if (datum2 && datum2.type === "midpoint") {
84016         datum2 = datum2.parents[0];
84017       }
84018       var newMode;
84019       if (datum2 instanceof osmEntity) {
84020         var selectedIDs = context.selectedIDs();
84021         context.selectedNoteID(null);
84022         context.selectedErrorID(null);
84023         if (!isMultiselect) {
84024           if (!showMenu || selectedIDs.length <= 1 || selectedIDs.indexOf(datum2.id) === -1) {
84025             if (alsoSelectId === datum2.id)
84026               alsoSelectId = null;
84027             selectedIDs = (alsoSelectId ? [alsoSelectId] : []).concat([datum2.id]);
84028             newMode = mode.id === "select" ? mode.selectedIDs(selectedIDs) : modeSelect(context, selectedIDs).selectBehavior(behavior);
84029             context.enter(newMode);
84030           }
84031         } else {
84032           if (selectedIDs.indexOf(datum2.id) !== -1) {
84033             if (!showMenu) {
84034               selectedIDs = selectedIDs.filter(function(id2) {
84035                 return id2 !== datum2.id;
84036               });
84037               newMode = selectedIDs.length ? mode.selectedIDs(selectedIDs) : modeBrowse(context).selectBehavior(behavior);
84038               context.enter(newMode);
84039             }
84040           } else {
84041             selectedIDs = selectedIDs.concat([datum2.id]);
84042             newMode = mode.selectedIDs(selectedIDs);
84043             context.enter(newMode);
84044           }
84045         }
84046       } else if (datum2 && datum2.__featurehash__ && !isMultiselect) {
84047         context.selectedNoteID(null).enter(modeSelectData(context, datum2));
84048       } else if (datum2 instanceof osmNote && !isMultiselect) {
84049         context.selectedNoteID(datum2.id).enter(modeSelectNote(context, datum2.id));
84050       } else if (datum2 instanceof QAItem && !isMultiselect) {
84051         context.selectedErrorID(datum2.id).enter(modeSelectError(context, datum2.id, datum2.service));
84052       } else {
84053         context.selectedNoteID(null);
84054         context.selectedErrorID(null);
84055         if (!isMultiselect && mode.id !== "browse") {
84056           context.enter(modeBrowse(context));
84057         }
84058       }
84059       context.ui().closeEditMenu();
84060       if (showMenu)
84061         context.ui().showEditMenu(point2, interactionType);
84062       resetProperties();
84063     }
84064     function cancelLongPress() {
84065       if (_longPressTimeout)
84066         window.clearTimeout(_longPressTimeout);
84067       _longPressTimeout = null;
84068     }
84069     function resetProperties() {
84070       cancelLongPress();
84071       _showMenu = false;
84072       _lastInteractionType = null;
84073     }
84074     function behavior(selection2) {
84075       resetProperties();
84076       _lastMouseEvent = context.map().lastPointerEvent();
84077       select_default2(window).on("keydown.select", keydown).on("keyup.select", keyup).on(_pointerPrefix + "move.select", pointermove, true).on(_pointerPrefix + "up.select", pointerup, true).on("pointercancel.select", pointercancel, true).on("contextmenu.select-window", function(d3_event) {
84078         var e3 = d3_event;
84079         if (+e3.clientX === 0 && +e3.clientY === 0) {
84080           d3_event.preventDefault();
84081         }
84082       });
84083       selection2.on(_pointerPrefix + "down.select", pointerdown).on("contextmenu.select", contextmenu);
84084     }
84085     behavior.off = function(selection2) {
84086       cancelLongPress();
84087       select_default2(window).on("keydown.select", null).on("keyup.select", null).on("contextmenu.select-window", null).on(_pointerPrefix + "move.select", null, true).on(_pointerPrefix + "up.select", null, true).on("pointercancel.select", null, true);
84088       selection2.on(_pointerPrefix + "down.select", null).on("contextmenu.select", null);
84089       context.surface().classed("behavior-multiselect", false);
84090     };
84091     return behavior;
84092   }
84093
84094   // modules/operations/index.js
84095   var operations_exports = {};
84096   __export(operations_exports, {
84097     operationCircularize: () => operationCircularize,
84098     operationContinue: () => operationContinue,
84099     operationCopy: () => operationCopy,
84100     operationDelete: () => operationDelete,
84101     operationDisconnect: () => operationDisconnect,
84102     operationDowngrade: () => operationDowngrade,
84103     operationExtract: () => operationExtract,
84104     operationMerge: () => operationMerge,
84105     operationMove: () => operationMove,
84106     operationOrthogonalize: () => operationOrthogonalize,
84107     operationPaste: () => operationPaste,
84108     operationReflectLong: () => operationReflectLong,
84109     operationReflectShort: () => operationReflectShort,
84110     operationReverse: () => operationReverse,
84111     operationRotate: () => operationRotate,
84112     operationSplit: () => operationSplit,
84113     operationStraighten: () => operationStraighten
84114   });
84115
84116   // modules/operations/continue.js
84117   function operationContinue(context, selectedIDs) {
84118     var _entities = selectedIDs.map(function(id2) {
84119       return context.graph().entity(id2);
84120     });
84121     var _geometries = Object.assign(
84122       { line: [], vertex: [] },
84123       utilArrayGroupBy(_entities, function(entity) {
84124         return entity.geometry(context.graph());
84125       })
84126     );
84127     var _vertex = _geometries.vertex.length && _geometries.vertex[0];
84128     function candidateWays() {
84129       return _vertex ? context.graph().parentWays(_vertex).filter(function(parent) {
84130         return parent.geometry(context.graph()) === "line" && !parent.isClosed() && parent.affix(_vertex.id) && (_geometries.line.length === 0 || _geometries.line[0] === parent);
84131       }) : [];
84132     }
84133     var _candidates = candidateWays();
84134     var operation2 = function() {
84135       var candidate = _candidates[0];
84136       context.enter(
84137         modeDrawLine(context, candidate.id, context.graph(), "line", candidate.affix(_vertex.id), true)
84138       );
84139     };
84140     operation2.relatedEntityIds = function() {
84141       return _candidates.length ? [_candidates[0].id] : [];
84142     };
84143     operation2.available = function() {
84144       return _geometries.vertex.length === 1 && _geometries.line.length <= 1 && !context.features().hasHiddenConnections(_vertex, context.graph());
84145     };
84146     operation2.disabled = function() {
84147       if (_candidates.length === 0) {
84148         return "not_eligible";
84149       } else if (_candidates.length > 1) {
84150         return "multiple";
84151       }
84152       return false;
84153     };
84154     operation2.tooltip = function() {
84155       var disable = operation2.disabled();
84156       return disable ? _t.append("operations.continue." + disable) : _t.append("operations.continue.description");
84157     };
84158     operation2.annotation = function() {
84159       return _t("operations.continue.annotation.line");
84160     };
84161     operation2.id = "continue";
84162     operation2.keys = [_t("operations.continue.key")];
84163     operation2.title = _t.append("operations.continue.title");
84164     operation2.behavior = behaviorOperation(context).which(operation2);
84165     return operation2;
84166   }
84167
84168   // modules/operations/copy.js
84169   function operationCopy(context, selectedIDs) {
84170     function getFilteredIdsToCopy() {
84171       return selectedIDs.filter(function(selectedID) {
84172         var entity = context.graph().hasEntity(selectedID);
84173         return entity.hasInterestingTags() || entity.geometry(context.graph()) !== "vertex";
84174       });
84175     }
84176     var operation2 = function() {
84177       var graph = context.graph();
84178       var selected = groupEntities(getFilteredIdsToCopy(), graph);
84179       var canCopy = [];
84180       var skip = {};
84181       var entity;
84182       var i3;
84183       for (i3 = 0; i3 < selected.relation.length; i3++) {
84184         entity = selected.relation[i3];
84185         if (!skip[entity.id] && entity.isComplete(graph)) {
84186           canCopy.push(entity.id);
84187           skip = getDescendants(entity.id, graph, skip);
84188         }
84189       }
84190       for (i3 = 0; i3 < selected.way.length; i3++) {
84191         entity = selected.way[i3];
84192         if (!skip[entity.id]) {
84193           canCopy.push(entity.id);
84194           skip = getDescendants(entity.id, graph, skip);
84195         }
84196       }
84197       for (i3 = 0; i3 < selected.node.length; i3++) {
84198         entity = selected.node[i3];
84199         if (!skip[entity.id]) {
84200           canCopy.push(entity.id);
84201         }
84202       }
84203       context.copyIDs(canCopy);
84204       if (_point && (canCopy.length !== 1 || graph.entity(canCopy[0]).type !== "node")) {
84205         context.copyLonLat(context.projection.invert(_point));
84206       } else {
84207         context.copyLonLat(null);
84208       }
84209     };
84210     function groupEntities(ids, graph) {
84211       var entities = ids.map(function(id2) {
84212         return graph.entity(id2);
84213       });
84214       return Object.assign(
84215         { relation: [], way: [], node: [] },
84216         utilArrayGroupBy(entities, "type")
84217       );
84218     }
84219     function getDescendants(id2, graph, descendants) {
84220       var entity = graph.entity(id2);
84221       var children2;
84222       descendants = descendants || {};
84223       if (entity.type === "relation") {
84224         children2 = entity.members.map(function(m2) {
84225           return m2.id;
84226         });
84227       } else if (entity.type === "way") {
84228         children2 = entity.nodes;
84229       } else {
84230         children2 = [];
84231       }
84232       for (var i3 = 0; i3 < children2.length; i3++) {
84233         if (!descendants[children2[i3]]) {
84234           descendants[children2[i3]] = true;
84235           descendants = getDescendants(children2[i3], graph, descendants);
84236         }
84237       }
84238       return descendants;
84239     }
84240     operation2.available = function() {
84241       return getFilteredIdsToCopy().length > 0;
84242     };
84243     operation2.disabled = function() {
84244       var extent = utilTotalExtent(getFilteredIdsToCopy(), context.graph());
84245       if (extent.percentContainedIn(context.map().extent()) < 0.8) {
84246         return "too_large";
84247       }
84248       return false;
84249     };
84250     operation2.availableForKeypress = function() {
84251       var selection2 = window.getSelection && window.getSelection();
84252       return !selection2 || !selection2.toString();
84253     };
84254     operation2.tooltip = function() {
84255       var disable = operation2.disabled();
84256       return disable ? _t.append("operations.copy." + disable, { n: selectedIDs.length }) : _t.append("operations.copy.description", { n: selectedIDs.length });
84257     };
84258     operation2.annotation = function() {
84259       return _t("operations.copy.annotation", { n: selectedIDs.length });
84260     };
84261     var _point;
84262     operation2.point = function(val) {
84263       _point = val;
84264       return operation2;
84265     };
84266     operation2.id = "copy";
84267     operation2.keys = [uiCmd("\u2318C")];
84268     operation2.title = _t.append("operations.copy.title");
84269     operation2.behavior = behaviorOperation(context).which(operation2);
84270     return operation2;
84271   }
84272
84273   // modules/operations/disconnect.js
84274   function operationDisconnect(context, selectedIDs) {
84275     var _vertexIDs = [];
84276     var _wayIDs = [];
84277     var _otherIDs = [];
84278     var _actions = [];
84279     selectedIDs.forEach(function(id2) {
84280       var entity = context.entity(id2);
84281       if (entity.type === "way") {
84282         _wayIDs.push(id2);
84283       } else if (entity.geometry(context.graph()) === "vertex") {
84284         _vertexIDs.push(id2);
84285       } else {
84286         _otherIDs.push(id2);
84287       }
84288     });
84289     var _coords, _descriptionID = "", _annotationID = "features";
84290     var _disconnectingVertexIds = [];
84291     var _disconnectingWayIds = [];
84292     if (_vertexIDs.length > 0) {
84293       _disconnectingVertexIds = _vertexIDs;
84294       _vertexIDs.forEach(function(vertexID) {
84295         var action = actionDisconnect(vertexID);
84296         if (_wayIDs.length > 0) {
84297           var waysIDsForVertex = _wayIDs.filter(function(wayID) {
84298             var way = context.entity(wayID);
84299             return way.nodes.indexOf(vertexID) !== -1;
84300           });
84301           action.limitWays(waysIDsForVertex);
84302         }
84303         _actions.push(action);
84304         _disconnectingWayIds = _disconnectingWayIds.concat(context.graph().parentWays(context.graph().entity(vertexID)).map((d2) => d2.id));
84305       });
84306       _disconnectingWayIds = utilArrayUniq(_disconnectingWayIds).filter(function(id2) {
84307         return _wayIDs.indexOf(id2) === -1;
84308       });
84309       _descriptionID += _actions.length === 1 ? "single_point." : "multiple_points.";
84310       if (_wayIDs.length === 1) {
84311         _descriptionID += "single_way." + context.graph().geometry(_wayIDs[0]);
84312       } else {
84313         _descriptionID += _wayIDs.length === 0 ? "no_ways" : "multiple_ways";
84314       }
84315     } else if (_wayIDs.length > 0) {
84316       var ways = _wayIDs.map(function(id2) {
84317         return context.entity(id2);
84318       });
84319       var nodes = utilGetAllNodes(_wayIDs, context.graph());
84320       _coords = nodes.map(function(n3) {
84321         return n3.loc;
84322       });
84323       var sharedActions = [];
84324       var sharedNodes = [];
84325       var unsharedActions = [];
84326       var unsharedNodes = [];
84327       nodes.forEach(function(node) {
84328         var action = actionDisconnect(node.id).limitWays(_wayIDs);
84329         if (action.disabled(context.graph()) !== "not_connected") {
84330           var count = 0;
84331           for (var i3 in ways) {
84332             var way = ways[i3];
84333             if (way.nodes.indexOf(node.id) !== -1) {
84334               count += 1;
84335             }
84336             if (count > 1)
84337               break;
84338           }
84339           if (count > 1) {
84340             sharedActions.push(action);
84341             sharedNodes.push(node);
84342           } else {
84343             unsharedActions.push(action);
84344             unsharedNodes.push(node);
84345           }
84346         }
84347       });
84348       _descriptionID += "no_points.";
84349       _descriptionID += _wayIDs.length === 1 ? "single_way." : "multiple_ways.";
84350       if (sharedActions.length) {
84351         _actions = sharedActions;
84352         _disconnectingVertexIds = sharedNodes.map((node) => node.id);
84353         _descriptionID += "conjoined";
84354         _annotationID = "from_each_other";
84355       } else {
84356         _actions = unsharedActions;
84357         _disconnectingVertexIds = unsharedNodes.map((node) => node.id);
84358         if (_wayIDs.length === 1) {
84359           _descriptionID += context.graph().geometry(_wayIDs[0]);
84360         } else {
84361           _descriptionID += "separate";
84362         }
84363       }
84364     }
84365     var _extent = utilTotalExtent(_disconnectingVertexIds, context.graph());
84366     var operation2 = function() {
84367       context.perform(function(graph) {
84368         return _actions.reduce(function(graph2, action) {
84369           return action(graph2);
84370         }, graph);
84371       }, operation2.annotation());
84372       context.validator().validate();
84373     };
84374     operation2.relatedEntityIds = function() {
84375       if (_vertexIDs.length) {
84376         return _disconnectingWayIds;
84377       }
84378       return _disconnectingVertexIds;
84379     };
84380     operation2.available = function() {
84381       if (_actions.length === 0)
84382         return false;
84383       if (_otherIDs.length !== 0)
84384         return false;
84385       if (_vertexIDs.length !== 0 && _wayIDs.length !== 0 && !_wayIDs.every(function(wayID) {
84386         return _vertexIDs.some(function(vertexID) {
84387           var way = context.entity(wayID);
84388           return way.nodes.indexOf(vertexID) !== -1;
84389         });
84390       }))
84391         return false;
84392       return true;
84393     };
84394     operation2.disabled = function() {
84395       var reason;
84396       for (var actionIndex in _actions) {
84397         reason = _actions[actionIndex].disabled(context.graph());
84398         if (reason)
84399           return reason;
84400       }
84401       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
84402         return "too_large." + ((_vertexIDs.length ? _vertexIDs : _wayIDs).length === 1 ? "single" : "multiple");
84403       } else if (_coords && someMissing()) {
84404         return "not_downloaded";
84405       } else if (selectedIDs.some(context.hasHiddenConnections)) {
84406         return "connected_to_hidden";
84407       }
84408       return false;
84409       function someMissing() {
84410         if (context.inIntro())
84411           return false;
84412         var osm = context.connection();
84413         if (osm) {
84414           var missing = _coords.filter(function(loc) {
84415             return !osm.isDataLoaded(loc);
84416           });
84417           if (missing.length) {
84418             missing.forEach(function(loc) {
84419               context.loadTileAtLoc(loc);
84420             });
84421             return true;
84422           }
84423         }
84424         return false;
84425       }
84426     };
84427     operation2.tooltip = function() {
84428       var disable = operation2.disabled();
84429       return disable ? _t.append("operations.disconnect." + disable) : _t.append("operations.disconnect.description." + _descriptionID);
84430     };
84431     operation2.annotation = function() {
84432       return _t("operations.disconnect.annotation." + _annotationID);
84433     };
84434     operation2.id = "disconnect";
84435     operation2.keys = [_t("operations.disconnect.key")];
84436     operation2.title = _t.append("operations.disconnect.title");
84437     operation2.behavior = behaviorOperation(context).which(operation2);
84438     return operation2;
84439   }
84440
84441   // modules/operations/downgrade.js
84442   function operationDowngrade(context, selectedIDs) {
84443     var _affectedFeatureCount = 0;
84444     var _downgradeType = downgradeTypeForEntityIDs(selectedIDs);
84445     var _multi = _affectedFeatureCount === 1 ? "single" : "multiple";
84446     function downgradeTypeForEntityIDs(entityIds) {
84447       var downgradeType;
84448       _affectedFeatureCount = 0;
84449       for (var i3 in entityIds) {
84450         var entityID = entityIds[i3];
84451         var type2 = downgradeTypeForEntityID(entityID);
84452         if (type2) {
84453           _affectedFeatureCount += 1;
84454           if (downgradeType && type2 !== downgradeType) {
84455             if (downgradeType !== "generic" && type2 !== "generic") {
84456               downgradeType = "building_address";
84457             } else {
84458               downgradeType = "generic";
84459             }
84460           } else {
84461             downgradeType = type2;
84462           }
84463         }
84464       }
84465       return downgradeType;
84466     }
84467     function downgradeTypeForEntityID(entityID) {
84468       var graph = context.graph();
84469       var entity = graph.entity(entityID);
84470       var preset = _mainPresetIndex.match(entity, graph);
84471       if (!preset || preset.isFallback())
84472         return null;
84473       if (entity.type === "node" && preset.id !== "address" && Object.keys(entity.tags).some(function(key) {
84474         return key.match(/^addr:.{1,}/);
84475       })) {
84476         return "address";
84477       }
84478       var geometry = entity.geometry(graph);
84479       if (geometry === "area" && entity.tags.building && !preset.tags.building) {
84480         return "building";
84481       }
84482       if (geometry === "vertex" && Object.keys(entity.tags).length) {
84483         return "generic";
84484       }
84485       return null;
84486     }
84487     var buildingKeysToKeep = ["architect", "building", "height", "layer", "nycdoitt:bin", "source", "type", "wheelchair"];
84488     var addressKeysToKeep = ["source"];
84489     var operation2 = function() {
84490       context.perform(function(graph) {
84491         for (var i3 in selectedIDs) {
84492           var entityID = selectedIDs[i3];
84493           var type2 = downgradeTypeForEntityID(entityID);
84494           if (!type2)
84495             continue;
84496           var tags = Object.assign({}, graph.entity(entityID).tags);
84497           for (var key in tags) {
84498             if (type2 === "address" && addressKeysToKeep.indexOf(key) !== -1)
84499               continue;
84500             if (type2 === "building") {
84501               if (buildingKeysToKeep.indexOf(key) !== -1 || key.match(/^building:.{1,}/) || key.match(/^roof:.{1,}/))
84502                 continue;
84503             }
84504             if (type2 !== "generic") {
84505               if (key.match(/^addr:.{1,}/) || key.match(/^source:.{1,}/))
84506                 continue;
84507             }
84508             delete tags[key];
84509           }
84510           graph = actionChangeTags(entityID, tags)(graph);
84511         }
84512         return graph;
84513       }, operation2.annotation());
84514       context.validator().validate();
84515       context.enter(modeSelect(context, selectedIDs));
84516     };
84517     operation2.available = function() {
84518       return _downgradeType;
84519     };
84520     operation2.disabled = function() {
84521       if (selectedIDs.some(hasWikidataTag)) {
84522         return "has_wikidata_tag";
84523       }
84524       return false;
84525       function hasWikidataTag(id2) {
84526         var entity = context.entity(id2);
84527         return entity.tags.wikidata && entity.tags.wikidata.trim().length > 0;
84528       }
84529     };
84530     operation2.tooltip = function() {
84531       var disable = operation2.disabled();
84532       return disable ? _t.append("operations.downgrade." + disable + "." + _multi) : _t.append("operations.downgrade.description." + _downgradeType);
84533     };
84534     operation2.annotation = function() {
84535       var suffix;
84536       if (_downgradeType === "building_address") {
84537         suffix = "generic";
84538       } else {
84539         suffix = _downgradeType;
84540       }
84541       return _t("operations.downgrade.annotation." + suffix, { n: _affectedFeatureCount });
84542     };
84543     operation2.id = "downgrade";
84544     operation2.keys = [uiCmd("\u232B")];
84545     operation2.title = _t.append("operations.downgrade.title");
84546     operation2.behavior = behaviorOperation(context).which(operation2);
84547     return operation2;
84548   }
84549
84550   // modules/operations/extract.js
84551   function operationExtract(context, selectedIDs) {
84552     var _amount = selectedIDs.length === 1 ? "single" : "multiple";
84553     var _geometries = utilArrayUniq(selectedIDs.map(function(entityID) {
84554       return context.graph().hasEntity(entityID) && context.graph().geometry(entityID);
84555     }).filter(Boolean));
84556     var _geometryID = _geometries.length === 1 ? _geometries[0] : "feature";
84557     var _extent;
84558     var _actions = selectedIDs.map(function(entityID) {
84559       var graph = context.graph();
84560       var entity = graph.hasEntity(entityID);
84561       if (!entity || !entity.hasInterestingTags())
84562         return null;
84563       if (entity.type === "node" && graph.parentWays(entity).length === 0)
84564         return null;
84565       if (entity.type !== "node") {
84566         var preset = _mainPresetIndex.match(entity, graph);
84567         if (preset.geometry.indexOf("point") === -1)
84568           return null;
84569       }
84570       _extent = _extent ? _extent.extend(entity.extent(graph)) : entity.extent(graph);
84571       return actionExtract(entityID, context.projection);
84572     }).filter(Boolean);
84573     var operation2 = function() {
84574       var combinedAction = function(graph) {
84575         _actions.forEach(function(action) {
84576           graph = action(graph);
84577         });
84578         return graph;
84579       };
84580       context.perform(combinedAction, operation2.annotation());
84581       var extractedNodeIDs = _actions.map(function(action) {
84582         return action.getExtractedNodeID();
84583       });
84584       context.enter(modeSelect(context, extractedNodeIDs));
84585     };
84586     operation2.available = function() {
84587       return _actions.length && selectedIDs.length === _actions.length;
84588     };
84589     operation2.disabled = function() {
84590       if (_extent && _extent.percentContainedIn(context.map().extent()) < 0.8) {
84591         return "too_large";
84592       } else if (selectedIDs.some(function(entityID) {
84593         return context.graph().geometry(entityID) === "vertex" && context.hasHiddenConnections(entityID);
84594       })) {
84595         return "connected_to_hidden";
84596       }
84597       return false;
84598     };
84599     operation2.tooltip = function() {
84600       var disableReason = operation2.disabled();
84601       if (disableReason) {
84602         return _t.append("operations.extract." + disableReason + "." + _amount);
84603       } else {
84604         return _t.append("operations.extract.description." + _geometryID + "." + _amount);
84605       }
84606     };
84607     operation2.annotation = function() {
84608       return _t("operations.extract.annotation", { n: selectedIDs.length });
84609     };
84610     operation2.id = "extract";
84611     operation2.keys = [_t("operations.extract.key")];
84612     operation2.title = _t.append("operations.extract.title");
84613     operation2.behavior = behaviorOperation(context).which(operation2);
84614     return operation2;
84615   }
84616
84617   // modules/operations/merge.js
84618   function operationMerge(context, selectedIDs) {
84619     var _action = getAction();
84620     function getAction() {
84621       var join = actionJoin(selectedIDs);
84622       if (!join.disabled(context.graph()))
84623         return join;
84624       var merge2 = actionMerge(selectedIDs);
84625       if (!merge2.disabled(context.graph()))
84626         return merge2;
84627       var mergePolygon = actionMergePolygon(selectedIDs);
84628       if (!mergePolygon.disabled(context.graph()))
84629         return mergePolygon;
84630       var mergeNodes = actionMergeNodes(selectedIDs);
84631       if (!mergeNodes.disabled(context.graph()))
84632         return mergeNodes;
84633       if (join.disabled(context.graph()) !== "not_eligible")
84634         return join;
84635       if (merge2.disabled(context.graph()) !== "not_eligible")
84636         return merge2;
84637       if (mergePolygon.disabled(context.graph()) !== "not_eligible")
84638         return mergePolygon;
84639       return mergeNodes;
84640     }
84641     var operation2 = function() {
84642       if (operation2.disabled())
84643         return;
84644       context.perform(_action, operation2.annotation());
84645       context.validator().validate();
84646       var resultIDs = selectedIDs.filter(context.hasEntity);
84647       if (resultIDs.length > 1) {
84648         var interestingIDs = resultIDs.filter(function(id2) {
84649           return context.entity(id2).hasInterestingTags();
84650         });
84651         if (interestingIDs.length)
84652           resultIDs = interestingIDs;
84653       }
84654       context.enter(modeSelect(context, resultIDs));
84655     };
84656     operation2.available = function() {
84657       return selectedIDs.length >= 2;
84658     };
84659     operation2.disabled = function() {
84660       var actionDisabled = _action.disabled(context.graph());
84661       if (actionDisabled)
84662         return actionDisabled;
84663       var osm = context.connection();
84664       if (osm && _action.resultingWayNodesLength && _action.resultingWayNodesLength(context.graph()) > osm.maxWayNodes()) {
84665         return "too_many_vertices";
84666       }
84667       return false;
84668     };
84669     operation2.tooltip = function() {
84670       var disabled = operation2.disabled();
84671       if (disabled) {
84672         if (disabled === "conflicting_relations") {
84673           return _t.append("operations.merge.conflicting_relations");
84674         }
84675         if (disabled === "restriction" || disabled === "connectivity") {
84676           return _t.append(
84677             "operations.merge.damage_relation",
84678             { relation: _mainPresetIndex.item("type/" + disabled).name() }
84679           );
84680         }
84681         return _t.append("operations.merge." + disabled);
84682       }
84683       return _t.append("operations.merge.description");
84684     };
84685     operation2.annotation = function() {
84686       return _t("operations.merge.annotation", { n: selectedIDs.length });
84687     };
84688     operation2.id = "merge";
84689     operation2.keys = [_t("operations.merge.key")];
84690     operation2.title = _t.append("operations.merge.title");
84691     operation2.behavior = behaviorOperation(context).which(operation2);
84692     return operation2;
84693   }
84694
84695   // modules/operations/paste.js
84696   function operationPaste(context) {
84697     var _pastePoint;
84698     var operation2 = function() {
84699       if (!_pastePoint)
84700         return;
84701       var oldIDs = context.copyIDs();
84702       if (!oldIDs.length)
84703         return;
84704       var projection2 = context.projection;
84705       var extent = geoExtent();
84706       var oldGraph = context.copyGraph();
84707       var newIDs = [];
84708       var action = actionCopyEntities(oldIDs, oldGraph);
84709       context.perform(action);
84710       var copies = action.copies();
84711       var originals = /* @__PURE__ */ new Set();
84712       Object.values(copies).forEach(function(entity) {
84713         originals.add(entity.id);
84714       });
84715       for (var id2 in copies) {
84716         var oldEntity = oldGraph.entity(id2);
84717         var newEntity = copies[id2];
84718         extent._extend(oldEntity.extent(oldGraph));
84719         var parents = context.graph().parentWays(newEntity);
84720         var parentCopied = parents.some(function(parent) {
84721           return originals.has(parent.id);
84722         });
84723         if (!parentCopied) {
84724           newIDs.push(newEntity.id);
84725         }
84726       }
84727       var copyPoint = context.copyLonLat() && projection2(context.copyLonLat()) || projection2(extent.center());
84728       var delta = geoVecSubtract(_pastePoint, copyPoint);
84729       context.replace(actionMove(newIDs, delta, projection2), operation2.annotation());
84730       context.enter(modeSelect(context, newIDs));
84731     };
84732     operation2.point = function(val) {
84733       _pastePoint = val;
84734       return operation2;
84735     };
84736     operation2.available = function() {
84737       return context.mode().id === "browse";
84738     };
84739     operation2.disabled = function() {
84740       return !context.copyIDs().length;
84741     };
84742     operation2.tooltip = function() {
84743       var oldGraph = context.copyGraph();
84744       var ids = context.copyIDs();
84745       if (!ids.length) {
84746         return _t.append("operations.paste.nothing_copied");
84747       }
84748       return _t.append("operations.paste.description", { feature: utilDisplayLabel(oldGraph.entity(ids[0]), oldGraph), n: ids.length });
84749     };
84750     operation2.annotation = function() {
84751       var ids = context.copyIDs();
84752       return _t("operations.paste.annotation", { n: ids.length });
84753     };
84754     operation2.id = "paste";
84755     operation2.keys = [uiCmd("\u2318V")];
84756     operation2.title = _t.append("operations.paste.title");
84757     return operation2;
84758   }
84759
84760   // modules/operations/reverse.js
84761   function operationReverse(context, selectedIDs) {
84762     var operation2 = function() {
84763       context.perform(function combinedReverseAction(graph) {
84764         actions().forEach(function(action) {
84765           graph = action(graph);
84766         });
84767         return graph;
84768       }, operation2.annotation());
84769       context.validator().validate();
84770     };
84771     function actions(situation) {
84772       return selectedIDs.map(function(entityID) {
84773         var entity = context.hasEntity(entityID);
84774         if (!entity)
84775           return null;
84776         if (situation === "toolbar") {
84777           if (entity.type === "way" && (!entity.isOneWay() && !entity.isSided()))
84778             return null;
84779         }
84780         var geometry = entity.geometry(context.graph());
84781         if (entity.type !== "node" && geometry !== "line")
84782           return null;
84783         var action = actionReverse(entityID);
84784         if (action.disabled(context.graph()))
84785           return null;
84786         return action;
84787       }).filter(Boolean);
84788     }
84789     function reverseTypeID() {
84790       var acts = actions();
84791       var nodeActionCount = acts.filter(function(act) {
84792         var entity = context.hasEntity(act.entityID());
84793         return entity && entity.type === "node";
84794       }).length;
84795       if (nodeActionCount === 0)
84796         return "line";
84797       if (nodeActionCount === acts.length)
84798         return "point";
84799       return "feature";
84800     }
84801     operation2.available = function(situation) {
84802       return actions(situation).length > 0;
84803     };
84804     operation2.disabled = function() {
84805       return false;
84806     };
84807     operation2.tooltip = function() {
84808       return _t.append("operations.reverse.description." + reverseTypeID());
84809     };
84810     operation2.annotation = function() {
84811       var acts = actions();
84812       return _t("operations.reverse.annotation." + reverseTypeID(), { n: acts.length });
84813     };
84814     operation2.id = "reverse";
84815     operation2.keys = [_t("operations.reverse.key")];
84816     operation2.title = _t.append("operations.reverse.title");
84817     operation2.behavior = behaviorOperation(context).which(operation2);
84818     return operation2;
84819   }
84820
84821   // modules/operations/split.js
84822   function operationSplit(context, selectedIDs) {
84823     var _vertexIds = selectedIDs.filter(function(id2) {
84824       return context.graph().geometry(id2) === "vertex";
84825     });
84826     var _selectedWayIds = selectedIDs.filter(function(id2) {
84827       var entity = context.graph().hasEntity(id2);
84828       return entity && entity.type === "way";
84829     });
84830     var _isAvailable = _vertexIds.length > 0 && _vertexIds.length + _selectedWayIds.length === selectedIDs.length;
84831     var _action = actionSplit(_vertexIds);
84832     var _ways = [];
84833     var _geometry = "feature";
84834     var _waysAmount = "single";
84835     var _nodesAmount = _vertexIds.length === 1 ? "single" : "multiple";
84836     if (_isAvailable) {
84837       if (_selectedWayIds.length)
84838         _action.limitWays(_selectedWayIds);
84839       _ways = _action.ways(context.graph());
84840       var geometries = {};
84841       _ways.forEach(function(way) {
84842         geometries[way.geometry(context.graph())] = true;
84843       });
84844       if (Object.keys(geometries).length === 1) {
84845         _geometry = Object.keys(geometries)[0];
84846       }
84847       _waysAmount = _ways.length === 1 ? "single" : "multiple";
84848     }
84849     var operation2 = function() {
84850       var difference2 = context.perform(_action, operation2.annotation());
84851       var idsToSelect = _vertexIds.concat(difference2.extantIDs().filter(function(id2) {
84852         return context.entity(id2).type === "way";
84853       }));
84854       context.enter(modeSelect(context, idsToSelect));
84855     };
84856     operation2.relatedEntityIds = function() {
84857       return _selectedWayIds.length ? [] : _ways.map((way) => way.id);
84858     };
84859     operation2.available = function() {
84860       return _isAvailable;
84861     };
84862     operation2.disabled = function() {
84863       var reason = _action.disabled(context.graph());
84864       if (reason) {
84865         return reason;
84866       } else if (selectedIDs.some(context.hasHiddenConnections)) {
84867         return "connected_to_hidden";
84868       }
84869       return false;
84870     };
84871     operation2.tooltip = function() {
84872       var disable = operation2.disabled();
84873       return disable ? _t.append("operations.split." + disable) : _t.append("operations.split.description." + _geometry + "." + _waysAmount + "." + _nodesAmount + "_node");
84874     };
84875     operation2.annotation = function() {
84876       return _t("operations.split.annotation." + _geometry, { n: _ways.length });
84877     };
84878     operation2.icon = function() {
84879       if (_waysAmount === "multiple") {
84880         return "#iD-operation-split-multiple";
84881       } else {
84882         return "#iD-operation-split";
84883       }
84884     };
84885     operation2.id = "split";
84886     operation2.keys = [_t("operations.split.key")];
84887     operation2.title = _t.append("operations.split.title");
84888     operation2.behavior = behaviorOperation(context).which(operation2);
84889     return operation2;
84890   }
84891
84892   // modules/operations/straighten.js
84893   function operationStraighten(context, selectedIDs) {
84894     var _wayIDs = selectedIDs.filter(function(id2) {
84895       return id2.charAt(0) === "w";
84896     });
84897     var _nodeIDs = selectedIDs.filter(function(id2) {
84898       return id2.charAt(0) === "n";
84899     });
84900     var _amount = (_wayIDs.length ? _wayIDs : _nodeIDs).length === 1 ? "single" : "multiple";
84901     var _nodes = utilGetAllNodes(selectedIDs, context.graph());
84902     var _coords = _nodes.map(function(n3) {
84903       return n3.loc;
84904     });
84905     var _extent = utilTotalExtent(selectedIDs, context.graph());
84906     var _action = chooseAction();
84907     var _geometry;
84908     function chooseAction() {
84909       if (_wayIDs.length === 0 && _nodeIDs.length > 2) {
84910         _geometry = "point";
84911         return actionStraightenNodes(_nodeIDs, context.projection);
84912       } else if (_wayIDs.length > 0 && (_nodeIDs.length === 0 || _nodeIDs.length === 2)) {
84913         var startNodeIDs = [];
84914         var endNodeIDs = [];
84915         for (var i3 = 0; i3 < selectedIDs.length; i3++) {
84916           var entity = context.entity(selectedIDs[i3]);
84917           if (entity.type === "node") {
84918             continue;
84919           } else if (entity.type !== "way" || entity.isClosed()) {
84920             return null;
84921           }
84922           startNodeIDs.push(entity.first());
84923           endNodeIDs.push(entity.last());
84924         }
84925         startNodeIDs = startNodeIDs.filter(function(n3) {
84926           return startNodeIDs.indexOf(n3) === startNodeIDs.lastIndexOf(n3);
84927         });
84928         endNodeIDs = endNodeIDs.filter(function(n3) {
84929           return endNodeIDs.indexOf(n3) === endNodeIDs.lastIndexOf(n3);
84930         });
84931         if (utilArrayDifference(startNodeIDs, endNodeIDs).length + utilArrayDifference(endNodeIDs, startNodeIDs).length !== 2)
84932           return null;
84933         var wayNodeIDs = utilGetAllNodes(_wayIDs, context.graph()).map(function(node) {
84934           return node.id;
84935         });
84936         if (wayNodeIDs.length <= 2)
84937           return null;
84938         if (_nodeIDs.length === 2 && (wayNodeIDs.indexOf(_nodeIDs[0]) === -1 || wayNodeIDs.indexOf(_nodeIDs[1]) === -1))
84939           return null;
84940         if (_nodeIDs.length) {
84941           _extent = utilTotalExtent(_nodeIDs, context.graph());
84942         }
84943         _geometry = "line";
84944         return actionStraightenWay(selectedIDs, context.projection);
84945       }
84946       return null;
84947     }
84948     function operation2() {
84949       if (!_action)
84950         return;
84951       context.perform(_action, operation2.annotation());
84952       window.setTimeout(function() {
84953         context.validator().validate();
84954       }, 300);
84955     }
84956     operation2.available = function() {
84957       return Boolean(_action);
84958     };
84959     operation2.disabled = function() {
84960       var reason = _action.disabled(context.graph());
84961       if (reason) {
84962         return reason;
84963       } else if (_extent.percentContainedIn(context.map().extent()) < 0.8) {
84964         return "too_large";
84965       } else if (someMissing()) {
84966         return "not_downloaded";
84967       } else if (selectedIDs.some(context.hasHiddenConnections)) {
84968         return "connected_to_hidden";
84969       }
84970       return false;
84971       function someMissing() {
84972         if (context.inIntro())
84973           return false;
84974         var osm = context.connection();
84975         if (osm) {
84976           var missing = _coords.filter(function(loc) {
84977             return !osm.isDataLoaded(loc);
84978           });
84979           if (missing.length) {
84980             missing.forEach(function(loc) {
84981               context.loadTileAtLoc(loc);
84982             });
84983             return true;
84984           }
84985         }
84986         return false;
84987       }
84988     };
84989     operation2.tooltip = function() {
84990       var disable = operation2.disabled();
84991       return disable ? _t.append("operations.straighten." + disable + "." + _amount) : _t.append("operations.straighten.description." + _geometry + (_wayIDs.length === 1 ? "" : "s"));
84992     };
84993     operation2.annotation = function() {
84994       return _t("operations.straighten.annotation." + _geometry, { n: _wayIDs.length ? _wayIDs.length : _nodeIDs.length });
84995     };
84996     operation2.id = "straighten";
84997     operation2.keys = [_t("operations.straighten.key")];
84998     operation2.title = _t.append("operations.straighten.title");
84999     operation2.behavior = behaviorOperation(context).which(operation2);
85000     return operation2;
85001   }
85002
85003   // modules/modes/select.js
85004   function modeSelect(context, selectedIDs) {
85005     var mode = {
85006       id: "select",
85007       button: "browse"
85008     };
85009     var keybinding = utilKeybinding("select");
85010     var _breatheBehavior = behaviorBreathe(context);
85011     var _modeDragNode = modeDragNode(context);
85012     var _selectBehavior;
85013     var _behaviors = [];
85014     var _operations = [];
85015     var _newFeature = false;
85016     var _follow = false;
85017     var _focusedParentWayId;
85018     var _focusedVertexIds;
85019     function singular() {
85020       if (selectedIDs && selectedIDs.length === 1) {
85021         return context.hasEntity(selectedIDs[0]);
85022       }
85023     }
85024     function selectedEntities() {
85025       return selectedIDs.map(function(id2) {
85026         return context.hasEntity(id2);
85027       }).filter(Boolean);
85028     }
85029     function checkSelectedIDs() {
85030       var ids = [];
85031       if (Array.isArray(selectedIDs)) {
85032         ids = selectedIDs.filter(function(id2) {
85033           return context.hasEntity(id2);
85034         });
85035       }
85036       if (!ids.length) {
85037         context.enter(modeBrowse(context));
85038         return false;
85039       } else if (selectedIDs.length > 1 && ids.length === 1 || selectedIDs.length === 1 && ids.length > 1) {
85040         context.enter(modeSelect(context, ids));
85041         return false;
85042       }
85043       selectedIDs = ids;
85044       return true;
85045     }
85046     function parentWaysIdsOfSelection(onlyCommonParents) {
85047       var graph = context.graph();
85048       var parents = [];
85049       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
85050         var entity = context.hasEntity(selectedIDs[i3]);
85051         if (!entity || entity.geometry(graph) !== "vertex") {
85052           return [];
85053         }
85054         var currParents = graph.parentWays(entity).map(function(w2) {
85055           return w2.id;
85056         });
85057         if (!parents.length) {
85058           parents = currParents;
85059           continue;
85060         }
85061         parents = (onlyCommonParents ? utilArrayIntersection : utilArrayUnion)(parents, currParents);
85062         if (!parents.length) {
85063           return [];
85064         }
85065       }
85066       return parents;
85067     }
85068     function childNodeIdsOfSelection(onlyCommon) {
85069       var graph = context.graph();
85070       var childs = [];
85071       for (var i3 = 0; i3 < selectedIDs.length; i3++) {
85072         var entity = context.hasEntity(selectedIDs[i3]);
85073         if (!entity || !["area", "line"].includes(entity.geometry(graph))) {
85074           return [];
85075         }
85076         var currChilds = graph.childNodes(entity).map(function(node) {
85077           return node.id;
85078         });
85079         if (!childs.length) {
85080           childs = currChilds;
85081           continue;
85082         }
85083         childs = (onlyCommon ? utilArrayIntersection : utilArrayUnion)(childs, currChilds);
85084         if (!childs.length) {
85085           return [];
85086         }
85087       }
85088       return childs;
85089     }
85090     function checkFocusedParent() {
85091       if (_focusedParentWayId) {
85092         var parents = parentWaysIdsOfSelection(true);
85093         if (parents.indexOf(_focusedParentWayId) === -1)
85094           _focusedParentWayId = null;
85095       }
85096     }
85097     function parentWayIdForVertexNavigation() {
85098       var parentIds = parentWaysIdsOfSelection(true);
85099       if (_focusedParentWayId && parentIds.indexOf(_focusedParentWayId) !== -1) {
85100         return _focusedParentWayId;
85101       }
85102       return parentIds.length ? parentIds[0] : null;
85103     }
85104     mode.selectedIDs = function(val) {
85105       if (!arguments.length)
85106         return selectedIDs;
85107       selectedIDs = val;
85108       return mode;
85109     };
85110     mode.zoomToSelected = function() {
85111       context.map().zoomToEase(selectedEntities());
85112     };
85113     mode.newFeature = function(val) {
85114       if (!arguments.length)
85115         return _newFeature;
85116       _newFeature = val;
85117       return mode;
85118     };
85119     mode.selectBehavior = function(val) {
85120       if (!arguments.length)
85121         return _selectBehavior;
85122       _selectBehavior = val;
85123       return mode;
85124     };
85125     mode.follow = function(val) {
85126       if (!arguments.length)
85127         return _follow;
85128       _follow = val;
85129       return mode;
85130     };
85131     function loadOperations() {
85132       _operations.forEach(function(operation2) {
85133         if (operation2.behavior) {
85134           context.uninstall(operation2.behavior);
85135         }
85136       });
85137       _operations = Object.values(operations_exports).map(function(o2) {
85138         return o2(context, selectedIDs);
85139       }).filter(function(o2) {
85140         return o2.id !== "delete" && o2.id !== "downgrade" && o2.id !== "copy";
85141       }).concat([
85142         // group copy/downgrade/delete operation together at the end of the list
85143         operationCopy(context, selectedIDs),
85144         operationDowngrade(context, selectedIDs),
85145         operationDelete(context, selectedIDs)
85146       ]).filter(function(operation2) {
85147         return operation2.available();
85148       });
85149       _operations.forEach(function(operation2) {
85150         if (operation2.behavior) {
85151           context.install(operation2.behavior);
85152         }
85153       });
85154       context.ui().closeEditMenu();
85155     }
85156     mode.operations = function() {
85157       return _operations;
85158     };
85159     mode.enter = function() {
85160       if (!checkSelectedIDs())
85161         return;
85162       context.features().forceVisible(selectedIDs);
85163       _modeDragNode.restoreSelectedIDs(selectedIDs);
85164       loadOperations();
85165       if (!_behaviors.length) {
85166         if (!_selectBehavior)
85167           _selectBehavior = behaviorSelect(context);
85168         _behaviors = [
85169           behaviorPaste(context),
85170           _breatheBehavior,
85171           behaviorHover(context).on("hover", context.ui().sidebar.hoverModeSelect),
85172           _selectBehavior,
85173           behaviorLasso(context),
85174           _modeDragNode.behavior,
85175           modeDragNote(context).behavior
85176         ];
85177       }
85178       _behaviors.forEach(context.install);
85179       keybinding.on(_t("inspector.zoom_to.key"), mode.zoomToSelected).on(["[", "pgup"], previousVertex).on(["]", "pgdown"], nextVertex).on(["{", uiCmd("\u2318["), "home"], firstVertex).on(["}", uiCmd("\u2318]"), "end"], lastVertex).on(uiCmd("\u21E7\u2190"), nudgeSelection([-10, 0])).on(uiCmd("\u21E7\u2191"), nudgeSelection([0, -10])).on(uiCmd("\u21E7\u2192"), nudgeSelection([10, 0])).on(uiCmd("\u21E7\u2193"), nudgeSelection([0, 10])).on(uiCmd("\u21E7\u2325\u2190"), nudgeSelection([-100, 0])).on(uiCmd("\u21E7\u2325\u2191"), nudgeSelection([0, -100])).on(uiCmd("\u21E7\u2325\u2192"), nudgeSelection([100, 0])).on(uiCmd("\u21E7\u2325\u2193"), nudgeSelection([0, 100])).on(utilKeybinding.plusKeys.map((key) => uiCmd("\u21E7" + key)), scaleSelection(1.05)).on(utilKeybinding.plusKeys.map((key) => uiCmd("\u21E7\u2325" + key)), scaleSelection(Math.pow(1.05, 5))).on(utilKeybinding.minusKeys.map((key) => uiCmd("\u21E7" + key)), scaleSelection(1 / 1.05)).on(utilKeybinding.minusKeys.map((key) => uiCmd("\u21E7\u2325" + key)), scaleSelection(1 / Math.pow(1.05, 5))).on(["\\", "pause"], focusNextParent).on(uiCmd("\u2318\u2191"), selectParent).on(uiCmd("\u2318\u2193"), selectChild).on("\u238B", esc, true);
85180       select_default2(document).call(keybinding);
85181       context.ui().sidebar.select(selectedIDs, _newFeature);
85182       context.history().on("change.select", function() {
85183         loadOperations();
85184         selectElements();
85185       }).on("undone.select", checkSelectedIDs).on("redone.select", checkSelectedIDs);
85186       context.map().on("drawn.select", selectElements).on("crossEditableZoom.select", function() {
85187         selectElements();
85188         _breatheBehavior.restartIfNeeded(context.surface());
85189       });
85190       context.map().doubleUpHandler().on("doubleUp.modeSelect", didDoubleUp);
85191       selectElements();
85192       if (_follow) {
85193         var extent = geoExtent();
85194         var graph = context.graph();
85195         selectedIDs.forEach(function(id2) {
85196           var entity = context.entity(id2);
85197           extent._extend(entity.extent(graph));
85198         });
85199         var loc = extent.center();
85200         context.map().centerEase(loc);
85201         _follow = false;
85202       }
85203       function nudgeSelection(delta) {
85204         return function() {
85205           if (!context.map().withinEditableZoom())
85206             return;
85207           var moveOp = operationMove(context, selectedIDs);
85208           if (moveOp.disabled()) {
85209             context.ui().flash.duration(4e3).iconName("#iD-operation-" + moveOp.id).iconClass("operation disabled").label(moveOp.tooltip())();
85210           } else {
85211             context.perform(actionMove(selectedIDs, delta, context.projection), moveOp.annotation());
85212             context.validator().validate();
85213           }
85214         };
85215       }
85216       function scaleSelection(factor) {
85217         return function() {
85218           if (!context.map().withinEditableZoom())
85219             return;
85220           let nodes = utilGetAllNodes(selectedIDs, context.graph());
85221           let isUp = factor > 1;
85222           if (nodes.length <= 1)
85223             return;
85224           let extent2 = utilTotalExtent(selectedIDs, context.graph());
85225           function scalingDisabled() {
85226             if (tooSmall()) {
85227               return "too_small";
85228             } else if (extent2.percentContainedIn(context.map().extent()) < 0.8) {
85229               return "too_large";
85230             } else if (someMissing() || selectedIDs.some(incompleteRelation)) {
85231               return "not_downloaded";
85232             } else if (selectedIDs.some(context.hasHiddenConnections)) {
85233               return "connected_to_hidden";
85234             }
85235             return false;
85236             function tooSmall() {
85237               if (isUp)
85238                 return false;
85239               let dLon = Math.abs(extent2[1][0] - extent2[0][0]);
85240               let dLat = Math.abs(extent2[1][1] - extent2[0][1]);
85241               return dLon < geoMetersToLon(1, extent2[1][1]) && dLat < geoMetersToLat(1);
85242             }
85243             function someMissing() {
85244               if (context.inIntro())
85245                 return false;
85246               let osm = context.connection();
85247               if (osm) {
85248                 let missing = nodes.filter(function(n3) {
85249                   return !osm.isDataLoaded(n3.loc);
85250                 });
85251                 if (missing.length) {
85252                   missing.forEach(function(loc2) {
85253                     context.loadTileAtLoc(loc2);
85254                   });
85255                   return true;
85256                 }
85257               }
85258               return false;
85259             }
85260             function incompleteRelation(id2) {
85261               let entity = context.entity(id2);
85262               return entity.type === "relation" && !entity.isComplete(context.graph());
85263             }
85264           }
85265           const disabled = scalingDisabled();
85266           if (disabled) {
85267             let multi = selectedIDs.length === 1 ? "single" : "multiple";
85268             context.ui().flash.duration(4e3).iconName("#iD-icon-no").iconClass("operation disabled").label(_t.append("operations.scale." + disabled + "." + multi))();
85269           } else {
85270             const pivot = context.projection(extent2.center());
85271             const annotation = _t("operations.scale.annotation." + (isUp ? "up" : "down") + ".feature", { n: selectedIDs.length });
85272             context.perform(actionScale(selectedIDs, pivot, factor, context.projection), annotation);
85273             context.validator().validate();
85274           }
85275         };
85276       }
85277       function didDoubleUp(d3_event, loc2) {
85278         if (!context.map().withinEditableZoom())
85279           return;
85280         var target = select_default2(d3_event.target);
85281         var datum2 = target.datum();
85282         var entity = datum2 && datum2.properties && datum2.properties.entity;
85283         if (!entity)
85284           return;
85285         if (entity instanceof osmWay && target.classed("target")) {
85286           var choice = geoChooseEdge(context.graph().childNodes(entity), loc2, context.projection);
85287           var prev = entity.nodes[choice.index - 1];
85288           var next = entity.nodes[choice.index];
85289           context.perform(
85290             actionAddMidpoint({ loc: choice.loc, edge: [prev, next] }, osmNode()),
85291             _t("operations.add.annotation.vertex")
85292           );
85293           context.validator().validate();
85294         } else if (entity.type === "midpoint") {
85295           context.perform(
85296             actionAddMidpoint({ loc: entity.loc, edge: entity.edge }, osmNode()),
85297             _t("operations.add.annotation.vertex")
85298           );
85299           context.validator().validate();
85300         }
85301       }
85302       function selectElements() {
85303         if (!checkSelectedIDs())
85304           return;
85305         var surface = context.surface();
85306         surface.selectAll(".selected-member").classed("selected-member", false);
85307         surface.selectAll(".selected").classed("selected", false);
85308         surface.selectAll(".related").classed("related", false);
85309         checkFocusedParent();
85310         if (_focusedParentWayId) {
85311           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
85312         }
85313         if (context.map().withinEditableZoom()) {
85314           surface.selectAll(utilDeepMemberSelector(
85315             selectedIDs,
85316             context.graph(),
85317             true
85318             /* skipMultipolgonMembers */
85319           )).classed("selected-member", true);
85320           surface.selectAll(utilEntityOrDeepMemberSelector(selectedIDs, context.graph())).classed("selected", true);
85321         }
85322       }
85323       function esc() {
85324         if (context.container().select(".combobox").size())
85325           return;
85326         context.enter(modeBrowse(context));
85327       }
85328       function firstVertex(d3_event) {
85329         d3_event.preventDefault();
85330         var entity = singular();
85331         var parentId = parentWayIdForVertexNavigation();
85332         var way;
85333         if (entity && entity.type === "way") {
85334           way = entity;
85335         } else if (parentId) {
85336           way = context.entity(parentId);
85337         }
85338         _focusedParentWayId = way && way.id;
85339         if (way) {
85340           context.enter(
85341             mode.selectedIDs([way.first()]).follow(true)
85342           );
85343         }
85344       }
85345       function lastVertex(d3_event) {
85346         d3_event.preventDefault();
85347         var entity = singular();
85348         var parentId = parentWayIdForVertexNavigation();
85349         var way;
85350         if (entity && entity.type === "way") {
85351           way = entity;
85352         } else if (parentId) {
85353           way = context.entity(parentId);
85354         }
85355         _focusedParentWayId = way && way.id;
85356         if (way) {
85357           context.enter(
85358             mode.selectedIDs([way.last()]).follow(true)
85359           );
85360         }
85361       }
85362       function previousVertex(d3_event) {
85363         d3_event.preventDefault();
85364         var parentId = parentWayIdForVertexNavigation();
85365         _focusedParentWayId = parentId;
85366         if (!parentId)
85367           return;
85368         var way = context.entity(parentId);
85369         var length2 = way.nodes.length;
85370         var curr = way.nodes.indexOf(selectedIDs[0]);
85371         var index = -1;
85372         if (curr > 0) {
85373           index = curr - 1;
85374         } else if (way.isClosed()) {
85375           index = length2 - 2;
85376         }
85377         if (index !== -1) {
85378           context.enter(
85379             mode.selectedIDs([way.nodes[index]]).follow(true)
85380           );
85381         }
85382       }
85383       function nextVertex(d3_event) {
85384         d3_event.preventDefault();
85385         var parentId = parentWayIdForVertexNavigation();
85386         _focusedParentWayId = parentId;
85387         if (!parentId)
85388           return;
85389         var way = context.entity(parentId);
85390         var length2 = way.nodes.length;
85391         var curr = way.nodes.indexOf(selectedIDs[0]);
85392         var index = -1;
85393         if (curr < length2 - 1) {
85394           index = curr + 1;
85395         } else if (way.isClosed()) {
85396           index = 0;
85397         }
85398         if (index !== -1) {
85399           context.enter(
85400             mode.selectedIDs([way.nodes[index]]).follow(true)
85401           );
85402         }
85403       }
85404       function focusNextParent(d3_event) {
85405         d3_event.preventDefault();
85406         var parents = parentWaysIdsOfSelection(true);
85407         if (!parents || parents.length < 2)
85408           return;
85409         var index = parents.indexOf(_focusedParentWayId);
85410         if (index < 0 || index > parents.length - 2) {
85411           _focusedParentWayId = parents[0];
85412         } else {
85413           _focusedParentWayId = parents[index + 1];
85414         }
85415         var surface = context.surface();
85416         surface.selectAll(".related").classed("related", false);
85417         if (_focusedParentWayId) {
85418           surface.selectAll(utilEntitySelector([_focusedParentWayId])).classed("related", true);
85419         }
85420       }
85421       function selectParent(d3_event) {
85422         d3_event.preventDefault();
85423         var currentSelectedIds = mode.selectedIDs();
85424         var parentIds = _focusedParentWayId ? [_focusedParentWayId] : parentWaysIdsOfSelection(false);
85425         if (!parentIds.length)
85426           return;
85427         context.enter(
85428           mode.selectedIDs(parentIds)
85429         );
85430         _focusedVertexIds = currentSelectedIds;
85431       }
85432       function selectChild(d3_event) {
85433         d3_event.preventDefault();
85434         var currentSelectedIds = mode.selectedIDs();
85435         var childIds = _focusedVertexIds ? _focusedVertexIds.filter((id2) => context.hasEntity(id2)) : childNodeIdsOfSelection(true);
85436         if (!childIds || !childIds.length)
85437           return;
85438         if (currentSelectedIds.length === 1)
85439           _focusedParentWayId = currentSelectedIds[0];
85440         context.enter(
85441           mode.selectedIDs(childIds)
85442         );
85443       }
85444     };
85445     mode.exit = function() {
85446       _newFeature = false;
85447       _focusedVertexIds = null;
85448       _operations.forEach(function(operation2) {
85449         if (operation2.behavior) {
85450           context.uninstall(operation2.behavior);
85451         }
85452       });
85453       _operations = [];
85454       _behaviors.forEach(context.uninstall);
85455       select_default2(document).call(keybinding.unbind);
85456       context.ui().closeEditMenu();
85457       context.history().on("change.select", null).on("undone.select", null).on("redone.select", null);
85458       var surface = context.surface();
85459       surface.selectAll(".selected-member").classed("selected-member", false);
85460       surface.selectAll(".selected").classed("selected", false);
85461       surface.selectAll(".highlighted").classed("highlighted", false);
85462       surface.selectAll(".related").classed("related", false);
85463       context.map().on("drawn.select", null);
85464       context.ui().sidebar.hide();
85465       context.features().forceVisible([]);
85466       var entity = singular();
85467       if (_newFeature && entity && entity.type === "relation" && // no tags
85468       Object.keys(entity.tags).length === 0 && // no parent relations
85469       context.graph().parentRelations(entity).length === 0 && // no members or one member with no role
85470       (entity.members.length === 0 || entity.members.length === 1 && !entity.members[0].role)) {
85471         var deleteAction = actionDeleteRelation(
85472           entity.id,
85473           true
85474           /* don't delete untagged members */
85475         );
85476         context.perform(deleteAction, _t("operations.delete.annotation.relation"));
85477         context.validator().validate();
85478       }
85479     };
85480     return mode;
85481   }
85482
85483   // modules/behavior/lasso.js
85484   function behaviorLasso(context) {
85485     var _pointerPrefix = "PointerEvent" in window ? "pointer" : "mouse";
85486     var behavior = function(selection2) {
85487       var lasso;
85488       function pointerdown(d3_event) {
85489         var button = 0;
85490         if (d3_event.button === button && d3_event.shiftKey === true) {
85491           lasso = null;
85492           select_default2(window).on(_pointerPrefix + "move.lasso", pointermove).on(_pointerPrefix + "up.lasso", pointerup);
85493           d3_event.stopPropagation();
85494         }
85495       }
85496       function pointermove() {
85497         if (!lasso) {
85498           lasso = uiLasso(context);
85499           context.surface().call(lasso);
85500         }
85501         lasso.p(context.map().mouse());
85502       }
85503       function normalize2(a2, b2) {
85504         return [
85505           [Math.min(a2[0], b2[0]), Math.min(a2[1], b2[1])],
85506           [Math.max(a2[0], b2[0]), Math.max(a2[1], b2[1])]
85507         ];
85508       }
85509       function lassoed() {
85510         if (!lasso)
85511           return [];
85512         var graph = context.graph();
85513         var limitToNodes;
85514         if (context.map().editableDataEnabled(
85515           true
85516           /* skipZoomCheck */
85517         ) && context.map().isInWideSelection()) {
85518           limitToNodes = new Set(utilGetAllNodes(context.selectedIDs(), graph));
85519         } else if (!context.map().editableDataEnabled()) {
85520           return [];
85521         }
85522         var bounds = lasso.extent().map(context.projection.invert);
85523         var extent = geoExtent(normalize2(bounds[0], bounds[1]));
85524         var intersects = context.history().intersects(extent).filter(function(entity) {
85525           return entity.type === "node" && (!limitToNodes || limitToNodes.has(entity)) && geoPointInPolygon(context.projection(entity.loc), lasso.coordinates) && !context.features().isHidden(entity, graph, entity.geometry(graph));
85526         });
85527         intersects.sort(function(node1, node2) {
85528           var parents1 = graph.parentWays(node1);
85529           var parents2 = graph.parentWays(node2);
85530           if (parents1.length && parents2.length) {
85531             var sharedParents = utilArrayIntersection(parents1, parents2);
85532             if (sharedParents.length) {
85533               var sharedParentNodes = sharedParents[0].nodes;
85534               return sharedParentNodes.indexOf(node1.id) - sharedParentNodes.indexOf(node2.id);
85535             } else {
85536               return Number(parents1[0].id.slice(1)) - Number(parents2[0].id.slice(1));
85537             }
85538           } else if (parents1.length || parents2.length) {
85539             return parents1.length - parents2.length;
85540           }
85541           return node1.loc[0] - node2.loc[0];
85542         });
85543         return intersects.map(function(entity) {
85544           return entity.id;
85545         });
85546       }
85547       function pointerup() {
85548         select_default2(window).on(_pointerPrefix + "move.lasso", null).on(_pointerPrefix + "up.lasso", null);
85549         if (!lasso)
85550           return;
85551         var ids = lassoed();
85552         lasso.close();
85553         if (ids.length) {
85554           context.enter(modeSelect(context, ids));
85555         }
85556       }
85557       selection2.on(_pointerPrefix + "down.lasso", pointerdown);
85558     };
85559     behavior.off = function(selection2) {
85560       selection2.on(_pointerPrefix + "down.lasso", null);
85561     };
85562     return behavior;
85563   }
85564
85565   // modules/modes/browse.js
85566   function modeBrowse(context) {
85567     var mode = {
85568       button: "browse",
85569       id: "browse",
85570       title: _t.append("modes.browse.title"),
85571       description: _t.append("modes.browse.description")
85572     };
85573     var sidebar;
85574     var _selectBehavior;
85575     var _behaviors = [];
85576     mode.selectBehavior = function(val) {
85577       if (!arguments.length)
85578         return _selectBehavior;
85579       _selectBehavior = val;
85580       return mode;
85581     };
85582     mode.enter = function() {
85583       if (!_behaviors.length) {
85584         if (!_selectBehavior)
85585           _selectBehavior = behaviorSelect(context);
85586         _behaviors = [
85587           behaviorPaste(context),
85588           behaviorHover(context).on("hover", context.ui().sidebar.hover),
85589           _selectBehavior,
85590           behaviorLasso(context),
85591           modeDragNode(context).behavior,
85592           modeDragNote(context).behavior
85593         ];
85594       }
85595       _behaviors.forEach(context.install);
85596       if (document.activeElement && document.activeElement.blur) {
85597         document.activeElement.blur();
85598       }
85599       if (sidebar) {
85600         context.ui().sidebar.show(sidebar);
85601       } else {
85602         context.ui().sidebar.select(null);
85603       }
85604     };
85605     mode.exit = function() {
85606       context.ui().sidebar.hover.cancel();
85607       _behaviors.forEach(context.uninstall);
85608       if (sidebar) {
85609         context.ui().sidebar.hide();
85610       }
85611     };
85612     mode.sidebar = function(_2) {
85613       if (!arguments.length)
85614         return sidebar;
85615       sidebar = _2;
85616       return mode;
85617     };
85618     mode.operations = function() {
85619       return [operationPaste(context)];
85620     };
85621     return mode;
85622   }
85623
85624   // modules/behavior/add_way.js
85625   function behaviorAddWay(context) {
85626     var dispatch14 = dispatch_default("start", "startFromWay", "startFromNode");
85627     var draw = behaviorDraw(context);
85628     function behavior(surface) {
85629       draw.on("click", function() {
85630         dispatch14.apply("start", this, arguments);
85631       }).on("clickWay", function() {
85632         dispatch14.apply("startFromWay", this, arguments);
85633       }).on("clickNode", function() {
85634         dispatch14.apply("startFromNode", this, arguments);
85635       }).on("cancel", behavior.cancel).on("finish", behavior.cancel);
85636       context.map().dblclickZoomEnable(false);
85637       surface.call(draw);
85638     }
85639     behavior.off = function(surface) {
85640       surface.call(draw.off);
85641     };
85642     behavior.cancel = function() {
85643       window.setTimeout(function() {
85644         context.map().dblclickZoomEnable(true);
85645       }, 1e3);
85646       context.enter(modeBrowse(context));
85647     };
85648     return utilRebind(behavior, dispatch14, "on");
85649   }
85650
85651   // modules/behavior/hash.js
85652   function behaviorHash(context) {
85653     var _cachedHash = null;
85654     var _latitudeLimit = 90 - 1e-8;
85655     function computedHashParameters() {
85656       var map2 = context.map();
85657       var center = map2.center();
85658       var zoom = map2.zoom();
85659       var precision3 = Math.max(0, Math.ceil(Math.log(zoom) / Math.LN2));
85660       var oldParams = utilObjectOmit(
85661         utilStringQs(window.location.hash),
85662         ["comment", "source", "hashtags", "walkthrough"]
85663       );
85664       var newParams = {};
85665       delete oldParams.id;
85666       var selected = context.selectedIDs().filter(function(id2) {
85667         return context.hasEntity(id2);
85668       });
85669       if (selected.length) {
85670         newParams.id = selected.join(",");
85671       }
85672       newParams.map = zoom.toFixed(2) + "/" + center[1].toFixed(precision3) + "/" + center[0].toFixed(precision3);
85673       return Object.assign(oldParams, newParams);
85674     }
85675     function computedHash() {
85676       return "#" + utilQsString(computedHashParameters(), true);
85677     }
85678     function computedTitle(includeChangeCount) {
85679       var baseTitle = context.documentTitleBase() || "iD";
85680       var contextual;
85681       var changeCount;
85682       var titleID;
85683       var selected = context.selectedIDs().filter(function(id2) {
85684         return context.hasEntity(id2);
85685       });
85686       if (selected.length) {
85687         var firstLabel = utilDisplayLabel(context.entity(selected[0]), context.graph());
85688         if (selected.length > 1) {
85689           contextual = _t("title.labeled_and_more", {
85690             labeled: firstLabel,
85691             count: selected.length - 1
85692           });
85693         } else {
85694           contextual = firstLabel;
85695         }
85696         titleID = "context";
85697       }
85698       if (includeChangeCount) {
85699         changeCount = context.history().difference().summary().length;
85700         if (changeCount > 0) {
85701           titleID = contextual ? "changes_context" : "changes";
85702         }
85703       }
85704       if (titleID) {
85705         return _t("title.format." + titleID, {
85706           changes: changeCount,
85707           base: baseTitle,
85708           context: contextual
85709         });
85710       }
85711       return baseTitle;
85712     }
85713     function updateTitle(includeChangeCount) {
85714       if (!context.setsDocumentTitle())
85715         return;
85716       var newTitle = computedTitle(includeChangeCount);
85717       if (document.title !== newTitle) {
85718         document.title = newTitle;
85719       }
85720     }
85721     function updateHashIfNeeded() {
85722       if (context.inIntro())
85723         return;
85724       var latestHash = computedHash();
85725       if (_cachedHash !== latestHash) {
85726         _cachedHash = latestHash;
85727         window.history.replaceState(null, computedTitle(
85728           false
85729           /* includeChangeCount */
85730         ), latestHash);
85731         updateTitle(
85732           true
85733           /* includeChangeCount */
85734         );
85735         const q2 = utilStringQs(latestHash);
85736         if (q2.map) {
85737           corePreferences("map-location", q2.map);
85738         }
85739       }
85740     }
85741     var _throttledUpdate = throttle_default(updateHashIfNeeded, 500);
85742     var _throttledUpdateTitle = throttle_default(function() {
85743       updateTitle(
85744         true
85745         /* includeChangeCount */
85746       );
85747     }, 500);
85748     function hashchange() {
85749       if (window.location.hash === _cachedHash)
85750         return;
85751       _cachedHash = window.location.hash;
85752       var q2 = utilStringQs(_cachedHash);
85753       var mapArgs = (q2.map || "").split("/").map(Number);
85754       if (mapArgs.length < 3 || mapArgs.some(isNaN)) {
85755         updateHashIfNeeded();
85756       } else {
85757         if (_cachedHash === computedHash())
85758           return;
85759         var mode = context.mode();
85760         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
85761         if (q2.id && mode) {
85762           var ids = q2.id.split(",").filter(function(id2) {
85763             return context.hasEntity(id2);
85764           });
85765           if (ids.length && (mode.id === "browse" || mode.id === "select" && !utilArrayIdentical(mode.selectedIDs(), ids))) {
85766             context.enter(modeSelect(context, ids));
85767             return;
85768           }
85769         }
85770         var center = context.map().center();
85771         var dist = geoSphericalDistance(center, [mapArgs[2], mapArgs[1]]);
85772         var maxdist = 500;
85773         if (mode && mode.id.match(/^draw/) !== null && dist > maxdist) {
85774           context.enter(modeBrowse(context));
85775           return;
85776         }
85777       }
85778     }
85779     function behavior() {
85780       context.map().on("move.behaviorHash", _throttledUpdate);
85781       context.history().on("change.behaviorHash", _throttledUpdateTitle);
85782       context.on("enter.behaviorHash", _throttledUpdate);
85783       select_default2(window).on("hashchange.behaviorHash", hashchange);
85784       var q2 = utilStringQs(window.location.hash);
85785       if (q2.id) {
85786         context.zoomToEntity(q2.id.split(",")[0], !q2.map);
85787       }
85788       if (q2.walkthrough === "true") {
85789         behavior.startWalkthrough = true;
85790       }
85791       if (q2.map) {
85792         behavior.hadLocation = true;
85793       } else if (!q2.id && corePreferences("map-location")) {
85794         const mapArgs = corePreferences("map-location").split("/").map(Number);
85795         context.map().centerZoom([mapArgs[2], Math.min(_latitudeLimit, Math.max(-_latitudeLimit, mapArgs[1]))], mapArgs[0]);
85796         updateHashIfNeeded();
85797         behavior.hadLocation = true;
85798       }
85799       hashchange();
85800       updateTitle(false);
85801     }
85802     behavior.off = function() {
85803       _throttledUpdate.cancel();
85804       _throttledUpdateTitle.cancel();
85805       context.map().on("move.behaviorHash", null);
85806       context.on("enter.behaviorHash", null);
85807       select_default2(window).on("hashchange.behaviorHash", null);
85808       window.location.hash = "";
85809     };
85810     return behavior;
85811   }
85812
85813   // node_modules/d3-brush/src/brush.js
85814   var { abs: abs2, max: max2, min: min2 } = Math;
85815   function number1(e3) {
85816     return [+e3[0], +e3[1]];
85817   }
85818   function number22(e3) {
85819     return [number1(e3[0]), number1(e3[1])];
85820   }
85821   var X3 = {
85822     name: "x",
85823     handles: ["w", "e"].map(type),
85824     input: function(x2, e3) {
85825       return x2 == null ? null : [[+x2[0], e3[0][1]], [+x2[1], e3[1][1]]];
85826     },
85827     output: function(xy) {
85828       return xy && [xy[0][0], xy[1][0]];
85829     }
85830   };
85831   var Y3 = {
85832     name: "y",
85833     handles: ["n", "s"].map(type),
85834     input: function(y2, e3) {
85835       return y2 == null ? null : [[e3[0][0], +y2[0]], [e3[1][0], +y2[1]]];
85836     },
85837     output: function(xy) {
85838       return xy && [xy[0][1], xy[1][1]];
85839     }
85840   };
85841   var XY = {
85842     name: "xy",
85843     handles: ["n", "w", "e", "s", "nw", "ne", "sw", "se"].map(type),
85844     input: function(xy) {
85845       return xy == null ? null : number22(xy);
85846     },
85847     output: function(xy) {
85848       return xy;
85849     }
85850   };
85851   function type(t2) {
85852     return { type: t2 };
85853   }
85854
85855   // modules/index.js
85856   var debug = false;
85857   var d3 = {
85858     dispatch: dispatch_default,
85859     geoMercator: mercator_default,
85860     geoProjection: projection,
85861     polygonArea: area_default3,
85862     polygonCentroid: centroid_default2,
85863     select: select_default2,
85864     selectAll: selectAll_default2,
85865     timerFlush
85866   };
85867
85868   // modules/id.js
85869   window.requestIdleCallback = window.requestIdleCallback || function(cb) {
85870     var start2 = Date.now();
85871     return window.requestAnimationFrame(function() {
85872       cb({
85873         didTimeout: false,
85874         timeRemaining: function() {
85875           return Math.max(0, 50 - (Date.now() - start2));
85876         }
85877       });
85878     });
85879   };
85880   window.cancelIdleCallback = window.cancelIdleCallback || function(id2) {
85881     window.cancelAnimationFrame(id2);
85882   };
85883   window.iD = modules_exports;
85884 })();
85885 //# sourceMappingURL=iD.js.map